patch-2.1.25 linux/drivers/net/ni65.c

Next file: linux/drivers/net/pi2.c
Previous file: linux/drivers/net/ni52.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.24/linux/drivers/net/ni65.c linux/drivers/net/ni65.c
@@ -195,27 +195,27 @@
 
 struct priv
 {
-  struct rmd rmdhead[RMDNUM];
-  struct tmd tmdhead[TMDNUM];
-  struct init_block ib;
-  int rmdnum;
-  int tmdnum,tmdlast;
+	struct rmd rmdhead[RMDNUM];
+	struct tmd tmdhead[TMDNUM];
+	struct init_block ib;
+	int rmdnum;
+	int tmdnum,tmdlast;
 #ifdef RCV_VIA_SKB
-  struct sk_buff *recv_skb[RMDNUM];
+	struct sk_buff *recv_skb[RMDNUM];
 #else
-  void *recvbounce[RMDNUM];
+	void *recvbounce[RMDNUM];
 #endif
 #ifdef XMT_VIA_SKB
-  struct sk_buff *tmd_skb[TMDNUM];
+	struct sk_buff *tmd_skb[TMDNUM];
 #endif
-  void *tmdbounce[TMDNUM];
-  int tmdbouncenum;
-  int lock,xmit_queued;
-  struct enet_statistics stats;
-  void *self;
-  int cmdr_addr;
-  int cardno;
-  int features;
+	void *tmdbounce[TMDNUM];
+	int tmdbouncenum;
+	int lock,xmit_queued;
+	struct net_device_stats stats;
+	void *self;
+	int cmdr_addr;
+	int cardno;
+	int features;
 };
 
 static int  ni65_probe1(struct device *dev,int);
@@ -229,7 +229,7 @@
 static int  ni65_close(struct device *dev);
 static int  ni65_alloc_buffer(struct device *dev);
 static void ni65_free_buffer(struct priv *p);
-static struct enet_statistics *ni65_get_stats(struct device *);
+static struct net_device_stats *ni65_get_stats(struct device *);
 static void set_multicast_list(struct device *dev);
 
 static int irqtab[] = { 9,12,15,5 }; /* irq config-translate */
