]> git.karo-electronics.de Git - linux-beck.git/log
linux-beck.git
10 years agostaging: comedi: addi_apci_3120: enable AI async commands
H Hartley Sweeten [Tue, 4 Nov 2014 17:55:31 +0000 (10:55 -0700)]
staging: comedi: addi_apci_3120: enable AI async commands

The async command support should now work. Enable the hook up of the command
support functions in apci3120_auto_attach().

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: switch DMA buffers after writing samples
H Hartley Sweeten [Tue, 4 Nov 2014 17:55:30 +0000 (10:55 -0700)]
staging: comedi: addi_apci_3120: switch DMA buffers after writing samples

Currently the DMA buffers are switched before writing the current samples to
the async buffer. This works but when the EOA event happens we end up with an
outstanding DMA operation in progress that gets terminated by the (*cancel).

Avoid the outstanding DMA operation by switching the DMA buffers after writing
the samples. The driver will detect the EOA event and not retart the DMA.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: change params to apci3120_interrupt_dma()
H Hartley Sweeten [Tue, 4 Nov 2014 17:55:29 +0000 (10:55 -0700)]
staging: comedi: addi_apci_3120: change params to apci3120_interrupt_dma()

Pass the comedi_device and comedi_subdevice pointers to this function instead
of the irq number and void pointer.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: move apci3120_interrupt_dma() to driver
H Hartley Sweeten [Tue, 4 Nov 2014 17:55:28 +0000 (10:55 -0700)]
staging: comedi: addi_apci_3120: move apci3120_interrupt_dma() to driver

Move this function from the included source file to the main driver
source file.

Remove the now empty included source file.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: use comedi_bytes_to_samples()
H Hartley Sweeten [Tue, 4 Nov 2014 17:55:27 +0000 (10:55 -0700)]
staging: comedi: addi_apci_3120: use comedi_bytes_to_samples()

Use the helper function to calculate the number of samples in the DMA
buffer. For aesthetics, tidy up the local variables.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: move apci3120_interrupt() to driver
H Hartley Sweeten [Tue, 4 Nov 2014 17:55:26 +0000 (10:55 -0700)]
staging: comedi: addi_apci_3120: move apci3120_interrupt() to driver

Move this function from the included source file to the main driver
source file.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: move apci3120_cancel() to driver
H Hartley Sweeten [Tue, 4 Nov 2014 17:55:25 +0000 (10:55 -0700)]
staging: comedi: addi_apci_3120: move apci3120_cancel() to driver

Move this function from the included source file to the main driver
source file.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: use async->events to report hardware error
H Hartley Sweeten [Tue, 4 Nov 2014 17:55:24 +0000 (10:55 -0700)]
staging: comedi: addi_apci_3120: use async->events to report hardware error

In apci3120_interrupt_dma(), use the async->events to report the hardware
error and allow the core to (*cancel) the command instead of calling the
(*cancel) function directly.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: move apci3120_ai_cmd() to driver
H Hartley Sweeten [Tue, 4 Nov 2014 17:55:23 +0000 (10:55 -0700)]
staging: comedi: addi_apci_3120: move apci3120_ai_cmd() to driver

Move this function from the included source file to the main driver
source file.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: move apci3120_setup_dma() to driver
H Hartley Sweeten [Tue, 4 Nov 2014 17:55:22 +0000 (10:55 -0700)]
staging: comedi: addi_apci_3120: move apci3120_setup_dma() to driver

Move this function from the included source file to the main driver
source file.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: move apci3120_init_dma() to driver
H Hartley Sweeten [Tue, 4 Nov 2014 17:55:21 +0000 (10:55 -0700)]
staging: comedi: addi_apci_3120: move apci3120_init_dma() to driver

Move this function from the included source file to the main driver
source file.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: move apci3120_addon_write() to driver
H Hartley Sweeten [Tue, 4 Nov 2014 17:55:20 +0000 (10:55 -0700)]
staging: comedi: addi_apci_3120: move apci3120_addon_write() to driver

Move this function from the included source file to the main driver
source file.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: remove unnecessary include
H Hartley Sweeten [Tue, 4 Nov 2014 17:55:19 +0000 (10:55 -0700)]
staging: comedi: addi_apci_3120: remove unnecessary include

