vserver 2.0 rc7
[linux-2.6.git] / drivers / net / wireless / airport.c
index b2ad9cd..b4f4bd7 100644 (file)
@@ -1,4 +1,4 @@
-/* airport.c 0.13e
+/* airport.c
  *
  * A driver for "Hermes" chipset based Apple Airport wireless
  * card.
@@ -11,6 +11,9 @@
  *  0.06 : fix possible hang on powerup, add sleep support
  */
 
+#define DRIVER_NAME "airport"
+#define PFX DRIVER_NAME ": "
+
 #include <linux/config.h>
 
 #include <linux/module.h>
 
 struct airport {
        struct macio_dev *mdev;
-       void *vaddr;
+       void __iomem *vaddr;
        int irq_requested;
        int ndev_registered;
 };
 
 static int
-airport_suspend(struct macio_dev *mdev, u32 state)
+airport_suspend(struct macio_dev *mdev, pm_message_t state)
 {
        struct net_device *dev = dev_get_drvdata(&mdev->ofdev.dev);
-       struct orinoco_private *priv = dev->priv;
+       struct orinoco_private *priv = netdev_priv(dev);
        unsigned long flags;
        int err;
 
@@ -84,15 +87,14 @@ static int
 airport_resume(struct macio_dev *mdev)
 {
        struct net_device *dev = dev_get_drvdata(&mdev->ofdev.dev);
-       struct orinoco_private *priv = dev->priv;
+       struct orinoco_private *priv = netdev_priv(dev);
        unsigned long flags;
        int err;
 
        printk(KERN_DEBUG "%s: Airport waking up\n", dev->name);
 
        pmac_call_feature(PMAC_FTR_AIRPORT_ENABLE, macio_get_of_node(mdev), 0, 1);
-       set_current_state(TASK_UNINTERRUPTIBLE);
-       schedule_timeout(HZ/5);
+       msleep(200);
 
        enable_irq(dev->irq);
 
@@ -126,7 +128,7 @@ static int
 airport_detach(struct macio_dev *mdev)
 {
        struct net_device *dev = dev_get_drvdata(&mdev->ofdev.dev);
-       struct orinoco_private *priv = dev->priv;
+       struct orinoco_private *priv = netdev_priv(dev);
        struct airport *card = priv->card;
 
        if (card->ndev_registered)
@@ -139,16 +141,15 @@ airport_detach(struct macio_dev *mdev)
 
        if (card->vaddr)
                iounmap(card->vaddr);
-       card->vaddr = 0;
+       card->vaddr = NULL;
 
        macio_release_resource(mdev, 0);
 
        pmac_call_feature(PMAC_FTR_AIRPORT_ENABLE, macio_get_of_node(mdev), 0, 0);
-       set_current_state(TASK_UNINTERRUPTIBLE);
-       schedule_timeout(HZ);
+       ssleep(1);
 
        macio_set_drvdata(mdev, NULL);
-       free_netdev(dev);
+       free_orinocodev(dev);
 
        return 0;
 }
@@ -171,14 +172,12 @@ static int airport_hard_reset(struct orinoco_private *priv)
        disable_irq(dev->irq);
 
        pmac_call_feature(PMAC_FTR_AIRPORT_ENABLE, macio_get_of_node(card->mdev), 0, 0);
-       set_current_state(TASK_UNINTERRUPTIBLE);
-       schedule_timeout(HZ);
+       ssleep(1);
        pmac_call_feature(PMAC_FTR_AIRPORT_ENABLE, macio_get_of_node(card->mdev), 0, 1);
-       set_current_state(TASK_UNINTERRUPTIBLE);
-       schedule_timeout(HZ);
+       ssleep(1);
 
        enable_irq(dev->irq);
-       schedule_timeout(HZ);
+       ssleep(1);
 #endif
 
        return 0;
@@ -194,25 +193,25 @@ airport_attach(struct macio_dev *mdev, const struct of_match *match)
        hermes_t *hw;
 
        if (macio_resource_count(mdev) < 1 || macio_irq_count(mdev) < 1) {
-               printk(KERN_ERR "airport: wrong interrupt/addresses in OF tree\n");
+               printk(KERN_ERR PFX "Wrong interrupt/addresses in OF tree\n");
                return -ENODEV;
        }
 
        /* Allocate space for private device-specific data */
        dev = alloc_orinocodev(sizeof(*card), airport_hard_reset);
        if (! dev) {
-               printk(KERN_ERR "airport: can't allocate device datas\n");
+               printk(KERN_ERR PFX "Cannot allocate network device\n");
                return -ENODEV;
        }
-       priv = dev->priv;
+       priv = netdev_priv(dev);
        card = priv->card;
 
        hw = &priv->hw;
        card->mdev = mdev;
 
        if (macio_request_resource(mdev, 0, "airport")) {
-               printk(KERN_ERR "airport: can't request IO resource !\n");
-               free_netdev(dev);
+               printk(KERN_ERR PFX "can't request IO resource !\n");
+               free_orinocodev(dev);
                return -EBUSY;
        }
 
@@ -224,37 +223,35 @@ airport_attach(struct macio_dev *mdev, const struct of_match *match)
        /* Setup interrupts & base address */
        dev->irq = macio_irq(mdev, 0);
        phys_addr = macio_resource_start(mdev, 0);  /* Physical address */
-       printk(KERN_DEBUG "Airport at physical address %lx\n", phys_addr);
+       printk(KERN_DEBUG PFX "Physical address %lx\n", phys_addr);
        dev->base_addr = phys_addr;
        card->vaddr = ioremap(phys_addr, AIRPORT_IO_LEN);
        if (!card->vaddr) {
-               printk("airport: ioremap() failed\n");
+               printk(KERN_ERR PFX "ioremap() failed\n");
                goto failed;
        }
 
-       hermes_struct_init(hw, (ulong)card->vaddr,
-                       HERMES_MEM, HERMES_16BIT_REGSPACING);
+       hermes_struct_init(hw, card->vaddr, HERMES_16BIT_REGSPACING);
                
        /* Power up card */
        pmac_call_feature(PMAC_FTR_AIRPORT_ENABLE, macio_get_of_node(mdev), 0, 1);
-       set_current_state(TASK_UNINTERRUPTIBLE);
-       schedule_timeout(HZ);
+       ssleep(1);
 
        /* Reset it before we get the interrupt */
        hermes_init(hw);
 
-       if (request_irq(dev->irq, orinoco_interrupt, 0, "Airport", dev)) {
-               printk(KERN_ERR "airport: Couldn't get IRQ %d\n", dev->irq);
+       if (request_irq(dev->irq, orinoco_interrupt, 0, dev->name, dev)) {
+               printk(KERN_ERR PFX "Couldn't get IRQ %d\n", dev->irq);
                goto failed;
        }
        card->irq_requested = 1;
 
        /* Tell the stack we exist */
        if (register_netdev(dev) != 0) {
-               printk(KERN_ERR "airport: register_netdev() failed\n");
+               printk(KERN_ERR PFX "register_netdev() failed\n");
                goto failed;
        }
-       printk(KERN_DEBUG "airport: card registered for interface %s\n", dev->name);
+       printk(KERN_DEBUG PFX "Card registered for interface %s\n", dev->name);
        card->ndev_registered = 1;
        return 0;
  failed:
@@ -263,7 +260,8 @@ airport_attach(struct macio_dev *mdev, const struct of_match *match)
 }                              /* airport_attach */
 
 
-static char version[] __initdata = "airport.c 0.13e (Benjamin Herrenschmidt <benh@kernel.crashing.org>)";
+static char version[] __initdata = DRIVER_NAME " " DRIVER_VERSION
+       " (Benjamin Herrenschmidt <benh@kernel.crashing.org>)";
 MODULE_AUTHOR("Benjamin Herrenschmidt <benh@kernel.crashing.org>");
 MODULE_DESCRIPTION("Driver for the Apple Airport wireless card.");
 MODULE_LICENSE("Dual MPL/GPL");
@@ -280,7 +278,7 @@ static struct of_match airport_match[] =
 
 static struct macio_driver airport_driver = 
 {
-       .name           = "airport",
+       .name           = DRIVER_NAME,
        .match_table    = airport_match,
        .probe          = airport_attach,
        .remove         = airport_detach,