Staging: fix assorted typos all over the place
[safe/jmp/linux-2.6] / drivers / staging / comedi / drivers / quatech_daqp_cs.c
index c30b1cc..3325f24 100644 (file)
@@ -55,27 +55,10 @@ Devices: [Quatech] DAQP-208 (daqp), DAQP-308
 #include <pcmcia/cisreg.h>
 #include <pcmcia/ds.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, 0644);
-#define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args)
-static char *version = "quatech_daqp_cs.c 1.10 2003/04/21 (Brent Baccala)";
-#else
-#define DEBUG(n, args...)
-#endif
-
 /* Maximum number of separate DAQP devices we'll allow */
 #define MAX_DEV         4
 
-typedef struct local_info_t {
+struct local_info_t {
        struct pcmcia_device *link;
        dev_node_t node;
        int stop;
@@ -89,11 +72,11 @@ typedef struct local_info_t {
        struct comedi_device *dev;
        struct comedi_subdevice *s;
        int count;
-} local_info_t;
+};
 
 /* A list of "instances" of the device. */
 
-static local_info_t *dev_table[MAX_DEV] = { NULL, /* ... */  };
+static struct local_info_t *dev_table[MAX_DEV] = { NULL, /* ... */  };
 
 /* The DAQP communicates with the system through a 16 byte I/O window. */
 
@@ -179,39 +162,39 @@ static local_info_t *dev_table[MAX_DEV] = { NULL, /* ... */  };
 #define DAQP_AUX_FIFO_EMPTY            0x01
 
 /* These range structures tell COMEDI how the sample values map to
- * voltages.  The A/D converter has four ranges: +/- 10V through
- * +/- 1.25V, and the D/A converter has only one: +/- 5V.
+ * voltages.  The A/D converter has four       .ranges = +/- 10V through
+ * +/- 1.25V, and the D/A converter has only   .one = +/- 5V.
  */
 
-static const comedi_lrange range_daqp_ai = { 4, {
-                       BIP_RANGE(10),
-                       BIP_RANGE(5),
-                       BIP_RANGE(2.5),
-                       BIP_RANGE(1.25)
-       }
+static const struct comedi_lrange range_daqp_ai = { 4, {
+                                                       BIP_RANGE(10),
+                                                       BIP_RANGE(5),
+                                                       BIP_RANGE(2.5),
+                                                       BIP_RANGE(1.25)
+                                                       }
 };
 
-static const comedi_lrange range_daqp_ao = { 1, {BIP_RANGE(5)} };
+static const struct comedi_lrange range_daqp_ao = { 1, {BIP_RANGE(5)} };
 
 /*====================================================================*/
 
 /* comedi interface code */
 
-static int daqp_attach(struct comedi_device * dev, comedi_devconfig * it);
-static int daqp_detach(struct comedi_device * dev);
+static int daqp_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int daqp_detach(struct comedi_device *dev);
 static struct comedi_driver driver_daqp = {
-      driver_name:"quatech_daqp_cs",
-      module:THIS_MODULE,
-      attach:daqp_attach,
-      detach:daqp_detach,
+       .driver_name = "quatech_daqp_cs",
+       .module = THIS_MODULE,
+       .attach = daqp_attach,
+       .detach = daqp_detach,
 };
 
 #ifdef DAQP_DEBUG
 
-static void daqp_dump(struct comedi_device * dev)
+static void daqp_dump(struct comedi_device *dev)
 {
        printk("DAQP: status %02x; aux status %02x\n",
-               inb(dev->iobase + DAQP_STATUS), inb(dev->iobase + DAQP_AUX));
+              inb(dev->iobase + DAQP_STATUS), inb(dev->iobase + DAQP_AUX));
 }
 
 static void hex_dump(char *str, void *ptr, int len)
@@ -234,9 +217,9 @@ static void hex_dump(char *str, void *ptr, int len)
 
 /* Cancel a running acquisition */
 
-static int daqp_ai_cancel(struct comedi_device * dev, struct comedi_subdevice * s)
+static int daqp_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
 {
-       local_info_t *local = (local_info_t *) s->private;
+       struct local_info_t *local = (struct local_info_t *)s->private;
 
        if (local->stop) {
                return -EIO;
@@ -262,9 +245,9 @@ static int daqp_ai_cancel(struct comedi_device * dev, struct comedi_subdevice *
  * which run pretty quick.
  */
 
-static void daqp_interrupt(int irq, void *dev_id PT_REGS_ARG)
+static void daqp_interrupt(int irq, void *dev_id)
 {
-       local_info_t *local = (local_info_t *) dev_id;
+       struct local_info_t *local = (struct local_info_t *)dev_id;
        struct comedi_device *dev;
        struct comedi_subdevice *s;
        int loop_limit = 10000;
@@ -272,7 +255,7 @@ static void daqp_interrupt(int irq, void *dev_id PT_REGS_ARG)
 
        if (local == NULL) {
                printk(KERN_WARNING
-                       "daqp_interrupt(): irq %d for unknown device.\n", irq);
+                      "daqp_interrupt(): irq %d for unknown device.\n", irq);
                return;
        }
 
@@ -284,20 +267,20 @@ static void daqp_interrupt(int irq, void *dev_id PT_REGS_ARG)
 
        if (!dev->attached) {
                printk(KERN_WARNING
-                       "daqp_interrupt(): struct comedi_device not yet attached.\n");
+                      "daqp_interrupt(): struct comedi_device not yet attached.\n");
                return;
        }
 
        s = local->s;
        if (s == NULL) {
                printk(KERN_WARNING
-                       "daqp_interrupt(): NULL comedi_subdevice.\n");
+                      "daqp_interrupt(): NULL comedi_subdevice.\n");
                return;
        }
 
-       if ((local_info_t *) s->private != local) {
+       if ((struct local_info_t *)s->private != local) {
                printk(KERN_WARNING
-                       "daqp_interrupt(): invalid comedi_subdevice.\n");
+                      "daqp_interrupt(): invalid comedi_subdevice.\n");
                return;
        }
 
@@ -311,13 +294,13 @@ static void daqp_interrupt(int irq, void *dev_id PT_REGS_ARG)
        case buffer:
 
                while (!((status = inb(dev->iobase + DAQP_STATUS))
-                               & DAQP_STATUS_FIFO_EMPTY)) {
+                        & DAQP_STATUS_FIFO_EMPTY)) {
 
                        short data;
 
                        if (status & DAQP_STATUS_DATA_LOST) {
                                s->async->events |=
-                                       COMEDI_CB_EOA | COMEDI_CB_OVERFLOW;
+                                   COMEDI_CB_EOA | COMEDI_CB_OVERFLOW;
                                printk("daqp: data lost\n");
                                daqp_ai_cancel(dev, s);
                                break;
@@ -348,7 +331,7 @@ static void daqp_interrupt(int irq, void *dev_id PT_REGS_ARG)
 
                if (loop_limit <= 0) {
                        printk(KERN_WARNING
-                               "loop_limit reached in daqp_interrupt()\n");
+                              "loop_limit reached in daqp_interrupt()\n");
                        daqp_ai_cancel(dev, s);
                        s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;
                }
@@ -361,10 +344,11 @@ static void daqp_interrupt(int irq, void *dev_id PT_REGS_ARG)
 
 /* One-shot analog data acquisition routine */
 
-static int daqp_ai_insn_read(struct comedi_device * dev, struct comedi_subdevice * s,
-       comedi_insn * insn, unsigned int * data)
+static int daqp_ai_insn_read(struct comedi_device *dev,
+                            struct comedi_subdevice *s,
+                            struct comedi_insn *insn, unsigned int *data)
 {
-       local_info_t *local = (local_info_t *) s->private;
+       struct local_info_t *local = (struct local_info_t *)s->private;
        int i;
        int v;
        int counter = 10000;
@@ -384,7 +368,7 @@ static int daqp_ai_insn_read(struct comedi_device * dev, struct comedi_subdevice
        /* Program one scan list entry */
 
        v = DAQP_SCANLIST_CHANNEL(CR_CHAN(insn->chanspec))
-               | DAQP_SCANLIST_GAIN(CR_RANGE(insn->chanspec));
+           | DAQP_SCANLIST_GAIN(CR_RANGE(insn->chanspec));
 
        if (CR_AREF(insn->chanspec) == AREF_DIFF) {
                v |= DAQP_SCANLIST_DIFFERENTIAL;
@@ -402,7 +386,7 @@ static int daqp_ai_insn_read(struct comedi_device * dev, struct comedi_subdevice
        /* Set trigger */
 
        v = DAQP_CONTROL_TRIGGER_ONESHOT | DAQP_CONTROL_TRIGGER_INTERNAL
-               | DAQP_CONTROL_PACER_100kHz | DAQP_CONTROL_EOS_INT_ENABLE;
+           | DAQP_CONTROL_PACER_100kHz | DAQP_CONTROL_EOS_INT_ENABLE;
 
        outb(v, dev->iobase + DAQP_CONTROL);
 
@@ -411,7 +395,7 @@ static int daqp_ai_insn_read(struct comedi_device * dev, struct comedi_subdevice
         */
 
        while (--counter
-               && (inb(dev->iobase + DAQP_STATUS) & DAQP_STATUS_EVENTS)) ;
+              && (inb(dev->iobase + DAQP_STATUS) & DAQP_STATUS_EVENTS)) ;
        if (!counter) {
                printk("daqp: couldn't clear interrupts in status register\n");
                return -1;
@@ -427,7 +411,7 @@ static int daqp_ai_insn_read(struct comedi_device * dev, struct comedi_subdevice
 
                /* Start conversion */
                outb(DAQP_COMMAND_ARM | DAQP_COMMAND_FIFO_DATA,
-                       dev->iobase + DAQP_COMMAND);
+                    dev->iobase + DAQP_COMMAND);
 
                /* Wait for interrupt service routine to unblock semaphore */
                /* Maybe could use a timeout here, but it's interruptible */
@@ -467,8 +451,8 @@ static int daqp_ns_to_timer(unsigned int *ns, int round)
  * the command passes.
  */
 
-static int daqp_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
-       comedi_cmd * cmd)
+static int daqp_ai_cmdtest(struct comedi_device *dev,
+                          struct comedi_subdevice *s, struct comedi_cmd *cmd)
 {
        int err = 0;
        int tmp;
@@ -505,9 +489,9 @@ static int daqp_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice *
 
        /* step 2: make sure trigger sources are unique and mutually compatible */
 
-       /* note that mutual compatiblity is not an issue here */
+       /* note that mutual compatibility is not an issue here */
        if (cmd->scan_begin_src != TRIG_TIMER &&
-               cmd->scan_begin_src != TRIG_FOLLOW)
+           cmd->scan_begin_src != TRIG_FOLLOW)
                err++;
        if (cmd->convert_src != TRIG_NOW && cmd->convert_src != TRIG_TIMER)
                err++;
@@ -528,7 +512,7 @@ static int daqp_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice *
 #define MAX_SPEED      10000   /* 100 kHz - in nanoseconds */
 
        if (cmd->scan_begin_src == TRIG_TIMER
-               && cmd->scan_begin_arg < MAX_SPEED) {
+           && cmd->scan_begin_arg < MAX_SPEED) {
                cmd->scan_begin_arg = MAX_SPEED;
                err++;
        }
@@ -539,8 +523,7 @@ static int daqp_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice *
         */
 
        if (cmd->scan_begin_src == TRIG_TIMER && cmd->convert_src == TRIG_TIMER
-               && cmd->scan_begin_arg !=
-               cmd->convert_arg * cmd->scan_end_arg) {
+           && cmd->scan_begin_arg != cmd->convert_arg * cmd->scan_end_arg) {
                err++;
        }
 
@@ -574,7 +557,7 @@ static int daqp_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice *
        if (cmd->scan_begin_src == TRIG_TIMER) {
                tmp = cmd->scan_begin_arg;
                daqp_ns_to_timer(&cmd->scan_begin_arg,
-                       cmd->flags & TRIG_ROUND_MASK);
+                                cmd->flags & TRIG_ROUND_MASK);
                if (tmp != cmd->scan_begin_arg)
                        err++;
        }
@@ -582,7 +565,7 @@ static int daqp_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice *
        if (cmd->convert_src == TRIG_TIMER) {
                tmp = cmd->convert_arg;
                daqp_ns_to_timer(&cmd->convert_arg,
-                       cmd->flags & TRIG_ROUND_MASK);
+                                cmd->flags & TRIG_ROUND_MASK);
                if (tmp != cmd->convert_arg)
                        err++;
        }
@@ -593,10 +576,10 @@ static int daqp_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice *
        return 0;
 }
 
-static int daqp_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
+static int daqp_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
 {
-       local_info_t *local = (local_info_t *) s->private;
-       comedi_cmd *cmd = &s->async->cmd;
+       struct local_info_t *local = (struct local_info_t *)s->private;
+       struct comedi_cmd *cmd = &s->async->cmd;
        int counter = 100;
        int scanlist_start_on_every_entry;
        int threshold;
@@ -631,14 +614,14 @@ static int daqp_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
 
        if (cmd->convert_src == TRIG_TIMER) {
                int counter = daqp_ns_to_timer(&cmd->convert_arg,
-                       cmd->flags & TRIG_ROUND_MASK);
+                                              cmd->flags & TRIG_ROUND_MASK);
                outb(counter & 0xff, dev->iobase + DAQP_PACER_LOW);
                outb((counter >> 8) & 0xff, dev->iobase + DAQP_PACER_MID);
                outb((counter >> 16) & 0xff, dev->iobase + DAQP_PACER_HIGH);
                scanlist_start_on_every_entry = 1;
        } else {
                int counter = daqp_ns_to_timer(&cmd->scan_begin_arg,
-                       cmd->flags & TRIG_ROUND_MASK);
+                                              cmd->flags & TRIG_ROUND_MASK);
                outb(counter & 0xff, dev->iobase + DAQP_PACER_LOW);
                outb((counter >> 8) & 0xff, dev->iobase + DAQP_PACER_MID);
                outb((counter >> 16) & 0xff, dev->iobase + DAQP_PACER_HIGH);
@@ -654,7 +637,7 @@ static int daqp_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
                /* Program one scan list entry */
 
                v = DAQP_SCANLIST_CHANNEL(CR_CHAN(chanspec))
-                       | DAQP_SCANLIST_GAIN(CR_RANGE(chanspec));
+                   | DAQP_SCANLIST_GAIN(CR_RANGE(chanspec));
 
                if (CR_AREF(chanspec) == AREF_DIFF) {
                        v |= DAQP_SCANLIST_DIFFERENTIAL;
@@ -765,7 +748,7 @@ static int daqp_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
        /* Set trigger */
 
        v = DAQP_CONTROL_TRIGGER_CONTINUOUS | DAQP_CONTROL_TRIGGER_INTERNAL
-               | DAQP_CONTROL_PACER_5MHz | DAQP_CONTROL_FIFO_INT_ENABLE;
+           | DAQP_CONTROL_PACER_5MHz | DAQP_CONTROL_FIFO_INT_ENABLE;
 
        outb(v, dev->iobase + DAQP_CONTROL);
 
@@ -774,7 +757,7 @@ static int daqp_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
         */
 
        while (--counter
-               && (inb(dev->iobase + DAQP_STATUS) & DAQP_STATUS_EVENTS)) ;
+              && (inb(dev->iobase + DAQP_STATUS) & DAQP_STATUS_EVENTS)) ;
        if (!counter) {
                printk("daqp: couldn't clear interrupts in status register\n");
                return -1;
@@ -786,17 +769,18 @@ static int daqp_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
 
        /* Start conversion */
        outb(DAQP_COMMAND_ARM | DAQP_COMMAND_FIFO_DATA,
-               dev->iobase + DAQP_COMMAND);
+            dev->iobase + DAQP_COMMAND);
 
        return 0;
 }
 
 /* Single-shot analog output routine */
 
-static int daqp_ao_insn_write(struct comedi_device * dev, struct comedi_subdevice * s,
-       comedi_insn * insn, unsigned int * data)
+static int daqp_ao_insn_write(struct comedi_device *dev,
+                             struct comedi_subdevice *s,
+                             struct comedi_insn *insn, unsigned int *data)
 {
-       local_info_t *local = (local_info_t *) s->private;
+       struct local_info_t *local = (struct local_info_t *)s->private;
        int d;
        unsigned int chan;
 
@@ -820,10 +804,11 @@ static int daqp_ao_insn_write(struct comedi_device * dev, struct comedi_subdevic
 
 /* Digital input routine */
 
-static int daqp_di_insn_read(struct comedi_device * dev, struct comedi_subdevice * s,
-       comedi_insn * insn, unsigned int * data)
+static int daqp_di_insn_read(struct comedi_device *dev,
+                            struct comedi_subdevice *s,
+                            struct comedi_insn *insn, unsigned int *data)
 {
-       local_info_t *local = (local_info_t *) s->private;
+       struct local_info_t *local = (struct local_info_t *)s->private;
 
        if (local->stop) {
                return -EIO;
@@ -836,10 +821,11 @@ static int daqp_di_insn_read(struct comedi_device * dev, struct comedi_subdevice
 
 /* Digital output routine */
 
-static int daqp_do_insn_write(struct comedi_device * dev, struct comedi_subdevice * s,
-       comedi_insn * insn, unsigned int * data)
+static int daqp_do_insn_write(struct comedi_device *dev,
+                             struct comedi_subdevice *s,
+                             struct comedi_insn *insn, unsigned int *data)
 {
-       local_info_t *local = (local_info_t *) s->private;
+       struct local_info_t *local = (struct local_info_t *)s->private;
 
        if (local->stop) {
                return -EIO;
@@ -856,17 +842,15 @@ static int daqp_do_insn_write(struct comedi_device * dev, struct comedi_subdevic
  * when it is inserted.
  */
 
-static int daqp_attach(struct comedi_device * dev, comedi_devconfig * it)
+static int daqp_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 {
        int ret;
-       local_info_t *local = dev_table[it->options[0]];
-       tuple_t tuple;
-       int i;
+       struct local_info_t *local = dev_table[it->options[0]];
        struct comedi_subdevice *s;
 
        if (it->options[0] < 0 || it->options[0] >= MAX_DEV || !local) {
                printk("comedi%d: No such daqp device %d\n",
-                       dev->minor, it->options[0]);
+                      dev->minor, it->options[0]);
                return -EIO;
        }
 
@@ -880,39 +864,21 @@ static int daqp_attach(struct comedi_device * dev, comedi_devconfig * it)
 
        strcpy(local->board_name, "DAQP");
        dev->board_name = local->board_name;
-
-       tuple.DesiredTuple = CISTPL_VERS_1;
-       if (pcmcia_get_first_tuple(local->link, &tuple) == 0) {
-               u_char buf[128];
-
-               buf[0] = buf[sizeof(buf) - 1] = 0;
-               tuple.TupleData = buf;
-               tuple.TupleDataMax = sizeof(buf);
-               tuple.TupleOffset = 2;
-               if (pcmcia_get_tuple_data(local->link, &tuple) == 0) {
-
-                       for (i = 0; i < tuple.TupleDataLen - 4; i++)
-                               if (buf[i] == 0)
-                                       break;
-                       for (i++; i < tuple.TupleDataLen - 4; i++)
-                               if (buf[i] == 0)
-                                       break;
-                       i++;
-                       if ((i < tuple.TupleDataLen - 4)
-                               && (strncmp(buf + i, "DAQP", 4) == 0)) {
-                               strncpy(local->board_name, buf + i,
-                                       sizeof(local->board_name));
-                       }
+       if (local->link->prod_id[2]) {
+               if (strncmp(local->link->prod_id[2], "DAQP", 4) == 0) {
+                       strncpy(local->board_name, local->link->prod_id[2],
+                               sizeof(local->board_name));
                }
        }
 
        dev->iobase = local->link->io.BasePort1;
 
-       if ((ret = alloc_subdevices(dev, 4)) < 0)
+       ret = alloc_subdevices(dev, 4);
+       if (ret < 0)
                return ret;
 
        printk("comedi%d: attaching daqp%d (io 0x%04lx)\n",
-               dev->minor, it->options[0], dev->iobase);
+              dev->minor, it->options[0], dev->iobase);
 
        s = dev->subdevices + 0;
        dev->read_subdev = s;
@@ -962,7 +928,7 @@ static int daqp_attach(struct comedi_device * dev, comedi_devconfig * it)
  * card is removed, daqp_cs_detach() is called by the pcmcia subsystem.
  */
 
-static int daqp_detach(struct comedi_device * dev)
+static int daqp_detach(struct comedi_device *dev)
 {
        printk("comedi%d: detaching daqp\n", dev->minor);
 
@@ -1051,10 +1017,10 @@ static const dev_info_t dev_info = "quatech_daqp_cs";
 
 static int daqp_cs_attach(struct pcmcia_device *link)
 {
-       local_info_t *local;
+       struct local_info_t *local;
        int i;
 
-       DEBUG(0, "daqp_cs_attach()\n");
+       dev_dbg(&link->dev, "daqp_cs_attach()\n");
 
        for (i = 0; i < MAX_DEV; i++)
                if (dev_table[i] == NULL)
@@ -1065,7 +1031,7 @@ static int daqp_cs_attach(struct pcmcia_device *link)
        }
 
        /* Allocate space for private device-specific data */
-       local = kzalloc(sizeof(local_info_t), GFP_KERNEL);
+       local = kzalloc(sizeof(struct local_info_t), GFP_KERNEL);
        if (!local)
                return -ENOMEM;
 
@@ -1075,10 +1041,8 @@ static int daqp_cs_attach(struct pcmcia_device *link)
        link->priv = local;
 
        /* Interrupt setup */
-       link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT;
-       link->irq.IRQInfo1 = IRQ_LEVEL_ID;
+       link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
        link->irq.Handler = daqp_interrupt;
-       link->irq.Instance = local;
 
        /*
           General socket configuration defaults can go here.  In this
@@ -1106,9 +1070,9 @@ static int daqp_cs_attach(struct pcmcia_device *link)
 
 static void daqp_cs_detach(struct pcmcia_device *link)
 {
-       local_info_t *dev = link->priv;
+       struct local_info_t *dev = link->priv;
 
-       DEBUG(0, "daqp_cs_detach(0x%p)\n", link);
+       dev_dbg(&link->dev, "daqp_cs_detach\n");
 
        if (link->dev_node) {
                dev->stop = 1;
@@ -1130,106 +1094,54 @@ static void daqp_cs_detach(struct pcmcia_device *link)
 
 ======================================================================*/
 
-static void daqp_cs_config(struct pcmcia_device *link)
-{
-       local_info_t *dev = link->priv;
-       tuple_t tuple;
-       cisparse_t parse;
-       int last_ret;
-       u_char buf[64];
 
-       DEBUG(0, "daqp_cs_config(0x%p)\n", link);
+static int daqp_pcmcia_config_loop(struct pcmcia_device *p_dev,
+                               cistpl_cftable_entry_t *cfg,
+                               cistpl_cftable_entry_t *dflt,
+                               unsigned int vcc,
+                               void *priv_data)
+{
+       if (cfg->index == 0)
+               return -ENODEV;
 
-       /*
-          This reads the card's CONFIG tuple to find its configuration
-          registers.
-        */
-       tuple.DesiredTuple = CISTPL_CONFIG;
-       tuple.Attributes = 0;
-       tuple.TupleData = buf;
-       tuple.TupleDataMax = sizeof(buf);
-       tuple.TupleOffset = 0;
-       if ((last_ret = pcmcia_get_first_tuple(link, &tuple))) {
-               cs_error(link, GetFirstTuple, last_ret);
-               goto cs_failed;
-       }
-       if ((last_ret = pcmcia_get_tuple_data(link, &tuple))) {
-               cs_error(link, GetTupleData, last_ret);
-               goto cs_failed;
-       }
-       if ((last_ret = pcmcia_parse_tuple(&tuple, &parse))) {
-               cs_error(link, ParseTuple, last_ret);
-               goto cs_failed;
+       /* Do we need to allocate an interrupt? */
+       if (cfg->irq.IRQInfo1 || dflt->irq.IRQInfo1)
+               p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
+
+       /* IO window settings */
+       p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0;
+       if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) {
+               cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io;
+               p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
+               if (!(io->flags & CISTPL_IO_8BIT))
+                       p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_16;
+               if (!(io->flags & CISTPL_IO_16BIT))
+                       p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
+               p_dev->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK;
+               p_dev->io.BasePort1 = io->win[0].base;
+               p_dev->io.NumPorts1 = io->win[0].len;
+               if (io->nwin > 1) {
+                       p_dev->io.Attributes2 = p_dev->io.Attributes1;
+                       p_dev->io.BasePort2 = io->win[1].base;
+                       p_dev->io.NumPorts2 = io->win[1].len;
+               }
        }
-       link->conf.ConfigBase = parse.config.base;
-       link->conf.Present = parse.config.rmask[0];
 
-       /*
-          In this loop, we scan the CIS for configuration table entries,
-          each of which describes a valid card configuration, including
-          voltage, IO window, memory window, and interrupt settings.
-
-          We make no assumptions about the card to be configured: we use
-          just the information available in the CIS.  In an ideal world,
-          this would work for any PCMCIA card, but it requires a complete
-          and accurate CIS.  In practice, a driver usually "knows" most of
-          these things without consulting the CIS, and most client drivers
-          will only use the CIS to fill in implementation-defined details.
-        */
-       tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
-       if ((last_ret = pcmcia_get_first_tuple(link, &tuple))) {
-               cs_error(link, GetFirstTuple, last_ret);
-               goto cs_failed;
-       }
-       while (1) {
-               cistpl_cftable_entry_t dflt = { 0 };
-               cistpl_cftable_entry_t *cfg = &(parse.cftable_entry);
-               if (pcmcia_get_tuple_data(link, &tuple))
-                       goto next_entry;
-               if (pcmcia_parse_tuple(&tuple, &parse))
-                       goto next_entry;
-
-               if (cfg->flags & CISTPL_CFTABLE_DEFAULT)
-                       dflt = *cfg;
-               if (cfg->index == 0)
-                       goto next_entry;
-               link->conf.ConfigIndex = cfg->index;
-
-               /* Do we need to allocate an interrupt? */
-               if (cfg->irq.IRQInfo1 || dflt.irq.IRQInfo1)
-                       link->conf.Attributes |= CONF_ENABLE_IRQ;
-
-               /* IO window settings */
-               link->io.NumPorts1 = link->io.NumPorts2 = 0;
-               if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) {
-                       cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt.io;
-                       link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
-                       if (!(io->flags & CISTPL_IO_8BIT))
-                               link->io.Attributes1 = IO_DATA_PATH_WIDTH_16;
-                       if (!(io->flags & CISTPL_IO_16BIT))
-                               link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
-                       link->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK;
-                       link->io.BasePort1 = io->win[0].base;
-                       link->io.NumPorts1 = io->win[0].len;
-                       if (io->nwin > 1) {
-                               link->io.Attributes2 = link->io.Attributes1;
-                               link->io.BasePort2 = io->win[1].base;
-                               link->io.NumPorts2 = io->win[1].len;
-                       }
-               }
+       /* This reserves IO space but doesn't actually enable it */
+       return pcmcia_request_io(p_dev, &p_dev->io);
+}
 
-               /* This reserves IO space but doesn't actually enable it */
-               if (pcmcia_request_io(link, &link->io))
-                       goto next_entry;
+static void daqp_cs_config(struct pcmcia_device *link)
+{
+       struct local_info_t *dev = link->priv;
+       int ret;
 
-               /* If we got this far, we're cool! */
-               break;
+       dev_dbg(&link->dev, "daqp_cs_config\n");
 
-             next_entry:
-               if ((last_ret = pcmcia_get_next_tuple(link, &tuple))) {
-                       cs_error(link, GetNextTuple, last_ret);
-                       goto cs_failed;
-               }
+       ret = pcmcia_loop_config(link, daqp_pcmcia_config_loop, NULL);
+       if (ret) {
+               dev_warn(&link->dev, "no configuration found\n");
+               goto failed;
        }
 
        /*
@@ -1237,21 +1149,20 @@ static void daqp_cs_config(struct pcmcia_device *link)
           handler to the interrupt, unless the 'Handler' member of the
           irq structure is initialized.
         */
-       if (link->conf.Attributes & CONF_ENABLE_IRQ)
-               if ((last_ret = pcmcia_request_irq(link, &link->irq))) {
-                       cs_error(link, RequestIRQ, last_ret);
-                       goto cs_failed;
-               }
+       if (link->conf.Attributes & CONF_ENABLE_IRQ) {
+               ret = pcmcia_request_irq(link, &link->irq);
+               if (ret)
+                       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.
         */
-       if ((last_ret = pcmcia_request_configuration(link, &link->conf))) {
-               cs_error(link, RequestConfiguration, last_ret);
-               goto cs_failed;
-       }
+       ret = pcmcia_request_configuration(link, &link->conf);
+       if (ret)
+               goto failed;
 
        /*
           At this point, the dev_node_t structure(s) need to be
@@ -1267,27 +1178,27 @@ static void daqp_cs_config(struct pcmcia_device *link)
 
        /* Finally, report what we've done */
        printk(KERN_INFO "%s: index 0x%02x",
-               dev->node.dev_name, link->conf.ConfigIndex);
+              dev->node.dev_name, link->conf.ConfigIndex);
        if (link->conf.Attributes & CONF_ENABLE_IRQ)
                printk(", irq %u", link->irq.AssignedIRQ);
        if (link->io.NumPorts1)
                printk(", io 0x%04x-0x%04x", link->io.BasePort1,
-                       link->io.BasePort1 + link->io.NumPorts1 - 1);
+                      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);
+                      link->io.BasePort2 + link->io.NumPorts2 - 1);
        printk("\n");
 
        return;
 
-      cs_failed:
+failed:
        daqp_cs_release(link);
 
 }                              /* daqp_cs_config */
 
 static void daqp_cs_release(struct pcmcia_device *link)
 {
-       DEBUG(0, "daqp_cs_release(0x%p)\n", link);
+       dev_dbg(&link->dev, "daqp_cs_release\n");
 
        pcmcia_disable_device(link);
 }                              /* daqp_cs_release */
@@ -1306,7 +1217,7 @@ static void daqp_cs_release(struct pcmcia_device *link)
 
 static int daqp_cs_suspend(struct pcmcia_device *link)
 {
-       local_info_t *local = link->priv;
+       struct local_info_t *local = link->priv;
 
        /* Mark the device as stopped, to block IO until later */
        local->stop = 1;
@@ -1315,7 +1226,7 @@ static int daqp_cs_suspend(struct pcmcia_device *link)
 
 static int daqp_cs_resume(struct pcmcia_device *link)
 {
-       local_info_t *local = link->priv;
+       struct local_info_t *local = link->priv;
 
        local->stop = 0;
 
@@ -1341,13 +1252,12 @@ struct pcmcia_driver daqp_cs_driver = {
        .id_table = daqp_cs_id_table,
        .owner = THIS_MODULE,
        .drv = {
-                       .name = dev_info,
+               .name = dev_info,
                },
 };
 
 int __init init_module(void)
 {
-       DEBUG(0, "%s\n", version);
        pcmcia_register_driver(&daqp_cs_driver);
        comedi_driver_register(&driver_daqp);
        return 0;
@@ -1355,7 +1265,6 @@ int __init init_module(void)
 
 void __exit cleanup_module(void)
 {
-       DEBUG(0, "daqp_cs: unloading\n");
        comedi_driver_unregister(&driver_daqp);
        pcmcia_unregister_driver(&daqp_cs_driver);
 }