linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] Minor fixes for generic clock framework
@ 2012-10-04  6:38 Stephen Boyd
  2012-10-04  6:38 ` [PATCH 1/3] clk: Document .is_enabled op Stephen Boyd
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Stephen Boyd @ 2012-10-04  6:38 UTC (permalink / raw)
  To: linux-arm-kernel

This is a small set of patches that fixes some documentation
and fixes return values of functions that aren't used that
much yet. Noticed while going through this code.

Stephen Boyd (3):
  clk: Document .is_enabled op
  clk: Fix documentation typos
  clk: Don't return negative numbers for unsigned values with !clk

 drivers/clk/clk.c            | 20 ++++++++++----------
 include/linux/clk-provider.h | 16 ++++++++++------
 2 files changed, 20 insertions(+), 16 deletions(-)

-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/3] clk: Document .is_enabled op
  2012-10-04  6:38 [PATCH 0/3] Minor fixes for generic clock framework Stephen Boyd
@ 2012-10-04  6:38 ` Stephen Boyd
  2012-10-04  6:38 ` [PATCH 2/3] clk: Fix documentation typos Stephen Boyd
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Stephen Boyd @ 2012-10-04  6:38 UTC (permalink / raw)
  To: linux-arm-kernel

Add the missing kernel-doc for this op.

Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
---
 include/linux/clk-provider.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
index 710c6cb..5a548e3 100644
--- a/include/linux/clk-provider.h
+++ b/include/linux/clk-provider.h
@@ -53,6 +53,10 @@ struct clk_hw;
  * @disable:	Disable the clock atomically. Called with enable_lock held.
  * 		This function must not sleep.
  *
+ * @is_enabled:	Queries the hardware to determine if the clock is enabled.
+ * 		This function must not sleep. Optional, if this op is not
+ * 		set then the enable count will be used.
+ *
  * @recalc_rate	Recalculate the rate of this clock, by quering hardware.  The
  * 		parent rate is an input parameter.  It is up to the caller to
  * 		insure that the prepare_mutex is held across this call.
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/3] clk: Fix documentation typos
  2012-10-04  6:38 [PATCH 0/3] Minor fixes for generic clock framework Stephen Boyd
  2012-10-04  6:38 ` [PATCH 1/3] clk: Document .is_enabled op Stephen Boyd
@ 2012-10-04  6:38 ` Stephen Boyd
  2012-10-04  6:38 ` [PATCH 3/3] clk: Don't return negative numbers for unsigned values with !clk Stephen Boyd
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Stephen Boyd @ 2012-10-04  6:38 UTC (permalink / raw)
  To: linux-arm-kernel

Fix some minor typos in the documentation for the ops structure.

Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
---
 include/linux/clk-provider.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
index 5a548e3..0571261 100644
--- a/include/linux/clk-provider.h
+++ b/include/linux/clk-provider.h
@@ -57,9 +57,9 @@ struct clk_hw;
  * 		This function must not sleep. Optional, if this op is not
  * 		set then the enable count will be used.
  *
- * @recalc_rate	Recalculate the rate of this clock, by quering hardware.  The
+ * @recalc_rate	Recalculate the rate of this clock, by querying hardware. The
  * 		parent rate is an input parameter.  It is up to the caller to
- * 		insure that the prepare_mutex is held across this call.
+ * 		ensure that the prepare_mutex is held across this call.
  * 		Returns the calculated rate.  Optional, but recommended - if
  * 		this op is not set then clock rate will be initialized to 0.
  *
@@ -93,7 +93,7 @@ struct clk_hw;
  * implementations to split any work between atomic (enable) and sleepable
  * (prepare) contexts.  If enabling a clock requires code that might sleep,
  * this must be done in clk_prepare.  Clock enable code that will never be
- * called in a sleepable context may be implement in clk_enable.
+ * called in a sleepable context may be implemented in clk_enable.
  *
  * Typically, drivers will call clk_prepare when a clock may be needed later
  * (eg. when a device is opened), and clk_enable when the clock is actually
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/3] clk: Don't return negative numbers for unsigned values with !clk
  2012-10-04  6:38 [PATCH 0/3] Minor fixes for generic clock framework Stephen Boyd
  2012-10-04  6:38 ` [PATCH 1/3] clk: Document .is_enabled op Stephen Boyd
  2012-10-04  6:38 ` [PATCH 2/3] clk: Fix documentation typos Stephen Boyd
