ray_cs: convert to proc_fops
[safe/jmp/linux-2.6] / drivers / net / wireless / ray_cs.c
index b10b038..0366f5a 100644 (file)
@@ -104,7 +104,8 @@ static int ray_dev_init(struct net_device *dev);
 static const struct ethtool_ops netdev_ethtool_ops;
 
 static int ray_open(struct net_device *dev);
-static int ray_dev_start_xmit(struct sk_buff *skb, struct net_device *dev);
+static netdev_tx_t ray_dev_start_xmit(struct sk_buff *skb,
+                                           struct net_device *dev);
 static void set_multicast_list(struct net_device *dev);
 static void ray_update_multi_list(struct net_device *dev, int all);
 static int translate_frame(ray_dev_t *local, struct tx_msg __iomem *ptx,
@@ -915,16 +916,19 @@ static int ray_dev_config(struct net_device *dev, struct ifmap *map)
 }
 
 /*===========================================================================*/
-static int ray_dev_start_xmit(struct sk_buff *skb, struct net_device *dev)
+static netdev_tx_t ray_dev_start_xmit(struct sk_buff *skb,
+                                           struct net_device *dev)
 {
        ray_dev_t *local = netdev_priv(dev);
        struct pcmcia_device *link = local->finder;
        short length = skb->len;
 
-       if (!(pcmcia_dev_present(link))) {
+       if (!pcmcia_dev_present(link)) {
                DEBUG(2, "ray_dev_start_xmit - device not present\n");
-               return NETDEV_TX_LOCKED;
+               dev_kfree_skb(skb);
+               return NETDEV_TX_OK;
        }
+
        DEBUG(3, "ray_dev_start_xmit(skb=%p, dev=%p)\n", skb, dev);
        if (local->authentication_state == NEED_TO_AUTH) {
                DEBUG(0, "ray_cs Sending authentication request.\n");
@@ -937,7 +941,7 @@ static int ray_dev_start_xmit(struct sk_buff *skb, struct net_device *dev)
 
        if (length < ETH_ZLEN) {
                if (skb_padto(skb, ETH_ZLEN))
-                       return 0;
+                       return NETDEV_TX_OK;
                length = ETH_ZLEN;
        }
        switch (ray_hw_xmit(skb->data, length, dev, DATA_TYPE)) {
@@ -951,9 +955,9 @@ static int ray_dev_start_xmit(struct sk_buff *skb, struct net_device *dev)
        default:
                dev->trans_start = jiffies;
                dev_kfree_skb(skb);
-               return 0;
        }
-       return 0;
+
+       return NETDEV_TX_OK;
 } /* ray_dev_start_xmit */
 
 /*===========================================================================*/
@@ -1511,9 +1515,6 @@ static iw_stats *ray_get_wireless_stats(struct net_device *dev)
        struct pcmcia_device *link = local->finder;
        struct status __iomem *p = local->sram + STATUS_BASE;
 
-       if (local == (ray_dev_t *) NULL)
-               return (iw_stats *) NULL;
-
        local->wstats.status = local->card_status;
 #ifdef WIRELESS_SPY
        if ((local->spy_data.spy_number > 0)
@@ -2073,7 +2074,7 @@ static irqreturn_t ray_interrupt(int irq, void *dev_id)
                                del_timer(&local->timer);
                                local->timer.expires = jiffies + HZ * 5;
                                local->timer.data = (long)local;
-                               if (status == CCS_START_NETWORK) {
+                               if (cmd == CCS_START_NETWORK) {
                                        DEBUG(0,
                                              "ray_cs interrupt network \"%s\" start failed\n",
                                              local->sparm.b4.a_current_ess_id);
@@ -2427,11 +2428,10 @@ static void untranslate(ray_dev_t *local, struct sk_buff *skb, int len)
 
 #ifdef PCMCIA_DEBUG
        if (pc_debug > 3) {
-               int i;
-               printk(KERN_DEBUG "skb->data before untranslate");
-               for (i = 0; i < 64; i++)
-                       printk("%02x ", skb->data[i]);
-               printk("\n" KERN_DEBUG
+               print_hex_dump(KERN_DEBUG, "skb->data before untranslate: ",
+                              DUMP_PREFIX_NONE, 16, 1,
+                              skb->data, 64, true);
+               printk(KERN_DEBUG
                       "type = %08x, xsap = %02x%02x%02x, org = %02x02x02x\n",
                       ntohs(type), psnap->dsap, psnap->ssap, psnap->ctrl,
                       psnap->org[0], psnap->org[1], psnap->org[2]);
@@ -2865,21 +2865,11 @@ static int build_auth_frame(ray_dev_t *local, UCHAR *dest, int auth_type)
 
 /*===========================================================================*/
 #ifdef CONFIG_PROC_FS
-static void raycs_write(const char *name, write_proc_t *w, void *data)
-{
-       struct proc_dir_entry *entry =
-           create_proc_entry(name, S_IFREG | S_IWUSR, NULL);
-       if (entry) {
-               entry->write_proc = w;
-               entry->data = data;
-       }
-}
-
-static int write_essid(struct file *file, const char __user *buffer,
-                      unsigned long count, void *data)
+static ssize_t ray_cs_essid_proc_write(struct file *file,
+               const char __user *buffer, size_t count, loff_t *pos)
 {
        static char proc_essid[33];
-       int len = count;
+       unsigned int len = count;
 
        if (len > 32)
                len = 32;
@@ -2890,8 +2880,13 @@ static int write_essid(struct file *file, const char __user *buffer,
        return count;
 }
 
-static int write_int(struct file *file, const char __user *buffer,
-                    unsigned long count, void *data)
+static const struct file_operations ray_cs_essid_proc_fops = {
+       .owner          = THIS_MODULE,
+       .write          = ray_cs_essid_proc_write,
+};
+
+static ssize_t int_proc_write(struct file *file, const char __user *buffer,
+                             size_t count, loff_t *pos)
 {
        static char proc_number[10];
        char *p;
@@ -2914,9 +2909,14 @@ static int write_int(struct file *file, const char __user *buffer,
                nr = nr * 10 + c;
                p++;
        } while (--len);
-       *(int *)data = nr;
+       *(int *)PDE(file->f_path.dentry->d_inode)->data = nr;
        return count;
 }
+
+static const struct file_operations int_proc_fops = {
+       .owner          = THIS_MODULE,
+       .write          = int_proc_write,
+};
 #endif
 
 static struct pcmcia_device_id ray_ids[] = {
@@ -2951,9 +2951,9 @@ static int __init init_ray_cs(void)
        proc_mkdir("driver/ray_cs", NULL);
 
        proc_create("driver/ray_cs/ray_cs", 0, NULL, &ray_cs_proc_fops);
-       raycs_write("driver/ray_cs/essid", write_essid, NULL);
-       raycs_write("driver/ray_cs/net_type", write_int, &net_type);
-       raycs_write("driver/ray_cs/translate", write_int, &translate);
+       proc_create("driver/ray_cs/essid", S_IWUSR, NULL, &ray_cs_essid_proc_fops);
+       proc_create_data("driver/ray_cs/net_type", S_IWUSR, NULL, &int_proc_fops, &net_type);
+       proc_create_data("driver/ray_cs/translate", S_IWUSR, NULL, &int_proc_fops, &translate);
 #endif
        if (translate != 0)
                translate = 1;