mbox series

[v2,0/3] pwm: ensure pwm_apply_state() doesn't modify the state argument

Message ID 20190312214605.10223-1-u.kleine-koenig@pengutronix.de (mailing list archive)
Headers show
Series pwm: ensure pwm_apply_state() doesn't modify the state argument | expand

Message

Uwe Kleine-König March 12, 2019, 9:46 p.m. UTC
Hello,

this series eventually makes the "state" parameter of pwm_apply_state()
point to a const value. Two drivers (sun4i and rockchip) modfied the
contents here with good intentions, but I believe that it does more harm
than good. See the commit log of the last patch for a more detailed
reasoning.

The first two patches fix the two offending drivers to not modify the
state variable, then in the last patch the prototype of
pwm_apply_state() is changed to make the requirement to not change state
obvious. Note that the prototype of pwm_apply_state() already had a
const in include/linux/pwm.h for the !IS_ENABLED(CONFIG_PWM) case.

Compared to v1 sent earlier today, the sun4i patch is new. I missed that
there was a non-trivial change when preparing the patches and it was
folded into the last patch. Thanks to Thierry for spotting this. The end
result is unmodified.

Best regards
Uwe

Uwe Kleine-König (3):
  pwm: rockchip: Don't update the state for the caller of
    pwm_apply_state()
  pwm: sun4i: Don't update the state for the caller of pwm_apply_state()
  pwm: ensure pwm_apply_state() doesn't modify the state argument

 drivers/pwm/core.c            |  2 +-
 drivers/pwm/pwm-atmel-hlcdc.c |  2 +-
 drivers/pwm/pwm-atmel.c       |  2 +-
 drivers/pwm/pwm-bcm-iproc.c   |  2 +-
 drivers/pwm/pwm-cros-ec.c     |  2 +-
 drivers/pwm/pwm-hibvt.c       |  2 +-
 drivers/pwm/pwm-imx27.c       |  2 +-
 drivers/pwm/pwm-lpss.c        |  2 +-
 drivers/pwm/pwm-meson.c       |  2 +-
 drivers/pwm/pwm-rcar.c        |  2 +-
 drivers/pwm/pwm-rockchip.c    | 10 ++--------
 drivers/pwm/pwm-stm32-lp.c    |  2 +-
 drivers/pwm/pwm-sun4i.c       | 10 ++--------
 drivers/pwm/pwm-zx.c          |  2 +-
 include/linux/pwm.h           |  4 ++--
 15 files changed, 18 insertions(+), 30 deletions(-)