@@ -242,22 +242,22 @@
  */
 static void ni65_set_performance(struct priv *p)
 {
-  writereg(CSR0_STOP | CSR0_CLRALL,CSR0); /* STOP */
+	writereg(CSR0_STOP | CSR0_CLRALL,CSR0); /* STOP */
 
-  if( !(cards[p->cardno].config & 0x02) )
-    return;
+	if( !(cards[p->cardno].config & 0x02) )
+		return;
 
-  outw(80,PORT+L_ADDRREG);
-  if(inw(PORT+L_ADDRREG) != 80)
-    return;
-
-  writereg( (csr80 & 0x3fff) ,80); /* FIFO watermarks */
-  outw(0,PORT+L_ADDRREG);
-  outw((short)isa0,PORT+L_BUSIF); /* write ISA 0: DMA_R : isa0 * 50ns */
-  outw(1,PORT+L_ADDRREG);
-  outw((short)isa1,PORT+L_BUSIF); /* write ISA 1: DMA_W : isa1 * 50ns  */
+	outw(80,PORT+L_ADDRREG);
+	if(inw(PORT+L_ADDRREG) != 80)
+		return;
+
+	writereg( (csr80 & 0x3fff) ,80); /* FIFO watermarks */
+	outw(0,PORT+L_ADDRREG);
+	outw((short)isa0,PORT+L_BUSIF); /* write ISA 0: DMA_R : isa0 * 50ns */
+	outw(1,PORT+L_ADDRREG);
+	outw((short)isa1,PORT+L_BUSIF); /* write ISA 1: DMA_W : isa1 * 50ns	*/
 
-  outw(CSR0,PORT+L_ADDRREG);	/* switch back to CSR0 */
+	outw(CSR0,PORT+L_ADDRREG);	/* switch back to CSR0 */
 }
 
 /*
@@ -265,31 +265,31 @@
  */
 static int ni65_open(struct device *dev)
 {
-  struct priv *p = (struct priv *) dev->priv;
-  int irqval = request_irq(dev->irq, &ni65_interrupt,0,
+	struct priv *p = (struct priv *) dev->priv;
+	int irqval = request_irq(dev->irq, &ni65_interrupt,0,
                         cards[p->cardno].cardname,NULL);
-  if (irqval) {
-    printk ("%s: unable to get IRQ %d (irqval=%d).\n",
-              dev->name,dev->irq, irqval);
-    return -EAGAIN;
-  }
-  irq2dev_map[dev->irq] = dev;
-
-  if(ni65_lance_reinit(dev))
-  {
-    dev->tbusy     = 0;
-    dev->interrupt = 0;
-    dev->start     = 1;
-    MOD_INC_USE_COUNT;
-    return 0;
-  }
-  else
-  {
-    irq2dev_map[dev->irq] = NULL;
-    free_irq(dev->irq,NULL);
-    dev->start = 0;
-    return -EAGAIN;
-  }
+	if (irqval) {
+		printk ("%s: unable to get IRQ %d (irqval=%d).\n",
+		          dev->name,dev->irq, irqval);
+		return -EAGAIN;
+	}
+	irq2dev_map[dev->irq] = dev;
+
+	if(ni65_lance_reinit(dev))
+	{
+		dev->tbusy     = 0;
+		dev->interrupt = 0;
+		dev->start     = 1;
+		MOD_INC_USE_COUNT;
+		return 0;
+	}
+	else
+	{
+		irq2dev_map[dev->irq] = NULL;
+		free_irq(dev->irq,NULL);
+		dev->start = 0;
+		return -EAGAIN;
+	}
 }
 
 /*
@@ -297,28 +297,28 @@
  */
 static int ni65_close(struct device *dev)
 {
-  struct priv *p = (struct priv *) dev->priv;
+	struct priv *p = (struct priv *) dev->priv;
 
-  outw(inw(PORT+L_RESET),PORT+L_RESET); /* that's the hard way */
+	outw(inw(PORT+L_RESET),PORT+L_RESET); /* that's the hard way */
 
 #ifdef XMT_VIA_SKB
-  {
-    int i;
-    for(i=0;i<TMDNUM;i++)
-    {
-      if(p->tmd_skb[i]) {
-        dev_kfree_skb(p->tmd_skb[i],FREE_WRITE);
-        p->tmd_skb[i] = NULL;
-      }
-    }
-  }
-#endif
-  irq2dev_map[dev->irq] = NULL;
-  free_irq(dev->irq,NULL);
-  dev->tbusy = 1;
-  dev->start = 0;
-  MOD_DEC_USE_COUNT;
-  return 0;
+	{
+		int i;
+		for(i=0;i<TMDNUM;i++)
+		{
+			if(p->tmd_skb[i]) {
+				dev_kfree_skb(p->tmd_skb[i],FREE_WRITE);
+				p->tmd_skb[i] = NULL;
+			}
+		}
+	}
+#endif
+	irq2dev_map[dev->irq] = NULL;
+	free_irq(dev->irq,NULL);
+	dev->tbusy = 1;
+	dev->start = 0;
+	MOD_DEC_USE_COUNT;
+	return 0;
 }
 
 /*
@@ -329,21 +329,21 @@
 #endif
 int ni65_probe(struct device *dev)
 {
-  int *port;
-  static int ports[] = {0x360,0x300,0x320,0x340, 0};
+	int *port;
+	static int ports[] = {0x360,0x300,0x320,0x340, 0};
 
-  if (dev->base_addr > 0x1ff)          /* Check a single specified location. */
-     return ni65_probe1(dev, dev->base_addr);
-  else if (dev->base_addr > 0)         /* Don't probe at all. */
-     return -ENXIO;
-
-  for (port = ports; *port; port++)
-  {
-    if (ni65_probe1(dev, *port) == 0)
-       return 0;
-  }
+	if (dev->base_addr > 0x1ff)          /* Check a single specified location. */
+		 return ni65_probe1(dev, dev->base_addr);
+	else if (dev->base_addr > 0)         /* Don't probe at all. */
+		 return -ENXIO;
+
+	for (port = ports; *port; port++)
+	{
+		if (ni65_probe1(dev, *port) == 0)
+			 return 0;
+	}
 
-  return -ENODEV;
+	return -ENODEV;
 }
 
 /*
@@ -351,139 +351,139 @@
  */
 static int ni65_probe1(struct device *dev,int ioaddr)
 {
-  int i,j;
-  struct priv *p;
+	int i,j;
+	struct priv *p;
 
-  for(i=0;i<NUM_CARDS;i++) {
-    if(check_region(ioaddr, cards[i].total_size))
-      continue;
-    if(cards[i].id_offset >= 0) {
-      if(inb(ioaddr+cards[i].id_offset+0) != cards[i].id0 ||
-         inb(ioaddr+cards[i].id_offset+1) != cards[i].id1) {
-         continue;
-      }
-    }
-    if(cards[i].vendor_id) {
-      for(j=0;j<3;j++)
-        if(inb(ioaddr+cards[i].addr_offset+j) != cards[i].vendor_id[j])
-          continue;
-    }
-    break;
-  }
-  if(i == NUM_CARDS)
-    return -ENODEV;
-
-  for(j=0;j<6;j++)
-    dev->dev_addr[j] = inb(ioaddr+cards[i].addr_offset+j);
-
-  if( (j=ni65_alloc_buffer(dev)) < 0)
-    return j;
-  p = (struct priv *) dev->priv;
-  p->cmdr_addr = ioaddr + cards[i].cmd_offset;
-  p->cardno = i;
-
-  printk("%s: %s found at %#3x, ", dev->name, cards[p->cardno].cardname , ioaddr);
-
-  outw(inw(PORT+L_RESET),PORT+L_RESET); /* first: reset the card */
-  if( (j=readreg(CSR0)) != 0x4) {
-     printk(KERN_ERR "can't RESET card: %04x\n",j);
-     ni65_free_buffer(p);
-     return -EAGAIN;
-  }
-
-  outw(88,PORT+L_ADDRREG);
-  if(inw(PORT+L_ADDRREG) == 88) {
-    unsigned long v;
-    v = inw(PORT+L_DATAREG);
-    v <<= 16;
-    outw(89,PORT+L_ADDRREG);
-    v |= inw(PORT+L_DATAREG);
-    printk("Version %#08lx, ",v);
-    p->features = INIT_RING_BEFORE_START;
-  }
-  else {
-    printk("ancient LANCE, ");
-    p->features = 0x0;
-  }
-
-  if(test_bit(0,&cards[i].config)) {
-    dev->irq = irqtab[(inw(ioaddr+L_CONFIG)>>2)&3];
-    dev->dma = dmatab[inw(ioaddr+L_CONFIG)&3];
-    printk("IRQ %d (from card), DMA %d (from card).\n",dev->irq,dev->dma);
-  }
-  else {
-    if(dev->dma == 0) {
+	for(i=0;i<NUM_CARDS;i++) {
+		if(check_region(ioaddr, cards[i].total_size))
+			continue;
+		if(cards[i].id_offset >= 0) {
+			if(inb(ioaddr+cards[i].id_offset+0) != cards[i].id0 ||
+				 inb(ioaddr+cards[i].id_offset+1) != cards[i].id1) {
+				 continue;
+			}
+		}
+		if(cards[i].vendor_id) {
+			for(j=0;j<3;j++)
+				if(inb(ioaddr+cards[i].addr_offset+j) != cards[i].vendor_id[j])
+					continue;
+		}
+		break;
+	}
+	if(i == NUM_CARDS)
+		return -ENODEV;
+
+	for(j=0;j<6;j++)
+		dev->dev_addr[j] = inb(ioaddr+cards[i].addr_offset+j);
+
+	if( (j=ni65_alloc_buffer(dev)) < 0)
+		return j;
+	p = (struct priv *) dev->priv;
+	p->cmdr_addr = ioaddr + cards[i].cmd_offset;
+	p->cardno = i;
+
+	printk("%s: %s found at %#3x, ", dev->name, cards[p->cardno].cardname , ioaddr);
+
+	outw(inw(PORT+L_RESET),PORT+L_RESET); /* first: reset the card */
+	if( (j=readreg(CSR0)) != 0x4) {
+		 printk(KERN_ERR "can't RESET card: %04x\n",j);
+		 ni65_free_buffer(p);
+		 return -EAGAIN;
+	}
+
+	outw(88,PORT+L_ADDRREG);
+	if(inw(PORT+L_ADDRREG) == 88) {
+		unsigned long v;
+		v = inw(PORT+L_DATAREG);
+		v <<= 16;
+		outw(89,PORT+L_ADDRREG);
+		v |= inw(PORT+L_DATAREG);
+		printk("Version %#08lx, ",v);
+		p->features = INIT_RING_BEFORE_START;
+	}
+	else {
+		printk("ancient LANCE, ");
+		p->features = 0x0;
+	}
+
+	if(test_bit(0,&cards[i].config)) {
+		dev->irq = irqtab[(inw(ioaddr+L_CONFIG)>>2)&3];
+		dev->dma = dmatab[inw(ioaddr+L_CONFIG)&3];
+		printk("IRQ %d (from card), DMA %d (from card).\n",dev->irq,dev->dma);
+	}
+	else {
+		if(dev->dma == 0) {
 		/* 'stuck test' from lance.c */
-      int dma_channels = ((inb(DMA1_STAT_REG) >> 4) & 0x0f) | (inb(DMA2_STAT_REG) & 0xf0);
-      for(i=1;i<5;i++) {
-        int dma = dmatab[i];
-        if(test_bit(dma,&dma_channels) || request_dma(dma,"ni6510"))
-          continue;
-        disable_dma(dma);
-        set_dma_mode(dma,DMA_MODE_CASCADE);
-        enable_dma(dma);
-        ni65_init_lance(p,dev->dev_addr,0,0); /* trigger memory access */
-        disable_dma(dma);
-        free_dma(dma);
-        if(readreg(CSR0) & CSR0_IDON)
-          break;
-      }
-      if(i == 5) {
-        printk("Can't detect DMA channel!\n");
-        ni65_free_buffer(p);
-        return -EAGAIN;
-      }
-      dev->dma = dmatab[i];
-      printk("DMA %d (autodetected), ",dev->dma);
-    }
-    else
-      printk("DMA %d (assigned), ",dev->dma);
-
-    if(dev->irq < 2)
-    {
-      ni65_init_lance(p,dev->dev_addr,0,0);
-      autoirq_setup(0);
-      writereg(CSR0_INIT|CSR0_INEA,CSR0); /* trigger interrupt */
-
-      if(!(dev->irq = autoirq_report(2)))
-      {
-        printk("Failed to detect IRQ line!\n");
-        ni65_free_buffer(p);
-        return -EAGAIN;
-      }
-      printk("IRQ %d (autodetected).\n",dev->irq);
-    }
-    else
-      printk("IRQ %d (assigned).\n",dev->irq);
-  }
-
-  if(request_dma(dev->dma, cards[p->cardno].cardname ) != 0)
-  {
-    printk("%s: Can't request dma-channel %d\n",dev->name,(int) dev->dma);
-    ni65_free_buffer(p);
-    return -EAGAIN;
-  }
-
-  /*
-   * Grab the region so we can find another board.
-   */
-  request_region(ioaddr,cards[p->cardno].total_size,cards[p->cardno].cardname);
-
-  dev->base_addr = ioaddr;
-
-  dev->open               = ni65_open;
-  dev->stop               = ni65_close;
-  dev->hard_start_xmit    = ni65_send_packet;
-  dev->get_stats          = ni65_get_stats;
-  dev->set_multicast_list = set_multicast_list;
-
-  ether_setup(dev);
-
-  dev->interrupt      = 0;
-  dev->tbusy          = 0;
-  dev->start          = 0;
+			int dma_channels = ((inb(DMA1_STAT_REG) >> 4) & 0x0f) | (inb(DMA2_STAT_REG) & 0xf0);
+			for(i=1;i<5;i++) {
+				int dma = dmatab[i];
+				if(test_bit(dma,&dma_channels) || request_dma(dma,"ni6510"))
+					continue;
+				disable_dma(dma);
+				set_dma_mode(dma,DMA_MODE_CASCADE);
+				enable_dma(dma);
+				ni65_init_lance(p,dev->dev_addr,0,0); /* trigger memory access */
+				disable_dma(dma);
+				free_dma(dma);
+				if(readreg(CSR0) & CSR0_IDON)
+					break;
+			}
+			if(i == 5) {
+				printk("Can't detect DMA channel!\n");
+				ni65_free_buffer(p);
+				return -EAGAIN;
+			}
+			dev->dma = dmatab[i];
+			printk("DMA %d (autodetected), ",dev->dma);
+		}
+		else
+			printk("DMA %d (assigned), ",dev->dma);
+
+		if(dev->irq < 2)
+		{
+			ni65_init_lance(p,dev->dev_addr,0,0);
+			autoirq_setup(0);
+			writereg(CSR0_INIT|CSR0_INEA,CSR0); /* trigger interrupt */
+
+			if(!(dev->irq = autoirq_report(2)))
+			{
+				printk("Failed to detect IRQ line!\n");
+				ni65_free_buffer(p);
+				return -EAGAIN;
+			}
+			printk("IRQ %d (autodetected).\n",dev->irq);
+		}
+		else
+			printk("IRQ %d (assigned).\n",dev->irq);
+	}
+
+	if(request_dma(dev->dma, cards[p->cardno].cardname ) != 0)
+	{
+		printk("%s: Can't request dma-channel %d\n",dev->name,(int) dev->dma);
+		ni65_free_buffer(p);
+		return -EAGAIN;
+	}
+
+	/*
+	 * Grab the region so we can find another board.
+	 */
+	request_region(ioaddr,cards[p->cardno].total_size,cards[p->cardno].cardname);
+
+	dev->base_addr = ioaddr;
+
+	dev->open		= ni65_open;
+	dev->stop		= ni65_close;
+	dev->hard_start_xmit	= ni65_send_packet;
+	dev->get_stats		= ni65_get_stats;
+	dev->set_multicast_list = set_multicast_list;
+
+	ether_setup(dev);
+
+	dev->interrupt		= 0;
+	dev->tbusy		= 0;
+	dev->start		= 0;
 
-  return 0; /* everything is OK */
+	return 0; /* everything is OK */
 }
 
 /*
@@ -491,33 +491,33 @@
  */
 static void ni65_init_lance(struct priv *p,unsigned char *daddr,int filter,int mode)
 {
-  int i;
-  u32 pib;
+	int i;
+	u32 pib;
 
-  writereg(CSR0_CLRALL|CSR0_STOP,CSR0);
+	writereg(CSR0_CLRALL|CSR0_STOP,CSR0);
 
-  for(i=0;i<6;i++)
-    p->ib.eaddr[i] = daddr[i];
+	for(i=0;i<6;i++)
+		p->ib.eaddr[i] = daddr[i];
 
-  for(i=0;i<8;i++)
-    p->ib.filter[i] = filter;
-  p->ib.mode = mode;
-
-  p->ib.trp = (u32) virt_to_bus(p->tmdhead) | TMDNUMMASK;
-  p->ib.rrp = (u32) virt_to_bus(p->rmdhead) | RMDNUMMASK;
-  writereg(0,CSR3);  /* busmaster/no word-swap */
-  pib = (u32) virt_to_bus(&p->ib);
-  writereg(pib & 0xffff,CSR1);
-  writereg(pib >> 16,CSR2);
-
-  writereg(CSR0_INIT,CSR0); /* this changes L_ADDRREG to CSR0 */
-
-  for(i=0;i<32;i++)
-  {
-    udelay(4000);
-    if(inw(PORT+L_DATAREG) & (CSR0_IDON | CSR0_MERR) )
-      break; /* init ok ? */
-  }
+	for(i=0;i<8;i++)
+		p->ib.filter[i] = filter;
+	p->ib.mode = mode;
+
+	p->ib.trp = (u32) virt_to_bus(p->tmdhead) | TMDNUMMASK;
+	p->ib.rrp = (u32) virt_to_bus(p->rmdhead) | RMDNUMMASK;
+	writereg(0,CSR3);	/* busmaster/no word-swap */
+	pib = (u32) virt_to_bus(&p->ib);
+	writereg(pib & 0xffff,CSR1);
+	writereg(pib >> 16,CSR2);
+
+	writereg(CSR0_INIT,CSR0); /* this changes L_ADDRREG to CSR0 */
+
+	for(i=0;i<32;i++)
+	{
+		udelay(4000);
+		if(inw(PORT+L_DATAREG) & (CSR0_IDON | CSR0_MERR) )
+			break; /* init ok ? */
+	}
 }
 
 /*
@@ -525,37 +525,37 @@
  */
 static void *ni65_alloc_mem(struct device *dev,char *what,int size,int type)
 {
-  struct sk_buff *skb=NULL;
-  unsigned char *ptr;
-  void *ret;
-
-  if(type) {
-    ret = skb = alloc_skb(2+16+size,GFP_KERNEL|GFP_DMA);
-    if(!skb) {
-      printk("%s: unable to allocate %s memory.\n",dev->name,what);
-      return NULL;
-    }
-    skb->dev = dev;
-    skb_reserve(skb,2+16);
-    skb_put(skb,R_BUF_SIZE);   /* grab the whole space .. (not necessary) */
-    ptr = skb->data;
-  }
-  else {
-    ret = ptr = kmalloc(T_BUF_SIZE,GFP_KERNEL | GFP_DMA);
-    if(!ret) {
-      printk("%s: unable to allocate %s memory.\n",dev->name,what);
-      return NULL;
-    }
-  }
-  if( (u32) virt_to_bus(ptr+size) > 0x1000000) {
-    printk("%s: unable to allocate %s memory in lower 16MB!\n",dev->name,what);
-    if(type)
-      kfree_skb(skb,FREE_WRITE);
-    else
-      kfree(ptr);
-    return NULL;
-  }
-  return ret;
+	struct sk_buff *skb=NULL;
+	unsigned char *ptr;
+	void *ret;
+
+	if(type) {
+		ret = skb = alloc_skb(2+16+size,GFP_KERNEL|GFP_DMA);
+		if(!skb) {
+			printk("%s: unable to allocate %s memory.\n",dev->name,what);
+			return NULL;
+		}
+		skb->dev = dev;
+		skb_reserve(skb,2+16);
+		skb_put(skb,R_BUF_SIZE);	 /* grab the whole space .. (not necessary) */
+		ptr = skb->data;
+	}
+	else {
+		ret = ptr = kmalloc(T_BUF_SIZE,GFP_KERNEL | GFP_DMA);
+		if(!ret) {
+			printk("%s: unable to allocate %s memory.\n",dev->name,what);
+			return NULL;
+		}
+	}
+	if( (u32) virt_to_bus(ptr+size) > 0x1000000) {
+		printk("%s: unable to allocate %s memory in lower 16MB!\n",dev->name,what);
+		if(type)
+			kfree_skb(skb,FREE_WRITE);
+		else
+			kfree(ptr);
+		return NULL;
+	}
+	return ret;
 }
 
 /*
@@ -563,51 +563,51 @@
  */
 static int ni65_alloc_buffer(struct device *dev)
 {
-  unsigned char *ptr;
-  struct priv *p;
-  int i;
-
-  /*
-   * we need 8-aligned memory ..
-   */
-  ptr = ni65_alloc_mem(dev,"BUFFER",sizeof(struct priv)+8,0);
-  if(!ptr)
-    return -ENOMEM;
-
-  p = dev->priv = (struct priv *) (((unsigned long) ptr + 7) & ~0x7);
-  memset((char *) dev->priv,0,sizeof(struct priv));
-  p->self = ptr;
+	unsigned char *ptr;
+	struct priv *p;
+	int i;
+
+	/*
+	 * we need 8-aligned memory ..
+	 */
+	ptr = ni65_alloc_mem(dev,"BUFFER",sizeof(struct priv)+8,0);
+	if(!ptr)
+		return -ENOMEM;
+
+	p = dev->priv = (struct priv *) (((unsigned long) ptr + 7) & ~0x7);
+	memset((char *) dev->priv,0,sizeof(struct priv));
+	p->self = ptr;
+
+	for(i=0;i<TMDNUM;i++)
+	{
+#ifdef XMT_VIA_SKB
+		p->tmd_skb[i] = NULL;
+#endif
+		p->tmdbounce[i] = ni65_alloc_mem(dev,"XMIT",T_BUF_SIZE,0);
+		if(!p->tmdbounce[i]) {
+			ni65_free_buffer(p);
+			return -ENOMEM;
+		}
+	}
 
-  for(i=0;i<TMDNUM;i++)
-  {
-#ifdef XMT_VIA_SKB
-    p->tmd_skb[i] = NULL;
-#endif
-    p->tmdbounce[i] = ni65_alloc_mem(dev,"XMIT",T_BUF_SIZE,0);
-    if(!p->tmdbounce[i]) {
-      ni65_free_buffer(p);
-      return -ENOMEM;
-    }
-  }
-
-  for(i=0;i<RMDNUM;i++)
-  {
+	for(i=0;i<RMDNUM;i++)
+	{
 #ifdef RCV_VIA_SKB
-    p->recv_skb[i] = ni65_alloc_mem(dev,"RECV",R_BUF_SIZE,1);
-    if(!p->recv_skb[i]) {
-      ni65_free_buffer(p);
-      return -ENOMEM;
-    }
+		p->recv_skb[i] = ni65_alloc_mem(dev,"RECV",R_BUF_SIZE,1);
+		if(!p->recv_skb[i]) {
+			ni65_free_buffer(p);
+			return -ENOMEM;
+		}
 #else
-    p->recvbounce[i] = ni65_alloc_mem(dev,"RECV",R_BUF_SIZE,0);
-    if(!p->recvbounce[i]) {
-      ni65_free_buffer(p);
-      return -ENOMEM;
-    }
+		p->recvbounce[i] = ni65_alloc_mem(dev,"RECV",R_BUF_SIZE,0);
+		if(!p->recvbounce[i]) {
+			ni65_free_buffer(p);
+			return -ENOMEM;
+		}
 #endif
-  }
+	}
 
-  return 0; /* everything is OK */
+	return 0; /* everything is OK */
 }
 
 /*
@@ -615,32 +615,32 @@
  */
 static void ni65_free_buffer(struct priv *p)
 {
-  int i;
+	int i;
 
-  if(!p)
-    return;
+	if(!p)
+		return;
 
-  for(i=0;i<TMDNUM;i++) {
-    if(p->tmdbounce[i])
-      kfree(p->tmdbounce[i]);
+	for(i=0;i<TMDNUM;i++) {
+		if(p->tmdbounce[i])
+			kfree(p->tmdbounce[i]);
 #ifdef XMT_VIA_SKB
-    if(p->tmd_skb[i])
-      dev_kfree_skb(p->tmd_skb[i],FREE_WRITE);
+		if(p->tmd_skb[i])
+			dev_kfree_skb(p->tmd_skb[i],FREE_WRITE);
 #endif
-  }
+	}
 
-  for(i=0;i<RMDNUM;i++)
-  {
+	for(i=0;i<RMDNUM;i++)
+	{
 #ifdef RCV_VIA_SKB
-    if(p->recv_skb[i])
-      dev_kfree_skb(p->recv_skb[i],FREE_WRITE);
+		if(p->recv_skb[i])
+			dev_kfree_skb(p->recv_skb[i],FREE_WRITE);
 #else
-    if(p->recvbounce[i])
-      kfree(p->recvbounce[i]);
+		if(p->recvbounce[i])
+			kfree(p->recvbounce[i]);
 #endif
-  }
-  if(p->self)
-    kfree(p->self);
+	}
+	if(p->self)
+		kfree(p->self);
 }
 
 
