public inbox for linux-arm-kernel@lists.infradead.org 
 help / color / mirror / Atom feed
* [PATCH] ARM: davinci: clock: Correct return values for API functions
@ 2015-09-14  9:29 Peter Ujfalusi
  2015-09-22 15:27 ` Sekhar Nori
  0 siblings, 1 reply; 2+ messages in thread
From: Peter Ujfalusi @ 2015-09-14  9:29 UTC (permalink / raw)
  To: linux-arm-kernel

Fix the values returned by the publicly used functions.
These function should return 0 when they are called with clk == NULL in
similar manner as the clock API does to avoid different behavior in drivers
used by daVinci and other architectures.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti•com>
---
Hi Sekhar,

This issue is visible when using generic drivers like ASoC simnple card for
audio support.
They rely on the fact that these functions will not return with error in case
of clk == NULL.

Regards,
Peter

 arch/arm/mach-davinci/clock.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mach-davinci/clock.c b/arch/arm/mach-davinci/clock.c
index c70bb0a4dfb4..3caff9637a82 100644
--- a/arch/arm/mach-davinci/clock.c
+++ b/arch/arm/mach-davinci/clock.c
@@ -97,7 +97,9 @@ int clk_enable(struct clk *clk)
 {
 	unsigned long flags;
 
-	if (clk == NULL || IS_ERR(clk))
+	if (!clk)
+		return 0;
+	else if (IS_ERR(clk))
 		return -EINVAL;
 
 	spin_lock_irqsave(&clockfw_lock, flags);
@@ -124,7 +126,7 @@ EXPORT_SYMBOL(clk_disable);
 unsigned long clk_get_rate(struct clk *clk)
 {
 	if (clk == NULL || IS_ERR(clk))
-		return -EINVAL;
+		return 0;
 
 	return clk->rate;
 }
@@ -159,8 +161,10 @@ int clk_set_rate(struct clk *clk, unsigned long rate)
 	unsigned long flags;
 	int ret = -EINVAL;
 
-	if (clk == NULL || IS_ERR(clk))
-		return ret;
+	if (!clk)
+		return 0;
+	else if (IS_ERR(clk))
+		return -EINVAL;
 
 	if (clk->set_rate)
 		ret = clk->set_rate(clk, rate);
@@ -181,7 +185,9 @@ int clk_set_parent(struct clk *clk, struct clk *parent)
 {
 	unsigned long flags;
 
-	if (clk == NULL || IS_ERR(clk))
+	if (!clk)
+		return 0;
+	else if (IS_ERR(clk))
 		return -EINVAL;
 
 	/* Cannot change parent on enabled clock */
-- 
2.5.2

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

* [PATCH] ARM: davinci: clock: Correct return values for API functions
  2015-09-14  9:29 [PATCH] ARM: davinci: clock: Correct return values for API functions Peter Ujfalusi
@ 2015-09-22 15:27 ` Sekhar Nori
  0 siblings, 0 replies; 2+ messages in thread
From: Sekhar Nori @ 2015-09-22 15:27 UTC (permalink / raw)
  To: linux-arm-kernel

On Monday 14 September 2015 02:59 PM, Peter Ujfalusi wrote:
> Fix the values returned by the publicly used functions.
> These function should return 0 when they are called with clk == NULL in
> similar manner as the clock API does to avoid different behavior in drivers
> used by daVinci and other architectures.
> 
> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti•com>

> ---
> Hi Sekhar,
> 
> This issue is visible when using generic drivers like ASoC simnple card for
> audio support.
> They rely on the fact that these functions will not return with error in case
> of clk == NULL.

Looks good. Will queue for v4.4. Some of the information below the tear
line could go into the commit text too, I think.

Thanks,
Sekhar

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

end of thread, other threads:[~2015-09-22 15:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-14  9:29 [PATCH] ARM: davinci: clock: Correct return values for API functions Peter Ujfalusi
2015-09-22 15:27 ` Sekhar Nori

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox