linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* of_clk_get() / devm_clk_get()
@ 2013-02-14  4:17 Tony Prisk
  2013-02-14  4:40 ` Stephen Warren
  0 siblings, 1 reply; 4+ messages in thread
From: Tony Prisk @ 2013-02-14  4:17 UTC (permalink / raw)
  To: linux-arm-kernel

Currently we have devm_clk_get() which gives a managed-resource clk (by
name), or of_clk_get() which gives an unmanaged resource clk (by id).

I just wanted to sound out everyone as to whether there is a need for a
managed version of the of_clk_get.

My personal concern about devm_clk_get is that it requires (if I
understand correctly) that the DT node have the clock-names property
(which is optional). If the optional name is not supplied, it fails.
This basically makes it 'not optional' when a driver uses devm_clk_get.
(Please correct me if I'm wrong about this).

Everything below here is irrelevant if the above is wrong :)


If the above IS correct, then couldn't we have a devm_of_clk_get which
accepts a *id (as per devm_clk_get) AND an index (as per of_clk_get),
with the *id given priority.

Something along the lines of...

struct clk *devm_of_clk_get(struct device *dev,
			    const char *id,
			    int index)
{
	struct clk **ptr, *clk = NULL;

	if (id)
		clk = devm_clk_get(dev, id);

	if (!clk || IS_ERR(clk)) {
		clk = of_clk_get(dev->of_node, index);
		if (!IS_ERR(clk)) {
			ptr = devres_alloc(devm_clk_release,
					   sizeof(*ptr),
					   GFP_KERNEL)
			if (!ptr)
				return ERR_PTR(-ENOMEM);

			*ptr = clk;
			devres_add(dev, ptr);
		}
	}

	return clk;
}

This would make clock-names optional (as intended) and give a fallback
to the index when clock-names isn't specified.

One issue (which I don't know how much of an issue it is) is that this
doesn't follow the normal pattern of normal_func -> devm_func parameter
layout.


Regards
Tony Prisk

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-02-14 17:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-14  4:17 of_clk_get() / devm_clk_get() Tony Prisk
2013-02-14  4:40 ` Stephen Warren
2013-02-14  6:42   ` Tony Prisk
2013-02-14 17:28     ` Stephen Warren

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).