Skip to contentSkip to conversation

Warning Fix drivers/net/wireless in Kernel 2.6.9

PATCH Bryan Batten 2 participants 2 messages Nov 10, 2004 – Nov 11, 2004

lore
Share & tools
lore
#0 lore raw

The patch removes the "makes pointer from integer without a cast" warnings in orinoco code by casting the appropriate parameter to readw, writew as (void *) in the header file hermes.h.

The underlying problem is that readw/writes boil down to low level calls that take a pointer, while inw/outw boil down (eventually) to low level calls that take an int. So the choice was to either cast inw, outw parameters as (int)'s, or cast readw, writew parameters as (void *). I chose the latter.

I suspect the truly "best" fix would be to change the underlying inx/outx definitions to accept a pointer, so's to be consistent with the definitions of readx/writex, but that would probably break other stuff.

Anyway, here's the patch to hermes.h:

linux-2.6/drivers/net/wireless/hermes.h Wed Nov 10 09:35:55 2004 renamed from linux-2.6.9orig/drivers/net/wireless/hermes.h Thu Nov 4 11:33:23 2004 +5 -5
@@ -364,12 +364,12 @@ typedef struct hermes {
 /* Register access convenience macros */
 #define hermes_read_reg(hw, off) ((hw)->io_space ? \
        inw((hw)->iobase + ( (off) << (hw)->reg_spacing )) : \
-       readw((hw)->iobase + ( (off) << (hw)->reg_spacing )))
+       readw((void *)(hw)->iobase + ( (off) << (hw)->reg_spacing )))
 #define hermes_write_reg(hw, off, val) do { \
        if ((hw)->io_space) \
                outw_p((val), (hw)->iobase + ((off) << (hw)->reg_spacing)); \
        else \
-               writew((val), (hw)->iobase + ((off) << (hw)->reg_spacing)); \
+               writew((val), (void *)(hw)->iobase + ((off) << (hw)->reg_spacing)); \
        } while (0)
 #define hermes_read_regn(hw, name) hermes_read_reg((hw), HERMES_##name)
 #define hermes_write_regn(hw, name, val) hermes_write_reg((hw), HERMES_##name, (val))
@@ -442,7 +442,7 @@ static inline void hermes_read_words(str
                 * gcc is smart enough to fold away the two swaps on
                 * big-endian platforms. */
                for (i = 0, p = buf; i < count; i++) {
-                       *p++ = cpu_to_le16(readw(hw->iobase + off));
+                       *p++ = cpu_to_le16(readw((void *)hw->iobase + off));
                }
        }
 }
@@ -462,7 +462,7 @@ static inline void hermes_write_words(st
                 * hope gcc is smart enough to fold away the two swaps
                 * on big-endian platforms. */
                for (i = 0, p = buf; i < count; i++) {
-                       writew(le16_to_cpu(*p++), hw->iobase + off);
+                       writew(le16_to_cpu(*p++), (void *)hw->iobase + off);
                }
        }
 }
@@ -478,7 +478,7 @@ static inline void hermes_clear_words(st
                        outw(0, hw->iobase + off);
        } else {
                for (i = 0; i < count; i++)
-                       writew(0, hw->iobase + off);
+                       writew(0, (void *)hw->iobase + off);
        }
 }
#1 lore raw
Quoted 10 lines · Bryan Batten

The patch removes the "makes pointer from integer without a cast" warnings in orinoco code by casting the appropriate parameter to readw, writew as (void *) in the header file hermes.h.

The underlying problem is that readw/writes boil down to low level calls that take a pointer, while inw/outw boil down (eventually) to low level calls that take an int. So the choice was to either cast inw, outw parameters as (int)'s, or cast readw, writew parameters as (void *). I chose the latter.

Quoted 4 lines

I suspect the truly "best" fix would be to change the underlying inx/outx definitions to accept a pointer, so's to be consistent with the definitions of readx/writex, but that would probably break other stuff.

That's what the new ioread*() and iowrite*() functions are for. Al Viro has already made a fix to use these, and it is in the netdev bk tree.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist.  NOT _the_ _other_ _way_
				| _around_!
http://www.ozlabs.org/people/dgibson