The <linux/sched.h> header is not needed by this driver. Remove the
include.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: add copyright information
H Hartley Sweeten [Tue, 4 Nov 2014 17:55:18 +0000 (10:55 -0700)]
staging: comedi: addi_apci_3120: add copyright information

Remove the copyright info from the included source file and add it
to the main driver source file.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: move AI (*do_cmdtest) to main driver
H Hartley Sweeten [Tue, 4 Nov 2014 17:55:17 +0000 (10:55 -0700)]
staging: comedi: addi_apci_3120: move AI (*do_cmdtest) to main driver

Move apci3120_ai_cmdtest() from the included source file to the main
driver source file. Tidy up Step 4 a bit during the move.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: fix cmd->convert_arg vaildation
H Hartley Sweeten [Tue, 4 Nov 2014 17:55:16 +0000 (10:55 -0700)]
staging: comedi: addi_apci_3120: fix cmd->convert_arg vaildation

Regardless of the cmd->scan_begin_src, the minimum cmd->convert_arg
value is 10000 (10us). Fix the validation in apci3120_ai_cmdtest().

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: fix timer (*insn_config)
H Hartley Sweeten [Tue, 4 Nov 2014 17:55:15 +0000 (10:55 -0700)]
staging: comedi: addi_apci_3120: fix timer (*insn_config)

The timer subdevice in this driver does not follow the comedi API.

Fix the (*insn_config) to correctly arm, disarm, set the mode, and
get the status of the timer.

Remove the unnecessary, and broken, (*insn_write).

The new (*insn_config) does not enable the interrupt for timer 2.
Remove the interrupt support code for the timer.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: fix timer (*insn_read)
H Hartley Sweeten [Tue, 4 Nov 2014 17:55:14 +0000 (10:55 -0700)]
staging: comedi: addi_apci_3120: fix timer (*insn_read)

The timer subdevice in this driver does not follow the comedi API.
Fix the (*insn_read) to work correctly.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: define the AI software trigger register
H Hartley Sweeten [Tue, 4 Nov 2014 17:55:13 +0000 (10:55 -0700)]
staging: comedi: addi_apci_3120: define the AI software trigger register

Define the offset for the analog input software trigger register.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: define the AI FIFO register
H Hartley Sweeten [Tue, 4 Nov 2014 17:55:12 +0000 (10:55 -0700)]
staging: comedi: addi_apci_3120: define the AI FIFO register

Define the offset for the analog input FIFO register.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: don't use timer 2 to count scans
H Hartley Sweeten [Tue, 4 Nov 2014 17:55:11 +0000 (10:55 -0700)]
staging: comedi: addi_apci_3120: don't use timer 2 to count scans

Timer 2 can be used to count the number of scans when the cmd->stop_src
is TRIG_COUNT. Unfortunately that timer can also be used by userspace and
this breaks the async command. Timer 2 also only works for counting the
number of scans when DMA is not used.

The number of scans is counted by the core using the private data membmer
'scans_done'. Use that to detect the End-Of-Scan for both DMA and none
DMA modes.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: rename private data 'ui_DmaActualBuffer'
H Hartley Sweeten [Tue, 4 Nov 2014 17:55:10 +0000 (10:55 -0700)]
staging: comedi: addi_apci_3120: rename private data 'ui_DmaActualBuffer'

Rename this CamelCase member of the private data and convert it to
a bit-field.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: rename private data 'b_DmaDoubleBuffer'
H Hartley Sweeten [Tue, 4 Nov 2014 17:55:09 +0000 (10:55 -0700)]
staging: comedi: addi_apci_3120: rename private data 'b_DmaDoubleBuffer'

Rename this CamelCase member of the private data and convert it to
a bit-field.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: rename private data 'us_UseDma'
H Hartley Sweeten [Tue, 4 Nov 2014 17:55:08 +0000 (10:55 -0700)]
staging: comedi: addi_apci_3120: rename private data 'us_UseDma'

