diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-08-10 18:05:02 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-08-10 18:05:02 -0400 |
commit | 9895850b23886e030cd1e7241d5529a57e969c3d (patch) | |
tree | 1061626db450aeb72dcfcd247c24b33e5238c8c4 /drivers/usb | |
parent | fc385c313275b114bc6ad36e60c5177d63250548 (diff) | |
parent | b58af4066d240b18b43f202e07b9ec7461d90b17 (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: (148 commits)
USB: serial: fix stalled writes
USB: remove fake "address-of" expressions
USB: fix thread-unsafe anchor utiliy routines
USB: usbtest: support test device with only one iso-in or iso-out endpoint
USB: usbtest: avoid to free coherent buffer in atomic context
USB: xhci: Set DMA mask for host.
USB: xhci: Don't flush doorbell writes.
USB: xhci: Reduce reads and writes of interrupter registers.
USB: xhci: Make xhci_set_hc_event_deq() static.
USB: xhci: Minimize HW event ring dequeue pointer writes.
USB: xhci: Make xhci_handle_event() static.
USB: xhci: Remove unnecessary reads of IRQ_PENDING register.
USB: xhci: Performance - move xhci_work() into xhci_irq()
USB: xhci: Performance - move interrupt handlers into xhci-ring.c
USB: xhci: Performance - move functions that find ep ring.
USB:: fix linux/usb.h kernel-doc warnings
USB: add USB serial ssu100 driver
USB: usb-storage: implement autosuspend
USB: ehci: fix remove of ehci debugfs dir
USB: Add USB 2.0 to ssb ohci driver
...
Diffstat (limited to 'drivers/usb')
116 files changed, 4568 insertions, 1833 deletions
diff --git a/drivers/usb/Makefile b/drivers/usb/Makefile index 80b4008c89ba..239f050efa35 100644 --- a/drivers/usb/Makefile +++ b/drivers/usb/Makefile | |||
@@ -41,7 +41,7 @@ obj-$(CONFIG_USB_MICROTEK) += image/ | |||
41 | obj-$(CONFIG_USB_SERIAL) += serial/ | 41 | obj-$(CONFIG_USB_SERIAL) += serial/ |
42 | 42 | ||
43 | obj-$(CONFIG_USB) += misc/ | 43 | obj-$(CONFIG_USB) += misc/ |
44 | obj-y += early/ | 44 | obj-$(CONFIG_EARLY_PRINTK_DBGP) += early/ |
45 | 45 | ||
46 | obj-$(CONFIG_USB_ATM) += atm/ | 46 | obj-$(CONFIG_USB_ATM) += atm/ |
47 | obj-$(CONFIG_USB_SPEEDTOUCH) += atm/ | 47 | obj-$(CONFIG_USB_SPEEDTOUCH) += atm/ |
diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c index 101ffc965ee0..593fc5e2d2e6 100644 --- a/drivers/usb/atm/cxacru.c +++ b/drivers/usb/atm/cxacru.c | |||
@@ -564,7 +564,7 @@ static void cxacru_timeout_kill(unsigned long data) | |||
564 | } | 564 | } |
565 | 565 | ||
566 | static int cxacru_start_wait_urb(struct urb *urb, struct completion *done, | 566 | static int cxacru_start_wait_urb(struct urb *urb, struct completion *done, |
567 | int* actual_length) | 567 | int *actual_length) |
568 | { | 568 | { |
569 | struct timer_list timer; | 569 | struct timer_list timer; |
570 | 570 | ||
@@ -952,7 +952,7 @@ static int cxacru_fw(struct usb_device *usb_dev, enum cxacru_fw_request fw, | |||
952 | put_unaligned(cpu_to_le32(addr), (__le32 *)(buf + offb)); | 952 | put_unaligned(cpu_to_le32(addr), (__le32 *)(buf + offb)); |
953 | offb += 4; | 953 | offb += 4; |
954 | addr += l; | 954 | addr += l; |
955 | if(l) | 955 | if (l) |
956 | memcpy(buf + offb, data + offd, l); | 956 | memcpy(buf + offb, data + offd, l); |
957 | if (l < stride) | 957 | if (l < stride) |
958 | memset(buf + offb + l, 0, stride - l); | 958 | memset(buf + offb + l, 0, stride - l); |
@@ -967,7 +967,7 @@ static int cxacru_fw(struct usb_device *usb_dev, enum cxacru_fw_request fw, | |||
967 | } | 967 | } |
968 | offb = 0; | 968 | offb = 0; |
969 | } | 969 | } |
970 | } while(offd < size); | 970 | } while (offd < size); |
971 | dbg("sent fw %#x", fw); | 971 | dbg("sent fw %#x", fw); |
972 | 972 | ||
973 | ret = 0; | 973 | ret = 0; |
@@ -1043,8 +1043,7 @@ static void cxacru_upload_firmware(struct cxacru_data *instance, | |||
1043 | if (instance->modem_type->boot_rom_patch) { | 1043 | if (instance->modem_type->boot_rom_patch) { |
1044 | val = cpu_to_le32(BR_ADDR); | 1044 | val = cpu_to_le32(BR_ADDR); |
1045 | ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, BR_STACK_ADDR, (u8 *) &val, 4); | 1045 | ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, BR_STACK_ADDR, (u8 *) &val, 4); |
1046 | } | 1046 | } else { |
1047 | else { | ||
1048 | ret = cxacru_fw(usb_dev, FW_GOTO_MEM, 0x0, 0x0, FW_ADDR, NULL, 0); | 1047 | ret = cxacru_fw(usb_dev, FW_GOTO_MEM, 0x0, 0x0, FW_ADDR, NULL, 0); |
1049 | } | 1048 | } |
1050 | if (ret) { | 1049 | if (ret) { |
@@ -1068,7 +1067,7 @@ static void cxacru_upload_firmware(struct cxacru_data *instance, | |||
1068 | } | 1067 | } |
1069 | 1068 | ||
1070 | static int cxacru_find_firmware(struct cxacru_data *instance, | 1069 | static int cxacru_find_firmware(struct cxacru_data *instance, |
1071 | char* phase, const struct firmware **fw_p) | 1070 | char *phase, const struct firmware **fw_p) |
1072 | { | 1071 | { |
1073 | struct usbatm_data *usbatm = instance->usbatm; | 1072 | struct usbatm_data *usbatm = instance->usbatm; |
1074 | struct device *dev = &usbatm->usb_intf->dev; | 1073 | struct device *dev = &usbatm->usb_intf->dev; |
diff --git a/drivers/usb/atm/speedtch.c b/drivers/usb/atm/speedtch.c index 80f9617d3a15..4716e707de59 100644 --- a/drivers/usb/atm/speedtch.c +++ b/drivers/usb/atm/speedtch.c | |||
@@ -753,11 +753,13 @@ static struct usb_driver speedtch_usb_driver = { | |||
753 | .id_table = speedtch_usb_ids | 753 | .id_table = speedtch_usb_ids |
754 | }; | 754 | }; |
755 | 755 | ||
756 | static void speedtch_release_interfaces(struct usb_device *usb_dev, int num_interfaces) { | 756 | static void speedtch_release_interfaces(struct usb_device *usb_dev, |
757 | int num_interfaces) | ||
758 | { | ||
757 | struct usb_interface *cur_intf; | 759 | struct usb_interface *cur_intf; |
758 | int i; | 760 | int i; |
759 | 761 | ||
760 | for(i = 0; i < num_interfaces; i++) | 762 | for (i = 0; i < num_interfaces; i++) |
761 | if ((cur_intf = usb_ifnum_to_if(usb_dev, i))) { | 763 | if ((cur_intf = usb_ifnum_to_if(usb_dev, i))) { |
762 | usb_set_intfdata(cur_intf, NULL); | 764 | usb_set_intfdata(cur_intf, NULL); |
763 | usb_driver_release_interface(&speedtch_usb_driver, cur_intf); | 765 | usb_driver_release_interface(&speedtch_usb_driver, cur_intf); |
@@ -792,7 +794,7 @@ static int speedtch_bind(struct usbatm_data *usbatm, | |||
792 | 794 | ||
793 | /* claim all interfaces */ | 795 | /* claim all interfaces */ |
794 | 796 | ||
795 | for (i=0; i < num_interfaces; i++) { | 797 | for (i = 0; i < num_interfaces; i++) { |
796 | cur_intf = usb_ifnum_to_if(usb_dev, i); | 798 | cur_intf = usb_ifnum_to_if(usb_dev, i); |
797 | 799 | ||
798 | if ((i != ifnum) && cur_intf) { | 800 | if ((i != ifnum) && cur_intf) { |
@@ -842,7 +844,7 @@ static int speedtch_bind(struct usbatm_data *usbatm, | |||
842 | 844 | ||
843 | use_isoc = 0; /* fall back to bulk if endpoint not found */ | 845 | use_isoc = 0; /* fall back to bulk if endpoint not found */ |
844 | 846 | ||
845 | for (i=0; i<desc->desc.bNumEndpoints; i++) { | 847 | for (i = 0; i < desc->desc.bNumEndpoints; i++) { |
846 | const struct usb_endpoint_descriptor *endpoint_desc = &desc->endpoint[i].desc; | 848 | const struct usb_endpoint_descriptor *endpoint_desc = &desc->endpoint[i].desc; |
847 | 849 | ||
848 | if ((endpoint_desc->bEndpointAddress == target_address)) { | 850 | if ((endpoint_desc->bEndpointAddress == target_address)) { |
diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c index ebae94480140..5b3f555e01c9 100644 --- a/drivers/usb/atm/ueagle-atm.c +++ b/drivers/usb/atm/ueagle-atm.c | |||
@@ -67,6 +67,7 @@ | |||
67 | #include <linux/mutex.h> | 67 | #include <linux/mutex.h> |
68 | #include <linux/freezer.h> | 68 | #include <linux/freezer.h> |
69 | #include <linux/slab.h> | 69 | #include <linux/slab.h> |
70 | #include <linux/kernel.h> | ||
70 | 71 | ||
71 | #include <asm/unaligned.h> | 72 | #include <asm/unaligned.h> |
72 | 73 | ||
@@ -2436,7 +2437,6 @@ UEA_ATTR(firmid, 0); | |||
2436 | 2437 | ||
2437 | /* Retrieve the device End System Identifier (MAC) */ | 2438 | /* Retrieve the device End System Identifier (MAC) */ |
2438 | 2439 | ||
2439 | #define htoi(x) (isdigit(x) ? x-'0' : toupper(x)-'A'+10) | ||
2440 | static int uea_getesi(struct uea_softc *sc, u_char * esi) | 2440 | static int uea_getesi(struct uea_softc *sc, u_char * esi) |
2441 | { | 2441 | { |
2442 | unsigned char mac_str[2 * ETH_ALEN + 1]; | 2442 | unsigned char mac_str[2 * ETH_ALEN + 1]; |
@@ -2447,7 +2447,8 @@ static int uea_getesi(struct uea_softc *sc, u_char * esi) | |||
2447 | return 1; | 2447 | return 1; |
2448 | 2448 | ||
2449 | for (i = 0; i < ETH_ALEN; i++) | 2449 | for (i = 0; i < ETH_ALEN; i++) |
2450 | esi[i] = htoi(mac_str[2 * i]) * 16 + htoi(mac_str[2 * i + 1]); | 2450 | esi[i] = hex_to_bin(mac_str[2 * i]) * 16 + |
2451 | hex_to_bin(mac_str[2 * i + 1]); | ||
2451 | 2452 | ||
2452 | return 0; | 2453 | return 0; |
2453 | } | 2454 | } |
diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c index 9b53e8df4648..05bf5a27b5b0 100644 --- a/drivers/usb/atm/usbatm.c +++ b/drivers/usb/atm/usbatm.c | |||
@@ -84,8 +84,8 @@ | |||
84 | 84 | ||
85 | #ifdef VERBOSE_DEBUG | 85 | #ifdef VERBOSE_DEBUG |
86 | static int usbatm_print_packet(const unsigned char *data, int len); | 86 | static int usbatm_print_packet(const unsigned char *data, int len); |
87 | #define PACKETDEBUG(arg...) usbatm_print_packet (arg) | 87 | #define PACKETDEBUG(arg...) usbatm_print_packet(arg) |
88 | #define vdbg(arg...) dbg (arg) | 88 | #define vdbg(arg...) dbg(arg) |
89 | #else | 89 | #else |
90 | #define PACKETDEBUG(arg...) | 90 | #define PACKETDEBUG(arg...) |
91 | #define vdbg(arg...) | 91 | #define vdbg(arg...) |
@@ -273,8 +273,7 @@ static void usbatm_complete(struct urb *urb) | |||
273 | 273 | ||
274 | if (unlikely(status) && | 274 | if (unlikely(status) && |
275 | (!(channel->usbatm->flags & UDSL_IGNORE_EILSEQ) || | 275 | (!(channel->usbatm->flags & UDSL_IGNORE_EILSEQ) || |
276 | status != -EILSEQ )) | 276 | status != -EILSEQ)) { |
277 | { | ||
278 | if (status == -ESHUTDOWN) | 277 | if (status == -ESHUTDOWN) |
279 | return; | 278 | return; |
280 | 279 | ||
@@ -494,7 +493,7 @@ static unsigned int usbatm_write_cells(struct usbatm_data *instance, | |||
494 | ptr += data_len; | 493 | ptr += data_len; |
495 | __skb_pull(skb, data_len); | 494 | __skb_pull(skb, data_len); |
496 | 495 | ||
497 | if(!left) | 496 | if (!left) |
498 | continue; | 497 | continue; |
499 | 498 | ||
500 | memset(ptr, 0, left); | 499 | memset(ptr, 0, left); |
@@ -506,7 +505,7 @@ static unsigned int usbatm_write_cells(struct usbatm_data *instance, | |||
506 | trailer[2] = ctrl->len >> 8; | 505 | trailer[2] = ctrl->len >> 8; |
507 | trailer[3] = ctrl->len; | 506 | trailer[3] = ctrl->len; |
508 | 507 | ||
509 | ctrl->crc = ~ crc32_be(ctrl->crc, ptr, left - 4); | 508 | ctrl->crc = ~crc32_be(ctrl->crc, ptr, left - 4); |
510 | 509 | ||
511 | trailer[4] = ctrl->crc >> 24; | 510 | trailer[4] = ctrl->crc >> 24; |
512 | trailer[5] = ctrl->crc >> 16; | 511 | trailer[5] = ctrl->crc >> 16; |
@@ -516,8 +515,7 @@ static unsigned int usbatm_write_cells(struct usbatm_data *instance, | |||
516 | target[3] |= 0x2; /* adjust PTI */ | 515 | target[3] |= 0x2; /* adjust PTI */ |
517 | 516 | ||
518 | ctrl->len = 0; /* tag this skb finished */ | 517 | ctrl->len = 0; /* tag this skb finished */ |
519 | } | 518 | } else |
520 | else | ||
521 | ctrl->crc = crc32_be(ctrl->crc, ptr, left); | 519 | ctrl->crc = crc32_be(ctrl->crc, ptr, left); |
522 | } | 520 | } |
523 | 521 | ||
@@ -1146,7 +1144,7 @@ int usbatm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id, | |||
1146 | instance->tx_channel.endpoint = usb_sndbulkpipe(usb_dev, driver->bulk_out); | 1144 | instance->tx_channel.endpoint = usb_sndbulkpipe(usb_dev, driver->bulk_out); |
1147 | 1145 | ||
1148 | /* tx buffer size must be a positive multiple of the stride */ | 1146 | /* tx buffer size must be a positive multiple of the stride */ |
1149 | instance->tx_channel.buf_size = max (instance->tx_channel.stride, | 1147 | instance->tx_channel.buf_size = max(instance->tx_channel.stride, |
1150 | snd_buf_bytes - (snd_buf_bytes % instance->tx_channel.stride)); | 1148 | snd_buf_bytes - (snd_buf_bytes % instance->tx_channel.stride)); |
1151 | 1149 | ||
1152 | /* rx buffer size must be a positive multiple of the endpoint maxpacket */ | 1150 | /* rx buffer size must be a positive multiple of the endpoint maxpacket */ |
@@ -1159,7 +1157,7 @@ int usbatm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id, | |||
1159 | goto fail_unbind; | 1157 | goto fail_unbind; |
1160 | } | 1158 | } |
1161 | 1159 | ||
1162 | num_packets = max (1U, (rcv_buf_bytes + maxpacket / 2) / maxpacket); /* round */ | 1160 | num_packets = max(1U, (rcv_buf_bytes + maxpacket / 2) / maxpacket); /* round */ |
1163 | 1161 | ||
1164 | if (num_packets * maxpacket > UDSL_MAX_BUF_SIZE) | 1162 | if (num_packets * maxpacket > UDSL_MAX_BUF_SIZE) |
1165 | num_packets--; | 1163 | num_packets--; |
@@ -1262,7 +1260,7 @@ int usbatm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id, | |||
1262 | usb_free_urb(instance->urbs[i]); | 1260 | usb_free_urb(instance->urbs[i]); |
1263 | } | 1261 | } |
1264 | 1262 | ||
1265 | kfree (instance); | 1263 | kfree(instance); |
1266 | 1264 | ||
1267 | return error; | 1265 | return error; |
1268 | } | 1266 | } |
@@ -1390,9 +1388,8 @@ static int usbatm_print_packet(const unsigned char *data, int len) | |||
1390 | for (i = 0; i < len;) { | 1388 | for (i = 0; i < len;) { |
1391 | buffer[0] = '\0'; | 1389 | buffer[0] = '\0'; |
1392 | sprintf(buffer, "%.3d :", i); | 1390 | sprintf(buffer, "%.3d :", i); |
1393 | for (j = 0; (j < 16) && (i < len); j++, i++) { | 1391 | for (j = 0; (j < 16) && (i < len); j++, i++) |
1394 | sprintf(buffer, "%s %2.2x", buffer, data[i]); | 1392 | sprintf(buffer, "%s %2.2x", buffer, data[i]); |
1395 | } | ||
1396 | dbg("%s", buffer); | 1393 | dbg("%s", buffer); |
1397 | } | 1394 | } |
1398 | return i; | 1395 | return i; |
diff --git a/drivers/usb/atm/usbatm.h b/drivers/usb/atm/usbatm.h index 0863f85fcc26..5fc489405217 100644 --- a/drivers/usb/atm/usbatm.h +++ b/drivers/usb/atm/usbatm.h | |||
@@ -48,7 +48,7 @@ | |||
48 | dev_warn(&(instance)->usb_intf->dev, \ | 48 | dev_warn(&(instance)->usb_intf->dev, \ |
49 | "failed assertion '%s' at line %d", \ | 49 | "failed assertion '%s' at line %d", \ |
50 | __stringify(x), __LINE__); \ | 50 | __stringify(x), __LINE__); \ |
51 | } while(0) | 51 | } while (0) |
52 | #endif | 52 | #endif |
53 | 53 | ||
54 | #define usb_err(instance, format, arg...) \ | 54 | #define usb_err(instance, format, arg...) \ |
@@ -59,7 +59,7 @@ | |||
59 | dev_warn(&(instance)->usb_intf->dev , format , ## arg) | 59 | dev_warn(&(instance)->usb_intf->dev , format , ## arg) |
60 | #ifdef DEBUG | 60 | #ifdef DEBUG |
61 | #define usb_dbg(instance, format, arg...) \ | 61 | #define usb_dbg(instance, format, arg...) \ |
62 | dev_printk(KERN_DEBUG , &(instance)->usb_intf->dev , format , ## arg) | 62 | dev_printk(KERN_DEBUG , &(instance)->usb_intf->dev , format , ## arg) |
63 | #else | 63 | #else |
64 | #define usb_dbg(instance, format, arg...) \ | 64 | #define usb_dbg(instance, format, arg...) \ |
65 | do {} while (0) | 65 | do {} while (0) |
@@ -104,21 +104,21 @@ struct usbatm_data; | |||
104 | /* | 104 | /* |
105 | * Assuming all methods exist and succeed, they are called in this order: | 105 | * Assuming all methods exist and succeed, they are called in this order: |
106 | * | 106 | * |
107 | * bind, heavy_init, atm_start, ..., atm_stop, unbind | 107 | * bind, heavy_init, atm_start, ..., atm_stop, unbind |
108 | */ | 108 | */ |
109 | 109 | ||
110 | struct usbatm_driver { | 110 | struct usbatm_driver { |
111 | const char *driver_name; | 111 | const char *driver_name; |
112 | 112 | ||
113 | /* init device ... can sleep, or cause probe() failure */ | 113 | /* init device ... can sleep, or cause probe() failure */ |
114 | int (*bind) (struct usbatm_data *, struct usb_interface *, | 114 | int (*bind) (struct usbatm_data *, struct usb_interface *, |
115 | const struct usb_device_id *id); | 115 | const struct usb_device_id *id); |
116 | 116 | ||
117 | /* additional device initialization that is too slow to be done in probe() */ | 117 | /* additional device initialization that is too slow to be done in probe() */ |
118 | int (*heavy_init) (struct usbatm_data *, struct usb_interface *); | 118 | int (*heavy_init) (struct usbatm_data *, struct usb_interface *); |
119 | 119 | ||
120 | /* cleanup device ... can sleep, but can't fail */ | 120 | /* cleanup device ... can sleep, but can't fail */ |
121 | void (*unbind) (struct usbatm_data *, struct usb_interface *); | 121 | void (*unbind) (struct usbatm_data *, struct usb_interface *); |
122 | 122 | ||
123 | /* init ATM device ... can sleep, or cause ATM initialization failure */ | 123 | /* init ATM device ... can sleep, or cause ATM initialization failure */ |
124 | int (*atm_start) (struct usbatm_data *, struct atm_dev *); | 124 | int (*atm_start) (struct usbatm_data *, struct atm_dev *); |
@@ -126,9 +126,9 @@ struct usbatm_driver { | |||
126 | /* cleanup ATM device ... can sleep, but can't fail */ | 126 | /* cleanup ATM device ... can sleep, but can't fail */ |
127 | void (*atm_stop) (struct usbatm_data *, struct atm_dev *); | 127 | void (*atm_stop) (struct usbatm_data *, struct atm_dev *); |
128 | 128 | ||
129 | int bulk_in; /* bulk rx endpoint */ | 129 | int bulk_in; /* bulk rx endpoint */ |
130 | int isoc_in; /* isochronous rx endpoint */ | 130 | int isoc_in; /* isochronous rx endpoint */ |
131 | int bulk_out; /* bulk tx endpoint */ | 131 | int bulk_out; /* bulk tx endpoint */ |
132 | 132 | ||
133 | unsigned rx_padding; | 133 | unsigned rx_padding; |
134 | unsigned tx_padding; | 134 | unsigned tx_padding; |
@@ -156,7 +156,7 @@ struct usbatm_channel { | |||
156 | struct usbatm_data { | 156 | struct usbatm_data { |
157 | /****************** | 157 | /****************** |
158 | * public fields * | 158 | * public fields * |
159 | ******************/ | 159 | ******************/ |
160 | 160 | ||
161 | /* mini driver */ | 161 | /* mini driver */ |
162 | struct usbatm_driver *driver; | 162 | struct usbatm_driver *driver; |
@@ -174,7 +174,7 @@ struct usbatm_data { | |||
174 | 174 | ||
175 | /******************************** | 175 | /******************************** |
176 | * private fields - do not use * | 176 | * private fields - do not use * |
177 | ********************************/ | 177 | ********************************/ |
178 | 178 | ||
179 | struct kref refcount; | 179 | struct kref refcount; |
180 | struct mutex serialize; | 180 | struct mutex serialize; |
diff --git a/drivers/usb/atm/xusbatm.c b/drivers/usb/atm/xusbatm.c index 17d167bbd2dc..48ee0c5ff282 100644 --- a/drivers/usb/atm/xusbatm.c +++ b/drivers/usb/atm/xusbatm.c | |||
@@ -49,13 +49,13 @@ static struct usbatm_driver xusbatm_drivers[XUSBATM_DRIVERS_MAX]; | |||
49 | static struct usb_device_id xusbatm_usb_ids[XUSBATM_DRIVERS_MAX + 1]; | 49 | static struct usb_device_id xusbatm_usb_ids[XUSBATM_DRIVERS_MAX + 1]; |
50 | static struct usb_driver xusbatm_usb_driver; | 50 | static struct usb_driver xusbatm_usb_driver; |
51 | 51 | ||
52 | static struct usb_interface *xusbatm_find_intf (struct usb_device *usb_dev, int altsetting, u8 ep) | 52 | static struct usb_interface *xusbatm_find_intf(struct usb_device *usb_dev, int altsetting, u8 ep) |
53 | { | 53 | { |
54 | struct usb_host_interface *alt; | 54 | struct usb_host_interface *alt; |
55 | struct usb_interface *intf; | 55 | struct usb_interface *intf; |
56 | int i, j; | 56 | int i, j; |
57 | 57 | ||
58 | for(i = 0; i < usb_dev->actconfig->desc.bNumInterfaces; i++) | 58 | for (i = 0; i < usb_dev->actconfig->desc.bNumInterfaces; i++) |
59 | if ((intf = usb_dev->actconfig->interface[i]) && (alt = usb_altnum_to_altsetting(intf, altsetting))) | 59 | if ((intf = usb_dev->actconfig->interface[i]) && (alt = usb_altnum_to_altsetting(intf, altsetting))) |
60 | for (j = 0; j < alt->desc.bNumEndpoints; j++) | 60 | for (j = 0; j < alt->desc.bNumEndpoints; j++) |
61 | if (alt->endpoint[j].desc.bEndpointAddress == ep) | 61 | if (alt->endpoint[j].desc.bEndpointAddress == ep) |
@@ -63,7 +63,7 @@ static struct usb_interface *xusbatm_find_intf (struct usb_device *usb_dev, int | |||
63 | return NULL; | 63 | return NULL; |
64 | } | 64 | } |
65 | 65 | ||
66 | static int xusbatm_capture_intf (struct usbatm_data *usbatm, struct usb_device *usb_dev, | 66 | static int xusbatm_capture_intf(struct usbatm_data *usbatm, struct usb_device *usb_dev, |
67 | struct usb_interface *intf, int altsetting, int claim) | 67 | struct usb_interface *intf, int altsetting, int claim) |
68 | { | 68 | { |
69 | int ifnum = intf->altsetting->desc.bInterfaceNumber; | 69 | int ifnum = intf->altsetting->desc.bInterfaceNumber; |
@@ -80,7 +80,7 @@ static int xusbatm_capture_intf (struct usbatm_data *usbatm, struct usb_device * | |||
80 | return 0; | 80 | return 0; |
81 | } | 81 | } |
82 | 82 | ||
83 | static void xusbatm_release_intf (struct usb_device *usb_dev, struct usb_interface *intf, int claimed) | 83 | static void xusbatm_release_intf(struct usb_device *usb_dev, struct usb_interface *intf, int claimed) |
84 | { | 84 | { |
85 | if (claimed) { | 85 | if (claimed) { |
86 | usb_set_intfdata(intf, NULL); | 86 | usb_set_intfdata(intf, NULL); |
@@ -147,7 +147,7 @@ static void xusbatm_unbind(struct usbatm_data *usbatm, | |||
147 | 147 | ||
148 | usb_dbg(usbatm, "%s entered\n", __func__); | 148 | usb_dbg(usbatm, "%s entered\n", __func__); |
149 | 149 | ||
150 | for(i = 0; i < usb_dev->actconfig->desc.bNumInterfaces; i++) { | 150 | for (i = 0; i < usb_dev->actconfig->desc.bNumInterfaces; i++) { |
151 | struct usb_interface *cur_intf = usb_dev->actconfig->interface[i]; | 151 | struct usb_interface *cur_intf = usb_dev->actconfig->interface[i]; |
152 | 152 | ||
153 | if (cur_intf && (usb_get_intfdata(cur_intf) == usbatm)) { | 153 | if (cur_intf && (usb_get_intfdata(cur_intf) == usbatm)) { |
diff --git a/drivers/usb/c67x00/c67x00-hcd.c b/drivers/usb/c67x00/c67x00-hcd.c index a22b887f4e9e..d3e1356d091e 100644 --- a/drivers/usb/c67x00/c67x00-hcd.c +++ b/drivers/usb/c67x00/c67x00-hcd.c | |||
@@ -264,7 +264,7 @@ static void c67x00_hcd_irq(struct c67x00_sie *sie, u16 int_status, u16 msg) | |||
264 | if (unlikely(hcd->state == HC_STATE_HALT)) | 264 | if (unlikely(hcd->state == HC_STATE_HALT)) |
265 | return; | 265 | return; |
266 | 266 | ||
267 | if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) | 267 | if (!HCD_HW_ACCESSIBLE(hcd)) |
268 | return; | 268 | return; |
269 | 269 | ||
270 | /* Handle Start of frame events */ | 270 | /* Handle Start of frame events */ |
@@ -282,7 +282,7 @@ static int c67x00_hcd_start(struct usb_hcd *hcd) | |||
282 | { | 282 | { |
283 | hcd->uses_new_polling = 1; | 283 | hcd->uses_new_polling = 1; |
284 | hcd->state = HC_STATE_RUNNING; | 284 | hcd->state = HC_STATE_RUNNING; |
285 | hcd->poll_rh = 1; | 285 | set_bit(HCD_FLAG_POLL_RH, &hcd->flags); |
286 | 286 | ||
287 | return 0; | 287 | return 0; |
288 | } | 288 | } |
diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c index 84f9e52327f2..e325162859b0 100644 --- a/drivers/usb/class/usblp.c +++ b/drivers/usb/class/usblp.c | |||
@@ -135,7 +135,7 @@ MFG:HEWLETT-PACKARD;MDL:DESKJET 970C;CMD:MLC,PCL,PML;CLASS:PRINTER;DESCRIPTION:H | |||
135 | * ->lock locks what interrupt accesses. | 135 | * ->lock locks what interrupt accesses. |
136 | */ | 136 | */ |
137 | struct usblp { | 137 | struct usblp { |
138 | struct usb_device *dev; /* USB device */ | 138 | struct usb_device *dev; /* USB device */ |
139 | struct mutex wmut; | 139 | struct mutex wmut; |
140 | struct mutex mut; | 140 | struct mutex mut; |
141 | spinlock_t lock; /* locks rcomplete, wcomplete */ | 141 | spinlock_t lock; /* locks rcomplete, wcomplete */ |
@@ -169,7 +169,8 @@ struct usblp { | |||
169 | }; | 169 | }; |
170 | 170 | ||
171 | #ifdef DEBUG | 171 | #ifdef DEBUG |
172 | static void usblp_dump(struct usblp *usblp) { | 172 | static void usblp_dump(struct usblp *usblp) |
173 | { | ||
173 | int p; | 174 | int p; |
174 | 175 | ||
175 | dbg("usblp=0x%p", usblp); | 176 | dbg("usblp=0x%p", usblp); |
@@ -216,8 +217,8 @@ static const struct quirk_printer_struct quirk_printers[] = { | |||
216 | { 0x03f0, 0x0304, USBLP_QUIRK_BIDIR }, /* HP DeskJet 810C/812C */ | 217 | { 0x03f0, 0x0304, USBLP_QUIRK_BIDIR }, /* HP DeskJet 810C/812C */ |
217 | { 0x03f0, 0x0404, USBLP_QUIRK_BIDIR }, /* HP DeskJet 830C */ | 218 | { 0x03f0, 0x0404, USBLP_QUIRK_BIDIR }, /* HP DeskJet 830C */ |
218 | { 0x03f0, 0x0504, USBLP_QUIRK_BIDIR }, /* HP DeskJet 885C */ | 219 | { 0x03f0, 0x0504, USBLP_QUIRK_BIDIR }, /* HP DeskJet 885C */ |
219 | { 0x03f0, 0x0604, USBLP_QUIRK_BIDIR }, /* HP DeskJet 840C */ | 220 | { 0x03f0, 0x0604, USBLP_QUIRK_BIDIR }, /* HP DeskJet 840C */ |
220 | { 0x03f0, 0x0804, USBLP_QUIRK_BIDIR }, /* HP DeskJet 816C */ | 221 | { 0x03f0, 0x0804, USBLP_QUIRK_BIDIR }, /* HP DeskJet 816C */ |
221 | { 0x03f0, 0x1104, USBLP_QUIRK_BIDIR }, /* HP Deskjet 959C */ | 222 | { 0x03f0, 0x1104, USBLP_QUIRK_BIDIR }, /* HP Deskjet 959C */ |
222 | { 0x0409, 0xefbe, USBLP_QUIRK_BIDIR }, /* NEC Picty900 (HP OEM) */ | 223 | { 0x0409, 0xefbe, USBLP_QUIRK_BIDIR }, /* NEC Picty900 (HP OEM) */ |
223 | { 0x0409, 0xbef4, USBLP_QUIRK_BIDIR }, /* NEC Picty760 (HP OEM) */ | 224 | { 0x0409, 0xbef4, USBLP_QUIRK_BIDIR }, /* NEC Picty760 (HP OEM) */ |
@@ -254,9 +255,8 @@ static int usblp_ctrl_msg(struct usblp *usblp, int request, int type, int dir, i | |||
254 | /* High byte has the interface index. | 255 | /* High byte has the interface index. |
255 | Low byte has the alternate setting. | 256 | Low byte has the alternate setting. |
256 | */ | 257 | */ |
257 | if ((request == USBLP_REQ_GET_ID) && (type == USB_TYPE_CLASS)) { | 258 | if ((request == USBLP_REQ_GET_ID) && (type == USB_TYPE_CLASS)) |
258 | index = (usblp->ifnum<<8)|usblp->protocol[usblp->current_protocol].alt_setting; | 259 | index = (usblp->ifnum<<8)|usblp->protocol[usblp->current_protocol].alt_setting; |
259 | } | ||
260 | 260 | ||
261 | retval = usb_control_msg(usblp->dev, | 261 | retval = usb_control_msg(usblp->dev, |
262 | dir ? usb_rcvctrlpipe(usblp->dev, 0) : usb_sndctrlpipe(usblp->dev, 0), | 262 | dir ? usb_rcvctrlpipe(usblp->dev, 0) : usb_sndctrlpipe(usblp->dev, 0), |
@@ -372,7 +372,7 @@ static int usblp_check_status(struct usblp *usblp, int err) | |||
372 | return newerr; | 372 | return newerr; |
373 | } | 373 | } |
374 | 374 | ||
375 | static int handle_bidir (struct usblp *usblp) | 375 | static int handle_bidir(struct usblp *usblp) |
376 | { | 376 | { |
377 | if (usblp->bidir && usblp->used) { | 377 | if (usblp->bidir && usblp->used) { |
378 | if (usblp_submit_read(usblp) < 0) | 378 | if (usblp_submit_read(usblp) < 0) |
@@ -395,14 +395,13 @@ static int usblp_open(struct inode *inode, struct file *file) | |||
395 | if (minor < 0) | 395 | if (minor < 0) |
396 | return -ENODEV; | 396 | return -ENODEV; |
397 | 397 | ||
398 | mutex_lock (&usblp_mutex); | 398 | mutex_lock(&usblp_mutex); |
399 | 399 | ||
400 | retval = -ENODEV; | 400 | retval = -ENODEV; |
401 | intf = usb_find_interface(&usblp_driver, minor); | 401 | intf = usb_find_interface(&usblp_driver, minor); |
402 | if (!intf) { | 402 | if (!intf) |
403 | goto out; | 403 | goto out; |
404 | } | 404 | usblp = usb_get_intfdata(intf); |
405 | usblp = usb_get_intfdata (intf); | ||
406 | if (!usblp || !usblp->dev || !usblp->present) | 405 | if (!usblp || !usblp->dev || !usblp->present) |
407 | goto out; | 406 | goto out; |
408 | 407 | ||
@@ -433,18 +432,18 @@ static int usblp_open(struct inode *inode, struct file *file) | |||
433 | retval = -EIO; | 432 | retval = -EIO; |
434 | } | 433 | } |
435 | out: | 434 | out: |
436 | mutex_unlock (&usblp_mutex); | 435 | mutex_unlock(&usblp_mutex); |
437 | return retval; | 436 | return retval; |
438 | } | 437 | } |
439 | 438 | ||
440 | static void usblp_cleanup (struct usblp *usblp) | 439 | static void usblp_cleanup(struct usblp *usblp) |
441 | { | 440 | { |
442 | printk(KERN_INFO "usblp%d: removed\n", usblp->minor); | 441 | printk(KERN_INFO "usblp%d: removed\n", usblp->minor); |
443 | 442 | ||
444 | kfree(usblp->readbuf); | 443 | kfree(usblp->readbuf); |
445 | kfree (usblp->device_id_string); | 444 | kfree(usblp->device_id_string); |
446 | kfree (usblp->statusbuf); | 445 | kfree(usblp->statusbuf); |
447 | kfree (usblp); | 446 | kfree(usblp); |
448 | } | 447 | } |
449 | 448 | ||
450 | static void usblp_unlink_urbs(struct usblp *usblp) | 449 | static void usblp_unlink_urbs(struct usblp *usblp) |
@@ -458,14 +457,14 @@ static int usblp_release(struct inode *inode, struct file *file) | |||
458 | 457 | ||
459 | usblp->flags &= ~LP_ABORT; | 458 | usblp->flags &= ~LP_ABORT; |
460 | 459 | ||
461 | mutex_lock (&usblp_mutex); | 460 | mutex_lock(&usblp_mutex); |
462 | usblp->used = 0; | 461 | usblp->used = 0; |
463 | if (usblp->present) { | 462 | if (usblp->present) { |
464 | usblp_unlink_urbs(usblp); | 463 | usblp_unlink_urbs(usblp); |
465 | usb_autopm_put_interface(usblp->intf); | 464 | usb_autopm_put_interface(usblp->intf); |
466 | } else /* finish cleanup from disconnect */ | 465 | } else /* finish cleanup from disconnect */ |
467 | usblp_cleanup (usblp); | 466 | usblp_cleanup(usblp); |
468 | mutex_unlock (&usblp_mutex); | 467 | mutex_unlock(&usblp_mutex); |
469 | return 0; | 468 | return 0; |
470 | } | 469 | } |
471 | 470 | ||
@@ -495,190 +494,190 @@ static long usblp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
495 | int twoints[2]; | 494 | int twoints[2]; |
496 | int retval = 0; | 495 | int retval = 0; |
497 | 496 | ||
498 | mutex_lock (&usblp->mut); | 497 | mutex_lock(&usblp->mut); |
499 | if (!usblp->present) { | 498 | if (!usblp->present) { |
500 | retval = -ENODEV; | 499 | retval = -ENODEV; |
501 | goto done; | 500 | goto done; |
502 | } | 501 | } |
503 | 502 | ||
504 | dbg("usblp_ioctl: cmd=0x%x (%c nr=%d len=%d dir=%d)", cmd, _IOC_TYPE(cmd), | 503 | dbg("usblp_ioctl: cmd=0x%x (%c nr=%d len=%d dir=%d)", cmd, _IOC_TYPE(cmd), |
505 | _IOC_NR(cmd), _IOC_SIZE(cmd), _IOC_DIR(cmd) ); | 504 | _IOC_NR(cmd), _IOC_SIZE(cmd), _IOC_DIR(cmd)); |
506 | 505 | ||
507 | if (_IOC_TYPE(cmd) == 'P') /* new-style ioctl number */ | 506 | if (_IOC_TYPE(cmd) == 'P') /* new-style ioctl number */ |
508 | 507 | ||
509 | switch (_IOC_NR(cmd)) { | 508 | switch (_IOC_NR(cmd)) { |
510 | 509 | ||
511 | case IOCNR_GET_DEVICE_ID: /* get the DEVICE_ID string */ | 510 | case IOCNR_GET_DEVICE_ID: /* get the DEVICE_ID string */ |
512 | if (_IOC_DIR(cmd) != _IOC_READ) { | 511 | if (_IOC_DIR(cmd) != _IOC_READ) { |
513 | retval = -EINVAL; | 512 | retval = -EINVAL; |
514 | goto done; | 513 | goto done; |
515 | } | 514 | } |
516 | 515 | ||
517 | length = usblp_cache_device_id_string(usblp); | 516 | length = usblp_cache_device_id_string(usblp); |
518 | if (length < 0) { | 517 | if (length < 0) { |
519 | retval = length; | 518 | retval = length; |
520 | goto done; | 519 | goto done; |
521 | } | 520 | } |
522 | if (length > _IOC_SIZE(cmd)) | 521 | if (length > _IOC_SIZE(cmd)) |
523 | length = _IOC_SIZE(cmd); /* truncate */ | 522 | length = _IOC_SIZE(cmd); /* truncate */ |
524 | 523 | ||
525 | if (copy_to_user((void __user *) arg, | 524 | if (copy_to_user((void __user *) arg, |
526 | usblp->device_id_string, | 525 | usblp->device_id_string, |
527 | (unsigned long) length)) { | 526 | (unsigned long) length)) { |
528 | retval = -EFAULT; | 527 | retval = -EFAULT; |
529 | goto done; | 528 | goto done; |
530 | } | 529 | } |
531 | 530 | ||
532 | break; | 531 | break; |
533 | 532 | ||
534 | case IOCNR_GET_PROTOCOLS: | 533 | case IOCNR_GET_PROTOCOLS: |
535 | if (_IOC_DIR(cmd) != _IOC_READ || | 534 | if (_IOC_DIR(cmd) != _IOC_READ || |
536 | _IOC_SIZE(cmd) < sizeof(twoints)) { | 535 | _IOC_SIZE(cmd) < sizeof(twoints)) { |
537 | retval = -EINVAL; | 536 | retval = -EINVAL; |
538 | goto done; | 537 | goto done; |
539 | } | 538 | } |
540 | 539 | ||
541 | twoints[0] = usblp->current_protocol; | 540 | twoints[0] = usblp->current_protocol; |
542 | twoints[1] = 0; | 541 | twoints[1] = 0; |
543 | for (i = USBLP_FIRST_PROTOCOL; | 542 | for (i = USBLP_FIRST_PROTOCOL; |
544 | i <= USBLP_LAST_PROTOCOL; i++) { | 543 | i <= USBLP_LAST_PROTOCOL; i++) { |
545 | if (usblp->protocol[i].alt_setting >= 0) | 544 | if (usblp->protocol[i].alt_setting >= 0) |
546 | twoints[1] |= (1<<i); | 545 | twoints[1] |= (1<<i); |
547 | } | 546 | } |
548 | 547 | ||
549 | if (copy_to_user((void __user *)arg, | 548 | if (copy_to_user((void __user *)arg, |
550 | (unsigned char *)twoints, | 549 | (unsigned char *)twoints, |
551 | sizeof(twoints))) { | 550 | sizeof(twoints))) { |
552 | retval = -EFAULT; | 551 | retval = -EFAULT; |
553 | goto done; | 552 | goto done; |
554 | } | 553 | } |
555 | 554 | ||
556 | break; | 555 | break; |
557 | 556 | ||
558 | case IOCNR_SET_PROTOCOL: | 557 | case IOCNR_SET_PROTOCOL: |
559 | if (_IOC_DIR(cmd) != _IOC_WRITE) { | 558 | if (_IOC_DIR(cmd) != _IOC_WRITE) { |
560 | retval = -EINVAL; | 559 | retval = -EINVAL; |
561 | goto done; | 560 | goto done; |
562 | } | 561 | } |
563 | 562 | ||
564 | #ifdef DEBUG | 563 | #ifdef DEBUG |
565 | if (arg == -10) { | 564 | if (arg == -10) { |
566 | usblp_dump(usblp); | 565 | usblp_dump(usblp); |
567 | break; | 566 | break; |
568 | } | 567 | } |
569 | #endif | 568 | #endif |
570 | 569 | ||
571 | usblp_unlink_urbs(usblp); | 570 | usblp_unlink_urbs(usblp); |
572 | retval = usblp_set_protocol(usblp, arg); | 571 | retval = usblp_set_protocol(usblp, arg); |
573 | if (retval < 0) { | 572 | if (retval < 0) { |
574 | usblp_set_protocol(usblp, | 573 | usblp_set_protocol(usblp, |
575 | usblp->current_protocol); | 574 | usblp->current_protocol); |
576 | } | 575 | } |
577 | break; | 576 | break; |
578 | 577 | ||
579 | case IOCNR_HP_SET_CHANNEL: | 578 | case IOCNR_HP_SET_CHANNEL: |
580 | if (_IOC_DIR(cmd) != _IOC_WRITE || | 579 | if (_IOC_DIR(cmd) != _IOC_WRITE || |
581 | le16_to_cpu(usblp->dev->descriptor.idVendor) != 0x03F0 || | 580 | le16_to_cpu(usblp->dev->descriptor.idVendor) != 0x03F0 || |
582 | usblp->quirks & USBLP_QUIRK_BIDIR) { | 581 | usblp->quirks & USBLP_QUIRK_BIDIR) { |
583 | retval = -EINVAL; | 582 | retval = -EINVAL; |
584 | goto done; | 583 | goto done; |
585 | } | 584 | } |
586 | 585 | ||
587 | err = usblp_hp_channel_change_request(usblp, | 586 | err = usblp_hp_channel_change_request(usblp, |
588 | arg, &newChannel); | 587 | arg, &newChannel); |
589 | if (err < 0) { | 588 | if (err < 0) { |
590 | dev_err(&usblp->dev->dev, | 589 | dev_err(&usblp->dev->dev, |
591 | "usblp%d: error = %d setting " | 590 | "usblp%d: error = %d setting " |
592 | "HP channel\n", | 591 | "HP channel\n", |
593 | usblp->minor, err); | 592 | usblp->minor, err); |
594 | retval = -EIO; | 593 | retval = -EIO; |
595 | goto done; | 594 | goto done; |
596 | } | 595 | } |
597 | 596 | ||
598 | dbg("usblp%d requested/got HP channel %ld/%d", | 597 | dbg("usblp%d requested/got HP channel %ld/%d", |
599 | usblp->minor, arg, newChannel); | 598 | usblp->minor, arg, newChannel); |
600 | break; | 599 | break; |
601 | 600 | ||
602 | case IOCNR_GET_BUS_ADDRESS: | 601 | case IOCNR_GET_BUS_ADDRESS: |
603 | if (_IOC_DIR(cmd) != _IOC_READ || | 602 | if (_IOC_DIR(cmd) != _IOC_READ || |
604 | _IOC_SIZE(cmd) < sizeof(twoints)) { | 603 | _IOC_SIZE(cmd) < sizeof(twoints)) { |
605 | retval = -EINVAL; | 604 | retval = -EINVAL; |
606 | goto done; | 605 | goto done; |
607 | } | 606 | } |
608 | 607 | ||
609 | twoints[0] = usblp->dev->bus->busnum; | 608 | twoints[0] = usblp->dev->bus->busnum; |
610 | twoints[1] = usblp->dev->devnum; | 609 | twoints[1] = usblp->dev->devnum; |
611 | if (copy_to_user((void __user *)arg, | 610 | if (copy_to_user((void __user *)arg, |
612 | (unsigned char *)twoints, | 611 | (unsigned char *)twoints, |
613 | sizeof(twoints))) { | 612 | sizeof(twoints))) { |
614 | retval = -EFAULT; | 613 | retval = -EFAULT; |
615 | goto done; | 614 | goto done; |
616 | } | 615 | } |
617 | 616 | ||
618 | dbg("usblp%d is bus=%d, device=%d", | 617 | dbg("usblp%d is bus=%d, device=%d", |
619 | usblp->minor, twoints[0], twoints[1]); | 618 | usblp->minor, twoints[0], twoints[1]); |
620 | break; | 619 | break; |
621 | 620 | ||
622 | case IOCNR_GET_VID_PID: | 621 | case IOCNR_GET_VID_PID: |
623 | if (_IOC_DIR(cmd) != _IOC_READ || | 622 | if (_IOC_DIR(cmd) != _IOC_READ || |
624 | _IOC_SIZE(cmd) < sizeof(twoints)) { | 623 | _IOC_SIZE(cmd) < sizeof(twoints)) { |
625 | retval = -EINVAL; | 624 | retval = -EINVAL; |
626 | goto done; | 625 | goto done; |
627 | } | 626 | } |
628 | 627 | ||
629 | twoints[0] = le16_to_cpu(usblp->dev->descriptor.idVendor); | 628 | twoints[0] = le16_to_cpu(usblp->dev->descriptor.idVendor); |
630 | twoints[1] = le16_to_cpu(usblp->dev->descriptor.idProduct); | 629 | twoints[1] = le16_to_cpu(usblp->dev->descriptor.idProduct); |
631 | if (copy_to_user((void __user *)arg, | 630 | if (copy_to_user((void __user *)arg, |
632 | (unsigned char *)twoints, | 631 | (unsigned char *)twoints, |
633 | sizeof(twoints))) { | 632 | sizeof(twoints))) { |
634 | retval = -EFAULT; | 633 | retval = -EFAULT; |
635 | goto done; | 634 | goto done; |
636 | } | 635 | } |
637 | 636 | ||
638 | dbg("usblp%d is VID=0x%4.4X, PID=0x%4.4X", | 637 | dbg("usblp%d is VID=0x%4.4X, PID=0x%4.4X", |
639 | usblp->minor, twoints[0], twoints[1]); | 638 | usblp->minor, twoints[0], twoints[1]); |
640 | break; | 639 | break; |
641 | 640 | ||
642 | case IOCNR_SOFT_RESET: | 641 | case IOCNR_SOFT_RESET: |
643 | if (_IOC_DIR(cmd) != _IOC_NONE) { | 642 | if (_IOC_DIR(cmd) != _IOC_NONE) { |
644 | retval = -EINVAL; | 643 | retval = -EINVAL; |
645 | goto done; | 644 | goto done; |
646 | } | 645 | } |
647 | retval = usblp_reset(usblp); | 646 | retval = usblp_reset(usblp); |
648 | break; | 647 | break; |
649 | default: | 648 | default: |
650 | retval = -ENOTTY; | 649 | retval = -ENOTTY; |
651 | } | 650 | } |
652 | else /* old-style ioctl value */ | 651 | else /* old-style ioctl value */ |
653 | switch (cmd) { | 652 | switch (cmd) { |
654 | 653 | ||
655 | case LPGETSTATUS: | 654 | case LPGETSTATUS: |
656 | if ((retval = usblp_read_status(usblp, usblp->statusbuf))) { | 655 | if ((retval = usblp_read_status(usblp, usblp->statusbuf))) { |
657 | if (printk_ratelimit()) | 656 | if (printk_ratelimit()) |
658 | printk(KERN_ERR "usblp%d:" | 657 | printk(KERN_ERR "usblp%d:" |
659 | "failed reading printer status (%d)\n", | 658 | "failed reading printer status (%d)\n", |
660 | usblp->minor, retval); | 659 | usblp->minor, retval); |
661 | retval = -EIO; | 660 | retval = -EIO; |
662 | goto done; | 661 | goto done; |
663 | } | 662 | } |
664 | status = *usblp->statusbuf; | 663 | status = *usblp->statusbuf; |
665 | if (copy_to_user ((void __user *)arg, &status, sizeof(int))) | 664 | if (copy_to_user((void __user *)arg, &status, sizeof(int))) |
666 | retval = -EFAULT; | 665 | retval = -EFAULT; |
667 | break; | 666 | break; |
668 | 667 | ||
669 | case LPABORT: | 668 | case LPABORT: |
670 | if (arg) | 669 | if (arg) |
671 | usblp->flags |= LP_ABORT; | 670 | usblp->flags |= LP_ABORT; |
672 | else | 671 | else |
673 | usblp->flags &= ~LP_ABORT; | 672 | usblp->flags &= ~LP_ABORT; |
674 | break; | 673 | break; |
675 | 674 | ||
676 | default: | 675 | default: |
677 | retval = -ENOTTY; | 676 | retval = -ENOTTY; |
678 | } | 677 | } |
679 | 678 | ||
680 | done: | 679 | done: |
681 | mutex_unlock (&usblp->mut); | 680 | mutex_unlock(&usblp->mut); |
682 | return retval; | 681 | return retval; |
683 | } | 682 | } |
684 | 683 | ||
@@ -840,7 +839,7 @@ static ssize_t usblp_read(struct file *file, char __user *buffer, size_t len, lo | |||
840 | } | 839 | } |
841 | 840 | ||
842 | done: | 841 | done: |
843 | mutex_unlock (&usblp->mut); | 842 | mutex_unlock(&usblp->mut); |
844 | return count; | 843 | return count; |
845 | } | 844 | } |
846 | 845 | ||
@@ -1023,7 +1022,7 @@ raise_urb: | |||
1023 | * while you are sending print data, and you don't try to query the | 1022 | * while you are sending print data, and you don't try to query the |
1024 | * printer status every couple of milliseconds, you will probably be OK. | 1023 | * printer status every couple of milliseconds, you will probably be OK. |
1025 | */ | 1024 | */ |
1026 | static unsigned int usblp_quirks (__u16 vendor, __u16 product) | 1025 | static unsigned int usblp_quirks(__u16 vendor, __u16 product) |
1027 | { | 1026 | { |
1028 | int i; | 1027 | int i; |
1029 | 1028 | ||
@@ -1031,7 +1030,7 @@ static unsigned int usblp_quirks (__u16 vendor, __u16 product) | |||
1031 | if (vendor == quirk_printers[i].vendorId && | 1030 | if (vendor == quirk_printers[i].vendorId && |
1032 | product == quirk_printers[i].productId) | 1031 | product == quirk_printers[i].productId) |
1033 | return quirk_printers[i].quirks; | 1032 | return quirk_printers[i].quirks; |
1034 | } | 1033 | } |
1035 | return 0; | 1034 | return 0; |
1036 | } | 1035 | } |
1037 | 1036 | ||
@@ -1061,7 +1060,7 @@ static struct usb_class_driver usblp_class = { | |||
1061 | static ssize_t usblp_show_ieee1284_id(struct device *dev, struct device_attribute *attr, char *buf) | 1060 | static ssize_t usblp_show_ieee1284_id(struct device *dev, struct device_attribute *attr, char *buf) |
1062 | { | 1061 | { |
1063 | struct usb_interface *intf = to_usb_interface(dev); | 1062 | struct usb_interface *intf = to_usb_interface(dev); |
1064 | struct usblp *usblp = usb_get_intfdata (intf); | 1063 | struct usblp *usblp = usb_get_intfdata(intf); |
1065 | 1064 | ||
1066 | if (usblp->device_id_string[0] == 0 && | 1065 | if (usblp->device_id_string[0] == 0 && |
1067 | usblp->device_id_string[1] == 0) | 1066 | usblp->device_id_string[1] == 0) |
@@ -1075,7 +1074,7 @@ static DEVICE_ATTR(ieee1284_id, S_IRUGO, usblp_show_ieee1284_id, NULL); | |||
1075 | static int usblp_probe(struct usb_interface *intf, | 1074 | static int usblp_probe(struct usb_interface *intf, |
1076 | const struct usb_device_id *id) | 1075 | const struct usb_device_id *id) |
1077 | { | 1076 | { |
1078 | struct usb_device *dev = interface_to_usbdev (intf); | 1077 | struct usb_device *dev = interface_to_usbdev(intf); |
1079 | struct usblp *usblp; | 1078 | struct usblp *usblp; |
1080 | int protocol; | 1079 | int protocol; |
1081 | int retval; | 1080 | int retval; |
@@ -1089,7 +1088,7 @@ static int usblp_probe(struct usb_interface *intf, | |||
1089 | } | 1088 | } |
1090 | usblp->dev = dev; | 1089 | usblp->dev = dev; |
1091 | mutex_init(&usblp->wmut); | 1090 | mutex_init(&usblp->wmut); |
1092 | mutex_init (&usblp->mut); | 1091 | mutex_init(&usblp->mut); |
1093 | spin_lock_init(&usblp->lock); | 1092 | spin_lock_init(&usblp->lock); |
1094 | init_waitqueue_head(&usblp->rwait); | 1093 | init_waitqueue_head(&usblp->rwait); |
1095 | init_waitqueue_head(&usblp->wwait); | 1094 | init_waitqueue_head(&usblp->wwait); |
@@ -1153,7 +1152,7 @@ static int usblp_probe(struct usb_interface *intf, | |||
1153 | usblp_check_status(usblp, 0); | 1152 | usblp_check_status(usblp, 0); |
1154 | #endif | 1153 | #endif |
1155 | 1154 | ||
1156 | usb_set_intfdata (intf, usblp); | 1155 | usb_set_intfdata(intf, usblp); |
1157 | 1156 | ||
1158 | usblp->present = 1; | 1157 | usblp->present = 1; |
1159 | 1158 | ||
@@ -1177,7 +1176,7 @@ static int usblp_probe(struct usb_interface *intf, | |||
1177 | return 0; | 1176 | return 0; |
1178 | 1177 | ||
1179 | abort_intfdata: | 1178 | abort_intfdata: |
1180 | usb_set_intfdata (intf, NULL); | 1179 | usb_set_intfdata(intf, NULL); |
1181 | device_remove_file(&intf->dev, &dev_attr_ieee1284_id); | 1180 | device_remove_file(&intf->dev, &dev_attr_ieee1284_id); |
1182 | abort: | 1181 | abort: |
1183 | kfree(usblp->readbuf); | 1182 | kfree(usblp->readbuf); |
@@ -1340,35 +1339,35 @@ static int usblp_cache_device_id_string(struct usblp *usblp) | |||
1340 | 1339 | ||
1341 | static void usblp_disconnect(struct usb_interface *intf) | 1340 | static void usblp_disconnect(struct usb_interface *intf) |
1342 | { | 1341 | { |
1343 | struct usblp *usblp = usb_get_intfdata (intf); | 1342 | struct usblp *usblp = usb_get_intfdata(intf); |
1344 | 1343 | ||
1345 | usb_deregister_dev(intf, &usblp_class); | 1344 | usb_deregister_dev(intf, &usblp_class); |
1346 | 1345 | ||
1347 | if (!usblp || !usblp->dev) { | 1346 | if (!usblp || !usblp->dev) { |
1348 | dev_err(&intf->dev, "bogus disconnect\n"); | 1347 | dev_err(&intf->dev, "bogus disconnect\n"); |
1349 | BUG (); | 1348 | BUG(); |
1350 | } | 1349 | } |
1351 | 1350 | ||
1352 | device_remove_file(&intf->dev, &dev_attr_ieee1284_id); | 1351 | device_remove_file(&intf->dev, &dev_attr_ieee1284_id); |
1353 | 1352 | ||
1354 | mutex_lock (&usblp_mutex); | 1353 | mutex_lock(&usblp_mutex); |
1355 | mutex_lock (&usblp->mut); | 1354 | mutex_lock(&usblp->mut); |
1356 | usblp->present = 0; | 1355 | usblp->present = 0; |
1357 | wake_up(&usblp->wwait); | 1356 | wake_up(&usblp->wwait); |
1358 | wake_up(&usblp->rwait); | 1357 | wake_up(&usblp->rwait); |
1359 | usb_set_intfdata (intf, NULL); | 1358 | usb_set_intfdata(intf, NULL); |
1360 | 1359 | ||
1361 | usblp_unlink_urbs(usblp); | 1360 | usblp_unlink_urbs(usblp); |
1362 | mutex_unlock (&usblp->mut); | 1361 | mutex_unlock(&usblp->mut); |
1363 | 1362 | ||
1364 | if (!usblp->used) | 1363 | if (!usblp->used) |
1365 | usblp_cleanup (usblp); | 1364 | usblp_cleanup(usblp); |
1366 | mutex_unlock (&usblp_mutex); | 1365 | mutex_unlock(&usblp_mutex); |
1367 | } | 1366 | } |
1368 | 1367 | ||
1369 | static int usblp_suspend(struct usb_interface *intf, pm_message_t message) | 1368 | static int usblp_suspend(struct usb_interface *intf, pm_message_t message) |
1370 | { | 1369 | { |
1371 | struct usblp *usblp = usb_get_intfdata (intf); | 1370 | struct usblp *usblp = usb_get_intfdata(intf); |
1372 | 1371 | ||
1373 | usblp_unlink_urbs(usblp); | 1372 | usblp_unlink_urbs(usblp); |
1374 | #if 0 /* XXX Do we want this? What if someone is reading, should we fail? */ | 1373 | #if 0 /* XXX Do we want this? What if someone is reading, should we fail? */ |
@@ -1382,10 +1381,10 @@ static int usblp_suspend(struct usb_interface *intf, pm_message_t message) | |||
1382 | 1381 | ||
1383 | static int usblp_resume(struct usb_interface *intf) | 1382 | static int usblp_resume(struct usb_interface *intf) |
1384 | { | 1383 | { |
1385 | struct usblp *usblp = usb_get_intfdata (intf); | 1384 | struct usblp *usblp = usb_get_intfdata(intf); |
1386 | int r; | 1385 | int r; |
1387 | 1386 | ||
1388 | r = handle_bidir (usblp); | 1387 | r = handle_bidir(usblp); |
1389 | 1388 | ||
1390 | return r; | 1389 | return r; |
1391 | } | 1390 | } |
@@ -1401,7 +1400,7 @@ static const struct usb_device_id usblp_ids[] = { | |||
1401 | { } /* Terminating entry */ | 1400 | { } /* Terminating entry */ |
1402 | }; | 1401 | }; |
1403 | 1402 | ||
1404 | MODULE_DEVICE_TABLE (usb, usblp_ids); | 1403 | MODULE_DEVICE_TABLE(usb, usblp_ids); |
1405 | 1404 | ||
1406 | static struct usb_driver usblp_driver = { | 1405 | static struct usb_driver usblp_driver = { |
1407 | .name = "usblp", | 1406 | .name = "usblp", |
@@ -1426,8 +1425,8 @@ static void __exit usblp_exit(void) | |||
1426 | module_init(usblp_init); | 1425 | module_init(usblp_init); |
1427 | module_exit(usblp_exit); | 1426 | module_exit(usblp_exit); |
1428 | 1427 | ||
1429 | MODULE_AUTHOR( DRIVER_AUTHOR ); | 1428 | MODULE_AUTHOR(DRIVER_AUTHOR); |
1430 | MODULE_DESCRIPTION( DRIVER_DESC ); | 1429 | MODULE_DESCRIPTION(DRIVER_DESC); |
1431 | module_param(proto_bias, int, S_IRUGO | S_IWUSR); | 1430 | module_param(proto_bias, int, S_IRUGO | S_IWUSR); |
1432 | MODULE_PARM_DESC(proto_bias, "Favourite protocol number"); | 1431 | MODULE_PARM_DESC(proto_bias, "Favourite protocol number"); |
1433 | MODULE_LICENSE("GPL"); | 1432 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c index c2f62a3993d2..f1aaff6202a5 100644 --- a/drivers/usb/core/devio.c +++ b/drivers/usb/core/devio.c | |||
@@ -1668,13 +1668,10 @@ static int proc_ioctl(struct dev_state *ps, struct usbdevfs_ioctl *ctl) | |||
1668 | default: | 1668 | default: |
1669 | if (intf->dev.driver) | 1669 | if (intf->dev.driver) |
1670 | driver = to_usb_driver(intf->dev.driver); | 1670 | driver = to_usb_driver(intf->dev.driver); |
1671 | if (driver == NULL || driver->ioctl == NULL) { | 1671 | if (driver == NULL || driver->unlocked_ioctl == NULL) { |
1672 | retval = -ENOTTY; | 1672 | retval = -ENOTTY; |
1673 | } else { | 1673 | } else { |
1674 | /* keep API that guarantees BKL */ | 1674 | retval = driver->unlocked_ioctl(intf, ctl->ioctl_code, buf); |
1675 | lock_kernel(); | ||
1676 | retval = driver->ioctl(intf, ctl->ioctl_code, buf); | ||
1677 | unlock_kernel(); | ||
1678 | if (retval == -ENOIOCTLCMD) | 1675 | if (retval == -ENOIOCTLCMD) |
1679 | retval = -ENOTTY; | 1676 | retval = -ENOTTY; |
1680 | } | 1677 | } |
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c index a6bd53ace035..d7a4401ef019 100644 --- a/drivers/usb/core/driver.c +++ b/drivers/usb/core/driver.c | |||
@@ -1742,9 +1742,8 @@ static int usb_runtime_suspend(struct device *dev) | |||
1742 | } | 1742 | } |
1743 | 1743 | ||
1744 | /* Prevent the parent from suspending immediately after */ | 1744 | /* Prevent the parent from suspending immediately after */ |
1745 | else if (udev->parent) { | 1745 | else if (udev->parent) |
1746 | udev->parent->last_busy = jiffies; | 1746 | udev->parent->last_busy = jiffies; |
1747 | } | ||
1748 | } | 1747 | } |
1749 | 1748 | ||
1750 | /* Runtime suspend for a USB interface doesn't mean anything. */ | 1749 | /* Runtime suspend for a USB interface doesn't mean anything. */ |
@@ -1786,21 +1785,19 @@ static int usb_runtime_idle(struct device *dev) | |||
1786 | return 0; | 1785 | return 0; |
1787 | } | 1786 | } |
1788 | 1787 | ||
1789 | static struct dev_pm_ops usb_bus_pm_ops = { | 1788 | static const struct dev_pm_ops usb_bus_pm_ops = { |
1790 | .runtime_suspend = usb_runtime_suspend, | 1789 | .runtime_suspend = usb_runtime_suspend, |
1791 | .runtime_resume = usb_runtime_resume, | 1790 | .runtime_resume = usb_runtime_resume, |
1792 | .runtime_idle = usb_runtime_idle, | 1791 | .runtime_idle = usb_runtime_idle, |
1793 | }; | 1792 | }; |
1794 | 1793 | ||
1795 | #else | ||
1796 | |||
1797 | #define usb_bus_pm_ops (*(struct dev_pm_ops *) NULL) | ||
1798 | |||
1799 | #endif /* CONFIG_USB_SUSPEND */ | 1794 | #endif /* CONFIG_USB_SUSPEND */ |
1800 | 1795 | ||
1801 | struct bus_type usb_bus_type = { | 1796 | struct bus_type usb_bus_type = { |
1802 | .name = "usb", | 1797 | .name = "usb", |
1803 | .match = usb_device_match, | 1798 | .match = usb_device_match, |
1804 | .uevent = usb_uevent, | 1799 | .uevent = usb_uevent, |
1800 | #ifdef CONFIG_USB_SUSPEND | ||
1805 | .pm = &usb_bus_pm_ops, | 1801 | .pm = &usb_bus_pm_ops, |
1802 | #endif | ||
1806 | }; | 1803 | }; |
diff --git a/drivers/usb/core/endpoint.c b/drivers/usb/core/endpoint.c index 4f84a41ee7a8..3788e738e265 100644 --- a/drivers/usb/core/endpoint.c +++ b/drivers/usb/core/endpoint.c | |||
@@ -96,16 +96,21 @@ static ssize_t show_ep_interval(struct device *dev, | |||
96 | 96 | ||
97 | switch (usb_endpoint_type(ep->desc)) { | 97 | switch (usb_endpoint_type(ep->desc)) { |
98 | case USB_ENDPOINT_XFER_CONTROL: | 98 | case USB_ENDPOINT_XFER_CONTROL: |
99 | if (ep->udev->speed == USB_SPEED_HIGH) /* uframes per NAK */ | 99 | if (ep->udev->speed == USB_SPEED_HIGH) |
100 | /* uframes per NAK */ | ||
100 | interval = ep->desc->bInterval; | 101 | interval = ep->desc->bInterval; |
101 | break; | 102 | break; |
103 | |||
102 | case USB_ENDPOINT_XFER_ISOC: | 104 | case USB_ENDPOINT_XFER_ISOC: |
103 | interval = 1 << (ep->desc->bInterval - 1); | 105 | interval = 1 << (ep->desc->bInterval - 1); |
104 | break; | 106 | break; |
107 | |||
105 | case USB_ENDPOINT_XFER_BULK: | 108 | case USB_ENDPOINT_XFER_BULK: |
106 | if (ep->udev->speed == USB_SPEED_HIGH && !in) /* uframes per NAK */ | 109 | if (ep->udev->speed == USB_SPEED_HIGH && !in) |
110 | /* uframes per NAK */ | ||
107 | interval = ep->desc->bInterval; | 111 | interval = ep->desc->bInterval; |
108 | break; | 112 | break; |
113 | |||
109 | case USB_ENDPOINT_XFER_INT: | 114 | case USB_ENDPOINT_XFER_INT: |
110 | if (ep->udev->speed == USB_SPEED_HIGH) | 115 | if (ep->udev->speed == USB_SPEED_HIGH) |
111 | interval = 1 << (ep->desc->bInterval - 1); | 116 | interval = 1 << (ep->desc->bInterval - 1); |
diff --git a/drivers/usb/core/generic.c b/drivers/usb/core/generic.c index 9a34ccb0a1c0..69ecd3c92311 100644 --- a/drivers/usb/core/generic.c +++ b/drivers/usb/core/generic.c | |||
@@ -105,8 +105,10 @@ int usb_choose_configuration(struct usb_device *udev) | |||
105 | /* When the first config's first interface is one of Microsoft's | 105 | /* When the first config's first interface is one of Microsoft's |
106 | * pet nonstandard Ethernet-over-USB protocols, ignore it unless | 106 | * pet nonstandard Ethernet-over-USB protocols, ignore it unless |
107 | * this kernel has enabled the necessary host side driver. | 107 | * this kernel has enabled the necessary host side driver. |
108 | * But: Don't ignore it if it's the only config. | ||
108 | */ | 109 | */ |
109 | if (i == 0 && desc && (is_rndis(desc) || is_activesync(desc))) { | 110 | if (i == 0 && num_configs > 1 && desc && |
111 | (is_rndis(desc) || is_activesync(desc))) { | ||
110 | #if !defined(CONFIG_USB_NET_RNDIS_HOST) && !defined(CONFIG_USB_NET_RNDIS_HOST_MODULE) | 112 | #if !defined(CONFIG_USB_NET_RNDIS_HOST) && !defined(CONFIG_USB_NET_RNDIS_HOST_MODULE) |
111 | continue; | 113 | continue; |
112 | #else | 114 | #else |
diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c index 1cf2d1e79a5c..c3f98543caaf 100644 --- a/drivers/usb/core/hcd-pci.c +++ b/drivers/usb/core/hcd-pci.c | |||
@@ -66,10 +66,7 @@ static void companion_common(struct pci_dev *pdev, struct usb_hcd *hcd, | |||
66 | * vice versa. | 66 | * vice versa. |
67 | */ | 67 | */ |
68 | companion = NULL; | 68 | companion = NULL; |
69 | for (;;) { | 69 | for_each_pci_dev(companion) { |
70 | companion = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, companion); | ||
71 | if (!companion) | ||
72 | break; | ||
73 | if (companion->bus != pdev->bus || | 70 | if (companion->bus != pdev->bus || |
74 | PCI_SLOT(companion->devfn) != slot) | 71 | PCI_SLOT(companion->devfn) != slot) |
75 | continue; | 72 | continue; |
@@ -250,6 +247,9 @@ int usb_hcd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) | |||
250 | if (retval != 0) | 247 | if (retval != 0) |
251 | goto err4; | 248 | goto err4; |
252 | set_hs_companion(dev, hcd); | 249 | set_hs_companion(dev, hcd); |
250 | |||
251 | if (pci_dev_run_wake(dev)) | ||
252 | pm_runtime_put_noidle(&dev->dev); | ||
253 | return retval; | 253 | return retval; |
254 | 254 | ||
255 | err4: | 255 | err4: |
@@ -292,6 +292,17 @@ void usb_hcd_pci_remove(struct pci_dev *dev) | |||
292 | if (!hcd) | 292 | if (!hcd) |
293 | return; | 293 | return; |
294 | 294 | ||
295 | if (pci_dev_run_wake(dev)) | ||
296 | pm_runtime_get_noresume(&dev->dev); | ||
297 | |||
298 | /* Fake an interrupt request in order to give the driver a chance | ||
299 | * to test whether the controller hardware has been removed (e.g., | ||
300 | * cardbus physical eject). | ||
301 | */ | ||
302 | local_irq_disable(); | ||
303 | usb_hcd_irq(0, hcd); | ||
304 | local_irq_enable(); | ||
305 | |||
295 | usb_remove_hcd(hcd); | 306 | usb_remove_hcd(hcd); |
296 | if (hcd->driver->flags & HCD_MEMORY) { | 307 | if (hcd->driver->flags & HCD_MEMORY) { |
297 | iounmap(hcd->regs); | 308 | iounmap(hcd->regs); |
@@ -317,12 +328,34 @@ void usb_hcd_pci_shutdown(struct pci_dev *dev) | |||
317 | if (!hcd) | 328 | if (!hcd) |
318 | return; | 329 | return; |
319 | 330 | ||
320 | if (hcd->driver->shutdown) | 331 | if (test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags) && |
332 | hcd->driver->shutdown) | ||
321 | hcd->driver->shutdown(hcd); | 333 | hcd->driver->shutdown(hcd); |
322 | } | 334 | } |
323 | EXPORT_SYMBOL_GPL(usb_hcd_pci_shutdown); | 335 | EXPORT_SYMBOL_GPL(usb_hcd_pci_shutdown); |
324 | 336 | ||
325 | #ifdef CONFIG_PM_SLEEP | 337 | #ifdef CONFIG_PM_OPS |
338 | |||
339 | #ifdef CONFIG_PPC_PMAC | ||
340 | static void powermac_set_asic(struct pci_dev *pci_dev, int enable) | ||
341 | { | ||
342 | /* Enanble or disable ASIC clocks for USB */ | ||
343 | if (machine_is(powermac)) { | ||
344 | struct device_node *of_node; | ||
345 | |||
346 | of_node = pci_device_to_OF_node(pci_dev); | ||
347 | if (of_node) | ||
348 | pmac_call_feature(PMAC_FTR_USB_ENABLE, | ||
349 | of_node, 0, enable); | ||
350 | } | ||
351 | } | ||
352 | |||
353 | #else | ||
354 | |||
355 | static inline void powermac_set_asic(struct pci_dev *pci_dev, int enable) | ||
356 | {} | ||
357 | |||
358 | #endif /* CONFIG_PPC_PMAC */ | ||
326 | 359 | ||
327 | static int check_root_hub_suspended(struct device *dev) | 360 | static int check_root_hub_suspended(struct device *dev) |
328 | { | 361 | { |
@@ -337,7 +370,7 @@ static int check_root_hub_suspended(struct device *dev) | |||
337 | return 0; | 370 | return 0; |
338 | } | 371 | } |
339 | 372 | ||
340 | static int hcd_pci_suspend(struct device *dev) | 373 | static int suspend_common(struct device *dev, bool do_wakeup) |
341 | { | 374 | { |
342 | struct pci_dev *pci_dev = to_pci_dev(dev); | 375 | struct pci_dev *pci_dev = to_pci_dev(dev); |
343 | struct usb_hcd *hcd = pci_get_drvdata(pci_dev); | 376 | struct usb_hcd *hcd = pci_get_drvdata(pci_dev); |
@@ -352,13 +385,21 @@ static int hcd_pci_suspend(struct device *dev) | |||
352 | if (retval) | 385 | if (retval) |
353 | return retval; | 386 | return retval; |
354 | 387 | ||
355 | /* We might already be suspended (runtime PM -- not yet written) */ | ||
356 | if (pci_dev->current_state != PCI_D0) | ||
357 | return retval; | ||
358 | |||
359 | if (hcd->driver->pci_suspend) { | 388 | if (hcd->driver->pci_suspend) { |
360 | retval = hcd->driver->pci_suspend(hcd); | 389 | /* Optimization: Don't suspend if a root-hub wakeup is |
390 | * pending and it would cause the HCD to wake up anyway. | ||
391 | */ | ||
392 | if (do_wakeup && HCD_WAKEUP_PENDING(hcd)) | ||
393 | return -EBUSY; | ||
394 | retval = hcd->driver->pci_suspend(hcd, do_wakeup); | ||
361 | suspend_report_result(hcd->driver->pci_suspend, retval); | 395 | suspend_report_result(hcd->driver->pci_suspend, retval); |
396 | |||
397 | /* Check again in case wakeup raced with pci_suspend */ | ||
398 | if (retval == 0 && do_wakeup && HCD_WAKEUP_PENDING(hcd)) { | ||
399 | if (hcd->driver->pci_resume) | ||
400 | hcd->driver->pci_resume(hcd, false); | ||
401 | retval = -EBUSY; | ||
402 | } | ||
362 | if (retval) | 403 | if (retval) |
363 | return retval; | 404 | return retval; |
364 | } | 405 | } |
@@ -374,6 +415,48 @@ static int hcd_pci_suspend(struct device *dev) | |||
374 | return retval; | 415 | return retval; |
375 | } | 416 | } |
376 | 417 | ||
418 | static int resume_common(struct device *dev, int event) | ||
419 | { | ||
420 | struct pci_dev *pci_dev = to_pci_dev(dev); | ||
421 | struct usb_hcd *hcd = pci_get_drvdata(pci_dev); | ||
422 | int retval; | ||
423 | |||
424 | if (hcd->state != HC_STATE_SUSPENDED) { | ||
425 | dev_dbg(dev, "can't resume, not suspended!\n"); | ||
426 | return 0; | ||
427 | } | ||
428 | |||
429 | retval = pci_enable_device(pci_dev); | ||
430 | if (retval < 0) { | ||
431 | dev_err(dev, "can't re-enable after resume, %d!\n", retval); | ||
432 | return retval; | ||
433 | } | ||
434 | |||
435 | pci_set_master(pci_dev); | ||
436 | |||
437 | clear_bit(HCD_FLAG_SAW_IRQ, &hcd->flags); | ||
438 | |||
439 | if (hcd->driver->pci_resume) { | ||
440 | if (event != PM_EVENT_AUTO_RESUME) | ||
441 | wait_for_companions(pci_dev, hcd); | ||
442 | |||
443 | retval = hcd->driver->pci_resume(hcd, | ||
444 | event == PM_EVENT_RESTORE); | ||
445 | if (retval) { | ||
446 | dev_err(dev, "PCI post-resume error %d!\n", retval); | ||
447 | usb_hc_died(hcd); | ||
448 | } | ||
449 | } | ||
450 | return retval; | ||
451 | } | ||
452 | |||
453 | #ifdef CONFIG_PM_SLEEP | ||
454 | |||
455 | static int hcd_pci_suspend(struct device *dev) | ||
456 | { | ||
457 | return suspend_common(dev, device_may_wakeup(dev)); | ||
458 | } | ||
459 | |||
377 | static int hcd_pci_suspend_noirq(struct device *dev) | 460 | static int hcd_pci_suspend_noirq(struct device *dev) |
378 | { | 461 | { |
379 | struct pci_dev *pci_dev = to_pci_dev(dev); | 462 | struct pci_dev *pci_dev = to_pci_dev(dev); |
@@ -408,16 +491,7 @@ static int hcd_pci_suspend_noirq(struct device *dev) | |||
408 | return retval; | 491 | return retval; |
409 | } | 492 | } |
410 | 493 | ||
411 | #ifdef CONFIG_PPC_PMAC | 494 | powermac_set_asic(pci_dev, 0); |
412 | /* Disable ASIC clocks for USB */ | ||
413 | if (machine_is(powermac)) { | ||
414 | struct device_node *of_node; | ||
415 | |||
416 | of_node = pci_device_to_OF_node(pci_dev); | ||
417 | if (of_node) | ||
418 | pmac_call_feature(PMAC_FTR_USB_ENABLE, of_node, 0, 0); | ||
419 | } | ||
420 | #endif | ||
421 | return retval; | 495 | return retval; |
422 | } | 496 | } |
423 | 497 | ||
@@ -425,69 +499,63 @@ static int hcd_pci_resume_noirq(struct device *dev) | |||
425 | { | 499 | { |
426 | struct pci_dev *pci_dev = to_pci_dev(dev); | 500 | struct pci_dev *pci_dev = to_pci_dev(dev); |
427 | 501 | ||
428 | #ifdef CONFIG_PPC_PMAC | 502 | powermac_set_asic(pci_dev, 1); |
429 | /* Reenable ASIC clocks for USB */ | ||
430 | if (machine_is(powermac)) { | ||
431 | struct device_node *of_node; | ||
432 | |||
433 | of_node = pci_device_to_OF_node(pci_dev); | ||
434 | if (of_node) | ||
435 | pmac_call_feature(PMAC_FTR_USB_ENABLE, | ||
436 | of_node, 0, 1); | ||
437 | } | ||
438 | #endif | ||
439 | 503 | ||
440 | /* Go back to D0 and disable remote wakeup */ | 504 | /* Go back to D0 and disable remote wakeup */ |
441 | pci_back_from_sleep(pci_dev); | 505 | pci_back_from_sleep(pci_dev); |
442 | return 0; | 506 | return 0; |
443 | } | 507 | } |
444 | 508 | ||
445 | static int resume_common(struct device *dev, bool hibernated) | 509 | static int hcd_pci_resume(struct device *dev) |
446 | { | 510 | { |
447 | struct pci_dev *pci_dev = to_pci_dev(dev); | 511 | return resume_common(dev, PM_EVENT_RESUME); |
448 | struct usb_hcd *hcd = pci_get_drvdata(pci_dev); | 512 | } |
449 | int retval; | ||
450 | 513 | ||
451 | if (hcd->state != HC_STATE_SUSPENDED) { | 514 | static int hcd_pci_restore(struct device *dev) |
452 | dev_dbg(dev, "can't resume, not suspended!\n"); | 515 | { |
453 | return 0; | 516 | return resume_common(dev, PM_EVENT_RESTORE); |
454 | } | 517 | } |
455 | 518 | ||
456 | retval = pci_enable_device(pci_dev); | 519 | #else |
457 | if (retval < 0) { | ||
458 | dev_err(dev, "can't re-enable after resume, %d!\n", retval); | ||
459 | return retval; | ||
460 | } | ||
461 | 520 | ||
462 | pci_set_master(pci_dev); | 521 | #define hcd_pci_suspend NULL |
522 | #define hcd_pci_suspend_noirq NULL | ||
523 | #define hcd_pci_resume_noirq NULL | ||
524 | #define hcd_pci_resume NULL | ||
525 | #define hcd_pci_restore NULL | ||
463 | 526 | ||
464 | clear_bit(HCD_FLAG_SAW_IRQ, &hcd->flags); | 527 | #endif /* CONFIG_PM_SLEEP */ |
465 | 528 | ||
466 | if (hcd->driver->pci_resume) { | 529 | #ifdef CONFIG_PM_RUNTIME |
467 | /* This call should be made only during system resume, | ||
468 | * not during runtime resume. | ||
469 | */ | ||
470 | wait_for_companions(pci_dev, hcd); | ||
471 | 530 | ||
472 | retval = hcd->driver->pci_resume(hcd, hibernated); | 531 | static int hcd_pci_runtime_suspend(struct device *dev) |
473 | if (retval) { | 532 | { |
474 | dev_err(dev, "PCI post-resume error %d!\n", retval); | 533 | int retval; |
475 | usb_hc_died(hcd); | 534 | |
476 | } | 535 | retval = suspend_common(dev, true); |
477 | } | 536 | if (retval == 0) |
537 | powermac_set_asic(to_pci_dev(dev), 0); | ||
538 | dev_dbg(dev, "hcd_pci_runtime_suspend: %d\n", retval); | ||
478 | return retval; | 539 | return retval; |
479 | } | 540 | } |
480 | 541 | ||
481 | static int hcd_pci_resume(struct device *dev) | 542 | static int hcd_pci_runtime_resume(struct device *dev) |
482 | { | 543 | { |
483 | return resume_common(dev, false); | 544 | int retval; |
484 | } | ||
485 | 545 | ||
486 | static int hcd_pci_restore(struct device *dev) | 546 | powermac_set_asic(to_pci_dev(dev), 1); |
487 | { | 547 | retval = resume_common(dev, PM_EVENT_AUTO_RESUME); |
488 | return resume_common(dev, true); | 548 | dev_dbg(dev, "hcd_pci_runtime_resume: %d\n", retval); |
549 | return retval; | ||
489 | } | 550 | } |
490 | 551 | ||
552 | #else | ||
553 | |||
554 | #define hcd_pci_runtime_suspend NULL | ||
555 | #define hcd_pci_runtime_resume NULL | ||
556 | |||
557 | #endif /* CONFIG_PM_RUNTIME */ | ||
558 | |||
491 | const struct dev_pm_ops usb_hcd_pci_pm_ops = { | 559 | const struct dev_pm_ops usb_hcd_pci_pm_ops = { |
492 | .suspend = hcd_pci_suspend, | 560 | .suspend = hcd_pci_suspend, |
493 | .suspend_noirq = hcd_pci_suspend_noirq, | 561 | .suspend_noirq = hcd_pci_suspend_noirq, |
@@ -501,7 +569,9 @@ const struct dev_pm_ops usb_hcd_pci_pm_ops = { | |||
501 | .poweroff_noirq = hcd_pci_suspend_noirq, | 569 | .poweroff_noirq = hcd_pci_suspend_noirq, |
502 | .restore_noirq = hcd_pci_resume_noirq, | 570 | .restore_noirq = hcd_pci_resume_noirq, |
503 | .restore = hcd_pci_restore, | 571 | .restore = hcd_pci_restore, |
572 | .runtime_suspend = hcd_pci_runtime_suspend, | ||
573 | .runtime_resume = hcd_pci_runtime_resume, | ||
504 | }; | 574 | }; |
505 | EXPORT_SYMBOL_GPL(usb_hcd_pci_pm_ops); | 575 | EXPORT_SYMBOL_GPL(usb_hcd_pci_pm_ops); |
506 | 576 | ||
507 | #endif /* CONFIG_PM_SLEEP */ | 577 | #endif /* CONFIG_PM_OPS */ |
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index 12742f152f43..5cca00a6d09d 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c | |||
@@ -667,7 +667,7 @@ void usb_hcd_poll_rh_status(struct usb_hcd *hcd) | |||
667 | unsigned long flags; | 667 | unsigned long flags; |
668 | char buffer[6]; /* Any root hubs with > 31 ports? */ | 668 | char buffer[6]; /* Any root hubs with > 31 ports? */ |
669 | 669 | ||
670 | if (unlikely(!hcd->rh_registered)) | 670 | if (unlikely(!hcd->rh_pollable)) |
671 | return; | 671 | return; |
672 | if (!hcd->uses_new_polling && !hcd->status_urb) | 672 | if (!hcd->uses_new_polling && !hcd->status_urb) |
673 | return; | 673 | return; |
@@ -679,7 +679,7 @@ void usb_hcd_poll_rh_status(struct usb_hcd *hcd) | |||
679 | spin_lock_irqsave(&hcd_root_hub_lock, flags); | 679 | spin_lock_irqsave(&hcd_root_hub_lock, flags); |
680 | urb = hcd->status_urb; | 680 | urb = hcd->status_urb; |
681 | if (urb) { | 681 | if (urb) { |
682 | hcd->poll_pending = 0; | 682 | clear_bit(HCD_FLAG_POLL_PENDING, &hcd->flags); |
683 | hcd->status_urb = NULL; | 683 | hcd->status_urb = NULL; |
684 | urb->actual_length = length; | 684 | urb->actual_length = length; |
685 | memcpy(urb->transfer_buffer, buffer, length); | 685 | memcpy(urb->transfer_buffer, buffer, length); |
@@ -690,7 +690,7 @@ void usb_hcd_poll_rh_status(struct usb_hcd *hcd) | |||
690 | spin_lock(&hcd_root_hub_lock); | 690 | spin_lock(&hcd_root_hub_lock); |
691 | } else { | 691 | } else { |
692 | length = 0; | 692 | length = 0; |
693 | hcd->poll_pending = 1; | 693 | set_bit(HCD_FLAG_POLL_PENDING, &hcd->flags); |
694 | } | 694 | } |
695 | spin_unlock_irqrestore(&hcd_root_hub_lock, flags); | 695 | spin_unlock_irqrestore(&hcd_root_hub_lock, flags); |
696 | } | 696 | } |
@@ -699,7 +699,7 @@ void usb_hcd_poll_rh_status(struct usb_hcd *hcd) | |||
699 | * exceed that limit if HZ is 100. The math is more clunky than | 699 | * exceed that limit if HZ is 100. The math is more clunky than |
700 | * maybe expected, this is to make sure that all timers for USB devices | 700 | * maybe expected, this is to make sure that all timers for USB devices |
701 | * fire at the same time to give the CPU a break inbetween */ | 701 | * fire at the same time to give the CPU a break inbetween */ |
702 | if (hcd->uses_new_polling ? hcd->poll_rh : | 702 | if (hcd->uses_new_polling ? HCD_POLL_RH(hcd) : |
703 | (length == 0 && hcd->status_urb != NULL)) | 703 | (length == 0 && hcd->status_urb != NULL)) |
704 | mod_timer (&hcd->rh_timer, (jiffies/(HZ/4) + 1) * (HZ/4)); | 704 | mod_timer (&hcd->rh_timer, (jiffies/(HZ/4) + 1) * (HZ/4)); |
705 | } | 705 | } |
@@ -736,7 +736,7 @@ static int rh_queue_status (struct usb_hcd *hcd, struct urb *urb) | |||
736 | mod_timer(&hcd->rh_timer, (jiffies/(HZ/4) + 1) * (HZ/4)); | 736 | mod_timer(&hcd->rh_timer, (jiffies/(HZ/4) + 1) * (HZ/4)); |
737 | 737 | ||
738 | /* If a status change has already occurred, report it ASAP */ | 738 | /* If a status change has already occurred, report it ASAP */ |
739 | else if (hcd->poll_pending) | 739 | else if (HCD_POLL_PENDING(hcd)) |
740 | mod_timer(&hcd->rh_timer, jiffies); | 740 | mod_timer(&hcd->rh_timer, jiffies); |
741 | retval = 0; | 741 | retval = 0; |
742 | done: | 742 | done: |
@@ -1150,8 +1150,7 @@ int usb_hcd_check_unlink_urb(struct usb_hcd *hcd, struct urb *urb, | |||
1150 | * finish unlinking the initial failed usb_set_address() | 1150 | * finish unlinking the initial failed usb_set_address() |
1151 | * or device descriptor fetch. | 1151 | * or device descriptor fetch. |
1152 | */ | 1152 | */ |
1153 | if (!test_bit(HCD_FLAG_SAW_IRQ, &hcd->flags) && | 1153 | if (!HCD_SAW_IRQ(hcd) && !is_root_hub(urb->dev)) { |
1154 | !is_root_hub(urb->dev)) { | ||
1155 | dev_warn(hcd->self.controller, "Unlink after no-IRQ? " | 1154 | dev_warn(hcd->self.controller, "Unlink after no-IRQ? " |
1156 | "Controller is probably using the wrong IRQ.\n"); | 1155 | "Controller is probably using the wrong IRQ.\n"); |
1157 | set_bit(HCD_FLAG_SAW_IRQ, &hcd->flags); | 1156 | set_bit(HCD_FLAG_SAW_IRQ, &hcd->flags); |
@@ -1219,6 +1218,11 @@ static int hcd_alloc_coherent(struct usb_bus *bus, | |||
1219 | { | 1218 | { |
1220 | unsigned char *vaddr; | 1219 | unsigned char *vaddr; |
1221 | 1220 | ||
1221 | if (*vaddr_handle == NULL) { | ||
1222 | WARN_ON_ONCE(1); | ||
1223 | return -EFAULT; | ||
1224 | } | ||
1225 | |||
1222 | vaddr = hcd_buffer_alloc(bus, size + sizeof(vaddr), | 1226 | vaddr = hcd_buffer_alloc(bus, size + sizeof(vaddr), |
1223 | mem_flags, dma_handle); | 1227 | mem_flags, dma_handle); |
1224 | if (!vaddr) | 1228 | if (!vaddr) |
@@ -1941,6 +1945,7 @@ int hcd_bus_resume(struct usb_device *rhdev, pm_message_t msg) | |||
1941 | 1945 | ||
1942 | dev_dbg(&rhdev->dev, "usb %s%s\n", | 1946 | dev_dbg(&rhdev->dev, "usb %s%s\n", |
1943 | (msg.event & PM_EVENT_AUTO ? "auto-" : ""), "resume"); | 1947 | (msg.event & PM_EVENT_AUTO ? "auto-" : ""), "resume"); |
1948 | clear_bit(HCD_FLAG_WAKEUP_PENDING, &hcd->flags); | ||
1944 | if (!hcd->driver->bus_resume) | 1949 | if (!hcd->driver->bus_resume) |
1945 | return -ENOENT; | 1950 | return -ENOENT; |
1946 | if (hcd->state == HC_STATE_RUNNING) | 1951 | if (hcd->state == HC_STATE_RUNNING) |
@@ -1994,8 +1999,10 @@ void usb_hcd_resume_root_hub (struct usb_hcd *hcd) | |||
1994 | unsigned long flags; | 1999 | unsigned long flags; |
1995 | 2000 | ||
1996 | spin_lock_irqsave (&hcd_root_hub_lock, flags); | 2001 | spin_lock_irqsave (&hcd_root_hub_lock, flags); |
1997 | if (hcd->rh_registered) | 2002 | if (hcd->rh_registered) { |
2003 | set_bit(HCD_FLAG_WAKEUP_PENDING, &hcd->flags); | ||
1998 | queue_work(pm_wq, &hcd->wakeup_work); | 2004 | queue_work(pm_wq, &hcd->wakeup_work); |
2005 | } | ||
1999 | spin_unlock_irqrestore (&hcd_root_hub_lock, flags); | 2006 | spin_unlock_irqrestore (&hcd_root_hub_lock, flags); |
2000 | } | 2007 | } |
2001 | EXPORT_SYMBOL_GPL(usb_hcd_resume_root_hub); | 2008 | EXPORT_SYMBOL_GPL(usb_hcd_resume_root_hub); |
@@ -2063,8 +2070,7 @@ irqreturn_t usb_hcd_irq (int irq, void *__hcd) | |||
2063 | */ | 2070 | */ |
2064 | local_irq_save(flags); | 2071 | local_irq_save(flags); |
2065 | 2072 | ||
2066 | if (unlikely(hcd->state == HC_STATE_HALT || | 2073 | if (unlikely(hcd->state == HC_STATE_HALT || !HCD_HW_ACCESSIBLE(hcd))) { |
2067 | !test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags))) { | ||
2068 | rc = IRQ_NONE; | 2074 | rc = IRQ_NONE; |
2069 | } else if (hcd->driver->irq(hcd) == IRQ_NONE) { | 2075 | } else if (hcd->driver->irq(hcd) == IRQ_NONE) { |
2070 | rc = IRQ_NONE; | 2076 | rc = IRQ_NONE; |
@@ -2079,6 +2085,7 @@ irqreturn_t usb_hcd_irq (int irq, void *__hcd) | |||
2079 | local_irq_restore(flags); | 2085 | local_irq_restore(flags); |
2080 | return rc; | 2086 | return rc; |
2081 | } | 2087 | } |
2088 | EXPORT_SYMBOL_GPL(usb_hcd_irq); | ||
2082 | 2089 | ||
2083 | /*-------------------------------------------------------------------------*/ | 2090 | /*-------------------------------------------------------------------------*/ |
2084 | 2091 | ||
@@ -2098,7 +2105,7 @@ void usb_hc_died (struct usb_hcd *hcd) | |||
2098 | 2105 | ||
2099 | spin_lock_irqsave (&hcd_root_hub_lock, flags); | 2106 | spin_lock_irqsave (&hcd_root_hub_lock, flags); |
2100 | if (hcd->rh_registered) { | 2107 | if (hcd->rh_registered) { |
2101 | hcd->poll_rh = 0; | 2108 | clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); |
2102 | 2109 | ||
2103 | /* make khubd clean up old urbs and devices */ | 2110 | /* make khubd clean up old urbs and devices */ |
2104 | usb_set_device_state (hcd->self.root_hub, | 2111 | usb_set_device_state (hcd->self.root_hub, |
@@ -2217,6 +2224,7 @@ int usb_add_hcd(struct usb_hcd *hcd, | |||
2217 | retval = -ENOMEM; | 2224 | retval = -ENOMEM; |
2218 | goto err_allocate_root_hub; | 2225 | goto err_allocate_root_hub; |
2219 | } | 2226 | } |
2227 | hcd->self.root_hub = rhdev; | ||
2220 | 2228 | ||
2221 | switch (hcd->driver->flags & HCD_MASK) { | 2229 | switch (hcd->driver->flags & HCD_MASK) { |
2222 | case HCD_USB11: | 2230 | case HCD_USB11: |
@@ -2229,9 +2237,8 @@ int usb_add_hcd(struct usb_hcd *hcd, | |||
2229 | rhdev->speed = USB_SPEED_SUPER; | 2237 | rhdev->speed = USB_SPEED_SUPER; |
2230 | break; | 2238 | break; |
2231 | default: | 2239 | default: |
2232 | goto err_allocate_root_hub; | 2240 | goto err_set_rh_speed; |
2233 | } | 2241 | } |
2234 | hcd->self.root_hub = rhdev; | ||
2235 | 2242 | ||
2236 | /* wakeup flag init defaults to "everything works" for root hubs, | 2243 | /* wakeup flag init defaults to "everything works" for root hubs, |
2237 | * but drivers can override it in reset() if needed, along with | 2244 | * but drivers can override it in reset() if needed, along with |
@@ -2246,6 +2253,7 @@ int usb_add_hcd(struct usb_hcd *hcd, | |||
2246 | dev_err(hcd->self.controller, "can't setup\n"); | 2253 | dev_err(hcd->self.controller, "can't setup\n"); |
2247 | goto err_hcd_driver_setup; | 2254 | goto err_hcd_driver_setup; |
2248 | } | 2255 | } |
2256 | hcd->rh_pollable = 1; | ||
2249 | 2257 | ||
2250 | /* NOTE: root hub and controller capabilities may not be the same */ | 2258 | /* NOTE: root hub and controller capabilities may not be the same */ |
2251 | if (device_can_wakeup(hcd->self.controller) | 2259 | if (device_can_wakeup(hcd->self.controller) |
@@ -2300,23 +2308,38 @@ int usb_add_hcd(struct usb_hcd *hcd, | |||
2300 | retval); | 2308 | retval); |
2301 | goto error_create_attr_group; | 2309 | goto error_create_attr_group; |
2302 | } | 2310 | } |
2303 | if (hcd->uses_new_polling && hcd->poll_rh) | 2311 | if (hcd->uses_new_polling && HCD_POLL_RH(hcd)) |
2304 | usb_hcd_poll_rh_status(hcd); | 2312 | usb_hcd_poll_rh_status(hcd); |
2305 | return retval; | 2313 | return retval; |
2306 | 2314 | ||
2307 | error_create_attr_group: | 2315 | error_create_attr_group: |
2316 | if (HC_IS_RUNNING(hcd->state)) | ||
2317 | hcd->state = HC_STATE_QUIESCING; | ||
2318 | spin_lock_irq(&hcd_root_hub_lock); | ||
2319 | hcd->rh_registered = 0; | ||
2320 | spin_unlock_irq(&hcd_root_hub_lock); | ||
2321 | |||
2322 | #ifdef CONFIG_USB_SUSPEND | ||
2323 | cancel_work_sync(&hcd->wakeup_work); | ||
2324 | #endif | ||
2308 | mutex_lock(&usb_bus_list_lock); | 2325 | mutex_lock(&usb_bus_list_lock); |
2309 | usb_disconnect(&hcd->self.root_hub); | 2326 | usb_disconnect(&rhdev); /* Sets rhdev to NULL */ |
2310 | mutex_unlock(&usb_bus_list_lock); | 2327 | mutex_unlock(&usb_bus_list_lock); |
2311 | err_register_root_hub: | 2328 | err_register_root_hub: |
2329 | hcd->rh_pollable = 0; | ||
2330 | clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); | ||
2331 | del_timer_sync(&hcd->rh_timer); | ||
2312 | hcd->driver->stop(hcd); | 2332 | hcd->driver->stop(hcd); |
2333 | hcd->state = HC_STATE_HALT; | ||
2334 | clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); | ||
2335 | del_timer_sync(&hcd->rh_timer); | ||
2313 | err_hcd_driver_start: | 2336 | err_hcd_driver_start: |
2314 | if (hcd->irq >= 0) | 2337 | if (hcd->irq >= 0) |
2315 | free_irq(irqnum, hcd); | 2338 | free_irq(irqnum, hcd); |
2316 | err_request_irq: | 2339 | err_request_irq: |
2317 | err_hcd_driver_setup: | 2340 | err_hcd_driver_setup: |
2318 | hcd->self.root_hub = NULL; | 2341 | err_set_rh_speed: |
2319 | usb_put_dev(rhdev); | 2342 | usb_put_dev(hcd->self.root_hub); |
2320 | err_allocate_root_hub: | 2343 | err_allocate_root_hub: |
2321 | usb_deregister_bus(&hcd->self); | 2344 | usb_deregister_bus(&hcd->self); |
2322 | err_register_bus: | 2345 | err_register_bus: |
@@ -2335,8 +2358,13 @@ EXPORT_SYMBOL_GPL(usb_add_hcd); | |||
2335 | */ | 2358 | */ |
2336 | void usb_remove_hcd(struct usb_hcd *hcd) | 2359 | void usb_remove_hcd(struct usb_hcd *hcd) |
2337 | { | 2360 | { |
2361 | struct usb_device *rhdev = hcd->self.root_hub; | ||
2362 | |||
2338 | dev_info(hcd->self.controller, "remove, state %x\n", hcd->state); | 2363 | dev_info(hcd->self.controller, "remove, state %x\n", hcd->state); |
2339 | 2364 | ||
2365 | usb_get_dev(rhdev); | ||
2366 | sysfs_remove_group(&rhdev->dev.kobj, &usb_bus_attr_group); | ||
2367 | |||
2340 | if (HC_IS_RUNNING (hcd->state)) | 2368 | if (HC_IS_RUNNING (hcd->state)) |
2341 | hcd->state = HC_STATE_QUIESCING; | 2369 | hcd->state = HC_STATE_QUIESCING; |
2342 | 2370 | ||
@@ -2349,19 +2377,30 @@ void usb_remove_hcd(struct usb_hcd *hcd) | |||
2349 | cancel_work_sync(&hcd->wakeup_work); | 2377 | cancel_work_sync(&hcd->wakeup_work); |
2350 | #endif | 2378 | #endif |
2351 | 2379 | ||
2352 | sysfs_remove_group(&hcd->self.root_hub->dev.kobj, &usb_bus_attr_group); | ||
2353 | mutex_lock(&usb_bus_list_lock); | 2380 | mutex_lock(&usb_bus_list_lock); |
2354 | usb_disconnect(&hcd->self.root_hub); | 2381 | usb_disconnect(&rhdev); /* Sets rhdev to NULL */ |
2355 | mutex_unlock(&usb_bus_list_lock); | 2382 | mutex_unlock(&usb_bus_list_lock); |
2356 | 2383 | ||
2384 | /* Prevent any more root-hub status calls from the timer. | ||
2385 | * The HCD might still restart the timer (if a port status change | ||
2386 | * interrupt occurs), but usb_hcd_poll_rh_status() won't invoke | ||
2387 | * the hub_status_data() callback. | ||
2388 | */ | ||
2389 | hcd->rh_pollable = 0; | ||
2390 | clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); | ||
2391 | del_timer_sync(&hcd->rh_timer); | ||
2392 | |||
2357 | hcd->driver->stop(hcd); | 2393 | hcd->driver->stop(hcd); |
2358 | hcd->state = HC_STATE_HALT; | 2394 | hcd->state = HC_STATE_HALT; |
2359 | 2395 | ||
2360 | hcd->poll_rh = 0; | 2396 | /* In case the HCD restarted the timer, stop it again. */ |
2397 | clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); | ||
2361 | del_timer_sync(&hcd->rh_timer); | 2398 | del_timer_sync(&hcd->rh_timer); |
2362 | 2399 | ||
2363 | if (hcd->irq >= 0) | 2400 | if (hcd->irq >= 0) |
2364 | free_irq(hcd->irq, hcd); | 2401 | free_irq(hcd->irq, hcd); |
2402 | |||
2403 | usb_put_dev(hcd->self.root_hub); | ||
2365 | usb_deregister_bus(&hcd->self); | 2404 | usb_deregister_bus(&hcd->self); |
2366 | hcd_buffer_destroy(hcd); | 2405 | hcd_buffer_destroy(hcd); |
2367 | } | 2406 | } |
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 70cccc75a362..84c1897188d2 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/usb.h> | 20 | #include <linux/usb.h> |
21 | #include <linux/usbdevice_fs.h> | 21 | #include <linux/usbdevice_fs.h> |
22 | #include <linux/usb/hcd.h> | 22 | #include <linux/usb/hcd.h> |
23 | #include <linux/usb/quirks.h> | ||
23 | #include <linux/kthread.h> | 24 | #include <linux/kthread.h> |
24 | #include <linux/mutex.h> | 25 | #include <linux/mutex.h> |
25 | #include <linux/freezer.h> | 26 | #include <linux/freezer.h> |
@@ -1294,6 +1295,7 @@ descriptor_error: | |||
1294 | return -ENODEV; | 1295 | return -ENODEV; |
1295 | } | 1296 | } |
1296 | 1297 | ||
1298 | /* No BKL needed */ | ||
1297 | static int | 1299 | static int |
1298 | hub_ioctl(struct usb_interface *intf, unsigned int code, void *user_data) | 1300 | hub_ioctl(struct usb_interface *intf, unsigned int code, void *user_data) |
1299 | { | 1301 | { |
@@ -1801,7 +1803,6 @@ int usb_new_device(struct usb_device *udev) | |||
1801 | pm_runtime_set_active(&udev->dev); | 1803 | pm_runtime_set_active(&udev->dev); |
1802 | pm_runtime_enable(&udev->dev); | 1804 | pm_runtime_enable(&udev->dev); |
1803 | 1805 | ||
1804 | usb_detect_quirks(udev); | ||
1805 | err = usb_enumerate_device(udev); /* Read descriptors */ | 1806 | err = usb_enumerate_device(udev); /* Read descriptors */ |
1806 | if (err < 0) | 1807 | if (err < 0) |
1807 | goto fail; | 1808 | goto fail; |
@@ -2880,7 +2881,9 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1, | |||
2880 | } | 2881 | } |
2881 | 2882 | ||
2882 | retval = 0; | 2883 | retval = 0; |
2883 | 2884 | /* notify HCD that we have a device connected and addressed */ | |
2885 | if (hcd->driver->update_device) | ||
2886 | hcd->driver->update_device(hcd, udev); | ||
2884 | fail: | 2887 | fail: |
2885 | if (retval) { | 2888 | if (retval) { |
2886 | hub_port_disable(hub, port1, 0); | 2889 | hub_port_disable(hub, port1, 0); |
@@ -3111,6 +3114,10 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1, | |||
3111 | if (status < 0) | 3114 | if (status < 0) |
3112 | goto loop; | 3115 | goto loop; |
3113 | 3116 | ||
3117 | usb_detect_quirks(udev); | ||
3118 | if (udev->quirks & USB_QUIRK_DELAY_INIT) | ||
3119 | msleep(1000); | ||
3120 | |||
3114 | /* consecutive bus-powered hubs aren't reliable; they can | 3121 | /* consecutive bus-powered hubs aren't reliable; they can |
3115 | * violate the voltage drop budget. if the new child has | 3122 | * violate the voltage drop budget. if the new child has |
3116 | * a "powered" LED, users should notice we didn't enable it | 3123 | * a "powered" LED, users should notice we didn't enable it |
@@ -3463,7 +3470,7 @@ static struct usb_driver hub_driver = { | |||
3463 | .reset_resume = hub_reset_resume, | 3470 | .reset_resume = hub_reset_resume, |
3464 | .pre_reset = hub_pre_reset, | 3471 | .pre_reset = hub_pre_reset, |
3465 | .post_reset = hub_post_reset, | 3472 | .post_reset = hub_post_reset, |
3466 | .ioctl = hub_ioctl, | 3473 | .unlocked_ioctl = hub_ioctl, |
3467 | .id_table = hub_id_table, | 3474 | .id_table = hub_id_table, |
3468 | .supports_autosuspend = 1, | 3475 | .supports_autosuspend = 1, |
3469 | }; | 3476 | }; |
diff --git a/drivers/usb/core/inode.c b/drivers/usb/core/inode.c index 1a27618b67d6..095fa5366690 100644 --- a/drivers/usb/core/inode.c +++ b/drivers/usb/core/inode.c | |||
@@ -265,13 +265,9 @@ static int remount(struct super_block *sb, int *flags, char *data) | |||
265 | return -EINVAL; | 265 | return -EINVAL; |
266 | } | 266 | } |
267 | 267 | ||
268 | lock_kernel(); | ||
269 | |||
270 | if (usbfs_mount && usbfs_mount->mnt_sb) | 268 | if (usbfs_mount && usbfs_mount->mnt_sb) |
271 | update_sb(usbfs_mount->mnt_sb); | 269 | update_sb(usbfs_mount->mnt_sb); |
272 | 270 | ||
273 | unlock_kernel(); | ||
274 | |||
275 | return 0; | 271 | return 0; |
276 | } | 272 | } |
277 | 273 | ||
diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c index db99c084df92..25719da45e33 100644 --- a/drivers/usb/core/quirks.c +++ b/drivers/usb/core/quirks.c | |||
@@ -38,6 +38,9 @@ static const struct usb_device_id usb_quirk_list[] = { | |||
38 | /* Creative SB Audigy 2 NX */ | 38 | /* Creative SB Audigy 2 NX */ |
39 | { USB_DEVICE(0x041e, 0x3020), .driver_info = USB_QUIRK_RESET_RESUME }, | 39 | { USB_DEVICE(0x041e, 0x3020), .driver_info = USB_QUIRK_RESET_RESUME }, |
40 | 40 | ||
41 | /* Logitech Harmony 700-series */ | ||
42 | { USB_DEVICE(0x046d, 0xc122), .driver_info = USB_QUIRK_DELAY_INIT }, | ||
43 | |||
41 | /* Philips PSC805 audio device */ | 44 | /* Philips PSC805 audio device */ |
42 | { USB_DEVICE(0x0471, 0x0155), .driver_info = USB_QUIRK_RESET_RESUME }, | 45 | { USB_DEVICE(0x0471, 0x0155), .driver_info = USB_QUIRK_RESET_RESUME }, |
43 | 46 | ||
diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c index 7c0555548ac8..419e6b34e2fe 100644 --- a/drivers/usb/core/urb.c +++ b/drivers/usb/core/urb.c | |||
@@ -137,6 +137,16 @@ void usb_anchor_urb(struct urb *urb, struct usb_anchor *anchor) | |||
137 | } | 137 | } |
138 | EXPORT_SYMBOL_GPL(usb_anchor_urb); | 138 | EXPORT_SYMBOL_GPL(usb_anchor_urb); |
139 | 139 | ||
140 | /* Callers must hold anchor->lock */ | ||
141 | static void __usb_unanchor_urb(struct urb *urb, struct usb_anchor *anchor) | ||
142 | { | ||
143 | urb->anchor = NULL; | ||
144 | list_del(&urb->anchor_list); | ||
145 | usb_put_urb(urb); | ||
146 | if (list_empty(&anchor->urb_list)) | ||
147 | wake_up(&anchor->wait); | ||
148 | } | ||
149 | |||
140 | /** | 150 | /** |
141 | * usb_unanchor_urb - unanchors an URB | 151 | * usb_unanchor_urb - unanchors an URB |
142 | * @urb: pointer to the urb to anchor | 152 | * @urb: pointer to the urb to anchor |
@@ -156,17 +166,14 @@ void usb_unanchor_urb(struct urb *urb) | |||
156 | return; | 166 | return; |
157 | 167 | ||
158 | spin_lock_irqsave(&anchor->lock, flags); | 168 | spin_lock_irqsave(&anchor->lock, flags); |
159 | if (unlikely(anchor != urb->anchor)) { | 169 | /* |
160 | /* we've lost the race to another thread */ | 170 | * At this point, we could be competing with another thread which |
161 | spin_unlock_irqrestore(&anchor->lock, flags); | 171 | * has the same intention. To protect the urb from being unanchored |
162 | return; | 172 | * twice, only the winner of the race gets the job. |
163 | } | 173 | */ |
164 | urb->anchor = NULL; | 174 | if (likely(anchor == urb->anchor)) |
165 | list_del(&urb->anchor_list); | 175 | __usb_unanchor_urb(urb, anchor); |
166 | spin_unlock_irqrestore(&anchor->lock, flags); | 176 | spin_unlock_irqrestore(&anchor->lock, flags); |
167 | usb_put_urb(urb); | ||
168 | if (list_empty(&anchor->urb_list)) | ||
169 | wake_up(&anchor->wait); | ||
170 | } | 177 | } |
171 | EXPORT_SYMBOL_GPL(usb_unanchor_urb); | 178 | EXPORT_SYMBOL_GPL(usb_unanchor_urb); |
172 | 179 | ||
@@ -749,20 +756,11 @@ EXPORT_SYMBOL_GPL(usb_unpoison_anchored_urbs); | |||
749 | void usb_unlink_anchored_urbs(struct usb_anchor *anchor) | 756 | void usb_unlink_anchored_urbs(struct usb_anchor *anchor) |
750 | { | 757 | { |
751 | struct urb *victim; | 758 | struct urb *victim; |
752 | unsigned long flags; | ||
753 | 759 | ||
754 | spin_lock_irqsave(&anchor->lock, flags); | 760 | while ((victim = usb_get_from_anchor(anchor)) != NULL) { |
755 | while (!list_empty(&anchor->urb_list)) { | ||
756 | victim = list_entry(anchor->urb_list.prev, struct urb, | ||
757 | anchor_list); | ||
758 | usb_get_urb(victim); | ||
759 | spin_unlock_irqrestore(&anchor->lock, flags); | ||
760 | /* this will unanchor the URB */ | ||
761 | usb_unlink_urb(victim); | 761 | usb_unlink_urb(victim); |
762 | usb_put_urb(victim); | 762 | usb_put_urb(victim); |
763 | spin_lock_irqsave(&anchor->lock, flags); | ||
764 | } | 763 | } |
765 | spin_unlock_irqrestore(&anchor->lock, flags); | ||
766 | } | 764 | } |
767 | EXPORT_SYMBOL_GPL(usb_unlink_anchored_urbs); | 765 | EXPORT_SYMBOL_GPL(usb_unlink_anchored_urbs); |
768 | 766 | ||
@@ -799,12 +797,11 @@ struct urb *usb_get_from_anchor(struct usb_anchor *anchor) | |||
799 | victim = list_entry(anchor->urb_list.next, struct urb, | 797 | victim = list_entry(anchor->urb_list.next, struct urb, |
800 | anchor_list); | 798 | anchor_list); |
801 | usb_get_urb(victim); | 799 | usb_get_urb(victim); |
802 | spin_unlock_irqrestore(&anchor->lock, flags); | 800 | __usb_unanchor_urb(victim, anchor); |
803 | usb_unanchor_urb(victim); | ||
804 | } else { | 801 | } else { |
805 | spin_unlock_irqrestore(&anchor->lock, flags); | ||
806 | victim = NULL; | 802 | victim = NULL; |
807 | } | 803 | } |
804 | spin_unlock_irqrestore(&anchor->lock, flags); | ||
808 | 805 | ||
809 | return victim; | 806 | return victim; |
810 | } | 807 | } |
@@ -826,12 +823,7 @@ void usb_scuttle_anchored_urbs(struct usb_anchor *anchor) | |||
826 | while (!list_empty(&anchor->urb_list)) { | 823 | while (!list_empty(&anchor->urb_list)) { |
827 | victim = list_entry(anchor->urb_list.prev, struct urb, | 824 | victim = list_entry(anchor->urb_list.prev, struct urb, |
828 | anchor_list); | 825 | anchor_list); |
829 | usb_get_urb(victim); | 826 | __usb_unanchor_urb(victim, anchor); |
830 | spin_unlock_irqrestore(&anchor->lock, flags); | ||
831 | /* this may free the URB */ | ||
832 | usb_unanchor_urb(victim); | ||
833 | usb_put_urb(victim); | ||
834 | spin_lock_irqsave(&anchor->lock, flags); | ||
835 | } | 827 | } |
836 | spin_unlock_irqrestore(&anchor->lock, flags); | 828 | spin_unlock_irqrestore(&anchor->lock, flags); |
837 | } | 829 | } |
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index 5ae14f6c1e7a..fdd4130fbb7d 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c | |||
@@ -317,10 +317,6 @@ static const struct dev_pm_ops usb_device_pm_ops = { | |||
317 | .restore = usb_dev_restore, | 317 | .restore = usb_dev_restore, |
318 | }; | 318 | }; |
319 | 319 | ||
320 | #else | ||
321 | |||
322 | #define usb_device_pm_ops (*(struct dev_pm_ops *) NULL) | ||
323 | |||
324 | #endif /* CONFIG_PM */ | 320 | #endif /* CONFIG_PM */ |
325 | 321 | ||
326 | 322 | ||
@@ -338,7 +334,9 @@ struct device_type usb_device_type = { | |||
338 | .release = usb_release_dev, | 334 | .release = usb_release_dev, |
339 | .uevent = usb_dev_uevent, | 335 | .uevent = usb_dev_uevent, |
340 | .devnode = usb_devnode, | 336 | .devnode = usb_devnode, |
337 | #ifdef CONFIG_PM | ||
341 | .pm = &usb_device_pm_ops, | 338 | .pm = &usb_device_pm_ops, |
339 | #endif | ||
342 | }; | 340 | }; |
343 | 341 | ||
344 | 342 | ||
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index 591ae9fde199..cd27f9bde2c8 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig | |||
@@ -714,6 +714,7 @@ config USB_GADGETFS | |||
714 | config USB_FUNCTIONFS | 714 | config USB_FUNCTIONFS |
715 | tristate "Function Filesystem (EXPERIMENTAL)" | 715 | tristate "Function Filesystem (EXPERIMENTAL)" |
716 | depends on EXPERIMENTAL | 716 | depends on EXPERIMENTAL |
717 | select USB_FUNCTIONFS_GENERIC if !(USB_FUNCTIONFS_ETH || USB_FUNCTIONFS_RNDIS) | ||
717 | help | 718 | help |
718 | The Function Filesystem (FunctioFS) lets one create USB | 719 | The Function Filesystem (FunctioFS) lets one create USB |
719 | composite functions in user space in the same way as GadgetFS | 720 | composite functions in user space in the same way as GadgetFS |
@@ -722,31 +723,31 @@ config USB_FUNCTIONFS | |||
722 | implemented in kernel space (for instance Ethernet, serial or | 723 | implemented in kernel space (for instance Ethernet, serial or |
723 | mass storage) and other are implemented in user space. | 724 | mass storage) and other are implemented in user space. |
724 | 725 | ||
726 | If you say "y" or "m" here you will be able what kind of | ||
727 | configurations the gadget will provide. | ||
728 | |||
725 | Say "y" to link the driver statically, or "m" to build | 729 | Say "y" to link the driver statically, or "m" to build |
726 | a dynamically linked module called "g_ffs". | 730 | a dynamically linked module called "g_ffs". |
727 | 731 | ||
728 | config USB_FUNCTIONFS_ETH | 732 | config USB_FUNCTIONFS_ETH |
729 | bool "Include CDC ECM (Ethernet) function" | 733 | bool "Include configuration with CDC ECM (Ethernet)" |
730 | depends on USB_FUNCTIONFS && NET | 734 | depends on USB_FUNCTIONFS && NET |
731 | help | 735 | help |
732 | Include an CDC ECM (Ethernet) funcion in the CDC ECM (Funcion) | 736 | Include a configuration with CDC ECM funcion (Ethernet) and the |
733 | Filesystem. If you also say "y" to the RNDIS query below the | 737 | Funcion Filesystem. |
734 | gadget will have two configurations. | ||
735 | 738 | ||
736 | config USB_FUNCTIONFS_RNDIS | 739 | config USB_FUNCTIONFS_RNDIS |
737 | bool "Include RNDIS (Ethernet) function" | 740 | bool "Include configuration with RNDIS (Ethernet)" |
738 | depends on USB_FUNCTIONFS && NET | 741 | depends on USB_FUNCTIONFS && NET |
739 | help | 742 | help |
740 | Include an RNDIS (Ethernet) funcion in the Funcion Filesystem. | 743 | Include a configuration with RNDIS funcion (Ethernet) and the Filesystem. |
741 | If you also say "y" to the CDC ECM query above the gadget will | ||
742 | have two configurations. | ||
743 | 744 | ||
744 | config USB_FUNCTIONFS_GENERIC | 745 | config USB_FUNCTIONFS_GENERIC |
745 | bool "Include 'pure' configuration" | 746 | bool "Include 'pure' configuration" |
746 | depends on USB_FUNCTIONFS && (USB_FUNCTIONFS_ETH || USB_FUNCTIONFS_RNDIS) | 747 | depends on USB_FUNCTIONFS |
747 | help | 748 | help |
748 | Include a configuration with FunctionFS and no Ethernet | 749 | Include a configuration with the Function Filesystem alone with |
749 | configuration. | 750 | no Ethernet interface. |
750 | 751 | ||
751 | config USB_FILE_STORAGE | 752 | config USB_FILE_STORAGE |
752 | tristate "File-backed Storage Gadget" | 753 | tristate "File-backed Storage Gadget" |
@@ -863,6 +864,7 @@ config USB_G_NOKIA | |||
863 | config USB_G_MULTI | 864 | config USB_G_MULTI |
864 | tristate "Multifunction Composite Gadget (EXPERIMENTAL)" | 865 | tristate "Multifunction Composite Gadget (EXPERIMENTAL)" |
865 | depends on BLOCK && NET | 866 | depends on BLOCK && NET |
867 | select USB_G_MULTI_CDC if !USB_G_MULTI_RNDIS | ||
866 | help | 868 | help |
867 | The Multifunction Composite Gadget provides Ethernet (RNDIS | 869 | The Multifunction Composite Gadget provides Ethernet (RNDIS |
868 | and/or CDC Ethernet), mass storage and ACM serial link | 870 | and/or CDC Ethernet), mass storage and ACM serial link |
@@ -913,6 +915,34 @@ config USB_G_HID | |||
913 | Say "y" to link the driver statically, or "m" to build a | 915 | Say "y" to link the driver statically, or "m" to build a |
914 | dynamically linked module called "g_hid". | 916 | dynamically linked module called "g_hid". |
915 | 917 | ||
918 | config USB_G_DBGP | ||
919 | tristate "EHCI Debug Device Gadget" | ||
920 | help | ||
921 | This gadget emulates an EHCI Debug device. This is useful when you want | ||
922 | to interact with an EHCI Debug Port. | ||
923 | |||
924 | Say "y" to link the driver statically, or "m" to build a | ||
925 | dynamically linked module called "g_dbgp". | ||
926 | |||
927 | if USB_G_DBGP | ||
928 | choice | ||
929 | prompt "EHCI Debug Device mode" | ||
930 | default USB_G_DBGP_SERIAL | ||
931 | |||
932 | config USB_G_DBGP_PRINTK | ||
933 | depends on USB_G_DBGP | ||
934 | bool "printk" | ||
935 | help | ||
936 | Directly printk() received data. No interaction. | ||
937 | |||
938 | config USB_G_DBGP_SERIAL | ||
939 | depends on USB_G_DBGP | ||
940 | bool "serial" | ||
941 | help | ||
942 | Userland can interact using /dev/ttyGSxxx. | ||
943 | endchoice | ||
944 | endif | ||
945 | |||
916 | # put drivers that need isochronous transfer support (for audio | 946 | # put drivers that need isochronous transfer support (for audio |
917 | # or video class gadget drivers), or specific hardware, here. | 947 | # or video class gadget drivers), or specific hardware, here. |
918 | config USB_G_WEBCAM | 948 | config USB_G_WEBCAM |
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile index 9bcde110feb1..27283df37d09 100644 --- a/drivers/usb/gadget/Makefile +++ b/drivers/usb/gadget/Makefile | |||
@@ -44,6 +44,7 @@ g_printer-objs := printer.o | |||
44 | g_cdc-objs := cdc2.o | 44 | g_cdc-objs := cdc2.o |
45 | g_multi-objs := multi.o | 45 | g_multi-objs := multi.o |
46 | g_hid-objs := hid.o | 46 | g_hid-objs := hid.o |
47 | g_dbgp-objs := dbgp.o | ||
47 | g_nokia-objs := nokia.o | 48 | g_nokia-objs := nokia.o |
48 | g_webcam-objs := webcam.o | 49 | g_webcam-objs := webcam.o |
49 | 50 | ||
@@ -52,7 +53,6 @@ obj-$(CONFIG_USB_AUDIO) += g_audio.o | |||
52 | obj-$(CONFIG_USB_ETH) += g_ether.o | 53 | obj-$(CONFIG_USB_ETH) += g_ether.o |
53 | obj-$(CONFIG_USB_GADGETFS) += gadgetfs.o | 54 | obj-$(CONFIG_USB_GADGETFS) += gadgetfs.o |
54 | obj-$(CONFIG_USB_FUNCTIONFS) += g_ffs.o | 55 | obj-$(CONFIG_USB_FUNCTIONFS) += g_ffs.o |
55 | obj-$(CONFIG_USB_ETH_FUNCTIONFS) += g_eth_ffs.o | ||
56 | obj-$(CONFIG_USB_FILE_STORAGE) += g_file_storage.o | 56 | obj-$(CONFIG_USB_FILE_STORAGE) += g_file_storage.o |
57 | obj-$(CONFIG_USB_MASS_STORAGE) += g_mass_storage.o | 57 | obj-$(CONFIG_USB_MASS_STORAGE) += g_mass_storage.o |
58 | obj-$(CONFIG_USB_G_SERIAL) += g_serial.o | 58 | obj-$(CONFIG_USB_G_SERIAL) += g_serial.o |
@@ -60,6 +60,7 @@ obj-$(CONFIG_USB_G_PRINTER) += g_printer.o | |||
60 | obj-$(CONFIG_USB_MIDI_GADGET) += g_midi.o | 60 | obj-$(CONFIG_USB_MIDI_GADGET) += g_midi.o |
61 | obj-$(CONFIG_USB_CDC_COMPOSITE) += g_cdc.o | 61 | obj-$(CONFIG_USB_CDC_COMPOSITE) += g_cdc.o |
62 | obj-$(CONFIG_USB_G_HID) += g_hid.o | 62 | obj-$(CONFIG_USB_G_HID) += g_hid.o |
63 | obj-$(CONFIG_USB_G_DBGP) += g_dbgp.o | ||
63 | obj-$(CONFIG_USB_G_MULTI) += g_multi.o | 64 | obj-$(CONFIG_USB_G_MULTI) += g_multi.o |
64 | obj-$(CONFIG_USB_G_NOKIA) += g_nokia.o | 65 | obj-$(CONFIG_USB_G_NOKIA) += g_nokia.o |
65 | obj-$(CONFIG_USB_G_WEBCAM) += g_webcam.o | 66 | obj-$(CONFIG_USB_G_WEBCAM) += g_webcam.o |
diff --git a/drivers/usb/gadget/audio.c b/drivers/usb/gadget/audio.c index a62af7b59094..b744ccd0f34d 100644 --- a/drivers/usb/gadget/audio.c +++ b/drivers/usb/gadget/audio.c | |||
@@ -89,7 +89,7 @@ static const struct usb_descriptor_header *otg_desc[] = { | |||
89 | 89 | ||
90 | /*-------------------------------------------------------------------------*/ | 90 | /*-------------------------------------------------------------------------*/ |
91 | 91 | ||
92 | static int __init audio_do_config(struct usb_configuration *c) | 92 | static int __ref audio_do_config(struct usb_configuration *c) |
93 | { | 93 | { |
94 | /* FIXME alloc iConfiguration string, set it in c->strings */ | 94 | /* FIXME alloc iConfiguration string, set it in c->strings */ |
95 | 95 | ||
@@ -113,7 +113,7 @@ static struct usb_configuration audio_config_driver = { | |||
113 | 113 | ||
114 | /*-------------------------------------------------------------------------*/ | 114 | /*-------------------------------------------------------------------------*/ |
115 | 115 | ||
116 | static int __init audio_bind(struct usb_composite_dev *cdev) | 116 | static int __ref audio_bind(struct usb_composite_dev *cdev) |
117 | { | 117 | { |
118 | int gcnum; | 118 | int gcnum; |
119 | int status; | 119 | int status; |
diff --git a/drivers/usb/gadget/cdc2.c b/drivers/usb/gadget/cdc2.c index 928137d3dbdc..1f5ba2fd4c1f 100644 --- a/drivers/usb/gadget/cdc2.c +++ b/drivers/usb/gadget/cdc2.c | |||
@@ -129,7 +129,7 @@ static u8 hostaddr[ETH_ALEN]; | |||
129 | /* | 129 | /* |
130 | * We _always_ have both CDC ECM and CDC ACM functions. | 130 | * We _always_ have both CDC ECM and CDC ACM functions. |
131 | */ | 131 | */ |
132 | static int __init cdc_do_config(struct usb_configuration *c) | 132 | static int __ref cdc_do_config(struct usb_configuration *c) |
133 | { | 133 | { |
134 | int status; | 134 | int status; |
135 | 135 | ||
@@ -159,7 +159,7 @@ static struct usb_configuration cdc_config_driver = { | |||
159 | 159 | ||
160 | /*-------------------------------------------------------------------------*/ | 160 | /*-------------------------------------------------------------------------*/ |
161 | 161 | ||
162 | static int __init cdc_bind(struct usb_composite_dev *cdev) | 162 | static int __ref cdc_bind(struct usb_composite_dev *cdev) |
163 | { | 163 | { |
164 | int gcnum; | 164 | int gcnum; |
165 | struct usb_gadget *gadget = cdev->gadget; | 165 | struct usb_gadget *gadget = cdev->gadget; |
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 391d169f8d07..e483f80822d2 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c | |||
@@ -673,20 +673,83 @@ static int get_string(struct usb_composite_dev *cdev, | |||
673 | * string IDs. Drivers for functions, configurations, or gadgets will | 673 | * string IDs. Drivers for functions, configurations, or gadgets will |
674 | * then store that ID in the appropriate descriptors and string table. | 674 | * then store that ID in the appropriate descriptors and string table. |
675 | * | 675 | * |
676 | * All string identifier should be allocated using this routine, to | 676 | * All string identifier should be allocated using this, |
677 | * ensure that for example different functions don't wrongly assign | 677 | * @usb_string_ids_tab() or @usb_string_ids_n() routine, to ensure |
678 | * different meanings to the same identifier. | 678 | * that for example different functions don't wrongly assign different |
679 | * meanings to the same identifier. | ||
679 | */ | 680 | */ |
680 | int usb_string_id(struct usb_composite_dev *cdev) | 681 | int usb_string_id(struct usb_composite_dev *cdev) |
681 | { | 682 | { |
682 | if (cdev->next_string_id < 254) { | 683 | if (cdev->next_string_id < 254) { |
683 | /* string id 0 is reserved */ | 684 | /* string id 0 is reserved by USB spec for list of |
685 | * supported languages */ | ||
686 | /* 255 reserved as well? -- mina86 */ | ||
684 | cdev->next_string_id++; | 687 | cdev->next_string_id++; |
685 | return cdev->next_string_id; | 688 | return cdev->next_string_id; |
686 | } | 689 | } |
687 | return -ENODEV; | 690 | return -ENODEV; |
688 | } | 691 | } |
689 | 692 | ||
693 | /** | ||
694 | * usb_string_ids() - allocate unused string IDs in batch | ||
695 | * @cdev: the device whose string descriptor IDs are being allocated | ||
696 | * @str: an array of usb_string objects to assign numbers to | ||
697 | * Context: single threaded during gadget setup | ||
698 | * | ||
699 | * @usb_string_ids() is called from bind() callbacks to allocate | ||
700 | * string IDs. Drivers for functions, configurations, or gadgets will | ||
701 | * then copy IDs from the string table to the appropriate descriptors | ||
702 | * and string table for other languages. | ||
703 | * | ||
704 | * All string identifier should be allocated using this, | ||
705 | * @usb_string_id() or @usb_string_ids_n() routine, to ensure that for | ||
706 | * example different functions don't wrongly assign different meanings | ||
707 | * to the same identifier. | ||
708 | */ | ||
709 | int usb_string_ids_tab(struct usb_composite_dev *cdev, struct usb_string *str) | ||
710 | { | ||
711 | int next = cdev->next_string_id; | ||
712 | |||
713 | for (; str->s; ++str) { | ||
714 | if (unlikely(next >= 254)) | ||
715 | return -ENODEV; | ||
716 | str->id = ++next; | ||
717 | } | ||
718 | |||
719 | cdev->next_string_id = next; | ||
720 | |||
721 | return 0; | ||
722 | } | ||
723 | |||
724 | /** | ||
725 | * usb_string_ids_n() - allocate unused string IDs in batch | ||
726 | * @cdev: the device whose string descriptor IDs are being allocated | ||
727 | * @n: number of string IDs to allocate | ||
728 | * Context: single threaded during gadget setup | ||
729 | * | ||
730 | * Returns the first requested ID. This ID and next @n-1 IDs are now | ||
731 | * valid IDs. At least providind that @n is non zore because if it | ||
732 | * is, returns last requested ID which is now very useful information. | ||
733 | * | ||
734 | * @usb_string_ids_n() is called from bind() callbacks to allocate | ||
735 | * string IDs. Drivers for functions, configurations, or gadgets will | ||
736 | * then store that ID in the appropriate descriptors and string table. | ||
737 | * | ||
738 | * All string identifier should be allocated using this, | ||
739 | * @usb_string_id() or @usb_string_ids_n() routine, to ensure that for | ||
740 | * example different functions don't wrongly assign different meanings | ||
741 | * to the same identifier. | ||
742 | */ | ||
743 | int usb_string_ids_n(struct usb_composite_dev *c, unsigned n) | ||
744 | { | ||
745 | unsigned next = c->next_string_id; | ||
746 | if (unlikely(n > 254 || (unsigned)next + n > 254)) | ||
747 | return -ENODEV; | ||
748 | c->next_string_id += n; | ||
749 | return next + 1; | ||
750 | } | ||
751 | |||
752 | |||
690 | /*-------------------------------------------------------------------------*/ | 753 | /*-------------------------------------------------------------------------*/ |
691 | 754 | ||
692 | static void composite_setup_complete(struct usb_ep *ep, struct usb_request *req) | 755 | static void composite_setup_complete(struct usb_ep *ep, struct usb_request *req) |
@@ -893,6 +956,8 @@ static void composite_disconnect(struct usb_gadget *gadget) | |||
893 | spin_lock_irqsave(&cdev->lock, flags); | 956 | spin_lock_irqsave(&cdev->lock, flags); |
894 | if (cdev->config) | 957 | if (cdev->config) |
895 | reset_config(cdev); | 958 | reset_config(cdev); |
959 | if (composite->disconnect) | ||
960 | composite->disconnect(cdev); | ||
896 | spin_unlock_irqrestore(&cdev->lock, flags); | 961 | spin_unlock_irqrestore(&cdev->lock, flags); |
897 | } | 962 | } |
898 | 963 | ||
diff --git a/drivers/usb/gadget/dbgp.c b/drivers/usb/gadget/dbgp.c new file mode 100644 index 000000000000..0ed50a2c0a36 --- /dev/null +++ b/drivers/usb/gadget/dbgp.c | |||
@@ -0,0 +1,434 @@ | |||
1 | /* | ||
2 | * dbgp.c -- EHCI Debug Port device gadget | ||
3 | * | ||
4 | * Copyright (C) 2010 Stephane Duverger | ||
5 | * | ||
6 | * Released under the GPLv2. | ||
7 | * | ||
8 | */ | ||
9 | |||
10 | /* verbose messages */ | ||
11 | #include <linux/kernel.h> | ||
12 | #include <linux/device.h> | ||
13 | #include <linux/usb/ch9.h> | ||
14 | #include <linux/usb/gadget.h> | ||
15 | |||
16 | /* See comments in "zero.c" */ | ||
17 | #include "epautoconf.c" | ||
18 | |||
19 | #ifdef CONFIG_USB_G_DBGP_SERIAL | ||
20 | #include "u_serial.c" | ||
21 | #endif | ||
22 | |||
23 | #define DRIVER_VENDOR_ID 0x0525 /* NetChip */ | ||
24 | #define DRIVER_PRODUCT_ID 0xc0de /* undefined */ | ||
25 | |||
26 | #define USB_DEBUG_MAX_PACKET_SIZE 8 | ||
27 | #define DBGP_REQ_EP0_LEN 128 | ||
28 | #define DBGP_REQ_LEN 512 | ||
29 | |||
30 | static struct dbgp { | ||
31 | struct usb_gadget *gadget; | ||
32 | struct usb_request *req; | ||
33 | struct usb_ep *i_ep; | ||
34 | struct usb_ep *o_ep; | ||
35 | #ifdef CONFIG_USB_G_DBGP_SERIAL | ||
36 | struct gserial *serial; | ||
37 | #endif | ||
38 | } dbgp; | ||
39 | |||
40 | static struct usb_device_descriptor device_desc = { | ||
41 | .bLength = sizeof device_desc, | ||
42 | .bDescriptorType = USB_DT_DEVICE, | ||
43 | .bcdUSB = __constant_cpu_to_le16(0x0200), | ||
44 | .bDeviceClass = USB_CLASS_VENDOR_SPEC, | ||
45 | .idVendor = __constant_cpu_to_le16(DRIVER_VENDOR_ID), | ||
46 | .idProduct = __constant_cpu_to_le16(DRIVER_PRODUCT_ID), | ||
47 | .bNumConfigurations = 1, | ||
48 | }; | ||
49 | |||
50 | static struct usb_debug_descriptor dbg_desc = { | ||
51 | .bLength = sizeof dbg_desc, | ||
52 | .bDescriptorType = USB_DT_DEBUG, | ||
53 | }; | ||
54 | |||
55 | static struct usb_endpoint_descriptor i_desc = { | ||
56 | .bLength = USB_DT_ENDPOINT_SIZE, | ||
57 | .bDescriptorType = USB_DT_ENDPOINT, | ||
58 | .bmAttributes = USB_ENDPOINT_XFER_BULK, | ||
59 | .bEndpointAddress = USB_DIR_IN, | ||
60 | }; | ||
61 | |||
62 | static struct usb_endpoint_descriptor o_desc = { | ||
63 | .bLength = USB_DT_ENDPOINT_SIZE, | ||
64 | .bDescriptorType = USB_DT_ENDPOINT, | ||
65 | .bmAttributes = USB_ENDPOINT_XFER_BULK, | ||
66 | .bEndpointAddress = USB_DIR_OUT, | ||
67 | }; | ||
68 | |||
69 | #ifdef CONFIG_USB_G_DBGP_PRINTK | ||
70 | static int dbgp_consume(char *buf, unsigned len) | ||
71 | { | ||
72 | char c; | ||
73 | |||
74 | if (!len) | ||
75 | return 0; | ||
76 | |||
77 | c = buf[len-1]; | ||
78 | if (c != 0) | ||
79 | buf[len-1] = 0; | ||
80 | |||
81 | printk(KERN_NOTICE "%s%c", buf, c); | ||
82 | return 0; | ||
83 | } | ||
84 | |||
85 | static void __disable_ep(struct usb_ep *ep) | ||
86 | { | ||
87 | if (ep && ep->driver_data == dbgp.gadget) { | ||
88 | usb_ep_disable(ep); | ||
89 | ep->driver_data = NULL; | ||
90 | } | ||
91 | } | ||
92 | |||
93 | static void dbgp_disable_ep(void) | ||
94 | { | ||
95 | __disable_ep(dbgp.i_ep); | ||
96 | __disable_ep(dbgp.o_ep); | ||
97 | } | ||
98 | |||
99 | static void dbgp_complete(struct usb_ep *ep, struct usb_request *req) | ||
100 | { | ||
101 | int stp; | ||
102 | int err = 0; | ||
103 | int status = req->status; | ||
104 | |||
105 | if (ep == dbgp.i_ep) { | ||
106 | stp = 1; | ||
107 | goto fail; | ||
108 | } | ||
109 | |||
110 | if (status != 0) { | ||
111 | stp = 2; | ||
112 | goto release_req; | ||
113 | } | ||
114 | |||
115 | dbgp_consume(req->buf, req->actual); | ||
116 | |||
117 | req->length = DBGP_REQ_LEN; | ||
118 | err = usb_ep_queue(ep, req, GFP_ATOMIC); | ||
119 | if (err < 0) { | ||
120 | stp = 3; | ||
121 | goto release_req; | ||
122 | } | ||
123 | |||
124 | return; | ||
125 | |||
126 | release_req: | ||
127 | kfree(req->buf); | ||
128 | usb_ep_free_request(dbgp.o_ep, req); | ||
129 | dbgp_disable_ep(); | ||
130 | fail: | ||
131 | dev_dbg(&dbgp.gadget->dev, | ||
132 | "complete: failure (%d:%d) ==> %d\n", stp, err, status); | ||
133 | } | ||
134 | |||
135 | static int dbgp_enable_ep_req(struct usb_ep *ep) | ||
136 | { | ||
137 | int err, stp; | ||
138 | struct usb_request *req; | ||
139 | |||
140 | req = usb_ep_alloc_request(ep, GFP_KERNEL); | ||
141 | if (!req) { | ||
142 | err = -ENOMEM; | ||
143 | stp = 1; | ||
144 | goto fail_1; | ||
145 | } | ||
146 | |||
147 | req->buf = kmalloc(DBGP_REQ_LEN, GFP_KERNEL); | ||
148 | if (!req->buf) { | ||
149 | err = -ENOMEM; | ||
150 | stp = 2; | ||
151 | goto fail_2; | ||
152 | } | ||
153 | |||
154 | req->complete = dbgp_complete; | ||
155 | req->length = DBGP_REQ_LEN; | ||
156 | err = usb_ep_queue(ep, req, GFP_ATOMIC); | ||
157 | if (err < 0) { | ||
158 | stp = 3; | ||
159 | goto fail_3; | ||
160 | } | ||
161 | |||
162 | return 0; | ||
163 | |||
164 | fail_3: | ||
165 | kfree(req->buf); | ||
166 | fail_2: | ||
167 | usb_ep_free_request(dbgp.o_ep, req); | ||
168 | fail_1: | ||
169 | dev_dbg(&dbgp.gadget->dev, | ||
170 | "enable ep req: failure (%d:%d)\n", stp, err); | ||
171 | return err; | ||
172 | } | ||
173 | |||
174 | static int __enable_ep(struct usb_ep *ep, struct usb_endpoint_descriptor *desc) | ||
175 | { | ||
176 | int err = usb_ep_enable(ep, desc); | ||
177 | ep->driver_data = dbgp.gadget; | ||
178 | return err; | ||
179 | } | ||
180 | |||
181 | static int dbgp_enable_ep(void) | ||
182 | { | ||
183 | int err, stp; | ||
184 | |||
185 | err = __enable_ep(dbgp.i_ep, &i_desc); | ||
186 | if (err < 0) { | ||
187 | stp = 1; | ||
188 | goto fail_1; | ||
189 | } | ||
190 | |||
191 | err = __enable_ep(dbgp.o_ep, &o_desc); | ||
192 | if (err < 0) { | ||
193 | stp = 2; | ||
194 | goto fail_2; | ||
195 | } | ||
196 | |||
197 | err = dbgp_enable_ep_req(dbgp.o_ep); | ||
198 | if (err < 0) { | ||
199 | stp = 3; | ||
200 | goto fail_3; | ||
201 | } | ||
202 | |||
203 | return 0; | ||
204 | |||
205 | fail_3: | ||
206 | __disable_ep(dbgp.o_ep); | ||
207 | fail_2: | ||
208 | __disable_ep(dbgp.i_ep); | ||
209 | fail_1: | ||
210 | dev_dbg(&dbgp.gadget->dev, "enable ep: failure (%d:%d)\n", stp, err); | ||
211 | return err; | ||
212 | } | ||
213 | #endif | ||
214 | |||
215 | static void dbgp_disconnect(struct usb_gadget *gadget) | ||
216 | { | ||
217 | #ifdef CONFIG_USB_G_DBGP_PRINTK | ||
218 | dbgp_disable_ep(); | ||
219 | #else | ||
220 | gserial_disconnect(dbgp.serial); | ||
221 | #endif | ||
222 | } | ||
223 | |||
224 | static void dbgp_unbind(struct usb_gadget *gadget) | ||
225 | { | ||
226 | #ifdef CONFIG_USB_G_DBGP_SERIAL | ||
227 | kfree(dbgp.serial); | ||
228 | #endif | ||
229 | if (dbgp.req) { | ||
230 | kfree(dbgp.req->buf); | ||
231 | usb_ep_free_request(gadget->ep0, dbgp.req); | ||
232 | } | ||
233 | |||
234 | gadget->ep0->driver_data = NULL; | ||
235 | } | ||
236 | |||
237 | static int __init dbgp_configure_endpoints(struct usb_gadget *gadget) | ||
238 | { | ||
239 | int stp; | ||
240 | |||
241 | usb_ep_autoconfig_reset(gadget); | ||
242 | |||
243 | dbgp.i_ep = usb_ep_autoconfig(gadget, &i_desc); | ||
244 | if (!dbgp.i_ep) { | ||
245 | stp = 1; | ||
246 | goto fail_1; | ||
247 | } | ||
248 | |||
249 | dbgp.i_ep->driver_data = gadget; | ||
250 | i_desc.wMaxPacketSize = | ||
251 | __constant_cpu_to_le16(USB_DEBUG_MAX_PACKET_SIZE); | ||
252 | |||
253 | dbgp.o_ep = usb_ep_autoconfig(gadget, &o_desc); | ||
254 | if (!dbgp.o_ep) { | ||
255 | dbgp.i_ep->driver_data = NULL; | ||
256 | stp = 2; | ||
257 | goto fail_2; | ||
258 | } | ||
259 | |||
260 | dbgp.o_ep->driver_data = gadget; | ||
261 | o_desc.wMaxPacketSize = | ||
262 | __constant_cpu_to_le16(USB_DEBUG_MAX_PACKET_SIZE); | ||
263 | |||
264 | dbg_desc.bDebugInEndpoint = i_desc.bEndpointAddress & 0x7f; | ||
265 | dbg_desc.bDebugOutEndpoint = o_desc.bEndpointAddress & 0x7f; | ||
266 | |||
267 | #ifdef CONFIG_USB_G_DBGP_SERIAL | ||
268 | dbgp.serial->in = dbgp.i_ep; | ||
269 | dbgp.serial->out = dbgp.o_ep; | ||
270 | |||
271 | dbgp.serial->in_desc = &i_desc; | ||
272 | dbgp.serial->out_desc = &o_desc; | ||
273 | |||
274 | if (gserial_setup(gadget, 1) < 0) { | ||
275 | stp = 3; | ||
276 | goto fail_3; | ||
277 | } | ||
278 | |||
279 | return 0; | ||
280 | |||
281 | fail_3: | ||
282 | dbgp.o_ep->driver_data = NULL; | ||
283 | #else | ||
284 | return 0; | ||
285 | #endif | ||
286 | fail_2: | ||
287 | dbgp.i_ep->driver_data = NULL; | ||
288 | fail_1: | ||
289 | dev_dbg(&dbgp.gadget->dev, "ep config: failure (%d)\n", stp); | ||
290 | return -ENODEV; | ||
291 | } | ||
292 | |||
293 | static int __init dbgp_bind(struct usb_gadget *gadget) | ||
294 | { | ||
295 | int err, stp; | ||
296 | |||
297 | dbgp.gadget = gadget; | ||
298 | |||
299 | dbgp.req = usb_ep_alloc_request(gadget->ep0, GFP_KERNEL); | ||
300 | if (!dbgp.req) { | ||
301 | err = -ENOMEM; | ||
302 | stp = 1; | ||
303 | goto fail; | ||
304 | } | ||
305 | |||
306 | dbgp.req->buf = kmalloc(DBGP_REQ_EP0_LEN, GFP_KERNEL); | ||
307 | if (!dbgp.req->buf) { | ||
308 | err = -ENOMEM; | ||
309 | stp = 2; | ||
310 | goto fail; | ||
311 | } | ||
312 | |||
313 | dbgp.req->length = DBGP_REQ_EP0_LEN; | ||
314 | gadget->ep0->driver_data = gadget; | ||
315 | |||
316 | #ifdef CONFIG_USB_G_DBGP_SERIAL | ||
317 | dbgp.serial = kzalloc(sizeof(struct gserial), GFP_KERNEL); | ||
318 | if (!dbgp.serial) { | ||
319 | stp = 3; | ||
320 | err = -ENOMEM; | ||
321 | goto fail; | ||
322 | } | ||
323 | #endif | ||
324 | err = dbgp_configure_endpoints(gadget); | ||
325 | if (err < 0) { | ||
326 | stp = 4; | ||
327 | goto fail; | ||
328 | } | ||
329 | |||
330 | dev_dbg(&dbgp.gadget->dev, "bind: success\n"); | ||
331 | return 0; | ||
332 | |||
333 | fail: | ||
334 | dev_dbg(&gadget->dev, "bind: failure (%d:%d)\n", stp, err); | ||
335 | dbgp_unbind(gadget); | ||
336 | return err; | ||
337 | } | ||
338 | |||
339 | static void dbgp_setup_complete(struct usb_ep *ep, | ||
340 | struct usb_request *req) | ||
341 | { | ||
342 | dev_dbg(&dbgp.gadget->dev, "setup complete: %d, %d/%d\n", | ||
343 | req->status, req->actual, req->length); | ||
344 | } | ||
345 | |||
346 | static int dbgp_setup(struct usb_gadget *gadget, | ||
347 | const struct usb_ctrlrequest *ctrl) | ||
348 | { | ||
349 | struct usb_request *req = dbgp.req; | ||
350 | u8 request = ctrl->bRequest; | ||
351 | u16 value = le16_to_cpu(ctrl->wValue); | ||
352 | u16 length = le16_to_cpu(ctrl->wLength); | ||
353 | int err = 0; | ||
354 | void *data; | ||
355 | u16 len; | ||
356 | |||
357 | gadget->ep0->driver_data = gadget; | ||
358 | |||
359 | if (request == USB_REQ_GET_DESCRIPTOR) { | ||
360 | switch (value>>8) { | ||
361 | case USB_DT_DEVICE: | ||
362 | dev_dbg(&dbgp.gadget->dev, "setup: desc device\n"); | ||
363 | len = sizeof device_desc; | ||
364 | data = &device_desc; | ||
365 | break; | ||
366 | case USB_DT_DEBUG: | ||
367 | dev_dbg(&dbgp.gadget->dev, "setup: desc debug\n"); | ||
368 | len = sizeof dbg_desc; | ||
369 | data = &dbg_desc; | ||
370 | break; | ||
371 | default: | ||
372 | goto fail; | ||
373 | } | ||
374 | } else if (request == USB_REQ_SET_FEATURE && | ||
375 | value == USB_DEVICE_DEBUG_MODE) { | ||
376 | len = 0; | ||
377 | data = NULL; | ||
378 | dev_dbg(&dbgp.gadget->dev, "setup: feat debug\n"); | ||
379 | #ifdef CONFIG_USB_G_DBGP_PRINTK | ||
380 | err = dbgp_enable_ep(); | ||
381 | #else | ||
382 | err = gserial_connect(dbgp.serial, 0); | ||
383 | #endif | ||
384 | if (err < 0) | ||
385 | goto fail; | ||
386 | } else | ||
387 | goto fail; | ||
388 | |||
389 | if (len >= 0) { | ||
390 | req->length = min(length, len); | ||
391 | req->zero = len < req->length; | ||
392 | if (data && req->length) | ||
393 | memcpy(req->buf, data, req->length); | ||
394 | |||
395 | req->complete = dbgp_setup_complete; | ||
396 | return usb_ep_queue(gadget->ep0, req, GFP_ATOMIC); | ||
397 | } | ||
398 | |||
399 | fail: | ||
400 | dev_dbg(&dbgp.gadget->dev, | ||
401 | "setup: failure req %x v %x\n", request, value); | ||
402 | return err; | ||
403 | } | ||
404 | |||
405 | static struct usb_gadget_driver dbgp_driver = { | ||
406 | .function = "dbgp", | ||
407 | .speed = USB_SPEED_HIGH, | ||
408 | .bind = dbgp_bind, | ||
409 | .unbind = dbgp_unbind, | ||
410 | .setup = dbgp_setup, | ||
411 | .disconnect = dbgp_disconnect, | ||
412 | .driver = { | ||
413 | .owner = THIS_MODULE, | ||
414 | .name = "dbgp" | ||
415 | }, | ||
416 | }; | ||
417 | |||
418 | static int __init dbgp_init(void) | ||
419 | { | ||
420 | return usb_gadget_register_driver(&dbgp_driver); | ||
421 | } | ||
422 | |||
423 | static void __exit dbgp_exit(void) | ||
424 | { | ||
425 | usb_gadget_unregister_driver(&dbgp_driver); | ||
426 | #ifdef CONFIG_USB_G_DBGP_SERIAL | ||
427 | gserial_cleanup(); | ||
428 | #endif | ||
429 | } | ||
430 | |||
431 | MODULE_AUTHOR("Stephane Duverger"); | ||
432 | MODULE_LICENSE("GPL"); | ||
433 | module_init(dbgp_init); | ||
434 | module_exit(dbgp_exit); | ||
diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c index 4f9e578cde9d..dc6546248ed9 100644 --- a/drivers/usb/gadget/dummy_hcd.c +++ b/drivers/usb/gadget/dummy_hcd.c | |||
@@ -1542,7 +1542,7 @@ static int dummy_hub_status (struct usb_hcd *hcd, char *buf) | |||
1542 | dum = hcd_to_dummy (hcd); | 1542 | dum = hcd_to_dummy (hcd); |
1543 | 1543 | ||
1544 | spin_lock_irqsave (&dum->lock, flags); | 1544 | spin_lock_irqsave (&dum->lock, flags); |
1545 | if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) | 1545 | if (!HCD_HW_ACCESSIBLE(hcd)) |
1546 | goto done; | 1546 | goto done; |
1547 | 1547 | ||
1548 | if (dum->resuming && time_after_eq (jiffies, dum->re_timeout)) { | 1548 | if (dum->resuming && time_after_eq (jiffies, dum->re_timeout)) { |
@@ -1588,7 +1588,7 @@ static int dummy_hub_control ( | |||
1588 | int retval = 0; | 1588 | int retval = 0; |
1589 | unsigned long flags; | 1589 | unsigned long flags; |
1590 | 1590 | ||
1591 | if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) | 1591 | if (!HCD_HW_ACCESSIBLE(hcd)) |
1592 | return -ETIMEDOUT; | 1592 | return -ETIMEDOUT; |
1593 | 1593 | ||
1594 | dum = hcd_to_dummy (hcd); | 1594 | dum = hcd_to_dummy (hcd); |
@@ -1739,7 +1739,7 @@ static int dummy_bus_resume (struct usb_hcd *hcd) | |||
1739 | dev_dbg (&hcd->self.root_hub->dev, "%s\n", __func__); | 1739 | dev_dbg (&hcd->self.root_hub->dev, "%s\n", __func__); |
1740 | 1740 | ||
1741 | spin_lock_irq (&dum->lock); | 1741 | spin_lock_irq (&dum->lock); |
1742 | if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) { | 1742 | if (!HCD_HW_ACCESSIBLE(hcd)) { |
1743 | rc = -ESHUTDOWN; | 1743 | rc = -ESHUTDOWN; |
1744 | } else { | 1744 | } else { |
1745 | dum->rh_state = DUMMY_RH_RUNNING; | 1745 | dum->rh_state = DUMMY_RH_RUNNING; |
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c index 400f80372d93..114fa024c22c 100644 --- a/drivers/usb/gadget/ether.c +++ b/drivers/usb/gadget/ether.c | |||
@@ -237,7 +237,7 @@ static u8 hostaddr[ETH_ALEN]; | |||
237 | * the first one present. That's to make Microsoft's drivers happy, | 237 | * the first one present. That's to make Microsoft's drivers happy, |
238 | * and to follow DOCSIS 1.0 (cable modem standard). | 238 | * and to follow DOCSIS 1.0 (cable modem standard). |
239 | */ | 239 | */ |
240 | static int __init rndis_do_config(struct usb_configuration *c) | 240 | static int __ref rndis_do_config(struct usb_configuration *c) |
241 | { | 241 | { |
242 | /* FIXME alloc iConfiguration string, set it in c->strings */ | 242 | /* FIXME alloc iConfiguration string, set it in c->strings */ |
243 | 243 | ||
@@ -270,7 +270,7 @@ MODULE_PARM_DESC(use_eem, "use CDC EEM mode"); | |||
270 | /* | 270 | /* |
271 | * We _always_ have an ECM, CDC Subset, or EEM configuration. | 271 | * We _always_ have an ECM, CDC Subset, or EEM configuration. |
272 | */ | 272 | */ |
273 | static int __init eth_do_config(struct usb_configuration *c) | 273 | static int __ref eth_do_config(struct usb_configuration *c) |
274 | { | 274 | { |
275 | /* FIXME alloc iConfiguration string, set it in c->strings */ | 275 | /* FIXME alloc iConfiguration string, set it in c->strings */ |
276 | 276 | ||
@@ -297,7 +297,7 @@ static struct usb_configuration eth_config_driver = { | |||
297 | 297 | ||
298 | /*-------------------------------------------------------------------------*/ | 298 | /*-------------------------------------------------------------------------*/ |
299 | 299 | ||
300 | static int __init eth_bind(struct usb_composite_dev *cdev) | 300 | static int __ref eth_bind(struct usb_composite_dev *cdev) |
301 | { | 301 | { |
302 | int gcnum; | 302 | int gcnum; |
303 | struct usb_gadget *gadget = cdev->gadget; | 303 | struct usb_gadget *gadget = cdev->gadget; |
diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c index 2aaa0f75c6cf..e4f595055208 100644 --- a/drivers/usb/gadget/f_fs.c +++ b/drivers/usb/gadget/f_fs.c | |||
@@ -714,9 +714,7 @@ static long ffs_ep0_ioctl(struct file *file, unsigned code, unsigned long value) | |||
714 | struct ffs_function *func = ffs->func; | 714 | struct ffs_function *func = ffs->func; |
715 | ret = func ? ffs_func_revmap_intf(func, value) : -ENODEV; | 715 | ret = func ? ffs_func_revmap_intf(func, value) : -ENODEV; |
716 | } else if (gadget->ops->ioctl) { | 716 | } else if (gadget->ops->ioctl) { |
717 | lock_kernel(); | ||
718 | ret = gadget->ops->ioctl(gadget, code, value); | 717 | ret = gadget->ops->ioctl(gadget, code, value); |
719 | unlock_kernel(); | ||
720 | } else { | 718 | } else { |
721 | ret = -ENOTTY; | 719 | ret = -ENOTTY; |
722 | } | 720 | } |
@@ -1377,7 +1375,8 @@ static void ffs_data_reset(struct ffs_data *ffs) | |||
1377 | 1375 | ||
1378 | static int functionfs_bind(struct ffs_data *ffs, struct usb_composite_dev *cdev) | 1376 | static int functionfs_bind(struct ffs_data *ffs, struct usb_composite_dev *cdev) |
1379 | { | 1377 | { |
1380 | unsigned i, count; | 1378 | struct usb_gadget_strings **lang; |
1379 | int first_id; | ||
1381 | 1380 | ||
1382 | ENTER(); | 1381 | ENTER(); |
1383 | 1382 | ||
@@ -1385,7 +1384,9 @@ static int functionfs_bind(struct ffs_data *ffs, struct usb_composite_dev *cdev) | |||
1385 | || test_and_set_bit(FFS_FL_BOUND, &ffs->flags))) | 1384 | || test_and_set_bit(FFS_FL_BOUND, &ffs->flags))) |
1386 | return -EBADFD; | 1385 | return -EBADFD; |
1387 | 1386 | ||
1388 | ffs_data_get(ffs); | 1387 | first_id = usb_string_ids_n(cdev, ffs->strings_count); |
1388 | if (unlikely(first_id < 0)) | ||
1389 | return first_id; | ||
1389 | 1390 | ||
1390 | ffs->ep0req = usb_ep_alloc_request(cdev->gadget->ep0, GFP_KERNEL); | 1391 | ffs->ep0req = usb_ep_alloc_request(cdev->gadget->ep0, GFP_KERNEL); |
1391 | if (unlikely(!ffs->ep0req)) | 1392 | if (unlikely(!ffs->ep0req)) |
@@ -1393,25 +1394,16 @@ static int functionfs_bind(struct ffs_data *ffs, struct usb_composite_dev *cdev) | |||
1393 | ffs->ep0req->complete = ffs_ep0_complete; | 1394 | ffs->ep0req->complete = ffs_ep0_complete; |
1394 | ffs->ep0req->context = ffs; | 1395 | ffs->ep0req->context = ffs; |
1395 | 1396 | ||
1396 | /* Get strings identifiers */ | 1397 | lang = ffs->stringtabs; |
1397 | for (count = ffs->strings_count, i = 0; i < count; ++i) { | 1398 | for (lang = ffs->stringtabs; *lang; ++lang) { |
1398 | struct usb_gadget_strings **lang; | 1399 | struct usb_string *str = (*lang)->strings; |
1399 | 1400 | int id = first_id; | |
1400 | int id = usb_string_id(cdev); | 1401 | for (; str->s; ++id, ++str) |
1401 | if (unlikely(id < 0)) { | 1402 | str->id = id; |
1402 | usb_ep_free_request(cdev->gadget->ep0, ffs->ep0req); | ||
1403 | ffs->ep0req = NULL; | ||
1404 | return id; | ||
1405 | } | ||
1406 | |||
1407 | lang = ffs->stringtabs; | ||
1408 | do { | ||
1409 | (*lang)->strings[i].id = id; | ||
1410 | ++lang; | ||
1411 | } while (*lang); | ||
1412 | } | 1403 | } |
1413 | 1404 | ||
1414 | ffs->gadget = cdev->gadget; | 1405 | ffs->gadget = cdev->gadget; |
1406 | ffs_data_get(ffs); | ||
1415 | return 0; | 1407 | return 0; |
1416 | } | 1408 | } |
1417 | 1409 | ||
@@ -1480,9 +1472,9 @@ static void ffs_epfiles_destroy(struct ffs_epfile *epfiles, unsigned count) | |||
1480 | } | 1472 | } |
1481 | 1473 | ||
1482 | 1474 | ||
1483 | static int functionfs_add(struct usb_composite_dev *cdev, | 1475 | static int functionfs_bind_config(struct usb_composite_dev *cdev, |
1484 | struct usb_configuration *c, | 1476 | struct usb_configuration *c, |
1485 | struct ffs_data *ffs) | 1477 | struct ffs_data *ffs) |
1486 | { | 1478 | { |
1487 | struct ffs_function *func; | 1479 | struct ffs_function *func; |
1488 | int ret; | 1480 | int ret; |
diff --git a/drivers/usb/gadget/f_hid.c b/drivers/usb/gadget/f_hid.c index 1e00ff9866af..53e120208e99 100644 --- a/drivers/usb/gadget/f_hid.c +++ b/drivers/usb/gadget/f_hid.c | |||
@@ -142,7 +142,7 @@ static struct usb_descriptor_header *hidg_fs_descriptors[] = { | |||
142 | static ssize_t f_hidg_read(struct file *file, char __user *buffer, | 142 | static ssize_t f_hidg_read(struct file *file, char __user *buffer, |
143 | size_t count, loff_t *ptr) | 143 | size_t count, loff_t *ptr) |
144 | { | 144 | { |
145 | struct f_hidg *hidg = (struct f_hidg *)file->private_data; | 145 | struct f_hidg *hidg = file->private_data; |
146 | char *tmp_buff = NULL; | 146 | char *tmp_buff = NULL; |
147 | unsigned long flags; | 147 | unsigned long flags; |
148 | 148 | ||
@@ -200,7 +200,7 @@ static void f_hidg_req_complete(struct usb_ep *ep, struct usb_request *req) | |||
200 | static ssize_t f_hidg_write(struct file *file, const char __user *buffer, | 200 | static ssize_t f_hidg_write(struct file *file, const char __user *buffer, |
201 | size_t count, loff_t *offp) | 201 | size_t count, loff_t *offp) |
202 | { | 202 | { |
203 | struct f_hidg *hidg = (struct f_hidg *)file->private_data; | 203 | struct f_hidg *hidg = file->private_data; |
204 | ssize_t status = -ENOMEM; | 204 | ssize_t status = -ENOMEM; |
205 | 205 | ||
206 | if (!access_ok(VERIFY_READ, buffer, count)) | 206 | if (!access_ok(VERIFY_READ, buffer, count)) |
@@ -257,7 +257,7 @@ static ssize_t f_hidg_write(struct file *file, const char __user *buffer, | |||
257 | 257 | ||
258 | static unsigned int f_hidg_poll(struct file *file, poll_table *wait) | 258 | static unsigned int f_hidg_poll(struct file *file, poll_table *wait) |
259 | { | 259 | { |
260 | struct f_hidg *hidg = (struct f_hidg *)file->private_data; | 260 | struct f_hidg *hidg = file->private_data; |
261 | unsigned int ret = 0; | 261 | unsigned int ret = 0; |
262 | 262 | ||
263 | poll_wait(file, &hidg->read_queue, wait); | 263 | poll_wait(file, &hidg->read_queue, wait); |
diff --git a/drivers/usb/gadget/f_loopback.c b/drivers/usb/gadget/f_loopback.c index e91d1b16d9be..43225879c3cd 100644 --- a/drivers/usb/gadget/f_loopback.c +++ b/drivers/usb/gadget/f_loopback.c | |||
@@ -324,7 +324,7 @@ static void loopback_disable(struct usb_function *f) | |||
324 | 324 | ||
325 | /*-------------------------------------------------------------------------*/ | 325 | /*-------------------------------------------------------------------------*/ |
326 | 326 | ||
327 | static int __init loopback_bind_config(struct usb_configuration *c) | 327 | static int __ref loopback_bind_config(struct usb_configuration *c) |
328 | { | 328 | { |
329 | struct f_loopback *loop; | 329 | struct f_loopback *loop; |
330 | int status; | 330 | int status; |
@@ -346,7 +346,7 @@ static int __init loopback_bind_config(struct usb_configuration *c) | |||
346 | return status; | 346 | return status; |
347 | } | 347 | } |
348 | 348 | ||
349 | static struct usb_configuration loopback_driver = { | 349 | static struct usb_configuration loopback_driver = { |
350 | .label = "loopback", | 350 | .label = "loopback", |
351 | .strings = loopback_strings, | 351 | .strings = loopback_strings, |
352 | .bind = loopback_bind_config, | 352 | .bind = loopback_bind_config, |
diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index 4ce899c9b165..32cce029f65c 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c | |||
@@ -316,6 +316,27 @@ static const char fsg_string_interface[] = "Mass Storage"; | |||
316 | /*-------------------------------------------------------------------------*/ | 316 | /*-------------------------------------------------------------------------*/ |
317 | 317 | ||
318 | struct fsg_dev; | 318 | struct fsg_dev; |
319 | struct fsg_common; | ||
320 | |||
321 | /* FSF callback functions */ | ||
322 | struct fsg_operations { | ||
323 | /* Callback function to call when thread exits. If no | ||
324 | * callback is set or it returns value lower then zero MSF | ||
325 | * will force eject all LUNs it operates on (including those | ||
326 | * marked as non-removable or with prevent_medium_removal flag | ||
327 | * set). */ | ||
328 | int (*thread_exits)(struct fsg_common *common); | ||
329 | |||
330 | /* Called prior to ejection. Negative return means error, | ||
331 | * zero means to continue with ejection, positive means not to | ||
332 | * eject. */ | ||
333 | int (*pre_eject)(struct fsg_common *common, | ||
334 | struct fsg_lun *lun, int num); | ||
335 | /* Called after ejection. Negative return means error, zero | ||
336 | * or positive is just a success. */ | ||
337 | int (*post_eject)(struct fsg_common *common, | ||
338 | struct fsg_lun *lun, int num); | ||
339 | }; | ||
319 | 340 | ||
320 | 341 | ||
321 | /* Data shared by all the FSG instances. */ | 342 | /* Data shared by all the FSG instances. */ |
@@ -333,7 +354,6 @@ struct fsg_common { | |||
333 | struct usb_ep *ep0; /* Copy of gadget->ep0 */ | 354 | struct usb_ep *ep0; /* Copy of gadget->ep0 */ |
334 | struct usb_request *ep0req; /* Copy of cdev->req */ | 355 | struct usb_request *ep0req; /* Copy of cdev->req */ |
335 | unsigned int ep0_req_tag; | 356 | unsigned int ep0_req_tag; |
336 | const char *ep0req_name; | ||
337 | 357 | ||
338 | struct fsg_buffhd *next_buffhd_to_fill; | 358 | struct fsg_buffhd *next_buffhd_to_fill; |
339 | struct fsg_buffhd *next_buffhd_to_drain; | 359 | struct fsg_buffhd *next_buffhd_to_drain; |
@@ -369,8 +389,8 @@ struct fsg_common { | |||
369 | struct completion thread_notifier; | 389 | struct completion thread_notifier; |
370 | struct task_struct *thread_task; | 390 | struct task_struct *thread_task; |
371 | 391 | ||
372 | /* Callback function to call when thread exits. */ | 392 | /* Callback functions. */ |
373 | int (*thread_exits)(struct fsg_common *common); | 393 | const struct fsg_operations *ops; |
374 | /* Gadget's private data. */ | 394 | /* Gadget's private data. */ |
375 | void *private_data; | 395 | void *private_data; |
376 | 396 | ||
@@ -394,12 +414,8 @@ struct fsg_config { | |||
394 | const char *lun_name_format; | 414 | const char *lun_name_format; |
395 | const char *thread_name; | 415 | const char *thread_name; |
396 | 416 | ||
397 | /* Callback function to call when thread exits. If no | 417 | /* Callback functions. */ |
398 | * callback is set or it returns value lower then zero MSF | 418 | const struct fsg_operations *ops; |
399 | * will force eject all LUNs it operates on (including those | ||
400 | * marked as non-removable or with prevent_medium_removal flag | ||
401 | * set). */ | ||
402 | int (*thread_exits)(struct fsg_common *common); | ||
403 | /* Gadget's private data. */ | 419 | /* Gadget's private data. */ |
404 | void *private_data; | 420 | void *private_data; |
405 | 421 | ||
@@ -435,6 +451,7 @@ static inline int __fsg_is_set(struct fsg_common *common, | |||
435 | if (common->fsg) | 451 | if (common->fsg) |
436 | return 1; | 452 | return 1; |
437 | ERROR(common, "common->fsg is NULL in %s at %u\n", func, line); | 453 | ERROR(common, "common->fsg is NULL in %s at %u\n", func, line); |
454 | WARN_ON(1); | ||
438 | return 0; | 455 | return 0; |
439 | } | 456 | } |
440 | 457 | ||
@@ -623,8 +640,6 @@ static int fsg_setup(struct usb_function *f, | |||
623 | 640 | ||
624 | /* Respond with data/status */ | 641 | /* Respond with data/status */ |
625 | req->length = min((u16)1, w_length); | 642 | req->length = min((u16)1, w_length); |
626 | fsg->common->ep0req_name = | ||
627 | ctrl->bRequestType & USB_DIR_IN ? "ep0-in" : "ep0-out"; | ||
628 | return ep0_queue(fsg->common); | 643 | return ep0_queue(fsg->common); |
629 | } | 644 | } |
630 | 645 | ||
@@ -1395,43 +1410,55 @@ static int do_start_stop(struct fsg_common *common) | |||
1395 | } else if (!curlun->removable) { | 1410 | } else if (!curlun->removable) { |
1396 | curlun->sense_data = SS_INVALID_COMMAND; | 1411 | curlun->sense_data = SS_INVALID_COMMAND; |
1397 | return -EINVAL; | 1412 | return -EINVAL; |
1398 | } | 1413 | } else if ((common->cmnd[1] & ~0x01) != 0 || /* Mask away Immed */ |
1399 | 1414 | (common->cmnd[4] & ~0x03) != 0) { /* Mask LoEj, Start */ | |
1400 | loej = common->cmnd[4] & 0x02; | ||
1401 | start = common->cmnd[4] & 0x01; | ||
1402 | |||
1403 | /* eject code from file_storage.c:do_start_stop() */ | ||
1404 | |||
1405 | if ((common->cmnd[1] & ~0x01) != 0 || /* Mask away Immed */ | ||
1406 | (common->cmnd[4] & ~0x03) != 0) { /* Mask LoEj, Start */ | ||
1407 | curlun->sense_data = SS_INVALID_FIELD_IN_CDB; | 1415 | curlun->sense_data = SS_INVALID_FIELD_IN_CDB; |
1408 | return -EINVAL; | 1416 | return -EINVAL; |
1409 | } | 1417 | } |
1410 | 1418 | ||
1411 | if (!start) { | 1419 | loej = common->cmnd[4] & 0x02; |
1412 | /* Are we allowed to unload the media? */ | 1420 | start = common->cmnd[4] & 0x01; |
1413 | if (curlun->prevent_medium_removal) { | ||
1414 | LDBG(curlun, "unload attempt prevented\n"); | ||
1415 | curlun->sense_data = SS_MEDIUM_REMOVAL_PREVENTED; | ||
1416 | return -EINVAL; | ||
1417 | } | ||
1418 | if (loej) { /* Simulate an unload/eject */ | ||
1419 | up_read(&common->filesem); | ||
1420 | down_write(&common->filesem); | ||
1421 | fsg_lun_close(curlun); | ||
1422 | up_write(&common->filesem); | ||
1423 | down_read(&common->filesem); | ||
1424 | } | ||
1425 | } else { | ||
1426 | 1421 | ||
1427 | /* Our emulation doesn't support mounting; the medium is | 1422 | /* Our emulation doesn't support mounting; the medium is |
1428 | * available for use as soon as it is loaded. */ | 1423 | * available for use as soon as it is loaded. */ |
1424 | if (start) { | ||
1429 | if (!fsg_lun_is_open(curlun)) { | 1425 | if (!fsg_lun_is_open(curlun)) { |
1430 | curlun->sense_data = SS_MEDIUM_NOT_PRESENT; | 1426 | curlun->sense_data = SS_MEDIUM_NOT_PRESENT; |
1431 | return -EINVAL; | 1427 | return -EINVAL; |
1432 | } | 1428 | } |
1429 | return 0; | ||
1433 | } | 1430 | } |
1434 | return 0; | 1431 | |
1432 | /* Are we allowed to unload the media? */ | ||
1433 | if (curlun->prevent_medium_removal) { | ||
1434 | LDBG(curlun, "unload attempt prevented\n"); | ||
1435 | curlun->sense_data = SS_MEDIUM_REMOVAL_PREVENTED; | ||
1436 | return -EINVAL; | ||
1437 | } | ||
1438 | |||
1439 | if (!loej) | ||
1440 | return 0; | ||
1441 | |||
1442 | /* Simulate an unload/eject */ | ||
1443 | if (common->ops && common->ops->pre_eject) { | ||
1444 | int r = common->ops->pre_eject(common, curlun, | ||
1445 | curlun - common->luns); | ||
1446 | if (unlikely(r < 0)) | ||
1447 | return r; | ||
1448 | else if (r) | ||
1449 | return 0; | ||
1450 | } | ||
1451 | |||
1452 | up_read(&common->filesem); | ||
1453 | down_write(&common->filesem); | ||
1454 | fsg_lun_close(curlun); | ||
1455 | up_write(&common->filesem); | ||
1456 | down_read(&common->filesem); | ||
1457 | |||
1458 | return common->ops && common->ops->post_eject | ||
1459 | ? min(0, common->ops->post_eject(common, curlun, | ||
1460 | curlun - common->luns)) | ||
1461 | : 0; | ||
1435 | } | 1462 | } |
1436 | 1463 | ||
1437 | 1464 | ||
@@ -2610,7 +2637,8 @@ static int fsg_main_thread(void *common_) | |||
2610 | common->thread_task = NULL; | 2637 | common->thread_task = NULL; |
2611 | spin_unlock_irq(&common->lock); | 2638 | spin_unlock_irq(&common->lock); |
2612 | 2639 | ||
2613 | if (!common->thread_exits || common->thread_exits(common) < 0) { | 2640 | if (!common->ops || !common->ops->thread_exits |
2641 | || common->ops->thread_exits(common) < 0) { | ||
2614 | struct fsg_lun *curlun = common->luns; | 2642 | struct fsg_lun *curlun = common->luns; |
2615 | unsigned i = common->nluns; | 2643 | unsigned i = common->nluns; |
2616 | 2644 | ||
@@ -2686,6 +2714,7 @@ static struct fsg_common *fsg_common_init(struct fsg_common *common, | |||
2686 | common->free_storage_on_release = 0; | 2714 | common->free_storage_on_release = 0; |
2687 | } | 2715 | } |
2688 | 2716 | ||
2717 | common->ops = cfg->ops; | ||
2689 | common->private_data = cfg->private_data; | 2718 | common->private_data = cfg->private_data; |
2690 | 2719 | ||
2691 | common->gadget = gadget; | 2720 | common->gadget = gadget; |
@@ -2807,7 +2836,6 @@ buffhds_first_it: | |||
2807 | 2836 | ||
2808 | 2837 | ||
2809 | /* Tell the thread to start working */ | 2838 | /* Tell the thread to start working */ |
2810 | common->thread_exits = cfg->thread_exits; | ||
2811 | common->thread_task = | 2839 | common->thread_task = |
2812 | kthread_create(fsg_main_thread, common, | 2840 | kthread_create(fsg_main_thread, common, |
2813 | OR(cfg->thread_name, "file-storage")); | 2841 | OR(cfg->thread_name, "file-storage")); |
@@ -2990,9 +3018,9 @@ static struct usb_gadget_strings *fsg_strings_array[] = { | |||
2990 | NULL, | 3018 | NULL, |
2991 | }; | 3019 | }; |
2992 | 3020 | ||
2993 | static int fsg_add(struct usb_composite_dev *cdev, | 3021 | static int fsg_bind_config(struct usb_composite_dev *cdev, |
2994 | struct usb_configuration *c, | 3022 | struct usb_configuration *c, |
2995 | struct fsg_common *common) | 3023 | struct fsg_common *common) |
2996 | { | 3024 | { |
2997 | struct fsg_dev *fsg; | 3025 | struct fsg_dev *fsg; |
2998 | int rc; | 3026 | int rc; |
@@ -3024,6 +3052,13 @@ static int fsg_add(struct usb_composite_dev *cdev, | |||
3024 | return rc; | 3052 | return rc; |
3025 | } | 3053 | } |
3026 | 3054 | ||
3055 | static inline int __deprecated __maybe_unused | ||
3056 | fsg_add(struct usb_composite_dev *cdev, | ||
3057 | struct usb_configuration *c, | ||
3058 | struct fsg_common *common) | ||
3059 | { | ||
3060 | return fsg_bind_config(cdev, c, common); | ||
3061 | } | ||
3027 | 3062 | ||
3028 | 3063 | ||
3029 | /************************* Module parameters *************************/ | 3064 | /************************* Module parameters *************************/ |
@@ -3096,8 +3131,8 @@ fsg_config_from_params(struct fsg_config *cfg, | |||
3096 | cfg->product_name = 0; | 3131 | cfg->product_name = 0; |
3097 | cfg->release = 0xffff; | 3132 | cfg->release = 0xffff; |
3098 | 3133 | ||
3099 | cfg->thread_exits = 0; | 3134 | cfg->ops = NULL; |
3100 | cfg->private_data = 0; | 3135 | cfg->private_data = NULL; |
3101 | 3136 | ||
3102 | /* Finalise */ | 3137 | /* Finalise */ |
3103 | cfg->can_stall = params->stall; | 3138 | cfg->can_stall = params->stall; |
diff --git a/drivers/usb/gadget/f_sourcesink.c b/drivers/usb/gadget/f_sourcesink.c index 6d3cc443d914..685d768f336e 100644 --- a/drivers/usb/gadget/f_sourcesink.c +++ b/drivers/usb/gadget/f_sourcesink.c | |||
@@ -404,7 +404,7 @@ static void sourcesink_disable(struct usb_function *f) | |||
404 | 404 | ||
405 | /*-------------------------------------------------------------------------*/ | 405 | /*-------------------------------------------------------------------------*/ |
406 | 406 | ||
407 | static int __init sourcesink_bind_config(struct usb_configuration *c) | 407 | static int __ref sourcesink_bind_config(struct usb_configuration *c) |
408 | { | 408 | { |
409 | struct f_sourcesink *ss; | 409 | struct f_sourcesink *ss; |
410 | int status; | 410 | int status; |
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c index b49d86e3e45b..a857b7ac238c 100644 --- a/drivers/usb/gadget/file_storage.c +++ b/drivers/usb/gadget/file_storage.c | |||
@@ -56,7 +56,7 @@ | |||
56 | * following protocols: RBC (0x01), ATAPI or SFF-8020i (0x02), QIC-157 (0c03), | 56 | * following protocols: RBC (0x01), ATAPI or SFF-8020i (0x02), QIC-157 (0c03), |
57 | * UFI (0x04), SFF-8070i (0x05), and transparent SCSI (0x06), selected by | 57 | * UFI (0x04), SFF-8070i (0x05), and transparent SCSI (0x06), selected by |
58 | * the optional "protocol" module parameter. In addition, the default | 58 | * the optional "protocol" module parameter. In addition, the default |
59 | * Vendor ID, Product ID, and release number can be overridden. | 59 | * Vendor ID, Product ID, release number and serial number can be overridden. |
60 | * | 60 | * |
61 | * There is support for multiple logical units (LUNs), each of which has | 61 | * There is support for multiple logical units (LUNs), each of which has |
62 | * its own backing file. The number of LUNs can be set using the optional | 62 | * its own backing file. The number of LUNs can be set using the optional |
@@ -93,6 +93,8 @@ | |||
93 | * removable Default false, boolean for removable media | 93 | * removable Default false, boolean for removable media |
94 | * luns=N Default N = number of filenames, number of | 94 | * luns=N Default N = number of filenames, number of |
95 | * LUNs to support | 95 | * LUNs to support |
96 | * nofua=b[,b...] Default false, booleans for ignore FUA flag | ||
97 | * in SCSI WRITE(10,12) commands | ||
96 | * stall Default determined according to the type of | 98 | * stall Default determined according to the type of |
97 | * USB device controller (usually true), | 99 | * USB device controller (usually true), |
98 | * boolean to permit the driver to halt | 100 | * boolean to permit the driver to halt |
@@ -106,17 +108,18 @@ | |||
106 | * vendor=0xVVVV Default 0x0525 (NetChip), USB Vendor ID | 108 | * vendor=0xVVVV Default 0x0525 (NetChip), USB Vendor ID |
107 | * product=0xPPPP Default 0xa4a5 (FSG), USB Product ID | 109 | * product=0xPPPP Default 0xa4a5 (FSG), USB Product ID |
108 | * release=0xRRRR Override the USB release number (bcdDevice) | 110 | * release=0xRRRR Override the USB release number (bcdDevice) |
111 | * serial=HHHH... Override serial number (string of hex chars) | ||
109 | * buflen=N Default N=16384, buffer size used (will be | 112 | * buflen=N Default N=16384, buffer size used (will be |
110 | * rounded down to a multiple of | 113 | * rounded down to a multiple of |
111 | * PAGE_CACHE_SIZE) | 114 | * PAGE_CACHE_SIZE) |
112 | * | 115 | * |
113 | * If CONFIG_USB_FILE_STORAGE_TEST is not set, only the "file", "ro", | 116 | * If CONFIG_USB_FILE_STORAGE_TEST is not set, only the "file", "ro", |
114 | * "removable", "luns", "stall", and "cdrom" options are available; default | 117 | * "removable", "luns", "nofua", "stall", and "cdrom" options are available; |
115 | * values are used for everything else. | 118 | * default values are used for everything else. |
116 | * | 119 | * |
117 | * The pathnames of the backing files and the ro settings are available in | 120 | * The pathnames of the backing files and the ro settings are available in |
118 | * the attribute files "file" and "ro" in the lun<n> subdirectory of the | 121 | * the attribute files "file", "nofua", and "ro" in the lun<n> subdirectory of |
119 | * gadget's sysfs directory. If the "removable" option is set, writing to | 122 | * the gadget's sysfs directory. If the "removable" option is set, writing to |
120 | * these files will simulate ejecting/loading the medium (writing an empty | 123 | * these files will simulate ejecting/loading the medium (writing an empty |
121 | * line means eject) and adjusting a write-enable tab. Changes to the ro | 124 | * line means eject) and adjusting a write-enable tab. Changes to the ro |
122 | * setting are not allowed when the medium is loaded or if CD-ROM emulation | 125 | * setting are not allowed when the medium is loaded or if CD-ROM emulation |
@@ -270,6 +273,8 @@ | |||
270 | 273 | ||
271 | #define DRIVER_DESC "File-backed Storage Gadget" | 274 | #define DRIVER_DESC "File-backed Storage Gadget" |
272 | #define DRIVER_NAME "g_file_storage" | 275 | #define DRIVER_NAME "g_file_storage" |
276 | /* DRIVER_VERSION must be at least 6 characters long, as it is used | ||
277 | * to generate a fallback serial number. */ | ||
273 | #define DRIVER_VERSION "20 November 2008" | 278 | #define DRIVER_VERSION "20 November 2008" |
274 | 279 | ||
275 | static char fsg_string_manufacturer[64]; | 280 | static char fsg_string_manufacturer[64]; |
@@ -301,8 +306,10 @@ MODULE_LICENSE("Dual BSD/GPL"); | |||
301 | static struct { | 306 | static struct { |
302 | char *file[FSG_MAX_LUNS]; | 307 | char *file[FSG_MAX_LUNS]; |
303 | int ro[FSG_MAX_LUNS]; | 308 | int ro[FSG_MAX_LUNS]; |
309 | int nofua[FSG_MAX_LUNS]; | ||
304 | unsigned int num_filenames; | 310 | unsigned int num_filenames; |
305 | unsigned int num_ros; | 311 | unsigned int num_ros; |
312 | unsigned int num_nofuas; | ||
306 | unsigned int nluns; | 313 | unsigned int nluns; |
307 | 314 | ||
308 | int removable; | 315 | int removable; |
@@ -314,6 +321,7 @@ static struct { | |||
314 | unsigned short vendor; | 321 | unsigned short vendor; |
315 | unsigned short product; | 322 | unsigned short product; |
316 | unsigned short release; | 323 | unsigned short release; |
324 | char *serial; | ||
317 | unsigned int buflen; | 325 | unsigned int buflen; |
318 | 326 | ||
319 | int transport_type; | 327 | int transport_type; |
@@ -341,6 +349,10 @@ MODULE_PARM_DESC(file, "names of backing files or devices"); | |||
341 | module_param_array_named(ro, mod_data.ro, bool, &mod_data.num_ros, S_IRUGO); | 349 | module_param_array_named(ro, mod_data.ro, bool, &mod_data.num_ros, S_IRUGO); |
342 | MODULE_PARM_DESC(ro, "true to force read-only"); | 350 | MODULE_PARM_DESC(ro, "true to force read-only"); |
343 | 351 | ||
352 | module_param_array_named(nofua, mod_data.nofua, bool, &mod_data.num_nofuas, | ||
353 | S_IRUGO); | ||
354 | MODULE_PARM_DESC(nofua, "true to ignore SCSI WRITE(10,12) FUA bit"); | ||
355 | |||
344 | module_param_named(luns, mod_data.nluns, uint, S_IRUGO); | 356 | module_param_named(luns, mod_data.nluns, uint, S_IRUGO); |
345 | MODULE_PARM_DESC(luns, "number of LUNs"); | 357 | MODULE_PARM_DESC(luns, "number of LUNs"); |
346 | 358 | ||
@@ -353,6 +365,8 @@ MODULE_PARM_DESC(stall, "false to prevent bulk stalls"); | |||
353 | module_param_named(cdrom, mod_data.cdrom, bool, S_IRUGO); | 365 | module_param_named(cdrom, mod_data.cdrom, bool, S_IRUGO); |
354 | MODULE_PARM_DESC(cdrom, "true to emulate cdrom instead of disk"); | 366 | MODULE_PARM_DESC(cdrom, "true to emulate cdrom instead of disk"); |
355 | 367 | ||
368 | module_param_named(serial, mod_data.serial, charp, S_IRUGO); | ||
369 | MODULE_PARM_DESC(serial, "USB serial number"); | ||
356 | 370 | ||
357 | /* In the non-TEST version, only the module parameters listed above | 371 | /* In the non-TEST version, only the module parameters listed above |
358 | * are available. */ | 372 | * are available. */ |
@@ -1272,7 +1286,8 @@ static int do_write(struct fsg_dev *fsg) | |||
1272 | curlun->sense_data = SS_INVALID_FIELD_IN_CDB; | 1286 | curlun->sense_data = SS_INVALID_FIELD_IN_CDB; |
1273 | return -EINVAL; | 1287 | return -EINVAL; |
1274 | } | 1288 | } |
1275 | if (fsg->cmnd[1] & 0x08) { // FUA | 1289 | /* FUA */ |
1290 | if (!curlun->nofua && (fsg->cmnd[1] & 0x08)) { | ||
1276 | spin_lock(&curlun->filp->f_lock); | 1291 | spin_lock(&curlun->filp->f_lock); |
1277 | curlun->filp->f_flags |= O_DSYNC; | 1292 | curlun->filp->f_flags |= O_DSYNC; |
1278 | spin_unlock(&curlun->filp->f_lock); | 1293 | spin_unlock(&curlun->filp->f_lock); |
@@ -3126,6 +3141,7 @@ static int fsg_main_thread(void *fsg_) | |||
3126 | 3141 | ||
3127 | /* The write permissions and store_xxx pointers are set in fsg_bind() */ | 3142 | /* The write permissions and store_xxx pointers are set in fsg_bind() */ |
3128 | static DEVICE_ATTR(ro, 0444, fsg_show_ro, NULL); | 3143 | static DEVICE_ATTR(ro, 0444, fsg_show_ro, NULL); |
3144 | static DEVICE_ATTR(nofua, 0644, fsg_show_nofua, NULL); | ||
3129 | static DEVICE_ATTR(file, 0444, fsg_show_file, NULL); | 3145 | static DEVICE_ATTR(file, 0444, fsg_show_file, NULL); |
3130 | 3146 | ||
3131 | 3147 | ||
@@ -3197,6 +3213,7 @@ static int __init check_parameters(struct fsg_dev *fsg) | |||
3197 | { | 3213 | { |
3198 | int prot; | 3214 | int prot; |
3199 | int gcnum; | 3215 | int gcnum; |
3216 | int i; | ||
3200 | 3217 | ||
3201 | /* Store the default values */ | 3218 | /* Store the default values */ |
3202 | mod_data.transport_type = USB_PR_BULK; | 3219 | mod_data.transport_type = USB_PR_BULK; |
@@ -3272,13 +3289,65 @@ static int __init check_parameters(struct fsg_dev *fsg) | |||
3272 | ERROR(fsg, "invalid buflen\n"); | 3289 | ERROR(fsg, "invalid buflen\n"); |
3273 | return -ETOOSMALL; | 3290 | return -ETOOSMALL; |
3274 | } | 3291 | } |
3292 | |||
3275 | #endif /* CONFIG_USB_FILE_STORAGE_TEST */ | 3293 | #endif /* CONFIG_USB_FILE_STORAGE_TEST */ |
3276 | 3294 | ||
3295 | /* Serial string handling. | ||
3296 | * On a real device, the serial string would be loaded | ||
3297 | * from permanent storage. */ | ||
3298 | if (mod_data.serial) { | ||
3299 | const char *ch; | ||
3300 | unsigned len = 0; | ||
3301 | |||
3302 | /* Sanity check : | ||
3303 | * The CB[I] specification limits the serial string to | ||
3304 | * 12 uppercase hexadecimal characters. | ||
3305 | * BBB need at least 12 uppercase hexadecimal characters, | ||
3306 | * with a maximum of 126. */ | ||
3307 | for (ch = mod_data.serial; *ch; ++ch) { | ||
3308 | ++len; | ||
3309 | if ((*ch < '0' || *ch > '9') && | ||
3310 | (*ch < 'A' || *ch > 'F')) { /* not uppercase hex */ | ||
3311 | WARNING(fsg, | ||
3312 | "Invalid serial string character: %c; " | ||
3313 | "Failing back to default\n", | ||
3314 | *ch); | ||
3315 | goto fill_serial; | ||
3316 | } | ||
3317 | } | ||
3318 | if (len > 126 || | ||
3319 | (mod_data.transport_type == USB_PR_BULK && len < 12) || | ||
3320 | (mod_data.transport_type != USB_PR_BULK && len > 12)) { | ||
3321 | WARNING(fsg, | ||
3322 | "Invalid serial string length; " | ||
3323 | "Failing back to default\n"); | ||
3324 | goto fill_serial; | ||
3325 | } | ||
3326 | fsg_strings[FSG_STRING_SERIAL - 1].s = mod_data.serial; | ||
3327 | } else { | ||
3328 | WARNING(fsg, | ||
3329 | "Userspace failed to provide serial number; " | ||
3330 | "Failing back to default\n"); | ||
3331 | fill_serial: | ||
3332 | /* Serial number not specified or invalid, make our own. | ||
3333 | * We just encode it from the driver version string, | ||
3334 | * 12 characters to comply with both CB[I] and BBB spec. | ||
3335 | * Warning : Two devices running the same kernel will have | ||
3336 | * the same fallback serial number. */ | ||
3337 | for (i = 0; i < 12; i += 2) { | ||
3338 | unsigned char c = DRIVER_VERSION[i / 2]; | ||
3339 | |||
3340 | if (!c) | ||
3341 | break; | ||
3342 | sprintf(&fsg_string_serial[i], "%02X", c); | ||
3343 | } | ||
3344 | } | ||
3345 | |||
3277 | return 0; | 3346 | return 0; |
3278 | } | 3347 | } |
3279 | 3348 | ||
3280 | 3349 | ||
3281 | static int __init fsg_bind(struct usb_gadget *gadget) | 3350 | static int __ref fsg_bind(struct usb_gadget *gadget) |
3282 | { | 3351 | { |
3283 | struct fsg_dev *fsg = the_fsg; | 3352 | struct fsg_dev *fsg = the_fsg; |
3284 | int rc; | 3353 | int rc; |
@@ -3305,6 +3374,10 @@ static int __init fsg_bind(struct usb_gadget *gadget) | |||
3305 | } | 3374 | } |
3306 | } | 3375 | } |
3307 | 3376 | ||
3377 | /* Only for removable media? */ | ||
3378 | dev_attr_nofua.attr.mode = 0644; | ||
3379 | dev_attr_nofua.store = fsg_store_nofua; | ||
3380 | |||
3308 | /* Find out how many LUNs there should be */ | 3381 | /* Find out how many LUNs there should be */ |
3309 | i = mod_data.nluns; | 3382 | i = mod_data.nluns; |
3310 | if (i == 0) | 3383 | if (i == 0) |
@@ -3330,6 +3403,7 @@ static int __init fsg_bind(struct usb_gadget *gadget) | |||
3330 | curlun->ro = mod_data.cdrom || mod_data.ro[i]; | 3403 | curlun->ro = mod_data.cdrom || mod_data.ro[i]; |
3331 | curlun->initially_ro = curlun->ro; | 3404 | curlun->initially_ro = curlun->ro; |
3332 | curlun->removable = mod_data.removable; | 3405 | curlun->removable = mod_data.removable; |
3406 | curlun->nofua = mod_data.nofua[i]; | ||
3333 | curlun->dev.release = lun_release; | 3407 | curlun->dev.release = lun_release; |
3334 | curlun->dev.parent = &gadget->dev; | 3408 | curlun->dev.parent = &gadget->dev; |
3335 | curlun->dev.driver = &fsg_driver.driver; | 3409 | curlun->dev.driver = &fsg_driver.driver; |
@@ -3344,6 +3418,8 @@ static int __init fsg_bind(struct usb_gadget *gadget) | |||
3344 | if ((rc = device_create_file(&curlun->dev, | 3418 | if ((rc = device_create_file(&curlun->dev, |
3345 | &dev_attr_ro)) != 0 || | 3419 | &dev_attr_ro)) != 0 || |
3346 | (rc = device_create_file(&curlun->dev, | 3420 | (rc = device_create_file(&curlun->dev, |
3421 | &dev_attr_nofua)) != 0 || | ||
3422 | (rc = device_create_file(&curlun->dev, | ||
3347 | &dev_attr_file)) != 0) { | 3423 | &dev_attr_file)) != 0) { |
3348 | device_unregister(&curlun->dev); | 3424 | device_unregister(&curlun->dev); |
3349 | goto out; | 3425 | goto out; |
@@ -3447,16 +3523,6 @@ static int __init fsg_bind(struct usb_gadget *gadget) | |||
3447 | init_utsname()->sysname, init_utsname()->release, | 3523 | init_utsname()->sysname, init_utsname()->release, |
3448 | gadget->name); | 3524 | gadget->name); |
3449 | 3525 | ||
3450 | /* On a real device, serial[] would be loaded from permanent | ||
3451 | * storage. We just encode it from the driver version string. */ | ||
3452 | for (i = 0; i < sizeof fsg_string_serial - 2; i += 2) { | ||
3453 | unsigned char c = DRIVER_VERSION[i / 2]; | ||
3454 | |||
3455 | if (!c) | ||
3456 | break; | ||
3457 | sprintf(&fsg_string_serial[i], "%02X", c); | ||
3458 | } | ||
3459 | |||
3460 | fsg->thread_task = kthread_create(fsg_main_thread, fsg, | 3526 | fsg->thread_task = kthread_create(fsg_main_thread, fsg, |
3461 | "file-storage-gadget"); | 3527 | "file-storage-gadget"); |
3462 | if (IS_ERR(fsg->thread_task)) { | 3528 | if (IS_ERR(fsg->thread_task)) { |
@@ -3478,8 +3544,8 @@ static int __init fsg_bind(struct usb_gadget *gadget) | |||
3478 | if (IS_ERR(p)) | 3544 | if (IS_ERR(p)) |
3479 | p = NULL; | 3545 | p = NULL; |
3480 | } | 3546 | } |
3481 | LINFO(curlun, "ro=%d, file: %s\n", | 3547 | LINFO(curlun, "ro=%d, nofua=%d, file: %s\n", |
3482 | curlun->ro, (p ? p : "(error)")); | 3548 | curlun->ro, curlun->nofua, (p ? p : "(error)")); |
3483 | } | 3549 | } |
3484 | } | 3550 | } |
3485 | kfree(pathbuf); | 3551 | kfree(pathbuf); |
diff --git a/drivers/usb/gadget/g_ffs.c b/drivers/usb/gadget/g_ffs.c index d1af253a9105..a9474f8d5325 100644 --- a/drivers/usb/gadget/g_ffs.c +++ b/drivers/usb/gadget/g_ffs.c | |||
@@ -32,12 +32,13 @@ | |||
32 | # include "u_ether.c" | 32 | # include "u_ether.c" |
33 | 33 | ||
34 | static u8 gfs_hostaddr[ETH_ALEN]; | 34 | static u8 gfs_hostaddr[ETH_ALEN]; |
35 | #else | 35 | # ifdef CONFIG_USB_FUNCTIONFS_ETH |
36 | # if !defined CONFIG_USB_FUNCTIONFS_GENERIC | 36 | static int eth_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN]); |
37 | # define CONFIG_USB_FUNCTIONFS_GENERIC | ||
38 | # endif | 37 | # endif |
38 | #else | ||
39 | # define gether_cleanup() do { } while (0) | 39 | # define gether_cleanup() do { } while (0) |
40 | # define gether_setup(gadget, hostaddr) ((int)0) | 40 | # define gether_setup(gadget, hostaddr) ((int)0) |
41 | # define gfs_hostaddr NULL | ||
41 | #endif | 42 | #endif |
42 | 43 | ||
43 | #include "f_fs.c" | 44 | #include "f_fs.c" |
@@ -107,15 +108,7 @@ static const struct usb_descriptor_header *gfs_otg_desc[] = { | |||
107 | enum { | 108 | enum { |
108 | GFS_STRING_MANUFACTURER_IDX, | 109 | GFS_STRING_MANUFACTURER_IDX, |
109 | GFS_STRING_PRODUCT_IDX, | 110 | GFS_STRING_PRODUCT_IDX, |
110 | #ifdef CONFIG_USB_FUNCTIONFS_RNDIS | 111 | GFS_STRING_FIRST_CONFIG_IDX, |
111 | GFS_STRING_RNDIS_CONFIG_IDX, | ||
112 | #endif | ||
113 | #ifdef CONFIG_USB_FUNCTIONFS_ETH | ||
114 | GFS_STRING_ECM_CONFIG_IDX, | ||
115 | #endif | ||
116 | #ifdef CONFIG_USB_FUNCTIONFS_GENERIC | ||
117 | GFS_STRING_GENERIC_CONFIG_IDX, | ||
118 | #endif | ||
119 | }; | 112 | }; |
120 | 113 | ||
121 | static char gfs_manufacturer[50]; | 114 | static char gfs_manufacturer[50]; |
@@ -126,13 +119,13 @@ static struct usb_string gfs_strings[] = { | |||
126 | [GFS_STRING_MANUFACTURER_IDX].s = gfs_manufacturer, | 119 | [GFS_STRING_MANUFACTURER_IDX].s = gfs_manufacturer, |
127 | [GFS_STRING_PRODUCT_IDX].s = gfs_driver_desc, | 120 | [GFS_STRING_PRODUCT_IDX].s = gfs_driver_desc, |
128 | #ifdef CONFIG_USB_FUNCTIONFS_RNDIS | 121 | #ifdef CONFIG_USB_FUNCTIONFS_RNDIS |
129 | [GFS_STRING_RNDIS_CONFIG_IDX].s = "FunctionFS + RNDIS", | 122 | { .s = "FunctionFS + RNDIS" }, |
130 | #endif | 123 | #endif |
131 | #ifdef CONFIG_USB_FUNCTIONFS_ETH | 124 | #ifdef CONFIG_USB_FUNCTIONFS_ETH |
132 | [GFS_STRING_ECM_CONFIG_IDX].s = "FunctionFS + ECM", | 125 | { .s = "FunctionFS + ECM" }, |
133 | #endif | 126 | #endif |
134 | #ifdef CONFIG_USB_FUNCTIONFS_GENERIC | 127 | #ifdef CONFIG_USB_FUNCTIONFS_GENERIC |
135 | [GFS_STRING_GENERIC_CONFIG_IDX].s = "FunctionFS", | 128 | { .s = "FunctionFS" }, |
136 | #endif | 129 | #endif |
137 | { } /* end of list */ | 130 | { } /* end of list */ |
138 | }; | 131 | }; |
@@ -146,59 +139,33 @@ static struct usb_gadget_strings *gfs_dev_strings[] = { | |||
146 | }; | 139 | }; |
147 | 140 | ||
148 | 141 | ||
142 | |||
143 | struct gfs_configuration { | ||
144 | struct usb_configuration c; | ||
145 | int (*eth)(struct usb_configuration *c, u8 *ethaddr); | ||
146 | } gfs_configurations[] = { | ||
149 | #ifdef CONFIG_USB_FUNCTIONFS_RNDIS | 147 | #ifdef CONFIG_USB_FUNCTIONFS_RNDIS |
150 | static int gfs_do_rndis_config(struct usb_configuration *c); | 148 | { |
151 | 149 | .eth = rndis_bind_config, | |
152 | static struct usb_configuration gfs_rndis_config_driver = { | 150 | }, |
153 | .label = "FunctionFS + RNDIS", | ||
154 | .bind = gfs_do_rndis_config, | ||
155 | .bConfigurationValue = 1, | ||
156 | /* .iConfiguration = DYNAMIC */ | ||
157 | .bmAttributes = USB_CONFIG_ATT_SELFPOWER, | ||
158 | }; | ||
159 | # define gfs_add_rndis_config(cdev) \ | ||
160 | usb_add_config(cdev, &gfs_rndis_config_driver) | ||
161 | #else | ||
162 | # define gfs_add_rndis_config(cdev) 0 | ||
163 | #endif | 151 | #endif |
164 | 152 | ||
165 | |||
166 | #ifdef CONFIG_USB_FUNCTIONFS_ETH | 153 | #ifdef CONFIG_USB_FUNCTIONFS_ETH |
167 | static int gfs_do_ecm_config(struct usb_configuration *c); | 154 | { |
168 | 155 | .eth = eth_bind_config, | |
169 | static struct usb_configuration gfs_ecm_config_driver = { | 156 | }, |
170 | .label = "FunctionFS + ECM", | ||
171 | .bind = gfs_do_ecm_config, | ||
172 | .bConfigurationValue = 1, | ||
173 | /* .iConfiguration = DYNAMIC */ | ||
174 | .bmAttributes = USB_CONFIG_ATT_SELFPOWER, | ||
175 | }; | ||
176 | # define gfs_add_ecm_config(cdev) \ | ||
177 | usb_add_config(cdev, &gfs_ecm_config_driver) | ||
178 | #else | ||
179 | # define gfs_add_ecm_config(cdev) 0 | ||
180 | #endif | 157 | #endif |
181 | 158 | ||
182 | |||
183 | #ifdef CONFIG_USB_FUNCTIONFS_GENERIC | 159 | #ifdef CONFIG_USB_FUNCTIONFS_GENERIC |
184 | static int gfs_do_generic_config(struct usb_configuration *c); | 160 | { |
185 | 161 | }, | |
186 | static struct usb_configuration gfs_generic_config_driver = { | ||
187 | .label = "FunctionFS", | ||
188 | .bind = gfs_do_generic_config, | ||
189 | .bConfigurationValue = 2, | ||
190 | /* .iConfiguration = DYNAMIC */ | ||
191 | .bmAttributes = USB_CONFIG_ATT_SELFPOWER, | ||
192 | }; | ||
193 | # define gfs_add_generic_config(cdev) \ | ||
194 | usb_add_config(cdev, &gfs_generic_config_driver) | ||
195 | #else | ||
196 | # define gfs_add_generic_config(cdev) 0 | ||
197 | #endif | 162 | #endif |
163 | }; | ||
198 | 164 | ||
199 | 165 | ||
200 | static int gfs_bind(struct usb_composite_dev *cdev); | 166 | static int gfs_bind(struct usb_composite_dev *cdev); |
201 | static int gfs_unbind(struct usb_composite_dev *cdev); | 167 | static int gfs_unbind(struct usb_composite_dev *cdev); |
168 | static int gfs_do_config(struct usb_configuration *c); | ||
202 | 169 | ||
203 | static struct usb_composite_driver gfs_driver = { | 170 | static struct usb_composite_driver gfs_driver = { |
204 | .name = gfs_short_name, | 171 | .name = gfs_short_name, |
@@ -267,7 +234,7 @@ static int functionfs_check_dev_callback(const char *dev_name) | |||
267 | 234 | ||
268 | static int gfs_bind(struct usb_composite_dev *cdev) | 235 | static int gfs_bind(struct usb_composite_dev *cdev) |
269 | { | 236 | { |
270 | int ret; | 237 | int ret, i; |
271 | 238 | ||
272 | ENTER(); | 239 | ENTER(); |
273 | 240 | ||
@@ -284,57 +251,32 @@ static int gfs_bind(struct usb_composite_dev *cdev) | |||
284 | snprintf(gfs_manufacturer, sizeof gfs_manufacturer, "%s %s with %s", | 251 | snprintf(gfs_manufacturer, sizeof gfs_manufacturer, "%s %s with %s", |
285 | init_utsname()->sysname, init_utsname()->release, | 252 | init_utsname()->sysname, init_utsname()->release, |
286 | cdev->gadget->name); | 253 | cdev->gadget->name); |
287 | ret = usb_string_id(cdev); | ||
288 | if (unlikely(ret < 0)) | ||
289 | goto error; | ||
290 | gfs_strings[GFS_STRING_MANUFACTURER_IDX].id = ret; | ||
291 | gfs_dev_desc.iManufacturer = ret; | ||
292 | |||
293 | ret = usb_string_id(cdev); | ||
294 | if (unlikely(ret < 0)) | ||
295 | goto error; | ||
296 | gfs_strings[GFS_STRING_PRODUCT_IDX].id = ret; | ||
297 | gfs_dev_desc.iProduct = ret; | ||
298 | |||
299 | #ifdef CONFIG_USB_FUNCTIONFS_RNDIS | ||
300 | ret = usb_string_id(cdev); | ||
301 | if (unlikely(ret < 0)) | ||
302 | goto error; | ||
303 | gfs_strings[GFS_STRING_RNDIS_CONFIG_IDX].id = ret; | ||
304 | gfs_rndis_config_driver.iConfiguration = ret; | ||
305 | #endif | ||
306 | 254 | ||
307 | #ifdef CONFIG_USB_FUNCTIONFS_ETH | 255 | ret = usb_string_ids_tab(cdev, gfs_strings); |
308 | ret = usb_string_id(cdev); | ||
309 | if (unlikely(ret < 0)) | 256 | if (unlikely(ret < 0)) |
310 | goto error; | 257 | goto error; |
311 | gfs_strings[GFS_STRING_ECM_CONFIG_IDX].id = ret; | ||
312 | gfs_ecm_config_driver.iConfiguration = ret; | ||
313 | #endif | ||
314 | 258 | ||
315 | #ifdef CONFIG_USB_FUNCTIONFS_GENERIC | 259 | gfs_dev_desc.iManufacturer = gfs_strings[GFS_STRING_MANUFACTURER_IDX].id; |
316 | ret = usb_string_id(cdev); | 260 | gfs_dev_desc.iProduct = gfs_strings[GFS_STRING_PRODUCT_IDX].id; |
317 | if (unlikely(ret < 0)) | ||
318 | goto error; | ||
319 | gfs_strings[GFS_STRING_GENERIC_CONFIG_IDX].id = ret; | ||
320 | gfs_generic_config_driver.iConfiguration = ret; | ||
321 | #endif | ||
322 | 261 | ||
323 | ret = functionfs_bind(gfs_ffs_data, cdev); | 262 | ret = functionfs_bind(gfs_ffs_data, cdev); |
324 | if (unlikely(ret < 0)) | 263 | if (unlikely(ret < 0)) |
325 | goto error; | 264 | goto error; |
326 | 265 | ||
327 | ret = gfs_add_rndis_config(cdev); | 266 | for (i = 0; i < ARRAY_SIZE(gfs_configurations); ++i) { |
328 | if (unlikely(ret < 0)) | 267 | struct gfs_configuration *c = gfs_configurations + i; |
329 | goto error_unbind; | ||
330 | 268 | ||
331 | ret = gfs_add_ecm_config(cdev); | 269 | ret = GFS_STRING_FIRST_CONFIG_IDX + i; |
332 | if (unlikely(ret < 0)) | 270 | c->c.label = gfs_strings[ret].s; |
333 | goto error_unbind; | 271 | c->c.iConfiguration = gfs_strings[ret].id; |
272 | c->c.bind = gfs_do_config; | ||
273 | c->c.bConfigurationValue = 1 + i; | ||
274 | c->c.bmAttributes = USB_CONFIG_ATT_SELFPOWER; | ||
334 | 275 | ||
335 | ret = gfs_add_generic_config(cdev); | 276 | ret = usb_add_config(cdev, &c->c); |
336 | if (unlikely(ret < 0)) | 277 | if (unlikely(ret < 0)) |
337 | goto error_unbind; | 278 | goto error_unbind; |
279 | } | ||
338 | 280 | ||
339 | return 0; | 281 | return 0; |
340 | 282 | ||
@@ -368,10 +310,10 @@ static int gfs_unbind(struct usb_composite_dev *cdev) | |||
368 | } | 310 | } |
369 | 311 | ||
370 | 312 | ||
371 | static int __gfs_do_config(struct usb_configuration *c, | 313 | static int gfs_do_config(struct usb_configuration *c) |
372 | int (*eth)(struct usb_configuration *c, u8 *ethaddr), | ||
373 | u8 *ethaddr) | ||
374 | { | 314 | { |
315 | struct gfs_configuration *gc = | ||
316 | container_of(c, struct gfs_configuration, c); | ||
375 | int ret; | 317 | int ret; |
376 | 318 | ||
377 | if (WARN_ON(!gfs_ffs_data)) | 319 | if (WARN_ON(!gfs_ffs_data)) |
@@ -382,13 +324,13 @@ static int __gfs_do_config(struct usb_configuration *c, | |||
382 | c->bmAttributes |= USB_CONFIG_ATT_WAKEUP; | 324 | c->bmAttributes |= USB_CONFIG_ATT_WAKEUP; |
383 | } | 325 | } |
384 | 326 | ||
385 | if (eth) { | 327 | if (gc->eth) { |
386 | ret = eth(c, ethaddr); | 328 | ret = gc->eth(c, gfs_hostaddr); |
387 | if (unlikely(ret < 0)) | 329 | if (unlikely(ret < 0)) |
388 | return ret; | 330 | return ret; |
389 | } | 331 | } |
390 | 332 | ||
391 | ret = functionfs_add(c->cdev, c, gfs_ffs_data); | 333 | ret = functionfs_bind_config(c->cdev, c, gfs_ffs_data); |
392 | if (unlikely(ret < 0)) | 334 | if (unlikely(ret < 0)) |
393 | return ret; | 335 | return ret; |
394 | 336 | ||
@@ -406,32 +348,12 @@ static int __gfs_do_config(struct usb_configuration *c, | |||
406 | return 0; | 348 | return 0; |
407 | } | 349 | } |
408 | 350 | ||
409 | #ifdef CONFIG_USB_FUNCTIONFS_RNDIS | ||
410 | static int gfs_do_rndis_config(struct usb_configuration *c) | ||
411 | { | ||
412 | ENTER(); | ||
413 | |||
414 | return __gfs_do_config(c, rndis_bind_config, gfs_hostaddr); | ||
415 | } | ||
416 | #endif | ||
417 | 351 | ||
418 | #ifdef CONFIG_USB_FUNCTIONFS_ETH | 352 | #ifdef CONFIG_USB_FUNCTIONFS_ETH |
419 | static int gfs_do_ecm_config(struct usb_configuration *c) | 353 | static int eth_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN]) |
420 | { | ||
421 | ENTER(); | ||
422 | |||
423 | return __gfs_do_config(c, | ||
424 | can_support_ecm(c->cdev->gadget) | ||
425 | ? ecm_bind_config : geth_bind_config, | ||
426 | gfs_hostaddr); | ||
427 | } | ||
428 | #endif | ||
429 | |||
430 | #ifdef CONFIG_USB_FUNCTIONFS_GENERIC | ||
431 | static int gfs_do_generic_config(struct usb_configuration *c) | ||
432 | { | 354 | { |
433 | ENTER(); | 355 | return can_support_ecm(c->cdev->gadget) |
434 | 356 | ? ecm_bind_config(c, ethaddr) | |
435 | return __gfs_do_config(c, NULL, NULL); | 357 | : geth_bind_config(c, ethaddr); |
436 | } | 358 | } |
437 | #endif | 359 | #endif |
diff --git a/drivers/usb/gadget/gmidi.c b/drivers/usb/gadget/gmidi.c index b7bf88019b06..1b413a5cc3f6 100644 --- a/drivers/usb/gadget/gmidi.c +++ b/drivers/usb/gadget/gmidi.c | |||
@@ -1157,7 +1157,7 @@ fail: | |||
1157 | /* | 1157 | /* |
1158 | * Creates an output endpoint, and initializes output ports. | 1158 | * Creates an output endpoint, and initializes output ports. |
1159 | */ | 1159 | */ |
1160 | static int __init gmidi_bind(struct usb_gadget *gadget) | 1160 | static int __ref gmidi_bind(struct usb_gadget *gadget) |
1161 | { | 1161 | { |
1162 | struct gmidi_device *dev; | 1162 | struct gmidi_device *dev; |
1163 | struct usb_ep *in_ep, *out_ep; | 1163 | struct usb_ep *in_ep, *out_ep; |
diff --git a/drivers/usb/gadget/hid.c b/drivers/usb/gadget/hid.c index 775722686ed8..735495bf8411 100644 --- a/drivers/usb/gadget/hid.c +++ b/drivers/usb/gadget/hid.c | |||
@@ -127,7 +127,7 @@ static struct usb_gadget_strings *dev_strings[] = { | |||
127 | 127 | ||
128 | /****************************** Configurations ******************************/ | 128 | /****************************** Configurations ******************************/ |
129 | 129 | ||
130 | static int __init do_config(struct usb_configuration *c) | 130 | static int __ref do_config(struct usb_configuration *c) |
131 | { | 131 | { |
132 | struct hidg_func_node *e; | 132 | struct hidg_func_node *e; |
133 | int func = 0, status = 0; | 133 | int func = 0, status = 0; |
@@ -156,7 +156,7 @@ static struct usb_configuration config_driver = { | |||
156 | 156 | ||
157 | /****************************** Gadget Bind ******************************/ | 157 | /****************************** Gadget Bind ******************************/ |
158 | 158 | ||
159 | static int __init hid_bind(struct usb_composite_dev *cdev) | 159 | static int __ref hid_bind(struct usb_composite_dev *cdev) |
160 | { | 160 | { |
161 | struct usb_gadget *gadget = cdev->gadget; | 161 | struct usb_gadget *gadget = cdev->gadget; |
162 | struct list_head *tmp; | 162 | struct list_head *tmp; |
diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c index de8a83803505..fc35406fc80c 100644 --- a/drivers/usb/gadget/inode.c +++ b/drivers/usb/gadget/inode.c | |||
@@ -1299,11 +1299,9 @@ static long dev_ioctl (struct file *fd, unsigned code, unsigned long value) | |||
1299 | struct usb_gadget *gadget = dev->gadget; | 1299 | struct usb_gadget *gadget = dev->gadget; |
1300 | long ret = -ENOTTY; | 1300 | long ret = -ENOTTY; |
1301 | 1301 | ||
1302 | if (gadget->ops->ioctl) { | 1302 | if (gadget->ops->ioctl) |
1303 | lock_kernel(); | ||
1304 | ret = gadget->ops->ioctl (gadget, code, value); | 1303 | ret = gadget->ops->ioctl (gadget, code, value); |
1305 | unlock_kernel(); | 1304 | |
1306 | } | ||
1307 | return ret; | 1305 | return ret; |
1308 | } | 1306 | } |
1309 | 1307 | ||
@@ -1867,13 +1865,9 @@ dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr) | |||
1867 | buf += 4; | 1865 | buf += 4; |
1868 | length -= 4; | 1866 | length -= 4; |
1869 | 1867 | ||
1870 | kbuf = kmalloc (length, GFP_KERNEL); | 1868 | kbuf = memdup_user(buf, length); |
1871 | if (!kbuf) | 1869 | if (IS_ERR(kbuf)) |
1872 | return -ENOMEM; | 1870 | return PTR_ERR(kbuf); |
1873 | if (copy_from_user (kbuf, buf, length)) { | ||
1874 | kfree (kbuf); | ||
1875 | return -EFAULT; | ||
1876 | } | ||
1877 | 1871 | ||
1878 | spin_lock_irq (&dev->lock); | 1872 | spin_lock_irq (&dev->lock); |
1879 | value = -EINVAL; | 1873 | value = -EINVAL; |
diff --git a/drivers/usb/gadget/langwell_udc.c b/drivers/usb/gadget/langwell_udc.c index a3913519fd58..c2d2a201f84b 100644 --- a/drivers/usb/gadget/langwell_udc.c +++ b/drivers/usb/gadget/langwell_udc.c | |||
@@ -842,9 +842,9 @@ static int langwell_ep_queue(struct usb_ep *_ep, struct usb_request *_req, | |||
842 | VDBG(dev, "req->mapped = 0\n"); | 842 | VDBG(dev, "req->mapped = 0\n"); |
843 | } | 843 | } |
844 | 844 | ||
845 | DBG(dev, "%s queue req %p, len %u, buf %p, dma 0x%08x\n", | 845 | DBG(dev, "%s queue req %p, len %u, buf %p, dma 0x%08llx\n", |
846 | _ep->name, | 846 | _ep->name, |
847 | _req, _req->length, _req->buf, _req->dma); | 847 | _req, _req->length, _req->buf, (unsigned long long)_req->dma); |
848 | 848 | ||
849 | _req->status = -EINPROGRESS; | 849 | _req->status = -EINPROGRESS; |
850 | _req->actual = 0; | 850 | _req->actual = 0; |
diff --git a/drivers/usb/gadget/mass_storage.c b/drivers/usb/gadget/mass_storage.c index 705cc1f76327..585f2559484d 100644 --- a/drivers/usb/gadget/mass_storage.c +++ b/drivers/usb/gadget/mass_storage.c | |||
@@ -141,9 +141,14 @@ static int msg_thread_exits(struct fsg_common *common) | |||
141 | return 0; | 141 | return 0; |
142 | } | 142 | } |
143 | 143 | ||
144 | static int __init msg_do_config(struct usb_configuration *c) | 144 | static int __ref msg_do_config(struct usb_configuration *c) |
145 | { | 145 | { |
146 | struct fsg_common *common; | 146 | static const struct fsg_operations ops = { |
147 | .thread_exits = msg_thread_exits, | ||
148 | }; | ||
149 | static struct fsg_common common; | ||
150 | |||
151 | struct fsg_common *retp; | ||
147 | struct fsg_config config; | 152 | struct fsg_config config; |
148 | int ret; | 153 | int ret; |
149 | 154 | ||
@@ -153,13 +158,14 @@ static int __init msg_do_config(struct usb_configuration *c) | |||
153 | } | 158 | } |
154 | 159 | ||
155 | fsg_config_from_params(&config, &mod_data); | 160 | fsg_config_from_params(&config, &mod_data); |
156 | config.thread_exits = msg_thread_exits; | 161 | config.ops = &ops; |
157 | common = fsg_common_init(0, c->cdev, &config); | 162 | |
158 | if (IS_ERR(common)) | 163 | retp = fsg_common_init(&common, c->cdev, &config); |
159 | return PTR_ERR(common); | 164 | if (IS_ERR(retp)) |
165 | return PTR_ERR(retp); | ||
160 | 166 | ||
161 | ret = fsg_add(c->cdev, c, common); | 167 | ret = fsg_bind_config(c->cdev, c, &common); |
162 | fsg_common_put(common); | 168 | fsg_common_put(&common); |
163 | return ret; | 169 | return ret; |
164 | } | 170 | } |
165 | 171 | ||
@@ -176,7 +182,7 @@ static struct usb_configuration msg_config_driver = { | |||
176 | /****************************** Gadget Bind ******************************/ | 182 | /****************************** Gadget Bind ******************************/ |
177 | 183 | ||
178 | 184 | ||
179 | static int __init msg_bind(struct usb_composite_dev *cdev) | 185 | static int __ref msg_bind(struct usb_composite_dev *cdev) |
180 | { | 186 | { |
181 | struct usb_gadget *gadget = cdev->gadget; | 187 | struct usb_gadget *gadget = cdev->gadget; |
182 | int status; | 188 | int status; |
diff --git a/drivers/usb/gadget/multi.c b/drivers/usb/gadget/multi.c index a930d7fd7e7a..795d76232167 100644 --- a/drivers/usb/gadget/multi.c +++ b/drivers/usb/gadget/multi.c | |||
@@ -24,6 +24,7 @@ | |||
24 | 24 | ||
25 | #include <linux/kernel.h> | 25 | #include <linux/kernel.h> |
26 | #include <linux/utsname.h> | 26 | #include <linux/utsname.h> |
27 | #include <linux/module.h> | ||
27 | 28 | ||
28 | 29 | ||
29 | #if defined USB_ETH_RNDIS | 30 | #if defined USB_ETH_RNDIS |
@@ -35,14 +36,13 @@ | |||
35 | 36 | ||
36 | 37 | ||
37 | #define DRIVER_DESC "Multifunction Composite Gadget" | 38 | #define DRIVER_DESC "Multifunction Composite Gadget" |
38 | #define DRIVER_VERSION "2009/07/21" | ||
39 | 39 | ||
40 | /*-------------------------------------------------------------------------*/ | 40 | MODULE_DESCRIPTION(DRIVER_DESC); |
41 | MODULE_AUTHOR("Michal Nazarewicz"); | ||
42 | MODULE_LICENSE("GPL"); | ||
41 | 43 | ||
42 | #define MULTI_VENDOR_NUM 0x0525 /* XXX NetChip */ | ||
43 | #define MULTI_PRODUCT_NUM 0xa4ab /* XXX */ | ||
44 | 44 | ||
45 | /*-------------------------------------------------------------------------*/ | 45 | /***************************** All the files... *****************************/ |
46 | 46 | ||
47 | /* | 47 | /* |
48 | * kbuild is not very cooperative with respect to linking separately | 48 | * kbuild is not very cooperative with respect to linking separately |
@@ -57,6 +57,8 @@ | |||
57 | #include "config.c" | 57 | #include "config.c" |
58 | #include "epautoconf.c" | 58 | #include "epautoconf.c" |
59 | 59 | ||
60 | #include "f_mass_storage.c" | ||
61 | |||
60 | #include "u_serial.c" | 62 | #include "u_serial.c" |
61 | #include "f_acm.c" | 63 | #include "f_acm.c" |
62 | 64 | ||
@@ -68,13 +70,24 @@ | |||
68 | #endif | 70 | #endif |
69 | #include "u_ether.c" | 71 | #include "u_ether.c" |
70 | 72 | ||
71 | #undef DBG /* u_ether.c has broken idea about macros */ | ||
72 | #undef VDBG /* so clean up after it */ | ||
73 | #undef ERROR | ||
74 | #undef INFO | ||
75 | #include "f_mass_storage.c" | ||
76 | 73 | ||
77 | /*-------------------------------------------------------------------------*/ | 74 | |
75 | /***************************** Device Descriptor ****************************/ | ||
76 | |||
77 | #define MULTI_VENDOR_NUM 0x0525 /* XXX NetChip */ | ||
78 | #define MULTI_PRODUCT_NUM 0xa4ab /* XXX */ | ||
79 | |||
80 | |||
81 | enum { | ||
82 | __MULTI_NO_CONFIG, | ||
83 | #ifdef CONFIG_USB_G_MULTI_RNDIS | ||
84 | MULTI_RNDIS_CONFIG_NUM, | ||
85 | #endif | ||
86 | #ifdef CONFIG_USB_G_MULTI_CDC | ||
87 | MULTI_CDC_CONFIG_NUM, | ||
88 | #endif | ||
89 | }; | ||
90 | |||
78 | 91 | ||
79 | static struct usb_device_descriptor device_desc = { | 92 | static struct usb_device_descriptor device_desc = { |
80 | .bLength = sizeof device_desc, | 93 | .bLength = sizeof device_desc, |
@@ -82,80 +95,82 @@ static struct usb_device_descriptor device_desc = { | |||
82 | 95 | ||
83 | .bcdUSB = cpu_to_le16(0x0200), | 96 | .bcdUSB = cpu_to_le16(0x0200), |
84 | 97 | ||
85 | /* .bDeviceClass = USB_CLASS_COMM, */ | 98 | .bDeviceClass = USB_CLASS_MISC /* 0xEF */, |
86 | /* .bDeviceSubClass = 0, */ | ||
87 | /* .bDeviceProtocol = 0, */ | ||
88 | .bDeviceClass = 0xEF, | ||
89 | .bDeviceSubClass = 2, | 99 | .bDeviceSubClass = 2, |
90 | .bDeviceProtocol = 1, | 100 | .bDeviceProtocol = 1, |
91 | /* .bMaxPacketSize0 = f(hardware) */ | ||
92 | 101 | ||
93 | /* Vendor and product id can be overridden by module parameters. */ | 102 | /* Vendor and product id can be overridden by module parameters. */ |
94 | .idVendor = cpu_to_le16(MULTI_VENDOR_NUM), | 103 | .idVendor = cpu_to_le16(MULTI_VENDOR_NUM), |
95 | .idProduct = cpu_to_le16(MULTI_PRODUCT_NUM), | 104 | .idProduct = cpu_to_le16(MULTI_PRODUCT_NUM), |
96 | /* .bcdDevice = f(hardware) */ | ||
97 | /* .iManufacturer = DYNAMIC */ | ||
98 | /* .iProduct = DYNAMIC */ | ||
99 | /* NO SERIAL NUMBER */ | ||
100 | .bNumConfigurations = 1, | ||
101 | }; | 105 | }; |
102 | 106 | ||
103 | static struct usb_otg_descriptor otg_descriptor = { | ||
104 | .bLength = sizeof otg_descriptor, | ||
105 | .bDescriptorType = USB_DT_OTG, | ||
106 | |||
107 | /* REVISIT SRP-only hardware is possible, although | ||
108 | * it would not be called "OTG" ... | ||
109 | */ | ||
110 | .bmAttributes = USB_OTG_SRP | USB_OTG_HNP, | ||
111 | }; | ||
112 | 107 | ||
113 | static const struct usb_descriptor_header *otg_desc[] = { | 108 | static const struct usb_descriptor_header *otg_desc[] = { |
114 | (struct usb_descriptor_header *) &otg_descriptor, | 109 | (struct usb_descriptor_header *) &(struct usb_otg_descriptor){ |
110 | .bLength = sizeof(struct usb_otg_descriptor), | ||
111 | .bDescriptorType = USB_DT_OTG, | ||
112 | |||
113 | /* | ||
114 | * REVISIT SRP-only hardware is possible, although | ||
115 | * it would not be called "OTG" ... | ||
116 | */ | ||
117 | .bmAttributes = USB_OTG_SRP | USB_OTG_HNP, | ||
118 | }, | ||
115 | NULL, | 119 | NULL, |
116 | }; | 120 | }; |
117 | 121 | ||
118 | 122 | ||
119 | /* string IDs are assigned dynamically */ | 123 | enum { |
120 | 124 | MULTI_STRING_MANUFACTURER_IDX, | |
121 | #define STRING_MANUFACTURER_IDX 0 | 125 | MULTI_STRING_PRODUCT_IDX, |
122 | #define STRING_PRODUCT_IDX 1 | 126 | #ifdef CONFIG_USB_G_MULTI_RNDIS |
127 | MULTI_STRING_RNDIS_CONFIG_IDX, | ||
128 | #endif | ||
129 | #ifdef CONFIG_USB_G_MULTI_CDC | ||
130 | MULTI_STRING_CDC_CONFIG_IDX, | ||
131 | #endif | ||
132 | }; | ||
123 | 133 | ||
124 | static char manufacturer[50]; | 134 | static char manufacturer[50]; |
125 | 135 | ||
126 | static struct usb_string strings_dev[] = { | 136 | static struct usb_string strings_dev[] = { |
127 | [STRING_MANUFACTURER_IDX].s = manufacturer, | 137 | [MULTI_STRING_MANUFACTURER_IDX].s = manufacturer, |
128 | [STRING_PRODUCT_IDX].s = DRIVER_DESC, | 138 | [MULTI_STRING_PRODUCT_IDX].s = DRIVER_DESC, |
139 | #ifdef CONFIG_USB_G_MULTI_RNDIS | ||
140 | [MULTI_STRING_RNDIS_CONFIG_IDX].s = "Multifunction with RNDIS", | ||
141 | #endif | ||
142 | #ifdef CONFIG_USB_G_MULTI_CDC | ||
143 | [MULTI_STRING_CDC_CONFIG_IDX].s = "Multifunction with CDC ECM", | ||
144 | #endif | ||
129 | { } /* end of list */ | 145 | { } /* end of list */ |
130 | }; | 146 | }; |
131 | 147 | ||
132 | static struct usb_gadget_strings stringtab_dev = { | ||
133 | .language = 0x0409, /* en-us */ | ||
134 | .strings = strings_dev, | ||
135 | }; | ||
136 | |||
137 | static struct usb_gadget_strings *dev_strings[] = { | 148 | static struct usb_gadget_strings *dev_strings[] = { |
138 | &stringtab_dev, | 149 | &(struct usb_gadget_strings){ |
150 | .language = 0x0409, /* en-us */ | ||
151 | .strings = strings_dev, | ||
152 | }, | ||
139 | NULL, | 153 | NULL, |
140 | }; | 154 | }; |
141 | 155 | ||
142 | static u8 hostaddr[ETH_ALEN]; | ||
143 | 156 | ||
144 | 157 | ||
145 | 158 | ||
146 | /****************************** Configurations ******************************/ | 159 | /****************************** Configurations ******************************/ |
147 | 160 | ||
148 | static struct fsg_module_parameters mod_data = { | 161 | static struct fsg_module_parameters fsg_mod_data = { .stall = 1 }; |
149 | .stall = 1 | 162 | FSG_MODULE_PARAMETERS(/* no prefix */, fsg_mod_data); |
150 | }; | 163 | |
151 | FSG_MODULE_PARAMETERS(/* no prefix */, mod_data); | 164 | static struct fsg_common fsg_common; |
165 | |||
166 | static u8 hostaddr[ETH_ALEN]; | ||
152 | 167 | ||
153 | static struct fsg_common *fsg_common; | ||
154 | 168 | ||
169 | /********** RNDIS **********/ | ||
155 | 170 | ||
156 | #ifdef USB_ETH_RNDIS | 171 | #ifdef USB_ETH_RNDIS |
157 | 172 | ||
158 | static int __init rndis_do_config(struct usb_configuration *c) | 173 | static __ref int rndis_do_config(struct usb_configuration *c) |
159 | { | 174 | { |
160 | int ret; | 175 | int ret; |
161 | 176 | ||
@@ -172,26 +187,42 @@ static int __init rndis_do_config(struct usb_configuration *c) | |||
172 | if (ret < 0) | 187 | if (ret < 0) |
173 | return ret; | 188 | return ret; |
174 | 189 | ||
175 | ret = fsg_add(c->cdev, c, fsg_common); | 190 | ret = fsg_bind_config(c->cdev, c, &fsg_common); |
176 | if (ret < 0) | 191 | if (ret < 0) |
177 | return ret; | 192 | return ret; |
178 | 193 | ||
179 | return 0; | 194 | return 0; |
180 | } | 195 | } |
181 | 196 | ||
182 | static struct usb_configuration rndis_config_driver = { | 197 | static int rndis_config_register(struct usb_composite_dev *cdev) |
183 | .label = "Multifunction Composite (RNDIS + MS + ACM)", | 198 | { |
184 | .bind = rndis_do_config, | 199 | static struct usb_configuration config = { |
185 | .bConfigurationValue = 2, | 200 | .bind = rndis_do_config, |
186 | /* .iConfiguration = DYNAMIC */ | 201 | .bConfigurationValue = MULTI_RNDIS_CONFIG_NUM, |
187 | .bmAttributes = USB_CONFIG_ATT_SELFPOWER, | 202 | .bmAttributes = USB_CONFIG_ATT_SELFPOWER, |
188 | }; | 203 | }; |
204 | |||
205 | config.label = strings_dev[MULTI_STRING_RNDIS_CONFIG_IDX].s; | ||
206 | config.iConfiguration = strings_dev[MULTI_STRING_RNDIS_CONFIG_IDX].id; | ||
207 | |||
208 | return usb_add_config(cdev, &config); | ||
209 | } | ||
210 | |||
211 | #else | ||
212 | |||
213 | static int rndis_config_register(struct usb_composite_dev *cdev) | ||
214 | { | ||
215 | return 0; | ||
216 | } | ||
189 | 217 | ||
190 | #endif | 218 | #endif |
191 | 219 | ||
220 | |||
221 | /********** CDC ECM **********/ | ||
222 | |||
192 | #ifdef CONFIG_USB_G_MULTI_CDC | 223 | #ifdef CONFIG_USB_G_MULTI_CDC |
193 | 224 | ||
194 | static int __init cdc_do_config(struct usb_configuration *c) | 225 | static __ref int cdc_do_config(struct usb_configuration *c) |
195 | { | 226 | { |
196 | int ret; | 227 | int ret; |
197 | 228 | ||
@@ -208,20 +239,33 @@ static int __init cdc_do_config(struct usb_configuration *c) | |||
208 | if (ret < 0) | 239 | if (ret < 0) |
209 | return ret; | 240 | return ret; |
210 | 241 | ||
211 | ret = fsg_add(c->cdev, c, fsg_common); | 242 | ret = fsg_bind_config(c->cdev, c, &fsg_common); |
212 | if (ret < 0) | 243 | if (ret < 0) |
213 | return ret; | 244 | return ret; |
214 | 245 | ||
215 | return 0; | 246 | return 0; |
216 | } | 247 | } |
217 | 248 | ||
218 | static struct usb_configuration cdc_config_driver = { | 249 | static int cdc_config_register(struct usb_composite_dev *cdev) |
219 | .label = "Multifunction Composite (CDC + MS + ACM)", | 250 | { |
220 | .bind = cdc_do_config, | 251 | static struct usb_configuration config = { |
221 | .bConfigurationValue = 1, | 252 | .bind = cdc_do_config, |
222 | /* .iConfiguration = DYNAMIC */ | 253 | .bConfigurationValue = MULTI_CDC_CONFIG_NUM, |
223 | .bmAttributes = USB_CONFIG_ATT_SELFPOWER, | 254 | .bmAttributes = USB_CONFIG_ATT_SELFPOWER, |
224 | }; | 255 | }; |
256 | |||
257 | config.label = strings_dev[MULTI_STRING_CDC_CONFIG_IDX].s; | ||
258 | config.iConfiguration = strings_dev[MULTI_STRING_CDC_CONFIG_IDX].id; | ||
259 | |||
260 | return usb_add_config(cdev, &config); | ||
261 | } | ||
262 | |||
263 | #else | ||
264 | |||
265 | static int cdc_config_register(struct usb_composite_dev *cdev) | ||
266 | { | ||
267 | return 0; | ||
268 | } | ||
225 | 269 | ||
226 | #endif | 270 | #endif |
227 | 271 | ||
@@ -230,7 +274,7 @@ static struct usb_configuration cdc_config_driver = { | |||
230 | /****************************** Gadget Bind ******************************/ | 274 | /****************************** Gadget Bind ******************************/ |
231 | 275 | ||
232 | 276 | ||
233 | static int __init multi_bind(struct usb_composite_dev *cdev) | 277 | static int __ref multi_bind(struct usb_composite_dev *cdev) |
234 | { | 278 | { |
235 | struct usb_gadget *gadget = cdev->gadget; | 279 | struct usb_gadget *gadget = cdev->gadget; |
236 | int status, gcnum; | 280 | int status, gcnum; |
@@ -252,67 +296,56 @@ static int __init multi_bind(struct usb_composite_dev *cdev) | |||
252 | goto fail0; | 296 | goto fail0; |
253 | 297 | ||
254 | /* set up mass storage function */ | 298 | /* set up mass storage function */ |
255 | fsg_common = fsg_common_from_params(0, cdev, &mod_data); | 299 | { |
256 | if (IS_ERR(fsg_common)) { | 300 | void *retp; |
257 | status = PTR_ERR(fsg_common); | 301 | retp = fsg_common_from_params(&fsg_common, cdev, &fsg_mod_data); |
258 | goto fail1; | 302 | if (IS_ERR(retp)) { |
303 | status = PTR_ERR(retp); | ||
304 | goto fail1; | ||
305 | } | ||
259 | } | 306 | } |
260 | 307 | ||
261 | 308 | /* set bcdDevice */ | |
262 | gcnum = usb_gadget_controller_number(gadget); | 309 | gcnum = usb_gadget_controller_number(gadget); |
263 | if (gcnum >= 0) | 310 | if (gcnum >= 0) { |
264 | device_desc.bcdDevice = cpu_to_le16(0x0300 | gcnum); | 311 | device_desc.bcdDevice = cpu_to_le16(0x0300 | gcnum); |
265 | else { | 312 | } else { |
266 | /* We assume that can_support_ecm() tells the truth; | 313 | WARNING(cdev, "controller '%s' not recognized\n", gadget->name); |
267 | * but if the controller isn't recognized at all then | ||
268 | * that assumption is a bit more likely to be wrong. | ||
269 | */ | ||
270 | WARNING(cdev, "controller '%s' not recognized\n", | ||
271 | gadget->name); | ||
272 | device_desc.bcdDevice = cpu_to_le16(0x0300 | 0x0099); | 314 | device_desc.bcdDevice = cpu_to_le16(0x0300 | 0x0099); |
273 | } | 315 | } |
274 | 316 | ||
275 | 317 | /* allocate string descriptor numbers */ | |
276 | /* Allocate string descriptor numbers ... note that string | ||
277 | * contents can be overridden by the composite_dev glue. | ||
278 | */ | ||
279 | |||
280 | /* device descriptor strings: manufacturer, product */ | ||
281 | snprintf(manufacturer, sizeof manufacturer, "%s %s with %s", | 318 | snprintf(manufacturer, sizeof manufacturer, "%s %s with %s", |
282 | init_utsname()->sysname, init_utsname()->release, | 319 | init_utsname()->sysname, init_utsname()->release, |
283 | gadget->name); | 320 | gadget->name); |
284 | status = usb_string_id(cdev); | ||
285 | if (status < 0) | ||
286 | goto fail2; | ||
287 | strings_dev[STRING_MANUFACTURER_IDX].id = status; | ||
288 | device_desc.iManufacturer = status; | ||
289 | 321 | ||
290 | status = usb_string_id(cdev); | 322 | status = usb_string_ids_tab(cdev, strings_dev); |
291 | if (status < 0) | 323 | if (unlikely(status < 0)) |
292 | goto fail2; | 324 | goto fail2; |
293 | strings_dev[STRING_PRODUCT_IDX].id = status; | ||
294 | device_desc.iProduct = status; | ||
295 | 325 | ||
296 | #ifdef USB_ETH_RNDIS | 326 | device_desc.iManufacturer = |
297 | /* register our first configuration */ | 327 | strings_dev[MULTI_STRING_MANUFACTURER_IDX].id; |
298 | status = usb_add_config(cdev, &rndis_config_driver); | 328 | device_desc.iProduct = |
299 | if (status < 0) | 329 | strings_dev[MULTI_STRING_PRODUCT_IDX].id; |
330 | |||
331 | /* register configurations */ | ||
332 | status = rndis_config_register(cdev); | ||
333 | if (unlikely(status < 0)) | ||
300 | goto fail2; | 334 | goto fail2; |
301 | #endif | ||
302 | 335 | ||
303 | #ifdef CONFIG_USB_G_MULTI_CDC | 336 | status = cdc_config_register(cdev); |
304 | /* register our second configuration */ | 337 | if (unlikely(status < 0)) |
305 | status = usb_add_config(cdev, &cdc_config_driver); | ||
306 | if (status < 0) | ||
307 | goto fail2; | 338 | goto fail2; |
308 | #endif | ||
309 | 339 | ||
310 | dev_info(&gadget->dev, DRIVER_DESC ", version: " DRIVER_VERSION "\n"); | 340 | /* we're done */ |
311 | fsg_common_put(fsg_common); | 341 | dev_info(&gadget->dev, DRIVER_DESC "\n"); |
342 | fsg_common_put(&fsg_common); | ||
312 | return 0; | 343 | return 0; |
313 | 344 | ||
345 | |||
346 | /* error recovery */ | ||
314 | fail2: | 347 | fail2: |
315 | fsg_common_put(fsg_common); | 348 | fsg_common_put(&fsg_common); |
316 | fail1: | 349 | fail1: |
317 | gserial_cleanup(); | 350 | gserial_cleanup(); |
318 | fail0: | 351 | fail0: |
@@ -339,18 +372,15 @@ static struct usb_composite_driver multi_driver = { | |||
339 | .unbind = __exit_p(multi_unbind), | 372 | .unbind = __exit_p(multi_unbind), |
340 | }; | 373 | }; |
341 | 374 | ||
342 | MODULE_DESCRIPTION(DRIVER_DESC); | ||
343 | MODULE_AUTHOR("Michal Nazarewicz"); | ||
344 | MODULE_LICENSE("GPL"); | ||
345 | 375 | ||
346 | static int __init g_multi_init(void) | 376 | static int __init multi_init(void) |
347 | { | 377 | { |
348 | return usb_composite_register(&multi_driver); | 378 | return usb_composite_register(&multi_driver); |
349 | } | 379 | } |
350 | module_init(g_multi_init); | 380 | module_init(multi_init); |
351 | 381 | ||
352 | static void __exit g_multi_cleanup(void) | 382 | static void __exit multi_exit(void) |
353 | { | 383 | { |
354 | usb_composite_unregister(&multi_driver); | 384 | usb_composite_unregister(&multi_driver); |
355 | } | 385 | } |
356 | module_exit(g_multi_cleanup); | 386 | module_exit(multi_exit); |
diff --git a/drivers/usb/gadget/printer.c b/drivers/usb/gadget/printer.c index 4c3ac5c42237..cf241c371a71 100644 --- a/drivers/usb/gadget/printer.c +++ b/drivers/usb/gadget/printer.c | |||
@@ -25,7 +25,7 @@ | |||
25 | #include <linux/ioport.h> | 25 | #include <linux/ioport.h> |
26 | #include <linux/sched.h> | 26 | #include <linux/sched.h> |
27 | #include <linux/slab.h> | 27 | #include <linux/slab.h> |
28 | #include <linux/smp_lock.h> | 28 | #include <linux/mutex.h> |
29 | #include <linux/errno.h> | 29 | #include <linux/errno.h> |
30 | #include <linux/init.h> | 30 | #include <linux/init.h> |
31 | #include <linux/timer.h> | 31 | #include <linux/timer.h> |
@@ -70,6 +70,7 @@ | |||
70 | #define DRIVER_DESC "Printer Gadget" | 70 | #define DRIVER_DESC "Printer Gadget" |
71 | #define DRIVER_VERSION "2007 OCT 06" | 71 | #define DRIVER_VERSION "2007 OCT 06" |
72 | 72 | ||
73 | static DEFINE_MUTEX(printer_mutex); | ||
73 | static const char shortname [] = "printer"; | 74 | static const char shortname [] = "printer"; |
74 | static const char driver_desc [] = DRIVER_DESC; | 75 | static const char driver_desc [] = DRIVER_DESC; |
75 | 76 | ||
@@ -476,7 +477,7 @@ printer_open(struct inode *inode, struct file *fd) | |||
476 | unsigned long flags; | 477 | unsigned long flags; |
477 | int ret = -EBUSY; | 478 | int ret = -EBUSY; |
478 | 479 | ||
479 | lock_kernel(); | 480 | mutex_lock(&printer_mutex); |
480 | dev = container_of(inode->i_cdev, struct printer_dev, printer_cdev); | 481 | dev = container_of(inode->i_cdev, struct printer_dev, printer_cdev); |
481 | 482 | ||
482 | spin_lock_irqsave(&dev->lock, flags); | 483 | spin_lock_irqsave(&dev->lock, flags); |
@@ -492,7 +493,7 @@ printer_open(struct inode *inode, struct file *fd) | |||
492 | spin_unlock_irqrestore(&dev->lock, flags); | 493 | spin_unlock_irqrestore(&dev->lock, flags); |
493 | 494 | ||
494 | DBG(dev, "printer_open returned %x\n", ret); | 495 | DBG(dev, "printer_open returned %x\n", ret); |
495 | unlock_kernel(); | 496 | mutex_unlock(&printer_mutex); |
496 | return ret; | 497 | return ret; |
497 | } | 498 | } |
498 | 499 | ||
@@ -1346,7 +1347,7 @@ printer_unbind(struct usb_gadget *gadget) | |||
1346 | set_gadget_data(gadget, NULL); | 1347 | set_gadget_data(gadget, NULL); |
1347 | } | 1348 | } |
1348 | 1349 | ||
1349 | static int __init | 1350 | static int __ref |
1350 | printer_bind(struct usb_gadget *gadget) | 1351 | printer_bind(struct usb_gadget *gadget) |
1351 | { | 1352 | { |
1352 | struct printer_dev *dev; | 1353 | struct printer_dev *dev; |
diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c index 26193eceb323..521ebed0118d 100644 --- a/drivers/usb/gadget/s3c-hsotg.c +++ b/drivers/usb/gadget/s3c-hsotg.c | |||
@@ -12,6 +12,8 @@ | |||
12 | * published by the Free Software Foundation. | 12 | * published by the Free Software Foundation. |
13 | */ | 13 | */ |
14 | 14 | ||
15 | #define DEBUG | ||
16 | |||
15 | #include <linux/kernel.h> | 17 | #include <linux/kernel.h> |
16 | #include <linux/module.h> | 18 | #include <linux/module.h> |
17 | #include <linux/spinlock.h> | 19 | #include <linux/spinlock.h> |
@@ -23,6 +25,7 @@ | |||
23 | #include <linux/delay.h> | 25 | #include <linux/delay.h> |
24 | #include <linux/io.h> | 26 | #include <linux/io.h> |
25 | #include <linux/slab.h> | 27 | #include <linux/slab.h> |
28 | #include <linux/clk.h> | ||
26 | 29 | ||
27 | #include <linux/usb/ch9.h> | 30 | #include <linux/usb/ch9.h> |
28 | #include <linux/usb/gadget.h> | 31 | #include <linux/usb/gadget.h> |
@@ -33,6 +36,7 @@ | |||
33 | #include <plat/regs-usb-hsotg.h> | 36 | #include <plat/regs-usb-hsotg.h> |
34 | #include <mach/regs-sys.h> | 37 | #include <mach/regs-sys.h> |
35 | #include <plat/udc-hs.h> | 38 | #include <plat/udc-hs.h> |
39 | #include <plat/cpu.h> | ||
36 | 40 | ||
37 | #define DMA_ADDR_INVALID (~((dma_addr_t)0)) | 41 | #define DMA_ADDR_INVALID (~((dma_addr_t)0)) |
38 | 42 | ||
@@ -91,7 +95,9 @@ struct s3c_hsotg_req; | |||
91 | * For periodic IN endpoints, we have fifo_size and fifo_load to try | 95 | * For periodic IN endpoints, we have fifo_size and fifo_load to try |
92 | * and keep track of the amount of data in the periodic FIFO for each | 96 | * and keep track of the amount of data in the periodic FIFO for each |
93 | * of these as we don't have a status register that tells us how much | 97 | * of these as we don't have a status register that tells us how much |
94 | * is in each of them. | 98 | * is in each of them. (note, this may actually be useless information |
99 | * as in shared-fifo mode periodic in acts like a single-frame packet | ||
100 | * buffer than a fifo) | ||
95 | */ | 101 | */ |
96 | struct s3c_hsotg_ep { | 102 | struct s3c_hsotg_ep { |
97 | struct usb_ep ep; | 103 | struct usb_ep ep; |
@@ -128,6 +134,7 @@ struct s3c_hsotg_ep { | |||
128 | * @regs: The memory area mapped for accessing registers. | 134 | * @regs: The memory area mapped for accessing registers. |
129 | * @regs_res: The resource that was allocated when claiming register space. | 135 | * @regs_res: The resource that was allocated when claiming register space. |
130 | * @irq: The IRQ number we are using | 136 | * @irq: The IRQ number we are using |
137 | * @dedicated_fifos: Set if the hardware has dedicated IN-EP fifos. | ||
131 | * @debug_root: root directrory for debugfs. | 138 | * @debug_root: root directrory for debugfs. |
132 | * @debug_file: main status file for debugfs. | 139 | * @debug_file: main status file for debugfs. |
133 | * @debug_fifo: FIFO status file for debugfs. | 140 | * @debug_fifo: FIFO status file for debugfs. |
@@ -145,6 +152,9 @@ struct s3c_hsotg { | |||
145 | void __iomem *regs; | 152 | void __iomem *regs; |
146 | struct resource *regs_res; | 153 | struct resource *regs_res; |
147 | int irq; | 154 | int irq; |
155 | struct clk *clk; | ||
156 | |||
157 | unsigned int dedicated_fifos:1; | ||
148 | 158 | ||
149 | struct dentry *debug_root; | 159 | struct dentry *debug_root; |
150 | struct dentry *debug_file; | 160 | struct dentry *debug_file; |
@@ -310,11 +320,11 @@ static void s3c_hsotg_init_fifo(struct s3c_hsotg *hsotg) | |||
310 | hsotg->regs + S3C_GNPTXFSIZ); | 320 | hsotg->regs + S3C_GNPTXFSIZ); |
311 | */ | 321 | */ |
312 | 322 | ||
313 | /* set FIFO sizes to 2048/0x1C0 */ | 323 | /* set FIFO sizes to 2048/1024 */ |
314 | 324 | ||
315 | writel(2048, hsotg->regs + S3C_GRXFSIZ); | 325 | writel(2048, hsotg->regs + S3C_GRXFSIZ); |
316 | writel(S3C_GNPTXFSIZ_NPTxFStAddr(2048) | | 326 | writel(S3C_GNPTXFSIZ_NPTxFStAddr(2048) | |
317 | S3C_GNPTXFSIZ_NPTxFDep(0x1C0), | 327 | S3C_GNPTXFSIZ_NPTxFDep(1024), |
318 | hsotg->regs + S3C_GNPTXFSIZ); | 328 | hsotg->regs + S3C_GNPTXFSIZ); |
319 | 329 | ||
320 | /* arange all the rest of the TX FIFOs, as some versions of this | 330 | /* arange all the rest of the TX FIFOs, as some versions of this |
@@ -464,7 +474,7 @@ static int s3c_hsotg_write_fifo(struct s3c_hsotg *hsotg, | |||
464 | if (to_write == 0) | 474 | if (to_write == 0) |
465 | return 0; | 475 | return 0; |
466 | 476 | ||
467 | if (periodic) { | 477 | if (periodic && !hsotg->dedicated_fifos) { |
468 | u32 epsize = readl(hsotg->regs + S3C_DIEPTSIZ(hs_ep->index)); | 478 | u32 epsize = readl(hsotg->regs + S3C_DIEPTSIZ(hs_ep->index)); |
469 | int size_left; | 479 | int size_left; |
470 | int size_done; | 480 | int size_done; |
@@ -474,6 +484,14 @@ static int s3c_hsotg_write_fifo(struct s3c_hsotg *hsotg, | |||
474 | 484 | ||
475 | size_left = S3C_DxEPTSIZ_XferSize_GET(epsize); | 485 | size_left = S3C_DxEPTSIZ_XferSize_GET(epsize); |
476 | 486 | ||
487 | /* if shared fifo, we cannot write anything until the | ||
488 | * previous data has been completely sent. | ||
489 | */ | ||
490 | if (hs_ep->fifo_load != 0) { | ||
491 | s3c_hsotg_en_gsint(hsotg, S3C_GINTSTS_PTxFEmp); | ||
492 | return -ENOSPC; | ||
493 | } | ||
494 | |||
477 | dev_dbg(hsotg->dev, "%s: left=%d, load=%d, fifo=%d, size %d\n", | 495 | dev_dbg(hsotg->dev, "%s: left=%d, load=%d, fifo=%d, size %d\n", |
478 | __func__, size_left, | 496 | __func__, size_left, |
479 | hs_ep->size_loaded, hs_ep->fifo_load, hs_ep->fifo_size); | 497 | hs_ep->size_loaded, hs_ep->fifo_load, hs_ep->fifo_size); |
@@ -494,6 +512,11 @@ static int s3c_hsotg_write_fifo(struct s3c_hsotg *hsotg, | |||
494 | s3c_hsotg_en_gsint(hsotg, S3C_GINTSTS_PTxFEmp); | 512 | s3c_hsotg_en_gsint(hsotg, S3C_GINTSTS_PTxFEmp); |
495 | return -ENOSPC; | 513 | return -ENOSPC; |
496 | } | 514 | } |
515 | } else if (hsotg->dedicated_fifos && hs_ep->index != 0) { | ||
516 | can_write = readl(hsotg->regs + S3C_DTXFSTS(hs_ep->index)); | ||
517 | |||
518 | can_write &= 0xffff; | ||
519 | can_write *= 4; | ||
497 | } else { | 520 | } else { |
498 | if (S3C_GNPTXSTS_NPTxQSpcAvail_GET(gnptxsts) == 0) { | 521 | if (S3C_GNPTXSTS_NPTxQSpcAvail_GET(gnptxsts) == 0) { |
499 | dev_dbg(hsotg->dev, | 522 | dev_dbg(hsotg->dev, |
@@ -505,6 +528,7 @@ static int s3c_hsotg_write_fifo(struct s3c_hsotg *hsotg, | |||
505 | } | 528 | } |
506 | 529 | ||
507 | can_write = S3C_GNPTXSTS_NPTxFSpcAvail_GET(gnptxsts); | 530 | can_write = S3C_GNPTXSTS_NPTxFSpcAvail_GET(gnptxsts); |
531 | can_write *= 4; /* fifo size is in 32bit quantities. */ | ||
508 | } | 532 | } |
509 | 533 | ||
510 | dev_dbg(hsotg->dev, "%s: GNPTXSTS=%08x, can=%d, to=%d, mps %d\n", | 534 | dev_dbg(hsotg->dev, "%s: GNPTXSTS=%08x, can=%d, to=%d, mps %d\n", |
@@ -517,6 +541,17 @@ static int s3c_hsotg_write_fifo(struct s3c_hsotg *hsotg, | |||
517 | if (can_write > 512) | 541 | if (can_write > 512) |
518 | can_write = 512; | 542 | can_write = 512; |
519 | 543 | ||
544 | /* limit the write to one max-packet size worth of data, but allow | ||
545 | * the transfer to return that it did not run out of fifo space | ||
546 | * doing it. */ | ||
547 | if (to_write > hs_ep->ep.maxpacket) { | ||
548 | to_write = hs_ep->ep.maxpacket; | ||
549 | |||
550 | s3c_hsotg_en_gsint(hsotg, | ||
551 | periodic ? S3C_GINTSTS_PTxFEmp : | ||
552 | S3C_GINTSTS_NPTxFEmp); | ||
553 | } | ||
554 | |||
520 | /* see if we can write data */ | 555 | /* see if we can write data */ |
521 | 556 | ||
522 | if (to_write > can_write) { | 557 | if (to_write > can_write) { |
@@ -579,12 +614,10 @@ static unsigned get_ep_limit(struct s3c_hsotg_ep *hs_ep) | |||
579 | maxsize = S3C_DxEPTSIZ_XferSize_LIMIT + 1; | 614 | maxsize = S3C_DxEPTSIZ_XferSize_LIMIT + 1; |
580 | maxpkt = S3C_DxEPTSIZ_PktCnt_LIMIT + 1; | 615 | maxpkt = S3C_DxEPTSIZ_PktCnt_LIMIT + 1; |
581 | } else { | 616 | } else { |
617 | maxsize = 64+64; | ||
582 | if (hs_ep->dir_in) { | 618 | if (hs_ep->dir_in) { |
583 | /* maxsize = S3C_DIEPTSIZ0_XferSize_LIMIT + 1; */ | ||
584 | maxsize = 64+64+1; | ||
585 | maxpkt = S3C_DIEPTSIZ0_PktCnt_LIMIT + 1; | 619 | maxpkt = S3C_DIEPTSIZ0_PktCnt_LIMIT + 1; |
586 | } else { | 620 | } else { |
587 | maxsize = 0x3f; | ||
588 | maxpkt = 2; | 621 | maxpkt = 2; |
589 | } | 622 | } |
590 | } | 623 | } |
@@ -1353,6 +1386,9 @@ static void s3c_hsotg_rx_data(struct s3c_hsotg *hsotg, int ep_idx, int size) | |||
1353 | read_ptr = hs_req->req.actual; | 1386 | read_ptr = hs_req->req.actual; |
1354 | max_req = hs_req->req.length - read_ptr; | 1387 | max_req = hs_req->req.length - read_ptr; |
1355 | 1388 | ||
1389 | dev_dbg(hsotg->dev, "%s: read %d/%d, done %d/%d\n", | ||
1390 | __func__, to_read, max_req, read_ptr, hs_req->req.length); | ||
1391 | |||
1356 | if (to_read > max_req) { | 1392 | if (to_read > max_req) { |
1357 | /* more data appeared than we where willing | 1393 | /* more data appeared than we where willing |
1358 | * to deal with in this request. | 1394 | * to deal with in this request. |
@@ -1362,9 +1398,6 @@ static void s3c_hsotg_rx_data(struct s3c_hsotg *hsotg, int ep_idx, int size) | |||
1362 | WARN_ON_ONCE(1); | 1398 | WARN_ON_ONCE(1); |
1363 | } | 1399 | } |
1364 | 1400 | ||
1365 | dev_dbg(hsotg->dev, "%s: read %d/%d, done %d/%d\n", | ||
1366 | __func__, to_read, max_req, read_ptr, hs_req->req.length); | ||
1367 | |||
1368 | hs_ep->total_data += to_read; | 1401 | hs_ep->total_data += to_read; |
1369 | hs_req->req.actual += to_read; | 1402 | hs_req->req.actual += to_read; |
1370 | to_read = DIV_ROUND_UP(to_read, 4); | 1403 | to_read = DIV_ROUND_UP(to_read, 4); |
@@ -1433,9 +1466,11 @@ static void s3c_hsotg_send_zlp(struct s3c_hsotg *hsotg, | |||
1433 | static void s3c_hsotg_handle_outdone(struct s3c_hsotg *hsotg, | 1466 | static void s3c_hsotg_handle_outdone(struct s3c_hsotg *hsotg, |
1434 | int epnum, bool was_setup) | 1467 | int epnum, bool was_setup) |
1435 | { | 1468 | { |
1469 | u32 epsize = readl(hsotg->regs + S3C_DOEPTSIZ(epnum)); | ||
1436 | struct s3c_hsotg_ep *hs_ep = &hsotg->eps[epnum]; | 1470 | struct s3c_hsotg_ep *hs_ep = &hsotg->eps[epnum]; |
1437 | struct s3c_hsotg_req *hs_req = hs_ep->req; | 1471 | struct s3c_hsotg_req *hs_req = hs_ep->req; |
1438 | struct usb_request *req = &hs_req->req; | 1472 | struct usb_request *req = &hs_req->req; |
1473 | unsigned size_left = S3C_DxEPTSIZ_XferSize_GET(epsize); | ||
1439 | int result = 0; | 1474 | int result = 0; |
1440 | 1475 | ||
1441 | if (!hs_req) { | 1476 | if (!hs_req) { |
@@ -1444,9 +1479,7 @@ static void s3c_hsotg_handle_outdone(struct s3c_hsotg *hsotg, | |||
1444 | } | 1479 | } |
1445 | 1480 | ||
1446 | if (using_dma(hsotg)) { | 1481 | if (using_dma(hsotg)) { |
1447 | u32 epsize = readl(hsotg->regs + S3C_DOEPTSIZ(epnum)); | ||
1448 | unsigned size_done; | 1482 | unsigned size_done; |
1449 | unsigned size_left; | ||
1450 | 1483 | ||
1451 | /* Calculate the size of the transfer by checking how much | 1484 | /* Calculate the size of the transfer by checking how much |
1452 | * is left in the endpoint size register and then working it | 1485 | * is left in the endpoint size register and then working it |
@@ -1456,14 +1489,18 @@ static void s3c_hsotg_handle_outdone(struct s3c_hsotg *hsotg, | |||
1456 | * so may overshoot/undershoot the transfer. | 1489 | * so may overshoot/undershoot the transfer. |
1457 | */ | 1490 | */ |
1458 | 1491 | ||
1459 | size_left = S3C_DxEPTSIZ_XferSize_GET(epsize); | ||
1460 | |||
1461 | size_done = hs_ep->size_loaded - size_left; | 1492 | size_done = hs_ep->size_loaded - size_left; |
1462 | size_done += hs_ep->last_load; | 1493 | size_done += hs_ep->last_load; |
1463 | 1494 | ||
1464 | req->actual = size_done; | 1495 | req->actual = size_done; |
1465 | } | 1496 | } |
1466 | 1497 | ||
1498 | /* if there is more request to do, schedule new transfer */ | ||
1499 | if (req->actual < req->length && size_left == 0) { | ||
1500 | s3c_hsotg_start_req(hsotg, hs_ep, hs_req, true); | ||
1501 | return; | ||
1502 | } | ||
1503 | |||
1467 | if (req->actual < req->length && req->short_not_ok) { | 1504 | if (req->actual < req->length && req->short_not_ok) { |
1468 | dev_dbg(hsotg->dev, "%s: got %d/%d (short not ok) => error\n", | 1505 | dev_dbg(hsotg->dev, "%s: got %d/%d (short not ok) => error\n", |
1469 | __func__, req->actual, req->length); | 1506 | __func__, req->actual, req->length); |
@@ -1758,7 +1795,7 @@ static void s3c_hsotg_epint(struct s3c_hsotg *hsotg, unsigned int idx, | |||
1758 | if (dir_in) { | 1795 | if (dir_in) { |
1759 | s3c_hsotg_complete_in(hsotg, hs_ep); | 1796 | s3c_hsotg_complete_in(hsotg, hs_ep); |
1760 | 1797 | ||
1761 | if (idx == 0) | 1798 | if (idx == 0 && !hs_ep->req) |
1762 | s3c_hsotg_enqueue_setup(hsotg); | 1799 | s3c_hsotg_enqueue_setup(hsotg); |
1763 | } else if (using_dma(hsotg)) { | 1800 | } else if (using_dma(hsotg)) { |
1764 | /* We're using DMA, we need to fire an OutDone here | 1801 | /* We're using DMA, we need to fire an OutDone here |
@@ -1818,6 +1855,15 @@ static void s3c_hsotg_epint(struct s3c_hsotg *hsotg, unsigned int idx, | |||
1818 | __func__, idx); | 1855 | __func__, idx); |
1819 | clear |= S3C_DIEPMSK_INTknEPMisMsk; | 1856 | clear |= S3C_DIEPMSK_INTknEPMisMsk; |
1820 | } | 1857 | } |
1858 | |||
1859 | /* FIFO has space or is empty (see GAHBCFG) */ | ||
1860 | if (hsotg->dedicated_fifos && | ||
1861 | ints & S3C_DIEPMSK_TxFIFOEmpty) { | ||
1862 | dev_dbg(hsotg->dev, "%s: ep%d: TxFIFOEmpty\n", | ||
1863 | __func__, idx); | ||
1864 | s3c_hsotg_trytx(hsotg, hs_ep); | ||
1865 | clear |= S3C_DIEPMSK_TxFIFOEmpty; | ||
1866 | } | ||
1821 | } | 1867 | } |
1822 | 1868 | ||
1823 | writel(clear, hsotg->regs + epint_reg); | 1869 | writel(clear, hsotg->regs + epint_reg); |
@@ -2071,17 +2117,12 @@ irq_retry: | |||
2071 | kill_all_requests(hsotg, &hsotg->eps[0], -ECONNRESET, true); | 2117 | kill_all_requests(hsotg, &hsotg->eps[0], -ECONNRESET, true); |
2072 | 2118 | ||
2073 | /* it seems after a reset we can end up with a situation | 2119 | /* it seems after a reset we can end up with a situation |
2074 | * where the TXFIFO still has data in it... try flushing | 2120 | * where the TXFIFO still has data in it... the docs |
2075 | * it to remove anything that may still be in it. | 2121 | * suggest resetting all the fifos, so use the init_fifo |
2122 | * code to relayout and flush the fifos. | ||
2076 | */ | 2123 | */ |
2077 | 2124 | ||
2078 | if (1) { | 2125 | s3c_hsotg_init_fifo(hsotg); |
2079 | writel(S3C_GRSTCTL_TxFNum(0) | S3C_GRSTCTL_TxFFlsh, | ||
2080 | hsotg->regs + S3C_GRSTCTL); | ||
2081 | |||
2082 | dev_info(hsotg->dev, "GNPTXSTS=%08x\n", | ||
2083 | readl(hsotg->regs + S3C_GNPTXSTS)); | ||
2084 | } | ||
2085 | 2126 | ||
2086 | s3c_hsotg_enqueue_setup(hsotg); | 2127 | s3c_hsotg_enqueue_setup(hsotg); |
2087 | 2128 | ||
@@ -2274,6 +2315,12 @@ static int s3c_hsotg_ep_enable(struct usb_ep *ep, | |||
2274 | break; | 2315 | break; |
2275 | } | 2316 | } |
2276 | 2317 | ||
2318 | /* if the hardware has dedicated fifos, we must give each IN EP | ||
2319 | * a unique tx-fifo even if it is non-periodic. | ||
2320 | */ | ||
2321 | if (dir_in && hsotg->dedicated_fifos) | ||
2322 | epctrl |= S3C_DxEPCTL_TxFNum(index); | ||
2323 | |||
2277 | /* for non control endpoints, set PID to D0 */ | 2324 | /* for non control endpoints, set PID to D0 */ |
2278 | if (index) | 2325 | if (index) |
2279 | epctrl |= S3C_DxEPCTL_SetD0PID; | 2326 | epctrl |= S3C_DxEPCTL_SetD0PID; |
@@ -2563,7 +2610,8 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver) | |||
2563 | 2610 | ||
2564 | writel(S3C_DIEPMSK_TimeOUTMsk | S3C_DIEPMSK_AHBErrMsk | | 2611 | writel(S3C_DIEPMSK_TimeOUTMsk | S3C_DIEPMSK_AHBErrMsk | |
2565 | S3C_DIEPMSK_INTknEPMisMsk | | 2612 | S3C_DIEPMSK_INTknEPMisMsk | |
2566 | S3C_DIEPMSK_EPDisbldMsk | S3C_DIEPMSK_XferComplMsk, | 2613 | S3C_DIEPMSK_EPDisbldMsk | S3C_DIEPMSK_XferComplMsk | |
2614 | ((hsotg->dedicated_fifos) ? S3C_DIEPMSK_TxFIFOEmpty : 0), | ||
2567 | hsotg->regs + S3C_DIEPMSK); | 2615 | hsotg->regs + S3C_DIEPMSK); |
2568 | 2616 | ||
2569 | /* don't need XferCompl, we get that from RXFIFO in slave mode. In | 2617 | /* don't need XferCompl, we get that from RXFIFO in slave mode. In |
@@ -2732,7 +2780,7 @@ static void __devinit s3c_hsotg_initep(struct s3c_hsotg *hsotg, | |||
2732 | */ | 2780 | */ |
2733 | 2781 | ||
2734 | ptxfifo = readl(hsotg->regs + S3C_DPTXFSIZn(epnum)); | 2782 | ptxfifo = readl(hsotg->regs + S3C_DPTXFSIZn(epnum)); |
2735 | hs_ep->fifo_size = S3C_DPTXFSIZn_DPTxFSize_GET(ptxfifo); | 2783 | hs_ep->fifo_size = S3C_DPTXFSIZn_DPTxFSize_GET(ptxfifo) * 4; |
2736 | 2784 | ||
2737 | /* if we're using dma, we need to set the next-endpoint pointer | 2785 | /* if we're using dma, we need to set the next-endpoint pointer |
2738 | * to be something valid. | 2786 | * to be something valid. |
@@ -2753,13 +2801,33 @@ static void __devinit s3c_hsotg_initep(struct s3c_hsotg *hsotg, | |||
2753 | */ | 2801 | */ |
2754 | static void s3c_hsotg_otgreset(struct s3c_hsotg *hsotg) | 2802 | static void s3c_hsotg_otgreset(struct s3c_hsotg *hsotg) |
2755 | { | 2803 | { |
2756 | u32 osc; | 2804 | struct clk *xusbxti; |
2805 | u32 pwr, osc; | ||
2757 | 2806 | ||
2758 | writel(0, S3C_PHYPWR); | 2807 | pwr = readl(S3C_PHYPWR); |
2808 | pwr &= ~0x19; | ||
2809 | writel(pwr, S3C_PHYPWR); | ||
2759 | mdelay(1); | 2810 | mdelay(1); |
2760 | 2811 | ||
2761 | osc = hsotg->plat->is_osc ? S3C_PHYCLK_EXT_OSC : 0; | 2812 | osc = hsotg->plat->is_osc ? S3C_PHYCLK_EXT_OSC : 0; |
2762 | 2813 | ||
2814 | xusbxti = clk_get(hsotg->dev, "xusbxti"); | ||
2815 | if (xusbxti && !IS_ERR(xusbxti)) { | ||
2816 | switch (clk_get_rate(xusbxti)) { | ||
2817 | case 12*MHZ: | ||
2818 | osc |= S3C_PHYCLK_CLKSEL_12M; | ||
2819 | break; | ||
2820 | case 24*MHZ: | ||
2821 | osc |= S3C_PHYCLK_CLKSEL_24M; | ||
2822 | break; | ||
2823 | default: | ||
2824 | case 48*MHZ: | ||
2825 | /* default reference clock */ | ||
2826 | break; | ||
2827 | } | ||
2828 | clk_put(xusbxti); | ||
2829 | } | ||
2830 | |||
2763 | writel(osc | 0x10, S3C_PHYCLK); | 2831 | writel(osc | 0x10, S3C_PHYCLK); |
2764 | 2832 | ||
2765 | /* issue a full set of resets to the otg and core */ | 2833 | /* issue a full set of resets to the otg and core */ |
@@ -2772,6 +2840,8 @@ static void s3c_hsotg_otgreset(struct s3c_hsotg *hsotg) | |||
2772 | 2840 | ||
2773 | static void s3c_hsotg_init(struct s3c_hsotg *hsotg) | 2841 | static void s3c_hsotg_init(struct s3c_hsotg *hsotg) |
2774 | { | 2842 | { |
2843 | u32 cfg4; | ||
2844 | |||
2775 | /* unmask subset of endpoint interrupts */ | 2845 | /* unmask subset of endpoint interrupts */ |
2776 | 2846 | ||
2777 | writel(S3C_DIEPMSK_TimeOUTMsk | S3C_DIEPMSK_AHBErrMsk | | 2847 | writel(S3C_DIEPMSK_TimeOUTMsk | S3C_DIEPMSK_AHBErrMsk | |
@@ -2807,6 +2877,14 @@ static void s3c_hsotg_init(struct s3c_hsotg *hsotg) | |||
2807 | 2877 | ||
2808 | writel(using_dma(hsotg) ? S3C_GAHBCFG_DMAEn : 0x0, | 2878 | writel(using_dma(hsotg) ? S3C_GAHBCFG_DMAEn : 0x0, |
2809 | hsotg->regs + S3C_GAHBCFG); | 2879 | hsotg->regs + S3C_GAHBCFG); |
2880 | |||
2881 | /* check hardware configuration */ | ||
2882 | |||
2883 | cfg4 = readl(hsotg->regs + 0x50); | ||
2884 | hsotg->dedicated_fifos = (cfg4 >> 25) & 1; | ||
2885 | |||
2886 | dev_info(hsotg->dev, "%s fifos\n", | ||
2887 | hsotg->dedicated_fifos ? "dedicated" : "shared"); | ||
2810 | } | 2888 | } |
2811 | 2889 | ||
2812 | static void s3c_hsotg_dump(struct s3c_hsotg *hsotg) | 2890 | static void s3c_hsotg_dump(struct s3c_hsotg *hsotg) |
@@ -3181,13 +3259,20 @@ static int __devinit s3c_hsotg_probe(struct platform_device *pdev) | |||
3181 | hsotg->dev = dev; | 3259 | hsotg->dev = dev; |
3182 | hsotg->plat = plat; | 3260 | hsotg->plat = plat; |
3183 | 3261 | ||
3262 | hsotg->clk = clk_get(&pdev->dev, "otg"); | ||
3263 | if (IS_ERR(hsotg->clk)) { | ||
3264 | dev_err(dev, "cannot get otg clock\n"); | ||
3265 | ret = -EINVAL; | ||
3266 | goto err_mem; | ||
3267 | } | ||
3268 | |||
3184 | platform_set_drvdata(pdev, hsotg); | 3269 | platform_set_drvdata(pdev, hsotg); |
3185 | 3270 | ||
3186 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 3271 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
3187 | if (!res) { | 3272 | if (!res) { |
3188 | dev_err(dev, "cannot find register resource 0\n"); | 3273 | dev_err(dev, "cannot find register resource 0\n"); |
3189 | ret = -EINVAL; | 3274 | ret = -EINVAL; |
3190 | goto err_mem; | 3275 | goto err_clk; |
3191 | } | 3276 | } |
3192 | 3277 | ||
3193 | hsotg->regs_res = request_mem_region(res->start, resource_size(res), | 3278 | hsotg->regs_res = request_mem_region(res->start, resource_size(res), |
@@ -3195,7 +3280,7 @@ static int __devinit s3c_hsotg_probe(struct platform_device *pdev) | |||
3195 | if (!hsotg->regs_res) { | 3280 | if (!hsotg->regs_res) { |
3196 | dev_err(dev, "cannot reserve registers\n"); | 3281 | dev_err(dev, "cannot reserve registers\n"); |
3197 | ret = -ENOENT; | 3282 | ret = -ENOENT; |
3198 | goto err_mem; | 3283 | goto err_clk; |
3199 | } | 3284 | } |
3200 | 3285 | ||
3201 | hsotg->regs = ioremap(res->start, resource_size(res)); | 3286 | hsotg->regs = ioremap(res->start, resource_size(res)); |
@@ -3248,6 +3333,8 @@ static int __devinit s3c_hsotg_probe(struct platform_device *pdev) | |||
3248 | 3333 | ||
3249 | /* reset the system */ | 3334 | /* reset the system */ |
3250 | 3335 | ||
3336 | clk_enable(hsotg->clk); | ||
3337 | |||
3251 | s3c_hsotg_gate(pdev, true); | 3338 | s3c_hsotg_gate(pdev, true); |
3252 | 3339 | ||
3253 | s3c_hsotg_otgreset(hsotg); | 3340 | s3c_hsotg_otgreset(hsotg); |
@@ -3271,7 +3358,8 @@ err_regs: | |||
3271 | err_regs_res: | 3358 | err_regs_res: |
3272 | release_resource(hsotg->regs_res); | 3359 | release_resource(hsotg->regs_res); |
3273 | kfree(hsotg->regs_res); | 3360 | kfree(hsotg->regs_res); |
3274 | 3361 | err_clk: | |
3362 | clk_put(hsotg->clk); | ||
3275 | err_mem: | 3363 | err_mem: |
3276 | kfree(hsotg); | 3364 | kfree(hsotg); |
3277 | return ret; | 3365 | return ret; |
@@ -3293,6 +3381,9 @@ static int __devexit s3c_hsotg_remove(struct platform_device *pdev) | |||
3293 | 3381 | ||
3294 | s3c_hsotg_gate(pdev, false); | 3382 | s3c_hsotg_gate(pdev, false); |
3295 | 3383 | ||
3384 | clk_disable(hsotg->clk); | ||
3385 | clk_put(hsotg->clk); | ||
3386 | |||
3296 | kfree(hsotg); | 3387 | kfree(hsotg); |
3297 | return 0; | 3388 | return 0; |
3298 | } | 3389 | } |
diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c index f46a60962dab..b22eedbc7dc5 100644 --- a/drivers/usb/gadget/serial.c +++ b/drivers/usb/gadget/serial.c | |||
@@ -137,7 +137,7 @@ MODULE_PARM_DESC(n_ports, "number of ports to create, default=1"); | |||
137 | 137 | ||
138 | /*-------------------------------------------------------------------------*/ | 138 | /*-------------------------------------------------------------------------*/ |
139 | 139 | ||
140 | static int __init serial_bind_config(struct usb_configuration *c) | 140 | static int __ref serial_bind_config(struct usb_configuration *c) |
141 | { | 141 | { |
142 | unsigned i; | 142 | unsigned i; |
143 | int status = 0; | 143 | int status = 0; |
@@ -161,7 +161,7 @@ static struct usb_configuration serial_config_driver = { | |||
161 | .bmAttributes = USB_CONFIG_ATT_SELFPOWER, | 161 | .bmAttributes = USB_CONFIG_ATT_SELFPOWER, |
162 | }; | 162 | }; |
163 | 163 | ||
164 | static int __init gs_bind(struct usb_composite_dev *cdev) | 164 | static int __ref gs_bind(struct usb_composite_dev *cdev) |
165 | { | 165 | { |
166 | int gcnum; | 166 | int gcnum; |
167 | struct usb_gadget *gadget = cdev->gadget; | 167 | struct usb_gadget *gadget = cdev->gadget; |
diff --git a/drivers/usb/gadget/storage_common.c b/drivers/usb/gadget/storage_common.c index 04c462ff0ea6..484acfb1a7c5 100644 --- a/drivers/usb/gadget/storage_common.c +++ b/drivers/usb/gadget/storage_common.c | |||
@@ -57,10 +57,12 @@ | |||
57 | #include <asm/unaligned.h> | 57 | #include <asm/unaligned.h> |
58 | 58 | ||
59 | 59 | ||
60 | /* Thanks to NetChip Technologies for donating this product ID. | 60 | /* |
61 | * Thanks to NetChip Technologies for donating this product ID. | ||
61 | * | 62 | * |
62 | * DO NOT REUSE THESE IDs with any other driver!! Ever!! | 63 | * DO NOT REUSE THESE IDs with any other driver!! Ever!! |
63 | * Instead: allocate your own, using normal USB-IF procedures. */ | 64 | * Instead: allocate your own, using normal USB-IF procedures. |
65 | */ | ||
64 | #define FSG_VENDOR_ID 0x0525 /* NetChip */ | 66 | #define FSG_VENDOR_ID 0x0525 /* NetChip */ |
65 | #define FSG_PRODUCT_ID 0xa4a5 /* Linux-USB File-backed Storage Gadget */ | 67 | #define FSG_PRODUCT_ID 0xa4a5 /* Linux-USB File-backed Storage Gadget */ |
66 | 68 | ||
@@ -84,14 +86,27 @@ | |||
84 | #define LWARN(lun, fmt, args...) dev_warn(&(lun)->dev, fmt, ## args) | 86 | #define LWARN(lun, fmt, args...) dev_warn(&(lun)->dev, fmt, ## args) |
85 | #define LINFO(lun, fmt, args...) dev_info(&(lun)->dev, fmt, ## args) | 87 | #define LINFO(lun, fmt, args...) dev_info(&(lun)->dev, fmt, ## args) |
86 | 88 | ||
87 | /* Keep those macros in sync with thos in | 89 | /* |
88 | * include/linux/ubs/composite.h or else GCC will complain. If they | 90 | * Keep those macros in sync with those in |
91 | * include/linux/usb/composite.h or else GCC will complain. If they | ||
89 | * are identical (the same names of arguments, white spaces in the | 92 | * are identical (the same names of arguments, white spaces in the |
90 | * same places) GCC will allow redefinition otherwise (even if some | 93 | * same places) GCC will allow redefinition otherwise (even if some |
91 | * white space is removed or added) warning will be issued. No | 94 | * white space is removed or added) warning will be issued. |
92 | * checking if those symbols is defined is performed because warning | 95 | * |
93 | * is desired when those macros were defined by someone else to mean | 96 | * Those macros are needed here because File Storage Gadget does not |
94 | * something else. */ | 97 | * include the composite.h header. For composite gadgets those macros |
98 | * are redundant since composite.h is included any way. | ||
99 | * | ||
100 | * One could check whether those macros are already defined (which | ||
101 | * would indicate composite.h had been included) or not (which would | ||
102 | * indicate we were in FSG) but this is not done because a warning is | ||
103 | * desired if definitions here differ from the ones in composite.h. | ||
104 | * | ||
105 | * We want the definitions to match and be the same in File Storage | ||
106 | * Gadget as well as Mass Storage Function (and so composite gadgets | ||
107 | * using MSF). If someone changes them in composite.h it will produce | ||
108 | * a warning in this file when building MSF. | ||
109 | */ | ||
95 | #define DBG(d, fmt, args...) dev_dbg(&(d)->gadget->dev , fmt , ## args) | 110 | #define DBG(d, fmt, args...) dev_dbg(&(d)->gadget->dev , fmt , ## args) |
96 | #define VDBG(d, fmt, args...) dev_vdbg(&(d)->gadget->dev , fmt , ## args) | 111 | #define VDBG(d, fmt, args...) dev_vdbg(&(d)->gadget->dev , fmt , ## args) |
97 | #define ERROR(d, fmt, args...) dev_err(&(d)->gadget->dev , fmt , ## args) | 112 | #define ERROR(d, fmt, args...) dev_err(&(d)->gadget->dev , fmt , ## args) |
@@ -269,6 +284,7 @@ struct fsg_lun { | |||
269 | unsigned int prevent_medium_removal:1; | 284 | unsigned int prevent_medium_removal:1; |
270 | unsigned int registered:1; | 285 | unsigned int registered:1; |
271 | unsigned int info_valid:1; | 286 | unsigned int info_valid:1; |
287 | unsigned int nofua:1; | ||
272 | 288 | ||
273 | u32 sense_data; | 289 | u32 sense_data; |
274 | u32 sense_data_info; | 290 | u32 sense_data_info; |
@@ -313,9 +329,11 @@ struct fsg_buffhd { | |||
313 | enum fsg_buffer_state state; | 329 | enum fsg_buffer_state state; |
314 | struct fsg_buffhd *next; | 330 | struct fsg_buffhd *next; |
315 | 331 | ||
316 | /* The NetChip 2280 is faster, and handles some protocol faults | 332 | /* |
333 | * The NetChip 2280 is faster, and handles some protocol faults | ||
317 | * better, if we don't submit any short bulk-out read requests. | 334 | * better, if we don't submit any short bulk-out read requests. |
318 | * So we will record the intended request length here. */ | 335 | * So we will record the intended request length here. |
336 | */ | ||
319 | unsigned int bulk_out_intended_length; | 337 | unsigned int bulk_out_intended_length; |
320 | 338 | ||
321 | struct usb_request *inreq; | 339 | struct usb_request *inreq; |
@@ -395,8 +413,10 @@ fsg_intf_desc = { | |||
395 | .iInterface = FSG_STRING_INTERFACE, | 413 | .iInterface = FSG_STRING_INTERFACE, |
396 | }; | 414 | }; |
397 | 415 | ||
398 | /* Three full-speed endpoint descriptors: bulk-in, bulk-out, | 416 | /* |
399 | * and interrupt-in. */ | 417 | * Three full-speed endpoint descriptors: bulk-in, bulk-out, and |
418 | * interrupt-in. | ||
419 | */ | ||
400 | 420 | ||
401 | static struct usb_endpoint_descriptor | 421 | static struct usb_endpoint_descriptor |
402 | fsg_fs_bulk_in_desc = { | 422 | fsg_fs_bulk_in_desc = { |
@@ -459,7 +479,7 @@ static struct usb_descriptor_header *fsg_fs_function[] = { | |||
459 | * | 479 | * |
460 | * That means alternate endpoint descriptors (bigger packets) | 480 | * That means alternate endpoint descriptors (bigger packets) |
461 | * and a "device qualifier" ... plus more construction options | 481 | * and a "device qualifier" ... plus more construction options |
462 | * for the config descriptor. | 482 | * for the configuration descriptor. |
463 | */ | 483 | */ |
464 | static struct usb_endpoint_descriptor | 484 | static struct usb_endpoint_descriptor |
465 | fsg_hs_bulk_in_desc = { | 485 | fsg_hs_bulk_in_desc = { |
@@ -547,8 +567,10 @@ static struct usb_gadget_strings fsg_stringtab = { | |||
547 | 567 | ||
548 | /*-------------------------------------------------------------------------*/ | 568 | /*-------------------------------------------------------------------------*/ |
549 | 569 | ||
550 | /* If the next two routines are called while the gadget is registered, | 570 | /* |
551 | * the caller must own fsg->filesem for writing. */ | 571 | * If the next two routines are called while the gadget is registered, |
572 | * the caller must own fsg->filesem for writing. | ||
573 | */ | ||
552 | 574 | ||
553 | static int fsg_lun_open(struct fsg_lun *curlun, const char *filename) | 575 | static int fsg_lun_open(struct fsg_lun *curlun, const char *filename) |
554 | { | 576 | { |
@@ -587,8 +609,10 @@ static int fsg_lun_open(struct fsg_lun *curlun, const char *filename) | |||
587 | goto out; | 609 | goto out; |
588 | } | 610 | } |
589 | 611 | ||
590 | /* If we can't read the file, it's no good. | 612 | /* |
591 | * If we can't write the file, use it read-only. */ | 613 | * If we can't read the file, it's no good. |
614 | * If we can't write the file, use it read-only. | ||
615 | */ | ||
592 | if (!filp->f_op || !(filp->f_op->read || filp->f_op->aio_read)) { | 616 | if (!filp->f_op || !(filp->f_op->read || filp->f_op->aio_read)) { |
593 | LINFO(curlun, "file not readable: %s\n", filename); | 617 | LINFO(curlun, "file not readable: %s\n", filename); |
594 | goto out; | 618 | goto out; |
@@ -646,8 +670,10 @@ static void fsg_lun_close(struct fsg_lun *curlun) | |||
646 | 670 | ||
647 | /*-------------------------------------------------------------------------*/ | 671 | /*-------------------------------------------------------------------------*/ |
648 | 672 | ||
649 | /* Sync the file data, don't bother with the metadata. | 673 | /* |
650 | * This code was copied from fs/buffer.c:sys_fdatasync(). */ | 674 | * Sync the file data, don't bother with the metadata. |
675 | * This code was copied from fs/buffer.c:sys_fdatasync(). | ||
676 | */ | ||
651 | static int fsg_lun_fsync_sub(struct fsg_lun *curlun) | 677 | static int fsg_lun_fsync_sub(struct fsg_lun *curlun) |
652 | { | 678 | { |
653 | struct file *filp = curlun->filp; | 679 | struct file *filp = curlun->filp; |
@@ -689,6 +715,14 @@ static ssize_t fsg_show_ro(struct device *dev, struct device_attribute *attr, | |||
689 | : curlun->initially_ro); | 715 | : curlun->initially_ro); |
690 | } | 716 | } |
691 | 717 | ||
718 | static ssize_t fsg_show_nofua(struct device *dev, struct device_attribute *attr, | ||
719 | char *buf) | ||
720 | { | ||
721 | struct fsg_lun *curlun = fsg_lun_from_dev(dev); | ||
722 | |||
723 | return sprintf(buf, "%u\n", curlun->nofua); | ||
724 | } | ||
725 | |||
692 | static ssize_t fsg_show_file(struct device *dev, struct device_attribute *attr, | 726 | static ssize_t fsg_show_file(struct device *dev, struct device_attribute *attr, |
693 | char *buf) | 727 | char *buf) |
694 | { | 728 | { |
@@ -723,26 +757,47 @@ static ssize_t fsg_store_ro(struct device *dev, struct device_attribute *attr, | |||
723 | ssize_t rc = count; | 757 | ssize_t rc = count; |
724 | struct fsg_lun *curlun = fsg_lun_from_dev(dev); | 758 | struct fsg_lun *curlun = fsg_lun_from_dev(dev); |
725 | struct rw_semaphore *filesem = dev_get_drvdata(dev); | 759 | struct rw_semaphore *filesem = dev_get_drvdata(dev); |
726 | int i; | 760 | unsigned long ro; |
727 | 761 | ||
728 | if (sscanf(buf, "%d", &i) != 1) | 762 | if (strict_strtoul(buf, 2, &ro)) |
729 | return -EINVAL; | 763 | return -EINVAL; |
730 | 764 | ||
731 | /* Allow the write-enable status to change only while the backing file | 765 | /* |
732 | * is closed. */ | 766 | * Allow the write-enable status to change only while the |
767 | * backing file is closed. | ||
768 | */ | ||
733 | down_read(filesem); | 769 | down_read(filesem); |
734 | if (fsg_lun_is_open(curlun)) { | 770 | if (fsg_lun_is_open(curlun)) { |
735 | LDBG(curlun, "read-only status change prevented\n"); | 771 | LDBG(curlun, "read-only status change prevented\n"); |
736 | rc = -EBUSY; | 772 | rc = -EBUSY; |
737 | } else { | 773 | } else { |
738 | curlun->ro = !!i; | 774 | curlun->ro = ro; |
739 | curlun->initially_ro = !!i; | 775 | curlun->initially_ro = ro; |
740 | LDBG(curlun, "read-only status set to %d\n", curlun->ro); | 776 | LDBG(curlun, "read-only status set to %d\n", curlun->ro); |
741 | } | 777 | } |
742 | up_read(filesem); | 778 | up_read(filesem); |
743 | return rc; | 779 | return rc; |
744 | } | 780 | } |
745 | 781 | ||
782 | static ssize_t fsg_store_nofua(struct device *dev, | ||
783 | struct device_attribute *attr, | ||
784 | const char *buf, size_t count) | ||
785 | { | ||
786 | struct fsg_lun *curlun = fsg_lun_from_dev(dev); | ||
787 | unsigned long nofua; | ||
788 | |||
789 | if (strict_strtoul(buf, 2, &nofua)) | ||
790 | return -EINVAL; | ||
791 | |||
792 | /* Sync data when switching from async mode to sync */ | ||
793 | if (!nofua && curlun->nofua) | ||
794 | fsg_lun_fsync_sub(curlun); | ||
795 | |||
796 | curlun->nofua = nofua; | ||
797 | |||
798 | return count; | ||
799 | } | ||
800 | |||
746 | static ssize_t fsg_store_file(struct device *dev, struct device_attribute *attr, | 801 | static ssize_t fsg_store_file(struct device *dev, struct device_attribute *attr, |
747 | const char *buf, size_t count) | 802 | const char *buf, size_t count) |
748 | { | 803 | { |
diff --git a/drivers/usb/gadget/u_ether.c b/drivers/usb/gadget/u_ether.c index 1da755a1c855..6bb876d65252 100644 --- a/drivers/usb/gadget/u_ether.c +++ b/drivers/usb/gadget/u_ether.c | |||
@@ -704,17 +704,6 @@ static char *host_addr; | |||
704 | module_param(host_addr, charp, S_IRUGO); | 704 | module_param(host_addr, charp, S_IRUGO); |
705 | MODULE_PARM_DESC(host_addr, "Host Ethernet Address"); | 705 | MODULE_PARM_DESC(host_addr, "Host Ethernet Address"); |
706 | 706 | ||
707 | |||
708 | static u8 __init nibble(unsigned char c) | ||
709 | { | ||
710 | if (isdigit(c)) | ||
711 | return c - '0'; | ||
712 | c = toupper(c); | ||
713 | if (isxdigit(c)) | ||
714 | return 10 + c - 'A'; | ||
715 | return 0; | ||
716 | } | ||
717 | |||
718 | static int get_ether_addr(const char *str, u8 *dev_addr) | 707 | static int get_ether_addr(const char *str, u8 *dev_addr) |
719 | { | 708 | { |
720 | if (str) { | 709 | if (str) { |
@@ -725,8 +714,8 @@ static int get_ether_addr(const char *str, u8 *dev_addr) | |||
725 | 714 | ||
726 | if ((*str == '.') || (*str == ':')) | 715 | if ((*str == '.') || (*str == ':')) |
727 | str++; | 716 | str++; |
728 | num = nibble(*str++) << 4; | 717 | num = hex_to_bin(*str++) << 4; |
729 | num |= (nibble(*str++)); | 718 | num |= hex_to_bin(*str++); |
730 | dev_addr [i] = num; | 719 | dev_addr [i] = num; |
731 | } | 720 | } |
732 | if (is_valid_ether_addr(dev_addr)) | 721 | if (is_valid_ether_addr(dev_addr)) |
diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c index 3e8dcb5455e3..01e5354a4c20 100644 --- a/drivers/usb/gadget/u_serial.c +++ b/drivers/usb/gadget/u_serial.c | |||
@@ -18,6 +18,7 @@ | |||
18 | /* #define VERBOSE_DEBUG */ | 18 | /* #define VERBOSE_DEBUG */ |
19 | 19 | ||
20 | #include <linux/kernel.h> | 20 | #include <linux/kernel.h> |
21 | #include <linux/sched.h> | ||
21 | #include <linux/interrupt.h> | 22 | #include <linux/interrupt.h> |
22 | #include <linux/device.h> | 23 | #include <linux/device.h> |
23 | #include <linux/delay.h> | 24 | #include <linux/delay.h> |
diff --git a/drivers/usb/gadget/webcam.c b/drivers/usb/gadget/webcam.c index 288d21155abe..de1deb7a3c63 100644 --- a/drivers/usb/gadget/webcam.c +++ b/drivers/usb/gadget/webcam.c | |||
@@ -308,7 +308,7 @@ static const struct uvc_descriptor_header * const uvc_hs_streaming_cls[] = { | |||
308 | * USB configuration | 308 | * USB configuration |
309 | */ | 309 | */ |
310 | 310 | ||
311 | static int __init | 311 | static int __ref |
312 | webcam_config_bind(struct usb_configuration *c) | 312 | webcam_config_bind(struct usb_configuration *c) |
313 | { | 313 | { |
314 | return uvc_bind_config(c, uvc_control_cls, uvc_fs_streaming_cls, | 314 | return uvc_bind_config(c, uvc_control_cls, uvc_fs_streaming_cls, |
@@ -330,7 +330,7 @@ webcam_unbind(struct usb_composite_dev *cdev) | |||
330 | return 0; | 330 | return 0; |
331 | } | 331 | } |
332 | 332 | ||
333 | static int __init | 333 | static int __ref |
334 | webcam_bind(struct usb_composite_dev *cdev) | 334 | webcam_bind(struct usb_composite_dev *cdev) |
335 | { | 335 | { |
336 | int ret; | 336 | int ret; |
diff --git a/drivers/usb/gadget/zero.c b/drivers/usb/gadget/zero.c index 807280d069f9..cf353920bb1c 100644 --- a/drivers/usb/gadget/zero.c +++ b/drivers/usb/gadget/zero.c | |||
@@ -264,7 +264,7 @@ static void zero_resume(struct usb_composite_dev *cdev) | |||
264 | 264 | ||
265 | /*-------------------------------------------------------------------------*/ | 265 | /*-------------------------------------------------------------------------*/ |
266 | 266 | ||
267 | static int __init zero_bind(struct usb_composite_dev *cdev) | 267 | static int __ref zero_bind(struct usb_composite_dev *cdev) |
268 | { | 268 | { |
269 | int gcnum; | 269 | int gcnum; |
270 | struct usb_gadget *gadget = cdev->gadget; | 270 | struct usb_gadget *gadget = cdev->gadget; |
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index f865be2276d4..2d926cec0725 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig | |||
@@ -72,8 +72,9 @@ config USB_EHCI_ROOT_HUB_TT | |||
72 | from ARC, and has since changed hands a few times. | 72 | from ARC, and has since changed hands a few times. |
73 | 73 | ||
74 | config USB_EHCI_TT_NEWSCHED | 74 | config USB_EHCI_TT_NEWSCHED |
75 | bool "Improved Transaction Translator scheduling (EXPERIMENTAL)" | 75 | bool "Improved Transaction Translator scheduling" |
76 | depends on USB_EHCI_HCD && EXPERIMENTAL | 76 | depends on USB_EHCI_HCD |
77 | default y | ||
77 | ---help--- | 78 | ---help--- |
78 | This changes the periodic scheduling code to fill more of the low | 79 | This changes the periodic scheduling code to fill more of the low |
79 | and full speed bandwidth available from the Transaction Translator | 80 | and full speed bandwidth available from the Transaction Translator |
@@ -84,9 +85,11 @@ config USB_EHCI_TT_NEWSCHED | |||
84 | If you have multiple periodic low/fullspeed devices connected to a | 85 | If you have multiple periodic low/fullspeed devices connected to a |
85 | highspeed USB hub which is connected to a highspeed USB Host | 86 | highspeed USB hub which is connected to a highspeed USB Host |
86 | Controller, and some of those devices will not work correctly | 87 | Controller, and some of those devices will not work correctly |
87 | (possibly due to "ENOSPC" or "-28" errors), say Y. | 88 | (possibly due to "ENOSPC" or "-28" errors), say Y. Conversely, if |
89 | you have only one such device and it doesn't work, you could try | ||
90 | saying N. | ||
88 | 91 | ||
89 | If unsure, say N. | 92 | If unsure, say Y. |
90 | 93 | ||
91 | config USB_EHCI_BIG_ENDIAN_MMIO | 94 | config USB_EHCI_BIG_ENDIAN_MMIO |
92 | bool | 95 | bool |
diff --git a/drivers/usb/host/ehci-au1xxx.c b/drivers/usb/host/ehci-au1xxx.c index faa61748db70..2baf8a849086 100644 --- a/drivers/usb/host/ehci-au1xxx.c +++ b/drivers/usb/host/ehci-au1xxx.c | |||
@@ -228,7 +228,7 @@ static int ehci_hcd_au1xxx_drv_suspend(struct device *dev) | |||
228 | * the root hub is either suspended or stopped. | 228 | * the root hub is either suspended or stopped. |
229 | */ | 229 | */ |
230 | spin_lock_irqsave(&ehci->lock, flags); | 230 | spin_lock_irqsave(&ehci->lock, flags); |
231 | ehci_prepare_ports_for_controller_suspend(ehci); | 231 | ehci_prepare_ports_for_controller_suspend(ehci, device_may_wakeup(dev)); |
232 | ehci_writel(ehci, 0, &ehci->regs->intr_enable); | 232 | ehci_writel(ehci, 0, &ehci->regs->intr_enable); |
233 | (void)ehci_readl(ehci, &ehci->regs->intr_enable); | 233 | (void)ehci_readl(ehci, &ehci->regs->intr_enable); |
234 | 234 | ||
diff --git a/drivers/usb/host/ehci-dbg.c b/drivers/usb/host/ehci-dbg.c index 874d2000bf92..76b7fd2d838a 100644 --- a/drivers/usb/host/ehci-dbg.c +++ b/drivers/usb/host/ehci-dbg.c | |||
@@ -98,13 +98,18 @@ static void dbg_hcc_params (struct ehci_hcd *ehci, char *label) | |||
98 | HCC_64BIT_ADDR(params) ? " 64 bit addr" : ""); | 98 | HCC_64BIT_ADDR(params) ? " 64 bit addr" : ""); |
99 | } else { | 99 | } else { |
100 | ehci_dbg (ehci, | 100 | ehci_dbg (ehci, |
101 | "%s hcc_params %04x thresh %d uframes %s%s%s\n", | 101 | "%s hcc_params %04x thresh %d uframes %s%s%s%s%s%s%s\n", |
102 | label, | 102 | label, |
103 | params, | 103 | params, |
104 | HCC_ISOC_THRES(params), | 104 | HCC_ISOC_THRES(params), |
105 | HCC_PGM_FRAMELISTLEN(params) ? "256/512/1024" : "1024", | 105 | HCC_PGM_FRAMELISTLEN(params) ? "256/512/1024" : "1024", |
106 | HCC_CANPARK(params) ? " park" : "", | 106 | HCC_CANPARK(params) ? " park" : "", |
107 | HCC_64BIT_ADDR(params) ? " 64 bit addr" : ""); | 107 | HCC_64BIT_ADDR(params) ? " 64 bit addr" : "", |
108 | HCC_LPM(params) ? " LPM" : "", | ||
109 | HCC_PER_PORT_CHANGE_EVENT(params) ? " ppce" : "", | ||
110 | HCC_HW_PREFETCH(params) ? " hw prefetch" : "", | ||
111 | HCC_32FRAME_PERIODIC_LIST(params) ? | ||
112 | " 32 peridic list" : ""); | ||
108 | } | 113 | } |
109 | } | 114 | } |
110 | #else | 115 | #else |
@@ -191,8 +196,9 @@ static int __maybe_unused | |||
191 | dbg_status_buf (char *buf, unsigned len, const char *label, u32 status) | 196 | dbg_status_buf (char *buf, unsigned len, const char *label, u32 status) |
192 | { | 197 | { |
193 | return scnprintf (buf, len, | 198 | return scnprintf (buf, len, |
194 | "%s%sstatus %04x%s%s%s%s%s%s%s%s%s%s", | 199 | "%s%sstatus %04x%s%s%s%s%s%s%s%s%s%s%s", |
195 | label, label [0] ? " " : "", status, | 200 | label, label [0] ? " " : "", status, |
201 | (status & STS_PPCE_MASK) ? " PPCE" : "", | ||
196 | (status & STS_ASS) ? " Async" : "", | 202 | (status & STS_ASS) ? " Async" : "", |
197 | (status & STS_PSS) ? " Periodic" : "", | 203 | (status & STS_PSS) ? " Periodic" : "", |
198 | (status & STS_RECL) ? " Recl" : "", | 204 | (status & STS_RECL) ? " Recl" : "", |
@@ -210,8 +216,9 @@ static int __maybe_unused | |||
210 | dbg_intr_buf (char *buf, unsigned len, const char *label, u32 enable) | 216 | dbg_intr_buf (char *buf, unsigned len, const char *label, u32 enable) |
211 | { | 217 | { |
212 | return scnprintf (buf, len, | 218 | return scnprintf (buf, len, |
213 | "%s%sintrenable %02x%s%s%s%s%s%s", | 219 | "%s%sintrenable %02x%s%s%s%s%s%s%s", |
214 | label, label [0] ? " " : "", enable, | 220 | label, label [0] ? " " : "", enable, |
221 | (enable & STS_PPCE_MASK) ? " PPCE" : "", | ||
215 | (enable & STS_IAA) ? " IAA" : "", | 222 | (enable & STS_IAA) ? " IAA" : "", |
216 | (enable & STS_FATAL) ? " FATAL" : "", | 223 | (enable & STS_FATAL) ? " FATAL" : "", |
217 | (enable & STS_FLR) ? " FLR" : "", | 224 | (enable & STS_FLR) ? " FLR" : "", |
@@ -228,9 +235,15 @@ static int | |||
228 | dbg_command_buf (char *buf, unsigned len, const char *label, u32 command) | 235 | dbg_command_buf (char *buf, unsigned len, const char *label, u32 command) |
229 | { | 236 | { |
230 | return scnprintf (buf, len, | 237 | return scnprintf (buf, len, |
231 | "%s%scommand %06x %s=%d ithresh=%d%s%s%s%s period=%s%s %s", | 238 | "%s%scommand %07x %s%s%s%s%s%s=%d ithresh=%d%s%s%s%s " |
239 | "period=%s%s %s", | ||
232 | label, label [0] ? " " : "", command, | 240 | label, label [0] ? " " : "", command, |
233 | (command & CMD_PARK) ? "park" : "(park)", | 241 | (command & CMD_HIRD) ? " HIRD" : "", |
242 | (command & CMD_PPCEE) ? " PPCEE" : "", | ||
243 | (command & CMD_FSP) ? " FSP" : "", | ||
244 | (command & CMD_ASPE) ? " ASPE" : "", | ||
245 | (command & CMD_PSPE) ? " PSPE" : "", | ||
246 | (command & CMD_PARK) ? " park" : "(park)", | ||
234 | CMD_PARK_CNT (command), | 247 | CMD_PARK_CNT (command), |
235 | (command >> 16) & 0x3f, | 248 | (command >> 16) & 0x3f, |
236 | (command & CMD_LRESET) ? " LReset" : "", | 249 | (command & CMD_LRESET) ? " LReset" : "", |
@@ -257,11 +270,22 @@ dbg_port_buf (char *buf, unsigned len, const char *label, int port, u32 status) | |||
257 | } | 270 | } |
258 | 271 | ||
259 | return scnprintf (buf, len, | 272 | return scnprintf (buf, len, |
260 | "%s%sport %d status %06x%s%s sig=%s%s%s%s%s%s%s%s%s%s", | 273 | "%s%sport:%d status %06x %d %s%s%s%s%s%s " |
274 | "sig=%s%s%s%s%s%s%s%s%s%s%s", | ||
261 | label, label [0] ? " " : "", port, status, | 275 | label, label [0] ? " " : "", port, status, |
276 | status>>25,/*device address */ | ||
277 | (status & PORT_SSTS)>>23 == PORTSC_SUSPEND_STS_ACK ? | ||
278 | " ACK" : "", | ||
279 | (status & PORT_SSTS)>>23 == PORTSC_SUSPEND_STS_NYET ? | ||
280 | " NYET" : "", | ||
281 | (status & PORT_SSTS)>>23 == PORTSC_SUSPEND_STS_STALL ? | ||
282 | " STALL" : "", | ||
283 | (status & PORT_SSTS)>>23 == PORTSC_SUSPEND_STS_ERR ? | ||
284 | " ERR" : "", | ||
262 | (status & PORT_POWER) ? " POWER" : "", | 285 | (status & PORT_POWER) ? " POWER" : "", |
263 | (status & PORT_OWNER) ? " OWNER" : "", | 286 | (status & PORT_OWNER) ? " OWNER" : "", |
264 | sig, | 287 | sig, |
288 | (status & PORT_LPM) ? " LPM" : "", | ||
265 | (status & PORT_RESET) ? " RESET" : "", | 289 | (status & PORT_RESET) ? " RESET" : "", |
266 | (status & PORT_SUSPEND) ? " SUSPEND" : "", | 290 | (status & PORT_SUSPEND) ? " SUSPEND" : "", |
267 | (status & PORT_RESUME) ? " RESUME" : "", | 291 | (status & PORT_RESUME) ? " RESUME" : "", |
@@ -330,6 +354,13 @@ static int debug_async_open(struct inode *, struct file *); | |||
330 | static int debug_periodic_open(struct inode *, struct file *); | 354 | static int debug_periodic_open(struct inode *, struct file *); |
331 | static int debug_registers_open(struct inode *, struct file *); | 355 | static int debug_registers_open(struct inode *, struct file *); |
332 | static int debug_async_open(struct inode *, struct file *); | 356 | static int debug_async_open(struct inode *, struct file *); |
357 | static int debug_lpm_open(struct inode *, struct file *); | ||
358 | static ssize_t debug_lpm_read(struct file *file, char __user *user_buf, | ||
359 | size_t count, loff_t *ppos); | ||
360 | static ssize_t debug_lpm_write(struct file *file, const char __user *buffer, | ||
361 | size_t count, loff_t *ppos); | ||
362 | static int debug_lpm_close(struct inode *inode, struct file *file); | ||
363 | |||
333 | static ssize_t debug_output(struct file*, char __user*, size_t, loff_t*); | 364 | static ssize_t debug_output(struct file*, char __user*, size_t, loff_t*); |
334 | static int debug_close(struct inode *, struct file *); | 365 | static int debug_close(struct inode *, struct file *); |
335 | 366 | ||
@@ -351,6 +382,13 @@ static const struct file_operations debug_registers_fops = { | |||
351 | .read = debug_output, | 382 | .read = debug_output, |
352 | .release = debug_close, | 383 | .release = debug_close, |
353 | }; | 384 | }; |
385 | static const struct file_operations debug_lpm_fops = { | ||
386 | .owner = THIS_MODULE, | ||
387 | .open = debug_lpm_open, | ||
388 | .read = debug_lpm_read, | ||
389 | .write = debug_lpm_write, | ||
390 | .release = debug_lpm_close, | ||
391 | }; | ||
354 | 392 | ||
355 | static struct dentry *ehci_debug_root; | 393 | static struct dentry *ehci_debug_root; |
356 | 394 | ||
@@ -674,7 +712,7 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf) | |||
674 | 712 | ||
675 | spin_lock_irqsave (&ehci->lock, flags); | 713 | spin_lock_irqsave (&ehci->lock, flags); |
676 | 714 | ||
677 | if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) { | 715 | if (!HCD_HW_ACCESSIBLE(hcd)) { |
678 | size = scnprintf (next, size, | 716 | size = scnprintf (next, size, |
679 | "bus %s, device %s\n" | 717 | "bus %s, device %s\n" |
680 | "%s\n" | 718 | "%s\n" |
@@ -917,51 +955,127 @@ static int debug_registers_open(struct inode *inode, struct file *file) | |||
917 | return file->private_data ? 0 : -ENOMEM; | 955 | return file->private_data ? 0 : -ENOMEM; |
918 | } | 956 | } |
919 | 957 | ||
958 | static int debug_lpm_open(struct inode *inode, struct file *file) | ||
959 | { | ||
960 | file->private_data = inode->i_private; | ||
961 | return 0; | ||
962 | } | ||
963 | |||
964 | static int debug_lpm_close(struct inode *inode, struct file *file) | ||
965 | { | ||
966 | return 0; | ||
967 | } | ||
968 | |||
969 | static ssize_t debug_lpm_read(struct file *file, char __user *user_buf, | ||
970 | size_t count, loff_t *ppos) | ||
971 | { | ||
972 | /* TODO: show lpm stats */ | ||
973 | return 0; | ||
974 | } | ||
975 | |||
976 | static ssize_t debug_lpm_write(struct file *file, const char __user *user_buf, | ||
977 | size_t count, loff_t *ppos) | ||
978 | { | ||
979 | struct usb_hcd *hcd; | ||
980 | struct ehci_hcd *ehci; | ||
981 | char buf[50]; | ||
982 | size_t len; | ||
983 | u32 temp; | ||
984 | unsigned long port; | ||
985 | u32 __iomem *portsc ; | ||
986 | u32 params; | ||
987 | |||
988 | hcd = bus_to_hcd(file->private_data); | ||
989 | ehci = hcd_to_ehci(hcd); | ||
990 | |||
991 | len = min(count, sizeof(buf) - 1); | ||
992 | if (copy_from_user(buf, user_buf, len)) | ||
993 | return -EFAULT; | ||
994 | buf[len] = '\0'; | ||
995 | if (len > 0 && buf[len - 1] == '\n') | ||
996 | buf[len - 1] = '\0'; | ||
997 | |||
998 | if (strncmp(buf, "enable", 5) == 0) { | ||
999 | if (strict_strtoul(buf + 7, 10, &port)) | ||
1000 | return -EINVAL; | ||
1001 | params = ehci_readl(ehci, &ehci->caps->hcs_params); | ||
1002 | if (port > HCS_N_PORTS(params)) { | ||
1003 | ehci_dbg(ehci, "ERR: LPM on bad port %lu\n", port); | ||
1004 | return -ENODEV; | ||
1005 | } | ||
1006 | portsc = &ehci->regs->port_status[port-1]; | ||
1007 | temp = ehci_readl(ehci, portsc); | ||
1008 | if (!(temp & PORT_DEV_ADDR)) { | ||
1009 | ehci_dbg(ehci, "LPM: no device attached\n"); | ||
1010 | return -ENODEV; | ||
1011 | } | ||
1012 | temp |= PORT_LPM; | ||
1013 | ehci_writel(ehci, temp, portsc); | ||
1014 | printk(KERN_INFO "force enable LPM for port %lu\n", port); | ||
1015 | } else if (strncmp(buf, "hird=", 5) == 0) { | ||
1016 | unsigned long hird; | ||
1017 | if (strict_strtoul(buf + 5, 16, &hird)) | ||
1018 | return -EINVAL; | ||
1019 | printk(KERN_INFO "setting hird %s %lu\n", buf + 6, hird); | ||
1020 | temp = ehci_readl(ehci, &ehci->regs->command); | ||
1021 | temp &= ~CMD_HIRD; | ||
1022 | temp |= hird << 24; | ||
1023 | ehci_writel(ehci, temp, &ehci->regs->command); | ||
1024 | } else if (strncmp(buf, "disable", 7) == 0) { | ||
1025 | if (strict_strtoul(buf + 8, 10, &port)) | ||
1026 | return -EINVAL; | ||
1027 | params = ehci_readl(ehci, &ehci->caps->hcs_params); | ||
1028 | if (port > HCS_N_PORTS(params)) { | ||
1029 | ehci_dbg(ehci, "ERR: LPM off bad port %lu\n", port); | ||
1030 | return -ENODEV; | ||
1031 | } | ||
1032 | portsc = &ehci->regs->port_status[port-1]; | ||
1033 | temp = ehci_readl(ehci, portsc); | ||
1034 | if (!(temp & PORT_DEV_ADDR)) { | ||
1035 | ehci_dbg(ehci, "ERR: no device attached\n"); | ||
1036 | return -ENODEV; | ||
1037 | } | ||
1038 | temp &= ~PORT_LPM; | ||
1039 | ehci_writel(ehci, temp, portsc); | ||
1040 | printk(KERN_INFO "disabled LPM for port %lu\n", port); | ||
1041 | } else | ||
1042 | return -EOPNOTSUPP; | ||
1043 | return count; | ||
1044 | } | ||
1045 | |||
920 | static inline void create_debug_files (struct ehci_hcd *ehci) | 1046 | static inline void create_debug_files (struct ehci_hcd *ehci) |
921 | { | 1047 | { |
922 | struct usb_bus *bus = &ehci_to_hcd(ehci)->self; | 1048 | struct usb_bus *bus = &ehci_to_hcd(ehci)->self; |
923 | 1049 | ||
924 | ehci->debug_dir = debugfs_create_dir(bus->bus_name, ehci_debug_root); | 1050 | ehci->debug_dir = debugfs_create_dir(bus->bus_name, ehci_debug_root); |
925 | if (!ehci->debug_dir) | 1051 | if (!ehci->debug_dir) |
926 | goto dir_error; | 1052 | return; |
927 | 1053 | ||
928 | ehci->debug_async = debugfs_create_file("async", S_IRUGO, | 1054 | if (!debugfs_create_file("async", S_IRUGO, ehci->debug_dir, bus, |
929 | ehci->debug_dir, bus, | 1055 | &debug_async_fops)) |
930 | &debug_async_fops); | 1056 | goto file_error; |
931 | if (!ehci->debug_async) | 1057 | |
932 | goto async_error; | 1058 | if (!debugfs_create_file("periodic", S_IRUGO, ehci->debug_dir, bus, |
933 | 1059 | &debug_periodic_fops)) | |
934 | ehci->debug_periodic = debugfs_create_file("periodic", S_IRUGO, | 1060 | goto file_error; |
935 | ehci->debug_dir, bus, | 1061 | |
936 | &debug_periodic_fops); | 1062 | if (!debugfs_create_file("registers", S_IRUGO, ehci->debug_dir, bus, |
937 | if (!ehci->debug_periodic) | 1063 | &debug_registers_fops)) |
938 | goto periodic_error; | 1064 | goto file_error; |
939 | 1065 | ||
940 | ehci->debug_registers = debugfs_create_file("registers", S_IRUGO, | 1066 | if (!debugfs_create_file("lpm", S_IRUGO|S_IWUGO, ehci->debug_dir, bus, |
941 | ehci->debug_dir, bus, | 1067 | &debug_lpm_fops)) |
942 | &debug_registers_fops); | 1068 | goto file_error; |
943 | if (!ehci->debug_registers) | 1069 | |
944 | goto registers_error; | ||
945 | return; | 1070 | return; |
946 | 1071 | ||
947 | registers_error: | 1072 | file_error: |
948 | debugfs_remove(ehci->debug_periodic); | 1073 | debugfs_remove_recursive(ehci->debug_dir); |
949 | periodic_error: | ||
950 | debugfs_remove(ehci->debug_async); | ||
951 | async_error: | ||
952 | debugfs_remove(ehci->debug_dir); | ||
953 | dir_error: | ||
954 | ehci->debug_periodic = NULL; | ||
955 | ehci->debug_async = NULL; | ||
956 | ehci->debug_dir = NULL; | ||
957 | } | 1074 | } |
958 | 1075 | ||
959 | static inline void remove_debug_files (struct ehci_hcd *ehci) | 1076 | static inline void remove_debug_files (struct ehci_hcd *ehci) |
960 | { | 1077 | { |
961 | debugfs_remove(ehci->debug_registers); | 1078 | debugfs_remove_recursive(ehci->debug_dir); |
962 | debugfs_remove(ehci->debug_periodic); | ||
963 | debugfs_remove(ehci->debug_async); | ||
964 | debugfs_remove(ehci->debug_dir); | ||
965 | } | 1079 | } |
966 | 1080 | ||
967 | #endif /* STUB_DEBUG_FILES */ | 1081 | #endif /* STUB_DEBUG_FILES */ |
diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c index 5cd967d28938..a416421abfa2 100644 --- a/drivers/usb/host/ehci-fsl.c +++ b/drivers/usb/host/ehci-fsl.c | |||
@@ -313,7 +313,8 @@ static int ehci_fsl_drv_suspend(struct device *dev) | |||
313 | struct ehci_fsl *ehci_fsl = hcd_to_ehci_fsl(hcd); | 313 | struct ehci_fsl *ehci_fsl = hcd_to_ehci_fsl(hcd); |
314 | void __iomem *non_ehci = hcd->regs; | 314 | void __iomem *non_ehci = hcd->regs; |
315 | 315 | ||
316 | ehci_prepare_ports_for_controller_suspend(hcd_to_ehci(hcd)); | 316 | ehci_prepare_ports_for_controller_suspend(hcd_to_ehci(hcd), |
317 | device_may_wakeup(dev)); | ||
317 | if (!fsl_deep_sleep()) | 318 | if (!fsl_deep_sleep()) |
318 | return 0; | 319 | return 0; |
319 | 320 | ||
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index a3ef2a9d9dc2..34a928d3b7d2 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c | |||
@@ -36,6 +36,7 @@ | |||
36 | #include <linux/dma-mapping.h> | 36 | #include <linux/dma-mapping.h> |
37 | #include <linux/debugfs.h> | 37 | #include <linux/debugfs.h> |
38 | #include <linux/slab.h> | 38 | #include <linux/slab.h> |
39 | #include <linux/uaccess.h> | ||
39 | 40 | ||
40 | #include <asm/byteorder.h> | 41 | #include <asm/byteorder.h> |
41 | #include <asm/io.h> | 42 | #include <asm/io.h> |
@@ -78,7 +79,13 @@ static const char hcd_name [] = "ehci_hcd"; | |||
78 | #define EHCI_TUNE_RL_TT 0 | 79 | #define EHCI_TUNE_RL_TT 0 |
79 | #define EHCI_TUNE_MULT_HS 1 /* 1-3 transactions/uframe; 4.10.3 */ | 80 | #define EHCI_TUNE_MULT_HS 1 /* 1-3 transactions/uframe; 4.10.3 */ |
80 | #define EHCI_TUNE_MULT_TT 1 | 81 | #define EHCI_TUNE_MULT_TT 1 |
81 | #define EHCI_TUNE_FLS 2 /* (small) 256 frame schedule */ | 82 | /* |
83 | * Some drivers think it's safe to schedule isochronous transfers more than | ||
84 | * 256 ms into the future (partly as a result of an old bug in the scheduling | ||
85 | * code). In an attempt to avoid trouble, we will use a minimum scheduling | ||
86 | * length of 512 frames instead of 256. | ||
87 | */ | ||
88 | #define EHCI_TUNE_FLS 1 /* (medium) 512-frame schedule */ | ||
82 | 89 | ||
83 | #define EHCI_IAA_MSECS 10 /* arbitrary */ | 90 | #define EHCI_IAA_MSECS 10 /* arbitrary */ |
84 | #define EHCI_IO_JIFFIES (HZ/10) /* io watchdog > irq_thresh */ | 91 | #define EHCI_IO_JIFFIES (HZ/10) /* io watchdog > irq_thresh */ |
@@ -100,6 +107,11 @@ static int ignore_oc = 0; | |||
100 | module_param (ignore_oc, bool, S_IRUGO); | 107 | module_param (ignore_oc, bool, S_IRUGO); |
101 | MODULE_PARM_DESC (ignore_oc, "ignore bogus hardware overcurrent indications"); | 108 | MODULE_PARM_DESC (ignore_oc, "ignore bogus hardware overcurrent indications"); |
102 | 109 | ||
110 | /* for link power management(LPM) feature */ | ||
111 | static unsigned int hird; | ||
112 | module_param(hird, int, S_IRUGO); | ||
113 | MODULE_PARM_DESC(hird, "host initiated resume duration, +1 for each 75us\n"); | ||
114 | |||
103 | #define INTR_MASK (STS_IAA | STS_FATAL | STS_PCD | STS_ERR | STS_INT) | 115 | #define INTR_MASK (STS_IAA | STS_FATAL | STS_PCD | STS_ERR | STS_INT) |
104 | 116 | ||
105 | /*-------------------------------------------------------------------------*/ | 117 | /*-------------------------------------------------------------------------*/ |
@@ -304,6 +316,7 @@ static void end_unlink_async(struct ehci_hcd *ehci); | |||
304 | static void ehci_work(struct ehci_hcd *ehci); | 316 | static void ehci_work(struct ehci_hcd *ehci); |
305 | 317 | ||
306 | #include "ehci-hub.c" | 318 | #include "ehci-hub.c" |
319 | #include "ehci-lpm.c" | ||
307 | #include "ehci-mem.c" | 320 | #include "ehci-mem.c" |
308 | #include "ehci-q.c" | 321 | #include "ehci-q.c" |
309 | #include "ehci-sched.c" | 322 | #include "ehci-sched.c" |
@@ -577,6 +590,11 @@ static int ehci_init(struct usb_hcd *hcd) | |||
577 | if (log2_irq_thresh < 0 || log2_irq_thresh > 6) | 590 | if (log2_irq_thresh < 0 || log2_irq_thresh > 6) |
578 | log2_irq_thresh = 0; | 591 | log2_irq_thresh = 0; |
579 | temp = 1 << (16 + log2_irq_thresh); | 592 | temp = 1 << (16 + log2_irq_thresh); |
593 | if (HCC_PER_PORT_CHANGE_EVENT(hcc_params)) { | ||
594 | ehci->has_ppcd = 1; | ||
595 | ehci_dbg(ehci, "enable per-port change event\n"); | ||
596 | temp |= CMD_PPCEE; | ||
597 | } | ||
580 | if (HCC_CANPARK(hcc_params)) { | 598 | if (HCC_CANPARK(hcc_params)) { |
581 | /* HW default park == 3, on hardware that supports it (like | 599 | /* HW default park == 3, on hardware that supports it (like |
582 | * NVidia and ALI silicon), maximizes throughput on the async | 600 | * NVidia and ALI silicon), maximizes throughput on the async |
@@ -603,10 +621,22 @@ static int ehci_init(struct usb_hcd *hcd) | |||
603 | default: BUG(); | 621 | default: BUG(); |
604 | } | 622 | } |
605 | } | 623 | } |
624 | if (HCC_LPM(hcc_params)) { | ||
625 | /* support link power management EHCI 1.1 addendum */ | ||
626 | ehci_dbg(ehci, "support lpm\n"); | ||
627 | ehci->has_lpm = 1; | ||
628 | if (hird > 0xf) { | ||
629 | ehci_dbg(ehci, "hird %d invalid, use default 0", | ||
630 | hird); | ||
631 | hird = 0; | ||
632 | } | ||
633 | temp |= hird << 24; | ||
634 | } | ||
606 | ehci->command = temp; | 635 | ehci->command = temp; |
607 | 636 | ||
608 | /* Accept arbitrarily long scatter-gather lists */ | 637 | /* Accept arbitrarily long scatter-gather lists */ |
609 | hcd->self.sg_tablesize = ~0; | 638 | if (!(hcd->driver->flags & HCD_LOCAL_MEM)) |
639 | hcd->self.sg_tablesize = ~0; | ||
610 | return 0; | 640 | return 0; |
611 | } | 641 | } |
612 | 642 | ||
@@ -619,7 +649,6 @@ static int ehci_run (struct usb_hcd *hcd) | |||
619 | u32 hcc_params; | 649 | u32 hcc_params; |
620 | 650 | ||
621 | hcd->uses_new_polling = 1; | 651 | hcd->uses_new_polling = 1; |
622 | hcd->poll_rh = 0; | ||
623 | 652 | ||
624 | /* EHCI spec section 4.1 */ | 653 | /* EHCI spec section 4.1 */ |
625 | if ((retval = ehci_reset(ehci)) != 0) { | 654 | if ((retval = ehci_reset(ehci)) != 0) { |
@@ -764,6 +793,7 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd) | |||
764 | /* remote wakeup [4.3.1] */ | 793 | /* remote wakeup [4.3.1] */ |
765 | if (status & STS_PCD) { | 794 | if (status & STS_PCD) { |
766 | unsigned i = HCS_N_PORTS (ehci->hcs_params); | 795 | unsigned i = HCS_N_PORTS (ehci->hcs_params); |
796 | u32 ppcd = 0; | ||
767 | 797 | ||
768 | /* kick root hub later */ | 798 | /* kick root hub later */ |
769 | pcd_status = status; | 799 | pcd_status = status; |
@@ -772,9 +802,18 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd) | |||
772 | if (!(cmd & CMD_RUN)) | 802 | if (!(cmd & CMD_RUN)) |
773 | usb_hcd_resume_root_hub(hcd); | 803 | usb_hcd_resume_root_hub(hcd); |
774 | 804 | ||
805 | /* get per-port change detect bits */ | ||
806 | if (ehci->has_ppcd) | ||
807 | ppcd = status >> 16; | ||
808 | |||
775 | while (i--) { | 809 | while (i--) { |
776 | int pstatus = ehci_readl(ehci, | 810 | int pstatus; |
777 | &ehci->regs->port_status [i]); | 811 | |
812 | /* leverage per-port change bits feature */ | ||
813 | if (ehci->has_ppcd && !(ppcd & (1 << i))) | ||
814 | continue; | ||
815 | pstatus = ehci_readl(ehci, | ||
816 | &ehci->regs->port_status[i]); | ||
778 | 817 | ||
779 | if (pstatus & PORT_OWNER) | 818 | if (pstatus & PORT_OWNER) |
780 | continue; | 819 | continue; |
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c index e7d3d8def282..796ea0c8900f 100644 --- a/drivers/usb/host/ehci-hub.c +++ b/drivers/usb/host/ehci-hub.c | |||
@@ -107,7 +107,7 @@ static void ehci_handover_companion_ports(struct ehci_hcd *ehci) | |||
107 | } | 107 | } |
108 | 108 | ||
109 | static void ehci_adjust_port_wakeup_flags(struct ehci_hcd *ehci, | 109 | static void ehci_adjust_port_wakeup_flags(struct ehci_hcd *ehci, |
110 | bool suspending) | 110 | bool suspending, bool do_wakeup) |
111 | { | 111 | { |
112 | int port; | 112 | int port; |
113 | u32 temp; | 113 | u32 temp; |
@@ -117,8 +117,7 @@ static void ehci_adjust_port_wakeup_flags(struct ehci_hcd *ehci, | |||
117 | * when the controller is suspended or resumed. In all other | 117 | * when the controller is suspended or resumed. In all other |
118 | * cases they don't need to be changed. | 118 | * cases they don't need to be changed. |
119 | */ | 119 | */ |
120 | if (!ehci_to_hcd(ehci)->self.root_hub->do_remote_wakeup || | 120 | if (!ehci_to_hcd(ehci)->self.root_hub->do_remote_wakeup || do_wakeup) |
121 | device_may_wakeup(ehci_to_hcd(ehci)->self.controller)) | ||
122 | return; | 121 | return; |
123 | 122 | ||
124 | /* clear phy low-power mode before changing wakeup flags */ | 123 | /* clear phy low-power mode before changing wakeup flags */ |
@@ -167,6 +166,10 @@ static void ehci_adjust_port_wakeup_flags(struct ehci_hcd *ehci, | |||
167 | ehci_writel(ehci, temp | HOSTPC_PHCD, hostpc_reg); | 166 | ehci_writel(ehci, temp | HOSTPC_PHCD, hostpc_reg); |
168 | } | 167 | } |
169 | } | 168 | } |
169 | |||
170 | /* Does the root hub have a port wakeup pending? */ | ||
171 | if (!suspending && (ehci_readl(ehci, &ehci->regs->status) & STS_PCD)) | ||
172 | usb_hcd_resume_root_hub(ehci_to_hcd(ehci)); | ||
170 | } | 173 | } |
171 | 174 | ||
172 | static int ehci_bus_suspend (struct usb_hcd *hcd) | 175 | static int ehci_bus_suspend (struct usb_hcd *hcd) |
@@ -316,7 +319,7 @@ static int ehci_bus_resume (struct usb_hcd *hcd) | |||
316 | if (time_before (jiffies, ehci->next_statechange)) | 319 | if (time_before (jiffies, ehci->next_statechange)) |
317 | msleep(5); | 320 | msleep(5); |
318 | spin_lock_irq (&ehci->lock); | 321 | spin_lock_irq (&ehci->lock); |
319 | if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) { | 322 | if (!HCD_HW_ACCESSIBLE(hcd)) { |
320 | spin_unlock_irq(&ehci->lock); | 323 | spin_unlock_irq(&ehci->lock); |
321 | return -ESHUTDOWN; | 324 | return -ESHUTDOWN; |
322 | } | 325 | } |
@@ -603,6 +606,7 @@ ehci_hub_status_data (struct usb_hcd *hcd, char *buf) | |||
603 | u32 mask; | 606 | u32 mask; |
604 | int ports, i, retval = 1; | 607 | int ports, i, retval = 1; |
605 | unsigned long flags; | 608 | unsigned long flags; |
609 | u32 ppcd = 0; | ||
606 | 610 | ||
607 | /* if !USB_SUSPEND, root hub timers won't get shut down ... */ | 611 | /* if !USB_SUSPEND, root hub timers won't get shut down ... */ |
608 | if (!HC_IS_RUNNING(hcd->state)) | 612 | if (!HC_IS_RUNNING(hcd->state)) |
@@ -632,7 +636,15 @@ ehci_hub_status_data (struct usb_hcd *hcd, char *buf) | |||
632 | 636 | ||
633 | /* port N changes (bit N)? */ | 637 | /* port N changes (bit N)? */ |
634 | spin_lock_irqsave (&ehci->lock, flags); | 638 | spin_lock_irqsave (&ehci->lock, flags); |
639 | |||
640 | /* get per-port change detect bits */ | ||
641 | if (ehci->has_ppcd) | ||
642 | ppcd = ehci_readl(ehci, &ehci->regs->status) >> 16; | ||
643 | |||
635 | for (i = 0; i < ports; i++) { | 644 | for (i = 0; i < ports; i++) { |
645 | /* leverage per-port change bits feature */ | ||
646 | if (ehci->has_ppcd && !(ppcd & (1 << i))) | ||
647 | continue; | ||
636 | temp = ehci_readl(ehci, &ehci->regs->port_status [i]); | 648 | temp = ehci_readl(ehci, &ehci->regs->port_status [i]); |
637 | 649 | ||
638 | /* | 650 | /* |
@@ -790,6 +802,11 @@ static int ehci_hub_control ( | |||
790 | status_reg); | 802 | status_reg); |
791 | break; | 803 | break; |
792 | case USB_PORT_FEAT_C_CONNECTION: | 804 | case USB_PORT_FEAT_C_CONNECTION: |
805 | if (ehci->has_lpm) { | ||
806 | /* clear PORTSC bits on disconnect */ | ||
807 | temp &= ~PORT_LPM; | ||
808 | temp &= ~PORT_DEV_ADDR; | ||
809 | } | ||
793 | ehci_writel(ehci, (temp & ~PORT_RWC_BITS) | PORT_CSC, | 810 | ehci_writel(ehci, (temp & ~PORT_RWC_BITS) | PORT_CSC, |
794 | status_reg); | 811 | status_reg); |
795 | break; | 812 | break; |
diff --git a/drivers/usb/host/ehci-lpm.c b/drivers/usb/host/ehci-lpm.c new file mode 100644 index 000000000000..b4d4d63c13ed --- /dev/null +++ b/drivers/usb/host/ehci-lpm.c | |||
@@ -0,0 +1,83 @@ | |||
1 | /* ehci-lpm.c EHCI HCD LPM support code | ||
2 | * Copyright (c) 2008 - 2010, Intel Corporation. | ||
3 | * Author: Jacob Pan <jacob.jun.pan@intel.com> | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License version 2 as | ||
7 | * published by the Free Software Foundation. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the Free Software | ||
16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
17 | */ | ||
18 | |||
19 | /* this file is part of ehci-hcd.c */ | ||
20 | static int ehci_lpm_set_da(struct ehci_hcd *ehci, int dev_addr, int port_num) | ||
21 | { | ||
22 | u32 __iomem portsc; | ||
23 | |||
24 | ehci_dbg(ehci, "set dev address %d for port %d\n", dev_addr, port_num); | ||
25 | if (port_num > HCS_N_PORTS(ehci->hcs_params)) { | ||
26 | ehci_dbg(ehci, "invalid port number %d\n", port_num); | ||
27 | return -ENODEV; | ||
28 | } | ||
29 | portsc = ehci_readl(ehci, &ehci->regs->port_status[port_num-1]); | ||
30 | portsc &= ~PORT_DEV_ADDR; | ||
31 | portsc |= dev_addr<<25; | ||
32 | ehci_writel(ehci, portsc, &ehci->regs->port_status[port_num-1]); | ||
33 | return 0; | ||
34 | } | ||
35 | |||
36 | /* | ||
37 | * this function is used to check if the device support LPM | ||
38 | * if yes, mark the PORTSC register with PORT_LPM bit | ||
39 | */ | ||
40 | static int ehci_lpm_check(struct ehci_hcd *ehci, int port) | ||
41 | { | ||
42 | u32 __iomem *portsc ; | ||
43 | u32 val32; | ||
44 | int retval; | ||
45 | |||
46 | portsc = &ehci->regs->port_status[port-1]; | ||
47 | val32 = ehci_readl(ehci, portsc); | ||
48 | if (!(val32 & PORT_DEV_ADDR)) { | ||
49 | ehci_dbg(ehci, "LPM: no device attached\n"); | ||
50 | return -ENODEV; | ||
51 | } | ||
52 | val32 |= PORT_LPM; | ||
53 | ehci_writel(ehci, val32, portsc); | ||
54 | msleep(5); | ||
55 | val32 |= PORT_SUSPEND; | ||
56 | ehci_dbg(ehci, "Sending LPM 0x%08x to port %d\n", val32, port); | ||
57 | ehci_writel(ehci, val32, portsc); | ||
58 | /* wait for ACK */ | ||
59 | msleep(10); | ||
60 | retval = handshake(ehci, &ehci->regs->port_status[port-1], PORT_SSTS, | ||
61 | PORTSC_SUSPEND_STS_ACK, 125); | ||
62 | dbg_port(ehci, "LPM", port, val32); | ||
63 | if (retval != -ETIMEDOUT) { | ||
64 | ehci_dbg(ehci, "LPM: device ACK for LPM\n"); | ||
65 | val32 |= PORT_LPM; | ||
66 | /* | ||
67 | * now device should be in L1 sleep, let's wake up the device | ||
68 | * so that we can complete enumeration. | ||
69 | */ | ||
70 | ehci_writel(ehci, val32, portsc); | ||
71 | msleep(10); | ||
72 | val32 |= PORT_RESUME; | ||
73 | ehci_writel(ehci, val32, portsc); | ||
74 | } else { | ||
75 | ehci_dbg(ehci, "LPM: device does not ACK, disable LPM %d\n", | ||
76 | retval); | ||
77 | val32 &= ~PORT_LPM; | ||
78 | retval = -ETIMEDOUT; | ||
79 | ehci_writel(ehci, val32, portsc); | ||
80 | } | ||
81 | |||
82 | return retval; | ||
83 | } | ||
diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c index 5450e628157f..116ae280053a 100644 --- a/drivers/usb/host/ehci-omap.c +++ b/drivers/usb/host/ehci-omap.c | |||
@@ -38,6 +38,7 @@ | |||
38 | #include <linux/gpio.h> | 38 | #include <linux/gpio.h> |
39 | #include <linux/regulator/consumer.h> | 39 | #include <linux/regulator/consumer.h> |
40 | #include <linux/slab.h> | 40 | #include <linux/slab.h> |
41 | #include <linux/usb/ulpi.h> | ||
41 | #include <plat/usb.h> | 42 | #include <plat/usb.h> |
42 | 43 | ||
43 | /* | 44 | /* |
@@ -236,6 +237,35 @@ static void omap_usb_utmi_init(struct ehci_hcd_omap *omap, u8 tll_channel_mask) | |||
236 | 237 | ||
237 | /*-------------------------------------------------------------------------*/ | 238 | /*-------------------------------------------------------------------------*/ |
238 | 239 | ||
240 | static void omap_ehci_soft_phy_reset(struct ehci_hcd_omap *omap, u8 port) | ||
241 | { | ||
242 | unsigned long timeout = jiffies + msecs_to_jiffies(1000); | ||
243 | unsigned reg = 0; | ||
244 | |||
245 | reg = ULPI_FUNC_CTRL_RESET | ||
246 | /* FUNCTION_CTRL_SET register */ | ||
247 | | (ULPI_SET(ULPI_FUNC_CTRL) << EHCI_INSNREG05_ULPI_REGADD_SHIFT) | ||
248 | /* Write */ | ||
249 | | (2 << EHCI_INSNREG05_ULPI_OPSEL_SHIFT) | ||
250 | /* PORTn */ | ||
251 | | ((port + 1) << EHCI_INSNREG05_ULPI_PORTSEL_SHIFT) | ||
252 | /* start ULPI access*/ | ||
253 | | (1 << EHCI_INSNREG05_ULPI_CONTROL_SHIFT); | ||
254 | |||
255 | ehci_omap_writel(omap->ehci_base, EHCI_INSNREG05_ULPI, reg); | ||
256 | |||
257 | /* Wait for ULPI access completion */ | ||
258 | while ((ehci_omap_readl(omap->ehci_base, EHCI_INSNREG05_ULPI) | ||
259 | & (1 << EHCI_INSNREG05_ULPI_CONTROL_SHIFT))) { | ||
260 | cpu_relax(); | ||
261 | |||
262 | if (time_after(jiffies, timeout)) { | ||
263 | dev_dbg(omap->dev, "phy reset operation timed out\n"); | ||
264 | break; | ||
265 | } | ||
266 | } | ||
267 | } | ||
268 | |||
239 | /* omap_start_ehc | 269 | /* omap_start_ehc |
240 | * - Start the TI USBHOST controller | 270 | * - Start the TI USBHOST controller |
241 | */ | 271 | */ |
@@ -425,6 +455,12 @@ static int omap_start_ehc(struct ehci_hcd_omap *omap, struct usb_hcd *hcd) | |||
425 | gpio_set_value(omap->reset_gpio_port[1], 1); | 455 | gpio_set_value(omap->reset_gpio_port[1], 1); |
426 | } | 456 | } |
427 | 457 | ||
458 | /* Soft reset the PHY using PHY reset command over ULPI */ | ||
459 | if (omap->port_mode[0] == EHCI_HCD_OMAP_MODE_PHY) | ||
460 | omap_ehci_soft_phy_reset(omap, 0); | ||
461 | if (omap->port_mode[1] == EHCI_HCD_OMAP_MODE_PHY) | ||
462 | omap_ehci_soft_phy_reset(omap, 1); | ||
463 | |||
428 | return 0; | 464 | return 0; |
429 | 465 | ||
430 | err_sys_status: | 466 | err_sys_status: |
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c index d43d176161aa..58b72d741d93 100644 --- a/drivers/usb/host/ehci-pci.c +++ b/drivers/usb/host/ehci-pci.c | |||
@@ -114,6 +114,7 @@ static int ehci_pci_setup(struct usb_hcd *hcd) | |||
114 | break; | 114 | break; |
115 | case PCI_VENDOR_ID_INTEL: | 115 | case PCI_VENDOR_ID_INTEL: |
116 | ehci->need_io_watchdog = 0; | 116 | ehci->need_io_watchdog = 0; |
117 | ehci->fs_i_thresh = 1; | ||
117 | if (pdev->device == 0x27cc) { | 118 | if (pdev->device == 0x27cc) { |
118 | ehci->broken_periodic = 1; | 119 | ehci->broken_periodic = 1; |
119 | ehci_info(ehci, "using broken periodic workaround\n"); | 120 | ehci_info(ehci, "using broken periodic workaround\n"); |
@@ -277,7 +278,7 @@ done: | |||
277 | * Also they depend on separate root hub suspend/resume. | 278 | * Also they depend on separate root hub suspend/resume. |
278 | */ | 279 | */ |
279 | 280 | ||
280 | static int ehci_pci_suspend(struct usb_hcd *hcd) | 281 | static int ehci_pci_suspend(struct usb_hcd *hcd, bool do_wakeup) |
281 | { | 282 | { |
282 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | 283 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); |
283 | unsigned long flags; | 284 | unsigned long flags; |
@@ -291,7 +292,7 @@ static int ehci_pci_suspend(struct usb_hcd *hcd) | |||
291 | * the root hub is either suspended or stopped. | 292 | * the root hub is either suspended or stopped. |
292 | */ | 293 | */ |
293 | spin_lock_irqsave (&ehci->lock, flags); | 294 | spin_lock_irqsave (&ehci->lock, flags); |
294 | ehci_prepare_ports_for_controller_suspend(ehci); | 295 | ehci_prepare_ports_for_controller_suspend(ehci, do_wakeup); |
295 | ehci_writel(ehci, 0, &ehci->regs->intr_enable); | 296 | ehci_writel(ehci, 0, &ehci->regs->intr_enable); |
296 | (void)ehci_readl(ehci, &ehci->regs->intr_enable); | 297 | (void)ehci_readl(ehci, &ehci->regs->intr_enable); |
297 | 298 | ||
@@ -361,6 +362,22 @@ static int ehci_pci_resume(struct usb_hcd *hcd, bool hibernated) | |||
361 | } | 362 | } |
362 | #endif | 363 | #endif |
363 | 364 | ||
365 | static int ehci_update_device(struct usb_hcd *hcd, struct usb_device *udev) | ||
366 | { | ||
367 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | ||
368 | int rc = 0; | ||
369 | |||
370 | if (!udev->parent) /* udev is root hub itself, impossible */ | ||
371 | rc = -1; | ||
372 | /* we only support lpm device connected to root hub yet */ | ||
373 | if (ehci->has_lpm && !udev->parent->parent) { | ||
374 | rc = ehci_lpm_set_da(ehci, udev->devnum, udev->portnum); | ||
375 | if (!rc) | ||
376 | rc = ehci_lpm_check(ehci, udev->portnum); | ||
377 | } | ||
378 | return rc; | ||
379 | } | ||
380 | |||
364 | static const struct hc_driver ehci_pci_hc_driver = { | 381 | static const struct hc_driver ehci_pci_hc_driver = { |
365 | .description = hcd_name, | 382 | .description = hcd_name, |
366 | .product_desc = "EHCI Host Controller", | 383 | .product_desc = "EHCI Host Controller", |
@@ -407,6 +424,11 @@ static const struct hc_driver ehci_pci_hc_driver = { | |||
407 | .relinquish_port = ehci_relinquish_port, | 424 | .relinquish_port = ehci_relinquish_port, |
408 | .port_handed_over = ehci_port_handed_over, | 425 | .port_handed_over = ehci_port_handed_over, |
409 | 426 | ||
427 | /* | ||
428 | * call back when device connected and addressed | ||
429 | */ | ||
430 | .update_device = ehci_update_device, | ||
431 | |||
410 | .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, | 432 | .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, |
411 | }; | 433 | }; |
412 | 434 | ||
diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c index 11a79c4f4a9d..233c288e3f93 100644 --- a/drivers/usb/host/ehci-q.c +++ b/drivers/usb/host/ehci-q.c | |||
@@ -1126,8 +1126,7 @@ submit_async ( | |||
1126 | #endif | 1126 | #endif |
1127 | 1127 | ||
1128 | spin_lock_irqsave (&ehci->lock, flags); | 1128 | spin_lock_irqsave (&ehci->lock, flags); |
1129 | if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE, | 1129 | if (unlikely(!HCD_HW_ACCESSIBLE(ehci_to_hcd(ehci)))) { |
1130 | &ehci_to_hcd(ehci)->flags))) { | ||
1131 | rc = -ESHUTDOWN; | 1130 | rc = -ESHUTDOWN; |
1132 | goto done; | 1131 | goto done; |
1133 | } | 1132 | } |
diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c index 805ec633a652..a92526d6e5ae 100644 --- a/drivers/usb/host/ehci-sched.c +++ b/drivers/usb/host/ehci-sched.c | |||
@@ -880,8 +880,7 @@ static int intr_submit ( | |||
880 | 880 | ||
881 | spin_lock_irqsave (&ehci->lock, flags); | 881 | spin_lock_irqsave (&ehci->lock, flags); |
882 | 882 | ||
883 | if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE, | 883 | if (unlikely(!HCD_HW_ACCESSIBLE(ehci_to_hcd(ehci)))) { |
884 | &ehci_to_hcd(ehci)->flags))) { | ||
885 | status = -ESHUTDOWN; | 884 | status = -ESHUTDOWN; |
886 | goto done_not_linked; | 885 | goto done_not_linked; |
887 | } | 886 | } |
@@ -1075,15 +1074,6 @@ iso_stream_put(struct ehci_hcd *ehci, struct ehci_iso_stream *stream) | |||
1075 | if (stream->ep) | 1074 | if (stream->ep) |
1076 | stream->ep->hcpriv = NULL; | 1075 | stream->ep->hcpriv = NULL; |
1077 | 1076 | ||
1078 | if (stream->rescheduled) { | ||
1079 | ehci_info (ehci, "ep%d%s-iso rescheduled " | ||
1080 | "%lu times in %lu seconds\n", | ||
1081 | stream->bEndpointAddress, is_in ? "in" : "out", | ||
1082 | stream->rescheduled, | ||
1083 | ((jiffies - stream->start)/HZ) | ||
1084 | ); | ||
1085 | } | ||
1086 | |||
1087 | kfree(stream); | 1077 | kfree(stream); |
1088 | } | 1078 | } |
1089 | } | 1079 | } |
@@ -1396,30 +1386,25 @@ iso_stream_schedule ( | |||
1396 | struct ehci_iso_stream *stream | 1386 | struct ehci_iso_stream *stream |
1397 | ) | 1387 | ) |
1398 | { | 1388 | { |
1399 | u32 now, next, start, period; | 1389 | u32 now, next, start, period, span; |
1400 | int status; | 1390 | int status; |
1401 | unsigned mod = ehci->periodic_size << 3; | 1391 | unsigned mod = ehci->periodic_size << 3; |
1402 | struct ehci_iso_sched *sched = urb->hcpriv; | 1392 | struct ehci_iso_sched *sched = urb->hcpriv; |
1403 | struct pci_dev *pdev; | ||
1404 | 1393 | ||
1405 | if (sched->span > (mod - SCHEDULE_SLOP)) { | 1394 | period = urb->interval; |
1406 | ehci_dbg (ehci, "iso request %p too long\n", urb); | 1395 | span = sched->span; |
1407 | status = -EFBIG; | 1396 | if (!stream->highspeed) { |
1408 | goto fail; | 1397 | period <<= 3; |
1398 | span <<= 3; | ||
1409 | } | 1399 | } |
1410 | 1400 | ||
1411 | if ((stream->depth + sched->span) > mod) { | 1401 | if (span > mod - SCHEDULE_SLOP) { |
1412 | ehci_dbg (ehci, "request %p would overflow (%d+%d>%d)\n", | 1402 | ehci_dbg (ehci, "iso request %p too long\n", urb); |
1413 | urb, stream->depth, sched->span, mod); | ||
1414 | status = -EFBIG; | 1403 | status = -EFBIG; |
1415 | goto fail; | 1404 | goto fail; |
1416 | } | 1405 | } |
1417 | 1406 | ||
1418 | period = urb->interval; | 1407 | now = ehci_readl(ehci, &ehci->regs->frame_index) & (mod - 1); |
1419 | if (!stream->highspeed) | ||
1420 | period <<= 3; | ||
1421 | |||
1422 | now = ehci_readl(ehci, &ehci->regs->frame_index) % mod; | ||
1423 | 1408 | ||
1424 | /* Typical case: reuse current schedule, stream is still active. | 1409 | /* Typical case: reuse current schedule, stream is still active. |
1425 | * Hopefully there are no gaps from the host falling behind | 1410 | * Hopefully there are no gaps from the host falling behind |
@@ -1427,34 +1412,35 @@ iso_stream_schedule ( | |||
1427 | * slot in the schedule, implicitly assuming URB_ISO_ASAP. | 1412 | * slot in the schedule, implicitly assuming URB_ISO_ASAP. |
1428 | */ | 1413 | */ |
1429 | if (likely (!list_empty (&stream->td_list))) { | 1414 | if (likely (!list_empty (&stream->td_list))) { |
1430 | pdev = to_pci_dev(ehci_to_hcd(ehci)->self.controller); | 1415 | u32 excess; |
1431 | start = stream->next_uframe; | ||
1432 | 1416 | ||
1433 | /* For high speed devices, allow scheduling within the | 1417 | /* For high speed devices, allow scheduling within the |
1434 | * isochronous scheduling threshold. For full speed devices, | 1418 | * isochronous scheduling threshold. For full speed devices |
1435 | * don't. (Work around for Intel ICH9 bug.) | 1419 | * and Intel PCI-based controllers, don't (work around for |
1420 | * Intel ICH9 bug). | ||
1436 | */ | 1421 | */ |
1437 | if (!stream->highspeed && | 1422 | if (!stream->highspeed && ehci->fs_i_thresh) |
1438 | pdev->vendor == PCI_VENDOR_ID_INTEL) | ||
1439 | next = now + ehci->i_thresh; | 1423 | next = now + ehci->i_thresh; |
1440 | else | 1424 | else |
1441 | next = now; | 1425 | next = now; |
1442 | 1426 | ||
1443 | /* Fell behind (by up to twice the slop amount)? */ | 1427 | /* Fell behind (by up to twice the slop amount)? |
1444 | if (((start - next) & (mod - 1)) >= | 1428 | * We decide based on the time of the last currently-scheduled |
1445 | mod - 2 * SCHEDULE_SLOP) | 1429 | * slot, not the time of the next available slot. |
1446 | start += period * DIV_ROUND_UP( | 1430 | */ |
1447 | (next - start) & (mod - 1), | 1431 | excess = (stream->next_uframe - period - next) & (mod - 1); |
1448 | period); | 1432 | if (excess >= mod - 2 * SCHEDULE_SLOP) |
1449 | 1433 | start = next + excess - mod + period * | |
1450 | /* Tried to schedule too far into the future? */ | 1434 | DIV_ROUND_UP(mod - excess, period); |
1451 | if (unlikely(((start - now) & (mod - 1)) + sched->span | 1435 | else |
1452 | >= mod - 2 * SCHEDULE_SLOP)) { | 1436 | start = next + excess + period; |
1437 | if (start - now >= mod) { | ||
1438 | ehci_dbg(ehci, "request %p would overflow (%d+%d >= %d)\n", | ||
1439 | urb, start - now - period, period, | ||
1440 | mod); | ||
1453 | status = -EFBIG; | 1441 | status = -EFBIG; |
1454 | goto fail; | 1442 | goto fail; |
1455 | } | 1443 | } |
1456 | stream->next_uframe = start; | ||
1457 | goto ready; | ||
1458 | } | 1444 | } |
1459 | 1445 | ||
1460 | /* need to schedule; when's the next (u)frame we could start? | 1446 | /* need to schedule; when's the next (u)frame we could start? |
@@ -1463,51 +1449,60 @@ iso_stream_schedule ( | |||
1463 | * can also help high bandwidth if the dma and irq loads don't | 1449 | * can also help high bandwidth if the dma and irq loads don't |
1464 | * jump until after the queue is primed. | 1450 | * jump until after the queue is primed. |
1465 | */ | 1451 | */ |
1466 | start = SCHEDULE_SLOP + (now & ~0x07); | 1452 | else { |
1467 | start %= mod; | 1453 | start = SCHEDULE_SLOP + (now & ~0x07); |
1468 | stream->next_uframe = start; | 1454 | |
1469 | 1455 | /* NOTE: assumes URB_ISO_ASAP, to limit complexity/bugs */ | |
1470 | /* NOTE: assumes URB_ISO_ASAP, to limit complexity/bugs */ | 1456 | |
1471 | 1457 | /* find a uframe slot with enough bandwidth */ | |
1472 | /* find a uframe slot with enough bandwidth */ | 1458 | next = start + period; |
1473 | for (; start < (stream->next_uframe + period); start++) { | 1459 | for (; start < next; start++) { |
1474 | int enough_space; | 1460 | |
1475 | 1461 | /* check schedule: enough space? */ | |
1476 | /* check schedule: enough space? */ | 1462 | if (stream->highspeed) { |
1477 | if (stream->highspeed) | 1463 | if (itd_slot_ok(ehci, mod, start, |
1478 | enough_space = itd_slot_ok (ehci, mod, start, | 1464 | stream->usecs, period)) |
1479 | stream->usecs, period); | 1465 | break; |
1480 | else { | 1466 | } else { |
1481 | if ((start % 8) >= 6) | 1467 | if ((start % 8) >= 6) |
1482 | continue; | 1468 | continue; |
1483 | enough_space = sitd_slot_ok (ehci, mod, stream, | 1469 | if (sitd_slot_ok(ehci, mod, stream, |
1484 | start, sched, period); | 1470 | start, sched, period)) |
1471 | break; | ||
1472 | } | ||
1485 | } | 1473 | } |
1486 | 1474 | ||
1487 | /* schedule it here if there's enough bandwidth */ | 1475 | /* no room in the schedule */ |
1488 | if (enough_space) { | 1476 | if (start == next) { |
1489 | stream->next_uframe = start % mod; | 1477 | ehci_dbg(ehci, "iso resched full %p (now %d max %d)\n", |
1490 | goto ready; | 1478 | urb, now, now + mod); |
1479 | status = -ENOSPC; | ||
1480 | goto fail; | ||
1491 | } | 1481 | } |
1492 | } | 1482 | } |
1493 | 1483 | ||
1494 | /* no room in the schedule */ | 1484 | /* Tried to schedule too far into the future? */ |
1495 | ehci_dbg (ehci, "iso %ssched full %p (now %d max %d)\n", | 1485 | if (unlikely(start - now + span - period |
1496 | list_empty (&stream->td_list) ? "" : "re", | 1486 | >= mod - 2 * SCHEDULE_SLOP)) { |
1497 | urb, now, now + mod); | 1487 | ehci_dbg(ehci, "request %p would overflow (%d+%d >= %d)\n", |
1498 | status = -ENOSPC; | 1488 | urb, start - now, span - period, |
1489 | mod - 2 * SCHEDULE_SLOP); | ||
1490 | status = -EFBIG; | ||
1491 | goto fail; | ||
1492 | } | ||
1499 | 1493 | ||
1500 | fail: | 1494 | stream->next_uframe = start & (mod - 1); |
1501 | iso_sched_free (stream, sched); | ||
1502 | urb->hcpriv = NULL; | ||
1503 | return status; | ||
1504 | 1495 | ||
1505 | ready: | ||
1506 | /* report high speed start in uframes; full speed, in frames */ | 1496 | /* report high speed start in uframes; full speed, in frames */ |
1507 | urb->start_frame = stream->next_uframe; | 1497 | urb->start_frame = stream->next_uframe; |
1508 | if (!stream->highspeed) | 1498 | if (!stream->highspeed) |
1509 | urb->start_frame >>= 3; | 1499 | urb->start_frame >>= 3; |
1510 | return 0; | 1500 | return 0; |
1501 | |||
1502 | fail: | ||
1503 | iso_sched_free(stream, sched); | ||
1504 | urb->hcpriv = NULL; | ||
1505 | return status; | ||
1511 | } | 1506 | } |
1512 | 1507 | ||
1513 | /*-------------------------------------------------------------------------*/ | 1508 | /*-------------------------------------------------------------------------*/ |
@@ -1602,7 +1597,7 @@ itd_link_urb ( | |||
1602 | struct ehci_iso_sched *iso_sched = urb->hcpriv; | 1597 | struct ehci_iso_sched *iso_sched = urb->hcpriv; |
1603 | struct ehci_itd *itd; | 1598 | struct ehci_itd *itd; |
1604 | 1599 | ||
1605 | next_uframe = stream->next_uframe % mod; | 1600 | next_uframe = stream->next_uframe & (mod - 1); |
1606 | 1601 | ||
1607 | if (unlikely (list_empty(&stream->td_list))) { | 1602 | if (unlikely (list_empty(&stream->td_list))) { |
1608 | ehci_to_hcd(ehci)->self.bandwidth_allocated | 1603 | ehci_to_hcd(ehci)->self.bandwidth_allocated |
@@ -1613,7 +1608,6 @@ itd_link_urb ( | |||
1613 | (stream->bEndpointAddress & USB_DIR_IN) ? "in" : "out", | 1608 | (stream->bEndpointAddress & USB_DIR_IN) ? "in" : "out", |
1614 | urb->interval, | 1609 | urb->interval, |
1615 | next_uframe >> 3, next_uframe & 0x7); | 1610 | next_uframe >> 3, next_uframe & 0x7); |
1616 | stream->start = jiffies; | ||
1617 | } | 1611 | } |
1618 | ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs++; | 1612 | ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs++; |
1619 | 1613 | ||
@@ -1639,14 +1633,13 @@ itd_link_urb ( | |||
1639 | itd_patch(ehci, itd, iso_sched, packet, uframe); | 1633 | itd_patch(ehci, itd, iso_sched, packet, uframe); |
1640 | 1634 | ||
1641 | next_uframe += stream->interval; | 1635 | next_uframe += stream->interval; |
1642 | stream->depth += stream->interval; | 1636 | next_uframe &= mod - 1; |
1643 | next_uframe %= mod; | ||
1644 | packet++; | 1637 | packet++; |
1645 | 1638 | ||
1646 | /* link completed itds into the schedule */ | 1639 | /* link completed itds into the schedule */ |
1647 | if (((next_uframe >> 3) != frame) | 1640 | if (((next_uframe >> 3) != frame) |
1648 | || packet == urb->number_of_packets) { | 1641 | || packet == urb->number_of_packets) { |
1649 | itd_link (ehci, frame % ehci->periodic_size, itd); | 1642 | itd_link(ehci, frame & (ehci->periodic_size - 1), itd); |
1650 | itd = NULL; | 1643 | itd = NULL; |
1651 | } | 1644 | } |
1652 | } | 1645 | } |
@@ -1695,7 +1688,6 @@ itd_complete ( | |||
1695 | 1688 | ||
1696 | t = hc32_to_cpup(ehci, &itd->hw_transaction [uframe]); | 1689 | t = hc32_to_cpup(ehci, &itd->hw_transaction [uframe]); |
1697 | itd->hw_transaction [uframe] = 0; | 1690 | itd->hw_transaction [uframe] = 0; |
1698 | stream->depth -= stream->interval; | ||
1699 | 1691 | ||
1700 | /* report transfer status */ | 1692 | /* report transfer status */ |
1701 | if (unlikely (t & ISO_ERRS)) { | 1693 | if (unlikely (t & ISO_ERRS)) { |
@@ -1815,8 +1807,7 @@ static int itd_submit (struct ehci_hcd *ehci, struct urb *urb, | |||
1815 | 1807 | ||
1816 | /* schedule ... need to lock */ | 1808 | /* schedule ... need to lock */ |
1817 | spin_lock_irqsave (&ehci->lock, flags); | 1809 | spin_lock_irqsave (&ehci->lock, flags); |
1818 | if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE, | 1810 | if (unlikely(!HCD_HW_ACCESSIBLE(ehci_to_hcd(ehci)))) { |
1819 | &ehci_to_hcd(ehci)->flags))) { | ||
1820 | status = -ESHUTDOWN; | 1811 | status = -ESHUTDOWN; |
1821 | goto done_not_linked; | 1812 | goto done_not_linked; |
1822 | } | 1813 | } |
@@ -2024,9 +2015,8 @@ sitd_link_urb ( | |||
2024 | "sched devp %s ep%d%s-iso [%d] %dms/%04x\n", | 2015 | "sched devp %s ep%d%s-iso [%d] %dms/%04x\n", |
2025 | urb->dev->devpath, stream->bEndpointAddress & 0x0f, | 2016 | urb->dev->devpath, stream->bEndpointAddress & 0x0f, |
2026 | (stream->bEndpointAddress & USB_DIR_IN) ? "in" : "out", | 2017 | (stream->bEndpointAddress & USB_DIR_IN) ? "in" : "out", |
2027 | (next_uframe >> 3) % ehci->periodic_size, | 2018 | (next_uframe >> 3) & (ehci->periodic_size - 1), |
2028 | stream->interval, hc32_to_cpu(ehci, stream->splits)); | 2019 | stream->interval, hc32_to_cpu(ehci, stream->splits)); |
2029 | stream->start = jiffies; | ||
2030 | } | 2020 | } |
2031 | ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs++; | 2021 | ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs++; |
2032 | 2022 | ||
@@ -2047,13 +2037,12 @@ sitd_link_urb ( | |||
2047 | sitd->urb = urb; | 2037 | sitd->urb = urb; |
2048 | 2038 | ||
2049 | sitd_patch(ehci, stream, sitd, sched, packet); | 2039 | sitd_patch(ehci, stream, sitd, sched, packet); |
2050 | sitd_link (ehci, (next_uframe >> 3) % ehci->periodic_size, | 2040 | sitd_link(ehci, (next_uframe >> 3) & (ehci->periodic_size - 1), |
2051 | sitd); | 2041 | sitd); |
2052 | 2042 | ||
2053 | next_uframe += stream->interval << 3; | 2043 | next_uframe += stream->interval << 3; |
2054 | stream->depth += stream->interval << 3; | ||
2055 | } | 2044 | } |
2056 | stream->next_uframe = next_uframe % mod; | 2045 | stream->next_uframe = next_uframe & (mod - 1); |
2057 | 2046 | ||
2058 | /* don't need that schedule data any more */ | 2047 | /* don't need that schedule data any more */ |
2059 | iso_sched_free (stream, sched); | 2048 | iso_sched_free (stream, sched); |
@@ -2111,7 +2100,6 @@ sitd_complete ( | |||
2111 | desc->actual_length = desc->length - SITD_LENGTH(t); | 2100 | desc->actual_length = desc->length - SITD_LENGTH(t); |
2112 | urb->actual_length += desc->actual_length; | 2101 | urb->actual_length += desc->actual_length; |
2113 | } | 2102 | } |
2114 | stream->depth -= stream->interval << 3; | ||
2115 | 2103 | ||
2116 | /* handle completion now? */ | 2104 | /* handle completion now? */ |
2117 | if ((urb_index + 1) != urb->number_of_packets) | 2105 | if ((urb_index + 1) != urb->number_of_packets) |
@@ -2201,8 +2189,7 @@ static int sitd_submit (struct ehci_hcd *ehci, struct urb *urb, | |||
2201 | 2189 | ||
2202 | /* schedule ... need to lock */ | 2190 | /* schedule ... need to lock */ |
2203 | spin_lock_irqsave (&ehci->lock, flags); | 2191 | spin_lock_irqsave (&ehci->lock, flags); |
2204 | if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE, | 2192 | if (unlikely(!HCD_HW_ACCESSIBLE(ehci_to_hcd(ehci)))) { |
2205 | &ehci_to_hcd(ehci)->flags))) { | ||
2206 | status = -ESHUTDOWN; | 2193 | status = -ESHUTDOWN; |
2207 | goto done_not_linked; | 2194 | goto done_not_linked; |
2208 | } | 2195 | } |
@@ -2263,7 +2250,7 @@ scan_periodic (struct ehci_hcd *ehci) | |||
2263 | now_uframe = ehci->next_uframe; | 2250 | now_uframe = ehci->next_uframe; |
2264 | if (HC_IS_RUNNING(ehci_to_hcd(ehci)->state)) { | 2251 | if (HC_IS_RUNNING(ehci_to_hcd(ehci)->state)) { |
2265 | clock = ehci_readl(ehci, &ehci->regs->frame_index); | 2252 | clock = ehci_readl(ehci, &ehci->regs->frame_index); |
2266 | clock_frame = (clock >> 3) % ehci->periodic_size; | 2253 | clock_frame = (clock >> 3) & (ehci->periodic_size - 1); |
2267 | } else { | 2254 | } else { |
2268 | clock = now_uframe + mod - 1; | 2255 | clock = now_uframe + mod - 1; |
2269 | clock_frame = -1; | 2256 | clock_frame = -1; |
@@ -2272,7 +2259,7 @@ scan_periodic (struct ehci_hcd *ehci) | |||
2272 | free_cached_lists(ehci); | 2259 | free_cached_lists(ehci); |
2273 | ehci->clock_frame = clock_frame; | 2260 | ehci->clock_frame = clock_frame; |
2274 | } | 2261 | } |
2275 | clock %= mod; | 2262 | clock &= mod - 1; |
2276 | clock_frame = clock >> 3; | 2263 | clock_frame = clock >> 3; |
2277 | 2264 | ||
2278 | for (;;) { | 2265 | for (;;) { |
@@ -2361,7 +2348,7 @@ restart: | |||
2361 | * frame is current. | 2348 | * frame is current. |
2362 | */ | 2349 | */ |
2363 | if (((frame == clock_frame) || | 2350 | if (((frame == clock_frame) || |
2364 | (((frame + 1) % ehci->periodic_size) | 2351 | (((frame + 1) & (ehci->periodic_size - 1)) |
2365 | == clock_frame)) | 2352 | == clock_frame)) |
2366 | && live | 2353 | && live |
2367 | && (q.sitd->hw_results & | 2354 | && (q.sitd->hw_results & |
@@ -2428,7 +2415,8 @@ restart: | |||
2428 | || ehci->periodic_sched == 0) | 2415 | || ehci->periodic_sched == 0) |
2429 | break; | 2416 | break; |
2430 | ehci->next_uframe = now_uframe; | 2417 | ehci->next_uframe = now_uframe; |
2431 | now = ehci_readl(ehci, &ehci->regs->frame_index) % mod; | 2418 | now = ehci_readl(ehci, &ehci->regs->frame_index) & |
2419 | (mod - 1); | ||
2432 | if (now_uframe == now) | 2420 | if (now_uframe == now) |
2433 | break; | 2421 | break; |
2434 | 2422 | ||
@@ -2441,7 +2429,7 @@ restart: | |||
2441 | } | 2429 | } |
2442 | } else { | 2430 | } else { |
2443 | now_uframe++; | 2431 | now_uframe++; |
2444 | now_uframe %= mod; | 2432 | now_uframe &= mod - 1; |
2445 | } | 2433 | } |
2446 | } | 2434 | } |
2447 | } | 2435 | } |
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h index 650a687f2854..bde823f704e9 100644 --- a/drivers/usb/host/ehci.h +++ b/drivers/usb/host/ehci.h | |||
@@ -130,6 +130,7 @@ struct ehci_hcd { /* one per controller */ | |||
130 | unsigned has_amcc_usb23:1; | 130 | unsigned has_amcc_usb23:1; |
131 | unsigned need_io_watchdog:1; | 131 | unsigned need_io_watchdog:1; |
132 | unsigned broken_periodic:1; | 132 | unsigned broken_periodic:1; |
133 | unsigned fs_i_thresh:1; /* Intel iso scheduling */ | ||
133 | 134 | ||
134 | /* required for usb32 quirk */ | 135 | /* required for usb32 quirk */ |
135 | #define OHCI_CTRL_HCFS (3 << 6) | 136 | #define OHCI_CTRL_HCFS (3 << 6) |
@@ -140,7 +141,8 @@ struct ehci_hcd { /* one per controller */ | |||
140 | #define OHCI_HCCTRL_LEN 0x4 | 141 | #define OHCI_HCCTRL_LEN 0x4 |
141 | __hc32 *ohci_hcctrl_reg; | 142 | __hc32 *ohci_hcctrl_reg; |
142 | unsigned has_hostpc:1; | 143 | unsigned has_hostpc:1; |
143 | 144 | unsigned has_lpm:1; /* support link power management */ | |
145 | unsigned has_ppcd:1; /* support per-port change bits */ | ||
144 | u8 sbrn; /* packed release number */ | 146 | u8 sbrn; /* packed release number */ |
145 | 147 | ||
146 | /* irq statistics */ | 148 | /* irq statistics */ |
@@ -154,9 +156,6 @@ struct ehci_hcd { /* one per controller */ | |||
154 | /* debug files */ | 156 | /* debug files */ |
155 | #ifdef DEBUG | 157 | #ifdef DEBUG |
156 | struct dentry *debug_dir; | 158 | struct dentry *debug_dir; |
157 | struct dentry *debug_async; | ||
158 | struct dentry *debug_periodic; | ||
159 | struct dentry *debug_registers; | ||
160 | #endif | 159 | #endif |
161 | }; | 160 | }; |
162 | 161 | ||
@@ -401,15 +400,12 @@ struct ehci_iso_stream { | |||
401 | u32 refcount; | 400 | u32 refcount; |
402 | u8 bEndpointAddress; | 401 | u8 bEndpointAddress; |
403 | u8 highspeed; | 402 | u8 highspeed; |
404 | u16 depth; /* depth in uframes */ | ||
405 | struct list_head td_list; /* queued itds/sitds */ | 403 | struct list_head td_list; /* queued itds/sitds */ |
406 | struct list_head free_list; /* list of unused itds/sitds */ | 404 | struct list_head free_list; /* list of unused itds/sitds */ |
407 | struct usb_device *udev; | 405 | struct usb_device *udev; |
408 | struct usb_host_endpoint *ep; | 406 | struct usb_host_endpoint *ep; |
409 | 407 | ||
410 | /* output of (re)scheduling */ | 408 | /* output of (re)scheduling */ |
411 | unsigned long start; /* jiffies */ | ||
412 | unsigned long rescheduled; | ||
413 | int next_uframe; | 409 | int next_uframe; |
414 | __hc32 splits; | 410 | __hc32 splits; |
415 | 411 | ||
@@ -538,11 +534,11 @@ struct ehci_fstn { | |||
538 | 534 | ||
539 | /* Prepare the PORTSC wakeup flags during controller suspend/resume */ | 535 | /* Prepare the PORTSC wakeup flags during controller suspend/resume */ |
540 | 536 | ||
541 | #define ehci_prepare_ports_for_controller_suspend(ehci) \ | 537 | #define ehci_prepare_ports_for_controller_suspend(ehci, do_wakeup) \ |
542 | ehci_adjust_port_wakeup_flags(ehci, true); | 538 | ehci_adjust_port_wakeup_flags(ehci, true, do_wakeup); |
543 | 539 | ||
544 | #define ehci_prepare_ports_for_controller_resume(ehci) \ | 540 | #define ehci_prepare_ports_for_controller_resume(ehci) \ |
545 | ehci_adjust_port_wakeup_flags(ehci, false); | 541 | ehci_adjust_port_wakeup_flags(ehci, false, false); |
546 | 542 | ||
547 | /*-------------------------------------------------------------------------*/ | 543 | /*-------------------------------------------------------------------------*/ |
548 | 544 | ||
diff --git a/drivers/usb/host/hwa-hc.c b/drivers/usb/host/hwa-hc.c index 35742f8c7cda..9bfac657572e 100644 --- a/drivers/usb/host/hwa-hc.c +++ b/drivers/usb/host/hwa-hc.c | |||
@@ -159,7 +159,7 @@ static int hwahc_op_start(struct usb_hcd *usb_hcd) | |||
159 | goto error_set_cluster_id; | 159 | goto error_set_cluster_id; |
160 | 160 | ||
161 | usb_hcd->uses_new_polling = 1; | 161 | usb_hcd->uses_new_polling = 1; |
162 | usb_hcd->poll_rh = 1; | 162 | set_bit(HCD_FLAG_POLL_RH, &usb_hcd->flags); |
163 | usb_hcd->state = HC_STATE_RUNNING; | 163 | usb_hcd->state = HC_STATE_RUNNING; |
164 | result = 0; | 164 | result = 0; |
165 | out: | 165 | out: |
@@ -776,7 +776,7 @@ static int hwahc_probe(struct usb_interface *usb_iface, | |||
776 | goto error_alloc; | 776 | goto error_alloc; |
777 | } | 777 | } |
778 | usb_hcd->wireless = 1; | 778 | usb_hcd->wireless = 1; |
779 | usb_hcd->flags |= HCD_FLAG_SAW_IRQ; | 779 | set_bit(HCD_FLAG_SAW_IRQ, &usb_hcd->flags); |
780 | wusbhc = usb_hcd_to_wusbhc(usb_hcd); | 780 | wusbhc = usb_hcd_to_wusbhc(usb_hcd); |
781 | hwahc = container_of(wusbhc, struct hwahc, wusbhc); | 781 | hwahc = container_of(wusbhc, struct hwahc, wusbhc); |
782 | hwahc_init(hwahc); | 782 | hwahc_init(hwahc); |
diff --git a/drivers/usb/host/imx21-hcd.c b/drivers/usb/host/imx21-hcd.c index ca0e98d8e1f4..3e5630369c31 100644 --- a/drivers/usb/host/imx21-hcd.c +++ b/drivers/usb/host/imx21-hcd.c | |||
@@ -1521,7 +1521,7 @@ static int imx21_hc_reset(struct usb_hcd *hcd) | |||
1521 | return -ETIMEDOUT; | 1521 | return -ETIMEDOUT; |
1522 | } | 1522 | } |
1523 | spin_unlock_irq(&imx21->lock); | 1523 | spin_unlock_irq(&imx21->lock); |
1524 | schedule_timeout(1); | 1524 | schedule_timeout_uninterruptible(1); |
1525 | spin_lock_irq(&imx21->lock); | 1525 | spin_lock_irq(&imx21->lock); |
1526 | } | 1526 | } |
1527 | spin_unlock_irqrestore(&imx21->lock, flags); | 1527 | spin_unlock_irqrestore(&imx21->lock, flags); |
diff --git a/drivers/usb/host/isp1362.h b/drivers/usb/host/isp1362.h index d995351f9bed..0f97820e65be 100644 --- a/drivers/usb/host/isp1362.h +++ b/drivers/usb/host/isp1362.h | |||
@@ -8,29 +8,7 @@ | |||
8 | /* | 8 | /* |
9 | * Platform specific compile time options | 9 | * Platform specific compile time options |
10 | */ | 10 | */ |
11 | #if defined(CONFIG_ARCH_KARO) | 11 | #if defined(CONFIG_BLACKFIN) |
12 | #include <asm/arch/hardware.h> | ||
13 | #include <asm/arch/pxa-regs.h> | ||
14 | #include <asm/arch/karo.h> | ||
15 | |||
16 | #define USE_32BIT 1 | ||
17 | |||
18 | |||
19 | /* These options are mutually eclusive */ | ||
20 | #define USE_PLATFORM_DELAY 1 | ||
21 | #define USE_NDELAY 0 | ||
22 | /* | ||
23 | * MAX_ROOT_PORTS: Number of downstream ports | ||
24 | * | ||
25 | * The chip has two USB ports, one of which can be configured as | ||
26 | * an USB device port, so the value of this constant is implementation | ||
27 | * specific. | ||
28 | */ | ||
29 | #define MAX_ROOT_PORTS 2 | ||
30 | #define DUMMY_DELAY_ACCESS do {} while (0) | ||
31 | |||
32 | /* insert platform specific definitions for other machines here */ | ||
33 | #elif defined(CONFIG_BLACKFIN) | ||
34 | 12 | ||
35 | #include <linux/io.h> | 13 | #include <linux/io.h> |
36 | #define USE_32BIT 0 | 14 | #define USE_32BIT 0 |
diff --git a/drivers/usb/host/isp1760-hcd.c b/drivers/usb/host/isp1760-hcd.c index dbcafa29c775..d1a3dfc9a408 100644 --- a/drivers/usb/host/isp1760-hcd.c +++ b/drivers/usb/host/isp1760-hcd.c | |||
@@ -482,7 +482,6 @@ static int isp1760_run(struct usb_hcd *hcd) | |||
482 | u32 chipid; | 482 | u32 chipid; |
483 | 483 | ||
484 | hcd->uses_new_polling = 1; | 484 | hcd->uses_new_polling = 1; |
485 | hcd->poll_rh = 0; | ||
486 | 485 | ||
487 | hcd->state = HC_STATE_RUNNING; | 486 | hcd->state = HC_STATE_RUNNING; |
488 | isp1760_enable_interrupts(hcd); | 487 | isp1760_enable_interrupts(hcd); |
@@ -1450,7 +1449,7 @@ static int isp1760_prepare_enqueue(struct isp1760_hcd *priv, struct urb *urb, | |||
1450 | epnum = urb->ep->desc.bEndpointAddress; | 1449 | epnum = urb->ep->desc.bEndpointAddress; |
1451 | 1450 | ||
1452 | spin_lock_irqsave(&priv->lock, flags); | 1451 | spin_lock_irqsave(&priv->lock, flags); |
1453 | if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &priv_to_hcd(priv)->flags)) { | 1452 | if (!HCD_HW_ACCESSIBLE(priv_to_hcd(priv))) { |
1454 | rc = -ESHUTDOWN; | 1453 | rc = -ESHUTDOWN; |
1455 | goto done; | 1454 | goto done; |
1456 | } | 1455 | } |
diff --git a/drivers/usb/host/ohci-dbg.c b/drivers/usb/host/ohci-dbg.c index 8ad2441b0284..36abd2baa3ea 100644 --- a/drivers/usb/host/ohci-dbg.c +++ b/drivers/usb/host/ohci-dbg.c | |||
@@ -645,7 +645,7 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf) | |||
645 | hcd->product_desc, | 645 | hcd->product_desc, |
646 | hcd_name); | 646 | hcd_name); |
647 | 647 | ||
648 | if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) { | 648 | if (!HCD_HW_ACCESSIBLE(hcd)) { |
649 | size -= scnprintf (next, size, | 649 | size -= scnprintf (next, size, |
650 | "SUSPENDED (no register access)\n"); | 650 | "SUSPENDED (no register access)\n"); |
651 | goto done; | 651 | goto done; |
@@ -687,7 +687,7 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf) | |||
687 | next += temp; | 687 | next += temp; |
688 | 688 | ||
689 | temp = scnprintf (next, size, "hub poll timer %s\n", | 689 | temp = scnprintf (next, size, "hub poll timer %s\n", |
690 | ohci_to_hcd(ohci)->poll_rh ? "ON" : "off"); | 690 | HCD_POLL_RH(ohci_to_hcd(ohci)) ? "ON" : "off"); |
691 | size -= temp; | 691 | size -= temp; |
692 | next += temp; | 692 | next += temp; |
693 | 693 | ||
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index 02864a237a2c..c3b4ccc7337b 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c | |||
@@ -212,7 +212,7 @@ static int ohci_urb_enqueue ( | |||
212 | spin_lock_irqsave (&ohci->lock, flags); | 212 | spin_lock_irqsave (&ohci->lock, flags); |
213 | 213 | ||
214 | /* don't submit to a dead HC */ | 214 | /* don't submit to a dead HC */ |
215 | if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) { | 215 | if (!HCD_HW_ACCESSIBLE(hcd)) { |
216 | retval = -ENODEV; | 216 | retval = -ENODEV; |
217 | goto fail; | 217 | goto fail; |
218 | } | 218 | } |
@@ -685,7 +685,7 @@ retry: | |||
685 | } | 685 | } |
686 | 686 | ||
687 | /* use rhsc irqs after khubd is fully initialized */ | 687 | /* use rhsc irqs after khubd is fully initialized */ |
688 | hcd->poll_rh = 1; | 688 | set_bit(HCD_FLAG_POLL_RH, &hcd->flags); |
689 | hcd->uses_new_polling = 1; | 689 | hcd->uses_new_polling = 1; |
690 | 690 | ||
691 | /* start controller operations */ | 691 | /* start controller operations */ |
@@ -822,7 +822,7 @@ static irqreturn_t ohci_irq (struct usb_hcd *hcd) | |||
822 | else if (ints & OHCI_INTR_RD) { | 822 | else if (ints & OHCI_INTR_RD) { |
823 | ohci_vdbg(ohci, "resume detect\n"); | 823 | ohci_vdbg(ohci, "resume detect\n"); |
824 | ohci_writel(ohci, OHCI_INTR_RD, ®s->intrstatus); | 824 | ohci_writel(ohci, OHCI_INTR_RD, ®s->intrstatus); |
825 | hcd->poll_rh = 1; | 825 | set_bit(HCD_FLAG_POLL_RH, &hcd->flags); |
826 | if (ohci->autostop) { | 826 | if (ohci->autostop) { |
827 | spin_lock (&ohci->lock); | 827 | spin_lock (&ohci->lock); |
828 | ohci_rh_resume (ohci); | 828 | ohci_rh_resume (ohci); |
diff --git a/drivers/usb/host/ohci-hub.c b/drivers/usb/host/ohci-hub.c index 65cac8cc8921..cddcda95b579 100644 --- a/drivers/usb/host/ohci-hub.c +++ b/drivers/usb/host/ohci-hub.c | |||
@@ -284,7 +284,7 @@ static int ohci_bus_suspend (struct usb_hcd *hcd) | |||
284 | 284 | ||
285 | spin_lock_irq (&ohci->lock); | 285 | spin_lock_irq (&ohci->lock); |
286 | 286 | ||
287 | if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags))) | 287 | if (unlikely(!HCD_HW_ACCESSIBLE(hcd))) |
288 | rc = -ESHUTDOWN; | 288 | rc = -ESHUTDOWN; |
289 | else | 289 | else |
290 | rc = ohci_rh_suspend (ohci, 0); | 290 | rc = ohci_rh_suspend (ohci, 0); |
@@ -302,7 +302,7 @@ static int ohci_bus_resume (struct usb_hcd *hcd) | |||
302 | 302 | ||
303 | spin_lock_irq (&ohci->lock); | 303 | spin_lock_irq (&ohci->lock); |
304 | 304 | ||
305 | if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags))) | 305 | if (unlikely(!HCD_HW_ACCESSIBLE(hcd))) |
306 | rc = -ESHUTDOWN; | 306 | rc = -ESHUTDOWN; |
307 | else | 307 | else |
308 | rc = ohci_rh_resume (ohci); | 308 | rc = ohci_rh_resume (ohci); |
@@ -355,6 +355,11 @@ static void ohci_finish_controller_resume(struct usb_hcd *hcd) | |||
355 | ohci_readl(ohci, &ohci->regs->intrenable); | 355 | ohci_readl(ohci, &ohci->regs->intrenable); |
356 | msleep(20); | 356 | msleep(20); |
357 | } | 357 | } |
358 | |||
359 | /* Does the root hub have a port wakeup pending? */ | ||
360 | if (ohci_readl(ohci, &ohci->regs->intrstatus) & | ||
361 | (OHCI_INTR_RD | OHCI_INTR_RHSC)) | ||
362 | usb_hcd_resume_root_hub(hcd); | ||
358 | } | 363 | } |
359 | 364 | ||
360 | /* Carry out polling-, autostop-, and autoresume-related state changes */ | 365 | /* Carry out polling-, autostop-, and autoresume-related state changes */ |
@@ -364,7 +369,7 @@ static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed, | |||
364 | int poll_rh = 1; | 369 | int poll_rh = 1; |
365 | int rhsc_enable; | 370 | int rhsc_enable; |
366 | 371 | ||
367 | /* Some broken controllers never turn off RHCS in the interrupt | 372 | /* Some broken controllers never turn off RHSC in the interrupt |
368 | * status register. For their sake we won't re-enable RHSC | 373 | * status register. For their sake we won't re-enable RHSC |
369 | * interrupts if the interrupt bit is already active. | 374 | * interrupts if the interrupt bit is already active. |
370 | */ | 375 | */ |
@@ -489,7 +494,7 @@ ohci_hub_status_data (struct usb_hcd *hcd, char *buf) | |||
489 | unsigned long flags; | 494 | unsigned long flags; |
490 | 495 | ||
491 | spin_lock_irqsave (&ohci->lock, flags); | 496 | spin_lock_irqsave (&ohci->lock, flags); |
492 | if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) | 497 | if (!HCD_HW_ACCESSIBLE(hcd)) |
493 | goto done; | 498 | goto done; |
494 | 499 | ||
495 | /* undocumented erratum seen on at least rev D */ | 500 | /* undocumented erratum seen on at least rev D */ |
@@ -533,8 +538,12 @@ ohci_hub_status_data (struct usb_hcd *hcd, char *buf) | |||
533 | } | 538 | } |
534 | } | 539 | } |
535 | 540 | ||
536 | hcd->poll_rh = ohci_root_hub_state_changes(ohci, changed, | 541 | if (ohci_root_hub_state_changes(ohci, changed, |
537 | any_connected, rhsc_status); | 542 | any_connected, rhsc_status)) |
543 | set_bit(HCD_FLAG_POLL_RH, &hcd->flags); | ||
544 | else | ||
545 | clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); | ||
546 | |||
538 | 547 | ||
539 | done: | 548 | done: |
540 | spin_unlock_irqrestore (&ohci->lock, flags); | 549 | spin_unlock_irqrestore (&ohci->lock, flags); |
@@ -701,7 +710,7 @@ static int ohci_hub_control ( | |||
701 | u32 temp; | 710 | u32 temp; |
702 | int retval = 0; | 711 | int retval = 0; |
703 | 712 | ||
704 | if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags))) | 713 | if (unlikely(!HCD_HW_ACCESSIBLE(hcd))) |
705 | return -ESHUTDOWN; | 714 | return -ESHUTDOWN; |
706 | 715 | ||
707 | switch (typeReq) { | 716 | switch (typeReq) { |
diff --git a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c index b8a1148f248e..6bdc8b25a6a1 100644 --- a/drivers/usb/host/ohci-pci.c +++ b/drivers/usb/host/ohci-pci.c | |||
@@ -392,7 +392,7 @@ static int __devinit ohci_pci_start (struct usb_hcd *hcd) | |||
392 | 392 | ||
393 | #ifdef CONFIG_PM | 393 | #ifdef CONFIG_PM |
394 | 394 | ||
395 | static int ohci_pci_suspend(struct usb_hcd *hcd) | 395 | static int ohci_pci_suspend(struct usb_hcd *hcd, bool do_wakeup) |
396 | { | 396 | { |
397 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); | 397 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); |
398 | unsigned long flags; | 398 | unsigned long flags; |
diff --git a/drivers/usb/host/ohci-ssb.c b/drivers/usb/host/ohci-ssb.c index 23fd6a886bdd..48ee6943bf35 100644 --- a/drivers/usb/host/ohci-ssb.c +++ b/drivers/usb/host/ohci-ssb.c | |||
@@ -93,8 +93,11 @@ static void ssb_ohci_detach(struct ssb_device *dev) | |||
93 | { | 93 | { |
94 | struct usb_hcd *hcd = ssb_get_drvdata(dev); | 94 | struct usb_hcd *hcd = ssb_get_drvdata(dev); |
95 | 95 | ||
96 | if (hcd->driver->shutdown) | ||
97 | hcd->driver->shutdown(hcd); | ||
96 | usb_remove_hcd(hcd); | 98 | usb_remove_hcd(hcd); |
97 | iounmap(hcd->regs); | 99 | iounmap(hcd->regs); |
100 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
98 | usb_put_hcd(hcd); | 101 | usb_put_hcd(hcd); |
99 | ssb_device_disable(dev, 0); | 102 | ssb_device_disable(dev, 0); |
100 | } | 103 | } |
@@ -106,10 +109,52 @@ static int ssb_ohci_attach(struct ssb_device *dev) | |||
106 | int err = -ENOMEM; | 109 | int err = -ENOMEM; |
107 | u32 tmp, flags = 0; | 110 | u32 tmp, flags = 0; |
108 | 111 | ||
109 | if (dev->id.coreid == SSB_DEV_USB11_HOSTDEV) | 112 | if (dma_set_mask(dev->dma_dev, DMA_BIT_MASK(32)) || |
110 | flags |= SSB_OHCI_TMSLOW_HOSTMODE; | 113 | dma_set_coherent_mask(dev->dma_dev, DMA_BIT_MASK(32))) |
114 | return -EOPNOTSUPP; | ||
111 | 115 | ||
112 | ssb_device_enable(dev, flags); | 116 | if (dev->id.coreid == SSB_DEV_USB11_HOSTDEV) { |
117 | /* Put the device into host-mode. */ | ||
118 | flags |= SSB_OHCI_TMSLOW_HOSTMODE; | ||
119 | ssb_device_enable(dev, flags); | ||
120 | } else if (dev->id.coreid == SSB_DEV_USB20_HOST) { | ||
121 | /* | ||
122 | * USB 2.0 special considerations: | ||
123 | * | ||
124 | * In addition to the standard SSB reset sequence, the Host | ||
125 | * Control Register must be programmed to bring the USB core | ||
126 | * and various phy components out of reset. | ||
127 | */ | ||
128 | ssb_device_enable(dev, 0); | ||
129 | ssb_write32(dev, 0x200, 0x7ff); | ||
130 | |||
131 | /* Change Flush control reg */ | ||
132 | tmp = ssb_read32(dev, 0x400); | ||
133 | tmp &= ~8; | ||
134 | ssb_write32(dev, 0x400, tmp); | ||
135 | tmp = ssb_read32(dev, 0x400); | ||
136 | |||
137 | /* Change Shim control reg */ | ||
138 | tmp = ssb_read32(dev, 0x304); | ||
139 | tmp &= ~0x100; | ||
140 | ssb_write32(dev, 0x304, tmp); | ||
141 | tmp = ssb_read32(dev, 0x304); | ||
142 | |||
143 | udelay(1); | ||
144 | |||
145 | /* Work around for 5354 failures */ | ||
146 | if (dev->id.revision == 2 && dev->bus->chip_id == 0x5354) { | ||
147 | /* Change syn01 reg */ | ||
148 | tmp = 0x00fe00fe; | ||
149 | ssb_write32(dev, 0x894, tmp); | ||
150 | |||
151 | /* Change syn03 reg */ | ||
152 | tmp = ssb_read32(dev, 0x89c); | ||
153 | tmp |= 0x1; | ||
154 | ssb_write32(dev, 0x89c, tmp); | ||
155 | } | ||
156 | } else | ||
157 | ssb_device_enable(dev, 0); | ||
113 | 158 | ||
114 | hcd = usb_create_hcd(&ssb_ohci_hc_driver, dev->dev, | 159 | hcd = usb_create_hcd(&ssb_ohci_hc_driver, dev->dev, |
115 | dev_name(dev->dev)); | 160 | dev_name(dev->dev)); |
@@ -200,6 +245,7 @@ static int ssb_ohci_resume(struct ssb_device *dev) | |||
200 | static const struct ssb_device_id ssb_ohci_table[] = { | 245 | static const struct ssb_device_id ssb_ohci_table[] = { |
201 | SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_USB11_HOSTDEV, SSB_ANY_REV), | 246 | SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_USB11_HOSTDEV, SSB_ANY_REV), |
202 | SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_USB11_HOST, SSB_ANY_REV), | 247 | SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_USB11_HOST, SSB_ANY_REV), |
248 | SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_USB20_HOST, SSB_ANY_REV), | ||
203 | SSB_DEVTABLE_END | 249 | SSB_DEVTABLE_END |
204 | }; | 250 | }; |
205 | MODULE_DEVICE_TABLE(ssb, ssb_ohci_table); | 251 | MODULE_DEVICE_TABLE(ssb, ssb_ohci_table); |
diff --git a/drivers/usb/host/oxu210hp-hcd.c b/drivers/usb/host/oxu210hp-hcd.c index f608dfd09a8a..d9c85a292737 100644 --- a/drivers/usb/host/oxu210hp-hcd.c +++ b/drivers/usb/host/oxu210hp-hcd.c | |||
@@ -1641,8 +1641,7 @@ static int submit_async(struct oxu_hcd *oxu, struct urb *urb, | |||
1641 | #endif | 1641 | #endif |
1642 | 1642 | ||
1643 | spin_lock_irqsave(&oxu->lock, flags); | 1643 | spin_lock_irqsave(&oxu->lock, flags); |
1644 | if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE, | 1644 | if (unlikely(!HCD_HW_ACCESSIBLE(oxu_to_hcd(oxu)))) { |
1645 | &oxu_to_hcd(oxu)->flags))) { | ||
1646 | rc = -ESHUTDOWN; | 1645 | rc = -ESHUTDOWN; |
1647 | goto done; | 1646 | goto done; |
1648 | } | 1647 | } |
@@ -2209,8 +2208,7 @@ static int intr_submit(struct oxu_hcd *oxu, struct urb *urb, | |||
2209 | 2208 | ||
2210 | spin_lock_irqsave(&oxu->lock, flags); | 2209 | spin_lock_irqsave(&oxu->lock, flags); |
2211 | 2210 | ||
2212 | if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE, | 2211 | if (unlikely(!HCD_HW_ACCESSIBLE(oxu_to_hcd(oxu)))) { |
2213 | &oxu_to_hcd(oxu)->flags))) { | ||
2214 | status = -ESHUTDOWN; | 2212 | status = -ESHUTDOWN; |
2215 | goto done; | 2213 | goto done; |
2216 | } | 2214 | } |
@@ -2715,7 +2713,6 @@ static int oxu_run(struct usb_hcd *hcd) | |||
2715 | u32 temp, hcc_params; | 2713 | u32 temp, hcc_params; |
2716 | 2714 | ||
2717 | hcd->uses_new_polling = 1; | 2715 | hcd->uses_new_polling = 1; |
2718 | hcd->poll_rh = 0; | ||
2719 | 2716 | ||
2720 | /* EHCI spec section 4.1 */ | 2717 | /* EHCI spec section 4.1 */ |
2721 | retval = ehci_reset(oxu); | 2718 | retval = ehci_reset(oxu); |
diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c index bcf9f0e809de..990f06b89eaa 100644 --- a/drivers/usb/host/sl811-hcd.c +++ b/drivers/usb/host/sl811-hcd.c | |||
@@ -813,8 +813,11 @@ static int sl811h_urb_enqueue( | |||
813 | #endif | 813 | #endif |
814 | 814 | ||
815 | /* avoid all allocations within spinlocks */ | 815 | /* avoid all allocations within spinlocks */ |
816 | if (!hep->hcpriv) | 816 | if (!hep->hcpriv) { |
817 | ep = kzalloc(sizeof *ep, mem_flags); | 817 | ep = kzalloc(sizeof *ep, mem_flags); |
818 | if (ep == NULL) | ||
819 | return -ENOMEM; | ||
820 | } | ||
818 | 821 | ||
819 | spin_lock_irqsave(&sl811->lock, flags); | 822 | spin_lock_irqsave(&sl811->lock, flags); |
820 | 823 | ||
diff --git a/drivers/usb/host/uhci-debug.c b/drivers/usb/host/uhci-debug.c index 98cf0b26b968..6e7fb5f38db6 100644 --- a/drivers/usb/host/uhci-debug.c +++ b/drivers/usb/host/uhci-debug.c | |||
@@ -17,7 +17,6 @@ | |||
17 | 17 | ||
18 | #include "uhci-hcd.h" | 18 | #include "uhci-hcd.h" |
19 | 19 | ||
20 | #define uhci_debug_operations (* (const struct file_operations *) NULL) | ||
21 | static struct dentry *uhci_debugfs_root; | 20 | static struct dentry *uhci_debugfs_root; |
22 | 21 | ||
23 | #ifdef DEBUG | 22 | #ifdef DEBUG |
@@ -495,18 +494,16 @@ static int uhci_debug_open(struct inode *inode, struct file *file) | |||
495 | { | 494 | { |
496 | struct uhci_hcd *uhci = inode->i_private; | 495 | struct uhci_hcd *uhci = inode->i_private; |
497 | struct uhci_debug *up; | 496 | struct uhci_debug *up; |
498 | int ret = -ENOMEM; | ||
499 | unsigned long flags; | 497 | unsigned long flags; |
500 | 498 | ||
501 | lock_kernel(); | ||
502 | up = kmalloc(sizeof(*up), GFP_KERNEL); | 499 | up = kmalloc(sizeof(*up), GFP_KERNEL); |
503 | if (!up) | 500 | if (!up) |
504 | goto out; | 501 | return -ENOMEM; |
505 | 502 | ||
506 | up->data = kmalloc(MAX_OUTPUT, GFP_KERNEL); | 503 | up->data = kmalloc(MAX_OUTPUT, GFP_KERNEL); |
507 | if (!up->data) { | 504 | if (!up->data) { |
508 | kfree(up); | 505 | kfree(up); |
509 | goto out; | 506 | return -ENOMEM; |
510 | } | 507 | } |
511 | 508 | ||
512 | up->size = 0; | 509 | up->size = 0; |
@@ -517,10 +514,7 @@ static int uhci_debug_open(struct inode *inode, struct file *file) | |||
517 | 514 | ||
518 | file->private_data = up; | 515 | file->private_data = up; |
519 | 516 | ||
520 | ret = 0; | 517 | return 0; |
521 | out: | ||
522 | unlock_kernel(); | ||
523 | return ret; | ||
524 | } | 518 | } |
525 | 519 | ||
526 | static loff_t uhci_debug_lseek(struct file *file, loff_t off, int whence) | 520 | static loff_t uhci_debug_lseek(struct file *file, loff_t off, int whence) |
@@ -528,9 +522,9 @@ static loff_t uhci_debug_lseek(struct file *file, loff_t off, int whence) | |||
528 | struct uhci_debug *up; | 522 | struct uhci_debug *up; |
529 | loff_t new = -1; | 523 | loff_t new = -1; |
530 | 524 | ||
531 | lock_kernel(); | ||
532 | up = file->private_data; | 525 | up = file->private_data; |
533 | 526 | ||
527 | /* XXX: atomic 64bit seek access, but that needs to be fixed in the VFS */ | ||
534 | switch (whence) { | 528 | switch (whence) { |
535 | case 0: | 529 | case 0: |
536 | new = off; | 530 | new = off; |
@@ -539,11 +533,10 @@ static loff_t uhci_debug_lseek(struct file *file, loff_t off, int whence) | |||
539 | new = file->f_pos + off; | 533 | new = file->f_pos + off; |
540 | break; | 534 | break; |
541 | } | 535 | } |
542 | if (new < 0 || new > up->size) { | 536 | |
543 | unlock_kernel(); | 537 | if (new < 0 || new > up->size) |
544 | return -EINVAL; | 538 | return -EINVAL; |
545 | } | 539 | |
546 | unlock_kernel(); | ||
547 | return (file->f_pos = new); | 540 | return (file->f_pos = new); |
548 | } | 541 | } |
549 | 542 | ||
@@ -564,7 +557,6 @@ static int uhci_debug_release(struct inode *inode, struct file *file) | |||
564 | return 0; | 557 | return 0; |
565 | } | 558 | } |
566 | 559 | ||
567 | #undef uhci_debug_operations | ||
568 | static const struct file_operations uhci_debug_operations = { | 560 | static const struct file_operations uhci_debug_operations = { |
569 | .owner = THIS_MODULE, | 561 | .owner = THIS_MODULE, |
570 | .open = uhci_debug_open, | 562 | .open = uhci_debug_open, |
@@ -572,6 +564,7 @@ static const struct file_operations uhci_debug_operations = { | |||
572 | .read = uhci_debug_read, | 564 | .read = uhci_debug_read, |
573 | .release = uhci_debug_release, | 565 | .release = uhci_debug_release, |
574 | }; | 566 | }; |
567 | #define UHCI_DEBUG_OPS | ||
575 | 568 | ||
576 | #endif /* CONFIG_DEBUG_FS */ | 569 | #endif /* CONFIG_DEBUG_FS */ |
577 | 570 | ||
diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c index 6637e52736dd..f52d04db28f4 100644 --- a/drivers/usb/host/uhci-hcd.c +++ b/drivers/usb/host/uhci-hcd.c | |||
@@ -140,7 +140,7 @@ static void finish_reset(struct uhci_hcd *uhci) | |||
140 | uhci->rh_state = UHCI_RH_RESET; | 140 | uhci->rh_state = UHCI_RH_RESET; |
141 | uhci->is_stopped = UHCI_IS_STOPPED; | 141 | uhci->is_stopped = UHCI_IS_STOPPED; |
142 | uhci_to_hcd(uhci)->state = HC_STATE_HALT; | 142 | uhci_to_hcd(uhci)->state = HC_STATE_HALT; |
143 | uhci_to_hcd(uhci)->poll_rh = 0; | 143 | clear_bit(HCD_FLAG_POLL_RH, &uhci_to_hcd(uhci)->flags); |
144 | 144 | ||
145 | uhci->dead = 0; /* Full reset resurrects the controller */ | 145 | uhci->dead = 0; /* Full reset resurrects the controller */ |
146 | } | 146 | } |
@@ -176,6 +176,8 @@ static void check_and_reset_hc(struct uhci_hcd *uhci) | |||
176 | */ | 176 | */ |
177 | static void configure_hc(struct uhci_hcd *uhci) | 177 | static void configure_hc(struct uhci_hcd *uhci) |
178 | { | 178 | { |
179 | struct pci_dev *pdev = to_pci_dev(uhci_dev(uhci)); | ||
180 | |||
179 | /* Set the frame length to the default: 1 ms exactly */ | 181 | /* Set the frame length to the default: 1 ms exactly */ |
180 | outb(USBSOF_DEFAULT, uhci->io_addr + USBSOF); | 182 | outb(USBSOF_DEFAULT, uhci->io_addr + USBSOF); |
181 | 183 | ||
@@ -191,8 +193,11 @@ static void configure_hc(struct uhci_hcd *uhci) | |||
191 | mb(); | 193 | mb(); |
192 | 194 | ||
193 | /* Enable PIRQ */ | 195 | /* Enable PIRQ */ |
194 | pci_write_config_word(to_pci_dev(uhci_dev(uhci)), USBLEGSUP, | 196 | pci_write_config_word(pdev, USBLEGSUP, USBLEGSUP_DEFAULT); |
195 | USBLEGSUP_DEFAULT); | 197 | |
198 | /* Disable platform-specific non-PME# wakeup */ | ||
199 | if (pdev->vendor == PCI_VENDOR_ID_INTEL) | ||
200 | pci_write_config_byte(pdev, USBRES_INTEL, 0); | ||
196 | } | 201 | } |
197 | 202 | ||
198 | 203 | ||
@@ -344,7 +349,10 @@ __acquires(uhci->lock) | |||
344 | /* If interrupts don't work and remote wakeup is enabled then | 349 | /* If interrupts don't work and remote wakeup is enabled then |
345 | * the suspended root hub needs to be polled. | 350 | * the suspended root hub needs to be polled. |
346 | */ | 351 | */ |
347 | uhci_to_hcd(uhci)->poll_rh = (!int_enable && wakeup_enable); | 352 | if (!int_enable && wakeup_enable) |
353 | set_bit(HCD_FLAG_POLL_RH, &uhci_to_hcd(uhci)->flags); | ||
354 | else | ||
355 | clear_bit(HCD_FLAG_POLL_RH, &uhci_to_hcd(uhci)->flags); | ||
348 | 356 | ||
349 | uhci_scan_schedule(uhci); | 357 | uhci_scan_schedule(uhci); |
350 | uhci_fsbr_off(uhci); | 358 | uhci_fsbr_off(uhci); |
@@ -363,7 +371,7 @@ static void start_rh(struct uhci_hcd *uhci) | |||
363 | uhci->io_addr + USBINTR); | 371 | uhci->io_addr + USBINTR); |
364 | mb(); | 372 | mb(); |
365 | uhci->rh_state = UHCI_RH_RUNNING; | 373 | uhci->rh_state = UHCI_RH_RUNNING; |
366 | uhci_to_hcd(uhci)->poll_rh = 1; | 374 | set_bit(HCD_FLAG_POLL_RH, &uhci_to_hcd(uhci)->flags); |
367 | } | 375 | } |
368 | 376 | ||
369 | static void wakeup_rh(struct uhci_hcd *uhci) | 377 | static void wakeup_rh(struct uhci_hcd *uhci) |
@@ -589,7 +597,7 @@ static int uhci_start(struct usb_hcd *hcd) | |||
589 | struct uhci_hcd *uhci = hcd_to_uhci(hcd); | 597 | struct uhci_hcd *uhci = hcd_to_uhci(hcd); |
590 | int retval = -EBUSY; | 598 | int retval = -EBUSY; |
591 | int i; | 599 | int i; |
592 | struct dentry *dentry; | 600 | struct dentry __maybe_unused *dentry; |
593 | 601 | ||
594 | hcd->uses_new_polling = 1; | 602 | hcd->uses_new_polling = 1; |
595 | 603 | ||
@@ -599,18 +607,16 @@ static int uhci_start(struct usb_hcd *hcd) | |||
599 | INIT_LIST_HEAD(&uhci->idle_qh_list); | 607 | INIT_LIST_HEAD(&uhci->idle_qh_list); |
600 | init_waitqueue_head(&uhci->waitqh); | 608 | init_waitqueue_head(&uhci->waitqh); |
601 | 609 | ||
602 | if (DEBUG_CONFIGURED) { | 610 | #ifdef UHCI_DEBUG_OPS |
603 | dentry = debugfs_create_file(hcd->self.bus_name, | 611 | dentry = debugfs_create_file(hcd->self.bus_name, |
604 | S_IFREG|S_IRUGO|S_IWUSR, uhci_debugfs_root, | 612 | S_IFREG|S_IRUGO|S_IWUSR, uhci_debugfs_root, |
605 | uhci, &uhci_debug_operations); | 613 | uhci, &uhci_debug_operations); |
606 | if (!dentry) { | 614 | if (!dentry) { |
607 | dev_err(uhci_dev(uhci), "couldn't create uhci " | 615 | dev_err(uhci_dev(uhci), "couldn't create uhci debugfs entry\n"); |
608 | "debugfs entry\n"); | 616 | return -ENOMEM; |
609 | retval = -ENOMEM; | ||
610 | goto err_create_debug_entry; | ||
611 | } | ||
612 | uhci->dentry = dentry; | ||
613 | } | 617 | } |
618 | uhci->dentry = dentry; | ||
619 | #endif | ||
614 | 620 | ||
615 | uhci->frame = dma_alloc_coherent(uhci_dev(uhci), | 621 | uhci->frame = dma_alloc_coherent(uhci_dev(uhci), |
616 | UHCI_NUMFRAMES * sizeof(*uhci->frame), | 622 | UHCI_NUMFRAMES * sizeof(*uhci->frame), |
@@ -691,7 +697,9 @@ static int uhci_start(struct usb_hcd *hcd) | |||
691 | 697 | ||
692 | configure_hc(uhci); | 698 | configure_hc(uhci); |
693 | uhci->is_initialized = 1; | 699 | uhci->is_initialized = 1; |
700 | spin_lock_irq(&uhci->lock); | ||
694 | start_rh(uhci); | 701 | start_rh(uhci); |
702 | spin_unlock_irq(&uhci->lock); | ||
695 | return 0; | 703 | return 0; |
696 | 704 | ||
697 | /* | 705 | /* |
@@ -722,7 +730,6 @@ err_alloc_frame_cpu: | |||
722 | err_alloc_frame: | 730 | err_alloc_frame: |
723 | debugfs_remove(uhci->dentry); | 731 | debugfs_remove(uhci->dentry); |
724 | 732 | ||
725 | err_create_debug_entry: | ||
726 | return retval; | 733 | return retval; |
727 | } | 734 | } |
728 | 735 | ||
@@ -731,7 +738,7 @@ static void uhci_stop(struct usb_hcd *hcd) | |||
731 | struct uhci_hcd *uhci = hcd_to_uhci(hcd); | 738 | struct uhci_hcd *uhci = hcd_to_uhci(hcd); |
732 | 739 | ||
733 | spin_lock_irq(&uhci->lock); | 740 | spin_lock_irq(&uhci->lock); |
734 | if (test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags) && !uhci->dead) | 741 | if (HCD_HW_ACCESSIBLE(hcd) && !uhci->dead) |
735 | uhci_hc_died(uhci); | 742 | uhci_hc_died(uhci); |
736 | uhci_scan_schedule(uhci); | 743 | uhci_scan_schedule(uhci); |
737 | spin_unlock_irq(&uhci->lock); | 744 | spin_unlock_irq(&uhci->lock); |
@@ -748,7 +755,7 @@ static int uhci_rh_suspend(struct usb_hcd *hcd) | |||
748 | int rc = 0; | 755 | int rc = 0; |
749 | 756 | ||
750 | spin_lock_irq(&uhci->lock); | 757 | spin_lock_irq(&uhci->lock); |
751 | if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) | 758 | if (!HCD_HW_ACCESSIBLE(hcd)) |
752 | rc = -ESHUTDOWN; | 759 | rc = -ESHUTDOWN; |
753 | else if (uhci->dead) | 760 | else if (uhci->dead) |
754 | ; /* Dead controllers tell no tales */ | 761 | ; /* Dead controllers tell no tales */ |
@@ -775,7 +782,7 @@ static int uhci_rh_resume(struct usb_hcd *hcd) | |||
775 | int rc = 0; | 782 | int rc = 0; |
776 | 783 | ||
777 | spin_lock_irq(&uhci->lock); | 784 | spin_lock_irq(&uhci->lock); |
778 | if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) | 785 | if (!HCD_HW_ACCESSIBLE(hcd)) |
779 | rc = -ESHUTDOWN; | 786 | rc = -ESHUTDOWN; |
780 | else if (!uhci->dead) | 787 | else if (!uhci->dead) |
781 | wakeup_rh(uhci); | 788 | wakeup_rh(uhci); |
@@ -783,15 +790,16 @@ static int uhci_rh_resume(struct usb_hcd *hcd) | |||
783 | return rc; | 790 | return rc; |
784 | } | 791 | } |
785 | 792 | ||
786 | static int uhci_pci_suspend(struct usb_hcd *hcd) | 793 | static int uhci_pci_suspend(struct usb_hcd *hcd, bool do_wakeup) |
787 | { | 794 | { |
788 | struct uhci_hcd *uhci = hcd_to_uhci(hcd); | 795 | struct uhci_hcd *uhci = hcd_to_uhci(hcd); |
796 | struct pci_dev *pdev = to_pci_dev(uhci_dev(uhci)); | ||
789 | int rc = 0; | 797 | int rc = 0; |
790 | 798 | ||
791 | dev_dbg(uhci_dev(uhci), "%s\n", __func__); | 799 | dev_dbg(uhci_dev(uhci), "%s\n", __func__); |
792 | 800 | ||
793 | spin_lock_irq(&uhci->lock); | 801 | spin_lock_irq(&uhci->lock); |
794 | if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags) || uhci->dead) | 802 | if (!HCD_HW_ACCESSIBLE(hcd) || uhci->dead) |
795 | goto done_okay; /* Already suspended or dead */ | 803 | goto done_okay; /* Already suspended or dead */ |
796 | 804 | ||
797 | if (uhci->rh_state > UHCI_RH_SUSPENDED) { | 805 | if (uhci->rh_state > UHCI_RH_SUSPENDED) { |
@@ -803,11 +811,15 @@ static int uhci_pci_suspend(struct usb_hcd *hcd) | |||
803 | /* All PCI host controllers are required to disable IRQ generation | 811 | /* All PCI host controllers are required to disable IRQ generation |
804 | * at the source, so we must turn off PIRQ. | 812 | * at the source, so we must turn off PIRQ. |
805 | */ | 813 | */ |
806 | pci_write_config_word(to_pci_dev(uhci_dev(uhci)), USBLEGSUP, 0); | 814 | pci_write_config_word(pdev, USBLEGSUP, 0); |
807 | mb(); | 815 | clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); |
808 | hcd->poll_rh = 0; | 816 | |
809 | 817 | /* Enable platform-specific non-PME# wakeup */ | |
810 | /* FIXME: Enable non-PME# remote wakeup? */ | 818 | if (do_wakeup) { |
819 | if (pdev->vendor == PCI_VENDOR_ID_INTEL) | ||
820 | pci_write_config_byte(pdev, USBRES_INTEL, | ||
821 | USBPORT1EN | USBPORT2EN); | ||
822 | } | ||
811 | 823 | ||
812 | done_okay: | 824 | done_okay: |
813 | clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); | 825 | clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); |
@@ -826,7 +838,6 @@ static int uhci_pci_resume(struct usb_hcd *hcd, bool hibernated) | |||
826 | * even if the controller was dead. | 838 | * even if the controller was dead. |
827 | */ | 839 | */ |
828 | set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); | 840 | set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); |
829 | mb(); | ||
830 | 841 | ||
831 | spin_lock_irq(&uhci->lock); | 842 | spin_lock_irq(&uhci->lock); |
832 | 843 | ||
@@ -834,8 +845,6 @@ static int uhci_pci_resume(struct usb_hcd *hcd, bool hibernated) | |||
834 | if (hibernated) | 845 | if (hibernated) |
835 | uhci_hc_died(uhci); | 846 | uhci_hc_died(uhci); |
836 | 847 | ||
837 | /* FIXME: Disable non-PME# remote wakeup? */ | ||
838 | |||
839 | /* The firmware or a boot kernel may have changed the controller | 848 | /* The firmware or a boot kernel may have changed the controller |
840 | * settings during a system wakeup. Check it and reconfigure | 849 | * settings during a system wakeup. Check it and reconfigure |
841 | * to avoid problems. | 850 | * to avoid problems. |
@@ -845,22 +854,20 @@ static int uhci_pci_resume(struct usb_hcd *hcd, bool hibernated) | |||
845 | /* If the controller was dead before, it's back alive now */ | 854 | /* If the controller was dead before, it's back alive now */ |
846 | configure_hc(uhci); | 855 | configure_hc(uhci); |
847 | 856 | ||
848 | if (uhci->rh_state == UHCI_RH_RESET) { | 857 | /* Tell the core if the controller had to be reset */ |
849 | 858 | if (uhci->rh_state == UHCI_RH_RESET) | |
850 | /* The controller had to be reset */ | ||
851 | usb_root_hub_lost_power(hcd->self.root_hub); | 859 | usb_root_hub_lost_power(hcd->self.root_hub); |
852 | suspend_rh(uhci, UHCI_RH_SUSPENDED); | ||
853 | } | ||
854 | 860 | ||
855 | spin_unlock_irq(&uhci->lock); | 861 | spin_unlock_irq(&uhci->lock); |
856 | 862 | ||
857 | /* If interrupts don't work and remote wakeup is enabled then | 863 | /* If interrupts don't work and remote wakeup is enabled then |
858 | * the suspended root hub needs to be polled. | 864 | * the suspended root hub needs to be polled. |
859 | */ | 865 | */ |
860 | if (!uhci->RD_enable && hcd->self.root_hub->do_remote_wakeup) { | 866 | if (!uhci->RD_enable && hcd->self.root_hub->do_remote_wakeup) |
861 | hcd->poll_rh = 1; | 867 | set_bit(HCD_FLAG_POLL_RH, &hcd->flags); |
862 | usb_hcd_poll_rh_status(hcd); | 868 | |
863 | } | 869 | /* Does the root hub have a port wakeup pending? */ |
870 | usb_hcd_poll_rh_status(hcd); | ||
864 | return 0; | 871 | return 0; |
865 | } | 872 | } |
866 | #endif | 873 | #endif |
diff --git a/drivers/usb/host/uhci-hcd.h b/drivers/usb/host/uhci-hcd.h index 26bd1b2bcbfc..49bf2790f9c2 100644 --- a/drivers/usb/host/uhci-hcd.h +++ b/drivers/usb/host/uhci-hcd.h | |||
@@ -67,12 +67,17 @@ | |||
67 | #define USBPORTSC_RES3 0x4000 /* reserved, write zeroes */ | 67 | #define USBPORTSC_RES3 0x4000 /* reserved, write zeroes */ |
68 | #define USBPORTSC_RES4 0x8000 /* reserved, write zeroes */ | 68 | #define USBPORTSC_RES4 0x8000 /* reserved, write zeroes */ |
69 | 69 | ||
70 | /* Legacy support register */ | 70 | /* PCI legacy support register */ |
71 | #define USBLEGSUP 0xc0 | 71 | #define USBLEGSUP 0xc0 |
72 | #define USBLEGSUP_DEFAULT 0x2000 /* only PIRQ enable set */ | 72 | #define USBLEGSUP_DEFAULT 0x2000 /* only PIRQ enable set */ |
73 | #define USBLEGSUP_RWC 0x8f00 /* the R/WC bits */ | 73 | #define USBLEGSUP_RWC 0x8f00 /* the R/WC bits */ |
74 | #define USBLEGSUP_RO 0x5040 /* R/O and reserved bits */ | 74 | #define USBLEGSUP_RO 0x5040 /* R/O and reserved bits */ |
75 | 75 | ||
76 | /* PCI Intel-specific resume-enable register */ | ||
77 | #define USBRES_INTEL 0xc4 | ||
78 | #define USBPORT1EN 0x01 | ||
79 | #define USBPORT2EN 0x02 | ||
80 | |||
76 | #define UHCI_PTR_BITS cpu_to_le32(0x000F) | 81 | #define UHCI_PTR_BITS cpu_to_le32(0x000F) |
77 | #define UHCI_PTR_TERM cpu_to_le32(0x0001) | 82 | #define UHCI_PTR_TERM cpu_to_le32(0x0001) |
78 | #define UHCI_PTR_QH cpu_to_le32(0x0002) | 83 | #define UHCI_PTR_QH cpu_to_le32(0x0002) |
diff --git a/drivers/usb/host/uhci-hub.c b/drivers/usb/host/uhci-hub.c index 8270055848ca..6d59c0f77f25 100644 --- a/drivers/usb/host/uhci-hub.c +++ b/drivers/usb/host/uhci-hub.c | |||
@@ -190,7 +190,7 @@ static int uhci_hub_status_data(struct usb_hcd *hcd, char *buf) | |||
190 | spin_lock_irqsave(&uhci->lock, flags); | 190 | spin_lock_irqsave(&uhci->lock, flags); |
191 | 191 | ||
192 | uhci_scan_schedule(uhci); | 192 | uhci_scan_schedule(uhci); |
193 | if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags) || uhci->dead) | 193 | if (!HCD_HW_ACCESSIBLE(hcd) || uhci->dead) |
194 | goto done; | 194 | goto done; |
195 | uhci_check_ports(uhci); | 195 | uhci_check_ports(uhci); |
196 | 196 | ||
@@ -200,7 +200,7 @@ static int uhci_hub_status_data(struct usb_hcd *hcd, char *buf) | |||
200 | case UHCI_RH_SUSPENDING: | 200 | case UHCI_RH_SUSPENDING: |
201 | case UHCI_RH_SUSPENDED: | 201 | case UHCI_RH_SUSPENDED: |
202 | /* if port change, ask to be resumed */ | 202 | /* if port change, ask to be resumed */ |
203 | if (status) | 203 | if (status || uhci->resuming_ports) |
204 | usb_hcd_resume_root_hub(hcd); | 204 | usb_hcd_resume_root_hub(hcd); |
205 | break; | 205 | break; |
206 | 206 | ||
@@ -246,7 +246,7 @@ static int uhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, | |||
246 | u16 wPortChange, wPortStatus; | 246 | u16 wPortChange, wPortStatus; |
247 | unsigned long flags; | 247 | unsigned long flags; |
248 | 248 | ||
249 | if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags) || uhci->dead) | 249 | if (!HCD_HW_ACCESSIBLE(hcd) || uhci->dead) |
250 | return -ETIMEDOUT; | 250 | return -ETIMEDOUT; |
251 | 251 | ||
252 | spin_lock_irqsave(&uhci->lock, flags); | 252 | spin_lock_irqsave(&uhci->lock, flags); |
diff --git a/drivers/usb/host/uhci-q.c b/drivers/usb/host/uhci-q.c index acd582c02802..d3ade4018487 100644 --- a/drivers/usb/host/uhci-q.c +++ b/drivers/usb/host/uhci-q.c | |||
@@ -565,7 +565,7 @@ static void uhci_unlink_qh(struct uhci_hcd *uhci, struct uhci_qh *qh) | |||
565 | qh->unlink_frame = uhci->frame_number; | 565 | qh->unlink_frame = uhci->frame_number; |
566 | 566 | ||
567 | /* Force an interrupt so we know when the QH is fully unlinked */ | 567 | /* Force an interrupt so we know when the QH is fully unlinked */ |
568 | if (list_empty(&uhci->skel_unlink_qh->node)) | 568 | if (list_empty(&uhci->skel_unlink_qh->node) || uhci->is_stopped) |
569 | uhci_set_next_interrupt(uhci); | 569 | uhci_set_next_interrupt(uhci); |
570 | 570 | ||
571 | /* Move the QH from its old list to the end of the unlinking list */ | 571 | /* Move the QH from its old list to the end of the unlinking list */ |
@@ -1667,7 +1667,7 @@ static int uhci_advance_check(struct uhci_hcd *uhci, struct uhci_qh *qh) | |||
1667 | qh->advance_jiffies = jiffies; | 1667 | qh->advance_jiffies = jiffies; |
1668 | goto done; | 1668 | goto done; |
1669 | } | 1669 | } |
1670 | ret = 0; | 1670 | ret = uhci->is_stopped; |
1671 | } | 1671 | } |
1672 | 1672 | ||
1673 | /* The queue hasn't advanced; check for timeout */ | 1673 | /* The queue hasn't advanced; check for timeout */ |
diff --git a/drivers/usb/host/whci/hcd.c b/drivers/usb/host/whci/hcd.c index e0d3401285c8..72b6892fda67 100644 --- a/drivers/usb/host/whci/hcd.c +++ b/drivers/usb/host/whci/hcd.c | |||
@@ -68,7 +68,7 @@ static int whc_start(struct usb_hcd *usb_hcd) | |||
68 | whc_write_wusbcmd(whc, WUSBCMD_RUN, WUSBCMD_RUN); | 68 | whc_write_wusbcmd(whc, WUSBCMD_RUN, WUSBCMD_RUN); |
69 | 69 | ||
70 | usb_hcd->uses_new_polling = 1; | 70 | usb_hcd->uses_new_polling = 1; |
71 | usb_hcd->poll_rh = 1; | 71 | set_bit(HCD_FLAG_POLL_RH, &usb_hcd->flags); |
72 | usb_hcd->state = HC_STATE_RUNNING; | 72 | usb_hcd->state = HC_STATE_RUNNING; |
73 | 73 | ||
74 | out: | 74 | out: |
diff --git a/drivers/usb/host/whci/qset.c b/drivers/usb/host/whci/qset.c index ab5a14fbfeeb..dc0ab8382f5d 100644 --- a/drivers/usb/host/whci/qset.c +++ b/drivers/usb/host/whci/qset.c | |||
@@ -475,7 +475,7 @@ static int qset_add_urb_sg(struct whc *whc, struct whc_qset *qset, struct urb *u | |||
475 | || (prev_end & (WHCI_PAGE_SIZE-1)) | 475 | || (prev_end & (WHCI_PAGE_SIZE-1)) |
476 | || (dma_addr & (WHCI_PAGE_SIZE-1)) | 476 | || (dma_addr & (WHCI_PAGE_SIZE-1)) |
477 | || std->len + WHCI_PAGE_SIZE > QTD_MAX_XFER_SIZE) { | 477 | || std->len + WHCI_PAGE_SIZE > QTD_MAX_XFER_SIZE) { |
478 | if (std->len % qset->max_packet != 0) | 478 | if (std && std->len % qset->max_packet != 0) |
479 | return -EINVAL; | 479 | return -EINVAL; |
480 | std = qset_new_std(whc, qset, urb, mem_flags); | 480 | std = qset_new_std(whc, qset, urb, mem_flags); |
481 | if (std == NULL) { | 481 | if (std == NULL) { |
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index 2eb658d26394..4e51343ddffc 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c | |||
@@ -391,49 +391,6 @@ struct xhci_ring *xhci_stream_id_to_ring( | |||
391 | return ep->stream_info->stream_rings[stream_id]; | 391 | return ep->stream_info->stream_rings[stream_id]; |
392 | } | 392 | } |
393 | 393 | ||
394 | struct xhci_ring *xhci_triad_to_transfer_ring(struct xhci_hcd *xhci, | ||
395 | unsigned int slot_id, unsigned int ep_index, | ||
396 | unsigned int stream_id) | ||
397 | { | ||
398 | struct xhci_virt_ep *ep; | ||
399 | |||
400 | ep = &xhci->devs[slot_id]->eps[ep_index]; | ||
401 | /* Common case: no streams */ | ||
402 | if (!(ep->ep_state & EP_HAS_STREAMS)) | ||
403 | return ep->ring; | ||
404 | |||
405 | if (stream_id == 0) { | ||
406 | xhci_warn(xhci, | ||
407 | "WARN: Slot ID %u, ep index %u has streams, " | ||
408 | "but URB has no stream ID.\n", | ||
409 | slot_id, ep_index); | ||
410 | return NULL; | ||
411 | } | ||
412 | |||
413 | if (stream_id < ep->stream_info->num_streams) | ||
414 | return ep->stream_info->stream_rings[stream_id]; | ||
415 | |||
416 | xhci_warn(xhci, | ||
417 | "WARN: Slot ID %u, ep index %u has " | ||
418 | "stream IDs 1 to %u allocated, " | ||
419 | "but stream ID %u is requested.\n", | ||
420 | slot_id, ep_index, | ||
421 | ep->stream_info->num_streams - 1, | ||
422 | stream_id); | ||
423 | return NULL; | ||
424 | } | ||
425 | |||
426 | /* Get the right ring for the given URB. | ||
427 | * If the endpoint supports streams, boundary check the URB's stream ID. | ||
428 | * If the endpoint doesn't support streams, return the singular endpoint ring. | ||
429 | */ | ||
430 | struct xhci_ring *xhci_urb_to_transfer_ring(struct xhci_hcd *xhci, | ||
431 | struct urb *urb) | ||
432 | { | ||
433 | return xhci_triad_to_transfer_ring(xhci, urb->dev->slot_id, | ||
434 | xhci_get_endpoint_index(&urb->ep->desc), urb->stream_id); | ||
435 | } | ||
436 | |||
437 | #ifdef CONFIG_USB_XHCI_HCD_DEBUGGING | 394 | #ifdef CONFIG_USB_XHCI_HCD_DEBUGGING |
438 | static int xhci_test_radix_tree(struct xhci_hcd *xhci, | 395 | static int xhci_test_radix_tree(struct xhci_hcd *xhci, |
439 | unsigned int num_streams, | 396 | unsigned int num_streams, |
@@ -1112,8 +1069,18 @@ int xhci_endpoint_init(struct xhci_hcd *xhci, | |||
1112 | ep_ctx = xhci_get_ep_ctx(xhci, virt_dev->in_ctx, ep_index); | 1069 | ep_ctx = xhci_get_ep_ctx(xhci, virt_dev->in_ctx, ep_index); |
1113 | 1070 | ||
1114 | /* Set up the endpoint ring */ | 1071 | /* Set up the endpoint ring */ |
1115 | virt_dev->eps[ep_index].new_ring = | 1072 | /* |
1116 | xhci_ring_alloc(xhci, 1, true, mem_flags); | 1073 | * Isochronous endpoint ring needs bigger size because one isoc URB |
1074 | * carries multiple packets and it will insert multiple tds to the | ||
1075 | * ring. | ||
1076 | * This should be replaced with dynamic ring resizing in the future. | ||
1077 | */ | ||
1078 | if (usb_endpoint_xfer_isoc(&ep->desc)) | ||
1079 | virt_dev->eps[ep_index].new_ring = | ||
1080 | xhci_ring_alloc(xhci, 8, true, mem_flags); | ||
1081 | else | ||
1082 | virt_dev->eps[ep_index].new_ring = | ||
1083 | xhci_ring_alloc(xhci, 1, true, mem_flags); | ||
1117 | if (!virt_dev->eps[ep_index].new_ring) { | 1084 | if (!virt_dev->eps[ep_index].new_ring) { |
1118 | /* Attempt to use the ring cache */ | 1085 | /* Attempt to use the ring cache */ |
1119 | if (virt_dev->num_rings_cached == 0) | 1086 | if (virt_dev->num_rings_cached == 0) |
@@ -1124,6 +1091,7 @@ int xhci_endpoint_init(struct xhci_hcd *xhci, | |||
1124 | virt_dev->num_rings_cached--; | 1091 | virt_dev->num_rings_cached--; |
1125 | xhci_reinit_cached_ring(xhci, virt_dev->eps[ep_index].new_ring); | 1092 | xhci_reinit_cached_ring(xhci, virt_dev->eps[ep_index].new_ring); |
1126 | } | 1093 | } |
1094 | virt_dev->eps[ep_index].skip = false; | ||
1127 | ep_ring = virt_dev->eps[ep_index].new_ring; | 1095 | ep_ring = virt_dev->eps[ep_index].new_ring; |
1128 | ep_ctx->deq = ep_ring->first_seg->dma | ep_ring->cycle_state; | 1096 | ep_ctx->deq = ep_ring->first_seg->dma | ep_ring->cycle_state; |
1129 | 1097 | ||
@@ -1389,6 +1357,22 @@ struct xhci_command *xhci_alloc_command(struct xhci_hcd *xhci, | |||
1389 | return command; | 1357 | return command; |
1390 | } | 1358 | } |
1391 | 1359 | ||
1360 | void xhci_urb_free_priv(struct xhci_hcd *xhci, struct urb_priv *urb_priv) | ||
1361 | { | ||
1362 | int last; | ||
1363 | |||
1364 | if (!urb_priv) | ||
1365 | return; | ||
1366 | |||
1367 | last = urb_priv->length - 1; | ||
1368 | if (last >= 0) { | ||
1369 | int i; | ||
1370 | for (i = 0; i <= last; i++) | ||
1371 | kfree(urb_priv->td[i]); | ||
1372 | } | ||
1373 | kfree(urb_priv); | ||
1374 | } | ||
1375 | |||
1392 | void xhci_free_command(struct xhci_hcd *xhci, | 1376 | void xhci_free_command(struct xhci_hcd *xhci, |
1393 | struct xhci_command *command) | 1377 | struct xhci_command *command) |
1394 | { | 1378 | { |
@@ -1588,7 +1572,7 @@ static int xhci_check_trb_in_td_math(struct xhci_hcd *xhci, gfp_t mem_flags) | |||
1588 | unsigned int num_tests; | 1572 | unsigned int num_tests; |
1589 | int i, ret; | 1573 | int i, ret; |
1590 | 1574 | ||
1591 | num_tests = sizeof(simple_test_vector) / sizeof(simple_test_vector[0]); | 1575 | num_tests = ARRAY_SIZE(simple_test_vector); |
1592 | for (i = 0; i < num_tests; i++) { | 1576 | for (i = 0; i < num_tests; i++) { |
1593 | ret = xhci_test_trb_in_td(xhci, | 1577 | ret = xhci_test_trb_in_td(xhci, |
1594 | xhci->event_ring->first_seg, | 1578 | xhci->event_ring->first_seg, |
@@ -1601,7 +1585,7 @@ static int xhci_check_trb_in_td_math(struct xhci_hcd *xhci, gfp_t mem_flags) | |||
1601 | return ret; | 1585 | return ret; |
1602 | } | 1586 | } |
1603 | 1587 | ||
1604 | num_tests = sizeof(complex_test_vector) / sizeof(complex_test_vector[0]); | 1588 | num_tests = ARRAY_SIZE(complex_test_vector); |
1605 | for (i = 0; i < num_tests; i++) { | 1589 | for (i = 0; i < num_tests; i++) { |
1606 | ret = xhci_test_trb_in_td(xhci, | 1590 | ret = xhci_test_trb_in_td(xhci, |
1607 | complex_test_vector[i].input_seg, | 1591 | complex_test_vector[i].input_seg, |
@@ -1617,6 +1601,29 @@ static int xhci_check_trb_in_td_math(struct xhci_hcd *xhci, gfp_t mem_flags) | |||
1617 | return 0; | 1601 | return 0; |
1618 | } | 1602 | } |
1619 | 1603 | ||
1604 | static void xhci_set_hc_event_deq(struct xhci_hcd *xhci) | ||
1605 | { | ||
1606 | u64 temp; | ||
1607 | dma_addr_t deq; | ||
1608 | |||
1609 | deq = xhci_trb_virt_to_dma(xhci->event_ring->deq_seg, | ||
1610 | xhci->event_ring->dequeue); | ||
1611 | if (deq == 0 && !in_interrupt()) | ||
1612 | xhci_warn(xhci, "WARN something wrong with SW event ring " | ||
1613 | "dequeue ptr.\n"); | ||
1614 | /* Update HC event ring dequeue pointer */ | ||
1615 | temp = xhci_read_64(xhci, &xhci->ir_set->erst_dequeue); | ||
1616 | temp &= ERST_PTR_MASK; | ||
1617 | /* Don't clear the EHB bit (which is RW1C) because | ||
1618 | * there might be more events to service. | ||
1619 | */ | ||
1620 | temp &= ~ERST_EHB; | ||
1621 | xhci_dbg(xhci, "// Write event ring dequeue pointer, " | ||
1622 | "preserving EHB bit\n"); | ||
1623 | xhci_write_64(xhci, ((u64) deq & (u64) ~ERST_PTR_MASK) | temp, | ||
1624 | &xhci->ir_set->erst_dequeue); | ||
1625 | } | ||
1626 | |||
1620 | 1627 | ||
1621 | int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags) | 1628 | int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags) |
1622 | { | 1629 | { |
diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c index 11482b6b9381..f7efe025beda 100644 --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c | |||
@@ -53,6 +53,7 @@ static int xhci_pci_setup(struct usb_hcd *hcd) | |||
53 | struct xhci_hcd *xhci = hcd_to_xhci(hcd); | 53 | struct xhci_hcd *xhci = hcd_to_xhci(hcd); |
54 | struct pci_dev *pdev = to_pci_dev(hcd->self.controller); | 54 | struct pci_dev *pdev = to_pci_dev(hcd->self.controller); |
55 | int retval; | 55 | int retval; |
56 | u32 temp; | ||
56 | 57 | ||
57 | hcd->self.sg_tablesize = TRBS_PER_SEGMENT - 2; | 58 | hcd->self.sg_tablesize = TRBS_PER_SEGMENT - 2; |
58 | 59 | ||
@@ -93,6 +94,14 @@ static int xhci_pci_setup(struct usb_hcd *hcd) | |||
93 | return retval; | 94 | return retval; |
94 | xhci_dbg(xhci, "Reset complete\n"); | 95 | xhci_dbg(xhci, "Reset complete\n"); |
95 | 96 | ||
97 | temp = xhci_readl(xhci, &xhci->cap_regs->hcc_params); | ||
98 | if (HCC_64BIT_ADDR(temp)) { | ||
99 | xhci_dbg(xhci, "Enabling 64-bit DMA addresses.\n"); | ||
100 | dma_set_mask(hcd->self.controller, DMA_BIT_MASK(64)); | ||
101 | } else { | ||
102 | dma_set_mask(hcd->self.controller, DMA_BIT_MASK(32)); | ||
103 | } | ||
104 | |||
96 | xhci_dbg(xhci, "Calling HCD init\n"); | 105 | xhci_dbg(xhci, "Calling HCD init\n"); |
97 | /* Initialize HCD and host controller data structures. */ | 106 | /* Initialize HCD and host controller data structures. */ |
98 | retval = xhci_init(hcd); | 107 | retval = xhci_init(hcd); |
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index bfc99a939455..bc3f4f427065 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c | |||
@@ -301,28 +301,6 @@ static int room_on_ring(struct xhci_hcd *xhci, struct xhci_ring *ring, | |||
301 | return 1; | 301 | return 1; |
302 | } | 302 | } |
303 | 303 | ||
304 | void xhci_set_hc_event_deq(struct xhci_hcd *xhci) | ||
305 | { | ||
306 | u64 temp; | ||
307 | dma_addr_t deq; | ||
308 | |||
309 | deq = xhci_trb_virt_to_dma(xhci->event_ring->deq_seg, | ||
310 | xhci->event_ring->dequeue); | ||
311 | if (deq == 0 && !in_interrupt()) | ||
312 | xhci_warn(xhci, "WARN something wrong with SW event ring " | ||
313 | "dequeue ptr.\n"); | ||
314 | /* Update HC event ring dequeue pointer */ | ||
315 | temp = xhci_read_64(xhci, &xhci->ir_set->erst_dequeue); | ||
316 | temp &= ERST_PTR_MASK; | ||
317 | /* Don't clear the EHB bit (which is RW1C) because | ||
318 | * there might be more events to service. | ||
319 | */ | ||
320 | temp &= ~ERST_EHB; | ||
321 | xhci_dbg(xhci, "// Write event ring dequeue pointer, preserving EHB bit\n"); | ||
322 | xhci_write_64(xhci, ((u64) deq & (u64) ~ERST_PTR_MASK) | temp, | ||
323 | &xhci->ir_set->erst_dequeue); | ||
324 | } | ||
325 | |||
326 | /* Ring the host controller doorbell after placing a command on the ring */ | 304 | /* Ring the host controller doorbell after placing a command on the ring */ |
327 | void xhci_ring_cmd_db(struct xhci_hcd *xhci) | 305 | void xhci_ring_cmd_db(struct xhci_hcd *xhci) |
328 | { | 306 | { |
@@ -359,11 +337,6 @@ static void ring_ep_doorbell(struct xhci_hcd *xhci, | |||
359 | field = xhci_readl(xhci, db_addr) & DB_MASK; | 337 | field = xhci_readl(xhci, db_addr) & DB_MASK; |
360 | field |= EPI_TO_DB(ep_index) | STREAM_ID_TO_DB(stream_id); | 338 | field |= EPI_TO_DB(ep_index) | STREAM_ID_TO_DB(stream_id); |
361 | xhci_writel(xhci, field, db_addr); | 339 | xhci_writel(xhci, field, db_addr); |
362 | /* Flush PCI posted writes - FIXME Matthew Wilcox says this | ||
363 | * isn't time-critical and we shouldn't make the CPU wait for | ||
364 | * the flush. | ||
365 | */ | ||
366 | xhci_readl(xhci, db_addr); | ||
367 | } | 340 | } |
368 | } | 341 | } |
369 | 342 | ||
@@ -419,6 +392,50 @@ static struct xhci_segment *find_trb_seg( | |||
419 | return cur_seg; | 392 | return cur_seg; |
420 | } | 393 | } |
421 | 394 | ||
395 | |||
396 | static struct xhci_ring *xhci_triad_to_transfer_ring(struct xhci_hcd *xhci, | ||
397 | unsigned int slot_id, unsigned int ep_index, | ||
398 | unsigned int stream_id) | ||
399 | { | ||
400 | struct xhci_virt_ep *ep; | ||
401 | |||
402 | ep = &xhci->devs[slot_id]->eps[ep_index]; | ||
403 | /* Common case: no streams */ | ||
404 | if (!(ep->ep_state & EP_HAS_STREAMS)) | ||
405 | return ep->ring; | ||
406 | |||
407 | if (stream_id == 0) { | ||
408 | xhci_warn(xhci, | ||
409 | "WARN: Slot ID %u, ep index %u has streams, " | ||
410 | "but URB has no stream ID.\n", | ||
411 | slot_id, ep_index); | ||
412 | return NULL; | ||
413 | } | ||
414 | |||
415 | if (stream_id < ep->stream_info->num_streams) | ||
416 | return ep->stream_info->stream_rings[stream_id]; | ||
417 | |||
418 | xhci_warn(xhci, | ||
419 | "WARN: Slot ID %u, ep index %u has " | ||
420 | "stream IDs 1 to %u allocated, " | ||
421 | "but stream ID %u is requested.\n", | ||
422 | slot_id, ep_index, | ||
423 | ep->stream_info->num_streams - 1, | ||
424 | stream_id); | ||
425 | return NULL; | ||
426 | } | ||
427 | |||
428 | /* Get the right ring for the given URB. | ||
429 | * If the endpoint supports streams, boundary check the URB's stream ID. | ||
430 | * If the endpoint doesn't support streams, return the singular endpoint ring. | ||
431 | */ | ||
432 | static struct xhci_ring *xhci_urb_to_transfer_ring(struct xhci_hcd *xhci, | ||
433 | struct urb *urb) | ||
434 | { | ||
435 | return xhci_triad_to_transfer_ring(xhci, urb->dev->slot_id, | ||
436 | xhci_get_endpoint_index(&urb->ep->desc), urb->stream_id); | ||
437 | } | ||
438 | |||
422 | /* | 439 | /* |
423 | * Move the xHC's endpoint ring dequeue pointer past cur_td. | 440 | * Move the xHC's endpoint ring dequeue pointer past cur_td. |
424 | * Record the new state of the xHC's endpoint ring dequeue segment, | 441 | * Record the new state of the xHC's endpoint ring dequeue segment, |
@@ -578,16 +595,24 @@ static void xhci_giveback_urb_in_irq(struct xhci_hcd *xhci, | |||
578 | struct xhci_td *cur_td, int status, char *adjective) | 595 | struct xhci_td *cur_td, int status, char *adjective) |
579 | { | 596 | { |
580 | struct usb_hcd *hcd = xhci_to_hcd(xhci); | 597 | struct usb_hcd *hcd = xhci_to_hcd(xhci); |
598 | struct urb *urb; | ||
599 | struct urb_priv *urb_priv; | ||
581 | 600 | ||
582 | cur_td->urb->hcpriv = NULL; | 601 | urb = cur_td->urb; |
583 | usb_hcd_unlink_urb_from_ep(hcd, cur_td->urb); | 602 | urb_priv = urb->hcpriv; |
584 | xhci_dbg(xhci, "Giveback %s URB %p\n", adjective, cur_td->urb); | 603 | urb_priv->td_cnt++; |
585 | 604 | ||
586 | spin_unlock(&xhci->lock); | 605 | /* Only giveback urb when this is the last td in urb */ |
587 | usb_hcd_giveback_urb(hcd, cur_td->urb, status); | 606 | if (urb_priv->td_cnt == urb_priv->length) { |
588 | kfree(cur_td); | 607 | usb_hcd_unlink_urb_from_ep(hcd, urb); |
589 | spin_lock(&xhci->lock); | 608 | xhci_dbg(xhci, "Giveback %s URB %p\n", adjective, urb); |
590 | xhci_dbg(xhci, "%s URB given back\n", adjective); | 609 | |
610 | spin_unlock(&xhci->lock); | ||
611 | usb_hcd_giveback_urb(hcd, urb, status); | ||
612 | xhci_urb_free_priv(xhci, urb_priv); | ||
613 | spin_lock(&xhci->lock); | ||
614 | xhci_dbg(xhci, "%s URB given back\n", adjective); | ||
615 | } | ||
591 | } | 616 | } |
592 | 617 | ||
593 | /* | 618 | /* |
@@ -1132,7 +1157,6 @@ static void handle_port_status(struct xhci_hcd *xhci, | |||
1132 | 1157 | ||
1133 | /* Update event ring dequeue pointer before dropping the lock */ | 1158 | /* Update event ring dequeue pointer before dropping the lock */ |
1134 | inc_deq(xhci, xhci->event_ring, true); | 1159 | inc_deq(xhci, xhci->event_ring, true); |
1135 | xhci_set_hc_event_deq(xhci); | ||
1136 | 1160 | ||
1137 | spin_unlock(&xhci->lock); | 1161 | spin_unlock(&xhci->lock); |
1138 | /* Pass this up to the core */ | 1162 | /* Pass this up to the core */ |
@@ -1258,6 +1282,421 @@ int xhci_is_vendor_info_code(struct xhci_hcd *xhci, unsigned int trb_comp_code) | |||
1258 | } | 1282 | } |
1259 | 1283 | ||
1260 | /* | 1284 | /* |
1285 | * Finish the td processing, remove the td from td list; | ||
1286 | * Return 1 if the urb can be given back. | ||
1287 | */ | ||
1288 | static int finish_td(struct xhci_hcd *xhci, struct xhci_td *td, | ||
1289 | union xhci_trb *event_trb, struct xhci_transfer_event *event, | ||
1290 | struct xhci_virt_ep *ep, int *status, bool skip) | ||
1291 | { | ||
1292 | struct xhci_virt_device *xdev; | ||
1293 | struct xhci_ring *ep_ring; | ||
1294 | unsigned int slot_id; | ||
1295 | int ep_index; | ||
1296 | struct urb *urb = NULL; | ||
1297 | struct xhci_ep_ctx *ep_ctx; | ||
1298 | int ret = 0; | ||
1299 | struct urb_priv *urb_priv; | ||
1300 | u32 trb_comp_code; | ||
1301 | |||
1302 | slot_id = TRB_TO_SLOT_ID(event->flags); | ||
1303 | xdev = xhci->devs[slot_id]; | ||
1304 | ep_index = TRB_TO_EP_ID(event->flags) - 1; | ||
1305 | ep_ring = xhci_dma_to_transfer_ring(ep, event->buffer); | ||
1306 | ep_ctx = xhci_get_ep_ctx(xhci, xdev->out_ctx, ep_index); | ||
1307 | trb_comp_code = GET_COMP_CODE(event->transfer_len); | ||
1308 | |||
1309 | if (skip) | ||
1310 | goto td_cleanup; | ||
1311 | |||
1312 | if (trb_comp_code == COMP_STOP_INVAL || | ||
1313 | trb_comp_code == COMP_STOP) { | ||
1314 | /* The Endpoint Stop Command completion will take care of any | ||
1315 | * stopped TDs. A stopped TD may be restarted, so don't update | ||
1316 | * the ring dequeue pointer or take this TD off any lists yet. | ||
1317 | */ | ||
1318 | ep->stopped_td = td; | ||
1319 | ep->stopped_trb = event_trb; | ||
1320 | return 0; | ||
1321 | } else { | ||
1322 | if (trb_comp_code == COMP_STALL) { | ||
1323 | /* The transfer is completed from the driver's | ||
1324 | * perspective, but we need to issue a set dequeue | ||
1325 | * command for this stalled endpoint to move the dequeue | ||
1326 | * pointer past the TD. We can't do that here because | ||
1327 | * the halt condition must be cleared first. Let the | ||
1328 | * USB class driver clear the stall later. | ||
1329 | */ | ||
1330 | ep->stopped_td = td; | ||
1331 | ep->stopped_trb = event_trb; | ||
1332 | ep->stopped_stream = ep_ring->stream_id; | ||
1333 | } else if (xhci_requires_manual_halt_cleanup(xhci, | ||
1334 | ep_ctx, trb_comp_code)) { | ||
1335 | /* Other types of errors halt the endpoint, but the | ||
1336 | * class driver doesn't call usb_reset_endpoint() unless | ||
1337 | * the error is -EPIPE. Clear the halted status in the | ||
1338 | * xHCI hardware manually. | ||
1339 | */ | ||
1340 | xhci_cleanup_halted_endpoint(xhci, | ||
1341 | slot_id, ep_index, ep_ring->stream_id, | ||
1342 | td, event_trb); | ||
1343 | } else { | ||
1344 | /* Update ring dequeue pointer */ | ||
1345 | while (ep_ring->dequeue != td->last_trb) | ||
1346 | inc_deq(xhci, ep_ring, false); | ||
1347 | inc_deq(xhci, ep_ring, false); | ||
1348 | } | ||
1349 | |||
1350 | td_cleanup: | ||
1351 | /* Clean up the endpoint's TD list */ | ||
1352 | urb = td->urb; | ||
1353 | urb_priv = urb->hcpriv; | ||
1354 | |||
1355 | /* Do one last check of the actual transfer length. | ||
1356 | * If the host controller said we transferred more data than | ||
1357 | * the buffer length, urb->actual_length will be a very big | ||
1358 | * number (since it's unsigned). Play it safe and say we didn't | ||
1359 | * transfer anything. | ||
1360 | */ | ||
1361 | if (urb->actual_length > urb->transfer_buffer_length) { | ||
1362 | xhci_warn(xhci, "URB transfer length is wrong, " | ||
1363 | "xHC issue? req. len = %u, " | ||
1364 | "act. len = %u\n", | ||
1365 | urb->transfer_buffer_length, | ||
1366 | urb->actual_length); | ||
1367 | urb->actual_length = 0; | ||
1368 | if (td->urb->transfer_flags & URB_SHORT_NOT_OK) | ||
1369 | *status = -EREMOTEIO; | ||
1370 | else | ||
1371 | *status = 0; | ||
1372 | } | ||
1373 | list_del(&td->td_list); | ||
1374 | /* Was this TD slated to be cancelled but completed anyway? */ | ||
1375 | if (!list_empty(&td->cancelled_td_list)) | ||
1376 | list_del(&td->cancelled_td_list); | ||
1377 | |||
1378 | urb_priv->td_cnt++; | ||
1379 | /* Giveback the urb when all the tds are completed */ | ||
1380 | if (urb_priv->td_cnt == urb_priv->length) | ||
1381 | ret = 1; | ||
1382 | } | ||
1383 | |||
1384 | return ret; | ||
1385 | } | ||
1386 | |||
1387 | /* | ||
1388 | * Process control tds, update urb status and actual_length. | ||
1389 | */ | ||
1390 | static int process_ctrl_td(struct xhci_hcd *xhci, struct xhci_td *td, | ||
1391 | union xhci_trb *event_trb, struct xhci_transfer_event *event, | ||
1392 | struct xhci_virt_ep *ep, int *status) | ||
1393 | { | ||
1394 | struct xhci_virt_device *xdev; | ||
1395 | struct xhci_ring *ep_ring; | ||
1396 | unsigned int slot_id; | ||
1397 | int ep_index; | ||
1398 | struct xhci_ep_ctx *ep_ctx; | ||
1399 | u32 trb_comp_code; | ||
1400 | |||
1401 | slot_id = TRB_TO_SLOT_ID(event->flags); | ||
1402 | xdev = xhci->devs[slot_id]; | ||
1403 | ep_index = TRB_TO_EP_ID(event->flags) - 1; | ||
1404 | ep_ring = xhci_dma_to_transfer_ring(ep, event->buffer); | ||
1405 | ep_ctx = xhci_get_ep_ctx(xhci, xdev->out_ctx, ep_index); | ||
1406 | trb_comp_code = GET_COMP_CODE(event->transfer_len); | ||
1407 | |||
1408 | xhci_debug_trb(xhci, xhci->event_ring->dequeue); | ||
1409 | switch (trb_comp_code) { | ||
1410 | case COMP_SUCCESS: | ||
1411 | if (event_trb == ep_ring->dequeue) { | ||
1412 | xhci_warn(xhci, "WARN: Success on ctrl setup TRB " | ||
1413 | "without IOC set??\n"); | ||
1414 | *status = -ESHUTDOWN; | ||
1415 | } else if (event_trb != td->last_trb) { | ||
1416 | xhci_warn(xhci, "WARN: Success on ctrl data TRB " | ||
1417 | "without IOC set??\n"); | ||
1418 | *status = -ESHUTDOWN; | ||
1419 | } else { | ||
1420 | xhci_dbg(xhci, "Successful control transfer!\n"); | ||
1421 | *status = 0; | ||
1422 | } | ||
1423 | break; | ||
1424 | case COMP_SHORT_TX: | ||
1425 | xhci_warn(xhci, "WARN: short transfer on control ep\n"); | ||
1426 | if (td->urb->transfer_flags & URB_SHORT_NOT_OK) | ||
1427 | *status = -EREMOTEIO; | ||
1428 | else | ||
1429 | *status = 0; | ||
1430 | break; | ||
1431 | default: | ||
1432 | if (!xhci_requires_manual_halt_cleanup(xhci, | ||
1433 | ep_ctx, trb_comp_code)) | ||
1434 | break; | ||
1435 | xhci_dbg(xhci, "TRB error code %u, " | ||
1436 | "halted endpoint index = %u\n", | ||
1437 | trb_comp_code, ep_index); | ||
1438 | /* else fall through */ | ||
1439 | case COMP_STALL: | ||
1440 | /* Did we transfer part of the data (middle) phase? */ | ||
1441 | if (event_trb != ep_ring->dequeue && | ||
1442 | event_trb != td->last_trb) | ||
1443 | td->urb->actual_length = | ||
1444 | td->urb->transfer_buffer_length | ||
1445 | - TRB_LEN(event->transfer_len); | ||
1446 | else | ||
1447 | td->urb->actual_length = 0; | ||
1448 | |||
1449 | xhci_cleanup_halted_endpoint(xhci, | ||
1450 | slot_id, ep_index, 0, td, event_trb); | ||
1451 | return finish_td(xhci, td, event_trb, event, ep, status, true); | ||
1452 | } | ||
1453 | /* | ||
1454 | * Did we transfer any data, despite the errors that might have | ||
1455 | * happened? I.e. did we get past the setup stage? | ||
1456 | */ | ||
1457 | if (event_trb != ep_ring->dequeue) { | ||
1458 | /* The event was for the status stage */ | ||
1459 | if (event_trb == td->last_trb) { | ||
1460 | if (td->urb->actual_length != 0) { | ||
1461 | /* Don't overwrite a previously set error code | ||
1462 | */ | ||
1463 | if ((*status == -EINPROGRESS || *status == 0) && | ||
1464 | (td->urb->transfer_flags | ||
1465 | & URB_SHORT_NOT_OK)) | ||
1466 | /* Did we already see a short data | ||
1467 | * stage? */ | ||
1468 | *status = -EREMOTEIO; | ||
1469 | } else { | ||
1470 | td->urb->actual_length = | ||
1471 | td->urb->transfer_buffer_length; | ||
1472 | } | ||
1473 | } else { | ||
1474 | /* Maybe the event was for the data stage? */ | ||
1475 | if (trb_comp_code != COMP_STOP_INVAL) { | ||
1476 | /* We didn't stop on a link TRB in the middle */ | ||
1477 | td->urb->actual_length = | ||
1478 | td->urb->transfer_buffer_length - | ||
1479 | TRB_LEN(event->transfer_len); | ||
1480 | xhci_dbg(xhci, "Waiting for status " | ||
1481 | "stage event\n"); | ||
1482 | return 0; | ||
1483 | } | ||
1484 | } | ||
1485 | } | ||
1486 | |||
1487 | return finish_td(xhci, td, event_trb, event, ep, status, false); | ||
1488 | } | ||
1489 | |||
1490 | /* | ||
1491 | * Process isochronous tds, update urb packet status and actual_length. | ||
1492 | */ | ||
1493 | static int process_isoc_td(struct xhci_hcd *xhci, struct xhci_td *td, | ||
1494 | union xhci_trb *event_trb, struct xhci_transfer_event *event, | ||
1495 | struct xhci_virt_ep *ep, int *status) | ||
1496 | { | ||
1497 | struct xhci_ring *ep_ring; | ||
1498 | struct urb_priv *urb_priv; | ||
1499 | int idx; | ||
1500 | int len = 0; | ||
1501 | int skip_td = 0; | ||
1502 | union xhci_trb *cur_trb; | ||
1503 | struct xhci_segment *cur_seg; | ||
1504 | u32 trb_comp_code; | ||
1505 | |||
1506 | ep_ring = xhci_dma_to_transfer_ring(ep, event->buffer); | ||
1507 | trb_comp_code = GET_COMP_CODE(event->transfer_len); | ||
1508 | urb_priv = td->urb->hcpriv; | ||
1509 | idx = urb_priv->td_cnt; | ||
1510 | |||
1511 | if (ep->skip) { | ||
1512 | /* The transfer is partly done */ | ||
1513 | *status = -EXDEV; | ||
1514 | td->urb->iso_frame_desc[idx].status = -EXDEV; | ||
1515 | } else { | ||
1516 | /* handle completion code */ | ||
1517 | switch (trb_comp_code) { | ||
1518 | case COMP_SUCCESS: | ||
1519 | td->urb->iso_frame_desc[idx].status = 0; | ||
1520 | xhci_dbg(xhci, "Successful isoc transfer!\n"); | ||
1521 | break; | ||
1522 | case COMP_SHORT_TX: | ||
1523 | if (td->urb->transfer_flags & URB_SHORT_NOT_OK) | ||
1524 | td->urb->iso_frame_desc[idx].status = | ||
1525 | -EREMOTEIO; | ||
1526 | else | ||
1527 | td->urb->iso_frame_desc[idx].status = 0; | ||
1528 | break; | ||
1529 | case COMP_BW_OVER: | ||
1530 | td->urb->iso_frame_desc[idx].status = -ECOMM; | ||
1531 | skip_td = 1; | ||
1532 | break; | ||
1533 | case COMP_BUFF_OVER: | ||
1534 | case COMP_BABBLE: | ||
1535 | td->urb->iso_frame_desc[idx].status = -EOVERFLOW; | ||
1536 | skip_td = 1; | ||
1537 | break; | ||
1538 | case COMP_STALL: | ||
1539 | td->urb->iso_frame_desc[idx].status = -EPROTO; | ||
1540 | skip_td = 1; | ||
1541 | break; | ||
1542 | case COMP_STOP: | ||
1543 | case COMP_STOP_INVAL: | ||
1544 | break; | ||
1545 | default: | ||
1546 | td->urb->iso_frame_desc[idx].status = -1; | ||
1547 | break; | ||
1548 | } | ||
1549 | } | ||
1550 | |||
1551 | /* calc actual length */ | ||
1552 | if (ep->skip) { | ||
1553 | td->urb->iso_frame_desc[idx].actual_length = 0; | ||
1554 | return finish_td(xhci, td, event_trb, event, ep, status, true); | ||
1555 | } | ||
1556 | |||
1557 | if (trb_comp_code == COMP_SUCCESS || skip_td == 1) { | ||
1558 | td->urb->iso_frame_desc[idx].actual_length = | ||
1559 | td->urb->iso_frame_desc[idx].length; | ||
1560 | td->urb->actual_length += | ||
1561 | td->urb->iso_frame_desc[idx].length; | ||
1562 | } else { | ||
1563 | for (cur_trb = ep_ring->dequeue, | ||
1564 | cur_seg = ep_ring->deq_seg; cur_trb != event_trb; | ||
1565 | next_trb(xhci, ep_ring, &cur_seg, &cur_trb)) { | ||
1566 | if ((cur_trb->generic.field[3] & | ||
1567 | TRB_TYPE_BITMASK) != TRB_TYPE(TRB_TR_NOOP) && | ||
1568 | (cur_trb->generic.field[3] & | ||
1569 | TRB_TYPE_BITMASK) != TRB_TYPE(TRB_LINK)) | ||
1570 | len += | ||
1571 | TRB_LEN(cur_trb->generic.field[2]); | ||
1572 | } | ||
1573 | len += TRB_LEN(cur_trb->generic.field[2]) - | ||
1574 | TRB_LEN(event->transfer_len); | ||
1575 | |||
1576 | if (trb_comp_code != COMP_STOP_INVAL) { | ||
1577 | td->urb->iso_frame_desc[idx].actual_length = len; | ||
1578 | td->urb->actual_length += len; | ||
1579 | } | ||
1580 | } | ||
1581 | |||
1582 | if ((idx == urb_priv->length - 1) && *status == -EINPROGRESS) | ||
1583 | *status = 0; | ||
1584 | |||
1585 | return finish_td(xhci, td, event_trb, event, ep, status, false); | ||
1586 | } | ||
1587 | |||
1588 | /* | ||
1589 | * Process bulk and interrupt tds, update urb status and actual_length. | ||
1590 | */ | ||
1591 | static int process_bulk_intr_td(struct xhci_hcd *xhci, struct xhci_td *td, | ||
1592 | union xhci_trb *event_trb, struct xhci_transfer_event *event, | ||
1593 | struct xhci_virt_ep *ep, int *status) | ||
1594 | { | ||
1595 | struct xhci_ring *ep_ring; | ||
1596 | union xhci_trb *cur_trb; | ||
1597 | struct xhci_segment *cur_seg; | ||
1598 | u32 trb_comp_code; | ||
1599 | |||
1600 | ep_ring = xhci_dma_to_transfer_ring(ep, event->buffer); | ||
1601 | trb_comp_code = GET_COMP_CODE(event->transfer_len); | ||
1602 | |||
1603 | switch (trb_comp_code) { | ||
1604 | case COMP_SUCCESS: | ||
1605 | /* Double check that the HW transferred everything. */ | ||
1606 | if (event_trb != td->last_trb) { | ||
1607 | xhci_warn(xhci, "WARN Successful completion " | ||
1608 | "on short TX\n"); | ||
1609 | if (td->urb->transfer_flags & URB_SHORT_NOT_OK) | ||
1610 | *status = -EREMOTEIO; | ||
1611 | else | ||
1612 | *status = 0; | ||
1613 | } else { | ||
1614 | if (usb_endpoint_xfer_bulk(&td->urb->ep->desc)) | ||
1615 | xhci_dbg(xhci, "Successful bulk " | ||
1616 | "transfer!\n"); | ||
1617 | else | ||
1618 | xhci_dbg(xhci, "Successful interrupt " | ||
1619 | "transfer!\n"); | ||
1620 | *status = 0; | ||
1621 | } | ||
1622 | break; | ||
1623 | case COMP_SHORT_TX: | ||
1624 | if (td->urb->transfer_flags & URB_SHORT_NOT_OK) | ||
1625 | *status = -EREMOTEIO; | ||
1626 | else | ||
1627 | *status = 0; | ||
1628 | break; | ||
1629 | default: | ||
1630 | /* Others already handled above */ | ||
1631 | break; | ||
1632 | } | ||
1633 | dev_dbg(&td->urb->dev->dev, | ||
1634 | "ep %#x - asked for %d bytes, " | ||
1635 | "%d bytes untransferred\n", | ||
1636 | td->urb->ep->desc.bEndpointAddress, | ||
1637 | td->urb->transfer_buffer_length, | ||
1638 | TRB_LEN(event->transfer_len)); | ||
1639 | /* Fast path - was this the last TRB in the TD for this URB? */ | ||
1640 | if (event_trb == td->last_trb) { | ||
1641 | if (TRB_LEN(event->transfer_len) != 0) { | ||
1642 | td->urb->actual_length = | ||
1643 | td->urb->transfer_buffer_length - | ||
1644 | TRB_LEN(event->transfer_len); | ||
1645 | if (td->urb->transfer_buffer_length < | ||
1646 | td->urb->actual_length) { | ||
1647 | xhci_warn(xhci, "HC gave bad length " | ||
1648 | "of %d bytes left\n", | ||
1649 | TRB_LEN(event->transfer_len)); | ||
1650 | td->urb->actual_length = 0; | ||
1651 | if (td->urb->transfer_flags & URB_SHORT_NOT_OK) | ||
1652 | *status = -EREMOTEIO; | ||
1653 | else | ||
1654 | *status = 0; | ||
1655 | } | ||
1656 | /* Don't overwrite a previously set error code */ | ||
1657 | if (*status == -EINPROGRESS) { | ||
1658 | if (td->urb->transfer_flags & URB_SHORT_NOT_OK) | ||
1659 | *status = -EREMOTEIO; | ||
1660 | else | ||
1661 | *status = 0; | ||
1662 | } | ||
1663 | } else { | ||
1664 | td->urb->actual_length = | ||
1665 | td->urb->transfer_buffer_length; | ||
1666 | /* Ignore a short packet completion if the | ||
1667 | * untransferred length was zero. | ||
1668 | */ | ||
1669 | if (*status == -EREMOTEIO) | ||
1670 | *status = 0; | ||
1671 | } | ||
1672 | } else { | ||
1673 | /* Slow path - walk the list, starting from the dequeue | ||
1674 | * pointer, to get the actual length transferred. | ||
1675 | */ | ||
1676 | td->urb->actual_length = 0; | ||
1677 | for (cur_trb = ep_ring->dequeue, cur_seg = ep_ring->deq_seg; | ||
1678 | cur_trb != event_trb; | ||
1679 | next_trb(xhci, ep_ring, &cur_seg, &cur_trb)) { | ||
1680 | if ((cur_trb->generic.field[3] & | ||
1681 | TRB_TYPE_BITMASK) != TRB_TYPE(TRB_TR_NOOP) && | ||
1682 | (cur_trb->generic.field[3] & | ||
1683 | TRB_TYPE_BITMASK) != TRB_TYPE(TRB_LINK)) | ||
1684 | td->urb->actual_length += | ||
1685 | TRB_LEN(cur_trb->generic.field[2]); | ||
1686 | } | ||
1687 | /* If the ring didn't stop on a Link or No-op TRB, add | ||
1688 | * in the actual bytes transferred from the Normal TRB | ||
1689 | */ | ||
1690 | if (trb_comp_code != COMP_STOP_INVAL) | ||
1691 | td->urb->actual_length += | ||
1692 | TRB_LEN(cur_trb->generic.field[2]) - | ||
1693 | TRB_LEN(event->transfer_len); | ||
1694 | } | ||
1695 | |||
1696 | return finish_td(xhci, td, event_trb, event, ep, status, false); | ||
1697 | } | ||
1698 | |||
1699 | /* | ||
1261 | * If this function returns an error condition, it means it got a Transfer | 1700 | * If this function returns an error condition, it means it got a Transfer |
1262 | * event with a corrupted Slot ID, Endpoint ID, or TRB DMA address. | 1701 | * event with a corrupted Slot ID, Endpoint ID, or TRB DMA address. |
1263 | * At this point, the host controller is probably hosed and should be reset. | 1702 | * At this point, the host controller is probably hosed and should be reset. |
@@ -1276,10 +1715,11 @@ static int handle_tx_event(struct xhci_hcd *xhci, | |||
1276 | union xhci_trb *event_trb; | 1715 | union xhci_trb *event_trb; |
1277 | struct urb *urb = NULL; | 1716 | struct urb *urb = NULL; |
1278 | int status = -EINPROGRESS; | 1717 | int status = -EINPROGRESS; |
1718 | struct urb_priv *urb_priv; | ||
1279 | struct xhci_ep_ctx *ep_ctx; | 1719 | struct xhci_ep_ctx *ep_ctx; |
1280 | u32 trb_comp_code; | 1720 | u32 trb_comp_code; |
1721 | int ret = 0; | ||
1281 | 1722 | ||
1282 | xhci_dbg(xhci, "In %s\n", __func__); | ||
1283 | slot_id = TRB_TO_SLOT_ID(event->flags); | 1723 | slot_id = TRB_TO_SLOT_ID(event->flags); |
1284 | xdev = xhci->devs[slot_id]; | 1724 | xdev = xhci->devs[slot_id]; |
1285 | if (!xdev) { | 1725 | if (!xdev) { |
@@ -1293,51 +1733,16 @@ static int handle_tx_event(struct xhci_hcd *xhci, | |||
1293 | ep = &xdev->eps[ep_index]; | 1733 | ep = &xdev->eps[ep_index]; |
1294 | ep_ring = xhci_dma_to_transfer_ring(ep, event->buffer); | 1734 | ep_ring = xhci_dma_to_transfer_ring(ep, event->buffer); |
1295 | ep_ctx = xhci_get_ep_ctx(xhci, xdev->out_ctx, ep_index); | 1735 | ep_ctx = xhci_get_ep_ctx(xhci, xdev->out_ctx, ep_index); |
1296 | if (!ep_ring || (ep_ctx->ep_info & EP_STATE_MASK) == EP_STATE_DISABLED) { | 1736 | if (!ep_ring || |
1737 | (ep_ctx->ep_info & EP_STATE_MASK) == EP_STATE_DISABLED) { | ||
1297 | xhci_err(xhci, "ERROR Transfer event for disabled endpoint " | 1738 | xhci_err(xhci, "ERROR Transfer event for disabled endpoint " |
1298 | "or incorrect stream ring\n"); | 1739 | "or incorrect stream ring\n"); |
1299 | return -ENODEV; | 1740 | return -ENODEV; |
1300 | } | 1741 | } |
1301 | 1742 | ||
1302 | event_dma = event->buffer; | 1743 | event_dma = event->buffer; |
1303 | /* This TRB should be in the TD at the head of this ring's TD list */ | ||
1304 | xhci_dbg(xhci, "%s - checking for list empty\n", __func__); | ||
1305 | if (list_empty(&ep_ring->td_list)) { | ||
1306 | xhci_warn(xhci, "WARN Event TRB for slot %d ep %d with no TDs queued?\n", | ||
1307 | TRB_TO_SLOT_ID(event->flags), ep_index); | ||
1308 | xhci_dbg(xhci, "Event TRB with TRB type ID %u\n", | ||
1309 | (unsigned int) (event->flags & TRB_TYPE_BITMASK)>>10); | ||
1310 | xhci_print_trb_offsets(xhci, (union xhci_trb *) event); | ||
1311 | urb = NULL; | ||
1312 | goto cleanup; | ||
1313 | } | ||
1314 | xhci_dbg(xhci, "%s - getting list entry\n", __func__); | ||
1315 | td = list_entry(ep_ring->td_list.next, struct xhci_td, td_list); | ||
1316 | |||
1317 | /* Is this a TRB in the currently executing TD? */ | ||
1318 | xhci_dbg(xhci, "%s - looking for TD\n", __func__); | ||
1319 | event_seg = trb_in_td(ep_ring->deq_seg, ep_ring->dequeue, | ||
1320 | td->last_trb, event_dma); | ||
1321 | xhci_dbg(xhci, "%s - found event_seg = %p\n", __func__, event_seg); | ||
1322 | if (!event_seg) { | ||
1323 | /* HC is busted, give up! */ | ||
1324 | xhci_err(xhci, "ERROR Transfer event TRB DMA ptr not part of current TD\n"); | ||
1325 | return -ESHUTDOWN; | ||
1326 | } | ||
1327 | event_trb = &event_seg->trbs[(event_dma - event_seg->dma) / sizeof(*event_trb)]; | ||
1328 | xhci_dbg(xhci, "Event TRB with TRB type ID %u\n", | ||
1329 | (unsigned int) (event->flags & TRB_TYPE_BITMASK)>>10); | ||
1330 | xhci_dbg(xhci, "Offset 0x00 (buffer lo) = 0x%x\n", | ||
1331 | lower_32_bits(event->buffer)); | ||
1332 | xhci_dbg(xhci, "Offset 0x04 (buffer hi) = 0x%x\n", | ||
1333 | upper_32_bits(event->buffer)); | ||
1334 | xhci_dbg(xhci, "Offset 0x08 (transfer length) = 0x%x\n", | ||
1335 | (unsigned int) event->transfer_len); | ||
1336 | xhci_dbg(xhci, "Offset 0x0C (flags) = 0x%x\n", | ||
1337 | (unsigned int) event->flags); | ||
1338 | |||
1339 | /* Look for common error cases */ | ||
1340 | trb_comp_code = GET_COMP_CODE(event->transfer_len); | 1744 | trb_comp_code = GET_COMP_CODE(event->transfer_len); |
1745 | /* Look for common error cases */ | ||
1341 | switch (trb_comp_code) { | 1746 | switch (trb_comp_code) { |
1342 | /* Skip codes that require special handling depending on | 1747 | /* Skip codes that require special handling depending on |
1343 | * transfer type | 1748 | * transfer type |
@@ -1373,278 +1778,156 @@ static int handle_tx_event(struct xhci_hcd *xhci, | |||
1373 | xhci_warn(xhci, "WARN: HC couldn't access mem fast enough\n"); | 1778 | xhci_warn(xhci, "WARN: HC couldn't access mem fast enough\n"); |
1374 | status = -ENOSR; | 1779 | status = -ENOSR; |
1375 | break; | 1780 | break; |
1781 | case COMP_BW_OVER: | ||
1782 | xhci_warn(xhci, "WARN: bandwidth overrun event on endpoint\n"); | ||
1783 | break; | ||
1784 | case COMP_BUFF_OVER: | ||
1785 | xhci_warn(xhci, "WARN: buffer overrun event on endpoint\n"); | ||
1786 | break; | ||
1787 | case COMP_UNDERRUN: | ||
1788 | /* | ||
1789 | * When the Isoch ring is empty, the xHC will generate | ||
1790 | * a Ring Overrun Event for IN Isoch endpoint or Ring | ||
1791 | * Underrun Event for OUT Isoch endpoint. | ||
1792 | */ | ||
1793 | xhci_dbg(xhci, "underrun event on endpoint\n"); | ||
1794 | if (!list_empty(&ep_ring->td_list)) | ||
1795 | xhci_dbg(xhci, "Underrun Event for slot %d ep %d " | ||
1796 | "still with TDs queued?\n", | ||
1797 | TRB_TO_SLOT_ID(event->flags), ep_index); | ||
1798 | goto cleanup; | ||
1799 | case COMP_OVERRUN: | ||
1800 | xhci_dbg(xhci, "overrun event on endpoint\n"); | ||
1801 | if (!list_empty(&ep_ring->td_list)) | ||
1802 | xhci_dbg(xhci, "Overrun Event for slot %d ep %d " | ||
1803 | "still with TDs queued?\n", | ||
1804 | TRB_TO_SLOT_ID(event->flags), ep_index); | ||
1805 | goto cleanup; | ||
1806 | case COMP_MISSED_INT: | ||
1807 | /* | ||
1808 | * When encounter missed service error, one or more isoc tds | ||
1809 | * may be missed by xHC. | ||
1810 | * Set skip flag of the ep_ring; Complete the missed tds as | ||
1811 | * short transfer when process the ep_ring next time. | ||
1812 | */ | ||
1813 | ep->skip = true; | ||
1814 | xhci_dbg(xhci, "Miss service interval error, set skip flag\n"); | ||
1815 | goto cleanup; | ||
1376 | default: | 1816 | default: |
1377 | if (xhci_is_vendor_info_code(xhci, trb_comp_code)) { | 1817 | if (xhci_is_vendor_info_code(xhci, trb_comp_code)) { |
1378 | status = 0; | 1818 | status = 0; |
1379 | break; | 1819 | break; |
1380 | } | 1820 | } |
1381 | xhci_warn(xhci, "ERROR Unknown event condition, HC probably busted\n"); | 1821 | xhci_warn(xhci, "ERROR Unknown event condition, HC probably " |
1382 | urb = NULL; | 1822 | "busted\n"); |
1383 | goto cleanup; | 1823 | goto cleanup; |
1384 | } | 1824 | } |
1385 | /* Now update the urb's actual_length and give back to the core */ | ||
1386 | /* Was this a control transfer? */ | ||
1387 | if (usb_endpoint_xfer_control(&td->urb->ep->desc)) { | ||
1388 | xhci_debug_trb(xhci, xhci->event_ring->dequeue); | ||
1389 | switch (trb_comp_code) { | ||
1390 | case COMP_SUCCESS: | ||
1391 | if (event_trb == ep_ring->dequeue) { | ||
1392 | xhci_warn(xhci, "WARN: Success on ctrl setup TRB without IOC set??\n"); | ||
1393 | status = -ESHUTDOWN; | ||
1394 | } else if (event_trb != td->last_trb) { | ||
1395 | xhci_warn(xhci, "WARN: Success on ctrl data TRB without IOC set??\n"); | ||
1396 | status = -ESHUTDOWN; | ||
1397 | } else { | ||
1398 | xhci_dbg(xhci, "Successful control transfer!\n"); | ||
1399 | status = 0; | ||
1400 | } | ||
1401 | break; | ||
1402 | case COMP_SHORT_TX: | ||
1403 | xhci_warn(xhci, "WARN: short transfer on control ep\n"); | ||
1404 | if (td->urb->transfer_flags & URB_SHORT_NOT_OK) | ||
1405 | status = -EREMOTEIO; | ||
1406 | else | ||
1407 | status = 0; | ||
1408 | break; | ||
1409 | 1825 | ||
1410 | default: | 1826 | do { |
1411 | if (!xhci_requires_manual_halt_cleanup(xhci, | 1827 | /* This TRB should be in the TD at the head of this ring's |
1412 | ep_ctx, trb_comp_code)) | 1828 | * TD list. |
1413 | break; | ||
1414 | xhci_dbg(xhci, "TRB error code %u, " | ||
1415 | "halted endpoint index = %u\n", | ||
1416 | trb_comp_code, ep_index); | ||
1417 | /* else fall through */ | ||
1418 | case COMP_STALL: | ||
1419 | /* Did we transfer part of the data (middle) phase? */ | ||
1420 | if (event_trb != ep_ring->dequeue && | ||
1421 | event_trb != td->last_trb) | ||
1422 | td->urb->actual_length = | ||
1423 | td->urb->transfer_buffer_length | ||
1424 | - TRB_LEN(event->transfer_len); | ||
1425 | else | ||
1426 | td->urb->actual_length = 0; | ||
1427 | |||
1428 | xhci_cleanup_halted_endpoint(xhci, | ||
1429 | slot_id, ep_index, 0, td, event_trb); | ||
1430 | goto td_cleanup; | ||
1431 | } | ||
1432 | /* | ||
1433 | * Did we transfer any data, despite the errors that might have | ||
1434 | * happened? I.e. did we get past the setup stage? | ||
1435 | */ | 1829 | */ |
1436 | if (event_trb != ep_ring->dequeue) { | 1830 | if (list_empty(&ep_ring->td_list)) { |
1437 | /* The event was for the status stage */ | 1831 | xhci_warn(xhci, "WARN Event TRB for slot %d ep %d " |
1438 | if (event_trb == td->last_trb) { | 1832 | "with no TDs queued?\n", |
1439 | if (td->urb->actual_length != 0) { | 1833 | TRB_TO_SLOT_ID(event->flags), ep_index); |
1440 | /* Don't overwrite a previously set error code */ | 1834 | xhci_dbg(xhci, "Event TRB with TRB type ID %u\n", |
1441 | if ((status == -EINPROGRESS || | 1835 | (unsigned int) (event->flags & TRB_TYPE_BITMASK)>>10); |
1442 | status == 0) && | 1836 | xhci_print_trb_offsets(xhci, (union xhci_trb *) event); |
1443 | (td->urb->transfer_flags | 1837 | if (ep->skip) { |
1444 | & URB_SHORT_NOT_OK)) | 1838 | ep->skip = false; |
1445 | /* Did we already see a short data stage? */ | 1839 | xhci_dbg(xhci, "td_list is empty while skip " |
1446 | status = -EREMOTEIO; | 1840 | "flag set. Clear skip flag.\n"); |
1447 | } else { | ||
1448 | td->urb->actual_length = | ||
1449 | td->urb->transfer_buffer_length; | ||
1450 | } | ||
1451 | } else { | ||
1452 | /* Maybe the event was for the data stage? */ | ||
1453 | if (trb_comp_code != COMP_STOP_INVAL) { | ||
1454 | /* We didn't stop on a link TRB in the middle */ | ||
1455 | td->urb->actual_length = | ||
1456 | td->urb->transfer_buffer_length - | ||
1457 | TRB_LEN(event->transfer_len); | ||
1458 | xhci_dbg(xhci, "Waiting for status stage event\n"); | ||
1459 | urb = NULL; | ||
1460 | goto cleanup; | ||
1461 | } | ||
1462 | } | 1841 | } |
1842 | ret = 0; | ||
1843 | goto cleanup; | ||
1463 | } | 1844 | } |
1464 | } else { | 1845 | |
1465 | switch (trb_comp_code) { | 1846 | td = list_entry(ep_ring->td_list.next, struct xhci_td, td_list); |
1466 | case COMP_SUCCESS: | 1847 | /* Is this a TRB in the currently executing TD? */ |
1467 | /* Double check that the HW transferred everything. */ | 1848 | event_seg = trb_in_td(ep_ring->deq_seg, ep_ring->dequeue, |
1468 | if (event_trb != td->last_trb) { | 1849 | td->last_trb, event_dma); |
1469 | xhci_warn(xhci, "WARN Successful completion " | 1850 | if (event_seg && ep->skip) { |
1470 | "on short TX\n"); | 1851 | xhci_dbg(xhci, "Found td. Clear skip flag.\n"); |
1471 | if (td->urb->transfer_flags & URB_SHORT_NOT_OK) | 1852 | ep->skip = false; |
1472 | status = -EREMOTEIO; | 1853 | } |
1473 | else | 1854 | if (!event_seg && |
1474 | status = 0; | 1855 | (!ep->skip || !usb_endpoint_xfer_isoc(&td->urb->ep->desc))) { |
1475 | } else { | 1856 | /* HC is busted, give up! */ |
1476 | if (usb_endpoint_xfer_bulk(&td->urb->ep->desc)) | 1857 | xhci_err(xhci, "ERROR Transfer event TRB DMA ptr not " |
1477 | xhci_dbg(xhci, "Successful bulk " | 1858 | "part of current TD\n"); |
1478 | "transfer!\n"); | 1859 | return -ESHUTDOWN; |
1479 | else | ||
1480 | xhci_dbg(xhci, "Successful interrupt " | ||
1481 | "transfer!\n"); | ||
1482 | status = 0; | ||
1483 | } | ||
1484 | break; | ||
1485 | case COMP_SHORT_TX: | ||
1486 | if (td->urb->transfer_flags & URB_SHORT_NOT_OK) | ||
1487 | status = -EREMOTEIO; | ||
1488 | else | ||
1489 | status = 0; | ||
1490 | break; | ||
1491 | default: | ||
1492 | /* Others already handled above */ | ||
1493 | break; | ||
1494 | } | 1860 | } |
1495 | dev_dbg(&td->urb->dev->dev, | ||
1496 | "ep %#x - asked for %d bytes, " | ||
1497 | "%d bytes untransferred\n", | ||
1498 | td->urb->ep->desc.bEndpointAddress, | ||
1499 | td->urb->transfer_buffer_length, | ||
1500 | TRB_LEN(event->transfer_len)); | ||
1501 | /* Fast path - was this the last TRB in the TD for this URB? */ | ||
1502 | if (event_trb == td->last_trb) { | ||
1503 | if (TRB_LEN(event->transfer_len) != 0) { | ||
1504 | td->urb->actual_length = | ||
1505 | td->urb->transfer_buffer_length - | ||
1506 | TRB_LEN(event->transfer_len); | ||
1507 | if (td->urb->transfer_buffer_length < | ||
1508 | td->urb->actual_length) { | ||
1509 | xhci_warn(xhci, "HC gave bad length " | ||
1510 | "of %d bytes left\n", | ||
1511 | TRB_LEN(event->transfer_len)); | ||
1512 | td->urb->actual_length = 0; | ||
1513 | if (td->urb->transfer_flags & | ||
1514 | URB_SHORT_NOT_OK) | ||
1515 | status = -EREMOTEIO; | ||
1516 | else | ||
1517 | status = 0; | ||
1518 | } | ||
1519 | /* Don't overwrite a previously set error code */ | ||
1520 | if (status == -EINPROGRESS) { | ||
1521 | if (td->urb->transfer_flags & URB_SHORT_NOT_OK) | ||
1522 | status = -EREMOTEIO; | ||
1523 | else | ||
1524 | status = 0; | ||
1525 | } | ||
1526 | } else { | ||
1527 | td->urb->actual_length = td->urb->transfer_buffer_length; | ||
1528 | /* Ignore a short packet completion if the | ||
1529 | * untransferred length was zero. | ||
1530 | */ | ||
1531 | if (status == -EREMOTEIO) | ||
1532 | status = 0; | ||
1533 | } | ||
1534 | } else { | ||
1535 | /* Slow path - walk the list, starting from the dequeue | ||
1536 | * pointer, to get the actual length transferred. | ||
1537 | */ | ||
1538 | union xhci_trb *cur_trb; | ||
1539 | struct xhci_segment *cur_seg; | ||
1540 | 1861 | ||
1541 | td->urb->actual_length = 0; | 1862 | if (event_seg) { |
1542 | for (cur_trb = ep_ring->dequeue, cur_seg = ep_ring->deq_seg; | 1863 | event_trb = &event_seg->trbs[(event_dma - |
1543 | cur_trb != event_trb; | 1864 | event_seg->dma) / sizeof(*event_trb)]; |
1544 | next_trb(xhci, ep_ring, &cur_seg, &cur_trb)) { | 1865 | /* |
1545 | if ((cur_trb->generic.field[3] & | 1866 | * No-op TRB should not trigger interrupts. |
1546 | TRB_TYPE_BITMASK) != TRB_TYPE(TRB_TR_NOOP) && | 1867 | * If event_trb is a no-op TRB, it means the |
1547 | (cur_trb->generic.field[3] & | 1868 | * corresponding TD has been cancelled. Just ignore |
1548 | TRB_TYPE_BITMASK) != TRB_TYPE(TRB_LINK)) | 1869 | * the TD. |
1549 | td->urb->actual_length += | ||
1550 | TRB_LEN(cur_trb->generic.field[2]); | ||
1551 | } | ||
1552 | /* If the ring didn't stop on a Link or No-op TRB, add | ||
1553 | * in the actual bytes transferred from the Normal TRB | ||
1554 | */ | 1870 | */ |
1555 | if (trb_comp_code != COMP_STOP_INVAL) | 1871 | if ((event_trb->generic.field[3] & TRB_TYPE_BITMASK) |
1556 | td->urb->actual_length += | 1872 | == TRB_TYPE(TRB_TR_NOOP)) { |
1557 | TRB_LEN(cur_trb->generic.field[2]) - | 1873 | xhci_dbg(xhci, "event_trb is a no-op TRB. " |
1558 | TRB_LEN(event->transfer_len); | 1874 | "Skip it\n"); |
1875 | goto cleanup; | ||
1876 | } | ||
1559 | } | 1877 | } |
1560 | } | 1878 | |
1561 | if (trb_comp_code == COMP_STOP_INVAL || | 1879 | /* Now update the urb's actual_length and give back to |
1562 | trb_comp_code == COMP_STOP) { | 1880 | * the core |
1563 | /* The Endpoint Stop Command completion will take care of any | ||
1564 | * stopped TDs. A stopped TD may be restarted, so don't update | ||
1565 | * the ring dequeue pointer or take this TD off any lists yet. | ||
1566 | */ | 1881 | */ |
1567 | ep->stopped_td = td; | 1882 | if (usb_endpoint_xfer_control(&td->urb->ep->desc)) |
1568 | ep->stopped_trb = event_trb; | 1883 | ret = process_ctrl_td(xhci, td, event_trb, event, ep, |
1569 | } else { | 1884 | &status); |
1570 | if (trb_comp_code == COMP_STALL) { | 1885 | else if (usb_endpoint_xfer_isoc(&td->urb->ep->desc)) |
1571 | /* The transfer is completed from the driver's | 1886 | ret = process_isoc_td(xhci, td, event_trb, event, ep, |
1572 | * perspective, but we need to issue a set dequeue | 1887 | &status); |
1573 | * command for this stalled endpoint to move the dequeue | 1888 | else |
1574 | * pointer past the TD. We can't do that here because | 1889 | ret = process_bulk_intr_td(xhci, td, event_trb, event, |
1575 | * the halt condition must be cleared first. Let the | 1890 | ep, &status); |
1576 | * USB class driver clear the stall later. | ||
1577 | */ | ||
1578 | ep->stopped_td = td; | ||
1579 | ep->stopped_trb = event_trb; | ||
1580 | ep->stopped_stream = ep_ring->stream_id; | ||
1581 | } else if (xhci_requires_manual_halt_cleanup(xhci, | ||
1582 | ep_ctx, trb_comp_code)) { | ||
1583 | /* Other types of errors halt the endpoint, but the | ||
1584 | * class driver doesn't call usb_reset_endpoint() unless | ||
1585 | * the error is -EPIPE. Clear the halted status in the | ||
1586 | * xHCI hardware manually. | ||
1587 | */ | ||
1588 | xhci_cleanup_halted_endpoint(xhci, | ||
1589 | slot_id, ep_index, ep_ring->stream_id, td, event_trb); | ||
1590 | } else { | ||
1591 | /* Update ring dequeue pointer */ | ||
1592 | while (ep_ring->dequeue != td->last_trb) | ||
1593 | inc_deq(xhci, ep_ring, false); | ||
1594 | inc_deq(xhci, ep_ring, false); | ||
1595 | } | ||
1596 | 1891 | ||
1597 | td_cleanup: | 1892 | cleanup: |
1598 | /* Clean up the endpoint's TD list */ | 1893 | /* |
1599 | urb = td->urb; | 1894 | * Do not update event ring dequeue pointer if ep->skip is set. |
1600 | /* Do one last check of the actual transfer length. | 1895 | * Will roll back to continue process missed tds. |
1601 | * If the host controller said we transferred more data than | ||
1602 | * the buffer length, urb->actual_length will be a very big | ||
1603 | * number (since it's unsigned). Play it safe and say we didn't | ||
1604 | * transfer anything. | ||
1605 | */ | 1896 | */ |
1606 | if (urb->actual_length > urb->transfer_buffer_length) { | 1897 | if (trb_comp_code == COMP_MISSED_INT || !ep->skip) { |
1607 | xhci_warn(xhci, "URB transfer length is wrong, " | 1898 | inc_deq(xhci, xhci->event_ring, true); |
1608 | "xHC issue? req. len = %u, " | ||
1609 | "act. len = %u\n", | ||
1610 | urb->transfer_buffer_length, | ||
1611 | urb->actual_length); | ||
1612 | urb->actual_length = 0; | ||
1613 | if (td->urb->transfer_flags & URB_SHORT_NOT_OK) | ||
1614 | status = -EREMOTEIO; | ||
1615 | else | ||
1616 | status = 0; | ||
1617 | } | 1899 | } |
1618 | list_del(&td->td_list); | ||
1619 | /* Was this TD slated to be cancelled but completed anyway? */ | ||
1620 | if (!list_empty(&td->cancelled_td_list)) | ||
1621 | list_del(&td->cancelled_td_list); | ||
1622 | 1900 | ||
1623 | /* Leave the TD around for the reset endpoint function to use | 1901 | if (ret) { |
1624 | * (but only if it's not a control endpoint, since we already | 1902 | urb = td->urb; |
1625 | * queued the Set TR dequeue pointer command for stalled | 1903 | urb_priv = urb->hcpriv; |
1626 | * control endpoints). | 1904 | /* Leave the TD around for the reset endpoint function |
1627 | */ | 1905 | * to use(but only if it's not a control endpoint, |
1628 | if (usb_endpoint_xfer_control(&urb->ep->desc) || | 1906 | * since we already queued the Set TR dequeue pointer |
1629 | (trb_comp_code != COMP_STALL && | 1907 | * command for stalled control endpoints). |
1630 | trb_comp_code != COMP_BABBLE)) { | 1908 | */ |
1631 | kfree(td); | 1909 | if (usb_endpoint_xfer_control(&urb->ep->desc) || |
1910 | (trb_comp_code != COMP_STALL && | ||
1911 | trb_comp_code != COMP_BABBLE)) | ||
1912 | xhci_urb_free_priv(xhci, urb_priv); | ||
1913 | |||
1914 | usb_hcd_unlink_urb_from_ep(xhci_to_hcd(xhci), urb); | ||
1915 | xhci_dbg(xhci, "Giveback URB %p, len = %d, " | ||
1916 | "status = %d\n", | ||
1917 | urb, urb->actual_length, status); | ||
1918 | spin_unlock(&xhci->lock); | ||
1919 | usb_hcd_giveback_urb(xhci_to_hcd(xhci), urb, status); | ||
1920 | spin_lock(&xhci->lock); | ||
1632 | } | 1921 | } |
1633 | urb->hcpriv = NULL; | ||
1634 | } | ||
1635 | cleanup: | ||
1636 | inc_deq(xhci, xhci->event_ring, true); | ||
1637 | xhci_set_hc_event_deq(xhci); | ||
1638 | 1922 | ||
1639 | /* FIXME for multi-TD URBs (who have buffers bigger than 64MB) */ | 1923 | /* |
1640 | if (urb) { | 1924 | * If ep->skip is set, it means there are missed tds on the |
1641 | usb_hcd_unlink_urb_from_ep(xhci_to_hcd(xhci), urb); | 1925 | * endpoint ring need to take care of. |
1642 | xhci_dbg(xhci, "Giveback URB %p, len = %d, status = %d\n", | 1926 | * Process them as short transfer until reach the td pointed by |
1643 | urb, urb->actual_length, status); | 1927 | * the event. |
1644 | spin_unlock(&xhci->lock); | 1928 | */ |
1645 | usb_hcd_giveback_urb(xhci_to_hcd(xhci), urb, status); | 1929 | } while (ep->skip && trb_comp_code != COMP_MISSED_INT); |
1646 | spin_lock(&xhci->lock); | 1930 | |
1647 | } | ||
1648 | return 0; | 1931 | return 0; |
1649 | } | 1932 | } |
1650 | 1933 | ||
@@ -1652,7 +1935,7 @@ cleanup: | |||
1652 | * This function handles all OS-owned events on the event ring. It may drop | 1935 | * This function handles all OS-owned events on the event ring. It may drop |
1653 | * xhci->lock between event processing (e.g. to pass up port status changes). | 1936 | * xhci->lock between event processing (e.g. to pass up port status changes). |
1654 | */ | 1937 | */ |
1655 | void xhci_handle_event(struct xhci_hcd *xhci) | 1938 | static void xhci_handle_event(struct xhci_hcd *xhci) |
1656 | { | 1939 | { |
1657 | union xhci_trb *event; | 1940 | union xhci_trb *event; |
1658 | int update_ptrs = 1; | 1941 | int update_ptrs = 1; |
@@ -1710,15 +1993,130 @@ void xhci_handle_event(struct xhci_hcd *xhci) | |||
1710 | return; | 1993 | return; |
1711 | } | 1994 | } |
1712 | 1995 | ||
1713 | if (update_ptrs) { | 1996 | if (update_ptrs) |
1714 | /* Update SW and HC event ring dequeue pointer */ | 1997 | /* Update SW event ring dequeue pointer */ |
1715 | inc_deq(xhci, xhci->event_ring, true); | 1998 | inc_deq(xhci, xhci->event_ring, true); |
1716 | xhci_set_hc_event_deq(xhci); | 1999 | |
1717 | } | ||
1718 | /* Are there more items on the event ring? */ | 2000 | /* Are there more items on the event ring? */ |
1719 | xhci_handle_event(xhci); | 2001 | xhci_handle_event(xhci); |
1720 | } | 2002 | } |
1721 | 2003 | ||
2004 | /* | ||
2005 | * xHCI spec says we can get an interrupt, and if the HC has an error condition, | ||
2006 | * we might get bad data out of the event ring. Section 4.10.2.7 has a list of | ||
2007 | * indicators of an event TRB error, but we check the status *first* to be safe. | ||
2008 | */ | ||
2009 | irqreturn_t xhci_irq(struct usb_hcd *hcd) | ||
2010 | { | ||
2011 | struct xhci_hcd *xhci = hcd_to_xhci(hcd); | ||
2012 | u32 status; | ||
2013 | union xhci_trb *trb; | ||
2014 | u64 temp_64; | ||
2015 | union xhci_trb *event_ring_deq; | ||
2016 | dma_addr_t deq; | ||
2017 | |||
2018 | spin_lock(&xhci->lock); | ||
2019 | trb = xhci->event_ring->dequeue; | ||
2020 | /* Check if the xHC generated the interrupt, or the irq is shared */ | ||
2021 | status = xhci_readl(xhci, &xhci->op_regs->status); | ||
2022 | if (status == 0xffffffff) | ||
2023 | goto hw_died; | ||
2024 | |||
2025 | if (!(status & STS_EINT)) { | ||
2026 | spin_unlock(&xhci->lock); | ||
2027 | xhci_warn(xhci, "Spurious interrupt.\n"); | ||
2028 | return IRQ_NONE; | ||
2029 | } | ||
2030 | xhci_dbg(xhci, "op reg status = %08x\n", status); | ||
2031 | xhci_dbg(xhci, "Event ring dequeue ptr:\n"); | ||
2032 | xhci_dbg(xhci, "@%llx %08x %08x %08x %08x\n", | ||
2033 | (unsigned long long) | ||
2034 | xhci_trb_virt_to_dma(xhci->event_ring->deq_seg, trb), | ||
2035 | lower_32_bits(trb->link.segment_ptr), | ||
2036 | upper_32_bits(trb->link.segment_ptr), | ||
2037 | (unsigned int) trb->link.intr_target, | ||
2038 | (unsigned int) trb->link.control); | ||
2039 | |||
2040 | if (status & STS_FATAL) { | ||
2041 | xhci_warn(xhci, "WARNING: Host System Error\n"); | ||
2042 | xhci_halt(xhci); | ||
2043 | hw_died: | ||
2044 | xhci_to_hcd(xhci)->state = HC_STATE_HALT; | ||
2045 | spin_unlock(&xhci->lock); | ||
2046 | return -ESHUTDOWN; | ||
2047 | } | ||
2048 | |||
2049 | /* | ||
2050 | * Clear the op reg interrupt status first, | ||
2051 | * so we can receive interrupts from other MSI-X interrupters. | ||
2052 | * Write 1 to clear the interrupt status. | ||
2053 | */ | ||
2054 | status |= STS_EINT; | ||
2055 | xhci_writel(xhci, status, &xhci->op_regs->status); | ||
2056 | /* FIXME when MSI-X is supported and there are multiple vectors */ | ||
2057 | /* Clear the MSI-X event interrupt status */ | ||
2058 | |||
2059 | if (hcd->irq != -1) { | ||
2060 | u32 irq_pending; | ||
2061 | /* Acknowledge the PCI interrupt */ | ||
2062 | irq_pending = xhci_readl(xhci, &xhci->ir_set->irq_pending); | ||
2063 | irq_pending |= 0x3; | ||
2064 | xhci_writel(xhci, irq_pending, &xhci->ir_set->irq_pending); | ||
2065 | } | ||
2066 | |||
2067 | if (xhci->xhc_state & XHCI_STATE_DYING) { | ||
2068 | xhci_dbg(xhci, "xHCI dying, ignoring interrupt. " | ||
2069 | "Shouldn't IRQs be disabled?\n"); | ||
2070 | /* Clear the event handler busy flag (RW1C); | ||
2071 | * the event ring should be empty. | ||
2072 | */ | ||
2073 | temp_64 = xhci_read_64(xhci, &xhci->ir_set->erst_dequeue); | ||
2074 | xhci_write_64(xhci, temp_64 | ERST_EHB, | ||
2075 | &xhci->ir_set->erst_dequeue); | ||
2076 | spin_unlock(&xhci->lock); | ||
2077 | |||
2078 | return IRQ_HANDLED; | ||
2079 | } | ||
2080 | |||
2081 | event_ring_deq = xhci->event_ring->dequeue; | ||
2082 | /* FIXME this should be a delayed service routine | ||
2083 | * that clears the EHB. | ||
2084 | */ | ||
2085 | xhci_handle_event(xhci); | ||
2086 | |||
2087 | temp_64 = xhci_read_64(xhci, &xhci->ir_set->erst_dequeue); | ||
2088 | /* If necessary, update the HW's version of the event ring deq ptr. */ | ||
2089 | if (event_ring_deq != xhci->event_ring->dequeue) { | ||
2090 | deq = xhci_trb_virt_to_dma(xhci->event_ring->deq_seg, | ||
2091 | xhci->event_ring->dequeue); | ||
2092 | if (deq == 0) | ||
2093 | xhci_warn(xhci, "WARN something wrong with SW event " | ||
2094 | "ring dequeue ptr.\n"); | ||
2095 | /* Update HC event ring dequeue pointer */ | ||
2096 | temp_64 &= ERST_PTR_MASK; | ||
2097 | temp_64 |= ((u64) deq & (u64) ~ERST_PTR_MASK); | ||
2098 | } | ||
2099 | |||
2100 | /* Clear the event handler busy flag (RW1C); event ring is empty. */ | ||
2101 | temp_64 |= ERST_EHB; | ||
2102 | xhci_write_64(xhci, temp_64, &xhci->ir_set->erst_dequeue); | ||
2103 | |||
2104 | spin_unlock(&xhci->lock); | ||
2105 | |||
2106 | return IRQ_HANDLED; | ||
2107 | } | ||
2108 | |||
2109 | irqreturn_t xhci_msi_irq(int irq, struct usb_hcd *hcd) | ||
2110 | { | ||
2111 | irqreturn_t ret; | ||
2112 | |||
2113 | set_bit(HCD_FLAG_SAW_IRQ, &hcd->flags); | ||
2114 | |||
2115 | ret = xhci_irq(hcd); | ||
2116 | |||
2117 | return ret; | ||
2118 | } | ||
2119 | |||
1722 | /**** Endpoint Ring Operations ****/ | 2120 | /**** Endpoint Ring Operations ****/ |
1723 | 2121 | ||
1724 | /* | 2122 | /* |
@@ -1827,10 +2225,12 @@ static int prepare_transfer(struct xhci_hcd *xhci, | |||
1827 | unsigned int stream_id, | 2225 | unsigned int stream_id, |
1828 | unsigned int num_trbs, | 2226 | unsigned int num_trbs, |
1829 | struct urb *urb, | 2227 | struct urb *urb, |
1830 | struct xhci_td **td, | 2228 | unsigned int td_index, |
1831 | gfp_t mem_flags) | 2229 | gfp_t mem_flags) |
1832 | { | 2230 | { |
1833 | int ret; | 2231 | int ret; |
2232 | struct urb_priv *urb_priv; | ||
2233 | struct xhci_td *td; | ||
1834 | struct xhci_ring *ep_ring; | 2234 | struct xhci_ring *ep_ring; |
1835 | struct xhci_ep_ctx *ep_ctx = xhci_get_ep_ctx(xhci, xdev->out_ctx, ep_index); | 2235 | struct xhci_ep_ctx *ep_ctx = xhci_get_ep_ctx(xhci, xdev->out_ctx, ep_index); |
1836 | 2236 | ||
@@ -1846,24 +2246,29 @@ static int prepare_transfer(struct xhci_hcd *xhci, | |||
1846 | num_trbs, mem_flags); | 2246 | num_trbs, mem_flags); |
1847 | if (ret) | 2247 | if (ret) |
1848 | return ret; | 2248 | return ret; |
1849 | *td = kzalloc(sizeof(struct xhci_td), mem_flags); | ||
1850 | if (!*td) | ||
1851 | return -ENOMEM; | ||
1852 | INIT_LIST_HEAD(&(*td)->td_list); | ||
1853 | INIT_LIST_HEAD(&(*td)->cancelled_td_list); | ||
1854 | 2249 | ||
1855 | ret = usb_hcd_link_urb_to_ep(xhci_to_hcd(xhci), urb); | 2250 | urb_priv = urb->hcpriv; |
1856 | if (unlikely(ret)) { | 2251 | td = urb_priv->td[td_index]; |
1857 | kfree(*td); | 2252 | |
1858 | return ret; | 2253 | INIT_LIST_HEAD(&td->td_list); |
2254 | INIT_LIST_HEAD(&td->cancelled_td_list); | ||
2255 | |||
2256 | if (td_index == 0) { | ||
2257 | ret = usb_hcd_link_urb_to_ep(xhci_to_hcd(xhci), urb); | ||
2258 | if (unlikely(ret)) { | ||
2259 | xhci_urb_free_priv(xhci, urb_priv); | ||
2260 | urb->hcpriv = NULL; | ||
2261 | return ret; | ||
2262 | } | ||
1859 | } | 2263 | } |
1860 | 2264 | ||
1861 | (*td)->urb = urb; | 2265 | td->urb = urb; |
1862 | urb->hcpriv = (void *) (*td); | ||
1863 | /* Add this TD to the tail of the endpoint ring's TD list */ | 2266 | /* Add this TD to the tail of the endpoint ring's TD list */ |
1864 | list_add_tail(&(*td)->td_list, &ep_ring->td_list); | 2267 | list_add_tail(&td->td_list, &ep_ring->td_list); |
1865 | (*td)->start_seg = ep_ring->enq_seg; | 2268 | td->start_seg = ep_ring->enq_seg; |
1866 | (*td)->first_trb = ep_ring->enqueue; | 2269 | td->first_trb = ep_ring->enqueue; |
2270 | |||
2271 | urb_priv->td[td_index] = td; | ||
1867 | 2272 | ||
1868 | return 0; | 2273 | return 0; |
1869 | } | 2274 | } |
@@ -2002,6 +2407,7 @@ static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
2002 | { | 2407 | { |
2003 | struct xhci_ring *ep_ring; | 2408 | struct xhci_ring *ep_ring; |
2004 | unsigned int num_trbs; | 2409 | unsigned int num_trbs; |
2410 | struct urb_priv *urb_priv; | ||
2005 | struct xhci_td *td; | 2411 | struct xhci_td *td; |
2006 | struct scatterlist *sg; | 2412 | struct scatterlist *sg; |
2007 | int num_sgs; | 2413 | int num_sgs; |
@@ -2022,9 +2428,13 @@ static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
2022 | 2428 | ||
2023 | trb_buff_len = prepare_transfer(xhci, xhci->devs[slot_id], | 2429 | trb_buff_len = prepare_transfer(xhci, xhci->devs[slot_id], |
2024 | ep_index, urb->stream_id, | 2430 | ep_index, urb->stream_id, |
2025 | num_trbs, urb, &td, mem_flags); | 2431 | num_trbs, urb, 0, mem_flags); |
2026 | if (trb_buff_len < 0) | 2432 | if (trb_buff_len < 0) |
2027 | return trb_buff_len; | 2433 | return trb_buff_len; |
2434 | |||
2435 | urb_priv = urb->hcpriv; | ||
2436 | td = urb_priv->td[0]; | ||
2437 | |||
2028 | /* | 2438 | /* |
2029 | * Don't give the first TRB to the hardware (by toggling the cycle bit) | 2439 | * Don't give the first TRB to the hardware (by toggling the cycle bit) |
2030 | * until we've finished creating all the other TRBs. The ring's cycle | 2440 | * until we've finished creating all the other TRBs. The ring's cycle |
@@ -2145,6 +2555,7 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
2145 | struct urb *urb, int slot_id, unsigned int ep_index) | 2555 | struct urb *urb, int slot_id, unsigned int ep_index) |
2146 | { | 2556 | { |
2147 | struct xhci_ring *ep_ring; | 2557 | struct xhci_ring *ep_ring; |
2558 | struct urb_priv *urb_priv; | ||
2148 | struct xhci_td *td; | 2559 | struct xhci_td *td; |
2149 | int num_trbs; | 2560 | int num_trbs; |
2150 | struct xhci_generic_trb *start_trb; | 2561 | struct xhci_generic_trb *start_trb; |
@@ -2190,10 +2601,13 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
2190 | 2601 | ||
2191 | ret = prepare_transfer(xhci, xhci->devs[slot_id], | 2602 | ret = prepare_transfer(xhci, xhci->devs[slot_id], |
2192 | ep_index, urb->stream_id, | 2603 | ep_index, urb->stream_id, |
2193 | num_trbs, urb, &td, mem_flags); | 2604 | num_trbs, urb, 0, mem_flags); |
2194 | if (ret < 0) | 2605 | if (ret < 0) |
2195 | return ret; | 2606 | return ret; |
2196 | 2607 | ||
2608 | urb_priv = urb->hcpriv; | ||
2609 | td = urb_priv->td[0]; | ||
2610 | |||
2197 | /* | 2611 | /* |
2198 | * Don't give the first TRB to the hardware (by toggling the cycle bit) | 2612 | * Don't give the first TRB to the hardware (by toggling the cycle bit) |
2199 | * until we've finished creating all the other TRBs. The ring's cycle | 2613 | * until we've finished creating all the other TRBs. The ring's cycle |
@@ -2279,6 +2693,7 @@ int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
2279 | struct xhci_generic_trb *start_trb; | 2693 | struct xhci_generic_trb *start_trb; |
2280 | int start_cycle; | 2694 | int start_cycle; |
2281 | u32 field, length_field; | 2695 | u32 field, length_field; |
2696 | struct urb_priv *urb_priv; | ||
2282 | struct xhci_td *td; | 2697 | struct xhci_td *td; |
2283 | 2698 | ||
2284 | ep_ring = xhci_urb_to_transfer_ring(xhci, urb); | 2699 | ep_ring = xhci_urb_to_transfer_ring(xhci, urb); |
@@ -2306,10 +2721,13 @@ int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
2306 | num_trbs++; | 2721 | num_trbs++; |
2307 | ret = prepare_transfer(xhci, xhci->devs[slot_id], | 2722 | ret = prepare_transfer(xhci, xhci->devs[slot_id], |
2308 | ep_index, urb->stream_id, | 2723 | ep_index, urb->stream_id, |
2309 | num_trbs, urb, &td, mem_flags); | 2724 | num_trbs, urb, 0, mem_flags); |
2310 | if (ret < 0) | 2725 | if (ret < 0) |
2311 | return ret; | 2726 | return ret; |
2312 | 2727 | ||
2728 | urb_priv = urb->hcpriv; | ||
2729 | td = urb_priv->td[0]; | ||
2730 | |||
2313 | /* | 2731 | /* |
2314 | * Don't give the first TRB to the hardware (by toggling the cycle bit) | 2732 | * Don't give the first TRB to the hardware (by toggling the cycle bit) |
2315 | * until we've finished creating all the other TRBs. The ring's cycle | 2733 | * until we've finished creating all the other TRBs. The ring's cycle |
@@ -2366,6 +2784,224 @@ int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
2366 | return 0; | 2784 | return 0; |
2367 | } | 2785 | } |
2368 | 2786 | ||
2787 | static int count_isoc_trbs_needed(struct xhci_hcd *xhci, | ||
2788 | struct urb *urb, int i) | ||
2789 | { | ||
2790 | int num_trbs = 0; | ||
2791 | u64 addr, td_len, running_total; | ||
2792 | |||
2793 | addr = (u64) (urb->transfer_dma + urb->iso_frame_desc[i].offset); | ||
2794 | td_len = urb->iso_frame_desc[i].length; | ||
2795 | |||
2796 | running_total = TRB_MAX_BUFF_SIZE - | ||
2797 | (addr & ((1 << TRB_MAX_BUFF_SHIFT) - 1)); | ||
2798 | if (running_total != 0) | ||
2799 | num_trbs++; | ||
2800 | |||
2801 | while (running_total < td_len) { | ||
2802 | num_trbs++; | ||
2803 | running_total += TRB_MAX_BUFF_SIZE; | ||
2804 | } | ||
2805 | |||
2806 | return num_trbs; | ||
2807 | } | ||
2808 | |||
2809 | /* This is for isoc transfer */ | ||
2810 | static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | ||
2811 | struct urb *urb, int slot_id, unsigned int ep_index) | ||
2812 | { | ||
2813 | struct xhci_ring *ep_ring; | ||
2814 | struct urb_priv *urb_priv; | ||
2815 | struct xhci_td *td; | ||
2816 | int num_tds, trbs_per_td; | ||
2817 | struct xhci_generic_trb *start_trb; | ||
2818 | bool first_trb; | ||
2819 | int start_cycle; | ||
2820 | u32 field, length_field; | ||
2821 | int running_total, trb_buff_len, td_len, td_remain_len, ret; | ||
2822 | u64 start_addr, addr; | ||
2823 | int i, j; | ||
2824 | |||
2825 | ep_ring = xhci->devs[slot_id]->eps[ep_index].ring; | ||
2826 | |||
2827 | num_tds = urb->number_of_packets; | ||
2828 | if (num_tds < 1) { | ||
2829 | xhci_dbg(xhci, "Isoc URB with zero packets?\n"); | ||
2830 | return -EINVAL; | ||
2831 | } | ||
2832 | |||
2833 | if (!in_interrupt()) | ||
2834 | dev_dbg(&urb->dev->dev, "ep %#x - urb len = %#x (%d)," | ||
2835 | " addr = %#llx, num_tds = %d\n", | ||
2836 | urb->ep->desc.bEndpointAddress, | ||
2837 | urb->transfer_buffer_length, | ||
2838 | urb->transfer_buffer_length, | ||
2839 | (unsigned long long)urb->transfer_dma, | ||
2840 | num_tds); | ||
2841 | |||
2842 | start_addr = (u64) urb->transfer_dma; | ||
2843 | start_trb = &ep_ring->enqueue->generic; | ||
2844 | start_cycle = ep_ring->cycle_state; | ||
2845 | |||
2846 | /* Queue the first TRB, even if it's zero-length */ | ||
2847 | for (i = 0; i < num_tds; i++) { | ||
2848 | first_trb = true; | ||
2849 | |||
2850 | running_total = 0; | ||
2851 | addr = start_addr + urb->iso_frame_desc[i].offset; | ||
2852 | td_len = urb->iso_frame_desc[i].length; | ||
2853 | td_remain_len = td_len; | ||
2854 | |||
2855 | trbs_per_td = count_isoc_trbs_needed(xhci, urb, i); | ||
2856 | |||
2857 | ret = prepare_transfer(xhci, xhci->devs[slot_id], ep_index, | ||
2858 | urb->stream_id, trbs_per_td, urb, i, mem_flags); | ||
2859 | if (ret < 0) | ||
2860 | return ret; | ||
2861 | |||
2862 | urb_priv = urb->hcpriv; | ||
2863 | td = urb_priv->td[i]; | ||
2864 | |||
2865 | for (j = 0; j < trbs_per_td; j++) { | ||
2866 | u32 remainder = 0; | ||
2867 | field = 0; | ||
2868 | |||
2869 | if (first_trb) { | ||
2870 | /* Queue the isoc TRB */ | ||
2871 | field |= TRB_TYPE(TRB_ISOC); | ||
2872 | /* Assume URB_ISO_ASAP is set */ | ||
2873 | field |= TRB_SIA; | ||
2874 | if (i > 0) | ||
2875 | field |= ep_ring->cycle_state; | ||
2876 | first_trb = false; | ||
2877 | } else { | ||
2878 | /* Queue other normal TRBs */ | ||
2879 | field |= TRB_TYPE(TRB_NORMAL); | ||
2880 | field |= ep_ring->cycle_state; | ||
2881 | } | ||
2882 | |||
2883 | /* Chain all the TRBs together; clear the chain bit in | ||
2884 | * the last TRB to indicate it's the last TRB in the | ||
2885 | * chain. | ||
2886 | */ | ||
2887 | if (j < trbs_per_td - 1) { | ||
2888 | field |= TRB_CHAIN; | ||
2889 | } else { | ||
2890 | td->last_trb = ep_ring->enqueue; | ||
2891 | field |= TRB_IOC; | ||
2892 | } | ||
2893 | |||
2894 | /* Calculate TRB length */ | ||
2895 | trb_buff_len = TRB_MAX_BUFF_SIZE - | ||
2896 | (addr & ((1 << TRB_MAX_BUFF_SHIFT) - 1)); | ||
2897 | if (trb_buff_len > td_remain_len) | ||
2898 | trb_buff_len = td_remain_len; | ||
2899 | |||
2900 | remainder = xhci_td_remainder(td_len - running_total); | ||
2901 | length_field = TRB_LEN(trb_buff_len) | | ||
2902 | remainder | | ||
2903 | TRB_INTR_TARGET(0); | ||
2904 | queue_trb(xhci, ep_ring, false, false, | ||
2905 | lower_32_bits(addr), | ||
2906 | upper_32_bits(addr), | ||
2907 | length_field, | ||
2908 | /* We always want to know if the TRB was short, | ||
2909 | * or we won't get an event when it completes. | ||
2910 | * (Unless we use event data TRBs, which are a | ||
2911 | * waste of space and HC resources.) | ||
2912 | */ | ||
2913 | field | TRB_ISP); | ||
2914 | running_total += trb_buff_len; | ||
2915 | |||
2916 | addr += trb_buff_len; | ||
2917 | td_remain_len -= trb_buff_len; | ||
2918 | } | ||
2919 | |||
2920 | /* Check TD length */ | ||
2921 | if (running_total != td_len) { | ||
2922 | xhci_err(xhci, "ISOC TD length unmatch\n"); | ||
2923 | return -EINVAL; | ||
2924 | } | ||
2925 | } | ||
2926 | |||
2927 | wmb(); | ||
2928 | start_trb->field[3] |= start_cycle; | ||
2929 | |||
2930 | ring_ep_doorbell(xhci, slot_id, ep_index, urb->stream_id); | ||
2931 | return 0; | ||
2932 | } | ||
2933 | |||
2934 | /* | ||
2935 | * Check transfer ring to guarantee there is enough room for the urb. | ||
2936 | * Update ISO URB start_frame and interval. | ||
2937 | * Update interval as xhci_queue_intr_tx does. Just use xhci frame_index to | ||
2938 | * update the urb->start_frame by now. | ||
2939 | * Always assume URB_ISO_ASAP set, and NEVER use urb->start_frame as input. | ||
2940 | */ | ||
2941 | int xhci_queue_isoc_tx_prepare(struct xhci_hcd *xhci, gfp_t mem_flags, | ||
2942 | struct urb *urb, int slot_id, unsigned int ep_index) | ||
2943 | { | ||
2944 | struct xhci_virt_device *xdev; | ||
2945 | struct xhci_ring *ep_ring; | ||
2946 | struct xhci_ep_ctx *ep_ctx; | ||
2947 | int start_frame; | ||
2948 | int xhci_interval; | ||
2949 | int ep_interval; | ||
2950 | int num_tds, num_trbs, i; | ||
2951 | int ret; | ||
2952 | |||
2953 | xdev = xhci->devs[slot_id]; | ||
2954 | ep_ring = xdev->eps[ep_index].ring; | ||
2955 | ep_ctx = xhci_get_ep_ctx(xhci, xdev->out_ctx, ep_index); | ||
2956 | |||
2957 | num_trbs = 0; | ||
2958 | num_tds = urb->number_of_packets; | ||
2959 | for (i = 0; i < num_tds; i++) | ||
2960 | num_trbs += count_isoc_trbs_needed(xhci, urb, i); | ||
2961 | |||
2962 | /* Check the ring to guarantee there is enough room for the whole urb. | ||
2963 | * Do not insert any td of the urb to the ring if the check failed. | ||
2964 | */ | ||
2965 | ret = prepare_ring(xhci, ep_ring, ep_ctx->ep_info & EP_STATE_MASK, | ||
2966 | num_trbs, mem_flags); | ||
2967 | if (ret) | ||
2968 | return ret; | ||
2969 | |||
2970 | start_frame = xhci_readl(xhci, &xhci->run_regs->microframe_index); | ||
2971 | start_frame &= 0x3fff; | ||
2972 | |||
2973 | urb->start_frame = start_frame; | ||
2974 | if (urb->dev->speed == USB_SPEED_LOW || | ||
2975 | urb->dev->speed == USB_SPEED_FULL) | ||
2976 | urb->start_frame >>= 3; | ||
2977 | |||
2978 | xhci_interval = EP_INTERVAL_TO_UFRAMES(ep_ctx->ep_info); | ||
2979 | ep_interval = urb->interval; | ||
2980 | /* Convert to microframes */ | ||
2981 | if (urb->dev->speed == USB_SPEED_LOW || | ||
2982 | urb->dev->speed == USB_SPEED_FULL) | ||
2983 | ep_interval *= 8; | ||
2984 | /* FIXME change this to a warning and a suggestion to use the new API | ||
2985 | * to set the polling interval (once the API is added). | ||
2986 | */ | ||
2987 | if (xhci_interval != ep_interval) { | ||
2988 | if (!printk_ratelimit()) | ||
2989 | dev_dbg(&urb->dev->dev, "Driver uses different interval" | ||
2990 | " (%d microframe%s) than xHCI " | ||
2991 | "(%d microframe%s)\n", | ||
2992 | ep_interval, | ||
2993 | ep_interval == 1 ? "" : "s", | ||
2994 | xhci_interval, | ||
2995 | xhci_interval == 1 ? "" : "s"); | ||
2996 | urb->interval = xhci_interval; | ||
2997 | /* Convert back to frames for LS/FS devices */ | ||
2998 | if (urb->dev->speed == USB_SPEED_LOW || | ||
2999 | urb->dev->speed == USB_SPEED_FULL) | ||
3000 | urb->interval /= 8; | ||
3001 | } | ||
3002 | return xhci_queue_isoc_tx(xhci, GFP_ATOMIC, urb, slot_id, ep_index); | ||
3003 | } | ||
3004 | |||
2369 | /**** Command Ring Operations ****/ | 3005 | /**** Command Ring Operations ****/ |
2370 | 3006 | ||
2371 | /* Generic function for queueing a command TRB on the command ring. | 3007 | /* Generic function for queueing a command TRB on the command ring. |
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 3998f72cd0c4..d5c550ea3e68 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c | |||
@@ -20,6 +20,7 @@ | |||
20 | * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 20 | * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
21 | */ | 21 | */ |
22 | 22 | ||
23 | #include <linux/pci.h> | ||
23 | #include <linux/irq.h> | 24 | #include <linux/irq.h> |
24 | #include <linux/log2.h> | 25 | #include <linux/log2.h> |
25 | #include <linux/module.h> | 26 | #include <linux/module.h> |
@@ -171,22 +172,84 @@ int xhci_reset(struct xhci_hcd *xhci) | |||
171 | return handshake(xhci, &xhci->op_regs->status, STS_CNR, 0, 250 * 1000); | 172 | return handshake(xhci, &xhci->op_regs->status, STS_CNR, 0, 250 * 1000); |
172 | } | 173 | } |
173 | 174 | ||
175 | /* | ||
176 | * Free IRQs | ||
177 | * free all IRQs request | ||
178 | */ | ||
179 | static void xhci_free_irq(struct xhci_hcd *xhci) | ||
180 | { | ||
181 | int i; | ||
182 | struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller); | ||
174 | 183 | ||
175 | #if 0 | 184 | /* return if using legacy interrupt */ |
176 | /* Set up MSI-X table for entry 0 (may claim other entries later) */ | 185 | if (xhci_to_hcd(xhci)->irq >= 0) |
177 | static int xhci_setup_msix(struct xhci_hcd *xhci) | 186 | return; |
187 | |||
188 | if (xhci->msix_entries) { | ||
189 | for (i = 0; i < xhci->msix_count; i++) | ||
190 | if (xhci->msix_entries[i].vector) | ||
191 | free_irq(xhci->msix_entries[i].vector, | ||
192 | xhci_to_hcd(xhci)); | ||
193 | } else if (pdev->irq >= 0) | ||
194 | free_irq(pdev->irq, xhci_to_hcd(xhci)); | ||
195 | |||
196 | return; | ||
197 | } | ||
198 | |||
199 | /* | ||
200 | * Set up MSI | ||
201 | */ | ||
202 | static int xhci_setup_msi(struct xhci_hcd *xhci) | ||
178 | { | 203 | { |
179 | int ret; | 204 | int ret; |
205 | struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller); | ||
206 | |||
207 | ret = pci_enable_msi(pdev); | ||
208 | if (ret) { | ||
209 | xhci_err(xhci, "failed to allocate MSI entry\n"); | ||
210 | return ret; | ||
211 | } | ||
212 | |||
213 | ret = request_irq(pdev->irq, (irq_handler_t)xhci_msi_irq, | ||
214 | 0, "xhci_hcd", xhci_to_hcd(xhci)); | ||
215 | if (ret) { | ||
216 | xhci_err(xhci, "disable MSI interrupt\n"); | ||
217 | pci_disable_msi(pdev); | ||
218 | } | ||
219 | |||
220 | return ret; | ||
221 | } | ||
222 | |||
223 | /* | ||
224 | * Set up MSI-X | ||
225 | */ | ||
226 | static int xhci_setup_msix(struct xhci_hcd *xhci) | ||
227 | { | ||
228 | int i, ret = 0; | ||
180 | struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller); | 229 | struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller); |
181 | 230 | ||
182 | xhci->msix_count = 0; | 231 | /* |
183 | /* XXX: did I do this right? ixgbe does kcalloc for more than one */ | 232 | * calculate number of msi-x vectors supported. |
184 | xhci->msix_entries = kmalloc(sizeof(struct msix_entry), GFP_KERNEL); | 233 | * - HCS_MAX_INTRS: the max number of interrupts the host can handle, |
234 | * with max number of interrupters based on the xhci HCSPARAMS1. | ||
235 | * - num_online_cpus: maximum msi-x vectors per CPUs core. | ||
236 | * Add additional 1 vector to ensure always available interrupt. | ||
237 | */ | ||
238 | xhci->msix_count = min(num_online_cpus() + 1, | ||
239 | HCS_MAX_INTRS(xhci->hcs_params1)); | ||
240 | |||
241 | xhci->msix_entries = | ||
242 | kmalloc((sizeof(struct msix_entry))*xhci->msix_count, | ||
243 | GFP_KERNEL); | ||
185 | if (!xhci->msix_entries) { | 244 | if (!xhci->msix_entries) { |
186 | xhci_err(xhci, "Failed to allocate MSI-X entries\n"); | 245 | xhci_err(xhci, "Failed to allocate MSI-X entries\n"); |
187 | return -ENOMEM; | 246 | return -ENOMEM; |
188 | } | 247 | } |
189 | xhci->msix_entries[0].entry = 0; | 248 | |
249 | for (i = 0; i < xhci->msix_count; i++) { | ||
250 | xhci->msix_entries[i].entry = i; | ||
251 | xhci->msix_entries[i].vector = 0; | ||
252 | } | ||
190 | 253 | ||
191 | ret = pci_enable_msix(pdev, xhci->msix_entries, xhci->msix_count); | 254 | ret = pci_enable_msix(pdev, xhci->msix_entries, xhci->msix_count); |
192 | if (ret) { | 255 | if (ret) { |
@@ -194,20 +257,19 @@ static int xhci_setup_msix(struct xhci_hcd *xhci) | |||
194 | goto free_entries; | 257 | goto free_entries; |
195 | } | 258 | } |
196 | 259 | ||
197 | /* | 260 | for (i = 0; i < xhci->msix_count; i++) { |
198 | * Pass the xhci pointer value as the request_irq "cookie". | 261 | ret = request_irq(xhci->msix_entries[i].vector, |
199 | * If more irqs are added, this will need to be unique for each one. | 262 | (irq_handler_t)xhci_msi_irq, |
200 | */ | 263 | 0, "xhci_hcd", xhci_to_hcd(xhci)); |
201 | ret = request_irq(xhci->msix_entries[0].vector, &xhci_irq, 0, | 264 | if (ret) |
202 | "xHCI", xhci_to_hcd(xhci)); | 265 | goto disable_msix; |
203 | if (ret) { | ||
204 | xhci_err(xhci, "Failed to allocate MSI-X interrupt\n"); | ||
205 | goto disable_msix; | ||
206 | } | 266 | } |
207 | xhci_dbg(xhci, "Finished setting up MSI-X\n"); | 267 | |
208 | return 0; | 268 | return ret; |
209 | 269 | ||
210 | disable_msix: | 270 | disable_msix: |
271 | xhci_err(xhci, "disable MSI-X interrupt\n"); | ||
272 | xhci_free_irq(xhci); | ||
211 | pci_disable_msix(pdev); | 273 | pci_disable_msix(pdev); |
212 | free_entries: | 274 | free_entries: |
213 | kfree(xhci->msix_entries); | 275 | kfree(xhci->msix_entries); |
@@ -215,21 +277,23 @@ free_entries: | |||
215 | return ret; | 277 | return ret; |
216 | } | 278 | } |
217 | 279 | ||
218 | /* XXX: code duplication; can xhci_setup_msix call this? */ | ||
219 | /* Free any IRQs and disable MSI-X */ | 280 | /* Free any IRQs and disable MSI-X */ |
220 | static void xhci_cleanup_msix(struct xhci_hcd *xhci) | 281 | static void xhci_cleanup_msix(struct xhci_hcd *xhci) |
221 | { | 282 | { |
222 | struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller); | 283 | struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller); |
223 | if (!xhci->msix_entries) | ||
224 | return; | ||
225 | 284 | ||
226 | free_irq(xhci->msix_entries[0].vector, xhci); | 285 | xhci_free_irq(xhci); |
227 | pci_disable_msix(pdev); | 286 | |
228 | kfree(xhci->msix_entries); | 287 | if (xhci->msix_entries) { |
229 | xhci->msix_entries = NULL; | 288 | pci_disable_msix(pdev); |
230 | xhci_dbg(xhci, "Finished cleaning up MSI-X\n"); | 289 | kfree(xhci->msix_entries); |
290 | xhci->msix_entries = NULL; | ||
291 | } else { | ||
292 | pci_disable_msi(pdev); | ||
293 | } | ||
294 | |||
295 | return; | ||
231 | } | 296 | } |
232 | #endif | ||
233 | 297 | ||
234 | /* | 298 | /* |
235 | * Initialize memory for HCD and xHC (one-time init). | 299 | * Initialize memory for HCD and xHC (one-time init). |
@@ -257,100 +321,8 @@ int xhci_init(struct usb_hcd *hcd) | |||
257 | return retval; | 321 | return retval; |
258 | } | 322 | } |
259 | 323 | ||
260 | /* | ||
261 | * Called in interrupt context when there might be work | ||
262 | * queued on the event ring | ||
263 | * | ||
264 | * xhci->lock must be held by caller. | ||
265 | */ | ||
266 | static void xhci_work(struct xhci_hcd *xhci) | ||
267 | { | ||
268 | u32 temp; | ||
269 | u64 temp_64; | ||
270 | |||
271 | /* | ||
272 | * Clear the op reg interrupt status first, | ||
273 | * so we can receive interrupts from other MSI-X interrupters. | ||
274 | * Write 1 to clear the interrupt status. | ||
275 | */ | ||
276 | temp = xhci_readl(xhci, &xhci->op_regs->status); | ||
277 | temp |= STS_EINT; | ||
278 | xhci_writel(xhci, temp, &xhci->op_regs->status); | ||
279 | /* FIXME when MSI-X is supported and there are multiple vectors */ | ||
280 | /* Clear the MSI-X event interrupt status */ | ||
281 | |||
282 | /* Acknowledge the interrupt */ | ||
283 | temp = xhci_readl(xhci, &xhci->ir_set->irq_pending); | ||
284 | temp |= 0x3; | ||
285 | xhci_writel(xhci, temp, &xhci->ir_set->irq_pending); | ||
286 | /* Flush posted writes */ | ||
287 | xhci_readl(xhci, &xhci->ir_set->irq_pending); | ||
288 | |||
289 | if (xhci->xhc_state & XHCI_STATE_DYING) | ||
290 | xhci_dbg(xhci, "xHCI dying, ignoring interrupt. " | ||
291 | "Shouldn't IRQs be disabled?\n"); | ||
292 | else | ||
293 | /* FIXME this should be a delayed service routine | ||
294 | * that clears the EHB. | ||
295 | */ | ||
296 | xhci_handle_event(xhci); | ||
297 | |||
298 | /* Clear the event handler busy flag (RW1C); the event ring should be empty. */ | ||
299 | temp_64 = xhci_read_64(xhci, &xhci->ir_set->erst_dequeue); | ||
300 | xhci_write_64(xhci, temp_64 | ERST_EHB, &xhci->ir_set->erst_dequeue); | ||
301 | /* Flush posted writes -- FIXME is this necessary? */ | ||
302 | xhci_readl(xhci, &xhci->ir_set->irq_pending); | ||
303 | } | ||
304 | |||
305 | /*-------------------------------------------------------------------------*/ | 324 | /*-------------------------------------------------------------------------*/ |
306 | 325 | ||
307 | /* | ||
308 | * xHCI spec says we can get an interrupt, and if the HC has an error condition, | ||
309 | * we might get bad data out of the event ring. Section 4.10.2.7 has a list of | ||
310 | * indicators of an event TRB error, but we check the status *first* to be safe. | ||
311 | */ | ||
312 | irqreturn_t xhci_irq(struct usb_hcd *hcd) | ||
313 | { | ||
314 | struct xhci_hcd *xhci = hcd_to_xhci(hcd); | ||
315 | u32 temp, temp2; | ||
316 | union xhci_trb *trb; | ||
317 | |||
318 | spin_lock(&xhci->lock); | ||
319 | trb = xhci->event_ring->dequeue; | ||
320 | /* Check if the xHC generated the interrupt, or the irq is shared */ | ||
321 | temp = xhci_readl(xhci, &xhci->op_regs->status); | ||
322 | temp2 = xhci_readl(xhci, &xhci->ir_set->irq_pending); | ||
323 | if (temp == 0xffffffff && temp2 == 0xffffffff) | ||
324 | goto hw_died; | ||
325 | |||
326 | if (!(temp & STS_EINT) && !ER_IRQ_PENDING(temp2)) { | ||
327 | spin_unlock(&xhci->lock); | ||
328 | return IRQ_NONE; | ||
329 | } | ||
330 | xhci_dbg(xhci, "op reg status = %08x\n", temp); | ||
331 | xhci_dbg(xhci, "ir set irq_pending = %08x\n", temp2); | ||
332 | xhci_dbg(xhci, "Event ring dequeue ptr:\n"); | ||
333 | xhci_dbg(xhci, "@%llx %08x %08x %08x %08x\n", | ||
334 | (unsigned long long)xhci_trb_virt_to_dma(xhci->event_ring->deq_seg, trb), | ||
335 | lower_32_bits(trb->link.segment_ptr), | ||
336 | upper_32_bits(trb->link.segment_ptr), | ||
337 | (unsigned int) trb->link.intr_target, | ||
338 | (unsigned int) trb->link.control); | ||
339 | |||
340 | if (temp & STS_FATAL) { | ||
341 | xhci_warn(xhci, "WARNING: Host System Error\n"); | ||
342 | xhci_halt(xhci); | ||
343 | hw_died: | ||
344 | xhci_to_hcd(xhci)->state = HC_STATE_HALT; | ||
345 | spin_unlock(&xhci->lock); | ||
346 | return -ESHUTDOWN; | ||
347 | } | ||
348 | |||
349 | xhci_work(xhci); | ||
350 | spin_unlock(&xhci->lock); | ||
351 | |||
352 | return IRQ_HANDLED; | ||
353 | } | ||
354 | 326 | ||
355 | #ifdef CONFIG_USB_XHCI_HCD_DEBUGGING | 327 | #ifdef CONFIG_USB_XHCI_HCD_DEBUGGING |
356 | void xhci_event_ring_work(unsigned long arg) | 328 | void xhci_event_ring_work(unsigned long arg) |
@@ -423,21 +395,36 @@ int xhci_run(struct usb_hcd *hcd) | |||
423 | { | 395 | { |
424 | u32 temp; | 396 | u32 temp; |
425 | u64 temp_64; | 397 | u64 temp_64; |
398 | u32 ret; | ||
426 | struct xhci_hcd *xhci = hcd_to_xhci(hcd); | 399 | struct xhci_hcd *xhci = hcd_to_xhci(hcd); |
400 | struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller); | ||
427 | void (*doorbell)(struct xhci_hcd *) = NULL; | 401 | void (*doorbell)(struct xhci_hcd *) = NULL; |
428 | 402 | ||
429 | hcd->uses_new_polling = 1; | 403 | hcd->uses_new_polling = 1; |
430 | hcd->poll_rh = 0; | ||
431 | 404 | ||
432 | xhci_dbg(xhci, "xhci_run\n"); | 405 | xhci_dbg(xhci, "xhci_run\n"); |
433 | #if 0 /* FIXME: MSI not setup yet */ | 406 | /* unregister the legacy interrupt */ |
434 | /* Do this at the very last minute */ | 407 | if (hcd->irq) |
408 | free_irq(hcd->irq, hcd); | ||
409 | hcd->irq = -1; | ||
410 | |||
435 | ret = xhci_setup_msix(xhci); | 411 | ret = xhci_setup_msix(xhci); |
436 | if (!ret) | 412 | if (ret) |
437 | return ret; | 413 | /* fall back to msi*/ |
414 | ret = xhci_setup_msi(xhci); | ||
415 | |||
416 | if (ret) { | ||
417 | /* fall back to legacy interrupt*/ | ||
418 | ret = request_irq(pdev->irq, &usb_hcd_irq, IRQF_SHARED, | ||
419 | hcd->irq_descr, hcd); | ||
420 | if (ret) { | ||
421 | xhci_err(xhci, "request interrupt %d failed\n", | ||
422 | pdev->irq); | ||
423 | return ret; | ||
424 | } | ||
425 | hcd->irq = pdev->irq; | ||
426 | } | ||
438 | 427 | ||
439 | return -ENOSYS; | ||
440 | #endif | ||
441 | #ifdef CONFIG_USB_XHCI_HCD_DEBUGGING | 428 | #ifdef CONFIG_USB_XHCI_HCD_DEBUGGING |
442 | init_timer(&xhci->event_ring_timer); | 429 | init_timer(&xhci->event_ring_timer); |
443 | xhci->event_ring_timer.data = (unsigned long) xhci; | 430 | xhci->event_ring_timer.data = (unsigned long) xhci; |
@@ -495,7 +482,6 @@ int xhci_run(struct usb_hcd *hcd) | |||
495 | return -ENODEV; | 482 | return -ENODEV; |
496 | } | 483 | } |
497 | 484 | ||
498 | xhci_dbg(xhci, "// @%p = 0x%x\n", &xhci->op_regs->command, temp); | ||
499 | if (doorbell) | 485 | if (doorbell) |
500 | (*doorbell)(xhci); | 486 | (*doorbell)(xhci); |
501 | if (xhci->quirks & XHCI_NEC_HOST) | 487 | if (xhci->quirks & XHCI_NEC_HOST) |
@@ -522,11 +508,9 @@ void xhci_stop(struct usb_hcd *hcd) | |||
522 | spin_lock_irq(&xhci->lock); | 508 | spin_lock_irq(&xhci->lock); |
523 | xhci_halt(xhci); | 509 | xhci_halt(xhci); |
524 | xhci_reset(xhci); | 510 | xhci_reset(xhci); |
511 | xhci_cleanup_msix(xhci); | ||
525 | spin_unlock_irq(&xhci->lock); | 512 | spin_unlock_irq(&xhci->lock); |
526 | 513 | ||
527 | #if 0 /* No MSI yet */ | ||
528 | xhci_cleanup_msix(xhci); | ||
529 | #endif | ||
530 | #ifdef CONFIG_USB_XHCI_HCD_DEBUGGING | 514 | #ifdef CONFIG_USB_XHCI_HCD_DEBUGGING |
531 | /* Tell the event ring poll function not to reschedule */ | 515 | /* Tell the event ring poll function not to reschedule */ |
532 | xhci->zombie = 1; | 516 | xhci->zombie = 1; |
@@ -560,11 +544,8 @@ void xhci_shutdown(struct usb_hcd *hcd) | |||
560 | 544 | ||
561 | spin_lock_irq(&xhci->lock); | 545 | spin_lock_irq(&xhci->lock); |
562 | xhci_halt(xhci); | 546 | xhci_halt(xhci); |
563 | spin_unlock_irq(&xhci->lock); | ||
564 | |||
565 | #if 0 | ||
566 | xhci_cleanup_msix(xhci); | 547 | xhci_cleanup_msix(xhci); |
567 | #endif | 548 | spin_unlock_irq(&xhci->lock); |
568 | 549 | ||
569 | xhci_dbg(xhci, "xhci_shutdown completed - status = %x\n", | 550 | xhci_dbg(xhci, "xhci_shutdown completed - status = %x\n", |
570 | xhci_readl(xhci, &xhci->op_regs->status)); | 551 | xhci_readl(xhci, &xhci->op_regs->status)); |
@@ -720,7 +701,8 @@ int xhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flags) | |||
720 | unsigned long flags; | 701 | unsigned long flags; |
721 | int ret = 0; | 702 | int ret = 0; |
722 | unsigned int slot_id, ep_index; | 703 | unsigned int slot_id, ep_index; |
723 | 704 | struct urb_priv *urb_priv; | |
705 | int size, i; | ||
724 | 706 | ||
725 | if (!urb || xhci_check_args(hcd, urb->dev, urb->ep, true, __func__) <= 0) | 707 | if (!urb || xhci_check_args(hcd, urb->dev, urb->ep, true, __func__) <= 0) |
726 | return -EINVAL; | 708 | return -EINVAL; |
@@ -734,12 +716,36 @@ int xhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flags) | |||
734 | ret = -EINVAL; | 716 | ret = -EINVAL; |
735 | goto exit; | 717 | goto exit; |
736 | } | 718 | } |
737 | if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) { | 719 | if (!HCD_HW_ACCESSIBLE(hcd)) { |
738 | if (!in_interrupt()) | 720 | if (!in_interrupt()) |
739 | xhci_dbg(xhci, "urb submitted during PCI suspend\n"); | 721 | xhci_dbg(xhci, "urb submitted during PCI suspend\n"); |
740 | ret = -ESHUTDOWN; | 722 | ret = -ESHUTDOWN; |
741 | goto exit; | 723 | goto exit; |
742 | } | 724 | } |
725 | |||
726 | if (usb_endpoint_xfer_isoc(&urb->ep->desc)) | ||
727 | size = urb->number_of_packets; | ||
728 | else | ||
729 | size = 1; | ||
730 | |||
731 | urb_priv = kzalloc(sizeof(struct urb_priv) + | ||
732 | size * sizeof(struct xhci_td *), mem_flags); | ||
733 | if (!urb_priv) | ||
734 | return -ENOMEM; | ||
735 | |||
736 | for (i = 0; i < size; i++) { | ||
737 | urb_priv->td[i] = kzalloc(sizeof(struct xhci_td), mem_flags); | ||
738 | if (!urb_priv->td[i]) { | ||
739 | urb_priv->length = i; | ||
740 | xhci_urb_free_priv(xhci, urb_priv); | ||
741 | return -ENOMEM; | ||
742 | } | ||
743 | } | ||
744 | |||
745 | urb_priv->length = size; | ||
746 | urb_priv->td_cnt = 0; | ||
747 | urb->hcpriv = urb_priv; | ||
748 | |||
743 | if (usb_endpoint_xfer_control(&urb->ep->desc)) { | 749 | if (usb_endpoint_xfer_control(&urb->ep->desc)) { |
744 | /* Check to see if the max packet size for the default control | 750 | /* Check to see if the max packet size for the default control |
745 | * endpoint changed during FS device enumeration | 751 | * endpoint changed during FS device enumeration |
@@ -788,11 +794,18 @@ int xhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flags) | |||
788 | slot_id, ep_index); | 794 | slot_id, ep_index); |
789 | spin_unlock_irqrestore(&xhci->lock, flags); | 795 | spin_unlock_irqrestore(&xhci->lock, flags); |
790 | } else { | 796 | } else { |
791 | ret = -EINVAL; | 797 | spin_lock_irqsave(&xhci->lock, flags); |
798 | if (xhci->xhc_state & XHCI_STATE_DYING) | ||
799 | goto dying; | ||
800 | ret = xhci_queue_isoc_tx_prepare(xhci, GFP_ATOMIC, urb, | ||
801 | slot_id, ep_index); | ||
802 | spin_unlock_irqrestore(&xhci->lock, flags); | ||
792 | } | 803 | } |
793 | exit: | 804 | exit: |
794 | return ret; | 805 | return ret; |
795 | dying: | 806 | dying: |
807 | xhci_urb_free_priv(xhci, urb_priv); | ||
808 | urb->hcpriv = NULL; | ||
796 | xhci_dbg(xhci, "Ep 0x%x: URB %p submitted for " | 809 | xhci_dbg(xhci, "Ep 0x%x: URB %p submitted for " |
797 | "non-responsive xHCI host.\n", | 810 | "non-responsive xHCI host.\n", |
798 | urb->ep->desc.bEndpointAddress, urb); | 811 | urb->ep->desc.bEndpointAddress, urb); |
@@ -800,6 +813,47 @@ dying: | |||
800 | return -ESHUTDOWN; | 813 | return -ESHUTDOWN; |
801 | } | 814 | } |
802 | 815 | ||
816 | /* Get the right ring for the given URB. | ||
817 | * If the endpoint supports streams, boundary check the URB's stream ID. | ||
818 | * If the endpoint doesn't support streams, return the singular endpoint ring. | ||
819 | */ | ||
820 | static struct xhci_ring *xhci_urb_to_transfer_ring(struct xhci_hcd *xhci, | ||
821 | struct urb *urb) | ||
822 | { | ||
823 | unsigned int slot_id; | ||
824 | unsigned int ep_index; | ||
825 | unsigned int stream_id; | ||
826 | struct xhci_virt_ep *ep; | ||
827 | |||
828 | slot_id = urb->dev->slot_id; | ||
829 | ep_index = xhci_get_endpoint_index(&urb->ep->desc); | ||
830 | stream_id = urb->stream_id; | ||
831 | ep = &xhci->devs[slot_id]->eps[ep_index]; | ||
832 | /* Common case: no streams */ | ||
833 | if (!(ep->ep_state & EP_HAS_STREAMS)) | ||
834 | return ep->ring; | ||
835 | |||
836 | if (stream_id == 0) { | ||
837 | xhci_warn(xhci, | ||
838 | "WARN: Slot ID %u, ep index %u has streams, " | ||
839 | "but URB has no stream ID.\n", | ||
840 | slot_id, ep_index); | ||
841 | return NULL; | ||
842 | } | ||
843 | |||
844 | if (stream_id < ep->stream_info->num_streams) | ||
845 | return ep->stream_info->stream_rings[stream_id]; | ||
846 | |||
847 | xhci_warn(xhci, | ||
848 | "WARN: Slot ID %u, ep index %u has " | ||
849 | "stream IDs 1 to %u allocated, " | ||
850 | "but stream ID %u is requested.\n", | ||
851 | slot_id, ep_index, | ||
852 | ep->stream_info->num_streams - 1, | ||
853 | stream_id); | ||
854 | return NULL; | ||
855 | } | ||
856 | |||
803 | /* | 857 | /* |
804 | * Remove the URB's TD from the endpoint ring. This may cause the HC to stop | 858 | * Remove the URB's TD from the endpoint ring. This may cause the HC to stop |
805 | * USB transfers, potentially stopping in the middle of a TRB buffer. The HC | 859 | * USB transfers, potentially stopping in the middle of a TRB buffer. The HC |
@@ -834,9 +888,10 @@ dying: | |||
834 | int xhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) | 888 | int xhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) |
835 | { | 889 | { |
836 | unsigned long flags; | 890 | unsigned long flags; |
837 | int ret; | 891 | int ret, i; |
838 | u32 temp; | 892 | u32 temp; |
839 | struct xhci_hcd *xhci; | 893 | struct xhci_hcd *xhci; |
894 | struct urb_priv *urb_priv; | ||
840 | struct xhci_td *td; | 895 | struct xhci_td *td; |
841 | unsigned int ep_index; | 896 | unsigned int ep_index; |
842 | struct xhci_ring *ep_ring; | 897 | struct xhci_ring *ep_ring; |
@@ -851,12 +906,12 @@ int xhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) | |||
851 | temp = xhci_readl(xhci, &xhci->op_regs->status); | 906 | temp = xhci_readl(xhci, &xhci->op_regs->status); |
852 | if (temp == 0xffffffff) { | 907 | if (temp == 0xffffffff) { |
853 | xhci_dbg(xhci, "HW died, freeing TD.\n"); | 908 | xhci_dbg(xhci, "HW died, freeing TD.\n"); |
854 | td = (struct xhci_td *) urb->hcpriv; | 909 | urb_priv = urb->hcpriv; |
855 | 910 | ||
856 | usb_hcd_unlink_urb_from_ep(hcd, urb); | 911 | usb_hcd_unlink_urb_from_ep(hcd, urb); |
857 | spin_unlock_irqrestore(&xhci->lock, flags); | 912 | spin_unlock_irqrestore(&xhci->lock, flags); |
858 | usb_hcd_giveback_urb(xhci_to_hcd(xhci), urb, -ESHUTDOWN); | 913 | usb_hcd_giveback_urb(xhci_to_hcd(xhci), urb, -ESHUTDOWN); |
859 | kfree(td); | 914 | xhci_urb_free_priv(xhci, urb_priv); |
860 | return ret; | 915 | return ret; |
861 | } | 916 | } |
862 | if (xhci->xhc_state & XHCI_STATE_DYING) { | 917 | if (xhci->xhc_state & XHCI_STATE_DYING) { |
@@ -884,9 +939,14 @@ int xhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) | |||
884 | 939 | ||
885 | xhci_dbg(xhci, "Endpoint ring:\n"); | 940 | xhci_dbg(xhci, "Endpoint ring:\n"); |
886 | xhci_debug_ring(xhci, ep_ring); | 941 | xhci_debug_ring(xhci, ep_ring); |
887 | td = (struct xhci_td *) urb->hcpriv; | ||
888 | 942 | ||
889 | list_add_tail(&td->cancelled_td_list, &ep->cancelled_td_list); | 943 | urb_priv = urb->hcpriv; |
944 | |||
945 | for (i = urb_priv->td_cnt; i < urb_priv->length; i++) { | ||
946 | td = urb_priv->td[i]; | ||
947 | list_add_tail(&td->cancelled_td_list, &ep->cancelled_td_list); | ||
948 | } | ||
949 | |||
890 | /* Queue a stop endpoint command, but only if this is | 950 | /* Queue a stop endpoint command, but only if this is |
891 | * the first cancellation to be handled. | 951 | * the first cancellation to be handled. |
892 | */ | 952 | */ |
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 6c7e3430ec93..34a60d9f056a 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h | |||
@@ -720,6 +720,14 @@ struct xhci_virt_ep { | |||
720 | struct timer_list stop_cmd_timer; | 720 | struct timer_list stop_cmd_timer; |
721 | int stop_cmds_pending; | 721 | int stop_cmds_pending; |
722 | struct xhci_hcd *xhci; | 722 | struct xhci_hcd *xhci; |
723 | /* | ||
724 | * Sometimes the xHC can not process isochronous endpoint ring quickly | ||
725 | * enough, and it will miss some isoc tds on the ring and generate | ||
726 | * a Missed Service Error Event. | ||
727 | * Set skip flag when receive a Missed Service Error Event and | ||
728 | * process the missed tds on the endpoint ring. | ||
729 | */ | ||
730 | bool skip; | ||
723 | }; | 731 | }; |
724 | 732 | ||
725 | struct xhci_virt_device { | 733 | struct xhci_virt_device { |
@@ -911,6 +919,9 @@ struct xhci_event_cmd { | |||
911 | /* Control transfer TRB specific fields */ | 919 | /* Control transfer TRB specific fields */ |
912 | #define TRB_DIR_IN (1<<16) | 920 | #define TRB_DIR_IN (1<<16) |
913 | 921 | ||
922 | /* Isochronous TRB specific fields */ | ||
923 | #define TRB_SIA (1<<31) | ||
924 | |||
914 | struct xhci_generic_trb { | 925 | struct xhci_generic_trb { |
915 | u32 field[4]; | 926 | u32 field[4]; |
916 | }; | 927 | }; |
@@ -1082,6 +1093,12 @@ struct xhci_scratchpad { | |||
1082 | dma_addr_t *sp_dma_buffers; | 1093 | dma_addr_t *sp_dma_buffers; |
1083 | }; | 1094 | }; |
1084 | 1095 | ||
1096 | struct urb_priv { | ||
1097 | int length; | ||
1098 | int td_cnt; | ||
1099 | struct xhci_td *td[0]; | ||
1100 | }; | ||
1101 | |||
1085 | /* | 1102 | /* |
1086 | * Each segment table entry is 4*32bits long. 1K seems like an ok size: | 1103 | * Each segment table entry is 4*32bits long. 1K seems like an ok size: |
1087 | * (1K bytes * 8bytes/bit) / (4*32 bits) = 64 segment entries in the table, | 1104 | * (1K bytes * 8bytes/bit) / (4*32 bits) = 64 segment entries in the table, |
@@ -1130,7 +1147,7 @@ struct xhci_hcd { | |||
1130 | int page_size; | 1147 | int page_size; |
1131 | /* Valid values are 12 to 20, inclusive */ | 1148 | /* Valid values are 12 to 20, inclusive */ |
1132 | int page_shift; | 1149 | int page_shift; |
1133 | /* only one MSI vector for now, but might need more later */ | 1150 | /* msi-x vectors */ |
1134 | int msix_count; | 1151 | int msix_count; |
1135 | struct msix_entry *msix_entries; | 1152 | struct msix_entry *msix_entries; |
1136 | /* data structures */ | 1153 | /* data structures */ |
@@ -1327,11 +1344,6 @@ void xhci_setup_no_streams_ep_input_ctx(struct xhci_hcd *xhci, | |||
1327 | struct xhci_ring *xhci_dma_to_transfer_ring( | 1344 | struct xhci_ring *xhci_dma_to_transfer_ring( |
1328 | struct xhci_virt_ep *ep, | 1345 | struct xhci_virt_ep *ep, |
1329 | u64 address); | 1346 | u64 address); |
1330 | struct xhci_ring *xhci_urb_to_transfer_ring(struct xhci_hcd *xhci, | ||
1331 | struct urb *urb); | ||
1332 | struct xhci_ring *xhci_triad_to_transfer_ring(struct xhci_hcd *xhci, | ||
1333 | unsigned int slot_id, unsigned int ep_index, | ||
1334 | unsigned int stream_id); | ||
1335 | struct xhci_ring *xhci_stream_id_to_ring( | 1347 | struct xhci_ring *xhci_stream_id_to_ring( |
1336 | struct xhci_virt_device *dev, | 1348 | struct xhci_virt_device *dev, |
1337 | unsigned int ep_index, | 1349 | unsigned int ep_index, |
@@ -1339,6 +1351,7 @@ struct xhci_ring *xhci_stream_id_to_ring( | |||
1339 | struct xhci_command *xhci_alloc_command(struct xhci_hcd *xhci, | 1351 | struct xhci_command *xhci_alloc_command(struct xhci_hcd *xhci, |
1340 | bool allocate_in_ctx, bool allocate_completion, | 1352 | bool allocate_in_ctx, bool allocate_completion, |
1341 | gfp_t mem_flags); | 1353 | gfp_t mem_flags); |
1354 | void xhci_urb_free_priv(struct xhci_hcd *xhci, struct urb_priv *urb_priv); | ||
1342 | void xhci_free_command(struct xhci_hcd *xhci, | 1355 | void xhci_free_command(struct xhci_hcd *xhci, |
1343 | struct xhci_command *command); | 1356 | struct xhci_command *command); |
1344 | 1357 | ||
@@ -1358,6 +1371,7 @@ void xhci_stop(struct usb_hcd *hcd); | |||
1358 | void xhci_shutdown(struct usb_hcd *hcd); | 1371 | void xhci_shutdown(struct usb_hcd *hcd); |
1359 | int xhci_get_frame(struct usb_hcd *hcd); | 1372 | int xhci_get_frame(struct usb_hcd *hcd); |
1360 | irqreturn_t xhci_irq(struct usb_hcd *hcd); | 1373 | irqreturn_t xhci_irq(struct usb_hcd *hcd); |
1374 | irqreturn_t xhci_msi_irq(int irq, struct usb_hcd *hcd); | ||
1361 | int xhci_alloc_dev(struct usb_hcd *hcd, struct usb_device *udev); | 1375 | int xhci_alloc_dev(struct usb_hcd *hcd, struct usb_device *udev); |
1362 | void xhci_free_dev(struct usb_hcd *hcd, struct usb_device *udev); | 1376 | void xhci_free_dev(struct usb_hcd *hcd, struct usb_device *udev); |
1363 | int xhci_alloc_streams(struct usb_hcd *hcd, struct usb_device *udev, | 1377 | int xhci_alloc_streams(struct usb_hcd *hcd, struct usb_device *udev, |
@@ -1386,8 +1400,6 @@ struct xhci_segment *trb_in_td(struct xhci_segment *start_seg, | |||
1386 | int xhci_is_vendor_info_code(struct xhci_hcd *xhci, unsigned int trb_comp_code); | 1400 | int xhci_is_vendor_info_code(struct xhci_hcd *xhci, unsigned int trb_comp_code); |
1387 | void xhci_ring_cmd_db(struct xhci_hcd *xhci); | 1401 | void xhci_ring_cmd_db(struct xhci_hcd *xhci); |
1388 | void *xhci_setup_one_noop(struct xhci_hcd *xhci); | 1402 | void *xhci_setup_one_noop(struct xhci_hcd *xhci); |
1389 | void xhci_handle_event(struct xhci_hcd *xhci); | ||
1390 | void xhci_set_hc_event_deq(struct xhci_hcd *xhci); | ||
1391 | int xhci_queue_slot_control(struct xhci_hcd *xhci, u32 trb_type, u32 slot_id); | 1403 | int xhci_queue_slot_control(struct xhci_hcd *xhci, u32 trb_type, u32 slot_id); |
1392 | int xhci_queue_address_device(struct xhci_hcd *xhci, dma_addr_t in_ctx_ptr, | 1404 | int xhci_queue_address_device(struct xhci_hcd *xhci, dma_addr_t in_ctx_ptr, |
1393 | u32 slot_id); | 1405 | u32 slot_id); |
@@ -1401,6 +1413,8 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags, struct urb *urb, | |||
1401 | int slot_id, unsigned int ep_index); | 1413 | int slot_id, unsigned int ep_index); |
1402 | int xhci_queue_intr_tx(struct xhci_hcd *xhci, gfp_t mem_flags, struct urb *urb, | 1414 | int xhci_queue_intr_tx(struct xhci_hcd *xhci, gfp_t mem_flags, struct urb *urb, |
1403 | int slot_id, unsigned int ep_index); | 1415 | int slot_id, unsigned int ep_index); |
1416 | int xhci_queue_isoc_tx_prepare(struct xhci_hcd *xhci, gfp_t mem_flags, | ||
1417 | struct urb *urb, int slot_id, unsigned int ep_index); | ||
1404 | int xhci_queue_configure_endpoint(struct xhci_hcd *xhci, dma_addr_t in_ctx_ptr, | 1418 | int xhci_queue_configure_endpoint(struct xhci_hcd *xhci, dma_addr_t in_ctx_ptr, |
1405 | u32 slot_id, bool command_must_succeed); | 1419 | u32 slot_id, bool command_must_succeed); |
1406 | int xhci_queue_evaluate_context(struct xhci_hcd *xhci, dma_addr_t in_ctx_ptr, | 1420 | int xhci_queue_evaluate_context(struct xhci_hcd *xhci, dma_addr_t in_ctx_ptr, |
diff --git a/drivers/usb/misc/ftdi-elan.c b/drivers/usb/misc/ftdi-elan.c index 82e16630a78b..aecf380f6ecc 100644 --- a/drivers/usb/misc/ftdi-elan.c +++ b/drivers/usb/misc/ftdi-elan.c | |||
@@ -650,7 +650,7 @@ static int ftdi_elan_open(struct inode *inode, struct file *file) | |||
650 | 650 | ||
651 | static int ftdi_elan_release(struct inode *inode, struct file *file) | 651 | static int ftdi_elan_release(struct inode *inode, struct file *file) |
652 | { | 652 | { |
653 | struct usb_ftdi *ftdi = (struct usb_ftdi *)file->private_data; | 653 | struct usb_ftdi *ftdi = file->private_data; |
654 | if (ftdi == NULL) | 654 | if (ftdi == NULL) |
655 | return -ENODEV; | 655 | return -ENODEV; |
656 | up(&ftdi->sw_lock); /* decrement the count on our device */ | 656 | up(&ftdi->sw_lock); /* decrement the count on our device */ |
@@ -673,7 +673,7 @@ static ssize_t ftdi_elan_read(struct file *file, char __user *buffer, | |||
673 | int bytes_read = 0; | 673 | int bytes_read = 0; |
674 | int retry_on_empty = 10; | 674 | int retry_on_empty = 10; |
675 | int retry_on_timeout = 5; | 675 | int retry_on_timeout = 5; |
676 | struct usb_ftdi *ftdi = (struct usb_ftdi *)file->private_data; | 676 | struct usb_ftdi *ftdi = file->private_data; |
677 | if (ftdi->disconnected > 0) { | 677 | if (ftdi->disconnected > 0) { |
678 | return -ENODEV; | 678 | return -ENODEV; |
679 | } | 679 | } |
diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c index 7dc9d3c69984..2de49c8887c5 100644 --- a/drivers/usb/misc/iowarrior.c +++ b/drivers/usb/misc/iowarrior.c | |||
@@ -18,7 +18,7 @@ | |||
18 | #include <linux/init.h> | 18 | #include <linux/init.h> |
19 | #include <linux/slab.h> | 19 | #include <linux/slab.h> |
20 | #include <linux/sched.h> | 20 | #include <linux/sched.h> |
21 | #include <linux/smp_lock.h> | 21 | #include <linux/mutex.h> |
22 | #include <linux/poll.h> | 22 | #include <linux/poll.h> |
23 | #include <linux/usb/iowarrior.h> | 23 | #include <linux/usb/iowarrior.h> |
24 | 24 | ||
@@ -61,6 +61,7 @@ MODULE_DESCRIPTION(DRIVER_DESC); | |||
61 | MODULE_LICENSE("GPL"); | 61 | MODULE_LICENSE("GPL"); |
62 | 62 | ||
63 | /* Module parameters */ | 63 | /* Module parameters */ |
64 | static DEFINE_MUTEX(iowarrior_mutex); | ||
64 | static int debug = 0; | 65 | static int debug = 0; |
65 | module_param(debug, bool, 0644); | 66 | module_param(debug, bool, 0644); |
66 | MODULE_PARM_DESC(debug, "debug=1 enables debugging messages"); | 67 | MODULE_PARM_DESC(debug, "debug=1 enables debugging messages"); |
@@ -282,7 +283,7 @@ static ssize_t iowarrior_read(struct file *file, char __user *buffer, | |||
282 | int read_idx; | 283 | int read_idx; |
283 | int offset; | 284 | int offset; |
284 | 285 | ||
285 | dev = (struct iowarrior *)file->private_data; | 286 | dev = file->private_data; |
286 | 287 | ||
287 | /* verify that the device wasn't unplugged */ | 288 | /* verify that the device wasn't unplugged */ |
288 | if (dev == NULL || !dev->present) | 289 | if (dev == NULL || !dev->present) |
@@ -348,7 +349,7 @@ static ssize_t iowarrior_write(struct file *file, | |||
348 | char *buf = NULL; /* for IOW24 and IOW56 we need a buffer */ | 349 | char *buf = NULL; /* for IOW24 and IOW56 we need a buffer */ |
349 | struct urb *int_out_urb = NULL; | 350 | struct urb *int_out_urb = NULL; |
350 | 351 | ||
351 | dev = (struct iowarrior *)file->private_data; | 352 | dev = file->private_data; |
352 | 353 | ||
353 | mutex_lock(&dev->mutex); | 354 | mutex_lock(&dev->mutex); |
354 | /* verify that the device wasn't unplugged */ | 355 | /* verify that the device wasn't unplugged */ |
@@ -483,7 +484,7 @@ static long iowarrior_ioctl(struct file *file, unsigned int cmd, | |||
483 | int retval; | 484 | int retval; |
484 | int io_res; /* checks for bytes read/written and copy_to/from_user results */ | 485 | int io_res; /* checks for bytes read/written and copy_to/from_user results */ |
485 | 486 | ||
486 | dev = (struct iowarrior *)file->private_data; | 487 | dev = file->private_data; |
487 | if (dev == NULL) { | 488 | if (dev == NULL) { |
488 | return -ENODEV; | 489 | return -ENODEV; |
489 | } | 490 | } |
@@ -493,7 +494,7 @@ static long iowarrior_ioctl(struct file *file, unsigned int cmd, | |||
493 | return -ENOMEM; | 494 | return -ENOMEM; |
494 | 495 | ||
495 | /* lock this object */ | 496 | /* lock this object */ |
496 | lock_kernel(); | 497 | mutex_lock(&iowarrior_mutex); |
497 | mutex_lock(&dev->mutex); | 498 | mutex_lock(&dev->mutex); |
498 | 499 | ||
499 | /* verify that the device wasn't unplugged */ | 500 | /* verify that the device wasn't unplugged */ |
@@ -585,7 +586,7 @@ static long iowarrior_ioctl(struct file *file, unsigned int cmd, | |||
585 | error_out: | 586 | error_out: |
586 | /* unlock the device */ | 587 | /* unlock the device */ |
587 | mutex_unlock(&dev->mutex); | 588 | mutex_unlock(&dev->mutex); |
588 | unlock_kernel(); | 589 | mutex_unlock(&iowarrior_mutex); |
589 | kfree(buffer); | 590 | kfree(buffer); |
590 | return retval; | 591 | return retval; |
591 | } | 592 | } |
@@ -602,12 +603,12 @@ static int iowarrior_open(struct inode *inode, struct file *file) | |||
602 | 603 | ||
603 | dbg("%s", __func__); | 604 | dbg("%s", __func__); |
604 | 605 | ||
605 | lock_kernel(); | 606 | mutex_lock(&iowarrior_mutex); |
606 | subminor = iminor(inode); | 607 | subminor = iminor(inode); |
607 | 608 | ||
608 | interface = usb_find_interface(&iowarrior_driver, subminor); | 609 | interface = usb_find_interface(&iowarrior_driver, subminor); |
609 | if (!interface) { | 610 | if (!interface) { |
610 | unlock_kernel(); | 611 | mutex_unlock(&iowarrior_mutex); |
611 | err("%s - error, can't find device for minor %d", __func__, | 612 | err("%s - error, can't find device for minor %d", __func__, |
612 | subminor); | 613 | subminor); |
613 | return -ENODEV; | 614 | return -ENODEV; |
@@ -617,7 +618,7 @@ static int iowarrior_open(struct inode *inode, struct file *file) | |||
617 | dev = usb_get_intfdata(interface); | 618 | dev = usb_get_intfdata(interface); |
618 | if (!dev) { | 619 | if (!dev) { |
619 | mutex_unlock(&iowarrior_open_disc_lock); | 620 | mutex_unlock(&iowarrior_open_disc_lock); |
620 | unlock_kernel(); | 621 | mutex_unlock(&iowarrior_mutex); |
621 | return -ENODEV; | 622 | return -ENODEV; |
622 | } | 623 | } |
623 | 624 | ||
@@ -644,7 +645,7 @@ static int iowarrior_open(struct inode *inode, struct file *file) | |||
644 | 645 | ||
645 | out: | 646 | out: |
646 | mutex_unlock(&dev->mutex); | 647 | mutex_unlock(&dev->mutex); |
647 | unlock_kernel(); | 648 | mutex_unlock(&iowarrior_mutex); |
648 | return retval; | 649 | return retval; |
649 | } | 650 | } |
650 | 651 | ||
@@ -656,7 +657,7 @@ static int iowarrior_release(struct inode *inode, struct file *file) | |||
656 | struct iowarrior *dev; | 657 | struct iowarrior *dev; |
657 | int retval = 0; | 658 | int retval = 0; |
658 | 659 | ||
659 | dev = (struct iowarrior *)file->private_data; | 660 | dev = file->private_data; |
660 | if (dev == NULL) { | 661 | if (dev == NULL) { |
661 | return -ENODEV; | 662 | return -ENODEV; |
662 | } | 663 | } |
diff --git a/drivers/usb/misc/legousbtower.c b/drivers/usb/misc/legousbtower.c index 8547bf9e3175..6482c6e2e6bd 100644 --- a/drivers/usb/misc/legousbtower.c +++ b/drivers/usb/misc/legousbtower.c | |||
@@ -448,7 +448,7 @@ static int tower_release (struct inode *inode, struct file *file) | |||
448 | 448 | ||
449 | dbg(2, "%s: enter", __func__); | 449 | dbg(2, "%s: enter", __func__); |
450 | 450 | ||
451 | dev = (struct lego_usb_tower *)file->private_data; | 451 | dev = file->private_data; |
452 | 452 | ||
453 | if (dev == NULL) { | 453 | if (dev == NULL) { |
454 | dbg(1, "%s: object is NULL", __func__); | 454 | dbg(1, "%s: object is NULL", __func__); |
@@ -597,7 +597,7 @@ static ssize_t tower_read (struct file *file, char __user *buffer, size_t count, | |||
597 | 597 | ||
598 | dbg(2, "%s: enter, count = %Zd", __func__, count); | 598 | dbg(2, "%s: enter, count = %Zd", __func__, count); |
599 | 599 | ||
600 | dev = (struct lego_usb_tower *)file->private_data; | 600 | dev = file->private_data; |
601 | 601 | ||
602 | /* lock this object */ | 602 | /* lock this object */ |
603 | if (mutex_lock_interruptible(&dev->lock)) { | 603 | if (mutex_lock_interruptible(&dev->lock)) { |
@@ -686,7 +686,7 @@ static ssize_t tower_write (struct file *file, const char __user *buffer, size_t | |||
686 | 686 | ||
687 | dbg(2, "%s: enter, count = %Zd", __func__, count); | 687 | dbg(2, "%s: enter, count = %Zd", __func__, count); |
688 | 688 | ||
689 | dev = (struct lego_usb_tower *)file->private_data; | 689 | dev = file->private_data; |
690 | 690 | ||
691 | /* lock this object */ | 691 | /* lock this object */ |
692 | if (mutex_lock_interruptible(&dev->lock)) { | 692 | if (mutex_lock_interruptible(&dev->lock)) { |
diff --git a/drivers/usb/misc/rio500.c b/drivers/usb/misc/rio500.c index a85771b1563d..cc13ae61712a 100644 --- a/drivers/usb/misc/rio500.c +++ b/drivers/usb/misc/rio500.c | |||
@@ -32,7 +32,7 @@ | |||
32 | #include <linux/kernel.h> | 32 | #include <linux/kernel.h> |
33 | #include <linux/signal.h> | 33 | #include <linux/signal.h> |
34 | #include <linux/sched.h> | 34 | #include <linux/sched.h> |
35 | #include <linux/smp_lock.h> | 35 | #include <linux/mutex.h> |
36 | #include <linux/errno.h> | 36 | #include <linux/errno.h> |
37 | #include <linux/random.h> | 37 | #include <linux/random.h> |
38 | #include <linux/poll.h> | 38 | #include <linux/poll.h> |
@@ -72,6 +72,7 @@ struct rio_usb_data { | |||
72 | struct mutex lock; /* general race avoidance */ | 72 | struct mutex lock; /* general race avoidance */ |
73 | }; | 73 | }; |
74 | 74 | ||
75 | static DEFINE_MUTEX(rio500_mutex); | ||
75 | static struct rio_usb_data rio_instance; | 76 | static struct rio_usb_data rio_instance; |
76 | 77 | ||
77 | static int open_rio(struct inode *inode, struct file *file) | 78 | static int open_rio(struct inode *inode, struct file *file) |
@@ -79,12 +80,12 @@ static int open_rio(struct inode *inode, struct file *file) | |||
79 | struct rio_usb_data *rio = &rio_instance; | 80 | struct rio_usb_data *rio = &rio_instance; |
80 | 81 | ||
81 | /* against disconnect() */ | 82 | /* against disconnect() */ |
82 | lock_kernel(); | 83 | mutex_lock(&rio500_mutex); |
83 | mutex_lock(&(rio->lock)); | 84 | mutex_lock(&(rio->lock)); |
84 | 85 | ||
85 | if (rio->isopen || !rio->present) { | 86 | if (rio->isopen || !rio->present) { |
86 | mutex_unlock(&(rio->lock)); | 87 | mutex_unlock(&(rio->lock)); |
87 | unlock_kernel(); | 88 | mutex_unlock(&rio500_mutex); |
88 | return -EBUSY; | 89 | return -EBUSY; |
89 | } | 90 | } |
90 | rio->isopen = 1; | 91 | rio->isopen = 1; |
@@ -94,7 +95,7 @@ static int open_rio(struct inode *inode, struct file *file) | |||
94 | mutex_unlock(&(rio->lock)); | 95 | mutex_unlock(&(rio->lock)); |
95 | 96 | ||
96 | dev_info(&rio->rio_dev->dev, "Rio opened.\n"); | 97 | dev_info(&rio->rio_dev->dev, "Rio opened.\n"); |
97 | unlock_kernel(); | 98 | mutex_unlock(&rio500_mutex); |
98 | 99 | ||
99 | return 0; | 100 | return 0; |
100 | } | 101 | } |
@@ -491,7 +492,7 @@ static void disconnect_rio(struct usb_interface *intf) | |||
491 | struct rio_usb_data *rio = usb_get_intfdata (intf); | 492 | struct rio_usb_data *rio = usb_get_intfdata (intf); |
492 | 493 | ||
493 | usb_set_intfdata (intf, NULL); | 494 | usb_set_intfdata (intf, NULL); |
494 | lock_kernel(); | 495 | mutex_lock(&rio500_mutex); |
495 | if (rio) { | 496 | if (rio) { |
496 | usb_deregister_dev(intf, &usb_rio_class); | 497 | usb_deregister_dev(intf, &usb_rio_class); |
497 | 498 | ||
@@ -501,7 +502,7 @@ static void disconnect_rio(struct usb_interface *intf) | |||
501 | /* better let it finish - the release will do whats needed */ | 502 | /* better let it finish - the release will do whats needed */ |
502 | rio->rio_dev = NULL; | 503 | rio->rio_dev = NULL; |
503 | mutex_unlock(&(rio->lock)); | 504 | mutex_unlock(&(rio->lock)); |
504 | unlock_kernel(); | 505 | mutex_unlock(&rio500_mutex); |
505 | return; | 506 | return; |
506 | } | 507 | } |
507 | kfree(rio->ibuf); | 508 | kfree(rio->ibuf); |
@@ -512,7 +513,7 @@ static void disconnect_rio(struct usb_interface *intf) | |||
512 | rio->present = 0; | 513 | rio->present = 0; |
513 | mutex_unlock(&(rio->lock)); | 514 | mutex_unlock(&(rio->lock)); |
514 | } | 515 | } |
515 | unlock_kernel(); | 516 | mutex_unlock(&rio500_mutex); |
516 | } | 517 | } |
517 | 518 | ||
518 | static const struct usb_device_id rio_table[] = { | 519 | static const struct usb_device_id rio_table[] = { |
diff --git a/drivers/usb/misc/sisusbvga/sisusb.c b/drivers/usb/misc/sisusbvga/sisusb.c index d25814c172b2..70d00e99a4b4 100644 --- a/drivers/usb/misc/sisusbvga/sisusb.c +++ b/drivers/usb/misc/sisusbvga/sisusb.c | |||
@@ -2487,7 +2487,7 @@ sisusb_release(struct inode *inode, struct file *file) | |||
2487 | { | 2487 | { |
2488 | struct sisusb_usb_data *sisusb; | 2488 | struct sisusb_usb_data *sisusb; |
2489 | 2489 | ||
2490 | if (!(sisusb = (struct sisusb_usb_data *)file->private_data)) | 2490 | if (!(sisusb = file->private_data)) |
2491 | return -ENODEV; | 2491 | return -ENODEV; |
2492 | 2492 | ||
2493 | mutex_lock(&sisusb->lock); | 2493 | mutex_lock(&sisusb->lock); |
@@ -2519,7 +2519,7 @@ sisusb_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos) | |||
2519 | u16 buf16; | 2519 | u16 buf16; |
2520 | u32 buf32, address; | 2520 | u32 buf32, address; |
2521 | 2521 | ||
2522 | if (!(sisusb = (struct sisusb_usb_data *)file->private_data)) | 2522 | if (!(sisusb = file->private_data)) |
2523 | return -ENODEV; | 2523 | return -ENODEV; |
2524 | 2524 | ||
2525 | mutex_lock(&sisusb->lock); | 2525 | mutex_lock(&sisusb->lock); |
@@ -2661,7 +2661,7 @@ sisusb_write(struct file *file, const char __user *buffer, size_t count, | |||
2661 | u16 buf16; | 2661 | u16 buf16; |
2662 | u32 buf32, address; | 2662 | u32 buf32, address; |
2663 | 2663 | ||
2664 | if (!(sisusb = (struct sisusb_usb_data *)file->private_data)) | 2664 | if (!(sisusb = file->private_data)) |
2665 | return -ENODEV; | 2665 | return -ENODEV; |
2666 | 2666 | ||
2667 | mutex_lock(&sisusb->lock); | 2667 | mutex_lock(&sisusb->lock); |
@@ -2804,7 +2804,7 @@ sisusb_lseek(struct file *file, loff_t offset, int orig) | |||
2804 | struct sisusb_usb_data *sisusb; | 2804 | struct sisusb_usb_data *sisusb; |
2805 | loff_t ret; | 2805 | loff_t ret; |
2806 | 2806 | ||
2807 | if (!(sisusb = (struct sisusb_usb_data *)file->private_data)) | 2807 | if (!(sisusb = file->private_data)) |
2808 | return -ENODEV; | 2808 | return -ENODEV; |
2809 | 2809 | ||
2810 | mutex_lock(&sisusb->lock); | 2810 | mutex_lock(&sisusb->lock); |
@@ -2969,7 +2969,7 @@ sisusb_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
2969 | long retval = 0; | 2969 | long retval = 0; |
2970 | u32 __user *argp = (u32 __user *)arg; | 2970 | u32 __user *argp = (u32 __user *)arg; |
2971 | 2971 | ||
2972 | if (!(sisusb = (struct sisusb_usb_data *)file->private_data)) | 2972 | if (!(sisusb = file->private_data)) |
2973 | return -ENODEV; | 2973 | return -ENODEV; |
2974 | 2974 | ||
2975 | mutex_lock(&sisusb->lock); | 2975 | mutex_lock(&sisusb->lock); |
diff --git a/drivers/usb/misc/usblcd.c b/drivers/usb/misc/usblcd.c index 7828c764b323..d00dde19194c 100644 --- a/drivers/usb/misc/usblcd.c +++ b/drivers/usb/misc/usblcd.c | |||
@@ -16,7 +16,6 @@ | |||
16 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
17 | #include <linux/init.h> | 17 | #include <linux/init.h> |
18 | #include <linux/slab.h> | 18 | #include <linux/slab.h> |
19 | #include <linux/smp_lock.h> | ||
20 | #include <linux/errno.h> | 19 | #include <linux/errno.h> |
21 | #include <linux/mutex.h> | 20 | #include <linux/mutex.h> |
22 | #include <asm/uaccess.h> | 21 | #include <asm/uaccess.h> |
@@ -30,6 +29,7 @@ | |||
30 | #define IOCTL_GET_DRV_VERSION 2 | 29 | #define IOCTL_GET_DRV_VERSION 2 |
31 | 30 | ||
32 | 31 | ||
32 | static DEFINE_MUTEX(lcd_mutex); | ||
33 | static const struct usb_device_id id_table[] = { | 33 | static const struct usb_device_id id_table[] = { |
34 | { .idVendor = 0x10D2, .match_flags = USB_DEVICE_ID_MATCH_VENDOR, }, | 34 | { .idVendor = 0x10D2, .match_flags = USB_DEVICE_ID_MATCH_VENDOR, }, |
35 | { }, | 35 | { }, |
@@ -74,12 +74,12 @@ static int lcd_open(struct inode *inode, struct file *file) | |||
74 | struct usb_interface *interface; | 74 | struct usb_interface *interface; |
75 | int subminor, r; | 75 | int subminor, r; |
76 | 76 | ||
77 | lock_kernel(); | 77 | mutex_lock(&lcd_mutex); |
78 | subminor = iminor(inode); | 78 | subminor = iminor(inode); |
79 | 79 | ||
80 | interface = usb_find_interface(&lcd_driver, subminor); | 80 | interface = usb_find_interface(&lcd_driver, subminor); |
81 | if (!interface) { | 81 | if (!interface) { |
82 | unlock_kernel(); | 82 | mutex_unlock(&lcd_mutex); |
83 | err ("USBLCD: %s - error, can't find device for minor %d", | 83 | err ("USBLCD: %s - error, can't find device for minor %d", |
84 | __func__, subminor); | 84 | __func__, subminor); |
85 | return -ENODEV; | 85 | return -ENODEV; |
@@ -89,7 +89,7 @@ static int lcd_open(struct inode *inode, struct file *file) | |||
89 | dev = usb_get_intfdata(interface); | 89 | dev = usb_get_intfdata(interface); |
90 | if (!dev) { | 90 | if (!dev) { |
91 | mutex_unlock(&open_disc_mutex); | 91 | mutex_unlock(&open_disc_mutex); |
92 | unlock_kernel(); | 92 | mutex_unlock(&lcd_mutex); |
93 | return -ENODEV; | 93 | return -ENODEV; |
94 | } | 94 | } |
95 | 95 | ||
@@ -101,13 +101,13 @@ static int lcd_open(struct inode *inode, struct file *file) | |||
101 | r = usb_autopm_get_interface(interface); | 101 | r = usb_autopm_get_interface(interface); |
102 | if (r < 0) { | 102 | if (r < 0) { |
103 | kref_put(&dev->kref, lcd_delete); | 103 | kref_put(&dev->kref, lcd_delete); |
104 | unlock_kernel(); | 104 | mutex_unlock(&lcd_mutex); |
105 | return r; | 105 | return r; |
106 | } | 106 | } |
107 | 107 | ||
108 | /* save our object in the file's private structure */ | 108 | /* save our object in the file's private structure */ |
109 | file->private_data = dev; | 109 | file->private_data = dev; |
110 | unlock_kernel(); | 110 | mutex_unlock(&lcd_mutex); |
111 | 111 | ||
112 | return 0; | 112 | return 0; |
113 | } | 113 | } |
@@ -116,7 +116,7 @@ static int lcd_release(struct inode *inode, struct file *file) | |||
116 | { | 116 | { |
117 | struct usb_lcd *dev; | 117 | struct usb_lcd *dev; |
118 | 118 | ||
119 | dev = (struct usb_lcd *)file->private_data; | 119 | dev = file->private_data; |
120 | if (dev == NULL) | 120 | if (dev == NULL) |
121 | return -ENODEV; | 121 | return -ENODEV; |
122 | 122 | ||
@@ -132,7 +132,7 @@ static ssize_t lcd_read(struct file *file, char __user * buffer, size_t count, l | |||
132 | int retval = 0; | 132 | int retval = 0; |
133 | int bytes_read; | 133 | int bytes_read; |
134 | 134 | ||
135 | dev = (struct usb_lcd *)file->private_data; | 135 | dev = file->private_data; |
136 | 136 | ||
137 | /* do a blocking bulk read to get data from the device */ | 137 | /* do a blocking bulk read to get data from the device */ |
138 | retval = usb_bulk_msg(dev->udev, | 138 | retval = usb_bulk_msg(dev->udev, |
@@ -158,20 +158,20 @@ static long lcd_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
158 | u16 bcdDevice; | 158 | u16 bcdDevice; |
159 | char buf[30]; | 159 | char buf[30]; |
160 | 160 | ||
161 | dev = (struct usb_lcd *)file->private_data; | 161 | dev = file->private_data; |
162 | if (dev == NULL) | 162 | if (dev == NULL) |
163 | return -ENODEV; | 163 | return -ENODEV; |
164 | 164 | ||
165 | switch (cmd) { | 165 | switch (cmd) { |
166 | case IOCTL_GET_HARD_VERSION: | 166 | case IOCTL_GET_HARD_VERSION: |
167 | lock_kernel(); | 167 | mutex_lock(&lcd_mutex); |
168 | bcdDevice = le16_to_cpu((dev->udev)->descriptor.bcdDevice); | 168 | bcdDevice = le16_to_cpu((dev->udev)->descriptor.bcdDevice); |
169 | sprintf(buf,"%1d%1d.%1d%1d", | 169 | sprintf(buf,"%1d%1d.%1d%1d", |
170 | (bcdDevice & 0xF000)>>12, | 170 | (bcdDevice & 0xF000)>>12, |
171 | (bcdDevice & 0xF00)>>8, | 171 | (bcdDevice & 0xF00)>>8, |
172 | (bcdDevice & 0xF0)>>4, | 172 | (bcdDevice & 0xF0)>>4, |
173 | (bcdDevice & 0xF)); | 173 | (bcdDevice & 0xF)); |
174 | unlock_kernel(); | 174 | mutex_unlock(&lcd_mutex); |
175 | if (copy_to_user((void __user *)arg,buf,strlen(buf))!=0) | 175 | if (copy_to_user((void __user *)arg,buf,strlen(buf))!=0) |
176 | return -EFAULT; | 176 | return -EFAULT; |
177 | break; | 177 | break; |
@@ -217,7 +217,7 @@ static ssize_t lcd_write(struct file *file, const char __user * user_buffer, siz | |||
217 | struct urb *urb = NULL; | 217 | struct urb *urb = NULL; |
218 | char *buf = NULL; | 218 | char *buf = NULL; |
219 | 219 | ||
220 | dev = (struct usb_lcd *)file->private_data; | 220 | dev = file->private_data; |
221 | 221 | ||
222 | /* verify that we actually have some data to write */ | 222 | /* verify that we actually have some data to write */ |
223 | if (count == 0) | 223 | if (count == 0) |
diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c index 16dffe99d9f1..eef370eb7a54 100644 --- a/drivers/usb/misc/usbtest.c +++ b/drivers/usb/misc/usbtest.c | |||
@@ -136,7 +136,7 @@ try_iso: | |||
136 | iso_out = e; | 136 | iso_out = e; |
137 | } | 137 | } |
138 | } | 138 | } |
139 | if ((in && out) || (iso_in && iso_out)) | 139 | if ((in && out) || iso_in || iso_out) |
140 | goto found; | 140 | goto found; |
141 | } | 141 | } |
142 | return -EINVAL; | 142 | return -EINVAL; |
@@ -162,6 +162,9 @@ found: | |||
162 | dev->in_iso_pipe = usb_rcvisocpipe (udev, | 162 | dev->in_iso_pipe = usb_rcvisocpipe (udev, |
163 | iso_in->desc.bEndpointAddress | 163 | iso_in->desc.bEndpointAddress |
164 | & USB_ENDPOINT_NUMBER_MASK); | 164 | & USB_ENDPOINT_NUMBER_MASK); |
165 | } | ||
166 | |||
167 | if (iso_out) { | ||
165 | dev->iso_out = &iso_out->desc; | 168 | dev->iso_out = &iso_out->desc; |
166 | dev->out_iso_pipe = usb_sndisocpipe (udev, | 169 | dev->out_iso_pipe = usb_sndisocpipe (udev, |
167 | iso_out->desc.bEndpointAddress | 170 | iso_out->desc.bEndpointAddress |
@@ -1378,7 +1381,6 @@ static void iso_callback (struct urb *urb) | |||
1378 | break; | 1381 | break; |
1379 | } | 1382 | } |
1380 | } | 1383 | } |
1381 | simple_free_urb (urb); | ||
1382 | 1384 | ||
1383 | ctx->pending--; | 1385 | ctx->pending--; |
1384 | if (ctx->pending == 0) { | 1386 | if (ctx->pending == 0) { |
@@ -1495,6 +1497,7 @@ test_iso_queue (struct usbtest_dev *dev, struct usbtest_param *param, | |||
1495 | } | 1497 | } |
1496 | 1498 | ||
1497 | simple_free_urb (urbs [i]); | 1499 | simple_free_urb (urbs [i]); |
1500 | urbs[i] = NULL; | ||
1498 | context.pending--; | 1501 | context.pending--; |
1499 | context.submit_error = 1; | 1502 | context.submit_error = 1; |
1500 | break; | 1503 | break; |
@@ -1504,6 +1507,10 @@ test_iso_queue (struct usbtest_dev *dev, struct usbtest_param *param, | |||
1504 | 1507 | ||
1505 | wait_for_completion (&context.done); | 1508 | wait_for_completion (&context.done); |
1506 | 1509 | ||
1510 | for (i = 0; i < param->sglen; i++) { | ||
1511 | if (urbs[i]) | ||
1512 | simple_free_urb(urbs[i]); | ||
1513 | } | ||
1507 | /* | 1514 | /* |
1508 | * Isochronous transfers are expected to fail sometimes. As an | 1515 | * Isochronous transfers are expected to fail sometimes. As an |
1509 | * arbitrary limit, we will report an error if any submissions | 1516 | * arbitrary limit, we will report an error if any submissions |
@@ -1548,6 +1555,7 @@ fail: | |||
1548 | * off just killing the userspace task and waiting for it to exit. | 1555 | * off just killing the userspace task and waiting for it to exit. |
1549 | */ | 1556 | */ |
1550 | 1557 | ||
1558 | /* No BKL needed */ | ||
1551 | static int | 1559 | static int |
1552 | usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | 1560 | usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) |
1553 | { | 1561 | { |
@@ -2170,7 +2178,7 @@ static struct usb_driver usbtest_driver = { | |||
2170 | .name = "usbtest", | 2178 | .name = "usbtest", |
2171 | .id_table = id_table, | 2179 | .id_table = id_table, |
2172 | .probe = usbtest_probe, | 2180 | .probe = usbtest_probe, |
2173 | .ioctl = usbtest_ioctl, | 2181 | .unlocked_ioctl = usbtest_ioctl, |
2174 | .disconnect = usbtest_disconnect, | 2182 | .disconnect = usbtest_disconnect, |
2175 | .suspend = usbtest_suspend, | 2183 | .suspend = usbtest_suspend, |
2176 | .resume = usbtest_resume, | 2184 | .resume = usbtest_resume, |
diff --git a/drivers/usb/mon/mon_bin.c b/drivers/usb/mon/mon_bin.c index 61c76b13f0f1..44cb37b5a4dc 100644 --- a/drivers/usb/mon/mon_bin.c +++ b/drivers/usb/mon/mon_bin.c | |||
@@ -646,17 +646,14 @@ static int mon_bin_open(struct inode *inode, struct file *file) | |||
646 | size_t size; | 646 | size_t size; |
647 | int rc; | 647 | int rc; |
648 | 648 | ||
649 | lock_kernel(); | ||
650 | mutex_lock(&mon_lock); | 649 | mutex_lock(&mon_lock); |
651 | if ((mbus = mon_bus_lookup(iminor(inode))) == NULL) { | 650 | if ((mbus = mon_bus_lookup(iminor(inode))) == NULL) { |
652 | mutex_unlock(&mon_lock); | 651 | mutex_unlock(&mon_lock); |
653 | unlock_kernel(); | ||
654 | return -ENODEV; | 652 | return -ENODEV; |
655 | } | 653 | } |
656 | if (mbus != &mon_bus0 && mbus->u_bus == NULL) { | 654 | if (mbus != &mon_bus0 && mbus->u_bus == NULL) { |
657 | printk(KERN_ERR TAG ": consistency error on open\n"); | 655 | printk(KERN_ERR TAG ": consistency error on open\n"); |
658 | mutex_unlock(&mon_lock); | 656 | mutex_unlock(&mon_lock); |
659 | unlock_kernel(); | ||
660 | return -ENODEV; | 657 | return -ENODEV; |
661 | } | 658 | } |
662 | 659 | ||
@@ -689,7 +686,6 @@ static int mon_bin_open(struct inode *inode, struct file *file) | |||
689 | 686 | ||
690 | file->private_data = rp; | 687 | file->private_data = rp; |
691 | mutex_unlock(&mon_lock); | 688 | mutex_unlock(&mon_lock); |
692 | unlock_kernel(); | ||
693 | return 0; | 689 | return 0; |
694 | 690 | ||
695 | err_allocbuff: | 691 | err_allocbuff: |
@@ -698,7 +694,6 @@ err_allocvec: | |||
698 | kfree(rp); | 694 | kfree(rp); |
699 | err_alloc: | 695 | err_alloc: |
700 | mutex_unlock(&mon_lock); | 696 | mutex_unlock(&mon_lock); |
701 | unlock_kernel(); | ||
702 | return rc; | 697 | return rc; |
703 | } | 698 | } |
704 | 699 | ||
@@ -954,7 +949,7 @@ static int mon_bin_queued(struct mon_reader_bin *rp) | |||
954 | 949 | ||
955 | /* | 950 | /* |
956 | */ | 951 | */ |
957 | static int mon_bin_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | 952 | static long mon_bin_ioctl(struct file *file, unsigned int cmd, unsigned long arg) |
958 | { | 953 | { |
959 | struct mon_reader_bin *rp = file->private_data; | 954 | struct mon_reader_bin *rp = file->private_data; |
960 | // struct mon_bus* mbus = rp->r.m_bus; | 955 | // struct mon_bus* mbus = rp->r.m_bus; |
@@ -1009,7 +1004,7 @@ static int mon_bin_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
1009 | 1004 | ||
1010 | mutex_lock(&rp->fetch_lock); | 1005 | mutex_lock(&rp->fetch_lock); |
1011 | spin_lock_irqsave(&rp->b_lock, flags); | 1006 | spin_lock_irqsave(&rp->b_lock, flags); |
1012 | mon_free_buff(rp->b_vec, size/CHUNK_SIZE); | 1007 | mon_free_buff(rp->b_vec, rp->b_size/CHUNK_SIZE); |
1013 | kfree(rp->b_vec); | 1008 | kfree(rp->b_vec); |
1014 | rp->b_vec = vec; | 1009 | rp->b_vec = vec; |
1015 | rp->b_size = size; | 1010 | rp->b_size = size; |
@@ -1094,19 +1089,6 @@ static int mon_bin_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
1094 | return ret; | 1089 | return ret; |
1095 | } | 1090 | } |
1096 | 1091 | ||
1097 | static long mon_bin_unlocked_ioctl(struct file *file, unsigned int cmd, | ||
1098 | unsigned long arg) | ||
1099 | { | ||
1100 | int ret; | ||
1101 | |||
1102 | lock_kernel(); | ||
1103 | ret = mon_bin_ioctl(file, cmd, arg); | ||
1104 | unlock_kernel(); | ||
1105 | |||
1106 | return ret; | ||
1107 | } | ||
1108 | |||
1109 | |||
1110 | #ifdef CONFIG_COMPAT | 1092 | #ifdef CONFIG_COMPAT |
1111 | static long mon_bin_compat_ioctl(struct file *file, | 1093 | static long mon_bin_compat_ioctl(struct file *file, |
1112 | unsigned int cmd, unsigned long arg) | 1094 | unsigned int cmd, unsigned long arg) |
@@ -1250,7 +1232,7 @@ static const struct file_operations mon_fops_binary = { | |||
1250 | .read = mon_bin_read, | 1232 | .read = mon_bin_read, |
1251 | /* .write = mon_text_write, */ | 1233 | /* .write = mon_text_write, */ |
1252 | .poll = mon_bin_poll, | 1234 | .poll = mon_bin_poll, |
1253 | .unlocked_ioctl = mon_bin_unlocked_ioctl, | 1235 | .unlocked_ioctl = mon_bin_ioctl, |
1254 | #ifdef CONFIG_COMPAT | 1236 | #ifdef CONFIG_COMPAT |
1255 | .compat_ioctl = mon_bin_compat_ioctl, | 1237 | .compat_ioctl = mon_bin_compat_ioctl, |
1256 | #endif | 1238 | #endif |
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index 3b795c56221f..540c766c4f86 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c | |||
@@ -704,7 +704,6 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, | |||
704 | #ifdef CONFIG_USB_MUSB_HDRC_HCD | 704 | #ifdef CONFIG_USB_MUSB_HDRC_HCD |
705 | if (int_usb & MUSB_INTR_CONNECT) { | 705 | if (int_usb & MUSB_INTR_CONNECT) { |
706 | struct usb_hcd *hcd = musb_to_hcd(musb); | 706 | struct usb_hcd *hcd = musb_to_hcd(musb); |
707 | void __iomem *mbase = musb->mregs; | ||
708 | 707 | ||
709 | handled = IRQ_HANDLED; | 708 | handled = IRQ_HANDLED; |
710 | musb->is_active = 1; | 709 | musb->is_active = 1; |
@@ -717,9 +716,9 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, | |||
717 | if (is_peripheral_active(musb)) { | 716 | if (is_peripheral_active(musb)) { |
718 | /* REVISIT HNP; just force disconnect */ | 717 | /* REVISIT HNP; just force disconnect */ |
719 | } | 718 | } |
720 | musb_writew(mbase, MUSB_INTRTXE, musb->epmask); | 719 | musb_writew(musb->mregs, MUSB_INTRTXE, musb->epmask); |
721 | musb_writew(mbase, MUSB_INTRRXE, musb->epmask & 0xfffe); | 720 | musb_writew(musb->mregs, MUSB_INTRRXE, musb->epmask & 0xfffe); |
722 | musb_writeb(mbase, MUSB_INTRUSBE, 0xf7); | 721 | musb_writeb(musb->mregs, MUSB_INTRUSBE, 0xf7); |
723 | #endif | 722 | #endif |
724 | musb->port1_status &= ~(USB_PORT_STAT_LOW_SPEED | 723 | musb->port1_status &= ~(USB_PORT_STAT_LOW_SPEED |
725 | |USB_PORT_STAT_HIGH_SPEED | 724 | |USB_PORT_STAT_HIGH_SPEED |
diff --git a/drivers/usb/musb/musb_debugfs.c b/drivers/usb/musb/musb_debugfs.c index bba76af0c0c6..c79a5e30d437 100644 --- a/drivers/usb/musb/musb_debugfs.c +++ b/drivers/usb/musb/musb_debugfs.c | |||
@@ -92,29 +92,29 @@ static const struct musb_register_map musb_regmap[] = { | |||
92 | { "LS_EOF1", 0x7E, 8 }, | 92 | { "LS_EOF1", 0x7E, 8 }, |
93 | { "SOFT_RST", 0x7F, 8 }, | 93 | { "SOFT_RST", 0x7F, 8 }, |
94 | { "DMA_CNTLch0", 0x204, 16 }, | 94 | { "DMA_CNTLch0", 0x204, 16 }, |
95 | { "DMA_ADDRch0", 0x208, 16 }, | 95 | { "DMA_ADDRch0", 0x208, 32 }, |
96 | { "DMA_COUNTch0", 0x20C, 16 }, | 96 | { "DMA_COUNTch0", 0x20C, 32 }, |
97 | { "DMA_CNTLch1", 0x214, 16 }, | 97 | { "DMA_CNTLch1", 0x214, 16 }, |
98 | { "DMA_ADDRch1", 0x218, 16 }, | 98 | { "DMA_ADDRch1", 0x218, 32 }, |
99 | { "DMA_COUNTch1", 0x21C, 16 }, | 99 | { "DMA_COUNTch1", 0x21C, 32 }, |
100 | { "DMA_CNTLch2", 0x224, 16 }, | 100 | { "DMA_CNTLch2", 0x224, 16 }, |
101 | { "DMA_ADDRch2", 0x228, 16 }, | 101 | { "DMA_ADDRch2", 0x228, 32 }, |
102 | { "DMA_COUNTch2", 0x22C, 16 }, | 102 | { "DMA_COUNTch2", 0x22C, 32 }, |
103 | { "DMA_CNTLch3", 0x234, 16 }, | 103 | { "DMA_CNTLch3", 0x234, 16 }, |
104 | { "DMA_ADDRch3", 0x238, 16 }, | 104 | { "DMA_ADDRch3", 0x238, 32 }, |
105 | { "DMA_COUNTch3", 0x23C, 16 }, | 105 | { "DMA_COUNTch3", 0x23C, 32 }, |
106 | { "DMA_CNTLch4", 0x244, 16 }, | 106 | { "DMA_CNTLch4", 0x244, 16 }, |
107 | { "DMA_ADDRch4", 0x248, 16 }, | 107 | { "DMA_ADDRch4", 0x248, 32 }, |
108 | { "DMA_COUNTch4", 0x24C, 16 }, | 108 | { "DMA_COUNTch4", 0x24C, 32 }, |
109 | { "DMA_CNTLch5", 0x254, 16 }, | 109 | { "DMA_CNTLch5", 0x254, 16 }, |
110 | { "DMA_ADDRch5", 0x258, 16 }, | 110 | { "DMA_ADDRch5", 0x258, 32 }, |
111 | { "DMA_COUNTch5", 0x25C, 16 }, | 111 | { "DMA_COUNTch5", 0x25C, 32 }, |
112 | { "DMA_CNTLch6", 0x264, 16 }, | 112 | { "DMA_CNTLch6", 0x264, 16 }, |
113 | { "DMA_ADDRch6", 0x268, 16 }, | 113 | { "DMA_ADDRch6", 0x268, 32 }, |
114 | { "DMA_COUNTch6", 0x26C, 16 }, | 114 | { "DMA_COUNTch6", 0x26C, 32 }, |
115 | { "DMA_CNTLch7", 0x274, 16 }, | 115 | { "DMA_CNTLch7", 0x274, 16 }, |
116 | { "DMA_ADDRch7", 0x278, 16 }, | 116 | { "DMA_ADDRch7", 0x278, 32 }, |
117 | { "DMA_COUNTch7", 0x27C, 16 }, | 117 | { "DMA_COUNTch7", 0x27C, 32 }, |
118 | { } /* Terminating Entry */ | 118 | { } /* Terminating Entry */ |
119 | }; | 119 | }; |
120 | 120 | ||
diff --git a/drivers/usb/musb/musb_gadget_ep0.c b/drivers/usb/musb/musb_gadget_ep0.c index 21b9788d0243..59bef8f3a358 100644 --- a/drivers/usb/musb/musb_gadget_ep0.c +++ b/drivers/usb/musb/musb_gadget_ep0.c | |||
@@ -402,6 +402,9 @@ __acquires(musb->lock) | |||
402 | musb->g.a_alt_hnp_support = 1; | 402 | musb->g.a_alt_hnp_support = 1; |
403 | break; | 403 | break; |
404 | #endif | 404 | #endif |
405 | case USB_DEVICE_DEBUG_MODE: | ||
406 | handled = 0; | ||
407 | break; | ||
405 | stall: | 408 | stall: |
406 | default: | 409 | default: |
407 | handled = -EINVAL; | 410 | handled = -EINVAL; |
diff --git a/drivers/usb/musb/musb_virthub.c b/drivers/usb/musb/musb_virthub.c index 92e85e027cfb..43233c397b6e 100644 --- a/drivers/usb/musb/musb_virthub.c +++ b/drivers/usb/musb/musb_virthub.c | |||
@@ -244,7 +244,7 @@ int musb_hub_control( | |||
244 | 244 | ||
245 | spin_lock_irqsave(&musb->lock, flags); | 245 | spin_lock_irqsave(&musb->lock, flags); |
246 | 246 | ||
247 | if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags))) { | 247 | if (unlikely(!HCD_HW_ACCESSIBLE(hcd))) { |
248 | spin_unlock_irqrestore(&musb->lock, flags); | 248 | spin_unlock_irqrestore(&musb->lock, flags); |
249 | return -ESHUTDOWN; | 249 | return -ESHUTDOWN; |
250 | } | 250 | } |
diff --git a/drivers/usb/musb/musbhsdma.c b/drivers/usb/musb/musbhsdma.c index dc66e4376d49..6dc107f25245 100644 --- a/drivers/usb/musb/musbhsdma.c +++ b/drivers/usb/musb/musbhsdma.c | |||
@@ -173,10 +173,7 @@ static int dma_channel_program(struct dma_channel *channel, | |||
173 | musb_channel->max_packet_sz = packet_sz; | 173 | musb_channel->max_packet_sz = packet_sz; |
174 | channel->status = MUSB_DMA_STATUS_BUSY; | 174 | channel->status = MUSB_DMA_STATUS_BUSY; |
175 | 175 | ||
176 | if ((mode == 1) && (len >= packet_sz)) | 176 | configure_channel(channel, packet_sz, mode, dma_addr, len); |
177 | configure_channel(channel, packet_sz, 1, dma_addr, len); | ||
178 | else | ||
179 | configure_channel(channel, packet_sz, 0, dma_addr, len); | ||
180 | 177 | ||
181 | return true; | 178 | return true; |
182 | } | 179 | } |
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c index e06d65e36bf7..2111a241dd03 100644 --- a/drivers/usb/musb/omap2430.c +++ b/drivers/usb/musb/omap2430.c | |||
@@ -32,8 +32,6 @@ | |||
32 | #include <linux/clk.h> | 32 | #include <linux/clk.h> |
33 | #include <linux/io.h> | 33 | #include <linux/io.h> |
34 | 34 | ||
35 | #include <plat/mux.h> | ||
36 | |||
37 | #include "musb_core.h" | 35 | #include "musb_core.h" |
38 | #include "omap2430.h" | 36 | #include "omap2430.h" |
39 | 37 | ||
@@ -194,10 +192,6 @@ int __init musb_platform_init(struct musb *musb, void *board_data) | |||
194 | u32 l; | 192 | u32 l; |
195 | struct omap_musb_board_data *data = board_data; | 193 | struct omap_musb_board_data *data = board_data; |
196 | 194 | ||
197 | #if defined(CONFIG_ARCH_OMAP2430) | ||
198 | omap_cfg_reg(AE5_2430_USB0HS_STP); | ||
199 | #endif | ||
200 | |||
201 | /* We require some kind of external transceiver, hooked | 195 | /* We require some kind of external transceiver, hooked |
202 | * up through ULPI. TWL4030-family PMICs include one, | 196 | * up through ULPI. TWL4030-family PMICs include one, |
203 | * which needs a driver, drivers aren't always needed. | 197 | * which needs a driver, drivers aren't always needed. |
diff --git a/drivers/usb/otg/Kconfig b/drivers/usb/otg/Kconfig index 3d2d3e549bd1..3b1289572d72 100644 --- a/drivers/usb/otg/Kconfig +++ b/drivers/usb/otg/Kconfig | |||
@@ -49,8 +49,6 @@ config USB_ULPI | |||
49 | Enable this to support ULPI connected USB OTG transceivers which | 49 | Enable this to support ULPI connected USB OTG transceivers which |
50 | are likely found on embedded boards. | 50 | are likely found on embedded boards. |
51 | 51 | ||
52 | The only chip currently supported is NXP's ISP1504 | ||
53 | |||
54 | config TWL4030_USB | 52 | config TWL4030_USB |
55 | tristate "TWL4030 USB Transceiver Driver" | 53 | tristate "TWL4030 USB Transceiver Driver" |
56 | depends on TWL4030_CORE && REGULATOR_TWL4030 | 54 | depends on TWL4030_CORE && REGULATOR_TWL4030 |
diff --git a/drivers/usb/otg/ulpi.c b/drivers/usb/otg/ulpi.c index d331b222ad21..ccc81950822b 100644 --- a/drivers/usb/otg/ulpi.c +++ b/drivers/usb/otg/ulpi.c | |||
@@ -31,30 +31,110 @@ | |||
31 | 31 | ||
32 | #define ULPI_ID(vendor, product) (((vendor) << 16) | (product)) | 32 | #define ULPI_ID(vendor, product) (((vendor) << 16) | (product)) |
33 | 33 | ||
34 | #define TR_FLAG(flags, a, b) (((flags) & a) ? b : 0) | ||
35 | |||
36 | /* ULPI hardcoded IDs, used for probing */ | 34 | /* ULPI hardcoded IDs, used for probing */ |
37 | static unsigned int ulpi_ids[] = { | 35 | static unsigned int ulpi_ids[] = { |
38 | ULPI_ID(0x04cc, 0x1504), /* NXP ISP1504 */ | 36 | ULPI_ID(0x04cc, 0x1504), /* NXP ISP1504 */ |
37 | ULPI_ID(0x0424, 0x0006), /* SMSC USB3319 */ | ||
39 | }; | 38 | }; |
40 | 39 | ||
41 | static int ulpi_set_flags(struct otg_transceiver *otg) | 40 | static int ulpi_set_otg_flags(struct otg_transceiver *otg) |
42 | { | 41 | { |
43 | unsigned int flags = 0; | 42 | unsigned int flags = ULPI_OTG_CTRL_DP_PULLDOWN | |
43 | ULPI_OTG_CTRL_DM_PULLDOWN; | ||
44 | 44 | ||
45 | if (otg->flags & USB_OTG_PULLUP_ID) | 45 | if (otg->flags & ULPI_OTG_ID_PULLUP) |
46 | flags |= ULPI_OTG_CTRL_ID_PULLUP; | 46 | flags |= ULPI_OTG_CTRL_ID_PULLUP; |
47 | 47 | ||
48 | if (otg->flags & USB_OTG_PULLDOWN_DM) | 48 | /* |
49 | flags |= ULPI_OTG_CTRL_DM_PULLDOWN; | 49 | * ULPI Specification rev.1.1 default |
50 | * for Dp/DmPulldown is enabled. | ||
51 | */ | ||
52 | if (otg->flags & ULPI_OTG_DP_PULLDOWN_DIS) | ||
53 | flags &= ~ULPI_OTG_CTRL_DP_PULLDOWN; | ||
50 | 54 | ||
51 | if (otg->flags & USB_OTG_PULLDOWN_DP) | 55 | if (otg->flags & ULPI_OTG_DM_PULLDOWN_DIS) |
52 | flags |= ULPI_OTG_CTRL_DP_PULLDOWN; | 56 | flags &= ~ULPI_OTG_CTRL_DM_PULLDOWN; |
53 | 57 | ||
54 | if (otg->flags & USB_OTG_EXT_VBUS_INDICATOR) | 58 | if (otg->flags & ULPI_OTG_EXTVBUSIND) |
55 | flags |= ULPI_OTG_CTRL_EXTVBUSIND; | 59 | flags |= ULPI_OTG_CTRL_EXTVBUSIND; |
56 | 60 | ||
57 | return otg_io_write(otg, flags, ULPI_SET(ULPI_OTG_CTRL)); | 61 | return otg_io_write(otg, flags, ULPI_OTG_CTRL); |
62 | } | ||
63 | |||
64 | static int ulpi_set_fc_flags(struct otg_transceiver *otg) | ||
65 | { | ||
66 | unsigned int flags = 0; | ||
67 | |||
68 | /* | ||
69 | * ULPI Specification rev.1.1 default | ||
70 | * for XcvrSelect is Full Speed. | ||
71 | */ | ||
72 | if (otg->flags & ULPI_FC_HS) | ||
73 | flags |= ULPI_FUNC_CTRL_HIGH_SPEED; | ||
74 | else if (otg->flags & ULPI_FC_LS) | ||
75 | flags |= ULPI_FUNC_CTRL_LOW_SPEED; | ||
76 | else if (otg->flags & ULPI_FC_FS4LS) | ||
77 | flags |= ULPI_FUNC_CTRL_FS4LS; | ||
78 | else | ||
79 | flags |= ULPI_FUNC_CTRL_FULL_SPEED; | ||
80 | |||
81 | if (otg->flags & ULPI_FC_TERMSEL) | ||
82 | flags |= ULPI_FUNC_CTRL_TERMSELECT; | ||
83 | |||
84 | /* | ||
85 | * ULPI Specification rev.1.1 default | ||
86 | * for OpMode is Normal Operation. | ||
87 | */ | ||
88 | if (otg->flags & ULPI_FC_OP_NODRV) | ||
89 | flags |= ULPI_FUNC_CTRL_OPMODE_NONDRIVING; | ||
90 | else if (otg->flags & ULPI_FC_OP_DIS_NRZI) | ||
91 | flags |= ULPI_FUNC_CTRL_OPMODE_DISABLE_NRZI; | ||
92 | else if (otg->flags & ULPI_FC_OP_NSYNC_NEOP) | ||
93 | flags |= ULPI_FUNC_CTRL_OPMODE_NOSYNC_NOEOP; | ||
94 | else | ||
95 | flags |= ULPI_FUNC_CTRL_OPMODE_NORMAL; | ||
96 | |||
97 | /* | ||
98 | * ULPI Specification rev.1.1 default | ||
99 | * for SuspendM is Powered. | ||
100 | */ | ||
101 | flags |= ULPI_FUNC_CTRL_SUSPENDM; | ||
102 | |||
103 | return otg_io_write(otg, flags, ULPI_FUNC_CTRL); | ||
104 | } | ||
105 | |||
106 | static int ulpi_set_ic_flags(struct otg_transceiver *otg) | ||
107 | { | ||
108 | unsigned int flags = 0; | ||
109 | |||
110 | if (otg->flags & ULPI_IC_AUTORESUME) | ||
111 | flags |= ULPI_IFC_CTRL_AUTORESUME; | ||
112 | |||
113 | if (otg->flags & ULPI_IC_EXTVBUS_INDINV) | ||
114 | flags |= ULPI_IFC_CTRL_EXTERNAL_VBUS; | ||
115 | |||
116 | if (otg->flags & ULPI_IC_IND_PASSTHRU) | ||
117 | flags |= ULPI_IFC_CTRL_PASSTHRU; | ||
118 | |||
119 | if (otg->flags & ULPI_IC_PROTECT_DIS) | ||
120 | flags |= ULPI_IFC_CTRL_PROTECT_IFC_DISABLE; | ||
121 | |||
122 | return otg_io_write(otg, flags, ULPI_IFC_CTRL); | ||
123 | } | ||
124 | |||
125 | static int ulpi_set_flags(struct otg_transceiver *otg) | ||
126 | { | ||
127 | int ret; | ||
128 | |||
129 | ret = ulpi_set_otg_flags(otg); | ||
130 | if (ret) | ||
131 | return ret; | ||
132 | |||
133 | ret = ulpi_set_ic_flags(otg); | ||
134 | if (ret) | ||
135 | return ret; | ||
136 | |||
137 | return ulpi_set_fc_flags(otg); | ||
58 | } | 138 | } |
59 | 139 | ||
60 | static int ulpi_init(struct otg_transceiver *otg) | 140 | static int ulpi_init(struct otg_transceiver *otg) |
@@ -81,6 +161,31 @@ static int ulpi_init(struct otg_transceiver *otg) | |||
81 | return -ENODEV; | 161 | return -ENODEV; |
82 | } | 162 | } |
83 | 163 | ||
164 | static int ulpi_set_host(struct otg_transceiver *otg, struct usb_bus *host) | ||
165 | { | ||
166 | unsigned int flags = otg_io_read(otg, ULPI_IFC_CTRL); | ||
167 | |||
168 | if (!host) { | ||
169 | otg->host = NULL; | ||
170 | return 0; | ||
171 | } | ||
172 | |||
173 | otg->host = host; | ||
174 | |||
175 | flags &= ~(ULPI_IFC_CTRL_6_PIN_SERIAL_MODE | | ||
176 | ULPI_IFC_CTRL_3_PIN_SERIAL_MODE | | ||
177 | ULPI_IFC_CTRL_CARKITMODE); | ||
178 | |||
179 | if (otg->flags & ULPI_IC_6PIN_SERIAL) | ||
180 | flags |= ULPI_IFC_CTRL_6_PIN_SERIAL_MODE; | ||
181 | else if (otg->flags & ULPI_IC_3PIN_SERIAL) | ||
182 | flags |= ULPI_IFC_CTRL_3_PIN_SERIAL_MODE; | ||
183 | else if (otg->flags & ULPI_IC_CARKIT) | ||
184 | flags |= ULPI_IFC_CTRL_CARKITMODE; | ||
185 | |||
186 | return otg_io_write(otg, flags, ULPI_IFC_CTRL); | ||
187 | } | ||
188 | |||
84 | static int ulpi_set_vbus(struct otg_transceiver *otg, bool on) | 189 | static int ulpi_set_vbus(struct otg_transceiver *otg, bool on) |
85 | { | 190 | { |
86 | unsigned int flags = otg_io_read(otg, ULPI_OTG_CTRL); | 191 | unsigned int flags = otg_io_read(otg, ULPI_OTG_CTRL); |
@@ -88,14 +193,14 @@ static int ulpi_set_vbus(struct otg_transceiver *otg, bool on) | |||
88 | flags &= ~(ULPI_OTG_CTRL_DRVVBUS | ULPI_OTG_CTRL_DRVVBUS_EXT); | 193 | flags &= ~(ULPI_OTG_CTRL_DRVVBUS | ULPI_OTG_CTRL_DRVVBUS_EXT); |
89 | 194 | ||
90 | if (on) { | 195 | if (on) { |
91 | if (otg->flags & USB_OTG_DRV_VBUS) | 196 | if (otg->flags & ULPI_OTG_DRVVBUS) |
92 | flags |= ULPI_OTG_CTRL_DRVVBUS; | 197 | flags |= ULPI_OTG_CTRL_DRVVBUS; |
93 | 198 | ||
94 | if (otg->flags & USB_OTG_DRV_VBUS_EXT) | 199 | if (otg->flags & ULPI_OTG_DRVVBUS_EXT) |
95 | flags |= ULPI_OTG_CTRL_DRVVBUS_EXT; | 200 | flags |= ULPI_OTG_CTRL_DRVVBUS_EXT; |
96 | } | 201 | } |
97 | 202 | ||
98 | return otg_io_write(otg, flags, ULPI_SET(ULPI_OTG_CTRL)); | 203 | return otg_io_write(otg, flags, ULPI_OTG_CTRL); |
99 | } | 204 | } |
100 | 205 | ||
101 | struct otg_transceiver * | 206 | struct otg_transceiver * |
@@ -112,6 +217,7 @@ otg_ulpi_create(struct otg_io_access_ops *ops, | |||
112 | otg->flags = flags; | 217 | otg->flags = flags; |
113 | otg->io_ops = ops; | 218 | otg->io_ops = ops; |
114 | otg->init = ulpi_init; | 219 | otg->init = ulpi_init; |
220 | otg->set_host = ulpi_set_host; | ||
115 | otg->set_vbus = ulpi_set_vbus; | 221 | otg->set_vbus = ulpi_set_vbus; |
116 | 222 | ||
117 | return otg; | 223 | return otg; |
diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig index bd8aab0ef1cf..916b2b6d765f 100644 --- a/drivers/usb/serial/Kconfig +++ b/drivers/usb/serial/Kconfig | |||
@@ -642,6 +642,15 @@ config USB_SERIAL_ZIO | |||
642 | To compile this driver as a module, choose M here: the | 642 | To compile this driver as a module, choose M here: the |
643 | module will be called zio. | 643 | module will be called zio. |
644 | 644 | ||
645 | config USB_SERIAL_SSU100 | ||
646 | tristate "USB Quatech SSU-100 Single Port Serial Driver" | ||
647 | help | ||
648 | Say Y here if you want to use the Quatech SSU-100 single | ||
649 | port usb to serial adapter. | ||
650 | |||
651 | To compile this driver as a module, choose M here: the | ||
652 | module will be called ssu100. | ||
653 | |||
645 | config USB_SERIAL_DEBUG | 654 | config USB_SERIAL_DEBUG |
646 | tristate "USB Debugging Device" | 655 | tristate "USB Debugging Device" |
647 | help | 656 | help |
diff --git a/drivers/usb/serial/Makefile b/drivers/usb/serial/Makefile index e54c728c016e..40ebe17b6ea8 100644 --- a/drivers/usb/serial/Makefile +++ b/drivers/usb/serial/Makefile | |||
@@ -51,6 +51,7 @@ obj-$(CONFIG_USB_SERIAL_SAFE) += safe_serial.o | |||
51 | obj-$(CONFIG_USB_SERIAL_SIEMENS_MPI) += siemens_mpi.o | 51 | obj-$(CONFIG_USB_SERIAL_SIEMENS_MPI) += siemens_mpi.o |
52 | obj-$(CONFIG_USB_SERIAL_SIERRAWIRELESS) += sierra.o | 52 | obj-$(CONFIG_USB_SERIAL_SIERRAWIRELESS) += sierra.o |
53 | obj-$(CONFIG_USB_SERIAL_SPCP8X5) += spcp8x5.o | 53 | obj-$(CONFIG_USB_SERIAL_SPCP8X5) += spcp8x5.o |
54 | obj-$(CONFIG_USB_SERIAL_SSU100) += ssu100.o | ||
54 | obj-$(CONFIG_USB_SERIAL_SYMBOL) += symbolserial.o | 55 | obj-$(CONFIG_USB_SERIAL_SYMBOL) += symbolserial.o |
55 | obj-$(CONFIG_USB_SERIAL_WWAN) += usb_wwan.o | 56 | obj-$(CONFIG_USB_SERIAL_WWAN) += usb_wwan.o |
56 | obj-$(CONFIG_USB_SERIAL_TI) += ti_usb_3410_5052.o | 57 | obj-$(CONFIG_USB_SERIAL_TI) += ti_usb_3410_5052.o |
diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c index 8b8c7976b4c0..2bef4415c19c 100644 --- a/drivers/usb/serial/cp210x.c +++ b/drivers/usb/serial/cp210x.c | |||
@@ -126,6 +126,10 @@ static const struct usb_device_id id_table[] = { | |||
126 | { USB_DEVICE(0x1843, 0x0200) }, /* Vaisala USB Instrument Cable */ | 126 | { USB_DEVICE(0x1843, 0x0200) }, /* Vaisala USB Instrument Cable */ |
127 | { USB_DEVICE(0x18EF, 0xE00F) }, /* ELV USB-I2C-Interface */ | 127 | { USB_DEVICE(0x18EF, 0xE00F) }, /* ELV USB-I2C-Interface */ |
128 | { USB_DEVICE(0x413C, 0x9500) }, /* DW700 GPS USB interface */ | 128 | { USB_DEVICE(0x413C, 0x9500) }, /* DW700 GPS USB interface */ |
129 | { USB_DEVICE(0x16DC, 0x0010) }, /* W-IE-NE-R Plein & Baus GmbH PL512 Power Supply */ | ||
130 | { USB_DEVICE(0x16DC, 0x0011) }, /* W-IE-NE-R Plein & Baus GmbH RCM Remote Control for MARATON Power Supply */ | ||
131 | { USB_DEVICE(0x16DC, 0x0012) }, /* W-IE-NE-R Plein & Baus GmbH MPOD Multi Channel Power Supply */ | ||
132 | { USB_DEVICE(0x16DC, 0x0015) }, /* W-IE-NE-R Plein & Baus GmbH CML Control, Monitoring and Data Logger */ | ||
129 | { } /* Terminating Entry */ | 133 | { } /* Terminating Entry */ |
130 | }; | 134 | }; |
131 | 135 | ||
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index e298dc4baed7..eb12d9b096b4 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c | |||
@@ -157,6 +157,9 @@ static struct usb_device_id id_table_combined [] = { | |||
157 | { USB_DEVICE(FTDI_VID, FTDI_SCS_DEVICE_5_PID) }, | 157 | { USB_DEVICE(FTDI_VID, FTDI_SCS_DEVICE_5_PID) }, |
158 | { USB_DEVICE(FTDI_VID, FTDI_SCS_DEVICE_6_PID) }, | 158 | { USB_DEVICE(FTDI_VID, FTDI_SCS_DEVICE_6_PID) }, |
159 | { USB_DEVICE(FTDI_VID, FTDI_SCS_DEVICE_7_PID) }, | 159 | { USB_DEVICE(FTDI_VID, FTDI_SCS_DEVICE_7_PID) }, |
160 | { USB_DEVICE(FTDI_VID, FTDI_USINT_CAT_PID) }, | ||
161 | { USB_DEVICE(FTDI_VID, FTDI_USINT_WKEY_PID) }, | ||
162 | { USB_DEVICE(FTDI_VID, FTDI_USINT_RS232_PID) }, | ||
160 | { USB_DEVICE(FTDI_VID, FTDI_ACTZWAVE_PID) }, | 163 | { USB_DEVICE(FTDI_VID, FTDI_ACTZWAVE_PID) }, |
161 | { USB_DEVICE(FTDI_VID, FTDI_IRTRANS_PID) }, | 164 | { USB_DEVICE(FTDI_VID, FTDI_IRTRANS_PID) }, |
162 | { USB_DEVICE(FTDI_VID, FTDI_IPLUS_PID) }, | 165 | { USB_DEVICE(FTDI_VID, FTDI_IPLUS_PID) }, |
@@ -746,6 +749,7 @@ static struct usb_device_id id_table_combined [] = { | |||
746 | .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, | 749 | .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, |
747 | { USB_DEVICE(FTDI_VID, XVERVE_SIGNALYZER_SH4_PID), | 750 | { USB_DEVICE(FTDI_VID, XVERVE_SIGNALYZER_SH4_PID), |
748 | .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, | 751 | .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, |
752 | { USB_DEVICE(FTDI_VID, SEGWAY_RMP200_PID) }, | ||
749 | { }, /* Optional parameter entry */ | 753 | { }, /* Optional parameter entry */ |
750 | { } /* Terminating entry */ | 754 | { } /* Terminating entry */ |
751 | }; | 755 | }; |
diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h index d01946db8fac..6e612c52e763 100644 --- a/drivers/usb/serial/ftdi_sio_ids.h +++ b/drivers/usb/serial/ftdi_sio_ids.h | |||
@@ -40,6 +40,11 @@ | |||
40 | 40 | ||
41 | #define FTDI_NXTCAM_PID 0xABB8 /* NXTCam for Mindstorms NXT */ | 41 | #define FTDI_NXTCAM_PID 0xABB8 /* NXTCam for Mindstorms NXT */ |
42 | 42 | ||
43 | /* US Interface Navigator (http://www.usinterface.com/) */ | ||
44 | #define FTDI_USINT_CAT_PID 0xb810 /* Navigator CAT and 2nd PTT lines */ | ||
45 | #define FTDI_USINT_WKEY_PID 0xb811 /* Navigator WKEY and FSK lines */ | ||
46 | #define FTDI_USINT_RS232_PID 0xb812 /* Navigator RS232 and CONFIG lines */ | ||
47 | |||
43 | /* OOCDlink by Joern Kaipf <joernk@web.de> | 48 | /* OOCDlink by Joern Kaipf <joernk@web.de> |
44 | * (http://www.joernonline.de/dw/doku.php?id=start&idx=projects:oocdlink) */ | 49 | * (http://www.joernonline.de/dw/doku.php?id=start&idx=projects:oocdlink) */ |
45 | #define FTDI_OOCDLINK_PID 0xbaf8 /* Amontec JTAGkey */ | 50 | #define FTDI_OOCDLINK_PID 0xbaf8 /* Amontec JTAGkey */ |
@@ -1032,3 +1037,8 @@ | |||
1032 | #define XVERVE_SIGNALYZER_SH2_PID 0xBCA2 | 1037 | #define XVERVE_SIGNALYZER_SH2_PID 0xBCA2 |
1033 | #define XVERVE_SIGNALYZER_SH4_PID 0xBCA4 | 1038 | #define XVERVE_SIGNALYZER_SH4_PID 0xBCA4 |
1034 | 1039 | ||
1040 | /* | ||
1041 | * Segway Robotic Mobility Platform USB interface (using VID 0x0403) | ||
1042 | * Submitted by John G. Rogers | ||
1043 | */ | ||
1044 | #define SEGWAY_RMP200_PID 0xe729 | ||
diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c index a817ced82835..ca92f67747cc 100644 --- a/drivers/usb/serial/generic.c +++ b/drivers/usb/serial/generic.c | |||
@@ -208,18 +208,23 @@ retry: | |||
208 | urb->transfer_buffer_length = count; | 208 | urb->transfer_buffer_length = count; |
209 | usb_serial_debug_data(debug, &port->dev, __func__, count, | 209 | usb_serial_debug_data(debug, &port->dev, __func__, count, |
210 | urb->transfer_buffer); | 210 | urb->transfer_buffer); |
211 | spin_lock_irqsave(&port->lock, flags); | ||
212 | port->tx_bytes += count; | ||
213 | spin_unlock_irqrestore(&port->lock, flags); | ||
214 | |||
215 | clear_bit(i, &port->write_urbs_free); | ||
211 | result = usb_submit_urb(urb, GFP_ATOMIC); | 216 | result = usb_submit_urb(urb, GFP_ATOMIC); |
212 | if (result) { | 217 | if (result) { |
213 | dev_err(&port->dev, "%s - error submitting urb: %d\n", | 218 | dev_err(&port->dev, "%s - error submitting urb: %d\n", |
214 | __func__, result); | 219 | __func__, result); |
220 | set_bit(i, &port->write_urbs_free); | ||
221 | spin_lock_irqsave(&port->lock, flags); | ||
222 | port->tx_bytes -= count; | ||
223 | spin_unlock_irqrestore(&port->lock, flags); | ||
224 | |||
215 | clear_bit_unlock(USB_SERIAL_WRITE_BUSY, &port->flags); | 225 | clear_bit_unlock(USB_SERIAL_WRITE_BUSY, &port->flags); |
216 | return result; | 226 | return result; |
217 | } | 227 | } |
218 | clear_bit(i, &port->write_urbs_free); | ||
219 | |||
220 | spin_lock_irqsave(&port->lock, flags); | ||
221 | port->tx_bytes += count; | ||
222 | spin_unlock_irqrestore(&port->lock, flags); | ||
223 | 228 | ||
224 | /* Try sending off another urb, unless in irq context (in which case | 229 | /* Try sending off another urb, unless in irq context (in which case |
225 | * there will be no free urb). */ | 230 | * there will be no free urb). */ |
diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c index 0fca2659206f..dc47f986df57 100644 --- a/drivers/usb/serial/io_ti.c +++ b/drivers/usb/serial/io_ti.c | |||
@@ -1298,7 +1298,7 @@ static int download_fw(struct edgeport_serial *serial) | |||
1298 | kfree(header); | 1298 | kfree(header); |
1299 | kfree(rom_desc); | 1299 | kfree(rom_desc); |
1300 | kfree(ti_manuf_desc); | 1300 | kfree(ti_manuf_desc); |
1301 | return status; | 1301 | return -EINVAL; |
1302 | } | 1302 | } |
1303 | 1303 | ||
1304 | /* verify the write -- must do this in order for | 1304 | /* verify the write -- must do this in order for |
@@ -1321,7 +1321,7 @@ static int download_fw(struct edgeport_serial *serial) | |||
1321 | kfree(header); | 1321 | kfree(header); |
1322 | kfree(rom_desc); | 1322 | kfree(rom_desc); |
1323 | kfree(ti_manuf_desc); | 1323 | kfree(ti_manuf_desc); |
1324 | return status; | 1324 | return -EINVAL; |
1325 | } | 1325 | } |
1326 | 1326 | ||
1327 | kfree(vheader); | 1327 | kfree(vheader); |
diff --git a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c index 28913fa95fb7..4735931b4c7b 100644 --- a/drivers/usb/serial/ipaq.c +++ b/drivers/usb/serial/ipaq.c | |||
@@ -534,7 +534,6 @@ static struct usb_device_id ipaq_id_table [] = { | |||
534 | { USB_DEVICE(0x413C, 0x4009) }, /* Dell Axim USB Sync */ | 534 | { USB_DEVICE(0x413C, 0x4009) }, /* Dell Axim USB Sync */ |
535 | { USB_DEVICE(0x4505, 0x0010) }, /* Smartphone */ | 535 | { USB_DEVICE(0x4505, 0x0010) }, /* Smartphone */ |
536 | { USB_DEVICE(0x5E04, 0xCE00) }, /* SAGEM Wireless Assistant */ | 536 | { USB_DEVICE(0x5E04, 0xCE00) }, /* SAGEM Wireless Assistant */ |
537 | { USB_DEVICE(0x0BB4, 0x00CF) }, /* HTC smartphone modems */ | ||
538 | { } /* Terminating entry */ | 537 | { } /* Terminating entry */ |
539 | }; | 538 | }; |
540 | 539 | ||
diff --git a/drivers/usb/serial/iuu_phoenix.c b/drivers/usb/serial/iuu_phoenix.c index 74551cb2e8ee..efc72113216b 100644 --- a/drivers/usb/serial/iuu_phoenix.c +++ b/drivers/usb/serial/iuu_phoenix.c | |||
@@ -1,6 +1,8 @@ | |||
1 | /* | 1 | /* |
2 | * Infinity Unlimited USB Phoenix driver | 2 | * Infinity Unlimited USB Phoenix driver |
3 | * | 3 | * |
4 | * Copyright (C) 2010 James Courtier-Dutton (James@superbug.co.uk) | ||
5 | |||
4 | * Copyright (C) 2007 Alain Degreffe (eczema@ecze.com) | 6 | * Copyright (C) 2007 Alain Degreffe (eczema@ecze.com) |
5 | * | 7 | * |
6 | * Original code taken from iuutool (Copyright (C) 2006 Juan Carlos Borrás) | 8 | * Original code taken from iuutool (Copyright (C) 2006 Juan Carlos Borrás) |
@@ -40,7 +42,7 @@ static int debug; | |||
40 | /* | 42 | /* |
41 | * Version Information | 43 | * Version Information |
42 | */ | 44 | */ |
43 | #define DRIVER_VERSION "v0.11" | 45 | #define DRIVER_VERSION "v0.12" |
44 | #define DRIVER_DESC "Infinity USB Unlimited Phoenix driver" | 46 | #define DRIVER_DESC "Infinity USB Unlimited Phoenix driver" |
45 | 47 | ||
46 | static const struct usb_device_id id_table[] = { | 48 | static const struct usb_device_id id_table[] = { |
@@ -81,6 +83,9 @@ struct iuu_private { | |||
81 | u8 *dbgbuf; /* debug buffer */ | 83 | u8 *dbgbuf; /* debug buffer */ |
82 | u8 len; | 84 | u8 len; |
83 | int vcc; /* vcc (either 3 or 5 V) */ | 85 | int vcc; /* vcc (either 3 or 5 V) */ |
86 | u32 baud; | ||
87 | u32 boost; | ||
88 | u32 clk; | ||
84 | }; | 89 | }; |
85 | 90 | ||
86 | 91 | ||
@@ -157,13 +162,14 @@ static int iuu_tiocmset(struct tty_struct *tty, struct file *file, | |||
157 | port->number, set, clear); | 162 | port->number, set, clear); |
158 | 163 | ||
159 | spin_lock_irqsave(&priv->lock, flags); | 164 | spin_lock_irqsave(&priv->lock, flags); |
160 | if (set & TIOCM_RTS) | ||
161 | priv->tiostatus = TIOCM_RTS; | ||
162 | 165 | ||
163 | if (!(set & TIOCM_RTS) && priv->tiostatus == TIOCM_RTS) { | 166 | if ((set & TIOCM_RTS) && !(priv->tiostatus == TIOCM_RTS)) { |
164 | dbg("%s TIOCMSET RESET called !!!", __func__); | 167 | dbg("%s TIOCMSET RESET called !!!", __func__); |
165 | priv->reset = 1; | 168 | priv->reset = 1; |
166 | } | 169 | } |
170 | if (set & TIOCM_RTS) | ||
171 | priv->tiostatus = TIOCM_RTS; | ||
172 | |||
167 | spin_unlock_irqrestore(&priv->lock, flags); | 173 | spin_unlock_irqrestore(&priv->lock, flags); |
168 | return 0; | 174 | return 0; |
169 | } | 175 | } |
@@ -851,20 +857,24 @@ static int iuu_uart_off(struct usb_serial_port *port) | |||
851 | return status; | 857 | return status; |
852 | } | 858 | } |
853 | 859 | ||
854 | static int iuu_uart_baud(struct usb_serial_port *port, u32 baud, | 860 | static int iuu_uart_baud(struct usb_serial_port *port, u32 baud_base, |
855 | u32 *actual, u8 parity) | 861 | u32 *actual, u8 parity) |
856 | { | 862 | { |
857 | int status; | 863 | int status; |
864 | u32 baud; | ||
858 | u8 *dataout; | 865 | u8 *dataout; |
859 | u8 DataCount = 0; | 866 | u8 DataCount = 0; |
860 | u8 T1Frekvens = 0; | 867 | u8 T1Frekvens = 0; |
861 | u8 T1reload = 0; | 868 | u8 T1reload = 0; |
862 | unsigned int T1FrekvensHZ = 0; | 869 | unsigned int T1FrekvensHZ = 0; |
863 | 870 | ||
871 | dbg("%s - enter baud_base=%d", __func__, baud_base); | ||
864 | dataout = kmalloc(sizeof(u8) * 5, GFP_KERNEL); | 872 | dataout = kmalloc(sizeof(u8) * 5, GFP_KERNEL); |
865 | 873 | ||
866 | if (!dataout) | 874 | if (!dataout) |
867 | return -ENOMEM; | 875 | return -ENOMEM; |
876 | /*baud = (((priv->clk / 35) * baud_base) / 100000); */ | ||
877 | baud = baud_base; | ||
868 | 878 | ||
869 | if (baud < 1200 || baud > 230400) { | 879 | if (baud < 1200 || baud > 230400) { |
870 | kfree(dataout); | 880 | kfree(dataout); |
@@ -948,15 +958,20 @@ static void iuu_set_termios(struct tty_struct *tty, | |||
948 | struct usb_serial_port *port, struct ktermios *old_termios) | 958 | struct usb_serial_port *port, struct ktermios *old_termios) |
949 | { | 959 | { |
950 | const u32 supported_mask = CMSPAR|PARENB|PARODD; | 960 | const u32 supported_mask = CMSPAR|PARENB|PARODD; |
951 | 961 | struct iuu_private *priv = usb_get_serial_port_data(port); | |
952 | unsigned int cflag = tty->termios->c_cflag; | 962 | unsigned int cflag = tty->termios->c_cflag; |
953 | int status; | 963 | int status; |
954 | u32 actual; | 964 | u32 actual; |
955 | u32 parity; | 965 | u32 parity; |
956 | int csize = CS7; | 966 | int csize = CS7; |
957 | int baud = 9600; /* Fixed for the moment */ | 967 | int baud; |
958 | u32 newval = cflag & supported_mask; | 968 | u32 newval = cflag & supported_mask; |
959 | 969 | ||
970 | /* Just use the ospeed. ispeed should be the same. */ | ||
971 | baud = tty->termios->c_ospeed; | ||
972 | |||
973 | dbg("%s - enter c_ospeed or baud=%d", __func__, baud); | ||
974 | |||
960 | /* compute the parity parameter */ | 975 | /* compute the parity parameter */ |
961 | parity = 0; | 976 | parity = 0; |
962 | if (cflag & CMSPAR) { /* Using mark space */ | 977 | if (cflag & CMSPAR) { /* Using mark space */ |
@@ -976,15 +991,15 @@ static void iuu_set_termios(struct tty_struct *tty, | |||
976 | 991 | ||
977 | /* set it */ | 992 | /* set it */ |
978 | status = iuu_uart_baud(port, | 993 | status = iuu_uart_baud(port, |
979 | (clockmode == 2) ? 16457 : 9600 * boost / 100, | 994 | baud * priv->boost / 100, |
980 | &actual, parity); | 995 | &actual, parity); |
981 | 996 | ||
982 | /* set the termios value to the real one, so the user now what has | 997 | /* set the termios value to the real one, so the user now what has |
983 | * changed. We support few fields so its easies to copy the old hw | 998 | * changed. We support few fields so its easies to copy the old hw |
984 | * settings back over and then adjust them | 999 | * settings back over and then adjust them |
985 | */ | 1000 | */ |
986 | if (old_termios) | 1001 | if (old_termios) |
987 | tty_termios_copy_hw(tty->termios, old_termios); | 1002 | tty_termios_copy_hw(tty->termios, old_termios); |
988 | if (status != 0) /* Set failed - return old bits */ | 1003 | if (status != 0) /* Set failed - return old bits */ |
989 | return; | 1004 | return; |
990 | /* Re-encode speed, parity and csize */ | 1005 | /* Re-encode speed, parity and csize */ |
@@ -1018,6 +1033,7 @@ static void iuu_close(struct usb_serial_port *port) | |||
1018 | 1033 | ||
1019 | static void iuu_init_termios(struct tty_struct *tty) | 1034 | static void iuu_init_termios(struct tty_struct *tty) |
1020 | { | 1035 | { |
1036 | dbg("%s - enter", __func__); | ||
1021 | *(tty->termios) = tty_std_termios; | 1037 | *(tty->termios) = tty_std_termios; |
1022 | tty->termios->c_cflag = CLOCAL | CREAD | CS8 | B9600 | 1038 | tty->termios->c_cflag = CLOCAL | CREAD | CS8 | B9600 |
1023 | | TIOCM_CTS | CSTOPB | PARENB; | 1039 | | TIOCM_CTS | CSTOPB | PARENB; |
@@ -1033,10 +1049,16 @@ static int iuu_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
1033 | struct usb_serial *serial = port->serial; | 1049 | struct usb_serial *serial = port->serial; |
1034 | u8 *buf; | 1050 | u8 *buf; |
1035 | int result; | 1051 | int result; |
1052 | int baud; | ||
1036 | u32 actual; | 1053 | u32 actual; |
1037 | struct iuu_private *priv = usb_get_serial_port_data(port); | 1054 | struct iuu_private *priv = usb_get_serial_port_data(port); |
1038 | 1055 | ||
1039 | dbg("%s - port %d", __func__, port->number); | 1056 | baud = tty->termios->c_ospeed; |
1057 | tty->termios->c_ispeed = baud; | ||
1058 | /* Re-encode speed */ | ||
1059 | tty_encode_baud_rate(tty, baud, baud); | ||
1060 | |||
1061 | dbg("%s - port %d, baud %d", __func__, port->number, baud); | ||
1040 | usb_clear_halt(serial->dev, port->write_urb->pipe); | 1062 | usb_clear_halt(serial->dev, port->write_urb->pipe); |
1041 | usb_clear_halt(serial->dev, port->read_urb->pipe); | 1063 | usb_clear_halt(serial->dev, port->read_urb->pipe); |
1042 | 1064 | ||
@@ -1071,23 +1093,29 @@ static int iuu_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
1071 | iuu_uart_on(port); | 1093 | iuu_uart_on(port); |
1072 | if (boost < 100) | 1094 | if (boost < 100) |
1073 | boost = 100; | 1095 | boost = 100; |
1096 | priv->boost = boost; | ||
1097 | priv->baud = baud; | ||
1074 | switch (clockmode) { | 1098 | switch (clockmode) { |
1075 | case 2: /* 3.680 Mhz */ | 1099 | case 2: /* 3.680 Mhz */ |
1100 | priv->clk = IUU_CLK_3680000; | ||
1076 | iuu_clk(port, IUU_CLK_3680000 * boost / 100); | 1101 | iuu_clk(port, IUU_CLK_3680000 * boost / 100); |
1077 | result = | 1102 | result = |
1078 | iuu_uart_baud(port, 9600 * boost / 100, &actual, | 1103 | iuu_uart_baud(port, baud * boost / 100, &actual, |
1079 | IUU_PARITY_EVEN); | 1104 | IUU_PARITY_EVEN); |
1080 | break; | 1105 | break; |
1081 | case 3: /* 6.00 Mhz */ | 1106 | case 3: /* 6.00 Mhz */ |
1082 | iuu_clk(port, IUU_CLK_6000000 * boost / 100); | 1107 | iuu_clk(port, IUU_CLK_6000000 * boost / 100); |
1108 | priv->clk = IUU_CLK_6000000; | ||
1109 | /* Ratio of 6000000 to 3500000 for baud 9600 */ | ||
1083 | result = | 1110 | result = |
1084 | iuu_uart_baud(port, 16457 * boost / 100, &actual, | 1111 | iuu_uart_baud(port, 16457 * boost / 100, &actual, |
1085 | IUU_PARITY_EVEN); | 1112 | IUU_PARITY_EVEN); |
1086 | break; | 1113 | break; |
1087 | default: /* 3.579 Mhz */ | 1114 | default: /* 3.579 Mhz */ |
1088 | iuu_clk(port, IUU_CLK_3579000 * boost / 100); | 1115 | iuu_clk(port, IUU_CLK_3579000 * boost / 100); |
1116 | priv->clk = IUU_CLK_3579000; | ||
1089 | result = | 1117 | result = |
1090 | iuu_uart_baud(port, 9600 * boost / 100, &actual, | 1118 | iuu_uart_baud(port, baud * boost / 100, &actual, |
1091 | IUU_PARITY_EVEN); | 1119 | IUU_PARITY_EVEN); |
1092 | } | 1120 | } |
1093 | 1121 | ||
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index 5cd30e4345c6..9fc6ea2c681f 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c | |||
@@ -145,7 +145,10 @@ static void option_instat_callback(struct urb *urb); | |||
145 | #define HUAWEI_PRODUCT_E143D 0x143D | 145 | #define HUAWEI_PRODUCT_E143D 0x143D |
146 | #define HUAWEI_PRODUCT_E143E 0x143E | 146 | #define HUAWEI_PRODUCT_E143E 0x143E |
147 | #define HUAWEI_PRODUCT_E143F 0x143F | 147 | #define HUAWEI_PRODUCT_E143F 0x143F |
148 | #define HUAWEI_PRODUCT_K4505 0x1464 | ||
149 | #define HUAWEI_PRODUCT_K3765 0x1465 | ||
148 | #define HUAWEI_PRODUCT_E14AC 0x14AC | 150 | #define HUAWEI_PRODUCT_E14AC 0x14AC |
151 | #define HUAWEI_PRODUCT_ETS1220 0x1803 | ||
149 | 152 | ||
150 | #define QUANTA_VENDOR_ID 0x0408 | 153 | #define QUANTA_VENDOR_ID 0x0408 |
151 | #define QUANTA_PRODUCT_Q101 0xEA02 | 154 | #define QUANTA_PRODUCT_Q101 0xEA02 |
@@ -264,9 +267,6 @@ static void option_instat_callback(struct urb *urb); | |||
264 | #define BANDRICH_PRODUCT_1011 0x1011 | 267 | #define BANDRICH_PRODUCT_1011 0x1011 |
265 | #define BANDRICH_PRODUCT_1012 0x1012 | 268 | #define BANDRICH_PRODUCT_1012 0x1012 |
266 | 269 | ||
267 | #define AMOI_VENDOR_ID 0x1614 | ||
268 | #define AMOI_PRODUCT_9508 0x0800 | ||
269 | |||
270 | #define QUALCOMM_VENDOR_ID 0x05C6 | 270 | #define QUALCOMM_VENDOR_ID 0x05C6 |
271 | 271 | ||
272 | #define CMOTECH_VENDOR_ID 0x16d8 | 272 | #define CMOTECH_VENDOR_ID 0x16d8 |
@@ -482,8 +482,10 @@ static const struct usb_device_id option_ids[] = { | |||
482 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E143D, 0xff, 0xff, 0xff) }, | 482 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E143D, 0xff, 0xff, 0xff) }, |
483 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E143E, 0xff, 0xff, 0xff) }, | 483 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E143E, 0xff, 0xff, 0xff) }, |
484 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E143F, 0xff, 0xff, 0xff) }, | 484 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E143F, 0xff, 0xff, 0xff) }, |
485 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_K4505, 0xff, 0xff, 0xff) }, | ||
486 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_K3765, 0xff, 0xff, 0xff) }, | ||
487 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_ETS1220, 0xff, 0xff, 0xff) }, | ||
485 | { USB_DEVICE(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E14AC) }, | 488 | { USB_DEVICE(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E14AC) }, |
486 | { USB_DEVICE(AMOI_VENDOR_ID, AMOI_PRODUCT_9508) }, | ||
487 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_V640) }, /* Novatel Merlin V640/XV620 */ | 489 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_V640) }, /* Novatel Merlin V640/XV620 */ |
488 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_V620) }, /* Novatel Merlin V620/S620 */ | 490 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_V620) }, /* Novatel Merlin V620/S620 */ |
489 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_V740) }, /* Novatel Merlin EX720/V740/X720 */ | 491 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_V740) }, /* Novatel Merlin EX720/V740/X720 */ |
@@ -1017,6 +1019,13 @@ static int option_probe(struct usb_serial *serial, | |||
1017 | serial->interface->cur_altsetting->desc.bInterfaceClass != 0xff) | 1019 | serial->interface->cur_altsetting->desc.bInterfaceClass != 0xff) |
1018 | return -ENODEV; | 1020 | return -ENODEV; |
1019 | 1021 | ||
1022 | /* Don't bind network interfaces on Huawei K3765 & K4505 */ | ||
1023 | if (serial->dev->descriptor.idVendor == HUAWEI_VENDOR_ID && | ||
1024 | (serial->dev->descriptor.idProduct == HUAWEI_PRODUCT_K3765 || | ||
1025 | serial->dev->descriptor.idProduct == HUAWEI_PRODUCT_K4505) && | ||
1026 | serial->interface->cur_altsetting->desc.bInterfaceNumber == 1) | ||
1027 | return -ENODEV; | ||
1028 | |||
1020 | data = serial->private = kzalloc(sizeof(struct usb_wwan_intf_private), GFP_KERNEL); | 1029 | data = serial->private = kzalloc(sizeof(struct usb_wwan_intf_private), GFP_KERNEL); |
1021 | 1030 | ||
1022 | if (!data) | 1031 | if (!data) |
diff --git a/drivers/usb/serial/ssu100.c b/drivers/usb/serial/ssu100.c new file mode 100644 index 000000000000..6e82d4f54bc8 --- /dev/null +++ b/drivers/usb/serial/ssu100.c | |||
@@ -0,0 +1,698 @@ | |||
1 | /* | ||
2 | * usb-serial driver for Quatech SSU-100 | ||
3 | * | ||
4 | * based on ftdi_sio.c and the original serqt_usb.c from Quatech | ||
5 | * | ||
6 | */ | ||
7 | |||
8 | #include <linux/errno.h> | ||
9 | #include <linux/init.h> | ||
10 | #include <linux/slab.h> | ||
11 | #include <linux/tty.h> | ||
12 | #include <linux/tty_driver.h> | ||
13 | #include <linux/tty_flip.h> | ||
14 | #include <linux/module.h> | ||
15 | #include <linux/serial.h> | ||
16 | #include <linux/usb.h> | ||
17 | #include <linux/usb/serial.h> | ||
18 | #include <linux/uaccess.h> | ||
19 | |||
20 | #define QT_OPEN_CLOSE_CHANNEL 0xca | ||
21 | #define QT_SET_GET_DEVICE 0xc2 | ||
22 | #define QT_SET_GET_REGISTER 0xc0 | ||
23 | #define QT_GET_SET_PREBUF_TRIG_LVL 0xcc | ||
24 | #define QT_SET_ATF 0xcd | ||
25 | #define QT_GET_SET_UART 0xc1 | ||
26 | #define QT_TRANSFER_IN 0xc0 | ||
27 | #define QT_HW_FLOW_CONTROL_MASK 0xc5 | ||
28 | #define QT_SW_FLOW_CONTROL_MASK 0xc6 | ||
29 | |||
30 | #define MODEM_CTL_REGISTER 0x04 | ||
31 | #define MODEM_STATUS_REGISTER 0x06 | ||
32 | |||
33 | |||
34 | #define SERIAL_LSR_OE 0x02 | ||
35 | #define SERIAL_LSR_PE 0x04 | ||
36 | #define SERIAL_LSR_FE 0x08 | ||
37 | #define SERIAL_LSR_BI 0x10 | ||
38 | |||
39 | #define SERIAL_LSR_TEMT 0x40 | ||
40 | |||
41 | #define SERIAL_MCR_DTR 0x01 | ||
42 | #define SERIAL_MCR_RTS 0x02 | ||
43 | #define SERIAL_MCR_LOOP 0x10 | ||
44 | |||
45 | #define SERIAL_MSR_CTS 0x10 | ||
46 | #define SERIAL_MSR_CD 0x80 | ||
47 | #define SERIAL_MSR_RI 0x40 | ||
48 | #define SERIAL_MSR_DSR 0x20 | ||
49 | #define SERIAL_MSR_MASK 0xf0 | ||
50 | |||
51 | #define SERIAL_CRTSCTS ((SERIAL_MCR_RTS << 8) | SERIAL_MSR_CTS) | ||
52 | |||
53 | #define SERIAL_8_DATA 0x03 | ||
54 | #define SERIAL_7_DATA 0x02 | ||
55 | #define SERIAL_6_DATA 0x01 | ||
56 | #define SERIAL_5_DATA 0x00 | ||
57 | |||
58 | #define SERIAL_ODD_PARITY 0X08 | ||
59 | #define SERIAL_EVEN_PARITY 0X18 | ||
60 | |||
61 | #define MAX_BAUD_RATE 460800 | ||
62 | |||
63 | #define ATC_DISABLED 0x00 | ||
64 | #define DUPMODE_BITS 0xc0 | ||
65 | #define RR_BITS 0x03 | ||
66 | #define LOOPMODE_BITS 0x41 | ||
67 | #define RS232_MODE 0x00 | ||
68 | #define RTSCTS_TO_CONNECTOR 0x40 | ||
69 | #define CLKS_X4 0x02 | ||
70 | #define FULLPWRBIT 0x00000080 | ||
71 | #define NEXT_BOARD_POWER_BIT 0x00000004 | ||
72 | |||
73 | static int debug = 1; | ||
74 | |||
75 | /* Version Information */ | ||
76 | #define DRIVER_VERSION "v0.1" | ||
77 | #define DRIVER_DESC "Quatech SSU-100 USB to Serial Driver" | ||
78 | |||
79 | #define USB_VENDOR_ID_QUATECH 0x061d /* Quatech VID */ | ||
80 | #define QUATECH_SSU100 0xC020 /* SSU100 */ | ||
81 | |||
82 | static const struct usb_device_id id_table[] = { | ||
83 | {USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_SSU100)}, | ||
84 | {} /* Terminating entry */ | ||
85 | }; | ||
86 | |||
87 | MODULE_DEVICE_TABLE(usb, id_table); | ||
88 | |||
89 | |||
90 | static struct usb_driver ssu100_driver = { | ||
91 | .name = "ssu100", | ||
92 | .probe = usb_serial_probe, | ||
93 | .disconnect = usb_serial_disconnect, | ||
94 | .id_table = id_table, | ||
95 | .suspend = usb_serial_suspend, | ||
96 | .resume = usb_serial_resume, | ||
97 | .no_dynamic_id = 1, | ||
98 | .supports_autosuspend = 1, | ||
99 | }; | ||
100 | |||
101 | struct ssu100_port_private { | ||
102 | u8 shadowLSR; | ||
103 | u8 shadowMSR; | ||
104 | wait_queue_head_t delta_msr_wait; /* Used for TIOCMIWAIT */ | ||
105 | unsigned short max_packet_size; | ||
106 | }; | ||
107 | |||
108 | static void ssu100_release(struct usb_serial *serial) | ||
109 | { | ||
110 | struct ssu100_port_private *priv = usb_get_serial_port_data(*serial->port); | ||
111 | |||
112 | dbg("%s", __func__); | ||
113 | kfree(priv); | ||
114 | } | ||
115 | |||
116 | static inline int ssu100_control_msg(struct usb_device *dev, | ||
117 | u8 request, u16 data, u16 index) | ||
118 | { | ||
119 | return usb_control_msg(dev, usb_sndctrlpipe(dev, 0), | ||
120 | request, 0x40, data, index, | ||
121 | NULL, 0, 300); | ||
122 | } | ||
123 | |||
124 | static inline int ssu100_setdevice(struct usb_device *dev, u8 *data) | ||
125 | { | ||
126 | u16 x = ((u16)(data[1] << 8) | (u16)(data[0])); | ||
127 | |||
128 | return ssu100_control_msg(dev, QT_SET_GET_DEVICE, x, 0); | ||
129 | } | ||
130 | |||
131 | |||
132 | static inline int ssu100_getdevice(struct usb_device *dev, u8 *data) | ||
133 | { | ||
134 | return usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), | ||
135 | QT_SET_GET_DEVICE, 0xc0, 0, 0, | ||
136 | data, 3, 300); | ||
137 | } | ||
138 | |||
139 | static inline int ssu100_getregister(struct usb_device *dev, | ||
140 | unsigned short uart, | ||
141 | unsigned short reg, | ||
142 | u8 *data) | ||
143 | { | ||
144 | return usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), | ||
145 | QT_SET_GET_REGISTER, 0xc0, reg, | ||
146 | uart, data, sizeof(*data), 300); | ||
147 | |||
148 | } | ||
149 | |||
150 | |||
151 | static inline int ssu100_setregister(struct usb_device *dev, | ||
152 | unsigned short uart, | ||
153 | u16 data) | ||
154 | { | ||
155 | u16 value = (data << 8) | MODEM_CTL_REGISTER; | ||
156 | |||
157 | return usb_control_msg(dev, usb_sndctrlpipe(dev, 0), | ||
158 | QT_SET_GET_REGISTER, 0x40, value, uart, | ||
159 | NULL, 0, 300); | ||
160 | |||
161 | } | ||
162 | |||
163 | #define set_mctrl(dev, set) update_mctrl((dev), (set), 0) | ||
164 | #define clear_mctrl(dev, clear) update_mctrl((dev), 0, (clear)) | ||
165 | |||
166 | /* these do not deal with device that have more than 1 port */ | ||
167 | static inline int update_mctrl(struct usb_device *dev, unsigned int set, | ||
168 | unsigned int clear) | ||
169 | { | ||
170 | unsigned urb_value; | ||
171 | int result; | ||
172 | |||
173 | if (((set | clear) & (TIOCM_DTR | TIOCM_RTS)) == 0) { | ||
174 | dbg("%s - DTR|RTS not being set|cleared", __func__); | ||
175 | return 0; /* no change */ | ||
176 | } | ||
177 | |||
178 | clear &= ~set; /* 'set' takes precedence over 'clear' */ | ||
179 | urb_value = 0; | ||
180 | if (set & TIOCM_DTR) | ||
181 | urb_value |= SERIAL_MCR_DTR; | ||
182 | if (set & TIOCM_RTS) | ||
183 | urb_value |= SERIAL_MCR_RTS; | ||
184 | |||
185 | result = ssu100_setregister(dev, 0, urb_value); | ||
186 | if (result < 0) | ||
187 | dbg("%s Error from MODEM_CTRL urb", __func__); | ||
188 | |||
189 | return result; | ||
190 | } | ||
191 | |||
192 | static int ssu100_initdevice(struct usb_device *dev) | ||
193 | { | ||
194 | u8 *data; | ||
195 | int result = 0; | ||
196 | |||
197 | dbg("%s", __func__); | ||
198 | |||
199 | data = kzalloc(3, GFP_KERNEL); | ||
200 | if (!data) | ||
201 | return -ENOMEM; | ||
202 | |||
203 | result = ssu100_getdevice(dev, data); | ||
204 | if (result < 0) { | ||
205 | dbg("%s - get_device failed %i", __func__, result); | ||
206 | goto out; | ||
207 | } | ||
208 | |||
209 | data[1] &= ~FULLPWRBIT; | ||
210 | |||
211 | result = ssu100_setdevice(dev, data); | ||
212 | if (result < 0) { | ||
213 | dbg("%s - setdevice failed %i", __func__, result); | ||
214 | goto out; | ||
215 | } | ||
216 | |||
217 | result = ssu100_control_msg(dev, QT_GET_SET_PREBUF_TRIG_LVL, 128, 0); | ||
218 | if (result < 0) { | ||
219 | dbg("%s - set prebuffer level failed %i", __func__, result); | ||
220 | goto out; | ||
221 | } | ||
222 | |||
223 | result = ssu100_control_msg(dev, QT_SET_ATF, ATC_DISABLED, 0); | ||
224 | if (result < 0) { | ||
225 | dbg("%s - set ATFprebuffer level failed %i", __func__, result); | ||
226 | goto out; | ||
227 | } | ||
228 | |||
229 | result = ssu100_getdevice(dev, data); | ||
230 | if (result < 0) { | ||
231 | dbg("%s - get_device failed %i", __func__, result); | ||
232 | goto out; | ||
233 | } | ||
234 | |||
235 | data[0] &= ~(RR_BITS | DUPMODE_BITS); | ||
236 | data[0] |= CLKS_X4; | ||
237 | data[1] &= ~(LOOPMODE_BITS); | ||
238 | data[1] |= RS232_MODE; | ||
239 | |||
240 | result = ssu100_setdevice(dev, data); | ||
241 | if (result < 0) { | ||
242 | dbg("%s - setdevice failed %i", __func__, result); | ||
243 | goto out; | ||
244 | } | ||
245 | |||
246 | out: kfree(data); | ||
247 | return result; | ||
248 | |||
249 | } | ||
250 | |||
251 | |||
252 | static void ssu100_set_termios(struct tty_struct *tty, | ||
253 | struct usb_serial_port *port, | ||
254 | struct ktermios *old_termios) | ||
255 | { | ||
256 | struct usb_device *dev = port->serial->dev; | ||
257 | struct ktermios *termios = tty->termios; | ||
258 | u16 baud, divisor, remainder; | ||
259 | unsigned int cflag = termios->c_cflag; | ||
260 | u16 urb_value = 0; /* will hold the new flags */ | ||
261 | int result; | ||
262 | |||
263 | dbg("%s", __func__); | ||
264 | |||
265 | if (cflag & PARENB) { | ||
266 | if (cflag & PARODD) | ||
267 | urb_value |= SERIAL_ODD_PARITY; | ||
268 | else | ||
269 | urb_value |= SERIAL_EVEN_PARITY; | ||
270 | } | ||
271 | |||
272 | switch (cflag & CSIZE) { | ||
273 | case CS5: | ||
274 | urb_value |= SERIAL_5_DATA; | ||
275 | break; | ||
276 | case CS6: | ||
277 | urb_value |= SERIAL_6_DATA; | ||
278 | break; | ||
279 | case CS7: | ||
280 | urb_value |= SERIAL_7_DATA; | ||
281 | break; | ||
282 | default: | ||
283 | case CS8: | ||
284 | urb_value |= SERIAL_8_DATA; | ||
285 | break; | ||
286 | } | ||
287 | |||
288 | baud = tty_get_baud_rate(tty); | ||
289 | if (!baud) | ||
290 | baud = 9600; | ||
291 | |||
292 | dbg("%s - got baud = %d\n", __func__, baud); | ||
293 | |||
294 | |||
295 | divisor = MAX_BAUD_RATE / baud; | ||
296 | remainder = MAX_BAUD_RATE % baud; | ||
297 | if (((remainder * 2) >= baud) && (baud != 110)) | ||
298 | divisor++; | ||
299 | |||
300 | urb_value = urb_value << 8; | ||
301 | |||
302 | result = ssu100_control_msg(dev, QT_GET_SET_UART, divisor, urb_value); | ||
303 | if (result < 0) | ||
304 | dbg("%s - set uart failed", __func__); | ||
305 | |||
306 | if (cflag & CRTSCTS) | ||
307 | result = ssu100_control_msg(dev, QT_HW_FLOW_CONTROL_MASK, | ||
308 | SERIAL_CRTSCTS, 0); | ||
309 | else | ||
310 | result = ssu100_control_msg(dev, QT_HW_FLOW_CONTROL_MASK, | ||
311 | 0, 0); | ||
312 | if (result < 0) | ||
313 | dbg("%s - set HW flow control failed", __func__); | ||
314 | |||
315 | if (I_IXOFF(tty) || I_IXON(tty)) { | ||
316 | u16 x = ((u16)(START_CHAR(tty) << 8) | (u16)(STOP_CHAR(tty))); | ||
317 | |||
318 | result = ssu100_control_msg(dev, QT_SW_FLOW_CONTROL_MASK, | ||
319 | x, 0); | ||
320 | } else | ||
321 | result = ssu100_control_msg(dev, QT_SW_FLOW_CONTROL_MASK, | ||
322 | 0, 0); | ||
323 | |||
324 | if (result < 0) | ||
325 | dbg("%s - set SW flow control failed", __func__); | ||
326 | |||
327 | } | ||
328 | |||
329 | |||
330 | static int ssu100_open(struct tty_struct *tty, struct usb_serial_port *port) | ||
331 | { | ||
332 | struct usb_device *dev = port->serial->dev; | ||
333 | struct ssu100_port_private *priv = usb_get_serial_port_data(port); | ||
334 | u8 *data; | ||
335 | int result; | ||
336 | |||
337 | dbg("%s - port %d", __func__, port->number); | ||
338 | |||
339 | data = kzalloc(2, GFP_KERNEL); | ||
340 | if (!data) | ||
341 | return -ENOMEM; | ||
342 | |||
343 | result = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), | ||
344 | QT_OPEN_CLOSE_CHANNEL, | ||
345 | QT_TRANSFER_IN, 0x01, | ||
346 | 0, data, 2, 300); | ||
347 | if (result < 0) { | ||
348 | dbg("%s - open failed %i", __func__, result); | ||
349 | kfree(data); | ||
350 | return result; | ||
351 | } | ||
352 | |||
353 | priv->shadowLSR = data[0] & (SERIAL_LSR_OE | SERIAL_LSR_PE | | ||
354 | SERIAL_LSR_FE | SERIAL_LSR_BI); | ||
355 | |||
356 | priv->shadowMSR = data[1] & (SERIAL_MSR_CTS | SERIAL_MSR_DSR | | ||
357 | SERIAL_MSR_RI | SERIAL_MSR_CD); | ||
358 | |||
359 | kfree(data); | ||
360 | |||
361 | /* set to 9600 */ | ||
362 | result = ssu100_control_msg(dev, QT_GET_SET_UART, 0x30, 0x0300); | ||
363 | if (result < 0) | ||
364 | dbg("%s - set uart failed", __func__); | ||
365 | |||
366 | if (tty) | ||
367 | ssu100_set_termios(tty, port, tty->termios); | ||
368 | |||
369 | return usb_serial_generic_open(tty, port); | ||
370 | } | ||
371 | |||
372 | static void ssu100_close(struct usb_serial_port *port) | ||
373 | { | ||
374 | dbg("%s", __func__); | ||
375 | usb_serial_generic_close(port); | ||
376 | } | ||
377 | |||
378 | static int get_serial_info(struct usb_serial_port *port, | ||
379 | struct serial_struct __user *retinfo) | ||
380 | { | ||
381 | struct serial_struct tmp; | ||
382 | |||
383 | if (!retinfo) | ||
384 | return -EFAULT; | ||
385 | |||
386 | memset(&tmp, 0, sizeof(tmp)); | ||
387 | tmp.line = port->serial->minor; | ||
388 | tmp.port = 0; | ||
389 | tmp.irq = 0; | ||
390 | tmp.flags = ASYNC_SKIP_TEST | ASYNC_AUTO_IRQ; | ||
391 | tmp.xmit_fifo_size = port->bulk_out_size; | ||
392 | tmp.baud_base = 9600; | ||
393 | tmp.close_delay = 5*HZ; | ||
394 | tmp.closing_wait = 30*HZ; | ||
395 | |||
396 | if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) | ||
397 | return -EFAULT; | ||
398 | return 0; | ||
399 | } | ||
400 | |||
401 | static int ssu100_ioctl(struct tty_struct *tty, struct file *file, | ||
402 | unsigned int cmd, unsigned long arg) | ||
403 | { | ||
404 | struct usb_serial_port *port = tty->driver_data; | ||
405 | struct ssu100_port_private *priv = usb_get_serial_port_data(port); | ||
406 | |||
407 | dbg("%s cmd 0x%04x", __func__, cmd); | ||
408 | |||
409 | switch (cmd) { | ||
410 | case TIOCGSERIAL: | ||
411 | return get_serial_info(port, | ||
412 | (struct serial_struct __user *) arg); | ||
413 | |||
414 | case TIOCMIWAIT: | ||
415 | while (priv != NULL) { | ||
416 | u8 prevMSR = priv->shadowMSR & SERIAL_MSR_MASK; | ||
417 | interruptible_sleep_on(&priv->delta_msr_wait); | ||
418 | /* see if a signal did it */ | ||
419 | if (signal_pending(current)) | ||
420 | return -ERESTARTSYS; | ||
421 | else { | ||
422 | u8 diff = (priv->shadowMSR & SERIAL_MSR_MASK) ^ prevMSR; | ||
423 | if (!diff) | ||
424 | return -EIO; /* no change => error */ | ||
425 | |||
426 | /* Return 0 if caller wanted to know about | ||
427 | these bits */ | ||
428 | |||
429 | if (((arg & TIOCM_RNG) && (diff & SERIAL_MSR_RI)) || | ||
430 | ((arg & TIOCM_DSR) && (diff & SERIAL_MSR_DSR)) || | ||
431 | ((arg & TIOCM_CD) && (diff & SERIAL_MSR_CD)) || | ||
432 | ((arg & TIOCM_CTS) && (diff & SERIAL_MSR_CTS))) | ||
433 | return 0; | ||
434 | } | ||
435 | } | ||
436 | return 0; | ||
437 | |||
438 | default: | ||
439 | break; | ||
440 | } | ||
441 | |||
442 | dbg("%s arg not supported", __func__); | ||
443 | |||
444 | return -ENOIOCTLCMD; | ||
445 | } | ||
446 | |||
447 | static void ssu100_set_max_packet_size(struct usb_serial_port *port) | ||
448 | { | ||
449 | struct ssu100_port_private *priv = usb_get_serial_port_data(port); | ||
450 | struct usb_serial *serial = port->serial; | ||
451 | struct usb_device *udev = serial->dev; | ||
452 | |||
453 | struct usb_interface *interface = serial->interface; | ||
454 | struct usb_endpoint_descriptor *ep_desc = &interface->cur_altsetting->endpoint[1].desc; | ||
455 | |||
456 | unsigned num_endpoints; | ||
457 | int i; | ||
458 | |||
459 | num_endpoints = interface->cur_altsetting->desc.bNumEndpoints; | ||
460 | dev_info(&udev->dev, "Number of endpoints %d\n", num_endpoints); | ||
461 | |||
462 | for (i = 0; i < num_endpoints; i++) { | ||
463 | dev_info(&udev->dev, "Endpoint %d MaxPacketSize %d\n", i+1, | ||
464 | interface->cur_altsetting->endpoint[i].desc.wMaxPacketSize); | ||
465 | ep_desc = &interface->cur_altsetting->endpoint[i].desc; | ||
466 | } | ||
467 | |||
468 | /* set max packet size based on descriptor */ | ||
469 | priv->max_packet_size = ep_desc->wMaxPacketSize; | ||
470 | |||
471 | dev_info(&udev->dev, "Setting MaxPacketSize %d\n", priv->max_packet_size); | ||
472 | } | ||
473 | |||
474 | static int ssu100_attach(struct usb_serial *serial) | ||
475 | { | ||
476 | struct ssu100_port_private *priv; | ||
477 | struct usb_serial_port *port = *serial->port; | ||
478 | |||
479 | dbg("%s", __func__); | ||
480 | |||
481 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); | ||
482 | if (!priv) { | ||
483 | dev_err(&port->dev, "%s- kmalloc(%Zd) failed.\n", __func__, | ||
484 | sizeof(*priv)); | ||
485 | return -ENOMEM; | ||
486 | } | ||
487 | |||
488 | init_waitqueue_head(&priv->delta_msr_wait); | ||
489 | usb_set_serial_port_data(port, priv); | ||
490 | |||
491 | ssu100_set_max_packet_size(port); | ||
492 | |||
493 | return ssu100_initdevice(serial->dev); | ||
494 | } | ||
495 | |||
496 | static int ssu100_tiocmget(struct tty_struct *tty, struct file *file) | ||
497 | { | ||
498 | struct usb_serial_port *port = tty->driver_data; | ||
499 | struct usb_device *dev = port->serial->dev; | ||
500 | u8 *d; | ||
501 | int r; | ||
502 | |||
503 | dbg("%s\n", __func__); | ||
504 | |||
505 | d = kzalloc(2, GFP_KERNEL); | ||
506 | if (!d) | ||
507 | return -ENOMEM; | ||
508 | |||
509 | r = ssu100_getregister(dev, 0, MODEM_CTL_REGISTER, d); | ||
510 | if (r < 0) | ||
511 | goto mget_out; | ||
512 | |||
513 | r = ssu100_getregister(dev, 0, MODEM_STATUS_REGISTER, d+1); | ||
514 | if (r < 0) | ||
515 | goto mget_out; | ||
516 | |||
517 | r = (d[0] & SERIAL_MCR_DTR ? TIOCM_DTR : 0) | | ||
518 | (d[0] & SERIAL_MCR_RTS ? TIOCM_RTS : 0) | | ||
519 | (d[1] & SERIAL_MSR_CTS ? TIOCM_CTS : 0) | | ||
520 | (d[1] & SERIAL_MSR_CD ? TIOCM_CAR : 0) | | ||
521 | (d[1] & SERIAL_MSR_RI ? TIOCM_RI : 0) | | ||
522 | (d[1] & SERIAL_MSR_DSR ? TIOCM_DSR : 0); | ||
523 | |||
524 | mget_out: | ||
525 | kfree(d); | ||
526 | return r; | ||
527 | } | ||
528 | |||
529 | static int ssu100_tiocmset(struct tty_struct *tty, struct file *file, | ||
530 | unsigned int set, unsigned int clear) | ||
531 | { | ||
532 | struct usb_serial_port *port = tty->driver_data; | ||
533 | struct usb_device *dev = port->serial->dev; | ||
534 | |||
535 | dbg("%s\n", __func__); | ||
536 | return update_mctrl(dev, set, clear); | ||
537 | } | ||
538 | |||
539 | static void ssu100_dtr_rts(struct usb_serial_port *port, int on) | ||
540 | { | ||
541 | struct usb_device *dev = port->serial->dev; | ||
542 | |||
543 | dbg("%s\n", __func__); | ||
544 | |||
545 | mutex_lock(&port->serial->disc_mutex); | ||
546 | if (!port->serial->disconnected) { | ||
547 | /* Disable flow control */ | ||
548 | if (!on && | ||
549 | ssu100_setregister(dev, 0, 0) < 0) | ||
550 | dev_err(&port->dev, "error from flowcontrol urb\n"); | ||
551 | /* drop RTS and DTR */ | ||
552 | if (on) | ||
553 | set_mctrl(dev, TIOCM_DTR | TIOCM_RTS); | ||
554 | else | ||
555 | clear_mctrl(dev, TIOCM_DTR | TIOCM_RTS); | ||
556 | } | ||
557 | mutex_unlock(&port->serial->disc_mutex); | ||
558 | } | ||
559 | |||
560 | static int ssu100_process_packet(struct tty_struct *tty, | ||
561 | struct usb_serial_port *port, | ||
562 | struct ssu100_port_private *priv, | ||
563 | char *packet, int len) | ||
564 | { | ||
565 | int i; | ||
566 | char flag; | ||
567 | char *ch; | ||
568 | |||
569 | dbg("%s - port %d", __func__, port->number); | ||
570 | |||
571 | if (len < 4) { | ||
572 | dbg("%s - malformed packet", __func__); | ||
573 | return 0; | ||
574 | } | ||
575 | |||
576 | if ((packet[0] == 0x1b) && (packet[1] == 0x1b) && | ||
577 | ((packet[2] == 0x00) || (packet[2] == 0x01))) { | ||
578 | if (packet[2] == 0x00) | ||
579 | priv->shadowLSR = packet[3] & (SERIAL_LSR_OE | | ||
580 | SERIAL_LSR_PE | | ||
581 | SERIAL_LSR_FE | | ||
582 | SERIAL_LSR_BI); | ||
583 | |||
584 | if (packet[2] == 0x01) { | ||
585 | priv->shadowMSR = packet[3]; | ||
586 | wake_up_interruptible(&priv->delta_msr_wait); | ||
587 | } | ||
588 | |||
589 | len -= 4; | ||
590 | ch = packet + 4; | ||
591 | } else | ||
592 | ch = packet; | ||
593 | |||
594 | if (!len) | ||
595 | return 0; /* status only */ | ||
596 | |||
597 | if (port->port.console && port->sysrq) { | ||
598 | for (i = 0; i < len; i++, ch++) { | ||
599 | if (!usb_serial_handle_sysrq_char(tty, port, *ch)) | ||
600 | tty_insert_flip_char(tty, *ch, flag); | ||
601 | } | ||
602 | } else | ||
603 | tty_insert_flip_string_fixed_flag(tty, ch, flag, len); | ||
604 | |||
605 | return len; | ||
606 | } | ||
607 | |||
608 | static void ssu100_process_read_urb(struct urb *urb) | ||
609 | { | ||
610 | struct usb_serial_port *port = urb->context; | ||
611 | struct ssu100_port_private *priv = usb_get_serial_port_data(port); | ||
612 | char *data = (char *)urb->transfer_buffer; | ||
613 | struct tty_struct *tty; | ||
614 | int count = 0; | ||
615 | int i; | ||
616 | int len; | ||
617 | |||
618 | dbg("%s", __func__); | ||
619 | |||
620 | tty = tty_port_tty_get(&port->port); | ||
621 | if (!tty) | ||
622 | return; | ||
623 | |||
624 | for (i = 0; i < urb->actual_length; i += priv->max_packet_size) { | ||
625 | len = min_t(int, urb->actual_length - i, priv->max_packet_size); | ||
626 | count += ssu100_process_packet(tty, port, priv, &data[i], len); | ||
627 | } | ||
628 | |||
629 | if (count) | ||
630 | tty_flip_buffer_push(tty); | ||
631 | tty_kref_put(tty); | ||
632 | } | ||
633 | |||
634 | |||
635 | static struct usb_serial_driver ssu100_device = { | ||
636 | .driver = { | ||
637 | .owner = THIS_MODULE, | ||
638 | .name = "ssu100", | ||
639 | }, | ||
640 | .description = DRIVER_DESC, | ||
641 | .id_table = id_table, | ||
642 | .usb_driver = &ssu100_driver, | ||
643 | .num_ports = 1, | ||
644 | .bulk_in_size = 256, | ||
645 | .bulk_out_size = 256, | ||
646 | .open = ssu100_open, | ||
647 | .close = ssu100_close, | ||
648 | .attach = ssu100_attach, | ||
649 | .release = ssu100_release, | ||
650 | .dtr_rts = ssu100_dtr_rts, | ||
651 | .process_read_urb = ssu100_process_read_urb, | ||
652 | .tiocmget = ssu100_tiocmget, | ||
653 | .tiocmset = ssu100_tiocmset, | ||
654 | .ioctl = ssu100_ioctl, | ||
655 | .set_termios = ssu100_set_termios, | ||
656 | }; | ||
657 | |||
658 | static int __init ssu100_init(void) | ||
659 | { | ||
660 | int retval; | ||
661 | |||
662 | dbg("%s", __func__); | ||
663 | |||
664 | /* register with usb-serial */ | ||
665 | retval = usb_serial_register(&ssu100_device); | ||
666 | |||
667 | if (retval) | ||
668 | goto failed_usb_sio_register; | ||
669 | |||
670 | retval = usb_register(&ssu100_driver); | ||
671 | if (retval) | ||
672 | goto failed_usb_register; | ||
673 | |||
674 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" | ||
675 | DRIVER_DESC "\n"); | ||
676 | |||
677 | return 0; | ||
678 | |||
679 | failed_usb_register: | ||
680 | usb_serial_deregister(&ssu100_device); | ||
681 | failed_usb_sio_register: | ||
682 | return retval; | ||
683 | } | ||
684 | |||
685 | static void __exit ssu100_exit(void) | ||
686 | { | ||
687 | usb_deregister(&ssu100_driver); | ||
688 | usb_serial_deregister(&ssu100_device); | ||
689 | } | ||
690 | |||
691 | module_init(ssu100_init); | ||
692 | module_exit(ssu100_exit); | ||
693 | |||
694 | MODULE_DESCRIPTION(DRIVER_DESC); | ||
695 | MODULE_LICENSE("GPL"); | ||
696 | |||
697 | module_param(debug, bool, S_IRUGO | S_IWUSR); | ||
698 | MODULE_PARM_DESC(debug, "Debug enabled or not"); | ||
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index 941c2d409f85..2a982e62963b 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c | |||
@@ -653,6 +653,7 @@ exit: | |||
653 | return id; | 653 | return id; |
654 | } | 654 | } |
655 | 655 | ||
656 | /* Caller must hold table_lock */ | ||
656 | static struct usb_serial_driver *search_serial_device( | 657 | static struct usb_serial_driver *search_serial_device( |
657 | struct usb_interface *iface) | 658 | struct usb_interface *iface) |
658 | { | 659 | { |
@@ -718,17 +719,23 @@ int usb_serial_probe(struct usb_interface *interface, | |||
718 | int num_ports = 0; | 719 | int num_ports = 0; |
719 | int max_endpoints; | 720 | int max_endpoints; |
720 | 721 | ||
721 | lock_kernel(); /* guard against unloading a serial driver module */ | 722 | mutex_lock(&table_lock); |
722 | type = search_serial_device(interface); | 723 | type = search_serial_device(interface); |
723 | if (!type) { | 724 | if (!type) { |
724 | unlock_kernel(); | 725 | mutex_unlock(&table_lock); |
725 | dbg("none matched"); | 726 | dbg("none matched"); |
726 | return -ENODEV; | 727 | return -ENODEV; |
727 | } | 728 | } |
728 | 729 | ||
730 | if (!try_module_get(type->driver.owner)) { | ||
731 | mutex_unlock(&table_lock); | ||
732 | dev_err(&interface->dev, "module get failed, exiting\n"); | ||
733 | return -EIO; | ||
734 | } | ||
735 | mutex_unlock(&table_lock); | ||
736 | |||
729 | serial = create_serial(dev, interface, type); | 737 | serial = create_serial(dev, interface, type); |
730 | if (!serial) { | 738 | if (!serial) { |
731 | unlock_kernel(); | ||
732 | dev_err(&interface->dev, "%s - out of memory\n", __func__); | 739 | dev_err(&interface->dev, "%s - out of memory\n", __func__); |
733 | return -ENOMEM; | 740 | return -ENOMEM; |
734 | } | 741 | } |
@@ -737,20 +744,11 @@ int usb_serial_probe(struct usb_interface *interface, | |||
737 | if (type->probe) { | 744 | if (type->probe) { |
738 | const struct usb_device_id *id; | 745 | const struct usb_device_id *id; |
739 | 746 | ||
740 | if (!try_module_get(type->driver.owner)) { | ||
741 | unlock_kernel(); | ||
742 | dev_err(&interface->dev, | ||
743 | "module get failed, exiting\n"); | ||
744 | kfree(serial); | ||
745 | return -EIO; | ||
746 | } | ||
747 | |||
748 | id = get_iface_id(type, interface); | 747 | id = get_iface_id(type, interface); |
749 | retval = type->probe(serial, id); | 748 | retval = type->probe(serial, id); |
750 | module_put(type->driver.owner); | 749 | module_put(type->driver.owner); |
751 | 750 | ||
752 | if (retval) { | 751 | if (retval) { |
753 | unlock_kernel(); | ||
754 | dbg("sub driver rejected device"); | 752 | dbg("sub driver rejected device"); |
755 | kfree(serial); | 753 | kfree(serial); |
756 | return retval; | 754 | return retval; |
@@ -822,7 +820,6 @@ int usb_serial_probe(struct usb_interface *interface, | |||
822 | * properly during a later invocation of usb_serial_probe | 820 | * properly during a later invocation of usb_serial_probe |
823 | */ | 821 | */ |
824 | if (num_bulk_in == 0 || num_bulk_out == 0) { | 822 | if (num_bulk_in == 0 || num_bulk_out == 0) { |
825 | unlock_kernel(); | ||
826 | dev_info(&interface->dev, "PL-2303 hack: descriptors matched but endpoints did not\n"); | 823 | dev_info(&interface->dev, "PL-2303 hack: descriptors matched but endpoints did not\n"); |
827 | kfree(serial); | 824 | kfree(serial); |
828 | return -ENODEV; | 825 | return -ENODEV; |
@@ -835,7 +832,6 @@ int usb_serial_probe(struct usb_interface *interface, | |||
835 | if (type == &usb_serial_generic_device) { | 832 | if (type == &usb_serial_generic_device) { |
836 | num_ports = num_bulk_out; | 833 | num_ports = num_bulk_out; |
837 | if (num_ports == 0) { | 834 | if (num_ports == 0) { |
838 | unlock_kernel(); | ||
839 | dev_err(&interface->dev, | 835 | dev_err(&interface->dev, |
840 | "Generic device with no bulk out, not allowed.\n"); | 836 | "Generic device with no bulk out, not allowed.\n"); |
841 | kfree(serial); | 837 | kfree(serial); |
@@ -847,7 +843,6 @@ int usb_serial_probe(struct usb_interface *interface, | |||
847 | /* if this device type has a calc_num_ports function, call it */ | 843 | /* if this device type has a calc_num_ports function, call it */ |
848 | if (type->calc_num_ports) { | 844 | if (type->calc_num_ports) { |
849 | if (!try_module_get(type->driver.owner)) { | 845 | if (!try_module_get(type->driver.owner)) { |
850 | unlock_kernel(); | ||
851 | dev_err(&interface->dev, | 846 | dev_err(&interface->dev, |
852 | "module get failed, exiting\n"); | 847 | "module get failed, exiting\n"); |
853 | kfree(serial); | 848 | kfree(serial); |
@@ -878,7 +873,6 @@ int usb_serial_probe(struct usb_interface *interface, | |||
878 | max_endpoints = max(max_endpoints, num_interrupt_out); | 873 | max_endpoints = max(max_endpoints, num_interrupt_out); |
879 | max_endpoints = max(max_endpoints, (int)serial->num_ports); | 874 | max_endpoints = max(max_endpoints, (int)serial->num_ports); |
880 | serial->num_port_pointers = max_endpoints; | 875 | serial->num_port_pointers = max_endpoints; |
881 | unlock_kernel(); | ||
882 | 876 | ||
883 | dbg("%s - setting up %d port structures for this device", | 877 | dbg("%s - setting up %d port structures for this device", |
884 | __func__, max_endpoints); | 878 | __func__, max_endpoints); |
@@ -1077,6 +1071,8 @@ int usb_serial_probe(struct usb_interface *interface, | |||
1077 | dev_set_name(&port->dev, "ttyUSB%d", port->number); | 1071 | dev_set_name(&port->dev, "ttyUSB%d", port->number); |
1078 | dbg ("%s - registering %s", __func__, dev_name(&port->dev)); | 1072 | dbg ("%s - registering %s", __func__, dev_name(&port->dev)); |
1079 | port->dev_state = PORT_REGISTERING; | 1073 | port->dev_state = PORT_REGISTERING; |
1074 | device_enable_async_suspend(&port->dev); | ||
1075 | |||
1080 | retval = device_add(&port->dev); | 1076 | retval = device_add(&port->dev); |
1081 | if (retval) { | 1077 | if (retval) { |
1082 | dev_err(&port->dev, "Error registering port device, " | 1078 | dev_err(&port->dev, "Error registering port device, " |
@@ -1349,6 +1345,7 @@ int usb_serial_register(struct usb_serial_driver *driver) | |||
1349 | driver->description = driver->driver.name; | 1345 | driver->description = driver->driver.name; |
1350 | 1346 | ||
1351 | /* Add this device to our list of devices */ | 1347 | /* Add this device to our list of devices */ |
1348 | mutex_lock(&table_lock); | ||
1352 | list_add(&driver->driver_list, &usb_serial_driver_list); | 1349 | list_add(&driver->driver_list, &usb_serial_driver_list); |
1353 | 1350 | ||
1354 | retval = usb_serial_bus_register(driver); | 1351 | retval = usb_serial_bus_register(driver); |
@@ -1360,6 +1357,7 @@ int usb_serial_register(struct usb_serial_driver *driver) | |||
1360 | printk(KERN_INFO "USB Serial support registered for %s\n", | 1357 | printk(KERN_INFO "USB Serial support registered for %s\n", |
1361 | driver->description); | 1358 | driver->description); |
1362 | 1359 | ||
1360 | mutex_unlock(&table_lock); | ||
1363 | return retval; | 1361 | return retval; |
1364 | } | 1362 | } |
1365 | EXPORT_SYMBOL_GPL(usb_serial_register); | 1363 | EXPORT_SYMBOL_GPL(usb_serial_register); |
@@ -1370,8 +1368,10 @@ void usb_serial_deregister(struct usb_serial_driver *device) | |||
1370 | /* must be called with BKL held */ | 1368 | /* must be called with BKL held */ |
1371 | printk(KERN_INFO "USB Serial deregistering driver %s\n", | 1369 | printk(KERN_INFO "USB Serial deregistering driver %s\n", |
1372 | device->description); | 1370 | device->description); |
1371 | mutex_lock(&table_lock); | ||
1373 | list_del(&device->driver_list); | 1372 | list_del(&device->driver_list); |
1374 | usb_serial_bus_deregister(device); | 1373 | usb_serial_bus_deregister(device); |
1374 | mutex_unlock(&table_lock); | ||
1375 | } | 1375 | } |
1376 | EXPORT_SYMBOL_GPL(usb_serial_deregister); | 1376 | EXPORT_SYMBOL_GPL(usb_serial_deregister); |
1377 | 1377 | ||
diff --git a/drivers/usb/storage/freecom.c b/drivers/usb/storage/freecom.c index 54cc94277acb..6542ca40d505 100644 --- a/drivers/usb/storage/freecom.c +++ b/drivers/usb/storage/freecom.c | |||
@@ -269,7 +269,7 @@ static int freecom_transport(struct scsi_cmnd *srb, struct us_data *us) | |||
269 | /* The firmware will time-out commands after 20 seconds. Some commands | 269 | /* The firmware will time-out commands after 20 seconds. Some commands |
270 | * can legitimately take longer than this, so we use a different | 270 | * can legitimately take longer than this, so we use a different |
271 | * command that only waits for the interrupt and then sends status, | 271 | * command that only waits for the interrupt and then sends status, |
272 | * without having to send a new ATAPI command to the device. | 272 | * without having to send a new ATAPI command to the device. |
273 | * | 273 | * |
274 | * NOTE: There is some indication that a data transfer after a timeout | 274 | * NOTE: There is some indication that a data transfer after a timeout |
275 | * may not work, but that is a condition that should never happen. | 275 | * may not work, but that is a condition that should never happen. |
@@ -324,14 +324,14 @@ static int freecom_transport(struct scsi_cmnd *srb, struct us_data *us) | |||
324 | 324 | ||
325 | /* Find the length we desire to read. */ | 325 | /* Find the length we desire to read. */ |
326 | switch (srb->cmnd[0]) { | 326 | switch (srb->cmnd[0]) { |
327 | case INQUIRY: | 327 | case INQUIRY: |
328 | case REQUEST_SENSE: /* 16 or 18 bytes? spec says 18, lots of devices only have 16 */ | 328 | case REQUEST_SENSE: /* 16 or 18 bytes? spec says 18, lots of devices only have 16 */ |
329 | case MODE_SENSE: | 329 | case MODE_SENSE: |
330 | case MODE_SENSE_10: | 330 | case MODE_SENSE_10: |
331 | length = le16_to_cpu(fst->Count); | 331 | length = le16_to_cpu(fst->Count); |
332 | break; | 332 | break; |
333 | default: | 333 | default: |
334 | length = scsi_bufflen(srb); | 334 | length = scsi_bufflen(srb); |
335 | } | 335 | } |
336 | 336 | ||
337 | /* verify that this amount is legal */ | 337 | /* verify that this amount is legal */ |
@@ -414,7 +414,7 @@ static int freecom_transport(struct scsi_cmnd *srb, struct us_data *us) | |||
414 | /* should never hit here -- filtered in usb.c */ | 414 | /* should never hit here -- filtered in usb.c */ |
415 | US_DEBUGP ("freecom unimplemented direction: %d\n", | 415 | US_DEBUGP ("freecom unimplemented direction: %d\n", |
416 | us->srb->sc_data_direction); | 416 | us->srb->sc_data_direction); |
417 | // Return fail, SCSI seems to handle this better. | 417 | /* Return fail, SCSI seems to handle this better. */ |
418 | return USB_STOR_TRANSPORT_FAILED; | 418 | return USB_STOR_TRANSPORT_FAILED; |
419 | break; | 419 | break; |
420 | } | 420 | } |
@@ -494,8 +494,7 @@ static void pdump (void *ibuffer, int length) | |||
494 | offset = 0; | 494 | offset = 0; |
495 | } | 495 | } |
496 | offset += sprintf (line+offset, "%08x:", i); | 496 | offset += sprintf (line+offset, "%08x:", i); |
497 | } | 497 | } else if ((i & 7) == 0) { |
498 | else if ((i & 7) == 0) { | ||
499 | offset += sprintf (line+offset, " -"); | 498 | offset += sprintf (line+offset, " -"); |
500 | } | 499 | } |
501 | offset += sprintf (line+offset, " %02x", buffer[i] & 0xff); | 500 | offset += sprintf (line+offset, " %02x", buffer[i] & 0xff); |
diff --git a/drivers/usb/storage/isd200.c b/drivers/usb/storage/isd200.c index e9cbc1467f76..6b9982cd5423 100644 --- a/drivers/usb/storage/isd200.c +++ b/drivers/usb/storage/isd200.c | |||
@@ -1456,8 +1456,7 @@ static int isd200_init_info(struct us_data *us) | |||
1456 | int retStatus = ISD200_GOOD; | 1456 | int retStatus = ISD200_GOOD; |
1457 | struct isd200_info *info; | 1457 | struct isd200_info *info; |
1458 | 1458 | ||
1459 | info = (struct isd200_info *) | 1459 | info = kzalloc(sizeof(struct isd200_info), GFP_KERNEL); |
1460 | kzalloc(sizeof(struct isd200_info), GFP_KERNEL); | ||
1461 | if (!info) | 1460 | if (!info) |
1462 | retStatus = ISD200_ERROR; | 1461 | retStatus = ISD200_ERROR; |
1463 | else { | 1462 | else { |
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c index a7d0bf9d92a7..90bb0175a152 100644 --- a/drivers/usb/storage/usb.c +++ b/drivers/usb/storage/usb.c | |||
@@ -336,6 +336,7 @@ static int usb_stor_control_thread(void * __us) | |||
336 | else { | 336 | else { |
337 | US_DEBUG(usb_stor_show_command(us->srb)); | 337 | US_DEBUG(usb_stor_show_command(us->srb)); |
338 | us->proto_handler(us->srb, us); | 338 | us->proto_handler(us->srb, us); |
339 | usb_mark_last_busy(us->pusb_dev); | ||
339 | } | 340 | } |
340 | 341 | ||
341 | /* lock access to the state */ | 342 | /* lock access to the state */ |
@@ -845,6 +846,7 @@ static int usb_stor_scan_thread(void * __us) | |||
845 | /* Should we unbind if no devices were detected? */ | 846 | /* Should we unbind if no devices were detected? */ |
846 | } | 847 | } |
847 | 848 | ||
849 | usb_autopm_put_interface(us->pusb_intf); | ||
848 | complete_and_exit(&us->scanning_done, 0); | 850 | complete_and_exit(&us->scanning_done, 0); |
849 | } | 851 | } |
850 | 852 | ||
@@ -968,6 +970,7 @@ int usb_stor_probe2(struct us_data *us) | |||
968 | goto BadDevice; | 970 | goto BadDevice; |
969 | } | 971 | } |
970 | 972 | ||
973 | usb_autopm_get_interface_no_resume(us->pusb_intf); | ||
971 | wake_up_process(th); | 974 | wake_up_process(th); |
972 | 975 | ||
973 | return 0; | 976 | return 0; |
@@ -1040,6 +1043,7 @@ static struct usb_driver usb_storage_driver = { | |||
1040 | .pre_reset = usb_stor_pre_reset, | 1043 | .pre_reset = usb_stor_pre_reset, |
1041 | .post_reset = usb_stor_post_reset, | 1044 | .post_reset = usb_stor_post_reset, |
1042 | .id_table = usb_storage_usb_ids, | 1045 | .id_table = usb_storage_usb_ids, |
1046 | .supports_autosuspend = 1, | ||
1043 | .soft_unbind = 1, | 1047 | .soft_unbind = 1, |
1044 | }; | 1048 | }; |
1045 | 1049 | ||
diff --git a/drivers/usb/usb-skeleton.c b/drivers/usb/usb-skeleton.c index d110588b56f1..552679b8dbd1 100644 --- a/drivers/usb/usb-skeleton.c +++ b/drivers/usb/usb-skeleton.c | |||
@@ -142,7 +142,7 @@ static int skel_release(struct inode *inode, struct file *file) | |||
142 | { | 142 | { |
143 | struct usb_skel *dev; | 143 | struct usb_skel *dev; |
144 | 144 | ||
145 | dev = (struct usb_skel *)file->private_data; | 145 | dev = file->private_data; |
146 | if (dev == NULL) | 146 | if (dev == NULL) |
147 | return -ENODEV; | 147 | return -ENODEV; |
148 | 148 | ||
@@ -162,7 +162,7 @@ static int skel_flush(struct file *file, fl_owner_t id) | |||
162 | struct usb_skel *dev; | 162 | struct usb_skel *dev; |
163 | int res; | 163 | int res; |
164 | 164 | ||
165 | dev = (struct usb_skel *)file->private_data; | 165 | dev = file->private_data; |
166 | if (dev == NULL) | 166 | if (dev == NULL) |
167 | return -ENODEV; | 167 | return -ENODEV; |
168 | 168 | ||
@@ -246,7 +246,7 @@ static ssize_t skel_read(struct file *file, char *buffer, size_t count, | |||
246 | int rv; | 246 | int rv; |
247 | bool ongoing_io; | 247 | bool ongoing_io; |
248 | 248 | ||
249 | dev = (struct usb_skel *)file->private_data; | 249 | dev = file->private_data; |
250 | 250 | ||
251 | /* if we cannot read at all, return EOF */ | 251 | /* if we cannot read at all, return EOF */ |
252 | if (!dev->bulk_in_urb || !count) | 252 | if (!dev->bulk_in_urb || !count) |
@@ -401,7 +401,7 @@ static ssize_t skel_write(struct file *file, const char *user_buffer, | |||
401 | char *buf = NULL; | 401 | char *buf = NULL; |
402 | size_t writesize = min(count, (size_t)MAX_TRANSFER); | 402 | size_t writesize = min(count, (size_t)MAX_TRANSFER); |
403 | 403 | ||
404 | dev = (struct usb_skel *)file->private_data; | 404 | dev = file->private_data; |
405 | 405 | ||
406 | /* verify that we actually have some data to write */ | 406 | /* verify that we actually have some data to write */ |
407 | if (count == 0) | 407 | if (count == 0) |