[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>
This commit is contained in:

committed by
Mauro Carvalho Chehab

父節點
95323361e5
當前提交
c02b211df6
@@ -59,7 +59,7 @@ static int ov7640_probe(struct i2c_client *client,
|
||||
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
|
||||
return -ENODEV;
|
||||
|
||||
sd = kzalloc(sizeof(struct v4l2_subdev), GFP_KERNEL);
|
||||
sd = devm_kzalloc(&client->dev, sizeof(*sd), GFP_KERNEL);
|
||||
if (sd == NULL)
|
||||
return -ENOMEM;
|
||||
v4l2_i2c_subdev_init(sd, client, &ov7640_ops);
|
||||
@@ -71,7 +71,6 @@ static int ov7640_probe(struct i2c_client *client,
|
||||
|
||||
if (write_regs(client, initial_registers) < 0) {
|
||||
v4l_err(client, "error initializing OV7640\n");
|
||||
kfree(sd);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
@@ -84,7 +83,7 @@ static int ov7640_remove(struct i2c_client *client)
|
||||
struct v4l2_subdev *sd = i2c_get_clientdata(client);
|
||||
|
||||
v4l2_device_unregister_subdev(sd);
|
||||
kfree(sd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user