Re: [PATCH 3/3] clk: renesas: rzv2h: Simplify rzv2h_cpg_assert()/rzv2h_cpg_deassert()

From: Geert Uytterhoeven
Date: Thu Apr 10 2025 - 12:26:33 EST


Hi Tommaso,

On Mon, 17 Mar 2025 at 09:33, Tommaso Merciai
<tommaso.merciai.xr@xxxxxxxxxxxxxx> wrote:
> rzv2h_cpg_assert() and rzv2h_cpg_deassert() functions are similar. Share
> this code via __rzv2h_cpg_assert(). This avoid code duplication.
>
> Reported-by: Pavel Machek <pavel@xxxxxxx>
> Closes: https://lore.kernel.org/cip-dev/Z9QA9rwuXCuVbOXp@xxxxxxxxxx/
> Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@xxxxxxxxxxxxxx>

Thanks for your patch!

Reviewed-by: Geert Uytterhoeven <geert+renesas@xxxxxxxxx>
i.e. will queue in renesas-clk for v6.16.

> --- a/drivers/clk/renesas/rzv2h-cpg.c
> +++ b/drivers/clk/renesas/rzv2h-cpg.c
> @@ -652,16 +652,17 @@ rzv2h_cpg_register_mod_clk(const struct rzv2h_mod_clk *mod,
> mod->name, PTR_ERR(clk));
> }
>
> -static int rzv2h_cpg_assert(struct reset_controller_dev *rcdev,
> - unsigned long id)
> +static int __rzv2h_cpg_assert(struct reset_controller_dev *rcdev,
> + unsigned long id, bool assert)
> {
> struct rzv2h_cpg_priv *priv = rcdev_to_priv(rcdev);
> unsigned int reg = GET_RST_OFFSET(priv->resets[id].reset_index);
> u32 mask = BIT(priv->resets[id].reset_bit);
> u8 monbit = priv->resets[id].mon_bit;
> - u32 value = mask << 16;
> + u32 value = assert ? (mask << 16) : ((mask << 16) | mask);

Do you mind if I change this to

u32 value = mask << 16;

if (!assert)
value |= mask;

while applying?

>
> - dev_dbg(rcdev->dev, "assert id:%ld offset:0x%x\n", id, reg);
> + dev_dbg(rcdev->dev, "%s id:%ld offset:0x%x\n",
> + assert ? "assert" : "deassert", id, reg);
>
> writel(value, priv->base + reg);
>

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