Rename this CamelCase member of the private data and convert it to
a bit-field.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: move apci3120_reset() to driver source
H Hartley Sweeten [Tue, 4 Nov 2014 17:55:07 +0000 (10:55 -0700)]
staging: comedi: addi_apci_3120: move apci3120_reset() to driver source

Move this function from the included hwdrv_apci31210.c source file to
the main driver source file.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: tidy up apci3120_reset()
H Hartley Sweeten [Tue, 4 Nov 2014 17:55:06 +0000 (10:55 -0700)]
staging: comedi: addi_apci_3120: tidy up apci3120_reset()

This function is only called during the attach of the driver and it's
called after the private data has been kzalloc'd. There is no reason
to clear any of the private data members.

Simplify the function by just writing '0' to the necessary registers
to disable all the interrupt sources and stop the timers.

For aesthetics, change the return type to void.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: move DMA init code to apci3120_init_dma()
H Hartley Sweeten [Tue, 4 Nov 2014 17:55:05 +0000 (10:55 -0700)]
staging: comedi: addi_apci_3120: move DMA init code to apci3120_init_dma()

Move the common code used to initialize DMA to apci3120_init_dma().

This follows the programming procedure described in the APCI-3120
documentation.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: move APCI3120_FIFO_ADVANCE_ON_BYTE_2
H Hartley Sweeten [Tue, 4 Nov 2014 17:55:04 +0000 (10:55 -0700)]
staging: comedi: addi_apci_3120: move APCI3120_FIFO_ADVANCE_ON_BYTE_2

Move this define to the main driver source and convert it to a bit-shift.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: define the Add-On registers
H Hartley Sweeten [Tue, 4 Nov 2014 17:55:03 +0000 (10:55 -0700)]
staging: comedi: addi_apci_3120: define the Add-On registers

Define the add-On registers and bits and remove the "magic" numbers in the
driver.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: use amcc_s5933.h defines
H Hartley Sweeten [Tue, 4 Nov 2014 17:55:02 +0000 (10:55 -0700)]
staging: comedi: addi_apci_3120: use amcc_s5933.h defines

Use the defines for the AMCC 5933 PCI controller registers and bits instead
of creating private defines in this driver.

Move the generic AGCSTS_TC_ENABLE define from this driver to the header.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: introduce apci3120_addon_write()
H Hartley Sweeten [Tue, 4 Nov 2014 17:55:01 +0000 (10:55 -0700)]
staging: comedi: addi_apci_3120: introduce apci3120_addon_write()

Introduce a helper function to handle the common code that writes a 32-bit
value to the 16-bit add-on register.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: introduce apci3120_init_dma()
H Hartley Sweeten [Tue, 4 Nov 2014 17:55:00 +0000 (10:55 -0700)]
staging: comedi: addi_apci_3120: introduce apci3120_init_dma()

Introduce a helper function to handle the common code that writes the DMA
start address and number of acquisitions to the AMCC Add-on registers.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: remove private data 'b_ExttrigEnable'
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:59 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: remove private data 'b_ExttrigEnable'

This member of the private data is not really needed. The devpriv->ctrl
value can be checked to determine if the external trigger is enabled.
Remove the unnecessary member.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: remove private data 'b_InterruptMode'
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:58 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: remove private data 'b_InterruptMode'

This member of the private data is not really needed. The interrupt mode
can be determined by checking the devpriv->mode value to see if the
interrupt is enabled. Remove the unnecessary member.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: tidy up devpriv->mode in apci3120_ai_cmd()
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:57 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: tidy up devpriv->mode in apci3120_ai_cmd()

There is no reason for the separate updates of the mode register in this
function. Refactor the code so that the mode register is only updated at
the end of the function after all the necessary bits have been set.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: enable chanlist scanning if needed
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:56 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: enable chanlist scanning if needed

The 'SCAN_ENA' bit in the mode register needs to be set if the chanlist
has more than 1 channel. Set the bit in apci3120_set_chanlist() if needed.
The callers write the mode register after setting any additional bits,

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: set scan length/start after programming chanlist
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:55 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: set scan length/start after programming chanlist

The APCI-3120 documentation says that the PR/PA bits should be set after the
chanlist sequence is programmed.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: reset fifo after programming chanlist
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:54 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: reset fifo after programming chanlist

