mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 18:09:56 +00:00
media: atomisp: gc0310: Use devm_kzalloc() for data struct
Use devm_kzalloc() to allocate the data struct. It is always free-ed as the last step of probe-error-exit or remove, so it can be devm-managed. This will make unwinding things easier when support is added to the gc0310 code to use standard GPIO APIs instead of the custom atomisp_gmin code. This also allows dropping the out_free label and use direct return on errors. This may seem like a functional change since the out_free label also did a v4l2_device_unregister_subdev() but at the 1 changed return the device is not registered yet, so that always is a no-op and can be dropped. Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
This commit is contained in:
committed by
Mauro Carvalho Chehab
parent
2726c899fb
commit
340b4dd6c1
@@ -546,7 +546,7 @@ static int gc0310_probe(struct i2c_client *client)
|
|||||||
int ret;
|
int ret;
|
||||||
void *pdata;
|
void *pdata;
|
||||||
|
|
||||||
dev = kzalloc(sizeof(*dev), GFP_KERNEL);
|
dev = devm_kzalloc(&client->dev, sizeof(*dev), GFP_KERNEL);
|
||||||
if (!dev)
|
if (!dev)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
@@ -557,10 +557,8 @@ static int gc0310_probe(struct i2c_client *client)
|
|||||||
pdata = gmin_camera_platform_data(&dev->sd,
|
pdata = gmin_camera_platform_data(&dev->sd,
|
||||||
ATOMISP_INPUT_FORMAT_RAW_8,
|
ATOMISP_INPUT_FORMAT_RAW_8,
|
||||||
atomisp_bayer_order_grbg);
|
atomisp_bayer_order_grbg);
|
||||||
if (!pdata) {
|
if (!pdata)
|
||||||
ret = -EINVAL;
|
return -EINVAL;
|
||||||
goto out_free;
|
|
||||||
}
|
|
||||||
|
|
||||||
pm_runtime_set_suspended(&client->dev);
|
pm_runtime_set_suspended(&client->dev);
|
||||||
pm_runtime_enable(&client->dev);
|
pm_runtime_enable(&client->dev);
|
||||||
@@ -594,10 +592,6 @@ static int gc0310_probe(struct i2c_client *client)
|
|||||||
gc0310_remove(client);
|
gc0310_remove(client);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
out_free:
|
|
||||||
v4l2_device_unregister_subdev(&dev->sd);
|
|
||||||
kfree(dev);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int gc0310_suspend(struct device *dev)
|
static int gc0310_suspend(struct device *dev)
|
||||||
|
|||||||
Reference in New Issue
Block a user