Skip to content

Commit

Permalink
media: ti-vpe: cal: Add context V4L2 cleanup and unregister functions
Browse files Browse the repository at this point in the history
Create cal_ctx_v4l2_unregister() and cal_ctx_v4l2_cleanup() functions to
unregister and cleanup the V4L2-related objects from the context, and
call them in cal_remove() and in the error path of cal_probe().

Signed-off-by: Laurent Pinchart <[email protected]>
Reviewed-by: Benoit Parrot <[email protected]>
Signed-off-by: Hans Verkuil <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
  • Loading branch information
pinchartl authored and sigmaris committed Aug 8, 2020
1 parent 5221e56 commit 43e9a17
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions drivers/media/platform/ti-vpe/cal.c
Original file line number Diff line number Diff line change
Expand Up @@ -1895,6 +1895,11 @@ static int cal_ctx_v4l2_register(struct cal_ctx *ctx)
return 0;
}

static void cal_ctx_v4l2_unregister(struct cal_ctx *ctx)
{
video_unregister_device(&ctx->vdev);
}

static int cal_ctx_v4l2_init(struct cal_ctx *ctx)
{
struct v4l2_ctrl_handler *hdl = &ctx->ctrl_handler;
Expand Down Expand Up @@ -1948,6 +1953,11 @@ static int cal_ctx_v4l2_init(struct cal_ctx *ctx)
return 0;
}

static void cal_ctx_v4l2_cleanup(struct cal_ctx *ctx)
{
v4l2_ctrl_handler_free(&ctx->ctrl_handler);
}

/* ------------------------------------------------------------------
* Initialization and module stuff
* ------------------------------------------------------------------
Expand Down Expand Up @@ -2286,7 +2296,7 @@ static int cal_probe(struct platform_device *pdev)
if (ctx) {
v4l2_async_notifier_unregister(&ctx->notifier);
v4l2_async_notifier_cleanup(&ctx->notifier);
v4l2_ctrl_handler_free(&ctx->ctrl_handler);
cal_ctx_v4l2_cleanup(ctx);
}
}

Expand All @@ -2313,8 +2323,8 @@ static int cal_remove(struct platform_device *pdev)
cal_camerarx_disable(ctx->phy);
v4l2_async_notifier_unregister(&ctx->notifier);
v4l2_async_notifier_cleanup(&ctx->notifier);
v4l2_ctrl_handler_free(&ctx->ctrl_handler);
video_unregister_device(&ctx->vdev);
cal_ctx_v4l2_cleanup(ctx);
cal_ctx_v4l2_unregister(ctx);
}
}

Expand Down

0 comments on commit 43e9a17

Please sign in to comment.