mempolicy: ERR_PTR dereference in mpol_shared_policy_init()
[safe/jmp/linux-2.6] / drivers / hid / hid-roccat-kone.c
index 7b11784..66e6940 100644 (file)
@@ -630,7 +630,7 @@ static ssize_t kone_sysfs_set_startup_profile(struct device *dev,
 static ssize_t kone_sysfs_show_driver_version(struct device *dev,
                struct device_attribute *attr, char *buf)
 {
-       return snprintf(buf, PAGE_SIZE, DRIVER_VERSION "\n");
+       return snprintf(buf, PAGE_SIZE, ROCCAT_KONE_DRIVER_VERSION "\n");
 }
 
 /*
@@ -912,6 +912,24 @@ static void kone_remove(struct hid_device *hdev)
        hid_hw_stop(hdev);
 }
 
+/* handle special events and keep actual profile and dpi values up to date */
+static void kone_keep_values_up_to_date(struct kone_device *kone,
+               struct kone_mouse_event const *event)
+{
+       switch (event->event) {
+       case kone_mouse_event_switch_profile:
+       case kone_mouse_event_osd_profile:
+               kone->actual_profile = event->value;
+               kone->actual_dpi = kone->profiles[kone->actual_profile - 1].
+                               startup_dpi;
+               break;
+       case kone_mouse_event_switch_dpi:
+       case kone_mouse_event_osd_dpi:
+               kone->actual_dpi = event->value;
+               break;
+       }
+}
+
 /*
  * Is called for keyboard- and mousepart.
  * Only mousepart gets informations about special events in its extended event
@@ -928,50 +946,19 @@ static int kone_raw_event(struct hid_device *hdev, struct hid_report *report,
                return 0;
 
        /*
-        * Firmware 1.38 introduced new behaviour for tilt buttons.
-        * Pressed tilt button is reported in each movement event.
+        * Firmware 1.38 introduced new behaviour for tilt and special buttons.
+        * Pressed button is reported in each movement event.
         * Workaround sends only one event per press.
         */
-       if (kone->last_tilt_state == event->tilt)
-               event->tilt = 0;
+       if (memcmp(&kone->last_mouse_event.tilt, &event->tilt, 5))
+               memcpy(&kone->last_mouse_event, event,
+                               sizeof(struct kone_mouse_event));
        else
-               kone->last_tilt_state = event->tilt;
+               memset(&event->tilt, 0, 5);
 
-       /*
-        * handle special events and keep actual profile and dpi values
-        * up to date
-        */
-       switch (event->event) {
-       case kone_mouse_event_osd_dpi:
-               dev_dbg(&hdev->dev, "osd dpi event. actual dpi %d\n",
-                               event->value);
-               return 1; /* return 1 if event was handled */
-       case kone_mouse_event_switch_dpi:
-               kone->actual_dpi = event->value;
-               dev_dbg(&hdev->dev, "switched dpi to %d\n", event->value);
-               return 1;
-       case kone_mouse_event_osd_profile:
-               dev_dbg(&hdev->dev, "osd profile event. actual profile %d\n",
-                               event->value);
-               return 1;
-       case kone_mouse_event_switch_profile:
-               kone->actual_profile = event->value;
-               kone->actual_dpi = kone->profiles[kone->actual_profile - 1].
-                               startup_dpi;
-               dev_dbg(&hdev->dev, "switched profile to %d\n", event->value);
-               return 1;
-       case kone_mouse_event_call_overlong_macro:
-               dev_dbg(&hdev->dev, "overlong macro called, button %d %s/%s\n",
-                               event->macro_key,
-                               kone->profiles[kone->actual_profile - 1].
-                               button_infos[event->macro_key].macro_set_name,
-                               kone->profiles[kone->actual_profile - 1].
-                               button_infos[event->macro_key].macro_name
-                               );
-               return 1;
-       }
+       kone_keep_values_up_to_date(kone, event);
 
-       return 0; /* do further processing */
+       return 0; /* always do further processing */
 }
 
 static const struct hid_device_id kone_devices[] = {
@@ -989,12 +976,12 @@ static struct hid_driver kone_driver = {
                .raw_event = kone_raw_event
 };
 
-static int kone_init(void)
+static int __init kone_init(void)
 {
        return hid_register_driver(&kone_driver);
 }
 
-static void kone_exit(void)
+static void __exit kone_exit(void)
 {
        hid_unregister_driver(&kone_driver);
 }
@@ -1002,6 +989,6 @@ static void kone_exit(void)
 module_init(kone_init);
 module_exit(kone_exit);
 
-MODULE_AUTHOR(DRIVER_AUTHOR);
-MODULE_DESCRIPTION(DRIVER_DESC);
-MODULE_LICENSE(DRIVER_LICENSE);
+MODULE_AUTHOR("Stefan Achatz");
+MODULE_DESCRIPTION("USB Roccat Kone driver");
+MODULE_LICENSE("GPL v2");