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
diff --git a/drivers/usb/usb_device.c b/drivers/usb/usb_device.c
index 27b78e7..8f73a6b 100644
--- a/drivers/usb/usb_device.c
+++ b/drivers/usb/usb_device.c
@@ -611,6 +611,17 @@
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 @@
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 @@
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;
}