From patchwork Mon Nov 28 09:32:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 9449217 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 5451F6071E for ; Mon, 28 Nov 2016 09:35:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4814F20223 for ; Mon, 28 Nov 2016 09:35:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3C9E024B91; Mon, 28 Nov 2016 09:35:46 +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=-4.1 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DC65620223 for ; Mon, 28 Nov 2016 09:35:45 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1cBIJP-0008O0-Og; Mon, 28 Nov 2016 09:33:23 +0000 Received: from relmlor2.renesas.com ([210.160.252.172] helo=relmlie1.idc.renesas.com) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1cBIJL-0008F7-DP for linux-arm-kernel@lists.infradead.org; Mon, 28 Nov 2016 09:33:21 +0000 Received: from unknown (HELO relmlir1.idc.renesas.com) ([10.200.68.151]) by relmlie1.idc.renesas.com with ESMTP; 28 Nov 2016 18:32:56 +0900 Received: from relmlac2.idc.renesas.com (relmlac2.idc.renesas.com [10.200.69.22]) by relmlir1.idc.renesas.com (Postfix) with ESMTP id 505F75285D; Mon, 28 Nov 2016 18:32:56 +0900 (JST) Received: by relmlac2.idc.renesas.com (Postfix, from userid 0) id 4015F28070; Mon, 28 Nov 2016 18:32:56 +0900 (JST) Received: from relmlac2.idc.renesas.com (localhost [127.0.0.1]) by relmlac2.idc.renesas.com (Postfix) with ESMTP id 3BA172806F; Mon, 28 Nov 2016 18:32:56 +0900 (JST) Received: from relmlii1.idc.renesas.com [10.200.68.65] by relmlac2.idc.renesas.com with ESMTP id UAK21320; Mon, 28 Nov 2016 18:32:56 +0900 X-IronPort-AV: E=Sophos;i="5.31,563,1473087600"; d="scan'";a="226465712" Received: from mail-sg2apc01lp0239.outbound.protection.outlook.com (HELO APC01-SG2-obe.outbound.protection.outlook.com) ([65.55.88.239]) by relmlii1.idc.renesas.com with ESMTP/TLS/AES256-SHA256; 28 Nov 2016 18:32:54 +0900 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=renesasgroup.onmicrosoft.com; s=selector1-renesas-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=QHR+oMGG820rDDdoFbuAcqjyk48svVfUrLZwAlxqM7I=; b=Tdo4CQWQG/7YXAEX5xwtIijZ8wuZ9zhLmq36K8/TLLRAtrxYKQF3AawDbum6aXxPioPutSKV+InOMK08bRv6gmDIDMHbWWzIk0zGgaY3ws+yf/Xo5gpe2wjcttMwXChvMlsCGGVCFE2pRHqCr15VvZ1Y6OwY3a3LBRZzvK1x8q8= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=kuninori.morimoto.gx@renesas.com; Received: from morimoto-PC.renesas.com (211.11.155.144) by HK2PR0601MB1444.apcprd06.prod.outlook.com (10.165.182.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.747.13; Mon, 28 Nov 2016 09:32:51 +0000 Message-ID: <87vav89chw.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH v3] clkdev: add devm_of_clk_get() User-Agent: Wanderlust/2.15.9 Emacs/24.3 Mule/6.0 MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") To: Russell King - ARM Linux , Stephen Boyd , Rob Herring , Linux-ALSA , Linux-DT , Michael Turquette , Linux-Kernel , Mark Brown , , Linux-ARM Date: Mon, 28 Nov 2016 09:32:51 +0000 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: TY1PR01CA0137.jpnprd01.prod.outlook.com (10.174.224.141) To HK2PR0601MB1444.apcprd06.prod.outlook.com (10.165.182.150) X-MS-Office365-Filtering-Correlation-Id: cdf178dc-b9ca-4596-fef2-08d4177186c5 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:HK2PR0601MB1444; X-Microsoft-Exchange-Diagnostics: 1; HK2PR0601MB1444; 3:pCh1TMoJr9EJRPcZtN+HBu0HTgMNm5vSZKSoE3mlpQdUdNV2g+EufqcQz8h0SAeVE8yoB1H/Ra49ZcliqLqPb5ZukBNOdP8iJ4g/dBcdnVXLzMCu0YTpRuxC8wLkE3REw9Eisw0/YV47UUqaD+g6A2BJ/YALdXhi+85P9nFFgwPxQ2zUzaez2dPIb/qvJMTkH5x4q9s5hSNCZFUkmWTFCGk0guqu2Gy/i71UhK5Hc+yDMPoSvm/1IPPdPZ3YmBkSuLZC9DiSkayMxU/hmyJEKQ==; 25:4ygHHJisKFcPPN9CBri5zlcG0Bvxy2CjMRPwZHH7GZk90vV0JnYTp8gpK8hgDA6HxM7gm39REBG6lVtdsBuflk2u1WsTcSESzsbaNVJIGXZ/ISCIHQGGjcISYE9GS3Ya0l+T35xuWOuK6OtYnV6kKEkG69k6nMUQXiqNSqRReVJA0TcQp0ntexIQgUIGOXfbptBFUvJJNfQYxvgy4Enl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vT0eg+hUi3oRvkSJz+ITP/8UhDE2R0Aw6Zkom0e8xew9Ck X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040361)(6060326)(6045199)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6055026)(6061324)(6041248)(20161123555025)(20161123560025)(20161123562025)(20161123564025)(20161123558021)(6072148); SRVR:HK2PR0601MB1444; BCL:0; PCL:0; RULEID:; SRVR:HK2PR0601MB1444; X-Microsoft-Exchange-Diagnostics: 1; HK2PR0601MB1444; 4:t61Y60D5tvg4KGC8edrLM+SJ/lBoXmvKRELp9ijHaoQlKG5R9YbfT4bUp2YlhYK9EE1kdZo/15rtZASxMwWPNyjYzWrRMvQ0btd9MKhaJbRB8HN8XBjDuHUqLjE+pdrcyLRzRQgGTEpnsj4o5vJrCKouMtIR7JHxvBh5UkNgPB0GHiyA/fDJ5Co/UR16MV3RcfY7IEUTyY/nwI/triD2tDQBQQA0x9aIRNOuWjPyPr7Oj9B2hPzNlBBuPECRVbkM9kaOLRJR+d3wDvhREjBgvu0Ui/5LAudgIfsXt5TiEib3GLjv6Gs091pAh0jFIszaUEwFjn1GOmDn++aOYxyy38juBTdpLLsjreLFgukMYuFRemg1y63QWWnb6UoudNvK0OT/kUDLnl5wiNLMu7hI6rdUBhlusha+U5lam6EcErqVJzez3uGinTCWjV8vP225cwT2c3QcGYv75foC7ZYJg5QfTSwEBr4nfN+mD4EpNe9HRAPXJGcCsDCpw29GXyitlqX55Y16X28TGkaTkkyRs5W4uwE0zhgpMtNrZNIBNNyl58t5MDuSkdckCaD5Danv+uzxR/pMxG9Z1p8knJAzZyRpLdaclafVT1BtNzUUdwpc9S9793m0MbPYOuHckbJLvlPhK+gDFoknmTtl1i+INZZo1UBvrg/ZtcPw1ajJrYvTfUpCwvo9tcO48BY4PPW2 X-Forefront-PRVS: 01401330D1 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(7916002)(189002)(199003)(66066001)(305945005)(107886002)(39380400001)(5660300001)(6486002)(39410400001)(33646002)(733004)(39400400001)(50466002)(5001770100001)(68736007)(97736004)(39450400002)(36756003)(4001350100001)(2906002)(23726003)(6116002)(46406003)(7736002)(92566002)(8676002)(83506001)(3846002)(101416001)(38730400001)(86362001)(7846002)(53416004)(42186005)(105586002)(7416002)(106356001)(189998001)(50986999)(54356999)(81156014)(81166006)(47776003)(69596002)(921003)(1121003)(16060500001); DIR:OUT; SFP:1102; SCL:1; SRVR:HK2PR0601MB1444; H:morimoto-PC.renesas.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: renesas.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HK2PR0601MB1444; 23:7ZSFV3pnSFOthABYyXsU+0XScYISrFvu7iIO+9h?= =?us-ascii?Q?PPmMdS2uaxf/FVoos7adK/j8piuYTBX3V8LUsKi9CVe4JcxWLOa+W5IuQNDK?= =?us-ascii?Q?efpsRqftiE8akKXmOP/w57Kzh04I8BX8Q2Xtd3LYtreih9uDMX6B2X7Ma1nx?= =?us-ascii?Q?XI57CrZZXBXfP5Rl1CSbxvoAO6MlpttPnfIifk527uMihS+V5Q3g0DM6qO29?= =?us-ascii?Q?twm1ZfcTJEhj7FSPL+HduB6ZbKJAUovxUurJz5EOhzQTY4K0mPTmYiwLW5eu?= =?us-ascii?Q?zcDAGfEOWWhKwmccPI+ry8IKFEYeCJlqhlU/V/xcUCb9lEKT8JkId8upuxUX?= =?us-ascii?Q?BTr7uABUkdYAIcC6msNonmQzetA7gKRpiAXI8oSVme6es3RjH42dA/TH7eco?= =?us-ascii?Q?lecArtqssEzKxsEYuxjF6AApq5h+4vgdKSdMmG1ny/lIU8lBMzc1+d/vPMIt?= =?us-ascii?Q?zelQEakby3GG7jhj+1XhP5sgNn0iyTxfbEK/ALo3waT02F/N3oQX8vcw+Mmt?= =?us-ascii?Q?MZTR4Vtn8mdgxqrDAO9Z3w7NZjBL5Nj2eSKvQhnT1tLjZ6GlEX4ENd4/XbtI?= =?us-ascii?Q?0y0wQLIpc/XRDA6yeow11JgBopv3geE/PV1953/rND9GCgJPQ6YtlJalNKIU?= =?us-ascii?Q?wZ34+XgJT7gkO9HDFzwKW+AvLxrPQg69W+FsekkXeIHTjvqhy7nGaiAdQIQ0?= =?us-ascii?Q?KT3SOBzLUNQM90XJWPZqnv7h/+e3N0g7O5Isj8lpCET7ZN13dljdoMlGR2uP?= =?us-ascii?Q?VhZMb5pjL6wnUUXlkHxFlXp6/EV8L7soDGcnlWZbRZR6q7x14w+nbdM/CWnC?= =?us-ascii?Q?OL1507u/DcEpDPY8O/9Nm7ynLMLg/yKyvXzJmTNv862iOPECz1qM71Y6Y5Jj?= =?us-ascii?Q?6GQNm2IE10ojFZHTahps9wFJmUQpzcUWWmqykd2JXRCEqKHQutR7JbJqQgVM?= =?us-ascii?Q?4C4mCMzOWJtkVpKtsDUx19RDnmxArN7v3hBKwj18J8krWcq2F2Ozs7+J8sG3?= =?us-ascii?Q?FzrjaACuK3D3HgtrEQH2WS//kAxjCQL/1IjgkcY9BrAGaaUwQGbvq6RIzj98?= =?us-ascii?Q?XkttmT42LkPkdCjy7Xj0kyxkhF62PWB33pCwbgJ0pGQPrQb14nmFNNv/BKEe?= =?us-ascii?Q?QVoUBJvWWC9velQOiz1uG10eeVYT8CdZ5d0F2McJBiS10c0fhC3hNNuFs3Fj?= =?us-ascii?Q?M7pU33gQrXlM1VTk275YTNMjYZaadFvTuKpKdMxr3CsKjk7Ii83KD5xDo5w?= =?us-ascii?Q?=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; HK2PR0601MB1444; 6:nMzbm7IAWzbOcrD5kF+49k5Xkpz+1dfVmomHhzq351shVC6+Rfid5hU8owULvvohYxPxnBfVneftir2QZAryq+C+IL1HpGQ9HDvPDKwptrjdocWPpa5xLl1umurXsBX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xYOI1Sg1jlwSA2kd4+L6bOkinKyJEspljN0srAOk+Me2z9EoUl/0uSOpBRHT2VO2sC5FGWC74boUC5chh1MDk+9jTP5mh9v5dpVVhu6BxBFu5ze3ESRWInAYQw==; 20:G3BS8u6raO6hp4DBLKw0Qxmnl3cuz6KZCLpEB5J/FXKmd44+/Kc4+RHzsA7FVXU0blN88q5n38AzXIFzxGIiyq+br8cDIyUNI37v/9kju3C2hKUZjRrwBSwKyexBa2eJ9qS5CQc7EERR1cLYpXwTMyxuRI2wb0VrFcIvJtLi1V4= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Nov 2016 09:32:51.8752 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: HK2PR0601MB1444 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161128_013320_047382_4AAED1E7 X-CRM114-Status: GOOD ( 10.93 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 From: Kuninori Morimoto Current Linux has of_clk_get(), but doesn't have devm_of_clk_get(). This patch adds it. Signed-off-by: Kuninori Morimoto --- v2 -> v3 - implement in clk-devres.c, and reused existing devm_clk_release() drivers/clk/clk-devres.c | 21 +++++++++++++++++++++ include/linux/clk.h | 7 +++++++ 2 files changed, 28 insertions(+) diff --git a/drivers/clk/clk-devres.c b/drivers/clk/clk-devres.c index 8f57154..2449b25 100644 --- a/drivers/clk/clk-devres.c +++ b/drivers/clk/clk-devres.c @@ -53,3 +53,24 @@ void devm_clk_put(struct device *dev, struct clk *clk) WARN_ON(ret); } EXPORT_SYMBOL(devm_clk_put); + +struct clk *devm_of_clk_get(struct device *dev, + struct device_node *np, int index) +{ + struct clk **ptr, *clk; + + ptr = devres_alloc(devm_clk_release, sizeof(*ptr), GFP_KERNEL); + if (!ptr) + return ERR_PTR(-ENOMEM); + + clk = of_clk_get(np, index); + if (!IS_ERR(clk)) { + *ptr = clk; + devres_add(dev, ptr); + } else { + devres_free(ptr); + } + + return clk; +} +EXPORT_SYMBOL(devm_of_clk_get); diff --git a/include/linux/clk.h b/include/linux/clk.h index 123c027..1b713db 100644 --- a/include/linux/clk.h +++ b/include/linux/clk.h @@ -506,6 +506,8 @@ static inline void clk_disable_unprepare(struct clk *clk) #if defined(CONFIG_OF) && defined(CONFIG_COMMON_CLK) struct clk *of_clk_get(struct device_node *np, int index); +struct clk *devm_of_clk_get(struct device *dev, + struct device_node *np, int index); struct clk *of_clk_get_by_name(struct device_node *np, const char *name); struct clk *of_clk_get_from_provider(struct of_phandle_args *clkspec); #else @@ -513,6 +515,11 @@ static inline struct clk *of_clk_get(struct device_node *np, int index) { return ERR_PTR(-ENOENT); } +static inline struct clk *devm_of_clk_get(struct device *dev, + struct device_node *np, int index) +{ + return ERR_PTR(-ENOENT); +} static inline struct clk *of_clk_get_by_name(struct device_node *np, const char *name) {