Skip to content

Commit 08d496b

Browse files
jholdkalowsk
authored andcommitted
usb: device_next: Disassociate USB contexts from classes
The usbd_class_remove_all removes all registered classes from a configuration. However, it previously left the uds_ctx back-pointer to the usdb_context set, meaning that if the class is re-registered with the usbd_register_class function, this fails with the error message "Class registered to other context at different speed" due to uds_ctx being set to another context. This patch corrects the issue by clearing udc_ctx after usbd_class_shutdown has been called. Signed-off-by: Joel Holdsworth <[email protected]>
1 parent d5fc087 commit 08d496b

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

subsys/usb/device_next/usbd_class.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ int usbd_class_remove_all(struct usbd_context *const uds_ctx,
282282
c_nd = CONTAINER_OF(node, struct usbd_class_node, node);
283283
atomic_clear_bit(&c_nd->state, USBD_CCTX_REGISTERED);
284284
usbd_class_shutdown(c_nd->c_data);
285+
c_nd->c_data->uds_ctx = NULL;
285286
LOG_DBG("Remove class node %p from configuration %u", c_nd, cfg);
286287
}
287288

0 commit comments

Comments
 (0)