Skip to content
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

Closed
eobalski opened this issue Oct 30, 2019 · 4 comments
Closed

usb: api: Cleanup of current inclusion path for USB #20236

eobalski opened this issue Oct 30, 2019 · 4 comments
Assignees
Labels
area: USB Universal Serial Bus RFC Request For Comments: want input from the community

Comments

@eobalski
Copy link
Collaborator

eobalski commented Oct 30, 2019

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

??

@eobalski eobalski added area: USB Universal Serial Bus RFC Request For Comments: want input from the community labels Oct 30, 2019
eobalski pushed a commit to eobalski/zephyr that referenced this issue Nov 4, 2019
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 <emil.obalski@nordicsemi.no>
@carlescufi
Copy link
Member

@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.

@eobalski
Copy link
Collaborator Author

eobalski commented Nov 7, 2019

@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.

@carlescufi
Copy link
Member

@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.

@carlescufi
Copy link
Member

Reworked as part of the introduction of the chapter 9 header.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: USB Universal Serial Bus RFC Request For Comments: want input from the community
Projects
None yet
Development

No branches or pull requests

4 participants