summaryrefslogtreecommitdiff
path: root/drivers/staging/comedi/drivers/vmk80xx.c
AgeCommit message (Collapse)Author
2013-02-18staging: comedi: vmk80xx: wait for URBs to completeIan Abbott
For Velleman K8055 (aka VM110), `vmk80xx_read_packet()` and `vmk8055_write_packet()` send an URB asynchronously and do not wait for it complete. However, callers of `vmk80xx_read_packet()` are assuming the contents of the data buffer `devpriv->usb_rx_buf` are valid immediately after that function returns. For Velleman K8061 (aka VM140), `vmk80xx_read_packet()` and `vmk80xx_write_packet()` punt the requests to `vmk80xx_do_bulk_msg()` which *does* wait for the URBs to complete (albeit with no error checking!). Change `vmk80xx_read_packet()` and `vmk80xx_write_packet()` to use `usb_interrupt_msg()` for the K8055, so the callers of `vmk80xx_read_packet()` can assume the data buffer contents are valid (if no error occurred). Remove all the code for checking for transfers in progress and busy waiting, as it's no longer needed. Pretty much all the callers of `vmk80xx_read_packet()` and `vmk80xx_write_packet()` hold the same semaphore anyway, and the only caller that doesn't (`vmk80xx_reset_device()` called during initialization of the device) doesn't really matter. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-02-15staging: comedi: vmk80xx: initialize K8055 outputs to known stateIan Abbott
vmk8055_reset_device() is called during initialization of a Velleman K8055 (aka VM110) to send a reset command to the hardware. I don't know what this does, but I know that it doesn't reset the digital outputs as I've tried it. Since the hardware does not have any way to query the current output values and there is only the one command to update all the analog and digital outputs simultaneously (VMK8055_CMD_WRT_AD), send this command during initialization to set all the analog and digital outputs to a known state. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-02-15staging: comedi: vmk80xx: simplify vmk80xx_reset_device()Ian Abbott
vmk80xx_reset_device() is called during initialization of a Velleman K8055 (aka VM110) to send a reset command to the hardware. The current function is a bit long-winded and doesn't set the TRANS_OUT_BUSY flag to prevent re-use of the transmit buffer while the URB is in progress. Rewrite the function to use vmk80xx_write_packet() to send the command. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-02-15staging: comedi: vmk80xx: zero buffers on allocationIan Abbott
Zero out `devpriv->usb_tx_buf` and `devpriv->usb_rx_buf` on allocation. When sending data to the USB device, this ensures any unused part of the buffer will not contain random crap. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-02-13staging/comedi: Fix undefined array subscriptPeter Huewe
In vmk80xx_do_insn_bits the local variable reg, which is used as an index to the tx_buf array, can be used uninitialized if - data[0] == 0 and - devpriv->model != VMK8061_MODEL -> we get into the else branch without having reg initialized. Since the driver usually differentiates between VMK8061_MODEL and VMK8055_MODEL it's safe to assume that VMK8055_DO_REG was meant as an initial value. And to avoid duplication we can move the assignments to the top. Acked-by: Ian Abbott <abbotti@mev.co.uk> Acked-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Peter Huewe <peterhuewe@gmx.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-02-05staging: comedi: vmk80xx: rename vmk80xx_attach_common()H Hartley Sweeten
In comedi drivers typically *_attach_common() is used as the 'common' part of the comedi_driver attach code for drivers that support various bus types (ISA, PCI, etc.). This driver is specific to a USB device. To avoid confusion when grepping, rename this function to something more appropriate. 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: vmk80xx: remove the 'Changelog' commentsH Hartley Sweeten
git history provides a better Changelog for 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-02-05staging: comedi: vmk80xx: cleanup the comedi_lrange tablesH Hartley Sweeten
The vmk8055_range table is a duplicate of the comedi core provided range_unipolar5 table. Use that instead. For aesthetic reasons, clean up the formating of the vmk8061_range table. 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: vmk80xx: remove CONFIG_COMEDI_DEBUG codeH Hartley Sweeten
If CONFIG_COMEDI_DEBUG is defined a macro is enabled to output some printk(KERN_REBUG ...) messages. These are just added noise. Remove 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-02-05staging: comedi: vmk80xx: remove unused #defineH Hartley Sweeten
This define is no longer used by the driver. Remove 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-02-05staging: comedi: vmk80xx: remove digital input (*insn_read)H Hartley Sweeten
The comedi core can use the (*insn_bits) function to emulate the (*insn_read) function. Remove the unnecessary (*insn_read) 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-02-05staging: comedi: vmk80xx: remove digital output (*insn_write)H Hartley Sweeten
The comedi core can use the (*insn_bits) function to emulate the (*insn_write) function. Remove the unnecessary (*insn_read) 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-02-05staging: comedi: vmk80xx: remove digital output (*insn_read)H Hartley Sweeten
The comedi core can use the (*insn_bits) function to emulate the (*insn_read) function. The digital output (*insn_bits) function properly handles the VMK8061_MODEL to read the digital output states before returning. Remove the unnecessary (*insn_read) function. It's also not necessary to set the SDF_READABLE flag so remove the entire conditional in the 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-05staging: comedi: vmk80xx: cleanup pwm subdevice initH Hartley Sweeten
Change the 'pwm_bits' in the boardinfo to 'pwm_maxdata' so that the calculation of s->maxdata can be removed. Also, change the type to match the comedi_subdevice type. For aesthetic reasons, rename the 'pwm_chans' boardinfo and change its type also. Remove the '0' values in the boardinfo. Rename the (*insn_read) and (*insn_write) functions for the pwm subdevice to make grepping easier. For aesthetic reasons, add some whitespace to the subdevice init. 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: vmk80xx: cleanup counter subdevice initH Hartley Sweeten
Change the 'cnt_bits' in the boardinfo to 'cnt_maxdata' so that the calculation of s->maxdata can be removed. Also, change the type to match the comedi_subdevice type. Add a comment about the '0' value for DEVICE_VMK8061. The s->maxdata should always be set for the subdevice. Move it out of the conditional. Rename the (*insn_read), (*insn_config_, and (*insn_write) functions for the counter subdevice to make grepping easier. For aesthetic reasons, add some whitespace to the subdevice init. 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: vmk80xx: cleanup digital input subdevice initH Hartley Sweeten
Remove the SDF_GROUND flag from s->subdev_flags. This flag only has meaning for analog subdevices. Add the missing s->range_table for the subdevice. Rename the (*insn_write), (*insn_bits), and (*insn_read) functions for the digital input subdevice to make grepping easier. For aesthetic reasons, add some whitespace to the subdevice init. 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: vmk80xx: cleanup digital input subdevice initH Hartley Sweeten
Change the type for the digital input 'di_chans' boardinfo to match the comedi_subdevice type it is set to. For aesthetic reasons, rename the variable also. Remove the SDF_GROUND flag from s->subdev_flags. This flag only has meaning for analog subdevices. Add the missing s->range_table for the subdevice. Rename the (*insn_read) and (*insn_bits) functions for the digital input subdevice to make grepping easier. For aesthetic reasons, add some whitespace to the subdevice init. 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: vmk80xx: cleanup analog output subdevice initH Hartley Sweeten
Change the type for the analog output 'ao_chans' boardinfo to match the comedi_subdevice type it is set to. For aesthetic reasons, rename the variable also. Rename the (*insn_write) and (*insn_read) functions for the analog output subdevice to make grepping easier. For aesthetic reasons, add some whitespace to the subdevice init. 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: vmk80xx: cleanup analog input subdevice initH Hartley Sweeten
Change the 'ai_bits' in the boardinfo to 'ai_maxdata' so that the calculation of s->maxdata can be removed. Change the types for the analog input boardinfo to match the comedi_subdevice types they are set to. Rename the (*insn_read) function for the analog input subdevice from vmk80xx_ai_rinsn to vmk80xx_ai_insn_read to make grepping easier. For aesthetic reasons, add some whitespace to the subdevice init. 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: vmk80xx: remove need for boardinfo in private_dataH Hartley Sweeten
The only information in the boardinfo that is used outside of the attach of the driver is the 'model' of the device. Remove the 'board' pointer from the private data and replace it with the 'model' enum and just copy that information over during the 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-05staging: comedi: vmk80xx: push usb (*probe) into comedi (*auto_attach)H Hartley Sweeten
Make the usb_driver (*probe) simply call comedi_usb_auto_config() and move all the (*probe) code into the (*auto_attach) function. This allows getting rid of the static private data array since we no longer do part of the initialization in the (*probe) and then finish it in the (*auto_attach). We can simply kzalloc the private data instead. The comedi core will then handle the kfree of the data when the driver is detached. We can also get rid of the static 'glb_mutex' since this mutex was only used to protect the static private data array. Change the parameters for a couple of the helper functions used during the auto attach. Now that the comedi_device is available we can simply pass that pointer and get the specific pointers needed by the helper functions from 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-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-05staging: comedi: vmk80xx: remove private data 'attached'H Hartley Sweeten
The 'attached' flag in the private data is set after the comedi_driver (*auto_attach) function has completed successfully. The only places it's checked are in rudimentary_check(), which does some basic sanity checks before doing any of the subdevice operations, and vmk80xx_auto_attach(), which is the comedi_driver (*auto_attach) function. The (*auto_attach) function can only be called as the result of a successfull usb_driver (*probe). Part of the probe is to locate a free slot in the static private data array. All free slots are initialized to '0' so the 'attached' flag will always be cleared. Remove the unneccessary 'attached' flag in the private data. 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: vmk80xx: remove private data 'probed'H Hartley Sweeten
The 'probed' variable is used in the usb driver (*probe) to detect an unused element in the static private data arry. This variable is then set after the usb driver has completed its (*probe) before calling comedi_usb_auto_config(). When the comedi core does the auto config it will call the (*auto_attach) function, vmk80xx_auto_attach(), which then locates the correct private data in the static array by checking to see if it has been 'probed' and that the 'intf' variable matches the usb_interface pointer for the usb device. Now that the private data is clean after failed usb probes and disconnects we don't have to worry about have a garbage 'intf' value in the private data that might match. Remove the 'probed' flag from the private data and just use the 'intf' pointer to detect the match. 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: vmk80xx: make sure private data is clean when detachedH Hartley Sweeten
Currently the private data used in this driver is stored in a static array. During the usb (*probe) and empty location is found in this array for use by the usb device. Some initialization of the private data is then done before comedi_usb_auto_config() is called to allow the comedi core to attach its comedi_device to the usb device. The (*probe) can fail for various reasons. If it does, make sure that the private data is clean before returning an error. The usb (*disconnect) simply calls comedi_usb_auto_unconfig() to allow the comedi core to disconnect its comedi_device from the usb device. Since the private data points to the static array it cannot be kfree'ed during the detach. Instead make sure it clean before leaving the detach. 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: vmk80xx: remove private data 'count'H Hartley Sweeten
The 'count' in the private data is only used in a couple dev_info() kernel messages. These messages are just added noise. Remove the 'count' variable in the private data as well as the dev_info() messages. 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: vmk80xx: factor out usb buffer allocationH Hartley Sweeten
Factor the code that allocates the usb buffers out of vmk80xx_usb_probe(). 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: vmk80xx: factor out usb endpoint detectionH Hartley Sweeten
Factor the code that detects the usb endpoints out of vmk80xx_usb_probe(). Cleanup the detection code in the new 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-02-05staging: comedi: vmk80xx: consistently use the same local var namesH Hartley Sweeten
Rename some of the local variables used in this driver to make the code easier to maintain and understand. s/udev/usb the usb_device that the comedi_driver is attached to s/dev/devpriv the private data of the comedi_device s/cdev/dev the comedi_device Also, use some local variables in a couple of the functions to tidy up the code a bit. 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: vmk80xx: rename struct vmk80xx_usbH Hartley Sweeten
The struct vmk80xx_usb is actually the private data for the comedi_device. For aesthetic reasons, rename the struct to vmk80xx_private. 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: vmk80xx: remove VMK80XX_SUBD_* enumH Hartley Sweeten
These enum values are only used in the initialization of the comedi_subdevices. They don't help make the code any clearer so just remove them. 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: vmk80xx: remove common and unused boardinfoH Hartley Sweeten
Some of the information in the boardinfo is common for both boards supported by this driver. Remove that information from the boardinfo and just initialize the subdevice values directly. Also, remove any information in the boardinfo that is not used in 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-02-05staging: comedi: vmk80xx: save the boardinfo in the comedi_deviceH Hartley Sweeten
Save a copy of the boardinfo pointer in the comedi_device 'board_ptr'. The subdevice functions can then simply get it using the comedi_board() helper. 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: vmk80xx: move boardinfo into a const arrayH Hartley Sweeten
The normal way of presenting the board specific information in comedi drivers is store the data in a static const array. This data is then accessed using a pointer, normally the comedi_device 'board_ptr', Move the boardinfo for the two boards supported by this driver from the vmk80xx_usb_probe() function into a static const array. Change the access of this information so a pointer is 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: vmk80xx: use comedi_auto_unconfig() for (*disconnect)H Hartley Sweeten
The usb_driver (*disconnect) in this driver is simply a wrapper around comedi_auto_unconfig(). Just use comedi_auto_unconfig() directly for the (*disconnect). 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: vmk80xx: move usb_driver (*disconnect) codeH Hartley Sweeten
The usb_driver (*disconnect) in this driver calls the comedi core comedi_usb_auto_unconfig() which calls the comedi_driver (*detach). Move the code in the (*disconnect) to the (*detach) to get all the disconnect/detach in one place. 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: vmk80xx: remove support for manual attachingH Hartley Sweeten
This comedi USB driver supports attaching with the auto config mechanism. Remove the manual attaching support using the COMEDI_DEVCONFIG ioctl. 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>
2012-10-29staging: comedi: vmk80xx: use auto_attach() hookIan Abbott
Use the new `auto_attach()` hook in the `struct comedi_driver` instead of the old `attach_usb()` hook. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-10-24staging/comedi: Use dev_ printks in drivers/vmk80xx.cYAMANE Toshiaki
fixed below checkpatch warning. - Prefer netdev_info(netdev, ... then dev_info(dev, ... then pr_info(... to printk(KERN_INFO ... Signed-off-by: YAMANE Toshiaki <yamanetoshi@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-09-06staging: comedi: vmk80xx: fix compiler warningGreg Kroah-Hartman
gcc complains about some potentially uninitalized variables here, yet it can not happen, due to an enumerated type (either the board is one type or the other.) Make the compiler happy by providing a default case option that makes the logic a bit simpler for it to determine that there really isn't a problem here. Cc: H Hartley Sweeten <hartleys@visionengravers.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-09-05staging: comedi: vmk80xx: remove subdevice pointer mathH Hartley Sweeten
Convert the comedi_subdevice access from pointer math to array access. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-06-20staging: comedi: vmk80xx: refactor init codeH Hartley Sweeten
Refactor the usb driver probe/disconnect and comedi driver attach/ detach to follow the style of the other comedi driver types to improve maintainability. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Cc: Ian Abbott <abbotti@mev.co.uk> Cc: Frank Mori Hess <fmhess@users.sourceforge.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-06-20staging: comedi: vmk80xx: use module_comedi_usb_driver()H Hartley Sweeten
Use the module_comedi_usb_driver helper macro to initialize this module. Rename the driver structs to follow the pattern of the other comedi driver types and add some whitespace to improve readability. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Cc: Ian Abbott <abbotti@mev.co.uk> Cc: Frank Mori Hess <fmhess@users.sourceforge.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-06-18staging: comedi: vmk80xx: use attach_usb() hookIan Abbott
Change the vmv80xx driver to use the new attach_usb() hook in struct comedi_driver to auto-configure probed USB devices after the firmware is loaded. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-06-12staging: comedi: propogate error code from comedi_alloc_subdevicesH Hartley Sweeten
comedi_alloc_subdevices can fail with -EINVAL or -ENOMEM. When it does fail make sure to pass the proper error code back. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Cc: Ian Abbott <abbott@mev.co.uk> Cc: Frank Mori Hess <fmhess@users.sourceforge.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-06-12staging: comedi: export alloc_subdevices as comedi_alloc_subdevicesH Hartley Sweeten
Move the inline alloc_subdevices() function from comedidev.h to drivers.c and rename it to comedi_alloc_subdevices(). The function is large enough to warrant being an exported symbol rather than being an inline in every driver. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Cc: Ian Abbott <abbotti@mev.co.uk> Cc: Frank Mori Hess <fmhess@users.sourceforge.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-05-18staging: comedi: cleanup all the comedi_driver 'detach' functionsH Hartley Sweeten
1. Change the return type from int to void All the detach functions, except for the comedi usb drivers, simply return success (0). Plus, the return code is never checked in the comedi core. The comedi usb drivers do return error codes but the conditions can never happen. The first check is: if (!dev) return -EFAULT; This checks that the passed comedi_device pointer is valid. The detach function itself is called using this pointer so it MUST always be valid or there is a bug in the core: if (dev->driver) dev->driver->detach(dev); And the second check: usb = dev->private; if (!usb) return -EFAULT; The dev->private pointer is setup in the attach function to point to the probed usb device. This value could be NULL if the attach fails. But, since the comedi core is going to unload the driver anyway and does not check for errors there is no gain by returning one. After removing these checks from the comedi usb drivers the detach functions required a bit of cleanup. 2. Remove all the printk noise in the detach functions All of the printk output is really just noise. The user did a rmmod to unload the driver, we really don't need to tell them about it. Also, some of the messages are output using: dev_dbg(dev->hw_dev, ... or dev_info(dev->hw_dev, ... Unfortunately the hw_dev value is only used by drivers that are doing DMA. For most drivers this variable is going to be NULL so the output is not going to work as expected. 3. Refactor a couple static 'free_resource' functions into the detach functions. The 'free_resource' function is only being called by the detach and it makes more sense to just absorb the code. 4. Remove a couple unnecessary braces for single statements. 5. Remove unnecessary comments. Most of the comedi drivers appear to be based on the comedi skel driver and have the comments from that driver included. These comments make sense in the skel driver for reference but they don't need to be in any of the actual drivers. 6. Remove all the extra whitespace. It's not needed to make the functions any more readable. 7. Remove the now unused 'attached_successfully' variable in the cb_pcimdda driver. This variable was only used to conditionally output some driver noise during the detach. Since all the printk's have been removed this variable is no longer necessary. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Cc: Ian Abbott <abbotti@mev.co.uk> Cc: Mori Hess <fmhess@users.sourceforge.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-05-09staging: comedi: remove debug tracing in vmk80xx driverH Hartley Sweeten
The vmk80xx driver uses a non-existant Kconfig symbol to enable function call debug tracing. This output is really just noise and doesn't serve any useful purpose. Remove all it's uses in the driver. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Cc: Ian Abbott <abbotti@mev.co.uk> Cc: Mori Hess <fmhess@users.sourceforge.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-04-23staging: comedi: vmk80xx.c: remove err() usageGreg Kroah-Hartman
err() was a very old USB-specific macro that I thought had gone away. This patch removes it from being used in the driver and uses dev_err() instead. CC: Ian Abbott <abbotti@mev.co.uk> CC: Mori Hess <fmhess@users.sourceforge.net> CC: "J. Ali Harlow" <ali@avrc.city.ac.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-04-20staging: comedi vmk80xx: lock held on error pathDan Carpenter
If the user passes an invalid command, then we don't drop the lock before returning. The check for invalid commands doesn't need to be done under lock so I moved it forward a couple lines. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>