diff options
author | Ralf Baechle <ralf@linux-mips.org> | 2001-01-31 22:22:27 +0000 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2001-01-31 22:22:27 +0000 |
commit | 825423e4c4f18289df2393951cfd2a7a31fc0464 (patch) | |
tree | 4ad80e981c3d9effa910d2247d118d254f9a5d09 /drivers/net | |
parent | c4693dc4856ab907a5c02187a8d398861bebfc7e (diff) |
Merge with Linux 2.4.1.
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/3c59x.c | 108 | ||||
-rw-r--r-- | drivers/net/Makefile | 2 | ||||
-rw-r--r-- | drivers/net/depca.c | 4 | ||||
-rw-r--r-- | drivers/net/dmfe.c | 4 | ||||
-rw-r--r-- | drivers/net/eepro100.c | 15 | ||||
-rw-r--r-- | drivers/net/hamradio/mkiss.c | 2 | ||||
-rw-r--r-- | drivers/net/hamradio/scc.c | 4 | ||||
-rw-r--r-- | drivers/net/myri_sbus.c | 10 | ||||
-rw-r--r-- | drivers/net/pcnet32.c | 2 | ||||
-rw-r--r-- | drivers/net/ppp_async.c | 89 | ||||
-rw-r--r-- | drivers/net/pppoe.c | 40 | ||||
-rw-r--r-- | drivers/net/sunbmac.c | 61 | ||||
-rw-r--r-- | drivers/net/tulip/ChangeLog | 36 | ||||
-rw-r--r-- | drivers/net/tulip/eeprom.c | 12 | ||||
-rw-r--r-- | drivers/net/tulip/media.c | 6 | ||||
-rw-r--r-- | drivers/net/tulip/tulip_core.c | 2 | ||||
-rw-r--r-- | drivers/net/wan/lapbether.c | 172 | ||||
-rw-r--r-- | drivers/net/wan/lmc/lmc.h | 3 | ||||
-rw-r--r-- | drivers/net/wan/lmc/lmc_media.h | 3 | ||||
-rw-r--r-- | drivers/net/wan/lmc/lmc_prot.h | 3 | ||||
-rw-r--r-- | drivers/net/wan/lmc/lmc_proto.h | 3 | ||||
-rw-r--r-- | drivers/net/wan/sdla.c | 2 |
22 files changed, 308 insertions, 275 deletions
diff --git a/drivers/net/3c59x.c b/drivers/net/3c59x.c index ae4054d35..02c9204e9 100644 --- a/drivers/net/3c59x.c +++ b/drivers/net/3c59x.c @@ -118,6 +118,14 @@ LK1.1.11 13 Nov 2000 andrewm - Dump MOD_INC/DEC_USE_COUNT, use SET_MODULE_OWNER + LK1.1.12 1 Jan 2001 andrewm + - Call pci_enable_device before we request our IRQ (Tobias Ringstrom) + - Add 3c590 PCI latency timer hack to vortex_probe1 (from 0.99Ra) + - Added extended wait_for_completion for the 3c905CX. + - Look for an MII on PHY index 24 first (3c905CX oddity). + - Add HAS_NWAY to 3cSOHO100-TX (Brett Frankenberger) + - Don't free skbs we don't own on oom path in vortex_open(). + - See http://www.uow.edu.au/~andrewm/linux/#3c59x-2.3 for more details. - Also see Documentation/networking/vortex.txt */ @@ -203,7 +211,7 @@ static int rx_nocopy = 0, rx_copy = 0, queued_packet = 0, rx_csumhits; #include <linux/delay.h> static char version[] __devinitdata = -"3c59x.c:LK1.1.11 13 Nov 2000 Donald Becker and others. http://www.scyld.com/network/vortex.html " "$Revision: 1.102.2.46 $\n"; +"3c59x.c:LK1.1.12 06 Jan 2000 Donald Becker and others. http://www.scyld.com/network/vortex.html " "$Revision: 1.102.2.46 $\n"; MODULE_AUTHOR("Donald Becker <becker@scyld.com>"); MODULE_DESCRIPTION("3Com 3c59x/3c90x/3c575 series Vortex/Boomerang/Cyclone driver"); @@ -424,7 +432,7 @@ static struct vortex_chip_info { PCI_USES_IO|PCI_USES_MASTER, IS_CYCLONE, 128, }, {"3cSOHO100-TX Hurricane", - PCI_USES_IO|PCI_USES_MASTER, IS_CYCLONE, 128, }, + PCI_USES_IO|PCI_USES_MASTER, IS_CYCLONE|HAS_NWAY, 128, }, {"3c555 Laptop Hurricane", PCI_USES_IO|PCI_USES_MASTER, IS_CYCLONE|EEPROM_8BIT, 128, }, {"3c556 Laptop Tornado", @@ -843,10 +851,15 @@ static int __devinit vortex_init_one (struct pci_dev *pdev, { int rc; - rc = vortex_probe1 (pdev, pci_resource_start (pdev, 0), pdev->irq, - ent->driver_data, vortex_cards_found); - if (rc == 0) - vortex_cards_found++; + /* wake up and enable device */ + if (pci_enable_device (pdev)) { + rc = -EIO; + } else { + rc = vortex_probe1 (pdev, pci_resource_start (pdev, 0), pdev->irq, + ent->driver_data, vortex_cards_found); + if (rc == 0) + vortex_cards_found++; + } return rc; } @@ -863,7 +876,7 @@ static int __devinit vortex_probe1(struct pci_dev *pdev, struct vortex_private *vp; int option; unsigned int eeprom[0x40], checksum = 0; /* EEPROM contents */ - int i; + int i, step; struct net_device *dev; static int printed_version; int retval; @@ -889,7 +902,6 @@ static int __devinit vortex_probe1(struct pci_dev *pdev, vci->name, ioaddr); - /* private struct aligned and zeroed by init_etherdev */ vp = dev->priv; dev->base_addr = ioaddr; dev->irq = irq; @@ -908,19 +920,29 @@ static int __devinit vortex_probe1(struct pci_dev *pdev, if (pdev) { /* EISA resources already marked, so only PCI needs to do this here */ /* Ignore return value, because Cardbus drivers already allocate for us */ - if (request_region(ioaddr, vci->io_size, dev->name) != NULL) { + if (request_region(ioaddr, vci->io_size, dev->name) != NULL) vp->must_free_region = 1; - } - - /* wake up and enable device */ - if (pci_enable_device (pdev)) { - retval = -EIO; - goto free_region; - } /* enable bus-mastering if necessary */ if (vci->flags & PCI_USES_MASTER) pci_set_master (pdev); + + if (vci->drv_flags & IS_VORTEX) { + u8 pci_latency; + u8 new_latency = 248; + + /* Check the PCI latency value. On the 3c590 series the latency timer + must be set to the maximum value to avoid data corruption that occurs + when the timer expires during a transfer. This bug exists the Vortex + chip only. */ + pci_read_config_byte(pdev, PCI_LATENCY_TIMER, &pci_latency); + if (pci_latency < new_latency) { + printk(KERN_INFO "%s: Overriding PCI latency" + " timer (CFLT) setting of %d, new value is %d.\n", + dev->name, pci_latency, new_latency); + pci_write_config_byte(pdev, PCI_LATENCY_TIMER, new_latency); + } + } } spin_lock_init(&vp->lock); @@ -1025,6 +1047,13 @@ static int __devinit vortex_probe1(struct pci_dev *pdev, dev->irq); #endif + EL3WINDOW(4); + step = (inb(ioaddr + Wn4_NetDiag) & 0x1e) >> 1; + printk(KERN_INFO " product code '%c%c' rev %02x.%d date %02d-" + "%02d-%02d\n", eeprom[6]&0xff, eeprom[6]>>8, eeprom[0x14], + step, (eeprom[4]>>5) & 15, eeprom[4] & 31, eeprom[4]>>9); + + if (pdev && vci->drv_flags & HAS_CB_FNS) { unsigned long fn_st_addr; /* Cardbus function status space */ unsigned short n; @@ -1089,8 +1118,19 @@ static int __devinit vortex_probe1(struct pci_dev *pdev, mii_preamble_required++; mii_preamble_required++; mdio_read(dev, 24, 1); - for (phy = 1; phy <= 32 && phy_idx < sizeof(vp->phys); phy++) { - int mii_status, phyx = phy & 0x1f; + for (phy = 0; phy < 32 && phy_idx < 1; phy++) { + int mii_status, phyx; + + /* + * For the 3c905CX we look at index 24 first, because it bogusly + * reports an external PHY at all indices + */ + if (phy == 0) + phyx = 24; + else if (phy <= 24) + phyx = phy - 1; + else + phyx = phy; mii_status = mdio_read(dev, phyx, 1); if (mii_status && mii_status != 0xffff) { vp->phys[phy_idx++] = phyx; @@ -1135,12 +1175,13 @@ static int __devinit vortex_probe1(struct pci_dev *pdev, dev->set_multicast_list = set_rx_mode; dev->tx_timeout = vortex_tx_timeout; dev->watchdog_timeo = (watchdog * HZ) / 1000; - +// publish_netdev(dev); return 0; free_region: if (vp->must_free_region) release_region(ioaddr, vci->io_size); +// withdraw_netdev(dev); unregister_netdev(dev); kfree (dev); printk(KERN_ERR PFX "vortex_probe1 fails. Returns %d\n", retval); @@ -1150,13 +1191,23 @@ out: static void wait_for_completion(struct net_device *dev, int cmd) { - int i = 4000; + int i; outw(cmd, dev->base_addr + EL3_CMD); - while (--i > 0) { + for (i = 0; i < 2000; i++) { if (!(inw(dev->base_addr + EL3_STATUS) & CmdInProgress)) return; } + + /* OK, that didn't work. Do it the slow way. One second */ + for (i = 0; i < 100000; i++) { + if (!(inw(dev->base_addr + EL3_STATUS) & CmdInProgress)) { + printk(KERN_INFO "%s: command 0x%04x took %d usecs! Please tell andrewm@uow.edu.au\n", + dev->name, cmd, i * 10); + return; + } + udelay(10); + } printk(KERN_ERR "%s: command 0x%04x did not complete! Status=0x%x\n", dev->name, cmd, inw(dev->base_addr + EL3_STATUS)); } @@ -1331,6 +1382,7 @@ vortex_up(struct net_device *dev) set_rx_mode(dev); outw(StatsEnable, ioaddr + EL3_CMD); /* Turn on statistics. */ +// wait_for_completion(dev, SetTxStart|0x07ff); outw(RxEnable, ioaddr + EL3_CMD); /* Enable the receiver. */ outw(TxEnable, ioaddr + EL3_CMD); /* Enable transmitter. */ /* Allow status bits to be seen. */ @@ -1384,7 +1436,8 @@ vortex_open(struct net_device *dev) } if (i != RX_RING_SIZE) { int j; - for (j = 0; j < RX_RING_SIZE; j++) { + printk(KERN_EMERG "%s: no memory for rx ring\n", dev->name); + for (j = 0; j < i; j++) { if (vp->rx_skbuff[j]) { dev_kfree_skb(vp->rx_skbuff[j]); vp->rx_skbuff[j] = 0; @@ -1532,7 +1585,10 @@ static void vortex_tx_timeout(struct net_device *dev) printk(KERN_ERR "%s: transmit timed out, tx_status %2.2x status %4.4x.\n", dev->name, inb(ioaddr + TxStatus), inw(ioaddr + EL3_STATUS)); - + EL3WINDOW(4); + printk(KERN_ERR " diagnostics: net %04x media %04x dma %8.8x.\n", + inw(ioaddr + Wn4_NetDiag), inw(ioaddr + Wn4_Media), + inl(ioaddr + PktStatus)); /* Slight code bloat to be user friendly. */ if ((inb(ioaddr + TxStatus) & 0x88) == 0x88) printk(KERN_ERR "%s: Transmitter encountered 16 collisions --" @@ -1663,6 +1719,12 @@ vortex_error(struct net_device *dev, int status) dev->name, fifo_diag); /* Adapter failure requires Tx/Rx reset and reinit. */ if (vp->full_bus_master_tx) { + int bus_status = inl(ioaddr + PktStatus); + /* 0x80000000 PCI master abort. */ + /* 0x40000000 PCI target abort. */ + if (vortex_debug) + printk(KERN_ERR "%s: PCI bus error, bus status %8.8x\n", dev->name, bus_status); + /* In this case, blow the card away */ vortex_down(dev); wait_for_completion(dev, TotalReset | 0xff); diff --git a/drivers/net/Makefile b/drivers/net/Makefile index 290efb51c..5f9658fa5 100644 --- a/drivers/net/Makefile +++ b/drivers/net/Makefile @@ -26,7 +26,7 @@ ifeq ($(CONFIG_ISDN_PPP),y) obj-$(CONFIG_ISDN) += slhc.o endif -subdir-$(CONFIG_PCMCIA) += pcmcia +subdir-$(CONFIG_NET_PCMCIA) += pcmcia subdir-$(CONFIG_TULIP) += tulip subdir-$(CONFIG_IRDA) += irda subdir-$(CONFIG_TR) += tokenring diff --git a/drivers/net/depca.c b/drivers/net/depca.c index 448baa800..d5d3fa19f 100644 --- a/drivers/net/depca.c +++ b/drivers/net/depca.c @@ -1817,7 +1817,9 @@ EISA_signature(char *name, s32 eisa_id) ManCode[5]='\0'; for (i=0;(*signatures[i] != '\0') && (*name == '\0');i++) { - if (strstr(ManCode, signatures[i]) != NULL) { + const char * volatile lhs = ManCode; + const char * volatile rhs = signatures[i]; /* egcs-1.1.2 bug */ + if (strstr(lhs, rhs) != NULL) { strcpy(name,ManCode); status = 1; } diff --git a/drivers/net/dmfe.c b/drivers/net/dmfe.c index 481b28700..b160afd78 100644 --- a/drivers/net/dmfe.c +++ b/drivers/net/dmfe.c @@ -1596,10 +1596,10 @@ static int __init dmfe_init_module(void) break; } - rc = pci_register_driver(&dmfe_driver); + rc = pci_module_init(&dmfe_driver); if (rc < 0) return rc; - if (rc > 0) { + if (rc >= 0) { printk (KERN_INFO "Davicom DM91xx net driver loaded, version " DMFE_VERSION "\n"); return 0; diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index 298a317e2..2970fac9f 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -29,7 +29,7 @@ static const char *version = "eepro100.c:v1.09j-t 9/29/99 Donald Becker http://cesdis.gsfc.nasa.gov/linux/drivers/eepro100.html\n" -"eepro100.c: $Revision: 1.35 $ 2000/11/17 Modified by Andrey V. Savochkin <saw@saw.sw.com.sg> and others\n"; +"eepro100.c: $Revision: 1.36 $ 2000/11/17 Modified by Andrey V. Savochkin <saw@saw.sw.com.sg> and others\n"; /* A few user-configurable values that apply to all boards. First set is undocumented and spelled per Intel recommendations. */ @@ -698,6 +698,7 @@ static int speedo_found1(struct pci_dev *pdev, This takes less than 10usec and will easily finish before the next action. */ outl(PortReset, ioaddr + SCBPort); + inl(ioaddr + SCBPort); udelay(10); if (eeprom[3] & 0x0100) @@ -785,6 +786,7 @@ static int speedo_found1(struct pci_dev *pdev, #endif /* kernel_bloat */ outl(PortReset, ioaddr + SCBPort); + inl(ioaddr + SCBPort); udelay(10); /* Return the chip to its original power state. */ @@ -801,7 +803,7 @@ static int speedo_found1(struct pci_dev *pdev, sp->tx_ring = tx_ring_space; sp->tx_ring_dma = tx_ring_dma; sp->lstats = (struct speedo_stats *)(sp->tx_ring + TX_RING_SIZE); - sp->lstats_dma = cpu_to_le32(TX_RING_ELEM_DMA(sp, TX_RING_SIZE)); + sp->lstats_dma = TX_RING_ELEM_DMA(sp, TX_RING_SIZE); init_timer(&sp->timer); /* used in ioctl() */ sp->full_duplex = option >= 0 && (option & 0x10) ? 1 : 0; @@ -1002,7 +1004,9 @@ static void speedo_resume(struct net_device *dev) /* Set the segment registers to '0'. */ wait_for_cmd_done(ioaddr + SCBCmd); outl(0, ioaddr + SCBPointer); - inl(ioaddr + SCBPointer); /* XXX */ + /* impose a delay to avoid a bug */ + inl(ioaddr + SCBPointer); + udelay(10); outb(RxAddrLoad, ioaddr + SCBCmd); wait_for_cmd_done(ioaddr + SCBCmd); outb(CUCmdBase, ioaddr + SCBCmd); @@ -1010,7 +1014,6 @@ static void speedo_resume(struct net_device *dev) /* Load the statistics block and rx ring addresses. */ wait_for_cmd_done(ioaddr + SCBCmd); outl(sp->lstats_dma, ioaddr + SCBPointer); - inl(ioaddr + SCBPointer); /* XXX */ outb(CUStatsAddr, ioaddr + SCBCmd); sp->lstats->done_marker = 0; @@ -1045,7 +1048,7 @@ static void speedo_resume(struct net_device *dev) /* Start the chip's Tx process and unmask interrupts. */ wait_for_cmd_done(ioaddr + SCBCmd); - outl(cpu_to_le32(TX_RING_ELEM_DMA(sp, sp->dirty_tx % TX_RING_SIZE)), + outl(TX_RING_ELEM_DMA(sp, sp->dirty_tx % TX_RING_SIZE), ioaddr + SCBPointer); /* We are not ACK-ing FCP and ER in the interrupt handler yet so they should remain masked --Dragan */ @@ -1274,7 +1277,7 @@ static void speedo_tx_timeout(struct net_device *dev) /* Only the command unit has stopped. */ printk(KERN_WARNING "%s: Trying to restart the transmitter...\n", dev->name); - outl(cpu_to_le32(TX_RING_ELEM_DMA(sp, dirty_tx % TX_RING_SIZE])), + outl(TX_RING_ELEM_DMA(sp, dirty_tx % TX_RING_SIZE]), ioaddr + SCBPointer); outw(CUStart, ioaddr + SCBCmd); reset_mii(dev); diff --git a/drivers/net/hamradio/mkiss.c b/drivers/net/hamradio/mkiss.c index 7dab437e6..3ec09be5a 100644 --- a/drivers/net/hamradio/mkiss.c +++ b/drivers/net/hamradio/mkiss.c @@ -153,7 +153,7 @@ static int check_crc_flex(unsigned char *cp, int size) /* Find a free channel, and link in this `tty' line. */ static inline struct ax_disp *ax_alloc(void) { - ax25_ctrl_t *axp; + ax25_ctrl_t *axp=NULL; int i; for (i = 0; i < ax25_maxdev; i++) { diff --git a/drivers/net/hamradio/scc.c b/drivers/net/hamradio/scc.c index d65fddc41..cc31e9e30 100644 --- a/drivers/net/hamradio/scc.c +++ b/drivers/net/hamradio/scc.c @@ -136,7 +136,7 @@ /* ----------------------------------------------------------------------- */ -#undef SCC_LDELAY 1 /* slow it even a bit more down */ +#undef SCC_LDELAY /* slow it even a bit more down */ #undef SCC_DONT_CHECK /* don't look if the SCCs you specified are available */ #define SCC_MAXCHIPS 4 /* number of max. supported chips */ @@ -1776,7 +1776,7 @@ static int scc_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) if (hwcfg.vector_latch) { if (!request_region(Vector_Latch, 1, "scc vector latch")) - printk(KERN_WARNING "z8530drv: warning, cannot reserve vector latch port 0x%x\n, disabled.", hwcfg.vector_latch); + printk(KERN_WARNING "z8530drv: warning, cannot reserve vector latch port 0x%x\n, disabled.", (unsigned int)hwcfg.vector_latch); else Vector_Latch = hwcfg.vector_latch; } diff --git a/drivers/net/myri_sbus.c b/drivers/net/myri_sbus.c index ba9c60250..56ca24689 100644 --- a/drivers/net/myri_sbus.c +++ b/drivers/net/myri_sbus.c @@ -892,6 +892,9 @@ static int __init myri_ether_init(struct net_device *dev, struct sbus_dev *sdev, DET(("myri_ether_init(%p,%p,%d):\n", dev, sdev, num)); dev = init_etherdev(0, sizeof(struct myri_eth)); + if (!dev) + return -ENOMEM; + if (version_printed++ == 0) printk(version); @@ -982,7 +985,7 @@ static int __init myri_ether_init(struct net_device *dev, struct sbus_dev *sdev, mp->reg_size, "MyriCOM Regs"); if (!mp->regs) { printk("MyriCOM: Cannot map MyriCOM registers.\n"); - return -ENODEV; + goto err; } mp->lanai = (unsigned short *) (mp->regs + (256 * 1024)); mp->lanai3 = (unsigned int *) mp->lanai; @@ -1059,7 +1062,7 @@ static int __init myri_ether_init(struct net_device *dev, struct sbus_dev *sdev, if (request_irq(dev->irq, &myri_interrupt, SA_SHIRQ, "MyriCOM Ethernet", (void *) dev)) { printk("MyriCOM: Cannot register interrupt handler.\n"); - return -ENODEV; + goto err; } DET(("ether_setup()\n")); @@ -1083,6 +1086,9 @@ static int __init myri_ether_init(struct net_device *dev, struct sbus_dev *sdev, root_myri_dev = mp; #endif return 0; +err: unregister_netdev(dev); + kfree(dev); + return -ENODEV; } static int __init myri_sbus_match(struct sbus_dev *sdev) diff --git a/drivers/net/pcnet32.c b/drivers/net/pcnet32.c index ccb92e8a5..fa8b951a7 100644 --- a/drivers/net/pcnet32.c +++ b/drivers/net/pcnet32.c @@ -695,6 +695,7 @@ pcnet32_probe1(unsigned long ioaddr, unsigned char irq_line, int shared, int car if (a == NULL) { printk(KERN_ERR "pcnet32: No access methods\n"); + pci_free_consistent(lp->pci_dev, sizeof(*lp), lp, lp->dma_addr); return -ENODEV; } lp->a = *a; @@ -741,6 +742,7 @@ pcnet32_probe1(unsigned long ioaddr, unsigned char irq_line, int shared, int car printk(", probed IRQ %d.\n", dev->irq); else { printk(", failed to detect IRQ line.\n"); + pci_free_consistent(lp->pci_dev, sizeof(*lp), lp, lp->dma_addr); return -ENODEV; } } diff --git a/drivers/net/ppp_async.c b/drivers/net/ppp_async.c index d6b2c47f3..c1234c5c8 100644 --- a/drivers/net/ppp_async.c +++ b/drivers/net/ppp_async.c @@ -33,13 +33,6 @@ #include <linux/init.h> #include <asm/uaccess.h> -#ifndef spin_trylock_bh -#define spin_trylock_bh(lock) ({ int __r; local_bh_disable(); \ - __r = spin_trylock(lock); \ - if (!__r) local_bh_enable(); \ - __r; }) -#endif - #define PPP_VERSION "2.4.1" #define OBUFSIZE 256 @@ -76,6 +69,7 @@ struct asyncppp { /* Bit numbers in xmit_flags */ #define XMIT_WAKEUP 0 #define XMIT_FULL 1 +#define XMIT_BUSY 2 /* State bits */ #define SC_TOSS 0x20000000 @@ -181,18 +175,14 @@ ppp_asynctty_close(struct tty_struct *tty) } /* - * Read does nothing. + * Read does nothing - no data is ever available this way. + * Pppd reads and writes packets via /dev/ppp instead. */ static ssize_t ppp_asynctty_read(struct tty_struct *tty, struct file *file, unsigned char *buf, size_t count) { - /* For now, do the same as the old 2.3.x code useta */ - struct asyncppp *ap = tty->disc_data; - - if (ap == 0) - return -ENXIO; - return ppp_channel_read(&ap->chan, file, buf, count); + return -EAGAIN; } /* @@ -203,12 +193,7 @@ static ssize_t ppp_asynctty_write(struct tty_struct *tty, struct file *file, const unsigned char *buf, size_t count) { - /* For now, do the same as the old 2.3.x code useta */ - struct asyncppp *ap = tty->disc_data; - - if (ap == 0) - return -ENXIO; - return ppp_channel_write(&ap->chan, buf, count); + return -EAGAIN; } static int @@ -259,25 +244,6 @@ ppp_asynctty_ioctl(struct tty_struct *tty, struct file *file, err = 0; break; -/* - * For now, do the same as the old 2.3 driver useta - */ - case PPPIOCGFLAGS: - case PPPIOCSFLAGS: - case PPPIOCGASYNCMAP: - case PPPIOCSASYNCMAP: - case PPPIOCGRASYNCMAP: - case PPPIOCSRASYNCMAP: - case PPPIOCGXASYNCMAP: - case PPPIOCSXASYNCMAP: - case PPPIOCGMRU: - case PPPIOCSMRU: - err = -EPERM; - if (!capable(CAP_NET_ADMIN)) - break; - err = ppp_async_ioctl(&ap->chan, cmd, arg); - break; - case PPPIOCATTACH: case PPPIOCDETACH: err = ppp_channel_ioctl(&ap->chan, cmd, arg); @@ -294,18 +260,7 @@ ppp_asynctty_ioctl(struct tty_struct *tty, struct file *file, static unsigned int ppp_asynctty_poll(struct tty_struct *tty, struct file *file, poll_table *wait) { - unsigned int mask; - struct asyncppp *ap = tty->disc_data; - - mask = POLLOUT | POLLWRNORM; -/* - * For now, do the same as the old 2.3 driver useta - */ - if (ap != 0) - mask |= ppp_channel_poll(&ap->chan, file, wait); - if (test_bit(TTY_OTHER_CLOSED, &tty->flags) || tty_hung_up_p(file)) - mask |= POLLHUP; - return mask; + return 0; } static int @@ -637,8 +592,18 @@ ppp_async_push(struct asyncppp *ap) int tty_stuffed = 0; set_bit(XMIT_WAKEUP, &ap->xmit_flags); - if (!spin_trylock_bh(&ap->xmit_lock)) + /* + * We can get called recursively here if the tty write + * function calls our wakeup function. This can happen + * for example on a pty with both the master and slave + * set to PPP line discipline. + * We use the XMIT_BUSY bit to detect this and get out, + * leaving the XMIT_WAKEUP bit set to tell the other + * instance that it may now be able to write more now. + */ + if (test_and_set_bit(XMIT_BUSY, &ap->xmit_flags)) return 0; + spin_lock_bh(&ap->xmit_lock); for (;;) { if (test_and_clear_bit(XMIT_WAKEUP, &ap->xmit_flags)) tty_stuffed = 0; @@ -653,7 +618,7 @@ ppp_async_push(struct asyncppp *ap) tty_stuffed = 1; continue; } - if (ap->optr == ap->olim && ap->tpkt != 0) { + if (ap->optr >= ap->olim && ap->tpkt != 0) { if (ppp_async_encode(ap)) { /* finished processing ap->tpkt */ clear_bit(XMIT_FULL, &ap->xmit_flags); @@ -661,17 +626,29 @@ ppp_async_push(struct asyncppp *ap) } continue; } - /* haven't made any progress */ - spin_unlock_bh(&ap->xmit_lock); + /* + * We haven't made any progress this time around. + * Clear XMIT_BUSY to let other callers in, but + * after doing so we have to check if anyone set + * XMIT_WAKEUP since we last checked it. If they + * did, we should try again to set XMIT_BUSY and go + * around again in case XMIT_BUSY was still set when + * the other caller tried. + */ + clear_bit(XMIT_BUSY, &ap->xmit_flags); + /* any more work to do? if not, exit the loop */ if (!(test_bit(XMIT_WAKEUP, &ap->xmit_flags) || (!tty_stuffed && ap->tpkt != 0))) break; - if (!spin_trylock_bh(&ap->xmit_lock)) + /* more work to do, see if we can do it now */ + if (test_and_set_bit(XMIT_BUSY, &ap->xmit_flags)) break; } + spin_unlock_bh(&ap->xmit_lock); return done; flush: + clear_bit(XMIT_BUSY, &ap->xmit_flags); if (ap->tpkt != 0) { kfree_skb(ap->tpkt); ap->tpkt = 0; diff --git a/drivers/net/pppoe.c b/drivers/net/pppoe.c index 8744f6186..7fffdf4f7 100644 --- a/drivers/net/pppoe.c +++ b/drivers/net/pppoe.c @@ -5,23 +5,24 @@ * PPPoE --- PPP over Ethernet (RFC 2516) * * - * Version: 0.6.4 + * Version: 0.6.5 * * 030700 : Fixed connect logic to allow for disconnect. - * 270700 : Fixed potential SMP problems; we must protect against - * simultaneous invocation of ppp_input + * 270700 : Fixed potential SMP problems; we must protect against + * simultaneous invocation of ppp_input * and ppp_unregister_channel. * 040800 : Respect reference count mechanisms on net-devices. * 200800 : fix kfree(skb) in pppoe_rcv (acme) * Module reference count is decremented in the right spot now, - * guards against sock_put not actually freeing the sk + * guards against sock_put not actually freeing the sk * in pppoe_release. * 051000 : Initialization cleanup. * 111100 : Fix recvmsg. + * 050101 : Fix PADT procesing. * * Author: Michal Ostrowski <mostrows@styx.uwaterloo.ca> * Contributors: - * Arnaldo Carvalho de Melo <acme@conectiva.com.br> + * Arnaldo Carvalho de Melo <acme@xconectiva.com.br> * * License: * This program is free software; you can redistribute it and/or @@ -110,7 +111,7 @@ static int hash_item(unsigned long sid, unsigned char *addr) hash ^= sid >> (i*PPPOE_HASH_BITS); return hash & ( PPPOE_HASH_SIZE - 1 ); -} +} static struct pppox_opt *item_hash_table[PPPOE_HASH_SIZE] = { 0, }; @@ -238,7 +239,7 @@ static int pppoe_device_event(struct notifier_block *this, struct net_device *dev = (struct net_device *) ptr; struct pppox_opt *po = NULL; int hash = 0; - + /* Only look at sockets that are using this specific device. */ switch (event) { case NETDEV_CHANGEMTU: @@ -255,13 +256,13 @@ static int pppoe_device_event(struct notifier_block *this, po = item_hash_table[hash]; ++hash; } - + while (po && hash < PPPOE_HASH_SIZE){ if(po->pppoe_dev == dev){ lock_sock(po->sk); if (po->sk->state & (PPPOX_CONNECTED|PPPOX_BOUND)){ pppox_unbind_sock(po->sk); - + dev_put(po->pppoe_dev); po->pppoe_dev = NULL; @@ -308,7 +309,7 @@ int pppoe_rcv_core(struct sock *sk, struct sk_buff *skb){ if (sk->state & PPPOX_BOUND) { skb_pull(skb, sizeof(struct pppoe_hdr)); - + ppp_input(&po->chan, skb); } else if( sk->state & PPPOX_RELAY ){ @@ -318,7 +319,7 @@ int pppoe_rcv_core(struct sock *sk, struct sk_buff *skb){ !( relay_po->sk->state & PPPOX_CONNECTED ) ){ goto abort; } - + skb_pull(skb, sizeof(struct pppoe_hdr)); if( !__pppoe_xmit( relay_po->sk , skb) ){ goto abort; @@ -369,7 +370,7 @@ static int pppoe_rcv(struct sk_buff *skb, }else{ ret = pppoe_rcv_core(sk, skb); } - + bh_unlock_sock(sk); sock_put(sk); return ret; @@ -412,13 +413,12 @@ static int pppoe_disc_rcv(struct sk_buff *skb, po = get_item((unsigned long) ph->sid, skb->mac.ethernet->h_source); if (!po) - goto abort_put; + goto abort; sk = po->sk; pppox_unbind_sock(sk); - abort_put: sock_put(sk); abort: kfree_skb(skb); @@ -466,9 +466,9 @@ static int pppoe_create(struct socket *sock) { int error = 0; struct sock *sk; - + MOD_INC_USE_COUNT; - + sk = sk_alloc(PF_PPPOX, GFP_KERNEL, 1); if (!sk) return -ENOMEM; @@ -528,7 +528,7 @@ int pppoe_release(struct socket *sock) po = sk->protinfo.pppox; if (po->pppoe_pa.sid) delete_item(po->pppoe_pa.sid, po->pppoe_pa.remote); - + if (po->pppoe_dev) dev_put(po->pppoe_dev); @@ -945,7 +945,7 @@ int pppoe_proc_info(char *buffer, char **start, off_t offset, int length) off_t begin = 0; int size; int i; - + len += sprintf(buffer, "Id Address Device\n"); pos = len; @@ -1025,9 +1025,10 @@ int __init pppoe_init(void) int err = register_pppox_proto(PX_PROTO_OE, &pppoe_proto); if (err == 0) { - printk(KERN_INFO "Registered PPPoE v0.6.4\n"); + printk(KERN_INFO "Registered PPPoE v0.6.5\n"); dev_add_pack(&pppoes_ptype); + dev_add_pack(&pppoed_ptype); register_netdevice_notifier(&pppoe_notifier); proc_net_create("pppoe", 0, pppoe_proc_info); } @@ -1038,6 +1039,7 @@ void __exit pppoe_exit(void) { unregister_pppox_proto(PX_PROTO_OE); dev_remove_pack(&pppoes_ptype); + dev_remove_pack(&pppoed_ptype); unregister_netdevice_notifier(&pppoe_notifier); proc_net_remove("pppoe"); } diff --git a/drivers/net/sunbmac.c b/drivers/net/sunbmac.c index 3036684f9..253548599 100644 --- a/drivers/net/sunbmac.c +++ b/drivers/net/sunbmac.c @@ -1,12 +1,9 @@ -/* $Id: sunbmac.c,v 1.21 2000/10/22 16:08:38 davem Exp $ +/* $Id: sunbmac.c,v 1.23 2001/01/20 03:36:40 davem Exp $ * sunbmac.c: Driver for Sparc BigMAC 100baseT ethernet adapters. * * Copyright (C) 1997, 1998, 1999 David S. Miller (davem@redhat.com) */ -static char *version = - "sunbmac.c:v1.9 11/Sep/99 David S. Miller (davem@redhat.com)\n"; - #include <linux/module.h> #include <linux/kernel.h> @@ -41,6 +38,9 @@ static char *version = #include "sunbmac.h" +static char version[] __initdata = + "sunbmac.c:v1.9 11/Sep/99 David S. Miller (davem@redhat.com)\n"; + #undef DEBUG_PROBE #undef DEBUG_TX #undef DEBUG_IRQ @@ -1051,10 +1051,10 @@ static void bigmac_set_multicast(struct net_device *dev) static int __init bigmac_ether_init(struct net_device *dev, struct sbus_dev *qec_sdev) { - static int version_printed = 0; - struct bigmac *bp = 0; + static int version_printed; + struct bigmac *bp; u8 bsizes, bsizes_more; - int i, res = ENOMEM; + int i; /* Get a new device struct for this interface. */ dev = init_etherdev(0, sizeof(struct bigmac)); @@ -1062,6 +1062,9 @@ static int __init bigmac_ether_init(struct net_device *dev, struct sbus_dev *qec if (version_printed++ == 0) printk(KERN_INFO "%s", version); + if (!dev) + return -ENOMEM; + /* Report what we have found to the user. */ printk(KERN_INFO "%s: BigMAC 100baseT Ethernet ", dev->name); dev->base_addr = (long) qec_sdev; @@ -1077,9 +1080,6 @@ static int __init bigmac_ether_init(struct net_device *dev, struct sbus_dev *qec spin_lock_init(&bp->lock); - /* All further failures we find return this. */ - res = ENODEV; - /* Verify the registers we expect, are actually there. */ if ((bp->bigmac_sdev->num_registers != 3) || (bp->qec_sdev->num_registers != 2)) { @@ -1205,28 +1205,25 @@ static int __init bigmac_ether_init(struct net_device *dev, struct sbus_dev *qec fail_and_cleanup: /* Something went wrong, undo whatever we did so far. */ - if (bp) { - /* Free register mappings if any. */ - if (bp->gregs) - sbus_iounmap(bp->gregs, GLOB_REG_SIZE); - if (bp->creg) - sbus_iounmap(bp->creg, CREG_REG_SIZE); - if (bp->bregs) - sbus_iounmap(bp->bregs, BMAC_REG_SIZE); - if (bp->tregs) - sbus_iounmap(bp->tregs, TCVR_REG_SIZE); - - if (bp->bmac_block) - sbus_free_consistent(bp->bigmac_sdev, - PAGE_SIZE, - bp->bmac_block, - bp->bblock_dvma); - - /* Free the BigMAC softc. */ - kfree(bp); - dev->priv = 0; - } - return res; /* Return error code. */ + /* Free register mappings if any. */ + if (bp->gregs) + sbus_iounmap(bp->gregs, GLOB_REG_SIZE); + if (bp->creg) + sbus_iounmap(bp->creg, CREG_REG_SIZE); + if (bp->bregs) + sbus_iounmap(bp->bregs, BMAC_REG_SIZE); + if (bp->tregs) + sbus_iounmap(bp->tregs, TCVR_REG_SIZE); + + if (bp->bmac_block) + sbus_free_consistent(bp->bigmac_sdev, + PAGE_SIZE, + bp->bmac_block, + bp->bblock_dvma); + + unregister_netdev(dev); + kfree(dev); + return -ENODEV; } /* QEC can be the parent of either QuadEthernet or diff --git a/drivers/net/tulip/ChangeLog b/drivers/net/tulip/ChangeLog index dfac94349..bb5b70f01 100644 --- a/drivers/net/tulip/ChangeLog +++ b/drivers/net/tulip/ChangeLog @@ -1,7 +1,37 @@ -2000-12-17 Alan Cox <alan@redhat.com> +2001-01-16 Jeff Garzik <jgarzik@mandrakesoft.com> - * merge support for the Davicom's quirks into the main tulip. Patch - by Tobias Ringstrom + * tulip_core.c: static vars no longer explicitly + initialized to zero. + * eeprom.c (tulip_read_eeprom): Make sure to delay between + EE_ENB and EE_ENB|EE_SHIFT_CLK. Merged from becker tulip.c. + +2001-01-05 Peter De Schrijver <p2@mind.be> + + * eeprom.c (tulip_parse_eeprom): Interpret a bit more of 21142 + extended format type 3 info blocks in a tulip SROM. + +2001-01-03 Matti Aarnio <matti.aarnio@zmailer.org> + + * media.c (tulip_select_media): Support media types 5 and 6 + +2001-??-?? ?? + + * tulip_core.c: Add comment about LanMedia needing + a different driver. + Enable workarounds for early PCI chipsets. + Add IA64 csr0 support, update HPPA csr0 support. + +2000-12-17 Alan Cox <alan@redhat.com> + + * eeprom.c, timer.c, tulip.h, tulip_core.c: Merge support + for the Davicom's quirks into the main tulip. + Patch by Tobias Ringstrom + +2000-11-08 Jim Studt <jim@federated.com> + + * eeprom.c (tulip_parse_eeprom): Check array bounds for + medianame[] and block_name[] arrays to avoid oops due + to bad values returned from hardware. 2000-11-02 Jeff Garzik <jgarzik@mandrakesoft.com> diff --git a/drivers/net/tulip/eeprom.c b/drivers/net/tulip/eeprom.c index 49e8bf42e..f42baefc2 100644 --- a/drivers/net/tulip/eeprom.c +++ b/drivers/net/tulip/eeprom.c @@ -207,8 +207,13 @@ subsequent_board: p += (p[0] & 0x3f) + 1; continue; } else if (p[1] & 1) { + int gpr_len, reset_len; + mtable->has_mii = 1; leaf->media = 11; + gpr_len=p[3]*2; + reset_len=p[4+gpr_len]*2; + new_advertise |= get_u16(&p[7+gpr_len+reset_len]); } else { mtable->has_nonmii = 1; leaf->media = p[2] & 0x0f; @@ -247,9 +252,9 @@ subsequent_board: } printk(KERN_INFO "%s: Index #%d - Media %s (#%d) described " "by a %s (%d) block.\n", - dev->name, i, medianame[leaf->media], leaf->media, - leaf->type >= ARRAY_SIZE(block_name) ? "UNKNOWN" : - block_name[leaf->type], leaf->type); + dev->name, i, medianame[leaf->media & 15], leaf->media, + leaf->type < ARRAY_SIZE(block_name) ? block_name[leaf->type] : "<unknown>", + leaf->type); } if (new_advertise) tp->to_advertise = new_advertise; @@ -278,6 +283,7 @@ int __devinit tulip_read_eeprom(long ioaddr, int location, int addr_len) retval = (retval << 1) | ((inl(ee_addr) & EE_DATA_READ) ? 1 : 0); } outl(EE_ENB, ee_addr); + eeprom_delay(); for (i = 16; i > 0; i--) { outl(EE_ENB | EE_SHIFT_CLK, ee_addr); diff --git a/drivers/net/tulip/media.c b/drivers/net/tulip/media.c index b8203f33a..bc8e7bbbc 100644 --- a/drivers/net/tulip/media.c +++ b/drivers/net/tulip/media.c @@ -148,7 +148,7 @@ void tulip_select_media(struct net_device *dev, int startup) long ioaddr = dev->base_addr; struct tulip_private *tp = (struct tulip_private *)dev->priv; struct mediatable *mtable = tp->mtable; - u32 new_csr6; + u32 new_csr6=0; int i; if (mtable) { @@ -265,7 +265,9 @@ void tulip_select_media(struct net_device *dev, int startup) } case 5: case 6: { u16 setup[5]; - u32 csr13val, csr14val, csr15dir, csr15val; + + new_csr6 = 0; /* FIXME */ + for (i = 0; i < 5; i++) setup[i] = get_u16(&p[i*2 + 1]); diff --git a/drivers/net/tulip/tulip_core.c b/drivers/net/tulip/tulip_core.c index 765cd6c7c..0517b90af 100644 --- a/drivers/net/tulip/tulip_core.c +++ b/drivers/net/tulip/tulip_core.c @@ -28,7 +28,7 @@ #include <asm/unaligned.h> static char version[] __devinitdata = - "Linux Tulip driver version 0.9.13 (January 2, 2001)\n"; + "Linux Tulip driver version 0.9.13a (January 20, 2001)\n"; /* A few user-configurable values. */ diff --git a/drivers/net/wan/lapbether.c b/drivers/net/wan/lapbether.c index eaba0cd34..3f23aec1c 100644 --- a/drivers/net/wan/lapbether.c +++ b/drivers/net/wan/lapbether.c @@ -45,25 +45,10 @@ #include <linux/lapb.h> #include <linux/init.h> -static char bcast_addr[6]={0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; - -static int lapbeth_rcv(struct sk_buff *, struct net_device *, struct packet_type *); -static int lapbeth_device_event(struct notifier_block *, unsigned long, void *); - -static struct packet_type lapbeth_packet_type = { - 0, /* ntohs(ETH_P_DEC),*/ - 0, /* copy */ - lapbeth_rcv, - NULL, - NULL, -}; - -static struct notifier_block lapbeth_dev_notifier = { - lapbeth_device_event, - 0 -}; - +static char bcast_addr[6] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; +/* If this number is made larger, check that the temporary string buffer + * in lapbeth_new_device is large enough to store the probe device name.*/ #define MAXLAPBDEV 100 static struct lapbethdev { @@ -72,29 +57,14 @@ static struct lapbethdev { struct net_device *ethdev; /* link to ethernet device */ struct net_device axdev; /* lapbeth device (lapb#) */ struct net_device_stats stats; /* some statistics */ -} *lapbeth_devices = NULL; - +} *lapbeth_devices /* = NULL initially */; /* ------------------------------------------------------------------------ */ - -/* - * Get the ethernet device for a LAPB device - */ -#if 0 -static __inline__ struct net_device *lapbeth_get_ether_dev(struct net_device *dev) -{ - struct lapbethdev *lapbeth; - - lapbeth = (struct lapbethdev *)dev->priv; - - return (lapbeth != NULL) ? lapbeth->ethdev : NULL; -} -#endif /* * Get the LAPB device for the ethernet device */ -static __inline__ struct net_device *lapbeth_get_x25_dev(struct net_device *dev) +static inline struct net_device *lapbeth_get_x25_dev(struct net_device *dev) { struct lapbethdev *lapbeth; @@ -105,7 +75,7 @@ static __inline__ struct net_device *lapbeth_get_x25_dev(struct net_device *dev) return NULL; } -static __inline__ int dev_is_ethdev(struct net_device *dev) +static inline int dev_is_ethdev(struct net_device *dev) { return ( dev->type == ARPHRD_ETHER @@ -122,7 +92,7 @@ static int lapbeth_check_devices(struct net_device *dev) struct lapbethdev *lapbeth, *lapbeth_prev; int result = 0; unsigned long flags; - + save_flags(flags); cli(); @@ -134,7 +104,7 @@ static int lapbeth_check_devices(struct net_device *dev) lapbeth_prev->next = lapbeth->next; else lapbeth_devices = lapbeth->next; - + if (&lapbeth->axdev == dev) result = 1; @@ -145,16 +115,14 @@ static int lapbeth_check_devices(struct net_device *dev) lapbeth_prev = lapbeth; } - + restore_flags(flags); - + return result; } - /* ------------------------------------------------------------------------ */ - /* * Receive a LAPB frame via an ethernet interface. */ @@ -164,7 +132,7 @@ static int lapbeth_rcv(struct sk_buff *skb, struct net_device *dev, struct packe struct lapbethdev *lapbeth; skb->sk = NULL; /* Initially we don't know who it's for */ - + dev = lapbeth_get_x25_dev(dev); if (dev == NULL || !netif_running(dev)) { @@ -172,7 +140,7 @@ static int lapbeth_rcv(struct sk_buff *skb, struct net_device *dev, struct packe return 0; } - lapbeth = (struct lapbethdev *)dev->priv; + lapbeth = (struct lapbethdev *) dev->priv; lapbeth->stats.rx_packets++; @@ -191,7 +159,7 @@ static int lapbeth_rcv(struct sk_buff *skb, struct net_device *dev, struct packe static int lapbeth_data_indication(void *token, struct sk_buff *skb) { - struct lapbethdev *lapbeth = (struct lapbethdev *)token; + struct lapbethdev *lapbeth = (struct lapbethdev *) token; unsigned char *ptr; ptr = skb_push(skb, 1); @@ -206,14 +174,12 @@ static int lapbeth_data_indication(void *token, struct sk_buff *skb) } /* - * Send a LAPB frame via an ethernet interface + * Send a LAPB frame via an ethernet interface */ static int lapbeth_xmit(struct sk_buff *skb, struct net_device *dev) { - struct lapbethdev *lapbeth; + struct lapbethdev *lapbeth = (struct lapbethdev *) dev->priv; int err; - - lapbeth = (struct lapbethdev *)dev->priv; /* * Just to be *really* sure not to send anything if the interface @@ -253,10 +219,10 @@ static int lapbeth_xmit(struct sk_buff *skb, struct net_device *dev) return 0; } - + static void lapbeth_data_transmit(void *token, struct sk_buff *skb) { - struct lapbethdev *lapbeth = (struct lapbethdev *)token; + struct lapbethdev *lapbeth = (struct lapbethdev *) token; unsigned char *ptr; struct net_device *dev; int size; @@ -281,7 +247,7 @@ static void lapbeth_data_transmit(void *token, struct sk_buff *skb) static void lapbeth_connected(void *token, int reason) { - struct lapbethdev *lapbeth = (struct lapbethdev *)token; + struct lapbethdev *lapbeth = (struct lapbethdev *) token; struct sk_buff *skb; unsigned char *ptr; @@ -303,7 +269,7 @@ static void lapbeth_connected(void *token, int reason) static void lapbeth_disconnected(void *token, int reason) { - struct lapbethdev *lapbeth = (struct lapbethdev *)token; + struct lapbethdev *lapbeth = (struct lapbethdev *) token; struct sk_buff *skb; unsigned char *ptr; @@ -328,10 +294,7 @@ static void lapbeth_disconnected(void *token, int reason) */ static struct net_device_stats *lapbeth_get_stats(struct net_device *dev) { - struct lapbethdev *lapbeth; - - lapbeth = (struct lapbethdev *)dev->priv; - + struct lapbethdev *lapbeth = (struct lapbethdev *) dev->priv; return &lapbeth->stats; } @@ -340,18 +303,11 @@ static struct net_device_stats *lapbeth_get_stats(struct net_device *dev) */ static int lapbeth_set_mac_address(struct net_device *dev, void *addr) { - struct sockaddr *sa = (struct sockaddr *)addr; - + struct sockaddr *sa = (struct sockaddr *) addr; memcpy(dev->dev_addr, sa->sa_data, dev->addr_len); - return 0; } -static int lapbeth_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) -{ - return -EINVAL; -} - /* * open/close a device */ @@ -363,8 +319,8 @@ static int lapbeth_open(struct net_device *dev) if (lapbeth_check_devices(dev)) return -ENODEV; /* oops, it's gone */ - - lapbeth = (struct lapbethdev *)dev->priv; + + lapbeth = (struct lapbethdev *) dev->priv; lapbeth_callbacks.connect_confirmation = lapbeth_connected; lapbeth_callbacks.connect_indication = lapbeth_connected; @@ -378,31 +334,20 @@ static int lapbeth_open(struct net_device *dev) return -ENODEV; } - MOD_INC_USE_COUNT; netif_start_queue(dev); - return 0; } static int lapbeth_close(struct net_device *dev) { - struct lapbethdev *lapbeth; + struct lapbethdev *lapbeth = (struct lapbethdev *) dev->priv; int err; netif_stop_queue(dev); - - lapbeth = (struct lapbethdev *)dev->priv; if ((err = lapb_unregister(lapbeth)) != LAPB_OK) printk(KERN_ERR "lapbeth: lapb_unregister error - %d\n", err); - MOD_DEC_USE_COUNT; - - return 0; -} - -static int lapbeth_dev_init(struct net_device *dev) -{ return 0; } @@ -414,14 +359,14 @@ static int lapbeth_dev_init(struct net_device *dev) static int lapbeth_new_device(struct net_device *dev) { int k; - unsigned char *buf; + unsigned char buf[14]; struct lapbethdev *lapbeth, *lapbeth2; - + if ((lapbeth = kmalloc(sizeof(struct lapbethdev), GFP_KERNEL)) == NULL) return -ENOMEM; - + memset(lapbeth, 0, sizeof(struct lapbethdev)); - + dev_hold(dev); lapbeth->ethdev = dev; @@ -429,7 +374,7 @@ static int lapbeth_new_device(struct net_device *dev) strncpy(lapbeth->ethname, dev->name, sizeof(lapbeth->ethname)-1); dev = &lapbeth->axdev; - buf = kmalloc(14, GFP_KERNEL); + SET_MODULE_OWNER(dev); for (k = 0; k < MAXLAPBDEV; k++) { struct net_device *odev; @@ -445,10 +390,9 @@ static int lapbeth_new_device(struct net_device *dev) kfree(lapbeth); return -ENODEV; } - + dev->priv = (void *)lapbeth; /* pointer back */ strcpy(dev->name, buf); - dev->init = lapbeth_dev_init; if (register_netdev(dev) != 0) { dev_put(dev); @@ -463,10 +407,6 @@ static int lapbeth_new_device(struct net_device *dev) dev->stop = lapbeth_close; dev->set_mac_address = lapbeth_set_mac_address; dev->get_stats = lapbeth_get_stats; - dev->do_ioctl = lapbeth_ioctl; - - dev->flags = 0; - dev->type = ARPHRD_X25; dev->hard_header_len = 3; dev->mtu = 1000; @@ -480,20 +420,19 @@ static int lapbeth_new_device(struct net_device *dev) for (lapbeth2 = lapbeth_devices; lapbeth2->next != NULL; lapbeth2 = lapbeth2->next); lapbeth2->next = lapbeth; } - + sti(); return 0; } - /* * Handle device status changes. */ -static int lapbeth_device_event(struct notifier_block *this,unsigned long event, void *ptr) +static int lapbeth_device_event(struct notifier_block *this, unsigned long event, void *ptr) { - struct net_device *dev = (struct net_device *)ptr; - + struct net_device *dev = (struct net_device *) ptr; + if (!dev_is_ethdev(dev)) return NOTIFY_DONE; @@ -518,23 +457,28 @@ static int lapbeth_device_event(struct notifier_block *this,unsigned long event, return NOTIFY_DONE; } - /* ------------------------------------------------------------------------ */ -/* - * Initialize driver. To be called from af_ax25 if not compiled as a - * module - */ -int lapbeth_init(void) +static struct packet_type lapbeth_packet_type = { + type: __constant_htons(ETH_P_DEC), + func: lapbeth_rcv, +}; + +static struct notifier_block lapbeth_dev_notifier = { + notifier_call: lapbeth_device_event, +}; + +static const char banner[] __initdata = KERN_INFO "LAPB Ethernet driver version 0.01\n"; + +static int __init lapbeth_init_driver(void) { struct net_device *dev; - lapbeth_packet_type.type = htons(ETH_P_DEC); dev_add_pack(&lapbeth_packet_type); register_netdevice_notifier(&lapbeth_dev_notifier); - printk(KERN_INFO "LAPB Ethernet driver version 0.01\n"); + printk(banner); read_lock_bh(&dev_base_lock); for (dev = dev_base; dev != NULL; dev = dev->next) { @@ -548,19 +492,9 @@ int lapbeth_init(void) return 0; } +module_init(lapbeth_init_driver); -#ifdef MODULE -EXPORT_NO_SYMBOLS; - -MODULE_AUTHOR("Jonathan Naylor <g4klx@g4klx.demon.co.uk>"); -MODULE_DESCRIPTION("The unofficial LAPB over Ethernet driver"); - -int init_module(void) -{ - return lapbeth_init(); -} - -void cleanup_module(void) +static void __exit lapbeth_cleanup_driver(void) { struct lapbethdev *lapbeth; @@ -571,4 +505,10 @@ void cleanup_module(void) for (lapbeth = lapbeth_devices; lapbeth != NULL; lapbeth = lapbeth->next) unregister_netdev(&lapbeth->axdev); } -#endif +module_exit(lapbeth_cleanup_driver); + +EXPORT_NO_SYMBOLS; + +MODULE_AUTHOR("Jonathan Naylor <g4klx@g4klx.demon.co.uk>"); +MODULE_DESCRIPTION("The unofficial LAPB over Ethernet driver"); + diff --git a/drivers/net/wan/lmc/lmc.h b/drivers/net/wan/lmc/lmc.h index 91b9e8f00..882e58c1b 100644 --- a/drivers/net/wan/lmc/lmc.h +++ b/drivers/net/wan/lmc/lmc.h @@ -29,4 +29,5 @@ extern lmc_media_t lmc_hssi_media; static void lmcEventLog( u_int32_t EventNum, u_int32_t arg2, u_int32_t arg3 ); #endif -#endif
\ No newline at end of file +#endif + diff --git a/drivers/net/wan/lmc/lmc_media.h b/drivers/net/wan/lmc/lmc_media.h index 7cc6c1650..ddcc00403 100644 --- a/drivers/net/wan/lmc/lmc_media.h +++ b/drivers/net/wan/lmc/lmc_media.h @@ -61,4 +61,5 @@ lmc_media_t lmc_t1_media = { }; -#endif
\ No newline at end of file +#endif + diff --git a/drivers/net/wan/lmc/lmc_prot.h b/drivers/net/wan/lmc/lmc_prot.h index 859ef0f00..f3b1df9e2 100644 --- a/drivers/net/wan/lmc/lmc_prot.h +++ b/drivers/net/wan/lmc/lmc_prot.h @@ -11,4 +11,5 @@ void lmc_proto_close(lmc_softc_t *sc const) unsigned short lmc_proto_type(lmc_softc_t *sc const, struct skbuff *skb) -#endif
\ No newline at end of file +#endif + diff --git a/drivers/net/wan/lmc/lmc_proto.h b/drivers/net/wan/lmc/lmc_proto.h index 6136dfad7..080a55773 100644 --- a/drivers/net/wan/lmc/lmc_proto.h +++ b/drivers/net/wan/lmc/lmc_proto.h @@ -12,4 +12,5 @@ unsigned short lmc_proto_type(lmc_softc_t *sc, struct sk_buff *skb); void lmc_proto_netif(lmc_softc_t *sc, struct sk_buff *skb); int lmc_skb_rawpackets(char *buf, char **start, off_t offset, int len, int unused); -#endif
\ No newline at end of file +#endif + diff --git a/drivers/net/wan/sdla.c b/drivers/net/wan/sdla.c index ef489b1a6..1eb66b44e 100644 --- a/drivers/net/wan/sdla.c +++ b/drivers/net/wan/sdla.c @@ -744,7 +744,7 @@ static void sdla_receive(struct net_device *dev) struct buf_entry *pbuf; unsigned long flags; - int i, received, success, addr, buf_base, buf_top; + int i=0, received, success, addr, buf_base, buf_top; short dlci, len, len2, split; flp = dev->priv; |