Merge to Fedora kernel-2.6.18-1.2224_FC5 patched with stable patch-2.6.18.1-vs2.0...
[linux-2.6.git] / drivers / net / depca.c
index ec6d9d0..b1cbe99 100644 (file)
     =========================================================================
 */
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/string.h>
 #include <linux/unistd.h>
 #include <linux/ctype.h>
 #include <linux/moduleparam.h>
-#include <linux/device.h>
+#include <linux/platform_device.h>
 #include <linux/bitops.h>
 
 #include <asm/uaccess.h>
@@ -342,14 +341,15 @@ static char depca_string[] = "depca";
 static int depca_device_remove (struct device *device);
 
 #ifdef CONFIG_EISA
-struct eisa_device_id depca_eisa_ids[] = {
+static struct eisa_device_id depca_eisa_ids[] = {
        { "DEC4220", de422 },
        { "" }
 };
+MODULE_DEVICE_TABLE(eisa, depca_eisa_ids);
 
 static int depca_eisa_probe  (struct device *device);
 
-struct eisa_driver depca_eisa_driver = {
+static struct eisa_driver depca_eisa_driver = {
        .id_table = depca_eisa_ids,
        .driver   = {
                .name    = depca_string,
@@ -397,13 +397,19 @@ static struct mca_driver depca_mca_driver = {
 };
 #endif
 
-static int depca_isa_probe (struct device *);
+static int depca_isa_probe (struct platform_device *);
 
-static struct device_driver depca_isa_driver = {
-       .name   = depca_string,
-       .bus    = &platform_bus_type,
+static int __devexit depca_isa_remove(struct platform_device *pdev)
+{
+       return depca_device_remove(&pdev->dev);
+}
+
+static struct platform_driver depca_isa_driver = {
        .probe  = depca_isa_probe,
-       .remove = __devexit_p(depca_device_remove),
+       .remove = __devexit_p(depca_isa_remove),
+       .driver = {
+               .name   = depca_string,
+       },
 };
        
 /*
@@ -931,11 +937,8 @@ static int depca_start_xmit(struct sk_buff *skb, struct net_device *dev)
        if (skb->len < 1)
                goto out;
 
-       if (skb->len < ETH_ZLEN) {
-               skb = skb_padto(skb, ETH_ZLEN);
-               if (skb == NULL)
-                       goto out;
-       }
+       if (skb_padto(skb, ETH_ZLEN))
+               goto out;
        
        netif_stop_queue(dev);
 
@@ -1405,7 +1408,7 @@ static int __init depca_mca_probe(struct device *device)
                irq = 11;
                break;
        default:
-               printk("%s: mca_probe IRQ error.  You should never get here (%d).\n", dev->name, where);
+               printk("%s: mca_probe IRQ error.  You should never get here (%d).\n", mdev->name, where);
                return -EINVAL;
        }
 
@@ -1469,15 +1472,6 @@ static int __init depca_mca_probe(struct device *device)
 ** ISA bus I/O device probe
 */
 
-static void depca_platform_release (struct device *device)
-{
-       struct platform_device *pldev;
-
-       /* free device */
-       pldev = to_platform_device (device);
-       kfree (pldev);
-}
-
 static void __init depca_platform_probe (void)
 {
        int i;
@@ -1490,19 +1484,16 @@ static void __init depca_platform_probe (void)
                 * line, use it (if valid) */
                if (io && io != depca_io_ports[i].iobase)
                        continue;
-               
-               if (!(pldev = kmalloc (sizeof (*pldev), GFP_KERNEL)))
+
+               pldev = platform_device_alloc(depca_string, i);
+               if (!pldev)
                        continue;
 
-               memset (pldev, 0, sizeof (*pldev));
-               pldev->name = depca_string;
-               pldev->id   = i;
                pldev->dev.platform_data = (void *) depca_io_ports[i].iobase;
-               pldev->dev.release       = depca_platform_release;
                depca_io_ports[i].device = pldev;
 
-               if (platform_device_register (pldev)) {
-                       kfree (pldev);
+               if (platform_device_add(pldev)) {
+                       platform_device_put(pldev);
                        depca_io_ports[i].device = NULL;
                        continue;
                }
@@ -1514,6 +1505,7 @@ static void __init depca_platform_probe (void)
                 * allocated structure */
                        
                        depca_io_ports[i].device = NULL;
+                       pldev->dev.platform_data = NULL;
                        platform_device_unregister (pldev);
                }
        }
@@ -1535,7 +1527,7 @@ static enum depca_type __init depca_shmem_probe (ulong *mem_start)
        return adapter;
 }
 
-static int __init depca_isa_probe (struct device *device)
+static int __init depca_isa_probe (struct platform_device *device)
 {
        struct net_device *dev;
        struct depca_private *lp;
@@ -1543,7 +1535,7 @@ static int __init depca_isa_probe (struct device *device)
        enum depca_type adapter = unknown;
        int status = 0;
 
-       ioaddr = (u_long) device->platform_data;
+       ioaddr = (u_long) device->dev.platform_data;
 
        if ((status = depca_common_init (ioaddr, &dev)))
                goto out;
@@ -1563,7 +1555,7 @@ static int __init depca_isa_probe (struct device *device)
        lp->adapter = adapter;
        lp->mem_start = mem_start;
        
-       if ((status = depca_hw_init(dev, device)))
+       if ((status = depca_hw_init(dev, &device->dev)))
                goto out_free;
        
        return 0;
@@ -1826,7 +1818,7 @@ static int load_packet(struct net_device *dev, struct sk_buff *skb)
 
                /* set up the buffer descriptors */
                len = (skb->len < ETH_ZLEN) ? ETH_ZLEN : skb->len;
-               for (i = entry; i != end; i = (++i) & lp->txRingMask) {
+               for (i = entry; i != end; i = (i+1) & lp->txRingMask) {
                        /* clean out flags */
                        writel(readl(&lp->tx_ring[i].base) & ~T_FLAGS, &lp->tx_ring[i].base);
                        writew(0x0000, &lp->tx_ring[i].misc);   /* clears other error flags */
@@ -2092,7 +2084,7 @@ static int __init depca_module_init (void)
 #ifdef CONFIG_EISA
         err |= eisa_driver_register (&depca_eisa_driver);
 #endif
-       err |= driver_register (&depca_isa_driver);
+       err |= platform_driver_register (&depca_isa_driver);
        depca_platform_probe ();
        
         return err;
@@ -2107,10 +2099,11 @@ static void __exit depca_module_exit (void)
 #ifdef CONFIG_EISA
         eisa_driver_unregister (&depca_eisa_driver);
 #endif
-       driver_unregister (&depca_isa_driver);
+       platform_driver_unregister (&depca_isa_driver);
 
        for (i = 0; depca_io_ports[i].iobase; i++) {
                if (depca_io_ports[i].device) {
+                       depca_io_ports[i].device->dev.platform_data = NULL;
                        platform_device_unregister (depca_io_ports[i].device);
                        depca_io_ports[i].device = NULL;
                }