From patchwork Fri Aug 31 04:45:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aisheng Dong X-Patchwork-Id: 10583133 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 3BD3C1709 for ; Fri, 31 Aug 2018 04:50:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 29FAA2BFEE for ; Fri, 31 Aug 2018 04:50:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1E0402BFF8; Fri, 31 Aug 2018 04:50:04 +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 311602BFF5 for ; Fri, 31 Aug 2018 04:50:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727426AbeHaIzN (ORCPT ); Fri, 31 Aug 2018 04:55:13 -0400 Received: from mail-eopbgr20078.outbound.protection.outlook.com ([40.107.2.78]:42982 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727211AbeHaIzM (ORCPT ); Fri, 31 Aug 2018 04:55:12 -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=u+6NEH7Zr5SRGWO/XaG+8Pc/E0QQ63AsQolWsP2YzPoYSL+LCAzdkEhmaPXjlshRkL1QVZBPxqR5nyjq9pQcxBTpXTlxhNGoM8zX0k2jR/5hz9kS15pfsn40Ypm5C9b2D/hASz8MkbkHBsy5nHVt8B5pcYjIJ8RnGOiic1qztkQ= Received: from b29396-OptiPlex-7040.ap.freescale.net (119.31.174.66) by AM0PR04MB4212.eurprd04.prod.outlook.com (2603:10a6:208:66::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1080.18; Fri, 31 Aug 2018 04:49:29 +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, hdegoede@redhat.com, Dong Aisheng , Stephen Boyd , Russell King Subject: [PATCH V6 1/4] clk: bulk: add of_clk_bulk_get() Date: Fri, 31 Aug 2018 12:45:53 +0800 Message-Id: <1535690756-22234-2-git-send-email-aisheng.dong@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535690756-22234-1-git-send-email-aisheng.dong@nxp.com> References: <1535690756-22234-1-git-send-email-aisheng.dong@nxp.com> MIME-Version: 1.0 X-Originating-IP: [119.31.174.66] X-ClientProxiedBy: HK0PR03CA0061.apcprd03.prod.outlook.com (2603:1096:203:52::25) To AM0PR04MB4212.eurprd04.prod.outlook.com (2603:10a6:208:66::22) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 210ac8fc-ed9a-4f06-50b4-08d60efd2537 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:AM0PR04MB4212; X-Microsoft-Exchange-Diagnostics: 1;AM0PR04MB4212;3:34JX+g54hAowwSSp6B2gWkZZdvsCiFTl++od2/nFqjZCAz9T/5F+xxA62vQ+u7DNciSWi9ILdAz1K3kLo+VqESxUJvBmGhaysTg9uR49pNIpSoi+ks+vqbhcbPvHMIyFLwNJruuO8GRAFYLTVkkKfhAUHrkYOulomB7e3IoVf3mADz3XNWC1QIz0yhyERr3PCp2OvSxAqleQ6DF8a2vHEfg/A41PjkZR26+Y0WXjycMW5mljMTb96X7Zk+dj04DB;25:So3a9E4g+fE5hGZx027Pq9TAFPJtBR21tK1iVWRgb2gfOnwWoSZQtXtQodJUYQax/HLZCnletYgVqvdwd5SmiLPDC1GEzXV6HNDNayM30i1QuAk1R6GYx9JiWiYVYs5jDmLbzZDFwKPYBkkuVPMZ0kL9P7XpIc44Djvzdu2MfCun6iiFbU8fKLI12ND6KA2epcpn6ht03cGwQqpjM5npsbhK2QvlhNzU2bTqgwseYPhtGpuL7djAk0BaSYnhK68fTQiSFGpkdQMAmLG4czobQUmCE6wI2W3hRP3Z1Hz/IUHJvU7iX2xzfsXVLYL8lLCiclV0/+gBSRzxm1whc7lpCQ==;31:jH8vk+VzlOJNep4/g2zRXhnZnQ25cnfASYVu1ftVdLZabdyaVkgJ0wUoWwDccqva1Lk6GpoWp2IihZ5IE4SHwRDxXgxpDperk2iHTMYWQIDJLTJF7Y3eOJU3q8RB725mQVv4UyVgKfpgvKtSiWOolcEWN1liUfy5vrQBTxC4K4jm/N0r9brKhu7G9t1ImyIwkDIl2kSmS26niWkrQBL1H0b2wn3tKjwHWqg+8JgMl34= X-MS-TrafficTypeDiagnostic: AM0PR04MB4212: Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=aisheng.dong@nxp.com; X-Microsoft-Exchange-Diagnostics: 1;AM0PR04MB4212;20:mJFtbdPYRNEmDxvoxW8sIfsPncOLecA1YYsQ44jKNFrExpGIEPdp8U+X5iX4t0V60j/HZC61kmRrRy/x//dg+31nYx4lnBey9niWNx2+HxitOy+myWbZRfqfsZi0f9lYTYj/1xMBJ8vyugjGhg6yiAhXyXqEBKzrCWjS0FTC/yPJ0D9+WGGWdQZ2JbddkMKDmUUhzG/1tAfOu79HIXNDmkbmI90kEuGKPAWiI2b/QcdiiE+szq1d8DZC6ah6gk9BBrBdj99nFiwoXHKssQr7WcBPCcU2r73c6+3F2XBKcmmZ4zrydj5d3PGpiA50jVWC80STY+RxOvhZjMkHuY4uD90qIQB/6y+1r6Y7FAzD7mO/CYAdc402xS2zUMnGo2Dx6tzrX+/YerO8vku0xtKWpyBqmhk0IGBnaAod0xEQs8gS+BfBl7aCypHzVIPIOHag36Cqe7nYlZxVWWowwGzPaYvkWNxNmhHmof6VPit9iYcdZRgUO3SkqsxSWC9teqCx;4:PmW4f9pJwhOlQ0Ui2vD09qEjNURhm/2QlXY6S1KXX/wHq/HKy8tkCixFe4WBQDyXIsi4qlkNxcO/ZelV/5Oqetwxd4eLqO52HDIOFm3AaOxWvfJIBJrphOny+BiExzcka5Ow4t3pGtFMlEg5iz9qfMazvr5xRKBtNZgdeKYIK6WrBi2afivy4l98Gp2YOcI8p9sRvaFHMsjelgDF8rMqbJ5+Y7oFngPZdRuo1s2w2TkqkYWctqh+rl653Roqs9h0jCmwH3lzC+BFFABsxoUXC3tMmdrq/C8RG3/Ml5PjmSSN+KKnv9C0BKbGwn9Hxf63kKytSwU5OBXtdK8QtG7CD35QmLGZxg8a+/kNW6+fa6I= 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)(5005006)(8121501046)(823301075)(3002001)(10201501046)(3231311)(944501410)(52105095)(93006095)(93001095)(6055026)(149027)(150027)(6041310)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699016);SRVR:AM0PR04MB4212;BCL:0;PCL:0;RULEID:;SRVR:AM0PR04MB4212; X-Forefront-PRVS: 07817FCC2D X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(346002)(396003)(366004)(39860400002)(136003)(376002)(199004)(189003)(5660300001)(26005)(52116002)(186003)(47776003)(16526019)(2351001)(2906002)(6666003)(386003)(6506007)(51416003)(76176011)(446003)(11346002)(53936002)(2616005)(105586002)(486006)(25786009)(4326008)(6512007)(476003)(956004)(36756003)(66066001)(478600001)(86362001)(6486002)(106356001)(316002)(16586007)(6116002)(3846002)(50466002)(54906003)(2361001)(81156014)(48376002)(7736002)(97736004)(305945005)(50226002)(7416002)(81166006)(6916009)(8936002)(68736007)(8676002);DIR:OUT;SFP:1101;SCL:1;SRVR:AM0PR04MB4212;H:b29396-OptiPlex-7040.ap.freescale.net;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: 1;AM0PR04MB4212;23:/0d+WHTBrNMP607HtM+xhJIcQnyPeARm32JCpF9OUVEjDlCa7pcSGPfcTqC/VS4Dz2+6Ps29oxLXWl4mCDu9GzoigtGhgz0v0f+DNmPNo7iOClCyXsykEL50D6gj91l/mZSEpEsk0wMl6Ifel7lqY8WCTXFMLaIUDkGQKgteFlilJiMTgoctmtK5WWQofRqNRzlqiPH3J5OXbdqF35KTQ0bcGDgaQBQCQgCUYyZTH2jjIzdy9eUJDqntTBO0KhMvauattKbl4L5LoFepChhee2UxBXy6O6R1MalbUBVE0udZyG9OoAb3LrV8Ml43Smd/K5KNP5/uoWWIVmCrD3hQBoMo0l21chdFFPHcWk6nLnmZwITrqDBoVnO1Gq578to9nP33LcOoJSIBgrFJ+3RYHt8Xgt1/s2ByQMeWF4ntJXKvxtA7HDCnDKX6TvNGMGzZFU56PEfipEFNzH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99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2018 04:49:29.7150 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 210ac8fc-ed9a-4f06-50b4-08d60efd2537 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB4212 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 Fri Aug 31 04:45:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aisheng Dong X-Patchwork-Id: 10583131 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 BED751709 for ; Fri, 31 Aug 2018 04:50:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ABAD92BFEE for ; Fri, 31 Aug 2018 04:50:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9BB432BFFD; Fri, 31 Aug 2018 04:50:02 +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 05B002BFEE for ; Fri, 31 Aug 2018 04:50:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727457AbeHaIzR (ORCPT ); Fri, 31 Aug 2018 04:55:17 -0400 Received: from mail-eopbgr20080.outbound.protection.outlook.com ([40.107.2.80]:11232 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727211AbeHaIzR (ORCPT ); Fri, 31 Aug 2018 04:55:17 -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=aGiyY93UrBqIa/C5s/6WSsvNbUkBAz9BNS8BsEMCTO/PlbQjk/YPccxHC83mtyrUVjPKyo4OqyvvS6H9ifHS4BcYaQCLw+rolguKTJIO/twAL2vVfp/76+DrETy74Cr+kFmAVpUzGbQ/SNgxy5qkcJiaSBcjg4xL8VbaqhAeLwo= Received: from b29396-OptiPlex-7040.ap.freescale.net (119.31.174.66) by AM0PR04MB4212.eurprd04.prod.outlook.com (2603:10a6:208:66::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1080.18; Fri, 31 Aug 2018 04:49:33 +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, hdegoede@redhat.com, Dong Aisheng , Stephen Boyd , Masahiro Yamada Subject: [PATCH V6 2/4] clk: add new APIs to operate on all available clocks Date: Fri, 31 Aug 2018 12:45:54 +0800 Message-Id: <1535690756-22234-3-git-send-email-aisheng.dong@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535690756-22234-1-git-send-email-aisheng.dong@nxp.com> References: <1535690756-22234-1-git-send-email-aisheng.dong@nxp.com> MIME-Version: 1.0 X-Originating-IP: [119.31.174.66] X-ClientProxiedBy: HK0PR03CA0061.apcprd03.prod.outlook.com (2603:1096:203:52::25) To AM0PR04MB4212.eurprd04.prod.outlook.com (2603:10a6:208:66::22) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e4dc8375-e66b-4290-96a8-08d60efd27a5 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:AM0PR04MB4212; X-Microsoft-Exchange-Diagnostics: 1;AM0PR04MB4212;3:vsR42QjYCeb2B5EWlpSueHHlHUzejhfHc+gEl9g1B3AcgaRiXl6rXOauPq/vUEmT5cXJVzURC3Clr4SFxyuKCmWw8qRQ/ROxz1r3Wy9DzP8joeHxuGHsqKfk3FmRB0bl2oL0owNouwyYAVH7jlxD6abKkrdBqlyq7b+hzcZsnv1oZbfuOBBh7o93ZrlG3DRkggK/rBnu4BDmall4R8IhL1MOkaA8Q3FtFEGu0jSNx9oqmlo38wQeR0nsfWSeABKn;25:Fd/N7LLxgIghDcqfvCxkq/Qb5DUeSzcYRdESkkkwyqs1MnIrjo13+0sQ7G93yj7kNfE84TZ6BSB58sDyuFXFw/21hZrAf987szCtHm9ndjXXOgncYpKhCtZru7V7MnJqNAw3+Vd9dp9ElHyAkMOT3lmIkoKoHmMLQBCYKY57/orShyInehF1jhbQueM6y6EZXfonYwfGWhhN2lYXwgA1SzzfO4zGgBEx7C9E3SV9D67/xZKC1H445imy2t3MMgFluYsJrd/heg1bAWkG+aSLf4piudrDz9olvX0BDN2mK/isLd7drq9/GmndBZtfM8VTYEWsPP6pjpmkvMLXCHGFhg==;31:LBQrH+WBcq4fvQOyh3PoQrv3ui/+EGyZbBpw//OxV9FREsmHu3PeCtGnItuQip1CKNtGmeRQcLoJSl2UkxqZsRA1UfudCXeG8wBKNb198RFuYI9niU1y9dXXwz6AZE3LEmkA/a/C3vSrOjOt7JPOPM9gt1aBNW+7I44Yyct6UPLwRwm9O64+pdFTyutFQPwVOXxNZZ5vfiqd2O4AuT3nMRizfhG8FDt6QXmDIAtf26k= X-MS-TrafficTypeDiagnostic: AM0PR04MB4212: Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=aisheng.dong@nxp.com; X-Microsoft-Exchange-Diagnostics: 1;AM0PR04MB4212;20:6tG7GyRcFxlT/Kuk9fiIKxJ4u8DLgzzJrtL/zKlA2VvRgmpXXKmBFL3/y/nFMx5buMJFNw07MjxFwBolSxW/mdgedvTgeH0k7bXWuy7/l2ZBesuBOFLIXxGjd2QlreWkPLH15rdQX2ckkk4UKMyCjOZHQPEsXC6AvDlzxOCug4Y8xaOx3T2VrKTPQbwSIr6mKatko/jMeoo/YwIslsLm+G+8669OrVOxw0YD8rODYREkayvDw3OvhoMw869yT1Gjnn5sH0AFJdYvLrJzDpM6aoGm+yk+koEYTfhfSgeYYl/QUxSD6+bpPdQFrSnGPIE3QvDqzRAe7irLOwxoZX2vsvl6cE5KcJVZ2Iyp593JqP4KG4uyx0V2rOPRAa0fWfFdSeEAIMIE38YCmTuYd1JRCPG6mM4wG0EEjy297gEo7OKqki4LvFxUt+g0eeC8qDid2rtL+QKCcp8EQFwoniGqZ9MKITgVxfhsws6H+ag3qIyr6fr/ltgNwsktguCheIu1;4:Z5OtRLMcmw8mTsvUIbxQTt/KxlXR+r4W9UO28YQ672Ro/LBY4PlJqsPE2z7uYbliEbD/YYb+B8FoyHzvbAUHs6vIywOfbF0H66PNiYFdI8DStEGROGM61fEQXdu7vxiRS27j0LbpF4JOj6i6t+WIEE2OYDl/k09L+OCSvFOrs26pGlpB2o6wvOjtplp5WIBo2Xx/OLlveA9iROGWRgVu+ntMUOb0kI0NKPkPWG8C6oo9xdq66aq16g5JepExwxHqGgdKf1Z8MXXEwqc/Bry6JGUwstJxSZpNkG2qJu4xVud9sGDYyYKbWejD2XjhdxLv/p3gB+oldTHCcJk2+efbAHUtB8/LMjbPmlegb9C2oIU= 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)(5005006)(8121501046)(823301075)(3002001)(10201501046)(3231311)(944501410)(52105095)(93006095)(93001095)(6055026)(149027)(150027)(6041310)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699016);SRVR:AM0PR04MB4212;BCL:0;PCL:0;RULEID:;SRVR:AM0PR04MB4212; X-Forefront-PRVS: 07817FCC2D X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(346002)(396003)(366004)(39860400002)(136003)(376002)(199004)(189003)(5660300001)(26005)(52116002)(186003)(47776003)(16526019)(2351001)(2906002)(6666003)(386003)(6506007)(51416003)(76176011)(446003)(11346002)(53936002)(2616005)(105586002)(14444005)(486006)(25786009)(4326008)(6512007)(476003)(956004)(36756003)(66066001)(478600001)(86362001)(6486002)(106356001)(316002)(16586007)(6116002)(3846002)(50466002)(54906003)(2361001)(81156014)(48376002)(7736002)(97736004)(305945005)(50226002)(7416002)(81166006)(6916009)(8936002)(68736007)(8676002);DIR:OUT;SFP:1101;SCL:1;SRVR:AM0PR04MB4212;H:b29396-OptiPlex-7040.ap.freescale.net;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: 1;AM0PR04MB4212;23:/6vqMsdSMNQ3CAwXz9y37ccyHRPDoh5rR6qJCVZIGn/vaOERzfT3bEFrUkamOvhEswu2s0dXcZde95mnVBa+dRjuExh/EwPiagsiuLHx4UdAK8a/fEzQT9Q8Ito2AsQbgTQVDkpj1nUsZgr7KAB+eTYhcMHRQOZK1qFXgCxXApklsjCiJXqWfGmXH2OyJPlmaMdFAuaoUieBlZK7tw9wAdC3b+dq4bDVCBwjRNFWpqAtPYvJrFXZUnKYJ9Ryr1mlOHMI5nB55MuLY1PkLJOfdWKn2MHkVwFJhuCnb2cmzym2rCG+OgE6hHIoRCmub4dGTmM4dMziXGs8tWR4ISosm0gutUaPKkcwu0k7MGcGcDE6xtaxwasdRFe/xjisxQ6YO5906QEeXyTg1zho9H41fIlqXZapg/JAJEN+Ey6u/xergMGkkIPrhEgvxhsYdGGS3ta8mYHz1N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 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2018 04:49:33.8088 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e4dc8375-e66b-4290-96a8-08d60efd27a5 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB4212 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 Fri Aug 31 04:45:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aisheng Dong X-Patchwork-Id: 10583129 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 BD99E1709 for ; Fri, 31 Aug 2018 04:50:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ABE1A2BFEE for ; Fri, 31 Aug 2018 04:50:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9FC352BFF8; Fri, 31 Aug 2018 04:50:00 +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 10B362BFEE for ; Fri, 31 Aug 2018 04:50:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727496AbeHaIzV (ORCPT ); Fri, 31 Aug 2018 04:55:21 -0400 Received: from mail-eopbgr20067.outbound.protection.outlook.com ([40.107.2.67]:51856 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727211AbeHaIzV (ORCPT ); Fri, 31 Aug 2018 04:55:21 -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=WpJozmn+5SK+c3l6+BtdFY+gbwDbPdu19WCzDwJ+U8uv0riCgfapnRepNHLjwpqHMizUKKQP28I/hR4Ib76LYE05pzQ/C95dnyNFrUxX3QUjiOaZKMYkere5WQQnvo8pF7a+EImkcBUCLghuDPC7cbezrp3o/XLvMhH+BrshFMM= Received: from b29396-OptiPlex-7040.ap.freescale.net (119.31.174.66) by AM0PR04MB4212.eurprd04.prod.outlook.com (2603:10a6:208:66::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1080.18; Fri, 31 Aug 2018 04:49:38 +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, hdegoede@redhat.com, Dong Aisheng , Stephen Boyd Subject: [PATCH V6 3/4] clk: add managed version of clk_bulk_get_all Date: Fri, 31 Aug 2018 12:45:55 +0800 Message-Id: <1535690756-22234-4-git-send-email-aisheng.dong@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535690756-22234-1-git-send-email-aisheng.dong@nxp.com> References: <1535690756-22234-1-git-send-email-aisheng.dong@nxp.com> MIME-Version: 1.0 X-Originating-IP: [119.31.174.66] X-ClientProxiedBy: HK0PR03CA0061.apcprd03.prod.outlook.com (2603:1096:203:52::25) To AM0PR04MB4212.eurprd04.prod.outlook.com (2603:10a6:208:66::22) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9ec1784c-4091-4c73-5339-08d60efd2a0a 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:AM0PR04MB4212; X-Microsoft-Exchange-Diagnostics: 1;AM0PR04MB4212;3:JB6FcyAA+WylosnqxeoNXRwrZ+1WvL3jGKYWlSXJG5+1/5SiFTkQXIrkv3WdHfl2ci33NvKUwAQ4yxP7e0oPPL2RgW4mhZiotvOeLww+OsadazOSXCvhpBFnpt5uXJtcAQk7bcJRGBunO5h8jqt8DuDxmwvnBJ38eGgN/oPRRIJdqAu2bRwvWdAbDqKZ4x8CZfvaRW02UUyF4HFl7D7KagkFbF5C2dAERhTZjdufJVZlYFhxHEIaeCyRpxgBLoa/;25:Y21JppRwBgla7eKU8gwJSl09/MekUZw4wlC0jUFkbkouJqQ/VwgK5XcPLTeNghJ+YlkO/DNIaH5HT4zdPZSSOWVypii9qPv4ny+/oe+mA9XszAqM2FPNqn8/H3uZ9+NU4snxcdp7Rz9orm/bkDvdGFZOpX39WBc+iVgtnUXySiPpPp1tCT2WxfsVTC5dd401XRCpJwtmaUHMDrpd0X7nyVaJC6yqIMal5Ykz5ZuAhzaE3ApEV5fhtt6hz7Us4HZeWk7EcxfYb9WNOPS60VNb8aEpE2ZHzrkNTvuqMf4MYsXgdxDpE+nHSwnNAEyASh5zGXXCj/sPDWxV8bZN1s6KKA==;31:7HSD26gxzyp59lmzgGscvpKYg19YAhQCQFw1x5QqgHXJtoUKEDFGNVyoZ1ylAK9Iox/y3VwBVtnhIT4zlNP8qQJFFDuOxEZqiBoJh1RQQ0uoGhqM0BgkKQn0EgfV7oCDvS6LhaOOzeiMTu09zAasjiQGFYtUI47hE/TN2uoKaj1qlRzOZpQXzvwT3vm4+nEdeJz+jh5LEXC48HRIlEjj8fPhaY92Y5uMoxLjlQHFniA= X-MS-TrafficTypeDiagnostic: AM0PR04MB4212: Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=aisheng.dong@nxp.com; X-Microsoft-Exchange-Diagnostics: 1;AM0PR04MB4212;20:QGPgbYAb1SE/yACLyiPGZXpWv1bqW1Qn7qgpNJ/+s1HnbiewHriX+iSkMQ+5126LxihT29GQqnP0NbGGdT4YwCrSCtelLDr+uYi9JDanLCNhFLv6AID8jrm5caFoUYh4CYFfpIGmSDdvffxmSojssNUui5rxckTHIhfkDqP/n00lWfmSb7MHPrp9tYjZgNP7TQOWsz1mYjckux1xDH72DKPpw9FAhlOK9ai2s+6f0HcpJgMnAf7yKCculv5lHbgV2Nvcu7V4d+sEJZa1Qzu2ZWICQmdeDCW2TqPB1bcpLqPSS4fluV8F4W++puizTM0DVdHfWpMos8nLiHaTEdnueAj1CxAVJWXRqQM1l99+OM6o+AS39M5HDUbL3/8A6n3tMe8g7iFZSrovmnpWGVPkQMi1BRVC9tGv36gcCJOXyyDesjcDv6aWneGe8bQzBmWO8zb4CyWr6+gRsFgdUDMMNl6SUAFkujo9xaJaeRDB/9mN6zbKcfeTHrTV79IH36xm;4:jMXu11gtYkM1B033D+QdX7m9VKtFiH2nnPhYqlYMQeNc7nZSRVglzorO3wZPCZ2SnVRX+DawKpO7pSifFOf+AbR9SOg9PzC2QY+EMIaiXMfNgJ7idwa+YAX53F0AJI9Tje342/H+007GC7DEbLT8Y4DRG/vVh4+7ABo33OJbXLglkCW9Up8tBtmjKk/w7TV1uVx62CPLlHoOVe5DRoGrOM+rlHqhEzXwgJcXE2cvL01UU16DCKv7V/iTT7aloUoDFBDaLQqxCZusaBrHv+3vL8wEpEil6w5FJltP0WTGe7uRlXnlMY+2SXmHGt1s9Mwif9FxDg/qJ/mhNuL23a/2tgLM81FxnLLYZT1o2GZigy0= 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)(5005006)(8121501046)(823301075)(3002001)(10201501046)(3231311)(944501410)(52105095)(93006095)(93001095)(6055026)(149027)(150027)(6041310)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699016);SRVR:AM0PR04MB4212;BCL:0;PCL:0;RULEID:;SRVR:AM0PR04MB4212; X-Forefront-PRVS: 07817FCC2D X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(346002)(396003)(366004)(39860400002)(136003)(376002)(199004)(189003)(5660300001)(26005)(52116002)(186003)(47776003)(16526019)(2351001)(2906002)(6666003)(386003)(6506007)(51416003)(76176011)(446003)(11346002)(53936002)(2616005)(105586002)(14444005)(486006)(25786009)(4326008)(6512007)(476003)(956004)(36756003)(66066001)(478600001)(86362001)(6486002)(106356001)(316002)(16586007)(6116002)(3846002)(50466002)(54906003)(2361001)(81156014)(48376002)(7736002)(97736004)(305945005)(50226002)(81166006)(6916009)(8936002)(68736007)(8676002);DIR:OUT;SFP:1101;SCL:1;SRVR:AM0PR04MB4212;H:b29396-OptiPlex-7040.ap.freescale.net;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: 1;AM0PR04MB4212;23:mepacjAbXBWJ7wZX0xtp98ux4F2PjcB4gOvbjquaaba6QlGy6a2B8bUGapR8Xcefp1oz5qUtGxRovYyi7rTFOcOQfNPk2FXekGSgbpnfsBKMc2JQH8ULEyTtmI6LlRgzFXnxsjEq1iYY13FGe7Zf02yCK27bTnfXd9XfBJRL6tEytXnBNHlyHINyrY1YzsKC3oTHv4IVR/ekOywOPpj1Pv3p0RukYybrxO4ZnQIOI6t9gfGmZJWZoLPi6hnSmhVFIjxkKfWNHuY+NYhD/DqIYlkIINj2S+Q/+jOqwqMrx2URAKosmR/n3ZT9d1saB4lXIVzyyLI7OuGtvIxFOfpgZXRSLPjdLjFJ3ArhbySUromQp8S2kMI8Y1FwXh8hr2OjbWtj0TZ3GKPg8XzMQN0kmXBBXHD3fpG7JYtuQUdgaeQWvdcDE/Klnnt7ZRx74F+KCZDVyfZHfpBfK2+uXVqASj4oVxvQpISIAYJ5LTziVk6bcAPlEXT6T9SGkwc4gXt5VOe7t8hsMGLDt6XydypF7cMrJLWJOk7FErHhMuBWHUSpMHmWkptewTxq2kNlnv5/haEb74XZX3Imx4f2xoolM1IS/wVG3cKzWfRgclpT47hAJLLr+eCUzw+YbOQUbbcJtaU+j1NgwjkcnQbu/Ljv+fgljA8jhk/rxrjpWJrb4c+nLd9RJcR4D4cex4t7mM2Q36TUe5PBBPhB1O+2cUtNrq6i+HAGhLTeuY/0qYBPOKfz67m1eEl7T5Vj/figL6cdqWw/f0rKPcoPaOP8QSa/bQSgm+FZU0ogk6FiNHJTfKVFH4+dx0FKm1XreZKnUZo3T6xnOheTO3+oFrTfbYNk1SgcKeJ+6rMECGzLb19FpHKHlDwgF3TOu9QHJ/ayy8WFXWM4OUX+iQ6Eil0BeMSy7LXqpDUXuKUrmGgmn8G8dLwK+ccDwo6CsoZoRLrsYqabVM+EZWNH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Dq3Zb1t/pHJPAK/PyBiVc0xVrYCjmfr5LZvd+7owvAU0kePY/3FGf7uM+RHY8+Ix5Hvruuoy61DiPz8keZJ4hRxe1ZDxZdS4Ag==;5:T3GbIud7vBpuxj1qqphIuk0e0yqkQGoIlx9VDeXMlaWU+dJFOIxHc6/mHVVU0xZD1Z7zPBEaq2wYPB922ps0eAcyaJ9LlAGVUuEZal27ruFJcQGAeEI4LGtuxWF+r7QUCm+Mai5VVZcMv25QndRZsCRmNdZ5ab9a2zx72lrrBKI=;7:f9lYVpnJxHJH1jEXT2zjr0A9uGST3N0alFKw+rAjeLIP3Hgm9hAkrzNiDjJrm8NWBOVpvxagrn7qQo2pvK74dwwPxmiOCoqVR+jS962FEqMmMA39CUJwXJAT/m5UouYvBZl7StR1c7dR9iAAXs/gCcdjTucTYb+wmnYKra0uj04/jpMn1yY6x4Ej5XJY0kEHXaVNGJiQCAn/gCtzDfMGnQp6NWk37azxU0zzBAkwBo8wbE++LGstE6H5+DGet+8x SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2018 04:49:38.0744 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9ec1784c-4091-4c73-5339-08d60efd2a0a X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB4212 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 Fri Aug 31 04:45:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aisheng Dong X-Patchwork-Id: 10583123 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 147BC1709 for ; Fri, 31 Aug 2018 04:49:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0428D2BFEE for ; Fri, 31 Aug 2018 04:49:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EBABE2BFF5; Fri, 31 Aug 2018 04:49:54 +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 279372BFEE for ; Fri, 31 Aug 2018 04:49:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727572AbeHaIz2 (ORCPT ); Fri, 31 Aug 2018 04:55:28 -0400 Received: from mail-eopbgr20085.outbound.protection.outlook.com ([40.107.2.85]:60361 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727211AbeHaIz1 (ORCPT ); Fri, 31 Aug 2018 04:55:27 -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=b/thw4qAY2AosM13kzicMCmSaCF3HITh68iWufgkEdI=; b=wM1oDeWpI2KA+tmR0etAQXxl6wZ0DKQGn//wSfhAdHLvkxKW/wW0Z7eFnphxQINu9EXz67MDVcW/xEznJUM2c2I3MPmbBEqMqPc1Dc2ecnDFN2NtsyQG1HL9iQFP3EAxQrKWb9//E+JUodfFynWfMLFzB6ifisBHtLu7i2i0Jxg= Received: from b29396-OptiPlex-7040.ap.freescale.net (119.31.174.66) by AM0PR04MB4212.eurprd04.prod.outlook.com (2603:10a6:208:66::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1080.18; Fri, 31 Aug 2018 04:49:41 +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, hdegoede@redhat.com, Dong Aisheng , Bartlomiej Zolnierkiewicz , linux-fbdev@vger.kernel.org, Masahiro Yamada , Stephen Boyd Subject: [PATCH V6 4/4] video: simplefb: switch to use clk_bulk API to simplify clock operations Date: Fri, 31 Aug 2018 12:45:56 +0800 Message-Id: <1535690756-22234-5-git-send-email-aisheng.dong@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535690756-22234-1-git-send-email-aisheng.dong@nxp.com> References: <1535690756-22234-1-git-send-email-aisheng.dong@nxp.com> MIME-Version: 1.0 X-Originating-IP: [119.31.174.66] X-ClientProxiedBy: HK0PR03CA0061.apcprd03.prod.outlook.com (2603:1096:203:52::25) To AM0PR04MB4212.eurprd04.prod.outlook.com (2603:10a6:208:66::22) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 51cb1034-2ed8-4d1d-0b8c-08d60efd2ccc 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:AM0PR04MB4212; X-Microsoft-Exchange-Diagnostics: 1;AM0PR04MB4212;3:QRWF8apf5hmSrsxuxtXue1I/3gou4De+oFd+AXm6e72BrXgIO4CZE0cdcCxDQauQ8RHhBFZLNmSnmuJBPhXCM0iKNtp56qWMmC9wiTUKc3wPvV45Y+c9nfauDV2kEzwvwYSTpIOHNUztJVFxAobk6Cvi606IxL8NMuMBHQMYamrouCTnCp/BoV2gHq/duBXElTKfb6bsnI0w2ziwcvmqcVTw0VrFiyGXvDzwaQe2AQ0X1r4kgAb4LwjsTlKaXaDv;25:CG4TFYjWXiLTFC3mGtfF+3vkl9ET2bOwh+QnuQw3B4oxLB2C2p9DiW4mzhFiY3yZXwjJemxVQj+z411LO979lXzmksW5pjhn6iR3IRlA14VVxt1746qTwJsgqPvq5fY+FjYXi2s72IOfiyJvBrFl5WUs9THjpGTfaua243zFtezsaLL1dRMCbwngCsU0dWv/fOAnFO6JnQ5+KJLH9d17mhJaa6zmFOvAXIWeRSF3+hF/GXSHebxS0Z61fFGxwILynTnRQSuUP+6n8F617I1ak7uyIQckaOLc2wgE/yqL6S95y0D1Pak7lLmEXUe3YRDrhlGI2YCLb5RRR/1l7nifjQ==;31:f/MAVp8MkwA4jB33q4ccrax8jnLxC/yUlGoV7hUP+Uf4CLwHBRAyCfB5OtYJzoQBopX4Ia/DYCKiLyAaXi9ECn/mbi59xn4sNB0sK7Z5wfGJlg/p5JmBTDEbV7lJjnZJXn1lOVWfTDoVPfZTE9TBTw4OGcds5b2dIS4uPc7LFyKtnZXArUD0HPEv01Uib6nxVgc1Yixnt8oyjDSdzGa1xTi9Du3O/C+PE861jCeZicE= X-MS-TrafficTypeDiagnostic: AM0PR04MB4212: Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=aisheng.dong@nxp.com; X-Microsoft-Exchange-Diagnostics: 1;AM0PR04MB4212;20:TomZHKkKvdnkWzE4+oTmu2AJpfBjBmKm7m76guknwUjfmxJYlSAaVu4NTFWhGZyBhPD7Xtj6VL3CtJ4WFHAeCI/x77UIH2cY2gW/HWxkOBf2nCYZfBhxD1pCJuCoGG8a78MeGhhNrdURWWz8Zqe6UVyd7OgBSgWxz7sRxEvLqzghzQ6c4N7hC58Qtc1oEmdWYLDwygIGLlCqTSBwQlQxBcUDUThUuEUs7GKtUkL5cLFcynARZufcY+68Jqk+9A1q7KGJhfhe3m7nsIoMebBMOwnHHv8zkI5zTN+RMpF8UexUY1DCxtFPJbIS2GBQpJrIrmBuk1EMHVS900PeDiTzfM/6U1OX4AGrRdTzDRPX5wCX2l0QgQlEAHAQk57/K6lswZgf/4tfUIx7avgwPEVh3lvIiZPMX9TaTIkRf4o0XolZI6yzgS1817h5R2WuLyoiuPNXZ4CKBrNMlC08FDYIqLKs9k1o4O27mfC2ppupagb5h2IW4SdJuEiY7ac/izgr;4:YOwUo0OrAcESSPTR7rjwsNoQuw/jvhFH7eMDVL9Lx2KQVnPgTG2X+3jmYsBfmgy1XI8lxZNuXLjnIR3oq7nF6DiHFnTU9pLpiB3w6EKBXazCR5YGhR954YiFrq6qsyLRmVnARjqEcYo/otyZYaHeu3z7UYUpiBcw1rwbpAcYVKr2zlU33A17TfsfbyyQ4151L/UWqVQVjYpEQIDAhILdT6hMhxOO3k8OggND0+gTnEXh02gDAE0SRag3wi/euFMM6rG06DjtsEDkVX0JEK3lbLYa5u2uY7Sv7foCNEUQeWKrwZsrygtkTlXGSpHxw/kNroVffR2fxjDWL1vczm+FQb2dRa6waQa3kuVoqG18zqAAmVzoKovthgf5zSPsbzshJw/iuy/l0GkFr912qjG8mGTTkWUMwSSfzrAxxZ mjcOQ= 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)(5005006)(8121501046)(823301075)(3002001)(10201501046)(3231311)(944501410)(52105095)(93006095)(93001095)(6055026)(149027)(150027)(6041310)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699016);SRVR:AM0PR04MB4212;BCL:0;PCL:0;RULEID:;SRVR:AM0PR04MB4212; X-Forefront-PRVS: 07817FCC2D X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(346002)(396003)(366004)(39860400002)(136003)(376002)(199004)(189003)(5660300001)(26005)(52116002)(186003)(47776003)(16526019)(2351001)(2906002)(6666003)(386003)(6506007)(51416003)(76176011)(446003)(11346002)(53936002)(2616005)(105586002)(14444005)(486006)(25786009)(4326008)(6512007)(476003)(956004)(36756003)(66066001)(478600001)(86362001)(6486002)(106356001)(316002)(16586007)(6116002)(3846002)(50466002)(54906003)(2361001)(81156014)(48376002)(7736002)(97736004)(305945005)(50226002)(7416002)(81166006)(6916009)(8936002)(68736007)(8676002);DIR:OUT;SFP:1101;SCL:1;SRVR:AM0PR04MB4212;H:b29396-OptiPlex-7040.ap.freescale.net;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: 1;AM0PR04MB4212;23:FeVLEhCyKmhSKBWuhpnnrQXGR0L8ev3ihhUzgkilZj4oMwDngjYDgAd7K/85a+pDK5rd5fxbw/p0qR995REj8TOjjkIST0Yp7EbzRZU5G3RyPksI6EEdlegxdlbzfJg1LI7fYy5Z26MGxpC7YNFat1u74lE916x0mWcPwgwyRgqgIpkL4zyxQrwjolzN2UIPrs158eeCspSVn6CUKTymASeHRbX8dlw9qu15Nxvi+odTjk2pv+ufTOZHNArk+2/pAQfG22G4U88WvIhUnmx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sPj097egfCAvJamdfmjz2PU7Hddyv5u1mkj8qi+oORYJ4fjXhaA6fjqJSozAQ7vvrtpWfFT2YB5zefe/nUAymoZ4L2JiM+eWCOM4+iDPZfPO06Mw9KYwHU6Ayzket0WTV6YuqhRKb6V5eTc0MTusC/5f4YVi1qc4OZkjzWJf3urgFhw SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2018 04:49:41.9182 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 51cb1034-2ed8-4d1d-0b8c-08d60efd2ccc X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB4212 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 Reviewed-by: Hans de Goede --- v5->v6: * address Hans's comments v4->v5: * fix wrong setting of par->clks_enabled 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 | 72 +++++++++++------------------------------- 1 file changed, 18 insertions(+), 54 deletions(-) diff --git a/drivers/video/fbdev/simplefb.c b/drivers/video/fbdev/simplefb.c index 9a9d748..89fb1e7 100644 --- a/drivers/video/fbdev/simplefb.c +++ b/drivers/video/fbdev/simplefb.c @@ -181,8 +181,8 @@ struct simplefb_par { u32 palette[PSEUDO_PALETTE_SIZE]; #if defined CONFIG_OF && defined CONFIG_COMMON_CLK bool clks_enabled; - unsigned int clk_count; - struct clk **clks; + int clk_count; + 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 == -EPROBE_DEFER) + return -EPROBE_DEFER; return 0; } @@ -252,39 +228,27 @@ 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; - 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; + if (par->clk_count <= 0) + return; + + ret = clk_bulk_prepare_enable(par->clk_count, par->clks); + if (ret) + dev_warn(&pdev->dev, "failed to enable clocks\n"); + else + par->clks_enabled = true; } static void simplefb_clocks_destroy(struct simplefb_par *par) { - int i; - - if (!par->clks) + if (par->clk_count <= 0) 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,