pwm: Allow store 64-bit duty cycle from sysfs interface
PATCH 1/1 pwm: Allow store 64-bit duty cycle from sysfs interface
PWM core was converted to u64 by the commit a9d887dc1c60 ("pwm: Convert period and duty cycle to u64") but did not change the duty_cycle_store() so it will error out if trying to pass a numeric string bigger than 2^32-1.
Fix this by using u64 and kstrtou64() in duty_cycle_store().
---
I don't think this qualifies for a Fixes tag since original commit doesn't cause a regression while still might be good for v5.9 material.
--- drivers/pwm/sysfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pwm/sysfs.c +2 -2
@@ -87,10 +87,10 @@ static ssize_t duty_cycle_store(struct device *child,struct pwm_export *export =child_to_pwm_export (child);struct pwm_device *pwm = export->pwm;struct pwm_state state; -unsigned int val; +u64 val;int ret; - ret =kstrtouint (buf,0 , &val); + ret =kstrtou64 (buf,0 , &val);if (ret)return ret;
Signature · 1 line
2.28.0
Quoted 8 lines · Jarkko Nikula
PWM core was converted to u64 by the commit
a9d887dc1c60("pwm: Convert period and duty cycle to u64") but did not change theduty_cycle_store()so it will error out if trying to pass a numeric string bigger than 2^32-1.Fix this by using u64 and
kstrtou64()induty_cycle_store().Signed-off-by Jarkko Nikula <[email protected]>
I'd made the change to period_store(), but had missed doing the same for duty_cycle_store(). Thanks Jarkko for catching this.
Guru Das.
Quoted 27 lines
---
I don't think this qualifies for a Fixes tag since original commit doesn't cause a regression while still might be good for v5.9 material.--- drivers/pwm/sysfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/pwm/sysfs.c +2
-2@@ -87,10 +87,10 @@ static ssize_t duty_cycle_store(struct device *child,struct pwm_export *export =child_to_pwm_export (child);struct pwm_device *pwm = export->pwm;struct pwm_state state; -unsigned int val; +u64 val;int ret; - ret =kstrtouint (buf,0 , &val); + ret =kstrtou64 (buf,0 , &val);if (ret)return ret;Signature · 1 line
2.28.0
Quoted 8 lines · Jarkko Nikula
PWM core was converted to u64 by the commit
a9d887dc1c60("pwm: Convert period and duty cycle to u64") but did not change theduty_cycle_store()so it will error out if trying to pass a numeric string bigger than 2^32-1.Fix this by using u64 and
kstrtou64()induty_cycle_store().Signed-off-by Jarkko Nikula <[email protected]>
Thanks
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | https://www.pengutronix.de/ |
Thierry Reding
AppliedQuoted 7 lines · Jarkko Nikula
PWM core was converted to u64 by the commit
a9d887dc1c60("pwm: Convert period and duty cycle to u64") but did not change theduty_cycle_store()so it will error out if trying to pass a numeric string bigger than 2^32-1.Fix this by using u64 and
kstrtou64()induty_cycle_store().
Quoted 7 lines
Signed-off-by Jarkko Nikula <[email protected]>---
I don't think this qualifies for a Fixes tag since original commit doesn't cause a regression while still might be good for v5.9 material.--- drivers/pwm/sysfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Applied, thanks.
Thierry