The APCI-3120 documentation says that the FIFO should be reset after the
chanlist sequence is programmed.

Reset the FIFO after programming the chanlist and remove the extra FIFO
resets in the driver.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: tidy up timer 2 programming in apci3120_ai_cmd()
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:53 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: tidy up timer 2 programming in apci3120_ai_cmd()

Tidy up the programming of timer 2.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: tidy up timer programming in apci3120_ai_cmd()
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:52 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: tidy up timer programming in apci3120_ai_cmd()

Tidy up the programming of timers 0 and 1 so that only one local variable is
required.

Also, remove the unnecessary clear of devpriv->timer_mode. This value will get
set correctly by each apci3120_timer_set_mode() call. It's not necessary to
clear it first.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: absorb apci3120_cyclic_ai()
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:51 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: absorb apci3120_cyclic_ai()

This functon is called by apci3120_ai_cmd() with one additional parameter,
'mode', The 'mode' is based on the cmd->scan_begin_src.

For aesthetics, absorb the function into apci3120_ai_cmd() and use the
cmd->scan_begin_src directly to determine the 'mode'.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: move start_src check into apci3120_cyclic_ai()
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:50 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: move start_src check into apci3120_cyclic_ai()

For aesthetics, move the check of the cmd->start_src.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: move timer 2 enable in apci3120_cyclic_ai()
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:49 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: move timer 2 enable in apci3120_cyclic_ai()

Move the enable of timer 2 to avoid needing the extra if() check.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: flip 'us_UseDma' test in apci3120_cyclic_ai()
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:48 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: flip 'us_UseDma' test in apci3120_cyclic_ai()

For aesthetics, flip this test and do the DMA setup first.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: remove APCI3120_{ENABLE,DISABLE}
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:47 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: remove APCI3120_{ENABLE,DISABLE}

These true/false defines don't add any significant clarity to the code.
Remove them.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: factor DMA setup out of apci3120_cyclic_ai()
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:46 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: factor DMA setup out of apci3120_cyclic_ai()

For aesthetics, factor the DMA setup code out of apci3120_cyclic_ai().

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: move apci3120_set_chanlist() to driver source
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:45 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: move apci3120_set_chanlist() to driver source

Move this function from the included hwdrv_apci31210.c source file to the
main driver source file.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: remove check in apci3120_setup_chan_list()
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:44 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: remove check in apci3120_setup_chan_list()

The n_chan check is not needed. This value will always be >= 1. Remove
the unnecessary check.

For aesthetics, rename the function and change it's return type to void.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: move apci3120_ai_insn_read() to driver source
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:43 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: move apci3120_ai_insn_read() to driver source

Move this function, and its helper function, from the included hwdrv_apci31210.c
source file to the main driver source file.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: move apci3120_ao_insn_write() to driver source
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:42 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: move apci3120_ao_insn_write() to driver source

Move this function, and its helper function, from the included hwdrv_apci31210.c
source file to the main driver source file.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: move apci3120_di_insn_bits() to driver source
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:41 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: move apci3120_di_insn_bits() to driver source

Move this function from the included hwdrv_apci31210.c source file to the main
driver source file.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: move apci3120_do_insn_bits() to driver source
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:40 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: move apci3120_do_insn_bits() to driver source

Move this function from the included hwdrv_apci31210.c source file to the main
driver source file.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: remove private data 'ai_running'
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:39 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: remove private data 'ai_running'

This member of the private data was used to determine if the interrupt
routine was handling data for the (*insn_read) or an async command. Now
that the (*insn_read) does not use interrupts this member is not needed.

Remove the member and refactor the code.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: define status register bits
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:38 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: define status register bits

Define the bits in the status register and use them to clarify the code.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: rename APCI3120_RD_STATUS
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:37 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: rename APCI3120_RD_STATUS

For aesthetics, rename this define used for the status register offset.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: remove private data 'ui_AiChannelList'
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:36 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: remove private data 'ui_AiChannelList'

This member of the private data is no longer used. Remove it.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: remove private data 'ui_AiNbrofChannels'
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:35 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: remove private data 'ui_AiNbrofChannels'

