Commit bb672f57 authored by Oliver Neukum's avatar Oliver Neukum Committed by Greg Kroah-Hartman

[PATCH] USB: cleanup of usblp (release and poll)

this cleans up locking and freeing in usblp_release and
poll.
parent f3f7317f
...@@ -383,7 +383,7 @@ static void usblp_cleanup (struct usblp *usblp) ...@@ -383,7 +383,7 @@ static void usblp_cleanup (struct usblp *usblp)
usb_buffer_free (usblp->dev, USBLP_BUF_SIZE, usb_buffer_free (usblp->dev, USBLP_BUF_SIZE,
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->writeurb->transfer_dma); usblp->readbuf, usblp->readurb->transfer_dma);
kfree (usblp->device_id_string); kfree (usblp->device_id_string);
kfree (usblp->statusbuf); kfree (usblp->statusbuf);
usb_free_urb(usblp->writeurb); usb_free_urb(usblp->writeurb);
...@@ -403,14 +403,12 @@ static int usblp_release(struct inode *inode, struct file *file) ...@@ -403,14 +403,12 @@ 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);
lock_kernel();
usblp->used = 0; usblp->used = 0;
if (usblp->present) { if (usblp->present) {
usblp_unlink_urbs(usblp); usblp_unlink_urbs(usblp);
up(&usblp->sem); up(&usblp->sem);
} else /* finish cleanup from disconnect */ } else /* finish cleanup from disconnect */
usblp_cleanup (usblp); usblp_cleanup (usblp);
unlock_kernel();
return 0; return 0;
} }
...@@ -419,8 +417,8 @@ static unsigned int usblp_poll(struct file *file, struct poll_table_struct *wait ...@@ -419,8 +417,8 @@ static unsigned int usblp_poll(struct file *file, struct poll_table_struct *wait
{ {
struct usblp *usblp = file->private_data; struct usblp *usblp = file->private_data;
poll_wait(file, &usblp->wait, wait); poll_wait(file, &usblp->wait, wait);
return ((!usblp->bidir || usblp->readurb->status == -EINPROGRESS) ? 0 : POLLIN | POLLRDNORM) return ((!usblp->bidir || !usblp->rcomplete) ? 0 : POLLIN | POLLRDNORM)
| (usblp->writeurb->status == -EINPROGRESS ? 0 : POLLOUT | POLLWRNORM); | (!usblp->wcomplete ? 0 : POLLOUT | POLLWRNORM);
} }
static int usblp_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) static int usblp_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
...@@ -738,7 +736,7 @@ static ssize_t usblp_read(struct file *file, char __user *buffer, size_t count, ...@@ -738,7 +736,7 @@ static ssize_t usblp_read(struct file *file, char __user *buffer, size_t count,
usblp->readurb->dev = usblp->dev; usblp->readurb->dev = usblp->dev;
usblp->readcount = 0; usblp->readcount = 0;
if (usb_submit_urb(usblp->readurb, GFP_KERNEL) < 0) if (usb_submit_urb(usblp->readurb, GFP_KERNEL) < 0)
dbg("error submitting urb"); dbg("error submitting urb");
count = -EIO; count = -EIO;
goto done; goto done;
} }
......
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