Thread (10 messages) 10 messages, 2 authors, 2018-11-19

[PATCH v6 1/6] clk: Add of_clk_get_by_name_optional() function

From: Phil Edworthy <hidden>
Date: 2018-11-19 12:53:55
Also in: linux-clk, linux-renesas-soc, lkml

Hi Uwe,

On 19 November 2018 10:46 Uwe Kleine-K?nig wrote:
On Mon, Nov 19, 2018 at 10:41:42AM +0000, Phil Edworthy wrote:
quoted
On 16 November 2018 16:11 Uwe Kleine-K?nig wrote:
quoted
On Fri, Nov 16, 2018 at 05:01:28PM +0100, Uwe Kleine-K?nig wrote:
quoted
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) {
quoted
quoted
	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.
Sounds like a good plan.
Now that I have removed of_clk_get_by_name_optional(), I see that clk_get()
deals with __of_clk_get_by_name() returning -EINVAL and -ENOENT the same
way. In both cases, clk_get_sys() will return -ENOENT... i.e. I no longer need to
modify __of_clk_get_by_name().
All I need is a simple wrapper just as you have outlined above.
quoted
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.
I don't need it. Given that it is easy to add when someone has a need, I'd say,
skip it for now.
I'm wondering if we actually need clk_get_optional(). For me at least, I just
want devm_clk_get_optional(). That would get rid of the arch patches.

Thanks
Phil
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help