-
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
[topic-usb]usb: remove obsolete request handlers array #26854
[topic-usb]usb: remove obsolete request handlers array #26854
Conversation
I think We should also update drivers to use new struct and delete all of this. |
yes, but I wanted to discuss it first. |
subsys/usb/usb_device.c
Outdated
if (handler == NULL) { | ||
LOG_DBG("No handler for reqtype %d", type); | ||
switch (setup->RequestType.type) { | ||
case REQTYPE_TYPE_STANDARD: |
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.
nit: change the double space to a single space.
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, will fix (@nzmichaelh Please "request changes" for this kind of issues)
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.
fixed
include/usb/usb_device.h
Outdated
@@ -81,9 +81,24 @@ extern "C" { | |||
* USB application interface | |||
**************************************************************************/ | |||
|
|||
struct usb_req_type_field { | |||
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ |
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.
In Bluetooth we do it the same way:
https://github.com/zephyrproject-rtos/zephyr/blob/master/subsys/bluetooth/controller/ll_sw/pdu.h#L192
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 it is perfectly fine to use bitfields in packed structures, provided the endian macros are used like in this example.
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.
LGTM
3b893b0
to
839b40f
Compare
@emob-nordic please review |
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.
Nothing against, just wondering if shouldn't we reorganize the file and avoid declarations.
static int usb_handle_standard_request(struct usb_setup_packet *setup, | ||
int32_t *len, uint8_t **data_buf); | ||
static int class_handler(struct usb_setup_packet *pSetup, | ||
int32_t *len, uint8_t **data); | ||
static int vendor_handler(struct usb_setup_packet *pSetup, | ||
int32_t *len, uint8_t **data); | ||
static int custom_handler(struct usb_setup_packet *pSetup, | ||
int32_t *len, uint8_t **data); | ||
|
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.
This could actually be avoided, don't You want to do that?
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 agree, it is temporary, I did not want to do it yet. There is still some stuff to clean up, then we can reorganize it more logical.
I will reorganize it and open an other PR to rework and cleanup public headers. |
Apart from the fixed standard request handler, custom, class, and vendor handlers are handled on the basis of class/functions. Handlers array and its initialization is no longer necessary. Signed-off-by: Johann Fischer <[email protected]>
839b40f
to
255546d
Compare
Remove obsolete request handlers array.
Apart from the fixed standard request handler,
custom, class, and vendor handlers are handled
on the basis of class/functions.
Handlers array and its initialization is no longer necessary.
Add bit-field vor bmRequestType.