Commit graph

8093 commits

Author SHA1 Message Date
Aybuke Ozdemir 72315cdaba Staging: comedi: Prefer using the BIT macro
Replace all instances of bit shifting on 1 with the BIT(x) macro. In
addition, convert other non-1 shift operations with the equivalent
BIT(x) macro for uniformity. Issue pointed out by checkpatch.

CHECK: Prefer using the BIT macro

Signed-off-by: Aybuke Ozdemir <aybuke.147@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-11 19:47:27 -08:00
Janani Ravichandran e563637b5f staging: comedi: Use ARRAY_SIZE for sizes of arrays
Use ARRAY_SIZE to calculate the size of an array to make code concise.
The semantic patch used can be found here:
9cbab452a3

Signed-off-by: Janani Ravichandran <janani.rvchndrn@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-11 19:47:27 -08:00
Ian Abbott 222c402abf staging: comedi: comedi.h: remove SDF_MODE0 etc.
The macros `SDF_MODE0`, `SDF_MODE1`, `SDF_MODE2`, `SDF_MODE3`, and
`SDF_MODE4` are COMEDI subdevice flags originally associated with the
obsolete (and no longer present) COMEDI "trigger" functionality.  They
have been of no use since COMEDI release 0.7.61 back in November 2001.
Since they were going spare, a couple of them have been aliased as
`SDF_PWM_COUNTER` and `SDF_PWM_HBRIDGE` to mean other things.  Remove
the obsolete macros and redefine `SDF_PWM_COUNTER` and `SDF_PWM_HBRIDGE`
as equivalent numeric values.

Some code distributed with the userspace COMEDILIB library uses the
`SDF_MODE0` etc. flags to display the fact that they are set, but
COMEDILIB uses and installs its own, compatible version of "comedi.h"
anyway so isn't affected by their removal from the kernel copy.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-11 19:42:00 -08:00
Ian Abbott 75aa1ca7f7 staging: comedi: comedi.h: remove struct comedi_trig
Remove `struct comedi_trig` and some associated macros, `TRIG_DITHER`,
`TRIG_DEGLITCH`, `TRIG_CONFIG`, and ioctl code `COMEDI_TRIG`.  These
have been obsolete since COMEDI release 0.7.61 back in November 2001.

The userspace COMEDILIB library still has some deprecated code that
may attempt to use these, but it uses its own, compatible version of
"comedi.h", so isn't affected by their removal from the kernel copy.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-11 19:42:00 -08:00
Ian Abbott ace7aa7f64 staging: comedi: comedi.h: add kernel-doc comments to struct types
Add "kernel-doc"-formatted comments to the COMEDI `struct` declarations
used with ioctls.  Don't bother documenting `struct comedi_trig` as it
is obsolete and not supported.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-11 19:42:00 -08:00
Ian Abbott 8fb02b2947 staging: comedi: comedi.h: add kernel-doc to common enums
Add "kernel-doc"-formatted comments to COMEDI's general-purpose `enum`
type declarations.  Don't bother documenting the low-level
driver-specific ones for now.

Move the declaration of `enum comedi_counter_status_flags` next to the
other general-purpose `enum` types.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-11 19:42:00 -08:00
Ian Abbott 2892ffc2ec staging: comedi: comedi.h: tweak start of header comment
The wording at the start of the header comment is a bit misleading,
particularly the part in parentheses: "(installed as
/usr/include/comedi.h)".  This version of "comedi.h" certainly won't be
installed as that pathname.  Fix it.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-11 19:42:00 -08:00
Pablo G. Gallardo 0e05c02735 STAGING: COMEDI: Wrap line over 80 characters
This patch wraps lines over 80 characters.

Signed-off-by: Pablo G. Gallardo <pggllrd@gmail.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-07 18:38:37 -08:00
Pablo G. Gallardo b9491eab37 STAGING: COMEDI: Remove unnecessary typecast of c90 int constant
This patch removes unnecessary typecast of c90 int constant.

