From patchwork Wed Sep 20 07:49:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aisheng Dong X-Patchwork-Id: 9961051 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 E0631601D5 for ; Wed, 20 Sep 2017 07:49:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D23C028E67 for ; Wed, 20 Sep 2017 07:49:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C6CC028FE2; Wed, 20 Sep 2017 07:49: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 2F19028E67 for ; Wed, 20 Sep 2017 07:49:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751797AbdITHt0 (ORCPT ); Wed, 20 Sep 2017 03:49:26 -0400 Received: from mail-bn3nam01on0076.outbound.protection.outlook.com ([104.47.33.76]:20160 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751578AbdITHtZ (ORCPT ); Wed, 20 Sep 2017 03:49:25 -0400 Received: from CY1PR03CA0031.namprd03.prod.outlook.com (10.174.128.41) by CY1PR03MB2363.namprd03.prod.outlook.com (10.166.207.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.56.11; Wed, 20 Sep 2017 07:49:23 +0000 Received: from BL2FFO11FD023.protection.gbl (2a01:111:f400:7c09::164) by CY1PR03CA0031.outlook.office365.com (2603:10b6:600::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; Wed, 20 Sep 2017 07:49:22 +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 BL2FFO11FD023.mail.protection.outlook.com (10.173.161.102) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.35.14 via Frontend Transport; Wed, 20 Sep 2017 07:49:22 +0000 Received: from b29396-OptiPlex-7040.ap.freescale.net (b29396-OptiPlex-7040.ap.freescale.net [10.192.242.1] (may be forged)) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id v8K7nFAC032674; Wed, 20 Sep 2017 00:49:16 -0700 From: Dong Aisheng To: CC: , , , , , , , Dong Aisheng , Russell King Subject: [PATCH V3 1/1] clk: bulk: add of_clk_bulk_get() Date: Wed, 20 Sep 2017 15:49:13 +0800 Message-ID: <1505893753-16143-1-git-send-email-aisheng.dong@nxp.com> X-Mailer: git-send-email 2.7.4 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131503673624165829; (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)(7966004)(336005)(39860400002)(39380400002)(346002)(376002)(2980300002)(1109001)(1110001)(339900001)(189002)(199003)(81166006)(81156014)(50986999)(8936002)(5660300001)(5003940100001)(97736004)(68736007)(86362001)(4326008)(50226002)(48376002)(2906002)(36756003)(50466002)(189998001)(47776003)(8676002)(8656003)(104016004)(53936002)(7416002)(6666003)(6916009)(77096006)(356003)(105606002)(33646002)(16586007)(316002)(54906003)(85426001)(498600001)(106466001)(2351001)(305945005)(42866002); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR03MB2363; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD023; 1:R/qiU6wsSsHnM4KoCXng8pZLhCGm8+gSfhWga3zdFzlrqTwxpk8w0nyOM4ssoVwUN4Puw45fgH9/M/wjGWouFrgCeqSFPEd+M735lZqOz5o2grFqpYGG7WAZapVN8SYL MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2099b19e-270a-4ad6-fdc5-08d4fffc1b7d 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:CY1PR03MB2363; X-Microsoft-Exchange-Diagnostics: 1; CY1PR03MB2363; 3:EewvFMiTgXPacS+EnYAR3b1IZkBL3krqKM1c4IWLt4t43gd0pW3YVcWdrdq4BX+shQEE+Jh6Oec1GiszspFre2aDhZ4NnEPunEvIr/eCIAxSiEZ7yqr4a06ycqcTUoaOnLdvpZ+dIrGy6EMlMfZAxCqZE0ZKUSF0s5afXKzxnhZQqYNATF7cuJgtZZj61Ulbkjb8htmWJ+2OSQEJ5yQfoB2wDKGMBVNTswHRDOCS4dyliA407Y3MWEJX49Ha/XY+3f1Clc36JOji/Qbu0F6dYfSxLhYegAW1TtUTk+83UbG2MTCx43dtxzjrtTd8823MKR+MmpeMbkqWc/3J8ykf+SLXZ9Bba9/j4zLgGo4mKps=; 25:EirJWgYOepdfbl3TztSQNVtMmfydE69krTujVZ/+kSm646ghOHyBOSp3jbyMdJsppGoqQ7GoTE0UMntEssPM7uZ6V3LH4fTHkENcUSE6sfY4En3bIN17i4IA8GbfKorHCVIbXDGn3exnNFTQ6rpwlYOfAb0GFOLEOweA0+OTy2iqBtjrhMlaQIz5UFe+ojcxzXKyMw2na2GqXUO+lw+ppCNmds7Muz2VGKjK691uLhxHqeipHL8KjcHX/WnKt9Z6UzoEWoE/VjqYcGI871iyRMEmqItt2zSVxpR4hULsEC91fQ5OooYkhDYpR5Df9SSFM1qsCfU7sEEzSQSt/TqiIA== X-MS-TrafficTypeDiagnostic: CY1PR03MB2363: X-Microsoft-Exchange-Diagnostics: 1; CY1PR03MB2363; 31:gk8K98PdtbTX+pislbCdeGAhhDmjrPOFr5MYyuTdnHUMRt4ksMUZPucoArZHAbOS68SZVHHTcZ/JnLtm+doBr1LaqyPKGBNUbgPsu6Slg8+fSZumlBj8UPdAnD0NvJqKTMGMP+afwgBCVqtRb9Vx1Fz7p3TQ5AdDB1FXNCYvyFVs0U+lcHfTJcCIoxEOdfoV5x4rp67f3QZwvWkVznHfwOwdW8x3haxA6EwhEY8NtOo=; 4:N0+TGoPvrxSgsoPGtOuuufy3Q2hSNfrZiZ6y8JX3kr6LFrp7z68bI1hKPtQeBfJlFI/BBxH/anblle1p0Vyu1IIshHG+3hcjRLWAbw4XM3KNcqxqS2kTkJ4yigWoam297AC7ff8cWH3zdHKumlQIiW+ATRcFN206NYNtikjeCy8Sr7g9r4aogV4qxCRwMvS/HFbrbYHex88BFn9ADHPz25q0Ix+EMNziv3K3xNnV3Uv5NlCujMjJf8od1HjpSKpEPTVdDUkxAS6fLNkHVGJF9zkKxQZ4zx2kT2tPb9cpgLU= 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)(93006095)(93001095)(100000703101)(100105400095)(3002001)(10201501046)(6055026)(6096035)(201703131430075)(201703131441075)(201703131448075)(201703131433075)(201703161259150)(20161123556025)(20161123563025)(20161123561025)(20161123565025)(20161123559100)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:CY1PR03MB2363; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(400006)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:CY1PR03MB2363; X-Forefront-PRVS: 04362AC73B X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR03MB2363; 23:vbQrZuR6cGrXqsWxshLP5nkrjoOc09XRUDCKhu9u2?= =?us-ascii?Q?4LTRpV3zX1G1hk9551dyizlBaI7v9mz5w/z4AmRNo0sXfkJvCfgzlwlC6ybt?= =?us-ascii?Q?/WJwQlznT/L2OST0TssYVl5sTK5xtoFjT3YBKOl7NPzpIwVAyb0hUTIDWxcQ?= =?us-ascii?Q?/janO4tbG5X89gQ6/jShXCO2dVtfZ4txkeuUTMDzQweD2dP37iMgaomHoYif?= =?us-ascii?Q?diUQ/4o/vX0djLq2G4bX/chqTOPH0axWvQMc0X31sZJRN+bCRXVMpdGm6ZOv?= =?us-ascii?Q?kkgt2fFGi/uALWbjcXXebAu2MkX3Gd3wBYKeyafAYlloBDgmrwIBw/gebwD8?= =?us-ascii?Q?bbFiWthwofssHOEliwJ6EQwYvL88+suPfVNtLVAjqTRVUwF9ItfRwVH6R+Fx?= =?us-ascii?Q?v/Mc6pYXg8HSeZTWlUnlEPj8UPhnzMmX9wEGkzB0bfMfoUC7lEEh6LE2Ng2t?= =?us-ascii?Q?uLIZlFKggDFk0WKKRT2jVi78u+0dwVA5p1ywq0BPhUfvEZX3Wyx170CfwW/r?= =?us-ascii?Q?08qFhYy11FFa/DH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n99gDr61Kl+E6S6ZcJssi1Pu40rkPafU2YDn9A9zfnEd3lY5CZ/Uz5id+K+GxmTadZ7nGuV+JvDo1oa9+JuPiJZ/09acsqLCx5kzwvY47ZBTgPOh9femo7Ufs9zmGJ5sr75fErZqME3g==; 5:0wYhNtFzYYDIO/zoGopMs+VrMGX+LsEFboB5/cs6j3+yWW9TtyHP3e8afblcdgZKHstPYiR6imNob6tnSKAkLcFKzvFHxAYwnQAc7vH48sVtuTlvsZTnMjpueB4Br8uCiIeIKEjFo+eKliKmxYO2fMBS3bifu1NFqOhOKSV/cU0=; 24:4m1DB5yrgRXPk7AH/kH7negfbHQNeYe3nYBD2w+lqsqtNYh81pRGauP6AdMgHwsAzfMBdKPhgnp0d68Nej86utrUZhgbGqgMdgqa3y1DnR4=; 7:f0koXh8uwrSoYwbC77suI3plcfNIR9JRPtf9Y3ZJNEnEkb7+na2rN2k79nHlgOodv1X+y6kDyB6iFwFdS7AgixHp9hB8rE4ZT/7S/iWkCceJev07ZaeRDd59NjLwFWpaXoHWDk/X+/aP3idFBOY47CLa2zQh52HOl1ToG+T5HshI+bT1HqZ/Z2bYuLh8Qp86vGJmwbgFYX33Rj9iKqjvpunTm+nPbJF2l2FcDlIykCk= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Sep 2017 07:49:22.2605 (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: CY1PR03MB2363 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 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..a1f1f05 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 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);