aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-11-28 19:03:09 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-11-28 19:03:09 -0500
commitbb0851ff9dc65dd9c9365fdb87895d98235ac463 (patch)
treed19b7440bb5b0dec31cef2c384cccdd473f314e7 /drivers
parent34f2c1c35ff014a5d145971e41caa940cd62d563 (diff)
parent5f629ad7e5f9b99c6d025bf199d402734bd72d0f (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6: (25 commits) USB: s3c2410 gadget: ensure vbus pin in input mode during read USB: s3c2410 gadget: allow sharing of vbus irq USB: s3c2410 gadget: Header move fixups USB: usb-storage: unusual_devs entry for JetFlash TS1GJF2A USB: fix up EHCI startup synchronization USB: make the microtek driver and HAL cooperate USB: uevent environment key fix USB: keep track of whether interface sysfs files exist USB: sierra: new product id USB HCD: avoid duplicate local_irq_disable() USB: mailing lists have changed USB: remove USB HUB entry from MAINTAINERS USB: fix directory references in usb/README USB: add support for an older firmware revision for the Nikon D200 USB: FIx locks and urb->status in adutux (updated) USB: power-management documenation update USB: Fix signr comment in usbdevice_fs.h usbserial: fix inconsistent lock state USB: fix usbled disconnect read race #2 USB: free memory when writing fails in usb/serial/mos7840.c ...
Diffstat (limited to 'drivers')
-rw-r--r--drivers/usb/README6
-rw-r--r--drivers/usb/core/driver.c11
-rw-r--r--drivers/usb/core/hcd.c3
-rw-r--r--drivers/usb/core/hub.c2
-rw-r--r--drivers/usb/core/message.c36
-rw-r--r--drivers/usb/core/sysfs.c6
-rw-r--r--drivers/usb/core/usb.c25
-rw-r--r--drivers/usb/gadget/omap_udc.c6
-rw-r--r--drivers/usb/gadget/s3c2410_udc.c16
-rw-r--r--drivers/usb/host/Kconfig2
-rw-r--r--drivers/usb/host/ehci-hcd.c5
-rw-r--r--drivers/usb/image/microtek.c2
-rw-r--r--drivers/usb/misc/adutux.c262
-rw-r--r--drivers/usb/misc/usbled.c4
-rw-r--r--drivers/usb/serial/generic.c5
-rw-r--r--drivers/usb/serial/mos7840.c2
-rw-r--r--drivers/usb/serial/pl2303.c1
-rw-r--r--drivers/usb/serial/pl2303.h3
-rw-r--r--drivers/usb/serial/sierra.c2
-rw-r--r--drivers/usb/storage/scsiglue.c4
-rw-r--r--drivers/usb/storage/unusual_devs.h17
21 files changed, 226 insertions, 194 deletions
diff --git a/drivers/usb/README b/drivers/usb/README
index 3c8434128554..284f46b3e1cc 100644
--- a/drivers/usb/README
+++ b/drivers/usb/README
@@ -39,12 +39,12 @@ first subdirectory in the list below that it fits into.
39 39
40image/ - This is for still image drivers, like scanners or 40image/ - This is for still image drivers, like scanners or
41 digital cameras. 41 digital cameras.
42input/ - This is for any driver that uses the input subsystem, 42../input/ - This is for any driver that uses the input subsystem,
43 like keyboard, mice, touchscreens, tablets, etc. 43 like keyboard, mice, touchscreens, tablets, etc.
44media/ - This is for multimedia drivers, like video cameras, 44../media/ - This is for multimedia drivers, like video cameras,
45 radios, and any other drivers that talk to the v4l 45 radios, and any other drivers that talk to the v4l
46 subsystem. 46 subsystem.
47net/ - This is for network drivers. 47../net/ - This is for network drivers.
48serial/ - This is for USB to serial drivers. 48serial/ - This is for USB to serial drivers.
49storage/ - This is for USB mass-storage drivers. 49storage/ - This is for USB mass-storage drivers.
50class/ - This is for all USB device drivers that do not fit 50class/ - This is for all USB device drivers that do not fit
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index 8586817698ad..c51f8e9312e0 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -585,9 +585,6 @@ static int usb_uevent(struct device *dev, struct kobj_uevent_env *env)
585{ 585{
586 struct usb_device *usb_dev; 586 struct usb_device *usb_dev;
587 587
588 if (!dev)
589 return -ENODEV;
590
591 /* driver is often null here; dev_dbg() would oops */ 588 /* driver is often null here; dev_dbg() would oops */
592 pr_debug ("usb %s: uevent\n", dev->bus_id); 589 pr_debug ("usb %s: uevent\n", dev->bus_id);
593 590
@@ -631,14 +628,6 @@ static int usb_uevent(struct device *dev, struct kobj_uevent_env *env)
631 usb_dev->descriptor.bDeviceProtocol)) 628 usb_dev->descriptor.bDeviceProtocol))
632 return -ENOMEM; 629 return -ENOMEM;
633 630
634 if (add_uevent_var(env, "BUSNUM=%03d",
635 usb_dev->bus->busnum))
636 return -ENOMEM;
637
638 if (add_uevent_var(env, "DEVNUM=%03d",
639 usb_dev->devnum))
640 return -ENOMEM;
641
642 return 0; 631 return 0;
643} 632}
644 633
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index fea8256a18d6..d5ed3fa9e304 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -1311,8 +1311,8 @@ void usb_hcd_flush_endpoint(struct usb_device *udev,
1311 hcd = bus_to_hcd(udev->bus); 1311 hcd = bus_to_hcd(udev->bus);
1312 1312
1313 /* No more submits can occur */ 1313 /* No more submits can occur */
1314rescan:
1315 spin_lock_irq(&hcd_urb_list_lock); 1314 spin_lock_irq(&hcd_urb_list_lock);
1315rescan:
1316 list_for_each_entry (urb, &ep->urb_list, urb_list) { 1316 list_for_each_entry (urb, &ep->urb_list, urb_list) {
1317 int is_in; 1317 int is_in;
1318 1318
@@ -1345,6 +1345,7 @@ rescan:
1345 usb_put_urb (urb); 1345 usb_put_urb (urb);
1346 1346
1347 /* list contents may have changed */ 1347 /* list contents may have changed */
1348 spin_lock(&hcd_urb_list_lock);
1348 goto rescan; 1349 goto rescan;
1349 } 1350 }
1350 spin_unlock_irq(&hcd_urb_list_lock); 1351 spin_unlock_irq(&hcd_urb_list_lock);
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 036c3dea855e..13b326a13377 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -335,7 +335,7 @@ static void kick_khubd(struct usb_hub *hub)
335 to_usb_interface(hub->intfdev)->pm_usage_cnt = 1; 335 to_usb_interface(hub->intfdev)->pm_usage_cnt = 1;
336 336
337 spin_lock_irqsave(&hub_event_lock, flags); 337 spin_lock_irqsave(&hub_event_lock, flags);
338 if (!hub->disconnected & list_empty(&hub->event_list)) { 338 if (!hub->disconnected && list_empty(&hub->event_list)) {
339 list_add_tail(&hub->event_list, &hub_event_list); 339 list_add_tail(&hub->event_list, &hub_event_list);
340 wake_up(&khubd_wait); 340 wake_up(&khubd_wait);
341 } 341 }
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index 316a746e0080..fcd40ecbeecc 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -1172,7 +1172,6 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate)
1172 struct usb_host_interface *alt; 1172 struct usb_host_interface *alt;
1173 int ret; 1173 int ret;
1174 int manual = 0; 1174 int manual = 0;
1175 int changed;
1176 1175
1177 if (dev->state == USB_STATE_SUSPENDED) 1176 if (dev->state == USB_STATE_SUSPENDED)
1178 return -EHOSTUNREACH; 1177 return -EHOSTUNREACH;
@@ -1212,8 +1211,7 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate)
1212 */ 1211 */
1213 1212
1214 /* prevent submissions using previous endpoint settings */ 1213 /* prevent submissions using previous endpoint settings */
1215 changed = (iface->cur_altsetting != alt); 1214 if (iface->cur_altsetting != alt && device_is_registered(&iface->dev))
1216 if (changed && device_is_registered(&iface->dev))
1217 usb_remove_sysfs_intf_files(iface); 1215 usb_remove_sysfs_intf_files(iface);
1218 usb_disable_interface(dev, iface); 1216 usb_disable_interface(dev, iface);
1219 1217
@@ -1250,7 +1248,7 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate)
1250 * (Likewise, EP0 never "halts" on well designed devices.) 1248 * (Likewise, EP0 never "halts" on well designed devices.)
1251 */ 1249 */
1252 usb_enable_interface(dev, iface); 1250 usb_enable_interface(dev, iface);
1253 if (changed && device_is_registered(&iface->dev)) 1251 if (device_is_registered(&iface->dev))
1254 usb_create_sysfs_intf_files(iface); 1252 usb_create_sysfs_intf_files(iface);
1255 1253
1256 return 0; 1254 return 0;
@@ -1348,34 +1346,10 @@ static int usb_if_uevent(struct device *dev, struct kobj_uevent_env *env)
1348 struct usb_interface *intf; 1346 struct usb_interface *intf;
1349 struct usb_host_interface *alt; 1347 struct usb_host_interface *alt;
1350 1348
1351 if (!dev)
1352 return -ENODEV;
1353
1354 /* driver is often null here; dev_dbg() would oops */
1355 pr_debug ("usb %s: uevent\n", dev->bus_id);
1356
1357 intf = to_usb_interface(dev); 1349 intf = to_usb_interface(dev);
1358 usb_dev = interface_to_usbdev(intf); 1350 usb_dev = interface_to_usbdev(intf);
1359 alt = intf->cur_altsetting; 1351 alt = intf->cur_altsetting;
1360 1352
1361#ifdef CONFIG_USB_DEVICEFS
1362 if (add_uevent_var(env, "DEVICE=/proc/bus/usb/%03d/%03d",
1363 usb_dev->bus->busnum, usb_dev->devnum))
1364 return -ENOMEM;
1365#endif
1366
1367 if (add_uevent_var(env, "PRODUCT=%x/%x/%x",
1368 le16_to_cpu(usb_dev->descriptor.idVendor),
1369 le16_to_cpu(usb_dev->descriptor.idProduct),
1370 le16_to_cpu(usb_dev->descriptor.bcdDevice)))
1371 return -ENOMEM;
1372
1373 if (add_uevent_var(env, "TYPE=%d/%d/%d",
1374 usb_dev->descriptor.bDeviceClass,
1375 usb_dev->descriptor.bDeviceSubClass,
1376 usb_dev->descriptor.bDeviceProtocol))
1377 return -ENOMEM;
1378
1379 if (add_uevent_var(env, "INTERFACE=%d/%d/%d", 1353 if (add_uevent_var(env, "INTERFACE=%d/%d/%d",
1380 alt->desc.bInterfaceClass, 1354 alt->desc.bInterfaceClass,
1381 alt->desc.bInterfaceSubClass, 1355 alt->desc.bInterfaceSubClass,
@@ -1641,12 +1615,6 @@ free_interfaces:
1641 intf->dev.bus_id, ret); 1615 intf->dev.bus_id, ret);
1642 continue; 1616 continue;
1643 } 1617 }
1644
1645 /* The driver's probe method can call usb_set_interface(),
1646 * which would mean the interface's sysfs files are already
1647 * created. Just in case, we'll remove them first.
1648 */
1649 usb_remove_sysfs_intf_files(intf);
1650 usb_create_sysfs_intf_files(intf); 1618 usb_create_sysfs_intf_files(intf);
1651 } 1619 }
1652 1620
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
index b04afd06e502..32bd130b1eed 100644
--- a/drivers/usb/core/sysfs.c
+++ b/drivers/usb/core/sysfs.c
@@ -735,6 +735,8 @@ int usb_create_sysfs_intf_files(struct usb_interface *intf)
735 struct usb_host_interface *alt = intf->cur_altsetting; 735 struct usb_host_interface *alt = intf->cur_altsetting;
736 int retval; 736 int retval;
737 737
738 if (intf->sysfs_files_created)
739 return 0;
738 retval = sysfs_create_group(&dev->kobj, &intf_attr_grp); 740 retval = sysfs_create_group(&dev->kobj, &intf_attr_grp);
739 if (retval) 741 if (retval)
740 return retval; 742 return retval;
@@ -746,6 +748,7 @@ int usb_create_sysfs_intf_files(struct usb_interface *intf)
746 if (intf->intf_assoc) 748 if (intf->intf_assoc)
747 retval = sysfs_create_group(&dev->kobj, &intf_assoc_attr_grp); 749 retval = sysfs_create_group(&dev->kobj, &intf_assoc_attr_grp);
748 usb_create_intf_ep_files(intf, udev); 750 usb_create_intf_ep_files(intf, udev);
751 intf->sysfs_files_created = 1;
749 return 0; 752 return 0;
750} 753}
751 754
@@ -753,8 +756,11 @@ void usb_remove_sysfs_intf_files(struct usb_interface *intf)
753{ 756{
754 struct device *dev = &intf->dev; 757 struct device *dev = &intf->dev;
755 758
759 if (!intf->sysfs_files_created)
760 return;
756 usb_remove_intf_ep_files(intf); 761 usb_remove_intf_ep_files(intf);
757 device_remove_file(dev, &dev_attr_interface); 762 device_remove_file(dev, &dev_attr_interface);
758 sysfs_remove_group(&dev->kobj, &intf_attr_grp); 763 sysfs_remove_group(&dev->kobj, &intf_attr_grp);
759 sysfs_remove_group(&intf->dev.kobj, &intf_assoc_attr_grp); 764 sysfs_remove_group(&intf->dev.kobj, &intf_assoc_attr_grp);
765 intf->sysfs_files_created = 0;
760} 766}
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index c4a6f1095b8b..8f142370103d 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -192,9 +192,34 @@ static void usb_release_dev(struct device *dev)
192 kfree(udev); 192 kfree(udev);
193} 193}
194 194
195#ifdef CONFIG_HOTPLUG
196static int usb_dev_uevent(struct device *dev, struct kobj_uevent_env *env)
197{
198 struct usb_device *usb_dev;
199
200 usb_dev = to_usb_device(dev);
201
202 if (add_uevent_var(env, "BUSNUM=%03d", usb_dev->bus->busnum))
203 return -ENOMEM;
204
205 if (add_uevent_var(env, "DEVNUM=%03d", usb_dev->devnum))
206 return -ENOMEM;
207
208 return 0;
209}
210
211#else
212
213static int usb_dev_uevent(struct device *dev, struct kobj_uevent_env *env)
214{
215 return -ENODEV;
216}
217#endif /* CONFIG_HOTPLUG */
218
195struct device_type usb_device_type = { 219struct device_type usb_device_type = {
196 .name = "usb_device", 220 .name = "usb_device",
197 .release = usb_release_dev, 221 .release = usb_release_dev,
222 .uevent = usb_dev_uevent,
198}; 223};
199 224
200#ifdef CONFIG_PM 225#ifdef CONFIG_PM
diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c
index 87c4f50dfb61..d377154658b5 100644
--- a/drivers/usb/gadget/omap_udc.c
+++ b/drivers/usb/gadget/omap_udc.c
@@ -1241,14 +1241,14 @@ static void pullup_enable(struct omap_udc *udc)
1241 udc->gadget.dev.parent->power.power_state = PMSG_ON; 1241 udc->gadget.dev.parent->power.power_state = PMSG_ON;
1242 udc->gadget.dev.power.power_state = PMSG_ON; 1242 udc->gadget.dev.power.power_state = PMSG_ON;
1243 UDC_SYSCON1_REG |= UDC_PULLUP_EN; 1243 UDC_SYSCON1_REG |= UDC_PULLUP_EN;
1244 if (!gadget_is_otg(udc->gadget) && !cpu_is_omap15xx()) 1244 if (!gadget_is_otg(&udc->gadget) && !cpu_is_omap15xx())
1245 OTG_CTRL_REG |= OTG_BSESSVLD; 1245 OTG_CTRL_REG |= OTG_BSESSVLD;
1246 UDC_IRQ_EN_REG = UDC_DS_CHG_IE; 1246 UDC_IRQ_EN_REG = UDC_DS_CHG_IE;
1247} 1247}
1248 1248
1249static void pullup_disable(struct omap_udc *udc) 1249static void pullup_disable(struct omap_udc *udc)
1250{ 1250{
1251 if (!gadget_is_otg(udc->gadget) && !cpu_is_omap15xx()) 1251 if (!gadget_is_otg(&udc->gadget) && !cpu_is_omap15xx())
1252 OTG_CTRL_REG &= ~OTG_BSESSVLD; 1252 OTG_CTRL_REG &= ~OTG_BSESSVLD;
1253 UDC_IRQ_EN_REG = UDC_DS_CHG_IE; 1253 UDC_IRQ_EN_REG = UDC_DS_CHG_IE;
1254 UDC_SYSCON1_REG &= ~UDC_PULLUP_EN; 1254 UDC_SYSCON1_REG &= ~UDC_PULLUP_EN;
@@ -1386,7 +1386,7 @@ static void update_otg(struct omap_udc *udc)
1386{ 1386{
1387 u16 devstat; 1387 u16 devstat;
1388 1388
1389 if (!gadget_is_otg(udc->gadget)) 1389 if (!gadget_is_otg(&udc->gadget))
1390 return; 1390 return;
1391 1391
1392 if (OTG_CTRL_REG & OTG_ID) 1392 if (OTG_CTRL_REG & OTG_ID)
diff --git a/drivers/usb/gadget/s3c2410_udc.c b/drivers/usb/gadget/s3c2410_udc.c
index e3e90f8a75e7..4ce050c3d13f 100644
--- a/drivers/usb/gadget/s3c2410_udc.c
+++ b/drivers/usb/gadget/s3c2410_udc.c
@@ -52,10 +52,10 @@
52#include <asm/arch/irqs.h> 52#include <asm/arch/irqs.h>
53 53
54#include <asm/arch/hardware.h> 54#include <asm/arch/hardware.h>
55#include <asm/arch/regs-clock.h>
56#include <asm/arch/regs-gpio.h> 55#include <asm/arch/regs-gpio.h>
57#include <asm/arch/regs-udc.h> 56
58#include <asm/arch/udc.h> 57#include <asm/plat-s3c24xx/regs-udc.h>
58#include <asm/plat-s3c24xx/udc.h>
59 59
60#include <asm/mach-types.h> 60#include <asm/mach-types.h>
61 61
@@ -1511,7 +1511,11 @@ static irqreturn_t s3c2410_udc_vbus_irq(int irq, void *_dev)
1511 unsigned int value; 1511 unsigned int value;
1512 1512
1513 dprintk(DEBUG_NORMAL, "%s()\n", __func__); 1513 dprintk(DEBUG_NORMAL, "%s()\n", __func__);
1514
1515 /* some cpus cannot read from an line configured to IRQ! */
1516 s3c2410_gpio_cfgpin(udc_info->vbus_pin, S3C2410_GPIO_INPUT);
1514 value = s3c2410_gpio_getpin(udc_info->vbus_pin); 1517 value = s3c2410_gpio_getpin(udc_info->vbus_pin);
1518 s3c2410_gpio_cfgpin(udc_info->vbus_pin, S3C2410_GPIO_SFN2);
1515 1519
1516 if (udc_info->vbus_pin_inverted) 1520 if (udc_info->vbus_pin_inverted)
1517 value = !value; 1521 value = !value;
@@ -1872,9 +1876,9 @@ static int s3c2410_udc_probe(struct platform_device *pdev)
1872 if (udc_info && udc_info->vbus_pin > 0) { 1876 if (udc_info && udc_info->vbus_pin > 0) {
1873 irq = s3c2410_gpio_getirq(udc_info->vbus_pin); 1877 irq = s3c2410_gpio_getirq(udc_info->vbus_pin);
1874 retval = request_irq(irq, s3c2410_udc_vbus_irq, 1878 retval = request_irq(irq, s3c2410_udc_vbus_irq,
1875 IRQF_DISABLED | IRQF_TRIGGER_RISING 1879 IRQF_DISABLED | IRQF_TRIGGER_RISING
1876 | IRQF_TRIGGER_FALLING, 1880 | IRQF_TRIGGER_FALLING | IRQF_SHARED,
1877 gadget_name, udc); 1881 gadget_name, udc);
1878 1882
1879 if (retval != 0) { 1883 if (retval != 0) {
1880 dev_err(dev, "can't get vbus irq %i, err %d\n", 1884 dev_err(dev, "can't get vbus irq %i, err %d\n",
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 177e78ed241b..49a91c5ee51b 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -156,7 +156,7 @@ config USB_OHCI_HCD_PCI
156 156
157config USB_OHCI_HCD_SSB 157config USB_OHCI_HCD_SSB
158 bool "OHCI support for Broadcom SSB OHCI core" 158 bool "OHCI support for Broadcom SSB OHCI core"
159 depends on USB_OHCI_HCD && (SSB = y || SSB = CONFIG_USB_OHCI_HCD) && EXPERIMENTAL 159 depends on USB_OHCI_HCD && (SSB = y || SSB = USB_OHCI_HCD) && EXPERIMENTAL
160 default n 160 default n
161 ---help--- 161 ---help---
162 Support for the Sonics Silicon Backplane (SSB) attached 162 Support for the Sonics Silicon Backplane (SSB) attached
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index c1514442883e..5f2d74ed5ad7 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -575,12 +575,15 @@ static int ehci_run (struct usb_hcd *hcd)
575 * from the companions to the EHCI controller. If any of the 575 * from the companions to the EHCI controller. If any of the
576 * companions are in the middle of a port reset at the time, it 576 * companions are in the middle of a port reset at the time, it
577 * could cause trouble. Write-locking ehci_cf_port_reset_rwsem 577 * could cause trouble. Write-locking ehci_cf_port_reset_rwsem
578 * guarantees that no resets are in progress. 578 * guarantees that no resets are in progress. After we set CF,
579 * a short delay lets the hardware catch up; new resets shouldn't
580 * be started before the port switching actions could complete.
579 */ 581 */
580 down_write(&ehci_cf_port_reset_rwsem); 582 down_write(&ehci_cf_port_reset_rwsem);
581 hcd->state = HC_STATE_RUNNING; 583 hcd->state = HC_STATE_RUNNING;
582 ehci_writel(ehci, FLAG_CF, &ehci->regs->configured_flag); 584 ehci_writel(ehci, FLAG_CF, &ehci->regs->configured_flag);
583 ehci_readl(ehci, &ehci->regs->command); /* unblock posted writes */ 585 ehci_readl(ehci, &ehci->regs->command); /* unblock posted writes */
586 msleep(5);
584 up_write(&ehci_cf_port_reset_rwsem); 587 up_write(&ehci_cf_port_reset_rwsem);
585 588
586 temp = HC_VERSION(ehci_readl(ehci, &ehci->caps->hc_capbase)); 589 temp = HC_VERSION(ehci_readl(ehci, &ehci->caps->hc_capbase));
diff --git a/drivers/usb/image/microtek.c b/drivers/usb/image/microtek.c
index 91e999c9f680..bc207e3c21f5 100644
--- a/drivers/usb/image/microtek.c
+++ b/drivers/usb/image/microtek.c
@@ -819,7 +819,7 @@ static int mts_usb_probe(struct usb_interface *intf,
819 goto out_kfree2; 819 goto out_kfree2;
820 820
821 new_desc->host->hostdata[0] = (unsigned long)new_desc; 821 new_desc->host->hostdata[0] = (unsigned long)new_desc;
822 if (scsi_add_host(new_desc->host, NULL)) { 822 if (scsi_add_host(new_desc->host, &dev->dev)) {
823 err_retval = -EIO; 823 err_retval = -EIO;
824 goto out_host_put; 824 goto out_host_put;
825 } 825 }
diff --git a/drivers/usb/misc/adutux.c b/drivers/usb/misc/adutux.c
index c567aa7a41ea..5a2c44e4c1f7 100644
--- a/drivers/usb/misc/adutux.c
+++ b/drivers/usb/misc/adutux.c
@@ -79,12 +79,22 @@ MODULE_DEVICE_TABLE(usb, device_table);
79 79
80#define COMMAND_TIMEOUT (2*HZ) /* 60 second timeout for a command */ 80#define COMMAND_TIMEOUT (2*HZ) /* 60 second timeout for a command */
81 81
82/*
83 * The locking scheme is a vanilla 3-lock:
84 * adu_device.buflock: A spinlock, covers what IRQs touch.
85 * adutux_mutex: A Static lock to cover open_count. It would also cover
86 * any globals, but we don't have them in 2.6.
87 * adu_device.mtx: A mutex to hold across sleepers like copy_from_user.
88 * It covers all of adu_device, except the open_count
89 * and what .buflock covers.
90 */
91
82/* Structure to hold all of our device specific stuff */ 92/* Structure to hold all of our device specific stuff */
83struct adu_device { 93struct adu_device {
84 struct mutex mtx; /* locks this structure */ 94 struct mutex mtx;
85 struct usb_device* udev; /* save off the usb device pointer */ 95 struct usb_device* udev; /* save off the usb device pointer */
86 struct usb_interface* interface; 96 struct usb_interface* interface;
87 unsigned char minor; /* the starting minor number for this device */ 97 unsigned int minor; /* the starting minor number for this device */
88 char serial_number[8]; 98 char serial_number[8];
89 99
90 int open_count; /* number of times this port has been opened */ 100 int open_count; /* number of times this port has been opened */
@@ -107,8 +117,11 @@ struct adu_device {
107 char* interrupt_out_buffer; 117 char* interrupt_out_buffer;
108 struct usb_endpoint_descriptor* interrupt_out_endpoint; 118 struct usb_endpoint_descriptor* interrupt_out_endpoint;
109 struct urb* interrupt_out_urb; 119 struct urb* interrupt_out_urb;
120 int out_urb_finished;
110}; 121};
111 122
123static DEFINE_MUTEX(adutux_mutex);
124
112static struct usb_driver adu_driver; 125static struct usb_driver adu_driver;
113 126
114static void adu_debug_data(int level, const char *function, int size, 127static void adu_debug_data(int level, const char *function, int size,
@@ -132,27 +145,31 @@ static void adu_debug_data(int level, const char *function, int size,
132 */ 145 */
133static void adu_abort_transfers(struct adu_device *dev) 146static void adu_abort_transfers(struct adu_device *dev)
134{ 147{
135 dbg(2," %s : enter", __FUNCTION__); 148 unsigned long flags;
136 149
137 if (dev == NULL) { 150 dbg(2," %s : enter", __FUNCTION__);
138 dbg(1," %s : dev is null", __FUNCTION__);
139 goto exit;
140 }
141 151
142 if (dev->udev == NULL) { 152 if (dev->udev == NULL) {
143 dbg(1," %s : udev is null", __FUNCTION__); 153 dbg(1," %s : udev is null", __FUNCTION__);
144 goto exit; 154 goto exit;
145 } 155 }
146 156
147 dbg(2," %s : udev state %d", __FUNCTION__, dev->udev->state);
148 if (dev->udev->state == USB_STATE_NOTATTACHED) {
149 dbg(1," %s : udev is not attached", __FUNCTION__);
150 goto exit;
151 }
152
153 /* shutdown transfer */ 157 /* shutdown transfer */
154 usb_unlink_urb(dev->interrupt_in_urb); 158
155 usb_unlink_urb(dev->interrupt_out_urb); 159 /* XXX Anchor these instead */
160 spin_lock_irqsave(&dev->buflock, flags);
161 if (!dev->read_urb_finished) {
162 spin_unlock_irqrestore(&dev->buflock, flags);
163 usb_kill_urb(dev->interrupt_in_urb);
164 } else
165 spin_unlock_irqrestore(&dev->buflock, flags);
166
167 spin_lock_irqsave(&dev->buflock, flags);
168 if (!dev->out_urb_finished) {
169 spin_unlock_irqrestore(&dev->buflock, flags);
170 usb_kill_urb(dev->interrupt_out_urb);
171 } else
172 spin_unlock_irqrestore(&dev->buflock, flags);
156 173
157exit: 174exit:
158 dbg(2," %s : leave", __FUNCTION__); 175 dbg(2," %s : leave", __FUNCTION__);
@@ -162,8 +179,6 @@ static void adu_delete(struct adu_device *dev)
162{ 179{
163 dbg(2, "%s enter", __FUNCTION__); 180 dbg(2, "%s enter", __FUNCTION__);
164 181
165 adu_abort_transfers(dev);
166
167 /* free data structures */ 182 /* free data structures */
168 usb_free_urb(dev->interrupt_in_urb); 183 usb_free_urb(dev->interrupt_in_urb);
169 usb_free_urb(dev->interrupt_out_urb); 184 usb_free_urb(dev->interrupt_out_urb);
@@ -239,7 +254,10 @@ static void adu_interrupt_out_callback(struct urb *urb)
239 goto exit; 254 goto exit;
240 } 255 }
241 256
242 wake_up_interruptible(&dev->write_wait); 257 spin_lock(&dev->buflock);
258 dev->out_urb_finished = 1;
259 wake_up(&dev->write_wait);
260 spin_unlock(&dev->buflock);
243exit: 261exit:
244 262
245 adu_debug_data(5, __FUNCTION__, urb->actual_length, 263 adu_debug_data(5, __FUNCTION__, urb->actual_length,
@@ -252,12 +270,17 @@ static int adu_open(struct inode *inode, struct file *file)
252 struct adu_device *dev = NULL; 270 struct adu_device *dev = NULL;
253 struct usb_interface *interface; 271 struct usb_interface *interface;
254 int subminor; 272 int subminor;
255 int retval = 0; 273 int retval;
256 274
257 dbg(2,"%s : enter", __FUNCTION__); 275 dbg(2,"%s : enter", __FUNCTION__);
258 276
259 subminor = iminor(inode); 277 subminor = iminor(inode);
260 278
279 if ((retval = mutex_lock_interruptible(&adutux_mutex))) {
280 dbg(2, "%s : mutex lock failed", __FUNCTION__);
281 goto exit_no_lock;
282 }
283
261 interface = usb_find_interface(&adu_driver, subminor); 284 interface = usb_find_interface(&adu_driver, subminor);
262 if (!interface) { 285 if (!interface) {
263 err("%s - error, can't find device for minor %d", 286 err("%s - error, can't find device for minor %d",
@@ -267,54 +290,54 @@ static int adu_open(struct inode *inode, struct file *file)
267 } 290 }
268 291
269 dev = usb_get_intfdata(interface); 292 dev = usb_get_intfdata(interface);
270 if (!dev) { 293 if (!dev || !dev->udev) {
271 retval = -ENODEV; 294 retval = -ENODEV;
272 goto exit_no_device; 295 goto exit_no_device;
273 } 296 }
274 297
275 /* lock this device */ 298 /* check that nobody else is using the device */
276 if ((retval = mutex_lock_interruptible(&dev->mtx))) { 299 if (dev->open_count) {
277 dbg(2, "%s : mutex lock failed", __FUNCTION__); 300 retval = -EBUSY;
278 goto exit_no_device; 301 goto exit_no_device;
279 } 302 }
280 303
281 /* increment our usage count for the device */
282 ++dev->open_count; 304 ++dev->open_count;
283 dbg(2,"%s : open count %d", __FUNCTION__, dev->open_count); 305 dbg(2,"%s : open count %d", __FUNCTION__, dev->open_count);
284 306
285 /* save device in the file's private structure */ 307 /* save device in the file's private structure */
286 file->private_data = dev; 308 file->private_data = dev;
287 309
288 if (dev->open_count == 1) { 310 /* initialize in direction */
289 /* initialize in direction */ 311 dev->read_buffer_length = 0;
290 dev->read_buffer_length = 0;
291 312
292 /* fixup first read by having urb waiting for it */ 313 /* fixup first read by having urb waiting for it */
293 usb_fill_int_urb(dev->interrupt_in_urb,dev->udev, 314 usb_fill_int_urb(dev->interrupt_in_urb,dev->udev,
294 usb_rcvintpipe(dev->udev, 315 usb_rcvintpipe(dev->udev,
295 dev->interrupt_in_endpoint->bEndpointAddress), 316 dev->interrupt_in_endpoint->bEndpointAddress),
296 dev->interrupt_in_buffer, 317 dev->interrupt_in_buffer,
297 le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize), 318 le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize),
298 adu_interrupt_in_callback, dev, 319 adu_interrupt_in_callback, dev,
299 dev->interrupt_in_endpoint->bInterval); 320 dev->interrupt_in_endpoint->bInterval);
300 /* dev->interrupt_in_urb->transfer_flags |= URB_ASYNC_UNLINK; */ 321 dev->read_urb_finished = 0;
301 dev->read_urb_finished = 0; 322 if (usb_submit_urb(dev->interrupt_in_urb, GFP_KERNEL))
302 retval = usb_submit_urb(dev->interrupt_in_urb, GFP_KERNEL); 323 dev->read_urb_finished = 1;
303 if (retval) 324 /* we ignore failure */
304 --dev->open_count; 325 /* end of fixup for first read */
305 } 326
306 mutex_unlock(&dev->mtx); 327 /* initialize out direction */
328 dev->out_urb_finished = 1;
329
330 retval = 0;
307 331
308exit_no_device: 332exit_no_device:
333 mutex_unlock(&adutux_mutex);
334exit_no_lock:
309 dbg(2,"%s : leave, return value %d ", __FUNCTION__, retval); 335 dbg(2,"%s : leave, return value %d ", __FUNCTION__, retval);
310
311 return retval; 336 return retval;
312} 337}
313 338
314static int adu_release_internal(struct adu_device *dev) 339static void adu_release_internal(struct adu_device *dev)
315{ 340{
316 int retval = 0;
317
318 dbg(2," %s : enter", __FUNCTION__); 341 dbg(2," %s : enter", __FUNCTION__);
319 342
320 /* decrement our usage count for the device */ 343 /* decrement our usage count for the device */
@@ -326,12 +349,11 @@ static int adu_release_internal(struct adu_device *dev)
326 } 349 }
327 350
328 dbg(2," %s : leave", __FUNCTION__); 351 dbg(2," %s : leave", __FUNCTION__);
329 return retval;
330} 352}
331 353
332static int adu_release(struct inode *inode, struct file *file) 354static int adu_release(struct inode *inode, struct file *file)
333{ 355{
334 struct adu_device *dev = NULL; 356 struct adu_device *dev;
335 int retval = 0; 357 int retval = 0;
336 358
337 dbg(2," %s : enter", __FUNCTION__); 359 dbg(2," %s : enter", __FUNCTION__);
@@ -343,15 +365,13 @@ static int adu_release(struct inode *inode, struct file *file)
343 } 365 }
344 366
345 dev = file->private_data; 367 dev = file->private_data;
346
347 if (dev == NULL) { 368 if (dev == NULL) {
348 dbg(1," %s : object is NULL", __FUNCTION__); 369 dbg(1," %s : object is NULL", __FUNCTION__);
349 retval = -ENODEV; 370 retval = -ENODEV;
350 goto exit; 371 goto exit;
351 } 372 }
352 373
353 /* lock our device */ 374 mutex_lock(&adutux_mutex); /* not interruptible */
354 mutex_lock(&dev->mtx); /* not interruptible */
355 375
356 if (dev->open_count <= 0) { 376 if (dev->open_count <= 0) {
357 dbg(1," %s : device not opened", __FUNCTION__); 377 dbg(1," %s : device not opened", __FUNCTION__);
@@ -359,19 +379,15 @@ static int adu_release(struct inode *inode, struct file *file)
359 goto exit; 379 goto exit;
360 } 380 }
361 381
382 adu_release_internal(dev);
362 if (dev->udev == NULL) { 383 if (dev->udev == NULL) {
363 /* the device was unplugged before the file was released */ 384 /* the device was unplugged before the file was released */
364 mutex_unlock(&dev->mtx); 385 if (!dev->open_count) /* ... and we're the last user */
365 adu_delete(dev); 386 adu_delete(dev);
366 dev = NULL;
367 } else {
368 /* do the work */
369 retval = adu_release_internal(dev);
370 } 387 }
371 388
372exit: 389exit:
373 if (dev) 390 mutex_unlock(&adutux_mutex);
374 mutex_unlock(&dev->mtx);
375 dbg(2," %s : leave, return value %d", __FUNCTION__, retval); 391 dbg(2," %s : leave, return value %d", __FUNCTION__, retval);
376 return retval; 392 return retval;
377} 393}
@@ -393,12 +409,12 @@ static ssize_t adu_read(struct file *file, __user char *buffer, size_t count,
393 409
394 dev = file->private_data; 410 dev = file->private_data;
395 dbg(2," %s : dev=%p", __FUNCTION__, dev); 411 dbg(2," %s : dev=%p", __FUNCTION__, dev);
396 /* lock this object */ 412
397 if (mutex_lock_interruptible(&dev->mtx)) 413 if (mutex_lock_interruptible(&dev->mtx))
398 return -ERESTARTSYS; 414 return -ERESTARTSYS;
399 415
400 /* verify that the device wasn't unplugged */ 416 /* verify that the device wasn't unplugged */
401 if (dev->udev == NULL || dev->minor == 0) { 417 if (dev->udev == NULL) {
402 retval = -ENODEV; 418 retval = -ENODEV;
403 err("No device or device unplugged %d", retval); 419 err("No device or device unplugged %d", retval);
404 goto exit; 420 goto exit;
@@ -452,7 +468,7 @@ static ssize_t adu_read(struct file *file, __user char *buffer, size_t count,
452 should_submit = 1; 468 should_submit = 1;
453 } else { 469 } else {
454 /* even the primary was empty - we may need to do IO */ 470 /* even the primary was empty - we may need to do IO */
455 if (dev->interrupt_in_urb->status == -EINPROGRESS) { 471 if (!dev->read_urb_finished) {
456 /* somebody is doing IO */ 472 /* somebody is doing IO */
457 spin_unlock_irqrestore(&dev->buflock, flags); 473 spin_unlock_irqrestore(&dev->buflock, flags);
458 dbg(2," %s : submitted already", __FUNCTION__); 474 dbg(2," %s : submitted already", __FUNCTION__);
@@ -460,6 +476,7 @@ static ssize_t adu_read(struct file *file, __user char *buffer, size_t count,
460 /* we must initiate input */ 476 /* we must initiate input */
461 dbg(2," %s : initiate input", __FUNCTION__); 477 dbg(2," %s : initiate input", __FUNCTION__);
462 dev->read_urb_finished = 0; 478 dev->read_urb_finished = 0;
479 spin_unlock_irqrestore(&dev->buflock, flags);
463 480
464 usb_fill_int_urb(dev->interrupt_in_urb,dev->udev, 481 usb_fill_int_urb(dev->interrupt_in_urb,dev->udev,
465 usb_rcvintpipe(dev->udev, 482 usb_rcvintpipe(dev->udev,
@@ -469,15 +486,12 @@ static ssize_t adu_read(struct file *file, __user char *buffer, size_t count,
469 adu_interrupt_in_callback, 486 adu_interrupt_in_callback,
470 dev, 487 dev,
471 dev->interrupt_in_endpoint->bInterval); 488 dev->interrupt_in_endpoint->bInterval);
472 retval = usb_submit_urb(dev->interrupt_in_urb, GFP_ATOMIC); 489 retval = usb_submit_urb(dev->interrupt_in_urb, GFP_KERNEL);
473 if (!retval) { 490 if (retval) {
474 spin_unlock_irqrestore(&dev->buflock, flags); 491 dev->read_urb_finished = 1;
475 dbg(2," %s : submitted OK", __FUNCTION__);
476 } else {
477 if (retval == -ENOMEM) { 492 if (retval == -ENOMEM) {
478 retval = bytes_read ? bytes_read : -ENOMEM; 493 retval = bytes_read ? bytes_read : -ENOMEM;
479 } 494 }
480 spin_unlock_irqrestore(&dev->buflock, flags);
481 dbg(2," %s : submit failed", __FUNCTION__); 495 dbg(2," %s : submit failed", __FUNCTION__);
482 goto exit; 496 goto exit;
483 } 497 }
@@ -486,10 +500,14 @@ static ssize_t adu_read(struct file *file, __user char *buffer, size_t count,
486 /* we wait for I/O to complete */ 500 /* we wait for I/O to complete */
487 set_current_state(TASK_INTERRUPTIBLE); 501 set_current_state(TASK_INTERRUPTIBLE);
488 add_wait_queue(&dev->read_wait, &wait); 502 add_wait_queue(&dev->read_wait, &wait);
489 if (!dev->read_urb_finished) 503 spin_lock_irqsave(&dev->buflock, flags);
504 if (!dev->read_urb_finished) {
505 spin_unlock_irqrestore(&dev->buflock, flags);
490 timeout = schedule_timeout(COMMAND_TIMEOUT); 506 timeout = schedule_timeout(COMMAND_TIMEOUT);
491 else 507 } else {
508 spin_unlock_irqrestore(&dev->buflock, flags);
492 set_current_state(TASK_RUNNING); 509 set_current_state(TASK_RUNNING);
510 }
493 remove_wait_queue(&dev->read_wait, &wait); 511 remove_wait_queue(&dev->read_wait, &wait);
494 512
495 if (timeout <= 0) { 513 if (timeout <= 0) {
@@ -509,19 +527,23 @@ static ssize_t adu_read(struct file *file, __user char *buffer, size_t count,
509 527
510 retval = bytes_read; 528 retval = bytes_read;
511 /* if the primary buffer is empty then use it */ 529 /* if the primary buffer is empty then use it */
512 if (should_submit && !dev->interrupt_in_urb->status==-EINPROGRESS) { 530 spin_lock_irqsave(&dev->buflock, flags);
531 if (should_submit && dev->read_urb_finished) {
532 dev->read_urb_finished = 0;
533 spin_unlock_irqrestore(&dev->buflock, flags);
513 usb_fill_int_urb(dev->interrupt_in_urb,dev->udev, 534 usb_fill_int_urb(dev->interrupt_in_urb,dev->udev,
514 usb_rcvintpipe(dev->udev, 535 usb_rcvintpipe(dev->udev,
515 dev->interrupt_in_endpoint->bEndpointAddress), 536 dev->interrupt_in_endpoint->bEndpointAddress),
516 dev->interrupt_in_buffer, 537 dev->interrupt_in_buffer,
517 le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize), 538 le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize),
518 adu_interrupt_in_callback, 539 adu_interrupt_in_callback,
519 dev, 540 dev,
520 dev->interrupt_in_endpoint->bInterval); 541 dev->interrupt_in_endpoint->bInterval);
521 /* dev->interrupt_in_urb->transfer_flags |= URB_ASYNC_UNLINK; */ 542 if (usb_submit_urb(dev->interrupt_in_urb, GFP_KERNEL) != 0)
522 dev->read_urb_finished = 0; 543 dev->read_urb_finished = 1;
523 usb_submit_urb(dev->interrupt_in_urb, GFP_KERNEL);
524 /* we ignore failure */ 544 /* we ignore failure */
545 } else {
546 spin_unlock_irqrestore(&dev->buflock, flags);
525 } 547 }
526 548
527exit: 549exit:
@@ -535,24 +557,24 @@ exit:
535static ssize_t adu_write(struct file *file, const __user char *buffer, 557static ssize_t adu_write(struct file *file, const __user char *buffer,
536 size_t count, loff_t *ppos) 558 size_t count, loff_t *ppos)
537{ 559{
560 DECLARE_WAITQUEUE(waita, current);
538 struct adu_device *dev; 561 struct adu_device *dev;
539 size_t bytes_written = 0; 562 size_t bytes_written = 0;
540 size_t bytes_to_write; 563 size_t bytes_to_write;
541 size_t buffer_size; 564 size_t buffer_size;
565 unsigned long flags;
542 int retval; 566 int retval;
543 int timeout = 0;
544 567
545 dbg(2," %s : enter, count = %Zd", __FUNCTION__, count); 568 dbg(2," %s : enter, count = %Zd", __FUNCTION__, count);
546 569
547 dev = file->private_data; 570 dev = file->private_data;
548 571
549 /* lock this object */
550 retval = mutex_lock_interruptible(&dev->mtx); 572 retval = mutex_lock_interruptible(&dev->mtx);
551 if (retval) 573 if (retval)
552 goto exit_nolock; 574 goto exit_nolock;
553 575
554 /* verify that the device wasn't unplugged */ 576 /* verify that the device wasn't unplugged */
555 if (dev->udev == NULL || dev->minor == 0) { 577 if (dev->udev == NULL) {
556 retval = -ENODEV; 578 retval = -ENODEV;
557 err("No device or device unplugged %d", retval); 579 err("No device or device unplugged %d", retval);
558 goto exit; 580 goto exit;
@@ -564,42 +586,37 @@ static ssize_t adu_write(struct file *file, const __user char *buffer,
564 goto exit; 586 goto exit;
565 } 587 }
566 588
567
568 while (count > 0) { 589 while (count > 0) {
569 if (dev->interrupt_out_urb->status == -EINPROGRESS) { 590 add_wait_queue(&dev->write_wait, &waita);
570 timeout = COMMAND_TIMEOUT; 591 set_current_state(TASK_INTERRUPTIBLE);
592 spin_lock_irqsave(&dev->buflock, flags);
593 if (!dev->out_urb_finished) {
594 spin_unlock_irqrestore(&dev->buflock, flags);
571 595
572 while (timeout > 0) { 596 mutex_unlock(&dev->mtx);
573 if (signal_pending(current)) { 597 if (signal_pending(current)) {
574 dbg(1," %s : interrupted", __FUNCTION__); 598 dbg(1," %s : interrupted", __FUNCTION__);
599 set_current_state(TASK_RUNNING);
575 retval = -EINTR; 600 retval = -EINTR;
576 goto exit; 601 goto exit_onqueue;
577 } 602 }
578 mutex_unlock(&dev->mtx); 603 if (schedule_timeout(COMMAND_TIMEOUT) == 0) {
579 timeout = interruptible_sleep_on_timeout(&dev->write_wait, timeout); 604 dbg(1, "%s - command timed out.", __FUNCTION__);
605 retval = -ETIMEDOUT;
606 goto exit_onqueue;
607 }
608 remove_wait_queue(&dev->write_wait, &waita);
580 retval = mutex_lock_interruptible(&dev->mtx); 609 retval = mutex_lock_interruptible(&dev->mtx);
581 if (retval) { 610 if (retval) {
582 retval = bytes_written ? bytes_written : retval; 611 retval = bytes_written ? bytes_written : retval;
583 goto exit_nolock; 612 goto exit_nolock;
584 } 613 }
585 if (timeout > 0) {
586 break;
587 }
588 dbg(1," %s : interrupted timeout: %d", __FUNCTION__, timeout);
589 }
590
591
592 dbg(1," %s : final timeout: %d", __FUNCTION__, timeout);
593
594 if (timeout == 0) {
595 dbg(1, "%s - command timed out.", __FUNCTION__);
596 retval = -ETIMEDOUT;
597 goto exit;
598 }
599
600 dbg(4," %s : in progress, count = %Zd", __FUNCTION__, count);
601 614
615 dbg(4," %s : in progress, count = %Zd", __FUNCTION__, count);
602 } else { 616 } else {
617 spin_unlock_irqrestore(&dev->buflock, flags);
618 set_current_state(TASK_RUNNING);
619 remove_wait_queue(&dev->write_wait, &waita);
603 dbg(4," %s : sending, count = %Zd", __FUNCTION__, count); 620 dbg(4," %s : sending, count = %Zd", __FUNCTION__, count);
604 621
605 /* write the data into interrupt_out_buffer from userspace */ 622 /* write the data into interrupt_out_buffer from userspace */
@@ -622,11 +639,12 @@ static ssize_t adu_write(struct file *file, const __user char *buffer,
622 bytes_to_write, 639 bytes_to_write,
623 adu_interrupt_out_callback, 640 adu_interrupt_out_callback,
624 dev, 641 dev,
625 dev->interrupt_in_endpoint->bInterval); 642 dev->interrupt_out_endpoint->bInterval);
626 /* dev->interrupt_in_urb->transfer_flags |= URB_ASYNC_UNLINK; */
627 dev->interrupt_out_urb->actual_length = bytes_to_write; 643 dev->interrupt_out_urb->actual_length = bytes_to_write;
644 dev->out_urb_finished = 0;
628 retval = usb_submit_urb(dev->interrupt_out_urb, GFP_KERNEL); 645 retval = usb_submit_urb(dev->interrupt_out_urb, GFP_KERNEL);
629 if (retval < 0) { 646 if (retval < 0) {
647 dev->out_urb_finished = 1;
630 err("Couldn't submit interrupt_out_urb %d", retval); 648 err("Couldn't submit interrupt_out_urb %d", retval);
631 goto exit; 649 goto exit;
632 } 650 }
@@ -637,16 +655,17 @@ static ssize_t adu_write(struct file *file, const __user char *buffer,
637 bytes_written += bytes_to_write; 655 bytes_written += bytes_to_write;
638 } 656 }
639 } 657 }
640 658 mutex_unlock(&dev->mtx);
641 retval = bytes_written; 659 return bytes_written;
642 660
643exit: 661exit:
644 /* unlock the device */
645 mutex_unlock(&dev->mtx); 662 mutex_unlock(&dev->mtx);
646exit_nolock: 663exit_nolock:
647
648 dbg(2," %s : leave, return value %d", __FUNCTION__, retval); 664 dbg(2," %s : leave, return value %d", __FUNCTION__, retval);
665 return retval;
649 666
667exit_onqueue:
668 remove_wait_queue(&dev->write_wait, &waita);
650 return retval; 669 return retval;
651} 670}
652 671
@@ -831,25 +850,22 @@ static void adu_disconnect(struct usb_interface *interface)
831 dbg(2," %s : enter", __FUNCTION__); 850 dbg(2," %s : enter", __FUNCTION__);
832 851
833 dev = usb_get_intfdata(interface); 852 dev = usb_get_intfdata(interface);
834 usb_set_intfdata(interface, NULL);
835 853
854 mutex_lock(&dev->mtx); /* not interruptible */
855 dev->udev = NULL; /* poison */
836 minor = dev->minor; 856 minor = dev->minor;
837
838 /* give back our minor */
839 usb_deregister_dev(interface, &adu_class); 857 usb_deregister_dev(interface, &adu_class);
840 dev->minor = 0; 858 mutex_unlock(&dev->mtx);
841 859
842 mutex_lock(&dev->mtx); /* not interruptible */ 860 mutex_lock(&adutux_mutex);
861 usb_set_intfdata(interface, NULL);
843 862
844 /* if the device is not opened, then we clean up right now */ 863 /* if the device is not opened, then we clean up right now */
845 dbg(2," %s : open count %d", __FUNCTION__, dev->open_count); 864 dbg(2," %s : open count %d", __FUNCTION__, dev->open_count);
846 if (!dev->open_count) { 865 if (!dev->open_count)
847 mutex_unlock(&dev->mtx);
848 adu_delete(dev); 866 adu_delete(dev);
849 } else { 867
850 dev->udev = NULL; 868 mutex_unlock(&adutux_mutex);
851 mutex_unlock(&dev->mtx);
852 }
853 869
854 dev_info(&interface->dev, "ADU device adutux%d now disconnected\n", 870 dev_info(&interface->dev, "ADU device adutux%d now disconnected\n",
855 (minor - ADU_MINOR_BASE)); 871 (minor - ADU_MINOR_BASE));
diff --git a/drivers/usb/misc/usbled.c b/drivers/usb/misc/usbled.c
index 49c5c5c4c431..06cb71942dc7 100644
--- a/drivers/usb/misc/usbled.c
+++ b/drivers/usb/misc/usbled.c
@@ -144,12 +144,14 @@ static void led_disconnect(struct usb_interface *interface)
144 struct usb_led *dev; 144 struct usb_led *dev;
145 145
146 dev = usb_get_intfdata (interface); 146 dev = usb_get_intfdata (interface);
147 usb_set_intfdata (interface, NULL);
148 147
149 device_remove_file(&interface->dev, &dev_attr_blue); 148 device_remove_file(&interface->dev, &dev_attr_blue);
150 device_remove_file(&interface->dev, &dev_attr_red); 149 device_remove_file(&interface->dev, &dev_attr_red);
151 device_remove_file(&interface->dev, &dev_attr_green); 150 device_remove_file(&interface->dev, &dev_attr_green);
152 151
152 /* first remove the files, then set the pointer to NULL */
153 usb_set_intfdata (interface, NULL);
154
153 usb_put_dev(dev->udev); 155 usb_put_dev(dev->udev);
154 156
155 kfree(dev); 157 kfree(dev);
diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c
index 9eb4a65ee4d9..d41531139c55 100644
--- a/drivers/usb/serial/generic.c
+++ b/drivers/usb/serial/generic.c
@@ -327,6 +327,7 @@ void usb_serial_generic_read_bulk_callback (struct urb *urb)
327 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 327 struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
328 unsigned char *data = urb->transfer_buffer; 328 unsigned char *data = urb->transfer_buffer;
329 int status = urb->status; 329 int status = urb->status;
330 unsigned long flags;
330 331
331 dbg("%s - port %d", __FUNCTION__, port->number); 332 dbg("%s - port %d", __FUNCTION__, port->number);
332 333
@@ -339,11 +340,11 @@ void usb_serial_generic_read_bulk_callback (struct urb *urb)
339 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, urb->actual_length, data); 340 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, urb->actual_length, data);
340 341
341 /* Throttle the device if requested by tty */ 342 /* Throttle the device if requested by tty */
342 spin_lock(&port->lock); 343 spin_lock_irqsave(&port->lock, flags);
343 if (!(port->throttled = port->throttle_req)) 344 if (!(port->throttled = port->throttle_req))
344 /* Handle data and continue reading from device */ 345 /* Handle data and continue reading from device */
345 flush_and_resubmit_read_urb(port); 346 flush_and_resubmit_read_urb(port);
346 spin_unlock(&port->lock); 347 spin_unlock_irqrestore(&port->lock, flags);
347} 348}
348EXPORT_SYMBOL_GPL(usb_serial_generic_read_bulk_callback); 349EXPORT_SYMBOL_GPL(usb_serial_generic_read_bulk_callback);
349 350
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index a5ced7e08cbf..c29c91271133 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -2711,7 +2711,7 @@ static int mos7840_startup(struct usb_serial *serial)
2711 status = mos7840_set_reg_sync(serial->port[0], ZLP_REG5, Data); 2711 status = mos7840_set_reg_sync(serial->port[0], ZLP_REG5, Data);
2712 if (status < 0) { 2712 if (status < 0) {
2713 dbg("Writing ZLP_REG5 failed status-0x%x\n", status); 2713 dbg("Writing ZLP_REG5 failed status-0x%x\n", status);
2714 return -1; 2714 goto error;
2715 } else 2715 } else
2716 dbg("ZLP_REG5 Writing success status%d\n", status); 2716 dbg("ZLP_REG5 Writing success status%d\n", status);
2717 2717
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index 2cd3f1d4b687..cf8add91de05 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -86,6 +86,7 @@ static struct usb_device_id id_table [] = {
86 { USB_DEVICE(ALCOR_VENDOR_ID, ALCOR_PRODUCT_ID) }, 86 { USB_DEVICE(ALCOR_VENDOR_ID, ALCOR_PRODUCT_ID) },
87 { USB_DEVICE(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_ID) }, 87 { USB_DEVICE(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_ID) },
88 { USB_DEVICE(WS002IN_VENDOR_ID, WS002IN_PRODUCT_ID) }, 88 { USB_DEVICE(WS002IN_VENDOR_ID, WS002IN_PRODUCT_ID) },
89 { USB_DEVICE(COREGA_VENDOR_ID, COREGA_PRODUCT_ID) },
89 { } /* Terminating entry */ 90 { } /* Terminating entry */
90}; 91};
91 92
diff --git a/drivers/usb/serial/pl2303.h b/drivers/usb/serial/pl2303.h
index ed603e3decd6..d31f5d299989 100644
--- a/drivers/usb/serial/pl2303.h
+++ b/drivers/usb/serial/pl2303.h
@@ -104,3 +104,6 @@
104#define WS002IN_VENDOR_ID 0x11f6 104#define WS002IN_VENDOR_ID 0x11f6
105#define WS002IN_PRODUCT_ID 0x2001 105#define WS002IN_PRODUCT_ID 0x2001
106 106
107/* Corega CG-USBRS232R Serial Adapter */
108#define COREGA_VENDOR_ID 0x07aa
109#define COREGA_PRODUCT_ID 0x002a
diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c
index 833f6e1e3721..605ebccdcd51 100644
--- a/drivers/usb/serial/sierra.c
+++ b/drivers/usb/serial/sierra.c
@@ -136,6 +136,8 @@ static struct usb_device_id id_table_3port [] = {
136 { USB_DEVICE(0x0f30, 0x1b1d) }, /* Sierra Wireless MC5720 */ 136 { USB_DEVICE(0x0f30, 0x1b1d) }, /* Sierra Wireless MC5720 */
137 { USB_DEVICE(0x1199, 0x0218) }, /* Sierra Wireless MC5720 */ 137 { USB_DEVICE(0x1199, 0x0218) }, /* Sierra Wireless MC5720 */
138 { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */ 138 { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */
139 { USB_DEVICE(0x1199, 0x0220) }, /* Sierra Wireless MC5725 */
140 { USB_DEVICE(0x1199, 0x0220) }, /* Sierra Wireless MC5725 */
139 { USB_DEVICE(0x1199, 0x0019) }, /* Sierra Wireless AirCard 595 */ 141 { USB_DEVICE(0x1199, 0x0019) }, /* Sierra Wireless AirCard 595 */
140 { USB_DEVICE(0x1199, 0x0021) }, /* Sierra Wireless AirCard 597E */ 142 { USB_DEVICE(0x1199, 0x0021) }, /* Sierra Wireless AirCard 597E */
141 { USB_DEVICE(0x1199, 0x0120) }, /* Sierra Wireless USB Dongle 595U*/ 143 { USB_DEVICE(0x1199, 0x0120) }, /* Sierra Wireless USB Dongle 595U*/
diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
index 1ba19eaa1970..836a34ae6ec6 100644
--- a/drivers/usb/storage/scsiglue.c
+++ b/drivers/usb/storage/scsiglue.c
@@ -177,6 +177,10 @@ static int slave_configure(struct scsi_device *sdev)
177 * is an occasional series of retries that will all fail. */ 177 * is an occasional series of retries that will all fail. */
178 sdev->retry_hwerror = 1; 178 sdev->retry_hwerror = 1;
179 179
180 /* USB disks should allow restart. Some drives spin down
181 * automatically, requiring a START-STOP UNIT command. */
182 sdev->allow_restart = 1;
183
180 } else { 184 } else {
181 185
182 /* Non-disk-type devices don't need to blacklist any pages 186 /* Non-disk-type devices don't need to blacklist any pages
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index 22ab2380367d..2c27721bd259 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -342,11 +342,11 @@ UNUSUAL_DEV( 0x04b0, 0x040d, 0x0100, 0x0100,
342 US_FL_FIX_CAPACITY), 342 US_FL_FIX_CAPACITY),
343 343
344/* Reported by Graber and Mike Pagano <mpagano-kernel@mpagano.com> */ 344/* Reported by Graber and Mike Pagano <mpagano-kernel@mpagano.com> */
345UNUSUAL_DEV( 0x04b0, 0x040f, 0x0200, 0x0200, 345UNUSUAL_DEV( 0x04b0, 0x040f, 0x0100, 0x0200,
346 "NIKON", 346 "NIKON",
347 "NIKON DSC D200", 347 "NIKON DSC D200",
348 US_SC_DEVICE, US_PR_DEVICE, NULL, 348 US_SC_DEVICE, US_PR_DEVICE, NULL,
349 US_FL_FIX_CAPACITY), 349 US_FL_FIX_CAPACITY),
350 350
351/* Reported by Emil Larsson <emil@swip.net> */ 351/* Reported by Emil Larsson <emil@swip.net> */
352UNUSUAL_DEV( 0x04b0, 0x0411, 0x0100, 0x0101, 352UNUSUAL_DEV( 0x04b0, 0x0411, 0x0100, 0x0101,
@@ -731,6 +731,13 @@ UNUSUAL_DEV( 0x0584, 0x0008, 0x0102, 0x0102,
731 US_SC_SCSI, US_PR_ALAUDA, init_alauda, 0 ), 731 US_SC_SCSI, US_PR_ALAUDA, init_alauda, 0 ),
732#endif 732#endif
733 733
734/* Reported by RTE <raszilki@yandex.ru> */
735UNUSUAL_DEV( 0x058f, 0x6387, 0x0141, 0x0141,
736 "JetFlash",
737 "TS1GJF2A/120",
738 US_SC_DEVICE, US_PR_DEVICE, NULL,
739 US_FL_MAX_SECTORS_64 ),
740
734/* Fabrizio Fellini <fello@libero.it> */ 741/* Fabrizio Fellini <fello@libero.it> */
735UNUSUAL_DEV( 0x0595, 0x4343, 0x0000, 0x2210, 742UNUSUAL_DEV( 0x0595, 0x4343, 0x0000, 0x2210,
736 "Fujifilm", 743 "Fujifilm",