linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: linux@prisktech.co.nz (Tony Prisk)
To: linux-arm-kernel@lists.infradead.org
Subject: of_clk_get() / devm_clk_get()
Date: Thu, 14 Feb 2013 17:17:05 +1300	[thread overview]
Message-ID: <1360815425.21991.20.camel@gitbox> (raw)

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

             reply	other threads:[~2013-02-14  4:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-14  4:17 Tony Prisk [this message]
2013-02-14  4:40 ` of_clk_get() / devm_clk_get() Stephen Warren
2013-02-14  6:42   ` Tony Prisk
2013-02-14 17:28     ` Stephen Warren

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1360815425.21991.20.camel@gitbox \
    --to=linux@prisktech.co.nz \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).