提交 561b4fbf 编写于 作者: A Al Viro 提交者: Jeff Garzik

de4x5 fixes

* (trivial) endianness annotations
* don't bother with del_timer() from the inside of timer handler itself
* disable_ast() really ought to do del_timer_sync(), not del_timer()
* clean the timer handling in general.
Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
Signed-off-by: NJeff Garzik <jeff@garzik.org>
上级 6f35d5d5
...@@ -911,7 +911,7 @@ static int de4x5_init(struct net_device *dev); ...@@ -911,7 +911,7 @@ static int de4x5_init(struct net_device *dev);
static int de4x5_sw_reset(struct net_device *dev); static int de4x5_sw_reset(struct net_device *dev);
static int de4x5_rx(struct net_device *dev); static int de4x5_rx(struct net_device *dev);
static int de4x5_tx(struct net_device *dev); static int de4x5_tx(struct net_device *dev);
static int de4x5_ast(struct net_device *dev); static void de4x5_ast(struct net_device *dev);
static int de4x5_txur(struct net_device *dev); static int de4x5_txur(struct net_device *dev);
static int de4x5_rx_ovfc(struct net_device *dev); static int de4x5_rx_ovfc(struct net_device *dev);
...@@ -984,11 +984,9 @@ static int test_bad_enet(struct net_device *dev, int status); ...@@ -984,11 +984,9 @@ static int test_bad_enet(struct net_device *dev, int status);
static int an_exception(struct de4x5_private *lp); static int an_exception(struct de4x5_private *lp);
static char *build_setup_frame(struct net_device *dev, int mode); static char *build_setup_frame(struct net_device *dev, int mode);
static void disable_ast(struct net_device *dev); static void disable_ast(struct net_device *dev);
static void enable_ast(struct net_device *dev, u32 time_out);
static long de4x5_switch_mac_port(struct net_device *dev); static long de4x5_switch_mac_port(struct net_device *dev);
static int gep_rd(struct net_device *dev); static int gep_rd(struct net_device *dev);
static void gep_wr(s32 data, struct net_device *dev); static void gep_wr(s32 data, struct net_device *dev);
static void timeout(struct net_device *dev, void (*fn)(u_long data), u_long data, u_long msec);
static void yawn(struct net_device *dev, int state); static void yawn(struct net_device *dev, int state);
static void de4x5_parse_params(struct net_device *dev); static void de4x5_parse_params(struct net_device *dev);
static void de4x5_dbg_open(struct net_device *dev); static void de4x5_dbg_open(struct net_device *dev);
...@@ -1139,6 +1137,8 @@ de4x5_hw_init(struct net_device *dev, u_long iobase, struct device *gendev) ...@@ -1139,6 +1137,8 @@ de4x5_hw_init(struct net_device *dev, u_long iobase, struct device *gendev)
lp->gendev = gendev; lp->gendev = gendev;
spin_lock_init(&lp->lock); spin_lock_init(&lp->lock);
init_timer(&lp->timer); init_timer(&lp->timer);
lp->timer.function = (void (*)(unsigned long))de4x5_ast;
lp->timer.data = (unsigned long)dev;
de4x5_parse_params(dev); de4x5_parse_params(dev);
/* /*
...@@ -1311,7 +1311,7 @@ de4x5_open(struct net_device *dev) ...@@ -1311,7 +1311,7 @@ de4x5_open(struct net_device *dev)
lp->state = OPEN; lp->state = OPEN;
de4x5_dbg_open(dev); de4x5_dbg_open(dev);
if (request_irq(dev->irq, (void *)de4x5_interrupt, IRQF_SHARED, if (request_irq(dev->irq, de4x5_interrupt, IRQF_SHARED,
lp->adapter_name, dev)) { lp->adapter_name, dev)) {
printk("de4x5_open(): Requested IRQ%d is busy - attemping FAST/SHARE...", dev->irq); printk("de4x5_open(): Requested IRQ%d is busy - attemping FAST/SHARE...", dev->irq);
if (request_irq(dev->irq, de4x5_interrupt, IRQF_DISABLED | IRQF_SHARED, if (request_irq(dev->irq, de4x5_interrupt, IRQF_DISABLED | IRQF_SHARED,
...@@ -1737,27 +1737,29 @@ de4x5_tx(struct net_device *dev) ...@@ -1737,27 +1737,29 @@ de4x5_tx(struct net_device *dev)
return 0; return 0;
} }
static int static void
de4x5_ast(struct net_device *dev) de4x5_ast(struct net_device *dev)
{ {
struct de4x5_private *lp = netdev_priv(dev); struct de4x5_private *lp = netdev_priv(dev);
int next_tick = DE4X5_AUTOSENSE_MS; int next_tick = DE4X5_AUTOSENSE_MS;
int dt;
disable_ast(dev); if (lp->useSROM)
next_tick = srom_autoconf(dev);
else if (lp->chipset == DC21140)
next_tick = dc21140m_autoconf(dev);
else if (lp->chipset == DC21041)
next_tick = dc21041_autoconf(dev);
else if (lp->chipset == DC21040)
next_tick = dc21040_autoconf(dev);
lp->linkOK = 0;
if (lp->useSROM) { dt = (next_tick * HZ) / 1000;
next_tick = srom_autoconf(dev);
} else if (lp->chipset == DC21140) {
next_tick = dc21140m_autoconf(dev);
} else if (lp->chipset == DC21041) {
next_tick = dc21041_autoconf(dev);
} else if (lp->chipset == DC21040) {
next_tick = dc21040_autoconf(dev);
}
lp->linkOK = 0;
enable_ast(dev, next_tick);
return 0; if (!dt)
dt = 1;
mod_timer(&lp->timer, jiffies + dt);
} }
static int static int
...@@ -2174,7 +2176,7 @@ srom_search(struct net_device *dev, struct pci_dev *pdev) ...@@ -2174,7 +2176,7 @@ srom_search(struct net_device *dev, struct pci_dev *pdev)
for (j=0, i=0; i<ETH_ALEN; i++) { for (j=0, i=0; i<ETH_ALEN; i++) {
j += (u_char) *((u_char *)&lp->srom + SROM_HWADD + i); j += (u_char) *((u_char *)&lp->srom + SROM_HWADD + i);
} }
if ((j != 0) && (j != 0x5fa)) { if (j != 0 && j != 6 * 0xff) {
last.chipset = device; last.chipset = device;
last.bus = pb; last.bus = pb;
last.irq = irq; last.irq = irq;
...@@ -2371,30 +2373,19 @@ static struct pci_driver de4x5_pci_driver = { ...@@ -2371,30 +2373,19 @@ static struct pci_driver de4x5_pci_driver = {
static int static int
autoconf_media(struct net_device *dev) autoconf_media(struct net_device *dev)
{ {
struct de4x5_private *lp = netdev_priv(dev); struct de4x5_private *lp = netdev_priv(dev);
u_long iobase = dev->base_addr; u_long iobase = dev->base_addr;
int next_tick = DE4X5_AUTOSENSE_MS;
lp->linkOK = 0; disable_ast(dev);
lp->c_media = AUTO; /* Bogus last media */
disable_ast(dev);
inl(DE4X5_MFC); /* Zero the lost frames counter */
lp->media = INIT;
lp->tcount = 0;
if (lp->useSROM) { lp->c_media = AUTO; /* Bogus last media */
next_tick = srom_autoconf(dev); inl(DE4X5_MFC); /* Zero the lost frames counter */
} else if (lp->chipset == DC21040) { lp->media = INIT;
next_tick = dc21040_autoconf(dev); lp->tcount = 0;
} else if (lp->chipset == DC21041) {
next_tick = dc21041_autoconf(dev);
} else if (lp->chipset == DC21140) {
next_tick = dc21140m_autoconf(dev);
}
enable_ast(dev, next_tick); de4x5_ast(dev);
return (lp->media); return lp->media;
} }
/* /*
...@@ -4018,20 +4009,22 @@ DevicePresent(struct net_device *dev, u_long aprom_addr) ...@@ -4018,20 +4009,22 @@ DevicePresent(struct net_device *dev, u_long aprom_addr)
outl(0, aprom_addr); /* Reset Ethernet Address ROM Pointer */ outl(0, aprom_addr); /* Reset Ethernet Address ROM Pointer */
} }
} else { /* Read new srom */ } else { /* Read new srom */
u_short tmp, *p = (short *)((char *)&lp->srom + SROM_HWADD); u_short tmp;
__le16 *p = (__le16 *)((char *)&lp->srom + SROM_HWADD);
for (i=0; i<(ETH_ALEN>>1); i++) { for (i=0; i<(ETH_ALEN>>1); i++) {
tmp = srom_rd(aprom_addr, (SROM_HWADD>>1) + i); tmp = srom_rd(aprom_addr, (SROM_HWADD>>1) + i);
*p = le16_to_cpu(tmp); j += tmp; /* for check for 0:0:0:0:0:0 or ff:ff:ff:ff:ff:ff */
j += *p++; *p = cpu_to_le16(tmp);
} }
if ((j == 0) || (j == 0x2fffd)) { if (j == 0 || j == 3 * 0xffff) {
return; /* could get 0 only from all-0 and 3 * 0xffff only from all-1 */
return;
} }
p=(short *)&lp->srom; p = (__le16 *)&lp->srom;
for (i=0; i<(sizeof(struct de4x5_srom)>>1); i++) { for (i=0; i<(sizeof(struct de4x5_srom)>>1); i++) {
tmp = srom_rd(aprom_addr, i); tmp = srom_rd(aprom_addr, i);
*p++ = le16_to_cpu(tmp); *p++ = cpu_to_le16(tmp);
} }
de4x5_dbg_srom((struct de4x5_srom *)&lp->srom); de4x5_dbg_srom((struct de4x5_srom *)&lp->srom);
} }
...@@ -5160,22 +5153,11 @@ build_setup_frame(struct net_device *dev, int mode) ...@@ -5160,22 +5153,11 @@ build_setup_frame(struct net_device *dev, int mode)
return pa; /* Points to the next entry */ return pa; /* Points to the next entry */
} }
static void
enable_ast(struct net_device *dev, u32 time_out)
{
timeout(dev, (void *)&de4x5_ast, (u_long)dev, time_out);
return;
}
static void static void
disable_ast(struct net_device *dev) disable_ast(struct net_device *dev)
{ {
struct de4x5_private *lp = netdev_priv(dev); struct de4x5_private *lp = netdev_priv(dev);
del_timer_sync(&lp->timer);
del_timer(&lp->timer);
return;
} }
static long static long
...@@ -5244,29 +5226,6 @@ gep_rd(struct net_device *dev) ...@@ -5244,29 +5226,6 @@ gep_rd(struct net_device *dev)
return 0; return 0;
} }
static void
timeout(struct net_device *dev, void (*fn)(u_long data), u_long data, u_long msec)
{
struct de4x5_private *lp = netdev_priv(dev);
int dt;
/* First, cancel any pending timer events */
del_timer(&lp->timer);
/* Convert msec to ticks */
dt = (msec * HZ) / 1000;
if (dt==0) dt=1;
/* Set up timer */
init_timer(&lp->timer);
lp->timer.expires = jiffies + dt;
lp->timer.function = fn;
lp->timer.data = data;
add_timer(&lp->timer);
return;
}
static void static void
yawn(struct net_device *dev, int state) yawn(struct net_device *dev, int state)
{ {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册