History log of /drivers/staging/comedi/drivers/dt282x.c
Revision Date Author Comments
759658ddff327675bbf35063e2b04e0d7424124d 10-Sep-2014 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: dt282x: prevent "empty acquisition" async commands

This driver currently allows a cmd->stop_src == TRIG_COUNT with a cmd->stop_arg
of 0 for both the analog input and output async commands. The (*do_cmd) for
both subdevices sets up and starts the command without handling the "empty
acquisition". This results in the interrupt functions trying to transfer 0 data
samples.

Validate that the cmd->stop_arg is >= 1 in the (*do_cmdtest) to prevent the
"empty 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>
a4759d39e25cf8858e66608cee04f29910225e11 09-Sep-2014 Ian Abbott <abbotti@mev.co.uk> staging: comedi: dt282x: replace comedi_board() calls

The `comedi_board(dev)` inline function calls just return
`dev->board_ptr`. Expand the inline function calls.

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>
ba81e62d9934d072a77c01cd7715eed0816b5c53 03-Sep-2014 Ian Abbott <abbotti@mev.co.uk> staging: comedi: dt282x: use CMDF_ROUND_...

Replace use of the `TRIG_ROUND_...` macros with the new names
`CMDF_ROUND_...`. The numeric values are unchanged.

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>
559975c175767ccb2f0f9a8231b3fcb3adcd1650 26-Aug-2014 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: dt282x: use comedi_subdevice 'readback'

Use the new comedi_subdevice 'readback' member and the core provided
(*insn_read) for the readback of the analog output subdevice 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>
5a96ffbe795d71347fbebac9cf29772543d22961 17-Jul-2014 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: dt282x: remove use of comedi_error()

The comedi_error() function is just a wrapper around dev_err() that adds
the dev->driver->driver_name prefix to the message and a terminating
new-line character. The addition of the driver_name is just added noise
and some of the users of comedi_error() add unnecessary additional new-line
characters.

Use dev_err() directly instead of comedi_error() to avoid any confusion
and so that all the comedi generated kernel messages have the same format.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
aa2998450bcd44979b44ed8d4f226e3f486b3bb4 16-Jul-2014 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: dt282x: checkpatch.pl cleanup (else after return)

Fix checkpatch.pl warning:

WARNING: else is not generally useful after a break or return

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
d7b6c574d17fed09a0d9fa4bc7674c13fa156805 20-Jun-2014 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: dt282x: automatically handle D/A data format

The DT2821 series board have jumpers that set the output range for
the two Analog Output channels. The range_table for the Analog Output
subdevice provides all possible ranges to the user. When a unipolar
range is selected the board expects the data to be in a straight
binary format. When a bipolar range is select the data should be in
two's complement format.

Currently, the user passes some configuration options when attaching
to the driver to select the data format for each channel. If the
user does not pass the config options, the data format is assumed to
be straight binary.

The Analog Output subdevice now has a range_table that provides the
user will all possible ranges. Use the range information to determine
if the data values need to be munged into two's complememnt values
and deprecate the config options.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
c50d32de3707ee8165eaeaa319c5c13d12ea0669 20-Jun-2014 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: dt282x: fix bug where DIO direction is reset to inputs

The direction of the 16 DIO channels is controlled with two bits in the
DACSR register. The HBOE bit controls the direction of channels 15-8 and
the LBOE bit channels 7-0.

The DACSR register is also used to control the Analog Output async command
support. Currently, starting or canceling an Analog Output command would
also reset the DIO directions so that all channels were inputs.

Fix the driver so that the DIO direction is not changed when starting or
canceling an Analog Output 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>
0f8e8c5ab67a818ad56291007796d17f16d0fd6a 20-Jun-2014 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: dt282x: tidy up the register map and bit defines

For aesthetics, rename the register map defines so that the bit defines
are associated with the registers. Also, convert all the bit defines into
bit-shifts to make them clear.

Remove all the verbose comments. All the registers and bits are named
according to the User Manual for the DT2821 Series, Document UM-05073-G.
That manual can be checked if necessary for the verbose information.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3ec2e20274f5721949c27eac403e876f397db50e 20-Jun-2014 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: dt282x: avoid calculating the timer divisor multiple times

A common timer is used for analog input and output async commands. The
(*do_cmdtest) for both subdevices calculates the divisor as part of
Step 4 when validating the trigger arguments. The divisor is calculated
again in the (*do_cmd) for both subdevices in order to set the timer.

The comedi core only calls the (*do_cmd) is called after a successful
(*do_cmdtest). Save the divisor from the (*do_cmdtest) in the private
data and use that value in the (*do_cmd).

The extra check of the cmd->convert_arg in dt282x_ai_cmd() is not necessary.
The convert_arg was already checked in the (*do_cmdtest), and it's not used
in the (*do_cmd).

Tidy up dt282x_ns_to_timer(), the parameters are all unsigned int's and the
mask of the 'flags' can be moved here to simplify the callers.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7152f7d4b130a4b99c9a2dd1fc705a3b8ca8dcd5 20-Jun-2014 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: dt282x: update the MODULE_DESCRIPTION

Change the MODULE_DESCRIPTION to something more useful than the
generic "Comedi low-level 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>
9c64ef47a7134d3da686b63f79761e05ac504950 20-Jun-2014 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: dt282x: tidy up multi-line comments

Tidy up the multi-line comments at the beginning of the file to follow
the CodingStyle.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fc00fbc990871a17e0e0f31acc0876f83165cf53 20-Jun-2014 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: dt282x: cleanup analog output range table

The DT2821 series boards do not have programmable analog output ranges.
The range is set, per-channel, with jumpers on the board.

Currently the user has to pass some configuration options when attaching
to the driver in order to set the range for each channel. If they do not
pass the range options they will default to 0. If they pass an invalid
range option they will also default to 0. The 0 range option is bipolar
10V. If the user passes a range option that does not match the hardware
setting it doesn't cause any problems in the driver it just causes the
user space comedilib library to incorrectly convert the hardware values
to physical values.

Make the attach a bit simpler by deprecating these options and providing
a range table with all the valid ranges for the analog outputs. The user
can then select the correct range when they use the comedilib 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>
d5aa6b7c31d8f9667e743a8bb2a6677caf78cd31 20-Jun-2014 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: dt282x: fix Analog Input se/diff channel configuration

Most of the boards supported by this driver can do either single-ended or
differential Analog Input but there are a couple that can only do one or
the other. On the boards that can do both the type of input is set with
jumpers on the board.

The 'it->options[4]' passed by the user during the board (*attach) is used
to determine how the Analog Inputs are configured. This is used to set
the subdevice flags and number of channels correctly.

Fix the check of this option so that it only applies when the board can
actually do differential input. Also, default to differential inputs if
that is the only mode the board supports.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
810c8a88b660b1a06bd9b8b7b0fa00c990c4e734 20-Jun-2014 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: dt282x: tidy up Analog Input subdevice init

For aesthetics, add some whitespace to the Analog Input subdevice init.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9803bc096910ce4f012699d4dae07d91346c6d66 20-Jun-2014 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: dt282x: tidy up Analog Output subdevice init

For aesthetics, add some whitespace to the Analog Output subdevice init.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
f8b987b4d35c37cf973c30871fc42b16c6272041 20-Jun-2014 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: dt282x: remove the 'opt_*' enum

This enum is used to index the 'options' values that are passed
by the user attaches to the driver. These options are identified
in the comedi comment block.

For aesthetics, remove the enum and just open code the index values.

Refactor the Analog Input subdevice init so that the it->options[4],
indicating differential inputs, does not have to be checked multiple
times.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
f4af8d4991bd3575d8eb54b08d78fb0e498b8ec8 20-Jun-2014 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: dt282x: factor board initialization out of (*attach)

For aesthetics, factor the code that initializes the then checks to see
if it is actually a DT2821 series board out of the (*attach).

For clarity, remove the MASK and VAL defines used to check the board and
jsut open code the values.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9504be8a1b84d5139f7475c0e705bc0630e82dc9 20-Jun-2014 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: dt282x: fix dt282x_ao_insn_read()

The comedi core expects the (*insn_read) functions to return 'insn->n'
samples. Fix this function to work like the core expects.

For aesthetics, rename the private data 'ao' member to clarify its
use. Also, remove the unnecessary comment.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
de91bb97254cec30f24b4f770e10eab7da3f6be1 20-Jun-2014 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: dt282x: tidy up dt282x_ai_dma_interrupt()

The main interrupt handler already has the comedi_subdevice pointer
needed in this function. Pass that subdevice pointer so that it does
not need to be fetched as a local variable.

Tidy up the function a bit.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
e6cff3990d53d93f5b1bf59984a4fe7816f02b63 20-Jun-2014 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: dt282x: tidy up dt282x_ao_dma_interrupt()

The main interrupt handler already has the comedi_subdevice pointer
needed in this function. Pass that subdevice pointer so that it does
not need to be fetched as a local variable.

Tidy up the function a bit.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
ecac148c60d341c9e50e2b65744d2ffde5b884cb 20-Jun-2014 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: dt282x: remove sanity checks of 's->async->prealloc_buf'

The comedi core sanity checks that the subdevice has a buffer allocated
before allowing an async command to start. The helper functions in comedi_buf
will also sanity check the buffer as a side effect of the 'alloc' helpers
with reading or writing data for the buffer.

Remove the unnecessary sanity checks in the ai/ao dma interrupt handlers.
This will allow the handlers to disable the dma and then fail when they
try to read/write the buffer. Currently dma is left enabled due to the
sanity 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>
f83cbc53dafb9755b0002976c3956052b089c4c6 20-Jun-2014 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: dt282x: tidy up Digital I/O subdevice init

For aesthetics, add some whitespace to the Digital I/O subdevice init.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
198c15a63d016ce6e7b339e1b7e02e2595a75b00 20-Jun-2014 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: dt282x: rename the prep_{ai,ao}_dma() functions

Rename these functions so they have namespace associated with 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>
6ee9c91fbbcf9e29951fb741492b5e9e6b6ac0ef 20-Jun-2014 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: dt282x: remove unused chan_to_DAC() macro

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

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
30dadbd208a480bb1ca919e395602adaafdbc449 20-Jun-2014 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: dt282x: convert private data flags to bit-fields

Convert the '2scomp' flags in the private data into bit-fields to save
a bit of space.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
c53a62f64a072ea1ba31aa657e5962cf2a8f360e 20-Jun-2014 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: dt282x: remove DT2821_SIZE define

This define is only used in the comedi_request_region() call to specify
the size of the I/O region. Remove it and just open code the value.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
cb3d0d3996fe5c8c4fd7063b4bea890767469cb1 20-Jun-2014 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: dt282x: IRQ and DMA are needed for async command support

This driver requires an IRQ and 2 DMA channels in order to execute async
commands.

Modify the (*attach) so that command support is only hooked up if
DMA is available. This allows removing the extra checks in the
command support 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>
ebf86ea9a68e2ebb366dc7640f916e233d614db1 20-Jun-2014 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: dt282x: remove 'volatile' on private data variables

As indicated by checkpatch.pl, "WARNING: Use of volatile is usually
wrong: ...". The variables in the private data that are marked
volatile don't need to be. Remove the volatile.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
804ee9ac04c01946c5ba158b5e350b40ee515fed 20-Jun-2014 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: dt282x: fix dt282x_ao_insn_write()

The (*insn_write) functions are expected to write 'insn->n' samples to the
hardware. Fix this function so it works like the comedi core expects.

The comedi core sanity checks that the samples are within the 'maxdata' range
of the subdevice before calling the (*insn_write) so this function does not
need to mask each sample by 's->maxdata'.

Also, the wrong '*2scomp' flag in the private data was being checked to see
if the sample needs to be munged before being written. Fix 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>
58c8c47fda4aa37ec946ff7ad1a42b875b03da74 20-Jun-2014 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: dt282x: convert 'dabits' boardinfo to 'ao_maxdata'

This member of the boardinfo is the number of bits in the analog output data.
Convert this member into the subdevice 'maxdata', (1 << board->dabits) - 1,
to avoid needing to do the calculation.

Use the subdevice 'maxdata' in the driver instead of using the boardinfo and
use the comedi_offset_munge() helper to convert the two's complement data to
the offset binary form that the comedi core expects.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
d839495b64d0ec599e1d2cc74ce3705043c2dae4 20-Jun-2014 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: dt282x: convert 'adbits' boardinfo to 'ai_maxdata'

This member of the boardinfo is the number of bits in the analog input data.
Convert this member into the subdevice 'maxdata', (1 << board->adbits) - 1,
to avoid needing to do the calculation.

Use the subdevice 'maxdata' in the driver instead of using the boardinfo and
use the comedi_offset_munge() helper to convert the two's complement data to
the offset binary form that the comedi core expects.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
f11c4b6caef19f331a9ce4821602eed6b12f131f 20-Jun-2014 H Hartley Sweeten <hartleys@visionengravers.com> staging: comedi: dt282x: remove '= 0' boardinfo

All unlisted members in the boardinfo declaraction will default to '0'.
Remove the unnecessary 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>
5aeb355fc7ebc0e8e50254193ddc830c059de33d 20-Jun-2014 H Hartley Sweeten <hartleys@visionengravers.com> staging: comedi: dt282x: move boardinfo declaration

For asethetics, move the boardinfo declaration closer to the struct
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>
935f0e8c2b127d0aaec12184718c7b3fc73b7787 20-Jun-2014 H Hartley Sweeten <hartleys@visionengravers.com> staging: comedi: dt282x: remove forward declarations

Move some of the functions to remove the need for the forward
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>
9f57921507dacdcba186e384b2025601ad09b227 27-May-2014 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: dt282x: use comedi_fc helpers to validate timer args

Use the comedi_fc helper cfc_check_trigger_arg_is() to validate the
trigger arguments when the source is TRIG_TIMER.

All the arguments are unsigned int, change the local variable to an
unsigned int and rename it for aesthetic reasons.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3672effdeae5395d661a2103f69082146ef949fc 06-May-2014 Ian Abbott <abbotti@mev.co.uk> staging: comedi: pass subdevice to comedi_buf_put()

Change the parameters of `comedi_buf_put()` to pass a pointer to the
comedi subdevice instead of a pointer to the "async" structure belonging
to the subdevice.

The function puts a sample value in the comedi buffer, but currently
only deals with 16-bit sample types. A future version could deal with
16 or 32-bit sample types depending on the value of the SDF_LSAMPL
subdevice flag.

The main aim at the moment is to replace all the `struct comedi_async *`
parameters with `struct comedi_subdevice *` parameters in the comedi
driver API.

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>
bdbca9b562a2e892b77811ef2b70e1981e26b7e2 17-Apr-2014 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: dt282x: fix the ao cmd->start_arg use for TRIG_INT

This driver only supports a cmd->start_src of TRIG_INT for ao commands. The
cmd->start_arg is trivially validated to be 0. For TRIG_INT source, the
cmd->start_arg is actually the valid trig_num that is passed to the async
(*inttrig) callback.

Refactor the (*inttrig) function so that the cmd->start_arg is used to check
the trig_num instead of the open coded value.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
f50cebb9baa5fd0e561f436bd53ffa35df16edb2 17-Apr-2014 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: drivers: properly validate cmd->scan_end_arg

When the async command 'scan_end_src' is TRIG_COUNT the 'scan_end_arg'
is the cmd->chanlist_len. Fix a couple open-coded drivers. Add the
check to the drivers that do not validate this command argument.

The core validates that the cmd->chanlist_len is <= s->len_chanlist.
During the post config after the attach the core also make sure that
the s->len_chanlist is initialized. For clarity, initialize the
s->len_chanlist in a couple drivers that are relying on the core to
initialize it to '1'.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
f21c74fa4cfe675f5e81b7d604212882799f4e6d 08-Mar-2014 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: dt282x: use cfc_handle_events()

Use the comedi_fc helper function to automatically call the subdevice
(*cancel) function when needed and call comedi_event().

This also fixes two bugs.
1) the analog input command is canceled due to a buffer overflow
without sending an event (@@ -341,7 +340,7 @@).
2) an analog output error causes the command to cancel but the event
is reported to the analog input subdevice (@@ -449,15 +447,13 @@).

In the Kconfig, COMEDI_DT282X already selects COMEDI_FC.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
22ca19d93d92c79cff68270846a84bd34fe6fb34 10-Feb-2014 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: move (*insn_{read, write}) timeout debug messages to core

Have the comedi core display a standard dev_dbg() message when a timeout
occurs and remove all the driver specific messages.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
d8644e418b2613b3eaf1e10fe6fd0d84018c2f8a 10-Feb-2014 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: dt282x: use comedi_timeout()

The wait_for() macro in this driver is a bit nasty. It effects control flow
which according to the CodingStyle is a _very_ bad idea.

The mux_busy() and ad_done() macros are also bad since they rely on a local
variable having a specific name.

Remove these macros and use comedi_timeout() to wait for the analog input
mux busy completion and end-of-conversion. Both of these are detected by
reading the same register and testing different bits. Pass the bits to test
as the 'context' to the callback function.

The dt282x_ai_cmd() function also checks for the mux busy completion. The
'insn' is not available here but passing NULL is safe because nothing
uses it.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
0bb7781b43b1d8585016b0e731edfa264620601e 10-Dec-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: dt282x: tidy up comedi_lrange tables

Tidy up the whitespace in the comedi_lrange tables.

Use the BIP_RANGE and UNI_RANGE macros instead of the more generic
RANGE macro to reduce possible typo errors.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
95dc140a5e9210c6305b4f8b91cf2e654e1bba1e 05-Dec-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: dt282x: use dev->write_subdev

Use the dev->write_subdev that was setup in the device attach instead
of accessing the dev->subdevices array 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>
9ee0de0ec1196df99c9d6ecec6a25ee383de6bc1 05-Dec-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: dt282x: use dev->read_subdev

Use the dev->read_subdev that was setup in the device attach instead
of accessing the dev->subdevices array 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>
54bb2637645819302b0ca5b36ecb1391f684e87d 27-Nov-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: dt282x: remove commented out printk

This printk is just added noise. 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>
50dbda4a9e3573a22b00bb8e7f179d0f75c641e6 27-Nov-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: dt282x: convert dt282x_ao_inttrig() messages

Convert the messages in this function to dev_err().

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
e0bee2de37da868c858891dd1c5e2fd93ec15297 27-Nov-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: dt282x: convert dt282x_ai_dma_interrupt() messages

Convert the messages in this function to dev_{level}().

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
01112bf1efdec5ee63a8ee31c5b4c6b0331e83f0 27-Nov-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: dt282x: convert dt282x_ao_dma_interrupt() messages

Convert the messages in this function to dev_err().

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
427f35222e7da82f4ffead939b1586623d92e1c5 27-Nov-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: dt282x: remove disable code that disables the irq

The code that would disable the irq after getting a number of D/A errors
is disabled. Just remove it.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
d3ea1818f36991de1aaf8cc1958768a060a46cde 27-Nov-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: dt282x: remove unnecessary blank line message

This blank line message is not needed. 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>
753b53d9b169043c6d2c30f7f990c2e4f7b23b14 27-Nov-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: dt282x: convert printk() in dt282x_attach to a dev_err()

Convert this printk message into a dev_err().

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
ab49581acebd6926842d261a74693e70564afe54 27-Nov-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: dt282x: remove attach noise in dt282x_grab_dma()

These messages are just added noise. 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>
06551fda7e0f07250884c0cf47d1286da0a5651c 27-Nov-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: dt282x: tidy up the irq support in dt282x_attach()

An irq is only needed by this driver in order to support async commands.
Since it is optional, modify the attach so that if the request_irq() fails
the attach does not fail.

Remove the printk noise about the irq.

Only hookup the async command support if the request_irq() was successful.

Also, only call dt282x_grab_dma() if we have an irq since interrupt support
is needed to support dma.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
84f3da09858c821d008d6efd5190565f7e8048c5 22-Nov-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: dt282x: remove DEBUG define

This define is only used to enable a debug message during the board attach.
The message is just added noise, remove it as well as the DEBUG 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>
766b1f95cf3ce6a70fa25978591f3fcf5de0d51c 16-Oct-2013 Ian Abbott <abbotti@mev.co.uk> staging: comedi: dt282x: sample types are unsigned

Sample values in comedi are generally represented as unsigned values.
Change various members of `struct dt282x_private` and various parameters
and variables dealing with samples to use `unsigned short` instead of
`short` for consistency.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
97f4289ad08cffe55de06d4ac4f89ac540450aee 30-Aug-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: drivers: use comedi_dio_update_state() for simple cases

Use comedi_dio_update_state() to handle the boilerplate code to update
the subdevice s->state for simple cases where the hardware is updated
when any channel is modified.

Also, fix a bug in the amplc_pc263 and amplc_pci263 drivers where the
current state is not returned in data[1].

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9b3e5aec9b275a6a7bad48f2dc2c2dcfd38a4779 27-Aug-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: dt282x: fix dt282x_dio_insn_config()

This is the (*insn_config) function for a DIO subdevice. It should be
using the data[0] value as the "instruction" to perform on the subdevice.

Use the comedi_dio_insn_config() helper to properly handle instructions.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2c4283ca7cdcc6605859c836fc536fcd83a4525f 20-Aug-2013 Dan Carpenter <dan.carpenter@oracle.com> staging: comedi: dt282x: dt282x_ai_insn_read() always fails

In dt282x_ai_insn_read() we call this macro like:
wait_for(!mux_busy(), comedi_error(dev, "timeout\n"); return -ETIME;);
Because the if statement doesn't have curly braces it means we always
return -ETIME and the function never succeeds.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Ian Abbott <abbotti@mev.co.uk>
Cc: stable <stable@vger.kernel.org> # 2.6.36+
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
8e6b7915a1da703617dca28c33e150141fcec9b0 25-Jun-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: drivers do not need <linux/ioport.h>

All the ioport resources are managed by the comedi core. None of
the drivers depend on <linux/ioport.h>. Remove the includes.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
ce157f8032bbd46d9427034c335b0afd751da25d 25-Jun-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: don't rely on comedidev.h to include headers

