]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ARM pxa: fix clock lookup to find specific device clocks
authorRussell King <rmk+kernel@arm.linux.org.uk>
Sun, 24 Feb 2008 14:55:37 +0000 (15:55 +0100)
committerChris Wright <chrisw@sous-sol.org>
Mon, 24 Mar 2008 18:47:17 +0000 (11:47 -0700)
commit: a0dd005d1d9f4c3beab52086f3844ef9342d1e67

Ensure that the clock lookup always finds an entry for a specific
device and ID before it falls back to finding just by ID.  This
fixes a problem reported by Holger Schurig where the BTUART was
assigned the wrong clock.

Tested-by: Holger Schurig <hs4233@mail.mn-solutions.de>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Uli Luckas notes:

  The patch fixes the otherwise unusable bluetooth uart on pxa25x. The
  patch is written by Russell King [1] who also gave his OK for
  stable inclusion [2].  The patch is also available as commit
  a0dd005d1d9f4c3beab52086f3844ef9342d1e67 to Linus' tree.

  [1] http://marc.info/?l=linux-arm-kernel&m=120298366510315
  [2] http://marc.info/?l=linux-arm-kernel&m=120384388411097

Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
arch/arm/mach-pxa/clock.c

index 83ef5ecaf432513eabe2c6e9f09c72dbedae9139..df5ae2710ab1744197e1fc8d77bccce41f575622 100644 (file)
@@ -23,18 +23,27 @@ static LIST_HEAD(clocks);
 static DEFINE_MUTEX(clocks_mutex);
 static DEFINE_SPINLOCK(clocks_lock);
 
+static struct clk *clk_lookup(struct device *dev, const char *id)
+{
+       struct clk *p;
+
+       list_for_each_entry(p, &clocks, node)
+               if (strcmp(id, p->name) == 0 && p->dev == dev)
+                       return p;
+
+       return NULL;
+}
+
 struct clk *clk_get(struct device *dev, const char *id)
 {
        struct clk *p, *clk = ERR_PTR(-ENOENT);
 
        mutex_lock(&clocks_mutex);
-       list_for_each_entry(p, &clocks, node) {
-               if (strcmp(id, p->name) == 0 &&
-                   (p->dev == NULL || p->dev == dev)) {
-                       clk = p;
-                       break;
-               }
-       }
+       p = clk_lookup(dev, id);
+       if (!p)
+               p = clk_lookup(NULL, id);
+       if (p)
+               clk = p;
        mutex_unlock(&clocks_mutex);
 
        return clk;