From 23408f95fa92483527de3206ebeb55c37e0f679c Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sun, 5 Aug 2012 23:57:14 +0200 Subject: [PATCH 01/20] HID: Bump maximum global item tag report size to 128 bytes The Freescale i.MX28 BootROM USB recovery mode implements the USB HID protocol, yet the global item tag report size is 128. Linux checks if this is 96 as of now, see [1]. This causes Linux to refuse to communicate with this device, making it impossible to use the recovery mode. This is not a standard HID device per se, but rather a software emulation implemented within the BootROM code and realized through USB OTG-capable port switched to device mode present on the device. Previous attempt to discuss this issue dates back to 2011, see [2]. There has been not much response. Also noteworthy is the [3], where there seems to be a pointing device that has issue similar to this one. The tool making use of the USB recovery mode is available at [4]. [1] http://comments.gmane.org/gmane.linux.kernel.input/22328 [2] http://www.spinics.net/lists/linux-usb/msg43463.html [3] https://bbs.archlinux.org/viewtopic.php?pid=1141340 [4] http://git.bfuser.eu/?p=marex/mxsldr.git;a=summary Signed-off-by: Marek Vasut Cc: Chen Peter Cc: Greg KH Cc: Jiri Kosina Signed-off-by: Jiri Kosina --- drivers/hid/hid-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 500844f04f93..0b62bb510ffc 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -374,7 +374,7 @@ static int hid_parser_global(struct hid_parser *parser, struct hid_item *item) case HID_GLOBAL_ITEM_TAG_REPORT_SIZE: parser->global.report_size = item_udata(item); - if (parser->global.report_size > 96) { + if (parser->global.report_size > 128) { hid_err(parser->device, "invalid report_size %d\n", parser->global.report_size); return -1; From 2843b673d03421e0e73cf061820d1db328f7c8eb Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sun, 5 Aug 2012 23:57:15 +0200 Subject: [PATCH 02/20] HID: add quirk for Freescale i.MX28 ROM recovery The USB recovery mode present in i.MX28 ROM emulates USB HID. It needs this quirk to behave properly. Signed-off-by: Marek Vasut Cc: Chen Peter Cc: Greg KH Cc: Jiri Kosina [jkosina@suse.cz: fix alphabetical ordering] Signed-off-by: Jiri Kosina --- drivers/hid/hid-ids.h | 3 +++ drivers/hid/usbhid/hid-quirks.c | 1 + 2 files changed, 4 insertions(+) diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index 41c34f21bd00..ec0d6d2ea943 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h @@ -296,6 +296,9 @@ #define USB_VENDOR_ID_EZKEY 0x0518 #define USB_DEVICE_ID_BTC_8193 0x0002 +#define USB_VENDOR_ID_FREESCALE 0x15A2 +#define USB_DEVICE_ID_FREESCALE_MX28 0x004F + #define USB_VENDOR_ID_FRUCTEL 0x25B6 #define USB_DEVICE_ID_GAMETEL_MT_MODE 0x0002 diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c index 903eef3d3e10..ccb8de6156f3 100644 --- a/drivers/hid/usbhid/hid-quirks.c +++ b/drivers/hid/usbhid/hid-quirks.c @@ -70,6 +70,7 @@ static const struct hid_blacklist { { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_AXIS_295, HID_QUIRK_NOGET }, { USB_VENDOR_ID_DMI, USB_DEVICE_ID_DMI_ENC, HID_QUIRK_NOGET }, { USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_TS2700, HID_QUIRK_NOGET }, + { USB_VENDOR_ID_FREESCALE, USB_DEVICE_ID_FREESCALE_MX28, HID_QUIRK_NOGET }, { USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN, HID_QUIRK_NO_INIT_REPORTS }, { USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN1, HID_QUIRK_NO_INIT_REPORTS }, { USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN2, HID_QUIRK_NO_INIT_REPORTS }, From bcb4a75bde3821cecb17a71d287abfd6ef9bd68d Mon Sep 17 00:00:00 2001 From: Alexey Khoroshilov Date: Wed, 15 Aug 2012 23:31:45 +0400 Subject: [PATCH 03/20] HID: hidraw: improve error handling in hidraw_init() Several improvements in error handling: - do not report success if alloc_chrdev_region() failed - check for error code of cdev_add() - use unregister_chrdev_region() instead of unregister_chrdev() if class_create() failed Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Alexey Khoroshilov Signed-off-by: Jiri Kosina --- drivers/hid/hidraw.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c index 3b6f7bf5a77e..7c47fc3f7b2b 100644 --- a/drivers/hid/hidraw.c +++ b/drivers/hid/hidraw.c @@ -559,21 +559,28 @@ int __init hidraw_init(void) if (result < 0) { pr_warn("can't get major number\n"); - result = 0; goto out; } hidraw_class = class_create(THIS_MODULE, "hidraw"); if (IS_ERR(hidraw_class)) { result = PTR_ERR(hidraw_class); - unregister_chrdev(hidraw_major, "hidraw"); - goto out; + goto error_cdev; } cdev_init(&hidraw_cdev, &hidraw_ops); - cdev_add(&hidraw_cdev, dev_id, HIDRAW_MAX_DEVICES); + result = cdev_add(&hidraw_cdev, dev_id, HIDRAW_MAX_DEVICES); + if (result < 0) + goto error_class; + out: return result; + +error_class: + class_destroy(hidraw_class); +error_cdev: + unregister_chrdev_region(dev_id, HIDRAW_MAX_DEVICES); + goto out; } void hidraw_exit(void) From b0be5b3bac6376ea55bfcbac04cc521428043742 Mon Sep 17 00:00:00 2001 From: Simon Farnsworth Date: Thu, 23 Aug 2012 11:12:47 +0100 Subject: [PATCH 04/20] HID: Remove duplicate ID for QUANTA 3001 touchscreen For some reason, we had two IDs for the QUANTA 3001 touchscreen controller, one USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH_3001 and one USB_DEVICE_ID_PIXART_IMAGING_INC_OPTICAL_TOUCH_SCREEN. As this has caused confusion, remove USB_DEVICE_ID_PIXART_IMAGING_INC_OPTICAL_TOUCH_SCREEN completely, and fix places where it was used to refer to USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH_3001. Signed-off-by: Simon Farnsworth Acked-by: Henrik Rydberg Signed-off-by: Jiri Kosina --- drivers/hid/hid-ids.h | 1 - drivers/hid/usbhid/hid-quirks.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index ec0d6d2ea943..5d886b7cade9 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h @@ -654,7 +654,6 @@ #define USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH 0x3000 #define USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH_3001 0x3001 #define USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH_3008 0x3008 -#define USB_DEVICE_ID_PIXART_IMAGING_INC_OPTICAL_TOUCH_SCREEN 0x3001 #define USB_VENDOR_ID_ROCCAT 0x1e7d #define USB_DEVICE_ID_ROCCAT_ARVO 0x30d4 diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c index ccb8de6156f3..9af530e4555c 100644 --- a/drivers/hid/usbhid/hid-quirks.c +++ b/drivers/hid/usbhid/hid-quirks.c @@ -75,7 +75,7 @@ static const struct hid_blacklist { { USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN1, HID_QUIRK_NO_INIT_REPORTS }, { USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN2, HID_QUIRK_NO_INIT_REPORTS }, { USB_VENDOR_ID_PRODIGE, USB_DEVICE_ID_PRODIGE_CORDLESS, HID_QUIRK_NOGET }, - { USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_PIXART_IMAGING_INC_OPTICAL_TOUCH_SCREEN, HID_QUIRK_NOGET }, + { USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH_3001, HID_QUIRK_NOGET }, { USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH_3008, HID_QUIRK_NOGET }, { USB_VENDOR_ID_SENNHEISER, USB_DEVICE_ID_SENNHEISER_BTD500USB, HID_QUIRK_NOGET }, { USB_VENDOR_ID_SUN, USB_DEVICE_ID_RARITAN_KVM_DONGLE, HID_QUIRK_NOGET }, From 8db089d1b08209c04cd130e49fa4796b5513ce7f Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Tue, 21 Aug 2012 20:22:44 +0200 Subject: [PATCH 05/20] HID: hid-debug: Show rdesc for unclaimed devices Since commit a7197c2e, the raw report descriptor is available also for unclaimed devices. This patchs make it show in the rdesc debugfs node. Signed-off-by: Henrik Rydberg Signed-off-by: Jiri Kosina --- drivers/hid/hid-debug.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c index 01dd9a7daf7a..933fff0fff1f 100644 --- a/drivers/hid/hid-debug.c +++ b/drivers/hid/hid-debug.c @@ -911,15 +911,21 @@ static void hid_dump_input_mapping(struct hid_device *hid, struct seq_file *f) } - static int hid_debug_rdesc_show(struct seq_file *f, void *p) { struct hid_device *hdev = f->private; + const __u8 *rdesc = hdev->rdesc; + unsigned rsize = hdev->rsize; int i; + if (!rdesc) { + rdesc = hdev->dev_rdesc; + rsize = hdev->dev_rsize; + } + /* dump HID report descriptor */ - for (i = 0; i < hdev->rsize; i++) - seq_printf(f, "%02x ", hdev->rdesc[i]); + for (i = 0; i < rsize; i++) + seq_printf(f, "%02x ", rdesc[i]); seq_printf(f, "\n\n"); /* dump parsed data and input mappings */ From 00315e4f5343bf8b0858f840884f6e19464698c7 Mon Sep 17 00:00:00 2001 From: Jiri Kosina Date: Sun, 2 Sep 2012 09:28:51 +0200 Subject: [PATCH 06/20] HID: update hid_have_special_driver[] explanation Update the comment of hid_have_special_driver[] field to reflect the fact that multitouch devices don't need to be present there. Signed-off-by: Jiri Kosina --- drivers/hid/hid-core.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index fa5fcca16a9a..8d3946af9ff6 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -1447,7 +1447,14 @@ void hid_disconnect(struct hid_device *hdev) } EXPORT_SYMBOL_GPL(hid_disconnect); -/* a list of devices for which there is a specialized driver on HID bus */ +/* + * A list of devices for which there is a specialized driver on HID bus. + * + * Please note that for multitouch devices (driven by hid-multitouch driver), + * there is a proper autodetection and autoloading in place (based on presence + * of HID_DG_CONTACTID), so those devices don't need to be added to this list, + * as we are doing the right thing in hid_scan_usage(). + */ static const struct hid_device_id hid_have_special_driver[] = { { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU) }, { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_X5_005D) }, From 6dbea04417817995a08c1c478f2a40733465bc19 Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Sun, 2 Sep 2012 21:43:52 -0700 Subject: [PATCH 07/20] HID: Remove "default m" from HID_LOGITECH_DJ HID_LOGITECH_DJ uses "default m", which enables it in default kernel builds. Since this module just enables extra, non-critical functionality for one particular piece of hardware (specifically, differentiating multiple wireless keyboards and mice as separate input devices rather than treating them as one device), and the hardware works just fine with the default USB HID support, drop the "default m". Signed-off-by: Josh Triplett Signed-off-by: Jiri Kosina --- drivers/hid/Kconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig index fbf49503508d..d0045283e604 100644 --- a/drivers/hid/Kconfig +++ b/drivers/hid/Kconfig @@ -307,7 +307,6 @@ config HID_LOGITECH config HID_LOGITECH_DJ tristate "Logitech Unifying receivers full support" depends on HID_LOGITECH - default m ---help--- Say Y if you want support for Logitech Unifying receivers and devices. Unifying receivers are capable of pairing up to 6 Logitech compliant From 2f43f8749ebaeb4934f73a6f864fcbb60ce9f48a Mon Sep 17 00:00:00 2001 From: Jiri Kosina Date: Tue, 4 Sep 2012 13:31:42 +0200 Subject: [PATCH 08/20] HID: remove Paul Walmsley's copyright from places where it shouldn't be Paul Walmsley has implemented dynamic quirk handling back in 2007 through commits: 2eb5dc30eb ("USB HID: encapsulate quirk handling into hid-quirks.c") 8222fbe67c ("USB HID: clarify static quirk handling as squirks") 8cef908235 ("USB HID: add support for dynamically-created quirks") 876b9276b9 ("USB HID: add 'quirks' module parameter") and as such, his copyright rightly belongs to drivers/hid/usbhid/hid-quirks.c file. However when generic HID code has been converted to bus and individual quirks separated out to individual drivers on the bus, the copyright has been blindly transfered into all the tiny drivers, which actually don't contain any of Pauls' copyrighted code. Remove the copyright from those sub-drivers. Signed-off-by: Jiri Kosina Acked-by: Paul Walmsley --- drivers/hid/hid-a4tech.c | 1 - drivers/hid/hid-apple.c | 1 - drivers/hid/hid-aureal.c | 1 - drivers/hid/hid-belkin.c | 1 - drivers/hid/hid-cherry.c | 1 - drivers/hid/hid-cypress.c | 1 - drivers/hid/hid-ezkey.c | 1 - drivers/hid/hid-gyration.c | 1 - drivers/hid/hid-ids.h | 1 - drivers/hid/hid-lg.c | 1 - drivers/hid/hid-microsoft.c | 1 - drivers/hid/hid-monterey.c | 1 - drivers/hid/hid-petalynx.c | 1 - drivers/hid/hid-samsung.c | 1 - drivers/hid/hid-sony.c | 1 - drivers/hid/hid-sunplus.c | 1 - drivers/hid/hid-wacom.c | 1 - 17 files changed, 17 deletions(-) diff --git a/drivers/hid/hid-a4tech.c b/drivers/hid/hid-a4tech.c index 902d1dfeb1b5..0a239885e67c 100644 --- a/drivers/hid/hid-a4tech.c +++ b/drivers/hid/hid-a4tech.c @@ -5,7 +5,6 @@ * Copyright (c) 2000-2005 Vojtech Pavlik * Copyright (c) 2005 Michael Haboustak for Concept2, Inc * Copyright (c) 2006-2007 Jiri Kosina - * Copyright (c) 2007 Paul Walmsley * Copyright (c) 2008 Jiri Slaby */ diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c index 585344b6d338..06ebdbb6ea02 100644 --- a/drivers/hid/hid-apple.c +++ b/drivers/hid/hid-apple.c @@ -5,7 +5,6 @@ * Copyright (c) 2000-2005 Vojtech Pavlik * Copyright (c) 2005 Michael Haboustak for Concept2, Inc * Copyright (c) 2006-2007 Jiri Kosina - * Copyright (c) 2007 Paul Walmsley * Copyright (c) 2008 Jiri Slaby */ diff --git a/drivers/hid/hid-aureal.c b/drivers/hid/hid-aureal.c index ba64b041b8bf..7968187ddf7b 100644 --- a/drivers/hid/hid-aureal.c +++ b/drivers/hid/hid-aureal.c @@ -9,7 +9,6 @@ * Copyright (c) 2000-2005 Vojtech Pavlik * Copyright (c) 2005 Michael Haboustak for Concept2, Inc * Copyright (c) 2006-2007 Jiri Kosina - * Copyright (c) 2007 Paul Walmsley * Copyright (c) 2008 Jiri Slaby */ #include diff --git a/drivers/hid/hid-belkin.c b/drivers/hid/hid-belkin.c index a1a765a5b08a..a1a5a12c3a6b 100644 --- a/drivers/hid/hid-belkin.c +++ b/drivers/hid/hid-belkin.c @@ -5,7 +5,6 @@ * Copyright (c) 2000-2005 Vojtech Pavlik * Copyright (c) 2005 Michael Haboustak for Concept2, Inc * Copyright (c) 2006-2007 Jiri Kosina - * Copyright (c) 2007 Paul Walmsley * Copyright (c) 2008 Jiri Slaby */ diff --git a/drivers/hid/hid-cherry.c b/drivers/hid/hid-cherry.c index 888ece68a47c..af034d3d9256 100644 --- a/drivers/hid/hid-cherry.c +++ b/drivers/hid/hid-cherry.c @@ -5,7 +5,6 @@ * Copyright (c) 2000-2005 Vojtech Pavlik * Copyright (c) 2005 Michael Haboustak for Concept2, Inc * Copyright (c) 2006-2007 Jiri Kosina - * Copyright (c) 2007 Paul Walmsley * Copyright (c) 2008 Jiri Slaby */ diff --git a/drivers/hid/hid-cypress.c b/drivers/hid/hid-cypress.c index 9e43aaca9774..3e159a50dac7 100644 --- a/drivers/hid/hid-cypress.c +++ b/drivers/hid/hid-cypress.c @@ -5,7 +5,6 @@ * Copyright (c) 2000-2005 Vojtech Pavlik * Copyright (c) 2005 Michael Haboustak for Concept2, Inc * Copyright (c) 2006-2007 Jiri Kosina - * Copyright (c) 2007 Paul Walmsley * Copyright (c) 2008 Jiri Slaby */ diff --git a/drivers/hid/hid-ezkey.c b/drivers/hid/hid-ezkey.c index ca1163e9d42d..6540af2871a7 100644 --- a/drivers/hid/hid-ezkey.c +++ b/drivers/hid/hid-ezkey.c @@ -5,7 +5,6 @@ * Copyright (c) 2000-2005 Vojtech Pavlik * Copyright (c) 2005 Michael Haboustak for Concept2, Inc * Copyright (c) 2006-2007 Jiri Kosina - * Copyright (c) 2007 Paul Walmsley * Copyright (c) 2008 Jiri Slaby */ diff --git a/drivers/hid/hid-gyration.c b/drivers/hid/hid-gyration.c index e88b951cd10d..4442c30ef531 100644 --- a/drivers/hid/hid-gyration.c +++ b/drivers/hid/hid-gyration.c @@ -4,7 +4,6 @@ * Copyright (c) 1999 Andreas Gal * Copyright (c) 2000-2005 Vojtech Pavlik * Copyright (c) 2005 Michael Haboustak for Concept2, Inc - * Copyright (c) 2007 Paul Walmsley * Copyright (c) 2008 Jiri Slaby * Copyright (c) 2006-2008 Jiri Kosina */ diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index 0709c0093ac5..753f3d65f94c 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h @@ -5,7 +5,6 @@ * Copyright (c) 2000-2005 Vojtech Pavlik * Copyright (c) 2005 Michael Haboustak for Concept2, Inc * Copyright (c) 2006-2007 Jiri Kosina - * Copyright (c) 2007 Paul Walmsley */ /* diff --git a/drivers/hid/hid-lg.c b/drivers/hid/hid-lg.c index fc37ed6b108c..e6eca2dc7b46 100644 --- a/drivers/hid/hid-lg.c +++ b/drivers/hid/hid-lg.c @@ -5,7 +5,6 @@ * Copyright (c) 2000-2005 Vojtech Pavlik * Copyright (c) 2005 Michael Haboustak for Concept2, Inc * Copyright (c) 2006-2007 Jiri Kosina - * Copyright (c) 2007 Paul Walmsley * Copyright (c) 2008 Jiri Slaby * Copyright (c) 2010 Hendrik Iben */ diff --git a/drivers/hid/hid-microsoft.c b/drivers/hid/hid-microsoft.c index e5c699b6c6f3..3acdcfcc17df 100644 --- a/drivers/hid/hid-microsoft.c +++ b/drivers/hid/hid-microsoft.c @@ -5,7 +5,6 @@ * Copyright (c) 2000-2005 Vojtech Pavlik * Copyright (c) 2005 Michael Haboustak for Concept2, Inc * Copyright (c) 2006-2007 Jiri Kosina - * Copyright (c) 2007 Paul Walmsley * Copyright (c) 2008 Jiri Slaby */ diff --git a/drivers/hid/hid-monterey.c b/drivers/hid/hid-monterey.c index dedf757781ae..cd3643e06fa6 100644 --- a/drivers/hid/hid-monterey.c +++ b/drivers/hid/hid-monterey.c @@ -5,7 +5,6 @@ * Copyright (c) 2000-2005 Vojtech Pavlik * Copyright (c) 2005 Michael Haboustak for Concept2, Inc * Copyright (c) 2006-2007 Jiri Kosina - * Copyright (c) 2007 Paul Walmsley * Copyright (c) 2008 Jiri Slaby */ diff --git a/drivers/hid/hid-petalynx.c b/drivers/hid/hid-petalynx.c index f1ea3ff8a98d..4c521de4e7e6 100644 --- a/drivers/hid/hid-petalynx.c +++ b/drivers/hid/hid-petalynx.c @@ -5,7 +5,6 @@ * Copyright (c) 2000-2005 Vojtech Pavlik * Copyright (c) 2005 Michael Haboustak for Concept2, Inc * Copyright (c) 2006-2007 Jiri Kosina - * Copyright (c) 2007 Paul Walmsley * Copyright (c) 2008 Jiri Slaby */ diff --git a/drivers/hid/hid-samsung.c b/drivers/hid/hid-samsung.c index 3c1fd8af5e0c..a5821d317229 100644 --- a/drivers/hid/hid-samsung.c +++ b/drivers/hid/hid-samsung.c @@ -5,7 +5,6 @@ * Copyright (c) 2000-2005 Vojtech Pavlik * Copyright (c) 2005 Michael Haboustak for Concept2, Inc * Copyright (c) 2006-2007 Jiri Kosina - * Copyright (c) 2007 Paul Walmsley * Copyright (c) 2008 Jiri Slaby * Copyright (c) 2010 Don Prince * diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c index 5cd25bd907f8..7f33ebf299c2 100644 --- a/drivers/hid/hid-sony.c +++ b/drivers/hid/hid-sony.c @@ -4,7 +4,6 @@ * Copyright (c) 1999 Andreas Gal * Copyright (c) 2000-2005 Vojtech Pavlik * Copyright (c) 2005 Michael Haboustak for Concept2, Inc - * Copyright (c) 2007 Paul Walmsley * Copyright (c) 2008 Jiri Slaby * Copyright (c) 2006-2008 Jiri Kosina */ diff --git a/drivers/hid/hid-sunplus.c b/drivers/hid/hid-sunplus.c index d484a0043dd4..45b4b066a262 100644 --- a/drivers/hid/hid-sunplus.c +++ b/drivers/hid/hid-sunplus.c @@ -5,7 +5,6 @@ * Copyright (c) 2000-2005 Vojtech Pavlik * Copyright (c) 2005 Michael Haboustak for Concept2, Inc * Copyright (c) 2006-2007 Jiri Kosina - * Copyright (c) 2007 Paul Walmsley * Copyright (c) 2008 Jiri Slaby */ diff --git a/drivers/hid/hid-wacom.c b/drivers/hid/hid-wacom.c index fe23a1eb586b..a92d11690c19 100644 --- a/drivers/hid/hid-wacom.c +++ b/drivers/hid/hid-wacom.c @@ -5,7 +5,6 @@ * Copyright (c) 2000-2005 Vojtech Pavlik * Copyright (c) 2005 Michael Haboustak for Concept2, Inc * Copyright (c) 2006-2007 Jiri Kosina - * Copyright (c) 2007 Paul Walmsley * Copyright (c) 2008 Jiri Slaby * Copyright (c) 2006 Andrew Zabolotny * Copyright (c) 2009 Bastien Nocera From 5f4fa6afd31c1002c7cbd13d33dcc6e9d3bef10e Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Wed, 5 Sep 2012 10:19:30 +0800 Subject: [PATCH 09/20] HID: hid-lcpower: Use HID_UP_LOGIVENDOR instead of hard coded 0x0ffbc0000 Signed-off-by: Axel Lin Signed-off-by: Jiri Kosina --- drivers/hid/hid-lcpower.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hid/hid-lcpower.c b/drivers/hid/hid-lcpower.c index c4fe9bd095b7..22bc14abdfa3 100644 --- a/drivers/hid/hid-lcpower.c +++ b/drivers/hid/hid-lcpower.c @@ -24,7 +24,7 @@ static int ts_input_mapping(struct hid_device *hdev, struct hid_input *hi, struct hid_field *field, struct hid_usage *usage, unsigned long **bit, int *max) { - if ((usage->hid & HID_USAGE_PAGE) != 0x0ffbc0000) + if ((usage->hid & HID_USAGE_PAGE) != HID_UP_LOGIVENDOR) return 0; switch (usage->hid & HID_USAGE) { From 751e5ed350ac3f8dff9fd63ce01405da9472a034 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Fri, 7 Sep 2012 15:13:24 +0800 Subject: [PATCH 10/20] HID: waltop: Remove waltop_probe() and waltop_remove() functions The waltop_probe() and waltop_remove() functions do not have any special initialization and cleanup. Remove them and let HID core handle the default probe/remove actions. Signed-off-by: Axel Lin Acked-by: Nikolai Kondrashov Signed-off-by: Jiri Kosina --- drivers/hid/hid-waltop.c | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/drivers/hid/hid-waltop.c b/drivers/hid/hid-waltop.c index 745e4e9a8cf2..bb536ab5941e 100644 --- a/drivers/hid/hid-waltop.c +++ b/drivers/hid/hid-waltop.c @@ -638,28 +638,6 @@ static __u8 sirius_battery_free_tablet_rdesc_fixed[] = { 0xC0 /* End Collection */ }; -static int waltop_probe(struct hid_device *hdev, - const struct hid_device_id *id) -{ - int ret; - - ret = hid_parse(hdev); - if (ret) { - hid_err(hdev, "parse failed\n"); - goto err; - } - - ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); - if (ret) { - hid_err(hdev, "hw start failed\n"); - goto err; - } - - return 0; -err: - return ret; -} - static __u8 *waltop_report_fixup(struct hid_device *hdev, __u8 *rdesc, unsigned int *rsize) { @@ -776,11 +754,6 @@ static int waltop_raw_event(struct hid_device *hdev, struct hid_report *report, return 0; } -static void waltop_remove(struct hid_device *hdev) -{ - hid_hw_stop(hdev); -} - static const struct hid_device_id waltop_devices[] = { { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_SLIM_TABLET_5_8_INCH) }, @@ -803,10 +776,8 @@ MODULE_DEVICE_TABLE(hid, waltop_devices); static struct hid_driver waltop_driver = { .name = "waltop", .id_table = waltop_devices, - .probe = waltop_probe, .report_fixup = waltop_report_fixup, .raw_event = waltop_raw_event, - .remove = waltop_remove, }; static int __init waltop_init(void) From 8b61513b86a221760389237c039105b5a5a332b3 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Fri, 7 Sep 2012 15:11:50 +0800 Subject: [PATCH 11/20] HID: primax: Remove px_probe() and px_remove() functions The px_probe() and px_remove() functions do not have any special initialization and cleanup. Remove them and let HID core handle the default probe/remove actions. Signed-off-by: Axel Lin Signed-off-by: Jiri Kosina --- drivers/hid/hid-primax.c | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/drivers/hid/hid-primax.c b/drivers/hid/hid-primax.c index 4d3c60d88318..c15adb0c98a1 100644 --- a/drivers/hid/hid-primax.c +++ b/drivers/hid/hid-primax.c @@ -64,29 +64,6 @@ static int px_raw_event(struct hid_device *hid, struct hid_report *report, return 0; } -static int px_probe(struct hid_device *hid, const struct hid_device_id *id) -{ - int ret; - - ret = hid_parse(hid); - if (ret) { - hid_err(hid, "parse failed\n"); - goto fail; - } - - ret = hid_hw_start(hid, HID_CONNECT_DEFAULT); - if (ret) - hid_err(hid, "hw start failed\n"); - -fail: - return ret; -} - -static void px_remove(struct hid_device *hid) -{ - hid_hw_stop(hid); -} - static const struct hid_device_id px_devices[] = { { HID_USB_DEVICE(USB_VENDOR_ID_PRIMAX, USB_DEVICE_ID_PRIMAX_KEYBOARD) }, { } @@ -97,8 +74,6 @@ static struct hid_driver px_driver = { .name = "primax", .id_table = px_devices, .raw_event = px_raw_event, - .probe = px_probe, - .remove = px_remove, }; static int __init px_init(void) From e2e78e71d1a3d721beaaab591f3d6c4886ef21a4 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Wed, 5 Sep 2012 15:00:43 +0300 Subject: [PATCH 12/20] HID: holtekff: use %*ph to dump small buffers Signed-off-by: Andy Shevchenko Signed-off-by: Jiri Kosina --- drivers/hid/hid-holtekff.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/hid/hid-holtekff.c b/drivers/hid/hid-holtekff.c index 4e7542151e22..ff295e60059b 100644 --- a/drivers/hid/hid-holtekff.c +++ b/drivers/hid/hid-holtekff.c @@ -100,8 +100,7 @@ static void holtekff_send(struct holtekff_device *holtekff, holtekff->field->value[i] = data[i]; } - dbg_hid("sending %02x %02x %02x %02x %02x %02x %02x\n", data[0], - data[1], data[2], data[3], data[4], data[5], data[6]); + dbg_hid("sending %*ph\n", 7, data); usbhid_submit_report(hid, holtekff->field->report, USB_DIR_OUT); } From 2575155309947063927b123c56119f36dfda3b50 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Thu, 13 Sep 2012 14:08:32 +0800 Subject: [PATCH 13/20] HID: lg: Remove unnecessary casts of void pointers Signed-off-by: Axel Lin Signed-off-by: Jiri Kosina --- drivers/hid/hid-lg.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/hid/hid-lg.c b/drivers/hid/hid-lg.c index e6eca2dc7b46..55ce2bfe51fa 100644 --- a/drivers/hid/hid-lg.c +++ b/drivers/hid/hid-lg.c @@ -108,7 +108,7 @@ static __u8 dfp_rdesc_fixed[] = { static __u8 *lg_report_fixup(struct hid_device *hdev, __u8 *rdesc, unsigned int *rsize) { - struct lg_drv_data *drv_data = (struct lg_drv_data *)hid_get_drvdata(hdev); + struct lg_drv_data *drv_data = hid_get_drvdata(hdev); if ((drv_data->quirks & LG_RDESC) && *rsize >= 90 && rdesc[83] == 0x26 && rdesc[84] == 0x8c && rdesc[85] == 0x02) { @@ -277,7 +277,7 @@ static int lg_input_mapping(struct hid_device *hdev, struct hid_input *hi, 0, 0, 0, 0, 0,183,184,185,186,187, 188,189,190,191,192,193,194, 0, 0, 0 }; - struct lg_drv_data *drv_data = (struct lg_drv_data *)hid_get_drvdata(hdev); + struct lg_drv_data *drv_data = hid_get_drvdata(hdev); unsigned int hid = usage->hid; if (hdev->product == USB_DEVICE_ID_LOGITECH_RECEIVER && @@ -318,7 +318,7 @@ static int lg_input_mapped(struct hid_device *hdev, struct hid_input *hi, struct hid_field *field, struct hid_usage *usage, unsigned long **bit, int *max) { - struct lg_drv_data *drv_data = (struct lg_drv_data *)hid_get_drvdata(hdev); + struct lg_drv_data *drv_data = hid_get_drvdata(hdev); if ((drv_data->quirks & LG_BAD_RELATIVE_KEYS) && usage->type == EV_KEY && (field->flags & HID_MAIN_ITEM_RELATIVE)) @@ -334,7 +334,7 @@ static int lg_input_mapped(struct hid_device *hdev, struct hid_input *hi, static int lg_event(struct hid_device *hdev, struct hid_field *field, struct hid_usage *usage, __s32 value) { - struct lg_drv_data *drv_data = (struct lg_drv_data *)hid_get_drvdata(hdev); + struct lg_drv_data *drv_data = hid_get_drvdata(hdev); if ((drv_data->quirks & LG_INVERT_HWHEEL) && usage->code == REL_HWHEEL) { input_event(field->hidinput->input, usage->type, usage->code, @@ -415,7 +415,7 @@ err_free: static void lg_remove(struct hid_device *hdev) { - struct lg_drv_data *drv_data = (struct lg_drv_data *)hid_get_drvdata(hdev); + struct lg_drv_data *drv_data = hid_get_drvdata(hdev); if (drv_data->quirks & LG_FF4) lg4ff_deinit(hdev); From 4629fd160f7da96b9e6b5abf3f65dbf53642467b Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Thu, 13 Sep 2012 14:09:33 +0800 Subject: [PATCH 14/20] HID: lg4ff: Remove unnecessary casts of void pointers Signed-off-by: Axel Lin Signed-off-by: Jiri Kosina --- drivers/hid/hid-lg4ff.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/hid/hid-lg4ff.c b/drivers/hid/hid-lg4ff.c index f3390ee6105c..da23c6bf1a63 100644 --- a/drivers/hid/hid-lg4ff.c +++ b/drivers/hid/hid-lg4ff.c @@ -360,7 +360,7 @@ static void lg4ff_led_set_brightness(struct led_classdev *led_cdev, { struct device *dev = led_cdev->dev->parent; struct hid_device *hid = container_of(dev, struct hid_device, dev); - struct lg_drv_data *drv_data = (struct lg_drv_data *)hid_get_drvdata(hid); + struct lg_drv_data *drv_data = hid_get_drvdata(hid); struct lg4ff_device_entry *entry; int i, state = 0; @@ -395,7 +395,7 @@ static enum led_brightness lg4ff_led_get_brightness(struct led_classdev *led_cde { struct device *dev = led_cdev->dev->parent; struct hid_device *hid = container_of(dev, struct hid_device, dev); - struct lg_drv_data *drv_data = (struct lg_drv_data *)hid_get_drvdata(hid); + struct lg_drv_data *drv_data = hid_get_drvdata(hid); struct lg4ff_device_entry *entry; int i, value = 0; From 372d297b8c8968d7a05e4a63911bea8ec335e031 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Thu, 13 Sep 2012 14:10:34 +0800 Subject: [PATCH 15/20] HID: prodikeys: Remove unnecessary casts of void pointers Signed-off-by: Axel Lin Signed-off-by: Jiri Kosina --- drivers/hid/hid-prodikeys.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/hid/hid-prodikeys.c b/drivers/hid/hid-prodikeys.c index b71b77ab0dc7..ec8ca3336315 100644 --- a/drivers/hid/hid-prodikeys.c +++ b/drivers/hid/hid-prodikeys.c @@ -105,7 +105,7 @@ static ssize_t show_channel(struct device *dev, struct device_attribute *attr, char *buf) { struct hid_device *hdev = container_of(dev, struct hid_device, dev); - struct pk_device *pk = (struct pk_device *)hid_get_drvdata(hdev); + struct pk_device *pk = hid_get_drvdata(hdev); dbg_hid("pcmidi sysfs read channel=%u\n", pk->pm->midi_channel); @@ -118,7 +118,7 @@ static ssize_t store_channel(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct hid_device *hdev = container_of(dev, struct hid_device, dev); - struct pk_device *pk = (struct pk_device *)hid_get_drvdata(hdev); + struct pk_device *pk = hid_get_drvdata(hdev); unsigned channel = 0; @@ -142,7 +142,7 @@ static ssize_t show_sustain(struct device *dev, struct device_attribute *attr, char *buf) { struct hid_device *hdev = container_of(dev, struct hid_device, dev); - struct pk_device *pk = (struct pk_device *)hid_get_drvdata(hdev); + struct pk_device *pk = hid_get_drvdata(hdev); dbg_hid("pcmidi sysfs read sustain=%u\n", pk->pm->midi_sustain); @@ -155,7 +155,7 @@ static ssize_t store_sustain(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct hid_device *hdev = container_of(dev, struct hid_device, dev); - struct pk_device *pk = (struct pk_device *)hid_get_drvdata(hdev); + struct pk_device *pk = hid_get_drvdata(hdev); unsigned sustain = 0; @@ -181,7 +181,7 @@ static ssize_t show_octave(struct device *dev, struct device_attribute *attr, char *buf) { struct hid_device *hdev = container_of(dev, struct hid_device, dev); - struct pk_device *pk = (struct pk_device *)hid_get_drvdata(hdev); + struct pk_device *pk = hid_get_drvdata(hdev); dbg_hid("pcmidi sysfs read octave=%d\n", pk->pm->midi_octave); @@ -194,7 +194,7 @@ static ssize_t store_octave(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct hid_device *hdev = container_of(dev, struct hid_device, dev); - struct pk_device *pk = (struct pk_device *)hid_get_drvdata(hdev); + struct pk_device *pk = hid_get_drvdata(hdev); int octave = 0; @@ -759,7 +759,7 @@ static int pk_input_mapping(struct hid_device *hdev, struct hid_input *hi, struct hid_field *field, struct hid_usage *usage, unsigned long **bit, int *max) { - struct pk_device *pk = (struct pk_device *)hid_get_drvdata(hdev); + struct pk_device *pk = hid_get_drvdata(hdev); struct pcmidi_snd *pm; pm = pk->pm; @@ -777,7 +777,7 @@ static int pk_input_mapping(struct hid_device *hdev, struct hid_input *hi, static int pk_raw_event(struct hid_device *hdev, struct hid_report *report, u8 *data, int size) { - struct pk_device *pk = (struct pk_device *)hid_get_drvdata(hdev); + struct pk_device *pk = hid_get_drvdata(hdev); int ret = 0; if (1 == pk->pm->ifnum) { @@ -858,7 +858,7 @@ err_free_pk: static void pk_remove(struct hid_device *hdev) { - struct pk_device *pk = (struct pk_device *)hid_get_drvdata(hdev); + struct pk_device *pk = hid_get_drvdata(hdev); struct pcmidi_snd *pm; pm = pk->pm; From 832fbeaef446a7024c5e0f19b7122100a7b1003d Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Thu, 13 Sep 2012 14:12:08 +0800 Subject: [PATCH 16/20] HID: lenovo-tpkbd: Remove unnecessary casts of void pointers container_of() never returns NULL, thus also remove the NULL checking for it. Signed-off-by: Axel Lin Signed-off-by: Jiri Kosina --- drivers/hid/hid-lenovo-tpkbd.c | 147 ++++++++------------------------- 1 file changed, 33 insertions(+), 114 deletions(-) diff --git a/drivers/hid/hid-lenovo-tpkbd.c b/drivers/hid/hid-lenovo-tpkbd.c index 77d2df04c97b..32bfcc4808b7 100644 --- a/drivers/hid/hid-lenovo-tpkbd.c +++ b/drivers/hid/hid-lenovo-tpkbd.c @@ -56,9 +56,8 @@ static int tpkbd_input_mapping(struct hid_device *hdev, static int tpkbd_features_set(struct hid_device *hdev) { struct hid_report *report; - struct tpkbd_data_pointer *data_pointer; + struct tpkbd_data_pointer *data_pointer = hid_get_drvdata(hdev); - data_pointer = (struct tpkbd_data_pointer *) hid_get_drvdata(hdev); report = hdev->report_enum[HID_FEATURE_REPORT].report_id_hash[4]; report->field[0]->value[0] = data_pointer->press_to_select ? 0x01 : 0x02; @@ -77,14 +76,8 @@ static ssize_t pointer_press_to_select_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct hid_device *hdev; - struct tpkbd_data_pointer *data_pointer; - - hdev = container_of(dev, struct hid_device, dev); - if (hdev == NULL) - return -ENODEV; - - data_pointer = (struct tpkbd_data_pointer *) hid_get_drvdata(hdev); + struct hid_device *hdev = container_of(dev, struct hid_device, dev); + struct tpkbd_data_pointer *data_pointer = hid_get_drvdata(hdev); return snprintf(buf, PAGE_SIZE, "%u\n", data_pointer->press_to_select); } @@ -94,16 +87,10 @@ static ssize_t pointer_press_to_select_store(struct device *dev, const char *buf, size_t count) { - struct hid_device *hdev; - struct tpkbd_data_pointer *data_pointer; + struct hid_device *hdev = container_of(dev, struct hid_device, dev); + struct tpkbd_data_pointer *data_pointer = hid_get_drvdata(hdev); int value; - hdev = container_of(dev, struct hid_device, dev); - if (hdev == NULL) - return -ENODEV; - - data_pointer = (struct tpkbd_data_pointer *) hid_get_drvdata(hdev); - if (kstrtoint(buf, 10, &value)) return -EINVAL; if (value < 0 || value > 1) @@ -119,14 +106,8 @@ static ssize_t pointer_dragging_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct hid_device *hdev; - struct tpkbd_data_pointer *data_pointer; - - hdev = container_of(dev, struct hid_device, dev); - if (hdev == NULL) - return -ENODEV; - - data_pointer = (struct tpkbd_data_pointer *) hid_get_drvdata(hdev); + struct hid_device *hdev = container_of(dev, struct hid_device, dev); + struct tpkbd_data_pointer *data_pointer = hid_get_drvdata(hdev); return snprintf(buf, PAGE_SIZE, "%u\n", data_pointer->dragging); } @@ -136,16 +117,10 @@ static ssize_t pointer_dragging_store(struct device *dev, const char *buf, size_t count) { - struct hid_device *hdev; - struct tpkbd_data_pointer *data_pointer; + struct hid_device *hdev = container_of(dev, struct hid_device, dev); + struct tpkbd_data_pointer *data_pointer = hid_get_drvdata(hdev); int value; - hdev = container_of(dev, struct hid_device, dev); - if (hdev == NULL) - return -ENODEV; - - data_pointer = (struct tpkbd_data_pointer *) hid_get_drvdata(hdev); - if (kstrtoint(buf, 10, &value)) return -EINVAL; if (value < 0 || value > 1) @@ -161,14 +136,8 @@ static ssize_t pointer_release_to_select_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct hid_device *hdev; - struct tpkbd_data_pointer *data_pointer; - - hdev = container_of(dev, struct hid_device, dev); - if (hdev == NULL) - return -ENODEV; - - data_pointer = (struct tpkbd_data_pointer *) hid_get_drvdata(hdev); + struct hid_device *hdev = container_of(dev, struct hid_device, dev); + struct tpkbd_data_pointer *data_pointer = hid_get_drvdata(hdev); return snprintf(buf, PAGE_SIZE, "%u\n", data_pointer->release_to_select); } @@ -178,16 +147,10 @@ static ssize_t pointer_release_to_select_store(struct device *dev, const char *buf, size_t count) { - struct hid_device *hdev; - struct tpkbd_data_pointer *data_pointer; + struct hid_device *hdev = container_of(dev, struct hid_device, dev); + struct tpkbd_data_pointer *data_pointer = hid_get_drvdata(hdev); int value; - hdev = container_of(dev, struct hid_device, dev); - if (hdev == NULL) - return -ENODEV; - - data_pointer = (struct tpkbd_data_pointer *) hid_get_drvdata(hdev); - if (kstrtoint(buf, 10, &value)) return -EINVAL; if (value < 0 || value > 1) @@ -203,14 +166,8 @@ static ssize_t pointer_select_right_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct hid_device *hdev; - struct tpkbd_data_pointer *data_pointer; - - hdev = container_of(dev, struct hid_device, dev); - if (hdev == NULL) - return -ENODEV; - - data_pointer = (struct tpkbd_data_pointer *) hid_get_drvdata(hdev); + struct hid_device *hdev = container_of(dev, struct hid_device, dev); + struct tpkbd_data_pointer *data_pointer = hid_get_drvdata(hdev); return snprintf(buf, PAGE_SIZE, "%u\n", data_pointer->select_right); } @@ -220,16 +177,10 @@ static ssize_t pointer_select_right_store(struct device *dev, const char *buf, size_t count) { - struct hid_device *hdev; - struct tpkbd_data_pointer *data_pointer; + struct hid_device *hdev = container_of(dev, struct hid_device, dev); + struct tpkbd_data_pointer *data_pointer = hid_get_drvdata(hdev); int value; - hdev = container_of(dev, struct hid_device, dev); - if (hdev == NULL) - return -ENODEV; - - data_pointer = (struct tpkbd_data_pointer *) hid_get_drvdata(hdev); - if (kstrtoint(buf, 10, &value)) return -EINVAL; if (value < 0 || value > 1) @@ -245,14 +196,8 @@ static ssize_t pointer_sensitivity_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct hid_device *hdev; - struct tpkbd_data_pointer *data_pointer; - - hdev = container_of(dev, struct hid_device, dev); - if (hdev == NULL) - return -ENODEV; - - data_pointer = (struct tpkbd_data_pointer *) hid_get_drvdata(hdev); + struct hid_device *hdev = container_of(dev, struct hid_device, dev); + struct tpkbd_data_pointer *data_pointer = hid_get_drvdata(hdev); return snprintf(buf, PAGE_SIZE, "%u\n", data_pointer->sensitivity); @@ -263,16 +208,10 @@ static ssize_t pointer_sensitivity_store(struct device *dev, const char *buf, size_t count) { - struct hid_device *hdev; - struct tpkbd_data_pointer *data_pointer; + struct hid_device *hdev = container_of(dev, struct hid_device, dev); + struct tpkbd_data_pointer *data_pointer = hid_get_drvdata(hdev); int value; - hdev = container_of(dev, struct hid_device, dev); - if (hdev == NULL) - return -ENODEV; - - data_pointer = (struct tpkbd_data_pointer *) hid_get_drvdata(hdev); - if (kstrtoint(buf, 10, &value) || value < 1 || value > 255) return -EINVAL; @@ -286,14 +225,10 @@ static ssize_t pointer_press_speed_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct hid_device *hdev; - struct tpkbd_data_pointer *data_pointer; + struct hid_device *hdev = container_of(dev, struct hid_device, dev); + struct tpkbd_data_pointer *data_pointer = hid_get_drvdata(hdev); - hdev = container_of(dev, struct hid_device, dev); - if (hdev == NULL) - return -ENODEV; - - data_pointer = (struct tpkbd_data_pointer *) hid_get_drvdata(hdev); + data_pointer = hid_get_drvdata(hdev); return snprintf(buf, PAGE_SIZE, "%u\n", data_pointer->press_speed); @@ -304,16 +239,10 @@ static ssize_t pointer_press_speed_store(struct device *dev, const char *buf, size_t count) { - struct hid_device *hdev; - struct tpkbd_data_pointer *data_pointer; + struct hid_device *hdev = container_of(dev, struct hid_device, dev); + struct tpkbd_data_pointer *data_pointer = hid_get_drvdata(hdev); int value; - hdev = container_of(dev, struct hid_device, dev); - if (hdev == NULL) - return -ENODEV; - - data_pointer = (struct tpkbd_data_pointer *) hid_get_drvdata(hdev); - if (kstrtoint(buf, 10, &value) || value < 1 || value > 255) return -EINVAL; @@ -370,15 +299,11 @@ static const struct attribute_group tpkbd_attr_group_pointer = { static enum led_brightness tpkbd_led_brightness_get( struct led_classdev *led_cdev) { - struct device *dev; - struct hid_device *hdev; - struct tpkbd_data_pointer *data_pointer; + struct device *dev = led_cdev->dev->parent; + struct hid_device *hdev = container_of(dev, struct hid_device, dev); + struct tpkbd_data_pointer *data_pointer = hid_get_drvdata(hdev); int led_nr = 0; - dev = led_cdev->dev->parent; - hdev = container_of(dev, struct hid_device, dev); - data_pointer = (struct tpkbd_data_pointer *) hid_get_drvdata(hdev); - if (led_cdev == &data_pointer->led_micmute) led_nr = 1; @@ -390,16 +315,12 @@ static enum led_brightness tpkbd_led_brightness_get( static void tpkbd_led_brightness_set(struct led_classdev *led_cdev, enum led_brightness value) { - struct device *dev; - struct hid_device *hdev; + struct device *dev = led_cdev->dev->parent; + struct hid_device *hdev = container_of(dev, struct hid_device, dev); + struct tpkbd_data_pointer *data_pointer = hid_get_drvdata(hdev); struct hid_report *report; - struct tpkbd_data_pointer *data_pointer; int led_nr = 0; - dev = led_cdev->dev->parent; - hdev = container_of(dev, struct hid_device, dev); - data_pointer = (struct tpkbd_data_pointer *) hid_get_drvdata(hdev); - if (led_cdev == &data_pointer->led_micmute) led_nr = 1; @@ -508,13 +429,11 @@ err_free: static void tpkbd_remove_tp(struct hid_device *hdev) { - struct tpkbd_data_pointer *data_pointer; + struct tpkbd_data_pointer *data_pointer = hid_get_drvdata(hdev); sysfs_remove_group(&hdev->dev.kobj, &tpkbd_attr_group_pointer); - data_pointer = (struct tpkbd_data_pointer *) hid_get_drvdata(hdev); - led_classdev_unregister(&data_pointer->led_micmute); led_classdev_unregister(&data_pointer->led_mute); From a6fbaacfb990580c080e4fad6623b7108f5a0507 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Mon, 17 Sep 2012 16:41:56 +0530 Subject: [PATCH 17/20] HID: Fix return values in open_collection() Return -ENOMEM instead of -1 if memory allocation fails. Return -EINVAL instead of -1 for stack overflow and underflow errors. Signed-off-by: Sachin Kamat Signed-off-by: Jiri Kosina --- drivers/hid/hid-core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 8d3946af9ff6..62333e9dcb3a 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -126,7 +126,7 @@ static int open_collection(struct hid_parser *parser, unsigned type) if (parser->collection_stack_ptr == HID_COLLECTION_STACK_SIZE) { hid_err(parser->device, "collection stack overflow\n"); - return -1; + return -EINVAL; } if (parser->device->maxcollection == parser->device->collection_size) { @@ -134,7 +134,7 @@ static int open_collection(struct hid_parser *parser, unsigned type) parser->device->collection_size * 2, GFP_KERNEL); if (collection == NULL) { hid_err(parser->device, "failed to reallocate collection array\n"); - return -1; + return -ENOMEM; } memcpy(collection, parser->device->collection, sizeof(struct hid_collection) * @@ -170,7 +170,7 @@ static int close_collection(struct hid_parser *parser) { if (!parser->collection_stack_ptr) { hid_err(parser->device, "collection stack underflow\n"); - return -1; + return -EINVAL; } parser->collection_stack_ptr--; return 0; From ca9bbdcc89ecc1018215ec7f7e881840d40404c4 Mon Sep 17 00:00:00 2001 From: Stefan Achatz Date: Mon, 17 Sep 2012 16:04:19 +0200 Subject: [PATCH 18/20] HID: roccat: conditional blacklisting of Roccat modules Roccat devices are standard compatible, specific drivers are only needed for extended functionality. If Roccat drivers are not configured, hid-generic binds these devices now. Signed-off-by: Stefan Achatz Signed-off-by: Jiri Kosina --- drivers/hid/hid-core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 62333e9dcb3a..dd679a582c2c 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -1631,6 +1631,7 @@ static const struct hid_device_id hid_have_special_driver[] = { { HID_USB_DEVICE(USB_VENDOR_ID_ORTEK, USB_DEVICE_ID_ORTEK_WKB2000) }, { HID_USB_DEVICE(USB_VENDOR_ID_PETALYNX, USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE) }, { HID_USB_DEVICE(USB_VENDOR_ID_PRIMAX, USB_DEVICE_ID_PRIMAX_KEYBOARD) }, +#if IS_ENABLED(CONFIG_HID_ROCCAT) { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONE) }, { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_ARVO) }, { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_ISKU) }, @@ -1639,6 +1640,7 @@ static const struct hid_device_id hid_have_special_driver[] = { { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_PYRA_WIRED) }, { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_PYRA_WIRELESS) }, { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_SAVU) }, +#endif { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_PS1000) }, { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE) }, { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE) }, From 4cc9834518efed3b69d3a8ff3bd162e089f68d34 Mon Sep 17 00:00:00 2001 From: Wen-chien Jesse Sung Date: Tue, 25 Sep 2012 18:51:07 +0800 Subject: [PATCH 19/20] HID: ntrig: change default value of logical/physical width/height to 1 Since something will be divided by these variables in show_min_width()/show_min_height() and show_activate_width()/ show_activate_height(), a divided error would be triggered if they are zero. Signed-off-by: Wen-chien Jesse Sung Acked-by: Rafi Rubin Signed-off-by: Jiri Kosina --- drivers/hid/hid-ntrig.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/hid/hid-ntrig.c b/drivers/hid/hid-ntrig.c index 9fae2ebdd758..86a969f63292 100644 --- a/drivers/hid/hid-ntrig.c +++ b/drivers/hid/hid-ntrig.c @@ -882,10 +882,10 @@ static int ntrig_probe(struct hid_device *hdev, const struct hid_device_id *id) nd->activate_slack = activate_slack; nd->act_state = activate_slack; nd->deactivate_slack = -deactivate_slack; - nd->sensor_logical_width = 0; - nd->sensor_logical_height = 0; - nd->sensor_physical_width = 0; - nd->sensor_physical_height = 0; + nd->sensor_logical_width = 1; + nd->sensor_logical_height = 1; + nd->sensor_physical_width = 1; + nd->sensor_physical_height = 1; hid_set_drvdata(hdev, nd); From 86e6b77eb7cf9ca2e9c7092b4dfd588f0a3307b6 Mon Sep 17 00:00:00 2001 From: Kevin Daughtridge Date: Thu, 20 Sep 2012 12:00:32 -0700 Subject: [PATCH 20/20] HID: keep dev_rdesc unmodified and use it for comparisons The dev_rdesc member of the hid_device structure is meant to store the original report descriptor received from the device, but it is currently passed to any report_fixup method before it is copied to the rdesc member. This patch uses a temporary buffer to shield dev_rdesc from the side effects of many HID drivers' report_fixup implementations. usbhid's hid_post_reset checks the report descriptor currently returned by the device against a descriptor that may have been modified by a driver's report_fixup method. That leaves some devices nonfunctional after a resume, with a "reset_resume error 1" reported. This patch checks the new descriptor against the unmodified dev_rdesc instead and uses the original, instead of modified, report size. BugLink: http://bugs.launchpad.net/bugs/1049623 Signed-off-by: Kevin Daughtridge Signed-off-by: Jiri Kosina --- drivers/hid/hid-core.c | 20 +++++++++++++++----- drivers/hid/usbhid/hid-core.c | 6 +++--- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index dd679a582c2c..ec917690c263 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -757,6 +757,7 @@ int hid_open_report(struct hid_device *device) struct hid_item item; unsigned int size; __u8 *start; + __u8 *buf; __u8 *end; int ret; static int (*dispatch_type[])(struct hid_parser *parser, @@ -775,12 +776,21 @@ int hid_open_report(struct hid_device *device) return -ENODEV; size = device->dev_rsize; - if (device->driver->report_fixup) - start = device->driver->report_fixup(device, start, &size); - - device->rdesc = kmemdup(start, size, GFP_KERNEL); - if (device->rdesc == NULL) + buf = kmemdup(start, size, GFP_KERNEL); + if (buf == NULL) return -ENOMEM; + + if (device->driver->report_fixup) + start = device->driver->report_fixup(device, buf, &size); + else + start = buf; + + start = kmemdup(start, size, GFP_KERNEL); + kfree(buf); + if (start == NULL) + return -ENOMEM; + + device->rdesc = start; device->rsize = size; parser = vzalloc(sizeof(struct hid_parser)); diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c index dedd8e4e5c6d..8e0c4bf94ebc 100644 --- a/drivers/hid/usbhid/hid-core.c +++ b/drivers/hid/usbhid/hid-core.c @@ -1415,20 +1415,20 @@ static int hid_post_reset(struct usb_interface *intf) * configuration descriptors passed, we already know that * the size of the HID report descriptor has not changed. */ - rdesc = kmalloc(hid->rsize, GFP_KERNEL); + rdesc = kmalloc(hid->dev_rsize, GFP_KERNEL); if (!rdesc) { dbg_hid("couldn't allocate rdesc memory (post_reset)\n"); return 1; } status = hid_get_class_descriptor(dev, interface->desc.bInterfaceNumber, - HID_DT_REPORT, rdesc, hid->rsize); + HID_DT_REPORT, rdesc, hid->dev_rsize); if (status < 0) { dbg_hid("reading report descriptor failed (post_reset)\n"); kfree(rdesc); return 1; } - status = memcmp(rdesc, hid->rdesc, hid->rsize); + status = memcmp(rdesc, hid->dev_rdesc, hid->dev_rsize); kfree(rdesc); if (status != 0) { dbg_hid("report descriptor changed\n");