@@ -649,68 +649,68 @@
  */
 static void ni65_stop_start(struct device *dev,struct priv *p)
 {
-  int csr0 = CSR0_INEA;
+	int csr0 = CSR0_INEA;
 
-  writedatareg(CSR0_STOP);
+	writedatareg(CSR0_STOP);
 
-  if(debuglevel > 1)
-    printk("ni65_stop_start\n");
-
-  if(p->features & INIT_RING_BEFORE_START) {
-    int i;
-#ifdef XMT_VIA_SKB
-    struct sk_buff *skb_save[TMDNUM];
-#endif
-    unsigned long buffer[TMDNUM];
-    short blen[TMDNUM];
+	if(debuglevel > 1)
+		printk("ni65_stop_start\n");
 
-    if(p->xmit_queued) {
-      while(1) {
-        if((p->tmdhead[p->tmdlast].u.s.status & XMIT_OWN))
-          break;
-        p->tmdlast = (p->tmdlast + 1) & (TMDNUM-1);
-        if(p->tmdlast == p->tmdnum)
-          break;
-      }
-    }
-
-    for(i=0;i<TMDNUM;i++) {
-      struct tmd *tmdp = p->tmdhead + i;
-#ifdef XMT_VIA_SKB
-      skb_save[i] = p->tmd_skb[i];
-#endif
-      buffer[i] = (u32) bus_to_virt(tmdp->u.buffer);
-      blen[i] = tmdp->blen;
-      tmdp->u.s.status = 0x0;
-    }
-
-    for(i=0;i<RMDNUM;i++) {
-      struct rmd *rmdp = p->rmdhead + i;
-      rmdp->u.s.status = RCV_OWN;
-    }
-    p->tmdnum = p->xmit_queued = 0;
-    writedatareg(CSR0_STRT | csr0);
-
-    for(i=0;i<TMDNUM;i++) {
-      int num = (i + p->tmdlast) & (TMDNUM-1);
-      p->tmdhead[i].u.buffer = (u32) virt_to_bus((char *)buffer[num]); /* status is part of buffer field */
-      p->tmdhead[i].blen = blen[num];
-      if(p->tmdhead[i].u.s.status & XMIT_OWN) {
-         p->tmdnum = (p->tmdnum + 1) & (TMDNUM-1);
-         p->xmit_queued = 1;
+	if(p->features & INIT_RING_BEFORE_START) {
+		int i;
+#ifdef XMT_VIA_SKB
+		struct sk_buff *skb_save[TMDNUM];
+#endif
+		unsigned long buffer[TMDNUM];
+		short blen[TMDNUM];
+
+		if(p->xmit_queued) {
+			while(1) {
+				if((p->tmdhead[p->tmdlast].u.s.status & XMIT_OWN))
+					break;
+				p->tmdlast = (p->tmdlast + 1) & (TMDNUM-1);
+				if(p->tmdlast == p->tmdnum)
+					break;
+			}
+		}
+
+		for(i=0;i<TMDNUM;i++) {
+			struct tmd *tmdp = p->tmdhead + i;
+#ifdef XMT_VIA_SKB
+			skb_save[i] = p->tmd_skb[i];
+#endif
+			buffer[i] = (u32) bus_to_virt(tmdp->u.buffer);
+			blen[i] = tmdp->blen;
+			tmdp->u.s.status = 0x0;
+		}
+
+		for(i=0;i<RMDNUM;i++) {
+			struct rmd *rmdp = p->rmdhead + i;
+			rmdp->u.s.status = RCV_OWN;
+		}
+		p->tmdnum = p->xmit_queued = 0;
+		writedatareg(CSR0_STRT | csr0);
+
+		for(i=0;i<TMDNUM;i++) {
+			int num = (i + p->tmdlast) & (TMDNUM-1);
+			p->tmdhead[i].u.buffer = (u32) virt_to_bus((char *)buffer[num]); /* status is part of buffer field */
+			p->tmdhead[i].blen = blen[num];
+			if(p->tmdhead[i].u.s.status & XMIT_OWN) {
+				 p->tmdnum = (p->tmdnum + 1) & (TMDNUM-1);
+				 p->xmit_queued = 1;
 	 writedatareg(CSR0_TDMD | CSR0_INEA | csr0);
-      }
+			}
 #ifdef XMT_VIA_SKB
-      p->tmd_skb[i] = skb_save[num];
+			p->tmd_skb[i] = skb_save[num];
 #endif
-    }
-    p->rmdnum = p->tmdlast = 0;
-    if(!p->lock)
-      dev->tbusy = (p->tmdnum || !p->xmit_queued) ? 0 : 1;
-    dev->trans_start = jiffies;
-  }
-  else
-    writedatareg(CSR0_STRT | csr0);
+		}
+		p->rmdnum = p->tmdlast = 0;
+		if(!p->lock)
+			dev->tbusy = (p->tmdnum || !p->xmit_queued) ? 0 : 1;
+		dev->trans_start = jiffies;
+	}
+	else
+		writedatareg(CSR0_STRT | csr0);
 }
 
 /*
@@ -718,74 +718,74 @@
  */
 static int ni65_lance_reinit(struct device *dev)
 {
-   int i;
-   struct priv *p = (struct priv *) dev->priv;
+	 int i;
+	 struct priv *p = (struct priv *) dev->priv;
 
-   p->lock = 0;
-   p->xmit_queued = 0;
+	 p->lock = 0;
+	 p->xmit_queued = 0;
 
-   disable_dma(dev->dma); /* I've never worked with dma, but we do it like the packetdriver */
-   set_dma_mode(dev->dma,DMA_MODE_CASCADE);
-   enable_dma(dev->dma);
-
-   outw(inw(PORT+L_RESET),PORT+L_RESET); /* first: reset the card */
-   if( (i=readreg(CSR0) ) != 0x4)
-   {
-     printk(KERN_ERR "%s: can't RESET %s card: %04x\n",dev->name,
-              cards[p->cardno].cardname,(int) i);
-     disable_dma(dev->dma);
-     return 0;
-   }
-
-   p->rmdnum = p->tmdnum = p->tmdlast = p->tmdbouncenum = 0;
-   for(i=0;i<TMDNUM;i++)
-   {
-     struct tmd *tmdp = p->tmdhead + i;
-#ifdef XMT_VIA_SKB
-     if(p->tmd_skb[i]) {
-       dev_kfree_skb(p->tmd_skb[i],FREE_WRITE);
-       p->tmd_skb[i] = NULL;
-     }
-#endif
-     tmdp->u.buffer = 0x0;
-     tmdp->u.s.status = XMIT_START | XMIT_END;
-     tmdp->blen = tmdp->status2 = 0;
-   }
-
-   for(i=0;i<RMDNUM;i++)
-   {
-     struct rmd *rmdp = p->rmdhead + i;
+	 disable_dma(dev->dma); /* I've never worked with dma, but we do it like the packetdriver */
+	 set_dma_mode(dev->dma,DMA_MODE_CASCADE);
+	 enable_dma(dev->dma);
+
+	 outw(inw(PORT+L_RESET),PORT+L_RESET); /* first: reset the card */
+	 if( (i=readreg(CSR0) ) != 0x4)
+	 {
+		 printk(KERN_ERR "%s: can't RESET %s card: %04x\n",dev->name,
+							cards[p->cardno].cardname,(int) i);
+		 disable_dma(dev->dma);
+		 return 0;
+	 }
+
+	 p->rmdnum = p->tmdnum = p->tmdlast = p->tmdbouncenum = 0;
+	 for(i=0;i<TMDNUM;i++)
+	 {
+		 struct tmd *tmdp = p->tmdhead + i;
+#ifdef XMT_VIA_SKB
+		 if(p->tmd_skb[i]) {
+			 dev_kfree_skb(p->tmd_skb[i],FREE_WRITE);
+			 p->tmd_skb[i] = NULL;
+		 }
+#endif
+		 tmdp->u.buffer = 0x0;
+		 tmdp->u.s.status = XMIT_START | XMIT_END;
+		 tmdp->blen = tmdp->status2 = 0;
+	 }
+
+	 for(i=0;i<RMDNUM;i++)
+	 {
+		 struct rmd *rmdp = p->rmdhead + i;
 #ifdef RCV_VIA_SKB
-     rmdp->u.buffer = (u32) virt_to_bus(p->recv_skb[i]->data);
+		 rmdp->u.buffer = (u32) virt_to_bus(p->recv_skb[i]->data);
 #else
-     rmdp->u.buffer = (u32) virt_to_bus(p->recvbounce[i]);
+		 rmdp->u.buffer = (u32) virt_to_bus(p->recvbounce[i]);
 #endif
-     rmdp->blen = -(R_BUF_SIZE-8);
-     rmdp->mlen = 0;
-     rmdp->u.s.status = RCV_OWN;
-   }
-
-   if(dev->flags & IFF_PROMISC)
-     ni65_init_lance(p,dev->dev_addr,0x00,M_PROM);
-   else if(dev->mc_count || dev->flags & IFF_ALLMULTI)
-     ni65_init_lance(p,dev->dev_addr,0xff,0x0);
-   else
-     ni65_init_lance(p,dev->dev_addr,0x00,0x00);
-
-  /*
-   * ni65_set_lance_mem() sets L_ADDRREG to CSR0
-   * NOW, WE WILL NEVER CHANGE THE L_ADDRREG, CSR0 IS ALWAYS SELECTED
-   */
-
-   if(inw(PORT+L_DATAREG) & CSR0_IDON)  {
-     ni65_set_performance(p);
-           /* init OK: start lance , enable interrupts */
-     writedatareg(CSR0_CLRALL | CSR0_INEA | CSR0_STRT);
-     return 1; /* ->OK */
-   }
-   printk(KERN_ERR "%s: can't init lance, status: %04x\n",dev->name,(int) inw(PORT+L_DATAREG));
-   disable_dma(dev->dma);
-   return 0; /* ->Error */
+		 rmdp->blen = -(R_BUF_SIZE-8);
+		 rmdp->mlen = 0;
+		 rmdp->u.s.status = RCV_OWN;
+	 }
+
+	 if(dev->flags & IFF_PROMISC)
+		 ni65_init_lance(p,dev->dev_addr,0x00,M_PROM);
+	 else if(dev->mc_count || dev->flags & IFF_ALLMULTI)
+		 ni65_init_lance(p,dev->dev_addr,0xff,0x0);
+	 else
+		 ni65_init_lance(p,dev->dev_addr,0x00,0x00);
+
+	/*
+	 * ni65_set_lance_mem() sets L_ADDRREG to CSR0
+	 * NOW, WE WILL NEVER CHANGE THE L_ADDRREG, CSR0 IS ALWAYS SELECTED
+	 */
+
+	 if(inw(PORT+L_DATAREG) & CSR0_IDON)	{
+		 ni65_set_performance(p);
+					 /* init OK: start lance , enable interrupts */
+		 writedatareg(CSR0_CLRALL | CSR0_INEA | CSR0_STRT);
+		 return 1; /* ->OK */
+	 }
+	 printk(KERN_ERR "%s: can't init lance, status: %04x\n",dev->name,(int) inw(PORT+L_DATAREG));
+	 disable_dma(dev->dma);
+	 return 0; /* ->Error */
 }
 
 /*
@@ -793,117 +793,117 @@
  */
 static void ni65_interrupt(int irq, void * dev_id, struct pt_regs * regs)
 {
-  int csr0;
-  struct device *dev = (struct device *) irq2dev_map[irq];
-  struct priv *p;
-  int bcnt = 32;
-
-  if (dev == NULL) {
-    printk (KERN_ERR "ni65_interrupt(): irq %d for unknown device.\n", irq);
-    return;
-  }
-
-  if(set_bit(0,(int *) &dev->interrupt)) {
-    printk("ni65: oops .. interrupt while proceeding interrupt\n");
-    return;
-  }
-  p = (struct priv *) dev->priv;
+	int csr0;
+	struct device *dev = (struct device *) irq2dev_map[irq];
+	struct priv *p;
+	int bcnt = 32;
+
+	if (dev == NULL) {
+		printk (KERN_ERR "ni65_interrupt(): irq %d for unknown device.\n", irq);
+		return;
+	}
+
+	if(set_bit(0,(int *) &dev->interrupt)) {
+		printk("ni65: oops .. interrupt while proceeding interrupt\n");
+		return;
+	}
+	p = (struct priv *) dev->priv;
 
-  while(--bcnt) {
-    csr0 = inw(PORT+L_DATAREG);
+	while(--bcnt) {
+		csr0 = inw(PORT+L_DATAREG);
 
 #if 0
-    writedatareg( (csr0 & CSR0_CLRALL) ); /* ack interrupts, disable int. */
+		writedatareg( (csr0 & CSR0_CLRALL) ); /* ack interrupts, disable int. */
 #else
-    writedatareg( (csr0 & CSR0_CLRALL) | CSR0_INEA ); /* ack interrupts, interrupts enabled */
+		writedatareg( (csr0 & CSR0_CLRALL) | CSR0_INEA ); /* ack interrupts, interrupts enabled */
 #endif
 
-    if(!(csr0 & (CSR0_ERR | CSR0_RINT | CSR0_TINT)))
-      break;
+		if(!(csr0 & (CSR0_ERR | CSR0_RINT | CSR0_TINT)))
+			break;
 
-    if(csr0 & CSR0_RINT) /* RECV-int? */
-      ni65_recv_intr(dev,csr0);
-    if(csr0 & CSR0_TINT) /* XMIT-int? */
-      ni65_xmit_intr(dev,csr0);
-
-    if(csr0 & CSR0_ERR)
-    {
-      struct priv *p = (struct priv *) dev->priv;
-      if(debuglevel > 1)
-        printk("%s: general error: %04x.\n",dev->name,csr0);
-      if(csr0 & CSR0_BABL)
-        p->stats.tx_errors++;
-      if(csr0 & CSR0_MISS) {
-        int i;
-        for(i=0;i<RMDNUM;i++)
-          printk("%02x ",p->rmdhead[i].u.s.status);
-        printk("\n");
-        p->stats.rx_errors++;
-      }
-      if(csr0 & CSR0_MERR) {
-        if(debuglevel > 1)
-          printk("%s: Ooops .. memory error: %04x.\n",dev->name,csr0);
-        ni65_stop_start(dev,p);
-      }
-    }
-  }
+		if(csr0 & CSR0_RINT) /* RECV-int? */
+			ni65_recv_intr(dev,csr0);
+		if(csr0 & CSR0_TINT) /* XMIT-int? */
+			ni65_xmit_intr(dev,csr0);
+
+		if(csr0 & CSR0_ERR)
+		{
+			struct priv *p = (struct priv *) dev->priv;
+			if(debuglevel > 1)
+				printk("%s: general error: %04x.\n",dev->name,csr0);
+			if(csr0 & CSR0_BABL)
+				p->stats.tx_errors++;
+			if(csr0 & CSR0_MISS) {
+				int i;
+				for(i=0;i<RMDNUM;i++)
+					printk("%02x ",p->rmdhead[i].u.s.status);
+				printk("\n");
+				p->stats.rx_errors++;
+			}
+			if(csr0 & CSR0_MERR) {
+				if(debuglevel > 1)
+					printk("%s: Ooops .. memory error: %04x.\n",dev->name,csr0);
+				ni65_stop_start(dev,p);
+			}
+		}
+	}
 
 #ifdef RCV_PARANOIA_CHECK
 {
  int j;
  for(j=0;j<RMDNUM;j++)
  {
-  struct priv *p = (struct priv *) dev->priv;
-  int i,k,num1,num2;
-  for(i=RMDNUM-1;i>0;i--) {
-     num2 = (p->rmdnum + i) & (RMDNUM-1);
-     if(!(p->rmdhead[num2].u.s.status & RCV_OWN))
-        break;
-  }
-
-  if(i) {
-    for(k=0;k<RMDNUM;k++) {
-      num1 = (p->rmdnum + k) & (RMDNUM-1);
-      if(!(p->rmdhead[num1].u.s.status & RCV_OWN))
-        break;
-    }
-    if(!k)
-      break;
-
-    if(debuglevel > 0)
-    {
-      char buf[256],*buf1;
-      int k;
-      buf1 = buf;
-      for(k=0;k<RMDNUM;k++) {
-        sprintf(buf1,"%02x ",(p->rmdhead[k].u.s.status)); /* & RCV_OWN) ); */
-        buf1 += 3;
-      }
-      *buf1 = 0;
-      printk(KERN_ERR "%s: Ooops, receive ring corrupted %2d %2d | %s\n",dev->name,p->rmdnum,i,buf);
-    }
-
-    p->rmdnum = num1;
-    ni65_recv_intr(dev,csr0);
-    if((p->rmdhead[num2].u.s.status & RCV_OWN))
-      break;	/* ok, we are 'in sync' again */
-  }
-  else
-    break;
+	struct priv *p = (struct priv *) dev->priv;
+	int i,k,num1,num2;
+	for(i=RMDNUM-1;i>0;i--) {
+		 num2 = (p->rmdnum + i) & (RMDNUM-1);
+		 if(!(p->rmdhead[num2].u.s.status & RCV_OWN))
+				break;
+	}
+
+	if(i) {
+		for(k=0;k<RMDNUM;k++) {
+			num1 = (p->rmdnum + k) & (RMDNUM-1);
+			if(!(p->rmdhead[num1].u.s.status & RCV_OWN))
+				break;
+		}
+		if(!k)
+			break;
+
+		if(debuglevel > 0)
+		{
+			char buf[256],*buf1;
+			int k;
+			buf1 = buf;
+			for(k=0;k<RMDNUM;k++) {
+				sprintf(buf1,"%02x ",(p->rmdhead[k].u.s.status)); /* & RCV_OWN) ); */
+				buf1 += 3;
+			}
+			*buf1 = 0;
+			printk(KERN_ERR "%s: Ooops, receive ring corrupted %2d %2d | %s\n",dev->name,p->rmdnum,i,buf);
+		}
+
+		p->rmdnum = num1;
+		ni65_recv_intr(dev,csr0);
+		if((p->rmdhead[num2].u.s.status & RCV_OWN))
+			break;	/* ok, we are 'in sync' again */
+	}
+	else
+		break;
  }
 }
 #endif
 
-  if( (csr0 & (CSR0_RXON | CSR0_TXON)) != (CSR0_RXON | CSR0_TXON) ) {
-    printk("%s: RX or TX was offline -> restart\n",dev->name);
-    ni65_stop_start(dev,p);
-  }
-  else
-    writedatareg(CSR0_INEA);
+	if( (csr0 & (CSR0_RXON | CSR0_TXON)) != (CSR0_RXON | CSR0_TXON) ) {
+		printk("%s: RX or TX was offline -> restart\n",dev->name);
+		ni65_stop_start(dev,p);
+	}
+	else
+		writedatareg(CSR0_INEA);
 
-  dev->interrupt = 0;
+	dev->interrupt = 0;
 
-  return;
+	return;
 }
 
 /*
@@ -912,62 +912,62 @@
  */
 static void ni65_xmit_intr(struct device *dev,int csr0)
 {
-  struct priv *p = (struct priv *) dev->priv;
+	struct priv *p = (struct priv *) dev->priv;
 
-  while(p->xmit_queued)
-  {
-    struct tmd *tmdp = p->tmdhead + p->tmdlast;
-    int tmdstat = tmdp->u.s.status;
+	while(p->xmit_queued)
+	{
+		struct tmd *tmdp = p->tmdhead + p->tmdlast;
+		int tmdstat = tmdp->u.s.status;
 
-    if(tmdstat & XMIT_OWN)
-      break;
+		if(tmdstat & XMIT_OWN)
+			break;
 
-    if(tmdstat & XMIT_ERR)
-    {
+		if(tmdstat & XMIT_ERR)
+		{
 #if 0
-      if(tmdp->status2 & XMIT_TDRMASK && debuglevel > 3)
-        printk(KERN_ERR "%s: tdr-problems (e.g. no resistor)\n",dev->name);
+			if(tmdp->status2 & XMIT_TDRMASK && debuglevel > 3)
+				printk(KERN_ERR "%s: tdr-problems (e.g. no resistor)\n",dev->name);
 #endif
-     /* checking some errors */
-      if(tmdp->status2 & XMIT_RTRY)
-        p->stats.tx_aborted_errors++;
-      if(tmdp->status2 & XMIT_LCAR)
-        p->stats.tx_carrier_errors++;
-      if(tmdp->status2 & (XMIT_BUFF | XMIT_UFLO )) {
+		 /* checking some errors */
+			if(tmdp->status2 & XMIT_RTRY)
+				p->stats.tx_aborted_errors++;
+			if(tmdp->status2 & XMIT_LCAR)
+				p->stats.tx_carrier_errors++;
+			if(tmdp->status2 & (XMIT_BUFF | XMIT_UFLO )) {
 		/* this stops the xmitter */
-        p->stats.tx_fifo_errors++;
-        if(debuglevel > 0)
-          printk(KERN_ERR "%s: Xmit FIFO/BUFF error\n",dev->name);
-        if(p->features & INIT_RING_BEFORE_START) {
-          tmdp->u.s.status = XMIT_OWN | XMIT_START | XMIT_END;	/* test: resend this frame */
-          ni65_stop_start(dev,p);
-          break;	/* no more Xmit processing .. */
-        }
-        else
-         ni65_stop_start(dev,p);
-      }
-      if(debuglevel > 2)
-        printk(KERN_ERR "%s: xmit-error: %04x %02x-%04x\n",dev->name,csr0,(int) tmdstat,(int) tmdp->status2);
-      if(!(csr0 & CSR0_BABL)) /* don't count errors twice */
-        p->stats.tx_errors++;
-      tmdp->status2 = 0;
-    }
-    else
-      p->stats.tx_packets++;
-
-#ifdef XMT_VIA_SKB
-    if(p->tmd_skb[p->tmdlast]) {
-       dev_kfree_skb(p->tmd_skb[p->tmdlast],FREE_WRITE);
-       p->tmd_skb[p->tmdlast] = NULL;
-    }
-#endif
-
-    p->tmdlast = (p->tmdlast + 1) & (TMDNUM-1);
-    if(p->tmdlast == p->tmdnum)
-      p->xmit_queued = 0;
-  }
-  dev->tbusy = 0;
-  mark_bh(NET_BH);
+				p->stats.tx_fifo_errors++;
+				if(debuglevel > 0)
+					printk(KERN_ERR "%s: Xmit FIFO/BUFF error\n",dev->name);
+				if(p->features & INIT_RING_BEFORE_START) {
+					tmdp->u.s.status = XMIT_OWN | XMIT_START | XMIT_END;	/* test: resend this frame */
+					ni65_stop_start(dev,p);
+					break;	/* no more Xmit processing .. */
+				}
+				else
+				 ni65_stop_start(dev,p);
+			}
+			if(debuglevel > 2)
+				printk(KERN_ERR "%s: xmit-error: %04x %02x-%04x\n",dev->name,csr0,(int) tmdstat,(int) tmdp->status2);
+			if(!(csr0 & CSR0_BABL)) /* don't count errors twice */
+				p->stats.tx_errors++;
+			tmdp->status2 = 0;
+		}
+		else
+			p->stats.tx_packets++;
+
+#ifdef XMT_VIA_SKB
+		if(p->tmd_skb[p->tmdlast]) {
+			 dev_kfree_skb(p->tmd_skb[p->tmdlast],FREE_WRITE);
+			 p->tmd_skb[p->tmdlast] = NULL;
+		}
+#endif
+
+		p->tmdlast = (p->tmdlast + 1) & (TMDNUM-1);
+		if(p->tmdlast == p->tmdnum)
+			p->xmit_queued = 0;
+	}
+	dev->tbusy = 0;
+	mark_bh(NET_BH);
 }
 
 /*
@@ -975,90 +975,90 @@
  */
 static void ni65_recv_intr(struct device *dev,int csr0)
 {
-  struct rmd *rmdp;
-  int rmdstat,len;
-  int cnt=0;
-  struct priv *p = (struct priv *) dev->priv;
-
-  rmdp = p->rmdhead + p->rmdnum;
-  while(!( (rmdstat = rmdp->u.s.status) & RCV_OWN))
-  {
-    cnt++;
-    if( (rmdstat & (RCV_START | RCV_END | RCV_ERR)) != (RCV_START | RCV_END) ) /* error or oversized? */
-    {
-      if(!(rmdstat & RCV_ERR)) {
-        if(rmdstat & RCV_START)
-        {
-          p->stats.rx_length_errors++;
-          printk(KERN_ERR "%s: recv, packet too long: %d\n",dev->name,rmdp->mlen & 0x0fff);
-        }
-      }
-      else {
-        if(debuglevel > 2)
-          printk(KERN_ERR "%s: receive-error: %04x, lance-status: %04x/%04x\n",
-                  dev->name,(int) rmdstat,csr0,(int) inw(PORT+L_DATAREG) );
-        if(rmdstat & RCV_FRAM)
-          p->stats.rx_frame_errors++;
-        if(rmdstat & RCV_OFLO)
-          p->stats.rx_over_errors++;
-        if(rmdstat & RCV_CRC)
-          p->stats.rx_crc_errors++;
-        if(rmdstat & RCV_BUF_ERR)
-          p->stats.rx_fifo_errors++;
-      }
-      if(!(csr0 & CSR0_MISS)) /* don't count errors twice */
-        p->stats.rx_errors++;
-    }
-    else if( (len = (rmdp->mlen & 0x0fff) - 4) >= 60)
-    {
+	struct rmd *rmdp;
+	int rmdstat,len;
+	int cnt=0;
+	struct priv *p = (struct priv *) dev->priv;
+
+	rmdp = p->rmdhead + p->rmdnum;
+	while(!( (rmdstat = rmdp->u.s.status) & RCV_OWN))
+	{
+		cnt++;
+		if( (rmdstat & (RCV_START | RCV_END | RCV_ERR)) != (RCV_START | RCV_END) ) /* error or oversized? */
+		{
+			if(!(rmdstat & RCV_ERR)) {
+				if(rmdstat & RCV_START)
+				{
+					p->stats.rx_length_errors++;
+					printk(KERN_ERR "%s: recv, packet too long: %d\n",dev->name,rmdp->mlen & 0x0fff);
+				}
+			}
+			else {
+				if(debuglevel > 2)
+					printk(KERN_ERR "%s: receive-error: %04x, lance-status: %04x/%04x\n",
+									dev->name,(int) rmdstat,csr0,(int) inw(PORT+L_DATAREG) );
+				if(rmdstat & RCV_FRAM)
+					p->stats.rx_frame_errors++;
+				if(rmdstat & RCV_OFLO)
+					p->stats.rx_over_errors++;
+				if(rmdstat & RCV_CRC)
+					p->stats.rx_crc_errors++;
+				if(rmdstat & RCV_BUF_ERR)
+					p->stats.rx_fifo_errors++;
+			}
+			if(!(csr0 & CSR0_MISS)) /* don't count errors twice */
+				p->stats.rx_errors++;
+		}
+		else if( (len = (rmdp->mlen & 0x0fff) - 4) >= 60)
+		{
 #ifdef RCV_VIA_SKB
-      struct sk_buff *skb = alloc_skb(R_BUF_SIZE+2+16,GFP_ATOMIC);
-      if (skb)
-        skb_reserve(skb,16);
+			struct sk_buff *skb = alloc_skb(R_BUF_SIZE+2+16,GFP_ATOMIC);
+			if (skb)
+				skb_reserve(skb,16);
 #else
-      struct sk_buff *skb = dev_alloc_skb(len+2);
+			struct sk_buff *skb = dev_alloc_skb(len+2);
 #endif
-      if(skb)
-      {
-        skb_reserve(skb,2);
+			if(skb)
+			{
+				skb_reserve(skb,2);
 	skb->dev = dev;
 #ifdef RCV_VIA_SKB
-        if( (unsigned long) (skb->data + R_BUF_SIZE) > 0x1000000) {
-          skb_put(skb,len);
-          eth_copy_and_sum(skb, (unsigned char *)(p->recv_skb[p->rmdnum]->data),len,0);
-        }
-        else {
-          struct sk_buff *skb1 = p->recv_skb[p->rmdnum];
-          skb_put(skb,R_BUF_SIZE);
-          p->recv_skb[p->rmdnum] = skb;
-          rmdp->u.buffer = (u32) virt_to_bus(skb->data);
-          skb = skb1;
-          skb_trim(skb,len);
-        }
+				if( (unsigned long) (skb->data + R_BUF_SIZE) > 0x1000000) {
+					skb_put(skb,len);
+					eth_copy_and_sum(skb, (unsigned char *)(p->recv_skb[p->rmdnum]->data),len,0);
+				}
+				else {
+					struct sk_buff *skb1 = p->recv_skb[p->rmdnum];
+					skb_put(skb,R_BUF_SIZE);
+					p->recv_skb[p->rmdnum] = skb;
+					rmdp->u.buffer = (u32) virt_to_bus(skb->data);
+					skb = skb1;
+					skb_trim(skb,len);
+				}
 #else
-        skb_put(skb,len);
-        eth_copy_and_sum(skb, (unsigned char *) p->recvbounce[p->rmdnum],len,0);
+				skb_put(skb,len);
+				eth_copy_and_sum(skb, (unsigned char *) p->recvbounce[p->rmdnum],len,0);
 #endif
-        p->stats.rx_packets++;
-        skb->protocol=eth_type_trans(skb,dev);
-        netif_rx(skb);
-      }
-      else
-      {
-        printk(KERN_ERR "%s: can't alloc new sk_buff\n",dev->name);
-        p->stats.rx_dropped++;
-      }
-    }
-    else {
-      printk(KERN_INFO "%s: received runt packet\n",dev->name);
-      p->stats.rx_errors++;
-    }
-    rmdp->blen = -(R_BUF_SIZE-8);
-    rmdp->mlen = 0;
-    rmdp->u.s.status = RCV_OWN; /* change owner */
-    p->rmdnum = (p->rmdnum + 1) & (RMDNUM-1);
-    rmdp = p->rmdhead + p->rmdnum;
-  }
+				p->stats.rx_packets++;
+				skb->protocol=eth_type_trans(skb,dev);
+				netif_rx(skb);
+			}
+			else
+			{
+				printk(KERN_ERR "%s: can't alloc new sk_buff\n",dev->name);
+				p->stats.rx_dropped++;
+			}
+		}
+		else {
+			printk(KERN_INFO "%s: received runt packet\n",dev->name);
+			p->stats.rx_errors++;
+		}
+		rmdp->blen = -(R_BUF_SIZE-8);
+		rmdp->mlen = 0;
+		rmdp->u.s.status = RCV_OWN; /* change owner */
+		p->rmdnum = (p->rmdnum + 1) & (RMDNUM-1);
+		rmdp = p->rmdhead + p->rmdnum;
+	}
 }
 
 /*
@@ -1066,106 +1066,99 @@
  */
 static int ni65_send_packet(struct sk_buff *skb, struct device *dev)
 {
-  struct priv *p = (struct priv *) dev->priv;
+	struct priv *p = (struct priv *) dev->priv;
 
-  if(dev->tbusy)
-  {
-    int tickssofar = jiffies - dev->trans_start;
-    if (tickssofar < 50)
-      return 1;
+	if(dev->tbusy)
+	{
+		int tickssofar = jiffies - dev->trans_start;
+		if (tickssofar < 50)
+			return 1;
 
-    printk(KERN_ERR "%s: xmitter timed out, try to restart!\n",dev->name);
-{
-  int i;
-  for(i=0;i<TMDNUM;i++)
-    printk("%02x ",p->tmdhead[i].u.s.status);
-  printk("\n");
-}
-    ni65_lance_reinit(dev);
-    dev->tbusy=0;
-    dev->trans_start = jiffies;
-  }
-
-  if(skb == NULL) {
-    dev_tint(dev);
-    return 0;
-  }
-
-  if (skb->len <= 0)
-    return 0;
-
-  if (set_bit(0, (void*)&dev->tbusy) != 0) {
-     printk(KERN_ERR "%s: Transmitter access conflict.\n", dev->name);
-     return 1;
-  }
-  if (set_bit(0, (void*)&p->lock)) {
-	printk(KERN_ERR "%s: Queue was locked.\n", dev->name);
-	return 1;
-  }
-
-  {
-    short len = ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN;
-    struct tmd *tmdp;
-    long flags;
+		printk(KERN_ERR "%s: xmitter timed out, try to restart!\n",dev->name);
+		{
+			int i;
+			for(i=0;i<TMDNUM;i++)
+				printk("%02x ",p->tmdhead[i].u.s.status);
+			printk("\n");
+		}
+		ni65_lance_reinit(dev);
+		dev->tbusy=0;
+		dev->trans_start = jiffies;
+	}
+
+	if (set_bit(0, (void*)&dev->tbusy) != 0) {
+		 printk(KERN_ERR "%s: Transmitter access conflict.\n", dev->name);
+		 return 1;
+	}
+	if (set_bit(0, (void*)&p->lock)) {
+		printk(KERN_ERR "%s: Queue was locked.\n", dev->name);
+		return 1;
+	}
+
+	{
+		short len = ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN;
+		struct tmd *tmdp;
+		long flags;
 
 #ifdef XMT_VIA_SKB
-    if( (unsigned long) (skb->data + skb->len) > 0x1000000) {
+		if( (unsigned long) (skb->data + skb->len) > 0x1000000) {
 #endif
 
-      memcpy((char *) p->tmdbounce[p->tmdbouncenum] ,(char *)skb->data,
-               (skb->len > T_BUF_SIZE) ? T_BUF_SIZE : skb->len);
-      dev_kfree_skb (skb, FREE_WRITE);
+			memcpy((char *) p->tmdbounce[p->tmdbouncenum] ,(char *)skb->data,
+							 (skb->len > T_BUF_SIZE) ? T_BUF_SIZE : skb->len);
+			dev_kfree_skb (skb, FREE_WRITE);
 
-      save_flags(flags);
-      cli();
+			save_flags(flags);
+			cli();
 
-      tmdp = p->tmdhead + p->tmdnum;
-      tmdp->u.buffer = (u32) virt_to_bus(p->tmdbounce[p->tmdbouncenum]);
-      p->tmdbouncenum = (p->tmdbouncenum + 1) & (TMDNUM - 1);
+			tmdp = p->tmdhead + p->tmdnum;
+			tmdp->u.buffer = (u32) virt_to_bus(p->tmdbounce[p->tmdbouncenum]);
+			p->tmdbouncenum = (p->tmdbouncenum + 1) & (TMDNUM - 1);
 
 #ifdef XMT_VIA_SKB
-    }
-    else {
-      save_flags(flags);
-      cli();
+		}
+		else {
+			save_flags(flags);
+			cli();
 
-      tmdp = p->tmdhead + p->tmdnum;
-      tmdp->u.buffer = (u32) virt_to_bus(skb->data);
-      p->tmd_skb[p->tmdnum] = skb;
-    }
+			tmdp = p->tmdhead + p->tmdnum;
+			tmdp->u.buffer = (u32) virt_to_bus(skb->data);
+			p->tmd_skb[p->tmdnum] = skb;
+		}
 #endif
-    tmdp->blen = -len;
+		tmdp->blen = -len;
 
-    tmdp->u.s.status = XMIT_OWN | XMIT_START | XMIT_END;
-    writedatareg(CSR0_TDMD | CSR0_INEA); /* enable xmit & interrupt */
+		tmdp->u.s.status = XMIT_OWN | XMIT_START | XMIT_END;
+		writedatareg(CSR0_TDMD | CSR0_INEA); /* enable xmit & interrupt */
 
-    p->xmit_queued = 1;
-    p->tmdnum = (p->tmdnum + 1) & (TMDNUM-1);
+		p->xmit_queued = 1;
+		p->tmdnum = (p->tmdnum + 1) & (TMDNUM-1);
 
-    dev->tbusy = (p->tmdnum == p->tmdlast) ? 1 : 0;
-    p->lock = 0;
-    dev->trans_start = jiffies;
+		dev->tbusy = (p->tmdnum == p->tmdlast) ? 1 : 0;
+		p->lock = 0;
+		dev->trans_start = jiffies;
 
-    restore_flags(flags);
-  }
+		restore_flags(flags);
+	}
 
-  return 0;
+	return 0;
 }
 
