usbhost: Fix function address generation for multi-port root hubs.

Devices connected to the same USB bus should have unique function addresses.
This was not true for root hubs with multiple ports. After this change,
enumeration is more reliable on the sama5d3-xplained board when both root hub
ports are used.

This change amounts to using one usbhost_devaddr_s object per root hub
instead of one per root hub port. For the majority of boards only one
root hub port is available so no change in behavior should be expected.
This commit is contained in:
Lwazi Dube
2023-05-10 20:05:21 -04:00
committed by Alin Jerpelea
parent 4ed48c33e9
commit d66282a893
22 changed files with 118 additions and 58 deletions
+16 -10
View File
@@ -182,7 +182,7 @@ usbhost_devaddr_gen(FAR struct usbhost_hubport_s *hport)
rhport = usbhost_roothubport(hport);
if (rhport != NULL)
{
return &rhport->devgen;
return rhport->pdevgen;
}
return NULL;
@@ -201,23 +201,29 @@ usbhost_devaddr_gen(FAR struct usbhost_hubport_s *hport)
* hub port.
*
* Input Parameters:
* rhport - A reference to a roothubport structure.
* devgen - A reference to a usbhost_devaddr_s structure.
*
* Returned Value:
* None
* On success, zero (OK) is returned. On a failure, a negated errno value
* is returned indicating the nature of the failure.
*
****************************************************************************/
void usbhost_devaddr_initialize(FAR struct usbhost_roothubport_s *rhport)
int usbhost_devaddr_initialize(FAR struct usbhost_devaddr_s *devgen)
{
FAR struct usbhost_devaddr_s *devgen;
int ret = -EINVAL;
DEBUGASSERT(rhport);
devgen = &rhport->devgen;
DEBUGASSERT(devgen);
memset(devgen, 0, sizeof(struct usbhost_devaddr_s));
nxmutex_init(&devgen->lock);
devgen->next = 1;
if (devgen)
{
memset(devgen, 0, sizeof(struct usbhost_devaddr_s));
nxmutex_init(&devgen->lock);
devgen->next = 1;
ret = OK;
}
return ret;
}
/****************************************************************************