This member of the private data is always the cmd->chanlist_len. Use that
instead and remove the member.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: absorb apci3120_interrupt_handle_eos()
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:34 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: absorb apci3120_interrupt_handle_eos()

Absorb this simple function into apci3120_interrupt().

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: fix apci3120_ai_insn_read()
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:33 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: fix apci3120_ai_insn_read()

Now that the scanning and interrupt support have been removed from this
function it can be refactored to work correctly.

The comedi core expects (*insn_read) functions to read insn->n values
from the hardware and return the number of samples read. This function
currently just reads one sample but it returns insn->n.

Fix this function to work like the core expects.

Use comedi_timeout() to prevent a possible deadlock in the loop that
waits for the end-of-conversion.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: remove private data 'ui_AiReadData'
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:32 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: remove private data 'ui_AiReadData'

This member of the private data was used to return analog input samples that
were acquired for the (*insn_read) using interrupts. The interrupt support
code for the (*insn_read) has been removed. Remove this unused member from
the private data.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: remove apci3120_ai_insn_config()
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:31 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: remove apci3120_ai_insn_config()

This function does not follow the comedi API for (*insn_config) functions.
It's also no long needed. Just remove it.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: remove interrupt support from ai (*insn_read)
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:30 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: remove interrupt support from ai (*insn_read)

(*insn_read) functions are supposed to do simple polled reads of a single
channel. This driver tries to be tricky and allow enabling interrupts in
the analog input (*insn_config) to allow the (*insn_read) to read samples
with the end-of-conversion interrupt.

The (*insn_config) doesn't follow the comedi API and this operation mode
is not part of the API.

Remove the interrupt support from the (*insn_read) as well as the support
code in the (*insn_config) and interrupt handler.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: remove private data 'ui_EocEosConversionTime'
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:29 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: remove private data 'ui_EocEosConversionTime'

This driver tries to be tricky and allow passing an analog input conversion time
for the (*insn_read) in the (*insn_config).  The (*insn_config) doesn't follow
the comedi API and this programmable conversion time is not part of the API for
(*insn_read) operations.

Remove the member from the private data and use a fixed 10us (10000ns) conversion
time in the (*insn_read).

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: remove scanning from ai (*insn_read)
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:28 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: remove scanning from ai (*insn_read)

(*insn_read) functions are supposed to do simple polled reads of a single
channel. This driver tries to be tricky and allow passing a chanlist in
the analog input (*insn_config) to allow the (*insn_read) to do chanlist
scanning with or without interrupts.

The (*insn_config) doesn't follow the comedi API and this operation mode
is not part of the API.

Remove the scanning support from the (*insn_read) as well as the support
code in the (*insn_config) and interrupt handler.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: rename APCI3120_WRITE_MODE_SELECT
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:27 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: rename APCI3120_WRITE_MODE_SELECT

For aesthetics, rename this define used for the mode register offset.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: define the timer 2 clock select bits
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:26 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: define the timer 2 clock select bits

For aesthetics, redefine the bits in the mode register used to select the
clock for timer 2.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: define the timer 2 operation bits
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:25 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: define the timer 2 operation bits

For aesthetics, redefine the bits in the mode register used to set the
operation mode of timer 2.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: define the "enable" bits in the mode register
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:24 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: define the "enable" bits in the mode register

For aesthetics, redefine the bits in the mode register that enable interrupts
and scanning.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: remove APCI3120_DISABLE_SCAN
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:23 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: remove APCI3120_DISABLE_SCAN

This define is not used in the driver. Remove it.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: remove APCI3120_DISABLE_EOS_INT
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:22 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: remove APCI3120_DISABLE_EOS_INT

For aesthetics, remove this define and just use ~APCI3120_ENABLE_EOS_INT.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: remove APCI3120_DISABLE_EOC_INT
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:21 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: remove APCI3120_DISABLE_EOC_INT

For aesthetics, remove this define and just use ~APCI3120_ENABLE_EOC_INT.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: remove APCI3120_DISABLE_TIMER_INT
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:20 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: remove APCI3120_DISABLE_TIMER_INT

For aesthetics, remove this define and just use ~APCI3120_ENABLE_TIMER_INT.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: remove APCI3120_DISABLE_WATCHDOG
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:19 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: remove APCI3120_DISABLE_WATCHDOG

