From patchwork Mon Sep 11 07:36:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aisheng Dong X-Patchwork-Id: 9946739 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 BB0726035D for ; Mon, 11 Sep 2017 07:40:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AD5F928B3B for ; Mon, 11 Sep 2017 07:40:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A132B28B42; Mon, 11 Sep 2017 07:40:56 +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 DAE3828B3B for ; Mon, 11 Sep 2017 07:40:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750986AbdIKHkz (ORCPT ); Mon, 11 Sep 2017 03:40:55 -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 Received: from MWHPR03CA0052.namprd03.prod.outlook.com (10.174.173.169) by DM5PR03MB3322.namprd03.prod.outlook.com (10.174.241.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.35.12; Mon, 11 Sep 2017 07:40:52 +0000 Received: from BN1BFFO11FD019.protection.gbl (2a01:111:f400:7c10::1:123) by MWHPR03CA0052.outlook.office365.com (2603:10b6:301:3b::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.35.12 via Frontend Transport; Mon, 11 Sep 2017 07:40:52 +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 BN1BFFO11FD019.mail.protection.outlook.com (10.58.144.82) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.13.11 via Frontend Transport; Mon, 11 Sep 2017 07:40:51 +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 v8B7eko9003466; Mon, 11 Sep 2017 00:40:47 -0700 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 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/1iSF7darQCdnPBuniT32l61Z+SUkWEe9t6tjug?= =?us-ascii?Q?kAHAvHIzlurfoRiyBduk8jLs/sobn9TkUI58173UtkYoIp6ZR1HHuHRxuhdz?= =?us-ascii?Q?eZUKfgsSNP8hE2Zm9yXJH5k9hh6odyP/9+QeT+xNnJufMn6b1RfqOYQyVnQo?= =?us-ascii?Q?TeoT20VxSjkdM6nHhf88e6jmwQVCRlXCElDE1kt5GkgvIxX6oEbo40QYNm17?= =?us-ascii?Q?VZ66cdO6IbTwcdh8QTTjyFbAk8z?= X-Microsoft-Exchange-Diagnostics: 1; DM5PR03MB3322; 6:um+1k60vuBbd8Ztl4fZuXn4ZivZhJ1mstQSdnAqECgOiuDHGPgldWvgSuvnk1U8KhG00az/8QuO4hETf1hR8BrgF9cYYqgAXpWRjghuF3H/Fi4nYmD0At1MlfafQPcvz3LTABj4w0/dCRv+nq6gqFmE6qW1IErtE7v754qqd2b0wCD/q1hJy0C6/tqYfSo/xiZppZenHFcmzGBzZGzvNGoODiNHJxxb3//SftozmOMFp607iDy+Fyc+1ZB/+bAzppPoMCZZMmQdq0JNZvo/bU6yH7SHyfCkucm4PmGAiAij0fWOUtTvzzOcm2NhlOrHwIQtY1owFq5MFf5Prq6Fyzw==; 5:LC9nmYYtsO2uYXFmxHbiCbuxmTMs2q6g879xLDwkHooCrQJQkJT2QGQLM/HwuANzhIHC5VFlme1Kdfro6JhvsFIn+7cGD3tuME723nYKprXLCyrGt2X7CwSXzxNfPMakWvjio8m07tL+zKqTYyACgQ==; 24:T/unzuT2zc9av0rzP7JabJDnAkc8aNc1ycUYjcAdIp97lvIZPOVrI9r8mFaLWisnHOomfMDuzH75AUq0Iw8fqDQ1QXuesPEreezlN0FF1+o=; 7:ChjJibgmx5jeRC64n7fQFVpuHycwFrcEJcZBiPF9lCg+iLW9nPTkUgMSpptFRQrD/2zQXS8XQ6Lmg/rOml/ol1jkXU0AtEUsJO0Y0ZHhAbqxDEbk0OtxFD91p0g1e2GCegoo3yiZrbmFTdvRHl5L1kXgVEZfnR4R7zPBp987VLcZ2q+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-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 --- 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);