[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAGb2v661GYVmq9Xvw9j3RN1jV5Xe2c-naHkvEcVFSbHkeW3HBQ@mail.gmail.com>
Date: Tue, 11 Jun 2019 14:46:17 +0800
From: wens Tsai <wens213@...il.com>
To: Alexandre Mergnat <amergnat@...libre.com>,
Stephen Boyd <sboyd@...nel.org>
Cc: Mike Turquette <mturquette@...libre.com>,
linux-clk <linux-clk@...r.kernel.org>,
linux-kernel <linux-kernel@...r.kernel.org>,
baylibre-upstreaming@...ups.io,
Jerome Brunet <jbrunet@...libre.com>
Subject: Re: [PATCH] clk: fix clock global name usage.
On Fri, May 24, 2019 at 3:29 PM Alexandre Mergnat <amergnat@...libre.com> wrote:
>
> A recent patch allows the clock framework to specify the parent
> relationship with either the clk_hw pointer, the global name or through
> Device Tree name.
>
> But the global name isn't handled by the clk framework because the DT name
> is considered valid even if it's NULL, so of_clk_get_hw() returns an
> unexpected clock (the first clock specified in DT).
>
> This can be fixed by calling of_clk_get_hw() only when DT name is not NULL.
>
> Fixes: fc0c209c147f ("clk: Allow parents to be specified without string names")
> Cc: Jerome Brunet <jbrunet@...libre.com>
> Signed-off-by: Alexandre Mergnat <amergnat@...libre.com>
> ---
> drivers/clk/clk.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> index bdb077ba59b9..9624a75e5a8d 100644
> --- a/drivers/clk/clk.c
> +++ b/drivers/clk/clk.c
> @@ -368,7 +368,7 @@ static struct clk_core *clk_core_get(struct clk_core *core, u8 p_index)
> const char *dev_id = dev ? dev_name(dev) : NULL;
> struct device_node *np = core->of_node;
>
> - if (np && index >= 0)
> + if (name && np && index >= 0)
I think the opposite should be the case. If either the name or index is valid,
and there's a device node backing it, the code path should be entered.
This is implied by the description of struct clk_parent_data:
@index: parent index local to provider registering clk (if @fw_name absent)
So the code path should be valid regardless of the value of .index.
That would make it
if (np && (name || index >= 0)) ...
Regards
ChenYu
> hw = of_clk_get_hw(np, index, name);
>
> /*
> --
> 2.17.1
>
Powered by blists - more mailing lists