Skip to content

Commit 8f73285

Browse files
bentissJiri Kosina
authored andcommitted
HID: core: allow concurrent registration of drivers
Detected on the Dell XPS 9365. The laptop has 2 devices that benefit from the hid-generic auto-unbinding. When those 2 devices are presented to the userspace, udev loads both wacom and hid-multitouch. When this happens, the code in __hid_bus_reprobe_drivers() is called concurrently and the second device gets reprobed twice. An other bug in the power_supply subsystem prevent to remove the wacom driver if it just finished its initialization, which basically kills the wacom node. [jkosina@suse.cz: reformat changelog a bit] Fixes c17a747 ("HID: core: rewrite the hid-generic automatic unbind") Cc: stable@vger.kernel.org # v4.17 Tested-by: Mario Limonciello <mario.limonciello@dell.com> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
1 parent d471b6b commit 8f73285

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

drivers/hid/hid-core.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1949,6 +1949,8 @@ static int hid_device_probe(struct device *dev)
19491949
}
19501950
hdev->io_started = false;
19511951

1952+
clear_bit(ffs(HID_STAT_REPROBED), &hdev->status);
1953+
19521954
if (!hdev->driver) {
19531955
id = hid_match_device(hdev, hdrv);
19541956
if (id == NULL) {
@@ -2212,7 +2214,8 @@ static int __hid_bus_reprobe_drivers(struct device *dev, void *data)
22122214
struct hid_device *hdev = to_hid_device(dev);
22132215

22142216
if (hdev->driver == hdrv &&
2215-
!hdrv->match(hdev, hid_ignore_special_drivers))
2217+
!hdrv->match(hdev, hid_ignore_special_drivers) &&
2218+
!test_and_set_bit(ffs(HID_STAT_REPROBED), &hdev->status))
22162219
return device_reprobe(dev);
22172220

22182221
return 0;

include/linux/hid.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,7 @@ struct hid_output_fifo {
511511
#define HID_STAT_ADDED BIT(0)
512512
#define HID_STAT_PARSED BIT(1)
513513
#define HID_STAT_DUP_DETECTED BIT(2)
514+
#define HID_STAT_REPROBED BIT(3)
514515

515516
struct hid_input {
516517
struct list_head list;
@@ -579,7 +580,7 @@ struct hid_device { /* device report descriptor */
579580
bool battery_avoid_query;
580581
#endif
581582

582-
unsigned int status; /* see STAT flags above */
583+
unsigned long status; /* see STAT flags above */
583584
unsigned claimed; /* Claimed by hidinput, hiddev? */
584585
unsigned quirks; /* Various quirks the device can pull on us */
585586
bool io_started; /* If IO has started */

0 commit comments

Comments
 (0)