add USB_CONTROL_MSG and USB_BULK_MSG compatibility functions due
authorFrank Mori Hess <fmhess@speakeasy.net>
Sat, 28 May 2005 18:32:35 +0000 (18:32 +0000)
committerFrank Mori Hess <fmhess@speakeasy.net>
Sat, 28 May 2005 18:32:35 +0000 (18:32 +0000)
to change in meaning of timeout argument with kernel 2.6.12

comedi/drivers/usbdux.c
comedi/drivers/usbduxfast.c
include/linux/usb.h

index 3a62c41bc334520ebf613e8d736bb58b061d57a2..b153a875558530d6d4d3f333dab07b453b8609f4 100644 (file)
@@ -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;i<RETRIES;i++) {
-               result = usb_bulk_msg(this_usbduxsub->usbdev,
+               result = USB_BULK_MSG(this_usbduxsub->usbdev,
                                      usb_rcvbulkpipe(this_usbduxsub->usbdev,
                                                      COMMAND_IN_EP),
                                      this_usbduxsub->insnBuffer,
index d44aa773e38d6c345e312a5780701771d42ae525..c2b83058bde1e61098934d1f33cee1987dd91bab 100644 (file)
@@ -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;i<PACKETS_TO_IGNORE;i++) {
-               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 timeout. No data.\n",
                               dev->minor);
@@ -1282,12 +1282,12 @@ static int usbduxfast_ai_insn_read(comedi_device * dev,
        }
        // data points
        for(i=0;i<insn->n;) {
-               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);
index 331c2b25309ae9b99257ac8ee49135dd9c55c02e..18f6575652afeeb1229dcc1fc4dccb3c65925a85 100644 (file)
@@ -24,6 +24,7 @@
 #define __COMPAT_LINUX_USB_H_
 
 #include <linux/version.h>
+#include <linux/time.h>
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
 #define USB_ALLOC_URB(x) usb_alloc_urb(x)
 
 #include_next <linux/usb.h>
 
+#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