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: 1977701 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 41512DF264 for ; Tue, 15 Jan 2013 13:04:30 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Tv65t-0007AE-2K; Tue, 15 Jan 2013 12:58:22 +0000 Received: from wi-in-x022a.1e100.net ([2a00:1450:400c:c05::22a] helo=mail-wi0-x22a.google.com) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Tv649-0006Va-Bx for linux-arm-kernel@lists.infradead.org; Tue, 15 Jan 2013 12:56:35 +0000 Received: by mail-wi0-f170.google.com with SMTP id hq7so2313762wib.3 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:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=/i28mFMZq0GI9rF7kTqWt06aJgAobJESFh3OQIXim2I=; b=ibXYVfEFjKQXMppRIO+mrKdADdaeBwJ2z5j1U3pFsuvhnqtAylOgKIBrC/Gl2HoUrC aLztLjvJ0fSBnxo2fQglgwxTXi89M/d2qvVHcI28cU5JCBvBG88ptP7gPzWyumfs0iys SgWJXLkXUJkkYHcho+r+7+V+XlkwfKiXNRoJUBRVH37JLOPIBocHZIK6QgUJZRSwe5Tf AeeLXjlRH6rdSMftDvmNlrfTyWIX3VthUqdmYjd6yzyig/wM/cvOe1TWsBVa/6cfrDom FhWIq3+LUxadI8PCJYiCz8N0krJlEiWqIDpM0YOlKpdPqbXmcFVeR2fRe/21SrQvWC5l ouCA== 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 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: ALoCoQnMuvJ/TFdsKeOZ1EcMDZFKKvOjQQO31LjggX5Zy/YOq7TlT9Ax/dEqvP6+Fsn2+rvhe++t X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130115_075633_672735_BC1B673C X-CRM114-Status: GOOD ( 14.18 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Jonas Aaberg , Lee Jones , linus.walleij@stericsson.com, arnd@arndb.de, sameo@linux.intel.com 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 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)) {