patch-2.1.94 linux/drivers/acorn/net/ether1.c

Next file: linux/drivers/acorn/net/ether3.c
Previous file: linux/drivers/acorn/block/mfmhd.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.93/linux/drivers/acorn/net/ether1.c linux/drivers/acorn/net/ether1.c
@@ -41,16 +41,16 @@
 #include <linux/in.h>
 #include <linux/malloc.h>
 #include <linux/string.h>
-#include <asm/system.h>
-#include <asm/bitops.h>
-#include <asm/io.h>
-#include <asm/dma.h>
 #include <linux/errno.h>
-
+#include <linux/init.h>
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
 
+#include <asm/system.h>
+#include <asm/bitops.h>
+#include <asm/io.h>
+#include <asm/dma.h>
 #include <asm/ecard.h>
 
 #define __ETHER1_C
@@ -58,9 +58,6 @@
 
 static unsigned int net_debug = NET_DEBUG;
 
-#define 	struct ether1_priv *priv = (struct ether1_priv *)dev->priv \
-	struct ether1_priv *priv = (struct ether1_priv *)dev->priv
-
 #define BUFFER_SIZE	0x10000
 #define TX_AREA_START	0x00100
 #define TX_AREA_END	0x05000
@@ -87,7 +84,8 @@
 #define ether1_inw(dev, addr, type, offset, svflgs) ether1_inw_p (dev, addr + (int)(&((type *)0)->offset), svflgs)
 #define ether1_outw(dev, val, addr, type, offset, svflgs) ether1_outw_p (dev, val, addr + (int)(&((type *)0)->offset), svflgs)
 
-static inline unsigned short ether1_inw_p (struct device *dev, int addr, int svflgs)
+static inline unsigned short
+ether1_inw_p (struct device *dev, int addr, int svflgs)
 {
 	unsigned long flags;
 	unsigned short ret;
@@ -102,7 +100,8 @@
 	return ret;
 }
 
-static inline void ether1_outw_p (struct device *dev, unsigned short val, int addr, int svflgs)
+static inline void
+ether1_outw_p (struct device *dev, unsigned short val, int addr, int svflgs)
 {
 	unsigned long flags;
 
@@ -124,8 +123,8 @@
  * This routine is essentially an optimised memcpy from the card's
  * onboard RAM to kernel memory.
  */
- 
-static inline void *ether1_inswb (unsigned int addr, void *data, unsigned int len)
+static inline void *
+ether1_inswb (unsigned int addr, void *data, unsigned int len)
 {
 	int used;
 
@@ -161,13 +160,14 @@
 2:		adds	%3, %3, #1
 		ldreqb	%0, [%1]
 		streqb	%0, [%2]"
-		: "=&r" (used), "=&r" (addr), "=&r" (data), "=&r" (len)
-		:                "1"  (addr), "2"   (data), "3"   (len));
+	: "=&r" (used), "=&r" (addr), "=&r" (data), "=&r" (len)
+	:                "1"  (addr), "2"   (data), "3"   (len));
 
 	return data;
 }
 
-static inline void *ether1_outswb (unsigned int addr, void *data, unsigned int len)
+static inline void *
+ether1_outswb (unsigned int addr, void *data, unsigned int len)
 {
 	int used;
 
@@ -203,28 +203,26 @@
 2:		adds	%3, %3, #1
 		ldreqb	%0, [%2]
 		streqb	%0, [%1]"
-		: "=&r" (used), "=&r" (addr), "=&r" (data), "=&r" (len)
-		:                "1"  (addr), "2"   (data), "3"   (len));
+	: "=&r" (used), "=&r" (addr), "=&r" (data), "=&r" (len)
+	:                "1"  (addr), "2"   (data), "3"   (len));
 
 	return data;
 }
 
 
