[PATCH] add netpoll support for gianfar: respin
[safe/jmp/linux-2.6] / drivers / net / wireless / wl3501_cs.c
index 4b054f5..5b98a78 100644 (file)
@@ -28,7 +28,6 @@
  */
 #undef REALLY_SLOW_IO  /* most systems can safely undef this */
 
-#include <linux/config.h>
 #include <linux/delay.h>
 #include <linux/types.h>
 #include <linux/ethtool.h>
@@ -103,8 +102,8 @@ module_param(pc_debug, int, 0);
  * release a socket, in response to card insertion and ejection events.  They
  * are invoked from the wl24 event handler.
  */
-static void wl3501_config(dev_link_t *link);
-static void wl3501_release(dev_link_t *link);
+static int wl3501_config(struct pcmcia_device *link);
+static void wl3501_release(struct pcmcia_device *link);
 
 /*
  * The dev_info variable is the "key" that is used to match up this
@@ -1146,7 +1145,6 @@ static inline void wl3501_ack_interrupt(struct wl3501_card *this)
  * wl3501_interrupt - Hardware interrupt from card.
  * @irq - Interrupt number
  * @dev_id - net_device
- * @regs - registers
  *
  * We must acknowledge the interrupt as soon as possible, and block the
  * interrupt from the same card immediately to prevent re-entry.
@@ -1155,27 +1153,20 @@ static inline void wl3501_ack_interrupt(struct wl3501_card *this)
  * On the other hand, to prevent SUTRO from malfunctioning, we must
  * unlock the SUTRO as soon as possible.
  */
-static irqreturn_t wl3501_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t wl3501_interrupt(int irq, void *dev_id)
 {
-       struct net_device *dev = (struct net_device *)dev_id;
+       struct net_device *dev = dev_id;
        struct wl3501_card *this;
-       int handled = 1;
 
-       if (!dev)
-               goto unknown;
-       this = dev->priv;
+       this = netdev_priv(dev);
        spin_lock(&this->lock);
        wl3501_ack_interrupt(this);
        wl3501_block_interrupt(this);
        wl3501_rx_interrupt(dev);
        wl3501_unblock_interrupt(this);
        spin_unlock(&this->lock);
-out:
-       return IRQ_RETVAL(handled);
-unknown:
-       handled = 0;
-       printk(KERN_ERR "%s: irq %d for unknown device.\n", __FUNCTION__, irq);
-       goto out;
+
+       return IRQ_HANDLED;
 }
 
 static int wl3501_reset_board(struct wl3501_card *this)
@@ -1270,7 +1261,7 @@ static int wl3501_close(struct net_device *dev)
        struct wl3501_card *this = dev->priv;
        int rc = -ENODEV;
        unsigned long flags;
-       dev_link_t *link;
+       struct pcmcia_device *link;
        link = this->p_dev;
 
        spin_lock_irqsave(&this->lock, flags);
@@ -1383,11 +1374,11 @@ static int wl3501_open(struct net_device *dev)
        int rc = -ENODEV;
        struct wl3501_card *this = dev->priv;
        unsigned long flags;
-       dev_link_t *link;
+       struct pcmcia_device *link;
        link = this->p_dev;
 
        spin_lock_irqsave(&this->lock, flags);
-       if (!DEV_OK(link))
+       if (!pcmcia_dev_present(link))
                goto out;
        netif_device_attach(dev);
        link->open++;
@@ -1465,7 +1456,7 @@ static void wl3501_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *i
        strlcpy(info->driver, wl3501_dev_info, sizeof(info->driver));
 }
 
-static struct ethtool_ops ops = {
+static const struct ethtool_ops ops = {
        .get_drvinfo = wl3501_get_drvinfo
 };
 
@@ -1477,22 +1468,19 @@ static struct ethtool_ops ops = {
  * Services. If it has been released, all local data structures are freed.
  * Otherwise, the structures will be freed when the device is released.
  */
-static void wl3501_detach(struct pcmcia_device *p_dev)
+static void wl3501_detach(struct pcmcia_device *link)
 {
-       dev_link_t *link = dev_to_instance(p_dev);
        struct net_device *dev = link->priv;
 
        /* If the device is currently configured and active, we won't actually
         * delete it yet.  Instead, it is marked so that when the release()
         * function is called, that will trigger a proper detach(). */
 
-       if (link->state & DEV_CONFIG) {
-               while (link->open > 0)
-                       wl3501_close(dev);
+       while (link->open > 0)
+               wl3501_close(dev);
 
-               netif_device_detach(dev);
-               wl3501_release(link);
-       }
+       netif_device_detach(dev);
+       wl3501_release(link);
 
        if (link->priv)
                free_netdev(link->priv);
@@ -1806,15 +1794,15 @@ static int wl3501_get_retry(struct net_device *dev,
                                      &retry, sizeof(retry));
        if (rc)
                goto out;
-       if (wrqu->retry.flags & IW_RETRY_MAX) {
-               wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
+       if (wrqu->retry.flags & IW_RETRY_LONG) {
+               wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
                goto set_value;
        }
        rc = wl3501_get_mib_value(this, WL3501_MIB_ATTR_SHORT_RETRY_LIMIT,
                                  &retry, sizeof(retry));
        if (rc)
                goto out;
-       wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_MIN;
+       wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
 set_value:
        wrqu->retry.value = retry;
        wrqu->retry.disabled = 0;
@@ -1921,27 +1909,26 @@ static const struct iw_handler_def wl3501_handler_def = {
  * The dev_link structure is initialized, but we don't actually configure the
  * card at this point -- we wait until we receive a card insertion event.
  */
-static int wl3501_attach(struct pcmcia_device *p_dev)
+static int wl3501_probe(struct pcmcia_device *p_dev)
 {
        struct net_device *dev;
        struct wl3501_card *this;
-       dev_link_t *link = dev_to_instance(p_dev);
 
        /* The io structure describes IO port mapping */
-       link->io.NumPorts1      = 16;
-       link->io.Attributes1    = IO_DATA_PATH_WIDTH_8;
-       link->io.IOAddrLines    = 5;
+       p_dev->io.NumPorts1     = 16;
+       p_dev->io.Attributes1   = IO_DATA_PATH_WIDTH_8;
+       p_dev->io.IOAddrLines   = 5;
 
        /* Interrupt setup */
-       link->irq.Attributes    = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT;
-       link->irq.IRQInfo1      = IRQ_LEVEL_ID;
-       link->irq.Handler = wl3501_interrupt;
+       p_dev->irq.Attributes   = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT;
+       p_dev->irq.IRQInfo1     = IRQ_LEVEL_ID;
+       p_dev->irq.Handler = wl3501_interrupt;
 
        /* General socket configuration */
-       link->conf.Attributes   = CONF_ENABLE_IRQ;
-       link->conf.IntType      = INT_MEMORY_AND_IO;
-       link->conf.ConfigIndex  = 1;
-       link->conf.Present      = PRESENT_OPTION;
+       p_dev->conf.Attributes  = CONF_ENABLE_IRQ;
+       p_dev->conf.IntType     = INT_MEMORY_AND_IO;
+       p_dev->conf.ConfigIndex = 1;
+       p_dev->conf.Present     = PRESENT_OPTION;
 
        dev = alloc_etherdev(sizeof(struct wl3501_card));
        if (!dev)
@@ -1959,12 +1946,9 @@ static int wl3501_attach(struct pcmcia_device *p_dev)
        dev->wireless_handlers  = (struct iw_handler_def *)&wl3501_handler_def;
        SET_ETHTOOL_OPS(dev, &ops);
        netif_stop_queue(dev);
-       link->priv = link->irq.Instance = dev;
+       p_dev->priv = p_dev->irq.Instance = dev;
 
-       link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
-       wl3501_config(p_dev);
-
-       return 0;
+       return wl3501_config(p_dev);
 out_link:
        return -ENOMEM;
 }
@@ -1980,11 +1964,10 @@ do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
  * received, to configure the PCMCIA socket, and to make the ethernet device
  * available to the system.
  */
-static void wl3501_config(dev_link_t *link)
+static int wl3501_config(struct pcmcia_device *link)
 {
        tuple_t tuple;
        cisparse_t parse;
-       client_handle_t handle = link->handle;
        struct net_device *dev = link->priv;
        int i = 0, j, last_fn, last_ret;
        unsigned char bf[64];
@@ -1993,18 +1976,15 @@ static void wl3501_config(dev_link_t *link)
        /* This reads the card's CONFIG tuple to find its config registers. */
        tuple.Attributes        = 0;
        tuple.DesiredTuple      = CISTPL_CONFIG;
-       CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
+       CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
        tuple.TupleData         = bf;
        tuple.TupleDataMax      = sizeof(bf);
        tuple.TupleOffset       = 0;
-       CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
-       CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse));
+       CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
+       CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
        link->conf.ConfigBase   = parse.config.base;
        link->conf.Present      = parse.config.rmask[0];
 
-       /* Configure card */
-       link->state |= DEV_CONFIG;
-
        /* Try allocating IO ports.  This tries a few fixed addresses.  If you
         * want, you can also read the card's config table to pick addresses --
         * see the serial driver for an example. */
@@ -2014,28 +1994,28 @@ static void wl3501_config(dev_link_t *link)
                 * 0x200-0x2ff, and so on, because this seems safer */
                link->io.BasePort1 = j;
                link->io.BasePort2 = link->io.BasePort1 + 0x10;
-               i = pcmcia_request_io(link->handle, &link->io);
+               i = pcmcia_request_io(link, &link->io);
                if (i == CS_SUCCESS)
                        break;
        }
        if (i != CS_SUCCESS) {
-               cs_error(link->handle, RequestIO, i);
+               cs_error(link, RequestIO, i);
                goto failed;
        }
 
        /* Now allocate an interrupt line. Note that this does not actually
         * assign a handler to the interrupt. */
 
-       CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq));
+       CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq));
 
        /* This actually configures the PCMCIA socket -- setting up the I/O
         * windows and the interrupt mapping.  */
 
