Skip to contentSkip to conversation

netdev: DM9000: Added typecasting to supress some warnings on Blackfin

PATCH In review Bryan Wu 6 participants 11 messages Oct 13, 2008 – Oct 14, 2008

Subsystems (2)
lore
Share & tools
lore

Bryan Wu

author
#0 lore raw

PATCH 1/1 netdev: DM9000: Added typecasting to supress some warnings on Blackfin

From: Javier Herrero <[email protected]>

---
 drivers/net/dm9000.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
drivers/net/dm9000.c +6 -6
index f42c23f..c4737ca 100644
@@ -188,35 +188,35 @@ iow(board_info_t * db, int reg, int value)
 
 static void dm9000_outblk_8bit(void __iomem *reg, void *data, int count)
 {
-	writesb(reg, data, count);
+	writesb((int)reg, data, count);
 }
 
 static void dm9000_outblk_16bit(void __iomem *reg, void *data, int count)
 {
-	writesw(reg, data, (count+1) >> 1);
+	writesw((int)reg, data, (count+1) >> 1);
 }
 
 static void dm9000_outblk_32bit(void __iomem *reg, void *data, int count)
 {
-	writesl(reg, data, (count+3) >> 2);
+	writesl((int)reg, data, (count+3) >> 2);
 }
 
 /* input block from chip to memory */
 
 static void dm9000_inblk_8bit(void __iomem *reg, void *data, int count)
 {
-	readsb(reg, data, count);
+	readsb((int)reg, data, count);
 }
 
 
 static void dm9000_inblk_16bit(void __iomem *reg, void *data, int count)
 {
-	readsw(reg, data, (count+1) >> 1);
+	readsw((int)reg, data, (count+1) >> 1);
 }
 
 static void dm9000_inblk_32bit(void __iomem *reg, void *data, int count)
 {
-	readsl(reg, data, (count+3) >> 2);
+	readsl((int)reg, data, (count+3) >> 2);
 }
 
 /* dump block from chip to null */
Signature · 1 line
1.5.6
#1 lore raw
Quoted 1 line · Bryan Wu

From: Javier Herrero <[email protected]>

No, your arch definitions of writesb and co are wrong if they are not taking 'void __iomem *' arguments.

Quoted 54 lines
---
 drivers/net/dm9000.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
drivers/net/dm9000.c +6 -6
index f42c23f..c4737ca 100644
@@ -188,35 +188,35 @@ iow(board_info_t * db, int reg, int value)
 
 static void dm9000_outblk_8bit(void __iomem *reg, void *data, int count)
 {
-	writesb(reg, data, count);
+	writesb((int)reg, data, count);
 }
 
 static void dm9000_outblk_16bit(void __iomem *reg, void *data, int count)
 {
-	writesw(reg, data, (count+1) >> 1);
+	writesw((int)reg, data, (count+1) >> 1);
 }
 
 static void dm9000_outblk_32bit(void __iomem *reg, void *data, int count)
 {
-	writesl(reg, data, (count+3) >> 2);
+	writesl((int)reg, data, (count+3) >> 2);
 }
 
 /* input block from chip to memory */
 
 static void dm9000_inblk_8bit(void __iomem *reg, void *data, int count)
 {
-	readsb(reg, data, count);
+	readsb((int)reg, data, count);
 }
 
 
 static void dm9000_inblk_16bit(void __iomem *reg, void *data, int count)
 {
-	readsw(reg, data, (count+1) >> 1);
+	readsw((int)reg, data, (count+1) >> 1);
 }
 
 static void dm9000_inblk_32bit(void __iomem *reg, void *data, int count)
 {
-	readsl(reg, data, (count+3) >> 2);
+	readsl((int)reg, data, (count+3) >> 2);
 }
 
 /* dump block from chip to null */
Signature · 1 line
1.5.6
Signature · 5 lines
-- 
Ben

