History log of /drivers/staging/comedi/comedidev.h
Revision Date Author Comments
bfa9facdb13fb7bc47677bc8f590fc816ccd0c9a 15-Sep-2014 Ian Abbott <abbotti@mev.co.uk> staging: comedi: add comedi_read_array_from_buffer()

The "comedi_fc" module contains a few functions useful to Comedi
drivers. Their functionality is being migrated to the core "comedi"
module and renamed to start with the prefix `comedi_`. As part of this
migration, move `cfc_read_array_from_buffer()` into the core comedi
module and rename it to `comedi_read_array_from_buffer()`. Change the
external declaration of `cfc_read_array_from_buffer()` into an inline
function that calls `comedi_read_array_from_buffer()`.

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>
ea29c1d563a4d57db1c2955c22468a0947f110b0 15-Sep-2014 Ian Abbott <abbotti@mev.co.uk> staging: comedi: add comedi_write_array_to_buffer()

The "comedi_fc" module contains a few functions useful to Comedi
drivers. Their functionality is being migrated to the core "comedi"
module and renamed to start with the prefix `comedi_`. As part of this
migration, move `cfc_write_array_to_buffer()` into the core comedi
module and rename it to `comedi_write_array_to_buffer()`. Change the
external declaration of `cfc_write_array_to_buffer()` into an inline
function that calls `comedi_write_array_to_buffer()`.

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>
5a7803592409dc3b6ea3bce53a7517114f748dc8 15-Sep-2014 Ian Abbott <abbotti@mev.co.uk> staging: comedi: add comedi_handle_events()

The "comedi_fc" module contains a few functions useful to Comedi
drivers. Their functionality is being migrated to the core "comedi"
module and renamed to start with the prefix `comedi_`. As part of this
migration, move `cfc_handle_events()` into the core comedi module and
rename it to `comedi_handle_events()`. Change the external declaration
of `cfc_handle_events()` into an inline function that calls
`comedi_handle_events()`.

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>
2b4e1f632478f43bda1b38e04e0d740980fff1f3 15-Sep-2014 Ian Abbott <abbotti@mev.co.uk> staging: comedi: add comedi_inc_scan_progress()

The "comedi_fc" module contains a few functions useful to Comedi
drivers. Their functionality is being migrated to the core "comedi"
module and renamed to start with the prefix `comedi_`. As part of this
migration, move `cfc_inc_scan_progress()` into the core comedi module
and rename it to `comedi_inc_scan_progress()`. Change the external
declaration of `cfc_inc_scan_progress()` into an inline function that
calls `comedi_inc_scan_progress()`.

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>
f146fe63416de7162090a48135d33a2b74a4efcc 15-Sep-2014 Ian Abbott <abbotti@mev.co.uk> staging: comedi: add comedi_bytes_per_scan()

The "comedi_fc" module contains a few functions useful to Comedi
drivers. Their functionality is being migrated to the core "comedi"
module and renamed to start with the prefix `comedi_`. As part of this
migration, move `cfc_bytes_per_scan()` into the core comedi module and
rename it to `comedi_bytes_per_scan()`. Change the external declaration
of `cfc_bytes_per_scan()` into an inline function that calls
`comedi_bytes_per_scan()`.

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>
aee447566d08b7b0da482c4a9d8dc7a8332e4d69 12-Sep-2014 Ian Abbott <abbotti@mev.co.uk> staging: comedi: remove comedi_board()

All calls to the inline function `comedi_board()` in "comedidev.h" have
been removed, so remove the function.

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>
aac307f9dd5ce1fe651140a036ab4b0a0571b54a 26-Aug-2014 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: comedi_pci: introduce comedi_pci_detach()

Introduce a generic (*detach) function for comedi PCI drivers to handle
the boilerplate code needed to detach a PCI driver.

This function works similar to comedi_legacy_detach() where it will:

* free the dev->irq if it has been requested
* iounmap the dev->mmio addres if it has been ioremap'ed

The helper then calls comedi_pci_disable() to release the regions and
disable the PCI device.

Use the new helper directly for the (*detach) in the following cases:

* where comedi_pci_disable() is used directly for the (*detach)
* where the detach function is just boilerplate

Use the new helper in the (*detach) of the simpler PCI drivers. Call
the helper after disabling interrupts (reset) and before any additional
cleanup (kfree) to avoid any race conditions with 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>
d27620669209e3cc87f13449326eeb68229e4bd0 26-Aug-2014 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: add a 'readback' member to comedi_subdevice

The analog output hardware in most comedi drivers does not provide a
way to readback to last values written to the channels. In order to
provide an (*insn_read) for the analog output subdevice, the comedi
drivers save the last values for each channel in the private data.

Add a new member, 'readback', to the comedi_subdevice definition to
provide a common way to save these values.

Introduce a comedi core function, comedi_alloc_subdev_readback(), to
allocate the memory needed to save the values. This memory will be
automatically kfree'd when the driver is detached.

Introduce a comedi core function, comedi_readback_insn_read(), that
the comedi drivers can use for the (*insn_read) of a subdevice to
return the saved values for each channel.

This will allow removing the boilerplate in the comedi drivers to
return the saved values. In some drivers it will also allow removing
the private data completely.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
d7e6dc1338eebae3b324b9a99e9d03d80c43aaef 30-Jul-2014 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: add an 'mmio' member to comedi_device

All the comedi drivers that use memory mapped io currently have a
void __iomem * member in their private data for the driver. For
some of the drivers this is actually the only member in that data.

For convienence, add a new member to the comedi_device for this
void __iomem *.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
d546b8966e66b114809d4af14e2d837adeeec2fc 21-Jul-2014 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: comedidev.h: remove 'new_size' param from subdevice (*buf_change)

This parameter is never used by any of the comedi drivers that provide a
(*buf_change) callback. If the 'new_size' is needed in the callback it can
be found from the 's->async->prealloc_bufsz' as done in the ni_pcidio driver.

Remove the unused parameter.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
57a4f4cf409261b0330df909ad6fdb85cb096467 21-Jul-2014 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: comedidev.h: remove unused callbacks from comedi_subdevice

The 'do_lock' and 'do_unlock' callbacks are not used be any of the comedi
drivers or the comedi core. Just 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>
710a182b34e092184f051a8d6b08bdae0a18c16b 18-Jul-2014 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: comedidev.h: checkpatch.pl --strict cleanup

Fix the checkpatch.pl --strict issues:

CHECK: Please use a blank line after function/struct/union/enum declarations
CHECK: Alignment should match open parenthesis

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>
6b362f5bea0dfbb648656041a92f6a00b298f558 17-Jul-2014 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: remove 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.

All of the users of this function have been converted to use dev_err()
directly. Remove the now unused function.

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>
a8b677cb534c78e0aaa3c999891df07073e25566 14-Jul-2014 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: comedidev.h: introduce some 'range_is_external' helpers

The comedi_krange includes a flags member that currently identifies the
'units' of the range (RF_UNIT) and if the range is from an internal or
external source (RF_EXTERNAL).

Introduce some helper functions to check if a given range is from an
external source.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
cb3aadaec89109edb60d4829ce82e50b27cb4ce6 15-Jul-2014 Kinka Huang <kinkabrain@gmail.com> staging: comedi: removing not useful `else` after return

Signed-off-by: Kinka Huang <kinkabrain@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
f4f3f7cf27e7ae015672b59ec40c7deabeaf5d2e 20-Jun-2014 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: introduce comedi_buf_n_bytes_ready()

Introduce an inline helper to return the number of bytes that are
ready to read from the comedi_async buffer. Use the helper in the
comedi drivers that currently do the calculation as part of the
(*poll) operation.

Also, use the helper in comedi_fops where the calculation is used as
part of the subdevice going nonbusy.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
55d128bf999e355098630836c1add6119b9f2522 20-Jun-2014 Ian Abbott <abbotti@mev.co.uk> staging: comedi: describe struct comedi_async

Describe `struct comedi_async` in kerneldoc format. Expand on the
members involved in reading/writing the buffer.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
a5897f77607c52acb078b152b59fbe29ac92c640 27-May-2014 Ian Abbott <abbotti@mev.co.uk> staging: comedi: remove in_request_module

The `in_request_module` member of `struct comedi_device` is only ever
set to `false`, so remove the code that checks for it being `true` and
remove the member.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2891911a32e81942cefb1bbc1398f39e9fe76db5 06-May-2014 Ian Abbott <abbotti@mev.co.uk> staging: comedi: remove subdevice member of struct comedi_async

The `async` member of `struct comedi_subdevice` may point to a `struct
comedi_async` or may be NULL. The `subdevice` member of `struct
comedi_async` points back to the `struct comedi_subdevice` associated
with it in a one-to-one relationship.

All uses of the `subdevice` member of `struct comedi_async` apart from
its initialization have now been removed (by passing around a pointer to
the subdevice instead of to the "async" structure), so get rid of 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>
e9edef3a5454a19fd0d0c342cc88b6310b871a48 06-May-2014 Ian Abbott <abbotti@mev.co.uk> staging: comedi: pass subdevice to comedi_buf_read_n_available()

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

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>
f1df8662859e7edee134d3d77f241a32c9cfb8ef 06-May-2014 Ian Abbott <abbotti@mev.co.uk> staging: comedi: pass subdevice to comedi_buf_read_free()

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

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>
d13be55a37a136ee4274680308b7d0d7e3818bf3 06-May-2014 Ian Abbott <abbotti@mev.co.uk> staging: comedi: pass subdevice to comedi_buf_read_alloc()

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

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>
940dd35d5812ead0b93f3f2a1f44732ac069000b 06-May-2014 Ian Abbott <abbotti@mev.co.uk> staging: comedi: pass subdevice to comedi_buf_write_free()

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

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>
24e894bbf247ecdeed3ed2f77f658da756760f60 06-May-2014 Ian Abbott <abbotti@mev.co.uk> staging: comedi: pass subdevice to comedi_buf_write_alloc()

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

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>
2fadffc0bb2e0b33ebee72be172073f84624bc3d 06-May-2014 Ian Abbott <abbotti@mev.co.uk> staging: comedi: pass subdevice to comedi_buf_memcpy_from()

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

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>
00603a9c321e186bba000e01042529bf5cfe68a3 06-May-2014 Ian Abbott <abbotti@mev.co.uk> staging: comedi: pass subdevice to comedi_buf_memcpy_to()

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

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>
458c13e935d9f33fffb099e49ecb53c67ddd1a21 06-May-2014 Ian Abbott <abbotti@mev.co.uk> staging: comedi: pass subdevice to comedi_buf_get()

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

The function gets a sample value from 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>
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>
0cb4c151c3de6cfb649fd59142b144aeba77fc8b 25-Feb-2014 Monam Agarwal <monamagarwal123@gmail.com> Staging: comedi: Fix unnecessary space after function pointer

This patch fixes the following checkpatch.pl warning in comedidev.h
WARNING: Fix unnecessary space after function pointer

Signed-off-by: Monam Agarwal <monamagarwal123@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
915064086e0189ed2aa69fddf14718aabbb541cb 10-Feb-2014 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: introduce comedi_timeout()

Introduce a comedi core helper function to handle the boilerplate
needed by the drivers to busy- wait for a condition to occur.
Typically this condition is the analog input/output end-of-conversion
used with the comedi (*insn_read) and (*insn_write) operations.

To use this function, the drivers just need to provide a callback
that checks for the desired condition. The callback should return
0 if the condition is met or -EBUSY if it is still waiting. Any
other errno will be returned to the caller. If the timeout occurs
before the condition is met -ETIMEDOUT will be returned.

The parameters to the callback function are the comedi_device,
comedi_subdevice, and comedi_insn pointers that were passed to the
(*insn_read) or (*insn_write) as well as an unsigned long, driver
specific, 'context' that can be used to pass any other information
that might be needed in the callback. This 'context' could be anything
such as the register offset to read the status or the bits needed
to check the status. The comedi_timeout() function itself does not
use any of these parameters.

This will help remove all the crazy "wait this many loops" used by
some of the drivers. It also creates a common errno for comedi to
detect when a timeout occurs.

ADC/DAC conversion times are typically pretty fast, usually around
100K samples/sec (10 usec). A conservative timeout of 1 second is used
in comedi_timeout().

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>
04b565021a83ae1940f1f9b801d3ce5b5fc8ee1e 09-Jan-2014 Rostislav Lisovy <lisovy@gmail.com> comedi: Humusoft MF634 and MF624 DAQ cards driver

This patch adds Comedi driver for Humusoft MF634 (PCIe) and
MF624 (PCI) data acquisition cards. The legacy card Humusoft
MF614 is not supported. More info about the cards may be found
at http://humusoft.cz/produkty/datacq/
The driver was tested with both cards. Everything seems to work
properly. Just the basic functionality of the card (DIO, ADC, DAC)
is supported by this driver.

Signed-off-by: Rostislav Lisovy <lisovy@gmail.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
26901032089ecc6bba0ea9c04841e333e2ac8622 26-Nov-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: remove DPRINTK macro

All users of this macro have been converted to use dev_dbg(). Remove
the unused macro.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
d2601699d3381525d87cc7ccb3e886697c5af812 22-Nov-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: remove comedi_debug module parameter

Remove this module parameter and use the CONFIG_COMEDI_DEBUG option to
enable normal kernel debugging with -DDEBUG flag.

Remove the #undef DEBUG from all the comedi source files so they will
honour the -DDEBUG flag.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
af93da31634d6d55c9d313b5c49af8b272f7cb79 08-Nov-2013 Ian Abbott <abbotti@mev.co.uk> staging: comedi: protect buffer from being freed while mmapped

If a comedi device is automatically detached by `comedi_auto_unconfig()`
any data buffers associated with subdevices that support asynchronous
commands will be freed. If the buffer is mmapped at the time, bad
things are likely to happen! Prevent this by moving some of the buffer
details from `struct comedi_async` into a new, dynamically allocated,
and kref-counted `struct comedi_buf_map`. This holds a list of pages, a
reference count, and enough information to free the pages. The new
member `buf_map` of `struct comedi_async` points to a `struct
comedi_buf_map` when the buffer size is non-zero.

Provide a new helper function `comedi_buf_is_mapped()` to check whether
an a buffer is mmapped. If it is mmapped, the buffer is not allowed to
be resized and the device is not allowed to be manually detached by the
`COMEDI_DEVCONFIG` ioctl. Provide helper functions
`comedi_buf_map_get()` and `comedi_buf_map_put()` to manipulate the
reference count of the `struct comedi_buf_map`, which will be freed
along with its contents via the 'release' callback of the `kref_put()`
call. The reference count is manipulated by the vma operations and the
mmap file operation.

Now, when the comedi device is automatically detached, the buffer will
be effectively freed by calling `comedi_buf_alloc()` with a new buffer
size of 0. That calls local function `__comedi_buf_free()` which calls
`comedi_buf_map_put()` on the `buf_map` member to free it. It won't
actually be freed until the final 'put'.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
49445b9117a6e9ca9a741251784432a1da2f9919 08-Nov-2013 Ian Abbott <abbotti@mev.co.uk> staging: comedi: remove comedi_dev_from_minor()

The `comedi_dev_from_minor()` function is no longer used, so remove it.
Calls to it have either been replaced by calls to
`comedi_dev_get_from_minor()` or by using the `private_data` member of
the open file object.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
b449c1cad7e3acf80834d4bdb1b6241d5d8dd249 08-Nov-2013 Ian Abbott <abbotti@mev.co.uk> staging: comedi: add comedi_dev_get_from_minor()

Add function `struct comedi_device *comedi_dev_get_from_minor(unsigned
minor)`. This behaves like the existing `comedi_dev_from_minor()`
except that it also increments the `struct kref refcount` member (via
new helper function `comedi_dev_get()`) to prevent it being freed. If
it returns a valid pointer, the caller is responsible for calling
`comedi_dev_put()` to decrement the reference count.

Export `comedi_dev_get_from_minor()` and `comedi_dev_put()` as they will
be used by the "kcomedilib" module in addition to the "comedi" module
itself.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
5b13ed94a7d24fdc8abbac81e7e4d30ab22c6540 08-Nov-2013 Ian Abbott <abbotti@mev.co.uk> staging: comedi: add a kref to comedi device

Add a `struct kref refcount` member to `struct comedi_device` to allow
safe destruction of the comedi device. Only free the comedi device via
the 'release' callback `kref_put()`. Currently, nothing calls
`kref_put()`, so the safe destruction is ineffective, but this will be
addressed by later patches.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
ef77c0b2570623f1d72527cb1c6c3f3d3c59793e 08-Nov-2013 Ian Abbott <abbotti@mev.co.uk> staging: comedi: add detachment counter for validity checks

Add a member `detach_count` to `struct comedi_device` that is
incremented every time the device gets detached. This will be used in
some validity checks in the 'read' and 'write' file operations to make
sure the attachment remains valid.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2f3fdcd7ce935f6f2899ceab57dc8fe5286db3e1 08-Nov-2013 Ian Abbott <abbotti@mev.co.uk> staging: comedi: add rw_semaphore to protect against device detachment

The 'read' and 'write' file operations on comedi devices do not use the
main mutex in the `struct comedi_device` to avoid contention with ioctls
that may take a while to complete. However, it is necessary to protect
against the device being detached while the operation is in progress.
Add member `struct rw_semaphore attach_lock` to `struct comedi_device`
for this purpose and initialize it on creation.

The actual locking and unlocking will be implemented by subsequent
patches. Tasks that are attaching or detaching comedi devices will
write-acquire the new semaphore whilst also holding the main mutex in
the `struct comedi_device`. Tasks that wish to protect against the
comedi device being detached need to acquire either the main mutex, or
read-acquire the new semaphore, or both in that order.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
ab3cb2e30ec8223777f6ea4696ba24191ffc5c72 08-Nov-2013 Ian Abbott <abbotti@mev.co.uk> staging: comedi: add a couple of #includes to comedidev.h

Two structures defined in "comedidev.h" have an element of type
`spinlock_t`, so add `#include <linux/spinlock_types.h>` to declare it.
One structure has an element of type `struct mutex` so add `#include
<linux/mutex.h>` to declare it.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
c265be0121154709a0b16f13c87ff58245ba81bc 08-Nov-2013 Ian Abbott <abbotti@mev.co.uk> staging: comedi: remove unused command callback support

The 'kcomedilib' module used to provide functions to allow asynchronous
comedi commands to be set up from another kernel module, but now
commands can only be set up by ioctls from user space via the core
comedi module. Since support for commands initiated from kernel space
has been dropped, the `cb_func` and `cb_arg` members of `struct
comedi_async` are never set (although the `cb_mask` member is still used
to mask comedi events). The `SRF_USER` bit of the comedi subdevice
runflags is no longer needed to distinguish commands from user and
kernel space since they only come from user space.

