summaryrefslogtreecommitdiffstats
path: root/drivers/staging/comedi/drivers.c
Commit message (Collapse)AuthorAgeFilesLines
* staging: comedi: drivers: fix possible bug in comedi_handle_events()H Hartley Sweeten2016-03-301-1/+4
| | | | | | | | | | | | | | | | This function assumes that the async subdevice has a cancel() function. It looks like all the current comedi drivers implement a cancel() for the async subdevices except for the dt2814 analog input usbdevice. Fix comedi_handle_events() so it does not try to call a non-existent cancel() function. Add a dev_warn() to __comedi_device_postconfig_async() so that any new driver authors will be reminded to implement the cancel(). 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>
* staging: comedi: drivers: tidy up insn_rw_emulate_bits()H Hartley Sweeten2016-03-301-19/+16
| | | | | | | | | Tidy up this function and fix the checkpatch.pl issues: WARNING: Prefer 'unsigned int' to bare use of 'unsigned' 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>
* staging: comedi: fix extreme case of comedi_nsamples_left()Ian Abbott2015-10-271-17/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | `comedi_nsamples_left(s, nsamples)` returns the number of samples remaining to complete an asynchronous command or the passed in `nsamples`, whichever is lower. However, it goes wrong in the extreme case of setting the `nsamples` parameter to `UINT_MAX` when the number of conversions per "scan" (`s->async->cmd.scan_end_arg`) is 1. It uses `comedi_nscans_remaining(s, nscans)` to determine the number of scans remaining, or the parameter `nscans`, whichever is lower. To determine the parameter `nscans`, it divides `nsamples` by the number of conversions per scan and adds 1. The addition of 1 is to avoid setting the parameter `nscans` to 0, as `comedi_nscans_remaining(s, nscans)` treats that value specially. However in the extreme case where `nsamples` is `UINT_MAX` and the number of samples per scan is 1, the addition of 1 to `nscans` overflows, producing the unwanted 0. Fix it by refactoring new a function `__comedi_nscans_remaining(s, nscans)` out of `comedi_nscans_remaining(s, nscans)`. The new function does everything except the special handling when `nscans` is 0. Change `comedi_nsamples_remaining()` to call the new function without adding 1 to `nscans` to avoid the overflow. This overflow bug doesn't affect any of the current COMEDI drivers. I stumbled across it while changing to one of the drivers. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* staging: comedi: drivers.c: document exported functionsIan Abbott2015-09-291-69/+258
| | | | | | | | | Add missing kernel-doc to the low-level COMEDI driver API functions exported from "drivers.c" and tart up some of the existing kernel-doc comments for consistency. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* staging: comedi: drivers.c: replace #include <linux/dma-mapping.h>Ian Abbott2015-09-291-1/+1
| | | | | | | | | Comedi's "drivers.c" doesn't use anything from `<linux/dma-mapping.h>`, but it does use `DMA_NONE` from `<linux/dma-direction.h>`, so replace the appropriate `#include` directive. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* staging: comedi: drivers.c: remove irrelevant #includesIan Abbott2015-09-291-8/+0
| | | | | | | | Comedi's "drivers.c" doesn't use anything from these included headers, so remove them. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* staging: comedi: drivers: coding style: fixed block comment styleMarcos Canán2015-09-161-16/+16
| | | | | | | | This is a patch to the drivers.c file that fixes a block comment style. Signed-off-by: Marcos Canán <mcanan@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* staging: comedi: do not return -ENOSYS.Ted Chen2015-08-051-1/+1
| | | | | | | | | | fixed coding style issue by replacing ENOSYS with EIO because it means 'invalid syscall nr' and nothing else. Signed-off-by: Ted Chen <tedc.37zngo@gmail.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* staging: comedi: wrap COMEDI_SRF_FREE_SPRIV usageIan Abbott2015-04-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | The `COMEDI_SRF_FREE_SPRIV` flag in the `runflags` member of `struct comedi_subdevice` indicates that the memory pointed to by the `private` member can be automatically freed by the comedi core on subdevice clean-up (when the low-level comedi device is being "detached"). the flag doesn't really belong in `runflags`, but it was somewhere convenient to keep it without having to add a new member to the structure. Rather than access the `COMEDI_SRF_FREE_SPRIV` flag directly, use some new wrapper functions: * comedi_can_auto_free_spriv(s) - checks whether the subdevice's `s->private` points to memory that can be freed automatically. * comedi_set_spriv_auto_free(s) - marks the subdevice as having a `s->private` that points to memory that can be freed automatically. Export `comedi_set_spriv_auto_free()` for use by the low-level comedi driver modules, in particular the "amplc_dio200_common" module. 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>
* staging: comedi: drivers: (!foo) preferred over (foo == NULL)H Hartley Sweeten2015-03-061-4/+4
| | | | | | 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>
* staging: comedi: add 'pacer' member to struct comedi_deviceH Hartley Sweeten2015-03-011-0/+2
| | | | | | | | | | | | | Add a new member to the comedi_device struct for a comedi_8254 'pacer'. This provides a convient place to store the data allocated by the comedi_8254 module for boards that use an 8254 device to create the data acquisition pacer clock. Automatically free this pointer in comedi_device_detach_cleanup() so that the drivers don't need to do it when then are detached. 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>
* staging: comedi: comedidev.h: add namespace to the subdevice "runflags"H Hartley Sweeten2015-01-251-1/+1
| | | | | | | | | Tidy up and document the subdevice "runflags". Rename them so they have comedi namespace. 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>
* staging: comedi: drivers: have core hook up default (*insn_read) for readbackH Hartley Sweeten2014-11-261-0/+4
| | | | | | | | | | | | | | | Most of the comedi drivers that provide readback for write only subdevices now use the comedi core comedi_alloc_subdev_readback() helper to allocate the subdevice 'reaback' member instead of using some member in their private data. These drivers also hook up the (*insn_read) callback to the comedi_readback_insn_read() helper to provide the readback. Have the core automatically hook up the (*insn_read) callback after allocating the memory if the driver has not already hooked it up to a private 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>
* staging: comedi: fix scan_end_arg == chanlist_len assumptionIan Abbott2014-11-261-3/+5
| | | | | | | | | | | | | | | | | | | Some comedi drivers allow the `scan_end_arg` value of an asynchronous command to be a multiple (> 1) of the `chanlist_len` although most require them to be the same value. `comedi_bytes_per_scan()` is incorrectly using `chanlist_len` as the length of the scan. Change it to use `scan_end_arg`. `comedi_nsamples_left()` is incorrectly using `cur_chan` as the current sample position in the scan (it is actually the current position in the channel list). Change it to use the actual sample position in the scan. (Unfortunately we only have the current scan position in bytes currently, so convert that to a sample position.) 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>
* staging: comedi: drivers: introduce comedi_nsamples_left()H Hartley Sweeten2014-11-071-0/+32
| | | | | | | | | Introduce a helper function to calculate the number of samples remaining when the cmd->stop_src is TRIG_COUNT. 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>
* staging: comedi: drivers: introduce comedi_nscans_left()H Hartley Sweeten2014-11-071-0/+39
| | | | | | | | | Introduce a helper function to determine the number of scans left in the async 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>
* staging: comedi: comedidev.h: add 'scans_done' member to comedi_asyncH Hartley Sweeten2014-11-051-0/+7
| | | | | | | | | | | | | Introduce a new member to comedi_async to count the number of scans completed. This member is cleared by comedi_buf_reset() along with the other comedi_async members. It is incremented in comedi_inc_scan_progress() when the end of scan is detected. This member will be used to clean up the scan counting in the comedi drivers. 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>
* staging: comedi: remove use of 'bytes_per_sample()'H Hartley Sweeten2014-11-031-2/+2
| | | | | | | | | | | | | This inline helper function has been replaced with comedi_bytes_per_sample(). The same commit (bf33eb4b4f57) introduced a couple other related helper functions a manipulate the sample size. Use the new helper functions to remove the use of 'bytes_per_sample()' and remove it. 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>
* staging: comedi: drivers: move comedi_async 'cur_chan' tracking into the coreH Hartley Sweeten2014-11-031-0/+7
| | | | | | | | | | | | | | | | | | | | The commedi_async 'cur_chan' member is used to track the current position in the chanlist for a scan. Currently only a couple comedi drivers use this member. For aeshtetics, move the 'cur_chan' tracking into the core for non-SDF_PACKED subdevices. The 'cur_chan' will be updated after reading or writing samples to the async buffer by comedi_inc_scan_progress(). All non-SDF_PACKED subdevices will then automatiaclly track the 'cur_chan'. Some of the drivers use the 'cur_chan' to detect the end of scan event when counting scans. The COMEDI_CB_EOS event is automatically added by the core when the end of scan is detected. The drivers just need to check if the 'cur_chan' is 0 to count the number of scans completed. 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>
* staging: comedi: comedidev.h: clarify async->event error/cancel detectionH Hartley Sweeten2014-10-291-1/+1
| | | | | | | | | | | Introduce COMEDI_CB_ERROR_MASK and COMEDI_CB_CANCEL_MASK to clarify the async->events that indicate errors and cancel an async command. Use the new defines to tidy up 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>
* staging: comedi: use DIV_ROUND_UPTapasweni Pathak2014-10-201-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The kernel.h macro DIV_ROUND_UP performs the computation (((n) + (d) - 1) / (d)) but is perhaps more readable. Coccinelle script used : // <smpl> @haskernel@ @@ @depends on haskernel@ expression n,d; @@ ( - (n + d - 1) / d + DIV_ROUND_UP(n,d) | - (n + (d - 1)) / d + DIV_ROUND_UP(n,d) ) @depends on haskernel@ expression n,d; @@ - DIV_ROUND_UP((n),d) + DIV_ROUND_UP(n,d) @depends on haskernel@ expression n,d; @@ - DIV_ROUND_UP(n,(d)) + DIV_ROUND_UP(n,d) // </smpl> Signed-off-by: Tapasweni Pathak <tapaswenipathak@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* staging: comedi: migrate copyrights from "comedi_fc.c"Ian Abbott2014-09-191-0/+1
| | | | | | | | | | | The "comedi_fc" module was originally written and copyrighted by Frank Mori Hess, but the functionality has been migrated into the core "comedi" module. Move the copyright notices over to the affected .c files in the core comedi module. 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>
* staging: comedi: add comedi_handle_events()Ian Abbott2014-09-191-0/+33
| | | | | | | | | | | | | | 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>
* staging: comedi: add comedi_inc_scan_progress()Ian Abbott2014-09-191-0/+24
| | | | | | | | | | | | | | 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>
* staging: comedi: add comedi_bytes_per_scan()Ian Abbott2014-09-191-0/+37
| | | | | | | | | | | | | | 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>
* staging: comedi: add a 'readback' member to comedi_subdeviceH Hartley Sweeten2014-08-301-0/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* staging: comedi: add an 'mmio' member to comedi_deviceH Hartley Sweeten2014-07-301-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>
* staging: comedi: comedidev.h: remove 'new_size' param from subdevice ↵H Hartley Sweeten2014-07-221-1/+1
| | | | | | | | | | | | | | (*buf_change) 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>
* staging: comedi: drivers.c: checkpatch.pl --strict cleanupH Hartley Sweeten2014-07-181-1/+3
| | | | | | | | | | | Fix the checkpatch.pl --strict issues: CHECK: DEFINE_MUTEX definition without comment CHECK: braces {} should be used on all arms of this statement 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>
* staging: comedi: remove comedi_error()H Hartley Sweeten2014-07-171-2/+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>
* staging: comedi: remove subdevice member of struct comedi_asyncIan Abbott2014-05-231-1/+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>
* staging: comedi: drivers.c: Fix missing a blank line, after declarations warningYves Deweerdt2014-04-141-0/+1
| | | | | Signed-off-by: Yves Deweerdt <yves.deweerdt.linux@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* staging: comedi: introduce comedi_timeout()H Hartley Sweeten2014-02-141-0/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* staging: comedi: fix too early cleanup in comedi_auto_config()Ian Abbott2014-02-071-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | `comedi_auto_config()` is usually called from the probe routine of a low-level comedi driver to allocate and auto-configure a comedi device. Part of this involves calling the low-level driver's `auto_attach()` handler, and if that is successful, `comedi_device_postconfig()` tries to complete the configuration of the comedi device. If either of those fail, `comedi_device_detach()` is called to clean up, and `comedi_release_hardware_device()` is called to remove the dynamically allocated comedi device. Unfortunately, `comedi_device_detach()` clears the `hw_dev` member of the `struct comedi_device` (indirectly via `comedi_clear_hw_dev()`), and that stops `comedi_release_hardware_device()` finding the comedi device associated with the hardware device, so the comedi device won't be removed properly. Since `comedi_release_hardware_device()` also calls `comedi_device_detach()` (assuming it finds the comedi device associated with the hardware device), the fix is to remove the direct call to `comedi_device_detach()` from `comedi_auto_config()` and let the call to `comedi_release_hardware_device()` take care of it. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* staging: comedi: report success/failure of autoconfigBernd Porr2014-01-091-2/+18
| | | | | | | | | | | | | | | | 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>
* Merge 3.13-rc5 into staging-nextGreg Kroah-Hartman2013-12-241-1/+1
|\ | | | | | | | | | | This resolves a merge issue with drivers/staging/imx-drm/imx-drm-core.c Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * staging: comedi: drivers: fix return value of comedi_load_firmware()H Hartley Sweeten2013-12-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Some of the callback functions that upload the firmware in the comedi drivers return a positive value indicating the number of bytes sent to the device. Detect this condition and just return '0' to indicate a successful upload. Reported-by: Bernd Porr <mail@berndporr.me.uk> Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Acked-by: Ian Abbott <abbotti@mev.co.uk> Acked-by: Dan Carpenter <dan.carpenter@oracle.com> Cc: stable <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* | staging: comedi: use refcount in comedi_driver_unregister()Ian Abbott2013-11-111-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | Change `comedi_driver_unregister()` to call `comedi_dev_get_from_minor()` instead of `comedi_dev_from_minor()` when finding devices using the driver. This increments the reference count to prevent the device being removed while it is being checked to see if it is attached to the driver. Call `comedi_dev_put()` to decrement the reference afterwards. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* | staging: comedi: add detachment counter for validity checksIan Abbott2013-11-111-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>
* | staging: comedi: cancel commands before detaching deviceIan Abbott2013-11-111-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | The comedi core module's handling of the `COMEDI_DEVCONFIG` ioctl will not allow a device to be detached if it is busy. However, comedi devices can also be auto-detached due to a removal of a hardware device. One of the things we should do in that case is cancel any asynchronous commands that are running. Add a new function `comedi_device_cancel_all()` to do that and call it from `comedi_device_detach()`. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* | staging: comedi: cleanup_device() -> comedi_device_detach_cleanup()Ian Abbott2013-11-111-2/+2
| | | | | | | | | | | | | | | | | | | | | | Rename the local function `cleanup_device()` to `comedi_device_detach_cleanup()`. It is only called from the `comedi_device_detach()` function and that is called from `comedi_device_cleanup()` and other places. The more specific function name seems less confusing. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* | staging: comedi: use attach_lock semaphore during attach and detachIan Abbott2013-11-111-1/+4
|/ | | | | | | | | | | | Acquire the `attach_lock` semaphore in the `struct comedi_device` while modifying the `attached` flag. This is a "write" acquire. Note that the main mutex in the `struct comedi_device` is also held at this time. Tasks wishing to check the device is attached will need to either acquire the main mutex, or "read" acquire the `attach_lock` semaphore, or both in that order. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* staging: comedi: drivers: introduce comedi_dio_update_state()H Hartley Sweeten2013-09-171-0/+22
| | | | | | | | | | | | | | | | | | | | | 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>
* staging: comedi: initialize subdevice s->io_bits in postconfigH Hartley Sweeten2013-09-171-0/+7
| | | | | | | | | | | | | | | | | The subdevice 'io_bits' is a bit mask of the i/o configuration for digital subdevices. '0' values indicate that a channel is configured as an input and '1' values that the channel is an output. Since the subdevice data is kzalloc()'d, all channels default as inputs. Modify __comedi_device_postconfig() so that 'io_bits' is correctly initialized for Digital Output subdevices. Remove all the unnecessary initializations of 's->io_bits' from the drivers. Also, remove the unnecessary initialization of the 's->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>
* Merge tag 'staging-3.12-rc1' of ↵Linus Torvalds2013-09-031-17/+77
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging Pull staging tree merge from Greg KH: "Here's the bit staging tree pull request for 3.12-rc1. Lots of staging driver updates, and fixes. Lustre is finally enabled in the build, and lots of cleanup started happening in it. There's a new wireless driver in here, and 2 new TTY drivers, which cause the overall lines added/removed to be quite large on the "added" side. The IIO driver updates are also coming through here, as they are tied to the staging iio drivers" * tag 'staging-3.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (942 commits) staging: dwc2: make dwc2_core_params documentation more complete staging: dwc2: validate the value for phy_utmi_width staging: dwc2: interpret all hwcfg and related register at init time staging: dwc2: properly mask the GRXFSIZ register staging: dwc2: remove redundant register reads staging: dwc2: re-use hptxfsiz variable staging: dwc2: simplify debug output in dwc_hc_init staging: dwc2: add missing shift staging: dwc2: simplify register shift expressions staging: dwc2: only read the snpsid register once staging: dwc2: unshift non-bool register value constants staging: dwc2: fix off-by-one in check for max_packet_count parameter staging: dwc2: remove specific fifo size constants Staging:BCM:DDRInit.c:Renaming __FUNCTION__ staging: bcm: remove Version.h file. staging: rtl8188eu: off by one in rtw_set_802_11_add_wep() staging: r8188eu: copying one byte too much staging: rtl8188eu: || vs && typo staging: r8188eu: off by one bugs staging: crystalhd: Resolve sparse 'different base types' warnings. ...
| * staging: comedi: drivers: introduce comedi_dio_insn_config()H Hartley Sweeten2013-08-121-0/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * Revert "staging: comedi: core: introduce comedi_dio_insn_config()"Greg Kroah-Hartman2013-08-121-40/+0
| | | | | | | | | | | | | | | | | | | | This reverts commit 4f76463d3b8f8cc0cac5bb292ec766848f3f4fa1. I applied an incorrect version here as well :( Cc: H Hartley Sweeten <hsweeten@visionengravers.com> Cc: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * staging: comedi: core: introduce comedi_dio_insn_config()H Hartley Sweeten2013-08-121-0/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 parameters 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * staging: comedi: use a mutex when accessing driver listIan Abbott2013-07-231-14/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Low-level comedi drivers registered with the comedi core by `comedi_driver_register()` are linked together into a simple linked list headed by the `comedi_drivers` variable and chained by the `next` member of `struct comedi_driver`. A driver is removed from the list by `comedi_driver_unregister()`. The driver list is iterated through by `comedi_device_attach()` when the `COMEDI_DEVCONFIG` ioctl is used to attach a "legacy" device to a driver, and is also iterated through by `comedi_read()` in "proc.c" when reading "/proc/comedi". There is currently no protection against items being added or removed from the list while it is being iterated. Add a mutex `comedi_drivers_list_lock` to be locked while adding or removing an item on the list, or when iterating through the list. `comedi_driver_unregister()` also checks for and detaches any devices using the driver. This is currently done before unlinking the driver from the list, but it makes more sense to unlink the driver from the list first to prevent `comedi_device_attach()` attempting to use it, so move the unlinking part to the start of the function. Also, in `comedi_device_attach()` hold on to the mutex until we've finished attempting to attach the device to avoid it interfering with the detachment in `comedi_driver_unregister()`. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * staging: comedi: return void from comedi_driver_unregister()Ian Abbott2013-07-231-4/+3
| | | | | | | | | | | | | | | | | | 'Unregister' functions generally return `void`. `comedi_driver_unregister()` currently returns an `int` errno value. Nothing looks at the return value. Change the return type to `void`. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
OpenPOWER on IntegriCloud