summaryrefslogtreecommitdiff
path: root/drivers/clk
diff options
context:
space:
mode:
authorUlf Hansson <ulf.hansson@linaro.org>2013-03-12 20:26:02 +0100
committerMike Turquette <mturquette@linaro.org>2013-03-19 12:58:42 -0700
commit3d6ee287a3e341c88eafd0b4620b12d640b3736b (patch)
treec5361658171613baf2437e14ac27563a43241bd3 /drivers/clk
parent30ee400614385ac49f4c9b4bc03d77ff8f07a61e (diff)
clk: Introduce optional is_prepared callback
To reflect whether a clk_hw is prepared the clk_hw may implement the optional is_prepared callback. If not implemented we fall back to use the software prepare counter. Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Acked-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Mike Turquette <mturquette@linaro.org>
Diffstat (limited to 'drivers/clk')
-rw-r--r--drivers/clk/clk.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index ed87b2405806..7571b5054f3c 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -451,6 +451,27 @@ unsigned long __clk_get_flags(struct clk *clk)
return !clk ? 0 : clk->flags;
}
+bool __clk_is_prepared(struct clk *clk)
+{
+ int ret;
+
+ if (!clk)
+ return false;
+
+ /*
+ * .is_prepared is optional for clocks that can prepare
+ * fall back to software usage counter if it is missing
+ */
+ if (!clk->ops->is_prepared) {
+ ret = clk->prepare_count ? 1 : 0;
+ goto out;
+ }
+
+ ret = clk->ops->is_prepared(clk->hw);
+out:
+ return !!ret;
+}
+
bool __clk_is_enabled(struct clk *clk)
{
int ret;