Commit graph

3165 commits

Author SHA1 Message Date
H Hartley Sweeten
658cd3ac2e staging: comedi: vmk80xx: cleanup analog input subdevice init
Change the 'ai_bits' in the boardinfo to 'ai_maxdata' so that the
calculation of s->maxdata can be removed.

Change the types for the analog input boardinfo to match the
comedi_subdevice types they are set to.

Rename the (*insn_read) function for the analog input subdevice from
vmk80xx_ai_rinsn to vmk80xx_ai_insn_read to make grepping easier.

For aesthetic reasons, add some whitespace to the subdevice init.

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>
2013-02-05 18:07:11 -08:00
H Hartley Sweeten
52d895d367 staging: comedi: vmk80xx: remove need for boardinfo in private_data
The only information in the boardinfo that is used outside of the
attach of the driver is the 'model' of the device.

Remove the 'board' pointer from the private data and replace it with
the 'model' enum and just copy that information over during the 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>
2013-02-05 18:07:11 -08:00
H Hartley Sweeten
57cf09aeee staging: comedi: vmk80xx: push usb (*probe) into comedi (*auto_attach)
Make the usb_driver (*probe) simply call comedi_usb_auto_config()
and move all the (*probe) code into the (*auto_attach) function.

This allows getting rid of the static private data array since we
no longer do part of the initialization in the (*probe) and then
finish it in the (*auto_attach). We can simply kzalloc the private
data instead. The comedi core will then handle the kfree of the
data when the driver is detached.

We can also get rid of the static 'glb_mutex' since this mutex was
only used to protect the static private data array.

Change the parameters for a couple of the helper functions used
during the auto attach. Now that the comedi_device is available
we can simply pass that pointer and get the specific pointers
needed by the helper functions from 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>
2013-02-05 18:07:11 -08:00
H Hartley Sweeten
55ab4f641a 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>
2013-02-05 18:07:11 -08:00
H Hartley Sweeten
29d6dd3310 staging: comedi: vmk80xx: remove private data 'attached'
The 'attached' flag in the private data is set after the comedi_driver
(*auto_attach) function has completed successfully.

The only places it's checked are in rudimentary_check(), which does
some basic sanity checks before doing any of the subdevice operations,
and vmk80xx_auto_attach(), which is the comedi_driver (*auto_attach)
function.

The (*auto_attach) function can only be called as the result of a
successfull usb_driver (*probe). Part of the probe is to locate a
free slot in the static private data array. All free slots are
initialized to '0' so the 'attached' flag will always be cleared.

Remove the unneccessary 'attached' flag in the private data.

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>
2013-02-05 18:07:11 -08:00
H Hartley Sweeten
b105ad8a78 staging: comedi: vmk80xx: remove private data 'probed'
The 'probed' variable is used in the usb driver (*probe) to detect an
unused element in the static private data arry. This variable is then
set after the usb driver has completed its (*probe) before calling
comedi_usb_auto_config(). When the comedi core does the auto config
it will call the (*auto_attach) function, vmk80xx_auto_attach(), which
then locates the correct private data in the static array by checking
to see if it has been 'probed' and that the 'intf' variable matches
the usb_interface pointer for the usb device.

Now that the private data is clean after failed usb probes and disconnects
we don't have to worry about have a garbage 'intf' value in the private
data that might match.

Remove the 'probed' flag from the private data and just use the 'intf'
pointer to detect the match.

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>
2013-02-05 18:07:11 -08:00
H Hartley Sweeten
db7dabf707 staging: comedi: vmk80xx: make sure private data is clean when detached
Currently the private data used in this driver is stored in a static
array. During the usb (*probe) and empty location is found in this
array for use by the usb device. Some initialization of the private
data is then done before comedi_usb_auto_config() is called to allow
the comedi core to attach its comedi_device to the usb device.

The (*probe) can fail for various reasons. If it does, make sure that
the private data is clean before returning an error.

The usb (*disconnect) simply calls comedi_usb_auto_unconfig() to
allow the comedi core to disconnect its comedi_device from the usb
device. Since the private data points to the static array it cannot
be kfree'ed during the detach. Instead make sure it clean before
leaving the detach.

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>
2013-02-05 18:07:10 -08:00
H Hartley Sweeten
1cc8f8854c staging: comedi: vmk80xx: remove private data 'count'
The 'count' in the private data is only used in a couple dev_info()
kernel messages. These messages are just added noise.

