# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
#	           ChangeSet	1.376   -> 1.377  
#	drivers/usb/usb-uhci.c	1.27    -> 1.28   
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 02/02/20	greg@kroah.com	1.377
# usb usb-uhci.c:
# 	- added usb_put_urb() and usb_get_urb() logic.
# --------------------------------------------
#
diff -Nru a/drivers/usb/usb-uhci.c b/drivers/usb/usb-uhci.c
--- a/drivers/usb/usb-uhci.c	Wed Feb 20 16:55:11 2002
+++ b/drivers/usb/usb-uhci.c	Wed Feb 20 16:55:11 2002
@@ -1217,6 +1217,7 @@
 			urb->complete ((struct urb *) urb);
 		}
 		usb_dec_dev_use (usb_dev);
+		usb_put_urb (urb);
 	}
 	else
 		spin_unlock_irqrestore (&s->urb_list_lock, flags);
@@ -1305,7 +1306,7 @@
 #else
 			kfree (urb_priv);
 #endif
-
+			usb_put_urb (urb);
 		}
 	}
 }
@@ -1650,6 +1651,9 @@
 		return -EINVAL;
 	}
 
+	/* increment the reference count of the urb, as we now also control it */
+	urb = usb_get_urb (urb);
+
 	usb_inc_dev_use (urb->dev);
 
 	spin_lock_irqsave (&s->urb_list_lock, flags);
@@ -1665,6 +1669,7 @@
 		     (!(urb->transfer_flags & USB_QUEUE_BULK) || !(queued_urb->transfer_flags & USB_QUEUE_BULK)))) {
 			spin_unlock_irqrestore (&s->urb_list_lock, flags);
 			usb_dec_dev_use (urb->dev);
+			usb_put_urb (urb);
 			err("ENXIO %08x, flags %x, urb %p, burb %p",urb->pipe,urb->transfer_flags,urb,queued_urb);
 			return -ENXIO;	// urb already queued
 		}
@@ -1678,6 +1683,7 @@
 	if (!urb_priv) {
 		usb_dec_dev_use (urb->dev);
 		spin_unlock_irqrestore (&s->urb_list_lock, flags);
+		usb_put_urb (urb);
 		return -ENOMEM;
 	}
 
@@ -1766,6 +1772,7 @@
 #else
 		kfree (urb_priv);
 #endif
+		usb_put_urb (urb);
 		return ret;
 	}
 
@@ -2730,6 +2737,7 @@
 			}
 			
 			usb_dec_dev_use (usb_dev);
+			usb_put_urb (urb);
 		}
 	}
 
