comedi.git
12 years agoinclude/linux/firmware.h: Check for FW_ACTION_HOTPLUG.
Ian Abbott [Thu, 31 May 2012 10:08:55 +0000 (11:08 +0100)]
include/linux/firmware.h: Check for FW_ACTION_HOTPLUG.

The FW_ACTION_HOTPLUG and FW_ACTION_NOHOTPLUG macros, and the 'hotplug'
(later renamed 'uevent') parameter of request_firmware_nowait() were
added in vanilla kernel 2.6.14.  Update the include/linux/firmware.h
compatibility code to work with kernels prior to 2.6.14.  If
FW_ACTION_HOTPLUG is not defined, omit the uevent parameter and define
FW_ACTION_HOTPLUG and FW_ACTION_NOHOTPLUG.  The uevent parameter will be
ignored for these older kernels so FW_ACTION_NOHOTPLUG will behave just
like FW_ACTION_HOTPLUG for these older kernels.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
12 years agoDeal with Red Hat backporting request_firmware_nowait change.
Ian Abbott [Thu, 31 May 2012 09:47:10 +0000 (10:47 +0100)]
Deal with Red Hat backporting request_firmware_nowait change.

An extra 'gfp' parameter was added to request_firmware_nowait() in the
vanilla 2.6.33 kernel and the current <linux/firmware.h> compatibility
header checks for this kernel version.  Unfortunately, Red Hat
backported the change to their 2.6.32 kernel so the code in our
compatibility header breaks on those kernels.

Add a simple configure test to see if the gfp parameter is required and
use this to define CONFIG_COMEDI_REQUEST_FIRMWARE_NOWAIT_HAS_GFP if it
is required.  Change out <linux/firmware.h> compatibility header to
check this macro instead of checking the kernel version directly.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
12 years agoinclude/linux/firmware.h: Define COMEDI_RELEASE_FIRMWARE_NOWAIT(fw)
Ian Abbott [Thu, 31 May 2012 08:55:02 +0000 (09:55 +0100)]
include/linux/firmware.h: Define COMEDI_RELEASE_FIRMWARE_NOWAIT(fw)

The version of request_firmware_nowait() that takes a gfp_t parameter
also expects its callback function to call release_firmware() to free
the firmware, otherwise there is a memory leak.  The older version of
request_firmware_nowait() doesn't want the callback function to free the
firmware.  Define the macro COMEDI_RELEASE_FIRMWARE_NOWAIT(fw) to be
used in the callback function instead of calling release_firmware(fw)
directly.  This does nothing for the older request_firmware_nowait()
API, but calls release_firmware(fw) for the newer
request_firmware_nowait() API.

Change the request_firmware_nowait callback function in the usbdux,
usbduxfast and usbduxsigma drivers to use
COMEDI_RELEASE_FIRMWARE_NOWAIT().

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
12 years agoamplc_pc263: Change DIO subdevice to DO.
Ian Abbott [Tue, 29 May 2012 15:08:03 +0000 (16:08 +0100)]
amplc_pc263: Change DIO subdevice to DO.

This is a relay output card with no inputs.  Its subdevice is currently
configured as a DIO subdevice.  Change it to a DO subdevice and remove
the insn_config hook.

Also removed the deprecated SDF_RT flag.  Leave the SDF_READABLE flag.
Some drivers set this for DO subdevices and some don't.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
12 years agoamplc_pc263: Correct initial state
Ian Abbott [Tue, 29 May 2012 14:51:41 +0000 (15:51 +0100)]
amplc_pc263: Correct initial state

The initial state of the relays is being read incorrectly.  Fix it.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
12 years agocomedi.h: Add clock sources for Amplicon timer subdevice.
Ian Abbott [Mon, 28 May 2012 09:40:42 +0000 (10:40 +0100)]
comedi.h: Add clock sources for Amplicon timer subdevice.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
12 years agoamplc_dio200: Implement timer subdevice for new PCIe boards.
Ian Abbott [Mon, 28 May 2012 09:40:42 +0000 (10:40 +0100)]
amplc_dio200: Implement timer subdevice for new PCIe boards.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
12 years agoamplc_dio200: Add 32-bit register access functions.
Ian Abbott [Mon, 28 May 2012 09:40:42 +0000 (10:40 +0100)]
amplc_dio200: Add 32-bit register access functions.

These will be used to support extra features of the PCIe boards.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
12 years agoamplc_dio200: Change description of counter interrupt sources
Ian Abbott [Mon, 28 May 2012 09:40:42 +0000 (10:40 +0100)]
amplc_dio200: Change description of counter interrupt sources

In the device description comment, change the table of interrupt sources
for counter output interrupt sources to make it clearer that channel 1
is the interrupt source.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
12 years agoamplc_dio200: Allow extra clock and gate sources for PCIe boards.
Ian Abbott [Mon, 28 May 2012 09:40:42 +0000 (10:40 +0100)]
amplc_dio200: Allow extra clock and gate sources for PCIe boards.

One of the enhancements of the new PCIe boards is the addition of extra
clock and gate sources.  Allow clock and gate sources up to 31 for these
boards (compared to 7 for the old boards) although most of those are
reserved for future use.

Add constants to comedi.h for the new clock and gate sources.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
12 years agoamplc_dio200: Enable enhanced features of PCIe boards.
Ian Abbott [Mon, 28 May 2012 09:40:42 +0000 (10:40 +0100)]
amplc_dio200: Enable enhanced features of PCIe boards.

