Hi,

Here's a patch against 2.4.12-ac1 that brings the drivers/usb/devices.c
and drivers/usb/inode.c files up to the version in 2.4.7-pre2 (yes,
that's when these changes went into Linus's tree :)  The other parts of
the usbcore code use these locks, and this patch should also be applied.

thanks,

greg k-h


diff --minimal -Nru a/drivers/usb/devices.c b/drivers/usb/devices.c
--- a/drivers/usb/devices.c     Sat Oct 13 22:25:43 2001
+++ b/drivers/usb/devices.c     Sat Oct 13 22:25:43 2001
@@ -488,6 +488,7 @@
                return -EFAULT;
 
        /* enumerate busses */
+       read_lock_irq (&usb_bus_list_lock);
        for (buslist = usb_bus_list.next; buslist != &usb_bus_list; buslist = 
buslist->next) {
                /* print devices for this bus */
                bus = list_entry(buslist, struct usb_bus, bus_list);
@@ -497,6 +498,7 @@
                        return ret;
                total_written += ret;
        }
+       read_unlock_irq (&usb_bus_list_lock);
        return total_written;
 }
 
diff --minimal -Nru a/drivers/usb/inode.c b/drivers/usb/inode.c
--- a/drivers/usb/inode.c       Sat Oct 13 22:25:42 2001
+++ b/drivers/usb/inode.c       Sat Oct 13 22:25:42 2001
@@ -260,11 +260,15 @@
         struct list_head *list;
         struct usb_bus *bus;
 
+       read_lock_irq (&usb_bus_list_lock);
         for (list = usb_bus_list.next; list != &usb_bus_list; list = list->next) {
                 bus = list_entry(list, struct usb_bus, bus_list);
-                if (bus->busnum == busnr)
+                if (bus->busnum == busnr) {
+                       read_unlock_irq (&usb_bus_list_lock);
                         return bus;
+               }
         }
+       read_unlock_irq (&usb_bus_list_lock);
         return NULL;
 }
 
@@ -412,7 +416,7 @@
                if (i < 2+NRSPECIAL)
                        return 0;
                i -= 2+NRSPECIAL;
-               lock_kernel();
+               read_lock_irq (&usb_bus_list_lock);
                for (list = usb_bus_list.next; list != &usb_bus_list; list = 
list->next) {
                        if (i > 0) {
                                i--;
@@ -424,7 +428,7 @@
                                break;
                        filp->f_pos++;
                }
-               unlock_kernel();
+               read_unlock_irq (&usb_bus_list_lock);
                return 0;
        }
 }
@@ -635,13 +639,13 @@
                list_add_tail(&inode->u.usbdev_i.slist, &s->u.usbdevfs_sb.ilist);
                list_add_tail(&inode->u.usbdev_i.dlist, &special[i].inodes);
        }
-       lock_kernel();
+       read_lock_irq (&usb_bus_list_lock);
        for (blist = usb_bus_list.next; blist != &usb_bus_list; blist = blist->next) {
                bus = list_entry(blist, struct usb_bus, bus_list);
                new_bus_inode(bus, s);
                recurse_new_dev_inode(bus->root_hub, s);
        }
-       unlock_kernel();
+       read_unlock_irq (&usb_bus_list_lock);
         return s;
 
  out_no_root:

_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to