diff options
Diffstat (limited to 'drivers/usb/misc/usbtest.c')
-rw-r--r-- | drivers/usb/misc/usbtest.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c index ea3162146481..da922dfc0dcc 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; |
@@ -1151,6 +1152,7 @@ static int verify_halted (int ep, struct urb *urb) | |||
1151 | dbg ("ep %02x couldn't get halt status, %d", ep, retval); | 1152 | dbg ("ep %02x couldn't get halt status, %d", ep, retval); |
1152 | return retval; | 1153 | return retval; |
1153 | } | 1154 | } |
1155 | le16_to_cpus(&status); | ||
1154 | if (status != 1) { | 1156 | if (status != 1) { |
1155 | dbg ("ep %02x bogus status: %04x != 1", ep, status); | 1157 | dbg ("ep %02x bogus status: %04x != 1", ep, status); |
1156 | return -EINVAL; | 1158 | return -EINVAL; |
@@ -1310,7 +1312,7 @@ static int ctrl_out (struct usbtest_dev *dev, | |||
1310 | len += vary; | 1312 | len += vary; |
1311 | 1313 | ||
1312 | /* [real world] the "zero bytes IN" case isn't really used. | 1314 | /* [real world] the "zero bytes IN" case isn't really used. |
1313 | * hardware can easily trip up in this wierd case, since its | 1315 | * hardware can easily trip up in this weird case, since its |
1314 | * status stage is IN, not OUT like other ep0in transfers. | 1316 | * status stage is IN, not OUT like other ep0in transfers. |
1315 | */ | 1317 | */ |
1316 | if (len > length) | 1318 | if (len > length) |
@@ -1558,11 +1560,11 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1558 | || param->sglen < 0 || param->vary < 0) | 1560 | || param->sglen < 0 || param->vary < 0) |
1559 | return -EINVAL; | 1561 | return -EINVAL; |
1560 | 1562 | ||
1561 | if (down_interruptible (&dev->sem)) | 1563 | if (mutex_lock_interruptible(&dev->lock)) |
1562 | return -ERESTARTSYS; | 1564 | return -ERESTARTSYS; |
1563 | 1565 | ||
1564 | if (intf->dev.power.power_state.event != PM_EVENT_ON) { | 1566 | if (intf->dev.power.power_state.event != PM_EVENT_ON) { |
1565 | up (&dev->sem); | 1567 | mutex_unlock(&dev->lock); |
1566 | return -EHOSTUNREACH; | 1568 | return -EHOSTUNREACH; |
1567 | } | 1569 | } |
1568 | 1570 | ||
@@ -1574,7 +1576,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1574 | int res; | 1576 | int res; |
1575 | 1577 | ||
1576 | if (intf->altsetting->desc.bInterfaceNumber) { | 1578 | if (intf->altsetting->desc.bInterfaceNumber) { |
1577 | up (&dev->sem); | 1579 | mutex_unlock(&dev->lock); |
1578 | return -ENODEV; | 1580 | return -ENODEV; |
1579 | } | 1581 | } |
1580 | res = set_altsetting (dev, dev->info->alt); | 1582 | res = set_altsetting (dev, dev->info->alt); |
@@ -1582,7 +1584,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1582 | dev_err (&intf->dev, | 1584 | dev_err (&intf->dev, |
1583 | "set altsetting to %d failed, %d\n", | 1585 | "set altsetting to %d failed, %d\n", |
1584 | dev->info->alt, res); | 1586 | dev->info->alt, res); |
1585 | up (&dev->sem); | 1587 | mutex_unlock(&dev->lock); |
1586 | return res; | 1588 | return res; |
1587 | } | 1589 | } |
1588 | } | 1590 | } |
@@ -1855,7 +1857,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1855 | param->duration.tv_usec += 1000 * 1000; | 1857 | param->duration.tv_usec += 1000 * 1000; |
1856 | param->duration.tv_sec -= 1; | 1858 | param->duration.tv_sec -= 1; |
1857 | } | 1859 | } |
1858 | up (&dev->sem); | 1860 | mutex_unlock(&dev->lock); |
1859 | return retval; | 1861 | return retval; |
1860 | } | 1862 | } |
1861 | 1863 | ||
@@ -1905,7 +1907,7 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id) | |||
1905 | return -ENOMEM; | 1907 | return -ENOMEM; |
1906 | info = (struct usbtest_info *) id->driver_info; | 1908 | info = (struct usbtest_info *) id->driver_info; |
1907 | dev->info = info; | 1909 | dev->info = info; |
1908 | init_MUTEX (&dev->sem); | 1910 | mutex_init(&dev->lock); |
1909 | 1911 | ||
1910 | dev->intf = intf; | 1912 | dev->intf = intf; |
1911 | 1913 | ||
@@ -1990,8 +1992,6 @@ static void usbtest_disconnect (struct usb_interface *intf) | |||
1990 | { | 1992 | { |
1991 | struct usbtest_dev *dev = usb_get_intfdata (intf); | 1993 | struct usbtest_dev *dev = usb_get_intfdata (intf); |
1992 | 1994 | ||
1993 | down (&dev->sem); | ||
1994 | |||
1995 | usb_set_intfdata (intf, NULL); | 1995 | usb_set_intfdata (intf, NULL); |
1996 | dev_dbg (&intf->dev, "disconnect\n"); | 1996 | dev_dbg (&intf->dev, "disconnect\n"); |
1997 | kfree (dev); | 1997 | kfree (dev); |