From dce77641056ea4fb2efab0a66d6929a5008d7235 Mon Sep 17 00:00:00 2001 From: Jelle van der Waa Date: Mon, 9 Jun 2025 12:21:14 +0200 Subject: [PATCH] platform/x86: fujitsu: clamp charge_control_end_threshold values to 50 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Hans de Goede Acked-by: Jonathan Woithe Link: https://lore.kernel.org/r/20250609102115.36936-3-jvanderwaa@redhat.com Reviewed-by: Ilpo Järvinen Signed-off-by: Ilpo Järvinen --- 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 c6ec61518160b..931fbcdd21b88 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.47.2