mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
Merge pull request #11726 from keestux/usb-some-refactoring
usbus: simplify adding entry to list
This commit is contained in:
commit
968e53b74f
@ -107,37 +107,24 @@ uint16_t usbus_add_interface(usbus_t *usbus, usbus_interface_t *iface)
|
|||||||
* usages. Furthermore, the O(1) append is not really necessary as this is
|
* usages. Furthermore, the O(1) append is not really necessary as this is
|
||||||
* only used at init */
|
* only used at init */
|
||||||
uint16_t idx = 0;
|
uint16_t idx = 0;
|
||||||
usbus_interface_t *last = usbus->iface;
|
usbus_interface_t **last = &usbus->iface;
|
||||||
|
while (*last) {
|
||||||
if (last) {
|
last = &(*last)->next;
|
||||||
idx++;
|
idx++;
|
||||||
while (last->next) {
|
|
||||||
last = last->next;
|
|
||||||
idx++;
|
|
||||||
}
|
|
||||||
last->next = iface;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
usbus->iface = iface;
|
|
||||||
}
|
}
|
||||||
iface->idx = idx;
|
iface->idx = idx;
|
||||||
|
*last = iface;
|
||||||
return idx;
|
return idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
void usbus_register_event_handler(usbus_t *usbus, usbus_handler_t *handler)
|
void usbus_register_event_handler(usbus_t *usbus, usbus_handler_t *handler)
|
||||||
{
|
{
|
||||||
/* See note above for reasons against clist.h */
|
/* See note above for reasons against clist.h */
|
||||||
usbus_handler_t *last = usbus->handlers;
|
usbus_handler_t **last = &usbus->handlers;
|
||||||
|
while (*last) {
|
||||||
if (last) {
|
last = &(*last)->next;
|
||||||
while (last->next) {
|
|
||||||
last = last->next;
|
|
||||||
}
|
|
||||||
last->next = handler;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
usbus->handlers = handler;
|
|
||||||
}
|
}
|
||||||
|
*last = handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
usbus_endpoint_t *usbus_add_endpoint(usbus_t *usbus, usbus_interface_t *iface,
|
usbus_endpoint_t *usbus_add_endpoint(usbus_t *usbus, usbus_interface_t *iface,
|
||||||
|
Loading…
Reference in New Issue
Block a user