From patchwork Fri Dec 19 02:47:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonghwa Lee X-Patchwork-Id: 5517221 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id AB5FA9F1CD for ; Fri, 19 Dec 2014 02:49:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C8AAD2012B for ; Fri, 19 Dec 2014 02:49:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 73B2F2013A for ; Fri, 19 Dec 2014 02:49:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752001AbaLSCtA (ORCPT ); Thu, 18 Dec 2014 21:49:00 -0500 Received: from mailout2.samsung.com ([203.254.224.25]:58375 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751998AbaLSCrk (ORCPT ); Thu, 18 Dec 2014 21:47:40 -0500 Received: from epcpsbgr3.samsung.com (u143.gpu120.samsung.co.kr [203.254.230.143]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NGT00DLM6FDJ670@mailout2.samsung.com>; Fri, 19 Dec 2014 11:47:37 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.113]) by epcpsbgr3.samsung.com (EPCPMTA) with SMTP id 4E.B0.18484.9C193945; Fri, 19 Dec 2014 11:47:37 +0900 (KST) X-AuditID: cbfee68f-f791c6d000004834-dd-549391c9d315 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 45.EB.20081.8C193945; Fri, 19 Dec 2014 11:47:37 +0900 (KST) Received: from localhost.localdomain ([10.252.82.199]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0NGT004F46F82Y30@mmp1.samsung.com>; Fri, 19 Dec 2014 11:47:36 +0900 (KST) From: Jonghwa Lee To: linux-kernel@vger.kernel.org Cc: linux-pm@vger.kernel.org, sre@kernel.org, dbaryshkov@gmail.com, dwmw2@infradead.org, anton@enomsg.org, pavel@ucw.cz, myungjoo.ham@samsung.com, cw00.choi@samsung.com, Jonghwa Lee Subject: [PATCH RESEND v2 06/10] power: charger-manager: Get external power souce information only from EXTCON. Date: Fri, 19 Dec 2014 11:47:26 +0900 Message-id: <1418957250-6542-7-git-send-email-jonghwa3.lee@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1418957250-6542-1-git-send-email-jonghwa3.lee@samsung.com> References: <1418957250-6542-1-git-send-email-jonghwa3.lee@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrILMWRmVeSWpSXmKPExsWyRsSkUPfkxMkhBo2zuCwObtW0uP7lOavF pCfvmS0mrpzMbNF59gmzxeVdc9gsPvceYbS43biCzeLuqaNsFqd3lzhweUzo/8TosXPWXXaP zSu0PDat6mTz6NuyitFjxerv7B6fN8kFsEdx2aSk5mSWpRbp2yVwZfxbuIWx4KxQxYI5+5ga GDv4uxg5OSQETCSuLVzKBmGLSVy4tx7I5uIQEljKKHF9425mmKKZ3/+yQyQWMUpMXDaTGcJp Y5JYM38RE0gVm4COxP99N9lBbBEBBYnNvc9YQYqYBa4wStxcvB6sSFigUGLevz4gm4ODRUBV YnajNkiYV8Bdov/YJjaQsARQ75xJNiBhTgEPiaeXmsCuEwIqOfHtLQvISAmBXewS13bsANvF IiAg8W3yIRaIXlmJTQegjpaUOLjiBssERuEFjAyrGEVTC5ILipPSi4z1ihNzi0vz0vWS83M3 MQJj4vS/Z/07GO8es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OXbxye87/JsHPP5+Wd7wT5ra/8jP2j1/ic1eSC+VpvTp6qi40Sy1ZI ZzNsf+L/Tc0rOneFct6j7q6VKZmVM3+G+jMuW3fE+7V/xGMTnme6n/R/cr1i/WahxDT70fI8 Af4Hc5VYijMSDbWYi4oTAdW5GUnOAgAA DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When charger-manager checks whether external power source is available, it gets information from charger IC driver. However, it's not correct source, charger IC doesn't have responsibilty to give cable connection status. The charger-manager already gets cable information from EXTCON susbsystem, so it can re-use it. Signed-off-by: Jonghwa Lee --- drivers/power/charger-manager.c | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/drivers/power/charger-manager.c b/drivers/power/charger-manager.c index bb44588..172dfe5 100644 --- a/drivers/power/charger-manager.c +++ b/drivers/power/charger-manager.c @@ -115,34 +115,28 @@ static bool is_batt_present(struct charger_manager *cm) * is_ext_pwr_online - See if an external power source is attached to charge * @cm: the Charger Manager representing the battery. * - * Returns true if at least one of the chargers of the battery has an external - * power source attached to charge the battery regardless of whether it is - * actually charging or not. + * Returns true if there is external power source. + * Cable connection information is only obtained by EXTCON class notification. */ static bool is_ext_pwr_online(struct charger_manager *cm) { - union power_supply_propval val; - struct power_supply *psy; - bool online = false; - int i, ret; - /* If at least one of them has one, it's yes. */ - for (i = 0; cm->desc->psy_charger_stat[i]; i++) { - psy = power_supply_get_by_name(cm->desc->psy_charger_stat[i]); - if (!psy) { - dev_err(cm->dev, "Cannot find power supply \"%s\"\n", - cm->desc->psy_charger_stat[i]); - continue; - } + struct charger_desc *desc = cm->desc; + struct charger_regulator *regulators = desc->charger_regulators; + struct charger_cable *cables; + int i, j, num_cables; - ret = psy->get_property(psy, POWER_SUPPLY_PROP_ONLINE, &val); - if (ret == 0 && val.intval) { - online = true; - break; + /* If at least one of them has one, it's yes. */ + for (i = 0; i < desc->num_charger_regulators; i++) { + cables = regulators[i].cables; + num_cables = regulators[i].num_cables; + for (j = 0; j < num_cables; j++) { + if (cables[j].attached) + return true; } } - return online; + return false; } /**