iwlwifi: add missing rcu_read_lock
[safe/jmp/linux-2.6] / drivers / net / wireless / atmel_cs.c
index 12efd44..c2746fc 100644 (file)
 
 #include "atmel.h"
 
-/*
-   All the PCMCIA modules use PCMCIA_DEBUG to control debugging.  If
-   you do not define PCMCIA_DEBUG at all, all the debug code will be
-   left out.  If you compile with PCMCIA_DEBUG=0, the debug code will
-   be present but disabled -- but it can then be enabled for specific
-   modules at load time with a 'pc_debug=#' option to insmod.
-*/
-
-#ifdef PCMCIA_DEBUG
-static int pc_debug = PCMCIA_DEBUG;
-module_param(pc_debug, int, 0);
-static char *version = "$Revision: 1.2 $";
-#define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args);
-#else
-#define DEBUG(n, args...)
-#endif
 
 /*====================================================================*/
 
@@ -101,41 +85,7 @@ static void atmel_release(struct pcmcia_device *link);
 
 static void atmel_detach(struct pcmcia_device *p_dev);
 
-/*
-   You'll also need to prototype all the functions that will actually
-   be used to talk to your device.  See 'pcmem_cs' for a good example
-   of a fully self-sufficient driver; the other drivers rely more or
-   less on other parts of the kernel.
-*/
-
-/*
-   A linked list of "instances" of the  atmelnet device.  Each actual
-   PCMCIA card corresponds to one device instance, and is described
-   by one struct pcmcia_device structure (defined in ds.h).
-
-   You may not want to use a linked list for this -- for example, the
-   memory card driver uses an array of struct pcmcia_device pointers, where minor
-   device numbers are used to derive the corresponding array index.
-*/
-
-/*
-   A driver needs to provide a dev_node_t structure for each device
-   on a card.  In some cases, there is only one device per card (for
-   example, ethernet cards, modems).  In other cases, there may be
-   many actual or logical devices (SCSI adapters, memory cards with
-   multiple partitions).  The dev_node_t structures need to be kept
-   in a linked list starting at the 'dev' field of a struct pcmcia_device
-   structure.  We allocate them in the card's private data structure,
-   because they generally shouldn't be allocated dynamically.
-
-   In this case, we also provide a flag to indicate if a device is
-   "stopped" due to a power management event, or card ejection.  The
-   device IO routines can use a flag like this to throttle IO to a
-   card that is not ready to accept it.
-*/
-
 typedef struct local_info_t {
-       dev_node_t      node;
        struct net_device *eth_dev;
 } local_info_t;
 