Q:      What's a light-year?
A:      One-third less calories than a regular year.
#2 lore raw

Hi, Bryan,

So it seems that we must correct that in other place?

Regards,

Javier

Quoted 61 lines · Ben Dooks
Quoted 1 line · Bryan Wu

From: Javier Herrero <[email protected]>

No, your arch definitions of writesb and co are wrong if they are not taking 'void __iomem *' arguments.

Quoted 54 lines
---
 drivers/net/dm9000.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
drivers/net/dm9000.c +6 -6
index f42c23f..c4737ca 100644
@@ -188,35 +188,35 @@ iow(board_info_t * db, int reg, int value)
 
 static void dm9000_outblk_8bit(void __iomem *reg, void *data, int count)
 {
-	writesb(reg, data, count);
+	writesb((int)reg, data, count);
 }
 
 static void dm9000_outblk_16bit(void __iomem *reg, void *data, int count)
 {
-	writesw(reg, data, (count+1) >> 1);
+	writesw((int)reg, data, (count+1) >> 1);
 }
 
 static void dm9000_outblk_32bit(void __iomem *reg, void *data, int count)
 {
-	writesl(reg, data, (count+3) >> 2);
+	writesl((int)reg, data, (count+3) >> 2);
 }
 
 /* input block from chip to memory */
 
 static void dm9000_inblk_8bit(void __iomem *reg, void *data, int count)
 {
-	readsb(reg, data, count);
+	readsb((int)reg, data, count);
 }
 
 
 static void dm9000_inblk_16bit(void __iomem *reg, void *data, int count)
 {
-	readsw(reg, data, (count+1) >> 1);
+	readsw((int)reg, data, (count+1) >> 1);
 }
 
 static void dm9000_inblk_32bit(void __iomem *reg, void *data, int count)
 {
-	readsl(reg, data, (count+3) >> 2);
+	readsl((int)reg, data, (count+3) >> 2);
 }
 
 /* dump block from chip to null */
Signature · 1 line
1.5.6
Signature · 5 lines
------------------------------------------------------------------------
Javier Herrero                            EMAIL: [email protected]
HV Sistemas S.L.                          PHONE:         +34 949 336 806
Los Charcones, 17A                        FAX:           +34 949 336 792
19170 El Casar - Guadalajara - Spain      WEB: http://www.hvsistemas.com
author
#3 lore raw
Quoted 4 lines · Javier Herrero

Hi, Bryan,

So it seems that we must correct that in other place?

Yes, we need to check the I/O read_write functions.

-Bryan

Quoted 74 lines

Regards,

Javier

Quoted 51 lines · Ben Dooks
Quoted 2 lines · Bryan Wu

From: Javier Herrero <[email protected]>

No, your arch definitions of writesb and co are wrong if they are not taking 'void __iomem *' arguments.

Quoted 43 lines
---
 drivers/net/dm9000.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
drivers/net/dm9000.c +5 -5
index f42c23f..c4737ca 100644
@@ -188,35 +188,35 @@ iow(board_info_t * db, int reg, int value)
  static void dm9000_outblk_8bit(void __iomem *reg, void *data, int
 count)
 {
-       writesb(reg, data, count);
+       writesb((int)reg, data, count);
 }
  static void dm9000_outblk_16bit(void __iomem *reg, void *data, int
 count)
 {
-       writesw(reg, data, (count+1) >> 1);
+       writesw((int)reg, data, (count+1) >> 1);
 }
  static void dm9000_outblk_32bit(void __iomem *reg, void *data, int
 count)
 {
-       writesl(reg, data, (count+3) >> 2);
+       writesl((int)reg, data, (count+3) >> 2);
 }
  /* input block from chip to memory */
  static void dm9000_inblk_8bit(void __iomem *reg, void *data, int count)
 {
-       readsb(reg, data, count);
+       readsb((int)reg, data, count);
 }
   static void dm9000_inblk_16bit(void __iomem *reg, void *data, int
 count)
 {
-       readsw(reg, data, (count+1) >> 1);
+       readsw((int)reg, data, (count+1) >> 1);
 }
  static void dm9000_inblk_32bit(void __iomem *reg, void *data, int
Quoted 9 lines
Quoted 8 lines
drivers/net/dm9000.c +1 -2
 count)
 {
-       readsl(reg, data, (count+3) >> 2);
+       readsl((int)reg, data, (count+3) >> 2);
 }
  /* dump block from chip to null */
