patch-2.4.0-test11 linux/drivers/usb/usbmouse.c

Next file: linux/drivers/usb/uss720.c
Previous file: linux/drivers/usb/usbkbd.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.0-test10/linux/drivers/usb/usbmouse.c linux/drivers/usb/usbmouse.c
@@ -1,5 +1,5 @@
 /*
- * $Id: usbmouse.c,v 1.5 2000/05/29 09:01:52 vojtech Exp $
+ * $Id: usbmouse.c,v 1.6 2000/08/14 21:05:26 vojtech Exp $
  *
  *  Copyright (c) 1999-2000 Vojtech Pavlik
  *
@@ -41,9 +41,9 @@
 struct usb_mouse {
 	signed char data[8];
 	char name[128];
+	struct usb_device *usbdev;
 	struct input_dev dev;
 	struct urb irq;
-	struct usb_device *my_usb_device;	// for resubmitting my urb
 	int open;
 };
 
@@ -73,7 +73,7 @@
 	if (mouse->open++)
 		return 0;
 
-	mouse->irq.dev = mouse->my_usb_device;
+	mouse->irq.dev = mouse->usbdev;
 	if (usb_submit_urb(&mouse->irq))
 		return -EIO;
 
@@ -88,20 +88,19 @@
 		usb_unlink_urb(&mouse->irq);
 }
 
-static void *usb_mouse_probe(struct usb_device *dev, unsigned int ifnum)
+static void *usb_mouse_probe(struct usb_device *dev, unsigned int ifnum,
+			     const struct usb_device_id *id)
 {
+	struct usb_interface *iface;
 	struct usb_interface_descriptor *interface;
 	struct usb_endpoint_descriptor *endpoint;
 	struct usb_mouse *mouse;
 	int pipe, maxp;
 	char *buf;
 
-	if (dev->descriptor.bNumConfigurations != 1) return NULL;
-	interface = dev->config[0].interface[ifnum].altsetting + 0;
+	iface = &dev->actconfig->interface[ifnum];
+	interface = &iface->altsetting[iface->act_altsetting];
 
-	if (interface->bInterfaceClass != 3) return NULL;
-	if (interface->bInterfaceSubClass != 1) return NULL;
-	if (interface->bInterfaceProtocol != 2) return NULL;
 	if (interface->bNumEndpoints != 1) return NULL;
 
 	endpoint = interface->endpoint + 0;
@@ -116,6 +115,8 @@
 	if (!(mouse = kmalloc(sizeof(struct usb_mouse), GFP_KERNEL))) return NULL;
 	memset(mouse, 0, sizeof(struct usb_mouse));
 
+	mouse->usbdev = dev;
+
 	mouse->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
 	mouse->dev.keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE);
 	mouse->dev.relbit[0] = BIT(REL_X) | BIT(REL_Y);
@@ -150,7 +151,6 @@
 
 	kfree(buf);
 
-	mouse->my_usb_device = dev;
 	FILL_INT_URB(&mouse->irq, dev, pipe, mouse->data, maxp > 8 ? 8 : maxp,
 		usb_mouse_irq, mouse, endpoint->bInterval);
 
@@ -170,10 +170,18 @@
 	kfree(mouse);
 }
 
+static struct usb_device_id usb_mouse_id_table [] = {
+    { bInterfaceClass: 3, bInterfaceSubClass: 1, bInterfaceProtocol: 2},
+    { }						/* Terminating entry */
+};
+
+MODULE_DEVICE_TABLE (usb, usb_mouse_id_table);
+
 static struct usb_driver usb_mouse_driver = {
 	name:		"usb_mouse",
 	probe:		usb_mouse_probe,
 	disconnect:	usb_mouse_disconnect,
+	id_table:	usb_mouse_id_table,
 };
 
 static int __init usb_mouse_init(void)

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)