diff options
author | Lee Jones <lee.jones@linaro.org> | 2014-07-01 12:57:36 +0100 |
---|---|---|
committer | Lee Jones <lee.jones@linaro.org> | 2014-07-09 14:58:14 +0100 |
commit | c981015e55f51d3f9bb3d52d07015f791a6b278d (patch) | |
tree | 22f410561bb2c64cfef76d12cbad9a1165b80012 | |
parent | 932861748053a25848010aecbb15f23f455517b1 (diff) | |
download | linux-c981015e55f51d3f9bb3d52d07015f791a6b278d.tar.bz2 |
mfd: pcf50633: Reconnect -ENOMEM error path
If platform_device_alloc() or platform_device_add_data() fail during
pcf50633_probe(), the current code ignores the return error code and
continues to attempt to allocate new platform devices for each of the
supported regulators. Instead, if any failures occur we should fail
out gracefully by cleaning up after ourselves and return the error.
Signed-off-by: Lee Jones <lee.jones@linaro.org>
-rw-r--r-- | drivers/mfd/pcf50633-core.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/drivers/mfd/pcf50633-core.c b/drivers/mfd/pcf50633-core.c index 41ab5e34d2ac..c87f7a0a53f8 100644 --- a/drivers/mfd/pcf50633-core.c +++ b/drivers/mfd/pcf50633-core.c @@ -244,20 +244,20 @@ static int pcf50633_probe(struct i2c_client *client, for (i = 0; i < PCF50633_NUM_REGULATORS; i++) { struct platform_device *pdev; + int j; pdev = platform_device_alloc("pcf50633-regulator", i); - if (!pdev) { - dev_err(pcf->dev, "Cannot create regulator %d\n", i); - continue; - } + if (!pdev) + return -ENOMEM; pdev->dev.parent = pcf->dev; - if (platform_device_add_data(pdev, &pdata->reg_init_data[i], - sizeof(pdata->reg_init_data[i])) < 0) { + ret = platform_device_add_data(pdev, &pdata->reg_init_data[i], + sizeof(pdata->reg_init_data[i])); + if (ret) { platform_device_put(pdev); - dev_err(pcf->dev, "Out of memory for regulator parameters %d\n", - i); - continue; + for (j = 0; j < i; j++) + platform_device_put(pcf->regulator_pdev[j]); + return ret; } pcf->regulator_pdev[i] = pdev; |