-static struct enet_statistics *ni65_get_stats(struct device *dev)
+static struct net_device_stats *ni65_get_stats(struct device *dev)
 {
 
 #if 0
- int i;
- struct priv *p = (struct priv *) dev->priv;
- for(i=0;i<RMDNUM;i++) {
-   struct rmd *rmdp = p->rmdhead + ((p->rmdnum + i) & (RMDNUM-1));
-   printk("%02x ",rmdp->u.s.status);
- }
- printk("\n");
+	int i;
+	struct priv *p = (struct priv *) dev->priv;
+	for(i=0;i<RMDNUM;i++)
+	{
+		struct rmd *rmdp = p->rmdhead + ((p->rmdnum + i) & (RMDNUM-1));
+		printk("%02x ",rmdp->u.s.status);
+	}
+	printk("\n");
 #endif
 
-  return &((struct priv *) dev->priv)->stats;
+	return &((struct priv *) dev->priv)->stats;
 }
 
 static void set_multicast_list(struct device *dev)
@@ -1177,10 +1170,10 @@
 
 #ifdef MODULE
 static struct device dev_ni65 = {
-  "        ",  /* "ni6510": device name inserted by net_init.c */
-  0, 0, 0, 0,
-  0x360, 9,   /* I/O address, IRQ */
-  0, 0, 0, NULL, ni65_probe };
+	"				",	/* "ni6510": device name inserted by net_init.c */
+	0, 0, 0, 0,
+	0x360, 9,	 /* I/O address, IRQ */
+	0, 0, 0, NULL, ni65_probe };
 
 /* set: io,irq,dma or set it when calling insmod */
 static int irq=0;
@@ -1193,35 +1186,28 @@
 
 int init_module(void)
 {
-#if 0
-  if(io <= 0x0 || irq < 2) {
-    printk("ni65: Autoprobing not allowed for modules.\n");
-    printk("ni65: Set symbols 'io' 'irq' and 'dma'\n");
-    return -ENODEV;
-  }
-#endif
-  dev_ni65.irq = irq;
-  dev_ni65.dma = dma;
-  dev_ni65.base_addr = io;
-  if (register_netdev(&dev_ni65) != 0)
-    return -EIO;
-  return 0;
+	dev_ni65.irq = irq;
+	dev_ni65.dma = dma;
+	dev_ni65.base_addr = io;
+	if (register_netdev(&dev_ni65) != 0)
+		return -EIO;
+	return 0;
 }
 
 void cleanup_module(void)
 {
-  struct priv *p;
-  p = (struct priv *) dev_ni65.priv;
-  if(!p) {
-    printk("Ooops .. no privat struct\n");
-    return;
-  }
-  disable_dma(dev_ni65.dma);
-  free_dma(dev_ni65.dma);
-  release_region(dev_ni65.base_addr,cards[p->cardno].total_size);
-  ni65_free_buffer(p);
-  dev_ni65.priv = NULL;
-  unregister_netdev(&dev_ni65);
+	struct priv *p;
+	p = (struct priv *) dev_ni65.priv;
+	if(!p) {
+		printk("Ooops .. no private struct\n");
+		return;
+	}
+	disable_dma(dev_ni65.dma);
+	free_dma(dev_ni65.dma);
+	release_region(dev_ni65.base_addr,cards[p->cardno].total_size);
+	ni65_free_buffer(p);
+	dev_ni65.priv = NULL;
+	unregister_netdev(&dev_ni65);
 }
 #endif /* MODULE */
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov