All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 07/10] sh: clkfwk: add clk_rate_multi_range_round()
@ 2011-09-09 10:27 Kuninori Morimoto
  2011-09-16 10:29 ` Paul Mundt
  2011-09-20  1:18 ` Kuninori Morimoto
  0 siblings, 2 replies; 3+ messages in thread
From: Kuninori Morimoto @ 2011-09-09 10:27 UTC (permalink / raw)
  To: linux-sh

Some Clock Pulse Generator has PLL multiplication.
clk_rate_multi_range_round() will be good helper for it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 drivers/sh/clk/core.c  |   20 ++++++++++++++++++++
 include/linux/sh_clk.h |    3 +++
 2 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/drivers/sh/clk/core.c b/drivers/sh/clk/core.c
index dc8d022..f4323a3 100644
--- a/drivers/sh/clk/core.c
+++ b/drivers/sh/clk/core.c
@@ -173,6 +173,26 @@ long clk_rate_div_range_round(struct clk *clk, unsigned int div_min,
 	return clk_rate_round_helper(&div_range_round);
 }
 
+static long clk_rate_multi_range_iter(unsigned int pos,
+				      struct clk_rate_round_data *rounder)
+{
+	return clk_get_rate(rounder->arg) * pos;
+}
+
+long clk_rate_multi_range_round(struct clk *clk, unsigned int div_min,
+				unsigned int div_max, unsigned long rate)
+{
+	struct clk_rate_round_data div_range_round = {
+		.min	= div_min,
+		.max	= div_max,
+		.func	= clk_rate_multi_range_iter,
+		.arg	= clk_get_parent(clk),
+		.rate	= rate,
+	};
+
+	return clk_rate_round_helper(&div_range_round);
+}
+
 int clk_rate_table_find(struct clk *clk,
 			struct cpufreq_frequency_table *freq_table,
 			unsigned long rate)
diff --git a/include/linux/sh_clk.h b/include/linux/sh_clk.h
index 3ccf186..1fc9f28 100644
--- a/include/linux/sh_clk.h
+++ b/include/linux/sh_clk.h
@@ -94,6 +94,9 @@ int clk_rate_table_find(struct clk *clk,
 long clk_rate_div_range_round(struct clk *clk, unsigned int div_min,
 			      unsigned int div_max, unsigned long rate);
 
+long clk_rate_multi_range_round(struct clk *clk, unsigned int div_min,
+				unsigned int div_max, unsigned long rate);
+
 long clk_round_parent(struct clk *clk, unsigned long target,
 		      unsigned long *best_freq, unsigned long *parent_freq,
 		      unsigned int div_min, unsigned int div_max);
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 07/10] sh: clkfwk: add clk_rate_multi_range_round()
  2011-09-09 10:27 [PATCH 07/10] sh: clkfwk: add clk_rate_multi_range_round() Kuninori Morimoto
@ 2011-09-16 10:29 ` Paul Mundt
  2011-09-20  1:18 ` Kuninori Morimoto
  1 sibling, 0 replies; 3+ messages in thread
From: Paul Mundt @ 2011-09-16 10:29 UTC (permalink / raw)
  To: linux-sh

On Fri, Sep 09, 2011 at 03:27:43AM -0700, Kuninori Morimoto wrote:
> Some Clock Pulse Generator has PLL multiplication.
> clk_rate_multi_range_round() will be good helper for it.
> 
clk_rate_mult_range_round() would be more logically consistent.

> +long clk_rate_multi_range_round(struct clk *clk, unsigned int div_min,
> +				unsigned int div_max, unsigned long rate)
> +{
> +	struct clk_rate_round_data div_range_round = {
> +		.min	= div_min,
> +		.max	= div_max,
> +		.func	= clk_rate_multi_range_iter,
> +		.arg	= clk_get_parent(clk),
> +		.rate	= rate,
> +	};
> +
> +	return clk_rate_round_helper(&div_range_round);
> +}
> +
Clearly you want mult_range and not div_range here. Likewise div_min/max
should be mult_min/max or so, as you're clearly not doing division on
anything here.

Beyond that, I have no particular objections to the API addition.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 07/10] sh: clkfwk: add clk_rate_multi_range_round()
  2011-09-09 10:27 [PATCH 07/10] sh: clkfwk: add clk_rate_multi_range_round() Kuninori Morimoto
  2011-09-16 10:29 ` Paul Mundt
@ 2011-09-20  1:18 ` Kuninori Morimoto
  1 sibling, 0 replies; 3+ messages in thread
From: Kuninori Morimoto @ 2011-09-20  1:18 UTC (permalink / raw)
  To: linux-sh


Hi Paul

Thank you for checking patch

> On Fri, Sep 09, 2011 at 03:27:43AM -0700, Kuninori Morimoto wrote:
> > Some Clock Pulse Generator has PLL multiplication.
> > clk_rate_multi_range_round() will be good helper for it.
> > 
> clk_rate_mult_range_round() would be more logically consistent.
> 
> > +long clk_rate_multi_range_round(struct clk *clk, unsigned int div_min,
> > +				unsigned int div_max, unsigned long rate)
> > +{
> > +	struct clk_rate_round_data div_range_round = {
> > +		.min	= div_min,
> > +		.max	= div_max,
> > +		.func	= clk_rate_multi_range_iter,
> > +		.arg	= clk_get_parent(clk),
> > +		.rate	= rate,
> > +	};
> > +
> > +	return clk_rate_round_helper(&div_range_round);
> > +}
> > +
> Clearly you want mult_range and not div_range here. Likewise div_min/max
> should be mult_min/max or so, as you're clearly not doing division on
> anything here.
> 
> Beyond that, I have no particular objections to the API addition.

Thanks.
I send v2 patch

Best regards
---
Kuninori Morimoto

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-09-20  1:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-09 10:27 [PATCH 07/10] sh: clkfwk: add clk_rate_multi_range_round() Kuninori Morimoto
2011-09-16 10:29 ` Paul Mundt
2011-09-20  1:18 ` Kuninori Morimoto

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.