[LWN Logo]
[LWN.net]
From:	 Greg KH <greg@kroah.com>
To:	 linux-usb-devel@lists.sourceforge.net
Subject: [linux-usb-devel] Round 2: Differences between the two kernel trees
Date:	 Tue, 9 Oct 2001 10:03:57 -0700

Hi all,

Ok, In trying to resolve all of the USB differences between the -ac and
Linus trees, I'm down to the attached diff.  My question to everyone is
which version of each file is the newer one?

I'm pretty sure the usb.c and usb.h files should be taken from the -ac
tree like Pete said, but I want to make sure no one minds this before I
do it.

Here's the diffstat:

 include/linux/usb.h                             |   13 +--
 linux-2.4-ac/drivers/usb/devices.c              |    2 
 linux-2.4-ac/drivers/usb/inode.c                |   14 +---
 linux-2.4-ac/drivers/usb/kaweth.c               |   33 +++------
 linux-2.4-ac/drivers/usb/mdc800.c               |   12 ---
 linux-2.4-ac/drivers/usb/storage/unusual_devs.h |   25 +++++--
 linux-2.4-ac/drivers/usb/usb.c                  |   80 ++++++++++++------------
 7 files changed, 87 insertions, 92 deletions

Any help on any of this diffs is greatly appreciated, otherwise I'm just
going to guess which one is better :)

thanks,

greg k-h


diff -Naur -X dontdiff linux-2.4/drivers/usb/devices.c linux-2.4-ac/drivers/usb/devices.c
--- linux-2.4/drivers/usb/devices.c	Tue Sep 11 13:12:51 2001
+++ linux-2.4-ac/drivers/usb/devices.c	Wed Oct  3 10:12:42 2001
@@ -488,7 +488,6 @@
 		return -EFAULT;
 
 	/* enumerate busses */
-	read_lock_irq (&usb_bus_list_lock);
 	for (buslist = usb_bus_list.next; buslist != &usb_bus_list; buslist = buslist->next) {
 		/* print devices for this bus */
 		bus = list_entry(buslist, struct usb_bus, bus_list);
@@ -498,7 +497,6 @@
 			return ret;
 		total_written += ret;
 	}
-	read_unlock_irq (&usb_bus_list_lock);
 	return total_written;
 }
 
diff -Naur -X dontdiff linux-2.4/drivers/usb/inode.c linux-2.4-ac/drivers/usb/inode.c
--- linux-2.4/drivers/usb/inode.c	Tue Sep 11 13:12:52 2001
+++ linux-2.4-ac/drivers/usb/inode.c	Wed Oct  3 10:12:43 2001
@@ -260,15 +260,11 @@
         struct list_head *list;
         struct usb_bus *bus;
 
-	read_lock_irq (&usb_bus_list_lock);
         for (list = usb_bus_list.next; list != &usb_bus_list; list = list->next) {
                 bus = list_entry(list, struct usb_bus, bus_list);
-                if (bus->busnum == busnr) {
-			read_unlock_irq (&usb_bus_list_lock);
+                if (bus->busnum == busnr)
                         return bus;
-		}
         }
-	read_unlock_irq (&usb_bus_list_lock);
         return NULL;
 }
 
@@ -416,7 +412,7 @@
 		if (i < 2+NRSPECIAL)
 			return 0;
 		i -= 2+NRSPECIAL;
-		read_lock_irq (&usb_bus_list_lock);
+		lock_kernel();
 		for (list = usb_bus_list.next; list != &usb_bus_list; list = list->next) {
 			if (i > 0) {
 				i--;
@@ -428,7 +424,7 @@
 				break;
 			filp->f_pos++;
 		}
-		read_unlock_irq (&usb_bus_list_lock);
+		unlock_kernel();
 		return 0;
 	}
 }
@@ -639,13 +635,13 @@
 		list_add_tail(&inode->u.usbdev_i.slist, &s->u.usbdevfs_sb.ilist);
 		list_add_tail(&inode->u.usbdev_i.dlist, &special[i].inodes);
 	}
-	read_lock_irq (&usb_bus_list_lock);
+	lock_kernel();
 	for (blist = usb_bus_list.next; blist != &usb_bus_list; blist = blist->next) {
 		bus = list_entry(blist, struct usb_bus, bus_list);
 		new_bus_inode(bus, s);
 		recurse_new_dev_inode(bus->root_hub, s);
 	}
-	read_unlock_irq (&usb_bus_list_lock);
+	unlock_kernel();
         return s;
 
  out_no_root:
diff -Naur -X dontdiff linux-2.4/drivers/usb/kaweth.c linux-2.4-ac/drivers/usb/kaweth.c
--- linux-2.4/drivers/usb/kaweth.c	Mon Sep 17 08:41:29 2001
+++ linux-2.4-ac/drivers/usb/kaweth.c	Wed Oct  3 10:12:45 2001
@@ -949,12 +949,10 @@
  *-------------------------------------------------------------------*/
 static void usb_api_blocking_completion(urb_t *urb)
 {
-        api_wrapper_data *awd = (api_wrapper_data *)urb->context;
-
-        if (waitqueue_active(awd->wakeup)) {
-                wake_up(awd->wakeup);
-	}
+        struct usb_api_data *awd = (struct usb_api_data *)urb->context;
 
+	awd->done=1;
+	wake_up(&awd->wqh);
 }
 
 /*-------------------------------------------------------------------*
@@ -965,36 +963,31 @@
 static int usb_start_wait_urb(urb_t *urb, int timeout, int* actual_length)
 {
         DECLARE_WAITQUEUE(wait, current);
-        DECLARE_WAIT_QUEUE_HEAD(wqh);
-        api_wrapper_data awd;
+	struct usb_api_data awd;
         int status;
 
-        awd.wakeup = &wqh;
-        init_waitqueue_head(&wqh);
+        init_waitqueue_head(&awd.wqh);
+        awd.done = 0;
+        
         current->state = TASK_INTERRUPTIBLE;
-        add_wait_queue(&wqh, &wait);
+        add_wait_queue(&awd.wqh, &wait);
         urb->context = &awd;
         status = usb_submit_urb(urb);
         if (status) {
                 // something went wrong
                 usb_free_urb(urb);
                 current->state = TASK_RUNNING;
-                remove_wait_queue(&wqh, &wait);
+                remove_wait_queue(&awd.wqh, &wait);
                 return status;
         }
 
-        if (urb->status == -EINPROGRESS) {
-                while (timeout && urb->status == -EINPROGRESS)
-                        status = timeout = schedule_timeout(timeout);
-        } 
-	else {
-                status = 1;
-	}
+	while (timeout && !awd.done)
+		timeout = schedule_timeout(timeout);
 
         current->state = TASK_RUNNING;
-        remove_wait_queue(&wqh, &wait);
+        remove_wait_queue(&awd.wqh, &wait);
 
-        if (!status) {
+        if (!timeout) {
                 // timeout
                 kaweth_warn("usb_control/bulk_msg: timeout");
                 usb_unlink_urb(urb);  // remove urb safely
diff -Naur -X dontdiff linux-2.4/drivers/usb/mdc800.c linux-2.4-ac/drivers/usb/mdc800.c
--- linux-2.4/drivers/usb/mdc800.c	Tue Oct  9 09:48:52 2001
+++ linux-2.4-ac/drivers/usb/mdc800.c	Wed Oct  3 10:12:45 2001
@@ -718,7 +718,6 @@
 static ssize_t mdc800_device_write (struct file *file, const char *buf, size_t len, loff_t *pos)
 {
 	int i=0;
-	char c;
 
 	spin_lock (&mdc800->io_lock);
 	if (mdc800->state != READY)
@@ -741,14 +740,7 @@
 		}
 
 		/* check for command start */
-		
-		if(get_user(c, buf+i))
-		{
-			spin_unlock (&mdc800->io_lock);
-			return -EFAULT;
-		}
-		
-		if (c == (char) 0x55)
+		if (buf [i] == (char) 0x55)
 		{
 			mdc800->in_count=0;
 			mdc800->out_count=0;
@@ -759,7 +751,7 @@
 		/* save command byte */
 		if (mdc800->in_count < 8)
 		{
-			mdc800->in[mdc800->in_count]=c;
+			mdc800->in[mdc800->in_count]=buf[i];
 			mdc800->in_count++;
 		}
 		else
diff -Naur -X dontdiff linux-2.4/drivers/usb/storage/unusual_devs.h linux-2.4-ac/drivers/usb/storage/unusual_devs.h
--- linux-2.4/drivers/usb/storage/unusual_devs.h	Tue Sep 11 13:12:55 2001
+++ linux-2.4-ac/drivers/usb/storage/unusual_devs.h	Fri Oct  5 09:51:07 2001
@@ -60,6 +60,11 @@
 		US_SC_8070, US_PR_SCM_ATAPI, init_8200e, 0), 
 #endif
 
+UNUSUAL_DEV(  0x04cb, 0x0100, 0x0000, 0x2210,
+		"Fujifilm",
+		"FinePix 1400Zoom",
+		US_SC_8070, US_PR_CBI, NULL, US_FL_FIX_INQUIRY),
+
 #ifdef CONFIG_USB_STORAGE_DPCM
 UNUSUAL_DEV(  0x0436, 0x0005, 0x0100, 0x0100,
 		"Microtech",
@@ -293,18 +298,17 @@
                 US_FL_SINGLE_LUN ),
 
 #ifdef CONFIG_USB_STORAGE_SDDR09
-UNUSUAL_DEV(  0x0781, 0x0200, 0x0000, 0x9999, 
+UNUSUAL_DEV(  0x0781, 0x0200, 0x0100, 0x0208, 
 		"Sandisk",
 		"ImageMate SDDR-09",
 		US_SC_SCSI, US_PR_EUSB_SDDR09, NULL,
 		US_FL_SINGLE_LUN | US_FL_START_STOP ),
-#endif
 
-#ifdef CONFIG_USB_STORAGE_FREECOM
-UNUSUAL_DEV(  0x07ab, 0xfc01, 0x0000, 0x9999,
-                "Freecom",
-                "USB-IDE",
-                US_SC_QIC, US_PR_FREECOM, freecom_init, 0),
+UNUSUAL_DEV(  0x0781, 0x0200, 0x0000, 0x9999, 
+ 		"Sandisk",
+ 		"ImageMate SDDR-09",
+ 		US_SC_SCSI, US_PR_EUSB_SDDR09, NULL,
+ 		US_FL_SINGLE_LUN | US_FL_START_STOP ),
 #endif
 
 UNUSUAL_DEV(  0x07af, 0x0004, 0x0100, 0x0100, 
@@ -312,6 +316,13 @@
 		"USB-SCSI-DB25",
 		US_SC_SCSI, US_PR_BULK, usb_stor_euscsi_init,
 		US_FL_SCM_MULT_TARG ), 
+
+#ifdef CONFIG_USB_STORAGE_FREECOM
+UNUSUAL_DEV( 0x07ab, 0xfc01, 0x0000, 0x9999,
+                "Freecom",
+                "USB-IDE",
+                US_SC_QIC, US_PR_FREECOM, freecom_init, 0),
+#endif
 
 UNUSUAL_DEV(  0x07af, 0x0005, 0x0100, 0x0100, 
 		"Microtech",
diff -Naur -X dontdiff linux-2.4/drivers/usb/usb.c linux-2.4-ac/drivers/usb/usb.c
--- linux-2.4/drivers/usb/usb.c	Tue Oct  9 09:46:58 2001
+++ linux-2.4-ac/drivers/usb/usb.c	Tue Oct  9 09:47:49 2001
@@ -1042,15 +1042,11 @@
  *-------------------------------------------------------------------*/
 static void usb_api_blocking_completion(urb_t *urb)
 {
-	api_wrapper_data *awd = (api_wrapper_data *)urb->context;
+	struct usb_api_data *awd = (struct usb_api_data *)urb->context;
 
-	if (waitqueue_active(awd->wakeup))
-		wake_up(awd->wakeup);
-#if 0
-	else
-		dbg("(blocking_completion): waitqueue empty!"); 
-		// even occurs if urb was unlinked by timeout...
-#endif
+	awd->done = 1;
+	wmb();
+	wake_up(&awd->wqh);
 }
 
 /*-------------------------------------------------------------------*
@@ -1061,38 +1057,46 @@
 static int usb_start_wait_urb(urb_t *urb, int timeout, int* actual_length)
 { 
 	DECLARE_WAITQUEUE(wait, current);
-	DECLARE_WAIT_QUEUE_HEAD(wqh);
-	api_wrapper_data awd;
+	struct usb_api_data awd;
 	int status;
-  
-	awd.wakeup = &wqh;
-	init_waitqueue_head(&wqh); 	
-	current->state = TASK_INTERRUPTIBLE;
-	add_wait_queue(&wqh, &wait);
+
+	init_waitqueue_head(&awd.wqh); 	
+	awd.done = 0;
+
+	set_current_state(TASK_UNINTERRUPTIBLE);
+	add_wait_queue(&awd.wqh, &wait);
+
 	urb->context = &awd;
 	status = usb_submit_urb(urb);
 	if (status) {
 		// something went wrong
 		usb_free_urb(urb);
-		current->state = TASK_RUNNING;
-		remove_wait_queue(&wqh, &wait);
+		set_current_state(TASK_RUNNING);
+		remove_wait_queue(&awd.wqh, &wait);
 		return status;
 	}
 
-	if (urb->status == -EINPROGRESS) {
-		while (timeout && urb->status == -EINPROGRESS)
-			status = timeout = schedule_timeout(timeout);
-	} else
-		status = 1;
-
-	current->state = TASK_RUNNING;
-	remove_wait_queue(&wqh, &wait);
-
-	if (!status) {
-		// timeout
-		printk("usb_control/bulk_msg: timeout\n");
-		usb_unlink_urb(urb);  // remove urb safely
-		status = -ETIMEDOUT;
+	while (timeout && !awd.done)
+	{
+		timeout = schedule_timeout(timeout);
+		set_current_state(TASK_UNINTERRUPTIBLE);
+		rmb();
+	}
+
+	set_current_state(TASK_RUNNING);
+	remove_wait_queue(&awd.wqh, &wait);
+
+	if (!timeout && !awd.done) {
+		if (urb->status != -EINPROGRESS) {	/* No callback?!! */
+			printk(KERN_ERR "usb: raced timeout, "
+			    "pipe 0x%x status %d time left %d\n",
+			    urb->pipe, urb->status, timeout);
+			status = urb->status;
+		} else {
+			printk("usb_control/bulk_msg: timeout\n");
+			usb_unlink_urb(urb);  // remove urb safely
+			status = -ETIMEDOUT;
+		}
 	} else
 		status = urb->status;
 
@@ -1116,15 +1120,14 @@
 	if (!urb)
 		return -ENOMEM;
   
-	FILL_CONTROL_URB(urb, usb_dev, pipe, (unsigned char*)cmd, data, len,    /* build urb */  
-		   (usb_complete_t)usb_api_blocking_completion,0);
+	FILL_CONTROL_URB(urb, usb_dev, pipe, (unsigned char*)cmd, data, len,
+		   usb_api_blocking_completion, 0);
 
 	retv = usb_start_wait_urb(urb, timeout, &length);
 	if (retv < 0)
 		return retv;
 	else
 		return length;
-	
 }
 
 /**
@@ -1205,8 +1208,8 @@
 	if (!urb)
 		return -ENOMEM;
 
-	FILL_BULK_URB(urb,usb_dev,pipe,(unsigned char*)data,len,   /* build urb */
-			(usb_complete_t)usb_api_blocking_completion,0);
+	FILL_BULK_URB(urb, usb_dev, pipe, data, len,
+		    usb_api_blocking_completion, 0);
 
 	return usb_start_wait_urb(urb,timeout,actual_length);
 }
@@ -1767,8 +1770,11 @@
  * These are the actual routines to send
  * and receive control messages.
  */
-
+#ifdef CONFIG_USB_LONG_TIMEOUT
+#define GET_TIMEOUT 4
+#else
 #define GET_TIMEOUT 3
+#endif
 #define SET_TIMEOUT 3
 
 int usb_set_address(struct usb_device *dev)
--- linux-2.4/include/linux/usb.h	Mon Oct  8 08:57:55 2001
+++ linux-2.4-ac/include/linux/usb.h	Mon Oct  8 16:31:15 2001
@@ -539,13 +539,12 @@
  *                         SYNCHRONOUS CALL SUPPORT                  *
  *-------------------------------------------------------------------*/
 
-typedef struct
+struct usb_api_data
 {
-  wait_queue_head_t *wakeup;
-
-  void* stuff;
-  /* more to follow */
-} api_wrapper_data;
+	wait_queue_head_t wqh;
+	int done;
+	/* void* stuff;	*/	/* Possible extension later. */
+};
 
 /* -------------------------------------------------------------------------- */
 
@@ -718,7 +717,7 @@
  * appropriately.
  *
  * NOTE:  there's no encoding (yet?) for a "high speed" endpoint; treat them
- * like full speed devices.
+ * like like full speed devices.
  */
 
 #define PIPE_ISOCHRONOUS		0

_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel