Skip to contentSkip to conversation

rmobile: kzm9g: Fix warnin in cmp_loop function

PATCH New Nobuhiro Iwamatsu 3 participants 3 messages Jul 6, 2012 – Jul 19, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rmobile: kzm9g: Fix warnin in cmp_loop function

cmp_loop function was used from the structure of register. And for the member of this structure, volatile is defined. Since a volatile declaration of cmp_loop function is not made by argument, made warning by compiler. This fixes this problem.

---
 board/kmc/kzm9g/kzm9g.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
board/kmc/kzm9g/kzm9g.c +1 -1
index ad72c8d..8d7c61a 100644
@@ -48,7 +48,7 @@ DECLARE_GLOBAL_DATA_PTR;
 #define PORT34CR (0xE6051022)
 #define PORT35CR (0xE6051023)
 
-static int cmp_loop(u32 *addr, u32 data, u32 cmp)
+static int cmp_loop(volatile u32 *addr, u32 data, u32 cmp)
 {
 	int err = -1;
 	int timeout = 100;
Signature · 1 line
1.7.10
#1 lore raw

PATCH 1/1 rmobile: kzm9g: Fix warnin in cmp_loop function

Hi Nobuhiro,

Quoted 15 lines · Nobuhiro Iwamatsu

cmp_loop function was used from the structure of register. And for the member of this structure, volatile is defined. Since a volatile declaration of cmp_loop function is not made by argument, made warning by compiler. This fixes this problem.

---
 board/kmc/kzm9g/kzm9g.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
board/kmc/kzm9g/kzm9g.c +0 -0
index ad72c8d..8d7c61a 100644

board/kmc/kzm9g/kzm9g.c DECLARE_GLOBAL_DATA_PTR; · line 54

Quoted 8 lines
board/kmc/kzm9g/kzm9g.c +1 -1
@@ -48,7 +48,7 @@ DECLARE_GLOBAL_DATA_PTR;
 #define PORT34CR (0xE6051022)
 #define PORT35CR (0xE6051023)
 
-static int cmp_loop(u32 *addr, u32 data, u32 cmp)
+static int cmp_loop(volatile u32 *addr, u32 data, u32 cmp)
 {
 	int err = -1;
 	int timeout = 100;

I doubt cmp_loop needs this change. Volatile qualifiers do not make much sense in anything other than actual read or write instructions; if cmp_loop needs any volatile, it's as casts in its body, not as qualifiers in its signature. Fix the compiler warning by casting the actual argument in the *call* to cmp_loop to non-volatile instead.

(incidentally, you should ask yourself why is the structure, or structure member, is qualified volatile in the first place; usually this is the sign that some code should instead use readl or writel and/or have isb() barriers at strategic places.)

Amicalement,

Signature · 1 line
Albert.
#2 lore raw

PATCH 1/1 rmobile: kzm9g: Fix warnin in cmp_loop function

Hi,

2012/7/6 Albert ARIBAUD <[email protected]>:

Quoted 34 lines

Hi Nobuhiro,

Quoted 15 lines · Nobuhiro Iwamatsu

cmp_loop function was used from the structure of register. And for the member of this structure, volatile is defined. Since a volatile declaration of cmp_loop function is not made by argument, made warning by compiler. This fixes this problem.

---
 board/kmc/kzm9g/kzm9g.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
board/kmc/kzm9g/kzm9g.c +0 -0
index ad72c8d..8d7c61a 100644

board/kmc/kzm9g/kzm9g.c DECLARE_GLOBAL_DATA_PTR; · line 54

Quoted 8 lines
board/kmc/kzm9g/kzm9g.c +1 -1
@@ -48,7 +48,7 @@ DECLARE_GLOBAL_DATA_PTR;
 #define PORT34CR (0xE6051022)
 #define PORT35CR (0xE6051023)
 
-static int cmp_loop(u32 *addr, u32 data, u32 cmp)
+static int cmp_loop(volatile u32 *addr, u32 data, u32 cmp)
 {
      int err = -1;
      int timeout = 100;

I doubt cmp_loop needs this change. Volatile qualifiers do not make much sense in anything other than actual read or write instructions; if cmp_loop needs any volatile, it's as casts in its body, not as qualifiers in its signature. Fix the compiler warning by casting the actual argument in the *call* to cmp_loop to non-volatile instead.

Quoted 5 lines

(incidentally, you should ask yourself why is the structure, or structure member, is qualified volatile in the first place; usually this is the sign that some code should instead use readl or writel and/or have isb() barriers at strategic places.)

Thank you for your comment.
You are right. I will fix structure member.

Best regards,
Nobuhiro

Signature · 3 lines
Nobuhiro Iwamatsu
   iwamatsu at {nigauri.org / debian.org}
   GPG ID: 40AD1FA6