Merge tag 'v3.10.13' into lsk/v3.10/topic/kvm
[firefly-linux-kernel-4.4.55.git] / drivers / hid / hid-speedlink.c
index e94371a059cb3b65f53580d83f5dc40e51ee493c..7112f3e832ee22cd39f725f5f1100bb47f966643 100644 (file)
@@ -3,7 +3,7 @@
  *  Fixes "jumpy" cursor and removes nonexistent keyboard LEDS from
  *  the HID descriptor.
  *
- *  Copyright (c) 2011 Stefan Kriwanek <mail@stefankriwanek.de>
+ *  Copyright (c) 2011, 2013 Stefan Kriwanek <dev@stefankriwanek.de>
  */
 
 /*
 #include <linux/device.h>
 #include <linux/hid.h>
 #include <linux/module.h>
-#include <linux/usb.h>
 
 #include "hid-ids.h"
-#include "usbhid/usbhid.h"
 
 static const struct hid_device_id speedlink_devices[] = {
        { HID_USB_DEVICE(USB_VENDOR_ID_X_TENSIONS, USB_DEVICE_ID_SPEEDLINK_VAD_CEZANNE)},
@@ -48,8 +46,13 @@ static int speedlink_event(struct hid_device *hdev, struct hid_field *field,
                struct hid_usage *usage, __s32 value)
 {
        /* No other conditions due to usage_table. */
-       /* Fix "jumpy" cursor (invalid events sent by device). */
-       if (value == 256)
+
+       /* This fixes the "jumpy" cursor occuring due to invalid events sent
+        * by the device. Some devices only send them with value==+256, others
+        * don't. However, catching abs(value)>=256 is restrictive enough not
+        * to interfere with devices that were bug-free (has been tested).
+        */
+       if (abs(value) >= 256)
                return 1;
        /* Drop useless distance 0 events (on button clicks etc.) as well */
        if (value == 0)