-       CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link->handle, &link->conf));
+       CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf));
 
        dev->irq = link->irq.AssignedIRQ;
        dev->base_addr = link->io.BasePort1;
-       SET_NETDEV_DEV(dev, &handle_to_dev(handle));
+       SET_NETDEV_DEV(dev, &handle_to_dev(link));
        if (register_netdev(dev)) {
                printk(KERN_NOTICE "wl3501_cs: register_netdev() failed\n");
                goto failed;
@@ -2049,7 +2029,6 @@ static void wl3501_config(dev_link_t *link)
         * arranged in a linked list at link->dev_node.
         */
        link->dev_node = &this->node;
-       link->state &= ~DEV_CONFIG_PENDING;
 
        this->base_addr = dev->base_addr;
 
@@ -2085,13 +2064,13 @@ static void wl3501_config(dev_link_t *link)
        spin_lock_init(&this->lock);
        init_waitqueue_head(&this->wait);
        netif_start_queue(dev);
-       goto out;
+       return 0;
+
 cs_failed:
-       cs_error(link->handle, last_fn, last_ret);
+       cs_error(link, last_fn, last_ret);
 failed:
        wl3501_release(link);
-out:
-       return;
+       return -ENODEV;
 }
 
 /**
@@ -2102,7 +2081,7 @@ out:
  * and release the PCMCIA configuration.  If the device is still open, this
  * will be postponed until it is closed.
  */
-static void wl3501_release(dev_link_t *link)
+static void wl3501_release(struct pcmcia_device *link)
 {
        struct net_device *dev = link->priv;
 
@@ -2110,28 +2089,26 @@ static void wl3501_release(dev_link_t *link)
        if (link->dev_node)
                unregister_netdev(dev);
 
-       pcmcia_disable_device(link->handle);
+       pcmcia_disable_device(link);
 }
 
-static int wl3501_suspend(struct pcmcia_device *p_dev)
+static int wl3501_suspend(struct pcmcia_device *link)
 {
-       dev_link_t *link = dev_to_instance(p_dev);
        struct net_device *dev = link->priv;
 
        wl3501_pwr_mgmt(dev->priv, WL3501_SUSPEND);
-       if ((link->state & DEV_CONFIG) && (link->open))
+       if (link->open)
                netif_device_detach(dev);
 
        return 0;
 }
 
-static int wl3501_resume(struct pcmcia_device *p_dev)
+static int wl3501_resume(struct pcmcia_device *link)
 {
-       dev_link_t *link = dev_to_instance(p_dev);
        struct net_device *dev = link->priv;
 
        wl3501_pwr_mgmt(dev->priv, WL3501_RESUME);
-       if ((link->state & DEV_CONFIG) && (link->open)) {
+       if (link->open) {
                wl3501_reset(dev);
                netif_device_attach(dev);
        }
@@ -2151,7 +2128,7 @@ static struct pcmcia_driver wl3501_driver = {
        .drv            = {
                .name   = "wl3501_cs",
        },
-       .probe          = wl3501_attach,
+       .probe          = wl3501_probe,
        .remove         = wl3501_detach,
        .id_table       = wl3501_ids,
        .suspend        = wl3501_suspend,