aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/tulip/de4x5.c
diff options
context:
space:
mode:
authorAl Viro <viro@ftp.linux.org.uk>2007-12-23 15:01:04 -0500
committerJeff Garzik <jeff@garzik.org>2008-01-12 17:33:03 -0500
commit561b4fbf181926ab76e18a857593476ee76408f8 (patch)
treed7fa33dc412d625e93fc9e383bf3a0522e2de733 /drivers/net/tulip/de4x5.c
parent6f35d5d51619a1aa463180154c2d3c18a63e3950 (diff)
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: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net/tulip/de4x5.c')
-rw-r--r--drivers/net/tulip/de4x5.c127
1 files changed, 43 insertions, 84 deletions
diff --git a/drivers/net/tulip/de4x5.c b/drivers/net/tulip/de4x5.c
index 41f34bb91cad..6e8b18a3b3cc 100644
--- a/drivers/net/tulip/de4x5.c
+++ b/drivers/net/tulip/de4x5.c
@@ -911,7 +911,7 @@ static int de4x5_init(struct net_device *dev);
911static int de4x5_sw_reset(struct net_device *dev); 911static int de4x5_sw_reset(struct net_device *dev);
912static int de4x5_rx(struct net_device *dev); 912static int de4x5_rx(struct net_device *dev);
913static int de4x5_tx(struct net_device *dev); 913static int de4x5_tx(struct net_device *dev);
914static int de4x5_ast(struct net_device *dev); 914static void de4x5_ast(struct net_device *dev);
915static int de4x5_txur(struct net_device *dev); 915static int de4x5_txur(struct net_device *dev);
916static int de4x5_rx_ovfc(struct net_device *dev); 916static int de4x5_rx_ovfc(struct net_device *dev);
917 917
@@ -984,11 +984,9 @@ static int test_bad_enet(struct net_device *dev, int status);
984static int an_exception(struct de4x5_private *lp); 984static int an_exception(struct de4x5_private *lp);
985static char *build_setup_frame(struct net_device *dev, int mode); 985static char *build_setup_frame(struct net_device *dev, int mode);
986static void disable_ast(struct net_device *dev); 986static void disable_ast(struct net_device *dev);
987static void enable_ast(struct net_device *dev, u32 time_out);
988static long de4x5_switch_mac_port(struct net_device *dev); 987static long de4x5_switch_mac_port(struct net_device *dev);
989static int gep_rd(struct net_device *dev); 988static int gep_rd(struct net_device *dev);
990static void gep_wr(s32 data, struct net_device *dev); 989static void gep_wr(s32 data, struct net_device *dev);
991static void timeout(struct net_device *dev, void (*fn)(u_long data), u_long data, u_long msec);
992static void yawn(struct net_device *dev, int state); 990static void yawn(struct net_device *dev, int state);
993static void de4x5_parse_params(struct net_device *dev); 991static void de4x5_parse_params(struct net_device *dev);
994static void de4x5_dbg_open(struct net_device *dev); 992static 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 lp->gendev = gendev; 1137 lp->gendev = gendev;
1140 spin_lock_init(&lp->lock); 1138 spin_lock_init(&lp->lock);
1141 init_timer(&lp->timer); 1139 init_timer(&lp->timer);
1140 lp->timer.function = (void (*)(unsigned long))de4x5_ast;
1141 lp->timer.data = (unsigned long)dev;
1142 de4x5_parse_params(dev); 1142 de4x5_parse_params(dev);
1143 1143
1144 /* 1144 /*
@@ -1311,7 +1311,7 @@ de4x5_open(struct net_device *dev)
1311 lp->state = OPEN; 1311 lp->state = OPEN;
1312 de4x5_dbg_open(dev); 1312 de4x5_dbg_open(dev);
1313 1313
1314 if (request_irq(dev->irq, (void *)de4x5_interrupt, IRQF_SHARED, 1314 if (request_irq(dev->irq, de4x5_interrupt, IRQF_SHARED,
1315 lp->adapter_name, dev)) { 1315 lp->adapter_name, dev)) {
1316 printk("de4x5_open(): Requested IRQ%d is busy - attemping FAST/SHARE...", dev->irq); 1316 printk("de4x5_open(): Requested IRQ%d is busy - attemping FAST/SHARE...", dev->irq);
1317 if (request_irq(dev->irq, de4x5_interrupt, IRQF_DISABLED | IRQF_SHARED, 1317 if (request_irq(dev->irq, de4x5_interrupt, IRQF_DISABLED | IRQF_SHARED,
@@ -1737,27 +1737,29 @@ de4x5_tx(struct net_device *dev)
1737 return 0; 1737 return 0;
1738} 1738}
1739 1739
1740static int 1740static void
1741de4x5_ast(struct net_device *dev) 1741de4x5_ast(struct net_device *dev)
1742{ 1742{
1743 struct de4x5_private *lp = netdev_priv(dev); 1743 struct de4x5_private *lp = netdev_priv(dev);
1744 int next_tick = DE4X5_AUTOSENSE_MS; 1744 int next_tick = DE4X5_AUTOSENSE_MS;
1745 int dt;
1745 1746
1746 disable_ast(dev); 1747 if (lp->useSROM)
1748 next_tick = srom_autoconf(dev);
1749 else if (lp->chipset == DC21140)
1750 next_tick = dc21140m_autoconf(dev);
1751 else if (lp->chipset == DC21041)
1752 next_tick = dc21041_autoconf(dev);
1753 else if (lp->chipset == DC21040)
1754 next_tick = dc21040_autoconf(dev);
1755 lp->linkOK = 0;
1747 1756
1748 if (lp->useSROM) { 1757 dt = (next_tick * HZ) / 1000;
1749 next_tick = srom_autoconf(dev);
1750 } else if (lp->chipset == DC21140) {
1751 next_tick = dc21140m_autoconf(dev);
1752 } else if (lp->chipset == DC21041) {
1753 next_tick = dc21041_autoconf(dev);
1754 } else if (lp->chipset == DC21040) {
1755 next_tick = dc21040_autoconf(dev);
1756 }
1757 lp->linkOK = 0;
1758 enable_ast(dev, next_tick);
1759 1758
1760 return 0; 1759 if (!dt)
1760 dt = 1;
1761
1762 mod_timer(&lp->timer, jiffies + dt);
1761} 1763}
1762 1764
1763static int 1765static int
@@ -2174,7 +2176,7 @@ srom_search(struct net_device *dev, struct pci_dev *pdev)
2174 for (j=0, i=0; i<ETH_ALEN; i++) { 2176 for (j=0, i=0; i<ETH_ALEN; i++) {
2175 j += (u_char) *((u_char *)&lp->srom + SROM_HWADD + i); 2177 j += (u_char) *((u_char *)&lp->srom + SROM_HWADD + i);
2176 } 2178 }
2177 if ((j != 0) && (j != 0x5fa)) { 2179 if (j != 0 && j != 6 * 0xff) {
2178 last.chipset = device; 2180 last.chipset = device;
2179 last.bus = pb; 2181 last.bus = pb;
2180 last.irq = irq; 2182 last.irq = irq;
@@ -2371,30 +2373,19 @@ static struct pci_driver de4x5_pci_driver = {
2371static int 2373static int
2372autoconf_media(struct net_device *dev) 2374autoconf_media(struct net_device *dev)
2373{ 2375{
2374 struct de4x5_private *lp = netdev_priv(dev); 2376 struct de4x5_private *lp = netdev_priv(dev);
2375 u_long iobase = dev->base_addr; 2377 u_long iobase = dev->base_addr;
2376 int next_tick = DE4X5_AUTOSENSE_MS;
2377 2378
2378 lp->linkOK = 0; 2379 disable_ast(dev);
2379 lp->c_media = AUTO; /* Bogus last media */
2380 disable_ast(dev);
2381 inl(DE4X5_MFC); /* Zero the lost frames counter */
2382 lp->media = INIT;
2383 lp->tcount = 0;
2384 2380
2385 if (lp->useSROM) { 2381 lp->c_media = AUTO; /* Bogus last media */
2386 next_tick = srom_autoconf(dev); 2382 inl(DE4X5_MFC); /* Zero the lost frames counter */
2387 } else if (lp->chipset == DC21040) { 2383 lp->media = INIT;
2388 next_tick = dc21040_autoconf(dev); 2384 lp->tcount = 0;
2389 } else if (lp->chipset == DC21041) {
2390 next_tick = dc21041_autoconf(dev);
2391 } else if (lp->chipset == DC21140) {
2392 next_tick = dc21140m_autoconf(dev);
2393 }
2394 2385
2395 enable_ast(dev, next_tick); 2386 de4x5_ast(dev);
2396 2387
2397 return (lp->media); 2388 return lp->media;
2398} 2389}
2399 2390
2400/* 2391/*
@@ -4018,20 +4009,22 @@ DevicePresent(struct net_device *dev, u_long aprom_addr)
4018 outl(0, aprom_addr); /* Reset Ethernet Address ROM Pointer */ 4009 outl(0, aprom_addr); /* Reset Ethernet Address ROM Pointer */
4019 } 4010 }
4020 } else { /* Read new srom */ 4011 } else { /* Read new srom */
4021 u_short tmp, *p = (short *)((char *)&lp->srom + SROM_HWADD); 4012 u_short tmp;
4013 __le16 *p = (__le16 *)((char *)&lp->srom + SROM_HWADD);
4022 for (i=0; i<(ETH_ALEN>>1); i++) { 4014 for (i=0; i<(ETH_ALEN>>1); i++) {
4023 tmp = srom_rd(aprom_addr, (SROM_HWADD>>1) + i); 4015 tmp = srom_rd(aprom_addr, (SROM_HWADD>>1) + i);
4024 *p = le16_to_cpu(tmp); 4016 j += tmp; /* for check for 0:0:0:0:0:0 or ff:ff:ff:ff:ff:ff */
4025 j += *p++; 4017 *p = cpu_to_le16(tmp);
4026 } 4018 }
4027 if ((j == 0) || (j == 0x2fffd)) { 4019 if (j == 0 || j == 3 * 0xffff) {
4028 return; 4020 /* could get 0 only from all-0 and 3 * 0xffff only from all-1 */
4021 return;
4029 } 4022 }
4030 4023
4031 p=(short *)&lp->srom; 4024 p = (__le16 *)&lp->srom;
4032 for (i=0; i<(sizeof(struct de4x5_srom)>>1); i++) { 4025 for (i=0; i<(sizeof(struct de4x5_srom)>>1); i++) {
4033 tmp = srom_rd(aprom_addr, i); 4026 tmp = srom_rd(aprom_addr, i);
4034 *p++ = le16_to_cpu(tmp); 4027 *p++ = cpu_to_le16(tmp);
4035 } 4028 }
4036 de4x5_dbg_srom((struct de4x5_srom *)&lp->srom); 4029 de4x5_dbg_srom((struct de4x5_srom *)&lp->srom);
4037 } 4030 }
@@ -5161,21 +5154,10 @@ build_setup_frame(struct net_device *dev, int mode)
5161} 5154}
5162 5155
5163static void 5156static void
5164enable_ast(struct net_device *dev, u32 time_out)
5165{
5166 timeout(dev, (void *)&de4x5_ast, (u_long)dev, time_out);
5167
5168 return;
5169}
5170
5171static void
5172disable_ast(struct net_device *dev) 5157disable_ast(struct net_device *dev)
5173{ 5158{
5174 struct de4x5_private *lp = netdev_priv(dev); 5159 struct de4x5_private *lp = netdev_priv(dev);
5175 5160 del_timer_sync(&lp->timer);
5176 del_timer(&lp->timer);
5177
5178 return;
5179} 5161}
5180 5162
5181static long 5163static long
@@ -5245,29 +5227,6 @@ gep_rd(struct net_device *dev)
5245} 5227}
5246 5228
5247static void 5229static void
5248timeout(struct net_device *dev, void (*fn)(u_long data), u_long data, u_long msec)
5249{
5250 struct de4x5_private *lp = netdev_priv(dev);
5251 int dt;
5252
5253 /* First, cancel any pending timer events */
5254 del_timer(&lp->timer);
5255
5256 /* Convert msec to ticks */
5257 dt = (msec * HZ) / 1000;
5258 if (dt==0) dt=1;
5259
5260 /* Set up timer */
5261 init_timer(&lp->timer);
5262 lp->timer.expires = jiffies + dt;
5263 lp->timer.function = fn;
5264 lp->timer.data = data;
5265 add_timer(&lp->timer);
5266
5267 return;
5268}
5269
5270static void
5271yawn(struct net_device *dev, int state) 5230yawn(struct net_device *dev, int state)
5272{ 5231{
5273 struct de4x5_private *lp = netdev_priv(dev); 5232 struct de4x5_private *lp = netdev_priv(dev);