diff options
author | Lee Jones <lee.jones@linaro.org> | 2013-01-21 11:22:56 +0000 |
---|---|---|
committer | Lee Jones <lee.jones@linaro.org> | 2013-01-23 14:39:16 +0000 |
commit | c9ade0fca3f7939194677353097b16c9795df46b (patch) | |
tree | fa812c2a01be48859d9ece52462323a810af233d /drivers/power/abx500_chargalg.c | |
parent | e07a56453b14b929cf01bf032cc3e3220094609c (diff) | |
download | talos-op-linux-c9ade0fca3f7939194677353097b16c9795df46b.tar.gz talos-op-linux-c9ade0fca3f7939194677353097b16c9795df46b.zip |
abx500-chargalg: Add new sysfs interface to get current charge status
Allow a user to check on AB8500 charging status from debugfs.
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Diffstat (limited to 'drivers/power/abx500_chargalg.c')
-rw-r--r-- | drivers/power/abx500_chargalg.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/drivers/power/abx500_chargalg.c b/drivers/power/abx500_chargalg.c index 7defb3e91d59..f043c0851a76 100644 --- a/drivers/power/abx500_chargalg.c +++ b/drivers/power/abx500_chargalg.c @@ -1654,6 +1654,25 @@ static int abx500_chargalg_get_property(struct power_supply *psy, /* Exposure to the sysfs interface */ /** + * abx500_chargalg_sysfs_show() - sysfs show operations + * @kobj: pointer to the struct kobject + * @attr: pointer to the struct attribute + * @buf: buffer that holds the parameter to send to userspace + * + * Returns a buffer to be displayed in user space + */ +static ssize_t abx500_chargalg_sysfs_show(struct kobject *kobj, + struct attribute *attr, char *buf) +{ + struct abx500_chargalg *di = container_of(kobj, + struct abx500_chargalg, chargalg_kobject); + + return sprintf(buf, "%d\n", + di->susp_status.ac_suspended && + di->susp_status.usb_suspended); +} + +/** * abx500_chargalg_sysfs_charger() - sysfs store operations * @kobj: pointer to the struct kobject * @attr: pointer to the struct attribute @@ -1721,7 +1740,7 @@ static ssize_t abx500_chargalg_sysfs_charger(struct kobject *kobj, static struct attribute abx500_chargalg_en_charger = \ { .name = "chargalg", - .mode = S_IWUSR, + .mode = S_IRUGO | S_IWUSR, }; static struct attribute *abx500_chargalg_chg[] = { @@ -1730,6 +1749,7 @@ static struct attribute *abx500_chargalg_chg[] = { }; static const struct sysfs_ops abx500_chargalg_sysfs_ops = { + .show = abx500_chargalg_sysfs_show, .store = abx500_chargalg_sysfs_charger, }; |