* [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
* Re: [PATCH] pwm: Allow store 64-bit duty cycle from sysfs interface
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
2 siblings, 0 replies; 4+ messages in thread
From: Guru Das Srinagesh @ 2020-08-27 20:37 UTC (permalink / raw)
To: Jarkko Nikula; +Cc: linux-pwm, Thierry Reding, Uwe Kleine-König, Lee Jones
On Mon, Aug 24, 2020 at 05:55:39PM +0300, Jarkko Nikula wrote:
> 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>
Acked-by: Guru Das Srinagesh <gurus@codeaurora.org>
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.
> ---
> 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 [flat|nested] 4+ messages in thread
* Re: [PATCH] pwm: Allow store 64-bit duty cycle from sysfs interface
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
2 siblings, 0 replies; 4+ messages in thread
From: Uwe Kleine-König @ 2020-09-07 15:22 UTC (permalink / raw)
To: Jarkko Nikula; +Cc: linux-pwm, Thierry Reding, Lee Jones, Guru Das Srinagesh
[-- Attachment #1: Type: text/plain, Size: 670 bytes --]
On Mon, Aug 24, 2020 at 05:55:39PM +0300, Jarkko Nikula wrote:
> 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>
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Thanks
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | https://www.pengutronix.de/ |
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] pwm: Allow store 64-bit duty cycle from sysfs interface
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
2 siblings, 0 replies; 4+ messages in thread
From: Thierry Reding @ 2020-09-23 12:11 UTC (permalink / raw)
To: Jarkko Nikula
Cc: linux-pwm, Uwe Kleine-König, Lee Jones, Guru Das Srinagesh
[-- Attachment #1: Type: text/plain, Size: 708 bytes --]
On Mon, Aug 24, 2020 at 05:55:39PM +0300, Jarkko Nikula wrote:
> 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(-)
Applied, thanks.
Thierry
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [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