[PATCH] usb: common: debug: Hex dump non-standard control requests

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



usb_decode_ctrl() only decodes standard control requests. Don't attempt
to decode non-standard requests. Just dump the content of the requests.

Signed-off-by: Thinh Nguyen <Thinh.Nguyen@xxxxxxxxxxxx>
---
 drivers/usb/common/debug.c | 31 +++++++++++++++++++++++--------
 1 file changed, 23 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/common/debug.c b/drivers/usb/common/debug.c
index 075f6b1b2a1a..cb38725f9276 100644
--- a/drivers/usb/common/debug.c
+++ b/drivers/usb/common/debug.c
@@ -208,6 +208,20 @@ static void usb_decode_set_isoch_delay(__u8 wValue, char *str, size_t size)
 	snprintf(str, size, "Set Isochronous Delay(Delay = %d ns)", wValue);
 }
 
+static void usb_hex_dump_ctrl(char *str, size_t size, __u8 bRequestType,
+			      __u8 bRequest, __u16 wValue, __u16 wIndex,
+			      __u16 wLength)
+{
+	snprintf(str, size, "%02x %02x %02x %02x %02x %02x %02x %02x",
+		 bRequestType, bRequest,
+		 (u8)(cpu_to_le16(wValue) & 0xff),
+		 (u8)(cpu_to_le16(wValue) >> 8),
+		 (u8)(cpu_to_le16(wIndex) & 0xff),
+		 (u8)(cpu_to_le16(wIndex) >> 8),
+		 (u8)(cpu_to_le16(wLength) & 0xff),
+		 (u8)(cpu_to_le16(wLength) >> 8));
+}
+
 /**
  * usb_decode_ctrl - Returns human readable representation of control request.
  * @str: buffer to return a human-readable representation of control request.
@@ -233,6 +247,12 @@ const char *usb_decode_ctrl(char *str, size_t size, __u8 bRequestType,
 			    __u8 bRequest, __u16 wValue, __u16 wIndex,
 			    __u16 wLength)
 {
+	if ((bRequestType & USB_TYPE_MASK) != USB_TYPE_STANDARD) {
+		usb_hex_dump_ctrl(str, size, bRequestType, bRequest,
+				  wValue, wIndex, wLength);
+		return str;
+	}
+
 	switch (bRequest) {
 	case USB_REQ_GET_STATUS:
 		usb_decode_get_status(bRequestType, wIndex, wLength, str, size);
@@ -272,14 +292,9 @@ const char *usb_decode_ctrl(char *str, size_t size, __u8 bRequestType,
 		usb_decode_set_isoch_delay(wValue, str, size);
 		break;
 	default:
-		snprintf(str, size, "%02x %02x %02x %02x %02x %02x %02x %02x",
-			 bRequestType, bRequest,
-			 (u8)(cpu_to_le16(wValue) & 0xff),
-			 (u8)(cpu_to_le16(wValue) >> 8),
-			 (u8)(cpu_to_le16(wIndex) & 0xff),
-			 (u8)(cpu_to_le16(wIndex) >> 8),
-			 (u8)(cpu_to_le16(wLength) & 0xff),
-			 (u8)(cpu_to_le16(wLength) >> 8));
+		usb_hex_dump_ctrl(str, size, bRequestType, bRequest,
+				  wValue, wIndex, wLength);
+		break;
 	}
 
 	return str;

base-commit: 46d2c20b0b10cf07a2a24b047a09195ba96c84f7
-- 
2.28.0




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux