aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/i2c/tvp5150.c
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2013-05-02 07:29:43 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2013-05-21 06:52:15 -0400
commitc02b211df6fc54e51ee554c27a6736a11255a764 (patch)
treea2b78b3a7a0400550fdd89da110d1b21a9e1acb1 /drivers/media/i2c/tvp5150.c
parent95323361e5313733a54771c5059f5b352adbf32c (diff)
[media] media: i2c: Convert to devm_kzalloc()
Using the managed function the kfree() calls can be removed from the probe error path and the remove handler. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com> Acked-by: Lad, Prabhakar <prabhakar.csengg@gmail.com> Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/i2c/tvp5150.c')
-rw-r--r--drivers/media/i2c/tvp5150.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c
index 485159a3c0b7..de9db3bf1ebd 100644
--- a/drivers/media/i2c/tvp5150.c
+++ b/drivers/media/i2c/tvp5150.c
@@ -1152,10 +1152,9 @@ static int tvp5150_probe(struct i2c_client *c,
1152 I2C_FUNC_SMBUS_READ_BYTE | I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) 1152 I2C_FUNC_SMBUS_READ_BYTE | I2C_FUNC_SMBUS_WRITE_BYTE_DATA))
1153 return -EIO; 1153 return -EIO;
1154 1154
1155 core = kzalloc(sizeof(struct tvp5150), GFP_KERNEL); 1155 core = devm_kzalloc(&c->dev, sizeof(*core), GFP_KERNEL);
1156 if (!core) { 1156 if (!core)
1157 return -ENOMEM; 1157 return -ENOMEM;
1158 }
1159 sd = &core->sd; 1158 sd = &core->sd;
1160 v4l2_i2c_subdev_init(sd, c, &tvp5150_ops); 1159 v4l2_i2c_subdev_init(sd, c, &tvp5150_ops);
1161 1160
@@ -1166,7 +1165,7 @@ static int tvp5150_probe(struct i2c_client *c,
1166 for (i = 0; i < 4; i++) { 1165 for (i = 0; i < 4; i++) {
1167 res = tvp5150_read(sd, TVP5150_MSB_DEV_ID + i); 1166 res = tvp5150_read(sd, TVP5150_MSB_DEV_ID + i);
1168 if (res < 0) 1167 if (res < 0)
1169 goto free_core; 1168 return res;
1170 tvp5150_id[i] = res; 1169 tvp5150_id[i] = res;
1171 } 1170 }
1172 1171
@@ -1209,7 +1208,7 @@ static int tvp5150_probe(struct i2c_client *c,
1209 if (core->hdl.error) { 1208 if (core->hdl.error) {
1210 res = core->hdl.error; 1209 res = core->hdl.error;
1211 v4l2_ctrl_handler_free(&core->hdl); 1210 v4l2_ctrl_handler_free(&core->hdl);
1212 goto free_core; 1211 return res;
1213 } 1212 }
1214 v4l2_ctrl_handler_setup(&core->hdl); 1213 v4l2_ctrl_handler_setup(&core->hdl);
1215 1214
@@ -1225,10 +1224,6 @@ static int tvp5150_probe(struct i2c_client *c,
1225 if (debug > 1) 1224 if (debug > 1)
1226 tvp5150_log_status(sd); 1225 tvp5150_log_status(sd);
1227 return 0; 1226 return 0;
1228
1229free_core:
1230 kfree(core);
1231 return res;
1232} 1227}
1233 1228
1234static int tvp5150_remove(struct i2c_client *c) 1229static int tvp5150_remove(struct i2c_client *c)
@@ -1242,7 +1237,6 @@ static int tvp5150_remove(struct i2c_client *c)
1242 1237
1243 v4l2_device_unregister_subdev(sd); 1238 v4l2_device_unregister_subdev(sd);
1244 v4l2_ctrl_handler_free(&decoder->hdl); 1239 v4l2_ctrl_handler_free(&decoder->hdl);
1245 kfree(to_tvp5150(sd));
1246 return 0; 1240 return 0;
1247} 1241}
1248 1242