aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/platform/vimc/vimc-sensor.c
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil-cisco@xs4all.nl>2019-03-05 03:36:20 -0500
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>2019-03-19 13:34:16 -0400
commit2b177f2849d23061508bb13594cc1bff1ccb46c9 (patch)
treeaf17f637006d58cec9319e6ae442816d37124294 /drivers/media/platform/vimc/vimc-sensor.c
parent3650a23eda89f99b964fbd63a20320fafaa73e33 (diff)
media: vimc: use new release op
Use the new v4l2_subdev_internal_ops release op to free the subdev memory only when the last user closed the file handle. Move v4l2_device_unregister_subdev() to the end of the vimc_ent_sd_unregister() function since now the unregister_subdev() call may free the vimc_ent_device struct which is used after the unregister_subdev() call. So this now has to be done last. Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Diffstat (limited to 'drivers/media/platform/vimc/vimc-sensor.c')
-rw-r--r--drivers/media/platform/vimc/vimc-sensor.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/drivers/media/platform/vimc/vimc-sensor.c b/drivers/media/platform/vimc/vimc-sensor.c
index 59195f262623..d7891d3bbeaa 100644
--- a/drivers/media/platform/vimc/vimc-sensor.c
+++ b/drivers/media/platform/vimc/vimc-sensor.c
@@ -301,6 +301,20 @@ static const struct v4l2_ctrl_ops vimc_sen_ctrl_ops = {
301 .s_ctrl = vimc_sen_s_ctrl, 301 .s_ctrl = vimc_sen_s_ctrl,
302}; 302};
303 303
304static void vimc_sen_release(struct v4l2_subdev *sd)
305{
306 struct vimc_sen_device *vsen =
307 container_of(sd, struct vimc_sen_device, sd);
308
309 v4l2_ctrl_handler_free(&vsen->hdl);
310 tpg_free(&vsen->tpg);
311 kfree(vsen);
312}
313
314static const struct v4l2_subdev_internal_ops vimc_sen_int_ops = {
315 .release = vimc_sen_release,
316};
317
304static void vimc_sen_comp_unbind(struct device *comp, struct device *master, 318static void vimc_sen_comp_unbind(struct device *comp, struct device *master,
305 void *master_data) 319 void *master_data)
306{ 320{
@@ -309,9 +323,6 @@ static void vimc_sen_comp_unbind(struct device *comp, struct device *master,
309 container_of(ved, struct vimc_sen_device, ved); 323 container_of(ved, struct vimc_sen_device, ved);
310 324
311 vimc_ent_sd_unregister(ved, &vsen->sd); 325 vimc_ent_sd_unregister(ved, &vsen->sd);
312 v4l2_ctrl_handler_free(&vsen->hdl);
313 tpg_free(&vsen->tpg);
314 kfree(vsen);
315} 326}
316 327
317/* Image Processing Controls */ 328/* Image Processing Controls */
@@ -371,7 +382,7 @@ static int vimc_sen_comp_bind(struct device *comp, struct device *master,
371 pdata->entity_name, 382 pdata->entity_name,
372 MEDIA_ENT_F_CAM_SENSOR, 1, 383 MEDIA_ENT_F_CAM_SENSOR, 1,
373 (const unsigned long[1]) {MEDIA_PAD_FL_SOURCE}, 384 (const unsigned long[1]) {MEDIA_PAD_FL_SOURCE},
374 &vimc_sen_ops); 385 &vimc_sen_int_ops, &vimc_sen_ops);
375 if (ret) 386 if (ret)
376 goto err_free_hdl; 387 goto err_free_hdl;
377 388