comedidev.h is the main kernel header for comedi. Every comedi
driver includes this header which then includes a number of
<linux/*> headers. All the drivers need <linux/module.h> and some
of them need <linux/delay.h>. The rest are not needed by any of
the drivers.

Remove all the includes in comedidev.h except for <linux/dma-mapping.h>,
which is needed to pick up the enum dma_data_direction for the
comedi_subdevice definition, and "comedi.h", which is the uapi
header for comedi.

Add <linux/module.h> to all the comedi drivers and <linux/delay.h>
to the couple that need it.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
0bdab509bf9c6d838dc0a3b1d68bbf841fc20b5a 25-Jun-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: use comedi_alloc_devpriv()

Use the helper function to allocate memory and set the comedi_device
private data pointer.

This removes the dependency on slab.h from most of the drivers so
remove the global #include in comedidev.h and the local #include
in some of 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>
641f064e5df6fb3aaeb6256031a153a5efb16ca6 25-Apr-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: remove FSF address from boilerplate text

Addresses change...

Remove the paragraph with the FSF address from all the comedi source
files.

Also, remove the paragraph about the finding the complete GPL in the
COPYING file since it's unnecessary.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3d1fe3f785c80e17f62acf8f92570ae9210bd588 18-Apr-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: drivers: free_irq() in comedi_legacy_detach()

All the legacy comedi drivers now call comedi_legacy_detach()
either directly or as part of their (*detach). Move the free_irq()
into comedi_legacy_detach() so that the drivers don't have to
deal with it.

For drivers that then only call comedi_legacy_detach() in their
private (*detach), remove the private function and use the helper
directly for the (*detach).

The amplc_pc236 and ni_labpc drivers are hybrid legacy/PCI drivers.
In the detach of a PCI board free_irq() still needs to be handled
by the driver.

The pcl724 and pcl726 drivers currently have the free_irq() #ifdef'ed
out. The comedi_legacy_detach() function sanity checks that the irq
has been requested before freeing it so they are safe to convert.

For aesthetic reasons, move the #ifdef unused chunk in the pcl816
driver up to the previous #ifdef unused block.

The pcmio and pcmuio drivers request multiple irqs and handle the
freeing of them. Remove the 'dev->irq = irq[0]' in those drivers
so that comedi_legacy_detach() does not attempt to free the irq.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
a32c6d0084992d3e58a93120c9ce9527e80c651e 18-Apr-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: drivers: use comedi_legacy_detach()

Use comedi_legacy_detach() to release the I/O region requested
by these 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>
364e3a87f5759969cc287200c1cb5ba6151b5ba2 10-Apr-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: dt282x: use comedi_request_region()

Use comedi_request_region() to request the I/O region used by this
driver.

Remove the default iobase address (0x240) that is used when the user
does not pass a base address during the "comedi_config". Comedi
legacy drivers should only attach to a specified address.

Remove the noise when the board is first attached as well as the
error message when the request_region() fails, comedi_request_reqion()
will output the error message if necessary.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
25829c646e11dda92a5b3628b21fe852681fec44 10-Apr-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: dt282x: cleanup dev->board_name usage

This legacy driver does no additional probing so the dev->board_name
will already be properly initialized by the comedi core before calling
the (*attach) function.

Remove the unnecessary initialization of dev->board_name and use it
when requesting the resources instead of the open-coded strings.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
a56ec2fe6657984f84e419355e6451460ffb44ce 06-Apr-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: dt282x: remove 'boardtype' macro

The 'boardtype' macro relies on a local variable having a specific
name and yields a struct derived from that local variable.

Replace the macro with local variables and use the comedi_board()
helper to get the struct as a pointer. Use pointer access when
using the variable.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
61e55b88fd19331e33fb09e6b423ac0975aaa26d 14-Nov-2012 H Hartley Sweeten <hartleys@visionengravers.com> staging: comedi: dt282x: use cfc_check_trigger_arg_*() helpers

Use the new helpers in the step 3 tests of dt282x_{ai,ao}_cmdtest().

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
c34fa261b0ac3a862ccd3f71ee55a16b920dfc83 23-Oct-2012 H Hartley Sweeten <hartleys@visionengravers.com> staging: comedi: remove inline alloc_private()

This inline function has a very generic name and it's only a
wrapper around a simple kzalloc(). Since the inline function
does not save any lines-of-code, instead of renaming it just
remove it and do the kzalloc() directly.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9a1a6cf8ae5ca58171e117335b9983e3cfa2185c 15-Oct-2012 H Hartley Sweeten <hartleys@visionengravers.com> staging: comedi: drivers: remove remaining devpriv macros

The remaining comedi drivers that still have a devpriv macro
are all pretty straight forward for removing the devpriv
macro.

This macro relies on a local variable having a specific name.
Remove its use by replacing it with a local variable where
used.

The inline function alloc_private(), used to kzalloc the
dev->private memory, returns non-zero if there is an error.
Fix all the alloc_private() calls accordingly and remove any
kernel messages or obvious comments that still exist in the
drivers. Leave a comment in the skel driver.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
27020ffed9166d65ce1e5b523051d13bfa2329b0 26-Sep-2012 H Hartley Sweeten <hartleys@visionengravers.com> staging: comedi: drivers: use comedi_fc.h cmdtest helpers

Use the cfc_check_trigger_src() helper for Step 1 in all the
driver cmdtest functions.

Use the cfc_check_trigger_is_unique() helper for Step 2 in all
the driver cmdtest functions. Note that single source triggers
do not need to be checked, they are already unique if they pass
Step 1.

For aesthetic reasons, change the comments in the cmdtest
functions for steps 1 and 2 so that they are all the same.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
e1d7cf9c9dd7e08390d836e9f9c8b4851c0b1df0 06-Sep-2012 H Hartley Sweeten <hartleys@visionengravers.com> staging: comedi: dt282x: remove subdevice pointer math

Convert the comedi_subdevice access from pointer math to array
access.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
d254eb7418e389e063831d8d77b7dac240288f02 13-Jul-2012 H Hartley Sweeten <hartleys@visionengravers.com> staging: comedi: dt282x: remove the outw wrapper macros

The macros 'update_dacsr', 'update_adcsr', and 'update_supcsr' all use
the 'devpriv' macro which uses a local variable of a specific name and
yeilds a pointer derived from that name. They are also just wrappers
around simple 'outw' calls. Remove the macros.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
a2714e3e42e746d6c8525c35fdcc58fb60c2830d 18-Jun-2012 H Hartley Sweeten <hartleys@visionengravers.com> staging: comedi: fix return value for insn_bits functions

The comedi_subdevice 'insn_bits' functions return the number of data
elements used to perform the command. Most of the insn_bits functions
return an open coded '2' to indicate this. The same value is available
as 'insn->n'. Return that instead to better indicate what the return
means.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Frank Mori Hess <fmhess@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
8b6c56949ffa83dbc2a6e8fa3f98b10a19372207 12-Jun-2012 H Hartley Sweeten <hartleys@visionengravers.com> staging: comedi: propogate error code from comedi_alloc_subdevices

comedi_alloc_subdevices can fail with -EINVAL or -ENOMEM. When it
does fail make sure to pass the proper error code back.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbott@mev.co.uk>
Cc: Frank Mori Hess <fmhess@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2f0b9d082e5d0056a3aca4be038483a564849196 12-Jun-2012 H Hartley Sweeten <hartleys@visionengravers.com> staging: comedi: export alloc_subdevices as comedi_alloc_subdevices

Move the inline alloc_subdevices() function from comedidev.h
to drivers.c and rename it to comedi_alloc_subdevices(). The
function is large enough to warrant being an exported symbol
rather than being an inline in every driver.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Frank Mori Hess <fmhess@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
061319698271bc80155cf3a67f0d5afed4024705 23-May-2012 H Hartley Sweeten <hartleys@visionengravers.com> staging: comedi: remove this_board macro in the dt282x driver

The 'this_board' macro depends on having a local variable with
a magic name. The CodingStyle document suggests not doing this
to avoid confusion. Remove the macro and use the comedi_board()
inline helper to get the dev->board_ptr information.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Mori Hess <fmhess@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
484ecc95d9cdfa8b2f7029e2f3409cf078aed4ab 18-May-2012 H Hartley Sweeten <hartleys@visionengravers.com> staging: comedi: cleanup all the comedi_driver 'detach' functions

1. Change the return type from int to void

All the detach functions, except for the comedi usb drivers, simply
return success (0). Plus, the return code is never checked in the
comedi core.

The comedi usb drivers do return error codes but the conditions can
never happen.

The first check is:

if (!dev)
return -EFAULT;

This checks that the passed comedi_device pointer is valid. The detach
function itself is called using this pointer so it MUST always be valid
or there is a bug in the core:

if (dev->driver)
dev->driver->detach(dev);

And the second check:

usb = dev->private;
if (!usb)
return -EFAULT;

The dev->private pointer is setup in the attach function to point to the
probed usb device. This value could be NULL if the attach fails. But,
since the comedi core is going to unload the driver anyway and does not
check for errors there is no gain by returning one.

After removing these checks from the comedi usb drivers the detach
functions required a bit of cleanup.

2. Remove all the printk noise in the detach functions

All of the printk output is really just noise. The user did a rmmod to
unload the driver, we really don't need to tell them about it.

Also, some of the messages are output using:

dev_dbg(dev->hw_dev, ...
or
dev_info(dev->hw_dev, ...

Unfortunately the hw_dev value is only used by drivers that are doing
DMA. For most drivers this variable is going to be NULL so the output
is not going to work as expected.

3. Refactor a couple static 'free_resource' functions into the detach
functions.

The 'free_resource' function is only being called by the detach and it
makes more sense to just absorb the code.

4. Remove a couple unnecessary braces for single statements.

5. Remove unnecessary comments.

Most of the comedi drivers appear to be based on the comedi skel driver
and have the comments from that driver included. These comments make
sense in the skel driver for reference but they don't need to be in any
of the actual drivers.

6. Remove all the extra whitespace.

It's not needed to make the functions any more readable.

7. Remove the now unused 'attached_successfully' variable in the
cb_pcimdda driver.

This variable was only used to conditionally output some driver noise
during the detach. Since all the printk's have been removed this
variable is no longer necessary.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Mori Hess <fmhess@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
e0eaa10d4d23e35a2bf6ac4b3dff81ae30b0d7e5 05-May-2012 H Hartley Sweeten <hartleys@visionengravers.com> staging: comedi: refactor dt282x driver to remove forward declarations

Move the struct comedi_driver and variables to the end of the
source. This is more typical of how other drivers are written and
removes the need for the forward declarations.

Convert the driver to use the module_comedi_driver() macro which
makes the code smaller and a bit simpler.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Mori Hess <fmhess@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
542038f4df5a9d5d806a4af8725d2d21c4423a15 20-Apr-2012 H Hartley Sweeten <hartleys@visionengravers.com> staging: comedi: use ARRAY_SIZE instead of custom n_boardtypes macros

The n_boardtypes macros are simply open-coded versions of the kernels
ARRAY_SIZE macro. Use the kernel provided macro.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Frank Mori Hess <fmhess@users.sourceforge.net>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
845d131e2b363717d8ac8db2c6b4417de8cf10b5 09-Jun-2011 Greg Kroah-Hartman <gregkh@suse.de> Staging: comedi: add #include <linux/io.h> to a bunch of drivers

On some arches the function virt_to_bus() wasn't being pulled in due to
include chains being different. So, as we are explicitly calling this
function, explicitly include the proper header file so all will build
properly.

Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
7114a28011f9d5f3d981731ad341177c21f9d948 06-Jun-2010 Arun Thomas <arun.thomas@gmail.com> Staging: comedi: Remove COMEDI_INITCLEANUP macro

Move the init/exit routines to the respective C source files
instead of calling COMEDI_INITCLEANUP

Signed-off-by: Arun Thomas <arun.thomas@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
90f703d30dd3e0c16ff80f35e34e511385a05ad5 06-Jun-2010 Arun Thomas <arun.thomas@gmail.com> Staging: comedi: Remove COMEDI_MODULES_MACRO

Add MODULE_AUTHOR, MODULE_LICENSE, and MODULE_DESCRIPTION calls
to the respective C source files instead of calling COMEDI_MODULES_MACRO

Signed-off-by: Arun Thomas <arun.thomas@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
18e7e78e945527d9cb570a17f0835815f1794c2f 29-Apr-2010 Iain Churcher <iain.linux.coding@googlemail.com> Staging: comedi: numerous checkpatch.pl issues in dt282x.c

This patch cleans up numerous WARNINGS and ERRORS listed by the
checkpatch.pl tool

Signed-off-by: Iain Churcher <iain.linux.coding@googlemail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
5a0e3ad6af8660be21ca98a971cd00f331318c05 24-Mar-2010 Tejun Heo <tj@kernel.org> include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h

percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.

percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.

http://userweb.kernel.org/~tj/misc/slabh-sweep.py

The script does the followings.

* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.

* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.

* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.

The conversion was done in the following steps.

1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.

2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.

3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.

4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.

5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.

6. percpu.h was updated not to include slab.h.

7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).

* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig

8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.

Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.

Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
828684f9a6e096f9150bad523c43b75d74b9badd 29-Sep-2009 Dirk Hohndel <hohndel@infradead.org> Staging: comedi: trivial fix of a very frequent spelling mistake

something-bility is spelled as something-blity so a grep for 'blit'
would find these lines

this is so trivial that I didn't split it by subsystem / copy additional
maintainers - all changes are to comments The only purpose is to get
fewer false positives when grepping around the kernel sources.

Signed-off-by: Dirk Hohndel <hohndel@infradead.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
0a85b6f0ab0d2edb0d41b32697111ce0e4f43496 08-Jun-2009 Mithlesh Thukral <mithlesh@linsyssoft.com> Staging: Comedi: Lindent changes to comdi driver in staging tree

Lindent changes to comdi driver in staging tree.
This patch is followed by the checkpatch.pl error fixes.
Did not make them part of this patch as the patch size is already huge.

Signed-off-by: Mithlesh Thukral <mithlesh@linsyssoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
5f74ea14c07fee91d3bdbaad88bff6264c6200e6 27-Apr-2009 Greg Kroah-Hartman <gregkh@suse.de> Staging: comedi: remove comedi-specific wrappers

There are a number of comedi "wrappers" for some RT functions that are
about to go away. This patch removes all of the wrapper calls within
the comedi drivers and core in order to prepare for removing the RT
comedi code.

Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Frank Mori Hess <fmhess@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
68c3dbff9fc9f25872408d0e95980d41733d48d0 23-Apr-2009 Bill Pemberton <wfp5p@virginia.edu> Staging: comedi: fix the way structs are initialized.

Change from the foo: bar format to the .foo = bar format.

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
c3744138715045adb316284ee7a1e608f0278f6c 23-Apr-2009 Bill Pemberton <wfp5p@virginia.edu> Staging: comedi: remove assignment in conditionals

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
53106ae68acf6eda9593150a25fc44e30fd5ff68 09-Apr-2009 Bill Pemberton <wfp5p@virginia.edu> Staging Comedi: fix spacing around parens

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
f7cbd7aad063b2a4b7aff6a743b2b00015ce3c3e 09-Apr-2009 Bill Pemberton <wfp5p@virginia.edu> Staging: comedi: Add spaces after commas

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
da91b2692e0939b307f9047192d2b9fe07793e7a 09-Apr-2009 Bill Pemberton <wfp5p@virginia.edu> Staging: comedi: fix "foo * bar" should be "foo *bar"

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
70265d24e3404fe798b6edd55a02016b1edb49d7 26-Mar-2009 Jiri Slaby <jirislaby@gmail.com> staging: comedi, remove interrupt.h

Remove interrupt wraparound. Use defines from linux/interrupt.h
instead.

Change also parameter types of functions taking ISR to irq_handler_t.

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Frank Mori Hess <fmhess@users.sourceforge.net>
Cc: David Schleef <ds@schleef.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
68b08cdad78c79fc87df52f8c8d4adf60ec5d7fc 17-Mar-2009 Bill Pemberton <wfp5p@virginia.edu> Staging: comedi: Remove dt282x_private typedef

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
98484c1ae621eb784c4b2a7dd6c76a069bad6214 17-Mar-2009 Bill Pemberton <wfp5p@virginia.edu> Staging: comedi: Remove boardtype_t typedef in dt282x.c

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
0707bb04be89b18ee83b5a997e36cc585f0b988d 17-Mar-2009 Bill Pemberton <wfp5p@virginia.edu> Staging: comedi: Remove comedi_devconfig typedef

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
90035c0886b256d75bced13b3b3cea5234aff136 17-Mar-2009 Bill Pemberton <wfp5p@virginia.edu> Staging: comedi: Remove comedi_insn typedef

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
ea6d0d4cab4f4f2d6a88f3bce4707fe92696fd3f 17-Mar-2009 Bill Pemberton <wfp5p@virginia.edu> Staging: comedi: Remove comedi_cmd typedef

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
9ced1de69125b60f40127eddaa3be2a92bb0a1df 17-Mar-2009 Bill Pemberton <wfp5p@virginia.edu> Staging: comedi: Remove comedi_lrange typedef

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
139dfbdfacb02e3ef3df936d2fabd1ad5f14ea88 17-Mar-2009 Bill Pemberton <wfp5p@virginia.edu> Staging: comedi: Remove comedi_driver typedef

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
34c43922e62708d45e9660eee4b4f1fb7b4bf2c7 17-Mar-2009 Bill Pemberton <wfp5p@virginia.edu> Staging: comedi: Remove comedi_subdevice typedef

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
71b5f4f11971dea972832ad63a994c7e5b45db6b 17-Mar-2009 Bill Pemberton <wfp5p@virginia.edu> Staging: comedi: Remove comedi_device typedef

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
790c55415aa31f4c732729f94d2c3a54f7d3bfc2 17-Mar-2009 Bill Pemberton <wfp5p@virginia.edu> Staging: comedi: Remove lsampl_t and sampl_t typedefs

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
8d3d823c74a4c967b4a02e6466c6727ad21422a0 19-Feb-2009 David Schleef <ds@schleef.org> Staging: comedi: add dt282x driver

Driver for DataTranslation DT2821 series cards

From: David Schleef <ds@schleef.org>
Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Frank Mori Hess <fmhess@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>