The new PCIe boards have some enhanced features compared to the old PCI
boards, although none of these features are supported by amplc_dio200
yet.

Enable the enhanced features in hardware, and use dio200_layouts[] to
indicate which boards support the enhanced features.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
12 years agoamplc_dio200: Allow generation of PCIe interrupts.
Ian Abbott [Mon, 28 May 2012 09:40:41 +0000 (10:40 +0100)]
amplc_dio200: Allow generation of PCIe interrupts.

The new PCIe boards need a special register setting to allow generation
of interrupts.  Add function dio200_pcie_board_setup() to do this
special set-up for the new PCIe boards.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
12 years agoamplc_dio200: Support PCIe215, PCIe236 and PCIe296.
Ian Abbott [Mon, 28 May 2012 09:40:41 +0000 (10:40 +0100)]
amplc_dio200: Support PCIe215, PCIe236 and PCIe296.

Added preliminary support for the above PCIe boards.  The interrupt
subdevice is not working yet as the boards need some additional
initialization to enable interrupts.  Left an unused subdevice that will
eventually become a timer subdevice.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
12 years agoamplc_dio200: Use register size in board stucture.
Ian Abbott [Mon, 28 May 2012 09:40:41 +0000 (10:40 +0100)]
amplc_dio200: Use register size in board stucture.

Store the length of the main register region in new member 'mainsize' of
'struct dio200_board_struct' and initialize it in each element of
'dio200_boards[]'.

Check PCI resource holding the main registers is long enough.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
12 years agoamplc_dio200: Add PCI BAR information to board structure.
Ian Abbott [Mon, 28 May 2012 09:40:41 +0000 (10:40 +0100)]
amplc_dio200: Add PCI BAR information to board structure.

Add 'mainbar' member to 'struct dio200_board_struct', holding the PCI
BAR number for the main registers.  This is 2 for the PCI boards
currently supported (PCI215 and PCI272).

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
12 years agoamplc_dio200: Support memory-mapped I/O for PCI devices
Ian Abbott [Mon, 28 May 2012 09:40:41 +0000 (10:40 +0100)]
amplc_dio200: Support memory-mapped I/O for PCI devices

The cards currently supported by amplc_dio200  all use port I/O.
Support memory-mapped I/O as well for future PCI/PCIe cards.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
12 years agoamplc_dio200: Use custom register access functions
Ian Abbott [Mon, 28 May 2012 09:40:41 +0000 (10:40 +0100)]
amplc_dio200: Use custom register access functions

Add custom functions to access hardware registers instead of calling
inb() and outb() directly.  When we add more card types, these functions
will be changed to use I/O methods appropriate to the card type.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
12 years agoamplc_dio200: Add inline functions to access 8254 counter
Ian Abbott [Mon, 28 May 2012 09:40:41 +0000 (10:40 +0100)]
amplc_dio200: Add inline functions to access 8254 counter

Use our own inline functions to access the 8254 counter registers
instead of the ones in 8253.h.  This will make the code less messy when
we support newer cards.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
12 years agoamplc_dio200: Internalize 8255 DIO subdevice implementation
Ian Abbott [Mon, 28 May 2012 09:40:41 +0000 (10:40 +0100)]
amplc_dio200: Internalize 8255 DIO subdevice implementation

Implement the 8255 DIO subdevice internally to this module instead of
using the external '8255' kernel module.  This will allow the subdevice
to be enhanced with extra features at a later date (for new cards).

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
12 years agoamplc_dio200: Use offsets from base address in subdevice
Ian Abbott [Mon, 28 May 2012 09:40:41 +0000 (10:40 +0100)]
amplc_dio200: Use offsets from base address in subdevice

Replace modified I/O base addresses in the subdevice private structures
for '8254' counter subdevices and the 'INTERRUPT' subdevice with offsets
from the main I/O base address.

This will be useful when I add new supported cards later.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
12 years agoamplc_dio200: Eliminate 'has_int_sce' from 'dio200_subdev_intr'.
Ian Abbott [Mon, 28 May 2012 09:40:40 +0000 (10:40 +0100)]
amplc_dio200: Eliminate 'has_int_sce' from 'dio200_subdev_intr'.

Remove 'has_int_sce' flag from 'struct dio200_subdev_intr'.  Just use
the corresponding flag from the card layout structure instead.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
12 years agoamplc_dio200: Eliminate 'has_clk_gat_sce' from 'dio200_subdev_8254'.
Ian Abbott [Mon, 28 May 2012 09:40:40 +0000 (10:40 +0100)]
amplc_dio200: Eliminate 'has_clk_gat_sce' from 'dio200_subdev_8254'.

Remove 'has_clk_gat_sce' flag from 'struct dio200_subdev_8254'.  Just
use the corresponding flag from the card layout structure instead.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
12 years agoamplc_dio200: Pass device and subdevice to clock/gate config functions
Ian Abbott [Mon, 28 May 2012 09:40:40 +0000 (10:40 +0100)]
amplc_dio200: Pass device and subdevice to clock/gate config functions

Rename the clock and gate configuration functions for the 8254
subdevices and pass in the comedi device and subdevice pointers.

This doesn't achieve anything by itself; it's just preparing for later
changes.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
12 years agousbduxfast: Changed model name on Devices line for consistency.
Ian Abbott [Mon, 14 May 2012 13:06:47 +0000 (14:06 +0100)]
usbduxfast: Changed model name on Devices line for consistency.

Changed model name on Devices line from USB-DUX to USB-DUX-FAST for
consistency with the Description line and to avoid confusion.

12 years agoA colon in the description confused one of the scripts down the line in comedilib.
Bernd Porr [Sun, 13 May 2012 14:04:52 +0000 (15:04 +0100)]
A colon in the description confused one of the scripts down the line in comedilib.

12 years agoChanged the headers of usbdux, usbduxfast and usbduxsigma
Bernd Porr [Sun, 13 May 2012 10:06:37 +0000 (11:06 +0100)]
Changed the headers of usbdux, usbduxfast and usbduxsigma
so that there are proper comments and actually useful information.
Thanks Ian for pointing this out.

12 years agousbdux, usbduxfast, usbduxsigma: Drop the '.o' in module name
Ian Abbott [Fri, 11 May 2012 10:50:31 +0000 (11:50 +0100)]
usbdux, usbduxfast, usbduxsigma: Drop the '.o' in module name

In the description comment, drop the '.o' in the module name as we don't
do that any more.  (We dropped it when Comedi supported both 2.4 and 2.6
kernels that used different file extensions for modules.)

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
12 years agoHardware_Driver.HOWTO: Change submission instructions.
Ian Abbott [Thu, 26 Apr 2012 08:59:51 +0000 (09:59 +0100)]
Hardware_Driver.HOWTO: Change submission instructions.

The "Adding new drivers" section said new drivers should be sent to
David Schleef for review and integration.  I changed it to say they
should be sent to the mailing list.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
12 years agousbduxsigma: Change 'status:' to 'Status:' in driver comment block.
Ian Abbott [Mon, 23 Apr 2012 17:05:34 +0000 (18:05 +0100)]
usbduxsigma: Change 'status:' to 'Status:' in driver comment block.

12 years agocomedi.h: COMEDI_CB_EOA is also used to report end-of-output.
W. Trevor King [Mon, 16 Apr 2012 13:21:40 +0000 (09:21 -0400)]
comedi.h: COMEDI_CB_EOA is also used to report end-of-output.

Signed-off-by: W. Trevor King <wking@drexel.edu>
12 years agoReplace <asm/system.h> with <asm/barrier.h>
Ian Abbott [Mon, 2 Apr 2012 16:13:35 +0000 (17:13 +0100)]
Replace <asm/system.h> with <asm/barrier.h>

Added a compatibility header for <asm/barrier.h> which is being added in
kernel version 3.4, along with the removal of <asm/system.h>.

Changed C files that previously included <asm/system.h> to include
<asm/barrier.h> instead.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
12 years agopcl818: Fix write instruction for AO subdevice
Ian Abbott [Tue, 20 Mar 2012 14:40:57 +0000 (14:40 +0000)]
pcl818: Fix write instruction for AO subdevice

Max Korovkin reported that analog output was not working on Advantech
PCI818L and found the cause to be an operator precedence error in
pcl818_ao_insn_write().  The effect of the bug was that the function
wrote to absolute I/O port addresses 6 and 7 (part of the ISA DMA
controller) instead of the port addresses assigned to the board.

The same bug was reported by Kudlaty on 2010-11-25, but was not
investigated further at the time.

The same bug was already fixed by Roel Kluin in the "staging" version of
this driver in the 2.6.31 kernel back in May 2009 (commit
f764df88f86c8db669bd7bfac230b9d2689ae322 in Linus's linux-2.6 git
repository).

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
12 years agoUpdate symbolic links to sources during make.
Ian Abbott [Thu, 8 Mar 2012 15:11:02 +0000 (15:11 +0000)]
Update symbolic links to sources during make.

When building outside the source directory, recreate any symbolic links
to the sources if they are broken or pointing to the wrong files.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
12 years agoUse 'bool' type for 'bool' module parameters, if supported.
Ian Abbott [Mon, 20 Feb 2012 17:41:50 +0000 (17:41 +0000)]
Use 'bool' type for 'bool' module parameters, if supported.

In the compatibility header for linux/moduleparam.h, define a
type COMEDI_MODULE_PARAM_BOOL_T to be used for 'bool' module parameters.

For kernel versions before 2.6.31, make it an 'int'.

For kernel versions 2.6.31 onwards, make it a 'bool'.  Support for bool
module parameters of type 'int' or 'unsigned int' is going away in
kernel version 3.4.  In kernel version 3.3 it produces a warning.

The only bool module parameter we currently have is 'comedi_autoconfig'.

Moved the #include "comedi_fops.h" after the #include
<linux/moduleparam.h> to get it to compile.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
12 years agoTag user memory pointers with __user.
Ian Abbott [Thu, 19 Jan 2012 14:36:08 +0000 (14:36 +0000)]
Tag user memory pointers with __user.

Tag user memory pointers with __user.  Also replace some 'void *'
pointers in ioctl handler functions with more specific pointer types.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
12 years agolinux/compiler.h: Define __user and __iomem if missing.
Ian Abbott [Thu, 19 Jan 2012 13:11:15 +0000 (13:11 +0000)]
linux/compiler.h: Define __user and __iomem if missing.

In the linux/compiler.h compatibility header, define the __user and
__iomem macros with empty expansion if they are undefined.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
12 years agoamplc_dio200: Fix harmless typo in 8254 subdevice cleanup
Ian Abbott [Tue, 17 Jan 2012 11:03:23 +0000 (11:03 +0000)]
amplc_dio200: Fix harmless typo in 8254 subdevice cleanup

Correct type of 'subpriv' variable in dio200_subdev_8254_cleanup().

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
12 years agodt9812: Fix logical || vs bitwise |.
Ian Abbott [Tue, 17 Jan 2012 10:13:59 +0000 (10:13 +0000)]
dt9812: Fix logical || vs bitwise |.

Fix bug discovered by Dan Carpenter in the "staging" sources.

In dt9212_configure_gain(), some bitmask constants were OR'ed together
logically (giving the value 1) when they should have been OR'ed together
bitwise.  The effect of this bug is that the analog gain would be set
incorrectly on the AI subdevice for certain ranges.

As it happens, the driver is incomplete regarding range settings anyway,
so the bug fix currently has no effect.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
12 years agoRevert "Check integer overflow in do_cmd_ioctl() and do_cmdtest_ioctl()."
Ian Abbott [Fri, 13 Jan 2012 10:29:58 +0000 (10:29 +0000)]
Revert "Check integer overflow in do_cmd_ioctl() and do_cmdtest_ioctl()."

This reverts commit 824ffcaf3a1bd55a111ed67cf5b0cb3cd18b405f.

The check is unnecessary because user_cmd.chanlist_len has already been
checked against the maximum supported by the subdevice.

Thanks to Dan Carpenter for pointing this out.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
12 years agome4000: Correct previous change to INSN_CONFIG.
Ian Abbott [Mon, 9 Jan 2012 15:30:25 +0000 (15:30 +0000)]
me4000: Correct previous change to INSN_CONFIG.

I messed up the previous change to me4000.c on 2011-12-15 which meant
that INSN_CONFIG_DIO_INPUT behaved like INSN_CONFIG_DIO_OUTPUT and vice
versa!  Fix it.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
13 years agome_daq: don't access *data when insn->n == 0
Ian Abbott [Thu, 15 Dec 2011 21:10:21 +0000 (21:10 +0000)]
me_daq: don't access *data when insn->n == 0

Due to recent change to do_insnlist_ioctl() and do_insn_ioctl(), the
'data' pointer will be NULL when insn->n == 0.  Do not access *data
in this case.

Also for INSN_WRITE on the AO subdevice, write the nth data value in the
loop instead of the 0th data value.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
13 years agoadv_pci_dio: don't access *data when insn->n == 0
Ian Abbott [Thu, 15 Dec 2011 21:07:43 +0000 (21:07 +0000)]
adv_pci_dio: don't access *data when insn->n == 0

Due to recent change to do_insnlist_ioctl() and do_insn_ioctl(), the
'data' pointer will be NULL when insn->n == 0.  Do not access *data
in this case.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
13 years agoni_at_ao: don't access *data when insn->n == 0
Ian Abbott [Thu, 15 Dec 2011 21:04:50 +0000 (21:04 +0000)]
ni_at_ao: don't access *data when insn->n == 0

Due to recent change to do_insnlist_ioctl() and do_insn_ioctl(), the
'data' pointer will be NULL when insn->n == 0.  Do not access *data
in this case.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
13 years agousbdux: don't access *data when insn->n == 0
Ian Abbott [Thu, 15 Dec 2011 21:01:48 +0000 (21:01 +0000)]
usbdux: don't access *data when insn->n == 0

Due to recent change to do_insnlist_ioctl() and do_insn_ioctl(), the
'data' pointer will be NULL when insn->n == 0.  Do not access *data
in this case.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
13 years agodas1800: don't access *data when insn->bits == 0
Ian Abbott [Thu, 15 Dec 2011 20:57:29 +0000 (20:57 +0000)]
das1800: don't access *data when insn->bits == 0

Due to recent change to do_insnlist_ioctl() and do_insn_ioctl(), the
'data' pointer will be NULL when insn->n == 0.  Do not access *data
in this case.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
13 years agoamplc_dio200: don't access *data when insn->n == 0
Ian Abbott [Thu, 15 Dec 2011 20:56:11 +0000 (20:56 +0000)]
amplc_dio200: don't access *data when insn->n == 0

Due to recent change to do_insnlist_ioctl() and do_insn_ioctl(), the
'data' pointer will be NULL when insn->n == 0.  Do not access *data
in this case.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
13 years agocb_pcidas64: don't access *data when insn->n == 0
Ian Abbott [Thu, 15 Dec 2011 20:51:45 +0000 (20:51 +0000)]
cb_pcidas64: don't access *data when insn->n == 0

Due to recent change to do_insnlist_ioctl() and do_insn_ioctl(), the
'data' pointer will be NULL when insn->n == 0.  Do not access *data
in this case.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
13 years agoquatech_daqp_cs: don't access *data when insn->n == 0
Ian Abbott [Thu, 15 Dec 2011 20:47:07 +0000 (20:47 +0000)]
quatech_daqp_cs: don't access *data when insn->n == 0

Due to recent change to do_insnlist_ioctl() and do_insn_ioctl(), the
'data' pointer will be NULL when insn->n == 0.  Do not access *data
in this case.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
13 years agoadl_pci8164: don't access *data when insn->n == 0
Ian Abbott [Thu, 15 Dec 2011 20:42:01 +0000 (20:42 +0000)]
adl_pci8164: don't access *data when insn->n == 0

Due to recent change to do_insnlist_ioctl() and do_insn_ioctl(), the
'data' pointer will be NULL when insn->n == 0.  Do not access *data
in this case.

Also fixed instructions that printed the value of data[1] and returned 2
even though they only used data[0].

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
13 years agoni_mio_common: don't access *data when insn->n == 0
Ian Abbott [Thu, 15 Dec 2011 20:32:32 +0000 (20:32 +0000)]
ni_mio_common: don't access *data when insn->n == 0

Due to recent change to do_insnlist_ioctl() and do_insn_ioctl(), the
'data' pointer will be NULL when insn->n == 0.  Do not access *data
in this case.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
13 years agoaddi_common: don't access *data when insn->n == 0
Ian Abbott [Thu, 15 Dec 2011 20:24:17 +0000 (20:24 +0000)]
addi_common: don't access *data when insn->n == 0

Due to recent change to do_insnlist_ioctl() and do_insn_ioctl(), the
'data' pointer will be NULL when insn->n == 0.  Do not access *data
in this case.

The INSN_READ handler for the EEPROM was ignoring insn->n.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
13 years agome4000: check for unsupported INSN_CONFIG
Ian Abbott [Thu, 15 Dec 2011 20:21:09 +0000 (20:21 +0000)]
me4000: check for unsupported INSN_CONFIG

The INSN_CONFIG handler for the DIO subdevice should error out for
unsupported configuration instruction codes.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
13 years agodt2801: do INSN_CONFIG properly for DIO subdevice
Ian Abbott [Thu, 15 Dec 2011 20:08:16 +0000 (20:08 +0000)]
dt2801: do INSN_CONFIG properly for DIO subdevice

Handle INSN_CONFIG_DIO_INPUT, INSN_CONFIG_DIO_OUTPUT and
INSN_CONFIG_DIO_QUERY in data[0].

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
13 years agodt2801: don't access *data when insn->n == 0
Ian Abbott [Thu, 15 Dec 2011 20:01:53 +0000 (20:01 +0000)]
dt2801: don't access *data when insn->n == 0

Due to recent change to do_insnlist_ioctl() and do_insn_ioctl(), the
'data' pointer will be NULL when insn->n == 0.  Do not access *data
in this case.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
13 years agoni_labpc: don't access *data when insn->n == 0
Ian Abbott [Thu, 15 Dec 2011 19:55:53 +0000 (19:55 +0000)]
ni_labpc: don't access *data when insn->n == 0

Due to recent change to do_insnlist_ioctl() and do_insn_ioctl(), the
'data' pointer will be NULL when insn->n == 0.  Do not access *data
in this case.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
13 years agodt282x: don't access *data when insn->n == 0
Ian Abbott [Thu, 15 Dec 2011 19:52:32 +0000 (19:52 +0000)]
dt282x: don't access *data when insn->n == 0

Due to recent change to do_insnlist_ioctl() and do_insn_ioctl(), the
'data' pointer will be NULL when insn->n == 0.  Do not access *data
in this case.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
13 years agocb_pcidda: don't access *data when insn->n == 0
Ian Abbott [Thu, 15 Dec 2011 19:44:40 +0000 (19:44 +0000)]
cb_pcidda: don't access *data when insn->n == 0

Due to recent change to do_insnlist_ioctl() and do_insn_ioctl(), the
'data' pointer will be NULL when insn->n == 0.  Do not access *data
in this case.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
13 years agodas08: don't access *data when insn->n == 0
Ian Abbott [Thu, 15 Dec 2011 19:38:52 +0000 (19:38 +0000)]
das08: don't access *data when insn->n == 0

Due to recent change to do_insnlist_ioctl() and do_insn_ioctl(), the
'data' pointer will be NULL when insn->n == 0.  Do not access *data
in this case.

Also handle INSN_WRITE properly for AO subdevices.  Should use the nth
data value in the loop, not the 0th.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
13 years agoke_counter: don't access *data when insn->n == 0
Ian Abbott [Thu, 15 Dec 2011 19:32:31 +0000 (19:32 +0000)]
ke_counter: don't access *data when insn->n == 0

Due to recent change to do_insnlist_ioctl() and do_insn_ioctl(), the
'data' pointer will be NULL when insn->n == 0.  Do not access *data
in this case.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
13 years agocb_pcidas: don't access *data when insn-en == 0
Ian Abbott [Thu, 15 Dec 2011 19:29:52 +0000 (19:29 +0000)]
cb_pcidas: don't access *data when insn-en == 0

Due to recent change to do_insnlist_ioctl() and do_insn_ioctl(), the
'data' pointer will be NULL when insn->n == 0.  Do not access *data
in this case.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
13 years agoadv_pci1710: don't access *data when insn->n == 0
Ian Abbott [Thu, 15 Dec 2011 19:16:04 +0000 (19:16 +0000)]
adv_pci1710: don't access *data when insn->n == 0

Due to recent change to do_insnlist_ioctl() and do_insn_ioctl(), the
'data' pointer will be NULL when insn->n == 0.  Do not access *data
in this case.

Also, the INSN_WRITE handlers for AO subdevices were incorrectly storing
the data value past the end of the data array for read-back, instead of
the last data value (when insn->n > 0).

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
13 years agos526: don't access *data when insn->n == 0
Ian Abbott [Thu, 15 Dec 2011 19:06:37 +0000 (19:06 +0000)]
s526: don't access *data when insn->n == 0

Due to recent change to do_insnlist_ioctl() and do_insn_ioctl(), the
'data' pointer will be NULL when insn->n == 0.  Do not access *data
in this case.

