Re: [ibm-acpi-devel] [PATCH 1/4] thinkpad_acpi: Add support forcontrolling charge thresholds

From: Julian Andres Klode
Date: Tue Dec 31 2013 - 17:46:15 EST


On Tue, Dec 31, 2013 at 10:12:31AM -0200, Henrique de Moraes Holschuh wrote:
> On Tue, 31 Dec 2013, Julian Andres Klode wrote:
> > We might be able to work around this by simple setting stop = start
> > if a new write causes the stop threshold to be below the start
> > threshold. But this also seems ugly.
>
> It is the safest way, but the correct pseudo-code would be, assuiming
> unsigned:
>
> when someone changes start:
>
> if (start > 99)
> start = 99;

I think we should just return -EINVAL in such cases. Allowing users to
write larger percentages is a bit pointless (we don't allow them to write
negative ones either). And other promiment code (the backlight drivers)
seem to reject out-of-range values.

> set_thresholds(start, stop);

I think there should not be some common set_thresholds, because we also
need to write things in different orders for start / stop then:

DECREASE STOP => Write new start if needed, then write stop
INCREASE START => Write new stop if needed, then write start

Otherwise we might have a very very very short time in which start
is greater than stop.

I'll incorporate this in real code and test it tomorrow.

Sometimes after that, I'd like to tackle the integration with power_supply.
This is a bit more complicated, there even appear to be two battery drivers
in ACPI, namely battery and sbs, and battery is used on my system (I don't
know if that's the generic case on ThinkPads, or if is the case because
battery is builtin and sbs is not). How to do extend that is probably
something best discussed with ACPI maintainers, as I can't see
any mechanism for this.

--
Julian Andres Klode - Debian Developer, Ubuntu Member

See http://wiki.debian.org/JulianAndresKlode and http://jak-linux.org/.

Please do not top-post if possible.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/