Commit graph

6839 commits

Author SHA1 Message Date
H Hartley Sweeten 6d210c8d96 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>
2014-11-07 09:33:58 -08:00
H Hartley Sweeten 20f75b5641 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>
2014-11-07 09:33:58 -08:00
H Hartley Sweeten e0ca363a3e 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>
2014-11-07 09:33:58 -08:00
H Hartley Sweeten c24ca0e691 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>
2014-11-07 09:33:58 -08:00
H Hartley Sweeten 5a1f46c8fb 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>
2014-11-07 09:33:58 -08:00
H Hartley Sweeten b3c8ee5cbc 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>
2014-11-07 09:33:58 -08:00
H Hartley Sweeten e6da4c6a2d 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>
2014-11-07 09:33:58 -08:00
H Hartley Sweeten 2016c534dd 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>
2014-11-07 09:33:58 -08:00
H Hartley Sweeten 486beeb488 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>
2014-11-07 09:33:58 -08:00
H Hartley Sweeten 0c188e9cc9 staging: comedi: addi_apci_3120: rename APCI3120_TIMER_VALUE
For aesthetics, rename this 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>
2014-11-07 09:33:58 -08:00
H Hartley Sweeten dd62c4373a staging: comedi: addi_apci_3120: fix counter and external interrupt disable
The APCI3120_DISABLE_ALL_TIMER define define is not needed, and it's used
incorrectly in apci3120_cancel(). The define is a mask of the bits needed
to disable the counters. Writing the value directly sets unintended bits.

Prior to writing the value, the 'devpriv->us_OutputRegister' is set to 0
and written to the register. This disables all the timers and the external
trigger.

Remove the unnecessary apci3120_exttrig_disable() call as well as the write
of APCI3120_DISABLE_ALL_TIMER.

In apci3120_interrupt(), remove the unnecessary mask and write to disable
all the timers. The COMEDI_CB_EOA event will cause the core to call the
(*cancel) operation which will disable the timers.

Remove the unused 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>
2014-11-07 09:33:57 -08:00
H Hartley Sweeten 2e2e74e17a staging: comedi: addi_apci_3120: tidy up CTR0 register defines
Define the CTR0 register in the main driver source file and remove all
the old defines in hwrdv_apci3120.c.

For aesthetics, save the raw digital output state (devpriv->do_bits) in
the digital output (*insn_bits) function and use a macro to set them when
reading/writing a timer.

Use the CTR0 register define in the digital output (*insn_bits) function
and remove the current register 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>
2014-11-07 09:33:57 -08:00
H Hartley Sweeten 6931290785 staging: comedi: addi_apci_3120: introduce apci3120_timer_read()
Introduce a helper function to select a timer and read a value from 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>
2014-11-07 09:33:57 -08:00
H Hartley Sweeten ca578bce6d staging: comedi: addi_apci_3120: introduce apci3120_timer_write()
Introduce a helper function to select a timer and write a value to 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>
2014-11-07 09:33:57 -08:00
H Hartley Sweeten 36d553e47d staging: comedi: addi_apci_3120: rename private data 'b_DigitalOutputRegister'
Rename this CamelCase member of 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>
2014-11-07 09:33:57 -08:00
H Hartley Sweeten 546bf3382e staging: comedi: addi_apci_3120: introduce apci3120_ns_to_timer()
The timer divisor calculations in this driver are over complicated.

There are three timers on the board. They all use the same base clock
with a fixed prescaler for each timer. The base clock used depends on
the board version and type:

  APCI-3120 Rev A boards OSC = 14.29MHz base clock (~70ns)
  APCI-3120 Rev B boards OSC = 20MHz base clock (50ns)
  APCI-3001 boards OSC = 20MHz base clock (50ns)

The prescalers for each timer are:

  Timer 0 CLK = OSC/10
  Timer 1 CLK = OSC/1000
  Timer 2 CLK = OSC/1000

Add a new member to the private data, 'osc_base', to hold the base clock
time. Set this member during the board attach.

Introduce a helper function to calculate the divisor needed to generate
a nanosecond time with a given timer.

Use the new helper function in the driver 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>
2014-11-07 09:33:56 -08:00
H Hartley Sweeten 605d76f6eb staging: comedi: das1800: use comedi_async 'scans_done' to detect EOA
Remove the private data member 'count' and use the comedi_async 'scans_done'
member to detect the end-of-acquisition.

Use the comedi_nsamples_left() helper to get the number of samples to actually
add to the async buffer.

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>
2014-11-07 09:29:42 -08:00
H Hartley Sweeten 2d7840c70d staging: comedi: quatech_daqp_cs: use comedi_async 'scans_done' to detect EOA
Remove the private data member 'count' and use the comedi_async 'scans_done'
member to detect the end-of-acquisition.

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>
2014-11-07 09:29:41 -08:00
H Hartley Sweeten 0be887b92a staging: comedi: cb_pcidas64: use comedi_async 'scans_done' to detect AO EOA
Remove the private data member 'ao_count' and use the comedi_async 'scans_done'
member to detect the analog output end-of-acquisition.

Use the comedi_nsamples_left() helper to get the number of samples to actually
read from the async buffer.

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>
2014-11-07 09:29:41 -08:00
H Hartley Sweeten ccedb44075 staging: comedi: cb_pcidas64: use comedi_async 'scans_done' to detect AI EOA
Remove the private data member 'ai_count' and use the comedi_async 'scans_done'
member to detect the analog output end-of-acquisition.

Use the comedi_nsamples_left() helper to get the number of samples to actually
add to the async buffer.

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>
2014-11-07 09:29:41 -08:00
H Hartley Sweeten 9e4d755cdf staging: comedi: cb_pcidas: use comedi_async 'scans_done' to detect AO EOA
Remove the private data member 'ao_count' and use the comedi_async 'scans_done'
member to detect the analog output end-of-acquisition.

Use the comedi_nsamples_left() helper to get the number of samples to actually
read from the async buffer.

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>
2014-11-07 09:29:41 -08:00
H Hartley Sweeten f9f9838216 staging: comedi: cb_pcidas: use comedi_async 'scans_done' to detect AI EOA
Remove the private data member 'count' and use the comedi_async 'scans_done'
member to detect the analog input end-of-acquisition.

Use the comedi_nsamples_left() helper to get the number of samples to actually
add to the async buffer.

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>
2014-11-07 09:29:41 -08:00
H Hartley Sweeten 979f99963c staging: comedi: usbduxfast: use comedi_async 'scans_done' to detect AI EOA
Remove the private data member 'ai_sample_count' and use the comedi_async
'scans_done' member to detect the analog input end-of-acquisition.

Use the comedi_nsamples_left() helper to get the number of samples to actually
add to the async buffer.

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>
2014-11-07 09:29:41 -08:00
H Hartley Sweeten c6de95f467 staging: comedi: amplc_pci230: use comedi_async 'scans_done' to detect AI EOA
Remove the private data member 'ai_scan_count' and use the comedi_async 'scans_done'
member to detect the analog input end-of-acquisition.

Use the comedi_nsamples_left() helper to work out the number of 'wake' samples in
pci230_ai_update_fifo_trigger_level() and the number of 'todo' samples actually
added to the async buffer in pci230_handle_ai().

Remove the unnecessary COMEDI_CB_OVERFLOW event for the hardware FIFO overflow
error. The COMEDI_CB_ERROR event will terminate the command.

comedi_buf_write_samples() can fail if the async buffer does not have room for
the sample. The it will set the COMEDI_CB_OVERFLOW event and return 0. Detect
this and quit trying to read and add more samples. The event will terminate the
command.

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>
2014-11-07 09:29:41 -08:00
H Hartley Sweeten f615915ee5 staging: comedi: drivers: introduce comedi_nsamples_left()
Introduce a helper function to calculate the number of samples remaining
when the cmd->stop_src is TRIG_COUNT.

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>
2014-11-07 09:29:41 -08:00
H Hartley Sweeten a65ccf634c staging: comedi: amplc_pci230: use comedi_async 'scans_done' to detect AO EOA
Remove the private data member 'ai_count' and use the comedi_async 'scans_done'
member to detect the analog output end-of-acquisition.

Use the helper function comedi_nscans_left() to get the number of scans in the
async buffer of left in the command.

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>
2014-11-07 09:29:41 -08:00
H Hartley Sweeten f5345d459b staging: comedi: comedi_test: use comedi_async 'scans_done' to detect EOA
Remove the private data member 'ai_count' and use the comedi_async 'scans_done'
member to detect the end-of-acquisition.

Use the helper function comedi_nscans_left() to check if the number of scans
left in the command.

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>
2014-11-07 09:29:41 -08:00
H Hartley Sweeten d682141e59 staging: comedi: amplc_pci224: use comedi_async 'scans_done' to detect EOA
Remove the private data member 'ao_stop_count' and use the comedi_async
'scans_done' member to detect the end-of-acquisition.

Use the helper function comedi_nscans_left() to determine the number of scans
available in the async buffer or left in the command.

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>
2014-11-07 09:29:41 -08:00
H Hartley Sweeten 2ee3775001 staging: comedi: drivers: introduce comedi_nscans_left()
Introduce a helper function to determine the number of scans left in
the async command.

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>
2014-11-07 09:29:41 -08:00
Ian Abbott bc3fe15655 staging: comedi: split out PCI support into new module
Setting the `CONFIG_COMEDI_PCI_DRIVERS` kernel configuration option
makes the main "comedi" module depend on the PCI support in the kernel.
That's not that big a deal since PCI support in the kernel is either
built into the kernel or is absent, and is not in a separate module.
Still, not all low-level Comedi drivers need PCI support, so we could
save a bit of space by not including it.  The Comedi PCI support
functions are all in "comedi_pci.c".  Turn it into a separate module so
the support code doesn't have to be loaded unnecessarily.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-07 09:24:33 -08:00
Ian Abbott ba9ac25e96 staging: comedi: split out USB support into new module
Setting the `CONFIG_COMEDI_USB_DRIVERS` kernel configuration option
makes the main "comedi" module depend on the "usbcore" module.  But
perhaps the machine has no USB controllers (or they have been disabled),
in which case the "usbcore" module may have been pulled in
unnecessarily.  Only a few low-level Comedi drivers require USB support.
The Comedi USB support functions are all in "comedi_usb.c".  Turn it
into a separate module so we don't have to pull in the "usbcore" and
"usb_common" modules unnecessarily.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-07 09:24:33 -08:00
Ian Abbott aae434b3c3 staging: comedi: split out PCMCIA support into new module
Setting the `CONFIG_COMEDI_PCMCIA_DRIVERS` kernel configuration option
makes the main "comedi" module depend on the "pcmcia" module, but many
machines don't have PCMCIA slots and only a few low-level Comedi drivers
need PCMCIA support.  The Comedi PCMCIA support functions are all in
"comedi_pcmcia.c".  Turn it into a separate module so we don't have to
pull in the other PCMCIA support modules unnecessarily.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-07 09:24:33 -08:00
Ian Abbott d51b365101 staging: comedi: comedidev.h: remove some #ifdefs
Some declarations and macro definitions in "comedidev.h" are protected
by various `#ifdef`s for kernel configuration options, but the header
file compiles fine without the `#ifdef`s regardless of whether those
config option macros are defined or not.  Remove the `#ifdef`s and
compile the affected code unconditionally.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-07 09:24:33 -08:00
Ian Abbott 5aa1491a63 staging: comedi: comedidev.h: remove dummy PCI support functions
Some low-level Comedi driver modules used to handle PCI devices and ISA
devices in the same module with some conditional compilation.  To reduce
the amount of conditional compilation, some dummy inline versions of
`comedi_to_pci_dev()`, `comedi_pci_enable()`, `comedi_pci_disable()`,
and `comedi_pci_detach()` are defined in "comedidev.h" if
`CONFIG_COMEDI_PCI_DRIVERS` is undefined.  Since those Comedi low-level
driver modules have since had PCI support split out into separate
modules, there is no need to keep the dummy inline functions around any
more, so remove them.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-07 09:24:33 -08:00
H Hartley Sweeten 5e62863aea staging: comedi: das800: use comedi_async 'scans_done' to detect EOA
Remove the private data member 'count' and use the comedi_async 'scans_done'
member to detect the end-of-acquisition.

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>
2014-11-05 14:59:48 -08:00
H Hartley Sweeten 324e213a06 staging: comedi: addi_apci_3120: use comedi_async 'scans_done' to detect EOA
Remove the private data member 'ai_AiActualScan' and use the comedi_async
'scans_done' member to detect the end-of-acquisition.

The function v_APCI3120_InterruptDmaMoveBlock16bit() is then just a wrapper
for comedi_buf_write_samples(). 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>
2014-11-05 14:59:48 -08:00
H Hartley Sweeten 29ee9fbaa1 staging: comedi: usbduxsigma: use comedi_async 'scans_done' to detect AI EOA
Remove the private data member 'ai_sample_count' and use the comedi_async
'scans_done' member to detect the analog input end-of-acquisition.

Move the EOA check so it happens after adding the samples from the current
urb to the async buffer. This prevents the unnecessary resubmit of the urb
when the EOA occurs.

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>
2014-11-05 14:59:47 -08:00
H Hartley Sweeten 4b8ffac385 staging: comedi: usbduxsigma: use comedi_async 'scans_done' to detect AO EOA
Remove the private data member 'ao_sample_count' and use the comedi_async
'scans_done' member to detect the analog output end-of-acquisition.

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>
2014-11-05 14:59:47 -08:00
H Hartley Sweeten 88340999de staging: comedi: usbdux: use comedi_async 'scans_done' to detect AI EOA
Remove the private data member 'ai_sample_count' and use the comedi_async
'scans_done' member to detect the analog input end-of-acquisition.

Move the EOA check so it happens after adding the samples from the current
urb to the async buffer. This prevents the unnecessary resubmit of the urb
when the EOA occurs.

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>
2014-11-05 14:59:47 -08:00
H Hartley Sweeten 7c5fc7dd47 staging: comedi: usbdux: use comedi_async 'scans_done' to detect AO EOA
Remove the private data member 'ao_sample_count' and use the comedi_async
'scans_done' member to detect the analog output end-of-acquisition.

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>
2014-11-05 14:59:47 -08:00
H Hartley Sweeten aee15aea0d staging: comedi: s626: use comedi_async 'scans_done' to detect EOA
Remove the private data member 'ai_sample_count' and use the comedi_async
'scans_done' member to detect the end-of-acquisition.

Also, remove the unnecessary COMEDI_CB_EOS event. The core automatically
detects and adds that event.

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>
2014-11-05 14:59:47 -08:00
H Hartley Sweeten b03130b649 staging: comedi: pcmuio: use comedi_async 'scans_done' to detect EOA
Remove the private data member 'stop_count' and use the comedi_async 'scans_done'
member to detect the end-of-acquisition.

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>
2014-11-05 14:59:47 -08:00
H Hartley Sweeten 09959d658c staging: comedi: pcmmio: use comedi_async 'scans_done' to detect EOA
Remove the private data member 'count' and use the comedi_async 'scans_done'
member to detect the end-of-acquisition.

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>
2014-11-05 14:59:47 -08:00
H Hartley Sweeten f831de1023 staging: comedi: adv_pci1710: use comedi_async 'scans_done' to detect EOA
Remove the private data member 'ai_act_scan' and use the comedi_async
'scans_done' member to detect the end-of-acquisition.

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>
2014-11-05 14:59:47 -08:00
H Hartley Sweeten c76844e1ff staging: comedi: pcl818: use comedi_async 'scans_done' to detect EOA
Remove the private data member 'ai_act_scan' and use the comedi_async
'scans_done' member to detect the end-of-acquisition.

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>
2014-11-05 14:59:47 -08:00
H Hartley Sweeten 42dafac3a5 staging: comedi: pcl818: remove private data member 'ai_act_chan'
This member of the private data is set to '0' but never 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>
2014-11-05 14:59:47 -08:00
H Hartley Sweeten 64886498b2 staging: comedi: pcl816: use comedi_async 'scans_done' to detect EOA
Remove the private data member 'ai_act_scan' and use the comedi_async
'scans_done' member to detect the end-of-acquisition.

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>
2014-11-05 14:59:47 -08:00
H Hartley Sweeten 5f6da288e3 staging: comedi: pcl812: use comedi_async 'scans_done' to detect EOA
Remove the private data member 'ai_act_scan' and use the comedi_async
'scans_done' member to detect the end-of-acquisition.

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>
2014-11-05 14:59:47 -08:00
H Hartley Sweeten 8712f901c9 staging: comedi: pcl711: use comedi_async 'scans_done' to detect EOA
Remove the private data member 'ntrig' and use the comedi_async 'scans_done'
member to detect the end-of-acquisition.

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>
2014-11-05 14:59:46 -08:00
H Hartley Sweeten e268240387 staging: comedi: amplc_dio200_common: use comedi_async 'scans_done' to detect EOA
Remove the private data member 'stopcount' and use the comedi_async 'scans_done'
member to detect the end-of-acquisition.

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>
2014-11-05 14:59:46 -08:00
H Hartley Sweeten d1c87ceb44 staging: comedi: addi_apci_2032: use comedi_async 'scans_done' to detect EOA
Remove the private data member 'stop_count' and use the comedi_async 'scans_done'
member to detect the end-of-acquisition.

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>
2014-11-05 14:59:46 -08:00
H Hartley Sweeten 1dacbe5b26 staging: comedi: comedidev.h: add 'scans_done' member to comedi_async
Introduce a new member to comedi_async to count the number of scans completed.
This member is cleared by comedi_buf_reset() along with the other comedi_async
members. It is incremented in comedi_inc_scan_progress() when the end of scan
is detected.

This member will be used to clean up the scan counting in the comedi drivers.

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>
2014-11-05 14:59:46 -08:00
Ian Abbott c299a6789c staging: comedi: add ioctls to set per-file read and write subdevice
Now that Comedi has the structures in place to support setting the
current "read" and/or "write" subdevice on a per-file object basis, add
new ioctls to set them.  The newly chosen "read" ("write") subdevice
needs to support "read" ("write") commands, and the file cannot be busy
handling a "read" ("write") command on the previous subdevice (if any).

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-05 14:52:18 -08:00
Ian Abbott 20f083c075 staging: comedi: prepare support for per-file read and write subdevices
Comedi devices may have several subdevices that support "read" and/or
"write" asynchronous commands that use the "read" or "write" file
operations for data transfer.  The low-level Comedi drivers may nominate
a default "read" subdevice and/or a default "write" subdevice, but it
may have other subdevices that support asynchronous commands.

The Comedi core provides a somewhat clunky mechanism to provide access
to the asynchronous command support of the non-default subdevices.  When
a low-level device is "attached" to a core Comedi device, it dynamically
allocates a minor device number for each of the subdevices that support
asynchrounous commands and associates them with files created in SysFS
named "comediX_subdY", where "X" is the minor device number of the main
comedi device, and "Y" is the subdevice number.  An application can open
these subdevice-specific files and they behave like the regular
"comediX" files except that the "read" and/or "write" subdevice may be
different to the default chosen by the low-level driver.

This patch adds a layer of indirection between the file object and the
comedi device object to allow the current "read" and/or "write"
subdevice to be altered after opening the Comedi device, on a per-file
object basis.  The advantage is that an application only needs to open
the main Comedi device file and can then choose which subdevice it wants
to "read" or "write".  The main Comedi device file can be opened more
than once, and each file object can choose the "read" and "write"
subdevices independently.

The new `struct comedi_file` is created on "open" and freed on
"release".  It includes pointers to the main Comedi device structure,
and to the current "read" and "write" subdevice structures (which may be
NULL).  It also has information to keep track of when a low-level device
has been attached or detached since the previous time the file object
was used.  In that case, the current "read" and "write" subdevices in
the `struct comedi_file` will be changed to the new defaults (or set to
NULL).  (The change to new defaults is done by `comedi_file_reset()`.
The checking for attach/detach is done by `comedi_file_check()` which
will call `comedi_file_reset()` if there have been any attach/detach
operations since the previous call.)

A subsequent patch will add the ioctls to change the current "read" and
"write" subdevices.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-05 14:52:18 -08:00
Rickard Strandqvist 4884434c03 staging: comedi: drivers: comedi_bond.c: Remove unneeded #define
Remove unneeded #define. This was previously included in a patch set
two but patchset one was taken by mistake.

Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-03 16:34:18 -08:00
H Hartley Sweeten 26561101b8 staging: comedi: ni_at_a2150: use sample manipulation helpers
Use the recently added sample manipulation helpers to remove the hardcoded
assumption of the sample size.

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>
2014-11-03 16:34:18 -08:00
H Hartley Sweeten 14f7b68058 staging: comedi: hwdrv_apci3120: use sample manipulation helpers
Use the recently added sample manipulation helpers to remove the hardcoded
assumption of the sample size.

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>
2014-11-03 16:34:18 -08:00
H Hartley Sweeten 287a143ab4 staging: comedi: adl_pci9111: use sample manipulation helpers
Use the recently added sample manipulation helpers to remove the hardcoded
assumption of the sample size.

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>
2014-11-03 16:34:18 -08:00
H Hartley Sweeten 1d3d32a752 staging: comedi: adl_pci9118: use sample manipulation helpers
Use the recently added sample manipulation helpers to remove the hardcoded
assumption of the sample size.

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>
2014-11-03 16:34:18 -08:00
H Hartley Sweeten b7f9eb0549 staging: comedi: adv_pci1710: use sample manipulation helpers
Use the recently added sample manipulation helpers to remove the hardcoded
assumption of the sample size.

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>
2014-11-03 16:34:17 -08:00
H Hartley Sweeten bd508fffda staging: comedi: das16: use sample manipulation helpers
Use the recently added sample manipulation helpers to remove the hardcoded
assumption of the sample size.

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>
2014-11-03 16:34:17 -08:00
H Hartley Sweeten 5035a96f36 staging: comedi: das1800: use sample manipulation helpers
Use the recently added sample manipulation helpers to remove the hardcoded
assumption of the sample size.

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>
2014-11-03 16:34:17 -08:00
H Hartley Sweeten 836b571df7 staging: comedi: ni_mio_common: use sample manipulation helpers
Use the recently added sample manipulation helpers to remove the hardcoded
assumption of the sample size.

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>
2014-11-03 16:34:17 -08:00
H Hartley Sweeten c39e050d21 staging: comedi: remove use of 'bytes_per_sample()'
This inline helper function has been replaced with comedi_bytes_per_sample().
The same commit (bf33eb4b4f) introduced a couple other related helper
functions a manipulate the sample size.

Use the new helper functions to remove the use of 'bytes_per_sample()' and
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>
2014-11-03 16:34:17 -08:00
H Hartley Sweeten 272fe8f51f staging: comedi: amplc_pci230: remove private data 'ai_scan_pos'
This member of the private data is replicating what the comedi_async
'cur_chan' member is used for. Use that instead and remove the private
data 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>
2014-11-03 16:31:24 -08:00
H Hartley Sweeten f8736ca466 staging: comedi: drivers: move comedi_async 'cur_chan' tracking into the core
The commedi_async 'cur_chan' member is used to track the current position
in the chanlist for a scan. Currently only a couple comedi drivers use
this member.

For aeshtetics, move the 'cur_chan' tracking into the core for non-SDF_PACKED
subdevices. The 'cur_chan' will be updated after reading or writing samples
to the async buffer by comedi_inc_scan_progress(). All non-SDF_PACKED subdevices
will then automatiaclly track the 'cur_chan'.

Some of the drivers use the 'cur_chan' to detect the end of scan event when
counting scans. The COMEDI_CB_EOS event is automatically added by the core
when the end of scan is detected. The drivers just need to check if the
'cur_chan' is 0 to count the number of scans completed.

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>
2014-11-03 16:31:24 -08:00
H Hartley Sweeten c1b617e017 staging: comedi: ni_mio_common: remove unused variable in ni_ao_fifo_load()
The local variable 'range' is set but never 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>
2014-11-03 16:31:24 -08:00
Ian Abbott cf5d2af683 staging: comedi: icp_multi: correct insn_bits returned data for DO
For some unfathomable reason, the Comedi `insn_bits` handler for the
digital output subdevice (`icp_multi_insn_bits_do()`) writes the digital
output register and reads back the unrelated digital input register.
Read back the current state of the outputs (held in `s->state`) instead.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-03 16:31:23 -08:00
H Hartley Sweeten c234566f77 staging: comedi: rtd520: remove private data 'chan_is_bipolar' member
Currently this driver uses a bitmap in the private data to keep track of
the unipolar/bipolar range for each channel. This is needed to determine
if the data needs to be munged for bipolar samples.

Remove this member from the private data and use the comedi core helper
function comedi_range_is_bipolar() to determine if the data needs to be
munged.

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>
2014-11-03 16:30:04 -08:00
H Hartley Sweeten 0c8c1c0ad8 staging: comedi: rtd520: fix ai_read_n() async->cur_chan use
This functions uses the async->cur_chan to determine if the current channel
is using a bipolar range and the sample needs to be munged. The cur_chan is
never incremented so all the samples are munged based on the fist channel
in the cmd->chanlist.

Bump the cur_chan after writing each sample. This fixes the code so that
the munging will be done 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>
2014-11-03 16:30:04 -08:00
H Hartley Sweeten a7d3de75cf staging: comedi: drivers do not need to reset the async->cur_chan
The comedi core calls comedi_buf_reset() before starting an async command
(*do_cmd) and after returning a subdevice to an idle state (*cancel).

The drivers do not need to reset the async->cur_chan in those functions.

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>
2014-11-03 16:30:04 -08:00
H Hartley Sweeten 453fd2b395 staging: comedi: drivers: digital output subdevices do not need SDF_READABLE
The SDF_READABLE flag is not necessary for digital output subdevices. For
consistency, remove this flag from the comedi drivers that set 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>
2014-11-03 16:30:04 -08:00
H Hartley Sweeten e002591820 staging: comedi: drivers: remove inappropriate SDF_* flags from subdevices
The SDF_GROUND, SDF_COMMON, SDF_DIFF, and SDF_OTHER flags are only useful
with the analog input and output subdevices.

Remove these flags from the other subdevice types in the comedi drivers.

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>
2014-11-03 16:30:04 -08:00
H Hartley Sweeten ef49d8329e staging: comedi: drivers: replace SDF_WRITEABLE with SDF_WRITABLE
As indicated in the comedi.h uapi header, SDF_WRITEABLE was a spelling
error in the API, SDF_WRITABLE is prefered.

For aesthetics, replace all the SDF_WRITEABLE uses with SDF_WRITABLE.

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>
2014-11-03 16:30:04 -08:00
Ian Abbott 75f6108fa9 staging: comedi: check actual data direction for COMEDI_BUFINFO ioctl
`do_bufinfo_ioctl()` handled the `COMEDI_BUFINFO` ioctl.  It is supposed
to update the read or write positions in the buffer depending on the
direction of data transfer set up by the asynchronous command.
Currently it checks the `SDF_CMD_READ` and `SDF_CMD_WRITE` subdevice
flags.  That's fine for most subdevices - the ones that only support one
direction, but is incorrect for those subdevices that allow the command
to be set up in either direction.  Since we now set the `CMDF_WRITE`
flag according to the data transfer direction of the current command
running on the subdevice, check that flag instead.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-03 16:28:47 -08:00
Ian Abbott 662c722b64 staging: comedi: check command direction in poll() file operation
`comedi_poll()` handles the poll() file operation for comedi devices.

If no asynchronous command has been set up on the current "read"
subdevice, it sets the `POLLIN` and `POLLRDNORM` bits in the return
value to indicate that the read() file operation would not block as it
would return an error.  Add a check so it also does that if the
asynchronous command has been set up in the "write" direction as that
also causes the read() file operation to return an error.

Similarly, if no asynchronous command has need set up on the current
"write" subdevice, it sets the `POLLOUT` and `POLLWRNORM` bits in the
return value to indicate that the write() file operation would not block
as it would return an error.  Add a check so it also does that if the
asynchronous command has been set up in the "read" direction as that
also causes the write() file operation to return an error.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-03 16:28:47 -08:00
Ian Abbott f739850941 staging: comedi: don't allow write() on async command set up for "read"
If a Comedi asynchronous command has been set up for data transfer in
the "read" direction on the current "write" subdevice (for those
subdevices that support both directions), don't allow the "write" file
operation as that would mess with the data in the comedi data buffer
that is written by the low-level comedi hardware driver.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-03 16:28:47 -08:00
Ian Abbott f025ab9eb7 staging: comedi: don't allow read() on async command set up for "write"
If a Comedi asynchronous command has been set up for data transfer in
the "write" direction on the current "read" subdevice (for those
subdevices that support both directions), don't allow the "read" file
operation as that would mess with the data in the comedi data buffer
that is read by the low-level comedi hardware driver.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-03 16:28:46 -08:00
Ian Abbott fb5a88eb9c staging: comedi: ni_mio_common: don't change CMDF_WRITE flag
There is no need for `ni_ai_cmdtest()` or `ni_ao_cmdtest()` to set the
`CMDF_WRITE` flag to the correct state as it has already been done by
the core comedi module.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-03 16:28:46 -08:00
Ian Abbott 8986d37ace staging: comedi: me4000: don't clobber command flags
The low-level Comedi drivers shouldn't change the `flags` member of
`struct comedi_cmd` as the Comedi core also uses some of those flags.
They should just ignore the flags they don't understand.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-03 16:28:46 -08:00
Ian Abbott 5d070cf25c staging: comedi: maybe force CMDF_WRITE command flag
Most comedi subdevices that support asynchronous commands only support
data transfer in either the "read" or "write" direction, as indicated by
the `SDF_CMD_READ` and `SDF_CMD_WRITE` subdevice flags, although a few
support both directions on the same subdevice (though not
simultaneously).  The `struct comedi_cmd` structure passed via ioctl
call to set up the command contains a `CMDF_WRITE` flag that can be used
to choose the direction if the subdevice supports both directions, but
the flag is optional if the subdevice only supports data transfer in one
direction.

If the subdevice only supports asynchronous data transfer in a sing
direction, set the `CMDF_WRITE` flag to the correct state so that Comedi
can make use of it later.  In the case of the `COMEDI_CMDTEST` ioctl,
the updated flag will be written back to the `struct comedi_cmd` in
user-space.  In the case of the `COMEDI_CMD` ioctl, the flag only gets
written back if an error is detected while testing the command, or if
the `CMDF_BOGUS` command flag is set.  Since `__comedi_get_user_cmd()`
is called for both ioctls, that's a good place to set the flag.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-03 16:28:46 -08:00
H Hartley Sweeten eb3a13230b staging: comedi: comedi_buf: make comedi_buf_write_samples() add samples that fit
This function currently fails if the number of samples to add would
overflow the async buffer. Modify it to add the samples that fit so
at least some of the sample data is returned to the user.

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>
2014-11-03 16:11:59 -08:00
Greg Kroah-Hartman 7cbe010a5e Merge 3.18-rc3 into staging-next
We want the upstream fixes in here as well.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-02 18:06:03 -08:00
Ian Abbott 0a43f75ef5 staging: comedi: das16: use spin-lock when setting timer
"das16" sets a timer running in `das16_cmd_exec()` and sets
`devpriv->timer_running` to indicate that it is running.  The timer
expiration routine `das16_timer_interrupt()` checks
`devpriv->timer_running` to check whether it needs to reschedule the
timer, but this is not synchronized with `das16_cmd_exec()`.  Since
`das16_cancel()` acquires the `dev->spinlock` spin-lock when clearing
`devpriv->timer_running` and removing the timer from the queue, use the
same spin-lock in `das16_cmd_exec()` and `das16_timer_interrupt()`
around the setting and checking of `devpriv->timer_running`.

