Re: [PATCH] 2.6.24-rc1: ensure "present" sysfs attribute even if battery is absent

From: Andrey Borzenkov
Date: Sun Oct 28 2007 - 03:00:05 EST


On Saturday 27 October 2007, Anton Vorontsov wrote:
> On Sat, Oct 27, 2007 at 08:54:30PM +0400, Andrey Borzenkov wrote:
> > I am not exactly sure about this one ... what other power_supply class
> > drivers do? Should I fix HAL instead (but then, I do not know whether HAL
> > is the only application that is using this interface).
>
> Well, PROP_PRESENT wasn't my idea, currently it's used by pmu and
> olpc drivers becuase it's not trivial to register/unregister their
> batteries on physical insertion/removal. I have some plans to teach
> at least pmu batteries to not use PROP_PRESENT. I don't have any
> OLPC, thus I can't convert it.
>
> To sum this: the good way to handle "missing" batteries is to
> unregister them, so they'll not show up in the /sys/class/power_supply.

Well, in this case HAL behaviour makes sense (default to present == true
if "present" attribute is missing)

> Is that possible with the ACPI?
>

At least looking in ACPI specs, this looks possible. What currently is
presented as battery object is actually battery bay according to ACPI spec:

Unlike most other devices, when a battery is inserted or removed from the
system, the device itself (the
battery bay) is still considered to be present in the system.

When battery is inserted/removed, ACPI notifies us and we can check whether
battery is actually present and update registration accordingly. From the
sysfs structure POV probably nothing has to be changed; just when and how
power_supply is registered
under /sys/devices/LNXSYSTM:00/device:00/PNP0C0A:0n

Alexey, does it make sense (or doable)?

Attachment: signature.asc
Description: This is a digitally signed message part.