diff --git a/snull/snull.c b/snull/snull.c index 917ddec6c..290d9d988 100644 --- a/snull/snull.c +++ b/snull/snull.c @@ -140,13 +140,15 @@ static struct snull_packet *snull_get_tx_buffer(struct net_device *dev) pkt = priv->ppool; if(!pkt) { PDEBUG("Out of Pool\n"); - return pkt; + goto out; } priv->ppool = pkt->next; if (priv->ppool == NULL) { printk (KERN_INFO "Pool empty\n"); netif_stop_queue(dev); } + +out: spin_unlock_irqrestore(&priv->lock, flags); return pkt; } @@ -426,9 +428,9 @@ static void snull_napi_interrupt(int irq, void *dev_id, struct pt_regs *regs) /* retrieve statusword: real netdevices use I/O instructions */ statusword = priv->status; priv->status = 0; - if (statusword & SNULL_RX_INTR) { + if (statusword & SNULL_RX_INTR && napi_schedule_prep(&priv->napi)) { snull_rx_ints(dev, 0); /* Disable further interrupts */ - napi_schedule(&priv->napi); + __napi_schedule(&priv->napi); } if (statusword & SNULL_TX_INTR) { /* a transmission is over: free the skb */ @@ -750,28 +752,29 @@ static void snull_cleanup(void) static int snull_init_module(void) { - int result, i, ret = -ENOMEM; + int result, i, ret = 0; snull_interrupt = use_napi ? snull_napi_interrupt : snull_regular_interrupt; - /* Allocate the devices */ - snull_devs[0] = alloc_netdev(sizeof(struct snull_priv), "sn%d", - NET_NAME_UNKNOWN, snull_init); - snull_devs[1] = alloc_netdev(sizeof(struct snull_priv), "sn%d", + /* Allocate and register the devices */ + for (i = 0; i < 2; i++) { + snull_devs[i] = alloc_netdev(sizeof(struct snull_priv), "sn%d", NET_NAME_UNKNOWN, snull_init); - if (snull_devs[0] == NULL || snull_devs[1] == NULL) - goto out; - ret = -ENODEV; - for (i = 0; i < 2; i++) - if ((result = register_netdev(snull_devs[i]))) + if (snull_devs[i] == NULL) { + ret = -ENOMEM; + break; + } + + if ((result = register_netdev(snull_devs[i]))) { printk("snull: error %i registering device \"%s\"\n", result, snull_devs[i]->name); - else - ret = 0; - out: - if (ret) - snull_cleanup(); + free_netdev(snull_devs[i]); + ret = -ENODEV; + break; + } + } + return ret; }