Skip to contentSkip to conversation

sh: boards: mach-se: use IS_ERR() instead of NULL check

PATCH In review Vasiliy Kulikov 3 participants 5 messages Nov 26, 2010 – Nov 29, 2010

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

PATCH 1/1 sh: boards: mach-se: use IS_ERR() instead of NULL check

clk_get() returns ERR_PTR() on error, not NULL.

---
Cannot compile this driver, so it is not tested at all.

 arch/sh/boards/mach-se/7724/setup.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
arch/sh/boards/mach-se/7724/setup.c +2 -2
index c31d228..6735305 100644
@@ -871,14 +871,14 @@ static int __init devices_setup(void)
 
 	/* set SPU2 clock to 83.4 MHz */
 	clk = clk_get(NULL, "spu_clk");
-	if (clk) {
+	if (!IS_ERR(clk)) {
 		clk_set_rate(clk, clk_round_rate(clk, 83333333));
 		clk_put(clk);
 	}
 
 	/* change parent of FSI A */
 	clk = clk_get(NULL, "fsia_clk");
-	if (clk) {
+	if (!IS_ERR(clk)) {
 		clk_register(&fsimcka_clk);
 		clk_set_parent(clk, &fsimcka_clk);
 		clk_set_rate(clk, 11000);
Signature · 1 line
1.7.0.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 3 lines · Vasiliy Kulikov

clk_get() returns ERR_PTR() on error, not NULL.

Yep, there are, probably, a couple more of these, similar to

http://marc.info/?t8715350900002&r=1&w=2

Hardly required, but if you like:

Thanks
Guennadi

Quoted 31 lines

---
Cannot compile this driver, so it is not tested at all.

 arch/sh/boards/mach-se/7724/setup.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
arch/sh/boards/mach-se/7724/setup.c +2 -2
index c31d228..6735305 100644
@@ -871,14 +871,14 @@ static int __init devices_setup(void)
 
 	/* set SPU2 clock to 83.4 MHz */
 	clk = clk_get(NULL, "spu_clk");
-	if (clk) {
+	if (!IS_ERR(clk)) {
 		clk_set_rate(clk, clk_round_rate(clk, 83333333));
 		clk_put(clk);
 	}
 
 	/* change parent of FSI A */
 	clk = clk_get(NULL, "fsia_clk");
-	if (clk) {
+	if (!IS_ERR(clk)) {
 		clk_register(&fsimcka_clk);
 		clk_set_parent(clk, &fsimcka_clk);
 		clk_set_rate(clk, 11000);
Signature · 1 line
1.7.0.4

---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/

#2 lore raw

Hi Guennadi,

Quoted 6 lines · Guennadi Liakhovetski
Quoted 3 lines · Vasiliy Kulikov

clk_get() returns ERR_PTR() on error, not NULL.

Yep, there are, probably, a couple more of these, similar to

I found a bit more, but I'd like to get feedback on these or just see it applied first ;)

Thanks,

Signature · 2 lines
Vasiliy Kulikov
http://www.openwall.com - bringing security into open computing environments
#3 lore raw
Quoted 4 lines · Vasiliy Kulikov

Hi Guennadi,

Quoted 1 line · Guennadi Liakhovetski

On Fri, 26 Nov 2010, Vasiliy Kulikov wrote:

Quoted 9 lines
Quoted 5 lines
Quoted 3 lines

clk_get() returns ERR_PTR() on error, not NULL.

Yep, there are, probably, a couple more of these, similar to

I found a bit more, but I'd like to get feedback on these or just see it applied first ;)

It's a reasonable change, yes. The old clk_get() scanned multiple lists, and could return NULL or -ENOENT depending on which path failed. Now that everything is consolidated through the clk_get_sys() lookup, the NULL checks should probably all be replaced.

#4 lore raw
Quoted 11 lines · Paul Mundt
Quoted 10 lines · Vasiliy Kulikov

Hi Guennadi,

Quoted 6 lines · Guennadi Liakhovetski
Quoted 3 lines · Vasiliy Kulikov

clk_get() returns ERR_PTR() on error, not NULL.

Yep, there are, probably, a couple more of these, similar to

Quoted 7 lines
Quoted 3 lines

I found a bit more, but I'd like to get feedback on these or just see it applied first ;)

It's a reasonable change, yes. The old clk_get() scanned multiple lists, and could return NULL or -ENOENT depending on which path failed. Now that everything is consolidated through the clk_get_sys() lookup, the NULL checks should probably all be replaced.

Anyways, I've applied this one now. Feel free to send updates for the rest at your leisure.