Re: [ibm-acpi-devel] [PATCH 1/4] thinkpad_acpi: Add support forcontrolling charge thresholds
From: Henrique de Moraes Holschuh
Date: Tue Dec 31 2013 - 07:12:43 EST
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;
get_current_stop_treshold(&stop);
if (start > stop)
stop = start + 1;
set_thresholds(start, stop);
when someone changes stop:
if (stop == 0 || stop > 100)
stop = 100;
get_current_start_threshold(&start);
if (start > stop)
start = stop - 1;
set_thresholds(start, stop);
And write the stop threshold mod 100 at the low-level "send thresholds to
the firmware" routine.
> Writing the value 0 effectively means setting the stop threshold to 100%.
> The EC itself does not accept the value 100. I don't know why they choose
> to implement it this way. So the code should not accept 0 as an input
> value and replace an input of 100 with 0.
Yes. This behaviour exists since start/stop thresholds were first exported
outside the EC, in the X30 or thereabouts.
> > For thinkpads, I believe the EC firmware changes the other threshold so that
> > the boundary condition stop > start is always valid. But I never tried it
> > with a direct EC write to validate this. If it becomes important, I can
> > check -- but I'd still prefer to enforce sanity at the driver level just in
> > case. Don't tempt the gremilins, for they live at boundary conditions and
> > their sleep is light indeed.
>
> It does not seem to do this here.
Then it is best if we enforce it in the driver. I've crashed thinkpad ECs
before, *don't tempt the gremilins* indeed.
--
"One disk to rule them all, One disk to find them. One disk to bring
them all and in the darkness grind them. In the Land of Redmond
where the shadows lie." -- The Silicon Valley Tarot
Henrique Holschuh
--
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/