ChangeSet 1.924.3.3, 2002/11/30 00:03:51-08:00, baldrick@wanadoo.fr [PATCH] usbfs: more list cleanups Here is a small cleanup patch for 2.5 that goes on top of my previous ones. It makes devio.c use the list traversal macros from list.h. diff -Nru a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c --- a/drivers/usb/core/devio.c Sun Dec 1 23:06:24 2002 +++ b/drivers/usb/core/devio.c Sun Dec 1 23:06:24 2002 @@ -239,18 +239,14 @@ { unsigned long flags; struct async *as; - struct list_head *p; spin_lock_irqsave(&ps->lock, flags); - for (p = ps->async_pending.next; p != &ps->async_pending; ) { - as = list_entry(p, struct async, asynclist); - p = p->next; - if (as->userurb != userurb) - continue; - list_del_init(&as->asynclist); - spin_unlock_irqrestore(&ps->lock, flags); - return as; - } + list_for_each_entry(as, &ps->async_pending, asynclist) + if (as->userurb == userurb) { + list_del_init(&as->asynclist); + spin_unlock_irqrestore(&ps->lock, flags); + return as; + } spin_unlock_irqrestore(&ps->lock, flags); return NULL; } @@ -295,19 +291,14 @@ static void destroy_async_on_interface (struct dev_state *ps, unsigned int intf) { - struct async *as; - struct list_head *p, hitlist; + struct list_head *p, *q, hitlist; unsigned long flags; INIT_LIST_HEAD(&hitlist); spin_lock_irqsave(&ps->lock, flags); - for (p = ps->async_pending.next; p != &ps->async_pending; ) { - as = list_entry(p, struct async, asynclist); - p = p->next; - - if (as->intf == intf) - list_move_tail(&as->asynclist, &hitlist); - } + list_for_each_safe(p, q, &ps->async_pending) + if (intf == list_entry(p, struct async, asynclist)->intf) + list_move_tail(p, &hitlist); spin_unlock_irqrestore(&ps->lock, flags); destroy_async(ps, &hitlist); }