patch-2.4.3 linux/drivers/net/sgiseeq.c

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

diff -u --recursive --new-file v2.4.2/linux/drivers/net/sgiseeq.c linux/drivers/net/sgiseeq.c
@@ -149,7 +149,7 @@
 #define RCNTCFG_INIT  (HPCDMA_OWN | HPCDMA_EORP | HPCDMA_XIE)
 #define RCNTINFO_INIT (RCNTCFG_INIT | (PKT_BUF_SZ & HPCDMA_BCNT))
 
-static void seeq_init_ring(struct net_device *dev)
+static int seeq_init_ring(struct net_device *dev)
 {
 	struct sgiseeq_private *sp = (struct sgiseeq_private *) dev->priv;
 	volatile struct sgiseeq_init_block *ib = &sp->srings;
@@ -173,6 +173,8 @@
 			unsigned long buffer;
 
 			buffer = (unsigned long) kmalloc(PKT_BUF_SZ, GFP_KERNEL);
+			if (!buffer)
+				return -ENOMEM;
 			ib->tx_desc[i].buf_vaddr = KSEG1ADDR(buffer);
 			ib->tx_desc[i].tdma.pbuf = PHYSADDR(buffer);
 //			flush_cache_all();
@@ -186,6 +188,8 @@
 			unsigned long buffer;
 
 			buffer = (unsigned long) kmalloc(PKT_BUF_SZ, GFP_KERNEL);
+			if (!buffer)
+				return -ENOMEM;
 			ib->rx_desc[i].buf_vaddr = KSEG1ADDR(buffer);
 			ib->rx_desc[i].rdma.pbuf = PHYSADDR(buffer);
 //			flush_cache_all();
@@ -193,6 +197,7 @@
 		ib->rx_desc[i].rdma.cntinfo = (RCNTINFO_INIT);
 	}
 	ib->rx_desc[i - 1].rdma.cntinfo |= (HPCDMA_EOR);
+	return 0;
 }
 
 #ifdef DEBUG
@@ -242,13 +247,16 @@
 #define TSTAT_INIT_EDLC ((TSTAT_INIT_SEEQ) | SEEQ_TCMD_RB2)
 #define RDMACFG_INIT    (HPC3_ERXDCFG_FRXDC | HPC3_ERXDCFG_FEOP | HPC3_ERXDCFG_FIRQ)
 
-static void init_seeq(struct net_device *dev, struct sgiseeq_private *sp,
+static int init_seeq(struct net_device *dev, struct sgiseeq_private *sp,
 		      volatile struct sgiseeq_regs *sregs)
 {
 	volatile struct hpc3_ethregs *hregs = sp->hregs;
+	int err;
 
 	reset_hpc3_and_seeq(hregs, sregs);
-	seeq_init_ring(dev);
+	err = seeq_init_ring(dev);
+	if (err)
+		return err;
 
 	/* Setup to field the proper interrupt types. */
 	if (sp->is_edlc) {
@@ -265,6 +273,7 @@
 	hregs->tx_ndptr = PHYSADDR(&sp->srings.tx_desc[0]);
 
 	seeq_go(sp, hregs, sregs);
+	return 0;
 }
 
 static inline void record_rx_errors(struct sgiseeq_private *sp,
@@ -440,6 +449,7 @@
 	struct sgiseeq_private *sp = (struct sgiseeq_private *)dev->priv;
 	volatile struct sgiseeq_regs *sregs = sp->sregs;
 	unsigned long flags;
+	int err;
 
 	save_flags(flags); cli();
 	if (request_irq(dev->irq, sgiseeq_interrupt, 0, sgiseeqstr, (void *) dev)) {
@@ -448,7 +458,9 @@
 		return -EAGAIN;
 	}
 
-	init_seeq(dev, sp, sregs);
+	err = init_seeq(dev, sp, sregs);
+	if (err)
+		return err;
 
 	netif_start_queue(dev);
 	restore_flags(flags);
@@ -474,8 +486,11 @@
 {
 	struct sgiseeq_private *sp = (struct sgiseeq_private *) dev->priv;
 	volatile struct sgiseeq_regs *sregs = sp->sregs;
+	int err;
 
-	init_seeq(dev, sp, sregs);
+	err = init_seeq(dev, sp, sregs);
+	if (err)
+		return err;
 
 	dev->trans_start = jiffies;
 	netif_wake_queue(dev);

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)