From patchwork Tue Jan 15 12:55:42 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 14051 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 2EB0823E2E for ; Tue, 15 Jan 2013 12:56:32 +0000 (UTC) Received: from mail-vc0-f181.google.com (mail-vc0-f181.google.com [209.85.220.181]) by fiordland.canonical.com (Postfix) with ESMTP id E181BA192C6 for ; Tue, 15 Jan 2013 12:56:31 +0000 (UTC) Received: by mail-vc0-f181.google.com with SMTP id fl17so52151vcb.40 for ; Tue, 15 Jan 2013 04:56:31 -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=39UIOFiFMbL4c0L+U9WACVy1DLkrq4ldepHS+Hwn4Go=; b=ljwA+D2iJY5OQSGWpy9ezT7OK+nwXi0PkV1A26OERwAo4hrk/j7NbufF/N/l9yZRKq EwtW3uuzYWwJIZ1xY1fWiWCq3gJKJc6JGREuHSxGO2rcYZZXDxmFq9SI9wgkh0PBlQK3 IWz+urnm1/63r0F+90y9hxRVdSkFNEKUH9JYMSXiJMpXIwy0XRjewhmGlE1roT/Pa70z oz42H0fWtuOdY4uZmVzXAQRBKDdPhWM4LMC32QFKu/MoIRu7eP4orezFe8wUCNGwE7jk ovrs2FOmDJcipEZFpX5KE2Ctq5MCyr56yYP+2nMAOAGqTawshuBGKOmaCS5GI+u8PF+A uLpA== X-Received: by 10.52.70.205 with SMTP id o13mr91709886vdu.75.1358254591374; Tue, 15 Jan 2013 04:56:31 -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 st5csp110587veb; Tue, 15 Jan 2013 04:56:30 -0800 (PST) X-Received: by 10.180.99.227 with SMTP id et3mr3576625wib.6.1358254590068; Tue, 15 Jan 2013 04:56:30 -0800 (PST) Received: from mail-wg0-f47.google.com (mail-wg0-f47.google.com [74.125.82.47]) by mx.google.com with ESMTPS id e16si3361448wiw.28.2013.01.15.04.56.29 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 15 Jan 2013 04:56:30 -0800 (PST) Received-SPF: neutral (google.com: 74.125.82.47 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=74.125.82.47; Authentication-Results: mx.google.com; spf=neutral (google.com: 74.125.82.47 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-wg0-f47.google.com with SMTP id dq11so41784wgb.14 for ; Tue, 15 Jan 2013 04:56:29 -0800 (PST) X-Received: by 10.180.20.109 with SMTP id m13mr3586216wie.16.1358254589641; Tue, 15 Jan 2013 04:56:29 -0800 (PST) Received: from localhost.localdomain (cpc1-aztw13-0-0-cust473.18-1.cable.virginmedia.com. [77.102.241.218]) by mx.google.com with ESMTPS id eo10sm3672833wib.9.2013.01.15.04.56.27 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 15 Jan 2013 04:56:28 -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, sameo@linux.intel.com, Jonas Aaberg , Lee Jones Subject: [PATCH 02/26] mfd: ab8500-sysctrl: If a charger is present, reboot instead Date: Tue, 15 Jan 2013 12:55:42 +0000 Message-Id: <1358254566-12419-3-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1358254566-12419-1-git-send-email-lee.jones@linaro.org> References: <1358254566-12419-1-git-send-email-lee.jones@linaro.org> X-Gm-Message-State: ALoCoQkRLhJ1h5b+kWlqyeARE0LZyGkI1ySZY26yUuAGIp2zNTayAeHutdFoOtsXkiZK6KNb99Wa From: Jonas Aaberg If a changer is attached on power off, reboot the system into charging mode instead of powering it off. Signed-off-by: Lee Jones Signed-off-by: Jonas Aaberg Reviewed-by: Karl KOMIEROWSKI --- drivers/mfd/ab8500-sysctrl.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/mfd/ab8500-sysctrl.c b/drivers/mfd/ab8500-sysctrl.c index 799fb5e..01b0669 100644 --- a/drivers/mfd/ab8500-sysctrl.c +++ b/drivers/mfd/ab8500-sysctrl.c @@ -8,7 +8,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -19,6 +21,31 @@ void ab8500_power_off(void) { sigset_t old; sigset_t all; + static char *pss[] = {"ab8500_ac", "ab8500_usb"}; + int i; + + /* + * If we have a charger connected and we're powering off, + * reboot into charge-only mode. + */ + + for (i = 0; i < ARRAY_SIZE(pss); i++) { + union power_supply_propval val; + struct power_supply *psy; + int ret; + + psy = power_supply_get_by_name(pss[i]); + if (!psy) + continue; + ret = psy->get_property(psy, POWER_SUPPLY_PROP_ONLINE, &val); + + if (!ret && val.intval) { + printk(KERN_INFO + "Charger \"%s\" is connected. Rebooting.\n", + pss[i]); + machine_restart(NULL); + } + } sigfillset(&all);