From patchwork Tue Jan 15 12:55:43 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 14052 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 7306023E2E for ; Tue, 15 Jan 2013 12:56:33 +0000 (UTC) Received: from mail-vc0-f171.google.com (mail-vc0-f171.google.com [209.85.220.171]) by fiordland.canonical.com (Postfix) with ESMTP id 3D77CA1931C for ; Tue, 15 Jan 2013 12:56:33 +0000 (UTC) Received: by mail-vc0-f171.google.com with SMTP id n11so57965vch.2 for ; Tue, 15 Jan 2013 04:56:32 -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=/i28mFMZq0GI9rF7kTqWt06aJgAobJESFh3OQIXim2I=; b=aWMk1AD4nwhedh5YXyuLfxK8SB++T//9JKkSmIRGKwQK+d0ZlAMry1sZMA74P2Ob7b yMcPOa7lwO6Fxqf/zvPTecrEiW0SNpu6y/2u0WpOxe+36vzUlKkrhbeDE0phmTpaqIV2 kWpwIwFa4UR1XLVZ5iy0P99PAumKuCKKVemusfJJ2/9cEVrzz9sYo+qyDg6v/c0N6Til Qmci9DFgdwI/ESMEAlAzh0+AlLJBQ42O/yM8rcSmJKsq3OF3GiBjfoJflYpzidp3HVxD HlDpLamaQ55tiGgbzSkPbY5I5LYq0ZAb4O+MkAtJwAdg1FK0DY/IADYiJOkWNL9l1MPo UuZA== X-Received: by 10.221.0.79 with SMTP id nl15mr105476381vcb.41.1358254592735; Tue, 15 Jan 2013 04:56:32 -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 st5csp110590veb; Tue, 15 Jan 2013 04:56:31 -0800 (PST) X-Received: by 10.180.99.129 with SMTP id eq1mr3522921wib.30.1358254591517; Tue, 15 Jan 2013 04:56:31 -0800 (PST) Received: from mail-wg0-f48.google.com (mail-wg0-f48.google.com [74.125.82.48]) by mx.google.com with ESMTPS id u4si27428419wjr.28.2013.01.15.04.56.31 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 15 Jan 2013 04:56:31 -0800 (PST) Received-SPF: neutral (google.com: 74.125.82.48 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=74.125.82.48; Authentication-Results: mx.google.com; spf=neutral (google.com: 74.125.82.48 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-f48.google.com with SMTP id 16so39618wgi.15 for ; Tue, 15 Jan 2013 04:56:31 -0800 (PST) X-Received: by 10.194.19.170 with SMTP id g10mr141874382wje.56.1358254591131; Tue, 15 Jan 2013 04:56:31 -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.29 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 15 Jan 2013 04:56:30 -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 03/26] mfd: ab8500-sysctrl: Only reboot into charging mode if battery type is known Date: Tue, 15 Jan 2013 12:55:43 +0000 Message-Id: <1358254566-12419-4-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: ALoCoQnr/a2FzFak80v9RXkVap2A//qrLwfXzOwBefZzaAjUkvbfSa3afyAxQ/ckABBJWvflv8rA From: Jonas Aaberg When a charger is connected, we usually want AB8500 based systems to reboot into charging-only mode. However, if the battery type cannot be identified this would be futile, so we'll just shut the system down instead. Signed-off-by: Lee Jones Signed-off-by: Jonas Aaberg Reviewed-by: Karl KOMIEROWSKI --- drivers/mfd/ab8500-sysctrl.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/drivers/mfd/ab8500-sysctrl.c b/drivers/mfd/ab8500-sysctrl.c index 01b0669..26216e7 100644 --- a/drivers/mfd/ab8500-sysctrl.c +++ b/drivers/mfd/ab8500-sysctrl.c @@ -23,6 +23,10 @@ void ab8500_power_off(void) sigset_t all; static char *pss[] = {"ab8500_ac", "ab8500_usb"}; int i; + bool charger_present = false; + union power_supply_propval val; + struct power_supply *psy; + int ret; /* * If we have a charger connected and we're powering off, @@ -30,23 +34,36 @@ void ab8500_power_off(void) */ 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) { + charger_present = true; + break; + } + } + + if (!charger_present) + goto shutdown; + + /* Check if battery is known */ + psy = power_supply_get_by_name("ab8500_btemp"); + if (psy) { + ret = psy->get_property(psy, POWER_SUPPLY_PROP_TECHNOLOGY, + &val); + if (!ret && val.intval != POWER_SUPPLY_TECHNOLOGY_UNKNOWN) { printk(KERN_INFO - "Charger \"%s\" is connected. Rebooting.\n", + "Charger \"%s\" is connected with known battery." + " Rebooting.\n", pss[i]); machine_restart(NULL); } } +shutdown: sigfillset(&all); if (!sigprocmask(SIG_BLOCK, &all, &old)) {