diff mbox series

[v4,32/38] media: am437x-vpfe: Register V4L2 device early

Message ID 20230622114028.908825-33-sakari.ailus@linux.intel.com
State Superseded
Headers show
Series Separate links and async sub-devices | expand

Commit Message

Sakari Ailus June 22, 2023, 11:40 a.m. UTC
Register V4L2 device before the async notifier.This way the device can be
made available to the V4L2 async framework from the notifier init time
onwards. A subsequent patch will add struct v4l2_device as an argument to
v4l2_async_nf_init().

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Tested-by: Philipp Zabel <p.zabel@pengutronix.de> # imx6qp
Tested_by: Niklas Söderlund <niklas.soderlund@ragnatech.se> # rcar + adv746x
Tested-by: Aishwarya Kothari <aishwarya.kothari@toradex.com> # Apalis i.MX6Q with TC358743
---
 .../media/platform/ti/am437x/am437x-vpfe.c    | 27 +++++++++----------
 1 file changed, 13 insertions(+), 14 deletions(-)

Comments

Lad, Prabhakar June 26, 2023, 3:23 p.m. UTC | #1
Hi Sakari,

Thank you for the patch.

On Thu, Jun 22, 2023 at 12:41 PM Sakari Ailus
<sakari.ailus@linux.intel.com> wrote:
>
> Register V4L2 device before the async notifier.This way the device can be
> made available to the V4L2 async framework from the notifier init time
> onwards. A subsequent patch will add struct v4l2_device as an argument to
> v4l2_async_nf_init().
>
> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> Tested-by: Philipp Zabel <p.zabel@pengutronix.de> # imx6qp
> Tested_by: Niklas Söderlund <niklas.soderlund@ragnatech.se> # rcar + adv746x
s/Tested_by/Tested-by (exists in the entire series)

> Tested-by: Aishwarya Kothari <aishwarya.kothari@toradex.com> # Apalis i.MX6Q with TC358743
> ---
>  .../media/platform/ti/am437x/am437x-vpfe.c    | 27 +++++++++----------
>  1 file changed, 13 insertions(+), 14 deletions(-)
>

Reviewed-by: Lad Prabhakar <prabhakar.csengg@gmail.com>

Cheers,
Prabhakar

> diff --git a/drivers/media/platform/ti/am437x/am437x-vpfe.c b/drivers/media/platform/ti/am437x/am437x-vpfe.c
> index a1e01ef5ebddb..1457a188fea12 100644
> --- a/drivers/media/platform/ti/am437x/am437x-vpfe.c
> +++ b/drivers/media/platform/ti/am437x/am437x-vpfe.c
> @@ -2403,10 +2403,17 @@ static int vpfe_probe(struct platform_device *pdev)
>
>         vpfe->pdev = &pdev->dev;
>
> +       ret = v4l2_device_register(&pdev->dev, &vpfe->v4l2_dev);
> +       if (ret) {
> +               vpfe_err(vpfe, "Unable to register v4l2 device.\n");
> +               return ret;
> +       }
> +
>         vpfe_cfg = vpfe_get_pdata(vpfe);
>         if (!vpfe_cfg) {
>                 dev_err(&pdev->dev, "No platform data\n");
> -               return -EINVAL;
> +               ret = -EINVAL;
> +               goto probe_out_cleanup;
>         }
>
>         vpfe->cfg = vpfe_cfg;
> @@ -2433,13 +2440,6 @@ static int vpfe_probe(struct platform_device *pdev)
>                 goto probe_out_cleanup;
>         }
>
> -       ret = v4l2_device_register(&pdev->dev, &vpfe->v4l2_dev);
> -       if (ret) {
> -               vpfe_err(vpfe,
> -                       "Unable to register v4l2 device.\n");
> -               goto probe_out_cleanup;
> -       }
> -
>         /* set the driver data in platform device */
>         platform_set_drvdata(pdev, vpfe);
>         /* Enabling module functional clock */
> @@ -2449,7 +2449,7 @@ static int vpfe_probe(struct platform_device *pdev)
>         ret = pm_runtime_resume_and_get(&pdev->dev);
>         if (ret < 0) {
>                 vpfe_err(vpfe, "Unable to resume device.\n");
> -               goto probe_out_v4l2_unregister;
> +               goto probe_out_cleanup;
>         }
>
>         vpfe_ccdc_config_defaults(ccdc);
> @@ -2462,7 +2462,7 @@ static int vpfe_probe(struct platform_device *pdev)
>                                 GFP_KERNEL);
>         if (!vpfe->sd) {
>                 ret = -ENOMEM;
> -               goto probe_out_v4l2_unregister;
> +               goto probe_out_cleanup;
>         }
>
>         vpfe->notifier.ops = &vpfe_async_ops;
> @@ -2470,15 +2470,14 @@ static int vpfe_probe(struct platform_device *pdev)
>         if (ret) {
>                 vpfe_err(vpfe, "Error registering async notifier\n");
>                 ret = -EINVAL;
> -               goto probe_out_v4l2_unregister;
> +               goto probe_out_cleanup;
>         }
>
>         return 0;
>
> -probe_out_v4l2_unregister:
> -       v4l2_device_unregister(&vpfe->v4l2_dev);
>  probe_out_cleanup:
>         v4l2_async_nf_cleanup(&vpfe->notifier);
> +       v4l2_device_unregister(&vpfe->v4l2_dev);
>         return ret;
>  }
>
> @@ -2493,8 +2492,8 @@ static void vpfe_remove(struct platform_device *pdev)
>
>         v4l2_async_nf_unregister(&vpfe->notifier);
>         v4l2_async_nf_cleanup(&vpfe->notifier);
> -       v4l2_device_unregister(&vpfe->v4l2_dev);
>         video_unregister_device(&vpfe->video_dev);
> +       v4l2_device_unregister(&vpfe->v4l2_dev);
>  }
>
>  #ifdef CONFIG_PM_SLEEP
> --
> 2.39.2
>
Sakari Ailus June 29, 2023, 8:20 a.m. UTC | #2
Hi Prabhakar,

