Skip to contentSkip to conversation

sh: call clock framework init() callback once

PATCH In review Magnus Damm 2 participants 2 messages May 7, 2009 – May 8, 2009 SuperH

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sh: call clock framework init() callback once

From: Magnus Damm <[email protected]>

Make sure that clk->ops->init() only gets called once in the case of CLK_ALWAYS_ENABLED. Without this patch the init() callback may be called multiple times.

---

 arch/sh/kernel/cpu/clock.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
arch/sh/kernel/cpu/clock.c +6 -3
@@ -99,15 +99,18 @@ static int __clk_enable(struct clk *clk)
 	 * changes and the clock needs to hunt for the proper set of
 	 * divisors to use before it can effectively recalc.
 	 */
+
+	if (clk->flags & CLK_ALWAYS_ENABLED) {
+		kref_get(&clk->kref);
+		return 0;
+	}
+
 	if (unlikely(atomic_read(&clk->kref.refcount) = 1))
 		if (clk->ops && clk->ops->init)
 			clk->ops->init(clk);
 
 	kref_get(&clk->kref);
 
-	if (clk->flags & CLK_ALWAYS_ENABLED)
-		return 0;
-
 	if (likely(clk->ops && clk->ops->enable))
 		clk->ops->enable(clk);
 
#1 lore raw

Hi Magnus.

I saw this patch.
I still think the init callback has to be called during the registration... And at the and this is what your are doing with this patch...

Regards
Francesco

Magnus Damm ha scritto:

Quoted 42 lines

From: Magnus Damm <[email protected]>

Make sure that clk->ops->init() only gets called once in the case of CLK_ALWAYS_ENABLED. Without this patch the init() callback may be called multiple times.

---

 arch/sh/kernel/cpu/clock.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
arch/sh/kernel/cpu/clock.c +6 -4
@@ -99,15 +99,18 @@ static int __clk_enable(struct clk *clk)
 	 * changes and the clock needs to hunt for the proper set of
 	 * divisors to use before it can effectively recalc.
 	 */
+
+	if (clk->flags & CLK_ALWAYS_ENABLED) {
+		kref_get(&clk->kref);
+		return 0;
+	}
+
 	if (unlikely(atomic_read(&clk->kref.refcount) = 1))
 		if (clk->ops && clk->ops->init)
 			clk->ops->init(clk);
 
 	kref_get(&clk->kref);
 
-	if (clk->flags & CLK_ALWAYS_ENABLED)
-		return 0;
-
 	if (likely(clk->ops && clk->ops->enable))
 		clk->ops->enable(clk);
 
--

To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html