From: shawn.guo@linaro.org (Shawn Guo)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/3] clk: pass parent_rate into .set_rate
Date: Thu, 12 Apr 2012 20:50:18 +0800 [thread overview]
Message-ID: <1334235019-15553-2-git-send-email-shawn.guo@linaro.org> (raw)
In-Reply-To: <1334235019-15553-1-git-send-email-shawn.guo@linaro.org>
For most of .set_rate implementation, parent_rate will be used, so just
like passing parent_rate into .recalc_rate, let's pass parent_rate into
.set_rate too.
It also updates the kernel doc for .set_rate ops.
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
drivers/clk/clk-divider.c | 5 +++--
drivers/clk/clk.c | 2 +-
include/linux/clk-provider.h | 21 +++++++--------------
3 files changed, 11 insertions(+), 17 deletions(-)
diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c
index 04439f1..1793095 100644
--- a/drivers/clk/clk-divider.c
+++ b/drivers/clk/clk-divider.c
@@ -111,14 +111,15 @@ static long clk_divider_round_rate(struct clk_hw *hw, unsigned long rate,
return *prate / div;
}
-static int clk_divider_set_rate(struct clk_hw *hw, unsigned long rate)
+static int clk_divider_set_rate(struct clk_hw *hw, unsigned long rate,
+ unsigned long parent_rate)
{
struct clk_divider *divider = to_clk_divider(hw);
unsigned int div;
unsigned long flags = 0;
u32 val;
- div = __clk_get_rate(__clk_get_parent(hw->clk)) / rate;
+ div = parent_rate / rate;
if (!(divider->flags & CLK_DIVIDER_ONE_BASED))
div--;
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 19caa0a..d04e1e4 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -848,7 +848,7 @@ static void clk_change_rate(struct clk *clk)
old_rate = clk->rate;
if (clk->ops->set_rate)
- clk->ops->set_rate(clk->hw, clk->new_rate);
+ clk->ops->set_rate(clk->hw, clk->new_rate, clk->parent->rate);
if (clk->ops->recalc_rate)
clk->rate = clk->ops->recalc_rate(clk->hw,
diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
index 3323d24..cb82918 100644
--- a/include/linux/clk-provider.h
+++ b/include/linux/clk-provider.h
@@ -88,19 +88,11 @@ struct clk_hw {
* array index into the value programmed into the hardware.
* Returns 0 on success, -EERROR otherwise.
*
- * @set_rate: Change the rate of this clock. If this callback returns
- * CLK_SET_RATE_PARENT, the rate change will be propagated to the
- * parent clock (which may propagate again if the parent clock
- * also sets this flag). The requested rate of the parent is
- * passed back from the callback in the second 'unsigned long *'
- * argument. Note that it is up to the hardware clock's set_rate
- * implementation to insure that clocks do not run out of spec
- * when propgating the call to set_rate up to the parent. One way
- * to do this is to gate the clock (via clk_disable and/or
- * clk_unprepare) before calling clk_set_rate, then ungating it
- * afterward. If your clock also has the CLK_GATE_SET_RATE flag
- * set then this will insure safety. Returns 0 on success,
- * -EERROR otherwise.
+ * @set_rate: Change the rate of this clock. The requested rate is specified
+ * by the second argument, which should typically be the return
+ * of .round_rate call. The third argument gives the parent rate
+ * which is likely helpful for most .set_rate implementation.
+ * Returns 0 on success, -EERROR otherwise.
*
* The clk_enable/clk_disable and clk_prepare/clk_unprepare pairs allow
* implementations to split any work between atomic (enable) and sleepable
@@ -125,7 +117,8 @@ struct clk_ops {
unsigned long *);
int (*set_parent)(struct clk_hw *hw, u8 index);
u8 (*get_parent)(struct clk_hw *hw);
- int (*set_rate)(struct clk_hw *hw, unsigned long);
+ int (*set_rate)(struct clk_hw *hw, unsigned long,
+ unsigned long);
void (*init)(struct clk_hw *hw);
};
--
1.7.5.4
next prev parent reply other threads:[~2012-04-12 12:50 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-12 1:02 [PATCH 00/13] common clk framework misc fixes Mike Turquette
2012-04-12 1:02 ` [PATCH 01/13] clk: core: correct clk_set_rate kerneldoc Mike Turquette
2012-04-12 4:28 ` Viresh Kumar
2012-04-13 22:23 ` Turquette, Mike
2012-04-12 7:24 ` Andrew Lunn
2012-04-12 7:38 ` Amit Kucheria
2012-04-12 1:02 ` [PATCH 02/13] clk: core: remove dead code paths Mike Turquette
2012-04-12 6:14 ` Viresh Kumar
2012-04-13 22:27 ` Turquette, Mike
2012-04-12 1:02 ` [PATCH 03/13] clk: core: clk_calc_new_rates handles NULL parents Mike Turquette
2012-04-12 1:02 ` [PATCH 04/13] clk: core: enforce clk_ops consistency Mike Turquette
2012-04-12 6:17 ` Viresh Kumar
2012-04-12 1:02 ` [PATCH 05/13] clk: use kzalloc in clk_register_mux Mike Turquette
2012-04-12 6:18 ` Viresh Kumar
2012-04-12 1:02 ` [PATCH 06/13] clk: remove unnecessary EXPORT_SYMBOL_GPL Mike Turquette
2012-04-12 6:18 ` Viresh Kumar
2012-04-12 1:02 ` [PATCH 07/13] clk: add "const" for clk_ops of basic clks Mike Turquette
2012-04-12 6:19 ` Viresh Kumar
2012-04-12 1:02 ` [PATCH 08/13] clk: declare clk_ops of basic clks in clk-provider.h Mike Turquette
2012-04-12 6:20 ` Viresh Kumar
2012-04-12 1:02 ` [PATCH 09/13] clk: Make clk_get_rate() return 0 on error Mike Turquette
2012-04-12 6:21 ` Viresh Kumar
2012-04-12 1:02 ` [PATCH 10/13] clk: Remove comment for end of CONFIG_COMMON_CLK section Mike Turquette
2012-04-12 1:02 ` [PATCH 11/13] clk: Constify parent name arrays Mike Turquette
2012-04-12 1:02 ` [PATCH 12/13] clk: core: copy parent_names & return error codes Mike Turquette
2012-04-16 20:30 ` Sascha Hauer
2012-04-16 21:35 ` Turquette, Mike
2012-04-12 1:02 ` [PATCH 13/13] clk: basic: improve parent_names & return errors Mike Turquette
2012-04-12 6:49 ` Shawn Guo
2012-04-16 23:10 ` Turquette, Mike
2012-04-17 1:46 ` Shawn Guo
2012-04-17 3:50 ` Turquette, Mike
2012-04-17 7:17 ` Shawn Guo
2012-04-20 20:01 ` Saravana Kannan
2012-04-26 6:00 ` Saravana Kannan
2012-04-16 20:52 ` Sascha Hauer
2012-04-16 23:11 ` Turquette, Mike
2012-04-12 8:56 ` [PATCH 00/13] common clk framework misc fixes Sascha Hauer
2012-04-12 11:14 ` Arnd Bergmann
2012-04-12 13:11 ` Shawn Guo
2012-04-12 12:50 ` [PATCH 1/3] clk: always pass parent_rate into .round_rate Shawn Guo
2012-04-12 12:50 ` Shawn Guo [this message]
2012-04-18 1:05 ` [PATCH 2/3] clk: pass parent_rate into .set_rate Turquette, Mike
2012-04-12 12:50 ` [PATCH 3/3] clk: propagate round_rate for CLK_SET_RATE_PARENT case Shawn Guo
2012-04-18 1:07 ` Turquette, Mike
2012-04-18 1:05 ` [PATCH 1/3] clk: always pass parent_rate into .round_rate Turquette, Mike
2012-05-02 9:51 ` Sascha Hauer
2012-05-06 23:41 ` Turquette, Mike
2012-04-13 9:21 ` [PATCH 00/13] common clk framework misc fixes Mark Brown
2012-04-13 22:20 ` Turquette, Mike
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1334235019-15553-2-git-send-email-shawn.guo@linaro.org \
--to=shawn.guo@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).