diff mbox series

[v2,1/2] backlight: lm3630a: fix return code of .update_status() callback

Message ID 20210620193928.14467-1-u.kleine-koenig@pengutronix.de
State New
Headers show
Series [v2,1/2] backlight: lm3630a: fix return code of .update_status() callback | expand

Commit Message

Uwe Kleine-König June 20, 2021, 7:39 p.m. UTC
According to <linux/backlight.h> .update_status() is supposed to
return 0 on success and a negative error code otherwise. Adapt
lm3630a_bank_a_update_status() to actually do it.

While touching that also add the error code to the failure message.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/video/backlight/lm3630a_bl.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)


base-commit: 6efb943b8616ec53a5e444193dccf1af9ad627b5

Comments

Daniel Thompson June 21, 2021, 10:23 a.m. UTC | #1
On Sun, Jun 20, 2021 at 09:39:27PM +0200, Uwe Kleine-König wrote:
> According to <linux/backlight.h> .update_status() is supposed to
> return 0 on success and a negative error code otherwise. Adapt
> lm3630a_bank_a_update_status() to actually do it.
> 
> While touching that also add the error code to the failure message.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

Thanks for this!

Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>


Daniel.


> ---
>  drivers/video/backlight/lm3630a_bl.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/video/backlight/lm3630a_bl.c b/drivers/video/backlight/lm3630a_bl.c
> index e88a2b0e5904..16a2658a72e1 100644
> --- a/drivers/video/backlight/lm3630a_bl.c
> +++ b/drivers/video/backlight/lm3630a_bl.c
> @@ -190,7 +190,7 @@ static int lm3630a_bank_a_update_status(struct backlight_device *bl)
>  	if ((pwm_ctrl & LM3630A_PWM_BANK_A) != 0) {
>  		lm3630a_pwm_ctrl(pchip, bl->props.brightness,
>  				 bl->props.max_brightness);
> -		return bl->props.brightness;
> +		return 0;
>  	}
>  
>  	/* disable sleep */
> @@ -210,8 +210,8 @@ static int lm3630a_bank_a_update_status(struct backlight_device *bl)
>  	return 0;
>  
>  out_i2c_err:
> -	dev_err(pchip->dev, "i2c failed to access\n");
> -	return bl->props.brightness;
> +	dev_err(pchip->dev, "i2c failed to access (%pe)\n", ERR_PTR(ret));
> +	return ret;
>  }
>  
>  static int lm3630a_bank_a_get_brightness(struct backlight_device *bl)
> 
> base-commit: 6efb943b8616ec53a5e444193dccf1af9ad627b5
> -- 
> 2.30.2
>
Daniel Thompson June 21, 2021, 11:41 a.m. UTC | #2
On Mon, Jun 21, 2021 at 11:23:51AM +0100, Daniel Thompson wrote:
> On Sun, Jun 20, 2021 at 09:39:27PM +0200, Uwe Kleine-König wrote:
> > According to <linux/backlight.h> .update_status() is supposed to
> > return 0 on success and a negative error code otherwise. Adapt
> > lm3630a_bank_a_update_status() to actually do it.
> > 
> > While touching that also add the error code to the failure message.
> > 
> > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> 
> Thanks for this!
> 
> Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>

Sorry... looks like I was a little hasty here.

As mentioned in https://marc.info/?l=linux-fbdev&m=162427245024751&w=2
when lm3630a_bank_b_update_status() needs similar fixes.

Just wanted to put something in the ML record so Lee doesn't pick this
patch based on my R-b above...


Danieo.


> 
> 
> Daniel.
> 
> 
> > ---
> >  drivers/video/backlight/lm3630a_bl.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/video/backlight/lm3630a_bl.c b/drivers/video/backlight/lm3630a_bl.c
> > index e88a2b0e5904..16a2658a72e1 100644
> > --- a/drivers/video/backlight/lm3630a_bl.c
> > +++ b/drivers/video/backlight/lm3630a_bl.c
> > @@ -190,7 +190,7 @@ static int lm3630a_bank_a_update_status(struct backlight_device *bl)
> >  	if ((pwm_ctrl & LM3630A_PWM_BANK_A) != 0) {
> >  		lm3630a_pwm_ctrl(pchip, bl->props.brightness,
> >  				 bl->props.max_brightness);
> > -		return bl->props.brightness;
> > +		return 0;
> >  	}
> >  
> >  	/* disable sleep */
> > @@ -210,8 +210,8 @@ static int lm3630a_bank_a_update_status(struct backlight_device *bl)
> >  	return 0;
> >  
> >  out_i2c_err:
> > -	dev_err(pchip->dev, "i2c failed to access\n");
> > -	return bl->props.brightness;
> > +	dev_err(pchip->dev, "i2c failed to access (%pe)\n", ERR_PTR(ret));
> > +	return ret;
> >  }
> >  
> >  static int lm3630a_bank_a_get_brightness(struct backlight_device *bl)
> > 
> > base-commit: 6efb943b8616ec53a5e444193dccf1af9ad627b5
> > -- 
> > 2.30.2
> >
diff mbox series

Patch

diff --git a/drivers/video/backlight/lm3630a_bl.c b/drivers/video/backlight/lm3630a_bl.c
index e88a2b0e5904..16a2658a72e1 100644
--- a/drivers/video/backlight/lm3630a_bl.c
+++ b/drivers/video/backlight/lm3630a_bl.c
@@ -190,7 +190,7 @@  static int lm3630a_bank_a_update_status(struct backlight_device *bl)
 	if ((pwm_ctrl & LM3630A_PWM_BANK_A) != 0) {
 		lm3630a_pwm_ctrl(pchip, bl->props.brightness,
 				 bl->props.max_brightness);
-		return bl->props.brightness;
+		return 0;
 	}
 
 	/* disable sleep */
@@ -210,8 +210,8 @@  static int lm3630a_bank_a_update_status(struct backlight_device *bl)
 	return 0;
 
 out_i2c_err:
-	dev_err(pchip->dev, "i2c failed to access\n");
-	return bl->props.brightness;
+	dev_err(pchip->dev, "i2c failed to access (%pe)\n", ERR_PTR(ret));
+	return ret;
 }
 
 static int lm3630a_bank_a_get_brightness(struct backlight_device *bl)