aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/power
diff options
context:
space:
mode:
authorLee Jones <lee.jones@linaro.org>2013-01-21 06:22:56 -0500
committerLee Jones <lee.jones@linaro.org>2013-01-23 09:39:16 -0500
commitc9ade0fca3f7939194677353097b16c9795df46b (patch)
treefa812c2a01be48859d9ece52462323a810af233d /drivers/power
parente07a56453b14b929cf01bf032cc3e3220094609c (diff)
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')
-rw-r--r--drivers/power/ab8500_charger.c3
-rw-r--r--drivers/power/abx500_chargalg.c22
2 files changed, 24 insertions, 1 deletions
diff --git a/drivers/power/ab8500_charger.c b/drivers/power/ab8500_charger.c
index 0483e7cb2268..d834566410bc 100644
--- a/drivers/power/ab8500_charger.c
+++ b/drivers/power/ab8500_charger.c
@@ -2764,6 +2764,9 @@ static int ab8500_charger_usb_notifier_call(struct notifier_block *nb,
2764 enum ab8500_usb_state bm_usb_state; 2764 enum ab8500_usb_state bm_usb_state;
2765 unsigned mA = *((unsigned *)power); 2765 unsigned mA = *((unsigned *)power);
2766 2766
2767 if (!di)
2768 return NOTIFY_DONE;
2769
2767 if (event != USB_EVENT_VBUS) { 2770 if (event != USB_EVENT_VBUS) {
2768 dev_dbg(di->dev, "not a standard host, returning\n"); 2771 dev_dbg(di->dev, "not a standard host, returning\n");
2769 return NOTIFY_DONE; 2772 return NOTIFY_DONE;
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,
1654/* Exposure to the sysfs interface */ 1654/* Exposure to the sysfs interface */
1655 1655
1656/** 1656/**
1657 * abx500_chargalg_sysfs_show() - sysfs show operations
1658 * @kobj: pointer to the struct kobject
1659 * @attr: pointer to the struct attribute
1660 * @buf: buffer that holds the parameter to send to userspace
1661 *
1662 * Returns a buffer to be displayed in user space
1663 */
1664static ssize_t abx500_chargalg_sysfs_show(struct kobject *kobj,
1665 struct attribute *attr, char *buf)
1666{
1667 struct abx500_chargalg *di = container_of(kobj,
1668 struct abx500_chargalg, chargalg_kobject);
1669
1670 return sprintf(buf, "%d\n",
1671 di->susp_status.ac_suspended &&
1672 di->susp_status.usb_suspended);
1673}
1674
1675/**
1657 * abx500_chargalg_sysfs_charger() - sysfs store operations 1676 * abx500_chargalg_sysfs_charger() - sysfs store operations
1658 * @kobj: pointer to the struct kobject 1677 * @kobj: pointer to the struct kobject
1659 * @attr: pointer to the struct attribute 1678 * @attr: pointer to the struct attribute
@@ -1721,7 +1740,7 @@ static ssize_t abx500_chargalg_sysfs_charger(struct kobject *kobj,
1721static struct attribute abx500_chargalg_en_charger = \ 1740static struct attribute abx500_chargalg_en_charger = \
1722{ 1741{
1723 .name = "chargalg", 1742 .name = "chargalg",
1724 .mode = S_IWUSR, 1743 .mode = S_IRUGO | S_IWUSR,
1725}; 1744};
1726 1745
1727static struct attribute *abx500_chargalg_chg[] = { 1746static struct attribute *abx500_chargalg_chg[] = {
@@ -1730,6 +1749,7 @@ static struct attribute *abx500_chargalg_chg[] = {
1730}; 1749};
1731 1750
1732static const struct sysfs_ops abx500_chargalg_sysfs_ops = { 1751static const struct sysfs_ops abx500_chargalg_sysfs_ops = {
1752 .show = abx500_chargalg_sysfs_show,
1733 .store = abx500_chargalg_sysfs_charger, 1753 .store = abx500_chargalg_sysfs_charger,
1734}; 1754};
1735 1755