On second thought after reading Oliver Neukum's question about
"shaving off a cycle or two", here is version of my fix for down()
being called from interrupt context that uses unlikely() to get the
speed advantage that would be available from BUG_ON(), while still
ensuring that the condition is executed even if assertions are
compiled out.

-- 
Adam J. Richter     __     ______________   575 Oroville Road
[EMAIL PROTECTED]     \ /                  Milpitas, California 95035
+1 408 309-6081         | g g d r a s i l   United States of America
                         "Free Software For The Rest Of Us."
--- linux-2.5.41/drivers/usb/core/hub.c 2002-10-07 11:24:13.000000000 -0700
+++ linux/drivers/usb/core/hub.c        2002-10-09 06:26:50.000000000 -0700
@@ -944,7 +944,9 @@
                list_del(tmp);
                INIT_LIST_HEAD(tmp);
 
-               down(&hub->khubd_sem); /* never blocks, we were on list */
+               if (unlikely(down_trylock(&hub->khubd_sem)))
+                       BUG();  /* never blocks, we were on list */
+
                spin_unlock_irqrestore(&hub_event_lock, flags);
 
                if (hub->error) {

Reply via email to