On Mon, Jun 26, 2023 at 04:23:36PM +0100, Lad, Prabhakar wrote:
> Hi Sakari,
> 
> Thank you for the patch.
> 
> On Thu, Jun 22, 2023 at 12:41 PM Sakari Ailus
> <sakari.ailus@linux.intel.com> wrote:
> >
> > Register V4L2 device before the async notifier.This way the device can be
> > made available to the V4L2 async framework from the notifier init time
> > onwards. A subsequent patch will add struct v4l2_device as an argument to
> > v4l2_async_nf_init().
> >
> > Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> > Tested-by: Philipp Zabel <p.zabel@pengutronix.de> # imx6qp
> > Tested_by: Niklas Söderlund <niklas.soderlund@ragnatech.se> # rcar + adv746x
> s/Tested_by/Tested-by (exists in the entire series)

Oops. I added it manually and introduced a typo. Thanks for catching this!

> 
> > Tested-by: Aishwarya Kothari <aishwarya.kothari@toradex.com> # Apalis i.MX6Q with TC358743
> > ---
> >  .../media/platform/ti/am437x/am437x-vpfe.c    | 27 +++++++++----------
> >  1 file changed, 13 insertions(+), 14 deletions(-)
> >
> 
> Reviewed-by: Lad Prabhakar <prabhakar.csengg@gmail.com>

Thanks for testing and review.
diff mbox series

Patch

diff --git a/drivers/media/platform/ti/am437x/am437x-vpfe.c b/drivers/media/platform/ti/am437x/am437x-vpfe.c
index a1e01ef5ebddb..1457a188fea12 100644
--- a/drivers/media/platform/ti/am437x/am437x-vpfe.c
+++ b/drivers/media/platform/ti/am437x/am437x-vpfe.c
@@ -2403,10 +2403,17 @@  static int vpfe_probe(struct platform_device *pdev)
 
 	vpfe->pdev = &pdev->dev;
 
+	ret = v4l2_device_register(&pdev->dev, &vpfe->v4l2_dev);
+	if (ret) {
+		vpfe_err(vpfe, "Unable to register v4l2 device.\n");
+		return ret;
+	}
+
 	vpfe_cfg = vpfe_get_pdata(vpfe);
 	if (!vpfe_cfg) {
 		dev_err(&pdev->dev, "No platform data\n");
-		return -EINVAL;
+		ret = -EINVAL;
+		goto probe_out_cleanup;
 	}
 
 	vpfe->cfg = vpfe_cfg;
@@ -2433,13 +2440,6 @@  static int vpfe_probe(struct platform_device *pdev)
 		goto probe_out_cleanup;
 	}
 
-	ret = v4l2_device_register(&pdev->dev, &vpfe->v4l2_dev);
-	if (ret) {
-		vpfe_err(vpfe,
-			"Unable to register v4l2 device.\n");
-		goto probe_out_cleanup;
-	}
-
 	/* set the driver data in platform device */
 	platform_set_drvdata(pdev, vpfe);
 	/* Enabling module functional clock */
@@ -2449,7 +2449,7 @@  static int vpfe_probe(struct platform_device *pdev)
 	ret = pm_runtime_resume_and_get(&pdev->dev);
 	if (ret < 0) {
 		vpfe_err(vpfe, "Unable to resume device.\n");
-		goto probe_out_v4l2_unregister;
+		goto probe_out_cleanup;
 	}
 
 	vpfe_ccdc_config_defaults(ccdc);
@@ -2462,7 +2462,7 @@  static int vpfe_probe(struct platform_device *pdev)
 				GFP_KERNEL);
 	if (!vpfe->sd) {
 		ret = -ENOMEM;
-		goto probe_out_v4l2_unregister;
+		goto probe_out_cleanup;
 	}
 
 	vpfe->notifier.ops = &vpfe_async_ops;
@@ -2470,15 +2470,14 @@  static int vpfe_probe(struct platform_device *pdev)
 	if (ret) {
 		vpfe_err(vpfe, "Error registering async notifier\n");
 		ret = -EINVAL;
-		goto probe_out_v4l2_unregister;
+		goto probe_out_cleanup;
 	}
 
 	return 0;
 
-probe_out_v4l2_unregister:
-	v4l2_device_unregister(&vpfe->v4l2_dev);
 probe_out_cleanup:
 	v4l2_async_nf_cleanup(&vpfe->notifier);
+	v4l2_device_unregister(&vpfe->v4l2_dev);
 	return ret;
 }
 
@@ -2493,8 +2492,8 @@  static void vpfe_remove(struct platform_device *pdev)
 
 	v4l2_async_nf_unregister(&vpfe->notifier);
 	v4l2_async_nf_cleanup(&vpfe->notifier);
-	v4l2_device_unregister(&vpfe->v4l2_dev);
 	video_unregister_device(&vpfe->video_dev);
+	v4l2_device_unregister(&vpfe->v4l2_dev);
 }
 
 #ifdef CONFIG_PM_SLEEP