Signed-off-by: Pablo G. Gallardo <pggllrd@gmail.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-07 18:38:37 -08:00
Spencer E. Olson f164cbf98f staging: comedi: ni_mio_common: add finite regeneration to dio output
This patch continues the implementation of reinterpreting stop_arg when
stop_src == TRIG_NONE for national instruments cdio output on e/m-series
devices.  This is part of a series of patches that allow a user to have a
specific buffer repeated as-is indefinitely.  The contents of the DMA
buffer can be left static or changed by the user via mmap access to the DMA
buffer.  If the contents are changed by the user, additional munging is not
performed by the driver and only a single call to
comedi_mark_buffer_written should be done.  The original behavior is
preserved when stop_arg == 0, as would be the prior use case.

As opposed to analog output, this patch is relatively simple.  First, the
digital output capabilities are much more limited/simple as compared to the
analog output device on NI e/m-series hardware, and second, this patch
relies on changes made with the earlier patch to accomplish limiting the
DMA buffer transfer.

Signed-off-by: Spencer E. Olson <olsonse@umich.edu>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-07 18:38:08 -08:00
Spencer E. Olson 6aab7fee7a staging: comedi: ni_mio_common: adds finite regeneration to AO output
This patch implements for analog output the reinterpretation of stop_arg
when stop_src == TRIG_NONE to allow the user to specify the length of the
buffer that should be repeated.  The intent is to allow a user to have a
specific buffer repeated as-is indefinitely.  The contents of the DMA
buffer can be left static or changed by the user via mmap access to the DMA
buffer.  If the contents are changed by the user, additional munging is not
performed by the driver and only a single call to
comedi_mark_buffer_written should be done.

Signed-off-by: Spencer E. Olson <olsonse@umich.edu>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-07 18:38:08 -08:00
Spencer E. Olson 080e6795cb staging: comedi: ni_mio_common: Cleans up/clarifies ni_ao_cmd
This patch implements ni_ao_cmd much more closely organized like NI MHDDK
examples and DAQ-STC pseudo-code.  Adds comments with some more specific
references to the DAQ-STC.

For stop_src==TRIG_NONE (continuous output mode of entire buffer), the
count for the UC counter was corrected to represent the maximum count
possible (0xffffff).  Prior behavior for stop_src=TRIG_NONE did not
actually follow the DAQ-STC.  Furthermore, stop_src==TRIG_NONE now
correctly uses code specialized for either m-series or e-series devices.

It should be noted that stop_src==TRIG_NONE does _not_ with this patch
(or with prior behavior in ni_mio_common) actually implement true
continuous output.  Rather, the output is simply configured to operate as a
single buffer output, but where the buffer is as large as is possible with
NI-STC hardware.

Signed-off-by: Spencer E. Olson <olsonse@umich.edu>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-07 18:38:08 -08:00
Spencer E. Olson d2a6c32a22 staging: comedi: ni_mio_common: make more bits in ao_cmd1 reg be stateful
Bits NISTC_AO_CMD1_DAC0_UPDATE_MODE and NISTC_AO_CMD1_DAC1_UPDATE_MODE are
now saved in the local copy of the AO_CMD1 register.  This is more
appropriate than prior methods of setting these bits specifically _both_
in the ni_ao_cmd configuration function _and_ the ni_ao_inttrig trigger
function.  With this patch, the bits are only specifically called out now
in the ni_ao_cmd configuration function.  In the ni_ao_inttrig trigger
function, only the UI_ARM, UC_ARM, BC_ARM bits of the ao_cmd1 register are
specifically called out.  Each of these bits is a strobe bit, while the
DAC[0-1]_UPDATE_MODE bits are simple write bits.

