Commit Graph

2879 Commits

Author SHA1 Message Date
Ian Abbott c0729eeefd staging: comedi: comedi_test: fix race when cancelling command
Éric Piel reported a kernel oops in the "comedi_test" module.  It was a
NULL pointer dereference within `waveform_ai_interrupt()` (actually a
timer function) that sometimes occurred when a running asynchronous
command is cancelled (either by the `COMEDI_CANCEL` ioctl or by closing
the device file).

This seems to be a race between the caller of `waveform_ai_cancel()`
which on return from that function goes and tears down the running
command, and the timer function which uses the command.  In particular,
`async->cmd.chanlist` gets freed (and the pointer set to NULL) by
`do_become_nonbusy()` in "comedi_fops.c" but a previously scheduled
`waveform_ai_interrupt()` timer function will dereference that pointer
regardless, leading to the oops.

Fix it by replacing the `del_timer()` call in `waveform_ai_cancel()`
with `del_timer_sync()`.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reported-by: Éric Piel <piel@delmic.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-01-07 14:48:25 -08:00
Ian Abbott 34ffb33e09 staging: comedi: Kconfig: COMEDI_NI_AT_A2150 should select COMEDI_FC
The 'ni_at_a2150' module links to `cfc_write_to_buffer` in the
'comedi_fc' module, so selecting 'COMEDI_NI_AT_A2150' in the kernel config
needs to also select 'COMEDI_FC'.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Cc: stable <stable@vger.kernel.org> # 3.6+
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-01-07 14:48:24 -08:00
Ian Abbott 7d3135af39 staging: comedi: prevent auto-unconfig of manually configured devices
When a low-level comedi driver auto-configures a device, a `struct
comedi_dev_file_info` is allocated (as well as a `struct
comedi_device`) by `comedi_alloc_board_minor()`.  A pointer to the
hardware `struct device` is stored as a cookie in the `struct
comedi_dev_file_info`.  When the low-level comedi driver
auto-unconfigures the device, `comedi_auto_unconfig()` uses the cookie
to find the `struct comedi_dev_file_info` so it can detach the comedi
device from the driver, clean it up and free it.

A problem arises if the user manually unconfigures and reconfigures the
comedi device using the `COMEDI_DEVCONFIG` ioctl so that is no longer
associated with the original hardware device.  The problem is that the
cookie is not cleared, so that a call to `comedi_auto_unconfig()` from
the low-level driver will still find it, detach it, clean it up and free
it.

Stop this problem occurring by always clearing the `hardware_device`
cookie in the `struct comedi_dev_file_info` whenever the
`COMEDI_DEVCONFIG` ioctl call is successful.

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-01-07 14:22:37 -08:00
Éric Piel 34b55d8c48 staging: comedi: fix minimum AO period for NI 625x and NI 628x
The minimum period was set to 357 ns, while the divider for these boards is 50
ns. This prevented to output at maximum speed as ni_ao_cmdtest() would return
357 but would not accept it.

Not sure why it was set to 357 ns (this was done before the git history,
which starts 5 years ago). My guess is that it comes from reading the
specification stating a 2.8 MHz rate (~ 357 ns). The latest
specification states a 2.86 MHz rate (~ 350 ns), which makes a lot
more sense.

Tested on a pci-6251.

Signed-off-by: Éric Piel <piel@delmic.com>
Acked-By: Ian Abbott <abbotti@mev.co.uk>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-01-07 14:16:49 -08:00
Linus Torvalds a2013a13e6 Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial
Pull trivial branch from Jiri Kosina:
 "Usual stuff -- comment/printk typo fixes, documentation updates, dead
  code elimination."

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial: (39 commits)
  HOWTO: fix double words typo
  x86 mtrr: fix comment typo in mtrr_bp_init
  propagate name change to comments in kernel source
  doc: Update the name of profiling based on sysfs
  treewide: Fix typos in various drivers
  treewide: Fix typos in various Kconfig
  wireless: mwifiex: Fix typo in wireless/mwifiex driver
  messages: i2o: Fix typo in messages/i2o
  scripts/kernel-doc: check that non-void fcts describe their return value
  Kernel-doc: Convention: Use a "Return" section to describe return values
  radeon: Fix typo and copy/paste error in comments
  doc: Remove unnecessary declarations from Documentation/accounting/getdelays.c
  various: Fix spelling of "asynchronous" in comments.
  Fix misspellings of "whether" in comments.
  eisa: Fix spelling of "asynchronous".
  various: Fix spelling of "registered" in comments.
  doc: fix quite a few typos within Documentation
  target: iscsi: fix comment typos in target/iscsi drivers
  treewide: fix typo of "suport" in various comments and Kconfig
  treewide: fix typo of "suppport" in various comments
  ...