Also the INSN_WRITE code for pulse-train generation should only access
data[1] if insn->n >= 2.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
13 years agoii_pci20kc: don't access *data when insn->n == 0
Ian Abbott [Thu, 15 Dec 2011 18:46:31 +0000 (18:46 +0000)]
ii_pci20kc: don't access *data when insn->n == 0

Due to recent change to do_insnlist_ioctl() and do_insn_ioctl(), the
'data' pointer will be NULL when insn->n == 0.  Do not access *data
in this case.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
13 years agopoc: don't access *data when insn->n == 0
Ian Abbott [Thu, 15 Dec 2011 18:37:34 +0000 (18:37 +0000)]
poc: don't access *data when insn->n == 0

Due to recent change to do_insnlist_ioctl() and do_insn_ioctl(), the
'data' pointer will be NULL when insn->n == 0.  Do not access *data
in this case.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
13 years agounioxx5: don't access *data when insn->n == 0
Ian Abbott [Thu, 15 Dec 2011 18:31:00 +0000 (18:31 +0000)]
unioxx5: don't access *data when insn->n == 0

Due to recent change to do_insnlist_ioctl() and do_insn_ioctl(), the
'data' pointer will be NULL when insn->n == 0.  Do not access *data in
this case.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
13 years agocomedi/drivers.c: handle insn->n == 0 in insn_rw_emulate_bits
Ian Abbott [Thu, 15 Dec 2011 18:01:39 +0000 (18:01 +0000)]
comedi/drivers.c: handle insn->n == 0 in insn_rw_emulate_bits

A recent change to do_insnlist_ioctl() and do_insn_ioctl() to handle
arbitrary limits on means that the 'data' pointer will now be NULL when
insn->n == 0.  Need to check insn->n is non-zero before accessing *data.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
13 years agousbdux: unlock on error in usbdux_ao_inttrig()
Ian Abbott [Wed, 30 Nov 2011 14:59:33 +0000 (14:59 +0000)]
usbdux: unlock on error in usbdux_ao_inttrig()

Follow patch by Dan Carpenter to the "staging" sources.

When trignum is invalid it returned without unlocking the mutex.
Fix it.

13 years agousbduxsigma: unlock on error in usbdux_ao_inttrig()
Ian Abbott [Wed, 30 Nov 2011 14:55:06 +0000 (14:55 +0000)]
usbduxsigma: unlock on error in usbdux_ao_inttrig()

Follow patch by Dan Carpenter to the "staging" sources.

When trignum is invalid it returned without unlocking the mutex.
Fix it.

13 years agoRemove arbitrary limit in do_insnlist_ioctl() and do_insn_ioctl().
Ian Abbott [Wed, 23 Nov 2011 15:50:45 +0000 (15:50 +0000)]
Remove arbitrary limit in do_insnlist_ioctl() and do_insn_ioctl().

Remove the arbitrary limit on number of samples per instruction.  It
will still be limited by the maximum size of a kmalloc() buffer.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
13 years agoCheck integer overflow in do_cmd_ioctl() and do_cmdtest_ioctl().
Ian Abbott [Wed, 23 Nov 2011 15:28:57 +0000 (15:28 +0000)]
Check integer overflow in do_cmd_ioctl() and do_cmdtest_ioctl().

Check for integer overflow when allocating buffer for channel list.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
13 years agoCheck integer overflow in do_insnlist_ioctl().
Ian Abbott [Wed, 23 Nov 2011 15:16:53 +0000 (15:16 +0000)]
Check integer overflow in do_insnlist_ioctl().

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
13 years agoRevert "Check integer overflow in do_insnlist_ioctl()"
Ian Abbott [Wed, 23 Nov 2011 14:43:03 +0000 (14:43 +0000)]
Revert "Check integer overflow in do_insnlist_ioctl()"

Xi Wang pointed out a flaw in the current check.

13 years agoni_pcimio: Added support for NI PXIe-6251
Ian Abbott [Tue, 15 Nov 2011 15:16:09 +0000 (15:16 +0000)]
ni_pcimio: Added support for NI PXIe-6251

Paul Fulmek reports that PXIe-6251 works the same as the existing
PCIe-6251 and just needs the new PCI device ID adding to ni_pci_table[]
and a new entry adding to ni_boards[] based on the existing entry for
PCIe-6251.

The new entry has PCI device ID 0x72e8 and board name "pxie-6251".

Thanks Paul!

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
13 years agoChecks for NULL pointers to prevent kernel oops when a USB DAQ
Bernd Porr [Tue, 8 Nov 2011 22:49:30 +0000 (22:49 +0000)]
Checks for NULL pointers to prevent kernel oops when a USB DAQ
device is plugged out while communicating to a userspace program.

13 years agoCorrected wrong analogue input range. It's not +/-2.65V but +/-2.65V/2.
Bernd Porr [Tue, 8 Nov 2011 22:47:23 +0000 (22:47 +0000)]
Corrected wrong analogue input range. It's not +/-2.65V but +/-2.65V/2.

13 years agoCheck integer overflow in do_insnlist_ioctl()
Ian Abbott [Mon, 7 Nov 2011 10:20:23 +0000 (10:20 +0000)]
Check integer overflow in do_insnlist_ioctl()

Follow patch to "staging" comedi kernel sources by Dan Carpenter.

There is an integer overflow here that could cause memory corruption
on 32 bit systems.

insnlist.n_insns could be a very high value size calculation for
kmalloc() could overflow resulting in a smaller "insns" than
expected.  In the for (i = 0; i < insnlist.n_insns; i++) {... loop
we would read past the end of the buffer, possibly corrupting memory
as well.

13 years agoFix signal handling in read and write
Ian Abbott [Tue, 1 Nov 2011 09:49:29 +0000 (09:49 +0000)]
Fix signal handling in read and write

Follow bug-fix by Federico Vaga on the Linux "staging" version:

After sleeping on a wait queue, signal_pending(current) should be
checked (not before sleeping).

13 years agoFix mmap_count.
Ian Abbott [Tue, 1 Nov 2011 09:43:56 +0000 (09:43 +0000)]
Fix mmap_count.

Follow bug-fix by Federico Vaga in Linux "staging" version:

In comedi_fops, mmap_count is decremented at comedi_vm_ops->close but it
is not incremented at comedi_vm_ops->open. This may result in a negative
counter.  The patch introduces the open method to keep the counter
consistent.

The bug was triggerd by this sample code:

        mmap(0, ...., comedi_fd);
        fork();
        exit(0);

13 years agousbduxsigma: Remove conditional code that calls sema_init
Ian Abbott [Mon, 26 Sep 2011 09:29:35 +0000 (10:29 +0100)]
usbduxsigma: Remove conditional code that calls sema_init

Bernd says the removed code was needed for Ubuntu 10.04 LTS kernel, but
it's better to remove it and solve any problems for that kernel another
way.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
13 years agoAdded support for the new board by ITL called USBDUXsigma.
Bernd Porr [Sat, 3 Sep 2011 12:48:31 +0000 (13:48 +0100)]
Added support for the new board by ITL called USBDUXsigma.

13 years agoRename some function parameters from 'register' to 'reg'.
Ian Abbott [Wed, 14 Sep 2011 08:53:31 +0000 (09:53 +0100)]
Rename some function parameters from 'register' to 'reg'.

[Porting over relevant part of patch by Chris Peterson for Linux kernel
sources.]

Some function prototypes declare an 'int register' parameter. gcc -W
warns "‘register’ is not at beginning of declaration" because the
compiler thinks the parameter has been marked as a 'register' variable
but the author just wanted to name the parameter "register" (which is a
reserved keyword).

13 years agoAdded support for trailing edge external trigger to ni_pcidio
Nico Nell [Mon, 12 Sep 2011 20:47:07 +0000 (14:47 -0600)]
Added support for trailing edge external trigger to ni_pcidio

13 years agoAUTHORS: Add Nicholas Nell for various patches
Ian Abbott [Thu, 8 Sep 2011 11:11:44 +0000 (12:11 +0100)]
AUTHORS: Add Nicholas Nell for various patches

13 years agoAdded comedi_poll support to ni_pcidio
Nico Nell [Thu, 18 Aug 2011 17:14:30 +0000 (11:14 -0600)]
Added comedi_poll support to ni_pcidio

13 years agoFix warnings about including deprecated <linux/config.h>
Ian Abbott [Mon, 5 Sep 2011 12:29:20 +0000 (13:29 +0100)]
Fix warnings about including deprecated <linux/config.h>

Change Comedi's <linux/config.h> compatibility header so it only
includes the real <linux/config.h> for kernel versions below 2.6.15.
Previously it was included for kernel versions below 2.6.19 (when it was
removed from the kernel sources) but wasn't needed for 2.6.15 onwards.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
13 years agoDeal with backported bool type for RHEL5's 2.6.18 kernel
Ian Abbott [Mon, 5 Sep 2011 12:17:20 +0000 (13:17 +0100)]
Deal with backported bool type for RHEL5's 2.6.18 kernel

RHEL5's 2.6.18 kernel includes a change backported from 2.6.19 that
declares a generic 'bool' type in <linux/types.h> and declares the
'false' and 'true' enum values in <linux/stddef.h>.  Comedi's
compatibility header for <linux/stddef.h> declared the 'false' and
'true' enum values for any kernel version below 2.6.19.  This resulted
in comedi failing to build due to redeclaration errors.

Add an autoconf test to see if the generic 'bool' type is defined in
<linux/types.h> and if so define the macro
CONFIG_COMEDI_HAVE_GENERIC_BOOL_TYPE in <config.h>.  Conditionally
declare the 'bool' type in the <linux/types.h> compatibility header and
change the condition for declaring the 'false' and 'true' enum values in
the <linux/stddef.h> compatibility header so they are only declared if
the CONFIG_COMEDI_HAVE_GENERIC_BOOL_TYPE macro is undefined.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
13 years agoni_pcidio: Forgot to include irq flags variable for spinlock.
Ian Abbott [Mon, 18 Jul 2011 11:16:18 +0000 (12:16 +0100)]
ni_pcidio: Forgot to include irq flags variable for spinlock.

I messed up the previous commit.  Need to include a variable in
setup_mite_dma() to hold the IRQ flags when grabbing the spinlock.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
13 years agoni_pcidio: Grab MITE channel spinlock while preparing and arming DMA.
Ian Abbott [Mon, 18 Jul 2011 11:08:38 +0000 (12:08 +0100)]
ni_pcidio: Grab MITE channel spinlock while preparing and arming DMA.

When setting up the DMA for 'read' streaming acquisition command, grab
the MITE channel spinlock before preparing and arming the DMA.

Change inspired by ni_ai_setup_MITE_dma() in ni_mio_common.c.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
13 years agoni_pcidio: Mark buffer for writing when setting up DMA.
Ian Abbott [Mon, 18 Jul 2011 10:30:08 +0000 (11:30 +0100)]
ni_pcidio: Mark buffer for writing when setting up DMA.

When setting up the DMA for 'read' streaming acquisition on the DIO
subdevice, mark the whole buffer as writable before starting the DMA.
This prevents a spurious detection of a DMA overwrite of good data
during the first interrupt.

Problem reported by Nico Nell.  Fix suggested by Frank Mori Hess.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
13 years agoFix infoleak to userspace.
Ian Abbott [Mon, 27 Jun 2011 10:05:39 +0000 (11:05 +0100)]
Fix infoleak to userspace.

Following Vasiliy Kulikov <segoon _at_ openwall _dot_ org>'s patch for
the staging sources:

driver_name and board_name are pointers to strings, not buffers of size
COMEDI_NAMELEN.  Copying COMEDI_NAMELEN bytes of a string containing
less than COMEDI_NAMELEN-1 bytes would leak some unrelated bytes.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
13 years agoAdvantech PCI-1739U support
Nico Nell [Wed, 15 Jun 2011 19:46:19 +0000 (20:46 +0100)]
Advantech PCI-1739U support

Hello,

I've added a bit of simple configuration to adv_pci_dio.c in order to
make the PCI-1739U work with the adv_pci_dio driver. I have tested
inputs only so far but they seem to work. A git style patch is
attached.

Thanks,

--
Nicholas Nell
Professional Research Assistant
University of Colorado
nicholas.nell@colorado.edu
303-492-5661

From c2a97fef832aa70b7fb2eff60de6412829b314ba Mon Sep 17 00:00:00 2001
From: Gene Ray <user@SLICE-testing.Colorado.EDU>
Date: Thu, 2 Jun 2011 12:58:37 -0600
Subject: [PATCH] Added functionality for the Advantech PCI-1739U DIO board

13 years agoconfigure: Recognize kernel 3.x
Ian Abbott [Thu, 2 Jun 2011 13:47:01 +0000 (14:47 +0100)]
configure: Recognize kernel 3.x

Support Linus's alpha-maleness kernel version numbering change.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
13 years agoaddi-data: Get rid of redundant ps_BoardInfo
Ian Abbott [Mon, 16 May 2011 15:06:32 +0000 (16:06 +0100)]
addi-data: Get rid of redundant ps_BoardInfo

The ps_BoardInfo pointer in the device private data is redundant as we
can just use the this_board macro to access the same data, as is done
elsewhere in the code.  Get rid of the pointer and change the code to
use the this_board macro instead.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
13 years agoaddi_data: Don't overwrite read-only data
Ian Abbott [Mon, 16 May 2011 14:57:24 +0000 (15:57 +0100)]
addi_data: Don't overwrite read-only data

The drivers for ADDI-DATA cards can override some static parameters for
the board type using information read from EEPROM.  Unfortunately, they
currently write the parameters from the EEPROM back to the shared,
read-only board data!  The problem has been masked during compilation by
type-casting away the const-ness of the data.

This patch changes the code to use an area in the private data for the
board instance to hold the parameters read from EEPROM (after
initializing the parameters from the static board data).  It also
changes the type-casts to the read-only data to preserve the const
qualifier.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
13 years agoAUTHORS: Added Ivan Russkih (Иван Русских).
Ian Abbott [Mon, 16 May 2011 09:53:21 +0000 (10:53 +0100)]
AUTHORS: Added Ivan Russkih (Иван Русских).

Added for patch to adv_pci_dio to support counter subdevice on PCI-1751.

13 years agoadv_pci_dio: Add 8254 counter subdevice to PCI-1751
Ian Abbott [Mon, 16 May 2011 09:31:42 +0000 (10:31 +0100)]
adv_pci_dio: Add 8254 counter subdevice to PCI-1751

The Advantech PCI-1751 has a 8254 counter chip providing 3 counter
channels.  Add a counter subdevice for this card.

Patch from Иван Русских (vanekrus at gmail dot com).

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
13 years agocomedi: Removal of <linux/smp_lock.h>
Ian Abbott [Fri, 13 May 2011 13:55:19 +0000 (14:55 +0100)]
comedi: Removal of <linux/smp_lock.h>

The <linux/smp_lock.h> header (used for the Big Kernel Lock) is removed
in kernel 2.6.39.  It was included by:

  comedi/comedi_compat32.c
  comedi/drivers/usbdux.c
  comedi/drivers/usbduxfast.c

The usbdux and usbduxfast drivers shouldn't need to include the header
as they don't grab the BKL, so remove the #include line for these
drivers.

The comedi_compat32 code only uses it when calling the ioctl file
operation, and that can only happen for kernels up to 2.6.35 (and even
then it wouldn't be called if the unlocked_ioctl file operation is
available!). Ifdef out the #include line.  Also include
<linux/version.h> explicitly to avoid compiler errors for 2.6.39 kernel.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
13 years agoconfigure.ac: Change reference to CVS to Git.
Ian Abbott [Tue, 10 May 2011 13:26:31 +0000 (14:26 +0100)]
configure.ac: Change reference to CVS to Git.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
13 years agoINSTALL: Changed reference to cvs to git.
Ian Abbott [Tue, 10 May 2011 13:18:16 +0000 (14:18 +0100)]
INSTALL: Changed reference to cvs to git.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
13 years ago.gitignore: Ignore the file 'missing'.
Ian Abbott [Tue, 10 May 2011 13:14:14 +0000 (14:14 +0100)]
.gitignore: Ignore the file 'missing'.

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