Skip to content

Commit cea09a5

Browse files
committed
drivers/usbhost_hub: Add support to Multiple TT HS HUB
This is the case for USB2517 USB HUB. Also improved the driver to avoid mistakes: initially I changed g_id[3], but the in register there is another field where we need to pass this size again. So it is better to use ARRAY_SIZE() macro to avoid mistakes. Signed-off-by: Alan C. Assis <acassis@gmail.com>
1 parent 8c91052 commit cea09a5

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

drivers/usbhost/usbhost_hub.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@
103103

104104
#define PORT_INDX(x) ((x) - 1)
105105

106+
/* Array size to avoid mistake adding new item to g_id */
107+
108+
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
109+
106110
/****************************************************************************
107111
* Private Types
108112
****************************************************************************/
@@ -184,7 +188,7 @@ static int usbhost_disconnected(FAR struct usbhost_class_s *hubclass);
184188
* used to associate the USB host hub class to a connected USB hub.
185189
*/
186190

187-
static const struct usbhost_id_s g_id[2] =
191+
static const struct usbhost_id_s g_id[] =
188192
{
189193
{
190194
USB_CLASS_HUB, /* base */
@@ -196,7 +200,14 @@ static const struct usbhost_id_s g_id[2] =
196200
{
197201
USB_CLASS_HUB, /* base */
198202
0, /* subclass */
199-
1, /* proto HS hub */
203+
1, /* proto Single TT HS hub */
204+
0, /* vid */
205+
0 /* pid */
206+
},
207+
{
208+
USB_CLASS_HUB, /* base */
209+
0, /* subclass */
210+
2, /* proto Multiple TT HS hub */
200211
0, /* vid */
201212
0 /* pid */
202213
}
@@ -208,7 +219,7 @@ static struct usbhost_registry_s g_hub =
208219
{
209220
NULL, /* flink */
210221
usbhost_create, /* create */
211-
2, /* nids */
222+
ARRAY_SIZE(g_id), /* nids */
212223
g_id /* id[] */
213224
};
214225

0 commit comments

Comments
 (0)