Commit c981015e authored by Lee Jones's avatar Lee Jones

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: default avatarLee Jones <lee.jones@linaro.org>
parent 93286174
...@@ -244,20 +244,20 @@ static int pcf50633_probe(struct i2c_client *client, ...@@ -244,20 +244,20 @@ 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; struct platform_device *pdev;
int j;
pdev = platform_device_alloc("pcf50633-regulator", i); pdev = platform_device_alloc("pcf50633-regulator", i);
if (!pdev) { if (!pdev)
dev_err(pcf->dev, "Cannot create regulator %d\n", i); return -ENOMEM;
continue;
}
pdev->dev.parent = pcf->dev; pdev->dev.parent = pcf->dev;
if (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])) < 0) { sizeof(pdata->reg_init_data[i]));
if (ret) {
platform_device_put(pdev); platform_device_put(pdev);
dev_err(pcf->dev, "Out of memory for regulator parameters %d\n", for (j = 0; j < i; j++)
i); platform_device_put(pcf->regulator_pdev[j]);
continue; return ret;
} }
pcf->regulator_pdev[i] = pdev; pcf->regulator_pdev[i] = pdev;
......
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