Message ID | 1345116570-27335-1-git-send-email-sachin.kamat@linaro.org |
---|---|
State | Superseded |
Headers | show |
Hi Sachin, Thanks for the patch. On Thu, Aug 16, 2012 at 04:59:30PM +0530, Sachin Kamat wrote: > devm_kzalloc is a device managed function and makes code a bit > smaller and cleaner. > > Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> > --- > This patch is based on Mauro's re-organized tree > (media_tree staging/for_v3.7) and is compile tested. > --- > drivers/media/i2c/smiapp/smiapp-core.c | 11 ++--------- > 1 files changed, 2 insertions(+), 9 deletions(-) > > diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c > index 1cf914d..7d4280e 100644 > --- a/drivers/media/i2c/smiapp/smiapp-core.c > +++ b/drivers/media/i2c/smiapp/smiapp-core.c > @@ -2801,12 +2801,11 @@ static int smiapp_probe(struct i2c_client *client, > const struct i2c_device_id *devid) > { > struct smiapp_sensor *sensor; > - int rval; > > if (client->dev.platform_data == NULL) > return -ENODEV; > > - sensor = kzalloc(sizeof(*sensor), GFP_KERNEL); > + sensor = devm_kzalloc(&client->dev, sizeof(*sensor), GFP_KERNEL); > if (sensor == NULL) > return -ENOMEM; > I think the same should be done to sensor->nvm. Would you like to change the patch to incorporate the change? I'm fine doing that as well. Cheers,
Hi Sakari, Thanks for reviewing the patch. On 16 August 2012 22:26, Sakari Ailus <sakari.ailus@iki.fi> wrote: > Hi Sachin, > > Thanks for the patch. > > On Thu, Aug 16, 2012 at 04:59:30PM +0530, Sachin Kamat wrote: >> devm_kzalloc is a device managed function and makes code a bit >> smaller and cleaner. >> >> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> >> --- >> This patch is based on Mauro's re-organized tree >> (media_tree staging/for_v3.7) and is compile tested. >> --- >> drivers/media/i2c/smiapp/smiapp-core.c | 11 ++--------- >> 1 files changed, 2 insertions(+), 9 deletions(-) >> >> diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c >> index 1cf914d..7d4280e 100644 >> --- a/drivers/media/i2c/smiapp/smiapp-core.c >> +++ b/drivers/media/i2c/smiapp/smiapp-core.c >> @@ -2801,12 +2801,11 @@ static int smiapp_probe(struct i2c_client *client, >> const struct i2c_device_id *devid) >> { >> struct smiapp_sensor *sensor; >> - int rval; >> >> if (client->dev.platform_data == NULL) >> return -ENODEV; >> >> - sensor = kzalloc(sizeof(*sensor), GFP_KERNEL); >> + sensor = devm_kzalloc(&client->dev, sizeof(*sensor), GFP_KERNEL); >> if (sensor == NULL) >> return -ENOMEM; >> > > I think the same should be done to sensor->nvm. Would you like to change the > patch to incorporate the change? I'm fine doing that as well. Sure. I will send the updated patch shortly. I have also expanded the scope of the patch to use other devm_* functions too. > > Cheers, > > -- > Sakari Ailus > e-mail: sakari.ailus@iki.fi jabber/XMPP/Gmail: sailus@retiisi.org.uk
diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c index 1cf914d..7d4280e 100644 --- a/drivers/media/i2c/smiapp/smiapp-core.c +++ b/drivers/media/i2c/smiapp/smiapp-core.c @@ -2801,12 +2801,11 @@ static int smiapp_probe(struct i2c_client *client, const struct i2c_device_id *devid) { struct smiapp_sensor *sensor; - int rval; if (client->dev.platform_data == NULL) return -ENODEV; - sensor = kzalloc(sizeof(*sensor), GFP_KERNEL); + sensor = devm_kzalloc(&client->dev, sizeof(*sensor), GFP_KERNEL); if (sensor == NULL) return -ENOMEM; @@ -2821,12 +2820,8 @@ static int smiapp_probe(struct i2c_client *client, sensor->src->sensor = sensor; sensor->src->pads[0].flags = MEDIA_PAD_FL_SOURCE; - rval = media_entity_init(&sensor->src->sd.entity, 2, + return media_entity_init(&sensor->src->sd.entity, 2, sensor->src->pads, 0); - if (rval < 0) - kfree(sensor); - - return rval; } static int __exit smiapp_remove(struct i2c_client *client) @@ -2862,8 +2857,6 @@ static int __exit smiapp_remove(struct i2c_client *client) if (sensor->vana) regulator_put(sensor->vana); - kfree(sensor); - return 0; }
devm_kzalloc is a device managed function and makes code a bit smaller and cleaner. Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> --- This patch is based on Mauro's re-organized tree (media_tree staging/for_v3.7) and is compile tested. --- drivers/media/i2c/smiapp/smiapp-core.c | 11 ++--------- 1 files changed, 2 insertions(+), 9 deletions(-)