From: Ana Bobillo <[email protected]>

A hub's per-port state is sized by USB_MAXCHILDREN: the DeviceRemovable
and PortPowerCtrlMask bitmaps and overcurrent_count[] in struct
usb_hub_device, and children[] in struct usb_device without driver
model. At 8 this is below the port count of many root hubs. An xHCI root
hub reports every USB 2 and USB 3 port of its controller (HCS_MAX_PORTS),
more than 8 on many PC chipsets, and usb_scan_port() then counts
over-current events past the end of overcurrent_count[] for the higher
ports.

Use 31, as Linux does: the port bitmaps, with their bit for the hub
itself, then fill four bytes. A following patch keeps
usb_hub_configure() from using more ports than this.

This grows struct usb_hub_device by 96 bytes and, without driver model,
children[] by 23 pointers: about 4.4 KiB more BSS on a 32-bit board
without driver model (USB_MAX_DEVICE devices, USB_MAX_HUB hubs).

Signed-off-by: Ana Bobillo <[email protected]>
---
 include/usb.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/usb.h b/include/usb.h
index dab23753f0c..76a3efa49d3 100644
--- a/include/usb.h
+++ b/include/usb.h
@@ -38,7 +38,7 @@ extern bool usb_started; /* flag for the started/stopped USB 
status */
 #define USB_MAXCONFIG                  8
 #define USB_MAXINTERFACES              8
 #define USB_MAXENDPOINTS               16
-#define USB_MAXCHILDREN                        8       /* This is arbitrary */
+#define USB_MAXCHILDREN                        31      /* As Linux: the port 
bitmaps fit 4 bytes */
 #define USB_MAX_HUB                    16
 
 #define USB_CNTL_TIMEOUT 100 /* 100ms timeout */

Reply via email to