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>
This commit is contained in:
Al Viro 2007-12-22 18:56:13 +00:00 committed by Jeff Garzik
parent cf96237837
commit b1e247ad8e
2 changed files with 10 additions and 9 deletions

View file

@ -337,15 +337,15 @@ static int tc574_config(struct pcmcia_device *link)
struct net_device *dev = link->priv; struct net_device *dev = link->priv;
struct el3_private *lp = netdev_priv(dev); struct el3_private *lp = netdev_priv(dev);
tuple_t tuple; tuple_t tuple;
unsigned short buf[32]; __le16 buf[32];
int last_fn, last_ret, i, j; int last_fn, last_ret, i, j;
kio_addr_t ioaddr; kio_addr_t ioaddr;
u16 *phys_addr; __be16 *phys_addr;
char *cardname; char *cardname;
union wn3_config config; union wn3_config config;
DECLARE_MAC_BUF(mac); DECLARE_MAC_BUF(mac);
phys_addr = (u16 *)dev->dev_addr; phys_addr = (__be16 *)dev->dev_addr;
DEBUG(0, "3c574_config(0x%p)\n", link); DEBUG(0, "3c574_config(0x%p)\n", link);
@ -378,12 +378,12 @@ static int tc574_config(struct pcmcia_device *link)
if (pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS) { if (pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS) {
pcmcia_get_tuple_data(link, &tuple); pcmcia_get_tuple_data(link, &tuple);
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
phys_addr[i] = htons(buf[i]); phys_addr[i] = htons(le16_to_cpu(buf[i]));
} else { } else {
EL3WINDOW(0); EL3WINDOW(0);
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
phys_addr[i] = htons(read_eeprom(ioaddr, i + 10)); phys_addr[i] = htons(read_eeprom(ioaddr, i + 10));
if (phys_addr[0] == 0x6060) { if (phys_addr[0] == htons(0x6060)) {
printk(KERN_NOTICE "3c574_cs: IO port conflict at 0x%03lx" printk(KERN_NOTICE "3c574_cs: IO port conflict at 0x%03lx"
"-0x%03lx\n", dev->base_addr, dev->base_addr+15); "-0x%03lx\n", dev->base_addr, dev->base_addr+15);
goto failed; goto failed;

View file

@ -251,7 +251,8 @@ static int tc589_config(struct pcmcia_device *link)
struct net_device *dev = link->priv; struct net_device *dev = link->priv;
struct el3_private *lp = netdev_priv(dev); struct el3_private *lp = netdev_priv(dev);
tuple_t tuple; tuple_t tuple;
u16 buf[32], *phys_addr; __le16 buf[32];
__be16 *phys_addr;
int last_fn, last_ret, i, j, multi = 0, fifo; int last_fn, last_ret, i, j, multi = 0, fifo;
kio_addr_t ioaddr; kio_addr_t ioaddr;
char *ram_split[] = {"5:3", "3:1", "1:1", "3:5"}; char *ram_split[] = {"5:3", "3:1", "1:1", "3:5"};
@ -259,7 +260,7 @@ static int tc589_config(struct pcmcia_device *link)
DEBUG(0, "3c589_config(0x%p)\n", link); DEBUG(0, "3c589_config(0x%p)\n", link);
phys_addr = (u16 *)dev->dev_addr; phys_addr = (__be16 *)dev->dev_addr;
tuple.Attributes = 0; tuple.Attributes = 0;
tuple.TupleData = (cisdata_t *)buf; tuple.TupleData = (cisdata_t *)buf;
tuple.TupleDataMax = sizeof(buf); tuple.TupleDataMax = sizeof(buf);
@ -298,11 +299,11 @@ static int tc589_config(struct pcmcia_device *link)
if (pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS) { if (pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS) {
pcmcia_get_tuple_data(link, &tuple); pcmcia_get_tuple_data(link, &tuple);
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
phys_addr[i] = htons(buf[i]); phys_addr[i] = htons(le16_to_cpu(buf[i]));
} else { } else {
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
phys_addr[i] = htons(read_eeprom(ioaddr, i)); phys_addr[i] = htons(read_eeprom(ioaddr, i));
if (phys_addr[0] == 0x6060) { if (phys_addr[0] == htons(0x6060)) {
printk(KERN_ERR "3c589_cs: IO port conflict at 0x%03lx" printk(KERN_ERR "3c589_cs: IO port conflict at 0x%03lx"
"-0x%03lx\n", dev->base_addr, dev->base_addr+15); "-0x%03lx\n", dev->base_addr, dev->base_addr+15);
goto failed; goto failed;