Don't bother setting or testing the `SRF_USER` flag, and get rid of it,
along with the `cb_func` and `cb_arg` members.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
0a6fd02c1c0fe4ae872dc24260d569583363f52c 16-Oct-2013 Ian Abbott <abbotti@mev.co.uk> staging: comedi: use unsigned samples for comedi_buf_put()/get()

Sample values in comedi are generally represented as unsigned values.
`comedi_buf_put()` and `comedi_buf_get()` use a `short` to hold the
16-bit data value being transferred to or from the comedi buffer.
Change them to use `unsigned short` for consistency.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
cd94d281e9fa804c42a4e1b61f4430dbbf4cea18 07-Oct-2013 Ian Abbott <abbotti@mev.co.uk> staging: comedi: remove 'settling_time_0' from subdevice

The `settling_time_0` member of `struct comedi_subdevice` can be set by
a low-level comedi driver and will be copied to user-space as part of
the information provided by the `COMEDI_SUBDINFO` ioctl. No comedi
driver has ever set it; it's just been left at its initial value of 0.
Remove it to save a bit of space, and behave as though it is 0.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
64d9b1d293fef4854a759ad946c2b99a20cc197b 07-Oct-2013 Ian Abbott <abbotti@mev.co.uk> staging: comedi: remove unused 'channel flags' support

The `flags` and `flaglist` members of `struct comedi_subdevice` were
defined to supply "all-channel" flags via the `COMEDI_SUBDINFO` ioctl,
or "channel-specific" flags via the `COMEDI_CHANINFO` ioctls,
respectively. However, no comedi driver has ever set them.

It's not entirely clear how "all-channel" flags would differ from the
"subdevice" flags passed by `COMEDI_SUBDINFO`. It is conceivable that
"channel-specific" flags could be used to describe different analog
reference values (or whatever) supported by different channels.
Presumably these would use some sub-set of the `SDF_xxx` subdevice flag
values, or possibly the `CR_xxx` flag values that get packed into a
"chanspec" value (along with a channel number and range code). The
original intentions are lost in the mists of time.

For now, just remove the `flags` and `flaglist` members from `struct
comedi_subdevice` and behave as though they have been left at their
default values (0 or NULL) by the low-level comedi driver.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4916211615e21b1ae80632e57b6e0c8434b126fe 26-Sep-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: core: introduce comedi_chan_range_is_{bi,uni}polar()

Introduce two helper functions to check if a subdevice range_table_list
for a given channel/range is bipolar or unipolar.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
f0b215d6e8df3b595758b673543a96a013721d8f 18-Sep-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: core: introduce comedi_offset_munge()

The comedi core expects the data to/from analog subdevices to be
in offset binary coding. This means that a value of '0' represents
the most negative and a value of 's->maxdata' the most positive
signal of the analog subdevice.

Many comedi drivers require the data written to the analog outputs,
or returned from the analog inputs, be in two's complement format.

Introduce a helper function to munge the data for analog subdevices.
This function simply inverts the sign bit and masks the result by
's->maxdata' to keep the result in range for the subdevice. The
strange:

return val ^ s->maxdata ^ (s->maxdata >> 1);

is equivalent to:

