[1/4] pwm: hibvt: Explicitly set .polarity in .get_state()

Message ID 20230228135508.1798428-2-u.kleine-koenig@pengutronix.de
State New
Headers
Series pwm: Ensure .polarity is set in .get_state() |

Commit Message

Uwe Kleine-König Feb. 28, 2023, 1:55 p.m. UTC
  The driver only both polarities. Complete the implementation of
.get_state() by setting .polarity according to the configured hardware
state.

Fixes: d09f00810850 ("pwm: Add PWM driver for HiSilicon BVT SOCs")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/pwm/pwm-hibvt.c | 1 +
 1 file changed, 1 insertion(+)
  

Comments

Uwe Kleine-König March 10, 2023, 6:59 p.m. UTC | #1
[dropped yuanjian from To, as their address bounced when I submitted
this patch]

On Tue, Feb 28, 2023 at 02:55:05PM +0100, Uwe Kleine-König wrote:
> The driver only both polarities. Complete the implementation of

s/only/supports/

> .get_state() by setting .polarity according to the configured hardware
> state.
> 
> Fixes: d09f00810850 ("pwm: Add PWM driver for HiSilicon BVT SOCs")
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

Best regards
Uwe
  

Patch

diff --git a/drivers/pwm/pwm-hibvt.c b/drivers/pwm/pwm-hibvt.c
index 12c05c155cab..1b9274c5ad87 100644
--- a/drivers/pwm/pwm-hibvt.c
+++ b/drivers/pwm/pwm-hibvt.c
@@ -146,6 +146,7 @@  static int hibvt_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
 
 	value = readl(base + PWM_CTRL_ADDR(pwm->hwpwm));
 	state->enabled = (PWM_ENABLE_MASK & value);
+	state->polarity = (PWM_POLARITY_MASK & value) ? PWM_POLARITY_INVERSED : PWM_POLARITY_NORMAL;
 
 	return 0;
 }