From patchwork Tue Sep 26 08:44:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aisheng Dong X-Patchwork-Id: 9971527 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 9588D6037F for ; Tue, 26 Sep 2017 08:44:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7EC2228684 for ; Tue, 26 Sep 2017 08:44:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 734C9289BC; Tue, 26 Sep 2017 08:44:27 +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=-6.9 required=2.0 tests=BAYES_00,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 A799A28684 for ; Tue, 26 Sep 2017 08:44:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936532AbdIZIoZ (ORCPT ); Tue, 26 Sep 2017 04:44:25 -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 Received: from DM5PR03CA0060.namprd03.prod.outlook.com (2603:10b6:4:3b::49) by SN2PR03MB2367.namprd03.prod.outlook.com (2603:10b6:804:e::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.77.7; Tue, 26 Sep 2017 08:44:12 +0000 Received: from BL2FFO11FD006.protection.gbl (2a01:111:f400:7c09::155) by DM5PR03CA0060.outlook.office365.com (2603:10b6:4:3b::49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.56.11 via Frontend Transport; Tue, 26 Sep 2017 08:44:12 +0000 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; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BL2FFO11FD006.mail.protection.outlook.com (10.173.161.2) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.56.11 via Frontend Transport; Tue, 26 Sep 2017 08:44:11 +0000 Received: from b29396-OptiPlex-7040.ap.freescale.net (b29396-OptiPlex-7040.ap.freescale.net [10.192.242.1]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id v8Q8i6JJ021727; Tue, 26 Sep 2017 01:44:07 -0700 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 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; SN2PR03MB2367; 23:1E+yNCfUgnj3/t1ll7ygj4DItzRxytywZNPp+v84H?= =?us-ascii?Q?5bMngp5oXn0VwWcvBVpl466auDLwPhxKbu1FfCLrpuSiqtrcQc8U0PXZqhf/?= =?us-ascii?Q?qiXN8C94bztgYyDju4JCwnP2Fk/JZU13HY8XhcpAcAZEqNT3xymZw2WeMgT7?= =?us-ascii?Q?WOJJLICn3r2N3CItV95NOimaqgfrPCi07T10vGF4/TpN/TcoS2OmWSYu4eSt?= =?us-ascii?Q?GIpvcJaUkZ2G92+39f1WkYZ5Zy1YAI/khFdEdV9mdOXk4rdvCqRZDrtXC1Zn?= =?us-ascii?Q?sXzGISCUvbIDhELSc+TkGe/hR5cBjJ4lgcg4FYUgOCm4AvtP0wm2EUrneh+3?= =?us-ascii?Q?tJ002ZNVE6nHRoUsQ/9wwva3Q+Ro+Z9cyCTrMbmL9p0f6IuQLluYk62vEK8/?= =?us-ascii?Q?jWo6zwK9GMdEAZTClc5/xev8bhCC+XvnR1aZooLmqFrrU3tZcOZIAQHkXj5E?= =?us-ascii?Q?u8tl4EO1RfZ9qHNFkfZIbXhNhacTaPqoIe/GIwtT1kwl2g4WlijZ+/StJT+V?= =?us-ascii?Q?n+ZKE53TbVMuPcmrjtud2mzKPc+GoqTXBuJgBDVpWrvbONA40yOXJwkp9zBl?= =?us-ascii?Q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F7A8IlFY+2bGd0Pj/JK3yhx3A2z7qRr8IponlPkXNjowqjjWdWj58gIh5YMK4/vjdGEhup3iVbQ4IH1IEPXClxZY+p7LeTTit39wLWmZcydPF1dAT2GwYEuOzIJ2soOUuFV21RinHg==; 5:FvFqrPGG3Yr6Pkgk+KaHe8FHnRNB8LOIvlS7DtxUIHMkvbZ6EEY6JSUUsAVDAfnMHaRfCbMX++JSa9raTfkOKXBtetePTsTNaLm6odvY+N7gMjQzNeG9e+jGBgfkr3/eGH5AYLVgz682YXhEO0Ba3Q==; 24:G8Jvd+05fGAS72wpcB5EVKkmiC1qO6gPuJM62nWGZjbDh0Y4Hr0lGZI9rYuGoL6h/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-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP '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);