On Wed, 28 Jun 2006, Franck Bui-Huu wrote: > Hi, > > I noticed that the BKL is used a couple of time in the USB subsystem. > Here is the list of the file that use it: > > drivers/usb/host/uhci-debug.c > drivers/usb/misc/usblcd.c > drivers/usb/misc/sisusbvga/sisusb.c > drivers/usb/usb-skeleton.c > drivers/usb/core/devio.c > drivers/usb/core/devices.c > > I'm not sure to understand why it is used, specially in devices.c and > devio.c files. > > In devices.c, it's used by usb_device_poll() and usb_device_lseek() > functions. > > usb_device_poll(): > > It seems to use it only to protect usb_device_status > structure. Can't we use a simple mutex here ? > > usb_device_lseek(): > > can we use the inode's mutex instead ? > > In devio.c, it's used by usbdev_open() and usbdev_lseek() > functions. In both function can't we also use the inode's mutex > instead ?
I recently sent in a patch that removes the BKL from usbdev_open: http://marc.theaimsgroup.com/?l=linux-usb-devel&m=115074414607596&w=2 I didn't notice that it was used in usbdev_lseek and there doesn't seem to be any reason for it to be there. Nor does there seem to be any reason for it in usb_device_lseek. The code in usb_device_poll probably should be revised in view of the changes in my patch. You might want to look at that. But you're right, it shouldn't be using the BKL. Likewise, uhci-debug doesn't need to use the BKL either. It can simply be removed from that routine. The use of BKL in usb-skeleton and possibly some of the other drivers follows a simple pattern. It is there to prevent races between open() and disconnect(). The idea is that the kernel automatically acquires the BKL whenever a character device node is opened, so by taking the lock in the disconnect routine we avoid the problem of people opening a device file as it is being unregistered. Alan Stern Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ [email protected] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
