Skip to contentSkip to conversation

USB: Adding #define in hub_configure() and hcd.c file

PATCH In review Aman Deep 2 participants 2 messages Dec 8, 2011 – Dec 9, 2011 USB

lore
Share & tools
lore

Aman Deep

author
#0 lore raw

PATCH 1/1 USB: Adding #define in hub_configure() and hcd.c file

This patch is in succession of previous patch commit c8421147926fcacf53081a36438a0bed394da9f5
xHCI: Adding #define values used for hub descriptor

Hub descriptors characteristics #defines values are added in hub_configure() in place of magic numbers as asked by Alan Stern. And the indentation for switch and case is changed to be same.

Some #defines values are added in ch11.h for defining hub class protocols and used in hub.c and hcd.c in which magic values were used for hub class protocols.

---
 drivers/usb/core/hcd.c   |    2 +-
 drivers/usb/core/hub.c   |   88 +++++++++++++++++++++++-----------------------
 include/linux/usb/ch11.h |   11 ++++++
 3 files changed, 56 insertions(+), 45 deletions(-)
drivers/usb/core/hcd.c +1 -1
index 13222d3..13d75a0 100644
@@ -658,7 +658,7 @@ error:
 				len > offsetof(struct usb_device_descriptor,
 						bDeviceProtocol))
 			((struct usb_device_descriptor *) ubuf)->
-					bDeviceProtocol = 1;
+				bDeviceProtocol = USB_HUB_PR_HS_SINGLE_TT;
 	}
 
 	/* any errors get returned through the urb completion */
drivers/usb/core/hub.c +44 -44

109 lines not on this page · raw message

include/linux/usb/ch11.h +11 -0
index 537f354..ad6942b 100644
@@ -207,6 +207,17 @@ struct usb_hub_status {
 #define USB_DT_HUB_NONVAR_SIZE		7
 #define USB_DT_SS_HUB_SIZE              12
 
+/*
+ * Hub Device descriptor
+ * USB Hub class device protocols
+ */
+
+#define USB_HUB_PR_FS		0 /* Full speed hub */
+#define USB_HUB_PR_HS_NO_TT	0 /* Hi-speed hub without TT */
+#define USB_HUB_PR_HS_SINGLE_TT	1 /* Hi-speed hub with single TT */
+#define USB_HUB_PR_HS_MULTI_TT	2 /* Hi-speed hub with multiple TT */
+#define USB_HUB_PR_SS		3 /* Super speed hub */
+
 struct usb_hub_descriptor {
 	__u8  bDescLength;
 	__u8  bDescriptorType;
Signature · 1 line
1.7.6
#1 lore raw
Quoted 8 lines · Aman Deep

This patch is in succession of previous patch commit c8421147926fcacf53081a36438a0bed394da9f5
xHCI: Adding #define values used for hub descriptor

Hub descriptors characteristics #defines values are added in hub_configure() in place of magic numbers as asked by Alan Stern. And the indentation for switch and case is changed to be same.

Quoted 5 lines

Some #defines values are added in ch11.h for defining hub class protocols and used in hub.c and hcd.c in which magic values were used for hub class protocols.

I like it!

If you're looking for more things to work on, consider the #defines in ch11.h for the various port features and statuses. Some of the newer USB-3 entries were added in the wrong place, or even added twice! It would be good to get that straightened up.

Alan Stern