* [RFC 1/2] hid: usbhid: call usb_queue_reset_device directly
@ 2026-03-25 10:31 Oliver Neukum
2026-03-25 10:31 ` [RFC 2/2] hid: usbhid: rename reset_work Oliver Neukum
0 siblings, 1 reply; 2+ messages in thread
From: Oliver Neukum @ 2026-03-25 10:31 UTC (permalink / raw)
To: linux-usb; +Cc: Oliver Neukum
There is no point in scheduling a work to schedule another
work. Just schedule it directly.
Signed-off-by: Oliver Neukum <oneukum@suse.com>
---
drivers/hid/usbhid/hid-core.c | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index fd3e1aedc5cb..a70721b3add6 100644
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -132,13 +132,9 @@ static void hid_reset(struct work_struct *work)
dev_dbg(&usbhid->intf->dev,
"clear-halt failed: %d\n", rc);
set_bit(HID_RESET_PENDING, &usbhid->iofl);
+ usb_queue_reset_device(usbhid->intf);
}
}
-
- if (test_bit(HID_RESET_PENDING, &usbhid->iofl)) {
- dev_dbg(&usbhid->intf->dev, "resetting device\n");
- usb_queue_reset_device(usbhid->intf);
- }
}
/* Main I/O error handler */
@@ -171,7 +167,7 @@ static void hid_io_error(struct hid_device *hid)
if (!test_bit(HID_NO_BANDWIDTH, &usbhid->iofl)
&& !test_and_set_bit(HID_RESET_PENDING, &usbhid->iofl)) {
- schedule_work(&usbhid->reset_work);
+ usb_queue_reset_device(usbhid->intf);
goto done;
}
}
@@ -1496,18 +1492,18 @@ static void hid_restart_io(struct hid_device *hid)
{
struct usbhid_device *usbhid = hid->driver_data;
int clear_halt = test_bit(HID_CLEAR_HALT, &usbhid->iofl);
- int reset_pending = test_bit(HID_RESET_PENDING, &usbhid->iofl);
spin_lock_irq(&usbhid->lock);
clear_bit(HID_SUSPENDED, &usbhid->iofl);
usbhid_mark_busy(usbhid);
- if (clear_halt || reset_pending)
+ if (clear_halt)
schedule_work(&usbhid->reset_work);
+
usbhid->retry_delay = 0;
spin_unlock_irq(&usbhid->lock);
- if (reset_pending || !test_bit(HID_STARTED, &usbhid->iofl))
+ if (!test_bit(HID_STARTED, &usbhid->iofl))
return;
if (!clear_halt) {
--
2.53.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* [RFC 2/2] hid: usbhid: rename reset_work
2026-03-25 10:31 [RFC 1/2] hid: usbhid: call usb_queue_reset_device directly Oliver Neukum
@ 2026-03-25 10:31 ` Oliver Neukum
0 siblings, 0 replies; 2+ messages in thread
From: Oliver Neukum @ 2026-03-25 10:31 UTC (permalink / raw)
To: linux-usb; +Cc: Oliver Neukum
Now that reset is used directly, there is no point
in calling the generic error handling reset_work.
Signed-off-by: Oliver Neukum <oneukum@suse.com>
---
drivers/hid/usbhid/hid-core.c | 14 +++++++-------
drivers/hid/usbhid/usbhid.h | 2 +-
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index a70721b3add6..6cfdfc2be68b 100644
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -114,11 +114,11 @@ static void hid_retry_timeout(struct timer_list *t)
hid_io_error(hid);
}
-/* Workqueue routine to reset the device or clear a halt */
-static void hid_reset(struct work_struct *work)
+/* Workqueue routine to clear a halt */
+static void hid_err_work(struct work_struct *work)
{
struct usbhid_device *usbhid =
- container_of(work, struct usbhid_device, reset_work);
+ container_of(work, struct usbhid_device, error_work);
struct hid_device *hid = usbhid->hid;
int rc;
@@ -297,7 +297,7 @@ static void hid_irq_in(struct urb *urb)
usbhid_mark_busy(usbhid);
clear_bit(HID_IN_RUNNING, &usbhid->iofl);
set_bit(HID_CLEAR_HALT, &usbhid->iofl);
- schedule_work(&usbhid->reset_work);
+ schedule_work(&usbhid->error_work);
return;
case -ECONNRESET: /* unlink */
case -ENOENT:
@@ -1438,7 +1438,7 @@ static int usbhid_probe(struct usb_interface *intf, const struct usb_device_id *
usbhid->ifnum = interface->desc.bInterfaceNumber;
init_waitqueue_head(&usbhid->wait);
- INIT_WORK(&usbhid->reset_work, hid_reset);
+ INIT_WORK(&usbhid->error_work, hid_err_work);
timer_setup(&usbhid->io_retry, hid_retry_timeout, 0);
spin_lock_init(&usbhid->lock);
mutex_init(&usbhid->mutex);
@@ -1477,7 +1477,7 @@ static void usbhid_disconnect(struct usb_interface *intf)
static void hid_cancel_delayed_stuff(struct usbhid_device *usbhid)
{
timer_delete_sync(&usbhid->io_retry);
- cancel_work_sync(&usbhid->reset_work);
+ cancel_work_sync(&usbhid->error_work);
}
static void hid_cease_io(struct usbhid_device *usbhid)
@@ -1498,7 +1498,7 @@ static void hid_restart_io(struct hid_device *hid)
usbhid_mark_busy(usbhid);
if (clear_halt)
- schedule_work(&usbhid->reset_work);
+ schedule_work(&usbhid->error_work);
usbhid->retry_delay = 0;
spin_unlock_irq(&usbhid->lock);
diff --git a/drivers/hid/usbhid/usbhid.h b/drivers/hid/usbhid/usbhid.h
index 75fe85d3d27a..530dca7e5ef3 100644
--- a/drivers/hid/usbhid/usbhid.h
+++ b/drivers/hid/usbhid/usbhid.h
@@ -86,7 +86,7 @@ struct usbhid_device {
struct timer_list io_retry; /* Retry timer */
unsigned long stop_retry; /* Time to give up, in jiffies */
unsigned int retry_delay; /* Delay length in ms */
- struct work_struct reset_work; /* Task context for resets */
+ struct work_struct error_work; /* Task context for earing halts*/
wait_queue_head_t wait; /* For sleeping */
};
--
2.53.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-03-25 10:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-25 10:31 [RFC 1/2] hid: usbhid: call usb_queue_reset_device directly Oliver Neukum
2026-03-25 10:31 ` [RFC 2/2] hid: usbhid: rename reset_work Oliver Neukum
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox