X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fnet%2Fhp100.c;h=844c136e9920cc92c98d5abbb60c7a8a7767a14c;hb=refs%2Fheads%2Fvserver;hp=3c783a4591fe92c0aed0ba76a6e35fc003f05862;hpb=c7b5ebbddf7bcd3651947760f423e3783bbe6573;p=linux-2.6.git diff --git a/drivers/net/hp100.c b/drivers/net/hp100.c index 3c783a459..844c136e9 100644 --- a/drivers/net/hp100.c +++ b/drivers/net/hp100.c @@ -1,24 +1,24 @@ /* -** hp100.c +** hp100.c ** HP CASCADE Architecture Driver for 100VG-AnyLan Network Adapters ** ** $Id: hp100.c,v 1.58 2001/09/24 18:03:01 perex Exp perex $ ** ** Based on the HP100 driver written by Jaroslav Kysela -** Extended for new busmaster capable chipsets by +** Extended for new busmaster capable chipsets by ** Siegfried "Frieder" Loeffler (dg1sek) ** ** Maintained by: Jaroslav Kysela -** +** ** This driver has only been tested with ** -- HP J2585B 10/100 Mbit/s PCI Busmaster -** -- HP J2585A 10/100 Mbit/s PCI -** -- HP J2970 10 Mbit/s PCI Combo 10base-T/BNC -** -- HP J2973 10 Mbit/s PCI 10base-T +** -- HP J2585A 10/100 Mbit/s PCI +** -- HP J2970A 10 Mbit/s PCI Combo 10base-T/BNC +** -- HP J2973A 10 Mbit/s PCI 10base-T ** -- HP J2573 10/100 ISA ** -- Compex ReadyLink ENET100-VG4 10/100 Mbit/s PCI / EISA ** -- Compex FreedomLine 100/VG 10/100 Mbit/s ISA / EISA / PCI -** +** ** but it should also work with the other CASCADE based adapters. ** ** TODO: @@ -65,7 +65,7 @@ ** - timing changes in xmit routines, relogin to 100VG hub added when ** driver does reset ** - included fix for Compex FreedomLine PCI adapter -** +** ** 1.54 -> 1.55 ** - fixed bad initialization in init_module ** - added Compex FreedomLine adapter @@ -73,10 +73,10 @@ ** ** 1.53 -> 1.54 ** - added hardware multicast filter support (doesn't work) -** - little changes in hp100_sense_lan routine +** - little changes in hp100_sense_lan routine ** - added support for Coax and AUI (J2970) ** - fix for multiple cards and hp100_mode parameter (insmod) -** - fix for shared IRQ +** - fix for shared IRQ ** ** 1.52 -> 1.53 ** - fixed bug in multicast support @@ -96,7 +96,6 @@ #undef HP100_MULTICAST_FILTER /* Need to be debugged... */ -#include #include #include #include @@ -106,16 +105,17 @@ #include #include #include +#include #include #include #include #include #include -#include /* for CONFIG_PCI */ #include #include +#include +#include -#include #include #include "hp100.h" @@ -161,7 +161,7 @@ struct hp100_private { u_char bus; struct pci_dev *pci_dev; short mem_mapped; /* memory mapped access */ - void *mem_ptr_virt; /* virtual memory mapped area, maybe NULL */ + void __iomem *mem_ptr_virt; /* virtual memory mapped area, maybe NULL */ unsigned long mem_ptr_phys; /* physical memory mapped area */ short lan_type; /* 10Mb/s, 100Mb/s or -1 (error) */ int hub_status; /* was login to hub successful? */ @@ -188,10 +188,12 @@ struct hp100_private { /* * variables */ +#ifdef CONFIG_ISA static const char *hp100_isa_tbl[] = { "HWPF150", /* HP J2573 rev A */ "HWP1950", /* HP J2573 */ }; +#endif #ifdef CONFIG_EISA static struct eisa_device_id hp100_eisa_tbl[] = { @@ -224,9 +226,9 @@ static int hp100_rx_ratio = HP100_DEFAULT_RX_RATIO; static int hp100_priority_tx = HP100_DEFAULT_PRIORITY_TX; static int hp100_mode = 1; -MODULE_PARM(hp100_rx_ratio, "1i"); -MODULE_PARM(hp100_priority_tx, "1i"); -MODULE_PARM(hp100_mode, "1i"); +module_param(hp100_rx_ratio, int, 0); +module_param(hp100_priority_tx, int, 0); +module_param(hp100_mode, int, 0); /* * prototypes @@ -247,7 +249,7 @@ static void hp100_misc_interrupt(struct net_device *dev); static void hp100_update_stats(struct net_device *dev); static void hp100_clear_stats(struct hp100_private *lp, int ioaddr); static void hp100_set_multicast_list(struct net_device *dev); -static irqreturn_t hp100_interrupt(int irq, void *dev_id, struct pt_regs *regs); +static irqreturn_t hp100_interrupt(int irq, void *dev_id); static void hp100_start_interface(struct net_device *dev); static void hp100_stop_interface(struct net_device *dev); static void hp100_load_eeprom(struct net_device *dev, u_short ioaddr); @@ -276,12 +278,18 @@ static void hp100_RegisterDump(struct net_device *dev); * Convert an address in a kernel buffer to a bus/phys/dma address. * This work *only* for memory fragments part of lp->page_vaddr, * because it was properly DMA allocated via pci_alloc_consistent(), - * so we just need to "retreive" the original mapping to bus/phys/dma + * so we just need to "retrieve" the original mapping to bus/phys/dma * address - Jean II */ static inline dma_addr_t virt_to_whatever(struct net_device *dev, u32 * ptr) { - return ((u_long) ptr) + - ((struct hp100_private *) (dev->priv))->whatever_offset; + struct hp100_private *lp = netdev_priv(dev); + return ((u_long) ptr) + lp->whatever_offset; +} + +static inline u_int pdl_map_data(struct hp100_private *lp, void *data) +{ + return pci_map_single(lp->pci_dev, data, + MAX_ETHER_SIZE, PCI_DMA_FROMDEVICE); } /* TODO: This function should not really be needed in a good design... */ @@ -300,7 +308,7 @@ static void wait(void) * Read board id and convert to string. * Effectively same code as decode_eisa_sig */ -static __init const char *hp100_read_id(int ioaddr) +static __devinit const char *hp100_read_id(int ioaddr) { int i; static char str[HP100_SIG_LEN]; @@ -327,6 +335,7 @@ static __init const char *hp100_read_id(int ioaddr) return str; } +#ifdef CONFIG_ISA static __init int hp100_isa_probe1(struct net_device *dev, int ioaddr) { const char *sig; @@ -347,7 +356,7 @@ static __init int hp100_isa_probe1(struct net_device *dev, int ioaddr) goto err; for (i = 0; i < ARRAY_SIZE(hp100_isa_tbl); i++) { - if (!strcmp(hp100_isa_tbl[i], sig)) + if (!strcmp(hp100_isa_tbl[i], sig)) break; } @@ -367,11 +376,11 @@ static int __init hp100_isa_probe(struct net_device *dev, int addr) { int err = -ENODEV; - /* Probe for a specific ISA address */ + /* Probe for a specific ISA address */ if (addr > 0xff && addr < 0x400) err = hp100_isa_probe1(dev, addr); - else if (addr != 0) + else if (addr != 0) err = -ENXIO; else { @@ -384,9 +393,9 @@ static int __init hp100_isa_probe(struct net_device *dev, int addr) } return err; } +#endif /* CONFIG_ISA */ - -#ifndef MODULE +#if !defined(MODULE) && defined(CONFIG_ISA) struct net_device * __init hp100_probe(int unit) { struct net_device *dev = alloc_etherdev(sizeof(struct hp100_private)); @@ -411,20 +420,15 @@ struct net_device * __init hp100_probe(int unit) if (err) goto out; - err = register_netdev(dev); - if (err) - goto out1; return dev; - out1: - release_region(dev->base_addr, HP100_REGION_SIZE); out: free_netdev(dev); return ERR_PTR(err); } -#endif +#endif /* !MODULE && CONFIG_ISA */ -static int __init hp100_probe1(struct net_device *dev, int ioaddr, - u_char bus, struct pci_dev *pci_dev) +static int __devinit hp100_probe1(struct net_device *dev, int ioaddr, + u_char bus, struct pci_dev *pci_dev) { int i; int err = -ENODEV; @@ -435,7 +439,7 @@ static int __init hp100_probe1(struct net_device *dev, int ioaddr, u_short local_mode, lsw; short mem_mapped; unsigned long mem_ptr_phys; - void **mem_ptr_virt; + void __iomem *mem_ptr_virt; struct hp100_private *lp; #ifdef HP100_DEBUG_B @@ -447,7 +451,7 @@ static int __init hp100_probe1(struct net_device *dev, int ioaddr, if (!request_region(ioaddr, HP100_REGION_SIZE, "hp100")) goto out1; - if (hp100_inw(HW_ID) != HP100_HW_ID_CASCADE) + if (hp100_inw(HW_ID) != HP100_HW_ID_CASCADE) goto out2; chip = hp100_inw(PAGING) & HP100_CHIPID_MASK; @@ -490,7 +494,7 @@ static int __init hp100_probe1(struct net_device *dev, int ioaddr, * Use the variable "hp100_mode" upon insmod or as kernel parameter to * force driver modes: * hp100_mode=1 -> default, use busmaster mode if configured. - * hp100_mode=2 -> enable shared memory mode + * hp100_mode=2 -> enable shared memory mode * hp100_mode=3 -> force use of i/o mapped mode. * hp100_mode=4 -> same as 1, but re-set the enable bit on the card. */ @@ -556,7 +560,7 @@ static int __init hp100_probe1(struct net_device *dev, int ioaddr, * Also, we can have EISA Busmaster cards (not tested), * so beware !!! - Jean II */ if((bus == HP100_BUS_PCI) && - (pci_set_dma_mask(pci_dev, 0xffffffff))) { + (pci_set_dma_mask(pci_dev, DMA_32BIT_MASK))) { /* Gracefully fallback to shared memory */ goto busmasterfail; } @@ -631,7 +635,7 @@ static int __init hp100_probe1(struct net_device *dev, int ioaddr, } /* Initialise the "private" data structure for this card. */ - lp = (struct hp100_private *) dev->priv; + lp = netdev_priv(dev); spin_lock_init(&lp->lock); strlcpy(lp->id, eid, HP100_SIG_LEN); @@ -688,9 +692,9 @@ static int __init hp100_probe1(struct net_device *dev, int ioaddr, hp100_clear_stats(lp, ioaddr); /* If busmaster mode is wanted, a dma-capable memory area is needed for - * the rx and tx PDLs + * the rx and tx PDLs * PCI cards can access the whole PC memory. Therefore GFP_DMA is not - * needed for the allocation of the memory area. + * needed for the allocation of the memory area. */ /* TODO: We do not need this with old cards, where PDLs are stored @@ -717,7 +721,7 @@ static int __init hp100_probe1(struct net_device *dev, int ioaddr, } /* Initialise the card. */ - /* (I'm not really sure if it's a good idea to do this during probing, but + /* (I'm not really sure if it's a good idea to do this during probing, but * like this it's assured that the lan connection type can be sensed * correctly) */ @@ -770,18 +774,29 @@ static int __init hp100_probe1(struct net_device *dev, int ioaddr, printk("Warning! Link down.\n"); } + err = register_netdev(dev); + if (err) + goto out3; + return 0; +out3: + if (local_mode == 1) + pci_free_consistent(lp->pci_dev, MAX_RINGSIZE + 0x0f, + lp->page_vaddr_algn, + virt_to_whatever(dev, lp->page_vaddr_algn)); + if (mem_ptr_virt) + iounmap(mem_ptr_virt); out2: release_region(ioaddr, HP100_REGION_SIZE); out1: - return -ENODEV; + return err; } /* This procedure puts the card into a stable init state */ static void hp100_hwinit(struct net_device *dev) { int ioaddr = dev->base_addr; - struct hp100_private *lp = (struct hp100_private *) dev->priv; + struct hp100_private *lp = netdev_priv(dev); #ifdef HP100_DEBUG_B hp100_outw(0x4202, TRACE); @@ -848,7 +863,7 @@ static void hp100_hwinit(struct net_device *dev) /* Next comes code from mmuinit procedure of SCO BM driver which is * called from HWconfigure in the SCO driver. */ - /* Initialise MMU, eventually switch on Busmaster Mode, initialise + /* Initialise MMU, eventually switch on Busmaster Mode, initialise * multicast filter... */ hp100_mmuinit(dev); @@ -866,16 +881,16 @@ static void hp100_hwinit(struct net_device *dev) hp100_login_to_vg_hub(dev, 0); /* relogin */ } - -/* + +/* * mmuinit - Reinitialise Cascade MMU and MAC settings. - * Note: Must already be in reset and leaves card in reset. + * Note: Must already be in reset and leaves card in reset. */ static void hp100_mmuinit(struct net_device *dev) { int ioaddr = dev->base_addr; - struct hp100_private *lp = (struct hp100_private *) dev->priv; + struct hp100_private *lp = netdev_priv(dev); int i; #ifdef HP100_DEBUG_B @@ -896,7 +911,7 @@ static void hp100_mmuinit(struct net_device *dev) hp100_outw(0xffff, IRQ_STATUS); /* ack IRQ */ /* - * Enable Hardware + * Enable Hardware * - Clear Debug En, Rx Hdr Pipe, EE En, I/O En, Fake Int and Intr En * - Set Tri-State Int, Bus Master Rd/Wr, and Mem Map Disable * - Clear Priority, Advance Pkt and Xmit Cmd @@ -971,7 +986,7 @@ static void hp100_mmuinit(struct net_device *dev) * 4 bytes for header). We will leave NUM_RXPDLS * 508 (rounded * to the next higher 1k boundary) bytes for the rx-pdl's * Note: For non-etr chips the transmit stop register must be - * programmed on a 1k boundary, i.e. bits 9:0 must be zero. + * programmed on a 1k boundary, i.e. bits 9:0 must be zero. */ pdl_stop = lp->memory_size; xmit_stop = (pdl_stop - 508 * (MAX_RX_PDL) - 16) & ~(0x03ff); @@ -1053,7 +1068,7 @@ static void hp100_mmuinit(struct net_device *dev) static int hp100_open(struct net_device *dev) { - struct hp100_private *lp = (struct hp100_private *) dev->priv; + struct hp100_private *lp = netdev_priv(dev); #ifdef HP100_DEBUG_B int ioaddr = dev->base_addr; #endif @@ -1066,7 +1081,7 @@ static int hp100_open(struct net_device *dev) /* New: if bus is PCI or EISA, interrupts might be shared interrupts */ if (request_irq(dev->irq, hp100_interrupt, lp->bus == HP100_BUS_PCI || lp->bus == - HP100_BUS_EISA ? SA_SHIRQ : SA_INTERRUPT, + HP100_BUS_EISA ? IRQF_SHARED : IRQF_DISABLED, "hp100", dev)) { printk("hp100: %s: unable to get IRQ %d\n", dev->name, dev->irq); return -EAGAIN; @@ -1093,7 +1108,7 @@ static int hp100_open(struct net_device *dev) static int hp100_close(struct net_device *dev) { int ioaddr = dev->base_addr; - struct hp100_private *lp = (struct hp100_private *) dev->priv; + struct hp100_private *lp = netdev_priv(dev); #ifdef HP100_DEBUG_B hp100_outw(0x4205, TRACE); @@ -1119,14 +1134,14 @@ static int hp100_close(struct net_device *dev) return 0; } - + /* - * Configure the PDL Rx rings and LAN + * Configure the PDL Rx rings and LAN */ static void hp100_init_pdls(struct net_device *dev) { - struct hp100_private *lp = (struct hp100_private *) dev->priv; + struct hp100_private *lp = netdev_priv(dev); hp100_ring_t *ringptr; u_int *pageptr; /* Warning : increment by 4 - Jean II */ int i; @@ -1170,7 +1185,7 @@ static void hp100_init_pdls(struct net_device *dev) } } } - + /* These functions "format" the entries in the pdl structure */ /* They return how much memory the fragments need. */ @@ -1188,10 +1203,10 @@ static int hp100_init_rxpdl(struct net_device *dev, ringptr->pdl_paddr = virt_to_whatever(dev, pdlptr + 1); ringptr->skb = (void *) NULL; - /* + /* * Write address and length of first PDL Fragment (which is used for * storing the RX-Header - * We use the 4 bytes _before_ the PDH in the pdl memory area to + * We use the 4 bytes _before_ the PDH in the pdl memory area to * store this information. (PDH is at offset 0x04) */ /* Note that pdlptr+1 and not pdlptr is the pointer to the PDH */ @@ -1218,9 +1233,9 @@ static int hp100_init_txpdl(struct net_device *dev, } /* - * hp100_build_rx_pdl allocates an skb_buff of maximum size plus two bytes + * hp100_build_rx_pdl allocates an skb_buff of maximum size plus two bytes * for possible odd word alignment rounding up to next dword and set PDL - * address for fragment#2 + * address for fragment#2 * Returns: 0 if unable to allocate skb_buff * 1 if successful */ @@ -1240,13 +1255,13 @@ static int hp100_build_rx_pdl(hp100_ring_t * ringptr, #endif /* Allocate skb buffer of maximum size */ - /* Note: This depends on the alloc_skb functions allocating more + /* Note: This depends on the alloc_skb functions allocating more * space than requested, i.e. aligning to 16bytes */ ringptr->skb = dev_alloc_skb(((MAX_ETHER_SIZE + 2 + 3) / 4) * 4); if (NULL != ringptr->skb) { - /* + /* * Reserve 2 bytes at the head of the buffer to land the IP header * on a long word boundary (According to the Network Driver section * in the Linux KHG, this should help to increase performance.) @@ -1258,10 +1273,10 @@ static int hp100_build_rx_pdl(hp100_ring_t * ringptr, /* ringptr->pdl points to the beginning of the PDL, i.e. the PDH */ /* Note: 1st Fragment is used for the 4 byte packet status - * (receive header). Its PDL entries are set up by init_rxpdl. So + * (receive header). Its PDL entries are set up by init_rxpdl. So * here we only have to set up the PDL fragment entries for the data - * part. Those 4 bytes will be stored in the DMA memory region - * directly before the PDL. + * part. Those 4 bytes will be stored in the DMA memory region + * directly before the PDL. */ #ifdef HP100_DEBUG_BM printk("hp100: %s: build_rx_pdl: PDH@0x%x, skb->data (len %d) at 0x%x\n", @@ -1273,7 +1288,8 @@ static int hp100_build_rx_pdl(hp100_ring_t * ringptr, /* Conversion to new PCI API : map skbuf data to PCI bus. * Doc says it's OK for EISA as well - Jean II */ ringptr->pdl[0] = 0x00020000; /* Write PDH */ - ringptr->pdl[3] = ((u_int) pci_map_single(((struct hp100_private *) (dev->priv))->pci_dev, ringptr->skb->data, MAX_ETHER_SIZE, PCI_DMA_FROMDEVICE)); + ringptr->pdl[3] = pdl_map_data(netdev_priv(dev), + ringptr->skb->data); ringptr->pdl[4] = MAX_ETHER_SIZE; /* Length of Data */ #ifdef HP100_DEBUG_BM @@ -1310,7 +1326,7 @@ static void hp100_rxfill(struct net_device *dev) { int ioaddr = dev->base_addr; - struct hp100_private *lp = (struct hp100_private *) dev->priv; + struct hp100_private *lp = netdev_priv(dev); hp100_ring_t *ringptr; #ifdef HP100_DEBUG_B @@ -1351,7 +1367,7 @@ static void hp100_rxfill(struct net_device *dev) static void hp100_BM_shutdown(struct net_device *dev) { int ioaddr = dev->base_addr; - struct hp100_private *lp = (struct hp100_private *) dev->priv; + struct hp100_private *lp = netdev_priv(dev); unsigned long time; #ifdef HP100_DEBUG_B @@ -1393,7 +1409,7 @@ static void hp100_BM_shutdown(struct net_device *dev) } } else { /* Shasta or Rainier Shutdown/Reset */ /* To ensure all bus master inloading activity has ceased, - * wait for no Rx PDAs or no Rx packets on card. + * wait for no Rx PDAs or no Rx packets on card. */ hp100_page(PERFORMANCE); /* 100 ms timeout */ @@ -1409,7 +1425,7 @@ static void hp100_BM_shutdown(struct net_device *dev) /* To ensure all bus master outloading activity has ceased, * wait until the Tx PDA count goes to zero or no more Tx space - * available in the Tx region of the card. + * available in the Tx region of the card. */ /* 100 ms timeout */ for (time = 0; time < 10000; time++) { @@ -1432,7 +1448,7 @@ static void hp100_BM_shutdown(struct net_device *dev) static int hp100_check_lan(struct net_device *dev) { - struct hp100_private *lp = (struct hp100_private *) dev->priv; + struct hp100_private *lp = netdev_priv(dev); if (lp->lan_type < 0) { /* no LAN type detected yet? */ hp100_stop_interface(dev); @@ -1448,7 +1464,7 @@ static int hp100_check_lan(struct net_device *dev) return 0; } -/* +/* * transmit functions */ @@ -1458,7 +1474,7 @@ static int hp100_start_xmit_bm(struct sk_buff *skb, struct net_device *dev) unsigned long flags; int i, ok_flag; int ioaddr = dev->base_addr; - struct hp100_private *lp = (struct hp100_private *) dev->priv; + struct hp100_private *lp = netdev_priv(dev); hp100_ring_t *ringptr; #ifdef HP100_DEBUG_B @@ -1472,12 +1488,9 @@ static int hp100_start_xmit_bm(struct sk_buff *skb, struct net_device *dev) if (skb->len <= 0) return 0; - - if (skb->len < ETH_ZLEN && lp->chip == HP100_CHIPID_SHASTA) { - skb = skb_padto(skb, ETH_ZLEN); - if (skb == NULL) - return 0; - } + + if (lp->chip == HP100_CHIPID_SHASTA && skb_padto(skb, ETH_ZLEN)) + return 0; /* Get Tx ring tail pointer */ if (lp->txrtail->next == lp->txrhead) { @@ -1486,7 +1499,7 @@ static int hp100_start_xmit_bm(struct sk_buff *skb, struct net_device *dev) printk("hp100: %s: start_xmit_bm: No TX PDL available.\n", dev->name); #endif /* not waited long enough since last tx? */ - if (jiffies - dev->trans_start < HZ) + if (time_before(jiffies, dev->trans_start + HZ)) return -EAGAIN; if (hp100_check_lan(dev)) @@ -1565,18 +1578,18 @@ static int hp100_start_xmit_bm(struct sk_buff *skb, struct net_device *dev) return 0; } - + /* clean_txring checks if packets have been sent by the card by reading * the TX_PDL register from the performance page and comparing it to the * number of commited packets. It then frees the skb's of the packets that * obviously have been sent to the network. * - * Needs the PERFORMANCE page selected. + * Needs the PERFORMANCE page selected. */ static void hp100_clean_txring(struct net_device *dev) { - struct hp100_private *lp = (struct hp100_private *) dev->priv; + struct hp100_private *lp = netdev_priv(dev); int ioaddr = dev->base_addr; int donecount; @@ -1615,7 +1628,7 @@ static int hp100_start_xmit(struct sk_buff *skb, struct net_device *dev) int i, ok_flag; int ioaddr = dev->base_addr; u_short val; - struct hp100_private *lp = (struct hp100_private *) dev->priv; + struct hp100_private *lp = netdev_priv(dev); #ifdef HP100_DEBUG_B hp100_outw(0x4212, TRACE); @@ -1639,7 +1652,7 @@ static int hp100_start_xmit(struct sk_buff *skb, struct net_device *dev) printk("hp100: %s: start_xmit: tx free mem = 0x%x\n", dev->name, i); #endif /* not waited long enough since last failed tx try? */ - if (jiffies - dev->trans_start < HZ) { + if (time_before(jiffies, dev->trans_start + HZ)) { #ifdef HP100_DEBUG printk("hp100: %s: trans_start timing problem\n", dev->name); @@ -1705,17 +1718,10 @@ static int hp100_start_xmit(struct sk_buff *skb, struct net_device *dev) hp100_outw(i, FRAGMENT_LEN); /* and first/only fragment length */ if (lp->mode == 2) { /* memory mapped */ - if (lp->mem_ptr_virt) { /* high pci memory was remapped */ - /* Note: The J2585B needs alignment to 32bits here! */ - memcpy_toio(lp->mem_ptr_virt, skb->data, (skb->len + 3) & ~3); - if (!ok_flag) - memset_io(lp->mem_ptr_virt, 0, HP100_MIN_PACKET_SIZE - skb->len); - } else { - /* Note: The J2585B needs alignment to 32bits here! */ - isa_memcpy_toio(lp->mem_ptr_phys, skb->data, (skb->len + 3) & ~3); - if (!ok_flag) - isa_memset_io(lp->mem_ptr_phys, 0, HP100_MIN_PACKET_SIZE - skb->len); - } + /* Note: The J2585B needs alignment to 32bits here! */ + memcpy_toio(lp->mem_ptr_virt, skb->data, (skb->len + 3) & ~3); + if (!ok_flag) + memset_io(lp->mem_ptr_virt, 0, HP100_MIN_PACKET_SIZE - skb->len); } else { /* programmed i/o */ outsl(ioaddr + HP100_REG_DATA32, skb->data, (skb->len + 3) >> 2); @@ -1740,22 +1746,22 @@ static int hp100_start_xmit(struct sk_buff *skb, struct net_device *dev) return 0; } - + /* * Receive Function (Non-Busmaster mode) - * Called when an "Receive Packet" interrupt occurs, i.e. the receive + * Called when an "Receive Packet" interrupt occurs, i.e. the receive * packet counter is non-zero. * For non-busmaster, this function does the whole work of transfering * the packet to the host memory and then up to higher layers via skb - * and netif_rx. + * and netif_rx. */ static void hp100_rx(struct net_device *dev) { int packets, pkt_len; int ioaddr = dev->base_addr; - struct hp100_private *lp = (struct hp100_private *) dev->priv; + struct hp100_private *lp = netdev_priv(dev); u_int header; struct sk_buff *skb; @@ -1785,10 +1791,7 @@ static void hp100_rx(struct net_device *dev) /* First we get the header, which contains information about the */ /* actual length of the received packet. */ if (lp->mode == 2) { /* memory mapped mode */ - if (lp->mem_ptr_virt) /* if memory was remapped */ - header = readl(lp->mem_ptr_virt); - else - header = isa_readl(lp->mem_ptr_phys); + header = readl(lp->mem_ptr_virt); } else /* programmed i/o */ header = hp100_inl(DATA32); @@ -1820,13 +1823,9 @@ static void hp100_rx(struct net_device *dev) ptr = skb->data; /* Now transfer the data from the card into that area */ - if (lp->mode == 2) { - if (lp->mem_ptr_virt) - memcpy_fromio(ptr, lp->mem_ptr_virt,pkt_len); - /* Note alignment to 32bit transfers */ - else - isa_memcpy_fromio(ptr, lp->mem_ptr_phys, pkt_len); - } else /* io mapped */ + if (lp->mode == 2) + memcpy_fromio(ptr, lp->mem_ptr_virt,pkt_len); + else /* io mapped */ insl(ioaddr + HP100_REG_DATA32, ptr, pkt_len >> 2); skb->protocol = eth_type_trans(skb, dev); @@ -1858,13 +1857,13 @@ static void hp100_rx(struct net_device *dev) #endif } -/* +/* * Receive Function for Busmaster Mode */ static void hp100_rx_bm(struct net_device *dev) { int ioaddr = dev->base_addr; - struct hp100_private *lp = (struct hp100_private *) dev->priv; + struct hp100_private *lp = netdev_priv(dev); hp100_ring_t *ptr; u_int header; int pkt_len; @@ -1879,7 +1878,7 @@ static void hp100_rx_bm(struct net_device *dev) printk("hp100: %s: rx_bm called although no PDLs were committed to adapter?\n", dev->name); return; } else - /* RX_PKT_CNT states how many PDLs are currently formatted and available to + /* RX_PKT_CNT states how many PDLs are currently formatted and available to * the cards BM engine */ if ((hp100_inw(RX_PKT_CNT) & 0x00ff) >= lp->rxrcommit) { printk("hp100: %s: More packets received than commited? RX_PKT_CNT=0x%x, commit=0x%x\n", @@ -1892,7 +1891,7 @@ static void hp100_rx_bm(struct net_device *dev) while ((lp->rxrcommit > hp100_inb(RX_PDL))) { /* * The packet was received into the pdl pointed to by lp->rxrhead ( - * the oldest pdl in the ring + * the oldest pdl in the ring */ /* First we get the header, which contains information about the */ @@ -1973,7 +1972,7 @@ static struct net_device_stats *hp100_get_stats(struct net_device *dev) { unsigned long flags; int ioaddr = dev->base_addr; - struct hp100_private *lp = (struct hp100_private *) dev->priv; + struct hp100_private *lp = netdev_priv(dev); #ifdef HP100_DEBUG_B hp100_outw(0x4215, TRACE); @@ -1991,7 +1990,7 @@ static void hp100_update_stats(struct net_device *dev) { int ioaddr = dev->base_addr; u_short val; - struct hp100_private *lp = (struct hp100_private *) dev->priv; + struct hp100_private *lp = netdev_priv(dev); #ifdef HP100_DEBUG_B hp100_outw(0x4216, TRACE); @@ -2017,7 +2016,7 @@ static void hp100_misc_interrupt(struct net_device *dev) #ifdef HP100_DEBUG_B int ioaddr = dev->base_addr; #endif - struct hp100_private *lp = (struct hp100_private *) dev->priv; + struct hp100_private *lp = netdev_priv(dev); #ifdef HP100_DEBUG_B int ioaddr = dev->base_addr; @@ -2047,7 +2046,7 @@ static void hp100_clear_stats(struct hp100_private *lp, int ioaddr) hp100_page(PERFORMANCE); spin_unlock_irqrestore(&lp->lock, flags); } - + /* * multicast setup @@ -2061,7 +2060,7 @@ static void hp100_set_multicast_list(struct net_device *dev) { unsigned long flags; int ioaddr = dev->base_addr; - struct hp100_private *lp = (struct hp100_private *) dev->priv; + struct hp100_private *lp = netdev_priv(dev); #ifdef HP100_DEBUG_B hp100_outw(0x4218, TRACE); @@ -2188,10 +2187,10 @@ static void hp100_set_multicast_list(struct net_device *dev) * hardware interrupt handling */ -static irqreturn_t hp100_interrupt(int irq, void *dev_id, struct pt_regs *regs) +static irqreturn_t hp100_interrupt(int irq, void *dev_id) { struct net_device *dev = (struct net_device *) dev_id; - struct hp100_private *lp = (struct hp100_private *) dev->priv; + struct hp100_private *lp = netdev_priv(dev); int ioaddr; u_int val; @@ -2224,9 +2223,9 @@ static irqreturn_t hp100_interrupt(int irq, void *dev_id, struct pt_regs *regs) /* We're only interested in those interrupts we really enabled. */ /* val &= hp100_inw( IRQ_MASK ); */ - /* - * RX_PDL_FILL_COMPL is set whenever a RX_PDL has been executed. A RX_PDL - * is considered executed whenever the RX_PDL data structure is no longer + /* + * RX_PDL_FILL_COMPL is set whenever a RX_PDL has been executed. A RX_PDL + * is considered executed whenever the RX_PDL data structure is no longer * needed. */ if (val & HP100_RX_PDL_FILL_COMPL) { @@ -2237,7 +2236,7 @@ static irqreturn_t hp100_interrupt(int irq, void *dev_id, struct pt_regs *regs) } } - /* + /* * The RX_PACKET interrupt is set, when the receive packet counter is * non zero. We use this interrupt for receiving in slave mode. In * busmaster mode, we use it to make sure we did not miss any rx_pdl_fill @@ -2263,10 +2262,10 @@ static irqreturn_t hp100_interrupt(int irq, void *dev_id, struct pt_regs *regs) hp100_outw(val, IRQ_STATUS); /* - * RX_ERROR is set when a packet is dropped due to no memory resources on - * the card or when a RCV_ERR occurs. - * TX_ERROR is set when a TX_ABORT condition occurs in the MAC->exists - * only in the 802.3 MAC and happens when 16 collisions occur during a TX + * RX_ERROR is set when a packet is dropped due to no memory resources on + * the card or when a RCV_ERR occurs. + * TX_ERROR is set when a TX_ABORT condition occurs in the MAC->exists + * only in the 802.3 MAC and happens when 16 collisions occur during a TX */ if (val & (HP100_TX_ERROR | HP100_RX_ERROR)) { #ifdef HP100_DEBUG_IRQ @@ -2279,20 +2278,20 @@ static irqreturn_t hp100_interrupt(int irq, void *dev_id, struct pt_regs *regs) } } - /* - * RX_PDA_ZERO is set when the PDA count goes from non-zero to zero. + /* + * RX_PDA_ZERO is set when the PDA count goes from non-zero to zero. */ if ((lp->mode == 1) && (val & (HP100_RX_PDA_ZERO))) hp100_rxfill(dev); - /* - * HP100_TX_COMPLETE interrupt occurs when packet transmitted on wire - * is completed + /* + * HP100_TX_COMPLETE interrupt occurs when packet transmitted on wire + * is completed */ if ((lp->mode == 1) && (val & (HP100_TX_COMPLETE))) hp100_clean_txring(dev); - /* + /* * MISC_ERROR is set when either the LAN link goes down or a detected * bus error occurs. */ @@ -2322,7 +2321,7 @@ static void hp100_start_interface(struct net_device *dev) { unsigned long flags; int ioaddr = dev->base_addr; - struct hp100_private *lp = (struct hp100_private *) dev->priv; + struct hp100_private *lp = netdev_priv(dev); #ifdef HP100_DEBUG_B hp100_outw(0x4220, TRACE); @@ -2381,7 +2380,7 @@ static void hp100_start_interface(struct net_device *dev) static void hp100_stop_interface(struct net_device *dev) { - struct hp100_private *lp = (struct hp100_private *) dev->priv; + struct hp100_private *lp = netdev_priv(dev); int ioaddr = dev->base_addr; u_int val; @@ -2442,7 +2441,7 @@ static int hp100_sense_lan(struct net_device *dev) { int ioaddr = dev->base_addr; u_short val_VG, val_10; - struct hp100_private *lp = (struct hp100_private *) dev->priv; + struct hp100_private *lp = netdev_priv(dev); #ifdef HP100_DEBUG_B hp100_outw(0x4223, TRACE); @@ -2475,12 +2474,12 @@ static int hp100_sense_lan(struct net_device *dev) /* Those cards don't have a 100 Mbit connector */ if ( !strcmp(lp->id, "HWP1920") || - (lp->pci_dev && - lp->pci_dev->vendor == PCI_VENDOR_ID && + (lp->pci_dev && + lp->pci_dev->vendor == PCI_VENDOR_ID && (lp->pci_dev->device == PCI_DEVICE_ID_HP_J2970A || lp->pci_dev->device == PCI_DEVICE_ID_HP_J2973A))) return HP100_LAN_ERR; - + if (val_VG & HP100_LINK_CABLE_ST) /* Can hear the HUBs tone. */ return HP100_LAN_100; return HP100_LAN_ERR; @@ -2488,7 +2487,7 @@ static int hp100_sense_lan(struct net_device *dev) static int hp100_down_vg_link(struct net_device *dev) { - struct hp100_private *lp = (struct hp100_private *) dev->priv; + struct hp100_private *lp = netdev_priv(dev); int ioaddr = dev->base_addr; unsigned long time; long savelan, newlan; @@ -2503,10 +2502,8 @@ static int hp100_down_vg_link(struct net_device *dev) do { if (hp100_inb(VG_LAN_CFG_1) & HP100_LINK_CABLE_ST) break; - if (!in_interrupt()) { - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(1); - } + if (!in_interrupt()) + schedule_timeout_interruptible(1); } while (time_after(time, jiffies)); if (time_after_eq(jiffies, time)) /* no signal->no logout */ @@ -2522,10 +2519,8 @@ static int hp100_down_vg_link(struct net_device *dev) do { if (!(hp100_inb(VG_LAN_CFG_1) & HP100_LINK_UP_ST)) break; - if (!in_interrupt()) { - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(1); - } + if (!in_interrupt()) + schedule_timeout_interruptible(1); } while (time_after(time, jiffies)); #ifdef HP100_DEBUG @@ -2563,10 +2558,8 @@ static int hp100_down_vg_link(struct net_device *dev) do { if (!(hp100_inb(MAC_CFG_4) & HP100_MAC_SEL_ST)) break; - if (!in_interrupt()) { - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(1); - } + if (!in_interrupt()) + schedule_timeout_interruptible(1); } while (time_after(time, jiffies)); hp100_orb(HP100_AUTO_MODE, MAC_CFG_3); /* Autosel back on */ @@ -2577,10 +2570,8 @@ static int hp100_down_vg_link(struct net_device *dev) do { if ((hp100_inb(VG_LAN_CFG_1) & HP100_LINK_CABLE_ST) == 0) break; - if (!in_interrupt()) { - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(1); - } + if (!in_interrupt()) + schedule_timeout_interruptible(1); } while (time_after(time, jiffies)); if (time_before_eq(time, jiffies)) { @@ -2592,10 +2583,8 @@ static int hp100_down_vg_link(struct net_device *dev) time = jiffies + (2 * HZ); /* This seems to take a while.... */ do { - if (!in_interrupt()) { - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(1); - } + if (!in_interrupt()) + schedule_timeout_interruptible(1); } while (time_after(time, jiffies)); return 0; @@ -2604,7 +2593,7 @@ static int hp100_down_vg_link(struct net_device *dev) static int hp100_login_to_vg_hub(struct net_device *dev, u_short force_relogin) { int ioaddr = dev->base_addr; - struct hp100_private *lp = (struct hp100_private *) dev->priv; + struct hp100_private *lp = netdev_priv(dev); u_short val = 0; unsigned long time; int startst; @@ -2645,10 +2634,8 @@ static int hp100_login_to_vg_hub(struct net_device *dev, u_short force_relogin) do { if (~(hp100_inb(VG_LAN_CFG_1) & HP100_LINK_UP_ST)) break; - if (!in_interrupt()) { - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(1); - } + if (!in_interrupt()) + schedule_timeout_interruptible(1); } while (time_after(time, jiffies)); /* Start an addressed training and optionally request promiscuous port */ @@ -2683,10 +2670,8 @@ static int hp100_login_to_vg_hub(struct net_device *dev, u_short force_relogin) do { if (hp100_inb(VG_LAN_CFG_1) & HP100_LINK_CABLE_ST) break; - if (!in_interrupt()) { - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(1); - } + if (!in_interrupt()) + schedule_timeout_interruptible(1); } while (time_before(jiffies, time)); if (time_after_eq(jiffies, time)) { @@ -2709,10 +2694,8 @@ static int hp100_login_to_vg_hub(struct net_device *dev, u_short force_relogin) #endif break; } - if (!in_interrupt()) { - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(1); - } + if (!in_interrupt()) + schedule_timeout_interruptible(1); } while (time_after(time, jiffies)); } @@ -2775,7 +2758,7 @@ static int hp100_login_to_vg_hub(struct net_device *dev, u_short force_relogin) static void hp100_cascade_reset(struct net_device *dev, u_short enable) { int ioaddr = dev->base_addr; - struct hp100_private *lp = (struct hp100_private *) dev->priv; + struct hp100_private *lp = netdev_priv(dev); #ifdef HP100_DEBUG_B hp100_outw(0x4226, TRACE); @@ -2836,14 +2819,14 @@ void hp100_RegisterDump(struct net_device *dev) static void cleanup_dev(struct net_device *d) { - struct hp100_private *p = (struct hp100_private *) d->priv; + struct hp100_private *p = netdev_priv(d); unregister_netdev(d); release_region(d->base_addr, HP100_REGION_SIZE); if (p->mode == 1) /* busmaster */ - pci_free_consistent(p->pci_dev, MAX_RINGSIZE + 0x0f, - p->page_vaddr_algn, + pci_free_consistent(p->pci_dev, MAX_RINGSIZE + 0x0f, + p->page_vaddr_algn, virt_to_whatever(d, p->page_vaddr_algn)); if (p->mem_ptr_virt) iounmap(p->mem_ptr_virt); @@ -2868,18 +2851,12 @@ static int __init hp100_eisa_probe (struct device *gendev) if (err) goto out1; - err = register_netdev(dev); - if (err) - goto out2; - #ifdef HP100_DEBUG - printk("hp100: %s: EISA adapter found at 0x%x\n", dev->name, + printk("hp100: %s: EISA adapter found at 0x%x\n", dev->name, dev->base_addr); #endif gendev->driver_data = dev; return 0; - out2: - release_region(dev->base_addr, HP100_REGION_SIZE); out1: free_netdev(dev); return err; @@ -2939,22 +2916,17 @@ static int __devinit hp100_pci_probe (struct pci_dev *pdev, pci_command |= PCI_COMMAND_MASTER; pci_write_config_word(pdev, PCI_COMMAND, pci_command); } - + ioaddr = pci_resource_start(pdev, 0); err = hp100_probe1(dev, ioaddr, HP100_BUS_PCI, pdev); - if (err) - goto out1; - err = register_netdev(dev); if (err) - goto out2; - + goto out1; + #ifdef HP100_DEBUG printk("hp100: %s: PCI adapter found at 0x%x\n", dev->name, ioaddr); #endif pci_set_drvdata(pdev, dev); return 0; - out2: - release_region(dev->base_addr, HP100_REGION_SIZE); out1: free_netdev(dev); out0: @@ -2998,7 +2970,7 @@ MODULE_DESCRIPTION("HP CASCADE Architecture Driver for 100VG-AnyLan Network Adap #define HP100_DEVICES 5 /* Parameters set by insmod */ static int hp100_port[HP100_DEVICES] = { 0, [1 ... (HP100_DEVICES-1)] = -1 }; -MODULE_PARM(hp100_port, "1-" __MODULE_STRING(HP100_DEVICES) "i"); +module_param_array(hp100_port, int, NULL, 0); /* List of devices */ static struct net_device *hp100_devlist[HP100_DEVICES]; @@ -3025,22 +2997,16 @@ static int __init hp100_isa_init(void) SET_MODULE_OWNER(dev); err = hp100_isa_probe(dev, hp100_port[i]); - if (!err) { - err = register_netdev(dev); - if (!err) - hp100_devlist[cards++] = dev; - else - release_region(dev->base_addr, HP100_REGION_SIZE); - } - - if (err) + if (!err) + hp100_devlist[cards++] = dev; + else free_netdev(dev); } return cards > 0 ? 0 : -ENODEV; } -static void __exit hp100_isa_cleanup(void) +static void __exit hp100_isa_cleanup(void) { int i; @@ -3064,12 +3030,12 @@ static int __init hp100_module_init(void) goto out; #ifdef CONFIG_EISA err = eisa_driver_register(&hp100_eisa_driver); - if (err && err != -ENODEV) + if (err && err != -ENODEV) goto out2; #endif #ifdef CONFIG_PCI err = pci_module_init(&hp100_pci_driver); - if (err && err != -ENODEV) + if (err && err != -ENODEV) goto out3; #endif out: