[parisc-linux-cvs] lasi 82596 fixes

Helge Deller deller at gmx.de
Sat Apr 24 17:01:02 MDT 2004


On Sunday 25 April 2004 00:56, Helge Deller wrote:
> CVSROOT:	/var/cvs
> Module name:	linux-2.6
> Changes by:	deller	04/04/24 16:56:24
> 
> Modified files:
> 	drivers/net    : lasi_82596.c 
> 
> Log message:
> fix boot message: print "eth0:" instead of "eth%d",
> various cleanups
-------------- next part --------------
Index: lasi_82596.c
===================================================================
RCS file: /var/cvs/linux-2.6/drivers/net/lasi_82596.c,v
retrieving revision 1.8
diff -u -p -r1.8 lasi_82596.c
--- a/lasi_82596.c	31 Mar 2004 16:17:24 -0000	1.8
+++ b/lasi_82596.c	24 Apr 2004 22:53:33 -0000
@@ -93,8 +93,7 @@
 #include <asm/cache.h>
 #include <asm/parisc-device.h>
 
-static char version[] __devinitdata =
-	"82596.c $Revision: 1.29 $\n";
+#define LASI_82596_DRIVER_VERSION "LASI 82596 driver - Revision: 1.30"
 
 /* DEBUG flags
  */
@@ -553,7 +552,7 @@ static inline void init_rx_bufs(struct n
 		struct sk_buff *skb = dev_alloc_skb(PKT_BUF_SZ + 4);
 
 		if (skb == NULL)
-			panic("82596: alloc_skb() failed");
+			panic(__FILE__ ": alloc_skb() failed");
 		skb_reserve(skb, 2);
 		dma_addr = dma_map_single(lp->dev, skb->tail,PKT_BUF_SZ,
 					  DMA_FROM_DEVICE);
@@ -638,8 +637,8 @@ static int init_i596_mem(struct net_devi
 
 	disable_irq(dev->irq);	/* disable IRQs from LAN */
 	DEB(DEB_INIT,
-		printk("RESET 82596 port: %08lX (with IRQ%d disabled)\n",
-		       dev->base_addr + PA_I82596_RESET,
+		printk("RESET 82596 port: %p (with IRQ %d disabled)\n",
+		       (void*)(dev->base_addr + PA_I82596_RESET),
 		       dev->irq));
 	
 	gsc_writel(0, (void*)(dev->base_addr + PA_I82596_RESET)); /* Hard Reset */
@@ -668,7 +667,7 @@ static int init_i596_mem(struct net_devi
 
 	CA(dev);
 
-	if (wait_istat(dev,lp,1000,"initialization timed out"))
+	if (wait_istat(dev, lp, 1000, "initialization timed out"))
 		goto failed;
 	DEB(DEB_INIT,printk("%s: i82596 initialization successful\n", dev->name));
 
@@ -699,7 +698,7 @@ static int init_i596_mem(struct net_devi
 
 	spin_lock_irqsave (&lp->lock, flags);
 
-	if (wait_cmd(dev,lp,1000,"timed out waiting to issue RX_START")) {
+	if (wait_cmd(dev, lp, 1000, "timed out waiting to issue RX_START")) {
 		spin_unlock_irqrestore (&lp->lock, flags);
 		goto failed;
 	}
@@ -712,7 +711,7 @@ static int init_i596_mem(struct net_devi
 
 	spin_unlock_irqrestore (&lp->lock, flags);
 
-	if (wait_cmd(dev,lp,1000,"RX_START not processed"))
+	if (wait_cmd(dev, lp, 1000, "RX_START not processed"))
 		goto failed;
 	DEB(DEB_INIT,printk("%s: Receive unit started OK\n", dev->name));
 
@@ -903,7 +902,7 @@ static inline void i596_cleanup_cmd(stru
 		CHECK_WBACK_INV(ptr, sizeof(struct i596_cmd));
 	}
 
-	wait_cmd(dev,lp,100,"i596_cleanup_cmd timed out");
+	wait_cmd(dev, lp, 100, "i596_cleanup_cmd timed out");
 	lp->scb.cmd = I596_NULL;
 	CHECK_WBACK(&(lp->scb), sizeof(struct i596_scb));
 }
@@ -917,7 +916,7 @@ static inline void i596_reset(struct net
 
 	spin_lock_irqsave (&lp->lock, flags);
 
-	wait_cmd(dev,lp,100,"i596_reset timed out");
+	wait_cmd(dev, lp, 100, "i596_reset timed out");
 
 	netif_stop_queue(dev);
 
@@ -927,7 +926,7 @@ static inline void i596_reset(struct net
 	CA(dev);
 
 	/* wait for shutdown */
-	wait_cmd(dev,lp,1000,"i596_reset 2 timed out");
+	wait_cmd(dev, lp, 1000, "i596_reset 2 timed out");
 	spin_unlock_irqrestore (&lp->lock, flags);
 
 	i596_cleanup_cmd(dev,lp);
@@ -959,7 +958,7 @@ static void i596_add_cmd(struct net_devi
 		CHECK_WBACK(lp->cmd_tail, sizeof(struct i596_cmd));
 	} else {
 		lp->cmd_head = cmd;
-		wait_cmd(dev,lp,100,"i596_add_cmd timed out");
+		wait_cmd(dev, lp, 100, "i596_add_cmd timed out");
 		lp->scb.cmd = WSWAPcmd(virt_to_dma(lp,&cmd->status));
 		lp->scb.command = CUC_START;
 		CHECK_WBACK(&(lp->scb), sizeof(struct i596_scb));
@@ -1156,29 +1155,29 @@ static int __devinit i82596_probe(struct
 
 	/* This lot is ensure things have been cache line aligned. */
 	if (sizeof(struct i596_rfd) != 32) {
-	    printk("82596: sizeof(struct i596_rfd) = %d\n",
-			    (int)sizeof(struct i596_rfd));
+	    printk(KERN_ERR __FILE__ ": sizeof(struct i596_rfd) = %d\n",
+			sizeof(struct i596_rfd));
 	    return -ENODEV;
 	}
 	if ((sizeof(struct i596_rbd) % 32) != 0) {
-	    printk("82596: sizeof(struct i596_rbd) = %d\n",
-			    (int)sizeof(struct i596_rbd));
+	    printk(KERN_ERR __FILE__ ": sizeof(struct i596_rbd) = %d\n",
+			sizeof(struct i596_rbd));
 	    return -ENODEV;
 	}
 	if ((sizeof(struct tx_cmd) % 32) != 0) {
-	    printk("82596: sizeof(struct tx_cmd) = %d\n",
-			    (int)sizeof(struct tx_cmd));
+	    printk(KERN_ERR __FILE__ ": sizeof(struct tx_cmd) = %d\n",
+			sizeof(struct tx_cmd));
 	    return -ENODEV;
 	}
 	if (sizeof(struct i596_tbd) != 32) {
-	    printk("82596: sizeof(struct i596_tbd) = %d\n",
-			    (int)sizeof(struct i596_tbd));
+	    printk(KERN_ERR __FILE__ ": sizeof(struct i596_tbd) = %d\n",
+			sizeof(struct i596_tbd));
 	    return -ENODEV;
 	}
 #ifndef __LP64__
 	if (sizeof(struct i596_private) > 4096) {
-	    printk("82596: sizeof(struct i596_private) = %d\n",
-			    (int)sizeof(struct i596_private));
+	    printk(KERN_ERR __FILE__ ": sizeof(struct i596_private) = %d\n",
+			sizeof(struct i596_private));
 	    return -ENODEV;
 	}
 #endif
@@ -1190,24 +1189,18 @@ static int __devinit i82596_probe(struct
 		for (i=0; i < 6; i++) {
 			eth_addr[i] = gsc_readb(LAN_PROM_ADDR + i);
 		}
-		printk("82596.c: MAC of HP700 LAN read from EEPROM\n");
+		printk(KERN_INFO __FILE__ ": MAC of HP700 LAN read from EEPROM\n");
 	}
 
 	dev->mem_start = (unsigned long) dma_alloc_noncoherent(gen_dev, 
 		sizeof(struct i596_private), &dma_addr, GFP_KERNEL);
 	if (!dev->mem_start) {
-		printk("%s: Couldn't get shared memory\n", dev->name);
+		printk(KERN_ERR __FILE__ ": Couldn't get shared memory\n");
 		return -ENOMEM;
 	}
 
-	DEB(DEB_PROBE,printk("%s: 82596 at %#3lx,", dev->name, dev->base_addr));
-
 	for (i = 0; i < 6; i++)
-		DEB(DEB_PROBE,printk(" %2.2X", dev->dev_addr[i] = eth_addr[i]));
-
-	DEB(DEB_PROBE,printk(" IRQ %d.\n", dev->irq));
-
-	DEB(DEB_PROBE,printk(version));
+		dev->dev_addr[i] = eth_addr[i];
 
 	/* The 82596-specific entries in the device structure. */
 	dev->open = i596_open;
@@ -1221,9 +1214,6 @@ static int __devinit i82596_probe(struct
 	dev->priv = (void *)(dev->mem_start);
 
 	lp = dev->priv;
-	DEB(DEB_INIT,printk ("%s: lp at 0x%08lx (%d bytes), lp->scb at 0x%08lx\n",
-		dev->name, (unsigned long)lp,
-		(int)sizeof(struct i596_private), (unsigned long)&lp->scb));
 	memset(lp, 0, sizeof(struct i596_private));
 
 	lp->scb.command = 0;
@@ -1235,6 +1225,21 @@ static int __devinit i82596_probe(struct
 
 	CHECK_WBACK_INV(dev->mem_start, sizeof(struct i596_private));
 
+	i = register_netdev(dev);
+	if (i) {
+		lp = dev->priv;
+		dma_free_noncoherent(lp->dev, sizeof(struct i596_private), 
+				    (void *)dev->mem_start, lp->dma_addr);
+		return i;
+	};
+
+	DEB(DEB_PROBE,printk(KERN_INFO "%s: 82596 at %#3lx,", dev->name, dev->base_addr));
+	for (i = 0; i < 6; i++)
+		DEB(DEB_PROBE,printk(" %2.2X", dev->dev_addr[i]));
+	DEB(DEB_PROBE,printk(" IRQ %d.\n", dev->irq));
+	DEB(DEB_INIT,printk(KERN_INFO "%s: lp at 0x%p (%d bytes), lp->scb at 0x%p\n",
+		dev->name, lp, sizeof(struct i596_private), &lp->scb));
+
 	return 0;
 }
 
@@ -1246,7 +1251,7 @@ static irqreturn_t i596_interrupt(int ir
 	unsigned short status, ack_cmd = 0;
 
 	if (dev == NULL) {
-		printk("i596_interrupt(): irq %d for unknown device.\n", irq);
+		printk("%s: irq %d for unknown device.\n", __FUNCTION__, irq);
 		return IRQ_NONE;
 	}
 
@@ -1254,7 +1259,7 @@ static irqreturn_t i596_interrupt(int ir
 
 	spin_lock (&lp->lock);
 
-	wait_cmd(dev,lp,100,"i596 interrupt, timeout");
+	wait_cmd(dev, lp, 100, "i596 interrupt, timeout");
 	status = lp->scb.status;
 
 	DEB(DEB_INTS,printk("%s: i596 interrupt, IRQ %d, status %4.4x.\n",
@@ -1377,7 +1382,7 @@ static irqreturn_t i596_interrupt(int ir
 			}
 		}
 	}
-	wait_cmd(dev,lp,100,"i596 interrupt, timeout");
+	wait_cmd(dev, lp, 100, "i596 interrupt, timeout");
 	lp->scb.command = ack_cmd;
 	CHECK_WBACK(&lp->scb, sizeof(struct i596_scb));
 
@@ -1387,7 +1392,7 @@ static irqreturn_t i596_interrupt(int ir
 
 	CA(dev);
 
-	wait_cmd(dev,lp,100,"i596 interrupt, exit timeout");
+	wait_cmd(dev, lp, 100, "i596 interrupt, exit timeout");
 	DEB(DEB_INTS,printk("%s: exiting interrupt.\n", dev->name));
 
 	spin_unlock (&lp->lock);
@@ -1406,13 +1411,13 @@ static int i596_close(struct net_device 
 
 	spin_lock_irqsave(&lp->lock, flags);
 
-	wait_cmd(dev,lp,100,"close1 timed out");
+	wait_cmd(dev, lp, 100, "close1 timed out");
 	lp->scb.command = CUC_ABORT | RX_ABORT;
 	CHECK_WBACK(&lp->scb, sizeof(struct i596_scb));
 
 	CA(dev);
 
-	wait_cmd(dev,lp,100,"close2 timed out");
+	wait_cmd(dev, lp, 100, "close2 timed out");
 	spin_unlock_irqrestore(&lp->lock, flags);
 	DEB(DEB_STRUCT,i596_display_data(dev));
 	i596_cleanup_cmd(dev,lp);
@@ -1516,8 +1521,11 @@ lan_init_chip(struct parisc_device *dev)
 
 	if (num_drivers >= MAX_DRIVERS) {
 		/* max count of possible i82596 drivers reached */
-		return -ENODEV;
+		return -ENOMEM;
 	}
+
+	if (num_drivers == 0)
+		printk(KERN_INFO LASI_82596_DRIVER_VERSION "\n");
 	
 	if (!dev->irq) {
 		printk(KERN_ERR __FILE__ ": IRQ not found for i82596 at 0x%lx\n", dev->hpa);
@@ -1539,15 +1547,6 @@ lan_init_chip(struct parisc_device *dev)
 		return -ENODEV;
 	}
 
-	retval = register_netdev(netdevice);
-	if (retval) {
-		struct i596_private *lp = netdevice->priv;
-		printk(KERN_WARNING __FILE__ ": register_netdevice ret'd %d\n", retval);
-		dma_free_noncoherent(lp->dev, sizeof(struct i596_private), 
-				    (void *)netdevice->mem_start, lp->dma_addr);
-		free_netdev(netdevice);
-		return -ENODEV;
-	};
 	if (dev->id.sversion == 0x72) {
 		((struct i596_private *)netdevice->priv)->options = OPT_SWAP_PORT;
 	}
@@ -1600,6 +1599,7 @@ static void __exit lasi_82596_exit(void)
 				       (void *)netdevice->mem_start, lp->dma_addr);
 		free_netdev(netdevice);
 	}
+	num_drivers = 0;
 
 	unregister_parisc_driver(&lan_driver);
 }


More information about the parisc-linux-cvs mailing list