fix(drivers/usb): remove deadcode when USBD_EP_NB = 1

CID 373791:  Control flow issues  (DEADCODE)
CID 373789:  Control flow issues  (DEADCODE)

Since USBD_EP_NB = 1 for DFU stack on STMP32MP15 platform (only EP0 is
required for DFU support) the value of num can't be different of 0
and the code can't be reached in usb_core_receive / usb_core_transmit.

Add a simple sub-function with this part of code.

Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Change-Id: I07a56909bb1e6de19ce52da7945b6d2916be8538
This commit is contained in:
Patrick Delaunay 2021-11-02 13:14:45 +01:00
parent 0cb9870ddf
commit 7ca49284be
1 changed files with 13 additions and 10 deletions

View File

@ -611,6 +611,17 @@ enum usb_status usb_core_handle_it(struct usb_handle *pdev)
return USBD_OK;
}
static void usb_core_start_xfer(struct usb_handle *pdev,
void *handle,
struct usbd_ep *ep)
{
if (ep->num == 0U) {
pdev->driver->ep0_start_xfer(handle, ep);
} else {
pdev->driver->ep_start_xfer(handle, ep);
}
}
/*
* usb_core_receive
* Receive an amount of data
@ -640,11 +651,7 @@ enum usb_status usb_core_receive(struct usb_handle *pdev, uint8_t ep_addr,
ep->is_in = false;
ep->num = num;
if (num == 0U) {
pdev->driver->ep0_start_xfer(hpcd->instance, ep);
} else {
pdev->driver->ep_start_xfer(hpcd->instance, ep);
}
usb_core_start_xfer(pdev, hpcd->instance, ep);
return USBD_OK;
}
@ -678,11 +685,7 @@ enum usb_status usb_core_transmit(struct usb_handle *pdev, uint8_t ep_addr,
ep->is_in = true;
ep->num = num;
if (num == 0U) {
pdev->driver->ep0_start_xfer(hpcd->instance, ep);
} else {
pdev->driver->ep_start_xfer(hpcd->instance, ep);
}
usb_core_start_xfer(pdev, hpcd->instance, ep);
return USBD_OK;
}