-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Support multiple devices to connect with usb host if usb hub is used #99591
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Support multiple devices to connect with usb host if usb hub is used #99591
Conversation
091e8b6 to
0be1c7c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Some discussion about it below.
subsys/usb/host/usbh_device.c
Outdated
| SYS_DLIST_FOR_EACH_NODE(&uhs_ctx->udevs, node) { | ||
| device_count++; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can use device_count = sys_dlist_len(&uhs_ctx->udevs); in this case.
But let's discuss on https://github.com/zephyrproject-rtos/zephyr/pull/99591/files#r2538708506 first?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@
I think you can use
device_count = sys_dlist_len(&uhs_ctx->udevs);in this case.But let's discuss on https://github.com/zephyrproject-rtos/zephyr/pull/99591/files#r2538708506 first?
@josuah agree, already done for sys_dlist_len
| if (device_count == 1U) { | ||
| err = uhc_bus_reset(uhs_ctx->dev); | ||
| if (err) { | ||
| LOG_ERR("Failed to signal bus reset"); | ||
| return err; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about PORT_RESET hub class feature? Where this should be handled? At high-level Linux solves the issue by having a software-only hub at the top level.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about PORT_RESET hub class feature? Where this should be handled? At high-level Linux solves the issue by having a software-only hub at the top level.
Hi @tmon-nordic
The PORT_RESET of HUB is handled by a set feature request. This is handled in hub class layer. Actually I have finished the first version USB hub class and tested in my local project. Recently I will created one PR about it.
When hub is used, need to consider about multiple devices are attached. Signed-off-by: Aiden Hu <[email protected]>
46ef4c9 to
111a8d6
Compare
111a8d6 to
caaeeff
Compare
|
@josuah |
subsys/usb/host/usbh_core.c
Outdated
|
|
||
| udev = usbh_device_get_root(ctx); | ||
|
|
||
| if (udev) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comparing explicitly against NULL helps with MISRA compliance.
See rule 85 here:
https://docs.zephyrproject.org/latest/contribute/coding_guidelines/index.html#coding-guidelines
This is not strictly applied, as I remember, but it can also help keeping the code a bit more homogene.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comparing explicitly against
NULLhelps with MISRA compliance.See rule 85 here: https://docs.zephyrproject.org/latest/contribute/coding_guidelines/index.html#coding-guidelines
This is not strictly applied, as I remember, but it can also help keeping the code a bit more homogene.
Thanks, fixed it as the rule.
add usbh_device_get_root and usbh_device_is_root function to check root device Signed-off-by: Aiden Hu <[email protected]>
caaeeff to
4f2a48f
Compare
|




When USB hub is used, maybe multiple devices are attached, so need to consider about this.