From: Christopher Hall <christopher.s.hall@xxxxxxxxx> Add additional flag that can be set by drivers to indicate that the driver will manage its own PWM state. When calling pwm_ops.apply the driver applies the requested state change to the pwm_device reconciling, if possible, any conflicting requests. Intel(R) Timed I/O devices support very limited PWM capabilities. The duty cycle must always be 50% of the period. When changing one parameter at a time through the sysfs interface, it isn't possible for the user or the PWM subsystem to maintain this relation. Signed-off-by: Christopher Hall <christopher.s.hall@xxxxxxxxx> Signed-off-by: Tamal Saha <tamal.saha@xxxxxxxxx> Signed-off-by: Lakshmi Sowjanya D <lakshmi.sowjanya.d@xxxxxxxxx> Reviewed-by: Mark Gross <mgross@xxxxxxxxxxxxxxx> --- drivers/pwm/core.c | 3 ++- include/linux/pwm.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c index 35e894f4a379..c658585ac3bc 100644 --- a/drivers/pwm/core.c +++ b/drivers/pwm/core.c @@ -554,7 +554,8 @@ int pwm_apply_state(struct pwm_device *pwm, const struct pwm_state *state) trace_pwm_apply(pwm, state); - pwm->state = *state; + if (!test_bit(PWMF_DRIVERMANAGEDSTATE, &pwm->flags)) + pwm->state = *state; /* * only do this after pwm->state was applied as some diff --git a/include/linux/pwm.h b/include/linux/pwm.h index a0b7e43049d5..d805fee81e2c 100644 --- a/include/linux/pwm.h +++ b/include/linux/pwm.h @@ -46,6 +46,7 @@ struct pwm_args { enum { PWMF_REQUESTED = 1 << 0, PWMF_EXPORTED = 1 << 1, + PWMF_DRIVERMANAGEDSTATE = 1 << 2, }; /* -- 2.17.1