-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
usb: api: Cleanup of current inclusion path for USB #20236
Comments
By this commit public and private API is reworked. From user perspective unnecessary things are hidden by moving them from usb_device.h -> usb_dc.h. Endpoint related callbacks, structures, etc shall not be visuble to end user and thus are placed in device controller header file (usb_dc.h). Inclusion path is changed so that usb_device.h (public API) is no longer including (usb_dc.h). Right now, if user want to implement his own class or interact direclty with endpoints he needs to include usb_dc.h. This commit is solution for zephyrproject-rtos#20236. Signed-off-by: Emil Obalski <[email protected]>
@emob-nordic this seems like a change worth pursuing. Are you going to send a PR that addresses this particular issue? I think we should indeed do that. |
@carlescufi Yes, I am. I already have something prepared but its not clean enough to be candidate for PR. I will continue for that for sure. |
Great, thanks Emil. I really think this is worthwhile pursuing. |
Reworked as part of the introduction of the chapter 9 header. |
Introduction
USB public API should be reworked so user can see only what is necessary.
Problem description
User app shouldn't be aware of what is happening in the stack and in device controller.
Currently in the public API usb_device.h some additional structures, enums and callbacks are defined which should not bother user. For example:
Additionally usb_device.h includes usb_dc.h file, and by that users can see unnecessary declarations which should not be visible by them.
If we want users to use the classes and USB stack in proper way, We should avoid exposing unnecessary functionalities to them.
If anyone wants to use the USB devices directly and declare its own class then shall achieve that by including usb_dc.h
What is more. Current implementation creates unnecessary chaos. For example, have look at endpoint callback.
Both are exaclty the same, but someone once added this because he could not see it directly.
Proposed change
I suggest all mentioned structures, enum, callbacks, etc should be placed in usb_dc.h as this API actually interacts with devices directly.
Clean up API inclusion paths as now usb_device.h includes usb_dc.h. This should be done exactly the other way.
Detailed RFC
Proposed change (Detailed)
I came across this problem when facing point 1 from #13403 and initially my idea was to propose solution together with this PR #20044, however I've already started this work and it seems a big api change so I wont put this in one PR.
Dependencies
I don't see any but I might be missing something. This is strict USB topic IMO.
Concerns and Unresolved Questions
I count on You as I don't see any right now. Please feel free to comment.
Alternatives
??
The text was updated successfully, but these errors were encountered: