staging: comedi: icp_multi: remove board reset during (*detach)
The icp_multi_reset() function currnelt does the following during the
(*auto_attach) and (*detach) of this driver:
1) disables all interrupts and clears any pending requests
2) resets the analog output channels to 0V (0..5V range)
3) sets all digital output channels to 0
Interrupts are not used by this driver so the disable/clear when
detaching is not necessary.
Depending on the use, reseting the analog and digital outputs when the
driver is detached might not be desireable.
Remove the board reset during the (*detach) and use comedi_pci_detach()
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>
staging: comedi: icp_multi: remove private data member 'DacCmdStatus'
This private data member isn't really needed. The two functions
that use it, icp_multi_ao_insn_write() and icp_multi_reset(), mask
any previous value before setting the bits. The masking just clears
the variable.
Refactor the code to not use the private data member. This also
removes the need for the private data so remove it's allocation
during the 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>
staging: comedi: icp_multi: remove interrupt support
The interrupt handler in this driver doesn't do anything other than
read the interrupt status register. Since I can't locate a datasheet
for the board, remove the useless interrupt support 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>
The comedi core expects (*insn_read) functions to return insn->n data
values. Refactor the function to work like the core expects. For
aesthetics, use the comedi_offset_munge() helper to munge the 2's
complement data.
This also fixes a minor issue when comedi_timeout() times out. Currently
this function just returns which leaves the ADC mode programmed for
software triggering. With the refactor the ADC mode is always disabled
when the function exits. This allows removing the unnecessary steps to
"stop any running conversions" at the start of the 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>
staging: comedi: me_daq: allow differential analog inputs
The ai (*insn_read) allows differential analog inputs but the subdevice
initialization is missing the SDF_DIFF subdev_flag to allow the user to
select this mode. Fix the subdevice init.
According to the manual, differential operation only works with the
first 8 channels and bipolar ranges. Add a check to the (*insn_read) to
ensure this.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: comedi: me_daq: tidy up dac control register defines
Redefine the dac control register bits as macros that take the
channel number and return the correct bit values.
This register needs to be read after the new values are written
in order to actually update the dac. For aesthetics, use the same
define to read and write 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>
staging: comedi: me_daq: tidy up ai fifo/chanlist register defines
Tidy up this register usage by defining some macros to set the channel
and gain bits. Add a define for the bit that enables differential mode.
Writing to this offset puts data in the ai chanlist fifo, reading from
it gets data from the ai data fifo. For aesthetics, use the same define
to read and write 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>
staging: comedi: me_daq: tidy up status register defines
Rename the bits of this register so they have association with the
register. Use the BIT macro to define the bits.
Writing to the status register clears any pending interrupts. For
aesthetics, remove the ME_RESET_INTERRUPT define and just use the
ME_STATUS_REG define to write the register.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: comedi: me_daq: tidy up control 2 register defines
Rename the bits of this register so they have association with the
register. Use the BIT macro to define the bits.
Reading the control 2 register updates the DAC registers. For
aesthetics, remove the MC_DAC_UPDATE define and just use the
ME_CTRL2_REG define to read the register.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: comedi: me_daq: tidy up control 1 register defines
Rename the bits of this register so they have association with the
register. Use the BIT macro to define the bits.
Add a macro to select the ADC mode and remove the magic value used
to stop conversion.
Reading the control 1 register starts an analog input conversion.
For aesthetics, remove the MC_ADC_START define and just use the
ME_CTRL1_REG define to read the register.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Refactor this block comment to fix the checkpatch.pl issues:
WARNING: Block comments use * on subsequent lines
WARNING: Block comments use a trailing */ on a separate line
According to the user's manual, the A/D converter uses 2's complement
coding. Use the comedi_offset_munge() helper to convert the data to
the offset binary format used by comedi.
staging: comedi: mpc624: tidy up the ai conversion speed code
Rename the CamelCase private data 'ulConvertionRate' and MPC624_SPEED_*
defines.
Create a macro to set the OSR bits that set the ai conversion speed and
use it for the various MPC624_SPEED_* defines. Remove the unnecessary
comment describing the speeds, this information is alread in the comedi
driver comment block.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Remove the #if 0'ed out code that would initialize an analog output
subdevice.
The hardware does not normally support an analog output subdevice.
Analog outputs are only supported with additional "piggyback" modules.
Support for these modules is not included 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>
staging: comedi: multiq3: tidy up multiq3_encoder_insn_read()
Encoders are not a "normal" subdevice in comedi. For aesthetics, tidy
up this function and add a couple comments to clarify the function and
explain the strange munging of the data.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: comedi: multiq3: allow user to reset encoder channels
Currently this driver resets all the encoder channels when the driver
is first attached. Add a (*insn_config) to the subdevice to allow the
use to reset the channels manually.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: comedi: multiq3: tidy up control register bit defines
For aesthetics, move these defines closer to the register define and
use the BIT macro to define the bits.
Add macros to set the bits needed to select the channel for the analog
output, analog input, and encoder (counter) subdevices as well as the
realtime clock registers.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
According to the programming manual. the 'SH' and 'CLK' bits in the
control register need to be kept high at all times. Clarify this by
introducing a helper function to set the control register.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: comedi: quatech_daqp_cs: avoid calculating pacer divisor multiple times
The pacer will either be used to trigger each conversion or to start each
scan. Modify the (*do_cmdtest) so that one one divisor calculation is needed.
Save the divisor value in the private data so that the (*do_cmd) does not
have to do the calculation again.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: comedi: quatech_daqp_cs: ai async command requires a pacer
The ai (*do_cmd) assumes that either the convert_src is TRIG_TIMER or
the scan_begin_src is TRIG_TIMER and always programs the pacer clock
with the appropriate trigger argument.
Add a Step 2b check to the (*do_cmdtest) to ensure that at least one
of the triggers is TRIG_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>
staging: comedi: quatech_daqp_cs: cleanup Step 3 of ai (*do_cmdtest)
Step 3 of the (*do_cmdtest) trivially validates the async command arguments.
The validations also modify the arguments if they are invalid so that the
user gets valid values if the test fails.
Reorder the checks so that if any of the checks fail proper values are
used for subsequent checks.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Make sure interrupts are disabled and the event flags are cleared when
an analog input async command is canceled.
Remove the unnecessary calls to stop any running conversions in the
(*insn_read) and (*do_cmd) functions. The comedi core will only call
these functions if the subdevice is not busy (it has already been
canceled).
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This is a PCMCIA driver and interrupts are always shared. Detect if
the hardware did not produce the interrupt and return IRQ_NONE so
that other drivers might handle 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>
The interrupt handler is now only used for the ai async command.
Remove the unnecessary 'interrupt_mode' from the private data and
tidy up the interrupt handler.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: comedi: quatech_daqp_cs: only hook up cmd support if we have an IRQ
Interrupts are only needed by this driver to support the analog input async
commands. Don't hook up the command support if pcmcia_request_irq() fails
instead of completely failing the (*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>
staging: comedi: quatech_daqp_cs: don't use interrupts for ai (*insn_read)
The comedi (*insn_read) functions are supposed to do simple one-shot
reading of an analog input channel. Currently this driver enables
interrupts and uses wait_for_completion_interruptible() to allow the
interrupt routine to let the analog input (*insn_read) know that
the end-of-conversion has occured.
Simplify the function by using the comedi_timeout() helper to check
the aux status register to see when the conversion is finished.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: comedi: quatech_daqp_cs: tidy up command register bits
For aesthetics, move the bit defines for this register and use the
BIT macro to define the bits. Define a macro for the scanrate bits
and use it to remove the CamelCase. Rename the defines to match the
register.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
For aesthetics, rename the register map defines and convert the
values to hex. Also, move the private data definition and
DAQP_FIFO_SIZE define after the register definitions.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>