* [PATCH] sh: clkfw: Added the .set_rate_ex callback in the clock operation
@ 2009-05-11 16:20 Francesco VIRLINZI
2009-05-11 16:34 ` [PATCH] sh: clkfw: Added the .set_rate_ex callback in the clock operation [v2] Francesco VIRLINZI
2009-05-14 3:42 ` Paul Mundt
0 siblings, 2 replies; 3+ messages in thread
From: Francesco VIRLINZI @ 2009-05-11 16:20 UTC (permalink / raw)
To: linux-sh
This patch adds the .set_rate_ex callback to manage clearly the
clk_set_rate() operation and the operation under clk_set_rate_ex().
Signed-off-by: Francesco Virlinzi <francesco.virlinzi@st.com>
---
arch/sh/include/asm/clock.h | 3 ++-
arch/sh/kernel/cpu/clock.c | 19 ++++++++++++++++---
arch/sh/kernel/cpu/sh4/clock-sh4-202.c | 5 ++---
arch/sh/kernel/cpu/sh4a/clock-sh7722.c | 9 ++++-----
4 files changed, 24 insertions(+), 12 deletions(-)
diff --git a/arch/sh/include/asm/clock.h b/arch/sh/include/asm/clock.h
index b1f2919..ba9114b 100644
--- a/arch/sh/include/asm/clock.h
+++ b/arch/sh/include/asm/clock.h
@@ -13,7 +13,8 @@ struct clk_ops {
void (*enable)(struct clk *clk);
void (*disable)(struct clk *clk);
void (*recalc)(struct clk *clk);
- int (*set_rate)(struct clk *clk, unsigned long rate, int algo_id);
+ int (*set_rate)(struct clk *clk, unsigned long rate);
+ int (*set_rate_ex)(struct clk *clk, unsigned long rate, int algo_id);
int (*set_parent)(struct clk *clk, struct clk *parent);
long (*round_rate)(struct clk *clk, unsigned long rate);
};
diff --git a/arch/sh/kernel/cpu/clock.c b/arch/sh/kernel/cpu/clock.c
index 133dbe4..f97a0c6 100644
--- a/arch/sh/kernel/cpu/clock.c
+++ b/arch/sh/kernel/cpu/clock.c
@@ -211,7 +211,20 @@ EXPORT_SYMBOL_GPL(clk_get_rate);
int clk_set_rate(struct clk *clk, unsigned long rate)
{
- return clk_set_rate_ex(clk, rate, 0);
+ int ret = -EOPNOTSUPP;
+
+ if (likely(clk->ops && clk->ops->set_rate))
+ unsigned long flags;
+
+ spin_lock_irqsave(&clock_lock, flags);
+ ret = clk->ops->set_rate_ex(clk, rate);
+ spin_unlock_irqrestore(&clock_lock, flags);
+ }
+
+ if (unlikely(clk->flags & CLK_RATE_PROPAGATES)){
+ propagate_rate(clk);
+
+ return ret;
}
EXPORT_SYMBOL_GPL(clk_set_rate);
@@ -219,11 +232,11 @@ int clk_set_rate_ex(struct clk *clk, unsigned long rate, int algo_id)
{
int ret = -EOPNOTSUPP;
- if (likely(clk->ops && clk->ops->set_rate)) {
+ if (likely(clk->ops && clk->ops->set_rate_ex)) {
unsigned long flags;
spin_lock_irqsave(&clock_lock, flags);
- ret = clk->ops->set_rate(clk, rate, algo_id);
+ ret = clk->ops->set_rate_ex(clk, rate, algo_id);
spin_unlock_irqrestore(&clock_lock, flags);
}
diff --git a/arch/sh/kernel/cpu/sh4/clock-sh4-202.c b/arch/sh/kernel/cpu/sh4/clock-sh4-202.c
index a334294..eb22dcc 100644
--- a/arch/sh/kernel/cpu/sh4/clock-sh4-202.c
+++ b/arch/sh/kernel/cpu/sh4/clock-sh4-202.c
@@ -82,8 +82,7 @@ static void shoc_clk_init(struct clk *clk)
for (i = 0; i < ARRAY_SIZE(frqcr3_divisors); i++) {
int divisor = frqcr3_divisors[i];
- if (clk->ops->set_rate(clk, clk->parent->rate /
- divisor, 0) = 0)
+ if (clk->ops->set_rate(clk, clk->parent->rate / divisor) = 0)
break;
}
@@ -111,7 +110,7 @@ static int shoc_clk_verify_rate(struct clk *clk, unsigned long rate)
return 0;
}
-static int shoc_clk_set_rate(struct clk *clk, unsigned long rate, int algo_id)
+static int shoc_clk_set_rate(struct clk *clk, unsigned long rate)
{
unsigned long frqcr3;
unsigned int tmp;
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7722.c b/arch/sh/kernel/cpu/sh4a/clock-sh7722.c
index 1ccdfc5..9546904 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7722.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7722.c
@@ -191,7 +191,7 @@ static void module_clk_recalc(struct clk *clk)
#define FRQCRKICK 0x00000000
#endif
-static int master_clk_setrate(struct clk *clk, unsigned long rate, int id)
+static int master_clk_setrate(struct clk *clk, unsigned long rate)
{
int div = rate / clk->rate;
int master_divs[] = MASTERDIVS;
@@ -433,7 +433,7 @@ static long sh7722_frqcr_round_rate(struct clk *clk, unsigned long rate)
static struct clk_ops sh7722_frqcr_clk_ops = {
.recalc = sh7722_frqcr_recalc,
- .set_rate = sh7722_frqcr_set_rate,
+ .set_rate_ex = sh7722_frqcr_set_rate,
.round_rate = sh7722_frqcr_round_rate,
};
@@ -444,7 +444,7 @@ static struct clk_ops sh7722_frqcr_clk_ops = {
#ifndef CONFIG_CPU_SUBTYPE_SH7343
-static int sh7722_siu_set_rate(struct clk *clk, unsigned long rate, int algo_id)
+static int sh7722_siu_set_rate(struct clk *clk, unsigned long rate)
{
unsigned long r;
int div;
@@ -513,8 +513,7 @@ static void sh7722_video_disable(struct clk *clk)
ctrl_outl( r | (1<<8), VCLKCR);
}
-static int sh7722_video_set_rate(struct clk *clk, unsigned long rate,
- int algo_id)
+static int sh7722_video_set_rate(struct clk *clk, unsigned long rate)
{
unsigned long r;
--
1.6.0.6
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH] sh: clkfw: Added the .set_rate_ex callback in the clock operation [v2]
2009-05-11 16:20 [PATCH] sh: clkfw: Added the .set_rate_ex callback in the clock operation Francesco VIRLINZI
@ 2009-05-11 16:34 ` Francesco VIRLINZI
2009-05-14 3:42 ` Paul Mundt
1 sibling, 0 replies; 3+ messages in thread
From: Francesco VIRLINZI @ 2009-05-11 16:34 UTC (permalink / raw)
To: linux-sh
This patch adds the .set_rate_ex callback to manage clearly the
clk_set_rate() operation and the operation under clk_set_rate_ex().
Signed-off-by: Francesco Virlinzi <francesco.virlinzi@st.com>
---
arch/sh/include/asm/clock.h | 3 ++-
arch/sh/kernel/cpu/clock.c | 22 +++++++++++++++++-----
arch/sh/kernel/cpu/sh4/clock-sh4-202.c | 5 ++---
arch/sh/kernel/cpu/sh4a/clock-sh7722.c | 9 ++++-----
4 files changed, 25 insertions(+), 14 deletions(-)
diff --git a/arch/sh/include/asm/clock.h b/arch/sh/include/asm/clock.h
index b1f2919..ba9114b 100644
--- a/arch/sh/include/asm/clock.h
+++ b/arch/sh/include/asm/clock.h
@@ -13,7 +13,8 @@ struct clk_ops {
void (*enable)(struct clk *clk);
void (*disable)(struct clk *clk);
void (*recalc)(struct clk *clk);
- int (*set_rate)(struct clk *clk, unsigned long rate, int algo_id);
+ int (*set_rate)(struct clk *clk, unsigned long rate);
+ int (*set_rate_ex)(struct clk *clk, unsigned long rate, int algo_id);
int (*set_parent)(struct clk *clk, struct clk *parent);
long (*round_rate)(struct clk *clk, unsigned long rate);
};
diff --git a/arch/sh/kernel/cpu/clock.c b/arch/sh/kernel/cpu/clock.c
index 133dbe4..b2791ee 100644
--- a/arch/sh/kernel/cpu/clock.c
+++ b/arch/sh/kernel/cpu/clock.c
@@ -211,7 +211,20 @@ EXPORT_SYMBOL_GPL(clk_get_rate);
int clk_set_rate(struct clk *clk, unsigned long rate)
{
- return clk_set_rate_ex(clk, rate, 0);
+ int ret = -EOPNOTSUPP;
+
+ if (likely(clk->ops && clk->ops->set_rate)) {
+ unsigned long flags;
+
+ spin_lock_irqsave(&clock_lock, flags);
+ ret = clk->ops->set_rate(clk, rate);
+ spin_unlock_irqrestore(&clock_lock, flags);
+ }
+
+ if (unlikely(clk->flags & CLK_RATE_PROPAGATES))
+ propagate_rate(clk);
+
+ return ret;
}
EXPORT_SYMBOL_GPL(clk_set_rate);
@@ -219,11 +232,11 @@ int clk_set_rate_ex(struct clk *clk, unsigned long rate, int algo_id)
{
int ret = -EOPNOTSUPP;
- if (likely(clk->ops && clk->ops->set_rate)) {
+ if (likely(clk->ops && clk->ops->set_rate_ex)) {
unsigned long flags;
spin_lock_irqsave(&clock_lock, flags);
- ret = clk->ops->set_rate(clk, rate, algo_id);
+ ret = clk->ops->set_rate_ex(clk, rate, algo_id);
spin_unlock_irqrestore(&clock_lock, flags);
}
@@ -386,8 +399,7 @@ static int clks_sysdev_suspend(struct sys_device *dev, pm_message_t state)
clkp->ops->set_parent(clkp,
clkp->parent);
if (likely(clkp->ops->set_rate))
- clkp->ops->set_rate(clkp,
- rate, NO_CHANGE);
+ clkp->ops->set_rate(clkp, rate);
else if (likely(clkp->ops->recalc))
clkp->ops->recalc(clkp);
}
diff --git a/arch/sh/kernel/cpu/sh4/clock-sh4-202.c b/arch/sh/kernel/cpu/sh4/clock-sh4-202.c
index a334294..eb22dcc 100644
--- a/arch/sh/kernel/cpu/sh4/clock-sh4-202.c
+++ b/arch/sh/kernel/cpu/sh4/clock-sh4-202.c
@@ -82,8 +82,7 @@ static void shoc_clk_init(struct clk *clk)
for (i = 0; i < ARRAY_SIZE(frqcr3_divisors); i++) {
int divisor = frqcr3_divisors[i];
- if (clk->ops->set_rate(clk, clk->parent->rate /
- divisor, 0) = 0)
+ if (clk->ops->set_rate(clk, clk->parent->rate / divisor) = 0)
break;
}
@@ -111,7 +110,7 @@ static int shoc_clk_verify_rate(struct clk *clk, unsigned long rate)
return 0;
}
-static int shoc_clk_set_rate(struct clk *clk, unsigned long rate, int algo_id)
+static int shoc_clk_set_rate(struct clk *clk, unsigned long rate)
{
unsigned long frqcr3;
unsigned int tmp;
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7722.c b/arch/sh/kernel/cpu/sh4a/clock-sh7722.c
index 1ccdfc5..9546904 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7722.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7722.c
@@ -191,7 +191,7 @@ static void module_clk_recalc(struct clk *clk)
#define FRQCRKICK 0x00000000
#endif
-static int master_clk_setrate(struct clk *clk, unsigned long rate, int id)
+static int master_clk_setrate(struct clk *clk, unsigned long rate)
{
int div = rate / clk->rate;
int master_divs[] = MASTERDIVS;
@@ -433,7 +433,7 @@ static long sh7722_frqcr_round_rate(struct clk *clk, unsigned long rate)
static struct clk_ops sh7722_frqcr_clk_ops = {
.recalc = sh7722_frqcr_recalc,
- .set_rate = sh7722_frqcr_set_rate,
+ .set_rate_ex = sh7722_frqcr_set_rate,
.round_rate = sh7722_frqcr_round_rate,
};
@@ -444,7 +444,7 @@ static struct clk_ops sh7722_frqcr_clk_ops = {
#ifndef CONFIG_CPU_SUBTYPE_SH7343
-static int sh7722_siu_set_rate(struct clk *clk, unsigned long rate, int algo_id)
+static int sh7722_siu_set_rate(struct clk *clk, unsigned long rate)
{
unsigned long r;
int div;
@@ -513,8 +513,7 @@ static void sh7722_video_disable(struct clk *clk)
ctrl_outl( r | (1<<8), VCLKCR);
}
-static int sh7722_video_set_rate(struct clk *clk, unsigned long rate,
- int algo_id)
+static int sh7722_video_set_rate(struct clk *clk, unsigned long rate)
{
unsigned long r;
--
1.6.0.6
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] sh: clkfw: Added the .set_rate_ex callback in the clock operation [v2]
2009-05-11 16:20 [PATCH] sh: clkfw: Added the .set_rate_ex callback in the clock operation Francesco VIRLINZI
2009-05-11 16:34 ` [PATCH] sh: clkfw: Added the .set_rate_ex callback in the clock operation [v2] Francesco VIRLINZI
@ 2009-05-14 3:42 ` Paul Mundt
1 sibling, 0 replies; 3+ messages in thread
From: Paul Mundt @ 2009-05-14 3:42 UTC (permalink / raw)
To: linux-sh
On Mon, May 11, 2009 at 06:34:13PM +0200, Francesco VIRLINZI wrote:
> This patch adds the .set_rate_ex callback to manage clearly the
> clk_set_rate() operation and the operation under clk_set_rate_ex().
>
No. If you don't need to use algo_id, then just ignore it. We are not
going to have two different clock ops that do exactly the same thing
because you don't like the extra argument.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-05-14 3:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-11 16:20 [PATCH] sh: clkfw: Added the .set_rate_ex callback in the clock operation Francesco VIRLINZI
2009-05-11 16:34 ` [PATCH] sh: clkfw: Added the .set_rate_ex callback in the clock operation [v2] Francesco VIRLINZI
2009-05-14 3:42 ` Paul Mundt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox