]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
pwm: Fix setting period with #pwm-cells = <1> and of_pwm_single_xlate()
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Fri, 29 Mar 2024 10:35:40 +0000 (11:35 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 30 May 2024 07:49:52 +0000 (09:49 +0200)
[ Upstream commit 73dfe970c038d0548beccc5bfb2707e1d543b01f ]

For drivers making use of of_pwm_single_xlate() (i.e. those that don't
pass a hwpwm index) and also don't pass flags, setting period was
wrongly skipped. This affects the pwm-pxa and ti-sn65dsi86 drivers.

Reported-by: Karel Balej <balejk@matfyz.cz>
Link: https://lore.kernel.org/r/D05IVTPYH35N.2CLDG6LSILRSN@matfyz.cz
Fixes: 40ade0c2e794 ("pwm: Let the of_xlate callbacks accept references without period")
Tested-by: Karel Balej <balejk@matfyz.cz>
Link: https://lore.kernel.org/r/20240329103544.545290-2-u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/pwm/core.c

index 830a697826af52653259ace0df281ebe7a1adf5f..9d2dc5e1c8aacc6866d840bfc9b5043d7be777ec 100644 (file)
@@ -443,7 +443,7 @@ of_pwm_single_xlate(struct pwm_chip *chip, const struct of_phandle_args *args)
        if (IS_ERR(pwm))
                return pwm;
 
-       if (args->args_count > 1)
+       if (args->args_count > 0)
                pwm->args.period = args->args[0];
 
        pwm->args.polarity = PWM_POLARITY_NORMAL;