Merge git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-rc-fixes-2.6
[sfrench/cifs-2.6.git] / drivers / hid / hid-core.c
index 317cf8a7b63c11ed03e76772c8c8710a3ec5505c..f0b00ec1e47e7c1c0daf85cd6cc864f2c0c2c555 100644 (file)
 #include <linux/input.h>
 #include <linux/wait.h>
 #include <linux/vmalloc.h>
+#include <linux/sched.h>
 
 #include <linux/hid.h>
 #include <linux/hiddev.h>
 #include <linux/hid-debug.h>
+#include <linux/hidraw.h>
 
 /*
  * Version Information
@@ -757,7 +759,9 @@ static __inline__ __u32 extract(__u8 *report, unsigned offset, unsigned n)
 {
        u64 x;
 
-       WARN_ON(n > 32);
+       if (n > 32)
+               printk(KERN_WARNING "HID: extract() called with n (%d) > 32! (%s)\n",
+                               n, current->comm);
 
        report += offset >> 3;  /* adjust byte index */
        offset &= 7;            /* now only need bit offset into one byte */
@@ -779,8 +783,13 @@ static __inline__ void implement(__u8 *report, unsigned offset, unsigned n, __u3
        __le64 x;
        u64 m = (1ULL << n) - 1;
 
-       WARN_ON(n > 32);
+       if (n > 32)
+               printk(KERN_WARNING "HID: implement() called with n (%d) > 32! (%s)\n",
+                               n, current->comm);
 
+       if (value > m)
+               printk(KERN_WARNING "HID: implement() called with too large value %d! (%s)\n",
+                               value, current->comm);
        WARN_ON(value > m);
        value &= m;
 
@@ -959,7 +968,7 @@ int hid_input_report(struct hid_device *hid, int type, u8 *data, int size, int i
                size--;
        }
 
-       /* dump the report descriptor */
+       /* dump the report */
        dbg_hid("report %d (size %u) = ", n, size);
        for (i = 0; i < size; i++)
                dbg_hid_line(" %02x", data[i]);
@@ -979,6 +988,8 @@ int hid_input_report(struct hid_device *hid, int type, u8 *data, int size, int i
 
        if ((hid->claimed & HID_CLAIMED_HIDDEV) && hid->hiddev_report_event)
                hid->hiddev_report_event(hid, report);
+       if (hid->claimed & HID_CLAIMED_HIDRAW)
+               hidraw_report_event(hid, data, size);
 
        for (n = 0; n < report->maxfield; n++)
                hid_input_field(hid, report->field[n], data, interrupt);
@@ -990,5 +1001,18 @@ int hid_input_report(struct hid_device *hid, int type, u8 *data, int size, int i
 }
 EXPORT_SYMBOL_GPL(hid_input_report);
 
+static int __init hid_init(void)
+{
+       return hidraw_init();
+}
+
+static void __exit hid_exit(void)
+{
+       hidraw_exit();
+}
+
+module_init(hid_init);
+module_exit(hid_exit);
+
 MODULE_LICENSE(DRIVER_LICENSE);