From patchwork Sat Jul 22 20:41:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 705501 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D4987C001B0 for ; Sat, 22 Jul 2023 20:49:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229579AbjGVUtd (ORCPT ); Sat, 22 Jul 2023 16:49:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229483AbjGVUtc (ORCPT ); Sat, 22 Jul 2023 16:49:32 -0400 X-Greylist: delayed 450 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Sat, 22 Jul 2023 13:49:31 PDT Received: from smtp.smtpout.orange.fr (smtp-27.smtpout.orange.fr [80.12.242.27]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8893D1998 for ; Sat, 22 Jul 2023 13:49:31 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id NJQLqgycdZWkDNJQLqk8SS; Sat, 22 Jul 2023 22:41:59 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1690058519; bh=bWA5n6DBMnr6LPqtlqyYrLqir8O7olbWs97Uom4gQgI=; h=From:To:Cc:Subject:Date; b=BmfgCTgHGZmPLZfgh6/5mQP4E2wdZaHbTRVBvvHjna2XPxdRTQunjAprimqsHjq// 28oQACOKrz7hn5tCjfbN6bemF83SmLS+ApR/p9MhTQ+YjNo2MwFYtUb0PN9kUhuiJf inYIVqrF1IUwUyjIDKdUiEY6m+AXl/beuXy+2+yNAfRLxjcjC4YOMK9NhurBYWdaGx tBlD8jhpaF1DjxIfGQ8zEVQJTfDOoWiIx2O0I2ov0MJWuvjLGrwFsRHwdXiYLw5jgX CgIBt8suBeBH8XG66NmQWCneNIMeJNQk7l2gLZjYVM0D6rk/PwkQApOIS9+SvcUEyl zNkh5nN/SX/lg== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sat, 22 Jul 2023 22:41:59 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Geert Uytterhoeven , Linus Walleij Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-renesas-soc@vger.kernel.org, linux-gpio@vger.kernel.org Subject: [PATCH] pinctrl: renesas: rzg2l: Use devm_clk_get_enabled() helper Date: Sat, 22 Jul 2023 22:41:56 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org The devm_clk_get_enabled() helper: - calls devm_clk_get() - calls clk_prepare_enable() and registers what is needed in order to call clk_disable_unprepare() when needed, as a managed resource. This simplifies the code and avoids the need of a dedicated function used with devm_add_action_or_reset(). While at it, use dev_err_probe() which filters -EPROBE_DEFER. Signed-off-by: Christophe JAILLET --- drivers/pinctrl/renesas/pinctrl-rzg2l.c | 30 ++++--------------------- 1 file changed, 4 insertions(+), 26 deletions(-) diff --git a/drivers/pinctrl/renesas/pinctrl-rzg2l.c b/drivers/pinctrl/renesas/pinctrl-rzg2l.c index 2f1a08210fd6..b2d05cfe5d8c 100644 --- a/drivers/pinctrl/renesas/pinctrl-rzg2l.c +++ b/drivers/pinctrl/renesas/pinctrl-rzg2l.c @@ -1471,11 +1471,6 @@ static int rzg2l_pinctrl_register(struct rzg2l_pinctrl *pctrl) return 0; } -static void rzg2l_pinctrl_clk_disable(void *data) -{ - clk_disable_unprepare(data); -} - static int rzg2l_pinctrl_probe(struct platform_device *pdev) { struct rzg2l_pinctrl *pctrl; @@ -1501,33 +1496,16 @@ static int rzg2l_pinctrl_probe(struct platform_device *pdev) if (IS_ERR(pctrl->base)) return PTR_ERR(pctrl->base); - pctrl->clk = devm_clk_get(pctrl->dev, NULL); - if (IS_ERR(pctrl->clk)) { - ret = PTR_ERR(pctrl->clk); - dev_err(pctrl->dev, "failed to get GPIO clk : %i\n", ret); - return ret; - } + pctrl->clk = devm_clk_get_enabled(pctrl->dev, NULL); + if (IS_ERR(pctrl->clk)) + return dev_err_probe(pctrl->dev, PTR_ERR(pctrl->clk), + "failed to get GPIO clk\n"); spin_lock_init(&pctrl->lock); spin_lock_init(&pctrl->bitmap_lock); platform_set_drvdata(pdev, pctrl); - ret = clk_prepare_enable(pctrl->clk); - if (ret) { - dev_err(pctrl->dev, "failed to enable GPIO clk: %i\n", ret); - return ret; - } - - ret = devm_add_action_or_reset(&pdev->dev, rzg2l_pinctrl_clk_disable, - pctrl->clk); - if (ret) { - dev_err(pctrl->dev, - "failed to register GPIO clk disable action, %i\n", - ret); - return ret; - } - ret = rzg2l_pinctrl_register(pctrl); if (ret) return ret;