[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1348589574-25655-28-git-send-email-mathieu.poirier@linaro.org>
Date: Tue, 25 Sep 2012 10:12:24 -0600
From: mathieu.poirier@...aro.org
To: linux-kernel@...r.kernel.org, cbou@...l.ru, dwmw2@...radead.org
Cc: mathieu.poirier@...aro.org
Subject: [PATCH 27/57] power: sysfs interface update
From: Michel JAOUEN <michel.jaouen@...ricsson.com>
Add new sysfs interface to get current charge status
Signed-off-by: Michel JAOUEN <michel.jaouen@...ricsson.com>
Signed-off-by: Loic Pallardy <loic.pallardy@...ricsson.com>
Signed-off-by: Mathieu Poirier <mathieu.poirier@...aro.org>
Reviewed-by: Marcus COOPER <marcus.xm.cooper@...ricsson.com>
Reviewed-by: Olivier CLERGEAUD <olivier.clergeaud@...ricsson.com>
Reviewed-by: Jonas ABERG <jonas.aberg@...ricsson.com>
---
drivers/power/ab8500_charger.c | 3 +++
drivers/power/abx500_chargalg.c | 24 +++++++++++++++++++++++-
2 files changed, 26 insertions(+), 1 deletions(-)
diff --git a/drivers/power/ab8500_charger.c b/drivers/power/ab8500_charger.c
index 4129599..0a781a0 100644
--- a/drivers/power/ab8500_charger.c
+++ b/drivers/power/ab8500_charger.c
@@ -2759,6 +2759,9 @@ static int ab8500_charger_usb_notifier_call(struct notifier_block *nb,
enum ab8500_usb_state bm_usb_state;
unsigned mA = *((unsigned *)power);
+ if (di == NULL)
+ return NOTIFY_DONE;
+
if (event != USB_EVENT_VBUS) {
dev_dbg(di->dev, "not a standard host, returning\n");
return NOTIFY_DONE;
diff --git a/drivers/power/abx500_chargalg.c b/drivers/power/abx500_chargalg.c
index d3efc2a..4e3d20f 100644
--- a/drivers/power/abx500_chargalg.c
+++ b/drivers/power/abx500_chargalg.c
@@ -1679,6 +1679,27 @@ static int abx500_chargalg_get_property(struct power_supply *psy,
return 0;
}
+/**
+ * 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);
+
+ if ((di->susp_status.ac_suspended == true) &&
+ (di->susp_status.usb_suspended == true))
+ return sprintf(buf, "0\n");
+ else
+ return sprintf(buf, "1\n");
+}
+
/* Exposure to the sysfs interface */
/**
@@ -1749,7 +1770,7 @@ static ssize_t abx500_chargalg_sysfs_charger(struct kobject *kobj,
static struct attribute abx500_chargalg_en_charger = \
{
.name = "chargalg",
- .mode = S_IWUGO,
+ .mode = S_IRUGO | S_IWUSR,
};
static struct attribute *abx500_chargalg_chg[] = {
@@ -1758,6 +1779,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,
};
--
1.7.5.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists