comedi.git
12 years agoamplc_dio200: fix typo in driver comment
Ian Abbott [Wed, 3 Oct 2012 16:54:42 +0000 (17:54 +0100)]
amplc_dio200: fix typo in driver comment

The table showing the interrupt sources for each card shows the wrong
source for interrupt source 3 of the PCIe296.  It should be PPI-Y1-C3,
not PPI-Y2-C3.  Correct it.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
12 years agoFix memory leak for saved channel list
Ian Abbott [Fri, 28 Sep 2012 12:06:54 +0000 (13:06 +0100)]
Fix memory leak for saved channel list

When `do_cmd_ioctl()` allocates memory for the kernel copy of a channel
list, it frees any previously allocated channel list in
`async->cmd.chanlist` and replaces it with the new one.  However, if the
device is ever removed (or "detached") the cleanup code in
`cleanup_device()` in "drivers.c" does not free this memory so it is
lost.

A sensible place to free the kernel copy of the channel list is in
`do_become_nonbusy()` as at that point the comedi asynchronous command
associated with the channel list is no longer valid.  Free the channel
list in `do_become_nonbusy()` instead of `do_cmd_ioctl()` and clear the
pointer to prevent it being freed more than once.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
12 years agos526: don't dereference insn->data
Ian Abbott [Fri, 28 Sep 2012 11:12:47 +0000 (12:12 +0100)]
s526: don't dereference insn->data

`s526_gpct_insn_config()` and `s526_gpct_winsn()` are incorrectly
dereferencing `insn->data` which is a pointer to user memory.  They
should be using the separate `data` pointer that points to a copy of the
data in kernel memory.  Fix them.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
12 years agos626: don't dereference insn->data
Ian Abbott [Fri, 28 Sep 2012 11:05:05 +0000 (12:05 +0100)]
s626: don't dereference insn->data

`s626_enc_insn_config()` is incorrectly dereferencing `insn->data` which
is a pointer to user memory.  It should be using the separate `data`
parameter that points to a copy of the data in kernel memory.

Note that this insn_config handler is being used incorrectly by this
driver anyway.  `data[0]` should be used to select the type of
configuration being performed, but this driver is treating it as a
counter preload value.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
12 years agojr3_pci: fix iomem dereference
Ian Abbott [Fri, 28 Sep 2012 10:59:53 +0000 (11:59 +0100)]
jr3_pci: fix iomem dereference

Correct a direct dereference of I/O memory when writing the 'reset'
register in jr3_pci_attach().  Use writel() to write the register.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
12 years agocomedi_fops: fix user-memory dereference for INSN_INTTRIG
Ian Abbott [Tue, 18 Sep 2012 19:00:08 +0000 (20:00 +0100)]
comedi_fops: fix user-memory dereference for INSN_INTTRIG

The parse_insn() function shouldn't dereference `insn->data` as that is
pointing to user-space memory.  It should deference the separate `data`
parameter instead, which points to a kernel copy of the data.  Only the
`INSN_INTTRIG` case needs fixing.  Fix it.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
12 years agodas08: Correct AO output for das08jr-16-ao
Ian Abbott [Fri, 31 Aug 2012 16:44:16 +0000 (17:44 +0100)]
das08: Correct AO output for das08jr-16-ao

Don't zero out bits 15..12 of the data value in das08jr_ao_winsn() as
that knobbles the upper three quarters of the output range for the
"das08jr-16-ao" board.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
12 years agodas08: Fix wrong AI encoding for das08jr-16-ao.
Ian Abbott [Fri, 31 Aug 2012 13:28:39 +0000 (14:28 +0100)]
das08: Fix wrong AI encoding for das08jr-16-ao.

For das08jr-16-ao, the ai_encoding member of the board structure should
be set to das08_encoding16, not das08_encoding12.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
12 years agoserial2002: Set range for digital inputs and outputs...
Anders Blomdell [Fri, 24 Aug 2012 15:07:14 +0000 (16:07 +0100)]
serial2002: Set range for digital inputs and outputs...

12 years agos626: DIO subdevice 2 should have 16 channels.
Ian Abbott [Tue, 3 Jul 2012 10:27:51 +0000 (11:27 +0100)]
s626: DIO subdevice 2 should have 16 channels.

