From patchwork Thu Sep 27 20:08:44 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11800 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 625CE24140 for ; Thu, 27 Sep 2012 20:09:55 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id 118D8A18B18 for ; Thu, 27 Sep 2012 20:09:54 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id e10so5234855iej.11 for ; Thu, 27 Sep 2012 13:09:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to :subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=SGbg9fMs2C5wFl7SJ4dALiEwwN2FK+EDfzJi1ptoWoc=; b=lxZO5aG+NQqZreHKHeitYpIORzUWN8H9bloKM7U7ndHG6Qc1JvrbF3DOp5RvfOyH7A m0HXCBIeNJoXs3gdT1rgjYAl0NvBV2bd853+jH+UyW2kc3klPm4zSHAbmN2S+NYDjop2 ZGm7H1dM4KOfFpjW1WE5JXwR5FlpOgH2vuyYzsCRr/fNFT19FIthHXZVv5tcCRcgj1bJ nWgHtGkTR2HiIVLsITKfmByPFJu02Mi8jQBajBqsQVSUgjtTsQPB6cToaDKEo/THrNZS qQ1EAKpJnSQSPXBCffyYjAJQ59tvkPscDIekppj1qeOCHRzxfY5v6sduV3abpTNJWeRS AglQ== Received: by 10.50.7.212 with SMTP id l20mr4641785iga.43.1348776594848; Thu, 27 Sep 2012 13:09:54 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.184.232 with SMTP id ex8csp436324igc; Thu, 27 Sep 2012 13:09:54 -0700 (PDT) Received: by 10.68.221.168 with SMTP id qf8mr14492549pbc.37.1348776594154; Thu, 27 Sep 2012 13:09:54 -0700 (PDT) Received: from mail-pb0-f50.google.com (mail-pb0-f50.google.com [209.85.160.50]) by mx.google.com with ESMTPS id pi9si5467641pbb.12.2012.09.27.13.09.54 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 27 Sep 2012 13:09:54 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of mathieu.poirier@linaro.org) client-ip=209.85.160.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of mathieu.poirier@linaro.org) smtp.mail=mathieu.poirier@linaro.org Received: by mail-pb0-f50.google.com with SMTP id md4so1686045pbc.37 for ; Thu, 27 Sep 2012 13:09:54 -0700 (PDT) Received: by 10.66.85.8 with SMTP id d8mr12198280paz.30.1348776593870; Thu, 27 Sep 2012 13:09:53 -0700 (PDT) Received: from localhost.localdomain (S0106002369de4dac.cg.shawcable.net. [70.73.24.112]) by mx.google.com with ESMTPS id sa2sm1587890pbc.4.2012.09.27.13.09.52 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 27 Sep 2012 13:09:53 -0700 (PDT) From: mathieu.poirier@linaro.org To: patches@linaro.org Subject: [PATCH 27/57] power: sysfs interface update Date: Thu, 27 Sep 2012 14:08:44 -0600 Message-Id: <1348776554-10019-28-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1348776554-10019-1-git-send-email-mathieu.poirier@linaro.org> References: <1348776554-10019-1-git-send-email-mathieu.poirier@linaro.org> X-Gm-Message-State: ALoCoQnsoIBM03iZNL145cKvCy3oKfzyZYtMyBtFIvM5gQIdlGWfriRZ7Cw2sjrPl8ntL/rp1Sz6 From: Michel JAOUEN Add new sysfs interface to get current charge status Signed-off-by: Michel JAOUEN Signed-off-by: Loic Pallardy Signed-off-by: Mathieu Poirier Reviewed-by: Marcus COOPER Reviewed-by: Olivier CLERGEAUD Reviewed-by: Jonas ABERG --- 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, };