From patchwork Fri May 25 10:37:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aisheng Dong X-Patchwork-Id: 10427065 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 833AB6025B for ; Fri, 25 May 2018 10:38:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 647862948F for ; Fri, 25 May 2018 10:38:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 595B0294A2; Fri, 25 May 2018 10:38:57 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 A8ADC2948F for ; Fri, 25 May 2018 10:38:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966003AbeEYKi4 (ORCPT ); Fri, 25 May 2018 06:38:56 -0400 Received: from mail-eopbgr10109.outbound.protection.outlook.com ([40.107.1.109]:19632 "EHLO EUR02-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S965532AbeEYKiw (ORCPT ); Fri, 25 May 2018 06:38:52 -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=ugB16Wg6CxPuftqwnbW1CkiZVD1Z0XmZ3uRGzUiHSps=; b=gRe2FN/rlNp+thjVjhjdZNtJ+KglTIdTzCEuo0xq76PEx5xMj09nCUPjuw2rREHA44e4wEQwpAM6/zbNgO212PpcPBdtl2Dn1xGITGoJ4FfVxxzhYjQa57IVXPJIfRH4zYP0Kc9kmiSxD9bjhzjWDmlZ3W6xmASEvF8A5JMC3SE= 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 VI1PR04MB4224.eurprd04.prod.outlook.com (2603:10a6:803:3e::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.797.11; Fri, 25 May 2018 10:38:47 +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, linux-imx@nxp.com, Dong Aisheng , Stephen Boyd Subject: [PATCH V3 3/4] clk: add managed version of clk_bulk_get_all Date: Fri, 25 May 2018 18:37:22 +0800 Message-Id: <1527244643-10736-4-git-send-email-aisheng.dong@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1527244643-10736-1-git-send-email-aisheng.dong@nxp.com> References: <1527244643-10736-1-git-send-email-aisheng.dong@nxp.com> MIME-Version: 1.0 X-Originating-IP: [119.31.174.66] X-ClientProxiedBy: HK0PR03CA0069.apcprd03.prod.outlook.com (2603:1096:203:52::33) To VI1PR04MB4224.eurprd04.prod.outlook.com (2603:10a6:803:3e::23) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(48565401081)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:VI1PR04MB4224; X-Microsoft-Exchange-Diagnostics: 1; VI1PR04MB4224; 3:N3kWeyRN2fjg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MW8soRJ3d58kCPRcKpBwkQ7Atc3ytJE44B4cD/0ct3jY0ZMhPVxckUX+NDgmnmJEoSe3IY3Cs3xGzcJ9zjMKJDEXbbHR4YxDCiLiI2vByDIjkLy8FXfGchg95rlf7BNStPAq/QYE+S+ZCrQJvdsDIbU2B9LNQ0Iy0CEyMCdeA/H60eO7W27oPooBOM0Yw3QFounhpx3Ewxhwqc8xRd7gQJsSA2kWwXk28bOU1Dzp+fIAI2awP5PHXku91AxD2QFZN219FEVTQ1ettv6oRo9EmXHIun4Ff3wcnXzJNAtBAiV4cqY/3/IIcd7FIZ/QwDC2; 4:RyhxkTtL3gD0DLQJiDgGsNWo0a5Xz1ZuIZEGveEVAzmiN5lg6p6U/F1WdRK6rzozv/PgVlKYAelaKYAGQbk7LjED4rr+pSCRBvAckhdJjvZOVIeLzmqfBXxByzeED9VHCq0bkrJSTvzhPGl8qqe+OcmLX7f+zRxC865GSaojsOT7flvRznCCQTP2a3CVzMqSj1IhXEy5bGxsr0ghVT2zo93cgtsSx0mv763jY+azXPYthe74D1QlTSwEfsgit+EutDyxuw8vp2fJNh9FiEx0/iQTAoUd7+saLPIxmH7V3ACgdW5KrQNAF64qF9Q/nfI3 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3002001)(93006095)(93001095)(10201501046)(3231254)(944501410)(52105095)(6055026)(149027)(150027)(6041310)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(6072148)(201708071742011)(7699016); SRVR:VI1PR04MB4224; BCL:0; PCL:0; RULEID:; SRVR:VI1PR04MB4224; X-Forefront-PRVS: 06833C6A67 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019001)(6009001)(428001)(199002)(189002)(20776003)(69226001)(63696002)(47776003)(74876001)(62966002)(74706001)(36756003)(77096001)(77156001)(76786001)(76796001)(81542001)(42186004)(93136001)(92566001)(46102001)(64706001)(81342001)(92726001)(48376002)(77982001)(59766001)(56816005)(33646001)(80022001)(66066001)(76482001)(90146001)(89996001)(65816001)(87936001)(56776001)(88136002)(54316002)(74366001)(44376005)(87286001)(87266001)(50226001)(4396001)(47976001)(50986001)(95666003)(49866001)(47736001)(51856001)(50466002)(85306002)(79102001)(85852003)(83072002)(21056001)(97336001)(94946001)(93516002)(95416001)(94316002)(86362001)(97186001)(80976001)(93916002)(81686001)(83322001)(19580405001)(81816001)(31966008)(74662001)(19580395003)(53806001)(74502001)(47446002); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR04MB4224; 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: =?us-ascii?Q?1; VI1PR04MB4224; 23:zKcH4L/tuZq25/8WIkE8ohRecxFXi3YqzYexH6k22?= =?us-ascii?Q?RKAtNk52j18ppoxg6MyO3JbDsA7GB2nqcFl1t8lyo6J4yud0YO6uDQ/9DCzk?= =?us-ascii?Q?2EKfOboVGbCgh09cNQGPDq/VbIWmyjfTrdneszd6uxuNrinRfzfr2NMAUH1P?= =?us-ascii?Q?6CcO2ufiawBjRC0vFNB0LOLyUsZLyWTEa5A9HUQ9ZDKRHsuk7RmkATOR4E4y?= =?us-ascii?Q?EGWr5SgbcdRPwD1UCYiutPTj9+cAlv9Z07z6+JkCclN+BUV8dJYjfoBTKZm5?= =?us-ascii?Q?z3YacSgnkqYyDtnwnbeevdlmmsAh4BcsMCun7AOEopffOWYb4w9KV+1qv6mX?= =?us-ascii?Q?NM+hF5FJJJXiF+XCQwwuNwzkHKgaDHXlny5bbf6v9p1eJPrYny1n6sE9ZC9D?= =?us-ascii?Q?mYjGuy3S3ka1IkNrEED/b3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U8YRoCQ2KjdPCX/CuwvwTzNTouiu5CrHeQT0J74GmcZRTjLYhcXrbe3F+P5ZspAtdzeS2ThZX4XdY1WU/bGMM76QISe29OAxDVALCov/IsWQ0mUQ45TZSxPbPrq4vDXnelr1r5Zmo936QzZHxpfSkaJ3B6Ebw9UTonUha8MogIDiTcBbkqChB/ULzsy7q4zkJqFHBQr+A6iw6eaWkbR4dFfp1S8XskVRI0kccw==; 5:NIbysdaTY96LK5uPMxNkSLRKhWO2IrD640iFAH+4xK6d8veuXm5I22T9AEgDDebrIDZokiO9y4spMeY6YMkDuNidRTR1SRDzMI1g8XM6tFQKoSl9oMuaJPAQ29FOdwuxgkrCwSVkpEyhkdB/kASDNMZmzv/8F53pIwGaP5IVUN0=; 24:wokqta7jLd88ae+oxkfxRZczVnbPxlz2OEVHJxkXbCapi5s7c7+dsenPWwx2DiSSL7isFPF0fr8ZQbsSVHTuDo7IfEj2+8MfLNcjR3FgGz8= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; VI1PR04MB4224; 7:UB0abjP+z22uP+qe5cWlgQGVAKAEk2P+4Bc+ayAWXFlxqgYtuQHEp1XjLpJHIG+h1DaRcQe07ruaLcmvpGO7lE8gWAroY6wPgs4gVVNx8PDvp5Ucc/k7v0o16ejAIH4tEqPVOq/VRpt6Kg25t9nNu6pVFiiLbSkbkm35mHiYZAryzs/H0sRLVgB2ddIYDOnQBvhdLA/RtnNTHwl6f4N2JibKIajO3q8f9u55iZPpTqEhhDKCeSyVDDYI/uK4JkGn X-MS-Office365-Filtering-Correlation-Id: a5472690-f3d9-4095-8607-08d5c22bb435 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 May 2018 10:38:47.6206 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a5472690-f3d9-4095-8607-08d5c22bb435 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4224 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 Signed-off-by: Dong Aisheng --- 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..6d3ca5e 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, clks); + if (ret > 0) { + devres->clks = *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 a76fdff..ef20217 100644 --- a/include/linux/clk.h +++ b/include/linux/clk.h @@ -313,6 +313,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. @@ -658,6 +674,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) {