Message ID | 20140623085345.GD8847@lee--X1 |
---|---|
State | New |
Headers | show |
On Mon, 23 Jun 2014 09:53:45 +0100 Lee Jones <lee.jones@linaro.org> wrote: > Hi Alan, > > I'm looking at a patch you wrote which can be foudn below at [1]. Are > you sure it's correct to ignore i.e not return -ENOMEM from > platform_device_add_data() in pcf50633_probe()? I believe if > platform_device_add_data() returns an error we should > platform_device_put() and return immediately. Can you tell me if you > agree. If you don't, would you mind explaining to me why please? I made the change to maximise the chance of things booting up ok, but I agree, its a pointless exercise. If we fail to add the data we should just chuck it. Alan -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
On Tue, 24 Jun 2014, One Thousand Gnomes wrote: > On Mon, 23 Jun 2014 09:53:45 +0100 > Lee Jones <lee.jones@linaro.org> wrote: > > > Hi Alan, > > > > I'm looking at a patch you wrote which can be foudn below at [1]. Are > > you sure it's correct to ignore i.e not return -ENOMEM from > > platform_device_add_data() in pcf50633_probe()? I believe if > > platform_device_add_data() returns an error we should > > platform_device_put() and return immediately. Can you tell me if you > > agree. If you don't, would you mind explaining to me why please? > > I made the change to maximise the chance of things booting up ok, but I > agree, its a pointless exercise. If we fail to add the data we should > just chuck it. Thanks Alan, I'll get a patch out shortly.
diff --git a/drivers/mfd/pcf50633-core.c b/drivers/mfd/pcf50633-core.c index 29c122b..45ce1fb 100644 --- a/drivers/mfd/pcf50633-core.c +++ b/drivers/mfd/pcf50633-core.c @@ -253,8 +253,13 @@ static int __devinit pcf50633_probe(struct i2c_client *client, } pdev->dev.parent = pcf->dev; - platform_device_add_data(pdev, &pdata->reg_init_data[i], - sizeof(pdata->reg_init_data[i])); + if (platform_device_add_data(pdev, &pdata->reg_init_data[i], + sizeof(pdata->reg_init_data[i])) < 0) { + platform_device_put(pdev); + dev_err(pcf->dev, "Out of memory for regulator parameters %d\n", + i); + continue; + } pcf->regulator_pdev[i] = pdev; platform_device_add(pdev);