aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKévin Redon <kredon@sysmocom.de>2018-12-18 13:26:34 +0100
committerKévin Redon <kredon@sysmocom.de>2019-01-16 18:40:31 +0100
commit74a8e3b61594054e810c9e0833ae07832a7d7e49 (patch)
treec528e132c254a98bb4e63530c47d86e285a14558
parent56739ea0495b30eaba6b3f6b8e7d4a953cc51431 (diff)
fix USB enabling
-rw-r--r--usb/class/dfu/device/dfudf.c40
1 files changed, 19 insertions, 21 deletions
diff --git a/usb/class/dfu/device/dfudf.c b/usb/class/dfu/device/dfudf.c
index 7747a23..faf12c1 100644
--- a/usb/class/dfu/device/dfudf.c
+++ b/usb/class/dfu/device/dfudf.c
@@ -46,33 +46,31 @@ static int32_t dfudf_enable(struct usbdf_driver *drv, struct usbd_descriptors *d
usb_iface_desc_t ifc_desc;
uint8_t * ifc;
- uint8_t i;
ifc = desc->sod;
- for (i = 0; i < 2; i++) {
- if (NULL == ifc) {
- return ERR_NOT_FOUND;
- }
+ if (NULL == ifc) {
+ return ERR_NOT_FOUND;
+ }
- ifc_desc.bInterfaceNumber = ifc[2];
- ifc_desc.bInterfaceClass = ifc[5];
-
- if (USB_DFU_CLASS == ifc_desc.bInterfaceClass) {
- if (func_data->func_iface == ifc_desc.bInterfaceNumber) { // Initialized
- return ERR_ALREADY_INITIALIZED;
- } else if (func_data->func_iface != 0xFF) { // Occupied
- return ERR_NO_RESOURCE;
- } else {
- func_data->func_iface = ifc_desc.bInterfaceNumber;
- }
- } else { // Not supported by this function driver
- return ERR_NOT_FOUND;
+ ifc_desc.bInterfaceNumber = ifc[2];
+ ifc_desc.bInterfaceClass = ifc[5];
+
+ if (USB_DFU_CLASS == ifc_desc.bInterfaceClass) {
+ if (func_data->func_iface == ifc_desc.bInterfaceNumber) { // Initialized
+ return ERR_ALREADY_INITIALIZED;
+ } else if (func_data->func_iface != 0xFF) { // Occupied
+ return ERR_NO_RESOURCE;
+ } else {
+ func_data->func_iface = ifc_desc.bInterfaceNumber;
}
+ } else { // Not supported by this function driver
+ return ERR_NOT_FOUND;
+ }
- // there are no endpoint to install since DFU uses only the control endpoint
+ // there are no endpoint to install since DFU uses only the control endpoint
+
+ ifc = usb_find_desc(usb_desc_next(desc->sod), desc->eod, USB_DT_INTERFACE);
- ifc = usb_find_desc(usb_desc_next(desc->sod), desc->eod, USB_DT_INTERFACE);
- }
// Installed
_dfudf_funcd.enabled = true;
return ERR_NONE;