]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/net/wireless/spectrum_cs.c
Merge branch 'master' of /home/trondmy/kernel/linux-2.6/
[linux-2.6-omap-h63xx.git] / drivers / net / wireless / spectrum_cs.c
index a75ea7e593acea7a6f6ab0f0ea2dbc67e053e9b9..7f9aa139c3475fb11e526433fd85566ada350c48 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Driver for 802.11b cards using RAM-loadable Symbol firmware, such as
- * Symbol Wireless Networker LA4100, CompactFlash cards by Socket
+ * Symbol Wireless Networker LA4137, CompactFlash cards by Socket
  * Communications and Intel PRO/Wireless 2011B.
  *
  * The driver implements Symbol firmware download.  The rest is handled
@@ -71,7 +71,7 @@ struct orinoco_pccard {
 /* Function prototypes                                             */
 /********************************************************************/
 
-static void spectrum_cs_config(struct pcmcia_device *link);
+static int spectrum_cs_config(struct pcmcia_device *link);
 static void spectrum_cs_release(struct pcmcia_device *link);
 
 /********************************************************************/
@@ -120,8 +120,8 @@ static void spectrum_cs_release(struct pcmcia_device *link);
  * Each block has the following structure.
  */
 struct dblock {
-       __le32 _addr;           /* adapter address where to write the block */
-       __le16 _len;            /* length of the data only, in bytes */
+       __le32 addr;            /* adapter address where to write the block */
+       __le16 len;             /* length of the data only, in bytes */
        char data[0];           /* data to be written */
 } __attribute__ ((packed));
 
@@ -131,9 +131,9 @@ struct dblock {
  * items with matching ID should be written.
  */
 struct pdr {
-       __le32 _id;             /* record ID */
-       __le32 _addr;           /* adapter address where to write the data */
-       __le32 _len;            /* expected length of the data, in bytes */
+       __le32 id;              /* record ID */
+       __le32 addr;            /* adapter address where to write the data */
+       __le32 len;             /* expected length of the data, in bytes */
        char next[0];           /* next PDR starts here */
 } __attribute__ ((packed));
 
@@ -144,8 +144,8 @@ struct pdr {
  * be plugged into the secondary firmware.
  */
 struct pdi {
-       __le16 _len;            /* length of ID and data, in words */
-       __le16 _id;             /* record ID */
+       __le16 len;             /* length of ID and data, in words */
+       __le16 id;              /* record ID */
        char data[0];           /* plug data */
 } __attribute__ ((packed));
 
@@ -154,44 +154,44 @@ struct pdi {
 static inline u32
 dblock_addr(const struct dblock *blk)
 {
-       return le32_to_cpu(blk->_addr);
+       return le32_to_cpu(blk->addr);
 }
 
 static inline u32
 dblock_len(const struct dblock *blk)
 {
-       return le16_to_cpu(blk->_len);
+       return le16_to_cpu(blk->len);
 }
 
 static inline u32
 pdr_id(const struct pdr *pdr)
 {
-       return le32_to_cpu(pdr->_id);
+       return le32_to_cpu(pdr->id);
 }
 
 static inline u32
 pdr_addr(const struct pdr *pdr)
 {
-       return le32_to_cpu(pdr->_addr);
+       return le32_to_cpu(pdr->addr);
 }
 
 static inline u32
 pdr_len(const struct pdr *pdr)
 {
-       return le32_to_cpu(pdr->_len);
+       return le32_to_cpu(pdr->len);
 }
 
 static inline u32
 pdi_id(const struct pdi *pdi)
 {
-       return le16_to_cpu(pdi->_id);
+       return le16_to_cpu(pdi->id);
 }
 
 /* Return length of the data only, in bytes */
 static inline u32
 pdi_len(const struct pdi *pdi)
 {
-       return 2 * (le16_to_cpu(pdi->_len) - 1);
+       return 2 * (le16_to_cpu(pdi->len) - 1);
 }
 
 
@@ -245,7 +245,7 @@ spectrum_reset(struct pcmcia_device *link, int idle)
        u_int save_cor;
 
        /* Doing it if hardware is gone is guaranteed crash */
-       if (!(link->state & DEV_CONFIG))
+       if (pcmcia_dev_present(link))
                return -ENODEV;
 
        /* Save original COR value */
@@ -343,8 +343,7 @@ spectrum_plug_pdi(hermes_t *hw, struct pdr *first_pdr, struct pdi *pdi)
 
        /* do the actual plugging */
        spectrum_aux_setaddr(hw, pdr_addr(pdr));
-       hermes_write_words(hw, HERMES_AUXDATA, pdi->data,
-                          pdi_len(pdi) / 2);
+       hermes_write_bytes(hw, HERMES_AUXDATA, pdi->data, pdi_len(pdi));
 
        return 0;
 }
@@ -424,8 +423,8 @@ spectrum_load_blocks(hermes_t *hw, const struct dblock *first_block)
 
        while (dblock_addr(blk) != BLOCK_END) {
                spectrum_aux_setaddr(hw, blkaddr);
-               hermes_write_words(hw, HERMES_AUXDATA, blk->data,
-                                  blklen / 2);
+               hermes_write_bytes(hw, HERMES_AUXDATA, blk->data,
+                                  blklen);
 
                blk = (struct dblock *) &blk->data[blklen];
                blkaddr = dblock_addr(blk);
@@ -583,7 +582,7 @@ spectrum_cs_hard_reset(struct orinoco_private *priv)
  * configure the card at this point -- we wait until we receive a card
  * insertion event.  */
 static int
-spectrum_cs_attach(struct pcmcia_device *link)
+spectrum_cs_probe(struct pcmcia_device *link)
 {
        struct net_device *dev;
        struct orinoco_private *priv;
@@ -613,10 +612,7 @@ spectrum_cs_attach(struct pcmcia_device *link)
        link->conf.Attributes = 0;
        link->conf.IntType = INT_MEMORY_AND_IO;
 
-       link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
-       spectrum_cs_config(link);
-
-       return 0;
+       return spectrum_cs_config(link);
 }                              /* spectrum_cs_attach */
 
 /*
@@ -629,15 +625,11 @@ static void spectrum_cs_detach(struct pcmcia_device *link)
 {
        struct net_device *dev = link->priv;
 
-       if (link->state & DEV_CONFIG)
-               spectrum_cs_release(link);
-
-       DEBUG(0, PFX "detach: link=%p link->dev_node=%p\n", link, link->dev_node);
-       if (link->dev_node) {
-               DEBUG(0, PFX "About to unregister net device %p\n",
-                     dev);
+       if (link->dev_node)
                unregister_netdev(dev);
-       }
+
+       spectrum_cs_release(link);
+
        free_orinocodev(dev);
 }                              /* spectrum_cs_detach */
 
@@ -647,7 +639,7 @@ static void spectrum_cs_detach(struct pcmcia_device *link)
  * device available to the system.
  */
 
-static void
+static int
 spectrum_cs_config(struct pcmcia_device *link)
 {
        struct net_device *dev = link->priv;
@@ -657,13 +649,10 @@ spectrum_cs_config(struct pcmcia_device *link)
        int last_fn, last_ret;
        u_char buf[64];
        config_info_t conf;
-       cisinfo_t info;
        tuple_t tuple;
        cisparse_t parse;
        void __iomem *mem;
 
-       CS_CHECK(ValidateCIS, pcmcia_validate_cis(link, &info));
-
        /*
         * This reads the card's CONFIG tuple to find its
         * configuration registers.
@@ -679,9 +668,6 @@ spectrum_cs_config(struct pcmcia_device *link)
        link->conf.ConfigBase = parse.config.base;
        link->conf.Present = parse.config.rmask[0];
 
-       /* Configure card */
-       link->state |= DEV_CONFIG;
-
        /* Look up the current Vcc */
        CS_CHECK(GetConfigurationInfo,
                 pcmcia_get_configuration_info(link, &conf));
@@ -716,12 +702,6 @@ spectrum_cs_config(struct pcmcia_device *link)
                        goto next_entry;
                link->conf.ConfigIndex = cfg->index;
 
-               /* Does this card need audio output? */
-               if (cfg->flags & CISTPL_CFTABLE_AUDIO) {
-                       link->conf.Attributes |= CONF_ENABLE_SPKR;
-                       link->conf.Status = CCSR_AUDIO_ENA;
-               }
-
                /* Use power settings for Vcc and Vpp if present */
                /* Note that the CIS values need to be rescaled */
                if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) {
@@ -840,30 +820,21 @@ spectrum_cs_config(struct pcmcia_device *link)
        link->dev_node = &card->node; /* link->dev_node being non-NULL is also
                                     used to indicate that the
                                     net_device has been registered */
-       link->state &= ~DEV_CONFIG_PENDING;
 
        /* Finally, report what we've done */
-       printk(KERN_DEBUG "%s: index 0x%02x: ",
-              dev->name, link->conf.ConfigIndex);
-       if (link->conf.Vpp)
-               printk(", Vpp %d.%d", link->conf.Vpp / 10,
-                      link->conf.Vpp % 10);
-       printk(", irq %d", link->irq.AssignedIRQ);
-       if (link->io.NumPorts1)
-               printk(", io 0x%04x-0x%04x", link->io.BasePort1,
-                      link->io.BasePort1 + link->io.NumPorts1 - 1);
-       if (link->io.NumPorts2)
-               printk(" & 0x%04x-0x%04x", link->io.BasePort2,
-                      link->io.BasePort2 + link->io.NumPorts2 - 1);
-       printk("\n");
-
-       return;
+       printk(KERN_DEBUG "%s: " DRIVER_NAME " at %s, irq %d, io "
+              "0x%04x-0x%04x\n", dev->name, dev->class_dev.dev->bus_id,
+              link->irq.AssignedIRQ, link->io.BasePort1,
+              link->io.BasePort1 + link->io.NumPorts1 - 1);
+
+       return 0;
 
  cs_failed:
        cs_error(link, last_fn, last_ret);
 
  failed:
        spectrum_cs_release(link);
+       return -ENODEV;
 }                              /* spectrum_cs_config */
 
 /*
@@ -895,25 +866,22 @@ spectrum_cs_suspend(struct pcmcia_device *link)
 {
        struct net_device *dev = link->priv;
        struct orinoco_private *priv = netdev_priv(dev);
-       unsigned long flags;
        int err = 0;
 
        /* Mark the device as stopped, to block IO until later */
-       if (link->state & DEV_CONFIG) {
-               spin_lock_irqsave(&priv->lock, flags);
+       spin_lock(&priv->lock);
 
-               err = __orinoco_down(dev);
-               if (err)
-                       printk(KERN_WARNING "%s: Error %d downing interface\n",
-                              dev->name, err);
+       err = __orinoco_down(dev);
+       if (err)
+               printk(KERN_WARNING "%s: Error %d downing interface\n",
+                      dev->name, err);
 
-               netif_device_detach(dev);
-               priv->hw_unavailable++;
+       netif_device_detach(dev);
+       priv->hw_unavailable++;
 
-               spin_unlock_irqrestore(&priv->lock, flags);
-       }
+       spin_unlock(&priv->lock);
 
-       return 0;
+       return err;
 }
 
 static int
@@ -922,11 +890,10 @@ spectrum_cs_resume(struct pcmcia_device *link)
        struct net_device *dev = link->priv;
        struct orinoco_private *priv = netdev_priv(dev);
 
-       if (link->state & DEV_CONFIG) {
-               netif_device_attach(dev);
-               priv->hw_unavailable--;
-               schedule_work(&priv->reset_work);
-       }
+       netif_device_attach(dev);
+       priv->hw_unavailable--;
+       schedule_work(&priv->reset_work);
+
        return 0;
 }
 
@@ -942,7 +909,7 @@ static char version[] __initdata = DRIVER_NAME " " DRIVER_VERSION
        " David Gibson <hermes@gibson.dropbear.id.au>, et al)";
 
 static struct pcmcia_device_id spectrum_cs_ids[] = {
-       PCMCIA_DEVICE_MANF_CARD(0x026c, 0x0001), /* Symbol Spectrum24 LA4100 */
+       PCMCIA_DEVICE_MANF_CARD(0x026c, 0x0001), /* Symbol Spectrum24 LA4137 */
        PCMCIA_DEVICE_MANF_CARD(0x0104, 0x0001), /* Socket Communications CF */
        PCMCIA_DEVICE_PROD_ID12("Intel", "PRO/Wireless LAN PC Card", 0x816cc815, 0x6fbf459a), /* 2011B, not 2011 */
        PCMCIA_DEVICE_NULL,
@@ -954,7 +921,7 @@ static struct pcmcia_driver orinoco_driver = {
        .drv            = {
                .name   = DRIVER_NAME,
        },
-       .probe          = spectrum_cs_attach,
+       .probe          = spectrum_cs_probe,
        .remove         = spectrum_cs_detach,
        .suspend        = spectrum_cs_suspend,
        .resume         = spectrum_cs_resume,