From patchwork Wed Aug 29 12:51:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aisheng Dong X-Patchwork-Id: 10580303 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 30C4814BD for ; Wed, 29 Aug 2018 12:55:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2233328737 for ; Wed, 29 Aug 2018 12:55:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1558E2B03F; Wed, 29 Aug 2018 12:55:24 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,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 8D93B28737 for ; Wed, 29 Aug 2018 12:55:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728618AbeH2QwL (ORCPT ); Wed, 29 Aug 2018 12:52:11 -0400 Received: from mail-eopbgr80071.outbound.protection.outlook.com ([40.107.8.71]:57440 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728483AbeH2QwK (ORCPT ); Wed, 29 Aug 2018 12:52:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/8lMrKi/+vt2xJ54YJ0QBIBy7vs8gaLUNa0N+REDGwI=; b=sBSticgTRMGX28mK58JlSstID1tmicEMCWCay/scZRaxyBZKfFf69XKUaTQ5SLT6ZESSGQYScBSzFDuUp2ytZOyNAL3y44zhrqBYA9LY9htktFiLmrF3ORGWEAzYl4FMb5rvwTtTvw9TPGABYgBeppvDDcUt0ewNEaT1m6c8hJw= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=aisheng.dong@nxp.com; Received: from b29396-OptiPlex-7040.ap.freescale.net (119.31.174.66) by AM0PR04MB4211.eurprd04.prod.outlook.com (2603:10a6:208:66::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1080.17; Wed, 29 Aug 2018 12:55:14 +0000 From: Dong Aisheng To: linux-clk@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, sboyd@kernel.org, mturquette@baylibre.com, shawnguo@kernel.org, thor.thayer@linux.intel.com, linux-imx@nxp.com, Dong Aisheng , Stephen Boyd , Russell King Subject: [PATCH V4 1/4] clk: bulk: add of_clk_bulk_get() Date: Wed, 29 Aug 2018 20:51:37 +0800 Message-Id: <1535547100-25634-2-git-send-email-aisheng.dong@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535547100-25634-1-git-send-email-aisheng.dong@nxp.com> References: <1535547100-25634-1-git-send-email-aisheng.dong@nxp.com> MIME-Version: 1.0 X-Originating-IP: [119.31.174.66] X-ClientProxiedBy: HK0PR04CA0003.apcprd04.prod.outlook.com (2603:1096:203:36::15) To AM0PR04MB4211.eurprd04.prod.outlook.com (2603:10a6:208:66::21) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 696e3ce8-b44c-40c2-70a2-08d60daeac38 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020);SRVR:AM0PR04MB4211; X-Microsoft-Exchange-Diagnostics: 1;AM0PR04MB4211;3:IYSOdWRiKLY4IGBk9Z0x6wqrgrXKQ8kGAvfgk/QSULAWmMZpfO1ii61mdGLyuZnoL3nPxrGdLFkAL3z3kC4acnvWaJBIO/Pt5y29YVmikR7Fsz5nxIRCmjY1xIojHQU0Bh7MtuxSjdOIjL2shFCUF7a2eZkMZGORnw2LLjjEpAoYiQRRFRwkngrQwqCFm2oYPQqmRFXTs/fGYw4SFE4sw4FP+IdVz4Wd0XcMkvdYKVthAscRVK/s/gZxNR7poBUP;25:hRQFsunOfkBGFYtiOVmOPLneqF1r8otsTEaq9VCp1Qdc2VMik2gR2WdMG0lT2lJIHOY1qyIcwB1yrzqIMnv7C7sWArVNc4JbdG6Old7aYk2Yy1AD4BQf5uosm2uWkW3zuq0RBoEQSxJHhcibo4955uQm2dGKwJUt00v9Hhr7KtUBt5B5Qu04rFqLUjOTrCIs72rpN8+OD/s7cvp55vRTeNcHdkgnKsheAab9HhQxsZ1WgzRCtpkzLm0tRDNXAxYSTATE63PTPgpn7Z6csIJ1YutLgK8pvlUlLPEwJE0Vi2n3IyYRSFlMyJd4/cl/wHlga3ehDL/+Qz/NM1RB/YPTvw==;31:0043i6W2p/zy1aJnGZrSa9012UHz8u40T3eL85EuBCUch/vw/8dilNt7aMh/vp7HwmL3aPbKSdkmt3rWMHcxz3bf7BG76lgjx4XP1InsxCE2kYYsn05XrsyYs2P8M1wiiHcl5i+kBMux6RAnO4/Q4T4om6vCieDUtl/3RY+duqEhQk/FLfHF9ZJQAL084c02Thy7hZPdEdc2kv4KV551W8j28IFzCWWQ6Q6m2TQRbfc= X-MS-TrafficTypeDiagnostic: AM0PR04MB4211: X-Microsoft-Exchange-Diagnostics: 1;AM0PR04MB4211;20:p3xxXGYYEyQXqdoECTgizVd5NXRO5FWKEwVxPMgv5P6H29zzb1Vq4jqkhfxJxVqcTKWWYyOvRc6CzwwvqNEcbdrf4+kxPFs02UDhNLfZilnpmXEOxYul+0kkCCp5T7nv/i1TjIsVFXSuThyc2mrt8h2PUqrZlUq7dzne7ke3M3YUnY8ihKPe/PlkYJhqGmOXBWHP1sJ8LZhwPTv1JflHy3QntqzAZmapQ9lymX9Tiskongu5LxK9fJX9m53RvemMF8ZpH6LdTnfnn0SoG/Tl96CEZ7Mw9akPn282KPeL5BfYBGFirl9M0zYvDSlCkZxyaXUEhdXwOmLkxaXj9xSwSpIiAmlKLcMwzVVAY9MhRzGL9E8YBVT3XGa5b41Dhcx0kbNvcP/DANu2pGfzQDr48g8F+D/OSzYhclT9wzLDPtuZrqjNCPm/Jbc5YFG13QFhbSIaHBcFfnzK+nhvDnTqyNwuAImOzL8anxIKPtrXg70zF9pxR6LZhLbZ9OaZXgLq;4:azHgoWbfRDdS1OsRgpEbcI2l0hKy9NuIvetpmarbkVXTQFrnb8tGDfa1fKfxLGTqFVDyZHw1Fh82Jl+Omf+9vKa8ZnUBuRkYuIBmdJGOWkK4BNZjtSncU8OLEQ686fdtFqMV6suIOp1Fq5lN3a559q8DTxFTk8x5vKQ2eRYQflS92nxUsfD79GW1qV61J+PQx01uJImB6Kh5YcjSbprJe9xjt+Nrciz94r28PTXkKyom+yb7AQ5FDEnmlJTWtDf1VdHKvmd7WXmjo6WBqtCpxPV2Pz/ccMOmEMeGCCqIfgIPuKlTlC3Xa4Xr2BwRUoAvobuIuulgs8uB7MP3lthmXucNr85n6cr2kz2BjlkIUW0= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197)(228905959029699); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(823301075)(3231311)(944501410)(52105095)(10201501046)(93006095)(93001095)(3002001)(6055026)(149027)(150027)(6041310)(20161123564045)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(201708071742011)(7699016);SRVR:AM0PR04MB4211;BCL:0;PCL:0;RULEID:;SRVR:AM0PR04MB4211; X-Forefront-PRVS: 077929D941 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(396003)(366004)(376002)(346002)(39860400002)(136003)(189003)(199004)(51416003)(50226002)(3846002)(6116002)(68736007)(2361001)(8676002)(50466002)(48376002)(2351001)(2906002)(97736004)(106356001)(105586002)(36756003)(8936002)(7736002)(305945005)(53936002)(6512007)(386003)(47776003)(81166006)(6506007)(6916009)(2616005)(4326008)(26005)(446003)(16526019)(66066001)(25786009)(956004)(81156014)(476003)(86362001)(186003)(76176011)(486006)(5660300001)(16586007)(316002)(478600001)(52116002)(54906003)(6486002)(11346002)(6666003);DIR:OUT;SFP:1101;SCL:1;SRVR:AM0PR04MB4211;H:b29396-OptiPlex-7040.ap.freescale.net;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: 1;AM0PR04MB4211;23:/mIHy8uvTFpufVyupmYSLZJQ6Tb9n2VchpJ5UyfF8iS37rXbnfBbacLrnribJV38+GSpYhjY9Dag2Ta94yMhXJabjQj3iraK7uKkE8GZKaD+6w38LzMptGfTkHQBu7X/T7w/kHAbigT+f7NKDHRiGmfrvGeTE8zorqcnxXn1WRLH+FRTvqy74WWxhhBHSa0vLvxkWoDXAEX2BpXPr88tmILVEvPhtsexDbwVA4p+602iwapGgLe/iB7bA6coj8vya0y0WWDQL/qI7vvkDSnPAQiW6/P9KoyM4FeTmU2jMTiqBY+T15dyFFFl8TqgrRyO4G6z0L9l0qdw9Be+E8iwDCgKfY+uuGDj0sKZ5pnPBsjChrItdQYuuk5p0S3brU8cejCAXaxbmPMy4LO1Z3oq7z/mmjPa/UWEa2JmJBix/+E4WKBzPO/DTev6YYC/SCFj9B7ir7vos6KAcajqBJWPIGD7rMUrlTq0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UPg9GEhJqeeebkfd5VtkbOsbMjnQM5ichEQq6QMAPHM6MF1NlqE9bF0LFB2T+LNM= X-Microsoft-Exchange-Diagnostics: 1;AM0PR04MB4211;6:CFGLyN30MJpJtzK69B6cuJv4toptvguclRB1n2qy+Vzf1WrG36S8dzAb+fZ04nkbuO1oLsw/zo+trMgHjL8UCANdjn6iqCGOymqkqnGUPRbAqRuxpxrxFmnWslz3JXL8z+dSiUcsImTUS9RcEG76kEFbHo7Od4AVqZe6GGRG89T0i7XQJqj141+cpjf1FMZKlvnapMvnnftUI8gYHdXAK6z47AOLjCsq9bqAGF/NBAqDVhfeCByy5OfwsELl7yQ+C59/5JYp+TIFgXwXx7ylwc8KerEpU8z93e5rZcZmEc2P/62bUf0hnrf6JqC/DpnhZzPv1DnxIJDqAMRiNeTXbHJrTLdcHOJRTNe0s6mR/27wzaMP0EctjcoYd6WsX+N4oj/iNBqMXNo1Owo7pGZ2PJojf8XGeqHvjJI8zGdvx4BNh3zEojjqTzrUPmhXZhMq6wQSBzf3zIfyLHy/e6BMMQ==;5:NtfaG1jDNpGMGDdijW1YOWE5JnJe0ArTH1ALeqZv41RDOweel2PVeMPtCoRBQgg1QtBBJXWQA1eEen3xw3anJxq5vLkYEtDrTSuWsyrPSUAP++VswBJlb2G/Kcm3jEA5TVuUsThYG6GizSZ3sDUlkAopbRn/Jmqv75OtkPpj8uc=;7:MHGYoZLkZ/l9+4QOBs5l/eNKgPBG9LRQn+qNseN98YtLVFh9mtXZYE8o8//n46H7OS4Zel0HSEVQnI84garW6wVymq4VFgavvOn2YTp/4BLLtYZp0CxS37HNQeBl9PiRPhfsOrVQbzQiLDNrewiKmgLuS699x4NDpS9k2TyR+BJFgkpEBDfHenTq6B5AeZyi9EK2KH2JhCnO/Cd/InWdbGxQ/X3mHdJc4FJ18475mE2YEJuM8+yX7CbU7GdLW6Vm SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2018 12:55:14.5604 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 696e3ce8-b44c-40c2-70a2-08d60daeac38 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB4211 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 optional in DT, so of_clk_bulk_get() is introduced here to handle this for DT users without 'clock-names' specified. Later clk_bulk_get_all() will be implemented on top of it and this API will be kept private until someone proves they need it because they don't have a struct device pointer. Cc: Stephen Boyd Cc: Michael Turquette Cc: Russell King Reported-by: Shawn Guo Tested-by: Thor Thayer Signed-off-by: Dong Aisheng --- v3->v4: * no changes v2->v3: * remove #if define condition * remove EXPORT_SYMBOL --- drivers/clk/clk-bulk.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/clk/clk-bulk.c b/drivers/clk/clk-bulk.c index 6904ed6..4460ac5 100644 --- a/drivers/clk/clk-bulk.c +++ b/drivers/clk/clk-bulk.c @@ -19,6 +19,35 @@ #include #include #include +#include + +static 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; +} void clk_bulk_put(int num_clks, struct clk_bulk_data *clks) { From patchwork Wed Aug 29 12:51:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aisheng Dong X-Patchwork-Id: 10580305 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1BFFA14BD for ; Wed, 29 Aug 2018 12:55:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0D1CF28737 for ; Wed, 29 Aug 2018 12:55:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 00D112B03F; Wed, 29 Aug 2018 12:55:33 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,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 5640A28737 for ; Wed, 29 Aug 2018 12:55:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727651AbeH2QwQ (ORCPT ); Wed, 29 Aug 2018 12:52:16 -0400 Received: from mail-eopbgr80074.outbound.protection.outlook.com ([40.107.8.74]:31904 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728483AbeH2QwP (ORCPT ); Wed, 29 Aug 2018 12:52:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Rw9+YfSA6MDu1qVOhtAIGv4iDtfo3XsUT5Y+EGVeicw=; b=TmIPBc2bPoHKbcoy6sJmZHOQDu84A3VaetRQbAlH0JrnXHrBsyv6F+ryfW9HinupzgnG9W7H/cPPdnDdi8frCkEL+UtbeaYsr4pWqnt+1F9pHnNIpXKeLBs172zJplXFk1TtWP/YHce6SCHIlSkzr7nfVaic3Rza6mTkVInLPHM= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=aisheng.dong@nxp.com; Received: from b29396-OptiPlex-7040.ap.freescale.net (119.31.174.66) by AM0PR04MB4211.eurprd04.prod.outlook.com (2603:10a6:208:66::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1080.17; Wed, 29 Aug 2018 12:55:18 +0000 From: Dong Aisheng To: linux-clk@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, sboyd@kernel.org, mturquette@baylibre.com, shawnguo@kernel.org, thor.thayer@linux.intel.com, linux-imx@nxp.com, Dong Aisheng , Stephen Boyd , Masahiro Yamada Subject: [PATCH V4 2/4] clk: add new APIs to operate on all available clocks Date: Wed, 29 Aug 2018 20:51:38 +0800 Message-Id: <1535547100-25634-3-git-send-email-aisheng.dong@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535547100-25634-1-git-send-email-aisheng.dong@nxp.com> References: <1535547100-25634-1-git-send-email-aisheng.dong@nxp.com> MIME-Version: 1.0 X-Originating-IP: [119.31.174.66] X-ClientProxiedBy: HK0PR04CA0003.apcprd04.prod.outlook.com (2603:1096:203:36::15) To AM0PR04MB4211.eurprd04.prod.outlook.com (2603:10a6:208:66::21) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ab10b721-72c6-4342-a1e8-08d60daeaed1 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020);SRVR:A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2+bcTiJxZWZPs7vuqQV0aptezN3l2r+hf4YfLwbvFR6BrYcLs8KlU1mhsYLgM7WGl9AQm7ddyNtMYgyhKQ60MuWChQo1AOrZXar2u01HSUUo33TLoqWC7tCIaKq9QI0bFGX87MGTFdO8n7DHwIyM3nZLOPkQBiLjamqIBM3T4Yrt0V16wG85Fz5cBmMboE4SKEe7k+7cqUhZx5Gv5dTSBzx1S5yvDdDZxJ9N2JAc+AckRv+wN+jbsvXKoEonosFs/RB5QG1MN4zIr76/iojeD9w8/rEMHgn0bZvkNd7gjBpMBPgA0dDq/zx8iy3hHzXprrbbU4z3mvRvxgc/GngWwulchLIqvP+pdOFqVu5gAOtP2sp7Rs06q5Ke/F5Fjlc6ao5CwM7+STwlzEj+PV654T;4:9FrIO+s26S/nCvJ/BCEPLxUn4CAoHVkOw5YzYipEN8q/9X9Dx5rx/bE+BrKllkge0wokJibKvI83URGQcFAHBCrazusQQbtBTWl2RuuIG80evPKxu/zItzJax2WrGO8Q6F9FLKdf9QP+1zZeRYgw28KjqBsPCsl3FTC7sLlSnuvMhV0noPp6dDNJDFRDkNI/RzfFoMUq0p3TtvJ51ObKAZ/IXkNhgosozdtGsgMKmXPuSNFi2kE3cQ4ii/QaALdOyvmjI+Jh1RUi0bpTlNsc9gldeD0YR8gZjUZdWlX8NzhYjDvVPoP32y3jrj9Rz8somZKJKmGQs/kOvgZb118/x3oFvFd298KbCTCT04UB4i8= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197)(228905959029699); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(823301075)(3231311)(944501410)(52105095)(10201501046)(93006095)(93001095)(3002001)(6055026)(149027)(150027)(6041310)(20161123564045)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(201708071742011)(7699016);SRVR:AM0PR04MB4211;BCL:0;PCL:0;RULEID:;SRVR:AM0PR04MB4211; X-Forefront-PRVS: 077929D941 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(396003)(366004)(376002)(346002)(39860400002)(136003)(189003)(199004)(51416003)(50226002)(3846002)(6116002)(68736007)(2361001)(8676002)(50466002)(48376002)(2351001)(2906002)(97736004)(106356001)(105586002)(36756003)(8936002)(7736002)(305945005)(53936002)(6512007)(386003)(47776003)(81166006)(6506007)(14444005)(6916009)(2616005)(4326008)(26005)(446003)(16526019)(66066001)(25786009)(956004)(81156014)(476003)(86362001)(186003)(76176011)(486006)(5660300001)(16586007)(316002)(478600001)(52116002)(54906003)(6486002)(11346002)(6666003);DIR:OUT;SFP:1101;SCL:1;SRVR:AM0PR04MB4211;H:b29396-OptiPlex-7040.ap.freescale.net;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: 1;AM0PR04MB4211;23:WwbTkwrYDXLBOknbnhwprHj3BC/I1YOisZ5g1YFLMXO3wE0TTZJDUCzOSjMAI2tPmyLAdTW5igzInK9i0CrzOVfIyuftIdcKEjwiXfwhzyIMsypXc+pnEb0cSBoQdDrDks6NFAUWACqQIvSHMe1tsPcSkHwm83ohu+a4efG9q0SrfsXnlXyNyH05pHsd+JLJW57xSNFIjAycNjSVklHZRRvvgWXPcKLsS8JACd4MjmYBQ08Dq3elRtkC7Geoh/iE18JDu/Y5EfaULuJekzvoGu5eukpCfhZM7QUnwOISYw68Wbol+YRvGB8QIrAzE400TKQLsEiS6ClVC32+ssCGcRW8V0RlvsNZOQK3zZlMb/4O+pofA0PGMKAX4cdIL4HLFtiTU5ZldyxBB3XLjpqwV3NJ3bRplRnmXmrDEJocVKoHPR5ysyfJccE/e9dsiXC18tgTWflJ2cjBsHk73QaXGU9iq1eaDqjRX5OrKVfaqoW2tdiQkvZtlO1AzGCu5caMX1K5nh4/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nsCf1g5x0M9t4AhDxIPb/ynComm5WJPC3Oijq6MU= X-Microsoft-Exchange-Diagnostics: 1;AM0PR04MB4211;6:KJpoUyHouGDwF6SB3gtO6r3KWHDTWbOVPAf/uSaOnDAljOEv0gJR1TFjaP64wNKuBRtRx4mxRRvKvP9hBxdy5oH53tWKoxDGRs4sLIFpnW/dgKsdvP82IRP7F5+g96guF9p+taO2mdhIjuXDAXrSbrEGiBEGD6X5XMitBo410CMnVKTQfPWyPWHtvWYQyDs+g0yc4x0SukEZkXmOYNbpfdxZnS6we3taDlL6TOCzq9SP1wEqHX4eD/Vn0QmpXlYj4mrjK9XRAVD1GrYM/ErcFjW2doP8B67eTOt4D+uZrkwS+I9js7wcGVQK8TgM0cJAGsuJfXCVjmbeGgFwtnFrPfzKhrqCBxyzXovM/xgRwIXQhscvaXtpoI6iS3XhWH4ZHKyiWcaBEo0C26r3q8zK5MMya1cmQYMvwJBxnZaJInJ3wvlnlGjraKo5jJTFyN7X/+mHnX6jZEkDs40Ix8Zs1A==;5:InLI5jmBk4zZxNka/YZHDwirGDmadlYEYiB5NPbfBjxtxMHRrOWeJObQsitth/8ryyuGvs6MJP8RRKzfPai2wZbhCUGWiqkAXw++FeF5AEWnkgA934ouKNGiticAewdShoNcOablMpvCJFvZVR1psjBz1PHgHnY4cWTOFwojIAA=;7:W9OdBRuFvUSWCwX5dSL3UIrmCk1lheFlAzgqR5a0AUD77jEL+ayH2uLotQooXT0X06fjefCj/xN67RqCvuqPhTdNUXZCjMpF3T1IzOQxctgQXwvxylui32Dee9ZPeZXn7PnmA7l6GVMtI/oAX/QzET7YQJD9nqX9U3WeTvRz4z98AgGMeJk01bFtlCWZrlFZTQ/+8YE2+vuePq9kArJo/MUmdZmbQxS3fLi2OdVi9dbR4B1j7Na7XZ2rZhuCR5CC SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2018 12:55:18.9198 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ab10b721-72c6-4342-a1e8-08d60daeaed1 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB4211 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 This patch introduces of_clk_bulk_get_all and clk_bulk_x_all APIs to users who just want to handle all available clocks from device tree without need to know the detailed clock information likes clock numbers and names. This is useful in writing some generic drivers to handle clock part. Cc: Stephen Boyd Cc: Masahiro Yamada Tested-by: Thor Thayer Signed-off-by: Dong Aisheng --- v3->v4: * no changes v2->v3: * remove #if define condition * use kmalloc_array v1->v2: * make of_clk_bulk_get_all private * add clk_bulk_get/put_all --- drivers/clk/clk-bulk.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/clk.h | 42 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 92 insertions(+), 1 deletion(-) diff --git a/drivers/clk/clk-bulk.c b/drivers/clk/clk-bulk.c index 4460ac5..6a7118d 100644 --- a/drivers/clk/clk-bulk.c +++ b/drivers/clk/clk-bulk.c @@ -17,9 +17,11 @@ */ #include +#include #include #include #include +#include static int __must_check of_clk_bulk_get(struct device_node *np, int num_clks, struct clk_bulk_data *clks) @@ -49,6 +51,32 @@ static int __must_check of_clk_bulk_get(struct device_node *np, int num_clks, return ret; } +static int __must_check of_clk_bulk_get_all(struct device_node *np, + struct clk_bulk_data **clks) +{ + struct clk_bulk_data *clk_bulk; + int num_clks; + int ret; + + num_clks = of_clk_get_parent_count(np); + if (!num_clks) + return 0; + + clk_bulk = kmalloc_array(num_clks, sizeof(*clk_bulk), GFP_KERNEL); + if (!clk_bulk) + return -ENOMEM; + + ret = of_clk_bulk_get(np, num_clks, clk_bulk); + if (ret) { + kfree(clk_bulk); + return ret; + } + + *clks = clk_bulk; + + return num_clks; +} + void clk_bulk_put(int num_clks, struct clk_bulk_data *clks) { while (--num_clks >= 0) { @@ -88,6 +116,29 @@ int __must_check clk_bulk_get(struct device *dev, int num_clks, } EXPORT_SYMBOL(clk_bulk_get); +void clk_bulk_put_all(int num_clks, struct clk_bulk_data *clks) +{ + if (IS_ERR_OR_NULL(clks)) + return; + + clk_bulk_put(num_clks, clks); + + kfree(clks); +} +EXPORT_SYMBOL(clk_bulk_put_all); + +int __must_check clk_bulk_get_all(struct device *dev, + struct clk_bulk_data **clks) +{ + struct device_node *np = dev_of_node(dev); + + if (!np) + return 0; + + return of_clk_bulk_get_all(np, clks); +} +EXPORT_SYMBOL(clk_bulk_get_all); + #ifdef CONFIG_HAVE_CLK_PREPARE /** diff --git a/include/linux/clk.h b/include/linux/clk.h index 4f750c4..e9433c7 100644 --- a/include/linux/clk.h +++ b/include/linux/clk.h @@ -312,7 +312,26 @@ struct clk *clk_get(struct device *dev, const char *id); */ int __must_check clk_bulk_get(struct device *dev, int num_clks, struct clk_bulk_data *clks); - +/** + * clk_bulk_get_all - lookup and obtain all available references to clock + * producer. + * @dev: device for clock "consumer" + * @clks: pointer to the clk_bulk_data table of consumer + * + * This helper function allows drivers to get all clk consumers in one + * operation. If any of the clk cannot be acquired then any clks + * that were obtained will be freed before returning to the caller. + * + * Returns a positive value for the number of clocks obtained while the + * clock references are stored in the clk_bulk_data table in @clks field. + * Returns 0 if there're none and a negative value if something failed. + * + * Drivers must assume that the clock source is not enabled. + * + * clk_bulk_get should not be called from within interrupt context. + */ +int __must_check clk_bulk_get_all(struct device *dev, + struct clk_bulk_data **clks); /** * devm_clk_bulk_get - managed get multiple clk consumers * @dev: device for clock "consumer" @@ -488,6 +507,19 @@ void clk_put(struct clk *clk); void clk_bulk_put(int num_clks, struct clk_bulk_data *clks); /** + * clk_bulk_put_all - "free" all the clock source + * @num_clks: the number of clk_bulk_data + * @clks: the clk_bulk_data table of consumer + * + * Note: drivers must ensure that all clk_bulk_enable calls made on this + * clock source are balanced by clk_bulk_disable calls prior to calling + * this function. + * + * clk_bulk_put_all should not be called from within interrupt context. + */ +void clk_bulk_put_all(int num_clks, struct clk_bulk_data *clks); + +/** * devm_clk_put - "free" a managed clock source * @dev: device used to acquire the clock * @clk: clock source acquired with devm_clk_get() @@ -642,6 +674,12 @@ static inline int __must_check clk_bulk_get(struct device *dev, int num_clks, return 0; } +static inline int __must_check clk_bulk_get_all(struct device *dev, + struct clk_bulk_data **clks) +{ + return 0; +} + static inline struct clk *devm_clk_get(struct device *dev, const char *id) { return NULL; @@ -663,6 +701,8 @@ static inline void clk_put(struct clk *clk) {} static inline void clk_bulk_put(int num_clks, struct clk_bulk_data *clks) {} +static inline void clk_bulk_put_all(int num_clks, struct clk_bulk_data *clks) {} + static inline void devm_clk_put(struct device *dev, struct clk *clk) {} From patchwork Wed Aug 29 12:51:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aisheng Dong X-Patchwork-Id: 10580313 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2374714BD for ; Wed, 29 Aug 2018 12:55:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 13D0228737 for ; Wed, 29 Aug 2018 12:55:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 07A032B048; Wed, 29 Aug 2018 12:55:51 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,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 85A8E28737 for ; Wed, 29 Aug 2018 12:55:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728667AbeH2QwX (ORCPT ); Wed, 29 Aug 2018 12:52:23 -0400 Received: from mail-eopbgr80074.outbound.protection.outlook.com ([40.107.8.74]:45091 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728483AbeH2QwW (ORCPT ); Wed, 29 Aug 2018 12:52:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+iN9uc1R4Ctt5/eBOt/haNNMwfWSxMKXuI49Pwtddzo=; b=gO3/yfgVT5NahZaHswna6vmt94Y25pUb5WvjFkF+wfIneW80kJs+wqrH6D6BPT0nx46Zh0pmYeU5rgzSaE8c/xsljoX5SYSv1H4LpESYSuiT/gLXTGhtnZjhqRpZ1BOpoDMyDjh9rVYJTFmtBl6610uLHOMBgb2vCu0L6mfTCFg= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=aisheng.dong@nxp.com; Received: from b29396-OptiPlex-7040.ap.freescale.net (119.31.174.66) by AM0PR04MB4211.eurprd04.prod.outlook.com (2603:10a6:208:66::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1080.17; Wed, 29 Aug 2018 12:55:23 +0000 From: Dong Aisheng To: linux-clk@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, sboyd@kernel.org, mturquette@baylibre.com, shawnguo@kernel.org, thor.thayer@linux.intel.com, linux-imx@nxp.com, Dong Aisheng , Stephen Boyd Subject: [PATCH V4 3/4] clk: add managed version of clk_bulk_get_all Date: Wed, 29 Aug 2018 20:51:39 +0800 Message-Id: <1535547100-25634-4-git-send-email-aisheng.dong@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535547100-25634-1-git-send-email-aisheng.dong@nxp.com> References: <1535547100-25634-1-git-send-email-aisheng.dong@nxp.com> MIME-Version: 1.0 X-Originating-IP: [119.31.174.66] X-ClientProxiedBy: HK0PR04CA0003.apcprd04.prod.outlook.com (2603:1096:203:36::15) To AM0PR04MB4211.eurprd04.prod.outlook.com (2603:10a6:208:66::21) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4e33c8eb-f7a6-4189-6d66-08d60daeb168 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020);SRVR:AM0PR04MB4211; X-Microsoft-Exchange-Diagnostics: 1;AM0PR04MB4211;3:CbGCHxvxTIK9P/AhOOG6LdRA3edOD/rrNqPsK9sU4X5zOG9Eu2p3Y/uEv4HFmNNs999lkKvWdPnFmmsK8FgugIUG4pLsO54Jzv3lIZwY1wKIvFThR86Aq6MV/xtmShrJIDBiPTMW+OXjUj/2BV1eRTKivwzcygy/evgt70FDyK70CyejVK1nBRiKnmV7DsE9mSwYCShZ4B6tAdXVymdPA+Wk84ye/XIP2zw1moLT2zBBdhAkcVuYBtVhq4AjGqx1;25:aIZ20QspnsLIz3OmAigQHz6dB1Vo6Sy9gURIv4HsgeS+0e1iu551MsGZzSTg4wxaZwrtmhqx1fjEoBWlGzP7ICIXDMMrLc0p/MFNxFNUm82IJT49mttQ3Hsp1eW13sGsjcFb8Jx+a+L/sqrCrTQJw8p2h5ouCF2Ppwvoqba95Ky+DkspLkuNcwM9GFX80Yl2KUh3+7KEx9gukxcZdX/YD9E5JvyX4qrXHVRg30/piiIyfaoAXrT63Fd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Jl4PRE8/p1QO6M/XoZpXumgOerfoDoKNMvtN6KB588omogAGAG/7CDE+d4HIom783+Mjvx+iSNaFVF18Q4KbIT9z4j5sWncJjLOhjDEVJwE/q60MAF1GjyxmcKJTSYwfnDzwxYtMI8hMOBoIPbYWwm/lrKo+fvEmw2y/PFCXJv5DIFaEvyQbu1+rNcAp2xRDXbFoHkc/TTGtVk6CySWJ1OkmnUGKXdrWCais= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197)(228905959029699); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(823301075)(3231311)(944501410)(52105095)(10201501046)(93006095)(93001095)(3002001)(6055026)(149027)(150027)(6041310)(20161123564045)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(201708071742011)(7699016);SRVR:AM0PR04MB4211;BCL:0;PCL:0;RULEID:;SRVR:AM0PR04MB4211; X-Forefront-PRVS: 077929D941 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(396003)(366004)(376002)(346002)(39860400002)(136003)(189003)(199004)(51416003)(50226002)(3846002)(6116002)(68736007)(2361001)(8676002)(50466002)(48376002)(2351001)(2906002)(97736004)(106356001)(105586002)(36756003)(8936002)(7736002)(305945005)(53936002)(6512007)(386003)(47776003)(81166006)(6506007)(14444005)(6916009)(2616005)(4326008)(26005)(446003)(16526019)(66066001)(25786009)(956004)(81156014)(476003)(86362001)(186003)(76176011)(486006)(5660300001)(16586007)(316002)(478600001)(52116002)(54906003)(6486002)(11346002)(6666003);DIR:OUT;SFP:1101;SCL:1;SRVR:AM0PR04MB4211;H:b29396-OptiPlex-7040.ap.freescale.net;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: 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0iIdPZ7SfaOkWSKPCaqqqQK8siUwQU7di4A2Vz85tmoEmjGQVRQs2mz6FpF2e8luA30gQAcje7lCYyYVvxKyZnRNw8VPh/Z90IIGy4ZVPVS7Ek6KoL6B2fm5GQHDtQqIu7tTPs8CQQTEn7yEGfRDOUv4VfNVChtmpWp1j/p3pmE=;7:6oNjbwE4cmiOddUYuifKRrqlsEcUdwDW6szHG+Hv2pEnufdO5kYtyM+4iHE5g6pqy5QjMl8QWjX59di33zAwHAIUv4D87Zcvkr9d4I5E0PkbY503mgdpCQLjNMQQYvrrlo9JMcKW6uK+vah62/EzU8yrdpgGKl3P1dQnC2MKCeOoFNGi0K+L8eQClSnpA8OAvlwOJoP7XWRiTaXkbb8Uy965kTwd0QTHgJ5gmy7o3fEbYxpOP4+YebcWZPob+U18 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2018 12:55:23.5448 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4e33c8eb-f7a6-4189-6d66-08d60daeb168 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB4211 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 This patch introduces the managed version of clk_bulk_get_all. Cc: Michael Turquette Cc: Stephen Boyd Tested-by: Thor Thayer Signed-off-by: Dong Aisheng --- v3->v4: * improve 'devres->clks = *clks' according to Stephen's suggestion v2->v3: * a minor fix of build warning on PowerPC platform. v1->v2: * new patch --- drivers/clk/clk-devres.c | 24 ++++++++++++++++++++++++ include/linux/clk.h | 23 +++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/drivers/clk/clk-devres.c b/drivers/clk/clk-devres.c index d854e26..12c8745 100644 --- a/drivers/clk/clk-devres.c +++ b/drivers/clk/clk-devres.c @@ -70,6 +70,30 @@ int __must_check devm_clk_bulk_get(struct device *dev, int num_clks, } EXPORT_SYMBOL_GPL(devm_clk_bulk_get); +int __must_check devm_clk_bulk_get_all(struct device *dev, + struct clk_bulk_data **clks) +{ + struct clk_bulk_devres *devres; + int ret; + + devres = devres_alloc(devm_clk_bulk_release, + sizeof(*devres), GFP_KERNEL); + if (!devres) + return -ENOMEM; + + ret = clk_bulk_get_all(dev, &devres->clks); + if (ret > 0) { + *clks = devres->clks; + devres->num_clks = ret; + devres_add(dev, devres); + } else { + devres_free(devres); + } + + return ret; +} +EXPORT_SYMBOL_GPL(devm_clk_bulk_get_all); + static int devm_clk_match(struct device *dev, void *res, void *data) { struct clk **c = res; diff --git a/include/linux/clk.h b/include/linux/clk.h index e9433c7..c705271 100644 --- a/include/linux/clk.h +++ b/include/linux/clk.h @@ -346,6 +346,22 @@ int __must_check clk_bulk_get_all(struct device *dev, */ int __must_check devm_clk_bulk_get(struct device *dev, int num_clks, struct clk_bulk_data *clks); +/** + * devm_clk_bulk_get_all - managed get multiple clk consumers + * @dev: device for clock "consumer" + * @clks: pointer to the clk_bulk_data table of consumer + * + * Returns a positive value for the number of clocks obtained while the + * clock references are stored in the clk_bulk_data table in @clks field. + * Returns 0 if there're none and a negative value if something failed. + * + * This helper function allows drivers to get several clk + * consumers in one operation with management, the clks will + * automatically be freed when the device is unbound. + */ + +int __must_check devm_clk_bulk_get_all(struct device *dev, + struct clk_bulk_data **clks); /** * devm_clk_get - lookup and obtain a managed reference to a clock producer. @@ -691,6 +707,13 @@ static inline int __must_check devm_clk_bulk_get(struct device *dev, int num_clk return 0; } +static inline int __must_check devm_clk_bulk_get_all(struct device *dev, + struct clk_bulk_data **clks) +{ + + return 0; +} + static inline struct clk *devm_get_clk_from_child(struct device *dev, struct device_node *np, const char *con_id) { From patchwork Wed Aug 29 12:51:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aisheng Dong X-Patchwork-Id: 10580307 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 90A9217DB for ; Wed, 29 Aug 2018 12:55:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7FB942B041 for ; Wed, 29 Aug 2018 12:55:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 73A032B04A; Wed, 29 Aug 2018 12:55:40 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,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 D2BB52B041 for ; Wed, 29 Aug 2018 12:55:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728758AbeH2Qw0 (ORCPT ); Wed, 29 Aug 2018 12:52:26 -0400 Received: from mail-eopbgr80074.outbound.protection.outlook.com ([40.107.8.74]:45091 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727692AbeH2QwZ (ORCPT ); Wed, 29 Aug 2018 12:52:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4qAGmDD6BF63dOo/zUTsXb7go2KPJgKODZlAmitxuJU=; b=qbhLfhoyRU6e3nZXLVLN8120vSTgIFYuayLxj8eTV3kCIVLRNOXwyEtrqGBit3SNbbumqOq6nW+njuP8NWyXDulJYql+9afCGbvGvg4ZRP1lE4R032NJgQ74K3Zr3WJ/20tw3bXpeVw6CpZXSJ6sfp7nEzQc+JCavOdyCsU0T5U= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=aisheng.dong@nxp.com; Received: from b29396-OptiPlex-7040.ap.freescale.net (119.31.174.66) by AM0PR04MB4211.eurprd04.prod.outlook.com (2603:10a6:208:66::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1080.17; Wed, 29 Aug 2018 12:55:27 +0000 From: Dong Aisheng To: linux-clk@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, sboyd@kernel.org, mturquette@baylibre.com, shawnguo@kernel.org, thor.thayer@linux.intel.com, linux-imx@nxp.com, Dong Aisheng , Hans de Goede , Bartlomiej Zolnierkiewicz , linux-fbdev@vger.kernel.org, Masahiro Yamada , Stephen Boyd Subject: [PATCH V4 4/4] video: simplefb: switch to use clk_bulk API to simplify clock operations Date: Wed, 29 Aug 2018 20:51:40 +0800 Message-Id: <1535547100-25634-5-git-send-email-aisheng.dong@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535547100-25634-1-git-send-email-aisheng.dong@nxp.com> References: <1535547100-25634-1-git-send-email-aisheng.dong@nxp.com> MIME-Version: 1.0 X-Originating-IP: [119.31.174.66] X-ClientProxiedBy: HK0PR04CA0003.apcprd04.prod.outlook.com (2603:1096:203:36::15) To AM0PR04MB4211.eurprd04.prod.outlook.com (2603:10a6:208:66::21) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ed464481-d1dd-4eff-0c2e-08d60daeb493 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020);SRVR:AM0PR04MB4211; X-Microsoft-Exchange-Diagnostics: 1;AM0PR04MB4211;3:lsl6JyZ//rUTcBHS7Y3cB7zAQJDjCMW/1TgKLHf+WgTbCvkVIuyRnFp4GsbinrJa5nDMOLI1vMw0GHEJLG1QpeIixV5XJIOos78+DhSKQQK0ori4nmpLjV+1axBb07zcPYb9oF/EgvFzbY1B/SGtIF5u+qohSjfYzYeKwGMepBmgFLyhaCGkY2YBMzV8qLmAXgBn48n8cCZJtnHWlFB9ozeGYbyxBeXpygzF3FPKmJrGyiPFtWSZC9/xDXGIbVtb;25:0AZQ5bptMfdBMB0Yh10S5NzC1EePslfy0BEXDrOuwL53OGgRJvpPqQRDd8YgAFO6qHNRP4UZFbnBd3uLc5CqqMR8UrHguAKHLokfX+roRrkhrcytVLDVb2qZsO/qpeBsV7n7lq47FrHHRg+UNCmjnf/LANAz7DUXDgkYHLS/cDNXjDpx7DVbOTpjhzagxSDlXbr7f/Py+1BedR5Om4EIvi65qxBkG5lUIPVoFzflgN7NnDZoeivnpj8yUZavjtR6pmTlrDmpkSKqL3OI+OVqMJAoF6fIiZpNz+kOR/gXNiyR3FdtEIMWJrpF/Qbit9Qye0E//DUH63Hl4heoHH0TWA==;31:YVPBBhqbbBJpWsttHONWEQ1Pf7pgJEDn+Ba2NY93DZF0/fhhtUXgHCoyzUr+DSLk4XfOW2gqAH9FHIvSXrSy0674DSxWCgFTjptIuQHjK/e/nkNSaRPfSuS21n3z+2kDkdIKO9V9zGTW/pjAMaiYVL7MVh9rU5ohGjdMTYNufgDylTRXJvyj1PcguOFRW7NG9uNJFe+YdfqaPKDKBOhOU0t3bOaVEbCGl8tZqQeL7ik= X-MS-TrafficTypeDiagnostic: AM0PR04MB4211: X-Microsoft-Exchange-Diagnostics: 1;AM0PR04MB4211;20:azmr4IE27z/yJD49GH9JQSk1NLaZxZiNvhZWyqGYL5XYX86DJvAIIJ6Q4xDndwGf1oSftNBU2fHUEaJ4B3I5NAP2GTS+748mxkVZfBHhfASEeFsIVr9xviP64j09vIqSftGGHNiGzdWPkst9Jk9oXfBUoo4wOOaTebIwvQTtzdn0ybXFtHxDj8gwabxFBN9kL7wRT6W4TAiTRswyreFamIkLNZzxlEzsyVLe6mxSKDNzOuJ+6rVrwGXhRPEJozjX1tvEZ+naAcCLALtTBQYoUHMGF8gTRt2s+hwJQsrWtwTeeyTy4/5WVd3RRmNuXyalLXGWYqTgTde7e089pwv3zoCEK2vDXXCDNq/AMfDdzC3G3ommeciO7AbBd4hIpq+ub4x5V0Sy0st7azqoOc9YqYjziQkRGpNjOnkV9HkDXVgYbzYSU1AJaavx823rZ5dfXSDfRF2yZQR/K1d8jTEV3TpliptyTdE6esoyIgybOT/IaM0w+9L4zmjxNWY8k/nc;4:z1B3PjfI8Kact8tL8xHEq0g54f4Y77P8MKFa6tiX5m6W6L35XYb/B2zraYOuksl2LQP7SKzC6iCEkXcLPtE3tGhRT524rsflEiLMs+joIYHynhjHDzqoWRzhMDaxBOfm2o93D6JKXAZqqlk0AEGEPYRcATlRRN7yZBK8IcgKl/jG0sU/eWnKebTspDfQqfwLbgK3qTbPdMMW1CWlVc07oVA18enqsIk92Vy8B4ZC+o0yTSM0UUbULRq+7g4y5ODxyVqdM0f2dlclqEIbRTndRT5aHs+P/XmmM7B7l/mR13h9ZDg+OAgQY2q8A9pRX0nxX/Jh9Dh91dGQQ6WVHRaKAdjhrfF2lqZgYmojsKWlAEZLhkMiUWgCRpWggYQVYSg0g87P55rpUrf6n36+bx++cfI/IXrgdXT+CToruo jJ9aY= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(9452136761055)(185117386973197)(7411616537696)(228905959029699); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(823301075)(3231311)(944501410)(52105095)(10201501046)(93006095)(93001095)(3002001)(6055026)(149027)(150027)(6041310)(20161123564045)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(201708071742011)(7699016);SRVR:AM0PR04MB4211;BCL:0;PCL:0;RULEID:;SRVR:AM0PR04MB4211; X-Forefront-PRVS: 077929D941 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(396003)(366004)(376002)(346002)(39860400002)(136003)(189003)(199004)(51416003)(50226002)(3846002)(6116002)(68736007)(2361001)(8676002)(50466002)(48376002)(2351001)(2906002)(97736004)(106356001)(105586002)(36756003)(8936002)(7736002)(305945005)(53936002)(6512007)(386003)(47776003)(81166006)(6506007)(14444005)(7416002)(6916009)(2616005)(4326008)(26005)(446003)(16526019)(66066001)(25786009)(956004)(81156014)(476003)(86362001)(186003)(76176011)(486006)(5660300001)(16586007)(316002)(478600001)(52116002)(54906003)(6486002)(11346002)(6666003);DIR:OUT;SFP:1101;SCL:1;SRVR:AM0PR04MB4211;H:b29396-OptiPlex-7040.ap.freescale.net;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: 1;AM0PR04MB4211;23:wj2sW4Prl5wm8Ps0Yrq+DNYflHRP1EY+owJ7MGrteCVcuTFd79ZgEGLOm4huGf1LHrBb0ULac955dVMiOGsc6d/rNOoPO2Y06xrAOk5I5H6dzpM/RiF5nrCuI7sGWbJYb/J4Nc/d3aQhGl4FExMxeUYFcJQ9cdUO8n7g7OHE8IUT8xO3O9wSwWolijlTzEjK5uJn8lEzmpQoc/pFHV+S0QzkpZx8dsLi4g2rBZXZQ0xXwYHmVcr+gF4sWQguPiNt7Gb2tOtzD74aucFPuaVe1soVfzBUgO0UDPjxTSQA+4rMqVY1mu/6zSUOuyPvFzhPJACDrmviYUTV2+Gp27zlA86Fon1vOm/IKqksa1KSlOQ8gY1x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p8VebHzbFiL9KB7t7WAG7Mx7FI9WXXBQAJATYqw36k/clG1+uk/Flwy4RK/oW+Me/7dhYCEPS9 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2018 12:55:27.6854 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ed464481-d1dd-4eff-0c2e-08d60daeb493 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB4211 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 Switching to use clk_bulk API to simplify clock operations. Cc: Hans de Goede Cc: Bartlomiej Zolnierkiewicz Cc: linux-fbdev@vger.kernel.org Cc: Masahiro Yamada Cc: Stephen Boyd Tested-by: Thor Thayer Signed-off-by: Dong Aisheng --- v3->v4: * no changes v2->v3: * fix a build warning on x86 platform due to a wrong of the prototype of simplefb_clocks_enable v1->v2: * switch to clk_bulk_get_all from of_clk_bulk_get_all --- drivers/video/fbdev/simplefb.c | 66 ++++++++---------------------------------- 1 file changed, 12 insertions(+), 54 deletions(-) diff --git a/drivers/video/fbdev/simplefb.c b/drivers/video/fbdev/simplefb.c index 9a9d748..ed9a4c8 100644 --- a/drivers/video/fbdev/simplefb.c +++ b/drivers/video/fbdev/simplefb.c @@ -182,7 +182,7 @@ struct simplefb_par { #if defined CONFIG_OF && defined CONFIG_COMMON_CLK bool clks_enabled; unsigned int clk_count; - struct clk **clks; + struct clk_bulk_data *clks; #endif #if defined CONFIG_OF && defined CONFIG_REGULATOR bool regulators_enabled; @@ -214,37 +214,13 @@ static int simplefb_clocks_get(struct simplefb_par *par, struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; - struct clk *clock; - int i; if (dev_get_platdata(&pdev->dev) || !np) return 0; - par->clk_count = of_clk_get_parent_count(np); - if (!par->clk_count) - return 0; - - par->clks = kcalloc(par->clk_count, sizeof(struct clk *), GFP_KERNEL); - if (!par->clks) - return -ENOMEM; - - for (i = 0; i < par->clk_count; i++) { - clock = of_clk_get(np, i); - if (IS_ERR(clock)) { - if (PTR_ERR(clock) == -EPROBE_DEFER) { - while (--i >= 0) { - if (par->clks[i]) - clk_put(par->clks[i]); - } - kfree(par->clks); - return -EPROBE_DEFER; - } - dev_err(&pdev->dev, "%s: clock %d not found: %ld\n", - __func__, i, PTR_ERR(clock)); - continue; - } - par->clks[i] = clock; - } + par->clk_count = clk_bulk_get_all(&pdev->dev, &par->clks); + if ((par->clk_count < 0) && (par->clk_count == -EPROBE_DEFER)) + return -EPROBE_DEFER; return 0; } @@ -252,39 +228,21 @@ static int simplefb_clocks_get(struct simplefb_par *par, static void simplefb_clocks_enable(struct simplefb_par *par, struct platform_device *pdev) { - int i, ret; + int ret; + + ret = clk_bulk_prepare_enable(par->clk_count, par->clks); + if (ret) + dev_warn(&pdev->dev, "failed to enable clocks\n"); - for (i = 0; i < par->clk_count; i++) { - if (par->clks[i]) { - ret = clk_prepare_enable(par->clks[i]); - if (ret) { - dev_err(&pdev->dev, - "%s: failed to enable clock %d: %d\n", - __func__, i, ret); - clk_put(par->clks[i]); - par->clks[i] = NULL; - } - } - } par->clks_enabled = true; } static void simplefb_clocks_destroy(struct simplefb_par *par) { - int i; - - if (!par->clks) - return; - - for (i = 0; i < par->clk_count; i++) { - if (par->clks[i]) { - if (par->clks_enabled) - clk_disable_unprepare(par->clks[i]); - clk_put(par->clks[i]); - } - } + if (par->clks_enabled) + clk_bulk_disable_unprepare(par->clk_count, par->clks); - kfree(par->clks); + clk_bulk_put_all(par->clk_count, par->clks); } #else static int simplefb_clocks_get(struct simplefb_par *par,