SONIC: small fix and cleanup
[safe/jmp/linux-2.6] / drivers / net / jazzsonic.c
index 8423cb6..1a73630 100644 (file)
@@ -7,10 +7,10 @@
  * dhd's support for 16-bit cards.
  *
  * (C) 1996,1998 by Thomas Bogendoerfer (tsbogend@alpha.franken.de)
- * 
+ *
  * This driver is based on work from Andreas Busse, but most of
  * the code is rewritten.
- * 
+ *
  * (C) 1995 by Andreas Busse (andy@waldorf-gmbh.de)
  *
  * A driver for the onboard Sonic ethernet controller on Mips Jazz
@@ -33,7 +33,7 @@
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
-#include <linux/device.h>
+#include <linux/platform_device.h>
 #include <linux/dma-mapping.h>
 
 #include <asm/bootinfo.h>
@@ -65,7 +65,7 @@ do {                                                                  \
 /* use 0 for production, 1 for verification, >1 for debug */
 #ifdef SONIC_DEBUG
 static unsigned int sonic_debug = SONIC_DEBUG;
-#else 
+#else
 static unsigned int sonic_debug = 1;
 #endif
 
@@ -80,7 +80,7 @@ static struct {
 /*
  * We cannot use station (ethernet) address prefixes to detect the
  * sonic controller since these are board manufacturer depended.
- * So we check for known Silicon Revision IDs instead. 
+ * So we check for known Silicon Revision IDs instead.
  */
 static unsigned short known_revisions[] =
 {
@@ -119,7 +119,7 @@ static int __init sonic_probe1(struct net_device *dev)
                       silicon_revision);
                goto out;
        }
-    
+
        if (sonic_debug  &&  version_printed++ == 0)
                printk(version);
 
@@ -138,7 +138,7 @@ static int __init sonic_probe1(struct net_device *dev)
        }
 
        err = -ENOMEM;
-    
+
        /* Initialize the device structure. */
 
        lp->dma_bitmode = SONIC_BITMODE32;
@@ -194,7 +194,7 @@ out:
  * Probe for a SONIC ethernet controller on a Mips Jazz board.
  * Actually probing is superfluous but we're paranoid.
  */
-static int __init jazz_sonic_probe(struct device *device)
+static int __init jazz_sonic_probe(struct platform_device *pdev)
 {
        struct net_device *dev;
        struct sonic_local *lp;
@@ -212,8 +212,8 @@ static int __init jazz_sonic_probe(struct device *device)
                return -ENOMEM;
 
        lp = netdev_priv(dev);
-       lp->device = device;
-       SET_NETDEV_DEV(dev, device);
+       lp->device = &pdev->dev;
+       SET_NETDEV_DEV(dev, &pdev->dev);
        SET_MODULE_OWNER(dev);
 
        netdev_boot_setup_check(dev);
@@ -260,78 +260,61 @@ MODULE_DESCRIPTION("Jazz SONIC ethernet driver");
 module_param(sonic_debug, int, 0);
 MODULE_PARM_DESC(sonic_debug, "jazzsonic debug level (1-4)");
 
-#define SONIC_IRQ_FLAG SA_INTERRUPT
+#define SONIC_IRQ_FLAG IRQF_DISABLED
 
 #include "sonic.c"
 
-static int __devexit jazz_sonic_device_remove (struct device *device)
+static int __devexit jazz_sonic_device_remove (struct platform_device *pdev)
 {
-       struct net_device *dev = device->driver_data;
+       struct net_device *dev = platform_get_drvdata(pdev);
        struct sonic_local* lp = netdev_priv(dev);
 
-       unregister_netdev (dev);
+       unregister_netdev(dev);
        dma_free_coherent(lp->device, SIZEOF_SONIC_DESC * SONIC_BUS_SCALE(lp->dma_bitmode),
                          lp->descriptors, lp->descriptors_laddr);
        release_region (dev->base_addr, SONIC_MEM_SIZE);
-       free_netdev (dev);
+       free_netdev(dev);
 
        return 0;
 }
 
-static struct device_driver jazz_sonic_driver = {
-       .name   = jazz_sonic_string,
-       .bus    = &platform_bus_type,
+static struct platform_driver jazz_sonic_driver = {
        .probe  = jazz_sonic_probe,
        .remove = __devexit_p(jazz_sonic_device_remove),
+       .driver = {
+               .name   = jazz_sonic_string,
+       },
 };
 
-static void jazz_sonic_platform_release (struct device *device)
-{
-       struct platform_device *pldev;
-
-       /* free device */
-       pldev = to_platform_device (device);
-       kfree (pldev);
-}
-
 static int __init jazz_sonic_init_module(void)
 {
-       struct platform_device *pldev;
        int err;
 
-       if ((err = driver_register(&jazz_sonic_driver))) {
+       if ((err = platform_driver_register(&jazz_sonic_driver))) {
                printk(KERN_ERR "Driver registration failed\n");
                return err;
        }
 
-       jazz_sonic_device = NULL;
-
-       if (!(pldev = kmalloc (sizeof (*pldev), GFP_KERNEL))) {
+       jazz_sonic_device = platform_device_alloc(jazz_sonic_string, 0);
+       if (!jazz_sonic_device)
                goto out_unregister;
-       }
-
-       memset(pldev, 0, sizeof (*pldev));
-       pldev->name             = jazz_sonic_string;
-       pldev->id               = 0;
-       pldev->dev.release      = jazz_sonic_platform_release;
-       jazz_sonic_device       = pldev;
 
-       if (platform_device_register (pldev)) {
-               kfree(pldev);
+       if (platform_device_add(jazz_sonic_device)) {
+               platform_device_put(jazz_sonic_device);
                jazz_sonic_device = NULL;
        }
 
        return 0;
 
 out_unregister:
-       platform_device_unregister(pldev);
+       platform_driver_unregister(&jazz_sonic_driver);
 
        return -ENOMEM;
 }
 
 static void __exit jazz_sonic_cleanup_module(void)
 {
-       driver_unregister(&jazz_sonic_driver);
+       platform_driver_unregister(&jazz_sonic_driver);
 
        if (jazz_sonic_device) {
                platform_device_unregister(jazz_sonic_device);