For aesthetics, remove this define and just use ~APCI3120_ENABLE_WATCHDOG.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: remove APCI3120_DISABLE_TIMER_COUNTER
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:18 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: remove APCI3120_DISABLE_TIMER_COUNTER

For aesthetics, remove this define and just use ~APCI3120_ENABLE_TIMER_COUNTER.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: remove devpriv->mode '0xef' magic value
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:17 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: remove devpriv->mode '0xef' magic value

This mask value is the same as APCI3120_DISABLE_TIMER_COUNTER. Use that
instead and remove the "magic" value.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: remove unnecessary devpriv->mode masking
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:16 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: remove unnecessary devpriv->mode masking

The devpriv->mode is set to '0' at the start of apci3120_ai_insn_read() and
apci3120_cyclic_ai(). There is no need to clear any of the bits or do any
of the additional writes of those cleared bits.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: rename private data 'b_ModeSelectRegister'
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:15 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: rename private data 'b_ModeSelectRegister'

Rename this CamelCase member of the private data and tidy up the mask/set
of its bits.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: properly disable interrupts in apci3120_cancel()
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:14 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: properly disable interrupts in apci3120_cancel()

The APCI3120_DISABLE_ALL_INTERRUPT define is a mask value used to clear bits
in devpriv->b_ModeSelectRegister to disable the interrupt sources. Writing this
value directly sets unintended bits.

Just set the devpriv->b_ModeSelectRegister to '0' and write that to the register.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: remove APCI3120_DISABLE_ALL_INTERRUPT_WITHOUT_TIMER
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:13 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: remove APCI3120_DISABLE_ALL_INTERRUPT_WITHOUT_TIMER

At the start of apci3120_ai_insn_read() the devpriv->b_ModeSelectRegister is set
to '0'. Remove the unnecessary masking to clear the interrupt enable bits.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: move ai range table to driver source
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:12 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: move ai range table to driver source

Move the analog input comedi_lrange table from the included hwdrv_apci3120.c
source file to the main driver source file.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: introduce apci3120_ai_reset_fifo()
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:11 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: introduce apci3120_ai_reset_fifo()

A dummy read of APCI3120_TIMER_MODE_REG resets the analog input FIFO. Introduce
a helper function to clarify this.

It's not necessary to do a dummy read of the FIFO (base + 0) before reseting it.
Remove the unnecessary dummy reads.

The APCI3120_TIMER_MODE_REG is a 16-bit register. This fixes a couple 8-bit reads.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: remove 'check' param from apci3120_setup_chan_list()
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:10 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: remove 'check' param from apci3120_setup_chan_list()

This parameter is always passed as '0'. Remove it and refactor the code.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: tidy up scan chanlist programming
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:09 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: tidy up scan chanlist programming

Define the chanlist register and its bits and tidy up the programming
of the scan chanlist.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: remove unnecessary reset of the scan sequence
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:08 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: remove unnecessary reset of the scan sequence

The scan sequence does not need to be reset when the driver is attached. Remove
the code in apci3120_reset() that does this.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: introduce apci3120_clr_timer2_interrupt()
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:07 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: introduce apci3120_clr_timer2_interrupt()

A dummy read of APCI3120_CTR0_REG clears the timer 2 interrupt. Introduce a
helper function to clarify this.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: move apci3120_exttrig_enable() to driver source
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:06 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: move apci3120_exttrig_enable() to driver source

Move this helper function from the included source file into the main driver
source file.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: move apci3120_timer_enable() to driver source
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:05 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: move apci3120_timer_enable() to driver source

Move this helper function from the included source file into the main driver
source file.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: rename APCI3120_WR_ADDRESS
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:04 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: rename APCI3120_WR_ADDRESS

For aesthetics, rename this define.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: fix timer 2 disable in apci3120_write_insn_timer()
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:03 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: fix timer 2 disable in apci3120_write_insn_timer()

The wrong define is being used to disable the gate to stop timer 2 in this
function.

Use the apci3120_timer_enable() helper to properly disable the timer.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: introduce apci3120_timer_enable()
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:02 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: introduce apci3120_timer_enable()

