From dd105f08c0e9d4081629f96b09abadc0bb51e0d8 Mon Sep 17 00:00:00 2001 From: Andrea Gelmini Date: Fri, 26 Feb 2010 10:15:06 +0100 Subject: [PATCH] Staging: comedi: hwdrv_apci3120.c: Checkpatch cleanup ERROR: do not initialise statics to 0 or NULL +static unsigned int ui_Temp = 0; WARNING: braces {} are not necessary for any arm of this statement + if (data[1]) { [...] + } else [...] WARNING: braces {} are not necessary for single statement blocks + for (i = 0; i < devpriv->ui_AiNbrofChannels; i++) { + devpriv->ui_AiChannelList[i] = data[4 + i]; + } ERROR: that open brace { should be on the previous line + } else /* EOC */ + { WARNING: braces {} are not necessary for any arm of this statement + if (data[1]) { [...] + } else { [...] ERROR: that open brace { should be on the previous line + if (insn->unused[0] == 222) /* second insn read */ + { WARNING: braces {} are not necessary for single statement blocks + for (i = 0; i < insn->n; i++) { + data[i] = devpriv->ui_AiReadData[i]; + } WARNING: braces {} are not necessary for single statement blocks + if (cmd->start_src != TRIG_NOW && cmd->start_src != TRIG_EXT) { + err++; + } ERROR: that open brace { should be on the previous line + if (cmd->scan_begin_src == TRIG_TIMER) /* Test Delay timing */ + { ERROR: that open brace { should be on the previous line + if (cmd->convert_src == TRIG_TIMER) /* Test Acquisition timing */ + { WARNING: braces {} are not necessary for any arm of this statement + if (cmd->stop_src == TRIG_COUNT) { [...] + } else { [...] WARNING: braces {} are not necessary for single statement blocks + if (devpriv->b_ExttrigEnable == APCI3120_ENABLE) { + i_APCI3120_ExttrigEnable(dev); /* activate EXT trigger */ + } WARNING: braces {} are not necessary for single statement blocks + if (dmalen0 > (devpriv->ui_AiDataLength)) { + dmalen0 = devpriv->ui_AiDataLength; + } WARNING: braces {} are not necessary for single statement blocks + if (dmalen1 > (devpriv->ui_AiDataLength)) { + dmalen1 = devpriv->ui_AiDataLength; + } WARNING: braces {} are not necessary for any arm of this statement + if (CR_RANGE(chanlist[i]) < APCI3120_BIPOLAR_RANGES) { [...] + } else { [...] ERROR: that open brace { should be on the previous line + if (devpriv->b_EocEosInterrupt == APCI3120_ENABLE) /* enable this in without DMA ??? */ + { ERROR: that open brace { should be on the previous line + if (data[0] == APCI3120_TIMER) /* initialize timer */ + { ERROR: that open brace { should be on the previous line + } else /* Initialize Watch dog */ + { ERROR: that open brace { should be on the previous line + if (data[0] == 2) /* write new value */ + { ERROR: that open brace { should be on the previous line + if (devpriv->b_Timer2Mode == APCI3120_TIMER) /* start timer */ + { ERROR: that open brace { should be on the previous line + } else /* start watch dog */ + { ERROR: that open brace { should be on the previous line + if (devpriv->b_Timer2Mode == APCI3120_TIMER) /* start timer */ + { ERROR: that open brace { should be on the previous line + } else /* Read watch dog status */ + { WARNING: braces {} are not necessary for single statement blocks + if (!devpriv->b_OutputMemoryStatus) { + ui_Temp = 0; + + } /* if(!devpriv->b_OutputMemoryStatus ) */ ERROR: code indent should use tabs where possible + data[0] Value to be written$ ERROR: code indent should use tabs where possible + data[1] :1 Set digital o/p ON$ ERROR: code indent should use tabs where possible + data[1] 2 Set digital o/p OFF with memory ON$ ERROR: that open brace { should be on the previous line + if (ui_Range) /* if 1 then unipolar */ + { ERROR: that open brace { should be on the previous line + } else /* if 0 then bipolar */ + { ERROR: that open brace { should be on the previous line + do /* Waiting of DA_READY BIT */ + { Signed-off-by: Andrea Gelmini Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 119 +++++++----------- 1 file changed, 46 insertions(+), 73 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 07123fd766a3..f93ddd4eb06c 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -45,7 +45,7 @@ You should also find the complete GPL in the COPYING file accompanying this sour */ #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 */ /* @@ -519,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) @@ -548,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 < @@ -653,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; @@ -849,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 */ @@ -1049,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; @@ -1356,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 */ @@ -1514,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; @@ -1966,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; */ @@ -2006,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) */ @@ -2092,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"); @@ -2113,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-> @@ -2146,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-> @@ -2299,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 = @@ -2441,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; } @@ -2504,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 : | +| | +----------------------------------------------------------------------------+ */ @@ -2615,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] = @@ -2627,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]); @@ -2639,8 +2613,7 @@ int i_APCI3120_InsnWriteAnalogOutput(struct comedi_device *dev, * 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; -- 2.39.5