Signed-off-by: Spencer E. Olson <olsonse@umich.edu>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-07 18:38:08 -08:00
Spencer E. Olson 5c93736c20 staging: comedi: ni_mio_common: Cleans up/clarifies ni_ao_reset
This patch implements ni_ao_reset much more closely organized like NI MHDDK
examples and DAQ-STC pseudo-code.  Adds comments with some more specific
references to the DAQ-STC.

Signed-off-by: Spencer E. Olson <olsonse@umich.edu>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-07 18:38:08 -08:00
Spencer E. Olson 5b293beb2e staging: comedi: mite: enable continuous regeneration of finite samples
This change enables the mite DMA controller to only transfer the amount of
data needed by a command.  By default, the old behavior of transferring the
entire comedi DMA data buffer is still in effect.  These changes allow a
command to only transmit a limited portion of that data buffer as needed.

This patch begins to reinterprets stop_arg when stop_src == TRIG_NONE to
allow the user to specify the length of the buffer that should be repeated.
The intent is to allow a user to have a specific buffer repeated as-is
indefinitely.  The contents of the DMA buffer can be left static or changed
by the user via mmap access to the DMA buffer.  If the contents are changed
by the user, additional munging is not performed by the driver and only a
single call to comedi_mark_buffer_written should be done.

Signed-off-by: Spencer E. Olson <olsonse@umich.edu>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-07 18:38:08 -08:00
Spencer E. Olson f08a28e65c staging: comedi: ni_mio_common: use CR_CHAN more consistently
Generally, the CR_CHAN macro is/should be used to access the relevant bits
for channel identification in cmd->*_arg when the corresponding
cmd->*_src==TRIG_EXT, including cmd->convert_arg in this case.

This patch does not fix a bug per se, as NISTC_AI_MODE1_CONVERT_SRC() already
masks the value sufficiently, but using CR_CHAN() here makes the code clearer as
it avoids passing some irrelevant bits to NISTC_AI_MODE1_CONVERT_SRC() in the
first place.

Signed-off-by: Spencer E. Olson <olsonse@umich.edu>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-07 18:35:16 -08:00
Spencer E. Olson 1fd24a4702 staging: comedi: ni_tiocmd: change mistaken use of start_src for start_arg
This fixes a bug in function ni_tio_input_inttrig().  The trigger number
should be compared to cmd->start_arg, not cmd->start_src.

Fixes: 6a760394d7 ("staging: comedi: ni_tiocmd: clarify the cmd->start_arg validation and use")
Cc: <stable@vger.kernel.org> # 3.17+
Signed-off-by: Spencer E. Olson <olsonse@umich.edu>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-07 18:35:16 -08:00
Spencer E. Olson d463130122 staging: comedi: ni_pcimio: Adds PXI-6251 to supported boards
Signed-off-by: Spencer E. Olson <olsonse@umich.edu>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-07 18:35:16 -08:00
Bhaktipriya Shridhar 65dc150796 staging: comedi: dt2801: Prefer using the BIT macro
As suggested by checkpatch.pl, this patch replaces bit shifting on 1 with the
BIT(x) macro.

Signed-off-by: Bhaktipriya Shridhar <bhaktipriya96@gmail.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-07 18:35:16 -08:00
Moritz König f6e9b91433 STAGING: COMEDI: Using kernel types in plx9080.h
This patch makes plx9080.h use kernel types.

Signed-off-by: Moritz König <moritz.koenig@fau.de>
Signed-off-by: Fabian Lang <fabian.lang@fau.de>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Acked-by: Moritz Fischer <moritz.fischer@ettus.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-12-21 16:02:21 -08:00
Moritz König e0bcce6b3a STAGING: COMEDI: Added spaces around binary operators in plx9080.h
This patch adds spaces around binary operators in plx9080.h.

Signed-off-by: Moritz König <moritz.koenig@fau.de>
Signed-off-by: Fabian Lang <fabian.lang@fau.de>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-12-21 16:02:21 -08:00
Moritz König e554840c94 STAGING: COMEDI: Fixed format of comments in plx9080.h
This patch fixes the format of comments in plx9080.h.