--

1.5.6

--
------------------------------------------------------------------------

Javier Herrero                            EMAIL: [email protected]
HV Sistemas S.L.                          PHONE:         +34 949 336 806
Los Charcones, 17A                        FAX:           +34 949 336 792
19170 El Casar - Guadalajara - Spain      WEB: http://www.hvsistemas.com
#4 lore raw
Quoted 4 lines · Bryan Wu
Quoted 1 line · Javier Herrero

So it seems that we must correct that in other place?

Yes, we need to check the I/O read_write functions.

and drop the CONFIG_BLACKFIN hacks in the dm90000 driver ... we rewrite the write* functions to out* ... probably because we dont provide any write* functions in our headers
-mike

author
#5 lore raw
Quoted 11 lines · Mike Frysinger
Quoted 4 lines · Bryan Wu
Quoted 1 line · Javier Herrero

So it seems that we must correct that in other place?

Yes, we need to check the I/O read_write functions.

and drop the CONFIG_BLACKFIN hacks in the dm90000 driver ... we rewrite the write* functions to out* ... probably because we dont provide any write* functions in our headers
-mike

No problem, I will take care of that.

-Bryan

author
#6 lore raw
In reply to Ben Dooks
Quoted 6 lines · Ben Dooks
Quoted 1 line · Bryan Wu

From: Javier Herrero <[email protected]>

No, your arch definitions of writesb and co are wrong if they are not taking 'void __iomem *' arguments.

Right, we should check the I/O functions and make them support "void __iomem *" arguments.

Thanks
-Bryan

Quoted 63 lines
Quoted 53 lines
---
 drivers/net/dm9000.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
drivers/net/dm9000.c +6 -7
index f42c23f..c4737ca 100644
@@ -188,35 +188,35 @@ iow(board_info_t * db, int reg, int value)
 
 static void dm9000_outblk_8bit(void __iomem *reg, void *data, int count)
 {
-     writesb(reg, data, count);
+     writesb((int)reg, data, count);
 }
 
 static void dm9000_outblk_16bit(void __iomem *reg, void *data, int count)
 {
-     writesw(reg, data, (count+1) >> 1);
+     writesw((int)reg, data, (count+1) >> 1);
 }
 
 static void dm9000_outblk_32bit(void __iomem *reg, void *data, int count)
 {
-     writesl(reg, data, (count+3) >> 2);
+     writesl((int)reg, data, (count+3) >> 2);
 }
 
 /* input block from chip to memory */
 
 static void dm9000_inblk_8bit(void __iomem *reg, void *data, int count)
 {
-     readsb(reg, data, count);
+     readsb((int)reg, data, count);
 }
 
 
 static void dm9000_inblk_16bit(void __iomem *reg, void *data, int count)
 {
-     readsw(reg, data, (count+1) >> 1);
+     readsw((int)reg, data, (count+1) >> 1);
 }
 
 static void dm9000_inblk_32bit(void __iomem *reg, void *data, int count)
 {
-     readsl(reg, data, (count+3) >> 2);
+     readsl((int)reg, data, (count+3) >> 2);
 }
 
 /* dump block from chip to null */
--
Quoted 1 line

1.5.6

--
--
Ben

Q:      What's a light-year?
A:      One-third less calories than a regular year.
maintainer
#7 lore raw
In reply to Bryan Wu

