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/piiIyfaoAXrT63Fdl3N2dqufoWcaHHrAWUbBrPMpHH0DMb3eo7mdygOwfYH+I4FVvk0DnxqMKAeS5ZYmpgrH0PMXDnxAamwLFu8CIgN3s/Q9J5A==;31:09RVK2HCbJQDnhPeKT2THtf8+WA8LxM95i3YQyG+cmIv7GbDIlIqCFNBJ6+jYRh1zvrZ+bhdC6/xlDnxjVTQ8OWQWF3v6mFOZKifqAf/fsoTwSNyZZjVtEqh7dvN7mqXCZbWQ3ybNWeboyohfGPayixYgnBE5vqmtIv1lB+8HRlaKjSzEeFFlvI++2AryvRq8p4QYQpYxLYvo86CKOPCo+NwR4TbGG2h5ROZE+Q7/ZI= X-MS-TrafficTypeDiagnostic: AM0PR04MB4211: X-Microsoft-Exchange-Diagnostics: 1;AM0PR04MB4211;20:dWN8EqDM8qgP0cFRX+lzYu9VqM7y1xbyXnGlyw/v0l/X+2+oZwn344i5AFdL+cDmAPNOTXhd7r/CYPfeh0rFm2ObSde+nwUenqzDFUgQXF5pswY3wUTHl2HTYU/LVkC6tK/fMzzuKcNKwtpUh7S2QH4HaieMnkNzdhGMM+UNwZ9ipC7pPvYpbdj7G0l6fRNLAObX5wWIWggVzvF8dWSiY1hLMW8m0CLeTmA7NnPs+FG6+ZqT7Q1ijLXgIW2JHM0sihbjI6PsYN1sitIKzOxjZo3C/+h/w3niZKSvxrzofi5pbjAXOVbLY0vs5tHVb2OtC6iNQxn6xucWobGPegc+IxXhoZ4oYgy7lUM9+jZnIoXztqWCwDwbZMBKdj3mr1DA9HG3BmCgHy86UlWeJmjAk6+vgb+H2ROqJ6zBYxWdIn3lyX68N2xTB80xdF3q6icOgkmLpa2cpEguhGDtEosX8v8NyJv3LRoKHflGkcBRi8DIp+B0Hh7wAUhZ4QgNd5nY;4:78pPQQig1Aj2yD7JR4w3RBISTIGhaYoWEOwKtDX9KzHI9RBGI+eQOfoAxfR6C/Twn5sIb8OsbtjPVrmWu424gkNW5/1LoAWB7Bm04ddlr+XJ96VL7zSjnfCNfcGJehHcf5/oHAUJl4PRE8/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: 1;AM0PR04MB4211;23:vRuq9NyfYXBmQP4p0S1sURME0/WxLIMgbbwNIfCWxhlEN6iE/PO50NU+1NcOI3uK6cq3rHloBtX/OtmxsuGq84rUCNWCo8152MXSOnarP/9BVG8FLYe1j2cF4nh3TAY1JmUhhMgkZIDfExC+QWYKqB6O80HI5Iy9EAhkmwHyP3PHD/W1iR5T35YDwIES2sHKcGS4pPRpLwYCVYrzZQPSrHZJV31ONjEYSxjjVL7QB3VMuJXmFcwqRleRJwKRsVNOmgKfKogSBCadjRKGKzgLisvD0p2K1CR4leIo20+ZVAS5s7Ax0rw2yxS4RPh2QDTnzzQ2u+iajAEMmddOPDbuUelWa58KORGi+JebPv8ckcq++Jl/rOQ4L05+eGqS4ZyhVqCXBHqjdMwWEC7AKfCzMSQmtGVMXWaRyfkOG+hqKGDmojkftRTRAbDjLhRMqMbk/cDiIS9OZagYrP5G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atorOrg: 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) {