diff options
author | Lee Jones <lee.jones@linaro.org> | 2014-08-18 10:54:06 -0400 |
---|---|---|
committer | Lee Jones <lee.jones@linaro.org> | 2014-09-26 03:15:33 -0400 |
commit | cddc11412d604ad673709e91e7a35e9f10c68b39 (patch) | |
tree | ef3cd8c2e42790fe05861ca9d3b2d55bc993c9a0 | |
parent | b87d9a0fed5828e6cca4c3b02eacbc9c12a9a8e8 (diff) |
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: Lee Jones <lee.jones@linaro.org>
-rw-r--r-- | drivers/mfd/pcf50633-core.c | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/drivers/mfd/pcf50633-core.c b/drivers/mfd/pcf50633-core.c index c87f7a0a53f8..e15c060d2dc7 100644 --- a/drivers/mfd/pcf50633-core.c +++ b/drivers/mfd/pcf50633-core.c | |||
@@ -195,8 +195,9 @@ static int pcf50633_probe(struct i2c_client *client, | |||
195 | const struct i2c_device_id *ids) | 195 | const struct i2c_device_id *ids) |
196 | { | 196 | { |
197 | struct pcf50633 *pcf; | 197 | struct pcf50633 *pcf; |
198 | struct platform_device *pdev; | ||
198 | struct pcf50633_platform_data *pdata = dev_get_platdata(&client->dev); | 199 | struct pcf50633_platform_data *pdata = dev_get_platdata(&client->dev); |
199 | int i, ret; | 200 | int i, j, ret; |
200 | int version, variant; | 201 | int version, variant; |
201 | 202 | ||
202 | if (!client->irq) { | 203 | if (!client->irq) { |
@@ -243,9 +244,6 @@ static int pcf50633_probe(struct i2c_client *client, | |||
243 | 244 | ||
244 | 245 | ||
245 | for (i = 0; i < PCF50633_NUM_REGULATORS; i++) { | 246 | for (i = 0; i < PCF50633_NUM_REGULATORS; i++) { |
246 | struct platform_device *pdev; | ||
247 | int j; | ||
248 | |||
249 | pdev = platform_device_alloc("pcf50633-regulator", i); | 247 | pdev = platform_device_alloc("pcf50633-regulator", i); |
250 | if (!pdev) | 248 | if (!pdev) |
251 | return -ENOMEM; | 249 | return -ENOMEM; |
@@ -253,25 +251,31 @@ static int pcf50633_probe(struct i2c_client *client, | |||
253 | pdev->dev.parent = pcf->dev; | 251 | pdev->dev.parent = pcf->dev; |
254 | ret = platform_device_add_data(pdev, &pdata->reg_init_data[i], | 252 | ret = platform_device_add_data(pdev, &pdata->reg_init_data[i], |
255 | sizeof(pdata->reg_init_data[i])); | 253 | sizeof(pdata->reg_init_data[i])); |
256 | if (ret) { | 254 | if (ret) |
257 | platform_device_put(pdev); | 255 | goto err; |
258 | for (j = 0; j < i; j++) | 256 | |
259 | platform_device_put(pcf->regulator_pdev[j]); | 257 | ret = platform_device_add(pdev); |
260 | return ret; | 258 | if (ret) |
261 | } | 259 | goto err; |
262 | pcf->regulator_pdev[i] = pdev; | ||
263 | 260 | ||
264 | platform_device_add(pdev); | 261 | pcf->regulator_pdev[i] = pdev; |
265 | } | 262 | } |
266 | 263 | ||
267 | ret = sysfs_create_group(&client->dev.kobj, &pcf_attr_group); | 264 | ret = sysfs_create_group(&client->dev.kobj, &pcf_attr_group); |
268 | if (ret) | 265 | if (ret) |
269 | dev_err(pcf->dev, "error creating sysfs entries\n"); | 266 | dev_warn(pcf->dev, "error creating sysfs entries\n"); |
270 | 267 | ||
271 | if (pdata->probe_done) | 268 | if (pdata->probe_done) |
272 | pdata->probe_done(pcf); | 269 | pdata->probe_done(pcf); |
273 | 270 | ||
274 | return 0; | 271 | return 0; |
272 | |||
273 | err: | ||
274 | platform_device_put(pdev); | ||
275 | for (j = 0; j < i; j++) | ||
276 | platform_device_put(pcf->regulator_pdev[j]); | ||
277 | |||
278 | return ret; | ||
275 | } | 279 | } |
276 | 280 | ||
277 | static int pcf50633_remove(struct i2c_client *client) | 281 | static int pcf50633_remove(struct i2c_client *client) |