@ 2012-10-04  6:38 ` Stephen Boyd
  2012-10-29 18:12 ` [PATCH 0/3] Minor fixes for generic clock framework Stephen Boyd
  2012-10-29 18:16 ` Mike Turquette
  4 siblings, 0 replies; 6+ messages in thread
From: Stephen Boyd @ 2012-10-04  6:38 UTC (permalink / raw)
  To: linux-arm-kernel

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>
---
 drivers/clk/clk.c            | 20 ++++++++++----------
 include/linux/clk-provider.h |  6 +++---
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 6852809..2847a66 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -262,7 +262,7 @@ inline struct clk_hw *__clk_get_hw(struct clk *clk)
 
 inline u8 __clk_get_num_parents(struct clk *clk)
 {
-	return !clk ? -EINVAL : clk->num_parents;
+	return !clk ? 0 : clk->num_parents;
 }
 
 inline struct clk *__clk_get_parent(struct clk *clk)
@@ -270,14 +270,14 @@ inline struct clk *__clk_get_parent(struct clk *clk)
 	return !clk ? NULL : clk->parent;
 }
 
-inline int __clk_get_enable_count(struct clk *clk)
+inline unsigned int __clk_get_enable_count(struct clk *clk)
 {
-	return !clk ? -EINVAL : clk->enable_count;
+	return !clk ? 0 : clk->enable_count;
 }
 
-inline int __clk_get_prepare_count(struct clk *clk)
+inline unsigned int __clk_get_prepare_count(struct clk *clk)
 {
-	return !clk ? -EINVAL : clk->prepare_count;
+	return !clk ? 0 : clk->prepare_count;
 }
 
 unsigned long __clk_get_rate(struct clk *clk)
@@ -303,15 +303,15 @@ out:
 
 inline unsigned long __clk_get_flags(struct clk *clk)
 {
-	return !clk ? -EINVAL : clk->flags;
+	return !clk ? 0 : clk->flags;
 }
 
-int __clk_is_enabled(struct clk *clk)
+bool __clk_is_enabled(struct clk *clk)
 {
 	int ret;
 
 	if (!clk)
-		return -EINVAL;
+		return false;
 
 	/*
 	 * .is_enabled is only mandatory for clocks that gate
@@ -324,7 +324,7 @@ int __clk_is_enabled(struct clk *clk)
 
 	ret = clk->ops->is_enabled(clk->hw);
 out:
-	return ret;
+	return !!ret;
 }
 
 static struct clk *__clk_lookup_subtree(const char *name, struct clk *clk)
@@ -569,7 +569,7 @@ unsigned long __clk_round_rate(struct clk *clk, unsigned long rate)
 	unsigned long parent_rate = 0;
 
 	if (!clk)
-		return -EINVAL;
+		return 0;
 
 	if (!clk->ops->round_rate) {
 		if (clk->flags & CLK_SET_RATE_PARENT)
diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
index 0571261..3593a3c 100644
--- a/include/linux/clk-provider.h
+++ b/include/linux/clk-provider.h
@@ -341,11 +341,11 @@ const char *__clk_get_name(struct clk *clk);
 struct clk_hw *__clk_get_hw(struct clk *clk);
 u8 __clk_get_num_parents(struct clk *clk);
 struct clk *__clk_get_parent(struct clk *clk);
-inline int __clk_get_enable_count(struct clk *clk);
-inline int __clk_get_prepare_count(struct clk *clk);
+inline unsigned int __clk_get_enable_count(struct clk *clk);
+inline unsigned int __clk_get_prepare_count(struct clk *clk);
 unsigned long __clk_get_rate(struct clk *clk);
 unsigned long __clk_get_flags(struct clk *clk);
-int __clk_is_enabled(struct clk *clk);
+bool __clk_is_enabled(struct clk *clk);
 struct clk *__clk_lookup(const char *name);
 
 /*
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 0/3] Minor fixes for generic clock framework
  2012-10-04  6:38 [PATCH 0/3] Minor fixes for generic clock framework Stephen Boyd
                   ` (2 preceding siblings ...)
  2012-10-04  6:38 ` [PATCH 3/3] clk: Don't return negative numbers for unsigned values with !clk Stephen Boyd
@ 2012-10-29 18:12 ` Stephen Boyd
  2012-10-29 18:16 ` Mike Turquette
  4 siblings, 0 replies; 6+ messages in thread
From: Stephen Boyd @ 2012-10-29 18:12 UTC (permalink / raw)
  To: linux-arm-kernel

On 10/03/12 23:38, Stephen Boyd wrote:
> This is a small set of patches that fixes some documentation
> and fixes return values of functions that aren't used that
> much yet. Noticed while going through this code.
>

Mike, any comments on these patches?

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 0/3] Minor fixes for generic clock framework
  2012-10-04  6:38 [PATCH 0/3] Minor fixes for generic clock framework Stephen Boyd
                   ` (3 preceding siblings ...)
  2012-10-29 18:12 ` [PATCH 0/3] Minor fixes for generic clock framework Stephen Boyd
@ 2012-10-29 18:16 ` Mike Turquette
  4 siblings, 0 replies; 6+ messages in thread
From: Mike Turquette @ 2012-10-29 18:16 UTC (permalink / raw)
  To: linux-arm-kernel

Quoting Stephen Boyd (2012-10-03 23:38:52)
> This is a small set of patches that fixes some documentation
> and fixes return values of functions that aren't used that
> much yet. Noticed while going through this code.
> 

Taken into clk-next.

Thanks,
Mike

> Stephen Boyd (3):
>   clk: Document .is_enabled op
>   clk: Fix documentation typos
>   clk: Don't return negative numbers for unsigned values with !clk
> 
>  drivers/clk/clk.c            | 20 ++++++++++----------
>  include/linux/clk-provider.h | 16 ++++++++++------
>  2 files changed, 20 insertions(+), 16 deletions(-)
> 
> -- 
> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
> hosted by The Linux Foundation

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-10-29 18:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-04  6:38 [PATCH 0/3] Minor fixes for generic clock framework Stephen Boyd
2012-10-04  6:38 ` [PATCH 1/3] clk: Document .is_enabled op Stephen Boyd
2012-10-04  6:38 ` [PATCH 2/3] clk: Fix documentation typos Stephen Boyd
2012-10-04  6:38 ` [PATCH 3/3] clk: Don't return negative numbers for unsigned values with !clk Stephen Boyd
2012-10-29 18:12 ` [PATCH 0/3] Minor fixes for generic clock framework Stephen Boyd
2012-10-29 18:16 ` Mike Turquette

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).