From: andrew@lunn.ch (Andrew Lunn)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] clk: provide public clk_is_enabled function
Date: Fri, 4 Oct 2013 15:17:56 +0200 [thread overview]
Message-ID: <20131004131756.GD23809@lunn.ch> (raw)
In-Reply-To: <1380881310-24345-1-git-send-email-sebastian.hesselbarth@gmail.com>
On Fri, Oct 04, 2013 at 12:08:30PM +0200, Sebastian Hesselbarth wrote:
> To determine if a clk has been previously enabled, provide a public
> clk_is_enabled function. This is especially helpful to check the state
> of clk-gate without actually changing the state of the gate.
>
> Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Tested-by: Andrew Lunn <andrew@lunn.ch>
Andrew
> ---
> Cc: Mike Turquette <mturquette@linaro.org>
> Cc: Russell King <linux@arm.linux.org.uk>
> Cc: Jason Cooper <jason@lakedaemon.net>
> Cc: Andrew Lunn <andrew@lunn.ch>
> Cc: Grant Likely <grant.likely@linaro.org>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
> Cc: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
> Cc: linux-arm-kernel at lists.infradead.org
> Cc: linux-kernel at vger.kernel.org
> ---
> drivers/clk/clk.c | 18 ++++++++++++++++++
> include/linux/clk.h | 13 +++++++++++++
> 2 files changed, 31 insertions(+)
>
> diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> index a004769..26698d3 100644
> --- a/drivers/clk/clk.c
> +++ b/drivers/clk/clk.c
> @@ -929,6 +929,24 @@ int clk_enable(struct clk *clk)
> EXPORT_SYMBOL_GPL(clk_enable);
>
> /**
> + * clk_is_enabled - return the enabled state of a clk
> + * @clk: the clk whose enabled state gets returned
> + *
> + * Returns true if the clock is enabled, false otherwise.
> + */
> +bool clk_is_enabled(struct clk *clk)
> +{
> + bool is_en;
> +
> + clk_prepare_lock();
> + is_en = __clk_is_enabled(clk);
> + clk_prepare_unlock();
> +
> + return is_en;
> +}
> +EXPORT_SYMBOL_GPL(clk_is_enabled);
> +
> +/**
> * __clk_round_rate - round the given rate for a clk
> * @clk: round the rate of this clock
> * @rate: the rate which is to be rounded
> diff --git a/include/linux/clk.h b/include/linux/clk.h
> index 9a6d045..8cbf2f7 100644
> --- a/include/linux/clk.h
> +++ b/include/linux/clk.h
> @@ -187,6 +187,14 @@ int clk_enable(struct clk *clk);
> void clk_disable(struct clk *clk);
>
> /**
> + * clk_is_enabled - return the enabled state of a clk
> + * @clk: the clk whose enabled state gets returned
> + *
> + * Returns true if the clock is enabled, false otherwise.
> + */
> +bool clk_is_enabled(struct clk *clk);
> +
> +/**
> * clk_get_rate - obtain the current clock rate (in Hz) for a clock source.
> * This is only valid once the clock source has been enabled.
> * @clk: clock source
> @@ -299,6 +307,11 @@ static inline int clk_enable(struct clk *clk)
>
> static inline void clk_disable(struct clk *clk) {}
>
> +static inline bool clk_is_enabled(struct clk *clk)
> +{
> + return false;
> +}
> +
> static inline unsigned long clk_get_rate(struct clk *clk)
> {
> return 0;
> --
> 1.7.10.4
>
next prev parent reply other threads:[~2013-10-04 13:17 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-04 10:08 [PATCH] clk: provide public clk_is_enabled function Sebastian Hesselbarth
2013-10-04 13:17 ` Andrew Lunn [this message]
2013-10-05 20:24 ` Uwe Kleine-König
2013-10-05 20:42 ` Andrew Lunn
2013-10-06 9:06 ` Gerhard Sittig
2013-10-06 16:30 ` Andrew Lunn
2013-10-06 19:42 ` Sebastian Hesselbarth
2013-10-06 20:02 ` Mike Turquette
2013-10-06 22:24 ` Sebastian Hesselbarth
2013-10-06 21:04 ` Mike Turquette
2013-10-07 8:39 ` Sebastian Hesselbarth
2013-10-06 21:35 ` Andrew Lunn
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=20131004131756.GD23809@lunn.ch \
--to=andrew@lunn.ch \
--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).