pcmcia: convert pcmcia_request_configuration to pcmcia_enable_device
[linux-2.6.git] / drivers / net / wireless / ray_cs.c
index 2940d7d..1457f34 100644 (file)
 #include <linux/ethtool.h>
 #include <linux/ieee80211.h>
 
-#include <pcmcia/cs_types.h>
-#include <pcmcia/cs.h>
 #include <pcmcia/cistpl.h>
 #include <pcmcia/cisreg.h>
 #include <pcmcia/ds.h>
-#include <pcmcia/mem_op.h>
 
 #include <linux/wireless.h>
 #include <net/iw_handler.h>
@@ -98,7 +95,6 @@ static iw_stats *ray_get_wireless_stats(struct net_device *dev);
 static const struct iw_handler_def ray_handler_def;
 
 /***** Prototypes for raylink functions **************************************/
-static int asc_to_int(char a);
 static void authenticate(ray_dev_t *local);
 static int build_auth_frame(ray_dev_t *local, UCHAR *dest, int auth_type);
 static void authenticate_timeout(u_long);
@@ -317,18 +313,12 @@ static int ray_probe(struct pcmcia_device *p_dev)
        local->finder = p_dev;
 
        /* The io structure describes IO port mapping. None used here */
-       p_dev->io.NumPorts1 = 0;
-       p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
-       p_dev->io.IOAddrLines = 5;
-
-       /* Interrupt setup. For PCMCIA, driver takes what's given */
-       p_dev->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
-       p_dev->irq.Handler = &ray_interrupt;
+       p_dev->resource[0]->end = 0;
+       p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8;
 
        /* General socket configuration */
-       p_dev->conf.Attributes = CONF_ENABLE_IRQ;
-       p_dev->conf.IntType = INT_MEMORY_AND_IO;
-       p_dev->conf.ConfigIndex = 1;
+       p_dev->config_flags |= CONF_ENABLE_IRQ;
+       p_dev->config_index = 1;
 
        p_dev->priv = dev;
 
@@ -383,8 +373,7 @@ static void ray_detach(struct pcmcia_device *link)
        del_timer(&local->timer);
 
        if (link->priv) {
-               if (link->dev_node)
-                       unregister_netdev(dev);
+               unregister_netdev(dev);
                free_netdev(dev);
        }
        dev_dbg(&link->dev, "ray_cs ray_detach ending\n");
@@ -400,8 +389,6 @@ static int ray_config(struct pcmcia_device *link)
 {
        int ret = 0;
        int i;
-       win_req_t req;
-       memreq_t mem;
        struct net_device *dev = (struct net_device *)link->priv;
        ray_dev_t *local = netdev_priv(dev);
 
@@ -417,65 +404,58 @@ static int ray_config(struct pcmcia_device *link)
        /* Now allocate an interrupt line.  Note that this does not
           actually assign a handler to the interrupt.
         */
-       ret = pcmcia_request_irq(link, &link->irq);
+       ret = pcmcia_request_irq(link, ray_interrupt);
        if (ret)
                goto failed;
-       dev->irq = link->irq.AssignedIRQ;
+       dev->irq = link->irq;
 
        /* This actually configures the PCMCIA socket -- setting up
           the I/O windows and the interrupt mapping.
         */
-       ret = pcmcia_request_configuration(link, &link->conf);
+       ret = pcmcia_enable_device(link);
        if (ret)
                goto failed;
 
 /*** Set up 32k window for shared memory (transmit and control) ************/
-       req.Attributes =
-           WIN_DATA_WIDTH_8 | WIN_MEMORY_TYPE_CM | WIN_ENABLE | WIN_USE_WAIT;
-       req.Base = 0;
-       req.Size = 0x8000;
-       req.AccessSpeed = ray_mem_speed;
-       ret = pcmcia_request_window(link, &req, &link->win);
+       link->resource[2]->flags |= WIN_DATA_WIDTH_8 | WIN_MEMORY_TYPE_CM | WIN_ENABLE | WIN_USE_WAIT;
+       link->resource[2]->start = 0;
+       link->resource[2]->end = 0x8000;
+       ret = pcmcia_request_window(link, link->resource[2], ray_mem_speed);
        if (ret)
                goto failed;
-       mem.CardOffset = 0x0000;
-       mem.Page = 0;
-       ret = pcmcia_map_mem_page(link, link->win, &mem);
+       ret = pcmcia_map_mem_page(link, link->resource[2], 0);
        if (ret)
                goto failed;
-       local->sram = ioremap(req.Base, req.Size);
+       local->sram = ioremap(link->resource[2]->start,
+                       resource_size(link->resource[2]));
 
 /*** Set up 16k window for shared memory (receive buffer) ***************/
-       req.Attributes =
+       link->resource[3]->flags |=
            WIN_DATA_WIDTH_8 | WIN_MEMORY_TYPE_CM | WIN_ENABLE | WIN_USE_WAIT;
-       req.Base = 0;
-       req.Size = 0x4000;
-       req.AccessSpeed = ray_mem_speed;
-       ret = pcmcia_request_window(link, &req, &local->rmem_handle);
+       link->resource[3]->start = 0;
+       link->resource[3]->end = 0x4000;
+       ret = pcmcia_request_window(link, link->resource[3], ray_mem_speed);
        if (ret)
                goto failed;
-       mem.CardOffset = 0x8000;
-       mem.Page = 0;
-       ret = pcmcia_map_mem_page(link, local->rmem_handle, &mem);
+       ret = pcmcia_map_mem_page(link, link->resource[3], 0x8000);
        if (ret)
                goto failed;
-       local->rmem = ioremap(req.Base, req.Size);
+       local->rmem = ioremap(link->resource[3]->start,
+                       resource_size(link->resource[3]));
 
 /*** Set up window for attribute memory ***********************************/
-       req.Attributes =
+       link->resource[4]->flags |=
            WIN_DATA_WIDTH_8 | WIN_MEMORY_TYPE_AM | WIN_ENABLE | WIN_USE_WAIT;
-       req.Base = 0;
-       req.Size = 0x1000;
-       req.AccessSpeed = ray_mem_speed;
-       ret = pcmcia_request_window(link, &req, &local->amem_handle);
+       link->resource[4]->start = 0;
+       link->resource[4]->end = 0x1000;
+       ret = pcmcia_request_window(link, link->resource[4], ray_mem_speed);
        if (ret)
                goto failed;
-       mem.CardOffset = 0x0000;
-       mem.Page = 0;
-       ret = pcmcia_map_mem_page(link, local->amem_handle, &mem);
+       ret = pcmcia_map_mem_page(link, link->resource[4], 0);
        if (ret)
                goto failed;
-       local->amem = ioremap(req.Base, req.Size);
+       local->amem = ioremap(link->resource[4]->start,
+                       resource_size(link->resource[4]));
 
        dev_dbg(&link->dev, "ray_config sram=%p\n", local->sram);
        dev_dbg(&link->dev, "ray_config rmem=%p\n", local->rmem);
@@ -493,9 +473,6 @@ static int ray_config(struct pcmcia_device *link)
                return i;
        }
 
-       strcpy(local->node.dev_name, dev->name);
-       link->dev_node = &local->node;
-
        printk(KERN_INFO "%s: RayLink, irq %d, hw_addr %pM\n",
               dev->name, dev->irq, dev->dev_addr);
 
@@ -555,7 +532,7 @@ static int ray_init(struct net_device *dev)
        local->fw_ver = local->startup_res.firmware_version[0];
        local->fw_bld = local->startup_res.firmware_version[1];
        local->fw_var = local->startup_res.firmware_version[2];
-       dev_dbg(&link->dev, "ray_init firmware version %d.%d \n", local->fw_ver,
+       dev_dbg(&link->dev, "ray_init firmware version %d.%d\n", local->fw_ver,
              local->fw_bld);
 
        local->tib_length = 0x20;
@@ -735,8 +712,6 @@ static void verify_dl_startup(u_long data)
                start_net((u_long) local);
        else
                join_net((u_long) local);
-
-       return;
 } /* end verify_dl_startup */
 
 /*===========================================================================*/
@@ -764,7 +739,6 @@ static void start_net(u_long data)
                return;
        }
        local->card_status = CARD_DOING_ACQ;
-       return;
 } /* end start_net */
 
 /*===========================================================================*/
@@ -795,7 +769,6 @@ static void join_net(u_long data)
                return;
        }
        local->card_status = CARD_DOING_ACQ;
