Commit Graph

4764 Commits

Author SHA1 Message Date
Chase Southwood 69ba83585a Staging: comedi: fix extra whitespace style issues in ni_mio_common.c.
This patch for ni_mio_common.c removes extra whitespace causing
checkpatch.pl warnings.

Signed-off-by: Chase Southwood <chase.southwood@yahoo.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-13 15:04:52 -08:00
Chase Southwood b9ede3154a Staging: comedi: fix indentation coding style issue in ni_mio_common.c.
This patch for ni_mio_common.c fixes several indentation warnings from
checkpatch.pl.

Signed-off-by: Chase Southwood <chase.southwood@yahoo.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-13 15:04:52 -08:00
Chase Southwood bc4615561f Staging: comedi: fix numerous brace coding style issues in ni_mio_common.c.
This patch for ni_mio_common.c removes many unneccesary braces to fix
checkpatch.pl warnings.

Signed-off-by: Chase Southwood <chase.southwood@yahoo.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-13 15:04:52 -08:00
Rostislav Lisovy 04b565021a comedi: Humusoft MF634 and MF624 DAQ cards driver
This patch adds Comedi driver for Humusoft MF634 (PCIe) and
MF624 (PCI) data acquisition cards. The legacy card Humusoft
MF614 is not supported. More info about the cards may be found
at http://humusoft.cz/produkty/datacq/
The driver was tested with both cards. Everything seems to work
properly. Just the basic functionality of the card (DIO, ADC, DAC)
is supported by this driver.

Signed-off-by: Rostislav Lisovy <lisovy@gmail.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-13 15:03:12 -08:00
Michal Kwiatkowski 509e42e1d3 Staging: comedi: amcc_s5933: "no space before tabs" coding style fixes.
Fixed a coding style issues.

Signed-off-by: Michal Kwiatkowski <michaelflowersky@geekingspree.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-11 12:41:56 -08:00
Chase Southwood b281539839 Staging: comedi: fix spacing coding style issue in 8255.c.
This patch for 8255.c fixes a spacing warning found by checkpatch.pl.

Signed-off-by: Chase Southwood <chase.southwood@yahoo.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-11 12:41:56 -08:00
Bernd Porr 2783980525 staging: comedi: usbduxsigma: removing unneccesay attached info
Comedi core now reports that a device has been attached so that
the driver itself won't need to do it any longer. The driver now
just outputs the offset of the ADC converter which is a soft indicator
of the health of the board and also the user can grep this value
from the kernel log easier for debugging purposes.

Signed-off-by: Bernd Porr <mail@berndporr.me.uk>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-09 10:51:54 -08:00
Bernd Porr 7a45ae6edf staging: comedi: usbduxsigma: return failure of auto attach
The function usbduxsigma_getstatusinfo() returns a negative
value in case there has been a communication error with
the board. This should always work and if this communication
fails then there is something seriously wrong with the board.
This is now returned to the caller so that it can
terminte the auto attachement. The return command also prevents
printing out the offset value in case of a fault.

Signed-off-by: Bernd Porr <mail@berndporr.me.uk>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-09 10:51:54 -08:00
Bernd Porr bcb6232d09 staging: comedi: report success/failure of autoconfig
Added success message to the driver autoconfig and error
message in case it fails. A success message is required
so that the user can find out which comedi driver has been
associated with which udev device. This also makes troubleshooting
much easier when more than one card is in the computer or
there is a mix of USB and PCI devices.
As Ian suggested we should report both the driver and the board
which might have different names, especially if one driver covers a
range of different boards.

Signed-off-by: Bernd Porr <mail@berndporr.me.uk>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-09 10:51:54 -08:00
Ian Abbott 52ef9e7cb3 staging: comedi: fix bug destroying subdevice files after parent
`comedi_free_board_dev()` is called (via `comedi_auto_unconfig()` -->
`comedi_release_hardware_device()`) when an auto-configured comedi
device is removed.  This destroys the main sysfs class device and then
calls `comedi_device_cleanup()` to clean up the comedi device.  For
comedi devices that have comedi subdevices that asynchronous commands,
the clean up involves destroying the sysfs class devices associated with
those subdevices.

There is a bug in the above sequence because the sysfs class devices
associated with the comedi subdevices are children of the sysfs class
device associated with the main comedi device.  Therefore they will have
been automatically destroyed when the main sysfs class device is
destroyed.  When they are destroyed again as part of the clean-up, they
will not be found, leading to a warning and a stack trace similar to
this:

------------[ cut here ]------------
WARNING: CPU: 1 PID: 1213 at fs/sysfs/group.c:214
sysfs_remove_group+0x4e/0xa7()
sysfs group ffffffff817504c0 not found for kobject 'comedi4_subd0'
Modules linked in: nfsd auth_rpcgss oid_registry exportfs nfs_acl lockd
bridge stp llc sunrpc fuse binfmt_misc cpufreq_userspace sr_mod
snd_hda_codec_analog cdrom powernow_k8 kvm_amd kvm amplc_pci230(C)
8255(C) comedi(C) pcmcia xhci_hcd ehci_pci pcmcia_core ohci_pci ohci_hcd
ehci_hcd usbcore snd_hda_intel snd_hda_codec snd_pcm k8temp
snd_page_alloc 8139too snd_timer snd soundcore mii usb_common forcedeth
pata_amd
CPU: 1 PID: 1213 Comm: kworker/u4:6 Tainted: G         C
3.13.0-rc5-ija1+ #20
Hardware name: System manufacturer System Product Name/M2N-E, BIOS ASUS
M2N-E ACPI BIOS Revision 5001 03/23/2010
Workqueue: sysfsd sysfs_schedule_callback_work
 0000000000000000 ffff8800bf17fb38 ffffffff814672ce ffff8800bf17fb80
 ffff8800bf17fb70 ffffffff8103470b ffffffff8114f780 0000000000000000
 ffffffff817504c0 ffff8800bf39f410 ffff880139b68670 ffff8800bf17fbd0
Call Trace:
 [<ffffffff814672ce>] dump_stack+0x45/0x56
 [<ffffffff8103470b>] warn_slowpath_common+0x7a/0x93
 [<ffffffff8114f780>] ? sysfs_remove_group+0x4e/0xa7
 [<ffffffff8103476b>] warn_slowpath_fmt+0x47/0x49
 [<ffffffff8114e92d>] ? sysfs_get_dirent_ns+0x5e/0x66
 [<ffffffff8114f780>] sysfs_remove_group+0x4e/0xa7
 [<ffffffff8132aac0>] dpm_sysfs_remove+0x37/0x3b
 [<ffffffff81323781>] device_del+0x3e/0x173
 [<ffffffff813238c3>] device_unregister+0xd/0x18
 [<ffffffff8132392e>] device_destroy+0x33/0x37
 [<ffffffffa0212086>] comedi_free_subdevice_minor+0x80/0x92 [comedi]
 [<ffffffffa02128bb>] comedi_device_detach+0x79/0x152 [comedi]
 [<ffffffffa020f223>] comedi_device_cleanup+0x36/0x57 [comedi]
 [<ffffffffa020f275>] comedi_free_board_dev+0x31/0x3c [comedi]
 [<ffffffffa0211f2a>] comedi_release_hardware_device+0x5a/0x73 [comedi]
 [<ffffffffa0212547>] comedi_auto_unconfig+0xe/0x10 [comedi]
 [<ffffffffa021357c>] comedi_pci_auto_unconfig+0x10/0x12 [comedi]
 [<ffffffff811d2335>] pci_device_remove+0x40/0x8a
 [<ffffffff813261d0>] __device_release_driver+0x84/0xda
 [<ffffffff81326244>] device_release_driver+0x1e/0x2b
 [<ffffffff811cdcb5>] pci_stop_bus_device+0x44/0x87
 [<ffffffff811cdde2>] pci_stop_and_remove_bus_device+0xd/0x18
 [<ffffffff811d3f3d>] remove_callback+0x20/0x2f
 [<ffffffff8114d1f7>] sysfs_schedule_callback_work+0xf/0x70
 [<ffffffff81049498>] process_one_work+0x1d6/0x34c
 [<ffffffff81049a5f>] worker_thread+0x1cf/0x2b5
 [<ffffffff81049890>] ? rescuer_thread+0x258/0x258
 [<ffffffff8104e0e6>] kthread+0xd6/0xde
 [<ffffffff8104e010>] ? kthread_create_on_node+0x160/0x160
 [<ffffffff81472cbc>] ret_from_fork+0x7c/0xb0
 [<ffffffff8104e010>] ? kthread_create_on_node+0x160/0x160
