drivers: usb: use new USB framework header
Use macros and types from usb/usb_ch9.h header where it is possible. This patch also adds local macros, USB_REQTYPE_GET_DIR and USB_REQTYPE_GET_TYPE, which is an intermediate solution and these will be removed later. Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
This commit is contained in:
parent
6408d40fd6
commit
6954554284
5 changed files with 9 additions and 16 deletions
|
@ -462,8 +462,7 @@ static void update_control_stage(usb_device_callback_message_struct_t *cb_msg,
|
|||
if (cb_msg->isSetup) {
|
||||
if (usbd_setup->wLength == 0) {
|
||||
dev_data.setupDataStage = SETUP_DATA_STAGE_DONE;
|
||||
} else if (REQTYPE_GET_DIR(usbd_setup->bmRequestType)
|
||||
== REQTYPE_DIR_TO_HOST) {
|
||||
} else if (usb_reqtype_is_to_host(usbd_setup)) {
|
||||
dev_data.setupDataStage = SETUP_DATA_STAGE_IN;
|
||||
} else {
|
||||
dev_data.setupDataStage = SETUP_DATA_STAGE_OUT;
|
||||
|
|
|
@ -513,8 +513,7 @@ int handle_usb_control(struct usbip_header *hdr)
|
|||
}
|
||||
|
||||
if ((ntohl(hdr->common.direction) == USBIP_DIR_IN) ^
|
||||
(REQTYPE_GET_DIR(hdr->u.submit.bmRequestType) ==
|
||||
REQTYPE_DIR_TO_HOST)) {
|
||||
USB_REQTYPE_GET_DIR(hdr->u.submit.bmRequestType)) {
|
||||
LOG_ERR("Failed to verify bmRequestType");
|
||||
return -EIO;
|
||||
}
|
||||
|
|
|
@ -25,8 +25,6 @@
|
|||
|
||||
/* Zephyr headers */
|
||||
#include <kernel.h>
|
||||
#include <usb/usb_common.h>
|
||||
#include <usb/usbstruct.h>
|
||||
#include <usb/usb_device.h>
|
||||
|
||||
#include <posix_board_if.h>
|
||||
|
@ -75,7 +73,7 @@ static void usbip_header_dump(struct usbip_header *hdr)
|
|||
void get_interface(uint8_t *descriptors)
|
||||
{
|
||||
while (descriptors[0]) {
|
||||
if (descriptors[1] == USB_INTERFACE_DESC) {
|
||||
if (descriptors[1] == USB_DESC_INTERFACE) {
|
||||
LOG_DBG("interface found");
|
||||
}
|
||||
|
||||
|
@ -94,7 +92,7 @@ static int send_interfaces(const uint8_t *descriptors, int connfd)
|
|||
} __packed iface;
|
||||
|
||||
while (descriptors[0]) {
|
||||
if (descriptors[1] == USB_INTERFACE_DESC) {
|
||||
if (descriptors[1] == USB_DESC_INTERFACE) {
|
||||
struct usb_if_descriptor *desc = (void *)descriptors;
|
||||
|
||||
iface.bInterfaceClass = desc->bInterfaceClass;
|
||||
|
|
|
@ -796,9 +796,7 @@ static inline void usbd_work_process_setup(struct nrf_usbd_ep_ctx *ep_ctx)
|
|||
|
||||
struct nrf_usbd_ctx *ctx = get_usbd_ctx();
|
||||
|
||||
if ((REQTYPE_GET_DIR(usbd_setup->bmRequestType)
|
||||
== REQTYPE_DIR_TO_DEVICE)
|
||||
&& (usbd_setup->wLength)) {
|
||||
if (usb_reqtype_is_to_device(usbd_setup) && usbd_setup->wLength) {
|
||||
ctx->ctrl_read_len = usbd_setup->wLength;
|
||||
/* Allow data chunk on EP0 OUT */
|
||||
nrfx_usbd_setup_data_clear();
|
||||
|
@ -1127,9 +1125,9 @@ static void usbd_event_handler(nrfx_usbd_evt_t const *const p_event)
|
|||
nrfx_usbd_setup_t drv_setup;
|
||||
|
||||
nrfx_usbd_setup_get(&drv_setup);
|
||||
if ((drv_setup.bRequest != REQ_SET_ADDRESS)
|
||||
|| (REQTYPE_GET_TYPE(drv_setup.bmRequestType)
|
||||
!= REQTYPE_TYPE_STANDARD)) {
|
||||
if ((drv_setup.bRequest != USB_SREQ_SET_ADDRESS)
|
||||
|| (USB_REQTYPE_GET_TYPE(drv_setup.bmRequestType)
|
||||
!= USB_REQTYPE_TYPE_STANDARD)) {
|
||||
/* SetAddress is habdled by USBD hardware.
|
||||
* No software action required.
|
||||
*/
|
||||
|
|
|
@ -1042,8 +1042,7 @@ void HAL_PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd)
|
|||
ep_state->cb(EP0_OUT, USB_DC_EP_SETUP);
|
||||
|
||||
if (!(setup->wLength == 0U) &&
|
||||
!(REQTYPE_GET_DIR(setup->bmRequestType) ==
|
||||
REQTYPE_DIR_TO_HOST)) {
|
||||
usb_reqtype_is_to_device(setup)) {
|
||||
usb_dc_ep_start_read(EP0_OUT,
|
||||
usb_dc_stm32_state.ep_buf[EP0_IDX],
|
||||
setup->wLength);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue