diff options
Diffstat (limited to 'drivers/usb')
175 files changed, 9083 insertions, 3216 deletions
diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c index cb01b5106efd..b6483dd98acc 100644 --- a/drivers/usb/atm/ueagle-atm.c +++ b/drivers/usb/atm/ueagle-atm.c | |||
@@ -64,7 +64,6 @@ | |||
64 | #include <linux/ctype.h> | 64 | #include <linux/ctype.h> |
65 | #include <linux/sched.h> | 65 | #include <linux/sched.h> |
66 | #include <linux/kthread.h> | 66 | #include <linux/kthread.h> |
67 | #include <linux/version.h> | ||
68 | #include <linux/mutex.h> | 67 | #include <linux/mutex.h> |
69 | #include <linux/freezer.h> | 68 | #include <linux/freezer.h> |
70 | 69 | ||
diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c index 07228721cafe..06dd114910d4 100644 --- a/drivers/usb/atm/usbatm.c +++ b/drivers/usb/atm/usbatm.c | |||
@@ -344,7 +344,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char | |||
344 | __func__, sarb->len, vcc); | 344 | __func__, sarb->len, vcc); |
345 | /* discard cells already received */ | 345 | /* discard cells already received */ |
346 | skb_trim(sarb, 0); | 346 | skb_trim(sarb, 0); |
347 | UDSL_ASSERT(sarb->tail + ATM_CELL_PAYLOAD <= sarb->end); | 347 | UDSL_ASSERT(instance, sarb->tail + ATM_CELL_PAYLOAD <= sarb->end); |
348 | } | 348 | } |
349 | 349 | ||
350 | memcpy(skb_tail_pointer(sarb), source + ATM_CELL_HEADER, ATM_CELL_PAYLOAD); | 350 | memcpy(skb_tail_pointer(sarb), source + ATM_CELL_HEADER, ATM_CELL_PAYLOAD); |
@@ -432,7 +432,7 @@ static void usbatm_extract_cells(struct usbatm_data *instance, | |||
432 | unsigned char *cell_buf = instance->cell_buf; | 432 | unsigned char *cell_buf = instance->cell_buf; |
433 | unsigned int space_left = stride - buf_usage; | 433 | unsigned int space_left = stride - buf_usage; |
434 | 434 | ||
435 | UDSL_ASSERT(buf_usage <= stride); | 435 | UDSL_ASSERT(instance, buf_usage <= stride); |
436 | 436 | ||
437 | if (avail_data >= space_left) { | 437 | if (avail_data >= space_left) { |
438 | /* add new data and process cell */ | 438 | /* add new data and process cell */ |
@@ -475,7 +475,7 @@ static unsigned int usbatm_write_cells(struct usbatm_data *instance, | |||
475 | unsigned int stride = instance->tx_channel.stride; | 475 | unsigned int stride = instance->tx_channel.stride; |
476 | 476 | ||
477 | vdbg("%s: skb->len=%d, avail_space=%u", __func__, skb->len, avail_space); | 477 | vdbg("%s: skb->len=%d, avail_space=%u", __func__, skb->len, avail_space); |
478 | UDSL_ASSERT(!(avail_space % stride)); | 478 | UDSL_ASSERT(instance, !(avail_space % stride)); |
479 | 479 | ||
480 | for (bytes_written = 0; bytes_written < avail_space && ctrl->len; | 480 | for (bytes_written = 0; bytes_written < avail_space && ctrl->len; |
481 | bytes_written += stride, target += stride) { | 481 | bytes_written += stride, target += stride) { |
@@ -547,7 +547,7 @@ static void usbatm_rx_process(unsigned long data) | |||
547 | if (!urb->iso_frame_desc[i].status) { | 547 | if (!urb->iso_frame_desc[i].status) { |
548 | unsigned int actual_length = urb->iso_frame_desc[i].actual_length; | 548 | unsigned int actual_length = urb->iso_frame_desc[i].actual_length; |
549 | 549 | ||
550 | UDSL_ASSERT(actual_length <= packet_size); | 550 | UDSL_ASSERT(instance, actual_length <= packet_size); |
551 | 551 | ||
552 | if (!merge_length) | 552 | if (!merge_length) |
553 | merge_start = (unsigned char *)urb->transfer_buffer + urb->iso_frame_desc[i].offset; | 553 | merge_start = (unsigned char *)urb->transfer_buffer + urb->iso_frame_desc[i].offset; |
@@ -640,14 +640,13 @@ static void usbatm_cancel_send(struct usbatm_data *instance, | |||
640 | 640 | ||
641 | atm_dbg(instance, "%s entered\n", __func__); | 641 | atm_dbg(instance, "%s entered\n", __func__); |
642 | spin_lock_irq(&instance->sndqueue.lock); | 642 | spin_lock_irq(&instance->sndqueue.lock); |
643 | for (skb = instance->sndqueue.next, n = skb->next; | 643 | skb_queue_walk_safe(&instance->sndqueue, skb, n) { |
644 | skb != (struct sk_buff *)&instance->sndqueue; | ||
645 | skb = n, n = skb->next) | ||
646 | if (UDSL_SKB(skb)->atm.vcc == vcc) { | 644 | if (UDSL_SKB(skb)->atm.vcc == vcc) { |
647 | atm_dbg(instance, "%s: popping skb 0x%p\n", __func__, skb); | 645 | atm_dbg(instance, "%s: popping skb 0x%p\n", __func__, skb); |
648 | __skb_unlink(skb, &instance->sndqueue); | 646 | __skb_unlink(skb, &instance->sndqueue); |
649 | usbatm_pop(vcc, skb); | 647 | usbatm_pop(vcc, skb); |
650 | } | 648 | } |
649 | } | ||
651 | spin_unlock_irq(&instance->sndqueue.lock); | 650 | spin_unlock_irq(&instance->sndqueue.lock); |
652 | 651 | ||
653 | tasklet_disable(&instance->tx_channel.tasklet); | 652 | tasklet_disable(&instance->tx_channel.tasklet); |
@@ -1189,7 +1188,7 @@ int usbatm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id, | |||
1189 | struct urb *urb; | 1188 | struct urb *urb; |
1190 | unsigned int iso_packets = usb_pipeisoc(channel->endpoint) ? channel->buf_size / channel->packet_size : 0; | 1189 | unsigned int iso_packets = usb_pipeisoc(channel->endpoint) ? channel->buf_size / channel->packet_size : 0; |
1191 | 1190 | ||
1192 | UDSL_ASSERT(!usb_pipeisoc(channel->endpoint) || usb_pipein(channel->endpoint)); | 1191 | UDSL_ASSERT(instance, !usb_pipeisoc(channel->endpoint) || usb_pipein(channel->endpoint)); |
1193 | 1192 | ||
1194 | urb = usb_alloc_urb(iso_packets, GFP_KERNEL); | 1193 | urb = usb_alloc_urb(iso_packets, GFP_KERNEL); |
1195 | if (!urb) { | 1194 | if (!urb) { |
diff --git a/drivers/usb/atm/usbatm.h b/drivers/usb/atm/usbatm.h index e6887c6cf3cf..f6f4508a9d42 100644 --- a/drivers/usb/atm/usbatm.h +++ b/drivers/usb/atm/usbatm.h | |||
@@ -40,9 +40,15 @@ | |||
40 | */ | 40 | */ |
41 | 41 | ||
42 | #ifdef DEBUG | 42 | #ifdef DEBUG |
43 | #define UDSL_ASSERT(x) BUG_ON(!(x)) | 43 | #define UDSL_ASSERT(instance, x) BUG_ON(!(x)) |
44 | #else | 44 | #else |
45 | #define UDSL_ASSERT(x) do { if (!(x)) warn("failed assertion '%s' at line %d", __stringify(x), __LINE__); } while(0) | 45 | #define UDSL_ASSERT(instance, x) \ |
46 | do { \ | ||
47 | if (!(x)) \ | ||
48 | dev_warn(&(instance)->usb_intf->dev, \ | ||
49 | "failed assertion '%s' at line %d", \ | ||
50 | __stringify(x), __LINE__); \ | ||
51 | } while(0) | ||
46 | #endif | 52 | #endif |
47 | 53 | ||
48 | #define usb_err(instance, format, arg...) \ | 54 | #define usb_err(instance, format, arg...) \ |
diff --git a/drivers/usb/atm/xusbatm.c b/drivers/usb/atm/xusbatm.c index 8472543eee81..17d167bbd2dc 100644 --- a/drivers/usb/atm/xusbatm.c +++ b/drivers/usb/atm/xusbatm.c | |||
@@ -193,7 +193,7 @@ static int __init xusbatm_init(void) | |||
193 | num_vendor != num_product || | 193 | num_vendor != num_product || |
194 | num_vendor != num_rx_endpoint || | 194 | num_vendor != num_rx_endpoint || |
195 | num_vendor != num_tx_endpoint) { | 195 | num_vendor != num_tx_endpoint) { |
196 | warn("malformed module parameters"); | 196 | printk(KERN_WARNING "xusbatm: malformed module parameters\n"); |
197 | return -EINVAL; | 197 | return -EINVAL; |
198 | } | 198 | } |
199 | 199 | ||
diff --git a/drivers/usb/class/Kconfig b/drivers/usb/class/Kconfig index 66f17ed88cb5..2519e320098f 100644 --- a/drivers/usb/class/Kconfig +++ b/drivers/usb/class/Kconfig | |||
@@ -40,3 +40,13 @@ config USB_WDM | |||
40 | To compile this driver as a module, choose M here: the | 40 | To compile this driver as a module, choose M here: the |
41 | module will be called cdc-wdm. | 41 | module will be called cdc-wdm. |
42 | 42 | ||
43 | config USB_TMC | ||
44 | tristate "USB Test and Measurement Class support" | ||
45 | depends on USB | ||
46 | help | ||
47 | Say Y here if you want to connect a USB device that follows | ||
48 | the USB.org specification for USB Test and Measurement devices | ||
49 | to your computer's USB port. | ||
50 | |||
51 | To compile this driver as a module, choose M here: the | ||
52 | module will be called usbtmc. | ||
diff --git a/drivers/usb/class/Makefile b/drivers/usb/class/Makefile index 535d59a30600..32e85277b5cf 100644 --- a/drivers/usb/class/Makefile +++ b/drivers/usb/class/Makefile | |||
@@ -6,3 +6,4 @@ | |||
6 | obj-$(CONFIG_USB_ACM) += cdc-acm.o | 6 | obj-$(CONFIG_USB_ACM) += cdc-acm.o |
7 | obj-$(CONFIG_USB_PRINTER) += usblp.o | 7 | obj-$(CONFIG_USB_PRINTER) += usblp.o |
8 | obj-$(CONFIG_USB_WDM) += cdc-wdm.o | 8 | obj-$(CONFIG_USB_WDM) += cdc-wdm.o |
9 | obj-$(CONFIG_USB_TMC) += usbtmc.o | ||
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c index efc4373ededb..fab23ee8702b 100644 --- a/drivers/usb/class/cdc-acm.c +++ b/drivers/usb/class/cdc-acm.c | |||
@@ -326,8 +326,8 @@ exit: | |||
326 | usb_mark_last_busy(acm->dev); | 326 | usb_mark_last_busy(acm->dev); |
327 | retval = usb_submit_urb (urb, GFP_ATOMIC); | 327 | retval = usb_submit_urb (urb, GFP_ATOMIC); |
328 | if (retval) | 328 | if (retval) |
329 | err ("%s - usb_submit_urb failed with result %d", | 329 | dev_err(&urb->dev->dev, "%s - usb_submit_urb failed with " |
330 | __func__, retval); | 330 | "result %d", __func__, retval); |
331 | } | 331 | } |
332 | 332 | ||
333 | /* data interface returns incoming bytes, or we got unthrottled */ | 333 | /* data interface returns incoming bytes, or we got unthrottled */ |
@@ -514,7 +514,7 @@ static void acm_waker(struct work_struct *waker) | |||
514 | 514 | ||
515 | rv = usb_autopm_get_interface(acm->control); | 515 | rv = usb_autopm_get_interface(acm->control); |
516 | if (rv < 0) { | 516 | if (rv < 0) { |
517 | err("Autopm failure in %s", __func__); | 517 | dev_err(&acm->dev->dev, "Autopm failure in %s\n", __func__); |
518 | return; | 518 | return; |
519 | } | 519 | } |
520 | if (acm->delayed_wb) { | 520 | if (acm->delayed_wb) { |
@@ -589,8 +589,8 @@ static int acm_tty_open(struct tty_struct *tty, struct file *filp) | |||
589 | tasklet_schedule(&acm->urb_task); | 589 | tasklet_schedule(&acm->urb_task); |
590 | 590 | ||
591 | done: | 591 | done: |
592 | err_out: | ||
593 | mutex_unlock(&acm->mutex); | 592 | mutex_unlock(&acm->mutex); |
593 | err_out: | ||
594 | mutex_unlock(&open_mutex); | 594 | mutex_unlock(&open_mutex); |
595 | return rv; | 595 | return rv; |
596 | 596 | ||
@@ -924,7 +924,7 @@ static int acm_probe (struct usb_interface *intf, | |||
924 | 924 | ||
925 | /* normal probing*/ | 925 | /* normal probing*/ |
926 | if (!buffer) { | 926 | if (!buffer) { |
927 | err("Weird descriptor references\n"); | 927 | dev_err(&intf->dev, "Weird descriptor references\n"); |
928 | return -EINVAL; | 928 | return -EINVAL; |
929 | } | 929 | } |
930 | 930 | ||
@@ -934,21 +934,24 @@ static int acm_probe (struct usb_interface *intf, | |||
934 | buflen = intf->cur_altsetting->endpoint->extralen; | 934 | buflen = intf->cur_altsetting->endpoint->extralen; |
935 | buffer = intf->cur_altsetting->endpoint->extra; | 935 | buffer = intf->cur_altsetting->endpoint->extra; |
936 | } else { | 936 | } else { |
937 | err("Zero length descriptor references\n"); | 937 | dev_err(&intf->dev, |
938 | "Zero length descriptor references\n"); | ||
938 | return -EINVAL; | 939 | return -EINVAL; |
939 | } | 940 | } |
940 | } | 941 | } |
941 | 942 | ||
942 | while (buflen > 0) { | 943 | while (buflen > 0) { |
943 | if (buffer [1] != USB_DT_CS_INTERFACE) { | 944 | if (buffer [1] != USB_DT_CS_INTERFACE) { |
944 | err("skipping garbage\n"); | 945 | dev_err(&intf->dev, "skipping garbage\n"); |
945 | goto next_desc; | 946 | goto next_desc; |
946 | } | 947 | } |
947 | 948 | ||
948 | switch (buffer [2]) { | 949 | switch (buffer [2]) { |
949 | case USB_CDC_UNION_TYPE: /* we've found it */ | 950 | case USB_CDC_UNION_TYPE: /* we've found it */ |
950 | if (union_header) { | 951 | if (union_header) { |
951 | err("More than one union descriptor, skipping ..."); | 952 | dev_err(&intf->dev, "More than one " |
953 | "union descriptor, " | ||
954 | "skipping ...\n"); | ||
952 | goto next_desc; | 955 | goto next_desc; |
953 | } | 956 | } |
954 | union_header = (struct usb_cdc_union_desc *) | 957 | union_header = (struct usb_cdc_union_desc *) |
@@ -966,7 +969,9 @@ static int acm_probe (struct usb_interface *intf, | |||
966 | call_management_function = buffer[3]; | 969 | call_management_function = buffer[3]; |
967 | call_interface_num = buffer[4]; | 970 | call_interface_num = buffer[4]; |
968 | if ((call_management_function & 3) != 3) | 971 | if ((call_management_function & 3) != 3) |
969 | err("This device cannot do calls on its own. It is no modem."); | 972 | dev_err(&intf->dev, "This device " |
973 | "cannot do calls on its own. " | ||
974 | "It is no modem.\n"); | ||
970 | break; | 975 | break; |
971 | default: | 976 | default: |
972 | /* there are LOTS more CDC descriptors that | 977 | /* there are LOTS more CDC descriptors that |
@@ -1051,7 +1056,7 @@ skip_normal_probe: | |||
1051 | for (minor = 0; minor < ACM_TTY_MINORS && acm_table[minor]; minor++); | 1056 | for (minor = 0; minor < ACM_TTY_MINORS && acm_table[minor]; minor++); |
1052 | 1057 | ||
1053 | if (minor == ACM_TTY_MINORS) { | 1058 | if (minor == ACM_TTY_MINORS) { |
1054 | err("no more free acm devices"); | 1059 | dev_err(&intf->dev, "no more free acm devices\n"); |
1055 | return -ENODEV; | 1060 | return -ENODEV; |
1056 | } | 1061 | } |
1057 | 1062 | ||
@@ -1362,6 +1367,9 @@ static struct usb_device_id acm_ids[] = { | |||
1362 | { USB_DEVICE(0x0803, 0x3095), /* Zoom Telephonics Model 3095F USB MODEM */ | 1367 | { USB_DEVICE(0x0803, 0x3095), /* Zoom Telephonics Model 3095F USB MODEM */ |
1363 | .driver_info = NO_UNION_NORMAL, /* has no union descriptor */ | 1368 | .driver_info = NO_UNION_NORMAL, /* has no union descriptor */ |
1364 | }, | 1369 | }, |
1370 | { USB_DEVICE(0x0572, 0x1321), /* Conexant USB MODEM CX93010 */ | ||
1371 | .driver_info = NO_UNION_NORMAL, /* has no union descriptor */ | ||
1372 | }, | ||
1365 | 1373 | ||
1366 | /* control interfaces with various AT-command sets */ | 1374 | /* control interfaces with various AT-command sets */ |
1367 | { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM, | 1375 | { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM, |
@@ -1451,7 +1459,8 @@ static int __init acm_init(void) | |||
1451 | return retval; | 1459 | return retval; |
1452 | } | 1460 | } |
1453 | 1461 | ||
1454 | info(DRIVER_VERSION ":" DRIVER_DESC); | 1462 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
1463 | DRIVER_DESC "\n"); | ||
1455 | 1464 | ||
1456 | return 0; | 1465 | return 0; |
1457 | } | 1466 | } |
diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c index 7e8e1235e4e5..7429f70b9d06 100644 --- a/drivers/usb/class/cdc-wdm.c +++ b/drivers/usb/class/cdc-wdm.c | |||
@@ -132,10 +132,12 @@ static void wdm_in_callback(struct urb *urb) | |||
132 | "nonzero urb status received: -ESHUTDOWN"); | 132 | "nonzero urb status received: -ESHUTDOWN"); |
133 | break; | 133 | break; |
134 | case -EPIPE: | 134 | case -EPIPE: |
135 | err("nonzero urb status received: -EPIPE"); | 135 | dev_err(&desc->intf->dev, |
136 | "nonzero urb status received: -EPIPE\n"); | ||
136 | break; | 137 | break; |
137 | default: | 138 | default: |
138 | err("Unexpected error %d", status); | 139 | dev_err(&desc->intf->dev, |
140 | "Unexpected error %d\n", status); | ||
139 | break; | 141 | break; |
140 | } | 142 | } |
141 | } | 143 | } |
@@ -170,16 +172,18 @@ static void wdm_int_callback(struct urb *urb) | |||
170 | return; /* unplug */ | 172 | return; /* unplug */ |
171 | case -EPIPE: | 173 | case -EPIPE: |
172 | set_bit(WDM_INT_STALL, &desc->flags); | 174 | set_bit(WDM_INT_STALL, &desc->flags); |
173 | err("Stall on int endpoint"); | 175 | dev_err(&desc->intf->dev, "Stall on int endpoint\n"); |
174 | goto sw; /* halt is cleared in work */ | 176 | goto sw; /* halt is cleared in work */ |
175 | default: | 177 | default: |
176 | err("nonzero urb status received: %d", status); | 178 | dev_err(&desc->intf->dev, |
179 | "nonzero urb status received: %d\n", status); | ||
177 | break; | 180 | break; |
178 | } | 181 | } |
179 | } | 182 | } |
180 | 183 | ||
181 | if (urb->actual_length < sizeof(struct usb_cdc_notification)) { | 184 | if (urb->actual_length < sizeof(struct usb_cdc_notification)) { |
182 | err("wdm_int_callback - %d bytes", urb->actual_length); | 185 | dev_err(&desc->intf->dev, "wdm_int_callback - %d bytes\n", |
186 | urb->actual_length); | ||
183 | goto exit; | 187 | goto exit; |
184 | } | 188 | } |
185 | 189 | ||
@@ -198,7 +202,8 @@ static void wdm_int_callback(struct urb *urb) | |||
198 | goto exit; | 202 | goto exit; |
199 | default: | 203 | default: |
200 | clear_bit(WDM_POLL_RUNNING, &desc->flags); | 204 | clear_bit(WDM_POLL_RUNNING, &desc->flags); |
201 | err("unknown notification %d received: index %d len %d", | 205 | dev_err(&desc->intf->dev, |
206 | "unknown notification %d received: index %d len %d\n", | ||
202 | dr->bNotificationType, dr->wIndex, dr->wLength); | 207 | dr->bNotificationType, dr->wIndex, dr->wLength); |
203 | goto exit; | 208 | goto exit; |
204 | } | 209 | } |
@@ -236,14 +241,16 @@ static void wdm_int_callback(struct urb *urb) | |||
236 | sw: | 241 | sw: |
237 | rv = schedule_work(&desc->rxwork); | 242 | rv = schedule_work(&desc->rxwork); |
238 | if (rv) | 243 | if (rv) |
239 | err("Cannot schedule work"); | 244 | dev_err(&desc->intf->dev, |
245 | "Cannot schedule work\n"); | ||
240 | } | 246 | } |
241 | } | 247 | } |
242 | exit: | 248 | exit: |
243 | rv = usb_submit_urb(urb, GFP_ATOMIC); | 249 | rv = usb_submit_urb(urb, GFP_ATOMIC); |
244 | if (rv) | 250 | if (rv) |
245 | err("%s - usb_submit_urb failed with result %d", | 251 | dev_err(&desc->intf->dev, |
246 | __func__, rv); | 252 | "%s - usb_submit_urb failed with result %d\n", |
253 | __func__, rv); | ||
247 | 254 | ||
248 | } | 255 | } |
249 | 256 | ||
@@ -353,7 +360,7 @@ static ssize_t wdm_write | |||
353 | if (rv < 0) { | 360 | if (rv < 0) { |
354 | kfree(buf); | 361 | kfree(buf); |
355 | clear_bit(WDM_IN_USE, &desc->flags); | 362 | clear_bit(WDM_IN_USE, &desc->flags); |
356 | err("Tx URB error: %d", rv); | 363 | dev_err(&desc->intf->dev, "Tx URB error: %d\n", rv); |
357 | } else { | 364 | } else { |
358 | dev_dbg(&desc->intf->dev, "Tx URB has been submitted index=%d", | 365 | dev_dbg(&desc->intf->dev, "Tx URB has been submitted index=%d", |
359 | req->wIndex); | 366 | req->wIndex); |
@@ -401,7 +408,8 @@ retry: | |||
401 | int t = desc->rerr; | 408 | int t = desc->rerr; |
402 | desc->rerr = 0; | 409 | desc->rerr = 0; |
403 | spin_unlock_irq(&desc->iuspin); | 410 | spin_unlock_irq(&desc->iuspin); |
404 | err("reading had resulted in %d", t); | 411 | dev_err(&desc->intf->dev, |
412 | "reading had resulted in %d\n", t); | ||
405 | rv = -EIO; | 413 | rv = -EIO; |
406 | goto err; | 414 | goto err; |
407 | } | 415 | } |
@@ -440,7 +448,7 @@ retry: | |||
440 | err: | 448 | err: |
441 | mutex_unlock(&desc->rlock); | 449 | mutex_unlock(&desc->rlock); |
442 | if (rv < 0) | 450 | if (rv < 0) |
443 | err("wdm_read: exit error"); | 451 | dev_err(&desc->intf->dev, "wdm_read: exit error\n"); |
444 | return rv; | 452 | return rv; |
445 | } | 453 | } |
446 | 454 | ||
@@ -450,7 +458,8 @@ static int wdm_flush(struct file *file, fl_owner_t id) | |||
450 | 458 | ||
451 | wait_event(desc->wait, !test_bit(WDM_IN_USE, &desc->flags)); | 459 | wait_event(desc->wait, !test_bit(WDM_IN_USE, &desc->flags)); |
452 | if (desc->werr < 0) | 460 | if (desc->werr < 0) |
453 | err("Error in flush path: %d", desc->werr); | 461 | dev_err(&desc->intf->dev, "Error in flush path: %d\n", |
462 | desc->werr); | ||
454 | 463 | ||
455 | return desc->werr; | 464 | return desc->werr; |
456 | } | 465 | } |
@@ -502,7 +511,7 @@ static int wdm_open(struct inode *inode, struct file *file) | |||
502 | 511 | ||
503 | rv = usb_autopm_get_interface(desc->intf); | 512 | rv = usb_autopm_get_interface(desc->intf); |
504 | if (rv < 0) { | 513 | if (rv < 0) { |
505 | err("Error autopm - %d", rv); | 514 | dev_err(&desc->intf->dev, "Error autopm - %d\n", rv); |
506 | goto out; | 515 | goto out; |
507 | } | 516 | } |
508 | intf->needs_remote_wakeup = 1; | 517 | intf->needs_remote_wakeup = 1; |
@@ -512,7 +521,8 @@ static int wdm_open(struct inode *inode, struct file *file) | |||
512 | rv = usb_submit_urb(desc->validity, GFP_KERNEL); | 521 | rv = usb_submit_urb(desc->validity, GFP_KERNEL); |
513 | if (rv < 0) { | 522 | if (rv < 0) { |
514 | desc->count--; | 523 | desc->count--; |
515 | err("Error submitting int urb - %d", rv); | 524 | dev_err(&desc->intf->dev, |
525 | "Error submitting int urb - %d\n", rv); | ||
516 | } | 526 | } |
517 | } else { | 527 | } else { |
518 | rv = 0; | 528 | rv = 0; |
@@ -600,7 +610,7 @@ static int wdm_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
600 | 610 | ||
601 | while (buflen > 0) { | 611 | while (buflen > 0) { |
602 | if (buffer [1] != USB_DT_CS_INTERFACE) { | 612 | if (buffer [1] != USB_DT_CS_INTERFACE) { |
603 | err("skipping garbage"); | 613 | dev_err(&intf->dev, "skipping garbage\n"); |
604 | goto next_desc; | 614 | goto next_desc; |
605 | } | 615 | } |
606 | 616 | ||
@@ -614,7 +624,8 @@ static int wdm_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
614 | "Finding maximum buffer length: %d", maxcom); | 624 | "Finding maximum buffer length: %d", maxcom); |
615 | break; | 625 | break; |
616 | default: | 626 | default: |
617 | err("Ignoring extra header, type %d, length %d", | 627 | dev_err(&intf->dev, |
628 | "Ignoring extra header, type %d, length %d\n", | ||
618 | buffer[2], buffer[0]); | 629 | buffer[2], buffer[0]); |
619 | break; | 630 | break; |
620 | } | 631 | } |
@@ -772,7 +783,8 @@ static int recover_from_urb_loss(struct wdm_device *desc) | |||
772 | if (desc->count) { | 783 | if (desc->count) { |
773 | rv = usb_submit_urb(desc->validity, GFP_NOIO); | 784 | rv = usb_submit_urb(desc->validity, GFP_NOIO); |
774 | if (rv < 0) | 785 | if (rv < 0) |
775 | err("Error resume submitting int urb - %d", rv); | 786 | dev_err(&desc->intf->dev, |
787 | "Error resume submitting int urb - %d\n", rv); | ||
776 | } | 788 | } |
777 | return rv; | 789 | return rv; |
778 | } | 790 | } |
diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c index 0647164d36db..b5775af3ba26 100644 --- a/drivers/usb/class/usblp.c +++ b/drivers/usb/class/usblp.c | |||
@@ -593,8 +593,9 @@ static long usblp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
593 | err = usblp_hp_channel_change_request(usblp, | 593 | err = usblp_hp_channel_change_request(usblp, |
594 | arg, &newChannel); | 594 | arg, &newChannel); |
595 | if (err < 0) { | 595 | if (err < 0) { |
596 | err("usblp%d: error = %d setting " | 596 | dev_err(&usblp->dev->dev, |
597 | "HP channel", | 597 | "usblp%d: error = %d setting " |
598 | "HP channel\n", | ||
598 | usblp->minor, err); | 599 | usblp->minor, err); |
599 | retval = -EIO; | 600 | retval = -EIO; |
600 | goto done; | 601 | goto done; |
@@ -1076,15 +1077,16 @@ static int usblp_probe(struct usb_interface *intf, | |||
1076 | const struct usb_device_id *id) | 1077 | const struct usb_device_id *id) |
1077 | { | 1078 | { |
1078 | struct usb_device *dev = interface_to_usbdev (intf); | 1079 | struct usb_device *dev = interface_to_usbdev (intf); |
1079 | struct usblp *usblp = NULL; | 1080 | struct usblp *usblp; |
1080 | int protocol; | 1081 | int protocol; |
1081 | int retval; | 1082 | int retval; |
1082 | 1083 | ||
1083 | /* Malloc and start initializing usblp structure so we can use it | 1084 | /* Malloc and start initializing usblp structure so we can use it |
1084 | * directly. */ | 1085 | * directly. */ |
1085 | if (!(usblp = kzalloc(sizeof(struct usblp), GFP_KERNEL))) { | 1086 | usblp = kzalloc(sizeof(struct usblp), GFP_KERNEL); |
1087 | if (!usblp) { | ||
1086 | retval = -ENOMEM; | 1088 | retval = -ENOMEM; |
1087 | goto abort; | 1089 | goto abort_ret; |
1088 | } | 1090 | } |
1089 | usblp->dev = dev; | 1091 | usblp->dev = dev; |
1090 | mutex_init(&usblp->wmut); | 1092 | mutex_init(&usblp->wmut); |
@@ -1179,12 +1181,11 @@ abort_intfdata: | |||
1179 | usb_set_intfdata (intf, NULL); | 1181 | usb_set_intfdata (intf, NULL); |
1180 | device_remove_file(&intf->dev, &dev_attr_ieee1284_id); | 1182 | device_remove_file(&intf->dev, &dev_attr_ieee1284_id); |
1181 | abort: | 1183 | abort: |
1182 | if (usblp) { | 1184 | kfree(usblp->readbuf); |
1183 | kfree(usblp->readbuf); | 1185 | kfree(usblp->statusbuf); |
1184 | kfree(usblp->statusbuf); | 1186 | kfree(usblp->device_id_string); |
1185 | kfree(usblp->device_id_string); | 1187 | kfree(usblp); |
1186 | kfree(usblp); | 1188 | abort_ret: |
1187 | } | ||
1188 | return retval; | 1189 | return retval; |
1189 | } | 1190 | } |
1190 | 1191 | ||
@@ -1345,7 +1346,7 @@ static void usblp_disconnect(struct usb_interface *intf) | |||
1345 | usb_deregister_dev(intf, &usblp_class); | 1346 | usb_deregister_dev(intf, &usblp_class); |
1346 | 1347 | ||
1347 | if (!usblp || !usblp->dev) { | 1348 | if (!usblp || !usblp->dev) { |
1348 | err("bogus disconnect"); | 1349 | dev_err(&intf->dev, "bogus disconnect\n"); |
1349 | BUG (); | 1350 | BUG (); |
1350 | } | 1351 | } |
1351 | 1352 | ||
diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c new file mode 100644 index 000000000000..543811f6e6e8 --- /dev/null +++ b/drivers/usb/class/usbtmc.c | |||
@@ -0,0 +1,1087 @@ | |||
1 | /** | ||
2 | * drivers/usb/class/usbtmc.c - USB Test & Measurment class driver | ||
3 | * | ||
4 | * Copyright (C) 2007 Stefan Kopp, Gechingen, Germany | ||
5 | * Copyright (C) 2008 Novell, Inc. | ||
6 | * Copyright (C) 2008 Greg Kroah-Hartman <gregkh@suse.de> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or | ||
9 | * modify it under the terms of the GNU General Public License | ||
10 | * as published by the Free Software Foundation; either version 2 | ||
11 | * of the License, or (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | * The GNU General Public License is available at | ||
19 | * http://www.gnu.org/copyleft/gpl.html. | ||
20 | */ | ||
21 | |||
22 | #include <linux/init.h> | ||
23 | #include <linux/module.h> | ||
24 | #include <linux/fs.h> | ||
25 | #include <linux/uaccess.h> | ||
26 | #include <linux/kref.h> | ||
27 | #include <linux/mutex.h> | ||
28 | #include <linux/usb.h> | ||
29 | #include <linux/usb/tmc.h> | ||
30 | |||
31 | |||
32 | #define USBTMC_MINOR_BASE 176 | ||
33 | |||
34 | /* | ||
35 | * Size of driver internal IO buffer. Must be multiple of 4 and at least as | ||
36 | * large as wMaxPacketSize (which is usually 512 bytes). | ||
37 | */ | ||
38 | #define USBTMC_SIZE_IOBUFFER 2048 | ||
39 | |||
40 | /* Default USB timeout (in milliseconds) */ | ||
41 | #define USBTMC_TIMEOUT 10 | ||
42 | |||
43 | /* | ||
44 | * Maximum number of read cycles to empty bulk in endpoint during CLEAR and | ||
45 | * ABORT_BULK_IN requests. Ends the loop if (for whatever reason) a short | ||
46 | * packet is never read. | ||
47 | */ | ||
48 | #define USBTMC_MAX_READS_TO_CLEAR_BULK_IN 100 | ||
49 | |||
50 | static struct usb_device_id usbtmc_devices[] = { | ||
51 | { USB_INTERFACE_INFO(USB_CLASS_APP_SPEC, 3, 0), }, | ||
52 | { 0, } /* terminating entry */ | ||
53 | }; | ||
54 | |||
55 | /* | ||
56 | * This structure is the capabilities for the device | ||
57 | * See section 4.2.1.8 of the USBTMC specification for details. | ||
58 | */ | ||
59 | struct usbtmc_dev_capabilities { | ||
60 | __u8 interface_capabilities; | ||
61 | __u8 device_capabilities; | ||
62 | __u8 usb488_interface_capabilities; | ||
63 | __u8 usb488_device_capabilities; | ||
64 | }; | ||
65 | |||
66 | /* This structure holds private data for each USBTMC device. One copy is | ||
67 | * allocated for each USBTMC device in the driver's probe function. | ||
68 | */ | ||
69 | struct usbtmc_device_data { | ||
70 | const struct usb_device_id *id; | ||
71 | struct usb_device *usb_dev; | ||
72 | struct usb_interface *intf; | ||
73 | |||
74 | unsigned int bulk_in; | ||
75 | unsigned int bulk_out; | ||
76 | |||
77 | u8 bTag; | ||
78 | u8 bTag_last_write; /* needed for abort */ | ||
79 | u8 bTag_last_read; /* needed for abort */ | ||
80 | |||
81 | /* attributes from the USB TMC spec for this device */ | ||
82 | u8 TermChar; | ||
83 | bool TermCharEnabled; | ||
84 | bool auto_abort; | ||
85 | |||
86 | struct usbtmc_dev_capabilities capabilities; | ||
87 | struct kref kref; | ||
88 | struct mutex io_mutex; /* only one i/o function running at a time */ | ||
89 | }; | ||
90 | #define to_usbtmc_data(d) container_of(d, struct usbtmc_device_data, kref) | ||
91 | |||
92 | /* Forward declarations */ | ||
93 | static struct usb_driver usbtmc_driver; | ||
94 | |||
95 | static void usbtmc_delete(struct kref *kref) | ||
96 | { | ||
97 | struct usbtmc_device_data *data = to_usbtmc_data(kref); | ||
98 | |||
99 | usb_put_dev(data->usb_dev); | ||
100 | kfree(data); | ||
101 | } | ||
102 | |||
103 | static int usbtmc_open(struct inode *inode, struct file *filp) | ||
104 | { | ||
105 | struct usb_interface *intf; | ||
106 | struct usbtmc_device_data *data; | ||
107 | int retval = -ENODEV; | ||
108 | |||
109 | intf = usb_find_interface(&usbtmc_driver, iminor(inode)); | ||
110 | if (!intf) { | ||
111 | printk(KERN_ERR KBUILD_MODNAME | ||
112 | ": can not find device for minor %d", iminor(inode)); | ||
113 | goto exit; | ||
114 | } | ||
115 | |||
116 | data = usb_get_intfdata(intf); | ||
117 | kref_get(&data->kref); | ||
118 | |||
119 | /* Store pointer in file structure's private data field */ | ||
120 | filp->private_data = data; | ||
121 | |||
122 | exit: | ||
123 | return retval; | ||
124 | } | ||
125 | |||
126 | static int usbtmc_release(struct inode *inode, struct file *file) | ||
127 | { | ||
128 | struct usbtmc_device_data *data = file->private_data; | ||
129 | |||
130 | kref_put(&data->kref, usbtmc_delete); | ||
131 | return 0; | ||
132 | } | ||
133 | |||
134 | static int usbtmc_ioctl_abort_bulk_in(struct usbtmc_device_data *data) | ||
135 | { | ||
136 | char *buffer; | ||
137 | struct device *dev; | ||
138 | int rv; | ||
139 | int n; | ||
140 | int actual; | ||
141 | struct usb_host_interface *current_setting; | ||
142 | int max_size; | ||
143 | |||
144 | dev = &data->intf->dev; | ||
145 | buffer = kmalloc(USBTMC_SIZE_IOBUFFER, GFP_KERNEL); | ||
146 | if (!buffer) | ||
147 | return -ENOMEM; | ||
148 | |||
149 | rv = usb_control_msg(data->usb_dev, | ||
150 | usb_rcvctrlpipe(data->usb_dev, 0), | ||
151 | USBTMC_REQUEST_INITIATE_ABORT_BULK_IN, | ||
152 | USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_ENDPOINT, | ||
153 | data->bTag_last_read, data->bulk_in, | ||
154 | buffer, 2, USBTMC_TIMEOUT); | ||
155 | |||
156 | if (rv < 0) { | ||
157 | dev_err(dev, "usb_control_msg returned %d\n", rv); | ||
158 | goto exit; | ||
159 | } | ||
160 | |||
161 | dev_dbg(dev, "INITIATE_ABORT_BULK_IN returned %x\n", buffer[0]); | ||
162 | |||
163 | if (buffer[0] == USBTMC_STATUS_FAILED) { | ||
164 | rv = 0; | ||
165 | goto exit; | ||
166 | } | ||
167 | |||
168 | if (buffer[0] != USBTMC_STATUS_SUCCESS) { | ||
169 | dev_err(dev, "INITIATE_ABORT_BULK_IN returned %x\n", | ||
170 | buffer[0]); | ||
171 | rv = -EPERM; | ||
172 | goto exit; | ||
173 | } | ||
174 | |||
175 | max_size = 0; | ||
176 | current_setting = data->intf->cur_altsetting; | ||
177 | for (n = 0; n < current_setting->desc.bNumEndpoints; n++) | ||
178 | if (current_setting->endpoint[n].desc.bEndpointAddress == | ||
179 | data->bulk_in) | ||
180 | max_size = le16_to_cpu(current_setting->endpoint[n]. | ||
181 | desc.wMaxPacketSize); | ||
182 | |||
183 | if (max_size == 0) { | ||
184 | dev_err(dev, "Couldn't get wMaxPacketSize\n"); | ||
185 | rv = -EPERM; | ||
186 | goto exit; | ||
187 | } | ||
188 | |||
189 | dev_dbg(&data->intf->dev, "wMaxPacketSize is %d\n", max_size); | ||
190 | |||
191 | n = 0; | ||
192 | |||
193 | do { | ||
194 | dev_dbg(dev, "Reading from bulk in EP\n"); | ||
195 | |||
196 | rv = usb_bulk_msg(data->usb_dev, | ||
197 | usb_rcvbulkpipe(data->usb_dev, | ||
198 | data->bulk_in), | ||
199 | buffer, USBTMC_SIZE_IOBUFFER, | ||
200 | &actual, USBTMC_TIMEOUT); | ||
201 | |||
202 | n++; | ||
203 | |||
204 | if (rv < 0) { | ||
205 | dev_err(dev, "usb_bulk_msg returned %d\n", rv); | ||
206 | goto exit; | ||
207 | } | ||
208 | } while ((actual == max_size) && | ||
209 | (n < USBTMC_MAX_READS_TO_CLEAR_BULK_IN)); | ||
210 | |||
211 | if (actual == max_size) { | ||
212 | dev_err(dev, "Couldn't clear device buffer within %d cycles\n", | ||
213 | USBTMC_MAX_READS_TO_CLEAR_BULK_IN); | ||
214 | rv = -EPERM; | ||
215 | goto exit; | ||
216 | } | ||
217 | |||
218 | n = 0; | ||
219 | |||
220 | usbtmc_abort_bulk_in_status: | ||
221 | rv = usb_control_msg(data->usb_dev, | ||
222 | usb_rcvctrlpipe(data->usb_dev, 0), | ||
223 | USBTMC_REQUEST_CHECK_ABORT_BULK_IN_STATUS, | ||
224 | USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_ENDPOINT, | ||
225 | 0, data->bulk_in, buffer, 0x08, | ||
226 | USBTMC_TIMEOUT); | ||
227 | |||
228 | if (rv < 0) { | ||
229 | dev_err(dev, "usb_control_msg returned %d\n", rv); | ||
230 | goto exit; | ||
231 | } | ||
232 | |||
233 | dev_dbg(dev, "INITIATE_ABORT_BULK_IN returned %x\n", buffer[0]); | ||
234 | |||
235 | if (buffer[0] == USBTMC_STATUS_SUCCESS) { | ||
236 | rv = 0; | ||
237 | goto exit; | ||
238 | } | ||
239 | |||
240 | if (buffer[0] != USBTMC_STATUS_PENDING) { | ||
241 | dev_err(dev, "INITIATE_ABORT_BULK_IN returned %x\n", buffer[0]); | ||
242 | rv = -EPERM; | ||
243 | goto exit; | ||
244 | } | ||
245 | |||
246 | if (buffer[1] == 1) | ||
247 | do { | ||
248 | dev_dbg(dev, "Reading from bulk in EP\n"); | ||
249 | |||
250 | rv = usb_bulk_msg(data->usb_dev, | ||
251 | usb_rcvbulkpipe(data->usb_dev, | ||
252 | data->bulk_in), | ||
253 | buffer, USBTMC_SIZE_IOBUFFER, | ||
254 | &actual, USBTMC_TIMEOUT); | ||
255 | |||
256 | n++; | ||
257 | |||
258 | if (rv < 0) { | ||
259 | dev_err(dev, "usb_bulk_msg returned %d\n", rv); | ||
260 | goto exit; | ||
261 | } | ||
262 | } while ((actual = max_size) && | ||
263 | (n < USBTMC_MAX_READS_TO_CLEAR_BULK_IN)); | ||
264 | |||
265 | if (actual == max_size) { | ||
266 | dev_err(dev, "Couldn't clear device buffer within %d cycles\n", | ||
267 | USBTMC_MAX_READS_TO_CLEAR_BULK_IN); | ||
268 | rv = -EPERM; | ||
269 | goto exit; | ||
270 | } | ||
271 | |||
272 | goto usbtmc_abort_bulk_in_status; | ||
273 | |||
274 | exit: | ||
275 | kfree(buffer); | ||
276 | return rv; | ||
277 | |||
278 | } | ||
279 | |||
280 | static int usbtmc_ioctl_abort_bulk_out(struct usbtmc_device_data *data) | ||
281 | { | ||
282 | struct device *dev; | ||
283 | u8 *buffer; | ||
284 | int rv; | ||
285 | int n; | ||
286 | |||
287 | dev = &data->intf->dev; | ||
288 | |||
289 | buffer = kmalloc(8, GFP_KERNEL); | ||
290 | if (!buffer) | ||
291 | return -ENOMEM; | ||
292 | |||
293 | rv = usb_control_msg(data->usb_dev, | ||
294 | usb_rcvctrlpipe(data->usb_dev, 0), | ||
295 | USBTMC_REQUEST_INITIATE_ABORT_BULK_OUT, | ||
296 | USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_ENDPOINT, | ||
297 | data->bTag_last_write, data->bulk_out, | ||
298 | buffer, 2, USBTMC_TIMEOUT); | ||
299 | |||
300 | if (rv < 0) { | ||
301 | dev_err(dev, "usb_control_msg returned %d\n", rv); | ||
302 | goto exit; | ||
303 | } | ||
304 | |||
305 | dev_dbg(dev, "INITIATE_ABORT_BULK_OUT returned %x\n", buffer[0]); | ||
306 | |||
307 | if (buffer[0] != USBTMC_STATUS_SUCCESS) { | ||
308 | dev_err(dev, "INITIATE_ABORT_BULK_OUT returned %x\n", | ||
309 | buffer[0]); | ||
310 | rv = -EPERM; | ||
311 | goto exit; | ||
312 | } | ||
313 | |||
314 | n = 0; | ||
315 | |||
316 | usbtmc_abort_bulk_out_check_status: | ||
317 | rv = usb_control_msg(data->usb_dev, | ||
318 | usb_rcvctrlpipe(data->usb_dev, 0), | ||
319 | USBTMC_REQUEST_CHECK_ABORT_BULK_OUT_STATUS, | ||
320 | USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_ENDPOINT, | ||
321 | 0, data->bulk_out, buffer, 0x08, | ||
322 | USBTMC_TIMEOUT); | ||
323 | n++; | ||
324 | if (rv < 0) { | ||
325 | dev_err(dev, "usb_control_msg returned %d\n", rv); | ||
326 | goto exit; | ||
327 | } | ||
328 | |||
329 | dev_dbg(dev, "CHECK_ABORT_BULK_OUT returned %x\n", buffer[0]); | ||
330 | |||
331 | if (buffer[0] == USBTMC_STATUS_SUCCESS) | ||
332 | goto usbtmc_abort_bulk_out_clear_halt; | ||
333 | |||
334 | if ((buffer[0] == USBTMC_STATUS_PENDING) && | ||
335 | (n < USBTMC_MAX_READS_TO_CLEAR_BULK_IN)) | ||
336 | goto usbtmc_abort_bulk_out_check_status; | ||
337 | |||
338 | rv = -EPERM; | ||
339 | goto exit; | ||
340 | |||
341 | usbtmc_abort_bulk_out_clear_halt: | ||
342 | rv = usb_control_msg(data->usb_dev, | ||
343 | usb_sndctrlpipe(data->usb_dev, 0), | ||
344 | USB_REQ_CLEAR_FEATURE, | ||
345 | USB_DIR_OUT | USB_TYPE_STANDARD | | ||
346 | USB_RECIP_ENDPOINT, | ||
347 | USB_ENDPOINT_HALT, data->bulk_out, buffer, | ||
348 | 0, USBTMC_TIMEOUT); | ||
349 | |||
350 | if (rv < 0) { | ||
351 | dev_err(dev, "usb_control_msg returned %d\n", rv); | ||
352 | goto exit; | ||
353 | } | ||
354 | rv = 0; | ||
355 | |||
356 | exit: | ||
357 | kfree(buffer); | ||
358 | return rv; | ||
359 | } | ||
360 | |||
361 | static ssize_t usbtmc_read(struct file *filp, char __user *buf, | ||
362 | size_t count, loff_t *f_pos) | ||
363 | { | ||
364 | struct usbtmc_device_data *data; | ||
365 | struct device *dev; | ||
366 | unsigned long int n_characters; | ||
367 | u8 *buffer; | ||
368 | int actual; | ||
369 | int done; | ||
370 | int remaining; | ||
371 | int retval; | ||
372 | int this_part; | ||
373 | |||
374 | /* Get pointer to private data structure */ | ||
375 | data = filp->private_data; | ||
376 | dev = &data->intf->dev; | ||
377 | |||
378 | buffer = kmalloc(USBTMC_SIZE_IOBUFFER, GFP_KERNEL); | ||
379 | if (!buffer) | ||
380 | return -ENOMEM; | ||
381 | |||
382 | mutex_lock(&data->io_mutex); | ||
383 | |||
384 | remaining = count; | ||
385 | done = 0; | ||
386 | |||
387 | while (remaining > 0) { | ||
388 | if (remaining > USBTMC_SIZE_IOBUFFER - 12 - 3) | ||
389 | this_part = USBTMC_SIZE_IOBUFFER - 12 - 3; | ||
390 | else | ||
391 | this_part = remaining; | ||
392 | |||
393 | /* Setup IO buffer for DEV_DEP_MSG_IN message | ||
394 | * Refer to class specs for details | ||
395 | */ | ||
396 | buffer[0] = 2; | ||
397 | buffer[1] = data->bTag; | ||
398 | buffer[2] = ~(data->bTag); | ||
399 | buffer[3] = 0; /* Reserved */ | ||
400 | buffer[4] = (this_part - 12 - 3) & 255; | ||
401 | buffer[5] = ((this_part - 12 - 3) >> 8) & 255; | ||
402 | buffer[6] = ((this_part - 12 - 3) >> 16) & 255; | ||
403 | buffer[7] = ((this_part - 12 - 3) >> 24) & 255; | ||
404 | buffer[8] = data->TermCharEnabled * 2; | ||
405 | /* Use term character? */ | ||
406 | buffer[9] = data->TermChar; | ||
407 | buffer[10] = 0; /* Reserved */ | ||
408 | buffer[11] = 0; /* Reserved */ | ||
409 | |||
410 | /* Send bulk URB */ | ||
411 | retval = usb_bulk_msg(data->usb_dev, | ||
412 | usb_sndbulkpipe(data->usb_dev, | ||
413 | data->bulk_out), | ||
414 | buffer, 12, &actual, USBTMC_TIMEOUT); | ||
415 | |||
416 | /* Store bTag (in case we need to abort) */ | ||
417 | data->bTag_last_write = data->bTag; | ||
418 | |||
419 | /* Increment bTag -- and increment again if zero */ | ||
420 | data->bTag++; | ||
421 | if (!data->bTag) | ||
422 | (data->bTag)++; | ||
423 | |||
424 | if (retval < 0) { | ||
425 | dev_err(dev, "usb_bulk_msg returned %d\n", retval); | ||
426 | if (data->auto_abort) | ||
427 | usbtmc_ioctl_abort_bulk_out(data); | ||
428 | goto exit; | ||
429 | } | ||
430 | |||
431 | /* Send bulk URB */ | ||
432 | retval = usb_bulk_msg(data->usb_dev, | ||
433 | usb_rcvbulkpipe(data->usb_dev, | ||
434 | data->bulk_in), | ||
435 | buffer, USBTMC_SIZE_IOBUFFER, &actual, | ||
436 | USBTMC_TIMEOUT); | ||
437 | |||
438 | /* Store bTag (in case we need to abort) */ | ||
439 | data->bTag_last_read = data->bTag; | ||
440 | |||
441 | if (retval < 0) { | ||
442 | dev_err(dev, "Unable to read data, error %d\n", retval); | ||
443 | if (data->auto_abort) | ||
444 | usbtmc_ioctl_abort_bulk_in(data); | ||
445 | goto exit; | ||
446 | } | ||
447 | |||
448 | /* How many characters did the instrument send? */ | ||
449 | n_characters = buffer[4] + | ||
450 | (buffer[5] << 8) + | ||
451 | (buffer[6] << 16) + | ||
452 | (buffer[7] << 24); | ||
453 | |||
454 | /* Copy buffer to user space */ | ||
455 | if (copy_to_user(buf + done, &buffer[12], n_characters)) { | ||
456 | /* There must have been an addressing problem */ | ||
457 | retval = -EFAULT; | ||
458 | goto exit; | ||
459 | } | ||
460 | |||
461 | done += n_characters; | ||
462 | if (n_characters < USBTMC_SIZE_IOBUFFER) | ||
463 | remaining = 0; | ||
464 | } | ||
465 | |||
466 | /* Update file position value */ | ||
467 | *f_pos = *f_pos + done; | ||
468 | retval = done; | ||
469 | |||
470 | exit: | ||
471 | mutex_unlock(&data->io_mutex); | ||
472 | kfree(buffer); | ||
473 | return retval; | ||
474 | } | ||
475 | |||
476 | static ssize_t usbtmc_write(struct file *filp, const char __user *buf, | ||
477 | size_t count, loff_t *f_pos) | ||
478 | { | ||
479 | struct usbtmc_device_data *data; | ||
480 | u8 *buffer; | ||
481 | int retval; | ||
482 | int actual; | ||
483 | unsigned long int n_bytes; | ||
484 | int n; | ||
485 | int remaining; | ||
486 | int done; | ||
487 | int this_part; | ||
488 | |||
489 | data = filp->private_data; | ||
490 | |||
491 | buffer = kmalloc(USBTMC_SIZE_IOBUFFER, GFP_KERNEL); | ||
492 | if (!buffer) | ||
493 | return -ENOMEM; | ||
494 | |||
495 | mutex_lock(&data->io_mutex); | ||
496 | |||
497 | remaining = count; | ||
498 | done = 0; | ||
499 | |||
500 | while (remaining > 0) { | ||
501 | if (remaining > USBTMC_SIZE_IOBUFFER - 12) { | ||
502 | this_part = USBTMC_SIZE_IOBUFFER - 12; | ||
503 | buffer[8] = 0; | ||
504 | } else { | ||
505 | this_part = remaining; | ||
506 | buffer[8] = 1; | ||
507 | } | ||
508 | |||
509 | /* Setup IO buffer for DEV_DEP_MSG_OUT message */ | ||
510 | buffer[0] = 1; | ||
511 | buffer[1] = data->bTag; | ||
512 | buffer[2] = ~(data->bTag); | ||
513 | buffer[3] = 0; /* Reserved */ | ||
514 | buffer[4] = this_part & 255; | ||
515 | buffer[5] = (this_part >> 8) & 255; | ||
516 | buffer[6] = (this_part >> 16) & 255; | ||
517 | buffer[7] = (this_part >> 24) & 255; | ||
518 | /* buffer[8] is set above... */ | ||
519 | buffer[9] = 0; /* Reserved */ | ||
520 | buffer[10] = 0; /* Reserved */ | ||
521 | buffer[11] = 0; /* Reserved */ | ||
522 | |||
523 | if (copy_from_user(&buffer[12], buf + done, this_part)) { | ||
524 | retval = -EFAULT; | ||
525 | goto exit; | ||
526 | } | ||
527 | |||
528 | n_bytes = 12 + this_part; | ||
529 | if (this_part % 4) | ||
530 | n_bytes += 4 - this_part % 4; | ||
531 | for (n = 12 + this_part; n < n_bytes; n++) | ||
532 | buffer[n] = 0; | ||
533 | |||
534 | retval = usb_bulk_msg(data->usb_dev, | ||
535 | usb_sndbulkpipe(data->usb_dev, | ||
536 | data->bulk_out), | ||
537 | buffer, n_bytes, &actual, USBTMC_TIMEOUT); | ||
538 | |||
539 | data->bTag_last_write = data->bTag; | ||
540 | data->bTag++; | ||
541 | |||
542 | if (!data->bTag) | ||
543 | data->bTag++; | ||
544 | |||
545 | if (retval < 0) { | ||
546 | dev_err(&data->intf->dev, | ||
547 | "Unable to send data, error %d\n", retval); | ||
548 | if (data->auto_abort) | ||
549 | usbtmc_ioctl_abort_bulk_out(data); | ||
550 | goto exit; | ||
551 | } | ||
552 | |||
553 | remaining -= this_part; | ||
554 | done += this_part; | ||
555 | } | ||
556 | |||
557 | retval = count; | ||
558 | exit: | ||
559 | mutex_unlock(&data->io_mutex); | ||
560 | kfree(buffer); | ||
561 | return retval; | ||
562 | } | ||
563 | |||
564 | static int usbtmc_ioctl_clear(struct usbtmc_device_data *data) | ||
565 | { | ||
566 | struct usb_host_interface *current_setting; | ||
567 | struct usb_endpoint_descriptor *desc; | ||
568 | struct device *dev; | ||
569 | u8 *buffer; | ||
570 | int rv; | ||
571 | int n; | ||
572 | int actual; | ||
573 | int max_size; | ||
574 | |||
575 | dev = &data->intf->dev; | ||
576 | |||
577 | dev_dbg(dev, "Sending INITIATE_CLEAR request\n"); | ||
578 | |||
579 | buffer = kmalloc(USBTMC_SIZE_IOBUFFER, GFP_KERNEL); | ||
580 | if (!buffer) | ||
581 | return -ENOMEM; | ||
582 | |||
583 | rv = usb_control_msg(data->usb_dev, | ||
584 | usb_rcvctrlpipe(data->usb_dev, 0), | ||
585 | USBTMC_REQUEST_INITIATE_CLEAR, | ||
586 | USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE, | ||
587 | 0, 0, buffer, 1, USBTMC_TIMEOUT); | ||
588 | if (rv < 0) { | ||
589 | dev_err(dev, "usb_control_msg returned %d\n", rv); | ||
590 | goto exit; | ||
591 | } | ||
592 | |||
593 | dev_dbg(dev, "INITIATE_CLEAR returned %x\n", buffer[0]); | ||
594 | |||
595 | if (buffer[0] != USBTMC_STATUS_SUCCESS) { | ||
596 | dev_err(dev, "INITIATE_CLEAR returned %x\n", buffer[0]); | ||
597 | rv = -EPERM; | ||
598 | goto exit; | ||
599 | } | ||
600 | |||
601 | max_size = 0; | ||
602 | current_setting = data->intf->cur_altsetting; | ||
603 | for (n = 0; n < current_setting->desc.bNumEndpoints; n++) { | ||
604 | desc = ¤t_setting->endpoint[n].desc; | ||
605 | if (desc->bEndpointAddress == data->bulk_in) | ||
606 | max_size = le16_to_cpu(desc->wMaxPacketSize); | ||
607 | } | ||
608 | |||
609 | if (max_size == 0) { | ||
610 | dev_err(dev, "Couldn't get wMaxPacketSize\n"); | ||
611 | rv = -EPERM; | ||
612 | goto exit; | ||
613 | } | ||
614 | |||
615 | dev_dbg(dev, "wMaxPacketSize is %d\n", max_size); | ||
616 | |||
617 | n = 0; | ||
618 | |||
619 | usbtmc_clear_check_status: | ||
620 | |||
621 | dev_dbg(dev, "Sending CHECK_CLEAR_STATUS request\n"); | ||
622 | |||
623 | rv = usb_control_msg(data->usb_dev, | ||
624 | usb_rcvctrlpipe(data->usb_dev, 0), | ||
625 | USBTMC_REQUEST_CHECK_CLEAR_STATUS, | ||
626 | USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE, | ||
627 | 0, 0, buffer, 2, USBTMC_TIMEOUT); | ||
628 | if (rv < 0) { | ||
629 | dev_err(dev, "usb_control_msg returned %d\n", rv); | ||
630 | goto exit; | ||
631 | } | ||
632 | |||
633 | dev_dbg(dev, "CHECK_CLEAR_STATUS returned %x\n", buffer[0]); | ||
634 | |||
635 | if (buffer[0] == USBTMC_STATUS_SUCCESS) | ||
636 | goto usbtmc_clear_bulk_out_halt; | ||
637 | |||
638 | if (buffer[0] != USBTMC_STATUS_PENDING) { | ||
639 | dev_err(dev, "CHECK_CLEAR_STATUS returned %x\n", buffer[0]); | ||
640 | rv = -EPERM; | ||
641 | goto exit; | ||
642 | } | ||
643 | |||
644 | if (buffer[1] == 1) | ||
645 | do { | ||
646 | dev_dbg(dev, "Reading from bulk in EP\n"); | ||
647 | |||
648 | rv = usb_bulk_msg(data->usb_dev, | ||
649 | usb_rcvbulkpipe(data->usb_dev, | ||
650 | data->bulk_in), | ||
651 | buffer, USBTMC_SIZE_IOBUFFER, | ||
652 | &actual, USBTMC_TIMEOUT); | ||
653 | n++; | ||
654 | |||
655 | if (rv < 0) { | ||
656 | dev_err(dev, "usb_control_msg returned %d\n", | ||
657 | rv); | ||
658 | goto exit; | ||
659 | } | ||
660 | } while ((actual == max_size) && | ||
661 | (n < USBTMC_MAX_READS_TO_CLEAR_BULK_IN)); | ||
662 | |||
663 | if (actual == max_size) { | ||
664 | dev_err(dev, "Couldn't clear device buffer within %d cycles\n", | ||
665 | USBTMC_MAX_READS_TO_CLEAR_BULK_IN); | ||
666 | rv = -EPERM; | ||
667 | goto exit; | ||
668 | } | ||
669 | |||
670 | goto usbtmc_clear_check_status; | ||
671 | |||
672 | usbtmc_clear_bulk_out_halt: | ||
673 | |||
674 | rv = usb_control_msg(data->usb_dev, | ||
675 | usb_sndctrlpipe(data->usb_dev, 0), | ||
676 | USB_REQ_CLEAR_FEATURE, | ||
677 | USB_DIR_OUT | USB_TYPE_STANDARD | | ||
678 | USB_RECIP_ENDPOINT, | ||
679 | USB_ENDPOINT_HALT, | ||
680 | data->bulk_out, buffer, 0, | ||
681 | USBTMC_TIMEOUT); | ||
682 | if (rv < 0) { | ||
683 | dev_err(dev, "usb_control_msg returned %d\n", rv); | ||
684 | goto exit; | ||
685 | } | ||
686 | rv = 0; | ||
687 | |||
688 | exit: | ||
689 | kfree(buffer); | ||
690 | return rv; | ||
691 | } | ||
692 | |||
693 | static int usbtmc_ioctl_clear_out_halt(struct usbtmc_device_data *data) | ||
694 | { | ||
695 | u8 *buffer; | ||
696 | int rv; | ||
697 | |||
698 | buffer = kmalloc(2, GFP_KERNEL); | ||
699 | if (!buffer) | ||
700 | return -ENOMEM; | ||
701 | |||
702 | rv = usb_control_msg(data->usb_dev, | ||
703 | usb_sndctrlpipe(data->usb_dev, 0), | ||
704 | USB_REQ_CLEAR_FEATURE, | ||
705 | USB_DIR_OUT | USB_TYPE_STANDARD | | ||
706 | USB_RECIP_ENDPOINT, | ||
707 | USB_ENDPOINT_HALT, data->bulk_out, | ||
708 | buffer, 0, USBTMC_TIMEOUT); | ||
709 | |||
710 | if (rv < 0) { | ||
711 | dev_err(&data->usb_dev->dev, "usb_control_msg returned %d\n", | ||
712 | rv); | ||
713 | goto exit; | ||
714 | } | ||
715 | rv = 0; | ||
716 | |||
717 | exit: | ||
718 | kfree(buffer); | ||
719 | return rv; | ||
720 | } | ||
721 | |||
722 | static int usbtmc_ioctl_clear_in_halt(struct usbtmc_device_data *data) | ||
723 | { | ||
724 | u8 *buffer; | ||
725 | int rv; | ||
726 | |||
727 | buffer = kmalloc(2, GFP_KERNEL); | ||
728 | if (!buffer) | ||
729 | return -ENOMEM; | ||
730 | |||
731 | rv = usb_control_msg(data->usb_dev, usb_sndctrlpipe(data->usb_dev, 0), | ||
732 | USB_REQ_CLEAR_FEATURE, | ||
733 | USB_DIR_OUT | USB_TYPE_STANDARD | | ||
734 | USB_RECIP_ENDPOINT, | ||
735 | USB_ENDPOINT_HALT, data->bulk_in, buffer, 0, | ||
736 | USBTMC_TIMEOUT); | ||
737 | |||
738 | if (rv < 0) { | ||
739 | dev_err(&data->usb_dev->dev, "usb_control_msg returned %d\n", | ||
740 | rv); | ||
741 | goto exit; | ||
742 | } | ||
743 | rv = 0; | ||
744 | |||
745 | exit: | ||
746 | kfree(buffer); | ||
747 | return rv; | ||
748 | } | ||
749 | |||
750 | static int get_capabilities(struct usbtmc_device_data *data) | ||
751 | { | ||
752 | struct device *dev = &data->usb_dev->dev; | ||
753 | char *buffer; | ||
754 | int rv; | ||
755 | |||
756 | buffer = kmalloc(0x18, GFP_KERNEL); | ||
757 | if (!buffer) | ||
758 | return -ENOMEM; | ||
759 | |||
760 | rv = usb_control_msg(data->usb_dev, usb_rcvctrlpipe(data->usb_dev, 0), | ||
761 | USBTMC_REQUEST_GET_CAPABILITIES, | ||
762 | USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE, | ||
763 | 0, 0, buffer, 0x18, USBTMC_TIMEOUT); | ||
764 | if (rv < 0) { | ||
765 | dev_err(dev, "usb_control_msg returned %d\n", rv); | ||
766 | return rv; | ||
767 | } | ||
768 | |||
769 | dev_dbg(dev, "GET_CAPABILITIES returned %x\n", buffer[0]); | ||
770 | dev_dbg(dev, "Interface capabilities are %x\n", buffer[4]); | ||
771 | dev_dbg(dev, "Device capabilities are %x\n", buffer[5]); | ||
772 | dev_dbg(dev, "USB488 interface capabilities are %x\n", buffer[14]); | ||
773 | dev_dbg(dev, "USB488 device capabilities are %x\n", buffer[15]); | ||
774 | if (buffer[0] != USBTMC_STATUS_SUCCESS) { | ||
775 | dev_err(dev, "GET_CAPABILITIES returned %x\n", buffer[0]); | ||
776 | return -EPERM; | ||
777 | } | ||
778 | |||
779 | data->capabilities.interface_capabilities = buffer[4]; | ||
780 | data->capabilities.device_capabilities = buffer[5]; | ||
781 | data->capabilities.usb488_interface_capabilities = buffer[14]; | ||
782 | data->capabilities.usb488_device_capabilities = buffer[15]; | ||
783 | |||
784 | kfree(buffer); | ||
785 | return 0; | ||
786 | } | ||
787 | |||
788 | #define capability_attribute(name) \ | ||
789 | static ssize_t show_##name(struct device *dev, \ | ||
790 | struct device_attribute *attr, char *buf) \ | ||
791 | { \ | ||
792 | struct usb_interface *intf = to_usb_interface(dev); \ | ||
793 | struct usbtmc_device_data *data = usb_get_intfdata(intf); \ | ||
794 | \ | ||
795 | return sprintf(buf, "%d\n", data->capabilities.name); \ | ||
796 | } \ | ||
797 | static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL) | ||
798 | |||
799 | capability_attribute(interface_capabilities); | ||
800 | capability_attribute(device_capabilities); | ||
801 | capability_attribute(usb488_interface_capabilities); | ||
802 | capability_attribute(usb488_device_capabilities); | ||
803 | |||
804 | static struct attribute *capability_attrs[] = { | ||
805 | &dev_attr_interface_capabilities.attr, | ||
806 | &dev_attr_device_capabilities.attr, | ||
807 | &dev_attr_usb488_interface_capabilities.attr, | ||
808 | &dev_attr_usb488_device_capabilities.attr, | ||
809 | NULL, | ||
810 | }; | ||
811 | |||
812 | static struct attribute_group capability_attr_grp = { | ||
813 | .attrs = capability_attrs, | ||
814 | }; | ||
815 | |||
816 | static ssize_t show_TermChar(struct device *dev, | ||
817 | struct device_attribute *attr, char *buf) | ||
818 | { | ||
819 | struct usb_interface *intf = to_usb_interface(dev); | ||
820 | struct usbtmc_device_data *data = usb_get_intfdata(intf); | ||
821 | |||
822 | return sprintf(buf, "%c\n", data->TermChar); | ||
823 | } | ||
824 | |||
825 | static ssize_t store_TermChar(struct device *dev, | ||
826 | struct device_attribute *attr, | ||
827 | const char *buf, size_t count) | ||
828 | { | ||
829 | struct usb_interface *intf = to_usb_interface(dev); | ||
830 | struct usbtmc_device_data *data = usb_get_intfdata(intf); | ||
831 | |||
832 | if (count < 1) | ||
833 | return -EINVAL; | ||
834 | data->TermChar = buf[0]; | ||
835 | return count; | ||
836 | } | ||
837 | static DEVICE_ATTR(TermChar, S_IRUGO, show_TermChar, store_TermChar); | ||
838 | |||
839 | #define data_attribute(name) \ | ||
840 | static ssize_t show_##name(struct device *dev, \ | ||
841 | struct device_attribute *attr, char *buf) \ | ||
842 | { \ | ||
843 | struct usb_interface *intf = to_usb_interface(dev); \ | ||
844 | struct usbtmc_device_data *data = usb_get_intfdata(intf); \ | ||
845 | \ | ||
846 | return sprintf(buf, "%d\n", data->name); \ | ||
847 | } \ | ||
848 | static ssize_t store_##name(struct device *dev, \ | ||
849 | struct device_attribute *attr, \ | ||
850 | const char *buf, size_t count) \ | ||
851 | { \ | ||
852 | struct usb_interface *intf = to_usb_interface(dev); \ | ||
853 | struct usbtmc_device_data *data = usb_get_intfdata(intf); \ | ||
854 | ssize_t result; \ | ||
855 | unsigned val; \ | ||
856 | \ | ||
857 | result = sscanf(buf, "%u\n", &val); \ | ||
858 | if (result != 1) \ | ||
859 | result = -EINVAL; \ | ||
860 | data->name = val; \ | ||
861 | if (result < 0) \ | ||
862 | return result; \ | ||
863 | else \ | ||
864 | return count; \ | ||
865 | } \ | ||
866 | static DEVICE_ATTR(name, S_IRUGO, show_##name, store_##name) | ||
867 | |||
868 | data_attribute(TermCharEnabled); | ||
869 | data_attribute(auto_abort); | ||
870 | |||
871 | static struct attribute *data_attrs[] = { | ||
872 | &dev_attr_TermChar.attr, | ||
873 | &dev_attr_TermCharEnabled.attr, | ||
874 | &dev_attr_auto_abort.attr, | ||
875 | NULL, | ||
876 | }; | ||
877 | |||
878 | static struct attribute_group data_attr_grp = { | ||
879 | .attrs = data_attrs, | ||
880 | }; | ||
881 | |||
882 | static int usbtmc_ioctl_indicator_pulse(struct usbtmc_device_data *data) | ||
883 | { | ||
884 | struct device *dev; | ||
885 | u8 *buffer; | ||
886 | int rv; | ||
887 | |||
888 | dev = &data->intf->dev; | ||
889 | |||
890 | buffer = kmalloc(2, GFP_KERNEL); | ||
891 | if (!buffer) | ||
892 | return -ENOMEM; | ||
893 | |||
894 | rv = usb_control_msg(data->usb_dev, | ||
895 | usb_rcvctrlpipe(data->usb_dev, 0), | ||
896 | USBTMC_REQUEST_INDICATOR_PULSE, | ||
897 | USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE, | ||
898 | 0, 0, buffer, 0x01, USBTMC_TIMEOUT); | ||
899 | |||
900 | if (rv < 0) { | ||
901 | dev_err(dev, "usb_control_msg returned %d\n", rv); | ||
902 | goto exit; | ||
903 | } | ||
904 | |||
905 | dev_dbg(dev, "INDICATOR_PULSE returned %x\n", buffer[0]); | ||
906 | |||
907 | if (buffer[0] != USBTMC_STATUS_SUCCESS) { | ||
908 | dev_err(dev, "INDICATOR_PULSE returned %x\n", buffer[0]); | ||
909 | rv = -EPERM; | ||
910 | goto exit; | ||
911 | } | ||
912 | rv = 0; | ||
913 | |||
914 | exit: | ||
915 | kfree(buffer); | ||
916 | return rv; | ||
917 | } | ||
918 | |||
919 | static long usbtmc_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | ||
920 | { | ||
921 | struct usbtmc_device_data *data; | ||
922 | int retval = -EBADRQC; | ||
923 | |||
924 | data = file->private_data; | ||
925 | mutex_lock(&data->io_mutex); | ||
926 | |||
927 | switch (cmd) { | ||
928 | case USBTMC_IOCTL_CLEAR_OUT_HALT: | ||
929 | retval = usbtmc_ioctl_clear_out_halt(data); | ||
930 | |||
931 | case USBTMC_IOCTL_CLEAR_IN_HALT: | ||
932 | retval = usbtmc_ioctl_clear_in_halt(data); | ||
933 | |||
934 | case USBTMC_IOCTL_INDICATOR_PULSE: | ||
935 | retval = usbtmc_ioctl_indicator_pulse(data); | ||
936 | |||
937 | case USBTMC_IOCTL_CLEAR: | ||
938 | retval = usbtmc_ioctl_clear(data); | ||
939 | |||
940 | case USBTMC_IOCTL_ABORT_BULK_OUT: | ||
941 | retval = usbtmc_ioctl_abort_bulk_out(data); | ||
942 | |||
943 | case USBTMC_IOCTL_ABORT_BULK_IN: | ||
944 | retval = usbtmc_ioctl_abort_bulk_in(data); | ||
945 | } | ||
946 | |||
947 | mutex_unlock(&data->io_mutex); | ||
948 | return retval; | ||
949 | } | ||
950 | |||
951 | static struct file_operations fops = { | ||
952 | .owner = THIS_MODULE, | ||
953 | .read = usbtmc_read, | ||
954 | .write = usbtmc_write, | ||
955 | .open = usbtmc_open, | ||
956 | .release = usbtmc_release, | ||
957 | .unlocked_ioctl = usbtmc_ioctl, | ||
958 | }; | ||
959 | |||
960 | static struct usb_class_driver usbtmc_class = { | ||
961 | .name = "usbtmc%d", | ||
962 | .fops = &fops, | ||
963 | .minor_base = USBTMC_MINOR_BASE, | ||
964 | }; | ||
965 | |||
966 | |||
967 | static int usbtmc_probe(struct usb_interface *intf, | ||
968 | const struct usb_device_id *id) | ||
969 | { | ||
970 | struct usbtmc_device_data *data; | ||
971 | struct usb_host_interface *iface_desc; | ||
972 | struct usb_endpoint_descriptor *endpoint; | ||
973 | int n; | ||
974 | int retcode; | ||
975 | |||
976 | dev_dbg(&intf->dev, "%s called\n", __func__); | ||
977 | |||
978 | data = kmalloc(sizeof(struct usbtmc_device_data), GFP_KERNEL); | ||
979 | if (!data) { | ||
980 | dev_err(&intf->dev, "Unable to allocate kernel memory\n"); | ||
981 | return -ENOMEM; | ||
982 | } | ||
983 | |||
984 | data->intf = intf; | ||
985 | data->id = id; | ||
986 | data->usb_dev = usb_get_dev(interface_to_usbdev(intf)); | ||
987 | usb_set_intfdata(intf, data); | ||
988 | kref_init(&data->kref); | ||
989 | mutex_init(&data->io_mutex); | ||
990 | |||
991 | /* Initialize USBTMC bTag and other fields */ | ||
992 | data->bTag = 1; | ||
993 | data->TermCharEnabled = 0; | ||
994 | data->TermChar = '\n'; | ||
995 | |||
996 | /* USBTMC devices have only one setting, so use that */ | ||
997 | iface_desc = data->intf->cur_altsetting; | ||
998 | |||
999 | /* Find bulk in endpoint */ | ||
1000 | for (n = 0; n < iface_desc->desc.bNumEndpoints; n++) { | ||
1001 | endpoint = &iface_desc->endpoint[n].desc; | ||
1002 | |||
1003 | if (usb_endpoint_is_bulk_in(endpoint)) { | ||
1004 | data->bulk_in = endpoint->bEndpointAddress; | ||
1005 | dev_dbg(&intf->dev, "Found bulk in endpoint at %u\n", | ||
1006 | data->bulk_in); | ||
1007 | break; | ||
1008 | } | ||
1009 | } | ||
1010 | |||
1011 | /* Find bulk out endpoint */ | ||
1012 | for (n = 0; n < iface_desc->desc.bNumEndpoints; n++) { | ||
1013 | endpoint = &iface_desc->endpoint[n].desc; | ||
1014 | |||
1015 | if (usb_endpoint_is_bulk_out(endpoint)) { | ||
1016 | data->bulk_out = endpoint->bEndpointAddress; | ||
1017 | dev_dbg(&intf->dev, "Found Bulk out endpoint at %u\n", | ||
1018 | data->bulk_out); | ||
1019 | break; | ||
1020 | } | ||
1021 | } | ||
1022 | |||
1023 | retcode = get_capabilities(data); | ||
1024 | if (retcode) | ||
1025 | dev_err(&intf->dev, "can't read capabilities\n"); | ||
1026 | else | ||
1027 | retcode = sysfs_create_group(&intf->dev.kobj, | ||
1028 | &capability_attr_grp); | ||
1029 | |||
1030 | retcode = sysfs_create_group(&intf->dev.kobj, &data_attr_grp); | ||
1031 | |||
1032 | retcode = usb_register_dev(intf, &usbtmc_class); | ||
1033 | if (retcode) { | ||
1034 | dev_err(&intf->dev, "Not able to get a minor" | ||
1035 | " (base %u, slice default): %d\n", USBTMC_MINOR_BASE, | ||
1036 | retcode); | ||
1037 | goto error_register; | ||
1038 | } | ||
1039 | dev_dbg(&intf->dev, "Using minor number %d\n", intf->minor); | ||
1040 | |||
1041 | return 0; | ||
1042 | |||
1043 | error_register: | ||
1044 | sysfs_remove_group(&intf->dev.kobj, &capability_attr_grp); | ||
1045 | sysfs_remove_group(&intf->dev.kobj, &data_attr_grp); | ||
1046 | kref_put(&data->kref, usbtmc_delete); | ||
1047 | return retcode; | ||
1048 | } | ||
1049 | |||
1050 | static void usbtmc_disconnect(struct usb_interface *intf) | ||
1051 | { | ||
1052 | struct usbtmc_device_data *data; | ||
1053 | |||
1054 | dev_dbg(&intf->dev, "usbtmc_disconnect called\n"); | ||
1055 | |||
1056 | data = usb_get_intfdata(intf); | ||
1057 | usb_deregister_dev(intf, &usbtmc_class); | ||
1058 | sysfs_remove_group(&intf->dev.kobj, &capability_attr_grp); | ||
1059 | sysfs_remove_group(&intf->dev.kobj, &data_attr_grp); | ||
1060 | kref_put(&data->kref, usbtmc_delete); | ||
1061 | } | ||
1062 | |||
1063 | static struct usb_driver usbtmc_driver = { | ||
1064 | .name = "usbtmc", | ||
1065 | .id_table = usbtmc_devices, | ||
1066 | .probe = usbtmc_probe, | ||
1067 | .disconnect = usbtmc_disconnect | ||
1068 | }; | ||
1069 | |||
1070 | static int __init usbtmc_init(void) | ||
1071 | { | ||
1072 | int retcode; | ||
1073 | |||
1074 | retcode = usb_register(&usbtmc_driver); | ||
1075 | if (retcode) | ||
1076 | printk(KERN_ERR KBUILD_MODNAME": Unable to register driver\n"); | ||
1077 | return retcode; | ||
1078 | } | ||
1079 | module_init(usbtmc_init); | ||
1080 | |||
1081 | static void __exit usbtmc_exit(void) | ||
1082 | { | ||
1083 | usb_deregister(&usbtmc_driver); | ||
1084 | } | ||
1085 | module_exit(usbtmc_exit); | ||
1086 | |||
1087 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/usb/core/Kconfig b/drivers/usb/core/Kconfig index cc9f397e8398..e1759d17ac5d 100644 --- a/drivers/usb/core/Kconfig +++ b/drivers/usb/core/Kconfig | |||
@@ -134,5 +134,5 @@ config USB_OTG_BLACKLIST_HUB | |||
134 | If you say Y here, then Linux will refuse to enumerate | 134 | If you say Y here, then Linux will refuse to enumerate |
135 | external hubs. OTG hosts are allowed to reduce hardware | 135 | external hubs. OTG hosts are allowed to reduce hardware |
136 | and software costs by not supporting external hubs. So | 136 | and software costs by not supporting external hubs. So |
137 | are "Emedded Hosts" that don't offer OTG support. | 137 | are "Embedded Hosts" that don't offer OTG support. |
138 | 138 | ||
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c index 20290c5b1562..2bccefebff1b 100644 --- a/drivers/usb/core/devio.c +++ b/drivers/usb/core/devio.c | |||
@@ -413,7 +413,8 @@ static void driver_disconnect(struct usb_interface *intf) | |||
413 | if (likely(ifnum < 8*sizeof(ps->ifclaimed))) | 413 | if (likely(ifnum < 8*sizeof(ps->ifclaimed))) |
414 | clear_bit(ifnum, &ps->ifclaimed); | 414 | clear_bit(ifnum, &ps->ifclaimed); |
415 | else | 415 | else |
416 | warn("interface number %u out of range", ifnum); | 416 | dev_warn(&intf->dev, "interface number %u out of range\n", |
417 | ifnum); | ||
417 | 418 | ||
418 | usb_set_intfdata(intf, NULL); | 419 | usb_set_intfdata(intf, NULL); |
419 | 420 | ||
@@ -624,6 +625,8 @@ static int usbdev_open(struct inode *inode, struct file *file) | |||
624 | smp_wmb(); | 625 | smp_wmb(); |
625 | list_add_tail(&ps->list, &dev->filelist); | 626 | list_add_tail(&ps->list, &dev->filelist); |
626 | file->private_data = ps; | 627 | file->private_data = ps; |
628 | snoop(&dev->dev, "opened by process %d: %s\n", task_pid_nr(current), | ||
629 | current->comm); | ||
627 | out: | 630 | out: |
628 | if (ret) { | 631 | if (ret) { |
629 | kfree(ps); | 632 | kfree(ps); |
@@ -1729,9 +1732,9 @@ static int usb_classdev_add(struct usb_device *dev) | |||
1729 | { | 1732 | { |
1730 | struct device *cldev; | 1733 | struct device *cldev; |
1731 | 1734 | ||
1732 | cldev = device_create_drvdata(usb_classdev_class, &dev->dev, | 1735 | cldev = device_create(usb_classdev_class, &dev->dev, dev->dev.devt, |
1733 | dev->dev.devt, NULL, "usbdev%d.%d", | 1736 | NULL, "usbdev%d.%d", dev->bus->busnum, |
1734 | dev->bus->busnum, dev->devnum); | 1737 | dev->devnum); |
1735 | if (IS_ERR(cldev)) | 1738 | if (IS_ERR(cldev)) |
1736 | return PTR_ERR(cldev); | 1739 | return PTR_ERR(cldev); |
1737 | dev->usb_classdev = cldev; | 1740 | dev->usb_classdev = cldev; |
@@ -1774,19 +1777,20 @@ int __init usb_devio_init(void) | |||
1774 | retval = register_chrdev_region(USB_DEVICE_DEV, USB_DEVICE_MAX, | 1777 | retval = register_chrdev_region(USB_DEVICE_DEV, USB_DEVICE_MAX, |
1775 | "usb_device"); | 1778 | "usb_device"); |
1776 | if (retval) { | 1779 | if (retval) { |
1777 | err("unable to register minors for usb_device"); | 1780 | printk(KERN_ERR "Unable to register minors for usb_device\n"); |
1778 | goto out; | 1781 | goto out; |
1779 | } | 1782 | } |
1780 | cdev_init(&usb_device_cdev, &usbdev_file_operations); | 1783 | cdev_init(&usb_device_cdev, &usbdev_file_operations); |
1781 | retval = cdev_add(&usb_device_cdev, USB_DEVICE_DEV, USB_DEVICE_MAX); | 1784 | retval = cdev_add(&usb_device_cdev, USB_DEVICE_DEV, USB_DEVICE_MAX); |
1782 | if (retval) { | 1785 | if (retval) { |
1783 | err("unable to get usb_device major %d", USB_DEVICE_MAJOR); | 1786 | printk(KERN_ERR "Unable to get usb_device major %d\n", |
1787 | USB_DEVICE_MAJOR); | ||
1784 | goto error_cdev; | 1788 | goto error_cdev; |
1785 | } | 1789 | } |
1786 | #ifdef CONFIG_USB_DEVICE_CLASS | 1790 | #ifdef CONFIG_USB_DEVICE_CLASS |
1787 | usb_classdev_class = class_create(THIS_MODULE, "usb_device"); | 1791 | usb_classdev_class = class_create(THIS_MODULE, "usb_device"); |
1788 | if (IS_ERR(usb_classdev_class)) { | 1792 | if (IS_ERR(usb_classdev_class)) { |
1789 | err("unable to register usb_device class"); | 1793 | printk(KERN_ERR "Unable to register usb_device class\n"); |
1790 | retval = PTR_ERR(usb_classdev_class); | 1794 | retval = PTR_ERR(usb_classdev_class); |
1791 | cdev_del(&usb_device_cdev); | 1795 | cdev_del(&usb_device_cdev); |
1792 | usb_classdev_class = NULL; | 1796 | usb_classdev_class = NULL; |
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c index 2be37fe466f2..e935be7eb468 100644 --- a/drivers/usb/core/driver.c +++ b/drivers/usb/core/driver.c | |||
@@ -230,6 +230,13 @@ static int usb_probe_interface(struct device *dev) | |||
230 | */ | 230 | */ |
231 | intf->pm_usage_cnt = !(driver->supports_autosuspend); | 231 | intf->pm_usage_cnt = !(driver->supports_autosuspend); |
232 | 232 | ||
233 | /* Carry out a deferred switch to altsetting 0 */ | ||
234 | if (intf->needs_altsetting0) { | ||
235 | usb_set_interface(udev, intf->altsetting[0]. | ||
236 | desc.bInterfaceNumber, 0); | ||
237 | intf->needs_altsetting0 = 0; | ||
238 | } | ||
239 | |||
233 | error = driver->probe(intf, id); | 240 | error = driver->probe(intf, id); |
234 | if (error) { | 241 | if (error) { |
235 | mark_quiesced(intf); | 242 | mark_quiesced(intf); |
@@ -266,8 +273,17 @@ static int usb_unbind_interface(struct device *dev) | |||
266 | 273 | ||
267 | driver->disconnect(intf); | 274 | driver->disconnect(intf); |
268 | 275 | ||
269 | /* reset other interface state */ | 276 | /* Reset other interface state. |
270 | usb_set_interface(udev, intf->altsetting[0].desc.bInterfaceNumber, 0); | 277 | * We cannot do a Set-Interface if the device is suspended or |
278 | * if it is prepared for a system sleep (since installing a new | ||
279 | * altsetting means creating new endpoint device entries). | ||
280 | * When either of these happens, defer the Set-Interface. | ||
281 | */ | ||
282 | if (!error && intf->dev.power.status == DPM_ON) | ||
283 | usb_set_interface(udev, intf->altsetting[0]. | ||
284 | desc.bInterfaceNumber, 0); | ||
285 | else | ||
286 | intf->needs_altsetting0 = 1; | ||
271 | usb_set_intfdata(intf, NULL); | 287 | usb_set_intfdata(intf, NULL); |
272 | 288 | ||
273 | intf->condition = USB_INTERFACE_UNBOUND; | 289 | intf->condition = USB_INTERFACE_UNBOUND; |
@@ -798,7 +814,8 @@ void usb_forced_unbind_intf(struct usb_interface *intf) | |||
798 | * The caller must hold @intf's device's lock, but not its pm_mutex | 814 | * The caller must hold @intf's device's lock, but not its pm_mutex |
799 | * and not @intf->dev.sem. | 815 | * and not @intf->dev.sem. |
800 | * | 816 | * |
801 | * FIXME: The caller must block system sleep transitions. | 817 | * Note: Rebinds will be skipped if a system sleep transition is in |
818 | * progress and the PM "complete" callback hasn't occurred yet. | ||
802 | */ | 819 | */ |
803 | void usb_rebind_intf(struct usb_interface *intf) | 820 | void usb_rebind_intf(struct usb_interface *intf) |
804 | { | 821 | { |
@@ -814,10 +831,12 @@ void usb_rebind_intf(struct usb_interface *intf) | |||
814 | } | 831 | } |
815 | 832 | ||
816 | /* Try to rebind the interface */ | 833 | /* Try to rebind the interface */ |
817 | intf->needs_binding = 0; | 834 | if (intf->dev.power.status == DPM_ON) { |
818 | rc = device_attach(&intf->dev); | 835 | intf->needs_binding = 0; |
819 | if (rc < 0) | 836 | rc = device_attach(&intf->dev); |
820 | dev_warn(&intf->dev, "rebind failed: %d\n", rc); | 837 | if (rc < 0) |
838 | dev_warn(&intf->dev, "rebind failed: %d\n", rc); | ||
839 | } | ||
821 | } | 840 | } |
822 | 841 | ||
823 | #ifdef CONFIG_PM | 842 | #ifdef CONFIG_PM |
@@ -829,7 +848,6 @@ void usb_rebind_intf(struct usb_interface *intf) | |||
829 | * or rebind interfaces that have been unbound, according to @action. | 848 | * or rebind interfaces that have been unbound, according to @action. |
830 | * | 849 | * |
831 | * The caller must hold @udev's device lock. | 850 | * The caller must hold @udev's device lock. |
832 | * FIXME: For rebinds, the caller must block system sleep transitions. | ||
833 | */ | 851 | */ |
834 | static void do_unbind_rebind(struct usb_device *udev, int action) | 852 | static void do_unbind_rebind(struct usb_device *udev, int action) |
835 | { | 853 | { |
@@ -851,22 +869,8 @@ static void do_unbind_rebind(struct usb_device *udev, int action) | |||
851 | } | 869 | } |
852 | break; | 870 | break; |
853 | case DO_REBIND: | 871 | case DO_REBIND: |
854 | if (intf->needs_binding) { | 872 | if (intf->needs_binding) |
855 | |||
856 | /* FIXME: The next line is needed because we are going to probe | ||
857 | * the interface, but as far as the PM core is concerned the | ||
858 | * interface is still suspended. The problem wouldn't exist | ||
859 | * if we could rebind the interface during the interface's own | ||
860 | * resume() call, but at the time the usb_device isn't locked! | ||
861 | * | ||
862 | * The real solution will be to carry this out during the device's | ||
863 | * complete() callback. Until that is implemented, we have to | ||
864 | * use this hack. | ||
865 | */ | ||
866 | // intf->dev.power.sleeping = 0; | ||
867 | |||
868 | usb_rebind_intf(intf); | 873 | usb_rebind_intf(intf); |
869 | } | ||
870 | break; | 874 | break; |
871 | } | 875 | } |
872 | } | 876 | } |
@@ -926,14 +930,14 @@ static int usb_resume_device(struct usb_device *udev) | |||
926 | } | 930 | } |
927 | 931 | ||
928 | /* Caller has locked intf's usb_device's pm mutex */ | 932 | /* Caller has locked intf's usb_device's pm mutex */ |
929 | static int usb_suspend_interface(struct usb_interface *intf, pm_message_t msg) | 933 | static int usb_suspend_interface(struct usb_device *udev, |
934 | struct usb_interface *intf, pm_message_t msg) | ||
930 | { | 935 | { |
931 | struct usb_driver *driver; | 936 | struct usb_driver *driver; |
932 | int status = 0; | 937 | int status = 0; |
933 | 938 | ||
934 | /* with no hardware, USB interfaces only use FREEZE and ON states */ | 939 | /* with no hardware, USB interfaces only use FREEZE and ON states */ |
935 | if (interface_to_usbdev(intf)->state == USB_STATE_NOTATTACHED || | 940 | if (udev->state == USB_STATE_NOTATTACHED || !is_active(intf)) |
936 | !is_active(intf)) | ||
937 | goto done; | 941 | goto done; |
938 | 942 | ||
939 | if (intf->condition == USB_INTERFACE_UNBOUND) /* This can't happen */ | 943 | if (intf->condition == USB_INTERFACE_UNBOUND) /* This can't happen */ |
@@ -944,7 +948,7 @@ static int usb_suspend_interface(struct usb_interface *intf, pm_message_t msg) | |||
944 | status = driver->suspend(intf, msg); | 948 | status = driver->suspend(intf, msg); |
945 | if (status == 0) | 949 | if (status == 0) |
946 | mark_quiesced(intf); | 950 | mark_quiesced(intf); |
947 | else if (!interface_to_usbdev(intf)->auto_pm) | 951 | else if (!udev->auto_pm) |
948 | dev_err(&intf->dev, "%s error %d\n", | 952 | dev_err(&intf->dev, "%s error %d\n", |
949 | "suspend", status); | 953 | "suspend", status); |
950 | } else { | 954 | } else { |
@@ -961,13 +965,13 @@ static int usb_suspend_interface(struct usb_interface *intf, pm_message_t msg) | |||
961 | } | 965 | } |
962 | 966 | ||
963 | /* Caller has locked intf's usb_device's pm_mutex */ | 967 | /* Caller has locked intf's usb_device's pm_mutex */ |
964 | static int usb_resume_interface(struct usb_interface *intf, int reset_resume) | 968 | static int usb_resume_interface(struct usb_device *udev, |
969 | struct usb_interface *intf, int reset_resume) | ||
965 | { | 970 | { |
966 | struct usb_driver *driver; | 971 | struct usb_driver *driver; |
967 | int status = 0; | 972 | int status = 0; |
968 | 973 | ||
969 | if (interface_to_usbdev(intf)->state == USB_STATE_NOTATTACHED || | 974 | if (udev->state == USB_STATE_NOTATTACHED || is_active(intf)) |
970 | is_active(intf)) | ||
971 | goto done; | 975 | goto done; |
972 | 976 | ||
973 | /* Don't let autoresume interfere with unbinding */ | 977 | /* Don't let autoresume interfere with unbinding */ |
@@ -975,8 +979,17 @@ static int usb_resume_interface(struct usb_interface *intf, int reset_resume) | |||
975 | goto done; | 979 | goto done; |
976 | 980 | ||
977 | /* Can't resume it if it doesn't have a driver. */ | 981 | /* Can't resume it if it doesn't have a driver. */ |
978 | if (intf->condition == USB_INTERFACE_UNBOUND) | 982 | if (intf->condition == USB_INTERFACE_UNBOUND) { |
983 | |||
984 | /* Carry out a deferred switch to altsetting 0 */ | ||
985 | if (intf->needs_altsetting0 && | ||
986 | intf->dev.power.status == DPM_ON) { | ||
987 | usb_set_interface(udev, intf->altsetting[0]. | ||
988 | desc.bInterfaceNumber, 0); | ||
989 | intf->needs_altsetting0 = 0; | ||
990 | } | ||
979 | goto done; | 991 | goto done; |
992 | } | ||
980 | 993 | ||
981 | /* Don't resume if the interface is marked for rebinding */ | 994 | /* Don't resume if the interface is marked for rebinding */ |
982 | if (intf->needs_binding) | 995 | if (intf->needs_binding) |
@@ -1057,7 +1070,8 @@ static int autosuspend_check(struct usb_device *udev, int reschedule) | |||
1057 | struct usb_driver *driver; | 1070 | struct usb_driver *driver; |
1058 | 1071 | ||
1059 | driver = to_usb_driver(intf->dev.driver); | 1072 | driver = to_usb_driver(intf->dev.driver); |
1060 | if (!driver->reset_resume) | 1073 | if (!driver->reset_resume || |
1074 | intf->needs_remote_wakeup) | ||
1061 | return -EOPNOTSUPP; | 1075 | return -EOPNOTSUPP; |
1062 | } | 1076 | } |
1063 | } | 1077 | } |
@@ -1151,7 +1165,7 @@ static int usb_suspend_both(struct usb_device *udev, pm_message_t msg) | |||
1151 | if (udev->actconfig) { | 1165 | if (udev->actconfig) { |
1152 | for (; i < udev->actconfig->desc.bNumInterfaces; i++) { | 1166 | for (; i < udev->actconfig->desc.bNumInterfaces; i++) { |
1153 | intf = udev->actconfig->interface[i]; | 1167 | intf = udev->actconfig->interface[i]; |
1154 | status = usb_suspend_interface(intf, msg); | 1168 | status = usb_suspend_interface(udev, intf, msg); |
1155 | if (status != 0) | 1169 | if (status != 0) |
1156 | break; | 1170 | break; |
1157 | } | 1171 | } |
@@ -1163,7 +1177,7 @@ static int usb_suspend_both(struct usb_device *udev, pm_message_t msg) | |||
1163 | if (status != 0) { | 1177 | if (status != 0) { |
1164 | while (--i >= 0) { | 1178 | while (--i >= 0) { |
1165 | intf = udev->actconfig->interface[i]; | 1179 | intf = udev->actconfig->interface[i]; |
1166 | usb_resume_interface(intf, 0); | 1180 | usb_resume_interface(udev, intf, 0); |
1167 | } | 1181 | } |
1168 | 1182 | ||
1169 | /* Try another autosuspend when the interfaces aren't busy */ | 1183 | /* Try another autosuspend when the interfaces aren't busy */ |
@@ -1276,7 +1290,7 @@ static int usb_resume_both(struct usb_device *udev) | |||
1276 | if (status == 0 && udev->actconfig) { | 1290 | if (status == 0 && udev->actconfig) { |
1277 | for (i = 0; i < udev->actconfig->desc.bNumInterfaces; i++) { | 1291 | for (i = 0; i < udev->actconfig->desc.bNumInterfaces; i++) { |
1278 | intf = udev->actconfig->interface[i]; | 1292 | intf = udev->actconfig->interface[i]; |
1279 | usb_resume_interface(intf, udev->reset_resume); | 1293 | usb_resume_interface(udev, intf, udev->reset_resume); |
1280 | } | 1294 | } |
1281 | } | 1295 | } |
1282 | 1296 | ||
@@ -1605,12 +1619,10 @@ int usb_external_resume_device(struct usb_device *udev) | |||
1605 | return status; | 1619 | return status; |
1606 | } | 1620 | } |
1607 | 1621 | ||
1608 | static int usb_suspend(struct device *dev, pm_message_t message) | 1622 | int usb_suspend(struct device *dev, pm_message_t message) |
1609 | { | 1623 | { |
1610 | struct usb_device *udev; | 1624 | struct usb_device *udev; |
1611 | 1625 | ||
1612 | if (!is_usb_device(dev)) /* Ignore PM for interfaces */ | ||
1613 | return 0; | ||
1614 | udev = to_usb_device(dev); | 1626 | udev = to_usb_device(dev); |
1615 | 1627 | ||
1616 | /* If udev is already suspended, we can skip this suspend and | 1628 | /* If udev is already suspended, we can skip this suspend and |
@@ -1629,12 +1641,10 @@ static int usb_suspend(struct device *dev, pm_message_t message) | |||
1629 | return usb_external_suspend_device(udev, message); | 1641 | return usb_external_suspend_device(udev, message); |
1630 | } | 1642 | } |
1631 | 1643 | ||
1632 | static int usb_resume(struct device *dev) | 1644 | int usb_resume(struct device *dev) |
1633 | { | 1645 | { |
1634 | struct usb_device *udev; | 1646 | struct usb_device *udev; |
1635 | 1647 | ||
1636 | if (!is_usb_device(dev)) /* Ignore PM for interfaces */ | ||
1637 | return 0; | ||
1638 | udev = to_usb_device(dev); | 1648 | udev = to_usb_device(dev); |
1639 | 1649 | ||
1640 | /* If udev->skip_sys_resume is set then udev was already suspended | 1650 | /* If udev->skip_sys_resume is set then udev was already suspended |
@@ -1646,17 +1656,10 @@ static int usb_resume(struct device *dev) | |||
1646 | return usb_external_resume_device(udev); | 1656 | return usb_external_resume_device(udev); |
1647 | } | 1657 | } |
1648 | 1658 | ||
1649 | #else | ||
1650 | |||
1651 | #define usb_suspend NULL | ||
1652 | #define usb_resume NULL | ||
1653 | |||
1654 | #endif /* CONFIG_PM */ | 1659 | #endif /* CONFIG_PM */ |
1655 | 1660 | ||
1656 | struct bus_type usb_bus_type = { | 1661 | struct bus_type usb_bus_type = { |
1657 | .name = "usb", | 1662 | .name = "usb", |
1658 | .match = usb_device_match, | 1663 | .match = usb_device_match, |
1659 | .uevent = usb_uevent, | 1664 | .uevent = usb_uevent, |
1660 | .suspend = usb_suspend, | ||
1661 | .resume = usb_resume, | ||
1662 | }; | 1665 | }; |
diff --git a/drivers/usb/core/endpoint.c b/drivers/usb/core/endpoint.c index 22912136fc14..946fae43d622 100644 --- a/drivers/usb/core/endpoint.c +++ b/drivers/usb/core/endpoint.c | |||
@@ -169,7 +169,8 @@ static int usb_endpoint_major_init(void) | |||
169 | error = alloc_chrdev_region(&dev, 0, MAX_ENDPOINT_MINORS, | 169 | error = alloc_chrdev_region(&dev, 0, MAX_ENDPOINT_MINORS, |
170 | "usb_endpoint"); | 170 | "usb_endpoint"); |
171 | if (error) { | 171 | if (error) { |
172 | err("unable to get a dynamic major for usb endpoints"); | 172 | printk(KERN_ERR "Unable to get a dynamic major for " |
173 | "usb endpoints.\n"); | ||
173 | return error; | 174 | return error; |
174 | } | 175 | } |
175 | usb_endpoint_major = MAJOR(dev); | 176 | usb_endpoint_major = MAJOR(dev); |
diff --git a/drivers/usb/core/file.c b/drivers/usb/core/file.c index 6b1b229e38cd..997e659ff693 100644 --- a/drivers/usb/core/file.c +++ b/drivers/usb/core/file.c | |||
@@ -86,7 +86,7 @@ static int init_usb_class(void) | |||
86 | usb_class->class = class_create(THIS_MODULE, "usb"); | 86 | usb_class->class = class_create(THIS_MODULE, "usb"); |
87 | if (IS_ERR(usb_class->class)) { | 87 | if (IS_ERR(usb_class->class)) { |
88 | result = IS_ERR(usb_class->class); | 88 | result = IS_ERR(usb_class->class); |
89 | err("class_create failed for usb devices"); | 89 | printk(KERN_ERR "class_create failed for usb devices\n"); |
90 | kfree(usb_class); | 90 | kfree(usb_class); |
91 | usb_class = NULL; | 91 | usb_class = NULL; |
92 | } | 92 | } |
@@ -115,7 +115,8 @@ int usb_major_init(void) | |||
115 | 115 | ||
116 | error = register_chrdev(USB_MAJOR, "usb", &usb_fops); | 116 | error = register_chrdev(USB_MAJOR, "usb", &usb_fops); |
117 | if (error) | 117 | if (error) |
118 | err("unable to get major %d for usb devices", USB_MAJOR); | 118 | printk(KERN_ERR "Unable to get major %d for usb devices\n", |
119 | USB_MAJOR); | ||
119 | 120 | ||
120 | return error; | 121 | return error; |
121 | } | 122 | } |
@@ -196,9 +197,9 @@ int usb_register_dev(struct usb_interface *intf, | |||
196 | ++temp; | 197 | ++temp; |
197 | else | 198 | else |
198 | temp = name; | 199 | temp = name; |
199 | intf->usb_dev = device_create_drvdata(usb_class->class, &intf->dev, | 200 | intf->usb_dev = device_create(usb_class->class, &intf->dev, |
200 | MKDEV(USB_MAJOR, minor), NULL, | 201 | MKDEV(USB_MAJOR, minor), NULL, |
201 | "%s", temp); | 202 | "%s", temp); |
202 | if (IS_ERR(intf->usb_dev)) { | 203 | if (IS_ERR(intf->usb_dev)) { |
203 | down_write(&minor_rwsem); | 204 | down_write(&minor_rwsem); |
204 | usb_minors[intf->minor] = NULL; | 205 | usb_minors[intf->minor] = NULL; |
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index f7bfd72ef115..fc9018e72a09 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c | |||
@@ -81,6 +81,10 @@ | |||
81 | 81 | ||
82 | /*-------------------------------------------------------------------------*/ | 82 | /*-------------------------------------------------------------------------*/ |
83 | 83 | ||
84 | /* Keep track of which host controller drivers are loaded */ | ||
85 | unsigned long usb_hcds_loaded; | ||
86 | EXPORT_SYMBOL_GPL(usb_hcds_loaded); | ||
87 | |||
84 | /* host controllers we manage */ | 88 | /* host controllers we manage */ |
85 | LIST_HEAD (usb_bus_list); | 89 | LIST_HEAD (usb_bus_list); |
86 | EXPORT_SYMBOL_GPL (usb_bus_list); | 90 | EXPORT_SYMBOL_GPL (usb_bus_list); |
@@ -818,9 +822,8 @@ static int usb_register_bus(struct usb_bus *bus) | |||
818 | set_bit (busnum, busmap.busmap); | 822 | set_bit (busnum, busmap.busmap); |
819 | bus->busnum = busnum; | 823 | bus->busnum = busnum; |
820 | 824 | ||
821 | bus->dev = device_create_drvdata(usb_host_class, bus->controller, | 825 | bus->dev = device_create(usb_host_class, bus->controller, MKDEV(0, 0), |
822 | MKDEV(0, 0), bus, | 826 | bus, "usb_host%d", busnum); |
823 | "usb_host%d", busnum); | ||
824 | result = PTR_ERR(bus->dev); | 827 | result = PTR_ERR(bus->dev); |
825 | if (IS_ERR(bus->dev)) | 828 | if (IS_ERR(bus->dev)) |
826 | goto error_create_class_dev; | 829 | goto error_create_class_dev; |
@@ -924,15 +927,6 @@ static int register_root_hub(struct usb_hcd *hcd) | |||
924 | return retval; | 927 | return retval; |
925 | } | 928 | } |
926 | 929 | ||
927 | void usb_enable_root_hub_irq (struct usb_bus *bus) | ||
928 | { | ||
929 | struct usb_hcd *hcd; | ||
930 | |||
931 | hcd = container_of (bus, struct usb_hcd, self); | ||
932 | if (hcd->driver->hub_irq_enable && hcd->state != HC_STATE_HALT) | ||
933 | hcd->driver->hub_irq_enable (hcd); | ||
934 | } | ||
935 | |||
936 | 930 | ||
937 | /*-------------------------------------------------------------------------*/ | 931 | /*-------------------------------------------------------------------------*/ |
938 | 932 | ||
@@ -1885,7 +1879,8 @@ int usb_add_hcd(struct usb_hcd *hcd, | |||
1885 | * with IRQF_SHARED. As usb_hcd_irq() will always disable | 1879 | * with IRQF_SHARED. As usb_hcd_irq() will always disable |
1886 | * interrupts we can remove it here. | 1880 | * interrupts we can remove it here. |
1887 | */ | 1881 | */ |
1888 | irqflags &= ~IRQF_DISABLED; | 1882 | if (irqflags & IRQF_SHARED) |
1883 | irqflags &= ~IRQF_DISABLED; | ||
1889 | 1884 | ||
1890 | snprintf(hcd->irq_descr, sizeof(hcd->irq_descr), "%s:usb%d", | 1885 | snprintf(hcd->irq_descr, sizeof(hcd->irq_descr), "%s:usb%d", |
1891 | hcd->driver->description, hcd->self.busnum); | 1886 | hcd->driver->description, hcd->self.busnum); |
diff --git a/drivers/usb/core/hcd.h b/drivers/usb/core/hcd.h index 5b0b59b0d89b..2dcde61c465e 100644 --- a/drivers/usb/core/hcd.h +++ b/drivers/usb/core/hcd.h | |||
@@ -212,8 +212,6 @@ struct hc_driver { | |||
212 | int (*bus_suspend)(struct usb_hcd *); | 212 | int (*bus_suspend)(struct usb_hcd *); |
213 | int (*bus_resume)(struct usb_hcd *); | 213 | int (*bus_resume)(struct usb_hcd *); |
214 | int (*start_port_reset)(struct usb_hcd *, unsigned port_num); | 214 | int (*start_port_reset)(struct usb_hcd *, unsigned port_num); |
215 | void (*hub_irq_enable)(struct usb_hcd *); | ||
216 | /* Needed only if port-change IRQs are level-triggered */ | ||
217 | 215 | ||
218 | /* force handover of high-speed port to full-speed companion */ | 216 | /* force handover of high-speed port to full-speed companion */ |
219 | void (*relinquish_port)(struct usb_hcd *, int); | 217 | void (*relinquish_port)(struct usb_hcd *, int); |
@@ -379,8 +377,6 @@ extern struct list_head usb_bus_list; | |||
379 | extern struct mutex usb_bus_list_lock; | 377 | extern struct mutex usb_bus_list_lock; |
380 | extern wait_queue_head_t usb_kill_urb_queue; | 378 | extern wait_queue_head_t usb_kill_urb_queue; |
381 | 379 | ||
382 | extern void usb_enable_root_hub_irq(struct usb_bus *bus); | ||
383 | |||
384 | extern int usb_find_interface_driver(struct usb_device *dev, | 380 | extern int usb_find_interface_driver(struct usb_device *dev, |
385 | struct usb_interface *interface); | 381 | struct usb_interface *interface); |
386 | 382 | ||
@@ -486,4 +482,10 @@ static inline void usbmon_urb_complete(struct usb_bus *bus, struct urb *urb, | |||
486 | */ | 482 | */ |
487 | extern struct rw_semaphore ehci_cf_port_reset_rwsem; | 483 | extern struct rw_semaphore ehci_cf_port_reset_rwsem; |
488 | 484 | ||
485 | /* Keep track of which host controller drivers are loaded */ | ||
486 | #define USB_UHCI_LOADED 0 | ||
487 | #define USB_OHCI_LOADED 1 | ||
488 | #define USB_EHCI_LOADED 2 | ||
489 | extern unsigned long usb_hcds_loaded; | ||
490 | |||
489 | #endif /* __KERNEL__ */ | 491 | #endif /* __KERNEL__ */ |
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 107e1d25ddec..d73ce262c365 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c | |||
@@ -77,6 +77,7 @@ struct usb_hub { | |||
77 | unsigned has_indicators:1; | 77 | unsigned has_indicators:1; |
78 | u8 indicator[USB_MAXCHILDREN]; | 78 | u8 indicator[USB_MAXCHILDREN]; |
79 | struct delayed_work leds; | 79 | struct delayed_work leds; |
80 | struct delayed_work init_work; | ||
80 | }; | 81 | }; |
81 | 82 | ||
82 | 83 | ||
@@ -100,6 +101,15 @@ module_param (blinkenlights, bool, S_IRUGO); | |||
100 | MODULE_PARM_DESC (blinkenlights, "true to cycle leds on hubs"); | 101 | MODULE_PARM_DESC (blinkenlights, "true to cycle leds on hubs"); |
101 | 102 | ||
102 | /* | 103 | /* |
104 | * Device SATA8000 FW1.0 from DATAST0R Technology Corp requires about | ||
105 | * 10 seconds to send reply for the initial 64-byte descriptor request. | ||
106 | */ | ||
107 | /* define initial 64-byte descriptor request timeout in milliseconds */ | ||
108 | static int initial_descriptor_timeout = USB_CTRL_GET_TIMEOUT; | ||
109 | module_param(initial_descriptor_timeout, int, S_IRUGO|S_IWUSR); | ||
110 | MODULE_PARM_DESC(initial_descriptor_timeout, "initial 64-byte descriptor request timeout in milliseconds (default 5000 - 5.0 seconds)"); | ||
111 | |||
112 | /* | ||
103 | * As of 2.6.10 we introduce a new USB device initialization scheme which | 113 | * As of 2.6.10 we introduce a new USB device initialization scheme which |
104 | * closely resembles the way Windows works. Hopefully it will be compatible | 114 | * closely resembles the way Windows works. Hopefully it will be compatible |
105 | * with a wider range of devices than the old scheme. However some previously | 115 | * with a wider range of devices than the old scheme. However some previously |
@@ -515,10 +525,14 @@ void usb_hub_tt_clear_buffer (struct usb_device *udev, int pipe) | |||
515 | } | 525 | } |
516 | EXPORT_SYMBOL_GPL(usb_hub_tt_clear_buffer); | 526 | EXPORT_SYMBOL_GPL(usb_hub_tt_clear_buffer); |
517 | 527 | ||
518 | static void hub_power_on(struct usb_hub *hub) | 528 | /* If do_delay is false, return the number of milliseconds the caller |
529 | * needs to delay. | ||
530 | */ | ||
531 | static unsigned hub_power_on(struct usb_hub *hub, bool do_delay) | ||
519 | { | 532 | { |
520 | int port1; | 533 | int port1; |
521 | unsigned pgood_delay = hub->descriptor->bPwrOn2PwrGood * 2; | 534 | unsigned pgood_delay = hub->descriptor->bPwrOn2PwrGood * 2; |
535 | unsigned delay; | ||
522 | u16 wHubCharacteristics = | 536 | u16 wHubCharacteristics = |
523 | le16_to_cpu(hub->descriptor->wHubCharacteristics); | 537 | le16_to_cpu(hub->descriptor->wHubCharacteristics); |
524 | 538 | ||
@@ -537,7 +551,10 @@ static void hub_power_on(struct usb_hub *hub) | |||
537 | set_port_feature(hub->hdev, port1, USB_PORT_FEAT_POWER); | 551 | set_port_feature(hub->hdev, port1, USB_PORT_FEAT_POWER); |
538 | 552 | ||
539 | /* Wait at least 100 msec for power to become stable */ | 553 | /* Wait at least 100 msec for power to become stable */ |
540 | msleep(max(pgood_delay, (unsigned) 100)); | 554 | delay = max(pgood_delay, (unsigned) 100); |
555 | if (do_delay) | ||
556 | msleep(delay); | ||
557 | return delay; | ||
541 | } | 558 | } |
542 | 559 | ||
543 | static int hub_hub_status(struct usb_hub *hub, | 560 | static int hub_hub_status(struct usb_hub *hub, |
@@ -599,21 +616,55 @@ static void hub_port_logical_disconnect(struct usb_hub *hub, int port1) | |||
599 | } | 616 | } |
600 | 617 | ||
601 | enum hub_activation_type { | 618 | enum hub_activation_type { |
602 | HUB_INIT, HUB_POST_RESET, HUB_RESUME, HUB_RESET_RESUME | 619 | HUB_INIT, HUB_INIT2, HUB_INIT3, |
620 | HUB_POST_RESET, HUB_RESUME, HUB_RESET_RESUME, | ||
603 | }; | 621 | }; |
604 | 622 | ||
623 | static void hub_init_func2(struct work_struct *ws); | ||
624 | static void hub_init_func3(struct work_struct *ws); | ||
625 | |||
605 | static void hub_activate(struct usb_hub *hub, enum hub_activation_type type) | 626 | static void hub_activate(struct usb_hub *hub, enum hub_activation_type type) |
606 | { | 627 | { |
607 | struct usb_device *hdev = hub->hdev; | 628 | struct usb_device *hdev = hub->hdev; |
608 | int port1; | 629 | int port1; |
609 | int status; | 630 | int status; |
610 | bool need_debounce_delay = false; | 631 | bool need_debounce_delay = false; |
632 | unsigned delay; | ||
633 | |||
634 | /* Continue a partial initialization */ | ||
635 | if (type == HUB_INIT2) | ||
636 | goto init2; | ||
637 | if (type == HUB_INIT3) | ||
638 | goto init3; | ||
611 | 639 | ||
612 | /* After a resume, port power should still be on. | 640 | /* After a resume, port power should still be on. |
613 | * For any other type of activation, turn it on. | 641 | * For any other type of activation, turn it on. |
614 | */ | 642 | */ |
615 | if (type != HUB_RESUME) | 643 | if (type != HUB_RESUME) { |
616 | hub_power_on(hub); | 644 | |
645 | /* Speed up system boot by using a delayed_work for the | ||
646 | * hub's initial power-up delays. This is pretty awkward | ||
647 | * and the implementation looks like a home-brewed sort of | ||
648 | * setjmp/longjmp, but it saves at least 100 ms for each | ||
649 | * root hub (assuming usbcore is compiled into the kernel | ||
650 | * rather than as a module). It adds up. | ||
651 | * | ||
652 | * This can't be done for HUB_RESUME or HUB_RESET_RESUME | ||
653 | * because for those activation types the ports have to be | ||
654 | * operational when we return. In theory this could be done | ||
655 | * for HUB_POST_RESET, but it's easier not to. | ||
656 | */ | ||
657 | if (type == HUB_INIT) { | ||
658 | delay = hub_power_on(hub, false); | ||
659 | PREPARE_DELAYED_WORK(&hub->init_work, hub_init_func2); | ||
660 | schedule_delayed_work(&hub->init_work, | ||
661 | msecs_to_jiffies(delay)); | ||
662 | return; /* Continues at init2: below */ | ||
663 | } else { | ||
664 | hub_power_on(hub, true); | ||
665 | } | ||
666 | } | ||
667 | init2: | ||
617 | 668 | ||
618 | /* Check each port and set hub->change_bits to let khubd know | 669 | /* Check each port and set hub->change_bits to let khubd know |
619 | * which ports need attention. | 670 | * which ports need attention. |
@@ -692,9 +743,20 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type) | |||
692 | * If any port-status changes do occur during this delay, khubd | 743 | * If any port-status changes do occur during this delay, khubd |
693 | * will see them later and handle them normally. | 744 | * will see them later and handle them normally. |
694 | */ | 745 | */ |
695 | if (need_debounce_delay) | 746 | if (need_debounce_delay) { |
696 | msleep(HUB_DEBOUNCE_STABLE); | 747 | delay = HUB_DEBOUNCE_STABLE; |
697 | 748 | ||
749 | /* Don't do a long sleep inside a workqueue routine */ | ||
750 | if (type == HUB_INIT2) { | ||
751 | PREPARE_DELAYED_WORK(&hub->init_work, hub_init_func3); | ||
752 | schedule_delayed_work(&hub->init_work, | ||
753 | msecs_to_jiffies(delay)); | ||
754 | return; /* Continues at init3: below */ | ||
755 | } else { | ||
756 | msleep(delay); | ||
757 | } | ||
758 | } | ||
759 | init3: | ||
698 | hub->quiescing = 0; | 760 | hub->quiescing = 0; |
699 | 761 | ||
700 | status = usb_submit_urb(hub->urb, GFP_NOIO); | 762 | status = usb_submit_urb(hub->urb, GFP_NOIO); |
@@ -707,6 +769,21 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type) | |||
707 | kick_khubd(hub); | 769 | kick_khubd(hub); |
708 | } | 770 | } |
709 | 771 | ||
772 | /* Implement the continuations for the delays above */ | ||
773 | static void hub_init_func2(struct work_struct *ws) | ||
774 | { | ||
775 | struct usb_hub *hub = container_of(ws, struct usb_hub, init_work.work); | ||
776 | |||
777 | hub_activate(hub, HUB_INIT2); | ||
778 | } | ||
779 | |||
780 | static void hub_init_func3(struct work_struct *ws) | ||
781 | { | ||
782 | struct usb_hub *hub = container_of(ws, struct usb_hub, init_work.work); | ||
783 | |||
784 | hub_activate(hub, HUB_INIT3); | ||
785 | } | ||
786 | |||
710 | enum hub_quiescing_type { | 787 | enum hub_quiescing_type { |
711 | HUB_DISCONNECT, HUB_PRE_RESET, HUB_SUSPEND | 788 | HUB_DISCONNECT, HUB_PRE_RESET, HUB_SUSPEND |
712 | }; | 789 | }; |
@@ -716,6 +793,8 @@ static void hub_quiesce(struct usb_hub *hub, enum hub_quiescing_type type) | |||
716 | struct usb_device *hdev = hub->hdev; | 793 | struct usb_device *hdev = hub->hdev; |
717 | int i; | 794 | int i; |
718 | 795 | ||
796 | cancel_delayed_work_sync(&hub->init_work); | ||
797 | |||
719 | /* khubd and related activity won't re-trigger */ | 798 | /* khubd and related activity won't re-trigger */ |
720 | hub->quiescing = 1; | 799 | hub->quiescing = 1; |
721 | 800 | ||
@@ -1099,6 +1178,7 @@ descriptor_error: | |||
1099 | hub->intfdev = &intf->dev; | 1178 | hub->intfdev = &intf->dev; |
1100 | hub->hdev = hdev; | 1179 | hub->hdev = hdev; |
1101 | INIT_DELAYED_WORK(&hub->leds, led_work); | 1180 | INIT_DELAYED_WORK(&hub->leds, led_work); |
1181 | INIT_DELAYED_WORK(&hub->init_work, NULL); | ||
1102 | usb_get_intf(intf); | 1182 | usb_get_intf(intf); |
1103 | 1183 | ||
1104 | usb_set_intfdata (intf, hub); | 1184 | usb_set_intfdata (intf, hub); |
@@ -2102,8 +2182,6 @@ int usb_port_resume(struct usb_device *udev) | |||
2102 | } | 2182 | } |
2103 | 2183 | ||
2104 | clear_bit(port1, hub->busy_bits); | 2184 | clear_bit(port1, hub->busy_bits); |
2105 | if (!hub->hdev->parent && !hub->busy_bits[0]) | ||
2106 | usb_enable_root_hub_irq(hub->hdev->bus); | ||
2107 | 2185 | ||
2108 | status = check_port_resume_type(udev, | 2186 | status = check_port_resume_type(udev, |
2109 | hub, port1, status, portchange, portstatus); | 2187 | hub, port1, status, portchange, portstatus); |
@@ -2469,7 +2547,7 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1, | |||
2469 | USB_REQ_GET_DESCRIPTOR, USB_DIR_IN, | 2547 | USB_REQ_GET_DESCRIPTOR, USB_DIR_IN, |
2470 | USB_DT_DEVICE << 8, 0, | 2548 | USB_DT_DEVICE << 8, 0, |
2471 | buf, GET_DESCRIPTOR_BUFSIZE, | 2549 | buf, GET_DESCRIPTOR_BUFSIZE, |
2472 | USB_CTRL_GET_TIMEOUT); | 2550 | initial_descriptor_timeout); |
2473 | switch (buf->bMaxPacketSize0) { | 2551 | switch (buf->bMaxPacketSize0) { |
2474 | case 8: case 16: case 32: case 64: case 255: | 2552 | case 8: case 16: case 32: case 64: case 255: |
2475 | if (buf->bDescriptorType == | 2553 | if (buf->bDescriptorType == |
@@ -2685,35 +2763,17 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1, | |||
2685 | USB_PORT_STAT_C_ENABLE); | 2763 | USB_PORT_STAT_C_ENABLE); |
2686 | #endif | 2764 | #endif |
2687 | 2765 | ||
2688 | /* Try to use the debounce delay for protection against | ||
2689 | * port-enable changes caused, for example, by EMI. | ||
2690 | */ | ||
2691 | if (portchange & (USB_PORT_STAT_C_CONNECTION | | ||
2692 | USB_PORT_STAT_C_ENABLE)) { | ||
2693 | status = hub_port_debounce(hub, port1); | ||
2694 | if (status < 0) { | ||
2695 | if (printk_ratelimit()) | ||
2696 | dev_err (hub_dev, "connect-debounce failed, " | ||
2697 | "port %d disabled\n", port1); | ||
2698 | portstatus &= ~USB_PORT_STAT_CONNECTION; | ||
2699 | } else { | ||
2700 | portstatus = status; | ||
2701 | } | ||
2702 | } | ||
2703 | |||
2704 | /* Try to resuscitate an existing device */ | 2766 | /* Try to resuscitate an existing device */ |
2705 | udev = hdev->children[port1-1]; | 2767 | udev = hdev->children[port1-1]; |
2706 | if ((portstatus & USB_PORT_STAT_CONNECTION) && udev && | 2768 | if ((portstatus & USB_PORT_STAT_CONNECTION) && udev && |
2707 | udev->state != USB_STATE_NOTATTACHED) { | 2769 | udev->state != USB_STATE_NOTATTACHED) { |
2708 | |||
2709 | usb_lock_device(udev); | 2770 | usb_lock_device(udev); |
2710 | if (portstatus & USB_PORT_STAT_ENABLE) { | 2771 | if (portstatus & USB_PORT_STAT_ENABLE) { |
2711 | status = 0; /* Nothing to do */ | 2772 | status = 0; /* Nothing to do */ |
2712 | } else if (!udev->persist_enabled) { | ||
2713 | status = -ENODEV; /* Mustn't resuscitate */ | ||
2714 | 2773 | ||
2715 | #ifdef CONFIG_USB_SUSPEND | 2774 | #ifdef CONFIG_USB_SUSPEND |
2716 | } else if (udev->state == USB_STATE_SUSPENDED) { | 2775 | } else if (udev->state == USB_STATE_SUSPENDED && |
2776 | udev->persist_enabled) { | ||
2717 | /* For a suspended device, treat this as a | 2777 | /* For a suspended device, treat this as a |
2718 | * remote wakeup event. | 2778 | * remote wakeup event. |
2719 | */ | 2779 | */ |
@@ -2728,7 +2788,7 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1, | |||
2728 | #endif | 2788 | #endif |
2729 | 2789 | ||
2730 | } else { | 2790 | } else { |
2731 | status = usb_reset_device(udev); | 2791 | status = -ENODEV; /* Don't resuscitate */ |
2732 | } | 2792 | } |
2733 | usb_unlock_device(udev); | 2793 | usb_unlock_device(udev); |
2734 | 2794 | ||
@@ -2743,6 +2803,19 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1, | |||
2743 | usb_disconnect(&hdev->children[port1-1]); | 2803 | usb_disconnect(&hdev->children[port1-1]); |
2744 | clear_bit(port1, hub->change_bits); | 2804 | clear_bit(port1, hub->change_bits); |
2745 | 2805 | ||
2806 | if (portchange & (USB_PORT_STAT_C_CONNECTION | | ||
2807 | USB_PORT_STAT_C_ENABLE)) { | ||
2808 | status = hub_port_debounce(hub, port1); | ||
2809 | if (status < 0) { | ||
2810 | if (printk_ratelimit()) | ||
2811 | dev_err(hub_dev, "connect-debounce failed, " | ||
2812 | "port %d disabled\n", port1); | ||
2813 | portstatus &= ~USB_PORT_STAT_CONNECTION; | ||
2814 | } else { | ||
2815 | portstatus = status; | ||
2816 | } | ||
2817 | } | ||
2818 | |||
2746 | /* Return now if debouncing failed or nothing is connected */ | 2819 | /* Return now if debouncing failed or nothing is connected */ |
2747 | if (!(portstatus & USB_PORT_STAT_CONNECTION)) { | 2820 | if (!(portstatus & USB_PORT_STAT_CONNECTION)) { |
2748 | 2821 | ||
@@ -2750,7 +2823,7 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1, | |||
2750 | if ((wHubCharacteristics & HUB_CHAR_LPSM) < 2 | 2823 | if ((wHubCharacteristics & HUB_CHAR_LPSM) < 2 |
2751 | && !(portstatus & (1 << USB_PORT_FEAT_POWER))) | 2824 | && !(portstatus & (1 << USB_PORT_FEAT_POWER))) |
2752 | set_port_feature(hdev, port1, USB_PORT_FEAT_POWER); | 2825 | set_port_feature(hdev, port1, USB_PORT_FEAT_POWER); |
2753 | 2826 | ||
2754 | if (portstatus & USB_PORT_STAT_ENABLE) | 2827 | if (portstatus & USB_PORT_STAT_ENABLE) |
2755 | goto done; | 2828 | goto done; |
2756 | return; | 2829 | return; |
@@ -3042,7 +3115,7 @@ static void hub_events(void) | |||
3042 | i); | 3115 | i); |
3043 | clear_port_feature(hdev, i, | 3116 | clear_port_feature(hdev, i, |
3044 | USB_PORT_FEAT_C_OVER_CURRENT); | 3117 | USB_PORT_FEAT_C_OVER_CURRENT); |
3045 | hub_power_on(hub); | 3118 | hub_power_on(hub, true); |
3046 | } | 3119 | } |
3047 | 3120 | ||
3048 | if (portchange & USB_PORT_STAT_C_RESET) { | 3121 | if (portchange & USB_PORT_STAT_C_RESET) { |
@@ -3077,15 +3150,10 @@ static void hub_events(void) | |||
3077 | dev_dbg (hub_dev, "overcurrent change\n"); | 3150 | dev_dbg (hub_dev, "overcurrent change\n"); |
3078 | msleep(500); /* Cool down */ | 3151 | msleep(500); /* Cool down */ |
3079 | clear_hub_feature(hdev, C_HUB_OVER_CURRENT); | 3152 | clear_hub_feature(hdev, C_HUB_OVER_CURRENT); |
3080 | hub_power_on(hub); | 3153 | hub_power_on(hub, true); |
3081 | } | 3154 | } |
3082 | } | 3155 | } |
3083 | 3156 | ||
3084 | /* If this is a root hub, tell the HCD it's okay to | ||
3085 | * re-enable port-change interrupts now. */ | ||
3086 | if (!hdev->parent && !hub->busy_bits[0]) | ||
3087 | usb_enable_root_hub_irq(hdev->bus); | ||
3088 | |||
3089 | loop_autopm: | 3157 | loop_autopm: |
3090 | /* Allow autosuspend if we're not going to run again */ | 3158 | /* Allow autosuspend if we're not going to run again */ |
3091 | if (list_empty(&hub->event_list)) | 3159 | if (list_empty(&hub->event_list)) |
@@ -3311,8 +3379,6 @@ static int usb_reset_and_verify_device(struct usb_device *udev) | |||
3311 | break; | 3379 | break; |
3312 | } | 3380 | } |
3313 | clear_bit(port1, parent_hub->busy_bits); | 3381 | clear_bit(port1, parent_hub->busy_bits); |
3314 | if (!parent_hdev->parent && !parent_hub->busy_bits[0]) | ||
3315 | usb_enable_root_hub_irq(parent_hdev->bus); | ||
3316 | 3382 | ||
3317 | if (ret < 0) | 3383 | if (ret < 0) |
3318 | goto re_enumerate; | 3384 | goto re_enumerate; |
diff --git a/drivers/usb/core/inode.c b/drivers/usb/core/inode.c index db410e92c80d..94632264dccf 100644 --- a/drivers/usb/core/inode.c +++ b/drivers/usb/core/inode.c | |||
@@ -97,7 +97,7 @@ enum { | |||
97 | Opt_err, | 97 | Opt_err, |
98 | }; | 98 | }; |
99 | 99 | ||
100 | static match_table_t tokens = { | 100 | static const match_table_t tokens = { |
101 | {Opt_devuid, "devuid=%u"}, | 101 | {Opt_devuid, "devuid=%u"}, |
102 | {Opt_devgid, "devgid=%u"}, | 102 | {Opt_devgid, "devgid=%u"}, |
103 | {Opt_devmode, "devmode=%o"}, | 103 | {Opt_devmode, "devmode=%o"}, |
@@ -180,8 +180,8 @@ static int parse_options(struct super_block *s, char *data) | |||
180 | listmode = option & S_IRWXUGO; | 180 | listmode = option & S_IRWXUGO; |
181 | break; | 181 | break; |
182 | default: | 182 | default: |
183 | err("usbfs: unrecognised mount option \"%s\" " | 183 | printk(KERN_ERR "usbfs: unrecognised mount option " |
184 | "or missing value\n", p); | 184 | "\"%s\" or missing value\n", p); |
185 | return -EINVAL; | 185 | return -EINVAL; |
186 | } | 186 | } |
187 | } | 187 | } |
@@ -240,7 +240,9 @@ static void update_sb(struct super_block *sb) | |||
240 | update_special(bus); | 240 | update_special(bus); |
241 | break; | 241 | break; |
242 | default: | 242 | default: |
243 | warn("Unknown node %s mode %x found on remount!\n",bus->d_name.name,bus->d_inode->i_mode); | 243 | printk(KERN_WARNING "usbfs: Unknown node %s " |
244 | "mode %x found on remount!\n", | ||
245 | bus->d_name.name, bus->d_inode->i_mode); | ||
244 | break; | 246 | break; |
245 | } | 247 | } |
246 | } | 248 | } |
@@ -259,7 +261,7 @@ static int remount(struct super_block *sb, int *flags, char *data) | |||
259 | return 0; | 261 | return 0; |
260 | 262 | ||
261 | if (parse_options(sb, data)) { | 263 | if (parse_options(sb, data)) { |
262 | warn("usbfs: mount parameter error:"); | 264 | printk(KERN_WARNING "usbfs: mount parameter error.\n"); |
263 | return -EINVAL; | 265 | return -EINVAL; |
264 | } | 266 | } |
265 | 267 | ||
@@ -599,7 +601,7 @@ static int create_special_files (void) | |||
599 | /* create the devices special file */ | 601 | /* create the devices special file */ |
600 | retval = simple_pin_fs(&usb_fs_type, &usbfs_mount, &usbfs_mount_count); | 602 | retval = simple_pin_fs(&usb_fs_type, &usbfs_mount, &usbfs_mount_count); |
601 | if (retval) { | 603 | if (retval) { |
602 | err ("Unable to get usbfs mount"); | 604 | printk(KERN_ERR "Unable to get usbfs mount\n"); |
603 | goto exit; | 605 | goto exit; |
604 | } | 606 | } |
605 | 607 | ||
@@ -611,7 +613,7 @@ static int create_special_files (void) | |||
611 | NULL, &usbfs_devices_fops, | 613 | NULL, &usbfs_devices_fops, |
612 | listuid, listgid); | 614 | listuid, listgid); |
613 | if (devices_usbfs_dentry == NULL) { | 615 | if (devices_usbfs_dentry == NULL) { |
614 | err ("Unable to create devices usbfs file"); | 616 | printk(KERN_ERR "Unable to create devices usbfs file\n"); |
615 | retval = -ENODEV; | 617 | retval = -ENODEV; |
616 | goto error_clean_mounts; | 618 | goto error_clean_mounts; |
617 | } | 619 | } |
@@ -663,7 +665,7 @@ static void usbfs_add_bus(struct usb_bus *bus) | |||
663 | bus->usbfs_dentry = fs_create_file (name, busmode | S_IFDIR, parent, | 665 | bus->usbfs_dentry = fs_create_file (name, busmode | S_IFDIR, parent, |
664 | bus, NULL, busuid, busgid); | 666 | bus, NULL, busuid, busgid); |
665 | if (bus->usbfs_dentry == NULL) { | 667 | if (bus->usbfs_dentry == NULL) { |
666 | err ("error creating usbfs bus entry"); | 668 | printk(KERN_ERR "Error creating usbfs bus entry\n"); |
667 | return; | 669 | return; |
668 | } | 670 | } |
669 | } | 671 | } |
@@ -694,7 +696,7 @@ static void usbfs_add_device(struct usb_device *dev) | |||
694 | &usbdev_file_operations, | 696 | &usbdev_file_operations, |
695 | devuid, devgid); | 697 | devuid, devgid); |
696 | if (dev->usbfs_dentry == NULL) { | 698 | if (dev->usbfs_dentry == NULL) { |
697 | err ("error creating usbfs device entry"); | 699 | printk(KERN_ERR "Error creating usbfs device entry\n"); |
698 | return; | 700 | return; |
699 | } | 701 | } |
700 | 702 | ||
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index 286b4431a097..887738577b28 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c | |||
@@ -1204,7 +1204,8 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate) | |||
1204 | 1204 | ||
1205 | alt = usb_altnum_to_altsetting(iface, alternate); | 1205 | alt = usb_altnum_to_altsetting(iface, alternate); |
1206 | if (!alt) { | 1206 | if (!alt) { |
1207 | warn("selecting invalid altsetting %d", alternate); | 1207 | dev_warn(&dev->dev, "selecting invalid altsetting %d", |
1208 | alternate); | ||
1208 | return -EINVAL; | 1209 | return -EINVAL; |
1209 | } | 1210 | } |
1210 | 1211 | ||
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c index 5e1f5d55bf04..f66fba11fbd5 100644 --- a/drivers/usb/core/sysfs.c +++ b/drivers/usb/core/sysfs.c | |||
@@ -743,6 +743,29 @@ static ssize_t show_modalias(struct device *dev, | |||
743 | } | 743 | } |
744 | static DEVICE_ATTR(modalias, S_IRUGO, show_modalias, NULL); | 744 | static DEVICE_ATTR(modalias, S_IRUGO, show_modalias, NULL); |
745 | 745 | ||
746 | static ssize_t show_supports_autosuspend(struct device *dev, | ||
747 | struct device_attribute *attr, char *buf) | ||
748 | { | ||
749 | struct usb_interface *intf; | ||
750 | struct usb_device *udev; | ||
751 | int ret; | ||
752 | |||
753 | intf = to_usb_interface(dev); | ||
754 | udev = interface_to_usbdev(intf); | ||
755 | |||
756 | usb_lock_device(udev); | ||
757 | /* Devices will be autosuspended even when an interface isn't claimed */ | ||
758 | if (!intf->dev.driver || | ||
759 | to_usb_driver(intf->dev.driver)->supports_autosuspend) | ||
760 | ret = sprintf(buf, "%u\n", 1); | ||
761 | else | ||
762 | ret = sprintf(buf, "%u\n", 0); | ||
763 | usb_unlock_device(udev); | ||
764 | |||
765 | return ret; | ||
766 | } | ||
767 | static DEVICE_ATTR(supports_autosuspend, S_IRUGO, show_supports_autosuspend, NULL); | ||
768 | |||
746 | static struct attribute *intf_attrs[] = { | 769 | static struct attribute *intf_attrs[] = { |
747 | &dev_attr_bInterfaceNumber.attr, | 770 | &dev_attr_bInterfaceNumber.attr, |
748 | &dev_attr_bAlternateSetting.attr, | 771 | &dev_attr_bAlternateSetting.attr, |
@@ -751,6 +774,7 @@ static struct attribute *intf_attrs[] = { | |||
751 | &dev_attr_bInterfaceSubClass.attr, | 774 | &dev_attr_bInterfaceSubClass.attr, |
752 | &dev_attr_bInterfaceProtocol.attr, | 775 | &dev_attr_bInterfaceProtocol.attr, |
753 | &dev_attr_modalias.attr, | 776 | &dev_attr_modalias.attr, |
777 | &dev_attr_supports_autosuspend.attr, | ||
754 | NULL, | 778 | NULL, |
755 | }; | 779 | }; |
756 | static struct attribute_group intf_attr_grp = { | 780 | static struct attribute_group intf_attr_grp = { |
diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c index c0b1ae25ae2a..f2638009a464 100644 --- a/drivers/usb/core/urb.c +++ b/drivers/usb/core/urb.c | |||
@@ -10,6 +10,8 @@ | |||
10 | 10 | ||
11 | #define to_urb(d) container_of(d, struct urb, kref) | 11 | #define to_urb(d) container_of(d, struct urb, kref) |
12 | 12 | ||
13 | static DEFINE_SPINLOCK(usb_reject_lock); | ||
14 | |||
13 | static void urb_destroy(struct kref *kref) | 15 | static void urb_destroy(struct kref *kref) |
14 | { | 16 | { |
15 | struct urb *urb = to_urb(kref); | 17 | struct urb *urb = to_urb(kref); |
@@ -68,7 +70,7 @@ struct urb *usb_alloc_urb(int iso_packets, gfp_t mem_flags) | |||
68 | iso_packets * sizeof(struct usb_iso_packet_descriptor), | 70 | iso_packets * sizeof(struct usb_iso_packet_descriptor), |
69 | mem_flags); | 71 | mem_flags); |
70 | if (!urb) { | 72 | if (!urb) { |
71 | err("alloc_urb: kmalloc failed"); | 73 | printk(KERN_ERR "alloc_urb: kmalloc failed\n"); |
72 | return NULL; | 74 | return NULL; |
73 | } | 75 | } |
74 | usb_init_urb(urb); | 76 | usb_init_urb(urb); |
@@ -127,6 +129,13 @@ void usb_anchor_urb(struct urb *urb, struct usb_anchor *anchor) | |||
127 | usb_get_urb(urb); | 129 | usb_get_urb(urb); |
128 | list_add_tail(&urb->anchor_list, &anchor->urb_list); | 130 | list_add_tail(&urb->anchor_list, &anchor->urb_list); |
129 | urb->anchor = anchor; | 131 | urb->anchor = anchor; |
132 | |||
133 | if (unlikely(anchor->poisoned)) { | ||
134 | spin_lock(&usb_reject_lock); | ||
135 | urb->reject++; | ||
136 | spin_unlock(&usb_reject_lock); | ||
137 | } | ||
138 | |||
130 | spin_unlock_irqrestore(&anchor->lock, flags); | 139 | spin_unlock_irqrestore(&anchor->lock, flags); |
131 | } | 140 | } |
132 | EXPORT_SYMBOL_GPL(usb_anchor_urb); | 141 | EXPORT_SYMBOL_GPL(usb_anchor_urb); |
@@ -398,7 +407,7 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags) | |||
398 | 407 | ||
399 | /* fail if submitter gave bogus flags */ | 408 | /* fail if submitter gave bogus flags */ |
400 | if (urb->transfer_flags != orig_flags) { | 409 | if (urb->transfer_flags != orig_flags) { |
401 | err("BOGUS urb flags, %x --> %x", | 410 | dev_err(&dev->dev, "BOGUS urb flags, %x --> %x\n", |
402 | orig_flags, urb->transfer_flags); | 411 | orig_flags, urb->transfer_flags); |
403 | return -EINVAL; | 412 | return -EINVAL; |
404 | } | 413 | } |
@@ -544,25 +553,70 @@ EXPORT_SYMBOL_GPL(usb_unlink_urb); | |||
544 | */ | 553 | */ |
545 | void usb_kill_urb(struct urb *urb) | 554 | void usb_kill_urb(struct urb *urb) |
546 | { | 555 | { |
547 | static DEFINE_MUTEX(reject_mutex); | ||
548 | |||
549 | might_sleep(); | 556 | might_sleep(); |
550 | if (!(urb && urb->dev && urb->ep)) | 557 | if (!(urb && urb->dev && urb->ep)) |
551 | return; | 558 | return; |
552 | mutex_lock(&reject_mutex); | 559 | spin_lock_irq(&usb_reject_lock); |
553 | ++urb->reject; | 560 | ++urb->reject; |
554 | mutex_unlock(&reject_mutex); | 561 | spin_unlock_irq(&usb_reject_lock); |
555 | 562 | ||
556 | usb_hcd_unlink_urb(urb, -ENOENT); | 563 | usb_hcd_unlink_urb(urb, -ENOENT); |
557 | wait_event(usb_kill_urb_queue, atomic_read(&urb->use_count) == 0); | 564 | wait_event(usb_kill_urb_queue, atomic_read(&urb->use_count) == 0); |
558 | 565 | ||
559 | mutex_lock(&reject_mutex); | 566 | spin_lock_irq(&usb_reject_lock); |
560 | --urb->reject; | 567 | --urb->reject; |
561 | mutex_unlock(&reject_mutex); | 568 | spin_unlock_irq(&usb_reject_lock); |
562 | } | 569 | } |
563 | EXPORT_SYMBOL_GPL(usb_kill_urb); | 570 | EXPORT_SYMBOL_GPL(usb_kill_urb); |
564 | 571 | ||
565 | /** | 572 | /** |
573 | * usb_poison_urb - reliably kill a transfer and prevent further use of an URB | ||
574 | * @urb: pointer to URB describing a previously submitted request, | ||
575 | * may be NULL | ||
576 | * | ||
577 | * This routine cancels an in-progress request. It is guaranteed that | ||
578 | * upon return all completion handlers will have finished and the URB | ||
579 | * will be totally idle and cannot be reused. These features make | ||
580 | * this an ideal way to stop I/O in a disconnect() callback. | ||
581 | * If the request has not already finished or been unlinked | ||
582 | * the completion handler will see urb->status == -ENOENT. | ||
583 | * | ||
584 | * After and while the routine runs, attempts to resubmit the URB will fail | ||
585 | * with error -EPERM. Thus even if the URB's completion handler always | ||
586 | * tries to resubmit, it will not succeed and the URB will become idle. | ||
587 | * | ||
588 | * This routine may not be used in an interrupt context (such as a bottom | ||
589 | * half or a completion handler), or when holding a spinlock, or in other | ||
590 | * situations where the caller can't schedule(). | ||
591 | */ | ||
592 | void usb_poison_urb(struct urb *urb) | ||
593 | { | ||
594 | might_sleep(); | ||
595 | if (!(urb && urb->dev && urb->ep)) | ||
596 | return; | ||
597 | spin_lock_irq(&usb_reject_lock); | ||
598 | ++urb->reject; | ||
599 | spin_unlock_irq(&usb_reject_lock); | ||
600 | |||
601 | usb_hcd_unlink_urb(urb, -ENOENT); | ||
602 | wait_event(usb_kill_urb_queue, atomic_read(&urb->use_count) == 0); | ||
603 | } | ||
604 | EXPORT_SYMBOL_GPL(usb_poison_urb); | ||
605 | |||
606 | void usb_unpoison_urb(struct urb *urb) | ||
607 | { | ||
608 | unsigned long flags; | ||
609 | |||
610 | if (!urb) | ||
611 | return; | ||
612 | |||
613 | spin_lock_irqsave(&usb_reject_lock, flags); | ||
614 | --urb->reject; | ||
615 | spin_unlock_irqrestore(&usb_reject_lock, flags); | ||
616 | } | ||
617 | EXPORT_SYMBOL_GPL(usb_unpoison_urb); | ||
618 | |||
619 | /** | ||
566 | * usb_kill_anchored_urbs - cancel transfer requests en masse | 620 | * usb_kill_anchored_urbs - cancel transfer requests en masse |
567 | * @anchor: anchor the requests are bound to | 621 | * @anchor: anchor the requests are bound to |
568 | * | 622 | * |
@@ -589,6 +643,35 @@ void usb_kill_anchored_urbs(struct usb_anchor *anchor) | |||
589 | } | 643 | } |
590 | EXPORT_SYMBOL_GPL(usb_kill_anchored_urbs); | 644 | EXPORT_SYMBOL_GPL(usb_kill_anchored_urbs); |
591 | 645 | ||
646 | |||
647 | /** | ||
648 | * usb_poison_anchored_urbs - cease all traffic from an anchor | ||
649 | * @anchor: anchor the requests are bound to | ||
650 | * | ||
651 | * this allows all outstanding URBs to be poisoned starting | ||
652 | * from the back of the queue. Newly added URBs will also be | ||
653 | * poisoned | ||
654 | */ | ||
655 | void usb_poison_anchored_urbs(struct usb_anchor *anchor) | ||
656 | { | ||
657 | struct urb *victim; | ||
658 | |||
659 | spin_lock_irq(&anchor->lock); | ||
660 | anchor->poisoned = 1; | ||
661 | while (!list_empty(&anchor->urb_list)) { | ||
662 | victim = list_entry(anchor->urb_list.prev, struct urb, | ||
663 | anchor_list); | ||
664 | /* we must make sure the URB isn't freed before we kill it*/ | ||
665 | usb_get_urb(victim); | ||
666 | spin_unlock_irq(&anchor->lock); | ||
667 | /* this will unanchor the URB */ | ||
668 | usb_poison_urb(victim); | ||
669 | usb_put_urb(victim); | ||
670 | spin_lock_irq(&anchor->lock); | ||
671 | } | ||
672 | spin_unlock_irq(&anchor->lock); | ||
673 | } | ||
674 | EXPORT_SYMBOL_GPL(usb_poison_anchored_urbs); | ||
592 | /** | 675 | /** |
593 | * usb_unlink_anchored_urbs - asynchronously cancel transfer requests en masse | 676 | * usb_unlink_anchored_urbs - asynchronously cancel transfer requests en masse |
594 | * @anchor: anchor the requests are bound to | 677 | * @anchor: anchor the requests are bound to |
@@ -601,15 +684,20 @@ EXPORT_SYMBOL_GPL(usb_kill_anchored_urbs); | |||
601 | void usb_unlink_anchored_urbs(struct usb_anchor *anchor) | 684 | void usb_unlink_anchored_urbs(struct usb_anchor *anchor) |
602 | { | 685 | { |
603 | struct urb *victim; | 686 | struct urb *victim; |
687 | unsigned long flags; | ||
604 | 688 | ||
605 | spin_lock_irq(&anchor->lock); | 689 | spin_lock_irqsave(&anchor->lock, flags); |
606 | while (!list_empty(&anchor->urb_list)) { | 690 | while (!list_empty(&anchor->urb_list)) { |
607 | victim = list_entry(anchor->urb_list.prev, struct urb, | 691 | victim = list_entry(anchor->urb_list.prev, struct urb, |
608 | anchor_list); | 692 | anchor_list); |
693 | usb_get_urb(victim); | ||
694 | spin_unlock_irqrestore(&anchor->lock, flags); | ||
609 | /* this will unanchor the URB */ | 695 | /* this will unanchor the URB */ |
610 | usb_unlink_urb(victim); | 696 | usb_unlink_urb(victim); |
697 | usb_put_urb(victim); | ||
698 | spin_lock_irqsave(&anchor->lock, flags); | ||
611 | } | 699 | } |
612 | spin_unlock_irq(&anchor->lock); | 700 | spin_unlock_irqrestore(&anchor->lock, flags); |
613 | } | 701 | } |
614 | EXPORT_SYMBOL_GPL(usb_unlink_anchored_urbs); | 702 | EXPORT_SYMBOL_GPL(usb_unlink_anchored_urbs); |
615 | 703 | ||
@@ -628,3 +716,73 @@ int usb_wait_anchor_empty_timeout(struct usb_anchor *anchor, | |||
628 | msecs_to_jiffies(timeout)); | 716 | msecs_to_jiffies(timeout)); |
629 | } | 717 | } |
630 | EXPORT_SYMBOL_GPL(usb_wait_anchor_empty_timeout); | 718 | EXPORT_SYMBOL_GPL(usb_wait_anchor_empty_timeout); |
719 | |||
720 | /** | ||
721 | * usb_get_from_anchor - get an anchor's oldest urb | ||
722 | * @anchor: the anchor whose urb you want | ||
723 | * | ||
724 | * this will take the oldest urb from an anchor, | ||
725 | * unanchor and return it | ||
726 | */ | ||
727 | struct urb *usb_get_from_anchor(struct usb_anchor *anchor) | ||
728 | { | ||
729 | struct urb *victim; | ||
730 | unsigned long flags; | ||
731 | |||
732 | spin_lock_irqsave(&anchor->lock, flags); | ||
733 | if (!list_empty(&anchor->urb_list)) { | ||
734 | victim = list_entry(anchor->urb_list.next, struct urb, | ||
735 | anchor_list); | ||
736 | usb_get_urb(victim); | ||
737 | spin_unlock_irqrestore(&anchor->lock, flags); | ||
738 | usb_unanchor_urb(victim); | ||
739 | } else { | ||
740 | spin_unlock_irqrestore(&anchor->lock, flags); | ||
741 | victim = NULL; | ||
742 | } | ||
743 | |||
744 | return victim; | ||
745 | } | ||
746 | |||
747 | EXPORT_SYMBOL_GPL(usb_get_from_anchor); | ||
748 | |||
749 | /** | ||
750 | * usb_scuttle_anchored_urbs - unanchor all an anchor's urbs | ||
751 | * @anchor: the anchor whose urbs you want to unanchor | ||
752 | * | ||
753 | * use this to get rid of all an anchor's urbs | ||
754 | */ | ||
755 | void usb_scuttle_anchored_urbs(struct usb_anchor *anchor) | ||
756 | { | ||
757 | struct urb *victim; | ||
758 | unsigned long flags; | ||
759 | |||
760 | spin_lock_irqsave(&anchor->lock, flags); | ||
761 | while (!list_empty(&anchor->urb_list)) { | ||
762 | victim = list_entry(anchor->urb_list.prev, struct urb, | ||
763 | anchor_list); | ||
764 | usb_get_urb(victim); | ||
765 | spin_unlock_irqrestore(&anchor->lock, flags); | ||
766 | /* this may free the URB */ | ||
767 | usb_unanchor_urb(victim); | ||
768 | usb_put_urb(victim); | ||
769 | spin_lock_irqsave(&anchor->lock, flags); | ||
770 | } | ||
771 | spin_unlock_irqrestore(&anchor->lock, flags); | ||
772 | } | ||
773 | |||
774 | EXPORT_SYMBOL_GPL(usb_scuttle_anchored_urbs); | ||
775 | |||
776 | /** | ||
777 | * usb_anchor_empty - is an anchor empty | ||
778 | * @anchor: the anchor you want to query | ||
779 | * | ||
780 | * returns 1 if the anchor has no urbs associated with it | ||
781 | */ | ||
782 | int usb_anchor_empty(struct usb_anchor *anchor) | ||
783 | { | ||
784 | return list_empty(&anchor->urb_list); | ||
785 | } | ||
786 | |||
787 | EXPORT_SYMBOL_GPL(usb_anchor_empty); | ||
788 | |||
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index 84fcaa6a21ec..be1fa0723f2c 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c | |||
@@ -219,12 +219,6 @@ static int usb_dev_uevent(struct device *dev, struct kobj_uevent_env *env) | |||
219 | } | 219 | } |
220 | #endif /* CONFIG_HOTPLUG */ | 220 | #endif /* CONFIG_HOTPLUG */ |
221 | 221 | ||
222 | struct device_type usb_device_type = { | ||
223 | .name = "usb_device", | ||
224 | .release = usb_release_dev, | ||
225 | .uevent = usb_dev_uevent, | ||
226 | }; | ||
227 | |||
228 | #ifdef CONFIG_PM | 222 | #ifdef CONFIG_PM |
229 | 223 | ||
230 | static int ksuspend_usb_init(void) | 224 | static int ksuspend_usb_init(void) |
@@ -244,13 +238,80 @@ static void ksuspend_usb_cleanup(void) | |||
244 | destroy_workqueue(ksuspend_usb_wq); | 238 | destroy_workqueue(ksuspend_usb_wq); |
245 | } | 239 | } |
246 | 240 | ||
241 | /* USB device Power-Management thunks. | ||
242 | * There's no need to distinguish here between quiescing a USB device | ||
243 | * and powering it down; the generic_suspend() routine takes care of | ||
244 | * it by skipping the usb_port_suspend() call for a quiesce. And for | ||
245 | * USB interfaces there's no difference at all. | ||
246 | */ | ||
247 | |||
248 | static int usb_dev_prepare(struct device *dev) | ||
249 | { | ||
250 | return 0; /* Implement eventually? */ | ||
251 | } | ||
252 | |||
253 | static void usb_dev_complete(struct device *dev) | ||
254 | { | ||
255 | /* Currently used only for rebinding interfaces */ | ||
256 | usb_resume(dev); /* Implement eventually? */ | ||
257 | } | ||
258 | |||
259 | static int usb_dev_suspend(struct device *dev) | ||
260 | { | ||
261 | return usb_suspend(dev, PMSG_SUSPEND); | ||
262 | } | ||
263 | |||
264 | static int usb_dev_resume(struct device *dev) | ||
265 | { | ||
266 | return usb_resume(dev); | ||
267 | } | ||
268 | |||
269 | static int usb_dev_freeze(struct device *dev) | ||
270 | { | ||
271 | return usb_suspend(dev, PMSG_FREEZE); | ||
272 | } | ||
273 | |||
274 | static int usb_dev_thaw(struct device *dev) | ||
275 | { | ||
276 | return usb_resume(dev); | ||
277 | } | ||
278 | |||
279 | static int usb_dev_poweroff(struct device *dev) | ||
280 | { | ||
281 | return usb_suspend(dev, PMSG_HIBERNATE); | ||
282 | } | ||
283 | |||
284 | static int usb_dev_restore(struct device *dev) | ||
285 | { | ||
286 | return usb_resume(dev); | ||
287 | } | ||
288 | |||
289 | static struct pm_ops usb_device_pm_ops = { | ||
290 | .prepare = usb_dev_prepare, | ||
291 | .complete = usb_dev_complete, | ||
292 | .suspend = usb_dev_suspend, | ||
293 | .resume = usb_dev_resume, | ||
294 | .freeze = usb_dev_freeze, | ||
295 | .thaw = usb_dev_thaw, | ||
296 | .poweroff = usb_dev_poweroff, | ||
297 | .restore = usb_dev_restore, | ||
298 | }; | ||
299 | |||
247 | #else | 300 | #else |
248 | 301 | ||
249 | #define ksuspend_usb_init() 0 | 302 | #define ksuspend_usb_init() 0 |
250 | #define ksuspend_usb_cleanup() do {} while (0) | 303 | #define ksuspend_usb_cleanup() do {} while (0) |
304 | #define usb_device_pm_ops (*(struct pm_ops *)0) | ||
251 | 305 | ||
252 | #endif /* CONFIG_PM */ | 306 | #endif /* CONFIG_PM */ |
253 | 307 | ||
308 | struct device_type usb_device_type = { | ||
309 | .name = "usb_device", | ||
310 | .release = usb_release_dev, | ||
311 | .uevent = usb_dev_uevent, | ||
312 | .pm = &usb_device_pm_ops, | ||
313 | }; | ||
314 | |||
254 | 315 | ||
255 | /* Returns 1 if @usb_bus is WUSB, 0 otherwise */ | 316 | /* Returns 1 if @usb_bus is WUSB, 0 otherwise */ |
256 | static unsigned usb_bus_is_wusb(struct usb_bus *bus) | 317 | static unsigned usb_bus_is_wusb(struct usb_bus *bus) |
diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h index d9a6e16dbf84..9a1a45ac3add 100644 --- a/drivers/usb/core/usb.h +++ b/drivers/usb/core/usb.h | |||
@@ -41,6 +41,9 @@ extern void usb_host_cleanup(void); | |||
41 | 41 | ||
42 | #ifdef CONFIG_PM | 42 | #ifdef CONFIG_PM |
43 | 43 | ||
44 | extern int usb_suspend(struct device *dev, pm_message_t msg); | ||
45 | extern int usb_resume(struct device *dev); | ||
46 | |||
44 | extern void usb_autosuspend_work(struct work_struct *work); | 47 | extern void usb_autosuspend_work(struct work_struct *work); |
45 | extern int usb_port_suspend(struct usb_device *dev); | 48 | extern int usb_port_suspend(struct usb_device *dev); |
46 | extern int usb_port_resume(struct usb_device *dev); | 49 | extern int usb_port_resume(struct usb_device *dev); |
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index acc95b2ac6f8..dd4cd5a51370 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig | |||
@@ -45,7 +45,7 @@ if USB_GADGET | |||
45 | 45 | ||
46 | config USB_GADGET_DEBUG | 46 | config USB_GADGET_DEBUG |
47 | boolean "Debugging messages (DEVELOPMENT)" | 47 | boolean "Debugging messages (DEVELOPMENT)" |
48 | depends on USB_GADGET && DEBUG_KERNEL | 48 | depends on DEBUG_KERNEL |
49 | help | 49 | help |
50 | Many controller and gadget drivers will print some debugging | 50 | Many controller and gadget drivers will print some debugging |
51 | messages if you use this option to ask for those messages. | 51 | messages if you use this option to ask for those messages. |
@@ -59,7 +59,7 @@ config USB_GADGET_DEBUG | |||
59 | 59 | ||
60 | config USB_GADGET_DEBUG_FILES | 60 | config USB_GADGET_DEBUG_FILES |
61 | boolean "Debugging information files (DEVELOPMENT)" | 61 | boolean "Debugging information files (DEVELOPMENT)" |
62 | depends on USB_GADGET && PROC_FS | 62 | depends on PROC_FS |
63 | help | 63 | help |
64 | Some of the drivers in the "gadget" framework can expose | 64 | Some of the drivers in the "gadget" framework can expose |
65 | debugging information in files such as /proc/driver/udc | 65 | debugging information in files such as /proc/driver/udc |
@@ -70,7 +70,7 @@ config USB_GADGET_DEBUG_FILES | |||
70 | 70 | ||
71 | config USB_GADGET_DEBUG_FS | 71 | config USB_GADGET_DEBUG_FS |
72 | boolean "Debugging information files in debugfs (DEVELOPMENT)" | 72 | boolean "Debugging information files in debugfs (DEVELOPMENT)" |
73 | depends on USB_GADGET && DEBUG_FS | 73 | depends on DEBUG_FS |
74 | help | 74 | help |
75 | Some of the drivers in the "gadget" framework can expose | 75 | Some of the drivers in the "gadget" framework can expose |
76 | debugging information in files under /sys/kernel/debug/. | 76 | debugging information in files under /sys/kernel/debug/. |
@@ -79,12 +79,36 @@ config USB_GADGET_DEBUG_FS | |||
79 | Enable these files by choosing "Y" here. If in doubt, or | 79 | Enable these files by choosing "Y" here. If in doubt, or |
80 | to conserve kernel memory, say "N". | 80 | to conserve kernel memory, say "N". |
81 | 81 | ||
82 | config USB_GADGET_VBUS_DRAW | ||
83 | int "Maximum VBUS Power usage (2-500 mA)" | ||
84 | range 2 500 | ||
85 | default 2 | ||
86 | help | ||
87 | Some devices need to draw power from USB when they are | ||
88 | configured, perhaps to operate circuitry or to recharge | ||
89 | batteries. This is in addition to any local power supply, | ||
90 | such as an AC adapter or batteries. | ||
91 | |||
92 | Enter the maximum power your device draws through USB, in | ||
93 | milliAmperes. The permitted range of values is 2 - 500 mA; | ||
94 | 0 mA would be legal, but can make some hosts misbehave. | ||
95 | |||
96 | This value will be used except for system-specific gadget | ||
97 | drivers that have more specific information. | ||
98 | |||
82 | config USB_GADGET_SELECTED | 99 | config USB_GADGET_SELECTED |
83 | boolean | 100 | boolean |
84 | 101 | ||
85 | # | 102 | # |
86 | # USB Peripheral Controller Support | 103 | # USB Peripheral Controller Support |
87 | # | 104 | # |
105 | # The order here is alphabetical, except that integrated controllers go | ||
106 | # before discrete ones so they will be the initial/default value: | ||
107 | # - integrated/SOC controllers first | ||
108 | # - licensed IP used in both SOC and discrete versions | ||
109 | # - discrete ones (including all PCI-only controllers) | ||
110 | # - debug/dummy gadget+hcd is last. | ||
111 | # | ||
88 | choice | 112 | choice |
89 | prompt "USB Peripheral Controller" | 113 | prompt "USB Peripheral Controller" |
90 | depends on USB_GADGET | 114 | depends on USB_GADGET |
@@ -94,26 +118,27 @@ choice | |||
94 | Many controller drivers are platform-specific; these | 118 | Many controller drivers are platform-specific; these |
95 | often need board-specific hooks. | 119 | often need board-specific hooks. |
96 | 120 | ||
97 | config USB_GADGET_AMD5536UDC | 121 | # |
98 | boolean "AMD5536 UDC" | 122 | # Integrated controllers |
99 | depends on PCI | 123 | # |
100 | select USB_GADGET_DUALSPEED | 124 | |
125 | config USB_GADGET_AT91 | ||
126 | boolean "Atmel AT91 USB Device Port" | ||
127 | depends on ARCH_AT91 && !ARCH_AT91SAM9RL && !ARCH_AT91CAP9 | ||
128 | select USB_GADGET_SELECTED | ||
101 | help | 129 | help |
102 | The AMD5536 UDC is part of the AMD Geode CS5536, an x86 southbridge. | 130 | Many Atmel AT91 processors (such as the AT91RM2000) have a |
103 | It is a USB Highspeed DMA capable USB device controller. Beside ep0 | 131 | full speed USB Device Port with support for five configurable |
104 | it provides 4 IN and 4 OUT endpoints (bulk or interrupt type). | 132 | endpoints (plus endpoint zero). |
105 | The UDC port supports OTG operation, and may be used as a host port | ||
106 | if it's not being used to implement peripheral or OTG roles. | ||
107 | 133 | ||
108 | Say "y" to link the driver statically, or "m" to build a | 134 | Say "y" to link the driver statically, or "m" to build a |
109 | dynamically linked module called "amd5536udc" and force all | 135 | dynamically linked module called "at91_udc" and force all |
110 | gadget drivers to also be dynamically linked. | 136 | gadget drivers to also be dynamically linked. |
111 | 137 | ||
112 | config USB_AMD5536UDC | 138 | config USB_AT91 |
113 | tristate | 139 | tristate |
114 | depends on USB_GADGET_AMD5536UDC | 140 | depends on USB_GADGET_AT91 |
115 | default USB_GADGET | 141 | default USB_GADGET |
116 | select USB_GADGET_SELECTED | ||
117 | 142 | ||
118 | config USB_GADGET_ATMEL_USBA | 143 | config USB_GADGET_ATMEL_USBA |
119 | boolean "Atmel USBA" | 144 | boolean "Atmel USBA" |
@@ -150,28 +175,50 @@ config USB_FSL_USB2 | |||
150 | default USB_GADGET | 175 | default USB_GADGET |
151 | select USB_GADGET_SELECTED | 176 | select USB_GADGET_SELECTED |
152 | 177 | ||
153 | config USB_GADGET_NET2280 | 178 | config USB_GADGET_LH7A40X |
154 | boolean "NetChip 228x" | 179 | boolean "LH7A40X" |
155 | depends on PCI | 180 | depends on ARCH_LH7A40X |
156 | select USB_GADGET_DUALSPEED | ||
157 | help | 181 | help |
158 | NetChip 2280 / 2282 is a PCI based USB peripheral controller which | 182 | This driver provides USB Device Controller driver for LH7A40x |
159 | supports both full and high speed USB 2.0 data transfers. | 183 | |
160 | 184 | config USB_LH7A40X | |
161 | It has six configurable endpoints, as well as endpoint zero | 185 | tristate |
162 | (for control transfers) and several endpoints with dedicated | 186 | depends on USB_GADGET_LH7A40X |
163 | functions. | 187 | default USB_GADGET |
188 | select USB_GADGET_SELECTED | ||
189 | |||
190 | config USB_GADGET_OMAP | ||
191 | boolean "OMAP USB Device Controller" | ||
192 | depends on ARCH_OMAP | ||
193 | select ISP1301_OMAP if MACH_OMAP_H2 || MACH_OMAP_H3 || MACH_OMAP_H4_OTG | ||
194 | help | ||
195 | Many Texas Instruments OMAP processors have flexible full | ||
196 | speed USB device controllers, with support for up to 30 | ||
197 | endpoints (plus endpoint zero). This driver supports the | ||
198 | controller in the OMAP 1611, and should work with controllers | ||
199 | in other OMAP processors too, given minor tweaks. | ||
164 | 200 | ||
165 | Say "y" to link the driver statically, or "m" to build a | 201 | Say "y" to link the driver statically, or "m" to build a |
166 | dynamically linked module called "net2280" and force all | 202 | dynamically linked module called "omap_udc" and force all |
167 | gadget drivers to also be dynamically linked. | 203 | gadget drivers to also be dynamically linked. |
168 | 204 | ||
169 | config USB_NET2280 | 205 | config USB_OMAP |
170 | tristate | 206 | tristate |
171 | depends on USB_GADGET_NET2280 | 207 | depends on USB_GADGET_OMAP |
172 | default USB_GADGET | 208 | default USB_GADGET |
173 | select USB_GADGET_SELECTED | 209 | select USB_GADGET_SELECTED |
174 | 210 | ||
211 | config USB_OTG | ||
212 | boolean "OTG Support" | ||
213 | depends on USB_GADGET_OMAP && ARCH_OMAP_OTG && USB_OHCI_HCD | ||
214 | help | ||
215 | The most notable feature of USB OTG is support for a | ||
216 | "Dual-Role" device, which can act as either a device | ||
217 | or a host. The initial role choice can be changed | ||
218 | later, when two dual-role devices talk to each other. | ||
219 | |||
220 | Select this only if your OMAP board has a Mini-AB connector. | ||
221 | |||
175 | config USB_GADGET_PXA25X | 222 | config USB_GADGET_PXA25X |
176 | boolean "PXA 25x or IXP 4xx" | 223 | boolean "PXA 25x or IXP 4xx" |
177 | depends on (ARCH_PXA && PXA25x) || ARCH_IXP4XX | 224 | depends on (ARCH_PXA && PXA25x) || ARCH_IXP4XX |
@@ -203,34 +250,6 @@ config USB_PXA25X_SMALL | |||
203 | default y if USB_ETH | 250 | default y if USB_ETH |
204 | default y if USB_G_SERIAL | 251 | default y if USB_G_SERIAL |
205 | 252 | ||
206 | config USB_GADGET_M66592 | ||
207 | boolean "Renesas M66592 USB Peripheral Controller" | ||
208 | select USB_GADGET_DUALSPEED | ||
209 | help | ||
210 | M66592 is a discrete USB peripheral controller chip that | ||
211 | supports both full and high speed USB 2.0 data transfers. | ||
212 | It has seven configurable endpoints, and endpoint zero. | ||
213 | |||
214 | Say "y" to link the driver statically, or "m" to build a | ||
215 | dynamically linked module called "m66592_udc" and force all | ||
216 | gadget drivers to also be dynamically linked. | ||
217 | |||
218 | config USB_M66592 | ||
219 | tristate | ||
220 | depends on USB_GADGET_M66592 | ||
221 | default USB_GADGET | ||
222 | select USB_GADGET_SELECTED | ||
223 | |||
224 | config SUPERH_BUILT_IN_M66592 | ||
225 | boolean "Enable SuperH built-in USB like the M66592" | ||
226 | depends on USB_GADGET_M66592 && CPU_SUBTYPE_SH7722 | ||
227 | help | ||
228 | SH7722 has USB like the M66592. | ||
229 | |||
230 | The transfer rate is very slow when use "Ethernet Gadget". | ||
231 | However, this problem is improved if change a value of | ||
232 | NET_IP_ALIGN to 4. | ||
233 | |||
234 | config USB_GADGET_PXA27X | 253 | config USB_GADGET_PXA27X |
235 | boolean "PXA 27x" | 254 | boolean "PXA 27x" |
236 | depends on ARCH_PXA && PXA27x | 255 | depends on ARCH_PXA && PXA27x |
@@ -251,40 +270,32 @@ config USB_PXA27X | |||
251 | default USB_GADGET | 270 | default USB_GADGET |
252 | select USB_GADGET_SELECTED | 271 | select USB_GADGET_SELECTED |
253 | 272 | ||
254 | config USB_GADGET_GOKU | 273 | config USB_GADGET_S3C2410 |
255 | boolean "Toshiba TC86C001 'Goku-S'" | 274 | boolean "S3C2410 USB Device Controller" |
256 | depends on PCI | 275 | depends on ARCH_S3C2410 |
257 | help | 276 | help |
258 | The Toshiba TC86C001 is a PCI device which includes controllers | 277 | Samsung's S3C2410 is an ARM-4 processor with an integrated |
259 | for full speed USB devices, IDE, I2C, SIO, plus a USB host (OHCI). | 278 | full speed USB 1.1 device controller. It has 4 configurable |
260 | 279 | endpoints, as well as endpoint zero (for control transfers). | |
261 | The device controller has three configurable (bulk or interrupt) | ||
262 | endpoints, plus endpoint zero (for control transfers). | ||
263 | 280 | ||
264 | Say "y" to link the driver statically, or "m" to build a | 281 | This driver has been tested on the S3C2410, S3C2412, and |
265 | dynamically linked module called "goku_udc" and to force all | 282 | S3C2440 processors. |
266 | gadget drivers to also be dynamically linked. | ||
267 | 283 | ||
268 | config USB_GOKU | 284 | config USB_S3C2410 |
269 | tristate | 285 | tristate |
270 | depends on USB_GADGET_GOKU | 286 | depends on USB_GADGET_S3C2410 |
271 | default USB_GADGET | 287 | default USB_GADGET |
272 | select USB_GADGET_SELECTED | 288 | select USB_GADGET_SELECTED |
273 | 289 | ||
290 | config USB_S3C2410_DEBUG | ||
291 | boolean "S3C2410 udc debug messages" | ||
292 | depends on USB_GADGET_S3C2410 | ||
274 | 293 | ||
275 | config USB_GADGET_LH7A40X | 294 | # |
276 | boolean "LH7A40X" | 295 | # Controllers available in both integrated and discrete versions |
277 | depends on ARCH_LH7A40X | 296 | # |
278 | help | ||
279 | This driver provides USB Device Controller driver for LH7A40x | ||
280 | |||
281 | config USB_LH7A40X | ||
282 | tristate | ||
283 | depends on USB_GADGET_LH7A40X | ||
284 | default USB_GADGET | ||
285 | select USB_GADGET_SELECTED | ||
286 | 297 | ||
287 | # built in ../musb along with host support | 298 | # musb builds in ../musb along with host support |
288 | config USB_GADGET_MUSB_HDRC | 299 | config USB_GADGET_MUSB_HDRC |
289 | boolean "Inventra HDRC USB Peripheral (TI, ...)" | 300 | boolean "Inventra HDRC USB Peripheral (TI, ...)" |
290 | depends on USB_MUSB_HDRC && (USB_MUSB_PERIPHERAL || USB_MUSB_OTG) | 301 | depends on USB_MUSB_HDRC && (USB_MUSB_PERIPHERAL || USB_MUSB_OTG) |
@@ -294,76 +305,124 @@ config USB_GADGET_MUSB_HDRC | |||
294 | This OTG-capable silicon IP is used in dual designs including | 305 | This OTG-capable silicon IP is used in dual designs including |
295 | the TI DaVinci, OMAP 243x, OMAP 343x, and TUSB 6010. | 306 | the TI DaVinci, OMAP 243x, OMAP 343x, and TUSB 6010. |
296 | 307 | ||
297 | config USB_GADGET_OMAP | 308 | config USB_GADGET_M66592 |
298 | boolean "OMAP USB Device Controller" | 309 | boolean "Renesas M66592 USB Peripheral Controller" |
299 | depends on ARCH_OMAP | 310 | select USB_GADGET_DUALSPEED |
300 | select ISP1301_OMAP if MACH_OMAP_H2 || MACH_OMAP_H3 | ||
301 | help | 311 | help |
302 | Many Texas Instruments OMAP processors have flexible full | 312 | M66592 is a discrete USB peripheral controller chip that |
303 | speed USB device controllers, with support for up to 30 | 313 | supports both full and high speed USB 2.0 data transfers. |
304 | endpoints (plus endpoint zero). This driver supports the | 314 | It has seven configurable endpoints, and endpoint zero. |
305 | controller in the OMAP 1611, and should work with controllers | ||
306 | in other OMAP processors too, given minor tweaks. | ||
307 | 315 | ||
308 | Say "y" to link the driver statically, or "m" to build a | 316 | Say "y" to link the driver statically, or "m" to build a |
309 | dynamically linked module called "omap_udc" and force all | 317 | dynamically linked module called "m66592_udc" and force all |
310 | gadget drivers to also be dynamically linked. | 318 | gadget drivers to also be dynamically linked. |
311 | 319 | ||
312 | config USB_OMAP | 320 | config USB_M66592 |
313 | tristate | 321 | tristate |
314 | depends on USB_GADGET_OMAP | 322 | depends on USB_GADGET_M66592 |
315 | default USB_GADGET | 323 | default USB_GADGET |
316 | select USB_GADGET_SELECTED | 324 | select USB_GADGET_SELECTED |
317 | 325 | ||
318 | config USB_OTG | 326 | config SUPERH_BUILT_IN_M66592 |
319 | boolean "OTG Support" | 327 | boolean "Enable SuperH built-in USB like the M66592" |
320 | depends on USB_GADGET_OMAP && ARCH_OMAP_OTG && USB_OHCI_HCD | 328 | depends on USB_GADGET_M66592 && CPU_SUBTYPE_SH7722 |
321 | help | 329 | help |
322 | The most notable feature of USB OTG is support for a | 330 | SH7722 has USB like the M66592. |
323 | "Dual-Role" device, which can act as either a device | ||
324 | or a host. The initial role choice can be changed | ||
325 | later, when two dual-role devices talk to each other. | ||
326 | 331 | ||
327 | Select this only if your OMAP board has a Mini-AB connector. | 332 | The transfer rate is very slow when use "Ethernet Gadget". |
333 | However, this problem is improved if change a value of | ||
334 | NET_IP_ALIGN to 4. | ||
328 | 335 | ||
329 | config USB_GADGET_S3C2410 | 336 | # |
330 | boolean "S3C2410 USB Device Controller" | 337 | # Controllers available only in discrete form (and all PCI controllers) |
331 | depends on ARCH_S3C2410 | 338 | # |
339 | |||
340 | config USB_GADGET_AMD5536UDC | ||
341 | boolean "AMD5536 UDC" | ||
342 | depends on PCI | ||
343 | select USB_GADGET_DUALSPEED | ||
332 | help | 344 | help |
333 | Samsung's S3C2410 is an ARM-4 processor with an integrated | 345 | The AMD5536 UDC is part of the AMD Geode CS5536, an x86 southbridge. |
334 | full speed USB 1.1 device controller. It has 4 configurable | 346 | It is a USB Highspeed DMA capable USB device controller. Beside ep0 |
335 | endpoints, as well as endpoint zero (for control transfers). | 347 | it provides 4 IN and 4 OUT endpoints (bulk or interrupt type). |
348 | The UDC port supports OTG operation, and may be used as a host port | ||
349 | if it's not being used to implement peripheral or OTG roles. | ||
336 | 350 | ||
337 | This driver has been tested on the S3C2410, S3C2412, and | 351 | Say "y" to link the driver statically, or "m" to build a |
338 | S3C2440 processors. | 352 | dynamically linked module called "amd5536udc" and force all |
353 | gadget drivers to also be dynamically linked. | ||
339 | 354 | ||
340 | config USB_S3C2410 | 355 | config USB_AMD5536UDC |
341 | tristate | 356 | tristate |
342 | depends on USB_GADGET_S3C2410 | 357 | depends on USB_GADGET_AMD5536UDC |
343 | default USB_GADGET | 358 | default USB_GADGET |
344 | select USB_GADGET_SELECTED | 359 | select USB_GADGET_SELECTED |
345 | 360 | ||
346 | config USB_S3C2410_DEBUG | 361 | config USB_GADGET_FSL_QE |
347 | boolean "S3C2410 udc debug messages" | 362 | boolean "Freescale QE/CPM USB Device Controller" |
348 | depends on USB_GADGET_S3C2410 | 363 | depends on FSL_SOC && (QUICC_ENGINE || CPM) |
364 | help | ||
365 | Some of Freescale PowerPC processors have a Full Speed | ||
366 | QE/CPM2 USB controller, which support device mode with 4 | ||
367 | programmable endpoints. This driver supports the | ||
368 | controller in the MPC8360 and MPC8272, and should work with | ||
369 | controllers having QE or CPM2, given minor tweaks. | ||
349 | 370 | ||
350 | config USB_GADGET_AT91 | 371 | Set CONFIG_USB_GADGET to "m" to build this driver as a |
351 | boolean "AT91 USB Device Port" | 372 | dynmically linked module called "fsl_qe_udc". |
352 | depends on ARCH_AT91 && !ARCH_AT91SAM9RL && !ARCH_AT91CAP9 | 373 | |
374 | config USB_FSL_QE | ||
375 | tristate | ||
376 | depends on USB_GADGET_FSL_QE | ||
377 | default USB_GADGET | ||
353 | select USB_GADGET_SELECTED | 378 | select USB_GADGET_SELECTED |
379 | |||
380 | config USB_GADGET_NET2280 | ||
381 | boolean "NetChip 228x" | ||
382 | depends on PCI | ||
383 | select USB_GADGET_DUALSPEED | ||
354 | help | 384 | help |
355 | Many Atmel AT91 processors (such as the AT91RM2000) have a | 385 | NetChip 2280 / 2282 is a PCI based USB peripheral controller which |
356 | full speed USB Device Port with support for five configurable | 386 | supports both full and high speed USB 2.0 data transfers. |
357 | endpoints (plus endpoint zero). | 387 | |
388 | It has six configurable endpoints, as well as endpoint zero | ||
389 | (for control transfers) and several endpoints with dedicated | ||
390 | functions. | ||
358 | 391 | ||
359 | Say "y" to link the driver statically, or "m" to build a | 392 | Say "y" to link the driver statically, or "m" to build a |
360 | dynamically linked module called "at91_udc" and force all | 393 | dynamically linked module called "net2280" and force all |
361 | gadget drivers to also be dynamically linked. | 394 | gadget drivers to also be dynamically linked. |
362 | 395 | ||
363 | config USB_AT91 | 396 | config USB_NET2280 |
364 | tristate | 397 | tristate |
365 | depends on USB_GADGET_AT91 | 398 | depends on USB_GADGET_NET2280 |
399 | default USB_GADGET | ||
400 | select USB_GADGET_SELECTED | ||
401 | |||
402 | config USB_GADGET_GOKU | ||
403 | boolean "Toshiba TC86C001 'Goku-S'" | ||
404 | depends on PCI | ||
405 | help | ||
406 | The Toshiba TC86C001 is a PCI device which includes controllers | ||
407 | for full speed USB devices, IDE, I2C, SIO, plus a USB host (OHCI). | ||
408 | |||
409 | The device controller has three configurable (bulk or interrupt) | ||
410 | endpoints, plus endpoint zero (for control transfers). | ||
411 | |||
412 | Say "y" to link the driver statically, or "m" to build a | ||
413 | dynamically linked module called "goku_udc" and to force all | ||
414 | gadget drivers to also be dynamically linked. | ||
415 | |||
416 | config USB_GOKU | ||
417 | tristate | ||
418 | depends on USB_GADGET_GOKU | ||
366 | default USB_GADGET | 419 | default USB_GADGET |
420 | select USB_GADGET_SELECTED | ||
421 | |||
422 | |||
423 | # | ||
424 | # LAST -- dummy/emulated controller | ||
425 | # | ||
367 | 426 | ||
368 | config USB_GADGET_DUMMY_HCD | 427 | config USB_GADGET_DUMMY_HCD |
369 | boolean "Dummy HCD (DEVELOPMENT)" | 428 | boolean "Dummy HCD (DEVELOPMENT)" |
@@ -553,19 +612,23 @@ config USB_FILE_STORAGE_TEST | |||
553 | normal operation. | 612 | normal operation. |
554 | 613 | ||
555 | config USB_G_SERIAL | 614 | config USB_G_SERIAL |
556 | tristate "Serial Gadget (with CDC ACM support)" | 615 | tristate "Serial Gadget (with CDC ACM and CDC OBEX support)" |
557 | help | 616 | help |
558 | The Serial Gadget talks to the Linux-USB generic serial driver. | 617 | The Serial Gadget talks to the Linux-USB generic serial driver. |
559 | This driver supports a CDC-ACM module option, which can be used | 618 | This driver supports a CDC-ACM module option, which can be used |
560 | to interoperate with MS-Windows hosts or with the Linux-USB | 619 | to interoperate with MS-Windows hosts or with the Linux-USB |
561 | "cdc-acm" driver. | 620 | "cdc-acm" driver. |
562 | 621 | ||
622 | This driver also supports a CDC-OBEX option. You will need a | ||
623 | user space OBEX server talking to /dev/ttyGS*, since the kernel | ||
624 | itself doesn't implement the OBEX protocol. | ||
625 | |||
563 | Say "y" to link the driver statically, or "m" to build a | 626 | Say "y" to link the driver statically, or "m" to build a |
564 | dynamically linked module called "g_serial". | 627 | dynamically linked module called "g_serial". |
565 | 628 | ||
566 | For more information, see Documentation/usb/gadget_serial.txt | 629 | For more information, see Documentation/usb/gadget_serial.txt |
567 | which includes instructions and a "driver info file" needed to | 630 | which includes instructions and a "driver info file" needed to |
568 | make MS-Windows work with this driver. | 631 | make MS-Windows work with CDC ACM. |
569 | 632 | ||
570 | config USB_MIDI_GADGET | 633 | config USB_MIDI_GADGET |
571 | tristate "MIDI Gadget (EXPERIMENTAL)" | 634 | tristate "MIDI Gadget (EXPERIMENTAL)" |
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile index fcb5cb9094d9..bd4041b47dce 100644 --- a/drivers/usb/gadget/Makefile +++ b/drivers/usb/gadget/Makefile | |||
@@ -18,28 +18,20 @@ obj-$(CONFIG_USB_AT91) += at91_udc.o | |||
18 | obj-$(CONFIG_USB_ATMEL_USBA) += atmel_usba_udc.o | 18 | obj-$(CONFIG_USB_ATMEL_USBA) += atmel_usba_udc.o |
19 | obj-$(CONFIG_USB_FSL_USB2) += fsl_usb2_udc.o | 19 | obj-$(CONFIG_USB_FSL_USB2) += fsl_usb2_udc.o |
20 | obj-$(CONFIG_USB_M66592) += m66592-udc.o | 20 | obj-$(CONFIG_USB_M66592) += m66592-udc.o |
21 | obj-$(CONFIG_USB_FSL_QE) += fsl_qe_udc.o | ||
21 | 22 | ||
22 | # | 23 | # |
23 | # USB gadget drivers | 24 | # USB gadget drivers |
24 | # | 25 | # |
25 | C_UTILS = composite.o usbstring.o config.o epautoconf.o | 26 | g_zero-objs := zero.o |
26 | 27 | g_ether-objs := ether.o | |
27 | g_zero-objs := zero.o f_sourcesink.o f_loopback.o $(C_UTILS) | 28 | g_serial-objs := serial.o |
28 | g_ether-objs := ether.o u_ether.o f_subset.o f_ecm.o $(C_UTILS) | 29 | g_midi-objs := gmidi.o |
29 | g_serial-objs := serial.o u_serial.o f_acm.o f_serial.o $(C_UTILS) | ||
30 | g_midi-objs := gmidi.o usbstring.o config.o epautoconf.o | ||
31 | gadgetfs-objs := inode.o | 30 | gadgetfs-objs := inode.o |
32 | g_file_storage-objs := file_storage.o usbstring.o config.o \ | 31 | g_file_storage-objs := file_storage.o |
33 | epautoconf.o | 32 | g_printer-objs := printer.o |
34 | g_printer-objs := printer.o usbstring.o config.o \ | 33 | g_cdc-objs := cdc2.o |
35 | epautoconf.o | ||
36 | g_cdc-objs := cdc2.o u_ether.o f_ecm.o \ | ||
37 | u_serial.o f_acm.o $(C_UTILS) | ||
38 | 34 | ||
39 | ifeq ($(CONFIG_USB_ETH_RNDIS),y) | ||
40 | g_ether-objs += f_rndis.o rndis.o | ||
41 | endif | ||
42 | |||
43 | obj-$(CONFIG_USB_ZERO) += g_zero.o | 35 | obj-$(CONFIG_USB_ZERO) += g_zero.o |
44 | obj-$(CONFIG_USB_ETH) += g_ether.o | 36 | obj-$(CONFIG_USB_ETH) += g_ether.o |
45 | obj-$(CONFIG_USB_GADGETFS) += gadgetfs.o | 37 | obj-$(CONFIG_USB_GADGETFS) += gadgetfs.o |
diff --git a/drivers/usb/gadget/amd5536udc.c b/drivers/usb/gadget/amd5536udc.c index 1500e1b3c302..abf8192f89e8 100644 --- a/drivers/usb/gadget/amd5536udc.c +++ b/drivers/usb/gadget/amd5536udc.c | |||
@@ -44,7 +44,6 @@ | |||
44 | #include <linux/module.h> | 44 | #include <linux/module.h> |
45 | #include <linux/pci.h> | 45 | #include <linux/pci.h> |
46 | #include <linux/kernel.h> | 46 | #include <linux/kernel.h> |
47 | #include <linux/version.h> | ||
48 | #include <linux/delay.h> | 47 | #include <linux/delay.h> |
49 | #include <linux/ioport.h> | 48 | #include <linux/ioport.h> |
50 | #include <linux/sched.h> | 49 | #include <linux/sched.h> |
diff --git a/drivers/usb/gadget/cdc2.c b/drivers/usb/gadget/cdc2.c index a39a4b940c33..5495b171cf29 100644 --- a/drivers/usb/gadget/cdc2.c +++ b/drivers/usb/gadget/cdc2.c | |||
@@ -43,6 +43,25 @@ | |||
43 | 43 | ||
44 | /*-------------------------------------------------------------------------*/ | 44 | /*-------------------------------------------------------------------------*/ |
45 | 45 | ||
46 | /* | ||
47 | * Kbuild is not very cooperative with respect to linking separately | ||
48 | * compiled library objects into one module. So for now we won't use | ||
49 | * separate compilation ... ensuring init/exit sections work to shrink | ||
50 | * the runtime footprint, and giving us at least some parts of what | ||
51 | * a "gcc --combine ... part1.c part2.c part3.c ... " build would. | ||
52 | */ | ||
53 | |||
54 | #include "composite.c" | ||
55 | #include "usbstring.c" | ||
56 | #include "config.c" | ||
57 | #include "epautoconf.c" | ||
58 | #include "u_serial.c" | ||
59 | #include "f_acm.c" | ||
60 | #include "f_ecm.c" | ||
61 | #include "u_ether.c" | ||
62 | |||
63 | /*-------------------------------------------------------------------------*/ | ||
64 | |||
46 | static struct usb_device_descriptor device_desc = { | 65 | static struct usb_device_descriptor device_desc = { |
47 | .bLength = sizeof device_desc, | 66 | .bLength = sizeof device_desc, |
48 | .bDescriptorType = USB_DT_DEVICE, | 67 | .bDescriptorType = USB_DT_DEVICE, |
@@ -136,7 +155,6 @@ static struct usb_configuration cdc_config_driver = { | |||
136 | .bConfigurationValue = 1, | 155 | .bConfigurationValue = 1, |
137 | /* .iConfiguration = DYNAMIC */ | 156 | /* .iConfiguration = DYNAMIC */ |
138 | .bmAttributes = USB_CONFIG_ATT_SELFPOWER, | 157 | .bmAttributes = USB_CONFIG_ATT_SELFPOWER, |
139 | .bMaxPower = 1, /* 2 mA, minimal */ | ||
140 | }; | 158 | }; |
141 | 159 | ||
142 | /*-------------------------------------------------------------------------*/ | 160 | /*-------------------------------------------------------------------------*/ |
@@ -148,7 +166,8 @@ static int __init cdc_bind(struct usb_composite_dev *cdev) | |||
148 | int status; | 166 | int status; |
149 | 167 | ||
150 | if (!can_support_ecm(cdev->gadget)) { | 168 | if (!can_support_ecm(cdev->gadget)) { |
151 | ERROR(cdev, "controller '%s' not usable\n", gadget->name); | 169 | dev_err(&gadget->dev, "controller '%s' not usable\n", |
170 | gadget->name); | ||
152 | return -EINVAL; | 171 | return -EINVAL; |
153 | } | 172 | } |
154 | 173 | ||
@@ -203,7 +222,8 @@ static int __init cdc_bind(struct usb_composite_dev *cdev) | |||
203 | if (status < 0) | 222 | if (status < 0) |
204 | goto fail1; | 223 | goto fail1; |
205 | 224 | ||
206 | INFO(cdev, "%s, version: " DRIVER_VERSION "\n", DRIVER_DESC); | 225 | dev_info(&gadget->dev, "%s, version: " DRIVER_VERSION "\n", |
226 | DRIVER_DESC); | ||
207 | 227 | ||
208 | return 0; | 228 | return 0; |
209 | 229 | ||
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 85c876c1f150..f2da0269e1b1 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c | |||
@@ -128,6 +128,70 @@ done: | |||
128 | } | 128 | } |
129 | 129 | ||
130 | /** | 130 | /** |
131 | * usb_function_deactivate - prevent function and gadget enumeration | ||
132 | * @function: the function that isn't yet ready to respond | ||
133 | * | ||
134 | * Blocks response of the gadget driver to host enumeration by | ||
135 | * preventing the data line pullup from being activated. This is | ||
136 | * normally called during @bind() processing to change from the | ||
137 | * initial "ready to respond" state, or when a required resource | ||
138 | * becomes available. | ||
139 | * | ||
140 | * For example, drivers that serve as a passthrough to a userspace | ||
141 | * daemon can block enumeration unless that daemon (such as an OBEX, | ||
142 | * MTP, or print server) is ready to handle host requests. | ||
143 | * | ||
144 | * Not all systems support software control of their USB peripheral | ||
145 | * data pullups. | ||
146 | * | ||
147 | * Returns zero on success, else negative errno. | ||
148 | */ | ||
149 | int usb_function_deactivate(struct usb_function *function) | ||
150 | { | ||
151 | struct usb_composite_dev *cdev = function->config->cdev; | ||
152 | int status = 0; | ||
153 | |||
154 | spin_lock(&cdev->lock); | ||
155 | |||
156 | if (cdev->deactivations == 0) | ||
157 | status = usb_gadget_disconnect(cdev->gadget); | ||
158 | if (status == 0) | ||
159 | cdev->deactivations++; | ||
160 | |||
161 | spin_unlock(&cdev->lock); | ||
162 | return status; | ||
163 | } | ||
164 | |||
165 | /** | ||
166 | * usb_function_activate - allow function and gadget enumeration | ||
167 | * @function: function on which usb_function_activate() was called | ||
168 | * | ||
169 | * Reverses effect of usb_function_deactivate(). If no more functions | ||
170 | * are delaying their activation, the gadget driver will respond to | ||
171 | * host enumeration procedures. | ||
172 | * | ||
173 | * Returns zero on success, else negative errno. | ||
174 | */ | ||
175 | int usb_function_activate(struct usb_function *function) | ||
176 | { | ||
177 | struct usb_composite_dev *cdev = function->config->cdev; | ||
178 | int status = 0; | ||
179 | |||
180 | spin_lock(&cdev->lock); | ||
181 | |||
182 | if (WARN_ON(cdev->deactivations == 0)) | ||
183 | status = -EINVAL; | ||
184 | else { | ||
185 | cdev->deactivations--; | ||
186 | if (cdev->deactivations == 0) | ||
187 | status = usb_gadget_connect(cdev->gadget); | ||
188 | } | ||
189 | |||
190 | spin_unlock(&cdev->lock); | ||
191 | return status; | ||
192 | } | ||
193 | |||
194 | /** | ||
131 | * usb_interface_id() - allocate an unused interface ID | 195 | * usb_interface_id() - allocate an unused interface ID |
132 | * @config: configuration associated with the interface | 196 | * @config: configuration associated with the interface |
133 | * @function: function handling the interface | 197 | * @function: function handling the interface |
@@ -181,7 +245,7 @@ static int config_buf(struct usb_configuration *config, | |||
181 | c->bConfigurationValue = config->bConfigurationValue; | 245 | c->bConfigurationValue = config->bConfigurationValue; |
182 | c->iConfiguration = config->iConfiguration; | 246 | c->iConfiguration = config->iConfiguration; |
183 | c->bmAttributes = USB_CONFIG_ATT_ONE | config->bmAttributes; | 247 | c->bmAttributes = USB_CONFIG_ATT_ONE | config->bmAttributes; |
184 | c->bMaxPower = config->bMaxPower; | 248 | c->bMaxPower = config->bMaxPower ? : (CONFIG_USB_GADGET_VBUS_DRAW / 2); |
185 | 249 | ||
186 | /* There may be e.g. OTG descriptors */ | 250 | /* There may be e.g. OTG descriptors */ |
187 | if (config->descriptors) { | 251 | if (config->descriptors) { |
@@ -368,7 +432,7 @@ static int set_config(struct usb_composite_dev *cdev, | |||
368 | } | 432 | } |
369 | 433 | ||
370 | /* when we return, be sure our power usage is valid */ | 434 | /* when we return, be sure our power usage is valid */ |
371 | power = 2 * c->bMaxPower; | 435 | power = c->bMaxPower ? (2 * c->bMaxPower) : CONFIG_USB_GADGET_VBUS_DRAW; |
372 | done: | 436 | done: |
373 | usb_gadget_vbus_draw(gadget, power); | 437 | usb_gadget_vbus_draw(gadget, power); |
374 | return result; | 438 | return result; |
diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c index 7600a0c78753..9064696636ac 100644 --- a/drivers/usb/gadget/dummy_hcd.c +++ b/drivers/usb/gadget/dummy_hcd.c | |||
@@ -82,6 +82,7 @@ struct dummy_ep { | |||
82 | const struct usb_endpoint_descriptor *desc; | 82 | const struct usb_endpoint_descriptor *desc; |
83 | struct usb_ep ep; | 83 | struct usb_ep ep; |
84 | unsigned halted : 1; | 84 | unsigned halted : 1; |
85 | unsigned wedged : 1; | ||
85 | unsigned already_seen : 1; | 86 | unsigned already_seen : 1; |
86 | unsigned setup_stage : 1; | 87 | unsigned setup_stage : 1; |
87 | }; | 88 | }; |
@@ -436,6 +437,7 @@ dummy_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc) | |||
436 | /* at this point real hardware should be NAKing transfers | 437 | /* at this point real hardware should be NAKing transfers |
437 | * to that endpoint, until a buffer is queued to it. | 438 | * to that endpoint, until a buffer is queued to it. |
438 | */ | 439 | */ |
440 | ep->halted = ep->wedged = 0; | ||
439 | retval = 0; | 441 | retval = 0; |
440 | done: | 442 | done: |
441 | return retval; | 443 | return retval; |
@@ -597,7 +599,7 @@ static int dummy_dequeue (struct usb_ep *_ep, struct usb_request *_req) | |||
597 | } | 599 | } |
598 | 600 | ||
599 | static int | 601 | static int |
600 | dummy_set_halt (struct usb_ep *_ep, int value) | 602 | dummy_set_halt_and_wedge(struct usb_ep *_ep, int value, int wedged) |
601 | { | 603 | { |
602 | struct dummy_ep *ep; | 604 | struct dummy_ep *ep; |
603 | struct dummy *dum; | 605 | struct dummy *dum; |
@@ -609,16 +611,32 @@ dummy_set_halt (struct usb_ep *_ep, int value) | |||
609 | if (!dum->driver) | 611 | if (!dum->driver) |
610 | return -ESHUTDOWN; | 612 | return -ESHUTDOWN; |
611 | if (!value) | 613 | if (!value) |
612 | ep->halted = 0; | 614 | ep->halted = ep->wedged = 0; |
613 | else if (ep->desc && (ep->desc->bEndpointAddress & USB_DIR_IN) && | 615 | else if (ep->desc && (ep->desc->bEndpointAddress & USB_DIR_IN) && |
614 | !list_empty (&ep->queue)) | 616 | !list_empty (&ep->queue)) |
615 | return -EAGAIN; | 617 | return -EAGAIN; |
616 | else | 618 | else { |
617 | ep->halted = 1; | 619 | ep->halted = 1; |
620 | if (wedged) | ||
621 | ep->wedged = 1; | ||
622 | } | ||
618 | /* FIXME clear emulated data toggle too */ | 623 | /* FIXME clear emulated data toggle too */ |
619 | return 0; | 624 | return 0; |
620 | } | 625 | } |
621 | 626 | ||
627 | static int | ||
628 | dummy_set_halt(struct usb_ep *_ep, int value) | ||
629 | { | ||
630 | return dummy_set_halt_and_wedge(_ep, value, 0); | ||
631 | } | ||
632 | |||
633 | static int dummy_set_wedge(struct usb_ep *_ep) | ||
634 | { | ||
635 | if (!_ep || _ep->name == ep0name) | ||
636 | return -EINVAL; | ||
637 | return dummy_set_halt_and_wedge(_ep, 1, 1); | ||
638 | } | ||
639 | |||
622 | static const struct usb_ep_ops dummy_ep_ops = { | 640 | static const struct usb_ep_ops dummy_ep_ops = { |
623 | .enable = dummy_enable, | 641 | .enable = dummy_enable, |
624 | .disable = dummy_disable, | 642 | .disable = dummy_disable, |
@@ -630,6 +648,7 @@ static const struct usb_ep_ops dummy_ep_ops = { | |||
630 | .dequeue = dummy_dequeue, | 648 | .dequeue = dummy_dequeue, |
631 | 649 | ||
632 | .set_halt = dummy_set_halt, | 650 | .set_halt = dummy_set_halt, |
651 | .set_wedge = dummy_set_wedge, | ||
633 | }; | 652 | }; |
634 | 653 | ||
635 | /*-------------------------------------------------------------------------*/ | 654 | /*-------------------------------------------------------------------------*/ |
@@ -760,7 +779,8 @@ usb_gadget_register_driver (struct usb_gadget_driver *driver) | |||
760 | ep->ep.name = ep_name [i]; | 779 | ep->ep.name = ep_name [i]; |
761 | ep->ep.ops = &dummy_ep_ops; | 780 | ep->ep.ops = &dummy_ep_ops; |
762 | list_add_tail (&ep->ep.ep_list, &dum->gadget.ep_list); | 781 | list_add_tail (&ep->ep.ep_list, &dum->gadget.ep_list); |
763 | ep->halted = ep->already_seen = ep->setup_stage = 0; | 782 | ep->halted = ep->wedged = ep->already_seen = |
783 | ep->setup_stage = 0; | ||
764 | ep->ep.maxpacket = ~0; | 784 | ep->ep.maxpacket = ~0; |
765 | ep->last_io = jiffies; | 785 | ep->last_io = jiffies; |
766 | ep->gadget = &dum->gadget; | 786 | ep->gadget = &dum->gadget; |
@@ -1351,7 +1371,7 @@ restart: | |||
1351 | } else if (setup.bRequestType == Ep_Request) { | 1371 | } else if (setup.bRequestType == Ep_Request) { |
1352 | // endpoint halt | 1372 | // endpoint halt |
1353 | ep2 = find_endpoint (dum, w_index); | 1373 | ep2 = find_endpoint (dum, w_index); |
1354 | if (!ep2) { | 1374 | if (!ep2 || ep2->ep.name == ep0name) { |
1355 | value = -EOPNOTSUPP; | 1375 | value = -EOPNOTSUPP; |
1356 | break; | 1376 | break; |
1357 | } | 1377 | } |
@@ -1380,7 +1400,8 @@ restart: | |||
1380 | value = -EOPNOTSUPP; | 1400 | value = -EOPNOTSUPP; |
1381 | break; | 1401 | break; |
1382 | } | 1402 | } |
1383 | ep2->halted = 0; | 1403 | if (!ep2->wedged) |
1404 | ep2->halted = 0; | ||
1384 | value = 0; | 1405 | value = 0; |
1385 | status = 0; | 1406 | status = 0; |
1386 | } | 1407 | } |
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c index bcac2e68660d..37252d0012a7 100644 --- a/drivers/usb/gadget/ether.c +++ b/drivers/usb/gadget/ether.c | |||
@@ -96,6 +96,28 @@ static inline bool has_rndis(void) | |||
96 | 96 | ||
97 | /*-------------------------------------------------------------------------*/ | 97 | /*-------------------------------------------------------------------------*/ |
98 | 98 | ||
99 | /* | ||
100 | * Kbuild is not very cooperative with respect to linking separately | ||
101 | * compiled library objects into one module. So for now we won't use | ||
102 | * separate compilation ... ensuring init/exit sections work to shrink | ||
103 | * the runtime footprint, and giving us at least some parts of what | ||
104 | * a "gcc --combine ... part1.c part2.c part3.c ... " build would. | ||
105 | */ | ||
106 | #include "composite.c" | ||
107 | #include "usbstring.c" | ||
108 | #include "config.c" | ||
109 | #include "epautoconf.c" | ||
110 | |||
111 | #include "f_ecm.c" | ||
112 | #include "f_subset.c" | ||
113 | #ifdef CONFIG_USB_ETH_RNDIS | ||
114 | #include "f_rndis.c" | ||
115 | #include "rndis.c" | ||
116 | #endif | ||
117 | #include "u_ether.c" | ||
118 | |||
119 | /*-------------------------------------------------------------------------*/ | ||
120 | |||
99 | /* DO NOT REUSE THESE IDs with a protocol-incompatible driver!! Ever!! | 121 | /* DO NOT REUSE THESE IDs with a protocol-incompatible driver!! Ever!! |
100 | * Instead: allocate your own, using normal USB-IF procedures. | 122 | * Instead: allocate your own, using normal USB-IF procedures. |
101 | */ | 123 | */ |
@@ -220,7 +242,6 @@ static struct usb_configuration rndis_config_driver = { | |||
220 | .bConfigurationValue = 2, | 242 | .bConfigurationValue = 2, |
221 | /* .iConfiguration = DYNAMIC */ | 243 | /* .iConfiguration = DYNAMIC */ |
222 | .bmAttributes = USB_CONFIG_ATT_SELFPOWER, | 244 | .bmAttributes = USB_CONFIG_ATT_SELFPOWER, |
223 | .bMaxPower = 1, /* 2 mA, minimal */ | ||
224 | }; | 245 | }; |
225 | 246 | ||
226 | /*-------------------------------------------------------------------------*/ | 247 | /*-------------------------------------------------------------------------*/ |
@@ -249,7 +270,6 @@ static struct usb_configuration eth_config_driver = { | |||
249 | .bConfigurationValue = 1, | 270 | .bConfigurationValue = 1, |
250 | /* .iConfiguration = DYNAMIC */ | 271 | /* .iConfiguration = DYNAMIC */ |
251 | .bmAttributes = USB_CONFIG_ATT_SELFPOWER, | 272 | .bmAttributes = USB_CONFIG_ATT_SELFPOWER, |
252 | .bMaxPower = 1, /* 2 mA, minimal */ | ||
253 | }; | 273 | }; |
254 | 274 | ||
255 | /*-------------------------------------------------------------------------*/ | 275 | /*-------------------------------------------------------------------------*/ |
@@ -293,7 +313,8 @@ static int __init eth_bind(struct usb_composite_dev *cdev) | |||
293 | * but if the controller isn't recognized at all then | 313 | * but if the controller isn't recognized at all then |
294 | * that assumption is a bit more likely to be wrong. | 314 | * that assumption is a bit more likely to be wrong. |
295 | */ | 315 | */ |
296 | WARNING(cdev, "controller '%s' not recognized; trying %s\n", | 316 | dev_warn(&gadget->dev, |
317 | "controller '%s' not recognized; trying %s\n", | ||
297 | gadget->name, | 318 | gadget->name, |
298 | eth_config_driver.label); | 319 | eth_config_driver.label); |
299 | device_desc.bcdDevice = | 320 | device_desc.bcdDevice = |
@@ -332,7 +353,8 @@ static int __init eth_bind(struct usb_composite_dev *cdev) | |||
332 | if (status < 0) | 353 | if (status < 0) |
333 | goto fail; | 354 | goto fail; |
334 | 355 | ||
335 | INFO(cdev, "%s, version: " DRIVER_VERSION "\n", DRIVER_DESC); | 356 | dev_info(&gadget->dev, "%s, version: " DRIVER_VERSION "\n", |
357 | DRIVER_DESC); | ||
336 | 358 | ||
337 | return 0; | 359 | return 0; |
338 | 360 | ||
diff --git a/drivers/usb/gadget/f_ecm.c b/drivers/usb/gadget/f_ecm.c index a2b5c092bda0..4ae579948e54 100644 --- a/drivers/usb/gadget/f_ecm.c +++ b/drivers/usb/gadget/f_ecm.c | |||
@@ -83,7 +83,7 @@ static inline struct f_ecm *func_to_ecm(struct usb_function *f) | |||
83 | } | 83 | } |
84 | 84 | ||
85 | /* peak (theoretical) bulk transfer rate in bits-per-second */ | 85 | /* peak (theoretical) bulk transfer rate in bits-per-second */ |
86 | static inline unsigned bitrate(struct usb_gadget *g) | 86 | static inline unsigned ecm_bitrate(struct usb_gadget *g) |
87 | { | 87 | { |
88 | if (gadget_is_dualspeed(g) && g->speed == USB_SPEED_HIGH) | 88 | if (gadget_is_dualspeed(g) && g->speed == USB_SPEED_HIGH) |
89 | return 13 * 512 * 8 * 1000 * 8; | 89 | return 13 * 512 * 8 * 1000 * 8; |
@@ -107,7 +107,7 @@ static inline unsigned bitrate(struct usb_gadget *g) | |||
107 | */ | 107 | */ |
108 | 108 | ||
109 | #define LOG2_STATUS_INTERVAL_MSEC 5 /* 1 << 5 == 32 msec */ | 109 | #define LOG2_STATUS_INTERVAL_MSEC 5 /* 1 << 5 == 32 msec */ |
110 | #define STATUS_BYTECOUNT 16 /* 8 byte header + data */ | 110 | #define ECM_STATUS_BYTECOUNT 16 /* 8 byte header + data */ |
111 | 111 | ||
112 | 112 | ||
113 | /* interface descriptor: */ | 113 | /* interface descriptor: */ |
@@ -125,8 +125,8 @@ static struct usb_interface_descriptor ecm_control_intf __initdata = { | |||
125 | /* .iInterface = DYNAMIC */ | 125 | /* .iInterface = DYNAMIC */ |
126 | }; | 126 | }; |
127 | 127 | ||
128 | static struct usb_cdc_header_desc header_desc __initdata = { | 128 | static struct usb_cdc_header_desc ecm_header_desc __initdata = { |
129 | .bLength = sizeof header_desc, | 129 | .bLength = sizeof ecm_header_desc, |
130 | .bDescriptorType = USB_DT_CS_INTERFACE, | 130 | .bDescriptorType = USB_DT_CS_INTERFACE, |
131 | .bDescriptorSubType = USB_CDC_HEADER_TYPE, | 131 | .bDescriptorSubType = USB_CDC_HEADER_TYPE, |
132 | 132 | ||
@@ -141,8 +141,8 @@ static struct usb_cdc_union_desc ecm_union_desc __initdata = { | |||
141 | /* .bSlaveInterface0 = DYNAMIC */ | 141 | /* .bSlaveInterface0 = DYNAMIC */ |
142 | }; | 142 | }; |
143 | 143 | ||
144 | static struct usb_cdc_ether_desc ether_desc __initdata = { | 144 | static struct usb_cdc_ether_desc ecm_desc __initdata = { |
145 | .bLength = sizeof ether_desc, | 145 | .bLength = sizeof ecm_desc, |
146 | .bDescriptorType = USB_DT_CS_INTERFACE, | 146 | .bDescriptorType = USB_DT_CS_INTERFACE, |
147 | .bDescriptorSubType = USB_CDC_ETHERNET_TYPE, | 147 | .bDescriptorSubType = USB_CDC_ETHERNET_TYPE, |
148 | 148 | ||
@@ -186,17 +186,17 @@ static struct usb_interface_descriptor ecm_data_intf __initdata = { | |||
186 | 186 | ||
187 | /* full speed support: */ | 187 | /* full speed support: */ |
188 | 188 | ||
189 | static struct usb_endpoint_descriptor fs_notify_desc __initdata = { | 189 | static struct usb_endpoint_descriptor fs_ecm_notify_desc __initdata = { |
190 | .bLength = USB_DT_ENDPOINT_SIZE, | 190 | .bLength = USB_DT_ENDPOINT_SIZE, |
191 | .bDescriptorType = USB_DT_ENDPOINT, | 191 | .bDescriptorType = USB_DT_ENDPOINT, |
192 | 192 | ||
193 | .bEndpointAddress = USB_DIR_IN, | 193 | .bEndpointAddress = USB_DIR_IN, |
194 | .bmAttributes = USB_ENDPOINT_XFER_INT, | 194 | .bmAttributes = USB_ENDPOINT_XFER_INT, |
195 | .wMaxPacketSize = __constant_cpu_to_le16(STATUS_BYTECOUNT), | 195 | .wMaxPacketSize = __constant_cpu_to_le16(ECM_STATUS_BYTECOUNT), |
196 | .bInterval = 1 << LOG2_STATUS_INTERVAL_MSEC, | 196 | .bInterval = 1 << LOG2_STATUS_INTERVAL_MSEC, |
197 | }; | 197 | }; |
198 | 198 | ||
199 | static struct usb_endpoint_descriptor fs_in_desc __initdata = { | 199 | static struct usb_endpoint_descriptor fs_ecm_in_desc __initdata = { |
200 | .bLength = USB_DT_ENDPOINT_SIZE, | 200 | .bLength = USB_DT_ENDPOINT_SIZE, |
201 | .bDescriptorType = USB_DT_ENDPOINT, | 201 | .bDescriptorType = USB_DT_ENDPOINT, |
202 | 202 | ||
@@ -204,7 +204,7 @@ static struct usb_endpoint_descriptor fs_in_desc __initdata = { | |||
204 | .bmAttributes = USB_ENDPOINT_XFER_BULK, | 204 | .bmAttributes = USB_ENDPOINT_XFER_BULK, |
205 | }; | 205 | }; |
206 | 206 | ||
207 | static struct usb_endpoint_descriptor fs_out_desc __initdata = { | 207 | static struct usb_endpoint_descriptor fs_ecm_out_desc __initdata = { |
208 | .bLength = USB_DT_ENDPOINT_SIZE, | 208 | .bLength = USB_DT_ENDPOINT_SIZE, |
209 | .bDescriptorType = USB_DT_ENDPOINT, | 209 | .bDescriptorType = USB_DT_ENDPOINT, |
210 | 210 | ||
@@ -212,34 +212,34 @@ static struct usb_endpoint_descriptor fs_out_desc __initdata = { | |||
212 | .bmAttributes = USB_ENDPOINT_XFER_BULK, | 212 | .bmAttributes = USB_ENDPOINT_XFER_BULK, |
213 | }; | 213 | }; |
214 | 214 | ||
215 | static struct usb_descriptor_header *eth_fs_function[] __initdata = { | 215 | static struct usb_descriptor_header *ecm_fs_function[] __initdata = { |
216 | /* CDC ECM control descriptors */ | 216 | /* CDC ECM control descriptors */ |
217 | (struct usb_descriptor_header *) &ecm_control_intf, | 217 | (struct usb_descriptor_header *) &ecm_control_intf, |
218 | (struct usb_descriptor_header *) &header_desc, | 218 | (struct usb_descriptor_header *) &ecm_header_desc, |
219 | (struct usb_descriptor_header *) &ecm_union_desc, | 219 | (struct usb_descriptor_header *) &ecm_union_desc, |
220 | (struct usb_descriptor_header *) ðer_desc, | 220 | (struct usb_descriptor_header *) &ecm_desc, |
221 | /* NOTE: status endpoint might need to be removed */ | 221 | /* NOTE: status endpoint might need to be removed */ |
222 | (struct usb_descriptor_header *) &fs_notify_desc, | 222 | (struct usb_descriptor_header *) &fs_ecm_notify_desc, |
223 | /* data interface, altsettings 0 and 1 */ | 223 | /* data interface, altsettings 0 and 1 */ |
224 | (struct usb_descriptor_header *) &ecm_data_nop_intf, | 224 | (struct usb_descriptor_header *) &ecm_data_nop_intf, |
225 | (struct usb_descriptor_header *) &ecm_data_intf, | 225 | (struct usb_descriptor_header *) &ecm_data_intf, |
226 | (struct usb_descriptor_header *) &fs_in_desc, | 226 | (struct usb_descriptor_header *) &fs_ecm_in_desc, |
227 | (struct usb_descriptor_header *) &fs_out_desc, | 227 | (struct usb_descriptor_header *) &fs_ecm_out_desc, |
228 | NULL, | 228 | NULL, |
229 | }; | 229 | }; |
230 | 230 | ||
231 | /* high speed support: */ | 231 | /* high speed support: */ |
232 | 232 | ||
233 | static struct usb_endpoint_descriptor hs_notify_desc __initdata = { | 233 | static struct usb_endpoint_descriptor hs_ecm_notify_desc __initdata = { |
234 | .bLength = USB_DT_ENDPOINT_SIZE, | 234 | .bLength = USB_DT_ENDPOINT_SIZE, |
235 | .bDescriptorType = USB_DT_ENDPOINT, | 235 | .bDescriptorType = USB_DT_ENDPOINT, |
236 | 236 | ||
237 | .bEndpointAddress = USB_DIR_IN, | 237 | .bEndpointAddress = USB_DIR_IN, |
238 | .bmAttributes = USB_ENDPOINT_XFER_INT, | 238 | .bmAttributes = USB_ENDPOINT_XFER_INT, |
239 | .wMaxPacketSize = __constant_cpu_to_le16(STATUS_BYTECOUNT), | 239 | .wMaxPacketSize = __constant_cpu_to_le16(ECM_STATUS_BYTECOUNT), |
240 | .bInterval = LOG2_STATUS_INTERVAL_MSEC + 4, | 240 | .bInterval = LOG2_STATUS_INTERVAL_MSEC + 4, |
241 | }; | 241 | }; |
242 | static struct usb_endpoint_descriptor hs_in_desc __initdata = { | 242 | static struct usb_endpoint_descriptor hs_ecm_in_desc __initdata = { |
243 | .bLength = USB_DT_ENDPOINT_SIZE, | 243 | .bLength = USB_DT_ENDPOINT_SIZE, |
244 | .bDescriptorType = USB_DT_ENDPOINT, | 244 | .bDescriptorType = USB_DT_ENDPOINT, |
245 | 245 | ||
@@ -248,7 +248,7 @@ static struct usb_endpoint_descriptor hs_in_desc __initdata = { | |||
248 | .wMaxPacketSize = __constant_cpu_to_le16(512), | 248 | .wMaxPacketSize = __constant_cpu_to_le16(512), |
249 | }; | 249 | }; |
250 | 250 | ||
251 | static struct usb_endpoint_descriptor hs_out_desc __initdata = { | 251 | static struct usb_endpoint_descriptor hs_ecm_out_desc __initdata = { |
252 | .bLength = USB_DT_ENDPOINT_SIZE, | 252 | .bLength = USB_DT_ENDPOINT_SIZE, |
253 | .bDescriptorType = USB_DT_ENDPOINT, | 253 | .bDescriptorType = USB_DT_ENDPOINT, |
254 | 254 | ||
@@ -257,19 +257,19 @@ static struct usb_endpoint_descriptor hs_out_desc __initdata = { | |||
257 | .wMaxPacketSize = __constant_cpu_to_le16(512), | 257 | .wMaxPacketSize = __constant_cpu_to_le16(512), |
258 | }; | 258 | }; |
259 | 259 | ||
260 | static struct usb_descriptor_header *eth_hs_function[] __initdata = { | 260 | static struct usb_descriptor_header *ecm_hs_function[] __initdata = { |
261 | /* CDC ECM control descriptors */ | 261 | /* CDC ECM control descriptors */ |
262 | (struct usb_descriptor_header *) &ecm_control_intf, | 262 | (struct usb_descriptor_header *) &ecm_control_intf, |
263 | (struct usb_descriptor_header *) &header_desc, | 263 | (struct usb_descriptor_header *) &ecm_header_desc, |
264 | (struct usb_descriptor_header *) &ecm_union_desc, | 264 | (struct usb_descriptor_header *) &ecm_union_desc, |
265 | (struct usb_descriptor_header *) ðer_desc, | 265 | (struct usb_descriptor_header *) &ecm_desc, |
266 | /* NOTE: status endpoint might need to be removed */ | 266 | /* NOTE: status endpoint might need to be removed */ |
267 | (struct usb_descriptor_header *) &hs_notify_desc, | 267 | (struct usb_descriptor_header *) &hs_ecm_notify_desc, |
268 | /* data interface, altsettings 0 and 1 */ | 268 | /* data interface, altsettings 0 and 1 */ |
269 | (struct usb_descriptor_header *) &ecm_data_nop_intf, | 269 | (struct usb_descriptor_header *) &ecm_data_nop_intf, |
270 | (struct usb_descriptor_header *) &ecm_data_intf, | 270 | (struct usb_descriptor_header *) &ecm_data_intf, |
271 | (struct usb_descriptor_header *) &hs_in_desc, | 271 | (struct usb_descriptor_header *) &hs_ecm_in_desc, |
272 | (struct usb_descriptor_header *) &hs_out_desc, | 272 | (struct usb_descriptor_header *) &hs_ecm_out_desc, |
273 | NULL, | 273 | NULL, |
274 | }; | 274 | }; |
275 | 275 | ||
@@ -329,14 +329,14 @@ static void ecm_do_notify(struct f_ecm *ecm) | |||
329 | event->bNotificationType = USB_CDC_NOTIFY_SPEED_CHANGE; | 329 | event->bNotificationType = USB_CDC_NOTIFY_SPEED_CHANGE; |
330 | event->wValue = cpu_to_le16(0); | 330 | event->wValue = cpu_to_le16(0); |
331 | event->wLength = cpu_to_le16(8); | 331 | event->wLength = cpu_to_le16(8); |
332 | req->length = STATUS_BYTECOUNT; | 332 | req->length = ECM_STATUS_BYTECOUNT; |
333 | 333 | ||
334 | /* SPEED_CHANGE data is up/down speeds in bits/sec */ | 334 | /* SPEED_CHANGE data is up/down speeds in bits/sec */ |
335 | data = req->buf + sizeof *event; | 335 | data = req->buf + sizeof *event; |
336 | data[0] = cpu_to_le32(bitrate(cdev->gadget)); | 336 | data[0] = cpu_to_le32(ecm_bitrate(cdev->gadget)); |
337 | data[1] = data[0]; | 337 | data[1] = data[0]; |
338 | 338 | ||
339 | DBG(cdev, "notify speed %d\n", bitrate(cdev->gadget)); | 339 | DBG(cdev, "notify speed %d\n", ecm_bitrate(cdev->gadget)); |
340 | ecm->notify_state = ECM_NOTIFY_NONE; | 340 | ecm->notify_state = ECM_NOTIFY_NONE; |
341 | break; | 341 | break; |
342 | } | 342 | } |
@@ -628,13 +628,13 @@ ecm_bind(struct usb_configuration *c, struct usb_function *f) | |||
628 | status = -ENODEV; | 628 | status = -ENODEV; |
629 | 629 | ||
630 | /* allocate instance-specific endpoints */ | 630 | /* allocate instance-specific endpoints */ |
631 | ep = usb_ep_autoconfig(cdev->gadget, &fs_in_desc); | 631 | ep = usb_ep_autoconfig(cdev->gadget, &fs_ecm_in_desc); |
632 | if (!ep) | 632 | if (!ep) |
633 | goto fail; | 633 | goto fail; |
634 | ecm->port.in_ep = ep; | 634 | ecm->port.in_ep = ep; |
635 | ep->driver_data = cdev; /* claim */ | 635 | ep->driver_data = cdev; /* claim */ |
636 | 636 | ||
637 | ep = usb_ep_autoconfig(cdev->gadget, &fs_out_desc); | 637 | ep = usb_ep_autoconfig(cdev->gadget, &fs_ecm_out_desc); |
638 | if (!ep) | 638 | if (!ep) |
639 | goto fail; | 639 | goto fail; |
640 | ecm->port.out_ep = ep; | 640 | ecm->port.out_ep = ep; |
@@ -644,7 +644,7 @@ ecm_bind(struct usb_configuration *c, struct usb_function *f) | |||
644 | * don't treat it that way. It's simpler, and some newer CDC | 644 | * don't treat it that way. It's simpler, and some newer CDC |
645 | * profiles (wireless handsets) no longer treat it as optional. | 645 | * profiles (wireless handsets) no longer treat it as optional. |
646 | */ | 646 | */ |
647 | ep = usb_ep_autoconfig(cdev->gadget, &fs_notify_desc); | 647 | ep = usb_ep_autoconfig(cdev->gadget, &fs_ecm_notify_desc); |
648 | if (!ep) | 648 | if (!ep) |
649 | goto fail; | 649 | goto fail; |
650 | ecm->notify = ep; | 650 | ecm->notify = ep; |
@@ -656,47 +656,47 @@ ecm_bind(struct usb_configuration *c, struct usb_function *f) | |||
656 | ecm->notify_req = usb_ep_alloc_request(ep, GFP_KERNEL); | 656 | ecm->notify_req = usb_ep_alloc_request(ep, GFP_KERNEL); |
657 | if (!ecm->notify_req) | 657 | if (!ecm->notify_req) |
658 | goto fail; | 658 | goto fail; |
659 | ecm->notify_req->buf = kmalloc(STATUS_BYTECOUNT, GFP_KERNEL); | 659 | ecm->notify_req->buf = kmalloc(ECM_STATUS_BYTECOUNT, GFP_KERNEL); |
660 | if (!ecm->notify_req->buf) | 660 | if (!ecm->notify_req->buf) |
661 | goto fail; | 661 | goto fail; |
662 | ecm->notify_req->context = ecm; | 662 | ecm->notify_req->context = ecm; |
663 | ecm->notify_req->complete = ecm_notify_complete; | 663 | ecm->notify_req->complete = ecm_notify_complete; |
664 | 664 | ||
665 | /* copy descriptors, and track endpoint copies */ | 665 | /* copy descriptors, and track endpoint copies */ |
666 | f->descriptors = usb_copy_descriptors(eth_fs_function); | 666 | f->descriptors = usb_copy_descriptors(ecm_fs_function); |
667 | if (!f->descriptors) | 667 | if (!f->descriptors) |
668 | goto fail; | 668 | goto fail; |
669 | 669 | ||
670 | ecm->fs.in = usb_find_endpoint(eth_fs_function, | 670 | ecm->fs.in = usb_find_endpoint(ecm_fs_function, |
671 | f->descriptors, &fs_in_desc); | 671 | f->descriptors, &fs_ecm_in_desc); |
672 | ecm->fs.out = usb_find_endpoint(eth_fs_function, | 672 | ecm->fs.out = usb_find_endpoint(ecm_fs_function, |
673 | f->descriptors, &fs_out_desc); | 673 | f->descriptors, &fs_ecm_out_desc); |
674 | ecm->fs.notify = usb_find_endpoint(eth_fs_function, | 674 | ecm->fs.notify = usb_find_endpoint(ecm_fs_function, |
675 | f->descriptors, &fs_notify_desc); | 675 | f->descriptors, &fs_ecm_notify_desc); |
676 | 676 | ||
677 | /* support all relevant hardware speeds... we expect that when | 677 | /* support all relevant hardware speeds... we expect that when |
678 | * hardware is dual speed, all bulk-capable endpoints work at | 678 | * hardware is dual speed, all bulk-capable endpoints work at |
679 | * both speeds | 679 | * both speeds |
680 | */ | 680 | */ |
681 | if (gadget_is_dualspeed(c->cdev->gadget)) { | 681 | if (gadget_is_dualspeed(c->cdev->gadget)) { |
682 | hs_in_desc.bEndpointAddress = | 682 | hs_ecm_in_desc.bEndpointAddress = |
683 | fs_in_desc.bEndpointAddress; | 683 | fs_ecm_in_desc.bEndpointAddress; |
684 | hs_out_desc.bEndpointAddress = | 684 | hs_ecm_out_desc.bEndpointAddress = |
685 | fs_out_desc.bEndpointAddress; | 685 | fs_ecm_out_desc.bEndpointAddress; |
686 | hs_notify_desc.bEndpointAddress = | 686 | hs_ecm_notify_desc.bEndpointAddress = |
687 | fs_notify_desc.bEndpointAddress; | 687 | fs_ecm_notify_desc.bEndpointAddress; |
688 | 688 | ||
689 | /* copy descriptors, and track endpoint copies */ | 689 | /* copy descriptors, and track endpoint copies */ |
690 | f->hs_descriptors = usb_copy_descriptors(eth_hs_function); | 690 | f->hs_descriptors = usb_copy_descriptors(ecm_hs_function); |
691 | if (!f->hs_descriptors) | 691 | if (!f->hs_descriptors) |
692 | goto fail; | 692 | goto fail; |
693 | 693 | ||
694 | ecm->hs.in = usb_find_endpoint(eth_hs_function, | 694 | ecm->hs.in = usb_find_endpoint(ecm_hs_function, |
695 | f->hs_descriptors, &hs_in_desc); | 695 | f->hs_descriptors, &hs_ecm_in_desc); |
696 | ecm->hs.out = usb_find_endpoint(eth_hs_function, | 696 | ecm->hs.out = usb_find_endpoint(ecm_hs_function, |
697 | f->hs_descriptors, &hs_out_desc); | 697 | f->hs_descriptors, &hs_ecm_out_desc); |
698 | ecm->hs.notify = usb_find_endpoint(eth_hs_function, | 698 | ecm->hs.notify = usb_find_endpoint(ecm_hs_function, |
699 | f->hs_descriptors, &hs_notify_desc); | 699 | f->hs_descriptors, &hs_ecm_notify_desc); |
700 | } | 700 | } |
701 | 701 | ||
702 | /* NOTE: all that is done without knowing or caring about | 702 | /* NOTE: all that is done without knowing or caring about |
@@ -795,7 +795,7 @@ int __init ecm_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN]) | |||
795 | if (status < 0) | 795 | if (status < 0) |
796 | return status; | 796 | return status; |
797 | ecm_string_defs[1].id = status; | 797 | ecm_string_defs[1].id = status; |
798 | ether_desc.iMACAddress = status; | 798 | ecm_desc.iMACAddress = status; |
799 | } | 799 | } |
800 | 800 | ||
801 | /* allocate and initialize one new instance */ | 801 | /* allocate and initialize one new instance */ |
diff --git a/drivers/usb/gadget/f_loopback.c b/drivers/usb/gadget/f_loopback.c index eda4cde72c82..8affe1dfc2c1 100644 --- a/drivers/usb/gadget/f_loopback.c +++ b/drivers/usb/gadget/f_loopback.c | |||
@@ -70,7 +70,7 @@ static struct usb_interface_descriptor loopback_intf = { | |||
70 | 70 | ||
71 | /* full speed support: */ | 71 | /* full speed support: */ |
72 | 72 | ||
73 | static struct usb_endpoint_descriptor fs_source_desc = { | 73 | static struct usb_endpoint_descriptor fs_loop_source_desc = { |
74 | .bLength = USB_DT_ENDPOINT_SIZE, | 74 | .bLength = USB_DT_ENDPOINT_SIZE, |
75 | .bDescriptorType = USB_DT_ENDPOINT, | 75 | .bDescriptorType = USB_DT_ENDPOINT, |
76 | 76 | ||
@@ -78,7 +78,7 @@ static struct usb_endpoint_descriptor fs_source_desc = { | |||
78 | .bmAttributes = USB_ENDPOINT_XFER_BULK, | 78 | .bmAttributes = USB_ENDPOINT_XFER_BULK, |
79 | }; | 79 | }; |
80 | 80 | ||
81 | static struct usb_endpoint_descriptor fs_sink_desc = { | 81 | static struct usb_endpoint_descriptor fs_loop_sink_desc = { |
82 | .bLength = USB_DT_ENDPOINT_SIZE, | 82 | .bLength = USB_DT_ENDPOINT_SIZE, |
83 | .bDescriptorType = USB_DT_ENDPOINT, | 83 | .bDescriptorType = USB_DT_ENDPOINT, |
84 | 84 | ||
@@ -88,14 +88,14 @@ static struct usb_endpoint_descriptor fs_sink_desc = { | |||
88 | 88 | ||
89 | static struct usb_descriptor_header *fs_loopback_descs[] = { | 89 | static struct usb_descriptor_header *fs_loopback_descs[] = { |
90 | (struct usb_descriptor_header *) &loopback_intf, | 90 | (struct usb_descriptor_header *) &loopback_intf, |
91 | (struct usb_descriptor_header *) &fs_sink_desc, | 91 | (struct usb_descriptor_header *) &fs_loop_sink_desc, |
92 | (struct usb_descriptor_header *) &fs_source_desc, | 92 | (struct usb_descriptor_header *) &fs_loop_source_desc, |
93 | NULL, | 93 | NULL, |
94 | }; | 94 | }; |
95 | 95 | ||
96 | /* high speed support: */ | 96 | /* high speed support: */ |
97 | 97 | ||
98 | static struct usb_endpoint_descriptor hs_source_desc = { | 98 | static struct usb_endpoint_descriptor hs_loop_source_desc = { |
99 | .bLength = USB_DT_ENDPOINT_SIZE, | 99 | .bLength = USB_DT_ENDPOINT_SIZE, |
100 | .bDescriptorType = USB_DT_ENDPOINT, | 100 | .bDescriptorType = USB_DT_ENDPOINT, |
101 | 101 | ||
@@ -103,7 +103,7 @@ static struct usb_endpoint_descriptor hs_source_desc = { | |||
103 | .wMaxPacketSize = __constant_cpu_to_le16(512), | 103 | .wMaxPacketSize = __constant_cpu_to_le16(512), |
104 | }; | 104 | }; |
105 | 105 | ||
106 | static struct usb_endpoint_descriptor hs_sink_desc = { | 106 | static struct usb_endpoint_descriptor hs_loop_sink_desc = { |
107 | .bLength = USB_DT_ENDPOINT_SIZE, | 107 | .bLength = USB_DT_ENDPOINT_SIZE, |
108 | .bDescriptorType = USB_DT_ENDPOINT, | 108 | .bDescriptorType = USB_DT_ENDPOINT, |
109 | 109 | ||
@@ -113,8 +113,8 @@ static struct usb_endpoint_descriptor hs_sink_desc = { | |||
113 | 113 | ||
114 | static struct usb_descriptor_header *hs_loopback_descs[] = { | 114 | static struct usb_descriptor_header *hs_loopback_descs[] = { |
115 | (struct usb_descriptor_header *) &loopback_intf, | 115 | (struct usb_descriptor_header *) &loopback_intf, |
116 | (struct usb_descriptor_header *) &hs_source_desc, | 116 | (struct usb_descriptor_header *) &hs_loop_source_desc, |
117 | (struct usb_descriptor_header *) &hs_sink_desc, | 117 | (struct usb_descriptor_header *) &hs_loop_sink_desc, |
118 | NULL, | 118 | NULL, |
119 | }; | 119 | }; |
120 | 120 | ||
@@ -152,7 +152,7 @@ loopback_bind(struct usb_configuration *c, struct usb_function *f) | |||
152 | 152 | ||
153 | /* allocate endpoints */ | 153 | /* allocate endpoints */ |
154 | 154 | ||
155 | loop->in_ep = usb_ep_autoconfig(cdev->gadget, &fs_source_desc); | 155 | loop->in_ep = usb_ep_autoconfig(cdev->gadget, &fs_loop_source_desc); |
156 | if (!loop->in_ep) { | 156 | if (!loop->in_ep) { |
157 | autoconf_fail: | 157 | autoconf_fail: |
158 | ERROR(cdev, "%s: can't autoconfigure on %s\n", | 158 | ERROR(cdev, "%s: can't autoconfigure on %s\n", |
@@ -161,17 +161,17 @@ autoconf_fail: | |||
161 | } | 161 | } |
162 | loop->in_ep->driver_data = cdev; /* claim */ | 162 | loop->in_ep->driver_data = cdev; /* claim */ |
163 | 163 | ||
164 | loop->out_ep = usb_ep_autoconfig(cdev->gadget, &fs_sink_desc); | 164 | loop->out_ep = usb_ep_autoconfig(cdev->gadget, &fs_loop_sink_desc); |
165 | if (!loop->out_ep) | 165 | if (!loop->out_ep) |
166 | goto autoconf_fail; | 166 | goto autoconf_fail; |
167 | loop->out_ep->driver_data = cdev; /* claim */ | 167 | loop->out_ep->driver_data = cdev; /* claim */ |
168 | 168 | ||
169 | /* support high speed hardware */ | 169 | /* support high speed hardware */ |
170 | if (gadget_is_dualspeed(c->cdev->gadget)) { | 170 | if (gadget_is_dualspeed(c->cdev->gadget)) { |
171 | hs_source_desc.bEndpointAddress = | 171 | hs_loop_source_desc.bEndpointAddress = |
172 | fs_source_desc.bEndpointAddress; | 172 | fs_loop_source_desc.bEndpointAddress; |
173 | hs_sink_desc.bEndpointAddress = | 173 | hs_loop_sink_desc.bEndpointAddress = |
174 | fs_sink_desc.bEndpointAddress; | 174 | fs_loop_sink_desc.bEndpointAddress; |
175 | f->hs_descriptors = hs_loopback_descs; | 175 | f->hs_descriptors = hs_loopback_descs; |
176 | } | 176 | } |
177 | 177 | ||
@@ -255,8 +255,10 @@ enable_loopback(struct usb_composite_dev *cdev, struct f_loopback *loop) | |||
255 | struct usb_request *req; | 255 | struct usb_request *req; |
256 | unsigned i; | 256 | unsigned i; |
257 | 257 | ||
258 | src = ep_choose(cdev->gadget, &hs_source_desc, &fs_source_desc); | 258 | src = ep_choose(cdev->gadget, |
259 | sink = ep_choose(cdev->gadget, &hs_sink_desc, &fs_sink_desc); | 259 | &hs_loop_source_desc, &fs_loop_source_desc); |
260 | sink = ep_choose(cdev->gadget, | ||
261 | &hs_loop_sink_desc, &fs_loop_sink_desc); | ||
260 | 262 | ||
261 | /* one endpoint writes data back IN to the host */ | 263 | /* one endpoint writes data back IN to the host */ |
262 | ep = loop->in_ep; | 264 | ep = loop->in_ep; |
@@ -350,7 +352,6 @@ static struct usb_configuration loopback_driver = { | |||
350 | .bind = loopback_bind_config, | 352 | .bind = loopback_bind_config, |
351 | .bConfigurationValue = 2, | 353 | .bConfigurationValue = 2, |
352 | .bmAttributes = USB_CONFIG_ATT_SELFPOWER, | 354 | .bmAttributes = USB_CONFIG_ATT_SELFPOWER, |
353 | .bMaxPower = 1, /* 2 mA, minimal */ | ||
354 | /* .iConfiguration = DYNAMIC */ | 355 | /* .iConfiguration = DYNAMIC */ |
355 | }; | 356 | }; |
356 | 357 | ||
diff --git a/drivers/usb/gadget/f_obex.c b/drivers/usb/gadget/f_obex.c new file mode 100644 index 000000000000..80c2e7e9622f --- /dev/null +++ b/drivers/usb/gadget/f_obex.c | |||
@@ -0,0 +1,493 @@ | |||
1 | /* | ||
2 | * f_obex.c -- USB CDC OBEX function driver | ||
3 | * | ||
4 | * Copyright (C) 2008 Nokia Corporation | ||
5 | * Contact: Felipe Balbi <felipe.balbi@nokia.com> | ||
6 | * | ||
7 | * Based on f_acm.c by Al Borchers and David Brownell. | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License as published by | ||
11 | * the Free Software Foundation; either version 2 of the License, or | ||
12 | * (at your option) any later version. | ||
13 | * | ||
14 | * This program is distributed in the hope that it will be useful, | ||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | * GNU General Public License for more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License | ||
20 | * along with this program; if not, write to the Free Software | ||
21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
22 | */ | ||
23 | |||
24 | /* #define VERBOSE_DEBUG */ | ||
25 | |||
26 | #include <linux/kernel.h> | ||
27 | #include <linux/utsname.h> | ||
28 | #include <linux/device.h> | ||
29 | |||
30 | #include "u_serial.h" | ||
31 | #include "gadget_chips.h" | ||
32 | |||
33 | |||
34 | /* | ||
35 | * This CDC OBEX function support just packages a TTY-ish byte stream. | ||
36 | * A user mode server will put it into "raw" mode and handle all the | ||
37 | * relevant protocol details ... this is just a kernel passthrough. | ||
38 | * When possible, we prevent gadget enumeration until that server is | ||
39 | * ready to handle the commands. | ||
40 | */ | ||
41 | |||
42 | struct obex_ep_descs { | ||
43 | struct usb_endpoint_descriptor *obex_in; | ||
44 | struct usb_endpoint_descriptor *obex_out; | ||
45 | }; | ||
46 | |||
47 | struct f_obex { | ||
48 | struct gserial port; | ||
49 | u8 ctrl_id; | ||
50 | u8 data_id; | ||
51 | u8 port_num; | ||
52 | u8 can_activate; | ||
53 | |||
54 | struct obex_ep_descs fs; | ||
55 | struct obex_ep_descs hs; | ||
56 | }; | ||
57 | |||
58 | static inline struct f_obex *func_to_obex(struct usb_function *f) | ||
59 | { | ||
60 | return container_of(f, struct f_obex, port.func); | ||
61 | } | ||
62 | |||
63 | static inline struct f_obex *port_to_obex(struct gserial *p) | ||
64 | { | ||
65 | return container_of(p, struct f_obex, port); | ||
66 | } | ||
67 | |||
68 | /*-------------------------------------------------------------------------*/ | ||
69 | |||
70 | #define OBEX_CTRL_IDX 0 | ||
71 | #define OBEX_DATA_IDX 1 | ||
72 | |||
73 | static struct usb_string obex_string_defs[] = { | ||
74 | [OBEX_CTRL_IDX].s = "CDC Object Exchange (OBEX)", | ||
75 | [OBEX_DATA_IDX].s = "CDC OBEX Data", | ||
76 | { }, /* end of list */ | ||
77 | }; | ||
78 | |||
79 | static struct usb_gadget_strings obex_string_table = { | ||
80 | .language = 0x0409, /* en-US */ | ||
81 | .strings = obex_string_defs, | ||
82 | }; | ||
83 | |||
84 | static struct usb_gadget_strings *obex_strings[] = { | ||
85 | &obex_string_table, | ||
86 | NULL, | ||
87 | }; | ||
88 | |||
89 | /*-------------------------------------------------------------------------*/ | ||
90 | |||
91 | static struct usb_interface_descriptor obex_control_intf __initdata = { | ||
92 | .bLength = sizeof(obex_control_intf), | ||
93 | .bDescriptorType = USB_DT_INTERFACE, | ||
94 | .bInterfaceNumber = 0, | ||
95 | |||
96 | .bAlternateSetting = 0, | ||
97 | .bNumEndpoints = 0, | ||
98 | .bInterfaceClass = USB_CLASS_COMM, | ||
99 | .bInterfaceSubClass = USB_CDC_SUBCLASS_OBEX, | ||
100 | }; | ||
101 | |||
102 | static struct usb_interface_descriptor obex_data_nop_intf __initdata = { | ||
103 | .bLength = sizeof(obex_data_nop_intf), | ||
104 | .bDescriptorType = USB_DT_INTERFACE, | ||
105 | .bInterfaceNumber = 1, | ||
106 | |||
107 | .bAlternateSetting = 0, | ||
108 | .bNumEndpoints = 0, | ||
109 | .bInterfaceClass = USB_CLASS_CDC_DATA, | ||
110 | }; | ||
111 | |||
112 | static struct usb_interface_descriptor obex_data_intf __initdata = { | ||
113 | .bLength = sizeof(obex_data_intf), | ||
114 | .bDescriptorType = USB_DT_INTERFACE, | ||
115 | .bInterfaceNumber = 2, | ||
116 | |||
117 | .bAlternateSetting = 1, | ||
118 | .bNumEndpoints = 2, | ||
119 | .bInterfaceClass = USB_CLASS_CDC_DATA, | ||
120 | }; | ||
121 | |||
122 | static struct usb_cdc_header_desc obex_cdc_header_desc __initdata = { | ||
123 | .bLength = sizeof(obex_cdc_header_desc), | ||
124 | .bDescriptorType = USB_DT_CS_INTERFACE, | ||
125 | .bDescriptorSubType = USB_CDC_HEADER_TYPE, | ||
126 | .bcdCDC = __constant_cpu_to_le16(0x0120), | ||
127 | }; | ||
128 | |||
129 | static struct usb_cdc_union_desc obex_cdc_union_desc __initdata = { | ||
130 | .bLength = sizeof(obex_cdc_union_desc), | ||
131 | .bDescriptorType = USB_DT_CS_INTERFACE, | ||
132 | .bDescriptorSubType = USB_CDC_UNION_TYPE, | ||
133 | .bMasterInterface0 = 1, | ||
134 | .bSlaveInterface0 = 2, | ||
135 | }; | ||
136 | |||
137 | static struct usb_cdc_obex_desc obex_desc __initdata = { | ||
138 | .bLength = sizeof(obex_desc), | ||
139 | .bDescriptorType = USB_DT_CS_INTERFACE, | ||
140 | .bDescriptorSubType = USB_CDC_OBEX_TYPE, | ||
141 | .bcdVersion = __constant_cpu_to_le16(0x0100), | ||
142 | }; | ||
143 | |||
144 | /* High-Speed Support */ | ||
145 | |||
146 | static struct usb_endpoint_descriptor obex_hs_ep_out_desc __initdata = { | ||
147 | .bLength = USB_DT_ENDPOINT_SIZE, | ||
148 | .bDescriptorType = USB_DT_ENDPOINT, | ||
149 | |||
150 | .bEndpointAddress = USB_DIR_OUT, | ||
151 | .bmAttributes = USB_ENDPOINT_XFER_BULK, | ||
152 | .wMaxPacketSize = __constant_cpu_to_le16(512), | ||
153 | }; | ||
154 | |||
155 | static struct usb_endpoint_descriptor obex_hs_ep_in_desc __initdata = { | ||
156 | .bLength = USB_DT_ENDPOINT_SIZE, | ||
157 | .bDescriptorType = USB_DT_ENDPOINT, | ||
158 | |||
159 | .bEndpointAddress = USB_DIR_IN, | ||
160 | .bmAttributes = USB_ENDPOINT_XFER_BULK, | ||
161 | .wMaxPacketSize = __constant_cpu_to_le16(512), | ||
162 | }; | ||
163 | |||
164 | static struct usb_descriptor_header *hs_function[] __initdata = { | ||
165 | (struct usb_descriptor_header *) &obex_control_intf, | ||
166 | (struct usb_descriptor_header *) &obex_cdc_header_desc, | ||
167 | (struct usb_descriptor_header *) &obex_desc, | ||
168 | (struct usb_descriptor_header *) &obex_cdc_union_desc, | ||
169 | |||
170 | (struct usb_descriptor_header *) &obex_data_nop_intf, | ||
171 | (struct usb_descriptor_header *) &obex_data_intf, | ||
172 | (struct usb_descriptor_header *) &obex_hs_ep_in_desc, | ||
173 | (struct usb_descriptor_header *) &obex_hs_ep_out_desc, | ||
174 | NULL, | ||
175 | }; | ||
176 | |||
177 | /* Full-Speed Support */ | ||
178 | |||
179 | static struct usb_endpoint_descriptor obex_fs_ep_in_desc __initdata = { | ||
180 | .bLength = USB_DT_ENDPOINT_SIZE, | ||
181 | .bDescriptorType = USB_DT_ENDPOINT, | ||
182 | |||
183 | .bEndpointAddress = USB_DIR_IN, | ||
184 | .bmAttributes = USB_ENDPOINT_XFER_BULK, | ||
185 | }; | ||
186 | |||
187 | static struct usb_endpoint_descriptor obex_fs_ep_out_desc __initdata = { | ||
188 | .bLength = USB_DT_ENDPOINT_SIZE, | ||
189 | .bDescriptorType = USB_DT_ENDPOINT, | ||
190 | |||
191 | .bEndpointAddress = USB_DIR_OUT, | ||
192 | .bmAttributes = USB_ENDPOINT_XFER_BULK, | ||
193 | }; | ||
194 | |||
195 | static struct usb_descriptor_header *fs_function[] __initdata = { | ||
196 | (struct usb_descriptor_header *) &obex_control_intf, | ||
197 | (struct usb_descriptor_header *) &obex_cdc_header_desc, | ||
198 | (struct usb_descriptor_header *) &obex_desc, | ||
199 | (struct usb_descriptor_header *) &obex_cdc_union_desc, | ||
200 | |||
201 | (struct usb_descriptor_header *) &obex_data_nop_intf, | ||
202 | (struct usb_descriptor_header *) &obex_data_intf, | ||
203 | (struct usb_descriptor_header *) &obex_fs_ep_in_desc, | ||
204 | (struct usb_descriptor_header *) &obex_fs_ep_out_desc, | ||
205 | NULL, | ||
206 | }; | ||
207 | |||
208 | /*-------------------------------------------------------------------------*/ | ||
209 | |||
210 | static int obex_set_alt(struct usb_function *f, unsigned intf, unsigned alt) | ||
211 | { | ||
212 | struct f_obex *obex = func_to_obex(f); | ||
213 | struct usb_composite_dev *cdev = f->config->cdev; | ||
214 | |||
215 | if (intf == obex->ctrl_id) { | ||
216 | if (alt != 0) | ||
217 | goto fail; | ||
218 | /* NOP */ | ||
219 | DBG(cdev, "reset obex ttyGS%d control\n", obex->port_num); | ||
220 | |||
221 | } else if (intf == obex->data_id) { | ||
222 | if (alt > 1) | ||
223 | goto fail; | ||
224 | |||
225 | if (obex->port.in->driver_data) { | ||
226 | DBG(cdev, "reset obex ttyGS%d\n", obex->port_num); | ||
227 | gserial_disconnect(&obex->port); | ||
228 | } | ||
229 | |||
230 | if (!obex->port.in_desc) { | ||
231 | DBG(cdev, "init obex ttyGS%d\n", obex->port_num); | ||
232 | obex->port.in_desc = ep_choose(cdev->gadget, | ||
233 | obex->hs.obex_in, obex->fs.obex_in); | ||
234 | obex->port.out_desc = ep_choose(cdev->gadget, | ||
235 | obex->hs.obex_out, obex->fs.obex_out); | ||
236 | } | ||
237 | |||
238 | if (alt == 1) { | ||
239 | DBG(cdev, "activate obex ttyGS%d\n", obex->port_num); | ||
240 | gserial_connect(&obex->port, obex->port_num); | ||
241 | } | ||
242 | |||
243 | } else | ||
244 | goto fail; | ||
245 | |||
246 | return 0; | ||
247 | |||
248 | fail: | ||
249 | return -EINVAL; | ||
250 | } | ||
251 | |||
252 | static int obex_get_alt(struct usb_function *f, unsigned intf) | ||
253 | { | ||
254 | struct f_obex *obex = func_to_obex(f); | ||
255 | |||
256 | if (intf == obex->ctrl_id) | ||
257 | return 0; | ||
258 | |||
259 | return obex->port.in->driver_data ? 1 : 0; | ||
260 | } | ||
261 | |||
262 | static void obex_disable(struct usb_function *f) | ||
263 | { | ||
264 | struct f_obex *obex = func_to_obex(f); | ||
265 | struct usb_composite_dev *cdev = f->config->cdev; | ||
266 | |||
267 | DBG(cdev, "obex ttyGS%d disable\n", obex->port_num); | ||
268 | gserial_disconnect(&obex->port); | ||
269 | } | ||
270 | |||
271 | /*-------------------------------------------------------------------------*/ | ||
272 | |||
273 | static void obex_connect(struct gserial *g) | ||
274 | { | ||
275 | struct f_obex *obex = port_to_obex(g); | ||
276 | struct usb_composite_dev *cdev = g->func.config->cdev; | ||
277 | int status; | ||
278 | |||
279 | if (!obex->can_activate) | ||
280 | return; | ||
281 | |||
282 | status = usb_function_activate(&g->func); | ||
283 | if (status) | ||
284 | DBG(cdev, "obex ttyGS%d function activate --> %d\n", | ||
285 | obex->port_num, status); | ||
286 | } | ||
287 | |||
288 | static void obex_disconnect(struct gserial *g) | ||
289 | { | ||
290 | struct f_obex *obex = port_to_obex(g); | ||
291 | struct usb_composite_dev *cdev = g->func.config->cdev; | ||
292 | int status; | ||
293 | |||
294 | if (!obex->can_activate) | ||
295 | return; | ||
296 | |||
297 | status = usb_function_deactivate(&g->func); | ||
298 | if (status) | ||
299 | DBG(cdev, "obex ttyGS%d function deactivate --> %d\n", | ||
300 | obex->port_num, status); | ||
301 | } | ||
302 | |||
303 | /*-------------------------------------------------------------------------*/ | ||
304 | |||
305 | static int __init | ||
306 | obex_bind(struct usb_configuration *c, struct usb_function *f) | ||
307 | { | ||
308 | struct usb_composite_dev *cdev = c->cdev; | ||
309 | struct f_obex *obex = func_to_obex(f); | ||
310 | int status; | ||
311 | struct usb_ep *ep; | ||
312 | |||
313 | /* allocate instance-specific interface IDs, and patch descriptors */ | ||
314 | |||
315 | status = usb_interface_id(c, f); | ||
316 | if (status < 0) | ||
317 | goto fail; | ||
318 | obex->ctrl_id = status; | ||
319 | |||
320 | obex_control_intf.bInterfaceNumber = status; | ||
321 | obex_cdc_union_desc.bMasterInterface0 = status; | ||
322 | |||
323 | status = usb_interface_id(c, f); | ||
324 | if (status < 0) | ||
325 | goto fail; | ||
326 | obex->data_id = status; | ||
327 | |||
328 | obex_data_nop_intf.bInterfaceNumber = status; | ||
329 | obex_data_intf.bInterfaceNumber = status; | ||
330 | obex_cdc_union_desc.bSlaveInterface0 = status; | ||
331 | |||
332 | /* allocate instance-specific endpoints */ | ||
333 | |||
334 | ep = usb_ep_autoconfig(cdev->gadget, &obex_fs_ep_in_desc); | ||
335 | if (!ep) | ||
336 | goto fail; | ||
337 | obex->port.in = ep; | ||
338 | ep->driver_data = cdev; /* claim */ | ||
339 | |||
340 | ep = usb_ep_autoconfig(cdev->gadget, &obex_fs_ep_out_desc); | ||
341 | if (!ep) | ||
342 | goto fail; | ||
343 | obex->port.out = ep; | ||
344 | ep->driver_data = cdev; /* claim */ | ||
345 | |||
346 | /* copy descriptors, and track endpoint copies */ | ||
347 | f->descriptors = usb_copy_descriptors(fs_function); | ||
348 | |||
349 | obex->fs.obex_in = usb_find_endpoint(fs_function, | ||
350 | f->descriptors, &obex_fs_ep_in_desc); | ||
351 | obex->fs.obex_out = usb_find_endpoint(fs_function, | ||
352 | f->descriptors, &obex_fs_ep_out_desc); | ||
353 | |||
354 | /* support all relevant hardware speeds... we expect that when | ||
355 | * hardware is dual speed, all bulk-capable endpoints work at | ||
356 | * both speeds | ||
357 | */ | ||
358 | if (gadget_is_dualspeed(c->cdev->gadget)) { | ||
359 | |||
360 | obex_hs_ep_in_desc.bEndpointAddress = | ||
361 | obex_fs_ep_in_desc.bEndpointAddress; | ||
362 | obex_hs_ep_out_desc.bEndpointAddress = | ||
363 | obex_fs_ep_out_desc.bEndpointAddress; | ||
364 | |||
365 | /* copy descriptors, and track endpoint copies */ | ||
366 | f->hs_descriptors = usb_copy_descriptors(hs_function); | ||
367 | |||
368 | obex->hs.obex_in = usb_find_endpoint(hs_function, | ||
369 | f->descriptors, &obex_hs_ep_in_desc); | ||
370 | obex->hs.obex_out = usb_find_endpoint(hs_function, | ||
371 | f->descriptors, &obex_hs_ep_out_desc); | ||
372 | } | ||
373 | |||
374 | /* Avoid letting this gadget enumerate until the userspace | ||
375 | * OBEX server is active. | ||
376 | */ | ||
377 | status = usb_function_deactivate(f); | ||
378 | if (status < 0) | ||
379 | WARNING(cdev, "obex ttyGS%d: can't prevent enumeration, %d\n", | ||
380 | obex->port_num, status); | ||
381 | else | ||
382 | obex->can_activate = true; | ||
383 | |||
384 | |||
385 | DBG(cdev, "obex ttyGS%d: %s speed IN/%s OUT/%s\n", | ||
386 | obex->port_num, | ||
387 | gadget_is_dualspeed(c->cdev->gadget) ? "dual" : "full", | ||
388 | obex->port.in->name, obex->port.out->name); | ||
389 | |||
390 | return 0; | ||
391 | |||
392 | fail: | ||
393 | /* we might as well release our claims on endpoints */ | ||
394 | if (obex->port.out) | ||
395 | obex->port.out->driver_data = NULL; | ||
396 | if (obex->port.in) | ||
397 | obex->port.in->driver_data = NULL; | ||
398 | |||
399 | ERROR(cdev, "%s/%p: can't bind, err %d\n", f->name, f, status); | ||
400 | |||
401 | return status; | ||
402 | } | ||
403 | |||
404 | static void | ||
405 | obex_unbind(struct usb_configuration *c, struct usb_function *f) | ||
406 | { | ||
407 | if (gadget_is_dualspeed(c->cdev->gadget)) | ||
408 | usb_free_descriptors(f->hs_descriptors); | ||
409 | usb_free_descriptors(f->descriptors); | ||
410 | kfree(func_to_obex(f)); | ||
411 | } | ||
412 | |||
413 | /* Some controllers can't support CDC OBEX ... */ | ||
414 | static inline bool can_support_obex(struct usb_configuration *c) | ||
415 | { | ||
416 | /* Since the first interface is a NOP, we can ignore the | ||
417 | * issue of multi-interface support on most controllers. | ||
418 | * | ||
419 | * Altsettings are mandatory, however... | ||
420 | */ | ||
421 | if (!gadget_supports_altsettings(c->cdev->gadget)) | ||
422 | return false; | ||
423 | |||
424 | /* everything else is *probably* fine ... */ | ||
425 | return true; | ||
426 | } | ||
427 | |||
428 | /** | ||
429 | * obex_bind_config - add a CDC OBEX function to a configuration | ||
430 | * @c: the configuration to support the CDC OBEX instance | ||
431 | * @port_num: /dev/ttyGS* port this interface will use | ||
432 | * Context: single threaded during gadget setup | ||
433 | * | ||
434 | * Returns zero on success, else negative errno. | ||
435 | * | ||
436 | * Caller must have called @gserial_setup() with enough ports to | ||
437 | * handle all the ones it binds. Caller is also responsible | ||
438 | * for calling @gserial_cleanup() before module unload. | ||
439 | */ | ||
440 | int __init obex_bind_config(struct usb_configuration *c, u8 port_num) | ||
441 | { | ||
442 | struct f_obex *obex; | ||
443 | int status; | ||
444 | |||
445 | if (!can_support_obex(c)) | ||
446 | return -EINVAL; | ||
447 | |||
448 | /* maybe allocate device-global string IDs, and patch descriptors */ | ||
449 | if (obex_string_defs[OBEX_CTRL_IDX].id == 0) { | ||
450 | status = usb_string_id(c->cdev); | ||
451 | if (status < 0) | ||
452 | return status; | ||
453 | obex_string_defs[OBEX_CTRL_IDX].id = status; | ||
454 | |||
455 | obex_control_intf.iInterface = status; | ||
456 | |||
457 | status = usb_string_id(c->cdev); | ||
458 | if (status < 0) | ||
459 | return status; | ||
460 | obex_string_defs[OBEX_DATA_IDX].id = status; | ||
461 | |||
462 | obex_data_nop_intf.iInterface = | ||
463 | obex_data_intf.iInterface = status; | ||
464 | } | ||
465 | |||
466 | /* allocate and initialize one new instance */ | ||
467 | obex = kzalloc(sizeof *obex, GFP_KERNEL); | ||
468 | if (!obex) | ||
469 | return -ENOMEM; | ||
470 | |||
471 | obex->port_num = port_num; | ||
472 | |||
473 | obex->port.connect = obex_connect; | ||
474 | obex->port.disconnect = obex_disconnect; | ||
475 | |||
476 | obex->port.func.name = "obex"; | ||
477 | obex->port.func.strings = obex_strings; | ||
478 | /* descriptors are per-instance copies */ | ||
479 | obex->port.func.bind = obex_bind; | ||
480 | obex->port.func.unbind = obex_unbind; | ||
481 | obex->port.func.set_alt = obex_set_alt; | ||
482 | obex->port.func.get_alt = obex_get_alt; | ||
483 | obex->port.func.disable = obex_disable; | ||
484 | |||
485 | status = usb_add_function(c, &obex->port.func); | ||
486 | if (status) | ||
487 | kfree(obex); | ||
488 | |||
489 | return status; | ||
490 | } | ||
491 | |||
492 | MODULE_AUTHOR("Felipe Balbi"); | ||
493 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/usb/gadget/f_sourcesink.c b/drivers/usb/gadget/f_sourcesink.c index f18c3a14d72a..dc84d26d2835 100644 --- a/drivers/usb/gadget/f_sourcesink.c +++ b/drivers/usb/gadget/f_sourcesink.c | |||
@@ -552,7 +552,6 @@ static struct usb_configuration sourcesink_driver = { | |||
552 | .setup = sourcesink_setup, | 552 | .setup = sourcesink_setup, |
553 | .bConfigurationValue = 3, | 553 | .bConfigurationValue = 3, |
554 | .bmAttributes = USB_CONFIG_ATT_SELFPOWER, | 554 | .bmAttributes = USB_CONFIG_ATT_SELFPOWER, |
555 | .bMaxPower = 1, /* 2 mA, minimal */ | ||
556 | /* .iConfiguration = DYNAMIC */ | 555 | /* .iConfiguration = DYNAMIC */ |
557 | }; | 556 | }; |
558 | 557 | ||
diff --git a/drivers/usb/gadget/f_subset.c b/drivers/usb/gadget/f_subset.c index acb8d233aa1d..fe1832875771 100644 --- a/drivers/usb/gadget/f_subset.c +++ b/drivers/usb/gadget/f_subset.c | |||
@@ -103,8 +103,8 @@ static struct usb_interface_descriptor subset_data_intf __initdata = { | |||
103 | /* .iInterface = DYNAMIC */ | 103 | /* .iInterface = DYNAMIC */ |
104 | }; | 104 | }; |
105 | 105 | ||
106 | static struct usb_cdc_header_desc header_desc __initdata = { | 106 | static struct usb_cdc_header_desc mdlm_header_desc __initdata = { |
107 | .bLength = sizeof header_desc, | 107 | .bLength = sizeof mdlm_header_desc, |
108 | .bDescriptorType = USB_DT_CS_INTERFACE, | 108 | .bDescriptorType = USB_DT_CS_INTERFACE, |
109 | .bDescriptorSubType = USB_CDC_HEADER_TYPE, | 109 | .bDescriptorSubType = USB_CDC_HEADER_TYPE, |
110 | 110 | ||
@@ -152,7 +152,7 @@ static struct usb_cdc_ether_desc ether_desc __initdata = { | |||
152 | 152 | ||
153 | /* full speed support: */ | 153 | /* full speed support: */ |
154 | 154 | ||
155 | static struct usb_endpoint_descriptor fs_in_desc __initdata = { | 155 | static struct usb_endpoint_descriptor fs_subset_in_desc __initdata = { |
156 | .bLength = USB_DT_ENDPOINT_SIZE, | 156 | .bLength = USB_DT_ENDPOINT_SIZE, |
157 | .bDescriptorType = USB_DT_ENDPOINT, | 157 | .bDescriptorType = USB_DT_ENDPOINT, |
158 | 158 | ||
@@ -160,7 +160,7 @@ static struct usb_endpoint_descriptor fs_in_desc __initdata = { | |||
160 | .bmAttributes = USB_ENDPOINT_XFER_BULK, | 160 | .bmAttributes = USB_ENDPOINT_XFER_BULK, |
161 | }; | 161 | }; |
162 | 162 | ||
163 | static struct usb_endpoint_descriptor fs_out_desc __initdata = { | 163 | static struct usb_endpoint_descriptor fs_subset_out_desc __initdata = { |
164 | .bLength = USB_DT_ENDPOINT_SIZE, | 164 | .bLength = USB_DT_ENDPOINT_SIZE, |
165 | .bDescriptorType = USB_DT_ENDPOINT, | 165 | .bDescriptorType = USB_DT_ENDPOINT, |
166 | 166 | ||
@@ -170,18 +170,18 @@ static struct usb_endpoint_descriptor fs_out_desc __initdata = { | |||
170 | 170 | ||
171 | static struct usb_descriptor_header *fs_eth_function[] __initdata = { | 171 | static struct usb_descriptor_header *fs_eth_function[] __initdata = { |
172 | (struct usb_descriptor_header *) &subset_data_intf, | 172 | (struct usb_descriptor_header *) &subset_data_intf, |
173 | (struct usb_descriptor_header *) &header_desc, | 173 | (struct usb_descriptor_header *) &mdlm_header_desc, |
174 | (struct usb_descriptor_header *) &mdlm_desc, | 174 | (struct usb_descriptor_header *) &mdlm_desc, |
175 | (struct usb_descriptor_header *) &mdlm_detail_desc, | 175 | (struct usb_descriptor_header *) &mdlm_detail_desc, |
176 | (struct usb_descriptor_header *) ðer_desc, | 176 | (struct usb_descriptor_header *) ðer_desc, |
177 | (struct usb_descriptor_header *) &fs_in_desc, | 177 | (struct usb_descriptor_header *) &fs_subset_in_desc, |
178 | (struct usb_descriptor_header *) &fs_out_desc, | 178 | (struct usb_descriptor_header *) &fs_subset_out_desc, |
179 | NULL, | 179 | NULL, |
180 | }; | 180 | }; |
181 | 181 | ||
182 | /* high speed support: */ | 182 | /* high speed support: */ |
183 | 183 | ||
184 | static struct usb_endpoint_descriptor hs_in_desc __initdata = { | 184 | static struct usb_endpoint_descriptor hs_subset_in_desc __initdata = { |
185 | .bLength = USB_DT_ENDPOINT_SIZE, | 185 | .bLength = USB_DT_ENDPOINT_SIZE, |
186 | .bDescriptorType = USB_DT_ENDPOINT, | 186 | .bDescriptorType = USB_DT_ENDPOINT, |
187 | 187 | ||
@@ -189,7 +189,7 @@ static struct usb_endpoint_descriptor hs_in_desc __initdata = { | |||
189 | .wMaxPacketSize = __constant_cpu_to_le16(512), | 189 | .wMaxPacketSize = __constant_cpu_to_le16(512), |
190 | }; | 190 | }; |
191 | 191 | ||
192 | static struct usb_endpoint_descriptor hs_out_desc __initdata = { | 192 | static struct usb_endpoint_descriptor hs_subset_out_desc __initdata = { |
193 | .bLength = USB_DT_ENDPOINT_SIZE, | 193 | .bLength = USB_DT_ENDPOINT_SIZE, |
194 | .bDescriptorType = USB_DT_ENDPOINT, | 194 | .bDescriptorType = USB_DT_ENDPOINT, |
195 | 195 | ||
@@ -199,12 +199,12 @@ static struct usb_endpoint_descriptor hs_out_desc __initdata = { | |||
199 | 199 | ||
200 | static struct usb_descriptor_header *hs_eth_function[] __initdata = { | 200 | static struct usb_descriptor_header *hs_eth_function[] __initdata = { |
201 | (struct usb_descriptor_header *) &subset_data_intf, | 201 | (struct usb_descriptor_header *) &subset_data_intf, |
202 | (struct usb_descriptor_header *) &header_desc, | 202 | (struct usb_descriptor_header *) &mdlm_header_desc, |
203 | (struct usb_descriptor_header *) &mdlm_desc, | 203 | (struct usb_descriptor_header *) &mdlm_desc, |
204 | (struct usb_descriptor_header *) &mdlm_detail_desc, | 204 | (struct usb_descriptor_header *) &mdlm_detail_desc, |
205 | (struct usb_descriptor_header *) ðer_desc, | 205 | (struct usb_descriptor_header *) ðer_desc, |
206 | (struct usb_descriptor_header *) &hs_in_desc, | 206 | (struct usb_descriptor_header *) &hs_subset_in_desc, |
207 | (struct usb_descriptor_header *) &hs_out_desc, | 207 | (struct usb_descriptor_header *) &hs_subset_out_desc, |
208 | NULL, | 208 | NULL, |
209 | }; | 209 | }; |
210 | 210 | ||
@@ -281,13 +281,13 @@ geth_bind(struct usb_configuration *c, struct usb_function *f) | |||
281 | status = -ENODEV; | 281 | status = -ENODEV; |
282 | 282 | ||
283 | /* allocate instance-specific endpoints */ | 283 | /* allocate instance-specific endpoints */ |
284 | ep = usb_ep_autoconfig(cdev->gadget, &fs_in_desc); | 284 | ep = usb_ep_autoconfig(cdev->gadget, &fs_subset_in_desc); |
285 | if (!ep) | 285 | if (!ep) |
286 | goto fail; | 286 | goto fail; |
287 | geth->port.in_ep = ep; | 287 | geth->port.in_ep = ep; |
288 | ep->driver_data = cdev; /* claim */ | 288 | ep->driver_data = cdev; /* claim */ |
289 | 289 | ||
290 | ep = usb_ep_autoconfig(cdev->gadget, &fs_out_desc); | 290 | ep = usb_ep_autoconfig(cdev->gadget, &fs_subset_out_desc); |
291 | if (!ep) | 291 | if (!ep) |
292 | goto fail; | 292 | goto fail; |
293 | geth->port.out_ep = ep; | 293 | geth->port.out_ep = ep; |
@@ -297,9 +297,9 @@ geth_bind(struct usb_configuration *c, struct usb_function *f) | |||
297 | f->descriptors = usb_copy_descriptors(fs_eth_function); | 297 | f->descriptors = usb_copy_descriptors(fs_eth_function); |
298 | 298 | ||
299 | geth->fs.in = usb_find_endpoint(fs_eth_function, | 299 | geth->fs.in = usb_find_endpoint(fs_eth_function, |
300 | f->descriptors, &fs_in_desc); | 300 | f->descriptors, &fs_subset_in_desc); |
301 | geth->fs.out = usb_find_endpoint(fs_eth_function, | 301 | geth->fs.out = usb_find_endpoint(fs_eth_function, |
302 | f->descriptors, &fs_out_desc); | 302 | f->descriptors, &fs_subset_out_desc); |
303 | 303 | ||
304 | 304 | ||
305 | /* support all relevant hardware speeds... we expect that when | 305 | /* support all relevant hardware speeds... we expect that when |
@@ -307,18 +307,18 @@ geth_bind(struct usb_configuration *c, struct usb_function *f) | |||
307 | * both speeds | 307 | * both speeds |
308 | */ | 308 | */ |
309 | if (gadget_is_dualspeed(c->cdev->gadget)) { | 309 | if (gadget_is_dualspeed(c->cdev->gadget)) { |
310 | hs_in_desc.bEndpointAddress = | 310 | hs_subset_in_desc.bEndpointAddress = |
311 | fs_in_desc.bEndpointAddress; | 311 | fs_subset_in_desc.bEndpointAddress; |
312 | hs_out_desc.bEndpointAddress = | 312 | hs_subset_out_desc.bEndpointAddress = |
313 | fs_out_desc.bEndpointAddress; | 313 | fs_subset_out_desc.bEndpointAddress; |
314 | 314 | ||
315 | /* copy descriptors, and track endpoint copies */ | 315 | /* copy descriptors, and track endpoint copies */ |
316 | f->hs_descriptors = usb_copy_descriptors(hs_eth_function); | 316 | f->hs_descriptors = usb_copy_descriptors(hs_eth_function); |
317 | 317 | ||
318 | geth->hs.in = usb_find_endpoint(hs_eth_function, | 318 | geth->hs.in = usb_find_endpoint(hs_eth_function, |
319 | f->hs_descriptors, &hs_in_desc); | 319 | f->hs_descriptors, &hs_subset_in_desc); |
320 | geth->hs.out = usb_find_endpoint(hs_eth_function, | 320 | geth->hs.out = usb_find_endpoint(hs_eth_function, |
321 | f->hs_descriptors, &hs_out_desc); | 321 | f->hs_descriptors, &hs_subset_out_desc); |
322 | } | 322 | } |
323 | 323 | ||
324 | /* NOTE: all that is done without knowing or caring about | 324 | /* NOTE: all that is done without knowing or caring about |
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c index ea2c31d18080..c4e62a6297d7 100644 --- a/drivers/usb/gadget/file_storage.c +++ b/drivers/usb/gadget/file_storage.c | |||
@@ -245,6 +245,18 @@ | |||
245 | #include "gadget_chips.h" | 245 | #include "gadget_chips.h" |
246 | 246 | ||
247 | 247 | ||
248 | |||
249 | /* | ||
250 | * Kbuild is not very cooperative with respect to linking separately | ||
251 | * compiled library objects into one module. So for now we won't use | ||
252 | * separate compilation ... ensuring init/exit sections work to shrink | ||
253 | * the runtime footprint, and giving us at least some parts of what | ||
254 | * a "gcc --combine ... part1.c part2.c part3.c ... " build would. | ||
255 | */ | ||
256 | #include "usbstring.c" | ||
257 | #include "config.c" | ||
258 | #include "epautoconf.c" | ||
259 | |||
248 | /*-------------------------------------------------------------------------*/ | 260 | /*-------------------------------------------------------------------------*/ |
249 | 261 | ||
250 | #define DRIVER_DESC "File-backed Storage Gadget" | 262 | #define DRIVER_DESC "File-backed Storage Gadget" |
@@ -839,7 +851,7 @@ config_desc = { | |||
839 | .bConfigurationValue = CONFIG_VALUE, | 851 | .bConfigurationValue = CONFIG_VALUE, |
840 | .iConfiguration = STRING_CONFIG, | 852 | .iConfiguration = STRING_CONFIG, |
841 | .bmAttributes = USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER, | 853 | .bmAttributes = USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER, |
842 | .bMaxPower = 1, // self-powered | 854 | .bMaxPower = CONFIG_USB_GADGET_VBUS_DRAW / 2, |
843 | }; | 855 | }; |
844 | 856 | ||
845 | static struct usb_otg_descriptor | 857 | static struct usb_otg_descriptor |
@@ -2664,11 +2676,24 @@ static int check_command(struct fsg_dev *fsg, int cmnd_size, | |||
2664 | /* Verify the length of the command itself */ | 2676 | /* Verify the length of the command itself */ |
2665 | if (cmnd_size != fsg->cmnd_size) { | 2677 | if (cmnd_size != fsg->cmnd_size) { |
2666 | 2678 | ||
2667 | /* Special case workaround: MS-Windows issues REQUEST SENSE | 2679 | /* Special case workaround: There are plenty of buggy SCSI |
2668 | * with cbw->Length == 12 (it should be 6). */ | 2680 | * implementations. Many have issues with cbw->Length |
2669 | if (fsg->cmnd[0] == SC_REQUEST_SENSE && fsg->cmnd_size == 12) | 2681 | * field passing a wrong command size. For those cases we |
2682 | * always try to work around the problem by using the length | ||
2683 | * sent by the host side provided it is at least as large | ||
2684 | * as the correct command length. | ||
2685 | * Examples of such cases would be MS-Windows, which issues | ||
2686 | * REQUEST SENSE with cbw->Length == 12 where it should | ||
2687 | * be 6, and xbox360 issuing INQUIRY, TEST UNIT READY and | ||
2688 | * REQUEST SENSE with cbw->Length == 10 where it should | ||
2689 | * be 6 as well. | ||
2690 | */ | ||
2691 | if (cmnd_size <= fsg->cmnd_size) { | ||
2692 | DBG(fsg, "%s is buggy! Expected length %d " | ||
2693 | "but we got %d\n", name, | ||
2694 | cmnd_size, fsg->cmnd_size); | ||
2670 | cmnd_size = fsg->cmnd_size; | 2695 | cmnd_size = fsg->cmnd_size; |
2671 | else { | 2696 | } else { |
2672 | fsg->phase_error = 1; | 2697 | fsg->phase_error = 1; |
2673 | return -EINVAL; | 2698 | return -EINVAL; |
2674 | } | 2699 | } |
diff --git a/drivers/usb/gadget/fsl_qe_udc.c b/drivers/usb/gadget/fsl_qe_udc.c new file mode 100644 index 000000000000..1fe8b44787b3 --- /dev/null +++ b/drivers/usb/gadget/fsl_qe_udc.c | |||
@@ -0,0 +1,2760 @@ | |||
1 | /* | ||
2 | * driver/usb/gadget/fsl_qe_udc.c | ||
3 | * | ||
4 | * Copyright (c) 2006-2008 Freescale Semiconductor, Inc. All rights reserved. | ||
5 | * | ||
6 | * Xie Xiaobo <X.Xie@freescale.com> | ||
7 | * Li Yang <leoli@freescale.com> | ||
8 | * Based on bareboard code from Shlomi Gridish. | ||
9 | * | ||
10 | * Description: | ||
11 | * Freescle QE/CPM USB Pheripheral Controller Driver | ||
12 | * The controller can be found on MPC8360, MPC8272, and etc. | ||
13 | * MPC8360 Rev 1.1 may need QE mircocode update | ||
14 | * | ||
15 | * This program is free software; you can redistribute it and/or modify it | ||
16 | * under the terms of the GNU General Public License as published by the | ||
17 | * Free Software Foundation; either version 2 of the License, or (at your | ||
18 | * option) any later version. | ||
19 | */ | ||
20 | |||
21 | #undef USB_TRACE | ||
22 | |||
23 | #include <linux/module.h> | ||
24 | #include <linux/kernel.h> | ||
25 | #include <linux/init.h> | ||
26 | #include <linux/ioport.h> | ||
27 | #include <linux/types.h> | ||
28 | #include <linux/errno.h> | ||
29 | #include <linux/slab.h> | ||
30 | #include <linux/list.h> | ||
31 | #include <linux/interrupt.h> | ||
32 | #include <linux/io.h> | ||
33 | #include <linux/moduleparam.h> | ||
34 | #include <linux/of_platform.h> | ||
35 | #include <linux/dma-mapping.h> | ||
36 | #include <linux/usb/ch9.h> | ||
37 | #include <linux/usb/gadget.h> | ||
38 | #include <linux/usb/otg.h> | ||
39 | #include <asm/qe.h> | ||
40 | #include <asm/cpm.h> | ||
41 | #include <asm/dma.h> | ||
42 | #include <asm/reg.h> | ||
43 | #include "fsl_qe_udc.h" | ||
44 | |||
45 | #define DRIVER_DESC "Freescale QE/CPM USB Device Controller driver" | ||
46 | #define DRIVER_AUTHOR "Xie XiaoBo" | ||
47 | #define DRIVER_VERSION "1.0" | ||
48 | |||
49 | #define DMA_ADDR_INVALID (~(dma_addr_t)0) | ||
50 | |||
51 | static const char driver_name[] = "fsl_qe_udc"; | ||
52 | static const char driver_desc[] = DRIVER_DESC; | ||
53 | |||
54 | /*ep name is important in gadget, it should obey the convention of ep_match()*/ | ||
55 | static const char *const ep_name[] = { | ||
56 | "ep0-control", /* everyone has ep0 */ | ||
57 | /* 3 configurable endpoints */ | ||
58 | "ep1", | ||
59 | "ep2", | ||
60 | "ep3", | ||
61 | }; | ||
62 | |||
63 | static struct usb_endpoint_descriptor qe_ep0_desc = { | ||
64 | .bLength = USB_DT_ENDPOINT_SIZE, | ||
65 | .bDescriptorType = USB_DT_ENDPOINT, | ||
66 | |||
67 | .bEndpointAddress = 0, | ||
68 | .bmAttributes = USB_ENDPOINT_XFER_CONTROL, | ||
69 | .wMaxPacketSize = USB_MAX_CTRL_PAYLOAD, | ||
70 | }; | ||
71 | |||
72 | /* it is initialized in probe() */ | ||
73 | static struct qe_udc *udc_controller; | ||
74 | |||
75 | /******************************************************************** | ||
76 | * Internal Used Function Start | ||
77 | ********************************************************************/ | ||
78 | /*----------------------------------------------------------------- | ||
79 | * done() - retire a request; caller blocked irqs | ||
80 | *--------------------------------------------------------------*/ | ||
81 | static void done(struct qe_ep *ep, struct qe_req *req, int status) | ||
82 | { | ||
83 | struct qe_udc *udc = ep->udc; | ||
84 | unsigned char stopped = ep->stopped; | ||
85 | |||
86 | /* the req->queue pointer is used by ep_queue() func, in which | ||
87 | * the request will be added into a udc_ep->queue 'd tail | ||
88 | * so here the req will be dropped from the ep->queue | ||
89 | */ | ||
90 | list_del_init(&req->queue); | ||
91 | |||
92 | /* req.status should be set as -EINPROGRESS in ep_queue() */ | ||
93 | if (req->req.status == -EINPROGRESS) | ||
94 | req->req.status = status; | ||
95 | else | ||
96 | status = req->req.status; | ||
97 | |||
98 | if (req->mapped) { | ||
99 | dma_unmap_single(udc->gadget.dev.parent, | ||
100 | req->req.dma, req->req.length, | ||
101 | ep_is_in(ep) | ||
102 | ? DMA_TO_DEVICE | ||
103 | : DMA_FROM_DEVICE); | ||
104 | req->req.dma = DMA_ADDR_INVALID; | ||
105 | req->mapped = 0; | ||
106 | } else | ||
107 | dma_sync_single_for_cpu(udc->gadget.dev.parent, | ||
108 | req->req.dma, req->req.length, | ||
109 | ep_is_in(ep) | ||
110 | ? DMA_TO_DEVICE | ||
111 | : DMA_FROM_DEVICE); | ||
112 | |||
113 | if (status && (status != -ESHUTDOWN)) | ||
114 | dev_vdbg(udc->dev, "complete %s req %p stat %d len %u/%u\n", | ||
115 | ep->ep.name, &req->req, status, | ||
116 | req->req.actual, req->req.length); | ||
117 | |||
118 | /* don't modify queue heads during completion callback */ | ||
119 | ep->stopped = 1; | ||
120 | spin_unlock(&udc->lock); | ||
121 | |||
122 | /* this complete() should a func implemented by gadget layer, | ||
123 | * eg fsg->bulk_in_complete() */ | ||
124 | if (req->req.complete) | ||
125 | req->req.complete(&ep->ep, &req->req); | ||
126 | |||
127 | spin_lock(&udc->lock); | ||
128 | |||
129 | ep->stopped = stopped; | ||
130 | } | ||
131 | |||
132 | /*----------------------------------------------------------------- | ||
133 | * nuke(): delete all requests related to this ep | ||
134 | *--------------------------------------------------------------*/ | ||
135 | static void nuke(struct qe_ep *ep, int status) | ||
136 | { | ||
137 | /* Whether this eq has request linked */ | ||
138 | while (!list_empty(&ep->queue)) { | ||
139 | struct qe_req *req = NULL; | ||
140 | req = list_entry(ep->queue.next, struct qe_req, queue); | ||
141 | |||
142 | done(ep, req, status); | ||
143 | } | ||
144 | } | ||
145 | |||
146 | /*---------------------------------------------------------------------------* | ||
147 | * USB and Endpoint manipulate process, include parameter and register * | ||
148 | *---------------------------------------------------------------------------*/ | ||
149 | /* @value: 1--set stall 0--clean stall */ | ||
150 | static int qe_eprx_stall_change(struct qe_ep *ep, int value) | ||
151 | { | ||
152 | u16 tem_usep; | ||
153 | u8 epnum = ep->epnum; | ||
154 | struct qe_udc *udc = ep->udc; | ||
155 | |||
156 | tem_usep = in_be16(&udc->usb_regs->usb_usep[epnum]); | ||
157 | tem_usep = tem_usep & ~USB_RHS_MASK; | ||
158 | if (value == 1) | ||
159 | tem_usep |= USB_RHS_STALL; | ||
160 | else if (ep->dir == USB_DIR_IN) | ||
161 | tem_usep |= USB_RHS_IGNORE_OUT; | ||
162 | |||
163 | out_be16(&udc->usb_regs->usb_usep[epnum], tem_usep); | ||
164 | return 0; | ||
165 | } | ||
166 | |||
167 | static int qe_eptx_stall_change(struct qe_ep *ep, int value) | ||
168 | { | ||
169 | u16 tem_usep; | ||
170 | u8 epnum = ep->epnum; | ||
171 | struct qe_udc *udc = ep->udc; | ||
172 | |||
173 | tem_usep = in_be16(&udc->usb_regs->usb_usep[epnum]); | ||
174 | tem_usep = tem_usep & ~USB_THS_MASK; | ||
175 | if (value == 1) | ||
176 | tem_usep |= USB_THS_STALL; | ||
177 | else if (ep->dir == USB_DIR_OUT) | ||
178 | tem_usep |= USB_THS_IGNORE_IN; | ||
179 | |||
180 | out_be16(&udc->usb_regs->usb_usep[epnum], tem_usep); | ||
181 | |||
182 | return 0; | ||
183 | } | ||
184 | |||
185 | static int qe_ep0_stall(struct qe_udc *udc) | ||
186 | { | ||
187 | qe_eptx_stall_change(&udc->eps[0], 1); | ||
188 | qe_eprx_stall_change(&udc->eps[0], 1); | ||
189 | udc_controller->ep0_state = WAIT_FOR_SETUP; | ||
190 | udc_controller->ep0_dir = 0; | ||
191 | return 0; | ||
192 | } | ||
193 | |||
194 | static int qe_eprx_nack(struct qe_ep *ep) | ||
195 | { | ||
196 | u8 epnum = ep->epnum; | ||
197 | struct qe_udc *udc = ep->udc; | ||
198 | |||
199 | if (ep->state == EP_STATE_IDLE) { | ||
200 | /* Set the ep's nack */ | ||
201 | clrsetbits_be16(&udc->usb_regs->usb_usep[epnum], | ||
202 | USB_RHS_MASK, USB_RHS_NACK); | ||
203 | |||
204 | /* Mask Rx and Busy interrupts */ | ||
205 | clrbits16(&udc->usb_regs->usb_usbmr, | ||
206 | (USB_E_RXB_MASK | USB_E_BSY_MASK)); | ||
207 | |||
208 | ep->state = EP_STATE_NACK; | ||
209 | } | ||
210 | return 0; | ||
211 | } | ||
212 | |||
213 | static int qe_eprx_normal(struct qe_ep *ep) | ||
214 | { | ||
215 | struct qe_udc *udc = ep->udc; | ||
216 | |||
217 | if (ep->state == EP_STATE_NACK) { | ||
218 | clrsetbits_be16(&udc->usb_regs->usb_usep[ep->epnum], | ||
219 | USB_RTHS_MASK, USB_THS_IGNORE_IN); | ||
220 | |||
221 | /* Unmask RX interrupts */ | ||
222 | out_be16(&udc->usb_regs->usb_usber, | ||
223 | USB_E_BSY_MASK | USB_E_RXB_MASK); | ||
224 | setbits16(&udc->usb_regs->usb_usbmr, | ||
225 | (USB_E_RXB_MASK | USB_E_BSY_MASK)); | ||
226 | |||
227 | ep->state = EP_STATE_IDLE; | ||
228 | ep->has_data = 0; | ||
229 | } | ||
230 | |||
231 | return 0; | ||
232 | } | ||
233 | |||
234 | static int qe_ep_cmd_stoptx(struct qe_ep *ep) | ||
235 | { | ||
236 | if (ep->udc->soc_type == PORT_CPM) | ||
237 | cpm_command(CPM_USB_STOP_TX | (ep->epnum << CPM_USB_EP_SHIFT), | ||
238 | CPM_USB_STOP_TX_OPCODE); | ||
239 | else | ||
240 | qe_issue_cmd(QE_USB_STOP_TX, QE_CR_SUBBLOCK_USB, | ||
241 | ep->epnum, 0); | ||
242 | |||
243 | return 0; | ||
244 | } | ||
245 | |||
246 | static int qe_ep_cmd_restarttx(struct qe_ep *ep) | ||
247 | { | ||
248 | if (ep->udc->soc_type == PORT_CPM) | ||
249 | cpm_command(CPM_USB_RESTART_TX | (ep->epnum << | ||
250 | CPM_USB_EP_SHIFT), CPM_USB_RESTART_TX_OPCODE); | ||
251 | else | ||
252 | qe_issue_cmd(QE_USB_RESTART_TX, QE_CR_SUBBLOCK_USB, | ||
253 | ep->epnum, 0); | ||
254 | |||
255 | return 0; | ||
256 | } | ||
257 | |||
258 | static int qe_ep_flushtxfifo(struct qe_ep *ep) | ||
259 | { | ||
260 | struct qe_udc *udc = ep->udc; | ||
261 | int i; | ||
262 | |||
263 | i = (int)ep->epnum; | ||
264 | |||
265 | qe_ep_cmd_stoptx(ep); | ||
266 | out_8(&udc->usb_regs->usb_uscom, | ||
267 | USB_CMD_FLUSH_FIFO | (USB_CMD_EP_MASK & (ep->epnum))); | ||
268 | out_be16(&udc->ep_param[i]->tbptr, in_be16(&udc->ep_param[i]->tbase)); | ||
269 | out_be32(&udc->ep_param[i]->tstate, 0); | ||
270 | out_be16(&udc->ep_param[i]->tbcnt, 0); | ||
271 | |||
272 | ep->c_txbd = ep->txbase; | ||
273 | ep->n_txbd = ep->txbase; | ||
274 | qe_ep_cmd_restarttx(ep); | ||
275 | return 0; | ||
276 | } | ||
277 | |||
278 | static int qe_ep_filltxfifo(struct qe_ep *ep) | ||
279 | { | ||
280 | struct qe_udc *udc = ep->udc; | ||
281 | |||
282 | out_8(&udc->usb_regs->usb_uscom, | ||
283 | USB_CMD_STR_FIFO | (USB_CMD_EP_MASK & (ep->epnum))); | ||
284 | return 0; | ||
285 | } | ||
286 | |||
287 | static int qe_epbds_reset(struct qe_udc *udc, int pipe_num) | ||
288 | { | ||
289 | struct qe_ep *ep; | ||
290 | u32 bdring_len; | ||
291 | struct qe_bd __iomem *bd; | ||
292 | int i; | ||
293 | |||
294 | ep = &udc->eps[pipe_num]; | ||
295 | |||
296 | if (ep->dir == USB_DIR_OUT) | ||
297 | bdring_len = USB_BDRING_LEN_RX; | ||
298 | else | ||
299 | bdring_len = USB_BDRING_LEN; | ||
300 | |||
301 | bd = ep->rxbase; | ||
302 | for (i = 0; i < (bdring_len - 1); i++) { | ||
303 | out_be32((u32 __iomem *)bd, R_E | R_I); | ||
304 | bd++; | ||
305 | } | ||
306 | out_be32((u32 __iomem *)bd, R_E | R_I | R_W); | ||
307 | |||
308 | bd = ep->txbase; | ||
309 | for (i = 0; i < USB_BDRING_LEN_TX - 1; i++) { | ||
310 | out_be32(&bd->buf, 0); | ||
311 | out_be32((u32 __iomem *)bd, 0); | ||
312 | bd++; | ||
313 | } | ||
314 | out_be32((u32 __iomem *)bd, T_W); | ||
315 | |||
316 | return 0; | ||
317 | } | ||
318 | |||
319 | static int qe_ep_reset(struct qe_udc *udc, int pipe_num) | ||
320 | { | ||
321 | struct qe_ep *ep; | ||
322 | u16 tmpusep; | ||
323 | |||
324 | ep = &udc->eps[pipe_num]; | ||
325 | tmpusep = in_be16(&udc->usb_regs->usb_usep[pipe_num]); | ||
326 | tmpusep &= ~USB_RTHS_MASK; | ||
327 | |||
328 | switch (ep->dir) { | ||
329 | case USB_DIR_BOTH: | ||
330 | qe_ep_flushtxfifo(ep); | ||
331 | break; | ||
332 | case USB_DIR_OUT: | ||
333 | tmpusep |= USB_THS_IGNORE_IN; | ||
334 | break; | ||
335 | case USB_DIR_IN: | ||
336 | qe_ep_flushtxfifo(ep); | ||
337 | tmpusep |= USB_RHS_IGNORE_OUT; | ||
338 | break; | ||
339 | default: | ||
340 | break; | ||
341 | } | ||
342 | out_be16(&udc->usb_regs->usb_usep[pipe_num], tmpusep); | ||
343 | |||
344 | qe_epbds_reset(udc, pipe_num); | ||
345 | |||
346 | return 0; | ||
347 | } | ||
348 | |||
349 | static int qe_ep_toggledata01(struct qe_ep *ep) | ||
350 | { | ||
351 | ep->data01 ^= 0x1; | ||
352 | return 0; | ||
353 | } | ||
354 | |||
355 | static int qe_ep_bd_init(struct qe_udc *udc, unsigned char pipe_num) | ||
356 | { | ||
357 | struct qe_ep *ep = &udc->eps[pipe_num]; | ||
358 | unsigned long tmp_addr = 0; | ||
359 | struct usb_ep_para __iomem *epparam; | ||
360 | int i; | ||
361 | struct qe_bd __iomem *bd; | ||
362 | int bdring_len; | ||
363 | |||
364 | if (ep->dir == USB_DIR_OUT) | ||
365 | bdring_len = USB_BDRING_LEN_RX; | ||
366 | else | ||
367 | bdring_len = USB_BDRING_LEN; | ||
368 | |||
369 | epparam = udc->ep_param[pipe_num]; | ||
370 | /* alloc multi-ram for BD rings and set the ep parameters */ | ||
371 | tmp_addr = cpm_muram_alloc(sizeof(struct qe_bd) * (bdring_len + | ||
372 | USB_BDRING_LEN_TX), QE_ALIGNMENT_OF_BD); | ||
373 | out_be16(&epparam->rbase, (u16)tmp_addr); | ||
374 | out_be16(&epparam->tbase, (u16)(tmp_addr + | ||
375 | (sizeof(struct qe_bd) * bdring_len))); | ||
376 | |||
377 | out_be16(&epparam->rbptr, in_be16(&epparam->rbase)); | ||
378 | out_be16(&epparam->tbptr, in_be16(&epparam->tbase)); | ||
379 | |||
380 | ep->rxbase = cpm_muram_addr(tmp_addr); | ||
381 | ep->txbase = cpm_muram_addr(tmp_addr + (sizeof(struct qe_bd) | ||
382 | * bdring_len)); | ||
383 | ep->n_rxbd = ep->rxbase; | ||
384 | ep->e_rxbd = ep->rxbase; | ||
385 | ep->n_txbd = ep->txbase; | ||
386 | ep->c_txbd = ep->txbase; | ||
387 | ep->data01 = 0; /* data0 */ | ||
388 | |||
389 | /* Init TX and RX bds */ | ||
390 | bd = ep->rxbase; | ||
391 | for (i = 0; i < bdring_len - 1; i++) { | ||
392 | out_be32(&bd->buf, 0); | ||
393 | out_be32((u32 __iomem *)bd, 0); | ||
394 | bd++; | ||
395 | } | ||
396 | out_be32(&bd->buf, 0); | ||
397 | out_be32((u32 __iomem *)bd, R_W); | ||
398 | |||
399 | bd = ep->txbase; | ||
400 | for (i = 0; i < USB_BDRING_LEN_TX - 1; i++) { | ||
401 | out_be32(&bd->buf, 0); | ||
402 | out_be32((u32 __iomem *)bd, 0); | ||
403 | bd++; | ||
404 | } | ||
405 | out_be32(&bd->buf, 0); | ||
406 | out_be32((u32 __iomem *)bd, T_W); | ||
407 | |||
408 | return 0; | ||
409 | } | ||
410 | |||
411 | static int qe_ep_rxbd_update(struct qe_ep *ep) | ||
412 | { | ||
413 | unsigned int size; | ||
414 | int i; | ||
415 | unsigned int tmp; | ||
416 | struct qe_bd __iomem *bd; | ||
417 | unsigned int bdring_len; | ||
418 | |||
419 | if (ep->rxbase == NULL) | ||
420 | return -EINVAL; | ||
421 | |||
422 | bd = ep->rxbase; | ||
423 | |||
424 | ep->rxframe = kmalloc(sizeof(*ep->rxframe), GFP_ATOMIC); | ||
425 | if (ep->rxframe == NULL) { | ||
426 | dev_err(ep->udc->dev, "malloc rxframe failed\n"); | ||
427 | return -ENOMEM; | ||
428 | } | ||
429 | |||
430 | qe_frame_init(ep->rxframe); | ||
431 | |||
432 | if (ep->dir == USB_DIR_OUT) | ||
433 | bdring_len = USB_BDRING_LEN_RX; | ||
434 | else | ||
435 | bdring_len = USB_BDRING_LEN; | ||
436 | |||
437 | size = (ep->ep.maxpacket + USB_CRC_SIZE + 2) * (bdring_len + 1); | ||
438 | ep->rxbuffer = kzalloc(size, GFP_ATOMIC); | ||
439 | if (ep->rxbuffer == NULL) { | ||
440 | dev_err(ep->udc->dev, "malloc rxbuffer failed,size=%d\n", | ||
441 | size); | ||
442 | kfree(ep->rxframe); | ||
443 | return -ENOMEM; | ||
444 | } | ||
445 | |||
446 | ep->rxbuf_d = virt_to_phys((void *)ep->rxbuffer); | ||
447 | if (ep->rxbuf_d == DMA_ADDR_INVALID) { | ||
448 | ep->rxbuf_d = dma_map_single(udc_controller->gadget.dev.parent, | ||
449 | ep->rxbuffer, | ||
450 | size, | ||
451 | DMA_FROM_DEVICE); | ||
452 | ep->rxbufmap = 1; | ||
453 | } else { | ||
454 | dma_sync_single_for_device(udc_controller->gadget.dev.parent, | ||
455 | ep->rxbuf_d, size, | ||
456 | DMA_FROM_DEVICE); | ||
457 | ep->rxbufmap = 0; | ||
458 | } | ||
459 | |||
460 | size = ep->ep.maxpacket + USB_CRC_SIZE + 2; | ||
461 | tmp = ep->rxbuf_d; | ||
462 | tmp = (u32)(((tmp >> 2) << 2) + 4); | ||
463 | |||
464 | for (i = 0; i < bdring_len - 1; i++) { | ||
465 | out_be32(&bd->buf, tmp); | ||
466 | out_be32((u32 __iomem *)bd, (R_E | R_I)); | ||
467 | tmp = tmp + size; | ||
468 | bd++; | ||
469 | } | ||
470 | out_be32(&bd->buf, tmp); | ||
471 | out_be32((u32 __iomem *)bd, (R_E | R_I | R_W)); | ||
472 | |||
473 | return 0; | ||
474 | } | ||
475 | |||
476 | static int qe_ep_register_init(struct qe_udc *udc, unsigned char pipe_num) | ||
477 | { | ||
478 | struct qe_ep *ep = &udc->eps[pipe_num]; | ||
479 | struct usb_ep_para __iomem *epparam; | ||
480 | u16 usep, logepnum; | ||
481 | u16 tmp; | ||
482 | u8 rtfcr = 0; | ||
483 | |||
484 | epparam = udc->ep_param[pipe_num]; | ||
485 | |||
486 | usep = 0; | ||
487 | logepnum = (ep->desc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); | ||
488 | usep |= (logepnum << USB_EPNUM_SHIFT); | ||
489 | |||
490 | switch (ep->desc->bmAttributes & 0x03) { | ||
491 | case USB_ENDPOINT_XFER_BULK: | ||
492 | usep |= USB_TRANS_BULK; | ||
493 | break; | ||
494 | case USB_ENDPOINT_XFER_ISOC: | ||
495 | usep |= USB_TRANS_ISO; | ||
496 | break; | ||
497 | case USB_ENDPOINT_XFER_INT: | ||
498 | usep |= USB_TRANS_INT; | ||
499 | break; | ||
500 | default: | ||
501 | usep |= USB_TRANS_CTR; | ||
502 | break; | ||
503 | } | ||
504 | |||
505 | switch (ep->dir) { | ||
506 | case USB_DIR_OUT: | ||
507 | usep |= USB_THS_IGNORE_IN; | ||
508 | break; | ||
509 | case USB_DIR_IN: | ||
510 | usep |= USB_RHS_IGNORE_OUT; | ||
511 | break; | ||
512 | default: | ||
513 | break; | ||
514 | } | ||
515 | out_be16(&udc->usb_regs->usb_usep[pipe_num], usep); | ||
516 | |||
517 | rtfcr = 0x30; | ||
518 | out_8(&epparam->rbmr, rtfcr); | ||
519 | out_8(&epparam->tbmr, rtfcr); | ||
520 | |||
521 | tmp = (u16)(ep->ep.maxpacket + USB_CRC_SIZE); | ||
522 | /* MRBLR must be divisble by 4 */ | ||
523 | tmp = (u16)(((tmp >> 2) << 2) + 4); | ||
524 | out_be16(&epparam->mrblr, tmp); | ||
525 | |||
526 | return 0; | ||
527 | } | ||
528 | |||
529 | static int qe_ep_init(struct qe_udc *udc, | ||
530 | unsigned char pipe_num, | ||
531 | const struct usb_endpoint_descriptor *desc) | ||
532 | { | ||
533 | struct qe_ep *ep = &udc->eps[pipe_num]; | ||
534 | unsigned long flags; | ||
535 | int reval = 0; | ||
536 | u16 max = 0; | ||
537 | |||
538 | max = le16_to_cpu(desc->wMaxPacketSize); | ||
539 | |||
540 | /* check the max package size validate for this endpoint */ | ||
541 | /* Refer to USB2.0 spec table 9-13, | ||
542 | */ | ||
543 | if (pipe_num != 0) { | ||
544 | switch (desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) { | ||
545 | case USB_ENDPOINT_XFER_BULK: | ||
546 | if (strstr(ep->ep.name, "-iso") | ||
547 | || strstr(ep->ep.name, "-int")) | ||
548 | goto en_done; | ||
549 | switch (udc->gadget.speed) { | ||
550 | case USB_SPEED_HIGH: | ||
551 | if ((max == 128) || (max == 256) || (max == 512)) | ||
552 | break; | ||
553 | default: | ||
554 | switch (max) { | ||
555 | case 4: | ||
556 | case 8: | ||
557 | case 16: | ||
558 | case 32: | ||
559 | case 64: | ||
560 | break; | ||
561 | default: | ||
562 | case USB_SPEED_LOW: | ||
563 | goto en_done; | ||
564 | } | ||
565 | } | ||
566 | break; | ||
567 | case USB_ENDPOINT_XFER_INT: | ||
568 | if (strstr(ep->ep.name, "-iso")) /* bulk is ok */ | ||
569 | goto en_done; | ||
570 | switch (udc->gadget.speed) { | ||
571 | case USB_SPEED_HIGH: | ||
572 | if (max <= 1024) | ||
573 | break; | ||
574 | case USB_SPEED_FULL: | ||
575 | if (max <= 64) | ||
576 | break; | ||
577 | default: | ||
578 | if (max <= 8) | ||
579 | break; | ||
580 | goto en_done; | ||
581 | } | ||
582 | break; | ||
583 | case USB_ENDPOINT_XFER_ISOC: | ||
584 | if (strstr(ep->ep.name, "-bulk") | ||
585 | || strstr(ep->ep.name, "-int")) | ||
586 | goto en_done; | ||
587 | switch (udc->gadget.speed) { | ||
588 | case USB_SPEED_HIGH: | ||
589 | if (max <= 1024) | ||
590 | break; | ||
591 | case USB_SPEED_FULL: | ||
592 | if (max <= 1023) | ||
593 | break; | ||
594 | default: | ||
595 | goto en_done; | ||
596 | } | ||
597 | break; | ||
598 | case USB_ENDPOINT_XFER_CONTROL: | ||
599 | if (strstr(ep->ep.name, "-iso") | ||
600 | || strstr(ep->ep.name, "-int")) | ||
601 | goto en_done; | ||
602 | switch (udc->gadget.speed) { | ||
603 | case USB_SPEED_HIGH: | ||
604 | case USB_SPEED_FULL: | ||
605 | switch (max) { | ||
606 | case 1: | ||
607 | case 2: | ||
608 | case 4: | ||
609 | case 8: | ||
610 | case 16: | ||
611 | case 32: | ||
612 | case 64: | ||
613 | break; | ||
614 | default: | ||
615 | goto en_done; | ||
616 | } | ||
617 | case USB_SPEED_LOW: | ||
618 | switch (max) { | ||
619 | case 1: | ||
620 | case 2: | ||
621 | case 4: | ||
622 | case 8: | ||
623 | break; | ||
624 | default: | ||
625 | goto en_done; | ||
626 | } | ||
627 | default: | ||
628 | goto en_done; | ||
629 | } | ||
630 | break; | ||
631 | |||
632 | default: | ||
633 | goto en_done; | ||
634 | } | ||
635 | } /* if ep0*/ | ||
636 | |||
637 | spin_lock_irqsave(&udc->lock, flags); | ||
638 | |||
639 | /* initialize ep structure */ | ||
640 | ep->ep.maxpacket = max; | ||
641 | ep->tm = (u8)(desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK); | ||
642 | ep->desc = desc; | ||
643 | ep->stopped = 0; | ||
644 | ep->init = 1; | ||
645 | |||
646 | if (pipe_num == 0) { | ||
647 | ep->dir = USB_DIR_BOTH; | ||
648 | udc->ep0_dir = USB_DIR_OUT; | ||
649 | udc->ep0_state = WAIT_FOR_SETUP; | ||
650 | } else { | ||
651 | switch (desc->bEndpointAddress & USB_ENDPOINT_DIR_MASK) { | ||
652 | case USB_DIR_OUT: | ||
653 | ep->dir = USB_DIR_OUT; | ||
654 | break; | ||
655 | case USB_DIR_IN: | ||
656 | ep->dir = USB_DIR_IN; | ||
657 | default: | ||
658 | break; | ||
659 | } | ||
660 | } | ||
661 | |||
662 | /* hardware special operation */ | ||
663 | qe_ep_bd_init(udc, pipe_num); | ||
664 | if ((ep->tm == USBP_TM_CTL) || (ep->dir == USB_DIR_OUT)) { | ||
665 | reval = qe_ep_rxbd_update(ep); | ||
666 | if (reval) | ||
667 | goto en_done1; | ||
668 | } | ||
669 | |||
670 | if ((ep->tm == USBP_TM_CTL) || (ep->dir == USB_DIR_IN)) { | ||
671 | ep->txframe = kmalloc(sizeof(*ep->txframe), GFP_ATOMIC); | ||
672 | if (ep->txframe == NULL) { | ||
673 | dev_err(udc->dev, "malloc txframe failed\n"); | ||
674 | goto en_done2; | ||
675 | } | ||
676 | qe_frame_init(ep->txframe); | ||
677 | } | ||
678 | |||
679 | qe_ep_register_init(udc, pipe_num); | ||
680 | |||
681 | /* Now HW will be NAKing transfers to that EP, | ||
682 | * until a buffer is queued to it. */ | ||
683 | spin_unlock_irqrestore(&udc->lock, flags); | ||
684 | |||
685 | return 0; | ||
686 | en_done2: | ||
687 | kfree(ep->rxbuffer); | ||
688 | kfree(ep->rxframe); | ||
689 | en_done1: | ||
690 | spin_unlock_irqrestore(&udc->lock, flags); | ||
691 | en_done: | ||
692 | dev_dbg(udc->dev, "failed to initialize %s\n", ep->ep.name); | ||
693 | return -ENODEV; | ||
694 | } | ||
695 | |||
696 | static inline void qe_usb_enable(void) | ||
697 | { | ||
698 | setbits8(&udc_controller->usb_regs->usb_usmod, USB_MODE_EN); | ||
699 | } | ||
700 | |||
701 | static inline void qe_usb_disable(void) | ||
702 | { | ||
703 | clrbits8(&udc_controller->usb_regs->usb_usmod, USB_MODE_EN); | ||
704 | } | ||
705 | |||
706 | /*----------------------------------------------------------------------------* | ||
707 | * USB and EP basic manipulate function end * | ||
708 | *----------------------------------------------------------------------------*/ | ||
709 | |||
710 | |||
711 | /****************************************************************************** | ||
712 | UDC transmit and receive process | ||
713 | ******************************************************************************/ | ||
714 | static void recycle_one_rxbd(struct qe_ep *ep) | ||
715 | { | ||
716 | u32 bdstatus; | ||
717 | |||
718 | bdstatus = in_be32((u32 __iomem *)ep->e_rxbd); | ||
719 | bdstatus = R_I | R_E | (bdstatus & R_W); | ||
720 | out_be32((u32 __iomem *)ep->e_rxbd, bdstatus); | ||
721 | |||
722 | if (bdstatus & R_W) | ||
723 | ep->e_rxbd = ep->rxbase; | ||
724 | else | ||
725 | ep->e_rxbd++; | ||
726 | } | ||
727 | |||
728 | static void recycle_rxbds(struct qe_ep *ep, unsigned char stopatnext) | ||
729 | { | ||
730 | u32 bdstatus; | ||
731 | struct qe_bd __iomem *bd, *nextbd; | ||
732 | unsigned char stop = 0; | ||
733 | |||
734 | nextbd = ep->n_rxbd; | ||
735 | bd = ep->e_rxbd; | ||
736 | bdstatus = in_be32((u32 __iomem *)bd); | ||
737 | |||
738 | while (!(bdstatus & R_E) && !(bdstatus & BD_LENGTH_MASK) && !stop) { | ||
739 | bdstatus = R_E | R_I | (bdstatus & R_W); | ||
740 | out_be32((u32 __iomem *)bd, bdstatus); | ||
741 | |||
742 | if (bdstatus & R_W) | ||
743 | bd = ep->rxbase; | ||
744 | else | ||
745 | bd++; | ||
746 | |||
747 | bdstatus = in_be32((u32 __iomem *)bd); | ||
748 | if (stopatnext && (bd == nextbd)) | ||
749 | stop = 1; | ||
750 | } | ||
751 | |||
752 | ep->e_rxbd = bd; | ||
753 | } | ||
754 | |||
755 | static void ep_recycle_rxbds(struct qe_ep *ep) | ||
756 | { | ||
757 | struct qe_bd __iomem *bd = ep->n_rxbd; | ||
758 | u32 bdstatus; | ||
759 | u8 epnum = ep->epnum; | ||
760 | struct qe_udc *udc = ep->udc; | ||
761 | |||
762 | bdstatus = in_be32((u32 __iomem *)bd); | ||
763 | if (!(bdstatus & R_E) && !(bdstatus & BD_LENGTH_MASK)) { | ||
764 | bd = ep->rxbase + | ||
765 | ((in_be16(&udc->ep_param[epnum]->rbptr) - | ||
766 | in_be16(&udc->ep_param[epnum]->rbase)) | ||
767 | >> 3); | ||
768 | bdstatus = in_be32((u32 __iomem *)bd); | ||
769 | |||
770 | if (bdstatus & R_W) | ||
771 | bd = ep->rxbase; | ||
772 | else | ||
773 | bd++; | ||
774 | |||
775 | ep->e_rxbd = bd; | ||
776 | recycle_rxbds(ep, 0); | ||
777 | ep->e_rxbd = ep->n_rxbd; | ||
778 | } else | ||
779 | recycle_rxbds(ep, 1); | ||
780 | |||
781 | if (in_be16(&udc->usb_regs->usb_usber) & USB_E_BSY_MASK) | ||
782 | out_be16(&udc->usb_regs->usb_usber, USB_E_BSY_MASK); | ||
783 | |||
784 | if (ep->has_data <= 0 && (!list_empty(&ep->queue))) | ||
785 | qe_eprx_normal(ep); | ||
786 | |||
787 | ep->localnack = 0; | ||
788 | } | ||
789 | |||
790 | static void setup_received_handle(struct qe_udc *udc, | ||
791 | struct usb_ctrlrequest *setup); | ||
792 | static int qe_ep_rxframe_handle(struct qe_ep *ep); | ||
793 | static void ep0_req_complete(struct qe_udc *udc, struct qe_req *req); | ||
794 | /* when BD PID is setup, handle the packet */ | ||
795 | static int ep0_setup_handle(struct qe_udc *udc) | ||
796 | { | ||
797 | struct qe_ep *ep = &udc->eps[0]; | ||
798 | struct qe_frame *pframe; | ||
799 | unsigned int fsize; | ||
800 | u8 *cp; | ||
801 | |||
802 | pframe = ep->rxframe; | ||
803 | if ((frame_get_info(pframe) & PID_SETUP) | ||
804 | && (udc->ep0_state == WAIT_FOR_SETUP)) { | ||
805 | fsize = frame_get_length(pframe); | ||
806 | if (unlikely(fsize != 8)) | ||
807 | return -EINVAL; | ||
808 | cp = (u8 *)&udc->local_setup_buff; | ||
809 | memcpy(cp, pframe->data, fsize); | ||
810 | ep->data01 = 1; | ||
811 | |||
812 | /* handle the usb command base on the usb_ctrlrequest */ | ||
813 | setup_received_handle(udc, &udc->local_setup_buff); | ||
814 | return 0; | ||
815 | } | ||
816 | return -EINVAL; | ||
817 | } | ||
818 | |||
819 | static int qe_ep0_rx(struct qe_udc *udc) | ||
820 | { | ||
821 | struct qe_ep *ep = &udc->eps[0]; | ||
822 | struct qe_frame *pframe; | ||
823 | struct qe_bd __iomem *bd; | ||
824 | u32 bdstatus, length; | ||
825 | u32 vaddr; | ||
826 | |||
827 | pframe = ep->rxframe; | ||
828 | |||
829 | if (ep->dir == USB_DIR_IN) { | ||
830 | dev_err(udc->dev, "ep0 not a control endpoint\n"); | ||
831 | return -EINVAL; | ||
832 | } | ||
833 | |||
834 | bd = ep->n_rxbd; | ||
835 | bdstatus = in_be32((u32 __iomem *)bd); | ||
836 | length = bdstatus & BD_LENGTH_MASK; | ||
837 | |||
838 | while (!(bdstatus & R_E) && length) { | ||
839 | if ((bdstatus & R_F) && (bdstatus & R_L) | ||
840 | && !(bdstatus & R_ERROR)) { | ||
841 | if (length == USB_CRC_SIZE) { | ||
842 | udc->ep0_state = WAIT_FOR_SETUP; | ||
843 | dev_vdbg(udc->dev, | ||
844 | "receive a ZLP in status phase\n"); | ||
845 | } else { | ||
846 | qe_frame_clean(pframe); | ||
847 | vaddr = (u32)phys_to_virt(in_be32(&bd->buf)); | ||
848 | frame_set_data(pframe, (u8 *)vaddr); | ||
849 | frame_set_length(pframe, | ||
850 | (length - USB_CRC_SIZE)); | ||
851 | frame_set_status(pframe, FRAME_OK); | ||
852 | switch (bdstatus & R_PID) { | ||
853 | case R_PID_SETUP: | ||
854 | frame_set_info(pframe, PID_SETUP); | ||
855 | break; | ||
856 | case R_PID_DATA1: | ||
857 | frame_set_info(pframe, PID_DATA1); | ||
858 | break; | ||
859 | default: | ||
860 | frame_set_info(pframe, PID_DATA0); | ||
861 | break; | ||
862 | } | ||
863 | |||
864 | if ((bdstatus & R_PID) == R_PID_SETUP) | ||
865 | ep0_setup_handle(udc); | ||
866 | else | ||
867 | qe_ep_rxframe_handle(ep); | ||
868 | } | ||
869 | } else { | ||
870 | dev_err(udc->dev, "The receive frame with error!\n"); | ||
871 | } | ||
872 | |||
873 | /* note: don't clear the rxbd's buffer address */ | ||
874 | recycle_one_rxbd(ep); | ||
875 | |||
876 | /* Get next BD */ | ||
877 | if (bdstatus & R_W) | ||
878 | bd = ep->rxbase; | ||
879 | else | ||
880 | bd++; | ||
881 | |||
882 | bdstatus = in_be32((u32 __iomem *)bd); | ||
883 | length = bdstatus & BD_LENGTH_MASK; | ||
884 | |||
885 | } | ||
886 | |||
887 | ep->n_rxbd = bd; | ||
888 | |||
889 | return 0; | ||
890 | } | ||
891 | |||
892 | static int qe_ep_rxframe_handle(struct qe_ep *ep) | ||
893 | { | ||
894 | struct qe_frame *pframe; | ||
895 | u8 framepid = 0; | ||
896 | unsigned int fsize; | ||
897 | u8 *cp; | ||
898 | struct qe_req *req; | ||
899 | |||
900 | pframe = ep->rxframe; | ||
901 | |||
902 | if (frame_get_info(pframe) & PID_DATA1) | ||
903 | framepid = 0x1; | ||
904 | |||
905 | if (framepid != ep->data01) { | ||
906 | dev_err(ep->udc->dev, "the data01 error!\n"); | ||
907 | return -EIO; | ||
908 | } | ||
909 | |||
910 | fsize = frame_get_length(pframe); | ||
911 | if (list_empty(&ep->queue)) { | ||
912 | dev_err(ep->udc->dev, "the %s have no requeue!\n", ep->name); | ||
913 | } else { | ||
914 | req = list_entry(ep->queue.next, struct qe_req, queue); | ||
915 | |||
916 | cp = (u8 *)(req->req.buf) + req->req.actual; | ||
917 | if (cp) { | ||
918 | memcpy(cp, pframe->data, fsize); | ||
919 | req->req.actual += fsize; | ||
920 | if ((fsize < ep->ep.maxpacket) || | ||
921 | (req->req.actual >= req->req.length)) { | ||
922 | if (ep->epnum == 0) | ||
923 | ep0_req_complete(ep->udc, req); | ||
924 | else | ||
925 | done(ep, req, 0); | ||
926 | if (list_empty(&ep->queue) && ep->epnum != 0) | ||
927 | qe_eprx_nack(ep); | ||
928 | } | ||
929 | } | ||
930 | } | ||
931 | |||
932 | qe_ep_toggledata01(ep); | ||
933 | |||
934 | return 0; | ||
935 | } | ||
936 | |||
937 | static void ep_rx_tasklet(unsigned long data) | ||
938 | { | ||
939 | struct qe_udc *udc = (struct qe_udc *)data; | ||
940 | struct qe_ep *ep; | ||
941 | struct qe_frame *pframe; | ||
942 | struct qe_bd __iomem *bd; | ||
943 | unsigned long flags; | ||
944 | u32 bdstatus, length; | ||
945 | u32 vaddr, i; | ||
946 | |||
947 | spin_lock_irqsave(&udc->lock, flags); | ||
948 | |||
949 | for (i = 1; i < USB_MAX_ENDPOINTS; i++) { | ||
950 | ep = &udc->eps[i]; | ||
951 | |||
952 | if (ep->dir == USB_DIR_IN || ep->enable_tasklet == 0) { | ||
953 | dev_dbg(udc->dev, | ||
954 | "This is a transmit ep or disable tasklet!\n"); | ||
955 | continue; | ||
956 | } | ||
957 | |||
958 | pframe = ep->rxframe; | ||
959 | bd = ep->n_rxbd; | ||
960 | bdstatus = in_be32((u32 __iomem *)bd); | ||
961 | length = bdstatus & BD_LENGTH_MASK; | ||
962 | |||
963 | while (!(bdstatus & R_E) && length) { | ||
964 | if (list_empty(&ep->queue)) { | ||
965 | qe_eprx_nack(ep); | ||
966 | dev_dbg(udc->dev, | ||
967 | "The rxep have noreq %d\n", | ||
968 | ep->has_data); | ||
969 | break; | ||
970 | } | ||
971 | |||
972 | if ((bdstatus & R_F) && (bdstatus & R_L) | ||
973 | && !(bdstatus & R_ERROR)) { | ||
974 | qe_frame_clean(pframe); | ||
975 | vaddr = (u32)phys_to_virt(in_be32(&bd->buf)); | ||
976 | frame_set_data(pframe, (u8 *)vaddr); | ||
977 | frame_set_length(pframe, | ||
978 | (length - USB_CRC_SIZE)); | ||
979 | frame_set_status(pframe, FRAME_OK); | ||
980 | switch (bdstatus & R_PID) { | ||
981 | case R_PID_DATA1: | ||
982 | frame_set_info(pframe, PID_DATA1); | ||
983 | break; | ||
984 | case R_PID_SETUP: | ||
985 | frame_set_info(pframe, PID_SETUP); | ||
986 | break; | ||
987 | default: | ||
988 | frame_set_info(pframe, PID_DATA0); | ||
989 | break; | ||
990 | } | ||
991 | /* handle the rx frame */ | ||
992 | qe_ep_rxframe_handle(ep); | ||
993 | } else { | ||
994 | dev_err(udc->dev, | ||
995 | "error in received frame\n"); | ||
996 | } | ||
997 | /* note: don't clear the rxbd's buffer address */ | ||
998 | /*clear the length */ | ||
999 | out_be32((u32 __iomem *)bd, bdstatus & BD_STATUS_MASK); | ||
1000 | ep->has_data--; | ||
1001 | if (!(ep->localnack)) | ||
1002 | recycle_one_rxbd(ep); | ||
1003 | |||
1004 | /* Get next BD */ | ||
1005 | if (bdstatus & R_W) | ||
1006 | bd = ep->rxbase; | ||
1007 | else | ||
1008 | bd++; | ||
1009 | |||
1010 | bdstatus = in_be32((u32 __iomem *)bd); | ||
1011 | length = bdstatus & BD_LENGTH_MASK; | ||
1012 | } | ||
1013 | |||
1014 | ep->n_rxbd = bd; | ||
1015 | |||
1016 | if (ep->localnack) | ||
1017 | ep_recycle_rxbds(ep); | ||
1018 | |||
1019 | ep->enable_tasklet = 0; | ||
1020 | } /* for i=1 */ | ||
1021 | |||
1022 | spin_unlock_irqrestore(&udc->lock, flags); | ||
1023 | } | ||
1024 | |||
1025 | static int qe_ep_rx(struct qe_ep *ep) | ||
1026 | { | ||
1027 | struct qe_udc *udc; | ||
1028 | struct qe_frame *pframe; | ||
1029 | struct qe_bd __iomem *bd; | ||
1030 | u16 swoffs, ucoffs, emptybds; | ||
1031 | |||
1032 | udc = ep->udc; | ||
1033 | pframe = ep->rxframe; | ||
1034 | |||
1035 | if (ep->dir == USB_DIR_IN) { | ||
1036 | dev_err(udc->dev, "transmit ep in rx function\n"); | ||
1037 | return -EINVAL; | ||
1038 | } | ||
1039 | |||
1040 | bd = ep->n_rxbd; | ||
1041 | |||
1042 | swoffs = (u16)(bd - ep->rxbase); | ||
1043 | ucoffs = (u16)((in_be16(&udc->ep_param[ep->epnum]->rbptr) - | ||
1044 | in_be16(&udc->ep_param[ep->epnum]->rbase)) >> 3); | ||
1045 | if (swoffs < ucoffs) | ||
1046 | emptybds = USB_BDRING_LEN_RX - ucoffs + swoffs; | ||
1047 | else | ||
1048 | emptybds = swoffs - ucoffs; | ||
1049 | |||
1050 | if (emptybds < MIN_EMPTY_BDS) { | ||
1051 | qe_eprx_nack(ep); | ||
1052 | ep->localnack = 1; | ||
1053 | dev_vdbg(udc->dev, "%d empty bds, send NACK\n", emptybds); | ||
1054 | } | ||
1055 | ep->has_data = USB_BDRING_LEN_RX - emptybds; | ||
1056 | |||
1057 | if (list_empty(&ep->queue)) { | ||
1058 | qe_eprx_nack(ep); | ||
1059 | dev_vdbg(udc->dev, "The rxep have no req queued with %d BDs\n", | ||
1060 | ep->has_data); | ||
1061 | return 0; | ||
1062 | } | ||
1063 | |||
1064 | tasklet_schedule(&udc->rx_tasklet); | ||
1065 | ep->enable_tasklet = 1; | ||
1066 | |||
1067 | return 0; | ||
1068 | } | ||
1069 | |||
1070 | /* send data from a frame, no matter what tx_req */ | ||
1071 | static int qe_ep_tx(struct qe_ep *ep, struct qe_frame *frame) | ||
1072 | { | ||
1073 | struct qe_udc *udc = ep->udc; | ||
1074 | struct qe_bd __iomem *bd; | ||
1075 | u16 saveusbmr; | ||
1076 | u32 bdstatus, pidmask; | ||
1077 | u32 paddr; | ||
1078 | |||
1079 | if (ep->dir == USB_DIR_OUT) { | ||
1080 | dev_err(udc->dev, "receive ep passed to tx function\n"); | ||
1081 | return -EINVAL; | ||
1082 | } | ||
1083 | |||
1084 | /* Disable the Tx interrupt */ | ||
1085 | saveusbmr = in_be16(&udc->usb_regs->usb_usbmr); | ||
1086 | out_be16(&udc->usb_regs->usb_usbmr, | ||
1087 | saveusbmr & ~(USB_E_TXB_MASK | USB_E_TXE_MASK)); | ||
1088 | |||
1089 | bd = ep->n_txbd; | ||
1090 | bdstatus = in_be32((u32 __iomem *)bd); | ||
1091 | |||
1092 | if (!(bdstatus & (T_R | BD_LENGTH_MASK))) { | ||
1093 | if (frame_get_length(frame) == 0) { | ||
1094 | frame_set_data(frame, udc->nullbuf); | ||
1095 | frame_set_length(frame, 2); | ||
1096 | frame->info |= (ZLP | NO_CRC); | ||
1097 | dev_vdbg(udc->dev, "the frame size = 0\n"); | ||
1098 | } | ||
1099 | paddr = virt_to_phys((void *)frame->data); | ||
1100 | out_be32(&bd->buf, paddr); | ||
1101 | bdstatus = (bdstatus&T_W); | ||
1102 | if (!(frame_get_info(frame) & NO_CRC)) | ||
1103 | bdstatus |= T_R | T_I | T_L | T_TC | ||
1104 | | frame_get_length(frame); | ||
1105 | else | ||
1106 | bdstatus |= T_R | T_I | T_L | frame_get_length(frame); | ||
1107 | |||
1108 | /* if the packet is a ZLP in status phase */ | ||
1109 | if ((ep->epnum == 0) && (udc->ep0_state == DATA_STATE_NEED_ZLP)) | ||
1110 | ep->data01 = 0x1; | ||
1111 | |||
1112 | if (ep->data01) { | ||
1113 | pidmask = T_PID_DATA1; | ||
1114 | frame->info |= PID_DATA1; | ||
1115 | } else { | ||
1116 | pidmask = T_PID_DATA0; | ||
1117 | frame->info |= PID_DATA0; | ||
1118 | } | ||
1119 | bdstatus |= T_CNF; | ||
1120 | bdstatus |= pidmask; | ||
1121 | out_be32((u32 __iomem *)bd, bdstatus); | ||
1122 | qe_ep_filltxfifo(ep); | ||
1123 | |||
1124 | /* enable the TX interrupt */ | ||
1125 | out_be16(&udc->usb_regs->usb_usbmr, saveusbmr); | ||
1126 | |||
1127 | qe_ep_toggledata01(ep); | ||
1128 | if (bdstatus & T_W) | ||
1129 | ep->n_txbd = ep->txbase; | ||
1130 | else | ||
1131 | ep->n_txbd++; | ||
1132 | |||
1133 | return 0; | ||
1134 | } else { | ||
1135 | out_be16(&udc->usb_regs->usb_usbmr, saveusbmr); | ||
1136 | dev_vdbg(udc->dev, "The tx bd is not ready!\n"); | ||
1137 | return -EBUSY; | ||
1138 | } | ||
1139 | } | ||
1140 | |||
1141 | /* when a bd was transmitted, the function can | ||
1142 | * handle the tx_req, not include ep0 */ | ||
1143 | static int txcomplete(struct qe_ep *ep, unsigned char restart) | ||
1144 | { | ||
1145 | if (ep->tx_req != NULL) { | ||
1146 | if (!restart) { | ||
1147 | int asent = ep->last; | ||
1148 | ep->sent += asent; | ||
1149 | ep->last -= asent; | ||
1150 | } else { | ||
1151 | ep->last = 0; | ||
1152 | } | ||
1153 | |||
1154 | /* a request already were transmitted completely */ | ||
1155 | if ((ep->tx_req->req.length - ep->sent) <= 0) { | ||
1156 | ep->tx_req->req.actual = (unsigned int)ep->sent; | ||
1157 | done(ep, ep->tx_req, 0); | ||
1158 | ep->tx_req = NULL; | ||
1159 | ep->last = 0; | ||
1160 | ep->sent = 0; | ||
1161 | } | ||
1162 | } | ||
1163 | |||
1164 | /* we should gain a new tx_req fot this endpoint */ | ||
1165 | if (ep->tx_req == NULL) { | ||
1166 | if (!list_empty(&ep->queue)) { | ||
1167 | ep->tx_req = list_entry(ep->queue.next, struct qe_req, | ||
1168 | queue); | ||
1169 | ep->last = 0; | ||
1170 | ep->sent = 0; | ||
1171 | } | ||
1172 | } | ||
1173 | |||
1174 | return 0; | ||
1175 | } | ||
1176 | |||
1177 | /* give a frame and a tx_req, send some data */ | ||
1178 | static int qe_usb_senddata(struct qe_ep *ep, struct qe_frame *frame) | ||
1179 | { | ||
1180 | unsigned int size; | ||
1181 | u8 *buf; | ||
1182 | |||
1183 | qe_frame_clean(frame); | ||
1184 | size = min_t(u32, (ep->tx_req->req.length - ep->sent), | ||
1185 | ep->ep.maxpacket); | ||
1186 | buf = (u8 *)ep->tx_req->req.buf + ep->sent; | ||
1187 | if (buf && size) { | ||
1188 | ep->last = size; | ||
1189 | frame_set_data(frame, buf); | ||
1190 | frame_set_length(frame, size); | ||
1191 | frame_set_status(frame, FRAME_OK); | ||
1192 | frame_set_info(frame, 0); | ||
1193 | return qe_ep_tx(ep, frame); | ||
1194 | } | ||
1195 | return -EIO; | ||
1196 | } | ||
1197 | |||
1198 | /* give a frame struct,send a ZLP */ | ||
1199 | static int sendnulldata(struct qe_ep *ep, struct qe_frame *frame, uint infor) | ||
1200 | { | ||
1201 | struct qe_udc *udc = ep->udc; | ||
1202 | |||
1203 | if (frame == NULL) | ||
1204 | return -ENODEV; | ||
1205 | |||
1206 | qe_frame_clean(frame); | ||
1207 | frame_set_data(frame, (u8 *)udc->nullbuf); | ||
1208 | frame_set_length(frame, 2); | ||
1209 | frame_set_status(frame, FRAME_OK); | ||
1210 | frame_set_info(frame, (ZLP | NO_CRC | infor)); | ||
1211 | |||
1212 | return qe_ep_tx(ep, frame); | ||
1213 | } | ||
1214 | |||
1215 | static int frame_create_tx(struct qe_ep *ep, struct qe_frame *frame) | ||
1216 | { | ||
1217 | struct qe_req *req = ep->tx_req; | ||
1218 | int reval; | ||
1219 | |||
1220 | if (req == NULL) | ||
1221 | return -ENODEV; | ||
1222 | |||
1223 | if ((req->req.length - ep->sent) > 0) | ||
1224 | reval = qe_usb_senddata(ep, frame); | ||
1225 | else | ||
1226 | reval = sendnulldata(ep, frame, 0); | ||
1227 | |||
1228 | return reval; | ||
1229 | } | ||
1230 | |||
1231 | /* if direction is DIR_IN, the status is Device->Host | ||
1232 | * if direction is DIR_OUT, the status transaction is Device<-Host | ||
1233 | * in status phase, udc create a request and gain status */ | ||
1234 | static int ep0_prime_status(struct qe_udc *udc, int direction) | ||
1235 | { | ||
1236 | |||
1237 | struct qe_ep *ep = &udc->eps[0]; | ||
1238 | |||
1239 | if (direction == USB_DIR_IN) { | ||
1240 | udc->ep0_state = DATA_STATE_NEED_ZLP; | ||
1241 | udc->ep0_dir = USB_DIR_IN; | ||
1242 | sendnulldata(ep, ep->txframe, SETUP_STATUS | NO_REQ); | ||
1243 | } else { | ||
1244 | udc->ep0_dir = USB_DIR_OUT; | ||
1245 | udc->ep0_state = WAIT_FOR_OUT_STATUS; | ||
1246 | } | ||
1247 | |||
1248 | return 0; | ||
1249 | } | ||
1250 | |||
1251 | /* a request complete in ep0, whether gadget request or udc request */ | ||
1252 | static void ep0_req_complete(struct qe_udc *udc, struct qe_req *req) | ||
1253 | { | ||
1254 | struct qe_ep *ep = &udc->eps[0]; | ||
1255 | /* because usb and ep's status already been set in ch9setaddress() */ | ||
1256 | |||
1257 | switch (udc->ep0_state) { | ||
1258 | case DATA_STATE_XMIT: | ||
1259 | done(ep, req, 0); | ||
1260 | /* receive status phase */ | ||
1261 | if (ep0_prime_status(udc, USB_DIR_OUT)) | ||
1262 | qe_ep0_stall(udc); | ||
1263 | break; | ||
1264 | |||
1265 | case DATA_STATE_NEED_ZLP: | ||
1266 | done(ep, req, 0); | ||
1267 | udc->ep0_state = WAIT_FOR_SETUP; | ||
1268 | break; | ||
1269 | |||
1270 | case DATA_STATE_RECV: | ||
1271 | done(ep, req, 0); | ||
1272 | /* send status phase */ | ||
1273 | if (ep0_prime_status(udc, USB_DIR_IN)) | ||
1274 | qe_ep0_stall(udc); | ||
1275 | break; | ||
1276 | |||
1277 | case WAIT_FOR_OUT_STATUS: | ||
1278 | done(ep, req, 0); | ||
1279 | udc->ep0_state = WAIT_FOR_SETUP; | ||
1280 | break; | ||
1281 | |||
1282 | case WAIT_FOR_SETUP: | ||
1283 | dev_vdbg(udc->dev, "Unexpected interrupt\n"); | ||
1284 | break; | ||
1285 | |||
1286 | default: | ||
1287 | qe_ep0_stall(udc); | ||
1288 | break; | ||
1289 | } | ||
1290 | } | ||
1291 | |||
1292 | static int ep0_txcomplete(struct qe_ep *ep, unsigned char restart) | ||
1293 | { | ||
1294 | struct qe_req *tx_req = NULL; | ||
1295 | struct qe_frame *frame = ep->txframe; | ||
1296 | |||
1297 | if ((frame_get_info(frame) & (ZLP | NO_REQ)) == (ZLP | NO_REQ)) { | ||
1298 | if (!restart) | ||
1299 | ep->udc->ep0_state = WAIT_FOR_SETUP; | ||
1300 | else | ||
1301 | sendnulldata(ep, ep->txframe, SETUP_STATUS | NO_REQ); | ||
1302 | return 0; | ||
1303 | } | ||
1304 | |||
1305 | tx_req = ep->tx_req; | ||
1306 | if (tx_req != NULL) { | ||
1307 | if (!restart) { | ||
1308 | int asent = ep->last; | ||
1309 | ep->sent += asent; | ||
1310 | ep->last -= asent; | ||
1311 | } else { | ||
1312 | ep->last = 0; | ||
1313 | } | ||
1314 | |||
1315 | /* a request already were transmitted completely */ | ||
1316 | if ((ep->tx_req->req.length - ep->sent) <= 0) { | ||
1317 | ep->tx_req->req.actual = (unsigned int)ep->sent; | ||
1318 | ep0_req_complete(ep->udc, ep->tx_req); | ||
1319 | ep->tx_req = NULL; | ||
1320 | ep->last = 0; | ||
1321 | ep->sent = 0; | ||
1322 | } | ||
1323 | } else { | ||
1324 | dev_vdbg(ep->udc->dev, "the ep0_controller have no req\n"); | ||
1325 | } | ||
1326 | |||
1327 | return 0; | ||
1328 | } | ||
1329 | |||
1330 | static int ep0_txframe_handle(struct qe_ep *ep) | ||
1331 | { | ||
1332 | /* if have error, transmit again */ | ||
1333 | if (frame_get_status(ep->txframe) & FRAME_ERROR) { | ||
1334 | qe_ep_flushtxfifo(ep); | ||
1335 | dev_vdbg(ep->udc->dev, "The EP0 transmit data have error!\n"); | ||
1336 | if (frame_get_info(ep->txframe) & PID_DATA0) | ||
1337 | ep->data01 = 0; | ||
1338 | else | ||
1339 | ep->data01 = 1; | ||
1340 | |||
1341 | ep0_txcomplete(ep, 1); | ||
1342 | } else | ||
1343 | ep0_txcomplete(ep, 0); | ||
1344 | |||
1345 | frame_create_tx(ep, ep->txframe); | ||
1346 | return 0; | ||
1347 | } | ||
1348 | |||
1349 | static int qe_ep0_txconf(struct qe_ep *ep) | ||
1350 | { | ||
1351 | struct qe_bd __iomem *bd; | ||
1352 | struct qe_frame *pframe; | ||
1353 | u32 bdstatus; | ||
1354 | |||
1355 | bd = ep->c_txbd; | ||
1356 | bdstatus = in_be32((u32 __iomem *)bd); | ||
1357 | while (!(bdstatus & T_R) && (bdstatus & ~T_W)) { | ||
1358 | pframe = ep->txframe; | ||
1359 | |||
1360 | /* clear and recycle the BD */ | ||
1361 | out_be32((u32 __iomem *)bd, bdstatus & T_W); | ||
1362 | out_be32(&bd->buf, 0); | ||
1363 | if (bdstatus & T_W) | ||
1364 | ep->c_txbd = ep->txbase; | ||
1365 | else | ||
1366 | ep->c_txbd++; | ||
1367 | |||
1368 | if (ep->c_txbd == ep->n_txbd) { | ||
1369 | if (bdstatus & DEVICE_T_ERROR) { | ||
1370 | frame_set_status(pframe, FRAME_ERROR); | ||
1371 | if (bdstatus & T_TO) | ||
1372 | pframe->status |= TX_ER_TIMEOUT; | ||
1373 | if (bdstatus & T_UN) | ||
1374 | pframe->status |= TX_ER_UNDERUN; | ||
1375 | } | ||
1376 | ep0_txframe_handle(ep); | ||
1377 | } | ||
1378 | |||
1379 | bd = ep->c_txbd; | ||
1380 | bdstatus = in_be32((u32 __iomem *)bd); | ||
1381 | } | ||
1382 | |||
1383 | return 0; | ||
1384 | } | ||
1385 | |||
1386 | static int ep_txframe_handle(struct qe_ep *ep) | ||
1387 | { | ||
1388 | if (frame_get_status(ep->txframe) & FRAME_ERROR) { | ||
1389 | qe_ep_flushtxfifo(ep); | ||
1390 | dev_vdbg(ep->udc->dev, "The EP0 transmit data have error!\n"); | ||
1391 | if (frame_get_info(ep->txframe) & PID_DATA0) | ||
1392 | ep->data01 = 0; | ||
1393 | else | ||
1394 | ep->data01 = 1; | ||
1395 | |||
1396 | txcomplete(ep, 1); | ||
1397 | } else | ||
1398 | txcomplete(ep, 0); | ||
1399 | |||
1400 | frame_create_tx(ep, ep->txframe); /* send the data */ | ||
1401 | return 0; | ||
1402 | } | ||
1403 | |||
1404 | /* confirm the already trainsmited bd */ | ||
1405 | static int qe_ep_txconf(struct qe_ep *ep) | ||
1406 | { | ||
1407 | struct qe_bd __iomem *bd; | ||
1408 | struct qe_frame *pframe = NULL; | ||
1409 | u32 bdstatus; | ||
1410 | unsigned char breakonrxinterrupt = 0; | ||
1411 | |||
1412 | bd = ep->c_txbd; | ||
1413 | bdstatus = in_be32((u32 __iomem *)bd); | ||
1414 | while (!(bdstatus & T_R) && (bdstatus & ~T_W)) { | ||
1415 | pframe = ep->txframe; | ||
1416 | if (bdstatus & DEVICE_T_ERROR) { | ||
1417 | frame_set_status(pframe, FRAME_ERROR); | ||
1418 | if (bdstatus & T_TO) | ||
1419 | pframe->status |= TX_ER_TIMEOUT; | ||
1420 | if (bdstatus & T_UN) | ||
1421 | pframe->status |= TX_ER_UNDERUN; | ||
1422 | } | ||
1423 | |||
1424 | /* clear and recycle the BD */ | ||
1425 | out_be32((u32 __iomem *)bd, bdstatus & T_W); | ||
1426 | out_be32(&bd->buf, 0); | ||
1427 | if (bdstatus & T_W) | ||
1428 | ep->c_txbd = ep->txbase; | ||
1429 | else | ||
1430 | ep->c_txbd++; | ||
1431 | |||
1432 | /* handle the tx frame */ | ||
1433 | ep_txframe_handle(ep); | ||
1434 | bd = ep->c_txbd; | ||
1435 | bdstatus = in_be32((u32 __iomem *)bd); | ||
1436 | } | ||
1437 | if (breakonrxinterrupt) | ||
1438 | return -EIO; | ||
1439 | else | ||
1440 | return 0; | ||
1441 | } | ||
1442 | |||
1443 | /* Add a request in queue, and try to transmit a packet */ | ||
1444 | static int ep_req_send(struct qe_ep *ep, struct qe_req *req) | ||
1445 | { | ||
1446 | int reval = 0; | ||
1447 | |||
1448 | if (ep->tx_req == NULL) { | ||
1449 | ep->sent = 0; | ||
1450 | ep->last = 0; | ||
1451 | txcomplete(ep, 0); /* can gain a new tx_req */ | ||
1452 | reval = frame_create_tx(ep, ep->txframe); | ||
1453 | } | ||
1454 | return reval; | ||
1455 | } | ||
1456 | |||
1457 | /* Maybe this is a good ideal */ | ||
1458 | static int ep_req_rx(struct qe_ep *ep, struct qe_req *req) | ||
1459 | { | ||
1460 | struct qe_udc *udc = ep->udc; | ||
1461 | struct qe_frame *pframe = NULL; | ||
1462 | struct qe_bd __iomem *bd; | ||
1463 | u32 bdstatus, length; | ||
1464 | u32 vaddr, fsize; | ||
1465 | u8 *cp; | ||
1466 | u8 finish_req = 0; | ||
1467 | u8 framepid; | ||
1468 | |||
1469 | if (list_empty(&ep->queue)) { | ||
1470 | dev_vdbg(udc->dev, "the req already finish!\n"); | ||
1471 | return 0; | ||
1472 | } | ||
1473 | pframe = ep->rxframe; | ||
1474 | |||
1475 | bd = ep->n_rxbd; | ||
1476 | bdstatus = in_be32((u32 __iomem *)bd); | ||
1477 | length = bdstatus & BD_LENGTH_MASK; | ||
1478 | |||
1479 | while (!(bdstatus & R_E) && length) { | ||
1480 | if (finish_req) | ||
1481 | break; | ||
1482 | if ((bdstatus & R_F) && (bdstatus & R_L) | ||
1483 | && !(bdstatus & R_ERROR)) { | ||
1484 | qe_frame_clean(pframe); | ||
1485 | vaddr = (u32)phys_to_virt(in_be32(&bd->buf)); | ||
1486 | frame_set_data(pframe, (u8 *)vaddr); | ||
1487 | frame_set_length(pframe, (length - USB_CRC_SIZE)); | ||
1488 | frame_set_status(pframe, FRAME_OK); | ||
1489 | switch (bdstatus & R_PID) { | ||
1490 | case R_PID_DATA1: | ||
1491 | frame_set_info(pframe, PID_DATA1); break; | ||
1492 | default: | ||
1493 | frame_set_info(pframe, PID_DATA0); break; | ||
1494 | } | ||
1495 | /* handle the rx frame */ | ||
1496 | |||
1497 | if (frame_get_info(pframe) & PID_DATA1) | ||
1498 | framepid = 0x1; | ||
1499 | else | ||
1500 | framepid = 0; | ||
1501 | |||
1502 | if (framepid != ep->data01) { | ||
1503 | dev_vdbg(udc->dev, "the data01 error!\n"); | ||
1504 | } else { | ||
1505 | fsize = frame_get_length(pframe); | ||
1506 | |||
1507 | cp = (u8 *)(req->req.buf) + req->req.actual; | ||
1508 | if (cp) { | ||
1509 | memcpy(cp, pframe->data, fsize); | ||
1510 | req->req.actual += fsize; | ||
1511 | if ((fsize < ep->ep.maxpacket) | ||
1512 | || (req->req.actual >= | ||
1513 | req->req.length)) { | ||
1514 | finish_req = 1; | ||
1515 | done(ep, req, 0); | ||
1516 | if (list_empty(&ep->queue)) | ||
1517 | qe_eprx_nack(ep); | ||
1518 | } | ||
1519 | } | ||
1520 | qe_ep_toggledata01(ep); | ||
1521 | } | ||
1522 | } else { | ||
1523 | dev_err(udc->dev, "The receive frame with error!\n"); | ||
1524 | } | ||
1525 | |||
1526 | /* note: don't clear the rxbd's buffer address * | ||
1527 | * only Clear the length */ | ||
1528 | out_be32((u32 __iomem *)bd, (bdstatus & BD_STATUS_MASK)); | ||
1529 | ep->has_data--; | ||
1530 | |||
1531 | /* Get next BD */ | ||
1532 | if (bdstatus & R_W) | ||
1533 | bd = ep->rxbase; | ||
1534 | else | ||
1535 | bd++; | ||
1536 | |||
1537 | bdstatus = in_be32((u32 __iomem *)bd); | ||
1538 | length = bdstatus & BD_LENGTH_MASK; | ||
1539 | } | ||
1540 | |||
1541 | ep->n_rxbd = bd; | ||
1542 | ep_recycle_rxbds(ep); | ||
1543 | |||
1544 | return 0; | ||
1545 | } | ||
1546 | |||
1547 | /* only add the request in queue */ | ||
1548 | static int ep_req_receive(struct qe_ep *ep, struct qe_req *req) | ||
1549 | { | ||
1550 | if (ep->state == EP_STATE_NACK) { | ||
1551 | if (ep->has_data <= 0) { | ||
1552 | /* Enable rx and unmask rx interrupt */ | ||
1553 | qe_eprx_normal(ep); | ||
1554 | } else { | ||
1555 | /* Copy the exist BD data */ | ||
1556 | ep_req_rx(ep, req); | ||
1557 | } | ||
1558 | } | ||
1559 | |||
1560 | return 0; | ||
1561 | } | ||
1562 | |||
1563 | /******************************************************************** | ||
1564 | Internal Used Function End | ||
1565 | ********************************************************************/ | ||
1566 | |||
1567 | /*----------------------------------------------------------------------- | ||
1568 | Endpoint Management Functions For Gadget | ||
1569 | -----------------------------------------------------------------------*/ | ||
1570 | static int qe_ep_enable(struct usb_ep *_ep, | ||
1571 | const struct usb_endpoint_descriptor *desc) | ||
1572 | { | ||
1573 | struct qe_udc *udc; | ||
1574 | struct qe_ep *ep; | ||
1575 | int retval = 0; | ||
1576 | unsigned char epnum; | ||
1577 | |||
1578 | ep = container_of(_ep, struct qe_ep, ep); | ||
1579 | |||
1580 | /* catch various bogus parameters */ | ||
1581 | if (!_ep || !desc || ep->desc || _ep->name == ep_name[0] || | ||
1582 | (desc->bDescriptorType != USB_DT_ENDPOINT)) | ||
1583 | return -EINVAL; | ||
1584 | |||
1585 | udc = ep->udc; | ||
1586 | if (!udc->driver || (udc->gadget.speed == USB_SPEED_UNKNOWN)) | ||
1587 | return -ESHUTDOWN; | ||
1588 | |||
1589 | epnum = (u8)desc->bEndpointAddress & 0xF; | ||
1590 | |||
1591 | retval = qe_ep_init(udc, epnum, desc); | ||
1592 | if (retval != 0) { | ||
1593 | cpm_muram_free(cpm_muram_offset(ep->rxbase)); | ||
1594 | dev_dbg(udc->dev, "enable ep%d failed\n", ep->epnum); | ||
1595 | return -EINVAL; | ||
1596 | } | ||
1597 | dev_dbg(udc->dev, "enable ep%d successful\n", ep->epnum); | ||
1598 | return 0; | ||
1599 | } | ||
1600 | |||
1601 | static int qe_ep_disable(struct usb_ep *_ep) | ||
1602 | { | ||
1603 | struct qe_udc *udc; | ||
1604 | struct qe_ep *ep; | ||
1605 | unsigned long flags; | ||
1606 | unsigned int size; | ||
1607 | |||
1608 | ep = container_of(_ep, struct qe_ep, ep); | ||
1609 | udc = ep->udc; | ||
1610 | |||
1611 | if (!_ep || !ep->desc) { | ||
1612 | dev_dbg(udc->dev, "%s not enabled\n", _ep ? ep->ep.name : NULL); | ||
1613 | return -EINVAL; | ||
1614 | } | ||
1615 | |||
1616 | spin_lock_irqsave(&udc->lock, flags); | ||
1617 | /* Nuke all pending requests (does flush) */ | ||
1618 | nuke(ep, -ESHUTDOWN); | ||
1619 | ep->desc = NULL; | ||
1620 | ep->stopped = 1; | ||
1621 | spin_unlock_irqrestore(&udc->lock, flags); | ||
1622 | |||
1623 | cpm_muram_free(cpm_muram_offset(ep->rxbase)); | ||
1624 | |||
1625 | if (ep->dir == USB_DIR_OUT) | ||
1626 | size = (ep->ep.maxpacket + USB_CRC_SIZE + 2) * | ||
1627 | (USB_BDRING_LEN_RX + 1); | ||
1628 | else | ||
1629 | size = (ep->ep.maxpacket + USB_CRC_SIZE + 2) * | ||
1630 | (USB_BDRING_LEN + 1); | ||
1631 | |||
1632 | if (ep->dir != USB_DIR_IN) { | ||
1633 | kfree(ep->rxframe); | ||
1634 | if (ep->rxbufmap) { | ||
1635 | dma_unmap_single(udc_controller->gadget.dev.parent, | ||
1636 | ep->rxbuf_d, size, | ||
1637 | DMA_FROM_DEVICE); | ||
1638 | ep->rxbuf_d = DMA_ADDR_INVALID; | ||
1639 | } else { | ||
1640 | dma_sync_single_for_cpu( | ||
1641 | udc_controller->gadget.dev.parent, | ||
1642 | ep->rxbuf_d, size, | ||
1643 | DMA_FROM_DEVICE); | ||
1644 | } | ||
1645 | kfree(ep->rxbuffer); | ||
1646 | } | ||
1647 | |||
1648 | if (ep->dir != USB_DIR_OUT) | ||
1649 | kfree(ep->txframe); | ||
1650 | |||
1651 | dev_dbg(udc->dev, "disabled %s OK\n", _ep->name); | ||
1652 | return 0; | ||
1653 | } | ||
1654 | |||
1655 | static struct usb_request *qe_alloc_request(struct usb_ep *_ep, gfp_t gfp_flags) | ||
1656 | { | ||
1657 | struct qe_req *req; | ||
1658 | |||
1659 | req = kzalloc(sizeof(*req), gfp_flags); | ||
1660 | if (!req) | ||
1661 | return NULL; | ||
1662 | |||
1663 | req->req.dma = DMA_ADDR_INVALID; | ||
1664 | |||
1665 | INIT_LIST_HEAD(&req->queue); | ||
1666 | |||
1667 | return &req->req; | ||
1668 | } | ||
1669 | |||
1670 | static void qe_free_request(struct usb_ep *_ep, struct usb_request *_req) | ||
1671 | { | ||
1672 | struct qe_req *req; | ||
1673 | |||
1674 | req = container_of(_req, struct qe_req, req); | ||
1675 | |||
1676 | if (_req) | ||
1677 | kfree(req); | ||
1678 | } | ||
1679 | |||
1680 | /* queues (submits) an I/O request to an endpoint */ | ||
1681 | static int qe_ep_queue(struct usb_ep *_ep, struct usb_request *_req, | ||
1682 | gfp_t gfp_flags) | ||
1683 | { | ||
1684 | struct qe_ep *ep = container_of(_ep, struct qe_ep, ep); | ||
1685 | struct qe_req *req = container_of(_req, struct qe_req, req); | ||
1686 | struct qe_udc *udc; | ||
1687 | unsigned long flags; | ||
1688 | int reval; | ||
1689 | |||
1690 | udc = ep->udc; | ||
1691 | /* catch various bogus parameters */ | ||
1692 | if (!_req || !req->req.complete || !req->req.buf | ||
1693 | || !list_empty(&req->queue)) { | ||
1694 | dev_dbg(udc->dev, "bad params\n"); | ||
1695 | return -EINVAL; | ||
1696 | } | ||
1697 | if (!_ep || (!ep->desc && ep_index(ep))) { | ||
1698 | dev_dbg(udc->dev, "bad ep\n"); | ||
1699 | return -EINVAL; | ||
1700 | } | ||
1701 | |||
1702 | if (!udc->driver || udc->gadget.speed == USB_SPEED_UNKNOWN) | ||
1703 | return -ESHUTDOWN; | ||
1704 | |||
1705 | req->ep = ep; | ||
1706 | |||
1707 | /* map virtual address to hardware */ | ||
1708 | if (req->req.dma == DMA_ADDR_INVALID) { | ||
1709 | req->req.dma = dma_map_single(ep->udc->gadget.dev.parent, | ||
1710 | req->req.buf, | ||
1711 | req->req.length, | ||
1712 | ep_is_in(ep) | ||
1713 | ? DMA_TO_DEVICE : | ||
1714 | DMA_FROM_DEVICE); | ||
1715 | req->mapped = 1; | ||
1716 | } else { | ||
1717 | dma_sync_single_for_device(ep->udc->gadget.dev.parent, | ||
1718 | req->req.dma, req->req.length, | ||
1719 | ep_is_in(ep) | ||
1720 | ? DMA_TO_DEVICE : | ||
1721 | DMA_FROM_DEVICE); | ||
1722 | req->mapped = 0; | ||
1723 | } | ||
1724 | |||
1725 | req->req.status = -EINPROGRESS; | ||
1726 | req->req.actual = 0; | ||
1727 | |||
1728 | list_add_tail(&req->queue, &ep->queue); | ||
1729 | dev_vdbg(udc->dev, "gadget have request in %s! %d\n", | ||
1730 | ep->name, req->req.length); | ||
1731 | spin_lock_irqsave(&udc->lock, flags); | ||
1732 | /* push the request to device */ | ||
1733 | if (ep_is_in(ep)) | ||
1734 | reval = ep_req_send(ep, req); | ||
1735 | |||
1736 | /* EP0 */ | ||
1737 | if (ep_index(ep) == 0 && req->req.length > 0) { | ||
1738 | if (ep_is_in(ep)) | ||
1739 | udc->ep0_state = DATA_STATE_XMIT; | ||
1740 | else | ||
1741 | udc->ep0_state = DATA_STATE_RECV; | ||
1742 | } | ||
1743 | |||
1744 | if (ep->dir == USB_DIR_OUT) | ||
1745 | reval = ep_req_receive(ep, req); | ||
1746 | |||
1747 | spin_unlock_irqrestore(&udc->lock, flags); | ||
1748 | |||
1749 | return 0; | ||
1750 | } | ||
1751 | |||
1752 | /* dequeues (cancels, unlinks) an I/O request from an endpoint */ | ||
1753 | static int qe_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req) | ||
1754 | { | ||
1755 | struct qe_ep *ep = container_of(_ep, struct qe_ep, ep); | ||
1756 | struct qe_req *req; | ||
1757 | unsigned long flags; | ||
1758 | |||
1759 | if (!_ep || !_req) | ||
1760 | return -EINVAL; | ||
1761 | |||
1762 | spin_lock_irqsave(&ep->udc->lock, flags); | ||
1763 | |||
1764 | /* make sure it's actually queued on this endpoint */ | ||
1765 | list_for_each_entry(req, &ep->queue, queue) { | ||
1766 | if (&req->req == _req) | ||
1767 | break; | ||
1768 | } | ||
1769 | |||
1770 | if (&req->req != _req) { | ||
1771 | spin_unlock_irqrestore(&ep->udc->lock, flags); | ||
1772 | return -EINVAL; | ||
1773 | } | ||
1774 | |||
1775 | done(ep, req, -ECONNRESET); | ||
1776 | |||
1777 | spin_unlock_irqrestore(&ep->udc->lock, flags); | ||
1778 | return 0; | ||
1779 | } | ||
1780 | |||
1781 | /*----------------------------------------------------------------- | ||
1782 | * modify the endpoint halt feature | ||
1783 | * @ep: the non-isochronous endpoint being stalled | ||
1784 | * @value: 1--set halt 0--clear halt | ||
1785 | * Returns zero, or a negative error code. | ||
1786 | *----------------------------------------------------------------*/ | ||
1787 | static int qe_ep_set_halt(struct usb_ep *_ep, int value) | ||
1788 | { | ||
1789 | struct qe_ep *ep; | ||
1790 | unsigned long flags; | ||
1791 | int status = -EOPNOTSUPP; | ||
1792 | struct qe_udc *udc; | ||
1793 | |||
1794 | ep = container_of(_ep, struct qe_ep, ep); | ||
1795 | if (!_ep || !ep->desc) { | ||
1796 | status = -EINVAL; | ||
1797 | goto out; | ||
1798 | } | ||
1799 | |||
1800 | udc = ep->udc; | ||
1801 | /* Attempt to halt IN ep will fail if any transfer requests | ||
1802 | * are still queue */ | ||
1803 | if (value && ep_is_in(ep) && !list_empty(&ep->queue)) { | ||
1804 | status = -EAGAIN; | ||
1805 | goto out; | ||
1806 | } | ||
1807 | |||
1808 | status = 0; | ||
1809 | spin_lock_irqsave(&ep->udc->lock, flags); | ||
1810 | qe_eptx_stall_change(ep, value); | ||
1811 | qe_eprx_stall_change(ep, value); | ||
1812 | spin_unlock_irqrestore(&ep->udc->lock, flags); | ||
1813 | |||
1814 | if (ep->epnum == 0) { | ||
1815 | udc->ep0_state = WAIT_FOR_SETUP; | ||
1816 | udc->ep0_dir = 0; | ||
1817 | } | ||
1818 | |||
1819 | /* set data toggle to DATA0 on clear halt */ | ||
1820 | if (value == 0) | ||
1821 | ep->data01 = 0; | ||
1822 | out: | ||
1823 | dev_vdbg(udc->dev, "%s %s halt stat %d\n", ep->ep.name, | ||
1824 | value ? "set" : "clear", status); | ||
1825 | |||
1826 | return status; | ||
1827 | } | ||
1828 | |||
1829 | static struct usb_ep_ops qe_ep_ops = { | ||
1830 | .enable = qe_ep_enable, | ||
1831 | .disable = qe_ep_disable, | ||
1832 | |||
1833 | .alloc_request = qe_alloc_request, | ||
1834 | .free_request = qe_free_request, | ||
1835 | |||
1836 | .queue = qe_ep_queue, | ||
1837 | .dequeue = qe_ep_dequeue, | ||
1838 | |||
1839 | .set_halt = qe_ep_set_halt, | ||
1840 | }; | ||
1841 | |||
1842 | /*------------------------------------------------------------------------ | ||
1843 | Gadget Driver Layer Operations | ||
1844 | ------------------------------------------------------------------------*/ | ||
1845 | |||
1846 | /* Get the current frame number */ | ||
1847 | static int qe_get_frame(struct usb_gadget *gadget) | ||
1848 | { | ||
1849 | u16 tmp; | ||
1850 | |||
1851 | tmp = in_be16(&udc_controller->usb_param->frame_n); | ||
1852 | if (tmp & 0x8000) | ||
1853 | tmp = tmp & 0x07ff; | ||
1854 | else | ||
1855 | tmp = -EINVAL; | ||
1856 | |||
1857 | return (int)tmp; | ||
1858 | } | ||
1859 | |||
1860 | /* Tries to wake up the host connected to this gadget | ||
1861 | * | ||
1862 | * Return : 0-success | ||
1863 | * Negative-this feature not enabled by host or not supported by device hw | ||
1864 | */ | ||
1865 | static int qe_wakeup(struct usb_gadget *gadget) | ||
1866 | { | ||
1867 | return -ENOTSUPP; | ||
1868 | } | ||
1869 | |||
1870 | /* Notify controller that VBUS is powered, Called by whatever | ||
1871 | detects VBUS sessions */ | ||
1872 | static int qe_vbus_session(struct usb_gadget *gadget, int is_active) | ||
1873 | { | ||
1874 | return -ENOTSUPP; | ||
1875 | } | ||
1876 | |||
1877 | /* constrain controller's VBUS power usage | ||
1878 | * This call is used by gadget drivers during SET_CONFIGURATION calls, | ||
1879 | * reporting how much power the device may consume. For example, this | ||
1880 | * could affect how quickly batteries are recharged. | ||
1881 | * | ||
1882 | * Returns zero on success, else negative errno. | ||
1883 | */ | ||
1884 | static int qe_vbus_draw(struct usb_gadget *gadget, unsigned mA) | ||
1885 | { | ||
1886 | return -ENOTSUPP; | ||
1887 | } | ||
1888 | |||
1889 | /* Change Data+ pullup status | ||
1890 | * this func is used by usb_gadget_connect/disconnect | ||
1891 | */ | ||
1892 | static int qe_pullup(struct usb_gadget *gadget, int is_on) | ||
1893 | { | ||
1894 | return -ENOTSUPP; | ||
1895 | } | ||
1896 | |||
1897 | /* defined in usb_gadget.h */ | ||
1898 | static struct usb_gadget_ops qe_gadget_ops = { | ||
1899 | .get_frame = qe_get_frame, | ||
1900 | .wakeup = qe_wakeup, | ||
1901 | /* .set_selfpowered = qe_set_selfpowered,*/ /* always selfpowered */ | ||
1902 | .vbus_session = qe_vbus_session, | ||
1903 | .vbus_draw = qe_vbus_draw, | ||
1904 | .pullup = qe_pullup, | ||
1905 | }; | ||
1906 | |||
1907 | /*------------------------------------------------------------------------- | ||
1908 | USB ep0 Setup process in BUS Enumeration | ||
1909 | -------------------------------------------------------------------------*/ | ||
1910 | static int udc_reset_ep_queue(struct qe_udc *udc, u8 pipe) | ||
1911 | { | ||
1912 | struct qe_ep *ep = &udc->eps[pipe]; | ||
1913 | |||
1914 | nuke(ep, -ECONNRESET); | ||
1915 | ep->tx_req = NULL; | ||
1916 | return 0; | ||
1917 | } | ||
1918 | |||
1919 | static int reset_queues(struct qe_udc *udc) | ||
1920 | { | ||
1921 | u8 pipe; | ||
1922 | |||
1923 | for (pipe = 0; pipe < USB_MAX_ENDPOINTS; pipe++) | ||
1924 | udc_reset_ep_queue(udc, pipe); | ||
1925 | |||
1926 | /* report disconnect; the driver is already quiesced */ | ||
1927 | spin_unlock(&udc->lock); | ||
1928 | udc->driver->disconnect(&udc->gadget); | ||
1929 | spin_lock(&udc->lock); | ||
1930 | |||
1931 | return 0; | ||
1932 | } | ||
1933 | |||
1934 | static void ch9setaddress(struct qe_udc *udc, u16 value, u16 index, | ||
1935 | u16 length) | ||
1936 | { | ||
1937 | /* Save the new address to device struct */ | ||
1938 | udc->device_address = (u8) value; | ||
1939 | /* Update usb state */ | ||
1940 | udc->usb_state = USB_STATE_ADDRESS; | ||
1941 | |||
1942 | /* Status phase , send a ZLP */ | ||
1943 | if (ep0_prime_status(udc, USB_DIR_IN)) | ||
1944 | qe_ep0_stall(udc); | ||
1945 | } | ||
1946 | |||
1947 | static void ownercomplete(struct usb_ep *_ep, struct usb_request *_req) | ||
1948 | { | ||
1949 | struct qe_req *req = container_of(_req, struct qe_req, req); | ||
1950 | |||
1951 | req->req.buf = NULL; | ||
1952 | kfree(req); | ||
1953 | } | ||
1954 | |||
1955 | static void ch9getstatus(struct qe_udc *udc, u8 request_type, u16 value, | ||
1956 | u16 index, u16 length) | ||
1957 | { | ||
1958 | u16 usb_status = 0; | ||
1959 | struct qe_req *req; | ||
1960 | struct qe_ep *ep; | ||
1961 | int status = 0; | ||
1962 | |||
1963 | ep = &udc->eps[0]; | ||
1964 | if ((request_type & USB_RECIP_MASK) == USB_RECIP_DEVICE) { | ||
1965 | /* Get device status */ | ||
1966 | usb_status = 1 << USB_DEVICE_SELF_POWERED; | ||
1967 | } else if ((request_type & USB_RECIP_MASK) == USB_RECIP_INTERFACE) { | ||
1968 | /* Get interface status */ | ||
1969 | /* We don't have interface information in udc driver */ | ||
1970 | usb_status = 0; | ||
1971 | } else if ((request_type & USB_RECIP_MASK) == USB_RECIP_ENDPOINT) { | ||
1972 | /* Get endpoint status */ | ||
1973 | int pipe = index & USB_ENDPOINT_NUMBER_MASK; | ||
1974 | struct qe_ep *target_ep = &udc->eps[pipe]; | ||
1975 | u16 usep; | ||
1976 | |||
1977 | /* stall if endpoint doesn't exist */ | ||
1978 | if (!target_ep->desc) | ||
1979 | goto stall; | ||
1980 | |||
1981 | usep = in_be16(&udc->usb_regs->usb_usep[pipe]); | ||
1982 | if (index & USB_DIR_IN) { | ||
1983 | if (target_ep->dir != USB_DIR_IN) | ||
1984 | goto stall; | ||
1985 | if ((usep & USB_THS_MASK) == USB_THS_STALL) | ||
1986 | usb_status = 1 << USB_ENDPOINT_HALT; | ||
1987 | } else { | ||
1988 | if (target_ep->dir != USB_DIR_OUT) | ||
1989 | goto stall; | ||
1990 | if ((usep & USB_RHS_MASK) == USB_RHS_STALL) | ||
1991 | usb_status = 1 << USB_ENDPOINT_HALT; | ||
1992 | } | ||
1993 | } | ||
1994 | |||
1995 | req = container_of(qe_alloc_request(&ep->ep, GFP_KERNEL), | ||
1996 | struct qe_req, req); | ||
1997 | req->req.length = 2; | ||
1998 | req->req.buf = udc->statusbuf; | ||
1999 | *(u16 *)req->req.buf = cpu_to_le16(usb_status); | ||
2000 | req->req.status = -EINPROGRESS; | ||
2001 | req->req.actual = 0; | ||
2002 | req->req.complete = ownercomplete; | ||
2003 | |||
2004 | udc->ep0_dir = USB_DIR_IN; | ||
2005 | |||
2006 | /* data phase */ | ||
2007 | status = qe_ep_queue(&ep->ep, &req->req, GFP_ATOMIC); | ||
2008 | |||
2009 | if (status == 0) | ||
2010 | return; | ||
2011 | stall: | ||
2012 | dev_err(udc->dev, "Can't respond to getstatus request \n"); | ||
2013 | qe_ep0_stall(udc); | ||
2014 | } | ||
2015 | |||
2016 | /* only handle the setup request, suppose the device in normal status */ | ||
2017 | static void setup_received_handle(struct qe_udc *udc, | ||
2018 | struct usb_ctrlrequest *setup) | ||
2019 | { | ||
2020 | /* Fix Endian (udc->local_setup_buff is cpu Endian now)*/ | ||
2021 | u16 wValue = le16_to_cpu(setup->wValue); | ||
2022 | u16 wIndex = le16_to_cpu(setup->wIndex); | ||
2023 | u16 wLength = le16_to_cpu(setup->wLength); | ||
2024 | |||
2025 | /* clear the previous request in the ep0 */ | ||
2026 | udc_reset_ep_queue(udc, 0); | ||
2027 | |||
2028 | if (setup->bRequestType & USB_DIR_IN) | ||
2029 | udc->ep0_dir = USB_DIR_IN; | ||
2030 | else | ||
2031 | udc->ep0_dir = USB_DIR_OUT; | ||
2032 | |||
2033 | switch (setup->bRequest) { | ||
2034 | case USB_REQ_GET_STATUS: | ||
2035 | /* Data+Status phase form udc */ | ||
2036 | if ((setup->bRequestType & (USB_DIR_IN | USB_TYPE_MASK)) | ||
2037 | != (USB_DIR_IN | USB_TYPE_STANDARD)) | ||
2038 | break; | ||
2039 | ch9getstatus(udc, setup->bRequestType, wValue, wIndex, | ||
2040 | wLength); | ||
2041 | return; | ||
2042 | |||
2043 | case USB_REQ_SET_ADDRESS: | ||
2044 | /* Status phase from udc */ | ||
2045 | if (setup->bRequestType != (USB_DIR_OUT | USB_TYPE_STANDARD | | ||
2046 | USB_RECIP_DEVICE)) | ||
2047 | break; | ||
2048 | ch9setaddress(udc, wValue, wIndex, wLength); | ||
2049 | return; | ||
2050 | |||
2051 | case USB_REQ_CLEAR_FEATURE: | ||
2052 | case USB_REQ_SET_FEATURE: | ||
2053 | /* Requests with no data phase, status phase from udc */ | ||
2054 | if ((setup->bRequestType & USB_TYPE_MASK) | ||
2055 | != USB_TYPE_STANDARD) | ||
2056 | break; | ||
2057 | |||
2058 | if ((setup->bRequestType & USB_RECIP_MASK) | ||
2059 | == USB_RECIP_ENDPOINT) { | ||
2060 | int pipe = wIndex & USB_ENDPOINT_NUMBER_MASK; | ||
2061 | struct qe_ep *ep; | ||
2062 | |||
2063 | if (wValue != 0 || wLength != 0 | ||
2064 | || pipe > USB_MAX_ENDPOINTS) | ||
2065 | break; | ||
2066 | ep = &udc->eps[pipe]; | ||
2067 | |||
2068 | spin_unlock(&udc->lock); | ||
2069 | qe_ep_set_halt(&ep->ep, | ||
2070 | (setup->bRequest == USB_REQ_SET_FEATURE) | ||
2071 | ? 1 : 0); | ||
2072 | spin_lock(&udc->lock); | ||
2073 | } | ||
2074 | |||
2075 | ep0_prime_status(udc, USB_DIR_IN); | ||
2076 | |||
2077 | return; | ||
2078 | |||
2079 | default: | ||
2080 | break; | ||
2081 | } | ||
2082 | |||
2083 | if (wLength) { | ||
2084 | /* Data phase from gadget, status phase from udc */ | ||
2085 | if (setup->bRequestType & USB_DIR_IN) { | ||
2086 | udc->ep0_state = DATA_STATE_XMIT; | ||
2087 | udc->ep0_dir = USB_DIR_IN; | ||
2088 | } else { | ||
2089 | udc->ep0_state = DATA_STATE_RECV; | ||
2090 | udc->ep0_dir = USB_DIR_OUT; | ||
2091 | } | ||
2092 | spin_unlock(&udc->lock); | ||
2093 | if (udc->driver->setup(&udc->gadget, | ||
2094 | &udc->local_setup_buff) < 0) | ||
2095 | qe_ep0_stall(udc); | ||
2096 | spin_lock(&udc->lock); | ||
2097 | } else { | ||
2098 | /* No data phase, IN status from gadget */ | ||
2099 | udc->ep0_dir = USB_DIR_IN; | ||
2100 | spin_unlock(&udc->lock); | ||
2101 | if (udc->driver->setup(&udc->gadget, | ||
2102 | &udc->local_setup_buff) < 0) | ||
2103 | qe_ep0_stall(udc); | ||
2104 | spin_lock(&udc->lock); | ||
2105 | udc->ep0_state = DATA_STATE_NEED_ZLP; | ||
2106 | } | ||
2107 | } | ||
2108 | |||
2109 | /*------------------------------------------------------------------------- | ||
2110 | USB Interrupt handlers | ||
2111 | -------------------------------------------------------------------------*/ | ||
2112 | static void suspend_irq(struct qe_udc *udc) | ||
2113 | { | ||
2114 | udc->resume_state = udc->usb_state; | ||
2115 | udc->usb_state = USB_STATE_SUSPENDED; | ||
2116 | |||
2117 | /* report suspend to the driver ,serial.c not support this*/ | ||
2118 | if (udc->driver->suspend) | ||
2119 | udc->driver->suspend(&udc->gadget); | ||
2120 | } | ||
2121 | |||
2122 | static void resume_irq(struct qe_udc *udc) | ||
2123 | { | ||
2124 | udc->usb_state = udc->resume_state; | ||
2125 | udc->resume_state = 0; | ||
2126 | |||
2127 | /* report resume to the driver , serial.c not support this*/ | ||
2128 | if (udc->driver->resume) | ||
2129 | udc->driver->resume(&udc->gadget); | ||
2130 | } | ||
2131 | |||
2132 | static void idle_irq(struct qe_udc *udc) | ||
2133 | { | ||
2134 | u8 usbs; | ||
2135 | |||
2136 | usbs = in_8(&udc->usb_regs->usb_usbs); | ||
2137 | if (usbs & USB_IDLE_STATUS_MASK) { | ||
2138 | if ((udc->usb_state) != USB_STATE_SUSPENDED) | ||
2139 | suspend_irq(udc); | ||
2140 | } else { | ||
2141 | if (udc->usb_state == USB_STATE_SUSPENDED) | ||
2142 | resume_irq(udc); | ||
2143 | } | ||
2144 | } | ||
2145 | |||
2146 | static int reset_irq(struct qe_udc *udc) | ||
2147 | { | ||
2148 | unsigned char i; | ||
2149 | |||
2150 | qe_usb_disable(); | ||
2151 | out_8(&udc->usb_regs->usb_usadr, 0); | ||
2152 | |||
2153 | for (i = 0; i < USB_MAX_ENDPOINTS; i++) { | ||
2154 | if (udc->eps[i].init) | ||
2155 | qe_ep_reset(udc, i); | ||
2156 | } | ||
2157 | |||
2158 | reset_queues(udc); | ||
2159 | udc->usb_state = USB_STATE_DEFAULT; | ||
2160 | udc->ep0_state = WAIT_FOR_SETUP; | ||
2161 | udc->ep0_dir = USB_DIR_OUT; | ||
2162 | qe_usb_enable(); | ||
2163 | return 0; | ||
2164 | } | ||
2165 | |||
2166 | static int bsy_irq(struct qe_udc *udc) | ||
2167 | { | ||
2168 | return 0; | ||
2169 | } | ||
2170 | |||
2171 | static int txe_irq(struct qe_udc *udc) | ||
2172 | { | ||
2173 | return 0; | ||
2174 | } | ||
2175 | |||
2176 | /* ep0 tx interrupt also in here */ | ||
2177 | static int tx_irq(struct qe_udc *udc) | ||
2178 | { | ||
2179 | struct qe_ep *ep; | ||
2180 | struct qe_bd __iomem *bd; | ||
2181 | int i, res = 0; | ||
2182 | |||
2183 | if ((udc->usb_state == USB_STATE_ADDRESS) | ||
2184 | && (in_8(&udc->usb_regs->usb_usadr) == 0)) | ||
2185 | out_8(&udc->usb_regs->usb_usadr, udc->device_address); | ||
2186 | |||
2187 | for (i = (USB_MAX_ENDPOINTS-1); ((i >= 0) && (res == 0)); i--) { | ||
2188 | ep = &udc->eps[i]; | ||
2189 | if (ep && ep->init && (ep->dir != USB_DIR_OUT)) { | ||
2190 | bd = ep->c_txbd; | ||
2191 | if (!(in_be32((u32 __iomem *)bd) & T_R) | ||
2192 | && (in_be32(&bd->buf))) { | ||
2193 | /* confirm the transmitted bd */ | ||
2194 | if (ep->epnum == 0) | ||
2195 | res = qe_ep0_txconf(ep); | ||
2196 | else | ||
2197 | res = qe_ep_txconf(ep); | ||
2198 | } | ||
2199 | } | ||
2200 | } | ||
2201 | return res; | ||
2202 | } | ||
2203 | |||
2204 | |||
2205 | /* setup packect's rx is handle in the function too */ | ||
2206 | static void rx_irq(struct qe_udc *udc) | ||
2207 | { | ||
2208 | struct qe_ep *ep; | ||
2209 | struct qe_bd __iomem *bd; | ||
2210 | int i; | ||
2211 | |||
2212 | for (i = 0; i < USB_MAX_ENDPOINTS; i++) { | ||
2213 | ep = &udc->eps[i]; | ||
2214 | if (ep && ep->init && (ep->dir != USB_DIR_IN)) { | ||
2215 | bd = ep->n_rxbd; | ||
2216 | if (!(in_be32((u32 __iomem *)bd) & R_E) | ||
2217 | && (in_be32(&bd->buf))) { | ||
2218 | if (ep->epnum == 0) { | ||
2219 | qe_ep0_rx(udc); | ||
2220 | } else { | ||
2221 | /*non-setup package receive*/ | ||
2222 | qe_ep_rx(ep); | ||
2223 | } | ||
2224 | } | ||
2225 | } | ||
2226 | } | ||
2227 | } | ||
2228 | |||
2229 | static irqreturn_t qe_udc_irq(int irq, void *_udc) | ||
2230 | { | ||
2231 | struct qe_udc *udc = (struct qe_udc *)_udc; | ||
2232 | u16 irq_src; | ||
2233 | irqreturn_t status = IRQ_NONE; | ||
2234 | unsigned long flags; | ||
2235 | |||
2236 | spin_lock_irqsave(&udc->lock, flags); | ||
2237 | |||
2238 | irq_src = in_be16(&udc->usb_regs->usb_usber) & | ||
2239 | in_be16(&udc->usb_regs->usb_usbmr); | ||
2240 | /* Clear notification bits */ | ||
2241 | out_be16(&udc->usb_regs->usb_usber, irq_src); | ||
2242 | /* USB Interrupt */ | ||
2243 | if (irq_src & USB_E_IDLE_MASK) { | ||
2244 | idle_irq(udc); | ||
2245 | irq_src &= ~USB_E_IDLE_MASK; | ||
2246 | status = IRQ_HANDLED; | ||
2247 | } | ||
2248 | |||
2249 | if (irq_src & USB_E_TXB_MASK) { | ||
2250 | tx_irq(udc); | ||
2251 | irq_src &= ~USB_E_TXB_MASK; | ||
2252 | status = IRQ_HANDLED; | ||
2253 | } | ||
2254 | |||
2255 | if (irq_src & USB_E_RXB_MASK) { | ||
2256 | rx_irq(udc); | ||
2257 | irq_src &= ~USB_E_RXB_MASK; | ||
2258 | status = IRQ_HANDLED; | ||
2259 | } | ||
2260 | |||
2261 | if (irq_src & USB_E_RESET_MASK) { | ||
2262 | reset_irq(udc); | ||
2263 | irq_src &= ~USB_E_RESET_MASK; | ||
2264 | status = IRQ_HANDLED; | ||
2265 | } | ||
2266 | |||
2267 | if (irq_src & USB_E_BSY_MASK) { | ||
2268 | bsy_irq(udc); | ||
2269 | irq_src &= ~USB_E_BSY_MASK; | ||
2270 | status = IRQ_HANDLED; | ||
2271 | } | ||
2272 | |||
2273 | if (irq_src & USB_E_TXE_MASK) { | ||
2274 | txe_irq(udc); | ||
2275 | irq_src &= ~USB_E_TXE_MASK; | ||
2276 | status = IRQ_HANDLED; | ||
2277 | } | ||
2278 | |||
2279 | spin_unlock_irqrestore(&udc->lock, flags); | ||
2280 | |||
2281 | return status; | ||
2282 | } | ||
2283 | |||
2284 | /*------------------------------------------------------------------------- | ||
2285 | Gadget driver register and unregister. | ||
2286 | --------------------------------------------------------------------------*/ | ||
2287 | int usb_gadget_register_driver(struct usb_gadget_driver *driver) | ||
2288 | { | ||
2289 | int retval; | ||
2290 | unsigned long flags = 0; | ||
2291 | |||
2292 | /* standard operations */ | ||
2293 | if (!udc_controller) | ||
2294 | return -ENODEV; | ||
2295 | |||
2296 | if (!driver || (driver->speed != USB_SPEED_FULL | ||
2297 | && driver->speed != USB_SPEED_HIGH) | ||
2298 | || !driver->bind || !driver->disconnect | ||
2299 | || !driver->setup) | ||
2300 | return -EINVAL; | ||
2301 | |||
2302 | if (udc_controller->driver) | ||
2303 | return -EBUSY; | ||
2304 | |||
2305 | /* lock is needed but whether should use this lock or another */ | ||
2306 | spin_lock_irqsave(&udc_controller->lock, flags); | ||
2307 | |||
2308 | driver->driver.bus = NULL; | ||
2309 | /* hook up the driver */ | ||
2310 | udc_controller->driver = driver; | ||
2311 | udc_controller->gadget.dev.driver = &driver->driver; | ||
2312 | udc_controller->gadget.speed = (enum usb_device_speed)(driver->speed); | ||
2313 | spin_unlock_irqrestore(&udc_controller->lock, flags); | ||
2314 | |||
2315 | retval = driver->bind(&udc_controller->gadget); | ||
2316 | if (retval) { | ||
2317 | dev_err(udc_controller->dev, "bind to %s --> %d", | ||
2318 | driver->driver.name, retval); | ||
2319 | udc_controller->gadget.dev.driver = NULL; | ||
2320 | udc_controller->driver = NULL; | ||
2321 | return retval; | ||
2322 | } | ||
2323 | |||
2324 | /* Enable IRQ reg and Set usbcmd reg EN bit */ | ||
2325 | qe_usb_enable(); | ||
2326 | |||
2327 | out_be16(&udc_controller->usb_regs->usb_usber, 0xffff); | ||
2328 | out_be16(&udc_controller->usb_regs->usb_usbmr, USB_E_DEFAULT_DEVICE); | ||
2329 | udc_controller->usb_state = USB_STATE_ATTACHED; | ||
2330 | udc_controller->ep0_state = WAIT_FOR_SETUP; | ||
2331 | udc_controller->ep0_dir = USB_DIR_OUT; | ||
2332 | dev_info(udc_controller->dev, "%s bind to driver %s \n", | ||
2333 | udc_controller->gadget.name, driver->driver.name); | ||
2334 | return 0; | ||
2335 | } | ||
2336 | EXPORT_SYMBOL(usb_gadget_register_driver); | ||
2337 | |||
2338 | int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) | ||
2339 | { | ||
2340 | struct qe_ep *loop_ep; | ||
2341 | unsigned long flags; | ||
2342 | |||
2343 | if (!udc_controller) | ||
2344 | return -ENODEV; | ||
2345 | |||
2346 | if (!driver || driver != udc_controller->driver) | ||
2347 | return -EINVAL; | ||
2348 | |||
2349 | /* stop usb controller, disable intr */ | ||
2350 | qe_usb_disable(); | ||
2351 | |||
2352 | /* in fact, no needed */ | ||
2353 | udc_controller->usb_state = USB_STATE_ATTACHED; | ||
2354 | udc_controller->ep0_state = WAIT_FOR_SETUP; | ||
2355 | udc_controller->ep0_dir = 0; | ||
2356 | |||
2357 | /* stand operation */ | ||
2358 | spin_lock_irqsave(&udc_controller->lock, flags); | ||
2359 | udc_controller->gadget.speed = USB_SPEED_UNKNOWN; | ||
2360 | nuke(&udc_controller->eps[0], -ESHUTDOWN); | ||
2361 | list_for_each_entry(loop_ep, &udc_controller->gadget.ep_list, | ||
2362 | ep.ep_list) | ||
2363 | nuke(loop_ep, -ESHUTDOWN); | ||
2364 | spin_unlock_irqrestore(&udc_controller->lock, flags); | ||
2365 | |||
2366 | /* unbind gadget and unhook driver. */ | ||
2367 | driver->unbind(&udc_controller->gadget); | ||
2368 | udc_controller->gadget.dev.driver = NULL; | ||
2369 | udc_controller->driver = NULL; | ||
2370 | |||
2371 | dev_info(udc_controller->dev, "unregistered gadget driver '%s'\r\n", | ||
2372 | driver->driver.name); | ||
2373 | return 0; | ||
2374 | } | ||
2375 | EXPORT_SYMBOL(usb_gadget_unregister_driver); | ||
2376 | |||
2377 | /* udc structure's alloc and setup, include ep-param alloc */ | ||
2378 | static struct qe_udc __devinit *qe_udc_config(struct of_device *ofdev) | ||
2379 | { | ||
2380 | struct qe_udc *udc; | ||
2381 | struct device_node *np = ofdev->node; | ||
2382 | unsigned int tmp_addr = 0; | ||
2383 | struct usb_device_para __iomem *usbpram; | ||
2384 | unsigned int i; | ||
2385 | u64 size; | ||
2386 | u32 offset; | ||
2387 | |||
2388 | udc = kzalloc(sizeof(*udc), GFP_KERNEL); | ||
2389 | if (udc == NULL) { | ||
2390 | dev_err(&ofdev->dev, "malloc udc failed\n"); | ||
2391 | goto cleanup; | ||
2392 | } | ||
2393 | |||
2394 | udc->dev = &ofdev->dev; | ||
2395 | |||
2396 | /* get default address of usb parameter in MURAM from device tree */ | ||
2397 | offset = *of_get_address(np, 1, &size, NULL); | ||
2398 | udc->usb_param = cpm_muram_addr(offset); | ||
2399 | memset_io(udc->usb_param, 0, size); | ||
2400 | |||
2401 | usbpram = udc->usb_param; | ||
2402 | out_be16(&usbpram->frame_n, 0); | ||
2403 | out_be32(&usbpram->rstate, 0); | ||
2404 | |||
2405 | tmp_addr = cpm_muram_alloc((USB_MAX_ENDPOINTS * | ||
2406 | sizeof(struct usb_ep_para)), | ||
2407 | USB_EP_PARA_ALIGNMENT); | ||
2408 | |||
2409 | for (i = 0; i < USB_MAX_ENDPOINTS; i++) { | ||
2410 | out_be16(&usbpram->epptr[i], (u16)tmp_addr); | ||
2411 | udc->ep_param[i] = cpm_muram_addr(tmp_addr); | ||
2412 | tmp_addr += 32; | ||
2413 | } | ||
2414 | |||
2415 | memset_io(udc->ep_param[0], 0, | ||
2416 | USB_MAX_ENDPOINTS * sizeof(struct usb_ep_para)); | ||
2417 | |||
2418 | udc->resume_state = USB_STATE_NOTATTACHED; | ||
2419 | udc->usb_state = USB_STATE_POWERED; | ||
2420 | udc->ep0_dir = 0; | ||
2421 | |||
2422 | spin_lock_init(&udc->lock); | ||
2423 | return udc; | ||
2424 | |||
2425 | cleanup: | ||
2426 | kfree(udc); | ||
2427 | return NULL; | ||
2428 | } | ||
2429 | |||
2430 | /* USB Controller register init */ | ||
2431 | static int __devinit qe_udc_reg_init(struct qe_udc *udc) | ||
2432 | { | ||
2433 | struct usb_ctlr __iomem *qe_usbregs; | ||
2434 | qe_usbregs = udc->usb_regs; | ||
2435 | |||
2436 | /* Init the usb register */ | ||
2437 | out_8(&qe_usbregs->usb_usmod, 0x01); | ||
2438 | out_be16(&qe_usbregs->usb_usbmr, 0); | ||
2439 | out_8(&qe_usbregs->usb_uscom, 0); | ||
2440 | out_be16(&qe_usbregs->usb_usber, USBER_ALL_CLEAR); | ||
2441 | |||
2442 | return 0; | ||
2443 | } | ||
2444 | |||
2445 | static int __devinit qe_ep_config(struct qe_udc *udc, unsigned char pipe_num) | ||
2446 | { | ||
2447 | struct qe_ep *ep = &udc->eps[pipe_num]; | ||
2448 | |||
2449 | ep->udc = udc; | ||
2450 | strcpy(ep->name, ep_name[pipe_num]); | ||
2451 | ep->ep.name = ep_name[pipe_num]; | ||
2452 | |||
2453 | ep->ep.ops = &qe_ep_ops; | ||
2454 | ep->stopped = 1; | ||
2455 | ep->ep.maxpacket = (unsigned short) ~0; | ||
2456 | ep->desc = NULL; | ||
2457 | ep->dir = 0xff; | ||
2458 | ep->epnum = (u8)pipe_num; | ||
2459 | ep->sent = 0; | ||
2460 | ep->last = 0; | ||
2461 | ep->init = 0; | ||
2462 | ep->rxframe = NULL; | ||
2463 | ep->txframe = NULL; | ||
2464 | ep->tx_req = NULL; | ||
2465 | ep->state = EP_STATE_IDLE; | ||
2466 | ep->has_data = 0; | ||
2467 | |||
2468 | /* the queue lists any req for this ep */ | ||
2469 | INIT_LIST_HEAD(&ep->queue); | ||
2470 | |||
2471 | /* gagdet.ep_list used for ep_autoconfig so no ep0*/ | ||
2472 | if (pipe_num != 0) | ||
2473 | list_add_tail(&ep->ep.ep_list, &udc->gadget.ep_list); | ||
2474 | |||
2475 | ep->gadget = &udc->gadget; | ||
2476 | |||
2477 | return 0; | ||
2478 | } | ||
2479 | |||
2480 | /*----------------------------------------------------------------------- | ||
2481 | * UDC device Driver operation functions * | ||
2482 | *----------------------------------------------------------------------*/ | ||
2483 | static void qe_udc_release(struct device *dev) | ||
2484 | { | ||
2485 | int i = 0; | ||
2486 | |||
2487 | complete(udc_controller->done); | ||
2488 | cpm_muram_free(cpm_muram_offset(udc_controller->ep_param[0])); | ||
2489 | for (i = 0; i < USB_MAX_ENDPOINTS; i++) | ||
2490 | udc_controller->ep_param[i] = NULL; | ||
2491 | |||
2492 | kfree(udc_controller); | ||
2493 | udc_controller = NULL; | ||
2494 | } | ||
2495 | |||
2496 | /* Driver probe functions */ | ||
2497 | static int __devinit qe_udc_probe(struct of_device *ofdev, | ||
2498 | const struct of_device_id *match) | ||
2499 | { | ||
2500 | struct device_node *np = ofdev->node; | ||
2501 | struct qe_ep *ep; | ||
2502 | unsigned int ret = 0; | ||
2503 | unsigned int i; | ||
2504 | const void *prop; | ||
2505 | |||
2506 | prop = of_get_property(np, "mode", NULL); | ||
2507 | if (!prop || strcmp(prop, "peripheral")) | ||
2508 | return -ENODEV; | ||
2509 | |||
2510 | /* Initialize the udc structure including QH member and other member */ | ||
2511 | udc_controller = qe_udc_config(ofdev); | ||
2512 | if (!udc_controller) { | ||
2513 | dev_dbg(&ofdev->dev, "udc_controll is NULL\n"); | ||
2514 | return -ENOMEM; | ||
2515 | } | ||
2516 | |||
2517 | udc_controller->soc_type = (unsigned long)match->data; | ||
2518 | udc_controller->usb_regs = of_iomap(np, 0); | ||
2519 | if (!udc_controller->usb_regs) { | ||
2520 | ret = -ENOMEM; | ||
2521 | goto err1; | ||
2522 | } | ||
2523 | |||
2524 | /* initialize usb hw reg except for regs for EP, | ||
2525 | * leave usbintr reg untouched*/ | ||
2526 | qe_udc_reg_init(udc_controller); | ||
2527 | |||
2528 | /* here comes the stand operations for probe | ||
2529 | * set the qe_udc->gadget.xxx */ | ||
2530 | udc_controller->gadget.ops = &qe_gadget_ops; | ||
2531 | |||
2532 | /* gadget.ep0 is a pointer */ | ||
2533 | udc_controller->gadget.ep0 = &udc_controller->eps[0].ep; | ||
2534 | |||
2535 | INIT_LIST_HEAD(&udc_controller->gadget.ep_list); | ||
2536 | |||
2537 | /* modify in register gadget process */ | ||
2538 | udc_controller->gadget.speed = USB_SPEED_UNKNOWN; | ||
2539 | |||
2540 | /* name: Identifies the controller hardware type. */ | ||
2541 | udc_controller->gadget.name = driver_name; | ||
2542 | |||
2543 | device_initialize(&udc_controller->gadget.dev); | ||
2544 | |||
2545 | strcpy(udc_controller->gadget.dev.bus_id, "gadget"); | ||
2546 | |||
2547 | udc_controller->gadget.dev.release = qe_udc_release; | ||
2548 | udc_controller->gadget.dev.parent = &ofdev->dev; | ||
2549 | |||
2550 | /* initialize qe_ep struct */ | ||
2551 | for (i = 0; i < USB_MAX_ENDPOINTS ; i++) { | ||
2552 | /* because the ep type isn't decide here so | ||
2553 | * qe_ep_init() should be called in ep_enable() */ | ||
2554 | |||
2555 | /* setup the qe_ep struct and link ep.ep.list | ||
2556 | * into gadget.ep_list */ | ||
2557 | qe_ep_config(udc_controller, (unsigned char)i); | ||
2558 | } | ||
2559 | |||
2560 | /* ep0 initialization in here */ | ||
2561 | ret = qe_ep_init(udc_controller, 0, &qe_ep0_desc); | ||
2562 | if (ret) | ||
2563 | goto err2; | ||
2564 | |||
2565 | /* create a buf for ZLP send, need to remain zeroed */ | ||
2566 | udc_controller->nullbuf = kzalloc(256, GFP_KERNEL); | ||
2567 | if (udc_controller->nullbuf == NULL) { | ||
2568 | dev_dbg(udc_controller->dev, "cannot alloc nullbuf\n"); | ||
2569 | ret = -ENOMEM; | ||
2570 | goto err3; | ||
2571 | } | ||
2572 | |||
2573 | /* buffer for data of get_status request */ | ||
2574 | udc_controller->statusbuf = kzalloc(2, GFP_KERNEL); | ||
2575 | if (udc_controller->statusbuf == NULL) { | ||
2576 | ret = -ENOMEM; | ||
2577 | goto err4; | ||
2578 | } | ||
2579 | |||
2580 | udc_controller->nullp = virt_to_phys((void *)udc_controller->nullbuf); | ||
2581 | if (udc_controller->nullp == DMA_ADDR_INVALID) { | ||
2582 | udc_controller->nullp = dma_map_single( | ||
2583 | udc_controller->gadget.dev.parent, | ||
2584 | udc_controller->nullbuf, | ||
2585 | 256, | ||
2586 | DMA_TO_DEVICE); | ||
2587 | udc_controller->nullmap = 1; | ||
2588 | } else { | ||
2589 | dma_sync_single_for_device(udc_controller->gadget.dev.parent, | ||
2590 | udc_controller->nullp, 256, | ||
2591 | DMA_TO_DEVICE); | ||
2592 | } | ||
2593 | |||
2594 | tasklet_init(&udc_controller->rx_tasklet, ep_rx_tasklet, | ||
2595 | (unsigned long)udc_controller); | ||
2596 | /* request irq and disable DR */ | ||
2597 | udc_controller->usb_irq = irq_of_parse_and_map(np, 0); | ||
2598 | |||
2599 | ret = request_irq(udc_controller->usb_irq, qe_udc_irq, 0, | ||
2600 | driver_name, udc_controller); | ||
2601 | if (ret) { | ||
2602 | dev_err(udc_controller->dev, "cannot request irq %d err %d \n", | ||
2603 | udc_controller->usb_irq, ret); | ||
2604 | goto err5; | ||
2605 | } | ||
2606 | |||
2607 | ret = device_add(&udc_controller->gadget.dev); | ||
2608 | if (ret) | ||
2609 | goto err6; | ||
2610 | |||
2611 | dev_info(udc_controller->dev, | ||
2612 | "%s USB controller initialized as device\n", | ||
2613 | (udc_controller->soc_type == PORT_QE) ? "QE" : "CPM"); | ||
2614 | return 0; | ||
2615 | |||
2616 | err6: | ||
2617 | free_irq(udc_controller->usb_irq, udc_controller); | ||
2618 | err5: | ||
2619 | if (udc_controller->nullmap) { | ||
2620 | dma_unmap_single(udc_controller->gadget.dev.parent, | ||
2621 | udc_controller->nullp, 256, | ||
2622 | DMA_TO_DEVICE); | ||
2623 | udc_controller->nullp = DMA_ADDR_INVALID; | ||
2624 | } else { | ||
2625 | dma_sync_single_for_cpu(udc_controller->gadget.dev.parent, | ||
2626 | udc_controller->nullp, 256, | ||
2627 | DMA_TO_DEVICE); | ||
2628 | } | ||
2629 | kfree(udc_controller->statusbuf); | ||
2630 | err4: | ||
2631 | kfree(udc_controller->nullbuf); | ||
2632 | err3: | ||
2633 | ep = &udc_controller->eps[0]; | ||
2634 | cpm_muram_free(cpm_muram_offset(ep->rxbase)); | ||
2635 | kfree(ep->rxframe); | ||
2636 | kfree(ep->rxbuffer); | ||
2637 | kfree(ep->txframe); | ||
2638 | err2: | ||
2639 | iounmap(udc_controller->usb_regs); | ||
2640 | err1: | ||
2641 | kfree(udc_controller); | ||
2642 | |||
2643 | return ret; | ||
2644 | } | ||
2645 | |||
2646 | #ifdef CONFIG_PM | ||
2647 | static int qe_udc_suspend(struct of_device *dev, pm_message_t state) | ||
2648 | { | ||
2649 | return -ENOTSUPP; | ||
2650 | } | ||
2651 | |||
2652 | static int qe_udc_resume(struct of_device *dev) | ||
2653 | { | ||
2654 | return -ENOTSUPP; | ||
2655 | } | ||
2656 | #endif | ||
2657 | |||
2658 | static int __devexit qe_udc_remove(struct of_device *ofdev) | ||
2659 | { | ||
2660 | struct qe_ep *ep; | ||
2661 | unsigned int size; | ||
2662 | |||
2663 | DECLARE_COMPLETION(done); | ||
2664 | |||
2665 | if (!udc_controller) | ||
2666 | return -ENODEV; | ||
2667 | |||
2668 | udc_controller->done = &done; | ||
2669 | tasklet_disable(&udc_controller->rx_tasklet); | ||
2670 | |||
2671 | if (udc_controller->nullmap) { | ||
2672 | dma_unmap_single(udc_controller->gadget.dev.parent, | ||
2673 | udc_controller->nullp, 256, | ||
2674 | DMA_TO_DEVICE); | ||
2675 | udc_controller->nullp = DMA_ADDR_INVALID; | ||
2676 | } else { | ||
2677 | dma_sync_single_for_cpu(udc_controller->gadget.dev.parent, | ||
2678 | udc_controller->nullp, 256, | ||
2679 | DMA_TO_DEVICE); | ||
2680 | } | ||
2681 | kfree(udc_controller->statusbuf); | ||
2682 | kfree(udc_controller->nullbuf); | ||
2683 | |||
2684 | ep = &udc_controller->eps[0]; | ||
2685 | cpm_muram_free(cpm_muram_offset(ep->rxbase)); | ||
2686 | size = (ep->ep.maxpacket + USB_CRC_SIZE + 2) * (USB_BDRING_LEN + 1); | ||
2687 | |||
2688 | kfree(ep->rxframe); | ||
2689 | if (ep->rxbufmap) { | ||
2690 | dma_unmap_single(udc_controller->gadget.dev.parent, | ||
2691 | ep->rxbuf_d, size, | ||
2692 | DMA_FROM_DEVICE); | ||
2693 | ep->rxbuf_d = DMA_ADDR_INVALID; | ||
2694 | } else { | ||
2695 | dma_sync_single_for_cpu(udc_controller->gadget.dev.parent, | ||
2696 | ep->rxbuf_d, size, | ||
2697 | DMA_FROM_DEVICE); | ||
2698 | } | ||
2699 | |||
2700 | kfree(ep->rxbuffer); | ||
2701 | kfree(ep->txframe); | ||
2702 | |||
2703 | free_irq(udc_controller->usb_irq, udc_controller); | ||
2704 | |||
2705 | tasklet_kill(&udc_controller->rx_tasklet); | ||
2706 | |||
2707 | iounmap(udc_controller->usb_regs); | ||
2708 | |||
2709 | device_unregister(&udc_controller->gadget.dev); | ||
2710 | /* wait for release() of gadget.dev to free udc */ | ||
2711 | wait_for_completion(&done); | ||
2712 | |||
2713 | return 0; | ||
2714 | } | ||
2715 | |||
2716 | /*-------------------------------------------------------------------------*/ | ||
2717 | static struct of_device_id __devinitdata qe_udc_match[] = { | ||
2718 | { | ||
2719 | .compatible = "fsl,mpc8360-qe-usb", | ||
2720 | .data = (void *)PORT_QE, | ||
2721 | }, | ||
2722 | { | ||
2723 | .compatible = "fsl,mpc8272-cpm-usb", | ||
2724 | .data = (void *)PORT_CPM, | ||
2725 | }, | ||
2726 | {}, | ||
2727 | }; | ||
2728 | |||
2729 | MODULE_DEVICE_TABLE(of, qe_udc_match); | ||
2730 | |||
2731 | static struct of_platform_driver udc_driver = { | ||
2732 | .name = (char *)driver_name, | ||
2733 | .match_table = qe_udc_match, | ||
2734 | .probe = qe_udc_probe, | ||
2735 | .remove = __devexit_p(qe_udc_remove), | ||
2736 | #ifdef CONFIG_PM | ||
2737 | .suspend = qe_udc_suspend, | ||
2738 | .resume = qe_udc_resume, | ||
2739 | #endif | ||
2740 | }; | ||
2741 | |||
2742 | static int __init qe_udc_init(void) | ||
2743 | { | ||
2744 | printk(KERN_INFO "%s: %s, %s\n", driver_name, driver_desc, | ||
2745 | DRIVER_VERSION); | ||
2746 | return of_register_platform_driver(&udc_driver); | ||
2747 | } | ||
2748 | |||
2749 | static void __exit qe_udc_exit(void) | ||
2750 | { | ||
2751 | of_unregister_platform_driver(&udc_driver); | ||
2752 | } | ||
2753 | |||
2754 | module_init(qe_udc_init); | ||
2755 | module_exit(qe_udc_exit); | ||
2756 | |||
2757 | MODULE_DESCRIPTION(DRIVER_DESC); | ||
2758 | MODULE_AUTHOR(DRIVER_AUTHOR); | ||
2759 | MODULE_LICENSE("GPL"); | ||
2760 | |||
diff --git a/drivers/usb/gadget/fsl_qe_udc.h b/drivers/usb/gadget/fsl_qe_udc.h new file mode 100644 index 000000000000..31b2710882e4 --- /dev/null +++ b/drivers/usb/gadget/fsl_qe_udc.h | |||
@@ -0,0 +1,437 @@ | |||
1 | /* | ||
2 | * drivers/usb/gadget/qe_udc.h | ||
3 | * | ||
4 | * Copyright (C) 2006-2008 Freescale Semiconductor, Inc. All rights reserved. | ||
5 | * | ||
6 | * Xiaobo Xie <X.Xie@freescale.com> | ||
7 | * Li Yang <leoli@freescale.com> | ||
8 | * | ||
9 | * Description: | ||
10 | * Freescale USB device/endpoint management registers | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or modify | ||
13 | * it under the terms of the GNU General Public License as published by | ||
14 | * the Free Software Foundation; either version 2 of the License, or (at | ||
15 | * your option) any later version. | ||
16 | */ | ||
17 | |||
18 | #ifndef __FSL_QE_UDC_H | ||
19 | #define __FSL_QE_UDC_H | ||
20 | |||
21 | /* SoC type */ | ||
22 | #define PORT_CPM 0 | ||
23 | #define PORT_QE 1 | ||
24 | |||
25 | #define USB_MAX_ENDPOINTS 4 | ||
26 | #define USB_MAX_PIPES USB_MAX_ENDPOINTS | ||
27 | #define USB_EP0_MAX_SIZE 64 | ||
28 | #define USB_MAX_CTRL_PAYLOAD 0x4000 | ||
29 | #define USB_BDRING_LEN 16 | ||
30 | #define USB_BDRING_LEN_RX 256 | ||
31 | #define USB_BDRING_LEN_TX 16 | ||
32 | #define MIN_EMPTY_BDS 128 | ||
33 | #define MAX_DATA_BDS 8 | ||
34 | #define USB_CRC_SIZE 2 | ||
35 | #define USB_DIR_BOTH 0x88 | ||
36 | #define R_BUF_MAXSIZE 0x800 | ||
37 | #define USB_EP_PARA_ALIGNMENT 32 | ||
38 | |||
39 | /* USB Mode Register bit define */ | ||
40 | #define USB_MODE_EN 0x01 | ||
41 | #define USB_MODE_HOST 0x02 | ||
42 | #define USB_MODE_TEST 0x04 | ||
43 | #define USB_MODE_SFTE 0x08 | ||
44 | #define USB_MODE_RESUME 0x40 | ||
45 | #define USB_MODE_LSS 0x80 | ||
46 | |||
47 | /* USB Slave Address Register Mask */ | ||
48 | #define USB_SLVADDR_MASK 0x7F | ||
49 | |||
50 | /* USB Endpoint register define */ | ||
51 | #define USB_EPNUM_MASK 0xF000 | ||
52 | #define USB_EPNUM_SHIFT 12 | ||
53 | |||
54 | #define USB_TRANS_MODE_SHIFT 8 | ||
55 | #define USB_TRANS_CTR 0x0000 | ||
56 | #define USB_TRANS_INT 0x0100 | ||
57 | #define USB_TRANS_BULK 0x0200 | ||
58 | #define USB_TRANS_ISO 0x0300 | ||
59 | |||
60 | #define USB_EP_MF 0x0020 | ||
61 | #define USB_EP_RTE 0x0010 | ||
62 | |||
63 | #define USB_THS_SHIFT 2 | ||
64 | #define USB_THS_MASK 0x000c | ||
65 | #define USB_THS_NORMAL 0x0 | ||
66 | #define USB_THS_IGNORE_IN 0x0004 | ||
67 | #define USB_THS_NACK 0x0008 | ||
68 | #define USB_THS_STALL 0x000c | ||
69 | |||
70 | #define USB_RHS_SHIFT 0 | ||
71 | #define USB_RHS_MASK 0x0003 | ||
72 | #define USB_RHS_NORMAL 0x0 | ||
73 | #define USB_RHS_IGNORE_OUT 0x0001 | ||
74 | #define USB_RHS_NACK 0x0002 | ||
75 | #define USB_RHS_STALL 0x0003 | ||
76 | |||
77 | #define USB_RTHS_MASK 0x000f | ||
78 | |||
79 | /* USB Command Register define */ | ||
80 | #define USB_CMD_STR_FIFO 0x80 | ||
81 | #define USB_CMD_FLUSH_FIFO 0x40 | ||
82 | #define USB_CMD_ISFT 0x20 | ||
83 | #define USB_CMD_DSFT 0x10 | ||
84 | #define USB_CMD_EP_MASK 0x03 | ||
85 | |||
86 | /* USB Event and Mask Register define */ | ||
87 | #define USB_E_MSF_MASK 0x0800 | ||
88 | #define USB_E_SFT_MASK 0x0400 | ||
89 | #define USB_E_RESET_MASK 0x0200 | ||
90 | #define USB_E_IDLE_MASK 0x0100 | ||
91 | #define USB_E_TXE4_MASK 0x0080 | ||
92 | #define USB_E_TXE3_MASK 0x0040 | ||
93 | #define USB_E_TXE2_MASK 0x0020 | ||
94 | #define USB_E_TXE1_MASK 0x0010 | ||
95 | #define USB_E_SOF_MASK 0x0008 | ||
96 | #define USB_E_BSY_MASK 0x0004 | ||
97 | #define USB_E_TXB_MASK 0x0002 | ||
98 | #define USB_E_RXB_MASK 0x0001 | ||
99 | #define USBER_ALL_CLEAR 0x0fff | ||
100 | |||
101 | #define USB_E_DEFAULT_DEVICE (USB_E_RESET_MASK | USB_E_TXE4_MASK | \ | ||
102 | USB_E_TXE3_MASK | USB_E_TXE2_MASK | \ | ||
103 | USB_E_TXE1_MASK | USB_E_BSY_MASK | \ | ||
104 | USB_E_TXB_MASK | USB_E_RXB_MASK) | ||
105 | |||
106 | #define USB_E_TXE_MASK (USB_E_TXE4_MASK | USB_E_TXE3_MASK|\ | ||
107 | USB_E_TXE2_MASK | USB_E_TXE1_MASK) | ||
108 | /* USB Status Register define */ | ||
109 | #define USB_IDLE_STATUS_MASK 0x01 | ||
110 | |||
111 | /* USB Start of Frame Timer */ | ||
112 | #define USB_USSFT_MASK 0x3FFF | ||
113 | |||
114 | /* USB Frame Number Register */ | ||
115 | #define USB_USFRN_MASK 0xFFFF | ||
116 | |||
117 | struct usb_device_para{ | ||
118 | u16 epptr[4]; | ||
119 | u32 rstate; | ||
120 | u32 rptr; | ||
121 | u16 frame_n; | ||
122 | u16 rbcnt; | ||
123 | u32 rtemp; | ||
124 | u32 rxusb_data; | ||
125 | u16 rxuptr; | ||
126 | u8 reso[2]; | ||
127 | u32 softbl; | ||
128 | u8 sofucrctemp; | ||
129 | }; | ||
130 | |||
131 | struct usb_ep_para{ | ||
132 | u16 rbase; | ||
133 | u16 tbase; | ||
134 | u8 rbmr; | ||
135 | u8 tbmr; | ||
136 | u16 mrblr; | ||
137 | u16 rbptr; | ||
138 | u16 tbptr; | ||
139 | u32 tstate; | ||
140 | u32 tptr; | ||
141 | u16 tcrc; | ||
142 | u16 tbcnt; | ||
143 | u32 ttemp; | ||
144 | u16 txusbu_ptr; | ||
145 | u8 reserve[2]; | ||
146 | }; | ||
147 | |||
148 | #define USB_BUSMODE_GBL 0x20 | ||
149 | #define USB_BUSMODE_BO_MASK 0x18 | ||
150 | #define USB_BUSMODE_BO_SHIFT 0x3 | ||
151 | #define USB_BUSMODE_BE 0x2 | ||
152 | #define USB_BUSMODE_CETM 0x04 | ||
153 | #define USB_BUSMODE_DTB 0x02 | ||
154 | |||
155 | /* Endpoint basic handle */ | ||
156 | #define ep_index(EP) ((EP)->desc->bEndpointAddress & 0xF) | ||
157 | #define ep_maxpacket(EP) ((EP)->ep.maxpacket) | ||
158 | #define ep_is_in(EP) ((ep_index(EP) == 0) ? (EP->udc->ep0_dir == \ | ||
159 | USB_DIR_IN) : ((EP)->desc->bEndpointAddress \ | ||
160 | & USB_DIR_IN) == USB_DIR_IN) | ||
161 | |||
162 | /* ep0 transfer state */ | ||
163 | #define WAIT_FOR_SETUP 0 | ||
164 | #define DATA_STATE_XMIT 1 | ||
165 | #define DATA_STATE_NEED_ZLP 2 | ||
166 | #define WAIT_FOR_OUT_STATUS 3 | ||
167 | #define DATA_STATE_RECV 4 | ||
168 | |||
169 | /* ep tramsfer mode */ | ||
170 | #define USBP_TM_CTL 0 | ||
171 | #define USBP_TM_ISO 1 | ||
172 | #define USBP_TM_BULK 2 | ||
173 | #define USBP_TM_INT 3 | ||
174 | |||
175 | /*----------------------------------------------------------------------------- | ||
176 | USB RX And TX DATA Frame | ||
177 | -----------------------------------------------------------------------------*/ | ||
178 | struct qe_frame{ | ||
179 | u8 *data; | ||
180 | u32 len; | ||
181 | u32 status; | ||
182 | u32 info; | ||
183 | |||
184 | void *privdata; | ||
185 | struct list_head node; | ||
186 | }; | ||
187 | |||
188 | /* Frame structure, info field. */ | ||
189 | #define PID_DATA0 0x80000000 /* Data toggle zero */ | ||
190 | #define PID_DATA1 0x40000000 /* Data toggle one */ | ||
191 | #define PID_SETUP 0x20000000 /* setup bit */ | ||
192 | #define SETUP_STATUS 0x10000000 /* setup status bit */ | ||
193 | #define SETADDR_STATUS 0x08000000 /* setupup address status bit */ | ||
194 | #define NO_REQ 0x04000000 /* Frame without request */ | ||
195 | #define HOST_DATA 0x02000000 /* Host data frame */ | ||
196 | #define FIRST_PACKET_IN_FRAME 0x01000000 /* first packet in the frame */ | ||
197 | #define TOKEN_FRAME 0x00800000 /* Host token frame */ | ||
198 | #define ZLP 0x00400000 /* Zero length packet */ | ||
199 | #define IN_TOKEN_FRAME 0x00200000 /* In token package */ | ||
200 | #define OUT_TOKEN_FRAME 0x00100000 /* Out token package */ | ||
201 | #define SETUP_TOKEN_FRAME 0x00080000 /* Setup token package */ | ||
202 | #define STALL_FRAME 0x00040000 /* Stall handshake */ | ||
203 | #define NACK_FRAME 0x00020000 /* Nack handshake */ | ||
204 | #define NO_PID 0x00010000 /* No send PID */ | ||
205 | #define NO_CRC 0x00008000 /* No send CRC */ | ||
206 | #define HOST_COMMAND 0x00004000 /* Host command frame */ | ||
207 | |||
208 | /* Frame status field */ | ||
209 | /* Receive side */ | ||
210 | #define FRAME_OK 0x00000000 /* Frame tranmitted or received OK */ | ||
211 | #define FRAME_ERROR 0x80000000 /* Error occured on frame */ | ||
212 | #define START_FRAME_LOST 0x40000000 /* START_FRAME_LOST */ | ||
213 | #define END_FRAME_LOST 0x20000000 /* END_FRAME_LOST */ | ||
214 | #define RX_ER_NONOCT 0x10000000 /* Rx Non Octet Aligned Packet */ | ||
215 | #define RX_ER_BITSTUFF 0x08000000 /* Frame Aborted --Received packet | ||
216 | with bit stuff error */ | ||
217 | #define RX_ER_CRC 0x04000000 /* Received packet with CRC error */ | ||
218 | #define RX_ER_OVERUN 0x02000000 /* Over-run occured on reception */ | ||
219 | #define RX_ER_PID 0x01000000 /* Wrong PID received */ | ||
220 | /* Tranmit side */ | ||
221 | #define TX_ER_NAK 0x00800000 /* Received NAK handshake */ | ||
222 | #define TX_ER_STALL 0x00400000 /* Received STALL handshake */ | ||
223 | #define TX_ER_TIMEOUT 0x00200000 /* Transmit time out */ | ||
224 | #define TX_ER_UNDERUN 0x00100000 /* Transmit underrun */ | ||
225 | #define FRAME_INPROGRESS 0x00080000 /* Frame is being transmitted */ | ||
226 | #define ER_DATA_UNDERUN 0x00040000 /* Frame is shorter then expected */ | ||
227 | #define ER_DATA_OVERUN 0x00020000 /* Frame is longer then expected */ | ||
228 | |||
229 | /* QE USB frame operation functions */ | ||
230 | #define frame_get_length(frm) (frm->len) | ||
231 | #define frame_set_length(frm, leng) (frm->len = leng) | ||
232 | #define frame_get_data(frm) (frm->data) | ||
233 | #define frame_set_data(frm, dat) (frm->data = dat) | ||
234 | #define frame_get_info(frm) (frm->info) | ||
235 | #define frame_set_info(frm, inf) (frm->info = inf) | ||
236 | #define frame_get_status(frm) (frm->status) | ||
237 | #define frame_set_status(frm, stat) (frm->status = stat) | ||
238 | #define frame_get_privdata(frm) (frm->privdata) | ||
239 | #define frame_set_privdata(frm, dat) (frm->privdata = dat) | ||
240 | |||
241 | static inline void qe_frame_clean(struct qe_frame *frm) | ||
242 | { | ||
243 | frame_set_data(frm, NULL); | ||
244 | frame_set_length(frm, 0); | ||
245 | frame_set_status(frm, FRAME_OK); | ||
246 | frame_set_info(frm, 0); | ||
247 | frame_set_privdata(frm, NULL); | ||
248 | } | ||
249 | |||
250 | static inline void qe_frame_init(struct qe_frame *frm) | ||
251 | { | ||
252 | qe_frame_clean(frm); | ||
253 | INIT_LIST_HEAD(&(frm->node)); | ||
254 | } | ||
255 | |||
256 | struct qe_req { | ||
257 | struct usb_request req; | ||
258 | struct list_head queue; | ||
259 | /* ep_queue() func will add | ||
260 | a request->queue into a udc_ep->queue 'd tail */ | ||
261 | struct qe_ep *ep; | ||
262 | unsigned mapped:1; | ||
263 | }; | ||
264 | |||
265 | struct qe_ep { | ||
266 | struct usb_ep ep; | ||
267 | struct list_head queue; | ||
268 | struct qe_udc *udc; | ||
269 | const struct usb_endpoint_descriptor *desc; | ||
270 | struct usb_gadget *gadget; | ||
271 | |||
272 | u8 state; | ||
273 | |||
274 | struct qe_bd __iomem *rxbase; | ||
275 | struct qe_bd __iomem *n_rxbd; | ||
276 | struct qe_bd __iomem *e_rxbd; | ||
277 | |||
278 | struct qe_bd __iomem *txbase; | ||
279 | struct qe_bd __iomem *n_txbd; | ||
280 | struct qe_bd __iomem *c_txbd; | ||
281 | |||
282 | struct qe_frame *rxframe; | ||
283 | u8 *rxbuffer; | ||
284 | dma_addr_t rxbuf_d; | ||
285 | u8 rxbufmap; | ||
286 | unsigned char localnack; | ||
287 | int has_data; | ||
288 | |||
289 | struct qe_frame *txframe; | ||
290 | struct qe_req *tx_req; | ||
291 | int sent; /*data already sent */ | ||
292 | int last; /*data sent in the last time*/ | ||
293 | |||
294 | u8 dir; | ||
295 | u8 epnum; | ||
296 | u8 tm; /* transfer mode */ | ||
297 | u8 data01; | ||
298 | u8 init; | ||
299 | |||
300 | u8 already_seen; | ||
301 | u8 enable_tasklet; | ||
302 | u8 setup_stage; | ||
303 | u32 last_io; /* timestamp */ | ||
304 | |||
305 | char name[14]; | ||
306 | |||
307 | unsigned double_buf:1; | ||
308 | unsigned stopped:1; | ||
309 | unsigned fnf:1; | ||
310 | unsigned has_dma:1; | ||
311 | |||
312 | u8 ackwait; | ||
313 | u8 dma_channel; | ||
314 | u16 dma_counter; | ||
315 | int lch; | ||
316 | |||
317 | struct timer_list timer; | ||
318 | }; | ||
319 | |||
320 | struct qe_udc { | ||
321 | struct usb_gadget gadget; | ||
322 | struct usb_gadget_driver *driver; | ||
323 | struct device *dev; | ||
324 | struct qe_ep eps[USB_MAX_ENDPOINTS]; | ||
325 | struct usb_ctrlrequest local_setup_buff; | ||
326 | spinlock_t lock; /* lock for set/config qe_udc */ | ||
327 | unsigned long soc_type; /* QE or CPM soc */ | ||
328 | |||
329 | struct qe_req *status_req; /* ep0 status request */ | ||
330 | |||
331 | /* USB and EP Parameter Block pointer */ | ||
332 | struct usb_device_para __iomem *usb_param; | ||
333 | struct usb_ep_para __iomem *ep_param[4]; | ||
334 | |||
335 | u32 max_pipes; /* Device max pipes */ | ||
336 | u32 max_use_endpts; /* Max endpointes to be used */ | ||
337 | u32 bus_reset; /* Device is bus reseting */ | ||
338 | u32 resume_state; /* USB state to resume*/ | ||
339 | u32 usb_state; /* USB current state */ | ||
340 | u32 usb_next_state; /* USB next state */ | ||
341 | u32 ep0_state; /* Enpoint zero state */ | ||
342 | u32 ep0_dir; /* Enpoint zero direction: can be | ||
343 | USB_DIR_IN or USB_DIR_OUT*/ | ||
344 | u32 usb_sof_count; /* SOF count */ | ||
345 | u32 errors; /* USB ERRORs count */ | ||
346 | |||
347 | u8 *tmpbuf; | ||
348 | u32 c_start; | ||
349 | u32 c_end; | ||
350 | |||
351 | u8 *nullbuf; | ||
352 | u8 *statusbuf; | ||
353 | dma_addr_t nullp; | ||
354 | u8 nullmap; | ||
355 | u8 device_address; /* Device USB address */ | ||
356 | |||
357 | unsigned int usb_clock; | ||
358 | unsigned int usb_irq; | ||
359 | struct usb_ctlr __iomem *usb_regs; | ||
360 | |||
361 | struct tasklet_struct rx_tasklet; | ||
362 | |||
363 | struct completion *done; /* to make sure release() is done */ | ||
364 | }; | ||
365 | |||
366 | #define EP_STATE_IDLE 0 | ||
367 | #define EP_STATE_NACK 1 | ||
368 | #define EP_STATE_STALL 2 | ||
369 | |||
370 | /* | ||
371 | * transmit BD's status | ||
372 | */ | ||
373 | #define T_R 0x80000000 /* ready bit */ | ||
374 | #define T_W 0x20000000 /* wrap bit */ | ||
375 | #define T_I 0x10000000 /* interrupt on completion */ | ||
376 | #define T_L 0x08000000 /* last */ | ||
377 | #define T_TC 0x04000000 /* transmit CRC */ | ||
378 | #define T_CNF 0x02000000 /* wait for transmit confirm */ | ||
379 | #define T_LSP 0x01000000 /* Low-speed transaction */ | ||
380 | #define T_PID 0x00c00000 /* packet id */ | ||
381 | #define T_NAK 0x00100000 /* No ack. */ | ||
382 | #define T_STAL 0x00080000 /* Stall recieved */ | ||
383 | #define T_TO 0x00040000 /* time out */ | ||
384 | #define T_UN 0x00020000 /* underrun */ | ||
385 | |||
386 | #define DEVICE_T_ERROR (T_UN | T_TO) | ||
387 | #define HOST_T_ERROR (T_UN | T_TO | T_NAK | T_STAL) | ||
388 | #define DEVICE_T_BD_MASK DEVICE_T_ERROR | ||
389 | #define HOST_T_BD_MASK HOST_T_ERROR | ||
390 | |||
391 | #define T_PID_SHIFT 6 | ||
392 | #define T_PID_DATA0 0x00800000 /* Data 0 toggle */ | ||
393 | #define T_PID_DATA1 0x00c00000 /* Data 1 toggle */ | ||
394 | |||
395 | /* | ||
396 | * receive BD's status | ||
397 | */ | ||
398 | #define R_E 0x80000000 /* buffer empty */ | ||
399 | #define R_W 0x20000000 /* wrap bit */ | ||
400 | #define R_I 0x10000000 /* interrupt on reception */ | ||
401 | #define R_L 0x08000000 /* last */ | ||
402 | #define R_F 0x04000000 /* first */ | ||
403 | #define R_PID 0x00c00000 /* packet id */ | ||
404 | #define R_NO 0x00100000 /* Rx Non Octet Aligned Packet */ | ||
405 | #define R_AB 0x00080000 /* Frame Aborted */ | ||
406 | #define R_CR 0x00040000 /* CRC Error */ | ||
407 | #define R_OV 0x00020000 /* Overrun */ | ||
408 | |||
409 | #define R_ERROR (R_NO | R_AB | R_CR | R_OV) | ||
410 | #define R_BD_MASK R_ERROR | ||
411 | |||
412 | #define R_PID_DATA0 0x00000000 | ||
413 | #define R_PID_DATA1 0x00400000 | ||
414 | #define R_PID_SETUP 0x00800000 | ||
415 | |||
416 | #define CPM_USB_STOP_TX 0x2e600000 | ||
417 | #define CPM_USB_RESTART_TX 0x2e600000 | ||
418 | #define CPM_USB_STOP_TX_OPCODE 0x0a | ||
419 | #define CPM_USB_RESTART_TX_OPCODE 0x0b | ||
420 | #define CPM_USB_EP_SHIFT 5 | ||
421 | |||
422 | #ifndef CONFIG_CPM | ||
423 | inline int cpm_command(u32 command, u8 opcode) | ||
424 | { | ||
425 | return -EOPNOTSUPP; | ||
426 | } | ||
427 | #endif | ||
428 | |||
429 | #ifndef CONFIG_QUICC_ENGINE | ||
430 | inline int qe_issue_cmd(u32 cmd, u32 device, u8 mcn_protocol, | ||
431 | u32 cmd_input) | ||
432 | { | ||
433 | return -EOPNOTSUPP; | ||
434 | } | ||
435 | #endif | ||
436 | |||
437 | #endif /* __FSL_QE_UDC_H */ | ||
diff --git a/drivers/usb/gadget/fsl_usb2_udc.c b/drivers/usb/gadget/fsl_usb2_udc.c index 1cfccf102a2d..091bb55c9aa7 100644 --- a/drivers/usb/gadget/fsl_usb2_udc.c +++ b/drivers/usb/gadget/fsl_usb2_udc.c | |||
@@ -23,11 +23,8 @@ | |||
23 | #include <linux/ioport.h> | 23 | #include <linux/ioport.h> |
24 | #include <linux/types.h> | 24 | #include <linux/types.h> |
25 | #include <linux/errno.h> | 25 | #include <linux/errno.h> |
26 | #include <linux/delay.h> | ||
27 | #include <linux/sched.h> | ||
28 | #include <linux/slab.h> | 26 | #include <linux/slab.h> |
29 | #include <linux/init.h> | 27 | #include <linux/init.h> |
30 | #include <linux/timer.h> | ||
31 | #include <linux/list.h> | 28 | #include <linux/list.h> |
32 | #include <linux/interrupt.h> | 29 | #include <linux/interrupt.h> |
33 | #include <linux/proc_fs.h> | 30 | #include <linux/proc_fs.h> |
@@ -44,11 +41,9 @@ | |||
44 | 41 | ||
45 | #include <asm/byteorder.h> | 42 | #include <asm/byteorder.h> |
46 | #include <asm/io.h> | 43 | #include <asm/io.h> |
47 | #include <asm/irq.h> | ||
48 | #include <asm/system.h> | 44 | #include <asm/system.h> |
49 | #include <asm/unaligned.h> | 45 | #include <asm/unaligned.h> |
50 | #include <asm/dma.h> | 46 | #include <asm/dma.h> |
51 | #include <asm/cacheflush.h> | ||
52 | 47 | ||
53 | #include "fsl_usb2_udc.h" | 48 | #include "fsl_usb2_udc.h" |
54 | 49 | ||
@@ -61,8 +56,8 @@ | |||
61 | static const char driver_name[] = "fsl-usb2-udc"; | 56 | static const char driver_name[] = "fsl-usb2-udc"; |
62 | static const char driver_desc[] = DRIVER_DESC; | 57 | static const char driver_desc[] = DRIVER_DESC; |
63 | 58 | ||
64 | volatile static struct usb_dr_device *dr_regs = NULL; | 59 | static struct usb_dr_device *dr_regs; |
65 | volatile static struct usb_sys_interface *usb_sys_regs = NULL; | 60 | static struct usb_sys_interface *usb_sys_regs; |
66 | 61 | ||
67 | /* it is initialized in probe() */ | 62 | /* it is initialized in probe() */ |
68 | static struct fsl_udc *udc_controller = NULL; | 63 | static struct fsl_udc *udc_controller = NULL; |
@@ -76,16 +71,14 @@ fsl_ep0_desc = { | |||
76 | .wMaxPacketSize = USB_MAX_CTRL_PAYLOAD, | 71 | .wMaxPacketSize = USB_MAX_CTRL_PAYLOAD, |
77 | }; | 72 | }; |
78 | 73 | ||
79 | static int fsl_udc_suspend(struct platform_device *pdev, pm_message_t state); | ||
80 | static int fsl_udc_resume(struct platform_device *pdev); | ||
81 | static void fsl_ep_fifo_flush(struct usb_ep *_ep); | 74 | static void fsl_ep_fifo_flush(struct usb_ep *_ep); |
82 | 75 | ||
83 | #ifdef CONFIG_PPC32 | 76 | #ifdef CONFIG_PPC32 |
84 | #define fsl_readl(addr) in_le32(addr) | 77 | #define fsl_readl(addr) in_le32(addr) |
85 | #define fsl_writel(addr, val32) out_le32(val32, addr) | 78 | #define fsl_writel(val32, addr) out_le32(addr, val32) |
86 | #else | 79 | #else |
87 | #define fsl_readl(addr) readl(addr) | 80 | #define fsl_readl(addr) readl(addr) |
88 | #define fsl_writel(addr, val32) writel(addr, val32) | 81 | #define fsl_writel(val32, addr) writel(val32, addr) |
89 | #endif | 82 | #endif |
90 | 83 | ||
91 | /******************************************************************** | 84 | /******************************************************************** |
@@ -185,10 +178,6 @@ static int dr_controller_setup(struct fsl_udc *udc) | |||
185 | unsigned long timeout; | 178 | unsigned long timeout; |
186 | #define FSL_UDC_RESET_TIMEOUT 1000 | 179 | #define FSL_UDC_RESET_TIMEOUT 1000 |
187 | 180 | ||
188 | /* before here, make sure dr_regs has been initialized */ | ||
189 | if (!udc) | ||
190 | return -EINVAL; | ||
191 | |||
192 | /* Stop and reset the usb controller */ | 181 | /* Stop and reset the usb controller */ |
193 | tmp = fsl_readl(&dr_regs->usbcmd); | 182 | tmp = fsl_readl(&dr_regs->usbcmd); |
194 | tmp &= ~USB_CMD_RUN_STOP; | 183 | tmp &= ~USB_CMD_RUN_STOP; |
@@ -202,7 +191,7 @@ static int dr_controller_setup(struct fsl_udc *udc) | |||
202 | timeout = jiffies + FSL_UDC_RESET_TIMEOUT; | 191 | timeout = jiffies + FSL_UDC_RESET_TIMEOUT; |
203 | while (fsl_readl(&dr_regs->usbcmd) & USB_CMD_CTRL_RESET) { | 192 | while (fsl_readl(&dr_regs->usbcmd) & USB_CMD_CTRL_RESET) { |
204 | if (time_after(jiffies, timeout)) { | 193 | if (time_after(jiffies, timeout)) { |
205 | ERR("udc reset timeout! \n"); | 194 | ERR("udc reset timeout!\n"); |
206 | return -ETIMEDOUT; | 195 | return -ETIMEDOUT; |
207 | } | 196 | } |
208 | cpu_relax(); | 197 | cpu_relax(); |
@@ -223,7 +212,7 @@ static int dr_controller_setup(struct fsl_udc *udc) | |||
223 | fsl_writel(tmp, &dr_regs->endpointlistaddr); | 212 | fsl_writel(tmp, &dr_regs->endpointlistaddr); |
224 | 213 | ||
225 | VDBG("vir[qh_base] is %p phy[qh_base] is 0x%8x reg is 0x%8x", | 214 | VDBG("vir[qh_base] is %p phy[qh_base] is 0x%8x reg is 0x%8x", |
226 | (int)udc->ep_qh, (int)tmp, | 215 | udc->ep_qh, (int)tmp, |
227 | fsl_readl(&dr_regs->endpointlistaddr)); | 216 | fsl_readl(&dr_regs->endpointlistaddr)); |
228 | 217 | ||
229 | /* Config PHY interface */ | 218 | /* Config PHY interface */ |
@@ -315,7 +304,8 @@ static void dr_controller_stop(struct fsl_udc *udc) | |||
315 | return; | 304 | return; |
316 | } | 305 | } |
317 | 306 | ||
318 | void dr_ep_setup(unsigned char ep_num, unsigned char dir, unsigned char ep_type) | 307 | static void dr_ep_setup(unsigned char ep_num, unsigned char dir, |
308 | unsigned char ep_type) | ||
319 | { | 309 | { |
320 | unsigned int tmp_epctrl = 0; | 310 | unsigned int tmp_epctrl = 0; |
321 | 311 | ||
@@ -563,7 +553,7 @@ static int fsl_ep_disable(struct usb_ep *_ep) | |||
563 | /* nuke all pending requests (does flush) */ | 553 | /* nuke all pending requests (does flush) */ |
564 | nuke(ep, -ESHUTDOWN); | 554 | nuke(ep, -ESHUTDOWN); |
565 | 555 | ||
566 | ep->desc = 0; | 556 | ep->desc = NULL; |
567 | ep->stopped = 1; | 557 | ep->stopped = 1; |
568 | spin_unlock_irqrestore(&udc->lock, flags); | 558 | spin_unlock_irqrestore(&udc->lock, flags); |
569 | 559 | ||
@@ -602,7 +592,7 @@ static void fsl_free_request(struct usb_ep *_ep, struct usb_request *_req) | |||
602 | } | 592 | } |
603 | 593 | ||
604 | /*-------------------------------------------------------------------------*/ | 594 | /*-------------------------------------------------------------------------*/ |
605 | static int fsl_queue_td(struct fsl_ep *ep, struct fsl_req *req) | 595 | static void fsl_queue_td(struct fsl_ep *ep, struct fsl_req *req) |
606 | { | 596 | { |
607 | int i = ep_index(ep) * 2 + ep_is_in(ep); | 597 | int i = ep_index(ep) * 2 + ep_is_in(ep); |
608 | u32 temp, bitmask, tmp_stat; | 598 | u32 temp, bitmask, tmp_stat; |
@@ -653,13 +643,16 @@ static int fsl_queue_td(struct fsl_ep *ep, struct fsl_req *req) | |||
653 | | EP_QUEUE_HEAD_STATUS_HALT)); | 643 | | EP_QUEUE_HEAD_STATUS_HALT)); |
654 | dQH->size_ioc_int_sts &= temp; | 644 | dQH->size_ioc_int_sts &= temp; |
655 | 645 | ||
646 | /* Ensure that updates to the QH will occure before priming. */ | ||
647 | wmb(); | ||
648 | |||
656 | /* Prime endpoint by writing 1 to ENDPTPRIME */ | 649 | /* Prime endpoint by writing 1 to ENDPTPRIME */ |
657 | temp = ep_is_in(ep) | 650 | temp = ep_is_in(ep) |
658 | ? (1 << (ep_index(ep) + 16)) | 651 | ? (1 << (ep_index(ep) + 16)) |
659 | : (1 << (ep_index(ep))); | 652 | : (1 << (ep_index(ep))); |
660 | fsl_writel(temp, &dr_regs->endpointprime); | 653 | fsl_writel(temp, &dr_regs->endpointprime); |
661 | out: | 654 | out: |
662 | return 0; | 655 | return; |
663 | } | 656 | } |
664 | 657 | ||
665 | /* Fill in the dTD structure | 658 | /* Fill in the dTD structure |
@@ -710,7 +703,7 @@ static struct ep_td_struct *fsl_build_dtd(struct fsl_req *req, unsigned *length, | |||
710 | *is_last = 0; | 703 | *is_last = 0; |
711 | 704 | ||
712 | if ((*is_last) == 0) | 705 | if ((*is_last) == 0) |
713 | VDBG("multi-dtd request!\n"); | 706 | VDBG("multi-dtd request!"); |
714 | /* Fill in the transfer size; set active bit */ | 707 | /* Fill in the transfer size; set active bit */ |
715 | swap_temp = ((*length << DTD_LENGTH_BIT_POS) | DTD_STATUS_ACTIVE); | 708 | swap_temp = ((*length << DTD_LENGTH_BIT_POS) | DTD_STATUS_ACTIVE); |
716 | 709 | ||
@@ -773,11 +766,11 @@ fsl_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags) | |||
773 | /* catch various bogus parameters */ | 766 | /* catch various bogus parameters */ |
774 | if (!_req || !req->req.complete || !req->req.buf | 767 | if (!_req || !req->req.complete || !req->req.buf |
775 | || !list_empty(&req->queue)) { | 768 | || !list_empty(&req->queue)) { |
776 | VDBG("%s, bad params\n", __func__); | 769 | VDBG("%s, bad params", __func__); |
777 | return -EINVAL; | 770 | return -EINVAL; |
778 | } | 771 | } |
779 | if (unlikely(!_ep || !ep->desc)) { | 772 | if (unlikely(!_ep || !ep->desc)) { |
780 | VDBG("%s, bad ep\n", __func__); | 773 | VDBG("%s, bad ep", __func__); |
781 | return -EINVAL; | 774 | return -EINVAL; |
782 | } | 775 | } |
783 | if (ep->desc->bmAttributes == USB_ENDPOINT_XFER_ISOC) { | 776 | if (ep->desc->bmAttributes == USB_ENDPOINT_XFER_ISOC) { |
@@ -1069,7 +1062,7 @@ static int fsl_vbus_session(struct usb_gadget *gadget, int is_active) | |||
1069 | 1062 | ||
1070 | udc = container_of(gadget, struct fsl_udc, gadget); | 1063 | udc = container_of(gadget, struct fsl_udc, gadget); |
1071 | spin_lock_irqsave(&udc->lock, flags); | 1064 | spin_lock_irqsave(&udc->lock, flags); |
1072 | VDBG("VBUS %s\n", is_active ? "on" : "off"); | 1065 | VDBG("VBUS %s", is_active ? "on" : "off"); |
1073 | udc->vbus_active = (is_active != 0); | 1066 | udc->vbus_active = (is_active != 0); |
1074 | if (can_pullup(udc)) | 1067 | if (can_pullup(udc)) |
1075 | fsl_writel((fsl_readl(&dr_regs->usbcmd) | USB_CMD_RUN_STOP), | 1068 | fsl_writel((fsl_readl(&dr_regs->usbcmd) | USB_CMD_RUN_STOP), |
@@ -1146,7 +1139,6 @@ static int ep0_prime_status(struct fsl_udc *udc, int direction) | |||
1146 | { | 1139 | { |
1147 | struct fsl_req *req = udc->status_req; | 1140 | struct fsl_req *req = udc->status_req; |
1148 | struct fsl_ep *ep; | 1141 | struct fsl_ep *ep; |
1149 | int status = 0; | ||
1150 | 1142 | ||
1151 | if (direction == EP_DIR_IN) | 1143 | if (direction == EP_DIR_IN) |
1152 | udc->ep0_dir = USB_DIR_IN; | 1144 | udc->ep0_dir = USB_DIR_IN; |
@@ -1164,27 +1156,21 @@ static int ep0_prime_status(struct fsl_udc *udc, int direction) | |||
1164 | req->dtd_count = 0; | 1156 | req->dtd_count = 0; |
1165 | 1157 | ||
1166 | if (fsl_req_to_dtd(req) == 0) | 1158 | if (fsl_req_to_dtd(req) == 0) |
1167 | status = fsl_queue_td(ep, req); | 1159 | fsl_queue_td(ep, req); |
1168 | else | 1160 | else |
1169 | return -ENOMEM; | 1161 | return -ENOMEM; |
1170 | 1162 | ||
1171 | if (status) | ||
1172 | ERR("Can't queue ep0 status request \n"); | ||
1173 | list_add_tail(&req->queue, &ep->queue); | 1163 | list_add_tail(&req->queue, &ep->queue); |
1174 | 1164 | ||
1175 | return status; | 1165 | return 0; |
1176 | } | 1166 | } |
1177 | 1167 | ||
1178 | static inline int udc_reset_ep_queue(struct fsl_udc *udc, u8 pipe) | 1168 | static void udc_reset_ep_queue(struct fsl_udc *udc, u8 pipe) |
1179 | { | 1169 | { |
1180 | struct fsl_ep *ep = get_ep_by_pipe(udc, pipe); | 1170 | struct fsl_ep *ep = get_ep_by_pipe(udc, pipe); |
1181 | 1171 | ||
1182 | if (!ep->name) | 1172 | if (ep->name) |
1183 | return 0; | 1173 | nuke(ep, -ESHUTDOWN); |
1184 | |||
1185 | nuke(ep, -ESHUTDOWN); | ||
1186 | |||
1187 | return 0; | ||
1188 | } | 1174 | } |
1189 | 1175 | ||
1190 | /* | 1176 | /* |
@@ -1208,10 +1194,8 @@ static void ch9getstatus(struct fsl_udc *udc, u8 request_type, u16 value, | |||
1208 | u16 index, u16 length) | 1194 | u16 index, u16 length) |
1209 | { | 1195 | { |
1210 | u16 tmp = 0; /* Status, cpu endian */ | 1196 | u16 tmp = 0; /* Status, cpu endian */ |
1211 | |||
1212 | struct fsl_req *req; | 1197 | struct fsl_req *req; |
1213 | struct fsl_ep *ep; | 1198 | struct fsl_ep *ep; |
1214 | int status = 0; | ||
1215 | 1199 | ||
1216 | ep = &udc->eps[0]; | 1200 | ep = &udc->eps[0]; |
1217 | 1201 | ||
@@ -1250,14 +1234,10 @@ static void ch9getstatus(struct fsl_udc *udc, u8 request_type, u16 value, | |||
1250 | 1234 | ||
1251 | /* prime the data phase */ | 1235 | /* prime the data phase */ |
1252 | if ((fsl_req_to_dtd(req) == 0)) | 1236 | if ((fsl_req_to_dtd(req) == 0)) |
1253 | status = fsl_queue_td(ep, req); | 1237 | fsl_queue_td(ep, req); |
1254 | else /* no mem */ | 1238 | else /* no mem */ |
1255 | goto stall; | 1239 | goto stall; |
1256 | 1240 | ||
1257 | if (status) { | ||
1258 | ERR("Can't respond to getstatus request \n"); | ||
1259 | goto stall; | ||
1260 | } | ||
1261 | list_add_tail(&req->queue, &ep->queue); | 1241 | list_add_tail(&req->queue, &ep->queue); |
1262 | udc->ep0_state = DATA_STATE_XMIT; | 1242 | udc->ep0_state = DATA_STATE_XMIT; |
1263 | return; | 1243 | return; |
@@ -1397,7 +1377,7 @@ static void ep0_req_complete(struct fsl_udc *udc, struct fsl_ep *ep0, | |||
1397 | udc->ep0_state = WAIT_FOR_SETUP; | 1377 | udc->ep0_state = WAIT_FOR_SETUP; |
1398 | break; | 1378 | break; |
1399 | case WAIT_FOR_SETUP: | 1379 | case WAIT_FOR_SETUP: |
1400 | ERR("Unexpect ep0 packets \n"); | 1380 | ERR("Unexpect ep0 packets\n"); |
1401 | break; | 1381 | break; |
1402 | default: | 1382 | default: |
1403 | ep0stall(udc); | 1383 | ep0stall(udc); |
@@ -1476,7 +1456,7 @@ static int process_ep_req(struct fsl_udc *udc, int pipe, | |||
1476 | status = -EILSEQ; | 1456 | status = -EILSEQ; |
1477 | break; | 1457 | break; |
1478 | } else | 1458 | } else |
1479 | ERR("Unknown error has occured (0x%x)!\r\n", | 1459 | ERR("Unknown error has occured (0x%x)!\n", |
1480 | errors); | 1460 | errors); |
1481 | 1461 | ||
1482 | } else if (le32_to_cpu(curr_td->size_ioc_sts) | 1462 | } else if (le32_to_cpu(curr_td->size_ioc_sts) |
@@ -1495,7 +1475,7 @@ static int process_ep_req(struct fsl_udc *udc, int pipe, | |||
1495 | } | 1475 | } |
1496 | } else { | 1476 | } else { |
1497 | td_complete++; | 1477 | td_complete++; |
1498 | VDBG("dTD transmitted successful "); | 1478 | VDBG("dTD transmitted successful"); |
1499 | } | 1479 | } |
1500 | 1480 | ||
1501 | if (j != curr_req->dtd_count - 1) | 1481 | if (j != curr_req->dtd_count - 1) |
@@ -1568,9 +1548,6 @@ static void port_change_irq(struct fsl_udc *udc) | |||
1568 | { | 1548 | { |
1569 | u32 speed; | 1549 | u32 speed; |
1570 | 1550 | ||
1571 | if (udc->bus_reset) | ||
1572 | udc->bus_reset = 0; | ||
1573 | |||
1574 | /* Bus resetting is finished */ | 1551 | /* Bus resetting is finished */ |
1575 | if (!(fsl_readl(&dr_regs->portsc1) & PORTSCX_PORT_RESET)) { | 1552 | if (!(fsl_readl(&dr_regs->portsc1) & PORTSCX_PORT_RESET)) { |
1576 | /* Get the speed */ | 1553 | /* Get the speed */ |
@@ -1678,8 +1655,6 @@ static void reset_irq(struct fsl_udc *udc) | |||
1678 | 1655 | ||
1679 | if (fsl_readl(&dr_regs->portsc1) & PORTSCX_PORT_RESET) { | 1656 | if (fsl_readl(&dr_regs->portsc1) & PORTSCX_PORT_RESET) { |
1680 | VDBG("Bus reset"); | 1657 | VDBG("Bus reset"); |
1681 | /* Bus is reseting */ | ||
1682 | udc->bus_reset = 1; | ||
1683 | /* Reset all the queues, include XD, dTD, EP queue | 1658 | /* Reset all the queues, include XD, dTD, EP queue |
1684 | * head and TR Queue */ | 1659 | * head and TR Queue */ |
1685 | reset_queues(udc); | 1660 | reset_queues(udc); |
@@ -1768,7 +1743,7 @@ static irqreturn_t fsl_udc_irq(int irq, void *_udc) | |||
1768 | } | 1743 | } |
1769 | 1744 | ||
1770 | if (irq_src & (USB_STS_ERR | USB_STS_SYS_ERR)) { | 1745 | if (irq_src & (USB_STS_ERR | USB_STS_SYS_ERR)) { |
1771 | VDBG("Error IRQ %x ", irq_src); | 1746 | VDBG("Error IRQ %x", irq_src); |
1772 | } | 1747 | } |
1773 | 1748 | ||
1774 | spin_unlock_irqrestore(&udc->lock, flags); | 1749 | spin_unlock_irqrestore(&udc->lock, flags); |
@@ -1799,7 +1774,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver) | |||
1799 | /* lock is needed but whether should use this lock or another */ | 1774 | /* lock is needed but whether should use this lock or another */ |
1800 | spin_lock_irqsave(&udc_controller->lock, flags); | 1775 | spin_lock_irqsave(&udc_controller->lock, flags); |
1801 | 1776 | ||
1802 | driver->driver.bus = 0; | 1777 | driver->driver.bus = NULL; |
1803 | /* hook up the driver */ | 1778 | /* hook up the driver */ |
1804 | udc_controller->driver = driver; | 1779 | udc_controller->driver = driver; |
1805 | udc_controller->gadget.dev.driver = &driver->driver; | 1780 | udc_controller->gadget.dev.driver = &driver->driver; |
@@ -1809,8 +1784,8 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver) | |||
1809 | retval = driver->bind(&udc_controller->gadget); | 1784 | retval = driver->bind(&udc_controller->gadget); |
1810 | if (retval) { | 1785 | if (retval) { |
1811 | VDBG("bind to %s --> %d", driver->driver.name, retval); | 1786 | VDBG("bind to %s --> %d", driver->driver.name, retval); |
1812 | udc_controller->gadget.dev.driver = 0; | 1787 | udc_controller->gadget.dev.driver = NULL; |
1813 | udc_controller->driver = 0; | 1788 | udc_controller->driver = NULL; |
1814 | goto out; | 1789 | goto out; |
1815 | } | 1790 | } |
1816 | 1791 | ||
@@ -1819,12 +1794,12 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver) | |||
1819 | udc_controller->usb_state = USB_STATE_ATTACHED; | 1794 | udc_controller->usb_state = USB_STATE_ATTACHED; |
1820 | udc_controller->ep0_state = WAIT_FOR_SETUP; | 1795 | udc_controller->ep0_state = WAIT_FOR_SETUP; |
1821 | udc_controller->ep0_dir = 0; | 1796 | udc_controller->ep0_dir = 0; |
1822 | printk(KERN_INFO "%s: bind to driver %s \n", | 1797 | printk(KERN_INFO "%s: bind to driver %s\n", |
1823 | udc_controller->gadget.name, driver->driver.name); | 1798 | udc_controller->gadget.name, driver->driver.name); |
1824 | 1799 | ||
1825 | out: | 1800 | out: |
1826 | if (retval) | 1801 | if (retval) |
1827 | printk("retval %d \n", retval); | 1802 | printk("gadget driver register failed %d\n", retval); |
1828 | return retval; | 1803 | return retval; |
1829 | } | 1804 | } |
1830 | EXPORT_SYMBOL(usb_gadget_register_driver); | 1805 | EXPORT_SYMBOL(usb_gadget_register_driver); |
@@ -1842,7 +1817,7 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) | |||
1842 | return -EINVAL; | 1817 | return -EINVAL; |
1843 | 1818 | ||
1844 | if (udc_controller->transceiver) | 1819 | if (udc_controller->transceiver) |
1845 | (void)otg_set_peripheral(udc_controller->transceiver, 0); | 1820 | otg_set_peripheral(udc_controller->transceiver, NULL); |
1846 | 1821 | ||
1847 | /* stop DR, disable intr */ | 1822 | /* stop DR, disable intr */ |
1848 | dr_controller_stop(udc_controller); | 1823 | dr_controller_stop(udc_controller); |
@@ -1863,10 +1838,10 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) | |||
1863 | 1838 | ||
1864 | /* unbind gadget and unhook driver. */ | 1839 | /* unbind gadget and unhook driver. */ |
1865 | driver->unbind(&udc_controller->gadget); | 1840 | driver->unbind(&udc_controller->gadget); |
1866 | udc_controller->gadget.dev.driver = 0; | 1841 | udc_controller->gadget.dev.driver = NULL; |
1867 | udc_controller->driver = 0; | 1842 | udc_controller->driver = NULL; |
1868 | 1843 | ||
1869 | printk("unregistered gadget driver '%s'\r\n", driver->driver.name); | 1844 | printk("unregistered gadget driver '%s'\n", driver->driver.name); |
1870 | return 0; | 1845 | return 0; |
1871 | } | 1846 | } |
1872 | EXPORT_SYMBOL(usb_gadget_unregister_driver); | 1847 | EXPORT_SYMBOL(usb_gadget_unregister_driver); |
@@ -1922,7 +1897,7 @@ static int fsl_proc_read(char *page, char **start, off_t off, int count, | |||
1922 | tmp_reg = fsl_readl(&dr_regs->usbsts); | 1897 | tmp_reg = fsl_readl(&dr_regs->usbsts); |
1923 | t = scnprintf(next, size, | 1898 | t = scnprintf(next, size, |
1924 | "USB Status Reg:\n" | 1899 | "USB Status Reg:\n" |
1925 | "Dr Suspend: %d" "Reset Received: %d" "System Error: %s" | 1900 | "Dr Suspend: %d Reset Received: %d System Error: %s " |
1926 | "USB Error Interrupt: %s\n\n", | 1901 | "USB Error Interrupt: %s\n\n", |
1927 | (tmp_reg & USB_STS_SUSPEND) ? 1 : 0, | 1902 | (tmp_reg & USB_STS_SUSPEND) ? 1 : 0, |
1928 | (tmp_reg & USB_STS_RESET) ? 1 : 0, | 1903 | (tmp_reg & USB_STS_RESET) ? 1 : 0, |
@@ -1934,11 +1909,11 @@ static int fsl_proc_read(char *page, char **start, off_t off, int count, | |||
1934 | tmp_reg = fsl_readl(&dr_regs->usbintr); | 1909 | tmp_reg = fsl_readl(&dr_regs->usbintr); |
1935 | t = scnprintf(next, size, | 1910 | t = scnprintf(next, size, |
1936 | "USB Intrrupt Enable Reg:\n" | 1911 | "USB Intrrupt Enable Reg:\n" |
1937 | "Sleep Enable: %d" "SOF Received Enable: %d" | 1912 | "Sleep Enable: %d SOF Received Enable: %d " |
1938 | "Reset Enable: %d\n" | 1913 | "Reset Enable: %d\n" |
1939 | "System Error Enable: %d" | 1914 | "System Error Enable: %d " |
1940 | "Port Change Dectected Enable: %d\n" | 1915 | "Port Change Dectected Enable: %d\n" |
1941 | "USB Error Intr Enable: %d" "USB Intr Enable: %d\n\n", | 1916 | "USB Error Intr Enable: %d USB Intr Enable: %d\n\n", |
1942 | (tmp_reg & USB_INTR_DEVICE_SUSPEND) ? 1 : 0, | 1917 | (tmp_reg & USB_INTR_DEVICE_SUSPEND) ? 1 : 0, |
1943 | (tmp_reg & USB_INTR_SOF_EN) ? 1 : 0, | 1918 | (tmp_reg & USB_INTR_SOF_EN) ? 1 : 0, |
1944 | (tmp_reg & USB_INTR_RESET_EN) ? 1 : 0, | 1919 | (tmp_reg & USB_INTR_RESET_EN) ? 1 : 0, |
@@ -1951,21 +1926,21 @@ static int fsl_proc_read(char *page, char **start, off_t off, int count, | |||
1951 | 1926 | ||
1952 | tmp_reg = fsl_readl(&dr_regs->frindex); | 1927 | tmp_reg = fsl_readl(&dr_regs->frindex); |
1953 | t = scnprintf(next, size, | 1928 | t = scnprintf(next, size, |
1954 | "USB Frame Index Reg:" "Frame Number is 0x%x\n\n", | 1929 | "USB Frame Index Reg: Frame Number is 0x%x\n\n", |
1955 | (tmp_reg & USB_FRINDEX_MASKS)); | 1930 | (tmp_reg & USB_FRINDEX_MASKS)); |
1956 | size -= t; | 1931 | size -= t; |
1957 | next += t; | 1932 | next += t; |
1958 | 1933 | ||
1959 | tmp_reg = fsl_readl(&dr_regs->deviceaddr); | 1934 | tmp_reg = fsl_readl(&dr_regs->deviceaddr); |
1960 | t = scnprintf(next, size, | 1935 | t = scnprintf(next, size, |
1961 | "USB Device Address Reg:" "Device Addr is 0x%x\n\n", | 1936 | "USB Device Address Reg: Device Addr is 0x%x\n\n", |
1962 | (tmp_reg & USB_DEVICE_ADDRESS_MASK)); | 1937 | (tmp_reg & USB_DEVICE_ADDRESS_MASK)); |
1963 | size -= t; | 1938 | size -= t; |
1964 | next += t; | 1939 | next += t; |
1965 | 1940 | ||
1966 | tmp_reg = fsl_readl(&dr_regs->endpointlistaddr); | 1941 | tmp_reg = fsl_readl(&dr_regs->endpointlistaddr); |
1967 | t = scnprintf(next, size, | 1942 | t = scnprintf(next, size, |
1968 | "USB Endpoint List Address Reg:" | 1943 | "USB Endpoint List Address Reg: " |
1969 | "Device Addr is 0x%x\n\n", | 1944 | "Device Addr is 0x%x\n\n", |
1970 | (tmp_reg & USB_EP_LIST_ADDRESS_MASK)); | 1945 | (tmp_reg & USB_EP_LIST_ADDRESS_MASK)); |
1971 | size -= t; | 1946 | size -= t; |
@@ -1974,11 +1949,12 @@ static int fsl_proc_read(char *page, char **start, off_t off, int count, | |||
1974 | tmp_reg = fsl_readl(&dr_regs->portsc1); | 1949 | tmp_reg = fsl_readl(&dr_regs->portsc1); |
1975 | t = scnprintf(next, size, | 1950 | t = scnprintf(next, size, |
1976 | "USB Port Status&Control Reg:\n" | 1951 | "USB Port Status&Control Reg:\n" |
1977 | "Port Transceiver Type : %s" "Port Speed: %s \n" | 1952 | "Port Transceiver Type : %s Port Speed: %s\n" |
1978 | "PHY Low Power Suspend: %s" "Port Reset: %s" | 1953 | "PHY Low Power Suspend: %s Port Reset: %s " |
1979 | "Port Suspend Mode: %s \n" "Over-current Change: %s" | 1954 | "Port Suspend Mode: %s\n" |
1955 | "Over-current Change: %s " | ||
1980 | "Port Enable/Disable Change: %s\n" | 1956 | "Port Enable/Disable Change: %s\n" |
1981 | "Port Enabled/Disabled: %s" | 1957 | "Port Enabled/Disabled: %s " |
1982 | "Current Connect Status: %s\n\n", ( { | 1958 | "Current Connect Status: %s\n\n", ( { |
1983 | char *s; | 1959 | char *s; |
1984 | switch (tmp_reg & PORTSCX_PTS_FSLS) { | 1960 | switch (tmp_reg & PORTSCX_PTS_FSLS) { |
@@ -2023,7 +1999,7 @@ static int fsl_proc_read(char *page, char **start, off_t off, int count, | |||
2023 | 1999 | ||
2024 | tmp_reg = fsl_readl(&dr_regs->usbmode); | 2000 | tmp_reg = fsl_readl(&dr_regs->usbmode); |
2025 | t = scnprintf(next, size, | 2001 | t = scnprintf(next, size, |
2026 | "USB Mode Reg:" "Controller Mode is : %s\n\n", ( { | 2002 | "USB Mode Reg: Controller Mode is: %s\n\n", ( { |
2027 | char *s; | 2003 | char *s; |
2028 | switch (tmp_reg & USB_MODE_CTRL_MODE_HOST) { | 2004 | switch (tmp_reg & USB_MODE_CTRL_MODE_HOST) { |
2029 | case USB_MODE_CTRL_MODE_IDLE: | 2005 | case USB_MODE_CTRL_MODE_IDLE: |
@@ -2042,7 +2018,7 @@ static int fsl_proc_read(char *page, char **start, off_t off, int count, | |||
2042 | 2018 | ||
2043 | tmp_reg = fsl_readl(&dr_regs->endptsetupstat); | 2019 | tmp_reg = fsl_readl(&dr_regs->endptsetupstat); |
2044 | t = scnprintf(next, size, | 2020 | t = scnprintf(next, size, |
2045 | "Endpoint Setup Status Reg:" "SETUP on ep 0x%x\n\n", | 2021 | "Endpoint Setup Status Reg: SETUP on ep 0x%x\n\n", |
2046 | (tmp_reg & EP_SETUP_STATUS_MASK)); | 2022 | (tmp_reg & EP_SETUP_STATUS_MASK)); |
2047 | size -= t; | 2023 | size -= t; |
2048 | next += t; | 2024 | next += t; |
@@ -2055,12 +2031,12 @@ static int fsl_proc_read(char *page, char **start, off_t off, int count, | |||
2055 | next += t; | 2031 | next += t; |
2056 | } | 2032 | } |
2057 | tmp_reg = fsl_readl(&dr_regs->endpointprime); | 2033 | tmp_reg = fsl_readl(&dr_regs->endpointprime); |
2058 | t = scnprintf(next, size, "EP Prime Reg = [0x%x]\n", tmp_reg); | 2034 | t = scnprintf(next, size, "EP Prime Reg = [0x%x]\n\n", tmp_reg); |
2059 | size -= t; | 2035 | size -= t; |
2060 | next += t; | 2036 | next += t; |
2061 | 2037 | ||
2062 | tmp_reg = usb_sys_regs->snoop1; | 2038 | tmp_reg = usb_sys_regs->snoop1; |
2063 | t = scnprintf(next, size, "\nSnoop1 Reg : = [0x%x]\n\n", tmp_reg); | 2039 | t = scnprintf(next, size, "Snoop1 Reg : = [0x%x]\n\n", tmp_reg); |
2064 | size -= t; | 2040 | size -= t; |
2065 | next += t; | 2041 | next += t; |
2066 | 2042 | ||
@@ -2084,7 +2060,7 @@ static int fsl_proc_read(char *page, char **start, off_t off, int count, | |||
2084 | } else { | 2060 | } else { |
2085 | list_for_each_entry(req, &ep->queue, queue) { | 2061 | list_for_each_entry(req, &ep->queue, queue) { |
2086 | t = scnprintf(next, size, | 2062 | t = scnprintf(next, size, |
2087 | "req %p actual 0x%x length 0x%x buf %p\n", | 2063 | "req %p actual 0x%x length 0x%x buf %p\n", |
2088 | &req->req, req->req.actual, | 2064 | &req->req, req->req.actual, |
2089 | req->req.length, req->req.buf); | 2065 | req->req.length, req->req.buf); |
2090 | size -= t; | 2066 | size -= t; |
@@ -2110,7 +2086,7 @@ static int fsl_proc_read(char *page, char **start, off_t off, int count, | |||
2110 | } else { | 2086 | } else { |
2111 | list_for_each_entry(req, &ep->queue, queue) { | 2087 | list_for_each_entry(req, &ep->queue, queue) { |
2112 | t = scnprintf(next, size, | 2088 | t = scnprintf(next, size, |
2113 | "req %p actual 0x%x length" | 2089 | "req %p actual 0x%x length " |
2114 | "0x%x buf %p\n", | 2090 | "0x%x buf %p\n", |
2115 | &req->req, req->req.actual, | 2091 | &req->req, req->req.actual, |
2116 | req->req.length, req->req.buf); | 2092 | req->req.length, req->req.buf); |
@@ -2202,7 +2178,6 @@ static int __init struct_udc_setup(struct fsl_udc *udc, | |||
2202 | udc->usb_state = USB_STATE_POWERED; | 2178 | udc->usb_state = USB_STATE_POWERED; |
2203 | udc->ep0_dir = 0; | 2179 | udc->ep0_dir = 0; |
2204 | udc->remote_wakeup = 0; /* default to 0 on reset */ | 2180 | udc->remote_wakeup = 0; /* default to 0 on reset */ |
2205 | spin_lock_init(&udc->lock); | ||
2206 | 2181 | ||
2207 | return 0; | 2182 | return 0; |
2208 | } | 2183 | } |
@@ -2254,7 +2229,7 @@ static int __init fsl_udc_probe(struct platform_device *pdev) | |||
2254 | u32 dccparams; | 2229 | u32 dccparams; |
2255 | 2230 | ||
2256 | if (strcmp(pdev->name, driver_name)) { | 2231 | if (strcmp(pdev->name, driver_name)) { |
2257 | VDBG("Wrong device\n"); | 2232 | VDBG("Wrong device"); |
2258 | return -ENODEV; | 2233 | return -ENODEV; |
2259 | } | 2234 | } |
2260 | 2235 | ||
@@ -2264,23 +2239,26 @@ static int __init fsl_udc_probe(struct platform_device *pdev) | |||
2264 | return -ENOMEM; | 2239 | return -ENOMEM; |
2265 | } | 2240 | } |
2266 | 2241 | ||
2242 | spin_lock_init(&udc_controller->lock); | ||
2243 | udc_controller->stopped = 1; | ||
2244 | |||
2267 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 2245 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
2268 | if (!res) { | 2246 | if (!res) { |
2269 | kfree(udc_controller); | 2247 | ret = -ENXIO; |
2270 | return -ENXIO; | 2248 | goto err_kfree; |
2271 | } | 2249 | } |
2272 | 2250 | ||
2273 | if (!request_mem_region(res->start, res->end - res->start + 1, | 2251 | if (!request_mem_region(res->start, res->end - res->start + 1, |
2274 | driver_name)) { | 2252 | driver_name)) { |
2275 | ERR("request mem region for %s failed \n", pdev->name); | 2253 | ERR("request mem region for %s failed\n", pdev->name); |
2276 | kfree(udc_controller); | 2254 | ret = -EBUSY; |
2277 | return -EBUSY; | 2255 | goto err_kfree; |
2278 | } | 2256 | } |
2279 | 2257 | ||
2280 | dr_regs = ioremap(res->start, res->end - res->start + 1); | 2258 | dr_regs = ioremap(res->start, res->end - res->start + 1); |
2281 | if (!dr_regs) { | 2259 | if (!dr_regs) { |
2282 | ret = -ENOMEM; | 2260 | ret = -ENOMEM; |
2283 | goto err1; | 2261 | goto err_release_mem_region; |
2284 | } | 2262 | } |
2285 | 2263 | ||
2286 | usb_sys_regs = (struct usb_sys_interface *) | 2264 | usb_sys_regs = (struct usb_sys_interface *) |
@@ -2291,7 +2269,7 @@ static int __init fsl_udc_probe(struct platform_device *pdev) | |||
2291 | if (!(dccparams & DCCPARAMS_DC)) { | 2269 | if (!(dccparams & DCCPARAMS_DC)) { |
2292 | ERR("This SOC doesn't support device role\n"); | 2270 | ERR("This SOC doesn't support device role\n"); |
2293 | ret = -ENODEV; | 2271 | ret = -ENODEV; |
2294 | goto err2; | 2272 | goto err_iounmap; |
2295 | } | 2273 | } |
2296 | /* Get max device endpoints */ | 2274 | /* Get max device endpoints */ |
2297 | /* DEN is bidirectional ep number, max_ep doubles the number */ | 2275 | /* DEN is bidirectional ep number, max_ep doubles the number */ |
@@ -2300,22 +2278,22 @@ static int __init fsl_udc_probe(struct platform_device *pdev) | |||
2300 | udc_controller->irq = platform_get_irq(pdev, 0); | 2278 | udc_controller->irq = platform_get_irq(pdev, 0); |
2301 | if (!udc_controller->irq) { | 2279 | if (!udc_controller->irq) { |
2302 | ret = -ENODEV; | 2280 | ret = -ENODEV; |
2303 | goto err2; | 2281 | goto err_iounmap; |
2304 | } | 2282 | } |
2305 | 2283 | ||
2306 | ret = request_irq(udc_controller->irq, fsl_udc_irq, IRQF_SHARED, | 2284 | ret = request_irq(udc_controller->irq, fsl_udc_irq, IRQF_SHARED, |
2307 | driver_name, udc_controller); | 2285 | driver_name, udc_controller); |
2308 | if (ret != 0) { | 2286 | if (ret != 0) { |
2309 | ERR("cannot request irq %d err %d \n", | 2287 | ERR("cannot request irq %d err %d\n", |
2310 | udc_controller->irq, ret); | 2288 | udc_controller->irq, ret); |
2311 | goto err2; | 2289 | goto err_iounmap; |
2312 | } | 2290 | } |
2313 | 2291 | ||
2314 | /* Initialize the udc structure including QH member and other member */ | 2292 | /* Initialize the udc structure including QH member and other member */ |
2315 | if (struct_udc_setup(udc_controller, pdev)) { | 2293 | if (struct_udc_setup(udc_controller, pdev)) { |
2316 | ERR("Can't initialize udc data structure\n"); | 2294 | ERR("Can't initialize udc data structure\n"); |
2317 | ret = -ENOMEM; | 2295 | ret = -ENOMEM; |
2318 | goto err3; | 2296 | goto err_free_irq; |
2319 | } | 2297 | } |
2320 | 2298 | ||
2321 | /* initialize usb hw reg except for regs for EP, | 2299 | /* initialize usb hw reg except for regs for EP, |
@@ -2336,7 +2314,7 @@ static int __init fsl_udc_probe(struct platform_device *pdev) | |||
2336 | udc_controller->gadget.dev.parent = &pdev->dev; | 2314 | udc_controller->gadget.dev.parent = &pdev->dev; |
2337 | ret = device_register(&udc_controller->gadget.dev); | 2315 | ret = device_register(&udc_controller->gadget.dev); |
2338 | if (ret < 0) | 2316 | if (ret < 0) |
2339 | goto err3; | 2317 | goto err_free_irq; |
2340 | 2318 | ||
2341 | /* setup QH and epctrl for ep0 */ | 2319 | /* setup QH and epctrl for ep0 */ |
2342 | ep0_setup(udc_controller); | 2320 | ep0_setup(udc_controller); |
@@ -2366,20 +2344,22 @@ static int __init fsl_udc_probe(struct platform_device *pdev) | |||
2366 | DTD_ALIGNMENT, UDC_DMA_BOUNDARY); | 2344 | DTD_ALIGNMENT, UDC_DMA_BOUNDARY); |
2367 | if (udc_controller->td_pool == NULL) { | 2345 | if (udc_controller->td_pool == NULL) { |
2368 | ret = -ENOMEM; | 2346 | ret = -ENOMEM; |
2369 | goto err4; | 2347 | goto err_unregister; |
2370 | } | 2348 | } |
2371 | create_proc_file(); | 2349 | create_proc_file(); |
2372 | return 0; | 2350 | return 0; |
2373 | 2351 | ||
2374 | err4: | 2352 | err_unregister: |
2375 | device_unregister(&udc_controller->gadget.dev); | 2353 | device_unregister(&udc_controller->gadget.dev); |
2376 | err3: | 2354 | err_free_irq: |
2377 | free_irq(udc_controller->irq, udc_controller); | 2355 | free_irq(udc_controller->irq, udc_controller); |
2378 | err2: | 2356 | err_iounmap: |
2379 | iounmap(dr_regs); | 2357 | iounmap(dr_regs); |
2380 | err1: | 2358 | err_release_mem_region: |
2381 | release_mem_region(res->start, res->end - res->start + 1); | 2359 | release_mem_region(res->start, res->end - res->start + 1); |
2360 | err_kfree: | ||
2382 | kfree(udc_controller); | 2361 | kfree(udc_controller); |
2362 | udc_controller = NULL; | ||
2383 | return ret; | 2363 | return ret; |
2384 | } | 2364 | } |
2385 | 2365 | ||
@@ -2469,7 +2449,7 @@ module_init(udc_init); | |||
2469 | static void __exit udc_exit(void) | 2449 | static void __exit udc_exit(void) |
2470 | { | 2450 | { |
2471 | platform_driver_unregister(&udc_driver); | 2451 | platform_driver_unregister(&udc_driver); |
2472 | printk("%s unregistered \n", driver_desc); | 2452 | printk("%s unregistered\n", driver_desc); |
2473 | } | 2453 | } |
2474 | 2454 | ||
2475 | module_exit(udc_exit); | 2455 | module_exit(udc_exit); |
diff --git a/drivers/usb/gadget/fsl_usb2_udc.h b/drivers/usb/gadget/fsl_usb2_udc.h index 6131752a38bc..e63ef12645f5 100644 --- a/drivers/usb/gadget/fsl_usb2_udc.h +++ b/drivers/usb/gadget/fsl_usb2_udc.h | |||
@@ -424,16 +424,6 @@ struct ep_td_struct { | |||
424 | /* Controller dma boundary */ | 424 | /* Controller dma boundary */ |
425 | #define UDC_DMA_BOUNDARY 0x1000 | 425 | #define UDC_DMA_BOUNDARY 0x1000 |
426 | 426 | ||
427 | /* -----------------------------------------------------------------------*/ | ||
428 | /* ##### enum data | ||
429 | */ | ||
430 | typedef enum { | ||
431 | e_ULPI, | ||
432 | e_UTMI_8BIT, | ||
433 | e_UTMI_16BIT, | ||
434 | e_SERIAL | ||
435 | } e_PhyInterface; | ||
436 | |||
437 | /*-------------------------------------------------------------------------*/ | 427 | /*-------------------------------------------------------------------------*/ |
438 | 428 | ||
439 | /* ### driver private data | 429 | /* ### driver private data |
@@ -469,9 +459,9 @@ struct fsl_ep { | |||
469 | #define EP_DIR_OUT 0 | 459 | #define EP_DIR_OUT 0 |
470 | 460 | ||
471 | struct fsl_udc { | 461 | struct fsl_udc { |
472 | |||
473 | struct usb_gadget gadget; | 462 | struct usb_gadget gadget; |
474 | struct usb_gadget_driver *driver; | 463 | struct usb_gadget_driver *driver; |
464 | struct completion *done; /* to make sure release() is done */ | ||
475 | struct fsl_ep *eps; | 465 | struct fsl_ep *eps; |
476 | unsigned int max_ep; | 466 | unsigned int max_ep; |
477 | unsigned int irq; | 467 | unsigned int irq; |
@@ -492,20 +482,13 @@ struct fsl_udc { | |||
492 | size_t ep_qh_size; /* size after alignment adjustment*/ | 482 | size_t ep_qh_size; /* size after alignment adjustment*/ |
493 | dma_addr_t ep_qh_dma; /* dma address of QH */ | 483 | dma_addr_t ep_qh_dma; /* dma address of QH */ |
494 | 484 | ||
495 | u32 max_pipes; /* Device max pipes */ | 485 | u32 max_pipes; /* Device max pipes */ |
496 | u32 max_use_endpts; /* Max endpointes to be used */ | ||
497 | u32 bus_reset; /* Device is bus reseting */ | ||
498 | u32 resume_state; /* USB state to resume */ | 486 | u32 resume_state; /* USB state to resume */ |
499 | u32 usb_state; /* USB current state */ | 487 | u32 usb_state; /* USB current state */ |
500 | u32 usb_next_state; /* USB next state */ | ||
501 | u32 ep0_state; /* Endpoint zero state */ | 488 | u32 ep0_state; /* Endpoint zero state */ |
502 | u32 ep0_dir; /* Endpoint zero direction: can be | 489 | u32 ep0_dir; /* Endpoint zero direction: can be |
503 | USB_DIR_IN or USB_DIR_OUT */ | 490 | USB_DIR_IN or USB_DIR_OUT */ |
504 | u32 usb_sof_count; /* SOF count */ | ||
505 | u32 errors; /* USB ERRORs count */ | ||
506 | u8 device_address; /* Device USB address */ | 491 | u8 device_address; /* Device USB address */ |
507 | |||
508 | struct completion *done; /* to make sure release() is done */ | ||
509 | }; | 492 | }; |
510 | 493 | ||
511 | /*-------------------------------------------------------------------------*/ | 494 | /*-------------------------------------------------------------------------*/ |
diff --git a/drivers/usb/gadget/gadget_chips.h b/drivers/usb/gadget/gadget_chips.h index 17d9905101b7..4e3107dd2f34 100644 --- a/drivers/usb/gadget/gadget_chips.h +++ b/drivers/usb/gadget/gadget_chips.h | |||
@@ -151,6 +151,13 @@ | |||
151 | #define gadget_is_m66592(g) 0 | 151 | #define gadget_is_m66592(g) 0 |
152 | #endif | 152 | #endif |
153 | 153 | ||
154 | /* Freescale CPM/QE UDC SUPPORT */ | ||
155 | #ifdef CONFIG_USB_GADGET_FSL_QE | ||
156 | #define gadget_is_fsl_qe(g) !strcmp("fsl_qe_udc", (g)->name) | ||
157 | #else | ||
158 | #define gadget_is_fsl_qe(g) 0 | ||
159 | #endif | ||
160 | |||
154 | 161 | ||
155 | // CONFIG_USB_GADGET_SX2 | 162 | // CONFIG_USB_GADGET_SX2 |
156 | // CONFIG_USB_GADGET_AU1X00 | 163 | // CONFIG_USB_GADGET_AU1X00 |
@@ -216,6 +223,8 @@ static inline int usb_gadget_controller_number(struct usb_gadget *gadget) | |||
216 | return 0x20; | 223 | return 0x20; |
217 | else if (gadget_is_m66592(gadget)) | 224 | else if (gadget_is_m66592(gadget)) |
218 | return 0x21; | 225 | return 0x21; |
226 | else if (gadget_is_fsl_qe(gadget)) | ||
227 | return 0x22; | ||
219 | return -ENOENT; | 228 | return -ENOENT; |
220 | } | 229 | } |
221 | 230 | ||
diff --git a/drivers/usb/gadget/gmidi.c b/drivers/usb/gadget/gmidi.c index ea8651e3da1a..60d3f9e9b51f 100644 --- a/drivers/usb/gadget/gmidi.c +++ b/drivers/usb/gadget/gmidi.c | |||
@@ -35,6 +35,21 @@ | |||
35 | 35 | ||
36 | #include "gadget_chips.h" | 36 | #include "gadget_chips.h" |
37 | 37 | ||
38 | |||
39 | /* | ||
40 | * Kbuild is not very cooperative with respect to linking separately | ||
41 | * compiled library objects into one module. So for now we won't use | ||
42 | * separate compilation ... ensuring init/exit sections work to shrink | ||
43 | * the runtime footprint, and giving us at least some parts of what | ||
44 | * a "gcc --combine ... part1.c part2.c part3.c ... " build would. | ||
45 | */ | ||
46 | #include "usbstring.c" | ||
47 | #include "config.c" | ||
48 | #include "epautoconf.c" | ||
49 | |||
50 | /*-------------------------------------------------------------------------*/ | ||
51 | |||
52 | |||
38 | MODULE_AUTHOR("Ben Williamson"); | 53 | MODULE_AUTHOR("Ben Williamson"); |
39 | MODULE_LICENSE("GPL v2"); | 54 | MODULE_LICENSE("GPL v2"); |
40 | 55 | ||
@@ -207,7 +222,7 @@ static struct usb_config_descriptor config_desc = { | |||
207 | * power properties of the device. Is it selfpowered? | 222 | * power properties of the device. Is it selfpowered? |
208 | */ | 223 | */ |
209 | .bmAttributes = USB_CONFIG_ATT_ONE, | 224 | .bmAttributes = USB_CONFIG_ATT_ONE, |
210 | .bMaxPower = 1, | 225 | .bMaxPower = CONFIG_USB_GADGET_VBUS_DRAW / 2, |
211 | }; | 226 | }; |
212 | 227 | ||
213 | /* B.3.1 Standard AC Interface Descriptor */ | 228 | /* B.3.1 Standard AC Interface Descriptor */ |
diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c index 5cfb5ebf3881..8ae70de2c37d 100644 --- a/drivers/usb/gadget/net2280.c +++ b/drivers/usb/gadget/net2280.c | |||
@@ -178,6 +178,7 @@ net2280_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc) | |||
178 | 178 | ||
179 | /* ep_reset() has already been called */ | 179 | /* ep_reset() has already been called */ |
180 | ep->stopped = 0; | 180 | ep->stopped = 0; |
181 | ep->wedged = 0; | ||
181 | ep->out_overflow = 0; | 182 | ep->out_overflow = 0; |
182 | 183 | ||
183 | /* set speed-dependent max packet; may kick in high bandwidth */ | 184 | /* set speed-dependent max packet; may kick in high bandwidth */ |
@@ -1218,7 +1219,7 @@ static int net2280_dequeue (struct usb_ep *_ep, struct usb_request *_req) | |||
1218 | static int net2280_fifo_status (struct usb_ep *_ep); | 1219 | static int net2280_fifo_status (struct usb_ep *_ep); |
1219 | 1220 | ||
1220 | static int | 1221 | static int |
1221 | net2280_set_halt (struct usb_ep *_ep, int value) | 1222 | net2280_set_halt_and_wedge(struct usb_ep *_ep, int value, int wedged) |
1222 | { | 1223 | { |
1223 | struct net2280_ep *ep; | 1224 | struct net2280_ep *ep; |
1224 | unsigned long flags; | 1225 | unsigned long flags; |
@@ -1239,16 +1240,21 @@ net2280_set_halt (struct usb_ep *_ep, int value) | |||
1239 | else if (ep->is_in && value && net2280_fifo_status (_ep) != 0) | 1240 | else if (ep->is_in && value && net2280_fifo_status (_ep) != 0) |
1240 | retval = -EAGAIN; | 1241 | retval = -EAGAIN; |
1241 | else { | 1242 | else { |
1242 | VDEBUG (ep->dev, "%s %s halt\n", _ep->name, | 1243 | VDEBUG (ep->dev, "%s %s %s\n", _ep->name, |
1243 | value ? "set" : "clear"); | 1244 | value ? "set" : "clear", |
1245 | wedged ? "wedge" : "halt"); | ||
1244 | /* set/clear, then synch memory views with the device */ | 1246 | /* set/clear, then synch memory views with the device */ |
1245 | if (value) { | 1247 | if (value) { |
1246 | if (ep->num == 0) | 1248 | if (ep->num == 0) |
1247 | ep->dev->protocol_stall = 1; | 1249 | ep->dev->protocol_stall = 1; |
1248 | else | 1250 | else |
1249 | set_halt (ep); | 1251 | set_halt (ep); |
1250 | } else | 1252 | if (wedged) |
1253 | ep->wedged = 1; | ||
1254 | } else { | ||
1251 | clear_halt (ep); | 1255 | clear_halt (ep); |
1256 | ep->wedged = 0; | ||
1257 | } | ||
1252 | (void) readl (&ep->regs->ep_rsp); | 1258 | (void) readl (&ep->regs->ep_rsp); |
1253 | } | 1259 | } |
1254 | spin_unlock_irqrestore (&ep->dev->lock, flags); | 1260 | spin_unlock_irqrestore (&ep->dev->lock, flags); |
@@ -1257,6 +1263,20 @@ net2280_set_halt (struct usb_ep *_ep, int value) | |||
1257 | } | 1263 | } |
1258 | 1264 | ||
1259 | static int | 1265 | static int |
1266 | net2280_set_halt(struct usb_ep *_ep, int value) | ||
1267 | { | ||
1268 | return net2280_set_halt_and_wedge(_ep, value, 0); | ||
1269 | } | ||
1270 | |||
1271 | static int | ||
1272 | net2280_set_wedge(struct usb_ep *_ep) | ||
1273 | { | ||
1274 | if (!_ep || _ep->name == ep0name) | ||
1275 | return -EINVAL; | ||
1276 | return net2280_set_halt_and_wedge(_ep, 1, 1); | ||
1277 | } | ||
1278 | |||
1279 | static int | ||
1260 | net2280_fifo_status (struct usb_ep *_ep) | 1280 | net2280_fifo_status (struct usb_ep *_ep) |
1261 | { | 1281 | { |
1262 | struct net2280_ep *ep; | 1282 | struct net2280_ep *ep; |
@@ -1302,6 +1322,7 @@ static const struct usb_ep_ops net2280_ep_ops = { | |||
1302 | .dequeue = net2280_dequeue, | 1322 | .dequeue = net2280_dequeue, |
1303 | 1323 | ||
1304 | .set_halt = net2280_set_halt, | 1324 | .set_halt = net2280_set_halt, |
1325 | .set_wedge = net2280_set_wedge, | ||
1305 | .fifo_status = net2280_fifo_status, | 1326 | .fifo_status = net2280_fifo_status, |
1306 | .fifo_flush = net2280_fifo_flush, | 1327 | .fifo_flush = net2280_fifo_flush, |
1307 | }; | 1328 | }; |
@@ -2410,9 +2431,14 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat) | |||
2410 | goto do_stall; | 2431 | goto do_stall; |
2411 | if ((e = get_ep_by_addr (dev, w_index)) == 0) | 2432 | if ((e = get_ep_by_addr (dev, w_index)) == 0) |
2412 | goto do_stall; | 2433 | goto do_stall; |
2413 | clear_halt (e); | 2434 | if (e->wedged) { |
2435 | VDEBUG(dev, "%s wedged, halt not cleared\n", | ||
2436 | ep->ep.name); | ||
2437 | } else { | ||
2438 | VDEBUG(dev, "%s clear halt\n", ep->ep.name); | ||
2439 | clear_halt(e); | ||
2440 | } | ||
2414 | allow_status (ep); | 2441 | allow_status (ep); |
2415 | VDEBUG (dev, "%s clear halt\n", ep->ep.name); | ||
2416 | goto next_endpoints; | 2442 | goto next_endpoints; |
2417 | } | 2443 | } |
2418 | break; | 2444 | break; |
@@ -2427,6 +2453,8 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat) | |||
2427 | goto do_stall; | 2453 | goto do_stall; |
2428 | if ((e = get_ep_by_addr (dev, w_index)) == 0) | 2454 | if ((e = get_ep_by_addr (dev, w_index)) == 0) |
2429 | goto do_stall; | 2455 | goto do_stall; |
2456 | if (e->ep.name == ep0name) | ||
2457 | goto do_stall; | ||
2430 | set_halt (e); | 2458 | set_halt (e); |
2431 | allow_status (ep); | 2459 | allow_status (ep); |
2432 | VDEBUG (dev, "%s set halt\n", ep->ep.name); | 2460 | VDEBUG (dev, "%s set halt\n", ep->ep.name); |
diff --git a/drivers/usb/gadget/net2280.h b/drivers/usb/gadget/net2280.h index 81a71dbdc2c6..c36852263d93 100644 --- a/drivers/usb/gadget/net2280.h +++ b/drivers/usb/gadget/net2280.h | |||
@@ -109,6 +109,7 @@ struct net2280_ep { | |||
109 | in_fifo_validate : 1, | 109 | in_fifo_validate : 1, |
110 | out_overflow : 1, | 110 | out_overflow : 1, |
111 | stopped : 1, | 111 | stopped : 1, |
112 | wedged : 1, | ||
112 | is_in : 1, | 113 | is_in : 1, |
113 | is_iso : 1, | 114 | is_iso : 1, |
114 | responded : 1; | 115 | responded : 1; |
diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c index 574c53831a05..34e9e393f929 100644 --- a/drivers/usb/gadget/omap_udc.c +++ b/drivers/usb/gadget/omap_udc.c | |||
@@ -787,7 +787,7 @@ static void dma_channel_claim(struct omap_ep *ep, unsigned channel) | |||
787 | omap_set_dma_dest_params(ep->lch, | 787 | omap_set_dma_dest_params(ep->lch, |
788 | OMAP_DMA_PORT_TIPB, | 788 | OMAP_DMA_PORT_TIPB, |
789 | OMAP_DMA_AMODE_CONSTANT, | 789 | OMAP_DMA_AMODE_CONSTANT, |
790 | (unsigned long) io_v2p(UDC_DATA_DMA), | 790 | UDC_DATA_DMA, |
791 | 0, 0); | 791 | 0, 0); |
792 | } | 792 | } |
793 | } else { | 793 | } else { |
@@ -804,7 +804,7 @@ static void dma_channel_claim(struct omap_ep *ep, unsigned channel) | |||
804 | omap_set_dma_src_params(ep->lch, | 804 | omap_set_dma_src_params(ep->lch, |
805 | OMAP_DMA_PORT_TIPB, | 805 | OMAP_DMA_PORT_TIPB, |
806 | OMAP_DMA_AMODE_CONSTANT, | 806 | OMAP_DMA_AMODE_CONSTANT, |
807 | (unsigned long) io_v2p(UDC_DATA_DMA), | 807 | UDC_DATA_DMA, |
808 | 0, 0); | 808 | 0, 0); |
809 | /* EMIFF or SDRC */ | 809 | /* EMIFF or SDRC */ |
810 | omap_set_dma_dest_burst_mode(ep->lch, | 810 | omap_set_dma_dest_burst_mode(ep->lch, |
@@ -2313,6 +2313,13 @@ static int proc_otg_show(struct seq_file *s) | |||
2313 | 2313 | ||
2314 | tmp = omap_readl(OTG_REV); | 2314 | tmp = omap_readl(OTG_REV); |
2315 | if (cpu_is_omap24xx()) { | 2315 | if (cpu_is_omap24xx()) { |
2316 | /* | ||
2317 | * REVISIT: Not clear how this works on OMAP2. trans | ||
2318 | * is ANDed to produce bits 7 and 8, which might make | ||
2319 | * sense for USB_TRANSCEIVER_CTRL on OMAP1, | ||
2320 | * but with CONTROL_DEVCONF, these bits have something to | ||
2321 | * do with the frame adjustment counter and McBSP2. | ||
2322 | */ | ||
2316 | ctrl_name = "control_devconf"; | 2323 | ctrl_name = "control_devconf"; |
2317 | trans = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0); | 2324 | trans = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0); |
2318 | } else { | 2325 | } else { |
diff --git a/drivers/usb/gadget/printer.c b/drivers/usb/gadget/printer.c index e0090085b78e..5a3034fdfe47 100644 --- a/drivers/usb/gadget/printer.c +++ b/drivers/usb/gadget/printer.c | |||
@@ -53,6 +53,20 @@ | |||
53 | 53 | ||
54 | #include "gadget_chips.h" | 54 | #include "gadget_chips.h" |
55 | 55 | ||
56 | |||
57 | /* | ||
58 | * Kbuild is not very cooperative with respect to linking separately | ||
59 | * compiled library objects into one module. So for now we won't use | ||
60 | * separate compilation ... ensuring init/exit sections work to shrink | ||
61 | * the runtime footprint, and giving us at least some parts of what | ||
62 | * a "gcc --combine ... part1.c part2.c part3.c ... " build would. | ||
63 | */ | ||
64 | #include "usbstring.c" | ||
65 | #include "config.c" | ||
66 | #include "epautoconf.c" | ||
67 | |||
68 | /*-------------------------------------------------------------------------*/ | ||
69 | |||
56 | #define DRIVER_DESC "Printer Gadget" | 70 | #define DRIVER_DESC "Printer Gadget" |
57 | #define DRIVER_VERSION "2007 OCT 06" | 71 | #define DRIVER_VERSION "2007 OCT 06" |
58 | 72 | ||
@@ -238,7 +252,7 @@ static struct usb_config_descriptor config_desc = { | |||
238 | .bConfigurationValue = DEV_CONFIG_VALUE, | 252 | .bConfigurationValue = DEV_CONFIG_VALUE, |
239 | .iConfiguration = 0, | 253 | .iConfiguration = 0, |
240 | .bmAttributes = USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER, | 254 | .bmAttributes = USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER, |
241 | .bMaxPower = 1 /* Self-Powered */ | 255 | .bMaxPower = CONFIG_USB_GADGET_VBUS_DRAW / 2, |
242 | }; | 256 | }; |
243 | 257 | ||
244 | static struct usb_interface_descriptor intf_desc = { | 258 | static struct usb_interface_descriptor intf_desc = { |
@@ -1264,8 +1278,7 @@ unknown: | |||
1264 | /* respond with data transfer before status phase? */ | 1278 | /* respond with data transfer before status phase? */ |
1265 | if (value >= 0) { | 1279 | if (value >= 0) { |
1266 | req->length = value; | 1280 | req->length = value; |
1267 | req->zero = value < wLength | 1281 | req->zero = value < wLength; |
1268 | && (value % gadget->ep0->maxpacket) == 0; | ||
1269 | value = usb_ep_queue(gadget->ep0, req, GFP_ATOMIC); | 1282 | value = usb_ep_queue(gadget->ep0, req, GFP_ATOMIC); |
1270 | if (value < 0) { | 1283 | if (value < 0) { |
1271 | DBG(dev, "ep_queue --> %d\n", value); | 1284 | DBG(dev, "ep_queue --> %d\n", value); |
@@ -1360,8 +1373,8 @@ printer_bind(struct usb_gadget *gadget) | |||
1360 | 1373 | ||
1361 | 1374 | ||
1362 | /* Setup the sysfs files for the printer gadget. */ | 1375 | /* Setup the sysfs files for the printer gadget. */ |
1363 | dev->pdev = device_create_drvdata(usb_gadget_class, NULL, | 1376 | dev->pdev = device_create(usb_gadget_class, NULL, g_printer_devno, |
1364 | g_printer_devno, NULL, "g_printer"); | 1377 | NULL, "g_printer"); |
1365 | if (IS_ERR(dev->pdev)) { | 1378 | if (IS_ERR(dev->pdev)) { |
1366 | ERROR(dev, "Failed to create device: g_printer\n"); | 1379 | ERROR(dev, "Failed to create device: g_printer\n"); |
1367 | goto fail; | 1380 | goto fail; |
@@ -1463,7 +1476,6 @@ autoconf_fail: | |||
1463 | if (gadget->is_otg) { | 1476 | if (gadget->is_otg) { |
1464 | otg_desc.bmAttributes |= USB_OTG_HNP, | 1477 | otg_desc.bmAttributes |= USB_OTG_HNP, |
1465 | config_desc.bmAttributes |= USB_CONFIG_ATT_WAKEUP; | 1478 | config_desc.bmAttributes |= USB_CONFIG_ATT_WAKEUP; |
1466 | config_desc.bMaxPower = 4; | ||
1467 | } | 1479 | } |
1468 | 1480 | ||
1469 | spin_lock_init(&dev->lock); | 1481 | spin_lock_init(&dev->lock); |
diff --git a/drivers/usb/gadget/pxa27x_udc.c b/drivers/usb/gadget/pxa27x_udc.c index a28513ecbe5b..bcf375ca3d72 100644 --- a/drivers/usb/gadget/pxa27x_udc.c +++ b/drivers/usb/gadget/pxa27x_udc.c | |||
@@ -22,7 +22,6 @@ | |||
22 | #include <linux/module.h> | 22 | #include <linux/module.h> |
23 | #include <linux/kernel.h> | 23 | #include <linux/kernel.h> |
24 | #include <linux/types.h> | 24 | #include <linux/types.h> |
25 | #include <linux/version.h> | ||
26 | #include <linux/errno.h> | 25 | #include <linux/errno.h> |
27 | #include <linux/platform_device.h> | 26 | #include <linux/platform_device.h> |
28 | #include <linux/delay.h> | 27 | #include <linux/delay.h> |
@@ -1622,7 +1621,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver) | |||
1622 | struct pxa_udc *udc = the_controller; | 1621 | struct pxa_udc *udc = the_controller; |
1623 | int retval; | 1622 | int retval; |
1624 | 1623 | ||
1625 | if (!driver || driver->speed != USB_SPEED_FULL || !driver->bind | 1624 | if (!driver || driver->speed < USB_SPEED_FULL || !driver->bind |
1626 | || !driver->disconnect || !driver->setup) | 1625 | || !driver->disconnect || !driver->setup) |
1627 | return -EINVAL; | 1626 | return -EINVAL; |
1628 | if (!udc) | 1627 | if (!udc) |
diff --git a/drivers/usb/gadget/rndis.c b/drivers/usb/gadget/rndis.c index 7228e8562236..8c26f5ea2b83 100644 --- a/drivers/usb/gadget/rndis.c +++ b/drivers/usb/gadget/rndis.c | |||
@@ -57,11 +57,6 @@ MODULE_PARM_DESC (rndis_debug, "enable debugging"); | |||
57 | #define rndis_debug 0 | 57 | #define rndis_debug 0 |
58 | #endif | 58 | #endif |
59 | 59 | ||
60 | #define DBG(str,args...) do { \ | ||
61 | if (rndis_debug) \ | ||
62 | pr_debug(str , ## args); \ | ||
63 | } while (0) | ||
64 | |||
65 | #define RNDIS_MAX_CONFIGS 1 | 60 | #define RNDIS_MAX_CONFIGS 1 |
66 | 61 | ||
67 | 62 | ||
@@ -183,9 +178,9 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, | |||
183 | if (!resp) return -ENOMEM; | 178 | if (!resp) return -ENOMEM; |
184 | 179 | ||
185 | if (buf_len && rndis_debug > 1) { | 180 | if (buf_len && rndis_debug > 1) { |
186 | DBG("query OID %08x value, len %d:\n", OID, buf_len); | 181 | pr_debug("query OID %08x value, len %d:\n", OID, buf_len); |
187 | for (i = 0; i < buf_len; i += 16) { | 182 | for (i = 0; i < buf_len; i += 16) { |
188 | DBG("%03d: %08x %08x %08x %08x\n", i, | 183 | pr_debug("%03d: %08x %08x %08x %08x\n", i, |
189 | get_unaligned_le32(&buf[i]), | 184 | get_unaligned_le32(&buf[i]), |
190 | get_unaligned_le32(&buf[i + 4]), | 185 | get_unaligned_le32(&buf[i + 4]), |
191 | get_unaligned_le32(&buf[i + 8]), | 186 | get_unaligned_le32(&buf[i + 8]), |
@@ -209,7 +204,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, | |||
209 | 204 | ||
210 | /* mandatory */ | 205 | /* mandatory */ |
211 | case OID_GEN_SUPPORTED_LIST: | 206 | case OID_GEN_SUPPORTED_LIST: |
212 | DBG("%s: OID_GEN_SUPPORTED_LIST\n", __func__); | 207 | pr_debug("%s: OID_GEN_SUPPORTED_LIST\n", __func__); |
213 | length = sizeof (oid_supported_list); | 208 | length = sizeof (oid_supported_list); |
214 | count = length / sizeof (u32); | 209 | count = length / sizeof (u32); |
215 | for (i = 0; i < count; i++) | 210 | for (i = 0; i < count; i++) |
@@ -219,7 +214,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, | |||
219 | 214 | ||
220 | /* mandatory */ | 215 | /* mandatory */ |
221 | case OID_GEN_HARDWARE_STATUS: | 216 | case OID_GEN_HARDWARE_STATUS: |
222 | DBG("%s: OID_GEN_HARDWARE_STATUS\n", __func__); | 217 | pr_debug("%s: OID_GEN_HARDWARE_STATUS\n", __func__); |
223 | /* Bogus question! | 218 | /* Bogus question! |
224 | * Hardware must be ready to receive high level protocols. | 219 | * Hardware must be ready to receive high level protocols. |
225 | * BTW: | 220 | * BTW: |
@@ -232,14 +227,14 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, | |||
232 | 227 | ||
233 | /* mandatory */ | 228 | /* mandatory */ |
234 | case OID_GEN_MEDIA_SUPPORTED: | 229 | case OID_GEN_MEDIA_SUPPORTED: |
235 | DBG("%s: OID_GEN_MEDIA_SUPPORTED\n", __func__); | 230 | pr_debug("%s: OID_GEN_MEDIA_SUPPORTED\n", __func__); |
236 | *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr].medium); | 231 | *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr].medium); |
237 | retval = 0; | 232 | retval = 0; |
238 | break; | 233 | break; |
239 | 234 | ||
240 | /* mandatory */ | 235 | /* mandatory */ |
241 | case OID_GEN_MEDIA_IN_USE: | 236 | case OID_GEN_MEDIA_IN_USE: |
242 | DBG("%s: OID_GEN_MEDIA_IN_USE\n", __func__); | 237 | pr_debug("%s: OID_GEN_MEDIA_IN_USE\n", __func__); |
243 | /* one medium, one transport... (maybe you do it better) */ | 238 | /* one medium, one transport... (maybe you do it better) */ |
244 | *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr].medium); | 239 | *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr].medium); |
245 | retval = 0; | 240 | retval = 0; |
@@ -247,7 +242,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, | |||
247 | 242 | ||
248 | /* mandatory */ | 243 | /* mandatory */ |
249 | case OID_GEN_MAXIMUM_FRAME_SIZE: | 244 | case OID_GEN_MAXIMUM_FRAME_SIZE: |
250 | DBG("%s: OID_GEN_MAXIMUM_FRAME_SIZE\n", __func__); | 245 | pr_debug("%s: OID_GEN_MAXIMUM_FRAME_SIZE\n", __func__); |
251 | if (rndis_per_dev_params [configNr].dev) { | 246 | if (rndis_per_dev_params [configNr].dev) { |
252 | *outbuf = cpu_to_le32 ( | 247 | *outbuf = cpu_to_le32 ( |
253 | rndis_per_dev_params [configNr].dev->mtu); | 248 | rndis_per_dev_params [configNr].dev->mtu); |
@@ -258,7 +253,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, | |||
258 | /* mandatory */ | 253 | /* mandatory */ |
259 | case OID_GEN_LINK_SPEED: | 254 | case OID_GEN_LINK_SPEED: |
260 | if (rndis_debug > 1) | 255 | if (rndis_debug > 1) |
261 | DBG("%s: OID_GEN_LINK_SPEED\n", __func__); | 256 | pr_debug("%s: OID_GEN_LINK_SPEED\n", __func__); |
262 | if (rndis_per_dev_params [configNr].media_state | 257 | if (rndis_per_dev_params [configNr].media_state |
263 | == NDIS_MEDIA_STATE_DISCONNECTED) | 258 | == NDIS_MEDIA_STATE_DISCONNECTED) |
264 | *outbuf = __constant_cpu_to_le32 (0); | 259 | *outbuf = __constant_cpu_to_le32 (0); |
@@ -270,7 +265,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, | |||
270 | 265 | ||
271 | /* mandatory */ | 266 | /* mandatory */ |
272 | case OID_GEN_TRANSMIT_BLOCK_SIZE: | 267 | case OID_GEN_TRANSMIT_BLOCK_SIZE: |
273 | DBG("%s: OID_GEN_TRANSMIT_BLOCK_SIZE\n", __func__); | 268 | pr_debug("%s: OID_GEN_TRANSMIT_BLOCK_SIZE\n", __func__); |
274 | if (rndis_per_dev_params [configNr].dev) { | 269 | if (rndis_per_dev_params [configNr].dev) { |
275 | *outbuf = cpu_to_le32 ( | 270 | *outbuf = cpu_to_le32 ( |
276 | rndis_per_dev_params [configNr].dev->mtu); | 271 | rndis_per_dev_params [configNr].dev->mtu); |
@@ -280,7 +275,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, | |||
280 | 275 | ||
281 | /* mandatory */ | 276 | /* mandatory */ |
282 | case OID_GEN_RECEIVE_BLOCK_SIZE: | 277 | case OID_GEN_RECEIVE_BLOCK_SIZE: |
283 | DBG("%s: OID_GEN_RECEIVE_BLOCK_SIZE\n", __func__); | 278 | pr_debug("%s: OID_GEN_RECEIVE_BLOCK_SIZE\n", __func__); |
284 | if (rndis_per_dev_params [configNr].dev) { | 279 | if (rndis_per_dev_params [configNr].dev) { |
285 | *outbuf = cpu_to_le32 ( | 280 | *outbuf = cpu_to_le32 ( |
286 | rndis_per_dev_params [configNr].dev->mtu); | 281 | rndis_per_dev_params [configNr].dev->mtu); |
@@ -290,7 +285,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, | |||
290 | 285 | ||
291 | /* mandatory */ | 286 | /* mandatory */ |
292 | case OID_GEN_VENDOR_ID: | 287 | case OID_GEN_VENDOR_ID: |
293 | DBG("%s: OID_GEN_VENDOR_ID\n", __func__); | 288 | pr_debug("%s: OID_GEN_VENDOR_ID\n", __func__); |
294 | *outbuf = cpu_to_le32 ( | 289 | *outbuf = cpu_to_le32 ( |
295 | rndis_per_dev_params [configNr].vendorID); | 290 | rndis_per_dev_params [configNr].vendorID); |
296 | retval = 0; | 291 | retval = 0; |
@@ -298,7 +293,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, | |||
298 | 293 | ||
299 | /* mandatory */ | 294 | /* mandatory */ |
300 | case OID_GEN_VENDOR_DESCRIPTION: | 295 | case OID_GEN_VENDOR_DESCRIPTION: |
301 | DBG("%s: OID_GEN_VENDOR_DESCRIPTION\n", __func__); | 296 | pr_debug("%s: OID_GEN_VENDOR_DESCRIPTION\n", __func__); |
302 | length = strlen (rndis_per_dev_params [configNr].vendorDescr); | 297 | length = strlen (rndis_per_dev_params [configNr].vendorDescr); |
303 | memcpy (outbuf, | 298 | memcpy (outbuf, |
304 | rndis_per_dev_params [configNr].vendorDescr, length); | 299 | rndis_per_dev_params [configNr].vendorDescr, length); |
@@ -306,7 +301,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, | |||
306 | break; | 301 | break; |
307 | 302 | ||
308 | case OID_GEN_VENDOR_DRIVER_VERSION: | 303 | case OID_GEN_VENDOR_DRIVER_VERSION: |
309 | DBG("%s: OID_GEN_VENDOR_DRIVER_VERSION\n", __func__); | 304 | pr_debug("%s: OID_GEN_VENDOR_DRIVER_VERSION\n", __func__); |
310 | /* Created as LE */ | 305 | /* Created as LE */ |
311 | *outbuf = rndis_driver_version; | 306 | *outbuf = rndis_driver_version; |
312 | retval = 0; | 307 | retval = 0; |
@@ -314,14 +309,14 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, | |||
314 | 309 | ||
315 | /* mandatory */ | 310 | /* mandatory */ |
316 | case OID_GEN_CURRENT_PACKET_FILTER: | 311 | case OID_GEN_CURRENT_PACKET_FILTER: |
317 | DBG("%s: OID_GEN_CURRENT_PACKET_FILTER\n", __func__); | 312 | pr_debug("%s: OID_GEN_CURRENT_PACKET_FILTER\n", __func__); |
318 | *outbuf = cpu_to_le32 (*rndis_per_dev_params[configNr].filter); | 313 | *outbuf = cpu_to_le32 (*rndis_per_dev_params[configNr].filter); |
319 | retval = 0; | 314 | retval = 0; |
320 | break; | 315 | break; |
321 | 316 | ||
322 | /* mandatory */ | 317 | /* mandatory */ |
323 | case OID_GEN_MAXIMUM_TOTAL_SIZE: | 318 | case OID_GEN_MAXIMUM_TOTAL_SIZE: |
324 | DBG("%s: OID_GEN_MAXIMUM_TOTAL_SIZE\n", __func__); | 319 | pr_debug("%s: OID_GEN_MAXIMUM_TOTAL_SIZE\n", __func__); |
325 | *outbuf = __constant_cpu_to_le32(RNDIS_MAX_TOTAL_SIZE); | 320 | *outbuf = __constant_cpu_to_le32(RNDIS_MAX_TOTAL_SIZE); |
326 | retval = 0; | 321 | retval = 0; |
327 | break; | 322 | break; |
@@ -329,14 +324,14 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, | |||
329 | /* mandatory */ | 324 | /* mandatory */ |
330 | case OID_GEN_MEDIA_CONNECT_STATUS: | 325 | case OID_GEN_MEDIA_CONNECT_STATUS: |
331 | if (rndis_debug > 1) | 326 | if (rndis_debug > 1) |
332 | DBG("%s: OID_GEN_MEDIA_CONNECT_STATUS\n", __func__); | 327 | pr_debug("%s: OID_GEN_MEDIA_CONNECT_STATUS\n", __func__); |
333 | *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr] | 328 | *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr] |
334 | .media_state); | 329 | .media_state); |
335 | retval = 0; | 330 | retval = 0; |
336 | break; | 331 | break; |
337 | 332 | ||
338 | case OID_GEN_PHYSICAL_MEDIUM: | 333 | case OID_GEN_PHYSICAL_MEDIUM: |
339 | DBG("%s: OID_GEN_PHYSICAL_MEDIUM\n", __func__); | 334 | pr_debug("%s: OID_GEN_PHYSICAL_MEDIUM\n", __func__); |
340 | *outbuf = __constant_cpu_to_le32 (0); | 335 | *outbuf = __constant_cpu_to_le32 (0); |
341 | retval = 0; | 336 | retval = 0; |
342 | break; | 337 | break; |
@@ -346,7 +341,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, | |||
346 | * versions emit undefined RNDIS messages. DOCUMENT ALL THESE! | 341 | * versions emit undefined RNDIS messages. DOCUMENT ALL THESE! |
347 | */ | 342 | */ |
348 | case OID_GEN_MAC_OPTIONS: /* from WinME */ | 343 | case OID_GEN_MAC_OPTIONS: /* from WinME */ |
349 | DBG("%s: OID_GEN_MAC_OPTIONS\n", __func__); | 344 | pr_debug("%s: OID_GEN_MAC_OPTIONS\n", __func__); |
350 | *outbuf = __constant_cpu_to_le32( | 345 | *outbuf = __constant_cpu_to_le32( |
351 | NDIS_MAC_OPTION_RECEIVE_SERIALIZED | 346 | NDIS_MAC_OPTION_RECEIVE_SERIALIZED |
352 | | NDIS_MAC_OPTION_FULL_DUPLEX); | 347 | | NDIS_MAC_OPTION_FULL_DUPLEX); |
@@ -358,7 +353,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, | |||
358 | /* mandatory */ | 353 | /* mandatory */ |
359 | case OID_GEN_XMIT_OK: | 354 | case OID_GEN_XMIT_OK: |
360 | if (rndis_debug > 1) | 355 | if (rndis_debug > 1) |
361 | DBG("%s: OID_GEN_XMIT_OK\n", __func__); | 356 | pr_debug("%s: OID_GEN_XMIT_OK\n", __func__); |
362 | if (stats) { | 357 | if (stats) { |
363 | *outbuf = cpu_to_le32(stats->tx_packets | 358 | *outbuf = cpu_to_le32(stats->tx_packets |
364 | - stats->tx_errors - stats->tx_dropped); | 359 | - stats->tx_errors - stats->tx_dropped); |
@@ -369,7 +364,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, | |||
369 | /* mandatory */ | 364 | /* mandatory */ |
370 | case OID_GEN_RCV_OK: | 365 | case OID_GEN_RCV_OK: |
371 | if (rndis_debug > 1) | 366 | if (rndis_debug > 1) |
372 | DBG("%s: OID_GEN_RCV_OK\n", __func__); | 367 | pr_debug("%s: OID_GEN_RCV_OK\n", __func__); |
373 | if (stats) { | 368 | if (stats) { |
374 | *outbuf = cpu_to_le32(stats->rx_packets | 369 | *outbuf = cpu_to_le32(stats->rx_packets |
375 | - stats->rx_errors - stats->rx_dropped); | 370 | - stats->rx_errors - stats->rx_dropped); |
@@ -380,7 +375,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, | |||
380 | /* mandatory */ | 375 | /* mandatory */ |
381 | case OID_GEN_XMIT_ERROR: | 376 | case OID_GEN_XMIT_ERROR: |
382 | if (rndis_debug > 1) | 377 | if (rndis_debug > 1) |
383 | DBG("%s: OID_GEN_XMIT_ERROR\n", __func__); | 378 | pr_debug("%s: OID_GEN_XMIT_ERROR\n", __func__); |
384 | if (stats) { | 379 | if (stats) { |
385 | *outbuf = cpu_to_le32(stats->tx_errors); | 380 | *outbuf = cpu_to_le32(stats->tx_errors); |
386 | retval = 0; | 381 | retval = 0; |
@@ -390,7 +385,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, | |||
390 | /* mandatory */ | 385 | /* mandatory */ |
391 | case OID_GEN_RCV_ERROR: | 386 | case OID_GEN_RCV_ERROR: |
392 | if (rndis_debug > 1) | 387 | if (rndis_debug > 1) |
393 | DBG("%s: OID_GEN_RCV_ERROR\n", __func__); | 388 | pr_debug("%s: OID_GEN_RCV_ERROR\n", __func__); |
394 | if (stats) { | 389 | if (stats) { |
395 | *outbuf = cpu_to_le32(stats->rx_errors); | 390 | *outbuf = cpu_to_le32(stats->rx_errors); |
396 | retval = 0; | 391 | retval = 0; |
@@ -399,7 +394,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, | |||
399 | 394 | ||
400 | /* mandatory */ | 395 | /* mandatory */ |
401 | case OID_GEN_RCV_NO_BUFFER: | 396 | case OID_GEN_RCV_NO_BUFFER: |
402 | DBG("%s: OID_GEN_RCV_NO_BUFFER\n", __func__); | 397 | pr_debug("%s: OID_GEN_RCV_NO_BUFFER\n", __func__); |
403 | if (stats) { | 398 | if (stats) { |
404 | *outbuf = cpu_to_le32(stats->rx_dropped); | 399 | *outbuf = cpu_to_le32(stats->rx_dropped); |
405 | retval = 0; | 400 | retval = 0; |
@@ -410,7 +405,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, | |||
410 | 405 | ||
411 | /* mandatory */ | 406 | /* mandatory */ |
412 | case OID_802_3_PERMANENT_ADDRESS: | 407 | case OID_802_3_PERMANENT_ADDRESS: |
413 | DBG("%s: OID_802_3_PERMANENT_ADDRESS\n", __func__); | 408 | pr_debug("%s: OID_802_3_PERMANENT_ADDRESS\n", __func__); |
414 | if (rndis_per_dev_params [configNr].dev) { | 409 | if (rndis_per_dev_params [configNr].dev) { |
415 | length = ETH_ALEN; | 410 | length = ETH_ALEN; |
416 | memcpy (outbuf, | 411 | memcpy (outbuf, |
@@ -422,7 +417,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, | |||
422 | 417 | ||
423 | /* mandatory */ | 418 | /* mandatory */ |
424 | case OID_802_3_CURRENT_ADDRESS: | 419 | case OID_802_3_CURRENT_ADDRESS: |
425 | DBG("%s: OID_802_3_CURRENT_ADDRESS\n", __func__); | 420 | pr_debug("%s: OID_802_3_CURRENT_ADDRESS\n", __func__); |
426 | if (rndis_per_dev_params [configNr].dev) { | 421 | if (rndis_per_dev_params [configNr].dev) { |
427 | length = ETH_ALEN; | 422 | length = ETH_ALEN; |
428 | memcpy (outbuf, | 423 | memcpy (outbuf, |
@@ -434,7 +429,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, | |||
434 | 429 | ||
435 | /* mandatory */ | 430 | /* mandatory */ |
436 | case OID_802_3_MULTICAST_LIST: | 431 | case OID_802_3_MULTICAST_LIST: |
437 | DBG("%s: OID_802_3_MULTICAST_LIST\n", __func__); | 432 | pr_debug("%s: OID_802_3_MULTICAST_LIST\n", __func__); |
438 | /* Multicast base address only */ | 433 | /* Multicast base address only */ |
439 | *outbuf = __constant_cpu_to_le32 (0xE0000000); | 434 | *outbuf = __constant_cpu_to_le32 (0xE0000000); |
440 | retval = 0; | 435 | retval = 0; |
@@ -442,21 +437,21 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, | |||
442 | 437 | ||
443 | /* mandatory */ | 438 | /* mandatory */ |
444 | case OID_802_3_MAXIMUM_LIST_SIZE: | 439 | case OID_802_3_MAXIMUM_LIST_SIZE: |
445 | DBG("%s: OID_802_3_MAXIMUM_LIST_SIZE\n", __func__); | 440 | pr_debug("%s: OID_802_3_MAXIMUM_LIST_SIZE\n", __func__); |
446 | /* Multicast base address only */ | 441 | /* Multicast base address only */ |
447 | *outbuf = __constant_cpu_to_le32 (1); | 442 | *outbuf = __constant_cpu_to_le32 (1); |
448 | retval = 0; | 443 | retval = 0; |
449 | break; | 444 | break; |
450 | 445 | ||
451 | case OID_802_3_MAC_OPTIONS: | 446 | case OID_802_3_MAC_OPTIONS: |
452 | DBG("%s: OID_802_3_MAC_OPTIONS\n", __func__); | 447 | pr_debug("%s: OID_802_3_MAC_OPTIONS\n", __func__); |
453 | break; | 448 | break; |
454 | 449 | ||
455 | /* ieee802.3 statistics OIDs (table 4-4) */ | 450 | /* ieee802.3 statistics OIDs (table 4-4) */ |
456 | 451 | ||
457 | /* mandatory */ | 452 | /* mandatory */ |
458 | case OID_802_3_RCV_ERROR_ALIGNMENT: | 453 | case OID_802_3_RCV_ERROR_ALIGNMENT: |
459 | DBG("%s: OID_802_3_RCV_ERROR_ALIGNMENT\n", __func__); | 454 | pr_debug("%s: OID_802_3_RCV_ERROR_ALIGNMENT\n", __func__); |
460 | if (stats) { | 455 | if (stats) { |
461 | *outbuf = cpu_to_le32(stats->rx_frame_errors); | 456 | *outbuf = cpu_to_le32(stats->rx_frame_errors); |
462 | retval = 0; | 457 | retval = 0; |
@@ -465,14 +460,14 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, | |||
465 | 460 | ||
466 | /* mandatory */ | 461 | /* mandatory */ |
467 | case OID_802_3_XMIT_ONE_COLLISION: | 462 | case OID_802_3_XMIT_ONE_COLLISION: |
468 | DBG("%s: OID_802_3_XMIT_ONE_COLLISION\n", __func__); | 463 | pr_debug("%s: OID_802_3_XMIT_ONE_COLLISION\n", __func__); |
469 | *outbuf = __constant_cpu_to_le32 (0); | 464 | *outbuf = __constant_cpu_to_le32 (0); |
470 | retval = 0; | 465 | retval = 0; |
471 | break; | 466 | break; |
472 | 467 | ||
473 | /* mandatory */ | 468 | /* mandatory */ |
474 | case OID_802_3_XMIT_MORE_COLLISIONS: | 469 | case OID_802_3_XMIT_MORE_COLLISIONS: |
475 | DBG("%s: OID_802_3_XMIT_MORE_COLLISIONS\n", __func__); | 470 | pr_debug("%s: OID_802_3_XMIT_MORE_COLLISIONS\n", __func__); |
476 | *outbuf = __constant_cpu_to_le32 (0); | 471 | *outbuf = __constant_cpu_to_le32 (0); |
477 | retval = 0; | 472 | retval = 0; |
478 | break; | 473 | break; |
@@ -504,9 +499,9 @@ static int gen_ndis_set_resp (u8 configNr, u32 OID, u8 *buf, u32 buf_len, | |||
504 | return -ENOMEM; | 499 | return -ENOMEM; |
505 | 500 | ||
506 | if (buf_len && rndis_debug > 1) { | 501 | if (buf_len && rndis_debug > 1) { |
507 | DBG("set OID %08x value, len %d:\n", OID, buf_len); | 502 | pr_debug("set OID %08x value, len %d:\n", OID, buf_len); |
508 | for (i = 0; i < buf_len; i += 16) { | 503 | for (i = 0; i < buf_len; i += 16) { |
509 | DBG("%03d: %08x %08x %08x %08x\n", i, | 504 | pr_debug("%03d: %08x %08x %08x %08x\n", i, |
510 | get_unaligned_le32(&buf[i]), | 505 | get_unaligned_le32(&buf[i]), |
511 | get_unaligned_le32(&buf[i + 4]), | 506 | get_unaligned_le32(&buf[i + 4]), |
512 | get_unaligned_le32(&buf[i + 8]), | 507 | get_unaligned_le32(&buf[i + 8]), |
@@ -525,7 +520,7 @@ static int gen_ndis_set_resp (u8 configNr, u32 OID, u8 *buf, u32 buf_len, | |||
525 | * MULTICAST, ALL_MULTICAST, BROADCAST | 520 | * MULTICAST, ALL_MULTICAST, BROADCAST |
526 | */ | 521 | */ |
527 | *params->filter = (u16)get_unaligned_le32(buf); | 522 | *params->filter = (u16)get_unaligned_le32(buf); |
528 | DBG("%s: OID_GEN_CURRENT_PACKET_FILTER %08x\n", | 523 | pr_debug("%s: OID_GEN_CURRENT_PACKET_FILTER %08x\n", |
529 | __func__, *params->filter); | 524 | __func__, *params->filter); |
530 | 525 | ||
531 | /* this call has a significant side effect: it's | 526 | /* this call has a significant side effect: it's |
@@ -547,7 +542,7 @@ static int gen_ndis_set_resp (u8 configNr, u32 OID, u8 *buf, u32 buf_len, | |||
547 | 542 | ||
548 | case OID_802_3_MULTICAST_LIST: | 543 | case OID_802_3_MULTICAST_LIST: |
549 | /* I think we can ignore this */ | 544 | /* I think we can ignore this */ |
550 | DBG("%s: OID_802_3_MULTICAST_LIST\n", __func__); | 545 | pr_debug("%s: OID_802_3_MULTICAST_LIST\n", __func__); |
551 | retval = 0; | 546 | retval = 0; |
552 | break; | 547 | break; |
553 | 548 | ||
@@ -606,7 +601,7 @@ static int rndis_query_response (int configNr, rndis_query_msg_type *buf) | |||
606 | rndis_resp_t *r; | 601 | rndis_resp_t *r; |
607 | struct rndis_params *params = rndis_per_dev_params + configNr; | 602 | struct rndis_params *params = rndis_per_dev_params + configNr; |
608 | 603 | ||
609 | // DBG("%s: OID = %08X\n", __func__, cpu_to_le32(buf->OID)); | 604 | /* pr_debug("%s: OID = %08X\n", __func__, cpu_to_le32(buf->OID)); */ |
610 | if (!params->dev) | 605 | if (!params->dev) |
611 | return -ENOTSUPP; | 606 | return -ENOTSUPP; |
612 | 607 | ||
@@ -659,15 +654,15 @@ static int rndis_set_response (int configNr, rndis_set_msg_type *buf) | |||
659 | BufOffset = le32_to_cpu (buf->InformationBufferOffset); | 654 | BufOffset = le32_to_cpu (buf->InformationBufferOffset); |
660 | 655 | ||
661 | #ifdef VERBOSE_DEBUG | 656 | #ifdef VERBOSE_DEBUG |
662 | DBG("%s: Length: %d\n", __func__, BufLength); | 657 | pr_debug("%s: Length: %d\n", __func__, BufLength); |
663 | DBG("%s: Offset: %d\n", __func__, BufOffset); | 658 | pr_debug("%s: Offset: %d\n", __func__, BufOffset); |
664 | DBG("%s: InfoBuffer: ", __func__); | 659 | pr_debug("%s: InfoBuffer: ", __func__); |
665 | 660 | ||
666 | for (i = 0; i < BufLength; i++) { | 661 | for (i = 0; i < BufLength; i++) { |
667 | DBG("%02x ", *(((u8 *) buf) + i + 8 + BufOffset)); | 662 | pr_debug("%02x ", *(((u8 *) buf) + i + 8 + BufOffset)); |
668 | } | 663 | } |
669 | 664 | ||
670 | DBG("\n"); | 665 | pr_debug("\n"); |
671 | #endif | 666 | #endif |
672 | 667 | ||
673 | resp->MessageType = __constant_cpu_to_le32 (REMOTE_NDIS_SET_CMPLT); | 668 | resp->MessageType = __constant_cpu_to_le32 (REMOTE_NDIS_SET_CMPLT); |
@@ -821,14 +816,14 @@ int rndis_msg_parser (u8 configNr, u8 *buf) | |||
821 | /* For USB: responses may take up to 10 seconds */ | 816 | /* For USB: responses may take up to 10 seconds */ |
822 | switch (MsgType) { | 817 | switch (MsgType) { |
823 | case REMOTE_NDIS_INITIALIZE_MSG: | 818 | case REMOTE_NDIS_INITIALIZE_MSG: |
824 | DBG("%s: REMOTE_NDIS_INITIALIZE_MSG\n", | 819 | pr_debug("%s: REMOTE_NDIS_INITIALIZE_MSG\n", |
825 | __func__ ); | 820 | __func__ ); |
826 | params->state = RNDIS_INITIALIZED; | 821 | params->state = RNDIS_INITIALIZED; |
827 | return rndis_init_response (configNr, | 822 | return rndis_init_response (configNr, |
828 | (rndis_init_msg_type *) buf); | 823 | (rndis_init_msg_type *) buf); |
829 | 824 | ||
830 | case REMOTE_NDIS_HALT_MSG: | 825 | case REMOTE_NDIS_HALT_MSG: |
831 | DBG("%s: REMOTE_NDIS_HALT_MSG\n", | 826 | pr_debug("%s: REMOTE_NDIS_HALT_MSG\n", |
832 | __func__ ); | 827 | __func__ ); |
833 | params->state = RNDIS_UNINITIALIZED; | 828 | params->state = RNDIS_UNINITIALIZED; |
834 | if (params->dev) { | 829 | if (params->dev) { |
@@ -846,7 +841,7 @@ int rndis_msg_parser (u8 configNr, u8 *buf) | |||
846 | (rndis_set_msg_type *) buf); | 841 | (rndis_set_msg_type *) buf); |
847 | 842 | ||
848 | case REMOTE_NDIS_RESET_MSG: | 843 | case REMOTE_NDIS_RESET_MSG: |
849 | DBG("%s: REMOTE_NDIS_RESET_MSG\n", | 844 | pr_debug("%s: REMOTE_NDIS_RESET_MSG\n", |
850 | __func__ ); | 845 | __func__ ); |
851 | return rndis_reset_response (configNr, | 846 | return rndis_reset_response (configNr, |
852 | (rndis_reset_msg_type *) buf); | 847 | (rndis_reset_msg_type *) buf); |
@@ -854,7 +849,7 @@ int rndis_msg_parser (u8 configNr, u8 *buf) | |||
854 | case REMOTE_NDIS_KEEPALIVE_MSG: | 849 | case REMOTE_NDIS_KEEPALIVE_MSG: |
855 | /* For USB: host does this every 5 seconds */ | 850 | /* For USB: host does this every 5 seconds */ |
856 | if (rndis_debug > 1) | 851 | if (rndis_debug > 1) |
857 | DBG("%s: REMOTE_NDIS_KEEPALIVE_MSG\n", | 852 | pr_debug("%s: REMOTE_NDIS_KEEPALIVE_MSG\n", |
858 | __func__ ); | 853 | __func__ ); |
859 | return rndis_keepalive_response (configNr, | 854 | return rndis_keepalive_response (configNr, |
860 | (rndis_keepalive_msg_type *) | 855 | (rndis_keepalive_msg_type *) |
@@ -870,7 +865,7 @@ int rndis_msg_parser (u8 configNr, u8 *buf) | |||
870 | { | 865 | { |
871 | unsigned i; | 866 | unsigned i; |
872 | for (i = 0; i < MsgLength; i += 16) { | 867 | for (i = 0; i < MsgLength; i += 16) { |
873 | DBG("%03d: " | 868 | pr_debug("%03d: " |
874 | " %02x %02x %02x %02x" | 869 | " %02x %02x %02x %02x" |
875 | " %02x %02x %02x %02x" | 870 | " %02x %02x %02x %02x" |
876 | " %02x %02x %02x %02x" | 871 | " %02x %02x %02x %02x" |
@@ -905,18 +900,18 @@ int rndis_register(void (*resp_avail)(void *v), void *v) | |||
905 | rndis_per_dev_params [i].used = 1; | 900 | rndis_per_dev_params [i].used = 1; |
906 | rndis_per_dev_params [i].resp_avail = resp_avail; | 901 | rndis_per_dev_params [i].resp_avail = resp_avail; |
907 | rndis_per_dev_params [i].v = v; | 902 | rndis_per_dev_params [i].v = v; |
908 | DBG("%s: configNr = %d\n", __func__, i); | 903 | pr_debug("%s: configNr = %d\n", __func__, i); |
909 | return i; | 904 | return i; |
910 | } | 905 | } |
911 | } | 906 | } |
912 | DBG("failed\n"); | 907 | pr_debug("failed\n"); |
913 | 908 | ||
914 | return -ENODEV; | 909 | return -ENODEV; |
915 | } | 910 | } |
916 | 911 | ||
917 | void rndis_deregister (int configNr) | 912 | void rndis_deregister (int configNr) |
918 | { | 913 | { |
919 | DBG("%s: \n", __func__ ); | 914 | pr_debug("%s: \n", __func__); |
920 | 915 | ||
921 | if (configNr >= RNDIS_MAX_CONFIGS) return; | 916 | if (configNr >= RNDIS_MAX_CONFIGS) return; |
922 | rndis_per_dev_params [configNr].used = 0; | 917 | rndis_per_dev_params [configNr].used = 0; |
@@ -926,7 +921,7 @@ void rndis_deregister (int configNr) | |||
926 | 921 | ||
927 | int rndis_set_param_dev(u8 configNr, struct net_device *dev, u16 *cdc_filter) | 922 | int rndis_set_param_dev(u8 configNr, struct net_device *dev, u16 *cdc_filter) |
928 | { | 923 | { |
929 | DBG("%s:\n", __func__ ); | 924 | pr_debug("%s:\n", __func__); |
930 | if (!dev) | 925 | if (!dev) |
931 | return -EINVAL; | 926 | return -EINVAL; |
932 | if (configNr >= RNDIS_MAX_CONFIGS) return -1; | 927 | if (configNr >= RNDIS_MAX_CONFIGS) return -1; |
@@ -939,7 +934,7 @@ int rndis_set_param_dev(u8 configNr, struct net_device *dev, u16 *cdc_filter) | |||
939 | 934 | ||
940 | int rndis_set_param_vendor (u8 configNr, u32 vendorID, const char *vendorDescr) | 935 | int rndis_set_param_vendor (u8 configNr, u32 vendorID, const char *vendorDescr) |
941 | { | 936 | { |
942 | DBG("%s:\n", __func__ ); | 937 | pr_debug("%s:\n", __func__); |
943 | if (!vendorDescr) return -1; | 938 | if (!vendorDescr) return -1; |
944 | if (configNr >= RNDIS_MAX_CONFIGS) return -1; | 939 | if (configNr >= RNDIS_MAX_CONFIGS) return -1; |
945 | 940 | ||
@@ -951,7 +946,7 @@ int rndis_set_param_vendor (u8 configNr, u32 vendorID, const char *vendorDescr) | |||
951 | 946 | ||
952 | int rndis_set_param_medium (u8 configNr, u32 medium, u32 speed) | 947 | int rndis_set_param_medium (u8 configNr, u32 medium, u32 speed) |
953 | { | 948 | { |
954 | DBG("%s: %u %u\n", __func__, medium, speed); | 949 | pr_debug("%s: %u %u\n", __func__, medium, speed); |
955 | if (configNr >= RNDIS_MAX_CONFIGS) return -1; | 950 | if (configNr >= RNDIS_MAX_CONFIGS) return -1; |
956 | 951 | ||
957 | rndis_per_dev_params [configNr].medium = medium; | 952 | rndis_per_dev_params [configNr].medium = medium; |
@@ -1114,7 +1109,7 @@ static ssize_t rndis_proc_write(struct file *file, const char __user *buffer, | |||
1114 | break; | 1109 | break; |
1115 | default: | 1110 | default: |
1116 | if (fl_speed) p->speed = speed; | 1111 | if (fl_speed) p->speed = speed; |
1117 | else DBG("%c is not valid\n", c); | 1112 | else pr_debug("%c is not valid\n", c); |
1118 | break; | 1113 | break; |
1119 | } | 1114 | } |
1120 | 1115 | ||
@@ -1159,12 +1154,12 @@ int __init rndis_init (void) | |||
1159 | &rndis_proc_fops, | 1154 | &rndis_proc_fops, |
1160 | (void *)(rndis_per_dev_params + i)))) | 1155 | (void *)(rndis_per_dev_params + i)))) |
1161 | { | 1156 | { |
1162 | DBG("%s :remove entries", __func__); | 1157 | pr_debug("%s :remove entries", __func__); |
1163 | while (i) { | 1158 | while (i) { |
1164 | sprintf (name, NAME_TEMPLATE, --i); | 1159 | sprintf (name, NAME_TEMPLATE, --i); |
1165 | remove_proc_entry (name, NULL); | 1160 | remove_proc_entry (name, NULL); |
1166 | } | 1161 | } |
1167 | DBG("\n"); | 1162 | pr_debug("\n"); |
1168 | return -EIO; | 1163 | return -EIO; |
1169 | } | 1164 | } |
1170 | #endif | 1165 | #endif |
diff --git a/drivers/usb/gadget/s3c2410_udc.c b/drivers/usb/gadget/s3c2410_udc.c index 538807384592..48f51b12d2e2 100644 --- a/drivers/usb/gadget/s3c2410_udc.c +++ b/drivers/usb/gadget/s3c2410_udc.c | |||
@@ -35,7 +35,6 @@ | |||
35 | #include <linux/list.h> | 35 | #include <linux/list.h> |
36 | #include <linux/interrupt.h> | 36 | #include <linux/interrupt.h> |
37 | #include <linux/platform_device.h> | 37 | #include <linux/platform_device.h> |
38 | #include <linux/version.h> | ||
39 | #include <linux/clk.h> | 38 | #include <linux/clk.h> |
40 | 39 | ||
41 | #include <linux/debugfs.h> | 40 | #include <linux/debugfs.h> |
@@ -1652,7 +1651,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver) | |||
1652 | return -EBUSY; | 1651 | return -EBUSY; |
1653 | 1652 | ||
1654 | if (!driver->bind || !driver->setup | 1653 | if (!driver->bind || !driver->setup |
1655 | || driver->speed != USB_SPEED_FULL) { | 1654 | || driver->speed < USB_SPEED_FULL) { |
1656 | printk(KERN_ERR "Invalid driver: bind %p setup %p speed %d\n", | 1655 | printk(KERN_ERR "Invalid driver: bind %p setup %p speed %d\n", |
1657 | driver->bind, driver->setup, driver->speed); | 1656 | driver->bind, driver->setup, driver->speed); |
1658 | return -EINVAL; | 1657 | return -EINVAL; |
diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c index b3699afff002..37879af1c433 100644 --- a/drivers/usb/gadget/serial.c +++ b/drivers/usb/gadget/serial.c | |||
@@ -30,6 +30,25 @@ | |||
30 | 30 | ||
31 | /*-------------------------------------------------------------------------*/ | 31 | /*-------------------------------------------------------------------------*/ |
32 | 32 | ||
33 | /* | ||
34 | * Kbuild is not very cooperative with respect to linking separately | ||
35 | * compiled library objects into one module. So for now we won't use | ||
36 | * separate compilation ... ensuring init/exit sections work to shrink | ||
37 | * the runtime footprint, and giving us at least some parts of what | ||
38 | * a "gcc --combine ... part1.c part2.c part3.c ... " build would. | ||
39 | */ | ||
40 | #include "composite.c" | ||
41 | #include "usbstring.c" | ||
42 | #include "config.c" | ||
43 | #include "epautoconf.c" | ||
44 | |||
45 | #include "f_acm.c" | ||
46 | #include "f_obex.c" | ||
47 | #include "f_serial.c" | ||
48 | #include "u_serial.c" | ||
49 | |||
50 | /*-------------------------------------------------------------------------*/ | ||
51 | |||
33 | /* Thanks to NetChip Technologies for donating this product ID. | 52 | /* Thanks to NetChip Technologies for donating this product ID. |
34 | * | 53 | * |
35 | * DO NOT REUSE THESE IDs with a protocol-incompatible driver!! Ever!! | 54 | * DO NOT REUSE THESE IDs with a protocol-incompatible driver!! Ever!! |
@@ -38,6 +57,7 @@ | |||
38 | #define GS_VENDOR_ID 0x0525 /* NetChip */ | 57 | #define GS_VENDOR_ID 0x0525 /* NetChip */ |
39 | #define GS_PRODUCT_ID 0xa4a6 /* Linux-USB Serial Gadget */ | 58 | #define GS_PRODUCT_ID 0xa4a6 /* Linux-USB Serial Gadget */ |
40 | #define GS_CDC_PRODUCT_ID 0xa4a7 /* ... as CDC-ACM */ | 59 | #define GS_CDC_PRODUCT_ID 0xa4a7 /* ... as CDC-ACM */ |
60 | #define GS_CDC_OBEX_PRODUCT_ID 0xa4a9 /* ... as CDC-OBEX */ | ||
41 | 61 | ||
42 | /* string IDs are assigned dynamically */ | 62 | /* string IDs are assigned dynamically */ |
43 | 63 | ||
@@ -107,6 +127,10 @@ static int use_acm = true; | |||
107 | module_param(use_acm, bool, 0); | 127 | module_param(use_acm, bool, 0); |
108 | MODULE_PARM_DESC(use_acm, "Use CDC ACM, default=yes"); | 128 | MODULE_PARM_DESC(use_acm, "Use CDC ACM, default=yes"); |
109 | 129 | ||
130 | static int use_obex = false; | ||
131 | module_param(use_obex, bool, 0); | ||
132 | MODULE_PARM_DESC(use_obex, "Use CDC OBEX, default=no"); | ||
133 | |||
110 | static unsigned n_ports = 1; | 134 | static unsigned n_ports = 1; |
111 | module_param(n_ports, uint, 0); | 135 | module_param(n_ports, uint, 0); |
112 | MODULE_PARM_DESC(n_ports, "number of ports to create, default=1"); | 136 | MODULE_PARM_DESC(n_ports, "number of ports to create, default=1"); |
@@ -121,6 +145,8 @@ static int __init serial_bind_config(struct usb_configuration *c) | |||
121 | for (i = 0; i < n_ports && status == 0; i++) { | 145 | for (i = 0; i < n_ports && status == 0; i++) { |
122 | if (use_acm) | 146 | if (use_acm) |
123 | status = acm_bind_config(c, i); | 147 | status = acm_bind_config(c, i); |
148 | else if (use_obex) | ||
149 | status = obex_bind_config(c, i); | ||
124 | else | 150 | else |
125 | status = gser_bind_config(c, i); | 151 | status = gser_bind_config(c, i); |
126 | } | 152 | } |
@@ -133,7 +159,6 @@ static struct usb_configuration serial_config_driver = { | |||
133 | /* .bConfigurationValue = f(use_acm) */ | 159 | /* .bConfigurationValue = f(use_acm) */ |
134 | /* .iConfiguration = DYNAMIC */ | 160 | /* .iConfiguration = DYNAMIC */ |
135 | .bmAttributes = USB_CONFIG_ATT_SELFPOWER, | 161 | .bmAttributes = USB_CONFIG_ATT_SELFPOWER, |
136 | .bMaxPower = 1, /* 2 mA, minimal */ | ||
137 | }; | 162 | }; |
138 | 163 | ||
139 | static int __init gs_bind(struct usb_composite_dev *cdev) | 164 | static int __init gs_bind(struct usb_composite_dev *cdev) |
@@ -231,6 +256,12 @@ static int __init init(void) | |||
231 | device_desc.bDeviceClass = USB_CLASS_COMM; | 256 | device_desc.bDeviceClass = USB_CLASS_COMM; |
232 | device_desc.idProduct = | 257 | device_desc.idProduct = |
233 | __constant_cpu_to_le16(GS_CDC_PRODUCT_ID); | 258 | __constant_cpu_to_le16(GS_CDC_PRODUCT_ID); |
259 | } else if (use_obex) { | ||
260 | serial_config_driver.label = "CDC OBEX config"; | ||
261 | serial_config_driver.bConfigurationValue = 3; | ||
262 | device_desc.bDeviceClass = USB_CLASS_COMM; | ||
263 | device_desc.idProduct = | ||
264 | __constant_cpu_to_le16(GS_CDC_OBEX_PRODUCT_ID); | ||
234 | } else { | 265 | } else { |
235 | serial_config_driver.label = "Generic Serial config"; | 266 | serial_config_driver.label = "Generic Serial config"; |
236 | serial_config_driver.bConfigurationValue = 1; | 267 | serial_config_driver.bConfigurationValue = 1; |
diff --git a/drivers/usb/gadget/u_ether.c b/drivers/usb/gadget/u_ether.c index 3791e6271903..66948b72bb9b 100644 --- a/drivers/usb/gadget/u_ether.c +++ b/drivers/usb/gadget/u_ether.c | |||
@@ -52,7 +52,7 @@ | |||
52 | * this single "physical" link to be used by multiple virtual links.) | 52 | * this single "physical" link to be used by multiple virtual links.) |
53 | */ | 53 | */ |
54 | 54 | ||
55 | #define DRIVER_VERSION "29-May-2008" | 55 | #define UETH__VERSION "29-May-2008" |
56 | 56 | ||
57 | struct eth_dev { | 57 | struct eth_dev { |
58 | /* lock is held while accessing port_usb | 58 | /* lock is held while accessing port_usb |
@@ -170,7 +170,7 @@ static void eth_get_drvinfo(struct net_device *net, struct ethtool_drvinfo *p) | |||
170 | struct eth_dev *dev = netdev_priv(net); | 170 | struct eth_dev *dev = netdev_priv(net); |
171 | 171 | ||
172 | strlcpy(p->driver, "g_ether", sizeof p->driver); | 172 | strlcpy(p->driver, "g_ether", sizeof p->driver); |
173 | strlcpy(p->version, DRIVER_VERSION, sizeof p->version); | 173 | strlcpy(p->version, UETH__VERSION, sizeof p->version); |
174 | strlcpy(p->fw_version, dev->gadget->name, sizeof p->fw_version); | 174 | strlcpy(p->fw_version, dev->gadget->name, sizeof p->fw_version); |
175 | strlcpy(p->bus_info, dev_name(&dev->gadget->dev), sizeof p->bus_info); | 175 | strlcpy(p->bus_info, dev_name(&dev->gadget->dev), sizeof p->bus_info); |
176 | } | 176 | } |
@@ -873,6 +873,13 @@ struct net_device *gether_connect(struct gether *link) | |||
873 | spin_lock(&dev->lock); | 873 | spin_lock(&dev->lock); |
874 | dev->port_usb = link; | 874 | dev->port_usb = link; |
875 | link->ioport = dev; | 875 | link->ioport = dev; |
876 | if (netif_running(dev->net)) { | ||
877 | if (link->open) | ||
878 | link->open(link); | ||
879 | } else { | ||
880 | if (link->close) | ||
881 | link->close(link); | ||
882 | } | ||
876 | spin_unlock(&dev->lock); | 883 | spin_unlock(&dev->lock); |
877 | 884 | ||
878 | netif_carrier_on(dev->net); | 885 | netif_carrier_on(dev->net); |
diff --git a/drivers/usb/gadget/u_serial.h b/drivers/usb/gadget/u_serial.h index af3910d01aea..300f0ed9475d 100644 --- a/drivers/usb/gadget/u_serial.h +++ b/drivers/usb/gadget/u_serial.h | |||
@@ -62,5 +62,6 @@ void gserial_disconnect(struct gserial *); | |||
62 | /* functions are bound to configurations by a config or gadget driver */ | 62 | /* functions are bound to configurations by a config or gadget driver */ |
63 | int acm_bind_config(struct usb_configuration *c, u8 port_num); | 63 | int acm_bind_config(struct usb_configuration *c, u8 port_num); |
64 | int gser_bind_config(struct usb_configuration *c, u8 port_num); | 64 | int gser_bind_config(struct usb_configuration *c, u8 port_num); |
65 | int obex_bind_config(struct usb_configuration *c, u8 port_num); | ||
65 | 66 | ||
66 | #endif /* __U_SERIAL_H */ | 67 | #endif /* __U_SERIAL_H */ |
diff --git a/drivers/usb/gadget/zero.c b/drivers/usb/gadget/zero.c index aa0bd4f126a1..361d9659ac48 100644 --- a/drivers/usb/gadget/zero.c +++ b/drivers/usb/gadget/zero.c | |||
@@ -59,6 +59,23 @@ | |||
59 | 59 | ||
60 | /*-------------------------------------------------------------------------*/ | 60 | /*-------------------------------------------------------------------------*/ |
61 | 61 | ||
62 | /* | ||
63 | * Kbuild is not very cooperative with respect to linking separately | ||
64 | * compiled library objects into one module. So for now we won't use | ||
65 | * separate compilation ... ensuring init/exit sections work to shrink | ||
66 | * the runtime footprint, and giving us at least some parts of what | ||
67 | * a "gcc --combine ... part1.c part2.c part3.c ... " build would. | ||
68 | */ | ||
69 | #include "composite.c" | ||
70 | #include "usbstring.c" | ||
71 | #include "config.c" | ||
72 | #include "epautoconf.c" | ||
73 | |||
74 | #include "f_sourcesink.c" | ||
75 | #include "f_loopback.c" | ||
76 | |||
77 | /*-------------------------------------------------------------------------*/ | ||
78 | |||
62 | #define DRIVER_VERSION "Cinco de Mayo 2008" | 79 | #define DRIVER_VERSION "Cinco de Mayo 2008" |
63 | 80 | ||
64 | static const char longname[] = "Gadget Zero"; | 81 | static const char longname[] = "Gadget Zero"; |
diff --git a/drivers/usb/host/ehci-dbg.c b/drivers/usb/host/ehci-dbg.c index b0f8ed5a7fb9..0cb53ca8d343 100644 --- a/drivers/usb/host/ehci-dbg.c +++ b/drivers/usb/host/ehci-dbg.c | |||
@@ -358,7 +358,8 @@ struct debug_buffer { | |||
358 | struct usb_bus *bus; | 358 | struct usb_bus *bus; |
359 | struct mutex mutex; /* protect filling of buffer */ | 359 | struct mutex mutex; /* protect filling of buffer */ |
360 | size_t count; /* number of characters filled into buffer */ | 360 | size_t count; /* number of characters filled into buffer */ |
361 | char *page; | 361 | char *output_buf; |
362 | size_t alloc_size; | ||
362 | }; | 363 | }; |
363 | 364 | ||
364 | #define speed_char(info1) ({ char tmp; \ | 365 | #define speed_char(info1) ({ char tmp; \ |
@@ -488,8 +489,8 @@ static ssize_t fill_async_buffer(struct debug_buffer *buf) | |||
488 | 489 | ||
489 | hcd = bus_to_hcd(buf->bus); | 490 | hcd = bus_to_hcd(buf->bus); |
490 | ehci = hcd_to_ehci (hcd); | 491 | ehci = hcd_to_ehci (hcd); |
491 | next = buf->page; | 492 | next = buf->output_buf; |
492 | size = PAGE_SIZE; | 493 | size = buf->alloc_size; |
493 | 494 | ||
494 | *next = 0; | 495 | *next = 0; |
495 | 496 | ||
@@ -510,7 +511,7 @@ static ssize_t fill_async_buffer(struct debug_buffer *buf) | |||
510 | } | 511 | } |
511 | spin_unlock_irqrestore (&ehci->lock, flags); | 512 | spin_unlock_irqrestore (&ehci->lock, flags); |
512 | 513 | ||
513 | return strlen(buf->page); | 514 | return strlen(buf->output_buf); |
514 | } | 515 | } |
515 | 516 | ||
516 | #define DBG_SCHED_LIMIT 64 | 517 | #define DBG_SCHED_LIMIT 64 |
@@ -531,8 +532,8 @@ static ssize_t fill_periodic_buffer(struct debug_buffer *buf) | |||
531 | 532 | ||
532 | hcd = bus_to_hcd(buf->bus); | 533 | hcd = bus_to_hcd(buf->bus); |
533 | ehci = hcd_to_ehci (hcd); | 534 | ehci = hcd_to_ehci (hcd); |
534 | next = buf->page; | 535 | next = buf->output_buf; |
535 | size = PAGE_SIZE; | 536 | size = buf->alloc_size; |
536 | 537 | ||
537 | temp = scnprintf (next, size, "size = %d\n", ehci->periodic_size); | 538 | temp = scnprintf (next, size, "size = %d\n", ehci->periodic_size); |
538 | size -= temp; | 539 | size -= temp; |
@@ -568,14 +569,16 @@ static ssize_t fill_periodic_buffer(struct debug_buffer *buf) | |||
568 | for (temp = 0; temp < seen_count; temp++) { | 569 | for (temp = 0; temp < seen_count; temp++) { |
569 | if (seen [temp].ptr != p.ptr) | 570 | if (seen [temp].ptr != p.ptr) |
570 | continue; | 571 | continue; |
571 | if (p.qh->qh_next.ptr) | 572 | if (p.qh->qh_next.ptr) { |
572 | temp = scnprintf (next, size, | 573 | temp = scnprintf (next, size, |
573 | " ..."); | 574 | " ..."); |
574 | p.ptr = NULL; | 575 | size -= temp; |
576 | next += temp; | ||
577 | } | ||
575 | break; | 578 | break; |
576 | } | 579 | } |
577 | /* show more info the first time around */ | 580 | /* show more info the first time around */ |
578 | if (temp == seen_count && p.ptr) { | 581 | if (temp == seen_count) { |
579 | u32 scratch = hc32_to_cpup(ehci, | 582 | u32 scratch = hc32_to_cpup(ehci, |
580 | &p.qh->hw_info1); | 583 | &p.qh->hw_info1); |
581 | struct ehci_qtd *qtd; | 584 | struct ehci_qtd *qtd; |
@@ -649,7 +652,7 @@ static ssize_t fill_periodic_buffer(struct debug_buffer *buf) | |||
649 | spin_unlock_irqrestore (&ehci->lock, flags); | 652 | spin_unlock_irqrestore (&ehci->lock, flags); |
650 | kfree (seen); | 653 | kfree (seen); |
651 | 654 | ||
652 | return PAGE_SIZE - size; | 655 | return buf->alloc_size - size; |
653 | } | 656 | } |
654 | #undef DBG_SCHED_LIMIT | 657 | #undef DBG_SCHED_LIMIT |
655 | 658 | ||
@@ -665,14 +668,14 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf) | |||
665 | 668 | ||
666 | hcd = bus_to_hcd(buf->bus); | 669 | hcd = bus_to_hcd(buf->bus); |
667 | ehci = hcd_to_ehci (hcd); | 670 | ehci = hcd_to_ehci (hcd); |
668 | next = buf->page; | 671 | next = buf->output_buf; |
669 | size = PAGE_SIZE; | 672 | size = buf->alloc_size; |
670 | 673 | ||
671 | spin_lock_irqsave (&ehci->lock, flags); | 674 | spin_lock_irqsave (&ehci->lock, flags); |
672 | 675 | ||
673 | if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) { | 676 | if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) { |
674 | size = scnprintf (next, size, | 677 | size = scnprintf (next, size, |
675 | "bus %s, device %s (driver " DRIVER_VERSION ")\n" | 678 | "bus %s, device %s\n" |
676 | "%s\n" | 679 | "%s\n" |
677 | "SUSPENDED (no register access)\n", | 680 | "SUSPENDED (no register access)\n", |
678 | hcd->self.controller->bus->name, | 681 | hcd->self.controller->bus->name, |
@@ -684,7 +687,7 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf) | |||
684 | /* Capability Registers */ | 687 | /* Capability Registers */ |
685 | i = HC_VERSION(ehci_readl(ehci, &ehci->caps->hc_capbase)); | 688 | i = HC_VERSION(ehci_readl(ehci, &ehci->caps->hc_capbase)); |
686 | temp = scnprintf (next, size, | 689 | temp = scnprintf (next, size, |
687 | "bus %s, device %s (driver " DRIVER_VERSION ")\n" | 690 | "bus %s, device %s\n" |
688 | "%s\n" | 691 | "%s\n" |
689 | "EHCI %x.%02x, hcd state %d\n", | 692 | "EHCI %x.%02x, hcd state %d\n", |
690 | hcd->self.controller->bus->name, | 693 | hcd->self.controller->bus->name, |
@@ -808,7 +811,7 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf) | |||
808 | done: | 811 | done: |
809 | spin_unlock_irqrestore (&ehci->lock, flags); | 812 | spin_unlock_irqrestore (&ehci->lock, flags); |
810 | 813 | ||
811 | return PAGE_SIZE - size; | 814 | return buf->alloc_size - size; |
812 | } | 815 | } |
813 | 816 | ||
814 | static struct debug_buffer *alloc_buffer(struct usb_bus *bus, | 817 | static struct debug_buffer *alloc_buffer(struct usb_bus *bus, |
@@ -822,6 +825,7 @@ static struct debug_buffer *alloc_buffer(struct usb_bus *bus, | |||
822 | buf->bus = bus; | 825 | buf->bus = bus; |
823 | buf->fill_func = fill_func; | 826 | buf->fill_func = fill_func; |
824 | mutex_init(&buf->mutex); | 827 | mutex_init(&buf->mutex); |
828 | buf->alloc_size = PAGE_SIZE; | ||
825 | } | 829 | } |
826 | 830 | ||
827 | return buf; | 831 | return buf; |
@@ -831,10 +835,10 @@ static int fill_buffer(struct debug_buffer *buf) | |||
831 | { | 835 | { |
832 | int ret = 0; | 836 | int ret = 0; |
833 | 837 | ||
834 | if (!buf->page) | 838 | if (!buf->output_buf) |
835 | buf->page = (char *)get_zeroed_page(GFP_KERNEL); | 839 | buf->output_buf = (char *)vmalloc(buf->alloc_size); |
836 | 840 | ||
837 | if (!buf->page) { | 841 | if (!buf->output_buf) { |
838 | ret = -ENOMEM; | 842 | ret = -ENOMEM; |
839 | goto out; | 843 | goto out; |
840 | } | 844 | } |
@@ -867,7 +871,7 @@ static ssize_t debug_output(struct file *file, char __user *user_buf, | |||
867 | mutex_unlock(&buf->mutex); | 871 | mutex_unlock(&buf->mutex); |
868 | 872 | ||
869 | ret = simple_read_from_buffer(user_buf, len, offset, | 873 | ret = simple_read_from_buffer(user_buf, len, offset, |
870 | buf->page, buf->count); | 874 | buf->output_buf, buf->count); |
871 | 875 | ||
872 | out: | 876 | out: |
873 | return ret; | 877 | return ret; |
@@ -879,8 +883,8 @@ static int debug_close(struct inode *inode, struct file *file) | |||
879 | struct debug_buffer *buf = file->private_data; | 883 | struct debug_buffer *buf = file->private_data; |
880 | 884 | ||
881 | if (buf) { | 885 | if (buf) { |
882 | if (buf->page) | 886 | if (buf->output_buf) |
883 | free_page((unsigned long)buf->page); | 887 | vfree(buf->output_buf); |
884 | kfree(buf); | 888 | kfree(buf); |
885 | } | 889 | } |
886 | 890 | ||
@@ -895,10 +899,14 @@ static int debug_async_open(struct inode *inode, struct file *file) | |||
895 | 899 | ||
896 | static int debug_periodic_open(struct inode *inode, struct file *file) | 900 | static int debug_periodic_open(struct inode *inode, struct file *file) |
897 | { | 901 | { |
898 | file->private_data = alloc_buffer(inode->i_private, | 902 | struct debug_buffer *buf; |
899 | fill_periodic_buffer); | 903 | buf = alloc_buffer(inode->i_private, fill_periodic_buffer); |
904 | if (!buf) | ||
905 | return -ENOMEM; | ||
900 | 906 | ||
901 | return file->private_data ? 0 : -ENOMEM; | 907 | buf->alloc_size = (sizeof(void *) == 4 ? 6 : 8)*PAGE_SIZE; |
908 | file->private_data = buf; | ||
909 | return 0; | ||
902 | } | 910 | } |
903 | 911 | ||
904 | static int debug_registers_open(struct inode *inode, struct file *file) | 912 | static int debug_registers_open(struct inode *inode, struct file *file) |
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index d9d53f289caf..d343afacb0b0 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/ioport.h> | 24 | #include <linux/ioport.h> |
25 | #include <linux/sched.h> | 25 | #include <linux/sched.h> |
26 | #include <linux/slab.h> | 26 | #include <linux/slab.h> |
27 | #include <linux/vmalloc.h> | ||
27 | #include <linux/errno.h> | 28 | #include <linux/errno.h> |
28 | #include <linux/init.h> | 29 | #include <linux/init.h> |
29 | #include <linux/timer.h> | 30 | #include <linux/timer.h> |
@@ -59,7 +60,6 @@ | |||
59 | * providing early devices for those host controllers to talk to! | 60 | * providing early devices for those host controllers to talk to! |
60 | */ | 61 | */ |
61 | 62 | ||
62 | #define DRIVER_VERSION "10 Dec 2004" | ||
63 | #define DRIVER_AUTHOR "David Brownell" | 63 | #define DRIVER_AUTHOR "David Brownell" |
64 | #define DRIVER_DESC "USB 2.0 'Enhanced' Host Controller (EHCI) Driver" | 64 | #define DRIVER_DESC "USB 2.0 'Enhanced' Host Controller (EHCI) Driver" |
65 | 65 | ||
@@ -145,16 +145,6 @@ static int handshake (struct ehci_hcd *ehci, void __iomem *ptr, | |||
145 | return -ETIMEDOUT; | 145 | return -ETIMEDOUT; |
146 | } | 146 | } |
147 | 147 | ||
148 | static int handshake_on_error_set_halt(struct ehci_hcd *ehci, void __iomem *ptr, | ||
149 | u32 mask, u32 done, int usec) | ||
150 | { | ||
151 | int error = handshake(ehci, ptr, mask, done, usec); | ||
152 | if (error) | ||
153 | ehci_to_hcd(ehci)->state = HC_STATE_HALT; | ||
154 | |||
155 | return error; | ||
156 | } | ||
157 | |||
158 | /* force HC to halt state from unknown (EHCI spec section 2.3) */ | 148 | /* force HC to halt state from unknown (EHCI spec section 2.3) */ |
159 | static int ehci_halt (struct ehci_hcd *ehci) | 149 | static int ehci_halt (struct ehci_hcd *ehci) |
160 | { | 150 | { |
@@ -173,6 +163,22 @@ static int ehci_halt (struct ehci_hcd *ehci) | |||
173 | STS_HALT, STS_HALT, 16 * 125); | 163 | STS_HALT, STS_HALT, 16 * 125); |
174 | } | 164 | } |
175 | 165 | ||
166 | static int handshake_on_error_set_halt(struct ehci_hcd *ehci, void __iomem *ptr, | ||
167 | u32 mask, u32 done, int usec) | ||
168 | { | ||
169 | int error; | ||
170 | |||
171 | error = handshake(ehci, ptr, mask, done, usec); | ||
172 | if (error) { | ||
173 | ehci_halt(ehci); | ||
174 | ehci_to_hcd(ehci)->state = HC_STATE_HALT; | ||
175 | ehci_err(ehci, "force halt; handhake %p %08x %08x -> %d\n", | ||
176 | ptr, mask, done, error); | ||
177 | } | ||
178 | |||
179 | return error; | ||
180 | } | ||
181 | |||
176 | /* put TDI/ARC silicon into EHCI mode */ | 182 | /* put TDI/ARC silicon into EHCI mode */ |
177 | static void tdi_reset (struct ehci_hcd *ehci) | 183 | static void tdi_reset (struct ehci_hcd *ehci) |
178 | { | 184 | { |
@@ -614,9 +620,9 @@ static int ehci_run (struct usb_hcd *hcd) | |||
614 | 620 | ||
615 | temp = HC_VERSION(ehci_readl(ehci, &ehci->caps->hc_capbase)); | 621 | temp = HC_VERSION(ehci_readl(ehci, &ehci->caps->hc_capbase)); |
616 | ehci_info (ehci, | 622 | ehci_info (ehci, |
617 | "USB %x.%x started, EHCI %x.%02x, driver %s%s\n", | 623 | "USB %x.%x started, EHCI %x.%02x%s\n", |
618 | ((ehci->sbrn & 0xf0)>>4), (ehci->sbrn & 0x0f), | 624 | ((ehci->sbrn & 0xf0)>>4), (ehci->sbrn & 0x0f), |
619 | temp >> 8, temp & 0xff, DRIVER_VERSION, | 625 | temp >> 8, temp & 0xff, |
620 | ignore_oc ? ", overcurrent ignored" : ""); | 626 | ignore_oc ? ", overcurrent ignored" : ""); |
621 | 627 | ||
622 | ehci_writel(ehci, INTR_MASK, | 628 | ehci_writel(ehci, INTR_MASK, |
@@ -700,7 +706,7 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd) | |||
700 | pcd_status = status; | 706 | pcd_status = status; |
701 | 707 | ||
702 | /* resume root hub? */ | 708 | /* resume root hub? */ |
703 | if (!(ehci_readl(ehci, &ehci->regs->command) & CMD_RUN)) | 709 | if (!(cmd & CMD_RUN)) |
704 | usb_hcd_resume_root_hub(hcd); | 710 | usb_hcd_resume_root_hub(hcd); |
705 | 711 | ||
706 | while (i--) { | 712 | while (i--) { |
@@ -709,8 +715,11 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd) | |||
709 | 715 | ||
710 | if (pstatus & PORT_OWNER) | 716 | if (pstatus & PORT_OWNER) |
711 | continue; | 717 | continue; |
712 | if (!(pstatus & PORT_RESUME) | 718 | if (!(test_bit(i, &ehci->suspended_ports) && |
713 | || ehci->reset_done [i] != 0) | 719 | ((pstatus & PORT_RESUME) || |
720 | !(pstatus & PORT_SUSPEND)) && | ||
721 | (pstatus & PORT_PE) && | ||
722 | ehci->reset_done[i] == 0)) | ||
714 | continue; | 723 | continue; |
715 | 724 | ||
716 | /* start 20 msec resume signaling from this port, | 725 | /* start 20 msec resume signaling from this port, |
@@ -725,9 +734,8 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd) | |||
725 | 734 | ||
726 | /* PCI errors [4.15.2.4] */ | 735 | /* PCI errors [4.15.2.4] */ |
727 | if (unlikely ((status & STS_FATAL) != 0)) { | 736 | if (unlikely ((status & STS_FATAL) != 0)) { |
728 | dbg_cmd (ehci, "fatal", ehci_readl(ehci, | 737 | dbg_cmd(ehci, "fatal", cmd); |
729 | &ehci->regs->command)); | 738 | dbg_status(ehci, "fatal", status); |
730 | dbg_status (ehci, "fatal", status); | ||
731 | if (status & STS_HALT) { | 739 | if (status & STS_HALT) { |
732 | ehci_err (ehci, "fatal error\n"); | 740 | ehci_err (ehci, "fatal error\n"); |
733 | dead: | 741 | dead: |
@@ -988,9 +996,7 @@ static int ehci_get_frame (struct usb_hcd *hcd) | |||
988 | 996 | ||
989 | /*-------------------------------------------------------------------------*/ | 997 | /*-------------------------------------------------------------------------*/ |
990 | 998 | ||
991 | #define DRIVER_INFO DRIVER_VERSION " " DRIVER_DESC | 999 | MODULE_DESCRIPTION(DRIVER_DESC); |
992 | |||
993 | MODULE_DESCRIPTION (DRIVER_INFO); | ||
994 | MODULE_AUTHOR (DRIVER_AUTHOR); | 1000 | MODULE_AUTHOR (DRIVER_AUTHOR); |
995 | MODULE_LICENSE ("GPL"); | 1001 | MODULE_LICENSE ("GPL"); |
996 | 1002 | ||
@@ -1014,11 +1020,6 @@ MODULE_LICENSE ("GPL"); | |||
1014 | #define PS3_SYSTEM_BUS_DRIVER ps3_ehci_driver | 1020 | #define PS3_SYSTEM_BUS_DRIVER ps3_ehci_driver |
1015 | #endif | 1021 | #endif |
1016 | 1022 | ||
1017 | #if defined(CONFIG_440EPX) && !defined(CONFIG_PPC_MERGE) | ||
1018 | #include "ehci-ppc-soc.c" | ||
1019 | #define PLATFORM_DRIVER ehci_ppc_soc_driver | ||
1020 | #endif | ||
1021 | |||
1022 | #ifdef CONFIG_USB_EHCI_HCD_PPC_OF | 1023 | #ifdef CONFIG_USB_EHCI_HCD_PPC_OF |
1023 | #include "ehci-ppc-of.c" | 1024 | #include "ehci-ppc-of.c" |
1024 | #define OF_PLATFORM_DRIVER ehci_hcd_ppc_of_driver | 1025 | #define OF_PLATFORM_DRIVER ehci_hcd_ppc_of_driver |
@@ -1043,6 +1044,16 @@ static int __init ehci_hcd_init(void) | |||
1043 | { | 1044 | { |
1044 | int retval = 0; | 1045 | int retval = 0; |
1045 | 1046 | ||
1047 | if (usb_disabled()) | ||
1048 | return -ENODEV; | ||
1049 | |||
1050 | printk(KERN_INFO "%s: " DRIVER_DESC "\n", hcd_name); | ||
1051 | set_bit(USB_EHCI_LOADED, &usb_hcds_loaded); | ||
1052 | if (test_bit(USB_UHCI_LOADED, &usb_hcds_loaded) || | ||
1053 | test_bit(USB_OHCI_LOADED, &usb_hcds_loaded)) | ||
1054 | printk(KERN_WARNING "Warning! ehci_hcd should always be loaded" | ||
1055 | " before uhci_hcd and ohci_hcd, not after\n"); | ||
1056 | |||
1046 | pr_debug("%s: block sizes: qh %Zd qtd %Zd itd %Zd sitd %Zd\n", | 1057 | pr_debug("%s: block sizes: qh %Zd qtd %Zd itd %Zd sitd %Zd\n", |
1047 | hcd_name, | 1058 | hcd_name, |
1048 | sizeof(struct ehci_qh), sizeof(struct ehci_qtd), | 1059 | sizeof(struct ehci_qh), sizeof(struct ehci_qtd), |
@@ -1050,8 +1061,10 @@ static int __init ehci_hcd_init(void) | |||
1050 | 1061 | ||
1051 | #ifdef DEBUG | 1062 | #ifdef DEBUG |
1052 | ehci_debug_root = debugfs_create_dir("ehci", NULL); | 1063 | ehci_debug_root = debugfs_create_dir("ehci", NULL); |
1053 | if (!ehci_debug_root) | 1064 | if (!ehci_debug_root) { |
1054 | return -ENOENT; | 1065 | retval = -ENOENT; |
1066 | goto err_debug; | ||
1067 | } | ||
1055 | #endif | 1068 | #endif |
1056 | 1069 | ||
1057 | #ifdef PLATFORM_DRIVER | 1070 | #ifdef PLATFORM_DRIVER |
@@ -1099,6 +1112,8 @@ clean0: | |||
1099 | debugfs_remove(ehci_debug_root); | 1112 | debugfs_remove(ehci_debug_root); |
1100 | ehci_debug_root = NULL; | 1113 | ehci_debug_root = NULL; |
1101 | #endif | 1114 | #endif |
1115 | err_debug: | ||
1116 | clear_bit(USB_EHCI_LOADED, &usb_hcds_loaded); | ||
1102 | return retval; | 1117 | return retval; |
1103 | } | 1118 | } |
1104 | module_init(ehci_hcd_init); | 1119 | module_init(ehci_hcd_init); |
@@ -1120,6 +1135,7 @@ static void __exit ehci_hcd_cleanup(void) | |||
1120 | #ifdef DEBUG | 1135 | #ifdef DEBUG |
1121 | debugfs_remove(ehci_debug_root); | 1136 | debugfs_remove(ehci_debug_root); |
1122 | #endif | 1137 | #endif |
1138 | clear_bit(USB_EHCI_LOADED, &usb_hcds_loaded); | ||
1123 | } | 1139 | } |
1124 | module_exit(ehci_hcd_cleanup); | 1140 | module_exit(ehci_hcd_cleanup); |
1125 | 1141 | ||
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c index 740835bb8575..218f9660d7ee 100644 --- a/drivers/usb/host/ehci-hub.c +++ b/drivers/usb/host/ehci-hub.c | |||
@@ -236,10 +236,8 @@ static int ehci_bus_resume (struct usb_hcd *hcd) | |||
236 | temp = ehci_readl(ehci, &ehci->regs->port_status [i]); | 236 | temp = ehci_readl(ehci, &ehci->regs->port_status [i]); |
237 | temp &= ~(PORT_RWC_BITS | PORT_WAKE_BITS); | 237 | temp &= ~(PORT_RWC_BITS | PORT_WAKE_BITS); |
238 | if (test_bit(i, &ehci->bus_suspended) && | 238 | if (test_bit(i, &ehci->bus_suspended) && |
239 | (temp & PORT_SUSPEND)) { | 239 | (temp & PORT_SUSPEND)) |
240 | ehci->reset_done [i] = jiffies + msecs_to_jiffies (20); | ||
241 | temp |= PORT_RESUME; | 240 | temp |= PORT_RESUME; |
242 | } | ||
243 | ehci_writel(ehci, temp, &ehci->regs->port_status [i]); | 241 | ehci_writel(ehci, temp, &ehci->regs->port_status [i]); |
244 | } | 242 | } |
245 | i = HCS_N_PORTS (ehci->hcs_params); | 243 | i = HCS_N_PORTS (ehci->hcs_params); |
@@ -482,10 +480,9 @@ ehci_hub_status_data (struct usb_hcd *hcd, char *buf) | |||
482 | * controller by the user. | 480 | * controller by the user. |
483 | */ | 481 | */ |
484 | 482 | ||
485 | if ((temp & mask) != 0 | 483 | if ((temp & mask) != 0 || test_bit(i, &ehci->port_c_suspend) |
486 | || ((temp & PORT_RESUME) != 0 | 484 | || (ehci->reset_done[i] && time_after_eq( |
487 | && time_after_eq(jiffies, | 485 | jiffies, ehci->reset_done[i]))) { |
488 | ehci->reset_done[i]))) { | ||
489 | if (i < 7) | 486 | if (i < 7) |
490 | buf [0] |= 1 << (i + 1); | 487 | buf [0] |= 1 << (i + 1); |
491 | else | 488 | else |
@@ -688,6 +685,7 @@ static int ehci_hub_control ( | |||
688 | /* resume completed? */ | 685 | /* resume completed? */ |
689 | else if (time_after_eq(jiffies, | 686 | else if (time_after_eq(jiffies, |
690 | ehci->reset_done[wIndex])) { | 687 | ehci->reset_done[wIndex])) { |
688 | clear_bit(wIndex, &ehci->suspended_ports); | ||
691 | set_bit(wIndex, &ehci->port_c_suspend); | 689 | set_bit(wIndex, &ehci->port_c_suspend); |
692 | ehci->reset_done[wIndex] = 0; | 690 | ehci->reset_done[wIndex] = 0; |
693 | 691 | ||
@@ -734,6 +732,9 @@ static int ehci_hub_control ( | |||
734 | ehci_readl(ehci, status_reg)); | 732 | ehci_readl(ehci, status_reg)); |
735 | } | 733 | } |
736 | 734 | ||
735 | if (!(temp & (PORT_RESUME|PORT_RESET))) | ||
736 | ehci->reset_done[wIndex] = 0; | ||
737 | |||
737 | /* transfer dedicated ports to the companion hc */ | 738 | /* transfer dedicated ports to the companion hc */ |
738 | if ((temp & PORT_CONNECT) && | 739 | if ((temp & PORT_CONNECT) && |
739 | test_bit(wIndex, &ehci->companion_ports)) { | 740 | test_bit(wIndex, &ehci->companion_ports)) { |
@@ -757,8 +758,17 @@ static int ehci_hub_control ( | |||
757 | } | 758 | } |
758 | if (temp & PORT_PE) | 759 | if (temp & PORT_PE) |
759 | status |= 1 << USB_PORT_FEAT_ENABLE; | 760 | status |= 1 << USB_PORT_FEAT_ENABLE; |
760 | if (temp & (PORT_SUSPEND|PORT_RESUME)) | 761 | |
762 | /* maybe the port was unsuspended without our knowledge */ | ||
763 | if (temp & (PORT_SUSPEND|PORT_RESUME)) { | ||
761 | status |= 1 << USB_PORT_FEAT_SUSPEND; | 764 | status |= 1 << USB_PORT_FEAT_SUSPEND; |
765 | } else if (test_bit(wIndex, &ehci->suspended_ports)) { | ||
766 | clear_bit(wIndex, &ehci->suspended_ports); | ||
767 | ehci->reset_done[wIndex] = 0; | ||
768 | if (temp & PORT_PE) | ||
769 | set_bit(wIndex, &ehci->port_c_suspend); | ||
770 | } | ||
771 | |||
762 | if (temp & PORT_OC) | 772 | if (temp & PORT_OC) |
763 | status |= 1 << USB_PORT_FEAT_OVER_CURRENT; | 773 | status |= 1 << USB_PORT_FEAT_OVER_CURRENT; |
764 | if (temp & PORT_RESET) | 774 | if (temp & PORT_RESET) |
@@ -803,6 +813,7 @@ static int ehci_hub_control ( | |||
803 | || (temp & PORT_RESET) != 0) | 813 | || (temp & PORT_RESET) != 0) |
804 | goto error; | 814 | goto error; |
805 | ehci_writel(ehci, temp | PORT_SUSPEND, status_reg); | 815 | ehci_writel(ehci, temp | PORT_SUSPEND, status_reg); |
816 | set_bit(wIndex, &ehci->suspended_ports); | ||
806 | break; | 817 | break; |
807 | case USB_PORT_FEAT_POWER: | 818 | case USB_PORT_FEAT_POWER: |
808 | if (HCS_PPC (ehci->hcs_params)) | 819 | if (HCS_PPC (ehci->hcs_params)) |
diff --git a/drivers/usb/host/ehci-ixp4xx.c b/drivers/usb/host/ehci-ixp4xx.c index f9575c409124..9c32063a0c2f 100644 --- a/drivers/usb/host/ehci-ixp4xx.c +++ b/drivers/usb/host/ehci-ixp4xx.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * IXP4XX EHCI Host Controller Driver | 2 | * IXP4XX EHCI Host Controller Driver |
3 | * | 3 | * |
4 | * Author: Vladimir Barinov <vbarinov@ru.mvista.com> | 4 | * Author: Vladimir Barinov <vbarinov@embeddedalley.com> |
5 | * | 5 | * |
6 | * Based on "ehci-fsl.c" by Randy Vinson <rvinson@mvista.com> | 6 | * Based on "ehci-fsl.c" by Randy Vinson <rvinson@mvista.com> |
7 | * | 7 | * |
diff --git a/drivers/usb/host/ehci-ppc-soc.c b/drivers/usb/host/ehci-ppc-soc.c deleted file mode 100644 index 529590eb4037..000000000000 --- a/drivers/usb/host/ehci-ppc-soc.c +++ /dev/null | |||
@@ -1,201 +0,0 @@ | |||
1 | /* | ||
2 | * EHCI HCD (Host Controller Driver) for USB. | ||
3 | * | ||
4 | * (C) Copyright 2006-2007 Stefan Roese <sr@denx.de>, DENX Software Engineering | ||
5 | * | ||
6 | * Bus Glue for PPC On-Chip EHCI driver | ||
7 | * Tested on AMCC 440EPx | ||
8 | * | ||
9 | * Based on "ehci-au1xxx.c" by K.Boge <karsten.boge@amd.com> | ||
10 | * | ||
11 | * This file is licenced under the GPL. | ||
12 | */ | ||
13 | |||
14 | #include <linux/platform_device.h> | ||
15 | |||
16 | extern int usb_disabled(void); | ||
17 | |||
18 | /* called during probe() after chip reset completes */ | ||
19 | static int ehci_ppc_soc_setup(struct usb_hcd *hcd) | ||
20 | { | ||
21 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | ||
22 | int retval; | ||
23 | |||
24 | retval = ehci_halt(ehci); | ||
25 | if (retval) | ||
26 | return retval; | ||
27 | |||
28 | retval = ehci_init(hcd); | ||
29 | if (retval) | ||
30 | return retval; | ||
31 | |||
32 | ehci->sbrn = 0x20; | ||
33 | return ehci_reset(ehci); | ||
34 | } | ||
35 | |||
36 | /** | ||
37 | * usb_ehci_ppc_soc_probe - initialize PPC-SoC-based HCDs | ||
38 | * Context: !in_interrupt() | ||
39 | * | ||
40 | * Allocates basic resources for this USB host controller, and | ||
41 | * then invokes the start() method for the HCD associated with it | ||
42 | * through the hotplug entry's driver_data. | ||
43 | * | ||
44 | */ | ||
45 | int usb_ehci_ppc_soc_probe(const struct hc_driver *driver, | ||
46 | struct usb_hcd **hcd_out, | ||
47 | struct platform_device *dev) | ||
48 | { | ||
49 | int retval; | ||
50 | struct usb_hcd *hcd; | ||
51 | struct ehci_hcd *ehci; | ||
52 | |||
53 | if (dev->resource[1].flags != IORESOURCE_IRQ) { | ||
54 | pr_debug("resource[1] is not IORESOURCE_IRQ"); | ||
55 | retval = -ENOMEM; | ||
56 | } | ||
57 | hcd = usb_create_hcd(driver, &dev->dev, "PPC-SOC EHCI"); | ||
58 | if (!hcd) | ||
59 | return -ENOMEM; | ||
60 | hcd->rsrc_start = dev->resource[0].start; | ||
61 | hcd->rsrc_len = dev->resource[0].end - dev->resource[0].start + 1; | ||
62 | |||
63 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { | ||
64 | pr_debug("request_mem_region failed"); | ||
65 | retval = -EBUSY; | ||
66 | goto err1; | ||
67 | } | ||
68 | |||
69 | hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); | ||
70 | if (!hcd->regs) { | ||
71 | pr_debug("ioremap failed"); | ||
72 | retval = -ENOMEM; | ||
73 | goto err2; | ||
74 | } | ||
75 | |||
76 | ehci = hcd_to_ehci(hcd); | ||
77 | ehci->big_endian_mmio = 1; | ||
78 | ehci->big_endian_desc = 1; | ||
79 | ehci->caps = hcd->regs; | ||
80 | ehci->regs = hcd->regs + HC_LENGTH(ehci_readl(ehci, &ehci->caps->hc_capbase)); | ||
81 | |||
82 | /* cache this readonly data; minimize chip reads */ | ||
83 | ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params); | ||
84 | |||
85 | #if defined(CONFIG_440EPX) | ||
86 | /* | ||
87 | * 440EPx Errata USBH_3 | ||
88 | * Fix: Enable Break Memory Transfer (BMT) in INSNREG3 | ||
89 | */ | ||
90 | out_be32((void *)((ulong)(&ehci->regs->command) + 0x8c), (1 << 0)); | ||
91 | ehci_dbg(ehci, "Break Memory Transfer (BMT) has beed enabled!\n"); | ||
92 | #endif | ||
93 | |||
94 | retval = usb_add_hcd(hcd, dev->resource[1].start, IRQF_DISABLED); | ||
95 | if (retval == 0) | ||
96 | return retval; | ||
97 | |||
98 | iounmap(hcd->regs); | ||
99 | err2: | ||
100 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
101 | err1: | ||
102 | usb_put_hcd(hcd); | ||
103 | return retval; | ||
104 | } | ||
105 | |||
106 | /* may be called without controller electrically present */ | ||
107 | /* may be called with controller, bus, and devices active */ | ||
108 | |||
109 | /** | ||
110 | * usb_ehci_hcd_ppc_soc_remove - shutdown processing for PPC-SoC-based HCDs | ||
111 | * @dev: USB Host Controller being removed | ||
112 | * Context: !in_interrupt() | ||
113 | * | ||
114 | * Reverses the effect of usb_ehci_hcd_ppc_soc_probe(), first invoking | ||
115 | * the HCD's stop() method. It is always called from a thread | ||
116 | * context, normally "rmmod", "apmd", or something similar. | ||
117 | * | ||
118 | */ | ||
119 | void usb_ehci_ppc_soc_remove(struct usb_hcd *hcd, struct platform_device *dev) | ||
120 | { | ||
121 | usb_remove_hcd(hcd); | ||
122 | iounmap(hcd->regs); | ||
123 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
124 | usb_put_hcd(hcd); | ||
125 | } | ||
126 | |||
127 | static const struct hc_driver ehci_ppc_soc_hc_driver = { | ||
128 | .description = hcd_name, | ||
129 | .product_desc = "PPC-SOC EHCI", | ||
130 | .hcd_priv_size = sizeof(struct ehci_hcd), | ||
131 | |||
132 | /* | ||
133 | * generic hardware linkage | ||
134 | */ | ||
135 | .irq = ehci_irq, | ||
136 | .flags = HCD_MEMORY | HCD_USB2, | ||
137 | |||
138 | /* | ||
139 | * basic lifecycle operations | ||
140 | */ | ||
141 | .reset = ehci_ppc_soc_setup, | ||
142 | .start = ehci_run, | ||
143 | .stop = ehci_stop, | ||
144 | .shutdown = ehci_shutdown, | ||
145 | |||
146 | /* | ||
147 | * managing i/o requests and associated device resources | ||
148 | */ | ||
149 | .urb_enqueue = ehci_urb_enqueue, | ||
150 | .urb_dequeue = ehci_urb_dequeue, | ||
151 | .endpoint_disable = ehci_endpoint_disable, | ||
152 | |||
153 | /* | ||
154 | * scheduling support | ||
155 | */ | ||
156 | .get_frame_number = ehci_get_frame, | ||
157 | |||
158 | /* | ||
159 | * root hub support | ||
160 | */ | ||
161 | .hub_status_data = ehci_hub_status_data, | ||
162 | .hub_control = ehci_hub_control, | ||
163 | .bus_suspend = ehci_bus_suspend, | ||
164 | .bus_resume = ehci_bus_resume, | ||
165 | .relinquish_port = ehci_relinquish_port, | ||
166 | .port_handed_over = ehci_port_handed_over, | ||
167 | }; | ||
168 | |||
169 | static int ehci_hcd_ppc_soc_drv_probe(struct platform_device *pdev) | ||
170 | { | ||
171 | struct usb_hcd *hcd = NULL; | ||
172 | int ret; | ||
173 | |||
174 | pr_debug("In ehci_hcd_ppc_soc_drv_probe\n"); | ||
175 | |||
176 | if (usb_disabled()) | ||
177 | return -ENODEV; | ||
178 | |||
179 | /* FIXME we only want one one probe() not two */ | ||
180 | ret = usb_ehci_ppc_soc_probe(&ehci_ppc_soc_hc_driver, &hcd, pdev); | ||
181 | return ret; | ||
182 | } | ||
183 | |||
184 | static int ehci_hcd_ppc_soc_drv_remove(struct platform_device *pdev) | ||
185 | { | ||
186 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | ||
187 | |||
188 | /* FIXME we only want one one remove() not two */ | ||
189 | usb_ehci_ppc_soc_remove(hcd, pdev); | ||
190 | return 0; | ||
191 | } | ||
192 | |||
193 | MODULE_ALIAS("platform:ppc-soc-ehci"); | ||
194 | static struct platform_driver ehci_ppc_soc_driver = { | ||
195 | .probe = ehci_hcd_ppc_soc_drv_probe, | ||
196 | .remove = ehci_hcd_ppc_soc_drv_remove, | ||
197 | .shutdown = usb_hcd_platform_shutdown, | ||
198 | .driver = { | ||
199 | .name = "ppc-soc-ehci", | ||
200 | } | ||
201 | }; | ||
diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c index b7853c8bac0f..4a0c5a78b2ed 100644 --- a/drivers/usb/host/ehci-sched.c +++ b/drivers/usb/host/ehci-sched.c | |||
@@ -437,6 +437,9 @@ static int enable_periodic (struct ehci_hcd *ehci) | |||
437 | u32 cmd; | 437 | u32 cmd; |
438 | int status; | 438 | int status; |
439 | 439 | ||
440 | if (ehci->periodic_sched++) | ||
441 | return 0; | ||
442 | |||
440 | /* did clearing PSE did take effect yet? | 443 | /* did clearing PSE did take effect yet? |
441 | * takes effect only at frame boundaries... | 444 | * takes effect only at frame boundaries... |
442 | */ | 445 | */ |
@@ -461,6 +464,9 @@ static int disable_periodic (struct ehci_hcd *ehci) | |||
461 | u32 cmd; | 464 | u32 cmd; |
462 | int status; | 465 | int status; |
463 | 466 | ||
467 | if (--ehci->periodic_sched) | ||
468 | return 0; | ||
469 | |||
464 | /* did setting PSE not take effect yet? | 470 | /* did setting PSE not take effect yet? |
465 | * takes effect only at frame boundaries... | 471 | * takes effect only at frame boundaries... |
466 | */ | 472 | */ |
@@ -544,13 +550,10 @@ static int qh_link_periodic (struct ehci_hcd *ehci, struct ehci_qh *qh) | |||
544 | : (qh->usecs * 8); | 550 | : (qh->usecs * 8); |
545 | 551 | ||
546 | /* maybe enable periodic schedule processing */ | 552 | /* maybe enable periodic schedule processing */ |
547 | if (!ehci->periodic_sched++) | 553 | return enable_periodic(ehci); |
548 | return enable_periodic (ehci); | ||
549 | |||
550 | return 0; | ||
551 | } | 554 | } |
552 | 555 | ||
553 | static void qh_unlink_periodic (struct ehci_hcd *ehci, struct ehci_qh *qh) | 556 | static int qh_unlink_periodic(struct ehci_hcd *ehci, struct ehci_qh *qh) |
554 | { | 557 | { |
555 | unsigned i; | 558 | unsigned i; |
556 | unsigned period; | 559 | unsigned period; |
@@ -586,9 +589,7 @@ static void qh_unlink_periodic (struct ehci_hcd *ehci, struct ehci_qh *qh) | |||
586 | qh_put (qh); | 589 | qh_put (qh); |
587 | 590 | ||
588 | /* maybe turn off periodic schedule */ | 591 | /* maybe turn off periodic schedule */ |
589 | ehci->periodic_sched--; | 592 | return disable_periodic(ehci); |
590 | if (!ehci->periodic_sched) | ||
591 | (void) disable_periodic (ehci); | ||
592 | } | 593 | } |
593 | 594 | ||
594 | static void intr_deschedule (struct ehci_hcd *ehci, struct ehci_qh *qh) | 595 | static void intr_deschedule (struct ehci_hcd *ehci, struct ehci_qh *qh) |
@@ -1562,9 +1563,7 @@ itd_link_urb ( | |||
1562 | urb->hcpriv = NULL; | 1563 | urb->hcpriv = NULL; |
1563 | 1564 | ||
1564 | timer_action (ehci, TIMER_IO_WATCHDOG); | 1565 | timer_action (ehci, TIMER_IO_WATCHDOG); |
1565 | if (unlikely (!ehci->periodic_sched++)) | 1566 | return enable_periodic(ehci); |
1566 | return enable_periodic (ehci); | ||
1567 | return 0; | ||
1568 | } | 1567 | } |
1569 | 1568 | ||
1570 | #define ISO_ERRS (EHCI_ISOC_BUF_ERR | EHCI_ISOC_BABBLE | EHCI_ISOC_XACTERR) | 1569 | #define ISO_ERRS (EHCI_ISOC_BUF_ERR | EHCI_ISOC_BABBLE | EHCI_ISOC_XACTERR) |
@@ -1642,7 +1641,7 @@ itd_complete ( | |||
1642 | ehci_urb_done(ehci, urb, 0); | 1641 | ehci_urb_done(ehci, urb, 0); |
1643 | retval = true; | 1642 | retval = true; |
1644 | urb = NULL; | 1643 | urb = NULL; |
1645 | ehci->periodic_sched--; | 1644 | (void) disable_periodic(ehci); |
1646 | ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs--; | 1645 | ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs--; |
1647 | 1646 | ||
1648 | if (unlikely (list_empty (&stream->td_list))) { | 1647 | if (unlikely (list_empty (&stream->td_list))) { |
@@ -1951,9 +1950,7 @@ sitd_link_urb ( | |||
1951 | urb->hcpriv = NULL; | 1950 | urb->hcpriv = NULL; |
1952 | 1951 | ||
1953 | timer_action (ehci, TIMER_IO_WATCHDOG); | 1952 | timer_action (ehci, TIMER_IO_WATCHDOG); |
1954 | if (!ehci->periodic_sched++) | 1953 | return enable_periodic(ehci); |
1955 | return enable_periodic (ehci); | ||
1956 | return 0; | ||
1957 | } | 1954 | } |
1958 | 1955 | ||
1959 | /*-------------------------------------------------------------------------*/ | 1956 | /*-------------------------------------------------------------------------*/ |
@@ -2019,7 +2016,7 @@ sitd_complete ( | |||
2019 | ehci_urb_done(ehci, urb, 0); | 2016 | ehci_urb_done(ehci, urb, 0); |
2020 | retval = true; | 2017 | retval = true; |
2021 | urb = NULL; | 2018 | urb = NULL; |
2022 | ehci->periodic_sched--; | 2019 | (void) disable_periodic(ehci); |
2023 | ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs--; | 2020 | ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs--; |
2024 | 2021 | ||
2025 | if (list_empty (&stream->td_list)) { | 2022 | if (list_empty (&stream->td_list)) { |
@@ -2243,8 +2240,7 @@ restart: | |||
2243 | if (unlikely (modified)) { | 2240 | if (unlikely (modified)) { |
2244 | if (likely(ehci->periodic_sched > 0)) | 2241 | if (likely(ehci->periodic_sched > 0)) |
2245 | goto restart; | 2242 | goto restart; |
2246 | /* maybe we can short-circuit this scan! */ | 2243 | /* short-circuit this scan */ |
2247 | disable_periodic(ehci); | ||
2248 | now_uframe = clock; | 2244 | now_uframe = clock; |
2249 | break; | 2245 | break; |
2250 | } | 2246 | } |
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h index 5799298364fb..b11798d17ae5 100644 --- a/drivers/usb/host/ehci.h +++ b/drivers/usb/host/ehci.h | |||
@@ -99,6 +99,8 @@ struct ehci_hcd { /* one per controller */ | |||
99 | owned by the companion during a bus suspend */ | 99 | owned by the companion during a bus suspend */ |
100 | unsigned long port_c_suspend; /* which ports have | 100 | unsigned long port_c_suspend; /* which ports have |
101 | the change-suspend feature turned on */ | 101 | the change-suspend feature turned on */ |
102 | unsigned long suspended_ports; /* which ports are | ||
103 | suspended */ | ||
102 | 104 | ||
103 | /* per-HC memory pools (could be per-bus, but ...) */ | 105 | /* per-HC memory pools (could be per-bus, but ...) */ |
104 | struct dma_pool *qh_pool; /* qh per active urb */ | 106 | struct dma_pool *qh_pool; /* qh per active urb */ |
@@ -181,14 +183,16 @@ timer_action (struct ehci_hcd *ehci, enum ehci_timer_action action) | |||
181 | * the async ring; just the I/O watchdog. Note that if a | 183 | * the async ring; just the I/O watchdog. Note that if a |
182 | * SHRINK were pending, OFF would never be requested. | 184 | * SHRINK were pending, OFF would never be requested. |
183 | */ | 185 | */ |
184 | if (timer_pending(&ehci->watchdog) | 186 | enum ehci_timer_action oldactions = ehci->actions; |
185 | && ((BIT(TIMER_ASYNC_SHRINK) | BIT(TIMER_ASYNC_OFF)) | ||
186 | & ehci->actions)) | ||
187 | return; | ||
188 | 187 | ||
189 | if (!test_and_set_bit (action, &ehci->actions)) { | 188 | if (!test_and_set_bit (action, &ehci->actions)) { |
190 | unsigned long t; | 189 | unsigned long t; |
191 | 190 | ||
191 | if (timer_pending(&ehci->watchdog) | ||
192 | && ((BIT(TIMER_ASYNC_SHRINK) | BIT(TIMER_ASYNC_OFF)) | ||
193 | & oldactions)) | ||
194 | return; | ||
195 | |||
192 | switch (action) { | 196 | switch (action) { |
193 | case TIMER_IO_WATCHDOG: | 197 | case TIMER_IO_WATCHDOG: |
194 | t = EHCI_IO_JIFFIES; | 198 | t = EHCI_IO_JIFFIES; |
@@ -204,149 +208,13 @@ timer_action (struct ehci_hcd *ehci, enum ehci_timer_action action) | |||
204 | t = DIV_ROUND_UP(EHCI_SHRINK_FRAMES * HZ, 1000) + 1; | 208 | t = DIV_ROUND_UP(EHCI_SHRINK_FRAMES * HZ, 1000) + 1; |
205 | break; | 209 | break; |
206 | } | 210 | } |
207 | mod_timer(&ehci->watchdog, t + jiffies); | 211 | mod_timer(&ehci->watchdog, round_jiffies(t + jiffies)); |
208 | } | 212 | } |
209 | } | 213 | } |
210 | 214 | ||
211 | /*-------------------------------------------------------------------------*/ | 215 | /*-------------------------------------------------------------------------*/ |
212 | 216 | ||
213 | /* EHCI register interface, corresponds to EHCI Revision 0.95 specification */ | 217 | #include <linux/usb/ehci_def.h> |
214 | |||
215 | /* Section 2.2 Host Controller Capability Registers */ | ||
216 | struct ehci_caps { | ||
217 | /* these fields are specified as 8 and 16 bit registers, | ||
218 | * but some hosts can't perform 8 or 16 bit PCI accesses. | ||
219 | */ | ||
220 | u32 hc_capbase; | ||
221 | #define HC_LENGTH(p) (((p)>>00)&0x00ff) /* bits 7:0 */ | ||
222 | #define HC_VERSION(p) (((p)>>16)&0xffff) /* bits 31:16 */ | ||
223 | u32 hcs_params; /* HCSPARAMS - offset 0x4 */ | ||
224 | #define HCS_DEBUG_PORT(p) (((p)>>20)&0xf) /* bits 23:20, debug port? */ | ||
225 | #define HCS_INDICATOR(p) ((p)&(1 << 16)) /* true: has port indicators */ | ||
226 | #define HCS_N_CC(p) (((p)>>12)&0xf) /* bits 15:12, #companion HCs */ | ||
227 | #define HCS_N_PCC(p) (((p)>>8)&0xf) /* bits 11:8, ports per CC */ | ||
228 | #define HCS_PORTROUTED(p) ((p)&(1 << 7)) /* true: port routing */ | ||
229 | #define HCS_PPC(p) ((p)&(1 << 4)) /* true: port power control */ | ||
230 | #define HCS_N_PORTS(p) (((p)>>0)&0xf) /* bits 3:0, ports on HC */ | ||
231 | |||
232 | u32 hcc_params; /* HCCPARAMS - offset 0x8 */ | ||
233 | #define HCC_EXT_CAPS(p) (((p)>>8)&0xff) /* for pci extended caps */ | ||
234 | #define HCC_ISOC_CACHE(p) ((p)&(1 << 7)) /* true: can cache isoc frame */ | ||
235 | #define HCC_ISOC_THRES(p) (((p)>>4)&0x7) /* bits 6:4, uframes cached */ | ||
236 | #define HCC_CANPARK(p) ((p)&(1 << 2)) /* true: can park on async qh */ | ||
237 | #define HCC_PGM_FRAMELISTLEN(p) ((p)&(1 << 1)) /* true: periodic_size changes*/ | ||
238 | #define HCC_64BIT_ADDR(p) ((p)&(1)) /* true: can use 64-bit addr */ | ||
239 | u8 portroute [8]; /* nibbles for routing - offset 0xC */ | ||
240 | } __attribute__ ((packed)); | ||
241 | |||
242 | |||
243 | /* Section 2.3 Host Controller Operational Registers */ | ||
244 | struct ehci_regs { | ||
245 | |||
246 | /* USBCMD: offset 0x00 */ | ||
247 | u32 command; | ||
248 | /* 23:16 is r/w intr rate, in microframes; default "8" == 1/msec */ | ||
249 | #define CMD_PARK (1<<11) /* enable "park" on async qh */ | ||
250 | #define CMD_PARK_CNT(c) (((c)>>8)&3) /* how many transfers to park for */ | ||
251 | #define CMD_LRESET (1<<7) /* partial reset (no ports, etc) */ | ||
252 | #define CMD_IAAD (1<<6) /* "doorbell" interrupt async advance */ | ||
253 | #define CMD_ASE (1<<5) /* async schedule enable */ | ||
254 | #define CMD_PSE (1<<4) /* periodic schedule enable */ | ||
255 | /* 3:2 is periodic frame list size */ | ||
256 | #define CMD_RESET (1<<1) /* reset HC not bus */ | ||
257 | #define CMD_RUN (1<<0) /* start/stop HC */ | ||
258 | |||
259 | /* USBSTS: offset 0x04 */ | ||
260 | u32 status; | ||
261 | #define STS_ASS (1<<15) /* Async Schedule Status */ | ||
262 | #define STS_PSS (1<<14) /* Periodic Schedule Status */ | ||
263 | #define STS_RECL (1<<13) /* Reclamation */ | ||
264 | #define STS_HALT (1<<12) /* Not running (any reason) */ | ||
265 | /* some bits reserved */ | ||
266 | /* these STS_* flags are also intr_enable bits (USBINTR) */ | ||
267 | #define STS_IAA (1<<5) /* Interrupted on async advance */ | ||
268 | #define STS_FATAL (1<<4) /* such as some PCI access errors */ | ||
269 | #define STS_FLR (1<<3) /* frame list rolled over */ | ||
270 | #define STS_PCD (1<<2) /* port change detect */ | ||
271 | #define STS_ERR (1<<1) /* "error" completion (overflow, ...) */ | ||
272 | #define STS_INT (1<<0) /* "normal" completion (short, ...) */ | ||
273 | |||
274 | /* USBINTR: offset 0x08 */ | ||
275 | u32 intr_enable; | ||
276 | |||
277 | /* FRINDEX: offset 0x0C */ | ||
278 | u32 frame_index; /* current microframe number */ | ||
279 | /* CTRLDSSEGMENT: offset 0x10 */ | ||
280 | u32 segment; /* address bits 63:32 if needed */ | ||
281 | /* PERIODICLISTBASE: offset 0x14 */ | ||
282 | u32 frame_list; /* points to periodic list */ | ||
283 | /* ASYNCLISTADDR: offset 0x18 */ | ||
284 | u32 async_next; /* address of next async queue head */ | ||
285 | |||
286 | u32 reserved [9]; | ||
287 | |||
288 | /* CONFIGFLAG: offset 0x40 */ | ||
289 | u32 configured_flag; | ||
290 | #define FLAG_CF (1<<0) /* true: we'll support "high speed" */ | ||
291 | |||
292 | /* PORTSC: offset 0x44 */ | ||
293 | u32 port_status [0]; /* up to N_PORTS */ | ||
294 | /* 31:23 reserved */ | ||
295 | #define PORT_WKOC_E (1<<22) /* wake on overcurrent (enable) */ | ||
296 | #define PORT_WKDISC_E (1<<21) /* wake on disconnect (enable) */ | ||
297 | #define PORT_WKCONN_E (1<<20) /* wake on connect (enable) */ | ||
298 | /* 19:16 for port testing */ | ||
299 | #define PORT_LED_OFF (0<<14) | ||
300 | #define PORT_LED_AMBER (1<<14) | ||
301 | #define PORT_LED_GREEN (2<<14) | ||
302 | #define PORT_LED_MASK (3<<14) | ||
303 | #define PORT_OWNER (1<<13) /* true: companion hc owns this port */ | ||
304 | #define PORT_POWER (1<<12) /* true: has power (see PPC) */ | ||
305 | #define PORT_USB11(x) (((x)&(3<<10))==(1<<10)) /* USB 1.1 device */ | ||
306 | /* 11:10 for detecting lowspeed devices (reset vs release ownership) */ | ||
307 | /* 9 reserved */ | ||
308 | #define PORT_RESET (1<<8) /* reset port */ | ||
309 | #define PORT_SUSPEND (1<<7) /* suspend port */ | ||
310 | #define PORT_RESUME (1<<6) /* resume it */ | ||
311 | #define PORT_OCC (1<<5) /* over current change */ | ||
312 | #define PORT_OC (1<<4) /* over current active */ | ||
313 | #define PORT_PEC (1<<3) /* port enable change */ | ||
314 | #define PORT_PE (1<<2) /* port enable */ | ||
315 | #define PORT_CSC (1<<1) /* connect status change */ | ||
316 | #define PORT_CONNECT (1<<0) /* device connected */ | ||
317 | #define PORT_RWC_BITS (PORT_CSC | PORT_PEC | PORT_OCC) | ||
318 | } __attribute__ ((packed)); | ||
319 | |||
320 | #define USBMODE 0x68 /* USB Device mode */ | ||
321 | #define USBMODE_SDIS (1<<3) /* Stream disable */ | ||
322 | #define USBMODE_BE (1<<2) /* BE/LE endianness select */ | ||
323 | #define USBMODE_CM_HC (3<<0) /* host controller mode */ | ||
324 | #define USBMODE_CM_IDLE (0<<0) /* idle state */ | ||
325 | |||
326 | /* Appendix C, Debug port ... intended for use with special "debug devices" | ||
327 | * that can help if there's no serial console. (nonstandard enumeration.) | ||
328 | */ | ||
329 | struct ehci_dbg_port { | ||
330 | u32 control; | ||
331 | #define DBGP_OWNER (1<<30) | ||
332 | #define DBGP_ENABLED (1<<28) | ||
333 | #define DBGP_DONE (1<<16) | ||
334 | #define DBGP_INUSE (1<<10) | ||
335 | #define DBGP_ERRCODE(x) (((x)>>7)&0x07) | ||
336 | # define DBGP_ERR_BAD 1 | ||
337 | # define DBGP_ERR_SIGNAL 2 | ||
338 | #define DBGP_ERROR (1<<6) | ||
339 | #define DBGP_GO (1<<5) | ||
340 | #define DBGP_OUT (1<<4) | ||
341 | #define DBGP_LEN(x) (((x)>>0)&0x0f) | ||
342 | u32 pids; | ||
343 | #define DBGP_PID_GET(x) (((x)>>16)&0xff) | ||
344 | #define DBGP_PID_SET(data,tok) (((data)<<8)|(tok)) | ||
345 | u32 data03; | ||
346 | u32 data47; | ||
347 | u32 address; | ||
348 | #define DBGP_EPADDR(dev,ep) (((dev)<<8)|(ep)) | ||
349 | } __attribute__ ((packed)); | ||
350 | 218 | ||
351 | /*-------------------------------------------------------------------------*/ | 219 | /*-------------------------------------------------------------------------*/ |
352 | 220 | ||
@@ -740,16 +608,7 @@ ehci_port_speed(struct ehci_hcd *ehci, unsigned int portsc) | |||
740 | /* | 608 | /* |
741 | * Big-endian read/write functions are arch-specific. | 609 | * Big-endian read/write functions are arch-specific. |
742 | * Other arches can be added if/when they're needed. | 610 | * Other arches can be added if/when they're needed. |
743 | * | ||
744 | * REVISIT: arch/powerpc now has readl/writel_be, so the | ||
745 | * definition below can die once the 4xx support is | ||
746 | * finally ported over. | ||
747 | */ | 611 | */ |
748 | #if defined(CONFIG_PPC) && !defined(CONFIG_PPC_MERGE) | ||
749 | #define readl_be(addr) in_be32((__force unsigned *)addr) | ||
750 | #define writel_be(val, addr) out_be32((__force unsigned *)addr, val) | ||
751 | #endif | ||
752 | |||
753 | #if defined(CONFIG_ARM) && defined(CONFIG_ARCH_IXP4XX) | 612 | #if defined(CONFIG_ARM) && defined(CONFIG_ARCH_IXP4XX) |
754 | #define readl_be(addr) __raw_readl((__force unsigned *)addr) | 613 | #define readl_be(addr) __raw_readl((__force unsigned *)addr) |
755 | #define writel_be(val, addr) __raw_writel(val, (__force unsigned *)addr) | 614 | #define writel_be(val, addr) __raw_writel(val, (__force unsigned *)addr) |
diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c index ce1ca0ba0515..4dda31b26892 100644 --- a/drivers/usb/host/isp116x-hcd.c +++ b/drivers/usb/host/isp116x-hcd.c | |||
@@ -1562,11 +1562,12 @@ static int __devinit isp116x_probe(struct platform_device *pdev) | |||
1562 | { | 1562 | { |
1563 | struct usb_hcd *hcd; | 1563 | struct usb_hcd *hcd; |
1564 | struct isp116x *isp116x; | 1564 | struct isp116x *isp116x; |
1565 | struct resource *addr, *data; | 1565 | struct resource *addr, *data, *ires; |
1566 | void __iomem *addr_reg; | 1566 | void __iomem *addr_reg; |
1567 | void __iomem *data_reg; | 1567 | void __iomem *data_reg; |
1568 | int irq; | 1568 | int irq; |
1569 | int ret = 0; | 1569 | int ret = 0; |
1570 | unsigned long irqflags; | ||
1570 | 1571 | ||
1571 | if (pdev->num_resources < 3) { | 1572 | if (pdev->num_resources < 3) { |
1572 | ret = -ENODEV; | 1573 | ret = -ENODEV; |
@@ -1575,12 +1576,16 @@ static int __devinit isp116x_probe(struct platform_device *pdev) | |||
1575 | 1576 | ||
1576 | data = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 1577 | data = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
1577 | addr = platform_get_resource(pdev, IORESOURCE_MEM, 1); | 1578 | addr = platform_get_resource(pdev, IORESOURCE_MEM, 1); |
1578 | irq = platform_get_irq(pdev, 0); | 1579 | ires = platform_get_resource(pdev, IORESOURCE_IRQ, 0); |
1579 | if (!addr || !data || irq < 0) { | 1580 | |
1581 | if (!addr || !data || !ires) { | ||
1580 | ret = -ENODEV; | 1582 | ret = -ENODEV; |
1581 | goto err1; | 1583 | goto err1; |
1582 | } | 1584 | } |
1583 | 1585 | ||
1586 | irq = ires->start; | ||
1587 | irqflags = ires->flags & IRQF_TRIGGER_MASK; | ||
1588 | |||
1584 | if (pdev->dev.dma_mask) { | 1589 | if (pdev->dev.dma_mask) { |
1585 | DBG("DMA not supported\n"); | 1590 | DBG("DMA not supported\n"); |
1586 | ret = -EINVAL; | 1591 | ret = -EINVAL; |
@@ -1634,7 +1639,7 @@ static int __devinit isp116x_probe(struct platform_device *pdev) | |||
1634 | goto err6; | 1639 | goto err6; |
1635 | } | 1640 | } |
1636 | 1641 | ||
1637 | ret = usb_add_hcd(hcd, irq, IRQF_DISABLED); | 1642 | ret = usb_add_hcd(hcd, irq, irqflags | IRQF_DISABLED); |
1638 | if (ret) | 1643 | if (ret) |
1639 | goto err6; | 1644 | goto err6; |
1640 | 1645 | ||
diff --git a/drivers/usb/host/isp1760-hcd.c b/drivers/usb/host/isp1760-hcd.c index d22a84f86a33..8017f1cf78e2 100644 --- a/drivers/usb/host/isp1760-hcd.c +++ b/drivers/usb/host/isp1760-hcd.c | |||
@@ -988,7 +988,7 @@ static void do_atl_int(struct usb_hcd *usb_hcd) | |||
988 | /* | 988 | /* |
989 | * write bank1 address twice to ensure the 90ns delay (time | 989 | * write bank1 address twice to ensure the 90ns delay (time |
990 | * between BANK0 write and the priv_read_copy() call is at | 990 | * between BANK0 write and the priv_read_copy() call is at |
991 | * least 3*t_WHWL + 2*t_w11 = 3*25ns + 2*17ns = 92ns) | 991 | * least 3*t_WHWL + 2*t_w11 = 3*25ns + 2*17ns = 109ns) |
992 | */ | 992 | */ |
993 | isp1760_writel(payload + ISP_BANK(1), usb_hcd->regs + | 993 | isp1760_writel(payload + ISP_BANK(1), usb_hcd->regs + |
994 | HC_MEMORY_REG); | 994 | HC_MEMORY_REG); |
diff --git a/drivers/usb/host/isp1760-if.c b/drivers/usb/host/isp1760-if.c index 051ef7b6bdc6..af849f596135 100644 --- a/drivers/usb/host/isp1760-if.c +++ b/drivers/usb/host/isp1760-if.c | |||
@@ -218,7 +218,7 @@ static int __devinit isp1761_pci_probe(struct pci_dev *dev, | |||
218 | * and reading back and checking the contents are same or not | 218 | * and reading back and checking the contents are same or not |
219 | */ | 219 | */ |
220 | if (reg_data != 0xFACE) { | 220 | if (reg_data != 0xFACE) { |
221 | err("scratch register mismatch %x", reg_data); | 221 | dev_err(&dev->dev, "scratch register mismatch %x\n", reg_data); |
222 | goto clean; | 222 | goto clean; |
223 | } | 223 | } |
224 | 224 | ||
@@ -232,9 +232,10 @@ static int __devinit isp1761_pci_probe(struct pci_dev *dev, | |||
232 | hcd = isp1760_register(pci_mem_phy0, length, dev->irq, | 232 | hcd = isp1760_register(pci_mem_phy0, length, dev->irq, |
233 | IRQF_SHARED | IRQF_DISABLED, &dev->dev, dev_name(&dev->dev), | 233 | IRQF_SHARED | IRQF_DISABLED, &dev->dev, dev_name(&dev->dev), |
234 | devflags); | 234 | devflags); |
235 | pci_set_drvdata(dev, hcd); | 235 | if (!IS_ERR(hcd)) { |
236 | if (!hcd) | 236 | pci_set_drvdata(dev, hcd); |
237 | return 0; | 237 | return 0; |
238 | } | ||
238 | clean: | 239 | clean: |
239 | status = -ENODEV; | 240 | status = -ENODEV; |
240 | iounmap(iobase); | 241 | iounmap(iobase); |
diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c index 6db7a2889e66..4ed228a89943 100644 --- a/drivers/usb/host/ohci-at91.c +++ b/drivers/usb/host/ohci-at91.c | |||
@@ -260,7 +260,6 @@ static const struct hc_driver ohci_at91_hc_driver = { | |||
260 | */ | 260 | */ |
261 | .hub_status_data = ohci_hub_status_data, | 261 | .hub_status_data = ohci_hub_status_data, |
262 | .hub_control = ohci_hub_control, | 262 | .hub_control = ohci_hub_control, |
263 | .hub_irq_enable = ohci_rhsc_enable, | ||
264 | #ifdef CONFIG_PM | 263 | #ifdef CONFIG_PM |
265 | .bus_suspend = ohci_bus_suspend, | 264 | .bus_suspend = ohci_bus_suspend, |
266 | .bus_resume = ohci_bus_resume, | 265 | .bus_resume = ohci_bus_resume, |
diff --git a/drivers/usb/host/ohci-au1xxx.c b/drivers/usb/host/ohci-au1xxx.c index c0948008fe3d..2ac4e022a13f 100644 --- a/drivers/usb/host/ohci-au1xxx.c +++ b/drivers/usb/host/ohci-au1xxx.c | |||
@@ -163,7 +163,6 @@ static const struct hc_driver ohci_au1xxx_hc_driver = { | |||
163 | */ | 163 | */ |
164 | .hub_status_data = ohci_hub_status_data, | 164 | .hub_status_data = ohci_hub_status_data, |
165 | .hub_control = ohci_hub_control, | 165 | .hub_control = ohci_hub_control, |
166 | .hub_irq_enable = ohci_rhsc_enable, | ||
167 | #ifdef CONFIG_PM | 166 | #ifdef CONFIG_PM |
168 | .bus_suspend = ohci_bus_suspend, | 167 | .bus_suspend = ohci_bus_suspend, |
169 | .bus_resume = ohci_bus_resume, | 168 | .bus_resume = ohci_bus_resume, |
diff --git a/drivers/usb/host/ohci-dbg.c b/drivers/usb/host/ohci-dbg.c index 7cef1d2f7ccc..d3269656aa4d 100644 --- a/drivers/usb/host/ohci-dbg.c +++ b/drivers/usb/host/ohci-dbg.c | |||
@@ -649,7 +649,7 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf) | |||
649 | ohci_dbg_sw (ohci, &next, &size, | 649 | ohci_dbg_sw (ohci, &next, &size, |
650 | "bus %s, device %s\n" | 650 | "bus %s, device %s\n" |
651 | "%s\n" | 651 | "%s\n" |
652 | "%s version " DRIVER_VERSION "\n", | 652 | "%s\n", |
653 | hcd->self.controller->bus->name, | 653 | hcd->self.controller->bus->name, |
654 | dev_name(hcd->self.controller), | 654 | dev_name(hcd->self.controller), |
655 | hcd->product_desc, | 655 | hcd->product_desc, |
diff --git a/drivers/usb/host/ohci-ep93xx.c b/drivers/usb/host/ohci-ep93xx.c index cb0b506f8259..fb3055f084b5 100644 --- a/drivers/usb/host/ohci-ep93xx.c +++ b/drivers/usb/host/ohci-ep93xx.c | |||
@@ -134,7 +134,6 @@ static struct hc_driver ohci_ep93xx_hc_driver = { | |||
134 | .get_frame_number = ohci_get_frame, | 134 | .get_frame_number = ohci_get_frame, |
135 | .hub_status_data = ohci_hub_status_data, | 135 | .hub_status_data = ohci_hub_status_data, |
136 | .hub_control = ohci_hub_control, | 136 | .hub_control = ohci_hub_control, |
137 | .hub_irq_enable = ohci_rhsc_enable, | ||
138 | #ifdef CONFIG_PM | 137 | #ifdef CONFIG_PM |
139 | .bus_suspend = ohci_bus_suspend, | 138 | .bus_suspend = ohci_bus_suspend, |
140 | .bus_resume = ohci_bus_resume, | 139 | .bus_resume = ohci_bus_resume, |
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index 89901962cbfd..8647dab0d7f9 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c | |||
@@ -46,7 +46,6 @@ | |||
46 | 46 | ||
47 | #include "../core/hcd.h" | 47 | #include "../core/hcd.h" |
48 | 48 | ||
49 | #define DRIVER_VERSION "2006 August 04" | ||
50 | #define DRIVER_AUTHOR "Roman Weissgaerber, David Brownell" | 49 | #define DRIVER_AUTHOR "Roman Weissgaerber, David Brownell" |
51 | #define DRIVER_DESC "USB 1.1 'Open' Host Controller (OHCI) Driver" | 50 | #define DRIVER_DESC "USB 1.1 'Open' Host Controller (OHCI) Driver" |
52 | 51 | ||
@@ -984,10 +983,8 @@ static int ohci_restart (struct ohci_hcd *ohci) | |||
984 | 983 | ||
985 | /*-------------------------------------------------------------------------*/ | 984 | /*-------------------------------------------------------------------------*/ |
986 | 985 | ||
987 | #define DRIVER_INFO DRIVER_VERSION " " DRIVER_DESC | ||
988 | |||
989 | MODULE_AUTHOR (DRIVER_AUTHOR); | 986 | MODULE_AUTHOR (DRIVER_AUTHOR); |
990 | MODULE_DESCRIPTION (DRIVER_INFO); | 987 | MODULE_DESCRIPTION(DRIVER_DESC); |
991 | MODULE_LICENSE ("GPL"); | 988 | MODULE_LICENSE ("GPL"); |
992 | 989 | ||
993 | #ifdef CONFIG_PCI | 990 | #ifdef CONFIG_PCI |
@@ -1095,9 +1092,10 @@ static int __init ohci_hcd_mod_init(void) | |||
1095 | if (usb_disabled()) | 1092 | if (usb_disabled()) |
1096 | return -ENODEV; | 1093 | return -ENODEV; |
1097 | 1094 | ||
1098 | printk (KERN_DEBUG "%s: " DRIVER_INFO "\n", hcd_name); | 1095 | printk(KERN_INFO "%s: " DRIVER_DESC "\n", hcd_name); |
1099 | pr_debug ("%s: block sizes: ed %Zd td %Zd\n", hcd_name, | 1096 | pr_debug ("%s: block sizes: ed %Zd td %Zd\n", hcd_name, |
1100 | sizeof (struct ed), sizeof (struct td)); | 1097 | sizeof (struct ed), sizeof (struct td)); |
1098 | set_bit(USB_OHCI_LOADED, &usb_hcds_loaded); | ||
1101 | 1099 | ||
1102 | #ifdef DEBUG | 1100 | #ifdef DEBUG |
1103 | ohci_debug_root = debugfs_create_dir("ohci", NULL); | 1101 | ohci_debug_root = debugfs_create_dir("ohci", NULL); |
@@ -1184,6 +1182,7 @@ static int __init ohci_hcd_mod_init(void) | |||
1184 | error_debug: | 1182 | error_debug: |
1185 | #endif | 1183 | #endif |
1186 | 1184 | ||
1185 | clear_bit(USB_OHCI_LOADED, &usb_hcds_loaded); | ||
1187 | return retval; | 1186 | return retval; |
1188 | } | 1187 | } |
1189 | module_init(ohci_hcd_mod_init); | 1188 | module_init(ohci_hcd_mod_init); |
@@ -1214,6 +1213,7 @@ static void __exit ohci_hcd_mod_exit(void) | |||
1214 | #ifdef DEBUG | 1213 | #ifdef DEBUG |
1215 | debugfs_remove(ohci_debug_root); | 1214 | debugfs_remove(ohci_debug_root); |
1216 | #endif | 1215 | #endif |
1216 | clear_bit(USB_OHCI_LOADED, &usb_hcds_loaded); | ||
1217 | } | 1217 | } |
1218 | module_exit(ohci_hcd_mod_exit); | 1218 | module_exit(ohci_hcd_mod_exit); |
1219 | 1219 | ||
diff --git a/drivers/usb/host/ohci-hub.c b/drivers/usb/host/ohci-hub.c index 439beb784f3e..32bbce9718f0 100644 --- a/drivers/usb/host/ohci-hub.c +++ b/drivers/usb/host/ohci-hub.c | |||
@@ -36,18 +36,6 @@ | |||
36 | 36 | ||
37 | /*-------------------------------------------------------------------------*/ | 37 | /*-------------------------------------------------------------------------*/ |
38 | 38 | ||
39 | /* hcd->hub_irq_enable() */ | ||
40 | static void ohci_rhsc_enable (struct usb_hcd *hcd) | ||
41 | { | ||
42 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); | ||
43 | |||
44 | spin_lock_irq(&ohci->lock); | ||
45 | if (!ohci->autostop) | ||
46 | del_timer(&hcd->rh_timer); /* Prevent next poll */ | ||
47 | ohci_writel(ohci, OHCI_INTR_RHSC, &ohci->regs->intrenable); | ||
48 | spin_unlock_irq(&ohci->lock); | ||
49 | } | ||
50 | |||
51 | #define OHCI_SCHED_ENABLES \ | 39 | #define OHCI_SCHED_ENABLES \ |
52 | (OHCI_CTRL_CLE|OHCI_CTRL_BLE|OHCI_CTRL_PLE|OHCI_CTRL_IE) | 40 | (OHCI_CTRL_CLE|OHCI_CTRL_BLE|OHCI_CTRL_PLE|OHCI_CTRL_IE) |
53 | 41 | ||
@@ -371,21 +359,34 @@ static void ohci_finish_controller_resume(struct usb_hcd *hcd) | |||
371 | 359 | ||
372 | /* Carry out polling-, autostop-, and autoresume-related state changes */ | 360 | /* Carry out polling-, autostop-, and autoresume-related state changes */ |
373 | static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed, | 361 | static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed, |
374 | int any_connected) | 362 | int any_connected, int rhsc_status) |
375 | { | 363 | { |
376 | int poll_rh = 1; | 364 | int poll_rh = 1; |
365 | int rhsc_enable; | ||
377 | 366 | ||
378 | switch (ohci->hc_control & OHCI_CTRL_HCFS) { | 367 | /* Some broken controllers never turn off RHCS in the interrupt |
368 | * status register. For their sake we won't re-enable RHSC | ||
369 | * interrupts if the interrupt bit is already active. | ||
370 | */ | ||
371 | rhsc_enable = ohci_readl(ohci, &ohci->regs->intrenable) & | ||
372 | OHCI_INTR_RHSC; | ||
379 | 373 | ||
374 | switch (ohci->hc_control & OHCI_CTRL_HCFS) { | ||
380 | case OHCI_USB_OPER: | 375 | case OHCI_USB_OPER: |
381 | /* keep on polling until we know a device is connected | 376 | /* If no status changes are pending, enable RHSC interrupts. */ |
382 | * and RHSC is enabled */ | 377 | if (!rhsc_enable && !rhsc_status && !changed) { |
378 | rhsc_enable = OHCI_INTR_RHSC; | ||
379 | ohci_writel(ohci, rhsc_enable, &ohci->regs->intrenable); | ||
380 | } | ||
381 | |||
382 | /* Keep on polling until we know a device is connected | ||
383 | * and RHSC is enabled, or until we autostop. | ||
384 | */ | ||
383 | if (!ohci->autostop) { | 385 | if (!ohci->autostop) { |
384 | if (any_connected || | 386 | if (any_connected || |
385 | !device_may_wakeup(&ohci_to_hcd(ohci) | 387 | !device_may_wakeup(&ohci_to_hcd(ohci) |
386 | ->self.root_hub->dev)) { | 388 | ->self.root_hub->dev)) { |
387 | if (ohci_readl(ohci, &ohci->regs->intrenable) & | 389 | if (rhsc_enable) |
388 | OHCI_INTR_RHSC) | ||
389 | poll_rh = 0; | 390 | poll_rh = 0; |
390 | } else { | 391 | } else { |
391 | ohci->autostop = 1; | 392 | ohci->autostop = 1; |
@@ -404,21 +405,39 @@ static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed, | |||
404 | && !(ohci->hc_control & | 405 | && !(ohci->hc_control & |
405 | OHCI_SCHED_ENABLES)) { | 406 | OHCI_SCHED_ENABLES)) { |
406 | ohci_rh_suspend(ohci, 1); | 407 | ohci_rh_suspend(ohci, 1); |
408 | if (rhsc_enable) | ||
409 | poll_rh = 0; | ||
407 | } | 410 | } |
408 | } | 411 | } |
409 | break; | 412 | break; |
410 | 413 | ||
411 | /* if there is a port change, autostart or ask to be resumed */ | ||
412 | case OHCI_USB_SUSPEND: | 414 | case OHCI_USB_SUSPEND: |
413 | case OHCI_USB_RESUME: | 415 | case OHCI_USB_RESUME: |
416 | /* if there is a port change, autostart or ask to be resumed */ | ||
414 | if (changed) { | 417 | if (changed) { |
415 | if (ohci->autostop) | 418 | if (ohci->autostop) |
416 | ohci_rh_resume(ohci); | 419 | ohci_rh_resume(ohci); |
417 | else | 420 | else |
418 | usb_hcd_resume_root_hub(ohci_to_hcd(ohci)); | 421 | usb_hcd_resume_root_hub(ohci_to_hcd(ohci)); |
419 | } else { | 422 | |
420 | /* everything is idle, no need for polling */ | 423 | /* If remote wakeup is disabled, stop polling */ |
424 | } else if (!ohci->autostop && | ||
425 | !ohci_to_hcd(ohci)->self.root_hub-> | ||
426 | do_remote_wakeup) { | ||
421 | poll_rh = 0; | 427 | poll_rh = 0; |
428 | |||
429 | } else { | ||
430 | /* If no status changes are pending, | ||
431 | * enable RHSC interrupts | ||
432 | */ | ||
433 | if (!rhsc_enable && !rhsc_status) { | ||
434 | rhsc_enable = OHCI_INTR_RHSC; | ||
435 | ohci_writel(ohci, rhsc_enable, | ||
436 | &ohci->regs->intrenable); | ||
437 | } | ||
438 | /* Keep polling until RHSC is enabled */ | ||
439 | if (rhsc_enable) | ||
440 | poll_rh = 0; | ||
422 | } | 441 | } |
423 | break; | 442 | break; |
424 | } | 443 | } |
@@ -436,14 +455,22 @@ static inline int ohci_rh_resume(struct ohci_hcd *ohci) | |||
436 | * autostop isn't used when CONFIG_PM is turned off. | 455 | * autostop isn't used when CONFIG_PM is turned off. |
437 | */ | 456 | */ |
438 | static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed, | 457 | static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed, |
439 | int any_connected) | 458 | int any_connected, int rhsc_status) |
440 | { | 459 | { |
441 | int poll_rh = 1; | 460 | /* If RHSC is enabled, don't poll */ |
442 | |||
443 | /* keep on polling until RHSC is enabled */ | ||
444 | if (ohci_readl(ohci, &ohci->regs->intrenable) & OHCI_INTR_RHSC) | 461 | if (ohci_readl(ohci, &ohci->regs->intrenable) & OHCI_INTR_RHSC) |
445 | poll_rh = 0; | 462 | return 0; |
446 | return poll_rh; | 463 | |
464 | /* If status changes are pending, continue polling. | ||
465 | * Conversely, if no status changes are pending but the RHSC | ||
466 | * status bit was set, then RHSC may be broken so continue polling. | ||
467 | */ | ||
468 | if (changed || rhsc_status) | ||
469 | return 1; | ||
470 | |||
471 | /* It's safe to re-enable RHSC interrupts */ | ||
472 | ohci_writel(ohci, OHCI_INTR_RHSC, &ohci->regs->intrenable); | ||
473 | return 0; | ||
447 | } | 474 | } |
448 | 475 | ||
449 | #endif /* CONFIG_PM */ | 476 | #endif /* CONFIG_PM */ |
@@ -458,6 +485,7 @@ ohci_hub_status_data (struct usb_hcd *hcd, char *buf) | |||
458 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); | 485 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); |
459 | int i, changed = 0, length = 1; | 486 | int i, changed = 0, length = 1; |
460 | int any_connected = 0; | 487 | int any_connected = 0; |
488 | int rhsc_status; | ||
461 | unsigned long flags; | 489 | unsigned long flags; |
462 | 490 | ||
463 | spin_lock_irqsave (&ohci->lock, flags); | 491 | spin_lock_irqsave (&ohci->lock, flags); |
@@ -483,12 +511,10 @@ ohci_hub_status_data (struct usb_hcd *hcd, char *buf) | |||
483 | length++; | 511 | length++; |
484 | } | 512 | } |
485 | 513 | ||
486 | /* Some broken controllers never turn off RHCS in the interrupt | 514 | /* Clear the RHSC status flag before reading the port statuses */ |
487 | * status register. For their sake we won't re-enable RHSC | 515 | ohci_writel(ohci, OHCI_INTR_RHSC, &ohci->regs->intrstatus); |
488 | * interrupts if the flag is already set. | 516 | rhsc_status = ohci_readl(ohci, &ohci->regs->intrstatus) & |
489 | */ | 517 | OHCI_INTR_RHSC; |
490 | if (ohci_readl(ohci, &ohci->regs->intrstatus) & OHCI_INTR_RHSC) | ||
491 | changed = 1; | ||
492 | 518 | ||
493 | /* look at each port */ | 519 | /* look at each port */ |
494 | for (i = 0; i < ohci->num_ports; i++) { | 520 | for (i = 0; i < ohci->num_ports; i++) { |
@@ -508,7 +534,7 @@ ohci_hub_status_data (struct usb_hcd *hcd, char *buf) | |||
508 | } | 534 | } |
509 | 535 | ||
510 | hcd->poll_rh = ohci_root_hub_state_changes(ohci, changed, | 536 | hcd->poll_rh = ohci_root_hub_state_changes(ohci, changed, |
511 | any_connected); | 537 | any_connected, rhsc_status); |
512 | 538 | ||
513 | done: | 539 | done: |
514 | spin_unlock_irqrestore (&ohci->lock, flags); | 540 | spin_unlock_irqrestore (&ohci->lock, flags); |
diff --git a/drivers/usb/host/ohci-lh7a404.c b/drivers/usb/host/ohci-lh7a404.c index 9e31d440d115..de42283149c7 100644 --- a/drivers/usb/host/ohci-lh7a404.c +++ b/drivers/usb/host/ohci-lh7a404.c | |||
@@ -193,7 +193,6 @@ static const struct hc_driver ohci_lh7a404_hc_driver = { | |||
193 | */ | 193 | */ |
194 | .hub_status_data = ohci_hub_status_data, | 194 | .hub_status_data = ohci_hub_status_data, |
195 | .hub_control = ohci_hub_control, | 195 | .hub_control = ohci_hub_control, |
196 | .hub_irq_enable = ohci_rhsc_enable, | ||
197 | #ifdef CONFIG_PM | 196 | #ifdef CONFIG_PM |
198 | .bus_suspend = ohci_bus_suspend, | 197 | .bus_suspend = ohci_bus_suspend, |
199 | .bus_resume = ohci_bus_resume, | 198 | .bus_resume = ohci_bus_resume, |
diff --git a/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c index 3d532b709670..91697bdb399f 100644 --- a/drivers/usb/host/ohci-omap.c +++ b/drivers/usb/host/ohci-omap.c | |||
@@ -208,7 +208,7 @@ static int ohci_omap_init(struct usb_hcd *hcd) | |||
208 | if (cpu_is_omap16xx()) | 208 | if (cpu_is_omap16xx()) |
209 | ocpi_enable(); | 209 | ocpi_enable(); |
210 | 210 | ||
211 | #ifdef CONFIG_ARCH_OMAP_OTG | 211 | #ifdef CONFIG_USB_OTG |
212 | if (need_transceiver) { | 212 | if (need_transceiver) { |
213 | ohci->transceiver = otg_get_transceiver(); | 213 | ohci->transceiver = otg_get_transceiver(); |
214 | if (ohci->transceiver) { | 214 | if (ohci->transceiver) { |
@@ -231,7 +231,7 @@ static int ohci_omap_init(struct usb_hcd *hcd) | |||
231 | 231 | ||
232 | omap_ohci_clock_power(1); | 232 | omap_ohci_clock_power(1); |
233 | 233 | ||
234 | if (cpu_is_omap1510()) { | 234 | if (cpu_is_omap15xx()) { |
235 | omap_1510_local_bus_power(1); | 235 | omap_1510_local_bus_power(1); |
236 | omap_1510_local_bus_init(); | 236 | omap_1510_local_bus_init(); |
237 | } | 237 | } |
@@ -319,7 +319,7 @@ static int usb_hcd_omap_probe (const struct hc_driver *driver, | |||
319 | if (IS_ERR(usb_host_ck)) | 319 | if (IS_ERR(usb_host_ck)) |
320 | return PTR_ERR(usb_host_ck); | 320 | return PTR_ERR(usb_host_ck); |
321 | 321 | ||
322 | if (!cpu_is_omap1510()) | 322 | if (!cpu_is_omap15xx()) |
323 | usb_dc_ck = clk_get(0, "usb_dc_ck"); | 323 | usb_dc_ck = clk_get(0, "usb_dc_ck"); |
324 | else | 324 | else |
325 | usb_dc_ck = clk_get(0, "lb_ck"); | 325 | usb_dc_ck = clk_get(0, "lb_ck"); |
@@ -344,7 +344,12 @@ static int usb_hcd_omap_probe (const struct hc_driver *driver, | |||
344 | goto err1; | 344 | goto err1; |
345 | } | 345 | } |
346 | 346 | ||
347 | hcd->regs = (void __iomem *) (int) IO_ADDRESS(hcd->rsrc_start); | 347 | hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); |
348 | if (!hcd->regs) { | ||
349 | dev_err(&pdev->dev, "can't ioremap OHCI HCD\n"); | ||
350 | retval = -ENOMEM; | ||
351 | goto err2; | ||
352 | } | ||
348 | 353 | ||
349 | ohci = hcd_to_ohci(hcd); | 354 | ohci = hcd_to_ohci(hcd); |
350 | ohci_hcd_init(ohci); | 355 | ohci_hcd_init(ohci); |
@@ -355,11 +360,11 @@ static int usb_hcd_omap_probe (const struct hc_driver *driver, | |||
355 | irq = platform_get_irq(pdev, 0); | 360 | irq = platform_get_irq(pdev, 0); |
356 | if (irq < 0) { | 361 | if (irq < 0) { |
357 | retval = -ENXIO; | 362 | retval = -ENXIO; |
358 | goto err2; | 363 | goto err3; |
359 | } | 364 | } |
360 | retval = usb_add_hcd(hcd, irq, IRQF_DISABLED); | 365 | retval = usb_add_hcd(hcd, irq, IRQF_DISABLED); |
361 | if (retval) | 366 | if (retval) |
362 | goto err2; | 367 | goto err3; |
363 | 368 | ||
364 | host_initialized = 1; | 369 | host_initialized = 1; |
365 | 370 | ||
@@ -367,6 +372,8 @@ static int usb_hcd_omap_probe (const struct hc_driver *driver, | |||
367 | omap_ohci_clock_power(0); | 372 | omap_ohci_clock_power(0); |
368 | 373 | ||
369 | return 0; | 374 | return 0; |
375 | err3: | ||
376 | iounmap(hcd->regs); | ||
370 | err2: | 377 | err2: |
371 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | 378 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); |
372 | err1: | 379 | err1: |
@@ -401,6 +408,7 @@ usb_hcd_omap_remove (struct usb_hcd *hcd, struct platform_device *pdev) | |||
401 | } | 408 | } |
402 | if (machine_is_omap_osk()) | 409 | if (machine_is_omap_osk()) |
403 | omap_free_gpio(9); | 410 | omap_free_gpio(9); |
411 | iounmap(hcd->regs); | ||
404 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | 412 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); |
405 | usb_put_hcd(hcd); | 413 | usb_put_hcd(hcd); |
406 | clk_put(usb_dc_ck); | 414 | clk_put(usb_dc_ck); |
@@ -470,7 +478,6 @@ static const struct hc_driver ohci_omap_hc_driver = { | |||
470 | */ | 478 | */ |
471 | .hub_status_data = ohci_hub_status_data, | 479 | .hub_status_data = ohci_hub_status_data, |
472 | .hub_control = ohci_hub_control, | 480 | .hub_control = ohci_hub_control, |
473 | .hub_irq_enable = ohci_rhsc_enable, | ||
474 | #ifdef CONFIG_PM | 481 | #ifdef CONFIG_PM |
475 | .bus_suspend = ohci_bus_suspend, | 482 | .bus_suspend = ohci_bus_suspend, |
476 | .bus_resume = ohci_bus_resume, | 483 | .bus_resume = ohci_bus_resume, |
diff --git a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c index 083e8df0a817..a9c2ae36c7ad 100644 --- a/drivers/usb/host/ohci-pci.c +++ b/drivers/usb/host/ohci-pci.c | |||
@@ -459,7 +459,6 @@ static const struct hc_driver ohci_pci_hc_driver = { | |||
459 | */ | 459 | */ |
460 | .hub_status_data = ohci_hub_status_data, | 460 | .hub_status_data = ohci_hub_status_data, |
461 | .hub_control = ohci_hub_control, | 461 | .hub_control = ohci_hub_control, |
462 | .hub_irq_enable = ohci_rhsc_enable, | ||
463 | #ifdef CONFIG_PM | 462 | #ifdef CONFIG_PM |
464 | .bus_suspend = ohci_bus_suspend, | 463 | .bus_suspend = ohci_bus_suspend, |
465 | .bus_resume = ohci_bus_resume, | 464 | .bus_resume = ohci_bus_resume, |
diff --git a/drivers/usb/host/ohci-pnx4008.c b/drivers/usb/host/ohci-pnx4008.c index b02cd0761977..e306ca6aef3d 100644 --- a/drivers/usb/host/ohci-pnx4008.c +++ b/drivers/usb/host/ohci-pnx4008.c | |||
@@ -277,7 +277,6 @@ static const struct hc_driver ohci_pnx4008_hc_driver = { | |||
277 | */ | 277 | */ |
278 | .hub_status_data = ohci_hub_status_data, | 278 | .hub_status_data = ohci_hub_status_data, |
279 | .hub_control = ohci_hub_control, | 279 | .hub_control = ohci_hub_control, |
280 | .hub_irq_enable = ohci_rhsc_enable, | ||
281 | #ifdef CONFIG_PM | 280 | #ifdef CONFIG_PM |
282 | .bus_suspend = ohci_bus_suspend, | 281 | .bus_suspend = ohci_bus_suspend, |
283 | .bus_resume = ohci_bus_resume, | 282 | .bus_resume = ohci_bus_resume, |
@@ -332,7 +331,7 @@ static int __devinit usb_hcd_pnx4008_probe(struct platform_device *pdev) | |||
332 | 331 | ||
333 | int ret = 0, irq; | 332 | int ret = 0, irq; |
334 | 333 | ||
335 | dev_dbg(&pdev->dev, "%s: " DRIVER_INFO " (pnx4008)\n", hcd_name); | 334 | dev_dbg(&pdev->dev, "%s: " DRIVER_DESC " (pnx4008)\n", hcd_name); |
336 | if (usb_disabled()) { | 335 | if (usb_disabled()) { |
337 | err("USB is disabled"); | 336 | err("USB is disabled"); |
338 | ret = -ENODEV; | 337 | ret = -ENODEV; |
diff --git a/drivers/usb/host/ohci-pnx8550.c b/drivers/usb/host/ohci-pnx8550.c index 605d59cba28e..28467e288a93 100644 --- a/drivers/usb/host/ohci-pnx8550.c +++ b/drivers/usb/host/ohci-pnx8550.c | |||
@@ -201,7 +201,6 @@ static const struct hc_driver ohci_pnx8550_hc_driver = { | |||
201 | */ | 201 | */ |
202 | .hub_status_data = ohci_hub_status_data, | 202 | .hub_status_data = ohci_hub_status_data, |
203 | .hub_control = ohci_hub_control, | 203 | .hub_control = ohci_hub_control, |
204 | .hub_irq_enable = ohci_rhsc_enable, | ||
205 | #ifdef CONFIG_PM | 204 | #ifdef CONFIG_PM |
206 | .bus_suspend = ohci_bus_suspend, | 205 | .bus_suspend = ohci_bus_suspend, |
207 | .bus_resume = ohci_bus_resume, | 206 | .bus_resume = ohci_bus_resume, |
diff --git a/drivers/usb/host/ohci-ppc-of.c b/drivers/usb/host/ohci-ppc-of.c index 91e6e101a4cc..7ac53264ead3 100644 --- a/drivers/usb/host/ohci-ppc-of.c +++ b/drivers/usb/host/ohci-ppc-of.c | |||
@@ -72,7 +72,6 @@ static const struct hc_driver ohci_ppc_of_hc_driver = { | |||
72 | */ | 72 | */ |
73 | .hub_status_data = ohci_hub_status_data, | 73 | .hub_status_data = ohci_hub_status_data, |
74 | .hub_control = ohci_hub_control, | 74 | .hub_control = ohci_hub_control, |
75 | .hub_irq_enable = ohci_rhsc_enable, | ||
76 | #ifdef CONFIG_PM | 75 | #ifdef CONFIG_PM |
77 | .bus_suspend = ohci_bus_suspend, | 76 | .bus_suspend = ohci_bus_suspend, |
78 | .bus_resume = ohci_bus_resume, | 77 | .bus_resume = ohci_bus_resume, |
diff --git a/drivers/usb/host/ohci-ppc-soc.c b/drivers/usb/host/ohci-ppc-soc.c index 523c30125577..cd3398b675b2 100644 --- a/drivers/usb/host/ohci-ppc-soc.c +++ b/drivers/usb/host/ohci-ppc-soc.c | |||
@@ -172,7 +172,6 @@ static const struct hc_driver ohci_ppc_soc_hc_driver = { | |||
172 | */ | 172 | */ |
173 | .hub_status_data = ohci_hub_status_data, | 173 | .hub_status_data = ohci_hub_status_data, |
174 | .hub_control = ohci_hub_control, | 174 | .hub_control = ohci_hub_control, |
175 | .hub_irq_enable = ohci_rhsc_enable, | ||
176 | #ifdef CONFIG_PM | 175 | #ifdef CONFIG_PM |
177 | .bus_suspend = ohci_bus_suspend, | 176 | .bus_suspend = ohci_bus_suspend, |
178 | .bus_resume = ohci_bus_resume, | 177 | .bus_resume = ohci_bus_resume, |
diff --git a/drivers/usb/host/ohci-ps3.c b/drivers/usb/host/ohci-ps3.c index 55c95647f008..2089d8a46c4b 100644 --- a/drivers/usb/host/ohci-ps3.c +++ b/drivers/usb/host/ohci-ps3.c | |||
@@ -68,7 +68,6 @@ static const struct hc_driver ps3_ohci_hc_driver = { | |||
68 | .get_frame_number = ohci_get_frame, | 68 | .get_frame_number = ohci_get_frame, |
69 | .hub_status_data = ohci_hub_status_data, | 69 | .hub_status_data = ohci_hub_status_data, |
70 | .hub_control = ohci_hub_control, | 70 | .hub_control = ohci_hub_control, |
71 | .hub_irq_enable = ohci_rhsc_enable, | ||
72 | .start_port_reset = ohci_start_port_reset, | 71 | .start_port_reset = ohci_start_port_reset, |
73 | #if defined(CONFIG_PM) | 72 | #if defined(CONFIG_PM) |
74 | .bus_suspend = ohci_bus_suspend, | 73 | .bus_suspend = ohci_bus_suspend, |
diff --git a/drivers/usb/host/ohci-pxa27x.c b/drivers/usb/host/ohci-pxa27x.c index 8c9c4849db6e..e294d430733b 100644 --- a/drivers/usb/host/ohci-pxa27x.c +++ b/drivers/usb/host/ohci-pxa27x.c | |||
@@ -23,17 +23,90 @@ | |||
23 | #include <linux/signal.h> | 23 | #include <linux/signal.h> |
24 | #include <linux/platform_device.h> | 24 | #include <linux/platform_device.h> |
25 | #include <linux/clk.h> | 25 | #include <linux/clk.h> |
26 | |||
27 | #include <mach/hardware.h> | ||
28 | #include <mach/pxa-regs.h> | ||
29 | #include <mach/pxa2xx-regs.h> /* FIXME: for PSSR */ | ||
30 | #include <mach/ohci.h> | 26 | #include <mach/ohci.h> |
31 | 27 | ||
28 | /* | ||
29 | * UHC: USB Host Controller (OHCI-like) register definitions | ||
30 | */ | ||
31 | #define UHCREV (0x0000) /* UHC HCI Spec Revision */ | ||
32 | #define UHCHCON (0x0004) /* UHC Host Control Register */ | ||
33 | #define UHCCOMS (0x0008) /* UHC Command Status Register */ | ||
34 | #define UHCINTS (0x000C) /* UHC Interrupt Status Register */ | ||
35 | #define UHCINTE (0x0010) /* UHC Interrupt Enable */ | ||
36 | #define UHCINTD (0x0014) /* UHC Interrupt Disable */ | ||
37 | #define UHCHCCA (0x0018) /* UHC Host Controller Comm. Area */ | ||
38 | #define UHCPCED (0x001C) /* UHC Period Current Endpt Descr */ | ||
39 | #define UHCCHED (0x0020) /* UHC Control Head Endpt Descr */ | ||
40 | #define UHCCCED (0x0024) /* UHC Control Current Endpt Descr */ | ||
41 | #define UHCBHED (0x0028) /* UHC Bulk Head Endpt Descr */ | ||
42 | #define UHCBCED (0x002C) /* UHC Bulk Current Endpt Descr */ | ||
43 | #define UHCDHEAD (0x0030) /* UHC Done Head */ | ||
44 | #define UHCFMI (0x0034) /* UHC Frame Interval */ | ||
45 | #define UHCFMR (0x0038) /* UHC Frame Remaining */ | ||
46 | #define UHCFMN (0x003C) /* UHC Frame Number */ | ||
47 | #define UHCPERS (0x0040) /* UHC Periodic Start */ | ||
48 | #define UHCLS (0x0044) /* UHC Low Speed Threshold */ | ||
49 | |||
50 | #define UHCRHDA (0x0048) /* UHC Root Hub Descriptor A */ | ||
51 | #define UHCRHDA_NOCP (1 << 12) /* No over current protection */ | ||
52 | #define UHCRHDA_OCPM (1 << 11) /* Over Current Protection Mode */ | ||
53 | #define UHCRHDA_POTPGT(x) \ | ||
54 | (((x) & 0xff) << 24) /* Power On To Power Good Time */ | ||
55 | |||
56 | #define UHCRHDB (0x004C) /* UHC Root Hub Descriptor B */ | ||
57 | #define UHCRHS (0x0050) /* UHC Root Hub Status */ | ||
58 | #define UHCRHPS1 (0x0054) /* UHC Root Hub Port 1 Status */ | ||
59 | #define UHCRHPS2 (0x0058) /* UHC Root Hub Port 2 Status */ | ||
60 | #define UHCRHPS3 (0x005C) /* UHC Root Hub Port 3 Status */ | ||
61 | |||
62 | #define UHCSTAT (0x0060) /* UHC Status Register */ | ||
63 | #define UHCSTAT_UPS3 (1 << 16) /* USB Power Sense Port3 */ | ||
64 | #define UHCSTAT_SBMAI (1 << 15) /* System Bus Master Abort Interrupt*/ | ||
65 | #define UHCSTAT_SBTAI (1 << 14) /* System Bus Target Abort Interrupt*/ | ||
66 | #define UHCSTAT_UPRI (1 << 13) /* USB Port Resume Interrupt */ | ||
67 | #define UHCSTAT_UPS2 (1 << 12) /* USB Power Sense Port 2 */ | ||
68 | #define UHCSTAT_UPS1 (1 << 11) /* USB Power Sense Port 1 */ | ||
69 | #define UHCSTAT_HTA (1 << 10) /* HCI Target Abort */ | ||
70 | #define UHCSTAT_HBA (1 << 8) /* HCI Buffer Active */ | ||
71 | #define UHCSTAT_RWUE (1 << 7) /* HCI Remote Wake Up Event */ | ||
72 | |||
73 | #define UHCHR (0x0064) /* UHC Reset Register */ | ||
74 | #define UHCHR_SSEP3 (1 << 11) /* Sleep Standby Enable for Port3 */ | ||
75 | #define UHCHR_SSEP2 (1 << 10) /* Sleep Standby Enable for Port2 */ | ||
76 | #define UHCHR_SSEP1 (1 << 9) /* Sleep Standby Enable for Port1 */ | ||
77 | #define UHCHR_PCPL (1 << 7) /* Power control polarity low */ | ||
78 | #define UHCHR_PSPL (1 << 6) /* Power sense polarity low */ | ||
79 | #define UHCHR_SSE (1 << 5) /* Sleep Standby Enable */ | ||
80 | #define UHCHR_UIT (1 << 4) /* USB Interrupt Test */ | ||
81 | #define UHCHR_SSDC (1 << 3) /* Simulation Scale Down Clock */ | ||
82 | #define UHCHR_CGR (1 << 2) /* Clock Generation Reset */ | ||
83 | #define UHCHR_FHR (1 << 1) /* Force Host Controller Reset */ | ||
84 | #define UHCHR_FSBIR (1 << 0) /* Force System Bus Iface Reset */ | ||
85 | |||
86 | #define UHCHIE (0x0068) /* UHC Interrupt Enable Register*/ | ||
87 | #define UHCHIE_UPS3IE (1 << 14) /* Power Sense Port3 IntEn */ | ||
88 | #define UHCHIE_UPRIE (1 << 13) /* Port Resume IntEn */ | ||
89 | #define UHCHIE_UPS2IE (1 << 12) /* Power Sense Port2 IntEn */ | ||
90 | #define UHCHIE_UPS1IE (1 << 11) /* Power Sense Port1 IntEn */ | ||
91 | #define UHCHIE_TAIE (1 << 10) /* HCI Interface Transfer Abort | ||
92 | Interrupt Enable*/ | ||
93 | #define UHCHIE_HBAIE (1 << 8) /* HCI Buffer Active IntEn */ | ||
94 | #define UHCHIE_RWIE (1 << 7) /* Remote Wake-up IntEn */ | ||
95 | |||
96 | #define UHCHIT (0x006C) /* UHC Interrupt Test register */ | ||
97 | |||
32 | #define PXA_UHC_MAX_PORTNUM 3 | 98 | #define PXA_UHC_MAX_PORTNUM 3 |
33 | 99 | ||
34 | #define UHCRHPS(x) __REG2( 0x4C000050, (x)<<2 ) | 100 | struct pxa27x_ohci { |
101 | /* must be 1st member here for hcd_to_ohci() to work */ | ||
102 | struct ohci_hcd ohci; | ||
103 | |||
104 | struct device *dev; | ||
105 | struct clk *clk; | ||
106 | void __iomem *mmio_base; | ||
107 | }; | ||
35 | 108 | ||
36 | static struct clk *usb_clk; | 109 | #define to_pxa27x_ohci(hcd) (struct pxa27x_ohci *)hcd_to_ohci(hcd) |
37 | 110 | ||
38 | /* | 111 | /* |
39 | PMM_NPS_MODE -- PMM Non-power switching mode | 112 | PMM_NPS_MODE -- PMM Non-power switching mode |
@@ -45,30 +118,35 @@ static struct clk *usb_clk; | |||
45 | PMM_PERPORT_MODE -- PMM per port switching mode | 118 | PMM_PERPORT_MODE -- PMM per port switching mode |
46 | Ports are powered individually. | 119 | Ports are powered individually. |
47 | */ | 120 | */ |
48 | static int pxa27x_ohci_select_pmm( int mode ) | 121 | static int pxa27x_ohci_select_pmm(struct pxa27x_ohci *ohci, int mode) |
49 | { | 122 | { |
50 | switch ( mode ) { | 123 | uint32_t uhcrhda = __raw_readl(ohci->mmio_base + UHCRHDA); |
124 | uint32_t uhcrhdb = __raw_readl(ohci->mmio_base + UHCRHDB); | ||
125 | |||
126 | switch (mode) { | ||
51 | case PMM_NPS_MODE: | 127 | case PMM_NPS_MODE: |
52 | UHCRHDA |= RH_A_NPS; | 128 | uhcrhda |= RH_A_NPS; |
53 | break; | 129 | break; |
54 | case PMM_GLOBAL_MODE: | 130 | case PMM_GLOBAL_MODE: |
55 | UHCRHDA &= ~(RH_A_NPS & RH_A_PSM); | 131 | uhcrhda &= ~(RH_A_NPS & RH_A_PSM); |
56 | break; | 132 | break; |
57 | case PMM_PERPORT_MODE: | 133 | case PMM_PERPORT_MODE: |
58 | UHCRHDA &= ~(RH_A_NPS); | 134 | uhcrhda &= ~(RH_A_NPS); |
59 | UHCRHDA |= RH_A_PSM; | 135 | uhcrhda |= RH_A_PSM; |
60 | 136 | ||
61 | /* Set port power control mask bits, only 3 ports. */ | 137 | /* Set port power control mask bits, only 3 ports. */ |
62 | UHCRHDB |= (0x7<<17); | 138 | uhcrhdb |= (0x7<<17); |
63 | break; | 139 | break; |
64 | default: | 140 | default: |
65 | printk( KERN_ERR | 141 | printk( KERN_ERR |
66 | "Invalid mode %d, set to non-power switch mode.\n", | 142 | "Invalid mode %d, set to non-power switch mode.\n", |
67 | mode ); | 143 | mode ); |
68 | 144 | ||
69 | UHCRHDA |= RH_A_NPS; | 145 | uhcrhda |= RH_A_NPS; |
70 | } | 146 | } |
71 | 147 | ||
148 | __raw_writel(uhcrhda, ohci->mmio_base + UHCRHDA); | ||
149 | __raw_writel(uhcrhdb, ohci->mmio_base + UHCRHDB); | ||
72 | return 0; | 150 | return 0; |
73 | } | 151 | } |
74 | 152 | ||
@@ -76,57 +154,110 @@ extern int usb_disabled(void); | |||
76 | 154 | ||
77 | /*-------------------------------------------------------------------------*/ | 155 | /*-------------------------------------------------------------------------*/ |
78 | 156 | ||
79 | static int pxa27x_start_hc(struct device *dev) | 157 | static inline void pxa27x_setup_hc(struct pxa27x_ohci *ohci, |
158 | struct pxaohci_platform_data *inf) | ||
159 | { | ||
160 | uint32_t uhchr = __raw_readl(ohci->mmio_base + UHCHR); | ||
161 | uint32_t uhcrhda = __raw_readl(ohci->mmio_base + UHCRHDA); | ||
162 | |||
163 | if (inf->flags & ENABLE_PORT1) | ||
164 | uhchr &= ~UHCHR_SSEP1; | ||
165 | |||
166 | if (inf->flags & ENABLE_PORT2) | ||
167 | uhchr &= ~UHCHR_SSEP2; | ||
168 | |||
169 | if (inf->flags & ENABLE_PORT3) | ||
170 | uhchr &= ~UHCHR_SSEP3; | ||
171 | |||
172 | if (inf->flags & POWER_CONTROL_LOW) | ||
173 | uhchr |= UHCHR_PCPL; | ||
174 | |||
175 | if (inf->flags & POWER_SENSE_LOW) | ||
176 | uhchr |= UHCHR_PSPL; | ||
177 | |||
178 | if (inf->flags & NO_OC_PROTECTION) | ||
179 | uhcrhda |= UHCRHDA_NOCP; | ||
180 | |||
181 | if (inf->flags & OC_MODE_PERPORT) | ||
182 | uhcrhda |= UHCRHDA_OCPM; | ||
183 | |||
184 | if (inf->power_on_delay) { | ||
185 | uhcrhda &= ~UHCRHDA_POTPGT(0xff); | ||
186 | uhcrhda |= UHCRHDA_POTPGT(inf->power_on_delay / 2); | ||
187 | } | ||
188 | |||
189 | __raw_writel(uhchr, ohci->mmio_base + UHCHR); | ||
190 | __raw_writel(uhcrhda, ohci->mmio_base + UHCRHDA); | ||
191 | } | ||
192 | |||
193 | static inline void pxa27x_reset_hc(struct pxa27x_ohci *ohci) | ||
194 | { | ||
195 | uint32_t uhchr = __raw_readl(ohci->mmio_base + UHCHR); | ||
196 | |||
197 | __raw_writel(uhchr | UHCHR_FHR, ohci->mmio_base + UHCHR); | ||
198 | udelay(11); | ||
199 | __raw_writel(uhchr & ~UHCHR_FHR, ohci->mmio_base + UHCHR); | ||
200 | } | ||
201 | |||
202 | #ifdef CONFIG_CPU_PXA27x | ||
203 | extern void pxa27x_clear_otgph(void); | ||
204 | #else | ||
205 | #define pxa27x_clear_otgph() do {} while (0) | ||
206 | #endif | ||
207 | |||
208 | static int pxa27x_start_hc(struct pxa27x_ohci *ohci, struct device *dev) | ||
80 | { | 209 | { |
81 | int retval = 0; | 210 | int retval = 0; |
82 | struct pxaohci_platform_data *inf; | 211 | struct pxaohci_platform_data *inf; |
212 | uint32_t uhchr; | ||
83 | 213 | ||
84 | inf = dev->platform_data; | 214 | inf = dev->platform_data; |
85 | 215 | ||
86 | clk_enable(usb_clk); | 216 | clk_enable(ohci->clk); |
87 | 217 | ||
88 | UHCHR |= UHCHR_FHR; | 218 | pxa27x_reset_hc(ohci); |
89 | udelay(11); | 219 | |
90 | UHCHR &= ~UHCHR_FHR; | 220 | uhchr = __raw_readl(ohci->mmio_base + UHCHR) | UHCHR_FSBIR; |
221 | __raw_writel(uhchr, ohci->mmio_base + UHCHR); | ||
91 | 222 | ||
92 | UHCHR |= UHCHR_FSBIR; | 223 | while (__raw_readl(ohci->mmio_base + UHCHR) & UHCHR_FSBIR) |
93 | while (UHCHR & UHCHR_FSBIR) | ||
94 | cpu_relax(); | 224 | cpu_relax(); |
95 | 225 | ||
226 | pxa27x_setup_hc(ohci, inf); | ||
227 | |||
96 | if (inf->init) | 228 | if (inf->init) |
97 | retval = inf->init(dev); | 229 | retval = inf->init(dev); |
98 | 230 | ||
99 | if (retval < 0) | 231 | if (retval < 0) |
100 | return retval; | 232 | return retval; |
101 | 233 | ||
102 | UHCHR &= ~UHCHR_SSE; | 234 | uhchr = __raw_readl(ohci->mmio_base + UHCHR) & ~UHCHR_SSE; |
103 | 235 | __raw_writel(uhchr, ohci->mmio_base + UHCHR); | |
104 | UHCHIE = (UHCHIE_UPRIE | UHCHIE_RWIE); | 236 | __raw_writel(UHCHIE_UPRIE | UHCHIE_RWIE, ohci->mmio_base + UHCHIE); |
105 | 237 | ||
106 | /* Clear any OTG Pin Hold */ | 238 | /* Clear any OTG Pin Hold */ |
107 | if (cpu_is_pxa27x() && (PSSR & PSSR_OTGPH)) | 239 | pxa27x_clear_otgph(); |
108 | PSSR |= PSSR_OTGPH; | ||
109 | |||
110 | return 0; | 240 | return 0; |
111 | } | 241 | } |
112 | 242 | ||
113 | static void pxa27x_stop_hc(struct device *dev) | 243 | static void pxa27x_stop_hc(struct pxa27x_ohci *ohci, struct device *dev) |
114 | { | 244 | { |
115 | struct pxaohci_platform_data *inf; | 245 | struct pxaohci_platform_data *inf; |
246 | uint32_t uhccoms; | ||
116 | 247 | ||
117 | inf = dev->platform_data; | 248 | inf = dev->platform_data; |
118 | 249 | ||
119 | if (inf->exit) | 250 | if (inf->exit) |
120 | inf->exit(dev); | 251 | inf->exit(dev); |
121 | 252 | ||
122 | UHCHR |= UHCHR_FHR; | 253 | pxa27x_reset_hc(ohci); |
123 | udelay(11); | ||
124 | UHCHR &= ~UHCHR_FHR; | ||
125 | 254 | ||
126 | UHCCOMS |= 1; | 255 | /* Host Controller Reset */ |
256 | uhccoms = __raw_readl(ohci->mmio_base + UHCCOMS) | 0x01; | ||
257 | __raw_writel(uhccoms, ohci->mmio_base + UHCCOMS); | ||
127 | udelay(10); | 258 | udelay(10); |
128 | 259 | ||
129 | clk_disable(usb_clk); | 260 | clk_disable(ohci->clk); |
130 | } | 261 | } |
131 | 262 | ||
132 | 263 | ||
@@ -147,18 +278,22 @@ static void pxa27x_stop_hc(struct device *dev) | |||
147 | */ | 278 | */ |
148 | int usb_hcd_pxa27x_probe (const struct hc_driver *driver, struct platform_device *pdev) | 279 | int usb_hcd_pxa27x_probe (const struct hc_driver *driver, struct platform_device *pdev) |
149 | { | 280 | { |
150 | int retval; | 281 | int retval, irq; |
151 | struct usb_hcd *hcd; | 282 | struct usb_hcd *hcd; |
152 | struct pxaohci_platform_data *inf; | 283 | struct pxaohci_platform_data *inf; |
284 | struct pxa27x_ohci *ohci; | ||
285 | struct resource *r; | ||
286 | struct clk *usb_clk; | ||
153 | 287 | ||
154 | inf = pdev->dev.platform_data; | 288 | inf = pdev->dev.platform_data; |
155 | 289 | ||
156 | if (!inf) | 290 | if (!inf) |
157 | return -ENODEV; | 291 | return -ENODEV; |
158 | 292 | ||
159 | if (pdev->resource[1].flags != IORESOURCE_IRQ) { | 293 | irq = platform_get_irq(pdev, 0); |
160 | pr_debug ("resource[1] is not IORESOURCE_IRQ"); | 294 | if (irq < 0) { |
161 | return -ENOMEM; | 295 | pr_err("no resource of IORESOURCE_IRQ"); |
296 | return -ENXIO; | ||
162 | } | 297 | } |
163 | 298 | ||
164 | usb_clk = clk_get(&pdev->dev, "USBCLK"); | 299 | usb_clk = clk_get(&pdev->dev, "USBCLK"); |
@@ -168,8 +303,16 @@ int usb_hcd_pxa27x_probe (const struct hc_driver *driver, struct platform_device | |||
168 | hcd = usb_create_hcd (driver, &pdev->dev, "pxa27x"); | 303 | hcd = usb_create_hcd (driver, &pdev->dev, "pxa27x"); |
169 | if (!hcd) | 304 | if (!hcd) |
170 | return -ENOMEM; | 305 | return -ENOMEM; |
171 | hcd->rsrc_start = pdev->resource[0].start; | 306 | |
172 | hcd->rsrc_len = pdev->resource[0].end - pdev->resource[0].start + 1; | 307 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
308 | if (!r) { | ||
309 | pr_err("no resource of IORESOURCE_MEM"); | ||
310 | retval = -ENXIO; | ||
311 | goto err1; | ||
312 | } | ||
313 | |||
314 | hcd->rsrc_start = r->start; | ||
315 | hcd->rsrc_len = resource_size(r); | ||
173 | 316 | ||
174 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { | 317 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { |
175 | pr_debug("request_mem_region failed"); | 318 | pr_debug("request_mem_region failed"); |
@@ -184,24 +327,30 @@ int usb_hcd_pxa27x_probe (const struct hc_driver *driver, struct platform_device | |||
184 | goto err2; | 327 | goto err2; |
185 | } | 328 | } |
186 | 329 | ||
187 | if ((retval = pxa27x_start_hc(&pdev->dev)) < 0) { | 330 | /* initialize "struct pxa27x_ohci" */ |
331 | ohci = (struct pxa27x_ohci *)hcd_to_ohci(hcd); | ||
332 | ohci->dev = &pdev->dev; | ||
333 | ohci->clk = usb_clk; | ||
334 | ohci->mmio_base = (void __iomem *)hcd->regs; | ||
335 | |||
336 | if ((retval = pxa27x_start_hc(ohci, &pdev->dev)) < 0) { | ||
188 | pr_debug("pxa27x_start_hc failed"); | 337 | pr_debug("pxa27x_start_hc failed"); |
189 | goto err3; | 338 | goto err3; |
190 | } | 339 | } |
191 | 340 | ||
192 | /* Select Power Management Mode */ | 341 | /* Select Power Management Mode */ |
193 | pxa27x_ohci_select_pmm(inf->port_mode); | 342 | pxa27x_ohci_select_pmm(ohci, inf->port_mode); |
194 | 343 | ||
195 | if (inf->power_budget) | 344 | if (inf->power_budget) |
196 | hcd->power_budget = inf->power_budget; | 345 | hcd->power_budget = inf->power_budget; |
197 | 346 | ||
198 | ohci_hcd_init(hcd_to_ohci(hcd)); | 347 | ohci_hcd_init(hcd_to_ohci(hcd)); |
199 | 348 | ||
200 | retval = usb_add_hcd(hcd, pdev->resource[1].start, IRQF_DISABLED); | 349 | retval = usb_add_hcd(hcd, irq, IRQF_DISABLED); |
201 | if (retval == 0) | 350 | if (retval == 0) |
202 | return retval; | 351 | return retval; |
203 | 352 | ||
204 | pxa27x_stop_hc(&pdev->dev); | 353 | pxa27x_stop_hc(ohci, &pdev->dev); |
205 | err3: | 354 | err3: |
206 | iounmap(hcd->regs); | 355 | iounmap(hcd->regs); |
207 | err2: | 356 | err2: |
@@ -228,12 +377,14 @@ int usb_hcd_pxa27x_probe (const struct hc_driver *driver, struct platform_device | |||
228 | */ | 377 | */ |
229 | void usb_hcd_pxa27x_remove (struct usb_hcd *hcd, struct platform_device *pdev) | 378 | void usb_hcd_pxa27x_remove (struct usb_hcd *hcd, struct platform_device *pdev) |
230 | { | 379 | { |
380 | struct pxa27x_ohci *ohci = to_pxa27x_ohci(hcd); | ||
381 | |||
231 | usb_remove_hcd(hcd); | 382 | usb_remove_hcd(hcd); |
232 | pxa27x_stop_hc(&pdev->dev); | 383 | pxa27x_stop_hc(ohci, &pdev->dev); |
233 | iounmap(hcd->regs); | 384 | iounmap(hcd->regs); |
234 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | 385 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); |
235 | usb_put_hcd(hcd); | 386 | usb_put_hcd(hcd); |
236 | clk_put(usb_clk); | 387 | clk_put(ohci->clk); |
237 | } | 388 | } |
238 | 389 | ||
239 | /*-------------------------------------------------------------------------*/ | 390 | /*-------------------------------------------------------------------------*/ |
@@ -266,7 +417,7 @@ ohci_pxa27x_start (struct usb_hcd *hcd) | |||
266 | static const struct hc_driver ohci_pxa27x_hc_driver = { | 417 | static const struct hc_driver ohci_pxa27x_hc_driver = { |
267 | .description = hcd_name, | 418 | .description = hcd_name, |
268 | .product_desc = "PXA27x OHCI", | 419 | .product_desc = "PXA27x OHCI", |
269 | .hcd_priv_size = sizeof(struct ohci_hcd), | 420 | .hcd_priv_size = sizeof(struct pxa27x_ohci), |
270 | 421 | ||
271 | /* | 422 | /* |
272 | * generic hardware linkage | 423 | * generic hardware linkage |
@@ -298,7 +449,6 @@ static const struct hc_driver ohci_pxa27x_hc_driver = { | |||
298 | */ | 449 | */ |
299 | .hub_status_data = ohci_hub_status_data, | 450 | .hub_status_data = ohci_hub_status_data, |
300 | .hub_control = ohci_hub_control, | 451 | .hub_control = ohci_hub_control, |
301 | .hub_irq_enable = ohci_rhsc_enable, | ||
302 | #ifdef CONFIG_PM | 452 | #ifdef CONFIG_PM |
303 | .bus_suspend = ohci_bus_suspend, | 453 | .bus_suspend = ohci_bus_suspend, |
304 | .bus_resume = ohci_bus_resume, | 454 | .bus_resume = ohci_bus_resume, |
@@ -331,13 +481,13 @@ static int ohci_hcd_pxa27x_drv_remove(struct platform_device *pdev) | |||
331 | static int ohci_hcd_pxa27x_drv_suspend(struct platform_device *pdev, pm_message_t state) | 481 | static int ohci_hcd_pxa27x_drv_suspend(struct platform_device *pdev, pm_message_t state) |
332 | { | 482 | { |
333 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | 483 | struct usb_hcd *hcd = platform_get_drvdata(pdev); |
334 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); | 484 | struct pxa27x_ohci *ohci = to_pxa27x_ohci(hcd); |
335 | 485 | ||
336 | if (time_before(jiffies, ohci->next_statechange)) | 486 | if (time_before(jiffies, ohci->ohci.next_statechange)) |
337 | msleep(5); | 487 | msleep(5); |
338 | ohci->next_statechange = jiffies; | 488 | ohci->ohci.next_statechange = jiffies; |
339 | 489 | ||
340 | pxa27x_stop_hc(&pdev->dev); | 490 | pxa27x_stop_hc(ohci, &pdev->dev); |
341 | hcd->state = HC_STATE_SUSPENDED; | 491 | hcd->state = HC_STATE_SUSPENDED; |
342 | 492 | ||
343 | return 0; | 493 | return 0; |
@@ -346,14 +496,14 @@ static int ohci_hcd_pxa27x_drv_suspend(struct platform_device *pdev, pm_message_ | |||
346 | static int ohci_hcd_pxa27x_drv_resume(struct platform_device *pdev) | 496 | static int ohci_hcd_pxa27x_drv_resume(struct platform_device *pdev) |
347 | { | 497 | { |
348 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | 498 | struct usb_hcd *hcd = platform_get_drvdata(pdev); |
349 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); | 499 | struct pxa27x_ohci *ohci = to_pxa27x_ohci(hcd); |
350 | int status; | 500 | int status; |
351 | 501 | ||
352 | if (time_before(jiffies, ohci->next_statechange)) | 502 | if (time_before(jiffies, ohci->ohci.next_statechange)) |
353 | msleep(5); | 503 | msleep(5); |
354 | ohci->next_statechange = jiffies; | 504 | ohci->ohci.next_statechange = jiffies; |
355 | 505 | ||
356 | if ((status = pxa27x_start_hc(&pdev->dev)) < 0) | 506 | if ((status = pxa27x_start_hc(ohci, &pdev->dev)) < 0) |
357 | return status; | 507 | return status; |
358 | 508 | ||
359 | ohci_finish_controller_resume(hcd); | 509 | ohci_finish_controller_resume(hcd); |
diff --git a/drivers/usb/host/ohci-s3c2410.c b/drivers/usb/host/ohci-s3c2410.c index 9e3dc4069e8b..f46af7a718d4 100644 --- a/drivers/usb/host/ohci-s3c2410.c +++ b/drivers/usb/host/ohci-s3c2410.c | |||
@@ -466,7 +466,6 @@ static const struct hc_driver ohci_s3c2410_hc_driver = { | |||
466 | */ | 466 | */ |
467 | .hub_status_data = ohci_s3c2410_hub_status_data, | 467 | .hub_status_data = ohci_s3c2410_hub_status_data, |
468 | .hub_control = ohci_s3c2410_hub_control, | 468 | .hub_control = ohci_s3c2410_hub_control, |
469 | .hub_irq_enable = ohci_rhsc_enable, | ||
470 | #ifdef CONFIG_PM | 469 | #ifdef CONFIG_PM |
471 | .bus_suspend = ohci_bus_suspend, | 470 | .bus_suspend = ohci_bus_suspend, |
472 | .bus_resume = ohci_bus_resume, | 471 | .bus_resume = ohci_bus_resume, |
diff --git a/drivers/usb/host/ohci-sa1111.c b/drivers/usb/host/ohci-sa1111.c index 4626b002e670..e4bbe8e188e4 100644 --- a/drivers/usb/host/ohci-sa1111.c +++ b/drivers/usb/host/ohci-sa1111.c | |||
@@ -231,7 +231,6 @@ static const struct hc_driver ohci_sa1111_hc_driver = { | |||
231 | */ | 231 | */ |
232 | .hub_status_data = ohci_hub_status_data, | 232 | .hub_status_data = ohci_hub_status_data, |
233 | .hub_control = ohci_hub_control, | 233 | .hub_control = ohci_hub_control, |
234 | .hub_irq_enable = ohci_rhsc_enable, | ||
235 | #ifdef CONFIG_PM | 234 | #ifdef CONFIG_PM |
236 | .bus_suspend = ohci_bus_suspend, | 235 | .bus_suspend = ohci_bus_suspend, |
237 | .bus_resume = ohci_bus_resume, | 236 | .bus_resume = ohci_bus_resume, |
diff --git a/drivers/usb/host/ohci-sh.c b/drivers/usb/host/ohci-sh.c index e7ee607278fe..60f03cc7ec4f 100644 --- a/drivers/usb/host/ohci-sh.c +++ b/drivers/usb/host/ohci-sh.c | |||
@@ -68,7 +68,6 @@ static const struct hc_driver ohci_sh_hc_driver = { | |||
68 | */ | 68 | */ |
69 | .hub_status_data = ohci_hub_status_data, | 69 | .hub_status_data = ohci_hub_status_data, |
70 | .hub_control = ohci_hub_control, | 70 | .hub_control = ohci_hub_control, |
71 | .hub_irq_enable = ohci_rhsc_enable, | ||
72 | #ifdef CONFIG_PM | 71 | #ifdef CONFIG_PM |
73 | .bus_suspend = ohci_bus_suspend, | 72 | .bus_suspend = ohci_bus_suspend, |
74 | .bus_resume = ohci_bus_resume, | 73 | .bus_resume = ohci_bus_resume, |
diff --git a/drivers/usb/host/ohci-sm501.c b/drivers/usb/host/ohci-sm501.c index 21b164e4abeb..cff23637cfcc 100644 --- a/drivers/usb/host/ohci-sm501.c +++ b/drivers/usb/host/ohci-sm501.c | |||
@@ -75,7 +75,6 @@ static const struct hc_driver ohci_sm501_hc_driver = { | |||
75 | */ | 75 | */ |
76 | .hub_status_data = ohci_hub_status_data, | 76 | .hub_status_data = ohci_hub_status_data, |
77 | .hub_control = ohci_hub_control, | 77 | .hub_control = ohci_hub_control, |
78 | .hub_irq_enable = ohci_rhsc_enable, | ||
79 | #ifdef CONFIG_PM | 78 | #ifdef CONFIG_PM |
80 | .bus_suspend = ohci_bus_suspend, | 79 | .bus_suspend = ohci_bus_suspend, |
81 | .bus_resume = ohci_bus_resume, | 80 | .bus_resume = ohci_bus_resume, |
diff --git a/drivers/usb/host/ohci-ssb.c b/drivers/usb/host/ohci-ssb.c index 3660c83d80af..23fd6a886bdd 100644 --- a/drivers/usb/host/ohci-ssb.c +++ b/drivers/usb/host/ohci-ssb.c | |||
@@ -81,7 +81,6 @@ static const struct hc_driver ssb_ohci_hc_driver = { | |||
81 | 81 | ||
82 | .hub_status_data = ohci_hub_status_data, | 82 | .hub_status_data = ohci_hub_status_data, |
83 | .hub_control = ohci_hub_control, | 83 | .hub_control = ohci_hub_control, |
84 | .hub_irq_enable = ohci_rhsc_enable, | ||
85 | #ifdef CONFIG_PM | 84 | #ifdef CONFIG_PM |
86 | .bus_suspend = ohci_bus_suspend, | 85 | .bus_suspend = ohci_bus_suspend, |
87 | .bus_resume = ohci_bus_resume, | 86 | .bus_resume = ohci_bus_resume, |
diff --git a/drivers/usb/host/ohci.h b/drivers/usb/host/ohci.h index faf622eafce7..222011f6172c 100644 --- a/drivers/usb/host/ohci.h +++ b/drivers/usb/host/ohci.h | |||
@@ -540,15 +540,7 @@ static inline struct usb_hcd *ohci_to_hcd (const struct ohci_hcd *ohci) | |||
540 | * Big-endian read/write functions are arch-specific. | 540 | * Big-endian read/write functions are arch-specific. |
541 | * Other arches can be added if/when they're needed. | 541 | * Other arches can be added if/when they're needed. |
542 | * | 542 | * |
543 | * REVISIT: arch/powerpc now has readl/writel_be, so the | ||
544 | * definition below can die once the STB04xxx support is | ||
545 | * finally ported over. | ||
546 | */ | 543 | */ |
547 | #if defined(CONFIG_PPC) && !defined(CONFIG_PPC_MERGE) | ||
548 | #define readl_be(addr) in_be32((__force unsigned *)addr) | ||
549 | #define writel_be(val, addr) out_be32((__force unsigned *)addr, val) | ||
550 | #endif | ||
551 | |||
552 | static inline unsigned int _ohci_readl (const struct ohci_hcd *ohci, | 544 | static inline unsigned int _ohci_readl (const struct ohci_hcd *ohci, |
553 | __hc32 __iomem * regs) | 545 | __hc32 __iomem * regs) |
554 | { | 546 | { |
diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c index ea7126f99cab..c18d8790c410 100644 --- a/drivers/usb/host/r8a66597-hcd.c +++ b/drivers/usb/host/r8a66597-hcd.c | |||
@@ -66,7 +66,7 @@ static unsigned short endian; | |||
66 | module_param(endian, ushort, 0644); | 66 | module_param(endian, ushort, 0644); |
67 | MODULE_PARM_DESC(endian, "data endian: big=256, little=0 (default=0)"); | 67 | MODULE_PARM_DESC(endian, "data endian: big=256, little=0 (default=0)"); |
68 | 68 | ||
69 | static unsigned short irq_sense = INTL; | 69 | static unsigned short irq_sense = 0xff; |
70 | module_param(irq_sense, ushort, 0644); | 70 | module_param(irq_sense, ushort, 0644); |
71 | MODULE_PARM_DESC(irq_sense, "IRQ sense: low level=32, falling edge=0 " | 71 | MODULE_PARM_DESC(irq_sense, "IRQ sense: low level=32, falling edge=0 " |
72 | "(default=32)"); | 72 | "(default=32)"); |
@@ -118,7 +118,7 @@ static int r8a66597_clock_enable(struct r8a66597 *r8a66597) | |||
118 | r8a66597_write(r8a66597, SCKE, SYSCFG0); | 118 | r8a66597_write(r8a66597, SCKE, SYSCFG0); |
119 | tmp = r8a66597_read(r8a66597, SYSCFG0); | 119 | tmp = r8a66597_read(r8a66597, SYSCFG0); |
120 | if (i++ > 1000) { | 120 | if (i++ > 1000) { |
121 | err("register access fail."); | 121 | printk(KERN_ERR "r8a66597: register access fail.\n"); |
122 | return -ENXIO; | 122 | return -ENXIO; |
123 | } | 123 | } |
124 | } while ((tmp & SCKE) != SCKE); | 124 | } while ((tmp & SCKE) != SCKE); |
@@ -128,7 +128,7 @@ static int r8a66597_clock_enable(struct r8a66597 *r8a66597) | |||
128 | r8a66597_write(r8a66597, USBE, SYSCFG0); | 128 | r8a66597_write(r8a66597, USBE, SYSCFG0); |
129 | tmp = r8a66597_read(r8a66597, SYSCFG0); | 129 | tmp = r8a66597_read(r8a66597, SYSCFG0); |
130 | if (i++ > 1000) { | 130 | if (i++ > 1000) { |
131 | err("register access fail."); | 131 | printk(KERN_ERR "r8a66597: register access fail.\n"); |
132 | return -ENXIO; | 132 | return -ENXIO; |
133 | } | 133 | } |
134 | } while ((tmp & USBE) != USBE); | 134 | } while ((tmp & USBE) != USBE); |
@@ -141,7 +141,7 @@ static int r8a66597_clock_enable(struct r8a66597 *r8a66597) | |||
141 | msleep(1); | 141 | msleep(1); |
142 | tmp = r8a66597_read(r8a66597, SYSCFG0); | 142 | tmp = r8a66597_read(r8a66597, SYSCFG0); |
143 | if (i++ > 500) { | 143 | if (i++ > 500) { |
144 | err("register access fail."); | 144 | printk(KERN_ERR "r8a66597: register access fail.\n"); |
145 | return -ENXIO; | 145 | return -ENXIO; |
146 | } | 146 | } |
147 | } while ((tmp & SCKE) != SCKE); | 147 | } while ((tmp & SCKE) != SCKE); |
@@ -265,7 +265,7 @@ static void get_port_number(char *devpath, u16 *root_port, u16 *hub_port) | |||
265 | if (root_port) { | 265 | if (root_port) { |
266 | *root_port = (devpath[0] & 0x0F) - 1; | 266 | *root_port = (devpath[0] & 0x0F) - 1; |
267 | if (*root_port >= R8A66597_MAX_ROOT_HUB) | 267 | if (*root_port >= R8A66597_MAX_ROOT_HUB) |
268 | err("illegal root port number"); | 268 | printk(KERN_ERR "r8a66597: Illegal root port number.\n"); |
269 | } | 269 | } |
270 | if (hub_port) | 270 | if (hub_port) |
271 | *hub_port = devpath[2] & 0x0F; | 271 | *hub_port = devpath[2] & 0x0F; |
@@ -286,7 +286,7 @@ static u16 get_r8a66597_usb_speed(enum usb_device_speed speed) | |||
286 | usbspd = HSMODE; | 286 | usbspd = HSMODE; |
287 | break; | 287 | break; |
288 | default: | 288 | default: |
289 | err("unknown speed"); | 289 | printk(KERN_ERR "r8a66597: unknown speed\n"); |
290 | break; | 290 | break; |
291 | } | 291 | } |
292 | 292 | ||
@@ -385,7 +385,7 @@ static u8 alloc_usb_address(struct r8a66597 *r8a66597, struct urb *urb) | |||
385 | struct r8a66597_device *dev; | 385 | struct r8a66597_device *dev; |
386 | 386 | ||
387 | if (is_hub_limit(urb->dev->devpath)) { | 387 | if (is_hub_limit(urb->dev->devpath)) { |
388 | err("Externel hub limit reached."); | 388 | dev_err(&urb->dev->dev, "External hub limit reached.\n"); |
389 | return 0; | 389 | return 0; |
390 | } | 390 | } |
391 | 391 | ||
@@ -406,8 +406,9 @@ static u8 alloc_usb_address(struct r8a66597 *r8a66597, struct urb *urb) | |||
406 | return addr; | 406 | return addr; |
407 | } | 407 | } |
408 | 408 | ||
409 | err("cannot communicate with a USB device more than 10.(%x)", | 409 | dev_err(&urb->dev->dev, |
410 | r8a66597->address_map); | 410 | "cannot communicate with a USB device more than 10.(%x)\n", |
411 | r8a66597->address_map); | ||
411 | 412 | ||
412 | return 0; | 413 | return 0; |
413 | } | 414 | } |
@@ -447,7 +448,8 @@ static void r8a66597_reg_wait(struct r8a66597 *r8a66597, unsigned long reg, | |||
447 | do { | 448 | do { |
448 | tmp = r8a66597_read(r8a66597, reg); | 449 | tmp = r8a66597_read(r8a66597, reg); |
449 | if (i++ > 1000000) { | 450 | if (i++ > 1000000) { |
450 | err("register%lx, loop %x is timeout", reg, loop); | 451 | printk(KERN_ERR "r8a66597: register%lx, loop %x " |
452 | "is timeout\n", reg, loop); | ||
451 | break; | 453 | break; |
452 | } | 454 | } |
453 | ndelay(1); | 455 | ndelay(1); |
@@ -675,7 +677,7 @@ static u16 get_empty_pipenum(struct r8a66597 *r8a66597, | |||
675 | array[i++] = 1; | 677 | array[i++] = 1; |
676 | break; | 678 | break; |
677 | default: | 679 | default: |
678 | err("Illegal type"); | 680 | printk(KERN_ERR "r8a66597: Illegal type\n"); |
679 | return 0; | 681 | return 0; |
680 | } | 682 | } |
681 | 683 | ||
@@ -705,7 +707,7 @@ static u16 get_r8a66597_type(__u8 type) | |||
705 | r8a66597_type = R8A66597_ISO; | 707 | r8a66597_type = R8A66597_ISO; |
706 | break; | 708 | break; |
707 | default: | 709 | default: |
708 | err("Illegal type"); | 710 | printk(KERN_ERR "r8a66597: Illegal type\n"); |
709 | r8a66597_type = 0x0000; | 711 | r8a66597_type = 0x0000; |
710 | break; | 712 | break; |
711 | } | 713 | } |
@@ -724,7 +726,7 @@ static u16 get_bufnum(u16 pipenum) | |||
724 | else if (check_interrupt(pipenum)) | 726 | else if (check_interrupt(pipenum)) |
725 | bufnum = 4 + (pipenum - 6); | 727 | bufnum = 4 + (pipenum - 6); |
726 | else | 728 | else |
727 | err("Illegal pipenum (%d)", pipenum); | 729 | printk(KERN_ERR "r8a66597: Illegal pipenum (%d)\n", pipenum); |
728 | 730 | ||
729 | return bufnum; | 731 | return bufnum; |
730 | } | 732 | } |
@@ -740,7 +742,7 @@ static u16 get_buf_bsize(u16 pipenum) | |||
740 | else if (check_interrupt(pipenum)) | 742 | else if (check_interrupt(pipenum)) |
741 | buf_bsize = 0; | 743 | buf_bsize = 0; |
742 | else | 744 | else |
743 | err("Illegal pipenum (%d)", pipenum); | 745 | printk(KERN_ERR "r8a66597: Illegal pipenum (%d)\n", pipenum); |
744 | 746 | ||
745 | return buf_bsize; | 747 | return buf_bsize; |
746 | } | 748 | } |
@@ -760,10 +762,12 @@ static void enable_r8a66597_pipe_dma(struct r8a66597 *r8a66597, | |||
760 | if ((r8a66597->dma_map & (1 << i)) != 0) | 762 | if ((r8a66597->dma_map & (1 << i)) != 0) |
761 | continue; | 763 | continue; |
762 | 764 | ||
763 | info("address %d, EndpointAddress 0x%02x use DMA FIFO", | 765 | dev_info(&dev->udev->dev, |
764 | usb_pipedevice(urb->pipe), | 766 | "address %d, EndpointAddress 0x%02x use " |
765 | info->dir_in ? USB_ENDPOINT_DIR_MASK + info->epnum | 767 | "DMA FIFO\n", usb_pipedevice(urb->pipe), |
766 | : info->epnum); | 768 | info->dir_in ? |
769 | USB_ENDPOINT_DIR_MASK + info->epnum | ||
770 | : info->epnum); | ||
767 | 771 | ||
768 | r8a66597->dma_map |= 1 << i; | 772 | r8a66597->dma_map |= 1 << i; |
769 | dev->dma_map |= 1 << i; | 773 | dev->dma_map |= 1 << i; |
@@ -1187,7 +1191,7 @@ static int start_transfer(struct r8a66597 *r8a66597, struct r8a66597_td *td) | |||
1187 | prepare_status_packet(r8a66597, td); | 1191 | prepare_status_packet(r8a66597, td); |
1188 | break; | 1192 | break; |
1189 | default: | 1193 | default: |
1190 | err("invalid type."); | 1194 | printk(KERN_ERR "r8a66597: invalid type.\n"); |
1191 | break; | 1195 | break; |
1192 | } | 1196 | } |
1193 | 1197 | ||
@@ -1295,7 +1299,7 @@ static void packet_read(struct r8a66597 *r8a66597, u16 pipenum) | |||
1295 | if (unlikely((tmp & FRDY) == 0)) { | 1299 | if (unlikely((tmp & FRDY) == 0)) { |
1296 | pipe_stop(r8a66597, td->pipe); | 1300 | pipe_stop(r8a66597, td->pipe); |
1297 | pipe_irq_disable(r8a66597, pipenum); | 1301 | pipe_irq_disable(r8a66597, pipenum); |
1298 | err("in fifo not ready (%d)", pipenum); | 1302 | printk(KERN_ERR "r8a66597: in fifo not ready (%d)\n", pipenum); |
1299 | finish_request(r8a66597, td, pipenum, td->urb, -EPIPE); | 1303 | finish_request(r8a66597, td, pipenum, td->urb, -EPIPE); |
1300 | return; | 1304 | return; |
1301 | } | 1305 | } |
@@ -1370,7 +1374,7 @@ static void packet_write(struct r8a66597 *r8a66597, u16 pipenum) | |||
1370 | if (unlikely((tmp & FRDY) == 0)) { | 1374 | if (unlikely((tmp & FRDY) == 0)) { |
1371 | pipe_stop(r8a66597, td->pipe); | 1375 | pipe_stop(r8a66597, td->pipe); |
1372 | pipe_irq_disable(r8a66597, pipenum); | 1376 | pipe_irq_disable(r8a66597, pipenum); |
1373 | err("out write fifo not ready. (%d)", pipenum); | 1377 | printk(KERN_ERR "r8a66597: out fifo not ready (%d)\n", pipenum); |
1374 | finish_request(r8a66597, td, pipenum, urb, -EPIPE); | 1378 | finish_request(r8a66597, td, pipenum, urb, -EPIPE); |
1375 | return; | 1379 | return; |
1376 | } | 1380 | } |
@@ -2005,7 +2009,7 @@ static struct r8a66597_device *get_r8a66597_device(struct r8a66597 *r8a66597, | |||
2005 | return dev; | 2009 | return dev; |
2006 | } | 2010 | } |
2007 | 2011 | ||
2008 | err("get_r8a66597_device fail.(%d)\n", addr); | 2012 | printk(KERN_ERR "r8a66597: get_r8a66597_device fail.(%d)\n", addr); |
2009 | return NULL; | 2013 | return NULL; |
2010 | } | 2014 | } |
2011 | 2015 | ||
@@ -2263,7 +2267,7 @@ static int __init_or_module r8a66597_remove(struct platform_device *pdev) | |||
2263 | #define resource_len(r) (((r)->end - (r)->start) + 1) | 2267 | #define resource_len(r) (((r)->end - (r)->start) + 1) |
2264 | static int __init r8a66597_probe(struct platform_device *pdev) | 2268 | static int __init r8a66597_probe(struct platform_device *pdev) |
2265 | { | 2269 | { |
2266 | struct resource *res = NULL; | 2270 | struct resource *res = NULL, *ires; |
2267 | int irq = -1; | 2271 | int irq = -1; |
2268 | void __iomem *reg = NULL; | 2272 | void __iomem *reg = NULL; |
2269 | struct usb_hcd *hcd = NULL; | 2273 | struct usb_hcd *hcd = NULL; |
@@ -2274,7 +2278,7 @@ static int __init r8a66597_probe(struct platform_device *pdev) | |||
2274 | 2278 | ||
2275 | if (pdev->dev.dma_mask) { | 2279 | if (pdev->dev.dma_mask) { |
2276 | ret = -EINVAL; | 2280 | ret = -EINVAL; |
2277 | err("dma not support"); | 2281 | dev_err(&pdev->dev, "dma not supported\n"); |
2278 | goto clean_up; | 2282 | goto clean_up; |
2279 | } | 2283 | } |
2280 | 2284 | ||
@@ -2282,21 +2286,25 @@ static int __init r8a66597_probe(struct platform_device *pdev) | |||
2282 | (char *)hcd_name); | 2286 | (char *)hcd_name); |
2283 | if (!res) { | 2287 | if (!res) { |
2284 | ret = -ENODEV; | 2288 | ret = -ENODEV; |
2285 | err("platform_get_resource_byname error."); | 2289 | dev_err(&pdev->dev, "platform_get_resource_byname error.\n"); |
2286 | goto clean_up; | 2290 | goto clean_up; |
2287 | } | 2291 | } |
2288 | 2292 | ||
2289 | irq = platform_get_irq(pdev, 0); | 2293 | ires = platform_get_resource(pdev, IORESOURCE_IRQ, 0); |
2290 | if (irq < 0) { | 2294 | if (!ires) { |
2291 | ret = -ENODEV; | 2295 | ret = -ENODEV; |
2292 | err("platform_get_irq error."); | 2296 | dev_err(&pdev->dev, |
2297 | "platform_get_resource IORESOURCE_IRQ error.\n"); | ||
2293 | goto clean_up; | 2298 | goto clean_up; |
2294 | } | 2299 | } |
2295 | 2300 | ||
2301 | irq = ires->start; | ||
2302 | irq_trigger = ires->flags & IRQF_TRIGGER_MASK; | ||
2303 | |||
2296 | reg = ioremap(res->start, resource_len(res)); | 2304 | reg = ioremap(res->start, resource_len(res)); |
2297 | if (reg == NULL) { | 2305 | if (reg == NULL) { |
2298 | ret = -ENOMEM; | 2306 | ret = -ENOMEM; |
2299 | err("ioremap error."); | 2307 | dev_err(&pdev->dev, "ioremap error.\n"); |
2300 | goto clean_up; | 2308 | goto clean_up; |
2301 | } | 2309 | } |
2302 | 2310 | ||
@@ -2304,7 +2312,7 @@ static int __init r8a66597_probe(struct platform_device *pdev) | |||
2304 | hcd = usb_create_hcd(&r8a66597_hc_driver, &pdev->dev, (char *)hcd_name); | 2312 | hcd = usb_create_hcd(&r8a66597_hc_driver, &pdev->dev, (char *)hcd_name); |
2305 | if (!hcd) { | 2313 | if (!hcd) { |
2306 | ret = -ENOMEM; | 2314 | ret = -ENOMEM; |
2307 | err("Failed to create hcd"); | 2315 | dev_err(&pdev->dev, "Failed to create hcd\n"); |
2308 | goto clean_up; | 2316 | goto clean_up; |
2309 | } | 2317 | } |
2310 | r8a66597 = hcd_to_r8a66597(hcd); | 2318 | r8a66597 = hcd_to_r8a66597(hcd); |
@@ -2329,13 +2337,33 @@ static int __init r8a66597_probe(struct platform_device *pdev) | |||
2329 | INIT_LIST_HEAD(&r8a66597->child_device); | 2337 | INIT_LIST_HEAD(&r8a66597->child_device); |
2330 | 2338 | ||
2331 | hcd->rsrc_start = res->start; | 2339 | hcd->rsrc_start = res->start; |
2332 | if (irq_sense == INTL) | 2340 | |
2333 | irq_trigger = IRQF_TRIGGER_LOW; | 2341 | /* irq_sense setting on cmdline takes precedence over resource |
2334 | else | 2342 | * settings, so the introduction of irqflags in IRQ resourse |
2335 | irq_trigger = IRQF_TRIGGER_FALLING; | 2343 | * won't disturb existing setups */ |
2344 | switch (irq_sense) { | ||
2345 | case INTL: | ||
2346 | irq_trigger = IRQF_TRIGGER_LOW; | ||
2347 | break; | ||
2348 | case 0: | ||
2349 | irq_trigger = IRQF_TRIGGER_FALLING; | ||
2350 | break; | ||
2351 | case 0xff: | ||
2352 | if (irq_trigger) | ||
2353 | irq_sense = (irq_trigger & IRQF_TRIGGER_LOW) ? | ||
2354 | INTL : 0; | ||
2355 | else { | ||
2356 | irq_sense = INTL; | ||
2357 | irq_trigger = IRQF_TRIGGER_LOW; | ||
2358 | } | ||
2359 | break; | ||
2360 | default: | ||
2361 | dev_err(&pdev->dev, "Unknown irq_sense value.\n"); | ||
2362 | } | ||
2363 | |||
2336 | ret = usb_add_hcd(hcd, irq, IRQF_DISABLED | irq_trigger); | 2364 | ret = usb_add_hcd(hcd, irq, IRQF_DISABLED | irq_trigger); |
2337 | if (ret != 0) { | 2365 | if (ret != 0) { |
2338 | err("Failed to add hcd"); | 2366 | dev_err(&pdev->dev, "Failed to add hcd\n"); |
2339 | goto clean_up; | 2367 | goto clean_up; |
2340 | } | 2368 | } |
2341 | 2369 | ||
@@ -2364,7 +2392,8 @@ static int __init r8a66597_init(void) | |||
2364 | if (usb_disabled()) | 2392 | if (usb_disabled()) |
2365 | return -ENODEV; | 2393 | return -ENODEV; |
2366 | 2394 | ||
2367 | info("driver %s, %s", hcd_name, DRIVER_VERSION); | 2395 | printk(KERN_INFO KBUILD_MODNAME ": driver %s, %s\n", hcd_name, |
2396 | DRIVER_VERSION); | ||
2368 | return platform_driver_register(&r8a66597_driver); | 2397 | return platform_driver_register(&r8a66597_driver); |
2369 | } | 2398 | } |
2370 | module_init(r8a66597_init); | 2399 | module_init(r8a66597_init); |
diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c index 8a74bbb57d08..e106e9d48d4a 100644 --- a/drivers/usb/host/sl811-hcd.c +++ b/drivers/usb/host/sl811-hcd.c | |||
@@ -1620,22 +1620,26 @@ sl811h_probe(struct platform_device *dev) | |||
1620 | { | 1620 | { |
1621 | struct usb_hcd *hcd; | 1621 | struct usb_hcd *hcd; |
1622 | struct sl811 *sl811; | 1622 | struct sl811 *sl811; |
1623 | struct resource *addr, *data; | 1623 | struct resource *addr, *data, *ires; |
1624 | int irq; | 1624 | int irq; |
1625 | void __iomem *addr_reg; | 1625 | void __iomem *addr_reg; |
1626 | void __iomem *data_reg; | 1626 | void __iomem *data_reg; |
1627 | int retval; | 1627 | int retval; |
1628 | u8 tmp, ioaddr = 0; | 1628 | u8 tmp, ioaddr = 0; |
1629 | unsigned long irqflags; | ||
1629 | 1630 | ||
1630 | /* basic sanity checks first. board-specific init logic should | 1631 | /* basic sanity checks first. board-specific init logic should |
1631 | * have initialized these three resources and probably board | 1632 | * have initialized these three resources and probably board |
1632 | * specific platform_data. we don't probe for IRQs, and do only | 1633 | * specific platform_data. we don't probe for IRQs, and do only |
1633 | * minimal sanity checking. | 1634 | * minimal sanity checking. |
1634 | */ | 1635 | */ |
1635 | irq = platform_get_irq(dev, 0); | 1636 | ires = platform_get_resource(dev, IORESOURCE_IRQ, 0); |
1636 | if (dev->num_resources < 3 || irq < 0) | 1637 | if (dev->num_resources < 3 || !ires) |
1637 | return -ENODEV; | 1638 | return -ENODEV; |
1638 | 1639 | ||
1640 | irq = ires->start; | ||
1641 | irqflags = ires->flags & IRQF_TRIGGER_MASK; | ||
1642 | |||
1639 | /* refuse to confuse usbcore */ | 1643 | /* refuse to confuse usbcore */ |
1640 | if (dev->dev.dma_mask) { | 1644 | if (dev->dev.dma_mask) { |
1641 | DBG("no we won't dma\n"); | 1645 | DBG("no we won't dma\n"); |
@@ -1717,8 +1721,11 @@ sl811h_probe(struct platform_device *dev) | |||
1717 | * triggers (e.g. most ARM CPUs). Initial driver stress testing | 1721 | * triggers (e.g. most ARM CPUs). Initial driver stress testing |
1718 | * was on a system with single edge triggering, so most sorts of | 1722 | * was on a system with single edge triggering, so most sorts of |
1719 | * triggering arrangement should work. | 1723 | * triggering arrangement should work. |
1724 | * | ||
1725 | * Use resource IRQ flags if set by platform device setup. | ||
1720 | */ | 1726 | */ |
1721 | retval = usb_add_hcd(hcd, irq, IRQF_DISABLED | IRQF_SHARED); | 1727 | irqflags |= IRQF_SHARED; |
1728 | retval = usb_add_hcd(hcd, irq, IRQF_DISABLED | irqflags); | ||
1722 | if (retval != 0) | 1729 | if (retval != 0) |
1723 | goto err6; | 1730 | goto err6; |
1724 | 1731 | ||
diff --git a/drivers/usb/host/sl811_cs.c b/drivers/usb/host/sl811_cs.c index 5da63f535005..516848dd9b48 100644 --- a/drivers/usb/host/sl811_cs.c +++ b/drivers/usb/host/sl811_cs.c | |||
@@ -112,7 +112,8 @@ static struct platform_device platform_dev = { | |||
112 | .num_resources = ARRAY_SIZE(resources), | 112 | .num_resources = ARRAY_SIZE(resources), |
113 | }; | 113 | }; |
114 | 114 | ||
115 | static int sl811_hc_init(struct device *parent, ioaddr_t base_addr, int irq) | 115 | static int sl811_hc_init(struct device *parent, resource_size_t base_addr, |
116 | int irq) | ||
116 | { | 117 | { |
117 | if (platform_dev.dev.parent) | 118 | if (platform_dev.dev.parent) |
118 | return -EBUSY; | 119 | return -EBUSY; |
@@ -155,97 +156,72 @@ static void sl811_cs_release(struct pcmcia_device * link) | |||
155 | platform_device_unregister(&platform_dev); | 156 | platform_device_unregister(&platform_dev); |
156 | } | 157 | } |
157 | 158 | ||
159 | static int sl811_cs_config_check(struct pcmcia_device *p_dev, | ||
160 | cistpl_cftable_entry_t *cfg, | ||
161 | cistpl_cftable_entry_t *dflt, | ||
162 | unsigned int vcc, | ||
163 | void *priv_data) | ||
164 | { | ||
165 | if (cfg->index == 0) | ||
166 | return -ENODEV; | ||
167 | |||
168 | /* Use power settings for Vcc and Vpp if present */ | ||
169 | /* Note that the CIS values need to be rescaled */ | ||
170 | if (cfg->vcc.present & (1<<CISTPL_POWER_VNOM)) { | ||
171 | if (cfg->vcc.param[CISTPL_POWER_VNOM]/10000 != vcc) | ||
172 | return -ENODEV; | ||
173 | } else if (dflt->vcc.present & (1<<CISTPL_POWER_VNOM)) { | ||
174 | if (dflt->vcc.param[CISTPL_POWER_VNOM]/10000 != vcc) | ||
175 | return -ENODEV; | ||
176 | } | ||
177 | |||
178 | if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM)) | ||
179 | p_dev->conf.Vpp = | ||
180 | cfg->vpp1.param[CISTPL_POWER_VNOM]/10000; | ||
181 | else if (dflt->vpp1.present & (1<<CISTPL_POWER_VNOM)) | ||
182 | p_dev->conf.Vpp = | ||
183 | dflt->vpp1.param[CISTPL_POWER_VNOM]/10000; | ||
184 | |||
185 | /* we need an interrupt */ | ||
186 | if (cfg->irq.IRQInfo1 || dflt->irq.IRQInfo1) | ||
187 | p_dev->conf.Attributes |= CONF_ENABLE_IRQ; | ||
188 | |||
189 | /* IO window settings */ | ||
190 | p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0; | ||
191 | if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { | ||
192 | cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; | ||
193 | |||
194 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; | ||
195 | p_dev->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; | ||
196 | p_dev->io.BasePort1 = io->win[0].base; | ||
197 | p_dev->io.NumPorts1 = io->win[0].len; | ||
198 | |||
199 | return pcmcia_request_io(p_dev, &p_dev->io); | ||
200 | } | ||
201 | pcmcia_disable_device(p_dev); | ||
202 | return -ENODEV; | ||
203 | } | ||
204 | |||
205 | |||
158 | static int sl811_cs_config(struct pcmcia_device *link) | 206 | static int sl811_cs_config(struct pcmcia_device *link) |
159 | { | 207 | { |
160 | struct device *parent = &handle_to_dev(link); | 208 | struct device *parent = &handle_to_dev(link); |
161 | local_info_t *dev = link->priv; | 209 | local_info_t *dev = link->priv; |
162 | tuple_t tuple; | ||
163 | cisparse_t parse; | ||
164 | int last_fn, last_ret; | 210 | int last_fn, last_ret; |
165 | u_char buf[64]; | ||
166 | config_info_t conf; | ||
167 | cistpl_cftable_entry_t dflt = { 0 }; | ||
168 | 211 | ||
169 | DBG(0, "sl811_cs_config(0x%p)\n", link); | 212 | DBG(0, "sl811_cs_config(0x%p)\n", link); |
170 | 213 | ||
171 | /* Look up the current Vcc */ | 214 | if (pcmcia_loop_config(link, sl811_cs_config_check, NULL)) |
172 | CS_CHECK(GetConfigurationInfo, | 215 | goto failed; |
173 | pcmcia_get_configuration_info(link, &conf)); | ||
174 | |||
175 | tuple.Attributes = 0; | ||
176 | tuple.TupleData = buf; | ||
177 | tuple.TupleDataMax = sizeof(buf); | ||
178 | tuple.TupleOffset = 0; | ||
179 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | ||
180 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); | ||
181 | while (1) { | ||
182 | cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); | ||
183 | |||
184 | if (pcmcia_get_tuple_data(link, &tuple) != 0 | ||
185 | || pcmcia_parse_tuple(link, &tuple, &parse) | ||
186 | != 0) | ||
187 | goto next_entry; | ||
188 | |||
189 | if (cfg->flags & CISTPL_CFTABLE_DEFAULT) { | ||
190 | dflt = *cfg; | ||
191 | } | ||
192 | |||
193 | if (cfg->index == 0) | ||
194 | goto next_entry; | ||
195 | |||
196 | link->conf.ConfigIndex = cfg->index; | ||
197 | |||
198 | /* Use power settings for Vcc and Vpp if present */ | ||
199 | /* Note that the CIS values need to be rescaled */ | ||
200 | if (cfg->vcc.present & (1<<CISTPL_POWER_VNOM)) { | ||
201 | if (cfg->vcc.param[CISTPL_POWER_VNOM]/10000 | ||
202 | != conf.Vcc) | ||
203 | goto next_entry; | ||
204 | } else if (dflt.vcc.present & (1<<CISTPL_POWER_VNOM)) { | ||
205 | if (dflt.vcc.param[CISTPL_POWER_VNOM]/10000 | ||
206 | != conf.Vcc) | ||
207 | goto next_entry; | ||
208 | } | ||
209 | |||
210 | if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM)) | ||
211 | link->conf.Vpp = | ||
212 | cfg->vpp1.param[CISTPL_POWER_VNOM]/10000; | ||
213 | else if (dflt.vpp1.present & (1<<CISTPL_POWER_VNOM)) | ||
214 | link->conf.Vpp = | ||
215 | dflt.vpp1.param[CISTPL_POWER_VNOM]/10000; | ||
216 | |||
217 | /* we need an interrupt */ | ||
218 | if (cfg->irq.IRQInfo1 || dflt.irq.IRQInfo1) | ||
219 | link->conf.Attributes |= CONF_ENABLE_IRQ; | ||
220 | |||
221 | /* IO window settings */ | ||
222 | link->io.NumPorts1 = link->io.NumPorts2 = 0; | ||
223 | if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) { | ||
224 | cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt.io; | ||
225 | |||
226 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; | ||
227 | link->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; | ||
228 | link->io.BasePort1 = io->win[0].base; | ||
229 | link->io.NumPorts1 = io->win[0].len; | ||
230 | |||
231 | if (pcmcia_request_io(link, &link->io) != 0) | ||
232 | goto next_entry; | ||
233 | } | ||
234 | break; | ||
235 | |||
236 | next_entry: | ||
237 | pcmcia_disable_device(link); | ||
238 | last_ret = pcmcia_get_next_tuple(link, &tuple); | ||
239 | } | ||
240 | 216 | ||
241 | /* require an IRQ and two registers */ | 217 | /* require an IRQ and two registers */ |
242 | if (!link->io.NumPorts1 || link->io.NumPorts1 < 2) | 218 | if (!link->io.NumPorts1 || link->io.NumPorts1 < 2) |
243 | goto cs_failed; | 219 | goto failed; |
244 | if (link->conf.Attributes & CONF_ENABLE_IRQ) | 220 | if (link->conf.Attributes & CONF_ENABLE_IRQ) |
245 | CS_CHECK(RequestIRQ, | 221 | CS_CHECK(RequestIRQ, |
246 | pcmcia_request_irq(link, &link->irq)); | 222 | pcmcia_request_irq(link, &link->irq)); |
247 | else | 223 | else |
248 | goto cs_failed; | 224 | goto failed; |
249 | 225 | ||
250 | CS_CHECK(RequestConfiguration, | 226 | CS_CHECK(RequestConfiguration, |
251 | pcmcia_request_configuration(link, &link->conf)); | 227 | pcmcia_request_configuration(link, &link->conf)); |
@@ -266,8 +242,9 @@ next_entry: | |||
266 | if (sl811_hc_init(parent, link->io.BasePort1, link->irq.AssignedIRQ) | 242 | if (sl811_hc_init(parent, link->io.BasePort1, link->irq.AssignedIRQ) |
267 | < 0) { | 243 | < 0) { |
268 | cs_failed: | 244 | cs_failed: |
269 | printk("sl811_cs_config failed\n"); | ||
270 | cs_error(link, last_fn, last_ret); | 245 | cs_error(link, last_fn, last_ret); |
246 | failed: | ||
247 | printk(KERN_WARNING "sl811_cs_config failed\n"); | ||
271 | sl811_cs_release(link); | 248 | sl811_cs_release(link); |
272 | return -ENODEV; | 249 | return -ENODEV; |
273 | } | 250 | } |
diff --git a/drivers/usb/host/u132-hcd.c b/drivers/usb/host/u132-hcd.c index 20ad3c48fcb2..228f2b070f2b 100644 --- a/drivers/usb/host/u132-hcd.c +++ b/drivers/usb/host/u132-hcd.c | |||
@@ -2934,16 +2934,6 @@ static int u132_start_port_reset(struct usb_hcd *hcd, unsigned port_num) | |||
2934 | return 0; | 2934 | return 0; |
2935 | } | 2935 | } |
2936 | 2936 | ||
2937 | static void u132_hub_irq_enable(struct usb_hcd *hcd) | ||
2938 | { | ||
2939 | struct u132 *u132 = hcd_to_u132(hcd); | ||
2940 | if (u132->going > 1) { | ||
2941 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | ||
2942 | , u132->going); | ||
2943 | } else if (u132->going > 0) | ||
2944 | dev_err(&u132->platform_dev->dev, "device is being removed\n"); | ||
2945 | } | ||
2946 | |||
2947 | 2937 | ||
2948 | #ifdef CONFIG_PM | 2938 | #ifdef CONFIG_PM |
2949 | static int u132_bus_suspend(struct usb_hcd *hcd) | 2939 | static int u132_bus_suspend(struct usb_hcd *hcd) |
@@ -2995,7 +2985,6 @@ static struct hc_driver u132_hc_driver = { | |||
2995 | .bus_suspend = u132_bus_suspend, | 2985 | .bus_suspend = u132_bus_suspend, |
2996 | .bus_resume = u132_bus_resume, | 2986 | .bus_resume = u132_bus_resume, |
2997 | .start_port_reset = u132_start_port_reset, | 2987 | .start_port_reset = u132_start_port_reset, |
2998 | .hub_irq_enable = u132_hub_irq_enable, | ||
2999 | }; | 2988 | }; |
3000 | 2989 | ||
3001 | /* | 2990 | /* |
diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c index 3a7bfe7a8874..cf5e4cf7ea42 100644 --- a/drivers/usb/host/uhci-hcd.c +++ b/drivers/usb/host/uhci-hcd.c | |||
@@ -53,7 +53,6 @@ | |||
53 | /* | 53 | /* |
54 | * Version Information | 54 | * Version Information |
55 | */ | 55 | */ |
56 | #define DRIVER_VERSION "v3.0" | ||
57 | #define DRIVER_AUTHOR "Linus 'Frodo Rabbit' Torvalds, Johannes Erdfelt, \ | 56 | #define DRIVER_AUTHOR "Linus 'Frodo Rabbit' Torvalds, Johannes Erdfelt, \ |
58 | Randy Dunlap, Georg Acher, Deti Fliegl, Thomas Sailer, Roman Weissgaerber, \ | 57 | Randy Dunlap, Georg Acher, Deti Fliegl, Thomas Sailer, Roman Weissgaerber, \ |
59 | Alan Stern" | 58 | Alan Stern" |
@@ -951,12 +950,13 @@ static int __init uhci_hcd_init(void) | |||
951 | { | 950 | { |
952 | int retval = -ENOMEM; | 951 | int retval = -ENOMEM; |
953 | 952 | ||
954 | printk(KERN_INFO DRIVER_DESC " " DRIVER_VERSION "%s\n", | ||
955 | ignore_oc ? ", overcurrent ignored" : ""); | ||
956 | |||
957 | if (usb_disabled()) | 953 | if (usb_disabled()) |
958 | return -ENODEV; | 954 | return -ENODEV; |
959 | 955 | ||
956 | printk(KERN_INFO "uhci_hcd: " DRIVER_DESC "%s\n", | ||
957 | ignore_oc ? ", overcurrent ignored" : ""); | ||
958 | set_bit(USB_UHCI_LOADED, &usb_hcds_loaded); | ||
959 | |||
960 | if (DEBUG_CONFIGURED) { | 960 | if (DEBUG_CONFIGURED) { |
961 | errbuf = kmalloc(ERRBUF_LEN, GFP_KERNEL); | 961 | errbuf = kmalloc(ERRBUF_LEN, GFP_KERNEL); |
962 | if (!errbuf) | 962 | if (!errbuf) |
@@ -988,6 +988,7 @@ debug_failed: | |||
988 | 988 | ||
989 | errbuf_failed: | 989 | errbuf_failed: |
990 | 990 | ||
991 | clear_bit(USB_UHCI_LOADED, &usb_hcds_loaded); | ||
991 | return retval; | 992 | return retval; |
992 | } | 993 | } |
993 | 994 | ||
@@ -997,6 +998,7 @@ static void __exit uhci_hcd_cleanup(void) | |||
997 | kmem_cache_destroy(uhci_up_cachep); | 998 | kmem_cache_destroy(uhci_up_cachep); |
998 | debugfs_remove(uhci_debugfs_root); | 999 | debugfs_remove(uhci_debugfs_root); |
999 | kfree(errbuf); | 1000 | kfree(errbuf); |
1001 | clear_bit(USB_UHCI_LOADED, &usb_hcds_loaded); | ||
1000 | } | 1002 | } |
1001 | 1003 | ||
1002 | module_init(uhci_hcd_init); | 1004 | module_init(uhci_hcd_init); |
diff --git a/drivers/usb/host/uhci-q.c b/drivers/usb/host/uhci-q.c index db645936eedd..5631d89c8730 100644 --- a/drivers/usb/host/uhci-q.c +++ b/drivers/usb/host/uhci-q.c | |||
@@ -123,14 +123,10 @@ static struct uhci_td *uhci_alloc_td(struct uhci_hcd *uhci) | |||
123 | 123 | ||
124 | static void uhci_free_td(struct uhci_hcd *uhci, struct uhci_td *td) | 124 | static void uhci_free_td(struct uhci_hcd *uhci, struct uhci_td *td) |
125 | { | 125 | { |
126 | if (!list_empty(&td->list)) { | 126 | if (!list_empty(&td->list)) |
127 | dev_warn(uhci_dev(uhci), "td %p still in list!\n", td); | 127 | dev_WARN(uhci_dev(uhci), "td %p still in list!\n", td); |
128 | WARN_ON(1); | 128 | if (!list_empty(&td->fl_list)) |
129 | } | 129 | dev_WARN(uhci_dev(uhci), "td %p still in fl_list!\n", td); |
130 | if (!list_empty(&td->fl_list)) { | ||
131 | dev_warn(uhci_dev(uhci), "td %p still in fl_list!\n", td); | ||
132 | WARN_ON(1); | ||
133 | } | ||
134 | 130 | ||
135 | dma_pool_free(uhci->td_pool, td, td->dma_handle); | 131 | dma_pool_free(uhci->td_pool, td, td->dma_handle); |
136 | } | 132 | } |
@@ -295,10 +291,8 @@ static struct uhci_qh *uhci_alloc_qh(struct uhci_hcd *uhci, | |||
295 | static void uhci_free_qh(struct uhci_hcd *uhci, struct uhci_qh *qh) | 291 | static void uhci_free_qh(struct uhci_hcd *uhci, struct uhci_qh *qh) |
296 | { | 292 | { |
297 | WARN_ON(qh->state != QH_STATE_IDLE && qh->udev); | 293 | WARN_ON(qh->state != QH_STATE_IDLE && qh->udev); |
298 | if (!list_empty(&qh->queue)) { | 294 | if (!list_empty(&qh->queue)) |
299 | dev_warn(uhci_dev(uhci), "qh %p list not empty!\n", qh); | 295 | dev_WARN(uhci_dev(uhci), "qh %p list not empty!\n", qh); |
300 | WARN_ON(1); | ||
301 | } | ||
302 | 296 | ||
303 | list_del(&qh->node); | 297 | list_del(&qh->node); |
304 | if (qh->udev) { | 298 | if (qh->udev) { |
@@ -746,11 +740,9 @@ static void uhci_free_urb_priv(struct uhci_hcd *uhci, | |||
746 | { | 740 | { |
747 | struct uhci_td *td, *tmp; | 741 | struct uhci_td *td, *tmp; |
748 | 742 | ||
749 | if (!list_empty(&urbp->node)) { | 743 | if (!list_empty(&urbp->node)) |
750 | dev_warn(uhci_dev(uhci), "urb %p still on QH's list!\n", | 744 | dev_WARN(uhci_dev(uhci), "urb %p still on QH's list!\n", |
751 | urbp->urb); | 745 | urbp->urb); |
752 | WARN_ON(1); | ||
753 | } | ||
754 | 746 | ||
755 | list_for_each_entry_safe(td, tmp, &urbp->td_list, list) { | 747 | list_for_each_entry_safe(td, tmp, &urbp->td_list, list) { |
756 | uhci_remove_td_from_urbp(td); | 748 | uhci_remove_td_from_urbp(td); |
@@ -1073,13 +1065,18 @@ static int uhci_submit_interrupt(struct uhci_hcd *uhci, struct urb *urb, | |||
1073 | } | 1065 | } |
1074 | if (exponent < 0) | 1066 | if (exponent < 0) |
1075 | return -EINVAL; | 1067 | return -EINVAL; |
1076 | qh->period = 1 << exponent; | ||
1077 | qh->skel = SKEL_INDEX(exponent); | ||
1078 | 1068 | ||
1079 | /* For now, interrupt phase is fixed by the layout | 1069 | /* If the slot is full, try a lower period */ |
1080 | * of the QH lists. */ | 1070 | do { |
1081 | qh->phase = (qh->period / 2) & (MAX_PHASE - 1); | 1071 | qh->period = 1 << exponent; |
1082 | ret = uhci_check_bandwidth(uhci, qh); | 1072 | qh->skel = SKEL_INDEX(exponent); |
1073 | |||
1074 | /* For now, interrupt phase is fixed by the layout | ||
1075 | * of the QH lists. | ||
1076 | */ | ||
1077 | qh->phase = (qh->period / 2) & (MAX_PHASE - 1); | ||
1078 | ret = uhci_check_bandwidth(uhci, qh); | ||
1079 | } while (ret != 0 && --exponent >= 0); | ||
1083 | if (ret) | 1080 | if (ret) |
1084 | return ret; | 1081 | return ret; |
1085 | } else if (qh->period > urb->interval) | 1082 | } else if (qh->period > urb->interval) |
diff --git a/drivers/usb/image/mdc800.c b/drivers/usb/image/mdc800.c index 0fb114ca1eba..878c77ca086e 100644 --- a/drivers/usb/image/mdc800.c +++ b/drivers/usb/image/mdc800.c | |||
@@ -355,13 +355,14 @@ static int mdc800_usb_waitForIRQ (int mode, int msec) | |||
355 | if (mdc800->camera_request_ready>0) | 355 | if (mdc800->camera_request_ready>0) |
356 | { | 356 | { |
357 | mdc800->camera_request_ready=0; | 357 | mdc800->camera_request_ready=0; |
358 | err ("timeout waiting for camera."); | 358 | dev_err(&mdc800->dev->dev, "timeout waiting for camera.\n"); |
359 | return -1; | 359 | return -1; |
360 | } | 360 | } |
361 | 361 | ||
362 | if (mdc800->state == NOT_CONNECTED) | 362 | if (mdc800->state == NOT_CONNECTED) |
363 | { | 363 | { |
364 | warn ("Camera gets disconnected during waiting for irq."); | 364 | printk(KERN_WARNING "mdc800: Camera gets disconnected " |
365 | "during waiting for irq.\n"); | ||
365 | mdc800->camera_request_ready=0; | 366 | mdc800->camera_request_ready=0; |
366 | return -2; | 367 | return -2; |
367 | } | 368 | } |
@@ -379,7 +380,8 @@ static void mdc800_usb_write_notify (struct urb *urb) | |||
379 | int status = urb->status; | 380 | int status = urb->status; |
380 | 381 | ||
381 | if (status != 0) | 382 | if (status != 0) |
382 | err ("writing command fails (status=%i)", status); | 383 | dev_err(&mdc800->dev->dev, |
384 | "writing command fails (status=%i)\n", status); | ||
383 | else | 385 | else |
384 | mdc800->state=READY; | 386 | mdc800->state=READY; |
385 | mdc800->written = 1; | 387 | mdc800->written = 1; |
@@ -406,7 +408,8 @@ static void mdc800_usb_download_notify (struct urb *urb) | |||
406 | mdc800->state=READY; | 408 | mdc800->state=READY; |
407 | } | 409 | } |
408 | } else { | 410 | } else { |
409 | err ("request bytes fails (status:%i)", status); | 411 | dev_err(&mdc800->dev->dev, |
412 | "request bytes fails (status:%i)\n", status); | ||
410 | } | 413 | } |
411 | mdc800->downloaded = 1; | 414 | mdc800->downloaded = 1; |
412 | wake_up (&mdc800->download_wait); | 415 | wake_up (&mdc800->download_wait); |
@@ -443,13 +446,14 @@ static int mdc800_usb_probe (struct usb_interface *intf, | |||
443 | 446 | ||
444 | if (mdc800->dev != NULL) | 447 | if (mdc800->dev != NULL) |
445 | { | 448 | { |
446 | warn ("only one Mustek MDC800 is supported."); | 449 | dev_warn(&intf->dev, "only one Mustek MDC800 is supported.\n"); |
447 | return -ENODEV; | 450 | return -ENODEV; |
448 | } | 451 | } |
449 | 452 | ||
450 | if (dev->descriptor.bNumConfigurations != 1) | 453 | if (dev->descriptor.bNumConfigurations != 1) |
451 | { | 454 | { |
452 | err ("probe fails -> wrong Number of Configuration"); | 455 | dev_err(&intf->dev, |
456 | "probe fails -> wrong Number of Configuration\n"); | ||
453 | return -ENODEV; | 457 | return -ENODEV; |
454 | } | 458 | } |
455 | intf_desc = intf->cur_altsetting; | 459 | intf_desc = intf->cur_altsetting; |
@@ -461,7 +465,7 @@ static int mdc800_usb_probe (struct usb_interface *intf, | |||
461 | || ( intf_desc->desc.bNumEndpoints != 4) | 465 | || ( intf_desc->desc.bNumEndpoints != 4) |
462 | ) | 466 | ) |
463 | { | 467 | { |
464 | err ("probe fails -> wrong Interface"); | 468 | dev_err(&intf->dev, "probe fails -> wrong Interface\n"); |
465 | return -ENODEV; | 469 | return -ENODEV; |
466 | } | 470 | } |
467 | 471 | ||
@@ -482,19 +486,19 @@ static int mdc800_usb_probe (struct usb_interface *intf, | |||
482 | } | 486 | } |
483 | if (mdc800->endpoint[i] == -1) | 487 | if (mdc800->endpoint[i] == -1) |
484 | { | 488 | { |
485 | err ("probe fails -> Wrong Endpoints."); | 489 | dev_err(&intf->dev, "probe fails -> Wrong Endpoints.\n"); |
486 | return -ENODEV; | 490 | return -ENODEV; |
487 | } | 491 | } |
488 | } | 492 | } |
489 | 493 | ||
490 | 494 | ||
491 | info ("Found Mustek MDC800 on USB."); | 495 | dev_info(&intf->dev, "Found Mustek MDC800 on USB.\n"); |
492 | 496 | ||
493 | mutex_lock(&mdc800->io_lock); | 497 | mutex_lock(&mdc800->io_lock); |
494 | 498 | ||
495 | retval = usb_register_dev(intf, &mdc800_class); | 499 | retval = usb_register_dev(intf, &mdc800_class); |
496 | if (retval) { | 500 | if (retval) { |
497 | err ("Not able to get a minor for this device."); | 501 | dev_err(&intf->dev, "Not able to get a minor for this device.\n"); |
498 | return -ENODEV; | 502 | return -ENODEV; |
499 | } | 503 | } |
500 | 504 | ||
@@ -570,7 +574,7 @@ static void mdc800_usb_disconnect (struct usb_interface *intf) | |||
570 | mdc800->dev = NULL; | 574 | mdc800->dev = NULL; |
571 | usb_set_intfdata(intf, NULL); | 575 | usb_set_intfdata(intf, NULL); |
572 | } | 576 | } |
573 | info ("Mustek MDC800 disconnected from USB."); | 577 | dev_info(&intf->dev, "Mustek MDC800 disconnected from USB.\n"); |
574 | } | 578 | } |
575 | 579 | ||
576 | 580 | ||
@@ -644,7 +648,8 @@ static int mdc800_device_open (struct inode* inode, struct file *file) | |||
644 | mdc800->irq_urb->dev = mdc800->dev; | 648 | mdc800->irq_urb->dev = mdc800->dev; |
645 | retval = usb_submit_urb (mdc800->irq_urb, GFP_KERNEL); | 649 | retval = usb_submit_urb (mdc800->irq_urb, GFP_KERNEL); |
646 | if (retval) { | 650 | if (retval) { |
647 | err ("request USB irq fails (submit_retval=%i).", retval); | 651 | dev_err(&mdc800->dev->dev, |
652 | "request USB irq fails (submit_retval=%i).\n", retval); | ||
648 | errn = -EIO; | 653 | errn = -EIO; |
649 | goto error_out; | 654 | goto error_out; |
650 | } | 655 | } |
@@ -701,7 +706,8 @@ static ssize_t mdc800_device_read (struct file *file, char __user *buf, size_t l | |||
701 | } | 706 | } |
702 | if (mdc800->state == WORKING) | 707 | if (mdc800->state == WORKING) |
703 | { | 708 | { |
704 | warn ("Illegal State \"working\" reached during read ?!"); | 709 | printk(KERN_WARNING "mdc800: Illegal State \"working\"" |
710 | "reached during read ?!\n"); | ||
705 | mutex_unlock(&mdc800->io_lock); | 711 | mutex_unlock(&mdc800->io_lock); |
706 | return -EBUSY; | 712 | return -EBUSY; |
707 | } | 713 | } |
@@ -733,7 +739,9 @@ static ssize_t mdc800_device_read (struct file *file, char __user *buf, size_t l | |||
733 | mdc800->download_urb->dev = mdc800->dev; | 739 | mdc800->download_urb->dev = mdc800->dev; |
734 | retval = usb_submit_urb (mdc800->download_urb, GFP_KERNEL); | 740 | retval = usb_submit_urb (mdc800->download_urb, GFP_KERNEL); |
735 | if (retval) { | 741 | if (retval) { |
736 | err ("Can't submit download urb (retval=%i)",retval); | 742 | dev_err(&mdc800->dev->dev, |
743 | "Can't submit download urb " | ||
744 | "(retval=%i)\n", retval); | ||
737 | mutex_unlock(&mdc800->io_lock); | 745 | mutex_unlock(&mdc800->io_lock); |
738 | return len-left; | 746 | return len-left; |
739 | } | 747 | } |
@@ -742,7 +750,10 @@ static ssize_t mdc800_device_read (struct file *file, char __user *buf, size_t l | |||
742 | mdc800->downloaded = 0; | 750 | mdc800->downloaded = 0; |
743 | if (mdc800->download_urb->status != 0) | 751 | if (mdc800->download_urb->status != 0) |
744 | { | 752 | { |
745 | err ("request download-bytes fails (status=%i)",mdc800->download_urb->status); | 753 | dev_err(&mdc800->dev->dev, |
754 | "request download-bytes fails " | ||
755 | "(status=%i)\n", | ||
756 | mdc800->download_urb->status); | ||
746 | mutex_unlock(&mdc800->io_lock); | 757 | mutex_unlock(&mdc800->io_lock); |
747 | return len-left; | 758 | return len-left; |
748 | } | 759 | } |
@@ -839,7 +850,8 @@ static ssize_t mdc800_device_write (struct file *file, const char __user *buf, s | |||
839 | 850 | ||
840 | if (mdc800_usb_waitForIRQ (0,TO_GET_READY)) | 851 | if (mdc800_usb_waitForIRQ (0,TO_GET_READY)) |
841 | { | 852 | { |
842 | err ("Camera didn't get ready.\n"); | 853 | dev_err(&mdc800->dev->dev, |
854 | "Camera didn't get ready.\n"); | ||
843 | mutex_unlock(&mdc800->io_lock); | 855 | mutex_unlock(&mdc800->io_lock); |
844 | return -EIO; | 856 | return -EIO; |
845 | } | 857 | } |
@@ -851,7 +863,9 @@ static ssize_t mdc800_device_write (struct file *file, const char __user *buf, s | |||
851 | mdc800->write_urb->dev = mdc800->dev; | 863 | mdc800->write_urb->dev = mdc800->dev; |
852 | retval = usb_submit_urb (mdc800->write_urb, GFP_KERNEL); | 864 | retval = usb_submit_urb (mdc800->write_urb, GFP_KERNEL); |
853 | if (retval) { | 865 | if (retval) { |
854 | err ("submitting write urb fails (retval=%i)", retval); | 866 | dev_err(&mdc800->dev->dev, |
867 | "submitting write urb fails " | ||
868 | "(retval=%i)\n", retval); | ||
855 | mutex_unlock(&mdc800->io_lock); | 869 | mutex_unlock(&mdc800->io_lock); |
856 | return -EIO; | 870 | return -EIO; |
857 | } | 871 | } |
@@ -870,7 +884,9 @@ static ssize_t mdc800_device_write (struct file *file, const char __user *buf, s | |||
870 | case 0x3e: /* Take shot in Fine Mode (WCam Mode) */ | 884 | case 0x3e: /* Take shot in Fine Mode (WCam Mode) */ |
871 | if (mdc800->pic_len < 0) | 885 | if (mdc800->pic_len < 0) |
872 | { | 886 | { |
873 | err ("call 0x07 before 0x05,0x3e"); | 887 | dev_err(&mdc800->dev->dev, |
888 | "call 0x07 before " | ||
889 | "0x05,0x3e\n"); | ||
874 | mdc800->state=READY; | 890 | mdc800->state=READY; |
875 | mutex_unlock(&mdc800->io_lock); | 891 | mutex_unlock(&mdc800->io_lock); |
876 | return -EIO; | 892 | return -EIO; |
@@ -890,7 +906,7 @@ static ssize_t mdc800_device_write (struct file *file, const char __user *buf, s | |||
890 | 906 | ||
891 | if (mdc800_usb_waitForIRQ (1,TO_READ_FROM_IRQ)) | 907 | if (mdc800_usb_waitForIRQ (1,TO_READ_FROM_IRQ)) |
892 | { | 908 | { |
893 | err ("requesting answer from irq fails"); | 909 | dev_err(&mdc800->dev->dev, "requesting answer from irq fails\n"); |
894 | mutex_unlock(&mdc800->io_lock); | 910 | mutex_unlock(&mdc800->io_lock); |
895 | return -EIO; | 911 | return -EIO; |
896 | } | 912 | } |
@@ -918,7 +934,7 @@ static ssize_t mdc800_device_write (struct file *file, const char __user *buf, s | |||
918 | { | 934 | { |
919 | if (mdc800_usb_waitForIRQ (0,TO_DEFAULT_COMMAND)) | 935 | if (mdc800_usb_waitForIRQ (0,TO_DEFAULT_COMMAND)) |
920 | { | 936 | { |
921 | err ("Command Timeout."); | 937 | dev_err(&mdc800->dev->dev, "Command Timeout.\n"); |
922 | mutex_unlock(&mdc800->io_lock); | 938 | mutex_unlock(&mdc800->io_lock); |
923 | return -EIO; | 939 | return -EIO; |
924 | } | 940 | } |
@@ -1018,7 +1034,8 @@ static int __init usb_mdc800_init (void) | |||
1018 | if (retval) | 1034 | if (retval) |
1019 | goto cleanup_on_fail; | 1035 | goto cleanup_on_fail; |
1020 | 1036 | ||
1021 | info (DRIVER_VERSION ":" DRIVER_DESC); | 1037 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
1038 | DRIVER_DESC "\n"); | ||
1022 | 1039 | ||
1023 | return 0; | 1040 | return 0; |
1024 | 1041 | ||
@@ -1028,7 +1045,7 @@ cleanup_on_fail: | |||
1028 | 1045 | ||
1029 | if (mdc800 != NULL) | 1046 | if (mdc800 != NULL) |
1030 | { | 1047 | { |
1031 | err ("can't alloc memory!"); | 1048 | printk(KERN_ERR "mdc800: can't alloc memory!\n"); |
1032 | 1049 | ||
1033 | kfree(mdc800->download_urb_buffer); | 1050 | kfree(mdc800->download_urb_buffer); |
1034 | kfree(mdc800->write_urb_buffer); | 1051 | kfree(mdc800->write_urb_buffer); |
diff --git a/drivers/usb/misc/Kconfig b/drivers/usb/misc/Kconfig index 4ea50e0abcbb..e463db5d8188 100644 --- a/drivers/usb/misc/Kconfig +++ b/drivers/usb/misc/Kconfig | |||
@@ -42,6 +42,15 @@ config USB_ADUTUX | |||
42 | To compile this driver as a module, choose M here. The module | 42 | To compile this driver as a module, choose M here. The module |
43 | will be called adutux. | 43 | will be called adutux. |
44 | 44 | ||
45 | config USB_SEVSEG | ||
46 | tristate "USB 7-Segment LED Display" | ||
47 | depends on USB | ||
48 | help | ||
49 | Say Y here if you have a USB 7-Segment Display by Delcom | ||
50 | |||
51 | To compile this driver as a module, choose M here: the | ||
52 | module will be called usbsevseg. | ||
53 | |||
45 | config USB_RIO500 | 54 | config USB_RIO500 |
46 | tristate "USB Diamond Rio500 support" | 55 | tristate "USB Diamond Rio500 support" |
47 | depends on USB | 56 | depends on USB |
@@ -271,3 +280,18 @@ config USB_ISIGHTFW | |||
271 | The firmware for this driver must be extracted from the MacOS | 280 | The firmware for this driver must be extracted from the MacOS |
272 | driver beforehand. Tools for doing so are available at | 281 | driver beforehand. Tools for doing so are available at |
273 | http://bersace03.free.fr | 282 | http://bersace03.free.fr |
283 | |||
284 | config USB_VST | ||
285 | tristate "USB VST driver" | ||
286 | depends on USB | ||
287 | help | ||
288 | This driver is intended for Vernier Software Technologies | ||
289 | bulk usb devices such as their Ocean-Optics spectrometers or | ||
290 | Labquest. | ||
291 | It is a bulk channel driver with configurable read and write | ||
292 | timeouts. | ||
293 | |||
294 | To compile this driver as a module, choose M here: the | ||
295 | module will be called vstusb. | ||
296 | |||
297 | |||
diff --git a/drivers/usb/misc/Makefile b/drivers/usb/misc/Makefile index 45b4e12afb08..1334f7bdd7be 100644 --- a/drivers/usb/misc/Makefile +++ b/drivers/usb/misc/Makefile | |||
@@ -26,6 +26,8 @@ obj-$(CONFIG_USB_RIO500) += rio500.o | |||
26 | obj-$(CONFIG_USB_TEST) += usbtest.o | 26 | obj-$(CONFIG_USB_TEST) += usbtest.o |
27 | obj-$(CONFIG_USB_TRANCEVIBRATOR) += trancevibrator.o | 27 | obj-$(CONFIG_USB_TRANCEVIBRATOR) += trancevibrator.o |
28 | obj-$(CONFIG_USB_USS720) += uss720.o | 28 | obj-$(CONFIG_USB_USS720) += uss720.o |
29 | obj-$(CONFIG_USB_SEVSEG) += usbsevseg.o | ||
30 | obj-$(CONFIG_USB_VST) += vstusb.o | ||
29 | 31 | ||
30 | obj-$(CONFIG_USB_SISUSBVGA) += sisusbvga/ | 32 | obj-$(CONFIG_USB_SISUSBVGA) += sisusbvga/ |
31 | 33 | ||
diff --git a/drivers/usb/misc/adutux.c b/drivers/usb/misc/adutux.c index 965f6eaea6a0..7b6922e08ed1 100644 --- a/drivers/usb/misc/adutux.c +++ b/drivers/usb/misc/adutux.c | |||
@@ -283,8 +283,8 @@ static int adu_open(struct inode *inode, struct file *file) | |||
283 | 283 | ||
284 | interface = usb_find_interface(&adu_driver, subminor); | 284 | interface = usb_find_interface(&adu_driver, subminor); |
285 | if (!interface) { | 285 | if (!interface) { |
286 | err("%s - error, can't find device for minor %d", | 286 | printk(KERN_ERR "adutux: %s - error, can't find device for " |
287 | __func__, subminor); | 287 | "minor %d\n", __func__, subminor); |
288 | retval = -ENODEV; | 288 | retval = -ENODEV; |
289 | goto exit_no_device; | 289 | goto exit_no_device; |
290 | } | 290 | } |
@@ -416,7 +416,8 @@ static ssize_t adu_read(struct file *file, __user char *buffer, size_t count, | |||
416 | /* verify that the device wasn't unplugged */ | 416 | /* verify that the device wasn't unplugged */ |
417 | if (dev->udev == NULL) { | 417 | if (dev->udev == NULL) { |
418 | retval = -ENODEV; | 418 | retval = -ENODEV; |
419 | err("No device or device unplugged %d", retval); | 419 | printk(KERN_ERR "adutux: No device or device unplugged %d\n", |
420 | retval); | ||
420 | goto exit; | 421 | goto exit; |
421 | } | 422 | } |
422 | 423 | ||
@@ -576,7 +577,8 @@ static ssize_t adu_write(struct file *file, const __user char *buffer, | |||
576 | /* verify that the device wasn't unplugged */ | 577 | /* verify that the device wasn't unplugged */ |
577 | if (dev->udev == NULL) { | 578 | if (dev->udev == NULL) { |
578 | retval = -ENODEV; | 579 | retval = -ENODEV; |
579 | err("No device or device unplugged %d", retval); | 580 | printk(KERN_ERR "adutux: No device or device unplugged %d\n", |
581 | retval); | ||
580 | goto exit; | 582 | goto exit; |
581 | } | 583 | } |
582 | 584 | ||
@@ -645,7 +647,8 @@ static ssize_t adu_write(struct file *file, const __user char *buffer, | |||
645 | retval = usb_submit_urb(dev->interrupt_out_urb, GFP_KERNEL); | 647 | retval = usb_submit_urb(dev->interrupt_out_urb, GFP_KERNEL); |
646 | if (retval < 0) { | 648 | if (retval < 0) { |
647 | dev->out_urb_finished = 1; | 649 | dev->out_urb_finished = 1; |
648 | err("Couldn't submit interrupt_out_urb %d", retval); | 650 | dev_err(&dev->udev->dev, "Couldn't submit " |
651 | "interrupt_out_urb %d\n", retval); | ||
649 | goto exit; | 652 | goto exit; |
650 | } | 653 | } |
651 | 654 | ||
@@ -890,13 +893,14 @@ static int __init adu_init(void) | |||
890 | /* register this driver with the USB subsystem */ | 893 | /* register this driver with the USB subsystem */ |
891 | result = usb_register(&adu_driver); | 894 | result = usb_register(&adu_driver); |
892 | if (result < 0) { | 895 | if (result < 0) { |
893 | err("usb_register failed for the "__FILE__" driver. " | 896 | printk(KERN_ERR "usb_register failed for the "__FILE__ |
894 | "Error number %d", result); | 897 | " driver. Error number %d\n", result); |
895 | goto exit; | 898 | goto exit; |
896 | } | 899 | } |
897 | 900 | ||
898 | info("adutux " DRIVER_DESC " " DRIVER_VERSION); | 901 | printk(KERN_INFO "adutux " DRIVER_DESC " " DRIVER_VERSION "\n"); |
899 | info("adutux is an experimental driver. Use at your own risk"); | 902 | printk(KERN_INFO "adutux is an experimental driver. " |
903 | "Use at your own risk\n"); | ||
900 | 904 | ||
901 | exit: | 905 | exit: |
902 | dbg(2," %s : leave, return value %d", __func__, result); | 906 | dbg(2," %s : leave, return value %d", __func__, result); |
diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c index a076c24a312a..1d8e39a557d9 100644 --- a/drivers/usb/misc/appledisplay.c +++ b/drivers/usb/misc/appledisplay.c | |||
@@ -130,7 +130,8 @@ static void appledisplay_complete(struct urb *urb) | |||
130 | exit: | 130 | exit: |
131 | retval = usb_submit_urb(pdata->urb, GFP_ATOMIC); | 131 | retval = usb_submit_urb(pdata->urb, GFP_ATOMIC); |
132 | if (retval) { | 132 | if (retval) { |
133 | err("%s - usb_submit_urb failed with result %d", | 133 | dev_err(&pdata->udev->dev, |
134 | "%s - usb_submit_urb failed with result %d\n", | ||
134 | __func__, retval); | 135 | __func__, retval); |
135 | } | 136 | } |
136 | } | 137 | } |
@@ -220,7 +221,7 @@ static int appledisplay_probe(struct usb_interface *iface, | |||
220 | } | 221 | } |
221 | } | 222 | } |
222 | if (!int_in_endpointAddr) { | 223 | if (!int_in_endpointAddr) { |
223 | err("Could not find int-in endpoint"); | 224 | dev_err(&iface->dev, "Could not find int-in endpoint\n"); |
224 | return -EIO; | 225 | return -EIO; |
225 | } | 226 | } |
226 | 227 | ||
@@ -228,7 +229,7 @@ static int appledisplay_probe(struct usb_interface *iface, | |||
228 | pdata = kzalloc(sizeof(struct appledisplay), GFP_KERNEL); | 229 | pdata = kzalloc(sizeof(struct appledisplay), GFP_KERNEL); |
229 | if (!pdata) { | 230 | if (!pdata) { |
230 | retval = -ENOMEM; | 231 | retval = -ENOMEM; |
231 | err("Out of memory"); | 232 | dev_err(&iface->dev, "Out of memory\n"); |
232 | goto error; | 233 | goto error; |
233 | } | 234 | } |
234 | 235 | ||
@@ -241,8 +242,8 @@ static int appledisplay_probe(struct usb_interface *iface, | |||
241 | pdata->msgdata = kmalloc(ACD_MSG_BUFFER_LEN, GFP_KERNEL); | 242 | pdata->msgdata = kmalloc(ACD_MSG_BUFFER_LEN, GFP_KERNEL); |
242 | if (!pdata->msgdata) { | 243 | if (!pdata->msgdata) { |
243 | retval = -ENOMEM; | 244 | retval = -ENOMEM; |
244 | err("appledisplay: Allocating buffer for control messages " | 245 | dev_err(&iface->dev, |
245 | "failed"); | 246 | "Allocating buffer for control messages failed\n"); |
246 | goto error; | 247 | goto error; |
247 | } | 248 | } |
248 | 249 | ||
@@ -250,7 +251,7 @@ static int appledisplay_probe(struct usb_interface *iface, | |||
250 | pdata->urb = usb_alloc_urb(0, GFP_KERNEL); | 251 | pdata->urb = usb_alloc_urb(0, GFP_KERNEL); |
251 | if (!pdata->urb) { | 252 | if (!pdata->urb) { |
252 | retval = -ENOMEM; | 253 | retval = -ENOMEM; |
253 | err("appledisplay: Allocating URB failed"); | 254 | dev_err(&iface->dev, "Allocating URB failed\n"); |
254 | goto error; | 255 | goto error; |
255 | } | 256 | } |
256 | 257 | ||
@@ -259,7 +260,7 @@ static int appledisplay_probe(struct usb_interface *iface, | |||
259 | GFP_KERNEL, &pdata->urb->transfer_dma); | 260 | GFP_KERNEL, &pdata->urb->transfer_dma); |
260 | if (!pdata->urbdata) { | 261 | if (!pdata->urbdata) { |
261 | retval = -ENOMEM; | 262 | retval = -ENOMEM; |
262 | err("appledisplay: Allocating URB buffer failed"); | 263 | dev_err(&iface->dev, "Allocating URB buffer failed\n"); |
263 | goto error; | 264 | goto error; |
264 | } | 265 | } |
265 | 266 | ||
@@ -270,7 +271,7 @@ static int appledisplay_probe(struct usb_interface *iface, | |||
270 | pdata, 1); | 271 | pdata, 1); |
271 | if (usb_submit_urb(pdata->urb, GFP_KERNEL)) { | 272 | if (usb_submit_urb(pdata->urb, GFP_KERNEL)) { |
272 | retval = -EIO; | 273 | retval = -EIO; |
273 | err("appledisplay: Submitting URB failed"); | 274 | dev_err(&iface->dev, "Submitting URB failed\n"); |
274 | goto error; | 275 | goto error; |
275 | } | 276 | } |
276 | 277 | ||
@@ -280,7 +281,7 @@ static int appledisplay_probe(struct usb_interface *iface, | |||
280 | pdata->bd = backlight_device_register(bl_name, NULL, pdata, | 281 | pdata->bd = backlight_device_register(bl_name, NULL, pdata, |
281 | &appledisplay_bl_data); | 282 | &appledisplay_bl_data); |
282 | if (IS_ERR(pdata->bd)) { | 283 | if (IS_ERR(pdata->bd)) { |
283 | err("appledisplay: Backlight registration failed"); | 284 | dev_err(&iface->dev, "Backlight registration failed\n"); |
284 | goto error; | 285 | goto error; |
285 | } | 286 | } |
286 | 287 | ||
@@ -291,7 +292,8 @@ static int appledisplay_probe(struct usb_interface *iface, | |||
291 | 292 | ||
292 | if (brightness < 0) { | 293 | if (brightness < 0) { |
293 | retval = brightness; | 294 | retval = brightness; |
294 | err("appledisplay: Error while getting initial brightness: %d", retval); | 295 | dev_err(&iface->dev, |
296 | "Error while getting initial brightness: %d\n", retval); | ||
295 | goto error; | 297 | goto error; |
296 | } | 298 | } |
297 | 299 | ||
@@ -314,7 +316,7 @@ error: | |||
314 | pdata->urbdata, pdata->urb->transfer_dma); | 316 | pdata->urbdata, pdata->urb->transfer_dma); |
315 | usb_free_urb(pdata->urb); | 317 | usb_free_urb(pdata->urb); |
316 | } | 318 | } |
317 | if (pdata->bd) | 319 | if (pdata->bd && !IS_ERR(pdata->bd)) |
318 | backlight_device_unregister(pdata->bd); | 320 | backlight_device_unregister(pdata->bd); |
319 | kfree(pdata->msgdata); | 321 | kfree(pdata->msgdata); |
320 | } | 322 | } |
@@ -352,7 +354,7 @@ static int __init appledisplay_init(void) | |||
352 | { | 354 | { |
353 | wq = create_singlethread_workqueue("appledisplay"); | 355 | wq = create_singlethread_workqueue("appledisplay"); |
354 | if (!wq) { | 356 | if (!wq) { |
355 | err("Could not create work queue\n"); | 357 | printk(KERN_ERR "appledisplay: Could not create work queue\n"); |
356 | return -ENOMEM; | 358 | return -ENOMEM; |
357 | } | 359 | } |
358 | 360 | ||
diff --git a/drivers/usb/misc/cypress_cy7c63.c b/drivers/usb/misc/cypress_cy7c63.c index 937940404b7a..5720bfef6a38 100644 --- a/drivers/usb/misc/cypress_cy7c63.c +++ b/drivers/usb/misc/cypress_cy7c63.c | |||
@@ -278,9 +278,9 @@ static int __init cypress_init(void) | |||
278 | 278 | ||
279 | /* register this driver with the USB subsystem */ | 279 | /* register this driver with the USB subsystem */ |
280 | result = usb_register(&cypress_driver); | 280 | result = usb_register(&cypress_driver); |
281 | if (result) { | 281 | if (result) |
282 | err("Function usb_register failed! Error number: %d\n", result); | 282 | printk(KERN_ERR KBUILD_MODNAME ": usb_register failed! " |
283 | } | 283 | "Error number: %d\n", result); |
284 | 284 | ||
285 | return result; | 285 | return result; |
286 | } | 286 | } |
diff --git a/drivers/usb/misc/cytherm.c b/drivers/usb/misc/cytherm.c index 1cd9e7eba93b..4fb3c38b924b 100644 --- a/drivers/usb/misc/cytherm.c +++ b/drivers/usb/misc/cytherm.c | |||
@@ -422,13 +422,14 @@ static int __init usb_cytherm_init(void) | |||
422 | int result; | 422 | int result; |
423 | 423 | ||
424 | result = usb_register(&cytherm_driver); | 424 | result = usb_register(&cytherm_driver); |
425 | if (result) | 425 | if (result) { |
426 | { | 426 | printk(KERN_ERR KBUILD_MODNAME ": usb_register failed! " |
427 | err("usb_register failed. Error number %d", result); | 427 | "Error number: %d\n", result); |
428 | return result; | 428 | return result; |
429 | } | 429 | } |
430 | 430 | ||
431 | info(DRIVER_VERSION ":" DRIVER_DESC); | 431 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
432 | DRIVER_DESC "\n"); | ||
432 | return 0; | 433 | return 0; |
433 | } | 434 | } |
434 | 435 | ||
diff --git a/drivers/usb/misc/emi26.c b/drivers/usb/misc/emi26.c index 4b994a0cd272..e762beb5f3c6 100644 --- a/drivers/usb/misc/emi26.c +++ b/drivers/usb/misc/emi26.c | |||
@@ -50,7 +50,7 @@ static int emi26_writememory (struct usb_device *dev, int address, | |||
50 | unsigned char *buffer = kmemdup(data, length, GFP_KERNEL); | 50 | unsigned char *buffer = kmemdup(data, length, GFP_KERNEL); |
51 | 51 | ||
52 | if (!buffer) { | 52 | if (!buffer) { |
53 | err("emi26: kmalloc(%d) failed.", length); | 53 | dev_err(&dev->dev, "kmalloc(%d) failed.\n", length); |
54 | return -ENOMEM; | 54 | return -ENOMEM; |
55 | } | 55 | } |
56 | /* Note: usb_control_msg returns negative value on error or length of the | 56 | /* Note: usb_control_msg returns negative value on error or length of the |
@@ -64,11 +64,11 @@ static int emi26_writememory (struct usb_device *dev, int address, | |||
64 | static int emi26_set_reset (struct usb_device *dev, unsigned char reset_bit) | 64 | static int emi26_set_reset (struct usb_device *dev, unsigned char reset_bit) |
65 | { | 65 | { |
66 | int response; | 66 | int response; |
67 | info("%s - %d", __func__, reset_bit); | 67 | dev_info(&dev->dev, "%s - %d\n", __func__, reset_bit); |
68 | /* printk(KERN_DEBUG "%s - %d", __func__, reset_bit); */ | 68 | /* printk(KERN_DEBUG "%s - %d", __func__, reset_bit); */ |
69 | response = emi26_writememory (dev, CPUCS_REG, &reset_bit, 1, 0xa0); | 69 | response = emi26_writememory (dev, CPUCS_REG, &reset_bit, 1, 0xa0); |
70 | if (response < 0) { | 70 | if (response < 0) { |
71 | err("emi26: set_reset (%d) failed", reset_bit); | 71 | dev_err(&dev->dev, "set_reset (%d) failed\n", reset_bit); |
72 | } | 72 | } |
73 | return response; | 73 | return response; |
74 | } | 74 | } |
@@ -88,7 +88,8 @@ static int emi26_load_firmware (struct usb_device *dev) | |||
88 | 88 | ||
89 | buf = kmalloc(FW_LOAD_SIZE, GFP_KERNEL); | 89 | buf = kmalloc(FW_LOAD_SIZE, GFP_KERNEL); |
90 | if (!buf) { | 90 | if (!buf) { |
91 | err( "%s - error loading firmware: error = %d", __func__, -ENOMEM); | 91 | dev_err(&dev->dev, "%s - error loading firmware: error = %d\n", |
92 | __func__, -ENOMEM); | ||
92 | err = -ENOMEM; | 93 | err = -ENOMEM; |
93 | goto wraperr; | 94 | goto wraperr; |
94 | } | 95 | } |
@@ -106,14 +107,16 @@ static int emi26_load_firmware (struct usb_device *dev) | |||
106 | &dev->dev); | 107 | &dev->dev); |
107 | if (err) { | 108 | if (err) { |
108 | nofw: | 109 | nofw: |
109 | err( "%s - request_firmware() failed", __func__); | 110 | dev_err(&dev->dev, "%s - request_firmware() failed\n", |
111 | __func__); | ||
110 | goto wraperr; | 112 | goto wraperr; |
111 | } | 113 | } |
112 | 114 | ||
113 | /* Assert reset (stop the CPU in the EMI) */ | 115 | /* Assert reset (stop the CPU in the EMI) */ |
114 | err = emi26_set_reset(dev,1); | 116 | err = emi26_set_reset(dev,1); |
115 | if (err < 0) { | 117 | if (err < 0) { |
116 | err( "%s - error loading firmware: error = %d", __func__, err); | 118 | dev_err(&dev->dev,"%s - error loading firmware: error = %d\n", |
119 | __func__, err); | ||
117 | goto wraperr; | 120 | goto wraperr; |
118 | } | 121 | } |
119 | 122 | ||
@@ -254,7 +257,7 @@ static int emi26_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
254 | { | 257 | { |
255 | struct usb_device *dev = interface_to_usbdev(intf); | 258 | struct usb_device *dev = interface_to_usbdev(intf); |
256 | 259 | ||
257 | info("%s start", __func__); | 260 | dev_info(&intf->dev, "%s start\n", __func__); |
258 | 261 | ||
259 | emi26_load_firmware(dev); | 262 | emi26_load_firmware(dev); |
260 | 263 | ||
diff --git a/drivers/usb/misc/emi62.c b/drivers/usb/misc/emi62.c index 5d859ded5bbf..602ee05ba9ff 100644 --- a/drivers/usb/misc/emi62.c +++ b/drivers/usb/misc/emi62.c | |||
@@ -73,7 +73,7 @@ static int emi62_writememory(struct usb_device *dev, int address, | |||
73 | static int emi62_set_reset (struct usb_device *dev, unsigned char reset_bit) | 73 | static int emi62_set_reset (struct usb_device *dev, unsigned char reset_bit) |
74 | { | 74 | { |
75 | int response; | 75 | int response; |
76 | info("%s - %d", __func__, reset_bit); | 76 | dev_info(&dev->dev, "%s - %d\n", __func__, reset_bit); |
77 | 77 | ||
78 | response = emi62_writememory (dev, CPUCS_REG, &reset_bit, 1, 0xa0); | 78 | response = emi62_writememory (dev, CPUCS_REG, &reset_bit, 1, 0xa0); |
79 | if (response < 0) { | 79 | if (response < 0) { |
@@ -271,7 +271,7 @@ static int emi62_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
271 | struct usb_device *dev = interface_to_usbdev(intf); | 271 | struct usb_device *dev = interface_to_usbdev(intf); |
272 | dev_dbg(&intf->dev, "emi62_probe\n"); | 272 | dev_dbg(&intf->dev, "emi62_probe\n"); |
273 | 273 | ||
274 | info("%s start", __func__); | 274 | dev_info(&intf->dev, "%s start\n", __func__); |
275 | 275 | ||
276 | emi62_load_firmware(dev); | 276 | emi62_load_firmware(dev); |
277 | 277 | ||
diff --git a/drivers/usb/misc/ftdi-elan.c b/drivers/usb/misc/ftdi-elan.c index 97c280971532..79a7668ef264 100644 --- a/drivers/usb/misc/ftdi-elan.c +++ b/drivers/usb/misc/ftdi-elan.c | |||
@@ -698,7 +698,7 @@ static ssize_t ftdi_elan_read(struct file *file, char __user *buffer, | |||
698 | int retval = usb_bulk_msg(ftdi->udev, | 698 | int retval = usb_bulk_msg(ftdi->udev, |
699 | usb_rcvbulkpipe(ftdi->udev, ftdi->bulk_in_endpointAddr), | 699 | usb_rcvbulkpipe(ftdi->udev, ftdi->bulk_in_endpointAddr), |
700 | ftdi->bulk_in_buffer, ftdi->bulk_in_size, | 700 | ftdi->bulk_in_buffer, ftdi->bulk_in_size, |
701 | &packet_bytes, msecs_to_jiffies(50)); | 701 | &packet_bytes, 50); |
702 | if (packet_bytes > 2) { | 702 | if (packet_bytes > 2) { |
703 | ftdi->bulk_in_left = packet_bytes - 2; | 703 | ftdi->bulk_in_left = packet_bytes - 2; |
704 | ftdi->bulk_in_last = 1; | 704 | ftdi->bulk_in_last = 1; |
@@ -960,7 +960,7 @@ static int ftdi_elan_respond_engine(struct usb_ftdi *ftdi) | |||
960 | int retval = usb_bulk_msg(ftdi->udev, | 960 | int retval = usb_bulk_msg(ftdi->udev, |
961 | usb_rcvbulkpipe(ftdi->udev, ftdi->bulk_in_endpointAddr), | 961 | usb_rcvbulkpipe(ftdi->udev, ftdi->bulk_in_endpointAddr), |
962 | ftdi->bulk_in_buffer, ftdi->bulk_in_size, | 962 | ftdi->bulk_in_buffer, ftdi->bulk_in_size, |
963 | &packet_bytes, msecs_to_jiffies(500)); | 963 | &packet_bytes, 500); |
964 | char diag[30 *3 + 4]; | 964 | char diag[30 *3 + 4]; |
965 | char *d = diag; | 965 | char *d = diag; |
966 | int m = packet_bytes; | 966 | int m = packet_bytes; |
@@ -1880,7 +1880,7 @@ static int ftdi_elan_flush_input_fifo(struct usb_ftdi *ftdi) | |||
1880 | int retval = usb_bulk_msg(ftdi->udev, | 1880 | int retval = usb_bulk_msg(ftdi->udev, |
1881 | usb_rcvbulkpipe(ftdi->udev, ftdi->bulk_in_endpointAddr), | 1881 | usb_rcvbulkpipe(ftdi->udev, ftdi->bulk_in_endpointAddr), |
1882 | ftdi->bulk_in_buffer, ftdi->bulk_in_size, | 1882 | ftdi->bulk_in_buffer, ftdi->bulk_in_size, |
1883 | &packet_bytes, msecs_to_jiffies(100)); | 1883 | &packet_bytes, 100); |
1884 | if (packet_bytes > 2) { | 1884 | if (packet_bytes > 2) { |
1885 | char diag[30 *3 + 4]; | 1885 | char diag[30 *3 + 4]; |
1886 | char *d = diag; | 1886 | char *d = diag; |
@@ -2067,7 +2067,7 @@ static int ftdi_elan_synchronize(struct usb_ftdi *ftdi) | |||
2067 | usb_rcvbulkpipe(ftdi->udev, | 2067 | usb_rcvbulkpipe(ftdi->udev, |
2068 | ftdi->bulk_in_endpointAddr), | 2068 | ftdi->bulk_in_endpointAddr), |
2069 | ftdi->bulk_in_buffer, ftdi->bulk_in_size, | 2069 | ftdi->bulk_in_buffer, ftdi->bulk_in_size, |
2070 | &packet_bytes, msecs_to_jiffies(500)); | 2070 | &packet_bytes, 500); |
2071 | if (packet_bytes > 2) { | 2071 | if (packet_bytes > 2) { |
2072 | char diag[30 *3 + 4]; | 2072 | char diag[30 *3 + 4]; |
2073 | char *d = diag; | 2073 | char *d = diag; |
@@ -2176,7 +2176,7 @@ static int ftdi_elan_stuck_waiting(struct usb_ftdi *ftdi) | |||
2176 | int retval = usb_bulk_msg(ftdi->udev, | 2176 | int retval = usb_bulk_msg(ftdi->udev, |
2177 | usb_rcvbulkpipe(ftdi->udev, ftdi->bulk_in_endpointAddr), | 2177 | usb_rcvbulkpipe(ftdi->udev, ftdi->bulk_in_endpointAddr), |
2178 | ftdi->bulk_in_buffer, ftdi->bulk_in_size, | 2178 | ftdi->bulk_in_buffer, ftdi->bulk_in_size, |
2179 | &packet_bytes, msecs_to_jiffies(1000)); | 2179 | &packet_bytes, 1000); |
2180 | if (packet_bytes > 2) { | 2180 | if (packet_bytes > 2) { |
2181 | char diag[30 *3 + 4]; | 2181 | char diag[30 *3 + 4]; |
2182 | char *d = diag; | 2182 | char *d = diag; |
diff --git a/drivers/usb/misc/idmouse.c b/drivers/usb/misc/idmouse.c index 4bcf7fb4e5da..6da8887538c7 100644 --- a/drivers/usb/misc/idmouse.c +++ b/drivers/usb/misc/idmouse.c | |||
@@ -403,14 +403,15 @@ static void idmouse_disconnect(struct usb_interface *interface) | |||
403 | mutex_unlock(&dev->lock); | 403 | mutex_unlock(&dev->lock); |
404 | } | 404 | } |
405 | 405 | ||
406 | info("%s disconnected", DRIVER_DESC); | 406 | dev_info(&interface->dev, "disconnected\n"); |
407 | } | 407 | } |
408 | 408 | ||
409 | static int __init usb_idmouse_init(void) | 409 | static int __init usb_idmouse_init(void) |
410 | { | 410 | { |
411 | int result; | 411 | int result; |
412 | 412 | ||
413 | info(DRIVER_DESC " " DRIVER_VERSION); | 413 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
414 | DRIVER_DESC "\n"); | ||
414 | 415 | ||
415 | /* register this driver with the USB subsystem */ | 416 | /* register this driver with the USB subsystem */ |
416 | result = usb_register(&idmouse_driver); | 417 | result = usb_register(&idmouse_driver); |
diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c index e6ca9979e3ae..a4ef77ef917d 100644 --- a/drivers/usb/misc/iowarrior.c +++ b/drivers/usb/misc/iowarrior.c | |||
@@ -19,7 +19,6 @@ | |||
19 | #include <linux/slab.h> | 19 | #include <linux/slab.h> |
20 | #include <linux/sched.h> | 20 | #include <linux/sched.h> |
21 | #include <linux/poll.h> | 21 | #include <linux/poll.h> |
22 | #include <linux/version.h> | ||
23 | #include <linux/usb/iowarrior.h> | 22 | #include <linux/usb/iowarrior.h> |
24 | 23 | ||
25 | /* Version Information */ | 24 | /* Version Information */ |
diff --git a/drivers/usb/misc/legousbtower.c b/drivers/usb/misc/legousbtower.c index 9370326a5940..ab0f3226158b 100644 --- a/drivers/usb/misc/legousbtower.c +++ b/drivers/usb/misc/legousbtower.c | |||
@@ -851,9 +851,8 @@ static int tower_probe (struct usb_interface *interface, const struct usb_device | |||
851 | 851 | ||
852 | dbg(2, "%s: enter", __func__); | 852 | dbg(2, "%s: enter", __func__); |
853 | 853 | ||
854 | if (udev == NULL) { | 854 | if (udev == NULL) |
855 | info ("udev is NULL."); | 855 | dev_info(&interface->dev, "udev is NULL.\n"); |
856 | } | ||
857 | 856 | ||
858 | /* allocate memory for our device state and initialize it */ | 857 | /* allocate memory for our device state and initialize it */ |
859 | 858 | ||
@@ -954,7 +953,9 @@ static int tower_probe (struct usb_interface *interface, const struct usb_device | |||
954 | dev->minor = interface->minor; | 953 | dev->minor = interface->minor; |
955 | 954 | ||
956 | /* let the user know what node this device is now attached to */ | 955 | /* let the user know what node this device is now attached to */ |
957 | info ("LEGO USB Tower #%d now attached to major %d minor %d", (dev->minor - LEGO_USB_TOWER_MINOR_BASE), USB_MAJOR, dev->minor); | 956 | dev_info(&interface->dev, "LEGO USB Tower #%d now attached to major " |
957 | "%d minor %d\n", (dev->minor - LEGO_USB_TOWER_MINOR_BASE), | ||
958 | USB_MAJOR, dev->minor); | ||
958 | 959 | ||
959 | /* get the firmware version and log it */ | 960 | /* get the firmware version and log it */ |
960 | result = usb_control_msg (udev, | 961 | result = usb_control_msg (udev, |
@@ -971,10 +972,10 @@ static int tower_probe (struct usb_interface *interface, const struct usb_device | |||
971 | retval = result; | 972 | retval = result; |
972 | goto error; | 973 | goto error; |
973 | } | 974 | } |
974 | info("LEGO USB Tower firmware version is %d.%d build %d", | 975 | dev_info(&interface->dev, "LEGO USB Tower firmware version is %d.%d " |
975 | get_version_reply.major, | 976 | "build %d\n", get_version_reply.major, |
976 | get_version_reply.minor, | 977 | get_version_reply.minor, |
977 | le16_to_cpu(get_version_reply.build_no)); | 978 | le16_to_cpu(get_version_reply.build_no)); |
978 | 979 | ||
979 | 980 | ||
980 | exit: | 981 | exit: |
@@ -1021,7 +1022,8 @@ static void tower_disconnect (struct usb_interface *interface) | |||
1021 | mutex_unlock(&dev->lock); | 1022 | mutex_unlock(&dev->lock); |
1022 | } | 1023 | } |
1023 | 1024 | ||
1024 | info("LEGO USB Tower #%d now disconnected", (minor - LEGO_USB_TOWER_MINOR_BASE)); | 1025 | dev_info(&interface->dev, "LEGO USB Tower #%d now disconnected\n", |
1026 | (minor - LEGO_USB_TOWER_MINOR_BASE)); | ||
1025 | 1027 | ||
1026 | dbg(2, "%s: leave", __func__); | 1028 | dbg(2, "%s: leave", __func__); |
1027 | } | 1029 | } |
@@ -1046,7 +1048,8 @@ static int __init lego_usb_tower_init(void) | |||
1046 | goto exit; | 1048 | goto exit; |
1047 | } | 1049 | } |
1048 | 1050 | ||
1049 | info(DRIVER_DESC " " DRIVER_VERSION); | 1051 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
1052 | DRIVER_DESC "\n"); | ||
1050 | 1053 | ||
1051 | exit: | 1054 | exit: |
1052 | dbg(2, "%s: leave, return value %d", __func__, retval); | 1055 | dbg(2, "%s: leave, return value %d", __func__, retval); |
diff --git a/drivers/usb/misc/phidgetkit.c b/drivers/usb/misc/phidgetkit.c index 4cfa25b0f44e..cc8e0a926f99 100644 --- a/drivers/usb/misc/phidgetkit.c +++ b/drivers/usb/misc/phidgetkit.c | |||
@@ -595,9 +595,8 @@ static int interfacekit_probe(struct usb_interface *intf, const struct usb_devic | |||
595 | } while(value); | 595 | } while(value); |
596 | kit->dev_no = bit; | 596 | kit->dev_no = bit; |
597 | 597 | ||
598 | kit->dev = device_create_drvdata(phidget_class, &kit->udev->dev, | 598 | kit->dev = device_create(phidget_class, &kit->udev->dev, MKDEV(0, 0), |
599 | MKDEV(0, 0), kit, | 599 | kit, "interfacekit%d", kit->dev_no); |
600 | "interfacekit%d", kit->dev_no); | ||
601 | if (IS_ERR(kit->dev)) { | 600 | if (IS_ERR(kit->dev)) { |
602 | rc = PTR_ERR(kit->dev); | 601 | rc = PTR_ERR(kit->dev); |
603 | kit->dev = NULL; | 602 | kit->dev = NULL; |
diff --git a/drivers/usb/misc/phidgetmotorcontrol.c b/drivers/usb/misc/phidgetmotorcontrol.c index 9b4696f21b22..38088b44349e 100644 --- a/drivers/usb/misc/phidgetmotorcontrol.c +++ b/drivers/usb/misc/phidgetmotorcontrol.c | |||
@@ -365,9 +365,8 @@ static int motorcontrol_probe(struct usb_interface *intf, const struct usb_devic | |||
365 | } while(value); | 365 | } while(value); |
366 | mc->dev_no = bit; | 366 | mc->dev_no = bit; |
367 | 367 | ||
368 | mc->dev = device_create_drvdata(phidget_class, &mc->udev->dev, | 368 | mc->dev = device_create(phidget_class, &mc->udev->dev, MKDEV(0, 0), mc, |
369 | MKDEV(0, 0), mc, | 369 | "motorcontrol%d", mc->dev_no); |
370 | "motorcontrol%d", mc->dev_no); | ||
371 | if (IS_ERR(mc->dev)) { | 370 | if (IS_ERR(mc->dev)) { |
372 | rc = PTR_ERR(mc->dev); | 371 | rc = PTR_ERR(mc->dev); |
373 | mc->dev = NULL; | 372 | mc->dev = NULL; |
diff --git a/drivers/usb/misc/phidgetservo.c b/drivers/usb/misc/phidgetservo.c index 1ca7ddb41d4d..bef6fe16364b 100644 --- a/drivers/usb/misc/phidgetservo.c +++ b/drivers/usb/misc/phidgetservo.c | |||
@@ -275,9 +275,8 @@ servo_probe(struct usb_interface *interface, const struct usb_device_id *id) | |||
275 | } while (value); | 275 | } while (value); |
276 | dev->dev_no = bit; | 276 | dev->dev_no = bit; |
277 | 277 | ||
278 | dev->dev = device_create_drvdata(phidget_class, &dev->udev->dev, | 278 | dev->dev = device_create(phidget_class, &dev->udev->dev, MKDEV(0, 0), |
279 | MKDEV(0, 0), dev, | 279 | dev, "servo%d", dev->dev_no); |
280 | "servo%d", dev->dev_no); | ||
281 | if (IS_ERR(dev->dev)) { | 280 | if (IS_ERR(dev->dev)) { |
282 | rc = PTR_ERR(dev->dev); | 281 | rc = PTR_ERR(dev->dev); |
283 | dev->dev = NULL; | 282 | dev->dev = NULL; |
diff --git a/drivers/usb/misc/rio500.c b/drivers/usb/misc/rio500.c index 248a12aacef6..deb95bb49fd1 100644 --- a/drivers/usb/misc/rio500.c +++ b/drivers/usb/misc/rio500.c | |||
@@ -89,7 +89,7 @@ static int open_rio(struct inode *inode, struct file *file) | |||
89 | 89 | ||
90 | mutex_unlock(&(rio->lock)); | 90 | mutex_unlock(&(rio->lock)); |
91 | 91 | ||
92 | info("Rio opened."); | 92 | dev_info(&rio->rio_dev->dev, "Rio opened.\n"); |
93 | 93 | ||
94 | return 0; | 94 | return 0; |
95 | } | 95 | } |
@@ -100,7 +100,7 @@ static int close_rio(struct inode *inode, struct file *file) | |||
100 | 100 | ||
101 | rio->isopen = 0; | 101 | rio->isopen = 0; |
102 | 102 | ||
103 | info("Rio closed."); | 103 | dev_info(&rio->rio_dev->dev, "Rio closed.\n"); |
104 | return 0; | 104 | return 0; |
105 | } | 105 | } |
106 | 106 | ||
@@ -451,7 +451,7 @@ static int probe_rio(struct usb_interface *intf, | |||
451 | struct rio_usb_data *rio = &rio_instance; | 451 | struct rio_usb_data *rio = &rio_instance; |
452 | int retval; | 452 | int retval; |
453 | 453 | ||
454 | info("USB Rio found at address %d", dev->devnum); | 454 | dev_info(&intf->dev, "USB Rio found at address %d\n", dev->devnum); |
455 | 455 | ||
456 | retval = usb_register_dev(intf, &usb_rio_class); | 456 | retval = usb_register_dev(intf, &usb_rio_class); |
457 | if (retval) { | 457 | if (retval) { |
@@ -503,7 +503,7 @@ static void disconnect_rio(struct usb_interface *intf) | |||
503 | kfree(rio->ibuf); | 503 | kfree(rio->ibuf); |
504 | kfree(rio->obuf); | 504 | kfree(rio->obuf); |
505 | 505 | ||
506 | info("USB Rio disconnected."); | 506 | dev_info(&intf->dev, "USB Rio disconnected.\n"); |
507 | 507 | ||
508 | rio->present = 0; | 508 | rio->present = 0; |
509 | mutex_unlock(&(rio->lock)); | 509 | mutex_unlock(&(rio->lock)); |
@@ -531,7 +531,8 @@ static int __init usb_rio_init(void) | |||
531 | if (retval) | 531 | if (retval) |
532 | goto out; | 532 | goto out; |
533 | 533 | ||
534 | info(DRIVER_VERSION ":" DRIVER_DESC); | 534 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
535 | DRIVER_DESC "\n"); | ||
535 | 536 | ||
536 | out: | 537 | out: |
537 | return retval; | 538 | return retval; |
diff --git a/drivers/usb/misc/sisusbvga/sisusb.c b/drivers/usb/misc/sisusbvga/sisusb.c index fbace41a7cba..69c34a58e205 100644 --- a/drivers/usb/misc/sisusbvga/sisusb.c +++ b/drivers/usb/misc/sisusbvga/sisusb.c | |||
@@ -3270,6 +3270,7 @@ static struct usb_device_id sisusb_table [] = { | |||
3270 | { USB_DEVICE(0x0711, 0x0900) }, | 3270 | { USB_DEVICE(0x0711, 0x0900) }, |
3271 | { USB_DEVICE(0x0711, 0x0901) }, | 3271 | { USB_DEVICE(0x0711, 0x0901) }, |
3272 | { USB_DEVICE(0x0711, 0x0902) }, | 3272 | { USB_DEVICE(0x0711, 0x0902) }, |
3273 | { USB_DEVICE(0x0711, 0x0918) }, | ||
3273 | { USB_DEVICE(0x182d, 0x021c) }, | 3274 | { USB_DEVICE(0x182d, 0x021c) }, |
3274 | { USB_DEVICE(0x182d, 0x0269) }, | 3275 | { USB_DEVICE(0x182d, 0x0269) }, |
3275 | { } | 3276 | { } |
diff --git a/drivers/usb/misc/trancevibrator.c b/drivers/usb/misc/trancevibrator.c index 03368edf3f22..2e14102955c5 100644 --- a/drivers/usb/misc/trancevibrator.c +++ b/drivers/usb/misc/trancevibrator.c | |||
@@ -144,7 +144,8 @@ static int __init tv_init(void) | |||
144 | return retval; | 144 | return retval; |
145 | } | 145 | } |
146 | 146 | ||
147 | info(DRIVER_VERSION ":" DRIVER_DESC); | 147 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
148 | DRIVER_DESC "\n"); | ||
148 | return 0; | 149 | return 0; |
149 | } | 150 | } |
150 | 151 | ||
diff --git a/drivers/usb/misc/usblcd.c b/drivers/usb/misc/usblcd.c index 2db4228fbb01..e0ff9ccd866b 100644 --- a/drivers/usb/misc/usblcd.c +++ b/drivers/usb/misc/usblcd.c | |||
@@ -311,7 +311,7 @@ static int lcd_probe(struct usb_interface *interface, const struct usb_device_id | |||
311 | dev->interface = interface; | 311 | dev->interface = interface; |
312 | 312 | ||
313 | if (le16_to_cpu(dev->udev->descriptor.idProduct) != 0x0001) { | 313 | if (le16_to_cpu(dev->udev->descriptor.idProduct) != 0x0001) { |
314 | warn(KERN_INFO "USBLCD model not supported."); | 314 | dev_warn(&interface->dev, "USBLCD model not supported.\n"); |
315 | return -ENODEV; | 315 | return -ENODEV; |
316 | } | 316 | } |
317 | 317 | ||
@@ -359,12 +359,13 @@ static int lcd_probe(struct usb_interface *interface, const struct usb_device_id | |||
359 | 359 | ||
360 | i = le16_to_cpu(dev->udev->descriptor.bcdDevice); | 360 | i = le16_to_cpu(dev->udev->descriptor.bcdDevice); |
361 | 361 | ||
362 | info("USBLCD Version %1d%1d.%1d%1d found at address %d", | 362 | dev_info(&interface->dev, "USBLCD Version %1d%1d.%1d%1d found " |
363 | (i & 0xF000)>>12,(i & 0xF00)>>8,(i & 0xF0)>>4,(i & 0xF), | 363 | "at address %d\n", (i & 0xF000)>>12, (i & 0xF00)>>8, |
364 | dev->udev->devnum); | 364 | (i & 0xF0)>>4,(i & 0xF), dev->udev->devnum); |
365 | 365 | ||
366 | /* let the user know what node this device is now attached to */ | 366 | /* let the user know what node this device is now attached to */ |
367 | info("USB LCD device now attached to USBLCD-%d", interface->minor); | 367 | dev_info(&interface->dev, "USB LCD device now attached to USBLCD-%d\n", |
368 | interface->minor); | ||
368 | return 0; | 369 | return 0; |
369 | 370 | ||
370 | error: | 371 | error: |
@@ -413,7 +414,7 @@ static void lcd_disconnect(struct usb_interface *interface) | |||
413 | /* decrement our usage count */ | 414 | /* decrement our usage count */ |
414 | kref_put(&dev->kref, lcd_delete); | 415 | kref_put(&dev->kref, lcd_delete); |
415 | 416 | ||
416 | info("USB LCD #%d now disconnected", minor); | 417 | dev_info(&interface->dev, "USB LCD #%d now disconnected\n", minor); |
417 | } | 418 | } |
418 | 419 | ||
419 | static struct usb_driver lcd_driver = { | 420 | static struct usb_driver lcd_driver = { |
diff --git a/drivers/usb/misc/usbsevseg.c b/drivers/usb/misc/usbsevseg.c new file mode 100644 index 000000000000..28a6a3a09538 --- /dev/null +++ b/drivers/usb/misc/usbsevseg.c | |||
@@ -0,0 +1,394 @@ | |||
1 | /* | ||
2 | * USB 7 Segment Driver | ||
3 | * | ||
4 | * Copyright (C) 2008 Harrison Metzger <harrisonmetz@gmail.com> | ||
5 | * Based on usbled.c by Greg Kroah-Hartman (greg@kroah.com) | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License as | ||
9 | * published by the Free Software Foundation, version 2. | ||
10 | * | ||
11 | */ | ||
12 | |||
13 | #include <linux/kernel.h> | ||
14 | #include <linux/errno.h> | ||
15 | #include <linux/init.h> | ||
16 | #include <linux/slab.h> | ||
17 | #include <linux/module.h> | ||
18 | #include <linux/string.h> | ||
19 | #include <linux/usb.h> | ||
20 | |||
21 | |||
22 | #define DRIVER_AUTHOR "Harrison Metzger <harrisonmetz@gmail.com>" | ||
23 | #define DRIVER_DESC "USB 7 Segment Driver" | ||
24 | |||
25 | #define VENDOR_ID 0x0fc5 | ||
26 | #define PRODUCT_ID 0x1227 | ||
27 | #define MAXLEN 6 | ||
28 | |||
29 | /* table of devices that work with this driver */ | ||
30 | static struct usb_device_id id_table[] = { | ||
31 | { USB_DEVICE(VENDOR_ID, PRODUCT_ID) }, | ||
32 | { }, | ||
33 | }; | ||
34 | MODULE_DEVICE_TABLE(usb, id_table); | ||
35 | |||
36 | /* the different text display modes the device is capable of */ | ||
37 | static char *display_textmodes[] = {"raw", "hex", "ascii", NULL}; | ||
38 | |||
39 | struct usb_sevsegdev { | ||
40 | struct usb_device *udev; | ||
41 | |||
42 | u8 powered; | ||
43 | u8 mode_msb; | ||
44 | u8 mode_lsb; | ||
45 | u8 decimals[MAXLEN]; | ||
46 | u8 textmode; | ||
47 | u8 text[MAXLEN]; | ||
48 | u16 textlength; | ||
49 | }; | ||
50 | |||
51 | /* sysfs_streq can't replace this completely | ||
52 | * If the device was in hex mode, and the user wanted a 0, | ||
53 | * if str commands are used, we would assume the end of string | ||
54 | * so mem commands are used. | ||
55 | */ | ||
56 | inline size_t my_memlen(const char *buf, size_t count) | ||
57 | { | ||
58 | if (count > 0 && buf[count-1] == '\n') | ||
59 | return count - 1; | ||
60 | else | ||
61 | return count; | ||
62 | } | ||
63 | |||
64 | static void update_display_powered(struct usb_sevsegdev *mydev) | ||
65 | { | ||
66 | int rc; | ||
67 | |||
68 | rc = usb_control_msg(mydev->udev, | ||
69 | usb_sndctrlpipe(mydev->udev, 0), | ||
70 | 0x12, | ||
71 | 0x48, | ||
72 | (80 * 0x100) + 10, /* (power mode) */ | ||
73 | (0x00 * 0x100) + (mydev->powered ? 1 : 0), | ||
74 | NULL, | ||
75 | 0, | ||
76 | 2000); | ||
77 | if (rc < 0) | ||
78 | dev_dbg(&mydev->udev->dev, "power retval = %d\n", rc); | ||
79 | } | ||
80 | |||
81 | static void update_display_mode(struct usb_sevsegdev *mydev) | ||
82 | { | ||
83 | int rc; | ||
84 | |||
85 | rc = usb_control_msg(mydev->udev, | ||
86 | usb_sndctrlpipe(mydev->udev, 0), | ||
87 | 0x12, | ||
88 | 0x48, | ||
89 | (82 * 0x100) + 10, /* (set mode) */ | ||
90 | (mydev->mode_msb * 0x100) + mydev->mode_lsb, | ||
91 | NULL, | ||
92 | 0, | ||
93 | 2000); | ||
94 | |||
95 | if (rc < 0) | ||
96 | dev_dbg(&mydev->udev->dev, "mode retval = %d\n", rc); | ||
97 | } | ||
98 | |||
99 | static void update_display_visual(struct usb_sevsegdev *mydev) | ||
100 | { | ||
101 | int rc; | ||
102 | int i; | ||
103 | unsigned char *buffer; | ||
104 | u8 decimals = 0; | ||
105 | |||
106 | buffer = kzalloc(MAXLEN, GFP_KERNEL); | ||
107 | if (!buffer) { | ||
108 | dev_err(&mydev->udev->dev, "out of memory\n"); | ||
109 | return; | ||
110 | } | ||
111 | |||
112 | /* The device is right to left, where as you write left to right */ | ||
113 | for (i = 0; i < mydev->textlength; i++) | ||
114 | buffer[i] = mydev->text[mydev->textlength-1-i]; | ||
115 | |||
116 | rc = usb_control_msg(mydev->udev, | ||
117 | usb_sndctrlpipe(mydev->udev, 0), | ||
118 | 0x12, | ||
119 | 0x48, | ||
120 | (85 * 0x100) + 10, /* (write text) */ | ||
121 | (0 * 0x100) + mydev->textmode, /* mode */ | ||
122 | buffer, | ||
123 | mydev->textlength, | ||
124 | 2000); | ||
125 | |||
126 | if (rc < 0) | ||
127 | dev_dbg(&mydev->udev->dev, "write retval = %d\n", rc); | ||
128 | |||
129 | kfree(buffer); | ||
130 | |||
131 | /* The device is right to left, where as you write left to right */ | ||
132 | for (i = 0; i < sizeof(mydev->decimals); i++) | ||
133 | decimals |= mydev->decimals[i] << i; | ||
134 | |||
135 | rc = usb_control_msg(mydev->udev, | ||
136 | usb_sndctrlpipe(mydev->udev, 0), | ||
137 | 0x12, | ||
138 | 0x48, | ||
139 | (86 * 0x100) + 10, /* (set decimal) */ | ||
140 | (0 * 0x100) + decimals, /* decimals */ | ||
141 | NULL, | ||
142 | 0, | ||
143 | 2000); | ||
144 | |||
145 | if (rc < 0) | ||
146 | dev_dbg(&mydev->udev->dev, "decimal retval = %d\n", rc); | ||
147 | } | ||
148 | |||
149 | #define MYDEV_ATTR_SIMPLE_UNSIGNED(name, update_fcn) \ | ||
150 | static ssize_t show_attr_##name(struct device *dev, \ | ||
151 | struct device_attribute *attr, char *buf) \ | ||
152 | { \ | ||
153 | struct usb_interface *intf = to_usb_interface(dev); \ | ||
154 | struct usb_sevsegdev *mydev = usb_get_intfdata(intf); \ | ||
155 | \ | ||
156 | return sprintf(buf, "%u\n", mydev->name); \ | ||
157 | } \ | ||
158 | \ | ||
159 | static ssize_t set_attr_##name(struct device *dev, \ | ||
160 | struct device_attribute *attr, const char *buf, size_t count) \ | ||
161 | { \ | ||
162 | struct usb_interface *intf = to_usb_interface(dev); \ | ||
163 | struct usb_sevsegdev *mydev = usb_get_intfdata(intf); \ | ||
164 | \ | ||
165 | mydev->name = simple_strtoul(buf, NULL, 10); \ | ||
166 | update_fcn(mydev); \ | ||
167 | \ | ||
168 | return count; \ | ||
169 | } \ | ||
170 | static DEVICE_ATTR(name, S_IWUGO | S_IRUGO, show_attr_##name, set_attr_##name); | ||
171 | |||
172 | static ssize_t show_attr_text(struct device *dev, | ||
173 | struct device_attribute *attr, char *buf) | ||
174 | { | ||
175 | struct usb_interface *intf = to_usb_interface(dev); | ||
176 | struct usb_sevsegdev *mydev = usb_get_intfdata(intf); | ||
177 | |||
178 | return snprintf(buf, mydev->textlength, "%s\n", mydev->text); | ||
179 | } | ||
180 | |||
181 | static ssize_t set_attr_text(struct device *dev, | ||
182 | struct device_attribute *attr, const char *buf, size_t count) | ||
183 | { | ||
184 | struct usb_interface *intf = to_usb_interface(dev); | ||
185 | struct usb_sevsegdev *mydev = usb_get_intfdata(intf); | ||
186 | size_t end = my_memlen(buf, count); | ||
187 | |||
188 | if (end > sizeof(mydev->text)) | ||
189 | return -EINVAL; | ||
190 | |||
191 | memset(mydev->text, 0, sizeof(mydev->text)); | ||
192 | mydev->textlength = end; | ||
193 | |||
194 | if (end > 0) | ||
195 | memcpy(mydev->text, buf, end); | ||
196 | |||
197 | update_display_visual(mydev); | ||
198 | return count; | ||
199 | } | ||
200 | |||
201 | static DEVICE_ATTR(text, S_IWUGO | S_IRUGO, show_attr_text, set_attr_text); | ||
202 | |||
203 | static ssize_t show_attr_decimals(struct device *dev, | ||
204 | struct device_attribute *attr, char *buf) | ||
205 | { | ||
206 | struct usb_interface *intf = to_usb_interface(dev); | ||
207 | struct usb_sevsegdev *mydev = usb_get_intfdata(intf); | ||
208 | int i; | ||
209 | int pos; | ||
210 | |||
211 | for (i = 0; i < sizeof(mydev->decimals); i++) { | ||
212 | pos = sizeof(mydev->decimals) - 1 - i; | ||
213 | if (mydev->decimals[i] == 0) | ||
214 | buf[pos] = '0'; | ||
215 | else if (mydev->decimals[i] == 1) | ||
216 | buf[pos] = '1'; | ||
217 | else | ||
218 | buf[pos] = 'x'; | ||
219 | } | ||
220 | |||
221 | buf[sizeof(mydev->decimals)] = '\n'; | ||
222 | return sizeof(mydev->decimals) + 1; | ||
223 | } | ||
224 | |||
225 | static ssize_t set_attr_decimals(struct device *dev, | ||
226 | struct device_attribute *attr, const char *buf, size_t count) | ||
227 | { | ||
228 | struct usb_interface *intf = to_usb_interface(dev); | ||
229 | struct usb_sevsegdev *mydev = usb_get_intfdata(intf); | ||
230 | size_t end = my_memlen(buf, count); | ||
231 | int i; | ||
232 | |||
233 | if (end > sizeof(mydev->decimals)) | ||
234 | return -EINVAL; | ||
235 | |||
236 | for (i = 0; i < end; i++) | ||
237 | if (buf[i] != '0' && buf[i] != '1') | ||
238 | return -EINVAL; | ||
239 | |||
240 | memset(mydev->decimals, 0, sizeof(mydev->decimals)); | ||
241 | for (i = 0; i < end; i++) | ||
242 | if (buf[i] == '1') | ||
243 | mydev->decimals[end-1-i] = 1; | ||
244 | |||
245 | update_display_visual(mydev); | ||
246 | |||
247 | return count; | ||
248 | } | ||
249 | |||
250 | static DEVICE_ATTR(decimals, S_IWUGO | S_IRUGO, | ||
251 | show_attr_decimals, set_attr_decimals); | ||
252 | |||
253 | static ssize_t show_attr_textmode(struct device *dev, | ||
254 | struct device_attribute *attr, char *buf) | ||
255 | { | ||
256 | struct usb_interface *intf = to_usb_interface(dev); | ||
257 | struct usb_sevsegdev *mydev = usb_get_intfdata(intf); | ||
258 | int i; | ||
259 | |||
260 | buf[0] = 0; | ||
261 | |||
262 | for (i = 0; display_textmodes[i]; i++) { | ||
263 | if (mydev->textmode == i) { | ||
264 | strcat(buf, " ["); | ||
265 | strcat(buf, display_textmodes[i]); | ||
266 | strcat(buf, "] "); | ||
267 | } else { | ||
268 | strcat(buf, " "); | ||
269 | strcat(buf, display_textmodes[i]); | ||
270 | strcat(buf, " "); | ||
271 | } | ||
272 | } | ||
273 | strcat(buf, "\n"); | ||
274 | |||
275 | |||
276 | return strlen(buf); | ||
277 | } | ||
278 | |||
279 | static ssize_t set_attr_textmode(struct device *dev, | ||
280 | struct device_attribute *attr, const char *buf, size_t count) | ||
281 | { | ||
282 | struct usb_interface *intf = to_usb_interface(dev); | ||
283 | struct usb_sevsegdev *mydev = usb_get_intfdata(intf); | ||
284 | int i; | ||
285 | |||
286 | for (i = 0; display_textmodes[i]; i++) { | ||
287 | if (sysfs_streq(display_textmodes[i], buf)) { | ||
288 | mydev->textmode = i; | ||
289 | update_display_visual(mydev); | ||
290 | return count; | ||
291 | } | ||
292 | } | ||
293 | |||
294 | return -EINVAL; | ||
295 | } | ||
296 | |||
297 | static DEVICE_ATTR(textmode, S_IWUGO | S_IRUGO, | ||
298 | show_attr_textmode, set_attr_textmode); | ||
299 | |||
300 | |||
301 | MYDEV_ATTR_SIMPLE_UNSIGNED(powered, update_display_powered); | ||
302 | MYDEV_ATTR_SIMPLE_UNSIGNED(mode_msb, update_display_mode); | ||
303 | MYDEV_ATTR_SIMPLE_UNSIGNED(mode_lsb, update_display_mode); | ||
304 | |||
305 | static struct attribute *dev_attrs[] = { | ||
306 | &dev_attr_powered.attr, | ||
307 | &dev_attr_text.attr, | ||
308 | &dev_attr_textmode.attr, | ||
309 | &dev_attr_decimals.attr, | ||
310 | &dev_attr_mode_msb.attr, | ||
311 | &dev_attr_mode_lsb.attr, | ||
312 | NULL | ||
313 | }; | ||
314 | |||
315 | static struct attribute_group dev_attr_grp = { | ||
316 | .attrs = dev_attrs, | ||
317 | }; | ||
318 | |||
319 | static int sevseg_probe(struct usb_interface *interface, | ||
320 | const struct usb_device_id *id) | ||
321 | { | ||
322 | struct usb_device *udev = interface_to_usbdev(interface); | ||
323 | struct usb_sevsegdev *mydev = NULL; | ||
324 | int rc = -ENOMEM; | ||
325 | |||
326 | mydev = kzalloc(sizeof(struct usb_sevsegdev), GFP_KERNEL); | ||
327 | if (mydev == NULL) { | ||
328 | dev_err(&interface->dev, "Out of memory\n"); | ||
329 | goto error_mem; | ||
330 | } | ||
331 | |||
332 | mydev->udev = usb_get_dev(udev); | ||
333 | usb_set_intfdata(interface, mydev); | ||
334 | |||
335 | /*set defaults */ | ||
336 | mydev->textmode = 0x02; /* ascii mode */ | ||
337 | mydev->mode_msb = 0x06; /* 6 characters */ | ||
338 | mydev->mode_lsb = 0x3f; /* scanmode for 6 chars */ | ||
339 | |||
340 | rc = sysfs_create_group(&interface->dev.kobj, &dev_attr_grp); | ||
341 | if (rc) | ||
342 | goto error; | ||
343 | |||
344 | dev_info(&interface->dev, "USB 7 Segment device now attached\n"); | ||
345 | return 0; | ||
346 | |||
347 | error: | ||
348 | usb_set_intfdata(interface, NULL); | ||
349 | usb_put_dev(mydev->udev); | ||
350 | kfree(mydev); | ||
351 | error_mem: | ||
352 | return rc; | ||
353 | } | ||
354 | |||
355 | static void sevseg_disconnect(struct usb_interface *interface) | ||
356 | { | ||
357 | struct usb_sevsegdev *mydev; | ||
358 | |||
359 | mydev = usb_get_intfdata(interface); | ||
360 | sysfs_remove_group(&interface->dev.kobj, &dev_attr_grp); | ||
361 | usb_set_intfdata(interface, NULL); | ||
362 | usb_put_dev(mydev->udev); | ||
363 | kfree(mydev); | ||
364 | dev_info(&interface->dev, "USB 7 Segment now disconnected\n"); | ||
365 | } | ||
366 | |||
367 | static struct usb_driver sevseg_driver = { | ||
368 | .name = "usbsevseg", | ||
369 | .probe = sevseg_probe, | ||
370 | .disconnect = sevseg_disconnect, | ||
371 | .id_table = id_table, | ||
372 | }; | ||
373 | |||
374 | static int __init usb_sevseg_init(void) | ||
375 | { | ||
376 | int rc = 0; | ||
377 | |||
378 | rc = usb_register(&sevseg_driver); | ||
379 | if (rc) | ||
380 | err("usb_register failed. Error number %d", rc); | ||
381 | return rc; | ||
382 | } | ||
383 | |||
384 | static void __exit usb_sevseg_exit(void) | ||
385 | { | ||
386 | usb_deregister(&sevseg_driver); | ||
387 | } | ||
388 | |||
389 | module_init(usb_sevseg_init); | ||
390 | module_exit(usb_sevseg_exit); | ||
391 | |||
392 | MODULE_AUTHOR(DRIVER_AUTHOR); | ||
393 | MODULE_DESCRIPTION(DRIVER_DESC); | ||
394 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/usb/misc/uss720.c b/drivers/usb/misc/uss720.c index f1255b0a182d..9a6c27a01793 100644 --- a/drivers/usb/misc/uss720.c +++ b/drivers/usb/misc/uss720.c | |||
@@ -228,11 +228,12 @@ static int get_1284_register(struct parport *pp, unsigned char reg, unsigned cha | |||
228 | ret = rq->urb->status; | 228 | ret = rq->urb->status; |
229 | *val = priv->reg[(reg >= 9) ? 0 : regindex[reg]]; | 229 | *val = priv->reg[(reg >= 9) ? 0 : regindex[reg]]; |
230 | if (ret) | 230 | if (ret) |
231 | warn("get_1284_register: usb error %d", ret); | 231 | printk(KERN_WARNING "get_1284_register: " |
232 | "usb error %d\n", ret); | ||
232 | kref_put(&rq->ref_count, destroy_async); | 233 | kref_put(&rq->ref_count, destroy_async); |
233 | return ret; | 234 | return ret; |
234 | } | 235 | } |
235 | warn("get_1284_register timeout"); | 236 | printk(KERN_WARNING "get_1284_register timeout\n"); |
236 | kill_all_async_requests_priv(priv); | 237 | kill_all_async_requests_priv(priv); |
237 | return -EIO; | 238 | return -EIO; |
238 | } | 239 | } |
@@ -716,7 +717,7 @@ static int uss720_probe(struct usb_interface *intf, | |||
716 | spin_lock_init(&priv->asynclock); | 717 | spin_lock_init(&priv->asynclock); |
717 | INIT_LIST_HEAD(&priv->asynclist); | 718 | INIT_LIST_HEAD(&priv->asynclist); |
718 | if (!(pp = parport_register_port(0, PARPORT_IRQ_NONE, PARPORT_DMA_NONE, &parport_uss720_ops))) { | 719 | if (!(pp = parport_register_port(0, PARPORT_IRQ_NONE, PARPORT_DMA_NONE, &parport_uss720_ops))) { |
719 | warn("could not register parport"); | 720 | printk(KERN_WARNING "uss720: could not register parport\n"); |
720 | goto probe_abort; | 721 | goto probe_abort; |
721 | } | 722 | } |
722 | 723 | ||
@@ -800,10 +801,14 @@ static int __init uss720_init(void) | |||
800 | if (retval) | 801 | if (retval) |
801 | goto out; | 802 | goto out; |
802 | 803 | ||
803 | info(DRIVER_VERSION ":" DRIVER_DESC); | 804 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
804 | info("NOTE: this is a special purpose driver to allow nonstandard"); | 805 | DRIVER_DESC "\n"); |
805 | info("protocols (eg. bitbang) over USS720 usb to parallel cables"); | 806 | printk(KERN_INFO KBUILD_MODNAME ": NOTE: this is a special purpose " |
806 | info("If you just want to connect to a printer, use usblp instead"); | 807 | "driver to allow nonstandard\n"); |
808 | printk(KERN_INFO KBUILD_MODNAME ": protocols (eg. bitbang) over " | ||
809 | "USS720 usb to parallel cables\n"); | ||
810 | printk(KERN_INFO KBUILD_MODNAME ": If you just want to connect to a " | ||
811 | "printer, use usblp instead\n"); | ||
807 | out: | 812 | out: |
808 | return retval; | 813 | return retval; |
809 | } | 814 | } |
diff --git a/drivers/usb/misc/vstusb.c b/drivers/usb/misc/vstusb.c new file mode 100644 index 000000000000..8648470c81ca --- /dev/null +++ b/drivers/usb/misc/vstusb.c | |||
@@ -0,0 +1,782 @@ | |||
1 | /***************************************************************************** | ||
2 | * File: drivers/usb/misc/vstusb.c | ||
3 | * | ||
4 | * Purpose: Support for the bulk USB Vernier Spectrophotometers | ||
5 | * | ||
6 | * Author: Johnnie Peters | ||
7 | * Axian Consulting | ||
8 | * Beaverton, OR, USA 97005 | ||
9 | * | ||
10 | * Modified by: EQware Engineering, Inc. | ||
11 | * Oregon City, OR, USA 97045 | ||
12 | * | ||
13 | * Copyright: 2007, 2008 | ||
14 | * Vernier Software & Technology | ||
15 | * Beaverton, OR, USA 97005 | ||
16 | * | ||
17 | * Web: www.vernier.com | ||
18 | * | ||
19 | * This program is free software; you can redistribute it and/or modify | ||
20 | * it under the terms of the GNU General Public License version 2 as | ||
21 | * published by the Free Software Foundation. | ||
22 | * | ||
23 | *****************************************************************************/ | ||
24 | #include <linux/kernel.h> | ||
25 | #include <linux/errno.h> | ||
26 | #include <linux/init.h> | ||
27 | #include <linux/slab.h> | ||
28 | #include <linux/module.h> | ||
29 | #include <linux/mutex.h> | ||
30 | #include <linux/uaccess.h> | ||
31 | #include <linux/usb.h> | ||
32 | |||
33 | #include <linux/usb/vstusb.h> | ||
34 | |||
35 | #define DRIVER_VERSION "VST USB Driver Version 1.5" | ||
36 | #define DRIVER_DESC "Vernier Software Technology Bulk USB Driver" | ||
37 | |||
38 | #ifdef CONFIG_USB_DYNAMIC_MINORS | ||
39 | #define VSTUSB_MINOR_BASE 0 | ||
40 | #else | ||
41 | #define VSTUSB_MINOR_BASE 199 | ||
42 | #endif | ||
43 | |||
44 | #define USB_VENDOR_OCEANOPTICS 0x2457 | ||
45 | #define USB_VENDOR_VERNIER 0x08F7 /* Vernier Software & Technology */ | ||
46 | |||
47 | #define USB_PRODUCT_USB2000 0x1002 | ||
48 | #define USB_PRODUCT_ADC1000_FW 0x1003 /* firmware download (renumerates) */ | ||
49 | #define USB_PRODUCT_ADC1000 0x1004 | ||
50 | #define USB_PRODUCT_HR2000_FW 0x1009 /* firmware download (renumerates) */ | ||
51 | #define USB_PRODUCT_HR2000 0x100A | ||
52 | #define USB_PRODUCT_HR4000_FW 0x1011 /* firmware download (renumerates) */ | ||
53 | #define USB_PRODUCT_HR4000 0x1012 | ||
54 | #define USB_PRODUCT_USB650 0x1014 /* "Red Tide" */ | ||
55 | #define USB_PRODUCT_QE65000 0x1018 | ||
56 | #define USB_PRODUCT_USB4000 0x1022 | ||
57 | #define USB_PRODUCT_USB325 0x1024 /* "Vernier Spectrometer" */ | ||
58 | |||
59 | #define USB_PRODUCT_LABPRO 0x0001 | ||
60 | #define USB_PRODUCT_LABQUEST 0x0005 | ||
61 | |||
62 | #define VST_MAXBUFFER (64*1024) | ||
63 | |||
64 | static struct usb_device_id id_table[] = { | ||
65 | { USB_DEVICE(USB_VENDOR_OCEANOPTICS, USB_PRODUCT_USB2000)}, | ||
66 | { USB_DEVICE(USB_VENDOR_OCEANOPTICS, USB_PRODUCT_HR4000)}, | ||
67 | { USB_DEVICE(USB_VENDOR_OCEANOPTICS, USB_PRODUCT_USB650)}, | ||
68 | { USB_DEVICE(USB_VENDOR_OCEANOPTICS, USB_PRODUCT_USB4000)}, | ||
69 | { USB_DEVICE(USB_VENDOR_OCEANOPTICS, USB_PRODUCT_USB325)}, | ||
70 | { USB_DEVICE(USB_VENDOR_VERNIER, USB_PRODUCT_LABQUEST)}, | ||
71 | { USB_DEVICE(USB_VENDOR_VERNIER, USB_PRODUCT_LABPRO)}, | ||
72 | {}, | ||
73 | }; | ||
74 | |||
75 | MODULE_DEVICE_TABLE(usb, id_table); | ||
76 | |||
77 | struct vstusb_device { | ||
78 | struct kref kref; | ||
79 | struct mutex lock; | ||
80 | struct usb_device *usb_dev; | ||
81 | char present; | ||
82 | char isopen; | ||
83 | struct usb_anchor submitted; | ||
84 | int rd_pipe; | ||
85 | int rd_timeout_ms; | ||
86 | int wr_pipe; | ||
87 | int wr_timeout_ms; | ||
88 | }; | ||
89 | #define to_vst_dev(d) container_of(d, struct vstusb_device, kref) | ||
90 | |||
91 | static struct usb_driver vstusb_driver; | ||
92 | |||
93 | static void vstusb_delete(struct kref *kref) | ||
94 | { | ||
95 | struct vstusb_device *vstdev = to_vst_dev(kref); | ||
96 | |||
97 | usb_put_dev(vstdev->usb_dev); | ||
98 | kfree(vstdev); | ||
99 | } | ||
100 | |||
101 | static int vstusb_open(struct inode *inode, struct file *file) | ||
102 | { | ||
103 | struct vstusb_device *vstdev; | ||
104 | struct usb_interface *interface; | ||
105 | |||
106 | interface = usb_find_interface(&vstusb_driver, iminor(inode)); | ||
107 | |||
108 | if (!interface) { | ||
109 | printk(KERN_ERR KBUILD_MODNAME | ||
110 | ": %s - error, can't find device for minor %d\n", | ||
111 | __func__, iminor(inode)); | ||
112 | return -ENODEV; | ||
113 | } | ||
114 | |||
115 | vstdev = usb_get_intfdata(interface); | ||
116 | |||
117 | if (!vstdev) | ||
118 | return -ENODEV; | ||
119 | |||
120 | /* lock this device */ | ||
121 | mutex_lock(&vstdev->lock); | ||
122 | |||
123 | /* can only open one time */ | ||
124 | if ((!vstdev->present) || (vstdev->isopen)) { | ||
125 | mutex_unlock(&vstdev->lock); | ||
126 | return -EBUSY; | ||
127 | } | ||
128 | |||
129 | /* increment our usage count */ | ||
130 | kref_get(&vstdev->kref); | ||
131 | |||
132 | vstdev->isopen = 1; | ||
133 | |||
134 | /* save device in the file's private structure */ | ||
135 | file->private_data = vstdev; | ||
136 | |||
137 | dev_dbg(&vstdev->usb_dev->dev, "%s: opened\n", __func__); | ||
138 | |||
139 | mutex_unlock(&vstdev->lock); | ||
140 | |||
141 | return 0; | ||
142 | } | ||
143 | |||
144 | static int vstusb_release(struct inode *inode, struct file *file) | ||
145 | { | ||
146 | struct vstusb_device *vstdev; | ||
147 | |||
148 | vstdev = file->private_data; | ||
149 | |||
150 | if (vstdev == NULL) | ||
151 | return -ENODEV; | ||
152 | |||
153 | mutex_lock(&vstdev->lock); | ||
154 | |||
155 | vstdev->isopen = 0; | ||
156 | |||
157 | dev_dbg(&vstdev->usb_dev->dev, "%s: released\n", __func__); | ||
158 | |||
159 | mutex_unlock(&vstdev->lock); | ||
160 | |||
161 | kref_put(&vstdev->kref, vstusb_delete); | ||
162 | |||
163 | return 0; | ||
164 | } | ||
165 | |||
166 | static void usb_api_blocking_completion(struct urb *urb) | ||
167 | { | ||
168 | struct completion *completeit = urb->context; | ||
169 | |||
170 | complete(completeit); | ||
171 | } | ||
172 | |||
173 | static int vstusb_fill_and_send_urb(struct urb *urb, | ||
174 | struct usb_device *usb_dev, | ||
175 | unsigned int pipe, void *data, | ||
176 | unsigned int len, struct completion *done) | ||
177 | { | ||
178 | struct usb_host_endpoint *ep; | ||
179 | struct usb_host_endpoint **hostep; | ||
180 | unsigned int pipend; | ||
181 | |||
182 | int status; | ||
183 | |||
184 | hostep = usb_pipein(pipe) ? usb_dev->ep_in : usb_dev->ep_out; | ||
185 | pipend = usb_pipeendpoint(pipe); | ||
186 | ep = hostep[pipend]; | ||
187 | |||
188 | if (!ep || (len == 0)) | ||
189 | return -EINVAL; | ||
190 | |||
191 | if ((ep->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) | ||
192 | == USB_ENDPOINT_XFER_INT) { | ||
193 | pipe = (pipe & ~(3 << 30)) | (PIPE_INTERRUPT << 30); | ||
194 | usb_fill_int_urb(urb, usb_dev, pipe, data, len, | ||
195 | (usb_complete_t)usb_api_blocking_completion, | ||
196 | NULL, ep->desc.bInterval); | ||
197 | } else | ||
198 | usb_fill_bulk_urb(urb, usb_dev, pipe, data, len, | ||
199 | (usb_complete_t)usb_api_blocking_completion, | ||
200 | NULL); | ||
201 | |||
202 | init_completion(done); | ||
203 | urb->context = done; | ||
204 | urb->actual_length = 0; | ||
205 | status = usb_submit_urb(urb, GFP_KERNEL); | ||
206 | |||
207 | return status; | ||
208 | } | ||
209 | |||
210 | static int vstusb_complete_urb(struct urb *urb, struct completion *done, | ||
211 | int timeout, int *actual_length) | ||
212 | { | ||
213 | unsigned long expire; | ||
214 | int status; | ||
215 | |||
216 | expire = timeout ? msecs_to_jiffies(timeout) : MAX_SCHEDULE_TIMEOUT; | ||
217 | if (!wait_for_completion_interruptible_timeout(done, expire)) { | ||
218 | usb_kill_urb(urb); | ||
219 | status = urb->status == -ENOENT ? -ETIMEDOUT : urb->status; | ||
220 | |||
221 | dev_dbg(&urb->dev->dev, | ||
222 | "%s timed out on ep%d%s len=%d/%d, urb status = %d\n", | ||
223 | current->comm, | ||
224 | usb_pipeendpoint(urb->pipe), | ||
225 | usb_pipein(urb->pipe) ? "in" : "out", | ||
226 | urb->actual_length, | ||
227 | urb->transfer_buffer_length, | ||
228 | urb->status); | ||
229 | |||
230 | } else { | ||
231 | if (signal_pending(current)) { | ||
232 | /* if really an error */ | ||
233 | if (urb->status && !((urb->status == -ENOENT) || | ||
234 | (urb->status == -ECONNRESET) || | ||
235 | (urb->status == -ESHUTDOWN))) { | ||
236 | status = -EINTR; | ||
237 | usb_kill_urb(urb); | ||
238 | } else { | ||
239 | status = 0; | ||
240 | } | ||
241 | |||
242 | dev_dbg(&urb->dev->dev, | ||
243 | "%s: signal pending on ep%d%s len=%d/%d," | ||
244 | "urb status = %d\n", | ||
245 | current->comm, | ||
246 | usb_pipeendpoint(urb->pipe), | ||
247 | usb_pipein(urb->pipe) ? "in" : "out", | ||
248 | urb->actual_length, | ||
249 | urb->transfer_buffer_length, | ||
250 | urb->status); | ||
251 | |||
252 | } else { | ||
253 | status = urb->status; | ||
254 | } | ||
255 | } | ||
256 | |||
257 | if (actual_length) | ||
258 | *actual_length = urb->actual_length; | ||
259 | |||
260 | return status; | ||
261 | } | ||
262 | |||
263 | static ssize_t vstusb_read(struct file *file, char __user *buffer, | ||
264 | size_t count, loff_t *ppos) | ||
265 | { | ||
266 | struct vstusb_device *vstdev; | ||
267 | int cnt = -1; | ||
268 | void *buf; | ||
269 | int retval = 0; | ||
270 | |||
271 | struct urb *urb; | ||
272 | struct usb_device *dev; | ||
273 | unsigned int pipe; | ||
274 | int timeout; | ||
275 | |||
276 | DECLARE_COMPLETION_ONSTACK(done); | ||
277 | |||
278 | vstdev = file->private_data; | ||
279 | |||
280 | if (vstdev == NULL) | ||
281 | return -ENODEV; | ||
282 | |||
283 | /* verify that we actually want to read some data */ | ||
284 | if ((count == 0) || (count > VST_MAXBUFFER)) | ||
285 | return -EINVAL; | ||
286 | |||
287 | /* lock this object */ | ||
288 | if (mutex_lock_interruptible(&vstdev->lock)) | ||
289 | return -ERESTARTSYS; | ||
290 | |||
291 | /* anyone home */ | ||
292 | if (!vstdev->present) { | ||
293 | mutex_unlock(&vstdev->lock); | ||
294 | printk(KERN_ERR KBUILD_MODNAME | ||
295 | ": %s: device not present\n", __func__); | ||
296 | return -ENODEV; | ||
297 | } | ||
298 | |||
299 | /* pull out the necessary data */ | ||
300 | dev = vstdev->usb_dev; | ||
301 | pipe = usb_rcvbulkpipe(dev, vstdev->rd_pipe); | ||
302 | timeout = vstdev->rd_timeout_ms; | ||
303 | |||
304 | buf = kmalloc(count, GFP_KERNEL); | ||
305 | if (buf == NULL) { | ||
306 | mutex_unlock(&vstdev->lock); | ||
307 | return -ENOMEM; | ||
308 | } | ||
309 | |||
310 | urb = usb_alloc_urb(0, GFP_KERNEL); | ||
311 | if (!urb) { | ||
312 | kfree(buf); | ||
313 | mutex_unlock(&vstdev->lock); | ||
314 | return -ENOMEM; | ||
315 | } | ||
316 | |||
317 | usb_anchor_urb(urb, &vstdev->submitted); | ||
318 | retval = vstusb_fill_and_send_urb(urb, dev, pipe, buf, count, &done); | ||
319 | mutex_unlock(&vstdev->lock); | ||
320 | if (retval) { | ||
321 | usb_unanchor_urb(urb); | ||
322 | dev_err(&dev->dev, "%s: error %d filling and sending urb %d\n", | ||
323 | __func__, retval, pipe); | ||
324 | goto exit; | ||
325 | } | ||
326 | |||
327 | retval = vstusb_complete_urb(urb, &done, timeout, &cnt); | ||
328 | if (retval) { | ||
329 | dev_err(&dev->dev, "%s: error %d completing urb %d\n", | ||
330 | __func__, retval, pipe); | ||
331 | goto exit; | ||
332 | } | ||
333 | |||
334 | if (copy_to_user(buffer, buf, cnt)) { | ||
335 | dev_err(&dev->dev, "%s: can't copy_to_user\n", __func__); | ||
336 | retval = -EFAULT; | ||
337 | } else { | ||
338 | retval = cnt; | ||
339 | dev_dbg(&dev->dev, "%s: read %d bytes from pipe %d\n", | ||
340 | __func__, cnt, pipe); | ||
341 | } | ||
342 | |||
343 | exit: | ||
344 | usb_free_urb(urb); | ||
345 | kfree(buf); | ||
346 | return retval; | ||
347 | } | ||
348 | |||
349 | static ssize_t vstusb_write(struct file *file, const char __user *buffer, | ||
350 | size_t count, loff_t *ppos) | ||
351 | { | ||
352 | struct vstusb_device *vstdev; | ||
353 | int cnt = -1; | ||
354 | void *buf; | ||
355 | int retval = 0; | ||
356 | |||
357 | struct urb *urb; | ||
358 | struct usb_device *dev; | ||
359 | unsigned int pipe; | ||
360 | int timeout; | ||
361 | |||
362 | DECLARE_COMPLETION_ONSTACK(done); | ||
363 | |||
364 | vstdev = file->private_data; | ||
365 | |||
366 | if (vstdev == NULL) | ||
367 | return -ENODEV; | ||
368 | |||
369 | /* verify that we actually have some data to write */ | ||
370 | if ((count == 0) || (count > VST_MAXBUFFER)) | ||
371 | return retval; | ||
372 | |||
373 | /* lock this object */ | ||
374 | if (mutex_lock_interruptible(&vstdev->lock)) | ||
375 | return -ERESTARTSYS; | ||
376 | |||
377 | /* anyone home */ | ||
378 | if (!vstdev->present) { | ||
379 | mutex_unlock(&vstdev->lock); | ||
380 | printk(KERN_ERR KBUILD_MODNAME | ||
381 | ": %s: device not present\n", __func__); | ||
382 | return -ENODEV; | ||
383 | } | ||
384 | |||
385 | /* pull out the necessary data */ | ||
386 | dev = vstdev->usb_dev; | ||
387 | pipe = usb_sndbulkpipe(dev, vstdev->wr_pipe); | ||
388 | timeout = vstdev->wr_timeout_ms; | ||
389 | |||
390 | buf = kmalloc(count, GFP_KERNEL); | ||
391 | if (buf == NULL) { | ||
392 | mutex_unlock(&vstdev->lock); | ||
393 | return -ENOMEM; | ||
394 | } | ||
395 | |||
396 | urb = usb_alloc_urb(0, GFP_KERNEL); | ||
397 | if (!urb) { | ||
398 | kfree(buf); | ||
399 | mutex_unlock(&vstdev->lock); | ||
400 | return -ENOMEM; | ||
401 | } | ||
402 | |||
403 | if (copy_from_user(buf, buffer, count)) { | ||
404 | dev_err(&dev->dev, "%s: can't copy_from_user\n", __func__); | ||
405 | retval = -EFAULT; | ||
406 | goto exit; | ||
407 | } | ||
408 | |||
409 | usb_anchor_urb(urb, &vstdev->submitted); | ||
410 | retval = vstusb_fill_and_send_urb(urb, dev, pipe, buf, count, &done); | ||
411 | mutex_unlock(&vstdev->lock); | ||
412 | if (retval) { | ||
413 | usb_unanchor_urb(urb); | ||
414 | dev_err(&dev->dev, "%s: error %d filling and sending urb %d\n", | ||
415 | __func__, retval, pipe); | ||
416 | goto exit; | ||
417 | } | ||
418 | |||
419 | retval = vstusb_complete_urb(urb, &done, timeout, &cnt); | ||
420 | if (retval) { | ||
421 | dev_err(&dev->dev, "%s: error %d completing urb %d\n", | ||
422 | __func__, retval, pipe); | ||
423 | goto exit; | ||
424 | } else { | ||
425 | retval = cnt; | ||
426 | dev_dbg(&dev->dev, "%s: sent %d bytes to pipe %d\n", | ||
427 | __func__, cnt, pipe); | ||
428 | } | ||
429 | |||
430 | exit: | ||
431 | usb_free_urb(urb); | ||
432 | kfree(buf); | ||
433 | return retval; | ||
434 | } | ||
435 | |||
436 | static long vstusb_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | ||
437 | { | ||
438 | int retval = 0; | ||
439 | int cnt = -1; | ||
440 | void __user *data = (void __user *)arg; | ||
441 | struct vstusb_args usb_data; | ||
442 | |||
443 | struct vstusb_device *vstdev; | ||
444 | void *buffer = NULL; /* must be initialized. buffer is | ||
445 | * referenced on exit but not all | ||
446 | * ioctls allocate it */ | ||
447 | |||
448 | struct urb *urb = NULL; /* must be initialized. urb is | ||
449 | * referenced on exit but not all | ||
450 | * ioctls allocate it */ | ||
451 | struct usb_device *dev; | ||
452 | unsigned int pipe; | ||
453 | int timeout; | ||
454 | |||
455 | DECLARE_COMPLETION_ONSTACK(done); | ||
456 | |||
457 | vstdev = file->private_data; | ||
458 | |||
459 | if (_IOC_TYPE(cmd) != VST_IOC_MAGIC) { | ||
460 | dev_warn(&vstdev->usb_dev->dev, | ||
461 | "%s: ioctl command %x, bad ioctl magic %x, " | ||
462 | "expected %x\n", __func__, cmd, | ||
463 | _IOC_TYPE(cmd), VST_IOC_MAGIC); | ||
464 | return -EINVAL; | ||
465 | } | ||
466 | |||
467 | if (vstdev == NULL) | ||
468 | return -ENODEV; | ||
469 | |||
470 | if (copy_from_user(&usb_data, data, sizeof(struct vstusb_args))) { | ||
471 | dev_err(&vstdev->usb_dev->dev, "%s: can't copy_from_user\n", | ||
472 | __func__); | ||
473 | return -EFAULT; | ||
474 | } | ||
475 | |||
476 | /* lock this object */ | ||
477 | if (mutex_lock_interruptible(&vstdev->lock)) { | ||
478 | retval = -ERESTARTSYS; | ||
479 | goto exit; | ||
480 | } | ||
481 | |||
482 | /* anyone home */ | ||
483 | if (!vstdev->present) { | ||
484 | mutex_unlock(&vstdev->lock); | ||
485 | dev_err(&vstdev->usb_dev->dev, "%s: device not present\n", | ||
486 | __func__); | ||
487 | retval = -ENODEV; | ||
488 | goto exit; | ||
489 | } | ||
490 | |||
491 | /* pull out the necessary data */ | ||
492 | dev = vstdev->usb_dev; | ||
493 | |||
494 | switch (cmd) { | ||
495 | |||
496 | case IOCTL_VSTUSB_CONFIG_RW: | ||
497 | |||
498 | vstdev->rd_pipe = usb_data.rd_pipe; | ||
499 | vstdev->rd_timeout_ms = usb_data.rd_timeout_ms; | ||
500 | vstdev->wr_pipe = usb_data.wr_pipe; | ||
501 | vstdev->wr_timeout_ms = usb_data.wr_timeout_ms; | ||
502 | |||
503 | mutex_unlock(&vstdev->lock); | ||
504 | |||
505 | dev_dbg(&dev->dev, "%s: setting pipes/timeouts, " | ||
506 | "rdpipe = %d, rdtimeout = %d, " | ||
507 | "wrpipe = %d, wrtimeout = %d\n", __func__, | ||
508 | vstdev->rd_pipe, vstdev->rd_timeout_ms, | ||
509 | vstdev->wr_pipe, vstdev->wr_timeout_ms); | ||
510 | break; | ||
511 | |||
512 | case IOCTL_VSTUSB_SEND_PIPE: | ||
513 | |||
514 | if ((usb_data.count == 0) || (usb_data.count > VST_MAXBUFFER)) { | ||
515 | mutex_unlock(&vstdev->lock); | ||
516 | retval = -EINVAL; | ||
517 | goto exit; | ||
518 | } | ||
519 | |||
520 | buffer = kmalloc(usb_data.count, GFP_KERNEL); | ||
521 | if (buffer == NULL) { | ||
522 | mutex_unlock(&vstdev->lock); | ||
523 | retval = -ENOMEM; | ||
524 | goto exit; | ||
525 | } | ||
526 | |||
527 | urb = usb_alloc_urb(0, GFP_KERNEL); | ||
528 | if (!urb) { | ||
529 | mutex_unlock(&vstdev->lock); | ||
530 | retval = -ENOMEM; | ||
531 | goto exit; | ||
532 | } | ||
533 | |||
534 | timeout = usb_data.timeout_ms; | ||
535 | |||
536 | pipe = usb_sndbulkpipe(dev, usb_data.pipe); | ||
537 | |||
538 | if (copy_from_user(buffer, usb_data.buffer, usb_data.count)) { | ||
539 | dev_err(&dev->dev, "%s: can't copy_from_user\n", | ||
540 | __func__); | ||
541 | mutex_unlock(&vstdev->lock); | ||
542 | retval = -EFAULT; | ||
543 | goto exit; | ||
544 | } | ||
545 | |||
546 | usb_anchor_urb(urb, &vstdev->submitted); | ||
547 | retval = vstusb_fill_and_send_urb(urb, dev, pipe, buffer, | ||
548 | usb_data.count, &done); | ||
549 | mutex_unlock(&vstdev->lock); | ||
550 | if (retval) { | ||
551 | usb_unanchor_urb(urb); | ||
552 | dev_err(&dev->dev, | ||
553 | "%s: error %d filling and sending urb %d\n", | ||
554 | __func__, retval, pipe); | ||
555 | goto exit; | ||
556 | } | ||
557 | |||
558 | retval = vstusb_complete_urb(urb, &done, timeout, &cnt); | ||
559 | if (retval) { | ||
560 | dev_err(&dev->dev, "%s: error %d completing urb %d\n", | ||
561 | __func__, retval, pipe); | ||
562 | } | ||
563 | |||
564 | break; | ||
565 | case IOCTL_VSTUSB_RECV_PIPE: | ||
566 | |||
567 | if ((usb_data.count == 0) || (usb_data.count > VST_MAXBUFFER)) { | ||
568 | mutex_unlock(&vstdev->lock); | ||
569 | retval = -EINVAL; | ||
570 | goto exit; | ||
571 | } | ||
572 | |||
573 | buffer = kmalloc(usb_data.count, GFP_KERNEL); | ||
574 | if (buffer == NULL) { | ||
575 | mutex_unlock(&vstdev->lock); | ||
576 | retval = -ENOMEM; | ||
577 | goto exit; | ||
578 | } | ||
579 | |||
580 | urb = usb_alloc_urb(0, GFP_KERNEL); | ||
581 | if (!urb) { | ||
582 | mutex_unlock(&vstdev->lock); | ||
583 | retval = -ENOMEM; | ||
584 | goto exit; | ||
585 | } | ||
586 | |||
587 | timeout = usb_data.timeout_ms; | ||
588 | |||
589 | pipe = usb_rcvbulkpipe(dev, usb_data.pipe); | ||
590 | |||
591 | usb_anchor_urb(urb, &vstdev->submitted); | ||
592 | retval = vstusb_fill_and_send_urb(urb, dev, pipe, buffer, | ||
593 | usb_data.count, &done); | ||
594 | mutex_unlock(&vstdev->lock); | ||
595 | if (retval) { | ||
596 | usb_unanchor_urb(urb); | ||
597 | dev_err(&dev->dev, | ||
598 | "%s: error %d filling and sending urb %d\n", | ||
599 | __func__, retval, pipe); | ||
600 | goto exit; | ||
601 | } | ||
602 | |||
603 | retval = vstusb_complete_urb(urb, &done, timeout, &cnt); | ||
604 | if (retval) { | ||
605 | dev_err(&dev->dev, "%s: error %d completing urb %d\n", | ||
606 | __func__, retval, pipe); | ||
607 | goto exit; | ||
608 | } | ||
609 | |||
610 | if (copy_to_user(usb_data.buffer, buffer, cnt)) { | ||
611 | dev_err(&dev->dev, "%s: can't copy_to_user\n", | ||
612 | __func__); | ||
613 | retval = -EFAULT; | ||
614 | goto exit; | ||
615 | } | ||
616 | |||
617 | usb_data.count = cnt; | ||
618 | if (copy_to_user(data, &usb_data, sizeof(struct vstusb_args))) { | ||
619 | dev_err(&dev->dev, "%s: can't copy_to_user\n", | ||
620 | __func__); | ||
621 | retval = -EFAULT; | ||
622 | } else { | ||
623 | dev_dbg(&dev->dev, "%s: recv %d bytes from pipe %d\n", | ||
624 | __func__, usb_data.count, usb_data.pipe); | ||
625 | } | ||
626 | |||
627 | break; | ||
628 | |||
629 | default: | ||
630 | mutex_unlock(&vstdev->lock); | ||
631 | dev_warn(&dev->dev, "ioctl_vstusb: invalid ioctl cmd %x\n", | ||
632 | cmd); | ||
633 | return -EINVAL; | ||
634 | break; | ||
635 | } | ||
636 | exit: | ||
637 | usb_free_urb(urb); | ||
638 | kfree(buffer); | ||
639 | return retval; | ||
640 | } | ||
641 | |||
642 | static const struct file_operations vstusb_fops = { | ||
643 | .owner = THIS_MODULE, | ||
644 | .read = vstusb_read, | ||
645 | .write = vstusb_write, | ||
646 | .unlocked_ioctl = vstusb_ioctl, | ||
647 | .compat_ioctl = vstusb_ioctl, | ||
648 | .open = vstusb_open, | ||
649 | .release = vstusb_release, | ||
650 | }; | ||
651 | |||
652 | static struct usb_class_driver usb_vstusb_class = { | ||
653 | .name = "usb/vstusb%d", | ||
654 | .fops = &vstusb_fops, | ||
655 | .minor_base = VSTUSB_MINOR_BASE, | ||
656 | }; | ||
657 | |||
658 | static int vstusb_probe(struct usb_interface *intf, | ||
659 | const struct usb_device_id *id) | ||
660 | { | ||
661 | struct usb_device *dev = interface_to_usbdev(intf); | ||
662 | struct vstusb_device *vstdev; | ||
663 | int i; | ||
664 | int retval = 0; | ||
665 | |||
666 | /* allocate memory for our device state and intialize it */ | ||
667 | |||
668 | vstdev = kzalloc(sizeof(*vstdev), GFP_KERNEL); | ||
669 | if (vstdev == NULL) | ||
670 | return -ENOMEM; | ||
671 | |||
672 | /* must do usb_get_dev() prior to kref_init() since the kref_put() | ||
673 | * release function will do a usb_put_dev() */ | ||
674 | usb_get_dev(dev); | ||
675 | kref_init(&vstdev->kref); | ||
676 | mutex_init(&vstdev->lock); | ||
677 | |||
678 | i = dev->descriptor.bcdDevice; | ||
679 | |||
680 | dev_dbg(&intf->dev, "Version %1d%1d.%1d%1d found at address %d\n", | ||
681 | (i & 0xF000) >> 12, (i & 0xF00) >> 8, | ||
682 | (i & 0xF0) >> 4, (i & 0xF), dev->devnum); | ||
683 | |||
684 | vstdev->present = 1; | ||
685 | vstdev->isopen = 0; | ||
686 | vstdev->usb_dev = dev; | ||
687 | init_usb_anchor(&vstdev->submitted); | ||
688 | |||
689 | usb_set_intfdata(intf, vstdev); | ||
690 | retval = usb_register_dev(intf, &usb_vstusb_class); | ||
691 | if (retval) { | ||
692 | dev_err(&intf->dev, | ||
693 | "%s: Not able to get a minor for this device.\n", | ||
694 | __func__); | ||
695 | usb_set_intfdata(intf, NULL); | ||
696 | kref_put(&vstdev->kref, vstusb_delete); | ||
697 | return retval; | ||
698 | } | ||
699 | |||
700 | /* let the user know what node this device is now attached to */ | ||
701 | dev_info(&intf->dev, | ||
702 | "VST USB Device #%d now attached to major %d minor %d\n", | ||
703 | (intf->minor - VSTUSB_MINOR_BASE), USB_MAJOR, intf->minor); | ||
704 | |||
705 | dev_info(&intf->dev, "%s, %s\n", DRIVER_DESC, DRIVER_VERSION); | ||
706 | |||
707 | return retval; | ||
708 | } | ||
709 | |||
710 | static void vstusb_disconnect(struct usb_interface *intf) | ||
711 | { | ||
712 | struct vstusb_device *vstdev = usb_get_intfdata(intf); | ||
713 | |||
714 | usb_deregister_dev(intf, &usb_vstusb_class); | ||
715 | usb_set_intfdata(intf, NULL); | ||
716 | |||
717 | if (vstdev) { | ||
718 | |||
719 | mutex_lock(&vstdev->lock); | ||
720 | vstdev->present = 0; | ||
721 | |||
722 | usb_kill_anchored_urbs(&vstdev->submitted); | ||
723 | |||
724 | mutex_unlock(&vstdev->lock); | ||
725 | |||
726 | kref_put(&vstdev->kref, vstusb_delete); | ||
727 | } | ||
728 | |||
729 | } | ||
730 | |||
731 | static int vstusb_suspend(struct usb_interface *intf, pm_message_t message) | ||
732 | { | ||
733 | struct vstusb_device *vstdev = usb_get_intfdata(intf); | ||
734 | int time; | ||
735 | if (!vstdev) | ||
736 | return 0; | ||
737 | |||
738 | mutex_lock(&vstdev->lock); | ||
739 | time = usb_wait_anchor_empty_timeout(&vstdev->submitted, 1000); | ||
740 | if (!time) | ||
741 | usb_kill_anchored_urbs(&vstdev->submitted); | ||
742 | mutex_unlock(&vstdev->lock); | ||
743 | |||
744 | return 0; | ||
745 | } | ||
746 | |||
747 | static int vstusb_resume(struct usb_interface *intf) | ||
748 | { | ||
749 | return 0; | ||
750 | } | ||
751 | |||
752 | static struct usb_driver vstusb_driver = { | ||
753 | .name = "vstusb", | ||
754 | .probe = vstusb_probe, | ||
755 | .disconnect = vstusb_disconnect, | ||
756 | .suspend = vstusb_suspend, | ||
757 | .resume = vstusb_resume, | ||
758 | .id_table = id_table, | ||
759 | }; | ||
760 | |||
761 | static int __init vstusb_init(void) | ||
762 | { | ||
763 | int rc; | ||
764 | |||
765 | rc = usb_register(&vstusb_driver); | ||
766 | if (rc) | ||
767 | printk(KERN_ERR "%s: failed to register (%d)", __func__, rc); | ||
768 | |||
769 | return rc; | ||
770 | } | ||
771 | |||
772 | static void __exit vstusb_exit(void) | ||
773 | { | ||
774 | usb_deregister(&vstusb_driver); | ||
775 | } | ||
776 | |||
777 | module_init(vstusb_init); | ||
778 | module_exit(vstusb_exit); | ||
779 | |||
780 | MODULE_AUTHOR("Dennis O'Brien/Stephen Ware"); | ||
781 | MODULE_DESCRIPTION(DRIVER_VERSION); | ||
782 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/usb/mon/mon_bin.c b/drivers/usb/mon/mon_bin.c index 6566fc0a3228..c9de3f027aab 100644 --- a/drivers/usb/mon/mon_bin.c +++ b/drivers/usb/mon/mon_bin.c | |||
@@ -1162,9 +1162,9 @@ int mon_bin_add(struct mon_bus *mbus, const struct usb_bus *ubus) | |||
1162 | if (minor >= MON_BIN_MAX_MINOR) | 1162 | if (minor >= MON_BIN_MAX_MINOR) |
1163 | return 0; | 1163 | return 0; |
1164 | 1164 | ||
1165 | dev = device_create_drvdata(mon_bin_class, ubus? ubus->controller: NULL, | 1165 | dev = device_create(mon_bin_class, ubus ? ubus->controller : NULL, |
1166 | MKDEV(MAJOR(mon_bin_dev0), minor), NULL, | 1166 | MKDEV(MAJOR(mon_bin_dev0), minor), NULL, |
1167 | "usbmon%d", minor); | 1167 | "usbmon%d", minor); |
1168 | if (IS_ERR(dev)) | 1168 | if (IS_ERR(dev)) |
1169 | return 0; | 1169 | return 0; |
1170 | 1170 | ||
diff --git a/drivers/usb/mon/mon_main.c b/drivers/usb/mon/mon_main.c index 442d8076b201..5e0ab4201c00 100644 --- a/drivers/usb/mon/mon_main.c +++ b/drivers/usb/mon/mon_main.c | |||
@@ -361,12 +361,12 @@ static int __init mon_init(void) | |||
361 | } | 361 | } |
362 | // MOD_INC_USE_COUNT(which_module?); | 362 | // MOD_INC_USE_COUNT(which_module?); |
363 | 363 | ||
364 | usb_register_notify(&mon_nb); | ||
365 | 364 | ||
366 | mutex_lock(&usb_bus_list_lock); | 365 | mutex_lock(&usb_bus_list_lock); |
367 | list_for_each_entry (ubus, &usb_bus_list, bus_list) { | 366 | list_for_each_entry (ubus, &usb_bus_list, bus_list) { |
368 | mon_bus_init(ubus); | 367 | mon_bus_init(ubus); |
369 | } | 368 | } |
369 | usb_register_notify(&mon_nb); | ||
370 | mutex_unlock(&usb_bus_list_lock); | 370 | mutex_unlock(&usb_bus_list_lock); |
371 | return 0; | 371 | return 0; |
372 | 372 | ||
diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig index faca4333f27a..4b9542bbb35c 100644 --- a/drivers/usb/musb/Kconfig +++ b/drivers/usb/musb/Kconfig | |||
@@ -9,6 +9,7 @@ comment "Enable Host or Gadget support to see Inventra options" | |||
9 | # (M)HDRC = (Multipoint) Highspeed Dual-Role Controller | 9 | # (M)HDRC = (Multipoint) Highspeed Dual-Role Controller |
10 | config USB_MUSB_HDRC | 10 | config USB_MUSB_HDRC |
11 | depends on (USB || USB_GADGET) && HAVE_CLK | 11 | depends on (USB || USB_GADGET) && HAVE_CLK |
12 | depends on !SUPERH | ||
12 | select TWL4030_USB if MACH_OMAP_3430SDP | 13 | select TWL4030_USB if MACH_OMAP_3430SDP |
13 | tristate 'Inventra Highspeed Dual Role Controller (TI, ...)' | 14 | tristate 'Inventra Highspeed Dual Role Controller (TI, ...)' |
14 | help | 15 | help |
@@ -32,10 +33,6 @@ config USB_MUSB_SOC | |||
32 | default y if ARCH_DAVINCI | 33 | default y if ARCH_DAVINCI |
33 | default y if ARCH_OMAP2430 | 34 | default y if ARCH_OMAP2430 |
34 | default y if ARCH_OMAP34XX | 35 | default y if ARCH_OMAP34XX |
35 | help | ||
36 | Use a static <asm/arch/hdrc_cnf.h> file to describe how the | ||
37 | controller is configured (endpoints, mechanisms, etc) on the | ||
38 | current iteration of a given system-on-chip. | ||
39 | 36 | ||
40 | comment "DaVinci 644x USB support" | 37 | comment "DaVinci 644x USB support" |
41 | depends on USB_MUSB_HDRC && ARCH_DAVINCI | 38 | depends on USB_MUSB_HDRC && ARCH_DAVINCI |
@@ -165,12 +162,11 @@ config USB_TUSB_OMAP_DMA | |||
165 | help | 162 | help |
166 | Enable DMA transfers on TUSB 6010 when OMAP DMA is available. | 163 | Enable DMA transfers on TUSB 6010 when OMAP DMA is available. |
167 | 164 | ||
168 | config USB_MUSB_LOGLEVEL | 165 | config USB_MUSB_DEBUG |
169 | depends on USB_MUSB_HDRC | 166 | depends on USB_MUSB_HDRC |
170 | int 'Logging Level (0 - none / 3 - annoying / ... )' | 167 | bool "Enable debugging messages" |
171 | default 0 | 168 | default n |
172 | help | 169 | help |
173 | Set the logging level. 0 disables the debugging altogether, | 170 | This enables musb debugging. To set the logging level use the debug |
174 | although when USB_DEBUG is set the value is at least 1. | 171 | module parameter. Starting at level 3, per-transfer (urb, usb_request, |
175 | Starting at level 3, per-transfer (urb, usb_request, packet, | 172 | packet, or dma transfer) tracing may kick in. |
176 | or dma transfer) tracing may kick in. | ||
diff --git a/drivers/usb/musb/Makefile b/drivers/usb/musb/Makefile index 88eb67de08ae..b6af0d687a73 100644 --- a/drivers/usb/musb/Makefile +++ b/drivers/usb/musb/Makefile | |||
@@ -64,23 +64,6 @@ endif | |||
64 | 64 | ||
65 | # Debugging | 65 | # Debugging |
66 | 66 | ||
67 | MUSB_DEBUG:=$(CONFIG_USB_MUSB_LOGLEVEL) | 67 | ifeq ($(CONFIG_USB_MUSB_DEBUG),y) |
68 | 68 | EXTRA_CFLAGS += -DDEBUG | |
69 | ifeq ("$(strip $(MUSB_DEBUG))","") | ||
70 | ifdef CONFIG_USB_DEBUG | ||
71 | MUSB_DEBUG:=1 | ||
72 | else | ||
73 | MUSB_DEBUG:=0 | ||
74 | endif | ||
75 | endif | 69 | endif |
76 | |||
77 | ifneq ($(MUSB_DEBUG),0) | ||
78 | EXTRA_CFLAGS += -DDEBUG | ||
79 | |||
80 | ifeq ($(CONFIG_PROC_FS),y) | ||
81 | musb_hdrc-objs += musb_procfs.o | ||
82 | endif | ||
83 | |||
84 | endif | ||
85 | |||
86 | EXTRA_CFLAGS += -DMUSB_DEBUG=$(MUSB_DEBUG) | ||
diff --git a/drivers/usb/musb/cppi_dma.h b/drivers/usb/musb/cppi_dma.h index fc5216b5d2c5..729b4071787b 100644 --- a/drivers/usb/musb/cppi_dma.h +++ b/drivers/usb/musb/cppi_dma.h | |||
@@ -119,8 +119,8 @@ struct cppi { | |||
119 | void __iomem *mregs; /* Mentor regs */ | 119 | void __iomem *mregs; /* Mentor regs */ |
120 | void __iomem *tibase; /* TI/CPPI regs */ | 120 | void __iomem *tibase; /* TI/CPPI regs */ |
121 | 121 | ||
122 | struct cppi_channel tx[MUSB_C_NUM_EPT - 1]; | 122 | struct cppi_channel tx[4]; |
123 | struct cppi_channel rx[MUSB_C_NUM_EPR - 1]; | 123 | struct cppi_channel rx[4]; |
124 | 124 | ||
125 | struct dma_pool *pool; | 125 | struct dma_pool *pool; |
126 | 126 | ||
diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c index 75baf181a8cd..dfb3bcbe00fc 100644 --- a/drivers/usb/musb/davinci.c +++ b/drivers/usb/musb/davinci.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <linux/delay.h> | 30 | #include <linux/delay.h> |
31 | #include <linux/clk.h> | 31 | #include <linux/clk.h> |
32 | #include <linux/io.h> | 32 | #include <linux/io.h> |
33 | #include <linux/gpio.h> | ||
33 | 34 | ||
34 | #include <asm/arch/hardware.h> | 35 | #include <asm/arch/hardware.h> |
35 | #include <asm/arch/memory.h> | 36 | #include <asm/arch/memory.h> |
@@ -39,7 +40,7 @@ | |||
39 | #include "musb_core.h" | 40 | #include "musb_core.h" |
40 | 41 | ||
41 | #ifdef CONFIG_MACH_DAVINCI_EVM | 42 | #ifdef CONFIG_MACH_DAVINCI_EVM |
42 | #include <asm/arch/i2c-client.h> | 43 | #define GPIO_nVBUS_DRV 87 |
43 | #endif | 44 | #endif |
44 | 45 | ||
45 | #include "davinci.h" | 46 | #include "davinci.h" |
@@ -138,7 +139,6 @@ static int vbus_state = -1; | |||
138 | /* VBUS SWITCHING IS BOARD-SPECIFIC */ | 139 | /* VBUS SWITCHING IS BOARD-SPECIFIC */ |
139 | 140 | ||
140 | #ifdef CONFIG_MACH_DAVINCI_EVM | 141 | #ifdef CONFIG_MACH_DAVINCI_EVM |
141 | #ifndef CONFIG_MACH_DAVINCI_EVM_OTG | ||
142 | 142 | ||
143 | /* I2C operations are always synchronous, and require a task context. | 143 | /* I2C operations are always synchronous, and require a task context. |
144 | * With unloaded systems, using the shared workqueue seems to suffice | 144 | * With unloaded systems, using the shared workqueue seems to suffice |
@@ -146,12 +146,11 @@ static int vbus_state = -1; | |||
146 | */ | 146 | */ |
147 | static void evm_deferred_drvvbus(struct work_struct *ignored) | 147 | static void evm_deferred_drvvbus(struct work_struct *ignored) |
148 | { | 148 | { |
149 | davinci_i2c_expander_op(0x3a, USB_DRVVBUS, vbus_state); | 149 | gpio_set_value_cansleep(GPIO_nVBUS_DRV, vbus_state); |
150 | vbus_state = !vbus_state; | 150 | vbus_state = !vbus_state; |
151 | } | 151 | } |
152 | static DECLARE_WORK(evm_vbus_work, evm_deferred_drvvbus); | 152 | static DECLARE_WORK(evm_vbus_work, evm_deferred_drvvbus); |
153 | 153 | ||
154 | #endif /* modified board */ | ||
155 | #endif /* EVM */ | 154 | #endif /* EVM */ |
156 | 155 | ||
157 | static void davinci_source_power(struct musb *musb, int is_on, int immediate) | 156 | static void davinci_source_power(struct musb *musb, int is_on, int immediate) |
@@ -165,21 +164,10 @@ static void davinci_source_power(struct musb *musb, int is_on, int immediate) | |||
165 | 164 | ||
166 | #ifdef CONFIG_MACH_DAVINCI_EVM | 165 | #ifdef CONFIG_MACH_DAVINCI_EVM |
167 | if (machine_is_davinci_evm()) { | 166 | if (machine_is_davinci_evm()) { |
168 | #ifdef CONFIG_MACH_DAVINCI_EVM_OTG | ||
169 | /* modified EVM board switching VBUS with GPIO(6) not I2C | ||
170 | * NOTE: PINMUX0.RGB888 (bit23) must be clear | ||
171 | */ | ||
172 | if (is_on) | ||
173 | gpio_set(GPIO(6)); | ||
174 | else | ||
175 | gpio_clear(GPIO(6)); | ||
176 | immediate = 1; | ||
177 | #else | ||
178 | if (immediate) | 167 | if (immediate) |
179 | davinci_i2c_expander_op(0x3a, USB_DRVVBUS, !is_on); | 168 | gpio_set_value_cansleep(GPIO_nVBUS_DRV, vbus_state); |
180 | else | 169 | else |
181 | schedule_work(&evm_vbus_work); | 170 | schedule_work(&evm_vbus_work); |
182 | #endif | ||
183 | } | 171 | } |
184 | #endif | 172 | #endif |
185 | if (immediate) | 173 | if (immediate) |
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index d68ec6daf335..4a35745b30be 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c | |||
@@ -82,9 +82,9 @@ | |||
82 | /* | 82 | /* |
83 | * This gets many kinds of configuration information: | 83 | * This gets many kinds of configuration information: |
84 | * - Kconfig for everything user-configurable | 84 | * - Kconfig for everything user-configurable |
85 | * - <asm/arch/hdrc_cnf.h> for SOC or family details | ||
86 | * - platform_device for addressing, irq, and platform_data | 85 | * - platform_device for addressing, irq, and platform_data |
87 | * - platform_data is mostly for board-specific informarion | 86 | * - platform_data is mostly for board-specific informarion |
87 | * (plus recentrly, SOC or family details) | ||
88 | * | 88 | * |
89 | * Most of the conditional compilation will (someday) vanish. | 89 | * Most of the conditional compilation will (someday) vanish. |
90 | */ | 90 | */ |
@@ -100,8 +100,8 @@ | |||
100 | #include <linux/io.h> | 100 | #include <linux/io.h> |
101 | 101 | ||
102 | #ifdef CONFIG_ARM | 102 | #ifdef CONFIG_ARM |
103 | #include <asm/arch/hardware.h> | 103 | #include <mach/hardware.h> |
104 | #include <asm/arch/memory.h> | 104 | #include <mach/memory.h> |
105 | #include <asm/mach-types.h> | 105 | #include <asm/mach-types.h> |
106 | #endif | 106 | #endif |
107 | 107 | ||
@@ -114,23 +114,14 @@ | |||
114 | 114 | ||
115 | 115 | ||
116 | 116 | ||
117 | #if MUSB_DEBUG > 0 | 117 | unsigned debug; |
118 | unsigned debug = MUSB_DEBUG; | 118 | module_param(debug, uint, S_IRUGO | S_IWUSR); |
119 | module_param(debug, uint, 0); | 119 | MODULE_PARM_DESC(debug, "Debug message level. Default = 0"); |
120 | MODULE_PARM_DESC(debug, "initial debug message level"); | ||
121 | |||
122 | #define MUSB_VERSION_SUFFIX "/dbg" | ||
123 | #endif | ||
124 | 120 | ||
125 | #define DRIVER_AUTHOR "Mentor Graphics, Texas Instruments, Nokia" | 121 | #define DRIVER_AUTHOR "Mentor Graphics, Texas Instruments, Nokia" |
126 | #define DRIVER_DESC "Inventra Dual-Role USB Controller Driver" | 122 | #define DRIVER_DESC "Inventra Dual-Role USB Controller Driver" |
127 | 123 | ||
128 | #define MUSB_VERSION_BASE "6.0" | 124 | #define MUSB_VERSION "6.0" |
129 | |||
130 | #ifndef MUSB_VERSION_SUFFIX | ||
131 | #define MUSB_VERSION_SUFFIX "" | ||
132 | #endif | ||
133 | #define MUSB_VERSION MUSB_VERSION_BASE MUSB_VERSION_SUFFIX | ||
134 | 125 | ||
135 | #define DRIVER_INFO DRIVER_DESC ", v" MUSB_VERSION | 126 | #define DRIVER_INFO DRIVER_DESC ", v" MUSB_VERSION |
136 | 127 | ||
@@ -983,9 +974,9 @@ static void musb_shutdown(struct platform_device *pdev) | |||
983 | /* | 974 | /* |
984 | * The silicon either has hard-wired endpoint configurations, or else | 975 | * The silicon either has hard-wired endpoint configurations, or else |
985 | * "dynamic fifo" sizing. The driver has support for both, though at this | 976 | * "dynamic fifo" sizing. The driver has support for both, though at this |
986 | * writing only the dynamic sizing is very well tested. We use normal | 977 | * writing only the dynamic sizing is very well tested. Since we switched |
987 | * idioms to so both modes are compile-tested, but dead code elimination | 978 | * away from compile-time hardware parameters, we can no longer rely on |
988 | * leaves only the relevant one in the object file. | 979 | * dead code elimination to leave only the relevant one in the object file. |
989 | * | 980 | * |
990 | * We don't currently use dynamic fifo setup capability to do anything | 981 | * We don't currently use dynamic fifo setup capability to do anything |
991 | * more than selecting one of a bunch of predefined configurations. | 982 | * more than selecting one of a bunch of predefined configurations. |
@@ -1815,6 +1806,7 @@ allocate_instance(struct device *dev, | |||
1815 | musb->ctrl_base = mbase; | 1806 | musb->ctrl_base = mbase; |
1816 | musb->nIrq = -ENODEV; | 1807 | musb->nIrq = -ENODEV; |
1817 | musb->config = config; | 1808 | musb->config = config; |
1809 | BUG_ON(musb->config->num_eps > MUSB_C_NUM_EPS); | ||
1818 | for (epnum = 0, ep = musb->endpoints; | 1810 | for (epnum = 0, ep = musb->endpoints; |
1819 | epnum < musb->config->num_eps; | 1811 | epnum < musb->config->num_eps; |
1820 | epnum++, ep++) { | 1812 | epnum++, ep++) { |
@@ -2037,6 +2029,8 @@ bad_config: | |||
2037 | musb->xceiv.state = OTG_STATE_A_IDLE; | 2029 | musb->xceiv.state = OTG_STATE_A_IDLE; |
2038 | 2030 | ||
2039 | status = usb_add_hcd(musb_to_hcd(musb), -1, 0); | 2031 | status = usb_add_hcd(musb_to_hcd(musb), -1, 0); |
2032 | if (status) | ||
2033 | goto fail; | ||
2040 | 2034 | ||
2041 | DBG(1, "%s mode, status %d, devctl %02x %c\n", | 2035 | DBG(1, "%s mode, status %d, devctl %02x %c\n", |
2042 | "HOST", status, | 2036 | "HOST", status, |
@@ -2051,6 +2045,8 @@ bad_config: | |||
2051 | musb->xceiv.state = OTG_STATE_B_IDLE; | 2045 | musb->xceiv.state = OTG_STATE_B_IDLE; |
2052 | 2046 | ||
2053 | status = musb_gadget_setup(musb); | 2047 | status = musb_gadget_setup(musb); |
2048 | if (status) | ||
2049 | goto fail; | ||
2054 | 2050 | ||
2055 | DBG(1, "%s mode, status %d, dev%02x\n", | 2051 | DBG(1, "%s mode, status %d, dev%02x\n", |
2056 | is_otg_enabled(musb) ? "OTG" : "PERIPHERAL", | 2052 | is_otg_enabled(musb) ? "OTG" : "PERIPHERAL", |
@@ -2059,17 +2055,6 @@ bad_config: | |||
2059 | 2055 | ||
2060 | } | 2056 | } |
2061 | 2057 | ||
2062 | if (status == 0) | ||
2063 | musb_debug_create("driver/musb_hdrc", musb); | ||
2064 | else { | ||
2065 | fail: | ||
2066 | if (musb->clock) | ||
2067 | clk_put(musb->clock); | ||
2068 | device_init_wakeup(dev, 0); | ||
2069 | musb_free(musb); | ||
2070 | return status; | ||
2071 | } | ||
2072 | |||
2073 | #ifdef CONFIG_SYSFS | 2058 | #ifdef CONFIG_SYSFS |
2074 | status = device_create_file(dev, &dev_attr_mode); | 2059 | status = device_create_file(dev, &dev_attr_mode); |
2075 | status = device_create_file(dev, &dev_attr_vbus); | 2060 | status = device_create_file(dev, &dev_attr_vbus); |
@@ -2078,12 +2063,31 @@ fail: | |||
2078 | #endif /* CONFIG_USB_GADGET_MUSB_HDRC */ | 2063 | #endif /* CONFIG_USB_GADGET_MUSB_HDRC */ |
2079 | status = 0; | 2064 | status = 0; |
2080 | #endif | 2065 | #endif |
2066 | if (status) | ||
2067 | goto fail2; | ||
2081 | 2068 | ||
2082 | return status; | 2069 | return 0; |
2083 | 2070 | ||
2084 | fail2: | 2071 | fail2: |
2072 | #ifdef CONFIG_SYSFS | ||
2073 | device_remove_file(musb->controller, &dev_attr_mode); | ||
2074 | device_remove_file(musb->controller, &dev_attr_vbus); | ||
2075 | #ifdef CONFIG_USB_MUSB_OTG | ||
2076 | device_remove_file(musb->controller, &dev_attr_srp); | ||
2077 | #endif | ||
2078 | #endif | ||
2085 | musb_platform_exit(musb); | 2079 | musb_platform_exit(musb); |
2086 | goto fail; | 2080 | fail: |
2081 | dev_err(musb->controller, | ||
2082 | "musb_init_controller failed with status %d\n", status); | ||
2083 | |||
2084 | if (musb->clock) | ||
2085 | clk_put(musb->clock); | ||
2086 | device_init_wakeup(dev, 0); | ||
2087 | musb_free(musb); | ||
2088 | |||
2089 | return status; | ||
2090 | |||
2087 | } | 2091 | } |
2088 | 2092 | ||
2089 | /*-------------------------------------------------------------------------*/ | 2093 | /*-------------------------------------------------------------------------*/ |
@@ -2131,7 +2135,6 @@ static int __devexit musb_remove(struct platform_device *pdev) | |||
2131 | * - OTG mode: both roles are deactivated (or never-activated) | 2135 | * - OTG mode: both roles are deactivated (or never-activated) |
2132 | */ | 2136 | */ |
2133 | musb_shutdown(pdev); | 2137 | musb_shutdown(pdev); |
2134 | musb_debug_delete("driver/musb_hdrc", musb); | ||
2135 | #ifdef CONFIG_USB_MUSB_HDRC_HCD | 2138 | #ifdef CONFIG_USB_MUSB_HDRC_HCD |
2136 | if (musb->board_mode == MUSB_HOST) | 2139 | if (musb->board_mode == MUSB_HOST) |
2137 | usb_remove_hcd(musb_to_hcd(musb)); | 2140 | usb_remove_hcd(musb_to_hcd(musb)); |
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h index eade46d81708..82227251931b 100644 --- a/drivers/usb/musb/musb_core.h +++ b/drivers/usb/musb/musb_core.h | |||
@@ -485,23 +485,4 @@ extern int musb_platform_get_vbus_status(struct musb *musb); | |||
485 | extern int __init musb_platform_init(struct musb *musb); | 485 | extern int __init musb_platform_init(struct musb *musb); |
486 | extern int musb_platform_exit(struct musb *musb); | 486 | extern int musb_platform_exit(struct musb *musb); |
487 | 487 | ||
488 | /*-------------------------- ProcFS definitions ---------------------*/ | ||
489 | |||
490 | struct proc_dir_entry; | ||
491 | |||
492 | #if (MUSB_DEBUG > 0) && defined(MUSB_CONFIG_PROC_FS) | ||
493 | extern struct proc_dir_entry *musb_debug_create(char *name, struct musb *data); | ||
494 | extern void musb_debug_delete(char *name, struct musb *data); | ||
495 | |||
496 | #else | ||
497 | static inline struct proc_dir_entry * | ||
498 | musb_debug_create(char *name, struct musb *data) | ||
499 | { | ||
500 | return NULL; | ||
501 | } | ||
502 | static inline void musb_debug_delete(char *name, struct musb *data) | ||
503 | { | ||
504 | } | ||
505 | #endif | ||
506 | |||
507 | #endif /* __MUSB_CORE_H__ */ | 488 | #endif /* __MUSB_CORE_H__ */ |
diff --git a/drivers/usb/musb/musb_debug.h b/drivers/usb/musb/musb_debug.h index 3bdb311e820d..4d2794441b15 100644 --- a/drivers/usb/musb/musb_debug.h +++ b/drivers/usb/musb/musb_debug.h | |||
@@ -48,11 +48,7 @@ | |||
48 | __func__, __LINE__ , ## args); \ | 48 | __func__, __LINE__ , ## args); \ |
49 | } } while (0) | 49 | } } while (0) |
50 | 50 | ||
51 | #if MUSB_DEBUG > 0 | ||
52 | extern unsigned debug; | 51 | extern unsigned debug; |
53 | #else | ||
54 | #define debug 0 | ||
55 | #endif | ||
56 | 52 | ||
57 | static inline int _dbg_level(unsigned l) | 53 | static inline int _dbg_level(unsigned l) |
58 | { | 54 | { |
diff --git a/drivers/usb/musb/musb_gadget_ep0.c b/drivers/usb/musb/musb_gadget_ep0.c index 48d7d3ccb243..3f5e30ddfa27 100644 --- a/drivers/usb/musb/musb_gadget_ep0.c +++ b/drivers/usb/musb/musb_gadget_ep0.c | |||
@@ -437,7 +437,7 @@ static void ep0_rxstate(struct musb *musb) | |||
437 | { | 437 | { |
438 | void __iomem *regs = musb->control_ep->regs; | 438 | void __iomem *regs = musb->control_ep->regs; |
439 | struct usb_request *req; | 439 | struct usb_request *req; |
440 | u16 tmp; | 440 | u16 count, csr; |
441 | 441 | ||
442 | req = next_ep0_request(musb); | 442 | req = next_ep0_request(musb); |
443 | 443 | ||
@@ -449,34 +449,35 @@ static void ep0_rxstate(struct musb *musb) | |||
449 | unsigned len = req->length - req->actual; | 449 | unsigned len = req->length - req->actual; |
450 | 450 | ||
451 | /* read the buffer */ | 451 | /* read the buffer */ |
452 | tmp = musb_readb(regs, MUSB_COUNT0); | 452 | count = musb_readb(regs, MUSB_COUNT0); |
453 | if (tmp > len) { | 453 | if (count > len) { |
454 | req->status = -EOVERFLOW; | 454 | req->status = -EOVERFLOW; |
455 | tmp = len; | 455 | count = len; |
456 | } | 456 | } |
457 | musb_read_fifo(&musb->endpoints[0], tmp, buf); | 457 | musb_read_fifo(&musb->endpoints[0], count, buf); |
458 | req->actual += tmp; | 458 | req->actual += count; |
459 | tmp = MUSB_CSR0_P_SVDRXPKTRDY; | 459 | csr = MUSB_CSR0_P_SVDRXPKTRDY; |
460 | if (tmp < 64 || req->actual == req->length) { | 460 | if (count < 64 || req->actual == req->length) { |
461 | musb->ep0_state = MUSB_EP0_STAGE_STATUSIN; | 461 | musb->ep0_state = MUSB_EP0_STAGE_STATUSIN; |
462 | tmp |= MUSB_CSR0_P_DATAEND; | 462 | csr |= MUSB_CSR0_P_DATAEND; |
463 | } else | 463 | } else |
464 | req = NULL; | 464 | req = NULL; |
465 | } else | 465 | } else |
466 | tmp = MUSB_CSR0_P_SVDRXPKTRDY | MUSB_CSR0_P_SENDSTALL; | 466 | csr = MUSB_CSR0_P_SVDRXPKTRDY | MUSB_CSR0_P_SENDSTALL; |
467 | 467 | ||
468 | 468 | ||
469 | /* Completion handler may choose to stall, e.g. because the | 469 | /* Completion handler may choose to stall, e.g. because the |
470 | * message just received holds invalid data. | 470 | * message just received holds invalid data. |
471 | */ | 471 | */ |
472 | if (req) { | 472 | if (req) { |
473 | musb->ackpend = tmp; | 473 | musb->ackpend = csr; |
474 | musb_g_ep0_giveback(musb, req); | 474 | musb_g_ep0_giveback(musb, req); |
475 | if (!musb->ackpend) | 475 | if (!musb->ackpend) |
476 | return; | 476 | return; |
477 | musb->ackpend = 0; | 477 | musb->ackpend = 0; |
478 | } | 478 | } |
479 | musb_writew(regs, MUSB_CSR0, tmp); | 479 | musb_ep_select(musb->mregs, 0); |
480 | musb_writew(regs, MUSB_CSR0, csr); | ||
480 | } | 481 | } |
481 | 482 | ||
482 | /* | 483 | /* |
@@ -528,6 +529,7 @@ static void ep0_txstate(struct musb *musb) | |||
528 | } | 529 | } |
529 | 530 | ||
530 | /* send it out, triggering a "txpktrdy cleared" irq */ | 531 | /* send it out, triggering a "txpktrdy cleared" irq */ |
532 | musb_ep_select(musb->mregs, 0); | ||
531 | musb_writew(regs, MUSB_CSR0, csr); | 533 | musb_writew(regs, MUSB_CSR0, csr); |
532 | } | 534 | } |
533 | 535 | ||
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c index 8b4be012669a..3133990f04ec 100644 --- a/drivers/usb/musb/musb_host.c +++ b/drivers/usb/musb/musb_host.c | |||
@@ -108,7 +108,7 @@ static void musb_ep_program(struct musb *musb, u8 epnum, | |||
108 | /* | 108 | /* |
109 | * Clear TX fifo. Needed to avoid BABBLE errors. | 109 | * Clear TX fifo. Needed to avoid BABBLE errors. |
110 | */ | 110 | */ |
111 | static inline void musb_h_tx_flush_fifo(struct musb_hw_ep *ep) | 111 | static void musb_h_tx_flush_fifo(struct musb_hw_ep *ep) |
112 | { | 112 | { |
113 | void __iomem *epio = ep->regs; | 113 | void __iomem *epio = ep->regs; |
114 | u16 csr; | 114 | u16 csr; |
@@ -291,6 +291,7 @@ __acquires(musb->lock) | |||
291 | urb->actual_length, urb->transfer_buffer_length | 291 | urb->actual_length, urb->transfer_buffer_length |
292 | ); | 292 | ); |
293 | 293 | ||
294 | usb_hcd_unlink_urb_from_ep(musb_to_hcd(musb), urb); | ||
294 | spin_unlock(&musb->lock); | 295 | spin_unlock(&musb->lock); |
295 | usb_hcd_giveback_urb(musb_to_hcd(musb), urb, status); | 296 | usb_hcd_giveback_urb(musb_to_hcd(musb), urb, status); |
296 | spin_lock(&musb->lock); | 297 | spin_lock(&musb->lock); |
@@ -353,8 +354,6 @@ musb_giveback(struct musb_qh *qh, struct urb *urb, int status) | |||
353 | break; | 354 | break; |
354 | } | 355 | } |
355 | 356 | ||
356 | usb_hcd_unlink_urb_from_ep(musb_to_hcd(musb), urb); | ||
357 | |||
358 | qh->is_ready = 0; | 357 | qh->is_ready = 0; |
359 | __musb_giveback(musb, urb, status); | 358 | __musb_giveback(musb, urb, status); |
360 | qh->is_ready = ready; | 359 | qh->is_ready = ready; |
@@ -436,7 +435,7 @@ musb_advance_schedule(struct musb *musb, struct urb *urb, | |||
436 | } | 435 | } |
437 | } | 436 | } |
438 | 437 | ||
439 | static inline u16 musb_h_flush_rxfifo(struct musb_hw_ep *hw_ep, u16 csr) | 438 | static u16 musb_h_flush_rxfifo(struct musb_hw_ep *hw_ep, u16 csr) |
440 | { | 439 | { |
441 | /* we don't want fifo to fill itself again; | 440 | /* we don't want fifo to fill itself again; |
442 | * ignore dma (various models), | 441 | * ignore dma (various models), |
@@ -1005,7 +1004,7 @@ static bool musb_h_ep0_continue(struct musb *musb, u16 len, struct urb *urb) | |||
1005 | 1004 | ||
1006 | /* | 1005 | /* |
1007 | * Handle default endpoint interrupt as host. Only called in IRQ time | 1006 | * Handle default endpoint interrupt as host. Only called in IRQ time |
1008 | * from the LinuxIsr() interrupt service routine. | 1007 | * from musb_interrupt(). |
1009 | * | 1008 | * |
1010 | * called with controller irqlocked | 1009 | * called with controller irqlocked |
1011 | */ | 1010 | */ |
@@ -1791,7 +1790,9 @@ static int musb_urb_enqueue( | |||
1791 | */ | 1790 | */ |
1792 | qh = kzalloc(sizeof *qh, mem_flags); | 1791 | qh = kzalloc(sizeof *qh, mem_flags); |
1793 | if (!qh) { | 1792 | if (!qh) { |
1793 | spin_lock_irqsave(&musb->lock, flags); | ||
1794 | usb_hcd_unlink_urb_from_ep(hcd, urb); | 1794 | usb_hcd_unlink_urb_from_ep(hcd, urb); |
1795 | spin_unlock_irqrestore(&musb->lock, flags); | ||
1795 | return -ENOMEM; | 1796 | return -ENOMEM; |
1796 | } | 1797 | } |
1797 | 1798 | ||
@@ -1873,7 +1874,11 @@ static int musb_urb_enqueue( | |||
1873 | /* set up tt info if needed */ | 1874 | /* set up tt info if needed */ |
1874 | if (urb->dev->tt) { | 1875 | if (urb->dev->tt) { |
1875 | qh->h_port_reg = (u8) urb->dev->ttport; | 1876 | qh->h_port_reg = (u8) urb->dev->ttport; |
1876 | qh->h_addr_reg |= 0x80; | 1877 | if (urb->dev->tt->hub) |
1878 | qh->h_addr_reg = | ||
1879 | (u8) urb->dev->tt->hub->devnum; | ||
1880 | if (urb->dev->tt->multi) | ||
1881 | qh->h_addr_reg |= 0x80; | ||
1877 | } | 1882 | } |
1878 | } | 1883 | } |
1879 | } | 1884 | } |
@@ -1903,7 +1908,9 @@ static int musb_urb_enqueue( | |||
1903 | 1908 | ||
1904 | done: | 1909 | done: |
1905 | if (ret != 0) { | 1910 | if (ret != 0) { |
1911 | spin_lock_irqsave(&musb->lock, flags); | ||
1906 | usb_hcd_unlink_urb_from_ep(hcd, urb); | 1912 | usb_hcd_unlink_urb_from_ep(hcd, urb); |
1913 | spin_unlock_irqrestore(&musb->lock, flags); | ||
1907 | kfree(qh); | 1914 | kfree(qh); |
1908 | } | 1915 | } |
1909 | return ret; | 1916 | return ret; |
diff --git a/drivers/usb/musb/musb_io.h b/drivers/usb/musb/musb_io.h index 6bbedae83af8..223f0a514094 100644 --- a/drivers/usb/musb/musb_io.h +++ b/drivers/usb/musb/musb_io.h | |||
@@ -37,7 +37,9 @@ | |||
37 | 37 | ||
38 | #include <linux/io.h> | 38 | #include <linux/io.h> |
39 | 39 | ||
40 | #ifndef CONFIG_ARM | 40 | #if !defined(CONFIG_ARM) && !defined(CONFIG_SUPERH) \ |
41 | && !defined(CONFIG_AVR32) && !defined(CONFIG_PPC32) \ | ||
42 | && !defined(CONFIG_PPC64) | ||
41 | static inline void readsl(const void __iomem *addr, void *buf, int len) | 43 | static inline void readsl(const void __iomem *addr, void *buf, int len) |
42 | { insl((unsigned long)addr, buf, len); } | 44 | { insl((unsigned long)addr, buf, len); } |
43 | static inline void readsw(const void __iomem *addr, void *buf, int len) | 45 | static inline void readsw(const void __iomem *addr, void *buf, int len) |
diff --git a/drivers/usb/musb/musb_procfs.c b/drivers/usb/musb/musb_procfs.c deleted file mode 100644 index 55e6b78bdccc..000000000000 --- a/drivers/usb/musb/musb_procfs.c +++ /dev/null | |||
@@ -1,830 +0,0 @@ | |||
1 | /* | ||
2 | * MUSB OTG driver debug support | ||
3 | * | ||
4 | * Copyright 2005 Mentor Graphics Corporation | ||
5 | * Copyright (C) 2005-2006 by Texas Instruments | ||
6 | * Copyright (C) 2006-2007 Nokia Corporation | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or | ||
9 | * modify it under the terms of the GNU General Public License | ||
10 | * version 2 as published by the Free Software Foundation. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, but | ||
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
15 | * General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
20 | * 02110-1301 USA | ||
21 | * | ||
22 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED | ||
23 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
24 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN | ||
25 | * NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
27 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | ||
28 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
29 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
31 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
32 | * | ||
33 | */ | ||
34 | |||
35 | #include <linux/kernel.h> | ||
36 | #include <linux/proc_fs.h> | ||
37 | #include <linux/seq_file.h> | ||
38 | #include <linux/uaccess.h> /* FIXME remove procfs writes */ | ||
39 | #include <asm/arch/hardware.h> | ||
40 | |||
41 | #include "musb_core.h" | ||
42 | |||
43 | #include "davinci.h" | ||
44 | |||
45 | #ifdef CONFIG_USB_MUSB_HDRC_HCD | ||
46 | |||
47 | static int dump_qh(struct musb_qh *qh, char *buf, unsigned max) | ||
48 | { | ||
49 | int count; | ||
50 | int tmp; | ||
51 | struct usb_host_endpoint *hep = qh->hep; | ||
52 | struct urb *urb; | ||
53 | |||
54 | count = snprintf(buf, max, " qh %p dev%d ep%d%s max%d\n", | ||
55 | qh, qh->dev->devnum, qh->epnum, | ||
56 | ({ char *s; switch (qh->type) { | ||
57 | case USB_ENDPOINT_XFER_BULK: | ||
58 | s = "-bulk"; break; | ||
59 | case USB_ENDPOINT_XFER_INT: | ||
60 | s = "-int"; break; | ||
61 | case USB_ENDPOINT_XFER_CONTROL: | ||
62 | s = ""; break; | ||
63 | default: | ||
64 | s = "iso"; break; | ||
65 | }; s; }), | ||
66 | qh->maxpacket); | ||
67 | if (count <= 0) | ||
68 | return 0; | ||
69 | buf += count; | ||
70 | max -= count; | ||
71 | |||
72 | list_for_each_entry(urb, &hep->urb_list, urb_list) { | ||
73 | tmp = snprintf(buf, max, "\t%s urb %p %d/%d\n", | ||
74 | usb_pipein(urb->pipe) ? "in" : "out", | ||
75 | urb, urb->actual_length, | ||
76 | urb->transfer_buffer_length); | ||
77 | if (tmp <= 0) | ||
78 | break; | ||
79 | tmp = min(tmp, (int)max); | ||
80 | count += tmp; | ||
81 | buf += tmp; | ||
82 | max -= tmp; | ||
83 | } | ||
84 | return count; | ||
85 | } | ||
86 | |||
87 | static int | ||
88 | dump_queue(struct list_head *q, char *buf, unsigned max) | ||
89 | { | ||
90 | int count = 0; | ||
91 | struct musb_qh *qh; | ||
92 | |||
93 | list_for_each_entry(qh, q, ring) { | ||
94 | int tmp; | ||
95 | |||
96 | tmp = dump_qh(qh, buf, max); | ||
97 | if (tmp <= 0) | ||
98 | break; | ||
99 | tmp = min(tmp, (int)max); | ||
100 | count += tmp; | ||
101 | buf += tmp; | ||
102 | max -= tmp; | ||
103 | } | ||
104 | return count; | ||
105 | } | ||
106 | |||
107 | #endif /* HCD */ | ||
108 | |||
109 | #ifdef CONFIG_USB_GADGET_MUSB_HDRC | ||
110 | static int dump_ep(struct musb_ep *ep, char *buffer, unsigned max) | ||
111 | { | ||
112 | char *buf = buffer; | ||
113 | int code = 0; | ||
114 | void __iomem *regs = ep->hw_ep->regs; | ||
115 | char *mode = "1buf"; | ||
116 | |||
117 | if (ep->is_in) { | ||
118 | if (ep->hw_ep->tx_double_buffered) | ||
119 | mode = "2buf"; | ||
120 | } else { | ||
121 | if (ep->hw_ep->rx_double_buffered) | ||
122 | mode = "2buf"; | ||
123 | } | ||
124 | |||
125 | do { | ||
126 | struct usb_request *req; | ||
127 | |||
128 | code = snprintf(buf, max, | ||
129 | "\n%s (hw%d): %s%s, csr %04x maxp %04x\n", | ||
130 | ep->name, ep->current_epnum, | ||
131 | mode, ep->dma ? " dma" : "", | ||
132 | musb_readw(regs, | ||
133 | (ep->is_in || !ep->current_epnum) | ||
134 | ? MUSB_TXCSR | ||
135 | : MUSB_RXCSR), | ||
136 | musb_readw(regs, ep->is_in | ||
137 | ? MUSB_TXMAXP | ||
138 | : MUSB_RXMAXP) | ||
139 | ); | ||
140 | if (code <= 0) | ||
141 | break; | ||
142 | code = min(code, (int) max); | ||
143 | buf += code; | ||
144 | max -= code; | ||
145 | |||
146 | if (is_cppi_enabled() && ep->current_epnum) { | ||
147 | unsigned cppi = ep->current_epnum - 1; | ||
148 | void __iomem *base = ep->musb->ctrl_base; | ||
149 | unsigned off1 = cppi << 2; | ||
150 | void __iomem *ram = base; | ||
151 | char tmp[16]; | ||
152 | |||
153 | if (ep->is_in) { | ||
154 | ram += DAVINCI_TXCPPI_STATERAM_OFFSET(cppi); | ||
155 | tmp[0] = 0; | ||
156 | } else { | ||
157 | ram += DAVINCI_RXCPPI_STATERAM_OFFSET(cppi); | ||
158 | snprintf(tmp, sizeof tmp, "%d left, ", | ||
159 | musb_readl(base, | ||
160 | DAVINCI_RXCPPI_BUFCNT0_REG + off1)); | ||
161 | } | ||
162 | |||
163 | code = snprintf(buf, max, "%cX DMA%d: %s" | ||
164 | "%08x %08x, %08x %08x; " | ||
165 | "%08x %08x %08x .. %08x\n", | ||
166 | ep->is_in ? 'T' : 'R', | ||
167 | ep->current_epnum - 1, tmp, | ||
168 | musb_readl(ram, 0 * 4), | ||
169 | musb_readl(ram, 1 * 4), | ||
170 | musb_readl(ram, 2 * 4), | ||
171 | musb_readl(ram, 3 * 4), | ||
172 | musb_readl(ram, 4 * 4), | ||
173 | musb_readl(ram, 5 * 4), | ||
174 | musb_readl(ram, 6 * 4), | ||
175 | musb_readl(ram, 7 * 4)); | ||
176 | if (code <= 0) | ||
177 | break; | ||
178 | code = min(code, (int) max); | ||
179 | buf += code; | ||
180 | max -= code; | ||
181 | } | ||
182 | |||
183 | if (list_empty(&ep->req_list)) { | ||
184 | code = snprintf(buf, max, "\t(queue empty)\n"); | ||
185 | if (code <= 0) | ||
186 | break; | ||
187 | code = min(code, (int) max); | ||
188 | buf += code; | ||
189 | max -= code; | ||
190 | break; | ||
191 | } | ||
192 | list_for_each_entry(req, &ep->req_list, list) { | ||
193 | code = snprintf(buf, max, "\treq %p, %s%s%d/%d\n", | ||
194 | req, | ||
195 | req->zero ? "zero, " : "", | ||
196 | req->short_not_ok ? "!short, " : "", | ||
197 | req->actual, req->length); | ||
198 | if (code <= 0) | ||
199 | break; | ||
200 | code = min(code, (int) max); | ||
201 | buf += code; | ||
202 | max -= code; | ||
203 | } | ||
204 | } while (0); | ||
205 | return buf - buffer; | ||
206 | } | ||
207 | #endif | ||
208 | |||
209 | static int | ||
210 | dump_end_info(struct musb *musb, u8 epnum, char *aBuffer, unsigned max) | ||
211 | { | ||
212 | int code = 0; | ||
213 | char *buf = aBuffer; | ||
214 | struct musb_hw_ep *hw_ep = &musb->endpoints[epnum]; | ||
215 | |||
216 | do { | ||
217 | musb_ep_select(musb->mregs, epnum); | ||
218 | #ifdef CONFIG_USB_MUSB_HDRC_HCD | ||
219 | if (is_host_active(musb)) { | ||
220 | int dump_rx, dump_tx; | ||
221 | void __iomem *regs = hw_ep->regs; | ||
222 | |||
223 | /* TEMPORARY (!) until we have a real periodic | ||
224 | * schedule tree ... | ||
225 | */ | ||
226 | if (!epnum) { | ||
227 | /* control is shared, uses RX queue | ||
228 | * but (mostly) shadowed tx registers | ||
229 | */ | ||
230 | dump_tx = !list_empty(&musb->control); | ||
231 | dump_rx = 0; | ||
232 | } else if (hw_ep == musb->bulk_ep) { | ||
233 | dump_tx = !list_empty(&musb->out_bulk); | ||
234 | dump_rx = !list_empty(&musb->in_bulk); | ||
235 | } else if (musb->periodic[epnum]) { | ||
236 | struct usb_host_endpoint *hep; | ||
237 | |||
238 | hep = musb->periodic[epnum]->hep; | ||
239 | dump_rx = hep->desc.bEndpointAddress | ||
240 | & USB_ENDPOINT_DIR_MASK; | ||
241 | dump_tx = !dump_rx; | ||
242 | } else | ||
243 | break; | ||
244 | /* END TEMPORARY */ | ||
245 | |||
246 | |||
247 | if (dump_rx) { | ||
248 | code = snprintf(buf, max, | ||
249 | "\nRX%d: %s rxcsr %04x interval %02x " | ||
250 | "max %04x type %02x; " | ||
251 | "dev %d hub %d port %d" | ||
252 | "\n", | ||
253 | epnum, | ||
254 | hw_ep->rx_double_buffered | ||
255 | ? "2buf" : "1buf", | ||
256 | musb_readw(regs, MUSB_RXCSR), | ||
257 | musb_readb(regs, MUSB_RXINTERVAL), | ||
258 | musb_readw(regs, MUSB_RXMAXP), | ||
259 | musb_readb(regs, MUSB_RXTYPE), | ||
260 | /* FIXME: assumes multipoint */ | ||
261 | musb_readb(musb->mregs, | ||
262 | MUSB_BUSCTL_OFFSET(epnum, | ||
263 | MUSB_RXFUNCADDR)), | ||
264 | musb_readb(musb->mregs, | ||
265 | MUSB_BUSCTL_OFFSET(epnum, | ||
266 | MUSB_RXHUBADDR)), | ||
267 | musb_readb(musb->mregs, | ||
268 | MUSB_BUSCTL_OFFSET(epnum, | ||
269 | MUSB_RXHUBPORT)) | ||
270 | ); | ||
271 | if (code <= 0) | ||
272 | break; | ||
273 | code = min(code, (int) max); | ||
274 | buf += code; | ||
275 | max -= code; | ||
276 | |||
277 | if (is_cppi_enabled() | ||
278 | && epnum | ||
279 | && hw_ep->rx_channel) { | ||
280 | unsigned cppi = epnum - 1; | ||
281 | unsigned off1 = cppi << 2; | ||
282 | void __iomem *base; | ||
283 | void __iomem *ram; | ||
284 | char tmp[16]; | ||
285 | |||
286 | base = musb->ctrl_base; | ||
287 | ram = DAVINCI_RXCPPI_STATERAM_OFFSET( | ||
288 | cppi) + base; | ||
289 | snprintf(tmp, sizeof tmp, "%d left, ", | ||
290 | musb_readl(base, | ||
291 | DAVINCI_RXCPPI_BUFCNT0_REG | ||
292 | + off1)); | ||
293 | |||
294 | code = snprintf(buf, max, | ||
295 | " rx dma%d: %s" | ||
296 | "%08x %08x, %08x %08x; " | ||
297 | "%08x %08x %08x .. %08x\n", | ||
298 | cppi, tmp, | ||
299 | musb_readl(ram, 0 * 4), | ||
300 | musb_readl(ram, 1 * 4), | ||
301 | musb_readl(ram, 2 * 4), | ||
302 | musb_readl(ram, 3 * 4), | ||
303 | musb_readl(ram, 4 * 4), | ||
304 | musb_readl(ram, 5 * 4), | ||
305 | musb_readl(ram, 6 * 4), | ||
306 | musb_readl(ram, 7 * 4)); | ||
307 | if (code <= 0) | ||
308 | break; | ||
309 | code = min(code, (int) max); | ||
310 | buf += code; | ||
311 | max -= code; | ||
312 | } | ||
313 | |||
314 | if (hw_ep == musb->bulk_ep | ||
315 | && !list_empty( | ||
316 | &musb->in_bulk)) { | ||
317 | code = dump_queue(&musb->in_bulk, | ||
318 | buf, max); | ||
319 | if (code <= 0) | ||
320 | break; | ||
321 | code = min(code, (int) max); | ||
322 | buf += code; | ||
323 | max -= code; | ||
324 | } else if (musb->periodic[epnum]) { | ||
325 | code = dump_qh(musb->periodic[epnum], | ||
326 | buf, max); | ||
327 | if (code <= 0) | ||
328 | break; | ||
329 | code = min(code, (int) max); | ||
330 | buf += code; | ||
331 | max -= code; | ||
332 | } | ||
333 | } | ||
334 | |||
335 | if (dump_tx) { | ||
336 | code = snprintf(buf, max, | ||
337 | "\nTX%d: %s txcsr %04x interval %02x " | ||
338 | "max %04x type %02x; " | ||
339 | "dev %d hub %d port %d" | ||
340 | "\n", | ||
341 | epnum, | ||
342 | hw_ep->tx_double_buffered | ||
343 | ? "2buf" : "1buf", | ||
344 | musb_readw(regs, MUSB_TXCSR), | ||
345 | musb_readb(regs, MUSB_TXINTERVAL), | ||
346 | musb_readw(regs, MUSB_TXMAXP), | ||
347 | musb_readb(regs, MUSB_TXTYPE), | ||
348 | /* FIXME: assumes multipoint */ | ||
349 | musb_readb(musb->mregs, | ||
350 | MUSB_BUSCTL_OFFSET(epnum, | ||
351 | MUSB_TXFUNCADDR)), | ||
352 | musb_readb(musb->mregs, | ||
353 | MUSB_BUSCTL_OFFSET(epnum, | ||
354 | MUSB_TXHUBADDR)), | ||
355 | musb_readb(musb->mregs, | ||
356 | MUSB_BUSCTL_OFFSET(epnum, | ||
357 | MUSB_TXHUBPORT)) | ||
358 | ); | ||
359 | if (code <= 0) | ||
360 | break; | ||
361 | code = min(code, (int) max); | ||
362 | buf += code; | ||
363 | max -= code; | ||
364 | |||
365 | if (is_cppi_enabled() | ||
366 | && epnum | ||
367 | && hw_ep->tx_channel) { | ||
368 | unsigned cppi = epnum - 1; | ||
369 | void __iomem *base; | ||
370 | void __iomem *ram; | ||
371 | |||
372 | base = musb->ctrl_base; | ||
373 | ram = DAVINCI_RXCPPI_STATERAM_OFFSET( | ||
374 | cppi) + base; | ||
375 | code = snprintf(buf, max, | ||
376 | " tx dma%d: " | ||
377 | "%08x %08x, %08x %08x; " | ||
378 | "%08x %08x %08x .. %08x\n", | ||
379 | cppi, | ||
380 | musb_readl(ram, 0 * 4), | ||
381 | musb_readl(ram, 1 * 4), | ||
382 | musb_readl(ram, 2 * 4), | ||
383 | musb_readl(ram, 3 * 4), | ||
384 | musb_readl(ram, 4 * 4), | ||
385 | musb_readl(ram, 5 * 4), | ||
386 | musb_readl(ram, 6 * 4), | ||
387 | musb_readl(ram, 7 * 4)); | ||
388 | if (code <= 0) | ||
389 | break; | ||
390 | code = min(code, (int) max); | ||
391 | buf += code; | ||
392 | max -= code; | ||
393 | } | ||
394 | |||
395 | if (hw_ep == musb->control_ep | ||
396 | && !list_empty( | ||
397 | &musb->control)) { | ||
398 | code = dump_queue(&musb->control, | ||
399 | buf, max); | ||
400 | if (code <= 0) | ||
401 | break; | ||
402 | code = min(code, (int) max); | ||
403 | buf += code; | ||
404 | max -= code; | ||
405 | } else if (hw_ep == musb->bulk_ep | ||
406 | && !list_empty( | ||
407 | &musb->out_bulk)) { | ||
408 | code = dump_queue(&musb->out_bulk, | ||
409 | buf, max); | ||
410 | if (code <= 0) | ||
411 | break; | ||
412 | code = min(code, (int) max); | ||
413 | buf += code; | ||
414 | max -= code; | ||
415 | } else if (musb->periodic[epnum]) { | ||
416 | code = dump_qh(musb->periodic[epnum], | ||
417 | buf, max); | ||
418 | if (code <= 0) | ||
419 | break; | ||
420 | code = min(code, (int) max); | ||
421 | buf += code; | ||
422 | max -= code; | ||
423 | } | ||
424 | } | ||
425 | } | ||
426 | #endif | ||
427 | #ifdef CONFIG_USB_GADGET_MUSB_HDRC | ||
428 | if (is_peripheral_active(musb)) { | ||
429 | code = 0; | ||
430 | |||
431 | if (hw_ep->ep_in.desc || !epnum) { | ||
432 | code = dump_ep(&hw_ep->ep_in, buf, max); | ||
433 | if (code <= 0) | ||
434 | break; | ||
435 | code = min(code, (int) max); | ||
436 | buf += code; | ||
437 | max -= code; | ||
438 | } | ||
439 | if (hw_ep->ep_out.desc) { | ||
440 | code = dump_ep(&hw_ep->ep_out, buf, max); | ||
441 | if (code <= 0) | ||
442 | break; | ||
443 | code = min(code, (int) max); | ||
444 | buf += code; | ||
445 | max -= code; | ||
446 | } | ||
447 | } | ||
448 | #endif | ||
449 | } while (0); | ||
450 | |||
451 | return buf - aBuffer; | ||
452 | } | ||
453 | |||
454 | /* Dump the current status and compile options. | ||
455 | * @param musb the device driver instance | ||
456 | * @param buffer where to dump the status; it must be big enough to hold the | ||
457 | * result otherwise "BAD THINGS HAPPENS(TM)". | ||
458 | */ | ||
459 | static int dump_header_stats(struct musb *musb, char *buffer) | ||
460 | { | ||
461 | int code, count = 0; | ||
462 | const void __iomem *mbase = musb->mregs; | ||
463 | |||
464 | *buffer = 0; | ||
465 | count = sprintf(buffer, "Status: %sHDRC, Mode=%s " | ||
466 | "(Power=%02x, DevCtl=%02x)\n", | ||
467 | (musb->is_multipoint ? "M" : ""), MUSB_MODE(musb), | ||
468 | musb_readb(mbase, MUSB_POWER), | ||
469 | musb_readb(mbase, MUSB_DEVCTL)); | ||
470 | if (count <= 0) | ||
471 | return 0; | ||
472 | buffer += count; | ||
473 | |||
474 | code = sprintf(buffer, "OTG state: %s; %sactive\n", | ||
475 | otg_state_string(musb), | ||
476 | musb->is_active ? "" : "in"); | ||
477 | if (code <= 0) | ||
478 | goto done; | ||
479 | buffer += code; | ||
480 | count += code; | ||
481 | |||
482 | code = sprintf(buffer, | ||
483 | "Options: " | ||
484 | #ifdef CONFIG_MUSB_PIO_ONLY | ||
485 | "pio" | ||
486 | #elif defined(CONFIG_USB_TI_CPPI_DMA) | ||
487 | "cppi-dma" | ||
488 | #elif defined(CONFIG_USB_INVENTRA_DMA) | ||
489 | "musb-dma" | ||
490 | #elif defined(CONFIG_USB_TUSB_OMAP_DMA) | ||
491 | "tusb-omap-dma" | ||
492 | #else | ||
493 | "?dma?" | ||
494 | #endif | ||
495 | ", " | ||
496 | #ifdef CONFIG_USB_MUSB_OTG | ||
497 | "otg (peripheral+host)" | ||
498 | #elif defined(CONFIG_USB_GADGET_MUSB_HDRC) | ||
499 | "peripheral" | ||
500 | #elif defined(CONFIG_USB_MUSB_HDRC_HCD) | ||
501 | "host" | ||
502 | #endif | ||
503 | ", debug=%d [eps=%d]\n", | ||
504 | debug, | ||
505 | musb->nr_endpoints); | ||
506 | if (code <= 0) | ||
507 | goto done; | ||
508 | count += code; | ||
509 | buffer += code; | ||
510 | |||
511 | #ifdef CONFIG_USB_GADGET_MUSB_HDRC | ||
512 | code = sprintf(buffer, "Peripheral address: %02x\n", | ||
513 | musb_readb(musb->ctrl_base, MUSB_FADDR)); | ||
514 | if (code <= 0) | ||
515 | goto done; | ||
516 | buffer += code; | ||
517 | count += code; | ||
518 | #endif | ||
519 | |||
520 | #ifdef CONFIG_USB_MUSB_HDRC_HCD | ||
521 | code = sprintf(buffer, "Root port status: %08x\n", | ||
522 | musb->port1_status); | ||
523 | if (code <= 0) | ||
524 | goto done; | ||
525 | buffer += code; | ||
526 | count += code; | ||
527 | #endif | ||
528 | |||
529 | #ifdef CONFIG_ARCH_DAVINCI | ||
530 | code = sprintf(buffer, | ||
531 | "DaVinci: ctrl=%02x stat=%1x phy=%03x\n" | ||
532 | "\trndis=%05x auto=%04x intsrc=%08x intmsk=%08x" | ||
533 | "\n", | ||
534 | musb_readl(musb->ctrl_base, DAVINCI_USB_CTRL_REG), | ||
535 | musb_readl(musb->ctrl_base, DAVINCI_USB_STAT_REG), | ||
536 | __raw_readl((void __force __iomem *) | ||
537 | IO_ADDRESS(USBPHY_CTL_PADDR)), | ||
538 | musb_readl(musb->ctrl_base, DAVINCI_RNDIS_REG), | ||
539 | musb_readl(musb->ctrl_base, DAVINCI_AUTOREQ_REG), | ||
540 | musb_readl(musb->ctrl_base, | ||
541 | DAVINCI_USB_INT_SOURCE_REG), | ||
542 | musb_readl(musb->ctrl_base, | ||
543 | DAVINCI_USB_INT_MASK_REG)); | ||
544 | if (code <= 0) | ||
545 | goto done; | ||
546 | count += code; | ||
547 | buffer += code; | ||
548 | #endif /* DAVINCI */ | ||
549 | |||
550 | #ifdef CONFIG_USB_TUSB6010 | ||
551 | code = sprintf(buffer, | ||
552 | "TUSB6010: devconf %08x, phy enable %08x drive %08x" | ||
553 | "\n\totg %03x timer %08x" | ||
554 | "\n\tprcm conf %08x mgmt %08x; int src %08x mask %08x" | ||
555 | "\n", | ||
556 | musb_readl(musb->ctrl_base, TUSB_DEV_CONF), | ||
557 | musb_readl(musb->ctrl_base, TUSB_PHY_OTG_CTRL_ENABLE), | ||
558 | musb_readl(musb->ctrl_base, TUSB_PHY_OTG_CTRL), | ||
559 | musb_readl(musb->ctrl_base, TUSB_DEV_OTG_STAT), | ||
560 | musb_readl(musb->ctrl_base, TUSB_DEV_OTG_TIMER), | ||
561 | musb_readl(musb->ctrl_base, TUSB_PRCM_CONF), | ||
562 | musb_readl(musb->ctrl_base, TUSB_PRCM_MNGMT), | ||
563 | musb_readl(musb->ctrl_base, TUSB_INT_SRC), | ||
564 | musb_readl(musb->ctrl_base, TUSB_INT_MASK)); | ||
565 | if (code <= 0) | ||
566 | goto done; | ||
567 | count += code; | ||
568 | buffer += code; | ||
569 | #endif /* DAVINCI */ | ||
570 | |||
571 | if (is_cppi_enabled() && musb->dma_controller) { | ||
572 | code = sprintf(buffer, | ||
573 | "CPPI: txcr=%d txsrc=%01x txena=%01x; " | ||
574 | "rxcr=%d rxsrc=%01x rxena=%01x " | ||
575 | "\n", | ||
576 | musb_readl(musb->ctrl_base, | ||
577 | DAVINCI_TXCPPI_CTRL_REG), | ||
578 | musb_readl(musb->ctrl_base, | ||
579 | DAVINCI_TXCPPI_RAW_REG), | ||
580 | musb_readl(musb->ctrl_base, | ||
581 | DAVINCI_TXCPPI_INTENAB_REG), | ||
582 | musb_readl(musb->ctrl_base, | ||
583 | DAVINCI_RXCPPI_CTRL_REG), | ||
584 | musb_readl(musb->ctrl_base, | ||
585 | DAVINCI_RXCPPI_RAW_REG), | ||
586 | musb_readl(musb->ctrl_base, | ||
587 | DAVINCI_RXCPPI_INTENAB_REG)); | ||
588 | if (code <= 0) | ||
589 | goto done; | ||
590 | count += code; | ||
591 | buffer += code; | ||
592 | } | ||
593 | |||
594 | #ifdef CONFIG_USB_GADGET_MUSB_HDRC | ||
595 | if (is_peripheral_enabled(musb)) { | ||
596 | code = sprintf(buffer, "Gadget driver: %s\n", | ||
597 | musb->gadget_driver | ||
598 | ? musb->gadget_driver->driver.name | ||
599 | : "(none)"); | ||
600 | if (code <= 0) | ||
601 | goto done; | ||
602 | count += code; | ||
603 | buffer += code; | ||
604 | } | ||
605 | #endif | ||
606 | |||
607 | done: | ||
608 | return count; | ||
609 | } | ||
610 | |||
611 | /* Write to ProcFS | ||
612 | * | ||
613 | * C soft-connect | ||
614 | * c soft-disconnect | ||
615 | * I enable HS | ||
616 | * i disable HS | ||
617 | * s stop session | ||
618 | * F force session (OTG-unfriendly) | ||
619 | * E rElinquish bus (OTG) | ||
620 | * H request host mode | ||
621 | * h cancel host request | ||
622 | * T start sending TEST_PACKET | ||
623 | * D<num> set/query the debug level | ||
624 | */ | ||
625 | static int musb_proc_write(struct file *file, const char __user *buffer, | ||
626 | unsigned long count, void *data) | ||
627 | { | ||
628 | char cmd; | ||
629 | u8 reg; | ||
630 | struct musb *musb = (struct musb *)data; | ||
631 | void __iomem *mbase = musb->mregs; | ||
632 | |||
633 | /* MOD_INC_USE_COUNT; */ | ||
634 | |||
635 | if (unlikely(copy_from_user(&cmd, buffer, 1))) | ||
636 | return -EFAULT; | ||
637 | |||
638 | switch (cmd) { | ||
639 | case 'C': | ||
640 | if (mbase) { | ||
641 | reg = musb_readb(mbase, MUSB_POWER) | ||
642 | | MUSB_POWER_SOFTCONN; | ||
643 | musb_writeb(mbase, MUSB_POWER, reg); | ||
644 | } | ||
645 | break; | ||
646 | |||
647 | case 'c': | ||
648 | if (mbase) { | ||
649 | reg = musb_readb(mbase, MUSB_POWER) | ||
650 | & ~MUSB_POWER_SOFTCONN; | ||
651 | musb_writeb(mbase, MUSB_POWER, reg); | ||
652 | } | ||
653 | break; | ||
654 | |||
655 | case 'I': | ||
656 | if (mbase) { | ||
657 | reg = musb_readb(mbase, MUSB_POWER) | ||
658 | | MUSB_POWER_HSENAB; | ||
659 | musb_writeb(mbase, MUSB_POWER, reg); | ||
660 | } | ||
661 | break; | ||
662 | |||
663 | case 'i': | ||
664 | if (mbase) { | ||
665 | reg = musb_readb(mbase, MUSB_POWER) | ||
666 | & ~MUSB_POWER_HSENAB; | ||
667 | musb_writeb(mbase, MUSB_POWER, reg); | ||
668 | } | ||
669 | break; | ||
670 | |||
671 | case 'F': | ||
672 | reg = musb_readb(mbase, MUSB_DEVCTL); | ||
673 | reg |= MUSB_DEVCTL_SESSION; | ||
674 | musb_writeb(mbase, MUSB_DEVCTL, reg); | ||
675 | break; | ||
676 | |||
677 | case 'H': | ||
678 | if (mbase) { | ||
679 | reg = musb_readb(mbase, MUSB_DEVCTL); | ||
680 | reg |= MUSB_DEVCTL_HR; | ||
681 | musb_writeb(mbase, MUSB_DEVCTL, reg); | ||
682 | /* MUSB_HST_MODE( ((struct musb*)data) ); */ | ||
683 | /* WARNING("Host Mode\n"); */ | ||
684 | } | ||
685 | break; | ||
686 | |||
687 | case 'h': | ||
688 | if (mbase) { | ||
689 | reg = musb_readb(mbase, MUSB_DEVCTL); | ||
690 | reg &= ~MUSB_DEVCTL_HR; | ||
691 | musb_writeb(mbase, MUSB_DEVCTL, reg); | ||
692 | } | ||
693 | break; | ||
694 | |||
695 | case 'T': | ||
696 | if (mbase) { | ||
697 | musb_load_testpacket(musb); | ||
698 | musb_writeb(mbase, MUSB_TESTMODE, | ||
699 | MUSB_TEST_PACKET); | ||
700 | } | ||
701 | break; | ||
702 | |||
703 | #if (MUSB_DEBUG > 0) | ||
704 | /* set/read debug level */ | ||
705 | case 'D':{ | ||
706 | if (count > 1) { | ||
707 | char digits[8], *p = digits; | ||
708 | int i = 0, level = 0, sign = 1; | ||
709 | int len = min(count - 1, (unsigned long)8); | ||
710 | |||
711 | if (copy_from_user(&digits, &buffer[1], len)) | ||
712 | return -EFAULT; | ||
713 | |||
714 | /* optional sign */ | ||
715 | if (*p == '-') { | ||
716 | len -= 1; | ||
717 | sign = -sign; | ||
718 | p++; | ||
719 | } | ||
720 | |||
721 | /* read it */ | ||
722 | while (i++ < len && *p > '0' && *p < '9') { | ||
723 | level = level * 10 + (*p - '0'); | ||
724 | p++; | ||
725 | } | ||
726 | |||
727 | level *= sign; | ||
728 | DBG(1, "debug level %d\n", level); | ||
729 | debug = level; | ||
730 | } | ||
731 | } | ||
732 | break; | ||
733 | |||
734 | |||
735 | case '?': | ||
736 | INFO("?: you are seeing it\n"); | ||
737 | INFO("C/c: soft connect enable/disable\n"); | ||
738 | INFO("I/i: hispeed enable/disable\n"); | ||
739 | INFO("F: force session start\n"); | ||
740 | INFO("H: host mode\n"); | ||
741 | INFO("T: start sending TEST_PACKET\n"); | ||
742 | INFO("D: set/read dbug level\n"); | ||
743 | break; | ||
744 | #endif | ||
745 | |||
746 | default: | ||
747 | ERR("Command %c not implemented\n", cmd); | ||
748 | break; | ||
749 | } | ||
750 | |||
751 | musb_platform_try_idle(musb, 0); | ||
752 | |||
753 | return count; | ||
754 | } | ||
755 | |||
756 | static int musb_proc_read(char *page, char **start, | ||
757 | off_t off, int count, int *eof, void *data) | ||
758 | { | ||
759 | char *buffer = page; | ||
760 | int code = 0; | ||
761 | unsigned long flags; | ||
762 | struct musb *musb = data; | ||
763 | unsigned epnum; | ||
764 | |||
765 | count -= off; | ||
766 | count -= 1; /* for NUL at end */ | ||
767 | if (count <= 0) | ||
768 | return -EINVAL; | ||
769 | |||
770 | spin_lock_irqsave(&musb->lock, flags); | ||
771 | |||
772 | code = dump_header_stats(musb, buffer); | ||
773 | if (code > 0) { | ||
774 | buffer += code; | ||
775 | count -= code; | ||
776 | } | ||
777 | |||
778 | /* generate the report for the end points */ | ||
779 | /* REVISIT ... not unless something's connected! */ | ||
780 | for (epnum = 0; count >= 0 && epnum < musb->nr_endpoints; | ||
781 | epnum++) { | ||
782 | code = dump_end_info(musb, epnum, buffer, count); | ||
783 | if (code > 0) { | ||
784 | buffer += code; | ||
785 | count -= code; | ||
786 | } | ||
787 | } | ||
788 | |||
789 | musb_platform_try_idle(musb, 0); | ||
790 | |||
791 | spin_unlock_irqrestore(&musb->lock, flags); | ||
792 | *eof = 1; | ||
793 | |||
794 | return buffer - page; | ||
795 | } | ||
796 | |||
797 | void __devexit musb_debug_delete(char *name, struct musb *musb) | ||
798 | { | ||
799 | if (musb->proc_entry) | ||
800 | remove_proc_entry(name, NULL); | ||
801 | } | ||
802 | |||
803 | struct proc_dir_entry *__init | ||
804 | musb_debug_create(char *name, struct musb *data) | ||
805 | { | ||
806 | struct proc_dir_entry *pde; | ||
807 | |||
808 | /* FIXME convert everything to seq_file; then later, debugfs */ | ||
809 | |||
810 | if (!name) | ||
811 | return NULL; | ||
812 | |||
813 | pde = create_proc_entry(name, S_IFREG | S_IRUGO | S_IWUSR, NULL); | ||
814 | data->proc_entry = pde; | ||
815 | if (pde) { | ||
816 | pde->data = data; | ||
817 | /* pde->owner = THIS_MODULE; */ | ||
818 | |||
819 | pde->read_proc = musb_proc_read; | ||
820 | pde->write_proc = musb_proc_write; | ||
821 | |||
822 | pde->size = 0; | ||
823 | |||
824 | pr_debug("Registered /proc/%s\n", name); | ||
825 | } else { | ||
826 | pr_debug("Cannot create a valid proc file entry"); | ||
827 | } | ||
828 | |||
829 | return pde; | ||
830 | } | ||
diff --git a/drivers/usb/musb/musbhsdma.c b/drivers/usb/musb/musbhsdma.c index 9ba8fb7fcd24..8c734ef2c1ed 100644 --- a/drivers/usb/musb/musbhsdma.c +++ b/drivers/usb/musb/musbhsdma.c | |||
@@ -45,8 +45,8 @@ | |||
45 | #define MUSB_HSDMA_ADDRESS 0x8 | 45 | #define MUSB_HSDMA_ADDRESS 0x8 |
46 | #define MUSB_HSDMA_COUNT 0xc | 46 | #define MUSB_HSDMA_COUNT 0xc |
47 | 47 | ||
48 | #define MUSB_HSDMA_CHANNEL_OFFSET(_bChannel, _offset) \ | 48 | #define MUSB_HSDMA_CHANNEL_OFFSET(_bchannel, _offset) \ |
49 | (MUSB_HSDMA_BASE + (_bChannel << 4) + _offset) | 49 | (MUSB_HSDMA_BASE + (_bchannel << 4) + _offset) |
50 | 50 | ||
51 | /* control register (16-bit): */ | 51 | /* control register (16-bit): */ |
52 | #define MUSB_HSDMA_ENABLE_SHIFT 0 | 52 | #define MUSB_HSDMA_ENABLE_SHIFT 0 |
@@ -67,23 +67,23 @@ | |||
67 | struct musb_dma_controller; | 67 | struct musb_dma_controller; |
68 | 68 | ||
69 | struct musb_dma_channel { | 69 | struct musb_dma_channel { |
70 | struct dma_channel Channel; | 70 | struct dma_channel channel; |
71 | struct musb_dma_controller *controller; | 71 | struct musb_dma_controller *controller; |
72 | u32 dwStartAddress; | 72 | u32 start_addr; |
73 | u32 len; | 73 | u32 len; |
74 | u16 wMaxPacketSize; | 74 | u16 max_packet_sz; |
75 | u8 bIndex; | 75 | u8 idx; |
76 | u8 epnum; | 76 | u8 epnum; |
77 | u8 transmit; | 77 | u8 transmit; |
78 | }; | 78 | }; |
79 | 79 | ||
80 | struct musb_dma_controller { | 80 | struct musb_dma_controller { |
81 | struct dma_controller Controller; | 81 | struct dma_controller controller; |
82 | struct musb_dma_channel aChannel[MUSB_HSDMA_CHANNELS]; | 82 | struct musb_dma_channel channel[MUSB_HSDMA_CHANNELS]; |
83 | void *pDmaPrivate; | 83 | void *private_data; |
84 | void __iomem *pCoreBase; | 84 | void __iomem *base; |
85 | u8 bChannelCount; | 85 | u8 channel_count; |
86 | u8 bmUsedChannels; | 86 | u8 used_channels; |
87 | u8 irq; | 87 | u8 irq; |
88 | }; | 88 | }; |
89 | 89 | ||
@@ -93,91 +93,91 @@ static int dma_controller_start(struct dma_controller *c) | |||
93 | return 0; | 93 | return 0; |
94 | } | 94 | } |
95 | 95 | ||
96 | static void dma_channel_release(struct dma_channel *pChannel); | 96 | static void dma_channel_release(struct dma_channel *channel); |
97 | 97 | ||
98 | static int dma_controller_stop(struct dma_controller *c) | 98 | static int dma_controller_stop(struct dma_controller *c) |
99 | { | 99 | { |
100 | struct musb_dma_controller *controller = | 100 | struct musb_dma_controller *controller = container_of(c, |
101 | container_of(c, struct musb_dma_controller, Controller); | 101 | struct musb_dma_controller, controller); |
102 | struct musb *musb = (struct musb *) controller->pDmaPrivate; | 102 | struct musb *musb = controller->private_data; |
103 | struct dma_channel *pChannel; | 103 | struct dma_channel *channel; |
104 | u8 bBit; | 104 | u8 bit; |
105 | 105 | ||
106 | if (controller->bmUsedChannels != 0) { | 106 | if (controller->used_channels != 0) { |
107 | dev_err(musb->controller, | 107 | dev_err(musb->controller, |
108 | "Stopping DMA controller while channel active\n"); | 108 | "Stopping DMA controller while channel active\n"); |
109 | 109 | ||
110 | for (bBit = 0; bBit < MUSB_HSDMA_CHANNELS; bBit++) { | 110 | for (bit = 0; bit < MUSB_HSDMA_CHANNELS; bit++) { |
111 | if (controller->bmUsedChannels & (1 << bBit)) { | 111 | if (controller->used_channels & (1 << bit)) { |
112 | pChannel = &controller->aChannel[bBit].Channel; | 112 | channel = &controller->channel[bit].channel; |
113 | dma_channel_release(pChannel); | 113 | dma_channel_release(channel); |
114 | 114 | ||
115 | if (!controller->bmUsedChannels) | 115 | if (!controller->used_channels) |
116 | break; | 116 | break; |
117 | } | 117 | } |
118 | } | 118 | } |
119 | } | 119 | } |
120 | |||
120 | return 0; | 121 | return 0; |
121 | } | 122 | } |
122 | 123 | ||
123 | static struct dma_channel *dma_channel_allocate(struct dma_controller *c, | 124 | static struct dma_channel *dma_channel_allocate(struct dma_controller *c, |
124 | struct musb_hw_ep *hw_ep, u8 transmit) | 125 | struct musb_hw_ep *hw_ep, u8 transmit) |
125 | { | 126 | { |
126 | u8 bBit; | 127 | struct musb_dma_controller *controller = container_of(c, |
127 | struct dma_channel *pChannel = NULL; | 128 | struct musb_dma_controller, controller); |
128 | struct musb_dma_channel *pImplChannel = NULL; | 129 | struct musb_dma_channel *musb_channel = NULL; |
129 | struct musb_dma_controller *controller = | 130 | struct dma_channel *channel = NULL; |
130 | container_of(c, struct musb_dma_controller, Controller); | 131 | u8 bit; |
131 | 132 | ||
132 | for (bBit = 0; bBit < MUSB_HSDMA_CHANNELS; bBit++) { | 133 | for (bit = 0; bit < MUSB_HSDMA_CHANNELS; bit++) { |
133 | if (!(controller->bmUsedChannels & (1 << bBit))) { | 134 | if (!(controller->used_channels & (1 << bit))) { |
134 | controller->bmUsedChannels |= (1 << bBit); | 135 | controller->used_channels |= (1 << bit); |
135 | pImplChannel = &(controller->aChannel[bBit]); | 136 | musb_channel = &(controller->channel[bit]); |
136 | pImplChannel->controller = controller; | 137 | musb_channel->controller = controller; |
137 | pImplChannel->bIndex = bBit; | 138 | musb_channel->idx = bit; |
138 | pImplChannel->epnum = hw_ep->epnum; | 139 | musb_channel->epnum = hw_ep->epnum; |
139 | pImplChannel->transmit = transmit; | 140 | musb_channel->transmit = transmit; |
140 | pChannel = &(pImplChannel->Channel); | 141 | channel = &(musb_channel->channel); |
141 | pChannel->private_data = pImplChannel; | 142 | channel->private_data = musb_channel; |
142 | pChannel->status = MUSB_DMA_STATUS_FREE; | 143 | channel->status = MUSB_DMA_STATUS_FREE; |
143 | pChannel->max_len = 0x10000; | 144 | channel->max_len = 0x10000; |
144 | /* Tx => mode 1; Rx => mode 0 */ | 145 | /* Tx => mode 1; Rx => mode 0 */ |
145 | pChannel->desired_mode = transmit; | 146 | channel->desired_mode = transmit; |
146 | pChannel->actual_len = 0; | 147 | channel->actual_len = 0; |
147 | break; | 148 | break; |
148 | } | 149 | } |
149 | } | 150 | } |
150 | return pChannel; | 151 | |
152 | return channel; | ||
151 | } | 153 | } |
152 | 154 | ||
153 | static void dma_channel_release(struct dma_channel *pChannel) | 155 | static void dma_channel_release(struct dma_channel *channel) |
154 | { | 156 | { |
155 | struct musb_dma_channel *pImplChannel = | 157 | struct musb_dma_channel *musb_channel = channel->private_data; |
156 | (struct musb_dma_channel *) pChannel->private_data; | ||
157 | 158 | ||
158 | pChannel->actual_len = 0; | 159 | channel->actual_len = 0; |
159 | pImplChannel->dwStartAddress = 0; | 160 | musb_channel->start_addr = 0; |
160 | pImplChannel->len = 0; | 161 | musb_channel->len = 0; |
161 | 162 | ||
162 | pImplChannel->controller->bmUsedChannels &= | 163 | musb_channel->controller->used_channels &= |
163 | ~(1 << pImplChannel->bIndex); | 164 | ~(1 << musb_channel->idx); |
164 | 165 | ||
165 | pChannel->status = MUSB_DMA_STATUS_UNKNOWN; | 166 | channel->status = MUSB_DMA_STATUS_UNKNOWN; |
166 | } | 167 | } |
167 | 168 | ||
168 | static void configure_channel(struct dma_channel *pChannel, | 169 | static void configure_channel(struct dma_channel *channel, |
169 | u16 packet_sz, u8 mode, | 170 | u16 packet_sz, u8 mode, |
170 | dma_addr_t dma_addr, u32 len) | 171 | dma_addr_t dma_addr, u32 len) |
171 | { | 172 | { |
172 | struct musb_dma_channel *pImplChannel = | 173 | struct musb_dma_channel *musb_channel = channel->private_data; |
173 | (struct musb_dma_channel *) pChannel->private_data; | 174 | struct musb_dma_controller *controller = musb_channel->controller; |
174 | struct musb_dma_controller *controller = pImplChannel->controller; | 175 | void __iomem *mbase = controller->base; |
175 | void __iomem *mbase = controller->pCoreBase; | 176 | u8 bchannel = musb_channel->idx; |
176 | u8 bChannel = pImplChannel->bIndex; | ||
177 | u16 csr = 0; | 177 | u16 csr = 0; |
178 | 178 | ||
179 | DBG(4, "%p, pkt_sz %d, addr 0x%x, len %d, mode %d\n", | 179 | DBG(4, "%p, pkt_sz %d, addr 0x%x, len %d, mode %d\n", |
180 | pChannel, packet_sz, dma_addr, len, mode); | 180 | channel, packet_sz, dma_addr, len, mode); |
181 | 181 | ||
182 | if (mode) { | 182 | if (mode) { |
183 | csr |= 1 << MUSB_HSDMA_MODE1_SHIFT; | 183 | csr |= 1 << MUSB_HSDMA_MODE1_SHIFT; |
@@ -195,180 +195,183 @@ static void configure_channel(struct dma_channel *pChannel, | |||
195 | } | 195 | } |
196 | } | 196 | } |
197 | 197 | ||
198 | csr |= (pImplChannel->epnum << MUSB_HSDMA_ENDPOINT_SHIFT) | 198 | csr |= (musb_channel->epnum << MUSB_HSDMA_ENDPOINT_SHIFT) |
199 | | (1 << MUSB_HSDMA_ENABLE_SHIFT) | 199 | | (1 << MUSB_HSDMA_ENABLE_SHIFT) |
200 | | (1 << MUSB_HSDMA_IRQENABLE_SHIFT) | 200 | | (1 << MUSB_HSDMA_IRQENABLE_SHIFT) |
201 | | (pImplChannel->transmit | 201 | | (musb_channel->transmit |
202 | ? (1 << MUSB_HSDMA_TRANSMIT_SHIFT) | 202 | ? (1 << MUSB_HSDMA_TRANSMIT_SHIFT) |
203 | : 0); | 203 | : 0); |
204 | 204 | ||
205 | /* address/count */ | 205 | /* address/count */ |
206 | musb_writel(mbase, | 206 | musb_writel(mbase, |
207 | MUSB_HSDMA_CHANNEL_OFFSET(bChannel, MUSB_HSDMA_ADDRESS), | 207 | MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_ADDRESS), |
208 | dma_addr); | 208 | dma_addr); |
209 | musb_writel(mbase, | 209 | musb_writel(mbase, |
210 | MUSB_HSDMA_CHANNEL_OFFSET(bChannel, MUSB_HSDMA_COUNT), | 210 | MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_COUNT), |
211 | len); | 211 | len); |
212 | 212 | ||
213 | /* control (this should start things) */ | 213 | /* control (this should start things) */ |
214 | musb_writew(mbase, | 214 | musb_writew(mbase, |
215 | MUSB_HSDMA_CHANNEL_OFFSET(bChannel, MUSB_HSDMA_CONTROL), | 215 | MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_CONTROL), |
216 | csr); | 216 | csr); |
217 | } | 217 | } |
218 | 218 | ||
219 | static int dma_channel_program(struct dma_channel *pChannel, | 219 | static int dma_channel_program(struct dma_channel *channel, |
220 | u16 packet_sz, u8 mode, | 220 | u16 packet_sz, u8 mode, |
221 | dma_addr_t dma_addr, u32 len) | 221 | dma_addr_t dma_addr, u32 len) |
222 | { | 222 | { |
223 | struct musb_dma_channel *pImplChannel = | 223 | struct musb_dma_channel *musb_channel = channel->private_data; |
224 | (struct musb_dma_channel *) pChannel->private_data; | ||
225 | 224 | ||
226 | DBG(2, "ep%d-%s pkt_sz %d, dma_addr 0x%x length %d, mode %d\n", | 225 | DBG(2, "ep%d-%s pkt_sz %d, dma_addr 0x%x length %d, mode %d\n", |
227 | pImplChannel->epnum, | 226 | musb_channel->epnum, |
228 | pImplChannel->transmit ? "Tx" : "Rx", | 227 | musb_channel->transmit ? "Tx" : "Rx", |
229 | packet_sz, dma_addr, len, mode); | 228 | packet_sz, dma_addr, len, mode); |
230 | 229 | ||
231 | BUG_ON(pChannel->status == MUSB_DMA_STATUS_UNKNOWN || | 230 | BUG_ON(channel->status == MUSB_DMA_STATUS_UNKNOWN || |
232 | pChannel->status == MUSB_DMA_STATUS_BUSY); | 231 | channel->status == MUSB_DMA_STATUS_BUSY); |
233 | 232 | ||
234 | pChannel->actual_len = 0; | 233 | channel->actual_len = 0; |
235 | pImplChannel->dwStartAddress = dma_addr; | 234 | musb_channel->start_addr = dma_addr; |
236 | pImplChannel->len = len; | 235 | musb_channel->len = len; |
237 | pImplChannel->wMaxPacketSize = packet_sz; | 236 | musb_channel->max_packet_sz = packet_sz; |
238 | pChannel->status = MUSB_DMA_STATUS_BUSY; | 237 | channel->status = MUSB_DMA_STATUS_BUSY; |
239 | 238 | ||
240 | if ((mode == 1) && (len >= packet_sz)) | 239 | if ((mode == 1) && (len >= packet_sz)) |
241 | configure_channel(pChannel, packet_sz, 1, dma_addr, len); | 240 | configure_channel(channel, packet_sz, 1, dma_addr, len); |
242 | else | 241 | else |
243 | configure_channel(pChannel, packet_sz, 0, dma_addr, len); | 242 | configure_channel(channel, packet_sz, 0, dma_addr, len); |
244 | 243 | ||
245 | return true; | 244 | return true; |
246 | } | 245 | } |
247 | 246 | ||
248 | static int dma_channel_abort(struct dma_channel *pChannel) | 247 | static int dma_channel_abort(struct dma_channel *channel) |
249 | { | 248 | { |
250 | struct musb_dma_channel *pImplChannel = | 249 | struct musb_dma_channel *musb_channel = channel->private_data; |
251 | (struct musb_dma_channel *) pChannel->private_data; | 250 | void __iomem *mbase = musb_channel->controller->base; |
252 | u8 bChannel = pImplChannel->bIndex; | 251 | |
253 | void __iomem *mbase = pImplChannel->controller->pCoreBase; | 252 | u8 bchannel = musb_channel->idx; |
254 | u16 csr; | 253 | u16 csr; |
255 | 254 | ||
256 | if (pChannel->status == MUSB_DMA_STATUS_BUSY) { | 255 | if (channel->status == MUSB_DMA_STATUS_BUSY) { |
257 | if (pImplChannel->transmit) { | 256 | if (musb_channel->transmit) { |
258 | 257 | ||
259 | csr = musb_readw(mbase, | 258 | csr = musb_readw(mbase, |
260 | MUSB_EP_OFFSET(pImplChannel->epnum, | 259 | MUSB_EP_OFFSET(musb_channel->epnum, |
261 | MUSB_TXCSR)); | 260 | MUSB_TXCSR)); |
262 | csr &= ~(MUSB_TXCSR_AUTOSET | | 261 | csr &= ~(MUSB_TXCSR_AUTOSET | |
263 | MUSB_TXCSR_DMAENAB | | 262 | MUSB_TXCSR_DMAENAB | |
264 | MUSB_TXCSR_DMAMODE); | 263 | MUSB_TXCSR_DMAMODE); |
265 | musb_writew(mbase, | 264 | musb_writew(mbase, |
266 | MUSB_EP_OFFSET(pImplChannel->epnum, | 265 | MUSB_EP_OFFSET(musb_channel->epnum, MUSB_TXCSR), |
267 | MUSB_TXCSR), | ||
268 | csr); | 266 | csr); |
269 | } else { | 267 | } else { |
270 | csr = musb_readw(mbase, | 268 | csr = musb_readw(mbase, |
271 | MUSB_EP_OFFSET(pImplChannel->epnum, | 269 | MUSB_EP_OFFSET(musb_channel->epnum, |
272 | MUSB_RXCSR)); | 270 | MUSB_RXCSR)); |
273 | csr &= ~(MUSB_RXCSR_AUTOCLEAR | | 271 | csr &= ~(MUSB_RXCSR_AUTOCLEAR | |
274 | MUSB_RXCSR_DMAENAB | | 272 | MUSB_RXCSR_DMAENAB | |
275 | MUSB_RXCSR_DMAMODE); | 273 | MUSB_RXCSR_DMAMODE); |
276 | musb_writew(mbase, | 274 | musb_writew(mbase, |
277 | MUSB_EP_OFFSET(pImplChannel->epnum, | 275 | MUSB_EP_OFFSET(musb_channel->epnum, MUSB_RXCSR), |
278 | MUSB_RXCSR), | ||
279 | csr); | 276 | csr); |
280 | } | 277 | } |
281 | 278 | ||
282 | musb_writew(mbase, | 279 | musb_writew(mbase, |
283 | MUSB_HSDMA_CHANNEL_OFFSET(bChannel, MUSB_HSDMA_CONTROL), | 280 | MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_CONTROL), |
284 | 0); | 281 | 0); |
285 | musb_writel(mbase, | 282 | musb_writel(mbase, |
286 | MUSB_HSDMA_CHANNEL_OFFSET(bChannel, MUSB_HSDMA_ADDRESS), | 283 | MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_ADDRESS), |
287 | 0); | 284 | 0); |
288 | musb_writel(mbase, | 285 | musb_writel(mbase, |
289 | MUSB_HSDMA_CHANNEL_OFFSET(bChannel, MUSB_HSDMA_COUNT), | 286 | MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_COUNT), |
290 | 0); | 287 | 0); |
291 | 288 | ||
292 | pChannel->status = MUSB_DMA_STATUS_FREE; | 289 | channel->status = MUSB_DMA_STATUS_FREE; |
293 | } | 290 | } |
291 | |||
294 | return 0; | 292 | return 0; |
295 | } | 293 | } |
296 | 294 | ||
297 | static irqreturn_t dma_controller_irq(int irq, void *private_data) | 295 | static irqreturn_t dma_controller_irq(int irq, void *private_data) |
298 | { | 296 | { |
299 | struct musb_dma_controller *controller = | 297 | struct musb_dma_controller *controller = private_data; |
300 | (struct musb_dma_controller *)private_data; | 298 | struct musb *musb = controller->private_data; |
301 | struct musb_dma_channel *pImplChannel; | 299 | struct musb_dma_channel *musb_channel; |
302 | struct musb *musb = controller->pDmaPrivate; | 300 | struct dma_channel *channel; |
303 | void __iomem *mbase = controller->pCoreBase; | 301 | |
304 | struct dma_channel *pChannel; | 302 | void __iomem *mbase = controller->base; |
305 | u8 bChannel; | 303 | |
306 | u16 csr; | ||
307 | u32 dwAddress; | ||
308 | u8 int_hsdma; | ||
309 | irqreturn_t retval = IRQ_NONE; | 304 | irqreturn_t retval = IRQ_NONE; |
305 | |||
310 | unsigned long flags; | 306 | unsigned long flags; |
311 | 307 | ||
308 | u8 bchannel; | ||
309 | u8 int_hsdma; | ||
310 | |||
311 | u32 addr; | ||
312 | u16 csr; | ||
313 | |||
312 | spin_lock_irqsave(&musb->lock, flags); | 314 | spin_lock_irqsave(&musb->lock, flags); |
313 | 315 | ||
314 | int_hsdma = musb_readb(mbase, MUSB_HSDMA_INTR); | 316 | int_hsdma = musb_readb(mbase, MUSB_HSDMA_INTR); |
315 | if (!int_hsdma) | 317 | if (!int_hsdma) |
316 | goto done; | 318 | goto done; |
317 | 319 | ||
318 | for (bChannel = 0; bChannel < MUSB_HSDMA_CHANNELS; bChannel++) { | 320 | for (bchannel = 0; bchannel < MUSB_HSDMA_CHANNELS; bchannel++) { |
319 | if (int_hsdma & (1 << bChannel)) { | 321 | if (int_hsdma & (1 << bchannel)) { |
320 | pImplChannel = (struct musb_dma_channel *) | 322 | musb_channel = (struct musb_dma_channel *) |
321 | &(controller->aChannel[bChannel]); | 323 | &(controller->channel[bchannel]); |
322 | pChannel = &pImplChannel->Channel; | 324 | channel = &musb_channel->channel; |
323 | 325 | ||
324 | csr = musb_readw(mbase, | 326 | csr = musb_readw(mbase, |
325 | MUSB_HSDMA_CHANNEL_OFFSET(bChannel, | 327 | MUSB_HSDMA_CHANNEL_OFFSET(bchannel, |
326 | MUSB_HSDMA_CONTROL)); | 328 | MUSB_HSDMA_CONTROL)); |
327 | 329 | ||
328 | if (csr & (1 << MUSB_HSDMA_BUSERROR_SHIFT)) | 330 | if (csr & (1 << MUSB_HSDMA_BUSERROR_SHIFT)) { |
329 | pImplChannel->Channel.status = | 331 | musb_channel->channel.status = |
330 | MUSB_DMA_STATUS_BUS_ABORT; | 332 | MUSB_DMA_STATUS_BUS_ABORT; |
331 | else { | 333 | } else { |
332 | u8 devctl; | 334 | u8 devctl; |
333 | 335 | ||
334 | dwAddress = musb_readl(mbase, | 336 | addr = musb_readl(mbase, |
335 | MUSB_HSDMA_CHANNEL_OFFSET( | 337 | MUSB_HSDMA_CHANNEL_OFFSET( |
336 | bChannel, | 338 | bchannel, |
337 | MUSB_HSDMA_ADDRESS)); | 339 | MUSB_HSDMA_ADDRESS)); |
338 | pChannel->actual_len = dwAddress | 340 | channel->actual_len = addr |
339 | - pImplChannel->dwStartAddress; | 341 | - musb_channel->start_addr; |
340 | 342 | ||
341 | DBG(2, "ch %p, 0x%x -> 0x%x (%d / %d) %s\n", | 343 | DBG(2, "ch %p, 0x%x -> 0x%x (%d / %d) %s\n", |
342 | pChannel, pImplChannel->dwStartAddress, | 344 | channel, musb_channel->start_addr, |
343 | dwAddress, pChannel->actual_len, | 345 | addr, channel->actual_len, |
344 | pImplChannel->len, | 346 | musb_channel->len, |
345 | (pChannel->actual_len | 347 | (channel->actual_len |
346 | < pImplChannel->len) ? | 348 | < musb_channel->len) ? |
347 | "=> reconfig 0" : "=> complete"); | 349 | "=> reconfig 0" : "=> complete"); |
348 | 350 | ||
349 | devctl = musb_readb(mbase, MUSB_DEVCTL); | 351 | devctl = musb_readb(mbase, MUSB_DEVCTL); |
350 | 352 | ||
351 | pChannel->status = MUSB_DMA_STATUS_FREE; | 353 | channel->status = MUSB_DMA_STATUS_FREE; |
352 | 354 | ||
353 | /* completed */ | 355 | /* completed */ |
354 | if ((devctl & MUSB_DEVCTL_HM) | 356 | if ((devctl & MUSB_DEVCTL_HM) |
355 | && (pImplChannel->transmit) | 357 | && (musb_channel->transmit) |
356 | && ((pChannel->desired_mode == 0) | 358 | && ((channel->desired_mode == 0) |
357 | || (pChannel->actual_len & | 359 | || (channel->actual_len & |
358 | (pImplChannel->wMaxPacketSize - 1))) | 360 | (musb_channel->max_packet_sz - 1))) |
359 | ) { | 361 | ) { |
360 | /* Send out the packet */ | 362 | /* Send out the packet */ |
361 | musb_ep_select(mbase, | 363 | musb_ep_select(mbase, |
362 | pImplChannel->epnum); | 364 | musb_channel->epnum); |
363 | musb_writew(mbase, MUSB_EP_OFFSET( | 365 | musb_writew(mbase, MUSB_EP_OFFSET( |
364 | pImplChannel->epnum, | 366 | musb_channel->epnum, |
365 | MUSB_TXCSR), | 367 | MUSB_TXCSR), |
366 | MUSB_TXCSR_TXPKTRDY); | 368 | MUSB_TXCSR_TXPKTRDY); |
367 | } else | 369 | } else { |
368 | musb_dma_completion( | 370 | musb_dma_completion( |
369 | musb, | 371 | musb, |
370 | pImplChannel->epnum, | 372 | musb_channel->epnum, |
371 | pImplChannel->transmit); | 373 | musb_channel->transmit); |
374 | } | ||
372 | } | 375 | } |
373 | } | 376 | } |
374 | } | 377 | } |
@@ -380,9 +383,9 @@ done: | |||
380 | 383 | ||
381 | void dma_controller_destroy(struct dma_controller *c) | 384 | void dma_controller_destroy(struct dma_controller *c) |
382 | { | 385 | { |
383 | struct musb_dma_controller *controller; | 386 | struct musb_dma_controller *controller = container_of(c, |
387 | struct musb_dma_controller, controller); | ||
384 | 388 | ||
385 | controller = container_of(c, struct musb_dma_controller, Controller); | ||
386 | if (!controller) | 389 | if (!controller) |
387 | return; | 390 | return; |
388 | 391 | ||
@@ -393,7 +396,7 @@ void dma_controller_destroy(struct dma_controller *c) | |||
393 | } | 396 | } |
394 | 397 | ||
395 | struct dma_controller *__init | 398 | struct dma_controller *__init |
396 | dma_controller_create(struct musb *musb, void __iomem *pCoreBase) | 399 | dma_controller_create(struct musb *musb, void __iomem *base) |
397 | { | 400 | { |
398 | struct musb_dma_controller *controller; | 401 | struct musb_dma_controller *controller; |
399 | struct device *dev = musb->controller; | 402 | struct device *dev = musb->controller; |
@@ -405,29 +408,30 @@ dma_controller_create(struct musb *musb, void __iomem *pCoreBase) | |||
405 | return NULL; | 408 | return NULL; |
406 | } | 409 | } |
407 | 410 | ||
408 | controller = kzalloc(sizeof(struct musb_dma_controller), GFP_KERNEL); | 411 | controller = kzalloc(sizeof(*controller), GFP_KERNEL); |
409 | if (!controller) | 412 | if (!controller) |
410 | return NULL; | 413 | return NULL; |
411 | 414 | ||
412 | controller->bChannelCount = MUSB_HSDMA_CHANNELS; | 415 | controller->channel_count = MUSB_HSDMA_CHANNELS; |
413 | controller->pDmaPrivate = musb; | 416 | controller->private_data = musb; |
414 | controller->pCoreBase = pCoreBase; | 417 | controller->base = base; |
415 | 418 | ||
416 | controller->Controller.start = dma_controller_start; | 419 | controller->controller.start = dma_controller_start; |
417 | controller->Controller.stop = dma_controller_stop; | 420 | controller->controller.stop = dma_controller_stop; |
418 | controller->Controller.channel_alloc = dma_channel_allocate; | 421 | controller->controller.channel_alloc = dma_channel_allocate; |
419 | controller->Controller.channel_release = dma_channel_release; | 422 | controller->controller.channel_release = dma_channel_release; |
420 | controller->Controller.channel_program = dma_channel_program; | 423 | controller->controller.channel_program = dma_channel_program; |
421 | controller->Controller.channel_abort = dma_channel_abort; | 424 | controller->controller.channel_abort = dma_channel_abort; |
422 | 425 | ||
423 | if (request_irq(irq, dma_controller_irq, IRQF_DISABLED, | 426 | if (request_irq(irq, dma_controller_irq, IRQF_DISABLED, |
424 | musb->controller->bus_id, &controller->Controller)) { | 427 | musb->controller->bus_id, &controller->controller)) { |
425 | dev_err(dev, "request_irq %d failed!\n", irq); | 428 | dev_err(dev, "request_irq %d failed!\n", irq); |
426 | dma_controller_destroy(&controller->Controller); | 429 | dma_controller_destroy(&controller->controller); |
430 | |||
427 | return NULL; | 431 | return NULL; |
428 | } | 432 | } |
429 | 433 | ||
430 | controller->irq = irq; | 434 | controller->irq = irq; |
431 | 435 | ||
432 | return &controller->Controller; | 436 | return &controller->controller; |
433 | } | 437 | } |
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c index 298b22e6ad0d..9d2dcb121c5e 100644 --- a/drivers/usb/musb/omap2430.c +++ b/drivers/usb/musb/omap2430.c | |||
@@ -35,8 +35,8 @@ | |||
35 | #include <linux/io.h> | 35 | #include <linux/io.h> |
36 | 36 | ||
37 | #include <asm/mach-types.h> | 37 | #include <asm/mach-types.h> |
38 | #include <asm/arch/hardware.h> | 38 | #include <mach/hardware.h> |
39 | #include <asm/arch/mux.h> | 39 | #include <mach/mux.h> |
40 | 40 | ||
41 | #include "musb_core.h" | 41 | #include "musb_core.h" |
42 | #include "omap2430.h" | 42 | #include "omap2430.h" |
diff --git a/drivers/usb/musb/omap2430.h b/drivers/usb/musb/omap2430.h index 786a62071f72..dc7670718cd2 100644 --- a/drivers/usb/musb/omap2430.h +++ b/drivers/usb/musb/omap2430.h | |||
@@ -11,8 +11,8 @@ | |||
11 | #define __MUSB_OMAP243X_H__ | 11 | #define __MUSB_OMAP243X_H__ |
12 | 12 | ||
13 | #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3430) | 13 | #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3430) |
14 | #include <asm/arch/hardware.h> | 14 | #include <mach/hardware.h> |
15 | #include <asm/arch/usb.h> | 15 | #include <mach/usb.h> |
16 | 16 | ||
17 | /* | 17 | /* |
18 | * OMAP2430-specific definitions | 18 | * OMAP2430-specific definitions |
diff --git a/drivers/usb/serial/aircable.c b/drivers/usb/serial/aircable.c index 79ea98c66fa8..537f953bd7f8 100644 --- a/drivers/usb/serial/aircable.c +++ b/drivers/usb/serial/aircable.c | |||
@@ -220,8 +220,8 @@ static void aircable_send(struct usb_serial_port *port) | |||
220 | 220 | ||
221 | buf = kzalloc(count + HCI_HEADER_LENGTH, GFP_ATOMIC); | 221 | buf = kzalloc(count + HCI_HEADER_LENGTH, GFP_ATOMIC); |
222 | if (!buf) { | 222 | if (!buf) { |
223 | err("%s- kzalloc(%d) failed.", __func__, | 223 | dev_err(&port->dev, "%s- kzalloc(%d) failed.\n", |
224 | count + HCI_HEADER_LENGTH); | 224 | __func__, count + HCI_HEADER_LENGTH); |
225 | return; | 225 | return; |
226 | } | 226 | } |
227 | 227 | ||
@@ -272,23 +272,24 @@ static void aircable_read(struct work_struct *work) | |||
272 | * 64 bytes, to ensure I do not get throttled. | 272 | * 64 bytes, to ensure I do not get throttled. |
273 | * Ask USB mailing list for better aproach. | 273 | * Ask USB mailing list for better aproach. |
274 | */ | 274 | */ |
275 | tty = port->port.tty; | 275 | tty = tty_port_tty_get(&port->port); |
276 | 276 | ||
277 | if (!tty) { | 277 | if (!tty) { |
278 | schedule_work(&priv->rx_work); | 278 | schedule_work(&priv->rx_work); |
279 | err("%s - No tty available", __func__); | 279 | dev_err(&port->dev, "%s - No tty available\n", __func__); |
280 | return ; | 280 | return ; |
281 | } | 281 | } |
282 | 282 | ||
283 | count = min(64, serial_buf_data_avail(priv->rx_buf)); | 283 | count = min(64, serial_buf_data_avail(priv->rx_buf)); |
284 | 284 | ||
285 | if (count <= 0) | 285 | if (count <= 0) |
286 | return; /* We have finished sending everything. */ | 286 | goto out; /* We have finished sending everything. */ |
287 | 287 | ||
288 | tty_prepare_flip_string(tty, &data, count); | 288 | tty_prepare_flip_string(tty, &data, count); |
289 | if (!data) { | 289 | if (!data) { |
290 | err("%s- kzalloc(%d) failed.", __func__, count); | 290 | dev_err(&port->dev, "%s- kzalloc(%d) failed.", |
291 | return; | 291 | __func__, count); |
292 | goto out; | ||
292 | } | 293 | } |
293 | 294 | ||
294 | serial_buf_get(priv->rx_buf, data, count); | 295 | serial_buf_get(priv->rx_buf, data, count); |
@@ -297,7 +298,8 @@ static void aircable_read(struct work_struct *work) | |||
297 | 298 | ||
298 | if (serial_buf_data_avail(priv->rx_buf)) | 299 | if (serial_buf_data_avail(priv->rx_buf)) |
299 | schedule_work(&priv->rx_work); | 300 | schedule_work(&priv->rx_work); |
300 | 301 | out: | |
302 | tty_kref_put(tty); | ||
301 | return; | 303 | return; |
302 | } | 304 | } |
303 | /* End of private methods */ | 305 | /* End of private methods */ |
@@ -334,7 +336,7 @@ static int aircable_attach(struct usb_serial *serial) | |||
334 | 336 | ||
335 | priv = kzalloc(sizeof(struct aircable_private), GFP_KERNEL); | 337 | priv = kzalloc(sizeof(struct aircable_private), GFP_KERNEL); |
336 | if (!priv) { | 338 | if (!priv) { |
337 | err("%s- kmalloc(%Zd) failed.", __func__, | 339 | dev_err(&port->dev, "%s- kmalloc(%Zd) failed.\n", __func__, |
338 | sizeof(struct aircable_private)); | 340 | sizeof(struct aircable_private)); |
339 | return -ENOMEM; | 341 | return -ENOMEM; |
340 | } | 342 | } |
@@ -495,7 +497,7 @@ static void aircable_read_bulk_callback(struct urb *urb) | |||
495 | usb_serial_debug_data(debug, &port->dev, __func__, | 497 | usb_serial_debug_data(debug, &port->dev, __func__, |
496 | urb->actual_length, urb->transfer_buffer); | 498 | urb->actual_length, urb->transfer_buffer); |
497 | 499 | ||
498 | tty = port->port.tty; | 500 | tty = tty_port_tty_get(&port->port); |
499 | if (tty && urb->actual_length) { | 501 | if (tty && urb->actual_length) { |
500 | if (urb->actual_length <= 2) { | 502 | if (urb->actual_length <= 2) { |
501 | /* This is an incomplete package */ | 503 | /* This is an incomplete package */ |
@@ -527,6 +529,7 @@ static void aircable_read_bulk_callback(struct urb *urb) | |||
527 | } | 529 | } |
528 | aircable_read(&priv->rx_work); | 530 | aircable_read(&priv->rx_work); |
529 | } | 531 | } |
532 | tty_kref_put(tty); | ||
530 | 533 | ||
531 | /* Schedule the next read _if_ we are still open */ | 534 | /* Schedule the next read _if_ we are still open */ |
532 | if (port->port.count) { | 535 | if (port->port.count) { |
diff --git a/drivers/usb/serial/belkin_sa.c b/drivers/usb/serial/belkin_sa.c index 2ebe06c3405a..b7eacad4d48c 100644 --- a/drivers/usb/serial/belkin_sa.c +++ b/drivers/usb/serial/belkin_sa.c | |||
@@ -187,7 +187,7 @@ static int belkin_sa_startup(struct usb_serial *serial) | |||
187 | /* see comments at top of file */ | 187 | /* see comments at top of file */ |
188 | priv->bad_flow_control = | 188 | priv->bad_flow_control = |
189 | (le16_to_cpu(dev->descriptor.bcdDevice) <= 0x0206) ? 1 : 0; | 189 | (le16_to_cpu(dev->descriptor.bcdDevice) <= 0x0206) ? 1 : 0; |
190 | info("bcdDevice: %04x, bfc: %d", | 190 | dev_info(&dev->dev, "bcdDevice: %04x, bfc: %d\n", |
191 | le16_to_cpu(dev->descriptor.bcdDevice), | 191 | le16_to_cpu(dev->descriptor.bcdDevice), |
192 | priv->bad_flow_control); | 192 | priv->bad_flow_control); |
193 | 193 | ||
@@ -228,7 +228,7 @@ static int belkin_sa_open(struct tty_struct *tty, | |||
228 | port->read_urb->dev = port->serial->dev; | 228 | port->read_urb->dev = port->serial->dev; |
229 | retval = usb_submit_urb(port->read_urb, GFP_KERNEL); | 229 | retval = usb_submit_urb(port->read_urb, GFP_KERNEL); |
230 | if (retval) { | 230 | if (retval) { |
231 | err("usb_submit_urb(read bulk) failed"); | 231 | dev_err(&port->dev, "usb_submit_urb(read bulk) failed\n"); |
232 | goto exit; | 232 | goto exit; |
233 | } | 233 | } |
234 | 234 | ||
@@ -236,7 +236,7 @@ static int belkin_sa_open(struct tty_struct *tty, | |||
236 | retval = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); | 236 | retval = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); |
237 | if (retval) { | 237 | if (retval) { |
238 | usb_kill_urb(port->read_urb); | 238 | usb_kill_urb(port->read_urb); |
239 | err(" usb_submit_urb(read int) failed"); | 239 | dev_err(&port->dev, "usb_submit_urb(read int) failed\n"); |
240 | } | 240 | } |
241 | 241 | ||
242 | exit: | 242 | exit: |
@@ -322,7 +322,7 @@ static void belkin_sa_read_int_callback(struct urb *urb) | |||
322 | * to look in to this before committing any code. | 322 | * to look in to this before committing any code. |
323 | */ | 323 | */ |
324 | if (priv->last_lsr & BELKIN_SA_LSR_ERR) { | 324 | if (priv->last_lsr & BELKIN_SA_LSR_ERR) { |
325 | tty = port->port.tty; | 325 | tty = tty_port_tty_get(&port->port); |
326 | /* Overrun Error */ | 326 | /* Overrun Error */ |
327 | if (priv->last_lsr & BELKIN_SA_LSR_OE) { | 327 | if (priv->last_lsr & BELKIN_SA_LSR_OE) { |
328 | } | 328 | } |
@@ -335,14 +335,15 @@ static void belkin_sa_read_int_callback(struct urb *urb) | |||
335 | /* Break Indicator */ | 335 | /* Break Indicator */ |
336 | if (priv->last_lsr & BELKIN_SA_LSR_BI) { | 336 | if (priv->last_lsr & BELKIN_SA_LSR_BI) { |
337 | } | 337 | } |
338 | tty_kref_put(tty); | ||
338 | } | 339 | } |
339 | #endif | 340 | #endif |
340 | spin_unlock_irqrestore(&priv->lock, flags); | 341 | spin_unlock_irqrestore(&priv->lock, flags); |
341 | exit: | 342 | exit: |
342 | retval = usb_submit_urb(urb, GFP_ATOMIC); | 343 | retval = usb_submit_urb(urb, GFP_ATOMIC); |
343 | if (retval) | 344 | if (retval) |
344 | err("%s - usb_submit_urb failed with result %d", | 345 | dev_err(&port->dev, "%s - usb_submit_urb failed with " |
345 | __func__, retval); | 346 | "result %d\n", __func__, retval); |
346 | } | 347 | } |
347 | 348 | ||
348 | static void belkin_sa_set_termios(struct tty_struct *tty, | 349 | static void belkin_sa_set_termios(struct tty_struct *tty, |
@@ -381,12 +382,12 @@ static void belkin_sa_set_termios(struct tty_struct *tty, | |||
381 | if ((old_cflag & CBAUD) == B0) { | 382 | if ((old_cflag & CBAUD) == B0) { |
382 | control_state |= (TIOCM_DTR|TIOCM_RTS); | 383 | control_state |= (TIOCM_DTR|TIOCM_RTS); |
383 | if (BSA_USB_CMD(BELKIN_SA_SET_DTR_REQUEST, 1) < 0) | 384 | if (BSA_USB_CMD(BELKIN_SA_SET_DTR_REQUEST, 1) < 0) |
384 | err("Set DTR error"); | 385 | dev_err(&port->dev, "Set DTR error\n"); |
385 | /* don't set RTS if using hardware flow control */ | 386 | /* don't set RTS if using hardware flow control */ |
386 | if (!(old_cflag & CRTSCTS)) | 387 | if (!(old_cflag & CRTSCTS)) |
387 | if (BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST | 388 | if (BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST |
388 | , 1) < 0) | 389 | , 1) < 0) |
389 | err("Set RTS error"); | 390 | dev_err(&port->dev, "Set RTS error\n"); |
390 | } | 391 | } |
391 | } | 392 | } |
392 | 393 | ||
@@ -402,18 +403,18 @@ static void belkin_sa_set_termios(struct tty_struct *tty, | |||
402 | /* Report the actual baud rate back to the caller */ | 403 | /* Report the actual baud rate back to the caller */ |
403 | tty_encode_baud_rate(tty, baud, baud); | 404 | tty_encode_baud_rate(tty, baud, baud); |
404 | if (BSA_USB_CMD(BELKIN_SA_SET_BAUDRATE_REQUEST, urb_value) < 0) | 405 | if (BSA_USB_CMD(BELKIN_SA_SET_BAUDRATE_REQUEST, urb_value) < 0) |
405 | err("Set baudrate error"); | 406 | dev_err(&port->dev, "Set baudrate error\n"); |
406 | } else { | 407 | } else { |
407 | /* Disable flow control */ | 408 | /* Disable flow control */ |
408 | if (BSA_USB_CMD(BELKIN_SA_SET_FLOW_CTRL_REQUEST, | 409 | if (BSA_USB_CMD(BELKIN_SA_SET_FLOW_CTRL_REQUEST, |
409 | BELKIN_SA_FLOW_NONE) < 0) | 410 | BELKIN_SA_FLOW_NONE) < 0) |
410 | err("Disable flowcontrol error"); | 411 | dev_err(&port->dev, "Disable flowcontrol error\n"); |
411 | /* Drop RTS and DTR */ | 412 | /* Drop RTS and DTR */ |
412 | control_state &= ~(TIOCM_DTR | TIOCM_RTS); | 413 | control_state &= ~(TIOCM_DTR | TIOCM_RTS); |
413 | if (BSA_USB_CMD(BELKIN_SA_SET_DTR_REQUEST, 0) < 0) | 414 | if (BSA_USB_CMD(BELKIN_SA_SET_DTR_REQUEST, 0) < 0) |
414 | err("DTR LOW error"); | 415 | dev_err(&port->dev, "DTR LOW error\n"); |
415 | if (BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST, 0) < 0) | 416 | if (BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST, 0) < 0) |
416 | err("RTS LOW error"); | 417 | dev_err(&port->dev, "RTS LOW error\n"); |
417 | } | 418 | } |
418 | 419 | ||
419 | /* set the parity */ | 420 | /* set the parity */ |
@@ -424,7 +425,7 @@ static void belkin_sa_set_termios(struct tty_struct *tty, | |||
424 | else | 425 | else |
425 | urb_value = BELKIN_SA_PARITY_NONE; | 426 | urb_value = BELKIN_SA_PARITY_NONE; |
426 | if (BSA_USB_CMD(BELKIN_SA_SET_PARITY_REQUEST, urb_value) < 0) | 427 | if (BSA_USB_CMD(BELKIN_SA_SET_PARITY_REQUEST, urb_value) < 0) |
427 | err("Set parity error"); | 428 | dev_err(&port->dev, "Set parity error\n"); |
428 | } | 429 | } |
429 | 430 | ||
430 | /* set the number of data bits */ | 431 | /* set the number of data bits */ |
@@ -447,7 +448,7 @@ static void belkin_sa_set_termios(struct tty_struct *tty, | |||
447 | break; | 448 | break; |
448 | } | 449 | } |
449 | if (BSA_USB_CMD(BELKIN_SA_SET_DATA_BITS_REQUEST, urb_value) < 0) | 450 | if (BSA_USB_CMD(BELKIN_SA_SET_DATA_BITS_REQUEST, urb_value) < 0) |
450 | err("Set data bits error"); | 451 | dev_err(&port->dev, "Set data bits error\n"); |
451 | } | 452 | } |
452 | 453 | ||
453 | /* set the number of stop bits */ | 454 | /* set the number of stop bits */ |
@@ -456,7 +457,7 @@ static void belkin_sa_set_termios(struct tty_struct *tty, | |||
456 | : BELKIN_SA_STOP_BITS(1); | 457 | : BELKIN_SA_STOP_BITS(1); |
457 | if (BSA_USB_CMD(BELKIN_SA_SET_STOP_BITS_REQUEST, | 458 | if (BSA_USB_CMD(BELKIN_SA_SET_STOP_BITS_REQUEST, |
458 | urb_value) < 0) | 459 | urb_value) < 0) |
459 | err("Set stop bits error"); | 460 | dev_err(&port->dev, "Set stop bits error\n"); |
460 | } | 461 | } |
461 | 462 | ||
462 | /* Set flow control */ | 463 | /* Set flow control */ |
@@ -477,7 +478,7 @@ static void belkin_sa_set_termios(struct tty_struct *tty, | |||
477 | urb_value &= ~(BELKIN_SA_FLOW_IRTS); | 478 | urb_value &= ~(BELKIN_SA_FLOW_IRTS); |
478 | 479 | ||
479 | if (BSA_USB_CMD(BELKIN_SA_SET_FLOW_CTRL_REQUEST, urb_value) < 0) | 480 | if (BSA_USB_CMD(BELKIN_SA_SET_FLOW_CTRL_REQUEST, urb_value) < 0) |
480 | err("Set flow control error"); | 481 | dev_err(&port->dev, "Set flow control error\n"); |
481 | } | 482 | } |
482 | 483 | ||
483 | /* save off the modified port settings */ | 484 | /* save off the modified port settings */ |
@@ -493,7 +494,7 @@ static void belkin_sa_break_ctl(struct tty_struct *tty, int break_state) | |||
493 | struct usb_serial *serial = port->serial; | 494 | struct usb_serial *serial = port->serial; |
494 | 495 | ||
495 | if (BSA_USB_CMD(BELKIN_SA_SET_BREAK_REQUEST, break_state ? 1 : 0) < 0) | 496 | if (BSA_USB_CMD(BELKIN_SA_SET_BREAK_REQUEST, break_state ? 1 : 0) < 0) |
496 | err("Set break_ctl %d", break_state); | 497 | dev_err(&port->dev, "Set break_ctl %d\n", break_state); |
497 | } | 498 | } |
498 | 499 | ||
499 | 500 | ||
@@ -553,13 +554,13 @@ static int belkin_sa_tiocmset(struct tty_struct *tty, struct file *file, | |||
553 | 554 | ||
554 | retval = BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST, rts); | 555 | retval = BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST, rts); |
555 | if (retval < 0) { | 556 | if (retval < 0) { |
556 | err("Set RTS error %d", retval); | 557 | dev_err(&port->dev, "Set RTS error %d\n", retval); |
557 | goto exit; | 558 | goto exit; |
558 | } | 559 | } |
559 | 560 | ||
560 | retval = BSA_USB_CMD(BELKIN_SA_SET_DTR_REQUEST, dtr); | 561 | retval = BSA_USB_CMD(BELKIN_SA_SET_DTR_REQUEST, dtr); |
561 | if (retval < 0) { | 562 | if (retval < 0) { |
562 | err("Set DTR error %d", retval); | 563 | dev_err(&port->dev, "Set DTR error %d\n", retval); |
563 | goto exit; | 564 | goto exit; |
564 | } | 565 | } |
565 | exit: | 566 | exit: |
@@ -576,7 +577,8 @@ static int __init belkin_sa_init(void) | |||
576 | retval = usb_register(&belkin_driver); | 577 | retval = usb_register(&belkin_driver); |
577 | if (retval) | 578 | if (retval) |
578 | goto failed_usb_register; | 579 | goto failed_usb_register; |
579 | info(DRIVER_DESC " " DRIVER_VERSION); | 580 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
581 | DRIVER_DESC "\n"); | ||
580 | return 0; | 582 | return 0; |
581 | failed_usb_register: | 583 | failed_usb_register: |
582 | usb_serial_deregister(&belkin_device); | 584 | usb_serial_deregister(&belkin_device); |
diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c index 7b74238ad1c7..5b20de130e08 100644 --- a/drivers/usb/serial/console.c +++ b/drivers/usb/serial/console.c | |||
@@ -117,7 +117,7 @@ static int usb_console_setup(struct console *co, char *options) | |||
117 | } | 117 | } |
118 | 118 | ||
119 | port = serial->port[0]; | 119 | port = serial->port[0]; |
120 | port->port.tty = NULL; | 120 | tty_port_tty_set(&port->port, NULL); |
121 | 121 | ||
122 | info->port = port; | 122 | info->port = port; |
123 | 123 | ||
@@ -143,7 +143,7 @@ static int usb_console_setup(struct console *co, char *options) | |||
143 | } | 143 | } |
144 | memset(&dummy, 0, sizeof(struct ktermios)); | 144 | memset(&dummy, 0, sizeof(struct ktermios)); |
145 | tty->termios = termios; | 145 | tty->termios = termios; |
146 | port->port.tty = tty; | 146 | tty_port_tty_set(&port->port, tty); |
147 | } | 147 | } |
148 | 148 | ||
149 | /* only call the device specific open if this | 149 | /* only call the device specific open if this |
@@ -161,9 +161,9 @@ static int usb_console_setup(struct console *co, char *options) | |||
161 | if (serial->type->set_termios) { | 161 | if (serial->type->set_termios) { |
162 | termios->c_cflag = cflag; | 162 | termios->c_cflag = cflag; |
163 | tty_termios_encode_baud_rate(termios, baud, baud); | 163 | tty_termios_encode_baud_rate(termios, baud, baud); |
164 | serial->type->set_termios(NULL, port, &dummy); | 164 | serial->type->set_termios(tty, port, &dummy); |
165 | 165 | ||
166 | port->port.tty = NULL; | 166 | tty_port_tty_set(&port->port, NULL); |
167 | kfree(termios); | 167 | kfree(termios); |
168 | kfree(tty); | 168 | kfree(tty); |
169 | } | 169 | } |
@@ -176,7 +176,7 @@ out: | |||
176 | return retval; | 176 | return retval; |
177 | free_termios: | 177 | free_termios: |
178 | kfree(termios); | 178 | kfree(termios); |
179 | port->port.tty = NULL; | 179 | tty_port_tty_set(&port->port, NULL); |
180 | free_tty: | 180 | free_tty: |
181 | kfree(tty); | 181 | kfree(tty); |
182 | reset_open_count: | 182 | reset_open_count: |
diff --git a/drivers/usb/serial/cp2101.c b/drivers/usb/serial/cp2101.c index 442cba69cce5..8008d0bc80ad 100644 --- a/drivers/usb/serial/cp2101.c +++ b/drivers/usb/serial/cp2101.c | |||
@@ -72,6 +72,7 @@ static struct usb_device_id id_table [] = { | |||
72 | { USB_DEVICE(0x10C4, 0x80CA) }, /* Degree Controls Inc */ | 72 | { USB_DEVICE(0x10C4, 0x80CA) }, /* Degree Controls Inc */ |
73 | { USB_DEVICE(0x10C4, 0x80DD) }, /* Tracient RFID */ | 73 | { USB_DEVICE(0x10C4, 0x80DD) }, /* Tracient RFID */ |
74 | { USB_DEVICE(0x10C4, 0x80F6) }, /* Suunto sports instrument */ | 74 | { USB_DEVICE(0x10C4, 0x80F6) }, /* Suunto sports instrument */ |
75 | { USB_DEVICE(0x10C4, 0x8115) }, /* Arygon NFC/Mifare Reader */ | ||
75 | { USB_DEVICE(0x10C4, 0x813D) }, /* Burnside Telecom Deskmobile */ | 76 | { USB_DEVICE(0x10C4, 0x813D) }, /* Burnside Telecom Deskmobile */ |
76 | { USB_DEVICE(0x10C4, 0x814A) }, /* West Mountain Radio RIGblaster P&P */ | 77 | { USB_DEVICE(0x10C4, 0x814A) }, /* West Mountain Radio RIGblaster P&P */ |
77 | { USB_DEVICE(0x10C4, 0x814B) }, /* West Mountain Radio RIGtalk */ | 78 | { USB_DEVICE(0x10C4, 0x814B) }, /* West Mountain Radio RIGtalk */ |
@@ -83,6 +84,7 @@ static struct usb_device_id id_table [] = { | |||
83 | { USB_DEVICE(0x10C4, 0x81E7) }, /* Aerocomm Radio */ | 84 | { USB_DEVICE(0x10C4, 0x81E7) }, /* Aerocomm Radio */ |
84 | { USB_DEVICE(0x10C4, 0x8218) }, /* Lipowsky Industrie Elektronik GmbH, HARP-1 */ | 85 | { USB_DEVICE(0x10C4, 0x8218) }, /* Lipowsky Industrie Elektronik GmbH, HARP-1 */ |
85 | { USB_DEVICE(0x10c4, 0x8293) }, /* Telegesys ETRX2USB */ | 86 | { USB_DEVICE(0x10c4, 0x8293) }, /* Telegesys ETRX2USB */ |
87 | { USB_DEVICE(0x10C4, 0x8341) }, /* Siemens MC35PU GPRS Modem */ | ||
86 | { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */ | 88 | { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */ |
87 | { USB_DEVICE(0x10C4, 0xEA61) }, /* Silicon Labs factory default */ | 89 | { USB_DEVICE(0x10C4, 0xEA61) }, /* Silicon Labs factory default */ |
88 | { USB_DEVICE(0x10C4, 0xF001) }, /* Elan Digital Systems USBscope50 */ | 90 | { USB_DEVICE(0x10C4, 0xF001) }, /* Elan Digital Systems USBscope50 */ |
@@ -93,6 +95,7 @@ static struct usb_device_id id_table [] = { | |||
93 | { USB_DEVICE(0x13AD, 0x9999) }, /* Baltech card reader */ | 95 | { USB_DEVICE(0x13AD, 0x9999) }, /* Baltech card reader */ |
94 | { USB_DEVICE(0x166A, 0x0303) }, /* Clipsal 5500PCU C-Bus USB interface */ | 96 | { USB_DEVICE(0x166A, 0x0303) }, /* Clipsal 5500PCU C-Bus USB interface */ |
95 | { USB_DEVICE(0x16D6, 0x0001) }, /* Jablotron serial interface */ | 97 | { USB_DEVICE(0x16D6, 0x0001) }, /* Jablotron serial interface */ |
98 | { USB_DEVICE(0x18EF, 0xE00F) }, /* ELV USB-I2C-Interface */ | ||
96 | { } /* Terminating Entry */ | 99 | { } /* Terminating Entry */ |
97 | }; | 100 | }; |
98 | 101 | ||
@@ -750,7 +753,8 @@ static int __init cp2101_init(void) | |||
750 | } | 753 | } |
751 | 754 | ||
752 | /* Success */ | 755 | /* Success */ |
753 | info(DRIVER_DESC " " DRIVER_VERSION); | 756 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
757 | DRIVER_DESC "\n"); | ||
754 | return 0; | 758 | return 0; |
755 | } | 759 | } |
756 | 760 | ||
diff --git a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c index b4d72351cb96..858bdd038fbc 100644 --- a/drivers/usb/serial/cyberjack.c +++ b/drivers/usb/serial/cyberjack.c | |||
@@ -141,7 +141,8 @@ static int cyberjack_startup(struct usb_serial *serial) | |||
141 | result = usb_submit_urb(serial->port[i]->interrupt_in_urb, | 141 | result = usb_submit_urb(serial->port[i]->interrupt_in_urb, |
142 | GFP_KERNEL); | 142 | GFP_KERNEL); |
143 | if (result) | 143 | if (result) |
144 | err(" usb_submit_urb(read int) failed"); | 144 | dev_err(&serial->dev->dev, |
145 | "usb_submit_urb(read int) failed\n"); | ||
145 | dbg("%s - usb_submit_urb(int urb)", __func__); | 146 | dbg("%s - usb_submit_urb(int urb)", __func__); |
146 | } | 147 | } |
147 | 148 | ||
@@ -274,8 +275,9 @@ static int cyberjack_write(struct tty_struct *tty, | |||
274 | /* send the data out the bulk port */ | 275 | /* send the data out the bulk port */ |
275 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); | 276 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); |
276 | if (result) { | 277 | if (result) { |
277 | err("%s - failed submitting write urb, error %d", | 278 | dev_err(&port->dev, |
278 | __func__, result); | 279 | "%s - failed submitting write urb, error %d", |
280 | __func__, result); | ||
279 | /* Throw away data. No better idea what to do with it. */ | 281 | /* Throw away data. No better idea what to do with it. */ |
280 | priv->wrfilled = 0; | 282 | priv->wrfilled = 0; |
281 | priv->wrsent = 0; | 283 | priv->wrsent = 0; |
@@ -351,7 +353,9 @@ static void cyberjack_read_int_callback(struct urb *urb) | |||
351 | port->read_urb->dev = port->serial->dev; | 353 | port->read_urb->dev = port->serial->dev; |
352 | result = usb_submit_urb(port->read_urb, GFP_ATOMIC); | 354 | result = usb_submit_urb(port->read_urb, GFP_ATOMIC); |
353 | if (result) | 355 | if (result) |
354 | err("%s - failed resubmitting read urb, error %d", __func__, result); | 356 | dev_err(&port->dev, "%s - failed resubmitting " |
357 | "read urb, error %d\n", | ||
358 | __func__, result); | ||
355 | dbg("%s - usb_submit_urb(read urb)", __func__); | 359 | dbg("%s - usb_submit_urb(read urb)", __func__); |
356 | } | 360 | } |
357 | } | 361 | } |
@@ -360,7 +364,7 @@ resubmit: | |||
360 | port->interrupt_in_urb->dev = port->serial->dev; | 364 | port->interrupt_in_urb->dev = port->serial->dev; |
361 | result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); | 365 | result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); |
362 | if (result) | 366 | if (result) |
363 | err(" usb_submit_urb(read int) failed"); | 367 | dev_err(&port->dev, "usb_submit_urb(read int) failed\n"); |
364 | dbg("%s - usb_submit_urb(int urb)", __func__); | 368 | dbg("%s - usb_submit_urb(int urb)", __func__); |
365 | } | 369 | } |
366 | 370 | ||
@@ -384,7 +388,7 @@ static void cyberjack_read_bulk_callback(struct urb *urb) | |||
384 | return; | 388 | return; |
385 | } | 389 | } |
386 | 390 | ||
387 | tty = port->port.tty; | 391 | tty = tty_port_tty_get(&port->port); |
388 | if (!tty) { | 392 | if (!tty) { |
389 | dbg("%s - ignoring since device not open\n", __func__); | 393 | dbg("%s - ignoring since device not open\n", __func__); |
390 | return; | 394 | return; |
@@ -394,6 +398,7 @@ static void cyberjack_read_bulk_callback(struct urb *urb) | |||
394 | tty_insert_flip_string(tty, data, urb->actual_length); | 398 | tty_insert_flip_string(tty, data, urb->actual_length); |
395 | tty_flip_buffer_push(tty); | 399 | tty_flip_buffer_push(tty); |
396 | } | 400 | } |
401 | tty_kref_put(tty); | ||
397 | 402 | ||
398 | spin_lock(&priv->lock); | 403 | spin_lock(&priv->lock); |
399 | 404 | ||
@@ -413,8 +418,8 @@ static void cyberjack_read_bulk_callback(struct urb *urb) | |||
413 | port->read_urb->dev = port->serial->dev; | 418 | port->read_urb->dev = port->serial->dev; |
414 | result = usb_submit_urb(port->read_urb, GFP_ATOMIC); | 419 | result = usb_submit_urb(port->read_urb, GFP_ATOMIC); |
415 | if (result) | 420 | if (result) |
416 | err("%s - failed resubmitting read urb, error %d", | 421 | dev_err(&port->dev, "%s - failed resubmitting read " |
417 | __func__, result); | 422 | "urb, error %d\n", __func__, result); |
418 | dbg("%s - usb_submit_urb(read urb)", __func__); | 423 | dbg("%s - usb_submit_urb(read urb)", __func__); |
419 | } | 424 | } |
420 | } | 425 | } |
@@ -461,8 +466,9 @@ static void cyberjack_write_bulk_callback(struct urb *urb) | |||
461 | /* send the data out the bulk port */ | 466 | /* send the data out the bulk port */ |
462 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); | 467 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); |
463 | if (result) { | 468 | if (result) { |
464 | err("%s - failed submitting write urb, error %d", | 469 | dev_err(&port->dev, |
465 | __func__, result); | 470 | "%s - failed submitting write urb, error %d\n", |
471 | __func__, result); | ||
466 | /* Throw away data. No better idea what to do with it. */ | 472 | /* Throw away data. No better idea what to do with it. */ |
467 | priv->wrfilled = 0; | 473 | priv->wrfilled = 0; |
468 | priv->wrsent = 0; | 474 | priv->wrsent = 0; |
@@ -498,8 +504,9 @@ static int __init cyberjack_init(void) | |||
498 | if (retval) | 504 | if (retval) |
499 | goto failed_usb_register; | 505 | goto failed_usb_register; |
500 | 506 | ||
501 | info(DRIVER_VERSION " " DRIVER_AUTHOR); | 507 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION " " |
502 | info(DRIVER_DESC); | 508 | DRIVER_AUTHOR "\n"); |
509 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_DESC "\n"); | ||
503 | 510 | ||
504 | return 0; | 511 | return 0; |
505 | failed_usb_register: | 512 | failed_usb_register: |
diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c index 22837a3f2f89..eae4740d448c 100644 --- a/drivers/usb/serial/cypress_m8.c +++ b/drivers/usb/serial/cypress_m8.c | |||
@@ -404,8 +404,8 @@ static int cypress_serial_control(struct tty_struct *tty, | |||
404 | retval != -ENODEV); | 404 | retval != -ENODEV); |
405 | 405 | ||
406 | if (retval != sizeof(feature_buffer)) { | 406 | if (retval != sizeof(feature_buffer)) { |
407 | err("%s - failed sending serial line settings - %d", | 407 | dev_err(&port->dev, "%s - failed sending serial " |
408 | __func__, retval); | 408 | "line settings - %d\n", __func__, retval); |
409 | cypress_set_dead(port); | 409 | cypress_set_dead(port); |
410 | } else { | 410 | } else { |
411 | spin_lock_irqsave(&priv->lock, flags); | 411 | spin_lock_irqsave(&priv->lock, flags); |
@@ -443,7 +443,8 @@ static int cypress_serial_control(struct tty_struct *tty, | |||
443 | && retval != -ENODEV); | 443 | && retval != -ENODEV); |
444 | 444 | ||
445 | if (retval != sizeof(feature_buffer)) { | 445 | if (retval != sizeof(feature_buffer)) { |
446 | err("%s - failed to retrieve serial line settings - %d", __func__, retval); | 446 | dev_err(&port->dev, "%s - failed to retrieve serial " |
447 | "line settings - %d\n", __func__, retval); | ||
447 | cypress_set_dead(port); | 448 | cypress_set_dead(port); |
448 | return retval; | 449 | return retval; |
449 | } else { | 450 | } else { |
@@ -476,8 +477,8 @@ static void cypress_set_dead(struct usb_serial_port *port) | |||
476 | priv->comm_is_ok = 0; | 477 | priv->comm_is_ok = 0; |
477 | spin_unlock_irqrestore(&priv->lock, flags); | 478 | spin_unlock_irqrestore(&priv->lock, flags); |
478 | 479 | ||
479 | err("cypress_m8 suspending failing port %d - interval might be too short", | 480 | dev_err(&port->dev, "cypress_m8 suspending failing port %d - " |
480 | port->number); | 481 | "interval might be too short\n", port->number); |
481 | } | 482 | } |
482 | 483 | ||
483 | 484 | ||
@@ -679,7 +680,8 @@ static int cypress_open(struct tty_struct *tty, | |||
679 | 680 | ||
680 | /* setup the port and start reading from the device */ | 681 | /* setup the port and start reading from the device */ |
681 | if (!port->interrupt_in_urb) { | 682 | if (!port->interrupt_in_urb) { |
682 | err("%s - interrupt_in_urb is empty!", __func__); | 683 | dev_err(&port->dev, "%s - interrupt_in_urb is empty!\n", |
684 | __func__); | ||
683 | return -1; | 685 | return -1; |
684 | } | 686 | } |
685 | 687 | ||
@@ -1107,8 +1109,8 @@ static void cypress_set_termios(struct tty_struct *tty, | |||
1107 | data_bits = 3; | 1109 | data_bits = 3; |
1108 | break; | 1110 | break; |
1109 | default: | 1111 | default: |
1110 | err("%s - CSIZE was set, but not CS5-CS8", | 1112 | dev_err(&port->dev, "%s - CSIZE was set, but not CS5-CS8\n", |
1111 | __func__); | 1113 | __func__); |
1112 | data_bits = 3; | 1114 | data_bits = 3; |
1113 | } | 1115 | } |
1114 | spin_lock_irqsave(&priv->lock, flags); | 1116 | spin_lock_irqsave(&priv->lock, flags); |
@@ -1286,7 +1288,7 @@ static void cypress_read_int_callback(struct urb *urb) | |||
1286 | } | 1288 | } |
1287 | spin_unlock_irqrestore(&priv->lock, flags); | 1289 | spin_unlock_irqrestore(&priv->lock, flags); |
1288 | 1290 | ||
1289 | tty = port->port.tty; | 1291 | tty = tty_port_tty_get(&port->port); |
1290 | if (!tty) { | 1292 | if (!tty) { |
1291 | dbg("%s - bad tty pointer - exiting", __func__); | 1293 | dbg("%s - bad tty pointer - exiting", __func__); |
1292 | return; | 1294 | return; |
@@ -1362,7 +1364,7 @@ static void cypress_read_int_callback(struct urb *urb) | |||
1362 | data[i]); | 1364 | data[i]); |
1363 | tty_insert_flip_char(tty, data[i], tty_flag); | 1365 | tty_insert_flip_char(tty, data[i], tty_flag); |
1364 | } | 1366 | } |
1365 | tty_flip_buffer_push(port->port.tty); | 1367 | tty_flip_buffer_push(tty); |
1366 | } | 1368 | } |
1367 | 1369 | ||
1368 | spin_lock_irqsave(&priv->lock, flags); | 1370 | spin_lock_irqsave(&priv->lock, flags); |
@@ -1371,6 +1373,7 @@ static void cypress_read_int_callback(struct urb *urb) | |||
1371 | spin_unlock_irqrestore(&priv->lock, flags); | 1373 | spin_unlock_irqrestore(&priv->lock, flags); |
1372 | 1374 | ||
1373 | continue_read: | 1375 | continue_read: |
1376 | tty_kref_put(tty); | ||
1374 | 1377 | ||
1375 | /* Continue trying to always read... unless the port has closed. */ | 1378 | /* Continue trying to always read... unless the port has closed. */ |
1376 | 1379 | ||
@@ -1657,7 +1660,8 @@ static int __init cypress_init(void) | |||
1657 | if (retval) | 1660 | if (retval) |
1658 | goto failed_usb_register; | 1661 | goto failed_usb_register; |
1659 | 1662 | ||
1660 | info(DRIVER_DESC " " DRIVER_VERSION); | 1663 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
1664 | DRIVER_DESC "\n"); | ||
1661 | return 0; | 1665 | return 0; |
1662 | 1666 | ||
1663 | failed_usb_register: | 1667 | failed_usb_register: |
diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c index 240aad1acaab..69f84f0ea6fe 100644 --- a/drivers/usb/serial/digi_acceleport.c +++ b/drivers/usb/serial/digi_acceleport.c | |||
@@ -604,7 +604,9 @@ static void digi_wakeup_write_lock(struct work_struct *work) | |||
604 | 604 | ||
605 | static void digi_wakeup_write(struct usb_serial_port *port) | 605 | static void digi_wakeup_write(struct usb_serial_port *port) |
606 | { | 606 | { |
607 | tty_wakeup(port->port.tty); | 607 | struct tty_struct *tty = tty_port_tty_get(&port->port); |
608 | tty_wakeup(tty); | ||
609 | tty_kref_put(tty); | ||
608 | } | 610 | } |
609 | 611 | ||
610 | 612 | ||
@@ -659,7 +661,8 @@ static int digi_write_oob_command(struct usb_serial_port *port, | |||
659 | } | 661 | } |
660 | spin_unlock_irqrestore(&oob_priv->dp_port_lock, flags); | 662 | spin_unlock_irqrestore(&oob_priv->dp_port_lock, flags); |
661 | if (ret) | 663 | if (ret) |
662 | err("%s: usb_submit_urb failed, ret=%d", __func__, ret); | 664 | dev_err(&port->dev, "%s: usb_submit_urb failed, ret=%d\n", |
665 | __func__, ret); | ||
663 | return ret; | 666 | return ret; |
664 | 667 | ||
665 | } | 668 | } |
@@ -741,7 +744,8 @@ static int digi_write_inb_command(struct usb_serial_port *port, | |||
741 | spin_unlock_irqrestore(&priv->dp_port_lock, flags); | 744 | spin_unlock_irqrestore(&priv->dp_port_lock, flags); |
742 | 745 | ||
743 | if (ret) | 746 | if (ret) |
744 | err("%s: usb_submit_urb failed, ret=%d, port=%d", | 747 | dev_err(&port->dev, |
748 | "%s: usb_submit_urb failed, ret=%d, port=%d\n", | ||
745 | __func__, ret, priv->dp_port_num); | 749 | __func__, ret, priv->dp_port_num); |
746 | return ret; | 750 | return ret; |
747 | } | 751 | } |
@@ -810,7 +814,8 @@ static int digi_set_modem_signals(struct usb_serial_port *port, | |||
810 | spin_unlock(&port_priv->dp_port_lock); | 814 | spin_unlock(&port_priv->dp_port_lock); |
811 | spin_unlock_irqrestore(&oob_priv->dp_port_lock, flags); | 815 | spin_unlock_irqrestore(&oob_priv->dp_port_lock, flags); |
812 | if (ret) | 816 | if (ret) |
813 | err("%s: usb_submit_urb failed, ret=%d", __func__, ret); | 817 | dev_err(&port->dev, "%s: usb_submit_urb failed, ret=%d\n", |
818 | __func__, ret); | ||
814 | return ret; | 819 | return ret; |
815 | } | 820 | } |
816 | 821 | ||
@@ -905,7 +910,8 @@ static void digi_rx_unthrottle(struct tty_struct *tty) | |||
905 | spin_unlock_irqrestore(&priv->dp_port_lock, flags); | 910 | spin_unlock_irqrestore(&priv->dp_port_lock, flags); |
906 | 911 | ||
907 | if (ret) | 912 | if (ret) |
908 | err("%s: usb_submit_urb failed, ret=%d, port=%d", | 913 | dev_err(&port->dev, |
914 | "%s: usb_submit_urb failed, ret=%d, port=%d\n", | ||
909 | __func__, ret, priv->dp_port_num); | 915 | __func__, ret, priv->dp_port_num); |
910 | } | 916 | } |
911 | 917 | ||
@@ -1212,7 +1218,8 @@ static int digi_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
1212 | /* return length of new data written, or error */ | 1218 | /* return length of new data written, or error */ |
1213 | spin_unlock_irqrestore(&priv->dp_port_lock, flags); | 1219 | spin_unlock_irqrestore(&priv->dp_port_lock, flags); |
1214 | if (ret < 0) | 1220 | if (ret < 0) |
1215 | err("%s: usb_submit_urb failed, ret=%d, port=%d", | 1221 | dev_err(&port->dev, |
1222 | "%s: usb_submit_urb failed, ret=%d, port=%d\n", | ||
1216 | __func__, ret, priv->dp_port_num); | 1223 | __func__, ret, priv->dp_port_num); |
1217 | dbg("digi_write: returning %d", ret); | 1224 | dbg("digi_write: returning %d", ret); |
1218 | return ret; | 1225 | return ret; |
@@ -1233,14 +1240,16 @@ static void digi_write_bulk_callback(struct urb *urb) | |||
1233 | 1240 | ||
1234 | /* port and serial sanity check */ | 1241 | /* port and serial sanity check */ |
1235 | if (port == NULL || (priv = usb_get_serial_port_data(port)) == NULL) { | 1242 | if (port == NULL || (priv = usb_get_serial_port_data(port)) == NULL) { |
1236 | err("%s: port or port->private is NULL, status=%d", | 1243 | dev_err(&port->dev, |
1237 | __func__, status); | 1244 | "%s: port or port->private is NULL, status=%d\n", |
1245 | __func__, status); | ||
1238 | return; | 1246 | return; |
1239 | } | 1247 | } |
1240 | serial = port->serial; | 1248 | serial = port->serial; |
1241 | if (serial == NULL || (serial_priv = usb_get_serial_data(serial)) == NULL) { | 1249 | if (serial == NULL || (serial_priv = usb_get_serial_data(serial)) == NULL) { |
1242 | err("%s: serial or serial->private is NULL, status=%d", | 1250 | dev_err(&port->dev, |
1243 | __func__, status); | 1251 | "%s: serial or serial->private is NULL, status=%d\n", |
1252 | __func__, status); | ||
1244 | return; | 1253 | return; |
1245 | } | 1254 | } |
1246 | 1255 | ||
@@ -1282,7 +1291,8 @@ static void digi_write_bulk_callback(struct urb *urb) | |||
1282 | 1291 | ||
1283 | spin_unlock(&priv->dp_port_lock); | 1292 | spin_unlock(&priv->dp_port_lock); |
1284 | if (ret) | 1293 | if (ret) |
1285 | err("%s: usb_submit_urb failed, ret=%d, port=%d", | 1294 | dev_err(&port->dev, |
1295 | "%s: usb_submit_urb failed, ret=%d, port=%d\n", | ||
1286 | __func__, ret, priv->dp_port_num); | 1296 | __func__, ret, priv->dp_port_num); |
1287 | } | 1297 | } |
1288 | 1298 | ||
@@ -1516,8 +1526,9 @@ static int digi_startup_device(struct usb_serial *serial) | |||
1516 | port->write_urb->dev = port->serial->dev; | 1526 | port->write_urb->dev = port->serial->dev; |
1517 | ret = usb_submit_urb(port->read_urb, GFP_KERNEL); | 1527 | ret = usb_submit_urb(port->read_urb, GFP_KERNEL); |
1518 | if (ret != 0) { | 1528 | if (ret != 0) { |
1519 | err("%s: usb_submit_urb failed, ret=%d, port=%d", | 1529 | dev_err(&port->dev, |
1520 | __func__, ret, i); | 1530 | "%s: usb_submit_urb failed, ret=%d, port=%d\n", |
1531 | __func__, ret, i); | ||
1521 | break; | 1532 | break; |
1522 | } | 1533 | } |
1523 | } | 1534 | } |
@@ -1616,22 +1627,26 @@ static void digi_read_bulk_callback(struct urb *urb) | |||
1616 | dbg("digi_read_bulk_callback: TOP"); | 1627 | dbg("digi_read_bulk_callback: TOP"); |
1617 | 1628 | ||
1618 | /* port sanity check, do not resubmit if port is not valid */ | 1629 | /* port sanity check, do not resubmit if port is not valid */ |
1619 | if (port == NULL || (priv = usb_get_serial_port_data(port)) == NULL) { | 1630 | if (port == NULL) |
1620 | err("%s: port or port->private is NULL, status=%d", | 1631 | return; |
1621 | __func__, status); | 1632 | priv = usb_get_serial_port_data(port); |
1633 | if (priv == NULL) { | ||
1634 | dev_err(&port->dev, "%s: port->private is NULL, status=%d\n", | ||
1635 | __func__, status); | ||
1622 | return; | 1636 | return; |
1623 | } | 1637 | } |
1624 | if (port->serial == NULL || | 1638 | if (port->serial == NULL || |
1625 | (serial_priv = usb_get_serial_data(port->serial)) == NULL) { | 1639 | (serial_priv = usb_get_serial_data(port->serial)) == NULL) { |
1626 | err("%s: serial is bad or serial->private is NULL, status=%d", | 1640 | dev_err(&port->dev, "%s: serial is bad or serial->private " |
1627 | __func__, status); | 1641 | "is NULL, status=%d\n", __func__, status); |
1628 | return; | 1642 | return; |
1629 | } | 1643 | } |
1630 | 1644 | ||
1631 | /* do not resubmit urb if it has any status error */ | 1645 | /* do not resubmit urb if it has any status error */ |
1632 | if (status) { | 1646 | if (status) { |
1633 | err("%s: nonzero read bulk status: status=%d, port=%d", | 1647 | dev_err(&port->dev, |
1634 | __func__, status, priv->dp_port_num); | 1648 | "%s: nonzero read bulk status: status=%d, port=%d\n", |
1649 | __func__, status, priv->dp_port_num); | ||
1635 | return; | 1650 | return; |
1636 | } | 1651 | } |
1637 | 1652 | ||
@@ -1648,8 +1663,9 @@ static void digi_read_bulk_callback(struct urb *urb) | |||
1648 | urb->dev = port->serial->dev; | 1663 | urb->dev = port->serial->dev; |
1649 | ret = usb_submit_urb(urb, GFP_ATOMIC); | 1664 | ret = usb_submit_urb(urb, GFP_ATOMIC); |
1650 | if (ret != 0) { | 1665 | if (ret != 0) { |
1651 | err("%s: failed resubmitting urb, ret=%d, port=%d", | 1666 | dev_err(&port->dev, |
1652 | __func__, ret, priv->dp_port_num); | 1667 | "%s: failed resubmitting urb, ret=%d, port=%d\n", |
1668 | __func__, ret, priv->dp_port_num); | ||
1653 | } | 1669 | } |
1654 | 1670 | ||
1655 | } | 1671 | } |
@@ -1668,7 +1684,7 @@ static int digi_read_inb_callback(struct urb *urb) | |||
1668 | { | 1684 | { |
1669 | 1685 | ||
1670 | struct usb_serial_port *port = urb->context; | 1686 | struct usb_serial_port *port = urb->context; |
1671 | struct tty_struct *tty = port->port.tty; | 1687 | struct tty_struct *tty; |
1672 | struct digi_port *priv = usb_get_serial_port_data(port); | 1688 | struct digi_port *priv = usb_get_serial_port_data(port); |
1673 | int opcode = ((unsigned char *)urb->transfer_buffer)[0]; | 1689 | int opcode = ((unsigned char *)urb->transfer_buffer)[0]; |
1674 | int len = ((unsigned char *)urb->transfer_buffer)[1]; | 1690 | int len = ((unsigned char *)urb->transfer_buffer)[1]; |
@@ -1685,13 +1701,15 @@ static int digi_read_inb_callback(struct urb *urb) | |||
1685 | 1701 | ||
1686 | /* short/multiple packet check */ | 1702 | /* short/multiple packet check */ |
1687 | if (urb->actual_length != len + 2) { | 1703 | if (urb->actual_length != len + 2) { |
1688 | err("%s: INCOMPLETE OR MULTIPLE PACKET, urb->status=%d, " | 1704 | dev_err(&port->dev, "%s: INCOMPLETE OR MULTIPLE PACKET, " |
1689 | "port=%d, opcode=%d, len=%d, actual_length=%d, " | 1705 | "urb->status=%d, port=%d, opcode=%d, len=%d, " |
1690 | "status=%d", __func__, status, priv->dp_port_num, | 1706 | "actual_length=%d, status=%d\n", __func__, status, |
1691 | opcode, len, urb->actual_length, port_status); | 1707 | priv->dp_port_num, opcode, len, urb->actual_length, |
1708 | port_status); | ||
1692 | return -1; | 1709 | return -1; |
1693 | } | 1710 | } |
1694 | 1711 | ||
1712 | tty = tty_port_tty_get(&port->port); | ||
1695 | spin_lock(&priv->dp_port_lock); | 1713 | spin_lock(&priv->dp_port_lock); |
1696 | 1714 | ||
1697 | /* check for throttle; if set, do not resubmit read urb */ | 1715 | /* check for throttle; if set, do not resubmit read urb */ |
@@ -1735,6 +1753,7 @@ static int digi_read_inb_callback(struct urb *urb) | |||
1735 | } | 1753 | } |
1736 | } | 1754 | } |
1737 | spin_unlock(&priv->dp_port_lock); | 1755 | spin_unlock(&priv->dp_port_lock); |
1756 | tty_kref_put(tty); | ||
1738 | 1757 | ||
1739 | if (opcode == DIGI_CMD_RECEIVE_DISABLE) | 1758 | if (opcode == DIGI_CMD_RECEIVE_DISABLE) |
1740 | dbg("%s: got RECEIVE_DISABLE", __func__); | 1759 | dbg("%s: got RECEIVE_DISABLE", __func__); |
@@ -1760,6 +1779,7 @@ static int digi_read_oob_callback(struct urb *urb) | |||
1760 | 1779 | ||
1761 | struct usb_serial_port *port = urb->context; | 1780 | struct usb_serial_port *port = urb->context; |
1762 | struct usb_serial *serial = port->serial; | 1781 | struct usb_serial *serial = port->serial; |
1782 | struct tty_struct *tty; | ||
1763 | struct digi_port *priv = usb_get_serial_port_data(port); | 1783 | struct digi_port *priv = usb_get_serial_port_data(port); |
1764 | int opcode, line, status, val; | 1784 | int opcode, line, status, val; |
1765 | int i; | 1785 | int i; |
@@ -1787,10 +1807,11 @@ static int digi_read_oob_callback(struct urb *urb) | |||
1787 | if (priv == NULL) | 1807 | if (priv == NULL) |
1788 | return -1; | 1808 | return -1; |
1789 | 1809 | ||
1810 | tty = tty_port_tty_get(&port->port); | ||
1790 | rts = 0; | 1811 | rts = 0; |
1791 | if (port->port.count) | 1812 | if (port->port.count) |
1792 | rts = port->port.tty->termios->c_cflag & CRTSCTS; | 1813 | rts = tty->termios->c_cflag & CRTSCTS; |
1793 | 1814 | ||
1794 | if (opcode == DIGI_CMD_READ_INPUT_SIGNALS) { | 1815 | if (opcode == DIGI_CMD_READ_INPUT_SIGNALS) { |
1795 | spin_lock(&priv->dp_port_lock); | 1816 | spin_lock(&priv->dp_port_lock); |
1796 | /* convert from digi flags to termiox flags */ | 1817 | /* convert from digi flags to termiox flags */ |
@@ -1798,14 +1819,14 @@ static int digi_read_oob_callback(struct urb *urb) | |||
1798 | priv->dp_modem_signals |= TIOCM_CTS; | 1819 | priv->dp_modem_signals |= TIOCM_CTS; |
1799 | /* port must be open to use tty struct */ | 1820 | /* port must be open to use tty struct */ |
1800 | if (rts) { | 1821 | if (rts) { |
1801 | port->port.tty->hw_stopped = 0; | 1822 | tty->hw_stopped = 0; |
1802 | digi_wakeup_write(port); | 1823 | digi_wakeup_write(port); |
1803 | } | 1824 | } |
1804 | } else { | 1825 | } else { |
1805 | priv->dp_modem_signals &= ~TIOCM_CTS; | 1826 | priv->dp_modem_signals &= ~TIOCM_CTS; |
1806 | /* port must be open to use tty struct */ | 1827 | /* port must be open to use tty struct */ |
1807 | if (rts) | 1828 | if (rts) |
1808 | port->port.tty->hw_stopped = 1; | 1829 | tty->hw_stopped = 1; |
1809 | } | 1830 | } |
1810 | if (val & DIGI_READ_INPUT_SIGNALS_DSR) | 1831 | if (val & DIGI_READ_INPUT_SIGNALS_DSR) |
1811 | priv->dp_modem_signals |= TIOCM_DSR; | 1832 | priv->dp_modem_signals |= TIOCM_DSR; |
@@ -1830,6 +1851,7 @@ static int digi_read_oob_callback(struct urb *urb) | |||
1830 | } else if (opcode == DIGI_CMD_IFLUSH_FIFO) { | 1851 | } else if (opcode == DIGI_CMD_IFLUSH_FIFO) { |
1831 | wake_up_interruptible(&priv->dp_flush_wait); | 1852 | wake_up_interruptible(&priv->dp_flush_wait); |
1832 | } | 1853 | } |
1854 | tty_kref_put(tty); | ||
1833 | } | 1855 | } |
1834 | return 0; | 1856 | return 0; |
1835 | 1857 | ||
@@ -1847,7 +1869,8 @@ static int __init digi_init(void) | |||
1847 | retval = usb_register(&digi_driver); | 1869 | retval = usb_register(&digi_driver); |
1848 | if (retval) | 1870 | if (retval) |
1849 | goto failed_usb_register; | 1871 | goto failed_usb_register; |
1850 | info(DRIVER_VERSION ":" DRIVER_DESC); | 1872 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
1873 | DRIVER_DESC "\n"); | ||
1851 | return 0; | 1874 | return 0; |
1852 | failed_usb_register: | 1875 | failed_usb_register: |
1853 | usb_serial_deregister(&digi_acceleport_4_device); | 1876 | usb_serial_deregister(&digi_acceleport_4_device); |
diff --git a/drivers/usb/serial/empeg.c b/drivers/usb/serial/empeg.c index a6ab5b58d9ca..8a69cce40b6d 100644 --- a/drivers/usb/serial/empeg.c +++ b/drivers/usb/serial/empeg.c | |||
@@ -33,9 +33,8 @@ | |||
33 | * Moved MOD_DEC_USE_COUNT to end of empeg_close(). | 33 | * Moved MOD_DEC_USE_COUNT to end of empeg_close(). |
34 | * | 34 | * |
35 | * (12/03/2000) gb | 35 | * (12/03/2000) gb |
36 | * Added port->port.tty->ldisc.set_termios(port->port.tty, NULL) to | 36 | * Added tty->ldisc.set_termios(port, tty, NULL) to empeg_open(). |
37 | * empeg_open(). This notifies the tty driver that the termios have | 37 | * This notifies the tty driver that the termios have changed. |
38 | * changed. | ||
39 | * | 38 | * |
40 | * (11/13/2000) gb | 39 | * (11/13/2000) gb |
41 | * Moved tty->low_latency = 1 from empeg_read_bulk_callback() to | 40 | * Moved tty->low_latency = 1 from empeg_read_bulk_callback() to |
@@ -354,7 +353,7 @@ static void empeg_read_bulk_callback(struct urb *urb) | |||
354 | 353 | ||
355 | usb_serial_debug_data(debug, &port->dev, __func__, | 354 | usb_serial_debug_data(debug, &port->dev, __func__, |
356 | urb->actual_length, data); | 355 | urb->actual_length, data); |
357 | tty = port->port.tty; | 356 | tty = tty_port_tty_get(&port->port); |
358 | 357 | ||
359 | if (urb->actual_length) { | 358 | if (urb->actual_length) { |
360 | tty_buffer_request_room(tty, urb->actual_length); | 359 | tty_buffer_request_room(tty, urb->actual_length); |
@@ -362,6 +361,7 @@ static void empeg_read_bulk_callback(struct urb *urb) | |||
362 | tty_flip_buffer_push(tty); | 361 | tty_flip_buffer_push(tty); |
363 | bytes_in += urb->actual_length; | 362 | bytes_in += urb->actual_length; |
364 | } | 363 | } |
364 | tty_kref_put(tty); | ||
365 | 365 | ||
366 | /* Continue trying to always read */ | 366 | /* Continue trying to always read */ |
367 | usb_fill_bulk_urb( | 367 | usb_fill_bulk_urb( |
@@ -416,7 +416,7 @@ static int empeg_startup(struct usb_serial *serial) | |||
416 | dbg("%s", __func__); | 416 | dbg("%s", __func__); |
417 | 417 | ||
418 | if (serial->dev->actconfig->desc.bConfigurationValue != 1) { | 418 | if (serial->dev->actconfig->desc.bConfigurationValue != 1) { |
419 | err("active config #%d != 1 ??", | 419 | dev_err(&serial->dev->dev, "active config #%d != 1 ??\n", |
420 | serial->dev->actconfig->desc.bConfigurationValue); | 420 | serial->dev->actconfig->desc.bConfigurationValue); |
421 | return -ENODEV; | 421 | return -ENODEV; |
422 | } | 422 | } |
@@ -499,15 +499,15 @@ static int __init empeg_init(void) | |||
499 | urb = usb_alloc_urb(0, GFP_KERNEL); | 499 | urb = usb_alloc_urb(0, GFP_KERNEL); |
500 | write_urb_pool[i] = urb; | 500 | write_urb_pool[i] = urb; |
501 | if (urb == NULL) { | 501 | if (urb == NULL) { |
502 | err("No more urbs???"); | 502 | printk(KERN_ERR "empeg: No more urbs???\n"); |
503 | continue; | 503 | continue; |
504 | } | 504 | } |
505 | 505 | ||
506 | urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE, | 506 | urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE, |
507 | GFP_KERNEL); | 507 | GFP_KERNEL); |
508 | if (!urb->transfer_buffer) { | 508 | if (!urb->transfer_buffer) { |
509 | err("%s - out of memory for urb buffers.", | 509 | printk(KERN_ERR "empeg: %s - out of memory for urb " |
510 | __func__); | 510 | "buffers.", __func__); |
511 | continue; | 511 | continue; |
512 | } | 512 | } |
513 | } | 513 | } |
@@ -519,7 +519,8 @@ static int __init empeg_init(void) | |||
519 | if (retval) | 519 | if (retval) |
520 | goto failed_usb_register; | 520 | goto failed_usb_register; |
521 | 521 | ||
522 | info(DRIVER_VERSION ":" DRIVER_DESC); | 522 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
523 | DRIVER_DESC "\n"); | ||
523 | 524 | ||
524 | return 0; | 525 | return 0; |
525 | failed_usb_register: | 526 | failed_usb_register: |
diff --git a/drivers/usb/serial/ezusb.c b/drivers/usb/serial/ezusb.c index 711e84f6ed82..3cfc762f5056 100644 --- a/drivers/usb/serial/ezusb.c +++ b/drivers/usb/serial/ezusb.c | |||
@@ -28,7 +28,8 @@ int ezusb_writememory(struct usb_serial *serial, int address, | |||
28 | 28 | ||
29 | /* dbg("ezusb_writememory %x, %d", address, length); */ | 29 | /* dbg("ezusb_writememory %x, %d", address, length); */ |
30 | if (!serial->dev) { | 30 | if (!serial->dev) { |
31 | err("%s - no physical device present, failing.", __func__); | 31 | printk(KERN_ERR "ezusb: %s - no physical device present, " |
32 | "failing.\n", __func__); | ||
32 | return -ENODEV; | 33 | return -ENODEV; |
33 | } | 34 | } |
34 | 35 | ||
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index 984f6eff4c47..51d7bdea2869 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c | |||
@@ -578,6 +578,7 @@ static struct usb_device_id id_table_combined [] = { | |||
578 | { USB_DEVICE(FALCOM_VID, FALCOM_TWIST_PID) }, | 578 | { USB_DEVICE(FALCOM_VID, FALCOM_TWIST_PID) }, |
579 | { USB_DEVICE(FALCOM_VID, FALCOM_SAMBA_PID) }, | 579 | { USB_DEVICE(FALCOM_VID, FALCOM_SAMBA_PID) }, |
580 | { USB_DEVICE(FTDI_VID, FTDI_SUUNTO_SPORTS_PID) }, | 580 | { USB_DEVICE(FTDI_VID, FTDI_SUUNTO_SPORTS_PID) }, |
581 | { USB_DEVICE(FTDI_VID, FTDI_OCEANIC_PID) }, | ||
581 | { USB_DEVICE(TTI_VID, TTI_QL355P_PID) }, | 582 | { USB_DEVICE(TTI_VID, TTI_QL355P_PID) }, |
582 | { USB_DEVICE(FTDI_VID, FTDI_RM_CANVIEW_PID) }, | 583 | { USB_DEVICE(FTDI_VID, FTDI_RM_CANVIEW_PID) }, |
583 | { USB_DEVICE(BANDB_VID, BANDB_USOTL4_PID) }, | 584 | { USB_DEVICE(BANDB_VID, BANDB_USOTL4_PID) }, |
@@ -654,6 +655,9 @@ static struct usb_device_id id_table_combined [] = { | |||
654 | .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, | 655 | .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, |
655 | { USB_DEVICE(RATOC_VENDOR_ID, RATOC_PRODUCT_ID_USB60F) }, | 656 | { USB_DEVICE(RATOC_VENDOR_ID, RATOC_PRODUCT_ID_USB60F) }, |
656 | { USB_DEVICE(FTDI_VID, FTDI_REU_TINY_PID) }, | 657 | { USB_DEVICE(FTDI_VID, FTDI_REU_TINY_PID) }, |
658 | { USB_DEVICE(PAPOUCH_VID, PAPOUCH_QUIDO4x4_PID) }, | ||
659 | { USB_DEVICE(FTDI_VID, FTDI_DOMINTELL_DGQG_PID) }, | ||
660 | { USB_DEVICE(FTDI_VID, FTDI_DOMINTELL_DUSB_PID) }, | ||
657 | { }, /* Optional parameter entry */ | 661 | { }, /* Optional parameter entry */ |
658 | { } /* Terminating entry */ | 662 | { } /* Terminating entry */ |
659 | }; | 663 | }; |
@@ -857,7 +861,7 @@ static int update_mctrl(struct usb_serial_port *port, unsigned int set, | |||
857 | 861 | ||
858 | kfree(buf); | 862 | kfree(buf); |
859 | if (rv < 0) { | 863 | if (rv < 0) { |
860 | err("%s Error from MODEM_CTRL urb: DTR %s, RTS %s", | 864 | dbg("%s Error from MODEM_CTRL urb: DTR %s, RTS %s", |
861 | __func__, | 865 | __func__, |
862 | (set & TIOCM_DTR) ? "HIGH" : | 866 | (set & TIOCM_DTR) ? "HIGH" : |
863 | (clear & TIOCM_DTR) ? "LOW" : "unchanged", | 867 | (clear & TIOCM_DTR) ? "LOW" : "unchanged", |
@@ -1150,7 +1154,7 @@ static void ftdi_determine_type(struct usb_serial_port *port) | |||
1150 | /* Assume its an FT232R */ | 1154 | /* Assume its an FT232R */ |
1151 | priv->chip_type = FT232RL; | 1155 | priv->chip_type = FT232RL; |
1152 | } | 1156 | } |
1153 | info("Detected %s", ftdi_chip_name[priv->chip_type]); | 1157 | dev_info(&udev->dev, "Detected %s\n", ftdi_chip_name[priv->chip_type]); |
1154 | } | 1158 | } |
1155 | 1159 | ||
1156 | 1160 | ||
@@ -1323,7 +1327,7 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port) | |||
1323 | 1327 | ||
1324 | priv = kzalloc(sizeof(struct ftdi_private), GFP_KERNEL); | 1328 | priv = kzalloc(sizeof(struct ftdi_private), GFP_KERNEL); |
1325 | if (!priv) { | 1329 | if (!priv) { |
1326 | err("%s- kmalloc(%Zd) failed.", __func__, | 1330 | dev_err(&port->dev, "%s- kmalloc(%Zd) failed.\n", __func__, |
1327 | sizeof(struct ftdi_private)); | 1331 | sizeof(struct ftdi_private)); |
1328 | return -ENOMEM; | 1332 | return -ENOMEM; |
1329 | } | 1333 | } |
@@ -1406,7 +1410,8 @@ static int ftdi_jtag_probe(struct usb_serial *serial) | |||
1406 | dbg("%s", __func__); | 1410 | dbg("%s", __func__); |
1407 | 1411 | ||
1408 | if (interface == udev->actconfig->interface[0]) { | 1412 | if (interface == udev->actconfig->interface[0]) { |
1409 | info("Ignoring serial port reserved for JTAG"); | 1413 | dev_info(&udev->dev, |
1414 | "Ignoring serial port reserved for JTAG\n"); | ||
1410 | return -ENODEV; | 1415 | return -ENODEV; |
1411 | } | 1416 | } |
1412 | 1417 | ||
@@ -1424,7 +1429,8 @@ static int ftdi_mtxorb_hack_setup(struct usb_serial *serial) | |||
1424 | 1429 | ||
1425 | if (ep->enabled && ep_desc->wMaxPacketSize == 0) { | 1430 | if (ep->enabled && ep_desc->wMaxPacketSize == 0) { |
1426 | ep_desc->wMaxPacketSize = cpu_to_le16(0x40); | 1431 | ep_desc->wMaxPacketSize = cpu_to_le16(0x40); |
1427 | info("Fixing invalid wMaxPacketSize on read pipe"); | 1432 | dev_info(&serial->dev->dev, |
1433 | "Fixing invalid wMaxPacketSize on read pipe\n"); | ||
1428 | } | 1434 | } |
1429 | 1435 | ||
1430 | return 0; | 1436 | return 0; |
@@ -1518,8 +1524,9 @@ static int ftdi_open(struct tty_struct *tty, | |||
1518 | ftdi_read_bulk_callback, port); | 1524 | ftdi_read_bulk_callback, port); |
1519 | result = usb_submit_urb(port->read_urb, GFP_KERNEL); | 1525 | result = usb_submit_urb(port->read_urb, GFP_KERNEL); |
1520 | if (result) | 1526 | if (result) |
1521 | err("%s - failed submitting read urb, error %d", | 1527 | dev_err(&port->dev, |
1522 | __func__, result); | 1528 | "%s - failed submitting read urb, error %d\n", |
1529 | __func__, result); | ||
1523 | 1530 | ||
1524 | 1531 | ||
1525 | return result; | 1532 | return result; |
@@ -1553,7 +1560,7 @@ static void ftdi_close(struct tty_struct *tty, | |||
1553 | FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, | 1560 | FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, |
1554 | 0, priv->interface, buf, 0, | 1561 | 0, priv->interface, buf, 0, |
1555 | WDR_TIMEOUT) < 0) { | 1562 | WDR_TIMEOUT) < 0) { |
1556 | err("error from flowcontrol urb"); | 1563 | dev_err(&port->dev, "error from flowcontrol urb\n"); |
1557 | } | 1564 | } |
1558 | 1565 | ||
1559 | /* drop RTS and DTR */ | 1566 | /* drop RTS and DTR */ |
@@ -1618,14 +1625,15 @@ static int ftdi_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
1618 | 1625 | ||
1619 | buffer = kmalloc(transfer_size, GFP_ATOMIC); | 1626 | buffer = kmalloc(transfer_size, GFP_ATOMIC); |
1620 | if (!buffer) { | 1627 | if (!buffer) { |
1621 | err("%s ran out of kernel memory for urb ...", __func__); | 1628 | dev_err(&port->dev, |
1629 | "%s ran out of kernel memory for urb ...\n", __func__); | ||
1622 | count = -ENOMEM; | 1630 | count = -ENOMEM; |
1623 | goto error_no_buffer; | 1631 | goto error_no_buffer; |
1624 | } | 1632 | } |
1625 | 1633 | ||
1626 | urb = usb_alloc_urb(0, GFP_ATOMIC); | 1634 | urb = usb_alloc_urb(0, GFP_ATOMIC); |
1627 | if (!urb) { | 1635 | if (!urb) { |
1628 | err("%s - no more free urbs", __func__); | 1636 | dev_err(&port->dev, "%s - no more free urbs\n", __func__); |
1629 | count = -ENOMEM; | 1637 | count = -ENOMEM; |
1630 | goto error_no_urb; | 1638 | goto error_no_urb; |
1631 | } | 1639 | } |
@@ -1669,8 +1677,9 @@ static int ftdi_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
1669 | 1677 | ||
1670 | status = usb_submit_urb(urb, GFP_ATOMIC); | 1678 | status = usb_submit_urb(urb, GFP_ATOMIC); |
1671 | if (status) { | 1679 | if (status) { |
1672 | err("%s - failed submitting write urb, error %d", | 1680 | dev_err(&port->dev, |
1673 | __func__, status); | 1681 | "%s - failed submitting write urb, error %d\n", |
1682 | __func__, status); | ||
1674 | count = status; | 1683 | count = status; |
1675 | goto error; | 1684 | goto error; |
1676 | } else { | 1685 | } else { |
@@ -1777,7 +1786,8 @@ static int ftdi_chars_in_buffer(struct tty_struct *tty) | |||
1777 | buffered = (int)priv->tx_outstanding_bytes; | 1786 | buffered = (int)priv->tx_outstanding_bytes; |
1778 | spin_unlock_irqrestore(&priv->tx_lock, flags); | 1787 | spin_unlock_irqrestore(&priv->tx_lock, flags); |
1779 | if (buffered < 0) { | 1788 | if (buffered < 0) { |
1780 | err("%s outstanding tx bytes is negative!", __func__); | 1789 | dev_err(&port->dev, "%s outstanding tx bytes is negative!\n", |
1790 | __func__); | ||
1781 | buffered = 0; | 1791 | buffered = 0; |
1782 | } | 1792 | } |
1783 | return buffered; | 1793 | return buffered; |
@@ -1793,11 +1803,12 @@ static void ftdi_read_bulk_callback(struct urb *urb) | |||
1793 | int status = urb->status; | 1803 | int status = urb->status; |
1794 | 1804 | ||
1795 | if (urb->number_of_packets > 0) { | 1805 | if (urb->number_of_packets > 0) { |
1796 | err("%s transfer_buffer_length %d actual_length %d number of packets %d", | 1806 | dev_err(&port->dev, "%s transfer_buffer_length %d " |
1797 | __func__, | 1807 | "actual_length %d number of packets %d\n", __func__, |
1798 | urb->transfer_buffer_length, | 1808 | urb->transfer_buffer_length, |
1799 | urb->actual_length, urb->number_of_packets); | 1809 | urb->actual_length, urb->number_of_packets); |
1800 | err("%s transfer_flags %x ", __func__, urb->transfer_flags); | 1810 | dev_err(&port->dev, "%s transfer_flags %x\n", __func__, |
1811 | urb->transfer_flags); | ||
1801 | } | 1812 | } |
1802 | 1813 | ||
1803 | dbg("%s - port %d", __func__, port->number); | 1814 | dbg("%s - port %d", __func__, port->number); |
@@ -1805,7 +1816,7 @@ static void ftdi_read_bulk_callback(struct urb *urb) | |||
1805 | if (port->port.count <= 0) | 1816 | if (port->port.count <= 0) |
1806 | return; | 1817 | return; |
1807 | 1818 | ||
1808 | tty = port->port.tty; | 1819 | tty = tty_port_tty_get(&port->port); |
1809 | if (!tty) { | 1820 | if (!tty) { |
1810 | dbg("%s - bad tty pointer - exiting", __func__); | 1821 | dbg("%s - bad tty pointer - exiting", __func__); |
1811 | return; | 1822 | return; |
@@ -1814,17 +1825,17 @@ static void ftdi_read_bulk_callback(struct urb *urb) | |||
1814 | priv = usb_get_serial_port_data(port); | 1825 | priv = usb_get_serial_port_data(port); |
1815 | if (!priv) { | 1826 | if (!priv) { |
1816 | dbg("%s - bad port private data pointer - exiting", __func__); | 1827 | dbg("%s - bad port private data pointer - exiting", __func__); |
1817 | return; | 1828 | goto out; |
1818 | } | 1829 | } |
1819 | 1830 | ||
1820 | if (urb != port->read_urb) | 1831 | if (urb != port->read_urb) |
1821 | err("%s - Not my urb!", __func__); | 1832 | dev_err(&port->dev, "%s - Not my urb!\n", __func__); |
1822 | 1833 | ||
1823 | if (status) { | 1834 | if (status) { |
1824 | /* This will happen at close every time so it is a dbg not an | 1835 | /* This will happen at close every time so it is a dbg not an |
1825 | err */ | 1836 | err */ |
1826 | dbg("(this is ok on close) nonzero read bulk status received: %d", status); | 1837 | dbg("(this is ok on close) nonzero read bulk status received: %d", status); |
1827 | return; | 1838 | goto out; |
1828 | } | 1839 | } |
1829 | 1840 | ||
1830 | /* count data bytes, but not status bytes */ | 1841 | /* count data bytes, but not status bytes */ |
@@ -1835,7 +1846,8 @@ static void ftdi_read_bulk_callback(struct urb *urb) | |||
1835 | spin_unlock_irqrestore(&priv->rx_lock, flags); | 1846 | spin_unlock_irqrestore(&priv->rx_lock, flags); |
1836 | 1847 | ||
1837 | ftdi_process_read(&priv->rx_work.work); | 1848 | ftdi_process_read(&priv->rx_work.work); |
1838 | 1849 | out: | |
1850 | tty_kref_put(tty); | ||
1839 | } /* ftdi_read_bulk_callback */ | 1851 | } /* ftdi_read_bulk_callback */ |
1840 | 1852 | ||
1841 | 1853 | ||
@@ -1860,7 +1872,7 @@ static void ftdi_process_read(struct work_struct *work) | |||
1860 | if (port->port.count <= 0) | 1872 | if (port->port.count <= 0) |
1861 | return; | 1873 | return; |
1862 | 1874 | ||
1863 | tty = port->port.tty; | 1875 | tty = tty_port_tty_get(&port->port); |
1864 | if (!tty) { | 1876 | if (!tty) { |
1865 | dbg("%s - bad tty pointer - exiting", __func__); | 1877 | dbg("%s - bad tty pointer - exiting", __func__); |
1866 | return; | 1878 | return; |
@@ -1869,13 +1881,13 @@ static void ftdi_process_read(struct work_struct *work) | |||
1869 | priv = usb_get_serial_port_data(port); | 1881 | priv = usb_get_serial_port_data(port); |
1870 | if (!priv) { | 1882 | if (!priv) { |
1871 | dbg("%s - bad port private data pointer - exiting", __func__); | 1883 | dbg("%s - bad port private data pointer - exiting", __func__); |
1872 | return; | 1884 | goto out; |
1873 | } | 1885 | } |
1874 | 1886 | ||
1875 | urb = port->read_urb; | 1887 | urb = port->read_urb; |
1876 | if (!urb) { | 1888 | if (!urb) { |
1877 | dbg("%s - bad read_urb pointer - exiting", __func__); | 1889 | dbg("%s - bad read_urb pointer - exiting", __func__); |
1878 | return; | 1890 | goto out; |
1879 | } | 1891 | } |
1880 | 1892 | ||
1881 | data = urb->transfer_buffer; | 1893 | data = urb->transfer_buffer; |
@@ -1920,7 +1932,8 @@ static void ftdi_process_read(struct work_struct *work) | |||
1920 | 1932 | ||
1921 | length = min(PKTSZ, urb->actual_length-packet_offset)-2; | 1933 | length = min(PKTSZ, urb->actual_length-packet_offset)-2; |
1922 | if (length < 0) { | 1934 | if (length < 0) { |
1923 | err("%s - bad packet length: %d", __func__, length+2); | 1935 | dev_err(&port->dev, "%s - bad packet length: %d\n", |
1936 | __func__, length+2); | ||
1924 | length = 0; | 1937 | length = 0; |
1925 | } | 1938 | } |
1926 | 1939 | ||
@@ -2017,7 +2030,7 @@ static void ftdi_process_read(struct work_struct *work) | |||
2017 | schedule_delayed_work(&priv->rx_work, 1); | 2030 | schedule_delayed_work(&priv->rx_work, 1); |
2018 | else | 2031 | else |
2019 | dbg("%s - port is closed", __func__); | 2032 | dbg("%s - port is closed", __func__); |
2020 | return; | 2033 | goto out; |
2021 | } | 2034 | } |
2022 | 2035 | ||
2023 | /* urb is completely processed */ | 2036 | /* urb is completely processed */ |
@@ -2035,9 +2048,12 @@ static void ftdi_process_read(struct work_struct *work) | |||
2035 | 2048 | ||
2036 | result = usb_submit_urb(port->read_urb, GFP_ATOMIC); | 2049 | result = usb_submit_urb(port->read_urb, GFP_ATOMIC); |
2037 | if (result) | 2050 | if (result) |
2038 | err("%s - failed resubmitting read urb, error %d", | 2051 | dev_err(&port->dev, |
2039 | __func__, result); | 2052 | "%s - failed resubmitting read urb, error %d\n", |
2053 | __func__, result); | ||
2040 | } | 2054 | } |
2055 | out: | ||
2056 | tty_kref_put(tty); | ||
2041 | } /* ftdi_process_read */ | 2057 | } /* ftdi_process_read */ |
2042 | 2058 | ||
2043 | 2059 | ||
@@ -2063,8 +2079,8 @@ static void ftdi_break_ctl(struct tty_struct *tty, int break_state) | |||
2063 | FTDI_SIO_SET_DATA_REQUEST_TYPE, | 2079 | FTDI_SIO_SET_DATA_REQUEST_TYPE, |
2064 | urb_value , priv->interface, | 2080 | urb_value , priv->interface, |
2065 | buf, 0, WDR_TIMEOUT) < 0) { | 2081 | buf, 0, WDR_TIMEOUT) < 0) { |
2066 | err("%s FAILED to enable/disable break state (state was %d)", | 2082 | dev_err(&port->dev, "%s FAILED to enable/disable break state " |
2067 | __func__, break_state); | 2083 | "(state was %d)\n", __func__, break_state); |
2068 | } | 2084 | } |
2069 | 2085 | ||
2070 | dbg("%s break state is %d - urb is %d", __func__, | 2086 | dbg("%s break state is %d - urb is %d", __func__, |
@@ -2136,7 +2152,7 @@ static void ftdi_set_termios(struct tty_struct *tty, | |||
2136 | case CS7: urb_value |= 7; dbg("Setting CS7"); break; | 2152 | case CS7: urb_value |= 7; dbg("Setting CS7"); break; |
2137 | case CS8: urb_value |= 8; dbg("Setting CS8"); break; | 2153 | case CS8: urb_value |= 8; dbg("Setting CS8"); break; |
2138 | default: | 2154 | default: |
2139 | err("CSIZE was set but not CS5-CS8"); | 2155 | dev_err(&port->dev, "CSIZE was set but not CS5-CS8\n"); |
2140 | } | 2156 | } |
2141 | } | 2157 | } |
2142 | 2158 | ||
@@ -2149,7 +2165,8 @@ static void ftdi_set_termios(struct tty_struct *tty, | |||
2149 | FTDI_SIO_SET_DATA_REQUEST_TYPE, | 2165 | FTDI_SIO_SET_DATA_REQUEST_TYPE, |
2150 | urb_value , priv->interface, | 2166 | urb_value , priv->interface, |
2151 | buf, 0, WDR_SHORT_TIMEOUT) < 0) { | 2167 | buf, 0, WDR_SHORT_TIMEOUT) < 0) { |
2152 | err("%s FAILED to set databits/stopbits/parity", __func__); | 2168 | dev_err(&port->dev, "%s FAILED to set " |
2169 | "databits/stopbits/parity\n", __func__); | ||
2153 | } | 2170 | } |
2154 | 2171 | ||
2155 | /* Now do the baudrate */ | 2172 | /* Now do the baudrate */ |
@@ -2160,14 +2177,17 @@ static void ftdi_set_termios(struct tty_struct *tty, | |||
2160 | FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, | 2177 | FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, |
2161 | 0, priv->interface, | 2178 | 0, priv->interface, |
2162 | buf, 0, WDR_TIMEOUT) < 0) { | 2179 | buf, 0, WDR_TIMEOUT) < 0) { |
2163 | err("%s error from disable flowcontrol urb", __func__); | 2180 | dev_err(&port->dev, |
2181 | "%s error from disable flowcontrol urb\n", | ||
2182 | __func__); | ||
2164 | } | 2183 | } |
2165 | /* Drop RTS and DTR */ | 2184 | /* Drop RTS and DTR */ |
2166 | clear_mctrl(port, TIOCM_DTR | TIOCM_RTS); | 2185 | clear_mctrl(port, TIOCM_DTR | TIOCM_RTS); |
2167 | } else { | 2186 | } else { |
2168 | /* set the baudrate determined before */ | 2187 | /* set the baudrate determined before */ |
2169 | if (change_speed(tty, port)) | 2188 | if (change_speed(tty, port)) |
2170 | err("%s urb failed to set baudrate", __func__); | 2189 | dev_err(&port->dev, "%s urb failed to set baudrate\n", |
2190 | __func__); | ||
2171 | /* Ensure RTS and DTR are raised when baudrate changed from 0 */ | 2191 | /* Ensure RTS and DTR are raised when baudrate changed from 0 */ |
2172 | if (!old_termios || (old_termios->c_cflag & CBAUD) == B0) | 2192 | if (!old_termios || (old_termios->c_cflag & CBAUD) == B0) |
2173 | set_mctrl(port, TIOCM_DTR | TIOCM_RTS); | 2193 | set_mctrl(port, TIOCM_DTR | TIOCM_RTS); |
@@ -2183,7 +2203,8 @@ static void ftdi_set_termios(struct tty_struct *tty, | |||
2183 | FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, | 2203 | FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, |
2184 | 0 , (FTDI_SIO_RTS_CTS_HS | priv->interface), | 2204 | 0 , (FTDI_SIO_RTS_CTS_HS | priv->interface), |
2185 | buf, 0, WDR_TIMEOUT) < 0) { | 2205 | buf, 0, WDR_TIMEOUT) < 0) { |
2186 | err("urb failed to set to rts/cts flow control"); | 2206 | dev_err(&port->dev, |
2207 | "urb failed to set to rts/cts flow control\n"); | ||
2187 | } | 2208 | } |
2188 | 2209 | ||
2189 | } else { | 2210 | } else { |
@@ -2214,7 +2235,8 @@ static void ftdi_set_termios(struct tty_struct *tty, | |||
2214 | urb_value , (FTDI_SIO_XON_XOFF_HS | 2235 | urb_value , (FTDI_SIO_XON_XOFF_HS |
2215 | | priv->interface), | 2236 | | priv->interface), |
2216 | buf, 0, WDR_TIMEOUT) < 0) { | 2237 | buf, 0, WDR_TIMEOUT) < 0) { |
2217 | err("urb failed to set to xon/xoff flow control"); | 2238 | dev_err(&port->dev, "urb failed to set to " |
2239 | "xon/xoff flow control\n"); | ||
2218 | } | 2240 | } |
2219 | } else { | 2241 | } else { |
2220 | /* else clause to only run if cflag ! CRTSCTS and iflag | 2242 | /* else clause to only run if cflag ! CRTSCTS and iflag |
@@ -2227,7 +2249,8 @@ static void ftdi_set_termios(struct tty_struct *tty, | |||
2227 | FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, | 2249 | FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, |
2228 | 0, priv->interface, | 2250 | 0, priv->interface, |
2229 | buf, 0, WDR_TIMEOUT) < 0) { | 2251 | buf, 0, WDR_TIMEOUT) < 0) { |
2230 | err("urb failed to clear flow control"); | 2252 | dev_err(&port->dev, |
2253 | "urb failed to clear flow control\n"); | ||
2231 | } | 2254 | } |
2232 | } | 2255 | } |
2233 | 2256 | ||
@@ -2253,7 +2276,7 @@ static int ftdi_tiocmget(struct tty_struct *tty, struct file *file) | |||
2253 | 0, 0, | 2276 | 0, 0, |
2254 | buf, 1, WDR_TIMEOUT); | 2277 | buf, 1, WDR_TIMEOUT); |
2255 | if (ret < 0) { | 2278 | if (ret < 0) { |
2256 | err("%s Could not get modem status of device - err: %d", __func__, | 2279 | dbg("%s Could not get modem status of device - err: %d", __func__, |
2257 | ret); | 2280 | ret); |
2258 | return ret; | 2281 | return ret; |
2259 | } | 2282 | } |
@@ -2272,7 +2295,7 @@ static int ftdi_tiocmget(struct tty_struct *tty, struct file *file) | |||
2272 | 0, priv->interface, | 2295 | 0, priv->interface, |
2273 | buf, 2, WDR_TIMEOUT); | 2296 | buf, 2, WDR_TIMEOUT); |
2274 | if (ret < 0) { | 2297 | if (ret < 0) { |
2275 | err("%s Could not get modem status of device - err: %d", __func__, | 2298 | dbg("%s Could not get modem status of device - err: %d", __func__, |
2276 | ret); | 2299 | ret); |
2277 | return ret; | 2300 | return ret; |
2278 | } | 2301 | } |
@@ -2419,7 +2442,8 @@ static int __init ftdi_init(void) | |||
2419 | if (retval) | 2442 | if (retval) |
2420 | goto failed_usb_register; | 2443 | goto failed_usb_register; |
2421 | 2444 | ||
2422 | info(DRIVER_VERSION ":" DRIVER_DESC); | 2445 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
2446 | DRIVER_DESC "\n"); | ||
2423 | return 0; | 2447 | return 0; |
2424 | failed_usb_register: | 2448 | failed_usb_register: |
2425 | usb_serial_deregister(&ftdi_sio_device); | 2449 | usb_serial_deregister(&ftdi_sio_device); |
@@ -2452,5 +2476,5 @@ module_param(vendor, ushort, 0); | |||
2452 | MODULE_PARM_DESC(vendor, "User specified vendor ID (default=" | 2476 | MODULE_PARM_DESC(vendor, "User specified vendor ID (default=" |
2453 | __MODULE_STRING(FTDI_VID)")"); | 2477 | __MODULE_STRING(FTDI_VID)")"); |
2454 | module_param(product, ushort, 0); | 2478 | module_param(product, ushort, 0); |
2455 | MODULE_PARM_DESC(vendor, "User specified product ID"); | 2479 | MODULE_PARM_DESC(product, "User specified product ID"); |
2456 | 2480 | ||
diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h index 382265bba969..07a3992abad2 100644 --- a/drivers/usb/serial/ftdi_sio.h +++ b/drivers/usb/serial/ftdi_sio.h | |||
@@ -628,6 +628,11 @@ | |||
628 | #define FTDI_SUUNTO_SPORTS_PID 0xF680 /* Suunto Sports instrument */ | 628 | #define FTDI_SUUNTO_SPORTS_PID 0xF680 /* Suunto Sports instrument */ |
629 | 629 | ||
630 | /* | 630 | /* |
631 | * Oceanic product ids | ||
632 | */ | ||
633 | #define FTDI_OCEANIC_PID 0xF460 /* Oceanic dive instrument */ | ||
634 | |||
635 | /* | ||
631 | * TTi (Thurlby Thandar Instruments) | 636 | * TTi (Thurlby Thandar Instruments) |
632 | */ | 637 | */ |
633 | #define TTI_VID 0x103E /* Vendor Id */ | 638 | #define TTI_VID 0x103E /* Vendor Id */ |
@@ -750,6 +755,7 @@ | |||
750 | 755 | ||
751 | #define PAPOUCH_VID 0x5050 /* Vendor ID */ | 756 | #define PAPOUCH_VID 0x5050 /* Vendor ID */ |
752 | #define PAPOUCH_TMU_PID 0x0400 /* TMU USB Thermometer */ | 757 | #define PAPOUCH_TMU_PID 0x0400 /* TMU USB Thermometer */ |
758 | #define PAPOUCH_QUIDO4x4_PID 0x0900 /* Quido 4/4 Module */ | ||
753 | 759 | ||
754 | /* | 760 | /* |
755 | * ACG Identification Technologies GmbH products (http://www.acg.de/). | 761 | * ACG Identification Technologies GmbH products (http://www.acg.de/). |
@@ -838,6 +844,10 @@ | |||
838 | /* Rig Expert Ukraine devices */ | 844 | /* Rig Expert Ukraine devices */ |
839 | #define FTDI_REU_TINY_PID 0xED22 /* RigExpert Tiny */ | 845 | #define FTDI_REU_TINY_PID 0xED22 /* RigExpert Tiny */ |
840 | 846 | ||
847 | /* Domintell products http://www.domintell.com */ | ||
848 | #define FTDI_DOMINTELL_DGQG_PID 0xEF50 /* Master */ | ||
849 | #define FTDI_DOMINTELL_DUSB_PID 0xEF51 /* DUSB01 module */ | ||
850 | |||
841 | /* Commands */ | 851 | /* Commands */ |
842 | #define FTDI_SIO_RESET 0 /* Reset the port */ | 852 | #define FTDI_SIO_RESET 0 /* Reset the port */ |
843 | #define FTDI_SIO_MODEM_CTRL 1 /* Set the modem control register */ | 853 | #define FTDI_SIO_MODEM_CTRL 1 /* Set the modem control register */ |
diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c index 2e663f1afd5e..8e6a66e38db2 100644 --- a/drivers/usb/serial/garmin_gps.c +++ b/drivers/usb/serial/garmin_gps.c | |||
@@ -38,8 +38,6 @@ | |||
38 | #include <linux/usb.h> | 38 | #include <linux/usb.h> |
39 | #include <linux/usb/serial.h> | 39 | #include <linux/usb/serial.h> |
40 | 40 | ||
41 | #include <linux/version.h> | ||
42 | |||
43 | /* the mode to be set when the port ist opened */ | 41 | /* the mode to be set when the port ist opened */ |
44 | static int initial_mode = 1; | 42 | static int initial_mode = 1; |
45 | 43 | ||
@@ -278,7 +276,7 @@ static inline int isAbortTrfCmnd(const unsigned char *buf) | |||
278 | static void send_to_tty(struct usb_serial_port *port, | 276 | static void send_to_tty(struct usb_serial_port *port, |
279 | char *data, unsigned int actual_length) | 277 | char *data, unsigned int actual_length) |
280 | { | 278 | { |
281 | struct tty_struct *tty = port->port.tty; | 279 | struct tty_struct *tty = tty_port_tty_get(&port->port); |
282 | 280 | ||
283 | if (tty && actual_length) { | 281 | if (tty && actual_length) { |
284 | 282 | ||
@@ -289,6 +287,7 @@ static void send_to_tty(struct usb_serial_port *port, | |||
289 | tty_insert_flip_string(tty, data, actual_length); | 287 | tty_insert_flip_string(tty, data, actual_length); |
290 | tty_flip_buffer_push(tty); | 288 | tty_flip_buffer_push(tty); |
291 | } | 289 | } |
290 | tty_kref_put(tty); | ||
292 | } | 291 | } |
293 | 292 | ||
294 | 293 | ||
@@ -1586,7 +1585,8 @@ static int __init garmin_init(void) | |||
1586 | retval = usb_register(&garmin_driver); | 1585 | retval = usb_register(&garmin_driver); |
1587 | if (retval) | 1586 | if (retval) |
1588 | goto failed_usb_register; | 1587 | goto failed_usb_register; |
1589 | info(DRIVER_DESC " " DRIVER_VERSION); | 1588 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
1589 | DRIVER_DESC "\n"); | ||
1590 | 1590 | ||
1591 | return 0; | 1591 | return 0; |
1592 | failed_usb_register: | 1592 | failed_usb_register: |
diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c index fe84c88ec20c..814909f1ee63 100644 --- a/drivers/usb/serial/generic.c +++ b/drivers/usb/serial/generic.c | |||
@@ -330,7 +330,7 @@ static void resubmit_read_urb(struct usb_serial_port *port, gfp_t mem_flags) | |||
330 | static void flush_and_resubmit_read_urb(struct usb_serial_port *port) | 330 | static void flush_and_resubmit_read_urb(struct usb_serial_port *port) |
331 | { | 331 | { |
332 | struct urb *urb = port->read_urb; | 332 | struct urb *urb = port->read_urb; |
333 | struct tty_struct *tty = port->port.tty; | 333 | struct tty_struct *tty = tty_port_tty_get(&port->port); |
334 | int room; | 334 | int room; |
335 | 335 | ||
336 | /* Push data to tty */ | 336 | /* Push data to tty */ |
@@ -341,6 +341,7 @@ static void flush_and_resubmit_read_urb(struct usb_serial_port *port) | |||
341 | tty_flip_buffer_push(tty); | 341 | tty_flip_buffer_push(tty); |
342 | } | 342 | } |
343 | } | 343 | } |
344 | tty_kref_put(tty); | ||
344 | 345 | ||
345 | resubmit_read_urb(port, GFP_ATOMIC); | 346 | resubmit_read_urb(port, GFP_ATOMIC); |
346 | } | 347 | } |
diff --git a/drivers/usb/serial/hp4x.c b/drivers/usb/serial/hp4x.c index ab905869e959..431329275133 100644 --- a/drivers/usb/serial/hp4x.c +++ b/drivers/usb/serial/hp4x.c | |||
@@ -63,7 +63,8 @@ static int __init hp49gp_init(void) | |||
63 | retval = usb_register(&hp49gp_driver); | 63 | retval = usb_register(&hp49gp_driver); |
64 | if (retval) | 64 | if (retval) |
65 | goto failed_usb_register; | 65 | goto failed_usb_register; |
66 | info(DRIVER_DESC " " DRIVER_VERSION); | 66 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
67 | DRIVER_DESC "\n"); | ||
67 | return 0; | 68 | return 0; |
68 | failed_usb_register: | 69 | failed_usb_register: |
69 | usb_serial_deregister(&hp49gp_device); | 70 | usb_serial_deregister(&hp49gp_device); |
diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c index bfa508ddb0fe..e85c8c0d1ad9 100644 --- a/drivers/usb/serial/io_edgeport.c +++ b/drivers/usb/serial/io_edgeport.c | |||
@@ -600,6 +600,7 @@ static void edge_interrupt_callback(struct urb *urb) | |||
600 | struct edgeport_serial *edge_serial = urb->context; | 600 | struct edgeport_serial *edge_serial = urb->context; |
601 | struct edgeport_port *edge_port; | 601 | struct edgeport_port *edge_port; |
602 | struct usb_serial_port *port; | 602 | struct usb_serial_port *port; |
603 | struct tty_struct *tty; | ||
603 | unsigned char *data = urb->transfer_buffer; | 604 | unsigned char *data = urb->transfer_buffer; |
604 | int length = urb->actual_length; | 605 | int length = urb->actual_length; |
605 | int bytes_avail; | 606 | int bytes_avail; |
@@ -675,9 +676,12 @@ static void edge_interrupt_callback(struct urb *urb) | |||
675 | 676 | ||
676 | /* tell the tty driver that something | 677 | /* tell the tty driver that something |
677 | has changed */ | 678 | has changed */ |
678 | if (edge_port->port->port.tty) | 679 | tty = tty_port_tty_get( |
679 | tty_wakeup(edge_port->port->port.tty); | 680 | &edge_port->port->port); |
680 | 681 | if (tty) { | |
682 | tty_wakeup(tty); | ||
683 | tty_kref_put(tty); | ||
684 | } | ||
681 | /* Since we have more credit, check | 685 | /* Since we have more credit, check |
682 | if more data can be sent */ | 686 | if more data can be sent */ |
683 | send_more_port_data(edge_serial, | 687 | send_more_port_data(edge_serial, |
@@ -778,13 +782,14 @@ static void edge_bulk_out_data_callback(struct urb *urb) | |||
778 | __func__, status); | 782 | __func__, status); |
779 | } | 783 | } |
780 | 784 | ||
781 | tty = edge_port->port->port.tty; | 785 | tty = tty_port_tty_get(&edge_port->port->port); |
782 | 786 | ||
783 | if (tty && edge_port->open) { | 787 | if (tty && edge_port->open) { |
784 | /* let the tty driver wakeup if it has a special | 788 | /* let the tty driver wakeup if it has a special |
785 | write_wakeup function */ | 789 | write_wakeup function */ |
786 | tty_wakeup(tty); | 790 | tty_wakeup(tty); |
787 | } | 791 | } |
792 | tty_kref_put(tty); | ||
788 | 793 | ||
789 | /* Release the Write URB */ | 794 | /* Release the Write URB */ |
790 | edge_port->write_in_progress = false; | 795 | edge_port->write_in_progress = false; |
@@ -826,11 +831,12 @@ static void edge_bulk_out_cmd_callback(struct urb *urb) | |||
826 | } | 831 | } |
827 | 832 | ||
828 | /* Get pointer to tty */ | 833 | /* Get pointer to tty */ |
829 | tty = edge_port->port->port.tty; | 834 | tty = tty_port_tty_get(&edge_port->port->port); |
830 | 835 | ||
831 | /* tell the tty driver that something has changed */ | 836 | /* tell the tty driver that something has changed */ |
832 | if (tty && edge_port->open) | 837 | if (tty && edge_port->open) |
833 | tty_wakeup(tty); | 838 | tty_wakeup(tty); |
839 | tty_kref_put(tty); | ||
834 | 840 | ||
835 | /* we have completed the command */ | 841 | /* we have completed the command */ |
836 | edge_port->commandPending = false; | 842 | edge_port->commandPending = false; |
@@ -1932,11 +1938,13 @@ static void process_rcvd_data(struct edgeport_serial *edge_serial, | |||
1932 | edge_serial->rxPort]; | 1938 | edge_serial->rxPort]; |
1933 | edge_port = usb_get_serial_port_data(port); | 1939 | edge_port = usb_get_serial_port_data(port); |
1934 | if (edge_port->open) { | 1940 | if (edge_port->open) { |
1935 | tty = edge_port->port->port.tty; | 1941 | tty = tty_port_tty_get( |
1942 | &edge_port->port->port); | ||
1936 | if (tty) { | 1943 | if (tty) { |
1937 | dbg("%s - Sending %d bytes to TTY for port %d", | 1944 | dbg("%s - Sending %d bytes to TTY for port %d", |
1938 | __func__, rxLen, edge_serial->rxPort); | 1945 | __func__, rxLen, edge_serial->rxPort); |
1939 | edge_tty_recv(&edge_serial->serial->dev->dev, tty, buffer, rxLen); | 1946 | edge_tty_recv(&edge_serial->serial->dev->dev, tty, buffer, rxLen); |
1947 | tty_kref_put(tty); | ||
1940 | } | 1948 | } |
1941 | edge_port->icount.rx += rxLen; | 1949 | edge_port->icount.rx += rxLen; |
1942 | } | 1950 | } |
@@ -1971,6 +1979,7 @@ static void process_rcvd_status(struct edgeport_serial *edge_serial, | |||
1971 | { | 1979 | { |
1972 | struct usb_serial_port *port; | 1980 | struct usb_serial_port *port; |
1973 | struct edgeport_port *edge_port; | 1981 | struct edgeport_port *edge_port; |
1982 | struct tty_struct *tty; | ||
1974 | __u8 code = edge_serial->rxStatusCode; | 1983 | __u8 code = edge_serial->rxStatusCode; |
1975 | 1984 | ||
1976 | /* switch the port pointer to the one being currently talked about */ | 1985 | /* switch the port pointer to the one being currently talked about */ |
@@ -2020,10 +2029,12 @@ static void process_rcvd_status(struct edgeport_serial *edge_serial, | |||
2020 | 2029 | ||
2021 | /* send the current line settings to the port so we are | 2030 | /* send the current line settings to the port so we are |
2022 | in sync with any further termios calls */ | 2031 | in sync with any further termios calls */ |
2023 | /* FIXME: locking on tty */ | 2032 | tty = tty_port_tty_get(&edge_port->port->port); |
2024 | if (edge_port->port->port.tty) | 2033 | if (tty) { |
2025 | change_port_settings(edge_port->port->port.tty, | 2034 | change_port_settings(tty, |
2026 | edge_port, edge_port->port->port.tty->termios); | 2035 | edge_port, tty->termios); |
2036 | tty_kref_put(tty); | ||
2037 | } | ||
2027 | 2038 | ||
2028 | /* we have completed the open */ | 2039 | /* we have completed the open */ |
2029 | edge_port->openPending = false; | 2040 | edge_port->openPending = false; |
@@ -2163,10 +2174,14 @@ static void handle_new_lsr(struct edgeport_port *edge_port, __u8 lsrData, | |||
2163 | } | 2174 | } |
2164 | 2175 | ||
2165 | /* Place LSR data byte into Rx buffer */ | 2176 | /* Place LSR data byte into Rx buffer */ |
2166 | if (lsrData && edge_port->port->port.tty) | 2177 | if (lsrData) { |
2167 | edge_tty_recv(&edge_port->port->dev, | 2178 | struct tty_struct *tty = |
2168 | edge_port->port->port.tty, &data, 1); | 2179 | tty_port_tty_get(&edge_port->port->port); |
2169 | 2180 | if (tty) { | |
2181 | edge_tty_recv(&edge_port->port->dev, tty, &data, 1); | ||
2182 | tty_kref_put(tty); | ||
2183 | } | ||
2184 | } | ||
2170 | /* update input line counters */ | 2185 | /* update input line counters */ |
2171 | icount = &edge_port->icount; | 2186 | icount = &edge_port->icount; |
2172 | if (newLsr & LSR_BREAK) | 2187 | if (newLsr & LSR_BREAK) |
@@ -3094,13 +3109,13 @@ static int edge_startup(struct usb_serial *serial) | |||
3094 | edge_serial->interrupt_read_urb = | 3109 | edge_serial->interrupt_read_urb = |
3095 | usb_alloc_urb(0, GFP_KERNEL); | 3110 | usb_alloc_urb(0, GFP_KERNEL); |
3096 | if (!edge_serial->interrupt_read_urb) { | 3111 | if (!edge_serial->interrupt_read_urb) { |
3097 | err("out of memory"); | 3112 | dev_err(&dev->dev, "out of memory\n"); |
3098 | return -ENOMEM; | 3113 | return -ENOMEM; |
3099 | } | 3114 | } |
3100 | edge_serial->interrupt_in_buffer = | 3115 | edge_serial->interrupt_in_buffer = |
3101 | kmalloc(buffer_size, GFP_KERNEL); | 3116 | kmalloc(buffer_size, GFP_KERNEL); |
3102 | if (!edge_serial->interrupt_in_buffer) { | 3117 | if (!edge_serial->interrupt_in_buffer) { |
3103 | err("out of memory"); | 3118 | dev_err(&dev->dev, "out of memory\n"); |
3104 | usb_free_urb(edge_serial->interrupt_read_urb); | 3119 | usb_free_urb(edge_serial->interrupt_read_urb); |
3105 | return -ENOMEM; | 3120 | return -ENOMEM; |
3106 | } | 3121 | } |
@@ -3131,13 +3146,13 @@ static int edge_startup(struct usb_serial *serial) | |||
3131 | edge_serial->read_urb = | 3146 | edge_serial->read_urb = |
3132 | usb_alloc_urb(0, GFP_KERNEL); | 3147 | usb_alloc_urb(0, GFP_KERNEL); |
3133 | if (!edge_serial->read_urb) { | 3148 | if (!edge_serial->read_urb) { |
3134 | err("out of memory"); | 3149 | dev_err(&dev->dev, "out of memory\n"); |
3135 | return -ENOMEM; | 3150 | return -ENOMEM; |
3136 | } | 3151 | } |
3137 | edge_serial->bulk_in_buffer = | 3152 | edge_serial->bulk_in_buffer = |
3138 | kmalloc(buffer_size, GFP_KERNEL); | 3153 | kmalloc(buffer_size, GFP_KERNEL); |
3139 | if (!edge_serial->bulk_in_buffer) { | 3154 | if (!edge_serial->bulk_in_buffer) { |
3140 | err("out of memory"); | 3155 | dev_err(&dev->dev, "out of memory\n"); |
3141 | usb_free_urb(edge_serial->read_urb); | 3156 | usb_free_urb(edge_serial->read_urb); |
3142 | return -ENOMEM; | 3157 | return -ENOMEM; |
3143 | } | 3158 | } |
@@ -3166,7 +3181,8 @@ static int edge_startup(struct usb_serial *serial) | |||
3166 | } | 3181 | } |
3167 | 3182 | ||
3168 | if (!interrupt_in_found || !bulk_in_found || !bulk_out_found) { | 3183 | if (!interrupt_in_found || !bulk_in_found || !bulk_out_found) { |
3169 | err("Error - the proper endpoints were not found!"); | 3184 | dev_err(&dev->dev, "Error - the proper endpoints " |
3185 | "were not found!\n"); | ||
3170 | return -ENODEV; | 3186 | return -ENODEV; |
3171 | } | 3187 | } |
3172 | 3188 | ||
@@ -3175,8 +3191,9 @@ static int edge_startup(struct usb_serial *serial) | |||
3175 | response = usb_submit_urb(edge_serial->interrupt_read_urb, | 3191 | response = usb_submit_urb(edge_serial->interrupt_read_urb, |
3176 | GFP_KERNEL); | 3192 | GFP_KERNEL); |
3177 | if (response) | 3193 | if (response) |
3178 | err("%s - Error %d submitting control urb", | 3194 | dev_err(&dev->dev, |
3179 | __func__, response); | 3195 | "%s - Error %d submitting control urb\n", |
3196 | __func__, response); | ||
3180 | } | 3197 | } |
3181 | return response; | 3198 | return response; |
3182 | } | 3199 | } |
@@ -3238,7 +3255,8 @@ static int __init edgeport_init(void) | |||
3238 | if (retval) | 3255 | if (retval) |
3239 | goto failed_usb_register; | 3256 | goto failed_usb_register; |
3240 | atomic_set(&CmdUrbs, 0); | 3257 | atomic_set(&CmdUrbs, 0); |
3241 | info(DRIVER_DESC " " DRIVER_VERSION); | 3258 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
3259 | DRIVER_DESC "\n"); | ||
3242 | return 0; | 3260 | return 0; |
3243 | 3261 | ||
3244 | failed_usb_register: | 3262 | failed_usb_register: |
diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c index cb4c54316cf5..c3cdd00ddc41 100644 --- a/drivers/usb/serial/io_ti.c +++ b/drivers/usb/serial/io_ti.c | |||
@@ -572,7 +572,7 @@ static void chase_port(struct edgeport_port *port, unsigned long timeout, | |||
572 | int flush) | 572 | int flush) |
573 | { | 573 | { |
574 | int baud_rate; | 574 | int baud_rate; |
575 | struct tty_struct *tty = port->port->port.tty; | 575 | struct tty_struct *tty = tty_port_tty_get(&port->port->port); |
576 | wait_queue_t wait; | 576 | wait_queue_t wait; |
577 | unsigned long flags; | 577 | unsigned long flags; |
578 | 578 | ||
@@ -599,6 +599,7 @@ static void chase_port(struct edgeport_port *port, unsigned long timeout, | |||
599 | if (flush) | 599 | if (flush) |
600 | edge_buf_clear(port->ep_out_buf); | 600 | edge_buf_clear(port->ep_out_buf); |
601 | spin_unlock_irqrestore(&port->ep_lock, flags); | 601 | spin_unlock_irqrestore(&port->ep_lock, flags); |
602 | tty_kref_put(tty); | ||
602 | 603 | ||
603 | /* wait for data to drain from the device */ | 604 | /* wait for data to drain from the device */ |
604 | timeout += jiffies; | 605 | timeout += jiffies; |
@@ -1554,7 +1555,7 @@ static void handle_new_msr(struct edgeport_port *edge_port, __u8 msr) | |||
1554 | /* Save the new modem status */ | 1555 | /* Save the new modem status */ |
1555 | edge_port->shadow_msr = msr & 0xf0; | 1556 | edge_port->shadow_msr = msr & 0xf0; |
1556 | 1557 | ||
1557 | tty = edge_port->port->port.tty; | 1558 | tty = tty_port_tty_get(&edge_port->port->port); |
1558 | /* handle CTS flow control */ | 1559 | /* handle CTS flow control */ |
1559 | if (tty && C_CRTSCTS(tty)) { | 1560 | if (tty && C_CRTSCTS(tty)) { |
1560 | if (msr & EDGEPORT_MSR_CTS) { | 1561 | if (msr & EDGEPORT_MSR_CTS) { |
@@ -1564,6 +1565,7 @@ static void handle_new_msr(struct edgeport_port *edge_port, __u8 msr) | |||
1564 | tty->hw_stopped = 1; | 1565 | tty->hw_stopped = 1; |
1565 | } | 1566 | } |
1566 | } | 1567 | } |
1568 | tty_kref_put(tty); | ||
1567 | 1569 | ||
1568 | return; | 1570 | return; |
1569 | } | 1571 | } |
@@ -1574,6 +1576,7 @@ static void handle_new_lsr(struct edgeport_port *edge_port, int lsr_data, | |||
1574 | struct async_icount *icount; | 1576 | struct async_icount *icount; |
1575 | __u8 new_lsr = (__u8)(lsr & (__u8)(LSR_OVER_ERR | LSR_PAR_ERR | | 1577 | __u8 new_lsr = (__u8)(lsr & (__u8)(LSR_OVER_ERR | LSR_PAR_ERR | |
1576 | LSR_FRM_ERR | LSR_BREAK)); | 1578 | LSR_FRM_ERR | LSR_BREAK)); |
1579 | struct tty_struct *tty; | ||
1577 | 1580 | ||
1578 | dbg("%s - %02x", __func__, new_lsr); | 1581 | dbg("%s - %02x", __func__, new_lsr); |
1579 | 1582 | ||
@@ -1587,8 +1590,13 @@ static void handle_new_lsr(struct edgeport_port *edge_port, int lsr_data, | |||
1587 | new_lsr &= (__u8)(LSR_OVER_ERR | LSR_BREAK); | 1590 | new_lsr &= (__u8)(LSR_OVER_ERR | LSR_BREAK); |
1588 | 1591 | ||
1589 | /* Place LSR data byte into Rx buffer */ | 1592 | /* Place LSR data byte into Rx buffer */ |
1590 | if (lsr_data && edge_port->port->port.tty) | 1593 | if (lsr_data) { |
1591 | edge_tty_recv(&edge_port->port->dev, edge_port->port->port.tty, &data, 1); | 1594 | tty = tty_port_tty_get(&edge_port->port->port); |
1595 | if (tty) { | ||
1596 | edge_tty_recv(&edge_port->port->dev, tty, &data, 1); | ||
1597 | tty_kref_put(tty); | ||
1598 | } | ||
1599 | } | ||
1592 | 1600 | ||
1593 | /* update input line counters */ | 1601 | /* update input line counters */ |
1594 | icount = &edge_port->icount; | 1602 | icount = &edge_port->icount; |
@@ -1749,7 +1757,7 @@ static void edge_bulk_in_callback(struct urb *urb) | |||
1749 | ++data; | 1757 | ++data; |
1750 | } | 1758 | } |
1751 | 1759 | ||
1752 | tty = edge_port->port->port.tty; | 1760 | tty = tty_port_tty_get(&edge_port->port->port); |
1753 | if (tty && urb->actual_length) { | 1761 | if (tty && urb->actual_length) { |
1754 | usb_serial_debug_data(debug, &edge_port->port->dev, | 1762 | usb_serial_debug_data(debug, &edge_port->port->dev, |
1755 | __func__, urb->actual_length, data); | 1763 | __func__, urb->actual_length, data); |
@@ -1761,6 +1769,7 @@ static void edge_bulk_in_callback(struct urb *urb) | |||
1761 | urb->actual_length); | 1769 | urb->actual_length); |
1762 | edge_port->icount.rx += urb->actual_length; | 1770 | edge_port->icount.rx += urb->actual_length; |
1763 | } | 1771 | } |
1772 | tty_kref_put(tty); | ||
1764 | 1773 | ||
1765 | exit: | 1774 | exit: |
1766 | /* continue read unless stopped */ | 1775 | /* continue read unless stopped */ |
@@ -1796,6 +1805,7 @@ static void edge_bulk_out_callback(struct urb *urb) | |||
1796 | struct usb_serial_port *port = urb->context; | 1805 | struct usb_serial_port *port = urb->context; |
1797 | struct edgeport_port *edge_port = usb_get_serial_port_data(port); | 1806 | struct edgeport_port *edge_port = usb_get_serial_port_data(port); |
1798 | int status = urb->status; | 1807 | int status = urb->status; |
1808 | struct tty_struct *tty; | ||
1799 | 1809 | ||
1800 | dbg("%s - port %d", __func__, port->number); | 1810 | dbg("%s - port %d", __func__, port->number); |
1801 | 1811 | ||
@@ -1818,7 +1828,9 @@ static void edge_bulk_out_callback(struct urb *urb) | |||
1818 | } | 1828 | } |
1819 | 1829 | ||
1820 | /* send any buffered data */ | 1830 | /* send any buffered data */ |
1821 | edge_send(port->port.tty); | 1831 | tty = tty_port_tty_get(&port->port); |
1832 | edge_send(tty); | ||
1833 | tty_kref_put(tty); | ||
1822 | } | 1834 | } |
1823 | 1835 | ||
1824 | static int edge_open(struct tty_struct *tty, | 1836 | static int edge_open(struct tty_struct *tty, |
@@ -1876,7 +1888,7 @@ static int edge_open(struct tty_struct *tty, | |||
1876 | 1888 | ||
1877 | /* set up the port settings */ | 1889 | /* set up the port settings */ |
1878 | if (tty) | 1890 | if (tty) |
1879 | edge_set_termios(tty, port, port->port.tty->termios); | 1891 | edge_set_termios(tty, port, tty->termios); |
1880 | 1892 | ||
1881 | /* open up the port */ | 1893 | /* open up the port */ |
1882 | 1894 | ||
@@ -2966,7 +2978,8 @@ static int __init edgeport_init(void) | |||
2966 | retval = usb_register(&io_driver); | 2978 | retval = usb_register(&io_driver); |
2967 | if (retval) | 2979 | if (retval) |
2968 | goto failed_usb_register; | 2980 | goto failed_usb_register; |
2969 | info(DRIVER_DESC " " DRIVER_VERSION); | 2981 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
2982 | DRIVER_DESC "\n"); | ||
2970 | return 0; | 2983 | return 0; |
2971 | failed_usb_register: | 2984 | failed_usb_register: |
2972 | usb_serial_deregister(&edgeport_2port_device); | 2985 | usb_serial_deregister(&edgeport_2port_device); |
diff --git a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c index cd9a2e138c8b..132be74d2b89 100644 --- a/drivers/usb/serial/ipaq.c +++ b/drivers/usb/serial/ipaq.c | |||
@@ -608,7 +608,7 @@ static int ipaq_open(struct tty_struct *tty, | |||
608 | bytes_out = 0; | 608 | bytes_out = 0; |
609 | priv = kmalloc(sizeof(struct ipaq_private), GFP_KERNEL); | 609 | priv = kmalloc(sizeof(struct ipaq_private), GFP_KERNEL); |
610 | if (priv == NULL) { | 610 | if (priv == NULL) { |
611 | err("%s - Out of memory", __func__); | 611 | dev_err(&port->dev, "%s - Out of memory\n", __func__); |
612 | return -ENOMEM; | 612 | return -ENOMEM; |
613 | } | 613 | } |
614 | usb_set_serial_port_data(port, priv); | 614 | usb_set_serial_port_data(port, priv); |
@@ -693,8 +693,7 @@ static int ipaq_open(struct tty_struct *tty, | |||
693 | } | 693 | } |
694 | 694 | ||
695 | if (!retries && result) { | 695 | if (!retries && result) { |
696 | err("%s - failed doing control urb, error %d", __func__, | 696 | dev_err(&port->dev, "%s - failed doing control urb, error %d\n", __func__, result); |
697 | result); | ||
698 | goto error; | 697 | goto error; |
699 | } | 698 | } |
700 | 699 | ||
@@ -707,8 +706,9 @@ static int ipaq_open(struct tty_struct *tty, | |||
707 | 706 | ||
708 | result = usb_submit_urb(port->read_urb, GFP_KERNEL); | 707 | result = usb_submit_urb(port->read_urb, GFP_KERNEL); |
709 | if (result) { | 708 | if (result) { |
710 | err("%s - failed submitting read urb, error %d", | 709 | dev_err(&port->dev, |
711 | __func__, result); | 710 | "%s - failed submitting read urb, error %d\n", |
711 | __func__, result); | ||
712 | goto error; | 712 | goto error; |
713 | } | 713 | } |
714 | 714 | ||
@@ -716,7 +716,7 @@ static int ipaq_open(struct tty_struct *tty, | |||
716 | 716 | ||
717 | enomem: | 717 | enomem: |
718 | result = -ENOMEM; | 718 | result = -ENOMEM; |
719 | err("%s - Out of memory", __func__); | 719 | dev_err(&port->dev, "%s - Out of memory\n", __func__); |
720 | error: | 720 | error: |
721 | ipaq_destroy_lists(port); | 721 | ipaq_destroy_lists(port); |
722 | kfree(priv); | 722 | kfree(priv); |
@@ -764,13 +764,14 @@ static void ipaq_read_bulk_callback(struct urb *urb) | |||
764 | usb_serial_debug_data(debug, &port->dev, __func__, | 764 | usb_serial_debug_data(debug, &port->dev, __func__, |
765 | urb->actual_length, data); | 765 | urb->actual_length, data); |
766 | 766 | ||
767 | tty = port->port.tty; | 767 | tty = tty_port_tty_get(&port->port); |
768 | if (tty && urb->actual_length) { | 768 | if (tty && urb->actual_length) { |
769 | tty_buffer_request_room(tty, urb->actual_length); | 769 | tty_buffer_request_room(tty, urb->actual_length); |
770 | tty_insert_flip_string(tty, data, urb->actual_length); | 770 | tty_insert_flip_string(tty, data, urb->actual_length); |
771 | tty_flip_buffer_push(tty); | 771 | tty_flip_buffer_push(tty); |
772 | bytes_in += urb->actual_length; | 772 | bytes_in += urb->actual_length; |
773 | } | 773 | } |
774 | tty_kref_put(tty); | ||
774 | 775 | ||
775 | /* Continue trying to always read */ | 776 | /* Continue trying to always read */ |
776 | usb_fill_bulk_urb(port->read_urb, port->serial->dev, | 777 | usb_fill_bulk_urb(port->read_urb, port->serial->dev, |
@@ -780,8 +781,9 @@ static void ipaq_read_bulk_callback(struct urb *urb) | |||
780 | ipaq_read_bulk_callback, port); | 781 | ipaq_read_bulk_callback, port); |
781 | result = usb_submit_urb(port->read_urb, GFP_ATOMIC); | 782 | result = usb_submit_urb(port->read_urb, GFP_ATOMIC); |
782 | if (result) | 783 | if (result) |
783 | err("%s - failed resubmitting read urb, error %d", | 784 | dev_err(&port->dev, |
784 | __func__, result); | 785 | "%s - failed resubmitting read urb, error %d\n", |
786 | __func__, result); | ||
785 | return; | 787 | return; |
786 | } | 788 | } |
787 | 789 | ||
@@ -846,7 +848,8 @@ static int ipaq_write_bulk(struct usb_serial_port *port, | |||
846 | spin_unlock_irqrestore(&write_list_lock, flags); | 848 | spin_unlock_irqrestore(&write_list_lock, flags); |
847 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); | 849 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); |
848 | if (result) | 850 | if (result) |
849 | err("%s - failed submitting write urb, error %d", | 851 | dev_err(&port->dev, |
852 | "%s - failed submitting write urb, error %d\n", | ||
850 | __func__, result); | 853 | __func__, result); |
851 | } else { | 854 | } else { |
852 | spin_unlock_irqrestore(&write_list_lock, flags); | 855 | spin_unlock_irqrestore(&write_list_lock, flags); |
@@ -908,8 +911,9 @@ static void ipaq_write_bulk_callback(struct urb *urb) | |||
908 | spin_unlock_irqrestore(&write_list_lock, flags); | 911 | spin_unlock_irqrestore(&write_list_lock, flags); |
909 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); | 912 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); |
910 | if (result) | 913 | if (result) |
911 | err("%s - failed submitting write urb, error %d", | 914 | dev_err(&port->dev, |
912 | __func__, result); | 915 | "%s - failed submitting write urb, error %d\n", |
916 | __func__, result); | ||
913 | } else { | 917 | } else { |
914 | priv->active = 0; | 918 | priv->active = 0; |
915 | spin_unlock_irqrestore(&write_list_lock, flags); | 919 | spin_unlock_irqrestore(&write_list_lock, flags); |
@@ -956,7 +960,7 @@ static int ipaq_startup(struct usb_serial *serial) | |||
956 | { | 960 | { |
957 | dbg("%s", __func__); | 961 | dbg("%s", __func__); |
958 | if (serial->dev->actconfig->desc.bConfigurationValue != 1) { | 962 | if (serial->dev->actconfig->desc.bConfigurationValue != 1) { |
959 | err("active config #%d != 1 ??", | 963 | dev_err(&serial->dev->dev, "active config #%d != 1 ??\n", |
960 | serial->dev->actconfig->desc.bConfigurationValue); | 964 | serial->dev->actconfig->desc.bConfigurationValue); |
961 | return -ENODEV; | 965 | return -ENODEV; |
962 | } | 966 | } |
@@ -975,7 +979,6 @@ static int __init ipaq_init(void) | |||
975 | retval = usb_serial_register(&ipaq_device); | 979 | retval = usb_serial_register(&ipaq_device); |
976 | if (retval) | 980 | if (retval) |
977 | goto failed_usb_serial_register; | 981 | goto failed_usb_serial_register; |
978 | info(DRIVER_DESC " " DRIVER_VERSION); | ||
979 | if (vendor) { | 982 | if (vendor) { |
980 | ipaq_id_table[0].idVendor = vendor; | 983 | ipaq_id_table[0].idVendor = vendor; |
981 | ipaq_id_table[0].idProduct = product; | 984 | ipaq_id_table[0].idProduct = product; |
@@ -984,6 +987,8 @@ static int __init ipaq_init(void) | |||
984 | if (retval) | 987 | if (retval) |
985 | goto failed_usb_register; | 988 | goto failed_usb_register; |
986 | 989 | ||
990 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" | ||
991 | DRIVER_DESC "\n"); | ||
987 | return 0; | 992 | return 0; |
988 | failed_usb_register: | 993 | failed_usb_register: |
989 | usb_serial_deregister(&ipaq_device); | 994 | usb_serial_deregister(&ipaq_device); |
diff --git a/drivers/usb/serial/ipw.c b/drivers/usb/serial/ipw.c index a842025b9b57..3ac59a8a980f 100644 --- a/drivers/usb/serial/ipw.c +++ b/drivers/usb/serial/ipw.c | |||
@@ -170,12 +170,13 @@ static void ipw_read_bulk_callback(struct urb *urb) | |||
170 | usb_serial_debug_data(debug, &port->dev, __func__, | 170 | usb_serial_debug_data(debug, &port->dev, __func__, |
171 | urb->actual_length, data); | 171 | urb->actual_length, data); |
172 | 172 | ||
173 | tty = port->port.tty; | 173 | tty = tty_port_tty_get(&port->port); |
174 | if (tty && urb->actual_length) { | 174 | if (tty && urb->actual_length) { |
175 | tty_buffer_request_room(tty, urb->actual_length); | 175 | tty_buffer_request_room(tty, urb->actual_length); |
176 | tty_insert_flip_string(tty, data, urb->actual_length); | 176 | tty_insert_flip_string(tty, data, urb->actual_length); |
177 | tty_flip_buffer_push(tty); | 177 | tty_flip_buffer_push(tty); |
178 | } | 178 | } |
179 | tty_kref_put(tty); | ||
179 | 180 | ||
180 | /* Continue trying to always read */ | 181 | /* Continue trying to always read */ |
181 | usb_fill_bulk_urb(port->read_urb, port->serial->dev, | 182 | usb_fill_bulk_urb(port->read_urb, port->serial->dev, |
@@ -484,7 +485,8 @@ static int usb_ipw_init(void) | |||
484 | usb_serial_deregister(&ipw_device); | 485 | usb_serial_deregister(&ipw_device); |
485 | return retval; | 486 | return retval; |
486 | } | 487 | } |
487 | info(DRIVER_DESC " " DRIVER_VERSION); | 488 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
489 | DRIVER_DESC "\n"); | ||
488 | return 0; | 490 | return 0; |
489 | } | 491 | } |
490 | 492 | ||
diff --git a/drivers/usb/serial/ir-usb.c b/drivers/usb/serial/ir-usb.c index e59155c6607d..b679a556b98d 100644 --- a/drivers/usb/serial/ir-usb.c +++ b/drivers/usb/serial/ir-usb.c | |||
@@ -465,11 +465,12 @@ static void ir_read_bulk_callback(struct urb *urb) | |||
465 | ir_baud = *data & 0x0f; | 465 | ir_baud = *data & 0x0f; |
466 | usb_serial_debug_data(debug, &port->dev, __func__, | 466 | usb_serial_debug_data(debug, &port->dev, __func__, |
467 | urb->actual_length, data); | 467 | urb->actual_length, data); |
468 | tty = port->port.tty; | 468 | tty = tty_port_tty_get(&port->port); |
469 | if (tty_buffer_request_room(tty, urb->actual_length - 1)) { | 469 | if (tty_buffer_request_room(tty, urb->actual_length - 1)) { |
470 | tty_insert_flip_string(tty, data+1, urb->actual_length - 1); | 470 | tty_insert_flip_string(tty, data+1, urb->actual_length - 1); |
471 | tty_flip_buffer_push(tty); | 471 | tty_flip_buffer_push(tty); |
472 | } | 472 | } |
473 | tty_kref_put(tty); | ||
473 | 474 | ||
474 | /* | 475 | /* |
475 | * No break here. | 476 | * No break here. |
@@ -601,7 +602,8 @@ static int __init ir_init(void) | |||
601 | if (retval) | 602 | if (retval) |
602 | goto failed_usb_register; | 603 | goto failed_usb_register; |
603 | 604 | ||
604 | info(DRIVER_DESC " " DRIVER_VERSION); | 605 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
606 | DRIVER_DESC "\n"); | ||
605 | 607 | ||
606 | return 0; | 608 | return 0; |
607 | 609 | ||
diff --git a/drivers/usb/serial/iuu_phoenix.c b/drivers/usb/serial/iuu_phoenix.c index ddff37fa6339..e320972cb227 100644 --- a/drivers/usb/serial/iuu_phoenix.c +++ b/drivers/usb/serial/iuu_phoenix.c | |||
@@ -629,13 +629,14 @@ static void read_buf_callback(struct urb *urb) | |||
629 | } | 629 | } |
630 | 630 | ||
631 | dbg("%s - %i chars to write", __func__, urb->actual_length); | 631 | dbg("%s - %i chars to write", __func__, urb->actual_length); |
632 | tty = port->port.tty; | 632 | tty = tty_port_tty_get(&port->port); |
633 | if (data == NULL) | 633 | if (data == NULL) |
634 | dbg("%s - data is NULL !!!", __func__); | 634 | dbg("%s - data is NULL !!!", __func__); |
635 | if (tty && urb->actual_length && data) { | 635 | if (tty && urb->actual_length && data) { |
636 | tty_insert_flip_string(tty, data, urb->actual_length); | 636 | tty_insert_flip_string(tty, data, urb->actual_length); |
637 | tty_flip_buffer_push(tty); | 637 | tty_flip_buffer_push(tty); |
638 | } | 638 | } |
639 | tty_kref_put(tty); | ||
639 | iuu_led_activity_on(urb); | 640 | iuu_led_activity_on(urb); |
640 | } | 641 | } |
641 | 642 | ||
@@ -1184,7 +1185,8 @@ static int __init iuu_init(void) | |||
1184 | retval = usb_register(&iuu_driver); | 1185 | retval = usb_register(&iuu_driver); |
1185 | if (retval) | 1186 | if (retval) |
1186 | goto failed_usb_register; | 1187 | goto failed_usb_register; |
1187 | info(DRIVER_DESC " " DRIVER_VERSION); | 1188 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
1189 | DRIVER_DESC "\n"); | ||
1188 | return 0; | 1190 | return 0; |
1189 | failed_usb_register: | 1191 | failed_usb_register: |
1190 | usb_serial_deregister(&iuu_device); | 1192 | usb_serial_deregister(&iuu_device); |
diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c index 704716f6f6d3..9878c0fb3859 100644 --- a/drivers/usb/serial/keyspan.c +++ b/drivers/usb/serial/keyspan.c | |||
@@ -217,7 +217,8 @@ static int __init keyspan_init(void) | |||
217 | if (retval) | 217 | if (retval) |
218 | goto failed_usb_register; | 218 | goto failed_usb_register; |
219 | 219 | ||
220 | info(DRIVER_VERSION ":" DRIVER_DESC); | 220 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
221 | DRIVER_DESC "\n"); | ||
221 | 222 | ||
222 | return 0; | 223 | return 0; |
223 | failed_usb_register: | 224 | failed_usb_register: |
@@ -430,7 +431,7 @@ static void usa26_indat_callback(struct urb *urb) | |||
430 | } | 431 | } |
431 | 432 | ||
432 | port = urb->context; | 433 | port = urb->context; |
433 | tty = port->port.tty; | 434 | tty = tty_port_tty_get(&port->port); |
434 | if (tty && urb->actual_length) { | 435 | if (tty && urb->actual_length) { |
435 | /* 0x80 bit is error flag */ | 436 | /* 0x80 bit is error flag */ |
436 | if ((data[0] & 0x80) == 0) { | 437 | if ((data[0] & 0x80) == 0) { |
@@ -459,6 +460,7 @@ static void usa26_indat_callback(struct urb *urb) | |||
459 | } | 460 | } |
460 | tty_flip_buffer_push(tty); | 461 | tty_flip_buffer_push(tty); |
461 | } | 462 | } |
463 | tty_kref_put(tty); | ||
462 | 464 | ||
463 | /* Resubmit urb so we continue receiving */ | 465 | /* Resubmit urb so we continue receiving */ |
464 | urb->dev = port->serial->dev; | 466 | urb->dev = port->serial->dev; |
@@ -513,6 +515,7 @@ static void usa26_instat_callback(struct urb *urb) | |||
513 | struct usb_serial *serial; | 515 | struct usb_serial *serial; |
514 | struct usb_serial_port *port; | 516 | struct usb_serial_port *port; |
515 | struct keyspan_port_private *p_priv; | 517 | struct keyspan_port_private *p_priv; |
518 | struct tty_struct *tty; | ||
516 | int old_dcd_state, err; | 519 | int old_dcd_state, err; |
517 | int status = urb->status; | 520 | int status = urb->status; |
518 | 521 | ||
@@ -553,12 +556,11 @@ static void usa26_instat_callback(struct urb *urb) | |||
553 | p_priv->dcd_state = ((msg->gpia_dcd) ? 1 : 0); | 556 | p_priv->dcd_state = ((msg->gpia_dcd) ? 1 : 0); |
554 | p_priv->ri_state = ((msg->ri) ? 1 : 0); | 557 | p_priv->ri_state = ((msg->ri) ? 1 : 0); |
555 | 558 | ||
556 | if (port->port.tty && !C_CLOCAL(port->port.tty) | 559 | if (old_dcd_state != p_priv->dcd_state) { |
557 | && old_dcd_state != p_priv->dcd_state) { | 560 | tty = tty_port_tty_get(&port->port); |
558 | if (old_dcd_state) | 561 | if (tty && !C_CLOCAL(tty)) |
559 | tty_hangup(port->port.tty); | 562 | tty_hangup(tty); |
560 | /* else */ | 563 | tty_kref_put(tty); |
561 | /* wake_up_interruptible(&p_priv->open_wait); */ | ||
562 | } | 564 | } |
563 | 565 | ||
564 | /* Resubmit urb so we continue receiving */ | 566 | /* Resubmit urb so we continue receiving */ |
@@ -604,11 +606,12 @@ static void usa28_indat_callback(struct urb *urb) | |||
604 | p_priv = usb_get_serial_port_data(port); | 606 | p_priv = usb_get_serial_port_data(port); |
605 | data = urb->transfer_buffer; | 607 | data = urb->transfer_buffer; |
606 | 608 | ||
607 | tty = port->port.tty; | 609 | tty =tty_port_tty_get(&port->port); |
608 | if (urb->actual_length) { | 610 | if (tty && urb->actual_length) { |
609 | tty_insert_flip_string(tty, data, urb->actual_length); | 611 | tty_insert_flip_string(tty, data, urb->actual_length); |
610 | tty_flip_buffer_push(tty); | 612 | tty_flip_buffer_push(tty); |
611 | } | 613 | } |
614 | tty_kref_put(tty); | ||
612 | 615 | ||
613 | /* Resubmit urb so we continue receiving */ | 616 | /* Resubmit urb so we continue receiving */ |
614 | urb->dev = port->serial->dev; | 617 | urb->dev = port->serial->dev; |
@@ -652,6 +655,7 @@ static void usa28_instat_callback(struct urb *urb) | |||
652 | struct usb_serial *serial; | 655 | struct usb_serial *serial; |
653 | struct usb_serial_port *port; | 656 | struct usb_serial_port *port; |
654 | struct keyspan_port_private *p_priv; | 657 | struct keyspan_port_private *p_priv; |
658 | struct tty_struct *tty; | ||
655 | int old_dcd_state; | 659 | int old_dcd_state; |
656 | int status = urb->status; | 660 | int status = urb->status; |
657 | 661 | ||
@@ -689,12 +693,11 @@ static void usa28_instat_callback(struct urb *urb) | |||
689 | p_priv->dcd_state = ((msg->dcd) ? 1 : 0); | 693 | p_priv->dcd_state = ((msg->dcd) ? 1 : 0); |
690 | p_priv->ri_state = ((msg->ri) ? 1 : 0); | 694 | p_priv->ri_state = ((msg->ri) ? 1 : 0); |
691 | 695 | ||
692 | if (port->port.tty && !C_CLOCAL(port->port.tty) | 696 | if( old_dcd_state != p_priv->dcd_state && old_dcd_state) { |
693 | && old_dcd_state != p_priv->dcd_state) { | 697 | tty = tty_port_tty_get(&port->port); |
694 | if (old_dcd_state) | 698 | if (tty && !C_CLOCAL(tty)) |
695 | tty_hangup(port->port.tty); | 699 | tty_hangup(tty); |
696 | /* else */ | 700 | tty_kref_put(tty); |
697 | /* wake_up_interruptible(&p_priv->open_wait); */ | ||
698 | } | 701 | } |
699 | 702 | ||
700 | /* Resubmit urb so we continue receiving */ | 703 | /* Resubmit urb so we continue receiving */ |
@@ -785,12 +788,11 @@ static void usa49_instat_callback(struct urb *urb) | |||
785 | p_priv->dcd_state = ((msg->dcd) ? 1 : 0); | 788 | p_priv->dcd_state = ((msg->dcd) ? 1 : 0); |
786 | p_priv->ri_state = ((msg->ri) ? 1 : 0); | 789 | p_priv->ri_state = ((msg->ri) ? 1 : 0); |
787 | 790 | ||
788 | if (port->port.tty && !C_CLOCAL(port->port.tty) | 791 | if (old_dcd_state != p_priv->dcd_state && old_dcd_state) { |
789 | && old_dcd_state != p_priv->dcd_state) { | 792 | struct tty_struct *tty = tty_port_tty_get(&port->port); |
790 | if (old_dcd_state) | 793 | if (tty && !C_CLOCAL(tty)) |
791 | tty_hangup(port->port.tty); | 794 | tty_hangup(tty); |
792 | /* else */ | 795 | tty_kref_put(tty); |
793 | /* wake_up_interruptible(&p_priv->open_wait); */ | ||
794 | } | 796 | } |
795 | 797 | ||
796 | /* Resubmit urb so we continue receiving */ | 798 | /* Resubmit urb so we continue receiving */ |
@@ -827,7 +829,7 @@ static void usa49_indat_callback(struct urb *urb) | |||
827 | } | 829 | } |
828 | 830 | ||
829 | port = urb->context; | 831 | port = urb->context; |
830 | tty = port->port.tty; | 832 | tty = tty_port_tty_get(&port->port); |
831 | if (tty && urb->actual_length) { | 833 | if (tty && urb->actual_length) { |
832 | /* 0x80 bit is error flag */ | 834 | /* 0x80 bit is error flag */ |
833 | if ((data[0] & 0x80) == 0) { | 835 | if ((data[0] & 0x80) == 0) { |
@@ -850,6 +852,7 @@ static void usa49_indat_callback(struct urb *urb) | |||
850 | } | 852 | } |
851 | tty_flip_buffer_push(tty); | 853 | tty_flip_buffer_push(tty); |
852 | } | 854 | } |
855 | tty_kref_put(tty); | ||
853 | 856 | ||
854 | /* Resubmit urb so we continue receiving */ | 857 | /* Resubmit urb so we continue receiving */ |
855 | urb->dev = port->serial->dev; | 858 | urb->dev = port->serial->dev; |
@@ -893,7 +896,7 @@ static void usa49wg_indat_callback(struct urb *urb) | |||
893 | return; | 896 | return; |
894 | } | 897 | } |
895 | port = serial->port[data[i++]]; | 898 | port = serial->port[data[i++]]; |
896 | tty = port->port.tty; | 899 | tty = tty_port_tty_get(&port->port); |
897 | len = data[i++]; | 900 | len = data[i++]; |
898 | 901 | ||
899 | /* 0x80 bit is error flag */ | 902 | /* 0x80 bit is error flag */ |
@@ -927,6 +930,7 @@ static void usa49wg_indat_callback(struct urb *urb) | |||
927 | } | 930 | } |
928 | if (port->port.count) | 931 | if (port->port.count) |
929 | tty_flip_buffer_push(tty); | 932 | tty_flip_buffer_push(tty); |
933 | tty_kref_put(tty); | ||
930 | } | 934 | } |
931 | } | 935 | } |
932 | 936 | ||
@@ -967,8 +971,8 @@ static void usa90_indat_callback(struct urb *urb) | |||
967 | port = urb->context; | 971 | port = urb->context; |
968 | p_priv = usb_get_serial_port_data(port); | 972 | p_priv = usb_get_serial_port_data(port); |
969 | 973 | ||
970 | tty = port->port.tty; | ||
971 | if (urb->actual_length) { | 974 | if (urb->actual_length) { |
975 | tty = tty_port_tty_get(&port->port); | ||
972 | /* if current mode is DMA, looks like usa28 format | 976 | /* if current mode is DMA, looks like usa28 format |
973 | otherwise looks like usa26 data format */ | 977 | otherwise looks like usa26 data format */ |
974 | 978 | ||
@@ -1004,6 +1008,7 @@ static void usa90_indat_callback(struct urb *urb) | |||
1004 | } | 1008 | } |
1005 | } | 1009 | } |
1006 | tty_flip_buffer_push(tty); | 1010 | tty_flip_buffer_push(tty); |
1011 | tty_kref_put(tty); | ||
1007 | } | 1012 | } |
1008 | 1013 | ||
1009 | /* Resubmit urb so we continue receiving */ | 1014 | /* Resubmit urb so we continue receiving */ |
@@ -1025,6 +1030,7 @@ static void usa90_instat_callback(struct urb *urb) | |||
1025 | struct usb_serial *serial; | 1030 | struct usb_serial *serial; |
1026 | struct usb_serial_port *port; | 1031 | struct usb_serial_port *port; |
1027 | struct keyspan_port_private *p_priv; | 1032 | struct keyspan_port_private *p_priv; |
1033 | struct tty_struct *tty; | ||
1028 | int old_dcd_state, err; | 1034 | int old_dcd_state, err; |
1029 | int status = urb->status; | 1035 | int status = urb->status; |
1030 | 1036 | ||
@@ -1053,12 +1059,11 @@ static void usa90_instat_callback(struct urb *urb) | |||
1053 | p_priv->dcd_state = ((msg->dcd) ? 1 : 0); | 1059 | p_priv->dcd_state = ((msg->dcd) ? 1 : 0); |
1054 | p_priv->ri_state = ((msg->ri) ? 1 : 0); | 1060 | p_priv->ri_state = ((msg->ri) ? 1 : 0); |
1055 | 1061 | ||
1056 | if (port->port.tty && !C_CLOCAL(port->port.tty) | 1062 | if (old_dcd_state != p_priv->dcd_state && old_dcd_state) { |
1057 | && old_dcd_state != p_priv->dcd_state) { | 1063 | tty = tty_port_tty_get(&port->port); |
1058 | if (old_dcd_state) | 1064 | if (tty && !C_CLOCAL(tty)) |
1059 | tty_hangup(port->port.tty); | 1065 | tty_hangup(tty); |
1060 | /* else */ | 1066 | tty_kref_put(tty); |
1061 | /* wake_up_interruptible(&p_priv->open_wait); */ | ||
1062 | } | 1067 | } |
1063 | 1068 | ||
1064 | /* Resubmit urb so we continue receiving */ | 1069 | /* Resubmit urb so we continue receiving */ |
@@ -1130,12 +1135,11 @@ static void usa67_instat_callback(struct urb *urb) | |||
1130 | p_priv->cts_state = ((msg->hskia_cts) ? 1 : 0); | 1135 | p_priv->cts_state = ((msg->hskia_cts) ? 1 : 0); |
1131 | p_priv->dcd_state = ((msg->gpia_dcd) ? 1 : 0); | 1136 | p_priv->dcd_state = ((msg->gpia_dcd) ? 1 : 0); |
1132 | 1137 | ||
1133 | if (port->port.tty && !C_CLOCAL(port->port.tty) | 1138 | if (old_dcd_state != p_priv->dcd_state && old_dcd_state) { |
1134 | && old_dcd_state != p_priv->dcd_state) { | 1139 | struct tty_struct *tty = tty_port_tty_get(&port->port); |
1135 | if (old_dcd_state) | 1140 | if (tty && !C_CLOCAL(tty)) |
1136 | tty_hangup(port->port.tty); | 1141 | tty_hangup(tty); |
1137 | /* else */ | 1142 | tty_kref_put(tty); |
1138 | /* wake_up_interruptible(&p_priv->open_wait); */ | ||
1139 | } | 1143 | } |
1140 | 1144 | ||
1141 | /* Resubmit urb so we continue receiving */ | 1145 | /* Resubmit urb so we continue receiving */ |
@@ -1332,7 +1336,7 @@ static void keyspan_close(struct tty_struct *tty, | |||
1332 | stop_urb(p_priv->out_urbs[i]); | 1336 | stop_urb(p_priv->out_urbs[i]); |
1333 | } | 1337 | } |
1334 | } | 1338 | } |
1335 | port->port.tty = NULL; | 1339 | tty_port_tty_set(&port->port, NULL); |
1336 | } | 1340 | } |
1337 | 1341 | ||
1338 | /* download the firmware to a pre-renumeration device */ | 1342 | /* download the firmware to a pre-renumeration device */ |
diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c index 040040a267d9..bf1ae247da66 100644 --- a/drivers/usb/serial/keyspan_pda.c +++ b/drivers/usb/serial/keyspan_pda.c | |||
@@ -172,8 +172,9 @@ static void keyspan_pda_wakeup_write(struct work_struct *work) | |||
172 | struct keyspan_pda_private *priv = | 172 | struct keyspan_pda_private *priv = |
173 | container_of(work, struct keyspan_pda_private, wakeup_work); | 173 | container_of(work, struct keyspan_pda_private, wakeup_work); |
174 | struct usb_serial_port *port = priv->port; | 174 | struct usb_serial_port *port = priv->port; |
175 | 175 | struct tty_struct *tty = tty_port_tty_get(&port->port); | |
176 | tty_wakeup(port->port.tty); | 176 | tty_wakeup(tty); |
177 | tty_kref_put(tty); | ||
177 | } | 178 | } |
178 | 179 | ||
179 | static void keyspan_pda_request_unthrottle(struct work_struct *work) | 180 | static void keyspan_pda_request_unthrottle(struct work_struct *work) |
@@ -205,7 +206,7 @@ static void keyspan_pda_request_unthrottle(struct work_struct *work) | |||
205 | static void keyspan_pda_rx_interrupt(struct urb *urb) | 206 | static void keyspan_pda_rx_interrupt(struct urb *urb) |
206 | { | 207 | { |
207 | struct usb_serial_port *port = urb->context; | 208 | struct usb_serial_port *port = urb->context; |
208 | struct tty_struct *tty = port->port.tty; | 209 | struct tty_struct *tty = tty_port_tty_get(&port->port); |
209 | unsigned char *data = urb->transfer_buffer; | 210 | unsigned char *data = urb->transfer_buffer; |
210 | int retval; | 211 | int retval; |
211 | int status = urb->status; | 212 | int status = urb->status; |
@@ -222,7 +223,7 @@ static void keyspan_pda_rx_interrupt(struct urb *urb) | |||
222 | /* this urb is terminated, clean up */ | 223 | /* this urb is terminated, clean up */ |
223 | dbg("%s - urb shutting down with status: %d", | 224 | dbg("%s - urb shutting down with status: %d", |
224 | __func__, status); | 225 | __func__, status); |
225 | return; | 226 | goto out; |
226 | default: | 227 | default: |
227 | dbg("%s - nonzero urb status received: %d", | 228 | dbg("%s - nonzero urb status received: %d", |
228 | __func__, status); | 229 | __func__, status); |
@@ -261,8 +262,11 @@ static void keyspan_pda_rx_interrupt(struct urb *urb) | |||
261 | exit: | 262 | exit: |
262 | retval = usb_submit_urb(urb, GFP_ATOMIC); | 263 | retval = usb_submit_urb(urb, GFP_ATOMIC); |
263 | if (retval) | 264 | if (retval) |
264 | err("%s - usb_submit_urb failed with result %d", | 265 | dev_err(&port->dev, |
265 | __func__, retval); | 266 | "%s - usb_submit_urb failed with result %d", |
267 | __func__, retval); | ||
268 | out: | ||
269 | tty_kref_put(tty); | ||
266 | } | 270 | } |
267 | 271 | ||
268 | 272 | ||
@@ -738,11 +742,13 @@ static int keyspan_pda_fake_startup(struct usb_serial *serial) | |||
738 | fw_name = "keyspan_pda/xircom_pgs.fw"; | 742 | fw_name = "keyspan_pda/xircom_pgs.fw"; |
739 | #endif | 743 | #endif |
740 | else { | 744 | else { |
741 | err("%s: unknown vendor, aborting.", __func__); | 745 | dev_err(&serial->dev->dev, "%s: unknown vendor, aborting.\n", |
746 | __func__); | ||
742 | return -ENODEV; | 747 | return -ENODEV; |
743 | } | 748 | } |
744 | if (request_ihex_firmware(&fw, fw_name, &serial->dev->dev)) { | 749 | if (request_ihex_firmware(&fw, fw_name, &serial->dev->dev)) { |
745 | err("failed to load firmware \"%s\"\n", fw_name); | 750 | dev_err(&serial->dev->dev, "failed to load firmware \"%s\"\n", |
751 | fw_name); | ||
746 | return -ENOENT; | 752 | return -ENOENT; |
747 | } | 753 | } |
748 | record = (const struct ihex_binrec *)fw->data; | 754 | record = (const struct ihex_binrec *)fw->data; |
@@ -752,10 +758,10 @@ static int keyspan_pda_fake_startup(struct usb_serial *serial) | |||
752 | (unsigned char *)record->data, | 758 | (unsigned char *)record->data, |
753 | be16_to_cpu(record->len), 0xa0); | 759 | be16_to_cpu(record->len), 0xa0); |
754 | if (response < 0) { | 760 | if (response < 0) { |
755 | err("ezusb_writememory failed for Keyspan PDA " | 761 | dev_err(&serial->dev->dev, "ezusb_writememory failed " |
756 | "firmware (%d %04X %p %d)", | 762 | "for Keyspan PDA firmware (%d %04X %p %d)\n", |
757 | response, be32_to_cpu(record->addr), | 763 | response, be32_to_cpu(record->addr), |
758 | record->data, be16_to_cpu(record->len)); | 764 | record->data, be16_to_cpu(record->len)); |
759 | break; | 765 | break; |
760 | } | 766 | } |
761 | record = ihex_next_binrec(record); | 767 | record = ihex_next_binrec(record); |
@@ -870,7 +876,8 @@ static int __init keyspan_pda_init(void) | |||
870 | retval = usb_register(&keyspan_pda_driver); | 876 | retval = usb_register(&keyspan_pda_driver); |
871 | if (retval) | 877 | if (retval) |
872 | goto failed_usb_register; | 878 | goto failed_usb_register; |
873 | info(DRIVER_DESC " " DRIVER_VERSION); | 879 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
880 | DRIVER_DESC "\n"); | ||
874 | return 0; | 881 | return 0; |
875 | failed_usb_register: | 882 | failed_usb_register: |
876 | #ifdef XIRCOM | 883 | #ifdef XIRCOM |
diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c index b84dddc71124..dc36a052766f 100644 --- a/drivers/usb/serial/kl5kusb105.c +++ b/drivers/usb/serial/kl5kusb105.c | |||
@@ -182,12 +182,12 @@ static int klsi_105_chg_port_settings(struct usb_serial_port *port, | |||
182 | sizeof(struct klsi_105_port_settings), | 182 | sizeof(struct klsi_105_port_settings), |
183 | KLSI_TIMEOUT); | 183 | KLSI_TIMEOUT); |
184 | if (rc < 0) | 184 | if (rc < 0) |
185 | err("Change port settings failed (error = %d)", rc); | 185 | dev_err(&port->dev, |
186 | info("%s - %d byte block, baudrate %x, databits %d, u1 %d, u2 %d", | 186 | "Change port settings failed (error = %d)\n", rc); |
187 | __func__, | 187 | dev_info(&port->serial->dev->dev, |
188 | settings->pktlen, | 188 | "%d byte block, baudrate %x, databits %d, u1 %d, u2 %d\n", |
189 | settings->baudrate, settings->databits, | 189 | settings->pktlen, settings->baudrate, settings->databits, |
190 | settings->unknown1, settings->unknown2); | 190 | settings->unknown1, settings->unknown2); |
191 | return rc; | 191 | return rc; |
192 | } /* klsi_105_chg_port_settings */ | 192 | } /* klsi_105_chg_port_settings */ |
193 | 193 | ||
@@ -215,7 +215,7 @@ static int klsi_105_get_line_state(struct usb_serial_port *port, | |||
215 | __u8 status_buf[KLSI_STATUSBUF_LEN] = { -1, -1}; | 215 | __u8 status_buf[KLSI_STATUSBUF_LEN] = { -1, -1}; |
216 | __u16 status; | 216 | __u16 status; |
217 | 217 | ||
218 | info("%s - sending SIO Poll request", __func__); | 218 | dev_info(&port->serial->dev->dev, "sending SIO Poll request\n"); |
219 | rc = usb_control_msg(port->serial->dev, | 219 | rc = usb_control_msg(port->serial->dev, |
220 | usb_rcvctrlpipe(port->serial->dev, 0), | 220 | usb_rcvctrlpipe(port->serial->dev, 0), |
221 | KL5KUSB105A_SIO_POLL, | 221 | KL5KUSB105A_SIO_POLL, |
@@ -226,12 +226,13 @@ static int klsi_105_get_line_state(struct usb_serial_port *port, | |||
226 | 10000 | 226 | 10000 |
227 | ); | 227 | ); |
228 | if (rc < 0) | 228 | if (rc < 0) |
229 | err("Reading line status failed (error = %d)", rc); | 229 | dev_err(&port->dev, "Reading line status failed (error = %d)\n", |
230 | rc); | ||
230 | else { | 231 | else { |
231 | status = get_unaligned_le16(status_buf); | 232 | status = get_unaligned_le16(status_buf); |
232 | 233 | ||
233 | info("%s - read status %x %x", __func__, | 234 | dev_info(&port->serial->dev->dev, "read status %x %x", |
234 | status_buf[0], status_buf[1]); | 235 | status_buf[0], status_buf[1]); |
235 | 236 | ||
236 | *line_state_p = klsi_105_status2linestate(status); | 237 | *line_state_p = klsi_105_status2linestate(status); |
237 | } | 238 | } |
@@ -280,15 +281,16 @@ static int klsi_105_startup(struct usb_serial *serial) | |||
280 | 281 | ||
281 | priv->write_urb_pool[j] = urb; | 282 | priv->write_urb_pool[j] = urb; |
282 | if (urb == NULL) { | 283 | if (urb == NULL) { |
283 | err("No more urbs???"); | 284 | dev_err(&serial->dev->dev, "No more urbs???\n"); |
284 | goto err_cleanup; | 285 | goto err_cleanup; |
285 | } | 286 | } |
286 | 287 | ||
287 | urb->transfer_buffer = | 288 | urb->transfer_buffer = |
288 | kmalloc(URB_TRANSFER_BUFFER_SIZE, GFP_KERNEL); | 289 | kmalloc(URB_TRANSFER_BUFFER_SIZE, GFP_KERNEL); |
289 | if (!urb->transfer_buffer) { | 290 | if (!urb->transfer_buffer) { |
290 | err("%s - out of memory for urb buffers.", | 291 | dev_err(&serial->dev->dev, |
291 | __func__); | 292 | "%s - out of memory for urb buffers.\n", |
293 | __func__); | ||
292 | goto err_cleanup; | 294 | goto err_cleanup; |
293 | } | 295 | } |
294 | } | 296 | } |
@@ -409,7 +411,8 @@ static int klsi_105_open(struct tty_struct *tty, | |||
409 | 411 | ||
410 | rc = usb_submit_urb(port->read_urb, GFP_KERNEL); | 412 | rc = usb_submit_urb(port->read_urb, GFP_KERNEL); |
411 | if (rc) { | 413 | if (rc) { |
412 | err("%s - failed submitting read urb, error %d", __func__, rc); | 414 | dev_err(&port->dev, "%s - failed submitting read urb, " |
415 | "error %d\n", __func__, rc); | ||
413 | retval = rc; | 416 | retval = rc; |
414 | goto exit; | 417 | goto exit; |
415 | } | 418 | } |
@@ -424,7 +427,7 @@ static int klsi_105_open(struct tty_struct *tty, | |||
424 | 0, | 427 | 0, |
425 | KLSI_TIMEOUT); | 428 | KLSI_TIMEOUT); |
426 | if (rc < 0) { | 429 | if (rc < 0) { |
427 | err("Enabling read failed (error = %d)", rc); | 430 | dev_err(&port->dev, "Enabling read failed (error = %d)\n", rc); |
428 | retval = rc; | 431 | retval = rc; |
429 | } else | 432 | } else |
430 | dbg("%s - enabled reading", __func__); | 433 | dbg("%s - enabled reading", __func__); |
@@ -464,7 +467,8 @@ static void klsi_105_close(struct tty_struct *tty, | |||
464 | NULL, 0, | 467 | NULL, 0, |
465 | KLSI_TIMEOUT); | 468 | KLSI_TIMEOUT); |
466 | if (rc < 0) | 469 | if (rc < 0) |
467 | err("Disabling read failed (error = %d)", rc); | 470 | dev_err(&port->dev, |
471 | "Disabling read failed (error = %d)\n", rc); | ||
468 | } | 472 | } |
469 | mutex_unlock(&port->serial->disc_mutex); | 473 | mutex_unlock(&port->serial->disc_mutex); |
470 | 474 | ||
@@ -475,8 +479,9 @@ static void klsi_105_close(struct tty_struct *tty, | |||
475 | /* FIXME */ | 479 | /* FIXME */ |
476 | /* wgg - do I need this? I think so. */ | 480 | /* wgg - do I need this? I think so. */ |
477 | usb_kill_urb(port->interrupt_in_urb); | 481 | usb_kill_urb(port->interrupt_in_urb); |
478 | info("kl5kusb105 port stats: %ld bytes in, %ld bytes out", | 482 | dev_info(&port->serial->dev->dev, |
479 | priv->bytes_in, priv->bytes_out); | 483 | "port stats: %ld bytes in, %ld bytes out\n", |
484 | priv->bytes_in, priv->bytes_out); | ||
480 | } /* klsi_105_close */ | 485 | } /* klsi_105_close */ |
481 | 486 | ||
482 | 487 | ||
@@ -522,7 +527,9 @@ static int klsi_105_write(struct tty_struct *tty, | |||
522 | urb->transfer_buffer = | 527 | urb->transfer_buffer = |
523 | kmalloc(URB_TRANSFER_BUFFER_SIZE, GFP_ATOMIC); | 528 | kmalloc(URB_TRANSFER_BUFFER_SIZE, GFP_ATOMIC); |
524 | if (urb->transfer_buffer == NULL) { | 529 | if (urb->transfer_buffer == NULL) { |
525 | err("%s - no more kernel memory...", __func__); | 530 | dev_err(&port->dev, |
531 | "%s - no more kernel memory...\n", | ||
532 | __func__); | ||
526 | goto exit; | 533 | goto exit; |
527 | } | 534 | } |
528 | } | 535 | } |
@@ -549,8 +556,9 @@ static int klsi_105_write(struct tty_struct *tty, | |||
549 | /* send the data out the bulk port */ | 556 | /* send the data out the bulk port */ |
550 | result = usb_submit_urb(urb, GFP_ATOMIC); | 557 | result = usb_submit_urb(urb, GFP_ATOMIC); |
551 | if (result) { | 558 | if (result) { |
552 | err("%s - failed submitting write urb, error %d", | 559 | dev_err(&port->dev, |
553 | __func__, result); | 560 | "%s - failed submitting write urb, error %d\n", |
561 | __func__, result); | ||
554 | goto exit; | 562 | goto exit; |
555 | } | 563 | } |
556 | buf += size; | 564 | buf += size; |
@@ -658,7 +666,7 @@ static void klsi_105_read_bulk_callback(struct urb *urb) | |||
658 | } else { | 666 | } else { |
659 | int bytes_sent = ((__u8 *) data)[0] + | 667 | int bytes_sent = ((__u8 *) data)[0] + |
660 | ((unsigned int) ((__u8 *) data)[1] << 8); | 668 | ((unsigned int) ((__u8 *) data)[1] << 8); |
661 | tty = port->port.tty; | 669 | tty = tty_port_tty_get(&port->port); |
662 | /* we should immediately resubmit the URB, before attempting | 670 | /* we should immediately resubmit the URB, before attempting |
663 | * to pass the data on to the tty layer. But that needs locking | 671 | * to pass the data on to the tty layer. But that needs locking |
664 | * against re-entry an then mixed-up data because of | 672 | * against re-entry an then mixed-up data because of |
@@ -679,6 +687,7 @@ static void klsi_105_read_bulk_callback(struct urb *urb) | |||
679 | tty_buffer_request_room(tty, bytes_sent); | 687 | tty_buffer_request_room(tty, bytes_sent); |
680 | tty_insert_flip_string(tty, data + 2, bytes_sent); | 688 | tty_insert_flip_string(tty, data + 2, bytes_sent); |
681 | tty_flip_buffer_push(tty); | 689 | tty_flip_buffer_push(tty); |
690 | tty_kref_put(tty); | ||
682 | 691 | ||
683 | /* again lockless, but debug info only */ | 692 | /* again lockless, but debug info only */ |
684 | priv->bytes_in += bytes_sent; | 693 | priv->bytes_in += bytes_sent; |
@@ -693,8 +702,9 @@ static void klsi_105_read_bulk_callback(struct urb *urb) | |||
693 | port); | 702 | port); |
694 | rc = usb_submit_urb(port->read_urb, GFP_ATOMIC); | 703 | rc = usb_submit_urb(port->read_urb, GFP_ATOMIC); |
695 | if (rc) | 704 | if (rc) |
696 | err("%s - failed resubmitting read urb, error %d", | 705 | dev_err(&port->dev, |
697 | __func__, rc); | 706 | "%s - failed resubmitting read urb, error %d\n", |
707 | __func__, rc); | ||
698 | } /* klsi_105_read_bulk_callback */ | 708 | } /* klsi_105_read_bulk_callback */ |
699 | 709 | ||
700 | 710 | ||
@@ -798,7 +808,8 @@ static void klsi_105_set_termios(struct tty_struct *tty, | |||
798 | priv->cfg.databits = kl5kusb105a_dtb_8; | 808 | priv->cfg.databits = kl5kusb105a_dtb_8; |
799 | break; | 809 | break; |
800 | default: | 810 | default: |
801 | err("CSIZE was not CS5-CS8, using default of 8"); | 811 | dev_err(&port->dev, |
812 | "CSIZE was not CS5-CS8, using default of 8\n"); | ||
802 | priv->cfg.databits = kl5kusb105a_dtb_8; | 813 | priv->cfg.databits = kl5kusb105a_dtb_8; |
803 | break; | 814 | break; |
804 | } | 815 | } |
@@ -885,7 +896,8 @@ static int klsi_105_tiocmget(struct tty_struct *tty, struct file *file) | |||
885 | 896 | ||
886 | rc = klsi_105_get_line_state(port, &line_state); | 897 | rc = klsi_105_get_line_state(port, &line_state); |
887 | if (rc < 0) { | 898 | if (rc < 0) { |
888 | err("Reading line control failed (error = %d)", rc); | 899 | dev_err(&port->dev, |
900 | "Reading line control failed (error = %d)\n", rc); | ||
889 | /* better return value? EAGAIN? */ | 901 | /* better return value? EAGAIN? */ |
890 | return rc; | 902 | return rc; |
891 | } | 903 | } |
@@ -943,8 +955,9 @@ static void klsi_105_unthrottle(struct tty_struct *tty) | |||
943 | port->read_urb->dev = port->serial->dev; | 955 | port->read_urb->dev = port->serial->dev; |
944 | result = usb_submit_urb(port->read_urb, GFP_ATOMIC); | 956 | result = usb_submit_urb(port->read_urb, GFP_ATOMIC); |
945 | if (result) | 957 | if (result) |
946 | err("%s - failed submitting read urb, error %d", __func__, | 958 | dev_err(&port->dev, |
947 | result); | 959 | "%s - failed submitting read urb, error %d\n", |
960 | __func__, result); | ||
948 | } | 961 | } |
949 | 962 | ||
950 | 963 | ||
@@ -959,7 +972,8 @@ static int __init klsi_105_init(void) | |||
959 | if (retval) | 972 | if (retval) |
960 | goto failed_usb_register; | 973 | goto failed_usb_register; |
961 | 974 | ||
962 | info(DRIVER_DESC " " DRIVER_VERSION); | 975 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
976 | DRIVER_DESC "\n"); | ||
963 | return 0; | 977 | return 0; |
964 | failed_usb_register: | 978 | failed_usb_register: |
965 | usb_serial_deregister(&kl5kusb105d_device); | 979 | usb_serial_deregister(&kl5kusb105d_device); |
diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c index deba28ec77e8..6286baad9392 100644 --- a/drivers/usb/serial/kobil_sct.c +++ b/drivers/usb/serial/kobil_sct.c | |||
@@ -383,7 +383,7 @@ static void kobil_read_int_callback(struct urb *urb) | |||
383 | return; | 383 | return; |
384 | } | 384 | } |
385 | 385 | ||
386 | tty = port->port.tty; | 386 | tty = tty_port_tty_get(&port->port); |
387 | if (urb->actual_length) { | 387 | if (urb->actual_length) { |
388 | 388 | ||
389 | /* BEGIN DEBUG */ | 389 | /* BEGIN DEBUG */ |
@@ -405,6 +405,7 @@ static void kobil_read_int_callback(struct urb *urb) | |||
405 | tty_insert_flip_string(tty, data, urb->actual_length); | 405 | tty_insert_flip_string(tty, data, urb->actual_length); |
406 | tty_flip_buffer_push(tty); | 406 | tty_flip_buffer_push(tty); |
407 | } | 407 | } |
408 | tty_kref_put(tty); | ||
408 | /* someone sets the dev to 0 if the close method has been called */ | 409 | /* someone sets the dev to 0 if the close method has been called */ |
409 | port->interrupt_in_urb->dev = port->serial->dev; | 410 | port->interrupt_in_urb->dev = port->serial->dev; |
410 | 411 | ||
@@ -743,8 +744,8 @@ static int __init kobil_init(void) | |||
743 | if (retval) | 744 | if (retval) |
744 | goto failed_usb_register; | 745 | goto failed_usb_register; |
745 | 746 | ||
746 | info(DRIVER_VERSION " " DRIVER_AUTHOR); | 747 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
747 | info(DRIVER_DESC); | 748 | DRIVER_DESC "\n"); |
748 | 749 | ||
749 | return 0; | 750 | return 0; |
750 | failed_usb_register: | 751 | failed_usb_register: |
diff --git a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c index 0ded8bd6ec85..07710cf31d0d 100644 --- a/drivers/usb/serial/mct_u232.c +++ b/drivers/usb/serial/mct_u232.c | |||
@@ -246,7 +246,8 @@ static int mct_u232_set_baud_rate(struct tty_struct *tty, | |||
246 | 0, 0, &divisor, MCT_U232_SET_BAUD_RATE_SIZE, | 246 | 0, 0, &divisor, MCT_U232_SET_BAUD_RATE_SIZE, |
247 | WDR_TIMEOUT); | 247 | WDR_TIMEOUT); |
248 | if (rc < 0) /*FIXME: What value speed results */ | 248 | if (rc < 0) /*FIXME: What value speed results */ |
249 | err("Set BAUD RATE %d failed (error = %d)", value, rc); | 249 | dev_err(&port->dev, "Set BAUD RATE %d failed (error = %d)\n", |
250 | value, rc); | ||
250 | else | 251 | else |
251 | tty_encode_baud_rate(tty, speed, speed); | 252 | tty_encode_baud_rate(tty, speed, speed); |
252 | dbg("set_baud_rate: value: 0x%x, divisor: 0x%x", value, divisor); | 253 | dbg("set_baud_rate: value: 0x%x, divisor: 0x%x", value, divisor); |
@@ -274,8 +275,9 @@ static int mct_u232_set_baud_rate(struct tty_struct *tty, | |||
274 | 0, 0, &zero_byte, MCT_U232_SET_UNKNOWN1_SIZE, | 275 | 0, 0, &zero_byte, MCT_U232_SET_UNKNOWN1_SIZE, |
275 | WDR_TIMEOUT); | 276 | WDR_TIMEOUT); |
276 | if (rc < 0) | 277 | if (rc < 0) |
277 | err("Sending USB device request code %d failed (error = %d)", | 278 | dev_err(&port->dev, "Sending USB device request code %d " |
278 | MCT_U232_SET_UNKNOWN1_REQUEST, rc); | 279 | "failed (error = %d)\n", MCT_U232_SET_UNKNOWN1_REQUEST, |
280 | rc); | ||
279 | 281 | ||
280 | if (port && C_CRTSCTS(tty)) | 282 | if (port && C_CRTSCTS(tty)) |
281 | cts_enable_byte = 1; | 283 | cts_enable_byte = 1; |
@@ -288,8 +290,8 @@ static int mct_u232_set_baud_rate(struct tty_struct *tty, | |||
288 | 0, 0, &cts_enable_byte, MCT_U232_SET_CTS_SIZE, | 290 | 0, 0, &cts_enable_byte, MCT_U232_SET_CTS_SIZE, |
289 | WDR_TIMEOUT); | 291 | WDR_TIMEOUT); |
290 | if (rc < 0) | 292 | if (rc < 0) |
291 | err("Sending USB device request code %d failed (error = %d)", | 293 | dev_err(&port->dev, "Sending USB device request code %d " |
292 | MCT_U232_SET_CTS_REQUEST, rc); | 294 | "failed (error = %d)\n", MCT_U232_SET_CTS_REQUEST, rc); |
293 | 295 | ||
294 | return rc; | 296 | return rc; |
295 | } /* mct_u232_set_baud_rate */ | 297 | } /* mct_u232_set_baud_rate */ |
@@ -303,7 +305,8 @@ static int mct_u232_set_line_ctrl(struct usb_serial *serial, unsigned char lcr) | |||
303 | 0, 0, &lcr, MCT_U232_SET_LINE_CTRL_SIZE, | 305 | 0, 0, &lcr, MCT_U232_SET_LINE_CTRL_SIZE, |
304 | WDR_TIMEOUT); | 306 | WDR_TIMEOUT); |
305 | if (rc < 0) | 307 | if (rc < 0) |
306 | err("Set LINE CTRL 0x%x failed (error = %d)", lcr, rc); | 308 | dev_err(&serial->dev->dev, |
309 | "Set LINE CTRL 0x%x failed (error = %d)\n", lcr, rc); | ||
307 | dbg("set_line_ctrl: 0x%x", lcr); | 310 | dbg("set_line_ctrl: 0x%x", lcr); |
308 | return rc; | 311 | return rc; |
309 | } /* mct_u232_set_line_ctrl */ | 312 | } /* mct_u232_set_line_ctrl */ |
@@ -325,7 +328,8 @@ static int mct_u232_set_modem_ctrl(struct usb_serial *serial, | |||
325 | 0, 0, &mcr, MCT_U232_SET_MODEM_CTRL_SIZE, | 328 | 0, 0, &mcr, MCT_U232_SET_MODEM_CTRL_SIZE, |
326 | WDR_TIMEOUT); | 329 | WDR_TIMEOUT); |
327 | if (rc < 0) | 330 | if (rc < 0) |
328 | err("Set MODEM CTRL 0x%x failed (error = %d)", mcr, rc); | 331 | dev_err(&serial->dev->dev, |
332 | "Set MODEM CTRL 0x%x failed (error = %d)\n", mcr, rc); | ||
329 | dbg("set_modem_ctrl: state=0x%x ==> mcr=0x%x", control_state, mcr); | 333 | dbg("set_modem_ctrl: state=0x%x ==> mcr=0x%x", control_state, mcr); |
330 | 334 | ||
331 | return rc; | 335 | return rc; |
@@ -341,7 +345,8 @@ static int mct_u232_get_modem_stat(struct usb_serial *serial, | |||
341 | 0, 0, msr, MCT_U232_GET_MODEM_STAT_SIZE, | 345 | 0, 0, msr, MCT_U232_GET_MODEM_STAT_SIZE, |
342 | WDR_TIMEOUT); | 346 | WDR_TIMEOUT); |
343 | if (rc < 0) { | 347 | if (rc < 0) { |
344 | err("Get MODEM STATus failed (error = %d)", rc); | 348 | dev_err(&serial->dev->dev, |
349 | "Get MODEM STATus failed (error = %d)\n", rc); | ||
345 | *msr = 0; | 350 | *msr = 0; |
346 | } | 351 | } |
347 | dbg("get_modem_stat: 0x%x", *msr); | 352 | dbg("get_modem_stat: 0x%x", *msr); |
@@ -470,8 +475,9 @@ static int mct_u232_open(struct tty_struct *tty, | |||
470 | port->read_urb->dev = port->serial->dev; | 475 | port->read_urb->dev = port->serial->dev; |
471 | retval = usb_submit_urb(port->read_urb, GFP_KERNEL); | 476 | retval = usb_submit_urb(port->read_urb, GFP_KERNEL); |
472 | if (retval) { | 477 | if (retval) { |
473 | err("usb_submit_urb(read bulk) failed pipe 0x%x err %d", | 478 | dev_err(&port->dev, |
474 | port->read_urb->pipe, retval); | 479 | "usb_submit_urb(read bulk) failed pipe 0x%x err %d\n", |
480 | port->read_urb->pipe, retval); | ||
475 | goto error; | 481 | goto error; |
476 | } | 482 | } |
477 | 483 | ||
@@ -479,8 +485,9 @@ static int mct_u232_open(struct tty_struct *tty, | |||
479 | retval = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); | 485 | retval = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); |
480 | if (retval) { | 486 | if (retval) { |
481 | usb_kill_urb(port->read_urb); | 487 | usb_kill_urb(port->read_urb); |
482 | err(" usb_submit_urb(read int) failed pipe 0x%x err %d", | 488 | dev_err(&port->dev, |
483 | port->interrupt_in_urb->pipe, retval); | 489 | "usb_submit_urb(read int) failed pipe 0x%x err %d", |
490 | port->interrupt_in_urb->pipe, retval); | ||
484 | goto error; | 491 | goto error; |
485 | } | 492 | } |
486 | return 0; | 493 | return 0; |
@@ -563,10 +570,11 @@ static void mct_u232_read_int_callback(struct urb *urb) | |||
563 | * Work-a-round: handle the 'usual' bulk-in pipe here | 570 | * Work-a-round: handle the 'usual' bulk-in pipe here |
564 | */ | 571 | */ |
565 | if (urb->transfer_buffer_length > 2) { | 572 | if (urb->transfer_buffer_length > 2) { |
566 | tty = port->port.tty; | 573 | tty = tty_port_tty_get(&port->port); |
567 | if (urb->actual_length) { | 574 | if (urb->actual_length) { |
568 | tty_insert_flip_string(tty, data, urb->actual_length); | 575 | tty_insert_flip_string(tty, data, urb->actual_length); |
569 | tty_flip_buffer_push(tty); | 576 | tty_flip_buffer_push(tty); |
577 | tty_kref_put(tty); | ||
570 | } | 578 | } |
571 | goto exit; | 579 | goto exit; |
572 | } | 580 | } |
@@ -591,7 +599,7 @@ static void mct_u232_read_int_callback(struct urb *urb) | |||
591 | * to look in to this before committing any code. | 599 | * to look in to this before committing any code. |
592 | */ | 600 | */ |
593 | if (priv->last_lsr & MCT_U232_LSR_ERR) { | 601 | if (priv->last_lsr & MCT_U232_LSR_ERR) { |
594 | tty = port->port.tty; | 602 | tty = tty_port_tty_get(&port->port); |
595 | /* Overrun Error */ | 603 | /* Overrun Error */ |
596 | if (priv->last_lsr & MCT_U232_LSR_OE) { | 604 | if (priv->last_lsr & MCT_U232_LSR_OE) { |
597 | } | 605 | } |
@@ -604,14 +612,16 @@ static void mct_u232_read_int_callback(struct urb *urb) | |||
604 | /* Break Indicator */ | 612 | /* Break Indicator */ |
605 | if (priv->last_lsr & MCT_U232_LSR_BI) { | 613 | if (priv->last_lsr & MCT_U232_LSR_BI) { |
606 | } | 614 | } |
615 | tty_kref_put(tty); | ||
607 | } | 616 | } |
608 | #endif | 617 | #endif |
609 | spin_unlock_irqrestore(&priv->lock, flags); | 618 | spin_unlock_irqrestore(&priv->lock, flags); |
610 | exit: | 619 | exit: |
611 | retval = usb_submit_urb(urb, GFP_ATOMIC); | 620 | retval = usb_submit_urb(urb, GFP_ATOMIC); |
612 | if (retval) | 621 | if (retval) |
613 | err("%s - usb_submit_urb failed with result %d", | 622 | dev_err(&port->dev, |
614 | __func__, retval); | 623 | "%s - usb_submit_urb failed with result %d\n", |
624 | __func__, retval); | ||
615 | } /* mct_u232_read_int_callback */ | 625 | } /* mct_u232_read_int_callback */ |
616 | 626 | ||
617 | static void mct_u232_set_termios(struct tty_struct *tty, | 627 | static void mct_u232_set_termios(struct tty_struct *tty, |
@@ -678,7 +688,8 @@ static void mct_u232_set_termios(struct tty_struct *tty, | |||
678 | case CS8: | 688 | case CS8: |
679 | last_lcr |= MCT_U232_DATA_BITS_8; break; | 689 | last_lcr |= MCT_U232_DATA_BITS_8; break; |
680 | default: | 690 | default: |
681 | err("CSIZE was not CS5-CS8, using default of 8"); | 691 | dev_err(&port->dev, |
692 | "CSIZE was not CS5-CS8, using default of 8\n"); | ||
682 | last_lcr |= MCT_U232_DATA_BITS_8; | 693 | last_lcr |= MCT_U232_DATA_BITS_8; |
683 | break; | 694 | break; |
684 | } | 695 | } |
@@ -815,7 +826,8 @@ static int __init mct_u232_init(void) | |||
815 | retval = usb_register(&mct_u232_driver); | 826 | retval = usb_register(&mct_u232_driver); |
816 | if (retval) | 827 | if (retval) |
817 | goto failed_usb_register; | 828 | goto failed_usb_register; |
818 | info(DRIVER_DESC " " DRIVER_VERSION); | 829 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
830 | DRIVER_DESC "\n"); | ||
819 | return 0; | 831 | return 0; |
820 | failed_usb_register: | 832 | failed_usb_register: |
821 | usb_serial_deregister(&mct_u232_device); | 833 | usb_serial_deregister(&mct_u232_device); |
diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c index 7c4917d77c0a..e772cc0a97fd 100644 --- a/drivers/usb/serial/mos7720.c +++ b/drivers/usb/serial/mos7720.c | |||
@@ -216,12 +216,13 @@ static void mos7720_bulk_in_callback(struct urb *urb) | |||
216 | 216 | ||
217 | data = urb->transfer_buffer; | 217 | data = urb->transfer_buffer; |
218 | 218 | ||
219 | tty = port->port.tty; | 219 | tty = tty_port_tty_get(&port->port); |
220 | if (tty && urb->actual_length) { | 220 | if (tty && urb->actual_length) { |
221 | tty_buffer_request_room(tty, urb->actual_length); | 221 | tty_buffer_request_room(tty, urb->actual_length); |
222 | tty_insert_flip_string(tty, data, urb->actual_length); | 222 | tty_insert_flip_string(tty, data, urb->actual_length); |
223 | tty_flip_buffer_push(tty); | 223 | tty_flip_buffer_push(tty); |
224 | } | 224 | } |
225 | tty_kref_put(tty); | ||
225 | 226 | ||
226 | if (!port->read_urb) { | 227 | if (!port->read_urb) { |
227 | dbg("URB KILLED !!!"); | 228 | dbg("URB KILLED !!!"); |
@@ -262,10 +263,11 @@ static void mos7720_bulk_out_data_callback(struct urb *urb) | |||
262 | 263 | ||
263 | dbg("Entering ........."); | 264 | dbg("Entering ........."); |
264 | 265 | ||
265 | tty = mos7720_port->port->port.tty; | 266 | tty = tty_port_tty_get(&mos7720_port->port->port); |
266 | 267 | ||
267 | if (tty && mos7720_port->open) | 268 | if (tty && mos7720_port->open) |
268 | tty_wakeup(tty); | 269 | tty_wakeup(tty); |
270 | tty_kref_put(tty); | ||
269 | } | 271 | } |
270 | 272 | ||
271 | /* | 273 | /* |
@@ -353,14 +355,16 @@ static int mos7720_open(struct tty_struct *tty, | |||
353 | mos7720_port->write_urb_pool[j] = urb; | 355 | mos7720_port->write_urb_pool[j] = urb; |
354 | 356 | ||
355 | if (urb == NULL) { | 357 | if (urb == NULL) { |
356 | err("No more urbs???"); | 358 | dev_err(&port->dev, "No more urbs???\n"); |
357 | continue; | 359 | continue; |
358 | } | 360 | } |
359 | 361 | ||
360 | urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE, | 362 | urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE, |
361 | GFP_KERNEL); | 363 | GFP_KERNEL); |
362 | if (!urb->transfer_buffer) { | 364 | if (!urb->transfer_buffer) { |
363 | err("%s-out of memory for urb buffers.", __func__); | 365 | dev_err(&port->dev, |
366 | "%s-out of memory for urb buffers.\n", | ||
367 | __func__); | ||
364 | usb_free_urb(mos7720_port->write_urb_pool[j]); | 368 | usb_free_urb(mos7720_port->write_urb_pool[j]); |
365 | mos7720_port->write_urb_pool[j] = NULL; | 369 | mos7720_port->write_urb_pool[j] = NULL; |
366 | continue; | 370 | continue; |
@@ -692,7 +696,8 @@ static int mos7720_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
692 | urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE, | 696 | urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE, |
693 | GFP_KERNEL); | 697 | GFP_KERNEL); |
694 | if (urb->transfer_buffer == NULL) { | 698 | if (urb->transfer_buffer == NULL) { |
695 | err("%s no more kernel memory...", __func__); | 699 | dev_err(&port->dev, "%s no more kernel memory...\n", |
700 | __func__); | ||
696 | goto exit; | 701 | goto exit; |
697 | } | 702 | } |
698 | } | 703 | } |
@@ -712,8 +717,8 @@ static int mos7720_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
712 | /* send it down the pipe */ | 717 | /* send it down the pipe */ |
713 | status = usb_submit_urb(urb, GFP_ATOMIC); | 718 | status = usb_submit_urb(urb, GFP_ATOMIC); |
714 | if (status) { | 719 | if (status) { |
715 | err("%s - usb_submit_urb(write bulk) failed with status = %d", | 720 | dev_err(&port->dev, "%s - usb_submit_urb(write bulk) failed " |
716 | __func__, status); | 721 | "with status = %d\n", __func__, status); |
717 | bytes_sent = status; | 722 | bytes_sent = status; |
718 | goto exit; | 723 | goto exit; |
719 | } | 724 | } |
@@ -973,7 +978,7 @@ static int send_cmd_write_baud_rate(struct moschip_port *mos7720_port, | |||
973 | /* Calculate the Divisor */ | 978 | /* Calculate the Divisor */ |
974 | status = calc_baud_rate_divisor(baudrate, &divisor); | 979 | status = calc_baud_rate_divisor(baudrate, &divisor); |
975 | if (status) { | 980 | if (status) { |
976 | err("%s - bad baud rate", __func__); | 981 | dev_err(&port->dev, "%s - bad baud rate\n", __func__); |
977 | return status; | 982 | return status; |
978 | } | 983 | } |
979 | 984 | ||
@@ -1267,29 +1272,6 @@ static int get_lsr_info(struct tty_struct *tty, | |||
1267 | return 0; | 1272 | return 0; |
1268 | } | 1273 | } |
1269 | 1274 | ||
1270 | /* | ||
1271 | * get_number_bytes_avail - get number of bytes available | ||
1272 | * | ||
1273 | * Purpose: Let user call ioctl to get the count of number of bytes available. | ||
1274 | */ | ||
1275 | static int get_number_bytes_avail(struct moschip_port *mos7720_port, | ||
1276 | unsigned int __user *value) | ||
1277 | { | ||
1278 | unsigned int result = 0; | ||
1279 | struct tty_struct *tty = mos7720_port->port->port.tty; | ||
1280 | |||
1281 | if (!tty) | ||
1282 | return -ENOIOCTLCMD; | ||
1283 | |||
1284 | result = tty->read_cnt; | ||
1285 | |||
1286 | dbg("%s(%d) = %d", __func__, mos7720_port->port->number, result); | ||
1287 | if (copy_to_user(value, &result, sizeof(int))) | ||
1288 | return -EFAULT; | ||
1289 | |||
1290 | return -ENOIOCTLCMD; | ||
1291 | } | ||
1292 | |||
1293 | static int set_modem_info(struct moschip_port *mos7720_port, unsigned int cmd, | 1275 | static int set_modem_info(struct moschip_port *mos7720_port, unsigned int cmd, |
1294 | unsigned int __user *value) | 1276 | unsigned int __user *value) |
1295 | { | 1277 | { |
@@ -1409,13 +1391,6 @@ static int mos7720_ioctl(struct tty_struct *tty, struct file *file, | |||
1409 | dbg("%s - port %d, cmd = 0x%x", __func__, port->number, cmd); | 1391 | dbg("%s - port %d, cmd = 0x%x", __func__, port->number, cmd); |
1410 | 1392 | ||
1411 | switch (cmd) { | 1393 | switch (cmd) { |
1412 | case TIOCINQ: | ||
1413 | /* return number of bytes available */ | ||
1414 | dbg("%s (%d) TIOCINQ", __func__, port->number); | ||
1415 | return get_number_bytes_avail(mos7720_port, | ||
1416 | (unsigned int __user *)arg); | ||
1417 | break; | ||
1418 | |||
1419 | case TIOCSERGETLSR: | 1394 | case TIOCSERGETLSR: |
1420 | dbg("%s (%d) TIOCSERGETLSR", __func__, port->number); | 1395 | dbg("%s (%d) TIOCSERGETLSR", __func__, port->number); |
1421 | return get_lsr_info(tty, mos7720_port, | 1396 | return get_lsr_info(tty, mos7720_port, |
@@ -1506,7 +1481,7 @@ static int mos7720_startup(struct usb_serial *serial) | |||
1506 | /* create our private serial structure */ | 1481 | /* create our private serial structure */ |
1507 | mos7720_serial = kzalloc(sizeof(struct moschip_serial), GFP_KERNEL); | 1482 | mos7720_serial = kzalloc(sizeof(struct moschip_serial), GFP_KERNEL); |
1508 | if (mos7720_serial == NULL) { | 1483 | if (mos7720_serial == NULL) { |
1509 | err("%s - Out of memory", __func__); | 1484 | dev_err(&dev->dev, "%s - Out of memory\n", __func__); |
1510 | return -ENOMEM; | 1485 | return -ENOMEM; |
1511 | } | 1486 | } |
1512 | 1487 | ||
@@ -1519,7 +1494,7 @@ static int mos7720_startup(struct usb_serial *serial) | |||
1519 | for (i = 0; i < serial->num_ports; ++i) { | 1494 | for (i = 0; i < serial->num_ports; ++i) { |
1520 | mos7720_port = kzalloc(sizeof(struct moschip_port), GFP_KERNEL); | 1495 | mos7720_port = kzalloc(sizeof(struct moschip_port), GFP_KERNEL); |
1521 | if (mos7720_port == NULL) { | 1496 | if (mos7720_port == NULL) { |
1522 | err("%s - Out of memory", __func__); | 1497 | dev_err(&dev->dev, "%s - Out of memory\n", __func__); |
1523 | usb_set_serial_data(serial, NULL); | 1498 | usb_set_serial_data(serial, NULL); |
1524 | kfree(mos7720_serial); | 1499 | kfree(mos7720_serial); |
1525 | return -ENOMEM; | 1500 | return -ENOMEM; |
@@ -1613,7 +1588,8 @@ static int __init moschip7720_init(void) | |||
1613 | if (retval) | 1588 | if (retval) |
1614 | goto failed_port_device_register; | 1589 | goto failed_port_device_register; |
1615 | 1590 | ||
1616 | info(DRIVER_DESC " " DRIVER_VERSION); | 1591 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
1592 | DRIVER_DESC "\n"); | ||
1617 | 1593 | ||
1618 | /* Register with the usb */ | 1594 | /* Register with the usb */ |
1619 | retval = usb_register(&usb_driver); | 1595 | retval = usb_register(&usb_driver); |
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c index 09d82062b973..fda4a6421c44 100644 --- a/drivers/usb/serial/mos7840.c +++ b/drivers/usb/serial/mos7840.c | |||
@@ -709,12 +709,13 @@ static void mos7840_bulk_in_callback(struct urb *urb) | |||
709 | dbg("%s", "Entering ........... \n"); | 709 | dbg("%s", "Entering ........... \n"); |
710 | 710 | ||
711 | if (urb->actual_length) { | 711 | if (urb->actual_length) { |
712 | tty = mos7840_port->port->port.tty; | 712 | tty = tty_port_tty_get(&mos7840_port->port->port); |
713 | if (tty) { | 713 | if (tty) { |
714 | tty_buffer_request_room(tty, urb->actual_length); | 714 | tty_buffer_request_room(tty, urb->actual_length); |
715 | tty_insert_flip_string(tty, data, urb->actual_length); | 715 | tty_insert_flip_string(tty, data, urb->actual_length); |
716 | dbg(" %s \n", data); | 716 | dbg(" %s \n", data); |
717 | tty_flip_buffer_push(tty); | 717 | tty_flip_buffer_push(tty); |
718 | tty_kref_put(tty); | ||
718 | } | 719 | } |
719 | mos7840_port->icount.rx += urb->actual_length; | 720 | mos7840_port->icount.rx += urb->actual_length; |
720 | smp_wmb(); | 721 | smp_wmb(); |
@@ -773,10 +774,10 @@ static void mos7840_bulk_out_data_callback(struct urb *urb) | |||
773 | 774 | ||
774 | dbg("%s \n", "Entering ........."); | 775 | dbg("%s \n", "Entering ........."); |
775 | 776 | ||
776 | tty = mos7840_port->port->port.tty; | 777 | tty = tty_port_tty_get(&mos7840_port->port->port); |
777 | |||
778 | if (tty && mos7840_port->open) | 778 | if (tty && mos7840_port->open) |
779 | tty_wakeup(tty); | 779 | tty_wakeup(tty); |
780 | tty_kref_put(tty); | ||
780 | 781 | ||
781 | } | 782 | } |
782 | 783 | ||
@@ -843,7 +844,7 @@ static int mos7840_open(struct tty_struct *tty, | |||
843 | mos7840_port->write_urb_pool[j] = urb; | 844 | mos7840_port->write_urb_pool[j] = urb; |
844 | 845 | ||
845 | if (urb == NULL) { | 846 | if (urb == NULL) { |
846 | err("No more urbs???"); | 847 | dev_err(&port->dev, "No more urbs???\n"); |
847 | continue; | 848 | continue; |
848 | } | 849 | } |
849 | 850 | ||
@@ -852,7 +853,9 @@ static int mos7840_open(struct tty_struct *tty, | |||
852 | if (!urb->transfer_buffer) { | 853 | if (!urb->transfer_buffer) { |
853 | usb_free_urb(urb); | 854 | usb_free_urb(urb); |
854 | mos7840_port->write_urb_pool[j] = NULL; | 855 | mos7840_port->write_urb_pool[j] = NULL; |
855 | err("%s-out of memory for urb buffers.", __func__); | 856 | dev_err(&port->dev, |
857 | "%s-out of memory for urb buffers.\n", | ||
858 | __func__); | ||
856 | continue; | 859 | continue; |
857 | } | 860 | } |
858 | } | 861 | } |
@@ -1020,8 +1023,8 @@ static int mos7840_open(struct tty_struct *tty, | |||
1020 | usb_submit_urb(serial->port[0]->interrupt_in_urb, | 1023 | usb_submit_urb(serial->port[0]->interrupt_in_urb, |
1021 | GFP_KERNEL); | 1024 | GFP_KERNEL); |
1022 | if (response) { | 1025 | if (response) { |
1023 | err("%s - Error %d submitting interrupt urb", | 1026 | dev_err(&port->dev, "%s - Error %d submitting " |
1024 | __func__, response); | 1027 | "interrupt urb\n", __func__, response); |
1025 | } | 1028 | } |
1026 | 1029 | ||
1027 | } | 1030 | } |
@@ -1054,8 +1057,8 @@ static int mos7840_open(struct tty_struct *tty, | |||
1054 | port->bulk_in_endpointAddress); | 1057 | port->bulk_in_endpointAddress); |
1055 | response = usb_submit_urb(mos7840_port->read_urb, GFP_KERNEL); | 1058 | response = usb_submit_urb(mos7840_port->read_urb, GFP_KERNEL); |
1056 | if (response) { | 1059 | if (response) { |
1057 | err("%s - Error %d submitting control urb", __func__, | 1060 | dev_err(&port->dev, "%s - Error %d submitting control urb\n", |
1058 | response); | 1061 | __func__, response); |
1059 | } | 1062 | } |
1060 | 1063 | ||
1061 | /* initialize our wait queues */ | 1064 | /* initialize our wait queues */ |
@@ -1491,7 +1494,8 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
1491 | kmalloc(URB_TRANSFER_BUFFER_SIZE, GFP_KERNEL); | 1494 | kmalloc(URB_TRANSFER_BUFFER_SIZE, GFP_KERNEL); |
1492 | 1495 | ||
1493 | if (urb->transfer_buffer == NULL) { | 1496 | if (urb->transfer_buffer == NULL) { |
1494 | err("%s no more kernel memory...", __func__); | 1497 | dev_err(&port->dev, "%s no more kernel memory...\n", |
1498 | __func__); | ||
1495 | goto exit; | 1499 | goto exit; |
1496 | } | 1500 | } |
1497 | } | 1501 | } |
@@ -1516,8 +1520,8 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
1516 | 1520 | ||
1517 | if (status) { | 1521 | if (status) { |
1518 | mos7840_port->busy[i] = 0; | 1522 | mos7840_port->busy[i] = 0; |
1519 | err("%s - usb_submit_urb(write bulk) failed with status = %d", | 1523 | dev_err(&port->dev, "%s - usb_submit_urb(write bulk) failed " |
1520 | __func__, status); | 1524 | "with status = %d\n", __func__, status); |
1521 | bytes_sent = status; | 1525 | bytes_sent = status; |
1522 | goto exit; | 1526 | goto exit; |
1523 | } | 1527 | } |
@@ -1855,8 +1859,7 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port, | |||
1855 | /* Calculate the Divisor */ | 1859 | /* Calculate the Divisor */ |
1856 | 1860 | ||
1857 | if (status) { | 1861 | if (status) { |
1858 | err("%s - bad baud rate", __func__); | 1862 | dev_err(&port->dev, "%s - bad baud rate\n", __func__); |
1859 | dbg("%s\n", "bad baud rate"); | ||
1860 | return status; | 1863 | return status; |
1861 | } | 1864 | } |
1862 | /* Enable access to divisor latch */ | 1865 | /* Enable access to divisor latch */ |
@@ -2445,7 +2448,7 @@ static int mos7840_startup(struct usb_serial *serial) | |||
2445 | for (i = 0; i < serial->num_ports; ++i) { | 2448 | for (i = 0; i < serial->num_ports; ++i) { |
2446 | mos7840_port = kzalloc(sizeof(struct moschip_port), GFP_KERNEL); | 2449 | mos7840_port = kzalloc(sizeof(struct moschip_port), GFP_KERNEL); |
2447 | if (mos7840_port == NULL) { | 2450 | if (mos7840_port == NULL) { |
2448 | err("%s - Out of memory", __func__); | 2451 | dev_err(&dev->dev, "%s - Out of memory\n", __func__); |
2449 | status = -ENOMEM; | 2452 | status = -ENOMEM; |
2450 | i--; /* don't follow NULL pointer cleaning up */ | 2453 | i--; /* don't follow NULL pointer cleaning up */ |
2451 | goto error; | 2454 | goto error; |
@@ -2742,7 +2745,8 @@ static int __init moschip7840_init(void) | |||
2742 | goto failed_port_device_register; | 2745 | goto failed_port_device_register; |
2743 | 2746 | ||
2744 | dbg("%s\n", "Entring..."); | 2747 | dbg("%s\n", "Entring..."); |
2745 | info(DRIVER_DESC " " DRIVER_VERSION); | 2748 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
2749 | DRIVER_DESC "\n"); | ||
2746 | 2750 | ||
2747 | /* Register with the usb */ | 2751 | /* Register with the usb */ |
2748 | retval = usb_register(&io_driver); | 2752 | retval = usb_register(&io_driver); |
diff --git a/drivers/usb/serial/navman.c b/drivers/usb/serial/navman.c index d6736531a0fa..bcdcbb822705 100644 --- a/drivers/usb/serial/navman.c +++ b/drivers/usb/serial/navman.c | |||
@@ -64,12 +64,13 @@ static void navman_read_int_callback(struct urb *urb) | |||
64 | usb_serial_debug_data(debug, &port->dev, __func__, | 64 | usb_serial_debug_data(debug, &port->dev, __func__, |
65 | urb->actual_length, data); | 65 | urb->actual_length, data); |
66 | 66 | ||
67 | tty = port->port.tty; | 67 | tty = tty_port_tty_get(&port->port); |
68 | if (tty && urb->actual_length) { | 68 | if (tty && urb->actual_length) { |
69 | tty_buffer_request_room(tty, urb->actual_length); | 69 | tty_buffer_request_room(tty, urb->actual_length); |
70 | tty_insert_flip_string(tty, data, urb->actual_length); | 70 | tty_insert_flip_string(tty, data, urb->actual_length); |
71 | tty_flip_buffer_push(tty); | 71 | tty_flip_buffer_push(tty); |
72 | } | 72 | } |
73 | tty_kref_put(tty); | ||
73 | 74 | ||
74 | exit: | 75 | exit: |
75 | result = usb_submit_urb(urb, GFP_ATOMIC); | 76 | result = usb_submit_urb(urb, GFP_ATOMIC); |
diff --git a/drivers/usb/serial/omninet.c b/drivers/usb/serial/omninet.c index ae8e227f3db2..df6539712726 100644 --- a/drivers/usb/serial/omninet.c +++ b/drivers/usb/serial/omninet.c | |||
@@ -154,8 +154,8 @@ static int omninet_attach(struct usb_serial *serial) | |||
154 | 154 | ||
155 | od = kmalloc(sizeof(struct omninet_data), GFP_KERNEL); | 155 | od = kmalloc(sizeof(struct omninet_data), GFP_KERNEL); |
156 | if (!od) { | 156 | if (!od) { |
157 | err("%s- kmalloc(%Zd) failed.", | 157 | dev_err(&port->dev, "%s- kmalloc(%Zd) failed.\n", |
158 | __func__, sizeof(struct omninet_data)); | 158 | __func__, sizeof(struct omninet_data)); |
159 | return -ENOMEM; | 159 | return -ENOMEM; |
160 | } | 160 | } |
161 | usb_set_serial_port_data(port, od); | 161 | usb_set_serial_port_data(port, od); |
@@ -172,7 +172,7 @@ static int omninet_open(struct tty_struct *tty, | |||
172 | dbg("%s - port %d", __func__, port->number); | 172 | dbg("%s - port %d", __func__, port->number); |
173 | 173 | ||
174 | wport = serial->port[1]; | 174 | wport = serial->port[1]; |
175 | wport->port.tty = tty; /* FIXME */ | 175 | tty_port_tty_set(&wport->port, tty); |
176 | 176 | ||
177 | /* Start reading from the device */ | 177 | /* Start reading from the device */ |
178 | usb_fill_bulk_urb(port->read_urb, serial->dev, | 178 | usb_fill_bulk_urb(port->read_urb, serial->dev, |
@@ -183,8 +183,9 @@ static int omninet_open(struct tty_struct *tty, | |||
183 | omninet_read_bulk_callback, port); | 183 | omninet_read_bulk_callback, port); |
184 | result = usb_submit_urb(port->read_urb, GFP_KERNEL); | 184 | result = usb_submit_urb(port->read_urb, GFP_KERNEL); |
185 | if (result) | 185 | if (result) |
186 | err("%s - failed submitting read urb, error %d", | 186 | dev_err(&port->dev, |
187 | __func__, result); | 187 | "%s - failed submitting read urb, error %d\n", |
188 | __func__, result); | ||
188 | return result; | 189 | return result; |
189 | } | 190 | } |
190 | 191 | ||
@@ -229,9 +230,11 @@ static void omninet_read_bulk_callback(struct urb *urb) | |||
229 | } | 230 | } |
230 | 231 | ||
231 | if (urb->actual_length && header->oh_len) { | 232 | if (urb->actual_length && header->oh_len) { |
232 | tty_insert_flip_string(port->port.tty, | 233 | struct tty_struct *tty = tty_port_tty_get(&port->port); |
233 | data + OMNINET_DATAOFFSET, header->oh_len); | 234 | tty_insert_flip_string(tty, data + OMNINET_DATAOFFSET, |
234 | tty_flip_buffer_push(port->port.tty); | 235 | header->oh_len); |
236 | tty_flip_buffer_push(tty); | ||
237 | tty_kref_put(tty); | ||
235 | } | 238 | } |
236 | 239 | ||
237 | /* Continue trying to always read */ | 240 | /* Continue trying to always read */ |
@@ -242,8 +245,9 @@ static void omninet_read_bulk_callback(struct urb *urb) | |||
242 | omninet_read_bulk_callback, port); | 245 | omninet_read_bulk_callback, port); |
243 | result = usb_submit_urb(urb, GFP_ATOMIC); | 246 | result = usb_submit_urb(urb, GFP_ATOMIC); |
244 | if (result) | 247 | if (result) |
245 | err("%s - failed resubmitting read urb, error %d", | 248 | dev_err(&port->dev, |
246 | __func__, result); | 249 | "%s - failed resubmitting read urb, error %d\n", |
250 | __func__, result); | ||
247 | 251 | ||
248 | return; | 252 | return; |
249 | } | 253 | } |
@@ -296,8 +300,9 @@ static int omninet_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
296 | result = usb_submit_urb(wport->write_urb, GFP_ATOMIC); | 300 | result = usb_submit_urb(wport->write_urb, GFP_ATOMIC); |
297 | if (result) { | 301 | if (result) { |
298 | wport->write_urb_busy = 0; | 302 | wport->write_urb_busy = 0; |
299 | err("%s - failed submitting write urb, error %d", | 303 | dev_err(&port->dev, |
300 | __func__, result); | 304 | "%s - failed submitting write urb, error %d\n", |
305 | __func__, result); | ||
301 | } else | 306 | } else |
302 | result = count; | 307 | result = count; |
303 | 308 | ||
@@ -362,7 +367,8 @@ static int __init omninet_init(void) | |||
362 | retval = usb_register(&omninet_driver); | 367 | retval = usb_register(&omninet_driver); |
363 | if (retval) | 368 | if (retval) |
364 | goto failed_usb_register; | 369 | goto failed_usb_register; |
365 | info(DRIVER_VERSION ":" DRIVER_DESC); | 370 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
371 | DRIVER_DESC "\n"); | ||
366 | return 0; | 372 | return 0; |
367 | failed_usb_register: | 373 | failed_usb_register: |
368 | usb_serial_deregister(&zyxel_omninet_device); | 374 | usb_serial_deregister(&zyxel_omninet_device); |
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index e143198aeb02..3d87eabcd922 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c | |||
@@ -79,27 +79,16 @@ static int option_send_setup(struct tty_struct *tty, struct usb_serial_port *po | |||
79 | #define OPTION_PRODUCT_VIPER 0x6600 | 79 | #define OPTION_PRODUCT_VIPER 0x6600 |
80 | #define OPTION_PRODUCT_VIPER_BUS 0x6601 | 80 | #define OPTION_PRODUCT_VIPER_BUS 0x6601 |
81 | #define OPTION_PRODUCT_GT_MAX_READY 0x6701 | 81 | #define OPTION_PRODUCT_GT_MAX_READY 0x6701 |
82 | #define OPTION_PRODUCT_GT_MAX 0x6711 | ||
83 | #define OPTION_PRODUCT_FUJI_MODEM_LIGHT 0x6721 | 82 | #define OPTION_PRODUCT_FUJI_MODEM_LIGHT 0x6721 |
84 | #define OPTION_PRODUCT_FUJI_MODEM_GT 0x6741 | 83 | #define OPTION_PRODUCT_FUJI_MODEM_GT 0x6741 |
85 | #define OPTION_PRODUCT_FUJI_MODEM_EX 0x6761 | 84 | #define OPTION_PRODUCT_FUJI_MODEM_EX 0x6761 |
86 | #define OPTION_PRODUCT_FUJI_NETWORK_LIGHT 0x6731 | ||
87 | #define OPTION_PRODUCT_FUJI_NETWORK_GT 0x6751 | ||
88 | #define OPTION_PRODUCT_FUJI_NETWORK_EX 0x6771 | ||
89 | #define OPTION_PRODUCT_KOI_MODEM 0x6800 | 85 | #define OPTION_PRODUCT_KOI_MODEM 0x6800 |
90 | #define OPTION_PRODUCT_KOI_NETWORK 0x6811 | ||
91 | #define OPTION_PRODUCT_SCORPION_MODEM 0x6901 | 86 | #define OPTION_PRODUCT_SCORPION_MODEM 0x6901 |
92 | #define OPTION_PRODUCT_SCORPION_NETWORK 0x6911 | ||
93 | #define OPTION_PRODUCT_ETNA_MODEM 0x7001 | 87 | #define OPTION_PRODUCT_ETNA_MODEM 0x7001 |
94 | #define OPTION_PRODUCT_ETNA_NETWORK 0x7011 | ||
95 | #define OPTION_PRODUCT_ETNA_MODEM_LITE 0x7021 | 88 | #define OPTION_PRODUCT_ETNA_MODEM_LITE 0x7021 |
96 | #define OPTION_PRODUCT_ETNA_MODEM_GT 0x7041 | 89 | #define OPTION_PRODUCT_ETNA_MODEM_GT 0x7041 |
97 | #define OPTION_PRODUCT_ETNA_MODEM_EX 0x7061 | 90 | #define OPTION_PRODUCT_ETNA_MODEM_EX 0x7061 |
98 | #define OPTION_PRODUCT_ETNA_NETWORK_LITE 0x7031 | ||
99 | #define OPTION_PRODUCT_ETNA_NETWORK_GT 0x7051 | ||
100 | #define OPTION_PRODUCT_ETNA_NETWORK_EX 0x7071 | ||
101 | #define OPTION_PRODUCT_ETNA_KOI_MODEM 0x7100 | 91 | #define OPTION_PRODUCT_ETNA_KOI_MODEM 0x7100 |
102 | #define OPTION_PRODUCT_ETNA_KOI_NETWORK 0x7111 | ||
103 | 92 | ||
104 | #define HUAWEI_VENDOR_ID 0x12D1 | 93 | #define HUAWEI_VENDOR_ID 0x12D1 |
105 | #define HUAWEI_PRODUCT_E600 0x1001 | 94 | #define HUAWEI_PRODUCT_E600 0x1001 |
@@ -173,6 +162,7 @@ static int option_send_setup(struct tty_struct *tty, struct usb_serial_port *po | |||
173 | #define KYOCERA_PRODUCT_KPC680 0x180a | 162 | #define KYOCERA_PRODUCT_KPC680 0x180a |
174 | 163 | ||
175 | #define ANYDATA_VENDOR_ID 0x16d5 | 164 | #define ANYDATA_VENDOR_ID 0x16d5 |
165 | #define ANYDATA_PRODUCT_ADU_620UW 0x6202 | ||
176 | #define ANYDATA_PRODUCT_ADU_E100A 0x6501 | 166 | #define ANYDATA_PRODUCT_ADU_E100A 0x6501 |
177 | #define ANYDATA_PRODUCT_ADU_500A 0x6502 | 167 | #define ANYDATA_PRODUCT_ADU_500A 0x6502 |
178 | 168 | ||
@@ -217,6 +207,17 @@ static int option_send_setup(struct tty_struct *tty, struct usb_serial_port *po | |||
217 | /* ZTE PRODUCTS */ | 207 | /* ZTE PRODUCTS */ |
218 | #define ZTE_VENDOR_ID 0x19d2 | 208 | #define ZTE_VENDOR_ID 0x19d2 |
219 | #define ZTE_PRODUCT_MF628 0x0015 | 209 | #define ZTE_PRODUCT_MF628 0x0015 |
210 | #define ZTE_PRODUCT_CDMA_TECH 0xfffe | ||
211 | |||
212 | /* Ericsson products */ | ||
213 | #define ERICSSON_VENDOR_ID 0x0bdb | ||
214 | #define ERICSSON_PRODUCT_F3507G 0x1900 | ||
215 | |||
216 | /* Pantech products */ | ||
217 | #define PANTECH_VENDOR_ID 0x106c | ||
218 | #define PANTECH_PRODUCT_PC5740 0x3701 | ||
219 | #define PANTECH_PRODUCT_PC5750 0x3702 /* PX-500 */ | ||
220 | #define PANTECH_PRODUCT_UM150 0x3711 | ||
220 | 221 | ||
221 | static struct usb_device_id option_ids[] = { | 222 | static struct usb_device_id option_ids[] = { |
222 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) }, | 223 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) }, |
@@ -233,27 +234,16 @@ static struct usb_device_id option_ids[] = { | |||
233 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_VIPER) }, | 234 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_VIPER) }, |
234 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_VIPER_BUS) }, | 235 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_VIPER_BUS) }, |
235 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_GT_MAX_READY) }, | 236 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_GT_MAX_READY) }, |
236 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_GT_MAX) }, | ||
237 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUJI_MODEM_LIGHT) }, | 237 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUJI_MODEM_LIGHT) }, |
238 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUJI_MODEM_GT) }, | 238 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUJI_MODEM_GT) }, |
239 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUJI_MODEM_EX) }, | 239 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUJI_MODEM_EX) }, |
240 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUJI_NETWORK_LIGHT) }, | ||
241 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUJI_NETWORK_GT) }, | ||
242 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUJI_NETWORK_EX) }, | ||
243 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_KOI_MODEM) }, | 240 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_KOI_MODEM) }, |
244 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_KOI_NETWORK) }, | ||
245 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_SCORPION_MODEM) }, | 241 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_SCORPION_MODEM) }, |
246 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_SCORPION_NETWORK) }, | ||
247 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_MODEM) }, | 242 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_MODEM) }, |
248 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_NETWORK) }, | ||
249 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_MODEM_LITE) }, | 243 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_MODEM_LITE) }, |
250 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_MODEM_GT) }, | 244 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_MODEM_GT) }, |
251 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_MODEM_EX) }, | 245 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_MODEM_EX) }, |
252 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_NETWORK_LITE) }, | ||
253 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_NETWORK_GT) }, | ||
254 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_NETWORK_EX) }, | ||
255 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_KOI_MODEM) }, | 246 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_KOI_MODEM) }, |
256 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_KOI_NETWORK) }, | ||
257 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E600, 0xff, 0xff, 0xff) }, | 247 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E600, 0xff, 0xff, 0xff) }, |
258 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E220, 0xff, 0xff, 0xff) }, | 248 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E220, 0xff, 0xff, 0xff) }, |
259 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E220BIS, 0xff, 0xff, 0xff) }, | 249 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E220BIS, 0xff, 0xff, 0xff) }, |
@@ -316,8 +306,10 @@ static struct usb_device_id option_ids[] = { | |||
316 | { USB_DEVICE(DELL_VENDOR_ID, 0x8136) }, /* Dell Wireless HSDPA 5520 == Novatel Expedite EU860D */ | 306 | { USB_DEVICE(DELL_VENDOR_ID, 0x8136) }, /* Dell Wireless HSDPA 5520 == Novatel Expedite EU860D */ |
317 | { USB_DEVICE(DELL_VENDOR_ID, 0x8137) }, /* Dell Wireless HSDPA 5520 */ | 307 | { USB_DEVICE(DELL_VENDOR_ID, 0x8137) }, /* Dell Wireless HSDPA 5520 */ |
318 | { USB_DEVICE(DELL_VENDOR_ID, 0x8138) }, /* Dell Wireless 5520 Voda I Mobile Broadband (3G HSDPA) Minicard */ | 308 | { USB_DEVICE(DELL_VENDOR_ID, 0x8138) }, /* Dell Wireless 5520 Voda I Mobile Broadband (3G HSDPA) Minicard */ |
319 | { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_E100A) }, | 309 | { USB_DEVICE(DELL_VENDOR_ID, 0x8147) }, /* Dell Wireless 5530 Mobile Broadband (3G HSPA) Mini-Card */ |
310 | { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_E100A) }, /* ADU-E100, ADU-310 */ | ||
320 | { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_500A) }, | 311 | { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_500A) }, |
312 | { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_620UW) }, | ||
321 | { USB_DEVICE(AXESSTEL_VENDOR_ID, AXESSTEL_PRODUCT_MV110H) }, | 313 | { USB_DEVICE(AXESSTEL_VENDOR_ID, AXESSTEL_PRODUCT_MV110H) }, |
322 | { USB_DEVICE(ONDA_VENDOR_ID, ONDA_PRODUCT_MSA501HS) }, | 314 | { USB_DEVICE(ONDA_VENDOR_ID, ONDA_PRODUCT_MSA501HS) }, |
323 | { USB_DEVICE(ONDA_VENDOR_ID, ONDA_PRODUCT_ET502HS) }, | 315 | { USB_DEVICE(ONDA_VENDOR_ID, ONDA_PRODUCT_ET502HS) }, |
@@ -345,6 +337,11 @@ static struct usb_device_id option_ids[] = { | |||
345 | { USB_DEVICE(MAXON_VENDOR_ID, 0x6280) }, /* BP3-USB & BP3-EXT HSDPA */ | 337 | { USB_DEVICE(MAXON_VENDOR_ID, 0x6280) }, /* BP3-USB & BP3-EXT HSDPA */ |
346 | { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UC864E) }, | 338 | { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UC864E) }, |
347 | { USB_DEVICE(ZTE_VENDOR_ID, ZTE_PRODUCT_MF628) }, | 339 | { USB_DEVICE(ZTE_VENDOR_ID, ZTE_PRODUCT_MF628) }, |
340 | { USB_DEVICE(ZTE_VENDOR_ID, ZTE_PRODUCT_CDMA_TECH) }, | ||
341 | { USB_DEVICE(ERICSSON_VENDOR_ID, ERICSSON_PRODUCT_F3507G) }, | ||
342 | { USB_DEVICE(PANTECH_VENDOR_ID, PANTECH_PRODUCT_PC5740) }, | ||
343 | { USB_DEVICE(PANTECH_VENDOR_ID, PANTECH_PRODUCT_PC5750) }, | ||
344 | { USB_DEVICE(PANTECH_VENDOR_ID, PANTECH_PRODUCT_UM150) }, | ||
348 | { } /* Terminating entry */ | 345 | { } /* Terminating entry */ |
349 | }; | 346 | }; |
350 | MODULE_DEVICE_TABLE(usb, option_ids); | 347 | MODULE_DEVICE_TABLE(usb, option_ids); |
@@ -423,7 +420,8 @@ static int __init option_init(void) | |||
423 | if (retval) | 420 | if (retval) |
424 | goto failed_driver_register; | 421 | goto failed_driver_register; |
425 | 422 | ||
426 | info(DRIVER_DESC ": " DRIVER_VERSION); | 423 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
424 | DRIVER_DESC "\n"); | ||
427 | 425 | ||
428 | return 0; | 426 | return 0; |
429 | 427 | ||
@@ -567,14 +565,14 @@ static void option_indat_callback(struct urb *urb) | |||
567 | dbg("%s: nonzero status: %d on endpoint %02x.", | 565 | dbg("%s: nonzero status: %d on endpoint %02x.", |
568 | __func__, status, endpoint); | 566 | __func__, status, endpoint); |
569 | } else { | 567 | } else { |
570 | tty = port->port.tty; | 568 | tty = tty_port_tty_get(&port->port); |
571 | if (urb->actual_length) { | 569 | if (urb->actual_length) { |
572 | tty_buffer_request_room(tty, urb->actual_length); | 570 | tty_buffer_request_room(tty, urb->actual_length); |
573 | tty_insert_flip_string(tty, data, urb->actual_length); | 571 | tty_insert_flip_string(tty, data, urb->actual_length); |
574 | tty_flip_buffer_push(tty); | 572 | tty_flip_buffer_push(tty); |
575 | } else { | 573 | } else |
576 | dbg("%s: empty read urb received", __func__); | 574 | dbg("%s: empty read urb received", __func__); |
577 | } | 575 | tty_kref_put(tty); |
578 | 576 | ||
579 | /* Resubmit urb so we continue receiving */ | 577 | /* Resubmit urb so we continue receiving */ |
580 | if (port->port.count && status != -ESHUTDOWN) { | 578 | if (port->port.count && status != -ESHUTDOWN) { |
@@ -643,9 +641,13 @@ static void option_instat_callback(struct urb *urb) | |||
643 | portdata->dsr_state = ((signals & 0x02) ? 1 : 0); | 641 | portdata->dsr_state = ((signals & 0x02) ? 1 : 0); |
644 | portdata->ri_state = ((signals & 0x08) ? 1 : 0); | 642 | portdata->ri_state = ((signals & 0x08) ? 1 : 0); |
645 | 643 | ||
646 | if (port->port.tty && !C_CLOCAL(port->port.tty) && | 644 | if (old_dcd_state && !portdata->dcd_state) { |
647 | old_dcd_state && !portdata->dcd_state) | 645 | struct tty_struct *tty = |
648 | tty_hangup(port->port.tty); | 646 | tty_port_tty_get(&port->port); |
647 | if (tty && !C_CLOCAL(tty)) | ||
648 | tty_hangup(tty); | ||
649 | tty_kref_put(tty); | ||
650 | } | ||
649 | } else { | 651 | } else { |
650 | dbg("%s: type %x req %x", __func__, | 652 | dbg("%s: type %x req %x", __func__, |
651 | req_pkt->bRequestType, req_pkt->bRequest); | 653 | req_pkt->bRequestType, req_pkt->bRequest); |
@@ -789,7 +791,7 @@ static void option_close(struct tty_struct *tty, | |||
789 | for (i = 0; i < N_OUT_URB; i++) | 791 | for (i = 0; i < N_OUT_URB; i++) |
790 | usb_kill_urb(portdata->out_urbs[i]); | 792 | usb_kill_urb(portdata->out_urbs[i]); |
791 | } | 793 | } |
792 | port->port.tty = NULL; /* FIXME */ | 794 | tty_port_tty_set(&port->port, NULL); |
793 | } | 795 | } |
794 | 796 | ||
795 | /* Helper functions used by option_setup_urbs */ | 797 | /* Helper functions used by option_setup_urbs */ |
diff --git a/drivers/usb/serial/oti6858.c b/drivers/usb/serial/oti6858.c index 81db5715ee25..ba551f00f16f 100644 --- a/drivers/usb/serial/oti6858.c +++ b/drivers/usb/serial/oti6858.c | |||
@@ -224,10 +224,6 @@ struct oti6858_private { | |||
224 | struct usb_serial_port *port; /* USB port with which associated */ | 224 | struct usb_serial_port *port; /* USB port with which associated */ |
225 | }; | 225 | }; |
226 | 226 | ||
227 | #undef dbg | ||
228 | /* #define dbg(format, arg...) printk(KERN_INFO "%s: " format "\n", __FILE__, ## arg) */ | ||
229 | #define dbg(format, arg...) printk(KERN_INFO "" format "\n", ## arg) | ||
230 | |||
231 | static void setup_line(struct work_struct *work) | 227 | static void setup_line(struct work_struct *work) |
232 | { | 228 | { |
233 | struct oti6858_private *priv = container_of(work, | 229 | struct oti6858_private *priv = container_of(work, |
@@ -1002,11 +998,12 @@ static void oti6858_read_bulk_callback(struct urb *urb) | |||
1002 | return; | 998 | return; |
1003 | } | 999 | } |
1004 | 1000 | ||
1005 | tty = port->port.tty; | 1001 | tty = tty_port_tty_get(&port->port); |
1006 | if (tty != NULL && urb->actual_length > 0) { | 1002 | if (tty != NULL && urb->actual_length > 0) { |
1007 | tty_insert_flip_string(tty, data, urb->actual_length); | 1003 | tty_insert_flip_string(tty, data, urb->actual_length); |
1008 | tty_flip_buffer_push(tty); | 1004 | tty_flip_buffer_push(tty); |
1009 | } | 1005 | } |
1006 | tty_kref_put(tty); | ||
1010 | 1007 | ||
1011 | /* schedule the interrupt urb if we are still open */ | 1008 | /* schedule the interrupt urb if we are still open */ |
1012 | if (port->port.count != 0) { | 1009 | if (port->port.count != 0) { |
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index 1ede1441cb1b..491c8857b644 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c | |||
@@ -154,7 +154,6 @@ struct pl2303_private { | |||
154 | wait_queue_head_t delta_msr_wait; | 154 | wait_queue_head_t delta_msr_wait; |
155 | u8 line_control; | 155 | u8 line_control; |
156 | u8 line_status; | 156 | u8 line_status; |
157 | u8 termios_initialized; | ||
158 | enum pl2303_type type; | 157 | enum pl2303_type type; |
159 | }; | 158 | }; |
160 | 159 | ||
@@ -526,16 +525,6 @@ static void pl2303_set_termios(struct tty_struct *tty, | |||
526 | 525 | ||
527 | dbg("%s - port %d", __func__, port->number); | 526 | dbg("%s - port %d", __func__, port->number); |
528 | 527 | ||
529 | spin_lock_irqsave(&priv->lock, flags); | ||
530 | if (!priv->termios_initialized) { | ||
531 | *(tty->termios) = tty_std_termios; | ||
532 | tty->termios->c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; | ||
533 | tty->termios->c_ispeed = 9600; | ||
534 | tty->termios->c_ospeed = 9600; | ||
535 | priv->termios_initialized = 1; | ||
536 | } | ||
537 | spin_unlock_irqrestore(&priv->lock, flags); | ||
538 | |||
539 | /* The PL2303 is reported to lose bytes if you change | 528 | /* The PL2303 is reported to lose bytes if you change |
540 | serial settings even to the same values as before. Thus | 529 | serial settings even to the same values as before. Thus |
541 | we actually need to filter in this specific case */ | 530 | we actually need to filter in this specific case */ |
@@ -1057,7 +1046,7 @@ static void pl2303_read_bulk_callback(struct urb *urb) | |||
1057 | tty_flag = TTY_FRAME; | 1046 | tty_flag = TTY_FRAME; |
1058 | dbg("%s - tty_flag = %d", __func__, tty_flag); | 1047 | dbg("%s - tty_flag = %d", __func__, tty_flag); |
1059 | 1048 | ||
1060 | tty = port->port.tty; | 1049 | tty = tty_port_tty_get(&port->port); |
1061 | if (tty && urb->actual_length) { | 1050 | if (tty && urb->actual_length) { |
1062 | tty_buffer_request_room(tty, urb->actual_length + 1); | 1051 | tty_buffer_request_room(tty, urb->actual_length + 1); |
1063 | /* overrun is special, not associated with a char */ | 1052 | /* overrun is special, not associated with a char */ |
@@ -1067,7 +1056,7 @@ static void pl2303_read_bulk_callback(struct urb *urb) | |||
1067 | tty_insert_flip_char(tty, data[i], tty_flag); | 1056 | tty_insert_flip_char(tty, data[i], tty_flag); |
1068 | tty_flip_buffer_push(tty); | 1057 | tty_flip_buffer_push(tty); |
1069 | } | 1058 | } |
1070 | 1059 | tty_kref_put(tty); | |
1071 | /* Schedule the next read _if_ we are still open */ | 1060 | /* Schedule the next read _if_ we are still open */ |
1072 | if (port->port.count) { | 1061 | if (port->port.count) { |
1073 | urb->dev = port->serial->dev; | 1062 | urb->dev = port->serial->dev; |
@@ -1158,7 +1147,7 @@ static int __init pl2303_init(void) | |||
1158 | retval = usb_register(&pl2303_driver); | 1147 | retval = usb_register(&pl2303_driver); |
1159 | if (retval) | 1148 | if (retval) |
1160 | goto failed_usb_register; | 1149 | goto failed_usb_register; |
1161 | info(DRIVER_DESC); | 1150 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_DESC "\n"); |
1162 | return 0; | 1151 | return 0; |
1163 | failed_usb_register: | 1152 | failed_usb_register: |
1164 | usb_serial_deregister(&pl2303_device); | 1153 | usb_serial_deregister(&pl2303_device); |
diff --git a/drivers/usb/serial/safe_serial.c b/drivers/usb/serial/safe_serial.c index def52d07a4ea..4b463cd140ef 100644 --- a/drivers/usb/serial/safe_serial.c +++ b/drivers/usb/serial/safe_serial.c | |||
@@ -217,6 +217,7 @@ static void safe_read_bulk_callback(struct urb *urb) | |||
217 | struct usb_serial_port *port = urb->context; | 217 | struct usb_serial_port *port = urb->context; |
218 | unsigned char *data = urb->transfer_buffer; | 218 | unsigned char *data = urb->transfer_buffer; |
219 | unsigned char length = urb->actual_length; | 219 | unsigned char length = urb->actual_length; |
220 | struct tty_struct *tty; | ||
220 | int result; | 221 | int result; |
221 | int status = urb->status; | 222 | int status = urb->status; |
222 | 223 | ||
@@ -242,28 +243,31 @@ static void safe_read_bulk_callback(struct urb *urb) | |||
242 | printk("\n"); | 243 | printk("\n"); |
243 | } | 244 | } |
244 | #endif | 245 | #endif |
246 | tty = tty_port_tty_get(&port->port); | ||
245 | if (safe) { | 247 | if (safe) { |
246 | __u16 fcs; | 248 | __u16 fcs; |
247 | fcs = fcs_compute10(data, length, CRC10_INITFCS); | 249 | fcs = fcs_compute10(data, length, CRC10_INITFCS); |
248 | if (!fcs) { | 250 | if (!fcs) { |
249 | int actual_length = data[length - 2] >> 2; | 251 | int actual_length = data[length - 2] >> 2; |
250 | if (actual_length <= (length - 2)) { | 252 | if (actual_length <= (length - 2)) { |
251 | info("%s - actual: %d", __func__, | 253 | dev_info(&urb->dev->dev, "%s - actual: %d\n", |
252 | actual_length); | 254 | __func__, actual_length); |
253 | tty_insert_flip_string(port->port.tty, | 255 | tty_insert_flip_string(tty, |
254 | data, actual_length); | 256 | data, actual_length); |
255 | tty_flip_buffer_push(port->port.tty); | 257 | tty_flip_buffer_push(tty); |
256 | } else { | 258 | } else { |
257 | err("%s - inconsistent lengths %d:%d", | 259 | dev_err(&port->dev, |
260 | "%s - inconsistent lengths %d:%d\n", | ||
258 | __func__, actual_length, length); | 261 | __func__, actual_length, length); |
259 | } | 262 | } |
260 | } else { | 263 | } else { |
261 | err("%s - bad CRC %x", __func__, fcs); | 264 | dev_err(&port->dev, "%s - bad CRC %x\n", __func__, fcs); |
262 | } | 265 | } |
263 | } else { | 266 | } else { |
264 | tty_insert_flip_string(port->port.tty, data, length); | 267 | tty_insert_flip_string(tty, data, length); |
265 | tty_flip_buffer_push(port->port.tty); | 268 | tty_flip_buffer_push(tty); |
266 | } | 269 | } |
270 | tty_kref_put(tty); | ||
267 | 271 | ||
268 | /* Continue trying to always read */ | 272 | /* Continue trying to always read */ |
269 | usb_fill_bulk_urb(urb, port->serial->dev, | 273 | usb_fill_bulk_urb(urb, port->serial->dev, |
@@ -274,8 +278,9 @@ static void safe_read_bulk_callback(struct urb *urb) | |||
274 | 278 | ||
275 | result = usb_submit_urb(urb, GFP_ATOMIC); | 279 | result = usb_submit_urb(urb, GFP_ATOMIC); |
276 | if (result) | 280 | if (result) |
277 | err("%s - failed resubmitting read urb, error %d", | 281 | dev_err(&port->dev, |
278 | __func__, result); | 282 | "%s - failed resubmitting read urb, error %d\n", |
283 | __func__, result); | ||
279 | /* FIXME: Need a mechanism to retry later if this happens */ | 284 | /* FIXME: Need a mechanism to retry later if this happens */ |
280 | } | 285 | } |
281 | 286 | ||
@@ -366,8 +371,9 @@ static int safe_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
366 | result = usb_submit_urb(port->write_urb, GFP_KERNEL); | 371 | result = usb_submit_urb(port->write_urb, GFP_KERNEL); |
367 | if (result) { | 372 | if (result) { |
368 | port->write_urb_busy = 0; | 373 | port->write_urb_busy = 0; |
369 | err("%s - failed submitting write urb, error %d", | 374 | dev_err(&port->dev, |
370 | __func__, result); | 375 | "%s - failed submitting write urb, error %d\n", |
376 | __func__, result); | ||
371 | return 0; | 377 | return 0; |
372 | } | 378 | } |
373 | dbg("%s urb: %p submitted", __func__, port->write_urb); | 379 | dbg("%s urb: %p submitted", __func__, port->write_urb); |
@@ -425,14 +431,13 @@ static int __init safe_init(void) | |||
425 | { | 431 | { |
426 | int i, retval; | 432 | int i, retval; |
427 | 433 | ||
428 | info(DRIVER_VERSION " " DRIVER_AUTHOR); | 434 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
429 | info(DRIVER_DESC); | 435 | DRIVER_DESC "\n"); |
430 | info("vendor: %x product: %x safe: %d padded: %d\n", | ||
431 | vendor, product, safe, padded); | ||
432 | 436 | ||
433 | /* if we have vendor / product parameters patch them into id list */ | 437 | /* if we have vendor / product parameters patch them into id list */ |
434 | if (vendor || product) { | 438 | if (vendor || product) { |
435 | info("vendor: %x product: %x\n", vendor, product); | 439 | printk(KERN_INFO KBUILD_MODNAME ": vendor: %x product: %x\n", |
440 | vendor, product); | ||
436 | 441 | ||
437 | for (i = 0; i < ARRAY_SIZE(id_table); i++) { | 442 | for (i = 0; i < ARRAY_SIZE(id_table); i++) { |
438 | if (!id_table[i].idVendor && !id_table[i].idProduct) { | 443 | if (!id_table[i].idVendor && !id_table[i].idProduct) { |
diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c index 706033753adb..0f2b67244af6 100644 --- a/drivers/usb/serial/sierra.c +++ b/drivers/usb/serial/sierra.c | |||
@@ -14,7 +14,7 @@ | |||
14 | Whom based his on the Keyspan driver by Hugh Blemings <hugh@blemings.org> | 14 | Whom based his on the Keyspan driver by Hugh Blemings <hugh@blemings.org> |
15 | */ | 15 | */ |
16 | 16 | ||
17 | #define DRIVER_VERSION "v.1.2.13a" | 17 | #define DRIVER_VERSION "v.1.3.2" |
18 | #define DRIVER_AUTHOR "Kevin Lloyd <klloyd@sierrawireless.com>" | 18 | #define DRIVER_AUTHOR "Kevin Lloyd <klloyd@sierrawireless.com>" |
19 | #define DRIVER_DESC "USB Driver for Sierra Wireless USB modems" | 19 | #define DRIVER_DESC "USB Driver for Sierra Wireless USB modems" |
20 | 20 | ||
@@ -30,9 +30,6 @@ | |||
30 | 30 | ||
31 | #define SWIMS_USB_REQUEST_SetPower 0x00 | 31 | #define SWIMS_USB_REQUEST_SetPower 0x00 |
32 | #define SWIMS_USB_REQUEST_SetNmea 0x07 | 32 | #define SWIMS_USB_REQUEST_SetNmea 0x07 |
33 | #define SWIMS_USB_REQUEST_SetMode 0x0B | ||
34 | #define SWIMS_USB_REQUEST_GetSwocInfo 0x0A | ||
35 | #define SWIMS_SET_MODE_Modem 0x0001 | ||
36 | 33 | ||
37 | /* per port private data */ | 34 | /* per port private data */ |
38 | #define N_IN_URB 4 | 35 | #define N_IN_URB 4 |
@@ -163,7 +160,7 @@ static struct usb_device_id id_table [] = { | |||
163 | { USB_DEVICE(0x1199, 0x0017) }, /* Sierra Wireless EM5625 */ | 160 | { USB_DEVICE(0x1199, 0x0017) }, /* Sierra Wireless EM5625 */ |
164 | { USB_DEVICE(0x1199, 0x0018) }, /* Sierra Wireless MC5720 */ | 161 | { USB_DEVICE(0x1199, 0x0018) }, /* Sierra Wireless MC5720 */ |
165 | { USB_DEVICE(0x1199, 0x0218) }, /* Sierra Wireless MC5720 */ | 162 | { USB_DEVICE(0x1199, 0x0218) }, /* Sierra Wireless MC5720 */ |
166 | { USB_DEVICE(0x0f30, 0x1b1d) }, /* Sierra Wireless MC5720 */ | 163 | { USB_DEVICE(0x03f0, 0x1b1d) }, /* HP ev2200 a.k.a MC5720 */ |
167 | { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */ | 164 | { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */ |
168 | { USB_DEVICE(0x1199, 0x0024) }, /* Sierra Wireless MC5727 */ | 165 | { USB_DEVICE(0x1199, 0x0024) }, /* Sierra Wireless MC5727 */ |
169 | { USB_DEVICE(0x1199, 0x0220) }, /* Sierra Wireless MC5725 */ | 166 | { USB_DEVICE(0x1199, 0x0220) }, /* Sierra Wireless MC5725 */ |
@@ -175,6 +172,8 @@ static struct usb_device_id id_table [] = { | |||
175 | /* Sierra Wireless Device */ | 172 | /* Sierra Wireless Device */ |
176 | { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x0025, 0xFF, 0xFF, 0xFF) }, | 173 | { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x0025, 0xFF, 0xFF, 0xFF) }, |
177 | { USB_DEVICE(0x1199, 0x0026) }, /* Sierra Wireless Device */ | 174 | { USB_DEVICE(0x1199, 0x0026) }, /* Sierra Wireless Device */ |
175 | { USB_DEVICE(0x1199, 0x0027) }, /* Sierra Wireless Device */ | ||
176 | { USB_DEVICE(0x1199, 0x0028) }, /* Sierra Wireless Device */ | ||
178 | 177 | ||
179 | { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */ | 178 | { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */ |
180 | { USB_DEVICE(0x1199, 0x6804) }, /* Sierra Wireless MC8755 */ | 179 | { USB_DEVICE(0x1199, 0x6804) }, /* Sierra Wireless MC8755 */ |
@@ -187,6 +186,7 @@ static struct usb_device_id id_table [] = { | |||
187 | { USB_DEVICE(0x1199, 0x6821) }, /* Sierra Wireless AirCard 875U */ | 186 | { USB_DEVICE(0x1199, 0x6821) }, /* Sierra Wireless AirCard 875U */ |
188 | { USB_DEVICE(0x1199, 0x6832) }, /* Sierra Wireless MC8780 */ | 187 | { USB_DEVICE(0x1199, 0x6832) }, /* Sierra Wireless MC8780 */ |
189 | { USB_DEVICE(0x1199, 0x6833) }, /* Sierra Wireless MC8781 */ | 188 | { USB_DEVICE(0x1199, 0x6833) }, /* Sierra Wireless MC8781 */ |
189 | { USB_DEVICE(0x1199, 0x683A) }, /* Sierra Wireless MC8785 */ | ||
190 | { USB_DEVICE(0x1199, 0x683B) }, /* Sierra Wireless MC8785 Composite */ | 190 | { USB_DEVICE(0x1199, 0x683B) }, /* Sierra Wireless MC8785 Composite */ |
191 | { USB_DEVICE(0x1199, 0x683C) }, /* Sierra Wireless MC8790 */ | 191 | { USB_DEVICE(0x1199, 0x683C) }, /* Sierra Wireless MC8790 */ |
192 | { USB_DEVICE(0x1199, 0x683D) }, /* Sierra Wireless MC8790 */ | 192 | { USB_DEVICE(0x1199, 0x683D) }, /* Sierra Wireless MC8790 */ |
@@ -204,6 +204,8 @@ static struct usb_device_id id_table [] = { | |||
204 | /* Sierra Wireless Device */ | 204 | /* Sierra Wireless Device */ |
205 | { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x6890, 0xFF, 0xFF, 0xFF)}, | 205 | { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x6890, 0xFF, 0xFF, 0xFF)}, |
206 | /* Sierra Wireless Device */ | 206 | /* Sierra Wireless Device */ |
207 | { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x6891, 0xFF, 0xFF, 0xFF)}, | ||
208 | /* Sierra Wireless Device */ | ||
207 | { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x6892, 0xFF, 0xFF, 0xFF)}, | 209 | { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x6892, 0xFF, 0xFF, 0xFF)}, |
208 | 210 | ||
209 | { USB_DEVICE(0x1199, 0x0112) }, /* Sierra Wireless AirCard 580 */ | 211 | { USB_DEVICE(0x1199, 0x0112) }, /* Sierra Wireless AirCard 580 */ |
@@ -245,7 +247,7 @@ static int sierra_send_setup(struct tty_struct *tty, | |||
245 | struct sierra_port_private *portdata; | 247 | struct sierra_port_private *portdata; |
246 | __u16 interface = 0; | 248 | __u16 interface = 0; |
247 | 249 | ||
248 | dbg("%s", __func__); | 250 | dev_dbg(&port->dev, "%s", __func__); |
249 | 251 | ||
250 | portdata = usb_get_serial_port_data(port); | 252 | portdata = usb_get_serial_port_data(port); |
251 | 253 | ||
@@ -282,7 +284,7 @@ static int sierra_send_setup(struct tty_struct *tty, | |||
282 | static void sierra_set_termios(struct tty_struct *tty, | 284 | static void sierra_set_termios(struct tty_struct *tty, |
283 | struct usb_serial_port *port, struct ktermios *old_termios) | 285 | struct usb_serial_port *port, struct ktermios *old_termios) |
284 | { | 286 | { |
285 | dbg("%s", __func__); | 287 | dev_dbg(&port->dev, "%s", __func__); |
286 | tty_termios_copy_hw(tty->termios, old_termios); | 288 | tty_termios_copy_hw(tty->termios, old_termios); |
287 | sierra_send_setup(tty, port); | 289 | sierra_send_setup(tty, port); |
288 | } | 290 | } |
@@ -293,6 +295,7 @@ static int sierra_tiocmget(struct tty_struct *tty, struct file *file) | |||
293 | unsigned int value; | 295 | unsigned int value; |
294 | struct sierra_port_private *portdata; | 296 | struct sierra_port_private *portdata; |
295 | 297 | ||
298 | dev_dbg(&port->dev, "%s", __func__); | ||
296 | portdata = usb_get_serial_port_data(port); | 299 | portdata = usb_get_serial_port_data(port); |
297 | 300 | ||
298 | value = ((portdata->rts_state) ? TIOCM_RTS : 0) | | 301 | value = ((portdata->rts_state) ? TIOCM_RTS : 0) | |
@@ -332,14 +335,14 @@ static void sierra_outdat_callback(struct urb *urb) | |||
332 | int status = urb->status; | 335 | int status = urb->status; |
333 | unsigned long flags; | 336 | unsigned long flags; |
334 | 337 | ||
335 | dbg("%s - port %d", __func__, port->number); | 338 | dev_dbg(&port->dev, "%s - port %d", __func__, port->number); |
336 | 339 | ||
337 | /* free up the transfer buffer, as usb_free_urb() does not do this */ | 340 | /* free up the transfer buffer, as usb_free_urb() does not do this */ |
338 | kfree(urb->transfer_buffer); | 341 | kfree(urb->transfer_buffer); |
339 | 342 | ||
340 | if (status) | 343 | if (status) |
341 | dbg("%s - nonzero write bulk status received: %d", | 344 | dev_dbg(&port->dev, "%s - nonzero write bulk status " |
342 | __func__, status); | 345 | "received: %d", __func__, status); |
343 | 346 | ||
344 | spin_lock_irqsave(&portdata->lock, flags); | 347 | spin_lock_irqsave(&portdata->lock, flags); |
345 | --portdata->outstanding_urbs; | 348 | --portdata->outstanding_urbs; |
@@ -361,12 +364,12 @@ static int sierra_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
361 | 364 | ||
362 | portdata = usb_get_serial_port_data(port); | 365 | portdata = usb_get_serial_port_data(port); |
363 | 366 | ||
364 | dbg("%s: write (%d chars)", __func__, count); | 367 | dev_dbg(&port->dev, "%s: write (%d chars)", __func__, count); |
365 | 368 | ||
366 | spin_lock_irqsave(&portdata->lock, flags); | 369 | spin_lock_irqsave(&portdata->lock, flags); |
367 | if (portdata->outstanding_urbs > N_OUT_URB) { | 370 | if (portdata->outstanding_urbs > N_OUT_URB) { |
368 | spin_unlock_irqrestore(&portdata->lock, flags); | 371 | spin_unlock_irqrestore(&portdata->lock, flags); |
369 | dbg("%s - write limit hit\n", __func__); | 372 | dev_dbg(&port->dev, "%s - write limit hit\n", __func__); |
370 | return 0; | 373 | return 0; |
371 | } | 374 | } |
372 | portdata->outstanding_urbs++; | 375 | portdata->outstanding_urbs++; |
@@ -435,17 +438,18 @@ static void sierra_indat_callback(struct urb *urb) | |||
435 | port = urb->context; | 438 | port = urb->context; |
436 | 439 | ||
437 | if (status) { | 440 | if (status) { |
438 | dbg("%s: nonzero status: %d on endpoint %02x.", | 441 | dev_dbg(&port->dev, "%s: nonzero status: %d on" |
439 | __func__, status, endpoint); | 442 | " endpoint %02x.", __func__, status, endpoint); |
440 | } else { | 443 | } else { |
441 | tty = port->port.tty; | ||
442 | if (urb->actual_length) { | 444 | if (urb->actual_length) { |
445 | tty = tty_port_tty_get(&port->port); | ||
443 | tty_buffer_request_room(tty, urb->actual_length); | 446 | tty_buffer_request_room(tty, urb->actual_length); |
444 | tty_insert_flip_string(tty, data, urb->actual_length); | 447 | tty_insert_flip_string(tty, data, urb->actual_length); |
445 | tty_flip_buffer_push(tty); | 448 | tty_flip_buffer_push(tty); |
446 | } else { | 449 | tty_kref_put(tty); |
447 | dbg("%s: empty read urb received", __func__); | 450 | } else |
448 | } | 451 | dev_dbg(&port->dev, "%s: empty read urb" |
452 | " received", __func__); | ||
449 | 453 | ||
450 | /* Resubmit urb so we continue receiving */ | 454 | /* Resubmit urb so we continue receiving */ |
451 | if (port->port.count && status != -ESHUTDOWN) { | 455 | if (port->port.count && status != -ESHUTDOWN) { |
@@ -466,15 +470,17 @@ static void sierra_instat_callback(struct urb *urb) | |||
466 | struct sierra_port_private *portdata = usb_get_serial_port_data(port); | 470 | struct sierra_port_private *portdata = usb_get_serial_port_data(port); |
467 | struct usb_serial *serial = port->serial; | 471 | struct usb_serial *serial = port->serial; |
468 | 472 | ||
469 | dbg("%s", __func__); | 473 | dev_dbg(&port->dev, "%s", __func__); |
470 | dbg("%s: urb %p port %p has data %p", __func__, urb, port, portdata); | 474 | dev_dbg(&port->dev, "%s: urb %p port %p has data %p", __func__, |
475 | urb, port, portdata); | ||
471 | 476 | ||
472 | if (status == 0) { | 477 | if (status == 0) { |
473 | struct usb_ctrlrequest *req_pkt = | 478 | struct usb_ctrlrequest *req_pkt = |
474 | (struct usb_ctrlrequest *)urb->transfer_buffer; | 479 | (struct usb_ctrlrequest *)urb->transfer_buffer; |
475 | 480 | ||
476 | if (!req_pkt) { | 481 | if (!req_pkt) { |
477 | dbg("%s: NULL req_pkt\n", __func__); | 482 | dev_dbg(&port->dev, "%s: NULL req_pkt\n", |
483 | __func__); | ||
478 | return; | 484 | return; |
479 | } | 485 | } |
480 | if ((req_pkt->bRequestType == 0xA1) && | 486 | if ((req_pkt->bRequestType == 0xA1) && |
@@ -483,8 +489,10 @@ static void sierra_instat_callback(struct urb *urb) | |||
483 | unsigned char signals = *((unsigned char *) | 489 | unsigned char signals = *((unsigned char *) |
484 | urb->transfer_buffer + | 490 | urb->transfer_buffer + |
485 | sizeof(struct usb_ctrlrequest)); | 491 | sizeof(struct usb_ctrlrequest)); |
492 | struct tty_struct *tty; | ||
486 | 493 | ||
487 | dbg("%s: signal x%x", __func__, signals); | 494 | dev_dbg(&port->dev, "%s: signal x%x", __func__, |
495 | signals); | ||
488 | 496 | ||
489 | old_dcd_state = portdata->dcd_state; | 497 | old_dcd_state = portdata->dcd_state; |
490 | portdata->cts_state = 1; | 498 | portdata->cts_state = 1; |
@@ -492,23 +500,26 @@ static void sierra_instat_callback(struct urb *urb) | |||
492 | portdata->dsr_state = ((signals & 0x02) ? 1 : 0); | 500 | portdata->dsr_state = ((signals & 0x02) ? 1 : 0); |
493 | portdata->ri_state = ((signals & 0x08) ? 1 : 0); | 501 | portdata->ri_state = ((signals & 0x08) ? 1 : 0); |
494 | 502 | ||
495 | if (port->port.tty && !C_CLOCAL(port->port.tty) && | 503 | tty = tty_port_tty_get(&port->port); |
504 | if (tty && !C_CLOCAL(tty) && | ||
496 | old_dcd_state && !portdata->dcd_state) | 505 | old_dcd_state && !portdata->dcd_state) |
497 | tty_hangup(port->port.tty); | 506 | tty_hangup(tty); |
507 | tty_kref_put(tty); | ||
498 | } else { | 508 | } else { |
499 | dbg("%s: type %x req %x", __func__, | 509 | dev_dbg(&port->dev, "%s: type %x req %x", |
500 | req_pkt->bRequestType, req_pkt->bRequest); | 510 | __func__, req_pkt->bRequestType, |
511 | req_pkt->bRequest); | ||
501 | } | 512 | } |
502 | } else | 513 | } else |
503 | dbg("%s: error %d", __func__, status); | 514 | dev_dbg(&port->dev, "%s: error %d", __func__, status); |
504 | 515 | ||
505 | /* Resubmit urb so we continue receiving IRQ data */ | 516 | /* Resubmit urb so we continue receiving IRQ data */ |
506 | if (status != -ESHUTDOWN) { | 517 | if (status != -ESHUTDOWN) { |
507 | urb->dev = serial->dev; | 518 | urb->dev = serial->dev; |
508 | err = usb_submit_urb(urb, GFP_ATOMIC); | 519 | err = usb_submit_urb(urb, GFP_ATOMIC); |
509 | if (err) | 520 | if (err) |
510 | dbg("%s: resubmit intr urb failed. (%d)", | 521 | dev_dbg(&port->dev, "%s: resubmit intr urb " |
511 | __func__, err); | 522 | "failed. (%d)", __func__, err); |
512 | } | 523 | } |
513 | } | 524 | } |
514 | 525 | ||
@@ -518,14 +529,14 @@ static int sierra_write_room(struct tty_struct *tty) | |||
518 | struct sierra_port_private *portdata = usb_get_serial_port_data(port); | 529 | struct sierra_port_private *portdata = usb_get_serial_port_data(port); |
519 | unsigned long flags; | 530 | unsigned long flags; |
520 | 531 | ||
521 | dbg("%s - port %d", __func__, port->number); | 532 | dev_dbg(&port->dev, "%s - port %d", __func__, port->number); |
522 | 533 | ||
523 | /* try to give a good number back based on if we have any free urbs at | 534 | /* try to give a good number back based on if we have any free urbs at |
524 | * this point in time */ | 535 | * this point in time */ |
525 | spin_lock_irqsave(&portdata->lock, flags); | 536 | spin_lock_irqsave(&portdata->lock, flags); |
526 | if (portdata->outstanding_urbs > N_OUT_URB * 2 / 3) { | 537 | if (portdata->outstanding_urbs > N_OUT_URB * 2 / 3) { |
527 | spin_unlock_irqrestore(&portdata->lock, flags); | 538 | spin_unlock_irqrestore(&portdata->lock, flags); |
528 | dbg("%s - write limit hit\n", __func__); | 539 | dev_dbg(&port->dev, "%s - write limit hit\n", __func__); |
529 | return 0; | 540 | return 0; |
530 | } | 541 | } |
531 | spin_unlock_irqrestore(&portdata->lock, flags); | 542 | spin_unlock_irqrestore(&portdata->lock, flags); |
@@ -544,7 +555,7 @@ static int sierra_open(struct tty_struct *tty, | |||
544 | 555 | ||
545 | portdata = usb_get_serial_port_data(port); | 556 | portdata = usb_get_serial_port_data(port); |
546 | 557 | ||
547 | dbg("%s", __func__); | 558 | dev_dbg(&port->dev, "%s", __func__); |
548 | 559 | ||
549 | /* Set some sane defaults */ | 560 | /* Set some sane defaults */ |
550 | portdata->rts_state = 1; | 561 | portdata->rts_state = 1; |
@@ -556,8 +567,8 @@ static int sierra_open(struct tty_struct *tty, | |||
556 | if (!urb) | 567 | if (!urb) |
557 | continue; | 568 | continue; |
558 | if (urb->dev != serial->dev) { | 569 | if (urb->dev != serial->dev) { |
559 | dbg("%s: dev %p != %p", __func__, | 570 | dev_dbg(&port->dev, "%s: dev %p != %p", |
560 | urb->dev, serial->dev); | 571 | __func__, urb->dev, serial->dev); |
561 | continue; | 572 | continue; |
562 | } | 573 | } |
563 | 574 | ||
@@ -596,7 +607,7 @@ static void sierra_close(struct tty_struct *tty, | |||
596 | struct usb_serial *serial = port->serial; | 607 | struct usb_serial *serial = port->serial; |
597 | struct sierra_port_private *portdata; | 608 | struct sierra_port_private *portdata; |
598 | 609 | ||
599 | dbg("%s", __func__); | 610 | dev_dbg(&port->dev, "%s", __func__); |
600 | portdata = usb_get_serial_port_data(port); | 611 | portdata = usb_get_serial_port_data(port); |
601 | 612 | ||
602 | portdata->rts_state = 0; | 613 | portdata->rts_state = 0; |
@@ -614,8 +625,7 @@ static void sierra_close(struct tty_struct *tty, | |||
614 | } | 625 | } |
615 | 626 | ||
616 | usb_kill_urb(port->interrupt_in_urb); | 627 | usb_kill_urb(port->interrupt_in_urb); |
617 | 628 | tty_port_tty_set(&port->port, NULL); | |
618 | port->port.tty = NULL; /* FIXME */ | ||
619 | } | 629 | } |
620 | 630 | ||
621 | static int sierra_startup(struct usb_serial *serial) | 631 | static int sierra_startup(struct usb_serial *serial) |
@@ -626,7 +636,7 @@ static int sierra_startup(struct usb_serial *serial) | |||
626 | int i; | 636 | int i; |
627 | int j; | 637 | int j; |
628 | 638 | ||
629 | dbg("%s", __func__); | 639 | dev_dbg(&serial->dev->dev, "%s", __func__); |
630 | 640 | ||
631 | /* Set Device mode to D0 */ | 641 | /* Set Device mode to D0 */ |
632 | sierra_set_power_state(serial->dev, 0x0000); | 642 | sierra_set_power_state(serial->dev, 0x0000); |
@@ -640,8 +650,9 @@ static int sierra_startup(struct usb_serial *serial) | |||
640 | port = serial->port[i]; | 650 | port = serial->port[i]; |
641 | portdata = kzalloc(sizeof(*portdata), GFP_KERNEL); | 651 | portdata = kzalloc(sizeof(*portdata), GFP_KERNEL); |
642 | if (!portdata) { | 652 | if (!portdata) { |
643 | dbg("%s: kmalloc for sierra_port_private (%d) failed!.", | 653 | dev_dbg(&port->dev, "%s: kmalloc for " |
644 | __func__, i); | 654 | "sierra_port_private (%d) failed!.", |
655 | __func__, i); | ||
645 | return -ENOMEM; | 656 | return -ENOMEM; |
646 | } | 657 | } |
647 | spin_lock_init(&portdata->lock); | 658 | spin_lock_init(&portdata->lock); |
@@ -661,8 +672,8 @@ static int sierra_startup(struct usb_serial *serial) | |||
661 | for (j = 0; j < N_IN_URB; ++j) { | 672 | for (j = 0; j < N_IN_URB; ++j) { |
662 | urb = usb_alloc_urb(0, GFP_KERNEL); | 673 | urb = usb_alloc_urb(0, GFP_KERNEL); |
663 | if (urb == NULL) { | 674 | if (urb == NULL) { |
664 | dbg("%s: alloc for in port failed.", | 675 | dev_dbg(&port->dev, "%s: alloc for in " |
665 | __func__); | 676 | "port failed.", __func__); |
666 | continue; | 677 | continue; |
667 | } | 678 | } |
668 | /* Fill URB using supplied data. */ | 679 | /* Fill URB using supplied data. */ |
@@ -684,7 +695,7 @@ static void sierra_shutdown(struct usb_serial *serial) | |||
684 | struct usb_serial_port *port; | 695 | struct usb_serial_port *port; |
685 | struct sierra_port_private *portdata; | 696 | struct sierra_port_private *portdata; |
686 | 697 | ||
687 | dbg("%s", __func__); | 698 | dev_dbg(&serial->dev->dev, "%s", __func__); |
688 | 699 | ||
689 | for (i = 0; i < serial->num_ports; ++i) { | 700 | for (i = 0; i < serial->num_ports; ++i) { |
690 | port = serial->port[i]; | 701 | port = serial->port[i]; |
@@ -739,7 +750,8 @@ static int __init sierra_init(void) | |||
739 | if (retval) | 750 | if (retval) |
740 | goto failed_driver_register; | 751 | goto failed_driver_register; |
741 | 752 | ||
742 | info(DRIVER_DESC ": " DRIVER_VERSION); | 753 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
754 | DRIVER_DESC "\n"); | ||
743 | 755 | ||
744 | return 0; | 756 | return 0; |
745 | 757 | ||
diff --git a/drivers/usb/serial/spcp8x5.c b/drivers/usb/serial/spcp8x5.c index 283cf6b36b2c..a65bc2bd8e71 100644 --- a/drivers/usb/serial/spcp8x5.c +++ b/drivers/usb/serial/spcp8x5.c | |||
@@ -589,8 +589,8 @@ static void spcp8x5_set_termios(struct tty_struct *tty, | |||
589 | case 1000000: | 589 | case 1000000: |
590 | buf[0] = 0x0b; break; | 590 | buf[0] = 0x0b; break; |
591 | default: | 591 | default: |
592 | err("spcp825 driver does not support the baudrate " | 592 | dev_err(&port->dev, "spcp825 driver does not support the " |
593 | "requested, using default of 9600."); | 593 | "baudrate requested, using default of 9600.\n"); |
594 | } | 594 | } |
595 | 595 | ||
596 | /* Set Data Length : 00:5bit, 01:6bit, 10:7bit, 11:8bit */ | 596 | /* Set Data Length : 00:5bit, 01:6bit, 10:7bit, 11:8bit */ |
@@ -629,7 +629,8 @@ static void spcp8x5_set_termios(struct tty_struct *tty, | |||
629 | SET_UART_FORMAT_TYPE, SET_UART_FORMAT, | 629 | SET_UART_FORMAT_TYPE, SET_UART_FORMAT, |
630 | uartdata, 0, NULL, 0, 100); | 630 | uartdata, 0, NULL, 0, 100); |
631 | if (i < 0) | 631 | if (i < 0) |
632 | err("Set UART format %#x failed (error = %d)", uartdata, i); | 632 | dev_err(&port->dev, "Set UART format %#x failed (error = %d)\n", |
633 | uartdata, i); | ||
633 | dbg("0x21:0x40:0:0 %d\n", i); | 634 | dbg("0x21:0x40:0:0 %d\n", i); |
634 | 635 | ||
635 | if (cflag & CRTSCTS) { | 636 | if (cflag & CRTSCTS) { |
@@ -755,7 +756,7 @@ static void spcp8x5_read_bulk_callback(struct urb *urb) | |||
755 | tty_flag = TTY_FRAME; | 756 | tty_flag = TTY_FRAME; |
756 | dev_dbg(&port->dev, "tty_flag = %d\n", tty_flag); | 757 | dev_dbg(&port->dev, "tty_flag = %d\n", tty_flag); |
757 | 758 | ||
758 | tty = port->port.tty; | 759 | tty = tty_port_tty_get(&port->port); |
759 | if (tty && urb->actual_length) { | 760 | if (tty && urb->actual_length) { |
760 | tty_buffer_request_room(tty, urb->actual_length + 1); | 761 | tty_buffer_request_room(tty, urb->actual_length + 1); |
761 | /* overrun is special, not associated with a char */ | 762 | /* overrun is special, not associated with a char */ |
@@ -765,6 +766,7 @@ static void spcp8x5_read_bulk_callback(struct urb *urb) | |||
765 | tty_insert_flip_char(tty, data[i], tty_flag); | 766 | tty_insert_flip_char(tty, data[i], tty_flag); |
766 | tty_flip_buffer_push(tty); | 767 | tty_flip_buffer_push(tty); |
767 | } | 768 | } |
769 | tty_kref_put(tty); | ||
768 | 770 | ||
769 | /* Schedule the next read _if_ we are still open */ | 771 | /* Schedule the next read _if_ we are still open */ |
770 | if (port->port.count) { | 772 | if (port->port.count) { |
@@ -1053,7 +1055,8 @@ static int __init spcp8x5_init(void) | |||
1053 | retval = usb_register(&spcp8x5_driver); | 1055 | retval = usb_register(&spcp8x5_driver); |
1054 | if (retval) | 1056 | if (retval) |
1055 | goto failed_usb_register; | 1057 | goto failed_usb_register; |
1056 | info(DRIVER_DESC " " DRIVER_VERSION); | 1058 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
1059 | DRIVER_DESC "\n"); | ||
1057 | return 0; | 1060 | return 0; |
1058 | failed_usb_register: | 1061 | failed_usb_register: |
1059 | usb_serial_deregister(&spcp8x5_device); | 1062 | usb_serial_deregister(&spcp8x5_device); |
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c index e39c779e4160..31c42d1cae13 100644 --- a/drivers/usb/serial/ti_usb_3410_5052.c +++ b/drivers/usb/serial/ti_usb_3410_5052.c | |||
@@ -85,7 +85,6 @@ | |||
85 | #include <linux/uaccess.h> | 85 | #include <linux/uaccess.h> |
86 | #include <linux/usb.h> | 86 | #include <linux/usb.h> |
87 | #include <linux/usb/serial.h> | 87 | #include <linux/usb/serial.h> |
88 | #include <linux/firmware.h> | ||
89 | 88 | ||
90 | #include "ti_usb_3410_5052.h" | 89 | #include "ti_usb_3410_5052.h" |
91 | 90 | ||
@@ -179,7 +178,7 @@ static int ti_set_mcr(struct ti_port *tport, unsigned int mcr); | |||
179 | static int ti_get_lsr(struct ti_port *tport); | 178 | static int ti_get_lsr(struct ti_port *tport); |
180 | static int ti_get_serial_info(struct ti_port *tport, | 179 | static int ti_get_serial_info(struct ti_port *tport, |
181 | struct serial_struct __user *ret_arg); | 180 | struct serial_struct __user *ret_arg); |
182 | static int ti_set_serial_info(struct ti_port *tport, | 181 | static int ti_set_serial_info(struct tty_struct *tty, struct ti_port *tport, |
183 | struct serial_struct __user *new_arg); | 182 | struct serial_struct __user *new_arg); |
184 | static void ti_handle_new_msr(struct ti_port *tport, __u8 msr); | 183 | static void ti_handle_new_msr(struct ti_port *tport, __u8 msr); |
185 | 184 | ||
@@ -383,7 +382,8 @@ static int __init ti_init(void) | |||
383 | if (ret) | 382 | if (ret) |
384 | goto failed_usb; | 383 | goto failed_usb; |
385 | 384 | ||
386 | info(TI_DRIVER_DESC " " TI_DRIVER_VERSION); | 385 | printk(KERN_INFO KBUILD_MODNAME ": " TI_DRIVER_VERSION ":" |
386 | TI_DRIVER_DESC "\n"); | ||
387 | 387 | ||
388 | return 0; | 388 | return 0; |
389 | 389 | ||
@@ -857,8 +857,8 @@ static int ti_ioctl(struct tty_struct *tty, struct file *file, | |||
857 | (struct serial_struct __user *)arg); | 857 | (struct serial_struct __user *)arg); |
858 | case TIOCSSERIAL: | 858 | case TIOCSSERIAL: |
859 | dbg("%s - (%d) TIOCSSERIAL", __func__, port->number); | 859 | dbg("%s - (%d) TIOCSSERIAL", __func__, port->number); |
860 | return ti_set_serial_info(tport, | 860 | return ti_set_serial_info(tty, tport, |
861 | (struct serial_struct __user *)arg); | 861 | (struct serial_struct __user *)arg); |
862 | case TIOCMIWAIT: | 862 | case TIOCMIWAIT: |
863 | dbg("%s - (%d) TIOCMIWAIT", __func__, port->number); | 863 | dbg("%s - (%d) TIOCMIWAIT", __func__, port->number); |
864 | cprev = tport->tp_icount; | 864 | cprev = tport->tp_icount; |
@@ -1211,6 +1211,7 @@ static void ti_bulk_in_callback(struct urb *urb) | |||
1211 | struct device *dev = &urb->dev->dev; | 1211 | struct device *dev = &urb->dev->dev; |
1212 | int status = urb->status; | 1212 | int status = urb->status; |
1213 | int retval = 0; | 1213 | int retval = 0; |
1214 | struct tty_struct *tty; | ||
1214 | 1215 | ||
1215 | dbg("%s", __func__); | 1216 | dbg("%s", __func__); |
1216 | 1217 | ||
@@ -1239,20 +1240,22 @@ static void ti_bulk_in_callback(struct urb *urb) | |||
1239 | return; | 1240 | return; |
1240 | } | 1241 | } |
1241 | 1242 | ||
1242 | if (port->port.tty && urb->actual_length) { | 1243 | tty = tty_port_tty_get(&port->port); |
1244 | if (tty && urb->actual_length) { | ||
1243 | usb_serial_debug_data(debug, dev, __func__, | 1245 | usb_serial_debug_data(debug, dev, __func__, |
1244 | urb->actual_length, urb->transfer_buffer); | 1246 | urb->actual_length, urb->transfer_buffer); |
1245 | 1247 | ||
1246 | if (!tport->tp_is_open) | 1248 | if (!tport->tp_is_open) |
1247 | dbg("%s - port closed, dropping data", __func__); | 1249 | dbg("%s - port closed, dropping data", __func__); |
1248 | else | 1250 | else |
1249 | ti_recv(&urb->dev->dev, port->port.tty, | 1251 | ti_recv(&urb->dev->dev, tty, |
1250 | urb->transfer_buffer, | 1252 | urb->transfer_buffer, |
1251 | urb->actual_length); | 1253 | urb->actual_length); |
1252 | 1254 | ||
1253 | spin_lock(&tport->tp_lock); | 1255 | spin_lock(&tport->tp_lock); |
1254 | tport->tp_icount.rx += urb->actual_length; | 1256 | tport->tp_icount.rx += urb->actual_length; |
1255 | spin_unlock(&tport->tp_lock); | 1257 | spin_unlock(&tport->tp_lock); |
1258 | tty_kref_put(tty); | ||
1256 | } | 1259 | } |
1257 | 1260 | ||
1258 | exit: | 1261 | exit: |
@@ -1330,7 +1333,7 @@ static void ti_send(struct ti_port *tport) | |||
1330 | { | 1333 | { |
1331 | int count, result; | 1334 | int count, result; |
1332 | struct usb_serial_port *port = tport->tp_port; | 1335 | struct usb_serial_port *port = tport->tp_port; |
1333 | struct tty_struct *tty = port->port.tty; /* FIXME */ | 1336 | struct tty_struct *tty = tty_port_tty_get(&port->port); /* FIXME */ |
1334 | unsigned long flags; | 1337 | unsigned long flags; |
1335 | 1338 | ||
1336 | 1339 | ||
@@ -1338,19 +1341,15 @@ static void ti_send(struct ti_port *tport) | |||
1338 | 1341 | ||
1339 | spin_lock_irqsave(&tport->tp_lock, flags); | 1342 | spin_lock_irqsave(&tport->tp_lock, flags); |
1340 | 1343 | ||
1341 | if (tport->tp_write_urb_in_use) { | 1344 | if (tport->tp_write_urb_in_use) |
1342 | spin_unlock_irqrestore(&tport->tp_lock, flags); | 1345 | goto unlock; |
1343 | return; | ||
1344 | } | ||
1345 | 1346 | ||
1346 | count = ti_buf_get(tport->tp_write_buf, | 1347 | count = ti_buf_get(tport->tp_write_buf, |
1347 | port->write_urb->transfer_buffer, | 1348 | port->write_urb->transfer_buffer, |
1348 | port->bulk_out_size); | 1349 | port->bulk_out_size); |
1349 | 1350 | ||
1350 | if (count == 0) { | 1351 | if (count == 0) |
1351 | spin_unlock_irqrestore(&tport->tp_lock, flags); | 1352 | goto unlock; |
1352 | return; | ||
1353 | } | ||
1354 | 1353 | ||
1355 | tport->tp_write_urb_in_use = 1; | 1354 | tport->tp_write_urb_in_use = 1; |
1356 | 1355 | ||
@@ -1380,7 +1379,13 @@ static void ti_send(struct ti_port *tport) | |||
1380 | /* more room in the buffer for new writes, wakeup */ | 1379 | /* more room in the buffer for new writes, wakeup */ |
1381 | if (tty) | 1380 | if (tty) |
1382 | tty_wakeup(tty); | 1381 | tty_wakeup(tty); |
1382 | tty_kref_put(tty); | ||
1383 | wake_up_interruptible(&tport->tp_write_wait); | 1383 | wake_up_interruptible(&tport->tp_write_wait); |
1384 | return; | ||
1385 | unlock: | ||
1386 | spin_unlock_irqrestore(&tport->tp_lock, flags); | ||
1387 | tty_kref_put(tty); | ||
1388 | return; | ||
1384 | } | 1389 | } |
1385 | 1390 | ||
1386 | 1391 | ||
@@ -1464,20 +1469,16 @@ static int ti_get_serial_info(struct ti_port *tport, | |||
1464 | } | 1469 | } |
1465 | 1470 | ||
1466 | 1471 | ||
1467 | static int ti_set_serial_info(struct ti_port *tport, | 1472 | static int ti_set_serial_info(struct tty_struct *tty, struct ti_port *tport, |
1468 | struct serial_struct __user *new_arg) | 1473 | struct serial_struct __user *new_arg) |
1469 | { | 1474 | { |
1470 | struct usb_serial_port *port = tport->tp_port; | ||
1471 | struct serial_struct new_serial; | 1475 | struct serial_struct new_serial; |
1472 | 1476 | ||
1473 | if (copy_from_user(&new_serial, new_arg, sizeof(new_serial))) | 1477 | if (copy_from_user(&new_serial, new_arg, sizeof(new_serial))) |
1474 | return -EFAULT; | 1478 | return -EFAULT; |
1475 | 1479 | ||
1476 | tport->tp_flags = new_serial.flags & TI_SET_SERIAL_FLAGS; | 1480 | tport->tp_flags = new_serial.flags & TI_SET_SERIAL_FLAGS; |
1477 | /* FIXME */ | 1481 | tty->low_latency = (tport->tp_flags & ASYNC_LOW_LATENCY) ? 1 : 0; |
1478 | if (port->port.tty) | ||
1479 | port->port.tty->low_latency = | ||
1480 | (tport->tp_flags & ASYNC_LOW_LATENCY) ? 1 : 0; | ||
1481 | tport->tp_closing_wait = new_serial.closing_wait; | 1482 | tport->tp_closing_wait = new_serial.closing_wait; |
1482 | 1483 | ||
1483 | return 0; | 1484 | return 0; |
@@ -1510,7 +1511,7 @@ static void ti_handle_new_msr(struct ti_port *tport, __u8 msr) | |||
1510 | tport->tp_msr = msr & TI_MSR_MASK; | 1511 | tport->tp_msr = msr & TI_MSR_MASK; |
1511 | 1512 | ||
1512 | /* handle CTS flow control */ | 1513 | /* handle CTS flow control */ |
1513 | tty = tport->tp_port->port.tty; | 1514 | tty = tty_port_tty_get(&tport->tp_port->port); |
1514 | if (tty && C_CRTSCTS(tty)) { | 1515 | if (tty && C_CRTSCTS(tty)) { |
1515 | if (msr & TI_MSR_CTS) { | 1516 | if (msr & TI_MSR_CTS) { |
1516 | tty->hw_stopped = 0; | 1517 | tty->hw_stopped = 0; |
@@ -1519,6 +1520,7 @@ static void ti_handle_new_msr(struct ti_port *tport, __u8 msr) | |||
1519 | tty->hw_stopped = 1; | 1520 | tty->hw_stopped = 1; |
1520 | } | 1521 | } |
1521 | } | 1522 | } |
1523 | tty_kref_put(tty); | ||
1522 | } | 1524 | } |
1523 | 1525 | ||
1524 | 1526 | ||
@@ -1744,7 +1746,7 @@ static int ti_download_firmware(struct ti_device *tdev, int type) | |||
1744 | if (buffer) { | 1746 | if (buffer) { |
1745 | memcpy(buffer, fw_p->data, fw_p->size); | 1747 | memcpy(buffer, fw_p->data, fw_p->size); |
1746 | memset(buffer + fw_p->size, 0xff, buffer_size - fw_p->size); | 1748 | memset(buffer + fw_p->size, 0xff, buffer_size - fw_p->size); |
1747 | ti_do_download(dev, pipe, buffer, fw_p->size); | 1749 | status = ti_do_download(dev, pipe, buffer, fw_p->size); |
1748 | kfree(buffer); | 1750 | kfree(buffer); |
1749 | } | 1751 | } |
1750 | release_firmware(fw_p); | 1752 | release_firmware(fw_p); |
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index b157c48e8b78..8be3f39891c7 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c | |||
@@ -214,7 +214,7 @@ static int serial_open (struct tty_struct *tty, struct file *filp) | |||
214 | /* set up our port structure making the tty driver | 214 | /* set up our port structure making the tty driver |
215 | * remember our port object, and us it */ | 215 | * remember our port object, and us it */ |
216 | tty->driver_data = port; | 216 | tty->driver_data = port; |
217 | port->port.tty = tty; | 217 | tty_port_tty_set(&port->port, tty); |
218 | 218 | ||
219 | if (port->port.count == 1) { | 219 | if (port->port.count == 1) { |
220 | 220 | ||
@@ -246,7 +246,7 @@ bailout_module_put: | |||
246 | bailout_mutex_unlock: | 246 | bailout_mutex_unlock: |
247 | port->port.count = 0; | 247 | port->port.count = 0; |
248 | tty->driver_data = NULL; | 248 | tty->driver_data = NULL; |
249 | port->port.tty = NULL; | 249 | tty_port_tty_set(&port->port, NULL); |
250 | mutex_unlock(&port->mutex); | 250 | mutex_unlock(&port->mutex); |
251 | bailout_kref_put: | 251 | bailout_kref_put: |
252 | usb_serial_put(serial); | 252 | usb_serial_put(serial); |
@@ -276,10 +276,11 @@ static void serial_close(struct tty_struct *tty, struct file *filp) | |||
276 | port->serial->type->close(tty, port, filp); | 276 | port->serial->type->close(tty, port, filp); |
277 | 277 | ||
278 | if (port->port.count == (port->console? 1 : 0)) { | 278 | if (port->port.count == (port->console? 1 : 0)) { |
279 | if (port->port.tty) { | 279 | struct tty_struct *tty = tty_port_tty_get(&port->port); |
280 | if (port->port.tty->driver_data) | 280 | if (tty) { |
281 | port->port.tty->driver_data = NULL; | 281 | if (tty->driver_data) |
282 | port->port.tty = NULL; | 282 | tty->driver_data = NULL; |
283 | tty_port_tty_set(&port->port, NULL); | ||
283 | } | 284 | } |
284 | } | 285 | } |
285 | 286 | ||
@@ -508,11 +509,12 @@ static void usb_serial_port_work(struct work_struct *work) | |||
508 | if (!port) | 509 | if (!port) |
509 | return; | 510 | return; |
510 | 511 | ||
511 | tty = port->port.tty; | 512 | tty = tty_port_tty_get(&port->port); |
512 | if (!tty) | 513 | if (!tty) |
513 | return; | 514 | return; |
514 | 515 | ||
515 | tty_wakeup(tty); | 516 | tty_wakeup(tty); |
517 | tty_kref_put(tty); | ||
516 | } | 518 | } |
517 | 519 | ||
518 | static void port_release(struct device *dev) | 520 | static void port_release(struct device *dev) |
@@ -733,7 +735,9 @@ int usb_serial_probe(struct usb_interface *interface, | |||
733 | ((le16_to_cpu(dev->descriptor.idVendor) == ATEN_VENDOR_ID) && | 735 | ((le16_to_cpu(dev->descriptor.idVendor) == ATEN_VENDOR_ID) && |
734 | (le16_to_cpu(dev->descriptor.idProduct) == ATEN_PRODUCT_ID)) || | 736 | (le16_to_cpu(dev->descriptor.idProduct) == ATEN_PRODUCT_ID)) || |
735 | ((le16_to_cpu(dev->descriptor.idVendor) == ALCOR_VENDOR_ID) && | 737 | ((le16_to_cpu(dev->descriptor.idVendor) == ALCOR_VENDOR_ID) && |
736 | (le16_to_cpu(dev->descriptor.idProduct) == ALCOR_PRODUCT_ID))) { | 738 | (le16_to_cpu(dev->descriptor.idProduct) == ALCOR_PRODUCT_ID)) || |
739 | ((le16_to_cpu(dev->descriptor.idVendor) == SIEMENS_VENDOR_ID) && | ||
740 | (le16_to_cpu(dev->descriptor.idProduct) == SIEMENS_PRODUCT_ID_EF81))) { | ||
737 | if (interface != dev->actconfig->interface[0]) { | 741 | if (interface != dev->actconfig->interface[0]) { |
738 | /* check out the endpoints of the other interface*/ | 742 | /* check out the endpoints of the other interface*/ |
739 | iface_desc = dev->actconfig->interface[0]->cur_altsetting; | 743 | iface_desc = dev->actconfig->interface[0]->cur_altsetting; |
@@ -817,6 +821,7 @@ int usb_serial_probe(struct usb_interface *interface, | |||
817 | port = kzalloc(sizeof(struct usb_serial_port), GFP_KERNEL); | 821 | port = kzalloc(sizeof(struct usb_serial_port), GFP_KERNEL); |
818 | if (!port) | 822 | if (!port) |
819 | goto probe_error; | 823 | goto probe_error; |
824 | tty_port_init(&port->port); | ||
820 | port->serial = serial; | 825 | port->serial = serial; |
821 | spin_lock_init(&port->lock); | 826 | spin_lock_init(&port->lock); |
822 | mutex_init(&port->mutex); | 827 | mutex_init(&port->mutex); |
@@ -1038,8 +1043,11 @@ void usb_serial_disconnect(struct usb_interface *interface) | |||
1038 | for (i = 0; i < serial->num_ports; ++i) { | 1043 | for (i = 0; i < serial->num_ports; ++i) { |
1039 | port = serial->port[i]; | 1044 | port = serial->port[i]; |
1040 | if (port) { | 1045 | if (port) { |
1041 | if (port->port.tty) | 1046 | struct tty_struct *tty = tty_port_tty_get(&port->port); |
1042 | tty_hangup(port->port.tty); | 1047 | if (tty) { |
1048 | tty_hangup(tty); | ||
1049 | tty_kref_put(tty); | ||
1050 | } | ||
1043 | kill_traffic(port); | 1051 | kill_traffic(port); |
1044 | } | 1052 | } |
1045 | } | 1053 | } |
@@ -1113,7 +1121,8 @@ static int __init usb_serial_init(void) | |||
1113 | 1121 | ||
1114 | result = bus_register(&usb_serial_bus_type); | 1122 | result = bus_register(&usb_serial_bus_type); |
1115 | if (result) { | 1123 | if (result) { |
1116 | err("%s - registering bus driver failed", __func__); | 1124 | printk(KERN_ERR "usb-serial: %s - registering bus driver " |
1125 | "failed\n", __func__); | ||
1117 | goto exit_bus; | 1126 | goto exit_bus; |
1118 | } | 1127 | } |
1119 | 1128 | ||
@@ -1134,25 +1143,28 @@ static int __init usb_serial_init(void) | |||
1134 | tty_set_operations(usb_serial_tty_driver, &serial_ops); | 1143 | tty_set_operations(usb_serial_tty_driver, &serial_ops); |
1135 | result = tty_register_driver(usb_serial_tty_driver); | 1144 | result = tty_register_driver(usb_serial_tty_driver); |
1136 | if (result) { | 1145 | if (result) { |
1137 | err("%s - tty_register_driver failed", __func__); | 1146 | printk(KERN_ERR "usb-serial: %s - tty_register_driver failed\n", |
1147 | __func__); | ||
1138 | goto exit_reg_driver; | 1148 | goto exit_reg_driver; |
1139 | } | 1149 | } |
1140 | 1150 | ||
1141 | /* register the USB driver */ | 1151 | /* register the USB driver */ |
1142 | result = usb_register(&usb_serial_driver); | 1152 | result = usb_register(&usb_serial_driver); |
1143 | if (result < 0) { | 1153 | if (result < 0) { |
1144 | err("%s - usb_register failed", __func__); | 1154 | printk(KERN_ERR "usb-serial: %s - usb_register failed\n", |
1155 | __func__); | ||
1145 | goto exit_tty; | 1156 | goto exit_tty; |
1146 | } | 1157 | } |
1147 | 1158 | ||
1148 | /* register the generic driver, if we should */ | 1159 | /* register the generic driver, if we should */ |
1149 | result = usb_serial_generic_register(debug); | 1160 | result = usb_serial_generic_register(debug); |
1150 | if (result < 0) { | 1161 | if (result < 0) { |
1151 | err("%s - registering generic driver failed", __func__); | 1162 | printk(KERN_ERR "usb-serial: %s - registering generic " |
1163 | "driver failed\n", __func__); | ||
1152 | goto exit_generic; | 1164 | goto exit_generic; |
1153 | } | 1165 | } |
1154 | 1166 | ||
1155 | info(DRIVER_DESC); | 1167 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_DESC "\n"); |
1156 | 1168 | ||
1157 | return result; | 1169 | return result; |
1158 | 1170 | ||
@@ -1166,7 +1178,8 @@ exit_reg_driver: | |||
1166 | bus_unregister(&usb_serial_bus_type); | 1178 | bus_unregister(&usb_serial_bus_type); |
1167 | 1179 | ||
1168 | exit_bus: | 1180 | exit_bus: |
1169 | err("%s - returning with error %d", __func__, result); | 1181 | printk(KERN_ERR "usb-serial: %s - returning with error %d\n", |
1182 | __func__, result); | ||
1170 | put_tty_driver(usb_serial_tty_driver); | 1183 | put_tty_driver(usb_serial_tty_driver); |
1171 | return result; | 1184 | return result; |
1172 | } | 1185 | } |
@@ -1225,11 +1238,11 @@ int usb_serial_register(struct usb_serial_driver *driver) | |||
1225 | 1238 | ||
1226 | retval = usb_serial_bus_register(driver); | 1239 | retval = usb_serial_bus_register(driver); |
1227 | if (retval) { | 1240 | if (retval) { |
1228 | err("problem %d when registering driver %s", | 1241 | printk(KERN_ERR "usb-serial: problem %d when registering " |
1229 | retval, driver->description); | 1242 | "driver %s\n", retval, driver->description); |
1230 | list_del(&driver->driver_list); | 1243 | list_del(&driver->driver_list); |
1231 | } else | 1244 | } else |
1232 | info("USB Serial support registered for %s", | 1245 | printk(KERN_INFO "USB Serial support registered for %s\n", |
1233 | driver->description); | 1246 | driver->description); |
1234 | 1247 | ||
1235 | return retval; | 1248 | return retval; |
@@ -1240,7 +1253,8 @@ EXPORT_SYMBOL_GPL(usb_serial_register); | |||
1240 | void usb_serial_deregister(struct usb_serial_driver *device) | 1253 | void usb_serial_deregister(struct usb_serial_driver *device) |
1241 | { | 1254 | { |
1242 | /* must be called with BKL held */ | 1255 | /* must be called with BKL held */ |
1243 | info("USB Serial deregistering driver %s", device->description); | 1256 | printk(KERN_INFO "USB Serial deregistering driver %s\n", |
1257 | device->description); | ||
1244 | list_del(&device->driver_list); | 1258 | list_del(&device->driver_list); |
1245 | usb_serial_bus_deregister(device); | 1259 | usb_serial_bus_deregister(device); |
1246 | } | 1260 | } |
diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c index cf8924f9a2cc..4facce3d9364 100644 --- a/drivers/usb/serial/visor.c +++ b/drivers/usb/serial/visor.c | |||
@@ -499,7 +499,7 @@ static void visor_read_bulk_callback(struct urb *urb) | |||
499 | int status = urb->status; | 499 | int status = urb->status; |
500 | struct tty_struct *tty; | 500 | struct tty_struct *tty; |
501 | int result; | 501 | int result; |
502 | int available_room; | 502 | int available_room = 0; |
503 | 503 | ||
504 | dbg("%s - port %d", __func__, port->number); | 504 | dbg("%s - port %d", __func__, port->number); |
505 | 505 | ||
@@ -512,13 +512,17 @@ static void visor_read_bulk_callback(struct urb *urb) | |||
512 | usb_serial_debug_data(debug, &port->dev, __func__, | 512 | usb_serial_debug_data(debug, &port->dev, __func__, |
513 | urb->actual_length, data); | 513 | urb->actual_length, data); |
514 | 514 | ||
515 | tty = port->port.tty; | 515 | if (urb->actual_length) { |
516 | if (tty && urb->actual_length) { | 516 | tty = tty_port_tty_get(&port->port); |
517 | available_room = tty_buffer_request_room(tty, | 517 | if (tty) { |
518 | available_room = tty_buffer_request_room(tty, | ||
518 | urb->actual_length); | 519 | urb->actual_length); |
519 | if (available_room) { | 520 | if (available_room) { |
520 | tty_insert_flip_string(tty, data, available_room); | 521 | tty_insert_flip_string(tty, data, |
521 | tty_flip_buffer_push(tty); | 522 | available_room); |
523 | tty_flip_buffer_push(tty); | ||
524 | } | ||
525 | tty_kref_put(tty); | ||
522 | } | 526 | } |
523 | spin_lock(&priv->lock); | 527 | spin_lock(&priv->lock); |
524 | priv->bytes_in += available_room; | 528 | priv->bytes_in += available_room; |
@@ -764,7 +768,7 @@ static int visor_probe(struct usb_serial *serial, | |||
764 | dbg("%s", __func__); | 768 | dbg("%s", __func__); |
765 | 769 | ||
766 | if (serial->dev->actconfig->desc.bConfigurationValue != 1) { | 770 | if (serial->dev->actconfig->desc.bConfigurationValue != 1) { |
767 | err("active config #%d != 1 ??", | 771 | dev_err(&serial->dev->dev, "active config #%d != 1 ??\n", |
768 | serial->dev->actconfig->desc.bConfigurationValue); | 772 | serial->dev->actconfig->desc.bConfigurationValue); |
769 | return -ENODEV; | 773 | return -ENODEV; |
770 | } | 774 | } |
@@ -967,11 +971,14 @@ static int __init visor_init(void) | |||
967 | break; | 971 | break; |
968 | } | 972 | } |
969 | } | 973 | } |
970 | info( | 974 | printk(KERN_INFO KBUILD_MODNAME |
971 | "Untested USB device specified at time of module insertion"); | 975 | ": Untested USB device specified at time of module insertion\n"); |
972 | info("Warning: This is not guaranteed to work"); | 976 | printk(KERN_INFO KBUILD_MODNAME |
973 | info("Using a newer kernel is preferred to this method"); | 977 | ": Warning: This is not guaranteed to work\n"); |
974 | info("Adding Palm OS protocol 4.x support for unknown device: 0x%x/0x%x", | 978 | printk(KERN_INFO KBUILD_MODNAME |
979 | ": Using a newer kernel is preferred to this method\n"); | ||
980 | printk(KERN_INFO KBUILD_MODNAME | ||
981 | ": Adding Palm OS protocol 4.x support for unknown device: 0x%x/0x%x\n", | ||
975 | vendor, product); | 982 | vendor, product); |
976 | } | 983 | } |
977 | retval = usb_serial_register(&handspring_device); | 984 | retval = usb_serial_register(&handspring_device); |
@@ -986,7 +993,7 @@ static int __init visor_init(void) | |||
986 | retval = usb_register(&visor_driver); | 993 | retval = usb_register(&visor_driver); |
987 | if (retval) | 994 | if (retval) |
988 | goto failed_usb_register; | 995 | goto failed_usb_register; |
989 | info(DRIVER_DESC); | 996 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_DESC "\n"); |
990 | 997 | ||
991 | return 0; | 998 | return 0; |
992 | failed_usb_register: | 999 | failed_usb_register: |
diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c index 3a9d14384a43..5335d3211c07 100644 --- a/drivers/usb/serial/whiteheat.c +++ b/drivers/usb/serial/whiteheat.c | |||
@@ -303,12 +303,15 @@ static int whiteheat_firmware_download(struct usb_serial *serial, | |||
303 | 303 | ||
304 | if (request_ihex_firmware(&firmware_fw, "whiteheat.fw", | 304 | if (request_ihex_firmware(&firmware_fw, "whiteheat.fw", |
305 | &serial->dev->dev)) { | 305 | &serial->dev->dev)) { |
306 | err("%s - request \"whiteheat.fw\" failed", __func__); | 306 | dev_err(&serial->dev->dev, |
307 | "%s - request \"whiteheat.fw\" failed\n", __func__); | ||
307 | goto out; | 308 | goto out; |
308 | } | 309 | } |
309 | if (request_ihex_firmware(&loader_fw, "whiteheat_loader.fw", | 310 | if (request_ihex_firmware(&loader_fw, "whiteheat_loader.fw", |
310 | &serial->dev->dev)) { | 311 | &serial->dev->dev)) { |
311 | err("%s - request \"whiteheat_loader.fw\" failed", __func__); | 312 | dev_err(&serial->dev->dev, |
313 | "%s - request \"whiteheat_loader.fw\" failed\n", | ||
314 | __func__); | ||
312 | goto out; | 315 | goto out; |
313 | } | 316 | } |
314 | ret = 0; | 317 | ret = 0; |
@@ -320,9 +323,10 @@ static int whiteheat_firmware_download(struct usb_serial *serial, | |||
320 | (unsigned char *)record->data, | 323 | (unsigned char *)record->data, |
321 | be16_to_cpu(record->len), 0xa0); | 324 | be16_to_cpu(record->len), 0xa0); |
322 | if (response < 0) { | 325 | if (response < 0) { |
323 | err("%s - ezusb_writememory failed for loader (%d %04X %p %d)", | 326 | dev_err(&serial->dev->dev, "%s - ezusb_writememory " |
324 | __func__, response, be32_to_cpu(record->addr), | 327 | "failed for loader (%d %04X %p %d)\n", |
325 | record->data, be16_to_cpu(record->len)); | 328 | __func__, response, be32_to_cpu(record->addr), |
329 | record->data, be16_to_cpu(record->len)); | ||
326 | break; | 330 | break; |
327 | } | 331 | } |
328 | record = ihex_next_binrec(record); | 332 | record = ihex_next_binrec(record); |
@@ -338,9 +342,11 @@ static int whiteheat_firmware_download(struct usb_serial *serial, | |||
338 | (unsigned char *)record->data, | 342 | (unsigned char *)record->data, |
339 | be16_to_cpu(record->len), 0xa3); | 343 | be16_to_cpu(record->len), 0xa3); |
340 | if (response < 0) { | 344 | if (response < 0) { |
341 | err("%s - ezusb_writememory failed for first firmware step (%d %04X %p %d)", | 345 | dev_err(&serial->dev->dev, "%s - ezusb_writememory " |
342 | __func__, response, be32_to_cpu(record->addr), | 346 | "failed for first firmware step " |
343 | record->data, be16_to_cpu(record->len)); | 347 | "(%d %04X %p %d)\n", __func__, response, |
348 | be32_to_cpu(record->addr), record->data, | ||
349 | be16_to_cpu(record->len)); | ||
344 | break; | 350 | break; |
345 | } | 351 | } |
346 | ++record; | 352 | ++record; |
@@ -354,9 +360,11 @@ static int whiteheat_firmware_download(struct usb_serial *serial, | |||
354 | (unsigned char *)record->data, | 360 | (unsigned char *)record->data, |
355 | be16_to_cpu(record->len), 0xa0); | 361 | be16_to_cpu(record->len), 0xa0); |
356 | if (response < 0) { | 362 | if (response < 0) { |
357 | err("%s - ezusb_writememory failed for second firmware step (%d %04X %p %d)", | 363 | dev_err(&serial->dev->dev, "%s - ezusb_writememory " |
358 | __func__, response, be32_to_cpu(record->addr), | 364 | "failed for second firmware step " |
359 | record->data, be16_to_cpu(record->len)); | 365 | "(%d %04X %p %d)\n", __func__, response, |
366 | be32_to_cpu(record->addr), record->data, | ||
367 | be16_to_cpu(record->len)); | ||
360 | break; | 368 | break; |
361 | } | 369 | } |
362 | ++record; | 370 | ++record; |
@@ -421,12 +429,12 @@ static int whiteheat_attach(struct usb_serial *serial) | |||
421 | ret = usb_bulk_msg(serial->dev, pipe, command, 2, | 429 | ret = usb_bulk_msg(serial->dev, pipe, command, 2, |
422 | &alen, COMMAND_TIMEOUT_MS); | 430 | &alen, COMMAND_TIMEOUT_MS); |
423 | if (ret) { | 431 | if (ret) { |
424 | err("%s: Couldn't send command [%d]", | 432 | dev_err(&serial->dev->dev, "%s: Couldn't send command [%d]\n", |
425 | serial->type->description, ret); | 433 | serial->type->description, ret); |
426 | goto no_firmware; | 434 | goto no_firmware; |
427 | } else if (alen != 2) { | 435 | } else if (alen != 2) { |
428 | err("%s: Send command incomplete [%d]", | 436 | dev_err(&serial->dev->dev, "%s: Send command incomplete [%d]\n", |
429 | serial->type->description, alen); | 437 | serial->type->description, alen); |
430 | goto no_firmware; | 438 | goto no_firmware; |
431 | } | 439 | } |
432 | 440 | ||
@@ -437,31 +445,33 @@ static int whiteheat_attach(struct usb_serial *serial) | |||
437 | ret = usb_bulk_msg(serial->dev, pipe, result, | 445 | ret = usb_bulk_msg(serial->dev, pipe, result, |
438 | sizeof(*hw_info) + 1, &alen, COMMAND_TIMEOUT_MS); | 446 | sizeof(*hw_info) + 1, &alen, COMMAND_TIMEOUT_MS); |
439 | if (ret) { | 447 | if (ret) { |
440 | err("%s: Couldn't get results [%d]", | 448 | dev_err(&serial->dev->dev, "%s: Couldn't get results [%d]\n", |
441 | serial->type->description, ret); | 449 | serial->type->description, ret); |
442 | goto no_firmware; | 450 | goto no_firmware; |
443 | } else if (alen != sizeof(*hw_info) + 1) { | 451 | } else if (alen != sizeof(*hw_info) + 1) { |
444 | err("%s: Get results incomplete [%d]", | 452 | dev_err(&serial->dev->dev, "%s: Get results incomplete [%d]\n", |
445 | serial->type->description, alen); | 453 | serial->type->description, alen); |
446 | goto no_firmware; | 454 | goto no_firmware; |
447 | } else if (result[0] != command[0]) { | 455 | } else if (result[0] != command[0]) { |
448 | err("%s: Command failed [%d]", | 456 | dev_err(&serial->dev->dev, "%s: Command failed [%d]\n", |
449 | serial->type->description, result[0]); | 457 | serial->type->description, result[0]); |
450 | goto no_firmware; | 458 | goto no_firmware; |
451 | } | 459 | } |
452 | 460 | ||
453 | hw_info = (struct whiteheat_hw_info *)&result[1]; | 461 | hw_info = (struct whiteheat_hw_info *)&result[1]; |
454 | 462 | ||
455 | info("%s: Driver %s: Firmware v%d.%02d", serial->type->description, | 463 | dev_info(&serial->dev->dev, "%s: Driver %s: Firmware v%d.%02d\n", |
456 | DRIVER_VERSION, hw_info->sw_major_rev, hw_info->sw_minor_rev); | 464 | serial->type->description, DRIVER_VERSION, |
465 | hw_info->sw_major_rev, hw_info->sw_minor_rev); | ||
457 | 466 | ||
458 | for (i = 0; i < serial->num_ports; i++) { | 467 | for (i = 0; i < serial->num_ports; i++) { |
459 | port = serial->port[i]; | 468 | port = serial->port[i]; |
460 | 469 | ||
461 | info = kmalloc(sizeof(struct whiteheat_private), GFP_KERNEL); | 470 | info = kmalloc(sizeof(struct whiteheat_private), GFP_KERNEL); |
462 | if (info == NULL) { | 471 | if (info == NULL) { |
463 | err("%s: Out of memory for port structures\n", | 472 | dev_err(&port->dev, |
464 | serial->type->description); | 473 | "%s: Out of memory for port structures\n", |
474 | serial->type->description); | ||
465 | goto no_private; | 475 | goto no_private; |
466 | } | 476 | } |
467 | 477 | ||
@@ -481,18 +491,20 @@ static int whiteheat_attach(struct usb_serial *serial) | |||
481 | for (j = 0; j < urb_pool_size; j++) { | 491 | for (j = 0; j < urb_pool_size; j++) { |
482 | urb = usb_alloc_urb(0, GFP_KERNEL); | 492 | urb = usb_alloc_urb(0, GFP_KERNEL); |
483 | if (!urb) { | 493 | if (!urb) { |
484 | err("No free urbs available"); | 494 | dev_err(&port->dev, "No free urbs available\n"); |
485 | goto no_rx_urb; | 495 | goto no_rx_urb; |
486 | } | 496 | } |
487 | buf_size = port->read_urb->transfer_buffer_length; | 497 | buf_size = port->read_urb->transfer_buffer_length; |
488 | urb->transfer_buffer = kmalloc(buf_size, GFP_KERNEL); | 498 | urb->transfer_buffer = kmalloc(buf_size, GFP_KERNEL); |
489 | if (!urb->transfer_buffer) { | 499 | if (!urb->transfer_buffer) { |
490 | err("Couldn't allocate urb buffer"); | 500 | dev_err(&port->dev, |
501 | "Couldn't allocate urb buffer\n"); | ||
491 | goto no_rx_buf; | 502 | goto no_rx_buf; |
492 | } | 503 | } |
493 | wrap = kmalloc(sizeof(*wrap), GFP_KERNEL); | 504 | wrap = kmalloc(sizeof(*wrap), GFP_KERNEL); |
494 | if (!wrap) { | 505 | if (!wrap) { |
495 | err("Couldn't allocate urb wrapper"); | 506 | dev_err(&port->dev, |
507 | "Couldn't allocate urb wrapper\n"); | ||
496 | goto no_rx_wrap; | 508 | goto no_rx_wrap; |
497 | } | 509 | } |
498 | usb_fill_bulk_urb(urb, serial->dev, | 510 | usb_fill_bulk_urb(urb, serial->dev, |
@@ -505,18 +517,20 @@ static int whiteheat_attach(struct usb_serial *serial) | |||
505 | 517 | ||
506 | urb = usb_alloc_urb(0, GFP_KERNEL); | 518 | urb = usb_alloc_urb(0, GFP_KERNEL); |
507 | if (!urb) { | 519 | if (!urb) { |
508 | err("No free urbs available"); | 520 | dev_err(&port->dev, "No free urbs available\n"); |
509 | goto no_tx_urb; | 521 | goto no_tx_urb; |
510 | } | 522 | } |
511 | buf_size = port->write_urb->transfer_buffer_length; | 523 | buf_size = port->write_urb->transfer_buffer_length; |
512 | urb->transfer_buffer = kmalloc(buf_size, GFP_KERNEL); | 524 | urb->transfer_buffer = kmalloc(buf_size, GFP_KERNEL); |
513 | if (!urb->transfer_buffer) { | 525 | if (!urb->transfer_buffer) { |
514 | err("Couldn't allocate urb buffer"); | 526 | dev_err(&port->dev, |
527 | "Couldn't allocate urb buffer\n"); | ||
515 | goto no_tx_buf; | 528 | goto no_tx_buf; |
516 | } | 529 | } |
517 | wrap = kmalloc(sizeof(*wrap), GFP_KERNEL); | 530 | wrap = kmalloc(sizeof(*wrap), GFP_KERNEL); |
518 | if (!wrap) { | 531 | if (!wrap) { |
519 | err("Couldn't allocate urb wrapper"); | 532 | dev_err(&port->dev, |
533 | "Couldn't allocate urb wrapper\n"); | ||
520 | goto no_tx_wrap; | 534 | goto no_tx_wrap; |
521 | } | 535 | } |
522 | usb_fill_bulk_urb(urb, serial->dev, | 536 | usb_fill_bulk_urb(urb, serial->dev, |
@@ -534,8 +548,9 @@ static int whiteheat_attach(struct usb_serial *serial) | |||
534 | command_info = kmalloc(sizeof(struct whiteheat_command_private), | 548 | command_info = kmalloc(sizeof(struct whiteheat_command_private), |
535 | GFP_KERNEL); | 549 | GFP_KERNEL); |
536 | if (command_info == NULL) { | 550 | if (command_info == NULL) { |
537 | err("%s: Out of memory for port structures\n", | 551 | dev_err(&serial->dev->dev, |
538 | serial->type->description); | 552 | "%s: Out of memory for port structures\n", |
553 | serial->type->description); | ||
539 | goto no_command_private; | 554 | goto no_command_private; |
540 | } | 555 | } |
541 | 556 | ||
@@ -552,12 +567,15 @@ static int whiteheat_attach(struct usb_serial *serial) | |||
552 | 567 | ||
553 | no_firmware: | 568 | no_firmware: |
554 | /* Firmware likely not running */ | 569 | /* Firmware likely not running */ |
555 | err("%s: Unable to retrieve firmware version, try replugging\n", | 570 | dev_err(&serial->dev->dev, |
556 | serial->type->description); | 571 | "%s: Unable to retrieve firmware version, try replugging\n", |
557 | err("%s: If the firmware is not running (status led not blinking)\n", | 572 | serial->type->description); |
558 | serial->type->description); | 573 | dev_err(&serial->dev->dev, |
559 | err("%s: please contact support@connecttech.com\n", | 574 | "%s: If the firmware is not running (status led not blinking)\n", |
560 | serial->type->description); | 575 | serial->type->description); |
576 | dev_err(&serial->dev->dev, | ||
577 | "%s: please contact support@connecttech.com\n", | ||
578 | serial->type->description); | ||
561 | kfree(result); | 579 | kfree(result); |
562 | return -ENODEV; | 580 | return -ENODEV; |
563 | 581 | ||
@@ -680,8 +698,9 @@ static int whiteheat_open(struct tty_struct *tty, | |||
680 | /* Start reading from the device */ | 698 | /* Start reading from the device */ |
681 | retval = start_port_read(port); | 699 | retval = start_port_read(port); |
682 | if (retval) { | 700 | if (retval) { |
683 | err("%s - failed submitting read urb, error %d", | 701 | dev_err(&port->dev, |
684 | __func__, retval); | 702 | "%s - failed submitting read urb, error %d\n", |
703 | __func__, retval); | ||
685 | firm_close(port); | 704 | firm_close(port); |
686 | stop_command_port(port->serial); | 705 | stop_command_port(port->serial); |
687 | goto exit; | 706 | goto exit; |
@@ -806,8 +825,9 @@ static int whiteheat_write(struct tty_struct *tty, | |||
806 | urb->transfer_buffer_length = bytes; | 825 | urb->transfer_buffer_length = bytes; |
807 | result = usb_submit_urb(urb, GFP_ATOMIC); | 826 | result = usb_submit_urb(urb, GFP_ATOMIC); |
808 | if (result) { | 827 | if (result) { |
809 | err("%s - failed submitting write urb, error %d", | 828 | dev_err(&port->dev, |
810 | __func__, result); | 829 | "%s - failed submitting write urb, error %d\n", |
830 | __func__, result); | ||
811 | sent = result; | 831 | sent = result; |
812 | spin_lock_irqsave(&info->lock, flags); | 832 | spin_lock_irqsave(&info->lock, flags); |
813 | list_add(tmp, &info->tx_urbs_free); | 833 | list_add(tmp, &info->tx_urbs_free); |
@@ -1075,7 +1095,7 @@ static void whiteheat_read_callback(struct urb *urb) | |||
1075 | wrap = urb_to_wrap(urb, &info->rx_urbs_submitted); | 1095 | wrap = urb_to_wrap(urb, &info->rx_urbs_submitted); |
1076 | if (!wrap) { | 1096 | if (!wrap) { |
1077 | spin_unlock(&info->lock); | 1097 | spin_unlock(&info->lock); |
1078 | err("%s - Not my urb!", __func__); | 1098 | dev_err(&port->dev, "%s - Not my urb!\n", __func__); |
1079 | return; | 1099 | return; |
1080 | } | 1100 | } |
1081 | list_del(&wrap->list); | 1101 | list_del(&wrap->list); |
@@ -1119,7 +1139,7 @@ static void whiteheat_write_callback(struct urb *urb) | |||
1119 | wrap = urb_to_wrap(urb, &info->tx_urbs_submitted); | 1139 | wrap = urb_to_wrap(urb, &info->tx_urbs_submitted); |
1120 | if (!wrap) { | 1140 | if (!wrap) { |
1121 | spin_unlock(&info->lock); | 1141 | spin_unlock(&info->lock); |
1122 | err("%s - Not my urb!", __func__); | 1142 | dev_err(&port->dev, "%s - Not my urb!\n", __func__); |
1123 | return; | 1143 | return; |
1124 | } | 1144 | } |
1125 | list_move(&wrap->list, &info->tx_urbs_free); | 1145 | list_move(&wrap->list, &info->tx_urbs_free); |
@@ -1383,8 +1403,9 @@ static int start_command_port(struct usb_serial *serial) | |||
1383 | command_port->read_urb->dev = serial->dev; | 1403 | command_port->read_urb->dev = serial->dev; |
1384 | retval = usb_submit_urb(command_port->read_urb, GFP_KERNEL); | 1404 | retval = usb_submit_urb(command_port->read_urb, GFP_KERNEL); |
1385 | if (retval) { | 1405 | if (retval) { |
1386 | err("%s - failed submitting read urb, error %d", | 1406 | dev_err(&serial->dev->dev, |
1387 | __func__, retval); | 1407 | "%s - failed submitting read urb, error %d\n", |
1408 | __func__, retval); | ||
1388 | goto exit; | 1409 | goto exit; |
1389 | } | 1410 | } |
1390 | } | 1411 | } |
@@ -1481,7 +1502,7 @@ static void rx_data_softint(struct work_struct *work) | |||
1481 | struct whiteheat_private *info = | 1502 | struct whiteheat_private *info = |
1482 | container_of(work, struct whiteheat_private, rx_work); | 1503 | container_of(work, struct whiteheat_private, rx_work); |
1483 | struct usb_serial_port *port = info->port; | 1504 | struct usb_serial_port *port = info->port; |
1484 | struct tty_struct *tty = port->port.tty; | 1505 | struct tty_struct *tty = tty_port_tty_get(&port->port); |
1485 | struct whiteheat_urb_wrap *wrap; | 1506 | struct whiteheat_urb_wrap *wrap; |
1486 | struct urb *urb; | 1507 | struct urb *urb; |
1487 | unsigned long flags; | 1508 | unsigned long flags; |
@@ -1493,7 +1514,7 @@ static void rx_data_softint(struct work_struct *work) | |||
1493 | spin_lock_irqsave(&info->lock, flags); | 1514 | spin_lock_irqsave(&info->lock, flags); |
1494 | if (info->flags & THROTTLED) { | 1515 | if (info->flags & THROTTLED) { |
1495 | spin_unlock_irqrestore(&info->lock, flags); | 1516 | spin_unlock_irqrestore(&info->lock, flags); |
1496 | return; | 1517 | goto out; |
1497 | } | 1518 | } |
1498 | 1519 | ||
1499 | list_for_each_safe(tmp, tmp2, &info->rx_urb_q) { | 1520 | list_for_each_safe(tmp, tmp2, &info->rx_urb_q) { |
@@ -1513,7 +1534,7 @@ static void rx_data_softint(struct work_struct *work) | |||
1513 | spin_unlock_irqrestore(&info->lock, flags); | 1534 | spin_unlock_irqrestore(&info->lock, flags); |
1514 | tty_flip_buffer_push(tty); | 1535 | tty_flip_buffer_push(tty); |
1515 | schedule_work(&info->rx_work); | 1536 | schedule_work(&info->rx_work); |
1516 | return; | 1537 | goto out; |
1517 | } | 1538 | } |
1518 | tty_insert_flip_string(tty, urb->transfer_buffer, len); | 1539 | tty_insert_flip_string(tty, urb->transfer_buffer, len); |
1519 | sent += len; | 1540 | sent += len; |
@@ -1522,7 +1543,8 @@ static void rx_data_softint(struct work_struct *work) | |||
1522 | urb->dev = port->serial->dev; | 1543 | urb->dev = port->serial->dev; |
1523 | result = usb_submit_urb(urb, GFP_ATOMIC); | 1544 | result = usb_submit_urb(urb, GFP_ATOMIC); |
1524 | if (result) { | 1545 | if (result) { |
1525 | err("%s - failed resubmitting read urb, error %d", | 1546 | dev_err(&port->dev, |
1547 | "%s - failed resubmitting read urb, error %d\n", | ||
1526 | __func__, result); | 1548 | __func__, result); |
1527 | spin_lock_irqsave(&info->lock, flags); | 1549 | spin_lock_irqsave(&info->lock, flags); |
1528 | list_add(tmp, &info->rx_urbs_free); | 1550 | list_add(tmp, &info->rx_urbs_free); |
@@ -1536,6 +1558,8 @@ static void rx_data_softint(struct work_struct *work) | |||
1536 | 1558 | ||
1537 | if (sent) | 1559 | if (sent) |
1538 | tty_flip_buffer_push(tty); | 1560 | tty_flip_buffer_push(tty); |
1561 | out: | ||
1562 | tty_kref_put(tty); | ||
1539 | } | 1563 | } |
1540 | 1564 | ||
1541 | 1565 | ||
@@ -1554,7 +1578,8 @@ static int __init whiteheat_init(void) | |||
1554 | retval = usb_register(&whiteheat_driver); | 1578 | retval = usb_register(&whiteheat_driver); |
1555 | if (retval) | 1579 | if (retval) |
1556 | goto failed_usb_register; | 1580 | goto failed_usb_register; |
1557 | info(DRIVER_DESC " " DRIVER_VERSION); | 1581 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
1582 | DRIVER_DESC "\n"); | ||
1558 | return 0; | 1583 | return 0; |
1559 | failed_usb_register: | 1584 | failed_usb_register: |
1560 | usb_serial_deregister(&whiteheat_device); | 1585 | usb_serial_deregister(&whiteheat_device); |
diff --git a/drivers/usb/storage/Kconfig b/drivers/usb/storage/Kconfig index c76034672c18..3d9249632ae1 100644 --- a/drivers/usb/storage/Kconfig +++ b/drivers/usb/storage/Kconfig | |||
@@ -146,18 +146,6 @@ config USB_STORAGE_KARMA | |||
146 | on the resulting scsi device node returns the Karma to normal | 146 | on the resulting scsi device node returns the Karma to normal |
147 | operation. | 147 | operation. |
148 | 148 | ||
149 | config USB_STORAGE_SIERRA | ||
150 | bool "Sierra Wireless TRU-Install Feature Support" | ||
151 | depends on USB_STORAGE | ||
152 | help | ||
153 | Say Y here to include additional code to support Sierra Wireless | ||
154 | products with the TRU-Install feature (e.g., AC597E, AC881U). | ||
155 | |||
156 | This code switches the Sierra Wireless device from being in | ||
157 | Mass Storage mode to Modem mode. It also has the ability to | ||
158 | support host software upgrades should full Linux support be added | ||
159 | to TRU-Install. | ||
160 | |||
161 | config USB_STORAGE_CYPRESS_ATACB | 149 | config USB_STORAGE_CYPRESS_ATACB |
162 | bool "SAT emulation on Cypress USB/ATA Bridge with ATACB" | 150 | bool "SAT emulation on Cypress USB/ATA Bridge with ATACB" |
163 | depends on USB_STORAGE | 151 | depends on USB_STORAGE |
diff --git a/drivers/usb/storage/Makefile b/drivers/usb/storage/Makefile index bc3415b475c9..7f8beb5366ae 100644 --- a/drivers/usb/storage/Makefile +++ b/drivers/usb/storage/Makefile | |||
@@ -21,11 +21,10 @@ usb-storage-obj-$(CONFIG_USB_STORAGE_JUMPSHOT) += jumpshot.o | |||
21 | usb-storage-obj-$(CONFIG_USB_STORAGE_ALAUDA) += alauda.o | 21 | usb-storage-obj-$(CONFIG_USB_STORAGE_ALAUDA) += alauda.o |
22 | usb-storage-obj-$(CONFIG_USB_STORAGE_ONETOUCH) += onetouch.o | 22 | usb-storage-obj-$(CONFIG_USB_STORAGE_ONETOUCH) += onetouch.o |
23 | usb-storage-obj-$(CONFIG_USB_STORAGE_KARMA) += karma.o | 23 | usb-storage-obj-$(CONFIG_USB_STORAGE_KARMA) += karma.o |
24 | usb-storage-obj-$(CONFIG_USB_STORAGE_SIERRA) += sierra_ms.o | ||
25 | usb-storage-obj-$(CONFIG_USB_STORAGE_CYPRESS_ATACB) += cypress_atacb.o | 24 | usb-storage-obj-$(CONFIG_USB_STORAGE_CYPRESS_ATACB) += cypress_atacb.o |
26 | 25 | ||
27 | usb-storage-objs := scsiglue.o protocol.o transport.o usb.o \ | 26 | usb-storage-objs := scsiglue.o protocol.o transport.o usb.o \ |
28 | initializers.o $(usb-storage-obj-y) | 27 | initializers.o sierra_ms.o $(usb-storage-obj-y) |
29 | 28 | ||
30 | ifneq ($(CONFIG_USB_LIBUSUAL),) | 29 | ifneq ($(CONFIG_USB_LIBUSUAL),) |
31 | obj-$(CONFIG_USB) += libusual.o | 30 | obj-$(CONFIG_USB) += libusual.o |
diff --git a/drivers/usb/storage/onetouch.c b/drivers/usb/storage/onetouch.c index 98b89ea9e312..c7bf8954b4e4 100644 --- a/drivers/usb/storage/onetouch.c +++ b/drivers/usb/storage/onetouch.c | |||
@@ -78,8 +78,8 @@ static void usb_onetouch_irq(struct urb *urb) | |||
78 | resubmit: | 78 | resubmit: |
79 | retval = usb_submit_urb (urb, GFP_ATOMIC); | 79 | retval = usb_submit_urb (urb, GFP_ATOMIC); |
80 | if (retval) | 80 | if (retval) |
81 | err ("can't resubmit intr, %s-%s/input0, retval %d", | 81 | dev_err(&dev->dev, "can't resubmit intr, %s-%s/input0, " |
82 | onetouch->udev->bus->bus_name, | 82 | "retval %d\n", onetouch->udev->bus->bus_name, |
83 | onetouch->udev->devpath, retval); | 83 | onetouch->udev->devpath, retval); |
84 | } | 84 | } |
85 | 85 | ||
@@ -90,7 +90,7 @@ static int usb_onetouch_open(struct input_dev *dev) | |||
90 | onetouch->is_open = 1; | 90 | onetouch->is_open = 1; |
91 | onetouch->irq->dev = onetouch->udev; | 91 | onetouch->irq->dev = onetouch->udev; |
92 | if (usb_submit_urb(onetouch->irq, GFP_KERNEL)) { | 92 | if (usb_submit_urb(onetouch->irq, GFP_KERNEL)) { |
93 | err("usb_submit_urb failed"); | 93 | dev_err(&dev->dev, "usb_submit_urb failed\n"); |
94 | return -EIO; | 94 | return -EIO; |
95 | } | 95 | } |
96 | 96 | ||
@@ -117,7 +117,8 @@ static void usb_onetouch_pm_hook(struct us_data *us, int action) | |||
117 | break; | 117 | break; |
118 | case US_RESUME: | 118 | case US_RESUME: |
119 | if (usb_submit_urb(onetouch->irq, GFP_KERNEL) != 0) | 119 | if (usb_submit_urb(onetouch->irq, GFP_KERNEL) != 0) |
120 | err("usb_submit_urb failed"); | 120 | dev_err(&onetouch->irq->dev->dev, |
121 | "usb_submit_urb failed\n"); | ||
121 | break; | 122 | break; |
122 | default: | 123 | default: |
123 | break; | 124 | break; |
diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c index 3523a0bfa0ff..79108d5d3171 100644 --- a/drivers/usb/storage/transport.c +++ b/drivers/usb/storage/transport.c | |||
@@ -663,7 +663,7 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us) | |||
663 | } | 663 | } |
664 | 664 | ||
665 | /* Did we transfer less than the minimum amount required? */ | 665 | /* Did we transfer less than the minimum amount required? */ |
666 | if (srb->result == SAM_STAT_GOOD && | 666 | if ((srb->result == SAM_STAT_GOOD || srb->sense_buffer[2] == 0) && |
667 | scsi_bufflen(srb) - scsi_get_resid(srb) < srb->underflow) | 667 | scsi_bufflen(srb) - scsi_get_resid(srb) < srb->underflow) |
668 | srb->result = (DID_ERROR << 16) | (SUGGEST_RETRY << 24); | 668 | srb->result = (DID_ERROR << 16) | (SUGGEST_RETRY << 24); |
669 | 669 | ||
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h index ba412e68d474..cd155475cb6e 100644 --- a/drivers/usb/storage/unusual_devs.h +++ b/drivers/usb/storage/unusual_devs.h | |||
@@ -160,6 +160,13 @@ UNUSUAL_DEV( 0x0421, 0x0019, 0x0592, 0x0592, | |||
160 | US_SC_DEVICE, US_PR_DEVICE, NULL, | 160 | US_SC_DEVICE, US_PR_DEVICE, NULL, |
161 | US_FL_MAX_SECTORS_64 ), | 161 | US_FL_MAX_SECTORS_64 ), |
162 | 162 | ||
163 | /* Reported by Filip Joelsson <filip@blueturtle.nu> */ | ||
164 | UNUSUAL_DEV( 0x0421, 0x005d, 0x0001, 0x0600, | ||
165 | "Nokia", | ||
166 | "Nokia 3110c", | ||
167 | US_SC_DEVICE, US_PR_DEVICE, NULL, | ||
168 | US_FL_FIX_CAPACITY ), | ||
169 | |||
163 | /* Reported by Mario Rettig <mariorettig@web.de> */ | 170 | /* Reported by Mario Rettig <mariorettig@web.de> */ |
164 | UNUSUAL_DEV( 0x0421, 0x042e, 0x0100, 0x0100, | 171 | UNUSUAL_DEV( 0x0421, 0x042e, 0x0100, 0x0100, |
165 | "Nokia", | 172 | "Nokia", |
@@ -232,6 +239,20 @@ UNUSUAL_DEV( 0x0421, 0x04b9, 0x0551, 0x0551, | |||
232 | US_SC_DEVICE, US_PR_DEVICE, NULL, | 239 | US_SC_DEVICE, US_PR_DEVICE, NULL, |
233 | US_FL_FIX_CAPACITY ), | 240 | US_FL_FIX_CAPACITY ), |
234 | 241 | ||
242 | /* Reported by Richard Nauber <RichardNauber@web.de> */ | ||
243 | UNUSUAL_DEV( 0x0421, 0x04fa, 0x0601, 0x0601, | ||
244 | "Nokia", | ||
245 | "6300", | ||
246 | US_SC_DEVICE, US_PR_DEVICE, NULL, | ||
247 | US_FL_FIX_CAPACITY ), | ||
248 | |||
249 | /* Patch for Nokia 5310 capacity */ | ||
250 | UNUSUAL_DEV( 0x0421, 0x006a, 0x0000, 0x0591, | ||
251 | "Nokia", | ||
252 | "5310", | ||
253 | US_SC_DEVICE, US_PR_DEVICE, NULL, | ||
254 | US_FL_FIX_CAPACITY ), | ||
255 | |||
235 | /* Reported by Olaf Hering <olh@suse.de> from novell bug #105878 */ | 256 | /* Reported by Olaf Hering <olh@suse.de> from novell bug #105878 */ |
236 | UNUSUAL_DEV( 0x0424, 0x0fdc, 0x0210, 0x0210, | 257 | UNUSUAL_DEV( 0x0424, 0x0fdc, 0x0210, 0x0210, |
237 | "SMSC", | 258 | "SMSC", |
@@ -987,6 +1008,13 @@ UNUSUAL_DEV( 0x069b, 0x3004, 0x0001, 0x0001, | |||
987 | US_SC_DEVICE, US_PR_DEVICE, NULL, | 1008 | US_SC_DEVICE, US_PR_DEVICE, NULL, |
988 | US_FL_FIX_CAPACITY ), | 1009 | US_FL_FIX_CAPACITY ), |
989 | 1010 | ||
1011 | /* Reported by Adrian Pilchowiec <adi1981@epf.pl> */ | ||
1012 | UNUSUAL_DEV( 0x071b, 0x3203, 0x0000, 0x0000, | ||
1013 | "RockChip", | ||
1014 | "MP3", | ||
1015 | US_SC_DEVICE, US_PR_DEVICE, NULL, | ||
1016 | US_FL_NO_WP_DETECT | US_FL_MAX_SECTORS_64), | ||
1017 | |||
990 | /* Reported by Massimiliano Ghilardi <massimiliano.ghilardi@gmail.com> | 1018 | /* Reported by Massimiliano Ghilardi <massimiliano.ghilardi@gmail.com> |
991 | * This USB MP3/AVI player device fails and disconnects if more than 128 | 1019 | * This USB MP3/AVI player device fails and disconnects if more than 128 |
992 | * sectors (64kB) are read/written in a single command, and may be present | 1020 | * sectors (64kB) are read/written in a single command, and may be present |
@@ -1576,7 +1604,6 @@ UNUSUAL_DEV( 0x10d6, 0x2200, 0x0100, 0x0100, | |||
1576 | US_SC_DEVICE, US_PR_DEVICE, NULL, | 1604 | US_SC_DEVICE, US_PR_DEVICE, NULL, |
1577 | 0), | 1605 | 0), |
1578 | 1606 | ||
1579 | #ifdef CONFIG_USB_STORAGE_SIERRA | ||
1580 | /* Reported by Kevin Lloyd <linux@sierrawireless.com> | 1607 | /* Reported by Kevin Lloyd <linux@sierrawireless.com> |
1581 | * Entry is needed for the initializer function override, | 1608 | * Entry is needed for the initializer function override, |
1582 | * which instructs the device to load as a modem | 1609 | * which instructs the device to load as a modem |
@@ -1587,7 +1614,6 @@ UNUSUAL_DEV( 0x1199, 0x0fff, 0x0000, 0x9999, | |||
1587 | "USB MMC Storage", | 1614 | "USB MMC Storage", |
1588 | US_SC_DEVICE, US_PR_DEVICE, sierra_ms_init, | 1615 | US_SC_DEVICE, US_PR_DEVICE, sierra_ms_init, |
1589 | 0), | 1616 | 0), |
1590 | #endif | ||
1591 | 1617 | ||
1592 | /* Reported by Jaco Kroon <jaco@kroon.co.za> | 1618 | /* Reported by Jaco Kroon <jaco@kroon.co.za> |
1593 | * The usb-storage module found on the Digitech GNX4 (and supposedly other | 1619 | * The usb-storage module found on the Digitech GNX4 (and supposedly other |
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c index 73679aa506de..27016fd2cad1 100644 --- a/drivers/usb/storage/usb.c +++ b/drivers/usb/storage/usb.c | |||
@@ -102,9 +102,7 @@ | |||
102 | #ifdef CONFIG_USB_STORAGE_CYPRESS_ATACB | 102 | #ifdef CONFIG_USB_STORAGE_CYPRESS_ATACB |
103 | #include "cypress_atacb.h" | 103 | #include "cypress_atacb.h" |
104 | #endif | 104 | #endif |
105 | #ifdef CONFIG_USB_STORAGE_SIERRA | ||
106 | #include "sierra_ms.h" | 105 | #include "sierra_ms.h" |
107 | #endif | ||
108 | 106 | ||
109 | /* Some informational data */ | 107 | /* Some informational data */ |
110 | MODULE_AUTHOR("Matthew Dharm <mdharm-usb@one-eyed-alien.net>"); | 108 | MODULE_AUTHOR("Matthew Dharm <mdharm-usb@one-eyed-alien.net>"); |