[PATCH] usb:BKL removal from ioctl path of usbfs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>From 558ff48c2918fdcd89045bb50da4b72d7d49bec9 Mon Sep 17 00:00:00 2001
From: Oliver Neukum <oliver@xxxxxxxxxx>
Date: Thu, 14 Jan 2010 16:20:32 +0100
Subject: [PATCH] usb:BKL removal from ioctl path of usbfs

Total removal from the ioctl code path except for the outcall
to external modules. Locking is ensured by the normal locks
of usbfs.

Signed-off-by: Oliver Neukum <oliver@xxxxxxxxxx>
---
 drivers/usb/core/devio.c |   12 +++---------
 1 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index 590b70e..5969157 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -1620,7 +1620,10 @@ static int proc_ioctl(struct dev_state *ps, struct usbdevfs_ioctl *ctl)
 		if (driver == NULL || driver->ioctl == NULL) {
 			retval = -ENOTTY;
 		} else {
+			/* keep API that guarantees BKL */
+			lock_kernel();
 			retval = driver->ioctl(intf, ctl->ioctl_code, buf);
+			unlock_kernel();
 			if (retval == -ENOIOCTLCMD)
 				retval = -ENOTTY;
 		}
@@ -1704,11 +1707,9 @@ static long usbdev_do_ioctl(struct file *file, unsigned int cmd,
 	if (!(file->f_mode & FMODE_WRITE))
 		return -EPERM;
 
-	lock_kernel();
 	usb_lock_device(dev);
 	if (!connected(ps)) {
 		usb_unlock_device(dev);
-		unlock_kernel();
 		return -ENODEV;
 	}
 
@@ -1767,12 +1768,10 @@ static long usbdev_do_ioctl(struct file *file, unsigned int cmd,
 		break;
 
 	case USBDEVFS_SUBMITURB:
-		unlock_kernel();
 		snoop(&dev->dev, "%s: SUBMITURB\n", __func__);
 		ret = proc_submiturb(ps, p);
 		if (ret >= 0)
 			inode->i_mtime = CURRENT_TIME;
-		lock_kernel();
 		break;
 
 #ifdef CONFIG_COMPAT
@@ -1824,17 +1823,13 @@ static long usbdev_do_ioctl(struct file *file, unsigned int cmd,
 		break;
 
 	case USBDEVFS_REAPURB:
-		unlock_kernel();
 		snoop(&dev->dev, "%s: REAPURB\n", __func__);
 		ret = proc_reapurb(ps, p);
-		lock_kernel();
 		break;
 
 	case USBDEVFS_REAPURBNDELAY:
-		unlock_kernel();
 		snoop(&dev->dev, "%s: REAPURBNDELAY\n", __func__);
 		ret = proc_reapurbnonblock(ps, p);
-		lock_kernel();
 		break;
 
 	case USBDEVFS_DISCSIGNAL:
@@ -1868,7 +1863,6 @@ static long usbdev_do_ioctl(struct file *file, unsigned int cmd,
 		break;
 	}
 	usb_unlock_device(dev);
-	unlock_kernel();
 	if (ret >= 0)
 		inode->i_atime = CURRENT_TIME;
 	return ret;
-- 
1.6.4.2

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux