mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] pinctrl: renesas: rzn1: Use devm_clk_get_enabled() in rzn1_pinctrl_probe()
@ 2026-11-23 14:21 Markus Elfring
  2026-11-23 17:08 ` Wolfram Sang
  0 siblings, 1 reply; 2+ messages in thread
From: Markus Elfring @ 2026-11-23 14:21 UTC (permalink / raw)
  To: linux-renesas-soc, linux-gpio, Geert Uytterhoeven, Jacopo Mondi,
	Linus Walleij, Phil Edworthy, Wolfram Sang
  Cc: LKML, kernel-janitors, Andy Shevchenko, Christophe Jaillet,
	Florian Fainelli, Frank Li, Michal Simek

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 23 Nov 2026 15:00:10 +0100

* Reuse existing functionality from devm_clk_get_enabled() instead of
  keeping duplicate source code.

* Delete a clk_disable_unprepare() call on an error handling path
  and the implementation of the function “rzn1_pinctrl_remove”.

* Convert the data structure member “clk” to a local variable.

* Omit the label “err_clk”.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---

V2:
Wolfram Sang requested further adjustments according to the proposed changes.
https://lore.kernel.org/linux-gpio/awQ7qa5FGG9RETtS@ninjato/


 drivers/pinctrl/renesas/pinctrl-rzn1.c | 32 ++++++--------------------
 1 file changed, 7 insertions(+), 25 deletions(-)

diff --git a/drivers/pinctrl/renesas/pinctrl-rzn1.c b/drivers/pinctrl/renesas/pinctrl-rzn1.c
index d8422d740433..64cef35dc9e7 100644
--- a/drivers/pinctrl/renesas/pinctrl-rzn1.c
+++ b/drivers/pinctrl/renesas/pinctrl-rzn1.c
@@ -110,7 +110,6 @@ struct rzn1_pin_group {
 
 struct rzn1_pinctrl {
 	struct device *dev;
-	struct clk *clk;
 	struct pinctrl_dev *pctl;
 	struct rzn1_pinctrl_regs __iomem *lev1;
 	struct rzn1_pinctrl_regs __iomem *lev2;
@@ -849,6 +848,7 @@ static int rzn1_pinctrl_probe(struct platform_device *pdev)
 {
 	struct rzn1_pinctrl *ipctl;
 	struct resource *res;
+	struct clk *clk;
 	int ret;
 
 	/* Create state holders etc for this driver */
@@ -869,12 +869,9 @@ static int rzn1_pinctrl_probe(struct platform_device *pdev)
 		return PTR_ERR(ipctl->lev2);
 	ipctl->lev2_protect_phys = (u32)res->start + 0x400;
 
-	ipctl->clk = devm_clk_get(&pdev->dev, NULL);
-	if (IS_ERR(ipctl->clk))
-		return PTR_ERR(ipctl->clk);
-	ret = clk_prepare_enable(ipctl->clk);
-	if (ret)
-		return ret;
+	clk = devm_clk_get_enabled(&pdev->dev, NULL);
+	if (IS_ERR(clk))
+		return PTR_ERR(clk);
 
 	ipctl->dev = &pdev->dev;
 	rzn1_pinctrl_desc.name = dev_name(&pdev->dev);
@@ -882,37 +879,23 @@ static int rzn1_pinctrl_probe(struct platform_device *pdev)
 	ret = rzn1_pinctrl_probe_dt(pdev, ipctl);
 	if (ret) {
 		dev_err(&pdev->dev, "fail to probe dt properties\n");
-		goto err_clk;
+		return ret;
 	}
 
-	platform_set_drvdata(pdev, ipctl);
-
 	ret = devm_pinctrl_register_and_init(&pdev->dev, &rzn1_pinctrl_desc,
 					     ipctl, &ipctl->pctl);
 	if (ret) {
 		dev_err(&pdev->dev, "could not register rzn1 pinctrl driver\n");
-		goto err_clk;
+		return ret;
 	}
 
 	ret = pinctrl_enable(ipctl->pctl);
 	if (ret)
-		goto err_clk;
+		return ret;
 
 	dev_info(&pdev->dev, "probed\n");
 
 	return 0;
-
-err_clk:
-	clk_disable_unprepare(ipctl->clk);
-
-	return ret;
-}
-
-static void rzn1_pinctrl_remove(struct platform_device *pdev)
-{
-	struct rzn1_pinctrl *ipctl = platform_get_drvdata(pdev);
-
-	clk_disable_unprepare(ipctl->clk);
 }
 
 static const struct of_device_id rzn1_pinctrl_match[] = {
@@ -923,7 +906,6 @@ MODULE_DEVICE_TABLE(of, rzn1_pinctrl_match);
 
 static struct platform_driver rzn1_pinctrl_driver = {
 	.probe	= rzn1_pinctrl_probe,
-	.remove = rzn1_pinctrl_remove,
 	.driver	= {
 		.name		= "rzn1-pinctrl",
 		.of_match_table	= rzn1_pinctrl_match,
-- 
2.56.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] pinctrl: renesas: rzn1: Use devm_clk_get_enabled() in rzn1_pinctrl_probe()
  2026-11-23 14:21 [PATCH v2] pinctrl: renesas: rzn1: Use devm_clk_get_enabled() in rzn1_pinctrl_probe() Markus Elfring
@ 2026-11-23 17:08 ` Wolfram Sang
  0 siblings, 0 replies; 2+ messages in thread
From: Wolfram Sang @ 2026-11-23 17:08 UTC (permalink / raw)
  To: Markus Elfring
  Cc: linux-renesas-soc, linux-gpio, Geert Uytterhoeven, Jacopo Mondi,
	Linus Walleij, Phil Edworthy, LKML, kernel-janitors,
	Andy Shevchenko, Christophe Jaillet, Florian Fainelli, Frank Li,
	Michal Simek

[-- Attachment #1: Type: text/plain, Size: 854 bytes --]

On Mon, Nov 23, 2026 at 03:21:57PM +0100, Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 23 Nov 2026 15:00:10 +0100
> 
> * Reuse existing functionality from devm_clk_get_enabled() instead of
>   keeping duplicate source code.
> 
> * Delete a clk_disable_unprepare() call on an error handling path
>   and the implementation of the function “rzn1_pinctrl_remove”.
> 
> * Convert the data structure member “clk” to a local variable.
> 
> * Omit the label “err_clk”.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

No regressions observed on my N1D board and nice diffstat!

Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-23 17:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-23 14:21 [PATCH v2] pinctrl: renesas: rzn1: Use devm_clk_get_enabled() in rzn1_pinctrl_probe() Markus Elfring
2026-11-23 17:08 ` Wolfram Sang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®