X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fnet%2Flance.c;h=f04d0a82cf3b847b6e7aacf87a215703b62fbf84;hb=9bf4aaab3e101692164d49b7ca357651eb691cb6;hp=fc1f9e90264daca69dff682d656d66ecd023e1ec;hpb=5273a3df6485dc2ad6aa7ddd441b9a21970f003b;p=linux-2.6.git diff --git a/drivers/net/lance.c b/drivers/net/lance.c index fc1f9e902..f04d0a82c 100644 --- a/drivers/net/lance.c +++ b/drivers/net/lance.c @@ -37,6 +37,9 @@ Get rid of check_region, check kmalloc return in lance_probe1 Arnaldo Carvalho de Melo - 11/01/2001 + + Reworked detection, added support for Racal InterLan EtherBlaster cards + Vesselin Kostadinov - 22/4/2004 */ static const char version[] = "lance.c:v1.15ac 1999/11/13 dplatt@3do.com, becker@cesdis.gsfc.nasa.gov\n"; @@ -62,6 +65,26 @@ static unsigned int lance_portlist[] __initdata = { 0x300, 0x320, 0x340, 0x360, static int lance_probe1(struct net_device *dev, int ioaddr, int irq, int options); static int __init do_lance_probe(struct net_device *dev); + +static struct card { + char id_offset14; + char id_offset15; +} cards[] = { + { //"normal" + .id_offset14 = 0x57, + .id_offset15 = 0x57, + }, + { //NI6510EB + .id_offset14 = 0x52, + .id_offset15 = 0x44, + }, + { //Racal InterLan EtherBlaster + .id_offset14 = 0x52, + .id_offset15 = 0x49, + }, +}; +#define NUM_CARDS 3 + #ifdef LANCE_DEBUG static int lance_debug = LANCE_DEBUG; #else @@ -380,13 +403,20 @@ static int __init do_lance_probe(struct net_device *dev) "lance-probe"); if (r) { - /* Detect "normal" 0x57 0x57 and the NI6510EB 0x52 0x44 - signatures w/ minimal I/O reads */ - char offset15, offset14 = inb(ioaddr + 14); - - if ((offset14 == 0x52 || offset14 == 0x57) && - ((offset15 = inb(ioaddr + 15)) == 0x57 || - offset15 == 0x44)) { + /* Detect the card with minimal I/O reads */ + char offset14 = inb(ioaddr + 14); + int card; + for (card = 0; card < NUM_CARDS; ++card) + if (cards[card].id_offset14 == offset14) + break; + if (card < NUM_CARDS) {/*yes, the first byte matches*/ + char offset15 = inb(ioaddr + 15); + for (card = 0; card < NUM_CARDS; ++card) + if ((cards[card].id_offset14 == offset14) && + (cards[card].id_offset15 == offset15)) + break; + } + if (card < NUM_CARDS) { /*Signature OK*/ result = lance_probe1(dev, ioaddr, 0, 0); if (!result) { struct lance_private *lp = dev->priv; @@ -402,6 +432,7 @@ static int __init do_lance_probe(struct net_device *dev) return -ENODEV; } +#ifndef MODULE struct net_device * __init lance_probe(int unit) { struct net_device *dev = alloc_etherdev(0); @@ -426,6 +457,7 @@ out: free_netdev(dev); return ERR_PTR(err); } +#endif static int __init lance_probe1(struct net_device *dev, int ioaddr, int irq, int options) { @@ -802,7 +834,7 @@ lance_purge_ring(struct net_device *dev) /* Free all the skbuffs in the Rx and Tx queues. */ for (i = 0; i < RX_RING_SIZE; i++) { struct sk_buff *skb = lp->rx_skbuff[i]; - lp->rx_skbuff[i] = 0; + lp->rx_skbuff[i] = NULL; lp->rx_ring[i].base = 0; /* Not owned by LANCE chip. */ if (skb) dev_kfree_skb_any(skb); @@ -846,7 +878,7 @@ lance_init_ring(struct net_device *dev, int gfp) /* The Tx buffer address is filled in as needed, but we do need to clear the upper ownership bit. */ for (i = 0; i < TX_RING_SIZE; i++) { - lp->tx_skbuff[i] = 0; + lp->tx_skbuff[i] = NULL; lp->tx_ring[i].base = 0; } @@ -1051,7 +1083,7 @@ lance_interrupt(int irq, void *dev_id, struct pt_regs * regs) in the bounce buffer. */ if (lp->tx_skbuff[entry]) { dev_kfree_skb_irq(lp->tx_skbuff[entry]); - lp->tx_skbuff[entry] = 0; + lp->tx_skbuff[entry] = NULL; } dirty_tx++; }