Signed-off-by: Moritz König <moritz.koenig@fau.de>
Signed-off-by: Fabian Lang <fabian.lang@fau.de>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-12-21 16:02:21 -08:00
Jitendra Kumar Khasdev 2acc980bc6 staging: comedi: comedilib.h: Coding style warning fix for block comments
This patch is to comedilib.h file that fixes up following warnings
reported by checkpatch.pl :
I) Block comments use * on subsequent lines.

Apart from it I have remove header file path by base file name as
suggested by community.

Signed-off-by: Jitendra Kumar Khasdev <jkhasdev@gmail.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-12-21 16:01:12 -08:00
Ian Abbott e5417e4996 staging: comedi: s526: add macros for counter control reg values
The driver writes a couple of literal values to the counter
control/status register, 0x8000 to reset the counter, and 0x4000 to load
the counter from preload register 0.  Add a bunch of macros to define
these values and other values for the register, based on the Sensoray
526 manual.

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>
2015-12-21 16:00:12 -08:00
Ian Abbott 479bd5edab staging: comedi: s526: replace counter mode bitfield struct
The driver uses `struct counter_mode_register_t` to describe the 16-bit
counter mode register as a sequence of bitfield members.  The struct
appears as the type of one of the members of `union cmReg`, the other
member of which is of type `unsigned short`, so the driver can
manipulate the register value as a whole, or as individual fields.
Although this is fairly convenient, it's not that conventional.  The
code also needs to define the bitfield members in ascending or
descending order of the physical bits, depending on whether bitfields
are little- or big-endian.

Rip all that out and replace it with a bunch of macros to set and mask
out bits of the register value, as that's the more conventional way to
do it.  A bonus is that we get rid of a load of CamelCase definitions in
the process.

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>
2015-12-21 16:00:12 -08:00
Ian Abbott 28a60c456b staging: comedi: check for more errors for zero-length write
If the "write" file operation handler, `comedi_write()` is passed 0 for
the amount to write, some error conditions are currently skipped and the
function just returns 0.  Change it to check those error conditions and
return an error value if appropriate.  The trickiest case is the check
for when the previously set up asynchronous command has terminated with
an error.  In that case, `-EPIPE` is returned (as it is for a write of
non-zero length) and the subdevice gets marked as non-busy.

A zero-length write that returns 0 has no other effects, in particular,
it does not cause the subdevice to be marked as non-busy.

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>
2015-12-21 15:58:54 -08:00
Ian Abbott 3318c7add8 staging: comedi: simplify returned errors for comedi_write()
In order to perform a "write" file operation, an asynchronous COMEDI
command in the "write" direction needs to have been set up by the
current file object on the COMEDI "write" subdevice associated with the
file object.  If there is a "write" subdevice, but a command has not
been set up by the file object (or is has been set-up in the wrong
direction), `comedi_write()` currently returns one of two error values
`-EINVAL` or `-EACCES`.  `-EACCES` is returned if the command was set up
by a different subdevice, or somewhat randomly, if a COMEDI
"instruction" is currently being processed.  `-EINVAL` is returned in
other cases.  Simplify it by returning `-EINVAL` for all these cases.

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>
2015-12-21 15:58:54 -08:00
Ian Abbott 40d0e80e08 staging: comedi: return error on "write" if no command set up
The "write" file operation handler, `comedi_write()` returns an error
for pretty much any condition that prevents a "write" going ahead.  One
of the conditions that prevents a "write" going ahead is that no
asynchronous command has been set up, but that currently results in a
return value of 0 (unless COMEDI instructions are being processed or an
asynchronous command has been set up by a different file object).
Change it to return `-EINVAL` in this case.

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>
2015-12-21 15:58:54 -08:00
Ian Abbott 35a7475dc8 staging: comedi: allow buffer wraparound in comedi_write()
`comedi_write()` copies data from the user buffer to the acquisition
data buffer, which is cyclic, using a single call to `copy_from_user()`.
It currently avoids having to deal with wraparound of the cyclic buffer
by limiting the amount it copies (and the amount returned to the user).
Change it to deal with the wraparound using two calls to
`copy_from_user()` if necessary.

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>
2015-12-21 15:58:54 -08:00
Ian Abbott 591c5f8a59 staging: comedi: avoid bad truncation of a size_t in comedi_write()
At one point in `comedi_write()`, the variable `n` gets assigned to the
minimum of the parameter `nbytes` and the amount of writeable buffer
space.  The way that is done currently is unsafe in the unlikely case
that `nbytes` exceeds `UINT_MAX`, so fix it.

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>
2015-12-21 15:58:54 -08:00
Ian Abbott 84a185ec42 staging: comedi: make some variables unsigned in comedi_write()
In `comedi_write()`, the `n` and `m` variables are of type `int`.
Change them to `unsigned int` as they are used to measure a positive
number of bytes.  The `count` variable is also of type `int` and holds
the returned number of bytes written.  Change it to type `ssize_t` to
match the function's return type.

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>
2015-12-21 15:58:54 -08:00
Ian Abbott ed65bba31b staging: comedi: do extra checks for becoming non-busy for "write"
`comedi_write()` is the handler for the "write" file operation for
COMEDI devices.  It mostly runs without using the main mutex of the
COMEDI device, but uses the `attach_lock` rw_semaphore to protect
against the COMEDI device becoming "detached".  A file object can write
data for a COMEDI asynchonous command if it initiated the command.  The
COMEDI subdevice is marked as busy when the command is started.  At some
point, the "write" handler detects that the command has terminated and
so marks the subdevice as non-busy.

