Re: Battery class driver.



On Mon, 2006-10-23 at 15:59 -0700, Greg KH wrote:
So, perhaps the battery class should provide a file called 'timestamp'
or something that is only writable by the super user. If you read from
that file it gives the time when the information was last updated. If
you write to the file it will force the driver query the hardware and
update the other files. Reading any other file than 'timestamp' will
just read cached information.

You can poll the sysfs file, which means you just sleep until something
changes in it and then you wake up and read it. Sound accepatble?

Yea, however I still think there needs to be a 'timestamp' file so

a) we don't need to poll every file in /sys/class/battery/BAT0
(if we had to do that, we would (potentially) wake up N times!); and

b) if the kernel ensures that the 'timestamp' file is updated last,
we get atomic updates (which might matter for drawing pretty graphs,
guestimating remaining time etc.); and

c) it provides some mechanism to instruct the driver to go read the
values from the hardware (if that is what user space wants)
nonwithstanding that the hardware / driver delivers asynchronous
updates once in a while via an IRQ.

Notably user space can see _when_ the values from the hardware was
retrieved the last time which makes it easier to work around with
hardware / drivers that don't provide asynchronous updates even
when they are supposed to (if there is some bug with e.g. the ACPI
stack).

This implies that the battery class should probably cache the values as
to make the platform driver as simple as possible. I've got a bad
feeling things like caching is badly frowned upon in kernel space but I
thought I'd ask for it anyway :-). I hope I've stated my case :-)

(Anyway, the point is that I want to avoid having an open file
descriptor for each and every file in /sys/class/battery/BAT0 to put it
into the huge poll() stmt in my main loop (granted with things like glib
it's dead simple), that's all.. Caching might also avoid excessive round
trips to the hardware but one can argue both way in most cases.)

So.. how all this relates to hwmon I'm not sure.. looking briefly at
Documentation/hwmon/sysfs-interface no such thing seems to be available,
I'm not sure how libsensors get by here but the problem is sorta
similar. I do think batteries in itself deserves it's own abstraction
instead of using hwmon but I'm no expert on this.

Btw, an OLPC specific feature is also to instruct the Embedded
Controller (EC) to stop delivering IRQ's on battery/ac_adapter changes.
This is so the host CPU won't be woken up when e.g. in e-book reader
mode (or whatever) where the host CPU is supposed to be turned off to
save juice.
This is simple right now as the EC currently doesn't deliver any IRQ's
at all [1] and I guess a simple sysfs file in the OLPC platform device
will let us do that once we actually get IRQ delivery. Thus, I'm not
sure "stop IRQ delivery" belongs in the battery class proper. This is
also why we need device link to the OLPC platform device.

David

[1] : but see http://dev.laptop.org/ticket/224



-
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/



Relevant Pages

  • Re: 2008 SBS no longer boots
    ... It sounds like you have a driver since the problem re-occurs even after a re-install. ... This gives you the ability to see what updates you are installing. ... If it is a security patch, for example, then you contact MS and find out why it kills your hardware. ... Then he had me look through the BIOS to change the SATA mode of the RAID ...
    (microsoft.public.windows.server.sbs)
  • Re: 2008 SBS no longer boots
    ... it were, the machine wouldn't run after reinstall, it does. ... Also, if it were hardware, and it is this consistent through ... it pulls all the updates in itself. ... driver updates tho'. ...
    (microsoft.public.windows.server.sbs)
  • Re: switching between slideshow & program causes white border to appear
    ... of the latest updates for MacOS? ... MVPs are not Microsoft Employees ... Then the problem might be hardware and/or device driver specific. ...
    (microsoft.public.mac.office.powerpoint)
  • Re: HP 873n Big Problems
    ... Have you looked in Device Manager, if it really is a driver problem? ... > Virus Definition updates. ... > destructive recovery when there should be no unknown drivers. ... > however the hardware testing should have dectected a problem here. ...
    (microsoft.public.windows.mediacenter)
  • [opensuse] openSUSE 10.3 not detecting SATA HD
    ... the sata_sis driver. ... I've tried turning off ACPI in bios and acpi=off which ... openSUSE 10.2 and all my hardware is working fine. ... info.product = 'USB Raw Device Access' ...
    (SuSE)