Commit bd266255 authored by Pete Zaitcev's avatar Pete Zaitcev Committed by Greg Kroah-Hartman

[PATCH] USB: usblp BKL removal

the appended patch is not in yet, what gives? I sent it to Marcelo with
an understanding that it would be in Linus tree any day now. It was a couple
of months ago. It's not just BKL witchhunt either. I remember that it fixed
an oops, although I do not remember the precise scenario by now (it had
something to do with a race between ->release and ->disconnect).


From: Pete Zaitcev <zaitcev@redhat.com>
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent 9e926158
...@@ -222,6 +222,7 @@ static int usblp_cache_device_id_string(struct usblp *usblp); ...@@ -222,6 +222,7 @@ static int usblp_cache_device_id_string(struct usblp *usblp);
/* forward reference to make our lives easier */ /* forward reference to make our lives easier */
static struct usb_driver usblp_driver; static struct usb_driver usblp_driver;
static DECLARE_MUTEX(usblp_sem); /* locks the existence of usblp's */
/* /*
* Functions for usblp control messages. * Functions for usblp control messages.
...@@ -343,7 +344,7 @@ static int usblp_open(struct inode *inode, struct file *file) ...@@ -343,7 +344,7 @@ static int usblp_open(struct inode *inode, struct file *file)
if (minor < 0) if (minor < 0)
return -ENODEV; return -ENODEV;
lock_kernel(); down (&usblp_sem);
retval = -ENODEV; retval = -ENODEV;
intf = usb_find_interface(&usblp_driver, minor); intf = usb_find_interface(&usblp_driver, minor);
...@@ -389,7 +390,7 @@ static int usblp_open(struct inode *inode, struct file *file) ...@@ -389,7 +390,7 @@ static int usblp_open(struct inode *inode, struct file *file)
} }
} }
out: out:
unlock_kernel(); up (&usblp_sem);
return retval; return retval;
} }
...@@ -415,13 +416,13 @@ static int usblp_release(struct inode *inode, struct file *file) ...@@ -415,13 +416,13 @@ static int usblp_release(struct inode *inode, struct file *file)
{ {
struct usblp *usblp = file->private_data; struct usblp *usblp = file->private_data;
down (&usblp->sem); down (&usblp_sem);
usblp->used = 0; usblp->used = 0;
if (usblp->present) { if (usblp->present) {
usblp_unlink_urbs(usblp); usblp_unlink_urbs(usblp);
up(&usblp->sem);
} else /* finish cleanup from disconnect */ } else /* finish cleanup from disconnect */
usblp_cleanup (usblp); usblp_cleanup (usblp);
up (&usblp_sem);
return 0; return 0;
} }
...@@ -1149,8 +1150,8 @@ static void usblp_disconnect(struct usb_interface *intf) ...@@ -1149,8 +1150,8 @@ static void usblp_disconnect(struct usb_interface *intf)
BUG (); BUG ();
} }
down (&usblp_sem);
down (&usblp->sem); down (&usblp->sem);
lock_kernel();
usblp->present = 0; usblp->present = 0;
usb_set_intfdata (intf, NULL); usb_set_intfdata (intf, NULL);
...@@ -1159,12 +1160,11 @@ static void usblp_disconnect(struct usb_interface *intf) ...@@ -1159,12 +1160,11 @@ static void usblp_disconnect(struct usb_interface *intf)
usblp->writebuf, usblp->writeurb->transfer_dma); usblp->writebuf, usblp->writeurb->transfer_dma);
usb_buffer_free (usblp->dev, USBLP_BUF_SIZE, usb_buffer_free (usblp->dev, USBLP_BUF_SIZE,
usblp->readbuf, usblp->readurb->transfer_dma); usblp->readbuf, usblp->readurb->transfer_dma);
up (&usblp->sem);
if (!usblp->used) if (!usblp->used)
usblp_cleanup (usblp); usblp_cleanup (usblp);
else /* cleanup later, on release */ up (&usblp_sem);
up (&usblp->sem);
unlock_kernel();
} }
static struct usb_device_id usblp_ids [] = { static struct usb_device_id usblp_ids [] = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment