Subject: [PATCH 10 of 16] USB scanner driver change
From: Greg KH <[email-masked]>
To: [email-masked]
Cc: [email-masked], [email-masked]

Hi,

Here's a patch against 2.5.3-pre3 for the USB scanner driver that
converts it to dynamically allocate its urbs.

thanks,

greg k-h

diff -Nru a/drivers/usb/scanner.c b/drivers/usb/scanner.c
--- a/drivers/usb/scanner.c	Tue Jan 22 12:54:25 2002
+++ b/drivers/usb/scanner.c	Tue Jan 22 12:54:25 2002
@@ -972,6 +972,13 @@
 	}
 	memset (scn, 0, sizeof(struct scn_usb_data));
 
+	scn->scn_irq = usb_alloc_urb(0);
+	if (!scn->scn_irq) {
+		kfree(scn);
+		up(&scn_mutex);
+		return NULL;
+	}
+
 	init_MUTEX(&(scn->sem)); /* Initializes to unlocked */
 
 	dbg ("probe_scanner(%d): Address of scn:%p", scn_minor, scn);
@@ -979,13 +986,13 @@
 /* Ok, if we detected an interrupt EP, setup a handler for it */
 	if (have_intr) {
 		dbg("probe_scanner(%d): Configuring IRQ handler for intr EP:%d", scn_minor, have_intr);
-		FILL_INT_URB(&scn->scn_irq, dev,
+		FILL_INT_URB(scn->scn_irq, dev,
 			     usb_rcvintpipe(dev, have_intr),
 			     &scn->button, 1, irq_scanner, scn,
 			     // endpoint[(int)have_intr].bInterval);
 			     250);
 
-	        if (usb_submit_urb(&scn->scn_irq)) {
+	        if (usb_submit_urb(scn->scn_irq)) {
 			err("probe_scanner(%d): Unable to allocate INT URB.", scn_minor);
                 	kfree(scn);
 			up(&scn_mutex);
@@ -1067,7 +1074,7 @@
 
 	if(scn->intr_ep) {
 		dbg("disconnect_scanner(%d): Unlinking IRQ URB", scn->scn_minor);
-		usb_unlink_urb(&scn->scn_irq);
+		usb_unlink_urb(scn->scn_irq);
 	}
         usb_driver_release_interface(&scanner_driver,
                 &scn->scn_dev->actconfig->interface[scn->ifnum]);
@@ -1078,6 +1085,7 @@
 	dbg("disconnect_scanner: De-allocating minor:%d", scn->scn_minor);
 	devfs_unregister(scn->devfs);
 	p_scn_table[scn->scn_minor] = NULL;
+	usb_free_urb(scn->scn_irq);
 	up (&(scn->sem));
 	kfree (scn);
 	up (&scn_mutex);
diff -Nru a/drivers/usb/scanner.h b/drivers/usb/scanner.h
--- a/drivers/usb/scanner.h	Tue Jan 22 12:54:24 2002
+++ b/drivers/usb/scanner.h	Tue Jan 22 12:54:24 2002
@@ -241,7 +241,7 @@
 struct scn_usb_data {
 	struct usb_device *scn_dev;
 	devfs_handle_t devfs;	/* devfs device */
-	struct urb scn_irq;
+	struct urb *scn_irq;
 	unsigned int ifnum;	/* Interface number of the USB device */
 	int scn_minor;		/* Scanner minor - used in disconnect() */
 	unsigned char button;	/* Front panel buffer */