Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751052AbdIKHk4 (ORCPT ); Mon, 11 Sep 2017 03:40:56 -0400 Received: from mail-bl2nam02on0060.outbound.protection.outlook.com ([104.47.38.60]:43424 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750922AbdIKHky (ORCPT ); Mon, 11 Sep 2017 03:40:54 -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 1/1] clk: bulk: add of_clk_bulk_get() Date: Mon, 11 Sep 2017 15:36:53 +0800 Message-ID: <1505115413-25483-1-git-send-email-aisheng.dong@nxp.com> X-Mailer: git-send-email 2.7.4 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131495892512123135;(91ab9b29-cfa4-454e-5278-08d120cd25b8);() X-Forefront-Antispam-Report: CIP:192.88.168.50;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(336005)(39860400002)(39380400002)(2980300002)(1110001)(1109001)(339900001)(199003)(189002)(97736004)(50466002)(104016004)(305945005)(47776003)(36756003)(2351001)(106466001)(105606002)(48376002)(498600001)(189998001)(2906002)(50226002)(85426001)(6916009)(77096006)(5660300001)(110136004)(50986999)(68736007)(86362001)(6666003)(4326008)(5003940100001)(8656003)(33646002)(356003)(8676002)(53936002)(81166006)(81156014)(54906002)(8936002);DIR:OUT;SFP:1101;SCL:1;SRVR:DM5PR03MB3322;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BN1BFFO11FD019;1:w+o3dVNJerhf47mEDbmdoldLgTvQrQAzx/jF3eD8KLXN5G2lBiXGHflDvYfkcWRiHw2I25lY58Zk/F9q5JnCGcobcq7E4/dUAVyagfZX+knlx4kft/vaGm/DOu/7hXRw MIME-Version: 1.0 Content-Type: text/plain X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6d5ac70d-811c-4fbc-e641-08d4f8e86d0d X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(300000503095)(300135400095)(2017052603199)(201703131430075)(201703131517081)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:DM5PR03MB3322; X-Microsoft-Exchange-Diagnostics: 1;DM5PR03MB3322;3:qXmzTUE/JJXA7YkeQC21gCmfk603M832wjyFCYoBnsPf6UMbQiAIUoX9+umK3kpCjFTRTdrr3kVZNUQxi3nNdXB4u9VM6N+VZmwu/Fzz9keMQDVMljN3JOOgw+asquDn5iCOW3KU7ZmKsQIWlqd38kbGAL3V54hh4gorUIFn+bXrAiSvcXK0zeamhOu47e+OnB/ZdQ+0lbJlLeYz1a+Hl5NleKjCmpra4OJwzwW4TphfO3nlhSwq1eIvMZL1T1oWzss8pa+9myfcoBVGyg+iRdrNE192RtuW5SRtkXMusXLPT0MUJj4cMx+rYIt1zkYexQjRri6FuInuAGzpTAdPonZEa3wKpVTUKaD7O8oo3Gw=;25:mzYPhc8yFim0IIQHmyEyvb6Js1BabEB3aytwF9/hQ3eSh1INAYfwnnGkvdGWpDGIreZvEdm+3bzDNYIOy3I7OvXYYMKiQ1MWhHFNBWzaMuYtHxtCJ5z5oNW3cubTLyTDPIWXiODPN9z/3iElpZxbqBSZyGG7MsWOdUNjVaBiQLt8dXWLMw/1Gv5C2cdQ97H+cX526thU7BYItwYSgkWbIgYCr6VHsp1HsdA6BTjrF9v37/9I0DrQT76Fsxj2ZgcJQCkbVTxEU7r/cqOh9HcyBGkcp7UmXSk41SuyZpk+Wi73+VC147YbyETolPpK1o/4lE+BBvkG985HACHuHxo/rg== X-MS-TrafficTypeDiagnostic: DM5PR03MB3322: X-Microsoft-Exchange-Diagnostics: 1;DM5PR03MB3322;31:cphgsh7ByHuFjPMjRz4eB97QA8mW0wypgBDIZLfqW9ffhYBzBSEf7szYTNDERuhsCHuXdSNi3s8MeNTm3zK+ZFifL5fK/AyqcYnBXOyzzgyPOE2e3K+QuUXODAYuFlJ8tqDZU1tlIc+klJOTRvGwcFEw+3Hum00cQHj8WUoFgfM5KCvIRnqFUNULH3hWlbEIV3gJmqzxrC1a0aHp/P5YW9ncAm7SKbs6TY/9dNO1/mg=;4:usKzy6X77f8pYIhuTskpzQfCWkU29nldcufyKGMsKcbF7awaODDma5w2MadQ5/NHwteXGP+dV1M2nks3jIsP0znwn0pnOi/YR+kyAjH6fpMJv5i5psk7NGa69kn8nO6218SbbIrTAoJV/6EQdrfDqDMmMG/tBO6SoMBzFAnUDiTQ5bMVFfOCuRqrHTudUEaRZ6pkGtPfiTyaXNLjdgxPYYgGogdgorhYQsJXgEcMjcpkVi44KhHmZd0xoX6jmwRRscBusVZwkKIIzBIHnYgQD4mkM4RKT676taq238lYJ0M= 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)(20161123563025)(201703131430075)(201703131433075)(201703131448075)(201703161259150)(201703151042153)(20161123556025)(20161123565025)(20161123559100)(20161123561025)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:DM5PR03MB3322;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(400006)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:DM5PR03MB3322; X-Forefront-PRVS: 04270EF89C X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;DM5PR03MB3322;23:XEEoVtUkl0iHf637YMuwkAEKZOdxOSBHetcBGcw3M?= =?us-ascii?Q?u73AwCb4wfbKzZtBsJB2ALyEniX6d20ea4ES/dl2/PWNvt+rBWMgf2lnPZII?= =?us-ascii?Q?ZW3rlx84/8eHIFStRGo+TjyhTZCiLd9zkRByGckCc1DYq17UdcLLT0GsV9HY?= =?us-ascii?Q?gpaElTm5KEpTghPoZbpbA5fWU/UFRCtNOj9tSn8JBuxu3UARdZO48R2XviA8?= =?us-ascii?Q?1AlaNP7Gp2296gicKTizqPerhh/JNXj9X9hAXCr6NjXz42FH0p2iSiSZCsB/?= =?us-ascii?Q?URNo7+c5wSoSC4eO7X3KmInJntx9TECCGMnp3b5AWZMtfh2kF/Z32+BYMQJZ?= =?us-ascii?Q?xLp9K2H45WoSdwbxDLQ2aP5UOkUk5ScFFfpRO+k6GvSmvTJdzk8e9X9p9fda?= =?us-ascii?Q?pUQQVIE7ewk3p1eU3eTngXdnQjVuj3CF0lPFIfQmWIpeteYloZRL21hmsJyo?= =?us-ascii?Q?W8CiGjk8LuRnAdP+VMQ37hlNNIbNPfmqlXDFSVby/l/csDoppUdnJv/LFE+5?= =?us-ascii?Q?BC0stj08mPVRx6EOHRp3nLOhy81rShLjMnYuHVDWVmn3wLTiOy7Ijw85wxGY?= =?us-ascii?Q?bL/wTxPyWyb5Snq02Izz49eYhIVxVRLKXDqJT9dA9CqWYQlwYNaAmcsaNvkq?= =?us-ascii?Q?iV2feRAABCrpItn0I0/NOKSvbxJkfEwNOD7Ydg/sM99dKVBukzOUgorzx34P?= =?us-ascii?Q?8g7JX/xixVk91ZXKCBNC14fz3XdoT7Tb3P3XOJULTw85/4haJsAzKB8LbvAl?= =?us-ascii?Q?IzXskwgFOImGU42MT2VX/xTUAETla48gbPjQDY03xoB2sie7Vl88V5SUFgNQ?= =?us-ascii?Q?z5blUOcv3Wj/tWO7/n0KY/1iSF7darQCdnPBuniT32l61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nR4R7zPBp987VLcZ2q+wGxvfW5V7lt2mzXkkEPUmpXlO91ljZ3HdGEiWHgfOJ+qbObg7GaKDlduexh4= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Sep 2017 07:40:51.0095 (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: DM5PR03MB3322 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2279 Lines: 80 '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 --- 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..3179f28 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("%s: Failed to get clk index: %d ret: %d\n", + np->full_name, 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 91bd464..c5281b3 100644 --- a/include/linux/clk.h +++ b/include/linux/clk.h @@ -658,10 +658,18 @@ static inline void clk_disable_unprepare(struct clk *clk) } #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 int of_clk_bulk_get(struct device_node *np, int num_clks, + struct clk_bulk_data *clks) +{ + return ERR_PTR(-ENOENT); +} + static inline struct clk *of_clk_get(struct device_node *np, int index) { return ERR_PTR(-ENOENT); -- 2.7.4