aboutsummaryrefslogtreecommitdiff
path: root/drivers/staging/comedi/comedidev.h
AgeCommit message (Collapse)Author
2013-09-03Merge tag 'tty-3.12-rc1' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty 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 Sweeten
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>
2013-08-12Revert "staging: comedi: core: introduce comedi_dio_insn_config()"Greg Kroah-Hartman
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>
2013-08-12staging: comedi: core: introduce comedi_dio_insn_config()H Hartley Sweeten
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>
2013-07-26pci_ids.h: move PCI_VENDOR_ID_AMCC hereIan Abbott
PCI_VENDOR_ID_AMCC is defined locally in "drivers/staging/comedi/comedidev.h" for a few comedi hardware drivers, namely "adl_pci9118", "addi_apci_1500" and "addi_apci_3120" (also "addi_apci_1710" but that is not currently built and will probably be removed soon). Move the define into "include/linux/pci_ids.h" as it is shared by several drivers (albeit all comedi drivers currently). PCI_VENDOR_ID_AMCC happens to have the same value (0x10e8) as PCI_VENDOR_ID_ADDIDATA_OLD. The vendor ID is actually assigned to Applied Micro Circuits Corporation and Addi-Data were using device IDs assigned by AMCC on some of their earlier PCI boards. The PCI_VENDOR_ID_ADDIDATA_OLD define is still being used by the "8250_pci" PCI serial board driver. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Acked-by: Bjorn Helgaas <bhelgaas@google.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-07-23staging: comedi: return void from comedi_driver_unregister()Ian Abbott
'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>
2013-07-23staging: comedi: don't rely on comedidev.h to include headersH Hartley Sweeten
comedidev.h is the main kernel header for comedi. Every comedi driver includes this header which then includes a number of <linux/*> headers. All the drivers need <linux/module.h> and some of them need <linux/delay.h>. The rest are not needed by any of the drivers. Remove all the includes in comedidev.h except for <linux/dma-mapping.h>, which is needed to pick up the enum dma_data_direction for the comedi_subdevice definition, and "comedi.h", which is the uapi header for comedi. Add <linux/module.h> to all the comedi drivers and <linux/delay.h> to the couple that need it. 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>
2013-07-23staging: comedi: use comedi_alloc_devpriv()H Hartley Sweeten
Use the helper function to allocate memory and set the comedi_device private data pointer. This removes the dependency on slab.h from most of the drivers so remove the global #include in comedidev.h and the local #include in some of the 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>
2013-07-23staging: comedi: drivers: introduce comedi_alloc_devpriv()H Hartley Sweeten
Introduce a helper function to allocate memory and set the comedi_device private data pointer. 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-06-24staging: comedi: have comedi_set_spriv() allocate the memoryH Hartley Sweeten
As suggested by Ian Abbott, comedi_set_spriv() can only be used to set the subdevice->private pointer to something that can be kfree()'d. Rename the function to comedi_alloc_spriv() and have it kzalloc() the memory as well as set the private pointer. This saves a function call in the drivers and avoids the possibility of incorrectly calling comedi_set_spriv() for some pointer that is not meant to be kfree()'d. 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-06-17staging: comedi: drivers: let core handle freeing s->privateH Hartley Sweeten
Introduce a new subdevice runflags, SRF_FREE_SPRIV, and a new helper function, comedi_set_spriv(), that the drivers can use to set the comedi_subdevice private data pointer. The helper function will also set SRF_FREE_SPRIV to allow the comedi core to automatically free the subdevice private data during the cleanup_device() stage of the detach. Currently s->private is only allocated by the 8255, addi_watchdog, amplc_dio200_common, and ni_65xx drivers. All users of those drivers can then have the comedi_spriv_free() calls removed and in many cases the (*detach) can then simply be the appropriate comedi core provided function. The ni_65xx driver uses a helper function, ni_65xx_alloc_subdevice_private(), to allocate the private data. Refactor the function to return an errno or call comedi_set_spriv() instead of returning a pointer to the private data and requiring the caller to handle 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>
2013-06-06staging: comedi: introduce comedi_range_is_{bi,uni}polar()H Hartley Sweeten
Introduce some helper functions to check if a given 'range' index to a comedi_subdevice 'range_table' is a bipolar or unipolar range. 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>
2013-05-21staging: comedi: introduce comedi_to_usb_dev()H Hartley Sweeten
Introduce a helper function to get a usb_device pointer from a comedi_device pointer. 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>
2013-05-17staging: comedi: ni_pcidio: use comedi_load_firmware()H Hartley Sweeten
Use comedi_load_firmware() instead of duplicating the code in a private function. This driver loads multiple firmware images to the device. Modify comedi_load_firmware() to take a 'context' that is passed to the firmware upload callback 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>
2013-05-17staging: comedi: drivers: generalize comedi_load_firmware()H Hartley Sweeten
Move comedi_load_firmware() from jr3_pci.c to drivers.c and export it for general use by the comedi drivers. 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>
2013-05-13staging: comedi: remove FSF address from boilerplate textH Hartley Sweeten
Addresses change... Remove the paragraph with the FSF address from all the comedi source files. Also, remove the paragraph about the finding the complete GPL in the COPYING file since it's unnecessary. 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>
2013-04-19staging: comedi: drivers: introduce comedi_legacy_detach()H Hartley Sweeten
This function is intended to be used by the comedi legacy (ISA) drivers either directly as the (*detach) function or as a helper in the drivers private (*detach) function. Modify the comedi_request_region() helper so that it stores the 'len' of the region as well as the 'start' after the region has been successfuly allocated by request_region() in __comedi_request_region(). This region will then be automatically released detach of the driver by the comedi_legacy_detach() helper. 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-04-17staging: comedi: introduce, and use, comedi_spriv_free()H Hartley Sweeten
The comedi_subdevice 'private' variable is a void * that is available for the subdevice to use in manner. It's common in comedi drivers for the driver to allocate memory for a subdevice and store the pointer to that memory in the 'private' variable. It's then the responsibility of the driver to free that memory when the device is detached. Due to how the attach/detach works in comedi, the drivers need to do some sanity checking before they can free the allocated memory during the detach. Introduce a helper function, comedi_spriv_free(), to handle freeing the private data allocated for a subdevice. This allows moving all the sanity checks into the helper function and makes it safe to call with any context. It also allows removing some of the boilerplate code in the (*detach) functions. Remove the subdev_8255_cleanup() export in the 8255 subdevice driver as well as the addi_watchdog_cleanup() export in the addi_watchdog driver and use the new helper instead. The amplc_dio200_common driver uses a number of local helper functions to free the private data for it's subdevices. Remove those as well and use the new helper. 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-04-11staging: comedi: drivers: refactor comedi_request_region()H Hartley Sweeten
Split comedi_request_region() into two helper functions. __comedi_request_region() Handles the actual request_region() call. comedi_request_region() Calls __comedi_request_region() and then sets dev->iobase if the request was successful. This allows drivers to use the __comedi_request_region() helper to handle the request without setting the dev->iobase. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Cc: Ian Abbott <abbotti@mev.co.uk> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-04-11staging: comedi: drivers: introduce comedi_request_region()H Hartley Sweeten
Introduce a helper function to handle the request_region() for legacy comedi drivers. As pointed out by Ian Abbott, legacy devices are configured manually with the "comedi_config" program. The error messages are useful diagnostics when trying to attach to these boards. Providing a helper function allows consolidating the error messages in the drivers and providing a consistent format for the errors. This helper also sets the dev->iobase automatically for the driver if the request_region() is successful. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Cc: Ian Abbott <abbotti@mev.co.uk> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-04-05staging: comedi: move COMEDI_NUM_MINORS and COMEDI_FIRST_SUBDEVICE_MINORIan Abbott
The macro definitions `COMEDI_NUM_MINORS` and `COMEDI_FIRST_SUBDEVICE_MINOR` are only used in "comedi_fops.c" so move them to there from "comedidev.h". 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>
2013-04-05staging: comedi: range: introduce some simple mA rangesH Hartley Sweeten
The simple mA ranges 0 to 20, 4 to 20, and 0 to 32 are fairly common. Introduce them in the comedi core and use them in the drivers. 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>
2013-04-05staging: comedi: range: introduce range_unipolar2_5H Hartley Sweeten
Introduce a simple unipolar 0 to 2.5 range, range_unipolar2_5, for use by the comedi drivers. 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>
2013-03-15staging: comedi: add 'ioenabled' flag to deviceIan Abbott
Add 1-bit bit-field member `ioenabled` of type `bool` to `struct comedi_device`. Use this to keep track of whether a PCI device and its BARs have been successfully enabled by `comedi_pci_enable()`. This avoids overloading the meaning of the `iobase` member which is used by several drivers to hold the base port I/O address of a board's "main" registers. Other drivers using MMIO use `iobase` as a flag to indicate that the preceding call to `comedi_pci_enable()` was successful. They no longer need to do that. The name `ioenabled` is intended to be PCI-agnostic so it can be used for similar purposes by non-PCI drivers. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-15staging: comedi: make 'in_request_module' a bool bit-fieldIan Abbott
Change the `in_request_module` member of `struct comedi_device` to a 1-bit bit-field of type `bool` and move it into a suitable hole in the data type to save a few bytes. Change the assigned values to `true` and `false`. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-15staging: comedi: make 'dev->attached' a bool bit-fieldIan Abbott
Change the `attached` member of `struct comedi_device` to a 1-bit bit-field of type `bool`. Change assigned values to `true` and `false` and replace or remove comparison operations with simple boolean tests. We'll put some extra bit-fields in the gap later to save space. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-14staging: comedi_pci: pass comedi_device to comedi_pci_enable()H Hartley Sweeten
Make comedi_pci_enable() use the same parameter type as comedi_pci_disable(). This also allows comedi_pci_enable to automatically determine the resource name passed to pci_request_regions(). Make sure the errno value returned is passed on instead of assuming an errno. Also, remove any kernel noise that is generated when the call fails. The National Instruments drivers that use the mite module currently enable the PCI device in the mite module. For those drivers move the call to comedi_pci_enable into the driver. 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>
2013-03-14staging: comedi_pci: make comedi_pci_disable() safe to callH Hartley Sweeten
Currently all the comedi PCI drivers need to do some checking in their (*detach) before calling comedi_pci_disable() in order to make sure the PCI device has actually be enabled. Change the parameter passed to comedi_pci_disable() from a struct pci_dev pointer to a comedi_device pointer and have comedi_pci_disable() handle all the checking. For most comedi PCI drivers this also allows removing the local variable holding the pointer to the pci_dev. For some of the drivers comedi_pci_disable can now be used directly as the (*detach) function. The National Instruments drivers that use the mite module currently enable/disable the PCI device in the mite module. For those drivers move the call to comedi_pci_disable into the driver and make sure dev->iobase is set to a non-zero value. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Cc: Ian Abbott <abbotti@mev.co.uk> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-11staging: comedi: comedi_pci: change the comedi_pci_auto_config() 'context'H Hartley Sweeten
The comedi_pci_auto_config() function is used to allow the PCI driver (*probe) function to automatically call the comedi driver (*auto_attach). This allows the comedi driver to be part of the PnP process when the PCI device is detected. Currently the comedi_pci_auto_config() always passes a 'context' of '0' to comedi_auto_config(). This makes the 'context' a bit useless. Modify comedi_pci_auto_config() to allow the comedi pci drivers to pass a 'context' from the PCI driver. Make all the comedi pci drivers pass the pci_device_id 'driver_data' as the 'context'. Since none of the comedi pci drivers currently set the 'driver_data' the 'context' will still be '0'. 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>
2013-02-05staging: comedi: comedi_pcmcia: allow drivers to use a custom conf_check()H Hartley Sweeten
Allow comedi pcmcia drivers to use a custom conf_check() when calling comedi_pcmcia_enable() to enable the pcmcia device. If a conf_check() is not passed the internal comedi_pcmcia_conf_check() will be used. 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>
2013-02-05staging: comedi: comedi_usb: allow comedi usb drivers to pass a 'context'H Hartley Sweeten
Allow the comedi usb drivers to pass a 'context' from their (*probe) functions to the comedi core's comedi_usb_auto_config(). This 'context' is then passed to comedi_auto_config() and then to the comedi_driver's (*auto_attach). 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>
2013-02-04staging: comedi: comedi_pcmcia: introduce comedi_pcmcia_{enable, disable}H Hartley Sweeten
Introduce some helper functions to enable/disable the PCMCIA device. This will allow removing some of the boilerplate code in the comedi PCMCIA drivers. 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>
2013-02-03pci_ids.h: add common pci vendor ids from comedi subsystemH Hartley Sweeten
There are a number of pci vendor ids that are used in multiple drivers in the comedi subsystem. Move these ids to pci_ids.h. This also fixes some build warnings reported by the kbuild test robot about PCI_VENDOR_ID_AMPLICON being undeclared. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-02-03staging: comedi: export comedi_set_hw_dev()Ian Abbott
Chnage the inline `comedi_set_hw_dev()` to an exported function and change it's return type from `void` to `int` so we can impose some restrictions (in a later patch) and return an error if necessary. Only a few comedi drivers call this, although they don't need to if the hardware device has been attached automatically via `comedi_auto_config()` and the comedi driver's `auto_attach()` method. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-02-03staging: comedi: move comedi_alloc_subdevice_minor declarationsIan Abbott
Move the declarations of `comedi_alloc_subdevice_minor()` and `comedi_free_subdevice_minor()` from "comedidev.h" to "comedi_internal.h" since they are only of interest to the comedi core, and are not exported to the low-level comedi drivers. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-01-31staging: comedi: don't expose comedi_proc_{init,cleanup}H Hartley Sweeten
These functions are only used by the comedi core. Move the prototypes to comedi_internal.h so they are not exposed to the comedi drivers. 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>
2013-01-31staging: comedi: don't expose comedi_device_{attach,detach}H Hartley Sweeten
These functions are only used by the comedi core. Move the prototypes to comedi_internal.h so they are not exposed to the comedi drivers. Tidy up comedi_internal.h a bit so that all the internal stuff in drivers.c is grouped. 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>
2013-01-31staging: comedi: tidy up the general purpose driver functionsH Hartley Sweeten
Group all the general comedi driver register/config/attach prototypes into one place in comedidev.h. Reorder the functions in drivers.c a bit so they are in a more logical usage order (bottom to top). 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>
2013-01-31staging: comedi: allow pcmcia drivers to auto attachH Hartley Sweeten
Introduce some helper functions to allow converting the comedi pcmcia drivers to the comedi auto_attach mechanism. 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>
2013-01-31staging: comedi: conditionally build in PCMCIA driver supportH Hartley Sweeten
Separate the comedi_pcmcia_* functions out of drivers.c into a new source file, comedi_pcmcia.c. This allows conditionally building support for comedi pcmcia drivers into the comedi core without the need for the #if'defery. Fix the Kconfig and Makefile appropriately. Group all the comedi_pcmcia_* prototypes into one place in comedidev.h. Protect these prototypes with an #ifdef so that building a comedi pcmcia driver without PCMCIA support will cause a build error. This will normally not happen as long as the comedi pcmcia driver is placed in the proper group in the Kconfig. Remove the #include <pcmcia/*.h> from drivers.c. These includes are only needed by the comedi pcmcia driver support code and the pcmcia drivers. The include should occur in those files. 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>
2013-01-31staging: comedi: conditionally build in PCI driver supportH Hartley Sweeten
Separate the comedi_pci_* functions out of drivers.c into a new source file, comedi_pci.c. This allows conditionally building support for comedi PCI drivers into the comedi core. Fix the Kconfig and Makefile appropriately. Group all the comedi_pci_* prototypes and related defines into one place in comedidev.h. Protect these prototypes with an #ifdef and provide some dummy functions so that the mixed ISA/PCI comedi drivers will still build correctly. Remove the #include <linux/pci.h> from comedidev.h and drivers.c. This include is only needed by the comedi PCI driver support code and the PCI drivers. The include should occur in those files. Also, remove the #include <linux/pci.h> from a couple non-PCI drivers since it's not needed. 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>
2013-01-31staging: comedi: conditionally build in USB driver supportH Hartley Sweeten
Separate the comedi_usb_* functions out of drivers.c into a new source file, comedi_usb.c. This allows conditionally building support for comedi USB drivers into the comedi core without the need for the #if'defery. Fix the Kconfig and Makefile appropriately. For aesthetic reasons, add some whitespace to the Makefile to keep everything lined up. Group all the comedi_usb_* prototypes into one place in comedidev.h. Protect these prototypes with an #ifdef so that building a comedi usb driver without USB support will cause a build error. This will normally not happen as long as the comedi USB driver is placed in the proper group in the Kconfig. Remove the #include<linux/usb.h> from comedidev.h and drivers.c. This include is only needed by the comedi USB driver support code and the USB drivers. The include should occur in those files. Removing the include of usb.h exposed a couple drivers that need <linux/interrupt.h> and <linux/sched.h>. Add the missing includes. 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>
2013-01-29staging: comedi: simplify comedi_set_hw_dev()Ian Abbott
Since `get_device()` and `put_device()` can take a NULL device parameter, `comedi_set_hw_dev()` can be simplified to always call `get_device()` for the new, possibly NULL hardware device, and `put_device()` for the old, possibly NULL hardware device. As long as we do it in that order, there shouldn't be any problem with `kref_release()` getting called unexpectedly when the new hardware device is the old hardware device. Simplify `comedi_set_hw_dev()` and update the comment because the function is used for additional purposes since the old comment was written. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-01-25staging/comedi: Move comedi_pci_auto_unconfig to drivers.cPeter Huewe
Since comedi_pci_auto_unconfig cannot be inlined anymore after staging/comedi: Use comedi_pci_auto_unconfig directly for pci_driver.remove is applied, it makes sense to move it drivers.c Signed-off-by: Peter Huewe <peterhuewe@gmx.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-01-17staging/comedi: Add macro for registering a comedi PCMCIA driverPeter Huewe
This patch introduces a new macro 'module_comedi_pcmcia_driver' for comedi PCMCIA drivers which do not do anything special in module init/exit. This eliminates a lot of boilerplate. Adapted from 'module_comedi_pci_driver' Signed-off-by: Peter Huewe <peterhuewe@gmx.de> Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-01-17staging: comedi: comedi_buf: reorder exported function prototypesH Hartley Sweeten
For aesthetic reasons, reorder the prototypes for the exported comedi_buf_* functions in comedidev.h to follow the function declarations in comedi_buf.c. Also, change a couple of the return values from 'unsigned' to 'unsigned int' to match the value actually returned. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-01-17staging: comedi: comedi_buf: don't expose comedi_buf_write_n_allocated()H Hartley Sweeten
This helper function is only called by the comedi core in comedi_buf.c and comedi_fops.c. For aesthetic reasons, move it to comedi_buf.c and remove the inline. Move the prototype from comedidev.h to comedi_internal.h so it's not exposed outside the comedi core. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-01-17staging: comedi: comedi_buf: don't expose comedi_buf_read_n_allocated()H Hartley Sweeten
This helper function is only called in comedi_buf.c. Move it there and make it static so it's not exposed globally. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-01-17staging: comedi: comedi_buf: remove comedi_buf_write_alloc_strictH Hartley Sweeten
This function is only called by comedi_buf_put(). Remove it and just call __comedi_buf_write_alloc() directly with the strict flag set. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-01-17staging: comedi: comedi_buf: factor out common comedi_buf_write_alloc_* codeH Hartley Sweeten
The only difference between comedi_buf_write_alloc() and the *_strict() version is that the *_strict() one will only allocate the chunk if it can completely fulfill the request. Factor out the common code and add a flag parameter to indicate the 'strict' usage. Change the exported functions so they are just wrappers around the common function. Cleanup the common function a bit and use the comedi_buf_write_n_available() helper to determine the number of bytes available. comedi_buf_write_n_available() is not used outside this module so make it static. Since the only caller is __comedi_buf_write_alloc(), which will always have a valid async pointer and already has a memory barrier, we can remove the unnecessary (async == NULL) test as well as the smp_mb(). Also, the rounding of the sample size can be removed since the caller does not need it. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>