Re: [PATCH] pinctrl: renesas: rzg2l: Use devm_clk_get_enabled() helper

From: Geert Uytterhoeven
Date: Tue Jul 25 2023 - 03:50:22 EST


Hi Christophe,

On Sat, Jul 22, 2023 at 10:42 PM Christophe JAILLET
<christophe.jaillet@xxxxxxxxxx> wrote:
> 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 <christophe.jaillet@xxxxxxxxxx>

Thanks for your patch!

> --- 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);

clk can become a local variable now.

> + if (IS_ERR(pctrl->clk))
> + return dev_err_probe(pctrl->dev, PTR_ERR(pctrl->clk),
> + "failed to get GPIO clk\n");

failed to enable

Reviewed-by: Geert Uytterhoeven <geert+renesas@xxxxxxxxx>
i.e. will queue in renesas-clk-for-v6.6 with the above changes.
No need to resend.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds