[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <TY1PR01MB17697C2C8BCE98009EBDECF7F5D80@TY1PR01MB1769.jpnprd01.prod.outlook.com>
Date: Mon, 19 Nov 2018 10:41:42 +0000
From: Phil Edworthy <phil.edworthy@...esas.com>
To: Uwe Kleine-König
<u.kleine-koenig@...gutronix.de>
CC: Stephen Boyd <sboyd@...nel.org>,
Michael Turquette <mturquette@...libre.com>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Russell King <linux@...linux.org.uk>,
"linux-clk@...r.kernel.org" <linux-clk@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-renesas-soc@...r.kernel.org"
<linux-renesas-soc@...r.kernel.org>,
Geert Uytterhoeven <geert@...ux-m68k.org>,
"linux-arm-kernel@...ts.infradead.org"
<linux-arm-kernel@...ts.infradead.org>
Subject: RE: [PATCH v6 1/6] clk: Add of_clk_get_by_name_optional() function
Hi Uwe,
On 16 November 2018 16:11 Uwe Kleine-König wrote:
> On Fri, Nov 16, 2018 at 05:01:28PM +0100, Uwe Kleine-König wrote:
> > Other than that I think the patch is fine
>
> Thinking again, I wonder why not just do:
>
> static inline struct clk *clk_get_optional(struct device *dev, const char *id) {
> struct clk *c = clk_get(dev, id);
>
> if (c == ERR_PTR(-ENOENT))
> return NULL;
> else
> return c;
> }
Unfortunately, underneath this __of_clk_get_by_name() returns -EINVAL
when looking for a named clock, and the "clock-names" OF property can't
be found or the name is not in that prop. This is because the index
returned by of_property_match_string() will be an error code and is then
currently always passed to __of_clk_get().
If, as you said, I split the patches into one that fixes the error code, and then
adds clk_get_optional() like above, it will make more sense.
btw, do we need to add of_clk_get_by_name_optional()? I only added it as a
counterpart to of_clk_get_by_name(), but it may not be needed.
Thanks
Phil
Powered by blists - more mailing lists