diff options
author | Hans de Goede <hdegoede@redhat.com> | 2023-01-15 16:05:38 +0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@kernel.org> | 2023-02-08 10:24:34 +0300 |
commit | e98b8993bfffbe552b7881bd9b7450f10f3bb9d3 (patch) | |
tree | e635c59c9fb948bfb38b3af36ce04c181fde7dfb /drivers/staging/media/atomisp/i2c/atomisp-ov2680.c | |
parent | 66c7b303c7108db0a6fe6525bf6acc749e979de4 (diff) | |
download | linux-e98b8993bfffbe552b7881bd9b7450f10f3bb9d3.tar.xz |
media: atomisp: ov2680: Use devm_kzalloc() for sensor data struct
Use devm_kzalloc() to allocate the sensor 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 ov2680
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 2 changed returns
the device is not registered yet, so that always is a no-op and can
be dropped.
Reviewed-by: Andy Shevchenko <andy@kernel.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Diffstat (limited to 'drivers/staging/media/atomisp/i2c/atomisp-ov2680.c')
-rw-r--r-- | drivers/staging/media/atomisp/i2c/atomisp-ov2680.c | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c b/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c index 6d2b0be6bf86..06df78d46689 100644 --- a/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c +++ b/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c @@ -776,7 +776,6 @@ static void ov2680_remove(struct i2c_client *client) media_entity_cleanup(&sensor->sd.entity); v4l2_ctrl_handler_free(&sensor->ctrls.handler); pm_runtime_disable(&client->dev); - kfree(sensor); } static int ov2680_probe(struct i2c_client *client) @@ -786,7 +785,7 @@ static int ov2680_probe(struct i2c_client *client) int ret; void *pdata; - sensor = kzalloc(sizeof(*sensor), GFP_KERNEL); + sensor = devm_kzalloc(dev, sizeof(*sensor), GFP_KERNEL); if (!sensor) return -ENOMEM; @@ -798,10 +797,8 @@ static int ov2680_probe(struct i2c_client *client) pdata = gmin_camera_platform_data(&sensor->sd, ATOMISP_INPUT_FORMAT_RAW_10, atomisp_bayer_order_bggr); - if (!pdata) { - ret = -EINVAL; - goto out_free; - } + if (!pdata) + return -EINVAL; pm_runtime_set_suspended(dev); pm_runtime_enable(dev); @@ -810,7 +807,7 @@ static int ov2680_probe(struct i2c_client *client) ret = ov2680_s_config(&sensor->sd, client->irq, pdata); if (ret) - goto out_free; + return ret; sensor->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; sensor->pad.flags = MEDIA_PAD_FL_SOURCE; @@ -837,11 +834,6 @@ static int ov2680_probe(struct i2c_client *client) } return 0; -out_free: - dev_dbg(&client->dev, "+++ out free\n"); - v4l2_device_unregister_subdev(&sensor->sd); - kfree(sensor); - return ret; } static int ov2680_suspend(struct device *dev) |