From patchwork Fri Nov 16 11:01:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "(Exiting) Baolin Wang" X-Patchwork-Id: 10685903 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A0E08109C for ; Fri, 16 Nov 2018 11:01:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8EEC72C119 for ; Fri, 16 Nov 2018 11:01:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 82BE02D110; Fri, 16 Nov 2018 11:01:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 28C952C119 for ; Fri, 16 Nov 2018 11:01:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727630AbeKPVNp (ORCPT ); Fri, 16 Nov 2018 16:13:45 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:44313 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727615AbeKPVNp (ORCPT ); Fri, 16 Nov 2018 16:13:45 -0500 Received: by mail-pf1-f196.google.com with SMTP id b81-v6so10755412pfe.11 for ; Fri, 16 Nov 2018 03:01:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=6LJBTmjPNOjTTUrUiu6Uu+XwWfVjQEp0CGIbptL2pHE=; b=fapVZTL3wXtnQ6qrqRRDkPW6zHsdgy5Hy97ifAbfHXRkAIiBxsmM0Sy8undREmQltZ aWIExxCEv7GERjq3U5gIThtpDaIv68DyzvWZg+mMtu8D+GCLNz8sKR2/r5/GBsn5M8YL Qv4l4dWy/0EKyK5VjrApfY2CXYwApuZdj6eHw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=6LJBTmjPNOjTTUrUiu6Uu+XwWfVjQEp0CGIbptL2pHE=; b=Cy810TpRaVgveAehPqA1iEJzMmilzoMROGp4ET2AL5lMwls7lJirutfQUJcfuEA1Kk jaWkpIZNhKGgO6nRGnYkhxWG8e+wKq2eIO9S5xW6EktRs/deHMPHSmpVJbbQ4BdlYStw F0DmGvfiQiFUZjCLHGfnNsmjT8idDROYW8++aMkua9iFxP4FCtbPtNZNInjfpgR9QGA1 nEg59kgwgyrYG7sCvEkJ641f1/819QGK0DQosWLi+9EYayCK614FpYA35uSNLc/Tznqe X+YVGsEeXManFv69RZwdw7ovwApcMjS6TBNMOkjS9mT0RC+TK5HSQnFGOCgOL2W9QtFT sZxA== X-Gm-Message-State: AGRZ1gIuJ8iYX/CX9mPZYtICrIXUVeZrryQdEMROpktGGhkN65OnG8ix qRhep0vV1t+byZDhrA3Y2a2pSw== X-Google-Smtp-Source: AJdET5dfi9j3r0ERwcuY1UtDOiaDjOZsh3x1EIH3bhnmuLfEZxizntcPaiO9nukcVW1tJo8voLzH+w== X-Received: by 2002:a63:dc0c:: with SMTP id s12mr9577968pgg.398.1542366114488; Fri, 16 Nov 2018 03:01:54 -0800 (PST) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id 202sm21268106pfy.87.2018.11.16.03.01.50 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 16 Nov 2018 03:01:53 -0800 (PST) From: Baolin Wang To: sre@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, yuanjiang.yu@unisoc.com, baolin.wang@linaro.org, broonie@kernel.org, linus.walleij@linaro.org Subject: [PATCH 1/6] power: supply: charger-manager: Remove unused index counting Date: Fri, 16 Nov 2018 19:01:08 +0800 Message-Id: <4ea9eaf85d780afb190cb45da2df8ff5fd86d449.1542362262.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Remove unused index counting. Signed-off-by: Baolin Wang --- drivers/power/supply/charger-manager.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/power/supply/charger-manager.c b/drivers/power/supply/charger-manager.c index faa1a67..a1b420a 100644 --- a/drivers/power/supply/charger-manager.c +++ b/drivers/power/supply/charger-manager.c @@ -1687,10 +1687,6 @@ static int charger_manager_probe(struct platform_device *pdev) return -EINVAL; } - /* Counting index only */ - while (desc->psy_charger_stat[i]) - i++; - /* Check if charger's supplies are present at probe */ for (i = 0; desc->psy_charger_stat[i]; i++) { struct power_supply *psy; From patchwork Fri Nov 16 11:01:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "(Exiting) Baolin Wang" X-Patchwork-Id: 10685905 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 61FBF109C for ; Fri, 16 Nov 2018 11:02:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C8502C119 for ; Fri, 16 Nov 2018 11:02:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 401A52D10D; Fri, 16 Nov 2018 11:02:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D11C52C119 for ; Fri, 16 Nov 2018 11:02:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727539AbeKPVNv (ORCPT ); Fri, 16 Nov 2018 16:13:51 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:43755 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727454AbeKPVNu (ORCPT ); Fri, 16 Nov 2018 16:13:50 -0500 Received: by mail-pg1-f196.google.com with SMTP id n10-v6so10460786pgv.10 for ; Fri, 16 Nov 2018 03:02:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=OmVH3UHc4jVpPVW6soMiO6W7+f+gJlHLBPjlEn0mL64=; b=NfmqTkykV8or7LF9itF66A4SSLCnZfQEBwB4ANhk+9QwBLM1R3UTvEyGIVssNXEiwF rMbP5tIk6X5TBQUGSvMoK6V2jpqCYLBsN1WH4AdSX/CZYHouqb7u6W0fP+XE5GLS2f0J J9IW6hEzw3HYASHr9ANbXLLpjiJEtDXY+CROo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=OmVH3UHc4jVpPVW6soMiO6W7+f+gJlHLBPjlEn0mL64=; b=lz54uyo4G3ogtYesGbJgAQkfBEtQGtxhw25gmHzSMdl0O1CdeuxYLz8aKzt9f8H48j A97QxVBjwLMv9K+TZjOxRyhmfseYc6OzjHwlyVsW6prRGWl3St1lvuo3x7m+tw32ZDEN zG1kCJe+6YEb9wyV9oTvvlocxq+LtJN/6uKkikfFbP6b+PRtf3X0whkmirr9nWXgXS4b osdpUvkVcyN+4ORkT5OtXC/pLsJ3AxVltAp7pEA2V8dkvdu2FvKywBNcqg9DMvBMQfNK eqcABglo2sifdEdBaFpQT1a3e5QIsuZZ+adF8ITBXS2U+l25QW03u6jOf7sj9CDHsRZN m+Ag== X-Gm-Message-State: AGRZ1gJBoDXcgbwMx5H/RnIQ3+7xKHEJ9daoMhQu/4jtxpWkfftJG088 p3Co4lib7UAIscSAkXCmVcu4/Q== X-Google-Smtp-Source: AJdET5fG7zURzFKKNVWK5RJ2B1oFaNmkCVlIjC5h17TPXlSAYBnRDUKMMrM369hw6Gub2PYvw9/Y9w== X-Received: by 2002:a62:ae12:: with SMTP id q18mr3320720pff.126.1542366119771; Fri, 16 Nov 2018 03:01:59 -0800 (PST) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id 202sm21268106pfy.87.2018.11.16.03.01.55 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 16 Nov 2018 03:01:59 -0800 (PST) From: Baolin Wang To: sre@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, yuanjiang.yu@unisoc.com, baolin.wang@linaro.org, broonie@kernel.org, linus.walleij@linaro.org Subject: [PATCH 2/6] power: supply: charger-manager: Fix some misspelled words Date: Fri, 16 Nov 2018 19:01:09 +0800 Message-Id: <24406bab7e6b694c8eeb621c450ea7b039beb1d8.1542362262.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <4ea9eaf85d780afb190cb45da2df8ff5fd86d449.1542362262.git.baolin.wang@linaro.org> References: <4ea9eaf85d780afb190cb45da2df8ff5fd86d449.1542362262.git.baolin.wang@linaro.org> In-Reply-To: <4ea9eaf85d780afb190cb45da2df8ff5fd86d449.1542362262.git.baolin.wang@linaro.org> References: <4ea9eaf85d780afb190cb45da2df8ff5fd86d449.1542362262.git.baolin.wang@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Fix some misspelled words. Signed-off-by: Baolin Wang --- drivers/power/supply/charger-manager.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/power/supply/charger-manager.c b/drivers/power/supply/charger-manager.c index a1b420a..bd6c450 100644 --- a/drivers/power/supply/charger-manager.c +++ b/drivers/power/supply/charger-manager.c @@ -363,7 +363,7 @@ static int try_charger_enable(struct charger_manager *cm, bool enable) int err = 0, i; struct charger_desc *desc = cm->desc; - /* Ignore if it's redundent command */ + /* Ignore if it's redundant command */ if (enable == cm->charger_enabled) return 0; @@ -1799,7 +1799,7 @@ static int charger_manager_probe(struct platform_device *pdev) /* * Charger-manager is capable of waking up the systme from sleep - * when event is happend through cm_notify_event() + * when event is happened through cm_notify_event() */ device_init_wakeup(&pdev->dev, true); device_set_wakeup_capable(&pdev->dev, false); @@ -2019,7 +2019,7 @@ static void __exit charger_manager_cleanup(void) * cm_notify_event - charger driver notify Charger Manager of charger event * @psy: pointer to instance of charger's power_supply * @type: type of charger event - * @msg: optional message passed to uevent_notify fuction + * @msg: optional message passed to uevent_notify function */ void cm_notify_event(struct power_supply *psy, enum cm_event_types type, char *msg) From patchwork Fri Nov 16 11:01:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "(Exiting) Baolin Wang" X-Patchwork-Id: 10685913 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5AB5E1747 for ; Fri, 16 Nov 2018 11:02:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 481332D0D5 for ; Fri, 16 Nov 2018 11:02:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 399482D110; Fri, 16 Nov 2018 11:02:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E5C6A2D128 for ; Fri, 16 Nov 2018 11:02:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389532AbeKPVN5 (ORCPT ); Fri, 16 Nov 2018 16:13:57 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:46044 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389514AbeKPVN4 (ORCPT ); Fri, 16 Nov 2018 16:13:56 -0500 Received: by mail-pg1-f193.google.com with SMTP id y4so10458171pgc.12 for ; Fri, 16 Nov 2018 03:02:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=1sCzjJpuyoWAr3SZdjEjaCQC9rkWcsgGFIVrSihaM1o=; b=EYSmG4fP+EBCLFpS0lesxnIuPLkCQaeDlr7V1pYlMXk9ZJBIW6Vkje/8uYps6+lbyX k/mvNHYnGrCviwD9IprEAwK3uYLY396LT9HIg/iEQbrgImLIfY+LZ0SODLR+dIkU7irv fmG0dV/IoMH3mgYZyk3Rwwn0PRWWShlCl8CkM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=1sCzjJpuyoWAr3SZdjEjaCQC9rkWcsgGFIVrSihaM1o=; b=R7A2Frf9VJ78OjhjbnygqkBIbT5WE+TyjuurJ4hQTK/qAGfToMe6vWlyR9mOIktr+d dJpcL3weEWdwpR8ePEQ0YUlObEv6rTvXD4PIgSLb8fsyg34YKdAIea2PPTBSBtWgqboK V4ULEVrnr8pUKwstOeBvfbyLwFv8ggPQcFu1/dFJX2G92H7UHaxPXZ+2Mx3gK3Ah67LG uwqKBp5+o0J9ZeYDnQysOzvTB5T7VZmxBVrcxey0nNlufEVGAaUrQibMPzk9+h+8oMsp snCw2HeJZOZdW9TMsJfDU05/LhxI23pqMmqojVdEr+c9+tjVjSYRRmW7Yil6/vRlRpJ+ bwPg== X-Gm-Message-State: AGRZ1gL2i290v4Z/JyhuwM/g2+gBJMGnDap/uU2IEBmOsTwdoIed9VIg VPd9AHUPvRwL7rJ1cuwva4fTGw== X-Google-Smtp-Source: AJdET5d9M+WFrHcPuCILaiINB7Uq4f1JDAtltUBrI+KqnwdRk33BFpgTjc5xh9Dtxw1yPwXuBjcbhA== X-Received: by 2002:a63:3546:: with SMTP id c67mr9619376pga.284.1542366125739; Fri, 16 Nov 2018 03:02:05 -0800 (PST) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id 202sm21268106pfy.87.2018.11.16.03.02.00 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 16 Nov 2018 03:02:05 -0800 (PST) From: Baolin Wang To: sre@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, yuanjiang.yu@unisoc.com, baolin.wang@linaro.org, broonie@kernel.org, linus.walleij@linaro.org Subject: [PATCH 3/6] power: supply: charger-manager: Fix incorrect return value Date: Fri, 16 Nov 2018 19:01:10 +0800 Message-Id: X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <4ea9eaf85d780afb190cb45da2df8ff5fd86d449.1542362262.git.baolin.wang@linaro.org> References: <4ea9eaf85d780afb190cb45da2df8ff5fd86d449.1542362262.git.baolin.wang@linaro.org> In-Reply-To: <4ea9eaf85d780afb190cb45da2df8ff5fd86d449.1542362262.git.baolin.wang@linaro.org> References: <4ea9eaf85d780afb190cb45da2df8ff5fd86d449.1542362262.git.baolin.wang@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Fix incorrect return value. Signed-off-by: Baolin Wang --- drivers/power/supply/charger-manager.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/power/supply/charger-manager.c b/drivers/power/supply/charger-manager.c index bd6c450..a52bc77 100644 --- a/drivers/power/supply/charger-manager.c +++ b/drivers/power/supply/charger-manager.c @@ -1212,7 +1212,6 @@ static int charger_extcon_init(struct charger_manager *cm, if (ret < 0) { pr_info("Cannot register extcon_dev for %s(cable: %s)\n", cable->extcon_name, cable->name); - ret = -EINVAL; } return ret; @@ -1633,7 +1632,7 @@ static int charger_manager_probe(struct platform_device *pdev) if (IS_ERR(desc)) { dev_err(&pdev->dev, "No platform data (desc) found\n"); - return -ENODEV; + return PTR_ERR(desc); } cm = devm_kzalloc(&pdev->dev, sizeof(*cm), GFP_KERNEL); From patchwork Fri Nov 16 11:01:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "(Exiting) Baolin Wang" X-Patchwork-Id: 10685911 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 01BFC109C for ; Fri, 16 Nov 2018 11:02:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DFACD2D0D5 for ; Fri, 16 Nov 2018 11:02:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D2D032D122; Fri, 16 Nov 2018 11:02:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 896922D0D5 for ; Fri, 16 Nov 2018 11:02:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389552AbeKPVOB (ORCPT ); Fri, 16 Nov 2018 16:14:01 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:33035 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389430AbeKPVOA (ORCPT ); Fri, 16 Nov 2018 16:14:00 -0500 Received: by mail-pl1-f196.google.com with SMTP id w22-v6so11027841plk.0 for ; Fri, 16 Nov 2018 03:02:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=L0xxyPjE8jBaIz9DC2r/ZKc+hYCfYlfYhlTPplJ8+20=; b=gTp6Rlk8HY7VLKjMhf6stj3PTnfOgE97FBcG62ZQAdB/Af8TqsQXH2pIH4adcwWGCB yBaeFJZl3fu+4VdwiydWoTWIaO2oIHnnsFEITi7b7QYr4ueIZhAfTdJgOFb6o5ZXDWgk ChlLSlhlxfKW+zj8fOS9RBOdsIEEzGtE552uI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=L0xxyPjE8jBaIz9DC2r/ZKc+hYCfYlfYhlTPplJ8+20=; b=Famihop+PrzAYUkrxNgY9FvnoVSFY8X3HkSMLIDSnv/eyLsc37pVTD0XD6IgUMub/f e25VLCMNEGzn4/jy4VGD+KiXbPFbcZ8oNC/isEcShqTOEB/8UDhPqo2ofBXepobEdR/5 ItCd5s0pHQ3pdy4Fk8EgHvVd4q4Cz9/C+J6bGiLUJtCAhIGtG34cqKrYM6i23cYNRW04 NwWLqyg355LYGahS0pjyZJfku/HaTClISFG8nEKyELqyrsRp3mLnv9kxNEr/NFJBjlGR cx/nxFJ+9kUmqffZw51YyvU4FgzDbS0Czz0Bk/CMPg/It1YSz0T11pG96kozaIwcMs+D PonQ== X-Gm-Message-State: AGRZ1gKVMBmWH14nP+71zyuXUgk8oKCnw+tbQTMQNAvo1d7SWV5DVRCn pLtFYSh2vcwlbvvGd2U/05/fCA== X-Google-Smtp-Source: AJdET5ecI8xeHd96IbsUVDWxyijJGYzDgELZQqV+WowqMjKAuSs6K/mwt37V3vFW8y4VYqqNIOrRxQ== X-Received: by 2002:a17:902:be07:: with SMTP id r7-v6mr10284545pls.137.1542366129680; Fri, 16 Nov 2018 03:02:09 -0800 (PST) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id 202sm21268106pfy.87.2018.11.16.03.02.05 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 16 Nov 2018 03:02:08 -0800 (PST) From: Baolin Wang To: sre@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, yuanjiang.yu@unisoc.com, baolin.wang@linaro.org, broonie@kernel.org, linus.walleij@linaro.org Subject: [PATCH 4/6] power: supply: charger-manager: Make code more readable Date: Fri, 16 Nov 2018 19:01:11 +0800 Message-Id: <12b1b583c3da503be4ad7bed01e7b07a0a2b2126.1542362262.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <4ea9eaf85d780afb190cb45da2df8ff5fd86d449.1542362262.git.baolin.wang@linaro.org> References: <4ea9eaf85d780afb190cb45da2df8ff5fd86d449.1542362262.git.baolin.wang@linaro.org> In-Reply-To: <4ea9eaf85d780afb190cb45da2df8ff5fd86d449.1542362262.git.baolin.wang@linaro.org> References: <4ea9eaf85d780afb190cb45da2df8ff5fd86d449.1542362262.git.baolin.wang@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Make code more readable. Signed-off-by: Baolin Wang --- drivers/power/supply/charger-manager.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/power/supply/charger-manager.c b/drivers/power/supply/charger-manager.c index a52bc77..dc0c9a6 100644 --- a/drivers/power/supply/charger-manager.c +++ b/drivers/power/supply/charger-manager.c @@ -1520,19 +1520,19 @@ static struct charger_desc *of_cm_parse_desc(struct device *dev) /* chargers */ of_property_read_u32(np, "cm-num-chargers", &num_chgs); if (num_chgs) { + int i; + /* Allocate empty bin at the tail of array */ desc->psy_charger_stat = devm_kcalloc(dev, num_chgs + 1, sizeof(char *), GFP_KERNEL); - if (desc->psy_charger_stat) { - int i; - for (i = 0; i < num_chgs; i++) - of_property_read_string_index(np, "cm-chargers", - i, &desc->psy_charger_stat[i]); - } else { + if (!desc->psy_charger_stat) return ERR_PTR(-ENOMEM); - } + + for (i = 0; i < num_chgs; i++) + of_property_read_string_index(np, "cm-chargers", + i, &desc->psy_charger_stat[i]); } of_property_read_string(np, "cm-fuel-gauge", &desc->psy_fuel_gauge); From patchwork Fri Nov 16 11:01:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "(Exiting) Baolin Wang" X-Patchwork-Id: 10685909 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7B6E51747 for ; Fri, 16 Nov 2018 11:02:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 697902D0D5 for ; Fri, 16 Nov 2018 11:02:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5D9EE2D122; Fri, 16 Nov 2018 11:02:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CEB0B2D0D5 for ; Fri, 16 Nov 2018 11:02:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389487AbeKPVOR (ORCPT ); Fri, 16 Nov 2018 16:14:17 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:44166 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389550AbeKPVOF (ORCPT ); Fri, 16 Nov 2018 16:14:05 -0500 Received: by mail-pg1-f195.google.com with SMTP id t13so1810791pgr.11 for ; Fri, 16 Nov 2018 03:02:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=oFvCzZZqNBSbDG9EOSs0H2fQO9rLPB9US33Ar8fKAkM=; b=R0QhzbVvE26Vzwv072oDm8R9rLKqth6qj0b3qrBuv9NlCudvzF0mmxvQx/ZAvuPQDr Q0mMTxVsV62Eo18dZA7NYVFq16oNuJaYaFzb1nGb6sNfHRUrrhu1Z/3bhxa7OSyOcvXc /SjgRJvcZxdBvRUXqUpUt+UGRcGLLGN/cUeq4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=oFvCzZZqNBSbDG9EOSs0H2fQO9rLPB9US33Ar8fKAkM=; b=R2V2gQo8QN0wUOPX9oAUNxjlFYF77Y/Eh/WWnIQjoP07RBm3BA2bKFRH4+nx1k5a+i TxwJ1rFCHsgb5xhu9V1mPekVZan+eYjyYDl073O31io7tsBFu7NeP3jGRvFlq43Nq2V9 Vrn6pGcZ2ZhCo/4tlq0HfAnFQ880Iv6MuuSzIFd2wP/1s0k3SuoxYe7zL26sHHl8jmGW PqnEOMyJKU59M+9grPZruvi2wK8zcsbbobWdJSsQvfIFz5nFE0caBuSirOTJZlXobiWI JKs+IkjNk5rf3VbdK9auw5XZdtLkeEPKHK6R6tyKepYXbIggXRna7bQQ1mrZz1gjWv4B OXOg== X-Gm-Message-State: AGRZ1gLjiHqwpkUTbmUomwIQoeT9b2lfJ8RBx29dPeNxDrwirhuXeXrW o1YsSvmyaL2VomrazC588Yp23C8KqVouHA== X-Google-Smtp-Source: AJdET5drnHPO+jP85ybSrULjCoRx34i4F5ifG0RLEX3gbm6IhCRzRgJt1fHT9KMzcZBxKGVD4P/COA== X-Received: by 2002:a63:e445:: with SMTP id i5mr9466026pgk.307.1542366134115; Fri, 16 Nov 2018 03:02:14 -0800 (PST) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id 202sm21268106pfy.87.2018.11.16.03.02.09 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 16 Nov 2018 03:02:13 -0800 (PST) From: Baolin Wang To: sre@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, yuanjiang.yu@unisoc.com, baolin.wang@linaro.org, broonie@kernel.org, linus.walleij@linaro.org Subject: [PATCH 5/6] power: supply: charger-manager: Remove deprecated extcon APIs Date: Fri, 16 Nov 2018 19:01:12 +0800 Message-Id: X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <4ea9eaf85d780afb190cb45da2df8ff5fd86d449.1542362262.git.baolin.wang@linaro.org> References: <4ea9eaf85d780afb190cb45da2df8ff5fd86d449.1542362262.git.baolin.wang@linaro.org> In-Reply-To: <4ea9eaf85d780afb190cb45da2df8ff5fd86d449.1542362262.git.baolin.wang@linaro.org> References: <4ea9eaf85d780afb190cb45da2df8ff5fd86d449.1542362262.git.baolin.wang@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The struct extcon_specific_cable_nb and related APIs are deprecated now, so we should use new method to get one extcon device and register extcon notifier. Signed-off-by: Baolin Wang --- .../bindings/power/supply/charger-manager.txt | 6 +-- drivers/power/supply/charger-manager.c | 51 ++++++++------------ include/linux/power/charger-manager.h | 2 +- 3 files changed, 23 insertions(+), 36 deletions(-) diff --git a/Documentation/devicetree/bindings/power/supply/charger-manager.txt b/Documentation/devicetree/bindings/power/supply/charger-manager.txt index ec4fe9d..315b0cb 100644 --- a/Documentation/devicetree/bindings/power/supply/charger-manager.txt +++ b/Documentation/devicetree/bindings/power/supply/charger-manager.txt @@ -11,7 +11,7 @@ Required properties : - cm-regulator-name : name of charger regulator - subnode : - cm-cable-name : name of charger cable - - cm-cable-extcon : name of extcon dev + - extcon : phandles to external connector devices (optional) - cm-cable-min : minimum current of cable (optional) - cm-cable-max : maximum current of cable @@ -66,13 +66,13 @@ Example : cm-regulator-name = "chg-reg"; cable@0 { cm-cable-name = "USB"; - cm-cable-extcon = "extcon-dev.0"; + extcon = <&extcon_usb>; cm-cable-min = <475000>; cm-cable-max = <500000>; }; cable@1 { cm-cable-name = "TA"; - cm-cable-extcon = "extcon-dev.0"; + extcon = <&extcon_usb>; cm-cable-min = <650000>; cm-cable-max = <675000>; }; diff --git a/drivers/power/supply/charger-manager.c b/drivers/power/supply/charger-manager.c index dc0c9a6..4f28c03 100644 --- a/drivers/power/supply/charger-manager.c +++ b/drivers/power/supply/charger-manager.c @@ -1207,12 +1207,11 @@ static int charger_extcon_init(struct charger_manager *cm, */ INIT_WORK(&cable->wq, charger_extcon_work); cable->nb.notifier_call = charger_extcon_notifier; - ret = extcon_register_interest(&cable->extcon_dev, - cable->extcon_name, cable->name, &cable->nb); - if (ret < 0) { - pr_info("Cannot register extcon_dev for %s(cable: %s)\n", - cable->extcon_name, cable->name); - } + ret = devm_extcon_register_notifier(cm->dev, cable->extcon_dev, + EXTCON_USB, &cable->nb); + if (ret < 0) + dev_err(cm->dev, "Cannot register extcon_dev for (cable: %s)\n", + cable->name); return ret; } @@ -1589,15 +1588,25 @@ static struct charger_desc *of_cm_parse_desc(struct device *dev) for_each_child_of_node(child, _child) { of_property_read_string(_child, "cm-cable-name", &cables->name); - of_property_read_string(_child, - "cm-cable-extcon", - &cables->extcon_name); of_property_read_u32(_child, "cm-cable-min", &cables->min_uA); of_property_read_u32(_child, "cm-cable-max", &cables->max_uA); + + if (of_property_read_bool(_child, "extcon")) { + struct device_node *np; + + np = of_parse_phandle(_child, "extcon", 0); + if (!np) + return ERR_PTR(-ENODEV); + + cables->extcon_dev = extcon_find_edev_by_node(np); + of_node_put(np); + if (IS_ERR(cables->extcon_dev)) + return ERR_PTR(PTR_ERR(cables->extcon_dev)); + } cables++; } } @@ -1625,7 +1634,6 @@ static int charger_manager_probe(struct platform_device *pdev) struct charger_desc *desc = cm_get_drv_data(pdev); struct charger_manager *cm; int ret, i = 0; - int j = 0; union power_supply_propval val; struct power_supply *fuel_gauge; struct power_supply_config psy_cfg = {}; @@ -1823,19 +1831,8 @@ static int charger_manager_probe(struct platform_device *pdev) &charger->attr_g); } err_reg_extcon: - for (i = 0; i < desc->num_charger_regulators; i++) { - struct charger_regulator *charger; - - charger = &desc->charger_regulators[i]; - for (j = 0; j < charger->num_cables; j++) { - struct charger_cable *cable = &charger->cables[j]; - /* Remove notifier block if only edev exists */ - if (cable->extcon_dev.edev) - extcon_unregister_interest(&cable->extcon_dev); - } - + for (i = 0; i < desc->num_charger_regulators; i++) regulator_put(desc->charger_regulators[i].consumer); - } power_supply_unregister(cm->charger_psy); @@ -1847,7 +1844,6 @@ static int charger_manager_remove(struct platform_device *pdev) struct charger_manager *cm = platform_get_drvdata(pdev); struct charger_desc *desc = cm->desc; int i = 0; - int j = 0; /* Remove from the list */ mutex_lock(&cm_list_mtx); @@ -1857,15 +1853,6 @@ static int charger_manager_remove(struct platform_device *pdev) cancel_work_sync(&setup_polling); cancel_delayed_work_sync(&cm_monitor_work); - for (i = 0 ; i < desc->num_charger_regulators ; i++) { - struct charger_regulator *charger - = &desc->charger_regulators[i]; - for (j = 0 ; j < charger->num_cables ; j++) { - struct charger_cable *cable = &charger->cables[j]; - extcon_unregister_interest(&cable->extcon_dev); - } - } - for (i = 0 ; i < desc->num_charger_regulators ; i++) regulator_put(desc->charger_regulators[i].consumer); diff --git a/include/linux/power/charger-manager.h b/include/linux/power/charger-manager.h index c4fa907..e4d0269 100644 --- a/include/linux/power/charger-manager.h +++ b/include/linux/power/charger-manager.h @@ -66,7 +66,7 @@ struct charger_cable { const char *name; /* The charger-manager use Extcon framework */ - struct extcon_specific_cable_nb extcon_dev; + struct extcon_dev *extcon_dev; struct work_struct wq; struct notifier_block nb; From patchwork Fri Nov 16 11:01:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "(Exiting) Baolin Wang" X-Patchwork-Id: 10685907 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C52C81747 for ; Fri, 16 Nov 2018 11:02:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B4AE52D111 for ; Fri, 16 Nov 2018 11:02:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A89672D128; Fri, 16 Nov 2018 11:02:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 356742D111 for ; Fri, 16 Nov 2018 11:02:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389616AbeKPVOJ (ORCPT ); Fri, 16 Nov 2018 16:14:09 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:40335 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389615AbeKPVOJ (ORCPT ); Fri, 16 Nov 2018 16:14:09 -0500 Received: by mail-pf1-f195.google.com with SMTP id x2-v6so11245949pfm.7 for ; Fri, 16 Nov 2018 03:02:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=SRjHqre43wUKPvvX7pz11akDR7cvUF9OTxM3rE3wtFs=; b=PPcUwKTDELEs2H6qRWEVBMOqPWZPT1r4mocWQTAPi2KSslFbxMaxJy+M85FunIkHxu T2ggfExjh6dD6Hq2yTWuOF2Bp/cic513KqQij3KpckKq6dSq0Ug8XCTq6ayk0ldTcc+O 1SNUkCNH92XdoWmL/81Yp9FfQFadyMciFaiN4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=SRjHqre43wUKPvvX7pz11akDR7cvUF9OTxM3rE3wtFs=; b=McysvbuRqAiPr6zaEp1qPQ2iHzUb8jUMwIfCcLiHmcXEQSIlvSqh8ZW2kJrmugC5Pr qMUJggFLWmjWa7WJIz1sZRh3CT78hqmc6CKRnmkFb+T27qMGl4d0itwnXLUXQxGrTCjJ Z5lyIOtn7T8jXDGClYhEBDcwRu7Q4TgP8r82VX/Ife1DTcLB/RskXXO2WZ+AR8J/skFO mXfulfIVfR+t4OGB1HNsq6NknoA9R1mh9Zq8kPyi//OlKnZKr/L9kcJC+Ospf+aYrLZu aSVi2kdE3V5uRYUuIv7tXKHKSnUzSEVYZl6WlB/LjhzAZwQ8HZo2F6F9krsZgWi9s6C4 J8nw== X-Gm-Message-State: AGRZ1gK8nPGgd+dadPXilraMHeGgG9mwfPWvosD90CbULUX+BgJZe04f AQ8kT/NezTg2Gtw+Zlv8V215Fw== X-Google-Smtp-Source: AJdET5fbJ3eNh+INMwDji2/km92/5BoHTI6IynzkyeYkhDhXi8AZyULLU+oszrVc0fbe/zEygstphg== X-Received: by 2002:a63:d604:: with SMTP id q4mr9374494pgg.175.1542366138298; Fri, 16 Nov 2018 03:02:18 -0800 (PST) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id 202sm21268106pfy.87.2018.11.16.03.02.14 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 16 Nov 2018 03:02:17 -0800 (PST) From: Baolin Wang To: sre@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, yuanjiang.yu@unisoc.com, baolin.wang@linaro.org, broonie@kernel.org, linus.walleij@linaro.org Subject: [PATCH 6/6] power: supply: charger-manager: Add new method to start/stop charging Date: Fri, 16 Nov 2018 19:01:13 +0800 Message-Id: X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <4ea9eaf85d780afb190cb45da2df8ff5fd86d449.1542362262.git.baolin.wang@linaro.org> References: <4ea9eaf85d780afb190cb45da2df8ff5fd86d449.1542362262.git.baolin.wang@linaro.org> In-Reply-To: <4ea9eaf85d780afb190cb45da2df8ff5fd86d449.1542362262.git.baolin.wang@linaro.org> References: <4ea9eaf85d780afb190cb45da2df8ff5fd86d449.1542362262.git.baolin.wang@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP For some chargers (such as Spreadtrum SC2731 charger), they don't use regulators to control charging, instead charging control was implemented in their drivers, so we can add some supports to start or stop charging by POWER_SUPPLY_PROP_STATUS property. Signed-off-by: Baolin Wang --- drivers/power/supply/charger-manager.c | 35 ++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/drivers/power/supply/charger-manager.c b/drivers/power/supply/charger-manager.c index 4f28c03..d0d0b82 100644 --- a/drivers/power/supply/charger-manager.c +++ b/drivers/power/supply/charger-manager.c @@ -348,6 +348,32 @@ static bool is_polling_required(struct charger_manager *cm) return false; } +static int try_charger_enable_by_psy(struct charger_manager *cm, bool enable) +{ + struct charger_desc *desc = cm->desc; + union power_supply_propval val; + struct power_supply *psy; + int i, err; + + for (i = 0; desc->psy_charger_stat[i]; i++) { + psy = power_supply_get_by_name(desc->psy_charger_stat[i]); + if (!psy) { + dev_err(cm->dev, "Cannot find power supply \"%s\"\n", + desc->psy_charger_stat[i]); + continue; + } + + val.intval = enable; + err = power_supply_set_property(psy, POWER_SUPPLY_PROP_STATUS, + &val); + power_supply_put(psy); + if (err) + return err; + } + + return 0; +} + /** * try_charger_enable - Enable/Disable chargers altogether * @cm: the Charger Manager representing the battery. @@ -378,6 +404,10 @@ static int try_charger_enable(struct charger_manager *cm, bool enable) cm->charging_start_time = ktime_to_ms(ktime_get()); cm->charging_end_time = 0; + err = try_charger_enable_by_psy(cm, enable); + if (!err) + goto out; + for (i = 0 ; i < desc->num_charger_regulators ; i++) { if (desc->charger_regulators[i].externally_control) continue; @@ -396,6 +426,10 @@ static int try_charger_enable(struct charger_manager *cm, bool enable) cm->charging_start_time = 0; cm->charging_end_time = ktime_to_ms(ktime_get()); + err = try_charger_enable_by_psy(cm, enable); + if (!err) + goto out; + for (i = 0 ; i < desc->num_charger_regulators ; i++) { if (desc->charger_regulators[i].externally_control) continue; @@ -422,6 +456,7 @@ static int try_charger_enable(struct charger_manager *cm, bool enable) } } +out: if (!err) cm->charger_enabled = enable;