From patchwork Mon Jan 21 12:03:49 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 2011791 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 73A13DF23A for ; Mon, 21 Jan 2013 12:14:40 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TxGDU-0001ME-KA; Mon, 21 Jan 2013 12:11:08 +0000 Received: from mail-wg0-f46.google.com ([74.125.82.46]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TxG8W-0006ZM-V7 for linux-arm-kernel@lists.infradead.org; Mon, 21 Jan 2013 12:06:15 +0000 Received: by mail-wg0-f46.google.com with SMTP id dr13so3601974wgb.13 for ; Mon, 21 Jan 2013 04:04:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=DvPp36yFPp5Du5cRkaKfMdifU21V8FApOHX1uuOeIFk=; b=hbOG7RWe9YWBN14HI/smiCuzjTo5/yyIYCY3AegNJ2bAEDHoWLos+/2vYj4EOHaIL2 NKIyqyYxyVcqo0NaujToQnJ00kq+aOsKfX9y3uh+6MBcGW0t7PA/fNltqfDRVkpCg7Fp 9ZyUbIuAcnoU+7LRIZKaVcaY3qSAZTVbs0wGAiprz/lp3O9nahWL6zDyTAvEzzyFAKFl 8Y+upetka1wPo91m7/RVATnBTbKNIaNJL/3KE54Q4PFNJuJXycRBvFmDqaZbPH69MJQ5 y7+SoLgyyd9kv2yqPfqQETHMQMLP5lW9CDX9Gc+nUIuiH+ues+QURl0aEtpJhQmC7wxK NfJw== X-Received: by 10.194.85.234 with SMTP id k10mr25762223wjz.53.1358769882544; Mon, 21 Jan 2013 04:04:42 -0800 (PST) Received: from localhost.localdomain (cpc34-aztw25-2-0-cust250.18-1.cable.virginmedia.com. [86.16.136.251]) by mx.google.com with ESMTPS id i2sm16575305wiw.3.2013.01.21.04.04.40 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 21 Jan 2013 04:04:41 -0800 (PST) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 13/24] abx500-chargalg: Add new sysfs interface to get current charge status Date: Mon, 21 Jan 2013 12:03:49 +0000 Message-Id: <1358769840-4763-14-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1358769840-4763-1-git-send-email-lee.jones@linaro.org> References: <1358769840-4763-1-git-send-email-lee.jones@linaro.org> X-Gm-Message-State: ALoCoQntx1KXx7neLmTRVfiZUkRo5bLa2J914crohs4rpCznajDOfKvYXYI9Ir9TyaAlStT0UMXI X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130121_070601_360594_219C167C X-CRM114-Status: GOOD ( 15.95 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [74.125.82.46 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: anton.vorontsov@linaro.org, Lee Jones , linus.walleij@stericsson.com, arnd@arndb.de, cbou@mail.ru X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Allow a user to check on AB8500 charging status from debugfs. Signed-off-by: Lee Jones --- drivers/power/ab8500_charger.c | 3 +++ drivers/power/abx500_chargalg.c | 22 +++++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/drivers/power/ab8500_charger.c b/drivers/power/ab8500_charger.c index 0483e7c..d834566 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, enum ab8500_usb_state bm_usb_state; unsigned mA = *((unsigned *)power); + if (!di) + 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 7defb3e..694f592 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 */ /** + * ab8500_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 ab8500_chargalg_sysfs_show(struct kobject *kobj, + struct attribute *attr, char *buf) +{ + struct ab8500_chargalg *di = container_of(kobj, + struct ab8500_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 = ab8500_chargalg_sysfs_show, .store = abx500_chargalg_sysfs_charger, };