Re: [PATCH v2 2/7] platform/x86: uniwill-laptop: Accept charging threshold of 0
From: Ilpo Järvinen
Date: Thu Apr 30 2026 - 08:56:21 EST
On Fri, 17 Apr 2026, Armin Wolf wrote:
> The power supply sysfs ABI states that:
>
> Not all hardware is capable of setting this to an arbitrary
> percentage. Drivers will round written values to the nearest
> supported value. Reading back the value will show the actual
> threshold set by the driver.
>
> The driver currently violates this ABI by rejecting a charging
> threshold of 0. Fix this by clamping this value to 1.
>
> Fixes: d050479693bb ("platform/x86: Add Uniwill laptop driver")
> Reviewed-by: Werner Sembach <wse@xxxxxxxxxxxxxxxxxxx>
> Signed-off-by: Armin Wolf <W_Armin@xxxxxx>
> ---
> drivers/platform/x86/uniwill/uniwill-acpi.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/platform/x86/uniwill/uniwill-acpi.c b/drivers/platform/x86/uniwill/uniwill-acpi.c
> index 8f16c94221aa..5551f193c2c1 100644
> --- a/drivers/platform/x86/uniwill/uniwill-acpi.c
> +++ b/drivers/platform/x86/uniwill/uniwill-acpi.c
> @@ -1424,11 +1424,11 @@ static int uniwill_set_property(struct power_supply *psy, const struct power_sup
>
> switch (psp) {
> case POWER_SUPPLY_PROP_CHARGE_CONTROL_END_THRESHOLD:
> - if (val->intval < 1 || val->intval > 100)
> + if (val->intval < 0 || val->intval > 100)
> return -EINVAL;
>
> return regmap_update_bits(data->regmap, EC_ADDR_CHARGE_CTRL, CHARGE_CTRL_MASK,
> - val->intval);
> + max(val->intval, 1));
> default:
> return -EINVAL;
> }
>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@xxxxxxxxxxxxxxx>
--
i.