ec battery commands

Andres Salomon dilinger at queued.net
Sat Nov 1 18:26:16 EDT 2008


On Sat, 01 Nov 2008 16:39:49 -0400
Paul Fox <pgf at foxharp.boston.ma.us> wrote:

> hi dilinger -- one of the tasks on the EC punchlist is this one:
> 
> "Make battery commands return 0xff (or some other invalid value)
> if the battery is not present.  This will be an error indication
> for the kernel."
> 
> can you point me at the kernel code that cares about this, and, in
> particular if you can remember, for which commands it's most important
> to have this behavior changed?  i'd like to be sure i understand
> the req'ts before implementing anything.
> 

Certainly; the specific code is drivers/power/olpc_battery.c.  The code that
is acutally querying the battery status is olpc_bat_get_property().  Due
to the current limitations of the API, we cannot simply fetch EC_BAT_ACR;
every value is valid, and (aiui) the EC will simply return the last known
value.  This is undesirable if there's no battery present, so we currently
first check EC_BAT_STATUS (for PRESENT), and then run the necessary EC
command.  This means that each query ends up running 2 EC commands.  It
would be nice to cut that down to 1.

Along those lines, it would be nice if there was an error value that we
could check for if the EC thinks that there is no battery present, and
we run some random command that is querying for battery info.  Richard
and I discussed this a bunch a long time ago, but it was in person and
my memory is fuzzy..  I don't remember if we came up w/ a value that
would work across all EC battery commands.  It would kind of suck if
we had to have different error codes for different commands, but that
would still be better than our current behavior.



More information about the Devel mailing list