In order to mark the subdevice as non-busy, the "write" handler needs to
release the `attach_lock` rw_semaphore and `acquire the main `mutex`.
There is a vulnerable point between the two, so it checks that the
device is still attached after acquiring the mutex.  However, it does
not currently check that the conditions for becoming non-busy still
hold.  Add some more checks that the subdevice is still busy with a
command initiated by the same file object, and that the command is in
the correct direction (in case the subdevice supports both "read" and
"write").

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>
2015-12-21 15:58:54 -08:00
Ian Abbott 06181de14f staging: comedi: rearrange comedi_write() code
Rearrange the code in `comedi_write()` to reduce the amount of
indentation.  The code never reiterates the `while` loop once `count`
has become non-zero, so we can check that in the `while` condition to
save an indentation level.  (Note that `nbytes` has been checked to be
non-zero before entering the loop, so we can remove that check.)  Move
the code that makes the subdevice "become non-busy" outside the `while`
loop, using a new flag variable `become_nonbusy` to decide whether it
needs to be done.  This simplifies the wait queue handling so there is a
single place where the task is removed from the wait queue, and we can
remove the `on_wait_queue` flag variable.

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>
2015-12-21 15:58:54 -08:00
H Hartley Sweeten b4717ff608 staging: comedi: adv_pci_dio: 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>
2015-12-21 15:57:40 -08:00
H Hartley Sweeten bb263fd5d3 staging: comedi: adv_pci_dio: tidy up the comedi comment block
The Description is a bit long winded and the same information is in
the Devices. Shorten the Description and tidy up the Devices.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-12-21 15:57:40 -08:00
H Hartley Sweeten d97e1552fd staging: comedi: adv_pci_dio: move pci_dio_override_cardtype()
This function is called as part of the pci_driver (*probe) before
doing the (*auto_attach) of the comedi driver. For aesthetics, move
the function to a more logical place 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>
2015-12-21 15:57:40 -08:00
H Hartley Sweeten a54b6e60f3 staging: comedi: adv_pci_dio: move and rename the MAX_*_SUBDEV[SG] defines
For aesthetics, move these defines after the register defines and rename
them to 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>
2015-12-21 15:57:40 -08:00
H Hartley Sweeten 2b60bbde04 staging: comedi: adv_pci_dio: move and rename enum hw_cards_id
For aesthetics, move this enum after the register defines and rename
it to 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>
2015-12-21 15:57:40 -08:00
H Hartley Sweeten bcae0adaf4 staging: comedi: adv_pci_dio: remove boardinfo 'cardtype'
This member of the boardinfo is identical to the offset of the boardinfo
in the boardtypes array. It's also passed as the 'context' to the driver
(*auto_attach).

The 'cardtype' is only needed by the (*auto_attach) to determine which
PCI BAR to use and in pci_dio_reset() to handle the board specific code.

Remove the 'cardtype' member and use the 'context' value instead.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-12-21 15:57:40 -08:00
H Hartley Sweeten d0b5860c27 staging: comedi: adv_pci_dio: cleanup PCI-1762 interrupt registers
For aesthetics, use a common define for the interrupt control and status
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>
2015-12-21 15:57:40 -08:00
H Hartley Sweeten 6a1c0149a4 staging: comedi: adv_pci_dio: rename PCI1752_6_CFC define
For aesthetics, rename this define and fix the alignment.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-12-21 15:57:40 -08:00
H Hartley Sweeten 008342ebfd staging: comedi: adv_pci_dio: cleanup PCI-175[46] interrupt registers
For aesthetics, replace these defines with a macro.

Refactor the switch in pci_dio_reset() to use common 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>
2015-12-21 15:57:40 -08:00
H Hartley Sweeten 774a8c57b1 staging: comedi: adv_pci_dio: cleanup PCI-1753 interrupt register defines
For aesthetics, replace these defines with some macros.

Refactor the switch in pci_dio_reset() to not require the fallthrough
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>
2015-12-21 15:57:40 -08:00
H Hartley Sweeten db2c830d46 staging: comedi: adv_pci_dio: use common defines for PCI-1739/175[01] registers
These boards use the same offsets for the interrupt control registers.
For aesthetics, remove the current defines and use common ones.

Fix the switch() in pci_dio_reset() to use common 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>
2015-12-21 15:57:40 -08:00
H Hartley Sweeten 86065e4d60 staging: comedi: adv_pci_dio: use common defines for PCI-173[036] registers
These boards use the same offsets for the interrupt control registers.
For aesthetics, remove the current defines and use common ones.

Fix the switch() in pci_dio_reset() to use common 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>
2015-12-21 15:57:40 -08:00
H Hartley Sweeten ac67a3b9ba staging: comedi: adv_pci_dio: cleanup "disable and clear interrupts" comments
For aesthetics, use a common comment for the switch() that disables and clears
interrupts.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-12-21 15:57:40 -08:00
H Hartley Sweeten c94a5991bf staging: comedi: adv_pci_dio: disable channel freeze outside of switch
For aesthetics, move the disable of the channel freeze for the PCI-1752
and PCI-1756 boards out of the switch used to disable and clear interrupts.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-12-21 15:57:40 -08:00
H Hartley Sweeten eaf1e647ef staging: comedi: adv_pci_dio: use a default case in pci_dio_reset()
For aesthetics, use a default case in the switch (board->cardtype) used
to reset the various boards.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-12-21 15:57:40 -08:00
H Hartley Sweeten 4cabeb10be staging: comedi: adv_pci_dio: remove defines used for the dio (8255) registers
These defines are only used to initialize the diosubd_data 'addr' members
in the boardinfo. For aesthetics, just open-code the values and remove the
defines.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-12-21 15:57:40 -08:00
H Hartley Sweeten 7f442292fa staging: comedi: adv_pci_dio: remove defines used for the do registers
These defines are only used to initialize the diosubd_data 'addr' members
in the boardinfo. For aesthetics, just open-code the values and remove the
defines.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-12-21 15:57:40 -08:00