diff options
author | Linus Torvalds <torvalds@g5.osdl.org> | 2006-03-21 12:25:47 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-03-21 12:25:47 -0500 |
commit | 2bf2154c6bb5599e3ec3f73c34861a0b12aa839e (patch) | |
tree | 62691bd915e2e3c2e6648306d3fb893f7a1dc57e /drivers/usb/core | |
parent | 08a4ecee986dd98e86090ff5faac4782b6765aed (diff) | |
parent | 71a8924bee63d891f6256d560e32416a458440b3 (diff) |
Merge master.kernel.org:/pub/scm/linux/kernel/git/gregkh/usb-2.6
* master.kernel.org:/pub/scm/linux/kernel/git/gregkh/usb-2.6: (81 commits)
[PATCH] USB: omninet: fix up debugging comments
[PATCH] USB serial: add navman driver
[PATCH] USB: Fix irda-usb use after use
[PATCH] USB: rtl8150 small fix
[PATCH] USB: ftdi_sio: add Icom ID1 USB product and vendor ids
[PATCH] USB: cp2101: add new device IDs
[PATCH] USB: fix check_ctrlrecip to allow control transfers in state ADDRESS
[PATCH] USB: vicam.c: fix a NULL pointer dereference
[PATCH] USB: ZC0301 driver bugfix
[PATCH] USB: add support for Creativelabs Silvercrest USB keyboard
[PATCH] USB: storage: new unusual_devs.h entry: Mitsumi 7in1 Card Reader
[PATCH] USB: storage: unusual_devs.h entry 0420:0001
[PATCH] USB: storage: another unusual_devs.h entry
[PATCH] USB: storage: sandisk unusual_devices entry
[PATCH] USB: fix initdata issue in isp116x-hcd
[PATCH] USB: usbcore: usb_set_configuration oops (NULL ptr dereference)
[PATCH] USB: usbcore: Don't assume a USB configuration includes any interfaces
[PATCH] USB: ub 03 drop stall clearing
[PATCH] USB: ub 02 remove diag
[PATCH] USB: ub 01 remove first_open
...
Diffstat (limited to 'drivers/usb/core')
-rw-r--r-- | drivers/usb/core/devices.c | 7 | ||||
-rw-r--r-- | drivers/usb/core/devio.c | 24 | ||||
-rw-r--r-- | drivers/usb/core/hcd-pci.c | 11 | ||||
-rw-r--r-- | drivers/usb/core/hcd.c | 153 | ||||
-rw-r--r-- | drivers/usb/core/hcd.h | 4 | ||||
-rw-r--r-- | drivers/usb/core/hub.c | 45 | ||||
-rw-r--r-- | drivers/usb/core/message.c | 17 | ||||
-rw-r--r-- | drivers/usb/core/notify.c | 15 | ||||
-rw-r--r-- | drivers/usb/core/usb.c | 5 |
9 files changed, 156 insertions, 125 deletions
diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c index 2684e15b813b..c0f37343a276 100644 --- a/drivers/usb/core/devices.c +++ b/drivers/usb/core/devices.c | |||
@@ -57,6 +57,7 @@ | |||
57 | #include <linux/usb.h> | 57 | #include <linux/usb.h> |
58 | #include <linux/smp_lock.h> | 58 | #include <linux/smp_lock.h> |
59 | #include <linux/usbdevice_fs.h> | 59 | #include <linux/usbdevice_fs.h> |
60 | #include <linux/mutex.h> | ||
60 | #include <asm/uaccess.h> | 61 | #include <asm/uaccess.h> |
61 | 62 | ||
62 | #include "usb.h" | 63 | #include "usb.h" |
@@ -570,7 +571,7 @@ static ssize_t usb_device_read(struct file *file, char __user *buf, size_t nbyte | |||
570 | if (!access_ok(VERIFY_WRITE, buf, nbytes)) | 571 | if (!access_ok(VERIFY_WRITE, buf, nbytes)) |
571 | return -EFAULT; | 572 | return -EFAULT; |
572 | 573 | ||
573 | down (&usb_bus_list_lock); | 574 | mutex_lock(&usb_bus_list_lock); |
574 | /* print devices for all busses */ | 575 | /* print devices for all busses */ |
575 | list_for_each_entry(bus, &usb_bus_list, bus_list) { | 576 | list_for_each_entry(bus, &usb_bus_list, bus_list) { |
576 | /* recurse through all children of the root hub */ | 577 | /* recurse through all children of the root hub */ |
@@ -580,12 +581,12 @@ static ssize_t usb_device_read(struct file *file, char __user *buf, size_t nbyte | |||
580 | ret = usb_device_dump(&buf, &nbytes, &skip_bytes, ppos, bus->root_hub, bus, 0, 0, 0); | 581 | ret = usb_device_dump(&buf, &nbytes, &skip_bytes, ppos, bus->root_hub, bus, 0, 0, 0); |
581 | usb_unlock_device(bus->root_hub); | 582 | usb_unlock_device(bus->root_hub); |
582 | if (ret < 0) { | 583 | if (ret < 0) { |
583 | up(&usb_bus_list_lock); | 584 | mutex_unlock(&usb_bus_list_lock); |
584 | return ret; | 585 | return ret; |
585 | } | 586 | } |
586 | total_written += ret; | 587 | total_written += ret; |
587 | } | 588 | } |
588 | up (&usb_bus_list_lock); | 589 | mutex_unlock(&usb_bus_list_lock); |
589 | return total_written; | 590 | return total_written; |
590 | } | 591 | } |
591 | 592 | ||
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c index 2b68998fe4b3..545da37afca7 100644 --- a/drivers/usb/core/devio.c +++ b/drivers/usb/core/devio.c | |||
@@ -134,26 +134,21 @@ static ssize_t usbdev_read(struct file *file, char __user *buf, size_t nbytes, l | |||
134 | } | 134 | } |
135 | 135 | ||
136 | if (pos < sizeof(struct usb_device_descriptor)) { | 136 | if (pos < sizeof(struct usb_device_descriptor)) { |
137 | struct usb_device_descriptor *desc = kmalloc(sizeof(*desc), GFP_KERNEL); | 137 | struct usb_device_descriptor temp_desc ; /* 18 bytes - fits on the stack */ |
138 | if (!desc) { | 138 | |
139 | ret = -ENOMEM; | 139 | memcpy(&temp_desc, &dev->descriptor, sizeof(dev->descriptor)); |
140 | goto err; | 140 | le16_to_cpus(&temp_desc.bcdUSB); |
141 | } | 141 | le16_to_cpus(&temp_desc.idVendor); |
142 | memcpy(desc, &dev->descriptor, sizeof(dev->descriptor)); | 142 | le16_to_cpus(&temp_desc.idProduct); |
143 | le16_to_cpus(&desc->bcdUSB); | 143 | le16_to_cpus(&temp_desc.bcdDevice); |
144 | le16_to_cpus(&desc->idVendor); | ||
145 | le16_to_cpus(&desc->idProduct); | ||
146 | le16_to_cpus(&desc->bcdDevice); | ||
147 | 144 | ||
148 | len = sizeof(struct usb_device_descriptor) - pos; | 145 | len = sizeof(struct usb_device_descriptor) - pos; |
149 | if (len > nbytes) | 146 | if (len > nbytes) |
150 | len = nbytes; | 147 | len = nbytes; |
151 | if (copy_to_user(buf, ((char *)desc) + pos, len)) { | 148 | if (copy_to_user(buf, ((char *)&temp_desc) + pos, len)) { |
152 | kfree(desc); | ||
153 | ret = -EFAULT; | 149 | ret = -EFAULT; |
154 | goto err; | 150 | goto err; |
155 | } | 151 | } |
156 | kfree(desc); | ||
157 | 152 | ||
158 | *ppos += len; | 153 | *ppos += len; |
159 | buf += len; | 154 | buf += len; |
@@ -498,7 +493,8 @@ static int check_ctrlrecip(struct dev_state *ps, unsigned int requesttype, unsig | |||
498 | { | 493 | { |
499 | int ret = 0; | 494 | int ret = 0; |
500 | 495 | ||
501 | if (ps->dev->state != USB_STATE_CONFIGURED) | 496 | if (ps->dev->state != USB_STATE_ADDRESS |
497 | && ps->dev->state != USB_STATE_CONFIGURED) | ||
502 | return -EHOSTUNREACH; | 498 | return -EHOSTUNREACH; |
503 | if (USB_TYPE_VENDOR == (USB_TYPE_MASK & requesttype)) | 499 | if (USB_TYPE_VENDOR == (USB_TYPE_MASK & requesttype)) |
504 | return 0; | 500 | return 0; |
diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c index 29b5b2a6e183..e0afb5ad29e5 100644 --- a/drivers/usb/core/hcd-pci.c +++ b/drivers/usb/core/hcd-pci.c | |||
@@ -264,14 +264,19 @@ int usb_hcd_pci_suspend (struct pci_dev *dev, pm_message_t message) | |||
264 | */ | 264 | */ |
265 | retval = pci_set_power_state (dev, PCI_D3hot); | 265 | retval = pci_set_power_state (dev, PCI_D3hot); |
266 | if (retval == 0) { | 266 | if (retval == 0) { |
267 | dev_dbg (hcd->self.controller, "--> PCI D3\n"); | 267 | int wake = device_can_wakeup(&hcd->self.root_hub->dev); |
268 | |||
269 | wake = wake && device_may_wakeup(hcd->self.controller); | ||
270 | |||
271 | dev_dbg (hcd->self.controller, "--> PCI D3%s\n", | ||
272 | wake ? "/wakeup" : ""); | ||
268 | 273 | ||
269 | /* Ignore these return values. We rely on pci code to | 274 | /* Ignore these return values. We rely on pci code to |
270 | * reject requests the hardware can't implement, rather | 275 | * reject requests the hardware can't implement, rather |
271 | * than coding the same thing. | 276 | * than coding the same thing. |
272 | */ | 277 | */ |
273 | (void) pci_enable_wake (dev, PCI_D3hot, hcd->remote_wakeup); | 278 | (void) pci_enable_wake (dev, PCI_D3hot, wake); |
274 | (void) pci_enable_wake (dev, PCI_D3cold, hcd->remote_wakeup); | 279 | (void) pci_enable_wake (dev, PCI_D3cold, wake); |
275 | } else { | 280 | } else { |
276 | dev_dbg (&dev->dev, "PCI D3 suspend fail, %d\n", | 281 | dev_dbg (&dev->dev, "PCI D3 suspend fail, %d\n", |
277 | retval); | 282 | retval); |
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index 0018bbc4de34..fbd938d4ea58 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c | |||
@@ -34,6 +34,7 @@ | |||
34 | #include <asm/scatterlist.h> | 34 | #include <asm/scatterlist.h> |
35 | #include <linux/device.h> | 35 | #include <linux/device.h> |
36 | #include <linux/dma-mapping.h> | 36 | #include <linux/dma-mapping.h> |
37 | #include <linux/mutex.h> | ||
37 | #include <asm/irq.h> | 38 | #include <asm/irq.h> |
38 | #include <asm/byteorder.h> | 39 | #include <asm/byteorder.h> |
39 | 40 | ||
@@ -93,7 +94,7 @@ struct usb_busmap { | |||
93 | static struct usb_busmap busmap; | 94 | static struct usb_busmap busmap; |
94 | 95 | ||
95 | /* used when updating list of hcds */ | 96 | /* used when updating list of hcds */ |
96 | DECLARE_MUTEX (usb_bus_list_lock); /* exported only for usbfs */ | 97 | DEFINE_MUTEX(usb_bus_list_lock); /* exported only for usbfs */ |
97 | EXPORT_SYMBOL_GPL (usb_bus_list_lock); | 98 | EXPORT_SYMBOL_GPL (usb_bus_list_lock); |
98 | 99 | ||
99 | /* used for controlling access to virtual root hubs */ | 100 | /* used for controlling access to virtual root hubs */ |
@@ -366,21 +367,39 @@ static int rh_call_control (struct usb_hcd *hcd, struct urb *urb) | |||
366 | 367 | ||
367 | /* DEVICE REQUESTS */ | 368 | /* DEVICE REQUESTS */ |
368 | 369 | ||
370 | /* The root hub's remote wakeup enable bit is implemented using | ||
371 | * driver model wakeup flags. If this system supports wakeup | ||
372 | * through USB, userspace may change the default "allow wakeup" | ||
373 | * policy through sysfs or these calls. | ||
374 | * | ||
375 | * Most root hubs support wakeup from downstream devices, for | ||
376 | * runtime power management (disabling USB clocks and reducing | ||
377 | * VBUS power usage). However, not all of them do so; silicon, | ||
378 | * board, and BIOS bugs here are not uncommon, so these can't | ||
379 | * be treated quite like external hubs. | ||
380 | * | ||
381 | * Likewise, not all root hubs will pass wakeup events upstream, | ||
382 | * to wake up the whole system. So don't assume root hub and | ||
383 | * controller capabilities are identical. | ||
384 | */ | ||
385 | |||
369 | case DeviceRequest | USB_REQ_GET_STATUS: | 386 | case DeviceRequest | USB_REQ_GET_STATUS: |
370 | tbuf [0] = (hcd->remote_wakeup << USB_DEVICE_REMOTE_WAKEUP) | 387 | tbuf [0] = (device_may_wakeup(&hcd->self.root_hub->dev) |
388 | << USB_DEVICE_REMOTE_WAKEUP) | ||
371 | | (1 << USB_DEVICE_SELF_POWERED); | 389 | | (1 << USB_DEVICE_SELF_POWERED); |
372 | tbuf [1] = 0; | 390 | tbuf [1] = 0; |
373 | len = 2; | 391 | len = 2; |
374 | break; | 392 | break; |
375 | case DeviceOutRequest | USB_REQ_CLEAR_FEATURE: | 393 | case DeviceOutRequest | USB_REQ_CLEAR_FEATURE: |
376 | if (wValue == USB_DEVICE_REMOTE_WAKEUP) | 394 | if (wValue == USB_DEVICE_REMOTE_WAKEUP) |
377 | hcd->remote_wakeup = 0; | 395 | device_set_wakeup_enable(&hcd->self.root_hub->dev, 0); |
378 | else | 396 | else |
379 | goto error; | 397 | goto error; |
380 | break; | 398 | break; |
381 | case DeviceOutRequest | USB_REQ_SET_FEATURE: | 399 | case DeviceOutRequest | USB_REQ_SET_FEATURE: |
382 | if (hcd->can_wakeup && wValue == USB_DEVICE_REMOTE_WAKEUP) | 400 | if (device_can_wakeup(&hcd->self.root_hub->dev) |
383 | hcd->remote_wakeup = 1; | 401 | && wValue == USB_DEVICE_REMOTE_WAKEUP) |
402 | device_set_wakeup_enable(&hcd->self.root_hub->dev, 1); | ||
384 | else | 403 | else |
385 | goto error; | 404 | goto error; |
386 | break; | 405 | break; |
@@ -409,7 +428,7 @@ static int rh_call_control (struct usb_hcd *hcd, struct urb *urb) | |||
409 | bufp = fs_rh_config_descriptor; | 428 | bufp = fs_rh_config_descriptor; |
410 | len = sizeof fs_rh_config_descriptor; | 429 | len = sizeof fs_rh_config_descriptor; |
411 | } | 430 | } |
412 | if (hcd->can_wakeup) | 431 | if (device_can_wakeup(&hcd->self.root_hub->dev)) |
413 | patch_wakeup = 1; | 432 | patch_wakeup = 1; |
414 | break; | 433 | break; |
415 | case USB_DT_STRING << 8: | 434 | case USB_DT_STRING << 8: |
@@ -761,14 +780,14 @@ static int usb_register_bus(struct usb_bus *bus) | |||
761 | { | 780 | { |
762 | int busnum; | 781 | int busnum; |
763 | 782 | ||
764 | down (&usb_bus_list_lock); | 783 | mutex_lock(&usb_bus_list_lock); |
765 | busnum = find_next_zero_bit (busmap.busmap, USB_MAXBUS, 1); | 784 | busnum = find_next_zero_bit (busmap.busmap, USB_MAXBUS, 1); |
766 | if (busnum < USB_MAXBUS) { | 785 | if (busnum < USB_MAXBUS) { |
767 | set_bit (busnum, busmap.busmap); | 786 | set_bit (busnum, busmap.busmap); |
768 | bus->busnum = busnum; | 787 | bus->busnum = busnum; |
769 | } else { | 788 | } else { |
770 | printk (KERN_ERR "%s: too many buses\n", usbcore_name); | 789 | printk (KERN_ERR "%s: too many buses\n", usbcore_name); |
771 | up(&usb_bus_list_lock); | 790 | mutex_unlock(&usb_bus_list_lock); |
772 | return -E2BIG; | 791 | return -E2BIG; |
773 | } | 792 | } |
774 | 793 | ||
@@ -776,7 +795,7 @@ static int usb_register_bus(struct usb_bus *bus) | |||
776 | bus->controller, "usb_host%d", busnum); | 795 | bus->controller, "usb_host%d", busnum); |
777 | if (IS_ERR(bus->class_dev)) { | 796 | if (IS_ERR(bus->class_dev)) { |
778 | clear_bit(busnum, busmap.busmap); | 797 | clear_bit(busnum, busmap.busmap); |
779 | up(&usb_bus_list_lock); | 798 | mutex_unlock(&usb_bus_list_lock); |
780 | return PTR_ERR(bus->class_dev); | 799 | return PTR_ERR(bus->class_dev); |
781 | } | 800 | } |
782 | 801 | ||
@@ -784,7 +803,7 @@ static int usb_register_bus(struct usb_bus *bus) | |||
784 | 803 | ||
785 | /* Add it to the local list of buses */ | 804 | /* Add it to the local list of buses */ |
786 | list_add (&bus->bus_list, &usb_bus_list); | 805 | list_add (&bus->bus_list, &usb_bus_list); |
787 | up (&usb_bus_list_lock); | 806 | mutex_unlock(&usb_bus_list_lock); |
788 | 807 | ||
789 | usb_notify_add_bus(bus); | 808 | usb_notify_add_bus(bus); |
790 | 809 | ||
@@ -809,9 +828,9 @@ static void usb_deregister_bus (struct usb_bus *bus) | |||
809 | * controller code, as well as having it call this when cleaning | 828 | * controller code, as well as having it call this when cleaning |
810 | * itself up | 829 | * itself up |
811 | */ | 830 | */ |
812 | down (&usb_bus_list_lock); | 831 | mutex_lock(&usb_bus_list_lock); |
813 | list_del (&bus->bus_list); | 832 | list_del (&bus->bus_list); |
814 | up (&usb_bus_list_lock); | 833 | mutex_unlock(&usb_bus_list_lock); |
815 | 834 | ||
816 | usb_notify_remove_bus(bus); | 835 | usb_notify_remove_bus(bus); |
817 | 836 | ||
@@ -822,18 +841,17 @@ static void usb_deregister_bus (struct usb_bus *bus) | |||
822 | 841 | ||
823 | /** | 842 | /** |
824 | * register_root_hub - called by usb_add_hcd() to register a root hub | 843 | * register_root_hub - called by usb_add_hcd() to register a root hub |
825 | * @usb_dev: the usb root hub device to be registered. | ||
826 | * @hcd: host controller for this root hub | 844 | * @hcd: host controller for this root hub |
827 | * | 845 | * |
828 | * This function registers the root hub with the USB subsystem. It sets up | 846 | * This function registers the root hub with the USB subsystem. It sets up |
829 | * the device properly in the device tree and stores the root_hub pointer | 847 | * the device properly in the device tree and then calls usb_new_device() |
830 | * in the bus structure, then calls usb_new_device() to register the usb | 848 | * to register the usb device. It also assigns the root hub's USB address |
831 | * device. It also assigns the root hub's USB address (always 1). | 849 | * (always 1). |
832 | */ | 850 | */ |
833 | static int register_root_hub (struct usb_device *usb_dev, | 851 | static int register_root_hub(struct usb_hcd *hcd) |
834 | struct usb_hcd *hcd) | ||
835 | { | 852 | { |
836 | struct device *parent_dev = hcd->self.controller; | 853 | struct device *parent_dev = hcd->self.controller; |
854 | struct usb_device *usb_dev = hcd->self.root_hub; | ||
837 | const int devnum = 1; | 855 | const int devnum = 1; |
838 | int retval; | 856 | int retval; |
839 | 857 | ||
@@ -844,14 +862,12 @@ static int register_root_hub (struct usb_device *usb_dev, | |||
844 | set_bit (devnum, usb_dev->bus->devmap.devicemap); | 862 | set_bit (devnum, usb_dev->bus->devmap.devicemap); |
845 | usb_set_device_state(usb_dev, USB_STATE_ADDRESS); | 863 | usb_set_device_state(usb_dev, USB_STATE_ADDRESS); |
846 | 864 | ||
847 | down (&usb_bus_list_lock); | 865 | mutex_lock(&usb_bus_list_lock); |
848 | usb_dev->bus->root_hub = usb_dev; | ||
849 | 866 | ||
850 | usb_dev->ep0.desc.wMaxPacketSize = __constant_cpu_to_le16(64); | 867 | usb_dev->ep0.desc.wMaxPacketSize = __constant_cpu_to_le16(64); |
851 | retval = usb_get_device_descriptor(usb_dev, USB_DT_DEVICE_SIZE); | 868 | retval = usb_get_device_descriptor(usb_dev, USB_DT_DEVICE_SIZE); |
852 | if (retval != sizeof usb_dev->descriptor) { | 869 | if (retval != sizeof usb_dev->descriptor) { |
853 | usb_dev->bus->root_hub = NULL; | 870 | mutex_unlock(&usb_bus_list_lock); |
854 | up (&usb_bus_list_lock); | ||
855 | dev_dbg (parent_dev, "can't read %s device descriptor %d\n", | 871 | dev_dbg (parent_dev, "can't read %s device descriptor %d\n", |
856 | usb_dev->dev.bus_id, retval); | 872 | usb_dev->dev.bus_id, retval); |
857 | return (retval < 0) ? retval : -EMSGSIZE; | 873 | return (retval < 0) ? retval : -EMSGSIZE; |
@@ -859,11 +875,10 @@ static int register_root_hub (struct usb_device *usb_dev, | |||
859 | 875 | ||
860 | retval = usb_new_device (usb_dev); | 876 | retval = usb_new_device (usb_dev); |
861 | if (retval) { | 877 | if (retval) { |
862 | usb_dev->bus->root_hub = NULL; | ||
863 | dev_err (parent_dev, "can't register root hub for %s, %d\n", | 878 | dev_err (parent_dev, "can't register root hub for %s, %d\n", |
864 | usb_dev->dev.bus_id, retval); | 879 | usb_dev->dev.bus_id, retval); |
865 | } | 880 | } |
866 | up (&usb_bus_list_lock); | 881 | mutex_unlock(&usb_bus_list_lock); |
867 | 882 | ||
868 | if (retval == 0) { | 883 | if (retval == 0) { |
869 | spin_lock_irq (&hcd_root_hub_lock); | 884 | spin_lock_irq (&hcd_root_hub_lock); |
@@ -1090,7 +1105,6 @@ static void urb_unlink (struct urb *urb) | |||
1090 | spin_lock_irqsave (&hcd_data_lock, flags); | 1105 | spin_lock_irqsave (&hcd_data_lock, flags); |
1091 | list_del_init (&urb->urb_list); | 1106 | list_del_init (&urb->urb_list); |
1092 | spin_unlock_irqrestore (&hcd_data_lock, flags); | 1107 | spin_unlock_irqrestore (&hcd_data_lock, flags); |
1093 | usb_put_dev (urb->dev); | ||
1094 | } | 1108 | } |
1095 | 1109 | ||
1096 | 1110 | ||
@@ -1130,7 +1144,6 @@ static int hcd_submit_urb (struct urb *urb, gfp_t mem_flags) | |||
1130 | case HC_STATE_RUNNING: | 1144 | case HC_STATE_RUNNING: |
1131 | case HC_STATE_RESUMING: | 1145 | case HC_STATE_RESUMING: |
1132 | doit: | 1146 | doit: |
1133 | usb_get_dev (urb->dev); | ||
1134 | list_add_tail (&urb->urb_list, &ep->urb_list); | 1147 | list_add_tail (&urb->urb_list, &ep->urb_list); |
1135 | status = 0; | 1148 | status = 0; |
1136 | break; | 1149 | break; |
@@ -1771,12 +1784,10 @@ int usb_add_hcd(struct usb_hcd *hcd, | |||
1771 | 1784 | ||
1772 | set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); | 1785 | set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); |
1773 | 1786 | ||
1774 | /* till now HC has been in an indeterminate state ... */ | 1787 | /* HC is in reset state, but accessible. Now do the one-time init, |
1775 | if (hcd->driver->reset && (retval = hcd->driver->reset(hcd)) < 0) { | 1788 | * bottom up so that hcds can customize the root hubs before khubd |
1776 | dev_err(hcd->self.controller, "can't reset\n"); | 1789 | * starts talking to them. (Note, bus id is assigned early too.) |
1777 | return retval; | 1790 | */ |
1778 | } | ||
1779 | |||
1780 | if ((retval = hcd_buffer_create(hcd)) != 0) { | 1791 | if ((retval = hcd_buffer_create(hcd)) != 0) { |
1781 | dev_dbg(hcd->self.controller, "pool alloc failed\n"); | 1792 | dev_dbg(hcd->self.controller, "pool alloc failed\n"); |
1782 | return retval; | 1793 | return retval; |
@@ -1785,6 +1796,36 @@ int usb_add_hcd(struct usb_hcd *hcd, | |||
1785 | if ((retval = usb_register_bus(&hcd->self)) < 0) | 1796 | if ((retval = usb_register_bus(&hcd->self)) < 0) |
1786 | goto err_register_bus; | 1797 | goto err_register_bus; |
1787 | 1798 | ||
1799 | if ((rhdev = usb_alloc_dev(NULL, &hcd->self, 0)) == NULL) { | ||
1800 | dev_err(hcd->self.controller, "unable to allocate root hub\n"); | ||
1801 | retval = -ENOMEM; | ||
1802 | goto err_allocate_root_hub; | ||
1803 | } | ||
1804 | rhdev->speed = (hcd->driver->flags & HCD_USB2) ? USB_SPEED_HIGH : | ||
1805 | USB_SPEED_FULL; | ||
1806 | hcd->self.root_hub = rhdev; | ||
1807 | |||
1808 | /* "reset" is misnamed; its role is now one-time init. the controller | ||
1809 | * should already have been reset (and boot firmware kicked off etc). | ||
1810 | */ | ||
1811 | if (hcd->driver->reset && (retval = hcd->driver->reset(hcd)) < 0) { | ||
1812 | dev_err(hcd->self.controller, "can't setup\n"); | ||
1813 | goto err_hcd_driver_setup; | ||
1814 | } | ||
1815 | |||
1816 | /* wakeup flag init is in transition; for now we can't rely on PCI to | ||
1817 | * initialize these bits properly, so we let reset() override it. | ||
1818 | * This init should _precede_ the reset() once PCI behaves. | ||
1819 | */ | ||
1820 | device_init_wakeup(&rhdev->dev, | ||
1821 | device_can_wakeup(hcd->self.controller)); | ||
1822 | |||
1823 | /* NOTE: root hub and controller capabilities may not be the same */ | ||
1824 | if (device_can_wakeup(hcd->self.controller) | ||
1825 | && device_can_wakeup(&hcd->self.root_hub->dev)) | ||
1826 | dev_dbg(hcd->self.controller, "supports USB remote wakeup\n"); | ||
1827 | |||
1828 | /* enable irqs just before we start the controller */ | ||
1788 | if (hcd->driver->irq) { | 1829 | if (hcd->driver->irq) { |
1789 | char buf[8], *bufp = buf; | 1830 | char buf[8], *bufp = buf; |
1790 | 1831 | ||
@@ -1816,56 +1857,32 @@ int usb_add_hcd(struct usb_hcd *hcd, | |||
1816 | (unsigned long long)hcd->rsrc_start); | 1857 | (unsigned long long)hcd->rsrc_start); |
1817 | } | 1858 | } |
1818 | 1859 | ||
1819 | /* Allocate the root hub before calling hcd->driver->start(), | ||
1820 | * but don't register it until afterward so that the hardware | ||
1821 | * is running. | ||
1822 | */ | ||
1823 | if ((rhdev = usb_alloc_dev(NULL, &hcd->self, 0)) == NULL) { | ||
1824 | dev_err(hcd->self.controller, "unable to allocate root hub\n"); | ||
1825 | retval = -ENOMEM; | ||
1826 | goto err_allocate_root_hub; | ||
1827 | } | ||
1828 | |||
1829 | /* Although in principle hcd->driver->start() might need to use rhdev, | ||
1830 | * none of the current drivers do. | ||
1831 | */ | ||
1832 | if ((retval = hcd->driver->start(hcd)) < 0) { | 1860 | if ((retval = hcd->driver->start(hcd)) < 0) { |
1833 | dev_err(hcd->self.controller, "startup error %d\n", retval); | 1861 | dev_err(hcd->self.controller, "startup error %d\n", retval); |
1834 | goto err_hcd_driver_start; | 1862 | goto err_hcd_driver_start; |
1835 | } | 1863 | } |
1836 | 1864 | ||
1837 | /* hcd->driver->start() reported can_wakeup, probably with | 1865 | /* starting here, usbcore will pay attention to this root hub */ |
1838 | * assistance from board's boot firmware. | ||
1839 | * NOTE: normal devices won't enable wakeup by default. | ||
1840 | */ | ||
1841 | if (hcd->can_wakeup) | ||
1842 | dev_dbg(hcd->self.controller, "supports USB remote wakeup\n"); | ||
1843 | hcd->remote_wakeup = hcd->can_wakeup; | ||
1844 | |||
1845 | rhdev->speed = (hcd->driver->flags & HCD_USB2) ? USB_SPEED_HIGH : | ||
1846 | USB_SPEED_FULL; | ||
1847 | rhdev->bus_mA = min(500u, hcd->power_budget); | 1866 | rhdev->bus_mA = min(500u, hcd->power_budget); |
1848 | if ((retval = register_root_hub(rhdev, hcd)) != 0) | 1867 | if ((retval = register_root_hub(hcd)) != 0) |
1849 | goto err_register_root_hub; | 1868 | goto err_register_root_hub; |
1850 | 1869 | ||
1851 | if (hcd->uses_new_polling && hcd->poll_rh) | 1870 | if (hcd->uses_new_polling && hcd->poll_rh) |
1852 | usb_hcd_poll_rh_status(hcd); | 1871 | usb_hcd_poll_rh_status(hcd); |
1853 | return retval; | 1872 | return retval; |
1854 | 1873 | ||
1855 | err_register_root_hub: | 1874 | err_register_root_hub: |
1856 | hcd->driver->stop(hcd); | 1875 | hcd->driver->stop(hcd); |
1857 | 1876 | err_hcd_driver_start: | |
1858 | err_hcd_driver_start: | ||
1859 | usb_put_dev(rhdev); | ||
1860 | |||
1861 | err_allocate_root_hub: | ||
1862 | if (hcd->irq >= 0) | 1877 | if (hcd->irq >= 0) |
1863 | free_irq(irqnum, hcd); | 1878 | free_irq(irqnum, hcd); |
1864 | 1879 | err_request_irq: | |
1865 | err_request_irq: | 1880 | err_hcd_driver_setup: |
1881 | hcd->self.root_hub = NULL; | ||
1882 | usb_put_dev(rhdev); | ||
1883 | err_allocate_root_hub: | ||
1866 | usb_deregister_bus(&hcd->self); | 1884 | usb_deregister_bus(&hcd->self); |
1867 | 1885 | err_register_bus: | |
1868 | err_register_bus: | ||
1869 | hcd_buffer_destroy(hcd); | 1886 | hcd_buffer_destroy(hcd); |
1870 | return retval; | 1887 | return retval; |
1871 | } | 1888 | } |
@@ -1891,9 +1908,9 @@ void usb_remove_hcd(struct usb_hcd *hcd) | |||
1891 | hcd->rh_registered = 0; | 1908 | hcd->rh_registered = 0; |
1892 | spin_unlock_irq (&hcd_root_hub_lock); | 1909 | spin_unlock_irq (&hcd_root_hub_lock); |
1893 | 1910 | ||
1894 | down(&usb_bus_list_lock); | 1911 | mutex_lock(&usb_bus_list_lock); |
1895 | usb_disconnect(&hcd->self.root_hub); | 1912 | usb_disconnect(&hcd->self.root_hub); |
1896 | up(&usb_bus_list_lock); | 1913 | mutex_unlock(&usb_bus_list_lock); |
1897 | 1914 | ||
1898 | hcd->poll_rh = 0; | 1915 | hcd->poll_rh = 0; |
1899 | del_timer_sync(&hcd->rh_timer); | 1916 | del_timer_sync(&hcd->rh_timer); |
diff --git a/drivers/usb/core/hcd.h b/drivers/usb/core/hcd.h index 591b5aad1a18..7022aafb2ae8 100644 --- a/drivers/usb/core/hcd.h +++ b/drivers/usb/core/hcd.h | |||
@@ -78,8 +78,6 @@ struct usb_hcd { /* usb_bus.hcpriv points to this */ | |||
78 | #define HCD_FLAG_HW_ACCESSIBLE 0x00000001 | 78 | #define HCD_FLAG_HW_ACCESSIBLE 0x00000001 |
79 | #define HCD_FLAG_SAW_IRQ 0x00000002 | 79 | #define HCD_FLAG_SAW_IRQ 0x00000002 |
80 | 80 | ||
81 | unsigned can_wakeup:1; /* hw supports wakeup? */ | ||
82 | unsigned remote_wakeup:1;/* sw should use wakeup? */ | ||
83 | unsigned rh_registered:1;/* is root hub registered? */ | 81 | unsigned rh_registered:1;/* is root hub registered? */ |
84 | 82 | ||
85 | /* The next flag is a stopgap, to be removed when all the HCDs | 83 | /* The next flag is a stopgap, to be removed when all the HCDs |
@@ -364,7 +362,7 @@ extern void usb_set_device_state(struct usb_device *udev, | |||
364 | /* exported only within usbcore */ | 362 | /* exported only within usbcore */ |
365 | 363 | ||
366 | extern struct list_head usb_bus_list; | 364 | extern struct list_head usb_bus_list; |
367 | extern struct semaphore usb_bus_list_lock; | 365 | extern struct mutex usb_bus_list_lock; |
368 | extern wait_queue_head_t usb_kill_urb_queue; | 366 | extern wait_queue_head_t usb_kill_urb_queue; |
369 | 367 | ||
370 | extern struct usb_bus *usb_bus_get (struct usb_bus *bus); | 368 | extern struct usb_bus *usb_bus_get (struct usb_bus *bus); |
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 650d5ee5871b..8e65f7a237e4 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/usb.h> | 22 | #include <linux/usb.h> |
23 | #include <linux/usbdevice_fs.h> | 23 | #include <linux/usbdevice_fs.h> |
24 | #include <linux/kthread.h> | 24 | #include <linux/kthread.h> |
25 | #include <linux/mutex.h> | ||
25 | 26 | ||
26 | #include <asm/semaphore.h> | 27 | #include <asm/semaphore.h> |
27 | #include <asm/uaccess.h> | 28 | #include <asm/uaccess.h> |
@@ -1005,12 +1006,18 @@ void usb_set_device_state(struct usb_device *udev, | |||
1005 | ; /* do nothing */ | 1006 | ; /* do nothing */ |
1006 | else if (new_state != USB_STATE_NOTATTACHED) { | 1007 | else if (new_state != USB_STATE_NOTATTACHED) { |
1007 | udev->state = new_state; | 1008 | udev->state = new_state; |
1008 | if (new_state == USB_STATE_CONFIGURED) | 1009 | |
1009 | device_init_wakeup(&udev->dev, | 1010 | /* root hub wakeup capabilities are managed out-of-band |
1010 | (udev->actconfig->desc.bmAttributes | 1011 | * and may involve silicon errata ... ignore them here. |
1011 | & USB_CONFIG_ATT_WAKEUP)); | 1012 | */ |
1012 | else if (new_state != USB_STATE_SUSPENDED) | 1013 | if (udev->parent) { |
1013 | device_init_wakeup(&udev->dev, 0); | 1014 | if (new_state == USB_STATE_CONFIGURED) |
1015 | device_init_wakeup(&udev->dev, | ||
1016 | (udev->actconfig->desc.bmAttributes | ||
1017 | & USB_CONFIG_ATT_WAKEUP)); | ||
1018 | else if (new_state != USB_STATE_SUSPENDED) | ||
1019 | device_init_wakeup(&udev->dev, 0); | ||
1020 | } | ||
1014 | } else | 1021 | } else |
1015 | recursively_mark_NOTATTACHED(udev); | 1022 | recursively_mark_NOTATTACHED(udev); |
1016 | spin_unlock_irqrestore(&device_state_lock, flags); | 1023 | spin_unlock_irqrestore(&device_state_lock, flags); |
@@ -1172,8 +1179,11 @@ static int choose_configuration(struct usb_device *udev) | |||
1172 | c = udev->config; | 1179 | c = udev->config; |
1173 | num_configs = udev->descriptor.bNumConfigurations; | 1180 | num_configs = udev->descriptor.bNumConfigurations; |
1174 | for (i = 0; i < num_configs; (i++, c++)) { | 1181 | for (i = 0; i < num_configs; (i++, c++)) { |
1175 | struct usb_interface_descriptor *desc = | 1182 | struct usb_interface_descriptor *desc = NULL; |
1176 | &c->intf_cache[0]->altsetting->desc; | 1183 | |
1184 | /* It's possible that a config has no interfaces! */ | ||
1185 | if (c->desc.bNumInterfaces > 0) | ||
1186 | desc = &c->intf_cache[0]->altsetting->desc; | ||
1177 | 1187 | ||
1178 | /* | 1188 | /* |
1179 | * HP's USB bus-powered keyboard has only one configuration | 1189 | * HP's USB bus-powered keyboard has only one configuration |
@@ -1208,7 +1218,8 @@ static int choose_configuration(struct usb_device *udev) | |||
1208 | /* If the first config's first interface is COMM/2/0xff | 1218 | /* If the first config's first interface is COMM/2/0xff |
1209 | * (MSFT RNDIS), rule it out unless Linux has host-side | 1219 | * (MSFT RNDIS), rule it out unless Linux has host-side |
1210 | * RNDIS support. */ | 1220 | * RNDIS support. */ |
1211 | if (i == 0 && desc->bInterfaceClass == USB_CLASS_COMM | 1221 | if (i == 0 && desc |
1222 | && desc->bInterfaceClass == USB_CLASS_COMM | ||
1212 | && desc->bInterfaceSubClass == 2 | 1223 | && desc->bInterfaceSubClass == 2 |
1213 | && desc->bInterfaceProtocol == 0xff) { | 1224 | && desc->bInterfaceProtocol == 0xff) { |
1214 | #ifndef CONFIG_USB_NET_RNDIS | 1225 | #ifndef CONFIG_USB_NET_RNDIS |
@@ -1224,8 +1235,8 @@ static int choose_configuration(struct usb_device *udev) | |||
1224 | * than a vendor-specific driver. */ | 1235 | * than a vendor-specific driver. */ |
1225 | else if (udev->descriptor.bDeviceClass != | 1236 | else if (udev->descriptor.bDeviceClass != |
1226 | USB_CLASS_VENDOR_SPEC && | 1237 | USB_CLASS_VENDOR_SPEC && |
1227 | desc->bInterfaceClass != | 1238 | (!desc || desc->bInterfaceClass != |
1228 | USB_CLASS_VENDOR_SPEC) { | 1239 | USB_CLASS_VENDOR_SPEC)) { |
1229 | best = c; | 1240 | best = c; |
1230 | break; | 1241 | break; |
1231 | } | 1242 | } |
@@ -1876,18 +1887,18 @@ int usb_resume_device(struct usb_device *udev) | |||
1876 | if (udev->state == USB_STATE_NOTATTACHED) | 1887 | if (udev->state == USB_STATE_NOTATTACHED) |
1877 | return -ENODEV; | 1888 | return -ENODEV; |
1878 | 1889 | ||
1879 | #ifdef CONFIG_USB_SUSPEND | ||
1880 | /* selective resume of one downstream hub-to-device port */ | 1890 | /* selective resume of one downstream hub-to-device port */ |
1881 | if (udev->parent) { | 1891 | if (udev->parent) { |
1892 | #ifdef CONFIG_USB_SUSPEND | ||
1882 | if (udev->state == USB_STATE_SUSPENDED) { | 1893 | if (udev->state == USB_STATE_SUSPENDED) { |
1883 | // NOTE swsusp may bork us, device state being wrong... | 1894 | // NOTE swsusp may bork us, device state being wrong... |
1884 | // NOTE this fails if parent is also suspended... | 1895 | // NOTE this fails if parent is also suspended... |
1885 | status = hub_port_resume(hdev_to_hub(udev->parent), | 1896 | status = hub_port_resume(hdev_to_hub(udev->parent), |
1886 | udev->portnum, udev); | 1897 | udev->portnum, udev); |
1887 | } else | 1898 | } else |
1899 | #endif | ||
1888 | status = 0; | 1900 | status = 0; |
1889 | } else | 1901 | } else |
1890 | #endif | ||
1891 | status = finish_device_resume(udev); | 1902 | status = finish_device_resume(udev); |
1892 | if (status < 0) | 1903 | if (status < 0) |
1893 | dev_dbg(&udev->dev, "can't resume, status %d\n", | 1904 | dev_dbg(&udev->dev, "can't resume, status %d\n", |
@@ -2162,7 +2173,7 @@ static int | |||
2162 | hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1, | 2173 | hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1, |
2163 | int retry_counter) | 2174 | int retry_counter) |
2164 | { | 2175 | { |
2165 | static DECLARE_MUTEX(usb_address0_sem); | 2176 | static DEFINE_MUTEX(usb_address0_mutex); |
2166 | 2177 | ||
2167 | struct usb_device *hdev = hub->hdev; | 2178 | struct usb_device *hdev = hub->hdev; |
2168 | int i, j, retval; | 2179 | int i, j, retval; |
@@ -2183,7 +2194,7 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1, | |||
2183 | if (oldspeed == USB_SPEED_LOW) | 2194 | if (oldspeed == USB_SPEED_LOW) |
2184 | delay = HUB_LONG_RESET_TIME; | 2195 | delay = HUB_LONG_RESET_TIME; |
2185 | 2196 | ||
2186 | down(&usb_address0_sem); | 2197 | mutex_lock(&usb_address0_mutex); |
2187 | 2198 | ||
2188 | /* Reset the device; full speed may morph to high speed */ | 2199 | /* Reset the device; full speed may morph to high speed */ |
2189 | retval = hub_port_reset(hub, port1, udev, delay); | 2200 | retval = hub_port_reset(hub, port1, udev, delay); |
@@ -2381,7 +2392,7 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1, | |||
2381 | fail: | 2392 | fail: |
2382 | if (retval) | 2393 | if (retval) |
2383 | hub_port_disable(hub, port1, 0); | 2394 | hub_port_disable(hub, port1, 0); |
2384 | up(&usb_address0_sem); | 2395 | mutex_unlock(&usb_address0_mutex); |
2385 | return retval; | 2396 | return retval; |
2386 | } | 2397 | } |
2387 | 2398 | ||
@@ -3017,7 +3028,7 @@ int usb_reset_device(struct usb_device *udev) | |||
3017 | parent_hub = hdev_to_hub(parent_hdev); | 3028 | parent_hub = hdev_to_hub(parent_hdev); |
3018 | 3029 | ||
3019 | /* If we're resetting an active hub, take some special actions */ | 3030 | /* If we're resetting an active hub, take some special actions */ |
3020 | if (udev->actconfig && | 3031 | if (udev->actconfig && udev->actconfig->desc.bNumInterfaces > 0 && |
3021 | udev->actconfig->interface[0]->dev.driver == | 3032 | udev->actconfig->interface[0]->dev.driver == |
3022 | &hub_driver.driver && | 3033 | &hub_driver.driver && |
3023 | (hub = hdev_to_hub(udev)) != NULL) { | 3034 | (hub = hdev_to_hub(udev)) != NULL) { |
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index 7135e542679d..08fb20f06f3e 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c | |||
@@ -631,8 +631,8 @@ int usb_get_descriptor(struct usb_device *dev, unsigned char type, unsigned char | |||
631 | * Returns the number of bytes received on success, or else the status code | 631 | * Returns the number of bytes received on success, or else the status code |
632 | * returned by the underlying usb_control_msg() call. | 632 | * returned by the underlying usb_control_msg() call. |
633 | */ | 633 | */ |
634 | int usb_get_string(struct usb_device *dev, unsigned short langid, | 634 | static int usb_get_string(struct usb_device *dev, unsigned short langid, |
635 | unsigned char index, void *buf, int size) | 635 | unsigned char index, void *buf, int size) |
636 | { | 636 | { |
637 | int i; | 637 | int i; |
638 | int result; | 638 | int result; |
@@ -1388,11 +1388,13 @@ free_interfaces: | |||
1388 | if (dev->state != USB_STATE_ADDRESS) | 1388 | if (dev->state != USB_STATE_ADDRESS) |
1389 | usb_disable_device (dev, 1); // Skip ep0 | 1389 | usb_disable_device (dev, 1); // Skip ep0 |
1390 | 1390 | ||
1391 | i = dev->bus_mA - cp->desc.bMaxPower * 2; | 1391 | if (cp) { |
1392 | if (i < 0) | 1392 | i = dev->bus_mA - cp->desc.bMaxPower * 2; |
1393 | dev_warn(&dev->dev, "new config #%d exceeds power " | 1393 | if (i < 0) |
1394 | "limit by %dmA\n", | 1394 | dev_warn(&dev->dev, "new config #%d exceeds power " |
1395 | configuration, -i); | 1395 | "limit by %dmA\n", |
1396 | configuration, -i); | ||
1397 | } | ||
1396 | 1398 | ||
1397 | if ((ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), | 1399 | if ((ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), |
1398 | USB_REQ_SET_CONFIGURATION, 0, configuration, 0, | 1400 | USB_REQ_SET_CONFIGURATION, 0, configuration, 0, |
@@ -1488,7 +1490,6 @@ EXPORT_SYMBOL(usb_sg_wait); | |||
1488 | // synchronous control message convenience routines | 1490 | // synchronous control message convenience routines |
1489 | EXPORT_SYMBOL(usb_get_descriptor); | 1491 | EXPORT_SYMBOL(usb_get_descriptor); |
1490 | EXPORT_SYMBOL(usb_get_status); | 1492 | EXPORT_SYMBOL(usb_get_status); |
1491 | EXPORT_SYMBOL(usb_get_string); | ||
1492 | EXPORT_SYMBOL(usb_string); | 1493 | EXPORT_SYMBOL(usb_string); |
1493 | 1494 | ||
1494 | // synchronous calls that also maintain usbcore state | 1495 | // synchronous calls that also maintain usbcore state |
diff --git a/drivers/usb/core/notify.c b/drivers/usb/core/notify.c index fbbebab52fbd..4b55285de9a0 100644 --- a/drivers/usb/core/notify.c +++ b/drivers/usb/core/notify.c | |||
@@ -13,16 +13,17 @@ | |||
13 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
14 | #include <linux/notifier.h> | 14 | #include <linux/notifier.h> |
15 | #include <linux/usb.h> | 15 | #include <linux/usb.h> |
16 | #include <linux/mutex.h> | ||
16 | #include "usb.h" | 17 | #include "usb.h" |
17 | 18 | ||
18 | 19 | ||
19 | static struct notifier_block *usb_notifier_list; | 20 | static struct notifier_block *usb_notifier_list; |
20 | static DECLARE_MUTEX(usb_notifier_lock); | 21 | static DEFINE_MUTEX(usb_notifier_lock); |
21 | 22 | ||
22 | static void usb_notifier_chain_register(struct notifier_block **list, | 23 | static void usb_notifier_chain_register(struct notifier_block **list, |
23 | struct notifier_block *n) | 24 | struct notifier_block *n) |
24 | { | 25 | { |
25 | down(&usb_notifier_lock); | 26 | mutex_lock(&usb_notifier_lock); |
26 | while (*list) { | 27 | while (*list) { |
27 | if (n->priority > (*list)->priority) | 28 | if (n->priority > (*list)->priority) |
28 | break; | 29 | break; |
@@ -30,13 +31,13 @@ static void usb_notifier_chain_register(struct notifier_block **list, | |||
30 | } | 31 | } |
31 | n->next = *list; | 32 | n->next = *list; |
32 | *list = n; | 33 | *list = n; |
33 | up(&usb_notifier_lock); | 34 | mutex_unlock(&usb_notifier_lock); |
34 | } | 35 | } |
35 | 36 | ||
36 | static void usb_notifier_chain_unregister(struct notifier_block **nl, | 37 | static void usb_notifier_chain_unregister(struct notifier_block **nl, |
37 | struct notifier_block *n) | 38 | struct notifier_block *n) |
38 | { | 39 | { |
39 | down(&usb_notifier_lock); | 40 | mutex_lock(&usb_notifier_lock); |
40 | while ((*nl)!=NULL) { | 41 | while ((*nl)!=NULL) { |
41 | if ((*nl)==n) { | 42 | if ((*nl)==n) { |
42 | *nl = n->next; | 43 | *nl = n->next; |
@@ -45,7 +46,7 @@ static void usb_notifier_chain_unregister(struct notifier_block **nl, | |||
45 | nl=&((*nl)->next); | 46 | nl=&((*nl)->next); |
46 | } | 47 | } |
47 | exit: | 48 | exit: |
48 | up(&usb_notifier_lock); | 49 | mutex_unlock(&usb_notifier_lock); |
49 | } | 50 | } |
50 | 51 | ||
51 | static int usb_notifier_call_chain(struct notifier_block **n, | 52 | static int usb_notifier_call_chain(struct notifier_block **n, |
@@ -54,7 +55,7 @@ static int usb_notifier_call_chain(struct notifier_block **n, | |||
54 | int ret=NOTIFY_DONE; | 55 | int ret=NOTIFY_DONE; |
55 | struct notifier_block *nb = *n; | 56 | struct notifier_block *nb = *n; |
56 | 57 | ||
57 | down(&usb_notifier_lock); | 58 | mutex_lock(&usb_notifier_lock); |
58 | while (nb) { | 59 | while (nb) { |
59 | ret = nb->notifier_call(nb,val,v); | 60 | ret = nb->notifier_call(nb,val,v); |
60 | if (ret&NOTIFY_STOP_MASK) { | 61 | if (ret&NOTIFY_STOP_MASK) { |
@@ -63,7 +64,7 @@ static int usb_notifier_call_chain(struct notifier_block **n, | |||
63 | nb = nb->next; | 64 | nb = nb->next; |
64 | } | 65 | } |
65 | exit: | 66 | exit: |
66 | up(&usb_notifier_lock); | 67 | mutex_unlock(&usb_notifier_lock); |
67 | return ret; | 68 | return ret; |
68 | } | 69 | } |
69 | 70 | ||
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index 13d1d367f7f1..d7352aa73b5e 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/errno.h> | 33 | #include <linux/errno.h> |
34 | #include <linux/smp_lock.h> | 34 | #include <linux/smp_lock.h> |
35 | #include <linux/usb.h> | 35 | #include <linux/usb.h> |
36 | #include <linux/mutex.h> | ||
36 | 37 | ||
37 | #include <asm/io.h> | 38 | #include <asm/io.h> |
38 | #include <asm/scatterlist.h> | 39 | #include <asm/scatterlist.h> |
@@ -639,7 +640,7 @@ struct usb_device *usb_find_device(u16 vendor_id, u16 product_id) | |||
639 | struct usb_bus *bus; | 640 | struct usb_bus *bus; |
640 | struct usb_device *dev = NULL; | 641 | struct usb_device *dev = NULL; |
641 | 642 | ||
642 | down(&usb_bus_list_lock); | 643 | mutex_lock(&usb_bus_list_lock); |
643 | for (buslist = usb_bus_list.next; | 644 | for (buslist = usb_bus_list.next; |
644 | buslist != &usb_bus_list; | 645 | buslist != &usb_bus_list; |
645 | buslist = buslist->next) { | 646 | buslist = buslist->next) { |
@@ -653,7 +654,7 @@ struct usb_device *usb_find_device(u16 vendor_id, u16 product_id) | |||
653 | goto exit; | 654 | goto exit; |
654 | } | 655 | } |
655 | exit: | 656 | exit: |
656 | up(&usb_bus_list_lock); | 657 | mutex_unlock(&usb_bus_list_lock); |
657 | return dev; | 658 | return dev; |
658 | } | 659 | } |
659 | 660 | ||