Subdevice 2 (which is a DIO subdevice) has the wrong number of channels,
48 defined by the S626_DIO_CHANNELS macro.  That is the total number of
DIO channels to be split over 3 subdevices (subdevices 2, 3, 4 with 16
channels each).  Fix the number of channels for subdevice 2.

Spotted by H Hartley Sweeten in the "staging" sources.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
12 years agoni_670x: Fix possible invalid pointer dereference in ni_670x_detach()
Ian Abbott [Mon, 2 Jul 2012 09:03:40 +0000 (10:03 +0100)]
ni_670x: Fix possible invalid pointer dereference in ni_670x_detach()

In ni_670x_detach(), dev->subdevices will be NULL if the call to
alloc_subdevices() failed in ni_670x_attach(), so don't dereference it
until the pointer has been checked.

Spotted by H Hartley Sweeten in the "staging" sources, but used a
different check due to difference in behavior of alloc_subdevices() on
error between the two versions.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
12 years agodkms.conf: Fixed bug in last commit ${kernel_src_dir}
Ian Abbott [Tue, 26 Jun 2012 18:58:00 +0000 (19:58 +0100)]
dkms.conf: Fixed bug in last commit ${kernel_src_dir}

${kernel_src_dir} should be ${kernel_source_dir}.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
12 years agodkms.conf: Try harder when looking for ds.h
Ian Abbott [Tue, 26 Jun 2012 17:46:33 +0000 (18:46 +0100)]
dkms.conf: Try harder when looking for ds.h

Some distros don't create /lib/modules/${kernelver}/source directory or
symlink, so the use of the
/lib/modules/${kernelver}/source/include/pcmcia/ds.h fails.  In this
case, use ${kernel_source_dir}/include/pcmcia/ds.h and hope for the
best.

This is useful for some versions of Ubuntu at least.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
12 years agodkms.conf: ${kernel_version} should be ${kernelver}
Ian Abbott [Tue, 26 Jun 2012 17:15:17 +0000 (18:15 +0100)]
dkms.conf: ${kernel_version} should be ${kernelver}

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
12 years agoAdd usbduxsigma to dkms.conf
Ian Abbott [Tue, 26 Jun 2012 16:57:48 +0000 (17:57 +0100)]
Add usbduxsigma to dkms.conf

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
12 years agoamplc_pci230: Fix dangling spin-lock
Ian Abbott [Fri, 8 Jun 2012 09:26:06 +0000 (10:26 +0100)]
amplc_pci230: Fix dangling spin-lock

pci230_ao_inttrig_scan_begin() could return without releasing a
spin-lock.  Fix it.

Spotted by Dan Carpenter in the "staging" sources.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
12 years agoni_mio_common: ni_release_gpct_mite_channel only used for PCI.
Ian Abbott [Wed, 6 Jun 2012 10:02:27 +0000 (11:02 +0100)]
ni_mio_common: ni_release_gpct_mite_channel only used for PCI.

The ni_release_gpct_mite_channel() function is static, but only called
from code within '#ifdef PCIDMA'.  Wrap the whole function within a
'#ifdef PCIDMA'/'#endif' pair to avoid compiler warning about unused
function for the ni_atmio driver.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
12 years agoni_mio_common: Made a couple of functions static.
Ian Abbott [Wed, 6 Jun 2012 09:53:30 +0000 (10:53 +0100)]
ni_mio_common: Made a couple of functions static.

Made ni_release_gpct_mite_channel() and ni_prime_channelgain_list()
static.

Spotted by H Hartley Sweeten in the "staging" sources.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
12 years agoni_labpc: Release spin-lock in labpc_ai_cmd returns an error.
Ian Abbott [Wed, 6 Jun 2012 09:48:09 +0000 (10:48 +0100)]
ni_labpc: Release spin-lock in labpc_ai_cmd returns an error.

There are a couple of places in labpc_ai_cmd() that return without
releasing the spin-lock.  These places should not be reachable, but
release the spin-lock anyway.

Spotted by H Hartley Sweeten in the "staging" sources.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
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).