[2/6] drm/bridge: anx6345: Clean up error handling in probe()
diff mbox series

Message ID 20200220083508.792071-3-anarsoul@gmail.com
State New
Headers show
Series
  • Add LCD support for Pine64 Pinebook 1080p
Related show

Commit Message

Vasily Khoruzhick Feb. 20, 2020, 8:35 a.m. UTC
devm_regulator_get() returns either a dummy regulator or -EPROBE_DEFER,
we don't need to print scary message in either case.

Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
---
 drivers/gpu/drm/bridge/analogix/analogix-anx6345.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

Comments

Laurent Pinchart Feb. 20, 2020, 1:52 p.m. UTC | #1
Hi Vasily,

Thank you for the patch.

On Thu, Feb 20, 2020 at 12:35:04AM -0800, Vasily Khoruzhick wrote:
> devm_regulator_get() returns either a dummy regulator or -EPROBE_DEFER,
> we don't need to print scary message in either case.
> 
> Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
> ---
>  drivers/gpu/drm/bridge/analogix/analogix-anx6345.c | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c b/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
> index 0d8d083b0207..0204bbe4f0a0 100644
> --- a/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
> +++ b/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
> @@ -713,17 +713,13 @@ static int anx6345_i2c_probe(struct i2c_client *client,
>  
>  	/* 1.2V digital core power regulator  */
>  	anx6345->dvdd12 = devm_regulator_get(dev, "dvdd12");
> -	if (IS_ERR(anx6345->dvdd12)) {
> -		DRM_ERROR("dvdd12-supply not found\n");
> +	if (IS_ERR(anx6345->dvdd12))
>  		return PTR_ERR(anx6345->dvdd12);
> -	}

There could be other errors such as -EBUSY or -EPERM. The following
would ensure a message gets printed in those cases, while avoiding
spamming the kernel log in the EPROBE_DEFER case.

	if (IS_ERR(anx6345->dvdd12)) {
		if (PTR_ERR(anx6345->dvdd12) != -EPROBE_DEFER)
			DRM_ERROR("Failed to get dvdd12 supply (%d)\n",
				  PTR_ERR(anx6345->dvdd12));
		return PTR_ERR(anx6345->dvdd12);
	}

But maybe it's overkill ? With or without that change (for the second
regulator below too),

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

>  	/* 2.5V digital core power regulator  */
>  	anx6345->dvdd25 = devm_regulator_get(dev, "dvdd25");
> -	if (IS_ERR(anx6345->dvdd25)) {
> -		DRM_ERROR("dvdd25-supply not found\n");
> +	if (IS_ERR(anx6345->dvdd25))
>  		return PTR_ERR(anx6345->dvdd25);
> -	}
>  
>  	/* GPIO for chip reset */
>  	anx6345->gpiod_reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW);
Vasily Khoruzhick Feb. 20, 2020, 9:37 p.m. UTC | #2
On Thu, Feb 20, 2020 at 5:53 AM Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
>
> Hi Vasily,

Hi Laurent,

> Thank you for the patch.
>
> On Thu, Feb 20, 2020 at 12:35:04AM -0800, Vasily Khoruzhick wrote:
> > devm_regulator_get() returns either a dummy regulator or -EPROBE_DEFER,
> > we don't need to print scary message in either case.
> >
> > Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
> > ---
> >  drivers/gpu/drm/bridge/analogix/analogix-anx6345.c | 8 ++------
> >  1 file changed, 2 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c b/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
> > index 0d8d083b0207..0204bbe4f0a0 100644
> > --- a/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
> > +++ b/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
> > @@ -713,17 +713,13 @@ static int anx6345_i2c_probe(struct i2c_client *client,
> >
> >       /* 1.2V digital core power regulator  */
> >       anx6345->dvdd12 = devm_regulator_get(dev, "dvdd12");
> > -     if (IS_ERR(anx6345->dvdd12)) {
> > -             DRM_ERROR("dvdd12-supply not found\n");
> > +     if (IS_ERR(anx6345->dvdd12))
> >               return PTR_ERR(anx6345->dvdd12);
> > -     }
>
> There could be other errors such as -EBUSY or -EPERM. The following
> would ensure a message gets printed in those cases, while avoiding
> spamming the kernel log in the EPROBE_DEFER case.
>
>         if (IS_ERR(anx6345->dvdd12)) {
>                 if (PTR_ERR(anx6345->dvdd12) != -EPROBE_DEFER)
>                         DRM_ERROR("Failed to get dvdd12 supply (%d)\n",
>                                   PTR_ERR(anx6345->dvdd12));
>                 return PTR_ERR(anx6345->dvdd12);
>         }
>
> But maybe it's overkill ? With or without that change (for the second
> regulator below too),

Thanks, I'll do as you suggested.



> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>
> >       /* 2.5V digital core power regulator  */
> >       anx6345->dvdd25 = devm_regulator_get(dev, "dvdd25");
> > -     if (IS_ERR(anx6345->dvdd25)) {
> > -             DRM_ERROR("dvdd25-supply not found\n");
> > +     if (IS_ERR(anx6345->dvdd25))
> >               return PTR_ERR(anx6345->dvdd25);
> > -     }
> >
> >       /* GPIO for chip reset */
> >       anx6345->gpiod_reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW);
>
> --
> Regards,
>
> Laurent Pinchart

Patch
diff mbox series

diff --git a/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c b/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
index 0d8d083b0207..0204bbe4f0a0 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
@@ -713,17 +713,13 @@  static int anx6345_i2c_probe(struct i2c_client *client,
 
 	/* 1.2V digital core power regulator  */
 	anx6345->dvdd12 = devm_regulator_get(dev, "dvdd12");
-	if (IS_ERR(anx6345->dvdd12)) {
-		DRM_ERROR("dvdd12-supply not found\n");
+	if (IS_ERR(anx6345->dvdd12))
 		return PTR_ERR(anx6345->dvdd12);
-	}
 
 	/* 2.5V digital core power regulator  */
 	anx6345->dvdd25 = devm_regulator_get(dev, "dvdd25");
-	if (IS_ERR(anx6345->dvdd25)) {
-		DRM_ERROR("dvdd25-supply not found\n");
+	if (IS_ERR(anx6345->dvdd25))
 		return PTR_ERR(anx6345->dvdd25);
-	}
 
 	/* GPIO for chip reset */
 	anx6345->gpiod_reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW);