Skip to contentSkip to conversation

ARM: SAMSUNG: Should check for IS_ERR(clk) instead of NULL

PATCH Applied [email protected] 4 participants 6 messages Apr 18, 2012 – Jun 21, 2012

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: SAMSUNG: Should check for IS_ERR(clk) instead of NULL

From: Jonghwan Choi <[email protected]>

On the error condition clk_get() returns ERR_PTR().

---
 .../arm/plat-samsung/include/plat/watchdog-reset.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/arm/plat-samsung/include/plat/watchdog-reset.h +1 -1
index f19aff1..bc4db9b 100644
@@ -25,7 +25,7 @@ static inline void arch_wdt_reset(void)
 
 	__raw_writel(0, S3C2410_WTCON);	  /* disable watchdog, to be safe  */
 
-	if (s3c2410_wdtclk)
+	if (!IS_ERR(s3c2410_wdtclk))
 		clk_enable(s3c2410_wdtclk);
 
 	/* put initial values into count and data */
Signature · 1 line
1.7.0.4
#1 lore raw
Quoted 14 lines · [email protected] wrote:

From: Jonghwan Choi<[email protected]>

On the error condition clk_get() returns ERR_PTR().

---
  .../arm/plat-samsung/include/plat/watchdog-reset.h |    2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
arch/arm/plat-samsung/include/plat/watchdog-reset.h +0 -0
index f19aff1..bc4db9b 100644

arch/arm/plat-samsung/include/plat/watchdog-reset.h static inline void arch_wdt_reset(void) · line 28

Quoted 5 lines
arch/arm/plat-samsung/include/plat/watchdog-reset.h +1 -1
@@ -25,7 +25,7 @@ static inline void arch_wdt_reset(void)
 
  	__raw_writel(0, S3C2410_WTCON);	  /* disable watchdog, to be safe  */
 
-	if (s3c2410_wdtclk)
+	if (!IS_ERR(s3c2410_wdtclk))

Yeah, right. BTW don't we need to check NULL here?

arch/arm/plat-samsung/include/plat/watchdog-reset.h static inline void arch_wdt_reset(void) · line 31

Quoted 3 lines
arch/arm/plat-samsung/include/plat/watchdog-reset.h +0 -0
  		clk_enable(s3c2410_wdtclk);
 
  	/* put initial values into count and data */

Thanks.

Best regards,
Kgene.
--
Kukjin Kim <[email protected]>, Senior Engineer, SW Solution Development Team, Samsung Electronics Co., Ltd.

#2 lore raw

PATCH 1/1 ARM: SAMSUNG: Should check for IS_ERR(clk) instead of NULL

Quoted 10 lines · Kukjin Kim

arch/arm/plat-samsung/include/plat/watchdog-reset.h static inline void arch_wdt_reset(void) · line 28

Quoted 8 lines
arch/arm/plat-samsung/include/plat/watchdog-reset.h +1 -1
@@ -25,7 +25,7 @@ static inline void arch_wdt_reset(void)
 
  	__raw_writel(0, S3C2410_WTCON);	  /* disable watchdog, to be safe  */
 
-	if (s3c2410_wdtclk)
+	if (!IS_ERR(s3c2410_wdtclk))

Yeah, right. BTW don't we need to check NULL here?

It might make sense to check for NULL as well, but only if it happens that a clock entry is ever added to clkdev with null struct clk_lookup:clk member. This in turn seems impossible with the current clock code at plat-samsung/clock.c.

Quoted 3 lines

arch/arm/plat-samsung/include/plat/watchdog-reset.h static inline void arch_wdt_reset(void) · line 31

Quoted 3 lines
arch/arm/plat-samsung/include/plat/watchdog-reset.h +0 -0
  		clk_enable(s3c2410_wdtclk);
 
  	/* put initial values into count and data */

--
Regards,
Sylwester

#3 lore raw

PATCH 1/1 ARM: SAMSUNG: Should check for IS_ERR(clk) instead of NULL

Quoted 7 lines · Sylwester Nawrocki
Quoted 6 lines · Kukjin Kim
Quoted 6 lines
arch/arm/plat-samsung/include/plat/watchdog-reset.h +0 -0
@@ -25,7 +25,7 @@ static inline void arch_wdt_reset(void)
 
  	__raw_writel(0, S3C2410_WTCON);	  /* disable watchdog, to be safe  */
 
Quoted 8 lines
Quoted 4 lines

arch/arm/plat-samsung/include/plat/watchdog-reset.h static inline void arch_wdt_reset(void) · line 28

Quoted 2 lines
arch/arm/plat-samsung/include/plat/watchdog-reset.h +1 -1
-	if (s3c2410_wdtclk)
+	if (!IS_ERR(s3c2410_wdtclk))

Yeah, right. BTW don't we need to check NULL here?

It might make sense to check for NULL as well, but only if it happens that a clock entry is ever added to clkdev with null struct clk_lookup:clk member.

Not quite the correct answer. The correct answer is:

Drivers have no business interpreting anything but IS_ERR() values from clk_get() as errors. Everything else they _MUST_ assume is valid for the rest of the clk API.

The clue: struct clk is an opaque cookie as far as drivers are concerned. The only interpretation drivers are allowed to make is that IS_ERR() values indicate an error. Everything else is potentially valid.

#4 lore raw

PATCH 1/1 ARM: SAMSUNG: Should check for IS_ERR(clk) instead of NULL

Quoted 19 lines · Russell King - ARM Linux
Quoted 7 lines · Sylwester Nawrocki
Quoted 6 lines · Kukjin Kim
Quoted 6 lines
arch/arm/plat-samsung/include/plat/watchdog-reset.h +0 -0
@@ -25,7 +25,7 @@ static inline void arch_wdt_reset(void)
 
  	__raw_writel(0, S3C2410_WTCON);	  /* disable watchdog, to be safe  */
 
Quoted 8 lines
Quoted 4 lines

arch/arm/plat-samsung/include/plat/watchdog-reset.h static inline void arch_wdt_reset(void) · line 28

Quoted 2 lines
arch/arm/plat-samsung/include/plat/watchdog-reset.h +1 -1
-	if (s3c2410_wdtclk)
+	if (!IS_ERR(s3c2410_wdtclk))

Yeah, right. BTW don't we need to check NULL here?

It might make sense to check for NULL as well, but only if it happens that a clock entry is ever added to clkdev with null struct clk_lookup:clk member.

Not quite the correct answer. The correct answer is:

Quoted 7 lines

Drivers have no business interpreting anything but IS_ERR() values from clk_get() as errors. Everything else they _MUST_ assume is valid for the rest of the clk API.

The clue: struct clk is an opaque cookie as far as drivers are concerned. The only interpretation drivers are allowed to make is that IS_ERR() values indicate an error. Everything else is potentially valid.

Thanks for the clarification. I stand corrected.

Applied
#5 lore raw
In reply to [email protected]
Quoted 24 lines · [email protected] wrote:

From: Jonghwan Choi <[email protected]>

On the error condition clk_get() returns ERR_PTR().

---
 .../arm/plat-samsung/include/plat/watchdog-reset.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/arm/plat-samsung/include/plat/watchdog-reset.h +1 -1
index f19aff1..bc4db9b 100644
@@ -25,7 +25,7 @@ static inline void arch_wdt_reset(void)
 
 	__raw_writel(0, S3C2410_WTCON);	  /* disable watchdog, to be safe
 */
 
-	if (s3c2410_wdtclk)
+	if (!IS_ERR(s3c2410_wdtclk))
 		clk_enable(s3c2410_wdtclk);
 
Quoted 3 lines

/* put initial values into count and data */
--
1.7.0.4

Applied, thanks.

Best regards,
Kgene.
--
Kukjin Kim <[email protected]>, Senior Engineer, SW Solution Development Team, Samsung Electronics Co., Ltd.