[PATCH 07/16] media: rkisp1: Simplify rkisp1_entities_register() error path
Dafna Hirschfeld
dafna at fastmail.com
Wed Mar 2 11:16:01 PST 2022
On 27.02.2022 18:01, Laurent Pinchart wrote:
> Now that all the unregistration functions are safe to call on
> non-registered entities, the error path in rkisp1_entities_register()
> can be simplified. Factor out the unregistration to a separate function
> to share code with rkisp1_remove().
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
Reviewed-by: Dafna Hirschfeld <dafna at fastmail.com>
> ---
> .../platform/rockchip/rkisp1/rkisp1-dev.c | 40 +++++++++----------
> 1 file changed, 19 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c
> index 3f5cfa7eb937..f8b2573aa9da 100644
> --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c
> +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c
> @@ -346,48 +346,50 @@ static const struct dev_pm_ops rkisp1_pm_ops = {
> * Core
> */
>
> +static void rkisp1_entities_unregister(struct rkisp1_device *rkisp1)
> +{
> + rkisp1_params_unregister(rkisp1);
> + rkisp1_stats_unregister(rkisp1);
> + rkisp1_capture_devs_unregister(rkisp1);
> + rkisp1_resizer_devs_unregister(rkisp1);
> + rkisp1_isp_unregister(rkisp1);
> +}
> +
> static int rkisp1_entities_register(struct rkisp1_device *rkisp1)
> {
> int ret;
>
> ret = rkisp1_isp_register(rkisp1);
> if (ret)
> - return ret;
> + goto error;
>
> ret = rkisp1_resizer_devs_register(rkisp1);
> if (ret)
> - goto err_unreg_isp_subdev;
> + goto error;
>
> ret = rkisp1_capture_devs_register(rkisp1);
> if (ret)
> - goto err_unreg_resizer_devs;
> + goto error;
>
> ret = rkisp1_stats_register(rkisp1);
> if (ret)
> - goto err_unreg_capture_devs;
> + goto error;
>
> ret = rkisp1_params_register(rkisp1);
> if (ret)
> - goto err_unreg_stats;
> + goto error;
>
> ret = rkisp1_subdev_notifier(rkisp1);
> if (ret) {
> dev_err(rkisp1->dev,
> "Failed to register subdev notifier(%d)\n", ret);
> - goto err_unreg_params;
> + goto error;
> }
>
> return 0;
> -err_unreg_params:
> - rkisp1_params_unregister(rkisp1);
> -err_unreg_stats:
> - rkisp1_stats_unregister(rkisp1);
> -err_unreg_capture_devs:
> - rkisp1_capture_devs_unregister(rkisp1);
> -err_unreg_resizer_devs:
> - rkisp1_resizer_devs_unregister(rkisp1);
> -err_unreg_isp_subdev:
> - rkisp1_isp_unregister(rkisp1);
> +
> +error:
> + rkisp1_entities_unregister(rkisp1);
> return ret;
> }
>
> @@ -583,11 +585,7 @@ static int rkisp1_remove(struct platform_device *pdev)
> v4l2_async_nf_unregister(&rkisp1->notifier);
> v4l2_async_nf_cleanup(&rkisp1->notifier);
>
> - rkisp1_params_unregister(rkisp1);
> - rkisp1_stats_unregister(rkisp1);
> - rkisp1_capture_devs_unregister(rkisp1);
> - rkisp1_resizer_devs_unregister(rkisp1);
> - rkisp1_isp_unregister(rkisp1);
> + rkisp1_entities_unregister(rkisp1);
>
> media_device_unregister(&rkisp1->media_dev);
> v4l2_device_unregister(&rkisp1->v4l2_dev);
> --
> Regards,
>
> Laurent Pinchart
>
More information about the Linux-rockchip
mailing list