aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLad, Prabhakar <prabhakar.lad@ti.com>2013-01-03 07:46:43 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2013-02-05 11:08:04 -0500
commitf3e8e4f1c039b13644f06c74cc5507bebc41da69 (patch)
tree1b5f65c6e1623388527c427c395c686f3a175e1b /drivers
parentd41d81983a9eb44626ab3ddd1f0184e4815f5bcc (diff)
[media] tvp7002: use devm_kzalloc() instead of kzalloc()
I2C drivers can use devm_kzalloc() too in their .probe() methods. Doing so simplifies their clean up paths. Signed-off-by: Lad, Prabhakar <prabhakar.lad@ti.com> Signed-off-by: Manjunath Hadli <manjunath.hadli@ti.com> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/i2c/tvp7002.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/drivers/media/i2c/tvp7002.c b/drivers/media/i2c/tvp7002.c
index fb6a5b57eb83..537f6b4d4918 100644
--- a/drivers/media/i2c/tvp7002.c
+++ b/drivers/media/i2c/tvp7002.c
@@ -1036,7 +1036,7 @@ static int tvp7002_probe(struct i2c_client *c, const struct i2c_device_id *id)
1036 return -ENODEV; 1036 return -ENODEV;
1037 } 1037 }
1038 1038
1039 device = kzalloc(sizeof(struct tvp7002), GFP_KERNEL); 1039 device = devm_kzalloc(&c->dev, sizeof(struct tvp7002), GFP_KERNEL);
1040 1040
1041 if (!device) 1041 if (!device)
1042 return -ENOMEM; 1042 return -ENOMEM;
@@ -1052,7 +1052,7 @@ static int tvp7002_probe(struct i2c_client *c, const struct i2c_device_id *id)
1052 1052
1053 error = tvp7002_read(sd, TVP7002_CHIP_REV, &revision); 1053 error = tvp7002_read(sd, TVP7002_CHIP_REV, &revision);
1054 if (error < 0) 1054 if (error < 0)
1055 goto found_error; 1055 return error;
1056 1056
1057 /* Get revision number */ 1057 /* Get revision number */
1058 v4l2_info(sd, "Rev. %02x detected.\n", revision); 1058 v4l2_info(sd, "Rev. %02x detected.\n", revision);
@@ -1063,21 +1063,21 @@ static int tvp7002_probe(struct i2c_client *c, const struct i2c_device_id *id)
1063 error = tvp7002_write_inittab(sd, tvp7002_init_default); 1063 error = tvp7002_write_inittab(sd, tvp7002_init_default);
1064 1064
1065 if (error < 0) 1065 if (error < 0)
1066 goto found_error; 1066 return error;
1067 1067
1068 /* Set polarity information after registers have been set */ 1068 /* Set polarity information after registers have been set */
1069 polarity_a = 0x20 | device->pdata->hs_polarity << 5 1069 polarity_a = 0x20 | device->pdata->hs_polarity << 5
1070 | device->pdata->vs_polarity << 2; 1070 | device->pdata->vs_polarity << 2;
1071 error = tvp7002_write(sd, TVP7002_SYNC_CTL_1, polarity_a); 1071 error = tvp7002_write(sd, TVP7002_SYNC_CTL_1, polarity_a);
1072 if (error < 0) 1072 if (error < 0)
1073 goto found_error; 1073 return error;
1074 1074
1075 polarity_b = 0x01 | device->pdata->fid_polarity << 2 1075 polarity_b = 0x01 | device->pdata->fid_polarity << 2
1076 | device->pdata->sog_polarity << 1 1076 | device->pdata->sog_polarity << 1
1077 | device->pdata->clk_polarity; 1077 | device->pdata->clk_polarity;
1078 error = tvp7002_write(sd, TVP7002_MISC_CTL_3, polarity_b); 1078 error = tvp7002_write(sd, TVP7002_MISC_CTL_3, polarity_b);
1079 if (error < 0) 1079 if (error < 0)
1080 goto found_error; 1080 return error;
1081 1081
1082 /* Set registers according to default video mode */ 1082 /* Set registers according to default video mode */
1083 preset.preset = device->current_preset->preset; 1083 preset.preset = device->current_preset->preset;
@@ -1091,16 +1091,11 @@ static int tvp7002_probe(struct i2c_client *c, const struct i2c_device_id *id)
1091 int err = device->hdl.error; 1091 int err = device->hdl.error;
1092 1092
1093 v4l2_ctrl_handler_free(&device->hdl); 1093 v4l2_ctrl_handler_free(&device->hdl);
1094 kfree(device);
1095 return err; 1094 return err;
1096 } 1095 }
1097 v4l2_ctrl_handler_setup(&device->hdl); 1096 v4l2_ctrl_handler_setup(&device->hdl);
1098 1097
1099found_error: 1098 return 0;
1100 if (error < 0)
1101 kfree(device);
1102
1103 return error;
1104} 1099}
1105 1100
1106/* 1101/*
@@ -1120,7 +1115,6 @@ static int tvp7002_remove(struct i2c_client *c)
1120 1115
1121 v4l2_device_unregister_subdev(sd); 1116 v4l2_device_unregister_subdev(sd);
1122 v4l2_ctrl_handler_free(&device->hdl); 1117 v4l2_ctrl_handler_free(&device->hdl);
1123 kfree(device);
1124 return 0; 1118 return 0;
1125} 1119}
1126 1120