diff options
author | Matthias Kaehlcke <matthias.kaehlcke@gmail.com> | 2007-12-13 19:15:33 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-02-01 17:34:56 -0500 |
commit | 1cfab028afe5827433195c57b6f36d61a79beb50 (patch) | |
tree | 080bc3b650654ebe5cc231980c0feafe0380d20d /drivers/usb/misc | |
parent | 041509db390cf97b09df0f51024f5d40407938db (diff) |
USB: testing driver: convert dev->sem to mutex
USB testing driver: convert semaphore dev->sem to the mutex API
Signed-off-by: Matthias Kaehlcke <matthias.kaehlcke@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/misc')
-rw-r--r-- | drivers/usb/misc/usbtest.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c index 81755d06a41..e3851359d65 100644 --- a/drivers/usb/misc/usbtest.c +++ b/drivers/usb/misc/usbtest.c | |||
@@ -6,6 +6,7 @@ | |||
6 | #include <linux/module.h> | 6 | #include <linux/module.h> |
7 | #include <linux/moduleparam.h> | 7 | #include <linux/moduleparam.h> |
8 | #include <linux/scatterlist.h> | 8 | #include <linux/scatterlist.h> |
9 | #include <linux/mutex.h> | ||
9 | 10 | ||
10 | #include <linux/usb.h> | 11 | #include <linux/usb.h> |
11 | 12 | ||
@@ -64,7 +65,7 @@ struct usbtest_dev { | |||
64 | int in_iso_pipe; | 65 | int in_iso_pipe; |
65 | int out_iso_pipe; | 66 | int out_iso_pipe; |
66 | struct usb_endpoint_descriptor *iso_in, *iso_out; | 67 | struct usb_endpoint_descriptor *iso_in, *iso_out; |
67 | struct semaphore sem; | 68 | struct mutex lock; |
68 | 69 | ||
69 | #define TBUF_SIZE 256 | 70 | #define TBUF_SIZE 256 |
70 | u8 *buf; | 71 | u8 *buf; |
@@ -1559,11 +1560,11 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1559 | || param->sglen < 0 || param->vary < 0) | 1560 | || param->sglen < 0 || param->vary < 0) |
1560 | return -EINVAL; | 1561 | return -EINVAL; |
1561 | 1562 | ||
1562 | if (down_interruptible (&dev->sem)) | 1563 | if (mutex_lock_interruptible(&dev->lock)) |
1563 | return -ERESTARTSYS; | 1564 | return -ERESTARTSYS; |
1564 | 1565 | ||
1565 | if (intf->dev.power.power_state.event != PM_EVENT_ON) { | 1566 | if (intf->dev.power.power_state.event != PM_EVENT_ON) { |
1566 | up (&dev->sem); | 1567 | mutex_unlock(&dev->lock); |
1567 | return -EHOSTUNREACH; | 1568 | return -EHOSTUNREACH; |
1568 | } | 1569 | } |
1569 | 1570 | ||
@@ -1575,7 +1576,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1575 | int res; | 1576 | int res; |
1576 | 1577 | ||
1577 | if (intf->altsetting->desc.bInterfaceNumber) { | 1578 | if (intf->altsetting->desc.bInterfaceNumber) { |
1578 | up (&dev->sem); | 1579 | mutex_unlock(&dev->lock); |
1579 | return -ENODEV; | 1580 | return -ENODEV; |
1580 | } | 1581 | } |
1581 | res = set_altsetting (dev, dev->info->alt); | 1582 | res = set_altsetting (dev, dev->info->alt); |
@@ -1583,7 +1584,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1583 | dev_err (&intf->dev, | 1584 | dev_err (&intf->dev, |
1584 | "set altsetting to %d failed, %d\n", | 1585 | "set altsetting to %d failed, %d\n", |
1585 | dev->info->alt, res); | 1586 | dev->info->alt, res); |
1586 | up (&dev->sem); | 1587 | mutex_unlock(&dev->lock); |
1587 | return res; | 1588 | return res; |
1588 | } | 1589 | } |
1589 | } | 1590 | } |
@@ -1856,7 +1857,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1856 | param->duration.tv_usec += 1000 * 1000; | 1857 | param->duration.tv_usec += 1000 * 1000; |
1857 | param->duration.tv_sec -= 1; | 1858 | param->duration.tv_sec -= 1; |
1858 | } | 1859 | } |
1859 | up (&dev->sem); | 1860 | mutex_unlock(&dev->lock); |
1860 | return retval; | 1861 | return retval; |
1861 | } | 1862 | } |
1862 | 1863 | ||
@@ -1906,7 +1907,7 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id) | |||
1906 | return -ENOMEM; | 1907 | return -ENOMEM; |
1907 | info = (struct usbtest_info *) id->driver_info; | 1908 | info = (struct usbtest_info *) id->driver_info; |
1908 | dev->info = info; | 1909 | dev->info = info; |
1909 | init_MUTEX (&dev->sem); | 1910 | mutex_init(&dev->lock); |
1910 | 1911 | ||
1911 | dev->intf = intf; | 1912 | dev->intf = intf; |
1912 | 1913 | ||
@@ -1991,7 +1992,7 @@ static void usbtest_disconnect (struct usb_interface *intf) | |||
1991 | { | 1992 | { |
1992 | struct usbtest_dev *dev = usb_get_intfdata (intf); | 1993 | struct usbtest_dev *dev = usb_get_intfdata (intf); |
1993 | 1994 | ||
1994 | down (&dev->sem); | 1995 | mutex_lock(&dev->lock); |
1995 | 1996 | ||
1996 | usb_set_intfdata (intf, NULL); | 1997 | usb_set_intfdata (intf, NULL); |
1997 | dev_dbg (&intf->dev, "disconnect\n"); | 1998 | dev_dbg (&intf->dev, "disconnect\n"); |