Bug 10772

Summary: [appleir] Should use power_supply class to tell battery level
Product: Drivers Reporter: Bastien Nocera (bugzilla)
Component: Input DevicesAssignee: drivers_input-devices
Status: CLOSED INVALID    
Severity: normal CC: alan, richard
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: Not yet merged Subsystem:
Regression: No Bisected commit-id:

Description Bastien Nocera 2008-05-22 02:59:18 UTC
The appleir driver was posted here:
http://thread.gmane.org/gmane.linux.kernel.input/4898

The patch shows that it only prints out a warning when the battery is running flat:
+	dev_err(&appleir->input_dev->dev, "possible flat battery?\n");

Instead, it should use power_supply class, so that the device's battery status can be propagated to user-space, and allow programs like gnome-power-manager to warn the user about the low-battery.
Comment 1 Dmitry Torokhov 2008-09-24 10:26:12 UTC
Is the userspace smart enough to distinguish between the main power source and somewhat uninteresting power supplys like this one and not try to shut down the box when power is low?
Comment 2 Bastien Nocera 2008-09-24 11:00:43 UTC
Of course it is. Otherwise we'd have been broken for a lot of other devices.
Comment 3 Richard Hughes 2010-01-19 17:42:57 UTC
(In reply to comment #2)
> Of course it is. Otherwise we'd have been broken for a lot of other devices.

DeviceKit-power supports lots of device types, and only does the shutdown logic on system devices like UPS and internal laptop battery.

I think it would be very simple to implement the power_supply class in this case.
Comment 4 Bastien Nocera 2010-01-19 17:51:56 UTC
FWIW, I reposted the appleir driver, and it wouldn't be possible to use the power_supply class, because the data is about the remote, not the receiver, and you can use whichever remote you fancy.

So you'd get data from one remote, and have no idea the other remote's battery was not dead. I'll use a kobject_uevent instead.