From patchwork Thu May 14 23:04:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Bakker X-Patchwork-Id: 212026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D55FAC433DF for ; Thu, 14 May 2020 23:05:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A7C0B2065F for ; Thu, 14 May 2020 23:05:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728863AbgENXFj (ORCPT ); Thu, 14 May 2020 19:05:39 -0400 Received: from mail-bn8nam12olkn2108.outbound.protection.outlook.com ([40.92.21.108]:20142 "EHLO NAM12-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728508AbgENXFL (ORCPT ); Thu, 14 May 2020 19:05:11 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=n+oD2qsV3IsjlI2vZ66rpKeZ7LBWeLwjDqPGsKoOo7ZhKEo53M+FMxK2ywa0cNChWzISLEVUf/A+cXKkBU081aRVG6xBxoNMa2W0DUX9CSe6VXHnV3KancyCrKYjN/8VByzAGOZDpJpnzRXglqhdj4UqoqcCFOLeIAZ+J+DZLMM+US6iEFOQJiI+srMPx4FNBdEYju4Fqzs6rb8EOY4KaWmkPnaZ7oON2iOo5bLUOWCGO0iu92PHa4Y2NMwcYNQCrJQX8fWhXa0QQHqAvFbqENfUnwO1aOBOe4t9zsJw3msIt1V4RrKAAlHv+oNkqWuABUo3h3vDzwjbeUywYBVYaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lyjKg82RDXOCg9HNE8hwuthY+JJZ6CRJdrgIFzS+iNo=; b=RbnFLpQZeIDa1Q1Ov+j3FgFtvu2MLKK/YThLyRGh/4QS4IaRtOcM3GfJciBQ2DJSszt+mXXM5P0zUSNXnEQLXQxBNCEG1NO7/FiY5zekj2Mt0cvv6/FfdKNwUPUPPtwgafRaNW9eie8vlKdbcWiRQqeT6sw6EHojR5rtUzkyz51cm9E3DwbFnmpMBbxRWsjtssZ7eNqP58NhE/BXw9mm/GJzXeAmv03eIbU+r57IhbkhtwX6ieTMPuYoNoAxeQC5MJE8FAOBD5z6gAQwwYs5UKRNkFsHsQIn92BOLBkYMFtbwIArybwI6GQy4WvxOwNgGQDEX+3K2VfuflzUhHTI0w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=live.ca; dmarc=pass action=none header.from=live.ca; dkim=pass header.d=live.ca; arc=none Received: from MW2NAM12FT003.eop-nam12.prod.protection.outlook.com (2a01:111:e400:fc65::48) by MW2NAM12HT165.eop-nam12.prod.protection.outlook.com (2a01:111:e400:fc65::320) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.11; Thu, 14 May 2020 23:05:07 +0000 Received: from BN6PR04MB0660.namprd04.prod.outlook.com (2a01:111:e400:fc65::44) by MW2NAM12FT003.mail.protection.outlook.com (2a01:111:e400:fc65::70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.11 via Frontend Transport; Thu, 14 May 2020 23:05:07 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:2016BDC7D35C5A6C359D7E9001B4EDC8631378461CFA9E445D7FF99FCAA2B433; UpperCasedChecksum:6018D499545EF9CA234DD02394934E579641570A08EE1F3EA4A34A0726C73216; SizeAsReceived:7957; Count:50 Received: from BN6PR04MB0660.namprd04.prod.outlook.com ([fe80::ad10:4127:4bc8:76fc]) by BN6PR04MB0660.namprd04.prod.outlook.com ([fe80::ad10:4127:4bc8:76fc%6]) with mapi id 15.20.3000.022; Thu, 14 May 2020 23:05:07 +0000 From: Jonathan Bakker To: sre@kernel.org, krzk@kernel.org, jonghwa3.lee@samsung.com, tglx@linutronix.de, kstewart@linuxfoundation.org, baolin.wang7@gmail.com, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Krzysztof Kozlowski , Jonathan Bakker Subject: [PATCH 02/10] power: supply: charger-manager: Remove cm_notify_event function Date: Thu, 14 May 2020 16:04:27 -0700 Message-ID: X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200514230435.11798-1-xc-racer2@live.ca> References: <20200514230435.11798-1-xc-racer2@live.ca> X-ClientProxiedBy: MWHPR22CA0040.namprd22.prod.outlook.com (2603:10b6:300:69::26) To BN6PR04MB0660.namprd04.prod.outlook.com (2603:10b6:404:d9::21) X-Microsoft-Original-Message-ID: <20200514230435.11798-3-xc-racer2@live.ca> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from jon-hp-6570b.telus (2001:569:fb68:9c00:8067:f823:1e15:7520) by MWHPR22CA0040.namprd22.prod.outlook.com (2603:10b6:300:69::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.26 via Frontend Transport; Thu, 14 May 2020 23:05:05 +0000 X-Mailer: git-send-email 2.20.1 X-Microsoft-Original-Message-ID: <20200514230435.11798-3-xc-racer2@live.ca> X-TMN: [xV0L5Z9tMl1BQBrVnn0IYO2sSh5535YaB7QpL7I3vEApBrFNhWEMqDXDGOUhWZo1] X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 50 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 91cd1ee8-1f5e-4fb2-2468-08d7f85b3e71 X-MS-TrafficTypeDiagnostic: MW2NAM12HT165: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: U/8jDoMB5T4IH3FjWgOgHjkbRzf2TWk6hDoXQ+7oghldWYXs3sYbVYS8/jvo9h70ezrUk4TCqRd+utC3/51P+eJrNyu8aW+lgq6GpB2i7Y0JiKrPVf4rmlmJXJNp0tJiw/W+qzRdPU8tY8mX7W3Ukae7lddrLBN9bdHYitzr/KELzdfhl1UBP+I5Gqkl3kJrVPdf5CZL+5BKhQdeMSm07Q== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:0; SRV:; IPV:NLI; SFV:NSPM; H:BN6PR04MB0660.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:; DIR:OUT; SFP:1901; X-MS-Exchange-AntiSpam-MessageData: vNj+264zHEsFFjpQ7zvYkxF83FqUXm76HPVebLT5vPxfNlp46U8biAIrvnH7NqryeBl15DMwQLhShcv6KIbDUq9E87fSTueqFLmMFyp/QKwWIGkcXez3iFMPwtn+/DjAFJho1/N93iwPR1npNKUF/SukHa+FWLFGSJz1VWhNgMoe4WuPLnlwszSoIUXQvhjBP8RomHInIFKAk3KRAWyImw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 91cd1ee8-1f5e-4fb2-2468-08d7f85b3e71 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 May 2020 23:05:07.3087 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2NAM12HT165 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Jonghwa Lee cm_notify_event() was introduced to get an event associated with the battery status externally (ie in board files), but no one ever used it. Moreover it makes charger manager driver more complicated. Drop the function and all data related to it to simplify the driver. Signed-off-by: Jonghwa Lee Signed-off-by: Krzysztof Kozlowski Signed-off-by: Jonathan Bakker --- drivers/power/supply/charger-manager.c | 183 ++----------------------- include/linux/power/charger-manager.h | 33 +---- 2 files changed, 16 insertions(+), 200 deletions(-) diff --git a/drivers/power/supply/charger-manager.c b/drivers/power/supply/charger-manager.c index 330185b960a5..413f291fda5f 100644 --- a/drivers/power/supply/charger-manager.c +++ b/drivers/power/supply/charger-manager.c @@ -434,25 +434,18 @@ static int try_charger_restart(struct charger_manager *cm) /** * fullbatt_vchk - Check voltage drop some times after "FULL" event. - * @work: the work_struct appointing the function * - * If a user has designated "fullbatt_vchkdrop_ms/uV" values with + * If a user has designated "fullbatt_vchkdrop_uV" values with * charger_desc, Charger Manager checks voltage drop after the battery * "FULL" event. It checks whether the voltage has dropped more than * fullbatt_vchkdrop_uV by calling this function after fullbatt_vchkrop_ms. */ -static void fullbatt_vchk(struct work_struct *work) +static void fullbatt_vchk(struct charger_manager *cm) { - struct delayed_work *dwork = to_delayed_work(work); - struct charger_manager *cm = container_of(dwork, - struct charger_manager, fullbatt_vchk_work); struct charger_desc *desc = cm->desc; int batt_uV, err, diff; - /* remove the appointment for fullbatt_vchk */ - cm->fullbatt_vchk_jiffies_at = 0; - - if (!desc->fullbatt_vchkdrop_uV || !desc->fullbatt_vchkdrop_ms) + if (!desc->fullbatt_vchkdrop_uV) return; err = get_batt_uV(cm, &batt_uV); @@ -588,9 +581,11 @@ static int cm_check_thermal_status(struct charger_manager *cm) } if (temp > upper_limit) - ret = CM_EVENT_BATT_OVERHEAT; + ret = CM_BATT_OVERHEAT; else if (temp < lower_limit) - ret = CM_EVENT_BATT_COLD; + ret = CM_BATT_COLD; + else + ret = CM_BATT_OK; return ret; } @@ -635,7 +630,7 @@ static bool _cm_monitor(struct charger_manager *cm) */ } else if (!cm->emergency_stop && is_ext_pwr_online(cm) && !cm->charger_enabled) { - fullbatt_vchk(&cm->fullbatt_vchk_work.work); + fullbatt_vchk(cm); /* * Check whether fully charged state to protect overcharge @@ -648,7 +643,7 @@ static bool _cm_monitor(struct charger_manager *cm) try_charger_enable(cm, false); - fullbatt_vchk(&cm->fullbatt_vchk_work.work); + fullbatt_vchk(cm); } else { cm->emergency_stop = 0; if (is_ext_pwr_online(cm)) { @@ -750,66 +745,6 @@ static void cm_monitor_poller(struct work_struct *work) schedule_work(&setup_polling); } -/** - * fullbatt_handler - Event handler for CM_EVENT_BATT_FULL - * @cm: the Charger Manager representing the battery. - */ -static void fullbatt_handler(struct charger_manager *cm) -{ - struct charger_desc *desc = cm->desc; - - if (!desc->fullbatt_vchkdrop_uV || !desc->fullbatt_vchkdrop_ms) - goto out; - - if (cm_suspended) - device_set_wakeup_capable(cm->dev, true); - - mod_delayed_work(cm_wq, &cm->fullbatt_vchk_work, - msecs_to_jiffies(desc->fullbatt_vchkdrop_ms)); - cm->fullbatt_vchk_jiffies_at = jiffies + msecs_to_jiffies( - desc->fullbatt_vchkdrop_ms); - - if (cm->fullbatt_vchk_jiffies_at == 0) - cm->fullbatt_vchk_jiffies_at = 1; - -out: - dev_info(cm->dev, "EVENT_HANDLE: Battery Fully Charged\n"); - power_supply_changed(cm->charger_psy); -} - -/** - * battout_handler - Event handler for CM_EVENT_BATT_OUT - * @cm: the Charger Manager representing the battery. - */ -static void battout_handler(struct charger_manager *cm) -{ - if (cm_suspended) - device_set_wakeup_capable(cm->dev, true); - - if (!is_batt_present(cm)) { - dev_emerg(cm->dev, "Battery Pulled Out!\n"); - power_supply_changed(cm->charger_psy); - } else { - power_supply_changed(cm->charger_psy); - } -} - -/** - * misc_event_handler - Handler for other events - * @cm: the Charger Manager representing the battery. - * @type: the Charger Manager representing the battery. - */ -static void misc_event_handler(struct charger_manager *cm, - enum cm_event_types type) -{ - if (cm_suspended) - device_set_wakeup_capable(cm->dev, true); - - if (is_polling_required(cm) && cm->desc->polling_interval_ms) - schedule_work(&setup_polling); - power_supply_changed(cm->charger_psy); -} - static int charger_get_property(struct power_supply *psy, enum power_supply_property psp, union power_supply_propval *val) @@ -1000,21 +935,6 @@ static bool cm_setup_timer(void) mutex_lock(&cm_list_mtx); list_for_each_entry(cm, &cm_list, entry) { - unsigned int fbchk_ms = 0; - - /* fullbatt_vchk is required. setup timer for that */ - if (cm->fullbatt_vchk_jiffies_at) { - fbchk_ms = jiffies_to_msecs(cm->fullbatt_vchk_jiffies_at - - jiffies); - if (time_is_before_eq_jiffies( - cm->fullbatt_vchk_jiffies_at) || - msecs_to_jiffies(fbchk_ms) < CM_JIFFIES_SMALL) { - fullbatt_vchk(&cm->fullbatt_vchk_work.work); - fbchk_ms = 0; - } - } - CM_MIN_VALID(wakeup_ms, fbchk_ms); - /* Skip if polling is not required for this CM */ if (!is_polling_required(cm) && !cm->emergency_stop) continue; @@ -1422,8 +1342,6 @@ static struct charger_desc *of_cm_parse_desc(struct device *dev) of_property_read_u32(np, "cm-poll-interval", &desc->polling_interval_ms); - of_property_read_u32(np, "cm-fullbatt-vchkdrop-ms", - &desc->fullbatt_vchkdrop_ms); of_property_read_u32(np, "cm-fullbatt-vchkdrop-volt", &desc->fullbatt_vchkdrop_uV); of_property_read_u32(np, "cm-fullbatt-voltage", &desc->fullbatt_uV); @@ -1583,9 +1501,8 @@ static int charger_manager_probe(struct platform_device *pdev) if (desc->fullbatt_uV == 0) { dev_info(&pdev->dev, "Ignoring full-battery voltage threshold as it is not supplied\n"); } - if (!desc->fullbatt_vchkdrop_ms || !desc->fullbatt_vchkdrop_uV) { + if (!desc->fullbatt_vchkdrop_uV) { dev_info(&pdev->dev, "Disabling full-battery voltage drop checking mechanism as it is not supplied\n"); - desc->fullbatt_vchkdrop_ms = 0; desc->fullbatt_vchkdrop_uV = 0; } if (desc->fullbatt_soc == 0) { @@ -1689,8 +1606,6 @@ static int charger_manager_probe(struct platform_device *pdev) } power_supply_put(fuel_gauge); - INIT_DELAYED_WORK(&cm->fullbatt_vchk_work, fullbatt_vchk); - /* Register sysfs entry for charger(regulator) */ ret = charger_manager_prepare_sysfs(cm); if (ret < 0) { @@ -1830,8 +1745,6 @@ static bool cm_need_to_awake(void) static int cm_suspend_prepare(struct device *dev) { - struct charger_manager *cm = dev_get_drvdata(dev); - if (cm_need_to_awake()) return -EBUSY; @@ -1843,7 +1756,6 @@ static int cm_suspend_prepare(struct device *dev) if (cm_timer_set) { cancel_work_sync(&setup_polling); cancel_delayed_work_sync(&cm_monitor_work); - cancel_delayed_work(&cm->fullbatt_vchk_work); } return 0; @@ -1868,31 +1780,6 @@ static void cm_suspend_complete(struct device *dev) _cm_monitor(cm); - /* Re-enqueue delayed work (fullbatt_vchk_work) */ - if (cm->fullbatt_vchk_jiffies_at) { - unsigned long delay = 0; - unsigned long now = jiffies + CM_JIFFIES_SMALL; - - if (time_after_eq(now, cm->fullbatt_vchk_jiffies_at)) { - delay = (unsigned long)((long)now - - (long)(cm->fullbatt_vchk_jiffies_at)); - delay = jiffies_to_msecs(delay); - } else { - delay = 0; - } - - /* - * Account for cm_suspend_duration_ms with assuming that - * timer stops in suspend. - */ - if (delay > cm_suspend_duration_ms) - delay -= cm_suspend_duration_ms; - else - delay = 0; - - queue_delayed_work(cm_wq, &cm->fullbatt_vchk_work, - msecs_to_jiffies(delay)); - } device_set_wakeup_capable(cm->dev, false); } @@ -1934,56 +1821,6 @@ static void __exit charger_manager_cleanup(void) } module_exit(charger_manager_cleanup); -/** - * 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 function - */ -void cm_notify_event(struct power_supply *psy, enum cm_event_types type, - char *msg) -{ - struct charger_manager *cm; - bool found_power_supply = false; - - if (psy == NULL) - return; - - mutex_lock(&cm_list_mtx); - list_for_each_entry(cm, &cm_list, entry) { - if (match_string(cm->desc->psy_charger_stat, -1, - psy->desc->name) >= 0) { - found_power_supply = true; - break; - } - } - mutex_unlock(&cm_list_mtx); - - if (!found_power_supply) - return; - - switch (type) { - case CM_EVENT_BATT_FULL: - fullbatt_handler(cm); - break; - case CM_EVENT_BATT_OUT: - battout_handler(cm); - break; - case CM_EVENT_BATT_IN: - case CM_EVENT_EXT_PWR_IN_OUT ... CM_EVENT_CHG_START_STOP: - misc_event_handler(cm, type); - break; - case CM_EVENT_UNKNOWN: - case CM_EVENT_OTHERS: - power_supply_changed(cm->charger_psy); - break; - default: - dev_err(cm->dev, "%s: type not specified\n", __func__); - break; - } -} -EXPORT_SYMBOL_GPL(cm_notify_event); - MODULE_AUTHOR("MyungJoo Ham "); MODULE_DESCRIPTION("Charger Manager"); MODULE_LICENSE("GPL"); diff --git a/include/linux/power/charger-manager.h b/include/linux/power/charger-manager.h index ae94dcebd936..3a98837684e3 100644 --- a/include/linux/power/charger-manager.h +++ b/include/linux/power/charger-manager.h @@ -31,16 +31,10 @@ enum polling_modes { CM_POLL_CHARGING_ONLY, }; -enum cm_event_types { - CM_EVENT_UNKNOWN = 0, - CM_EVENT_BATT_FULL, - CM_EVENT_BATT_IN, - CM_EVENT_BATT_OUT, - CM_EVENT_BATT_OVERHEAT, - CM_EVENT_BATT_COLD, - CM_EVENT_EXT_PWR_IN_OUT, - CM_EVENT_CHG_START_STOP, - CM_EVENT_OTHERS, +enum cm_batt_temp { + CM_BATT_OK = 0, + CM_BATT_OVERHEAT, + CM_BATT_COLD, }; /** @@ -131,11 +125,10 @@ struct charger_regulator { * @psy_name: the name of power-supply-class for charger manager * @polling_mode: * Determine which polling mode will be used - * @fullbatt_vchkdrop_ms: * @fullbatt_vchkdrop_uV: * Check voltage drop after the battery is fully charged. - * If it has dropped more than fullbatt_vchkdrop_uV after - * fullbatt_vchkdrop_ms, CM will restart charging. + * If it has dropped more than fullbatt_vchkdrop_uV + * CM will restart charging. * @fullbatt_uV: voltage in microvolt * If VBATT >= fullbatt_uV, it is assumed to be full. * @fullbatt_soc: state of Charge in % @@ -172,7 +165,6 @@ struct charger_desc { enum polling_modes polling_mode; unsigned int polling_interval_ms; - unsigned int fullbatt_vchkdrop_ms; unsigned int fullbatt_vchkdrop_uV; unsigned int fullbatt_uV; unsigned int fullbatt_soc; @@ -211,9 +203,6 @@ struct charger_desc { * @charger_stat: array of power_supply for chargers * @tzd_batt : thermal zone device for battery * @charger_enabled: the state of charger - * @fullbatt_vchk_jiffies_at: - * jiffies at the time full battery check will occur. - * @fullbatt_vchk_work: work queue for full battery check * @emergency_stop: * When setting true, stop charging * @psy_name_buf: the name of power-supply-class for charger manager @@ -235,9 +224,6 @@ struct charger_manager { #endif bool charger_enabled; - unsigned long fullbatt_vchk_jiffies_at; - struct delayed_work fullbatt_vchk_work; - int emergency_stop; char psy_name_buf[PSY_NAME_MAX + 1]; @@ -248,11 +234,4 @@ struct charger_manager { u64 charging_end_time; }; -#if IS_ENABLED(CONFIG_CHARGER_MANAGER) -extern void cm_notify_event(struct power_supply *psy, - enum cm_event_types type, char *msg); -#else -static inline void cm_notify_event(struct power_supply *psy, - enum cm_event_types type, char *msg) { } -#endif #endif /* _CHARGER_MANAGER_H */ From patchwork Thu May 14 23:04:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Bakker X-Patchwork-Id: 212030 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E8FFBC433E3 for ; Thu, 14 May 2020 23:05:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CDD6520727 for ; Thu, 14 May 2020 23:05:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729054AbgENXFL (ORCPT ); Thu, 14 May 2020 19:05:11 -0400 Received: from mail-mw2nam12olkn2106.outbound.protection.outlook.com ([40.92.23.106]:25648 "EHLO NAM12-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729030AbgENXFK (ORCPT ); Thu, 14 May 2020 19:05:10 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aLVLYC9nvW8X8/JMbhT6M1UnikqLvDY6Lb/fR474DHDEffIdrZa/J/tuQXIKvnABI328ZuxtDryUGqMUJDzmGr55rNNQX7AUTgZns3L0ngdgFOYTbblUl9+0u1Bp7pzobOUQOVyb1anO1EDUxKuciSoD2p8fsZ2xGc6gAsIlw3u/6RiA2rFnaVllrf/k64+rfO5e5s2emAz7fKNReI8Nm2CcHEbblszv9LYsy7+64l3gWjtIPD0cFMR+1I2jqkHX9Ljoe5uLkFB2ZQEd5s7mKgXG+Xfpd94vxVZrgx4LDDxICo8SySrke35mHqS+0PJcosjgUAJ41w2WFOHUiC59qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QLomBpgXv/TDUtX34CbzmZ3HlSD3S1fzXXzPwtYsxso=; b=HOFuGOVDECtZtLX5cAAnj314JCyAfo3a78mNEYlti1u6uNonMjqlxRAzKFsXqSH0MfgpJ4DfwZ/ua5AHxuHT+1jiIOpcadCc7QHLzvyf3KOcriCp3skyGFoaKeW76bpzBkT1vD4sGvOuG8L608wQoKy7iZuSNfSIxV5hKaDmFBDnNIp4sN4zlTkKUscd3OqkImIsbYeJzk0M+CXkidmqx7dUyRsEy1KZ2gnzRyFvTLfoc0rOwW+AEXIexh3Rba6U3iRfdh4woGftWDLH7YDXR3/5b5Aut5I8XTrzJKengJlG4dMIQ3fuMcf8eeaAuOheGS/bVmsgrU4nZkxeGq70ZA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=live.ca; dmarc=pass action=none header.from=live.ca; dkim=pass header.d=live.ca; arc=none Received: from MW2NAM12FT003.eop-nam12.prod.protection.outlook.com (2a01:111:e400:fc65::40) by MW2NAM12HT204.eop-nam12.prod.protection.outlook.com (2a01:111:e400:fc65::250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.11; Thu, 14 May 2020 23:05:09 +0000 Received: from BN6PR04MB0660.namprd04.prod.outlook.com (2a01:111:e400:fc65::44) by MW2NAM12FT003.mail.protection.outlook.com (2a01:111:e400:fc65::70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.11 via Frontend Transport; Thu, 14 May 2020 23:05:09 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:64CBFC3109C95C9FCBD57A6799AA931C810E773B695283F3A3641466A59781AC; UpperCasedChecksum:17975E63A85A75CD90A3DDC234C1FBC63FC781E611BF75CB3B850DE16DE0F16E; SizeAsReceived:7865; Count:50 Received: from BN6PR04MB0660.namprd04.prod.outlook.com ([fe80::ad10:4127:4bc8:76fc]) by BN6PR04MB0660.namprd04.prod.outlook.com ([fe80::ad10:4127:4bc8:76fc%6]) with mapi id 15.20.3000.022; Thu, 14 May 2020 23:05:08 +0000 From: Jonathan Bakker To: sre@kernel.org, krzk@kernel.org, jonghwa3.lee@samsung.com, tglx@linutronix.de, kstewart@linuxfoundation.org, baolin.wang7@gmail.com, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jonathan Bakker Subject: [PATCH 03/10] power: supply: charger-manager: Always use POWER_SUPPLY_PROP_TEMP Date: Thu, 14 May 2020 16:04:28 -0700 Message-ID: X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200514230435.11798-1-xc-racer2@live.ca> References: <20200514230435.11798-1-xc-racer2@live.ca> X-ClientProxiedBy: MWHPR22CA0040.namprd22.prod.outlook.com (2603:10b6:300:69::26) To BN6PR04MB0660.namprd04.prod.outlook.com (2603:10b6:404:d9::21) X-Microsoft-Original-Message-ID: <20200514230435.11798-4-xc-racer2@live.ca> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from jon-hp-6570b.telus (2001:569:fb68:9c00:8067:f823:1e15:7520) by MWHPR22CA0040.namprd22.prod.outlook.com (2603:10b6:300:69::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.26 via Frontend Transport; Thu, 14 May 2020 23:05:07 +0000 X-Mailer: git-send-email 2.20.1 X-Microsoft-Original-Message-ID: <20200514230435.11798-4-xc-racer2@live.ca> X-TMN: [yDx9y3RCGQmBAsPKlcjBN6IkC4h43GEhmkQKsM/wuvmI7hcTOrSOrrQj5QjGHG5+] X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 50 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: d49610f8-b4d8-4617-06bc-08d7f85b3f5c X-MS-TrafficTypeDiagnostic: MW2NAM12HT204: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2A6/MF1kAHsYuwQs/+VUj94zUE9CLuXQTeyuocBo6UCsYw0GxPcKq9ELw4y+HD0w44xUc6YnjPE5X0P9tO63J1sHhtCWC+BwXcEqYAWB89yHpMtlTDMvvuYFPWpn0tXL7xfemoClYIJDMi2QjlIEnrPTHt3wPsD5qWARa9Rh+3SotU9/z4RcREmVfbMwxi1+cRmVDIoP9IZANED/NOb4hg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:0; SRV:; IPV:NLI; SFV:NSPM; H:BN6PR04MB0660.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:; DIR:OUT; SFP:1901; X-MS-Exchange-AntiSpam-MessageData: aJ1pJZ5qNMvJfvKEVhwsdzUUBrdMYSPBGK1DWKQBi5IuyHgueMALySGQ3I32i2hJDnXrw7dIkqAXHRWx2SsWXrLgxPP/fPpdKRcJd2X5f2YB1yUD2Jeow+gQElc8MxonZ7jGDWSdC6Cafcea8fZtqbQpM6rO10TgnWls79b2jxLaA/kQmTQ2nn2pElHDRxvTiJr9MbIVWlokQrgvbcCw8A== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: d49610f8-b4d8-4617-06bc-08d7f85b3f5c X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 May 2020 23:05:08.9060 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2NAM12HT204 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org We were using POWER_SUPPLY_PROP_TEMP if the temperature was coming via the fuel gauge and POWER_SUPPLY_PROP_TEMP_AMBIENT if it was coming via the thermal framework. Since they're mutually exclusive in the driver and we don't know if the thermal framework is ambient or not, unify them both to use POWER_SUPPLY_PROP_TEMP. Signed-off-by: Jonathan Bakker --- drivers/power/supply/charger-manager.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/power/supply/charger-manager.c b/drivers/power/supply/charger-manager.c index 413f291fda5f..6a5ae1d0ef92 100644 --- a/drivers/power/supply/charger-manager.c +++ b/drivers/power/supply/charger-manager.c @@ -791,7 +791,6 @@ static int charger_get_property(struct power_supply *psy, POWER_SUPPLY_PROP_CURRENT_NOW, val); break; case POWER_SUPPLY_PROP_TEMP: - case POWER_SUPPLY_PROP_TEMP_AMBIENT: return cm_get_battery_temperature(cm, &val->intval); case POWER_SUPPLY_PROP_CAPACITY: if (!is_batt_present(cm)) { @@ -899,8 +898,7 @@ static enum power_supply_property default_charger_props[] = { * Optional properties are: * POWER_SUPPLY_PROP_CHARGE_NOW, * POWER_SUPPLY_PROP_CURRENT_NOW, - * POWER_SUPPLY_PROP_TEMP, and - * POWER_SUPPLY_PROP_TEMP_AMBIENT, + * POWER_SUPPLY_PROP_TEMP, */ }; @@ -1298,7 +1296,7 @@ static int cm_init_thermal_data(struct charger_manager *cm, /* Use external thermometer */ cm->charger_psy_desc.properties[cm->charger_psy_desc.num_properties] = - POWER_SUPPLY_PROP_TEMP_AMBIENT; + POWER_SUPPLY_PROP_TEMP; cm->charger_psy_desc.num_properties++; cm->desc->measure_battery_temp = true; ret = 0; From patchwork Thu May 14 23:04:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Bakker X-Patchwork-Id: 212027 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 166BEC433E0 for ; Thu, 14 May 2020 23:05:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F1255207D4 for ; Thu, 14 May 2020 23:05:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729101AbgENXFR (ORCPT ); Thu, 14 May 2020 19:05:17 -0400 Received: from mail-bn8nam12olkn2054.outbound.protection.outlook.com ([40.92.21.54]:33120 "EHLO NAM12-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729089AbgENXFQ (ORCPT ); Thu, 14 May 2020 19:05:16 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Jo5KZty/6gstHOjihVNK848jIxJMpRRl3Ka/k4iX6SPIog1/Z/ZEWpNNq+RwsO7ISLtTaM4f7ENMJOa14TJLhrL7Dk1vBUJto0Uj57kcUz510nh6ysNboGIykeuAXYbwugnomgXya+r7tkPQDjHrLUUd7vBeLQmCWsedOo7deOxCjmpAU2N355hWgpU5Q93gh+ZyCV88P+SdGLdrWtpB6y16pBK5r6VCgXLBi6v88NmLmgDvZ61SLYHsDD8ZRYk+sG9P2KqBEuby1kBpHHcp2/YnPqdA1vHCKgFDD510L0wjXKYiuThac98nhDoEjf7hnsQLX3fnVGlC54+iZRPvCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0/ojXOnyhyTbuZiHTpPWJRaeNoPwnXBkbesBz+CUR+s=; b=aivYGt5FnOSnbbjYzSV3dag1LR4ViqfWh56OQ9I66pJi+VY4BFhWfnkRqRqus+YdO4MW4MeDXGRLF1TfOxdmeH4CzsvOKAIb72C7tEBl1bzLPNIBuZ+Jo5LmrLoSOz4ASowORAp7Q8dBh6nIJjHy9X7EJwvhjTmnm1NWwaAxG8VLMDYV22ut0ouYURi7uJvRTSqAXhguVNOb6xWIfqj6fIvq4ZVOCmZA7YXQgaWyjLnHIyKf376b2fuj1qP0StNQoTlZOIwL6jTPWdITQR5X2ahmxWjQSnZ8dwPIj7s6lKJyvZuHUdA0iIuIwq6pdPiZHkef5UYVY7loMVj6XpKmyw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=live.ca; dmarc=pass action=none header.from=live.ca; dkim=pass header.d=live.ca; arc=none Received: from MW2NAM12FT003.eop-nam12.prod.protection.outlook.com (2a01:111:e400:fc65::49) by MW2NAM12HT003.eop-nam12.prod.protection.outlook.com (2a01:111:e400:fc65::97) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.11; Thu, 14 May 2020 23:05:12 +0000 Received: from BN6PR04MB0660.namprd04.prod.outlook.com (2a01:111:e400:fc65::44) by MW2NAM12FT003.mail.protection.outlook.com (2a01:111:e400:fc65::70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.11 via Frontend Transport; Thu, 14 May 2020 23:05:12 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:46D2674C3E3ACD975D3F292E58B620A0DFF44ACFE61B0D6D3E7BFFFBB5F1250C; UpperCasedChecksum:CC5D7174DD7BE7353E7D8A0DFDD4DF185588120DBCAF1662CB3119E7018BCC9C; SizeAsReceived:7952; Count:50 Received: from BN6PR04MB0660.namprd04.prod.outlook.com ([fe80::ad10:4127:4bc8:76fc]) by BN6PR04MB0660.namprd04.prod.outlook.com ([fe80::ad10:4127:4bc8:76fc%6]) with mapi id 15.20.3000.022; Thu, 14 May 2020 23:05:12 +0000 From: Jonathan Bakker To: sre@kernel.org, krzk@kernel.org, jonghwa3.lee@samsung.com, tglx@linutronix.de, kstewart@linuxfoundation.org, baolin.wang7@gmail.com, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Krzysztof Kozlowski , Jonathan Bakker Subject: [PATCH 05/10] power: supply: charger-manager: Collect all power_supply_changed() calls Date: Thu, 14 May 2020 16:04:30 -0700 Message-ID: X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200514230435.11798-1-xc-racer2@live.ca> References: <20200514230435.11798-1-xc-racer2@live.ca> X-ClientProxiedBy: MWHPR22CA0040.namprd22.prod.outlook.com (2603:10b6:300:69::26) To BN6PR04MB0660.namprd04.prod.outlook.com (2603:10b6:404:d9::21) X-Microsoft-Original-Message-ID: <20200514230435.11798-6-xc-racer2@live.ca> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from jon-hp-6570b.telus (2001:569:fb68:9c00:8067:f823:1e15:7520) by MWHPR22CA0040.namprd22.prod.outlook.com (2603:10b6:300:69::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.26 via Frontend Transport; Thu, 14 May 2020 23:05:11 +0000 X-Mailer: git-send-email 2.20.1 X-Microsoft-Original-Message-ID: <20200514230435.11798-6-xc-racer2@live.ca> X-TMN: [a2GnsS8BAg4aEnisxadQPAzfNz981r4B+n1d7Cac3tGaRxO8nVYlJAX2Ymkl2WGn] X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 50 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: d7e296ba-7962-4981-9451-08d7f85b4188 X-MS-TrafficTypeDiagnostic: MW2NAM12HT003: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yA9ltyohT4tcbduNjZHwR0KrKwhx6KeUb1hbM28N7/I1KohAukyHmxXSmc+D99u6YS4Ar7WtkD0LJmv6zaXjSItai2gUjgKxNf4tF1Lb1HYqAwXpYb1Y3VMt5jfJJtpxL7UkI8lNcr+jF/mSMa0zMi8MNwnDeHeKjqCxKmznMoKQmT++flyITU5APhBtBgLdv3v/eKJOu+47SWxcITSh2Q== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:0; SRV:; IPV:NLI; SFV:NSPM; H:BN6PR04MB0660.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:; DIR:OUT; SFP:1901; X-MS-Exchange-AntiSpam-MessageData: KVTmawHR+GpGWX62638HNetTw/tjxWPAuiFavgD/1Sy3YVktgI3fivD7u4aQasC6vYPIcxJ0en33x2jpy+DIoeuQY6BE3ktfDmNBUvjSZKWN6jkBbMOpultHHDQZkSHudbpz9qd9gORqFVMJqYE6ZIJq5+UAQTgjT5hhTbKDflavXY8KlFMtpbOMqKv3dlTP8sRtEzeAJvE67tungfTtkg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: d7e296ba-7962-4981-9451-08d7f85b4188 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 May 2020 23:05:12.5035 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2NAM12HT003 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Jonghwa Lee Current charger-manager calls power_supply_changed() whenever charging status is changed. Remove the separated power_supply_changed() calls and let it be called at end of try_charger_enable() function which is called to set charging/discharging. Signed-off-by: Jonghwa Lee Signed-off-by: Krzysztof Kozlowski Signed-off-by: Jonathan Bakker --- drivers/power/supply/charger-manager.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/power/supply/charger-manager.c b/drivers/power/supply/charger-manager.c index 80d1699c938a..b2daab480eb3 100644 --- a/drivers/power/supply/charger-manager.c +++ b/drivers/power/supply/charger-manager.c @@ -406,8 +406,10 @@ static int try_charger_enable(struct charger_manager *cm, bool enable) } } - if (!err) + if (!err) { cm->charger_enabled = enable; + power_supply_changed(cm->charger_psy); + } return err; } @@ -460,10 +462,8 @@ static void fullbatt_vchk(struct charger_manager *cm) dev_info(cm->dev, "VBATT dropped %duV after full-batt\n", diff); - if (diff > desc->fullbatt_vchkdrop_uV) { + if (diff > desc->fullbatt_vchkdrop_uV) try_charger_restart(cm); - power_supply_changed(cm->charger_psy); - } } /** @@ -493,7 +493,6 @@ static int check_charging_duration(struct charger_manager *cm) if (duration > desc->charging_max_duration_ms) { dev_info(cm->dev, "Charging duration exceed %ums\n", desc->charging_max_duration_ms); - power_supply_changed(cm->charger_psy); try_charger_enable(cm, false); ret = true; } @@ -504,7 +503,6 @@ static int check_charging_duration(struct charger_manager *cm) is_ext_pwr_online(cm)) { dev_info(cm->dev, "Discharging duration exceed %ums\n", desc->discharging_max_duration_ms); - power_supply_changed(cm->charger_psy); try_charger_enable(cm, true); ret = true; } @@ -613,8 +611,7 @@ static bool _cm_monitor(struct charger_manager *cm) */ if (temp_alrt) { cm->emergency_stop = temp_alrt; - if (!try_charger_enable(cm, false)) - power_supply_changed(cm->charger_psy); + try_charger_enable(cm, false); /* * Check whole charging duration and discharging duration @@ -639,16 +636,13 @@ static bool _cm_monitor(struct charger_manager *cm) } else if (!cm->emergency_stop && is_full_charged(cm) && cm->charger_enabled) { dev_info(cm->dev, "EVENT_HANDLE: Battery Fully Charged\n"); - power_supply_changed(cm->charger_psy); - try_charger_enable(cm, false); fullbatt_vchk(cm); } else { cm->emergency_stop = 0; if (is_ext_pwr_online(cm)) { - if (!try_charger_enable(cm, true)) - power_supply_changed(cm->charger_psy); + try_charger_enable(cm, true); } } From patchwork Thu May 14 23:04:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Bakker X-Patchwork-Id: 212028 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C714C433E0 for ; Thu, 14 May 2020 23:05:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1DDA920758 for ; Thu, 14 May 2020 23:05:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729144AbgENXFV (ORCPT ); Thu, 14 May 2020 19:05:21 -0400 Received: from mail-mw2nam12olkn2048.outbound.protection.outlook.com ([40.92.23.48]:48353 "EHLO NAM12-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729089AbgENXFU (ORCPT ); Thu, 14 May 2020 19:05:20 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=juQ1uv2PQI4oVeb3gR7UDjtU+bFKGd3Q4nSeUchXdd0froQzwMQ12DpNcqXyI94btSbdTMgQiBYFdoyJT7cCGPM+R+m/EAR5copLBmWUniHTygj7wXpf7aQZLjDiJ/bJxtSIujSVUOsDhMMNQJ+lyD5bFbASa0q3vXHmgD4HxduIU3aFsJSmgxQVvxI8O6A+lCN0Fz5HmLQJNxh8HtL1CxCO3xw10+6Gi9UHIV966j2ooev64zgUCmYGOX6Wn5+ZtAPzFj6b0ErtdktJGmf7Pie959KOFYkRgT22WDFRZb34oSGq2bbi4dlCYGvVtuTStHEGMQQq9ZujPb7UQpta/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4Awkr2HpBhIcbXNIc+x+8pzhsNau8D04HOqebPXK4AQ=; b=B2nxgdU0PPYAcG8kxLNqWLcrCJWVLIKtCzpLp7//l3ynEGSvJ5y5XOYZkol5CjT2D/bWFmeuiPUnFANLIS+0vYcUteQGr0TxhBQjxJqtYDd62U+9gHUNiLhYNxSGTnYbOKr67OgGiQxAEXSU4yy1yfgfHmfPS6SFWUIA6NcA8Hx1/Lvng9G7cSN+CjnOqQ8NjWW0tIi+RBX+WUbVDXG4hrclQa+8Y8sJDpRIXuv7JCDBRQTbHRbim1RZA8Gu7D33xjDMOgXHux/XnMvTjxadUV9YQyTl3+/HF9+UIpadTEPhp5RYAnG7KlVcYTpWuanLIAG2YPvJSGQIl/99aoGLiQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=live.ca; dmarc=pass action=none header.from=live.ca; dkim=pass header.d=live.ca; arc=none Received: from MW2NAM12FT003.eop-nam12.prod.protection.outlook.com (2a01:111:e400:fc65::47) by MW2NAM12HT137.eop-nam12.prod.protection.outlook.com (2a01:111:e400:fc65::308) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.11; Thu, 14 May 2020 23:05:17 +0000 Received: from BN6PR04MB0660.namprd04.prod.outlook.com (2a01:111:e400:fc65::44) by MW2NAM12FT003.mail.protection.outlook.com (2a01:111:e400:fc65::70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.11 via Frontend Transport; Thu, 14 May 2020 23:05:17 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:DA49E0BF4D44EDE16ED6CB8CF973445A05031789189D1DC617FF0DF5C394CCD6; UpperCasedChecksum:DB43982AC0D3BA7F762B9A5240929384587D5BA91CA2D7E9E9DD9B8CAFB75C9E; SizeAsReceived:7846; Count:50 Received: from BN6PR04MB0660.namprd04.prod.outlook.com ([fe80::ad10:4127:4bc8:76fc]) by BN6PR04MB0660.namprd04.prod.outlook.com ([fe80::ad10:4127:4bc8:76fc%6]) with mapi id 15.20.3000.022; Thu, 14 May 2020 23:05:17 +0000 From: Jonathan Bakker To: sre@kernel.org, krzk@kernel.org, jonghwa3.lee@samsung.com, tglx@linutronix.de, kstewart@linuxfoundation.org, baolin.wang7@gmail.com, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jonathan Bakker Subject: [PATCH 08/10] power: supply: charger-manager: Update extcon functions Date: Thu, 14 May 2020 16:04:33 -0700 Message-ID: X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200514230435.11798-1-xc-racer2@live.ca> References: <20200514230435.11798-1-xc-racer2@live.ca> X-ClientProxiedBy: MWHPR22CA0040.namprd22.prod.outlook.com (2603:10b6:300:69::26) To BN6PR04MB0660.namprd04.prod.outlook.com (2603:10b6:404:d9::21) X-Microsoft-Original-Message-ID: <20200514230435.11798-9-xc-racer2@live.ca> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from jon-hp-6570b.telus (2001:569:fb68:9c00:8067:f823:1e15:7520) by MWHPR22CA0040.namprd22.prod.outlook.com (2603:10b6:300:69::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.26 via Frontend Transport; Thu, 14 May 2020 23:05:16 +0000 X-Mailer: git-send-email 2.20.1 X-Microsoft-Original-Message-ID: <20200514230435.11798-9-xc-racer2@live.ca> X-TMN: [AcyfIgyKaFETI0utMZ2iLLGcFuqS6vCeNAZkAEPkpunVOy+2tlxhWt5qcagr9rVu] X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 50 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 74d3d40f-9c30-47aa-3c8d-08d7f85b44a1 X-MS-TrafficTypeDiagnostic: MW2NAM12HT137: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: w8P9hABOmelYHAoQi/+SKxUr+eOeeG32b5Sf1M477CajGAlyId7HMW4X92xnaQfjSNw3wpPSSDBM/OHKECCtXPwJrUeKcphgrcy7p8e/YNYAldjsf7MkPiFjHkRWsCKxa8lWc2kLMrgXz/R/5PEf9X8i9HFgV1v+dq0TAeK0kxQGRx07NhWQtRmttZIwBdhsxkLtIuT2Uw2IAMvV/6aOew== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:0; SRV:; IPV:NLI; SFV:NSPM; H:BN6PR04MB0660.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:; DIR:OUT; SFP:1901; X-MS-Exchange-AntiSpam-MessageData: sE0ZLSkAGq6PQiYLwIrACHzwkDqTagDcnuYORuwftGmFopS9lBY8vJ9k3pB20PG0ay6zCxXox6LpqScYCsakYPg6rgl9vNEtrapxXUzq7myirmnVno+lSKKa/xBMB8/sE8QrrNzZlo4wh9MN9mIqJyblwGNDsJS8iD+9NU7OqywH0E8HGME7EOSwRk0YWlqEIAnixBixEswVYwJDJRYe4g== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 74d3d40f-9c30-47aa-3c8d-08d7f85b44a1 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 May 2020 23:05:17.7312 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2NAM12HT137 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org In commit 830ae442202e ("extcon: Remove the deprecated extcon functions") the function extcon_register_interest became a no-op returning an error, leading to non-functional behaviour in charger-manager. Additionally, a translation table is needed between the text representation of the extcon cable names and their IDs is needed. In order to retain DT compatibility, TA and CHARGE-DOWNSTREAM are added as they were present up until commit 11eecf910bd8 ("extcon: Modify the id and name of external connector") Signed-off-by: Jonathan Bakker --- drivers/power/supply/charger-manager.c | 82 +++++++++++++++++++------- include/linux/power/charger-manager.h | 5 +- 2 files changed, 63 insertions(+), 24 deletions(-) diff --git a/drivers/power/supply/charger-manager.c b/drivers/power/supply/charger-manager.c index 27064a46a365..4ad3dd754abf 100644 --- a/drivers/power/supply/charger-manager.c +++ b/drivers/power/supply/charger-manager.c @@ -26,6 +26,29 @@ #include #include +static struct { + const char *name; + u64 extcon_type; +} extcon_mapping[] = { + /* Current textual representations */ + { "USB", EXTCON_USB }, + { "USB-HOST", EXTCON_USB_HOST }, + { "SDP", EXTCON_CHG_USB_SDP }, + { "DCP", EXTCON_CHG_USB_DCP }, + { "CDP", EXTCON_CHG_USB_CDP }, + { "ACA", EXTCON_CHG_USB_ACA }, + { "FAST-CHARGER", EXTCON_CHG_USB_FAST }, + { "SLOW-CHARGER", EXTCON_CHG_USB_SLOW }, + { "WPT", EXTCON_CHG_WPT }, + { "PD", EXTCON_CHG_USB_PD }, + { "DOCK", EXTCON_DOCK }, + { "JIG", EXTCON_JIG }, + { "MECHANICAL", EXTCON_MECHANICAL }, + /* Deprecated textual representations */ + { "TA", EXTCON_CHG_USB_SDP }, + { "CHARGE-DOWNSTREAM", EXTCON_CHG_USB_CDP }, +}; + /* * Default temperature threshold for charging. * Every temperature units are in tenth of centigrade. @@ -950,7 +973,8 @@ static int charger_extcon_notifier(struct notifier_block *self, static int charger_extcon_init(struct charger_manager *cm, struct charger_cable *cable) { - int ret; + int ret, i; + u64 extcon_type = EXTCON_NONE; /* * Charger manager use Extcon framework to identify @@ -959,14 +983,39 @@ 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); + + cable->extcon_dev = extcon_get_extcon_dev(cable->extcon_name); + if (IS_ERR_OR_NULL(cable->extcon_dev)) { + pr_err("Cannot find extcon_dev for %s (cable: %s)\n", + cable->extcon_name, cable->name); + if (cable->extcon_dev == NULL) + return -EPROBE_DEFER; + else + return PTR_ERR(cable->extcon_dev); + } + + for (i = 0; i < ARRAY_SIZE(extcon_mapping); i++) { + if (!strcmp(cable->name, extcon_mapping[i].name)) { + extcon_type = extcon_mapping[i].extcon_type; + break; + } + } + if (extcon_type == EXTCON_NONE) { + pr_err("Cannot find cable for type %s", cable->name); + return -EINVAL; + } + + cable->extcon_type = extcon_type; + + ret = devm_extcon_register_notifier(cm->dev, cable->extcon_dev, + cable->extcon_type, &cable->nb); if (ret < 0) { - pr_info("Cannot register extcon_dev for %s(cable: %s)\n", + pr_err("Cannot register extcon_dev for %s (cable: %s)\n", cable->extcon_name, cable->name); + return ret; } - return ret; + return 0; } /** @@ -983,6 +1032,7 @@ static int charger_manager_register_extcon(struct charger_manager *cm) { struct charger_desc *desc = cm->desc; struct charger_regulator *charger; + unsigned long event; int ret; int i; int j; @@ -1010,6 +1060,11 @@ static int charger_manager_register_extcon(struct charger_manager *cm) } cable->charger = charger; cable->cm = cm; + + event = extcon_get_state(cable->extcon_dev, + cable->extcon_type); + charger_extcon_notifier(&cable->nb, + event, NULL); } } @@ -1370,7 +1425,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 = {}; @@ -1568,12 +1622,6 @@ static int charger_manager_probe(struct platform_device *pdev) 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); - } regulator_put(desc->charger_regulators[i].consumer); } @@ -1588,7 +1636,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); @@ -1598,15 +1645,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 c127dbe31e49..45e228b353ea 100644 --- a/include/linux/power/charger-manager.h +++ b/include/linux/power/charger-manager.h @@ -40,7 +40,7 @@ enum cm_batt_temp { /** * struct charger_cable * @extcon_name: the name of extcon device. - * @name: the name of charger cable(external connector). + * @name: the name of the cable connector * @extcon_dev: the extcon device. * @wq: the workqueue to control charger according to the state of * charger cable. If charger cable is attached, enable charger. @@ -56,9 +56,10 @@ enum cm_batt_temp { struct charger_cable { const char *extcon_name; const char *name; + struct extcon_dev *extcon_dev; + u64 extcon_type; /* The charger-manager use Extcon framework */ - struct extcon_specific_cable_nb extcon_dev; struct work_struct wq; struct notifier_block nb; From patchwork Thu May 14 23:04:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Bakker X-Patchwork-Id: 212029 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7CD50C433DF for ; Thu, 14 May 2020 23:05:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6102C204EA for ; Thu, 14 May 2020 23:05:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729194AbgENXF1 (ORCPT ); Thu, 14 May 2020 19:05:27 -0400 Received: from mail-dm6nam12olkn2018.outbound.protection.outlook.com ([40.92.22.18]:32128 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729145AbgENXFW (ORCPT ); Thu, 14 May 2020 19:05:22 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KMKeYpli/g4HaT9v/UVXn11AlAzmxZeapvStl6V8lOwxuHjenUeGtSWmPPoLBfA558hlqV3Wiak0rbEHpWHN2k0l6e+UY3AyRQv5e9V9xOy+aWNQknaWRt1KPbsQaIfxxtxE+WJD3qIOQxoBGnPTag78zabKedc/77G+FyTPKRhOJjZQvHU5gopNjEcAQvw1Ll0okpgTsuVtWx6bnUjnW5+/EzuN4zErN6rBv0V4HHTrx3Y0cmoHvGhsUdzqNRvJUbaFsOJJhKNO21JothfDLyzK8JiZyUxHz4uJbnbebcj3yk6nIDK7wyJ/m1gG030UwUOqM5iP09FiXDsaIW0I/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=frjjLVPAF4ZuhXoCL/krqbQKU4CEv1ZHlJsmkJDyOAk=; b=kKfzxz8P1rXJRos3keXShy/VxanDUR1UUvtwOTVP4Cn1rAr40BeHrdktfOVA4aLGBwEUBXF8nT+3PLClJ1ku0V2qYjdoKzpBPvH89qLkHl/p3IGUDPA2MAaslfsSDYsh487s1QM/xJo+8/GN7npBxMpNOr6iHM9dSTFncHdYqqVJ22w7azqA3uboKS4IIu6WvuW1e45V4Ja4DGiVrwPBNimlR9hByIy7N4PmgAPqa4peFYoyZ5ZQIBHp31JLC3hS2Cg8f0UfO/8k+B98D7iVdDlZYLeTSQmRcHV05/TX01e7OPmJaShyxBCKPDFwi3MbIPt3dkqPsp5aC2YBC0Wdgw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=live.ca; dmarc=pass action=none header.from=live.ca; dkim=pass header.d=live.ca; arc=none Received: from MW2NAM12FT003.eop-nam12.prod.protection.outlook.com (2a01:111:e400:fc65::41) by MW2NAM12HT132.eop-nam12.prod.protection.outlook.com (2a01:111:e400:fc65::484) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.11; Thu, 14 May 2020 23:05:19 +0000 Received: from BN6PR04MB0660.namprd04.prod.outlook.com (2a01:111:e400:fc65::44) by MW2NAM12FT003.mail.protection.outlook.com (2a01:111:e400:fc65::70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.11 via Frontend Transport; Thu, 14 May 2020 23:05:19 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:74862B13F85791B1DEA666493F20868B73C6CDBCF68E78AB8A00B9EAED5B6DC7; UpperCasedChecksum:00EE86BF9418EED3CF25276A5E25B1D90AA9C5C451A54C98D07631ABF8140D81; SizeAsReceived:7869; Count:50 Received: from BN6PR04MB0660.namprd04.prod.outlook.com ([fe80::ad10:4127:4bc8:76fc]) by BN6PR04MB0660.namprd04.prod.outlook.com ([fe80::ad10:4127:4bc8:76fc%6]) with mapi id 15.20.3000.022; Thu, 14 May 2020 23:05:19 +0000 From: Jonathan Bakker To: sre@kernel.org, krzk@kernel.org, jonghwa3.lee@samsung.com, tglx@linutronix.de, kstewart@linuxfoundation.org, baolin.wang7@gmail.com, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jonathan Bakker Subject: [PATCH 09/10] power: supply: charger-manager: Count cm-chargers property directly Date: Thu, 14 May 2020 16:04:34 -0700 Message-ID: X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200514230435.11798-1-xc-racer2@live.ca> References: <20200514230435.11798-1-xc-racer2@live.ca> X-ClientProxiedBy: MWHPR22CA0040.namprd22.prod.outlook.com (2603:10b6:300:69::26) To BN6PR04MB0660.namprd04.prod.outlook.com (2603:10b6:404:d9::21) X-Microsoft-Original-Message-ID: <20200514230435.11798-10-xc-racer2@live.ca> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from jon-hp-6570b.telus (2001:569:fb68:9c00:8067:f823:1e15:7520) by MWHPR22CA0040.namprd22.prod.outlook.com (2603:10b6:300:69::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.26 via Frontend Transport; Thu, 14 May 2020 23:05:17 +0000 X-Mailer: git-send-email 2.20.1 X-Microsoft-Original-Message-ID: <20200514230435.11798-10-xc-racer2@live.ca> X-TMN: [EpCpjepnmk2cjalAvX2YBosdIDPdzGZTlvQoEZxd5csTAj9x2S6pPEJtc8Ppjy9u] X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 50 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: ece23963-be24-4f3a-9782-08d7f85b45a5 X-MS-TrafficTypeDiagnostic: MW2NAM12HT132: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +LYQwITxRiGsdQAQeQwKhOVcATtt6FfqJhh95tPGiyKITaMFb04krSNQERKHKtLJ9PRXNui69KEd2Ftrhdc83bwP3FDQJyNhCHP3jkriAWGuUl3FQ2KT4s43alM5+WEqp8A49Zs/H3PndiNKd7ibqt7mGPkmjt8kja+RirliWXlrD+ItsbB7CAk0+rQ/IeN2GxLPTFmjFaSuzVOCqKKd3A== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:0; SRV:; IPV:NLI; SFV:NSPM; H:BN6PR04MB0660.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:; DIR:OUT; SFP:1901; X-MS-Exchange-AntiSpam-MessageData: ticopCGDOfT5aqgJnzaVJu9MdZIa1+ST7R79Red8Ufk/fzzemgWI246Gn9c2AARx6PNBhbGVyMcyU4NcuKMvaXrSts3CSq5jq8bOKNbml4qutB8Yb+Ay+4U5h/969HsWitg+l40zZ5Y9p426vlHTu77vPSrIxzPAqfasqlRZ1sMLTiajHfeZ63GAtDHemSrQYvhFan+m6HVCc5wBiTAVcg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: ece23963-be24-4f3a-9782-08d7f85b45a5 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 May 2020 23:05:19.6494 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2NAM12HT132 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Rather than having a cm-chargers and a separate cm-num-chargers property, simply count the entries in cm-chargers. Signed-off-by: Jonathan Bakker --- drivers/power/supply/charger-manager.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/power/supply/charger-manager.c b/drivers/power/supply/charger-manager.c index 4ad3dd754abf..f0ef8a10891c 100644 --- a/drivers/power/supply/charger-manager.c +++ b/drivers/power/supply/charger-manager.c @@ -1311,8 +1311,8 @@ static struct charger_desc *of_cm_parse_desc(struct device *dev) desc->battery_present = battery_stat; /* chargers */ - of_property_read_u32(np, "cm-num-chargers", &num_chgs); - if (num_chgs) { + num_chgs = of_property_count_strings(np, "cm-chargers"); + if (num_chgs > 0) { int i; /* Allocate empty bin at the tail of array */