pcmcia: pccard_read_tuple and TUPLE_RETURN_COMMON cleanup
[safe/jmp/linux-2.6] / drivers / pcmcia / pcmcia_ioctl.c
index c400872..30cf71d 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/proc_fs.h>
 #include <linux/poll.h>
 #include <linux/pci.h>
+#include <linux/seq_file.h>
 #include <linux/smp_lock.h>
 #include <linux/workqueue.h>
 
@@ -105,37 +106,40 @@ static struct pcmcia_driver *get_pcmcia_driver(dev_info_t *dev_info)
 #ifdef CONFIG_PROC_FS
 static struct proc_dir_entry *proc_pccard = NULL;
 
-static int proc_read_drivers_callback(struct device_driver *driver, void *d)
+static int proc_read_drivers_callback(struct device_driver *driver, void *_m)
 {
-       char **p = d;
+       struct seq_file *m = _m;
        struct pcmcia_driver *p_drv = container_of(driver,
                                                   struct pcmcia_driver, drv);
 
-       *p += sprintf(*p, "%-24.24s 1 %d\n", p_drv->drv.name,
+       seq_printf(m, "%-24.24s 1 %d\n", p_drv->drv.name,
 #ifdef CONFIG_MODULE_UNLOAD
                      (p_drv->owner) ? module_refcount(p_drv->owner) : 1
 #else
                      1
 #endif
        );
-       d = (void *) p;
-
        return 0;
 }
 
-static int proc_read_drivers(char *buf, char **start, off_t pos,
-                            int count, int *eof, void *data)
+static int pccard_drivers_proc_show(struct seq_file *m, void *v)
 {
-       char *p = buf;
-       int rc;
-
-       rc = bus_for_each_drv(&pcmcia_bus_type, NULL,
-                             (void *) &p, proc_read_drivers_callback);
-       if (rc < 0)
-               return rc;
+       return bus_for_each_drv(&pcmcia_bus_type, NULL,
+                               m, proc_read_drivers_callback);
+}
 
-       return (p - buf);
+static int pccard_drivers_proc_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, pccard_drivers_proc_show, NULL);
 }
+
+static const struct file_operations pccard_drivers_proc_fops = {
+       .owner          = THIS_MODULE,
+       .open           = pccard_drivers_proc_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+};
 #endif
 
 
@@ -286,7 +290,7 @@ static int pccard_get_status(struct pcmcia_socket *s,
        return 0;
 } /* pccard_get_status */
 
-int pccard_get_configuration_info(struct pcmcia_socket *s,
+static int pccard_get_configuration_info(struct pcmcia_socket *s,
                                  struct pcmcia_device *p_dev,
                                  config_info_t *config)
 {
@@ -858,10 +862,10 @@ static int ds_ioctl(struct inode * inode, struct file * file,
        break;
     case DS_PARSE_TUPLE:
        buf->tuple.TupleData = buf->tuple_parse.data;
-       ret = pccard_parse_tuple(&buf->tuple, &buf->tuple_parse.parse);
+       ret = pcmcia_parse_tuple(&buf->tuple, &buf->tuple_parse.parse);
        break;
     case DS_RESET_CARD:
-       ret = pccard_reset_card(s);
+       ret = pcmcia_reset_card(s);
        break;
     case DS_GET_STATUS:
            if (buf->status.Function &&
@@ -877,7 +881,7 @@ static int ds_ioctl(struct inode * inode, struct file * file,
        mutex_lock(&s->skt_mutex);
        pcmcia_validate_mem(s);
        mutex_unlock(&s->skt_mutex);
-       ret = pccard_validate_cis(s, BIND_FN_ALL, &buf->cisinfo.Chains);
+       ret = pccard_validate_cis(s, &buf->cisinfo.Chains);
        break;
     case DS_SUSPEND_CARD:
        ret = pcmcia_suspend_card(s);
@@ -915,12 +919,9 @@ static int ds_ioctl(struct inode * inode, struct file * file,
                err = -EPERM;
                goto free_out;
        } else {
-               static int printed = 0;
-               if (!printed) {
-                       printk(KERN_WARNING "2.6. kernels use pcmciamtd instead of memory_cs.c and do not require special\n");
-                       printk(KERN_WARNING "MTD handling any more.\n");
-                       printed++;
-               }
+                       printk_once(KERN_WARNING
+                               "2.6. kernels use pcmciamtd instead of memory_cs.c and do not require special\n");
+                       printk_once(KERN_WARNING "MTD handling any more.\n");
        }
        err = -EINVAL;
        goto free_out;
@@ -1014,7 +1015,7 @@ void __init pcmcia_setup_ioctl(void) {
 #ifdef CONFIG_PROC_FS
        proc_pccard = proc_mkdir("bus/pccard", NULL);
        if (proc_pccard)
-               create_proc_read_entry("drivers",0,proc_pccard,proc_read_drivers,NULL);
+               proc_create("drivers", 0, proc_pccard, &pccard_drivers_proc_fops);
 #endif
 }