Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S968253AbdIZIo0 (ORCPT ); Tue, 26 Sep 2017 04:44:26 -0400 Received: from mail-sn1nam02on0054.outbound.protection.outlook.com ([104.47.36.54]:31835 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933842AbdIZIoO (ORCPT ); Tue, 26 Sep 2017 04:44:14 -0400 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; arm.linux.org.uk; dkim=none (message not signed) header.d=none;arm.linux.org.uk; dmarc=fail action=none header.from=nxp.com; From: Dong Aisheng To: CC: , , , , , , , Dong Aisheng , Russell King Subject: [PATCH V4 1/1] clk: bulk: add of_clk_bulk_get() Date: Tue, 26 Sep 2017 16:44:01 +0800 Message-ID: <1506415441-4435-1-git-send-email-aisheng.dong@nxp.com> X-Mailer: git-send-email 2.7.4 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131508890518290615;(91ab9b29-cfa4-454e-5278-08d120cd25b8);() X-Forefront-Antispam-Report: CIP:192.88.168.50;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(979002)(6009001)(7966004)(336005)(346002)(376002)(39860400002)(39380400002)(2980300002)(1110001)(1109001)(339900001)(189002)(199003)(47776003)(81166006)(356003)(498600001)(50226002)(48376002)(5660300001)(7416002)(86362001)(50466002)(6666003)(68736007)(104016004)(77096006)(54906003)(8676002)(316002)(81156014)(85426001)(16586007)(305945005)(53936002)(33646002)(8936002)(50986999)(106466001)(105606002)(2351001)(8656003)(4326008)(97736004)(6916009)(189998001)(5003940100001)(36756003)(2906002)(969003)(989001)(999001)(1009001)(1019001);DIR:OUT;SFP:1101;SCL:1;SRVR:SN2PR03MB2367;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BL2FFO11FD006;1:bOSmc+Oy3JBMqULkuVWxVguVzDHeTM0LIy2ppRorFRv7ck+BR3HvRF807AtNOJFp6Xit0VGbC8iJvX0QXVUenznUEaQUMPq0VvSk2Ty8nPfSzX/6KOXTe2lRI0aVkjaf MIME-Version: 1.0 Content-Type: text/plain X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 900015a3-7e85-4b59-9f56-08d504bac29a X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(2017052603199)(201703131430075)(201703131517081);SRVR:SN2PR03MB2367; X-Microsoft-Exchange-Diagnostics: 1;SN2PR03MB2367;3:wpb7aPhT+7soHomw/U0SwPQKlAC8ByXJb2Q5TRHw9EYfK0/CXUJkpvvvKy96oYAcsZdiLoVWw1TGpUlxnP5alJnYgNstILCpgk/9oupFK3Tpb9jli2qslJeKUfGpSEhpibLX3D/M+1cz72unOPsjk/GHuxK/5M9qUvyTlTgfExiMJNU1o0hCOSS/zA8yuX5bc+53W6dBXXFr4R9ApSjtWEv145yj9px7UHVi5k6M5YVNYbmZDcg/KVIZQuJpHQpWb/3ROnVe6tf5+n5+jf+xuaJds3baSufSzFoxluLm2EsXEnm3emAUz4viX2nmpmRo7B4Ba8Pkz45sHmfRuSX1HSWLPUo+1G7dS8sVtNqzW/4=;25:Z0q8K9PLr9lrZqO/7f+doJEnfHtfuxBDZBocH6QzA9+4MoSbbYiUDH2KuiySc0yBTyhmMNVsZ/DiNqcUo/h06UCarmJBCIYP7kvxKEU063G+l2MG0V2M19RDUm8UiWp4rNdQZnDS6LJheLB4je93qJTNABAm9EANQcuNmjUCEaC5uV+vK5y5tkhTcqqNxwHXXhqpOEeKtvkMvopV9rRHrzIdj+tsL001Kerv8i6vwlP5u0ktXPQs+28wwU1CLlDCdSBBTCiiokY1gR4hqeZdK6whFTCmZnKMzGOwKsf0pQkBkuXLs9h5BERTv+1WQ6qb3Ifhd/aJIqx/c7t15abudA== X-MS-TrafficTypeDiagnostic: SN2PR03MB2367: X-Microsoft-Exchange-Diagnostics: 1;SN2PR03MB2367;31:pKUzGLhOVaVPrXCnbyXqGYpUT4+01dF5Ss0JlFANCjdsqDZk2HXaDRpDIDi0bpkJLFEDWXyvOsSHkeh48Bk4GqCyxZ4qr1M0wFilXFVpOHF8VoKsM92kvPGLxvpklqxqSTyMb3TPxlS4JMUK3as5dpo8bNcvarSmzmKUek9d+M3v9olDBpYdJsL9Ju2ojVN7aCogm/KUsxLo0Y7TFH3SiU+dd6WDMblZ69D0HCZ4Q/M=;4:cRgfb5IhU45QZR7Q8SIv5lsKgO9BLqB2Q3nmPjhCfTq40vzapEBXl1Ed7J/rMI44GDAI6aWDTpHSbWH678t2mx2L3/J8bAr77GCT93CCr1gKPDAyZ16yku7JFdlGbs3yGM/UpHydVjlr7UzD8hz6WNQqfIUqzwkllncOINSVtF+j1juB031Q+NsDIy8cGSvrdL0Of3LNgIONq+GmOqXXs4whL+5M+pg8UxdPloDdKhBMEtU8G4khb4ZeX78nZbwxh8inhTgKZLI4n4u1LUcwVIRk1s9KgVzzOrd7rk4MEUw= X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6095135)(2401047)(5005006)(8121501046)(3002001)(93006095)(93001095)(100000703101)(100105400095)(10201501046)(6055026)(6096035)(20161123561025)(20161123559100)(20161123565025)(201703131430075)(201703131433075)(201703131441075)(201703131448075)(201703161259150)(20161123563025)(20161123556025)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:SN2PR03MB2367;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(400006)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:SN2PR03MB2367; X-Forefront-PRVS: 0442E569BC X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;SN2P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4Hr0lGZI9rYuGoL6h/oxsxsmrqOl5BzWbyx6nJBLxl+Yc00itKIefip+ybPg=;7:UTN94zqAMhmgBcNRndoHTrsXyMdhDDUEIllk54JEbsrHw+AYmEKgfK0g9NN4lS0tIs+KMTFZcqy2PiU/5Xj2wcPyUdfAsT18QQCv//kfIgis3HGTNJLaxENtu/gOMZR5/GuMvHNrhxB9JN2Fwp2DqUjE8bRVwgh+wAd2uFvtaPr1xvT0/Y48eGmHhHV4oR+U+w7vQsr5Rf23j2FBDxdf2uHDY1T9Pt+2FZWUGEFOJeM= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2017 08:44:11.6574 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e;Ip=[192.88.168.50];Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN2PR03MB2367 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2448 Lines: 90 'clock-names' property is optinal in DT, so of_clk_bulk_get() is introduced here to handle this for DT users without 'clock-names' specified. Cc: Stephen Boyd Cc: Michael Turquette Cc: Russell King Reported-by: Shawn Guo Signed-off-by: Dong Aisheng --- Changes since v3: * fix build warning on the SH platform Changes since v2: * of_clk_bulk_get should return -ENOENT; Changes since v1: * using %pOF instead of full_name --- drivers/clk/clk-bulk.c | 31 +++++++++++++++++++++++++++++++ include/linux/clk.h | 8 ++++++++ 2 files changed, 39 insertions(+) diff --git a/drivers/clk/clk-bulk.c b/drivers/clk/clk-bulk.c index c834f5a..896aa3b 100644 --- a/drivers/clk/clk-bulk.c +++ b/drivers/clk/clk-bulk.c @@ -19,6 +19,37 @@ #include #include #include +#include + +#if defined(CONFIG_OF) && defined(CONFIG_COMMON_CLK) +int __must_check of_clk_bulk_get(struct device_node *np, int num_clks, + struct clk_bulk_data *clks) +{ + int ret; + int i; + + for (i = 0; i < num_clks; i++) + clks[i].clk = NULL; + + for (i = 0; i < num_clks; i++) { + clks[i].clk = of_clk_get(np, i); + if (IS_ERR(clks[i].clk)) { + ret = PTR_ERR(clks[i].clk); + pr_err("%pOF: Failed to get clk index: %d ret: %d\n", + np, i, ret); + clks[i].clk = NULL; + goto err; + } + } + + return 0; + +err: + clk_bulk_put(i, clks); + + return ret; +} +#endif void clk_bulk_put(int num_clks, struct clk_bulk_data *clks) { diff --git a/include/linux/clk.h b/include/linux/clk.h index 12c96d9..073cb3b 100644 --- a/include/linux/clk.h +++ b/include/linux/clk.h @@ -680,10 +680,18 @@ static inline void clk_bulk_disable_unprepare(int num_clks, } #if defined(CONFIG_OF) && defined(CONFIG_COMMON_CLK) +int __must_check of_clk_bulk_get(struct device_node *np, int num_clks, + struct clk_bulk_data *clks); struct clk *of_clk_get(struct device_node *np, int index); struct clk *of_clk_get_by_name(struct device_node *np, const char *name); struct clk *of_clk_get_from_provider(struct of_phandle_args *clkspec); #else +static inline int of_clk_bulk_get(struct device_node *np, int num_clks, + struct clk_bulk_data *clks) +{ + return -ENOENT; +} + static inline struct clk *of_clk_get(struct device_node *np, int index) { return ERR_PTR(-ENOENT); -- 2.7.4