From patchwork Mon Jul 4 01:36:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 9211531 X-Patchwork-Delegate: sboyd@codeaurora.org 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 809EC60572 for ; Mon, 4 Jul 2016 01:37:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F37D28610 for ; Mon, 4 Jul 2016 01:37:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6204E286EC; Mon, 4 Jul 2016 01:37: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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, 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 288B828610 for ; Mon, 4 Jul 2016 01:37:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932471AbcGDBhA (ORCPT ); Sun, 3 Jul 2016 21:37:00 -0400 Received: from relmlor2.renesas.com ([210.160.252.172]:60394 "EHLO relmlie1.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932182AbcGDBg5 (ORCPT ); Sun, 3 Jul 2016 21:36:57 -0400 Received: from unknown (HELO relmlir1.idc.renesas.com) ([10.200.68.151]) by relmlie1.idc.renesas.com with ESMTP; 04 Jul 2016 10:36:54 +0900 Received: from relmlac3.idc.renesas.com (relmlac3.idc.renesas.com [10.200.69.23]) by relmlir1.idc.renesas.com (Postfix) with ESMTP id E717E49ABD; Mon, 4 Jul 2016 10:36:54 +0900 (JST) Received: by relmlac3.idc.renesas.com (Postfix, from userid 0) id D5ED31806F; Mon, 4 Jul 2016 10:36:54 +0900 (JST) Received: from relmlac3.idc.renesas.com (localhost [127.0.0.1]) by relmlac3.idc.renesas.com (Postfix) with ESMTP id CF6451800A; Mon, 4 Jul 2016 10:36:54 +0900 (JST) Received: from relmlii1.idc.renesas.com [10.200.68.65] by relmlac3.idc.renesas.com with ESMTP id LAJ19571; Mon, 4 Jul 2016 10:36:54 +0900 X-IronPort-AV: E=Sophos;i="5.22,559,1449500400"; d="scan'208";a="214324530" Received: from mail-pu1apc01lp0022.outbound.protection.outlook.com (HELO APC01-PU1-obe.outbound.protection.outlook.com) ([65.55.88.22]) by relmlii1.idc.renesas.com with ESMTP/TLS/AES256-SHA; 04 Jul 2016 10:36: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=qqsHsCoyKjgT1Kg80qZkDd7tB7QmH+CakDsY0zsYZLM=; b=nSAIGO+s4pJHqGO/TfGTf85PknLq7+fi1V4TOkWGFuLU43pn6nF55vS4ZxVZSFFazqSvHmOnwTHR9Fnxm6GTBtadB2IE/ww+vUsm+Wnzih1DPs7wb9RSwOyM1QbDZAaRVx4dyuB6fueHaBzY8Bp/rr8Xt0Ysm2a2G8MGopHckbA= 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 PS1PR06MB1705.apcprd06.prod.outlook.com (10.167.53.15) with Microsoft SMTP Server (TLS) id 15.1.528.16; Mon, 4 Jul 2016 01:36:50 +0000 Message-ID: <87wpl2yyuw.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH v2] clkdev: add devm_of_clk_get() User-Agent: Wanderlust/2.15.9 Emacs/24.3 Mule/6.0 To: Russell King , Rob Herring , "Mark Brown" CC: Linux-Kernel , Linux-DT , Linux-ARM , Linux-ALSA , MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Date: Mon, 4 Jul 2016 01:36:50 +0000 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: OSXPR01CA0013.jpnprd01.prod.outlook.com (10.167.143.159) To PS1PR06MB1705.apcprd06.prod.outlook.com (10.167.53.15) X-MS-Office365-Filtering-Correlation-Id: e5c5ea84-093f-4a41-408c-08d3a3abace8 X-Microsoft-Exchange-Diagnostics: 1; PS1PR06MB1705; 2:PR4OIHex0JzWeDPs4mDVS7v1oZYpHZiNxl8CASNmK+07W14ulJpjnC+jo6Fw4KmgkQgAiuSANjCA/J6Ij7Ihhpul0e5ATcjKI7tw+ITXVc29+TxbmsgEeWrenGtpelpgsyM73qNO+e5yXrQkHZ7JhSA9JXF709S/9X3KGXZwF6clKvb0xhkHYImYPepsrza0; 3:QVxrJLZm3jXkUw5Ge8UHLvnoKYCbYS06TBfWJM9AyxKA2jtrnA3X8Gf5nskwc/fXQMosMYolbafE5Cx/QOni1TKouUNwZ990RTejh+/09QmbhRsMVe4oWeP+kEA618CI X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:PS1PR06MB1705; X-Microsoft-Exchange-Diagnostics: 1; PS1PR06MB1705; 25:SbJTD0A5IErk1z7wg+3Lnq1b0ZM7myvGuYEm1ORH+lgbuLoojOG1uwmpt9QdZapHTdRNh1kE0HgZdoUZjzaAhm/EDXR1yB6B6mqutkHim4L5gsw/8k5Cg2E3h/GbxVki4OUPGlnaEKIcSqnfDaTrgQQ5dOwsk1iOWV6Xyoevm3mlyRgdnF0TrcH4ajsD93IUX4zt6EMYaAEj4O5A53+EEAuPa4SvmMYJhNSpuPxLG2pXhf0P9PzL+M8Nk/9D0N3lhxmvDYONMo8tyd1Tu3ax9r2gASo8QTu7+m/9lHpr6Q56ob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Sh0q4iMDqzXd6Cfxv+zVyoSr6UzhlIUKq3/G3qRXARJlrjzKIi6f1DsXfueWdeuKmrwibgt6U2OK3MSOOsBDYtP8gIP; 4:ewpgIaZA23TEJ4qKIoFAz0rHjTDNldM1yXHMgQ+RafXv5uyGnXTaVTlOT4HWDvGDoLoqKuIBUVO7lOPEv9HginDbd8XQLJLzY7vHlR/skO5bne6dfMUxrynV+fCUaYIyemOu2uS2cR4dCO4jKy3uDVDbTxB8Pr1kPH+VTzMws7Z2D3UFcvmxNpW5WI84t+foM5c2+0c9/Q1bNHvoZacxAMzHaStt9xXKe1iGJH9mNAo3KCFHcXN0J4G/n8TETN+CyaQiw2gURF/xm4KbJd1nUO20mzQKelftKYiLiQiiqAejLdStx037MNLO0jlrK70XcfkRDTQYpWxok/dDl0qJrciIslW6jpsMsVXi0Y0++HSjx4/XXx3V3tOyomecjDki5WJey05GtEJ1KyZWzXXFiA== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6055026); SRVR:PS1PR06MB1705; BCL:0; PCL:0; RULEID:; SRVR:PS1PR06MB1705; X-Forefront-PRVS: 0993689CD1 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(7916002)(189002)(199003)(86362001)(54356999)(50986999)(46406003)(586003)(106356001)(105586002)(229853001)(23726003)(6116002)(3846002)(33646002)(77096005)(4001350100001)(97736004)(5001770100001)(47776003)(66066001)(53416004)(189998001)(101416001)(92566002)(50466002)(42186005)(7846002)(7736002)(305945005)(81156014)(81166006)(19580395003)(19580405001)(68736007)(69596002)(36756003)(4326007)(83506001)(2906002)(8676002)(16060500001); DIR:OUT; SFP:1102; SCL:1; SRVR:PS1PR06MB1705; H:morimoto-PC.renesas.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; X-Microsoft-Exchange-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3itnQzEDY3PCeshLzupMrdDZC+8a3MMrioAN2toz1UGTnWFbSmsW/tl8+5GyuqMbxV+MGEzjgrwZJ72VQpospnAKxfQmPQRvXTDChf1z9GEY8sYwLXUJ/miW2u9q5oSA6eLYHRVk5GDdvdrzK4/J1GDxJ+wHlLr/VV1yyZr2eO481rR58KFsHAnY43Y SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; PS1PR06MB1705; 20:Ab4HzwaBLRJL8P53dSV6DxVZCKo1JUXNKrbOfC3aJz6R/MZWp2xdkSyTKoOhqK+GVE9GG0YFSVGGoFDkRNjIHlzoZV7JnBmfmjGOO/Kx2XjRTCuEW7ikbSQOihOLkH43EjpGWfz6KpXcbx66PWwG1zpOT6XK2UfFaA+ZIksK6i8= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jul 2016 01:36:50.8055 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: PS1PR06MB1705 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 is based on devm_clk_get() Signed-off-by: Kuninori Morimoto --- v1 -> v2 - added "static" and "inline" on header drivers/clk/clkdev.c | 26 ++++++++++++++++++++++++++ include/linux/clk.h | 7 +++++++ 2 files changed, 33 insertions(+) diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c index 89cc700..93a613b 100644 --- a/drivers/clk/clkdev.c +++ b/drivers/clk/clkdev.c @@ -55,6 +55,32 @@ struct clk *of_clk_get(struct device_node *np, int index) } EXPORT_SYMBOL(of_clk_get); +static void devm_of_clk_release(struct device *dev, void *res) +{ + clk_put(*(struct clk **)res); +} + +struct clk *devm_of_clk_get(struct device *dev, + struct device_node *np, int index) +{ + struct clk **ptr, *clk; + + ptr = devres_alloc(devm_of_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); + static struct clk *__of_clk_get_by_name(struct device_node *np, const char *dev_id, const char *name) diff --git a/include/linux/clk.h b/include/linux/clk.h index a89ba4e..33cd540 100644 --- a/include/linux/clk.h +++ b/include/linux/clk.h @@ -502,6 +502,8 @@ struct of_phandle_args; #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 @@ -509,6 +511,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) {