Re: [PATCH v3 2/2] clk: renesas: r9a06g032: Add clock domain support

From: Geert Uytterhoeven
Date: Tue May 28 2019 - 03:38:01 EST


Hi Gareth,

On Fri, May 24, 2019 at 5:32 PM Gareth Williams
<gareth.williams.jx@xxxxxxxxxxx> wrote:
> There are several clocks on the r9ag032 which are currently not enabled
> in their drivers that can be delegated to clock domain system for power
> management. Therefore add support for clock domain functionality to the
> r9a06g032 clock driver.
>
> Signed-off-by: Gareth Williams <gareth.williams.jx@xxxxxxxxxxx>

Thanks for the update!

> --- a/drivers/clk/renesas/r9a06g032-clocks.c
> +++ b/drivers/clk/renesas/r9a06g032-clocks.c

> @@ -344,6 +351,86 @@ struct r9a06g032_clk_gate {
>
> #define to_r9a06g032_gate(_hw) container_of(_hw, struct r9a06g032_clk_gate, hw)
>
> +static int create_add_module_clock(struct of_phandle_args *clkspec,
> + struct device *dev)
> +{
> + struct clk *clk;
> + int error = 0;

No need to initialize to 0.

> +
> + clk = of_clk_get_from_provider(clkspec);
> + if (IS_ERR(clk))
> + return PTR_ERR(clk);
> +
> + error = pm_clk_create(dev);

> +static int r9a06g032_attach_dev(struct generic_pm_domain *pd,
> + struct device *dev)
> +{
> + struct device_node *np = dev->of_node;
> + struct of_phandle_args clkspec;
> + int i = 0;
> + int error;
> +
> + while (!of_parse_phandle_with_args(np, "clocks", "#clock-cells", i,
> + &clkspec)) {
> + int index;

scripts/checkpatch.pl says a blank line is missing.
Alternatively, you can move the declaration of index to the top of the
function, together with error and i.

> + if (clkspec.np != pd->dev.of_node)
> + continue;
> +
> + index = clkspec.args[0];
> +
> + if (index < R9A06G032_CLOCK_COUNT &&
> + r9a06g032_clocks[index].managed) {
> + of_node_put(clkspec.np);

As the call below uses clkspec.np, the call to of_node_put() should be
after it, just before the error check.

> +
> + error = create_add_module_clock(&clkspec, dev);
> + if (error)
> + return error;
> + }
> + i++;
> + }
> +
> + return 0;
> +}

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