]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - arch/um/drivers/net_kern.c
Pull style into test branch
[mv-sheeva.git] / arch / um / drivers / net_kern.c
index c1c5604752fb20dada9f293393f3a8e32c4e0520..afe3d427ddfae510b29135453dcfa3217252c308 100644 (file)
@@ -72,12 +72,14 @@ static int uml_net_rx(struct net_device *dev)
        return pkt_len;
 }
 
-static void uml_dev_close(void* dev)
+static void uml_dev_close(struct work_struct *work)
 {
-       dev_close( (struct net_device *) dev);
+       struct uml_net_private *lp =
+               container_of(work, struct uml_net_private, work);
+       dev_close(lp->dev);
 }
 
-irqreturn_t uml_net_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+irqreturn_t uml_net_interrupt(int irq, void *dev_id)
 {
        struct net_device *dev = dev_id;
        struct uml_net_private *lp = dev->priv;
@@ -89,7 +91,6 @@ irqreturn_t uml_net_interrupt(int irq, void *dev_id, struct pt_regs *regs)
        spin_lock(&lp->lock);
        while((err = uml_net_rx(dev)) > 0) ;
        if(err < 0) {
-               DECLARE_WORK(close_work, uml_dev_close, dev);
                printk(KERN_ERR 
                       "Device '%s' read returned %d, shutting it down\n", 
                       dev->name, err);
@@ -97,8 +98,10 @@ irqreturn_t uml_net_interrupt(int irq, void *dev_id, struct pt_regs *regs)
                 * again lp->lock.
                 * And dev_close() can be safely called multiple times on the
                 * same device, since it tests for (dev->flags & IFF_UP). So
-                * there's no harm in delaying the device shutdown. */
-               schedule_work(&close_work);
+                * there's no harm in delaying the device shutdown.
+                * Furthermore, the workqueue will not re-enqueue an already
+                * enqueued work item. */
+               schedule_work(&lp->work);
                goto out;
        }
        reactivate_fd(lp->fd, UM_ETH_IRQ);
@@ -333,13 +336,12 @@ static int eth_configure(int n, void *init, char *mac,
        size = transport->private_size + sizeof(struct uml_net_private) + 
                sizeof(((struct uml_net_private *) 0)->user);
 
-       device = kmalloc(sizeof(*device), GFP_KERNEL);
+       device = kzalloc(sizeof(*device), GFP_KERNEL);
        if (device == NULL) {
                printk(KERN_ERR "eth_configure failed to allocate uml_net\n");
                return(1);
        }
 
-       memset(device, 0, sizeof(*device));
        INIT_LIST_HEAD(&device->list);
        device->index = n;
 
@@ -365,6 +367,7 @@ static int eth_configure(int n, void *init, char *mac,
        /* This points to the transport private data. It's still clear, but we
         * must memset it to 0 *now*. Let's help the drivers. */
        memset(lp, 0, size);
+       INIT_WORK(&lp->work, uml_dev_close);
 
        /* sysfs register */
        if (!driver_registered) {