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: 14156 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 0182923E33 for ; Mon, 21 Jan 2013 12:05:01 +0000 (UTC) Received: from mail-vb0-f46.google.com (mail-vb0-f46.google.com [209.85.212.46]) by fiordland.canonical.com (Postfix) with ESMTP id A3E72A18CF5 for ; Mon, 21 Jan 2013 12:05:00 +0000 (UTC) Received: by mail-vb0-f46.google.com with SMTP id b13so5629698vby.33 for ; Mon, 21 Jan 2013 04:05:00 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-received:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state; bh=DvPp36yFPp5Du5cRkaKfMdifU21V8FApOHX1uuOeIFk=; b=CBzFwVGqbmgiRa9NQOXITJO1g0wiXLfB6YiFj75TI63MXMS6+oV1nRUe7ZQSixOi08 teDkfCcPkKfHkGxf5kRtti7mRrWFaf0n/GQQhkQoPiZqcnGJAJzRjE7ArATt6ICdN1rJ ErTMCn+soG+M6ZW/tqlrkaiooe4S/J5Mjjzr2Rvp02XvoEk5FzRswBcRXaI9I4F9FfHA etmfEaO43DTZdO8bZEWUdy+aTgE0t12fvOU1hIRDXWd6qzrAPlYq7ZMVSEESQshvTwhm zJNf4Nzcbs7QO47k0BYbw0muxXhys2C0GOTGuBap2yc+YdRlpZ+YFAB/RnJDpeuLlcc9 Uz1A== X-Received: by 10.52.97.7 with SMTP id dw7mr16814407vdb.38.1358769900155; Mon, 21 Jan 2013 04:05:00 -0800 (PST) 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.58.145.101 with SMTP id st5csp197728veb; Mon, 21 Jan 2013 04:04:59 -0800 (PST) X-Received: by 10.180.109.10 with SMTP id ho10mr15104477wib.9.1358769886897; Mon, 21 Jan 2013 04:04:46 -0800 (PST) Received: from mail-we0-x231.google.com ([2a00:1450:400c:c03::231]) by mx.google.com with ESMTPS id i8si4794476wjw.144.2013.01.21.04.04.46 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 21 Jan 2013 04:04:46 -0800 (PST) Received-SPF: neutral (google.com: 2a00:1450:400c:c03::231 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=2a00:1450:400c:c03::231; Authentication-Results: mx.google.com; spf=neutral (google.com: 2a00:1450:400c:c03::231 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) smtp.mail=lee.jones@linaro.org Received: by mail-we0-f177.google.com with SMTP id d7so275667wer.22 for ; Mon, 21 Jan 2013 04:04:46 -0800 (PST) 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 Cc: arnd@arndb.de, linus.walleij@stericsson.com, anton.vorontsov@linaro.org, cbou@mail.ru, Lee Jones 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: ALoCoQk825GsSgT5MR5uGFCJbmGgAw7+Ia/UVWsaOJJvuMFPYlA7RqsJ2AYMPNhsPG/a+TF1irg/ 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, };