mbox series

[0/5] pwm: Use regmap_clear_bits and regmap_set_bits where applicable

Message ID 20221115111347.3705732-1-u.kleine-koenig@pengutronix.de
Headers show
Series pwm: Use regmap_clear_bits and regmap_set_bits where applicable | expand

Message

Uwe Kleine-König Nov. 15, 2022, 11:13 a.m. UTC
Hello,

I recently learned a bit of coccinelle and triggered by Paul Cercueil's
patch that replaces regmap_update_bits() by regmap_set_bits() and
regmap_clear_bits() where applicable in the jz4740 pwm driver[1] I
created a cocci patch for such calls.

This series adapts the other drivers below drivers/pwm accordingly.

Best regards
Uwe

[1] https://lore.kernel.org/linux-pwm/20221024205213.327001-6-paul@crapouillou.net

Uwe Kleine-König (5):
  pwm: fsl-ftm: Use regmap_clear_bits and regmap_set_bits where
    applicable
  pwm: img: Use regmap_clear_bits and regmap_set_bits where applicable
  pwm: iqs620a: Use regmap_clear_bits and regmap_set_bits where
    applicable
  pwm: stm32-lp: Use regmap_clear_bits and regmap_set_bits where
    applicable
  pwm: stm32: Use regmap_clear_bits and regmap_set_bits where applicable

 drivers/pwm/pwm-fsl-ftm.c  | 18 +++++++-----------
 drivers/pwm/pwm-img.c      | 15 +++++++--------
 drivers/pwm/pwm-iqs620a.c  |  4 ++--
 drivers/pwm/pwm-stm32-lp.c |  5 ++---
 drivers/pwm/pwm-stm32.c    | 34 ++++++++++++++++------------------
 5 files changed, 34 insertions(+), 42 deletions(-)


base-commit: 094226ad94f471a9f19e8f8e7140a09c2625abaa

Comments

Uwe Kleine-König Nov. 17, 2022, 1:52 p.m. UTC | #1
Hello,

On Tue, Nov 15, 2022 at 12:13:42PM +0100, Uwe Kleine-König wrote:
> I recently learned a bit of coccinelle and triggered by Paul Cercueil's
> patch that replaces regmap_update_bits() by regmap_set_bits() and
> regmap_clear_bits() where applicable in the jz4740 pwm driver[1] I
> created a cocci patch for such calls.

Pointing to this series I asked broonie in irc if a conversion like that
would be suitable to do in the complete tree. He objected that doing
that mechanically is probably wrong. His explicit concern was that a
call to regmap_clear_bits() (or regmap_set_bits()) in a series of
regmap_update_bits() is more disturbing than helpful.

So I looked at the remaining calls to regmap_update_bits() in the
drivers I converted in this series:

 - pwm-fsl-ftm
   There are two calls left that set bits in a mask (these should stay
   as they are) and one:

        reg_polarity = 0;
        if (newstate->polarity == PWM_POLARITY_INVERSED)
                reg_polarity = BIT(pwm->hwpwm);

        regmap_update_bits(fpc->regmap, FTM_POL, BIT(pwm->hwpwm), reg_polarity);

   which could benefit from a conversion (though I expect that to be
   controversial).
   The converted calls are all independent of the remaining
   regmap_update_bits().

 - pwm-img
   No regmap_update_bits() calls left.

 - pwm-iqs620a
   There is one call left that does:

        return regmap_update_bits(iqs62x->regmap, IQS620_PWR_SETTINGS,
                                  IQS620_PWR_SETTINGS_PWM_OUT, 0xff);

   I think this is a bug because IQS620_PWR_SETTINGS_PWM_OUT is only
   0xf.

 - pwm-stm32-lp
   No regmap_update_bits() calls left.

 - pwm-stm32
   There are several calls left, some of them also near converted calls.
   My personal opinion is, that the conversion is fine anyhow.

Best regards
Uwe