]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
platform/x86: fujitsu: clamp charge_control_end_threshold values to 50
authorJelle van der Waa <jvanderwaa@redhat.com>
Mon, 9 Jun 2025 10:21:14 +0000 (12:21 +0200)
committerIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Fri, 13 Jun 2025 09:33:28 +0000 (12:33 +0300)
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>
Reviewed-by: Hans de Goede <hansg@kernel.org>
Acked-by: Jonathan Woithe <jwoithe@just42.net>
Link: https://lore.kernel.org/r/20250609102115.36936-3-jvanderwaa@redhat.com
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
drivers/platform/x86/fujitsu-laptop.c

index c6ec61518160bbac84e7e256f4e89fd20938f6c2..931fbcdd21b88659ecd4998aa2559b1875c8eefb 100644 (file)
@@ -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);