From patchwork Tue May 22 15:16:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Thomson X-Patchwork-Id: 10418961 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D182E600CC for ; Tue, 22 May 2018 15:16:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BEC2028DE2 for ; Tue, 22 May 2018 15:16:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B275628DF4; Tue, 22 May 2018 15:16:50 +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=-5.4 required=2.0 tests=BAYES_00,FROM_WORDY, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable 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 7538228DE2 for ; Tue, 22 May 2018 15:16:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751701AbeEVPQf (ORCPT ); Tue, 22 May 2018 11:16:35 -0400 Received: from mail1.bemta26.messagelabs.com ([85.158.142.115]:52894 "EHLO mail1.bemta26.messagelabs.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751412AbeEVPQ0 (ORCPT ); Tue, 22 May 2018 11:16:26 -0400 Received: from [85.158.142.201] (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256 bits)) by server-4.bemta.az-b.eu-central-1.aws.symcld.net id 9E/D6-16868-844340B5; Tue, 22 May 2018 15:16:24 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrKIsWRWlGSWpSXmKPExsUSt3Opsa6HCUu 0weddghbNi9ezWXSt3slicXnXHDaLz71HGC0WLWtltniy8AyTxendJQ7sHptWdbJ5zDsZ6LF/ 7hp2j53fG9g9Pm+SC2CNYs3MS8qvSGDNOLPiOnNBs0DFkQuLWRsYn/N2MXJxCAmsZ5TY+/sJe xcjJ5BTIfH983ZWEJtXIFPi4fRHTCA2p4C7xMUF5xkhatwkdq3fABZnE7CQmHziARuIzSKgKj HxKUSvsECoROf/XWC2iMAGRontK0JBbGaBOone329ZIOYLSpyc+YQFIi4hcfDFC2aI+QYSpxc 0gsUlBOwlpr+/ChTnALL1JRqPxUKEDSW+z/oGVWIu0bR1JuMERsFZSKbOQjJ1ASPTKkbLpKLM 9IyS3MTMHF1DAwNdQ0NjXRNdIwNTvcQq3SS91FLd5NS8kqJEoKxeYnmxXnFlbnJOil5easkmR mB0MADBDsanx5IPMUpyMCmJ8oY9ZY4W4kvKT6nMSCzOiC8qzUktPsQow8GhJMH76A1QTrAoNT 21Ii0zBxinMGkJDh4lEV6Gt0Bp3uKCxNzizHSI1ClGRSlxXiWQhABIIqM0D64NlhouMcpKCfM yAh0ixFOQWpSbWYIq/4pRnINRSZg3AWQKT2ZeCdz0V0CLmYAWX1wOtrgkESEl1cC49ti7y2EH VysFTty94wn7zJC/+hX6e2LmPrv78GVZaDej3RyrmKdP4iZkss6fu8mjpprr2PTi038izsiod e1z5/ZW0zq5ua/px4FaF9XNMbmHV0c1tGzfYpO2+/d/8+1Nb9793yh9fFluZsgKXynPY59jn5 xX354S/pNtWrijtoxI01a/FuvtSizFGYmGWsxFxYkAN1tY7wgDAAA= X-Env-Sender: Adam.Thomson.Opensource@diasemi.com X-Msg-Ref: server-6.tower-246.messagelabs.com!1527002184!1043199!1 X-Originating-IP: [94.185.165.51] X-SYMC-ESS-Client-Auth: outbound-route-from=pass X-StarScan-Received: X-StarScan-Version: 9.9.15; banners=-,-,- X-VirusChecked: Checked Received: (qmail 29013 invoked from network); 22 May 2018 15:16:24 -0000 Received: from mailrelay2.diasemi.com (HELO sw-ex-cashub01.diasemi.com) (94.185.165.51) by server-6.tower-246.messagelabs.com with AES128-SHA encrypted SMTP; 22 May 2018 15:16:24 -0000 Received: from swsrvapps-01.diasemi.com (10.20.28.141) by SW-EX-CASHUB01.diasemi.com (10.20.16.140) with Microsoft SMTP Server id 14.3.382.0; Tue, 22 May 2018 16:16:23 +0100 Received: by swsrvapps-01.diasemi.com (Postfix, from userid 22379) id B05953FB77; Tue, 22 May 2018 16:16:23 +0100 (BST) Message-ID: In-Reply-To: References: From: Adam Thomson Date: Tue, 22 May 2018 16:16:23 +0100 Subject: [PATCH 1/2] power: supply: Add fwnode pointer to power_supply_config struct To: Heikki Krogerus , Guenter Roeck , Greg Kroah-Hartman , Sebastian Reichel CC: , , , MIME-Version: 1.0 X-KSE-AttachmentFiltering-Interceptor-Info: protection disabled X-KSE-ServerInfo: sw-ex-cashub01.diasemi.com, 9 X-KSE-Antivirus-Interceptor-Info: scan successful X-KSE-Antivirus-Info: Clean, bases: 22/05/2018 13:35:00 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP To allow users of the power supply framework to be hw description agnostic, this commit adds the ability to pass a fwnode pointer, via the power_supply_config structure, to the initialisation code of the core, instead of explicitly specifying of_ndoe. If that fwnode pointer is provided then it will automatically resolve down to of_node on platforms which support it, otherwise it will be NULL. In the future, when ACPI support is added, this can be modified to accommodate ACPI without the need to change calling code which already provides the fwnode handle in this manner. Signed-off-by: Adam Thomson Suggested-by: Heikki Krogerus Reviewed-by: Sebastian Reichel Reviewed-by: Heikki Krogerus --- drivers/power/supply/power_supply_core.c | 4 +++- include/linux/power_supply.h | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c index ecd68c2..f57ab0a 100644 --- a/drivers/power/supply/power_supply_core.c +++ b/drivers/power/supply/power_supply_core.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include "power_supply.h" @@ -874,7 +875,8 @@ static void psy_unregister_cooler(struct power_supply *psy) psy->desc = desc; if (cfg) { psy->drv_data = cfg->drv_data; - psy->of_node = cfg->of_node; + psy->of_node = + cfg->fwnode ? to_of_node(cfg->fwnode) : cfg->of_node; psy->supplied_to = cfg->supplied_to; psy->num_supplicants = cfg->num_supplicants; } diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index 0c9a572..b21c4bd9 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -199,6 +199,8 @@ enum power_supply_notifier_events { /* Run-time specific power supply configuration */ struct power_supply_config { struct device_node *of_node; + struct fwnode_handle *fwnode; + /* Driver private data */ void *drv_data;