Since `das16_interrupt()` (called from `das16_timer_interrupt()`) checks
whether DMA is enabled in the device while holding `dev->spinlock`, and
DMA is enabled by `das16_cmd_exec()` around the time it schedules the
timer, enable the DMA in the device while holding the spin-lock.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-10-30 13:29:31 -07:00
Ian Abbott ab784e5075 staging: comedi: das16: deschedule timer routine on detach
The "das16" driver optionally uses a kernel timer and a DMA channel to
support asynchronous data acquisition, but currently never calls
`del_timer_sync()`.  There is some possibility the timer routine could
still be scheduled to run when the comedi "detach" handler is run to
clean up the device and cause a certain amount of havoc.  Avoid that by
calling `del_time_sync()` in the comedi "detach" handler
`das16_detach()` if the timer was initialized by the "attach" handler
`das16_attach()`.  Use the timer's `data` member to tell whether it was
initialized or not.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-10-30 13:29:31 -07:00
Ian Abbott 238b5ad855 staging: comedi: fix memory leak / bad pointer freeing for chanlist
As a follow-up to commit 6cab7a37f5 ("staging: comedi: (regression)
channel list must be set for COMEDI_CMD ioctl"), Hartley Sweeten pointed
out another couple of bugs stemming from commit 6cab7a37f5 ("staging:
comedi: comedi_fops: introduce __comedi_get_user_chanlist()").

Firstly, `do_cmdtest_ioctl()` never frees the kernel copy of the user
chanlist allocated by `__comedi_get_user_chanlist()`, so that memory is
leaked.  Fix it by freeing the allocated kernel memory pointed to by
`cmd.chanlist` before that pointer is overwritten with its original
pointer to user memory before `cmd` is copied back to user-space.

Secondly, if `__comedi_get_user_chanlist()` returns an error,
`cmd->chanlist` is left unchanged and in fact will be a pointer to user
memory.  This causes `do_cmd_ioctl()` to `goto cleanup` and call
`do_become_nonbusy()` which would attempt to free the memory pointed to
by the user-space pointer.  Fix it by setting `cmd->chanlist` to NULL at
the start of `__comedi_get_user_chanlist()`.

Fixes: c6cd0eefb2 ("staging: comedi: comedi_fops: introduce __comedi_get_user_chanlist()")
Reported-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: <stable@vger.kernel.org> # 3.15.y 3.16.y 3.17.y: 6cab7a37f5
Cc: <stable@vger.kernel.org> # 3.15.y 3.16.y 3.17.y

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-10-29 16:18:31 +08:00
Ian Abbott 0ea6fa037e staging: comedi: Kconfig: fix config COMEDI_ADDI_APCI_3120 dependants
A merge conflict between commits
fbfd9c8a17 ("staging: comedi:
addi_apci_3120: use dma_alloc_coherent()") and
aff5b1f8eb ("staging: comedi: remove
comedi_fc module") left the COMEDI_ADDI_APCI_3120 config option
depending on VIRT_TO_BUS when it no longer needs to do so.  The
dependency was removed by the first commit and accidentally reinstated
by the second commit.  Remove the dependency again.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-10-29 16:18:31 +08:00
Ian Abbott c1a6eac169 staging: comedi: widen subdevice number argument in ioctl handlers
For the `COMEDI_LOCK`, `COMEDI_UNLOCK`, `COMEDI_CANCEL`, and
`COMEDI_POLL` ioctls the third argument is a comedi subdevice number.
This is passed as an `unsigned long`, but when it is passed down to the
ioctl command-specific handler functions `do_lock_ioctl()`,
`do_unlock_ioctl()`, `do_cancel_ioctl()`, and `do_poll_ioctl()`, the
value has been narrowed to an `unsigned int`.  Pass through the argument
as an `unsigned long` to avoid truncating the value on 64-bit
architectures.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-10-29 16:18:31 +08:00
Ian Abbott 73e0e4dfed staging: comedi: comedi_test: fix timer lock-up
Commit 2405124744 ("staging: comedi: comedi_test: use
comedi_handle_events()") resulted in the timer routine
`waveform_ai_interrupt()` calling `comedi_handle_events()` instead of
`comedi_events()`.  That had the advantage of automatically stopping the
acquisition on overflow/error/end-of-acquisition conditions (by calling
the comedi subdevice's "cancel" handler), but currently results in the
timer routine locking when one of those conditions occur.  This is
because the "cancel" handler `waveform_ai_cancel()` calls
`del_timer_sync()`.

Fix it by adding a bit to the device private data that indicates whether
the acquisition is active or not, and changing the "cancel" handler to
use `del_timer()` instead of `del_timer_sync()`.  The bit is set when
starting the acquisition, cleared when ending the acquisition (in the
"cancel" handler), and tested in the timer routine, which will do
nothing if the acquisition is inactive.  Also, make sure any scheduled
timeout event gets cancelled when the low-level device gets "detached"
from the comedi core by calling `del_timer_sync()` in the "detach"
handler `waveform_detach()`.

Fixes: 2405124744 ("staging: comedi: comedi_test: use comedi_handle_events()")
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-10-29 16:15:07 +08:00
Ian Abbott bf33eb4b4f staging: comedi: introduce some sample size manipulation functions
Introduce a few static inline helper functions:

`comedi_bytes_per_sample(s)` is the same as the existing
`bytes_per_sample(s)` and determines the size of a comedi sample in
bytes.  (`bytes_per_sample(s)` will be removed.)

`comedi_sample_shift(s)` determines the log2 of the comedi sample size,
so it can be used in bit-shift operations to multiply or divide by the
sample size.

`comedi_bytes_to_samples(s, nbytes)` converts a number of bytes to a
number of samples (rounding down).

`comedi_samples_to_bytes(s, nsamples)` converts a number of samples to a
number of bytes.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-10-29 16:12:41 +08:00
H Hartley Sweeten 7885b070b8 staging: comedi: addi_apci_1564: remove private data 'mode_select_register'
This driver currently passes the timer channel as the data[5] element to the
timer (*insn_config) function. This is stored in the private data and use in
the timer (*insn_read) and (*insn_write) functions to read/write the timer.

This is just wrong, comedi passes the channel number in the insn->chanspec.
Use that instead and remove the private data 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>
2014-10-29 16:06:01 +08:00
H Hartley Sweeten 367ff14edd staging: comedi: addi_apci_1564: board has 3 timers
According to ADDI-DATA, the APCI-1564 only has 3 timers. There are some
customer specific boards with 4 timers but they use out of tree drivers.

Now that the timer 'channels' are handled correctly in the subdevice
functions, fix the number of timer channels for the subdevice and remove
the code that would access a 4th timer.

Also, remove the unnecessary initialzation of the subdevice 'len_chanlist'.
That member is only used by subdevices that support async commands.

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>
2014-10-29 16:06:01 +08:00
H Hartley Sweeten b3ba2be24c staging: comedi: addi_apci_1564: remove APCI1564_COUNTER[1234] defines
These defines don't add any significant clarity to the driver. 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>
2014-10-29 16:06:01 +08:00
H Hartley Sweeten ac584af599 staging: comedi: me4000: fix firmware downloading
Convert this driver to use comedi_load_firmware() to download the firmware
to the board.

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>
2014-10-29 16:06:01 +08:00
H Hartley Sweeten 0cf5efaa4b staging: comedi: comedi_buf: absorb __comedi_buf_write_alloc()
This function is only called by comedi_buf_write_alloc(). Absorb it and remove
the unused 'strict' parameter.

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>
2014-10-29 16:03:16 +08:00
H Hartley Sweeten e19a3c9724 staging: comedi: comedi_buf: absorb comedi_write_array_to_buffer()
This function is only called by comedi_buf_write_samples(). Absorb it.

The buffer overflow was already checked so the overflow check of
comedi_buf_write_alloc() can be removed.

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>
2014-10-29 16:03:15 +08:00
H Hartley Sweeten 8f90726196 staging: comedi: comedi_buf: don't export comedi_write_array_to_buffer()
All the comedi drivers have been converted to use comedi_buf_write_samples().
This function is now only used internally by comedi_buf. Remvoe the export.

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>
2014-10-29 16:03:15 +08:00
H Hartley Sweeten 0ce64e6517 staging: comedi: comedi_buf: remove comedi_buf_put()
All comedi drivers now use comedi_buf_write_samples() to add the samples to
the async buffer. Remove this unused function.

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>
2014-10-29 16:03:15 +08:00
H Hartley Sweeten 7dd1b528c1 staging: comedi: pcmuio: use comedi_buf_write_samples()
The dev->read_subdev used in this driver for async commands returns 32-bit samples
and should have the SDF_LSAMPL subdev_flag set. It also returns the full scan with
each sample so it should have the SDF_PACKED subdev_flag set.

Add the missing subdev_flags and use comedi_buf_write_samples() to add the sample
to the async buffer.

The COMEDI_CB_BLOCK and COMEDI_CB_EOS events will be automatically handled by the
core. Remove the unnecessary events 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>
2014-10-29 16:03:15 +08:00
H Hartley Sweeten ff5eb046cf staging: comedi: pcmmio: use comedi_buf_write_samples()
The dev->read_subdev used in this driver for async commands returns 32-bit samples
and should have the SDF_LSAMPL subdev_flag set. It also returns the full scan with
each sample so it should have the SDF_PACKED subdev_flag set.

Add the missing subdev_flags and use comedi_buf_write_samples() to add the sample
to the async buffer.

The COMEDI_CB_BLOCK and COMEDI_CB_EOS events will be automatically handled by the
core. Remove the unnecessary events 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>
2014-10-29 16:03:15 +08:00
H Hartley Sweeten dbe81a93f4 staging: comedi: ni_pcidio: use comedi_buf_write_samples()
Use comedi_buf_write_samples() to add the sample to the async buffer. The 32-bit
sample size is automatically determined due to the subddev_flag SDF_LSAMPL.

The async event COMEDI_CB_BLOCK will be automatically set by the core. Remove the
unnecessary event in the driver.

This driver also has the SDF_PACKED subdev_flag set so the core will automatically
set the COMEDI_CB_EOS event after adding the sample.

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>
2014-10-29 16:03:15 +08:00
H Hartley Sweeten 2a07616cd9 staging: comedi: amplc_dio200_common: use comedi_buf_write_samples()
The dev->read_subdev used in this driver for async commands returns the
full scan with each sample so it should have the SDF_PACKED subdev_flag
set.

Add the missing subdev_flags and use comedi_buf_write_samples() to add
the sample to the async buffer.

The async events will set properly by the core. A dev_warn() message will
also be output by the core if the buffer overflows. Remove the unnecessary
events and dev_err() message 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>
2014-10-29 16:03:15 +08:00
H Hartley Sweeten 4c704690e7 staging: comedi: addi_apci_2032: use comedi_buf_write_samples()
The dev->read_subdev used in this driver for async commands returns the
full scan with each sample so it should have the SDF_PACKED subdev_flag
set.

Add the missing subdev_flags and use comedi_buf_write_samples() to add
the sample to the async buffer.

The core sets the async events appropriately. Remove the unnecessary
event handling 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>
2014-10-29 16:03:15 +08:00
H Hartley Sweeten 435efc8a43 staging: comedi: hwdrv_apci3120: use comedi_buf_write_samples()
Use comedi_buf_write_samples() to add the samples to the async buffer.

The COMEDI_CB_EOS and COMEDI_CB_OVERFLOW events will be automatically
handled by the core. Remove the unecessary handling 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>
2014-10-29 16:03:15 +08:00
H Hartley Sweeten 290d028e04 staging: comedi: usbdux: use comedi_buf_write_samples()
Use comedi_buf_write_samples() to add the sample to the async buffer.

The async events COMEDI_CB_BLOCK and COMEDI_CB_EOS will be detected and set
by the core. Remove the unnecessary events 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>
2014-10-29 16:03:15 +08:00
H Hartley Sweeten 5023a4bb10 staging: comedi: rtd520: use comedi_buf_write_samples()
For aesthetics, use comedi_buf_write_samples() to add the sample to the
async buffer.

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>
2014-10-29 16:03:14 +08:00
H Hartley Sweeten a4a68fe2a2 staging: comedi: quatech_daqp_cs: use comedi_buf_write_samples()
For aesthetics, use comedi_buf_write_samples() to add the sample to the
async buffer.

The core will add the COMEDI_CB_BLOCK event when data is written to the
async buffer. Remove the unnecessary event 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>
2014-10-29 16:03:14 +08:00
H Hartley Sweeten edf4537bcb staging: comedi: pcl818: use comedi_buf_write_samples()
For aesthetics, use comedi_buf_write_samples() to add the sample to the
async buffer.

The core will add the COMEDI_CB_BLOCK event when data is written to the
async buffer. Remove the unnecessary event 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>
2014-10-29 16:03:14 +08:00
H Hartley Sweeten c0491d4eb4 staging: comedi: pcl816: use comedi_buf_write_samples()
For aesthetics, use comedi_buf_write_samples() to add the sample to the
async buffer.

The core will add the COMEDI_CB_BLOCK event when data is written to the
async buffer. Remove the unnecessary event 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>
2014-10-29 16:03:14 +08:00
H Hartley Sweeten 76cb501924 staging: comedi: pcl812: use comedi_buf_write_samples()
For aesthetics, use comedi_buf_write_samples() to add the sample to the
async buffer.

The core will add the COMEDI_CB_BLOCK event when data is written to the
async buffer. Remove the nnecessary event 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>
2014-10-29 16:03:14 +08:00
H Hartley Sweeten 778d695e67 staging: comedi: pcl726: use comedi_buf_write_samples()
Use comedi_buf_write_samples() to add the sample to the async buffer.

The async events will set properly by the core. Remove the unnecessary
events 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>
2014-10-29 16:03:14 +08:00
H Hartley Sweeten 1f44c034de staging: comedi: pcl711: use comedi_buf_write_samples()
Use comedi_buf_write_samples() to add the sample to the async buffer.

The async events will set properly by the core. Remove the unnecessary
events 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>
2014-10-29 16:03:14 +08:00
H Hartley Sweeten 67fdc3073b staging: comedi: ni_atmio16d: use comedi_buf_write_samples()
For aesthetics, use comedi_buf_write_samples() to add the sample to
the async buffer.

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>
2014-10-29 16:03:14 +08:00
H Hartley Sweeten 562de49c52 staging: comedi: ni_65xx: use comedi_buf_write_samples()
Use comedi_buf_write_samples() to add the sample to the async buffer.

The async events COMEDI_CB_EOS will automatically be set by the core
with the end-of-scan is detected. Remove the unnecessary event 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>
2014-10-29 16:03:14 +08:00
H Hartley Sweeten 191db09026 staging: comedi: ni_6527: use comedi_buf_write_samples()
Use comedi_buf_write_samples() to add the sample to the async buffer.

The async events COMEDI_CB_EOS will automatically be set by the core
with the end-of-scan is detected. Remove the unnecessary event 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>
2014-10-29 16:03:13 +08:00
H Hartley Sweeten de88924f67 staging: comedi: me4000: use comedi_buf_write_samples()
Use comedi_buf_write_samples() to add the sample to the async buffer.

The async events COMEDI_CB_OVERFLOW will be set by the core if the async
buffer overflows. A dev_warn() message will also be output by the core
if the buffer overflows. Remove the unnecessary event and the dev_err()
messages in the driver.

The core will also add the COMEDI_CB_BLOCK event when data is written
to the async buffer. Remove these unnecessary events from 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>
2014-10-29 16:03:13 +08:00
H Hartley Sweeten aa96f6ef6f staging: comedi: dt3000: use comedi_buf_write_samples()
For aesthetics, use comedi_buf_write_samples() to add the sample to the
async buffer.

The core will set the COMEDi_CB_BLOCK event when data is written to the
async buffer. Remove the unnecessary event from 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>
2014-10-29 16:03:13 +08:00
H Hartley Sweeten 1700529b24 staging: comedi: dmm32at: use comedi_buf_write_samples()
For aesthetics, use comedi_buf_write_samples() to add the sample to the
async buffer.

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>
2014-10-29 16:03:13 +08:00
H Hartley Sweeten 9a84a7d2e7 staging: comedi: comedi_parport: use comedi_buf_write_samples()
Use comedi_buf_write_samples() to add the sample to the async buffer.

The async events COMEDI_CB_BLOCK and COMEDI_CB_EOS will be detected and set
by the core. Remove the unnecessary events 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>
2014-10-29 16:03:13 +08:00
H Hartley Sweeten 48e08de087 staging: comedi: amplc_pci230: use comedi_buf_write_samples()
Use comedi_buf_write_samples() to add the sample to the async buffer.

The async events will set properly by the core. A dev_warn() message will
also be output by the core if the buffer overflows. Remove the unnecessary
events and dev_err() message in the driver.

The core will also add the COMEDI_CB_BLOCK event when data is written to
the async buffer. Remove the unnecessary event 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>
2014-10-29 16:03:13 +08:00
H Hartley Sweeten 27913fa08c staging: comedi: amplc_pc236_common: use comedi_buf_write_samples()
Use comedi_buf_write_samples() to add the sample to the async buffer.

The async events COMEDI_CB_BLOCK and COMEDI_CB_EOS will be detected and set
by the core. Remove the unnecessary events 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>
2014-10-29 16:03:13 +08:00
H Hartley Sweeten a9c3a015c1 staging: comedi: adv_pci1710: use comedi_buf_write_samples()
For aesthetics, use comedi_buf_write_samples() to add the sample to the
async buffer.

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>
2014-10-29 16:03:13 +08:00
H Hartley Sweeten 6aec0f9af4 staging: comedi: addi_apci_3xxx: use comedi_buf_write_samples()
For aesthetics, use comedi_buf_write_samples() to add the sample to the
async buffer.

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>
2014-10-29 16:03:12 +08:00
H Hartley Sweeten c4a58f281a staging: comedi: addi_apci_1564: use comedi_buf_write_samples()
Use comedi_buf_write_samples() to add the sample to the async buffer.

The async events COMEDI_CB_BLOCK and COMEDI_CB_EOS will be detected and set
by the core. Remove the unnecessary events 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>
2014-10-29 16:03:12 +08:00
H Hartley Sweeten 6bb45f2b0c staging: comedi: addi_apci_1032: use comedi_buf_write_samples()
Use comedi_buf_write_samples() to add the sample to the async buffer.

The async events COMEDI_CB_BLOCK and COMEDI_CB_EOS will be detected and set
by the core. Remove the unnecessary events 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>
2014-10-29 16:03:12 +08:00
H Hartley Sweeten f4add8df72 staging: comedi: comedi_fc.h: remove cfc_write_array_to_buffer()
The inline function 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>
2014-10-29 16:03:12 +08:00
H Hartley Sweeten f81ac41b89 staging: comedi: usbduxfast: use comedi_buf_write_samples()
Use comedi_buf_write_samples() to add the samples to the async buffer.
That function will determining the number of bytes to add based on the
bytes_per_sample().

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>
2014-10-29 16:03:12 +08:00
H Hartley Sweeten 504d0239f6 staging: comedi: usbduxsigma: use comedi_buf_write_samples()
Use comedi_buf_write_samples() to add the sample to the async buffer.
That function will determining the number of bytes to add based on the
bytes_per_sample().

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>
2014-10-29 16:03:12 +08:00
H Hartley Sweeten 60e6644399 staging: comedi: gsc_hpdi: use comedi_buf_write_samples()
Use comedi_buf_write_samples() to add the samples to the async buffer.
That function will handle the '* sizeof(foo)' calculation to determine
the number of bytes to add.

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>
2014-10-29 16:03:12 +08:00
H Hartley Sweeten d4c2acd233 staging: comedi: dt282x: use comedi_buf_write_samples()
Use comedi_buf_write_samples() to add the samples to the async buffer.
That function will determining the number of bytes to add based on the
bytes_per_sample().

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>
2014-10-29 16:03:12 +08:00
H Hartley Sweeten 2e7b65e4bb staging: comedi: das16: use comedi_buf_write_samples()
Use comedi_buf_write_samples() to add the samples to the async buffer.
That function will determining the number of bytes to add based on the
bytes_per_sample().

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>
2014-10-29 16:03:12 +08:00
H Hartley Sweeten b45a7beb3b staging: comedi: das16m1: use comedi_buf_write_samples()
Use comedi_buf_write_samples() to add the samples to the async buffer.
The number of bytes to add is determined automatically based on the
number of samples and the bytes_per_sample().

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>
2014-10-29 16:03:12 +08:00
H Hartley Sweeten 5759a14d82 staging: comedi: hwdrv_apci3120: use comedi_buf_write_samples()
Use comedi_buf_write_samples() to add the samples to the async buffer.
That function will handle the '* sizeof(foo)' calculation to determine
the number of bytes to add.

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>
2014-10-29 16:03:12 +08:00
H Hartley Sweeten 9fdfe0fd00 staging: comedi: adl_pci9111: use comedi_buf_write_samples()
Use comedi_buf_write_samples() to add the samples to the async buffer.
The number of bytes to add is determined automatically based on the
number of samples and the bytes_per_sample().

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>
2014-10-29 16:03:11 +08:00
H Hartley Sweeten be591d5c42 staging: comedi: comedi_fc.h: remove cfc_write_to_buffer()
The inline function 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>
2014-10-29 16:03:11 +08:00
H Hartley Sweeten 9caba32961 staging: comedi: ni_mio_common: use comedi_buf_write_samples()
Use comedi_buf_write_samples() to add the samples to the async buffer.
That function will handle single and multi sample writes by determining
the number of bytes to add based on the bytes_per_sample().

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>
2014-10-29 16:03:11 +08:00
H Hartley Sweeten 7ba38a0144 staging: comedi: cb_pcidas64: use comedi_buf_write_samples()
Use comedi_buf_write_samples() to add the samples to the async buffer.
That function will handle single and multi samples writes by determining
the number of bytes to add based on the bytes_per_sample().

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>
2014-10-29 16:03:11 +08:00
H Hartley Sweeten 28e8c8984c staging: comedi: adl_pci9118: use comedi_buf_write_samples()
Use comedi_buf_write_samples() to add the samples to the async buffer.
The number of bytes to add is determined automatically based on the
number of samples and the bytes_per_sample().

Change the return type of move_block_from_dma() to void and remove the
unnecessary check of the return value of comedi_buf_write_samples().
The callers don't check the return and it's really not necessary. If
comedi_buf_write_samples() fails to allocate enough space in the async
buffer to add all the samples it sets the COMEDI_CB_OVERFLOW event.
This will cause the async command to (*cancel) when the events are
handled.

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>
2014-10-29 16:03:11 +08:00
H Hartley Sweeten 8d47c085e8 staging: comedi: cb_pcidas: use comedi_buf_write_samples()
Use comedi_buf_write_samples() to add the samples to the async buffer.
That function will handle single and multi samples writes by determining
the number of bytes to add based on the number of samples and the
bytes_per_sample().

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>
2014-10-29 16:03:11 +08:00
H Hartley Sweeten 880f582068 staging: comedi: das1800: use comedi_buf_write_samples()
Use comedi_buf_write_samples() to add the samples to the async buffer. That
function will handle single and multi samples writes by determining the number
of bytes to add based on the number of samples and the bytes_per_sample().

Also, remove the unnecessary COMEDI_CB_BLOCK event. comedi_buf_write_samples()
will automatically add that event after adding the samples to the async
buffer.

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>
2014-10-29 16:03:11 +08:00
H Hartley Sweeten b9357cba10 staging: comedi: ni_labpc_isadma: use comedi_buf_write_samples()
Use comedi_buf_write_samples() instead of cfc_write_to_buffer() to add all
the samples to the async buffer in one operation.

The core will add the COMEDI_CB_BLOCK event when data is written to the
async buffer. Remove the unnecessary event 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>
2014-10-29 16:03:11 +08:00
H Hartley Sweeten 8d185f52dc staging: comedi: ni_labpc_common: use comedi_buf_write_samples()
Use comedi_buf_write_samples() instead of cfc_write_to_buffer() to add the
single sample to the async buffer.

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>
2014-10-29 16:03:11 +08:00
H Hartley Sweeten 0e017a4bbe staging: comedi: s626: use comedi_buf_write_samples()
Use comedi_buf_write_samples() instead of cfc_write_to_buffer() to add the
single sample to the async buffer.

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>
2014-10-29 16:03:11 +08:00
H Hartley Sweeten 7138e892a6 staging: comedi: ni_at_a2150: use comedi_buf_write_samples()
Use comedi_buf_write_samples() instead of cfc_write_to_buffer() to add the
single sample to the async buffer.

The core will add the COMEDI_CB_BLOCK event when data is written to the
async buffer. Remove the unnecessary event 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>
2014-10-29 16:03:10 +08:00
H Hartley Sweeten ad9eb43c93 staging: comedi: das800: use comedi_buf_write_samples()
Use comedi_buf_write_samples() instead of cfc_write_to_buffer() to add the
single sample to the async buffer.

The core will add the COMEDI_CB_BLOCK event when data is written to the
async buffer. Remove the unnecessary event from 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>
2014-10-29 16:03:10 +08:00
H Hartley Sweeten 88f9662abb staging: comedi: comedi_test: use comedi_buf_write_samples()
Use comedi_buf_write_samples() instead of cfc_write_to_buffer() to add the
single sample to the async buffer.

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>
2014-10-29 16:03:10 +08:00
H Hartley Sweeten ce8bfa275a staging: comedi: comedi_fc.h: remove cfc_write_long_to_buffer()
The inline function is not 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>
2014-10-29 16:03:10 +08:00
H Hartley Sweeten 5438da85fc staging: comedi: comedi_buf: introduce comedi_buf_write_samples()
Introduce a generic method to write samples to the async buffer.

The number of samples is first checked against the number of samples that
would fill the async buffer. The size of each sample is determined using
the bytes_per_sample() helper. If all the samples will fit in the async
buffer they are written to the buffer using comedi_write_array_to_buffer().

This will allow converting all the comedi drivers to use a common method to
write data to the async buffer.

Since comedi_write_array_to_buffer() sets the COMEDI_CB_BLOCK event after
writing the data, those events can be removed from the drivers.

In addition, comedi_inc_scan_progress() will automatically detect the end of
scan and set the COMEDI_CB_EOS event. Those events can also be removed from
the drivers.

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>
2014-10-29 16:03:10 +08:00
H Hartley Sweeten 0ca7f61cd6 staging: comedi: comedi_buf: comedi_buf_memcpy_from() remove 'offset' param
This parameter is always passed as '0'. Remove the unnecessary parameter.

This allows removing the unnecessary check of the read_ptr overflow.

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>
2014-10-29 16:01:20 +08:00
H Hartley Sweeten 319ad742bd staging: comedi: comedi_buf: comedi_buf_memcpy_to() remove 'offset' param
This parameter is always passed as '0'. Remove the unnecessary parameter.

This allows removing the unnecessary check of the write_ptr overflow.

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>
2014-10-29 16:01:20 +08:00
H Hartley Sweeten aa26e46b0f staging: comedi: comedi_buf: don't export comedi_buf_memcpy_to()
This function is only used internally. Remove the export.

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>
2014-10-29 16:01:20 +08:00
H Hartley Sweeten 9e2093d239 staging: comedi: comedi_buf: dont't export comedi_buf_memcpy_from()
This function is only used internally. Remove the export.

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>
2014-10-29 16:01:20 +08:00
H Hartley Sweeten 04c4166a22 staging: comedi: comedi_buf: remove comedi_buf_get()
This function 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>
2014-10-29 16:01:20 +08:00
H Hartley Sweeten e463fbe419 staging: comedi: usbduxsigma: use comedi_buf_read_samples()
Use comedi_buf_read_samples() to read the analog output samples from
the async buffer. That function will set the COMEDI_CB_BLOCK event
when samples are read from the async buffer.

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>
2014-10-29 16:01:20 +08:00
H Hartley Sweeten 664ab5d6db staging: comedi: usbdux: use comedi_buf_read_samples()
Use comedi_buf_read_samples() to read the analog output samples from
the async buffer. That function will set the COMEDI_CB_BLOCK event
when samples are read from the async buffer.

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>
2014-10-29 16:01:20 +08:00
H Hartley Sweeten dec1a26686 staging: comedi: amplc_pci230: use comedi_buf_read_samples()
Use comedi_buf_read_samples() to read the analog output samples from
the async buffer. That function will set the COMEDI_CB_BLOCK event
when samples are read from the async buffer. In addition, the core
will also handle the end-of-scan detection and set the COMEDI_CB_EOS
event.

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>
2014-10-29 16:01:20 +08:00
H Hartley Sweeten e14c6a60b5 staging: comedi: ni_mio_common: use comedi_buf_read_samples()
Use comedi_buf_read_samples() to get the single samples from the async
buffer. The number of samples in the buffer was validated by the callers
so the error checking can be removed. In addition, the core will set the
COMEDI_CB_BLOCK event so it can also be removed.

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>
2014-10-29 16:01:19 +08:00
H Hartley Sweeten 8de27e7010 staging: comedi: comedi_buf: make comedi_buf_read_samples() always return full samples
A number of drivers currently use comedi_buf_get() to read single samples
from the the async buffer. This works but the drivers have to handle the
COMEDI_CB_BLOCK and COMEDI_CB_EOS events. Converting those drivers to use
comedi_buf_read_samples() moves the handling of those events into the core.

Modify comedi_buf_read_samples() so that the async buffer is checked for
the number of full samples available. Use that to clamp the number of
samples that will be read. This makes sure that only full samples are
read from the async buffer making comedi_buf_read_samples() mimic the
action of comedi_buf_get() with the added benifit of handling the events.

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>
2014-10-29 16:01:19 +08:00
H Hartley Sweeten 109bf06e2a staging: comedi: comedi_buf: absorb comedi_read_array_from_buffer()
This function is only called by comedi_buf_read_samples(). Absorb 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>
2014-10-29 16:01:19 +08:00
H Hartley Sweeten 2b3e13b860 staging: comedi: comedi_buf: remove export of comedi_read_array_from_buffer()
This function is only used internally. Remove the export.

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>
2014-10-29 16:01:19 +08:00
H Hartley Sweeten 65ad7c89aa staging: comedi: comedi_fc.h: remove cfc_read_array_from_buffer()
This inline function 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>
2014-10-29 16:01:19 +08:00
H Hartley Sweeten ecb11d8c28 staging: comedi: dt282x: introduce dt282x_ao_setup_dma()
Introduce a helper function to read the analog output samples from the
async buffer and prep the DMA.

Use comedi_buf_read_samples() to read the analog output samples from
the async buffer.

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>
2014-10-29 16:01:19 +08:00
H Hartley Sweeten 7bd7d90562 staging: comedi: cb_pcidas: introduce cb_pcidas64_ao_fill_buffer()
Introduce a helper function to read the analog output samples from the
async buffer.

This fixes a bug in load_ao_dma_buffer(). That function was decrementing
the 'ao_count' by the number of bytes, not the number of samples, that
were read from the async buffer.

Use comedi_buf_read_samples() to read the analog output samples from
the async buffer.

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>
2014-10-29 16:01:19 +08:00
H Hartley Sweeten 2cc9854caf staging: comedi: cb_pcidas: introduce cb_pcidas_ao_load_fifo()
Introduce a helper function to load the analog output FIFO.

This fixes a bug in cb_pcidas_ao_inttrig(). That function was writing
'num_bytes' data values to the FIFO instead of 'num_points'. This results
in twice the number of data values getting written to the FIFO.

Use comedi_buf_read_samples() read the analog output samples from the async
buffer.

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>
2014-10-29 16:01:19 +08:00
H Hartley Sweeten bcdbe8848e staging: comedi: amplc_pci224: use comedi_buf_read_samples()
Use the new generic method to read the analog output samples from the async
buffer.

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>
2014-10-29 16:01:19 +08:00
H Hartley Sweeten 4455d7c351 staging: comedi: comedi_buf: introduce comedi_buf_read_samples()
Introduce a generic method to read samples from the async buffer.

The number of requested samples is clampled to the number of samples that
would fill the async buffer. The size of each sample is determined using
the bytes_per_sample() helper. The number of bytes need are then read
from the async buffer using comedi_read_array_from_buffer().

This will allow converting all the comedi drivers to use a common method
to read data from the async buffer.

Since comedi_read_array_from_buffer() sets the COMEDI_CB_BLOCK event after
reading the data, those events can be removed from the drivers.

In addition, comedi_inc_scan_progress() will automatically detect the end of
scan and set the COMEDI_CB_EOS event. Those events can also be removed from
the drivers.

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>
2014-10-29 16:01:19 +08:00
H Hartley Sweeten 22be3f8142 staging: comedi: addi_apci_3120: don't reset board when detaching driver
The comedi core calls all the subdevice (*cancel) functions before it does
the driver (*detach). There is no reason to call the board reset function
in the (*detach).

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>
2014-10-29 15:58:37 +08:00
H Hartley Sweeten a2eb0fd71c staging: comedi: addi_apci_3120: don't reset board when canceling ai command
The analog input (*cancel) stops the async command. There is not reason to also
call the board reset function.

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>
2014-10-29 15:58:37 +08:00
H Hartley Sweeten 73ef193146 staging: comedi: addi_apci_3120: reset the board before hooking up the interrupt
Move the apci3120_reset() call in the (*auto_attach) to ensure that the board
is reset before hooking up the 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>
2014-10-29 15:58:37 +08:00
H Hartley Sweeten 758505199e staging: comedi: addi_apci_3120: tidy up timer subdevice init
It appears that this subdevice is actually broken. The subdevice functions
all violate the comedi API and, it they did work, it appears they would
break the analog input async commands.

For now just tidy up the subdevice init.

Add the SDF_READABLE subdev_flag, this subdevice provides an (*insn_read).

Fix the subdevice 'maxdata' initialization. The timer is 24-bits.

Remove the 'len_chanlist' initialization. This member is only used by
subdevices that support async commands.

Also remove the 'range_table' initialization. The core will set it to
range_unknown which is appropriate.

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>
2014-10-29 15:58:37 +08:00
H Hartley Sweeten 2a420f408a staging: comedi: addi_apci_3120: tidy up analog input subdevice init
For aesthetics, add some white space to the analog input subdevice
initialization.

The async command support in this driver is pretty messed up. I'm not
really sure if it actually works yet. Luckly this driver was not
setting the SDF_CMD_READ subdev_flag so the command support was not
actually getting enabled.

The command support only works if an interrupt is available. Refactor
the subdevice init so that the command support is only hooked up if
we have an interrupt. For now always disable the command support. Once
the driver has been cleaned up the command will be enabled.

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>
2014-10-29 15:58:37 +08:00
H Hartley Sweeten 1bed58e3b6 staging: comedi: addi_apci_3120: tidy up digital output subdevice init
For aesthetics, add some white space to the digital output subdevice
initialization.

Remove the subdev_flags SDF_GROUND and SDF_COMMON. These only apply to
analog subdevices. Also remove the unnecessary SDF_READABLE subdev_flag.

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>
2014-10-29 15:58:37 +08:00
H Hartley Sweeten dc842931be staging: comedi: addi_apci_3120: tidy up digital input subdevice init
For aesthetics, add some white space to the digital input subdevice
initialization.

Remove the subdev_flags SDF_GROUND and SDF_COMMON. These only apply to
analog subdevices.

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>
2014-10-29 15:58:37 +08:00
H Hartley Sweeten f6dc930826 staging: comedi: addi_apci_3120: tidy up analog output subdevice init
For aesthetics, add some white space to the analog output subdevice
initialization.

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>
2014-10-29 15:58:36 +08:00
H Hartley Sweeten bf34c22622 staging: comedi: addi_apci_3120: provide analog output 'readback'
Use the comedi_subdevice 'readback' member and the core provided (*insn_read)
function to provide radback of the analog output channels.

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>
2014-10-29 15:58:36 +08:00
H Hartley Sweeten 6174801d7e staging: comedi: addi_apci_3120: fix apci3120_ao_insn_write()
The comedi core expects (*insn_write) functions to write insn->n values and
return the number of values written or an errno. This function currently
returns insn->n but it only writes a single data value.

Fix the function to work like the core expects.

There are two registers used to update the analog outputs. Offset 0x08 is
used to update channels 0-3 and offset 0x0a to update channels 4-7. Bits
14 and 15 in each register set the mux to select which channel to update.
The lower 14 bits are the value used to set the DAC.

For aesthetics, tidy up the defines used for the register offsets and bits
in the 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>
2014-10-29 15:58:36 +08:00
H Hartley Sweeten b9ae204658 staging: comedi: addi_apci_3120: remove analog output reset
The apci3120_reset() function is called at the end of the (*auto_attach) and
with the (*detach) is called to unload the driver. Part of this function
resets all the analog output channels to 0V.

There are two problems with this.
1) Only the APCI-3120 has analog outputs, the APCI-3001 does not.
2) The DA_READY bit in the status register needs to be checked before each
   write to update the analog outputs. It's unknown what the DA_READY bit
   does on the APCI-3001 board.

Just remove the analog output reset to avoid any problems.

Also, remove the unnecessary udelay() in apci3120_reset().

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>
2014-10-29 15:58:36 +08:00
H Hartley Sweeten ce987a8a8f staging: comedi: addi_apci_3120: prevent deadlock in apci3120_ao_insn_write()
The DA_READY bit (0x0001) in the status register needs to be set before the
analog outputs can be updated.

Use comedi_timeout() to prevent a deadlock condition while waiting for the
DA_READY bit to get 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>
2014-10-29 15:58:36 +08:00
H Hartley Sweeten 695f34cef3 staging: comedi: addi_apci_3120: remove private data 'iobase'
This member of the private data holds the start address of PCI BAR 1 that is
used to access the board registers. The start address is also stored in the
comedi_device 'iobase' member. Use that instead and remove the private data
member.

Remove some unnecessary casts when reading the board 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>
2014-10-29 15:58:36 +08:00
H Hartley Sweeten 323503bfec staging: comedi: addi_apci_3120: rename private data 'i_IobaseAmcc'
This member of the private data holds the start address of PCI BAR 0 that is
used to access the AMCC registers.

Rename this CamelCase member and fix its type.

Remove an unnecessary local variable, 'ui_Tmp', in apci3120_cyclic_ai() and
tidy up the rest of the local variable declarations.

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>
2014-10-29 15:58:36 +08:00
H Hartley Sweeten 67941734d1 staging: comedi: addi_apci_3120: rename private data 'i_IobaseAddon'
This member of the private data holds the start address of PCI BAR 2 that is
used to access the AMCC Add-On registers.

Rename this CamelCase member and fix its type.

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>
2014-10-29 15:58:36 +08:00
H Hartley Sweeten 758cdd4a17 staging: comedi: addi_apci_3120: use correct iobase to read board register
The board registers are accessed using the bse address devpriv->iobase not
devpriv->i_IobaseAmcc. Fix a read in apci3120_interrupt() that is using the
wrong base address.

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>
2014-10-29 15:58:36 +08:00
H Hartley Sweeten 0defecbfd2 staging: comedi: addi_apci_3120: use correct iobase to write AMCC registers
The AMCC registers are accessed using the base address devpriv->i_IobaseAmcc
not devpriv->i_IobaseAddon. Fix a couple writes in apci3120_interrupt_dma()
that are using the wrong base address.

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>
2014-10-29 15:58:36 +08:00
H Hartley Sweeten 82263947b1 staging: comedi: addi_apci_3120: remove private data 'i_IobaseReserved'
This member of the private data is not used by 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>
2014-10-29 15:58:35 +08:00
H Hartley Sweeten 12d984ed51 staging: comedi: addi_apci_3120: remove unipolar range from analog outputs
The analog outputs of the APCI-3120 have a 14-bit bipolar range and use straight
binary values (0x0000 = -10V to 0x3fff = +10V) to set the outputs. This driver
tries to fake a unipolar range by munging the comedi data values to only output
0V to +10V signals (0x0000 to 0x1fff values are munged to 0x2000 - 0x3fff).

This causes problems with the comedilib API functions that convert between comedi
values and physical values. It's also possible for the user to pass a data value
that would get munged and actually change the wrong channel.

Fix this by change the subdevice range_table to range_bipolar10 and remove the
munging in apci3120_ao_insn_write().

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>
2014-10-29 15:58:35 +08:00
H Hartley Sweeten 99940229e5 staging: comedi: addi_apci_3120: remove unused struct definition
The struct str_AnalogReadInformation is not used in this 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>
2014-10-29 15:58:35 +08:00
H Hartley Sweeten 8f83d52d30 staging: comedi: addi_apci_3120: introduce struct apci3120_dmabuf
For aesthetics, wrap the DMA buffer information in a struct.

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>
2014-10-29 15:58:35 +08:00
H Hartley Sweeten 1b90779b23 staging: comedi: addi_apci_3120: DMA requires an interrupt
An interrupt is required for DMA to work.

Factor out the DMA buffer allocation from the (*auto_attach) and only
allocate the buffers if the interrupt is available.

For aesthetics, also factor the DMA buffer free from the (*detach).

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>
2014-10-29 15:58:35 +08:00
H Hartley Sweeten c3e1715890 staging: comedi: ni_65xx: remove deadcode in ni_65xx_intr_cmdtest()
Reported-by: coverity (CID 142963)
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>
2014-10-29 15:56:54 +08:00
H Hartley Sweeten e7ea440a57 staging: comedi: ni_6527: remove deadcode in ni6527_intr_cmdtest()
Reported-by: coverity (CID 142962)
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>
2014-10-29 15:56:54 +08:00
H Hartley Sweeten 60942e707f staging: comedi: ni_mio_common: remove deadcode in ni_cdio_cmdtest()
Reported-by: coverity (CID 142967)
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>
2014-10-29 15:56:53 +08:00
H Hartley Sweeten 4a3df1540b staging: comedi: addi_apci_035: remove driver
According to ADDI-DATA, this board was discontinued last year and they
feel that no further development is needed for this driver. Remove the
driver from comedi to help with the addi-data cleanup.

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>
2014-10-29 15:56:53 +08:00
H Hartley Sweeten bcbb0c47c7 staging: comedi: usbduxsigma: introduce usbduxsigma_ai_handle_urb()
Factor the urb handling and resubmit out of the analog input urb
completion handler and tidy it up. This allows a common exit path
to be used in the completion handler to stop the async command and
handle the events.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: Bernd Porr <mail@berndporr.me.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-10-29 15:52:14 +08:00
H Hartley Sweeten 7a5dfb2120 staging: comedi: usbduxsigma: introduce usbduxsigma_ao_handle_urb()
Factor the urb handling and resubmit out of the analog output urb
completion handler and tidy it up. This allows a common exit path
to be used in the completion handler to stop the async command and
handle the events.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: Bernd Porr <mail@berndporr.me.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-10-29 15:52:14 +08:00
H Hartley Sweeten 7c88f9f48c staging: comedi: usbduxfast: introduce usbduxfast_ai_handle_urb()
Factor the urb handling and resubmit out of the completion handler and
tidy it up. This allows a common exit path to be used in the completion
handler to stop the async command and handle the events.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: Bernd Porr <mail@berndporr.me.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-10-29 15:52:14 +08:00
H Hartley Sweeten 41ca22a8c5 staging: comedi: usbdux: introduce usbduxsub_ai_handle_urb()
Factor the urb handling and resubmit out of the analog input urb
completion handler and tidy it up. This allows a common exit path
to be used in the completion handler to stop the async command and
handle the events.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: Bernd Porr <mail@berndporr.me.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-10-29 15:52:14 +08:00
H Hartley Sweeten 67f61f7ae9 staging: comedi: usbdux: introduce usbduxsub_ao_handle_urb()
Factor the urb handling and resubmit out of the analog output urb
completion handler and tidy it up. This allows a common exit path
to be used in the completion handler to stop the async command and
handle the events.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: Bernd Porr <mail@berndporr.me.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-10-29 15:52:14 +08:00
H Hartley Sweeten a0a7ae158a staging: comedi: addi_common.h: remove file
This header is no longer included by any of the addi-data drivers.
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>
2014-10-29 15:48:56 +08:00
H Hartley Sweeten 4e068bec48 staging: comedi: addi_apci_3120: separate from addi_common.h
Remove the need to include addi_common.h by introducing a new private
data definition. Only include the members that are actually used by
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>
2014-10-29 15:48:56 +08:00
H Hartley Sweeten 1b7d0642b8 staging: comedi: addi_apci_1500: separate from addi_common.h
Remove the need to include addi_common.h by introducing a new private
data definition. Only include the members that are actually used by
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>
2014-10-29 15:48:56 +08:00
H Hartley Sweeten 0317ffd281 staging: comedi: addi_apci_035: separate from addi_common.h
Remove the need to include addi_common.h by introducing a new private
data definition. Only include the members that are actually used by
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>
2014-10-29 15:48:56 +08:00
H Hartley Sweeten 6a02623de5 staging: comedi: addi_apci_3120: simplify analog input boardinfo
There are two boards supported by this driver. One with 16-bit analog
inputs and the other 12-bit analog inputs.

Add a bit field flag, 'ai_is_16bit', to the boardinfo and remove the
'i_AiMaxdata' member. Use the new flag to initialize tne analog input
subdevice maxdata correctly.

For aesthetics, adjust the whitespace in the boardinfo declaration.

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>
2014-10-29 15:48:55 +08:00
H Hartley Sweeten 2cd6b2b2a9 staging: comedi: addi_apci_3120: simplify analog output boardinfo
There are two boards supported by this driver. One with eight 14-bit analog
outputs and the other without analog outputs.

Add a bit field flag, 'has_ao', to the boardinfo and remove the 'i_NbrAoChannel'
and 'i_AoMaxdata' members. Use the new flag to determine if the analog output
subdevice needs to be initialized and open code the n_chan and maxdata.

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>
2014-10-29 15:48:55 +08:00
H Hartley Sweeten 7fcf666b4a staging: comedi: addi_apci_3120: remove boardinfo 'i_AiChannelList'
All boardinfo entries have this member set as '16'. This is also the Analog
Input 'n_chan'. For aesthetics, initialize the Analog Input 'len_chanlist'
with s->n_chan and remove the boardinfo 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>
2014-10-29 15:48:55 +08:00
H Hartley Sweeten 98ea9f854a staging: comedi: addi_apci_3120: remove boardinfo 'i_NbrAiChannel'
All boardinfo entries have this member set as '16'. This will initialize
the Analog Input 'n_chan' and cause the 'i_NbrAiChannelDiff' member to
never get used. Remove both members and initialize the Analog Input 'n_chan'
with 16 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>
2014-10-29 15:48:55 +08:00
H Hartley Sweeten 171192d0d0 staging: comedi: addi_apci_3120: remove boardinfo 'i_NbrDiChannel'
All boardinfo entries have this member set as '4'. Remove the member and
initialize the Digial Input 'n_chan' with 4 directly.

Also, remove the initialization of 'len_chanlist'. This member is only
used with subdevices that support async commands.

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>
2014-10-29 15:48:55 +08:00
H Hartley Sweeten 4241d6b82d staging: comedi: addi_apci_3120: remove boardinfo 'i_NbrDoChannel'
All boardinfo entries have this member set as '4'. Remove the member and
initialize the Digial Output 'n_chan' with 4 directly.

Also, remove the initialization of 'len_chanlist'. This member is only
used with subdevices that support async commands.

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>
2014-10-29 15:48:55 +08:00
H Hartley Sweeten 73fc3c6c05 staging: comedi: addi_apci_3120: remove boardinfo 'i_DoMaxdata'
The maxdata for a Digital Output subdevice is always '1'. Remove this
incorrect boardinfo.

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>
2014-10-29 15:48:55 +08:00
H Hartley Sweeten 7067a34766 staging: comedi: addi_common.h: remove unused members from addi_private
Remove all the unused members from the addi_private definition.

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>
2014-10-29 15:48:55 +08:00
H Hartley Sweeten dbf502e4b8 staging: comedi: addi_common.h: remove boardinfo definition
The addi_board definition is not only used by the addi_apci_3120 driver.

Introduce a private definition in that driver and remove the global definition
from addi_common.h.

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>
2014-10-29 15:48:55 +08:00
H Hartley Sweeten 7fab573b61 staging: comedi: hwdrv_apci3120: remove need for boardinfo access
The apci3120_ai_insn_config() function is broken in this driver. It does
not follow the comedi API and will fail to work correctly.

For now just remove the need for the boardinfo access to allow additional
cleanup. The 'i_NbrAiChannel' is actually the subdevice 'n_chan' use that
instead and remove the boardinfo access.

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>
2014-10-29 15:48:55 +08:00
H Hartley Sweeten 3b00a0e0d6 staging: comedi: addi_eeprom: remove source file
This source file is no longer included by any of the addi-data drivers.
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>
2014-10-29 15:48:54 +08:00
H Hartley Sweeten 715ce8aac4 staging: comedi: addi_apci_035: remove boardinfo
The hardware has an eeprom but the boardinfo properly defines the subdevice
support so reading the eeprom and setting the 's_EeParameters' use is not
necessary. Since the boardinfo only has one entry its not really necessary.
Also, providing a subdevice the read the eeprom is not really interesting.

Remove the eeprom support code along with the boardinfo and initialize the
subdevices 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>
2014-10-29 15:48:54 +08:00
H Hartley Sweeten bb599f39fa staging: comedi: addi_apci_1500: remove boardinfo
The hardware does not have an eeprom so the 's_EeParameters' use is not
necessary. Remove it.

Since the boardinfo only has one entry its not really necessary. Remove
it and initialize the subdevices 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>
2014-10-29 15:48:54 +08:00
H Hartley Sweeten e10e23db54 staging: comedi: addi_common.h: remove boardinfo member 'i_PCIEeprom'
This member of the boardinfo is not used by any of the drivers. 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>
2014-10-29 15:48:54 +08:00
H Hartley Sweeten b6cc74814f staging: comedi: addi_apci_035: board has eeprom
As indicated in the boardinfo, the hardware has an eeprom. Simplify
the board attach code and remove the boardinfo.

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>
2014-10-29 15:48:54 +08:00
H Hartley Sweeten 73901b5215 staging: comedi: addi_apci_1500: remove eeprom support
As indicated in the boardinfo, the hardware does not have an eeprom. Remove
the subdevice and support code for 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>
2014-10-29 15:48:54 +08:00
H Hartley Sweeten d75a78435c staging: comedi: addi_common.h: remove boardinfo 'i_IorangeBase1'
This member of the boardinfo is used as a flag to determine what PCI BAR
to use for the main 'iobase' used by the driver.

Remove the boardinfo member and refactor the (*auto_attach) of the drivers
to use the correct PCI BAR.

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>
2014-10-29 15:48:54 +08:00
H Hartley Sweeten 23abae881b staging: comedi: addi_common.h: rename boardinfo 'pc_DriverName'
Rename this CamelCase member of the boardinfo.

The comedi_device 'board_name' is set to this member during the (*auto_attach)
of the addi-data that still use this boardinfo drivers. For aesthetics, use
the dev->board_name instead of the boardinfo in the drivers.

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>
2014-10-29 15:48:54 +08:00
H Hartley Sweeten dd2762023e staging: comedi: addi_apci_1500: remove unused subdevices
Only allocate space for the subdevicess used by the driver. Remove all
the COMEDI_SUBD_UNUSED subdevices.

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>
2014-10-29 15:48:54 +08:00
H Hartley Sweeten 35ce3c3cc1 staging: comedi: addi_apci_1500: remove unnecessary subdevice initialization
The subdevices that don't initialize any of the callbacks don't really
exist. Remove the unnecessary initialzation and just set the type to
COMEDI_SUBD_UNUSED.

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>
2014-10-29 15:48:54 +08:00
H Hartley Sweeten a6b5d2a272 staging: comedi: addi_apci_035: remove unused subdevices
Only allocate space for the subdevicess used by the driver. Remove all
the COMEDI_SUBD_UNUSED subdevices.

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>
2014-10-29 15:48:53 +08:00
H Hartley Sweeten 8d3e0bf092 staging: comedi: addi_apci_035: remove unnecessary subdevice initialization
The subdevices that don't initialize any of the callbacks don't really
exist. Remove the unnecessary initialzation and just set the type to
COMEDI_SUBD_UNUSED.

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>
2014-10-29 15:48:53 +08:00
H Hartley Sweeten 1881c0f3b9 staging: comedi: addi_common.h: remove subdevice callbacks from struct addi_board
None of the drivers that still include this header use the subdevice callbacks.
Remove all of them to reduce the bloat.

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>
2014-10-29 15:48:53 +08:00
H Hartley Sweeten 4cab75b555 staging: comedi: addi_apci_1500: remove subdevice callbacks from boardinfo
This driver only has one boardinfo entry so the subdevice callbacks are
always the same. Remvoe the callbacks from the boardinfo and use them
directly when initializing the subdevices.

Remove all the subdevice callback initialization that would be set to
NULL.

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>
2014-10-29 15:48:53 +08:00
H Hartley Sweeten 422b5353d0 staging: comedi: addi_apci_035: remove subdevice callbacks from boardinfo
This driver only has one boardinfo entry so the subdevice callbacks are
always the same. Remvoe the callbacks from the boardinfo and use them
directly when initializing the subdevices.

Remove all the subdevice callback initialization that would be set to
NULL.

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>
2014-10-29 15:48:53 +08:00
H Hartley Sweeten f6a154c5c7 staging: comedi: addi_common.c: remove included source file
The addi_apci_035 and addi_apci_1500 are the only drivers left that
include this source file. Copy the i_ADDIDATA_InsnReadEeprom() function
from that file to those drivers and remove the addi_common.c 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>
2014-10-29 15:48:53 +08:00
H Hartley Sweeten 6c76d4e778 staging: comedi: addi_common.c: remove v_ADDI_Interrupt()
The addi_apci_035 and addi_apci_1500 are the only drivers left that use
this function in addi_common.c. The function simply calls the 'interrupt'
function that is in the boardinfo of the driver. Both drivers use the
same 'interrupt' function for all boardnfo entries.

Remove the i_ADDI_Reset() function as well as the 'interrupt' boardinfo
and use the 'interrupt' function directly when doing the request_irq().

In addition, the addi_apci_3120 driver has a private v_ADDI_Interrupt()
function that is doing the same thing. Remove that one as well.

Fix the return type of 'interrupt' functions in the drivers and add the
return vaules.

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>
2014-10-29 15:48:53 +08:00
H Hartley Sweeten 3c3dcdd7eb staging: comedi: addi_common.c: remove addi_auto_attach()
The addi_apci_035 and addi_apci_1500 are the only drivers left that use
this function in addi_common.c. The addi_common code adds a lot of bloat
to the drivers.

Copy the addi_auto_attach() code to the (*auto_attach) functions of the
drivers and remove the function. This will help with removing the bloat.

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>
2014-10-29 15:48:53 +08:00
H Hartley Sweeten 5b1ccca727 staging: comedi: addi_common.c: remove i_ADDI_Reset()
The addi_apci_035 and addi_apci_1500 are the only drivers left that use
this function in addi_common.c. The function simply calls the 'reset'
function that is in the boardinfo of the driver. Both drivers use the
same 'reset' function for all boardnfo entries.

Remove the i_ADDI_Reset() function as well as the 'reset' boardinfo and
just call the 'reset' function directly.

The i_ADDI_Reset() is called by addi_auto_attach() in addi_common.c after
a sucessful attach. Modify the (*auto_attach) in the drivers to call the
'reset' function directly and remove it from addi_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>
2014-10-29 15:48:53 +08:00
H Hartley Sweeten 6a9c41990d staging: comedi: addi_common.c: remove i_ADDI_Detach()
The addi_apci_035 and addi_apci_1500 are the only drivers left that use
this function in addi_common.c. Remove the function an add a private
comedi_driver (*detach) function to those drivers.

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>
2014-10-29 15:48:53 +08:00
H Hartley Sweeten 8e89ba5b3d staging: comedi: addi_apci_3200: remove driver
This driver has some serious bitrot. In addition, it's not in the Kconfig
or Makefile so it can't even be built.

Just remove it. It would be easier to rewrite the driver than fix 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>
2014-10-29 15:47:11 +08:00
H Hartley Sweeten 781f933c15 staging: comedi: comedidev.h: clarify async->event error/cancel detection
Introduce COMEDI_CB_ERROR_MASK and COMEDI_CB_CANCEL_MASK to clarify the
async->events that indicate errors and cancel an async command.

Use the new defines to tidy up and 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>
2014-10-29 15:47:11 +08:00
H Hartley Sweeten bb856b6c04 staging: comedi: comedidev.h: don't expose COMEDI_CB_* defines to userspace
The COMEDI_CB_* defines are the comedi_async "events" that the drivers set
to let the core detect the state of running async commands. These "events"
are only relevant to the kernel modules and should not be exposed to
userspace in the comedi.h user API header.

Move the defines to comedidev.h to avoid exposing them. For aesthetics,
convert the defines to bit shifts to better indicate that they are bitmask
values. Cleanup the 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>
2014-10-29 15:47:11 +08:00
Rickard Strandqvist 42170711b7 staging: comedi: drivers: comedi_bond.c: Changed from using strncat to strlcat
Changed from using strncat to strlcat to simplify the code

Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-10-29 15:47:11 +08:00
Bernd Porr 533de0f865 staging: comedi: usbduxfast: updated address details
Updated the range of years, e-mail and added driver desription as
usually done in comedi.

Signed-off-by: Bernd Porr <mail@berndporr.me.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-10-29 15:45:05 +08:00
Ian Abbott 4e3d14af12 staging: comedi: cb_pcimdas: add support for PCIe-DAS1602/16
The Measurement Computing PCIe-DAS1602/16 is a PCI-Express version of
the PCIM-DAS1602/16, but has a different PCI device ID.  Add support
for this device and update the driver description, Kconfig description
and MODULE_DESCRIPTION.

Thanks to Christoph Langbein for supplying the PCI device ID.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-10-29 15:45:05 +08:00
Bernd Porr 79f54ac18b staging: comedi: usbdux: updated contact details / comments
I've updated my contact details and removed obsolete comments.

Signed-off-by: Bernd Porr <mail@berndporr.me.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-10-29 15:45:05 +08:00
Ian Abbott 430c742169 staging: comedi: cb_pcimdas: update driver comment
The Comedi driver comment mentions a couple of manual configuration
options, but manual configuration via the COMEDI_DEVCONFIG ioctl and
comedi "attach" handler is no longer supported by this driver.  Update
the comment appropriately.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-10-29 15:45:04 +08:00
Bernd Porr a3f8c58d6a staging: comedi: usbduxsigma: updated contact details and status
I've updated my contact details of the driver. I've also tested it
thoroughly and it works perfectly. I've changed the status to stable.

Signed-off-by: Bernd Porr <mail@berndporr.me.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-10-29 15:45:04 +08:00
Ian Abbott c2f5a8d793 staging: comedi: cb_pcimdas: use preferred block comment style
Use the preferred block comment style for the copyright and Comedi
driver description header comments.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-10-29 15:45:04 +08:00
Surya Seetharaman 6b9214b793 Staging: comedi: nio_tiocmd: fixed a brace coding style issue.
Removed unnecessary braces using checkpatch.pl tool

Signed-off-by: Surya Seetharaman <suryaseetharaman.9@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-10-28 16:19:04 +08:00
tssurya 0297ac39fa Staging: comedi: ni_tiocmd: fixed a brace coding style issue
Removed unneeded braces with the help of checkpatch.pl tool.

Signed-off-by: Surya Seetharaman <suryaseetharaman.9@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-10-27 10:33:06 +08:00
Surya Seetharaman 4475cf2ebf Staging: comedi: ni_mio_common.c: fixed brace coding style issue in two places
Removed unnecessary braces with the help of  checkpatch.pl tool.

Signed-off-by: Surya Seetharaman <suryaseetharaman.9@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-10-27 10:33:06 +08:00
Somya Anand dd28153b2a Staging: comedi: replace timeval with ktime_t
'struct timeval last' is used for recording last time interrupt.
'struct timeval now' is used for calculating elapsed time.

32-bit systems using 'struct timeval' will break in the year 2038,
so we have to replace that code with more appropriate types.
This patch changes the comedi driver to use ktime_t.

Since this code doesn't communicate the time values
to the outside (user space, file system, network).Thus ktime_get()
is a better than using do_gettimeofday() as it uses monotonic
clock.

ktime_to_us() returns an 's64', and using the '%' operator on that requires
doing a 64-bit division which needs an expensive library function call
the specific value of usec_current does not actually matter although it might
matter that it's not always the same
which will start with the offset from the lower 32 bit of the microsecond.
Therefore:
  devpriv->usec_current = (ktime_to_us(devpriv->last) % USEC_PER_SEC)
                          % devpriv->usec_period;
	is replaced by

  devpriv->usec_current = ((u32)ktime_to_us(devpriv->last))
                          % devpriv->usec_period;

Signed-off-by: Somya Anand <somyaanand214@gmail.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-10-27 10:33:05 +08:00
Chen Gang ab608c2478 drivers/staging/comedi/Kconfig: Let COMEDI_II_PCI20KC depend on HAS_IOMEM
COMEDI_II_PCI20KC needs HAS_IOMEM, so depend on it. The related error (
with allmodconfig under um):

    CC [M]  drivers/staging/comedi/drivers/ii_pci20kc.o
  drivers/staging/comedi/drivers/ii_pci20kc.c: In function ‘ii20k_attach’:
  drivers/staging/comedi/drivers/ii_pci20kc.c:442:2: error: implicit declaration of function ‘ioremap’ [-Werror=implicit-function-declaration]
    dev->mmio = ioremap(membase, II20K_SIZE);
    ^
  drivers/staging/comedi/drivers/ii_pci20kc.c:442:12: warning: assignment makes pointer from integer without a cast [enabled by default]
    dev->mmio = ioremap(membase, II20K_SIZE);
              ^
  drivers/staging/comedi/drivers/ii_pci20kc.c: In function ‘ii20k_detach’:
  drivers/staging/comedi/drivers/ii_pci20kc.c:512:3: error: implicit declaration of function ‘iounmap’ [-Werror=implicit-function-declaration]
     iounmap(dev->mmio);
     ^

Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-10-20 10:56:17 +08:00
Ian Abbott 6cab7a37f5 staging: comedi: (regression) channel list must be set for COMEDI_CMD ioctl
`do_cmd_ioctl()`, the handler for the `COMEDI_CMD` ioctl can incorrectly
call the Comedi subdevice's `do_cmd()` handler with a NULL channel list
pointer.  This is a regression as the `do_cmd()` handler has never been
expected to deal with that, leading to a kernel OOPS when it tries to
dereference it.

A NULL channel list pointer is allowed for the `COMEDI_CMDTEST` ioctl,
handled by `do_cmdtest_ioctl()` and the subdevice's `do_cmdtest()`
handler, but not for the `COMEDI_CMD` ioctl and its handlers.

Both `do_cmd_ioctl()` and `do_cmdtest_ioctl()` call
`__comedi_get_user_chanlist()` to copy the channel list from user memory
into dynamically allocated kernel memory and check it for consistency.
That function currently returns 0 if the `user_chanlist` parameter
(pointing to the channel list in user memory) is NULL.  That's fine for
`do_cmdtest_ioctl()`, but `do_cmd_ioctl()` incorrectly assumes the
kernel copy of the channel list has been set-up correctly.

Fix it by not allowing the `user_chanlist` parameter to be NULL in
`__comedi_get_user_chanlist()`, and only calling it from
`do_cmdtest_ioctl()` if the parameter is non-NULL.

Thanks to Bernd Porr for reporting the bug via an initial patch sent
privately.

Fixes: c6cd0eefb2 ("staging: comedi: comedi_fops: introduce __comedi_get_user_chanlist()")
Reported-by: Bernd Porr <mail@berndporr.me.uk>
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Bernd Porr <mail@berndporr.me.uk>
Cc: <stable@vger.kernel.org> # 3.15.y 3.16.y 3.17.y
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-10-20 10:56:17 +08:00
H Hartley Sweeten 5d0d813d34 staging: comedi: comedi_fc.h: remove cfc_inc_scan_progress()
This inline function 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>
2014-10-20 10:29:26 +08:00
H Hartley Sweeten eac783a6b7 staging: comedi: mite: use comedi_inc_scan_progress()
This inline function is just a wrapper around comedi_inc_scan_progress().

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>
2014-10-20 10:29:25 +08:00
H Hartley Sweeten f3055f9ef3 staging: comedi: comedi_fc.h: remove cfc_bytes_per_scan()
This inline function 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>
2014-10-20 10:29:25 +08:00