diff mbox series

[v2,04/11] leds: qcom-lpg: Propagate errors in .get_state() to the caller

Message ID 20221130152148.2769768-5-u.kleine-koenig@pengutronix.de
State New
Headers show
Series pwm: Allow .get_state to fail | expand

Commit Message

Uwe Kleine-König Nov. 30, 2022, 3:21 p.m. UTC
.get_state() can return an error indication. Make use of it to propagate
failing hardware accesses.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/leds/rgb/leds-qcom-lpg.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Uwe Kleine-König Dec. 4, 2022, 9:04 p.m. UTC | #1
Hello Pavel,

On Wed, Nov 30, 2022 at 04:21:41PM +0100, Uwe Kleine-König wrote:
> .get_state() can return an error indication. Make use of it to propagate
> failing hardware accesses.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
>  drivers/leds/rgb/leds-qcom-lpg.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/leds/rgb/leds-qcom-lpg.c b/drivers/leds/rgb/leds-qcom-lpg.c
> index 741cc2fd817d..0dcc046a9a19 100644
> --- a/drivers/leds/rgb/leds-qcom-lpg.c
> +++ b/drivers/leds/rgb/leds-qcom-lpg.c
> @@ -982,20 +982,20 @@ static int lpg_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
>  
>  	ret = regmap_read(lpg->map, chan->base + LPG_SIZE_CLK_REG, &val);
>  	if (ret)
> -		return 0;
> +		return ret;
>  
>  	refclk = lpg_clk_rates[val & PWM_CLK_SELECT_MASK];
>  	if (refclk) {
>  		ret = regmap_read(lpg->map, chan->base + LPG_PREDIV_CLK_REG, &val);
>  		if (ret)
> -			return 0;
> +			return ret;
>  
>  		pre_div = lpg_pre_divs[FIELD_GET(PWM_FREQ_PRE_DIV_MASK, val)];
>  		m = FIELD_GET(PWM_FREQ_EXP_MASK, val);
>  
>  		ret = regmap_bulk_read(lpg->map, chan->base + PWM_VALUE_REG, &pwm_value, sizeof(pwm_value));
>  		if (ret)
> -			return 0;
> +			return ret;
>  
>  		state->period = DIV_ROUND_UP_ULL((u64)NSEC_PER_SEC * LPG_RESOLUTION * pre_div * (1 << m), refclk);
>  		state->duty_cycle = DIV_ROUND_UP_ULL((u64)NSEC_PER_SEC * pwm_value * pre_div * (1 << m), refclk);
> @@ -1006,7 +1006,7 @@ static int lpg_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
>  
>  	ret = regmap_read(lpg->map, chan->base + PWM_ENABLE_CONTROL_REG, &val);
>  	if (ret)
> -		return 0;
> +		return ret;
>  
>  	state->enabled = FIELD_GET(LPG_ENABLE_CONTROL_OUTPUT, val);
>  	state->polarity = PWM_POLARITY_NORMAL;

It would be great to get an Ack from you for this patch and the led part
of patch 1 to take it via the PWM tree.

Best regards
Uwe
Pavel Machek Dec. 4, 2022, 10:28 p.m. UTC | #2
Hi!

> > .get_state() can return an error indication. Make use of it to propagate
> > failing hardware accesses.
> > 
> > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

> 
> It would be great to get an Ack from you for this patch and the led part
> of patch 1 to take it via the PWM tree.

Let me take a look at that tommorow. Sorry for the delay.

Best regards,
									Pavel
Pavel Machek Dec. 5, 2022, 10:31 p.m. UTC | #3
Hi!

> .get_state() can return an error indication. Make use of it to propagate
> failing hardware accesses.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

Acked-by: Pavel Machek <pavel@ucw.cz>

Best regards,
							Pavel
Lee Jones Jan. 4, 2023, 4:56 p.m. UTC | #4
On Mon, 05 Dec 2022, Pavel Machek wrote:

> Hi!
> 
> > .get_state() can return an error indication. Make use of it to propagate
> > failing hardware accesses.
> > 
> > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> 
> Acked-by: Pavel Machek <pavel@ucw.cz>

What's the merge strategy for this?  Can it go in on its own?
Uwe Kleine-König Jan. 5, 2023, 1:54 p.m. UTC | #5
On Wed, Jan 04, 2023 at 04:56:21PM +0000, Lee Jones wrote:
> On Mon, 05 Dec 2022, Pavel Machek wrote:
> 
> > Hi!
> > 
> > > .get_state() can return an error indication. Make use of it to propagate
> > > failing hardware accesses.
> > > 
> > > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> > 
> > Acked-by: Pavel Machek <pavel@ucw.cz>
> 
> What's the merge strategy for this?  Can it go in on its own?

It's already in Linus's tree as fea768cf68c04d68ea2a8091c559667378f3b77c.

Best regards
Uwe
Lee Jones Jan. 5, 2023, 4:29 p.m. UTC | #6
On Thu, 05 Jan 2023, Uwe Kleine-König wrote:

> On Wed, Jan 04, 2023 at 04:56:21PM +0000, Lee Jones wrote:
> > On Mon, 05 Dec 2022, Pavel Machek wrote:
> > 
> > > Hi!
> > > 
> > > > .get_state() can return an error indication. Make use of it to propagate
> > > > failing hardware accesses.
> > > > 
> > > > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> > > 
> > > Acked-by: Pavel Machek <pavel@ucw.cz>
> > 
> > What's the merge strategy for this?  Can it go in on its own?
> 
> It's already in Linus's tree as fea768cf68c04d68ea2a8091c559667378f3b77c.

Interesting.  All good then, thanks for letting me know.
diff mbox series

Patch

diff --git a/drivers/leds/rgb/leds-qcom-lpg.c b/drivers/leds/rgb/leds-qcom-lpg.c
index 741cc2fd817d..0dcc046a9a19 100644
--- a/drivers/leds/rgb/leds-qcom-lpg.c
+++ b/drivers/leds/rgb/leds-qcom-lpg.c
@@ -982,20 +982,20 @@  static int lpg_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
 
 	ret = regmap_read(lpg->map, chan->base + LPG_SIZE_CLK_REG, &val);
 	if (ret)
-		return 0;
+		return ret;
 
 	refclk = lpg_clk_rates[val & PWM_CLK_SELECT_MASK];
 	if (refclk) {
 		ret = regmap_read(lpg->map, chan->base + LPG_PREDIV_CLK_REG, &val);
 		if (ret)
-			return 0;
+			return ret;
 
 		pre_div = lpg_pre_divs[FIELD_GET(PWM_FREQ_PRE_DIV_MASK, val)];
 		m = FIELD_GET(PWM_FREQ_EXP_MASK, val);
 
 		ret = regmap_bulk_read(lpg->map, chan->base + PWM_VALUE_REG, &pwm_value, sizeof(pwm_value));
 		if (ret)
-			return 0;
+			return ret;
 
 		state->period = DIV_ROUND_UP_ULL((u64)NSEC_PER_SEC * LPG_RESOLUTION * pre_div * (1 << m), refclk);
 		state->duty_cycle = DIV_ROUND_UP_ULL((u64)NSEC_PER_SEC * pwm_value * pre_div * (1 << m), refclk);
@@ -1006,7 +1006,7 @@  static int lpg_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
 
 	ret = regmap_read(lpg->map, chan->base + PWM_ENABLE_CONTROL_REG, &val);
 	if (ret)
-		return 0;
+		return ret;
 
 	state->enabled = FIELD_GET(LPG_ENABLE_CONTROL_OUTPUT, val);
 	state->polarity = PWM_POLARITY_NORMAL;