usb: device_next: implement usbd_class_shutdown()

Implement marked as TODO usbd_class_shutdown().

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
diff --git a/include/zephyr/usb/usbd.h b/include/zephyr/usb/usbd.h
index e452f5e..c060411 100644
--- a/include/zephyr/usb/usbd.h
+++ b/include/zephyr/usb/usbd.h
@@ -221,8 +221,8 @@
 	/** Initialization of the class implementation */
 	int (*init)(struct usbd_class_node *const node);
 
-	/** Shutdown of the class implementation (TODO) */
-	int (*shutdown)(struct usbd_class_node *const node);
+	/** Shutdown of the class implementation */
+	void (*shutdown)(struct usbd_class_node *const node);
 };
 
 /**
diff --git a/subsys/usb/device_next/usbd_class.c b/subsys/usb/device_next/usbd_class.c
index 1464d84..41d6d7e 100644
--- a/subsys/usb/device_next/usbd_class.c
+++ b/subsys/usb/device_next/usbd_class.c
@@ -272,6 +272,7 @@
 	while ((node = sys_slist_get(&cfg_nd->class_list))) {
 		c_nd = CONTAINER_OF(node, struct usbd_class_node, node);
 		atomic_clear_bit(&c_nd->data->state, USBD_CCTX_REGISTERED);
+		usbd_class_shutdown(c_nd);
 		LOG_DBG("Remove class node %p from configuration %u", c_nd, cfg);
 	}
 
@@ -361,6 +362,7 @@
 	ret = usbd_class_remove(uds_ctx, c_nd, cfg);
 	if (ret == 0) {
 		atomic_clear_bit(&data->state, USBD_CCTX_REGISTERED);
+		usbd_class_shutdown(c_nd);
 		data->uds_ctx = NULL;
 	}
 
diff --git a/subsys/usb/device_next/usbd_class_api.h b/subsys/usb/device_next/usbd_class_api.h
index c2e1841..244ff87 100644
--- a/subsys/usb/device_next/usbd_class_api.h
+++ b/subsys/usb/device_next/usbd_class_api.h
@@ -206,7 +206,7 @@
 }
 
 /**
- * @brief Class associated configuration shutdown handler
+ * @brief Class associated configuration disable handler
  *
  * @note The execution of the handler must not block.
  *
@@ -247,5 +247,22 @@
 	return -ENOTSUP;
 }
 
+/**
+ * @brief Shutdown of the class implementation
+ *
+ * This is called for each instance during the shutdown phase.
+ *
+ * @note The execution of the handler must not block.
+ *
+ * @param[in] dev Pointer to device struct of the class instance
+ */
+static inline void usbd_class_shutdown(struct usbd_class_node *const node)
+{
+	const struct usbd_class_api *api = node->api;
+
+	if (api->shutdown != NULL) {
+		api->shutdown(node);
+	}
+}
 
 #endif /* ZEPHYR_INCLUDE_USBD_CLASS_API_H */