Skip to contentSkip to conversation

HID: usbhid: fix "always poll" quirk

PATCH In review Dmitry Torokhov 3 participants 3 messages Jul 13, 2017 – Jul 21, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 HID: usbhid: fix "always poll" quirk

Even though the IO for devices with "always poll" quirk is already running, we still need to set HID_OPENED bit in usbhid->iofl so the interrupt handler does not ignore the data coming from the device.

Fixes e399396a6b0 ("HID: usbhid: remove custom locking from usbhid_open...")
---
 drivers/hid/usbhid/hid-core.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/hid/usbhid/hid-core.c +5 -4
index 76013eb5cb7f..c008847e0b20 100644
@@ -680,18 +680,21 @@ static int usbhid_open(struct hid_device *hid)
 	struct usbhid_device *usbhid = hid->driver_data;
 	int res;
 
+	set_bit(HID_OPENED, &usbhid->iofl);
+
 	if (hid->quirks & HID_QUIRK_ALWAYS_POLL)
 		return 0;
 
 	res = usb_autopm_get_interface(usbhid->intf);
 	/* the device must be awake to reliably request remote wakeup */
-	if (res < 0)
+	if (res < 0) {
+		clear_bit(HID_OPENED, &usbhid->iofl);
 		return -EIO;
+	}
 
 	usbhid->intf->needs_remote_wakeup = 1;
 
 	set_bit(HID_RESUME_RUNNING, &usbhid->iofl);
-	set_bit(HID_OPENED, &usbhid->iofl);
 	set_bit(HID_IN_POLLING, &usbhid->iofl);
 
 	res = hid_start_in(hid);
@@ -727,19 +730,20 @@ static void usbhid_close(struct hid_device *hid)
 {
 	struct usbhid_device *usbhid = hid->driver_data;
 
-	if (hid->quirks & HID_QUIRK_ALWAYS_POLL)
-		return;
Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Dmitry Torokhov

Even though the IO for devices with "always poll" quirk is already running, we still need to set HID_OPENED bit in usbhid->iofl so the interrupt handler does not ignore the data coming from the device.

Fixes e399396a6b0 ("HID: usbhid: remove custom locking from usbhid_open...")

---

slightly reviewed and

Cheers,
Benjamin

Quoted 62 lines
 drivers/hid/usbhid/hid-core.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/hid/usbhid/hid-core.c +10 -6
index 76013eb5cb7f..c008847e0b20 100644
@@ -680,18 +680,21 @@ static int usbhid_open(struct hid_device *hid)
 	struct usbhid_device *usbhid = hid->driver_data;
 	int res;
 
+	set_bit(HID_OPENED, &usbhid->iofl);
+
 	if (hid->quirks & HID_QUIRK_ALWAYS_POLL)
 		return 0;
 
 	res = usb_autopm_get_interface(usbhid->intf);
 	/* the device must be awake to reliably request remote wakeup */
-	if (res < 0)
+	if (res < 0) {
+		clear_bit(HID_OPENED, &usbhid->iofl);
 		return -EIO;
+	}
 
 	usbhid->intf->needs_remote_wakeup = 1;
 
 	set_bit(HID_RESUME_RUNNING, &usbhid->iofl);
-	set_bit(HID_OPENED, &usbhid->iofl);
 	set_bit(HID_IN_POLLING, &usbhid->iofl);
 
 	res = hid_start_in(hid);
@@ -727,19 +730,20 @@ static void usbhid_close(struct hid_device *hid)
 {
 	struct usbhid_device *usbhid = hid->driver_data;
 
-	if (hid->quirks & HID_QUIRK_ALWAYS_POLL)
-		return;
-
 	/*
 	 * Make sure we don't restart data acquisition due to
 	 * a resumption we no longer care about by avoiding racing
 	 * with hid_start_in().
 	 */
 	spin_lock_irq(&usbhid->lock);
-	clear_bit(HID_IN_POLLING, &usbhid->iofl);
 	clear_bit(HID_OPENED, &usbhid->iofl);
+	if (!(hid->quirks & HID_QUIRK_ALWAYS_POLL))
+		clear_bit(HID_IN_POLLING, &usbhid->iofl);
 	spin_unlock_irq(&usbhid->lock);
 
+	if (hid->quirks & HID_QUIRK_ALWAYS_POLL)
+		return;
+
 	hid_cancel_delayed_stuff(usbhid);
 	usb_kill_urb(usbhid->urbin);
 	usbhid->intf->needs_remote_wakeup = 0;
Signature · 5 lines
2.13.2.932.g7449e964c-goog


-- 
Dmitry
maintainer
#2 lore raw
In reply to Dmitry Torokhov
Quoted 8 lines · Dmitry Torokhov

Even though the IO for devices with "always poll" quirk is already running, we still need to set HID_OPENED bit in usbhid->iofl so the interrupt handler does not ignore the data coming from the device.

Fixes e399396a6b0 ("HID: usbhid: remove custom locking from usbhid_open...")

Ah, pitty I've missed this one for the yesterday pull request, sorry for that. Applied now to for-4.13/upstream-fixes and will be sending upstream next week.

Thanks,

Signature · 2 lines
Jiri Kosina
SUSE Labs