diff mbox series

gpio: mvebu/pwm: Refuse requests with inverted polarity

Message ID 20220511075856.88687-1-u.kleine-koenig@pengutronix.de
State Accepted
Commit 3ecb10175b1f776f076553c24e2689e42953fef5
Headers show
Series gpio: mvebu/pwm: Refuse requests with inverted polarity | expand

Commit Message

Uwe Kleine-König May 11, 2022, 7:58 a.m. UTC
The driver doesn't take struct pwm_state::polarity into account when
configuring the hardware, so refuse requests for inverted polarity.

Fixes: 757642f9a584 ("gpio: mvebu: Add limited PWM support")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/gpio/gpio-mvebu.c | 3 +++
 1 file changed, 3 insertions(+)


base-commit: 3123109284176b1532874591f7c81f3837bbdc17

Comments

Bartosz Golaszewski May 14, 2022, 12:52 p.m. UTC | #1
On Wed, May 11, 2022 at 9:59 AM Uwe Kleine-König
<u.kleine-koenig@pengutronix.de> wrote:
>
> The driver doesn't take struct pwm_state::polarity into account when
> configuring the hardware, so refuse requests for inverted polarity.
>
> Fixes: 757642f9a584 ("gpio: mvebu: Add limited PWM support")
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
>  drivers/gpio/gpio-mvebu.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c
> index 4c1f9e1091b7..92ecaea2d5d4 100644
> --- a/drivers/gpio/gpio-mvebu.c
> +++ b/drivers/gpio/gpio-mvebu.c
> @@ -707,6 +707,9 @@ static int mvebu_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
>         unsigned long flags;
>         unsigned int on, off;
>
> +       if (state->polarity != PWM_POLARITY_NORMAL)
> +               return -EINVAL;
> +
>         val = (unsigned long long) mvpwm->clk_rate * state->duty_cycle;
>         do_div(val, NSEC_PER_SEC);
>         if (val > UINT_MAX + 1ULL)
>
> base-commit: 3123109284176b1532874591f7c81f3837bbdc17
> --
> 2.35.1
>

Applied, thanks!

Bart
diff mbox series

Patch

diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c
index 4c1f9e1091b7..92ecaea2d5d4 100644
--- a/drivers/gpio/gpio-mvebu.c
+++ b/drivers/gpio/gpio-mvebu.c
@@ -707,6 +707,9 @@  static int mvebu_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
 	unsigned long flags;
 	unsigned int on, off;
 
+	if (state->polarity != PWM_POLARITY_NORMAL)
+		return -EINVAL;
+
 	val = (unsigned long long) mvpwm->clk_rate * state->duty_cycle;
 	do_div(val, NSEC_PER_SEC);
 	if (val > UINT_MAX + 1ULL)