From: linux@arm.linux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 03/13] ARM: LPC32XX: Clock driver
Date: Sat, 20 Feb 2010 16:33:13 +0000 [thread overview]
Message-ID: <20100220163313.GA12409@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <1266621969-28847-4-git-send-email-wellsk40@gmail.com>
On Fri, Feb 19, 2010 at 03:25:59PM -0800, wellsk40 at gmail.com wrote:
> +static u32 local_return_parent_rate(struct clk *clk)
> +{
> + /*
> + * If a clock has a rate of 0, then it inherits it's parent
> + * clock rate
> + */
> + if (clk->rate == 0)
> + return local_return_parent_rate(clk->parent);
Does this really need to be recursive?
while (clk->rate == 0)
clk = clk->parent;
return clk->rate;
?
> +static u32 mmc_get_rate(struct clk *clk)
> +{
> + u32 div, tmp, rate;
> +
> + div = __raw_readl(LPC32XX_CLKPWR_MS_CTRL);
> + tmp = div & LPC32XX_CLKPWR_MSCARD_SDCARD_EN;
> +
> + if (!tmp)
> + return 0;
There's no requirement to return a rate of zero if the clock is not enabled.
In fact, it's something that should be avoided because it prevents querying
the rate you'll get before enabling the clock (which might affect whether
you decide to enable it.)
> +static void local_clk_disable(struct clk *clk)
> +{
> + WARN_ON(clk->usecount == 0);
> +
> + /* Don't attempt to disable clock if it has no users */
> + if (clk->usecount > 0) {
> + clk->usecount--;
> +
> + /* Only disable clock when it has no more users */
> + if ((clk->usecount == 0) && (clk->enable))
> + clk->enable(clk, 0);
> +
> + /* Check parent clocks, they may need to be disabled too */
> + if (clk->parent)
> + local_clk_disable(clk->parent);
This is not a good idea if you ever support clock reparenting - it's
much better to have the parent enabled when the usecount changes from
0 to 1, and disabled when you move from 1 to 0 - otherwise you'll
have to call local_clk_disable() and local_clk_enable() multiple times
when you reparent.
> +unsigned long clk_get_rate(struct clk *clk)
> +{
> + unsigned long rate;
> +
> + clk_lock();
> + rate = (clk->get_rate)(clk);
parens aren't required.
> + if (clk->set_rate) {
> + clk_lock();
> + ret = (clk->set_rate)(clk, rate);
Ditto.
> +/*
> + * clk_round_rate - adjust a rate to the exact rate a clock can provide
> + */
> +long clk_round_rate(struct clk *clk, unsigned long rate)
> +{
> + int ret;
> +
> + /* Use set_rate to try to adjust the rate if it supports it */
> + ret = clk_set_rate(clk, rate);
This is definitely wrong. round_rate() is supposed to return the rate
which the clock will give you for the rate you're asking for _without_
setting it.
next prev parent reply other threads:[~2010-02-20 16:33 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-19 23:25 LPC32XX architecture files (updated v4) wellsk40 at gmail.com
2010-02-19 23:25 ` [PATCH 01/13] ARM: LPC32XX: Initial architecture header files wellsk40 at gmail.com
2010-02-20 16:12 ` Uwe Kleine-König
[not found] ` <a08234131002201112x66a595c4j235bf1a31aef4f92@mail.gmail.com>
2010-02-20 19:14 ` Kevin Wells
2010-02-20 19:17 ` Kevin Wells
2010-02-22 21:41 ` Kevin Wells
2010-02-23 8:02 ` Uwe Kleine-König
2010-02-19 23:25 ` [PATCH 02/13] ARM: LPC32XX: Debug and IRQ macros wellsk40 at gmail.com
2010-02-19 23:25 ` [PATCH 03/13] ARM: LPC32XX: Clock driver wellsk40 at gmail.com
2010-02-20 16:33 ` Russell King - ARM Linux [this message]
2010-02-23 21:28 ` Kevin Wells
2010-02-19 23:26 ` [PATCH 04/13] ARM: LPC32XX: GPIO, timer, and IRQ drivers wellsk40 at gmail.com
2010-02-19 23:26 ` [PATCH 05/13] ARM: LPC32XX: System suspend support wellsk40 at gmail.com
2010-02-19 23:26 ` [PATCH 06/13] ARM: LPC32XX: Serial support code wellsk40 at gmail.com
2010-02-20 16:34 ` Russell King - ARM Linux
2010-02-19 23:26 ` [PATCH 07/13] ARM: LPC32XX: Misc support functions wellsk40 at gmail.com
2010-02-19 23:26 ` [PATCH 08/13] ARM: LPC32XX: Phytec 3250 platform support wellsk40 at gmail.com
2010-02-19 23:26 ` [PATCH 09/13] ARM: LPC32XX: Arch config menu supoport and makefiles wellsk40 at gmail.com
2010-02-19 23:26 ` [PATCH 10/13] ARM: LPC32XX: Default PHY3250 kernel config (ramdisk) wellsk40 at gmail.com
2010-02-19 23:26 ` [PATCH 11/13] ARM: Add support for the LPC32XX arch wellsk40 at gmail.com
2010-02-19 23:26 ` [PATCH 12/13] i2c: " wellsk40 at gmail.com
2010-02-19 23:26 ` [PATCH 13/13] WATCHDOG: " wellsk40 at gmail.com
-- strict thread matches above, loose matches on Subject: below --
2010-02-26 23:53 LPC32XX architecture files (updated v5) wellsk40 at gmail.com
2010-02-26 23:53 ` [PATCH 03/13] ARM: LPC32XX: Clock driver wellsk40 at gmail.com
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=20100220163313.GA12409@n2100.arm.linux.org.uk \
--to=linux@arm.linux.org.uk \
--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).