From: Bryan Wu <[email protected]>
Date: Mon, 13 Oct 2008 17:10:09 +0800

Quoted 4 lines

From: Javier Herrero <[email protected]>

This is not only inelegant, it'll likely break things on 64-bit MIPS or any other case where the upper 32-bit matter.

I'd rather see Blackfin fix it's I/O accessor prototypes to take a proper __iomem pointer.

This patch won't be applied.

#8 lore raw
Quoted 5 lines · David Miller

From: Bryan Wu <[email protected]>
Date: Mon, 13 Oct 2008 17:10:09 +0800

Quoted 2 lines

From: Javier Herrero <[email protected]>

Quoted 8 lines
Quoted 2 lines

This is not only inelegant, it'll likely break things on 64-bit MIPS or any other case where the upper 32-bit matter.

I'd rather see Blackfin fix it's I/O accessor prototypes to take a proper __iomem pointer.

How much would it hurt to provide blackfin wide readsb and friends with the correct prototype and remove the nasty blackfin hack in the dm9000.c driver for good?

Signature · 4 lines
Ben

Q:      What's a light-year?
A:      One-third less calories than a regular year.
#9 lore raw
In reply to Bryan Wu
Quoted 13 lines · On Mon, 13 Oct 2008 17:10:09 +0800 Bryan Wu <[email protected]> wrote:

From: Javier Herrero <[email protected]>

---
 drivers/net/dm9000.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
drivers/net/dm9000.c +0 -0
index f42c23f..c4737ca 100644

drivers/net/dm9000.c iow(board_info_t * db, int reg, int value) · line 192

Quoted 6 lines
drivers/net/dm9000.c +1 -1
@@ -188,35 +188,35 @@ iow(board_info_t * db, int reg, int value)
 
 static void dm9000_outblk_8bit(void __iomem *reg, void *data, int count)
 {
-	writesb(reg, data, count);
+	writesb((int)reg, data, count);
 }

You lose the sparse checking for misuse by doing this.

Why not this instead?

drivers/net/dm9000.c +34 -8
@@ -47,14 +47,6 @@
 #define CARDNAME	"dm9000"
 #define DRV_VERSION	"1.31"
 
-#ifdef CONFIG_BLACKFIN
-#define readsb	insb
-#define readsw	insw
-#define readsl	insl
-#define writesb	outsb
-#define writesw	outsw
-#define writesl	outsl
-#endif
 
 /*
  * Transmit timeout, default 5 seconds.
@@ -185,7 +177,40 @@ iow(board_info_t * db, int reg, int valu
 }
 
 /* routines for sending block to chip */
+#ifdef CONFIG_BLACKFIN
+static void dm9000_outblk_8bit(void __iomem *reg, void *data, int count)
+{
+	outsb((unsigned long)reg, data, count);
+}
 
