Commit 3390e579 authored by Jiri Kosina's avatar Jiri Kosina

Merge branch 'for-4.7/upstream' into for-linus

Conflicts:
	drivers/hid/usbhid/hid-quirks.c
parents 27fd38c5 282bf1fe
...@@ -1129,48 +1129,45 @@ EXPORT_SYMBOL_GPL(hid_field_extract); ...@@ -1129,48 +1129,45 @@ EXPORT_SYMBOL_GPL(hid_field_extract);
static void __implement(u8 *report, unsigned offset, int n, u32 value) static void __implement(u8 *report, unsigned offset, int n, u32 value)
{ {
unsigned int idx = offset / 8; unsigned int idx = offset / 8;
unsigned int size = offset + n;
unsigned int bit_shift = offset % 8; unsigned int bit_shift = offset % 8;
int bits_to_set = 8 - bit_shift; int bits_to_set = 8 - bit_shift;
u8 bit_mask = 0xff << bit_shift;
while (n - bits_to_set >= 0) { while (n - bits_to_set >= 0) {
report[idx] &= ~bit_mask; report[idx] &= ~(0xff << bit_shift);
report[idx] |= value << bit_shift; report[idx] |= value << bit_shift;
value >>= bits_to_set; value >>= bits_to_set;
n -= bits_to_set; n -= bits_to_set;
bits_to_set = 8; bits_to_set = 8;
bit_mask = 0xff;
bit_shift = 0; bit_shift = 0;
idx++; idx++;
} }
/* last nibble */ /* last nibble */
if (n) { if (n) {
if (size % 8) u8 bit_mask = ((1U << n) - 1);
bit_mask &= (1U << (size % 8)) - 1; report[idx] &= ~(bit_mask << bit_shift);
report[idx] &= ~bit_mask; report[idx] |= value << bit_shift;
report[idx] |= (value << bit_shift) & bit_mask;
} }
} }
static void implement(const struct hid_device *hid, u8 *report, static void implement(const struct hid_device *hid, u8 *report,
unsigned offset, unsigned n, u32 value) unsigned offset, unsigned n, u32 value)
{ {
u64 m; if (unlikely(n > 32)) {
if (n > 32) {
hid_warn(hid, "%s() called with n (%d) > 32! (%s)\n", hid_warn(hid, "%s() called with n (%d) > 32! (%s)\n",
__func__, n, current->comm); __func__, n, current->comm);
n = 32; n = 32;
} } else if (n < 32) {
u32 m = (1U << n) - 1;
m = (1ULL << n) - 1;
if (value > m) if (unlikely(value > m)) {
hid_warn(hid, "%s() called with too large value %d! (%s)\n", hid_warn(hid,
__func__, value, current->comm); "%s() called with too large value %d (n: %d)! (%s)\n",
WARN_ON(value > m); __func__, value, n, current->comm);
WARN_ON(1);
value &= m; value &= m;
}
}
__implement(report, offset, n, value); __implement(report, offset, n, value);
} }
......
...@@ -259,6 +259,13 @@ ...@@ -259,6 +259,13 @@
#define USB_VENDOR_ID_CORSAIR 0x1b1c #define USB_VENDOR_ID_CORSAIR 0x1b1c
#define USB_DEVICE_ID_CORSAIR_K90 0x1b02 #define USB_DEVICE_ID_CORSAIR_K90 0x1b02
#define USB_VENDOR_ID_CORSAIR 0x1b1c
#define USB_DEVICE_ID_CORSAIR_K70R 0x1b09
#define USB_DEVICE_ID_CORSAIR_K95RGB 0x1b11
#define USB_DEVICE_ID_CORSAIR_M65RGB 0x1b12
#define USB_DEVICE_ID_CORSAIR_K70RGB 0x1b13
#define USB_DEVICE_ID_CORSAIR_K65RGB 0x1b17
#define USB_VENDOR_ID_CREATIVELABS 0x041e #define USB_VENDOR_ID_CREATIVELABS 0x041e
#define USB_DEVICE_ID_CREATIVE_SB_OMNI_SURROUND_51 0x322c #define USB_DEVICE_ID_CREATIVE_SB_OMNI_SURROUND_51 0x322c
#define USB_DEVICE_ID_PRODIKEYS_PCMIDI 0x2801 #define USB_DEVICE_ID_PRODIKEYS_PCMIDI 0x2801
......
...@@ -421,14 +421,13 @@ static int __init roccat_init(void) ...@@ -421,14 +421,13 @@ static int __init roccat_init(void)
retval = alloc_chrdev_region(&dev_id, ROCCAT_FIRST_MINOR, retval = alloc_chrdev_region(&dev_id, ROCCAT_FIRST_MINOR,
ROCCAT_MAX_DEVICES, "roccat"); ROCCAT_MAX_DEVICES, "roccat");
roccat_major = MAJOR(dev_id);
if (retval < 0) { if (retval < 0) {
pr_warn("can't get major number\n"); pr_warn("can't get major number\n");
goto error; goto error;
} }
roccat_major = MAJOR(dev_id);
cdev_init(&roccat_cdev, &roccat_ops); cdev_init(&roccat_cdev, &roccat_ops);
retval = cdev_add(&roccat_cdev, dev_id, ROCCAT_MAX_DEVICES); retval = cdev_add(&roccat_cdev, dev_id, ROCCAT_MAX_DEVICES);
......
...@@ -582,14 +582,13 @@ int __init hidraw_init(void) ...@@ -582,14 +582,13 @@ int __init hidraw_init(void)
result = alloc_chrdev_region(&dev_id, HIDRAW_FIRST_MINOR, result = alloc_chrdev_region(&dev_id, HIDRAW_FIRST_MINOR,
HIDRAW_MAX_DEVICES, "hidraw"); HIDRAW_MAX_DEVICES, "hidraw");
hidraw_major = MAJOR(dev_id);
if (result < 0) { if (result < 0) {
pr_warn("can't get major number\n"); pr_warn("can't get major number\n");
goto out; goto out;
} }
hidraw_major = MAJOR(dev_id);
hidraw_class = class_create(THIS_MODULE, "hidraw"); hidraw_class = class_create(THIS_MODULE, "hidraw");
if (IS_ERR(hidraw_class)) { if (IS_ERR(hidraw_class)) {
result = PTR_ERR(hidraw_class); result = PTR_ERR(hidraw_class);
......
...@@ -71,6 +71,11 @@ static const struct hid_blacklist { ...@@ -71,6 +71,11 @@ static const struct hid_blacklist {
{ USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_3AXIS_5BUTTON_STICK, HID_QUIRK_NOGET }, { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_3AXIS_5BUTTON_STICK, HID_QUIRK_NOGET },
{ USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_AXIS_295, HID_QUIRK_NOGET }, { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_AXIS_295, HID_QUIRK_NOGET },
{ USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_PIXART_USB_OPTICAL_MOUSE, HID_QUIRK_ALWAYS_POLL }, { USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_PIXART_USB_OPTICAL_MOUSE, HID_QUIRK_ALWAYS_POLL },
{ USB_VENDOR_ID_CORSAIR, USB_DEVICE_ID_CORSAIR_K70R, HID_QUIRK_NO_INIT_REPORTS },
{ USB_VENDOR_ID_CORSAIR, USB_DEVICE_ID_CORSAIR_M65RGB, HID_QUIRK_NO_INIT_REPORTS },
{ USB_VENDOR_ID_CORSAIR, USB_DEVICE_ID_CORSAIR_K95RGB, HID_QUIRK_NO_INIT_REPORTS | HID_QUIRK_ALWAYS_POLL },
{ USB_VENDOR_ID_CORSAIR, USB_DEVICE_ID_CORSAIR_K70RGB, HID_QUIRK_NO_INIT_REPORTS },
{ USB_VENDOR_ID_CORSAIR, USB_DEVICE_ID_CORSAIR_K65RGB, HID_QUIRK_NO_INIT_REPORTS },
{ USB_VENDOR_ID_CREATIVELABS, USB_DEVICE_ID_CREATIVE_SB_OMNI_SURROUND_51, HID_QUIRK_NOGET }, { USB_VENDOR_ID_CREATIVELABS, USB_DEVICE_ID_CREATIVE_SB_OMNI_SURROUND_51, HID_QUIRK_NOGET },
{ USB_VENDOR_ID_DMI, USB_DEVICE_ID_DMI_ENC, HID_QUIRK_NOGET }, { USB_VENDOR_ID_DMI, USB_DEVICE_ID_DMI_ENC, HID_QUIRK_NOGET },
{ USB_VENDOR_ID_DRAGONRISE, USB_DEVICE_ID_DRAGONRISE_WIIU, HID_QUIRK_MULTI_INPUT }, { USB_VENDOR_ID_DRAGONRISE, USB_DEVICE_ID_DRAGONRISE_WIIU, HID_QUIRK_MULTI_INPUT },
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment