From 4a11b59d8283662193a9c6a9c14c58d1b9bf0617 Mon Sep 17 00:00:00 2001 From: Anton Vorontsov Date: Fri, 4 May 2007 00:27:45 +0400 Subject: [BATTERY] Universal power supply class (was: battery class) This class is result of "external power" and "battery" classes merge, as suggested by David Woodhouse. He also implemented uevent support. Here how userspace seeing it now: # ls /sys/class/power\ supply/ ac main-battery usb # cat /sys/class/power\ supply/ac/type AC # cat /sys/class/power\ supply/usb/type USB # cat /sys/class/power\ supply/main-battery/type Battery # cat /sys/class/power\ supply/ac/online 1 # cat /sys/class/power\ supply/usb/online 0 # cat /sys/class/power\ supply/main-battery/status Charging # cat /sys/class/leds/h5400\:red-left/trigger none h5400-radio timer hwtimer ac-online usb-online main-battery-charging-or-full [main-battery-charging] main-battery-full Signed-off-by: Anton Vorontsov Signed-off-by: David Woodhouse Signed-off-by: Andrew Morton --- drivers/power/power_supply.h | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 drivers/power/power_supply.h (limited to 'drivers/power/power_supply.h') diff --git a/drivers/power/power_supply.h b/drivers/power/power_supply.h new file mode 100644 index 000000000000..a9880d468ee4 --- /dev/null +++ b/drivers/power/power_supply.h @@ -0,0 +1,42 @@ +/* + * Functions private to power supply class + * + * Copyright © 2007 Anton Vorontsov + * Copyright © 2004 Szabolcs Gyurko + * Copyright © 2003 Ian Molton + * + * Modified: 2004, Oct Szabolcs Gyurko + * + * You may use this code as per GPL version 2 + */ + +#ifdef CONFIG_SYSFS + +extern int power_supply_create_attrs(struct power_supply *psy); +extern void power_supply_remove_attrs(struct power_supply *psy); +extern int power_supply_uevent(struct device *dev, char **envp, int num_envp, + char *buffer, int buffer_size); + +#else + +static inline int power_supply_create_attrs(struct power_supply *psy) +{ return 0; } +static inline void power_supply_remove_attrs(struct power_supply *psy) {} +#define power_supply_uevent NULL + +#endif /* CONFIG_SYSFS */ + +#ifdef CONFIG_LEDS_TRIGGERS + +extern void power_supply_update_leds(struct power_supply *psy); +extern int power_supply_create_triggers(struct power_supply *psy); +extern void power_supply_remove_triggers(struct power_supply *psy); + +#else + +static inline void power_supply_update_leds(struct power_supply *psy) {} +static inline int power_supply_create_triggers(struct power_supply *psy) +{ return 0; } +static inline void power_supply_remove_triggers(struct power_supply *psy) {} + +#endif /* CONFIG_LEDS_TRIGGERS */ -- cgit v1.2.3