return (val ^ ((s->maxdata + 1) >> 1) & s->maxdata;

as long as s->maxdata is a value of the form (1 << n) - 1. This
avoids the 32-bit unsigned overflow for a s->maxdata of 0xffffffff.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
05e60b13a36bf4b6bd4d724b2332d6c3a4023998 30-Aug-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: drivers: introduce comedi_dio_update_state()

The (*insn_bits) functions for DIO and DO subdevices typically use
the subdevice 's->state' to hold the current state of the output
channels. The 'insn' passed to these functions, INSN_BITS, specifies
two parameters passed in the 'data'.

data[0] = 'mask', the channels to update
data[1] = 'bits', the new state for the channels

Introduce a helper function to handle the boilerplate used to
update the internal state.

Note that the 'mask' is filtered by the 'chanmask' of the channels
actually supported by the subdevice. This is used to protect any
non-channel related bits that are stored in the subdevice state.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
e523c6c86232eb5564662aa17199c676d127bc5e 06-Aug-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: drivers: introduce comedi_dio_insn_config()

DIO subdevices always handle the INSN_CONFIG_DIO_{INPUT,OUTPUT} instructions
to configure the DIO channels. They also always handle the INSN_CONFIG_DIO_QUERY
instruction to query the configuration of a DIO channel.

Introduce a helper function to handle the (*insn_config) boilerplate for
comedi DIO subdevices. This function has the same paramters as (*insn_config)
functions with an additional parameter to allow the caller to pass a 'mask'
value for grouped DIO channels.

This function returns:

0 if the instruction was successful but requires additional handling by
the caller (INSN_CONFIG_DIO_{INPUT,OUTPUT}

insn->n if the instruction was handled (INSN_CONFIG_DIO_QUERY)

-EINVAL for all unhandled instructions

The caller is responsible for actually configuring the hardware based on
the configuration (s->io_bits).

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
99ac7cccb50fcbacdc21620a898e6d64b58a2282 13-Aug-2013 Greg Kroah-Hartman <gregkh@linuxfoundation.org> Revert "staging: comedi: core: introduce comedi_dio_insn_config()"

This reverts commit 4f76463d3b8f8cc0cac5bb292ec766848f3f4fa1.

I applied an incorrect version here as well :(

Cc: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4f76463d3b8f8cc0cac5bb292ec766848f3f4fa1 06-Aug-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: core: introduce comedi_dio_insn_config()

DIO subdevices always handle the INSN_CONFIG_DIO_{INPUT,OUTPUT} instructions
to configure the dio channels. They also always handle the INSN_CONFIG_DIO_QUERY
instruction to query the configuration of a dio channel.

Introduce a helper function to handle the (*insn_config) boilerplate for
comedi DIO subdevices. This function has the same parameters as (*insn_config)
functions with an additional parameter to allow the caller to pass a 'mask'
value for grouped dio channels.

This function returns:

0 if the instruction was successful but requires additional handling by
the caller (INSN_CONFIG_DIO_{INPUT,OUTPUT}

insn->n if the instruction was handled (INSN_CONFIG_DIO_QUERY)

-EINVAL for all unhandled instructions

The caller is responsible for actually configuring the hardware based on
the configuration (s->io_bits).

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
12197de2cdb2ded83db7b5a3a06f4b275fb8e62c 16-Jul-2013 Ian Abbott <abbotti@mev.co.uk> pci_ids.h: move PCI_VENDOR_ID_AMCC here

PCI_VENDOR_ID_AMCC is defined locally in
"drivers/staging/comedi/comedidev.h" for a few comedi hardware drivers,
namely "adl_pci9118", "addi_apci_1500" and "addi_apci_3120" (also
"addi_apci_1710" but that is not currently built and will probably be
removed soon). Move the define into "include/linux/pci_ids.h" as it is
shared by several drivers (albeit all comedi drivers currently).

PCI_VENDOR_ID_AMCC happens to have the same value (0x10e8) as
PCI_VENDOR_ID_ADDIDATA_OLD. The vendor ID is actually assigned to
Applied Micro Circuits Corporation and Addi-Data were using device IDs
assigned by AMCC on some of their earlier PCI boards. The
PCI_VENDOR_ID_ADDIDATA_OLD define is still being used by the "8250_pci"
PCI serial board driver.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
99c0e2691736d56190764bfdc59f11b090cda4ff 27-Jun-2013 Ian Abbott <abbotti@mev.co.uk> staging: comedi: return void from comedi_driver_unregister()

'Unregister' functions generally return `void`.
`comedi_driver_unregister()` currently returns an `int` errno value.
Nothing looks at the return value. Change the return type to `void`.

Signed-off-by: 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>
54db996e6dab51571718e8e97c26fdc695e254ac 25-Jun-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: drivers: introduce comedi_alloc_devpriv()

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

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
0480bcb9fb5e279df9d39f21bb0e87ab15b5092a 20-Jun-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: have comedi_set_spriv() allocate the memory

As suggested by Ian Abbott, comedi_set_spriv() can only be used to
set the subdevice->private pointer to something that can be kfree()'d.
Rename the function to comedi_alloc_spriv() and have it kzalloc() the
memory as well as set the private pointer. This saves a function call
in the drivers and avoids the possibility of incorrectly calling
comedi_set_spriv() for some pointer that is not meant to be kfree()'d.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
588ba6dc5fb4bdca47a3da38c2718fbb82d3eee1 11-Jun-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: drivers: let core handle freeing s->private

Introduce a new subdevice runflags, SRF_FREE_SPRIV, and a new helper
function, comedi_set_spriv(), that the drivers can use to set the
comedi_subdevice private data pointer. The helper function will also
set SRF_FREE_SPRIV to allow the comedi core to automatically free the
subdevice private data during the cleanup_device() stage of the detach.

Currently s->private is only allocated by the 8255, addi_watchdog,
amplc_dio200_common, and ni_65xx drivers. All users of those drivers
can then have the comedi_spriv_free() calls removed and in many cases
the (*detach) can then simply be the appropriate comedi core provided
function.

The ni_65xx driver uses a helper function, ni_65xx_alloc_subdevice_private(),
to allocate the private data. Refactor the function to return an errno
or call comedi_set_spriv() instead of returning a pointer to the private
data and requiring the caller to 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>
e3693fd3baeddf2e96b2f7734a5fe5509acedb40 06-Jun-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: introduce comedi_range_is_{bi,uni}polar()

Introduce some helper functions to check if a given 'range' index
to a comedi_subdevice 'range_table' is a bipolar or unipolar range.

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>
61dd149b102d00cea3815a161e07cd41fcc0d737 20-May-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: introduce comedi_to_usb_dev()

Introduce a helper function to get a usb_device pointer from a
comedi_device pointer.

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>
d569541e537e13136fc775a902cda06f4c48bbe1 17-May-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: ni_pcidio: use comedi_load_firmware()

Use comedi_load_firmware() instead of duplicating the code in a
private function.

This driver loads multiple firmware images to the device. Modify
comedi_load_firmware() to take a 'context' that is passed to the
firmware upload callback function.

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>
9ff8b151881adb408d1337bd7654cc869e9f42e0 17-May-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: drivers: generalize comedi_load_firmware()

Move comedi_load_firmware() from jr3_pci.c to drivers.c and export
it for general use by the comedi drivers.

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>
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>
316f97f169084c9a984d989d88ddce4eff60d749 18-Apr-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: drivers: introduce comedi_legacy_detach()

This function is intended to be used by the comedi legacy (ISA) drivers
either directly as the (*detach) function or as a helper in the drivers
private (*detach) function.

Modify the comedi_request_region() helper so that it stores the 'len' of
the region as well as the 'start' after the region has been successfuly
allocated by request_region() in __comedi_request_region(). This region
will then be automatically released detach of the driver by the
comedi_legacy_detach() helper.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2f69915c728c3be41e12dbbbdd4eeb8d3388d58c 16-Apr-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: introduce, and use, comedi_spriv_free()

The comedi_subdevice 'private' variable is a void * that is available
for the subdevice to use in manner. It's common in comedi drivers for
the driver to allocate memory for a subdevice and store the pointer
to that memory in the 'private' variable. It's then the responsibility
of the driver to free that memory when the device is detached.

Due to how the attach/detach works in comedi, the drivers need to do
some sanity checking before they can free the allocated memory during
the detach.

Introduce a helper function, comedi_spriv_free(), to handle freeing
the private data allocated for a subdevice. This allows moving all the
sanity checks into the helper function and makes it safe to call
with any context. It also allows removing some of the boilerplate
code in the (*detach) functions.

Remove the subdev_8255_cleanup() export in the 8255 subdevice driver
as well as the addi_watchdog_cleanup() export in the addi_watchdog
driver and use the new helper instead.

The amplc_dio200_common driver uses a number of local helper functions
to free the private data for it's subdevices. Remove those as well and
use the new helper.

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

Split comedi_request_region() into two helper functions.

__comedi_request_region()
Handles the actual request_region() call.

comedi_request_region()
Calls __comedi_request_region() and then sets dev->iobase if the
request was successful.

This allows drivers to use the __comedi_request_region() helper
to handle the request without setting the dev->iobase.

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>
f375ac5f197d32aeffe5436e5864525cc14ce44a 10-Apr-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: drivers: introduce comedi_request_region()

Introduce a helper function to handle the request_region() for legacy
comedi drivers.

As pointed out by Ian Abbott, legacy devices are configured manually
with the "comedi_config" program. The error messages are useful
diagnostics when trying to attach to these boards.

Providing a helper function allows consolidating the error messages
in the drivers and providing a consistent format for the errors.

This helper also sets the dev->iobase automatically for the driver
if the request_region() is successful.

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>
eda56825d582901b6a1c36fb8d754a3ebee0388c 04-Apr-2013 Ian Abbott <abbotti@mev.co.uk> staging: comedi: move COMEDI_NUM_MINORS and COMEDI_FIRST_SUBDEVICE_MINOR

The macro definitions `COMEDI_NUM_MINORS` and
`COMEDI_FIRST_SUBDEVICE_MINOR` are only used in "comedi_fops.c" so move
them to there from "comedidev.h".

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>
2c71c4ff57a6564097bedd45bc589f73da798a3a 03-Apr-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: range: introduce some simple mA ranges

The simple mA ranges 0 to 20, 4 to 20, and 0 to 32 are fairly common.
Introduce them in the comedi core and use them in the drivers.

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>
5f8eb72cef685462e1465ce3f317eaac4d93f9bd 03-Apr-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: range: introduce range_unipolar2_5

Introduce a simple unipolar 0 to 2.5 range, range_unipolar2_5, for
use by the comedi drivers.

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>
00ca6884186f18a758eae37e94f7c3c0527f8f30 15-Mar-2013 Ian Abbott <abbotti@mev.co.uk> staging: comedi: add 'ioenabled' flag to device

Add 1-bit bit-field member `ioenabled` of type `bool` to `struct
comedi_device`. Use this to keep track of whether a PCI device and its
BARs have been successfully enabled by `comedi_pci_enable()`. This
avoids overloading the meaning of the `iobase` member which is used by
several drivers to hold the base port I/O address of a board's "main"
registers. Other drivers using MMIO use `iobase` as a flag to indicate
that the preceding call to `comedi_pci_enable()` was successful. They
no longer need to do that.

The name `ioenabled` is intended to be PCI-agnostic so it can be used
for similar purposes by non-PCI drivers.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
13f12b5aea501bce146cdf213d1819083aadc847 15-Mar-2013 Ian Abbott <abbotti@mev.co.uk> staging: comedi: make 'in_request_module' a bool bit-field

Change the `in_request_module` member of `struct comedi_device` to a
1-bit bit-field of type `bool` and move it into a suitable hole in the
data type to save a few bytes. Change the assigned values to `true` and
`false`.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
a7401cddcdf739d3cb9598c9b3787a732fc87809 15-Mar-2013 Ian Abbott <abbotti@mev.co.uk> staging: comedi: make 'dev->attached' a bool bit-field

Change the `attached` member of `struct comedi_device` to a 1-bit
bit-field of type `bool`. Change assigned values to `true` and `false`
and replace or remove comparison operations with simple boolean tests.

We'll put some extra bit-fields in the gap later to save space.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
818f569fe930c5b8a05d1a44ece3c63c99c13c88 13-Mar-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi_pci: pass comedi_device to comedi_pci_enable()

Make comedi_pci_enable() use the same parameter type as
comedi_pci_disable(). This also allows comedi_pci_enable
to automatically determine the resource name passed to
pci_request_regions().

Make sure the errno value returned is passed on instead of
assuming an errno. Also, remove any kernel noise that is
generated when the call fails.

The National Instruments drivers that use the mite module
currently enable the PCI device in the mite module. For
those drivers move the call to comedi_pci_enable into the
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>
7f072f54ae5dc9965cbe450419b1389d13e2b849 13-Mar-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi_pci: make comedi_pci_disable() safe to call

Currently all the comedi PCI drivers need to do some checking in
their (*detach) before calling comedi_pci_disable() in order to
make sure the PCI device has actually be enabled.

Change the parameter passed to comedi_pci_disable() from a struct
pci_dev pointer to a comedi_device pointer and have comedi_pci_disable()
handle all the checking.

For most comedi PCI drivers this also allows removing the local
variable holding the pointer to the pci_dev. For some of the drivers
comedi_pci_disable can now be used directly as the (*detach) function.

The National Instruments drivers that use the mite module currently
enable/disable the PCI device in the mite module. For those drivers
move the call to comedi_pci_disable into the driver and make sure
dev->iobase is set to a non-zero value.

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>
b8f4ac237e382accd4b30c75043939f7ed9e79a6 05-Mar-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: comedi_pci: change the comedi_pci_auto_config() 'context'

The comedi_pci_auto_config() function is used to allow the PCI driver
(*probe) function to automatically call the comedi driver (*auto_attach).
This allows the comedi driver to be part of the PnP process when the
PCI device is detected.

Currently the comedi_pci_auto_config() always passes a 'context' of '0'
to comedi_auto_config(). This makes the 'context' a bit useless.

Modify comedi_pci_auto_config() to allow the comedi pci drivers to pass
a 'context' from the PCI driver.

Make all the comedi pci drivers pass the pci_device_id 'driver_data' as
the 'context'. Since none of the comedi pci drivers currently set the
'driver_data' the 'context' will still be '0'.

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>
a3ac95195b020a0a8fa2a9b0649145324ba64c83 06-Feb-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: comedi_pcmcia: allow drivers to use a custom conf_check()

Allow comedi pcmcia drivers to use a custom conf_check() when calling
comedi_pcmcia_enable() to enable the pcmcia device. If a conf_check()
is not passed the internal comedi_pcmcia_conf_check() will be used.

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>
55ab4f641a3bfbdb7c59b80e194c7242234bbb1f 06-Feb-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: comedi_usb: allow comedi usb drivers to pass a 'context'

Allow the comedi usb drivers to pass a 'context' from their (*probe)
functions to the comedi core's comedi_usb_auto_config(). This 'context'
is then passed to comedi_auto_config() and then to the comedi_driver's
(*auto_attach).

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>
ddb2d0a0185583b268dfe0a32e2f70ee2f118bd0 04-Feb-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: comedi_pcmcia: introduce comedi_pcmcia_{enable, disable}

Introduce some helper functions to enable/disable the PCMCIA device.
This will allow removing some of the boilerplate code in the comedi
PCMCIA drivers.

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>
7f70410fe03f9f31a99bb5074b5e3c48f3b90541 31-Jan-2013 H Hartley Sweeten <hsweeten@visionengravers.com> pci_ids.h: add common pci vendor ids from comedi subsystem

There are a number of pci vendor ids that are used in multiple
drivers in the comedi subsystem. Move these ids to pci_ids.h.

This also fixes some build warnings reported by the kbuild test
robot about PCI_VENDOR_ID_AMPLICON being undeclared.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
da71751177f35f0ca5494968cc237511c423a744 01-Feb-2013 Ian Abbott <abbotti@mev.co.uk> staging: comedi: export comedi_set_hw_dev()

Chnage the inline `comedi_set_hw_dev()` to an exported function and
change it's return type from `void` to `int` so we can impose some
restrictions (in a later patch) and return an error if necessary.

Only a few comedi drivers call this, although they don't need to if the
hardware device has been attached automatically via
`comedi_auto_config()` and the comedi driver's `auto_attach()` method.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
e9ab1c2f7eb6bc5d885429381e773bc1a61646ca 01-Feb-2013 Ian Abbott <abbotti@mev.co.uk> staging: comedi: move comedi_alloc_subdevice_minor declarations

Move the declarations of `comedi_alloc_subdevice_minor()` and
`comedi_free_subdevice_minor()` from "comedidev.h" to
"comedi_internal.h" since they are only of interest to the comedi core,
and are not exported to the low-level comedi drivers.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
085494ac2039433a5df9fdd6fb653579e18b8c71 30-Jan-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: don't expose comedi_proc_{init,cleanup}

These functions are only used by the comedi core. Move the
prototypes to comedi_internal.h so they are not exposed to
the comedi drivers.

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>
39bd5e59b1ebdaa58d9458923ab96f61bda1296c 30-Jan-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: don't expose comedi_device_{attach,detach}

These functions are only used by the comedi core. Move the
prototypes to comedi_internal.h so they are not exposed to
the comedi drivers.

Tidy up comedi_internal.h a bit so that all the internal stuff
in drivers.c is grouped.

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>
1ae6b20b88737f1828649b6cbe349c83b9f97bf0 30-Jan-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: tidy up the general purpose driver functions

Group all the general comedi driver register/config/attach
prototypes into one place in comedidev.h.

Reorder the functions in drivers.c a bit so they are in a more
logical usage order (bottom to top).

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>
1f021e1f3b187586e457b4584d0e5f0f5ca5fa15 30-Jan-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: allow pcmcia drivers to auto attach

Introduce some helper functions to allow converting the comedi
pcmcia drivers to the comedi auto_attach mechanism.

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>
309231d7a610554b02084ff7b465e43ef383a3bc 30-Jan-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: conditionally build in PCMCIA driver support

Separate the comedi_pcmcia_* functions out of drivers.c into a new
source file, comedi_pcmcia.c. This allows conditionally building
support for comedi pcmcia drivers into the comedi core without the
need for the #if'defery. Fix the Kconfig and Makefile appropriately.

Group all the comedi_pcmcia_* prototypes into one place in comedidev.h.
Protect these prototypes with an #ifdef so that building a comedi
pcmcia driver without PCMCIA support will cause a build error. This
will normally not happen as long as the comedi pcmcia driver is placed
in the proper group in the Kconfig.

Remove the #include <pcmcia/*.h> from drivers.c. These includes are only
needed by the comedi pcmcia driver support code and the pcmcia drivers.
The include should occur in those files.

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>
33782dd5edf8db3cdb7c81a3523bf743dd0209b7 30-Jan-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: conditionally build in PCI driver support

Separate the comedi_pci_* functions out of drivers.c into a new
source file, comedi_pci.c. This allows conditionally building
support for comedi PCI drivers into the comedi core. Fix the
Kconfig and Makefile appropriately.

Group all the comedi_pci_* prototypes and related defines into one
place in comedidev.h. Protect these prototypes with an #ifdef and
provide some dummy functions so that the mixed ISA/PCI comedi
drivers will still build correctly.

Remove the #include <linux/pci.h> from comedidev.h and drivers.c. This
include is only needed by the comedi PCI driver support code and the
PCI drivers. The include should occur in those files.

Also, remove the #include <linux/pci.h> from a couple non-PCI drivers
since it's not needed.

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>
abac8b54a353b9a1ac7d09ff790812655f618896 30-Jan-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: conditionally build in USB driver support

Separate the comedi_usb_* functions out of drivers.c into a new
source file, comedi_usb.c. This allows conditionally building
support for comedi USB drivers into the comedi core without the
need for the #if'defery. Fix the Kconfig and Makefile appropriately.
For aesthetic reasons, add some whitespace to the Makefile to keep
everything lined up.

Group all the comedi_usb_* prototypes into one place in comedidev.h.
Protect these prototypes with an #ifdef so that building a comedi
usb driver without USB support will cause a build error. This will
normally not happen as long as the comedi USB driver is placed in
the proper group in the Kconfig.

Remove the #include<linux/usb.h> from comedidev.h and drivers.c. This
include is only needed by the comedi USB driver support code and the
USB drivers. The include should occur in those files.

Removing the include of usb.h exposed a couple drivers that need
<linux/interrupt.h> and <linux/sched.h>. Add the missing 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>
bc3954b8147402e4495378d982cc8e708703a0f1 29-Jan-2013 Ian Abbott <abbotti@mev.co.uk> staging: comedi: simplify comedi_set_hw_dev()

Since `get_device()` and `put_device()` can take a NULL device
parameter, `comedi_set_hw_dev()` can be simplified to always call
`get_device()` for the new, possibly NULL hardware device, and
`put_device()` for the old, possibly NULL hardware device. As long as
we do it in that order, there shouldn't be any problem with
`kref_release()` getting called unexpectedly when the new hardware
device is the old hardware device.

Simplify `comedi_set_hw_dev()` and update the comment because the
function is used for additional purposes since the old comment was
written.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
c2f90a20c9166bf9effb064703903039a49324e3 23-Jan-2013 Peter Huewe <peterhuewe@gmx.de> staging/comedi: Move comedi_pci_auto_unconfig to drivers.c

Since comedi_pci_auto_unconfig cannot be inlined anymore after
staging/comedi: Use comedi_pci_auto_unconfig directly for
pci_driver.remove
is applied, it makes sense to move it drivers.c

Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
d607ffac4cbd22599f2b006465c722104cc1cd1b 14-Jan-2013 Peter Huewe <peterhuewe@gmx.de> staging/comedi: Add macro for registering a comedi PCMCIA driver

This patch introduces a new macro 'module_comedi_pcmcia_driver'
for comedi PCMCIA drivers which do not do anything special in module
init/exit. This eliminates a lot of boilerplate.

Adapted from 'module_comedi_pci_driver'

Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
8ae560a14abaf2b76fb486ad08fea9c6c5be640f 09-Jan-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: comedi_buf: reorder exported function prototypes

For aesthetic reasons, reorder the prototypes for the exported
comedi_buf_* functions in comedidev.h to follow the function
declarations in comedi_buf.c.

Also, change a couple of the return values from 'unsigned' to
'unsigned int' to match the value actually returned.

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>
8bd650f91be07fb84adc2e47fb1379b7223b95a4 09-Jan-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: comedi_buf: don't expose comedi_buf_write_n_allocated()

This helper function is only called by the comedi core in comedi_buf.c
and comedi_fops.c. For aesthetic reasons, move it to comedi_buf.c and
remove the inline. Move the prototype from comedidev.h to comedi_internal.h
so it's not exposed outside the comedi core.

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>
5b2b64b7510292f4b1e6363edb6f53c39828672e 09-Jan-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: comedi_buf: don't expose comedi_buf_read_n_allocated()

This helper function is only called in comedi_buf.c. Move it there and
make it static so it's not exposed globally.

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>
47181eab71a81a919bf74eee570d6db59c6cf298 09-Jan-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: comedi_buf: remove comedi_buf_write_alloc_strict

This function is only called by comedi_buf_put(). Remove it and just
call __comedi_buf_write_alloc() directly with the strict flag set.

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>
f8f76e909b8cc6696071e69cf4be07714c95bcb4 09-Jan-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: comedi_buf: factor out common comedi_buf_write_alloc_* code

The only difference between comedi_buf_write_alloc() and the *_strict()
version is that the *_strict() one will only allocate the chunk if it
can completely fulfill the request.

Factor out the common code and add a flag parameter to indicate the 'strict'
usage. Change the exported functions so they are just wrappers around the
common function.

Cleanup the common function a bit and use the comedi_buf_write_n_available()
helper to determine the number of bytes available.

comedi_buf_write_n_available() is not used outside this module so make it
static. Since the only caller is __comedi_buf_write_alloc(), which will
always have a valid async pointer and already has a memory barrier, we
can remove the unnecessary (async == NULL) test as well as the smp_mb().
Also, the rounding of the sample size can be removed since the caller
does not need it.

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>
d18431325be0d485f58097755de5ec90091f336d 09-Jan-2013 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: deprecate loading firmware with comedi_config

All the comedi drivers have been converted to use the request_firmware()
hotplug interface. The COMEDI_DEVCONFIG ioctl support for passing the
firmware blob as 'aux_data' is no longer required.

Remove the feature and give the user a dev_warn message if it is
attempted.

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>
21f181f16cea4a4cbaea25409ddb044a4ad5cd34 01-Jan-2013 Lijo Antony <lijo.kernel@gmail.com> Staging: comedi: comedidev.h: fixed a camel case

Fixed a camel case issue.

Signed-off-by: Lijo Antony <lijo.kernel@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
90a35c15c5d7d5c6254772d2752975dda185710c 20-Dec-2012 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: store the 'index' for each subdevice

Store the 'index' for each comedi_subdevice when they are initially
allocated by comedi_alloc_subdevice(). This allows removing the
pointer math in comedi_fops.c which is used to figure out the
index that user space uses to access the individual subdevices.

Fix the ni_mio_common driver so it also uses the 'index' instead
of doing the pointer math.

Also, remove a couple unused macros in the pcmda12, pcmmio, and
pcmuio drivers which also do the pointer math to figure out the
index.

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>
ade1764ff5f03bea4bc848de5e6d3db0758ff15a 19-Dec-2012 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: comedi_fops: don't export comedi_get_subdevice_runflags()

The subdevice runflags are protected with a spin_lock. Only the comedi
core should be accessing them directly.

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>
e0dac318ee2807d5ec1b09c1a608fdc25ef2ac7b 19-Dec-2012 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: comedi_fops: introduce comedi_is_subdevice_running()

Introduce a helper function that checks the subdevice runflags to
see if the subdevice is running a command.

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>
e79c8d21000eb484c54b2fa2f42e6b55775ef144 19-Dec-2012 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: don't expose struct comedi_device_file_info

This structure is only used in comedi_fops.c as part of handling
the file operations and sysfs files. Remove it's defenition from
comedidev.h so it's not exposed to the comedi drivers.

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>
87b1ad7a80d0a297448893e06f37c775951119d0 19-Dec-2012 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: comedi_fops: don't export comedi_get_device_file_info()

This function is now only used in comedi_fops.c and does not need
to be exported.

Make it static and move it to avoid forward declarations.

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>
85104e9b409013c78624b367dec02e6ccc996635 19-Dec-2012 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: comedi_fops: introduce comedi_dev_from_minor()

A number of functions have to call comedi_get_device_file_info()
to get the comedi_device_file_info pointer for a given minor. That
pointer is only used to get the actual comedi_device pointer for
the minor.

Introduce a new helper function, comedi_dev_from_minor(), to simplify
this operation. This will also allow us to make the comedi_device_file_info
struct private.

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>
43bd33f22444868cbc9d4cbec7a3efb0a7c2cb25 19-Dec-2012 H Hartley Sweeten <hsweeten@visionengravers.com> staging: comedi: don't expose comedi_get_{read, write}_subdevice

These two inline helper function in comedidev.h are only used in
comedi_fops.c. They return information that should only be used
by the comedi core.

Move both functions to comedi_fops.c so they aren't exposed to
the comedi drivers. Also, remove the inline tag and let the
compiler figure it out.

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>
581a7ddec13d8f08b308c4764090bf57b0254f6f 14-Nov-2012 Ian Abbott <abbotti@mev.co.uk> staging: comedi: use inlines for PCI/USB auto config

Apart from the somewhat unnecessary `BUG_ON()` calls,
`comedi_pci_auto_config()` and `comedi_usb_auto_config()` are just
one-line wrappers around `comedi_auto_config()`, and
`comedi_pci_auto_unconfig()` and `comedi_usb_auto_unconfig()` are just
one-line wrappers around `comedi_auto_unconfig()`. Convert them to
inline functions and remove the `BUG_ON()` calls.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
ddbd029903d29ec9a5aceb82d4b0c4a7468d1984 14-Nov-2012 Ian Abbott <abbotti@mev.co.uk> staging: comedi: remove attach_pci and attach_usb handlers

No comedi drivers set the `attach_pci()` or `attach_usb()` handlers in
their `struct comedi_driver` any longer as they have all been replaced
with an `auto_attach()` handler. Also, no code calls the `attach_pci()`
or `attach_usb()` handlers any longer. Remove them from `struct
comedi_driver`.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4dba6c02cd2bd4714db4f0ccd3ebc3983ff0e039 02-Nov-2012 Ian Abbott <abbotti@mev.co.uk> staging: comedi: comedidev.h: make comedi_board() parameter const

The inline function `comedi_board(dev)` merely returns `dev->board_ptr`.
It does not modify any members of `*dev` so make its parameter a const
pointer.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
0a577b823d0202b94eeef0e6b2b5653527fd6134 27-Oct-2012 Ian Abbott <abbotti@mev.co.uk> staging: comedi: add comedi to usb interface helper

Add inline helper function `comedi_to_usb_interface()` to get the
pointer to `struct usb_interface` associated with the comedi device.
This pointer is set by the call to `comedi_usb_auto_config()`.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
8ed705aff0652fdbd2c6b406155d7d480e1aabe0 27-Oct-2012 Ian Abbott <abbotti@mev.co.uk> staging: comedi: add generic auto-config functions

Add (and export) generic auto-config function `comedi_auto_config()` to
allow hardware devices on arbitrary bus types (e.g. platform devices,
spi devices, etc.) to be auto-configured as comedi devices. This uses a
new `auto_attach()` hook in the `struct comedi_driver`. This new hook
will eventually replace the bus-specific `attach_pci()` and
`attach_usb()` hooks in the low-level comedi drivers.

When the `auto_attach()` hook is called in the low-level driver, the
`hw_dev` member of the `struct comedi_device` will have already been set
to the hardware device passed to `comedi_auto_config()`. The low-level
driver can convert this to some bus-device wrapper structure pointer,
possibly with the help of the `context` parameter that is passed
unchanged from the `comedi_auto_config()` call.

Also export the existing `comedi_auto_unconfig()` function as the
matching call to `comedi_auto_config()`.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2847ff5d1b63496c2e3eedb8efad2752cc2e195d 25-Oct-2012 H Hartley Sweeten <hartleys@visionengravers.com> staging: comedi: comedidev.h: add PCI_VENDOR_ID_AMPLICON

Add a define for the Amplicon Liveline Limited PCI vendor id.
Remove the duplicates in the drivers.

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>
268533124d621360710e08e0ce71a3f5313b6c78 25-Oct-2012 H Hartley Sweeten <hartleys@visionengravers.com> staging: comedi: comedidev.h: add PCI_VENDOR_ID_AMCC

Add a define for the Applied Micro Circuits Corp. PCI vendor id.
Remove the duplicates in the drivers.

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>
50d3c3f591958d68a3dd9410c3682c91bd3dda4a 25-Oct-2012 H Hartley Sweeten <hartleys@visionengravers.com> staging: comedi: comedidev.h: add PCI_VENDOR_ID_RTD

Add a define for the RTD Embedded Technologies, Inc. PCI vendor id.
Remove the duplicates in the drivers.

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>
34f8d2089d0f7820da9cc24964da9f33d59c03b2 25-Oct-2012 H Hartley Sweeten <hartleys@visionengravers.com> staging: comedi: comedidev.h: add PCI_VENDOR_ID_IOTECH

Add a define for the Iotech Inc. PCI vendor id. Remove the duplicates
in the drivers.

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>
0d374622a8a45dec37702a40c803fb9e9e9cb8e0 25-Oct-2012 H Hartley Sweeten <hartleys@visionengravers.com> staging: comedi: comedidev.h: add PCI_VENDOR_ID_KOLTER

Add a define for the Kolter Electronic PCI vendor id. Remove the
duplicates in the drivers.

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>
f656ef5b6c15e518dde43a6d6ae6c47dccc6c920 25-Oct-2012 H Hartley Sweeten <hartleys@visionengravers.com> staging: comedi: comedidev.h: add PCI_VENDOR_ID_DT

Add a define for the Data Translation, Inc. PCI vendor id. Remove
the duplicates in the drivers.

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>
b77d93a0306766456d7d6da21fb6f16c5e129fe6 25-Oct-2012 H Hartley Sweeten <hartleys@visionengravers.com> staging: comedi: comedidev.h: add PCI_VENDOR_ID_MEILHAUS

Add a define for the Meilhaus Electronic GmbH Germany PCI vendor id.
Remove the duplicates in the drivers.

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>
12f07ba56bad3defc37416e496c6e790029715b4 25-Oct-2012 H Hartley Sweeten <hartleys@visionengravers.com> staging: comedi: comedidev.h: add PCI_VENDOR_ID_ADVANTECH

Add a define for the Advantech Co., Ltd. PCI vendor id. Remove the
duplicates in the drivers.

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>
cb3e9d86945181a2d9154543f402dccf35d8dd58 25-Oct-2012 H Hartley Sweeten <hartleys@visionengravers.com> staging: comedi: comedidev.h: add PCI_VENDOR_ID_CB

Add a define for the ComputerBoards/Measurement Computing PCI
vendor id. Remove the duplicates in the drivers.

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>
0a7717dfe097d7a0a08e824ed39547c3e6e9d7e8 15-Oct-2012 Ian Abbott <abbotti@mev.co.uk> staging: comedi: avoid a put_device(), get_device() sequence

In `comedi_set_hw_dev()`, if there is no change to `dev->hw_dev` (and it
is not `NULL`), don't bother putting and getting the device.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4f870fe6269bbc7cca2a70c50a4cc6f811fe21c5 16-Aug-2012 Ian Abbott <abbotti@mev.co.uk> staging: comedi: replace printk calls in comedi core

Replace the printk() calls in the comedi core module with something more
suitable, such as dev_...() or pr_...(). Remove the ones that report a
failure to increment a module count (try_module_get() failure). Change
the printk() call in the DPRINTK() macro to pr_debug().

TODO: Most of the DPRINTK() calls need to be replaced with something
else.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
ddb01367b85df2c4c773bde047e5b04b6de1835b 19-Jul-2012 H Hartley Sweeten <hartleys@visionengravers.com> staging: comedi: comedidev.h: introduce comedi_to_pci_dev() helper

Introduce a wrapper for to_pci_dev() to allow the comedi_pci_drivers
to store the pci_dev pointer in the comedi_device hw_dev variable and
retrieve it easily.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbot <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
928ae0956d8a3b26c3908c4bc97973cba36030a3 20-Jun-2012 H Hartley Sweeten <hartleys@visionengravers.com> staging: comedi: remove CONFIG_COMEDI_PCI define

CONFIG_COMEDI_PCI is not actually a Kconfig option. It is defined
in the comedidev.h header based on another Kconfig option being
enabled.

It is only referenced in the skel driver to conditionally compile
in the PCI support code. Use the CONFIG_COMEDI_PCI_DRIVERS Kconfig
option instead and remove the define.

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>
d4d3c4e676769dbabb0289f1a893854907950b65 20-Jun-2012 H Hartley Sweeten <hartleys@visionengravers.com> staging: comedi: remove unused CONFIG_COMEDI_PCMCIA define

CONFIG_COMEDI_PCMCIA is not actually a Kconfig option. It is
defined in the comedidev.h header based on another Kconfig
option being enbled.

Just remove it since the define is not used by any of the comedi
drivers.

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>
d4a7dc85289306d019378bac18fd88f35dc81b51 18-Jun-2012 H Hartley Sweeten <hartleys@visionengravers.com> staging: comedi: comedi_subdevice 'io_bits' should be an unsigned int

The 'io_bits' variable in the comedi_subdevice struct is a bitmask of
the input/output configuration of the the subdevice. It should be an
unsigned int to correctly represent this.

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>
8b9ba6e5efc3213f384cda155861a4f7ae903365 12-Jun-2012 H Hartley Sweeten <hartleys@visionengravers.com> staging: comedi: change type of num_subdevices parameter to comedi_alloc_subdevices

The n_subdevices variable of struct comedi_device is an int type.
Change the type of the comedi_alloc_subdevices 'num_subdevices' from
an unsigned int to an int to match it.

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>
55c03cff7fd73349473cc0a964df9d55b312dbbc 22-May-2012 H Hartley Sweeten <hartleys@visionengravers.com> staging: comedi: remove private header comedi_pci.h

Remove the private header, comedi_pci.h, by moving the two
helper functions into divers.c and providing the prototypes
in comedidev.h.

This allows the comedi_pci_enable/disable helper functions
to be shared instead of having an inline version in every
comedi pci driver.

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>
64255031bde68bd0f7ec934b83842619d513cf91 17-May-2012 H Hartley Sweeten <hartleys@visionengravers.com> staging: comedi: Add helper macro for comedi usb driver boilerplate

Introduce the module_comedi_usb_driver macro, and the
associated register/unregister functions, which is a
convenience macro for comedi usb driver modules similar
to module_platform_driver. It is intended to be used by
drivers where the init/exit section does nothing but
register/unregister the comedi driver and associated usb
driver. By using this macro it is possible to eliminate
a few lines of boilerplate code per comedi usb driver.

Also, when registering the usb driver check for failure
and unregister the comedi driver.

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>
d4899c6ff86ea9836c89250cb2127aa64765b35a 12-May-2012 H Hartley Sweeten <hartleys@visionengravers.com> staging: comedi: Add helper macro for comedi pci driver boilerplate

Introduce the module_comedi_pci_driver macro, and the
associated register/unregister functions, which is a
convenience macro for comedi pci driver modules similar
to module_platform_driver. It is intended to be used by
drivers where the init/exit section does nothing but
register/unregister the comedi driver and associated pci
driver. By using this macro it is possible to eliminate
a few lines of boilerplate code per comedi pci driver.

Add a check to make sure that the pci_driver->name is
set. Once all the comedi pci drivers have been fixed this
will be removed.

Also, when registering the pci driver check for failure
and unregister the comedi driver.

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>
204162572ff4a679a47c68a5d5b3ac2bcba3830e 02-May-2012 H Hartley Sweeten <hartleys@visionengravers.com> staging: comedi: Add helper macro for comedi_driver boilerplate

Introduce the module_comedi_driver macro which is a convenience
macro for comedi driver modules similar to module_platform_driver.
It is intended to be used by drivers where the init/exit section
does nothing but register/unregister the comedi driver. By using
this macro it is possible to eliminate a few lines of boilerplate
code per comedi driver.

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>
37859f8893c00fe4baa95f61ba560b9990f59484 27-Apr-2012 H Hartley Sweeten <hartleys@visionengravers.com> staging: comedi: introduce 'comedi_board' helper function

This helper function is used to fetch the comedi_device board_ptr
which is used during the attach to pass board specific information
to the comedi drivers.

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>
f4011670023f28cf9081904f8986c0c1be5c9f1e 30-Mar-2012 Ian Abbott <abbotti@mev.co.uk> staging: comedi: add bus-type-specific attach hooks for PCI and USB

The Comedi auto-configuration mechanism used to bind hardware devices to
comedi devices automatically is pretty kludgy. It fakes a "manual"
configuration of the comedi device as though the COMEDI_DEVCONFIG ioctl
(or the 'comedi_config' utility) were used. In particular, the
low-level comedi driver's '->attach()' routine is called with a pointer
to the struct comedi_device being attached and a pointer to a 'struct
devconfig' containing a device name string and a few integer options to
help the attach routine locate the device being attached. In the case
of PCI devices, these integer options are the PCI bus and slot numbers.
In the case of USB devices, there are no integer options and it relies
more on pot luck to attach the correct device.

This patch adds a couple of bus-type-specific attach routine hooks to
the struct comedi_driver, which a low-level driver can optionally fill
in if it supports auto-configuration.

A low-level driver that supports auto-configuration of {PCI,USB} devices
calls the existing comedi_{pci,usb}_auto_config() when it wishes to
auto-configure a freshly probed device (maybe after loading firmware).
This will call the new '->attach_{pci,usb}()' hook if the driver has
defined it, otherwise it will fall back to calling the '->attach()' hook
as before. The '->attach_{pci,usb}()' hook gets a pointer to the struct
comedi_device and a pointer to the struct {pci_dev,usb_interface} and
can figure out the {PCI,USB} device details for itself.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
d8b6ca0850c558f21989d468801ad1414b1372c4 30-Mar-2012 Ian Abbott <abbotti@mev.co.uk> staging: comedi: pass usb interface to comedi_usb_auto_config

The comedi_usb_auto_config() and comedi_usb_auto_unconfig() functions
currently take a 'struct usb_device *'. It makes more sense to pass a
'struct usb_interface *' to allow for composite USB devices.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
c43435d7722134ed1fda58ce1025f41029bd58ad 30-Mar-2012 Ian Abbott <abbotti@mev.co.uk> staging: comedi: don't hijack hardware device private data

comedi_auto_config() associates a Comedi minor device number with an
auto-configured hardware device and comedi_auto_unconfig() disassociates
it. Currently, these use the hardware device's private data pointer to
point to some allocated storage holding the minor device number. This
is a bit of a waste of the hardware device's private data pointer,
preventing it from being used for something more useful by the low-level
comedi device drivers. For example, it would make more sense if
comedi_usb_auto_config() was passed a pointer to the struct
usb_interface instead of the struct usb_device, but this cannot be done
currently because the low-level comedi drivers already use the private
data pointer in the struct usb_interface for something more useful.

This patch stops the comedi core hijacking the hardware device's private
data pointer. Instead, comedi_auto_config() stores a pointer to the
hardware device's struct device in the struct comedi_device_file_info
associated with the minor device number, and comedi_auto_unconfig()
calls new function comedi_find_board_minor() to recover the minor device
number associated with the hardware device.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4c093a6dc2240fd54d71a25b284e02d51509e430 30-Mar-2012 Ian Abbott <abbotti@mev.co.uk> staging: comedi: pass 'struct comedi_driver *' to comedi_..._auto_config

The comedi_pci_auto_config() and comedi_usb_auto_config() functions
currently take a board name parameter which is actually a driver name
parameter. Replace it with a pointer to the struct comedi_driver. This
will allow comedi_pci_auto_config() and comedi_usb_auto_config() to call
bus-type-specific auto-configuration hooks in the struct comedi_driver
if they exist (they don't yet). The idea is that these
bus-type-specific auto-configuration hooks won't have to search the bus
for the device being auto-configured like 'attach()' hook has to.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
0435f9337f051db77b4eaf02eee83e7a29f3474a 06-Jul-2011 Pavel Roskin <proski@gnu.org> staging: comedi: remove COMEDI_DEVICE_CREATE macro, expand all callers

This is no longer needed as the code is now in the main kernel tree.

Signed-off-by: Pavel Roskin <proski@gnu.org>
Cc: Frank Mori Hess <fmhess@users.sourceforge.net>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
727b286b44ea359d66f47d241cc2cdad36ed7bdc 06-Jun-2010 Arun Thomas <arun.thomas@gmail.com> Staging: comedi: Remove COMEDI_PCI_INITCLEANUP macro

Move the PCI devinit/devexit routines to the respective C source files
instead of calling COMEDI_PCI_INITCLEANUP

Signed-off-by: Arun Thomas <arun.thomas@gmail.com>
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>
3c17ba0743d75f9888d905ddf9f8551c7dd36493 19-May-2010 Ian Abbott <abbotti@mev.co.uk> Staging: comedi: Allow 'open' driver method to fail

Some comedi drivers should return an error from their 'open' method when
something goes wrong. Change the prototype of the 'open' method in
'struct comedi_device' to allow this, and change the drivers that use it.
Propagate any error to the 'open' file operation.

The corresponding 'close' method won't be called when the 'open' method
fails, so drivers failing the 'open' need to clean up any mess they
created.

The dt9812 and serial2002 drivers can now return an error on 'open'.
The jr3_pci driver also uses the 'open' method but doesn't fail it.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
5e220112c8c8e59c253f6ad473687444b3ca90bf 06-May-2010 Mark Rankilor <reodge@gmail.com> Staging: comedi: Fixed long line length in comedidev.h

This patch fixes a long line length in comedidev.h to make checkpatch.pl happy

Signed-off-by: Mark Rankilor <reodge@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
7029a87455af3cf303e8d6d0db8c26b6a94f1020 04-May-2010 Greg Kroah-Hartman <gregkh@suse.de> Staging: comedi: drivers.c sparse cleanup

Fix up some sparse issues in drivers.c

Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Frank Mori Hess <fmhess@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2434358ac7ece40e6aa8cd705927c423caa718ec 04-May-2010 Greg Kroah-Hartman <gregkh@suse.de> Staging: comedi: move some more functions to internal.h

Only the internal comedi core calls these, so put them here.

Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Frank Mori Hess <fmhess@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
09372df0dff51121e772ca5870fb565a08840c86 04-May-2010 Greg Kroah-Hartman <gregkh@suse.de> Staging: comedi: make comedi_reset_async_buf local to comedi core

No one outside of the comedi core calls this function, so don't export
it to the world.

Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Frank Mori Hess <fmhess@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
9e8c604821b372c6e98e9632f5617913bf92ae45 04-May-2010 Greg Kroah-Hartman <gregkh@suse.de> Staging: comedi: make comedi_free_board_minor local to comedi core

No one outside of the comedi core calls this function, so don't export
it to the world.

Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Frank Mori Hess <fmhess@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
242e7ad91a067243d7ab63b6a25ed2e085733446 04-May-2010 Greg Kroah-Hartman <gregkh@suse.de> Staging: comedi: make comedi_alloc_board_minor local to comedi core

No one outside of the comedi core calls this function, so create
an internal.h file to put the prototype in, and don't export
it to the world.

Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Frank Mori Hess <fmhess@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
181bd67bf5780b941f2cba6247ed1c0cdfce468a 04-May-2010 Greg Kroah-Hartman <gregkh@suse.de> Staging: comedi: make comedi_set_subdevice_runflags() static

No one calls this anymore, except the core comedi code, so
mark it static and don't export it.

Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Frank Mori Hess <fmhess@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
0fd0ca75fd9eb0e9cde49c28ad227c2d8d049366 01-May-2010 Greg Kroah-Hartman <gregkh@suse.de> Staging: comedi: rename check_chanlist to comedi_check_chanlist

It's a global function, so properly name it and move the
export to where the function is located at.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
6608224c9e5c8aacf88914697be2d5f1fc7a0be6 01-May-2010 Greg Kroah-Hartman <gregkh@suse.de> Staging: comedi: remove another vendor id

This id was already in the drivers, so just use it there
instead of in a common header file.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
59af888d6af8e3d2c91b32e00e43f2ce750589b8 01-May-2010 Greg Kroah-Hartman <gregkh@suse.de> Staging: comedi: move another pci vendor id

Move the vendor id to the drivers needing it.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
558587e2d96a4f5439a609509e4ea88f7536203b 01-May-2010 Greg Kroah-Hartman <gregkh@suse.de> Staging: comedi: move another pci device id to the driver

Put a pci vendor id into the drivers that need them.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
3ca88dd5c3c6739f685793539a679ab5ac85aca3 01-May-2010 Greg Kroah-Hartman <gregkh@suse.de> Staging: comedi: move a pci vendor id

The vendor id should be in the driver that needs it, not in
a common file.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
7a102e0ef173ff936efb6ea33b6a9db865c82645 01-May-2010 Greg Kroah-Hartman <gregkh@suse.de> Staging: comedi: remove some pci vendor ids

These are never used, so remove them.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
4e40cee9c8a46d4231d28ae7ae6d9938cf0526d5 01-May-2010 Greg Kroah-Hartman <gregkh@suse.de> Staging: comedi: use the standard NI pci device id

Don't redefine something that we already have in the core
kernel. Also move to use PCI_DEVICE() macros to make things
a bit simpler when changing the define.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
baf22b64aa7eb2d32c4ff49262b8d26c18bb232a 01-May-2010 Greg Kroah-Hartman <gregkh@suse.de> Staging: comedi: fix coding style issues in comedidev.h

This resolves some coding style issues in comedidev.h

And yes, volatile here meant nothing, removing it is ok.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
62eeae93080f1189894b7933d07e5f62461d1cd4 23-Sep-2009 Shane Warden <shane.warden@onyxneon.com> Staging: comedi: comedidev.h: Fixed checkpatch.pl issues

Signed-off-by: Shane Warden <shane.warden@onyxneon.com>
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>
c7a5d70796379e3d51d0c652fbe1634b81d3bbd5 19-Jun-2009 Greg Kroah-Hartman <gregkh@suse.de> Staging: comedi: fix build errors

Some of the comedi drivers need timer.h to build properly, so put it
in the comedidev.h file to fix these errors.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
f9c51375644e39f9626a4be4101e22d4841980a8 05-Jun-2009 Randy Dunlap <randy.dunlap@oracle.com> Staging: comedi: uses udelay, needs delay.h

comedi driver(s) use udelay() so they need to #include delay.h.

drivers/staging/comedi/drivers/adq12b.c: In function 'adq12b_ai_rinsn':
drivers/staging/comedi/drivers/adq12b.c:328: error: implicit declaration of function 'udelay'

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
fcea115462c690ba09f9df7471d60dda0d86a4ea 28-Apr-2009 Greg Kroah-Hartman <gregkh@suse.de> Staging: comedi: remove some RT code that lingered

This removes some pieces of RT code that was part of the main code
paths.

Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Frank Mori Hess <fmhess@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
25436dc9d84f1be60ff549c9ab712bba2835f284 28-Apr-2009 Greg Kroah-Hartman <gregkh@suse.de> Staging: comedi: remove RT code

This removes the unused RT code from the comedi subsystem.

A lot of drivers needed to then include interrupt.h on their own, as they
were picking it up through the comedi_rt.h inclusion.

Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Frank Mori Hess <fmhess@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
056d3ce5cfe3544b297e6bc90ffbbb317e7bbbff 17-Apr-2009 Greg Kroah-Hartman <gregkh@suse.de> Staging: comedi: set PCI and PCMCIA defines

The comedi drivers are looking for CONFIG_COMEDI_PCI and
CONFIG_COMEDI_PCMCIA, not the current config items. This creates a
define so that things build properly when these options are selected.
Long term goal is to fix up the drivers to not need any defines.

Cc: Frank Mori Hess <fmhess@users.sourceforge.net>
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>
1f6325d629ce03501e8927480495685828561f26 17-Mar-2009 Bill Pemberton <wfp5p@virginia.edu> Staging: comedi: Remove comedi_krange typedef

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

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>
0bfbbe8f09617247c87d3b626cbf007c423afff1 17-Mar-2009 Bill Pemberton <wfp5p@virginia.edu> Staging: comedi: Remove device_create_result_type 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>
d163679ceec20c50f9aee880fa76c0c1185244a8 17-Mar-2009 Bill Pemberton <wfp5p@virginia.edu> Staging: comedi: Remove comedi_async 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>
51b713a684d403bd672b3e4cac55db43dc5cca2d 17-Mar-2009 Bill Pemberton <wfp5p@virginia.edu> Staging: comedi: Misc code cleanups for checkpatch

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
4dc6b15bce9c0635850a9f5c1a493e09d2e8fe61 03-Mar-2009 Mariusz Kozlowski <m.kozlowski@tuxland.pl> Staging: comedi: remove unnecessary #include <linux/version.h>

Signed-off-by: Mariusz Kozlowski <m.kozlowski@tuxland.pl>
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>
a3cb729ef4a192f04179f780122df78ef1ffe779 15-Dec-2008 Frank Mori Hess <fmhess@users.sourceforge.net> Staging: comedi: Added some validation of comedi module parameter values.

Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: David Schleef <ds@schleef.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
c28264dac4348b1514a9a0abcf0014c6b460637f 09-Dec-2008 Bernd Porr <BerndPorr@f2s.com> Staging: comedi: add comedi_usb_auto_[un]config functions

This will be used by the usbdux and usbduxfast drivers.

From: Bernd Porr <BerndPorr@f2s.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>
4ed4f41c1b13873f4b8afd4fbe00eb8c3907bc4a 11-Jan-2009 Huang Weiyi <weiyi.huang@gmail.com> Staging: remove duplicated #include's

Removed duplicated #include's in
drivers/staging/altpciechdma/altpciechdma.c
drivers/staging/comedi/comedidev.h
drivers/staging/rt2860/rt_linux.h
drivers/staging/rt2870/rt_linux.h

Signed-off-by: Huang Weiyi <weiyi.huang@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
74b847f4d07bce1eaf84505d65aff42f14e5fb2f 14-Nov-2008 David Schleef <ds@schleef.org> Staging: comedi: add local copy of interrupt.h

This is needed for some internal comedi driver macros that were
built up over the years to handle multiple kernel versions. It will be
removed eventually.

From: David Schleef <ds@schleef.org>
Cc: Frank Mori Hess <fmhess@users.sourceforge.net>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
e0dcef71f6ea63f80631d2e87d06a9ae05624eef 14-Nov-2008 Greg Kroah-Hartman <gregkh@suse.de> Staging: comedi: fix up a lot of checkpatch.pl warnings

Only clean up some of the easier ones in the .h files

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>
ed9eccbe8970f6eedc1b978c157caf1251a896d4 05-Nov-2008 David Schleef <ds@schleef.org> Staging: add comedi core

This adds the Comedi core to the staging tree.
This is a data acquision infrastructure for Linux, providing a common
interface for these types of drivers.

Taken directly from the comedi git tree, with only minor tweaks
by Greg to get it to build properly within the kernel tree.

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