This is a note to let you know that I've just added the patch titled
Subject: USB: kill BKL in skeleton driver
to my gregkh-2.6 tree. Its filename is
usb-kill-bkl-in-skeleton-driver.patch
This tree can be found at
http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/
>From [email protected] Thu Mar 1 14:07:37 2007
From: Oliver Neukum <[email protected]>
Date: Thu, 1 Mar 2007 23:07:32 +0100
Subject: USB: kill BKL in skeleton driver
To: [email protected], "list, USB" <[email protected]>
Message-ID: <[email protected]>
Content-Disposition: inline
Iet's kill BKL where we can. This is relative to the last patch to the
skeleton driver.
Signed-off-by: Oliver Neukum <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
drivers/usb/usb-skeleton.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
--- gregkh-2.6.orig/drivers/usb/usb-skeleton.c
+++ gregkh-2.6/drivers/usb/usb-skeleton.c
@@ -34,6 +34,9 @@ static struct usb_device_id skel_table [
};
MODULE_DEVICE_TABLE(usb, skel_table);
+/* to prevent a race between open and disconnect */
+static DEFINE_MUTEX(skel_open_lock);
+
/* Get a minor range for your devices from the usb maintainer */
#define USB_SKEL_MINOR_BASE 192
@@ -80,8 +83,10 @@ static int skel_open(struct inode *inode
subminor = iminor(inode);
+ mutex_lock(&skel_open_lock);
interface = usb_find_interface(&skel_driver, subminor);
if (!interface) {
+ mutex_unlock(&skel_open_lock);
err ("%s - error, can't find device for minor %d",
__FUNCTION__, subminor);
retval = -ENODEV;
@@ -90,12 +95,15 @@ static int skel_open(struct inode *inode
dev = usb_get_intfdata(interface);
if (!dev) {
+ mutex_unlock(&skel_open_lock);
retval = -ENODEV;
goto exit;
}
/* increment our usage count for the device */
kref_get(&dev->kref);
+ /* now we can drop the lock */
+ mutex_unlock(&skel_open_lock);
/* prevent the device from being autosuspended */
retval = usb_autopm_get_interface(interface);
@@ -361,14 +369,14 @@ static void skel_disconnect(struct usb_i
int minor = interface->minor;
/* prevent skel_open() from racing skel_disconnect() */
- lock_kernel();
+ mutex_lock(&skel_open_lock);
dev = usb_get_intfdata(interface);
usb_set_intfdata(interface, NULL);
/* give back our minor */
usb_deregister_dev(interface, &skel_class);
- unlock_kernel();
+ mutex_unlock(&skel_open_lock);
/* prevent more I/O from starting */
mutex_lock(&dev->io_mutex);
Patches currently in gregkh-2.6 which might be from [email protected] are
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.