aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/comedi/comedidev.h (follow)
AgeCommit message (Collapse)AuthorFilesLines
2014-10-29staging: comedi: comedidev.h: don't expose COMEDI_CB_* defines to userspaceH Hartley Sweeten1-0/+16
The COMEDI_CB_* defines are the comedi_async "events" that the drivers set to let the core detect the state of running async commands. These "events" are only relevant to the kernel modules and should not be exposed to userspace in the comedi.h user API header. Move the defines to comedidev.h to avoid exposing them. For aesthetics, convert the defines to bit shifts to better indicate that they are bitmask values. Cleanup the documentation. 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>
2014-09-19staging: comedi: add comedi_read_array_from_buffer()Ian Abbott1-0/+2
The "comedi_fc" module contains a few functions useful to Comedi drivers. Their functionality is being migrated to the core "comedi" module and renamed to start with the prefix `comedi_`. As part of this migration, move `cfc_read_array_from_buffer()` into the core comedi module and rename it to `comedi_read_array_from_buffer()`. Change the external declaration of `cfc_read_array_from_buffer()` into an inline function that calls `comedi_read_array_from_buffer()`. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-09-19staging: comedi: add comedi_write_array_to_buffer()Ian Abbott1-0/+3
The "comedi_fc" module contains a few functions useful to Comedi drivers. Their functionality is being migrated to the core "comedi" module and renamed to start with the prefix `comedi_`. As part of this migration, move `cfc_write_array_to_buffer()` into the core comedi module and rename it to `comedi_write_array_to_buffer()`. Change the external declaration of `cfc_write_array_to_buffer()` into an inline function that calls `comedi_write_array_to_buffer()`. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-09-19staging: comedi: add comedi_handle_events()Ian Abbott1-0/+3
The "comedi_fc" module contains a few functions useful to Comedi drivers. Their functionality is being migrated to the core "comedi" module and renamed to start with the prefix `comedi_`. As part of this migration, move `cfc_handle_events()` into the core comedi module and rename it to `comedi_handle_events()`. Change the external declaration of `cfc_handle_events()` into an inline function that calls `comedi_handle_events()`. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-09-19staging: comedi: add comedi_inc_scan_progress()Ian Abbott1-0/+2
The "comedi_fc" module contains a few functions useful to Comedi drivers. Their functionality is being migrated to the core "comedi" module and renamed to start with the prefix `comedi_`. As part of this migration, move `cfc_inc_scan_progress()` into the core comedi module and rename it to `comedi_inc_scan_progress()`. Change the external declaration of `cfc_inc_scan_progress()` into an inline function that calls `comedi_inc_scan_progress()`. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-09-19staging: comedi: add comedi_bytes_per_scan()Ian Abbott1-0/+1
The "comedi_fc" module contains a few functions useful to Comedi drivers. Their functionality is being migrated to the core "comedi" module and renamed to start with the prefix `comedi_`. As part of this migration, move `cfc_bytes_per_scan()` into the core comedi module and rename it to `comedi_bytes_per_scan()`. Change the external declaration of `cfc_bytes_per_scan()` into an inline function that calls `comedi_bytes_per_scan()`. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-09-19staging: comedi: remove comedi_board()Ian Abbott1-5/+0
All calls to the inline function `comedi_board()` in "comedidev.h" have been removed, so remove the function. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-08-30staging: comedi: comedi_pci: introduce comedi_pci_detach()H Hartley Sweeten1-0/+5
Introduce a generic (*detach) function for comedi PCI drivers to handle the boilerplate code needed to detach a PCI driver. This function works similar to comedi_legacy_detach() where it will: * free the dev->irq if it has been requested * iounmap the dev->mmio addres if it has been ioremap'ed The helper then calls comedi_pci_disable() to release the regions and disable the PCI device. Use the new helper directly for the (*detach) in the following cases: * where comedi_pci_disable() is used directly for the (*detach) * where the detach function is just boilerplate Use the new helper in the (*detach) of the simpler PCI drivers. Call the helper after disabling interrupts (reset) and before any additional cleanup (kfree) to avoid any race conditions with the interrupt handler. 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>
2014-08-30staging: comedi: add a 'readback' member to comedi_subdeviceH Hartley Sweeten1-0/+6
The analog output hardware in most comedi drivers does not provide a way to readback to last values written to the channels. In order to provide an (*insn_read) for the analog output subdevice, the comedi drivers save the last values for each channel in the private data. Add a new member, 'readback', to the comedi_subdevice definition to provide a common way to save these values. Introduce a comedi core function, comedi_alloc_subdev_readback(), to allocate the memory needed to save the values. This memory will be automatically kfree'd when the driver is detached. Introduce a comedi core function, comedi_readback_insn_read(), that the comedi drivers can use for the (*insn_read) of a subdevice to return the saved values for each channel. This will allow removing the boilerplate in the comedi drivers to return the saved values. In some drivers it will also allow removing the private data completely. 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>
2014-07-30staging: comedi: add an 'mmio' member to comedi_deviceH Hartley Sweeten1-0/+1
All the comedi drivers that use memory mapped io currently have a void __iomem * member in their private data for the driver. For some of the drivers this is actually the only member in that data. For convienence, add a new member to the comedi_device for this void __iomem *. 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>
2014-07-22staging: comedi: comedidev.h: remove 'new_size' param from subdevice (*buf_change)H Hartley Sweeten1-2/+1
This parameter is never used by any of the comedi drivers that provide a (*buf_change) callback. If the 'new_size' is needed in the callback it can be found from the 's->async->prealloc_bufsz' as done in the ni_pcidio driver. Remove the unused parameter. 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>
2014-07-22staging: comedi: comedidev.h: remove unused callbacks from comedi_subdeviceH Hartley Sweeten1-3/+0
The 'do_lock' and 'do_unlock' callbacks are not used be any of the comedi drivers or the comedi core. Just remove them. 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>
2014-07-18staging: comedi: comedidev.h: checkpatch.pl --strict cleanupH Hartley Sweeten1-2/+3
Fix the checkpatch.pl --strict issues: CHECK: Please use a blank line after function/struct/union/enum declarations CHECK: Alignment should match open parenthesis Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Cc: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-07-17staging: comedi: remove comedi_error()H Hartley Sweeten1-1/+0
The comedi_error() function is just a wrapper around dev_err() that adds the dev->driver->driver_name prefix to the message and a terminating new-line character. All of the users of this function have been converted to use dev_err() directly. Remove the now unused function. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Cc: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-07-16staging: comedi: comedidev.h: introduce some 'range_is_external' helpersH Hartley Sweeten1-0/+13
The comedi_krange includes a flags member that currently identifies the 'units' of the range (RF_UNIT) and if the range is from an internal or external source (RF_EXTERNAL). Introduce some helper functions to check if a given range is from an external source. 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>
2014-07-15staging: comedi: removing not useful `else` after returnKinka Huang1-2/+2
Signed-off-by: Kinka Huang <kinkabrain@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-06-26staging: comedi: introduce comedi_buf_n_bytes_ready()H Hartley Sweeten1-0/+5
Introduce an inline helper to return the number of bytes that are ready to read from the comedi_async buffer. Use the helper in the comedi drivers that currently do the calculation as part of the (*poll) operation. Also, use the helper in comedi_fops where the calculation is used as part of the subdevice going nonbusy. 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>
2014-06-20staging: comedi: describe struct comedi_asyncIan Abbott1-25/+92
Describe `struct comedi_async` in kerneldoc format. Expand on the members involved in reading/writing the buffer. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-05-27staging: comedi: remove in_request_moduleIan Abbott1-1/+0
The `in_request_module` member of `struct comedi_device` is only ever set to `false`, so remove the code that checks for it being `true` and remove the member. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-05-23staging: comedi: remove subdevice member of struct comedi_asyncIan Abbott1-2/+0
The `async` member of `struct comedi_subdevice` may point to a `struct comedi_async` or may be NULL. The `subdevice` member of `struct comedi_async` points back to the `struct comedi_subdevice` associated with it in a one-to-one relationship. All uses of the `subdevice` member of `struct comedi_async` apart from its initialization have now been removed (by passing around a pointer to the subdevice instead of to the "async" structure), so get rid of it. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-05-23staging: comedi: pass subdevice to comedi_buf_read_n_available()Ian Abbott1-1/+1
Change the parameters of `comedi_buf_read_n_available()` to pass a pointer to the comedi subdevice instead of a pointer to the "async" structure belonging to the subdevice. The main aim at the moment is to replace all the `struct comedi_async *` parameters with `struct comedi_subdevice *` parameters in the comedi driver API. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-05-23staging: comedi: pass subdevice to comedi_buf_read_free()Ian Abbott1-1/+1
Change the parameters of `comedi_buf_read_free()` to pass a pointer to the comedi subdevice instead of a pointer to the "async" structure belonging to the subdevice. The main aim at the moment is to replace all the `struct comedi_async *` parameters with `struct comedi_subdevice *` parameters in the comedi driver API. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-05-23staging: comedi: pass subdevice to comedi_buf_read_alloc()Ian Abbott1-1/+1
Change the parameters of `comedi_buf_read_alloc()` to pass a pointer to the comedi subdevice instead of a pointer to the "async" structure belonging to the subdevice. The main aim at the moment is to replace all the `struct comedi_async *` parameters with `struct comedi_subdevice *` parameters in the comedi driver API. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-05-23staging: comedi: pass subdevice to comedi_buf_write_free()Ian Abbott1-1/+1
Change the parameters of `comedi_buf_write_free()` to pass a pointer to the comedi subdevice instead of a pointer to the "async" structure belonging to the subdevice. The main aim at the moment is to replace all the `struct comedi_async *` parameters with `struct comedi_subdevice *` parameters in the comedi driver API. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-05-23staging: comedi: pass subdevice to comedi_buf_write_alloc()Ian Abbott1-1/+1
Change the parameters of `comedi_buf_write_alloc()` to pass a pointer to the comedi subdevice instead of a pointer to the "async" structure belonging to the subdevice. The main aim at the moment is to replace all the `struct comedi_async *` parameters with `struct comedi_subdevice *` parameters in the comedi driver API. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-05-23staging: comedi: pass subdevice to comedi_buf_memcpy_from()Ian Abbott1-1/+1
Change the parameters of `comedi_buf_memcpy_from()` to pass a pointer to the comedi subdevice instead of a pointer to the "async" structure belonging to the subdevice. The main aim at the moment is to replace all the `struct comedi_async *` parameters with `struct comedi_subdevice *` parameters in the comedi driver API. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-05-23staging: comedi: pass subdevice to comedi_buf_memcpy_to()Ian Abbott1-1/+1
Change the parameters of `comedi_buf_memcpy_to()` to pass a pointer to the comedi subdevice instead of a pointer to the "async" structure belonging to the subdevice. The main aim at the moment is to replace all the `struct comedi_async *` parameters with `struct comedi_subdevice *` parameters in the comedi driver API. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-05-23staging: comedi: pass subdevice to comedi_buf_get()Ian Abbott1-1/+1
Change the parameters of `comedi_buf_get()` to pass a pointer to the comedi subdevice instead of a pointer to the "async" structure belonging to the subdevice. The function gets a sample value from the comedi buffer, but currently only deals with 16-bit sample types. A future version could deal with 16 or 32-bit sample types depending on the value of the SDF_LSAMPL subdevice flag. The main aim at the moment is to replace all the `struct comedi_async *` parameters with `struct comedi_subdevice *` parameters in the comedi driver API. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-05-23staging: comedi: pass subdevice to comedi_buf_put()Ian Abbott1-1/+1
Change the parameters of `comedi_buf_put()` to pass a pointer to the comedi subdevice instead of a pointer to the "async" structure belonging to the subdevice. The function puts a sample value in the comedi buffer, but currently only deals with 16-bit sample types. A future version could deal with 16 or 32-bit sample types depending on the value of the SDF_LSAMPL subdevice flag. The main aim at the moment is to replace all the `struct comedi_async *` parameters with `struct comedi_subdevice *` parameters in the comedi driver API. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-02-27Staging: comedi: Fix unnecessary space after function pointerMonam Agarwal1-24/+24
This patch fixes the following checkpatch.pl warning in comedidev.h WARNING: Fix unnecessary space after function pointer Signed-off-by: Monam Agarwal <monamagarwal123@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-02-14staging: comedi: introduce comedi_timeout()H Hartley Sweeten1-0/+8
Introduce a comedi core helper function to handle the boilerplate needed by the drivers to busy- wait for a condition to occur. Typically this condition is the analog input/output end-of-conversion used with the comedi (*insn_read) and (*insn_write) operations. To use this function, the drivers just need to provide a callback that checks for the desired condition. The callback should return 0 if the condition is met or -EBUSY if it is still waiting. Any other errno will be returned to the caller. If the timeout occurs before the condition is met -ETIMEDOUT will be returned. The parameters to the callback function are the comedi_device, comedi_subdevice, and comedi_insn pointers that were passed to the (*insn_read) or (*insn_write) as well as an unsigned long, driver specific, 'context' that can be used to pass any other information that might be needed in the callback. This 'context' could be anything such as the register offset to read the status or the bits needed to check the status. The comedi_timeout() function itself does not use any of these parameters. This will help remove all the crazy "wait this many loops" used by some of the drivers. It also creates a common errno for comedi to detect when a timeout occurs. ADC/DAC conversion times are typically pretty fast, usually around 100K samples/sec (10 usec). A conservative timeout of 1 second is used in comedi_timeout(). Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Cc: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-13comedi: Humusoft MF634 and MF624 DAQ cards driverRostislav Lisovy1-0/+1
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>
2013-11-26staging: comedi: remove DPRINTK macroH Hartley Sweeten1-2/+0
All users of this macro have been converted to use dev_dbg(). Remove the unused macro. 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-11-25staging: comedi: remove comedi_debug module parameterH Hartley Sweeten1-10/+1
Remove this module parameter and use the CONFIG_COMEDI_DEBUG option to enable normal kernel debugging with -DDEBUG flag. Remove the #undef DEBUG from all the comedi source files so they will honour the -DDEBUG flag. 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-11-11staging: comedi: protect buffer from being freed while mmappedIan Abbott1-5/+9
If a comedi device is automatically detached by `comedi_auto_unconfig()` any data buffers associated with subdevices that support asynchronous commands will be freed. If the buffer is mmapped at the time, bad things are likely to happen! Prevent this by moving some of the buffer details from `struct comedi_async` into a new, dynamically allocated, and kref-counted `struct comedi_buf_map`. This holds a list of pages, a reference count, and enough information to free the pages. The new member `buf_map` of `struct comedi_async` points to a `struct comedi_buf_map` when the buffer size is non-zero. Provide a new helper function `comedi_buf_is_mapped()` to check whether an a buffer is mmapped. If it is mmapped, the buffer is not allowed to be resized and the device is not allowed to be manually detached by the `COMEDI_DEVCONFIG` ioctl. Provide helper functions `comedi_buf_map_get()` and `comedi_buf_map_put()` to manipulate the reference count of the `struct comedi_buf_map`, which will be freed along with its contents via the 'release' callback of the `kref_put()` call. The reference count is manipulated by the vma operations and the mmap file operation. Now, when the comedi device is automatically detached, the buffer will be effectively freed by calling `comedi_buf_alloc()` with a new buffer size of 0. That calls local function `__comedi_buf_free()` which calls `comedi_buf_map_put()` on the `buf_map` member to free it. It won't actually be freed until the final 'put'. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-11-11staging: comedi: remove comedi_dev_from_minor()Ian Abbott1-1/+0
The `comedi_dev_from_minor()` function is no longer used, so remove it. Calls to it have either been replaced by calls to `comedi_dev_get_from_minor()` or by using the `private_data` member of the open file object. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-11-11staging: comedi: add comedi_dev_get_from_minor()Ian Abbott1-0/+2
Add function `struct comedi_device *comedi_dev_get_from_minor(unsigned minor)`. This behaves like the existing `comedi_dev_from_minor()` except that it also increments the `struct kref refcount` member (via new helper function `comedi_dev_get()`) to prevent it being freed. If it returns a valid pointer, the caller is responsible for calling `comedi_dev_put()` to decrement the reference count. Export `comedi_dev_get_from_minor()` and `comedi_dev_put()` as they will be used by the "kcomedilib" module in addition to the "comedi" module itself. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-11-11staging: comedi: add a kref to comedi deviceIan Abbott1-0/+2
Add a `struct kref refcount` member to `struct comedi_device` to allow safe destruction of the comedi device. Only free the comedi device via the 'release' callback `kref_put()`. Currently, nothing calls `kref_put()`, so the safe destruction is ineffective, but this will be addressed by later patches. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-11-11staging: comedi: add detachment counter for validity checksIan Abbott1-0/+1
Add a member `detach_count` to `struct comedi_device` that is incremented every time the device gets detached. This will be used in some validity checks in the 'read' and 'write' file operations to make sure the attachment remains valid. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-11-11staging: comedi: add rw_semaphore to protect against device detachmentIan Abbott1-0/+2
The 'read' and 'write' file operations on comedi devices do not use the main mutex in the `struct comedi_device` to avoid contention with ioctls that may take a while to complete. However, it is necessary to protect against the device being detached while the operation is in progress. Add member `struct rw_semaphore attach_lock` to `struct comedi_device` for this purpose and initialize it on creation. The actual locking and unlocking will be implemented by subsequent patches. Tasks that are attaching or detaching comedi devices will write-acquire the new semaphore whilst also holding the main mutex in the `struct comedi_device`. Tasks that wish to protect against the comedi device being detached need to acquire either the main mutex, or read-acquire the new semaphore, or both in that order. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-11-11staging: comedi: add a couple of #includes to comedidev.hIan Abbott1-0/+2
Two structures defined in "comedidev.h" have an element of type `spinlock_t`, so add `#include <linux/spinlock_types.h>` to declare it. One structure has an element of type `struct mutex` so add `#include <linux/mutex.h>` to declare it. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-11-11staging: comedi: remove unused command callback supportIan Abbott1-4/+0
The 'kcomedilib' module used to provide functions to allow asynchronous comedi commands to be set up from another kernel module, but now commands can only be set up by ioctls from user space via the core comedi module. Since support for commands initiated from kernel space has been dropped, the `cb_func` and `cb_arg` members of `struct comedi_async` are never set (although the `cb_mask` member is still used to mask comedi events). The `SRF_USER` bit of the comedi subdevice runflags is no longer needed to distinguish commands from user and kernel space since they only come from user space. Don't bother setting or testing the `SRF_USER` flag, and get rid of it, along with the `cb_func` and `cb_arg` members. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-10-16staging: comedi: use unsigned samples for comedi_buf_put()/get()Ian Abbott1-2/+2
Sample values in comedi are generally represented as unsigned values. `comedi_buf_put()` and `comedi_buf_get()` use a `short` to hold the 16-bit data value being transferred to or from the comedi buffer. Change them to use `unsigned short` for consistency. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-10-07staging: comedi: remove 'settling_time_0' from subdeviceIan Abbott1-2/+0
The `settling_time_0` member of `struct comedi_subdevice` can be set by a low-level comedi driver and will be copied to user-space as part of the information provided by the `COMEDI_SUBDINFO` ioctl. No comedi driver has ever set it; it's just been left at its initial value of 0. Remove it to save a bit of space, and behave as though it is 0. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-10-07staging: comedi: remove unused 'channel flags' supportIan Abbott1-3/+0
The `flags` and `flaglist` members of `struct comedi_subdevice` were defined to supply "all-channel" flags via the `COMEDI_SUBDINFO` ioctl, or "channel-specific" flags via the `COMEDI_CHANINFO` ioctls, respectively. However, no comedi driver has ever set them. It's not entirely clear how "all-channel" flags would differ from the "subdevice" flags passed by `COMEDI_SUBDINFO`. It is conceivable that "channel-specific" flags could be used to describe different analog reference values (or whatever) supported by different channels. Presumably these would use some sub-set of the `SDF_xxx` subdevice flag values, or possibly the `CR_xxx` flag values that get packed into a "chanspec" value (along with a channel number and range code). The original intentions are lost in the mists of time. For now, just remove the `flags` and `flaglist` members from `struct comedi_subdevice` and behave as though they have been left at their default values (0 or NULL) by the low-level comedi driver. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-09-26staging: comedi: core: introduce comedi_chan_range_is_{bi,uni}polar()H Hartley Sweeten1-0/+14
Introduce two helper functions to check if a subdevice range_table_list for a given channel/range is bipolar or unipolar. 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-09-25staging: comedi: core: introduce comedi_offset_munge()H Hartley Sweeten1-1/+6
The comedi core expects the data to/from analog subdevices to be in offset binary coding. This means that a value of '0' represents the most negative and a value of 's->maxdata' the most positive signal of the analog subdevice. Many comedi drivers require the data written to the analog outputs, or returned from the analog inputs, be in two's complement format. Introduce a helper function to munge the data for analog subdevices. This function simply inverts the sign bit and masks the result by 's->maxdata' to keep the result in range for the subdevice. The strange: return val ^ s->maxdata ^ (s->maxdata >> 1); is equivalent to: return (val ^ ((s->maxdata + 1) >> 1) & s->maxdata; as long as s->maxdata is a value of the form (1 << n) - 1. This avoids the 32-bit unsigned overflow for a s->maxdata of 0xffffffff. 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-09-17staging: comedi: drivers: introduce comedi_dio_update_state()H Hartley Sweeten1-0/+2
The (*insn_bits) functions for DIO and DO subdevices typically use the subdevice 's->state' to hold the current state of the output channels. The 'insn' passed to these functions, INSN_BITS, specifies two parameters passed in the 'data'. data[0] = 'mask', the channels to update data[1] = 'bits', the new state for the channels Introduce a helper function to handle the boilerplate used to update the internal state. Note that the 'mask' is filtered by the 'chanmask' of the channels actually supported by the subdevice. This is used to protect any non-channel related bits that are stored in the subdevice state. 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-09-03Merge tag 'tty-3.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/ttyLinus Torvalds1-1/+0
Pull tty/serial driver patches from Greg KH: "Here's the big tty/serial driver pull request for 3.12-rc1. Lots of n_tty reworks to resolve some very long-standing issues, removing the 3-4 different locks that were taken for every character. This code has been beaten on for a long time in linux-next with no reported regressions. Other than that, a range of serial and tty driver updates and revisions. Full details in the shortlog" * tag 'tty-3.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty: (226 commits) hvc_xen: Remove unnecessary __GFP_ZERO from kzalloc serial: imx: initialize the local variable tty: ar933x_uart: add device tree support and binding documentation tty: ar933x_uart: allow to build the driver as a module ARM: dts: msm: Update uartdm compatible strings devicetree: serial: Document msm_serial bindings serial: unify serial bindings into a single dir serial: fsl-imx-uart: Cleanup duplicate device tree binding tty: ar933x_uart: use config_enabled() macro to clean up ifdefs tty: ar933x_uart: remove superfluous assignment of ar933x_uart_driver.nr tty: ar933x_uart: use the clk API to get the uart clock tty: serial: cpm_uart: Adding proper request of GPIO used by cpm_uart driver serial: sirf: fix the amount of serial ports serial: sirf: define macro for some magic numbers of USP serial: icom: move array overflow checks earlier TTY: amiserial, remove unnecessary platform_set_drvdata() serial: st-asc: remove unnecessary platform_set_drvdata() msm_serial: Send more than 1 character on the console w/ UARTDM msm_serial: Add support for non-GSBI UARTDM devices msm_serial: Switch clock consumer strings and simplify code ...
2013-08-12staging: comedi: drivers: introduce comedi_dio_insn_config()H Hartley Sweeten1-0/+4
DIO subdevices always handle the INSN_CONFIG_DIO_{INPUT,OUTPUT} instructions to configure the DIO channels. They also always handle the INSN_CONFIG_DIO_QUERY instruction to query the configuration of a DIO channel. Introduce a helper function to handle the (*insn_config) boilerplate for comedi DIO subdevices. This function has the same paramters as (*insn_config) functions with an additional parameter to allow the caller to pass a 'mask' value for grouped DIO channels. This function returns: 0 if the instruction was successful but requires additional handling by the caller (INSN_CONFIG_DIO_{INPUT,OUTPUT} insn->n if the instruction was handled (INSN_CONFIG_DIO_QUERY) -EINVAL for all unhandled instructions The caller is responsible for actually configuring the hardware based on the configuration (s->io_bits). Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>