Re: [PATCH 2/2] pinctrl: renesas: rzt2h: Skip PFC mode configuration if already set
From: Geert Uytterhoeven
Date: Fri May 22 2026 - 06:12:50 EST
Hi Prabhakar,
On Wed, 13 May 2026 at 13:53, Prabhakar <prabhakar.csengg@xxxxxxxxx> wrote:
> From: Lad Prabhakar <prabhakar.mahadev-lad.rj@xxxxxxxxxxxxxx>
>
> In rzt2h_pinctrl_set_pfc_mode(), read the PMC and PFC registers upfront
> and skip the pin function configuration if the pin is already in
> peripheral mode with the desired function.
>
> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@xxxxxxxxxxxxxx>
Thanks for your patch!
> --- a/drivers/pinctrl/renesas/pinctrl-rzt2h.c
> +++ b/drivers/pinctrl/renesas/pinctrl-rzt2h.c
> @@ -188,8 +188,18 @@ static void rzt2h_pinctrl_set_pfc_mode(struct rzt2h_pinctrl *pctrl,
> {
> u64 reg64;
> u16 reg16;
> + u8 pmc;
>
> guard(raw_spinlock_irqsave)(&pctrl->lock);
Missing blank line.
> + reg64 = rzt2h_pinctrl_readq(pctrl, port, PFC(port));
> + pmc = (pctrl, port, PMC(port));
> + /* Check if pin is already configured to the desired function */
> + if (pmc & BIT(pin)) {
> + u8 current_func = field_get(PFC_PIN_MASK(pin), reg64);
> +
> + if (current_func == func)
> + return;
> + }
I will shrink that to
if ((rzt2h_pinctrl_readb(pctrl, port, PMC(port)) & BIT(pin)) &&
field_get(PFC_PIN_MASK(pin), reg64) == func)
return;
while applying.
>
> /* Set pin to 'Non-use (Hi-Z input protection)' */
> reg16 = rzt2h_pinctrl_readw(pctrl, port, PM(port));
Reviewed-by: Geert Uytterhoeven <geert+renesas@xxxxxxxxx>
i.e. will queue in renesas-pinctrl for v7.2.
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