Message ID | 20231109104748.2746839-1-m.szyprowski@samsung.com |
---|---|
State | New |
Headers | show |
Series | [1/2] pwm: samsung: Fix broken resume after putting per-channel data into driver data | expand |
On Thu, Nov 9, 2023 at 4:48 AM Marek Szyprowski <m.szyprowski@samsung.com> wrote: > > PWMF_* enums are defined as flag values (like 1 << n), but then in the > code they are used as bit numbers via set/test/clear_bit() macros. Change > their values to sequential numbers to clearly show that they are bit > numbers, not the flag values. > > Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> > --- Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org> > include/linux/pwm.h | 9 ++++++--- > 1 file changed, 6 insertions(+), 3 deletions(-) > > diff --git a/include/linux/pwm.h b/include/linux/pwm.h > index e3b437587b32..95c895c63cf6 100644 > --- a/include/linux/pwm.h > +++ b/include/linux/pwm.h > @@ -40,9 +40,12 @@ struct pwm_args { > enum pwm_polarity polarity; > }; > > -enum { > - PWMF_REQUESTED = 1 << 0, > - PWMF_EXPORTED = 1 << 1, > +/** > + * enum pwm_flags_bits - status bits for pwm->flags entry > + */ > +enum pwm_flags_bits { > + PWMF_REQUESTED = 0, > + PWMF_EXPORTED = 1, > }; > > /* > -- > 2.34.1 >
Hello, On Thu, Nov 09, 2023 at 11:47:47AM +0100, Marek Szyprowski wrote: > PWMF_EXPORTED is misleadingly used as a bit numer in the pwm->flags, not > as a flag value, so the proper test for it must use test_bit() helper. > This fixes broken resume after putting per-channel data into driver data. > > Fixes: e3fe982b2e4e ("pwm: samsung: Put per-channel data into driver data") > Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> > --- > drivers/pwm/pwm-samsung.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/pwm/pwm-samsung.c b/drivers/pwm/pwm-samsung.c > index 568491ed6829..69d9f4577b34 100644 > --- a/drivers/pwm/pwm-samsung.c > +++ b/drivers/pwm/pwm-samsung.c > @@ -631,7 +631,7 @@ static int pwm_samsung_resume(struct device *dev) > struct pwm_device *pwm = &chip->pwms[i]; > struct samsung_pwm_channel *chan = &our_chip->channel[i]; > > - if (!(pwm->flags & PWMF_REQUESTED)) > + if (!test_bit(PWMF_REQUESTED, &pwm->flags)) > continue; This is prior art: https://lore.kernel.org/linux-pwm/e031db45-add0-4da7-97fa-dee95ee936ad@moroto.mountain/ unfortunately this was missed to be included in Thierry's PR for v6.7-rc1 :-\ Best regards Uwe
diff --git a/drivers/pwm/pwm-samsung.c b/drivers/pwm/pwm-samsung.c index 568491ed6829..69d9f4577b34 100644 --- a/drivers/pwm/pwm-samsung.c +++ b/drivers/pwm/pwm-samsung.c @@ -631,7 +631,7 @@ static int pwm_samsung_resume(struct device *dev) struct pwm_device *pwm = &chip->pwms[i]; struct samsung_pwm_channel *chan = &our_chip->channel[i]; - if (!(pwm->flags & PWMF_REQUESTED)) + if (!test_bit(PWMF_REQUESTED, &pwm->flags)) continue; if (our_chip->variant.output_mask & BIT(i))
PWMF_EXPORTED is misleadingly used as a bit numer in the pwm->flags, not as a flag value, so the proper test for it must use test_bit() helper. This fixes broken resume after putting per-channel data into driver data. Fixes: e3fe982b2e4e ("pwm: samsung: Put per-channel data into driver data") Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> --- drivers/pwm/pwm-samsung.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)