From: Frank Mori Hess Date: Sat, 28 May 2005 18:32:35 +0000 (+0000) Subject: add USB_CONTROL_MSG and USB_BULK_MSG compatibility functions due X-Git-Tag: branch-0_7-end~59 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=660d34fb0632ecbb829036443ad72b576cbf47d8;p=comedi.git add USB_CONTROL_MSG and USB_BULK_MSG compatibility functions due to change in meaning of timeout argument with kernel 2.6.12 --- diff --git a/comedi/drivers/usbdux.c b/comedi/drivers/usbdux.c index 3a62c41b..b153a875 100644 --- a/comedi/drivers/usbdux.c +++ b/comedi/drivers/usbdux.c @@ -97,7 +97,7 @@ sampling rate. If you sample two channels you get 4kHz and so on. #define BOARDNAME "usbdux" // timeout for the USB-transfer -#define EZTIMEOUT 3 +#define EZTIMEOUT 30 // constants for "firmware" upload and download #define USBDUXSUB_FIRMWARE 0xA0 @@ -829,7 +829,7 @@ static int usbduxsub_start(usbduxsub_t* usbduxsub) { if (usbduxsub->probed) { // 7f92 to zero local_transfer_buffer[0]=0; - errcode=usb_control_msg + errcode=USB_CONTROL_MSG (usbduxsub->usbdev, // create a pipe for a control transfer usb_sndctrlpipe(usbduxsub->usbdev,0), @@ -866,7 +866,7 @@ static int usbduxsub_stop(usbduxsub_t* usbduxsub) { if (usbduxsub->probed) { // 7f92 to one local_transfer_buffer[0]=1; - errcode=usb_control_msg + errcode=USB_CONTROL_MSG (usbduxsub->usbdev, usb_sndctrlpipe(usbduxsub->usbdev,0), // bRequest, "Firmware" @@ -909,7 +909,7 @@ static int usbduxsub_upload(usbduxsub_t* usbduxsub, startAddr, local_transfer_buffer[0]); #endif - errcode=usb_control_msg + errcode=USB_CONTROL_MSG (usbduxsub->usbdev, usb_sndctrlpipe(usbduxsub->usbdev, 0), // brequest, firmware @@ -1196,7 +1196,7 @@ static int send_dux_commands(usbduxsub_t* this_usbduxsub,int cmd_type) { } printk("\n"); #endif - result = usb_bulk_msg(this_usbduxsub->usbdev, + result = USB_BULK_MSG(this_usbduxsub->usbdev, usb_sndbulkpipe(this_usbduxsub->usbdev, COMMAND_OUT_EP), this_usbduxsub->dux_commands, @@ -1221,7 +1221,7 @@ static int receive_dux_commands(usbduxsub_t* this_usbduxsub,int command) { int i; for(i=0;iusbdev, + result = USB_BULK_MSG(this_usbduxsub->usbdev, usb_rcvbulkpipe(this_usbduxsub->usbdev, COMMAND_IN_EP), this_usbduxsub->insnBuffer, diff --git a/comedi/drivers/usbduxfast.c b/comedi/drivers/usbduxfast.c index d44aa773..c2b83058 100644 --- a/comedi/drivers/usbduxfast.c +++ b/comedi/drivers/usbduxfast.c @@ -66,7 +66,7 @@ Status: testing #define BOARDNAME "usbduxfast" // timeout for the USB-transfer -#define EZTIMEOUT 3 +#define EZTIMEOUT 30 // constants for "firmware" upload and download #define USBDUXFASTSUB_FIRMWARE 0xA0 @@ -208,13 +208,13 @@ static int send_dux_commands(usbduxfastsub_t* this_usbduxfastsub,int cmd_type) { } printk("\n"); #endif - result = usb_bulk_msg(this_usbduxfastsub->usbdev, + result = USB_BULK_MSG(this_usbduxfastsub->usbdev, usb_sndbulkpipe(this_usbduxfastsub->usbdev, CHANNELLISTEP), this_usbduxfastsub->dux_commands, SIZEOFDUXBUFFER, &nsent, - 10*HZ); + 10000); if (result<0) { printk("comedi%d: could not transmit dux_commands to the usb-device, err=%d\n", this_usbduxfastsub->comedidev->minor,result); @@ -466,7 +466,7 @@ static int usbduxfastsub_start(usbduxfastsub_t* usbduxfastsub) { if (usbduxfastsub->probed) { // 7f92 to zero local_transfer_buffer[0]=0; - errcode=usb_control_msg + errcode=USB_CONTROL_MSG (usbduxfastsub->usbdev, // create a pipe for a control transfer usb_sndctrlpipe(usbduxfastsub->usbdev,0), @@ -503,7 +503,7 @@ static int usbduxfastsub_stop(usbduxfastsub_t* usbduxfastsub) { if (usbduxfastsub->probed) { // 7f92 to one local_transfer_buffer[0]=1; - errcode=usb_control_msg + errcode=USB_CONTROL_MSG (usbduxfastsub->usbdev, usb_sndctrlpipe(usbduxfastsub->usbdev,0), // bRequest, "Firmware" @@ -546,7 +546,7 @@ static int usbduxfastsub_upload(usbduxfastsub_t* usbduxfastsub, startAddr, local_transfer_buffer[0]); #endif - errcode=usb_control_msg + errcode=USB_CONTROL_MSG (usbduxfastsub->usbdev, usb_sndctrlpipe(usbduxfastsub->usbdev, 0), // brequest, firmware @@ -1267,12 +1267,12 @@ static int usbduxfast_ai_insn_read(comedi_device * dev, (int)(usbduxfastsub->urbIn->dev)); #endif for(i=0;iusbdev, + err=USB_BULK_MSG(usbduxfastsub->usbdev, usb_rcvbulkpipe(usbduxfastsub->usbdev,BULKINEP), usbduxfastsub->transfer_buffer, SIZEINBUF, &actual_length, - 10*HZ); + 10000); if (err<0) { printk("comedi%d: insn timeout. No data.\n", dev->minor); @@ -1282,12 +1282,12 @@ static int usbduxfast_ai_insn_read(comedi_device * dev, } // data points for(i=0;in;) { - err=usb_bulk_msg(usbduxfastsub->usbdev, + err=USB_BULK_MSG(usbduxfastsub->usbdev, usb_rcvbulkpipe(usbduxfastsub->usbdev,BULKINEP), usbduxfastsub->transfer_buffer, SIZEINBUF, &actual_length, - 10*HZ); + 10000); if (err<0) { printk("comedi%d: insn data error: %d\n", dev->minor,err); diff --git a/include/linux/usb.h b/include/linux/usb.h index 331c2b25..18f65756 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -24,6 +24,7 @@ #define __COMPAT_LINUX_USB_H_ #include +#include #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) #define USB_ALLOC_URB(x) usb_alloc_urb(x) @@ -39,5 +40,24 @@ #include_next +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,12) +static inline int USB_CONTROL_MSG(struct usb_device *dev, unsigned int pipe, + __u8 request, __u8 requesttype, __u16 value, __u16 index, + void *data, __u16 size, int millisec_timeout) +{ + return usb_control_msg(dev, pipe, request, requesttype, value, index, + data, size, msecs_to_jiffies(millisec_timeout)); +} +static inline int USB_BULK_MSG(struct usb_device *usb_dev, unsigned int pipe, + void *data, int len, int *actual_length, + int millisec_timeout) +{ + return usb_bulk_msg(usb_dev, pipe, data, len, actual_length, msecs_to_jiffies(millisec_timeout)); +} +#else +#define USB_CONTROL_MSG usb_control_msg +#define USB_BULK_MSG usb_bulk_msg +#endif + #endif