[PATCH] BUG: clk_find() misses some clocks

Richard Genoud richard.genoud at gmail.com
Fri Aug 17 05:47:23 EDT 2012


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 at 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




More information about the linux-arm-kernel mailing list