---[ end trace 94722aa2936a7adf ]---

To correct the bug, rearrange `comedi_free_board_dev()` to destroy the
main sysfs class device *after* the clean-up operation.

Thanks to Bernd Porr for finding the bug and his initial attempt to fix
it.

Reported-by: Bernd Porr <mail@berndporr.me.uk>
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Cc: Bernd Porr <mail@berndporr.me.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-09 10:50:13 -08:00
Chase Southwood c6273c0cfa Staging: comedi: fix spacing/style problem in das1800.c (and das6402.c)
This patch fixes a style issue regarding asterisk placement in
das1800.c and das6402.c found by checkpatch.pl.

Signed-off-by: Chase Southwood <chase.southwood@yahoo.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-09 10:49:31 -08:00
Greg Kroah-Hartman 912cbd4952 Merge 3.13-rc5 into staging-next
This resolves a merge issue with drivers/staging/imx-drm/imx-drm-core.c

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-12-24 10:06:37 -08:00
H Hartley Sweeten 01b6442b46 staging: comedi: ni_660x: tidy up set_tio_counterswap()
Clean up the multi-line comment and tidy the function a bit.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-12-20 11:49:34 -08:00
H Hartley Sweeten d783a20e8f staging: comedi: ni_660x: remove dma_selection_counter()
The counter->chip_index will always be < counters_per_chip due to the
initialization of the subdevices during the attach of the board.

The dma_selection_counter() helper just does a BUG_ON() check before
returning the original value. Just use the original value directly
in the caller and remove the helper function.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-12-20 11:49:34 -08:00
H Hartley Sweeten 0c26c7ed76 staging: comedi: ni_660x: use a local var for the 'chip_index'
Use a local variable for the 'counter->chip_index' to help shorten the
long lines and clarify the code.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-12-20 11:49:34 -08:00
H Hartley Sweeten 1246f05baa staging: comedi: ni_660x: rename the CamelCase enum NI_660x_Register and labels
As prefered by the CodingStyle, rename this CamelCase enum and its labels.

Also, cleanup the ni_gpct_to_660x_register() helper function. Just return the
ni_660x_register for each ni_gpct_register and remove the unnecessary break
statements after the return statements.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-12-20 11:49:34 -08:00
H Hartley Sweeten 16cc181d63 staging: comedi: ni_tiocmd: make ni_tio_cmd() a proper comedi (*do_cmd)
Change the parameters to ni_tio_cmd() to make it a proper comedi
(*do_cmd) function.

The wrappers in the ni_660x and ni_mio_common modules are still needed
to request the mite channel and setup the device before actually doing
the command.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-12-20 11:49:33 -08:00
H Hartley Sweeten c3f3b431de staging: comedi: ni_tiocmd: make ni_tio_cmdtest() a proper comedi (*do_cmdtest)
Change the parameters to ni_tio_cmdtest() to make it a proper comedi
(*do_cmdtest) function. This allows using it directly and removing the
wrapper functions in the ni_660x and ni_mio_common modules.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-12-20 11:49:33 -08:00
H Hartley Sweeten cac04c0f68 staging: comedi: ni_tio: make ni_tio_insn_config() a proper comedi (*insn_config)
Change the parameters to ni_tio_insn_config() to make it a proper comedi
(*insn_config) function. This allows using it directly and removing the
wrapper functions in the ni_660x and ni_mio_common modules.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-12-20 11:49:33 -08:00
H Hartley Sweeten 10f74377ee staging: comedi: ni_tio: make ni_tio_winsn() a proper comedi (*insn_write)
Change the parameters to ni_tio_winsn() to make it a proper comedi
(*insn_write) function. This allows using it directly and removing the
wrapper functions in the ni_660x and ni_mio_common modules.