@@ -155,12 +105,7 @@ static int atmel_probe(struct pcmcia_device *p_dev)
 {
        local_info_t *local;
 
-       DEBUG(0, "atmel_attach()\n");
-
-       /* Interrupt setup */
-       p_dev->irq.Attributes = IRQ_TYPE_EXCLUSIVE;
-       p_dev->irq.IRQInfo1 = IRQ_LEVEL_ID;
-       p_dev->irq.Handler = NULL;
+       dev_dbg(&p_dev->dev, "atmel_attach()\n");
 
        /*
          General socket configuration defaults can go here.  In this
@@ -194,7 +139,7 @@ static int atmel_probe(struct pcmcia_device *p_dev)
 
 static void atmel_detach(struct pcmcia_device *link)
 {
-       DEBUG(0, "atmel_detach(0x%p)\n", link);
+       dev_dbg(&link->dev, "atmel_detach\n");
 
        atmel_release(link);
 
@@ -209,9 +154,6 @@ static void atmel_detach(struct pcmcia_device *link)
 
   ======================================================================*/
 
-#define CS_CHECK(fn, ret) \
-do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
-
 /* Call-back function to interrogate PCMCIA-specific information
    about the current existance of the card */
 static int card_present(void *arg)
@@ -226,14 +168,13 @@ static int card_present(void *arg)
 
 static int atmel_config_check(struct pcmcia_device *p_dev,
                              cistpl_cftable_entry_t *cfg,
+                             cistpl_cftable_entry_t *dflt,
+                             unsigned int vcc,
                              void *priv_data)
 {
-       cistpl_cftable_entry_t *dflt = priv_data;
-
-       if (cfg->flags & CISTPL_CFTABLE_DEFAULT)
-               *dflt = *cfg;
        if (cfg->index == 0)
                return -ENODEV;
+
        /* Does this card need audio output? */
        if (cfg->flags & CISTPL_CFTABLE_AUDIO) {
                p_dev->conf.Attributes |= CONF_ENABLE_SPKR;
@@ -247,9 +188,7 @@ static int atmel_config_check(struct pcmcia_device *p_dev,
        else if (dflt->vpp1.present & (1<<CISTPL_POWER_VNOM))
                p_dev->conf.Vpp = dflt->vpp1.param[CISTPL_POWER_VNOM]/10000;
 
-       /* Do we need to allocate an interrupt? */
-       if (cfg->irq.IRQInfo1 || dflt->irq.IRQInfo1)
-               p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
+       p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
 
        /* IO window settings */
        p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0;
@@ -276,14 +215,13 @@ static int atmel_config_check(struct pcmcia_device *p_dev,
 static int atmel_config(struct pcmcia_device *link)
 {
        local_info_t *dev;
-       int last_fn, last_ret;
+       int ret;
        struct pcmcia_device_id *did;
-       cistpl_cftable_entry_t dflt = { 0 };
 
        dev = link->priv;
-       did = handle_to_dev(link).driver_data;
+       did = dev_get_drvdata(&link->dev);
 
-       DEBUG(0, "atmel_config(0x%p)\n", link);
+       dev_dbg(&link->dev, "atmel_config\n");
 
        /*
          In this loop, we scan the CIS for configuration table entries,
@@ -297,53 +235,36 @@ static int atmel_config(struct pcmcia_device *link)
          these things without consulting the CIS, and most client drivers
          will only use the CIS to fill in implementation-defined details.
        */
-       if (pcmcia_loop_config(link, atmel_config_check, &dflt))
+       if (pcmcia_loop_config(link, atmel_config_check, NULL))
                goto failed;
 
-       /*
-         Allocate an interrupt line.  Note that this does not assign a
-         handler to the interrupt, unless the 'Handler' member of the
-         irq structure is initialized.
-       */
-       if (link->conf.Attributes & CONF_ENABLE_IRQ)
-               CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq));
+       if (!link->irq) {
+               dev_err(&link->dev, "atmel: cannot assign IRQ: check that CONFIG_ISA is set in kernel config.");
+               goto failed;
+       }
 
        /*
          This actually configures the PCMCIA socket -- setting up
          the I/O windows and the interrupt mapping, and putting the
          card and host interface into "Memory and IO" mode.
        */
-       CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf));
-
-       if (link->irq.AssignedIRQ == 0) {
-               printk(KERN_ALERT
-                      "atmel: cannot assign IRQ: check that CONFIG_ISA is set in kernel config.");
-               goto cs_failed;
-       }
+       ret = pcmcia_request_configuration(link, &link->conf);
+       if (ret)
+               goto failed;
 
        ((local_info_t*)link->priv)->eth_dev =
-               init_atmel_card(link->irq.AssignedIRQ,
+               init_atmel_card(link->irq,
                                link->io.BasePort1,
                                did ? did->driver_info : ATMEL_FW_TYPE_NONE,
-                               &handle_to_dev(link),
+                               &link->dev,
                                card_present,
                                link);
        if (!((local_info_t*)link->priv)->eth_dev)
-                       goto cs_failed;
+                       goto failed;
 
 
-       /*
-         At this point, the dev_node_t structure(s) need to be
-         initialized and arranged in a linked list at link->dev_node.
-       */
-       strcpy(dev->node.dev_name, ((local_info_t*)link->priv)->eth_dev->name );
-       dev->node.major = dev->node.minor = 0;
-       link->dev_node = &dev->node;
-
        return 0;
 
- cs_failed:
-       cs_error(link, last_fn, last_ret);
  failed:
        atmel_release(link);
        return -ENODEV;
@@ -361,7 +282,7 @@ static void atmel_release(struct pcmcia_device *link)
 {
        struct net_device *dev = ((local_info_t*)link->priv)->eth_dev;
 
-       DEBUG(0, "atmel_release(0x%p)\n", link);
+       dev_dbg(&link->dev, "atmel_release\n");
 
        if (dev)
                stop_atmel_card(dev);