On Thu, Apr 28, 2011 at 6:14 AM, David Goldsmith wizard@houseoffire.ca wrote:
- I question the actual design safety of doing so. This is a script
that would be run as root, and even though only root could edit that script, is that really a safe thing to do?
What are you really concerned about, the script doing i2c pokes or running a script in general? Running script using udev (see below) is standard way of doing this, cards are automounted when inserted this way for example.
- I have no idea how to do it. As you can see in the diff, I tried
system(), but I can't just include stdlib.h. So if this is a good idea, someone please explain to me how a kernel module is supposed to execute a file? Actually, system or its ilk is probably an even worse idea, as it then blocks the interrupt. Gotta be a fork first.
Proper way to call stuff from kernel is using udev uevents, power_supply_changed() should do that for you. Then you add udev rules that runs scripts or whatever.
However we already have skeezix's pndevmapperd monitoring the battery, so we can patch that to also look for battery full state and take some action.
I want to incorporate Chris' "don't restart when shut down even if it's still plugged in" hack, but it really should be user selectable, which means dropping a new property into sysfs I think. Any thoughts?
Yeah I don't think there is anything standard for this, so add a custom sysfs entry. Look how charge_current is done, using DEVICE_ATTR macro.
Also note that drivers/power/twl4030_bci_battery.c does not exist in 2.6.37 kernel, all this will have to be ported to drivers/power/twl4030_charger.c that exists there for the next firmware.