* [PATCH 0/2] platform/x86: clamp charge thresholds on fujitsu
@ 2025-06-09 10:21 Jelle van der Waa
2025-06-09 10:21 ` [PATCH 1/2] platform/x86: fujitsu: use unsigned int for kstrtounit Jelle van der Waa
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Jelle van der Waa @ 2025-06-09 10:21 UTC (permalink / raw)
To: Jonathan Woithe, Hans de Goede, Ilpo Järvinen
Cc: Jelle van der Waa, platform-driver-x86
For userspace programs it is not know what the valid charge control
threshold values are, clamping them to the nearest supported threshold
makes the API easier to use for power management daemons such as UPower.
Jelle van der Waa (2):
platform/x86: fujitsu: use unsigned int for kstrtounit
platform/x86: fujitsu: clamp charge_control_end_threshold values to 50
drivers/platform/x86/fujitsu-laptop.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
--
2.49.0
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH 1/2] platform/x86: fujitsu: use unsigned int for kstrtounit
2025-06-09 10:21 [PATCH 0/2] platform/x86: clamp charge thresholds on fujitsu Jelle van der Waa
@ 2025-06-09 10:21 ` Jelle van der Waa
2025-06-09 10:36 ` Hans de Goede
2025-06-13 10:14 ` Ilpo Järvinen
2025-06-09 10:21 ` [PATCH 2/2] platform/x86: fujitsu: clamp charge_control_end_threshold values to 50 Jelle van der Waa
2025-06-09 10:47 ` [PATCH 0/2] platform/x86: clamp charge thresholds on fujitsu Jonathan Woithe
2 siblings, 2 replies; 7+ messages in thread
From: Jelle van der Waa @ 2025-06-09 10:21 UTC (permalink / raw)
To: Jonathan Woithe, Hans de Goede, Ilpo Järvinen
Cc: Jelle van der Waa, platform-driver-x86
The charge control threshold value ranges from 0-100.
Signed-off-by: Jelle van der Waa <jvanderwaa@redhat.com>
---
drivers/platform/x86/fujitsu-laptop.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c
index 162809140f68..c8aeb28a783c 100644
--- a/drivers/platform/x86/fujitsu-laptop.c
+++ b/drivers/platform/x86/fujitsu-laptop.c
@@ -180,7 +180,8 @@ static ssize_t charge_control_end_threshold_store(struct device *dev,
const char *buf, size_t count)
{
int cc_end_value, s006_cc_return;
- int value, ret;
+ int ret;
+ unsigned int value;
ret = kstrtouint(buf, 10, &value);
if (ret)
--
2.49.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH 1/2] platform/x86: fujitsu: use unsigned int for kstrtounit
2025-06-09 10:21 ` [PATCH 1/2] platform/x86: fujitsu: use unsigned int for kstrtounit Jelle van der Waa
@ 2025-06-09 10:36 ` Hans de Goede
2025-06-13 10:14 ` Ilpo Järvinen
1 sibling, 0 replies; 7+ messages in thread
From: Hans de Goede @ 2025-06-09 10:36 UTC (permalink / raw)
To: Jelle van der Waa, Jonathan Woithe, Ilpo Järvinen
Cc: platform-driver-x86
Hi,
On 9-Jun-25 12:21 PM, Jelle van der Waa wrote:
> The charge control threshold value ranges from 0-100.
>
> Signed-off-by: Jelle van der Waa <jvanderwaa@redhat.com>
Thanks, patch looks good to me:
Reviewed-by: Hans de Goede <hansg@kernel.org>
Regards,
Hans
> ---
> drivers/platform/x86/fujitsu-laptop.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c
> index 162809140f68..c8aeb28a783c 100644
> --- a/drivers/platform/x86/fujitsu-laptop.c
> +++ b/drivers/platform/x86/fujitsu-laptop.c
> @@ -180,7 +180,8 @@ static ssize_t charge_control_end_threshold_store(struct device *dev,
> const char *buf, size_t count)
> {
> int cc_end_value, s006_cc_return;
> - int value, ret;
> + int ret;
> + unsigned int value;
>
> ret = kstrtouint(buf, 10, &value);
> if (ret)
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH 1/2] platform/x86: fujitsu: use unsigned int for kstrtounit
2025-06-09 10:21 ` [PATCH 1/2] platform/x86: fujitsu: use unsigned int for kstrtounit Jelle van der Waa
2025-06-09 10:36 ` Hans de Goede
@ 2025-06-13 10:14 ` Ilpo Järvinen
1 sibling, 0 replies; 7+ messages in thread
From: Ilpo Järvinen @ 2025-06-13 10:14 UTC (permalink / raw)
To: Jelle van der Waa; +Cc: Jonathan Woithe, Hans de Goede, platform-driver-x86
On Mon, 9 Jun 2025, Jelle van der Waa wrote:
> The charge control threshold value ranges from 0-100.
>
> Signed-off-by: Jelle van der Waa <jvanderwaa@redhat.com>
> ---
> drivers/platform/x86/fujitsu-laptop.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c
> index 162809140f68..c8aeb28a783c 100644
> --- a/drivers/platform/x86/fujitsu-laptop.c
> +++ b/drivers/platform/x86/fujitsu-laptop.c
> @@ -180,7 +180,8 @@ static ssize_t charge_control_end_threshold_store(struct device *dev,
> const char *buf, size_t count)
> {
> int cc_end_value, s006_cc_return;
> - int value, ret;
> + int ret;
> + unsigned int value;
Thanks.
I've applied this series to the review-ilpo-next branch but I changed
these variables to the reverse xmas-tree order while applying. In general,
if there's no good reason to do otherwise, reverse xmas tree order is
preferred for local variables.
>
> ret = kstrtouint(buf, 10, &value);
> if (ret)
>
--
i.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/2] platform/x86: fujitsu: clamp charge_control_end_threshold values to 50
2025-06-09 10:21 [PATCH 0/2] platform/x86: clamp charge thresholds on fujitsu Jelle van der Waa
2025-06-09 10:21 ` [PATCH 1/2] platform/x86: fujitsu: use unsigned int for kstrtounit Jelle van der Waa
@ 2025-06-09 10:21 ` Jelle van der Waa
2025-06-09 10:38 ` Hans de Goede
2025-06-09 10:47 ` [PATCH 0/2] platform/x86: clamp charge thresholds on fujitsu Jonathan Woithe
2 siblings, 1 reply; 7+ messages in thread
From: Jelle van der Waa @ 2025-06-09 10:21 UTC (permalink / raw)
To: Jonathan Woithe, Hans de Goede, Ilpo Järvinen
Cc: Jelle van der Waa, platform-driver-x86
Follow the sysfs ABI documentation that drivers should round written
values to the nearest supported value instead of returning an error.
Tested on a Fujitsu Lifebook U7720.
Signed-off-by: Jelle van der Waa <jvanderwaa@redhat.com>
---
drivers/platform/x86/fujitsu-laptop.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c
index c8aeb28a783c..f6a4a02e8d44 100644
--- a/drivers/platform/x86/fujitsu-laptop.c
+++ b/drivers/platform/x86/fujitsu-laptop.c
@@ -187,9 +187,12 @@ static ssize_t charge_control_end_threshold_store(struct device *dev,
if (ret)
return ret;
- if (value < 50 || value > 100)
+ if (value > 100)
return -EINVAL;
+ if (value < 50)
+ value = 50;
+
cc_end_value = value * 0x100 + 0x20;
s006_cc_return = call_fext_func(fext, FUNC_S006_METHOD,
CHARGE_CONTROL_RW, cc_end_value, 0x0);
--
2.49.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] platform/x86: fujitsu: clamp charge_control_end_threshold values to 50
2025-06-09 10:21 ` [PATCH 2/2] platform/x86: fujitsu: clamp charge_control_end_threshold values to 50 Jelle van der Waa
@ 2025-06-09 10:38 ` Hans de Goede
0 siblings, 0 replies; 7+ messages in thread
From: Hans de Goede @ 2025-06-09 10:38 UTC (permalink / raw)
To: Jelle van der Waa, Jonathan Woithe, Ilpo Järvinen
Cc: platform-driver-x86
Hi,
On 9-Jun-25 12:21 PM, Jelle van der Waa wrote:
> Follow the sysfs ABI documentation that drivers should round written
> values to the nearest supported value instead of returning an error.
>
> Tested on a Fujitsu Lifebook U7720.
>
> Signed-off-by: Jelle van der Waa <jvanderwaa@redhat.com>
Thanks, patch looks good to me:
Reviewed-by: Hans de Goede <hansg@kernel.org>
Regards,
Hans
> ---
> drivers/platform/x86/fujitsu-laptop.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c
> index c8aeb28a783c..f6a4a02e8d44 100644
> --- a/drivers/platform/x86/fujitsu-laptop.c
> +++ b/drivers/platform/x86/fujitsu-laptop.c
> @@ -187,9 +187,12 @@ static ssize_t charge_control_end_threshold_store(struct device *dev,
> if (ret)
> return ret;
>
> - if (value < 50 || value > 100)
> + if (value > 100)
> return -EINVAL;
>
> + if (value < 50)
> + value = 50;
> +
> cc_end_value = value * 0x100 + 0x20;
> s006_cc_return = call_fext_func(fext, FUNC_S006_METHOD,
> CHARGE_CONTROL_RW, cc_end_value, 0x0);
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 0/2] platform/x86: clamp charge thresholds on fujitsu
2025-06-09 10:21 [PATCH 0/2] platform/x86: clamp charge thresholds on fujitsu Jelle van der Waa
2025-06-09 10:21 ` [PATCH 1/2] platform/x86: fujitsu: use unsigned int for kstrtounit Jelle van der Waa
2025-06-09 10:21 ` [PATCH 2/2] platform/x86: fujitsu: clamp charge_control_end_threshold values to 50 Jelle van der Waa
@ 2025-06-09 10:47 ` Jonathan Woithe
2 siblings, 0 replies; 7+ messages in thread
From: Jonathan Woithe @ 2025-06-09 10:47 UTC (permalink / raw)
To: Jelle van der Waa; +Cc: Hans de Goede, Ilpo Järvinen, platform-driver-x86
On Mon, Jun 09, 2025 at 12:21:12PM +0200, Jelle van der Waa wrote:
> For userspace programs it is not know what the valid charge control
> threshold values are, clamping them to the nearest supported threshold
> makes the API easier to use for power management daemons such as UPower.
>
> Jelle van der Waa (2):
> platform/x86: fujitsu: use unsigned int for kstrtounit
> platform/x86: fujitsu: clamp charge_control_end_threshold values to 50
>
> drivers/platform/x86/fujitsu-laptop.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> --
> 2.49.0
This patch series looks good to me.
Acked-by: Jonathan Woithe <jwoithe@just42.net>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-06-13 10:14 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-09 10:21 [PATCH 0/2] platform/x86: clamp charge thresholds on fujitsu Jelle van der Waa
2025-06-09 10:21 ` [PATCH 1/2] platform/x86: fujitsu: use unsigned int for kstrtounit Jelle van der Waa
2025-06-09 10:36 ` Hans de Goede
2025-06-13 10:14 ` Ilpo Järvinen
2025-06-09 10:21 ` [PATCH 2/2] platform/x86: fujitsu: clamp charge_control_end_threshold values to 50 Jelle van der Waa
2025-06-09 10:38 ` Hans de Goede
2025-06-09 10:47 ` [PATCH 0/2] platform/x86: clamp charge thresholds on fujitsu Jonathan Woithe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox