From 46386b587086c8d2698222a031bf749688464032 Mon Sep 17 00:00:00 2001 From: Simon Budig Date: Mon, 12 Mar 2007 13:52:04 +0100 Subject: HID: introduce proper zeroing of unused bits in output reports Some HID devices are looking on the unused bits in the HID reports they receive. This is violating the specification, but we want to make those devices work. Well-behaving devices are unaffected, as they don't care about the unused bits. If bitsused % 8 is 0 all bits in data[] get used and we don't need to clear anything. Otherwise (bitsused % 8) bits of the last byte get used. By shifting 1 for (bitsused % 8) bits and subtracting 1 we create a mask consisting of (bitsused % 8) ones and remaining zeroes. By ANDing we clear the upper unused bits. Signed-off-by: Simon Budig Signed-off-by: Jiri Kosina --- drivers/hid/hid-core.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'drivers/hid/hid-core.c') diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 67f3347afcf..c16c9499d9c 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -872,8 +872,13 @@ static void hid_output_field(struct hid_field *field, __u8 *data) unsigned count = field->report_count; unsigned offset = field->report_offset; unsigned size = field->report_size; + unsigned bitsused = offset + count * size; unsigned n; + /* make sure the unused bits in the last byte are zeros */ + if (count > 0 && size > 0 && (bitsused % 8) != 0) + data[(bitsused-1)/8] &= (1 << (bitsused % 8)) - 1; + for (n = 0; n < count; n++) { if (field->logical_minimum < 0) /* signed values */ implement(data, offset + n * size, size, s32ton(field->value[n], size)); -- cgit v1.2.3 From f142b3a4f64eca235f5890d9cecb68482f62ed26 Mon Sep 17 00:00:00 2001 From: Jiri Kosina Date: Mon, 16 Apr 2007 11:29:28 +0200 Subject: HID: update copyright and authorship macro Updates Copyright and DRIVER_AUTHOR in HID and USB HID sources. Signed-off-by: Jiri Kosina --- drivers/hid/hid-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/hid/hid-core.c') diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 67f3347afcf..7c0fab1efb2 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -4,7 +4,7 @@ * Copyright (c) 1999 Andreas Gal * Copyright (c) 2000-2005 Vojtech Pavlik * Copyright (c) 2005 Michael Haboustak for Concept2, Inc - * Copyright (c) 2006 Jiri Kosina + * Copyright (c) 2006-2007 Jiri Kosina */ /* @@ -37,7 +37,7 @@ */ #define DRIVER_VERSION "v2.6" -#define DRIVER_AUTHOR "Andreas Gal, Vojtech Pavlik" +#define DRIVER_AUTHOR "Andreas Gal, Vojtech Pavlik, Jiri Kosina" #define DRIVER_DESC "HID core driver" #define DRIVER_LICENSE "GPL" -- cgit v1.2.3