Skip to contentSkip to conversation

apm.c and multiple battery slots

DISCUSSION Thomas Hood 2 participants 2 messages Feb 2, 2002

lore
Share & tools
lore
#0 lore raw
Quoted 10 lines

I went to apm.c to look into patching it to support multiple batteries.
I found this function:
static int apm_get_battery_status(which, status, bat,
life, nbat <- battery #)
but it's #if 0'd out, and isn't referred to anywhere in the code. I looked at the changelog in the file to try to determine when it stopped being used, and why, but I found no useful information, and I can't even ask the person who did it, since they didn't tell me they did...

I am not the author, so the following is speculation. My guess is that apm_get_battery_status() was written to support multiple batteries (supported by APM 1.2 only) but that the authors never got around to providing a user interface to this functionality; so it remains ifdeffed out. (Hence the function never "stopped" being used.)

The current official maintainer of the driver is Stephen Rothwell.

Stephen: How do you think the info about the second battery might be furnished to the user?

--
Thomas

#1 lore raw
Quoted 11 lines · you

I am not the author, so the following is speculation. My guess is that apm_get_battery_status() was written to support multiple batteries (supported by APM 1.2 only) but that the authors never got around to providing a user interface to this functionality; so it remains ifdeffed out. (Hence the function never "stopped" being used.)

The current official maintainer of the driver is Stephen Rothwell.

Stephen: How do you think the info about the second battery might be furnished to the user?

I already thought about that a bit... what if we changed /proc/apm again, adding one line for each possible battery slot?

The current format is:

<driver version> <BIOS version> <APM flags> <AC status> <battery status> <battery flag> <battery left (%)> <remaining time> <remaining time units (min/sec)>

I suggest we change the first line to reflect an overall battery status (i.e. average of all slots in system). Then we could add one line for each battery slot, indicating <battery status> <battery flag> <battery left % > <remaining time in seconds>

I suggest we always show the new stuff in seconds because I like easily parsed things, and even shell scripts can divide by 60 if they want to ;)

If there's no battery in this slot, we can show the usual of -1's, or just put "? ? ? ?".

So on my system, I would see this if I did

$ cat /proc/apm
1.16 1.2 0x03 0x01 0x03 0x09 94% 283 min
0x04 0x80 -1 -1
0x03 0x09 94 16980

Whoever manages apmd also probably has some suggestions...

(btw, "Stephen" is a really great name ;)

--
Stevie-O

Real programmers use COPY CON VMLINUZ then run LoadLin