-       return;
 }
 
 /*============================================================================
@@ -807,7 +780,6 @@ static void ray_release(struct pcmcia_device *link)
 {
        struct net_device *dev = link->priv;
        ray_dev_t *local = netdev_priv(dev);
-       int i;
 
        dev_dbg(&link->dev, "ray_release\n");
 
@@ -816,13 +788,6 @@ static void ray_release(struct pcmcia_device *link)
        iounmap(local->sram);
        iounmap(local->rmem);
        iounmap(local->amem);
-       /* Do bother checking to see if these succeed or not */
-       i = pcmcia_release_window(link, local->amem_handle);
-       if (i != 0)
-               dev_dbg(&link->dev, "ReleaseWindow(local->amem) ret = %x\n", i);
-       i = pcmcia_release_window(link, local->rmem_handle);
-       if (i != 0)
-               dev_dbg(&link->dev, "ReleaseWindow(local->rmem) ret = %x\n", i);
        pcmcia_disable_device(link);
 
        dev_dbg(&link->dev, "ray_release ending\n");
@@ -941,7 +906,6 @@ static netdev_tx_t ray_dev_start_xmit(struct sk_buff *skb,
        case XMIT_MSG_BAD:
        case XMIT_OK:
        default:
-               dev->trans_start = jiffies;
                dev_kfree_skb(skb);
        }
 
@@ -1627,7 +1591,6 @@ static int ray_dev_close(struct net_device *dev)
 static void ray_reset(struct net_device *dev)
 {
        pr_debug("ray_reset entered\n");
-       return;
 }
 
 /*===========================================================================*/
@@ -1732,24 +1695,6 @@ static void authenticate_timeout(u_long data)
 }
 
 /*===========================================================================*/
-static int asc_to_int(char a)
-{
-       if (a < '0')
-               return -1;
-       if (a <= '9')
-               return (a - '0');
-       if (a < 'A')
-               return -1;
-       if (a <= 'F')
-               return (10 + a - 'A');
-       if (a < 'a')
-               return -1;
-       if (a <= 'f')
-               return (10 + a - 'a');
-       return -1;
-}
-
-/*===========================================================================*/
 static int parse_addr(char *in_str, UCHAR *out)
 {
        int len;
@@ -1769,14 +1714,14 @@ static int parse_addr(char *in_str, UCHAR *out)
        i = 5;
 
        while (j > 0) {
-               if ((k = asc_to_int(in_str[j--])) != -1)
+               if ((k = hex_to_bin(in_str[j--])) != -1)
                        out[i] = k;
                else
                        return 0;
 
                if (j == 0)
                        break;
-               if ((k = asc_to_int(in_str[j--])) != -1)
+               if ((k = hex_to_bin(in_str[j--])) != -1)
                        out[i] += k << 4;
                else
                        return 0;
@@ -2233,7 +2178,7 @@ static void rx_data(struct net_device *dev, struct rcs __iomem *prcs,
                            (dev->mtu + RX_MAC_HEADER_LENGTH + ETH_HLEN +
                             FCS_LEN)) {
                                pr_debug(
-                                     "ray_cs invalid packet length %d received \n",
+                                     "ray_cs invalid packet length %d received\n",
                                      rx_len);
                                return;
                        }
@@ -2244,7 +2189,7 @@ static void rx_data(struct net_device *dev, struct rcs __iomem *prcs,
                            (dev->mtu + RX_MAC_HEADER_LENGTH + ETH_HLEN +
                             FCS_LEN)) {
                                pr_debug(
-                                     "ray_cs invalid packet length %d received \n",
+                                     "ray_cs invalid packet length %d received\n",
                                      rx_len);
                                return;
                        }
@@ -2752,11 +2697,11 @@ static int ray_cs_proc_show(struct seq_file *m, void *v)
                        seq_printf(m, "Hop dwell            = %d Kus\n",
                                   pfh->dwell_time[0] +
                                   256 * pfh->dwell_time[1]);
-                       seq_printf(m, "Hop set              = %d \n",
+                       seq_printf(m, "Hop set              = %d\n",
                                   pfh->hop_set);
-                       seq_printf(m, "Hop pattern          = %d \n",
+                       seq_printf(m, "Hop pattern          = %d\n",
                                   pfh->hop_pattern);
-                       seq_printf(m, "Hop index            = %d \n",
+                       seq_printf(m, "Hop index            = %d\n",
                                   pfh->hop_index);
                        p += p[1] + 2;
                } else {