libata: straighten out ATA_ID_* constants
[powerpc.git] / drivers / hid / hid-core.c
index 18c2b3c..8c7d48e 100644 (file)
 #include <linux/input.h>
 #include <linux/wait.h>
 
-#undef DEBUG
-#undef DEBUG_DATA
-
 #include <linux/hid.h>
 #include <linux/hiddev.h>
+#include <linux/hid-debug.h>
 
 /*
  * Version Information
 
 #define DRIVER_VERSION "v2.6"
 #define DRIVER_AUTHOR "Andreas Gal, Vojtech Pavlik"
-#define DRIVER_DESC "USB HID core driver"
+#define DRIVER_DESC "HID core driver"
 #define DRIVER_LICENSE "GPL"
 
-/*
- * Module parameters.
- */
-
-static unsigned int hid_mousepoll_interval;
-module_param_named(mousepoll, hid_mousepoll_interval, uint, 0644);
-MODULE_PARM_DESC(mousepoll, "Polling interval of mice");
-
 /*
  * Register a new report for a device.
  */
@@ -551,6 +541,7 @@ void hid_free_device(struct hid_device *device)
        }
 
        kfree(device->rdesc);
+       kfree(device->collection);
        kfree(device);
 }
 EXPORT_SYMBOL_GPL(hid_free_device);
@@ -656,7 +647,7 @@ struct hid_device *hid_parse_report(__u8 *start, unsigned size)
        for (i = 0; i < HID_REPORT_TYPES; i++)
                INIT_LIST_HEAD(&device->report_enum[i].report_list);
 
-       if (!(device->rdesc = (__u8 *)kmalloc(size, GFP_KERNEL))) {
+       if (!(device->rdesc = kmalloc(size, GFP_KERNEL))) {
                kfree(device->collection);
                kfree(device);
                return NULL;
@@ -888,6 +879,10 @@ static void hid_output_field(struct hid_field *field, __u8 *data)
        unsigned size = field->report_size;
        unsigned n;
 
+       /* make sure the unused bits in the last byte are zeros */
+       if (count > 0 && size > 0)
+               data[(count*size-1)/8] = 0;
+
        for (n = 0; n < count; n++) {
                if (field->logical_minimum < 0) /* signed values */
                        implement(data, offset + n * size, size, s32ton(field->value[n], size));
@@ -954,8 +949,8 @@ int hid_input_report(struct hid_device *hid, int type, u8 *data, int size, int i
                return -1;
        }
 
-#ifdef DEBUG_DATA
-       printk(KERN_DEBUG __FILE__ ": report (size %u) (%snumbered)\n", len, report_enum->numbered ? "" : "un");
+#ifdef CONFIG_HID_DEBUG
+       printk(KERN_DEBUG __FILE__ ": report (size %u) (%snumbered)\n", size, report_enum->numbered ? "" : "un");
 #endif
 
        n = 0;                          /* Normally report number is 0 */
@@ -964,7 +959,7 @@ int hid_input_report(struct hid_device *hid, int type, u8 *data, int size, int i
                size--;
        }
 
-#ifdef DEBUG_DATA
+#ifdef CONFIG_HID_DEBUG
        {
                int i;
                printk(KERN_DEBUG __FILE__ ": report %d (size %u) = ", n, size);