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

drivers: usb: unify endpoint helper macros #26612

Merged

Conversation

jfischer-no
Copy link
Collaborator

Unify endpoint index and direction helper macros
across all usb device drivers.

ep_idx is common used designator for endpoint index,
rename ep_num to ep_idx in usb_dc_sam0 driver.

@jfischer-no jfischer-no added area: Drivers area: USB Universal Serial Bus labels Jul 2, 2020
@github-actions github-actions bot added area: API Changes to public APIs area: native port Host native arch port (native_sim) labels Jul 2, 2020
Copy link
Collaborator

@loicpoulain loicpoulain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a comment to address.

/** Get endpoint address from endpoint index and direction */
#define USB_EP_GET_ADDR(idx, dir) ((idx) | ((dir) & USB_EP_DIR_MASK))
/** True if the endpoint is an IN endpoint */
#define USB_EP_DIR_IS_IN(ep) (USB_EP_GET_DIR(ep) == USB_EP_DIR_IN ? true : false)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not the simple version:
#define USB_EP_DIR_IS_IN(ep) (USB_EP_GET_DIR(ep) == USB_EP_DIR_IN)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It turned out this way, I will change it

include/drivers/usb/usb_dc.h Show resolved Hide resolved
Copy link
Collaborator

@eobalski eobalski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I idon't know why but I cannot comment for unchanged line.
Line 24 inusb_dc_sam0.c . Macro USB_SAM0_IN_EP should be deleted and all occurances should be replaced with USB_EP_DIR_IN as a part of this PR.

drivers/usb/device/usb_dc_kinetis.c Show resolved Hide resolved
drivers/usb/device/usb_dc_mcux_ehci.c Show resolved Hide resolved
drivers/usb/device/usb_dc_native_posix.c Show resolved Hide resolved
drivers/usb/device/usb_dc_native_posix.c Show resolved Hide resolved
drivers/usb/device/usb_dc_native_posix.c Show resolved Hide resolved
drivers/usb/device/usb_dc_sam.c Show resolved Hide resolved
drivers/usb/device/usb_dc_sam.c Show resolved Hide resolved
drivers/usb/device/usb_dc_sam.c Show resolved Hide resolved
drivers/usb/device/usb_dc_sam.c Show resolved Hide resolved
drivers/usb/device/usb_dc_stm32.c Show resolved Hide resolved
@zephyrbot zephyrbot added has-conflicts Issue/PR has conflicts with another issue/PR and removed area: API Changes to public APIs area: Drivers area: USB Universal Serial Bus area: native port Host native arch port (native_sim) platform: NXP NXP platform: STM32 ST Micro STM32 labels Jul 7, 2020
@github-actions github-actions bot added area: API Changes to public APIs area: native port Host native arch port (native_sim) platform: NXP NXP platform: STM32 ST Micro STM32 labels Jul 7, 2020
@jfischer-no jfischer-no added the area: USB Universal Serial Bus label Jul 8, 2020
Unify endpoint index and direction helper macros
across all usb device drivers.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
ep_idx is common used designator for endpoint index,
rename ep_num to ep_idx in usb_dc_sam0 driver.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
@carlescufi carlescufi merged commit 6d76bd8 into zephyrproject-rtos:master Jul 10, 2020
@jfischer-no jfischer-no deleted the pr-usb_driver-cleanup branch July 10, 2020 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: API Changes to public APIs area: native port Host native arch port (native_sim) area: USB Universal Serial Bus has-conflicts Issue/PR has conflicts with another issue/PR platform: NXP NXP platform: STM32 ST Micro STM32
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants