<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">ChangeSet 1.792, 2002/12/05 14:21:46-08:00, baldrick@wanadoo.fr

[PATCH] usbdevfs: more list cleanups

Here is a small cleanup patch for 2.4 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/devio.c b/drivers/usb/devio.c
--- a/drivers/usb/devio.c	Thu Dec  5 14:48:25 2002
+++ b/drivers/usb/devio.c	Thu Dec  5 14:48:25 2002
@@ -227,18 +227,14 @@
 {
         unsigned long flags;
         struct async *as;
-        struct list_head *p;
 
         spin_lock_irqsave(&amp;ps-&gt;lock, flags);
-        for (p = ps-&gt;async_pending.next; p != &amp;ps-&gt;async_pending; ) {
-                as = list_entry(p, struct async, asynclist);
-                p = p-&gt;next;
-                if (as-&gt;userurb != userurb)
-                        continue;
-                list_del_init(&amp;as-&gt;asynclist);
-                spin_unlock_irqrestore(&amp;ps-&gt;lock, flags);
-                return as;
-        }
+	list_for_each_entry(as, &amp;ps-&gt;async_pending, asynclist)
+		if (as-&gt;userurb == userurb) {
+			list_del_init(&amp;as-&gt;asynclist);
+			spin_unlock_irqrestore(&amp;ps-&gt;lock, flags);
+			return as;
+		}
         spin_unlock_irqrestore(&amp;ps-&gt;lock, flags);
         return NULL;
 }
@@ -283,19 +279,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(&amp;hitlist);
 	spin_lock_irqsave(&amp;ps-&gt;lock, flags);
-	for (p = ps-&gt;async_pending.next; p != &amp;ps-&gt;async_pending; ) {
-		as = list_entry(p, struct async, asynclist);
-		p = p-&gt;next;
-
-		if (as-&gt;intf == intf)
-			list_move_tail(&amp;as-&gt;asynclist, &amp;hitlist);
-	}
+	list_for_each_safe(p, q, &amp;ps-&gt;async_pending)
+		if (intf == list_entry(p, struct async, asynclist)-&gt;intf)
+			list_move_tail(p, &amp;hitlist);
 	spin_unlock_irqrestore(&amp;ps-&gt;lock, flags);
 	destroy_async(ps, &amp;hitlist);
 }
</pre></body></html>