Introduce a helper function to enable/disable a timer.

The disable of timers 0 and 1 in apci3120_interrupt() is probably not needed.
For now use the helper function to make sure the devpriv->ctrl bits are cleared
correctly to disable the timers.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: tidy up apci3120_exttrig_{enable,disable}()
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:01 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: tidy up apci3120_exttrig_{enable,disable}()

Merge these two functions and use an 'enable' parameter to determine if the
external trigger needs to be enabled or disabled.

This function always succeeds and the callers don't check the return. Change
the return type to void.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: rename APCI3120_ENABLE_EXT_TRIGGER
H Hartley Sweeten [Tue, 4 Nov 2014 17:54:00 +0000 (10:54 -0700)]
staging: comedi: addi_apci_3120: rename APCI3120_ENABLE_EXT_TRIGGER

For aesthetics, rename this define.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: tidy up APCI3120_ENABLE_TIMER[012]
H Hartley Sweeten [Tue, 4 Nov 2014 17:53:59 +0000 (10:53 -0700)]
staging: comedi: addi_apci_3120: tidy up APCI3120_ENABLE_TIMER[012]

For aesthetics, replace these defines with a macro that returns the
correct bit needed to set the gate bit to enable a timer.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: remove APCI3120_DISABLE_TIMER[012]
H Hartley Sweeten [Tue, 4 Nov 2014 17:53:58 +0000 (10:53 -0700)]
staging: comedi: addi_apci_3120: remove APCI3120_DISABLE_TIMER[012]

For aesthetics, remove these defines and just use ~APCI3120_ENABLE_TIMER[012].

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: tidy up devpriv->ctrl use
H Hartley Sweeten [Tue, 4 Nov 2014 17:53:57 +0000 (10:53 -0700)]
staging: comedi: addi_apci_3120: tidy up devpriv->ctrl use

The apci3120_setup_chan_list() function sets devpriv->ctrl to the scan length
(PR) and scan start (PA) values and writes the value to the register. There is
no need to mask the value first.

The apci3120_ai_insn_read() function calles apci3120_setup_chan_list(). There
is no need to clear devpriv->ctrl first or clear any additional bits and write
the register again. This also fixes an incorrect use of APCI3120_DISABLE_TIMER0
to disable the timer.

apci3120_cyclic_ai() also calls apci3120_setup_chan_list() so it does not need
to clear devpriv->ctrl or clear any addidional bits and write the register.

Update the comments in apci3120_reset() and apci3120_cancel().

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: rename private data 'us_OutputRegister'
H Hartley Sweeten [Tue, 4 Nov 2014 17:53:56 +0000 (10:53 -0700)]
staging: comedi: addi_apci_3120: rename private data 'us_OutputRegister'

Rename this CamelCase member of the private data and tidy up the mask/set
of its bits.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: move timer helpers to main driver source
H Hartley Sweeten [Tue, 4 Nov 2014 17:53:55 +0000 (10:53 -0700)]
staging: comedi: addi_apci_3120: move timer helpers to main driver source

Move the timer read/write and set mode helpers from the included source
file into the main driver source file.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: introduce apci3120_timer_set_mode()
H Hartley Sweeten [Tue, 4 Nov 2014 17:53:54 +0000 (10:53 -0700)]
staging: comedi: addi_apci_3120: introduce apci3120_timer_set_mode()

Introduce a helper function to set the operation mode of a timer.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: tidy up timer_mode masking
H Hartley Sweeten [Tue, 4 Nov 2014 17:53:53 +0000 (10:53 -0700)]
staging: comedi: addi_apci_3120: tidy up timer_mode masking

Define a macro that returns the mask of the timer_mode bits for a given
timer. Use the macro to remove the "magic" values used to clear the bits.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agostaging: comedi: addi_apci_3120: rename private data 'b_TimerSelectMode'
H Hartley Sweeten [Tue, 4 Nov 2014 17:53:52 +0000 (10:53 -0700)]
staging: comedi: addi_apci_3120: rename private data 'b_TimerSelectMode'

Rename this CamelCase member of the private data and tidy up the mask/set
of its bits.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>