For aesthetics, rename the function.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-12-20 11:49:33 -08:00
H Hartley Sweeten 9014d816e5 staging: comedi: ni_tio: make ni_tio_rinsn() a proper comedi (*insn_read)
Change the parameters to ni_tio_rinsn() to make is a proper comedi
(*insn_read) function. This allows using it directly and removing the
wrapper functions in the ni_660x and ni_mio_common modules.

For aesthetics, rename the function.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-12-20 11:49:33 -08:00
H Hartley Sweeten 00edbc31d8 staging: comedi: ni_tio.h: remove subdev_to_counter()
This inline helper function simply returns the s->private void *.
Remove the helper and just get the s->private void * directly where
needed.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-12-20 11:49:33 -08:00
H Hartley Sweeten c2e11bb11d staging: comedi: ni_tio.h: remove 'extern' from exported function prototypes
The 'extern' is not required, remove it.

Tidy up the function prototypes a bit.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-12-20 11:49:33 -08:00
H Hartley Sweeten f688d4a763 staging: comedi: ni_tio: move the MODULE_* stuff to the end of file
For aesthetics, move all the MODULE_* information to the end of the file.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-12-20 11:49:33 -08:00
H Hartley Sweeten cafa814958 staging: comedi: ni_tiocmd: move the MODULE_* stuff to the end of file
For aesthetics, move all the MODULE_* information to the end of the file.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-12-20 11:49:33 -08:00
H Hartley Sweeten fca7c1d753 staging: comedi: ni_tio: use a local var for the 'counter_index'
Use a local variable for the 'counter->counter_index' to help shorten the
long lines and ugly line breaks.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-12-20 11:49:33 -08:00
H Hartley Sweeten 5382bfb978 staging: comedi: ni_tiocmd: use a local var for the 'counter_index'
Use a local variable for the 'counter->counter_index' to help shorten the
long lines and ugly line breaks.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-12-20 11:49:33 -08:00
H Hartley Sweeten e6b1624aae staging: comedi: ni_tio_internal.h: add missing NITIO_*_REG macro
The "HW Save" registers are the only ones missing an access macro.
Add one for completness.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-12-20 11:49:33 -08:00
H Hartley Sweeten 94baf025ba staging: comedi: ni_tio_internal.h: replace NITIO_Gi_Interrupt_Enable_Reg()
The "Interrupt Enable" registers are sequential in the enum ni_gpct_register.
Replace this inline CamelCase function with a simple define.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-12-20 11:49:33 -08:00
H Hartley Sweeten c9d766d04a staging: comedi: ni_tio_internal.h: replace NITIO_Gi_Status_Reg()
The "Status" registers are sequential in the enum ni_gpct_register.
Replace this inline CamelCase function with a simple define.

Rename the define for the shared status register.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-12-20 11:49:32 -08:00
H Hartley Sweeten e72ccb041b staging: comedi: ni_tio_internal.h: replace NITIO_Gi_Interrupt_Acknowledge_Reg()
The "Interrupt Acknowledge" registers are sequential in the enum ni_gpct_register.
Replace this inline CamelCase function with a simple define.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-12-20 11:49:32 -08:00
H Hartley Sweeten ff157abe21 staging: comedi: ni_tio_internal.h: replace NITIO_Gi_ABZ_Reg()
The "ABZ" registers are sequential in the enum ni_gpct_register.
Replace this inline CamelCase function with a simple define.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-12-20 11:49:32 -08:00
H Hartley Sweeten 8cd3936e97 staging: comedi: ni_tio_internal.h: replace NITIO_Gi_DMA_Status_Reg()
The "DMA Status" registers are sequential in the enum ni_gpct_register.
Replace this inline CamelCase function with a simple define.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-12-20 11:49:32 -08:00
H Hartley Sweeten 1dd26c2152 staging: comedi: ni_tio_internal.h: replace NITIO_Gi_DMA_Config_Reg()
The "DMA Config" registers are sequential in the enum ni_gpct_register.
Replace this inline CamelCase function with a simple define.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-12-20 11:49:32 -08:00
H Hartley Sweeten 5f19efaca6 staging: comedi: ni_tio_internal.h: replace NITIO_Gxx_Joint_Status2_Reg()
The shared "Status2" registers are sequential in the enum ni_gpct_register.
Replace this inline CamelCase function with a simple define.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-12-20 11:49:32 -08:00
H Hartley Sweeten 450a7c43e8 staging: comedi: ni_tio_internal.h: replace NITIO_Gxx_Joint_Status1_Reg()
The shared "Status1" registers are sequential in the enum ni_gpct_register.
Replace this inline CamelCase function with a simple define.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-12-20 11:49:32 -08:00
H Hartley Sweeten fc31c52f4c staging: comedi: ni_tio_internal.h: replace NITIO_Gxx_Joint_Reset_Reg()
The shared "Reset" registers are sequential in the enum ni_gpct_register.
Replace this inline CamelCase function with a simple define.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-12-20 11:49:32 -08:00
H Hartley Sweeten 96b6175aa3 staging: comedi: ni_tio_internal.h: replace NITIO_Gxx_Status_Reg()
The shared "Status" registers are sequential in the enum ni_gpct_register.
Replace this inline CamelCase function with a simple define.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-12-20 11:49:32 -08:00
H Hartley Sweeten 7a0894e0d4 staging: comedi: ni_tio_internal.h: replace NITIO_Gi_Second_Gate_Reg()
The "Second Gate" registers are sequential in the enum ni_gpct_register.
Replace this inline CamelCase function with a simple define.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-12-20 11:49:32 -08:00
H Hartley Sweeten 0412ea4696 staging: comedi: ni_tio_internal.h: replace NITIO_Gi_Counting_Mode_Reg()
The "Counting Mode" registers are sequential in the enum ni_gpct_register.
Replace this inline CamelCase function with a simple define.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-12-20 11:49:32 -08:00
H Hartley Sweeten 3da68f50f2 staging: comedi: ni_tio_internal.h: replace NITIO_Gi_Input_Select_Reg()
The "Input Select" registers are sequential in the enum ni_gpct_register.
Replace this inline CamelCase function with a simple define.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-12-20 11:49:32 -08:00
H Hartley Sweeten cc7a164b16 staging: comedi: ni_tio_internal.h: replace NITIO_Gi_LoadB_Reg()
The "LoadB" registers are sequential in the enum ni_gpct_register.
Replace this inline CamelCase function with a simple define.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-12-20 11:49:32 -08:00
H Hartley Sweeten 720712f439 staging: comedi: ni_tio_internal.h: replace NITIO_Gi_LoadA_Reg()
The "LoadA" registers are sequential in the enum ni_gpct_register.
Replace this inline CamelCase function with a simple define.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-12-20 11:49:31 -08:00
H Hartley Sweeten 0101791e83 staging: comedi: ni_tio_internal.h: replace NITIO_Gi_Mode_Reg()
The "Mode" registers are sequential in the enum ni_gpct_register.
Replace this inline CamelCase function with a simple define.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-12-20 11:49:31 -08:00
H Hartley Sweeten 67c68de0f1 staging: comedi: ni_tio_internal.h: replace NITIO_Gi_SW_Save_Reg()
The "SW Save" registers are sequential in the enum ni_gpct_register.
Replace this inline CamelCase function with a simple define.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-12-20 11:49:31 -08:00
H Hartley Sweeten e25ef74446 staging: comedi: ni_tio_internal.h: replace NITIO_Gi_Command_Reg()
The "Command" registers are sequential in the enum ni_gpct_register.
Replace this inline CamelCase function with a simple define.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-12-20 11:49:31 -08:00
H Hartley Sweeten e062f51b79 staging: comedi: ni_tio_internal.h: replace NITIO_Gi_Autoincrement_Reg()
The "AutoIncrement" registers are sequential in the enum ni_gpct_register.
Replace this inline CamelCase function with a simple define.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-12-20 11:49:31 -08:00
H Hartley Sweeten 12375292ce staging: comedi: ni_tio.h: rename the CamelCase enum ni_gpct_register labels
As prefered by the CodingStyle, rename all the CamelCase labels of the
enum ni_gpct_register.

Cleanup all the helper functions in ni_tio_internal.h that used the enum.

The 'counter_index' parameter to all the functions is the ni_gpct_device
'counter_index' which is initialized when the subdevices are setup. This
value is always < 4 so the default: BUG() cases can never happen. For
aesthetics, rename the 'counter_idx' to simply 'idx' and fix the type in
some of the helpers.

Also, remove the unnecessary break statements after the return statements.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-12-20 11:49:31 -08:00
Bernd Porr e56b140105 staging: comedi: fix result of memdup_user for user chanlist
If the channel list is not set in userspace we get an error at
PTR_ERR(async->cmd.chanlist). However, do_become_nonbusy(dev, s) cleans
up this pointer which causes a kernel ooops. Setting the channel list in
async to NULL and checking this in do_become_nonbusy prevents the oops.

[Ian Abbott] Also do the same for the chanlist allocated in
do_cmdtest_ioctl().

Signed-off-by: Bernd Porr <mail@berndporr.me.uk>
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-12-17 13:10:40 -08:00
Ian Abbott 1363e4fb4f staging/comedi: bug fix for module usage count on device removal
When a dynamically created comedi device is being automatically removed
by a call to `comedi_auto_unconfig()` from the lower level driver,
`comedi_device_cleanup()` is called to perform the detachment from the
lower level driver.  If the comedi device is open at the time,
`dev->use_count` will be the the number of outstanding opens.  The
function currently decrements the the module counts of the "comedi"
module and the low-level driver module by this amount and reduces
`dev->use_count` to zero.  There are various problems with this as the
`release` file operation handler `comedi_close()` also decrements
`dev->use_count` and decrements the module usage counts.  This means
that `dev->use_count` and the module counts can end up negative.

Also, the assumed one-to-one relationship between the file open count
and the low-level module usage count is invalid and can get screwed up.
We only want to stop the low-level module being unloaded while a comedi
device using the module has an open file object.

Also, there is no need to manipulate the module count of the core
"comedi" module at all since the comedi module is the owner of the file
operations structure and the system will not unload the module while
there are open file objects using it.

Correct the bugs and simplify as follows:

1. Get rid of the module count manipulations of the core "comedi" module
(`THIS_MODULE`) altogether.

2. Don't alter `dev->use_count` in `comedi_device_cleanup()` as it
should only be altered by the `open` and `release` file operation
handlers `comedi_open()` and `comedi_close()`.

3. Increment the low-level module count for the following reasons:

  a) In `comedi_open()` if the open count was zero and the comedi device
     is attached to the low-level driver.
  b) When the `COMEDI_DEVCONFIG` ioctl is used to manually attach an
     unattached comedi device to a low-level driver.  The open count
     will be greater than zero at this time.  The actual increment of
     the low-level module count is already done by
     `comedi_device_attach()`.

4. Decrement the low-level module count for the following reasons:

  a) In `comedi_close()` if the open count was 1 and the comedi device
     is attached to the low-level driver.
  b) In `comedi_device_cleanup()` (called via `comedi_auto_unconfig()`
     --> `comedi_release_hardware_device()` -->
     `comedi_free_board_dev()` when the comedi device is automatically
     unconfigured due to action by the low-level driver) if the device
     was attached (which it should be) and open count was non-zero
     (greater than zero).
  c) When the `COMEDI_DEVCONFIG` ioctl is used to manually detach the
     comedi device from the low-level driver.  The open count will be
     greater than zero at this time.

The open count should never go negative.  Parts 3 and 4 ensure that the
low-level module usage count is incremented on entering the state where
the comedi device is attached to the low-level driver AND the open count
is greater than zero, and is decremented on leaving that state.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-12-17 13:09:43 -08:00