Skip to contentSkip to conversation

/sys/class/power_supply/BAT0/ shouldn't disappear when battery is unplugged

BUG Maxim Levitsky 2 participants 3 messages Apr 26, 2009 – Apr 28, 2009

lore
Share & tools
lore
#0 lore raw

New sysfs battery interface has a flaw.

Suppose I removed battery from the system, and then booted it. then gnome power manager has no idea that my system has battery, and thus it hides battery settings.

It also has a bug that prevents it from hiding battery icon, when I unplug the battery, in other words, it isn't prepared for battery to disappear.

I think it would be nice to keep /sys/class/power_supply/BAT0/ even if battery isn't present.

btw, there is /sys/class/power_supply/BAT0/present, thus maybe this is just a bug?

Best regards,
Maxim Levitsky

#1 lore raw
Quoted 5 lines · Maxim Levitsky

New sysfs battery interface has a flaw.

Suppose I removed battery from the system, and then booted it. then gnome power manager has no idea that my system has battery, and thus it hides battery settings.

If after insertion the battery is visible in /sys/class/power_supply/, then it's not a kernel bug. That's purely gnome issue (or HAL), it seem to not handle hot-plugged batteries.

Quoted 3 lines

It also has a bug that prevents it from hiding battery icon, when I unplug the battery, in other words, it isn't prepared for battery to disappear.

Again, you should report that to HAL/Gnome maintainers, so that gnome power manager would handle battery removal events generated by the power supply class.

Quoted 2 lines

I think it would be nice to keep /sys/class/power_supply/BAT0/ even if battery isn't present.

That isn't always possible. Imagine a battery inside some hot-pluggable PCI device. Or an USB device, or a battery with a built-in controller connected through W1 bus (i.e. batteries w/ ds2760 chip).

Quoted 2 lines

btw, there is /sys/class/power_supply/BAT0/present, thus maybe this is just a bug?

Nope. And personally I think we should remove the "present" property, and drivers should learn to remove stuff from power_supply/ if there is no battery inserted. But so far HAL/Gnome/whatever have to handle both methods.

Thanks,

Signature · 3 lines
Anton Vorontsov
email: [email protected]
irc://irc.freenode.net/bd2
#2 lore raw
Quoted 10 lines · Anton Vorontsov
Quoted 5 lines · Maxim Levitsky

New sysfs battery interface has a flaw.

Suppose I removed battery from the system, and then booted it. then gnome power manager has no idea that my system has battery, and thus it hides battery settings.

If after insertion the battery is visible in /sys/class/power_supply/, then it's not a kernel bug. That's purely gnome issue (or HAL), it seem to not handle hot-plugged batteries.

No, I am talking about the following situation:

Suppose:

I keep battery in the closet.
I turn my system on
Gpm has no idea my system has a battery, thus it hides battery tab. I want to set change battery settings.

Quoted 8 lines
Quoted 4 lines

It also has a bug that prevents it from hiding battery icon, when I unplug the battery, in other words, it isn't prepared for battery to disappear.

Again, you should report that to HAL/Gnome maintainers, so that gnome power manager would handle battery removal events generated by the power supply class.

I did, no reaction so far...

Quoted 7 lines
Quoted 3 lines

I think it would be nice to keep /sys/class/power_supply/BAT0/ even if battery isn't present.

That isn't always possible. Imagine a battery inside some hot-pluggable PCI device. Or an USB device, or a battery with a built-in controller connected through W1 bus (i.e. batteries w/ ds2760 chip).

Ok, why not to do so for acpi devices?

Quoted 11 lines
Quoted 3 lines

btw, there is /sys/class/power_supply/BAT0/present, thus maybe this is just a bug?

Nope. And personally I think we should remove the "present" property, and drivers should learn to remove stuff from power_supply/ if there is no battery inserted. But so far HAL/Gnome/whatever have to handle both methods.

Thanks,

Best regards,
Maxim Levitsky