Staging: comedi: pcmcia irq fixes
[safe/jmp/linux-2.6] / drivers / staging / comedi / drivers / ni_labpc_cs.c
index 1e58d2e..a3053b8 100644 (file)
@@ -60,7 +60,7 @@ NI manuals:
 */
 
 #undef LABPC_DEBUG
-//#define LABPC_DEBUG   // enable debugging messages
+                           /* #define LABPC_DEBUG *//*  enable debugging messages */
 
 #include "../comedidev.h"
 
@@ -79,36 +79,36 @@ NI manuals:
 
 static struct pcmcia_device *pcmcia_cur_dev = NULL;
 
-static int labpc_attach(struct comedi_device * dev, struct comedi_devconfig * it);
+static int labpc_attach(struct comedi_device *dev, struct comedi_devconfig *it);
 
 static const struct labpc_board_struct labpc_cs_boards[] = {
        {
-             name:     "daqcard-1200",
-             device_id:0x103,  // 0x10b is manufacturer id, 0x103 is device id
-             ai_speed:10000,
-             bustype:  pcmcia_bustype,
-             register_layout:labpc_1200_layout,
-             has_ao:   1,
-             ai_range_table:&range_labpc_1200_ai,
-             ai_range_code:labpc_1200_ai_gain_bits,
-             ai_range_is_unipolar:labpc_1200_is_unipolar,
-             ai_scan_up:0,
-             memory_mapped_io:0,
-               },
+        .name = "daqcard-1200",
+        .device_id = 0x103,    /*  0x10b is manufacturer id, 0x103 is device id */
+        .ai_speed = 10000,
+        .bustype = pcmcia_bustype,
+        .register_layout = labpc_1200_layout,
+        .has_ao = 1,
+        .ai_range_table = &range_labpc_1200_ai,
+        .ai_range_code = labpc_1200_ai_gain_bits,
+        .ai_range_is_unipolar = labpc_1200_is_unipolar,
+        .ai_scan_up = 0,
+        .memory_mapped_io = 0,
+        },
        /* duplicate entry, to support using alternate name */
        {
-             name:     "ni_labpc_cs",
-             device_id:0x103,
-             ai_speed:10000,
-             bustype:  pcmcia_bustype,
-             register_layout:labpc_1200_layout,
-             has_ao:   1,
-             ai_range_table:&range_labpc_1200_ai,
-             ai_range_code:labpc_1200_ai_gain_bits,
-             ai_range_is_unipolar:labpc_1200_is_unipolar,
-             ai_scan_up:0,
-             memory_mapped_io:0,
-               },
+        .name = "ni_labpc_cs",
+        .device_id = 0x103,
+        .ai_speed = 10000,
+        .bustype = pcmcia_bustype,
+        .register_layout = labpc_1200_layout,
+        .has_ao = 1,
+        .ai_range_table = &range_labpc_1200_ai,
+        .ai_range_code = labpc_1200_ai_gain_bits,
+        .ai_range_is_unipolar = labpc_1200_is_unipolar,
+        .ai_scan_up = 0,
+        .memory_mapped_io = 0,
+        },
 };
 
 /*
@@ -121,22 +121,22 @@ static struct comedi_driver driver_labpc_cs = {
        .module = THIS_MODULE,
        .attach = &labpc_attach,
        .detach = &labpc_common_detach,
-       .num_names = sizeof(labpc_cs_boards) / sizeof(struct labpc_board_struct),
+       .num_names = ARRAY_SIZE(labpc_cs_boards),
        .board_name = &labpc_cs_boards[0].name,
        .offset = sizeof(struct labpc_board_struct),
 };
 
-static int labpc_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int labpc_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 {
        unsigned long iobase = 0;
        unsigned int irq = 0;
        struct pcmcia_device *link;
 
        /* allocate and initialize dev->private */
-       if (alloc_private(dev, sizeof(labpc_private)) < 0)
+       if (alloc_private(dev, sizeof(struct labpc_private)) < 0)
                return -ENOMEM;
 
-       // get base address, irq etc. based on bustype
+       /*  get base address, irq etc. based on bustype */
        switch (thisboard->bustype) {
        case pcmcia_bustype:
                link = pcmcia_cur_dev;  /* XXX hack */
@@ -165,7 +165,7 @@ 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 const char *version =
-       "ni_labpc.c, based on dummy_cs.c 1.31 2001/08/24 12:13:13";
+    "ni_labpc.c, based on dummy_cs.c 1.31 2001/08/24 12:13:13";
 #else
 #define DEBUG(n, args...)
 #endif
@@ -246,7 +246,7 @@ static int labpc_cs_attach(struct pcmcia_device *link)
        link->priv = local;
 
        /* Interrupt setup */
-       link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_FORCED_PULSE;
+       link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING | IRQ_FORCED_PULSE;
        link->irq.IRQInfo1 = IRQ_INFO2_VALID | IRQ_PULSE_ID;
        link->irq.Handler = NULL;
 
@@ -287,7 +287,7 @@ static void labpc_cs_detach(struct pcmcia_device *link)
           detach().
         */
        if (link->dev_node) {
-               ((struct local_info_t *) link->priv)->stop = 1;
+               ((struct local_info_t *)link->priv)->stop = 1;
                labpc_release(link);
        }
 
@@ -327,15 +327,21 @@ static void labpc_config(struct pcmcia_device *link)
        tuple.TupleData = buf;
        tuple.TupleDataMax = sizeof(buf);
        tuple.TupleOffset = 0;
-       if ((last_ret = pcmcia_get_first_tuple(link, &tuple))) {
+
+       last_ret = pcmcia_get_first_tuple(link, &tuple);
+       if (last_ret) {
                cs_error(link, GetFirstTuple, last_ret);
                goto cs_failed;
        }
-       if ((last_ret = pcmcia_get_tuple_data(link, &tuple))) {
+
+       last_ret = pcmcia_get_tuple_data(link, &tuple);
+       if (last_ret) {
                cs_error(link, GetTupleData, last_ret);
                goto cs_failed;
        }
-       if ((last_ret = pcmcia_parse_tuple(&tuple, &parse))) {
+
+       last_ret = pcmcia_parse_tuple(&tuple, &parse);
+       if (last_ret) {
                cs_error(link, ParseTuple, last_ret);
                goto cs_failed;
        }
@@ -355,7 +361,8 @@ static void labpc_config(struct pcmcia_device *link)
           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))) {
+       last_ret = pcmcia_get_first_tuple(link, &tuple);
+       if (last_ret) {
                cs_error(link, GetFirstTuple, last_ret);
                goto cs_failed;
        }
@@ -402,7 +409,7 @@ static void labpc_config(struct pcmcia_device *link)
 
                if ((cfg->mem.nwin > 0) || (dflt.mem.nwin > 0)) {
                        cistpl_mem_t *mem =
-                               (cfg->mem.nwin) ? &cfg->mem : &dflt.mem;
+                           (cfg->mem.nwin) ? &cfg->mem : &dflt.mem;
                        req.Attributes = WIN_DATA_WIDTH_16 | WIN_MEMORY_TYPE_CM;
                        req.Attributes |= WIN_ENABLE;
                        req.Base = mem->win[0].host_addr;
@@ -421,8 +428,9 @@ static void labpc_config(struct pcmcia_device *link)
                /* If we got this far, we're cool! */
                break;
 
-             next_entry:
-               if ((last_ret = pcmcia_get_next_tuple(link, &tuple))) {
+next_entry:
+               last_ret = pcmcia_get_next_tuple(link, &tuple);
+               if (last_ret) {
                        cs_error(link, GetNextTuple, last_ret);
                        goto cs_failed;
                }
@@ -433,18 +441,21 @@ static void labpc_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))) {
+       if (link->conf.Attributes & CONF_ENABLE_IRQ) {
+               last_ret = pcmcia_request_irq(link, &link->irq);
+               if (last_ret) {
                        cs_error(link, RequestIRQ, last_ret);
                        goto cs_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))) {
+       last_ret = pcmcia_request_configuration(link, &link->conf);
+       if (last_ret) {
                cs_error(link, RequestConfiguration, last_ret);
                goto cs_failed;
        }
@@ -459,23 +470,23 @@ static void labpc_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 %d", 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);
        if (link->win)
                printk(", mem 0x%06lx-0x%06lx", req.Base,
-                       req.Base + req.Size - 1);
+                      req.Base + req.Size - 1);
        printk("\n");
 
        return;
 
-      cs_failed:
+cs_failed:
        labpc_release(link);
 
 }                              /* labpc_config */
@@ -534,7 +545,7 @@ struct pcmcia_driver labpc_cs_driver = {
        .id_table = labpc_cs_ids,
        .owner = THIS_MODULE,
        .drv = {
-                       .name = dev_info,
+               .name = dev_info,
                },
 };