diff options
author | Hans Verkuil <hverkuil-cisco@xs4all.nl> | 2019-03-05 03:36:20 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab+samsung@kernel.org> | 2019-03-19 13:34:16 -0400 |
commit | 2b177f2849d23061508bb13594cc1bff1ccb46c9 (patch) | |
tree | af17f637006d58cec9319e6ae442816d37124294 /drivers/media/platform/vimc/vimc-scaler.c | |
parent | 3650a23eda89f99b964fbd63a20320fafaa73e33 (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-scaler.c')
-rw-r--r-- | drivers/media/platform/vimc/vimc-scaler.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/drivers/media/platform/vimc/vimc-scaler.c b/drivers/media/platform/vimc/vimc-scaler.c index 39b2a73dfcc1..2028afa4ef7a 100644 --- a/drivers/media/platform/vimc/vimc-scaler.c +++ b/drivers/media/platform/vimc/vimc-scaler.c | |||
@@ -348,6 +348,18 @@ static void *vimc_sca_process_frame(struct vimc_ent_device *ved, | |||
348 | return vsca->src_frame; | 348 | return vsca->src_frame; |
349 | }; | 349 | }; |
350 | 350 | ||
351 | static void vimc_sca_release(struct v4l2_subdev *sd) | ||
352 | { | ||
353 | struct vimc_sca_device *vsca = | ||
354 | container_of(sd, struct vimc_sca_device, sd); | ||
355 | |||
356 | kfree(vsca); | ||
357 | } | ||
358 | |||
359 | static const struct v4l2_subdev_internal_ops vimc_sca_int_ops = { | ||
360 | .release = vimc_sca_release, | ||
361 | }; | ||
362 | |||
351 | static void vimc_sca_comp_unbind(struct device *comp, struct device *master, | 363 | static void vimc_sca_comp_unbind(struct device *comp, struct device *master, |
352 | void *master_data) | 364 | void *master_data) |
353 | { | 365 | { |
@@ -356,7 +368,6 @@ static void vimc_sca_comp_unbind(struct device *comp, struct device *master, | |||
356 | ved); | 368 | ved); |
357 | 369 | ||
358 | vimc_ent_sd_unregister(ved, &vsca->sd); | 370 | vimc_ent_sd_unregister(ved, &vsca->sd); |
359 | kfree(vsca); | ||
360 | } | 371 | } |
361 | 372 | ||
362 | 373 | ||
@@ -379,7 +390,7 @@ static int vimc_sca_comp_bind(struct device *comp, struct device *master, | |||
379 | MEDIA_ENT_F_PROC_VIDEO_SCALER, 2, | 390 | MEDIA_ENT_F_PROC_VIDEO_SCALER, 2, |
380 | (const unsigned long[2]) {MEDIA_PAD_FL_SINK, | 391 | (const unsigned long[2]) {MEDIA_PAD_FL_SINK, |
381 | MEDIA_PAD_FL_SOURCE}, | 392 | MEDIA_PAD_FL_SOURCE}, |
382 | &vimc_sca_ops); | 393 | &vimc_sca_int_ops, &vimc_sca_ops); |
383 | if (ret) { | 394 | if (ret) { |
384 | kfree(vsca); | 395 | kfree(vsca); |
385 | return ret; | 396 | return ret; |