diff --git a/micropython/trezorhal/usb.c b/micropython/trezorhal/usb.c
index 55b6479766..28f21bce81 100644
--- a/micropython/trezorhal/usb.c
+++ b/micropython/trezorhal/usb.c
@@ -71,12 +71,20 @@ int usb_init(const usb_dev_info_t *dev_info) {
     // Reset the iface state map
     memset(&usb_ifaces, 0, sizeof(usb_ifaces));
 
-    USBD_Init(&usb_dev_handle, (USBD_DescriptorsTypeDef*)&usb_descriptors, USB_PHY_FS_ID);
-    USBD_RegisterClass(&usb_dev_handle, (USBD_ClassTypeDef*)&usb_class);
+    if (0 != USBD_Init(&usb_dev_handle, (USBD_DescriptorsTypeDef*)&usb_descriptors, USB_PHY_FS_ID)) {
+        return 1;
+    }
+    if (0 != USBD_RegisterClass(&usb_dev_handle, (USBD_ClassTypeDef*)&usb_class)) {
+        return 1;
+    }
 
     return 0;
 }
 
+int usb_deinit(void) {
+    return USBD_DeInit(&usb_dev_handle);
+}
+
 int usb_start(void) {
     return USBD_Start(&usb_dev_handle);
 }
diff --git a/micropython/trezorhal/usb.h b/micropython/trezorhal/usb.h
index 9383460923..4979a1d5f3 100644
--- a/micropython/trezorhal/usb.h
+++ b/micropython/trezorhal/usb.h
@@ -113,6 +113,7 @@ typedef struct {
 } usb_iface_t;
 
 int usb_init(const usb_dev_info_t *dev_info);
+int usb_deinit(void);
 int usb_start(void);
 int usb_stop(void);