Skip to contentSkip to conversation

USB: fix control-message timeouts

PATCH New Johan Hovold 1 participant 3 messages Oct 25, 2021

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

cover USB: fix control-message timeouts

A number of drivers throughout the tree were using timeout values in jiffies instead of milliseconds.

This series fixes a broken USB documentation example and the single driver in the USB subtree that got it wrong.

Johan

Johan Hovold (2):
Documentation: USB: fix example bulk-message timeout
USB: iowarrior: fix control-message timeouts

 Documentation/driver-api/usb/writing_usb_driver.rst | 2 +-
 drivers/usb/misc/iowarrior.c                        | 8 ++------
 2 files changed, 3 insertions(+), 7 deletions(-)
Signature · 1 line
2.32.0
#1 lore raw

PATCH 1/2 Documentation: USB: fix example bulk-message timeout

USB bulk-message timeouts are specified in milliseconds and should specifically not vary with CONFIG_HZ.

Use a fixed five-second timeout in the "Writing USB Device Drivers" example.

---
 Documentation/driver-api/usb/writing_usb_driver.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/driver-api/usb/writing_usb_driver.rst +1 -1
index 2176297e5765..4356f023065b 100644
@@ -231,7 +231,7 @@ error message. This can be shown with the following code::
 			   skel->bulk_in_endpointAddr),
 			   skel->bulk_in_buffer,
 			   skel->bulk_in_size,
-			   &count, HZ*10);
+			   &count, 5000);
     /* if the read was successful, copy the data to user space */
     if (!retval) {
 	    if (copy_to_user (buffer, skel->bulk_in_buffer, count))
Signature · 1 line
2.32.0
#2 lore raw

PATCH 2/2 USB: iowarrior: fix control-message timeouts

In reply to Johan Hovold

USB control-message timeouts are specified in milliseconds and should specifically not vary with CONFIG_HZ.

Use the common control-message timeout define for the five-second timeout and drop the driver-specific one.

Fixes 946b960d13c1 ("USB: add driver for iowarrior devices.")
Cc [email protected] # 2.6.21
---
 drivers/usb/misc/iowarrior.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/usb/misc/iowarrior.c +2 -6
index efbd317f2f25..988a8c02e7e2 100644
@@ -99,10 +99,6 @@ struct iowarrior {
 /*    globals   */
 /*--------------*/
 
-/*
- *  USB spec identifies 5 second timeouts.
- */
-#define GET_TIMEOUT 5
 #define USB_REQ_GET_REPORT  0x01
 //#if 0
 static int usb_get_report(struct usb_device *dev,
@@ -114,7 +110,7 @@ static int usb_get_report(struct usb_device *dev,
 			       USB_DIR_IN | USB_TYPE_CLASS |
 			       USB_RECIP_INTERFACE, (type << 8) + id,
 			       inter->desc.bInterfaceNumber, buf, size,
-			       GET_TIMEOUT*HZ);
+			       USB_CTRL_GET_TIMEOUT);
 }
 //#endif
 
@@ -129,7 +125,7 @@ static int usb_set_report(struct usb_interface *intf, unsigned char type,
 			       USB_TYPE_CLASS | USB_RECIP_INTERFACE,
 			       (type << 8) + id,
 			       intf->cur_altsetting->desc.bInterfaceNumber, buf,
-			       size, HZ);
+			       size, 1000);
 }
 
 /*---------------------*/
Signature · 1 line
2.32.0