Staging: comedi: hwdrv_apci3120.c: Checkpatch cleanup
[safe/jmp/linux-2.6] / drivers / staging / comedi / drivers / addi-data / hwdrv_apci3120.c
index 2b9a38f..f93ddd4 100644 (file)
@@ -17,7 +17,7 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY
 
 You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
-You shoud also find the complete GPL in the COPYING file accompanying this source code.
+You should also find the complete GPL in the COPYING file accompanying this source code.
 
 @endverbatim
 */
@@ -45,7 +45,7 @@ You shoud also find the complete GPL in the COPYING file accompanying this sourc
 */
 
 #include "hwdrv_apci3120.h"
-static unsigned int ui_Temp = 0;
+static unsigned int ui_Temp;
 
 /* FUNCTION DEFINITIONS */
 
@@ -98,25 +98,22 @@ int i_APCI3120_InsnConfigAnalogInput(struct comedi_device *dev, struct comedi_su
 
                devpriv->b_InterruptMode = APCI3120_EOS_MODE;
 
-               if (data[1]) {
+               if (data[1])
                        devpriv->b_EocEosInterrupt = APCI3120_ENABLE;
-               else
+               else
                        devpriv->b_EocEosInterrupt = APCI3120_DISABLE;
                /*  Copy channel list and Range List to devpriv */
 
                devpriv->ui_AiNbrofChannels = data[3];
-               for (i = 0; i < devpriv->ui_AiNbrofChannels; i++) {
+               for (i = 0; i < devpriv->ui_AiNbrofChannels; i++)
                        devpriv->ui_AiChannelList[i] = data[4 + i];
-               }
 
-       } else                  /*  EOC */
-       {
+       } else {                        /*  EOC */
                devpriv->b_InterruptMode = APCI3120_EOC_MODE;
-               if (data[1]) {
+               if (data[1])
                        devpriv->b_EocEosInterrupt = APCI3120_ENABLE;
-               } else {
+               else
                        devpriv->b_EocEosInterrupt = APCI3120_DISABLE;
-               }
        }
 
        return insn->n;
@@ -166,13 +163,9 @@ int i_APCI3120_InsnReadAnalogInput(struct comedi_device *dev, struct comedi_subd
        devpriv->us_OutputRegister = 0;
 /* devpriv->b_DigitalOutputRegister=0; */
 
-       if (insn->unused[0] == 222)     /*  second insn read */
-       {
-
-               for (i = 0; i < insn->n; i++) {
+       if (insn->unused[0] == 222) {   /*  second insn read */
+               for (i = 0; i < insn->n; i++)
                        data[i] = devpriv->ui_AiReadData[i];
-               }
-
        } else {
                devpriv->tsk_Current = current; /*  Save the current process task structure */
 /*
@@ -368,9 +361,8 @@ int i_APCI3120_InsnReadAnalogInput(struct comedi_device *dev, struct comedi_subd
                                        us_TmpValue =
                                                inw(devpriv->iobase +
                                                APCI3120_RD_STATUS);
-                               }
-                               while ((us_TmpValue & APCI3120_EOS) !=
-                                       APCI3120_EOS);
+                               } while ((us_TmpValue & APCI3120_EOS) !=
+                                        APCI3120_EOS);
 
                                for (i = 0; i < devpriv->ui_AiNbrofChannels;
                                        i++) {
@@ -520,9 +512,8 @@ int i_APCI3120_CommandTestAnalogInput(struct comedi_device *dev, struct comedi_s
 
        /* step 2: make sure trigger sources are unique and mutually compatible */
 
-       if (cmd->start_src != TRIG_NOW && cmd->start_src != TRIG_EXT) {
+       if (cmd->start_src != TRIG_NOW && cmd->start_src != TRIG_EXT)
                err++;
-       }
 
        if (cmd->scan_begin_src != TRIG_TIMER &&
                cmd->scan_begin_src != TRIG_FOLLOW)
@@ -549,16 +540,14 @@ int i_APCI3120_CommandTestAnalogInput(struct comedi_device *dev, struct comedi_s
                err++;
        }
 
-       if (cmd->scan_begin_src == TRIG_TIMER)  /*  Test Delay timing */
-       {
+       if (cmd->scan_begin_src == TRIG_TIMER) {        /*  Test Delay timing */
                if (cmd->scan_begin_arg < this_board->ui_MinDelaytimeNs) {
                        cmd->scan_begin_arg = this_board->ui_MinDelaytimeNs;
                        err++;
                }
        }
 
-       if (cmd->convert_src == TRIG_TIMER)     /*  Test Acquisition timing */
-       {
+       if (cmd->convert_src == TRIG_TIMER) {   /*  Test Acquisition timing */
                if (cmd->scan_begin_src == TRIG_TIMER) {
                        if ((cmd->convert_arg)
                                && (cmd->convert_arg <
@@ -654,11 +643,10 @@ int i_APCI3120_CommandAnalogInput(struct comedi_device *dev, struct comedi_subde
        /* UPDATE-0.7.57->0.7.68devpriv->ui_AiDataLength=s->async->data_len; */
        devpriv->ui_AiDataLength = s->async->prealloc_bufsz;
 
-       if (cmd->stop_src == TRIG_COUNT) {
+       if (cmd->stop_src == TRIG_COUNT)
                devpriv->ui_AiNbrofScans = cmd->stop_arg;
-       } else {
+       else
                devpriv->ui_AiNbrofScans = 0;
-       }
 
        devpriv->ui_AiTimer0 = 0;       /*  variables changed to timer0,timer1 */
        devpriv->ui_AiTimer1 = 0;
@@ -850,9 +838,8 @@ int i_APCI3120_CyclicAnalogInput(int mode, struct comedi_device *dev,
        }
 /*** EL241003 End ******************************************************************************/
 
-       if (devpriv->b_ExttrigEnable == APCI3120_ENABLE) {
+       if (devpriv->b_ExttrigEnable == APCI3120_ENABLE)
                i_APCI3120_ExttrigEnable(dev);  /*  activate EXT trigger */
-       }
        switch (mode) {
        case 1:
                /*  init timer0 in mode 2 */
@@ -1050,12 +1037,10 @@ int i_APCI3120_CyclicAnalogInput(int mode, struct comedi_device *dev,
                                        dmalen1 = 4;
                        }
                } else {        /*  isn't output buff smaller that our DMA buff? */
-                       if (dmalen0 > (devpriv->ui_AiDataLength)) {
+                       if (dmalen0 > (devpriv->ui_AiDataLength))
                                dmalen0 = devpriv->ui_AiDataLength;
-                       }
-                       if (dmalen1 > (devpriv->ui_AiDataLength)) {
+                       if (dmalen1 > (devpriv->ui_AiDataLength))
                                dmalen1 = devpriv->ui_AiDataLength;
-                       }
                }
                devpriv->ui_DmaBufferUsesize[0] = dmalen0;
                devpriv->ui_DmaBufferUsesize[1] = dmalen1;
@@ -1357,11 +1342,10 @@ int i_APCI3120_SetupChannelList(struct comedi_device *dev, struct comedi_subdevi
                /*  store range list to card */
                us_TmpValue = CR_CHAN(chanlist[i]);     /*  get channel number; */
 
-               if (CR_RANGE(chanlist[i]) < APCI3120_BIPOLAR_RANGES) {
+               if (CR_RANGE(chanlist[i]) < APCI3120_BIPOLAR_RANGES)
                        us_TmpValue &= ((~APCI3120_UNIPOLAR) & 0xff);   /*  set bipolar */
-               } else {
+               else
                        us_TmpValue |= APCI3120_UNIPOLAR;       /*  enable unipolar...... */
-               }
 
                gain = CR_RANGE(chanlist[i]);   /*  get gain number */
                us_TmpValue |= ((gain & 0x03) << 4);    /* <<4 for G0 and G1 bit in RAM */
@@ -1469,7 +1453,7 @@ void v_APCI3120_Interrupt(int irq, void *d)
        int_amcc = inl(devpriv->i_IobaseAmcc + AMCC_OP_REG_INTCSR);     /*  get AMCC int register */
 
        if ((!int_daq) && (!(int_amcc & ANY_S593X_INT))) {
-               comedi_error(dev, "IRQ from unknow source");
+               comedi_error(dev, "IRQ from unknown source");
                return;
        }
 
@@ -1515,8 +1499,7 @@ void v_APCI3120_Interrupt(int irq, void *d)
        /*  Check If EOS interrupt */
        if ((int_daq & 0x2) && (devpriv->b_InterruptMode == APCI3120_EOS_MODE)) {
 
-               if (devpriv->b_EocEosInterrupt == APCI3120_ENABLE)      /*  enable this in without DMA ??? */
-               {
+               if (devpriv->b_EocEosInterrupt == APCI3120_ENABLE) {    /*  enable this in without DMA ??? */
 
                        if (devpriv->b_AiCyclicAcquisition == APCI3120_ENABLE) {
                                ui_Check = 0;
@@ -1967,8 +1950,7 @@ int i_APCI3120_InsnConfigTimer(struct comedi_device *dev, struct comedi_subdevic
                APCI3120_DISABLE_EOS_INT;
        outb(devpriv->b_ModeSelectRegister,
                devpriv->iobase + APCI3120_WRITE_MODE_SELECT);
-       if (data[0] == APCI3120_TIMER)  /* initialize timer */
-       {
+       if (data[0] == APCI3120_TIMER) {        /* initialize timer */
                /* devpriv->b_ModeSelectRegister=devpriv->b_ModeSelectRegister |
                 * APCI3120_ENABLE_TIMER_INT; */
 
@@ -2007,8 +1989,7 @@ int i_APCI3120_InsnConfigTimer(struct comedi_device *dev, struct comedi_subdevic
                /*  timer2 in Timer mode enabled */
                devpriv->b_Timer2Mode = APCI3120_TIMER;
 
-       } else                  /*  Initialize Watch dog */
-       {
+       } else {                        /*  Initialize Watch dog */
 
                /* Set the Timer 2 in mode 5(Watchdog) */
 
@@ -2093,8 +2074,7 @@ int i_APCI3120_InsnWriteTimer(struct comedi_device *dev, struct comedi_subdevice
                return -EINVAL;
        }
 
-       if (data[0] == 2)       /*  write new value */
-       {
+       if (data[0] == 2) {     /*  write new value */
                if (devpriv->b_Timer2Mode != APCI3120_TIMER) {
                        comedi_error(dev,
                                "write :timer2  not configured  in TIMER MODE");
@@ -2114,13 +2094,11 @@ int i_APCI3120_InsnWriteTimer(struct comedi_device *dev, struct comedi_subdevice
 
                /*  Reset FC_TIMER BIT */
                inb(devpriv->iobase + APCI3120_TIMER_STATUS_REGISTER);
-               if (devpriv->b_Timer2Mode == APCI3120_TIMER)    /* start timer */
-               {
+               if (devpriv->b_Timer2Mode == APCI3120_TIMER) {  /* start timer */
                        /* Enable Timer */
                        devpriv->b_ModeSelectRegister =
                                devpriv->b_ModeSelectRegister & 0x0B;
-               } else          /* start watch dog */
-               {
+               } else {                /* start watch dog */
                        /* Enable WatchDog */
                        devpriv->b_ModeSelectRegister =
                                (devpriv->
@@ -2147,8 +2125,7 @@ int i_APCI3120_InsnWriteTimer(struct comedi_device *dev, struct comedi_subdevice
                outb(devpriv->b_ModeSelectRegister,
                        devpriv->iobase + APCI3120_WRITE_MODE_SELECT);
 
-               if (devpriv->b_Timer2Mode == APCI3120_TIMER)    /* start timer */
-               {
+               if (devpriv->b_Timer2Mode == APCI3120_TIMER) {  /* start timer */
                        /* For Timer mode is  Gate2 must be activated   **timer started */
                        devpriv->us_OutputRegister =
                                devpriv->
@@ -2300,8 +2277,7 @@ int i_APCI3120_InsnReadTimer(struct comedi_device *dev, struct comedi_subdevice
                /*  combining both words */
                data[0] = (unsigned int) ((us_TmpValue) | ((us_TmpValue_2) << 16));
 
-       } else                  /*  Read watch dog status */
-       {
+       } else {                        /*  Read watch dog status */
 
                us_StatusValue = inw(devpriv->iobase + APCI3120_RD_STATUS);
                us_StatusValue =
@@ -2351,7 +2327,7 @@ int i_APCI3120_InsnReadDigitalInput(struct comedi_device *dev,
        ui_Chan = CR_CHAN(insn->chanspec);      /*  channel specified */
 
        /* this_board->i_hwdrv_InsnReadDigitalInput(dev,ui_Chan,data); */
-       if (ui_Chan >= 0 && ui_Chan <= 3) {
+       if (ui_Chan <= 3) {
                ui_TmpValue = (unsigned int) inw(devpriv->iobase + APCI3120_RD_STATUS);
 
 /*
@@ -2442,10 +2418,9 @@ int i_APCI3120_InsnConfigDigitalOutput(struct comedi_device *dev,
                devpriv->b_OutputMemoryStatus = APCI3120_DISABLE;
                devpriv->b_DigitalOutputRegister = 0;
        }
-       if (!devpriv->b_OutputMemoryStatus) {
+       if (!devpriv->b_OutputMemoryStatus)
                ui_Temp = 0;
-
-       }                       /* if(!devpriv->b_OutputMemoryStatus ) */
+                               /* if(!devpriv->b_OutputMemoryStatus ) */
 
        return insn->n;
 }
@@ -2505,23 +2480,23 @@ int i_APCI3120_InsnBitsDigitalOutput(struct comedi_device *dev,
 
 /*
 +----------------------------------------------------------------------------+
-| Function name     :int i_APCI3120_InsnWriteDigitalOutput(struct comedi_device *dev,|
-|struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data)                                    |
-|                                                                                               |
+| Function name                :int i_APCI3120_InsnWriteDigitalOutput(struct comedi_device *dev,|
+|struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data)       |
+|                                                                              |
 +----------------------------------------------------------------------------+
-| Task              : Write digiatl output                                                                  |
-|                                                                                                               |
+| Task                 : Write digiatl output                                  |
+|                                                                              |
 +----------------------------------------------------------------------------+
-| Input Parameters  : struct comedi_device *dev                                                                         |
-|                     struct comedi_subdevice *s                                                                        |
-|                     struct comedi_insn *insn                                      |
-|                     unsigned int *data                                                                                |
-                      data[0]     Value to be written
-                      data[1]    :1 Set digital o/p ON
-                      data[1]     2 Set digital o/p OFF with memory ON
+| Input Parameters     : struct comedi_device *dev                             |
+|                      struct comedi_subdevice *s                              |
+|                      struct comedi_insn *insn                                |
+|                      unsigned int *data                                      |
+                       data[0]     Value to be written
+                       data[1]    :1 Set digital o/p ON
+                       data[1]     2 Set digital o/p OFF with memory ON
 +----------------------------------------------------------------------------+
-| Return Value      :                                                                           |
-|                                                                                                                           |
+| Return Value         :                                                       |
+|                                                                              |
 +----------------------------------------------------------------------------+
 */
 
@@ -2540,8 +2515,7 @@ int i_APCI3120_InsnWriteDigitalOutput(struct comedi_device *dev,
                        "Not a valid Data !!! ,Data should be 1 or 0\n");
                return -EINVAL;
        }
-       if ((ui_NoOfChannel > (this_board->i_NbrDoChannel - 1))
-               || (ui_NoOfChannel < 0)) {
+       if (ui_NoOfChannel > this_board->i_NbrDoChannel - 1) {
                comedi_error(dev,
                        "This board doesn't have specified channel !!! \n");
                return -EINVAL;
@@ -2576,7 +2550,7 @@ int i_APCI3120_InsnWriteDigitalOutput(struct comedi_device *dev,
 
 /* ES05        ui_Temp=data[0] & 0xf0; */
        devpriv->b_DigitalOutputRegister = data[0] & 0xf0;
-       return (insn->n);
+       return insn->n;
 
 }
 
@@ -2617,8 +2591,7 @@ int i_APCI3120_InsnWriteAnalogOutput(struct comedi_device *dev,
        ui_Channel = CR_CHAN(insn->chanspec);
 
        /* this_board->i_hwdrv_InsnWriteAnalogOutput(dev, ui_Range, ui_Channel,data[0]); */
-       if (ui_Range)           /*  if 1 then unipolar */
-       {
+       if (ui_Range) {         /*  if 1 then unipolar */
 
                if (data[0] != 0)
                        data[0] =
@@ -2629,8 +2602,7 @@ int i_APCI3120_InsnWriteAnalogOutput(struct comedi_device *dev,
                                ((((ui_Channel & 0x03) << 14) & 0xC000) | (1 <<
                                        13) | 8192);
 
-       } else                  /*  if 0 then   bipolar */
-       {
+       } else {                        /*  if 0 then   bipolar */
                data[0] =
                        ((((ui_Channel & 0x03) << 14) & 0xC000) | (0 << 13) |
                        data[0]);
@@ -2638,11 +2610,10 @@ int i_APCI3120_InsnWriteAnalogOutput(struct comedi_device *dev,
        }
 
 /*
- * out put n values at the given channel. rt_printk("\nwaiting for
+ * out put n values at the given channel. printk("\nwaiting for
  * DA_READY BIT");
  */
-       do                      /* Waiting of DA_READY BIT */
-       {
+       do {                    /* Waiting of DA_READY BIT */
                us_TmpValue =
                        ((unsigned short) inw(devpriv->iobase +
                                APCI3120_RD_STATUS)) & 0x0001;