Skip to contentSkip to conversation

net: fix SONIC_READ definition

PATCH In review Roel Kluin 2 participants 2 messages Jan 3, 2009 – Jan 5, 2009

Subsystems (2)
lore
Share & tools
lore

Roel Kluin

author
#0 lore raw

PATCH 1/1 net: fix SONIC_READ definition

drivers/net/jazzsonic.c:56:
#define SONIC_READ(reg) (*((volatile unsigned int *)dev->base_addr+reg))

drivers/net/sonic.h:53:
#define SONIC_CAP0 0x24

so drivers/net/jazzsonic.c:143:
val = SONIC_READ(SONIC_CAP0-i);

becomes

val = (*((volatile unsigned int *)dev->base_addr+0x24-i));

That is wrong, isn't it?
------------->8---------8<------------------
Fix SONIC_READ definition

---

drivers/net/jazzsonic.c +1 -1
index 334ff9e..b872f23 100644
@@ -53,7 +53,7 @@ static char jazz_sonic_string[] = "jazzsonic";
 /*
  * Macros to access SONIC registers
  */
-#define SONIC_READ(reg) (*((volatile unsigned int *)dev->base_addr+reg))
+#define SONIC_READ(reg) (*((volatile unsigned int *)dev->base_addr+(reg)))
 
 #define SONIC_WRITE(reg,val)						\
 do {									\
maintainer
#1 lore raw

From: Roel Kluin <[email protected]>
Date: Sat, 03 Jan 2009 19:43:24 +0100

Quoted 6 lines

drivers/net/jazzsonic.c:56:
#define SONIC_READ(reg) (*((volatile unsigned int *)dev->base_addr+reg))

drivers/net/sonic.h:53:
#define SONIC_CAP0 0x24

Quoted 8 lines

so drivers/net/jazzsonic.c:143:
val = SONIC_READ(SONIC_CAP0-i);

becomes

val = (*((volatile unsigned int *)dev->base_addr+0x24-i));

That is wrong, isn't it?

The expression, both with and without the parentheses around "reg", evaluate to the same final pointer value.

Compile a test program and look at the assembler output if you don't believe me :-)