sh: Implement clk_round_rate() in the clock framework.
authorPaul Mundt <lethal@linux-sh.org>
Fri, 20 Jul 2007 04:29:09 +0000 (13:29 +0900)
committerPaul Mundt <lethal@linux-sh.org>
Fri, 20 Jul 2007 04:29:09 +0000 (13:29 +0900)
This is an optional component of the clock framework. However,
as we're going to be using this in the cpufreq drivers, add
support for it to the framework.

Signed-off-by: Paul Mundt <lethal@linux-sh.org>
arch/sh/kernel/cpu/clock.c
include/asm-sh/clock.h

index 63251549e9a8b2dfddf1308f6ce13374cf8f9942..92807ffa8e2036a9d4ac66dbcf5d3e86276ea309 100644 (file)
@@ -229,6 +229,22 @@ void clk_recalc_rate(struct clk *clk)
 }
 EXPORT_SYMBOL_GPL(clk_recalc_rate);
 
+long clk_round_rate(struct clk *clk, unsigned long rate)
+{
+       if (likely(clk->ops && clk->ops->round_rate)) {
+               unsigned long flags, rounded;
+
+               spin_lock_irqsave(&clock_lock, flags);
+               rounded = clk->ops->round_rate(clk, rate);
+               spin_unlock_irqrestore(&clock_lock, flags);
+
+               return rounded;
+       }
+
+       return clk_get_rate(clk);
+}
+EXPORT_SYMBOL_GPL(clk_round_rate);
+
 /*
  * Returns a clock. Note that we first try to use device id on the bus
  * and clock name. If this fails, we try to use clock name only.
index 386d797d86b79f47b4fa2dfa82fc72b0a0a44b05..b550a27a7042c85bc856a39b0eec86dcba0ca9a8 100644 (file)
@@ -14,6 +14,7 @@ struct clk_ops {
        void (*disable)(struct clk *clk);
        void (*recalc)(struct clk *clk);
        int (*set_rate)(struct clk *clk, unsigned long rate, int algo_id);
+       long (*round_rate)(struct clk *clk, unsigned long rate);
 };
 
 struct clk {