public inbox for linux-pwm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pwm: Allow store 64-bit duty cycle from sysfs interface
@ 2020-08-24 14:55 Jarkko Nikula
  2020-08-27 20:37 ` Guru Das Srinagesh
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jarkko Nikula @ 2020-08-24 14:55 UTC (permalink / raw)
  To: linux-pwm
  Cc: Thierry Reding, Uwe Kleine-König, Lee Jones,
	Guru Das Srinagesh, Jarkko Nikula

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().

Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
---
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(-)

diff --git a/drivers/pwm/sysfs.c b/drivers/pwm/sysfs.c
index 449dbc0f49ed..9903c3a7eced 100644
--- a/drivers/pwm/sysfs.c
+++ b/drivers/pwm/sysfs.c
@@ -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;
 
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-09-23 12:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-08-24 14:55 [PATCH] pwm: Allow store 64-bit duty cycle from sysfs interface Jarkko Nikula
2020-08-27 20:37 ` Guru Das Srinagesh
2020-09-07 15:22 ` Uwe Kleine-König
2020-09-23 12:11 ` Thierry Reding

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox