Staging: Comedi: Lindent changes to comdi driver in staging tree
[pandora-kernel.git] / drivers / staging / comedi / drivers / dt3000.c
index 2af8b59..bbbef79 100644 (file)
@@ -68,18 +68,19 @@ AO commands are not supported.
 #define PCI_VENDOR_ID_DT       0x1116
 
 static const struct comedi_lrange range_dt3000_ai = { 4, {
-                       RANGE(-10, 10),
-                       RANGE(-5, 5),
-                       RANGE(-2.5, 2.5),
-                       RANGE(-1.25, 1.25)
-       }
+                                                         RANGE(-10, 10),
+                                                         RANGE(-5, 5),
+                                                         RANGE(-2.5, 2.5),
+                                                         RANGE(-1.25, 1.25)
+                                                         }
 };
+
 static const struct comedi_lrange range_dt3000_ai_pgl = { 4, {
-                       RANGE(-10, 10),
-                       RANGE(-1, 1),
-                       RANGE(-0.1, 0.1),
-                       RANGE(-0.02, 0.02)
-       }
+                                                             RANGE(-10, 10),
+                                                             RANGE(-1, 1),
+                                                             RANGE(-0.1, 0.1),
+                                                             RANGE(-0.02, 0.02)
+                                                             }
 };
 
 struct dt3k_boardtype {
@@ -94,7 +95,6 @@ struct dt3k_boardtype {
        int dabits;
 };
 
-
 static const struct dt3k_boardtype dt3k_boardtypes[] = {
        {.name = "dt3001",
         .device_id = 0x22,
@@ -104,7 +104,7 @@ static const struct dt3k_boardtype dt3k_boardtypes[] = {
         .ai_speed = 3000,
         .dachan = 2,
         .dabits = 12,
-       },
+        },
        {.name = "dt3001-pgl",
         .device_id = 0x27,
         .adchan = 16,
@@ -113,7 +113,7 @@ static const struct dt3k_boardtype dt3k_boardtypes[] = {
         .ai_speed = 3000,
         .dachan = 2,
         .dabits = 12,
-       },
+        },
        {.name = "dt3002",
         .device_id = 0x23,
         .adchan = 32,
@@ -122,7 +122,7 @@ static const struct dt3k_boardtype dt3k_boardtypes[] = {
         .ai_speed = 3000,
         .dachan = 0,
         .dabits = 0,
-       },
+        },
        {.name = "dt3003",
         .device_id = 0x24,
         .adchan = 64,
@@ -131,7 +131,7 @@ static const struct dt3k_boardtype dt3k_boardtypes[] = {
         .ai_speed = 3000,
         .dachan = 2,
         .dabits = 12,
-       },
+        },
        {.name = "dt3003-pgl",
         .device_id = 0x28,
         .adchan = 64,
@@ -140,7 +140,7 @@ static const struct dt3k_boardtype dt3k_boardtypes[] = {
         .ai_speed = 3000,
         .dachan = 2,
         .dabits = 12,
-       },
+        },
        {.name = "dt3004",
         .device_id = 0x25,
         .adchan = 16,
@@ -149,8 +149,8 @@ static const struct dt3k_boardtype dt3k_boardtypes[] = {
         .ai_speed = 10000,
         .dachan = 2,
         .dabits = 12,
-       },
-        {.name = "dt3005",             /* a.k.a. 3004-200 */
+        },
+       {.name = "dt3005",      /* a.k.a. 3004-200 */
         .device_id = 0x26,
         .adchan = 16,
         .adbits = 16,
@@ -158,21 +158,22 @@ static const struct dt3k_boardtype dt3k_boardtypes[] = {
         .ai_speed = 5000,
         .dachan = 2,
         .dabits = 12,
-       },
+        },
 };
 
 #define n_dt3k_boards sizeof(dt3k_boardtypes)/sizeof(struct dt3k_boardtype)
 #define this_board ((const struct dt3k_boardtype *)dev->board_ptr)
 
 static DEFINE_PCI_DEVICE_TABLE(dt3k_pci_table) = {
-       {PCI_VENDOR_ID_DT, 0x0022, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-       {PCI_VENDOR_ID_DT, 0x0027, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-       {PCI_VENDOR_ID_DT, 0x0023, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-       {PCI_VENDOR_ID_DT, 0x0024, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-       {PCI_VENDOR_ID_DT, 0x0028, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-       {PCI_VENDOR_ID_DT, 0x0025, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-       {PCI_VENDOR_ID_DT, 0x0026, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-       {0}
+       {
+       PCI_VENDOR_ID_DT, 0x0022, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+       PCI_VENDOR_ID_DT, 0x0027, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+       PCI_VENDOR_ID_DT, 0x0023, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+       PCI_VENDOR_ID_DT, 0x0024, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+       PCI_VENDOR_ID_DT, 0x0028, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+       PCI_VENDOR_ID_DT, 0x0025, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+       PCI_VENDOR_ID_DT, 0x0026, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+       0}
 };
 
 MODULE_DEVICE_TABLE(pci, dt3k_pci_table);
@@ -276,7 +277,8 @@ struct dt3k_private {
 
 #define devpriv ((struct dt3k_private *)dev->private)
 
-static int dt3000_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int dt3000_attach(struct comedi_device *dev,
+                        struct comedi_devconfig *it);
 static int dt3000_detach(struct comedi_device *dev);
 static struct comedi_driver driver_dt3000 = {
        .driver_name = "dt3000",
@@ -287,10 +289,12 @@ static struct comedi_driver driver_dt3000 = {
 
 COMEDI_PCI_INITCLEANUP(driver_dt3000, dt3k_pci_table);
 
-static void dt3k_ai_empty_fifo(struct comedi_device *dev, struct comedi_subdevice *s);
+static void dt3k_ai_empty_fifo(struct comedi_device *dev,
+                              struct comedi_subdevice *s);
 static int dt3k_ns_to_timer(unsigned int timer_base, unsigned int *arg,
-       unsigned int round_mode);
-static int dt3k_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
+                           unsigned int round_mode);
+static int dt3k_ai_cancel(struct comedi_device *dev,
+                         struct comedi_subdevice *s);
 #ifdef DEBUG
 static void debug_intr_flags(unsigned int flags);
 #endif
@@ -319,8 +323,9 @@ static int dt3k_send_cmd(struct comedi_device *dev, unsigned int cmd)
        return -ETIME;
 }
 
-static unsigned int dt3k_readsingle(struct comedi_device *dev, unsigned int subsys,
-       unsigned int chan, unsigned int gain)
+static unsigned int dt3k_readsingle(struct comedi_device *dev,
+                                   unsigned int subsys, unsigned int chan,
+                                   unsigned int gain)
 {
        writew(subsys, devpriv->io_addr + DPR_SubSys);
 
@@ -333,7 +338,7 @@ static unsigned int dt3k_readsingle(struct comedi_device *dev, unsigned int subs
 }
 
 static void dt3k_writesingle(struct comedi_device *dev, unsigned int subsys,
-       unsigned int chan, unsigned int data)
+                            unsigned int chan, unsigned int data)
 {
        writew(subsys, devpriv->io_addr + DPR_SubSys);
 
@@ -388,6 +393,7 @@ static char *intr_flags[] = {
        "AdFull", "AdSwError", "AdHwError", "DaEmpty",
        "DaSwError", "DaHwError", "CtDone", "CmDone",
 };
+
 static void debug_intr_flags(unsigned int flags)
 {
        int i;
@@ -401,7 +407,8 @@ static void debug_intr_flags(unsigned int flags)
 }
 #endif
 
-static void dt3k_ai_empty_fifo(struct comedi_device *dev, struct comedi_subdevice *s)
+static void dt3k_ai_empty_fifo(struct comedi_device *dev,
+                              struct comedi_subdevice *s)
 {
        int front;
        int rear;
@@ -430,8 +437,8 @@ static void dt3k_ai_empty_fifo(struct comedi_device *dev, struct comedi_subdevic
        writew(rear, devpriv->io_addr + DPR_AD_Buf_Rear);
 }
 
-static int dt3k_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
-       struct comedi_cmd *cmd)
+static int dt3k_ai_cmdtest(struct comedi_device *dev,
+                          struct comedi_subdevice *s, struct comedi_cmd *cmd)
 {
        int err = 0;
        int tmp;
@@ -528,7 +535,7 @@ static int dt3k_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s
        if (cmd->scan_begin_src == TRIG_TIMER) {
                tmp = cmd->scan_begin_arg;
                dt3k_ns_to_timer(100, &cmd->scan_begin_arg,
-                       cmd->flags & TRIG_ROUND_MASK);
+                                cmd->flags & TRIG_ROUND_MASK);
                if (tmp != cmd->scan_begin_arg)
                        err++;
        } else {
@@ -537,14 +544,14 @@ static int dt3k_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s
        if (cmd->convert_src == TRIG_TIMER) {
                tmp = cmd->convert_arg;
                dt3k_ns_to_timer(50, &cmd->convert_arg,
-                       cmd->flags & TRIG_ROUND_MASK);
+                                cmd->flags & TRIG_ROUND_MASK);
                if (tmp != cmd->convert_arg)
                        err++;
                if (cmd->scan_begin_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) {
                        cmd->scan_begin_arg =
-                               cmd->convert_arg * cmd->scan_end_arg;
+                           cmd->convert_arg * cmd->scan_end_arg;
                        err++;
                }
        } else {
@@ -558,7 +565,7 @@ static int dt3k_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s
 }
 
 static int dt3k_ns_to_timer(unsigned int timer_base, unsigned int *nanosec,
-       unsigned int round_mode)
+                           unsigned int round_mode)
 {
        int divider, base, prescale;
 
@@ -608,7 +615,7 @@ static int dt3k_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
                range = CR_RANGE(cmd->chanlist[i]);
 
                writew((range << 6) | chan,
-                       devpriv->io_addr + DPR_ADC_buffer + i);
+                      devpriv->io_addr + DPR_ADC_buffer + i);
        }
        aref = CR_AREF(cmd->chanlist[0]);
 
@@ -617,7 +624,7 @@ static int dt3k_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
 
        if (cmd->convert_src == TRIG_TIMER) {
                divider = dt3k_ns_to_timer(50, &cmd->convert_arg,
-                       cmd->flags & TRIG_ROUND_MASK);
+                                          cmd->flags & TRIG_ROUND_MASK);
                writew((divider >> 16), devpriv->io_addr + DPR_Params(1));
                printk("param[1]=0x%04x\n", divider >> 16);
                writew((divider & 0xffff), devpriv->io_addr + DPR_Params(2));
@@ -628,7 +635,7 @@ static int dt3k_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
 
        if (cmd->scan_begin_src == TRIG_TIMER) {
                tscandiv = dt3k_ns_to_timer(100, &cmd->scan_begin_arg,
-                       cmd->flags & TRIG_ROUND_MASK);
+                                           cmd->flags & TRIG_ROUND_MASK);
                writew((tscandiv >> 16), devpriv->io_addr + DPR_Params(3));
                printk("param[3]=0x%04x\n", tscandiv >> 16);
                writew((tscandiv & 0xffff), devpriv->io_addr + DPR_Params(4));
@@ -650,7 +657,7 @@ static int dt3k_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
        ret = dt3k_send_cmd(dev, CMD_CONFIG);
 
        writew(DT3000_ADFULL | DT3000_ADSWERR | DT3000_ADHWERR,
-               devpriv->io_addr + DPR_Int_Mask);
+              devpriv->io_addr + DPR_Int_Mask);
 
        debug_n_ints = 0;
 
@@ -673,7 +680,7 @@ static int dt3k_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
 }
 
 static int dt3k_ai_insn(struct comedi_device *dev, struct comedi_subdevice *s,
-       struct comedi_insn *insn, unsigned int *data)
+                       struct comedi_insn *insn, unsigned int *data)
 {
        int i;
        unsigned int chan, gain, aref;
@@ -691,7 +698,7 @@ static int dt3k_ai_insn(struct comedi_device *dev, struct comedi_subdevice *s,
 }
 
 static int dt3k_ao_insn(struct comedi_device *dev, struct comedi_subdevice *s,
-       struct comedi_insn *insn, unsigned int *data)
+                       struct comedi_insn *insn, unsigned int *data)
 {
        int i;
        unsigned int chan;
@@ -705,8 +712,9 @@ static int dt3k_ao_insn(struct comedi_device *dev, struct comedi_subdevice *s,
        return i;
 }
 
-static int dt3k_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
-       struct comedi_insn *insn, unsigned int *data)
+static int dt3k_ao_insn_read(struct comedi_device *dev,
+                            struct comedi_subdevice *s,
+                            struct comedi_insn *insn, unsigned int *data)
 {
        int i;
        unsigned int chan;
@@ -734,8 +742,9 @@ static void dt3k_dio_config(struct comedi_device *dev, int bits)
        dt3k_send_cmd(dev, CMD_CONFIG);
 }
 
-static int dt3k_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
-       struct comedi_insn *insn, unsigned int *data)
+static int dt3k_dio_insn_config(struct comedi_device *dev,
+                               struct comedi_subdevice *s,
+                               struct comedi_insn *insn, unsigned int *data)
 {
        int mask;
 
@@ -750,9 +759,9 @@ static int dt3k_dio_insn_config(struct comedi_device *dev, struct comedi_subdevi
                break;
        case INSN_CONFIG_DIO_QUERY:
                data[1] =
-                       (s->io_bits & (1 << CR_CHAN(insn->
-                                       chanspec))) ? COMEDI_OUTPUT :
-                       COMEDI_INPUT;
+                   (s->
+                    io_bits & (1 << CR_CHAN(insn->chanspec))) ? COMEDI_OUTPUT :
+                   COMEDI_INPUT;
                return insn->n;
                break;
        default:
@@ -765,8 +774,9 @@ static int dt3k_dio_insn_config(struct comedi_device *dev, struct comedi_subdevi
        return insn->n;
 }
 
-static int dt3k_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
-       struct comedi_insn *insn, unsigned int *data)
+static int dt3k_dio_insn_bits(struct comedi_device *dev,
+                             struct comedi_subdevice *s,
+                             struct comedi_insn *insn, unsigned int *data)
 {
        if (insn->n != 2)
                return -EINVAL;
@@ -781,8 +791,9 @@ static int dt3k_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice
        return 2;
 }
 
-static int dt3k_mem_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
-       struct comedi_insn *insn, unsigned int *data)
+static int dt3k_mem_insn_read(struct comedi_device *dev,
+                             struct comedi_subdevice *s,
+                             struct comedi_insn *insn, unsigned int *data)
 {
        unsigned int addr = CR_CHAN(insn->chanspec);
        int i;
@@ -925,8 +936,8 @@ static int dt_pci_probe(struct comedi_device *dev, int bus, int slot)
        pcidev = NULL;
        while ((pcidev = dt_pci_find_device(pcidev, &board)) != NULL) {
                if ((bus == 0 && slot == 0) ||
-                       (pcidev->bus->number == bus &&
-                        PCI_SLOT(pcidev->devfn) == slot)) {
+                   (pcidev->bus->number == bus &&
+                    PCI_SLOT(pcidev->devfn) == slot)) {
                        break;
                }
        }
@@ -961,7 +972,7 @@ static int setup_pci(struct comedi_device *dev)
                return -ENOMEM;
 #if DEBUG
        printk("0x%08llx mapped to %p, ",
-               (unsigned long long)devpriv->phys_addr, devpriv->io_addr);
+              (unsigned long long)devpriv->phys_addr, devpriv->io_addr);
 #endif
 
        return 0;
@@ -972,15 +983,17 @@ static struct pci_dev *dt_pci_find_device(struct pci_dev *from, int *board)
        int i;
 
        for (from = pci_get_device(PCI_VENDOR_ID_DT, PCI_ANY_ID, from);
-               from != NULL;
-               from = pci_get_device(PCI_VENDOR_ID_DT, PCI_ANY_ID, from)) {
+            from != NULL;
+            from = pci_get_device(PCI_VENDOR_ID_DT, PCI_ANY_ID, from)) {
                for (i = 0; i < n_dt3k_boards; i++) {
                        if (from->device == dt3k_boardtypes[i].device_id) {
                                *board = i;
                                return from;
                        }
                }
-               printk("unknown Data Translation PCI device found with device_id=0x%04x\n", from->device);
+               printk
+                   ("unknown Data Translation PCI device found with device_id=0x%04x\n",
+                    from->device);
        }
        *board = -1;
        return from;