+static void dm9000_outblk_16bit(void __iomem *reg, void *data, int count)
+{
+	outsw((unsigned long)reg, data, (count+1) >> 1);
+}
+
+static void dm9000_outblk_32bit(void __iomem *reg, void *data, int count)
+{
+	outsl((unsigned long)reg, data, (count+3) >> 2);
+}
+
+/* input block from chip to memory */
+
+static void dm9000_inblk_8bit(void __iomem *reg, void *data, int count)
+{
+	insb((unsigned long)reg, data, count);
+}
+
+
+static void dm9000_inblk_16bit(void __iomem *reg, void *data, int count)
+{
+	insw((unsigned long)reg, data, (count+1) >> 1);
+}
+
+static void dm9000_inblk_32bit(void __iomem *reg, void *data, int count)
+{
+	insl((unsigned long)reg, data, (count+3) >> 2);
+}
+#else
 static void dm9000_outblk_8bit(void __iomem *reg, void *data, int count)
 {
 	writesb(reg, data, count);
@@ -218,6 +243,7 @@ static void dm9000_inblk_32bit(void __io
 {
 	readsl(reg, data, (count+3) >> 2);
 }
+#endif
 
 /* dump block from chip to null */
 
author
#10 lore raw
Quoted 46 lines · Stephen Hemminger
Quoted 13 lines · On Mon, 13 Oct 2008 17:10:09 +0800 Bryan Wu <[email protected]> wrote:

From: Javier Herrero <[email protected]>

---
 drivers/net/dm9000.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
drivers/net/dm9000.c +0 -0
index f42c23f..c4737ca 100644

drivers/net/dm9000.c iow(board_info_t * db, int reg, int value) · line 192

Quoted 6 lines
drivers/net/dm9000.c +1 -1
@@ -188,35 +188,35 @@ iow(board_info_t * db, int reg, int value)
 
 static void dm9000_outblk_8bit(void __iomem *reg, void *data, int count)
 {
-     writesb(reg, data, count);
+     writesb((int)reg, data, count);
 }

You lose the sparse checking for misuse by doing this.

Why not this instead?

drivers/net/dm9000.c 2008-10-13 05:40:13.000000000 -0700 renamed from drivers/net/dm9000.c 2008-10-13 05:29:15.000000000 -0700 +0 -8
@@ -47,14 +47,6 @@
 #define CARDNAME       "dm9000"
 #define DRV_VERSION    "1.31"
 
-#ifdef CONFIG_BLACKFIN
-#define readsb insb
-#define readsw insw
-#define readsl insl
-#define writesb        outsb
-#define writesw        outsw
-#define writesl        outsl
-#endif
 
 /*
 * Transmit timeout, default 5 seconds.

drivers/net/dm9000.c 2008-10-13 05:40:13.000000000 -0700 iow(board_info_t * db, int reg, int valu · line 185

Quoted 9 lines
drivers/net/dm9000.c 2008-10-13 05:40:13.000000000 -0700 renamed from drivers/net/dm9000.c 2008-10-13 05:29:15.000000000 -0700 +5 -0
@@ -185,7 +177,40 @@ iow(board_info_t * db, int reg, int valu
 }
 
 /* routines for sending block to chip */
+#ifdef CONFIG_BLACKFIN
+static void dm9000_outblk_8bit(void __iomem *reg, void *data, int count)
+{
+       outsb((unsigned long)reg, data, count);
+}
 

I added readsl/writesl to blackfin arch, so we don't need to mess up the common DM9000 netdev driver here.

-Bryan

Quoted 44 lines
drivers/net/dm9000.c 2008-10-13 05:40:13.000000000 -0700 renamed from drivers/net/dm9000.c 2008-10-13 05:29:15.000000000 -0700 +29 -1
+static void dm9000_outblk_16bit(void __iomem *reg, void *data, int count)
+{
+       outsw((unsigned long)reg, data, (count+1) >> 1);
+}
+
+static void dm9000_outblk_32bit(void __iomem *reg, void *data, int count)
+{
+       outsl((unsigned long)reg, data, (count+3) >> 2);
+}
+
+/* input block from chip to memory */
+
+static void dm9000_inblk_8bit(void __iomem *reg, void *data, int count)
+{
+       insb((unsigned long)reg, data, count);
+}
+
+
+static void dm9000_inblk_16bit(void __iomem *reg, void *data, int count)
+{
+       insw((unsigned long)reg, data, (count+1) >> 1);
+}
+
+static void dm9000_inblk_32bit(void __iomem *reg, void *data, int count)
+{
+       insl((unsigned long)reg, data, (count+3) >> 2);
+}
+#else
 static void dm9000_outblk_8bit(void __iomem *reg, void *data, int count)
 {
       writesb(reg, data, count);
@@ -218,6 +243,7 @@ static void dm9000_inblk_32bit(void __io
 {
       readsl(reg, data, (count+3) >> 2);
 }
+#endif
 
 /* dump block from chip to null */
 
--

To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html