--- /home/kojak/src/linux-2.4.5-ac9-orig/drivers/usb/hid-core.c	Sat Jun 16 15:35:50 2001
+++ hid-core.c	Fri Jun 15 16:22:05 2001
@@ -42,7 +42,9 @@
 #include <linux/input.h>
 
 #undef DEBUG
+#define DEBUG 1
 #undef DEBUG_DATA
+#define DEBUG_DATA 1
 
 #include <linux/usb.h>
 
@@ -51,6 +53,11 @@
 #include <linux/hiddev.h>
 #endif
 
+/* Forward declarations */
+static void hid_read_report(struct hid_device *hid, struct hid_report *report);
+static void hid_init_reports(struct hid_device *hid);
+static void hid_set_report(struct hid_device *hid, struct hid_report *report);
+
 /*
  * Version Information
  */
@@ -618,6 +625,10 @@
 		return NULL;
 	memset(device, 0, sizeof(struct hid_device));
 
+	device->hiddev.read_report = hid_read_report;
+	device->hiddev.read_all_reports = hid_init_reports;
+	device->hiddev.write_report = hid_set_report;
+
 	for (i = 0; i < HID_REPORT_TYPES; i++)
 		INIT_LIST_HEAD(&device->report_enum[i].report_list);
 
@@ -809,6 +820,11 @@
 
 #ifdef DEBUG_DATA
 	printk(KERN_DEBUG __FILE__ ": report (size %u) (%snumbered)\n", len, report_enum->numbered ? "" : "un");
+	printk(KERN_DEBUG __FILE__ ": report (size %u) = ", len);
+	for (n = 0; n < len; n++)
+		printk(" %02x", data[n]);
+	printk("\n");
+
 #endif
 
 	n = 0;				/* Normally report number is 0 */
@@ -831,6 +847,13 @@
 
 	size = ((report->size - 1) >> 3) + 1;
 
+#ifdef DEBUG
+	printk(KERN_DEBUG __FILE__ ": report (size %u =? %u) = ", len, size);
+	for (n = 0; n < size; n++)
+		printk(" %02x", data[n]);
+	printk("\n");
+#endif
+
 	if (len < size) {
 
 		if (size <= 8) {
@@ -897,7 +920,7 @@
 	u8 data[len];
 	int read;
 
-	if ((read = usb_get_report(hid->dev, hid->ifnum, report->type + 1, report->id, data, len)) != len) {
+	if ((read = usb_get_report(hid->dev, hid->ifnum, report->type + 1, report->id, data, len)) < 0 ) {
 		dbg("reading report type %d id %d failed len %d read %d", report->type + 1, report->id, len, read);
 		return;
 	}
@@ -936,6 +959,29 @@
 }
 
 /*
+ * hid_set_report() writes a report to the device, without waiting for
+ * an irq urb
+ */
+static void hid_set_report(struct hid_device *hid, struct hid_report* report)
+{
+	int len = cpu_to_le16((report->size + 7) >> 3);
+	u8 data[len];
+	int written;
+
+	hid_output_report(report, data);
+
+	if ((written = usb_set_report(hid->dev,
+					hid->ifnum,
+					report->type + 1,
+					report->id,
+					data,
+					len))<0) {
+		dbg("writing report type %d id %d failed len %d written %d", report->type + 1, report->id, len, written);
+		return;
+	}
+}
+
+/*
  * Set a field value. The report this field belongs to has to be
  * created and transfered to the device, to set this value in the
  * device.
@@ -992,6 +1038,17 @@
 	hid->urbout.setup_packet = (void *) &(hid->out[hid->outtail].dr);
 	hid->urbout.dev = hid->dev;
 
+#ifdef DEBUG
+	{
+		int j;
+		printk(KERN_INFO __FILE__ ": hid_submit_out[0..%x] = ",
+			hid->urbout.transfer_buffer_length-1);
+		for (j=0;j<hid->urbout.transfer_buffer_length;j++)
+			printk(" %02x", ((char*)hid->urbout.transfer_buffer)[j]);
+		printk("\n");
+	}
+#endif
+
 	if (usb_submit_urb(&hid->urbout)) {
 		err("usb_submit_urb(out) failed");
 		return -1;
@@ -1013,7 +1070,7 @@
 		hid_submit_out(hid);
 }
 
-void hid_write_report(struct hid_device *hid, struct hid_report *report)
+static void hid_write_report(struct hid_device *hid, struct hid_report *report)
 {
 	hid_output_report(report, hid->out[hid->outhead].buffer);
 
@@ -1265,7 +1322,10 @@
 }
 
 static struct usb_device_id hid_usb_ids [] = {
-	{ bInterfaceClass: USB_INTERFACE_CLASS_HID },
+	{
+	    match_flags:        USB_DEVICE_ID_MATCH_INT_CLASS,
+	    bInterfaceClass: USB_INTERFACE_CLASS_HID
+	},
 	{ }						/* Terminating entry */
 };
 
