diff options
author | Al Viro <viro@ftp.linux.org.uk> | 2007-12-22 13:56:13 -0500 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-12-22 22:53:07 -0500 |
commit | b1e247ad8e4ff29b5c7fa2b9a081b4a0f483b0d3 (patch) | |
tree | 02c7d1ef91b0b8606309dda78455c00d0e2aadd2 | |
parent | cf96237837ec6d4fc48bc2f735c71027cc0fc5fa (diff) |
3c574 and 3c589 endianness fixes (.24?)
Both store MAC address in CIS; there's no decoder for that
type (0x88) so the drivers work with raw data. It is
byteswapped, so ntohs() works for little-endian, but for
big-endian it's wrong. ntohs(le16_to_cpu()) does the
right thing on both (and always expands to swab16()).
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
-rw-r--r-- | drivers/net/pcmcia/3c574_cs.c | 10 | ||||
-rw-r--r-- | drivers/net/pcmcia/3c589_cs.c | 9 |
2 files changed, 10 insertions, 9 deletions
diff --git a/drivers/net/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c index ad134a61302..288177716a4 100644 --- a/drivers/net/pcmcia/3c574_cs.c +++ b/drivers/net/pcmcia/3c574_cs.c | |||
@@ -337,15 +337,15 @@ static int tc574_config(struct pcmcia_device *link) | |||
337 | struct net_device *dev = link->priv; | 337 | struct net_device *dev = link->priv; |
338 | struct el3_private *lp = netdev_priv(dev); | 338 | struct el3_private *lp = netdev_priv(dev); |
339 | tuple_t tuple; | 339 | tuple_t tuple; |
340 | unsigned short buf[32]; | 340 | __le16 buf[32]; |
341 | int last_fn, last_ret, i, j; | 341 | int last_fn, last_ret, i, j; |
342 | kio_addr_t ioaddr; | 342 | kio_addr_t ioaddr; |
343 | u16 *phys_addr; | 343 | __be16 *phys_addr; |
344 | char *cardname; | 344 | char *cardname; |
345 | union wn3_config config; | 345 | union wn3_config config; |
346 | DECLARE_MAC_BUF(mac); | 346 | DECLARE_MAC_BUF(mac); |
347 | 347 | ||
348 | phys_addr = (u16 *)dev->dev_addr; | 348 | phys_addr = (__be16 *)dev->dev_addr; |
349 | 349 | ||
350 | DEBUG(0, "3c574_config(0x%p)\n", link); | 350 | DEBUG(0, "3c574_config(0x%p)\n", link); |
351 | 351 | ||
@@ -378,12 +378,12 @@ static int tc574_config(struct pcmcia_device *link) | |||
378 | if (pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS) { | 378 | if (pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS) { |
379 | pcmcia_get_tuple_data(link, &tuple); | 379 | pcmcia_get_tuple_data(link, &tuple); |
380 | for (i = 0; i < 3; i++) | 380 | for (i = 0; i < 3; i++) |
381 | phys_addr[i] = htons(buf[i]); | 381 | phys_addr[i] = htons(le16_to_cpu(buf[i])); |
382 | } else { | 382 | } else { |
383 | EL3WINDOW(0); | 383 | EL3WINDOW(0); |
384 | for (i = 0; i < 3; i++) | 384 | for (i = 0; i < 3; i++) |
385 | phys_addr[i] = htons(read_eeprom(ioaddr, i + 10)); | 385 | phys_addr[i] = htons(read_eeprom(ioaddr, i + 10)); |
386 | if (phys_addr[0] == 0x6060) { | 386 | if (phys_addr[0] == htons(0x6060)) { |
387 | printk(KERN_NOTICE "3c574_cs: IO port conflict at 0x%03lx" | 387 | printk(KERN_NOTICE "3c574_cs: IO port conflict at 0x%03lx" |
388 | "-0x%03lx\n", dev->base_addr, dev->base_addr+15); | 388 | "-0x%03lx\n", dev->base_addr, dev->base_addr+15); |
389 | goto failed; | 389 | goto failed; |
diff --git a/drivers/net/pcmcia/3c589_cs.c b/drivers/net/pcmcia/3c589_cs.c index a98fe07cce7..e862d14ece7 100644 --- a/drivers/net/pcmcia/3c589_cs.c +++ b/drivers/net/pcmcia/3c589_cs.c | |||
@@ -251,7 +251,8 @@ static int tc589_config(struct pcmcia_device *link) | |||
251 | struct net_device *dev = link->priv; | 251 | struct net_device *dev = link->priv; |
252 | struct el3_private *lp = netdev_priv(dev); | 252 | struct el3_private *lp = netdev_priv(dev); |
253 | tuple_t tuple; | 253 | tuple_t tuple; |
254 | u16 buf[32], *phys_addr; | 254 | __le16 buf[32]; |
255 | __be16 *phys_addr; | ||
255 | int last_fn, last_ret, i, j, multi = 0, fifo; | 256 | int last_fn, last_ret, i, j, multi = 0, fifo; |
256 | kio_addr_t ioaddr; | 257 | kio_addr_t ioaddr; |
257 | char *ram_split[] = {"5:3", "3:1", "1:1", "3:5"}; | 258 | char *ram_split[] = {"5:3", "3:1", "1:1", "3:5"}; |
@@ -259,7 +260,7 @@ static int tc589_config(struct pcmcia_device *link) | |||
259 | 260 | ||
260 | DEBUG(0, "3c589_config(0x%p)\n", link); | 261 | DEBUG(0, "3c589_config(0x%p)\n", link); |
261 | 262 | ||
262 | phys_addr = (u16 *)dev->dev_addr; | 263 | phys_addr = (__be16 *)dev->dev_addr; |
263 | tuple.Attributes = 0; | 264 | tuple.Attributes = 0; |
264 | tuple.TupleData = (cisdata_t *)buf; | 265 | tuple.TupleData = (cisdata_t *)buf; |
265 | tuple.TupleDataMax = sizeof(buf); | 266 | tuple.TupleDataMax = sizeof(buf); |
@@ -298,11 +299,11 @@ static int tc589_config(struct pcmcia_device *link) | |||
298 | if (pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS) { | 299 | if (pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS) { |
299 | pcmcia_get_tuple_data(link, &tuple); | 300 | pcmcia_get_tuple_data(link, &tuple); |
300 | for (i = 0; i < 3; i++) | 301 | for (i = 0; i < 3; i++) |
301 | phys_addr[i] = htons(buf[i]); | 302 | phys_addr[i] = htons(le16_to_cpu(buf[i])); |
302 | } else { | 303 | } else { |
303 | for (i = 0; i < 3; i++) | 304 | for (i = 0; i < 3; i++) |
304 | phys_addr[i] = htons(read_eeprom(ioaddr, i)); | 305 | phys_addr[i] = htons(read_eeprom(ioaddr, i)); |
305 | if (phys_addr[0] == 0x6060) { | 306 | if (phys_addr[0] == htons(0x6060)) { |
306 | printk(KERN_ERR "3c589_cs: IO port conflict at 0x%03lx" | 307 | printk(KERN_ERR "3c589_cs: IO port conflict at 0x%03lx" |
307 | "-0x%03lx\n", dev->base_addr, dev->base_addr+15); | 308 | "-0x%03lx\n", dev->base_addr, dev->base_addr+15); |
308 | goto failed; | 309 | goto failed; |