From 44d4d51de9a3534a2b63d69efda02a10e66541e4 Mon Sep 17 00:00:00 2001 From: Zhouyang Jia Date: Thu, 14 Jun 2018 21:37:17 +0800 Subject: [PATCH 1/4] HID: hid-ntrig: add error handling for sysfs_create_group When sysfs_create_group fails, the lack of error-handling code may cause unexpected results. This patch adds error-handling code after calling sysfs_create_group. Signed-off-by: Zhouyang Jia Signed-off-by: Jiri Kosina --- drivers/hid/hid-ntrig.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/hid/hid-ntrig.c b/drivers/hid/hid-ntrig.c index 43b1c7234316..9bc6f4867cb3 100644 --- a/drivers/hid/hid-ntrig.c +++ b/drivers/hid/hid-ntrig.c @@ -955,6 +955,8 @@ static int ntrig_probe(struct hid_device *hdev, const struct hid_device_id *id) ret = sysfs_create_group(&hdev->dev.kobj, &ntrig_attribute_group); + if (ret) + hid_err(hdev, "cannot create sysfs group\n"); return 0; err_free: From dc9b8e85ed95cbe7e3ad0eabb5b48d617bbc365e Mon Sep 17 00:00:00 2001 From: Robert Munteanu Date: Tue, 19 Jun 2018 11:20:40 +0300 Subject: [PATCH 2/4] HID: redragon: fix num lock and caps lock LEDs The redragon asura keyboard registers two input devices. The initial commit 85455dd906d5 ("HID: redragon: Fix modifier keys for Redragon Asura Keyboard") considered this an error and prevented one of the devices from registering. However, once this is done the num lock and caps lock leds no longer toggle on and off, although the key functionality is not affected. This commit removes the code that prevents the input device registration and restores the num lock and caps lock LEDs. Fixes: 85455dd906d5 ("HID: redragon: Fix modifier keys for Redragon Asura Keyboard") Signed-off-by: Robert Munteanu Signed-off-by: Jiri Kosina --- drivers/hid/hid-redragon.c | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/drivers/hid/hid-redragon.c b/drivers/hid/hid-redragon.c index daf59578bf93..73c9d4c4fa34 100644 --- a/drivers/hid/hid-redragon.c +++ b/drivers/hid/hid-redragon.c @@ -44,29 +44,6 @@ static __u8 *redragon_report_fixup(struct hid_device *hdev, __u8 *rdesc, return rdesc; } -static int redragon_probe(struct hid_device *dev, - const struct hid_device_id *id) -{ - int ret; - - ret = hid_parse(dev); - if (ret) { - hid_err(dev, "parse failed\n"); - return ret; - } - - /* do not register unused input device */ - if (dev->maxapplication == 1) - return 0; - - ret = hid_hw_start(dev, HID_CONNECT_DEFAULT); - if (ret) { - hid_err(dev, "hw start failed\n"); - return ret; - } - - return 0; -} static const struct hid_device_id redragon_devices[] = { {HID_USB_DEVICE(USB_VENDOR_ID_JESS, USB_DEVICE_ID_REDRAGON_ASURA)}, {} @@ -77,8 +54,7 @@ MODULE_DEVICE_TABLE(hid, redragon_devices); static struct hid_driver redragon_driver = { .name = "redragon", .id_table = redragon_devices, - .report_fixup = redragon_report_fixup, - .probe = redragon_probe + .report_fixup = redragon_report_fixup }; module_hid_driver(redragon_driver); From f49255e00c2e085b1467087d2dbb6b01d7042cc8 Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Tue, 19 Jun 2018 23:59:44 +0200 Subject: [PATCH 3/4] HID: usbhid: use irqsave() in USB's complete callback The USB completion callback does not disable interrupts while acquiring the ->lock. We want to remove the local_irq_disable() invocation from __usb_hcd_giveback_urb() and therefore it is required for the callback handler to disable the interrupts while acquiring the lock. The callback may be invoked either in IRQ or BH context depending on the USB host controller. Use the _irqsave() variant of the locking primitives. Cc: Jiri Kosina Cc: Benjamin Tissoires Cc: linux-input@vger.kernel.org Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Jiri Kosina --- drivers/hid/usbhid/hid-core.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c index af0e0d061b15..11103efebbaa 100644 --- a/drivers/hid/usbhid/hid-core.c +++ b/drivers/hid/usbhid/hid-core.c @@ -480,6 +480,7 @@ static void hid_ctrl(struct urb *urb) { struct hid_device *hid = urb->context; struct usbhid_device *usbhid = hid->driver_data; + unsigned long flags; int unplug = 0, status = urb->status; switch (status) { @@ -501,7 +502,7 @@ static void hid_ctrl(struct urb *urb) hid_warn(urb->dev, "ctrl urb status %d received\n", status); } - spin_lock(&usbhid->lock); + spin_lock_irqsave(&usbhid->lock, flags); if (unplug) { usbhid->ctrltail = usbhid->ctrlhead; @@ -511,13 +512,13 @@ static void hid_ctrl(struct urb *urb) if (usbhid->ctrlhead != usbhid->ctrltail && hid_submit_ctrl(hid) == 0) { /* Successfully submitted next urb in queue */ - spin_unlock(&usbhid->lock); + spin_unlock_irqrestore(&usbhid->lock, flags); return; } } clear_bit(HID_CTRL_RUNNING, &usbhid->iofl); - spin_unlock(&usbhid->lock); + spin_unlock_irqrestore(&usbhid->lock, flags); usb_autopm_put_interface_async(usbhid->intf); wake_up(&usbhid->wait); } From 7f342e9c61d7932b7b3dd8a0b9c2768fe7ca3436 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Mon, 2 Jul 2018 10:40:28 +0100 Subject: [PATCH 4/4] HID: intel-ish-hid: remove redundant variable num_frags Variable num_frags is being assigned but is never used hence it is redundant and can be removed. Cleans up clang warning: warning: variable 'num_frags' set but not used [-Wunused-but-set-variable] Signed-off-by: Colin Ian King Signed-off-by: Jiri Kosina --- drivers/hid/intel-ish-hid/ishtp/hbm.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/hid/intel-ish-hid/ishtp/hbm.c b/drivers/hid/intel-ish-hid/ishtp/hbm.c index ae4a69f7f2f4..8b5dd580ceec 100644 --- a/drivers/hid/intel-ish-hid/ishtp/hbm.c +++ b/drivers/hid/intel-ish-hid/ishtp/hbm.c @@ -298,7 +298,6 @@ int ishtp_hbm_cl_flow_control_req(struct ishtp_device *dev, struct ishtp_msg_hdr *ishtp_hdr = &hdr; const size_t len = sizeof(struct hbm_flow_control); int rv; - unsigned int num_frags; unsigned long flags; spin_lock_irqsave(&cl->fc_spinlock, flags); @@ -314,7 +313,6 @@ int ishtp_hbm_cl_flow_control_req(struct ishtp_device *dev, return 0; } - num_frags = cl->recv_msg_num_frags; cl->recv_msg_num_frags = 0; rv = ishtp_write_message(dev, ishtp_hdr, data);