-static void ether1_writebuffer (struct device *dev, void *data, unsigned int start, unsigned int length)
+static void
+ether1_writebuffer (struct device *dev, void *data, unsigned int start, unsigned int length)
 {
 	unsigned int page, thislen, offset;
+
 	offset = start & 4095;
 
-	for (page = start >> 12; length; page++) 
-	{
+	for (page = start >> 12; length; page++) {
 		outb (page, REG_PAGE);
-		if (offset + length > 4096) 
-		{
-		    length -= 4096 - offset;
-		    thislen = 4096 - offset;
-		}
-		else
-		{
+		if (offset + length > 4096) {
+			length -= 4096 - offset;
+			thislen = 4096 - offset;
+		} else {
 			thislen = length;
 			length = 0;
 		}
@@ -234,23 +232,20 @@
 	}
 }
 
-static void ether1_readbuffer (struct device *dev, void *data, unsigned int start, unsigned int length)
+static void
+ether1_readbuffer (struct device *dev, void *data, unsigned int start, unsigned int length)
 {
 	unsigned int page, thislen, offset;
 
 	offset = start & 4095;
 
-	for (page = start >> 12; length; page++) 
-	{
+	for (page = start >> 12; length; page++) {
 		outb (page, REG_PAGE);
-		if (offset + length > 4096) 
-		{
+		if (offset + length > 4096) {
 			length -= 4096 - offset;
 			thislen = 4096 - offset;
-		}
-		else
-		{
-	 		thislen = length;
+		} else {
+			thislen = length;
 			length = 0;
 		}
 
@@ -259,7 +254,8 @@
 	}
 }
 
-static int ether1_ramtest (struct device *dev, unsigned char byte)
+__initfunc(static int
+ether1_ramtest (struct device *dev, unsigned char byte))
 {
 	unsigned char *buffer = kmalloc (BUFFER_SIZE, GFP_KERNEL);
 	int i, ret = BUFFER_SIZE;
@@ -275,12 +271,9 @@
 	memset (buffer, byte ^ 0xff, BUFFER_SIZE);
 	ether1_readbuffer (dev, buffer, 0, BUFFER_SIZE);
 
-	for (i = 0; i < BUFFER_SIZE; i++) 
-	{
-		if (buffer[i] != byte) 
-		{
-			if (max_errors >= 0 && bad != buffer[i]) 
-			{
+	for (i = 0; i < BUFFER_SIZE; i++) {
+		if (buffer[i] != byte) {
+			if (max_errors >= 0 && bad != buffer[i]) {
 				if (bad != -1)
 					printk ("\n");
 				printk (KERN_CRIT "%s: RAM failed with (%02X instead of %02X) at 0x%04X",
@@ -290,12 +283,9 @@
 				bad = buffer[i];
 				bad_start = i;
 			}
-		}
-		else
-		{
-			if (bad != -1) 
-			{
-				if (bad_start == i - 1)
+		} else {
+			if (bad != -1) {
+			    	if (bad_start == i - 1)
 					printk ("\n");
 				else
 					printk (" - 0x%04X\n", i - 1);
@@ -311,13 +301,15 @@
 	return ret;
 }
 
-static int ether1_reset (struct device *dev)
+static int
+ether1_reset (struct device *dev)
 {
 	outb (CTRL_RST|CTRL_ACK, REG_CONTROL);
 	return BUS_16;
 }
 
-static int ether1_init_2 (struct device *dev)
+__initfunc(static int
+ether1_init_2 (struct device *dev))
 {
 	int i;
 	dev->mem_start = 0;
@@ -328,7 +320,7 @@
 		i = ether1_ramtest (dev, 0x1e);
 
 	if (i <= 0)
-    		return -ENODEV;
+	    	return -ENODEV;
 
 	dev->mem_end = i;
 	return 0;
@@ -340,12 +332,9 @@
  */
 
 /* at 0x0100 */
-
 #define NOP_ADDR	(TX_AREA_START)
 #define NOP_SIZE	(0x06)
-
-static nop_t  init_nop  = 
-{
+static nop_t  init_nop  = {
 	0,
 	CMD_NOP,
 	NOP_ADDR
@@ -364,8 +353,7 @@
 /* at 0x002e */
 #define MC_ADDR		(0x002e)
 #define MC_SIZE		(0x0c)
-static mc_t   init_mc   = 
-{
+static mc_t   init_mc   = {
 	0,
 	CMD_SETMULTICAST,
 	TDR_ADDR,
@@ -447,7 +435,7 @@
 };
 
 #define RBD_SIZE	(0x0a)
-static rbd_t  init_rbd	= {	
+static rbd_t  init_rbd	= {
 	0,
 	0,
 	0,
@@ -458,7 +446,8 @@
 #define TX_SIZE		(0x08)
 #define TBD_SIZE	(0x08)
 
-static int ether1_init_for_open (struct device *dev)
+static int
+ether1_init_for_open (struct device *dev)
 {
 	struct ether1_priv *priv = (struct ether1_priv *)dev->priv;
 	int i, status, addr, next, next2;
@@ -479,8 +468,7 @@
 	ether1_writebuffer (dev, &init_tdr,  TDR_ADDR,  TDR_SIZE);
 	ether1_writebuffer (dev, &init_nop,  NOP_ADDR,  NOP_SIZE);
 
-	if (ether1_inw (dev, CFG_ADDR, cfg_t, cfg_command, NORMALIRQS) != CMD_CONFIG) 
-	{
+	if (ether1_inw (dev, CFG_ADDR, cfg_t, cfg_command, NORMALIRQS) != CMD_CONFIG) {
 		printk (KERN_ERR "%s: detected either RAM fault or compiler bug\n",
 			dev->name);
 		return 1;
@@ -492,21 +480,16 @@
 	 * First rfd is linked to scp, first rbd is linked to first
 	 * rfd.  Last rbd has a suspend command.
 	 */
-	
 	addr = RX_AREA_START;
-
-	do 
-	{
+	do {
 		next = addr + RFD_SIZE + RBD_SIZE + ETH_FRAME_LEN + 10;
 		next2 = next + RFD_SIZE + RBD_SIZE + ETH_FRAME_LEN + 10;
 
-		if (next2 >= RX_AREA_END) 
-		{
+		if (next2 >= RX_AREA_END) {
 			next = RX_AREA_START;
 			init_rfd.rfd_command = RFD_CMDEL | RFD_CMDSUSPEND;
 			priv->rx_tail = addr;
-		}
-		else
+		} else
 			init_rfd.rfd_command = 0;
 		if (addr == RX_AREA_START)
 			init_rfd.rfd_rbdoffset = addr + RFD_SIZE;
@@ -519,8 +502,7 @@
 		ether1_writebuffer (dev, &init_rfd, addr, RFD_SIZE);
 		ether1_writebuffer (dev, &init_rbd, addr + RFD_SIZE, RBD_SIZE);
 		addr = next;
-	}
-	while (next2 < RX_AREA_END);
+	} while (next2 < RX_AREA_END);
 
 	priv->tx_link = NOP_ADDR;
 	priv->tx_head = NOP_ADDR + NOP_SIZE;
@@ -536,10 +518,8 @@
 
 	/* 586 should now unset iscp.busy */
 	i = jiffies + HZ/2;
-	while (ether1_inw (dev, ISCP_ADDR, iscp_t, iscp_busy, DISABLEIRQS) == 1) 
-	{
-		if (jiffies > i) 
-		{
+	while (ether1_inw (dev, ISCP_ADDR, iscp_t, iscp_busy, DISABLEIRQS) == 1) {
+		if (jiffies > i) {
 			printk (KERN_WARNING "%s: can't initialise 82586: iscp is busy\n", dev->name);
 			return 1;
 		}
@@ -547,32 +527,30 @@
 
 	/* check status of commands that we issued */
 	i += HZ/10;
-	while (((status = ether1_inw (dev, CFG_ADDR, cfg_t, cfg_status, DISABLEIRQS)) & STAT_COMPLETE) == 0) 
-	{
-		if (jiffies-i<0)
+	while (((status = ether1_inw (dev, CFG_ADDR, cfg_t, cfg_status, DISABLEIRQS))
+			& STAT_COMPLETE) == 0) {
+		if (jiffies > i)
 			break;
 	}
 
-	if ((status & (STAT_COMPLETE | STAT_OK)) != (STAT_COMPLETE | STAT_OK)) 
-	{
+	if ((status & (STAT_COMPLETE | STAT_OK)) != (STAT_COMPLETE | STAT_OK)) {
 		printk (KERN_WARNING "%s: can't initialise 82586: config status %04X\n", dev->name, status);
 		printk (KERN_DEBUG "%s: SCB=[STS=%04X CMD=%04X CBL=%04X RFA=%04X]\n", dev->name,
-		ether1_inw (dev, SCB_ADDR, scb_t, scb_status, NORMALIRQS),
-		ether1_inw (dev, SCB_ADDR, scb_t, scb_command, NORMALIRQS),
-		ether1_inw (dev, SCB_ADDR, scb_t, scb_cbl_offset, NORMALIRQS),
-		ether1_inw (dev, SCB_ADDR, scb_t, scb_rfa_offset, NORMALIRQS));
+			ether1_inw (dev, SCB_ADDR, scb_t, scb_status, NORMALIRQS),
+			ether1_inw (dev, SCB_ADDR, scb_t, scb_command, NORMALIRQS),
+			ether1_inw (dev, SCB_ADDR, scb_t, scb_cbl_offset, NORMALIRQS),
+			ether1_inw (dev, SCB_ADDR, scb_t, scb_rfa_offset, NORMALIRQS));
 		failures += 1;
 	}
 
 	i += HZ/10;
-	while (((status = ether1_inw (dev, SA_ADDR, sa_t, sa_status, DISABLEIRQS)) & STAT_COMPLETE) == 0) 
-	{
-		if (jiffies-i<0)
+	while (((status = ether1_inw (dev, SA_ADDR, sa_t, sa_status, DISABLEIRQS))
+			& STAT_COMPLETE) == 0) {
+		if (jiffies > i)
 			break;
 	}
 
-	if ((status & (STAT_COMPLETE | STAT_OK)) != (STAT_COMPLETE | STAT_OK)) 
-	{
+	if ((status & (STAT_COMPLETE | STAT_OK)) != (STAT_COMPLETE | STAT_OK)) {
 		printk (KERN_WARNING "%s: can't initialise 82586: set address status %04X\n", dev->name, status);
 		printk (KERN_DEBUG "%s: SCB=[STS=%04X CMD=%04X CBL=%04X RFA=%04X]\n", dev->name,
 			ether1_inw (dev, SCB_ADDR, scb_t, scb_status, NORMALIRQS),
@@ -583,14 +561,13 @@
 	}
 
 	i += HZ/10;
-	while (((status = ether1_inw (dev, MC_ADDR, mc_t, mc_status, DISABLEIRQS)) & STAT_COMPLETE) == 0) 
-	{
-		if (jiffies-i < 0)
+	while (((status = ether1_inw (dev, MC_ADDR, mc_t, mc_status, DISABLEIRQS))
+			& STAT_COMPLETE) == 0) {
+		if (jiffies > i)
 			break;
 	}
 
-	if ((status & (STAT_COMPLETE | STAT_OK)) != (STAT_COMPLETE | STAT_OK)) 
-	{
+	if ((status & (STAT_COMPLETE | STAT_OK)) != (STAT_COMPLETE | STAT_OK)) {
 		printk (KERN_WARNING "%s: can't initialise 82586: set multicast status %04X\n", dev->name, status);
 		printk (KERN_DEBUG "%s: SCB=[STS=%04X CMD=%04X CBL=%04X RFA=%04X]\n", dev->name,
 			ether1_inw (dev, SCB_ADDR, scb_t, scb_status, NORMALIRQS),
@@ -601,33 +578,29 @@
 	}
 
 	i += HZ;
-	while (((status = ether1_inw (dev, TDR_ADDR, tdr_t, tdr_status, DISABLEIRQS)) & STAT_COMPLETE) == 0) 
-	{
-		if (jiffies-i <0)
+	while (((status = ether1_inw (dev, TDR_ADDR, tdr_t, tdr_status, DISABLEIRQS))
+			& STAT_COMPLETE) == 0) {
+		if (jiffies > i)
 			break;
 	}
 
-	if ((status & (STAT_COMPLETE | STAT_OK)) != (STAT_COMPLETE | STAT_OK)) 
-	{
+	if ((status & (STAT_COMPLETE | STAT_OK)) != (STAT_COMPLETE | STAT_OK)) {
 		printk (KERN_WARNING "%s: can't tdr (ignored)\n", dev->name);
 		printk (KERN_DEBUG "%s: SCB=[STS=%04X CMD=%04X CBL=%04X RFA=%04X]\n", dev->name,
 			ether1_inw (dev, SCB_ADDR, scb_t, scb_status, NORMALIRQS),
 			ether1_inw (dev, SCB_ADDR, scb_t, scb_command, NORMALIRQS),
 			ether1_inw (dev, SCB_ADDR, scb_t, scb_cbl_offset, NORMALIRQS),
 			ether1_inw (dev, SCB_ADDR, scb_t, scb_rfa_offset, NORMALIRQS));
-	}
-	else 
-	{
+	} else {
 		status = ether1_inw (dev, TDR_ADDR, tdr_t, tdr_result, DISABLEIRQS);
 		if (status & TDR_XCVRPROB)
 			printk (KERN_WARNING "%s: i/f failed tdr: transceiver problem\n", dev->name);
-		else if ((status & (TDR_SHORT|TDR_OPEN)) && (status & TDR_TIME)) 
-		{
+		else if ((status & (TDR_SHORT|TDR_OPEN)) && (status & TDR_TIME)) {
 #ifdef FANCY
 			printk (KERN_WARNING "%s: i/f failed tdr: cable %s %d.%d us away\n", dev->name,
 				status & TDR_SHORT ? "short" : "open", (status & TDR_TIME) / 10,
 				(status & TDR_TIME) % 10);
-#else	
+#else
 			printk (KERN_WARNING "%s: i/f failed tdr: cable %s %d clks away\n", dev->name,
 				status & TDR_SHORT ? "short" : "open", (status & TDR_TIME));
 #endif
@@ -639,7 +612,8 @@
 	return failures ? 1 : 0;
 }
 
-static int ether1_probe1 (struct device *dev)
+__initfunc(static int
+ether1_probe1 (struct device *dev))
 {
 	static unsigned int version_printed = 0;
 	struct ether1_priv *priv;
@@ -649,13 +623,12 @@
 		dev->priv = kmalloc (sizeof (struct ether1_priv), GFP_KERNEL);
 
 	if (!dev->priv)
-    		return 1;
+	    	return 1;
 
 	priv = (struct ether1_priv *)dev->priv;
 	memset (priv, 0, sizeof (struct ether1_priv));
 
-	if ((priv->bus_type = ether1_reset (dev)) == 0) 
-	{
+	if ((priv->bus_type = ether1_reset (dev)) == 0) {
 		kfree (dev->priv);
 		return 1;
 	}
@@ -672,15 +645,14 @@
 	for (i = 0; i < 6; i++)
 		printk (i==0?" %02x":i==5?":%02x\n":":%02x", dev->dev_addr[i]);
 
-	if (ether1_init_2 (dev)) 
-	{
+	if (ether1_init_2 (dev)) {
 		kfree (dev->priv);
 		return 1;
 	}
 
-	dev->open	    = ether1_open;
-	dev->stop	    = ether1_close;
-	dev->hard_start_xmit= ether1_sendpacket;
+	dev->open		    = ether1_open;
+	dev->stop		    = ether1_close;
+	dev->hard_start_xmit    = ether1_sendpacket;
 	dev->get_stats	    = ether1_getstats;
 	dev->set_multicast_list = ether1_setmulticastlist;
 
@@ -688,8 +660,7 @@
 	ether_setup (dev);
 
 #ifndef CLAIM_IRQ_AT_OPEN
-	if (request_irq (dev->irq, ether1_interrupt, 0, "ether1", dev)) 
-	{
+	if (request_irq (dev->irq, ether1_interrupt, 0, "ether1", dev)) {
 		kfree (dev->priv);
 		return -EAGAIN;
 	}
@@ -699,7 +670,8 @@
     
 /* ------------------------------------------------------------------------- */
 
-static void ether1_addr (struct device *dev)
+__initfunc(static void
+ether1_addr (struct device *dev))
 {
 	int i;
     
@@ -707,7 +679,8 @@
 		dev->dev_addr[i] = inb (IDPROM_ADDRESS + i);
 }
 
-int ether1_probe (struct device *dev)
+__initfunc(int
+ether1_probe (struct device *dev))
 {
 #ifndef MODULE
 	struct expansion_card *ec;
@@ -723,6 +696,7 @@
 	dev->irq       = ec->irq;
 
 	ecard_claim (ec);
+
 #endif
 	ether1_addr (dev);
 
@@ -733,36 +707,36 @@
 
 /* ------------------------------------------------------------------------- */
 
-static int ether1_txalloc (struct device *dev, int size)
+static int
+ether1_txalloc (struct device *dev, int size)
 {
-    	struct ether1_priv *priv = (struct ether1_priv *)dev->priv;
+	struct ether1_priv *priv = (struct ether1_priv *)dev->priv;
 	int start, tail;
 
 	size = (size + 1) & ~1;
 	tail = priv->tx_tail;
 
-	if (priv->tx_head + size > TX_AREA_END) 
-	{
+	if (priv->tx_head + size > TX_AREA_END) {
 		if (tail > priv->tx_head)
 			return -1;
 		start = TX_AREA_START;
 		if (start + size > tail)
 			return -1;
 		priv->tx_head = start + size;
-	}
-	else
-	{
+	} else {
 		if (priv->tx_head < tail && (priv->tx_head + size) > tail)
 			return -1;
 		start = priv->tx_head;
 		priv->tx_head += size;
 	}
+
 	return start;
 }
 
-static void ether1_restart (struct device *dev, char *reason)
+static void
+ether1_restart (struct device *dev, char *reason)
 {
-    	struct ether1_priv *priv = (struct ether1_priv *)dev->priv;
+	struct ether1_priv *priv = (struct ether1_priv *)dev->priv;
 	priv->stats.tx_errors ++;
 
 	if (reason)
@@ -781,9 +755,10 @@
 	dev->start = 1;
 }
 
-static int ether1_open (struct device *dev)
+static int
+ether1_open (struct device *dev)
 {
-    	struct ether1_priv *priv = (struct ether1_priv *)dev->priv;
+	struct ether1_priv *priv = (struct ether1_priv *)dev->priv;
 #ifdef CLAIM_IRQ_AT_OPEN
 	if (request_irq (dev->irq, ether1_interrupt, 0, "ether1", dev))
 		return -EAGAIN;
@@ -792,8 +767,7 @@
 
 	memset (&priv->stats, 0, sizeof (struct enet_statistics));
 
-	if (ether1_init_for_open (dev)) 
-	{
+	if (ether1_init_for_open (dev)) {
 #ifdef CLAIM_IRQ_AT_OPEN
 		free_irq (dev->irq, dev);
 #endif
@@ -808,15 +782,15 @@
 	return 0;
 }
 
-static int ether1_sendpacket (struct sk_buff *skb, struct device *dev)
+static int
+ether1_sendpacket (struct sk_buff *skb, struct device *dev)
 {
-    	struct ether1_priv *priv = (struct ether1_priv *)dev->priv;
+	struct ether1_priv *priv = (struct ether1_priv *)dev->priv;
 
 	if (priv->restart)
 		ether1_restart (dev, NULL);
 
-	if (dev->tbusy) 
-	{
+	if (dev->tbusy) {
 		/*
 		 * If we get here, some higher level has decided that we are broken.
 		 * There should really be a "kick me" function call instead.
@@ -835,11 +809,9 @@
 	 * Block a timer-based transmit from overlapping.  This could better be
 	 * done with atomic_swap(1, dev->tbusy), but set_bit() works as well.
 	 */
-	 
 	if (test_and_set_bit (0, (void *)&dev->tbusy) != 0)
 		printk (KERN_WARNING "%s: transmitter access conflict.\n", dev->name);
-	else 
-	{
+	else {
 		int len = (ETH_ZLEN < skb->len) ? skb->len : ETH_ZLEN;
 		int tmp, tst, nopaddr, txaddr, tbdaddr, dataddr;
 		unsigned long flags;
@@ -890,14 +862,15 @@
 		if (tst != -1)
 			dev->tbusy = 0;
 	}
-	dev_kfree_skb (skb, FREE_WRITE);
+	dev_kfree_skb (skb);
 
 	return 0;
 }
 
-static void ether1_xmit_done (struct device *dev)
+static void
+ether1_xmit_done (struct device *dev)
 {
-    	struct ether1_priv *priv = (struct ether1_priv *)dev->priv;
+	struct ether1_priv *priv = (struct ether1_priv *)dev->priv;
 	nop_t nop;
 	int caddr, tst;
 
@@ -906,57 +879,52 @@
 again:
 	ether1_readbuffer (dev, &nop, caddr, NOP_SIZE);
 
-	switch (nop.nop_command & CMD_MASK) 
-	{
-		case CMD_TDR:
-			/* special case */
-			if (ether1_inw (dev, SCB_ADDR, scb_t, scb_cbl_offset, NORMALIRQS) != (unsigned short)I82586_NULL) 
-			{
-				ether1_outw (dev, SCB_CMDCUCSTART | SCB_CMDRXSTART, SCB_ADDR, scb_t,
-				scb_command, NORMALIRQS);
-				outb (CTRL_CA, REG_CONTROL);
-			}
-			priv->tx_tail = NOP_ADDR;
-			return;
+	switch (nop.nop_command & CMD_MASK) {
+	case CMD_TDR:
+		/* special case */
+		if (ether1_inw (dev, SCB_ADDR, scb_t, scb_cbl_offset, NORMALIRQS)
+				!= (unsigned short)I82586_NULL) {
+			ether1_outw(dev, SCB_CMDCUCSTART | SCB_CMDRXSTART, SCB_ADDR, scb_t,
+				    scb_command, NORMALIRQS);
+			outb (CTRL_CA, REG_CONTROL);
+		}
+		priv->tx_tail = NOP_ADDR;
+		return;
 
-		case CMD_NOP:
-			if (nop.nop_link == caddr)
-			{
-				if (priv->initialising == 0)
-					printk (KERN_WARNING "%s: strange command complete with no tx command!\n", dev->name);
-				else
-	        			priv->initialising = 0;
-				return;
-			}
-			if (caddr == nop.nop_link)
-				return;
-			caddr = nop.nop_link;
-			goto again;
-
-		case CMD_TX:
-			if (nop.nop_status & STAT_COMPLETE)
-				break;
-			printk (KERN_ERR "%s: strange command complete without completed command\n", dev->name);
-			priv->restart = 1;
+	case CMD_NOP:
+		if (nop.nop_link == caddr) {
+			if (priv->initialising == 0)
+				printk (KERN_WARNING "%s: strange command complete with no tx command!\n", dev->name);
+			else
+			        priv->initialising = 0;
 			return;
-
-		default:
-			printk (KERN_WARNING "%s: strange command %d complete! (offset %04X)", dev->name,
-				nop.nop_command & CMD_MASK, caddr);
-			priv->restart = 1;
+		}
+		if (caddr == nop.nop_link)
 			return;
+		caddr = nop.nop_link;
+		goto again;
+
+	case CMD_TX:
+		if (nop.nop_status & STAT_COMPLETE)
+			break;
+		printk (KERN_ERR "%s: strange command complete without completed command\n", dev->name);
+		priv->restart = 1;
+		return;
+
+	default:
+		printk (KERN_WARNING "%s: strange command %d complete! (offset %04X)", dev->name,
+			nop.nop_command & CMD_MASK, caddr);
+		priv->restart = 1;
+		return;
 	}
 
-	while (nop.nop_status & STAT_COMPLETE) 
-	{
-		if (nop.nop_status & STAT_OK) 
-		{
+	while (nop.nop_status & STAT_COMPLETE) {
+		if (nop.nop_status & STAT_OK) {
 			priv->stats.tx_packets ++;
 			priv->stats.collisions += (nop.nop_status & STAT_COLLISIONS);
-		}
-		else
-		{
+		} else {
 			priv->stats.tx_errors ++;
+
 			if (nop.nop_status & STAT_COLLAFTERTX)
 				priv->stats.collisions ++;
 			if (nop.nop_status & STAT_NOCARRIER)
@@ -968,16 +936,15 @@
 			if (nop.nop_status & STAT_COLLEXCESSIVE)
 				priv->stats.collisions += 16;
 		}
-		if (nop.nop_link == caddr) 
-		{
+
+		if (nop.nop_link == caddr) {
 			printk (KERN_ERR "%s: tx buffer chaining error: tx command points to itself\n", dev->name);
 			break;
 		}
 
 		caddr = nop.nop_link;
 		ether1_readbuffer (dev, &nop, caddr, NOP_SIZE);
-		if ((nop.nop_command & CMD_MASK) != CMD_NOP) 
-		{
+		if ((nop.nop_command & CMD_MASK) != CMD_NOP) {
 			printk (KERN_ERR "%s: tx buffer chaining error: no nop after tx command\n", dev->name);
 			break;
 		}
@@ -987,8 +954,7 @@
 
 		caddr = nop.nop_link;
 		ether1_readbuffer (dev, &nop, caddr, NOP_SIZE);
-		if ((nop.nop_command & CMD_MASK) != CMD_TX) 
-		{
+		if ((nop.nop_command & CMD_MASK) != CMD_TX) {
 			printk (KERN_ERR "%s: tx buffer chaining error: no tx command after nop\n", dev->name);
 			break;
 		}
@@ -1004,15 +970,15 @@
 	mark_bh (NET_BH);
 }
 
-static void ether1_recv_done (struct device *dev)
+static void
+ether1_recv_done (struct device *dev)
 {
-    	struct ether1_priv *priv = (struct ether1_priv *)dev->priv;
+	struct ether1_priv *priv = (struct ether1_priv *)dev->priv;
 	int status;
 	int nexttail, rbdaddr;
 	rbd_t rbd;
 
-	do
-	{
+	do {
 		status = ether1_inw (dev, priv->rx_head, rfd_t, rfd_status, NORMALIRQS);
 		if ((status & RFD_COMPLETE) == 0)
 			break;
@@ -1020,16 +986,14 @@
 		rbdaddr = ether1_inw (dev, priv->rx_head, rfd_t, rfd_rbdoffset, NORMALIRQS);
 		ether1_readbuffer (dev, &rbd, rbdaddr, RBD_SIZE);
 
-		if ((rbd.rbd_status & (RBD_EOF | RBD_ACNTVALID)) == (RBD_EOF | RBD_ACNTVALID)) 
-		{
+		if ((rbd.rbd_status & (RBD_EOF | RBD_ACNTVALID)) == (RBD_EOF | RBD_ACNTVALID)) {
 			int length = rbd.rbd_status & RBD_ACNT;
 			struct sk_buff *skb;
 
 			length = (length + 1) & ~1;
 			skb = dev_alloc_skb (length + 2);
 
-			if (skb) 
-			{
+			if (skb) {
 				skb->dev = dev;
 				skb_reserve (skb, 2);
 
@@ -1038,13 +1002,10 @@
 				skb->protocol = eth_type_trans (skb, dev);
 				netif_rx (skb);
 				priv->stats.rx_packets ++;
-			}
-			else
+			} else
 				priv->stats.rx_dropped ++;
-		}
-		else 
-		{
-			printk (KERN_WARNING "%s: %s\n", dev->name,
+		} else {
+			printk(KERN_WARNING "%s: %s\n", dev->name,
 				(rbd.rbd_status & RBD_EOF) ? "oversized packet" : "acnt not valid");
 			priv->stats.rx_dropped ++;
 		}
@@ -1052,7 +1013,7 @@
 		nexttail = ether1_inw (dev, priv->rx_tail, rfd_t, rfd_link, NORMALIRQS);
 		/* nexttail should be rx_head */
 		if (nexttail != priv->rx_head)
-			printk (KERN_ERR "%s: receiver buffer chaining error (%04X != %04X)\n",
+			printk(KERN_ERR "%s: receiver buffer chaining error (%04X != %04X)\n",
 				dev->name, nexttail, priv->rx_head);
 		ether1_outw (dev, RFD_CMDEL | RFD_CMDSUSPEND, nexttail, rfd_t, rfd_command, NORMALIRQS);
 		ether1_outw (dev, 0, priv->rx_tail, rfd_t, rfd_command, NORMALIRQS);
@@ -1061,86 +1022,85 @@
 	
 		priv->rx_tail = nexttail;
 		priv->rx_head = ether1_inw (dev, priv->rx_head, rfd_t, rfd_link, NORMALIRQS);
-	}
-	while (1);
+	} while (1);
 }
 
-static void ether1_interrupt (int irq, void *dev_id, struct pt_regs *regs)
+static void
+ether1_interrupt (int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct device *dev = (struct device *)dev_id;
-    	struct ether1_priv *priv = (struct ether1_priv *)dev->priv;
+	struct ether1_priv *priv = (struct ether1_priv *)dev->priv;
 	int status;
 
 	dev->interrupt = 1;
 
 	status = ether1_inw (dev, SCB_ADDR, scb_t, scb_status, NORMALIRQS);
 
-	if (status) 
-	{
-		ether1_outw (dev, status & (SCB_STRNR | SCB_STCNA | SCB_STFR | SCB_STCX),
-			SCB_ADDR, scb_t, scb_command, NORMALIRQS);
+	if (status) {
+		ether1_outw(dev, status & (SCB_STRNR | SCB_STCNA | SCB_STFR | SCB_STCX),
+			    SCB_ADDR, scb_t, scb_command, NORMALIRQS);
 		outb (CTRL_CA | CTRL_ACK, REG_CONTROL);
-		if (status & SCB_STCX)
+		if (status & SCB_STCX) {
 			ether1_xmit_done (dev);
-		if (status & SCB_STCNA) 
-		{
+		}
+		if (status & SCB_STCNA) {
 			if (priv->resetting == 0)
 				printk (KERN_WARNING "%s: CU went not ready ???\n", dev->name);
 			else
 				priv->resetting += 1;
-			if (ether1_inw (dev, SCB_ADDR, scb_t, scb_cbl_offset, NORMALIRQS) != (unsigned short)I82586_NULL) 
-			{
+			if (ether1_inw (dev, SCB_ADDR, scb_t, scb_cbl_offset, NORMALIRQS)
+					!= (unsigned short)I82586_NULL) {
 				ether1_outw (dev, SCB_CMDCUCSTART, SCB_ADDR, scb_t, scb_command, NORMALIRQS);
 				outb (CTRL_CA, REG_CONTROL);
 			}
 			if (priv->resetting == 2)
 				priv->resetting = 0;
 		}
-		if (status & SCB_STFR)
+		if (status & SCB_STFR) {
 			ether1_recv_done (dev);
-
-		if (status & SCB_STRNR) 
-		{
-			if (ether1_inw (dev, SCB_ADDR, scb_t, scb_status, NORMALIRQS) & SCB_STRXSUSP) 
-			{
+		}
+		if (status & SCB_STRNR) {
+			if (ether1_inw (dev, SCB_ADDR, scb_t, scb_status, NORMALIRQS) & SCB_STRXSUSP) {
 				printk (KERN_WARNING "%s: RU went not ready: RU suspended\n", dev->name);
 				ether1_outw (dev, SCB_CMDRXRESUME, SCB_ADDR, scb_t, scb_command, NORMALIRQS);
 				outb (CTRL_CA, REG_CONTROL);
 				priv->stats.rx_dropped ++;	/* we suspended due to lack of buffer space */
-			}
-			else
-				printk (KERN_WARNING "%s: RU went not ready: %04X\n", dev->name,
-			ether1_inw (dev, SCB_ADDR, scb_t, scb_status, NORMALIRQS));
-			printk (KERN_WARNING "RU ptr = %04X\n", ether1_inw (dev, SCB_ADDR, scb_t, scb_rfa_offset,NORMALIRQS));
+			} else
+				printk(KERN_WARNING "%s: RU went not ready: %04X\n", dev->name,
+					ether1_inw (dev, SCB_ADDR, scb_t, scb_status, NORMALIRQS));
+			printk (KERN_WARNING "RU ptr = %04X\n", ether1_inw (dev, SCB_ADDR, scb_t, scb_rfa_offset,
+						NORMALIRQS));
 		}
-	}
-	else
-        	outb (CTRL_ACK, REG_CONTROL);
+	} else
+	        outb (CTRL_ACK, REG_CONTROL);
 
 	dev->interrupt = 0;
 }
 
-static int ether1_close (struct device *dev)
+static int
+ether1_close (struct device *dev)
 {
 #ifdef CLAIM_IRQ_AT_OPEN
 	free_irq (dev->irq, dev);
 #endif
 
-	ether1_reset (dev);	
+	ether1_reset (dev);
+
 	dev->start = 0;
 	dev->tbusy = 0;
+
 	MOD_DEC_USE_COUNT;
 
 	return 0;
 }
 
-static struct enet_statistics *ether1_getstats (struct device *dev)
+static struct enet_statistics *
+ether1_getstats (struct device *dev)
 {
-    	struct ether1_priv *priv = (struct ether1_priv *)dev->priv;
+	struct ether1_priv *priv = (struct ether1_priv *)dev->priv;
 	return &priv->stats;
 }
 
-
 /*
  * Set or clear the multicast filter for this adaptor.
  * num_addrs == -1	Promiscuous mode, receive all packets.
@@ -1148,8 +1108,8 @@
  * num_addrs > 0	Multicast mode, receive normal and MC packets, and do
  *			best-effort filtering.
  */
-
-static void ether1_setmulticastlist (struct device *dev)
+static void
+ether1_setmulticastlist (struct device *dev)
 {
 }
 
@@ -1161,12 +1121,12 @@
 static struct device *my_ethers[MAX_ECARDS];
 static struct expansion_card *ec[MAX_ECARDS];
 
-int init_module (void)
+int
+init_module (void)
 {
 	int i;
 
-	for (i = 0; i < MAX_ECARDS; i++) 
-	{
+	for (i = 0; i < MAX_ECARDS; i++) {
 		my_ethers[i] = NULL;
 		ec[i] = NULL;
 		strcpy (ethernames[i], "        ");
@@ -1174,10 +1134,9 @@
 
 	i = 0;
 
-	ecard_startfind();
+	ecard_startfind ();
 
-	do 
-	{
+	do {
 		if ((ec[i] = ecard_find(0, ether1_cids)) == NULL)
 			break;
 
@@ -1191,17 +1150,13 @@
 
 		ecard_claim (ec[i]);
 
-		if (register_netdev (my_ethers[i]) != 0) 
-		{
-			for (i = 0; i < 4; i++) 
-	    		{
-				if (my_ethers[i]) 
-				{
+		if (register_netdev (my_ethers[i]) != 0) {
+			for (i = 0; i < 4; i++) {
+				if (my_ethers[i]) {
 					kfree (my_ethers[i]);
 					my_ethers[i] = NULL;
 				}
-				if (ec[i])
-				{
+				if (ec[i]) {
 					ecard_release (ec[i]);
 					ec[i] = NULL;
 				}
@@ -1209,20 +1164,18 @@
 			return -EIO;
 		}
 		i++;
-	}
-	while (i < MAX_ECARDS);
+	} while (i < MAX_ECARDS);
 
 	return i != 0 ? 0 : -ENODEV;
 }
 
-void cleanup_module (void)
+void
+cleanup_module (void)
 {
 	int i;
 
-	for (i = 0; i < MAX_ECARDS; i++) 
-	{
-		if (my_ethers[i]) 
-		{
+	for (i = 0; i < MAX_ECARDS; i++) {
+		if (my_ethers[i]) {
 			unregister_netdev (my_ethers[i]);
 			release_region (my_ethers[i]->base_addr, 16);
 			release_region (my_ethers[i]->base_addr + 0x800, 4096);
@@ -1231,8 +1184,7 @@
 #endif
 			my_ethers[i] = NULL;
 		}
-		if (ec[i]) 
-		{
+		if (ec[i]) {
 			ecard_release (ec[i]);
 			ec[i] = NULL;
 		}

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