ARM: SAMSUNG: Should check for IS_ERR(clk) instead of NULL
Subsystems (3)
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
@@ -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
Quoted 14 lines · [email protected] wrote:
From: Jonghwan Choi<[email protected]>
On the error condition
clk_get()returnsERR_PTR().Signed-off-by Jonghwan Choi<[email protected]>--- .../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
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
-0clk_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.
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
-0clk_enable (s3c2410_wdtclk);/* put initial values into count and data */
--
Regards,
Sylwester
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.
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 fromclk_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.
Kukjin Kim
AppliedQuoted 24 lines · [email protected] wrote:
From: Jonghwan Choi <[email protected]>
On the error condition
clk_get()returnsERR_PTR().Signed-off-by Jonghwan Choi <[email protected]>--- .../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@@ -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.