From fd06eb25341f40981662013432b08b1ab880386b Mon Sep 17 00:00:00 2001 From: Abdelhak Bougouffa Date: Sat, 2 Dec 2017 17:08:43 +0100 Subject: [PATCH 1/2] Replace the old deprecated callbacks --- features/unsupported/USBHost/USBHost/USBDeviceConnected.h | 4 ++-- features/unsupported/USBHost/USBHost/USBEndpoint.h | 4 ++-- features/unsupported/USBHost/USBHost/USBHost.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/features/unsupported/USBHost/USBHost/USBDeviceConnected.h b/features/unsupported/USBHost/USBHost/USBDeviceConnected.h index f74c4b6e4b..88dd6dbbbf 100644 --- a/features/unsupported/USBHost/USBHost/USBDeviceConnected.h +++ b/features/unsupported/USBHost/USBHost/USBDeviceConnected.h @@ -106,7 +106,7 @@ public: template inline void onDisconnect(uint8_t intf_nb, T* tptr, void (T::*mptr)(void)) { if ((mptr != NULL) && (tptr != NULL)) { - intf[intf_nb].detach.attach(tptr, mptr); + intf[intf_nb].detach = callback(tptr, mptr); } } @@ -118,7 +118,7 @@ public: */ inline void onDisconnect(uint8_t intf_nb, void (*fn)(void)) { if (fn != NULL) { - intf[intf_nb].detach.attach(fn); + intf[intf_nb].detach = fn; } } diff --git a/features/unsupported/USBHost/USBHost/USBEndpoint.h b/features/unsupported/USBHost/USBHost/USBEndpoint.h index 5b1287f421..d0d9fd4231 100644 --- a/features/unsupported/USBHost/USBHost/USBEndpoint.h +++ b/features/unsupported/USBHost/USBHost/USBEndpoint.h @@ -89,7 +89,7 @@ public: template inline void attach(T* tptr, void (T::*mptr)(void)) { if((mptr != NULL) && (tptr != NULL)) { - rx.attach(tptr, mptr); + rx = callback(tptr, mptr); } } @@ -100,7 +100,7 @@ public: */ inline void attach(void (*fptr)(void)) { if(fptr != NULL) { - rx.attach(fptr); + rx = fptr; } } diff --git a/features/unsupported/USBHost/USBHost/USBHost.cpp b/features/unsupported/USBHost/USBHost/USBHost.cpp index b9424f73f1..518d00d94f 100644 --- a/features/unsupported/USBHost/USBHost/USBHost.cpp +++ b/features/unsupported/USBHost/USBHost/USBHost.cpp @@ -312,7 +312,7 @@ USBHost::USBHost() : usbThread(osPriorityNormal, USB_THREAD_STACK) } #endif - usbThread.start(this, &USBHost::usb_process); + usbThread.start(callback(this, &USBHost::usb_process)); } USBHost::Lock::Lock(USBHost* pHost) : m_pHost(pHost) From 4bba4e59fcc409057fc46b01751d73fdc89aaab3 Mon Sep 17 00:00:00 2001 From: Abdelhak Bougouffa Date: Sat, 2 Dec 2017 17:09:46 +0100 Subject: [PATCH 2/2] Add checking for MAX_HUB_NB in a part of code that depend on MAX_HUB_NB --- features/unsupported/USBHost/USBHost/USBHost.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/features/unsupported/USBHost/USBHost/USBHost.cpp b/features/unsupported/USBHost/USBHost/USBHost.cpp index 518d00d94f..704e28001c 100644 --- a/features/unsupported/USBHost/USBHost/USBHost.cpp +++ b/features/unsupported/USBHost/USBHost/USBHost.cpp @@ -88,11 +88,14 @@ void USBHost::usb_process() /* check that hub is connected to root port */ if (usb_msg->hub_parent) { /* a hub device must be present */ +#if MAX_HUB_NB + for (k = 0; k < MAX_HUB_NB; k++) { if ((&hubs[k] == usb_msg->hub_parent) && (hub_in_use[k])) { hub_unplugged=false; } } +#endif } else { hub_unplugged = false; }