2012-12-13 12:00:02 -08:00
H Hartley Sweeten 05fcdcede0 staging: comedi: addi_apci_2032: fix interrupt support
This board supports two interrupt sources:

VCC : detects when the external supply voltage drops below 5V
CC  : over temperature diagnostic

Currently the interrupt support is tied into the digital output
subdevice. It's also broken since it does not follow the comedi
API.

Create a new digital input subdevice to handle the interrupts.

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>
2012-11-29 18:05:31 -08:00
H Hartley Sweeten b3b7dab758 staging: comedi: addi_apci_2032: move i_APCI2032_ConfigDigitalOutput()
For aesthetic reasons, move this function.

This function has nothing to do with the digital outputs. It's used
to enable the interrupt sources that the board can generate.

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>
2012-11-29 18:05:31 -08:00
H Hartley Sweeten 7c7c42cdf6 staging: comedi: addi_apci_2032: remove the timer s->range_table
The timer subdevice does not have a digital range. Its range of
0 to 0xff is the value used to set the reload timer.

Remove the setting of s->range_table. The comedi core will then
set it to range_unknown.

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>
2012-11-29 18:05:31 -08:00
H Hartley Sweeten cf11088242 staging: comedi: addi_apci_2032: cleanup the subdevice init
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>
2012-11-29 18:05:31 -08:00
H Hartley Sweeten 23fb174746 staging: comedi: addi_apci_2032: fix the watchdog timer subdevice
The watchdog timer on this board functions exactly like the one on
the apci_1516 board. Fix the i_APCI2032_StartStopWriteWatchdog and
i_APCI2032_ConfigWatchdo functions so that the watchdog follows the
comedi API.

Rename the CamelCase function i_APCI2032_StartStopWriteWatchdog to
apci2032_wdog_insn_writ. This function is used to "ping" the watchdog.

Rename the CamelCase function i_APCI2032_ConfigWatchdog to
apci2032_wdog_insn_config. This function is used to enable/disable
the watchdog and set the 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>
2012-11-29 18:05:31 -08:00
H Hartley Sweeten f82a66132b staging: comedi: addi_apci_2032: remove need for addi-data/addi_common.h
Only the ADDIDATA_ENABLE define is used from this header. Just
open-code the value to remove the dependency and remove the include.

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>
2012-11-29 18:05:31 -08:00
H Hartley Sweeten dce10abc49 staging: comedi: addi_apci_2032: remove use of struct addi_private
The only data in addi_private used in this driver is:

tsk_Current - used with send_sig to signal userspace when an interrupt
has occurred. Interrupt support in this driver does not follow the
standard comedi API so this functionality is currently broken. This
will be addressed.

b_OutputMemoryStatus - used in the addi-data "common" code to enable
reading of the eeprom. Eeprom support is not needed by this driver
and has been removed.

Since this data is not needed, remove the use of struct addi_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>
2012-11-29 18:05:31 -08:00
H Hartley Sweeten 7b5dd1cc98 staging: comedi: addi_apci_2032: fix i_APCI2032_ReadWatchdog()
This function is used by the watchdog subdevice to read the status of
the watchdog. Rename the CamelCase function to apci2032_wdog_insn_read
and fix the function to return the status value insn->n times like
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>
2012-11-29 18:05:30 -08:00
H Hartley Sweeten 7180eb30de staging: comedi: addi_apci_2032: cleanup register map defines
Cleanup the defines a bit and add the missing information for the
bits in the registers.

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>
2012-11-29 18:05:30 -08:00
H Hartley Sweeten d02178b7fb staging: comedi: addi_apci_2032: merge in hwdrv_apci2032.c
Merge the code from hwdrv_apci2032.c into the driver and delete the
now unused file.

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>
2012-11-29 18:05:30 -08:00
H Hartley Sweeten 61034e002d staging: comedi: addi_apci_2032: cleanup the s->subdev_flags
The flags SDF_GROUND and SDF_COMMON only have meaning for analog
input/output subdevices. Remove these flags from the digital
output and timer subdevices in this driver.

The digital output subdevice does not need the SDF_READABLE flag.
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>
2012-11-29 18:05:30 -08:00
H Hartley Sweeten c0c3c7dfc1 staging: comedi: addi_apci_2032: remove boardinfo
This driver only supports a single board type. Remove the boardinfo
and just use the information directly where 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>
2012-11-29 18:05:30 -08:00
H Hartley Sweeten 0c33bdd01a staging: comedi: addi_apci_2032: only allocate needed subdevices
The addi-data "common" code always allocated 7 subdevices. This driver
only requires 2. Change the allocation and remove the unused subdevices.

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>
2012-11-29 18:05:30 -08:00
H Hartley Sweeten 490555966e staging: comedi: addi_apci_2032: remove use of devpriv->s_EeParameters
This driver no longer reads the eeprom to find the board specific data,
all the necessary data is in the boardinfo. Use the boardinfo directly
instead of passing through devpriv->s_EeParameters.

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>
2012-11-29 18:05:30 -08:00
H Hartley Sweeten ff5eb17ef4 staging: comedi: addi_apci_2032: don't read the unused PCI bars
This driver only uses PCI bar 1 (dev->iobase), doon't bother reading
the unused PCI bars.

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>
2012-11-29 18:05:29 -08:00
H Hartley Sweeten f5f760e1d3 staging: comedi: addi_apci_2032: remove devpriv->iobase usage
The iobase address stored in devpriv->iobase is also stored in dev->iobase.
Use that instead.

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>
2012-11-29 18:05:29 -08:00
H Hartley Sweeten dba18c58e0 staging: comedi: addi_apci_2032: remove unnecessary info from boardinfo
The i_IorangeBase[012], i_PCIEeprom, and pc_EepromChip data in the
boardinfo was only needed to work out the usage of the PCI bars.
This is no longer needed so remove the 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>
2012-11-29 18:05:29 -08:00
H Hartley Sweeten 70ff406599 staging: comedi: addi_apci_2032: simplify the PCI bar reading
The board supported by this driver has a 93c76 eeprom. Knowing this
information allows simplifying the code that reads the PCI bars to
get the iobase address.

Also, since the 'dw_AiBase' is not ioremap'ed we can remove the iounmap
in 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>
2012-11-29 18:05:29 -08:00
H Hartley Sweeten 791c9792ff staging: comedi: addi_apci_2032: absorb i_APCI2032_Reset()
This is the only 'reset' function used by the driver, remove it
from the boardinfo and absorb the code from hwdrv_apci2032.c into
the driver.

Rename the CamelCase function i_ADDI_Reset() to apci2032_reset().

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>
2012-11-29 18:05:29 -08:00
H Hartley Sweeten 6f92e11a24 staging: comedi: addi_apci_2032: remove unnecessary include
This include is no longer 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>
2012-11-29 18:05:29 -08:00
H Hartley Sweeten 64b42f5e4a staging: comedi: addi_apci_2032: remove eeprom support code
Reading the eeprom on the board supported by this driver is not
necessary. All the information required is in the boardinfo.

Remove the eeprom support code since it's not really interesting
or useful.

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>
2012-11-29 18:05:29 -08:00
H Hartley Sweeten 3583c53bd5 staging: comedi: addi_apci_2032: board does not have analog inputs
The board supported by this driver does not have analog inputs. Remove
the subdevice init for 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>
2012-11-29 18:05:28 -08:00
H Hartley Sweeten 977b6944aa staging: comedi: addi_apci_2032: board does not have analog outputs
The board supported by this driver does not have analog outputs. Remove
the subdevice init for 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>
2012-11-29 18:05:28 -08:00
H Hartley Sweeten 0cbbbbb9f7 staging: comedi: addi_apci_2032: board does not have digital inputs
The board supported by this driver does not have digital inputs. Remove
the subdevice init for 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>
2012-11-29 18:05:28 -08:00
H Hartley Sweeten 84987a16ca staging: comedi: addi_apci_2032: board does not have ttl i/o
The board supported by this driver does not have ttl i/o. Remove the
subdevice init for 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>
2012-11-29 18:05:28 -08:00
H Hartley Sweeten 25adf2ccf6 staging: comedi: addi_apci_2032: separate from addi_common.c
This driver is for a simple 32 channel digital output board. Using the
addi-data "common" code introduces a lot of bloat.

Copy the code in addi_common.c to this driver and remove the #include
that caused addi_common.c to be compiled with this driver. This will
allow removing the bloat.

Rename the attach_pci and detach functions so they have namespace
associated with this 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>
2012-11-29 18:05:28 -08:00
H Hartley Sweeten 1b6c710e2a staging: comedi: remove unnecessary '#define __NO_VERSION__'
This define is no longer required for multi-file modules.

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>
2012-11-27 09:16:38 -08:00
H Hartley Sweeten 1be287f9db staging: comedi: remove unnecessary '#define _GNU_SOURCE'
This define is 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>
2012-11-27 09:16:38 -08:00
Matt Phillips d0cdf020ed staging: comedi: ni_tio.h fixed coding style issue with pointer variables
Fixed coding style issues with pointers

Signed-off-by: Matt Phillips <mathewrphillips@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-11-26 16:21:19 -08:00
Bill Pemberton 53b8001985 staging: comedi: remove use of __devexit
CONFIG_HOTPLUG is going away as an option so __devexit is no
longer needed.

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-11-21 14:14:56 -08:00
Bill Pemberton a690b7e535 staging: comedi: remove use of __devinit
CONFIG_HOTPLUG is going away as an option so __devinit is no longer
needed.

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-11-21 14:14:56 -08:00
Bill Pemberton a471eace7b staging: comedi: remove use of __devexit_p
CONFIG_HOTPLUG is going away as an option so __devexit_p is no longer
needed.

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-11-21 14:14:56 -08:00
Ian Abbott 971b5e5653 staging: comedi: me_daq: remove broken workaround for PLX bug
The PLX PCI 9050 interface chip has a bug where its local configuration
registers accessible through PCI BAR 0 and/or PCI BAR 1 (depending on
settings loaded from a serial EEPROM or local bus processor) are
unreadable (always read 0 instead of the true register values) if the
base address starts on an odd multiple of 0x80 (i.e.  has bit 7 set to
1).

The "me_daq" driver attempts to work around this by writing to the PCI
config space to swap the addresses assigned to PCI BAR 0 and PCI BAR 5
(which has been initially configured by serial EEPROM load as a spare
region of the same length as the PCI BAR 0 region).  (If the PCI BAR 5
region is absent, it attempts to reduce the PCI BAR 0 address by 0x80,
which is likely to cause havoc for some other device, but that case
shouldn't be reachable in practice.)

The workaround in the driver is ineffective because it has already
ioremapped the memory from `pci_resource_start(pcidev, 0)` *before* it
does the workaround, so after swapping PCI BAR 0 and PCI BAR 5, this
memory will end up accessing whatever onboard registers PCI BAR 5 was
linked to instead of the local configuration registers.  It also leaves
the addresses in the physical PCI BAR registers set differently to the
resource start addresses recorded in the `struct pci_dev`.

The workaround could be fixed by ioremapping `pci_resource_start(pcidev,
5)` if the PCI BAR addresses were physically swapped (and the fallback
workaround of subtracting 0x80 from the base address should really be
removed altogether).  However, it's not really worth it.  This sort of
thing should be worked around in "drivers/pci/quirks.c" by ensuring that
PCI BAR 0 and/or PCI BAR 1 do not end up on an odd multiple of 0x80
bytes.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-11-21 14:13:44 -08:00
Masanari Iida 02582e9bcc treewide: fix typo of "suport" in various comments and Kconfig
Signed-off-by: Masanari Iida <standby24x7@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2012-11-19 14:16:09 +01:00
H Hartley Sweeten dba2939c8d staging: comedi: cb_pcidas64: use cfc_check_trigger_arg_*() helpers
Use the new helpers in the step 3 tests of {ai,ao}_cmdtest().

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>
2012-11-14 19:42:37 -08:00
Ian Abbott 581a7ddec1 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>
2012-11-14 16:25:48 -08:00
Ian Abbott ddbd029903 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>
2012-11-14 16:25:48 -08:00
Ian Abbott a588da1d5a staging: comedi: simplify comedi_auto_attach()
`comedi_auto_config()` just calls internal function
`comedi_auto_config_helper()`, passing it a wrapper function
`comedi_auto_config_wrapper()` to handle the specifics of checking and
calling the low-level comedi driver's `auto_attach()` handler.

Since there are no other callers of `comedi_auto_config_helper()` or
`comedi_auto_config_wrapper()`, combine everything into the single
exported function `comedi_auto_config()`.

Change the ordering of the check for existence of the low-level comedi
driver's `auto_attach()` handler and the allocation of the comedi minor
device number.  This means the log message warning of the absence of the
handler now has to be refer to the hardware device instead of the
not-yet-allocated comedi device.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-11-14 16:25:48 -08:00
Ian Abbott af448aca8f staging: comedi: don't check driver->auto_attach
There is no need for `comedi_pci_auto_config()` and
`comedi_usb_auto_config()` to check that `driver->auto_attach` is
non-null before calling `comedi_auto_attach()` as this check is done by
`comedi_auto_config()` itself (actually by
`comedi_auto_config_wrapper()`).  Remove the unnecessary checks.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-11-14 16:25:47 -08:00
Ian Abbott 45d6f1965e staging: comedi: don't call attach_usb handler
All the Comedi drivers that call `comedi_usb_auto_config()` have
replaced the `attach_usb()` handler in their `struct comedi_driver` with
a `auto_attach()` handler, so there is no need to check for the
existence of the `attach_usb()` handler any more.  Remove this check and
the code that calls it.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-11-14 16:25:47 -08:00
Ian Abbott a692e9743a staging: comedi: don't call attach_pci handler
All the Comedi drivers that call `comedi_pci_auto_config()` have
replaced the `attach_pci()` handler in their `struct comedi_driver` with
a `auto_attach()` handler, so there is no need to check for the
existence of the `attach_pci()` handler any more.  Remove this check and
the code that calls it.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-11-14 16:25:47 -08:00
Ian Abbott 847d74a260 staging: comedi: remove old auto-config
All the Comedi drivers that call `comedi_pci_auto_config()` or
`comedi_usb_auto_config()` define a `auto_attach()` handler in their
`struct comedi_driver`.  There is no need to fall back to abusing the
`attach()` handler any more, so remove the code that supports that.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-11-14 16:25:47 -08:00
Ian Abbott 206cb10816 staging: comedi: define operations for INSN_CONFIG_DIGITAL_TRIG
The 'addi_apci_1032' driver recently started supporting the
`INSN_CONFIG_DIGITAL_TRIG` configuration instruction, but as no other
drivers were using it before, there was no existing practice of how the
instruction should look.

Define the format to be something a bit more configurable.  In
particular, a subdevice might have more than one trigger requiring an ID
and/or `COMEDI_EV_...` flags to disambiguate them, a trigger might have
more than 32 inputs, and a trigger might need several
`INSN_CONFIG_DIGITAL_TRIG` configuration instructions to configure
completely (if there are more than 32 inputs or if it uses a combination
of edge-triggered and level-triggered inputs).

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-11-14 16:25:08 -08:00
Ian Abbott b0a2b6d8ac staging: comedi: check data length for INSN_CONFIG_DIGITAL_TRIG
The newly defined format for the `INSN_CONFIG_DIGITAL_TRIG`
configuration instruction expects 6 data values.  Check the length in
`check_insn_config_length()` before calling the comedi subdevice's
`insn_config` handler.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-11-14 16:25:08 -08:00
Ian Abbott 33cdce6293 staging: comedi: addi_apci_1032: conform to new INSN_CONFIG_DIGITAL_TRIG
Conform to the new definition of the `INSN_CONFIG_DIGITAL_TRIG`
configuration instruction.

Return an error if the 'trigger number' in `data[1]` is non-zero or if
the configuration operation in `data[2]` is not supported.  Deal with
the 'left-shift' amount in `data[3]`.

The trigger's input channels can only be configured as a set of rising
and falling edges ('OR' mode) or as a set of high and low levels ('AND'
mode).  Preserve the old input channels to the right of the 'left-shift'
value except when switching modes.

(The 'left-shift' support is a bit of an overkill for this driver since
the trigger only has 16 input channels.)

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-11-14 16:25:08 -08:00