[PATCH v3 3/3] platform/x86: dell-laptop: Make the charge end threshold unsigned

From: Rosen Penev

Date: Wed Nov 25 2026 - 18:21:41 EST


charge_control_end_threshold_store() passes a pointer to an int to
kstrtouint(), which only builds because the kernel disables
-Wpointer-sign, and makes the following "end < 0" check dead code.

Declare end as unsigned int to match kstrtouint() and drop the dead
check. kstrtouint() already rejects negative input, so the accepted
range is unchanged.

Signed-off-by: Rosen Penev <rosenp@xxxxxxxxx>
---
v3: make end unsigned int and drop the dead check instead of switching
to kstrtoint(); retitled (review feedback)
v2: unchanged

drivers/platform/x86/dell/dell-laptop.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/x86/dell/dell-laptop.c b/drivers/platform/x86/dell/dell-laptop.c
index eca348497ac3..1e2867f182c8 100644
--- a/drivers/platform/x86/dell/dell-laptop.c
+++ b/drivers/platform/x86/dell/dell-laptop.c
@@ -2380,12 +2380,13 @@ static ssize_t charge_control_end_threshold_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t size)
{
- int ret, end;
+ unsigned int end;
+ int ret;

ret = kstrtouint(buf, 10, &end);
if (ret)
return ret;
- if (end < 0 || end > 100)
+ if (end > 100)
return -EINVAL;

ret = dell_battery_set_custom_charge_end(end);
--
2.56.1