Commit cddc1141 authored by Lee Jones's avatar Lee Jones

mfd: pcf50633: Check return value of platform_device_add()

The return value of platform_device_add() is checked after every
other use throughout the kernel.

We're also sliding in another cheeky dev_err() => dev_warn() change
as we're not actually erroring out here, rather reporting the fact
that something's gone wrong, but carrying on regardless.
Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
parent b87d9a0f
...@@ -195,8 +195,9 @@ static int pcf50633_probe(struct i2c_client *client, ...@@ -195,8 +195,9 @@ static int pcf50633_probe(struct i2c_client *client,
const struct i2c_device_id *ids) const struct i2c_device_id *ids)
{ {
struct pcf50633 *pcf; struct pcf50633 *pcf;
struct platform_device *pdev;
struct pcf50633_platform_data *pdata = dev_get_platdata(&client->dev); struct pcf50633_platform_data *pdata = dev_get_platdata(&client->dev);
int i, ret; int i, j, ret;
int version, variant; int version, variant;
if (!client->irq) { if (!client->irq) {
...@@ -243,9 +244,6 @@ static int pcf50633_probe(struct i2c_client *client, ...@@ -243,9 +244,6 @@ static int pcf50633_probe(struct i2c_client *client,
for (i = 0; i < PCF50633_NUM_REGULATORS; i++) { for (i = 0; i < PCF50633_NUM_REGULATORS; i++) {
struct platform_device *pdev;
int j;
pdev = platform_device_alloc("pcf50633-regulator", i); pdev = platform_device_alloc("pcf50633-regulator", i);
if (!pdev) if (!pdev)
return -ENOMEM; return -ENOMEM;
...@@ -253,25 +251,31 @@ static int pcf50633_probe(struct i2c_client *client, ...@@ -253,25 +251,31 @@ static int pcf50633_probe(struct i2c_client *client,
pdev->dev.parent = pcf->dev; pdev->dev.parent = pcf->dev;
ret = platform_device_add_data(pdev, &pdata->reg_init_data[i], ret = platform_device_add_data(pdev, &pdata->reg_init_data[i],
sizeof(pdata->reg_init_data[i])); sizeof(pdata->reg_init_data[i]));
if (ret) { if (ret)
platform_device_put(pdev); goto err;
for (j = 0; j < i; j++)
platform_device_put(pcf->regulator_pdev[j]); ret = platform_device_add(pdev);
return ret; if (ret)
} goto err;
pcf->regulator_pdev[i] = pdev;
platform_device_add(pdev); pcf->regulator_pdev[i] = pdev;
} }
ret = sysfs_create_group(&client->dev.kobj, &pcf_attr_group); ret = sysfs_create_group(&client->dev.kobj, &pcf_attr_group);
if (ret) if (ret)
dev_err(pcf->dev, "error creating sysfs entries\n"); dev_warn(pcf->dev, "error creating sysfs entries\n");
if (pdata->probe_done) if (pdata->probe_done)
pdata->probe_done(pcf); pdata->probe_done(pcf);
return 0; return 0;
err:
platform_device_put(pdev);
for (j = 0; j < i; j++)
platform_device_put(pcf->regulator_pdev[j]);
return ret;
} }
static int pcf50633_remove(struct i2c_client *client) static int pcf50633_remove(struct i2c_client *client)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment