Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions drivers/usbhost/usbhost_hub.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@

#define INTIN_BUFSIZE ((USBHUB_MAX_PORTS + 8) >> 3)

/* Convert 0-based index to port number. */

#define PORT_NO(x) ((x) + 1)

/* Convert port number to 0-based index. */

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

/****************************************************************************
* Private Types
****************************************************************************/
Expand Down Expand Up @@ -223,7 +231,7 @@ static struct usbhost_registry_s g_hub =
static void usbhost_hport_deactivate(FAR struct usbhost_hubport_s *hport)
{
uinfo("Deactivating: %s port %d\n",
ROOTHUB(hport) ? "Root" : "Hub", hport->port);
ROOTHUB(hport) ? "Root" : "Hub", PORT_NO(hport->port));

/* Don't free the control pipe of root hub ports! */

Expand Down Expand Up @@ -268,7 +276,7 @@ static int usbhost_hport_activate(FAR struct usbhost_hubport_s *hport)
struct usbhost_epdesc_s epdesc;
int ret;

uinfo("Activating port %d\n", hport->port);
uinfo("Activating port %d\n", PORT_NO(hport->port));

epdesc.hport = hport;
epdesc.addr = 0;
Expand Down Expand Up @@ -907,7 +915,7 @@ static void usbhost_hub_event(FAR void *arg)
DRVR_CTRLOUT(hport->drvr, hport->ep0, ctrlreq, NULL);
}

connport = &priv->hport[port];
connport = &priv->hport[PORT_INDX(port)];
if ((status & USBHUB_PORT_STAT_HIGH_SPEED) != 0)
{
connport->speed = USB_SPEED_HIGH;
Expand Down Expand Up @@ -961,7 +969,7 @@ static void usbhost_hub_event(FAR void *arg)

/* Free any devices classes connect on this hub port */

connport = &priv->hport[port];
connport = &priv->hport[PORT_INDX(port)];
if (connport->devclass != NULL)
{
CLASS_DISCONNECTED(connport->devclass);
Expand Down Expand Up @@ -1071,7 +1079,7 @@ static void usbhost_disconnect_event(FAR void *arg)
priv = &((FAR struct usbhost_hubclass_s *)hubclass)->hubpriv;
hport = hubclass->hport;

uinfo("Destroying hub on port %d\n", hport->port);
uinfo("Destroying hub on port %d\n", PORT_NO(hport->port));

/* Set an indication to any users of the device that the device is no
* longer available.
Expand Down