From c02b211df6fc54e51ee554c27a6736a11255a764 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Thu, 2 May 2013 08:29:43 -0300 Subject: [media] media: i2c: Convert to devm_kzalloc() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Using the managed function the kfree() calls can be removed from the probe error path and the remove handler. Signed-off-by: Laurent Pinchart Acked-by: Sylwester Nawrocki Acked-by: Lad, Prabhakar Acked-by: Andy Shevchenko Reviewed-by: Benoît Thébaudeau Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/ad9389b.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'drivers/media/i2c/ad9389b.c') diff --git a/drivers/media/i2c/ad9389b.c b/drivers/media/i2c/ad9389b.c index 58344b6c3a55..15043554cc8b 100644 --- a/drivers/media/i2c/ad9389b.c +++ b/drivers/media/i2c/ad9389b.c @@ -1188,15 +1188,14 @@ static int ad9389b_probe(struct i2c_client *client, const struct i2c_device_id * v4l_dbg(1, debug, client, "detecting ad9389b client on address 0x%x\n", client->addr << 1); - state = kzalloc(sizeof(struct ad9389b_state), GFP_KERNEL); + state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL); if (!state) return -ENOMEM; /* Platform data */ if (pdata == NULL) { v4l_err(client, "No platform data!\n"); - err = -ENODEV; - goto err_free; + return -ENODEV; } memcpy(&state->pdata, pdata, sizeof(state->pdata)); @@ -1276,8 +1275,6 @@ err_entity: media_entity_cleanup(&sd->entity); err_hdl: v4l2_ctrl_handler_free(&state->hdl); -err_free: - kfree(state); return err; } @@ -1302,7 +1299,6 @@ static int ad9389b_remove(struct i2c_client *client) v4l2_device_unregister_subdev(sd); media_entity_cleanup(&sd->entity); v4l2_ctrl_handler_free(sd->ctrl_handler); - kfree(get_ad9389b_state(sd)); return 0; } -- cgit v1.2.3