Remove the 'count' variable in the private data as well as the
dev_info() messages.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-02-05 18:07:10 -08:00
H Hartley Sweeten
78f8fa7f00 staging: comedi: vmk80xx: factor out usb buffer allocation
Factor the code that allocates the usb buffers out of vmk80xx_usb_probe().

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>
2013-02-05 18:07:10 -08:00
H Hartley Sweeten
49253d542c staging: comedi: vmk80xx: factor out usb endpoint detection
Factor the code that detects the usb endpoints out of vmk80xx_usb_probe().

Cleanup the detection code in the new 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>
2013-02-05 18:07:10 -08:00
H Hartley Sweeten
da7b18ee8b staging: comedi: vmk80xx: consistently use the same local var names
Rename some of the local variables used in this driver to make the
code easier to maintain and understand.

s/udev/usb	the usb_device that the comedi_driver is attached to
s/dev/devpriv	the private data of the comedi_device
s/cdev/dev	the comedi_device

Also, use some local variables in a couple of the functions to tidy
up the code a bit.

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>
2013-02-05 18:07:10 -08:00
H Hartley Sweeten
dc49cbfc67 staging: comedi: vmk80xx: rename struct vmk80xx_usb
The struct vmk80xx_usb is actually the private data for the
comedi_device. For aesthetic reasons, rename the struct to
vmk80xx_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>
2013-02-05 18:07:10 -08:00
H Hartley Sweeten
9f4d4de308 staging: comedi: vmk80xx: remove VMK80XX_SUBD_* enum
These enum values are only used in the initialization of the
comedi_subdevices. They don't help make the code any clearer
so just remove them.

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>
2013-02-05 18:07:10 -08:00
H Hartley Sweeten
70ba1a5993 staging: comedi: vmk80xx: remove common and unused boardinfo
Some of the information in the boardinfo is common for both boards
supported by this driver. Remove that information from the boardinfo
and just initialize the subdevice values directly.

Also, remove any information in the boardinfo that is not used in
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>
2013-02-05 18:07:09 -08:00
H Hartley Sweeten
0dd772bf76 staging: comedi: vmk80xx: save the boardinfo in the comedi_device
Save a copy of the boardinfo pointer in the comedi_device 'board_ptr'.
The subdevice functions can then simply get it using the comedi_board()
helper.

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>
2013-02-05 18:07:09 -08:00
H Hartley Sweeten
20d6007755 staging: comedi: vmk80xx: move boardinfo into a const array
The normal way of presenting the board specific information in comedi
drivers is store the data in a static const array. This data is then
accessed using a pointer, normally the comedi_device 'board_ptr',

Move the boardinfo for the two boards supported by this driver from
the vmk80xx_usb_probe() function into a static const array.

Change the access of this information so a pointer is 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>
2013-02-05 18:07:09 -08:00
H Hartley Sweeten
ce87422743 staging: comedi: vmk80xx: use comedi_auto_unconfig() for (*disconnect)
The usb_driver (*disconnect) in this driver is simply a wrapper around
comedi_auto_unconfig(). Just use comedi_auto_unconfig() directly for
the (*disconnect).

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>
2013-02-05 18:07:09 -08:00
H Hartley Sweeten
9377b9234f staging: comedi: vmk80xx: move usb_driver (*disconnect) code
The usb_driver (*disconnect) in this driver calls the comedi core
comedi_usb_auto_unconfig() which calls the comedi_driver (*detach).

Move the code in the (*disconnect) to the (*detach) to get all the
disconnect/detach in one place.

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>
2013-02-05 18:07:09 -08:00
H Hartley Sweeten
07b502f50b staging: comedi: vmk80xx: remove support for manual attaching
This comedi USB driver supports attaching with the auto config
mechanism. Remove the manual attaching support using the
COMEDI_DEVCONFIG ioctl.

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>
2013-02-05 18:07:09 -08:00
Ian Abbott
cc400e185c staging: comedi: check s->async for poll(), read() and write()
Some low-level comedi drivers (incorrectly) point `dev->read_subdev` or
`dev->write_subdev` to a subdevice that does not support asynchronous
commands.  Comedi's poll(), read() and write() file operation handlers
assume these subdevices do support asynchronous commands.  In
particular, they assume `s->async` is valid (where `s` points to the
read or write subdevice), which it won't be if it has been set
incorrectly.  This can lead to a NULL pointer dereference.

Check `s->async` is non-NULL in `comedi_poll()`, `comedi_read()` and
`comedi_write()` to avoid the bug.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-02-05 11:23:32 -08:00
H Hartley Sweeten
4a79f73017 staging: comedi: remove 'comedi_autoconfig' module parameter
This module parameter is used to enable the auto config mechanism
in the comedi core. Most of the PCI, PCMCIA, and USB drivers have
been converted to use the auto config mechanism and will not attach
if it is disabled.

Since the 'comedi_autoconfig' parameter is defaulted to true, just
remove it so that the comedi drivers that use auto config will
always be able to 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>
2013-02-05 11:22:08 -08:00
H Hartley Sweeten
bd7807f964 staging: comedi: quatech_daqp_cs: factor out common ai scanlist code
Factor the code that programs the analog input scanlist out of the
daqp_ai_insn_read() and daqp_ai_cmd() functions.

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>
2013-02-05 11:18:58 -08:00
H Hartley Sweeten
d35dcc89fc staging: comedi: quatech_daqp_cs: fix daqp_ao_insn_write()
The (*insn_write) functions are expected to write 'insn->n' number
of samples to the channel. Fix this function so it works as the
comedi core expects.

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>
2013-02-05 11:18:58 -08:00
H Hartley Sweeten
6a911d8aa5 staging: comedi: quatech_daqp_cs: use (*insn_bits) for digital outputs
Change the subdevice operation used to write the digital outputs from
a (*insn_write) to a (*insn_bits) function. The (*insn_write) functions
are expected to write 'insn->n' number of samples. The (*insn_bits)
functions just write a single sample (insn->n = 1). Change the return
from '1' to 'insn->n' to clarify what the return is.

Using an (*insn_bits) function to write the digital outputs also allows
the user to read the current state of the output channels.

Fix the io operation used to update the digital outputs. The register is
only 8-bits and should by updated with an outb() not an outw().

Also, set the 'maxdata' for the subdevice. For digital io this value
should be '1' (digital io can only be 1 or 0).

Remove the setting of the len_chanlist for the subdevice. This variable
only has meaning for subdevices that support asynchronous commands. The
comedi core will initialize it appropriately during the postconfig.

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>
2013-02-05 11:18:58 -08:00
H Hartley Sweeten
62100fefbc staging: comedi: quatech_daqp_cs: use (*insn_bits) for digital inputs
Change the subdevice operation used to read the digital inputs from
a (*insn_read) to a (*insn_bits) function. The (*insn_read) functions
are expected to read 'insn->n' number of samples. The (*insn_bits)
functions just read a single sample (insn->n = 1). Change the return
from '1' to 'insn->n' to clarify what the return is.

Also, set the 'maxdata' for the subdevice. For digital io this value
should be '1' (digital io can only be 1 or 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>
2013-02-05 11:18:58 -08:00
H Hartley Sweeten
491cc0b042 staging: comedi: quatech_daqp_cs: remove unused define
The MAX_DEV define is no longer used in this driver. Remove 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>
2013-02-05 11:18:58 -08:00
H Hartley Sweeten
1801726e87 staging: comedi: quatech_daqp_cs: rename the private data struct
The private data in this driver is associated with the comedi_device
pointer not the pcmcia_device. For aesthetic reasons, rename the
private data struct from local_into_t to daqp_private.

Also, rename the local variables used for the private data from
local to devpriv as that is more common in 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>
2013-02-05 11:18:57 -08:00
H Hartley Sweeten
c12717423e staging: comedi: quatech_daqp_cs: store private data in the comedi_device
All the comedi_subdevices in this driver use the same 'local' private data.
Instead of storing the pointer to the private data in each subdevice, just
store it in the comedi_device.

Also, instead of passing the private data pointer to pcmcia_request_irq()
in link->priv, pass the comedi_device pointer. This allows removing the
comedi_device and comedi_subdevice pointers from the private data. We can
get them as needed from the void * in the interrupt function.

Fix the pcmcia suspend/resume functions so they use the comedi_device
pointer stored in link->priv to then get the private data 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>
2013-02-05 11:18:57 -08:00
H Hartley Sweeten
9c1dcce9c6 staging: comedi: quatech_daqp_cs: ao subdevice does not support commands
The analog output subdevice does not support aynchronous commands.
Don't set the dev->write_subdev to this subdevice.

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>
2013-02-05 11:18:57 -08:00
H Hartley Sweeten
25736670bc staging: comedi: quatech_daqp_cs: use comedi_pcmcia_disable() for (*detach)
The (*detach) function, daqp_detach() is now a simple wrapper around
comedi_pcmcia_disable(). Just use comedi_pcmcia_disable() directly for
the (*detach).

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>
2013-02-05 11:18:57 -08:00
H Hartley Sweeten
87fe1452c6 staging: comedi: quatech_daqp_cs: use comedi_pcmcia_{enable, disable}
Use the comedi_pcmcia_{enable,disable} helpers to enable/disable
the PCMCIA device.

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>
2013-02-05 11:18:57 -08:00
H Hartley Sweeten
c04edbf2f4 staging: comedi: quatech_daqp_cs: convert to auto attach
Convert this pcmcia driver to the comedi auto attach mechanism.

This allows getting rid of the static data that held "A list of
"instances" of the device" that was used to pass the pcmcia_device
pointer from the pcmcia_driver to the comedi_driver.

Also, remove the now unused variables in the private data that
were used to pass the pcmcia_device.

Remove the code that pulled the model number of the card out of
the PCMCIA CIS and stashed it in the private data since it is
not used in 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>
2013-02-05 11:18:57 -08:00
H Hartley Sweeten
5056d87a88 staging: comedi: ni_daq_700: use comedi_pcmcia_disable() for (*detach)
The (*detach) function, daq700_detach() is now a simple wrapper around
comedi_pcmcia_disable(). Just use comedi_pcmcia_disable() directly for
the (*detach).

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>
2013-02-04 14:47:19 -08:00
H Hartley Sweeten
7dc99109f5 staging: comedi: ni_daq_700: use comedi_pcmcia_{enable, disable}
Use the comedi_pcmcia_{enable,disable} helpers to enable/disable
the PCMCIA device.

This driver does not use interrupts and is not an audio device,
remove CONF_ENABLE_IRQ and CONF_AUTO_AUDIO from the link->config_flags.

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>
2013-02-04 14:47:19 -08:00
H Hartley Sweeten
95f932cea3 staging: comedi: das08_cs: use comedi_pcmcia_{enable, disable}
Use the comedi_pcmcia_{enable,disable} helpers to enable/disable
the PCMCIA device.

This driver does not use interrupts so remove CONF_ENABLE_IRQ from
the link->config_flags.

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>
2013-02-04 14:47:19 -08:00
H Hartley Sweeten
7fadd565f0 staging: comedi: cb_das16_cs: use comedi_pcmcia_disable() for (*detach)
The (*detach) function, das16cs_detach() is a simple wrapper around
comedi_pcmcia_disable(). Just use comedi_pcmcia_disable() directly
for the (*detach).

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>
2013-02-04 14:47:19 -08:00
H Hartley Sweeten
bcd22e8ece staging: comedi: cb_das16_cs: use pcmcia_request_irq()
Use pcmcia_request_irq() instead of request_irq() to request the
irq for the PCMCIA device. This allows the PCMCIA core to clean
up the registration in pcmcia_disable_device().

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>
2013-02-04 14:47:19 -08:00
H Hartley Sweeten
9e29ce104a staging: comedi: cb_das16_cs: use comedi_pcmcia_{enable, disable}
Use the comedi_pcmcia_{enable,disable} helpers to enable/disable
the PCMCIA device.

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>
2013-02-04 14:47:18 -08:00
H Hartley Sweeten
ddb2d0a018 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>
2013-02-04 14:47:18 -08:00
H Hartley Sweeten
7f70410fe0 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>
2013-02-03 17:49:16 -08:00
Ian Abbott
4c4bc25d0f staging: comedi: ni_labpc: correct differential channel sequence for AI commands
Tuomas <tvainikk _at_ gmail _dot_ com> reported problems getting
meaningful output from a Lab-PC+ in differential mode for AI cmds, but
AI insn reads gave correct readings.  He tracked it down to two
problems, one of which is addressed by this patch.

It seems the setting of the channel bits for particular scanning modes
was incorrect for differential mode.  (Only half the number of channels
are available in differential mode; comedi refers to them as channels 0,
1, 2 and 3, but the hardware documentation refers to them as channels 0,
2, 4 and 6.)  In differential mode, the setting of the channel enable
bits in the command1 register should depend on whether the scan enable
bit is set.  Effectively, we need to double the comedi channel number
when the scan enable bit is not set in differential mode.  The scan
enable bit gets set when the AI scan mode is `MODE_MULT_CHAN_UP` or
`MODE_MULT_CHAN_DOWN`, and gets cleared when the AI scan mode is
`MODE_SINGLE_CHAN` or `MODE_SINGLE_CHAN_INTERVAL`.  The existing test
for whether the comedi channel number needs to be doubled in
differential mode is incorrect in `labpc_ai_cmd()`.  This patch corrects
the test.

Thanks to Tuomas for suggesting the fix.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Cc: <stable@vger.kernel.org> # 3.7.x, 3.8.x
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-02-03 17:45:07 -08:00
Ian Abbott
22056e2b46 staging: comedi: ni_labpc: set up command4 register *after* command3
Tuomas <tvainikk _at_ gmail _dot_ com> reported problems getting
meaningful output from a Lab-PC+ in differential mode for AI cmds, but
AI insn reads gave correct readings.  He tracked it down to two
problems, one of which is addressed by this patch.

It seems that writing to the command3 register after writing to the
command4 register in `labpc_ai_cmd()` messes up the differential
reference bit setting in the command4 register.  Set up the command4
register after the command3 register (as in `labpc_ai_rinsn()`) to avoid
the problem.

Thanks to Tuomas for suggesting the fix.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Cc: <stable@vger.kernel.org> # 3.7.x, 3.8.x
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-02-03 17:45:07 -08:00
Ian Abbott
de06d7c6b8 staging: comedi: restrict comedi_set_hw_dev() usage
Don't allow comedi drivers to change `dev->hw_dev` using
`comedi_set_hw_dev()` if it's already been set.  Return `-EEXIST` in
that case.

`dev->hw_dev` needs to be set to NULL by the core during clean-up of the
comedi device, so add a local function `comedi_clear_hw_dev()` to do
that.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-02-03 17:44:20 -08:00
Ian Abbott
da71751177 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>
2013-02-03 17:44:19 -08:00
Ian Abbott
f65cc5447e staging: comedi: change comedi_alloc_subdevice_minor parameters
`comedi_alloc_subdevice_minor()` doesn't really need a parameter
pointing to a `struct comedi_device` as it can get this information from
the parameter pointing to a `struct comedi_subdevice`.  Just pass the
subdevice parameter.

Signed-by: Ian Abbott <abbotti@mev.co.uk>

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-02-03 17:43:28 -08:00
Ian Abbott
e9ab1c2f7e 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>
2013-02-03 17:43:27 -08:00
H Hartley Sweeten
f91f9beaa1 staging: comedi: das08: split out bus specific code
Split the bus specific ISA/PC-104 and PCI code out of this driver
and create two new drivers, das08_isa and das08_pci.

This allows removing all the #ifdef'ery in the das08 driver that
handled if the CONFIG_COMEDI_DAS08_{ISA,PCI} options were enabled.

It also makes the PCI driver cleanly Plug-and-Play since the comedi
driver only has an auto_attach callback. Previously it also had an
attach callback in order to handle the ISA cards.

Since the PCMCIA support was already split out, we can also remove
the now unused enum das08_bustype and it's use in the boardinfo.
The bus specific code deals with the bustype automatically before
it calls the common attach function in das08.

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>
2013-02-03 17:33:08 -08:00
H Hartley Sweeten
42d1aeea84 staging: comedi: ni_mio_cs: convert to auto attach
Convert this pcmcia driver to the comedi auto attach mechanism.

This allows getting rid of the "hack" needed to pass the pcmcia_device
pointer from the pcmcia_driver to the comedi_driver.

We still need the boardinfo because ni_mio_common.c uses it. Cleanup
ni_getboardtype() so it returns a pointer to the boardinto instead
of 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>
2013-02-03 17:29:47 -08:00
H Hartley Sweeten
42e4472ef1 staging: comedi: ni_labpc_cs: convert to auto attach
Convert this pcmcia driver to the comedi auto attach mechanism.

This allows getting rid of the "hack" needed to pass the pcmcia_device
pointer from the pcmcia_driver to the comedi_driver.

We still need the boardinfo because the ni_labpc driver uses it. But
we can get rid of the duplicate that allowed attaching with the driver
name.

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>
2013-02-03 17:29:47 -08:00
H Hartley Sweeten
89d714ce63 staging: comedi: ni_daq_dio24: remove some unnecessary includes
This driver does not use anything from the interrupt.h, slab.h,
and ioport.h headers. Don't bother including them.

For aesthetic reasons, move the include of the comedi specific
8255.h header to the end of the includes.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-02-03 19:27:38 -06:00