linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] BUG: clk_find() misses some clocks
@ 2012-08-17  9:47 Richard Genoud
  2012-08-17  9:58 ` Russell King - ARM Linux
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Genoud @ 2012-08-17  9:47 UTC (permalink / raw)
  To: linux-arm-kernel

if a clock is declared like that:
CLKDEV_CON_DEV_ID("pioA", "fffff400.gpio", &pioAB_clk)
(so, dev_id AND con_id are defined)
and the driver looks for a dev_id (but no specific con_id) like that:
clock = clk_get(&pdev->dev, NULL);

The clock won't be found:

if (dev_id)
	best_possible += 2; /* dev_id != NULL */
if (con_id)
	best_possible += 1; /* con_id == NULL */
/* => so best possible == 2 */

list_for_each_entry(p, &clocks, node) {
	match = 0;
/*
 * checking p->dev_id = "fffff400.gpio" and p->con_id = "pioA"
 * against dev_id = "fffff400.gpio" and con_id = NULL
 */
	if (p->dev_id) { /* ok, p->dev_id exists */
	 /* and, we are lucky, there's a match ! \o/ */
		if (!dev_id || strcmp(p->dev_id, dev_id))
			continue;
		match += 2;
	}
/* so we have match == 2 */

	if (p->con_id) {
		/* p->con_id is not null */
		if (!con_id || strcmp(p->con_id, con_id))
		/*
		 * too bad !! con_id is null !
		 * even if we have best_possible == match
		 * our clock won't be selected
		 */
			continue;
		match += 1;
	}

	if (match > best_found) {
		cl = p;
		if (match != best_possible)
			best_found = match;
		else
			break;
	}
}

Signed-off-by: Richard Genoud <richard.genoud@gmail.com>
---
 drivers/clk/clkdev.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c
index d423c9b..e28b120 100644
--- a/drivers/clk/clkdev.c
+++ b/drivers/clk/clkdev.c
@@ -114,13 +114,13 @@ static struct clk_lookup *clk_find(const char *dev_id, const char *con_id)
 
 	list_for_each_entry(p, &clocks, node) {
 		match = 0;
-		if (p->dev_id) {
-			if (!dev_id || strcmp(p->dev_id, dev_id))
+		if (p->dev_id && dev_id) {
+			if (strcmp(p->dev_id, dev_id))
 				continue;
 			match += 2;
 		}
-		if (p->con_id) {
-			if (!con_id || strcmp(p->con_id, con_id))
+		if (p->con_id && con_id) {
+			if (strcmp(p->con_id, con_id))
 				continue;
 			match += 1;
 		}
-- 
1.7.2.5

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

end of thread, other threads:[~2012-08-17 11:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-17  9:47 [PATCH] BUG: clk_find() misses some clocks Richard Genoud
2012-08-17  9:58 ` Russell King - ARM Linux
2012-08-17 10:23   ` Richard Genoud
2012-08-17 11:34     ` Russell King - ARM Linux

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).