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: 10583139 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 2536D1709 for ; Fri, 31 Aug 2018 04:52:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 12CFE2BFF8 for ; Fri, 31 Aug 2018 04:52:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 04B472C001; Fri, 31 Aug 2018 04:52:08 +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=-2.9 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7DD3A2BFF8 for ; Fri, 31 Aug 2018 04:52:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=2RY+x9Pi/ahX4I8xbZUpeUqLV8J88qxpA1OJIQpR2Qs=; b=GkmU7sP7E/OCgN smlYwUU2Tqe4GYfxkYO/zFD8So4T2osKvJSogomGtfUCcUWSKuhVouSFgDcn3D4nRO8aZgg5Noa9M LUvOQPFXDR4Hlc4hI/scgMX/GDO5I7U7IWwoL1G8DhjlMyIg7eDYgULps9xNaCnL3ZG3GKUNBMDZe nL/5qR4BFF9FsOXLTn0+PrigEmgfVRhBs+z1J6iLAKD98QDgH1aYEuPfG34U5o7aaUoCVPgpBgNIH L5nFxIedPqmb4XShJH4qnnVvqN0P4CtvnmWMv806PcT0ARjHjL9TeG5NBjhWEDQIOzvb5eMC7yHQl L4rRPdG9bivjp5icy02Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fvbPa-0008Nh-9a; Fri, 31 Aug 2018 04:51:58 +0000 Received: from mail-ve1eur02on062e.outbound.protection.outlook.com ([2a01:111:f400:fe06::62e] helo=EUR02-VE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fvbNZ-0006Cf-NX for linux-arm-kernel@lists.infradead.org; Fri, 31 Aug 2018 04:49:55 +0000 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 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: =?us-ascii?Q?1; AM0PR04MB4212; 23:mepacjAbXBWJ7wZX0xtp98ux4F2PjcB4gOvbjquaa?= ba6QlGy6a2B8bUGapR8Xcefp1oz5qUtGxRovYyi7rTFOcOQfNPk2FXekGSgbpnfsBKMc2JQH8ULEyTtmI6LlRgzFXnxsjEq1iYY13FGe7Zf02yCK27bTnfXd9XfBJRL6tEytXnBNHlyHINyrY1YzsKC3oTHv4IVR/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+6rMECGzLb19FpHKHlDw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7mttxXvgjXoNLE3WIxApsbEYjRq+xuvRYdhpLWgARx0KKrARw/vhhoze3IUe+B9fYFGqNsPryWmTGGVaM6hQU8u9MH3eBSZcbDq3Zb1t/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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180830_214953_843969_D5F51ED5 X-CRM114-Status: GOOD ( 15.09 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dong Aisheng , thor.thayer@linux.intel.com, sboyd@kernel.org, mturquette@baylibre.com, Stephen Boyd , linux-kernel@vger.kernel.org, hdegoede@redhat.com, linux-imx@nxp.com, shawnguo@kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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) {