aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/clk/clk.c
diff options
context:
space:
mode:
authorStephen Boyd <sboyd@codeaurora.org>2012-10-04 02:38:55 -0400
committerMike Turquette <mturquette@linaro.org>2012-10-29 14:05:03 -0400
commit2ac6b1f50a397580b8dc28f2833e54af7926fc71 (patch)
treed9fbe4f63392d462b41296b9407ec622d9212823 /drivers/clk/clk.c
parent7ce3e8ccbac708229ba8c40c9c2a43ca7fcdb3ae (diff)
clk: Don't return negative numbers for unsigned values with !clk
Some of the helper functions return negative error codes if passed a NULL clock. This can lead to confusing behavior when the expected return value is unsigned. Fix up these accessors so that they return unsigned values (or bool in the case of is_enabled). This way we can't interpret NULL clocks as having valid and interesting values. Signed-off-by: Stephen Boyd <sboyd@codeaurora.org> Signed-off-by: Mike Turquette <mturquette@linaro.org>
Diffstat (limited to 'drivers/clk/clk.c')
-rw-r--r--drivers/clk/clk.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 56e4495ebeb..bbe52c4ae7c 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -261,7 +261,7 @@ inline struct clk_hw *__clk_get_hw(struct clk *clk)
261 261
262inline u8 __clk_get_num_parents(struct clk *clk) 262inline u8 __clk_get_num_parents(struct clk *clk)
263{ 263{
264 return !clk ? -EINVAL : clk->num_parents; 264 return !clk ? 0 : clk->num_parents;
265} 265}
266 266
267inline struct clk *__clk_get_parent(struct clk *clk) 267inline struct clk *__clk_get_parent(struct clk *clk)
@@ -269,14 +269,14 @@ inline struct clk *__clk_get_parent(struct clk *clk)
269 return !clk ? NULL : clk->parent; 269 return !clk ? NULL : clk->parent;
270} 270}
271 271
272inline int __clk_get_enable_count(struct clk *clk) 272inline unsigned int __clk_get_enable_count(struct clk *clk)
273{ 273{
274 return !clk ? -EINVAL : clk->enable_count; 274 return !clk ? 0 : clk->enable_count;
275} 275}
276 276
277inline int __clk_get_prepare_count(struct clk *clk) 277inline unsigned int __clk_get_prepare_count(struct clk *clk)
278{ 278{
279 return !clk ? -EINVAL : clk->prepare_count; 279 return !clk ? 0 : clk->prepare_count;
280} 280}
281 281
282unsigned long __clk_get_rate(struct clk *clk) 282unsigned long __clk_get_rate(struct clk *clk)
@@ -302,15 +302,15 @@ out:
302 302
303inline unsigned long __clk_get_flags(struct clk *clk) 303inline unsigned long __clk_get_flags(struct clk *clk)
304{ 304{
305 return !clk ? -EINVAL : clk->flags; 305 return !clk ? 0 : clk->flags;
306} 306}
307 307
308int __clk_is_enabled(struct clk *clk) 308bool __clk_is_enabled(struct clk *clk)
309{ 309{
310 int ret; 310 int ret;
311 311
312 if (!clk) 312 if (!clk)
313 return -EINVAL; 313 return false;
314 314
315 /* 315 /*
316 * .is_enabled is only mandatory for clocks that gate 316 * .is_enabled is only mandatory for clocks that gate
@@ -323,7 +323,7 @@ int __clk_is_enabled(struct clk *clk)
323 323
324 ret = clk->ops->is_enabled(clk->hw); 324 ret = clk->ops->is_enabled(clk->hw);
325out: 325out:
326 return ret; 326 return !!ret;
327} 327}
328 328
329static struct clk *__clk_lookup_subtree(const char *name, struct clk *clk) 329static struct clk *__clk_lookup_subtree(const char *name, struct clk *clk)
@@ -568,7 +568,7 @@ unsigned long __clk_round_rate(struct clk *clk, unsigned long rate)
568 unsigned long parent_rate = 0; 568 unsigned long parent_rate = 0;
569 569
570 if (!clk) 570 if (!clk)
571 return -EINVAL; 571 return 0;
572 572
573 if (!clk->ops->round_rate) { 573 if (!clk->ops->round_rate) {
574 if (clk->flags & CLK_SET_RATE_PARENT) 574 if (clk->flags & CLK_SET_RATE_PARENT)