From patchwork Thu Oct 30 12:43:12 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonghwa Lee X-Patchwork-Id: 5197311 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 96A95C11AC for ; Thu, 30 Oct 2014 12:44:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B54C020172 for ; Thu, 30 Oct 2014 12:44:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7875720165 for ; Thu, 30 Oct 2014 12:44:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759961AbaJ3Mnc (ORCPT ); Thu, 30 Oct 2014 08:43:32 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:23881 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759964AbaJ3Mn3 (ORCPT ); Thu, 30 Oct 2014 08:43:29 -0400 Received: from epcpsbgr1.samsung.com (u141.gpu120.samsung.co.kr [203.254.230.141]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NE900EUMCO9R590@mailout1.samsung.com>; Thu, 30 Oct 2014 21:43:22 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.114]) by epcpsbgr1.samsung.com (EPCPMTA) with SMTP id 87.89.17016.96232545; Thu, 30 Oct 2014 21:43:21 +0900 (KST) X-AuditID: cbfee68d-f79296d000004278-14-545232695a66 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id DC.24.09430.96232545; Thu, 30 Oct 2014 21:43:21 +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 <0NE900852CO56T50@mmp1.samsung.com>; Thu, 30 Oct 2014 21:43:21 +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 06/10] power: charger-manager: Get external power souce information only from EXTCON. Date: Thu, 30 Oct 2014 21:43:12 +0900 Message-id: <1414672996-28355-7-git-send-email-jonghwa3.lee@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1414672996-28355-1-git-send-email-jonghwa3.lee@samsung.com> References: <1414672996-28355-1-git-send-email-jonghwa3.lee@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrELMWRmVeSWpSXmKPExsWyRsSkSDfTKCjE4GmblcXBrZoW1788Z7WY 9OQ9s8XElZOZLTrPPmG2uLxrDpvF594jjBa3G1ewWdw9dZTN4vTuEgcujwn9nxg9ds66y+6x eYWWx6ZVnWwefVtWMXqsWP2d3ePzJrkA9igum5TUnMyy1CJ9uwSujH8LtzAWnBWqWDBnH1MD Ywd/FyMnh4SAicTq95MYIWwxiQv31rN1MXJxCAksZZS4uvQeG0zRpjUrmCESixglzi77xALh tDFJvNl5iB2kik1AR+L/vptgtoiAgsTm3mesIEXMAlcYJW4uXs8EkhAWSJe4cuEo2FgWAVWJ y22fWUBsXgEPiVVtM4AaOIDWKUjMmWQDEuYU8JTYdGUmWIkQUMmDXV3sIDMlBA6xS0yYuZER Yo6AxLfJh1ggemUlNh1ghrhaUuLgihssExiFFzAyrGIUTS1ILihOSi8y1CtOzC0uzUvXS87P 3cQIjIrT/5717mC8fcD6EKMAB6MSD6/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y1x+/UXpwcyfTBt4b tf3b/u/fEBNxKln9Z+3LFTdtgh91nr4rfi9pZ47rtCVSxnL3duTFZxZr7Uq/pK4sYLac+9yd c0lPa1dfvKTEUpyRaKjFXFScCACIh/ALzwIAAA== 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=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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; } /**