diff options
Diffstat (limited to 'drivers/usb')
256 files changed, 6024 insertions, 4976 deletions
diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig index 791f11bed606..75823a1abeb6 100644 --- a/drivers/usb/Kconfig +++ b/drivers/usb/Kconfig | |||
@@ -48,6 +48,7 @@ config USB_ARCH_HAS_OHCI | |||
48 | default y if ARCH_DAVINCI_DA8XX | 48 | default y if ARCH_DAVINCI_DA8XX |
49 | default y if ARCH_CNS3XXX | 49 | default y if ARCH_CNS3XXX |
50 | default y if PLAT_SPEAR | 50 | default y if PLAT_SPEAR |
51 | default y if ARCH_EXYNOS | ||
51 | # PPC: | 52 | # PPC: |
52 | default y if STB03xxx | 53 | default y if STB03xxx |
53 | default y if PPC_MPC52xx | 54 | default y if PPC_MPC52xx |
diff --git a/drivers/usb/Makefile b/drivers/usb/Makefile index 75eca7645227..53a7bc07dd8d 100644 --- a/drivers/usb/Makefile +++ b/drivers/usb/Makefile | |||
@@ -6,6 +6,8 @@ | |||
6 | 6 | ||
7 | obj-$(CONFIG_USB) += core/ | 7 | obj-$(CONFIG_USB) += core/ |
8 | 8 | ||
9 | obj-$(CONFIG_USB_OTG_UTILS) += otg/ | ||
10 | |||
9 | obj-$(CONFIG_USB_DWC3) += dwc3/ | 11 | obj-$(CONFIG_USB_DWC3) += dwc3/ |
10 | 12 | ||
11 | obj-$(CONFIG_USB_MON) += mon/ | 13 | obj-$(CONFIG_USB_MON) += mon/ |
@@ -51,7 +53,6 @@ obj-$(CONFIG_USB_SPEEDTOUCH) += atm/ | |||
51 | 53 | ||
52 | obj-$(CONFIG_USB_MUSB_HDRC) += musb/ | 54 | obj-$(CONFIG_USB_MUSB_HDRC) += musb/ |
53 | obj-$(CONFIG_USB_RENESAS_USBHS) += renesas_usbhs/ | 55 | obj-$(CONFIG_USB_RENESAS_USBHS) += renesas_usbhs/ |
54 | obj-$(CONFIG_USB_OTG_UTILS) += otg/ | ||
55 | obj-$(CONFIG_USB_GADGET) += gadget/ | 56 | obj-$(CONFIG_USB_GADGET) += gadget/ |
56 | 57 | ||
57 | obj-$(CONFIG_USB_COMMON) += usb-common.o | 58 | obj-$(CONFIG_USB_COMMON) += usb-common.o |
diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c index a845f8b8382f..98b89fe19867 100644 --- a/drivers/usb/atm/cxacru.c +++ b/drivers/usb/atm/cxacru.c | |||
@@ -1372,18 +1372,7 @@ static struct usb_driver cxacru_usb_driver = { | |||
1372 | .id_table = cxacru_usb_ids | 1372 | .id_table = cxacru_usb_ids |
1373 | }; | 1373 | }; |
1374 | 1374 | ||
1375 | static int __init cxacru_init(void) | 1375 | module_usb_driver(cxacru_usb_driver); |
1376 | { | ||
1377 | return usb_register(&cxacru_usb_driver); | ||
1378 | } | ||
1379 | |||
1380 | static void __exit cxacru_cleanup(void) | ||
1381 | { | ||
1382 | usb_deregister(&cxacru_usb_driver); | ||
1383 | } | ||
1384 | |||
1385 | module_init(cxacru_init); | ||
1386 | module_exit(cxacru_cleanup); | ||
1387 | 1376 | ||
1388 | MODULE_AUTHOR(DRIVER_AUTHOR); | 1377 | MODULE_AUTHOR(DRIVER_AUTHOR); |
1389 | MODULE_DESCRIPTION(DRIVER_DESC); | 1378 | MODULE_DESCRIPTION(DRIVER_DESC); |
diff --git a/drivers/usb/atm/speedtch.c b/drivers/usb/atm/speedtch.c index 0842cfbf60cf..98dd9e49b684 100644 --- a/drivers/usb/atm/speedtch.c +++ b/drivers/usb/atm/speedtch.c | |||
@@ -73,9 +73,9 @@ static const char speedtch_driver_name[] = "speedtch"; | |||
73 | #define DEFAULT_SW_BUFFERING 0 | 73 | #define DEFAULT_SW_BUFFERING 0 |
74 | 74 | ||
75 | static unsigned int altsetting = 0; /* zero means: use the default */ | 75 | static unsigned int altsetting = 0; /* zero means: use the default */ |
76 | static int dl_512_first = DEFAULT_DL_512_FIRST; | 76 | static bool dl_512_first = DEFAULT_DL_512_FIRST; |
77 | static int enable_isoc = DEFAULT_ENABLE_ISOC; | 77 | static bool enable_isoc = DEFAULT_ENABLE_ISOC; |
78 | static int sw_buffering = DEFAULT_SW_BUFFERING; | 78 | static bool sw_buffering = DEFAULT_SW_BUFFERING; |
79 | 79 | ||
80 | #define DEFAULT_B_MAX_DSL 8128 | 80 | #define DEFAULT_B_MAX_DSL 8128 |
81 | #define DEFAULT_MODEM_MODE 11 | 81 | #define DEFAULT_MODEM_MODE 11 |
@@ -953,22 +953,7 @@ static int speedtch_usb_probe(struct usb_interface *intf, const struct usb_devic | |||
953 | return usbatm_usb_probe(intf, id, &speedtch_usbatm_driver); | 953 | return usbatm_usb_probe(intf, id, &speedtch_usbatm_driver); |
954 | } | 954 | } |
955 | 955 | ||
956 | static int __init speedtch_usb_init(void) | 956 | module_usb_driver(speedtch_usb_driver); |
957 | { | ||
958 | dbg("%s: driver version %s", __func__, DRIVER_VERSION); | ||
959 | |||
960 | return usb_register(&speedtch_usb_driver); | ||
961 | } | ||
962 | |||
963 | static void __exit speedtch_usb_cleanup(void) | ||
964 | { | ||
965 | dbg("%s", __func__); | ||
966 | |||
967 | usb_deregister(&speedtch_usb_driver); | ||
968 | } | ||
969 | |||
970 | module_init(speedtch_usb_init); | ||
971 | module_exit(speedtch_usb_cleanup); | ||
972 | 957 | ||
973 | MODULE_AUTHOR(DRIVER_AUTHOR); | 958 | MODULE_AUTHOR(DRIVER_AUTHOR); |
974 | MODULE_DESCRIPTION(DRIVER_DESC); | 959 | MODULE_DESCRIPTION(DRIVER_DESC); |
diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c index 428f36801e06..01ea5d7421d4 100644 --- a/drivers/usb/atm/ueagle-atm.c +++ b/drivers/usb/atm/ueagle-atm.c | |||
@@ -542,7 +542,7 @@ static int modem_index; | |||
542 | static unsigned int debug; | 542 | static unsigned int debug; |
543 | static unsigned int altsetting[NB_MODEM] = { | 543 | static unsigned int altsetting[NB_MODEM] = { |
544 | [0 ... (NB_MODEM - 1)] = FASTEST_ISO_INTF}; | 544 | [0 ... (NB_MODEM - 1)] = FASTEST_ISO_INTF}; |
545 | static int sync_wait[NB_MODEM]; | 545 | static bool sync_wait[NB_MODEM]; |
546 | static char *cmv_file[NB_MODEM]; | 546 | static char *cmv_file[NB_MODEM]; |
547 | static int annex[NB_MODEM]; | 547 | static int annex[NB_MODEM]; |
548 | 548 | ||
@@ -2753,36 +2753,7 @@ static struct usb_driver uea_driver = { | |||
2753 | 2753 | ||
2754 | MODULE_DEVICE_TABLE(usb, uea_ids); | 2754 | MODULE_DEVICE_TABLE(usb, uea_ids); |
2755 | 2755 | ||
2756 | /** | 2756 | module_usb_driver(uea_driver); |
2757 | * uea_init - Initialize the module. | ||
2758 | * Register to USB subsystem | ||
2759 | */ | ||
2760 | static int __init uea_init(void) | ||
2761 | { | ||
2762 | printk(KERN_INFO "[ueagle-atm] driver " EAGLEUSBVERSION " loaded\n"); | ||
2763 | |||
2764 | usb_register(&uea_driver); | ||
2765 | |||
2766 | return 0; | ||
2767 | } | ||
2768 | |||
2769 | module_init(uea_init); | ||
2770 | |||
2771 | /** | ||
2772 | * uea_exit - Destroy module | ||
2773 | * Deregister with USB subsystem | ||
2774 | */ | ||
2775 | static void __exit uea_exit(void) | ||
2776 | { | ||
2777 | /* | ||
2778 | * This calls automatically the uea_disconnect method if necessary: | ||
2779 | */ | ||
2780 | usb_deregister(&uea_driver); | ||
2781 | |||
2782 | printk(KERN_INFO "[ueagle-atm] driver unloaded\n"); | ||
2783 | } | ||
2784 | |||
2785 | module_exit(uea_exit); | ||
2786 | 2757 | ||
2787 | MODULE_AUTHOR("Damien Bergamini/Matthieu Castet/Stanislaw W. Gruszka"); | 2758 | MODULE_AUTHOR("Damien Bergamini/Matthieu Castet/Stanislaw W. Gruszka"); |
2788 | MODULE_DESCRIPTION("ADI 930/Eagle USB ADSL Modem driver"); | 2759 | MODULE_DESCRIPTION("ADI 930/Eagle USB ADSL Modem driver"); |
diff --git a/drivers/usb/c67x00/c67x00-drv.c b/drivers/usb/c67x00/c67x00-drv.c index 57ae44cd0b88..6f3b6e267398 100644 --- a/drivers/usb/c67x00/c67x00-drv.c +++ b/drivers/usb/c67x00/c67x00-drv.c | |||
@@ -225,21 +225,10 @@ static struct platform_driver c67x00_driver = { | |||
225 | .name = "c67x00", | 225 | .name = "c67x00", |
226 | }, | 226 | }, |
227 | }; | 227 | }; |
228 | MODULE_ALIAS("platform:c67x00"); | ||
229 | |||
230 | static int __init c67x00_init(void) | ||
231 | { | ||
232 | return platform_driver_register(&c67x00_driver); | ||
233 | } | ||
234 | 228 | ||
235 | static void __exit c67x00_exit(void) | 229 | module_platform_driver(c67x00_driver); |
236 | { | ||
237 | platform_driver_unregister(&c67x00_driver); | ||
238 | } | ||
239 | |||
240 | module_init(c67x00_init); | ||
241 | module_exit(c67x00_exit); | ||
242 | 230 | ||
243 | MODULE_AUTHOR("Peter Korsgaard, Jan Veldeman, Grant Likely"); | 231 | MODULE_AUTHOR("Peter Korsgaard, Jan Veldeman, Grant Likely"); |
244 | MODULE_DESCRIPTION("Cypress C67X00 USB Controller Driver"); | 232 | MODULE_DESCRIPTION("Cypress C67X00 USB Controller Driver"); |
245 | MODULE_LICENSE("GPL"); | 233 | MODULE_LICENSE("GPL"); |
234 | MODULE_ALIAS("platform:c67x00"); | ||
diff --git a/drivers/usb/c67x00/c67x00-hcd.c b/drivers/usb/c67x00/c67x00-hcd.c index d3e1356d091e..75e47b860a53 100644 --- a/drivers/usb/c67x00/c67x00-hcd.c +++ b/drivers/usb/c67x00/c67x00-hcd.c | |||
@@ -271,7 +271,6 @@ static void c67x00_hcd_irq(struct c67x00_sie *sie, u16 int_status, u16 msg) | |||
271 | if (int_status & SOFEOP_FLG(sie->sie_num)) { | 271 | if (int_status & SOFEOP_FLG(sie->sie_num)) { |
272 | c67x00_ll_usb_clear_status(sie, SOF_EOP_IRQ_FLG); | 272 | c67x00_ll_usb_clear_status(sie, SOF_EOP_IRQ_FLG); |
273 | c67x00_sched_kick(c67x00); | 273 | c67x00_sched_kick(c67x00); |
274 | set_bit(HCD_FLAG_SAW_IRQ, &hcd->flags); | ||
275 | } | 274 | } |
276 | } | 275 | } |
277 | 276 | ||
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c index 6960715c5063..9543b19d410c 100644 --- a/drivers/usb/class/cdc-acm.c +++ b/drivers/usb/class/cdc-acm.c | |||
@@ -58,12 +58,62 @@ static struct usb_driver acm_driver; | |||
58 | static struct tty_driver *acm_tty_driver; | 58 | static struct tty_driver *acm_tty_driver; |
59 | static struct acm *acm_table[ACM_TTY_MINORS]; | 59 | static struct acm *acm_table[ACM_TTY_MINORS]; |
60 | 60 | ||
61 | static DEFINE_MUTEX(open_mutex); | 61 | static DEFINE_MUTEX(acm_table_lock); |
62 | 62 | ||
63 | #define ACM_READY(acm) (acm && acm->dev && acm->port.count) | 63 | /* |
64 | * acm_table accessors | ||
65 | */ | ||
64 | 66 | ||
65 | static const struct tty_port_operations acm_port_ops = { | 67 | /* |
66 | }; | 68 | * Look up an ACM structure by index. If found and not disconnected, increment |
69 | * its refcount and return it with its mutex held. | ||
70 | */ | ||
71 | static struct acm *acm_get_by_index(unsigned index) | ||
72 | { | ||
73 | struct acm *acm; | ||
74 | |||
75 | mutex_lock(&acm_table_lock); | ||
76 | acm = acm_table[index]; | ||
77 | if (acm) { | ||
78 | mutex_lock(&acm->mutex); | ||
79 | if (acm->disconnected) { | ||
80 | mutex_unlock(&acm->mutex); | ||
81 | acm = NULL; | ||
82 | } else { | ||
83 | tty_port_get(&acm->port); | ||
84 | mutex_unlock(&acm->mutex); | ||
85 | } | ||
86 | } | ||
87 | mutex_unlock(&acm_table_lock); | ||
88 | return acm; | ||
89 | } | ||
90 | |||
91 | /* | ||
92 | * Try to find an available minor number and if found, associate it with 'acm'. | ||
93 | */ | ||
94 | static int acm_alloc_minor(struct acm *acm) | ||
95 | { | ||
96 | int minor; | ||
97 | |||
98 | mutex_lock(&acm_table_lock); | ||
99 | for (minor = 0; minor < ACM_TTY_MINORS; minor++) { | ||
100 | if (!acm_table[minor]) { | ||
101 | acm_table[minor] = acm; | ||
102 | break; | ||
103 | } | ||
104 | } | ||
105 | mutex_unlock(&acm_table_lock); | ||
106 | |||
107 | return minor; | ||
108 | } | ||
109 | |||
110 | /* Release the minor number associated with 'acm'. */ | ||
111 | static void acm_release_minor(struct acm *acm) | ||
112 | { | ||
113 | mutex_lock(&acm_table_lock); | ||
114 | acm_table[acm->minor] = NULL; | ||
115 | mutex_unlock(&acm_table_lock); | ||
116 | } | ||
67 | 117 | ||
68 | /* | 118 | /* |
69 | * Functions for ACM control messages. | 119 | * Functions for ACM control messages. |
@@ -267,9 +317,6 @@ static void acm_ctrl_irq(struct urb *urb) | |||
267 | goto exit; | 317 | goto exit; |
268 | } | 318 | } |
269 | 319 | ||
270 | if (!ACM_READY(acm)) | ||
271 | goto exit; | ||
272 | |||
273 | usb_mark_last_busy(acm->dev); | 320 | usb_mark_last_busy(acm->dev); |
274 | 321 | ||
275 | data = (unsigned char *)(dr + 1); | 322 | data = (unsigned char *)(dr + 1); |
@@ -429,8 +476,7 @@ static void acm_write_bulk(struct urb *urb) | |||
429 | spin_lock_irqsave(&acm->write_lock, flags); | 476 | spin_lock_irqsave(&acm->write_lock, flags); |
430 | acm_write_done(acm, wb); | 477 | acm_write_done(acm, wb); |
431 | spin_unlock_irqrestore(&acm->write_lock, flags); | 478 | spin_unlock_irqrestore(&acm->write_lock, flags); |
432 | if (ACM_READY(acm)) | 479 | schedule_work(&acm->work); |
433 | schedule_work(&acm->work); | ||
434 | } | 480 | } |
435 | 481 | ||
436 | static void acm_softint(struct work_struct *work) | 482 | static void acm_softint(struct work_struct *work) |
@@ -440,8 +486,6 @@ static void acm_softint(struct work_struct *work) | |||
440 | 486 | ||
441 | dev_vdbg(&acm->data->dev, "%s\n", __func__); | 487 | dev_vdbg(&acm->data->dev, "%s\n", __func__); |
442 | 488 | ||
443 | if (!ACM_READY(acm)) | ||
444 | return; | ||
445 | tty = tty_port_tty_get(&acm->port); | 489 | tty = tty_port_tty_get(&acm->port); |
446 | if (!tty) | 490 | if (!tty) |
447 | return; | 491 | return; |
@@ -453,94 +497,122 @@ static void acm_softint(struct work_struct *work) | |||
453 | * TTY handlers | 497 | * TTY handlers |
454 | */ | 498 | */ |
455 | 499 | ||
456 | static int acm_tty_open(struct tty_struct *tty, struct file *filp) | 500 | static int acm_tty_install(struct tty_driver *driver, struct tty_struct *tty) |
457 | { | 501 | { |
458 | struct acm *acm; | 502 | struct acm *acm; |
459 | int rv = -ENODEV; | 503 | int retval; |
460 | |||
461 | mutex_lock(&open_mutex); | ||
462 | 504 | ||
463 | acm = acm_table[tty->index]; | 505 | dev_dbg(tty->dev, "%s\n", __func__); |
464 | if (!acm || !acm->dev) | ||
465 | goto out; | ||
466 | else | ||
467 | rv = 0; | ||
468 | 506 | ||
469 | dev_dbg(&acm->control->dev, "%s\n", __func__); | 507 | acm = acm_get_by_index(tty->index); |
508 | if (!acm) | ||
509 | return -ENODEV; | ||
470 | 510 | ||
471 | set_bit(TTY_NO_WRITE_SPLIT, &tty->flags); | 511 | retval = tty_init_termios(tty); |
512 | if (retval) | ||
513 | goto error_init_termios; | ||
472 | 514 | ||
473 | tty->driver_data = acm; | 515 | tty->driver_data = acm; |
474 | tty_port_tty_set(&acm->port, tty); | ||
475 | 516 | ||
476 | if (usb_autopm_get_interface(acm->control) < 0) | 517 | /* Final install (we use the default method) */ |
477 | goto early_bail; | 518 | tty_driver_kref_get(driver); |
478 | else | 519 | tty->count++; |
479 | acm->control->needs_remote_wakeup = 1; | 520 | driver->ttys[tty->index] = tty; |
521 | |||
522 | return 0; | ||
523 | |||
524 | error_init_termios: | ||
525 | tty_port_put(&acm->port); | ||
526 | return retval; | ||
527 | } | ||
528 | |||
529 | static int acm_tty_open(struct tty_struct *tty, struct file *filp) | ||
530 | { | ||
531 | struct acm *acm = tty->driver_data; | ||
532 | |||
533 | dev_dbg(tty->dev, "%s\n", __func__); | ||
534 | |||
535 | return tty_port_open(&acm->port, tty, filp); | ||
536 | } | ||
537 | |||
538 | static int acm_port_activate(struct tty_port *port, struct tty_struct *tty) | ||
539 | { | ||
540 | struct acm *acm = container_of(port, struct acm, port); | ||
541 | int retval = -ENODEV; | ||
542 | |||
543 | dev_dbg(&acm->control->dev, "%s\n", __func__); | ||
480 | 544 | ||
481 | mutex_lock(&acm->mutex); | 545 | mutex_lock(&acm->mutex); |
482 | if (acm->port.count++) { | 546 | if (acm->disconnected) |
483 | mutex_unlock(&acm->mutex); | 547 | goto disconnected; |
484 | usb_autopm_put_interface(acm->control); | 548 | |
485 | goto out; | 549 | retval = usb_autopm_get_interface(acm->control); |
486 | } | 550 | if (retval) |
551 | goto error_get_interface; | ||
552 | |||
553 | /* | ||
554 | * FIXME: Why do we need this? Allocating 64K of physically contiguous | ||
555 | * memory is really nasty... | ||
556 | */ | ||
557 | set_bit(TTY_NO_WRITE_SPLIT, &tty->flags); | ||
558 | acm->control->needs_remote_wakeup = 1; | ||
487 | 559 | ||
488 | acm->ctrlurb->dev = acm->dev; | 560 | acm->ctrlurb->dev = acm->dev; |
489 | if (usb_submit_urb(acm->ctrlurb, GFP_KERNEL)) { | 561 | if (usb_submit_urb(acm->ctrlurb, GFP_KERNEL)) { |
490 | dev_err(&acm->control->dev, | 562 | dev_err(&acm->control->dev, |
491 | "%s - usb_submit_urb(ctrl irq) failed\n", __func__); | 563 | "%s - usb_submit_urb(ctrl irq) failed\n", __func__); |
492 | goto bail_out; | 564 | goto error_submit_urb; |
493 | } | 565 | } |
494 | 566 | ||
495 | if (0 > acm_set_control(acm, acm->ctrlout = ACM_CTRL_DTR | ACM_CTRL_RTS) && | 567 | acm->ctrlout = ACM_CTRL_DTR | ACM_CTRL_RTS; |
568 | if (acm_set_control(acm, acm->ctrlout) < 0 && | ||
496 | (acm->ctrl_caps & USB_CDC_CAP_LINE)) | 569 | (acm->ctrl_caps & USB_CDC_CAP_LINE)) |
497 | goto bail_out; | 570 | goto error_set_control; |
498 | 571 | ||
499 | usb_autopm_put_interface(acm->control); | 572 | usb_autopm_put_interface(acm->control); |
500 | 573 | ||
501 | if (acm_submit_read_urbs(acm, GFP_KERNEL)) | 574 | if (acm_submit_read_urbs(acm, GFP_KERNEL)) |
502 | goto bail_out; | 575 | goto error_submit_read_urbs; |
503 | |||
504 | set_bit(ASYNCB_INITIALIZED, &acm->port.flags); | ||
505 | rv = tty_port_block_til_ready(&acm->port, tty, filp); | ||
506 | 576 | ||
507 | mutex_unlock(&acm->mutex); | 577 | mutex_unlock(&acm->mutex); |
508 | out: | ||
509 | mutex_unlock(&open_mutex); | ||
510 | return rv; | ||
511 | 578 | ||
512 | bail_out: | 579 | return 0; |
513 | acm->port.count--; | 580 | |
514 | mutex_unlock(&acm->mutex); | 581 | error_submit_read_urbs: |
582 | acm->ctrlout = 0; | ||
583 | acm_set_control(acm, acm->ctrlout); | ||
584 | error_set_control: | ||
585 | usb_kill_urb(acm->ctrlurb); | ||
586 | error_submit_urb: | ||
515 | usb_autopm_put_interface(acm->control); | 587 | usb_autopm_put_interface(acm->control); |
516 | early_bail: | 588 | error_get_interface: |
517 | mutex_unlock(&open_mutex); | 589 | disconnected: |
518 | tty_port_tty_set(&acm->port, NULL); | 590 | mutex_unlock(&acm->mutex); |
519 | return -EIO; | 591 | return retval; |
520 | } | 592 | } |
521 | 593 | ||
522 | static void acm_tty_unregister(struct acm *acm) | 594 | static void acm_port_destruct(struct tty_port *port) |
523 | { | 595 | { |
524 | int i; | 596 | struct acm *acm = container_of(port, struct acm, port); |
597 | |||
598 | dev_dbg(&acm->control->dev, "%s\n", __func__); | ||
525 | 599 | ||
526 | tty_unregister_device(acm_tty_driver, acm->minor); | 600 | tty_unregister_device(acm_tty_driver, acm->minor); |
601 | acm_release_minor(acm); | ||
527 | usb_put_intf(acm->control); | 602 | usb_put_intf(acm->control); |
528 | acm_table[acm->minor] = NULL; | ||
529 | usb_free_urb(acm->ctrlurb); | ||
530 | for (i = 0; i < ACM_NW; i++) | ||
531 | usb_free_urb(acm->wb[i].urb); | ||
532 | for (i = 0; i < acm->rx_buflimit; i++) | ||
533 | usb_free_urb(acm->read_urbs[i]); | ||
534 | kfree(acm->country_codes); | 603 | kfree(acm->country_codes); |
535 | kfree(acm); | 604 | kfree(acm); |
536 | } | 605 | } |
537 | 606 | ||
538 | static void acm_port_down(struct acm *acm) | 607 | static void acm_port_shutdown(struct tty_port *port) |
539 | { | 608 | { |
609 | struct acm *acm = container_of(port, struct acm, port); | ||
540 | int i; | 610 | int i; |
541 | 611 | ||
542 | mutex_lock(&open_mutex); | 612 | dev_dbg(&acm->control->dev, "%s\n", __func__); |
543 | if (acm->dev) { | 613 | |
614 | mutex_lock(&acm->mutex); | ||
615 | if (!acm->disconnected) { | ||
544 | usb_autopm_get_interface(acm->control); | 616 | usb_autopm_get_interface(acm->control); |
545 | acm_set_control(acm, acm->ctrlout = 0); | 617 | acm_set_control(acm, acm->ctrlout = 0); |
546 | usb_kill_urb(acm->ctrlurb); | 618 | usb_kill_urb(acm->ctrlurb); |
@@ -551,37 +623,28 @@ static void acm_port_down(struct acm *acm) | |||
551 | acm->control->needs_remote_wakeup = 0; | 623 | acm->control->needs_remote_wakeup = 0; |
552 | usb_autopm_put_interface(acm->control); | 624 | usb_autopm_put_interface(acm->control); |
553 | } | 625 | } |
554 | mutex_unlock(&open_mutex); | 626 | mutex_unlock(&acm->mutex); |
627 | } | ||
628 | |||
629 | static void acm_tty_cleanup(struct tty_struct *tty) | ||
630 | { | ||
631 | struct acm *acm = tty->driver_data; | ||
632 | dev_dbg(&acm->control->dev, "%s\n", __func__); | ||
633 | tty_port_put(&acm->port); | ||
555 | } | 634 | } |
556 | 635 | ||
557 | static void acm_tty_hangup(struct tty_struct *tty) | 636 | static void acm_tty_hangup(struct tty_struct *tty) |
558 | { | 637 | { |
559 | struct acm *acm = tty->driver_data; | 638 | struct acm *acm = tty->driver_data; |
639 | dev_dbg(&acm->control->dev, "%s\n", __func__); | ||
560 | tty_port_hangup(&acm->port); | 640 | tty_port_hangup(&acm->port); |
561 | acm_port_down(acm); | ||
562 | } | 641 | } |
563 | 642 | ||
564 | static void acm_tty_close(struct tty_struct *tty, struct file *filp) | 643 | static void acm_tty_close(struct tty_struct *tty, struct file *filp) |
565 | { | 644 | { |
566 | struct acm *acm = tty->driver_data; | 645 | struct acm *acm = tty->driver_data; |
567 | 646 | dev_dbg(&acm->control->dev, "%s\n", __func__); | |
568 | /* Perform the closing process and see if we need to do the hardware | 647 | tty_port_close(&acm->port, tty, filp); |
569 | shutdown */ | ||
570 | if (!acm) | ||
571 | return; | ||
572 | if (tty_port_close_start(&acm->port, tty, filp) == 0) { | ||
573 | mutex_lock(&open_mutex); | ||
574 | if (!acm->dev) { | ||
575 | tty_port_tty_set(&acm->port, NULL); | ||
576 | acm_tty_unregister(acm); | ||
577 | tty->driver_data = NULL; | ||
578 | } | ||
579 | mutex_unlock(&open_mutex); | ||
580 | return; | ||
581 | } | ||
582 | acm_port_down(acm); | ||
583 | tty_port_close_end(&acm->port, tty); | ||
584 | tty_port_tty_set(&acm->port, NULL); | ||
585 | } | 648 | } |
586 | 649 | ||
587 | static int acm_tty_write(struct tty_struct *tty, | 650 | static int acm_tty_write(struct tty_struct *tty, |
@@ -593,8 +656,6 @@ static int acm_tty_write(struct tty_struct *tty, | |||
593 | int wbn; | 656 | int wbn; |
594 | struct acm_wb *wb; | 657 | struct acm_wb *wb; |
595 | 658 | ||
596 | if (!ACM_READY(acm)) | ||
597 | return -EINVAL; | ||
598 | if (!count) | 659 | if (!count) |
599 | return 0; | 660 | return 0; |
600 | 661 | ||
@@ -623,8 +684,6 @@ static int acm_tty_write(struct tty_struct *tty, | |||
623 | static int acm_tty_write_room(struct tty_struct *tty) | 684 | static int acm_tty_write_room(struct tty_struct *tty) |
624 | { | 685 | { |
625 | struct acm *acm = tty->driver_data; | 686 | struct acm *acm = tty->driver_data; |
626 | if (!ACM_READY(acm)) | ||
627 | return -EINVAL; | ||
628 | /* | 687 | /* |
629 | * Do not let the line discipline to know that we have a reserve, | 688 | * Do not let the line discipline to know that we have a reserve, |
630 | * or it might get too enthusiastic. | 689 | * or it might get too enthusiastic. |
@@ -635,7 +694,11 @@ static int acm_tty_write_room(struct tty_struct *tty) | |||
635 | static int acm_tty_chars_in_buffer(struct tty_struct *tty) | 694 | static int acm_tty_chars_in_buffer(struct tty_struct *tty) |
636 | { | 695 | { |
637 | struct acm *acm = tty->driver_data; | 696 | struct acm *acm = tty->driver_data; |
638 | if (!ACM_READY(acm)) | 697 | /* |
698 | * if the device was unplugged then any remaining characters fell out | ||
699 | * of the connector ;) | ||
700 | */ | ||
701 | if (acm->disconnected) | ||
639 | return 0; | 702 | return 0; |
640 | /* | 703 | /* |
641 | * This is inaccurate (overcounts), but it works. | 704 | * This is inaccurate (overcounts), but it works. |
@@ -647,9 +710,6 @@ static void acm_tty_throttle(struct tty_struct *tty) | |||
647 | { | 710 | { |
648 | struct acm *acm = tty->driver_data; | 711 | struct acm *acm = tty->driver_data; |
649 | 712 | ||
650 | if (!ACM_READY(acm)) | ||
651 | return; | ||
652 | |||
653 | spin_lock_irq(&acm->read_lock); | 713 | spin_lock_irq(&acm->read_lock); |
654 | acm->throttle_req = 1; | 714 | acm->throttle_req = 1; |
655 | spin_unlock_irq(&acm->read_lock); | 715 | spin_unlock_irq(&acm->read_lock); |
@@ -660,9 +720,6 @@ static void acm_tty_unthrottle(struct tty_struct *tty) | |||
660 | struct acm *acm = tty->driver_data; | 720 | struct acm *acm = tty->driver_data; |
661 | unsigned int was_throttled; | 721 | unsigned int was_throttled; |
662 | 722 | ||
663 | if (!ACM_READY(acm)) | ||
664 | return; | ||
665 | |||
666 | spin_lock_irq(&acm->read_lock); | 723 | spin_lock_irq(&acm->read_lock); |
667 | was_throttled = acm->throttled; | 724 | was_throttled = acm->throttled; |
668 | acm->throttled = 0; | 725 | acm->throttled = 0; |
@@ -677,8 +734,7 @@ static int acm_tty_break_ctl(struct tty_struct *tty, int state) | |||
677 | { | 734 | { |
678 | struct acm *acm = tty->driver_data; | 735 | struct acm *acm = tty->driver_data; |
679 | int retval; | 736 | int retval; |
680 | if (!ACM_READY(acm)) | 737 | |
681 | return -EINVAL; | ||
682 | retval = acm_send_break(acm, state ? 0xffff : 0); | 738 | retval = acm_send_break(acm, state ? 0xffff : 0); |
683 | if (retval < 0) | 739 | if (retval < 0) |
684 | dev_dbg(&acm->control->dev, "%s - send break failed\n", | 740 | dev_dbg(&acm->control->dev, "%s - send break failed\n", |
@@ -690,9 +746,6 @@ static int acm_tty_tiocmget(struct tty_struct *tty) | |||
690 | { | 746 | { |
691 | struct acm *acm = tty->driver_data; | 747 | struct acm *acm = tty->driver_data; |
692 | 748 | ||
693 | if (!ACM_READY(acm)) | ||
694 | return -EINVAL; | ||
695 | |||
696 | return (acm->ctrlout & ACM_CTRL_DTR ? TIOCM_DTR : 0) | | 749 | return (acm->ctrlout & ACM_CTRL_DTR ? TIOCM_DTR : 0) | |
697 | (acm->ctrlout & ACM_CTRL_RTS ? TIOCM_RTS : 0) | | 750 | (acm->ctrlout & ACM_CTRL_RTS ? TIOCM_RTS : 0) | |
698 | (acm->ctrlin & ACM_CTRL_DSR ? TIOCM_DSR : 0) | | 751 | (acm->ctrlin & ACM_CTRL_DSR ? TIOCM_DSR : 0) | |
@@ -707,9 +760,6 @@ static int acm_tty_tiocmset(struct tty_struct *tty, | |||
707 | struct acm *acm = tty->driver_data; | 760 | struct acm *acm = tty->driver_data; |
708 | unsigned int newctrl; | 761 | unsigned int newctrl; |
709 | 762 | ||
710 | if (!ACM_READY(acm)) | ||
711 | return -EINVAL; | ||
712 | |||
713 | newctrl = acm->ctrlout; | 763 | newctrl = acm->ctrlout; |
714 | set = (set & TIOCM_DTR ? ACM_CTRL_DTR : 0) | | 764 | set = (set & TIOCM_DTR ? ACM_CTRL_DTR : 0) | |
715 | (set & TIOCM_RTS ? ACM_CTRL_RTS : 0); | 765 | (set & TIOCM_RTS ? ACM_CTRL_RTS : 0); |
@@ -726,11 +776,6 @@ static int acm_tty_tiocmset(struct tty_struct *tty, | |||
726 | static int acm_tty_ioctl(struct tty_struct *tty, | 776 | static int acm_tty_ioctl(struct tty_struct *tty, |
727 | unsigned int cmd, unsigned long arg) | 777 | unsigned int cmd, unsigned long arg) |
728 | { | 778 | { |
729 | struct acm *acm = tty->driver_data; | ||
730 | |||
731 | if (!ACM_READY(acm)) | ||
732 | return -EINVAL; | ||
733 | |||
734 | return -ENOIOCTLCMD; | 779 | return -ENOIOCTLCMD; |
735 | } | 780 | } |
736 | 781 | ||
@@ -754,9 +799,6 @@ static void acm_tty_set_termios(struct tty_struct *tty, | |||
754 | struct usb_cdc_line_coding newline; | 799 | struct usb_cdc_line_coding newline; |
755 | int newctrl = acm->ctrlout; | 800 | int newctrl = acm->ctrlout; |
756 | 801 | ||
757 | if (!ACM_READY(acm)) | ||
758 | return; | ||
759 | |||
760 | newline.dwDTERate = cpu_to_le32(tty_get_baud_rate(tty)); | 802 | newline.dwDTERate = cpu_to_le32(tty_get_baud_rate(tty)); |
761 | newline.bCharFormat = termios->c_cflag & CSTOPB ? 2 : 0; | 803 | newline.bCharFormat = termios->c_cflag & CSTOPB ? 2 : 0; |
762 | newline.bParityType = termios->c_cflag & PARENB ? | 804 | newline.bParityType = termios->c_cflag & PARENB ? |
@@ -786,6 +828,12 @@ static void acm_tty_set_termios(struct tty_struct *tty, | |||
786 | } | 828 | } |
787 | } | 829 | } |
788 | 830 | ||
831 | static const struct tty_port_operations acm_port_ops = { | ||
832 | .shutdown = acm_port_shutdown, | ||
833 | .activate = acm_port_activate, | ||
834 | .destruct = acm_port_destruct, | ||
835 | }; | ||
836 | |||
789 | /* | 837 | /* |
790 | * USB probe and disconnect routines. | 838 | * USB probe and disconnect routines. |
791 | */ | 839 | */ |
@@ -1045,12 +1093,6 @@ skip_normal_probe: | |||
1045 | } | 1093 | } |
1046 | made_compressed_probe: | 1094 | made_compressed_probe: |
1047 | dev_dbg(&intf->dev, "interfaces are valid\n"); | 1095 | dev_dbg(&intf->dev, "interfaces are valid\n"); |
1048 | for (minor = 0; minor < ACM_TTY_MINORS && acm_table[minor]; minor++); | ||
1049 | |||
1050 | if (minor == ACM_TTY_MINORS) { | ||
1051 | dev_err(&intf->dev, "no more free acm devices\n"); | ||
1052 | return -ENODEV; | ||
1053 | } | ||
1054 | 1096 | ||
1055 | acm = kzalloc(sizeof(struct acm), GFP_KERNEL); | 1097 | acm = kzalloc(sizeof(struct acm), GFP_KERNEL); |
1056 | if (acm == NULL) { | 1098 | if (acm == NULL) { |
@@ -1058,6 +1100,13 @@ made_compressed_probe: | |||
1058 | goto alloc_fail; | 1100 | goto alloc_fail; |
1059 | } | 1101 | } |
1060 | 1102 | ||
1103 | minor = acm_alloc_minor(acm); | ||
1104 | if (minor == ACM_TTY_MINORS) { | ||
1105 | dev_err(&intf->dev, "no more free acm devices\n"); | ||
1106 | kfree(acm); | ||
1107 | return -ENODEV; | ||
1108 | } | ||
1109 | |||
1061 | ctrlsize = usb_endpoint_maxp(epctrl); | 1110 | ctrlsize = usb_endpoint_maxp(epctrl); |
1062 | readsize = usb_endpoint_maxp(epread) * | 1111 | readsize = usb_endpoint_maxp(epread) * |
1063 | (quirks == SINGLE_RX_URB ? 1 : 2); | 1112 | (quirks == SINGLE_RX_URB ? 1 : 2); |
@@ -1181,6 +1230,8 @@ made_compressed_probe: | |||
1181 | i = device_create_file(&intf->dev, &dev_attr_wCountryCodes); | 1230 | i = device_create_file(&intf->dev, &dev_attr_wCountryCodes); |
1182 | if (i < 0) { | 1231 | if (i < 0) { |
1183 | kfree(acm->country_codes); | 1232 | kfree(acm->country_codes); |
1233 | acm->country_codes = NULL; | ||
1234 | acm->country_code_size = 0; | ||
1184 | goto skip_countries; | 1235 | goto skip_countries; |
1185 | } | 1236 | } |
1186 | 1237 | ||
@@ -1189,6 +1240,8 @@ made_compressed_probe: | |||
1189 | if (i < 0) { | 1240 | if (i < 0) { |
1190 | device_remove_file(&intf->dev, &dev_attr_wCountryCodes); | 1241 | device_remove_file(&intf->dev, &dev_attr_wCountryCodes); |
1191 | kfree(acm->country_codes); | 1242 | kfree(acm->country_codes); |
1243 | acm->country_codes = NULL; | ||
1244 | acm->country_code_size = 0; | ||
1192 | goto skip_countries; | 1245 | goto skip_countries; |
1193 | } | 1246 | } |
1194 | } | 1247 | } |
@@ -1216,8 +1269,6 @@ skip_countries: | |||
1216 | usb_get_intf(control_interface); | 1269 | usb_get_intf(control_interface); |
1217 | tty_register_device(acm_tty_driver, minor, &control_interface->dev); | 1270 | tty_register_device(acm_tty_driver, minor, &control_interface->dev); |
1218 | 1271 | ||
1219 | acm_table[minor] = acm; | ||
1220 | |||
1221 | return 0; | 1272 | return 0; |
1222 | alloc_fail7: | 1273 | alloc_fail7: |
1223 | for (i = 0; i < ACM_NW; i++) | 1274 | for (i = 0; i < ACM_NW; i++) |
@@ -1232,6 +1283,7 @@ alloc_fail5: | |||
1232 | alloc_fail4: | 1283 | alloc_fail4: |
1233 | usb_free_coherent(usb_dev, ctrlsize, acm->ctrl_buffer, acm->ctrl_dma); | 1284 | usb_free_coherent(usb_dev, ctrlsize, acm->ctrl_buffer, acm->ctrl_dma); |
1234 | alloc_fail2: | 1285 | alloc_fail2: |
1286 | acm_release_minor(acm); | ||
1235 | kfree(acm); | 1287 | kfree(acm); |
1236 | alloc_fail: | 1288 | alloc_fail: |
1237 | return -ENOMEM; | 1289 | return -ENOMEM; |
@@ -1257,12 +1309,16 @@ static void acm_disconnect(struct usb_interface *intf) | |||
1257 | struct acm *acm = usb_get_intfdata(intf); | 1309 | struct acm *acm = usb_get_intfdata(intf); |
1258 | struct usb_device *usb_dev = interface_to_usbdev(intf); | 1310 | struct usb_device *usb_dev = interface_to_usbdev(intf); |
1259 | struct tty_struct *tty; | 1311 | struct tty_struct *tty; |
1312 | int i; | ||
1313 | |||
1314 | dev_dbg(&intf->dev, "%s\n", __func__); | ||
1260 | 1315 | ||
1261 | /* sibling interface is already cleaning up */ | 1316 | /* sibling interface is already cleaning up */ |
1262 | if (!acm) | 1317 | if (!acm) |
1263 | return; | 1318 | return; |
1264 | 1319 | ||
1265 | mutex_lock(&open_mutex); | 1320 | mutex_lock(&acm->mutex); |
1321 | acm->disconnected = true; | ||
1266 | if (acm->country_codes) { | 1322 | if (acm->country_codes) { |
1267 | device_remove_file(&acm->control->dev, | 1323 | device_remove_file(&acm->control->dev, |
1268 | &dev_attr_wCountryCodes); | 1324 | &dev_attr_wCountryCodes); |
@@ -1270,33 +1326,32 @@ static void acm_disconnect(struct usb_interface *intf) | |||
1270 | &dev_attr_iCountryCodeRelDate); | 1326 | &dev_attr_iCountryCodeRelDate); |
1271 | } | 1327 | } |
1272 | device_remove_file(&acm->control->dev, &dev_attr_bmCapabilities); | 1328 | device_remove_file(&acm->control->dev, &dev_attr_bmCapabilities); |
1273 | acm->dev = NULL; | ||
1274 | usb_set_intfdata(acm->control, NULL); | 1329 | usb_set_intfdata(acm->control, NULL); |
1275 | usb_set_intfdata(acm->data, NULL); | 1330 | usb_set_intfdata(acm->data, NULL); |
1331 | mutex_unlock(&acm->mutex); | ||
1332 | |||
1333 | tty = tty_port_tty_get(&acm->port); | ||
1334 | if (tty) { | ||
1335 | tty_vhangup(tty); | ||
1336 | tty_kref_put(tty); | ||
1337 | } | ||
1276 | 1338 | ||
1277 | stop_data_traffic(acm); | 1339 | stop_data_traffic(acm); |
1278 | 1340 | ||
1341 | usb_free_urb(acm->ctrlurb); | ||
1342 | for (i = 0; i < ACM_NW; i++) | ||
1343 | usb_free_urb(acm->wb[i].urb); | ||
1344 | for (i = 0; i < acm->rx_buflimit; i++) | ||
1345 | usb_free_urb(acm->read_urbs[i]); | ||
1279 | acm_write_buffers_free(acm); | 1346 | acm_write_buffers_free(acm); |
1280 | usb_free_coherent(usb_dev, acm->ctrlsize, acm->ctrl_buffer, | 1347 | usb_free_coherent(usb_dev, acm->ctrlsize, acm->ctrl_buffer, acm->ctrl_dma); |
1281 | acm->ctrl_dma); | ||
1282 | acm_read_buffers_free(acm); | 1348 | acm_read_buffers_free(acm); |
1283 | 1349 | ||
1284 | if (!acm->combined_interfaces) | 1350 | if (!acm->combined_interfaces) |
1285 | usb_driver_release_interface(&acm_driver, intf == acm->control ? | 1351 | usb_driver_release_interface(&acm_driver, intf == acm->control ? |
1286 | acm->data : acm->control); | 1352 | acm->data : acm->control); |
1287 | 1353 | ||
1288 | if (acm->port.count == 0) { | 1354 | tty_port_put(&acm->port); |
1289 | acm_tty_unregister(acm); | ||
1290 | mutex_unlock(&open_mutex); | ||
1291 | return; | ||
1292 | } | ||
1293 | |||
1294 | mutex_unlock(&open_mutex); | ||
1295 | tty = tty_port_tty_get(&acm->port); | ||
1296 | if (tty) { | ||
1297 | tty_hangup(tty); | ||
1298 | tty_kref_put(tty); | ||
1299 | } | ||
1300 | } | 1355 | } |
1301 | 1356 | ||
1302 | #ifdef CONFIG_PM | 1357 | #ifdef CONFIG_PM |
@@ -1323,16 +1378,10 @@ static int acm_suspend(struct usb_interface *intf, pm_message_t message) | |||
1323 | 1378 | ||
1324 | if (cnt) | 1379 | if (cnt) |
1325 | return 0; | 1380 | return 0; |
1326 | /* | ||
1327 | we treat opened interfaces differently, | ||
1328 | we must guard against open | ||
1329 | */ | ||
1330 | mutex_lock(&acm->mutex); | ||
1331 | 1381 | ||
1332 | if (acm->port.count) | 1382 | if (test_bit(ASYNCB_INITIALIZED, &acm->port.flags)) |
1333 | stop_data_traffic(acm); | 1383 | stop_data_traffic(acm); |
1334 | 1384 | ||
1335 | mutex_unlock(&acm->mutex); | ||
1336 | return 0; | 1385 | return 0; |
1337 | } | 1386 | } |
1338 | 1387 | ||
@@ -1351,8 +1400,7 @@ static int acm_resume(struct usb_interface *intf) | |||
1351 | if (cnt) | 1400 | if (cnt) |
1352 | return 0; | 1401 | return 0; |
1353 | 1402 | ||
1354 | mutex_lock(&acm->mutex); | 1403 | if (test_bit(ASYNCB_INITIALIZED, &acm->port.flags)) { |
1355 | if (acm->port.count) { | ||
1356 | rv = usb_submit_urb(acm->ctrlurb, GFP_NOIO); | 1404 | rv = usb_submit_urb(acm->ctrlurb, GFP_NOIO); |
1357 | 1405 | ||
1358 | spin_lock_irq(&acm->write_lock); | 1406 | spin_lock_irq(&acm->write_lock); |
@@ -1376,7 +1424,6 @@ static int acm_resume(struct usb_interface *intf) | |||
1376 | } | 1424 | } |
1377 | 1425 | ||
1378 | err_out: | 1426 | err_out: |
1379 | mutex_unlock(&acm->mutex); | ||
1380 | return rv; | 1427 | return rv; |
1381 | } | 1428 | } |
1382 | 1429 | ||
@@ -1385,15 +1432,14 @@ static int acm_reset_resume(struct usb_interface *intf) | |||
1385 | struct acm *acm = usb_get_intfdata(intf); | 1432 | struct acm *acm = usb_get_intfdata(intf); |
1386 | struct tty_struct *tty; | 1433 | struct tty_struct *tty; |
1387 | 1434 | ||
1388 | mutex_lock(&acm->mutex); | 1435 | if (test_bit(ASYNCB_INITIALIZED, &acm->port.flags)) { |
1389 | if (acm->port.count) { | ||
1390 | tty = tty_port_tty_get(&acm->port); | 1436 | tty = tty_port_tty_get(&acm->port); |
1391 | if (tty) { | 1437 | if (tty) { |
1392 | tty_hangup(tty); | 1438 | tty_hangup(tty); |
1393 | tty_kref_put(tty); | 1439 | tty_kref_put(tty); |
1394 | } | 1440 | } |
1395 | } | 1441 | } |
1396 | mutex_unlock(&acm->mutex); | 1442 | |
1397 | return acm_resume(intf); | 1443 | return acm_resume(intf); |
1398 | } | 1444 | } |
1399 | 1445 | ||
@@ -1456,6 +1502,16 @@ static const struct usb_device_id acm_ids[] = { | |||
1456 | }, | 1502 | }, |
1457 | { USB_DEVICE(0x22b8, 0x6425), /* Motorola MOTOMAGX phones */ | 1503 | { USB_DEVICE(0x22b8, 0x6425), /* Motorola MOTOMAGX phones */ |
1458 | }, | 1504 | }, |
1505 | /* Motorola H24 HSPA module: */ | ||
1506 | { USB_DEVICE(0x22b8, 0x2d91) }, /* modem */ | ||
1507 | { USB_DEVICE(0x22b8, 0x2d92) }, /* modem + diagnostics */ | ||
1508 | { USB_DEVICE(0x22b8, 0x2d93) }, /* modem + AT port */ | ||
1509 | { USB_DEVICE(0x22b8, 0x2d95) }, /* modem + AT port + diagnostics */ | ||
1510 | { USB_DEVICE(0x22b8, 0x2d96) }, /* modem + NMEA */ | ||
1511 | { USB_DEVICE(0x22b8, 0x2d97) }, /* modem + diagnostics + NMEA */ | ||
1512 | { USB_DEVICE(0x22b8, 0x2d99) }, /* modem + AT port + NMEA */ | ||
1513 | { USB_DEVICE(0x22b8, 0x2d9a) }, /* modem + AT port + diagnostics + NMEA */ | ||
1514 | |||
1459 | { USB_DEVICE(0x0572, 0x1329), /* Hummingbird huc56s (Conexant) */ | 1515 | { USB_DEVICE(0x0572, 0x1329), /* Hummingbird huc56s (Conexant) */ |
1460 | .driver_info = NO_UNION_NORMAL, /* union descriptor misplaced on | 1516 | .driver_info = NO_UNION_NORMAL, /* union descriptor misplaced on |
1461 | data interface instead of | 1517 | data interface instead of |
@@ -1592,8 +1648,10 @@ static struct usb_driver acm_driver = { | |||
1592 | */ | 1648 | */ |
1593 | 1649 | ||
1594 | static const struct tty_operations acm_ops = { | 1650 | static const struct tty_operations acm_ops = { |
1651 | .install = acm_tty_install, | ||
1595 | .open = acm_tty_open, | 1652 | .open = acm_tty_open, |
1596 | .close = acm_tty_close, | 1653 | .close = acm_tty_close, |
1654 | .cleanup = acm_tty_cleanup, | ||
1597 | .hangup = acm_tty_hangup, | 1655 | .hangup = acm_tty_hangup, |
1598 | .write = acm_tty_write, | 1656 | .write = acm_tty_write, |
1599 | .write_room = acm_tty_write_room, | 1657 | .write_room = acm_tty_write_room, |
diff --git a/drivers/usb/class/cdc-acm.h b/drivers/usb/class/cdc-acm.h index ca7937f26e27..35ef887b7417 100644 --- a/drivers/usb/class/cdc-acm.h +++ b/drivers/usb/class/cdc-acm.h | |||
@@ -101,6 +101,7 @@ struct acm { | |||
101 | int transmitting; | 101 | int transmitting; |
102 | spinlock_t write_lock; | 102 | spinlock_t write_lock; |
103 | struct mutex mutex; | 103 | struct mutex mutex; |
104 | bool disconnected; | ||
104 | struct usb_cdc_line_coding line; /* bits, stop, parity */ | 105 | struct usb_cdc_line_coding line; /* bits, stop, parity */ |
105 | struct work_struct work; /* work queue entry for line discipline waking up */ | 106 | struct work_struct work; /* work queue entry for line discipline waking up */ |
106 | unsigned int ctrlin; /* input control lines (DCD, DSR, RI, break, overruns) */ | 107 | unsigned int ctrlin; /* input control lines (DCD, DSR, RI, break, overruns) */ |
diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c index efe684908c1f..1c50baff7725 100644 --- a/drivers/usb/class/cdc-wdm.c +++ b/drivers/usb/class/cdc-wdm.c | |||
@@ -895,24 +895,7 @@ static struct usb_driver wdm_driver = { | |||
895 | .supports_autosuspend = 1, | 895 | .supports_autosuspend = 1, |
896 | }; | 896 | }; |
897 | 897 | ||
898 | /* --- low level module stuff --- */ | 898 | module_usb_driver(wdm_driver); |
899 | |||
900 | static int __init wdm_init(void) | ||
901 | { | ||
902 | int rv; | ||
903 | |||
904 | rv = usb_register(&wdm_driver); | ||
905 | |||
906 | return rv; | ||
907 | } | ||
908 | |||
909 | static void __exit wdm_exit(void) | ||
910 | { | ||
911 | usb_deregister(&wdm_driver); | ||
912 | } | ||
913 | |||
914 | module_init(wdm_init); | ||
915 | module_exit(wdm_exit); | ||
916 | 899 | ||
917 | MODULE_AUTHOR(DRIVER_AUTHOR); | 900 | MODULE_AUTHOR(DRIVER_AUTHOR); |
918 | MODULE_DESCRIPTION(DRIVER_DESC); | 901 | MODULE_DESCRIPTION(DRIVER_DESC); |
diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c index cb3a93243a05..a68c1a63dc65 100644 --- a/drivers/usb/class/usblp.c +++ b/drivers/usb/class/usblp.c | |||
@@ -1045,7 +1045,7 @@ static const struct file_operations usblp_fops = { | |||
1045 | .llseek = noop_llseek, | 1045 | .llseek = noop_llseek, |
1046 | }; | 1046 | }; |
1047 | 1047 | ||
1048 | static char *usblp_devnode(struct device *dev, mode_t *mode) | 1048 | static char *usblp_devnode(struct device *dev, umode_t *mode) |
1049 | { | 1049 | { |
1050 | return kasprintf(GFP_KERNEL, "usb/%s", dev_name(dev)); | 1050 | return kasprintf(GFP_KERNEL, "usb/%s", dev_name(dev)); |
1051 | } | 1051 | } |
@@ -1412,18 +1412,7 @@ static struct usb_driver usblp_driver = { | |||
1412 | .supports_autosuspend = 1, | 1412 | .supports_autosuspend = 1, |
1413 | }; | 1413 | }; |
1414 | 1414 | ||
1415 | static int __init usblp_init(void) | 1415 | module_usb_driver(usblp_driver); |
1416 | { | ||
1417 | return usb_register(&usblp_driver); | ||
1418 | } | ||
1419 | |||
1420 | static void __exit usblp_exit(void) | ||
1421 | { | ||
1422 | usb_deregister(&usblp_driver); | ||
1423 | } | ||
1424 | |||
1425 | module_init(usblp_init); | ||
1426 | module_exit(usblp_exit); | ||
1427 | 1416 | ||
1428 | MODULE_AUTHOR(DRIVER_AUTHOR); | 1417 | MODULE_AUTHOR(DRIVER_AUTHOR); |
1429 | MODULE_DESCRIPTION(DRIVER_DESC); | 1418 | MODULE_DESCRIPTION(DRIVER_DESC); |
diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c index 12cf5e7395a8..70d69d06054f 100644 --- a/drivers/usb/class/usbtmc.c +++ b/drivers/usb/class/usbtmc.c | |||
@@ -1116,21 +1116,6 @@ static struct usb_driver usbtmc_driver = { | |||
1116 | .resume = usbtmc_resume, | 1116 | .resume = usbtmc_resume, |
1117 | }; | 1117 | }; |
1118 | 1118 | ||
1119 | static int __init usbtmc_init(void) | 1119 | module_usb_driver(usbtmc_driver); |
1120 | { | ||
1121 | int retcode; | ||
1122 | |||
1123 | retcode = usb_register(&usbtmc_driver); | ||
1124 | if (retcode) | ||
1125 | printk(KERN_ERR KBUILD_MODNAME": Unable to register driver\n"); | ||
1126 | return retcode; | ||
1127 | } | ||
1128 | module_init(usbtmc_init); | ||
1129 | |||
1130 | static void __exit usbtmc_exit(void) | ||
1131 | { | ||
1132 | usb_deregister(&usbtmc_driver); | ||
1133 | } | ||
1134 | module_exit(usbtmc_exit); | ||
1135 | 1120 | ||
1136 | MODULE_LICENSE("GPL"); | 1121 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c index e3beaf229ee3..8df4b76465ac 100644 --- a/drivers/usb/core/devio.c +++ b/drivers/usb/core/devio.c | |||
@@ -86,13 +86,14 @@ struct async { | |||
86 | void __user *userbuffer; | 86 | void __user *userbuffer; |
87 | void __user *userurb; | 87 | void __user *userurb; |
88 | struct urb *urb; | 88 | struct urb *urb; |
89 | unsigned int mem_usage; | ||
89 | int status; | 90 | int status; |
90 | u32 secid; | 91 | u32 secid; |
91 | u8 bulk_addr; | 92 | u8 bulk_addr; |
92 | u8 bulk_status; | 93 | u8 bulk_status; |
93 | }; | 94 | }; |
94 | 95 | ||
95 | static int usbfs_snoop; | 96 | static bool usbfs_snoop; |
96 | module_param(usbfs_snoop, bool, S_IRUGO | S_IWUSR); | 97 | module_param(usbfs_snoop, bool, S_IRUGO | S_IWUSR); |
97 | MODULE_PARM_DESC(usbfs_snoop, "true to log all usbfs traffic"); | 98 | MODULE_PARM_DESC(usbfs_snoop, "true to log all usbfs traffic"); |
98 | 99 | ||
@@ -108,8 +109,44 @@ enum snoop_when { | |||
108 | 109 | ||
109 | #define USB_DEVICE_DEV MKDEV(USB_DEVICE_MAJOR, 0) | 110 | #define USB_DEVICE_DEV MKDEV(USB_DEVICE_MAJOR, 0) |
110 | 111 | ||
111 | #define MAX_USBFS_BUFFER_SIZE 16384 | 112 | /* Limit on the total amount of memory we can allocate for transfers */ |
113 | static unsigned usbfs_memory_mb = 16; | ||
114 | module_param(usbfs_memory_mb, uint, 0644); | ||
115 | MODULE_PARM_DESC(usbfs_memory_mb, | ||
116 | "maximum MB allowed for usbfs buffers (0 = no limit)"); | ||
112 | 117 | ||
118 | /* Hard limit, necessary to avoid aithmetic overflow */ | ||
119 | #define USBFS_XFER_MAX (UINT_MAX / 2 - 1000000) | ||
120 | |||
121 | static atomic_t usbfs_memory_usage; /* Total memory currently allocated */ | ||
122 | |||
123 | /* Check whether it's okay to allocate more memory for a transfer */ | ||
124 | static int usbfs_increase_memory_usage(unsigned amount) | ||
125 | { | ||
126 | unsigned lim; | ||
127 | |||
128 | /* | ||
129 | * Convert usbfs_memory_mb to bytes, avoiding overflows. | ||
130 | * 0 means use the hard limit (effectively unlimited). | ||
131 | */ | ||
132 | lim = ACCESS_ONCE(usbfs_memory_mb); | ||
133 | if (lim == 0 || lim > (USBFS_XFER_MAX >> 20)) | ||
134 | lim = USBFS_XFER_MAX; | ||
135 | else | ||
136 | lim <<= 20; | ||
137 | |||
138 | atomic_add(amount, &usbfs_memory_usage); | ||
139 | if (atomic_read(&usbfs_memory_usage) <= lim) | ||
140 | return 0; | ||
141 | atomic_sub(amount, &usbfs_memory_usage); | ||
142 | return -ENOMEM; | ||
143 | } | ||
144 | |||
145 | /* Memory for a transfer is being deallocated */ | ||
146 | static void usbfs_decrease_memory_usage(unsigned amount) | ||
147 | { | ||
148 | atomic_sub(amount, &usbfs_memory_usage); | ||
149 | } | ||
113 | 150 | ||
114 | static int connected(struct dev_state *ps) | 151 | static int connected(struct dev_state *ps) |
115 | { | 152 | { |
@@ -249,10 +286,12 @@ static struct async *alloc_async(unsigned int numisoframes) | |||
249 | static void free_async(struct async *as) | 286 | static void free_async(struct async *as) |
250 | { | 287 | { |
251 | put_pid(as->pid); | 288 | put_pid(as->pid); |
252 | put_cred(as->cred); | 289 | if (as->cred) |
290 | put_cred(as->cred); | ||
253 | kfree(as->urb->transfer_buffer); | 291 | kfree(as->urb->transfer_buffer); |
254 | kfree(as->urb->setup_packet); | 292 | kfree(as->urb->setup_packet); |
255 | usb_free_urb(as->urb); | 293 | usb_free_urb(as->urb); |
294 | usbfs_decrease_memory_usage(as->mem_usage); | ||
256 | kfree(as); | 295 | kfree(as); |
257 | } | 296 | } |
258 | 297 | ||
@@ -792,9 +831,15 @@ static int proc_control(struct dev_state *ps, void __user *arg) | |||
792 | wLength = ctrl.wLength; /* To suppress 64k PAGE_SIZE warning */ | 831 | wLength = ctrl.wLength; /* To suppress 64k PAGE_SIZE warning */ |
793 | if (wLength > PAGE_SIZE) | 832 | if (wLength > PAGE_SIZE) |
794 | return -EINVAL; | 833 | return -EINVAL; |
834 | ret = usbfs_increase_memory_usage(PAGE_SIZE + sizeof(struct urb) + | ||
835 | sizeof(struct usb_ctrlrequest)); | ||
836 | if (ret) | ||
837 | return ret; | ||
795 | tbuf = (unsigned char *)__get_free_page(GFP_KERNEL); | 838 | tbuf = (unsigned char *)__get_free_page(GFP_KERNEL); |
796 | if (!tbuf) | 839 | if (!tbuf) { |
797 | return -ENOMEM; | 840 | ret = -ENOMEM; |
841 | goto done; | ||
842 | } | ||
798 | tmo = ctrl.timeout; | 843 | tmo = ctrl.timeout; |
799 | snoop(&dev->dev, "control urb: bRequestType=%02x " | 844 | snoop(&dev->dev, "control urb: bRequestType=%02x " |
800 | "bRequest=%02x wValue=%04x " | 845 | "bRequest=%02x wValue=%04x " |
@@ -806,8 +851,8 @@ static int proc_control(struct dev_state *ps, void __user *arg) | |||
806 | if (ctrl.bRequestType & 0x80) { | 851 | if (ctrl.bRequestType & 0x80) { |
807 | if (ctrl.wLength && !access_ok(VERIFY_WRITE, ctrl.data, | 852 | if (ctrl.wLength && !access_ok(VERIFY_WRITE, ctrl.data, |
808 | ctrl.wLength)) { | 853 | ctrl.wLength)) { |
809 | free_page((unsigned long)tbuf); | 854 | ret = -EINVAL; |
810 | return -EINVAL; | 855 | goto done; |
811 | } | 856 | } |
812 | pipe = usb_rcvctrlpipe(dev, 0); | 857 | pipe = usb_rcvctrlpipe(dev, 0); |
813 | snoop_urb(dev, NULL, pipe, ctrl.wLength, tmo, SUBMIT, NULL, 0); | 858 | snoop_urb(dev, NULL, pipe, ctrl.wLength, tmo, SUBMIT, NULL, 0); |
@@ -821,15 +866,15 @@ static int proc_control(struct dev_state *ps, void __user *arg) | |||
821 | tbuf, max(i, 0)); | 866 | tbuf, max(i, 0)); |
822 | if ((i > 0) && ctrl.wLength) { | 867 | if ((i > 0) && ctrl.wLength) { |
823 | if (copy_to_user(ctrl.data, tbuf, i)) { | 868 | if (copy_to_user(ctrl.data, tbuf, i)) { |
824 | free_page((unsigned long)tbuf); | 869 | ret = -EFAULT; |
825 | return -EFAULT; | 870 | goto done; |
826 | } | 871 | } |
827 | } | 872 | } |
828 | } else { | 873 | } else { |
829 | if (ctrl.wLength) { | 874 | if (ctrl.wLength) { |
830 | if (copy_from_user(tbuf, ctrl.data, ctrl.wLength)) { | 875 | if (copy_from_user(tbuf, ctrl.data, ctrl.wLength)) { |
831 | free_page((unsigned long)tbuf); | 876 | ret = -EFAULT; |
832 | return -EFAULT; | 877 | goto done; |
833 | } | 878 | } |
834 | } | 879 | } |
835 | pipe = usb_sndctrlpipe(dev, 0); | 880 | pipe = usb_sndctrlpipe(dev, 0); |
@@ -843,14 +888,18 @@ static int proc_control(struct dev_state *ps, void __user *arg) | |||
843 | usb_lock_device(dev); | 888 | usb_lock_device(dev); |
844 | snoop_urb(dev, NULL, pipe, max(i, 0), min(i, 0), COMPLETE, NULL, 0); | 889 | snoop_urb(dev, NULL, pipe, max(i, 0), min(i, 0), COMPLETE, NULL, 0); |
845 | } | 890 | } |
846 | free_page((unsigned long)tbuf); | ||
847 | if (i < 0 && i != -EPIPE) { | 891 | if (i < 0 && i != -EPIPE) { |
848 | dev_printk(KERN_DEBUG, &dev->dev, "usbfs: USBDEVFS_CONTROL " | 892 | dev_printk(KERN_DEBUG, &dev->dev, "usbfs: USBDEVFS_CONTROL " |
849 | "failed cmd %s rqt %u rq %u len %u ret %d\n", | 893 | "failed cmd %s rqt %u rq %u len %u ret %d\n", |
850 | current->comm, ctrl.bRequestType, ctrl.bRequest, | 894 | current->comm, ctrl.bRequestType, ctrl.bRequest, |
851 | ctrl.wLength, i); | 895 | ctrl.wLength, i); |
852 | } | 896 | } |
853 | return i; | 897 | ret = i; |
898 | done: | ||
899 | free_page((unsigned long) tbuf); | ||
900 | usbfs_decrease_memory_usage(PAGE_SIZE + sizeof(struct urb) + | ||
901 | sizeof(struct usb_ctrlrequest)); | ||
902 | return ret; | ||
854 | } | 903 | } |
855 | 904 | ||
856 | static int proc_bulk(struct dev_state *ps, void __user *arg) | 905 | static int proc_bulk(struct dev_state *ps, void __user *arg) |
@@ -877,15 +926,20 @@ static int proc_bulk(struct dev_state *ps, void __user *arg) | |||
877 | if (!usb_maxpacket(dev, pipe, !(bulk.ep & USB_DIR_IN))) | 926 | if (!usb_maxpacket(dev, pipe, !(bulk.ep & USB_DIR_IN))) |
878 | return -EINVAL; | 927 | return -EINVAL; |
879 | len1 = bulk.len; | 928 | len1 = bulk.len; |
880 | if (len1 > MAX_USBFS_BUFFER_SIZE) | 929 | if (len1 >= USBFS_XFER_MAX) |
881 | return -EINVAL; | 930 | return -EINVAL; |
882 | if (!(tbuf = kmalloc(len1, GFP_KERNEL))) | 931 | ret = usbfs_increase_memory_usage(len1 + sizeof(struct urb)); |
883 | return -ENOMEM; | 932 | if (ret) |
933 | return ret; | ||
934 | if (!(tbuf = kmalloc(len1, GFP_KERNEL))) { | ||
935 | ret = -ENOMEM; | ||
936 | goto done; | ||
937 | } | ||
884 | tmo = bulk.timeout; | 938 | tmo = bulk.timeout; |
885 | if (bulk.ep & 0x80) { | 939 | if (bulk.ep & 0x80) { |
886 | if (len1 && !access_ok(VERIFY_WRITE, bulk.data, len1)) { | 940 | if (len1 && !access_ok(VERIFY_WRITE, bulk.data, len1)) { |
887 | kfree(tbuf); | 941 | ret = -EINVAL; |
888 | return -EINVAL; | 942 | goto done; |
889 | } | 943 | } |
890 | snoop_urb(dev, NULL, pipe, len1, tmo, SUBMIT, NULL, 0); | 944 | snoop_urb(dev, NULL, pipe, len1, tmo, SUBMIT, NULL, 0); |
891 | 945 | ||
@@ -896,15 +950,15 @@ static int proc_bulk(struct dev_state *ps, void __user *arg) | |||
896 | 950 | ||
897 | if (!i && len2) { | 951 | if (!i && len2) { |
898 | if (copy_to_user(bulk.data, tbuf, len2)) { | 952 | if (copy_to_user(bulk.data, tbuf, len2)) { |
899 | kfree(tbuf); | 953 | ret = -EFAULT; |
900 | return -EFAULT; | 954 | goto done; |
901 | } | 955 | } |
902 | } | 956 | } |
903 | } else { | 957 | } else { |
904 | if (len1) { | 958 | if (len1) { |
905 | if (copy_from_user(tbuf, bulk.data, len1)) { | 959 | if (copy_from_user(tbuf, bulk.data, len1)) { |
906 | kfree(tbuf); | 960 | ret = -EFAULT; |
907 | return -EFAULT; | 961 | goto done; |
908 | } | 962 | } |
909 | } | 963 | } |
910 | snoop_urb(dev, NULL, pipe, len1, tmo, SUBMIT, tbuf, len1); | 964 | snoop_urb(dev, NULL, pipe, len1, tmo, SUBMIT, tbuf, len1); |
@@ -914,10 +968,11 @@ static int proc_bulk(struct dev_state *ps, void __user *arg) | |||
914 | usb_lock_device(dev); | 968 | usb_lock_device(dev); |
915 | snoop_urb(dev, NULL, pipe, len2, i, COMPLETE, NULL, 0); | 969 | snoop_urb(dev, NULL, pipe, len2, i, COMPLETE, NULL, 0); |
916 | } | 970 | } |
971 | ret = (i < 0 ? i : len2); | ||
972 | done: | ||
917 | kfree(tbuf); | 973 | kfree(tbuf); |
918 | if (i < 0) | 974 | usbfs_decrease_memory_usage(len1 + sizeof(struct urb)); |
919 | return i; | 975 | return ret; |
920 | return len2; | ||
921 | } | 976 | } |
922 | 977 | ||
923 | static int proc_resetep(struct dev_state *ps, void __user *arg) | 978 | static int proc_resetep(struct dev_state *ps, void __user *arg) |
@@ -1062,7 +1117,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, | |||
1062 | { | 1117 | { |
1063 | struct usbdevfs_iso_packet_desc *isopkt = NULL; | 1118 | struct usbdevfs_iso_packet_desc *isopkt = NULL; |
1064 | struct usb_host_endpoint *ep; | 1119 | struct usb_host_endpoint *ep; |
1065 | struct async *as; | 1120 | struct async *as = NULL; |
1066 | struct usb_ctrlrequest *dr = NULL; | 1121 | struct usb_ctrlrequest *dr = NULL; |
1067 | unsigned int u, totlen, isofrmlen; | 1122 | unsigned int u, totlen, isofrmlen; |
1068 | int ret, ifnum = -1; | 1123 | int ret, ifnum = -1; |
@@ -1095,32 +1150,30 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, | |||
1095 | } | 1150 | } |
1096 | if (!ep) | 1151 | if (!ep) |
1097 | return -ENOENT; | 1152 | return -ENOENT; |
1153 | |||
1154 | u = 0; | ||
1098 | switch(uurb->type) { | 1155 | switch(uurb->type) { |
1099 | case USBDEVFS_URB_TYPE_CONTROL: | 1156 | case USBDEVFS_URB_TYPE_CONTROL: |
1100 | if (!usb_endpoint_xfer_control(&ep->desc)) | 1157 | if (!usb_endpoint_xfer_control(&ep->desc)) |
1101 | return -EINVAL; | 1158 | return -EINVAL; |
1102 | /* min 8 byte setup packet, | 1159 | /* min 8 byte setup packet */ |
1103 | * max 8 byte setup plus an arbitrary data stage */ | 1160 | if (uurb->buffer_length < 8) |
1104 | if (uurb->buffer_length < 8 || | ||
1105 | uurb->buffer_length > (8 + MAX_USBFS_BUFFER_SIZE)) | ||
1106 | return -EINVAL; | 1161 | return -EINVAL; |
1107 | dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_KERNEL); | 1162 | dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_KERNEL); |
1108 | if (!dr) | 1163 | if (!dr) |
1109 | return -ENOMEM; | 1164 | return -ENOMEM; |
1110 | if (copy_from_user(dr, uurb->buffer, 8)) { | 1165 | if (copy_from_user(dr, uurb->buffer, 8)) { |
1111 | kfree(dr); | 1166 | ret = -EFAULT; |
1112 | return -EFAULT; | 1167 | goto error; |
1113 | } | 1168 | } |
1114 | if (uurb->buffer_length < (le16_to_cpup(&dr->wLength) + 8)) { | 1169 | if (uurb->buffer_length < (le16_to_cpup(&dr->wLength) + 8)) { |
1115 | kfree(dr); | 1170 | ret = -EINVAL; |
1116 | return -EINVAL; | 1171 | goto error; |
1117 | } | 1172 | } |
1118 | ret = check_ctrlrecip(ps, dr->bRequestType, dr->bRequest, | 1173 | ret = check_ctrlrecip(ps, dr->bRequestType, dr->bRequest, |
1119 | le16_to_cpup(&dr->wIndex)); | 1174 | le16_to_cpup(&dr->wIndex)); |
1120 | if (ret) { | 1175 | if (ret) |
1121 | kfree(dr); | 1176 | goto error; |
1122 | return ret; | ||
1123 | } | ||
1124 | uurb->number_of_packets = 0; | 1177 | uurb->number_of_packets = 0; |
1125 | uurb->buffer_length = le16_to_cpup(&dr->wLength); | 1178 | uurb->buffer_length = le16_to_cpup(&dr->wLength); |
1126 | uurb->buffer += 8; | 1179 | uurb->buffer += 8; |
@@ -1138,6 +1191,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, | |||
1138 | __le16_to_cpup(&dr->wValue), | 1191 | __le16_to_cpup(&dr->wValue), |
1139 | __le16_to_cpup(&dr->wIndex), | 1192 | __le16_to_cpup(&dr->wIndex), |
1140 | __le16_to_cpup(&dr->wLength)); | 1193 | __le16_to_cpup(&dr->wLength)); |
1194 | u = sizeof(struct usb_ctrlrequest); | ||
1141 | break; | 1195 | break; |
1142 | 1196 | ||
1143 | case USBDEVFS_URB_TYPE_BULK: | 1197 | case USBDEVFS_URB_TYPE_BULK: |
@@ -1151,8 +1205,6 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, | |||
1151 | goto interrupt_urb; | 1205 | goto interrupt_urb; |
1152 | } | 1206 | } |
1153 | uurb->number_of_packets = 0; | 1207 | uurb->number_of_packets = 0; |
1154 | if (uurb->buffer_length > MAX_USBFS_BUFFER_SIZE) | ||
1155 | return -EINVAL; | ||
1156 | break; | 1208 | break; |
1157 | 1209 | ||
1158 | case USBDEVFS_URB_TYPE_INTERRUPT: | 1210 | case USBDEVFS_URB_TYPE_INTERRUPT: |
@@ -1160,8 +1212,6 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, | |||
1160 | return -EINVAL; | 1212 | return -EINVAL; |
1161 | interrupt_urb: | 1213 | interrupt_urb: |
1162 | uurb->number_of_packets = 0; | 1214 | uurb->number_of_packets = 0; |
1163 | if (uurb->buffer_length > MAX_USBFS_BUFFER_SIZE) | ||
1164 | return -EINVAL; | ||
1165 | break; | 1215 | break; |
1166 | 1216 | ||
1167 | case USBDEVFS_URB_TYPE_ISO: | 1217 | case USBDEVFS_URB_TYPE_ISO: |
@@ -1176,50 +1226,53 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, | |||
1176 | if (!(isopkt = kmalloc(isofrmlen, GFP_KERNEL))) | 1226 | if (!(isopkt = kmalloc(isofrmlen, GFP_KERNEL))) |
1177 | return -ENOMEM; | 1227 | return -ENOMEM; |
1178 | if (copy_from_user(isopkt, iso_frame_desc, isofrmlen)) { | 1228 | if (copy_from_user(isopkt, iso_frame_desc, isofrmlen)) { |
1179 | kfree(isopkt); | 1229 | ret = -EFAULT; |
1180 | return -EFAULT; | 1230 | goto error; |
1181 | } | 1231 | } |
1182 | for (totlen = u = 0; u < uurb->number_of_packets; u++) { | 1232 | for (totlen = u = 0; u < uurb->number_of_packets; u++) { |
1183 | /* arbitrary limit, | 1233 | /* arbitrary limit, |
1184 | * sufficient for USB 2.0 high-bandwidth iso */ | 1234 | * sufficient for USB 2.0 high-bandwidth iso */ |
1185 | if (isopkt[u].length > 8192) { | 1235 | if (isopkt[u].length > 8192) { |
1186 | kfree(isopkt); | 1236 | ret = -EINVAL; |
1187 | return -EINVAL; | 1237 | goto error; |
1188 | } | 1238 | } |
1189 | totlen += isopkt[u].length; | 1239 | totlen += isopkt[u].length; |
1190 | } | 1240 | } |
1191 | /* 3072 * 64 microframes */ | 1241 | u *= sizeof(struct usb_iso_packet_descriptor); |
1192 | if (totlen > 196608) { | ||
1193 | kfree(isopkt); | ||
1194 | return -EINVAL; | ||
1195 | } | ||
1196 | uurb->buffer_length = totlen; | 1242 | uurb->buffer_length = totlen; |
1197 | break; | 1243 | break; |
1198 | 1244 | ||
1199 | default: | 1245 | default: |
1200 | return -EINVAL; | 1246 | return -EINVAL; |
1201 | } | 1247 | } |
1248 | |||
1249 | if (uurb->buffer_length >= USBFS_XFER_MAX) { | ||
1250 | ret = -EINVAL; | ||
1251 | goto error; | ||
1252 | } | ||
1202 | if (uurb->buffer_length > 0 && | 1253 | if (uurb->buffer_length > 0 && |
1203 | !access_ok(is_in ? VERIFY_WRITE : VERIFY_READ, | 1254 | !access_ok(is_in ? VERIFY_WRITE : VERIFY_READ, |
1204 | uurb->buffer, uurb->buffer_length)) { | 1255 | uurb->buffer, uurb->buffer_length)) { |
1205 | kfree(isopkt); | 1256 | ret = -EFAULT; |
1206 | kfree(dr); | 1257 | goto error; |
1207 | return -EFAULT; | ||
1208 | } | 1258 | } |
1209 | as = alloc_async(uurb->number_of_packets); | 1259 | as = alloc_async(uurb->number_of_packets); |
1210 | if (!as) { | 1260 | if (!as) { |
1211 | kfree(isopkt); | 1261 | ret = -ENOMEM; |
1212 | kfree(dr); | 1262 | goto error; |
1213 | return -ENOMEM; | ||
1214 | } | 1263 | } |
1264 | u += sizeof(struct async) + sizeof(struct urb) + uurb->buffer_length; | ||
1265 | ret = usbfs_increase_memory_usage(u); | ||
1266 | if (ret) | ||
1267 | goto error; | ||
1268 | as->mem_usage = u; | ||
1269 | |||
1215 | if (uurb->buffer_length > 0) { | 1270 | if (uurb->buffer_length > 0) { |
1216 | as->urb->transfer_buffer = kmalloc(uurb->buffer_length, | 1271 | as->urb->transfer_buffer = kmalloc(uurb->buffer_length, |
1217 | GFP_KERNEL); | 1272 | GFP_KERNEL); |
1218 | if (!as->urb->transfer_buffer) { | 1273 | if (!as->urb->transfer_buffer) { |
1219 | kfree(isopkt); | 1274 | ret = -ENOMEM; |
1220 | kfree(dr); | 1275 | goto error; |
1221 | free_async(as); | ||
1222 | return -ENOMEM; | ||
1223 | } | 1276 | } |
1224 | /* Isochronous input data may end up being discontiguous | 1277 | /* Isochronous input data may end up being discontiguous |
1225 | * if some of the packets are short. Clear the buffer so | 1278 | * if some of the packets are short. Clear the buffer so |
@@ -1253,6 +1306,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, | |||
1253 | 1306 | ||
1254 | as->urb->transfer_buffer_length = uurb->buffer_length; | 1307 | as->urb->transfer_buffer_length = uurb->buffer_length; |
1255 | as->urb->setup_packet = (unsigned char *)dr; | 1308 | as->urb->setup_packet = (unsigned char *)dr; |
1309 | dr = NULL; | ||
1256 | as->urb->start_frame = uurb->start_frame; | 1310 | as->urb->start_frame = uurb->start_frame; |
1257 | as->urb->number_of_packets = uurb->number_of_packets; | 1311 | as->urb->number_of_packets = uurb->number_of_packets; |
1258 | if (uurb->type == USBDEVFS_URB_TYPE_ISO || | 1312 | if (uurb->type == USBDEVFS_URB_TYPE_ISO || |
@@ -1268,6 +1322,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, | |||
1268 | totlen += isopkt[u].length; | 1322 | totlen += isopkt[u].length; |
1269 | } | 1323 | } |
1270 | kfree(isopkt); | 1324 | kfree(isopkt); |
1325 | isopkt = NULL; | ||
1271 | as->ps = ps; | 1326 | as->ps = ps; |
1272 | as->userurb = arg; | 1327 | as->userurb = arg; |
1273 | if (is_in && uurb->buffer_length > 0) | 1328 | if (is_in && uurb->buffer_length > 0) |
@@ -1282,8 +1337,8 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, | |||
1282 | if (!is_in && uurb->buffer_length > 0) { | 1337 | if (!is_in && uurb->buffer_length > 0) { |
1283 | if (copy_from_user(as->urb->transfer_buffer, uurb->buffer, | 1338 | if (copy_from_user(as->urb->transfer_buffer, uurb->buffer, |
1284 | uurb->buffer_length)) { | 1339 | uurb->buffer_length)) { |
1285 | free_async(as); | 1340 | ret = -EFAULT; |
1286 | return -EFAULT; | 1341 | goto error; |
1287 | } | 1342 | } |
1288 | } | 1343 | } |
1289 | snoop_urb(ps->dev, as->userurb, as->urb->pipe, | 1344 | snoop_urb(ps->dev, as->userurb, as->urb->pipe, |
@@ -1329,10 +1384,16 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, | |||
1329 | snoop_urb(ps->dev, as->userurb, as->urb->pipe, | 1384 | snoop_urb(ps->dev, as->userurb, as->urb->pipe, |
1330 | 0, ret, COMPLETE, NULL, 0); | 1385 | 0, ret, COMPLETE, NULL, 0); |
1331 | async_removepending(as); | 1386 | async_removepending(as); |
1332 | free_async(as); | 1387 | goto error; |
1333 | return ret; | ||
1334 | } | 1388 | } |
1335 | return 0; | 1389 | return 0; |
1390 | |||
1391 | error: | ||
1392 | kfree(isopkt); | ||
1393 | kfree(dr); | ||
1394 | if (as) | ||
1395 | free_async(as); | ||
1396 | return ret; | ||
1336 | } | 1397 | } |
1337 | 1398 | ||
1338 | static int proc_submiturb(struct dev_state *ps, void __user *arg) | 1399 | static int proc_submiturb(struct dev_state *ps, void __user *arg) |
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c index 45887a0ff873..d40ff9568813 100644 --- a/drivers/usb/core/driver.c +++ b/drivers/usb/core/driver.c | |||
@@ -45,10 +45,12 @@ ssize_t usb_store_new_id(struct usb_dynids *dynids, | |||
45 | struct usb_dynid *dynid; | 45 | struct usb_dynid *dynid; |
46 | u32 idVendor = 0; | 46 | u32 idVendor = 0; |
47 | u32 idProduct = 0; | 47 | u32 idProduct = 0; |
48 | unsigned int bInterfaceClass = 0; | ||
48 | int fields = 0; | 49 | int fields = 0; |
49 | int retval = 0; | 50 | int retval = 0; |
50 | 51 | ||
51 | fields = sscanf(buf, "%x %x", &idVendor, &idProduct); | 52 | fields = sscanf(buf, "%x %x %x", &idVendor, &idProduct, |
53 | &bInterfaceClass); | ||
52 | if (fields < 2) | 54 | if (fields < 2) |
53 | return -EINVAL; | 55 | return -EINVAL; |
54 | 56 | ||
@@ -60,6 +62,10 @@ ssize_t usb_store_new_id(struct usb_dynids *dynids, | |||
60 | dynid->id.idVendor = idVendor; | 62 | dynid->id.idVendor = idVendor; |
61 | dynid->id.idProduct = idProduct; | 63 | dynid->id.idProduct = idProduct; |
62 | dynid->id.match_flags = USB_DEVICE_ID_MATCH_DEVICE; | 64 | dynid->id.match_flags = USB_DEVICE_ID_MATCH_DEVICE; |
65 | if (fields == 3) { | ||
66 | dynid->id.bInterfaceClass = (u8)bInterfaceClass; | ||
67 | dynid->id.match_flags |= USB_DEVICE_ID_MATCH_INT_CLASS; | ||
68 | } | ||
63 | 69 | ||
64 | spin_lock(&dynids->lock); | 70 | spin_lock(&dynids->lock); |
65 | list_add_tail(&dynid->node, &dynids->list); | 71 | list_add_tail(&dynid->node, &dynids->list); |
@@ -1073,17 +1079,10 @@ static int usb_suspend_interface(struct usb_device *udev, | |||
1073 | goto done; | 1079 | goto done; |
1074 | driver = to_usb_driver(intf->dev.driver); | 1080 | driver = to_usb_driver(intf->dev.driver); |
1075 | 1081 | ||
1076 | if (driver->suspend) { | 1082 | /* at this time we know the driver supports suspend */ |
1077 | status = driver->suspend(intf, msg); | 1083 | status = driver->suspend(intf, msg); |
1078 | if (status && !PMSG_IS_AUTO(msg)) | 1084 | if (status && !PMSG_IS_AUTO(msg)) |
1079 | dev_err(&intf->dev, "%s error %d\n", | 1085 | dev_err(&intf->dev, "suspend error %d\n", status); |
1080 | "suspend", status); | ||
1081 | } else { | ||
1082 | /* Later we will unbind the driver and reprobe */ | ||
1083 | intf->needs_binding = 1; | ||
1084 | dev_warn(&intf->dev, "no %s for driver %s?\n", | ||
1085 | "suspend", driver->name); | ||
1086 | } | ||
1087 | 1086 | ||
1088 | done: | 1087 | done: |
1089 | dev_vdbg(&intf->dev, "%s: status %d\n", __func__, status); | 1088 | dev_vdbg(&intf->dev, "%s: status %d\n", __func__, status); |
@@ -1132,16 +1131,9 @@ static int usb_resume_interface(struct usb_device *udev, | |||
1132 | "reset_resume", driver->name); | 1131 | "reset_resume", driver->name); |
1133 | } | 1132 | } |
1134 | } else { | 1133 | } else { |
1135 | if (driver->resume) { | 1134 | status = driver->resume(intf); |
1136 | status = driver->resume(intf); | 1135 | if (status) |
1137 | if (status) | 1136 | dev_err(&intf->dev, "resume error %d\n", status); |
1138 | dev_err(&intf->dev, "%s error %d\n", | ||
1139 | "resume", status); | ||
1140 | } else { | ||
1141 | intf->needs_binding = 1; | ||
1142 | dev_warn(&intf->dev, "no %s for driver %s?\n", | ||
1143 | "resume", driver->name); | ||
1144 | } | ||
1145 | } | 1137 | } |
1146 | 1138 | ||
1147 | done: | 1139 | done: |
diff --git a/drivers/usb/core/file.c b/drivers/usb/core/file.c index 99458c843d60..d95760de9e8b 100644 --- a/drivers/usb/core/file.c +++ b/drivers/usb/core/file.c | |||
@@ -66,7 +66,7 @@ static struct usb_class { | |||
66 | struct class *class; | 66 | struct class *class; |
67 | } *usb_class; | 67 | } *usb_class; |
68 | 68 | ||
69 | static char *usb_devnode(struct device *dev, mode_t *mode) | 69 | static char *usb_devnode(struct device *dev, umode_t *mode) |
70 | { | 70 | { |
71 | struct usb_class_driver *drv; | 71 | struct usb_class_driver *drv; |
72 | 72 | ||
diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c index a004db35f6d0..d136b8f4c8a7 100644 --- a/drivers/usb/core/hcd-pci.c +++ b/drivers/usb/core/hcd-pci.c | |||
@@ -453,10 +453,6 @@ static int resume_common(struct device *dev, int event) | |||
453 | 453 | ||
454 | pci_set_master(pci_dev); | 454 | pci_set_master(pci_dev); |
455 | 455 | ||
456 | clear_bit(HCD_FLAG_SAW_IRQ, &hcd->flags); | ||
457 | if (hcd->shared_hcd) | ||
458 | clear_bit(HCD_FLAG_SAW_IRQ, &hcd->shared_hcd->flags); | ||
459 | |||
460 | if (hcd->driver->pci_resume && !HCD_DEAD(hcd)) { | 456 | if (hcd->driver->pci_resume && !HCD_DEAD(hcd)) { |
461 | if (event != PM_EVENT_AUTO_RESUME) | 457 | if (event != PM_EVENT_AUTO_RESUME) |
462 | wait_for_companions(pci_dev, hcd); | 458 | wait_for_companions(pci_dev, hcd); |
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index 13222d352a61..eb19cba34ac9 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c | |||
@@ -658,7 +658,7 @@ error: | |||
658 | len > offsetof(struct usb_device_descriptor, | 658 | len > offsetof(struct usb_device_descriptor, |
659 | bDeviceProtocol)) | 659 | bDeviceProtocol)) |
660 | ((struct usb_device_descriptor *) ubuf)-> | 660 | ((struct usb_device_descriptor *) ubuf)-> |
661 | bDeviceProtocol = 1; | 661 | bDeviceProtocol = USB_HUB_PR_HS_SINGLE_TT; |
662 | } | 662 | } |
663 | 663 | ||
664 | /* any errors get returned through the urb completion */ | 664 | /* any errors get returned through the urb completion */ |
@@ -1168,20 +1168,6 @@ int usb_hcd_check_unlink_urb(struct usb_hcd *hcd, struct urb *urb, | |||
1168 | if (urb->unlinked) | 1168 | if (urb->unlinked) |
1169 | return -EBUSY; | 1169 | return -EBUSY; |
1170 | urb->unlinked = status; | 1170 | urb->unlinked = status; |
1171 | |||
1172 | /* IRQ setup can easily be broken so that USB controllers | ||
1173 | * never get completion IRQs ... maybe even the ones we need to | ||
1174 | * finish unlinking the initial failed usb_set_address() | ||
1175 | * or device descriptor fetch. | ||
1176 | */ | ||
1177 | if (!HCD_SAW_IRQ(hcd) && !is_root_hub(urb->dev)) { | ||
1178 | dev_warn(hcd->self.controller, "Unlink after no-IRQ? " | ||
1179 | "Controller is probably using the wrong IRQ.\n"); | ||
1180 | set_bit(HCD_FLAG_SAW_IRQ, &hcd->flags); | ||
1181 | if (hcd->shared_hcd) | ||
1182 | set_bit(HCD_FLAG_SAW_IRQ, &hcd->shared_hcd->flags); | ||
1183 | } | ||
1184 | |||
1185 | return 0; | 1171 | return 0; |
1186 | } | 1172 | } |
1187 | EXPORT_SYMBOL_GPL(usb_hcd_check_unlink_urb); | 1173 | EXPORT_SYMBOL_GPL(usb_hcd_check_unlink_urb); |
@@ -1412,11 +1398,10 @@ int usb_hcd_map_urb_for_dma(struct usb_hcd *hcd, struct urb *urb, | |||
1412 | ret = -EAGAIN; | 1398 | ret = -EAGAIN; |
1413 | else | 1399 | else |
1414 | urb->transfer_flags |= URB_DMA_MAP_SG; | 1400 | urb->transfer_flags |= URB_DMA_MAP_SG; |
1415 | if (n != urb->num_sgs) { | 1401 | urb->num_mapped_sgs = n; |
1416 | urb->num_sgs = n; | 1402 | if (n != urb->num_sgs) |
1417 | urb->transfer_flags |= | 1403 | urb->transfer_flags |= |
1418 | URB_DMA_SG_COMBINED; | 1404 | URB_DMA_SG_COMBINED; |
1419 | } | ||
1420 | } else if (urb->sg) { | 1405 | } else if (urb->sg) { |
1421 | struct scatterlist *sg = urb->sg; | 1406 | struct scatterlist *sg = urb->sg; |
1422 | urb->transfer_dma = dma_map_page( | 1407 | urb->transfer_dma = dma_map_page( |
@@ -2148,16 +2133,12 @@ irqreturn_t usb_hcd_irq (int irq, void *__hcd) | |||
2148 | */ | 2133 | */ |
2149 | local_irq_save(flags); | 2134 | local_irq_save(flags); |
2150 | 2135 | ||
2151 | if (unlikely(HCD_DEAD(hcd) || !HCD_HW_ACCESSIBLE(hcd))) { | 2136 | if (unlikely(HCD_DEAD(hcd) || !HCD_HW_ACCESSIBLE(hcd))) |
2152 | rc = IRQ_NONE; | 2137 | rc = IRQ_NONE; |
2153 | } else if (hcd->driver->irq(hcd) == IRQ_NONE) { | 2138 | else if (hcd->driver->irq(hcd) == IRQ_NONE) |
2154 | rc = IRQ_NONE; | 2139 | rc = IRQ_NONE; |
2155 | } else { | 2140 | else |
2156 | set_bit(HCD_FLAG_SAW_IRQ, &hcd->flags); | ||
2157 | if (hcd->shared_hcd) | ||
2158 | set_bit(HCD_FLAG_SAW_IRQ, &hcd->shared_hcd->flags); | ||
2159 | rc = IRQ_HANDLED; | 2141 | rc = IRQ_HANDLED; |
2160 | } | ||
2161 | 2142 | ||
2162 | local_irq_restore(flags); | 2143 | local_irq_restore(flags); |
2163 | return rc; | 2144 | return rc; |
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 96f05b29c9ad..a0613d8f9be7 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c | |||
@@ -84,7 +84,7 @@ struct usb_hub { | |||
84 | 84 | ||
85 | static inline int hub_is_superspeed(struct usb_device *hdev) | 85 | static inline int hub_is_superspeed(struct usb_device *hdev) |
86 | { | 86 | { |
87 | return (hdev->descriptor.bDeviceProtocol == 3); | 87 | return (hdev->descriptor.bDeviceProtocol == USB_HUB_PR_SS); |
88 | } | 88 | } |
89 | 89 | ||
90 | /* Protect struct usb_device->state and ->children members | 90 | /* Protect struct usb_device->state and ->children members |
@@ -102,7 +102,7 @@ static DECLARE_WAIT_QUEUE_HEAD(khubd_wait); | |||
102 | static struct task_struct *khubd_task; | 102 | static struct task_struct *khubd_task; |
103 | 103 | ||
104 | /* cycle leds on hubs that aren't blinking for attention */ | 104 | /* cycle leds on hubs that aren't blinking for attention */ |
105 | static int blinkenlights = 0; | 105 | static bool blinkenlights = 0; |
106 | module_param (blinkenlights, bool, S_IRUGO); | 106 | module_param (blinkenlights, bool, S_IRUGO); |
107 | MODULE_PARM_DESC (blinkenlights, "true to cycle leds on hubs"); | 107 | MODULE_PARM_DESC (blinkenlights, "true to cycle leds on hubs"); |
108 | 108 | ||
@@ -131,12 +131,12 @@ MODULE_PARM_DESC(initial_descriptor_timeout, | |||
131 | * otherwise the new scheme is used. If that fails and "use_both_schemes" | 131 | * otherwise the new scheme is used. If that fails and "use_both_schemes" |
132 | * is set, then the driver will make another attempt, using the other scheme. | 132 | * is set, then the driver will make another attempt, using the other scheme. |
133 | */ | 133 | */ |
134 | static int old_scheme_first = 0; | 134 | static bool old_scheme_first = 0; |
135 | module_param(old_scheme_first, bool, S_IRUGO | S_IWUSR); | 135 | module_param(old_scheme_first, bool, S_IRUGO | S_IWUSR); |
136 | MODULE_PARM_DESC(old_scheme_first, | 136 | MODULE_PARM_DESC(old_scheme_first, |
137 | "start with the old device initialization scheme"); | 137 | "start with the old device initialization scheme"); |
138 | 138 | ||
139 | static int use_both_schemes = 1; | 139 | static bool use_both_schemes = 1; |
140 | module_param(use_both_schemes, bool, S_IRUGO | S_IWUSR); | 140 | module_param(use_both_schemes, bool, S_IRUGO | S_IWUSR); |
141 | MODULE_PARM_DESC(use_both_schemes, | 141 | MODULE_PARM_DESC(use_both_schemes, |
142 | "try the other device initialization scheme if the " | 142 | "try the other device initialization scheme if the " |
@@ -813,6 +813,12 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type) | |||
813 | USB_PORT_FEAT_C_PORT_LINK_STATE); | 813 | USB_PORT_FEAT_C_PORT_LINK_STATE); |
814 | } | 814 | } |
815 | 815 | ||
816 | if ((portchange & USB_PORT_STAT_C_BH_RESET) && | ||
817 | hub_is_superspeed(hub->hdev)) { | ||
818 | need_debounce_delay = true; | ||
819 | clear_port_feature(hub->hdev, port1, | ||
820 | USB_PORT_FEAT_C_BH_PORT_RESET); | ||
821 | } | ||
816 | /* We can forget about a "removed" device when there's a | 822 | /* We can forget about a "removed" device when there's a |
817 | * physical disconnect or the connect status changes. | 823 | * physical disconnect or the connect status changes. |
818 | */ | 824 | */ |
@@ -1035,58 +1041,58 @@ static int hub_configure(struct usb_hub *hub, | |||
1035 | dev_dbg(hub_dev, "standalone hub\n"); | 1041 | dev_dbg(hub_dev, "standalone hub\n"); |
1036 | 1042 | ||
1037 | switch (wHubCharacteristics & HUB_CHAR_LPSM) { | 1043 | switch (wHubCharacteristics & HUB_CHAR_LPSM) { |
1038 | case 0x00: | 1044 | case HUB_CHAR_COMMON_LPSM: |
1039 | dev_dbg(hub_dev, "ganged power switching\n"); | 1045 | dev_dbg(hub_dev, "ganged power switching\n"); |
1040 | break; | 1046 | break; |
1041 | case 0x01: | 1047 | case HUB_CHAR_INDV_PORT_LPSM: |
1042 | dev_dbg(hub_dev, "individual port power switching\n"); | 1048 | dev_dbg(hub_dev, "individual port power switching\n"); |
1043 | break; | 1049 | break; |
1044 | case 0x02: | 1050 | case HUB_CHAR_NO_LPSM: |
1045 | case 0x03: | 1051 | case HUB_CHAR_LPSM: |
1046 | dev_dbg(hub_dev, "no power switching (usb 1.0)\n"); | 1052 | dev_dbg(hub_dev, "no power switching (usb 1.0)\n"); |
1047 | break; | 1053 | break; |
1048 | } | 1054 | } |
1049 | 1055 | ||
1050 | switch (wHubCharacteristics & HUB_CHAR_OCPM) { | 1056 | switch (wHubCharacteristics & HUB_CHAR_OCPM) { |
1051 | case 0x00: | 1057 | case HUB_CHAR_COMMON_OCPM: |
1052 | dev_dbg(hub_dev, "global over-current protection\n"); | 1058 | dev_dbg(hub_dev, "global over-current protection\n"); |
1053 | break; | 1059 | break; |
1054 | case 0x08: | 1060 | case HUB_CHAR_INDV_PORT_OCPM: |
1055 | dev_dbg(hub_dev, "individual port over-current protection\n"); | 1061 | dev_dbg(hub_dev, "individual port over-current protection\n"); |
1056 | break; | 1062 | break; |
1057 | case 0x10: | 1063 | case HUB_CHAR_NO_OCPM: |
1058 | case 0x18: | 1064 | case HUB_CHAR_OCPM: |
1059 | dev_dbg(hub_dev, "no over-current protection\n"); | 1065 | dev_dbg(hub_dev, "no over-current protection\n"); |
1060 | break; | 1066 | break; |
1061 | } | 1067 | } |
1062 | 1068 | ||
1063 | spin_lock_init (&hub->tt.lock); | 1069 | spin_lock_init (&hub->tt.lock); |
1064 | INIT_LIST_HEAD (&hub->tt.clear_list); | 1070 | INIT_LIST_HEAD (&hub->tt.clear_list); |
1065 | INIT_WORK(&hub->tt.clear_work, hub_tt_work); | 1071 | INIT_WORK(&hub->tt.clear_work, hub_tt_work); |
1066 | switch (hdev->descriptor.bDeviceProtocol) { | 1072 | switch (hdev->descriptor.bDeviceProtocol) { |
1067 | case 0: | 1073 | case USB_HUB_PR_FS: |
1068 | break; | 1074 | break; |
1069 | case 1: | 1075 | case USB_HUB_PR_HS_SINGLE_TT: |
1070 | dev_dbg(hub_dev, "Single TT\n"); | 1076 | dev_dbg(hub_dev, "Single TT\n"); |
1071 | hub->tt.hub = hdev; | 1077 | hub->tt.hub = hdev; |
1072 | break; | 1078 | break; |
1073 | case 2: | 1079 | case USB_HUB_PR_HS_MULTI_TT: |
1074 | ret = usb_set_interface(hdev, 0, 1); | 1080 | ret = usb_set_interface(hdev, 0, 1); |
1075 | if (ret == 0) { | 1081 | if (ret == 0) { |
1076 | dev_dbg(hub_dev, "TT per port\n"); | 1082 | dev_dbg(hub_dev, "TT per port\n"); |
1077 | hub->tt.multi = 1; | 1083 | hub->tt.multi = 1; |
1078 | } else | 1084 | } else |
1079 | dev_err(hub_dev, "Using single TT (err %d)\n", | 1085 | dev_err(hub_dev, "Using single TT (err %d)\n", |
1080 | ret); | 1086 | ret); |
1081 | hub->tt.hub = hdev; | 1087 | hub->tt.hub = hdev; |
1082 | break; | 1088 | break; |
1083 | case 3: | 1089 | case USB_HUB_PR_SS: |
1084 | /* USB 3.0 hubs don't have a TT */ | 1090 | /* USB 3.0 hubs don't have a TT */ |
1085 | break; | 1091 | break; |
1086 | default: | 1092 | default: |
1087 | dev_dbg(hub_dev, "Unrecognized hub protocol %d\n", | 1093 | dev_dbg(hub_dev, "Unrecognized hub protocol %d\n", |
1088 | hdev->descriptor.bDeviceProtocol); | 1094 | hdev->descriptor.bDeviceProtocol); |
1089 | break; | 1095 | break; |
1090 | } | 1096 | } |
1091 | 1097 | ||
1092 | /* Note 8 FS bit times == (8 bits / 12000000 bps) ~= 666ns */ | 1098 | /* Note 8 FS bit times == (8 bits / 12000000 bps) ~= 666ns */ |
@@ -1354,7 +1360,6 @@ descriptor_error: | |||
1354 | return -ENODEV; | 1360 | return -ENODEV; |
1355 | } | 1361 | } |
1356 | 1362 | ||
1357 | /* No BKL needed */ | ||
1358 | static int | 1363 | static int |
1359 | hub_ioctl(struct usb_interface *intf, unsigned int code, void *user_data) | 1364 | hub_ioctl(struct usb_interface *intf, unsigned int code, void *user_data) |
1360 | { | 1365 | { |
@@ -2021,7 +2026,7 @@ static unsigned hub_is_wusb(struct usb_hub *hub) | |||
2021 | #define SET_ADDRESS_TRIES 2 | 2026 | #define SET_ADDRESS_TRIES 2 |
2022 | #define GET_DESCRIPTOR_TRIES 2 | 2027 | #define GET_DESCRIPTOR_TRIES 2 |
2023 | #define SET_CONFIG_TRIES (2 * (use_both_schemes + 1)) | 2028 | #define SET_CONFIG_TRIES (2 * (use_both_schemes + 1)) |
2024 | #define USE_NEW_SCHEME(i) ((i) / 2 == old_scheme_first) | 2029 | #define USE_NEW_SCHEME(i) ((i) / 2 == (int)old_scheme_first) |
2025 | 2030 | ||
2026 | #define HUB_ROOT_RESET_TIME 50 /* times are in msec */ | 2031 | #define HUB_ROOT_RESET_TIME 50 /* times are in msec */ |
2027 | #define HUB_SHORT_RESET_TIME 10 | 2032 | #define HUB_SHORT_RESET_TIME 10 |
diff --git a/drivers/usb/core/inode.c b/drivers/usb/core/inode.c index 2278dad886e2..9e186f3da839 100644 --- a/drivers/usb/core/inode.c +++ b/drivers/usb/core/inode.c | |||
@@ -65,7 +65,7 @@ static umode_t devmode = USBFS_DEFAULT_DEVMODE; | |||
65 | static umode_t busmode = USBFS_DEFAULT_BUSMODE; | 65 | static umode_t busmode = USBFS_DEFAULT_BUSMODE; |
66 | static umode_t listmode = USBFS_DEFAULT_LISTMODE; | 66 | static umode_t listmode = USBFS_DEFAULT_LISTMODE; |
67 | 67 | ||
68 | static int usbfs_show_options(struct seq_file *seq, struct vfsmount *mnt) | 68 | static int usbfs_show_options(struct seq_file *seq, struct dentry *root) |
69 | { | 69 | { |
70 | if (devuid != 0) | 70 | if (devuid != 0) |
71 | seq_printf(seq, ",devuid=%u", devuid); | 71 | seq_printf(seq, ",devuid=%u", devuid); |
@@ -264,21 +264,19 @@ static int remount(struct super_block *sb, int *flags, char *data) | |||
264 | return -EINVAL; | 264 | return -EINVAL; |
265 | } | 265 | } |
266 | 266 | ||
267 | if (usbfs_mount && usbfs_mount->mnt_sb) | 267 | if (usbfs_mount) |
268 | update_sb(usbfs_mount->mnt_sb); | 268 | update_sb(usbfs_mount->mnt_sb); |
269 | 269 | ||
270 | return 0; | 270 | return 0; |
271 | } | 271 | } |
272 | 272 | ||
273 | static struct inode *usbfs_get_inode (struct super_block *sb, int mode, dev_t dev) | 273 | static struct inode *usbfs_get_inode (struct super_block *sb, umode_t mode, dev_t dev) |
274 | { | 274 | { |
275 | struct inode *inode = new_inode(sb); | 275 | struct inode *inode = new_inode(sb); |
276 | 276 | ||
277 | if (inode) { | 277 | if (inode) { |
278 | inode->i_ino = get_next_ino(); | 278 | inode->i_ino = get_next_ino(); |
279 | inode->i_mode = mode; | 279 | inode_init_owner(inode, NULL, mode); |
280 | inode->i_uid = current_fsuid(); | ||
281 | inode->i_gid = current_fsgid(); | ||
282 | inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; | 280 | inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; |
283 | switch (mode & S_IFMT) { | 281 | switch (mode & S_IFMT) { |
284 | default: | 282 | default: |
@@ -300,7 +298,7 @@ static struct inode *usbfs_get_inode (struct super_block *sb, int mode, dev_t de | |||
300 | } | 298 | } |
301 | 299 | ||
302 | /* SMP-safe */ | 300 | /* SMP-safe */ |
303 | static int usbfs_mknod (struct inode *dir, struct dentry *dentry, int mode, | 301 | static int usbfs_mknod (struct inode *dir, struct dentry *dentry, umode_t mode, |
304 | dev_t dev) | 302 | dev_t dev) |
305 | { | 303 | { |
306 | struct inode *inode = usbfs_get_inode(dir->i_sb, mode, dev); | 304 | struct inode *inode = usbfs_get_inode(dir->i_sb, mode, dev); |
@@ -317,7 +315,7 @@ static int usbfs_mknod (struct inode *dir, struct dentry *dentry, int mode, | |||
317 | return error; | 315 | return error; |
318 | } | 316 | } |
319 | 317 | ||
320 | static int usbfs_mkdir (struct inode *dir, struct dentry *dentry, int mode) | 318 | static int usbfs_mkdir (struct inode *dir, struct dentry *dentry, umode_t mode) |
321 | { | 319 | { |
322 | int res; | 320 | int res; |
323 | 321 | ||
@@ -328,7 +326,7 @@ static int usbfs_mkdir (struct inode *dir, struct dentry *dentry, int mode) | |||
328 | return res; | 326 | return res; |
329 | } | 327 | } |
330 | 328 | ||
331 | static int usbfs_create (struct inode *dir, struct dentry *dentry, int mode) | 329 | static int usbfs_create (struct inode *dir, struct dentry *dentry, umode_t mode) |
332 | { | 330 | { |
333 | mode = (mode & S_IALLUGO) | S_IFREG; | 331 | mode = (mode & S_IALLUGO) | S_IFREG; |
334 | return usbfs_mknod (dir, dentry, mode, 0); | 332 | return usbfs_mknod (dir, dentry, mode, 0); |
@@ -489,7 +487,7 @@ static int usbfs_fill_super(struct super_block *sb, void *data, int silent) | |||
489 | * | 487 | * |
490 | * This function handles both regular files and directories. | 488 | * This function handles both regular files and directories. |
491 | */ | 489 | */ |
492 | static int fs_create_by_name (const char *name, mode_t mode, | 490 | static int fs_create_by_name (const char *name, umode_t mode, |
493 | struct dentry *parent, struct dentry **dentry) | 491 | struct dentry *parent, struct dentry **dentry) |
494 | { | 492 | { |
495 | int error = 0; | 493 | int error = 0; |
@@ -500,9 +498,8 @@ static int fs_create_by_name (const char *name, mode_t mode, | |||
500 | * have around. | 498 | * have around. |
501 | */ | 499 | */ |
502 | if (!parent ) { | 500 | if (!parent ) { |
503 | if (usbfs_mount && usbfs_mount->mnt_sb) { | 501 | if (usbfs_mount) |
504 | parent = usbfs_mount->mnt_sb->s_root; | 502 | parent = usbfs_mount->mnt_root; |
505 | } | ||
506 | } | 503 | } |
507 | 504 | ||
508 | if (!parent) { | 505 | if (!parent) { |
@@ -514,7 +511,7 @@ static int fs_create_by_name (const char *name, mode_t mode, | |||
514 | mutex_lock(&parent->d_inode->i_mutex); | 511 | mutex_lock(&parent->d_inode->i_mutex); |
515 | *dentry = lookup_one_len(name, parent, strlen(name)); | 512 | *dentry = lookup_one_len(name, parent, strlen(name)); |
516 | if (!IS_ERR(*dentry)) { | 513 | if (!IS_ERR(*dentry)) { |
517 | if ((mode & S_IFMT) == S_IFDIR) | 514 | if (S_ISDIR(mode)) |
518 | error = usbfs_mkdir (parent->d_inode, *dentry, mode); | 515 | error = usbfs_mkdir (parent->d_inode, *dentry, mode); |
519 | else | 516 | else |
520 | error = usbfs_create (parent->d_inode, *dentry, mode); | 517 | error = usbfs_create (parent->d_inode, *dentry, mode); |
@@ -525,7 +522,7 @@ static int fs_create_by_name (const char *name, mode_t mode, | |||
525 | return error; | 522 | return error; |
526 | } | 523 | } |
527 | 524 | ||
528 | static struct dentry *fs_create_file (const char *name, mode_t mode, | 525 | static struct dentry *fs_create_file (const char *name, umode_t mode, |
529 | struct dentry *parent, void *data, | 526 | struct dentry *parent, void *data, |
530 | const struct file_operations *fops, | 527 | const struct file_operations *fops, |
531 | uid_t uid, gid_t gid) | 528 | uid_t uid, gid_t gid) |
@@ -608,7 +605,7 @@ static int create_special_files (void) | |||
608 | 605 | ||
609 | ignore_mount = 0; | 606 | ignore_mount = 0; |
610 | 607 | ||
611 | parent = usbfs_mount->mnt_sb->s_root; | 608 | parent = usbfs_mount->mnt_root; |
612 | devices_usbfs_dentry = fs_create_file ("devices", | 609 | devices_usbfs_dentry = fs_create_file ("devices", |
613 | listmode | S_IFREG, parent, | 610 | listmode | S_IFREG, parent, |
614 | NULL, &usbfs_devices_fops, | 611 | NULL, &usbfs_devices_fops, |
@@ -662,7 +659,7 @@ static void usbfs_add_bus(struct usb_bus *bus) | |||
662 | 659 | ||
663 | sprintf (name, "%03d", bus->busnum); | 660 | sprintf (name, "%03d", bus->busnum); |
664 | 661 | ||
665 | parent = usbfs_mount->mnt_sb->s_root; | 662 | parent = usbfs_mount->mnt_root; |
666 | bus->usbfs_dentry = fs_create_file (name, busmode | S_IFDIR, parent, | 663 | bus->usbfs_dentry = fs_create_file (name, busmode | S_IFDIR, parent, |
667 | bus, NULL, busuid, busgid); | 664 | bus, NULL, busuid, busgid); |
668 | if (bus->usbfs_dentry == NULL) { | 665 | if (bus->usbfs_dentry == NULL) { |
diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c index d6a8d8269bfb..4c65eb6a867a 100644 --- a/drivers/usb/core/quirks.c +++ b/drivers/usb/core/quirks.c | |||
@@ -50,15 +50,42 @@ static const struct usb_device_id usb_quirk_list[] = { | |||
50 | /* Logitech Webcam B/C500 */ | 50 | /* Logitech Webcam B/C500 */ |
51 | { USB_DEVICE(0x046d, 0x0807), .driver_info = USB_QUIRK_RESET_RESUME }, | 51 | { USB_DEVICE(0x046d, 0x0807), .driver_info = USB_QUIRK_RESET_RESUME }, |
52 | 52 | ||
53 | /* Logitech Webcam C600 */ | ||
54 | { USB_DEVICE(0x046d, 0x0808), .driver_info = USB_QUIRK_RESET_RESUME }, | ||
55 | |||
53 | /* Logitech Webcam Pro 9000 */ | 56 | /* Logitech Webcam Pro 9000 */ |
54 | { USB_DEVICE(0x046d, 0x0809), .driver_info = USB_QUIRK_RESET_RESUME }, | 57 | { USB_DEVICE(0x046d, 0x0809), .driver_info = USB_QUIRK_RESET_RESUME }, |
55 | 58 | ||
59 | /* Logitech Webcam C905 */ | ||
60 | { USB_DEVICE(0x046d, 0x080a), .driver_info = USB_QUIRK_RESET_RESUME }, | ||
61 | |||
62 | /* Logitech Webcam C210 */ | ||
63 | { USB_DEVICE(0x046d, 0x0819), .driver_info = USB_QUIRK_RESET_RESUME }, | ||
64 | |||
65 | /* Logitech Webcam C260 */ | ||
66 | { USB_DEVICE(0x046d, 0x081a), .driver_info = USB_QUIRK_RESET_RESUME }, | ||
67 | |||
56 | /* Logitech Webcam C310 */ | 68 | /* Logitech Webcam C310 */ |
57 | { USB_DEVICE(0x046d, 0x081b), .driver_info = USB_QUIRK_RESET_RESUME }, | 69 | { USB_DEVICE(0x046d, 0x081b), .driver_info = USB_QUIRK_RESET_RESUME }, |
58 | 70 | ||
71 | /* Logitech Webcam C910 */ | ||
72 | { USB_DEVICE(0x046d, 0x0821), .driver_info = USB_QUIRK_RESET_RESUME }, | ||
73 | |||
74 | /* Logitech Webcam C160 */ | ||
75 | { USB_DEVICE(0x046d, 0x0824), .driver_info = USB_QUIRK_RESET_RESUME }, | ||
76 | |||
59 | /* Logitech Webcam C270 */ | 77 | /* Logitech Webcam C270 */ |
60 | { USB_DEVICE(0x046d, 0x0825), .driver_info = USB_QUIRK_RESET_RESUME }, | 78 | { USB_DEVICE(0x046d, 0x0825), .driver_info = USB_QUIRK_RESET_RESUME }, |
61 | 79 | ||
80 | /* Logitech Quickcam Pro 9000 */ | ||
81 | { USB_DEVICE(0x046d, 0x0990), .driver_info = USB_QUIRK_RESET_RESUME }, | ||
82 | |||
83 | /* Logitech Quickcam E3500 */ | ||
84 | { USB_DEVICE(0x046d, 0x09a4), .driver_info = USB_QUIRK_RESET_RESUME }, | ||
85 | |||
86 | /* Logitech Quickcam Vision Pro */ | ||
87 | { USB_DEVICE(0x046d, 0x09a6), .driver_info = USB_QUIRK_RESET_RESUME }, | ||
88 | |||
62 | /* Logitech Harmony 700-series */ | 89 | /* Logitech Harmony 700-series */ |
63 | { USB_DEVICE(0x046d, 0xc122), .driver_info = USB_QUIRK_DELAY_INIT }, | 90 | { USB_DEVICE(0x046d, 0xc122), .driver_info = USB_QUIRK_DELAY_INIT }, |
64 | 91 | ||
@@ -90,9 +117,12 @@ static const struct usb_device_id usb_quirk_list[] = { | |||
90 | { USB_DEVICE(0x06a3, 0x0006), .driver_info = | 117 | { USB_DEVICE(0x06a3, 0x0006), .driver_info = |
91 | USB_QUIRK_CONFIG_INTF_STRINGS }, | 118 | USB_QUIRK_CONFIG_INTF_STRINGS }, |
92 | 119 | ||
93 | /* Guillemot Webcam Hercules Dualpix Exchange*/ | 120 | /* Guillemot Webcam Hercules Dualpix Exchange (2nd ID) */ |
94 | { USB_DEVICE(0x06f8, 0x0804), .driver_info = USB_QUIRK_RESET_RESUME }, | 121 | { USB_DEVICE(0x06f8, 0x0804), .driver_info = USB_QUIRK_RESET_RESUME }, |
95 | 122 | ||
123 | /* Guillemot Webcam Hercules Dualpix Exchange*/ | ||
124 | { USB_DEVICE(0x06f8, 0x3005), .driver_info = USB_QUIRK_RESET_RESUME }, | ||
125 | |||
96 | /* M-Systems Flash Disk Pioneers */ | 126 | /* M-Systems Flash Disk Pioneers */ |
97 | { USB_DEVICE(0x08ec, 0x1000), .driver_info = USB_QUIRK_RESET_RESUME }, | 127 | { USB_DEVICE(0x08ec, 0x1000), .driver_info = USB_QUIRK_RESET_RESUME }, |
98 | 128 | ||
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c index 662c0cf3a3e1..9e491ca2e5c4 100644 --- a/drivers/usb/core/sysfs.c +++ b/drivers/usb/core/sysfs.c | |||
@@ -642,7 +642,7 @@ static struct attribute *dev_string_attrs[] = { | |||
642 | NULL | 642 | NULL |
643 | }; | 643 | }; |
644 | 644 | ||
645 | static mode_t dev_string_attrs_are_visible(struct kobject *kobj, | 645 | static umode_t dev_string_attrs_are_visible(struct kobject *kobj, |
646 | struct attribute *a, int n) | 646 | struct attribute *a, int n) |
647 | { | 647 | { |
648 | struct device *dev = container_of(kobj, struct device, kobj); | 648 | struct device *dev = container_of(kobj, struct device, kobj); |
@@ -877,7 +877,7 @@ static struct attribute *intf_assoc_attrs[] = { | |||
877 | NULL, | 877 | NULL, |
878 | }; | 878 | }; |
879 | 879 | ||
880 | static mode_t intf_assoc_attrs_are_visible(struct kobject *kobj, | 880 | static umode_t intf_assoc_attrs_are_visible(struct kobject *kobj, |
881 | struct attribute *a, int n) | 881 | struct attribute *a, int n) |
882 | { | 882 | { |
883 | struct device *dev = container_of(kobj, struct device, kobj); | 883 | struct device *dev = container_of(kobj, struct device, kobj); |
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index 73cd90012ec5..8ca9f994a280 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c | |||
@@ -47,7 +47,7 @@ | |||
47 | 47 | ||
48 | const char *usbcore_name = "usbcore"; | 48 | const char *usbcore_name = "usbcore"; |
49 | 49 | ||
50 | static int nousb; /* Disable USB when built into kernel image */ | 50 | static bool nousb; /* Disable USB when built into kernel image */ |
51 | 51 | ||
52 | #ifdef CONFIG_USB_SUSPEND | 52 | #ifdef CONFIG_USB_SUSPEND |
53 | static int usb_autosuspend_delay = 2; /* Default delay value, | 53 | static int usb_autosuspend_delay = 2; /* Default delay value, |
@@ -326,7 +326,7 @@ static const struct dev_pm_ops usb_device_pm_ops = { | |||
326 | #endif /* CONFIG_PM */ | 326 | #endif /* CONFIG_PM */ |
327 | 327 | ||
328 | 328 | ||
329 | static char *usb_devnode(struct device *dev, mode_t *mode) | 329 | static char *usb_devnode(struct device *dev, umode_t *mode) |
330 | { | 330 | { |
331 | struct usb_device *usb_dev; | 331 | struct usb_device *usb_dev; |
332 | 332 | ||
diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h index 3888778582c4..45e8479c377d 100644 --- a/drivers/usb/core/usb.h +++ b/drivers/usb/core/usb.h | |||
@@ -132,20 +132,6 @@ static inline int is_usb_device_driver(struct device_driver *drv) | |||
132 | for_devices; | 132 | for_devices; |
133 | } | 133 | } |
134 | 134 | ||
135 | /* translate USB error codes to codes user space understands */ | ||
136 | static inline int usb_translate_errors(int error_code) | ||
137 | { | ||
138 | switch (error_code) { | ||
139 | case 0: | ||
140 | case -ENOMEM: | ||
141 | case -ENODEV: | ||
142 | return error_code; | ||
143 | default: | ||
144 | return -EIO; | ||
145 | } | ||
146 | } | ||
147 | |||
148 | |||
149 | /* for labeling diagnostics */ | 135 | /* for labeling diagnostics */ |
150 | extern const char *usbcore_name; | 136 | extern const char *usbcore_name; |
151 | 137 | ||
diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig index 3c1d67d324fd..d8f741f9e56e 100644 --- a/drivers/usb/dwc3/Kconfig +++ b/drivers/usb/dwc3/Kconfig | |||
@@ -1,7 +1,10 @@ | |||
1 | config USB_DWC3 | 1 | config USB_DWC3 |
2 | tristate "DesignWare USB3 DRD Core Support" | 2 | tristate "DesignWare USB3 DRD Core Support" |
3 | depends on (USB || USB_GADGET) | 3 | depends on (USB && USB_GADGET) |
4 | select USB_OTG_UTILS | 4 | select USB_OTG_UTILS |
5 | select USB_GADGET_DUALSPEED | ||
6 | select USB_GADGET_SUPERSPEED | ||
7 | select USB_XHCI_PLATFORM | ||
5 | help | 8 | help |
6 | Say Y or M here if your system has a Dual Role SuperSpeed | 9 | Say Y or M here if your system has a Dual Role SuperSpeed |
7 | USB controller based on the DesignWare USB3 IP Core. | 10 | USB controller based on the DesignWare USB3 IP Core. |
diff --git a/drivers/usb/dwc3/Makefile b/drivers/usb/dwc3/Makefile index 593d1dbc465b..900ae74357f1 100644 --- a/drivers/usb/dwc3/Makefile +++ b/drivers/usb/dwc3/Makefile | |||
@@ -4,10 +4,8 @@ ccflags-$(CONFIG_USB_DWC3_VERBOSE) += -DVERBOSE_DEBUG | |||
4 | obj-$(CONFIG_USB_DWC3) += dwc3.o | 4 | obj-$(CONFIG_USB_DWC3) += dwc3.o |
5 | 5 | ||
6 | dwc3-y := core.o | 6 | dwc3-y := core.o |
7 | 7 | dwc3-y += host.o | |
8 | ifneq ($(CONFIG_USB_GADGET_DWC3),) | 8 | dwc3-y += gadget.o ep0.o |
9 | dwc3-y += gadget.o ep0.o | ||
10 | endif | ||
11 | 9 | ||
12 | ifneq ($(CONFIG_DEBUG_FS),) | 10 | ifneq ($(CONFIG_DEBUG_FS),) |
13 | dwc3-y += debugfs.o | 11 | dwc3-y += debugfs.o |
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 717ebc9ff941..7c9df630dbe4 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c | |||
@@ -59,6 +59,60 @@ | |||
59 | 59 | ||
60 | #include "debug.h" | 60 | #include "debug.h" |
61 | 61 | ||
62 | static char *maximum_speed = "super"; | ||
63 | module_param(maximum_speed, charp, 0); | ||
64 | MODULE_PARM_DESC(maximum_speed, "Maximum supported speed."); | ||
65 | |||
66 | /* -------------------------------------------------------------------------- */ | ||
67 | |||
68 | #define DWC3_DEVS_POSSIBLE 32 | ||
69 | |||
70 | static DECLARE_BITMAP(dwc3_devs, DWC3_DEVS_POSSIBLE); | ||
71 | |||
72 | int dwc3_get_device_id(void) | ||
73 | { | ||
74 | int id; | ||
75 | |||
76 | again: | ||
77 | id = find_first_zero_bit(dwc3_devs, DWC3_DEVS_POSSIBLE); | ||
78 | if (id < DWC3_DEVS_POSSIBLE) { | ||
79 | int old; | ||
80 | |||
81 | old = test_and_set_bit(id, dwc3_devs); | ||
82 | if (old) | ||
83 | goto again; | ||
84 | } else { | ||
85 | pr_err("dwc3: no space for new device\n"); | ||
86 | id = -ENOMEM; | ||
87 | } | ||
88 | |||
89 | return 0; | ||
90 | } | ||
91 | EXPORT_SYMBOL_GPL(dwc3_get_device_id); | ||
92 | |||
93 | void dwc3_put_device_id(int id) | ||
94 | { | ||
95 | int ret; | ||
96 | |||
97 | if (id < 0) | ||
98 | return; | ||
99 | |||
100 | ret = test_bit(id, dwc3_devs); | ||
101 | WARN(!ret, "dwc3: ID %d not in use\n", id); | ||
102 | clear_bit(id, dwc3_devs); | ||
103 | } | ||
104 | EXPORT_SYMBOL_GPL(dwc3_put_device_id); | ||
105 | |||
106 | void dwc3_set_mode(struct dwc3 *dwc, u32 mode) | ||
107 | { | ||
108 | u32 reg; | ||
109 | |||
110 | reg = dwc3_readl(dwc->regs, DWC3_GCTL); | ||
111 | reg &= ~(DWC3_GCTL_PRTCAPDIR(DWC3_GCTL_PRTCAP_OTG)); | ||
112 | reg |= DWC3_GCTL_PRTCAPDIR(mode); | ||
113 | dwc3_writel(dwc->regs, DWC3_GCTL, reg); | ||
114 | } | ||
115 | |||
62 | /** | 116 | /** |
63 | * dwc3_core_soft_reset - Issues core soft reset and PHY reset | 117 | * dwc3_core_soft_reset - Issues core soft reset and PHY reset |
64 | * @dwc: pointer to our context structure | 118 | * @dwc: pointer to our context structure |
@@ -150,7 +204,7 @@ static void dwc3_free_event_buffers(struct dwc3 *dwc) | |||
150 | struct dwc3_event_buffer *evt; | 204 | struct dwc3_event_buffer *evt; |
151 | int i; | 205 | int i; |
152 | 206 | ||
153 | for (i = 0; i < DWC3_EVENT_BUFFERS_NUM; i++) { | 207 | for (i = 0; i < dwc->num_event_buffers; i++) { |
154 | evt = dwc->ev_buffs[i]; | 208 | evt = dwc->ev_buffs[i]; |
155 | if (evt) { | 209 | if (evt) { |
156 | dwc3_free_one_event_buffer(dwc, evt); | 210 | dwc3_free_one_event_buffer(dwc, evt); |
@@ -162,17 +216,25 @@ static void dwc3_free_event_buffers(struct dwc3 *dwc) | |||
162 | /** | 216 | /** |
163 | * dwc3_alloc_event_buffers - Allocates @num event buffers of size @length | 217 | * dwc3_alloc_event_buffers - Allocates @num event buffers of size @length |
164 | * @dwc: Pointer to out controller context structure | 218 | * @dwc: Pointer to out controller context structure |
165 | * @num: number of event buffers to allocate | ||
166 | * @length: size of event buffer | 219 | * @length: size of event buffer |
167 | * | 220 | * |
168 | * Returns 0 on success otherwise negative errno. In error the case, dwc | 221 | * Returns 0 on success otherwise negative errno. In error the case, dwc |
169 | * may contain some buffers allocated but not all which were requested. | 222 | * may contain some buffers allocated but not all which were requested. |
170 | */ | 223 | */ |
171 | static int __devinit dwc3_alloc_event_buffers(struct dwc3 *dwc, unsigned num, | 224 | static int __devinit dwc3_alloc_event_buffers(struct dwc3 *dwc, unsigned length) |
172 | unsigned length) | ||
173 | { | 225 | { |
226 | int num; | ||
174 | int i; | 227 | int i; |
175 | 228 | ||
229 | num = DWC3_NUM_INT(dwc->hwparams.hwparams1); | ||
230 | dwc->num_event_buffers = num; | ||
231 | |||
232 | dwc->ev_buffs = kzalloc(sizeof(*dwc->ev_buffs) * num, GFP_KERNEL); | ||
233 | if (!dwc->ev_buffs) { | ||
234 | dev_err(dwc->dev, "can't allocate event buffers array\n"); | ||
235 | return -ENOMEM; | ||
236 | } | ||
237 | |||
176 | for (i = 0; i < num; i++) { | 238 | for (i = 0; i < num; i++) { |
177 | struct dwc3_event_buffer *evt; | 239 | struct dwc3_event_buffer *evt; |
178 | 240 | ||
@@ -198,7 +260,7 @@ static int __devinit dwc3_event_buffers_setup(struct dwc3 *dwc) | |||
198 | struct dwc3_event_buffer *evt; | 260 | struct dwc3_event_buffer *evt; |
199 | int n; | 261 | int n; |
200 | 262 | ||
201 | for (n = 0; n < DWC3_EVENT_BUFFERS_NUM; n++) { | 263 | for (n = 0; n < dwc->num_event_buffers; n++) { |
202 | evt = dwc->ev_buffs[n]; | 264 | evt = dwc->ev_buffs[n]; |
203 | dev_dbg(dwc->dev, "Event buf %p dma %08llx length %d\n", | 265 | dev_dbg(dwc->dev, "Event buf %p dma %08llx length %d\n", |
204 | evt->buf, (unsigned long long) evt->dma, | 266 | evt->buf, (unsigned long long) evt->dma, |
@@ -221,7 +283,7 @@ static void dwc3_event_buffers_cleanup(struct dwc3 *dwc) | |||
221 | struct dwc3_event_buffer *evt; | 283 | struct dwc3_event_buffer *evt; |
222 | int n; | 284 | int n; |
223 | 285 | ||
224 | for (n = 0; n < DWC3_EVENT_BUFFERS_NUM; n++) { | 286 | for (n = 0; n < dwc->num_event_buffers; n++) { |
225 | evt = dwc->ev_buffs[n]; | 287 | evt = dwc->ev_buffs[n]; |
226 | dwc3_writel(dwc->regs, DWC3_GEVNTADRLO(n), 0); | 288 | dwc3_writel(dwc->regs, DWC3_GEVNTADRLO(n), 0); |
227 | dwc3_writel(dwc->regs, DWC3_GEVNTADRHI(n), 0); | 289 | dwc3_writel(dwc->regs, DWC3_GEVNTADRHI(n), 0); |
@@ -264,7 +326,7 @@ static int __devinit dwc3_core_init(struct dwc3 *dwc) | |||
264 | ret = -ENODEV; | 326 | ret = -ENODEV; |
265 | goto err0; | 327 | goto err0; |
266 | } | 328 | } |
267 | dwc->revision = reg & DWC3_GSNPSREV_MASK; | 329 | dwc->revision = reg; |
268 | 330 | ||
269 | dwc3_core_soft_reset(dwc); | 331 | dwc3_core_soft_reset(dwc); |
270 | 332 | ||
@@ -285,8 +347,32 @@ static int __devinit dwc3_core_init(struct dwc3 *dwc) | |||
285 | cpu_relax(); | 347 | cpu_relax(); |
286 | } while (true); | 348 | } while (true); |
287 | 349 | ||
288 | ret = dwc3_alloc_event_buffers(dwc, DWC3_EVENT_BUFFERS_NUM, | 350 | dwc3_cache_hwparams(dwc); |
289 | DWC3_EVENT_BUFFERS_SIZE); | 351 | |
352 | reg = dwc3_readl(dwc->regs, DWC3_GCTL); | ||
353 | reg &= ~DWC3_GCTL_SCALEDOWN(3); | ||
354 | reg &= ~DWC3_GCTL_DISSCRAMBLE; | ||
355 | |||
356 | switch (DWC3_GHWPARAMS1_EN_PWROPT(dwc->hwparams.hwparams1)) { | ||
357 | case DWC3_GHWPARAMS1_EN_PWROPT_CLK: | ||
358 | reg &= ~DWC3_GCTL_DSBLCLKGTNG; | ||
359 | break; | ||
360 | default: | ||
361 | dev_dbg(dwc->dev, "No power optimization available\n"); | ||
362 | } | ||
363 | |||
364 | /* | ||
365 | * WORKAROUND: DWC3 revisions <1.90a have a bug | ||
366 | * when The device fails to connect at SuperSpeed | ||
367 | * and falls back to high-speed mode which causes | ||
368 | * the device to enter in a Connect/Disconnect loop | ||
369 | */ | ||
370 | if (dwc->revision < DWC3_REVISION_190A) | ||
371 | reg |= DWC3_GCTL_U2RSTECN; | ||
372 | |||
373 | dwc3_writel(dwc->regs, DWC3_GCTL, reg); | ||
374 | |||
375 | ret = dwc3_alloc_event_buffers(dwc, DWC3_EVENT_BUFFERS_SIZE); | ||
290 | if (ret) { | 376 | if (ret) { |
291 | dev_err(dwc->dev, "failed to allocate event buffers\n"); | 377 | dev_err(dwc->dev, "failed to allocate event buffers\n"); |
292 | ret = -ENOMEM; | 378 | ret = -ENOMEM; |
@@ -299,8 +385,6 @@ static int __devinit dwc3_core_init(struct dwc3 *dwc) | |||
299 | goto err1; | 385 | goto err1; |
300 | } | 386 | } |
301 | 387 | ||
302 | dwc3_cache_hwparams(dwc); | ||
303 | |||
304 | return 0; | 388 | return 0; |
305 | 389 | ||
306 | err1: | 390 | err1: |
@@ -320,15 +404,17 @@ static void dwc3_core_exit(struct dwc3 *dwc) | |||
320 | 404 | ||
321 | static int __devinit dwc3_probe(struct platform_device *pdev) | 405 | static int __devinit dwc3_probe(struct platform_device *pdev) |
322 | { | 406 | { |
323 | const struct platform_device_id *id = platform_get_device_id(pdev); | ||
324 | struct resource *res; | 407 | struct resource *res; |
325 | struct dwc3 *dwc; | 408 | struct dwc3 *dwc; |
326 | void __iomem *regs; | 409 | |
327 | unsigned int features = id->driver_data; | ||
328 | int ret = -ENOMEM; | 410 | int ret = -ENOMEM; |
329 | int irq; | 411 | int irq; |
412 | |||
413 | void __iomem *regs; | ||
330 | void *mem; | 414 | void *mem; |
331 | 415 | ||
416 | u8 mode; | ||
417 | |||
332 | mem = kzalloc(sizeof(*dwc) + DWC3_ALIGN_MASK, GFP_KERNEL); | 418 | mem = kzalloc(sizeof(*dwc) + DWC3_ALIGN_MASK, GFP_KERNEL); |
333 | if (!mem) { | 419 | if (!mem) { |
334 | dev_err(&pdev->dev, "not enough memory\n"); | 420 | dev_err(&pdev->dev, "not enough memory\n"); |
@@ -343,6 +429,8 @@ static int __devinit dwc3_probe(struct platform_device *pdev) | |||
343 | goto err1; | 429 | goto err1; |
344 | } | 430 | } |
345 | 431 | ||
432 | dwc->res = res; | ||
433 | |||
346 | res = request_mem_region(res->start, resource_size(res), | 434 | res = request_mem_region(res->start, resource_size(res), |
347 | dev_name(&pdev->dev)); | 435 | dev_name(&pdev->dev)); |
348 | if (!res) { | 436 | if (!res) { |
@@ -370,6 +458,17 @@ static int __devinit dwc3_probe(struct platform_device *pdev) | |||
370 | dwc->dev = &pdev->dev; | 458 | dwc->dev = &pdev->dev; |
371 | dwc->irq = irq; | 459 | dwc->irq = irq; |
372 | 460 | ||
461 | if (!strncmp("super", maximum_speed, 5)) | ||
462 | dwc->maximum_speed = DWC3_DCFG_SUPERSPEED; | ||
463 | else if (!strncmp("high", maximum_speed, 4)) | ||
464 | dwc->maximum_speed = DWC3_DCFG_HIGHSPEED; | ||
465 | else if (!strncmp("full", maximum_speed, 4)) | ||
466 | dwc->maximum_speed = DWC3_DCFG_FULLSPEED1; | ||
467 | else if (!strncmp("low", maximum_speed, 3)) | ||
468 | dwc->maximum_speed = DWC3_DCFG_LOWSPEED; | ||
469 | else | ||
470 | dwc->maximum_speed = DWC3_DCFG_SUPERSPEED; | ||
471 | |||
373 | pm_runtime_enable(&pdev->dev); | 472 | pm_runtime_enable(&pdev->dev); |
374 | pm_runtime_get_sync(&pdev->dev); | 473 | pm_runtime_get_sync(&pdev->dev); |
375 | pm_runtime_forbid(&pdev->dev); | 474 | pm_runtime_forbid(&pdev->dev); |
@@ -380,13 +479,44 @@ static int __devinit dwc3_probe(struct platform_device *pdev) | |||
380 | goto err3; | 479 | goto err3; |
381 | } | 480 | } |
382 | 481 | ||
383 | if (features & DWC3_HAS_PERIPHERAL) { | 482 | mode = DWC3_MODE(dwc->hwparams.hwparams0); |
483 | |||
484 | switch (mode) { | ||
485 | case DWC3_MODE_DEVICE: | ||
486 | dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE); | ||
384 | ret = dwc3_gadget_init(dwc); | 487 | ret = dwc3_gadget_init(dwc); |
385 | if (ret) { | 488 | if (ret) { |
386 | dev_err(&pdev->dev, "failed to initialized gadget\n"); | 489 | dev_err(&pdev->dev, "failed to initialize gadget\n"); |
387 | goto err4; | 490 | goto err4; |
388 | } | 491 | } |
492 | break; | ||
493 | case DWC3_MODE_HOST: | ||
494 | dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_HOST); | ||
495 | ret = dwc3_host_init(dwc); | ||
496 | if (ret) { | ||
497 | dev_err(&pdev->dev, "failed to initialize host\n"); | ||
498 | goto err4; | ||
499 | } | ||
500 | break; | ||
501 | case DWC3_MODE_DRD: | ||
502 | dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_OTG); | ||
503 | ret = dwc3_host_init(dwc); | ||
504 | if (ret) { | ||
505 | dev_err(&pdev->dev, "failed to initialize host\n"); | ||
506 | goto err4; | ||
507 | } | ||
508 | |||
509 | ret = dwc3_gadget_init(dwc); | ||
510 | if (ret) { | ||
511 | dev_err(&pdev->dev, "failed to initialize gadget\n"); | ||
512 | goto err4; | ||
513 | } | ||
514 | break; | ||
515 | default: | ||
516 | dev_err(&pdev->dev, "Unsupported mode of operation %d\n", mode); | ||
517 | goto err4; | ||
389 | } | 518 | } |
519 | dwc->mode = mode; | ||
390 | 520 | ||
391 | ret = dwc3_debugfs_init(dwc); | 521 | ret = dwc3_debugfs_init(dwc); |
392 | if (ret) { | 522 | if (ret) { |
@@ -399,8 +529,21 @@ static int __devinit dwc3_probe(struct platform_device *pdev) | |||
399 | return 0; | 529 | return 0; |
400 | 530 | ||
401 | err5: | 531 | err5: |
402 | if (features & DWC3_HAS_PERIPHERAL) | 532 | switch (mode) { |
533 | case DWC3_MODE_DEVICE: | ||
534 | dwc3_gadget_exit(dwc); | ||
535 | break; | ||
536 | case DWC3_MODE_HOST: | ||
537 | dwc3_host_exit(dwc); | ||
538 | break; | ||
539 | case DWC3_MODE_DRD: | ||
540 | dwc3_host_exit(dwc); | ||
403 | dwc3_gadget_exit(dwc); | 541 | dwc3_gadget_exit(dwc); |
542 | break; | ||
543 | default: | ||
544 | /* do nothing */ | ||
545 | break; | ||
546 | } | ||
404 | 547 | ||
405 | err4: | 548 | err4: |
406 | dwc3_core_exit(dwc); | 549 | dwc3_core_exit(dwc); |
@@ -420,10 +563,8 @@ err0: | |||
420 | 563 | ||
421 | static int __devexit dwc3_remove(struct platform_device *pdev) | 564 | static int __devexit dwc3_remove(struct platform_device *pdev) |
422 | { | 565 | { |
423 | const struct platform_device_id *id = platform_get_device_id(pdev); | ||
424 | struct dwc3 *dwc = platform_get_drvdata(pdev); | 566 | struct dwc3 *dwc = platform_get_drvdata(pdev); |
425 | struct resource *res; | 567 | struct resource *res; |
426 | unsigned int features = id->driver_data; | ||
427 | 568 | ||
428 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 569 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
429 | 570 | ||
@@ -432,8 +573,21 @@ static int __devexit dwc3_remove(struct platform_device *pdev) | |||
432 | 573 | ||
433 | dwc3_debugfs_exit(dwc); | 574 | dwc3_debugfs_exit(dwc); |
434 | 575 | ||
435 | if (features & DWC3_HAS_PERIPHERAL) | 576 | switch (dwc->mode) { |
577 | case DWC3_MODE_DEVICE: | ||
578 | dwc3_gadget_exit(dwc); | ||
579 | break; | ||
580 | case DWC3_MODE_HOST: | ||
581 | dwc3_host_exit(dwc); | ||
582 | break; | ||
583 | case DWC3_MODE_DRD: | ||
584 | dwc3_host_exit(dwc); | ||
436 | dwc3_gadget_exit(dwc); | 585 | dwc3_gadget_exit(dwc); |
586 | break; | ||
587 | default: | ||
588 | /* do nothing */ | ||
589 | break; | ||
590 | } | ||
437 | 591 | ||
438 | dwc3_core_exit(dwc); | 592 | dwc3_core_exit(dwc); |
439 | release_mem_region(res->start, resource_size(res)); | 593 | release_mem_region(res->start, resource_size(res)); |
@@ -443,30 +597,15 @@ static int __devexit dwc3_remove(struct platform_device *pdev) | |||
443 | return 0; | 597 | return 0; |
444 | } | 598 | } |
445 | 599 | ||
446 | static const struct platform_device_id dwc3_id_table[] __devinitconst = { | ||
447 | { | ||
448 | .name = "dwc3-omap", | ||
449 | .driver_data = (DWC3_HAS_PERIPHERAL | ||
450 | | DWC3_HAS_XHCI | ||
451 | | DWC3_HAS_OTG), | ||
452 | }, | ||
453 | { | ||
454 | .name = "dwc3-pci", | ||
455 | .driver_data = DWC3_HAS_PERIPHERAL, | ||
456 | }, | ||
457 | { }, /* Terminating Entry */ | ||
458 | }; | ||
459 | MODULE_DEVICE_TABLE(platform, dwc3_id_table); | ||
460 | |||
461 | static struct platform_driver dwc3_driver = { | 600 | static struct platform_driver dwc3_driver = { |
462 | .probe = dwc3_probe, | 601 | .probe = dwc3_probe, |
463 | .remove = __devexit_p(dwc3_remove), | 602 | .remove = __devexit_p(dwc3_remove), |
464 | .driver = { | 603 | .driver = { |
465 | .name = "dwc3", | 604 | .name = "dwc3", |
466 | }, | 605 | }, |
467 | .id_table = dwc3_id_table, | ||
468 | }; | 606 | }; |
469 | 607 | ||
608 | MODULE_ALIAS("platform:dwc3"); | ||
470 | MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>"); | 609 | MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>"); |
471 | MODULE_LICENSE("Dual BSD/GPL"); | 610 | MODULE_LICENSE("Dual BSD/GPL"); |
472 | MODULE_DESCRIPTION("DesignWare USB3 DRD Controller Driver"); | 611 | MODULE_DESCRIPTION("DesignWare USB3 DRD Controller Driver"); |
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 29a8e1679e12..9e57f8e9bf17 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h | |||
@@ -41,6 +41,7 @@ | |||
41 | 41 | ||
42 | #include <linux/device.h> | 42 | #include <linux/device.h> |
43 | #include <linux/spinlock.h> | 43 | #include <linux/spinlock.h> |
44 | #include <linux/ioport.h> | ||
44 | #include <linux/list.h> | 45 | #include <linux/list.h> |
45 | #include <linux/dma-mapping.h> | 46 | #include <linux/dma-mapping.h> |
46 | #include <linux/mm.h> | 47 | #include <linux/mm.h> |
@@ -52,7 +53,6 @@ | |||
52 | /* Global constants */ | 53 | /* Global constants */ |
53 | #define DWC3_ENDPOINTS_NUM 32 | 54 | #define DWC3_ENDPOINTS_NUM 32 |
54 | 55 | ||
55 | #define DWC3_EVENT_BUFFERS_NUM 2 | ||
56 | #define DWC3_EVENT_BUFFERS_SIZE PAGE_SIZE | 56 | #define DWC3_EVENT_BUFFERS_SIZE PAGE_SIZE |
57 | #define DWC3_EVENT_TYPE_MASK 0xfe | 57 | #define DWC3_EVENT_TYPE_MASK 0xfe |
58 | 58 | ||
@@ -153,6 +153,7 @@ | |||
153 | #define DWC3_GCTL_CLK_PIPEHALF (2) | 153 | #define DWC3_GCTL_CLK_PIPEHALF (2) |
154 | #define DWC3_GCTL_CLK_MASK (3) | 154 | #define DWC3_GCTL_CLK_MASK (3) |
155 | 155 | ||
156 | #define DWC3_GCTL_PRTCAP(n) (((n) & (3 << 12)) >> 12) | ||
156 | #define DWC3_GCTL_PRTCAPDIR(n) (n << 12) | 157 | #define DWC3_GCTL_PRTCAPDIR(n) (n << 12) |
157 | #define DWC3_GCTL_PRTCAP_HOST 1 | 158 | #define DWC3_GCTL_PRTCAP_HOST 1 |
158 | #define DWC3_GCTL_PRTCAP_DEVICE 2 | 159 | #define DWC3_GCTL_PRTCAP_DEVICE 2 |
@@ -347,6 +348,7 @@ struct dwc3_ep { | |||
347 | u32 free_slot; | 348 | u32 free_slot; |
348 | u32 busy_slot; | 349 | u32 busy_slot; |
349 | const struct usb_endpoint_descriptor *desc; | 350 | const struct usb_endpoint_descriptor *desc; |
351 | const struct usb_ss_ep_comp_descriptor *comp_desc; | ||
350 | struct dwc3 *dwc; | 352 | struct dwc3 *dwc; |
351 | 353 | ||
352 | unsigned flags; | 354 | unsigned flags; |
@@ -536,6 +538,31 @@ struct dwc3_hwparams { | |||
536 | u32 hwparams8; | 538 | u32 hwparams8; |
537 | }; | 539 | }; |
538 | 540 | ||
541 | /* HWPARAMS0 */ | ||
542 | #define DWC3_MODE(n) ((n) & 0x7) | ||
543 | |||
544 | #define DWC3_MODE_DEVICE 0 | ||
545 | #define DWC3_MODE_HOST 1 | ||
546 | #define DWC3_MODE_DRD 2 | ||
547 | #define DWC3_MODE_HUB 3 | ||
548 | |||
549 | /* HWPARAMS1 */ | ||
550 | #define DWC3_NUM_INT(n) (((n) & (0x3f << 15)) >> 15) | ||
551 | |||
552 | struct dwc3_request { | ||
553 | struct usb_request request; | ||
554 | struct list_head list; | ||
555 | struct dwc3_ep *dep; | ||
556 | |||
557 | u8 epnum; | ||
558 | struct dwc3_trb_hw *trb; | ||
559 | dma_addr_t trb_dma; | ||
560 | |||
561 | unsigned direction:1; | ||
562 | unsigned mapped:1; | ||
563 | unsigned queued:1; | ||
564 | }; | ||
565 | |||
539 | /** | 566 | /** |
540 | * struct dwc3 - representation of our controller | 567 | * struct dwc3 - representation of our controller |
541 | * @ctrl_req: usb control request which is used for ep0 | 568 | * @ctrl_req: usb control request which is used for ep0 |
@@ -549,19 +576,24 @@ struct dwc3_hwparams { | |||
549 | * @ep0_bounce_addr: dma address of ep0_bounce | 576 | * @ep0_bounce_addr: dma address of ep0_bounce |
550 | * @lock: for synchronizing | 577 | * @lock: for synchronizing |
551 | * @dev: pointer to our struct device | 578 | * @dev: pointer to our struct device |
579 | * @xhci: pointer to our xHCI child | ||
552 | * @event_buffer_list: a list of event buffers | 580 | * @event_buffer_list: a list of event buffers |
553 | * @gadget: device side representation of the peripheral controller | 581 | * @gadget: device side representation of the peripheral controller |
554 | * @gadget_driver: pointer to the gadget driver | 582 | * @gadget_driver: pointer to the gadget driver |
555 | * @regs: base address for our registers | 583 | * @regs: base address for our registers |
556 | * @regs_size: address space size | 584 | * @regs_size: address space size |
557 | * @irq: IRQ number | 585 | * @irq: IRQ number |
586 | * @num_event_buffers: calculated number of event buffers | ||
587 | * @u1u2: only used on revisions <1.83a for workaround | ||
588 | * @maximum_speed: maximum speed requested (mainly for testing purposes) | ||
558 | * @revision: revision register contents | 589 | * @revision: revision register contents |
590 | * @mode: mode of operation | ||
559 | * @is_selfpowered: true when we are selfpowered | 591 | * @is_selfpowered: true when we are selfpowered |
560 | * @three_stage_setup: set if we perform a three phase setup | 592 | * @three_stage_setup: set if we perform a three phase setup |
561 | * @ep0_status_pending: ep0 status response without a req is pending | ||
562 | * @ep0_bounced: true when we used bounce buffer | 593 | * @ep0_bounced: true when we used bounce buffer |
563 | * @ep0_expect_in: true when we expect a DATA IN transfer | 594 | * @ep0_expect_in: true when we expect a DATA IN transfer |
564 | * @start_config_issued: true when StartConfig command has been issued | 595 | * @start_config_issued: true when StartConfig command has been issued |
596 | * @setup_packet_pending: true when there's a Setup Packet in FIFO. Workaround | ||
565 | * @ep0_next_event: hold the next expected event | 597 | * @ep0_next_event: hold the next expected event |
566 | * @ep0state: state of endpoint zero | 598 | * @ep0state: state of endpoint zero |
567 | * @link_state: link state | 599 | * @link_state: link state |
@@ -579,12 +611,15 @@ struct dwc3 { | |||
579 | dma_addr_t ep0_trb_addr; | 611 | dma_addr_t ep0_trb_addr; |
580 | dma_addr_t setup_buf_addr; | 612 | dma_addr_t setup_buf_addr; |
581 | dma_addr_t ep0_bounce_addr; | 613 | dma_addr_t ep0_bounce_addr; |
582 | struct usb_request ep0_usb_req; | 614 | struct dwc3_request ep0_usb_req; |
583 | /* device lock */ | 615 | /* device lock */ |
584 | spinlock_t lock; | 616 | spinlock_t lock; |
585 | struct device *dev; | 617 | struct device *dev; |
586 | 618 | ||
587 | struct dwc3_event_buffer *ev_buffs[DWC3_EVENT_BUFFERS_NUM]; | 619 | struct platform_device *xhci; |
620 | struct resource *res; | ||
621 | |||
622 | struct dwc3_event_buffer **ev_buffs; | ||
588 | struct dwc3_ep *eps[DWC3_ENDPOINTS_NUM]; | 623 | struct dwc3_ep *eps[DWC3_ENDPOINTS_NUM]; |
589 | 624 | ||
590 | struct usb_gadget gadget; | 625 | struct usb_gadget gadget; |
@@ -595,7 +630,11 @@ struct dwc3 { | |||
595 | 630 | ||
596 | int irq; | 631 | int irq; |
597 | 632 | ||
633 | u32 num_event_buffers; | ||
634 | u32 u1u2; | ||
635 | u32 maximum_speed; | ||
598 | u32 revision; | 636 | u32 revision; |
637 | u32 mode; | ||
599 | 638 | ||
600 | #define DWC3_REVISION_173A 0x5533173a | 639 | #define DWC3_REVISION_173A 0x5533173a |
601 | #define DWC3_REVISION_175A 0x5533175a | 640 | #define DWC3_REVISION_175A 0x5533175a |
@@ -607,10 +646,11 @@ struct dwc3 { | |||
607 | 646 | ||
608 | unsigned is_selfpowered:1; | 647 | unsigned is_selfpowered:1; |
609 | unsigned three_stage_setup:1; | 648 | unsigned three_stage_setup:1; |
610 | unsigned ep0_status_pending:1; | ||
611 | unsigned ep0_bounced:1; | 649 | unsigned ep0_bounced:1; |
612 | unsigned ep0_expect_in:1; | 650 | unsigned ep0_expect_in:1; |
613 | unsigned start_config_issued:1; | 651 | unsigned start_config_issued:1; |
652 | unsigned setup_packet_pending:1; | ||
653 | unsigned delayed_status:1; | ||
614 | 654 | ||
615 | enum dwc3_ep0_next ep0_next_event; | 655 | enum dwc3_ep0_next ep0_next_event; |
616 | enum dwc3_ep0_state ep0state; | 656 | enum dwc3_ep0_state ep0state; |
@@ -765,4 +805,16 @@ union dwc3_event { | |||
765 | #define DWC3_HAS_XHCI BIT(1) | 805 | #define DWC3_HAS_XHCI BIT(1) |
766 | #define DWC3_HAS_OTG BIT(3) | 806 | #define DWC3_HAS_OTG BIT(3) |
767 | 807 | ||
808 | /* prototypes */ | ||
809 | void dwc3_set_mode(struct dwc3 *dwc, u32 mode); | ||
810 | |||
811 | int dwc3_host_init(struct dwc3 *dwc); | ||
812 | void dwc3_host_exit(struct dwc3 *dwc); | ||
813 | |||
814 | int dwc3_gadget_init(struct dwc3 *dwc); | ||
815 | void dwc3_gadget_exit(struct dwc3 *dwc); | ||
816 | |||
817 | extern int dwc3_get_device_id(void); | ||
818 | extern void dwc3_put_device_id(int id); | ||
819 | |||
768 | #endif /* __DRIVERS_USB_DWC3_CORE_H */ | 820 | #endif /* __DRIVERS_USB_DWC3_CORE_H */ |
diff --git a/drivers/usb/dwc3/debugfs.c b/drivers/usb/dwc3/debugfs.c index da1ad77d8d51..433c97c15fc5 100644 --- a/drivers/usb/dwc3/debugfs.c +++ b/drivers/usb/dwc3/debugfs.c | |||
@@ -44,17 +44,12 @@ | |||
44 | #include <linux/debugfs.h> | 44 | #include <linux/debugfs.h> |
45 | #include <linux/seq_file.h> | 45 | #include <linux/seq_file.h> |
46 | #include <linux/delay.h> | 46 | #include <linux/delay.h> |
47 | 47 | #include <linux/uaccess.h> | |
48 | #include <asm/uaccess.h> | ||
49 | 48 | ||
50 | #include "core.h" | 49 | #include "core.h" |
51 | #include "gadget.h" | 50 | #include "gadget.h" |
52 | #include "io.h" | 51 | #include "io.h" |
53 | 52 | #include "debug.h" | |
54 | struct dwc3_register { | ||
55 | const char *name; | ||
56 | u32 offset; | ||
57 | }; | ||
58 | 53 | ||
59 | #define dump_register(nm) \ | 54 | #define dump_register(nm) \ |
60 | { \ | 55 | { \ |
@@ -62,7 +57,7 @@ struct dwc3_register { | |||
62 | .offset = DWC3_ ##nm, \ | 57 | .offset = DWC3_ ##nm, \ |
63 | } | 58 | } |
64 | 59 | ||
65 | static const struct dwc3_register dwc3_regs[] = { | 60 | static const struct debugfs_reg32 dwc3_regs[] = { |
66 | dump_register(GSBUSCFG0), | 61 | dump_register(GSBUSCFG0), |
67 | dump_register(GSBUSCFG1), | 62 | dump_register(GSBUSCFG1), |
68 | dump_register(GTXTHRCFG), | 63 | dump_register(GTXTHRCFG), |
@@ -382,15 +377,10 @@ static const struct dwc3_register dwc3_regs[] = { | |||
382 | static int dwc3_regdump_show(struct seq_file *s, void *unused) | 377 | static int dwc3_regdump_show(struct seq_file *s, void *unused) |
383 | { | 378 | { |
384 | struct dwc3 *dwc = s->private; | 379 | struct dwc3 *dwc = s->private; |
385 | int i; | ||
386 | 380 | ||
387 | seq_printf(s, "DesignWare USB3 Core Register Dump\n"); | 381 | seq_printf(s, "DesignWare USB3 Core Register Dump\n"); |
388 | 382 | debugfs_print_regs32(s, dwc3_regs, ARRAY_SIZE(dwc3_regs), | |
389 | for (i = 0; i < ARRAY_SIZE(dwc3_regs); i++) { | 383 | dwc->regs, ""); |
390 | seq_printf(s, "%-20s : %08x\n", dwc3_regs[i].name, | ||
391 | dwc3_readl(dwc->regs, dwc3_regs[i].offset)); | ||
392 | } | ||
393 | |||
394 | return 0; | 384 | return 0; |
395 | } | 385 | } |
396 | 386 | ||
@@ -405,6 +395,75 @@ static const struct file_operations dwc3_regdump_fops = { | |||
405 | .release = single_release, | 395 | .release = single_release, |
406 | }; | 396 | }; |
407 | 397 | ||
398 | static int dwc3_mode_show(struct seq_file *s, void *unused) | ||
399 | { | ||
400 | struct dwc3 *dwc = s->private; | ||
401 | unsigned long flags; | ||
402 | u32 reg; | ||
403 | |||
404 | spin_lock_irqsave(&dwc->lock, flags); | ||
405 | reg = dwc3_readl(dwc->regs, DWC3_GCTL); | ||
406 | spin_unlock_irqrestore(&dwc->lock, flags); | ||
407 | |||
408 | switch (DWC3_GCTL_PRTCAP(reg)) { | ||
409 | case DWC3_GCTL_PRTCAP_HOST: | ||
410 | seq_printf(s, "host\n"); | ||
411 | break; | ||
412 | case DWC3_GCTL_PRTCAP_DEVICE: | ||
413 | seq_printf(s, "device\n"); | ||
414 | break; | ||
415 | case DWC3_GCTL_PRTCAP_OTG: | ||
416 | seq_printf(s, "OTG\n"); | ||
417 | break; | ||
418 | default: | ||
419 | seq_printf(s, "UNKNOWN %08x\n", DWC3_GCTL_PRTCAP(reg)); | ||
420 | } | ||
421 | |||
422 | return 0; | ||
423 | } | ||
424 | |||
425 | static int dwc3_mode_open(struct inode *inode, struct file *file) | ||
426 | { | ||
427 | return single_open(file, dwc3_mode_show, inode->i_private); | ||
428 | } | ||
429 | |||
430 | static ssize_t dwc3_mode_write(struct file *file, | ||
431 | const char __user *ubuf, size_t count, loff_t *ppos) | ||
432 | { | ||
433 | struct seq_file *s = file->private_data; | ||
434 | struct dwc3 *dwc = s->private; | ||
435 | unsigned long flags; | ||
436 | u32 mode = 0; | ||
437 | char buf[32]; | ||
438 | |||
439 | if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count))) | ||
440 | return -EFAULT; | ||
441 | |||
442 | if (!strncmp(buf, "host", 4)) | ||
443 | mode |= DWC3_GCTL_PRTCAP_HOST; | ||
444 | |||
445 | if (!strncmp(buf, "device", 6)) | ||
446 | mode |= DWC3_GCTL_PRTCAP_DEVICE; | ||
447 | |||
448 | if (!strncmp(buf, "otg", 3)) | ||
449 | mode |= DWC3_GCTL_PRTCAP_OTG; | ||
450 | |||
451 | if (mode) { | ||
452 | spin_lock_irqsave(&dwc->lock, flags); | ||
453 | dwc3_set_mode(dwc, mode); | ||
454 | spin_unlock_irqrestore(&dwc->lock, flags); | ||
455 | } | ||
456 | return count; | ||
457 | } | ||
458 | |||
459 | static const struct file_operations dwc3_mode_fops = { | ||
460 | .open = dwc3_mode_open, | ||
461 | .write = dwc3_mode_write, | ||
462 | .read = seq_read, | ||
463 | .llseek = seq_lseek, | ||
464 | .release = single_release, | ||
465 | }; | ||
466 | |||
408 | int __devinit dwc3_debugfs_init(struct dwc3 *dwc) | 467 | int __devinit dwc3_debugfs_init(struct dwc3 *dwc) |
409 | { | 468 | { |
410 | struct dentry *root; | 469 | struct dentry *root; |
@@ -412,7 +471,7 @@ int __devinit dwc3_debugfs_init(struct dwc3 *dwc) | |||
412 | int ret; | 471 | int ret; |
413 | 472 | ||
414 | root = debugfs_create_dir(dev_name(dwc->dev), NULL); | 473 | root = debugfs_create_dir(dev_name(dwc->dev), NULL); |
415 | if (IS_ERR(root)){ | 474 | if (IS_ERR(root)) { |
416 | ret = PTR_ERR(root); | 475 | ret = PTR_ERR(root); |
417 | goto err0; | 476 | goto err0; |
418 | } | 477 | } |
@@ -425,6 +484,14 @@ int __devinit dwc3_debugfs_init(struct dwc3 *dwc) | |||
425 | ret = PTR_ERR(file); | 484 | ret = PTR_ERR(file); |
426 | goto err1; | 485 | goto err1; |
427 | } | 486 | } |
487 | |||
488 | file = debugfs_create_file("mode", S_IRUGO | S_IWUSR, root, | ||
489 | dwc, &dwc3_mode_fops); | ||
490 | if (IS_ERR(file)) { | ||
491 | ret = PTR_ERR(file); | ||
492 | goto err1; | ||
493 | } | ||
494 | |||
428 | return 0; | 495 | return 0; |
429 | 496 | ||
430 | err1: | 497 | err1: |
diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c index 062552b5fc8a..3274ac8f1200 100644 --- a/drivers/usb/dwc3/dwc3-omap.c +++ b/drivers/usb/dwc3/dwc3-omap.c | |||
@@ -48,6 +48,7 @@ | |||
48 | #include <linux/io.h> | 48 | #include <linux/io.h> |
49 | #include <linux/module.h> | 49 | #include <linux/module.h> |
50 | 50 | ||
51 | #include "core.h" | ||
51 | #include "io.h" | 52 | #include "io.h" |
52 | 53 | ||
53 | /* | 54 | /* |
@@ -200,6 +201,7 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev) | |||
200 | struct dwc3_omap *omap; | 201 | struct dwc3_omap *omap; |
201 | struct resource *res; | 202 | struct resource *res; |
202 | 203 | ||
204 | int devid; | ||
203 | int ret = -ENOMEM; | 205 | int ret = -ENOMEM; |
204 | int irq; | 206 | int irq; |
205 | 207 | ||
@@ -236,16 +238,20 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev) | |||
236 | goto err1; | 238 | goto err1; |
237 | } | 239 | } |
238 | 240 | ||
239 | dwc3 = platform_device_alloc("dwc3-omap", -1); | 241 | devid = dwc3_get_device_id(); |
242 | if (devid < 0) | ||
243 | goto err2; | ||
244 | |||
245 | dwc3 = platform_device_alloc("dwc3", devid); | ||
240 | if (!dwc3) { | 246 | if (!dwc3) { |
241 | dev_err(&pdev->dev, "couldn't allocate dwc3 device\n"); | 247 | dev_err(&pdev->dev, "couldn't allocate dwc3 device\n"); |
242 | goto err2; | 248 | goto err3; |
243 | } | 249 | } |
244 | 250 | ||
245 | context = kzalloc(resource_size(res), GFP_KERNEL); | 251 | context = kzalloc(resource_size(res), GFP_KERNEL); |
246 | if (!context) { | 252 | if (!context) { |
247 | dev_err(&pdev->dev, "couldn't allocate dwc3 context memory\n"); | 253 | dev_err(&pdev->dev, "couldn't allocate dwc3 context memory\n"); |
248 | goto err3; | 254 | goto err4; |
249 | } | 255 | } |
250 | 256 | ||
251 | spin_lock_init(&omap->lock); | 257 | spin_lock_init(&omap->lock); |
@@ -299,7 +305,7 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev) | |||
299 | if (ret) { | 305 | if (ret) { |
300 | dev_err(&pdev->dev, "failed to request IRQ #%d --> %d\n", | 306 | dev_err(&pdev->dev, "failed to request IRQ #%d --> %d\n", |
301 | omap->irq, ret); | 307 | omap->irq, ret); |
302 | goto err4; | 308 | goto err5; |
303 | } | 309 | } |
304 | 310 | ||
305 | /* enable all IRQs */ | 311 | /* enable all IRQs */ |
@@ -322,26 +328,29 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev) | |||
322 | pdev->num_resources); | 328 | pdev->num_resources); |
323 | if (ret) { | 329 | if (ret) { |
324 | dev_err(&pdev->dev, "couldn't add resources to dwc3 device\n"); | 330 | dev_err(&pdev->dev, "couldn't add resources to dwc3 device\n"); |
325 | goto err5; | 331 | goto err6; |
326 | } | 332 | } |
327 | 333 | ||
328 | ret = platform_device_add(dwc3); | 334 | ret = platform_device_add(dwc3); |
329 | if (ret) { | 335 | if (ret) { |
330 | dev_err(&pdev->dev, "failed to register dwc3 device\n"); | 336 | dev_err(&pdev->dev, "failed to register dwc3 device\n"); |
331 | goto err5; | 337 | goto err6; |
332 | } | 338 | } |
333 | 339 | ||
334 | return 0; | 340 | return 0; |
335 | 341 | ||
336 | err5: | 342 | err6: |
337 | free_irq(omap->irq, omap); | 343 | free_irq(omap->irq, omap); |
338 | 344 | ||
339 | err4: | 345 | err5: |
340 | kfree(omap->context); | 346 | kfree(omap->context); |
341 | 347 | ||
342 | err3: | 348 | err4: |
343 | platform_device_put(dwc3); | 349 | platform_device_put(dwc3); |
344 | 350 | ||
351 | err3: | ||
352 | dwc3_put_device_id(devid); | ||
353 | |||
345 | err2: | 354 | err2: |
346 | iounmap(base); | 355 | iounmap(base); |
347 | 356 | ||
@@ -358,6 +367,7 @@ static int __devexit dwc3_omap_remove(struct platform_device *pdev) | |||
358 | 367 | ||
359 | platform_device_unregister(omap->dwc3); | 368 | platform_device_unregister(omap->dwc3); |
360 | 369 | ||
370 | dwc3_put_device_id(omap->dwc3->id); | ||
361 | free_irq(omap->irq, omap); | 371 | free_irq(omap->irq, omap); |
362 | iounmap(omap->base); | 372 | iounmap(omap->base); |
363 | 373 | ||
@@ -384,18 +394,9 @@ static struct platform_driver dwc3_omap_driver = { | |||
384 | }, | 394 | }, |
385 | }; | 395 | }; |
386 | 396 | ||
397 | module_platform_driver(dwc3_omap_driver); | ||
398 | |||
399 | MODULE_ALIAS("platform:omap-dwc3"); | ||
387 | MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>"); | 400 | MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>"); |
388 | MODULE_LICENSE("Dual BSD/GPL"); | 401 | MODULE_LICENSE("Dual BSD/GPL"); |
389 | MODULE_DESCRIPTION("DesignWare USB3 OMAP Glue Layer"); | 402 | MODULE_DESCRIPTION("DesignWare USB3 OMAP Glue Layer"); |
390 | |||
391 | static int __devinit dwc3_omap_init(void) | ||
392 | { | ||
393 | return platform_driver_register(&dwc3_omap_driver); | ||
394 | } | ||
395 | module_init(dwc3_omap_init); | ||
396 | |||
397 | static void __exit dwc3_omap_exit(void) | ||
398 | { | ||
399 | platform_driver_unregister(&dwc3_omap_driver); | ||
400 | } | ||
401 | module_exit(dwc3_omap_exit); | ||
diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c index f77c00042685..64e1f7c67b08 100644 --- a/drivers/usb/dwc3/dwc3-pci.c +++ b/drivers/usb/dwc3/dwc3-pci.c | |||
@@ -42,52 +42,17 @@ | |||
42 | #include <linux/pci.h> | 42 | #include <linux/pci.h> |
43 | #include <linux/platform_device.h> | 43 | #include <linux/platform_device.h> |
44 | 44 | ||
45 | #include "core.h" | ||
46 | |||
45 | /* FIXME define these in <linux/pci_ids.h> */ | 47 | /* FIXME define these in <linux/pci_ids.h> */ |
46 | #define PCI_VENDOR_ID_SYNOPSYS 0x16c3 | 48 | #define PCI_VENDOR_ID_SYNOPSYS 0x16c3 |
47 | #define PCI_DEVICE_ID_SYNOPSYS_HAPSUSB3 0xabcd | 49 | #define PCI_DEVICE_ID_SYNOPSYS_HAPSUSB3 0xabcd |
48 | 50 | ||
49 | #define DWC3_PCI_DEVS_POSSIBLE 32 | ||
50 | |||
51 | struct dwc3_pci { | 51 | struct dwc3_pci { |
52 | struct device *dev; | 52 | struct device *dev; |
53 | struct platform_device *dwc3; | 53 | struct platform_device *dwc3; |
54 | }; | 54 | }; |
55 | 55 | ||
56 | static DECLARE_BITMAP(dwc3_pci_devs, DWC3_PCI_DEVS_POSSIBLE); | ||
57 | |||
58 | static int dwc3_pci_get_device_id(struct dwc3_pci *glue) | ||
59 | { | ||
60 | int id; | ||
61 | |||
62 | again: | ||
63 | id = find_first_zero_bit(dwc3_pci_devs, DWC3_PCI_DEVS_POSSIBLE); | ||
64 | if (id < DWC3_PCI_DEVS_POSSIBLE) { | ||
65 | int old; | ||
66 | |||
67 | old = test_and_set_bit(id, dwc3_pci_devs); | ||
68 | if (old) | ||
69 | goto again; | ||
70 | } else { | ||
71 | dev_err(glue->dev, "no space for new device\n"); | ||
72 | id = -ENOMEM; | ||
73 | } | ||
74 | |||
75 | return 0; | ||
76 | } | ||
77 | |||
78 | static void dwc3_pci_put_device_id(struct dwc3_pci *glue, int id) | ||
79 | { | ||
80 | int ret; | ||
81 | |||
82 | if (id < 0) | ||
83 | return; | ||
84 | |||
85 | ret = test_bit(id, dwc3_pci_devs); | ||
86 | WARN(!ret, "Device: %s\nID %d not in use\n", | ||
87 | dev_driver_string(glue->dev), id); | ||
88 | clear_bit(id, dwc3_pci_devs); | ||
89 | } | ||
90 | |||
91 | static int __devinit dwc3_pci_probe(struct pci_dev *pci, | 56 | static int __devinit dwc3_pci_probe(struct pci_dev *pci, |
92 | const struct pci_device_id *id) | 57 | const struct pci_device_id *id) |
93 | { | 58 | { |
@@ -114,11 +79,11 @@ static int __devinit dwc3_pci_probe(struct pci_dev *pci, | |||
114 | pci_set_power_state(pci, PCI_D0); | 79 | pci_set_power_state(pci, PCI_D0); |
115 | pci_set_master(pci); | 80 | pci_set_master(pci); |
116 | 81 | ||
117 | devid = dwc3_pci_get_device_id(glue); | 82 | devid = dwc3_get_device_id(); |
118 | if (devid < 0) | 83 | if (devid < 0) |
119 | goto err2; | 84 | goto err2; |
120 | 85 | ||
121 | dwc3 = platform_device_alloc("dwc3-pci", devid); | 86 | dwc3 = platform_device_alloc("dwc3", devid); |
122 | if (!dwc3) { | 87 | if (!dwc3) { |
123 | dev_err(&pci->dev, "couldn't allocate dwc3 device\n"); | 88 | dev_err(&pci->dev, "couldn't allocate dwc3 device\n"); |
124 | goto err3; | 89 | goto err3; |
@@ -163,13 +128,13 @@ err4: | |||
163 | platform_device_put(dwc3); | 128 | platform_device_put(dwc3); |
164 | 129 | ||
165 | err3: | 130 | err3: |
166 | dwc3_pci_put_device_id(glue, devid); | 131 | dwc3_put_device_id(devid); |
167 | 132 | ||
168 | err2: | 133 | err2: |
169 | pci_disable_device(pci); | 134 | pci_disable_device(pci); |
170 | 135 | ||
171 | err1: | 136 | err1: |
172 | kfree(pci); | 137 | kfree(glue); |
173 | 138 | ||
174 | err0: | 139 | err0: |
175 | return ret; | 140 | return ret; |
@@ -179,7 +144,7 @@ static void __devexit dwc3_pci_remove(struct pci_dev *pci) | |||
179 | { | 144 | { |
180 | struct dwc3_pci *glue = pci_get_drvdata(pci); | 145 | struct dwc3_pci *glue = pci_get_drvdata(pci); |
181 | 146 | ||
182 | dwc3_pci_put_device_id(glue, glue->dwc3->id); | 147 | dwc3_put_device_id(glue->dwc3->id); |
183 | platform_device_unregister(glue->dwc3); | 148 | platform_device_unregister(glue->dwc3); |
184 | pci_set_drvdata(pci, NULL); | 149 | pci_set_drvdata(pci, NULL); |
185 | pci_disable_device(pci); | 150 | pci_disable_device(pci); |
@@ -196,7 +161,7 @@ static DEFINE_PCI_DEVICE_TABLE(dwc3_pci_id_table) = { | |||
196 | MODULE_DEVICE_TABLE(pci, dwc3_pci_id_table); | 161 | MODULE_DEVICE_TABLE(pci, dwc3_pci_id_table); |
197 | 162 | ||
198 | static struct pci_driver dwc3_pci_driver = { | 163 | static struct pci_driver dwc3_pci_driver = { |
199 | .name = "pci-dwc3", | 164 | .name = "dwc3-pci", |
200 | .id_table = dwc3_pci_id_table, | 165 | .id_table = dwc3_pci_id_table, |
201 | .probe = dwc3_pci_probe, | 166 | .probe = dwc3_pci_probe, |
202 | .remove = __devexit_p(dwc3_pci_remove), | 167 | .remove = __devexit_p(dwc3_pci_remove), |
diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c index 69a4e43ddf59..2f51de57593a 100644 --- a/drivers/usb/dwc3/ep0.c +++ b/drivers/usb/dwc3/ep0.c | |||
@@ -48,13 +48,13 @@ | |||
48 | 48 | ||
49 | #include <linux/usb/ch9.h> | 49 | #include <linux/usb/ch9.h> |
50 | #include <linux/usb/gadget.h> | 50 | #include <linux/usb/gadget.h> |
51 | #include <linux/usb/composite.h> | ||
51 | 52 | ||
52 | #include "core.h" | 53 | #include "core.h" |
53 | #include "gadget.h" | 54 | #include "gadget.h" |
54 | #include "io.h" | 55 | #include "io.h" |
55 | 56 | ||
56 | static void dwc3_ep0_inspect_setup(struct dwc3 *dwc, | 57 | static void dwc3_ep0_do_control_status(struct dwc3 *dwc, u32 epnum); |
57 | const struct dwc3_event_depevt *event); | ||
58 | 58 | ||
59 | static const char *dwc3_ep0_state_string(enum dwc3_ep0_state state) | 59 | static const char *dwc3_ep0_state_string(enum dwc3_ep0_state state) |
60 | { | 60 | { |
@@ -125,6 +125,8 @@ static int dwc3_ep0_start_trans(struct dwc3 *dwc, u8 epnum, dma_addr_t buf_dma, | |||
125 | static int __dwc3_gadget_ep0_queue(struct dwc3_ep *dep, | 125 | static int __dwc3_gadget_ep0_queue(struct dwc3_ep *dep, |
126 | struct dwc3_request *req) | 126 | struct dwc3_request *req) |
127 | { | 127 | { |
128 | struct dwc3 *dwc = dep->dwc; | ||
129 | u32 type; | ||
128 | int ret = 0; | 130 | int ret = 0; |
129 | 131 | ||
130 | req->request.actual = 0; | 132 | req->request.actual = 0; |
@@ -143,9 +145,7 @@ static int __dwc3_gadget_ep0_queue(struct dwc3_ep *dep, | |||
143 | * IRQ we were waiting for is long gone. | 145 | * IRQ we were waiting for is long gone. |
144 | */ | 146 | */ |
145 | if (dep->flags & DWC3_EP_PENDING_REQUEST) { | 147 | if (dep->flags & DWC3_EP_PENDING_REQUEST) { |
146 | struct dwc3 *dwc = dep->dwc; | ||
147 | unsigned direction; | 148 | unsigned direction; |
148 | u32 type; | ||
149 | 149 | ||
150 | direction = !!(dep->flags & DWC3_EP0_DIR_IN); | 150 | direction = !!(dep->flags & DWC3_EP0_DIR_IN); |
151 | 151 | ||
@@ -165,6 +165,13 @@ static int __dwc3_gadget_ep0_queue(struct dwc3_ep *dep, | |||
165 | req->request.dma, req->request.length, type); | 165 | req->request.dma, req->request.length, type); |
166 | dep->flags &= ~(DWC3_EP_PENDING_REQUEST | | 166 | dep->flags &= ~(DWC3_EP_PENDING_REQUEST | |
167 | DWC3_EP0_DIR_IN); | 167 | DWC3_EP0_DIR_IN); |
168 | } else if (dwc->delayed_status) { | ||
169 | dwc->delayed_status = false; | ||
170 | |||
171 | if (dwc->ep0state == EP0_STATUS_PHASE) | ||
172 | dwc3_ep0_do_control_status(dwc, 1); | ||
173 | else | ||
174 | dev_dbg(dwc->dev, "too early for delayed status\n"); | ||
168 | } | 175 | } |
169 | 176 | ||
170 | return ret; | 177 | return ret; |
@@ -190,9 +197,7 @@ int dwc3_gadget_ep0_queue(struct usb_ep *ep, struct usb_request *request, | |||
190 | } | 197 | } |
191 | 198 | ||
192 | /* we share one TRB for ep0/1 */ | 199 | /* we share one TRB for ep0/1 */ |
193 | if (!list_empty(&dwc->eps[0]->request_list) || | 200 | if (!list_empty(&dep->request_list)) { |
194 | !list_empty(&dwc->eps[1]->request_list) || | ||
195 | dwc->ep0_status_pending) { | ||
196 | ret = -EBUSY; | 201 | ret = -EBUSY; |
197 | goto out; | 202 | goto out; |
198 | } | 203 | } |
@@ -214,8 +219,9 @@ static void dwc3_ep0_stall_and_restart(struct dwc3 *dwc) | |||
214 | struct dwc3_ep *dep = dwc->eps[0]; | 219 | struct dwc3_ep *dep = dwc->eps[0]; |
215 | 220 | ||
216 | /* stall is always issued on EP0 */ | 221 | /* stall is always issued on EP0 */ |
217 | __dwc3_gadget_ep_set_halt(dwc->eps[0], 1); | 222 | __dwc3_gadget_ep_set_halt(dep, 1); |
218 | dwc->eps[0]->flags = DWC3_EP_ENABLED; | 223 | dep->flags = DWC3_EP_ENABLED; |
224 | dwc->delayed_status = false; | ||
219 | 225 | ||
220 | if (!list_empty(&dep->request_list)) { | 226 | if (!list_empty(&dep->request_list)) { |
221 | struct dwc3_request *req; | 227 | struct dwc3_request *req; |
@@ -254,17 +260,14 @@ static struct dwc3_ep *dwc3_wIndex_to_dep(struct dwc3 *dwc, __le16 wIndex_le) | |||
254 | return NULL; | 260 | return NULL; |
255 | } | 261 | } |
256 | 262 | ||
257 | static void dwc3_ep0_send_status_response(struct dwc3 *dwc) | 263 | static void dwc3_ep0_status_cmpl(struct usb_ep *ep, struct usb_request *req) |
258 | { | 264 | { |
259 | dwc3_ep0_start_trans(dwc, 1, dwc->setup_buf_addr, | ||
260 | dwc->ep0_usb_req.length, | ||
261 | DWC3_TRBCTL_CONTROL_DATA); | ||
262 | } | 265 | } |
263 | |||
264 | /* | 266 | /* |
265 | * ch 9.4.5 | 267 | * ch 9.4.5 |
266 | */ | 268 | */ |
267 | static int dwc3_ep0_handle_status(struct dwc3 *dwc, struct usb_ctrlrequest *ctrl) | 269 | static int dwc3_ep0_handle_status(struct dwc3 *dwc, |
270 | struct usb_ctrlrequest *ctrl) | ||
268 | { | 271 | { |
269 | struct dwc3_ep *dep; | 272 | struct dwc3_ep *dep; |
270 | u32 recip; | 273 | u32 recip; |
@@ -291,7 +294,7 @@ static int dwc3_ep0_handle_status(struct dwc3 *dwc, struct usb_ctrlrequest *ctrl | |||
291 | case USB_RECIP_ENDPOINT: | 294 | case USB_RECIP_ENDPOINT: |
292 | dep = dwc3_wIndex_to_dep(dwc, ctrl->wIndex); | 295 | dep = dwc3_wIndex_to_dep(dwc, ctrl->wIndex); |
293 | if (!dep) | 296 | if (!dep) |
294 | return -EINVAL; | 297 | return -EINVAL; |
295 | 298 | ||
296 | if (dep->flags & DWC3_EP_STALL) | 299 | if (dep->flags & DWC3_EP_STALL) |
297 | usb_status = 1 << USB_ENDPOINT_HALT; | 300 | usb_status = 1 << USB_ENDPOINT_HALT; |
@@ -302,10 +305,14 @@ static int dwc3_ep0_handle_status(struct dwc3 *dwc, struct usb_ctrlrequest *ctrl | |||
302 | 305 | ||
303 | response_pkt = (__le16 *) dwc->setup_buf; | 306 | response_pkt = (__le16 *) dwc->setup_buf; |
304 | *response_pkt = cpu_to_le16(usb_status); | 307 | *response_pkt = cpu_to_le16(usb_status); |
305 | dwc->ep0_usb_req.length = sizeof(*response_pkt); | ||
306 | dwc->ep0_status_pending = 1; | ||
307 | 308 | ||
308 | return 0; | 309 | dep = dwc->eps[0]; |
310 | dwc->ep0_usb_req.dep = dep; | ||
311 | dwc->ep0_usb_req.request.length = sizeof(*response_pkt); | ||
312 | dwc->ep0_usb_req.request.dma = dwc->setup_buf_addr; | ||
313 | dwc->ep0_usb_req.request.complete = dwc3_ep0_status_cmpl; | ||
314 | |||
315 | return __dwc3_gadget_ep0_queue(dep, &dwc->ep0_usb_req); | ||
309 | } | 316 | } |
310 | 317 | ||
311 | static int dwc3_ep0_handle_feature(struct dwc3 *dwc, | 318 | static int dwc3_ep0_handle_feature(struct dwc3 *dwc, |
@@ -396,8 +403,7 @@ static int dwc3_ep0_handle_feature(struct dwc3 *dwc, | |||
396 | case USB_RECIP_ENDPOINT: | 403 | case USB_RECIP_ENDPOINT: |
397 | switch (wValue) { | 404 | switch (wValue) { |
398 | case USB_ENDPOINT_HALT: | 405 | case USB_ENDPOINT_HALT: |
399 | 406 | dep = dwc3_wIndex_to_dep(dwc, wIndex); | |
400 | dep = dwc3_wIndex_to_dep(dwc, ctrl->wIndex); | ||
401 | if (!dep) | 407 | if (!dep) |
402 | return -EINVAL; | 408 | return -EINVAL; |
403 | ret = __dwc3_gadget_ep_set_halt(dep, set); | 409 | ret = __dwc3_gadget_ep_set_halt(dep, set); |
@@ -422,8 +428,15 @@ static int dwc3_ep0_set_address(struct dwc3 *dwc, struct usb_ctrlrequest *ctrl) | |||
422 | u32 reg; | 428 | u32 reg; |
423 | 429 | ||
424 | addr = le16_to_cpu(ctrl->wValue); | 430 | addr = le16_to_cpu(ctrl->wValue); |
425 | if (addr > 127) | 431 | if (addr > 127) { |
432 | dev_dbg(dwc->dev, "invalid device address %d\n", addr); | ||
426 | return -EINVAL; | 433 | return -EINVAL; |
434 | } | ||
435 | |||
436 | if (dwc->dev_state == DWC3_CONFIGURED_STATE) { | ||
437 | dev_dbg(dwc->dev, "trying to set address when configured\n"); | ||
438 | return -EINVAL; | ||
439 | } | ||
427 | 440 | ||
428 | reg = dwc3_readl(dwc->regs, DWC3_DCFG); | 441 | reg = dwc3_readl(dwc->regs, DWC3_DCFG); |
429 | reg &= ~(DWC3_DCFG_DEVADDR_MASK); | 442 | reg &= ~(DWC3_DCFG_DEVADDR_MASK); |
@@ -473,8 +486,10 @@ static int dwc3_ep0_set_config(struct dwc3 *dwc, struct usb_ctrlrequest *ctrl) | |||
473 | if (!cfg) | 486 | if (!cfg) |
474 | dwc->dev_state = DWC3_ADDRESS_STATE; | 487 | dwc->dev_state = DWC3_ADDRESS_STATE; |
475 | break; | 488 | break; |
489 | default: | ||
490 | ret = -EINVAL; | ||
476 | } | 491 | } |
477 | return 0; | 492 | return ret; |
478 | } | 493 | } |
479 | 494 | ||
480 | static int dwc3_ep0_std_request(struct dwc3 *dwc, struct usb_ctrlrequest *ctrl) | 495 | static int dwc3_ep0_std_request(struct dwc3 *dwc, struct usb_ctrlrequest *ctrl) |
@@ -537,6 +552,9 @@ static void dwc3_ep0_inspect_setup(struct dwc3 *dwc, | |||
537 | else | 552 | else |
538 | ret = dwc3_ep0_delegate_req(dwc, ctrl); | 553 | ret = dwc3_ep0_delegate_req(dwc, ctrl); |
539 | 554 | ||
555 | if (ret == USB_GADGET_DELAYED_STATUS) | ||
556 | dwc->delayed_status = true; | ||
557 | |||
540 | if (ret >= 0) | 558 | if (ret >= 0) |
541 | return; | 559 | return; |
542 | 560 | ||
@@ -550,27 +568,21 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc, | |||
550 | struct dwc3_request *r = NULL; | 568 | struct dwc3_request *r = NULL; |
551 | struct usb_request *ur; | 569 | struct usb_request *ur; |
552 | struct dwc3_trb trb; | 570 | struct dwc3_trb trb; |
553 | struct dwc3_ep *dep; | 571 | struct dwc3_ep *ep0; |
554 | u32 transferred; | 572 | u32 transferred; |
555 | u8 epnum; | 573 | u8 epnum; |
556 | 574 | ||
557 | epnum = event->endpoint_number; | 575 | epnum = event->endpoint_number; |
558 | dep = dwc->eps[epnum]; | 576 | ep0 = dwc->eps[0]; |
559 | 577 | ||
560 | dwc->ep0_next_event = DWC3_EP0_NRDY_STATUS; | 578 | dwc->ep0_next_event = DWC3_EP0_NRDY_STATUS; |
561 | 579 | ||
562 | if (!dwc->ep0_status_pending) { | 580 | r = next_request(&ep0->request_list); |
563 | r = next_request(&dwc->eps[0]->request_list); | 581 | ur = &r->request; |
564 | ur = &r->request; | ||
565 | } else { | ||
566 | ur = &dwc->ep0_usb_req; | ||
567 | dwc->ep0_status_pending = 0; | ||
568 | } | ||
569 | 582 | ||
570 | dwc3_trb_to_nat(dwc->ep0_trb, &trb); | 583 | dwc3_trb_to_nat(dwc->ep0_trb, &trb); |
571 | 584 | ||
572 | if (dwc->ep0_bounced) { | 585 | if (dwc->ep0_bounced) { |
573 | struct dwc3_ep *ep0 = dwc->eps[0]; | ||
574 | 586 | ||
575 | transferred = min_t(u32, ur->length, | 587 | transferred = min_t(u32, ur->length, |
576 | ep0->endpoint.maxpacket - trb.length); | 588 | ep0->endpoint.maxpacket - trb.length); |
@@ -591,7 +603,7 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc, | |||
591 | * seems to be case when req.length > maxpacket. Could it be? | 603 | * seems to be case when req.length > maxpacket. Could it be? |
592 | */ | 604 | */ |
593 | if (r) | 605 | if (r) |
594 | dwc3_gadget_giveback(dep, r, 0); | 606 | dwc3_gadget_giveback(ep0, r, 0); |
595 | } | 607 | } |
596 | } | 608 | } |
597 | 609 | ||
@@ -619,6 +631,7 @@ static void dwc3_ep0_xfer_complete(struct dwc3 *dwc, | |||
619 | struct dwc3_ep *dep = dwc->eps[event->endpoint_number]; | 631 | struct dwc3_ep *dep = dwc->eps[event->endpoint_number]; |
620 | 632 | ||
621 | dep->flags &= ~DWC3_EP_BUSY; | 633 | dep->flags &= ~DWC3_EP_BUSY; |
634 | dwc->setup_packet_pending = false; | ||
622 | 635 | ||
623 | switch (dwc->ep0state) { | 636 | switch (dwc->ep0state) { |
624 | case EP0_SETUP_PHASE: | 637 | case EP0_SETUP_PHASE: |
@@ -643,7 +656,6 @@ static void dwc3_ep0_xfer_complete(struct dwc3 *dwc, | |||
643 | static void dwc3_ep0_do_control_setup(struct dwc3 *dwc, | 656 | static void dwc3_ep0_do_control_setup(struct dwc3 *dwc, |
644 | const struct dwc3_event_depevt *event) | 657 | const struct dwc3_event_depevt *event) |
645 | { | 658 | { |
646 | dwc->ep0state = EP0_SETUP_PHASE; | ||
647 | dwc3_ep0_out_start(dwc); | 659 | dwc3_ep0_out_start(dwc); |
648 | } | 660 | } |
649 | 661 | ||
@@ -655,12 +667,6 @@ static void dwc3_ep0_do_control_data(struct dwc3 *dwc, | |||
655 | int ret; | 667 | int ret; |
656 | 668 | ||
657 | dep = dwc->eps[0]; | 669 | dep = dwc->eps[0]; |
658 | dwc->ep0state = EP0_DATA_PHASE; | ||
659 | |||
660 | if (dwc->ep0_status_pending) { | ||
661 | dwc3_ep0_send_status_response(dwc); | ||
662 | return; | ||
663 | } | ||
664 | 670 | ||
665 | if (list_empty(&dep->request_list)) { | 671 | if (list_empty(&dep->request_list)) { |
666 | dev_vdbg(dwc->dev, "pending request for EP0 Data phase\n"); | 672 | dev_vdbg(dwc->dev, "pending request for EP0 Data phase\n"); |
@@ -674,7 +680,6 @@ static void dwc3_ep0_do_control_data(struct dwc3 *dwc, | |||
674 | req = next_request(&dep->request_list); | 680 | req = next_request(&dep->request_list); |
675 | req->direction = !!event->endpoint_number; | 681 | req->direction = !!event->endpoint_number; |
676 | 682 | ||
677 | dwc->ep0state = EP0_DATA_PHASE; | ||
678 | if (req->request.length == 0) { | 683 | if (req->request.length == 0) { |
679 | ret = dwc3_ep0_start_trans(dwc, event->endpoint_number, | 684 | ret = dwc3_ep0_start_trans(dwc, event->endpoint_number, |
680 | dwc->ctrl_req_addr, 0, | 685 | dwc->ctrl_req_addr, 0, |
@@ -706,35 +711,79 @@ static void dwc3_ep0_do_control_data(struct dwc3 *dwc, | |||
706 | WARN_ON(ret < 0); | 711 | WARN_ON(ret < 0); |
707 | } | 712 | } |
708 | 713 | ||
709 | static void dwc3_ep0_do_control_status(struct dwc3 *dwc, | 714 | static int dwc3_ep0_start_control_status(struct dwc3_ep *dep) |
710 | const struct dwc3_event_depevt *event) | ||
711 | { | 715 | { |
716 | struct dwc3 *dwc = dep->dwc; | ||
712 | u32 type; | 717 | u32 type; |
713 | int ret; | ||
714 | |||
715 | dwc->ep0state = EP0_STATUS_PHASE; | ||
716 | 718 | ||
717 | type = dwc->three_stage_setup ? DWC3_TRBCTL_CONTROL_STATUS3 | 719 | type = dwc->three_stage_setup ? DWC3_TRBCTL_CONTROL_STATUS3 |
718 | : DWC3_TRBCTL_CONTROL_STATUS2; | 720 | : DWC3_TRBCTL_CONTROL_STATUS2; |
719 | 721 | ||
720 | ret = dwc3_ep0_start_trans(dwc, event->endpoint_number, | 722 | return dwc3_ep0_start_trans(dwc, dep->number, |
721 | dwc->ctrl_req_addr, 0, type); | 723 | dwc->ctrl_req_addr, 0, type); |
724 | } | ||
722 | 725 | ||
723 | WARN_ON(ret < 0); | 726 | static void dwc3_ep0_do_control_status(struct dwc3 *dwc, u32 epnum) |
727 | { | ||
728 | struct dwc3_ep *dep = dwc->eps[epnum]; | ||
729 | |||
730 | WARN_ON(dwc3_ep0_start_control_status(dep)); | ||
724 | } | 731 | } |
725 | 732 | ||
726 | static void dwc3_ep0_xfernotready(struct dwc3 *dwc, | 733 | static void dwc3_ep0_xfernotready(struct dwc3 *dwc, |
727 | const struct dwc3_event_depevt *event) | 734 | const struct dwc3_event_depevt *event) |
728 | { | 735 | { |
736 | dwc->setup_packet_pending = true; | ||
737 | |||
738 | /* | ||
739 | * This part is very tricky: If we has just handled | ||
740 | * XferNotReady(Setup) and we're now expecting a | ||
741 | * XferComplete but, instead, we receive another | ||
742 | * XferNotReady(Setup), we should STALL and restart | ||
743 | * the state machine. | ||
744 | * | ||
745 | * In all other cases, we just continue waiting | ||
746 | * for the XferComplete event. | ||
747 | * | ||
748 | * We are a little bit unsafe here because we're | ||
749 | * not trying to ensure that last event was, indeed, | ||
750 | * XferNotReady(Setup). | ||
751 | * | ||
752 | * Still, we don't expect any condition where that | ||
753 | * should happen and, even if it does, it would be | ||
754 | * another error condition. | ||
755 | */ | ||
756 | if (dwc->ep0_next_event == DWC3_EP0_COMPLETE) { | ||
757 | switch (event->status) { | ||
758 | case DEPEVT_STATUS_CONTROL_SETUP: | ||
759 | dev_vdbg(dwc->dev, "Unexpected XferNotReady(Setup)\n"); | ||
760 | dwc3_ep0_stall_and_restart(dwc); | ||
761 | break; | ||
762 | case DEPEVT_STATUS_CONTROL_DATA: | ||
763 | /* FALLTHROUGH */ | ||
764 | case DEPEVT_STATUS_CONTROL_STATUS: | ||
765 | /* FALLTHROUGH */ | ||
766 | default: | ||
767 | dev_vdbg(dwc->dev, "waiting for XferComplete\n"); | ||
768 | } | ||
769 | |||
770 | return; | ||
771 | } | ||
772 | |||
729 | switch (event->status) { | 773 | switch (event->status) { |
730 | case DEPEVT_STATUS_CONTROL_SETUP: | 774 | case DEPEVT_STATUS_CONTROL_SETUP: |
731 | dev_vdbg(dwc->dev, "Control Setup\n"); | 775 | dev_vdbg(dwc->dev, "Control Setup\n"); |
776 | |||
777 | dwc->ep0state = EP0_SETUP_PHASE; | ||
778 | |||
732 | dwc3_ep0_do_control_setup(dwc, event); | 779 | dwc3_ep0_do_control_setup(dwc, event); |
733 | break; | 780 | break; |
734 | 781 | ||
735 | case DEPEVT_STATUS_CONTROL_DATA: | 782 | case DEPEVT_STATUS_CONTROL_DATA: |
736 | dev_vdbg(dwc->dev, "Control Data\n"); | 783 | dev_vdbg(dwc->dev, "Control Data\n"); |
737 | 784 | ||
785 | dwc->ep0state = EP0_DATA_PHASE; | ||
786 | |||
738 | if (dwc->ep0_next_event != DWC3_EP0_NRDY_DATA) { | 787 | if (dwc->ep0_next_event != DWC3_EP0_NRDY_DATA) { |
739 | dev_vdbg(dwc->dev, "Expected %d got %d\n", | 788 | dev_vdbg(dwc->dev, "Expected %d got %d\n", |
740 | dwc->ep0_next_event, | 789 | dwc->ep0_next_event, |
@@ -764,6 +813,8 @@ static void dwc3_ep0_xfernotready(struct dwc3 *dwc, | |||
764 | case DEPEVT_STATUS_CONTROL_STATUS: | 813 | case DEPEVT_STATUS_CONTROL_STATUS: |
765 | dev_vdbg(dwc->dev, "Control Status\n"); | 814 | dev_vdbg(dwc->dev, "Control Status\n"); |
766 | 815 | ||
816 | dwc->ep0state = EP0_STATUS_PHASE; | ||
817 | |||
767 | if (dwc->ep0_next_event != DWC3_EP0_NRDY_STATUS) { | 818 | if (dwc->ep0_next_event != DWC3_EP0_NRDY_STATUS) { |
768 | dev_vdbg(dwc->dev, "Expected %d got %d\n", | 819 | dev_vdbg(dwc->dev, "Expected %d got %d\n", |
769 | dwc->ep0_next_event, | 820 | dwc->ep0_next_event, |
@@ -772,12 +823,19 @@ static void dwc3_ep0_xfernotready(struct dwc3 *dwc, | |||
772 | dwc3_ep0_stall_and_restart(dwc); | 823 | dwc3_ep0_stall_and_restart(dwc); |
773 | return; | 824 | return; |
774 | } | 825 | } |
775 | dwc3_ep0_do_control_status(dwc, event); | 826 | |
827 | if (dwc->delayed_status) { | ||
828 | WARN_ON_ONCE(event->endpoint_number != 1); | ||
829 | dev_vdbg(dwc->dev, "Mass Storage delayed status\n"); | ||
830 | return; | ||
831 | } | ||
832 | |||
833 | dwc3_ep0_do_control_status(dwc, event->endpoint_number); | ||
776 | } | 834 | } |
777 | } | 835 | } |
778 | 836 | ||
779 | void dwc3_ep0_interrupt(struct dwc3 *dwc, | 837 | void dwc3_ep0_interrupt(struct dwc3 *dwc, |
780 | const const struct dwc3_event_depevt *event) | 838 | const struct dwc3_event_depevt *event) |
781 | { | 839 | { |
782 | u8 epnum = event->endpoint_number; | 840 | u8 epnum = event->endpoint_number; |
783 | 841 | ||
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index fa824cfdd2eb..a696bde53222 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c | |||
@@ -65,6 +65,22 @@ void dwc3_map_buffer_to_dma(struct dwc3_request *req) | |||
65 | return; | 65 | return; |
66 | } | 66 | } |
67 | 67 | ||
68 | if (req->request.num_sgs) { | ||
69 | int mapped; | ||
70 | |||
71 | mapped = dma_map_sg(dwc->dev, req->request.sg, | ||
72 | req->request.num_sgs, | ||
73 | req->direction ? DMA_TO_DEVICE | ||
74 | : DMA_FROM_DEVICE); | ||
75 | if (mapped < 0) { | ||
76 | dev_err(dwc->dev, "failed to map SGs\n"); | ||
77 | return; | ||
78 | } | ||
79 | |||
80 | req->request.num_mapped_sgs = mapped; | ||
81 | return; | ||
82 | } | ||
83 | |||
68 | if (req->request.dma == DMA_ADDR_INVALID) { | 84 | if (req->request.dma == DMA_ADDR_INVALID) { |
69 | req->request.dma = dma_map_single(dwc->dev, req->request.buf, | 85 | req->request.dma = dma_map_single(dwc->dev, req->request.buf, |
70 | req->request.length, req->direction | 86 | req->request.length, req->direction |
@@ -82,6 +98,17 @@ void dwc3_unmap_buffer_from_dma(struct dwc3_request *req) | |||
82 | return; | 98 | return; |
83 | } | 99 | } |
84 | 100 | ||
101 | if (req->request.num_mapped_sgs) { | ||
102 | req->request.dma = DMA_ADDR_INVALID; | ||
103 | dma_unmap_sg(dwc->dev, req->request.sg, | ||
104 | req->request.num_sgs, | ||
105 | req->direction ? DMA_TO_DEVICE | ||
106 | : DMA_FROM_DEVICE); | ||
107 | |||
108 | req->request.num_mapped_sgs = 0; | ||
109 | return; | ||
110 | } | ||
111 | |||
85 | if (req->mapped) { | 112 | if (req->mapped) { |
86 | dma_unmap_single(dwc->dev, req->request.dma, | 113 | dma_unmap_single(dwc->dev, req->request.dma, |
87 | req->request.length, req->direction | 114 | req->request.length, req->direction |
@@ -97,7 +124,11 @@ void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req, | |||
97 | struct dwc3 *dwc = dep->dwc; | 124 | struct dwc3 *dwc = dep->dwc; |
98 | 125 | ||
99 | if (req->queued) { | 126 | if (req->queued) { |
100 | dep->busy_slot++; | 127 | if (req->request.num_mapped_sgs) |
128 | dep->busy_slot += req->request.num_mapped_sgs; | ||
129 | else | ||
130 | dep->busy_slot++; | ||
131 | |||
101 | /* | 132 | /* |
102 | * Skip LINK TRB. We can't use req->trb and check for | 133 | * Skip LINK TRB. We can't use req->trb and check for |
103 | * DWC3_TRBCTL_LINK_TRB because it points the TRB we just | 134 | * DWC3_TRBCTL_LINK_TRB because it points the TRB we just |
@@ -108,6 +139,7 @@ void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req, | |||
108 | dep->busy_slot++; | 139 | dep->busy_slot++; |
109 | } | 140 | } |
110 | list_del(&req->list); | 141 | list_del(&req->list); |
142 | req->trb = NULL; | ||
111 | 143 | ||
112 | if (req->request.status == -EINPROGRESS) | 144 | if (req->request.status == -EINPROGRESS) |
113 | req->request.status = status; | 145 | req->request.status = status; |
@@ -251,7 +283,8 @@ static int dwc3_gadget_start_config(struct dwc3 *dwc, struct dwc3_ep *dep) | |||
251 | } | 283 | } |
252 | 284 | ||
253 | static int dwc3_gadget_set_ep_config(struct dwc3 *dwc, struct dwc3_ep *dep, | 285 | static int dwc3_gadget_set_ep_config(struct dwc3 *dwc, struct dwc3_ep *dep, |
254 | const struct usb_endpoint_descriptor *desc) | 286 | const struct usb_endpoint_descriptor *desc, |
287 | const struct usb_ss_ep_comp_descriptor *comp_desc) | ||
255 | { | 288 | { |
256 | struct dwc3_gadget_ep_cmd_params params; | 289 | struct dwc3_gadget_ep_cmd_params params; |
257 | 290 | ||
@@ -264,7 +297,7 @@ static int dwc3_gadget_set_ep_config(struct dwc3 *dwc, struct dwc3_ep *dep, | |||
264 | params.param1 = DWC3_DEPCFG_XFER_COMPLETE_EN | 297 | params.param1 = DWC3_DEPCFG_XFER_COMPLETE_EN |
265 | | DWC3_DEPCFG_XFER_NOT_READY_EN; | 298 | | DWC3_DEPCFG_XFER_NOT_READY_EN; |
266 | 299 | ||
267 | if (usb_endpoint_xfer_bulk(desc) && dep->endpoint.max_streams) { | 300 | if (usb_ss_max_streams(comp_desc) && usb_endpoint_xfer_bulk(desc)) { |
268 | params.param1 |= DWC3_DEPCFG_STREAM_CAPABLE | 301 | params.param1 |= DWC3_DEPCFG_STREAM_CAPABLE |
269 | | DWC3_DEPCFG_STREAM_EVENT_EN; | 302 | | DWC3_DEPCFG_STREAM_EVENT_EN; |
270 | dep->stream_capable = true; | 303 | dep->stream_capable = true; |
@@ -317,7 +350,8 @@ static int dwc3_gadget_set_xfer_resource(struct dwc3 *dwc, struct dwc3_ep *dep) | |||
317 | * Caller should take care of locking | 350 | * Caller should take care of locking |
318 | */ | 351 | */ |
319 | static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep, | 352 | static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep, |
320 | const struct usb_endpoint_descriptor *desc) | 353 | const struct usb_endpoint_descriptor *desc, |
354 | const struct usb_ss_ep_comp_descriptor *comp_desc) | ||
321 | { | 355 | { |
322 | struct dwc3 *dwc = dep->dwc; | 356 | struct dwc3 *dwc = dep->dwc; |
323 | u32 reg; | 357 | u32 reg; |
@@ -329,7 +363,7 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep, | |||
329 | return ret; | 363 | return ret; |
330 | } | 364 | } |
331 | 365 | ||
332 | ret = dwc3_gadget_set_ep_config(dwc, dep, desc); | 366 | ret = dwc3_gadget_set_ep_config(dwc, dep, desc, comp_desc); |
333 | if (ret) | 367 | if (ret) |
334 | return ret; | 368 | return ret; |
335 | 369 | ||
@@ -343,6 +377,7 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep, | |||
343 | return ret; | 377 | return ret; |
344 | 378 | ||
345 | dep->desc = desc; | 379 | dep->desc = desc; |
380 | dep->comp_desc = comp_desc; | ||
346 | dep->type = usb_endpoint_type(desc); | 381 | dep->type = usb_endpoint_type(desc); |
347 | dep->flags |= DWC3_EP_ENABLED; | 382 | dep->flags |= DWC3_EP_ENABLED; |
348 | 383 | ||
@@ -405,6 +440,7 @@ static int __dwc3_gadget_ep_disable(struct dwc3_ep *dep) | |||
405 | 440 | ||
406 | dep->stream_capable = false; | 441 | dep->stream_capable = false; |
407 | dep->desc = NULL; | 442 | dep->desc = NULL; |
443 | dep->comp_desc = NULL; | ||
408 | dep->type = 0; | 444 | dep->type = 0; |
409 | dep->flags = 0; | 445 | dep->flags = 0; |
410 | 446 | ||
@@ -473,7 +509,7 @@ static int dwc3_gadget_ep_enable(struct usb_ep *ep, | |||
473 | dev_vdbg(dwc->dev, "Enabling %s\n", dep->name); | 509 | dev_vdbg(dwc->dev, "Enabling %s\n", dep->name); |
474 | 510 | ||
475 | spin_lock_irqsave(&dwc->lock, flags); | 511 | spin_lock_irqsave(&dwc->lock, flags); |
476 | ret = __dwc3_gadget_ep_enable(dep, desc); | 512 | ret = __dwc3_gadget_ep_enable(dep, desc, ep->comp_desc); |
477 | spin_unlock_irqrestore(&dwc->lock, flags); | 513 | spin_unlock_irqrestore(&dwc->lock, flags); |
478 | 514 | ||
479 | return ret; | 515 | return ret; |
@@ -539,6 +575,85 @@ static void dwc3_gadget_ep_free_request(struct usb_ep *ep, | |||
539 | kfree(req); | 575 | kfree(req); |
540 | } | 576 | } |
541 | 577 | ||
578 | /** | ||
579 | * dwc3_prepare_one_trb - setup one TRB from one request | ||
580 | * @dep: endpoint for which this request is prepared | ||
581 | * @req: dwc3_request pointer | ||
582 | */ | ||
583 | static void dwc3_prepare_one_trb(struct dwc3_ep *dep, | ||
584 | struct dwc3_request *req, dma_addr_t dma, | ||
585 | unsigned length, unsigned last, unsigned chain) | ||
586 | { | ||
587 | struct dwc3 *dwc = dep->dwc; | ||
588 | struct dwc3_trb_hw *trb_hw; | ||
589 | struct dwc3_trb trb; | ||
590 | |||
591 | unsigned int cur_slot; | ||
592 | |||
593 | dev_vdbg(dwc->dev, "%s: req %p dma %08llx length %d%s%s\n", | ||
594 | dep->name, req, (unsigned long long) dma, | ||
595 | length, last ? " last" : "", | ||
596 | chain ? " chain" : ""); | ||
597 | |||
598 | trb_hw = &dep->trb_pool[dep->free_slot & DWC3_TRB_MASK]; | ||
599 | cur_slot = dep->free_slot; | ||
600 | dep->free_slot++; | ||
601 | |||
602 | /* Skip the LINK-TRB on ISOC */ | ||
603 | if (((cur_slot & DWC3_TRB_MASK) == DWC3_TRB_NUM - 1) && | ||
604 | usb_endpoint_xfer_isoc(dep->desc)) | ||
605 | return; | ||
606 | |||
607 | memset(&trb, 0, sizeof(trb)); | ||
608 | if (!req->trb) { | ||
609 | dwc3_gadget_move_request_queued(req); | ||
610 | req->trb = trb_hw; | ||
611 | req->trb_dma = dwc3_trb_dma_offset(dep, trb_hw); | ||
612 | } | ||
613 | |||
614 | if (usb_endpoint_xfer_isoc(dep->desc)) { | ||
615 | trb.isp_imi = true; | ||
616 | trb.csp = true; | ||
617 | } else { | ||
618 | trb.chn = chain; | ||
619 | trb.lst = last; | ||
620 | } | ||
621 | |||
622 | if (usb_endpoint_xfer_bulk(dep->desc) && dep->stream_capable) | ||
623 | trb.sid_sofn = req->request.stream_id; | ||
624 | |||
625 | switch (usb_endpoint_type(dep->desc)) { | ||
626 | case USB_ENDPOINT_XFER_CONTROL: | ||
627 | trb.trbctl = DWC3_TRBCTL_CONTROL_SETUP; | ||
628 | break; | ||
629 | |||
630 | case USB_ENDPOINT_XFER_ISOC: | ||
631 | trb.trbctl = DWC3_TRBCTL_ISOCHRONOUS_FIRST; | ||
632 | |||
633 | /* IOC every DWC3_TRB_NUM / 4 so we can refill */ | ||
634 | if (!(cur_slot % (DWC3_TRB_NUM / 4))) | ||
635 | trb.ioc = last; | ||
636 | break; | ||
637 | |||
638 | case USB_ENDPOINT_XFER_BULK: | ||
639 | case USB_ENDPOINT_XFER_INT: | ||
640 | trb.trbctl = DWC3_TRBCTL_NORMAL; | ||
641 | break; | ||
642 | default: | ||
643 | /* | ||
644 | * This is only possible with faulty memory because we | ||
645 | * checked it already :) | ||
646 | */ | ||
647 | BUG(); | ||
648 | } | ||
649 | |||
650 | trb.length = length; | ||
651 | trb.bplh = dma; | ||
652 | trb.hwo = true; | ||
653 | |||
654 | dwc3_trb_to_hw(&trb, trb_hw); | ||
655 | } | ||
656 | |||
542 | /* | 657 | /* |
543 | * dwc3_prepare_trbs - setup TRBs from requests | 658 | * dwc3_prepare_trbs - setup TRBs from requests |
544 | * @dep: endpoint for which requests are being prepared | 659 | * @dep: endpoint for which requests are being prepared |
@@ -548,18 +663,17 @@ static void dwc3_gadget_ep_free_request(struct usb_ep *ep, | |||
548 | * transfers. The functions returns once there are not more TRBs available or | 663 | * transfers. The functions returns once there are not more TRBs available or |
549 | * it run out of requests. | 664 | * it run out of requests. |
550 | */ | 665 | */ |
551 | static struct dwc3_request *dwc3_prepare_trbs(struct dwc3_ep *dep, | 666 | static void dwc3_prepare_trbs(struct dwc3_ep *dep, bool starting) |
552 | bool starting) | ||
553 | { | 667 | { |
554 | struct dwc3_request *req, *n, *ret = NULL; | 668 | struct dwc3_request *req, *n; |
555 | struct dwc3_trb_hw *trb_hw; | ||
556 | struct dwc3_trb trb; | ||
557 | u32 trbs_left; | 669 | u32 trbs_left; |
670 | unsigned int last_one = 0; | ||
558 | 671 | ||
559 | BUILD_BUG_ON_NOT_POWER_OF_2(DWC3_TRB_NUM); | 672 | BUILD_BUG_ON_NOT_POWER_OF_2(DWC3_TRB_NUM); |
560 | 673 | ||
561 | /* the first request must not be queued */ | 674 | /* the first request must not be queued */ |
562 | trbs_left = (dep->busy_slot - dep->free_slot) & DWC3_TRB_MASK; | 675 | trbs_left = (dep->busy_slot - dep->free_slot) & DWC3_TRB_MASK; |
676 | |||
563 | /* | 677 | /* |
564 | * if busy & slot are equal than it is either full or empty. If we are | 678 | * if busy & slot are equal than it is either full or empty. If we are |
565 | * starting to proceed requests then we are empty. Otherwise we ar | 679 | * starting to proceed requests then we are empty. Otherwise we ar |
@@ -567,7 +681,7 @@ static struct dwc3_request *dwc3_prepare_trbs(struct dwc3_ep *dep, | |||
567 | */ | 681 | */ |
568 | if (!trbs_left) { | 682 | if (!trbs_left) { |
569 | if (!starting) | 683 | if (!starting) |
570 | return NULL; | 684 | return; |
571 | trbs_left = DWC3_TRB_NUM; | 685 | trbs_left = DWC3_TRB_NUM; |
572 | /* | 686 | /* |
573 | * In case we start from scratch, we queue the ISOC requests | 687 | * In case we start from scratch, we queue the ISOC requests |
@@ -591,94 +705,62 @@ static struct dwc3_request *dwc3_prepare_trbs(struct dwc3_ep *dep, | |||
591 | 705 | ||
592 | /* The last TRB is a link TRB, not used for xfer */ | 706 | /* The last TRB is a link TRB, not used for xfer */ |
593 | if ((trbs_left <= 1) && usb_endpoint_xfer_isoc(dep->desc)) | 707 | if ((trbs_left <= 1) && usb_endpoint_xfer_isoc(dep->desc)) |
594 | return NULL; | 708 | return; |
595 | 709 | ||
596 | list_for_each_entry_safe(req, n, &dep->request_list, list) { | 710 | list_for_each_entry_safe(req, n, &dep->request_list, list) { |
597 | unsigned int last_one = 0; | 711 | unsigned length; |
598 | unsigned int cur_slot; | 712 | dma_addr_t dma; |
599 | 713 | ||
600 | trb_hw = &dep->trb_pool[dep->free_slot & DWC3_TRB_MASK]; | 714 | if (req->request.num_mapped_sgs > 0) { |
601 | cur_slot = dep->free_slot; | 715 | struct usb_request *request = &req->request; |
602 | dep->free_slot++; | 716 | struct scatterlist *sg = request->sg; |
717 | struct scatterlist *s; | ||
718 | int i; | ||
603 | 719 | ||
604 | /* Skip the LINK-TRB on ISOC */ | 720 | for_each_sg(sg, s, request->num_mapped_sgs, i) { |
605 | if (((cur_slot & DWC3_TRB_MASK) == DWC3_TRB_NUM - 1) && | 721 | unsigned chain = true; |
606 | usb_endpoint_xfer_isoc(dep->desc)) | ||
607 | continue; | ||
608 | 722 | ||
609 | dwc3_gadget_move_request_queued(req); | 723 | length = sg_dma_len(s); |
610 | memset(&trb, 0, sizeof(trb)); | 724 | dma = sg_dma_address(s); |
611 | trbs_left--; | ||
612 | 725 | ||
613 | /* Is our TRB pool empty? */ | 726 | if (i == (request->num_mapped_sgs - 1) |
614 | if (!trbs_left) | 727 | || sg_is_last(s)) { |
615 | last_one = 1; | 728 | last_one = true; |
616 | /* Is this the last request? */ | 729 | chain = false; |
617 | if (list_empty(&dep->request_list)) | 730 | } |
618 | last_one = 1; | ||
619 | 731 | ||
620 | /* | 732 | trbs_left--; |
621 | * FIXME we shouldn't need to set LST bit always but we are | 733 | if (!trbs_left) |
622 | * facing some weird problem with the Hardware where it doesn't | 734 | last_one = true; |
623 | * complete even though it has been previously started. | ||
624 | * | ||
625 | * While we're debugging the problem, as a workaround to | ||
626 | * multiple TRBs handling, use only one TRB at a time. | ||
627 | */ | ||
628 | last_one = 1; | ||
629 | 735 | ||
630 | req->trb = trb_hw; | 736 | if (last_one) |
631 | if (!ret) | 737 | chain = false; |
632 | ret = req; | ||
633 | 738 | ||
634 | trb.bplh = req->request.dma; | 739 | dwc3_prepare_one_trb(dep, req, dma, length, |
740 | last_one, chain); | ||
635 | 741 | ||
636 | if (usb_endpoint_xfer_isoc(dep->desc)) { | 742 | if (last_one) |
637 | trb.isp_imi = true; | 743 | break; |
638 | trb.csp = true; | 744 | } |
639 | } else { | 745 | } else { |
640 | trb.lst = last_one; | 746 | dma = req->request.dma; |
641 | } | 747 | length = req->request.length; |
748 | trbs_left--; | ||
642 | 749 | ||
643 | if (usb_endpoint_xfer_bulk(dep->desc) && dep->stream_capable) | 750 | if (!trbs_left) |
644 | trb.sid_sofn = req->request.stream_id; | 751 | last_one = 1; |
645 | |||
646 | switch (usb_endpoint_type(dep->desc)) { | ||
647 | case USB_ENDPOINT_XFER_CONTROL: | ||
648 | trb.trbctl = DWC3_TRBCTL_CONTROL_SETUP; | ||
649 | break; | ||
650 | 752 | ||
651 | case USB_ENDPOINT_XFER_ISOC: | 753 | /* Is this the last request? */ |
652 | trb.trbctl = DWC3_TRBCTL_ISOCHRONOUS_FIRST; | 754 | if (list_is_last(&req->list, &dep->request_list)) |
755 | last_one = 1; | ||
653 | 756 | ||
654 | /* IOC every DWC3_TRB_NUM / 4 so we can refill */ | 757 | dwc3_prepare_one_trb(dep, req, dma, length, |
655 | if (!(cur_slot % (DWC3_TRB_NUM / 4))) | 758 | last_one, false); |
656 | trb.ioc = last_one; | ||
657 | break; | ||
658 | 759 | ||
659 | case USB_ENDPOINT_XFER_BULK: | 760 | if (last_one) |
660 | case USB_ENDPOINT_XFER_INT: | 761 | break; |
661 | trb.trbctl = DWC3_TRBCTL_NORMAL; | ||
662 | break; | ||
663 | default: | ||
664 | /* | ||
665 | * This is only possible with faulty memory because we | ||
666 | * checked it already :) | ||
667 | */ | ||
668 | BUG(); | ||
669 | } | 762 | } |
670 | |||
671 | trb.length = req->request.length; | ||
672 | trb.hwo = true; | ||
673 | |||
674 | dwc3_trb_to_hw(&trb, trb_hw); | ||
675 | req->trb_dma = dwc3_trb_dma_offset(dep, trb_hw); | ||
676 | |||
677 | if (last_one) | ||
678 | break; | ||
679 | } | 763 | } |
680 | |||
681 | return ret; | ||
682 | } | 764 | } |
683 | 765 | ||
684 | static int __dwc3_gadget_kick_transfer(struct dwc3_ep *dep, u16 cmd_param, | 766 | static int __dwc3_gadget_kick_transfer(struct dwc3_ep *dep, u16 cmd_param, |
@@ -707,11 +789,13 @@ static int __dwc3_gadget_kick_transfer(struct dwc3_ep *dep, u16 cmd_param, | |||
707 | /* req points to the first request which will be sent */ | 789 | /* req points to the first request which will be sent */ |
708 | req = next_request(&dep->req_queued); | 790 | req = next_request(&dep->req_queued); |
709 | } else { | 791 | } else { |
792 | dwc3_prepare_trbs(dep, start_new); | ||
793 | |||
710 | /* | 794 | /* |
711 | * req points to the first request where HWO changed | 795 | * req points to the first request where HWO changed |
712 | * from 0 to 1 | 796 | * from 0 to 1 |
713 | */ | 797 | */ |
714 | req = dwc3_prepare_trbs(dep, start_new); | 798 | req = next_request(&dep->req_queued); |
715 | } | 799 | } |
716 | if (!req) { | 800 | if (!req) { |
717 | dep->flags |= DWC3_EP_PENDING_REQUEST; | 801 | dep->flags |= DWC3_EP_PENDING_REQUEST; |
@@ -745,8 +829,9 @@ static int __dwc3_gadget_kick_transfer(struct dwc3_ep *dep, u16 cmd_param, | |||
745 | dep->flags |= DWC3_EP_BUSY; | 829 | dep->flags |= DWC3_EP_BUSY; |
746 | dep->res_trans_idx = dwc3_gadget_ep_get_transfer_index(dwc, | 830 | dep->res_trans_idx = dwc3_gadget_ep_get_transfer_index(dwc, |
747 | dep->number); | 831 | dep->number); |
748 | if (!dep->res_trans_idx) | 832 | |
749 | printk_once(KERN_ERR "%s() res_trans_idx is invalid\n", __func__); | 833 | WARN_ON_ONCE(!dep->res_trans_idx); |
834 | |||
750 | return 0; | 835 | return 0; |
751 | } | 836 | } |
752 | 837 | ||
@@ -1155,35 +1240,9 @@ static int dwc3_gadget_start(struct usb_gadget *g, | |||
1155 | dwc->gadget_driver = driver; | 1240 | dwc->gadget_driver = driver; |
1156 | dwc->gadget.dev.driver = &driver->driver; | 1241 | dwc->gadget.dev.driver = &driver->driver; |
1157 | 1242 | ||
1158 | reg = dwc3_readl(dwc->regs, DWC3_GCTL); | ||
1159 | |||
1160 | reg &= ~DWC3_GCTL_SCALEDOWN(3); | ||
1161 | reg &= ~DWC3_GCTL_PRTCAPDIR(DWC3_GCTL_PRTCAP_OTG); | ||
1162 | reg &= ~DWC3_GCTL_DISSCRAMBLE; | ||
1163 | reg |= DWC3_GCTL_PRTCAPDIR(DWC3_GCTL_PRTCAP_DEVICE); | ||
1164 | |||
1165 | switch (DWC3_GHWPARAMS1_EN_PWROPT(dwc->hwparams.hwparams0)) { | ||
1166 | case DWC3_GHWPARAMS1_EN_PWROPT_CLK: | ||
1167 | reg &= ~DWC3_GCTL_DSBLCLKGTNG; | ||
1168 | break; | ||
1169 | default: | ||
1170 | dev_dbg(dwc->dev, "No power optimization available\n"); | ||
1171 | } | ||
1172 | |||
1173 | /* | ||
1174 | * WORKAROUND: DWC3 revisions <1.90a have a bug | ||
1175 | * when The device fails to connect at SuperSpeed | ||
1176 | * and falls back to high-speed mode which causes | ||
1177 | * the device to enter in a Connect/Disconnect loop | ||
1178 | */ | ||
1179 | if (dwc->revision < DWC3_REVISION_190A) | ||
1180 | reg |= DWC3_GCTL_U2RSTECN; | ||
1181 | |||
1182 | dwc3_writel(dwc->regs, DWC3_GCTL, reg); | ||
1183 | |||
1184 | reg = dwc3_readl(dwc->regs, DWC3_DCFG); | 1243 | reg = dwc3_readl(dwc->regs, DWC3_DCFG); |
1185 | reg &= ~(DWC3_DCFG_SPEED_MASK); | 1244 | reg &= ~(DWC3_DCFG_SPEED_MASK); |
1186 | reg |= DWC3_DCFG_SUPERSPEED; | 1245 | reg |= dwc->maximum_speed; |
1187 | dwc3_writel(dwc->regs, DWC3_DCFG, reg); | 1246 | dwc3_writel(dwc->regs, DWC3_DCFG, reg); |
1188 | 1247 | ||
1189 | dwc->start_config_issued = false; | 1248 | dwc->start_config_issued = false; |
@@ -1192,14 +1251,14 @@ static int dwc3_gadget_start(struct usb_gadget *g, | |||
1192 | dwc3_gadget_ep0_desc.wMaxPacketSize = cpu_to_le16(512); | 1251 | dwc3_gadget_ep0_desc.wMaxPacketSize = cpu_to_le16(512); |
1193 | 1252 | ||
1194 | dep = dwc->eps[0]; | 1253 | dep = dwc->eps[0]; |
1195 | ret = __dwc3_gadget_ep_enable(dep, &dwc3_gadget_ep0_desc); | 1254 | ret = __dwc3_gadget_ep_enable(dep, &dwc3_gadget_ep0_desc, NULL); |
1196 | if (ret) { | 1255 | if (ret) { |
1197 | dev_err(dwc->dev, "failed to enable %s\n", dep->name); | 1256 | dev_err(dwc->dev, "failed to enable %s\n", dep->name); |
1198 | goto err0; | 1257 | goto err0; |
1199 | } | 1258 | } |
1200 | 1259 | ||
1201 | dep = dwc->eps[1]; | 1260 | dep = dwc->eps[1]; |
1202 | ret = __dwc3_gadget_ep_enable(dep, &dwc3_gadget_ep0_desc); | 1261 | ret = __dwc3_gadget_ep_enable(dep, &dwc3_gadget_ep0_desc, NULL); |
1203 | if (ret) { | 1262 | if (ret) { |
1204 | dev_err(dwc->dev, "failed to enable %s\n", dep->name); | 1263 | dev_err(dwc->dev, "failed to enable %s\n", dep->name); |
1205 | goto err1; | 1264 | goto err1; |
@@ -1284,16 +1343,16 @@ static int __devinit dwc3_gadget_init_endpoints(struct dwc3 *dwc) | |||
1284 | int ret; | 1343 | int ret; |
1285 | 1344 | ||
1286 | dep->endpoint.maxpacket = 1024; | 1345 | dep->endpoint.maxpacket = 1024; |
1346 | dep->endpoint.max_streams = 15; | ||
1287 | dep->endpoint.ops = &dwc3_gadget_ep_ops; | 1347 | dep->endpoint.ops = &dwc3_gadget_ep_ops; |
1288 | list_add_tail(&dep->endpoint.ep_list, | 1348 | list_add_tail(&dep->endpoint.ep_list, |
1289 | &dwc->gadget.ep_list); | 1349 | &dwc->gadget.ep_list); |
1290 | 1350 | ||
1291 | ret = dwc3_alloc_trb_pool(dep); | 1351 | ret = dwc3_alloc_trb_pool(dep); |
1292 | if (ret) { | 1352 | if (ret) |
1293 | dev_err(dwc->dev, "%s: failed to allocate TRB pool\n", dep->name); | ||
1294 | return ret; | 1353 | return ret; |
1295 | } | ||
1296 | } | 1354 | } |
1355 | |||
1297 | INIT_LIST_HEAD(&dep->request_list); | 1356 | INIT_LIST_HEAD(&dep->request_list); |
1298 | INIT_LIST_HEAD(&dep->req_queued); | 1357 | INIT_LIST_HEAD(&dep->req_queued); |
1299 | } | 1358 | } |
@@ -1333,8 +1392,10 @@ static int dwc3_cleanup_done_reqs(struct dwc3 *dwc, struct dwc3_ep *dep, | |||
1333 | 1392 | ||
1334 | do { | 1393 | do { |
1335 | req = next_request(&dep->req_queued); | 1394 | req = next_request(&dep->req_queued); |
1336 | if (!req) | 1395 | if (!req) { |
1337 | break; | 1396 | WARN_ON_ONCE(1); |
1397 | return 1; | ||
1398 | } | ||
1338 | 1399 | ||
1339 | dwc3_trb_to_nat(req->trb, &trb); | 1400 | dwc3_trb_to_nat(req->trb, &trb); |
1340 | 1401 | ||
@@ -1399,6 +1460,31 @@ static void dwc3_endpoint_transfer_complete(struct dwc3 *dwc, | |||
1399 | dep->flags &= ~DWC3_EP_BUSY; | 1460 | dep->flags &= ~DWC3_EP_BUSY; |
1400 | dep->res_trans_idx = 0; | 1461 | dep->res_trans_idx = 0; |
1401 | } | 1462 | } |
1463 | |||
1464 | /* | ||
1465 | * WORKAROUND: This is the 2nd half of U1/U2 -> U0 workaround. | ||
1466 | * See dwc3_gadget_linksts_change_interrupt() for 1st half. | ||
1467 | */ | ||
1468 | if (dwc->revision < DWC3_REVISION_183A) { | ||
1469 | u32 reg; | ||
1470 | int i; | ||
1471 | |||
1472 | for (i = 0; i < DWC3_ENDPOINTS_NUM; i++) { | ||
1473 | struct dwc3_ep *dep = dwc->eps[i]; | ||
1474 | |||
1475 | if (!(dep->flags & DWC3_EP_ENABLED)) | ||
1476 | continue; | ||
1477 | |||
1478 | if (!list_empty(&dep->req_queued)) | ||
1479 | return; | ||
1480 | } | ||
1481 | |||
1482 | reg = dwc3_readl(dwc->regs, DWC3_DCTL); | ||
1483 | reg |= dwc->u1u2; | ||
1484 | dwc3_writel(dwc->regs, DWC3_DCTL, reg); | ||
1485 | |||
1486 | dwc->u1u2 = 0; | ||
1487 | } | ||
1402 | } | 1488 | } |
1403 | 1489 | ||
1404 | static void dwc3_gadget_start_isoc(struct dwc3 *dwc, | 1490 | static void dwc3_gadget_start_isoc(struct dwc3 *dwc, |
@@ -1638,6 +1724,7 @@ static void dwc3_gadget_disconnect_interrupt(struct dwc3 *dwc) | |||
1638 | dwc->start_config_issued = false; | 1724 | dwc->start_config_issued = false; |
1639 | 1725 | ||
1640 | dwc->gadget.speed = USB_SPEED_UNKNOWN; | 1726 | dwc->gadget.speed = USB_SPEED_UNKNOWN; |
1727 | dwc->setup_packet_pending = false; | ||
1641 | } | 1728 | } |
1642 | 1729 | ||
1643 | static void dwc3_gadget_usb3_phy_power(struct dwc3 *dwc, int on) | 1730 | static void dwc3_gadget_usb3_phy_power(struct dwc3 *dwc, int on) |
@@ -1674,6 +1761,40 @@ static void dwc3_gadget_reset_interrupt(struct dwc3 *dwc) | |||
1674 | 1761 | ||
1675 | dev_vdbg(dwc->dev, "%s\n", __func__); | 1762 | dev_vdbg(dwc->dev, "%s\n", __func__); |
1676 | 1763 | ||
1764 | /* | ||
1765 | * WORKAROUND: DWC3 revisions <1.88a have an issue which | ||
1766 | * would cause a missing Disconnect Event if there's a | ||
1767 | * pending Setup Packet in the FIFO. | ||
1768 | * | ||
1769 | * There's no suggested workaround on the official Bug | ||
1770 | * report, which states that "unless the driver/application | ||
1771 | * is doing any special handling of a disconnect event, | ||
1772 | * there is no functional issue". | ||
1773 | * | ||
1774 | * Unfortunately, it turns out that we _do_ some special | ||
1775 | * handling of a disconnect event, namely complete all | ||
1776 | * pending transfers, notify gadget driver of the | ||
1777 | * disconnection, and so on. | ||
1778 | * | ||
1779 | * Our suggested workaround is to follow the Disconnect | ||
1780 | * Event steps here, instead, based on a setup_packet_pending | ||
1781 | * flag. Such flag gets set whenever we have a XferNotReady | ||
1782 | * event on EP0 and gets cleared on XferComplete for the | ||
1783 | * same endpoint. | ||
1784 | * | ||
1785 | * Refers to: | ||
1786 | * | ||
1787 | * STAR#9000466709: RTL: Device : Disconnect event not | ||
1788 | * generated if setup packet pending in FIFO | ||
1789 | */ | ||
1790 | if (dwc->revision < DWC3_REVISION_188A) { | ||
1791 | if (dwc->setup_packet_pending) | ||
1792 | dwc3_gadget_disconnect_interrupt(dwc); | ||
1793 | } | ||
1794 | |||
1795 | /* after reset -> Default State */ | ||
1796 | dwc->dev_state = DWC3_DEFAULT_STATE; | ||
1797 | |||
1677 | /* Enable PHYs */ | 1798 | /* Enable PHYs */ |
1678 | dwc3_gadget_usb2_phy_power(dwc, true); | 1799 | dwc3_gadget_usb2_phy_power(dwc, true); |
1679 | dwc3_gadget_usb3_phy_power(dwc, true); | 1800 | dwc3_gadget_usb3_phy_power(dwc, true); |
@@ -1754,6 +1875,22 @@ static void dwc3_gadget_conndone_interrupt(struct dwc3 *dwc) | |||
1754 | 1875 | ||
1755 | switch (speed) { | 1876 | switch (speed) { |
1756 | case DWC3_DCFG_SUPERSPEED: | 1877 | case DWC3_DCFG_SUPERSPEED: |
1878 | /* | ||
1879 | * WORKAROUND: DWC3 revisions <1.90a have an issue which | ||
1880 | * would cause a missing USB3 Reset event. | ||
1881 | * | ||
1882 | * In such situations, we should force a USB3 Reset | ||
1883 | * event by calling our dwc3_gadget_reset_interrupt() | ||
1884 | * routine. | ||
1885 | * | ||
1886 | * Refers to: | ||
1887 | * | ||
1888 | * STAR#9000483510: RTL: SS : USB3 reset event may | ||
1889 | * not be generated always when the link enters poll | ||
1890 | */ | ||
1891 | if (dwc->revision < DWC3_REVISION_190A) | ||
1892 | dwc3_gadget_reset_interrupt(dwc); | ||
1893 | |||
1757 | dwc3_gadget_ep0_desc.wMaxPacketSize = cpu_to_le16(512); | 1894 | dwc3_gadget_ep0_desc.wMaxPacketSize = cpu_to_le16(512); |
1758 | dwc->gadget.ep0->maxpacket = 512; | 1895 | dwc->gadget.ep0->maxpacket = 512; |
1759 | dwc->gadget.speed = USB_SPEED_SUPER; | 1896 | dwc->gadget.speed = USB_SPEED_SUPER; |
@@ -1780,14 +1917,14 @@ static void dwc3_gadget_conndone_interrupt(struct dwc3 *dwc) | |||
1780 | dwc3_gadget_disable_phy(dwc, dwc->gadget.speed); | 1917 | dwc3_gadget_disable_phy(dwc, dwc->gadget.speed); |
1781 | 1918 | ||
1782 | dep = dwc->eps[0]; | 1919 | dep = dwc->eps[0]; |
1783 | ret = __dwc3_gadget_ep_enable(dep, &dwc3_gadget_ep0_desc); | 1920 | ret = __dwc3_gadget_ep_enable(dep, &dwc3_gadget_ep0_desc, NULL); |
1784 | if (ret) { | 1921 | if (ret) { |
1785 | dev_err(dwc->dev, "failed to enable %s\n", dep->name); | 1922 | dev_err(dwc->dev, "failed to enable %s\n", dep->name); |
1786 | return; | 1923 | return; |
1787 | } | 1924 | } |
1788 | 1925 | ||
1789 | dep = dwc->eps[1]; | 1926 | dep = dwc->eps[1]; |
1790 | ret = __dwc3_gadget_ep_enable(dep, &dwc3_gadget_ep0_desc); | 1927 | ret = __dwc3_gadget_ep_enable(dep, &dwc3_gadget_ep0_desc, NULL); |
1791 | if (ret) { | 1928 | if (ret) { |
1792 | dev_err(dwc->dev, "failed to enable %s\n", dep->name); | 1929 | dev_err(dwc->dev, "failed to enable %s\n", dep->name); |
1793 | return; | 1930 | return; |
@@ -1817,8 +1954,55 @@ static void dwc3_gadget_wakeup_interrupt(struct dwc3 *dwc) | |||
1817 | static void dwc3_gadget_linksts_change_interrupt(struct dwc3 *dwc, | 1954 | static void dwc3_gadget_linksts_change_interrupt(struct dwc3 *dwc, |
1818 | unsigned int evtinfo) | 1955 | unsigned int evtinfo) |
1819 | { | 1956 | { |
1820 | /* The fith bit says SuperSpeed yes or no. */ | 1957 | enum dwc3_link_state next = evtinfo & DWC3_LINK_STATE_MASK; |
1821 | dwc->link_state = evtinfo & DWC3_LINK_STATE_MASK; | 1958 | |
1959 | /* | ||
1960 | * WORKAROUND: DWC3 Revisions <1.83a have an issue which, depending | ||
1961 | * on the link partner, the USB session might do multiple entry/exit | ||
1962 | * of low power states before a transfer takes place. | ||
1963 | * | ||
1964 | * Due to this problem, we might experience lower throughput. The | ||
1965 | * suggested workaround is to disable DCTL[12:9] bits if we're | ||
1966 | * transitioning from U1/U2 to U0 and enable those bits again | ||
1967 | * after a transfer completes and there are no pending transfers | ||
1968 | * on any of the enabled endpoints. | ||
1969 | * | ||
1970 | * This is the first half of that workaround. | ||
1971 | * | ||
1972 | * Refers to: | ||
1973 | * | ||
1974 | * STAR#9000446952: RTL: Device SS : if U1/U2 ->U0 takes >128us | ||
1975 | * core send LGO_Ux entering U0 | ||
1976 | */ | ||
1977 | if (dwc->revision < DWC3_REVISION_183A) { | ||
1978 | if (next == DWC3_LINK_STATE_U0) { | ||
1979 | u32 u1u2; | ||
1980 | u32 reg; | ||
1981 | |||
1982 | switch (dwc->link_state) { | ||
1983 | case DWC3_LINK_STATE_U1: | ||
1984 | case DWC3_LINK_STATE_U2: | ||
1985 | reg = dwc3_readl(dwc->regs, DWC3_DCTL); | ||
1986 | u1u2 = reg & (DWC3_DCTL_INITU2ENA | ||
1987 | | DWC3_DCTL_ACCEPTU2ENA | ||
1988 | | DWC3_DCTL_INITU1ENA | ||
1989 | | DWC3_DCTL_ACCEPTU1ENA); | ||
1990 | |||
1991 | if (!dwc->u1u2) | ||
1992 | dwc->u1u2 = reg & u1u2; | ||
1993 | |||
1994 | reg &= ~u1u2; | ||
1995 | |||
1996 | dwc3_writel(dwc->regs, DWC3_DCTL, reg); | ||
1997 | break; | ||
1998 | default: | ||
1999 | /* do nothing */ | ||
2000 | break; | ||
2001 | } | ||
2002 | } | ||
2003 | } | ||
2004 | |||
2005 | dwc->link_state = next; | ||
1822 | 2006 | ||
1823 | dev_vdbg(dwc->dev, "%s link %d\n", __func__, dwc->link_state); | 2007 | dev_vdbg(dwc->dev, "%s link %d\n", __func__, dwc->link_state); |
1824 | } | 2008 | } |
@@ -1924,7 +2108,7 @@ static irqreturn_t dwc3_interrupt(int irq, void *_dwc) | |||
1924 | 2108 | ||
1925 | spin_lock(&dwc->lock); | 2109 | spin_lock(&dwc->lock); |
1926 | 2110 | ||
1927 | for (i = 0; i < DWC3_EVENT_BUFFERS_NUM; i++) { | 2111 | for (i = 0; i < dwc->num_event_buffers; i++) { |
1928 | irqreturn_t status; | 2112 | irqreturn_t status; |
1929 | 2113 | ||
1930 | status = dwc3_process_event_buf(dwc, i); | 2114 | status = dwc3_process_event_buf(dwc, i); |
@@ -1985,9 +2169,10 @@ int __devinit dwc3_gadget_init(struct dwc3 *dwc) | |||
1985 | dev_set_name(&dwc->gadget.dev, "gadget"); | 2169 | dev_set_name(&dwc->gadget.dev, "gadget"); |
1986 | 2170 | ||
1987 | dwc->gadget.ops = &dwc3_gadget_ops; | 2171 | dwc->gadget.ops = &dwc3_gadget_ops; |
1988 | dwc->gadget.is_dualspeed = true; | 2172 | dwc->gadget.max_speed = USB_SPEED_SUPER; |
1989 | dwc->gadget.speed = USB_SPEED_UNKNOWN; | 2173 | dwc->gadget.speed = USB_SPEED_UNKNOWN; |
1990 | dwc->gadget.dev.parent = dwc->dev; | 2174 | dwc->gadget.dev.parent = dwc->dev; |
2175 | dwc->gadget.sg_supported = true; | ||
1991 | 2176 | ||
1992 | dma_set_coherent_mask(&dwc->gadget.dev, dwc->dev->coherent_dma_mask); | 2177 | dma_set_coherent_mask(&dwc->gadget.dev, dwc->dev->coherent_dma_mask); |
1993 | 2178 | ||
@@ -2075,7 +2260,6 @@ err0: | |||
2075 | void dwc3_gadget_exit(struct dwc3 *dwc) | 2260 | void dwc3_gadget_exit(struct dwc3 *dwc) |
2076 | { | 2261 | { |
2077 | int irq; | 2262 | int irq; |
2078 | int i; | ||
2079 | 2263 | ||
2080 | usb_del_gadget_udc(&dwc->gadget); | 2264 | usb_del_gadget_udc(&dwc->gadget); |
2081 | irq = platform_get_irq(to_platform_device(dwc->dev), 0); | 2265 | irq = platform_get_irq(to_platform_device(dwc->dev), 0); |
@@ -2083,9 +2267,6 @@ void dwc3_gadget_exit(struct dwc3 *dwc) | |||
2083 | dwc3_writel(dwc->regs, DWC3_DEVTEN, 0x00); | 2267 | dwc3_writel(dwc->regs, DWC3_DEVTEN, 0x00); |
2084 | free_irq(irq, dwc); | 2268 | free_irq(irq, dwc); |
2085 | 2269 | ||
2086 | for (i = 0; i < ARRAY_SIZE(dwc->eps); i++) | ||
2087 | __dwc3_gadget_ep_disable(dwc->eps[i]); | ||
2088 | |||
2089 | dwc3_gadget_free_endpoints(dwc); | 2270 | dwc3_gadget_free_endpoints(dwc); |
2090 | 2271 | ||
2091 | dma_free_coherent(dwc->dev, 512, dwc->ep0_bounce, | 2272 | dma_free_coherent(dwc->dev, 512, dwc->ep0_bounce, |
diff --git a/drivers/usb/dwc3/gadget.h b/drivers/usb/dwc3/gadget.h index 71145a449d99..d97f467d41cc 100644 --- a/drivers/usb/dwc3/gadget.h +++ b/drivers/usb/dwc3/gadget.h | |||
@@ -79,19 +79,6 @@ struct dwc3_gadget_ep_cmd_params { | |||
79 | 79 | ||
80 | /* -------------------------------------------------------------------------- */ | 80 | /* -------------------------------------------------------------------------- */ |
81 | 81 | ||
82 | struct dwc3_request { | ||
83 | struct usb_request request; | ||
84 | struct list_head list; | ||
85 | struct dwc3_ep *dep; | ||
86 | |||
87 | u8 epnum; | ||
88 | struct dwc3_trb_hw *trb; | ||
89 | dma_addr_t trb_dma; | ||
90 | |||
91 | unsigned direction:1; | ||
92 | unsigned mapped:1; | ||
93 | unsigned queued:1; | ||
94 | }; | ||
95 | #define to_dwc3_request(r) (container_of(r, struct dwc3_request, request)) | 82 | #define to_dwc3_request(r) (container_of(r, struct dwc3_request, request)) |
96 | 83 | ||
97 | static inline struct dwc3_request *next_request(struct list_head *list) | 84 | static inline struct dwc3_request *next_request(struct list_head *list) |
@@ -110,23 +97,11 @@ static inline void dwc3_gadget_move_request_queued(struct dwc3_request *req) | |||
110 | list_move_tail(&req->list, &dep->req_queued); | 97 | list_move_tail(&req->list, &dep->req_queued); |
111 | } | 98 | } |
112 | 99 | ||
113 | #if defined(CONFIG_USB_GADGET_DWC3) || defined(CONFIG_USB_GADGET_DWC3_MODULE) | ||
114 | int dwc3_gadget_init(struct dwc3 *dwc); | ||
115 | void dwc3_gadget_exit(struct dwc3 *dwc); | ||
116 | #else | ||
117 | static inline int dwc3_gadget_init(struct dwc3 *dwc) { return 0; } | ||
118 | static inline void dwc3_gadget_exit(struct dwc3 *dwc) { } | ||
119 | static inline int dwc3_send_gadget_ep_cmd(struct dwc3 *dwc, unsigned ep, | ||
120 | unsigned cmd, struct dwc3_gadget_ep_cmd_params *params) | ||
121 | { | ||
122 | return 0; | ||
123 | } | ||
124 | #endif | ||
125 | |||
126 | void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req, | 100 | void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req, |
127 | int status); | 101 | int status); |
128 | 102 | ||
129 | void dwc3_ep0_interrupt(struct dwc3 *dwc, const struct dwc3_event_depevt *event); | 103 | void dwc3_ep0_interrupt(struct dwc3 *dwc, |
104 | const struct dwc3_event_depevt *event); | ||
130 | void dwc3_ep0_out_start(struct dwc3 *dwc); | 105 | void dwc3_ep0_out_start(struct dwc3 *dwc); |
131 | int dwc3_gadget_ep0_queue(struct usb_ep *ep, struct usb_request *request, | 106 | int dwc3_gadget_ep0_queue(struct usb_ep *ep, struct usb_request *request, |
132 | gfp_t gfp_flags); | 107 | gfp_t gfp_flags); |
diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c new file mode 100644 index 000000000000..7cfe211b6c37 --- /dev/null +++ b/drivers/usb/dwc3/host.c | |||
@@ -0,0 +1,102 @@ | |||
1 | /** | ||
2 | * host.c - DesignWare USB3 DRD Controller Host Glue | ||
3 | * | ||
4 | * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com | ||
5 | * | ||
6 | * Authors: Felipe Balbi <balbi@ti.com>, | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions | ||
10 | * are met: | ||
11 | * 1. Redistributions of source code must retain the above copyright | ||
12 | * notice, this list of conditions, and the following disclaimer, | ||
13 | * without modification. | ||
14 | * 2. Redistributions in binary form must reproduce the above copyright | ||
15 | * notice, this list of conditions and the following disclaimer in the | ||
16 | * documentation and/or other materials provided with the distribution. | ||
17 | * 3. The names of the above-listed copyright holders may not be used | ||
18 | * to endorse or promote products derived from this software without | ||
19 | * specific prior written permission. | ||
20 | * | ||
21 | * ALTERNATIVELY, this software may be distributed under the terms of the | ||
22 | * GNU General Public License ("GPL") version 2, as published by the Free | ||
23 | * Software Foundation. | ||
24 | * | ||
25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
26 | * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
27 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
28 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
29 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
30 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
31 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
32 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
33 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
34 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
35 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
36 | */ | ||
37 | |||
38 | #include <linux/platform_device.h> | ||
39 | |||
40 | #include "core.h" | ||
41 | |||
42 | static struct resource generic_resources[] = { | ||
43 | { | ||
44 | .flags = IORESOURCE_IRQ, | ||
45 | }, | ||
46 | { | ||
47 | .flags = IORESOURCE_MEM, | ||
48 | }, | ||
49 | }; | ||
50 | |||
51 | int dwc3_host_init(struct dwc3 *dwc) | ||
52 | { | ||
53 | struct platform_device *xhci; | ||
54 | int ret; | ||
55 | |||
56 | xhci = platform_device_alloc("xhci", -1); | ||
57 | if (!xhci) { | ||
58 | dev_err(dwc->dev, "couldn't allocate xHCI device\n"); | ||
59 | ret = -ENOMEM; | ||
60 | goto err0; | ||
61 | } | ||
62 | |||
63 | dma_set_coherent_mask(&xhci->dev, dwc->dev->coherent_dma_mask); | ||
64 | |||
65 | xhci->dev.parent = dwc->dev; | ||
66 | xhci->dev.dma_mask = dwc->dev->dma_mask; | ||
67 | xhci->dev.dma_parms = dwc->dev->dma_parms; | ||
68 | |||
69 | dwc->xhci = xhci; | ||
70 | |||
71 | /* setup resources */ | ||
72 | generic_resources[0].start = dwc->irq; | ||
73 | |||
74 | generic_resources[1].start = dwc->res->start; | ||
75 | generic_resources[1].end = dwc->res->start + 0x7fff; | ||
76 | |||
77 | ret = platform_device_add_resources(xhci, generic_resources, | ||
78 | ARRAY_SIZE(generic_resources)); | ||
79 | if (ret) { | ||
80 | dev_err(dwc->dev, "couldn't add resources to xHCI device\n"); | ||
81 | goto err1; | ||
82 | } | ||
83 | |||
84 | ret = platform_device_add(xhci); | ||
85 | if (ret) { | ||
86 | dev_err(dwc->dev, "failed to register xHCI device\n"); | ||
87 | goto err1; | ||
88 | } | ||
89 | |||
90 | return 0; | ||
91 | |||
92 | err1: | ||
93 | platform_device_put(xhci); | ||
94 | |||
95 | err0: | ||
96 | return ret; | ||
97 | } | ||
98 | |||
99 | void dwc3_host_exit(struct dwc3 *dwc) | ||
100 | { | ||
101 | platform_device_unregister(dwc->xhci); | ||
102 | } | ||
diff --git a/drivers/usb/dwc3/io.h b/drivers/usb/dwc3/io.h index bc957db1ea4b..071d561f3e68 100644 --- a/drivers/usb/dwc3/io.h +++ b/drivers/usb/dwc3/io.h | |||
@@ -39,7 +39,7 @@ | |||
39 | #ifndef __DRIVERS_USB_DWC3_IO_H | 39 | #ifndef __DRIVERS_USB_DWC3_IO_H |
40 | #define __DRIVERS_USB_DWC3_IO_H | 40 | #define __DRIVERS_USB_DWC3_IO_H |
41 | 41 | ||
42 | #include <asm/io.h> | 42 | #include <linux/io.h> |
43 | 43 | ||
44 | static inline u32 dwc3_readl(void __iomem *base, u32 offset) | 44 | static inline u32 dwc3_readl(void __iomem *base, u32 offset) |
45 | { | 45 | { |
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index b21cd376c11a..7ecb68a67411 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig | |||
@@ -15,6 +15,7 @@ | |||
15 | 15 | ||
16 | menuconfig USB_GADGET | 16 | menuconfig USB_GADGET |
17 | tristate "USB Gadget Support" | 17 | tristate "USB Gadget Support" |
18 | select NLS | ||
18 | help | 19 | help |
19 | USB is a master/slave protocol, organized with one master | 20 | USB is a master/slave protocol, organized with one master |
20 | host (such as a PC) controlling up to 127 peripheral devices. | 21 | host (such as a PC) controlling up to 127 peripheral devices. |
@@ -124,7 +125,6 @@ config USB_GADGET_STORAGE_NUM_BUFFERS | |||
124 | # | 125 | # |
125 | choice | 126 | choice |
126 | prompt "USB Peripheral Controller" | 127 | prompt "USB Peripheral Controller" |
127 | depends on USB_GADGET | ||
128 | help | 128 | help |
129 | A USB device uses a controller to talk to its host. | 129 | A USB device uses a controller to talk to its host. |
130 | Systems should have only one such upstream link. | 130 | Systems should have only one such upstream link. |
@@ -234,7 +234,6 @@ config USB_R8A66597 | |||
234 | 234 | ||
235 | config USB_RENESAS_USBHS_UDC | 235 | config USB_RENESAS_USBHS_UDC |
236 | tristate 'Renesas USBHS controller' | 236 | tristate 'Renesas USBHS controller' |
237 | depends on SUPERH || ARCH_SHMOBILE | ||
238 | depends on USB_RENESAS_USBHS | 237 | depends on USB_RENESAS_USBHS |
239 | select USB_GADGET_DUALSPEED | 238 | select USB_GADGET_DUALSPEED |
240 | help | 239 | help |
@@ -264,7 +263,6 @@ config USB_PXA27X | |||
264 | config USB_S3C_HSOTG | 263 | config USB_S3C_HSOTG |
265 | tristate "S3C HS/OtG USB Device controller" | 264 | tristate "S3C HS/OtG USB Device controller" |
266 | depends on S3C_DEV_USB_HSOTG | 265 | depends on S3C_DEV_USB_HSOTG |
267 | select USB_GADGET_S3C_HSOTG_PIO | ||
268 | select USB_GADGET_DUALSPEED | 266 | select USB_GADGET_DUALSPEED |
269 | help | 267 | help |
270 | The Samsung S3C64XX USB2.0 high-speed gadget controller | 268 | The Samsung S3C64XX USB2.0 high-speed gadget controller |
@@ -310,25 +308,13 @@ config USB_S3C_HSUDC | |||
310 | 308 | ||
311 | This driver has been tested on S3C2416 and S3C2450 processors. | 309 | This driver has been tested on S3C2416 and S3C2450 processors. |
312 | 310 | ||
313 | config USB_PXA_U2O | 311 | config USB_MV_UDC |
314 | tristate "PXA9xx Processor USB2.0 controller" | 312 | tristate "Marvell USB2.0 Device Controller" |
315 | depends on ARCH_MMP | ||
316 | select USB_GADGET_DUALSPEED | 313 | select USB_GADGET_DUALSPEED |
317 | help | 314 | help |
318 | PXA9xx Processor series include a high speed USB2.0 device | 315 | Marvell Socs (including PXA and MMP series) include a high speed |
319 | controller, which support high speed and full speed USB peripheral. | 316 | USB2.0 OTG controller, which can be configured as high speed or |
320 | 317 | full speed USB peripheral. | |
321 | config USB_GADGET_DWC3 | ||
322 | tristate "DesignWare USB3.0 (DRD) Controller" | ||
323 | depends on USB_DWC3 | ||
324 | select USB_GADGET_DUALSPEED | ||
325 | select USB_GADGET_SUPERSPEED | ||
326 | help | ||
327 | DesignWare USB3.0 controller is a SuperSpeed USB3.0 Controller | ||
328 | which can be configured for peripheral-only, host-only, hub-only | ||
329 | and Dual-Role operation. This Controller was first integrated into | ||
330 | the OMAP5 series of processors. More information about the OMAP5 | ||
331 | version of this controller, refer to http://www.ti.com/omap5. | ||
332 | 318 | ||
333 | # | 319 | # |
334 | # Controllers available in both integrated and discrete versions | 320 | # Controllers available in both integrated and discrete versions |
@@ -469,7 +455,7 @@ config USB_LANGWELL | |||
469 | gadget drivers to also be dynamically linked. | 455 | gadget drivers to also be dynamically linked. |
470 | 456 | ||
471 | config USB_EG20T | 457 | config USB_EG20T |
472 | tristate "Intel EG20T PCH/OKI SEMICONDUCTOR ML7213 IOH UDC" | 458 | tristate "Intel EG20T PCH/LAPIS Semiconductor IOH(ML7213/ML7831) UDC" |
473 | depends on PCI | 459 | depends on PCI |
474 | select USB_GADGET_DUALSPEED | 460 | select USB_GADGET_DUALSPEED |
475 | help | 461 | help |
@@ -485,10 +471,11 @@ config USB_EG20T | |||
485 | This driver dose not support interrupt transfer or isochronous | 471 | This driver dose not support interrupt transfer or isochronous |
486 | transfer modes. | 472 | transfer modes. |
487 | 473 | ||
488 | This driver also can be used for OKI SEMICONDUCTOR's ML7213 which is | 474 | This driver also can be used for LAPIS Semiconductor's ML7213 which is |
489 | for IVI(In-Vehicle Infotainment) use. | 475 | for IVI(In-Vehicle Infotainment) use. |
490 | ML7213 is companion chip for Intel Atom E6xx series. | 476 | ML7831 is for general purpose use. |
491 | ML7213 is completely compatible for Intel EG20T PCH. | 477 | ML7213/ML7831 is companion chip for Intel Atom E6xx series. |
478 | ML7213/ML7831 is completely compatible for Intel EG20T PCH. | ||
492 | 479 | ||
493 | config USB_CI13XXX_MSM | 480 | config USB_CI13XXX_MSM |
494 | tristate "MIPS USB CI13xxx for MSM" | 481 | tristate "MIPS USB CI13xxx for MSM" |
@@ -543,12 +530,10 @@ endchoice | |||
543 | # Selected by UDC drivers that support high-speed operation. | 530 | # Selected by UDC drivers that support high-speed operation. |
544 | config USB_GADGET_DUALSPEED | 531 | config USB_GADGET_DUALSPEED |
545 | bool | 532 | bool |
546 | depends on USB_GADGET | ||
547 | 533 | ||
548 | # Selected by UDC drivers that support super-speed opperation | 534 | # Selected by UDC drivers that support super-speed opperation |
549 | config USB_GADGET_SUPERSPEED | 535 | config USB_GADGET_SUPERSPEED |
550 | bool | 536 | bool |
551 | depends on USB_GADGET | ||
552 | depends on USB_GADGET_DUALSPEED | 537 | depends on USB_GADGET_DUALSPEED |
553 | 538 | ||
554 | # | 539 | # |
@@ -556,7 +541,6 @@ config USB_GADGET_SUPERSPEED | |||
556 | # | 541 | # |
557 | choice | 542 | choice |
558 | tristate "USB Gadget Drivers" | 543 | tristate "USB Gadget Drivers" |
559 | depends on USB_GADGET | ||
560 | default USB_ETH | 544 | default USB_ETH |
561 | help | 545 | help |
562 | A Linux "Gadget Driver" talks to the USB Peripheral Controller | 546 | A Linux "Gadget Driver" talks to the USB Peripheral Controller |
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile index b54ac6190890..b7f6eefc3927 100644 --- a/drivers/usb/gadget/Makefile +++ b/drivers/usb/gadget/Makefile | |||
@@ -27,7 +27,7 @@ obj-$(CONFIG_USB_S3C_HSOTG) += s3c-hsotg.o | |||
27 | obj-$(CONFIG_USB_S3C_HSUDC) += s3c-hsudc.o | 27 | obj-$(CONFIG_USB_S3C_HSUDC) += s3c-hsudc.o |
28 | obj-$(CONFIG_USB_LANGWELL) += langwell_udc.o | 28 | obj-$(CONFIG_USB_LANGWELL) += langwell_udc.o |
29 | obj-$(CONFIG_USB_EG20T) += pch_udc.o | 29 | obj-$(CONFIG_USB_EG20T) += pch_udc.o |
30 | obj-$(CONFIG_USB_PXA_U2O) += mv_udc.o | 30 | obj-$(CONFIG_USB_MV_UDC) += mv_udc.o |
31 | mv_udc-y := mv_udc_core.o | 31 | mv_udc-y := mv_udc_core.o |
32 | obj-$(CONFIG_USB_CI13XXX_MSM) += ci13xxx_msm.o | 32 | obj-$(CONFIG_USB_CI13XXX_MSM) += ci13xxx_msm.o |
33 | obj-$(CONFIG_USB_FUSB300) += fusb300_udc.o | 33 | obj-$(CONFIG_USB_FUSB300) += fusb300_udc.o |
diff --git a/drivers/usb/gadget/amd5536udc.c b/drivers/usb/gadget/amd5536udc.c index 4730016d7cd4..c16ff55a74e8 100644 --- a/drivers/usb/gadget/amd5536udc.c +++ b/drivers/usb/gadget/amd5536udc.c | |||
@@ -152,15 +152,15 @@ static const char *ep_string[] = { | |||
152 | }; | 152 | }; |
153 | 153 | ||
154 | /* DMA usage flag */ | 154 | /* DMA usage flag */ |
155 | static int use_dma = 1; | 155 | static bool use_dma = 1; |
156 | /* packet per buffer dma */ | 156 | /* packet per buffer dma */ |
157 | static int use_dma_ppb = 1; | 157 | static bool use_dma_ppb = 1; |
158 | /* with per descr. update */ | 158 | /* with per descr. update */ |
159 | static int use_dma_ppb_du; | 159 | static bool use_dma_ppb_du; |
160 | /* buffer fill mode */ | 160 | /* buffer fill mode */ |
161 | static int use_dma_bufferfill_mode; | 161 | static int use_dma_bufferfill_mode; |
162 | /* full speed only mode */ | 162 | /* full speed only mode */ |
163 | static int use_fullspeed; | 163 | static bool use_fullspeed; |
164 | /* tx buffer size for high speed */ | 164 | /* tx buffer size for high speed */ |
165 | static unsigned long hs_tx_buf = UDC_EPIN_BUFF_SIZE; | 165 | static unsigned long hs_tx_buf = UDC_EPIN_BUFF_SIZE; |
166 | 166 | ||
@@ -1959,7 +1959,7 @@ static int amd5536_start(struct usb_gadget_driver *driver, | |||
1959 | u32 tmp; | 1959 | u32 tmp; |
1960 | 1960 | ||
1961 | if (!driver || !bind || !driver->setup | 1961 | if (!driver || !bind || !driver->setup |
1962 | || driver->speed != USB_SPEED_HIGH) | 1962 | || driver->max_speed < USB_SPEED_HIGH) |
1963 | return -EINVAL; | 1963 | return -EINVAL; |
1964 | if (!dev) | 1964 | if (!dev) |
1965 | return -ENODEV; | 1965 | return -ENODEV; |
@@ -3349,7 +3349,7 @@ static int udc_probe(struct udc *dev) | |||
3349 | dev_set_name(&dev->gadget.dev, "gadget"); | 3349 | dev_set_name(&dev->gadget.dev, "gadget"); |
3350 | dev->gadget.dev.release = gadget_release; | 3350 | dev->gadget.dev.release = gadget_release; |
3351 | dev->gadget.name = name; | 3351 | dev->gadget.name = name; |
3352 | dev->gadget.is_dualspeed = 1; | 3352 | dev->gadget.max_speed = USB_SPEED_HIGH; |
3353 | 3353 | ||
3354 | /* init registers, interrupts, ... */ | 3354 | /* init registers, interrupts, ... */ |
3355 | startup_registers(dev); | 3355 | startup_registers(dev); |
diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c index 8efe0fa9228d..143a7256b598 100644 --- a/drivers/usb/gadget/at91_udc.c +++ b/drivers/usb/gadget/at91_udc.c | |||
@@ -1633,7 +1633,7 @@ static int at91_start(struct usb_gadget_driver *driver, | |||
1633 | unsigned long flags; | 1633 | unsigned long flags; |
1634 | 1634 | ||
1635 | if (!driver | 1635 | if (!driver |
1636 | || driver->speed < USB_SPEED_FULL | 1636 | || driver->max_speed < USB_SPEED_FULL |
1637 | || !bind | 1637 | || !bind |
1638 | || !driver->setup) { | 1638 | || !driver->setup) { |
1639 | DBG("bad parameter.\n"); | 1639 | DBG("bad parameter.\n"); |
@@ -1748,7 +1748,7 @@ static int __init at91udc_probe(struct platform_device *pdev) | |||
1748 | 1748 | ||
1749 | /* rm9200 needs manual D+ pullup; off by default */ | 1749 | /* rm9200 needs manual D+ pullup; off by default */ |
1750 | if (cpu_is_at91rm9200()) { | 1750 | if (cpu_is_at91rm9200()) { |
1751 | if (udc->board.pullup_pin <= 0) { | 1751 | if (gpio_is_valid(udc->board.pullup_pin)) { |
1752 | DBG("no D+ pullup?\n"); | 1752 | DBG("no D+ pullup?\n"); |
1753 | retval = -ENODEV; | 1753 | retval = -ENODEV; |
1754 | goto fail0; | 1754 | goto fail0; |
@@ -1815,7 +1815,7 @@ static int __init at91udc_probe(struct platform_device *pdev) | |||
1815 | DBG("request irq %d failed\n", udc->udp_irq); | 1815 | DBG("request irq %d failed\n", udc->udp_irq); |
1816 | goto fail1; | 1816 | goto fail1; |
1817 | } | 1817 | } |
1818 | if (udc->board.vbus_pin > 0) { | 1818 | if (gpio_is_valid(udc->board.vbus_pin)) { |
1819 | retval = gpio_request(udc->board.vbus_pin, "udc_vbus"); | 1819 | retval = gpio_request(udc->board.vbus_pin, "udc_vbus"); |
1820 | if (retval < 0) { | 1820 | if (retval < 0) { |
1821 | DBG("request vbus pin failed\n"); | 1821 | DBG("request vbus pin failed\n"); |
@@ -1859,10 +1859,10 @@ static int __init at91udc_probe(struct platform_device *pdev) | |||
1859 | INFO("%s version %s\n", driver_name, DRIVER_VERSION); | 1859 | INFO("%s version %s\n", driver_name, DRIVER_VERSION); |
1860 | return 0; | 1860 | return 0; |
1861 | fail4: | 1861 | fail4: |
1862 | if (udc->board.vbus_pin > 0 && !udc->board.vbus_polled) | 1862 | if (gpio_is_valid(udc->board.vbus_pin) && !udc->board.vbus_polled) |
1863 | free_irq(udc->board.vbus_pin, udc); | 1863 | free_irq(udc->board.vbus_pin, udc); |
1864 | fail3: | 1864 | fail3: |
1865 | if (udc->board.vbus_pin > 0) | 1865 | if (gpio_is_valid(udc->board.vbus_pin)) |
1866 | gpio_free(udc->board.vbus_pin); | 1866 | gpio_free(udc->board.vbus_pin); |
1867 | fail2: | 1867 | fail2: |
1868 | free_irq(udc->udp_irq, udc); | 1868 | free_irq(udc->udp_irq, udc); |
@@ -1897,7 +1897,7 @@ static int __exit at91udc_remove(struct platform_device *pdev) | |||
1897 | 1897 | ||
1898 | device_init_wakeup(&pdev->dev, 0); | 1898 | device_init_wakeup(&pdev->dev, 0); |
1899 | remove_debug_file(udc); | 1899 | remove_debug_file(udc); |
1900 | if (udc->board.vbus_pin > 0) { | 1900 | if (gpio_is_valid(udc->board.vbus_pin)) { |
1901 | free_irq(udc->board.vbus_pin, udc); | 1901 | free_irq(udc->board.vbus_pin, udc); |
1902 | gpio_free(udc->board.vbus_pin); | 1902 | gpio_free(udc->board.vbus_pin); |
1903 | } | 1903 | } |
@@ -1941,7 +1941,7 @@ static int at91udc_suspend(struct platform_device *pdev, pm_message_t mesg) | |||
1941 | enable_irq_wake(udc->udp_irq); | 1941 | enable_irq_wake(udc->udp_irq); |
1942 | 1942 | ||
1943 | udc->active_suspend = wake; | 1943 | udc->active_suspend = wake; |
1944 | if (udc->board.vbus_pin > 0 && !udc->board.vbus_polled && wake) | 1944 | if (gpio_is_valid(udc->board.vbus_pin) && !udc->board.vbus_polled && wake) |
1945 | enable_irq_wake(udc->board.vbus_pin); | 1945 | enable_irq_wake(udc->board.vbus_pin); |
1946 | return 0; | 1946 | return 0; |
1947 | } | 1947 | } |
@@ -1951,7 +1951,7 @@ static int at91udc_resume(struct platform_device *pdev) | |||
1951 | struct at91_udc *udc = platform_get_drvdata(pdev); | 1951 | struct at91_udc *udc = platform_get_drvdata(pdev); |
1952 | unsigned long flags; | 1952 | unsigned long flags; |
1953 | 1953 | ||
1954 | if (udc->board.vbus_pin > 0 && !udc->board.vbus_polled && | 1954 | if (gpio_is_valid(udc->board.vbus_pin) && !udc->board.vbus_polled && |
1955 | udc->active_suspend) | 1955 | udc->active_suspend) |
1956 | disable_irq_wake(udc->board.vbus_pin); | 1956 | disable_irq_wake(udc->board.vbus_pin); |
1957 | 1957 | ||
diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c index 271a9d873608..e2fb6d583bd9 100644 --- a/drivers/usb/gadget/atmel_usba_udc.c +++ b/drivers/usb/gadget/atmel_usba_udc.c | |||
@@ -1038,7 +1038,7 @@ static struct usba_udc the_udc = { | |||
1038 | .gadget = { | 1038 | .gadget = { |
1039 | .ops = &usba_udc_ops, | 1039 | .ops = &usba_udc_ops, |
1040 | .ep_list = LIST_HEAD_INIT(the_udc.gadget.ep_list), | 1040 | .ep_list = LIST_HEAD_INIT(the_udc.gadget.ep_list), |
1041 | .is_dualspeed = 1, | 1041 | .max_speed = USB_SPEED_HIGH, |
1042 | .name = "atmel_usba_udc", | 1042 | .name = "atmel_usba_udc", |
1043 | .dev = { | 1043 | .dev = { |
1044 | .init_name = "gadget", | 1044 | .init_name = "gadget", |
diff --git a/drivers/usb/gadget/ci13xxx_msm.c b/drivers/usb/gadget/ci13xxx_msm.c index 4eedfe557154..1fc612914c52 100644 --- a/drivers/usb/gadget/ci13xxx_msm.c +++ b/drivers/usb/gadget/ci13xxx_msm.c | |||
@@ -122,3 +122,5 @@ static int __init ci13xxx_msm_init(void) | |||
122 | return platform_driver_register(&ci13xxx_msm_driver); | 122 | return platform_driver_register(&ci13xxx_msm_driver); |
123 | } | 123 | } |
124 | module_init(ci13xxx_msm_init); | 124 | module_init(ci13xxx_msm_init); |
125 | |||
126 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/usb/gadget/ci13xxx_udc.c b/drivers/usb/gadget/ci13xxx_udc.c index 83428f56253b..27e313718422 100644 --- a/drivers/usb/gadget/ci13xxx_udc.c +++ b/drivers/usb/gadget/ci13xxx_udc.c | |||
@@ -71,6 +71,9 @@ | |||
71 | /****************************************************************************** | 71 | /****************************************************************************** |
72 | * DEFINE | 72 | * DEFINE |
73 | *****************************************************************************/ | 73 | *****************************************************************************/ |
74 | |||
75 | #define DMA_ADDR_INVALID (~(dma_addr_t)0) | ||
76 | |||
74 | /* ctrl register bank access */ | 77 | /* ctrl register bank access */ |
75 | static DEFINE_SPINLOCK(udc_lock); | 78 | static DEFINE_SPINLOCK(udc_lock); |
76 | 79 | ||
@@ -179,6 +182,16 @@ static inline int hw_ep_bit(int num, int dir) | |||
179 | return num + (dir ? 16 : 0); | 182 | return num + (dir ? 16 : 0); |
180 | } | 183 | } |
181 | 184 | ||
185 | static int ep_to_bit(int n) | ||
186 | { | ||
187 | int fill = 16 - hw_ep_max / 2; | ||
188 | |||
189 | if (n >= hw_ep_max / 2) | ||
190 | n += fill; | ||
191 | |||
192 | return n; | ||
193 | } | ||
194 | |||
182 | /** | 195 | /** |
183 | * hw_aread: reads from register bitfield | 196 | * hw_aread: reads from register bitfield |
184 | * @addr: address relative to bus map | 197 | * @addr: address relative to bus map |
@@ -437,12 +450,13 @@ static int hw_ep_get_halt(int num, int dir) | |||
437 | /** | 450 | /** |
438 | * hw_test_and_clear_setup_status: test & clear setup status (execute without | 451 | * hw_test_and_clear_setup_status: test & clear setup status (execute without |
439 | * interruption) | 452 | * interruption) |
440 | * @n: bit number (endpoint) | 453 | * @n: endpoint number |
441 | * | 454 | * |
442 | * This function returns setup status | 455 | * This function returns setup status |
443 | */ | 456 | */ |
444 | static int hw_test_and_clear_setup_status(int n) | 457 | static int hw_test_and_clear_setup_status(int n) |
445 | { | 458 | { |
459 | n = ep_to_bit(n); | ||
446 | return hw_ctest_and_clear(CAP_ENDPTSETUPSTAT, BIT(n)); | 460 | return hw_ctest_and_clear(CAP_ENDPTSETUPSTAT, BIT(n)); |
447 | } | 461 | } |
448 | 462 | ||
@@ -638,12 +652,13 @@ static int hw_register_write(u16 addr, u32 data) | |||
638 | /** | 652 | /** |
639 | * hw_test_and_clear_complete: test & clear complete status (execute without | 653 | * hw_test_and_clear_complete: test & clear complete status (execute without |
640 | * interruption) | 654 | * interruption) |
641 | * @n: bit number (endpoint) | 655 | * @n: endpoint number |
642 | * | 656 | * |
643 | * This function returns complete status | 657 | * This function returns complete status |
644 | */ | 658 | */ |
645 | static int hw_test_and_clear_complete(int n) | 659 | static int hw_test_and_clear_complete(int n) |
646 | { | 660 | { |
661 | n = ep_to_bit(n); | ||
647 | return hw_ctest_and_clear(CAP_ENDPTCOMPLETE, BIT(n)); | 662 | return hw_ctest_and_clear(CAP_ENDPTCOMPLETE, BIT(n)); |
648 | } | 663 | } |
649 | 664 | ||
@@ -751,8 +766,11 @@ static ssize_t show_device(struct device *dev, struct device_attribute *attr, | |||
751 | 766 | ||
752 | n += scnprintf(buf + n, PAGE_SIZE - n, "speed = %d\n", | 767 | n += scnprintf(buf + n, PAGE_SIZE - n, "speed = %d\n", |
753 | gadget->speed); | 768 | gadget->speed); |
769 | n += scnprintf(buf + n, PAGE_SIZE - n, "max_speed = %d\n", | ||
770 | gadget->max_speed); | ||
771 | /* TODO: Scheduled for removal in 3.8. */ | ||
754 | n += scnprintf(buf + n, PAGE_SIZE - n, "is_dualspeed = %d\n", | 772 | n += scnprintf(buf + n, PAGE_SIZE - n, "is_dualspeed = %d\n", |
755 | gadget->is_dualspeed); | 773 | gadget_is_dualspeed(gadget)); |
756 | n += scnprintf(buf + n, PAGE_SIZE - n, "is_otg = %d\n", | 774 | n += scnprintf(buf + n, PAGE_SIZE - n, "is_otg = %d\n", |
757 | gadget->is_otg); | 775 | gadget->is_otg); |
758 | n += scnprintf(buf + n, PAGE_SIZE - n, "is_a_peripheral = %d\n", | 776 | n += scnprintf(buf + n, PAGE_SIZE - n, "is_a_peripheral = %d\n", |
@@ -795,7 +813,7 @@ static ssize_t show_driver(struct device *dev, struct device_attribute *attr, | |||
795 | n += scnprintf(buf + n, PAGE_SIZE - n, "function = %s\n", | 813 | n += scnprintf(buf + n, PAGE_SIZE - n, "function = %s\n", |
796 | (driver->function ? driver->function : "")); | 814 | (driver->function ? driver->function : "")); |
797 | n += scnprintf(buf + n, PAGE_SIZE - n, "max speed = %d\n", | 815 | n += scnprintf(buf + n, PAGE_SIZE - n, "max speed = %d\n", |
798 | driver->speed); | 816 | driver->max_speed); |
799 | 817 | ||
800 | return n; | 818 | return n; |
801 | } | 819 | } |
@@ -1434,7 +1452,7 @@ static int _hardware_enqueue(struct ci13xxx_ep *mEp, struct ci13xxx_req *mReq) | |||
1434 | return -EALREADY; | 1452 | return -EALREADY; |
1435 | 1453 | ||
1436 | mReq->req.status = -EALREADY; | 1454 | mReq->req.status = -EALREADY; |
1437 | if (length && !mReq->req.dma) { | 1455 | if (length && mReq->req.dma == DMA_ADDR_INVALID) { |
1438 | mReq->req.dma = \ | 1456 | mReq->req.dma = \ |
1439 | dma_map_single(mEp->device, mReq->req.buf, | 1457 | dma_map_single(mEp->device, mReq->req.buf, |
1440 | length, mEp->dir ? DMA_TO_DEVICE : | 1458 | length, mEp->dir ? DMA_TO_DEVICE : |
@@ -1453,7 +1471,7 @@ static int _hardware_enqueue(struct ci13xxx_ep *mEp, struct ci13xxx_req *mReq) | |||
1453 | dma_unmap_single(mEp->device, mReq->req.dma, | 1471 | dma_unmap_single(mEp->device, mReq->req.dma, |
1454 | length, mEp->dir ? DMA_TO_DEVICE : | 1472 | length, mEp->dir ? DMA_TO_DEVICE : |
1455 | DMA_FROM_DEVICE); | 1473 | DMA_FROM_DEVICE); |
1456 | mReq->req.dma = 0; | 1474 | mReq->req.dma = DMA_ADDR_INVALID; |
1457 | mReq->map = 0; | 1475 | mReq->map = 0; |
1458 | } | 1476 | } |
1459 | return -ENOMEM; | 1477 | return -ENOMEM; |
@@ -1549,7 +1567,7 @@ static int _hardware_dequeue(struct ci13xxx_ep *mEp, struct ci13xxx_req *mReq) | |||
1549 | if (mReq->map) { | 1567 | if (mReq->map) { |
1550 | dma_unmap_single(mEp->device, mReq->req.dma, mReq->req.length, | 1568 | dma_unmap_single(mEp->device, mReq->req.dma, mReq->req.length, |
1551 | mEp->dir ? DMA_TO_DEVICE : DMA_FROM_DEVICE); | 1569 | mEp->dir ? DMA_TO_DEVICE : DMA_FROM_DEVICE); |
1552 | mReq->req.dma = 0; | 1570 | mReq->req.dma = DMA_ADDR_INVALID; |
1553 | mReq->map = 0; | 1571 | mReq->map = 0; |
1554 | } | 1572 | } |
1555 | 1573 | ||
@@ -1610,7 +1628,6 @@ __acquires(mEp->lock) | |||
1610 | * @gadget: gadget | 1628 | * @gadget: gadget |
1611 | * | 1629 | * |
1612 | * This function returns an error code | 1630 | * This function returns an error code |
1613 | * Caller must hold lock | ||
1614 | */ | 1631 | */ |
1615 | static int _gadget_stop_activity(struct usb_gadget *gadget) | 1632 | static int _gadget_stop_activity(struct usb_gadget *gadget) |
1616 | { | 1633 | { |
@@ -2189,6 +2206,7 @@ static struct usb_request *ep_alloc_request(struct usb_ep *ep, gfp_t gfp_flags) | |||
2189 | mReq = kzalloc(sizeof(struct ci13xxx_req), gfp_flags); | 2206 | mReq = kzalloc(sizeof(struct ci13xxx_req), gfp_flags); |
2190 | if (mReq != NULL) { | 2207 | if (mReq != NULL) { |
2191 | INIT_LIST_HEAD(&mReq->queue); | 2208 | INIT_LIST_HEAD(&mReq->queue); |
2209 | mReq->req.dma = DMA_ADDR_INVALID; | ||
2192 | 2210 | ||
2193 | mReq->ptr = dma_pool_alloc(mEp->td_pool, gfp_flags, | 2211 | mReq->ptr = dma_pool_alloc(mEp->td_pool, gfp_flags, |
2194 | &mReq->dma); | 2212 | &mReq->dma); |
@@ -2328,7 +2346,7 @@ static int ep_dequeue(struct usb_ep *ep, struct usb_request *req) | |||
2328 | if (mReq->map) { | 2346 | if (mReq->map) { |
2329 | dma_unmap_single(mEp->device, mReq->req.dma, mReq->req.length, | 2347 | dma_unmap_single(mEp->device, mReq->req.dma, mReq->req.length, |
2330 | mEp->dir ? DMA_TO_DEVICE : DMA_FROM_DEVICE); | 2348 | mEp->dir ? DMA_TO_DEVICE : DMA_FROM_DEVICE); |
2331 | mReq->req.dma = 0; | 2349 | mReq->req.dma = DMA_ADDR_INVALID; |
2332 | mReq->map = 0; | 2350 | mReq->map = 0; |
2333 | } | 2351 | } |
2334 | req->status = -ECONNRESET; | 2352 | req->status = -ECONNRESET; |
@@ -2500,12 +2518,12 @@ static int ci13xxx_wakeup(struct usb_gadget *_gadget) | |||
2500 | spin_lock_irqsave(udc->lock, flags); | 2518 | spin_lock_irqsave(udc->lock, flags); |
2501 | if (!udc->remote_wakeup) { | 2519 | if (!udc->remote_wakeup) { |
2502 | ret = -EOPNOTSUPP; | 2520 | ret = -EOPNOTSUPP; |
2503 | dbg_trace("remote wakeup feature is not enabled\n"); | 2521 | trace("remote wakeup feature is not enabled\n"); |
2504 | goto out; | 2522 | goto out; |
2505 | } | 2523 | } |
2506 | if (!hw_cread(CAP_PORTSC, PORTSC_SUSP)) { | 2524 | if (!hw_cread(CAP_PORTSC, PORTSC_SUSP)) { |
2507 | ret = -EINVAL; | 2525 | ret = -EINVAL; |
2508 | dbg_trace("port is not suspended\n"); | 2526 | trace("port is not suspended\n"); |
2509 | goto out; | 2527 | goto out; |
2510 | } | 2528 | } |
2511 | hw_cwrite(CAP_PORTSC, PORTSC_FPR, PORTSC_FPR); | 2529 | hw_cwrite(CAP_PORTSC, PORTSC_FPR, PORTSC_FPR); |
@@ -2560,9 +2578,7 @@ static int ci13xxx_start(struct usb_gadget_driver *driver, | |||
2560 | if (driver == NULL || | 2578 | if (driver == NULL || |
2561 | bind == NULL || | 2579 | bind == NULL || |
2562 | driver->setup == NULL || | 2580 | driver->setup == NULL || |
2563 | driver->disconnect == NULL || | 2581 | driver->disconnect == NULL) |
2564 | driver->suspend == NULL || | ||
2565 | driver->resume == NULL) | ||
2566 | return -EINVAL; | 2582 | return -EINVAL; |
2567 | else if (udc == NULL) | 2583 | else if (udc == NULL) |
2568 | return -ENODEV; | 2584 | return -ENODEV; |
@@ -2690,8 +2706,6 @@ static int ci13xxx_stop(struct usb_gadget_driver *driver) | |||
2690 | driver->unbind == NULL || | 2706 | driver->unbind == NULL || |
2691 | driver->setup == NULL || | 2707 | driver->setup == NULL || |
2692 | driver->disconnect == NULL || | 2708 | driver->disconnect == NULL || |
2693 | driver->suspend == NULL || | ||
2694 | driver->resume == NULL || | ||
2695 | driver != udc->driver) | 2709 | driver != udc->driver) |
2696 | return -EINVAL; | 2710 | return -EINVAL; |
2697 | 2711 | ||
@@ -2703,7 +2717,9 @@ static int ci13xxx_stop(struct usb_gadget_driver *driver) | |||
2703 | if (udc->udc_driver->notify_event) | 2717 | if (udc->udc_driver->notify_event) |
2704 | udc->udc_driver->notify_event(udc, | 2718 | udc->udc_driver->notify_event(udc, |
2705 | CI13XXX_CONTROLLER_STOPPED_EVENT); | 2719 | CI13XXX_CONTROLLER_STOPPED_EVENT); |
2720 | spin_unlock_irqrestore(udc->lock, flags); | ||
2706 | _gadget_stop_activity(&udc->gadget); | 2721 | _gadget_stop_activity(&udc->gadget); |
2722 | spin_lock_irqsave(udc->lock, flags); | ||
2707 | pm_runtime_put(&udc->gadget.dev); | 2723 | pm_runtime_put(&udc->gadget.dev); |
2708 | } | 2724 | } |
2709 | 2725 | ||
@@ -2788,7 +2804,7 @@ static irqreturn_t udc_irq(void) | |||
2788 | isr_statistics.pci++; | 2804 | isr_statistics.pci++; |
2789 | udc->gadget.speed = hw_port_is_high_speed() ? | 2805 | udc->gadget.speed = hw_port_is_high_speed() ? |
2790 | USB_SPEED_HIGH : USB_SPEED_FULL; | 2806 | USB_SPEED_HIGH : USB_SPEED_FULL; |
2791 | if (udc->suspended) { | 2807 | if (udc->suspended && udc->driver->resume) { |
2792 | spin_unlock(udc->lock); | 2808 | spin_unlock(udc->lock); |
2793 | udc->driver->resume(&udc->gadget); | 2809 | udc->driver->resume(&udc->gadget); |
2794 | spin_lock(udc->lock); | 2810 | spin_lock(udc->lock); |
@@ -2802,7 +2818,8 @@ static irqreturn_t udc_irq(void) | |||
2802 | isr_tr_complete_handler(udc); | 2818 | isr_tr_complete_handler(udc); |
2803 | } | 2819 | } |
2804 | if (USBi_SLI & intr) { | 2820 | if (USBi_SLI & intr) { |
2805 | if (udc->gadget.speed != USB_SPEED_UNKNOWN) { | 2821 | if (udc->gadget.speed != USB_SPEED_UNKNOWN && |
2822 | udc->driver->suspend) { | ||
2806 | udc->suspended = 1; | 2823 | udc->suspended = 1; |
2807 | spin_unlock(udc->lock); | 2824 | spin_unlock(udc->lock); |
2808 | udc->driver->suspend(&udc->gadget); | 2825 | udc->driver->suspend(&udc->gadget); |
@@ -2850,7 +2867,7 @@ static int udc_probe(struct ci13xxx_udc_driver *driver, struct device *dev, | |||
2850 | struct ci13xxx *udc; | 2867 | struct ci13xxx *udc; |
2851 | int retval = 0; | 2868 | int retval = 0; |
2852 | 2869 | ||
2853 | trace("%p, %p, %p", dev, regs, name); | 2870 | trace("%p, %p, %p", dev, regs, driver->name); |
2854 | 2871 | ||
2855 | if (dev == NULL || regs == NULL || driver == NULL || | 2872 | if (dev == NULL || regs == NULL || driver == NULL || |
2856 | driver->name == NULL) | 2873 | driver->name == NULL) |
@@ -2866,7 +2883,7 @@ static int udc_probe(struct ci13xxx_udc_driver *driver, struct device *dev, | |||
2866 | 2883 | ||
2867 | udc->gadget.ops = &usb_gadget_ops; | 2884 | udc->gadget.ops = &usb_gadget_ops; |
2868 | udc->gadget.speed = USB_SPEED_UNKNOWN; | 2885 | udc->gadget.speed = USB_SPEED_UNKNOWN; |
2869 | udc->gadget.is_dualspeed = 1; | 2886 | udc->gadget.max_speed = USB_SPEED_HIGH; |
2870 | udc->gadget.is_otg = 0; | 2887 | udc->gadget.is_otg = 0; |
2871 | udc->gadget.name = driver->name; | 2888 | udc->gadget.name = driver->name; |
2872 | 2889 | ||
diff --git a/drivers/usb/gadget/ci13xxx_udc.h b/drivers/usb/gadget/ci13xxx_udc.h index 23707775cb43..f4871e1fac59 100644 --- a/drivers/usb/gadget/ci13xxx_udc.h +++ b/drivers/usb/gadget/ci13xxx_udc.h | |||
@@ -127,7 +127,7 @@ struct ci13xxx { | |||
127 | struct ci13xxx_ep ci13xxx_ep[ENDPT_MAX]; /* extended endpts */ | 127 | struct ci13xxx_ep ci13xxx_ep[ENDPT_MAX]; /* extended endpts */ |
128 | u32 ep0_dir; /* ep0 direction */ | 128 | u32 ep0_dir; /* ep0 direction */ |
129 | #define ep0out ci13xxx_ep[0] | 129 | #define ep0out ci13xxx_ep[0] |
130 | #define ep0in ci13xxx_ep[16] | 130 | #define ep0in ci13xxx_ep[hw_ep_max / 2] |
131 | u8 remote_wakeup; /* Is remote wakeup feature | 131 | u8 remote_wakeup; /* Is remote wakeup feature |
132 | enabled by the host? */ | 132 | enabled by the host? */ |
133 | u8 suspended; /* suspended by the host */ | 133 | u8 suspended; /* suspended by the host */ |
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index f71b0787983f..a95de6a4a134 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c | |||
@@ -1535,9 +1535,9 @@ composite_resume(struct usb_gadget *gadget) | |||
1535 | 1535 | ||
1536 | static struct usb_gadget_driver composite_driver = { | 1536 | static struct usb_gadget_driver composite_driver = { |
1537 | #ifdef CONFIG_USB_GADGET_SUPERSPEED | 1537 | #ifdef CONFIG_USB_GADGET_SUPERSPEED |
1538 | .speed = USB_SPEED_SUPER, | 1538 | .max_speed = USB_SPEED_SUPER, |
1539 | #else | 1539 | #else |
1540 | .speed = USB_SPEED_HIGH, | 1540 | .max_speed = USB_SPEED_HIGH, |
1541 | #endif | 1541 | #endif |
1542 | 1542 | ||
1543 | .unbind = composite_unbind, | 1543 | .unbind = composite_unbind, |
@@ -1584,8 +1584,8 @@ int usb_composite_probe(struct usb_composite_driver *driver, | |||
1584 | driver->iProduct = driver->name; | 1584 | driver->iProduct = driver->name; |
1585 | composite_driver.function = (char *) driver->name; | 1585 | composite_driver.function = (char *) driver->name; |
1586 | composite_driver.driver.name = driver->name; | 1586 | composite_driver.driver.name = driver->name; |
1587 | composite_driver.speed = min((u8)composite_driver.speed, | 1587 | composite_driver.max_speed = |
1588 | (u8)driver->max_speed); | 1588 | min_t(u8, composite_driver.max_speed, driver->max_speed); |
1589 | composite = driver; | 1589 | composite = driver; |
1590 | composite_gadget_bind = bind; | 1590 | composite_gadget_bind = bind; |
1591 | 1591 | ||
diff --git a/drivers/usb/gadget/dbgp.c b/drivers/usb/gadget/dbgp.c index 6256420089f3..19d7bb0df75a 100644 --- a/drivers/usb/gadget/dbgp.c +++ b/drivers/usb/gadget/dbgp.c | |||
@@ -404,7 +404,7 @@ fail: | |||
404 | 404 | ||
405 | static struct usb_gadget_driver dbgp_driver = { | 405 | static struct usb_gadget_driver dbgp_driver = { |
406 | .function = "dbgp", | 406 | .function = "dbgp", |
407 | .speed = USB_SPEED_HIGH, | 407 | .max_speed = USB_SPEED_HIGH, |
408 | .unbind = dbgp_unbind, | 408 | .unbind = dbgp_unbind, |
409 | .setup = dbgp_setup, | 409 | .setup = dbgp_setup, |
410 | .disconnect = dbgp_disconnect, | 410 | .disconnect = dbgp_disconnect, |
diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c index ab8f1b488d54..db815c2da7ed 100644 --- a/drivers/usb/gadget/dummy_hcd.c +++ b/drivers/usb/gadget/dummy_hcd.c | |||
@@ -823,19 +823,18 @@ static int dummy_pullup (struct usb_gadget *_gadget, int value) | |||
823 | 823 | ||
824 | if (value && dum->driver) { | 824 | if (value && dum->driver) { |
825 | if (mod_data.is_super_speed) | 825 | if (mod_data.is_super_speed) |
826 | dum->gadget.speed = dum->driver->speed; | 826 | dum->gadget.speed = dum->driver->max_speed; |
827 | else if (mod_data.is_high_speed) | 827 | else if (mod_data.is_high_speed) |
828 | dum->gadget.speed = min_t(u8, USB_SPEED_HIGH, | 828 | dum->gadget.speed = min_t(u8, USB_SPEED_HIGH, |
829 | dum->driver->speed); | 829 | dum->driver->max_speed); |
830 | else | 830 | else |
831 | dum->gadget.speed = USB_SPEED_FULL; | 831 | dum->gadget.speed = USB_SPEED_FULL; |
832 | dummy_udc_udpate_ep0(dum); | 832 | dummy_udc_udpate_ep0(dum); |
833 | 833 | ||
834 | if (dum->gadget.speed < dum->driver->speed) | 834 | if (dum->gadget.speed < dum->driver->max_speed) |
835 | dev_dbg(udc_dev(dum), "This device can perform faster" | 835 | dev_dbg(udc_dev(dum), "This device can perform faster" |
836 | " if you connect it to a %s port...\n", | 836 | " if you connect it to a %s port...\n", |
837 | (dum->driver->speed == USB_SPEED_SUPER ? | 837 | usb_speed_string(dum->driver->max_speed)); |
838 | "SuperSpeed" : "HighSpeed")); | ||
839 | } | 838 | } |
840 | dum_hcd = gadget_to_dummy_hcd(_gadget); | 839 | dum_hcd = gadget_to_dummy_hcd(_gadget); |
841 | 840 | ||
@@ -898,7 +897,7 @@ static int dummy_udc_start(struct usb_gadget *g, | |||
898 | struct dummy_hcd *dum_hcd = gadget_to_dummy_hcd(g); | 897 | struct dummy_hcd *dum_hcd = gadget_to_dummy_hcd(g); |
899 | struct dummy *dum = dum_hcd->dum; | 898 | struct dummy *dum = dum_hcd->dum; |
900 | 899 | ||
901 | if (driver->speed == USB_SPEED_UNKNOWN) | 900 | if (driver->max_speed == USB_SPEED_UNKNOWN) |
902 | return -EINVAL; | 901 | return -EINVAL; |
903 | 902 | ||
904 | /* | 903 | /* |
@@ -977,7 +976,7 @@ static int dummy_udc_probe (struct platform_device *pdev) | |||
977 | 976 | ||
978 | dum->gadget.name = gadget_name; | 977 | dum->gadget.name = gadget_name; |
979 | dum->gadget.ops = &dummy_ops; | 978 | dum->gadget.ops = &dummy_ops; |
980 | dum->gadget.is_dualspeed = 1; | 979 | dum->gadget.max_speed = USB_SPEED_SUPER; |
981 | 980 | ||
982 | dev_set_name(&dum->gadget.dev, "gadget"); | 981 | dev_set_name(&dum->gadget.dev, "gadget"); |
983 | dum->gadget.dev.parent = &pdev->dev; | 982 | dum->gadget.dev.parent = &pdev->dev; |
diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c index 596a0b464e61..753aa0683ac1 100644 --- a/drivers/usb/gadget/epautoconf.c +++ b/drivers/usb/gadget/epautoconf.c | |||
@@ -130,9 +130,6 @@ ep_matches ( | |||
130 | num_req_streams = ep_comp->bmAttributes & 0x1f; | 130 | num_req_streams = ep_comp->bmAttributes & 0x1f; |
131 | if (num_req_streams > ep->max_streams) | 131 | if (num_req_streams > ep->max_streams) |
132 | return 0; | 132 | return 0; |
133 | /* Update the ep_comp descriptor if needed */ | ||
134 | if (num_req_streams != ep->max_streams) | ||
135 | ep_comp->bmAttributes = ep->max_streams; | ||
136 | } | 133 | } |
137 | 134 | ||
138 | } | 135 | } |
@@ -152,7 +149,7 @@ ep_matches ( | |||
152 | switch (type) { | 149 | switch (type) { |
153 | case USB_ENDPOINT_XFER_INT: | 150 | case USB_ENDPOINT_XFER_INT: |
154 | /* INT: limit 64 bytes full speed, 1024 high/super speed */ | 151 | /* INT: limit 64 bytes full speed, 1024 high/super speed */ |
155 | if (!gadget->is_dualspeed && max > 64) | 152 | if (!gadget_is_dualspeed(gadget) && max > 64) |
156 | return 0; | 153 | return 0; |
157 | /* FALLTHROUGH */ | 154 | /* FALLTHROUGH */ |
158 | 155 | ||
@@ -160,12 +157,12 @@ ep_matches ( | |||
160 | /* ISO: limit 1023 bytes full speed, 1024 high/super speed */ | 157 | /* ISO: limit 1023 bytes full speed, 1024 high/super speed */ |
161 | if (ep->maxpacket < max) | 158 | if (ep->maxpacket < max) |
162 | return 0; | 159 | return 0; |
163 | if (!gadget->is_dualspeed && max > 1023) | 160 | if (!gadget_is_dualspeed(gadget) && max > 1023) |
164 | return 0; | 161 | return 0; |
165 | 162 | ||
166 | /* BOTH: "high bandwidth" works only at high speed */ | 163 | /* BOTH: "high bandwidth" works only at high speed */ |
167 | if ((desc->wMaxPacketSize & cpu_to_le16(3<<11))) { | 164 | if ((desc->wMaxPacketSize & cpu_to_le16(3<<11))) { |
168 | if (!gadget->is_dualspeed) | 165 | if (!gadget_is_dualspeed(gadget)) |
169 | return 0; | 166 | return 0; |
170 | /* configure your hardware with enough buffering!! */ | 167 | /* configure your hardware with enough buffering!! */ |
171 | } | 168 | } |
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c index 0cd764d59351..a28f6ffcd0f3 100644 --- a/drivers/usb/gadget/ether.c +++ b/drivers/usb/gadget/ether.c | |||
@@ -250,9 +250,9 @@ static struct usb_configuration rndis_config_driver = { | |||
250 | /*-------------------------------------------------------------------------*/ | 250 | /*-------------------------------------------------------------------------*/ |
251 | 251 | ||
252 | #ifdef CONFIG_USB_ETH_EEM | 252 | #ifdef CONFIG_USB_ETH_EEM |
253 | static int use_eem = 1; | 253 | static bool use_eem = 1; |
254 | #else | 254 | #else |
255 | static int use_eem; | 255 | static bool use_eem; |
256 | #endif | 256 | #endif |
257 | module_param(use_eem, bool, 0); | 257 | module_param(use_eem, bool, 0); |
258 | MODULE_PARM_DESC(use_eem, "use CDC EEM mode"); | 258 | MODULE_PARM_DESC(use_eem, "use CDC EEM mode"); |
diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c index acb38004eec0..f63dc6c150d2 100644 --- a/drivers/usb/gadget/f_fs.c +++ b/drivers/usb/gadget/f_fs.c | |||
@@ -1037,7 +1037,6 @@ static int ffs_sb_fill(struct super_block *sb, void *_data, int silent) | |||
1037 | { | 1037 | { |
1038 | struct ffs_sb_fill_data *data = _data; | 1038 | struct ffs_sb_fill_data *data = _data; |
1039 | struct inode *inode; | 1039 | struct inode *inode; |
1040 | struct dentry *d; | ||
1041 | struct ffs_data *ffs; | 1040 | struct ffs_data *ffs; |
1042 | 1041 | ||
1043 | ENTER(); | 1042 | ENTER(); |
@@ -1045,7 +1044,7 @@ static int ffs_sb_fill(struct super_block *sb, void *_data, int silent) | |||
1045 | /* Initialise data */ | 1044 | /* Initialise data */ |
1046 | ffs = ffs_data_new(); | 1045 | ffs = ffs_data_new(); |
1047 | if (unlikely(!ffs)) | 1046 | if (unlikely(!ffs)) |
1048 | goto enomem0; | 1047 | goto Enomem; |
1049 | 1048 | ||
1050 | ffs->sb = sb; | 1049 | ffs->sb = sb; |
1051 | ffs->dev_name = data->dev_name; | 1050 | ffs->dev_name = data->dev_name; |
@@ -1065,26 +1064,21 @@ static int ffs_sb_fill(struct super_block *sb, void *_data, int silent) | |||
1065 | &simple_dir_inode_operations, | 1064 | &simple_dir_inode_operations, |
1066 | &data->perms); | 1065 | &data->perms); |
1067 | if (unlikely(!inode)) | 1066 | if (unlikely(!inode)) |
1068 | goto enomem1; | 1067 | goto Enomem; |
1069 | d = d_alloc_root(inode); | 1068 | sb->s_root = d_alloc_root(inode); |
1070 | if (unlikely(!d)) | 1069 | if (unlikely(!sb->s_root)) { |
1071 | goto enomem2; | 1070 | iput(inode); |
1072 | sb->s_root = d; | 1071 | goto Enomem; |
1072 | } | ||
1073 | 1073 | ||
1074 | /* EP0 file */ | 1074 | /* EP0 file */ |
1075 | if (unlikely(!ffs_sb_create_file(sb, "ep0", ffs, | 1075 | if (unlikely(!ffs_sb_create_file(sb, "ep0", ffs, |
1076 | &ffs_ep0_operations, NULL))) | 1076 | &ffs_ep0_operations, NULL))) |
1077 | goto enomem3; | 1077 | goto Enomem; |
1078 | 1078 | ||
1079 | return 0; | 1079 | return 0; |
1080 | 1080 | ||
1081 | enomem3: | 1081 | Enomem: |
1082 | dput(d); | ||
1083 | enomem2: | ||
1084 | iput(inode); | ||
1085 | enomem1: | ||
1086 | ffs_data_put(ffs); | ||
1087 | enomem0: | ||
1088 | return -ENOMEM; | 1082 | return -ENOMEM; |
1089 | } | 1083 | } |
1090 | 1084 | ||
@@ -1196,14 +1190,11 @@ ffs_fs_mount(struct file_system_type *t, int flags, | |||
1196 | static void | 1190 | static void |
1197 | ffs_fs_kill_sb(struct super_block *sb) | 1191 | ffs_fs_kill_sb(struct super_block *sb) |
1198 | { | 1192 | { |
1199 | void *ptr; | ||
1200 | |||
1201 | ENTER(); | 1193 | ENTER(); |
1202 | 1194 | ||
1203 | kill_litter_super(sb); | 1195 | kill_litter_super(sb); |
1204 | ptr = xchg(&sb->s_fs_info, NULL); | 1196 | if (sb->s_fs_info) |
1205 | if (ptr) | 1197 | ffs_data_put(sb->s_fs_info); |
1206 | ffs_data_put(ptr); | ||
1207 | } | 1198 | } |
1208 | 1199 | ||
1209 | static struct file_system_type ffs_fs_type = { | 1200 | static struct file_system_type ffs_fs_type = { |
@@ -1408,7 +1399,7 @@ static int ffs_epfiles_create(struct ffs_data *ffs) | |||
1408 | ENTER(); | 1399 | ENTER(); |
1409 | 1400 | ||
1410 | count = ffs->eps_count; | 1401 | count = ffs->eps_count; |
1411 | epfiles = kzalloc(count * sizeof *epfiles, GFP_KERNEL); | 1402 | epfiles = kcalloc(count, sizeof(*epfiles), GFP_KERNEL); |
1412 | if (!epfiles) | 1403 | if (!epfiles) |
1413 | return -ENOMEM; | 1404 | return -ENOMEM; |
1414 | 1405 | ||
diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index 52583a235330..6353eca1e852 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c | |||
@@ -624,7 +624,8 @@ static int fsg_setup(struct usb_function *f, | |||
624 | if (ctrl->bRequestType != | 624 | if (ctrl->bRequestType != |
625 | (USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE)) | 625 | (USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE)) |
626 | break; | 626 | break; |
627 | if (w_index != fsg->interface_number || w_value != 0) | 627 | if (w_index != fsg->interface_number || w_value != 0 || |
628 | w_length != 0) | ||
628 | return -EDOM; | 629 | return -EDOM; |
629 | 630 | ||
630 | /* | 631 | /* |
@@ -639,7 +640,8 @@ static int fsg_setup(struct usb_function *f, | |||
639 | if (ctrl->bRequestType != | 640 | if (ctrl->bRequestType != |
640 | (USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE)) | 641 | (USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE)) |
641 | break; | 642 | break; |
642 | if (w_index != fsg->interface_number || w_value != 0) | 643 | if (w_index != fsg->interface_number || w_value != 0 || |
644 | w_length != 1) | ||
643 | return -EDOM; | 645 | return -EDOM; |
644 | VDBG(fsg, "get max LUN\n"); | 646 | VDBG(fsg, "get max LUN\n"); |
645 | *(u8 *)req->buf = fsg->common->nluns - 1; | 647 | *(u8 *)req->buf = fsg->common->nluns - 1; |
@@ -1871,17 +1873,14 @@ static int check_command(struct fsg_common *common, int cmnd_size, | |||
1871 | common->lun, lun); | 1873 | common->lun, lun); |
1872 | 1874 | ||
1873 | /* Check the LUN */ | 1875 | /* Check the LUN */ |
1874 | if (common->lun < common->nluns) { | 1876 | curlun = common->curlun; |
1875 | curlun = &common->luns[common->lun]; | 1877 | if (curlun) { |
1876 | common->curlun = curlun; | ||
1877 | if (common->cmnd[0] != REQUEST_SENSE) { | 1878 | if (common->cmnd[0] != REQUEST_SENSE) { |
1878 | curlun->sense_data = SS_NO_SENSE; | 1879 | curlun->sense_data = SS_NO_SENSE; |
1879 | curlun->sense_data_info = 0; | 1880 | curlun->sense_data_info = 0; |
1880 | curlun->info_valid = 0; | 1881 | curlun->info_valid = 0; |
1881 | } | 1882 | } |
1882 | } else { | 1883 | } else { |
1883 | common->curlun = NULL; | ||
1884 | curlun = NULL; | ||
1885 | common->bad_lun_okay = 0; | 1884 | common->bad_lun_okay = 0; |
1886 | 1885 | ||
1887 | /* | 1886 | /* |
@@ -1927,6 +1926,17 @@ static int check_command(struct fsg_common *common, int cmnd_size, | |||
1927 | return 0; | 1926 | return 0; |
1928 | } | 1927 | } |
1929 | 1928 | ||
1929 | /* wrapper of check_command for data size in blocks handling */ | ||
1930 | static int check_command_size_in_blocks(struct fsg_common *common, | ||
1931 | int cmnd_size, enum data_direction data_dir, | ||
1932 | unsigned int mask, int needs_medium, const char *name) | ||
1933 | { | ||
1934 | if (common->curlun) | ||
1935 | common->data_size_from_cmnd <<= common->curlun->blkbits; | ||
1936 | return check_command(common, cmnd_size, data_dir, | ||
1937 | mask, needs_medium, name); | ||
1938 | } | ||
1939 | |||
1930 | static int do_scsi_command(struct fsg_common *common) | 1940 | static int do_scsi_command(struct fsg_common *common) |
1931 | { | 1941 | { |
1932 | struct fsg_buffhd *bh; | 1942 | struct fsg_buffhd *bh; |
@@ -2009,9 +2019,9 @@ static int do_scsi_command(struct fsg_common *common) | |||
2009 | 2019 | ||
2010 | case READ_6: | 2020 | case READ_6: |
2011 | i = common->cmnd[4]; | 2021 | i = common->cmnd[4]; |
2012 | common->data_size_from_cmnd = (i == 0 ? 256 : i) << | 2022 | common->data_size_from_cmnd = (i == 0) ? 256 : i; |
2013 | common->curlun->blkbits; | 2023 | reply = check_command_size_in_blocks(common, 6, |
2014 | reply = check_command(common, 6, DATA_DIR_TO_HOST, | 2024 | DATA_DIR_TO_HOST, |
2015 | (7<<1) | (1<<4), 1, | 2025 | (7<<1) | (1<<4), 1, |
2016 | "READ(6)"); | 2026 | "READ(6)"); |
2017 | if (reply == 0) | 2027 | if (reply == 0) |
@@ -2020,9 +2030,9 @@ static int do_scsi_command(struct fsg_common *common) | |||
2020 | 2030 | ||
2021 | case READ_10: | 2031 | case READ_10: |
2022 | common->data_size_from_cmnd = | 2032 | common->data_size_from_cmnd = |
2023 | get_unaligned_be16(&common->cmnd[7]) << | 2033 | get_unaligned_be16(&common->cmnd[7]); |
2024 | common->curlun->blkbits; | 2034 | reply = check_command_size_in_blocks(common, 10, |
2025 | reply = check_command(common, 10, DATA_DIR_TO_HOST, | 2035 | DATA_DIR_TO_HOST, |
2026 | (1<<1) | (0xf<<2) | (3<<7), 1, | 2036 | (1<<1) | (0xf<<2) | (3<<7), 1, |
2027 | "READ(10)"); | 2037 | "READ(10)"); |
2028 | if (reply == 0) | 2038 | if (reply == 0) |
@@ -2031,9 +2041,9 @@ static int do_scsi_command(struct fsg_common *common) | |||
2031 | 2041 | ||
2032 | case READ_12: | 2042 | case READ_12: |
2033 | common->data_size_from_cmnd = | 2043 | common->data_size_from_cmnd = |
2034 | get_unaligned_be32(&common->cmnd[6]) << | 2044 | get_unaligned_be32(&common->cmnd[6]); |
2035 | common->curlun->blkbits; | 2045 | reply = check_command_size_in_blocks(common, 12, |
2036 | reply = check_command(common, 12, DATA_DIR_TO_HOST, | 2046 | DATA_DIR_TO_HOST, |
2037 | (1<<1) | (0xf<<2) | (0xf<<6), 1, | 2047 | (1<<1) | (0xf<<2) | (0xf<<6), 1, |
2038 | "READ(12)"); | 2048 | "READ(12)"); |
2039 | if (reply == 0) | 2049 | if (reply == 0) |
@@ -2132,9 +2142,9 @@ static int do_scsi_command(struct fsg_common *common) | |||
2132 | 2142 | ||
2133 | case WRITE_6: | 2143 | case WRITE_6: |
2134 | i = common->cmnd[4]; | 2144 | i = common->cmnd[4]; |
2135 | common->data_size_from_cmnd = (i == 0 ? 256 : i) << | 2145 | common->data_size_from_cmnd = (i == 0) ? 256 : i; |
2136 | common->curlun->blkbits; | 2146 | reply = check_command_size_in_blocks(common, 6, |
2137 | reply = check_command(common, 6, DATA_DIR_FROM_HOST, | 2147 | DATA_DIR_FROM_HOST, |
2138 | (7<<1) | (1<<4), 1, | 2148 | (7<<1) | (1<<4), 1, |
2139 | "WRITE(6)"); | 2149 | "WRITE(6)"); |
2140 | if (reply == 0) | 2150 | if (reply == 0) |
@@ -2143,9 +2153,9 @@ static int do_scsi_command(struct fsg_common *common) | |||
2143 | 2153 | ||
2144 | case WRITE_10: | 2154 | case WRITE_10: |
2145 | common->data_size_from_cmnd = | 2155 | common->data_size_from_cmnd = |
2146 | get_unaligned_be16(&common->cmnd[7]) << | 2156 | get_unaligned_be16(&common->cmnd[7]); |
2147 | common->curlun->blkbits; | 2157 | reply = check_command_size_in_blocks(common, 10, |
2148 | reply = check_command(common, 10, DATA_DIR_FROM_HOST, | 2158 | DATA_DIR_FROM_HOST, |
2149 | (1<<1) | (0xf<<2) | (3<<7), 1, | 2159 | (1<<1) | (0xf<<2) | (3<<7), 1, |
2150 | "WRITE(10)"); | 2160 | "WRITE(10)"); |
2151 | if (reply == 0) | 2161 | if (reply == 0) |
@@ -2154,9 +2164,9 @@ static int do_scsi_command(struct fsg_common *common) | |||
2154 | 2164 | ||
2155 | case WRITE_12: | 2165 | case WRITE_12: |
2156 | common->data_size_from_cmnd = | 2166 | common->data_size_from_cmnd = |
2157 | get_unaligned_be32(&common->cmnd[6]) << | 2167 | get_unaligned_be32(&common->cmnd[6]); |
2158 | common->curlun->blkbits; | 2168 | reply = check_command_size_in_blocks(common, 12, |
2159 | reply = check_command(common, 12, DATA_DIR_FROM_HOST, | 2169 | DATA_DIR_FROM_HOST, |
2160 | (1<<1) | (0xf<<2) | (0xf<<6), 1, | 2170 | (1<<1) | (0xf<<2) | (0xf<<6), 1, |
2161 | "WRITE(12)"); | 2171 | "WRITE(12)"); |
2162 | if (reply == 0) | 2172 | if (reply == 0) |
@@ -2271,6 +2281,10 @@ static int received_cbw(struct fsg_dev *fsg, struct fsg_buffhd *bh) | |||
2271 | if (common->data_size == 0) | 2281 | if (common->data_size == 0) |
2272 | common->data_dir = DATA_DIR_NONE; | 2282 | common->data_dir = DATA_DIR_NONE; |
2273 | common->lun = cbw->Lun; | 2283 | common->lun = cbw->Lun; |
2284 | if (common->lun >= 0 && common->lun < common->nluns) | ||
2285 | common->curlun = &common->luns[common->lun]; | ||
2286 | else | ||
2287 | common->curlun = NULL; | ||
2274 | common->tag = cbw->Tag; | 2288 | common->tag = cbw->Tag; |
2275 | return 0; | 2289 | return 0; |
2276 | } | 2290 | } |
@@ -2761,7 +2775,7 @@ static struct fsg_common *fsg_common_init(struct fsg_common *common, | |||
2761 | * Create the LUNs, open their backing files, and register the | 2775 | * Create the LUNs, open their backing files, and register the |
2762 | * LUN devices in sysfs. | 2776 | * LUN devices in sysfs. |
2763 | */ | 2777 | */ |
2764 | curlun = kzalloc(nluns * sizeof *curlun, GFP_KERNEL); | 2778 | curlun = kcalloc(nluns, sizeof(*curlun), GFP_KERNEL); |
2765 | if (unlikely(!curlun)) { | 2779 | if (unlikely(!curlun)) { |
2766 | rc = -ENOMEM; | 2780 | rc = -ENOMEM; |
2767 | goto error_release; | 2781 | goto error_release; |
@@ -2973,6 +2987,7 @@ static void fsg_unbind(struct usb_configuration *c, struct usb_function *f) | |||
2973 | fsg_common_put(common); | 2987 | fsg_common_put(common); |
2974 | usb_free_descriptors(fsg->function.descriptors); | 2988 | usb_free_descriptors(fsg->function.descriptors); |
2975 | usb_free_descriptors(fsg->function.hs_descriptors); | 2989 | usb_free_descriptors(fsg->function.hs_descriptors); |
2990 | usb_free_descriptors(fsg->function.ss_descriptors); | ||
2976 | kfree(fsg); | 2991 | kfree(fsg); |
2977 | } | 2992 | } |
2978 | 2993 | ||
diff --git a/drivers/usb/gadget/f_midi.c b/drivers/usb/gadget/f_midi.c index 67b222908cf9..3797b3d6c622 100644 --- a/drivers/usb/gadget/f_midi.c +++ b/drivers/usb/gadget/f_midi.c | |||
@@ -95,7 +95,6 @@ static void f_midi_transmit(struct f_midi *midi, struct usb_request *req); | |||
95 | 95 | ||
96 | DECLARE_UAC_AC_HEADER_DESCRIPTOR(1); | 96 | DECLARE_UAC_AC_HEADER_DESCRIPTOR(1); |
97 | DECLARE_USB_MIDI_OUT_JACK_DESCRIPTOR(1); | 97 | DECLARE_USB_MIDI_OUT_JACK_DESCRIPTOR(1); |
98 | DECLARE_USB_MIDI_OUT_JACK_DESCRIPTOR(16); | ||
99 | DECLARE_USB_MS_ENDPOINT_DESCRIPTOR(16); | 98 | DECLARE_USB_MS_ENDPOINT_DESCRIPTOR(16); |
100 | 99 | ||
101 | /* B.3.1 Standard AC Interface Descriptor */ | 100 | /* B.3.1 Standard AC Interface Descriptor */ |
@@ -140,26 +139,6 @@ static struct usb_ms_header_descriptor ms_header_desc __initdata = { | |||
140 | /* .wTotalLength = DYNAMIC */ | 139 | /* .wTotalLength = DYNAMIC */ |
141 | }; | 140 | }; |
142 | 141 | ||
143 | /* B.4.3 Embedded MIDI IN Jack Descriptor */ | ||
144 | static struct usb_midi_in_jack_descriptor jack_in_emb_desc = { | ||
145 | .bLength = USB_DT_MIDI_IN_SIZE, | ||
146 | .bDescriptorType = USB_DT_CS_INTERFACE, | ||
147 | .bDescriptorSubtype = USB_MS_MIDI_IN_JACK, | ||
148 | .bJackType = USB_MS_EMBEDDED, | ||
149 | /* .bJackID = DYNAMIC */ | ||
150 | }; | ||
151 | |||
152 | /* B.4.4 Embedded MIDI OUT Jack Descriptor */ | ||
153 | static struct usb_midi_out_jack_descriptor_16 jack_out_emb_desc = { | ||
154 | /* .bLength = DYNAMIC */ | ||
155 | .bDescriptorType = USB_DT_CS_INTERFACE, | ||
156 | .bDescriptorSubtype = USB_MS_MIDI_OUT_JACK, | ||
157 | .bJackType = USB_MS_EMBEDDED, | ||
158 | /* .bJackID = DYNAMIC */ | ||
159 | /* .bNrInputPins = DYNAMIC */ | ||
160 | /* .pins = DYNAMIC */ | ||
161 | }; | ||
162 | |||
163 | /* B.5.1 Standard Bulk OUT Endpoint Descriptor */ | 142 | /* B.5.1 Standard Bulk OUT Endpoint Descriptor */ |
164 | static struct usb_endpoint_descriptor bulk_out_desc = { | 143 | static struct usb_endpoint_descriptor bulk_out_desc = { |
165 | .bLength = USB_DT_ENDPOINT_AUDIO_SIZE, | 144 | .bLength = USB_DT_ENDPOINT_AUDIO_SIZE, |
@@ -758,9 +737,11 @@ fail: | |||
758 | static int __init | 737 | static int __init |
759 | f_midi_bind(struct usb_configuration *c, struct usb_function *f) | 738 | f_midi_bind(struct usb_configuration *c, struct usb_function *f) |
760 | { | 739 | { |
761 | struct usb_descriptor_header *midi_function[(MAX_PORTS * 2) + 12]; | 740 | struct usb_descriptor_header **midi_function; |
762 | struct usb_midi_in_jack_descriptor jack_in_ext_desc[MAX_PORTS]; | 741 | struct usb_midi_in_jack_descriptor jack_in_ext_desc[MAX_PORTS]; |
742 | struct usb_midi_in_jack_descriptor jack_in_emb_desc[MAX_PORTS]; | ||
763 | struct usb_midi_out_jack_descriptor_1 jack_out_ext_desc[MAX_PORTS]; | 743 | struct usb_midi_out_jack_descriptor_1 jack_out_ext_desc[MAX_PORTS]; |
744 | struct usb_midi_out_jack_descriptor_1 jack_out_emb_desc[MAX_PORTS]; | ||
764 | struct usb_composite_dev *cdev = c->cdev; | 745 | struct usb_composite_dev *cdev = c->cdev; |
765 | struct f_midi *midi = func_to_midi(f); | 746 | struct f_midi *midi = func_to_midi(f); |
766 | int status, n, jack = 1, i = 0; | 747 | int status, n, jack = 1, i = 0; |
@@ -798,6 +779,14 @@ f_midi_bind(struct usb_configuration *c, struct usb_function *f) | |||
798 | goto fail; | 779 | goto fail; |
799 | midi->out_ep->driver_data = cdev; /* claim */ | 780 | midi->out_ep->driver_data = cdev; /* claim */ |
800 | 781 | ||
782 | /* allocate temporary function list */ | ||
783 | midi_function = kcalloc((MAX_PORTS * 4) + 9, sizeof(midi_function), | ||
784 | GFP_KERNEL); | ||
785 | if (!midi_function) { | ||
786 | status = -ENOMEM; | ||
787 | goto fail; | ||
788 | } | ||
789 | |||
801 | /* | 790 | /* |
802 | * construct the function's descriptor set. As the number of | 791 | * construct the function's descriptor set. As the number of |
803 | * input and output MIDI ports is configurable, we have to do | 792 | * input and output MIDI ports is configurable, we have to do |
@@ -811,73 +800,74 @@ f_midi_bind(struct usb_configuration *c, struct usb_function *f) | |||
811 | 800 | ||
812 | /* calculate the header's wTotalLength */ | 801 | /* calculate the header's wTotalLength */ |
813 | n = USB_DT_MS_HEADER_SIZE | 802 | n = USB_DT_MS_HEADER_SIZE |
814 | + (1 + midi->in_ports) * USB_DT_MIDI_IN_SIZE | 803 | + (midi->in_ports + midi->out_ports) * |
815 | + (1 + midi->out_ports) * USB_DT_MIDI_OUT_SIZE(1); | 804 | (USB_DT_MIDI_IN_SIZE + USB_DT_MIDI_OUT_SIZE(1)); |
816 | ms_header_desc.wTotalLength = cpu_to_le16(n); | 805 | ms_header_desc.wTotalLength = cpu_to_le16(n); |
817 | 806 | ||
818 | midi_function[i++] = (struct usb_descriptor_header *) &ms_header_desc; | 807 | midi_function[i++] = (struct usb_descriptor_header *) &ms_header_desc; |
819 | 808 | ||
820 | /* we have one embedded IN jack */ | 809 | /* configure the external IN jacks, each linked to an embedded OUT jack */ |
821 | jack_in_emb_desc.bJackID = jack++; | ||
822 | midi_function[i++] = (struct usb_descriptor_header *) &jack_in_emb_desc; | ||
823 | |||
824 | /* and a dynamic amount of external IN jacks */ | ||
825 | for (n = 0; n < midi->in_ports; n++) { | ||
826 | struct usb_midi_in_jack_descriptor *ext = &jack_in_ext_desc[n]; | ||
827 | |||
828 | ext->bLength = USB_DT_MIDI_IN_SIZE; | ||
829 | ext->bDescriptorType = USB_DT_CS_INTERFACE; | ||
830 | ext->bDescriptorSubtype = USB_MS_MIDI_IN_JACK; | ||
831 | ext->bJackType = USB_MS_EXTERNAL; | ||
832 | ext->bJackID = jack++; | ||
833 | ext->iJack = 0; | ||
834 | |||
835 | midi_function[i++] = (struct usb_descriptor_header *) ext; | ||
836 | } | ||
837 | |||
838 | /* one embedded OUT jack ... */ | ||
839 | jack_out_emb_desc.bLength = USB_DT_MIDI_OUT_SIZE(midi->in_ports); | ||
840 | jack_out_emb_desc.bJackID = jack++; | ||
841 | jack_out_emb_desc.bNrInputPins = midi->in_ports; | ||
842 | /* ... which referencess all external IN jacks */ | ||
843 | for (n = 0; n < midi->in_ports; n++) { | 810 | for (n = 0; n < midi->in_ports; n++) { |
844 | jack_out_emb_desc.pins[n].baSourceID = jack_in_ext_desc[n].bJackID; | 811 | struct usb_midi_in_jack_descriptor *in_ext = &jack_in_ext_desc[n]; |
845 | jack_out_emb_desc.pins[n].baSourcePin = 1; | 812 | struct usb_midi_out_jack_descriptor_1 *out_emb = &jack_out_emb_desc[n]; |
813 | |||
814 | in_ext->bLength = USB_DT_MIDI_IN_SIZE; | ||
815 | in_ext->bDescriptorType = USB_DT_CS_INTERFACE; | ||
816 | in_ext->bDescriptorSubtype = USB_MS_MIDI_IN_JACK; | ||
817 | in_ext->bJackType = USB_MS_EXTERNAL; | ||
818 | in_ext->bJackID = jack++; | ||
819 | in_ext->iJack = 0; | ||
820 | midi_function[i++] = (struct usb_descriptor_header *) in_ext; | ||
821 | |||
822 | out_emb->bLength = USB_DT_MIDI_OUT_SIZE(1); | ||
823 | out_emb->bDescriptorType = USB_DT_CS_INTERFACE; | ||
824 | out_emb->bDescriptorSubtype = USB_MS_MIDI_OUT_JACK; | ||
825 | out_emb->bJackType = USB_MS_EMBEDDED; | ||
826 | out_emb->bJackID = jack++; | ||
827 | out_emb->bNrInputPins = 1; | ||
828 | out_emb->pins[0].baSourcePin = 1; | ||
829 | out_emb->pins[0].baSourceID = in_ext->bJackID; | ||
830 | out_emb->iJack = 0; | ||
831 | midi_function[i++] = (struct usb_descriptor_header *) out_emb; | ||
832 | |||
833 | /* link it to the endpoint */ | ||
834 | ms_in_desc.baAssocJackID[n] = out_emb->bJackID; | ||
846 | } | 835 | } |
847 | 836 | ||
848 | midi_function[i++] = (struct usb_descriptor_header *) &jack_out_emb_desc; | 837 | /* configure the external OUT jacks, each linked to an embedded IN jack */ |
849 | |||
850 | /* and multiple external OUT jacks ... */ | ||
851 | for (n = 0; n < midi->out_ports; n++) { | 838 | for (n = 0; n < midi->out_ports; n++) { |
852 | struct usb_midi_out_jack_descriptor_1 *ext = &jack_out_ext_desc[n]; | 839 | struct usb_midi_in_jack_descriptor *in_emb = &jack_in_emb_desc[n]; |
853 | int m; | 840 | struct usb_midi_out_jack_descriptor_1 *out_ext = &jack_out_ext_desc[n]; |
854 | 841 | ||
855 | ext->bLength = USB_DT_MIDI_OUT_SIZE(1); | 842 | in_emb->bLength = USB_DT_MIDI_IN_SIZE; |
856 | ext->bDescriptorType = USB_DT_CS_INTERFACE; | 843 | in_emb->bDescriptorType = USB_DT_CS_INTERFACE; |
857 | ext->bDescriptorSubtype = USB_MS_MIDI_OUT_JACK; | 844 | in_emb->bDescriptorSubtype = USB_MS_MIDI_IN_JACK; |
858 | ext->bJackType = USB_MS_EXTERNAL; | 845 | in_emb->bJackType = USB_MS_EMBEDDED; |
859 | ext->bJackID = jack++; | 846 | in_emb->bJackID = jack++; |
860 | ext->bNrInputPins = 1; | 847 | in_emb->iJack = 0; |
861 | ext->iJack = 0; | 848 | midi_function[i++] = (struct usb_descriptor_header *) in_emb; |
862 | /* ... which all reference the same embedded IN jack */ | 849 | |
863 | for (m = 0; m < midi->out_ports; m++) { | 850 | out_ext->bLength = USB_DT_MIDI_OUT_SIZE(1); |
864 | ext->pins[m].baSourceID = jack_in_emb_desc.bJackID; | 851 | out_ext->bDescriptorType = USB_DT_CS_INTERFACE; |
865 | ext->pins[m].baSourcePin = 1; | 852 | out_ext->bDescriptorSubtype = USB_MS_MIDI_OUT_JACK; |
866 | } | 853 | out_ext->bJackType = USB_MS_EXTERNAL; |
867 | 854 | out_ext->bJackID = jack++; | |
868 | midi_function[i++] = (struct usb_descriptor_header *) ext; | 855 | out_ext->bNrInputPins = 1; |
856 | out_ext->iJack = 0; | ||
857 | out_ext->pins[0].baSourceID = in_emb->bJackID; | ||
858 | out_ext->pins[0].baSourcePin = 1; | ||
859 | midi_function[i++] = (struct usb_descriptor_header *) out_ext; | ||
860 | |||
861 | /* link it to the endpoint */ | ||
862 | ms_out_desc.baAssocJackID[n] = in_emb->bJackID; | ||
869 | } | 863 | } |
870 | 864 | ||
871 | /* configure the endpoint descriptors ... */ | 865 | /* configure the endpoint descriptors ... */ |
872 | ms_out_desc.bLength = USB_DT_MS_ENDPOINT_SIZE(midi->in_ports); | 866 | ms_out_desc.bLength = USB_DT_MS_ENDPOINT_SIZE(midi->in_ports); |
873 | ms_out_desc.bNumEmbMIDIJack = midi->in_ports; | 867 | ms_out_desc.bNumEmbMIDIJack = midi->in_ports; |
874 | for (n = 0; n < midi->in_ports; n++) | ||
875 | ms_out_desc.baAssocJackID[n] = jack_in_emb_desc.bJackID; | ||
876 | 868 | ||
877 | ms_in_desc.bLength = USB_DT_MS_ENDPOINT_SIZE(midi->out_ports); | 869 | ms_in_desc.bLength = USB_DT_MS_ENDPOINT_SIZE(midi->out_ports); |
878 | ms_in_desc.bNumEmbMIDIJack = midi->out_ports; | 870 | ms_in_desc.bNumEmbMIDIJack = midi->out_ports; |
879 | for (n = 0; n < midi->out_ports; n++) | ||
880 | ms_in_desc.baAssocJackID[n] = jack_out_emb_desc.bJackID; | ||
881 | 871 | ||
882 | /* ... and add them to the list */ | 872 | /* ... and add them to the list */ |
883 | midi_function[i++] = (struct usb_descriptor_header *) &bulk_out_desc; | 873 | midi_function[i++] = (struct usb_descriptor_header *) &bulk_out_desc; |
@@ -901,6 +891,8 @@ f_midi_bind(struct usb_configuration *c, struct usb_function *f) | |||
901 | f->descriptors = usb_copy_descriptors(midi_function); | 891 | f->descriptors = usb_copy_descriptors(midi_function); |
902 | } | 892 | } |
903 | 893 | ||
894 | kfree(midi_function); | ||
895 | |||
904 | return 0; | 896 | return 0; |
905 | 897 | ||
906 | fail: | 898 | fail: |
diff --git a/drivers/usb/gadget/f_phonet.c b/drivers/usb/gadget/f_phonet.c index 349077033338..7cdcb63b21ff 100644 --- a/drivers/usb/gadget/f_phonet.c +++ b/drivers/usb/gadget/f_phonet.c | |||
@@ -298,11 +298,10 @@ static void pn_net_setup(struct net_device *dev) | |||
298 | static int | 298 | static int |
299 | pn_rx_submit(struct f_phonet *fp, struct usb_request *req, gfp_t gfp_flags) | 299 | pn_rx_submit(struct f_phonet *fp, struct usb_request *req, gfp_t gfp_flags) |
300 | { | 300 | { |
301 | struct net_device *dev = fp->dev; | ||
302 | struct page *page; | 301 | struct page *page; |
303 | int err; | 302 | int err; |
304 | 303 | ||
305 | page = __netdev_alloc_page(dev, gfp_flags); | 304 | page = alloc_page(gfp_flags); |
306 | if (!page) | 305 | if (!page) |
307 | return -ENOMEM; | 306 | return -ENOMEM; |
308 | 307 | ||
@@ -312,7 +311,7 @@ pn_rx_submit(struct f_phonet *fp, struct usb_request *req, gfp_t gfp_flags) | |||
312 | 311 | ||
313 | err = usb_ep_queue(fp->out_ep, req, gfp_flags); | 312 | err = usb_ep_queue(fp->out_ep, req, gfp_flags); |
314 | if (unlikely(err)) | 313 | if (unlikely(err)) |
315 | netdev_free_page(dev, page); | 314 | put_page(page); |
316 | return err; | 315 | return err; |
317 | } | 316 | } |
318 | 317 | ||
@@ -346,7 +345,7 @@ static void pn_rx_complete(struct usb_ep *ep, struct usb_request *req) | |||
346 | } | 345 | } |
347 | 346 | ||
348 | skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, page, | 347 | skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, page, |
349 | skb->len == 0, req->actual); | 348 | skb->len <= 1, req->actual); |
350 | page = NULL; | 349 | page = NULL; |
351 | 350 | ||
352 | if (req->actual < req->length) { /* Last fragment */ | 351 | if (req->actual < req->length) { /* Last fragment */ |
@@ -374,9 +373,9 @@ static void pn_rx_complete(struct usb_ep *ep, struct usb_request *req) | |||
374 | } | 373 | } |
375 | 374 | ||
376 | if (page) | 375 | if (page) |
377 | netdev_free_page(dev, page); | 376 | put_page(page); |
378 | if (req) | 377 | if (req) |
379 | pn_rx_submit(fp, req, GFP_ATOMIC); | 378 | pn_rx_submit(fp, req, GFP_ATOMIC | __GFP_COLD); |
380 | } | 379 | } |
381 | 380 | ||
382 | /*-------------------------------------------------------------------------*/ | 381 | /*-------------------------------------------------------------------------*/ |
@@ -436,7 +435,7 @@ static int pn_set_alt(struct usb_function *f, unsigned intf, unsigned alt) | |||
436 | 435 | ||
437 | netif_carrier_on(dev); | 436 | netif_carrier_on(dev); |
438 | for (i = 0; i < phonet_rxq_size; i++) | 437 | for (i = 0; i < phonet_rxq_size; i++) |
439 | pn_rx_submit(fp, fp->out_reqv[i], GFP_ATOMIC); | 438 | pn_rx_submit(fp, fp->out_reqv[i], GFP_ATOMIC | __GFP_COLD); |
440 | } | 439 | } |
441 | spin_unlock(&port->lock); | 440 | spin_unlock(&port->lock); |
442 | return 0; | 441 | return 0; |
diff --git a/drivers/usb/gadget/f_serial.c b/drivers/usb/gadget/f_serial.c index 91fdf790ed20..cf33a8d0fd5d 100644 --- a/drivers/usb/gadget/f_serial.c +++ b/drivers/usb/gadget/f_serial.c | |||
@@ -131,8 +131,8 @@ static int gser_set_alt(struct usb_function *f, unsigned intf, unsigned alt) | |||
131 | } | 131 | } |
132 | if (!gser->port.in->desc || !gser->port.out->desc) { | 132 | if (!gser->port.in->desc || !gser->port.out->desc) { |
133 | DBG(cdev, "activate generic ttyGS%d\n", gser->port_num); | 133 | DBG(cdev, "activate generic ttyGS%d\n", gser->port_num); |
134 | if (!config_ep_by_speed(cdev->gadget, f, gser->port.in) || | 134 | if (config_ep_by_speed(cdev->gadget, f, gser->port.in) || |
135 | !config_ep_by_speed(cdev->gadget, f, gser->port.out)) { | 135 | config_ep_by_speed(cdev->gadget, f, gser->port.out)) { |
136 | gser->port.in->desc = NULL; | 136 | gser->port.in->desc = NULL; |
137 | gser->port.out->desc = NULL; | 137 | gser->port.out->desc = NULL; |
138 | return -EINVAL; | 138 | return -EINVAL; |
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c index f7e39b0365ce..47766f0e7caa 100644 --- a/drivers/usb/gadget/file_storage.c +++ b/drivers/usb/gadget/file_storage.c | |||
@@ -303,16 +303,16 @@ MODULE_LICENSE("Dual BSD/GPL"); | |||
303 | static struct { | 303 | static struct { |
304 | char *file[FSG_MAX_LUNS]; | 304 | char *file[FSG_MAX_LUNS]; |
305 | char *serial; | 305 | char *serial; |
306 | int ro[FSG_MAX_LUNS]; | 306 | bool ro[FSG_MAX_LUNS]; |
307 | int nofua[FSG_MAX_LUNS]; | 307 | bool nofua[FSG_MAX_LUNS]; |
308 | unsigned int num_filenames; | 308 | unsigned int num_filenames; |
309 | unsigned int num_ros; | 309 | unsigned int num_ros; |
310 | unsigned int num_nofuas; | 310 | unsigned int num_nofuas; |
311 | unsigned int nluns; | 311 | unsigned int nluns; |
312 | 312 | ||
313 | int removable; | 313 | bool removable; |
314 | int can_stall; | 314 | bool can_stall; |
315 | int cdrom; | 315 | bool cdrom; |
316 | 316 | ||
317 | char *transport_parm; | 317 | char *transport_parm; |
318 | char *protocol_parm; | 318 | char *protocol_parm; |
@@ -859,7 +859,7 @@ static int class_setup_req(struct fsg_dev *fsg, | |||
859 | if (ctrl->bRequestType != (USB_DIR_OUT | | 859 | if (ctrl->bRequestType != (USB_DIR_OUT | |
860 | USB_TYPE_CLASS | USB_RECIP_INTERFACE)) | 860 | USB_TYPE_CLASS | USB_RECIP_INTERFACE)) |
861 | break; | 861 | break; |
862 | if (w_index != 0 || w_value != 0) { | 862 | if (w_index != 0 || w_value != 0 || w_length != 0) { |
863 | value = -EDOM; | 863 | value = -EDOM; |
864 | break; | 864 | break; |
865 | } | 865 | } |
@@ -875,7 +875,7 @@ static int class_setup_req(struct fsg_dev *fsg, | |||
875 | if (ctrl->bRequestType != (USB_DIR_IN | | 875 | if (ctrl->bRequestType != (USB_DIR_IN | |
876 | USB_TYPE_CLASS | USB_RECIP_INTERFACE)) | 876 | USB_TYPE_CLASS | USB_RECIP_INTERFACE)) |
877 | break; | 877 | break; |
878 | if (w_index != 0 || w_value != 0) { | 878 | if (w_index != 0 || w_value != 0 || w_length != 1) { |
879 | value = -EDOM; | 879 | value = -EDOM; |
880 | break; | 880 | break; |
881 | } | 881 | } |
@@ -2297,19 +2297,17 @@ static int check_command(struct fsg_dev *fsg, int cmnd_size, | |||
2297 | DBG(fsg, "using LUN %d from CBW, " | 2297 | DBG(fsg, "using LUN %d from CBW, " |
2298 | "not LUN %d from CDB\n", | 2298 | "not LUN %d from CDB\n", |
2299 | fsg->lun, lun); | 2299 | fsg->lun, lun); |
2300 | } else | 2300 | } |
2301 | fsg->lun = lun; // Use LUN from the command | ||
2302 | 2301 | ||
2303 | /* Check the LUN */ | 2302 | /* Check the LUN */ |
2304 | if (fsg->lun < fsg->nluns) { | 2303 | curlun = fsg->curlun; |
2305 | fsg->curlun = curlun = &fsg->luns[fsg->lun]; | 2304 | if (curlun) { |
2306 | if (fsg->cmnd[0] != REQUEST_SENSE) { | 2305 | if (fsg->cmnd[0] != REQUEST_SENSE) { |
2307 | curlun->sense_data = SS_NO_SENSE; | 2306 | curlun->sense_data = SS_NO_SENSE; |
2308 | curlun->sense_data_info = 0; | 2307 | curlun->sense_data_info = 0; |
2309 | curlun->info_valid = 0; | 2308 | curlun->info_valid = 0; |
2310 | } | 2309 | } |
2311 | } else { | 2310 | } else { |
2312 | fsg->curlun = curlun = NULL; | ||
2313 | fsg->bad_lun_okay = 0; | 2311 | fsg->bad_lun_okay = 0; |
2314 | 2312 | ||
2315 | /* INQUIRY and REQUEST SENSE commands are explicitly allowed | 2313 | /* INQUIRY and REQUEST SENSE commands are explicitly allowed |
@@ -2351,6 +2349,16 @@ static int check_command(struct fsg_dev *fsg, int cmnd_size, | |||
2351 | return 0; | 2349 | return 0; |
2352 | } | 2350 | } |
2353 | 2351 | ||
2352 | /* wrapper of check_command for data size in blocks handling */ | ||
2353 | static int check_command_size_in_blocks(struct fsg_dev *fsg, int cmnd_size, | ||
2354 | enum data_direction data_dir, unsigned int mask, | ||
2355 | int needs_medium, const char *name) | ||
2356 | { | ||
2357 | if (fsg->curlun) | ||
2358 | fsg->data_size_from_cmnd <<= fsg->curlun->blkbits; | ||
2359 | return check_command(fsg, cmnd_size, data_dir, | ||
2360 | mask, needs_medium, name); | ||
2361 | } | ||
2354 | 2362 | ||
2355 | static int do_scsi_command(struct fsg_dev *fsg) | 2363 | static int do_scsi_command(struct fsg_dev *fsg) |
2356 | { | 2364 | { |
@@ -2425,26 +2433,27 @@ static int do_scsi_command(struct fsg_dev *fsg) | |||
2425 | 2433 | ||
2426 | case READ_6: | 2434 | case READ_6: |
2427 | i = fsg->cmnd[4]; | 2435 | i = fsg->cmnd[4]; |
2428 | fsg->data_size_from_cmnd = (i == 0 ? 256 : i) << fsg->curlun->blkbits; | 2436 | fsg->data_size_from_cmnd = (i == 0) ? 256 : i; |
2429 | if ((reply = check_command(fsg, 6, DATA_DIR_TO_HOST, | 2437 | if ((reply = check_command_size_in_blocks(fsg, 6, |
2438 | DATA_DIR_TO_HOST, | ||
2430 | (7<<1) | (1<<4), 1, | 2439 | (7<<1) | (1<<4), 1, |
2431 | "READ(6)")) == 0) | 2440 | "READ(6)")) == 0) |
2432 | reply = do_read(fsg); | 2441 | reply = do_read(fsg); |
2433 | break; | 2442 | break; |
2434 | 2443 | ||
2435 | case READ_10: | 2444 | case READ_10: |
2436 | fsg->data_size_from_cmnd = | 2445 | fsg->data_size_from_cmnd = get_unaligned_be16(&fsg->cmnd[7]); |
2437 | get_unaligned_be16(&fsg->cmnd[7]) << fsg->curlun->blkbits; | 2446 | if ((reply = check_command_size_in_blocks(fsg, 10, |
2438 | if ((reply = check_command(fsg, 10, DATA_DIR_TO_HOST, | 2447 | DATA_DIR_TO_HOST, |
2439 | (1<<1) | (0xf<<2) | (3<<7), 1, | 2448 | (1<<1) | (0xf<<2) | (3<<7), 1, |
2440 | "READ(10)")) == 0) | 2449 | "READ(10)")) == 0) |
2441 | reply = do_read(fsg); | 2450 | reply = do_read(fsg); |
2442 | break; | 2451 | break; |
2443 | 2452 | ||
2444 | case READ_12: | 2453 | case READ_12: |
2445 | fsg->data_size_from_cmnd = | 2454 | fsg->data_size_from_cmnd = get_unaligned_be32(&fsg->cmnd[6]); |
2446 | get_unaligned_be32(&fsg->cmnd[6]) << fsg->curlun->blkbits; | 2455 | if ((reply = check_command_size_in_blocks(fsg, 12, |
2447 | if ((reply = check_command(fsg, 12, DATA_DIR_TO_HOST, | 2456 | DATA_DIR_TO_HOST, |
2448 | (1<<1) | (0xf<<2) | (0xf<<6), 1, | 2457 | (1<<1) | (0xf<<2) | (0xf<<6), 1, |
2449 | "READ(12)")) == 0) | 2458 | "READ(12)")) == 0) |
2450 | reply = do_read(fsg); | 2459 | reply = do_read(fsg); |
@@ -2529,26 +2538,27 @@ static int do_scsi_command(struct fsg_dev *fsg) | |||
2529 | 2538 | ||
2530 | case WRITE_6: | 2539 | case WRITE_6: |
2531 | i = fsg->cmnd[4]; | 2540 | i = fsg->cmnd[4]; |
2532 | fsg->data_size_from_cmnd = (i == 0 ? 256 : i) << fsg->curlun->blkbits; | 2541 | fsg->data_size_from_cmnd = (i == 0) ? 256 : i; |
2533 | if ((reply = check_command(fsg, 6, DATA_DIR_FROM_HOST, | 2542 | if ((reply = check_command_size_in_blocks(fsg, 6, |
2543 | DATA_DIR_FROM_HOST, | ||
2534 | (7<<1) | (1<<4), 1, | 2544 | (7<<1) | (1<<4), 1, |
2535 | "WRITE(6)")) == 0) | 2545 | "WRITE(6)")) == 0) |
2536 | reply = do_write(fsg); | 2546 | reply = do_write(fsg); |
2537 | break; | 2547 | break; |
2538 | 2548 | ||
2539 | case WRITE_10: | 2549 | case WRITE_10: |
2540 | fsg->data_size_from_cmnd = | 2550 | fsg->data_size_from_cmnd = get_unaligned_be16(&fsg->cmnd[7]); |
2541 | get_unaligned_be16(&fsg->cmnd[7]) << fsg->curlun->blkbits; | 2551 | if ((reply = check_command_size_in_blocks(fsg, 10, |
2542 | if ((reply = check_command(fsg, 10, DATA_DIR_FROM_HOST, | 2552 | DATA_DIR_FROM_HOST, |
2543 | (1<<1) | (0xf<<2) | (3<<7), 1, | 2553 | (1<<1) | (0xf<<2) | (3<<7), 1, |
2544 | "WRITE(10)")) == 0) | 2554 | "WRITE(10)")) == 0) |
2545 | reply = do_write(fsg); | 2555 | reply = do_write(fsg); |
2546 | break; | 2556 | break; |
2547 | 2557 | ||
2548 | case WRITE_12: | 2558 | case WRITE_12: |
2549 | fsg->data_size_from_cmnd = | 2559 | fsg->data_size_from_cmnd = get_unaligned_be32(&fsg->cmnd[6]); |
2550 | get_unaligned_be32(&fsg->cmnd[6]) << fsg->curlun->blkbits; | 2560 | if ((reply = check_command_size_in_blocks(fsg, 12, |
2551 | if ((reply = check_command(fsg, 12, DATA_DIR_FROM_HOST, | 2561 | DATA_DIR_FROM_HOST, |
2552 | (1<<1) | (0xf<<2) | (0xf<<6), 1, | 2562 | (1<<1) | (0xf<<2) | (0xf<<6), 1, |
2553 | "WRITE(12)")) == 0) | 2563 | "WRITE(12)")) == 0) |
2554 | reply = do_write(fsg); | 2564 | reply = do_write(fsg); |
@@ -2715,7 +2725,17 @@ static int get_next_command(struct fsg_dev *fsg) | |||
2715 | memcpy(fsg->cmnd, fsg->cbbuf_cmnd, fsg->cmnd_size); | 2725 | memcpy(fsg->cmnd, fsg->cbbuf_cmnd, fsg->cmnd_size); |
2716 | fsg->cbbuf_cmnd_size = 0; | 2726 | fsg->cbbuf_cmnd_size = 0; |
2717 | spin_unlock_irq(&fsg->lock); | 2727 | spin_unlock_irq(&fsg->lock); |
2728 | |||
2729 | /* Use LUN from the command */ | ||
2730 | fsg->lun = fsg->cmnd[1] >> 5; | ||
2718 | } | 2731 | } |
2732 | |||
2733 | /* Update current lun */ | ||
2734 | if (fsg->lun >= 0 && fsg->lun < fsg->nluns) | ||
2735 | fsg->curlun = &fsg->luns[fsg->lun]; | ||
2736 | else | ||
2737 | fsg->curlun = NULL; | ||
2738 | |||
2719 | return rc; | 2739 | return rc; |
2720 | } | 2740 | } |
2721 | 2741 | ||
@@ -3584,7 +3604,7 @@ static void fsg_resume(struct usb_gadget *gadget) | |||
3584 | /*-------------------------------------------------------------------------*/ | 3604 | /*-------------------------------------------------------------------------*/ |
3585 | 3605 | ||
3586 | static struct usb_gadget_driver fsg_driver = { | 3606 | static struct usb_gadget_driver fsg_driver = { |
3587 | .speed = USB_SPEED_SUPER, | 3607 | .max_speed = USB_SPEED_SUPER, |
3588 | .function = (char *) fsg_string_product, | 3608 | .function = (char *) fsg_string_product, |
3589 | .unbind = fsg_unbind, | 3609 | .unbind = fsg_unbind, |
3590 | .disconnect = fsg_disconnect, | 3610 | .disconnect = fsg_disconnect, |
diff --git a/drivers/usb/gadget/fsl_mxc_udc.c b/drivers/usb/gadget/fsl_mxc_udc.c index 43a49ecc1f36..dcbc0a2e48dd 100644 --- a/drivers/usb/gadget/fsl_mxc_udc.c +++ b/drivers/usb/gadget/fsl_mxc_udc.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/err.h> | 16 | #include <linux/err.h> |
17 | #include <linux/fsl_devices.h> | 17 | #include <linux/fsl_devices.h> |
18 | #include <linux/platform_device.h> | 18 | #include <linux/platform_device.h> |
19 | #include <linux/io.h> | ||
19 | 20 | ||
20 | #include <mach/hardware.h> | 21 | #include <mach/hardware.h> |
21 | 22 | ||
@@ -88,7 +89,6 @@ eenahb: | |||
88 | void fsl_udc_clk_finalize(struct platform_device *pdev) | 89 | void fsl_udc_clk_finalize(struct platform_device *pdev) |
89 | { | 90 | { |
90 | struct fsl_usb2_platform_data *pdata = pdev->dev.platform_data; | 91 | struct fsl_usb2_platform_data *pdata = pdev->dev.platform_data; |
91 | #if defined(CONFIG_SOC_IMX35) | ||
92 | if (cpu_is_mx35()) { | 92 | if (cpu_is_mx35()) { |
93 | unsigned int v; | 93 | unsigned int v; |
94 | 94 | ||
@@ -101,7 +101,6 @@ void fsl_udc_clk_finalize(struct platform_device *pdev) | |||
101 | USBPHYCTRL_OTGBASE_OFFSET)); | 101 | USBPHYCTRL_OTGBASE_OFFSET)); |
102 | } | 102 | } |
103 | } | 103 | } |
104 | #endif | ||
105 | 104 | ||
106 | /* ULPI transceivers don't need usbpll */ | 105 | /* ULPI transceivers don't need usbpll */ |
107 | if (pdata->phy_mode == FSL_USB2_PHY_ULPI) { | 106 | if (pdata->phy_mode == FSL_USB2_PHY_ULPI) { |
diff --git a/drivers/usb/gadget/fsl_qe_udc.c b/drivers/usb/gadget/fsl_qe_udc.c index 2a03e4de11c1..b95697c03d07 100644 --- a/drivers/usb/gadget/fsl_qe_udc.c +++ b/drivers/usb/gadget/fsl_qe_udc.c | |||
@@ -2336,8 +2336,7 @@ static int fsl_qe_start(struct usb_gadget_driver *driver, | |||
2336 | if (!udc_controller) | 2336 | if (!udc_controller) |
2337 | return -ENODEV; | 2337 | return -ENODEV; |
2338 | 2338 | ||
2339 | if (!driver || (driver->speed != USB_SPEED_FULL | 2339 | if (!driver || driver->max_speed < USB_SPEED_FULL |
2340 | && driver->speed != USB_SPEED_HIGH) | ||
2341 | || !bind || !driver->disconnect || !driver->setup) | 2340 | || !bind || !driver->disconnect || !driver->setup) |
2342 | return -EINVAL; | 2341 | return -EINVAL; |
2343 | 2342 | ||
@@ -2351,7 +2350,7 @@ static int fsl_qe_start(struct usb_gadget_driver *driver, | |||
2351 | /* hook up the driver */ | 2350 | /* hook up the driver */ |
2352 | udc_controller->driver = driver; | 2351 | udc_controller->driver = driver; |
2353 | udc_controller->gadget.dev.driver = &driver->driver; | 2352 | udc_controller->gadget.dev.driver = &driver->driver; |
2354 | udc_controller->gadget.speed = (enum usb_device_speed)(driver->speed); | 2353 | udc_controller->gadget.speed = driver->max_speed; |
2355 | spin_unlock_irqrestore(&udc_controller->lock, flags); | 2354 | spin_unlock_irqrestore(&udc_controller->lock, flags); |
2356 | 2355 | ||
2357 | retval = bind(&udc_controller->gadget); | 2356 | retval = bind(&udc_controller->gadget); |
@@ -2815,20 +2814,7 @@ static struct platform_driver udc_driver = { | |||
2815 | #endif | 2814 | #endif |
2816 | }; | 2815 | }; |
2817 | 2816 | ||
2818 | static int __init qe_udc_init(void) | 2817 | module_platform_driver(udc_driver); |
2819 | { | ||
2820 | printk(KERN_INFO "%s: %s, %s\n", driver_name, driver_desc, | ||
2821 | DRIVER_VERSION); | ||
2822 | return platform_driver_register(&udc_driver); | ||
2823 | } | ||
2824 | |||
2825 | static void __exit qe_udc_exit(void) | ||
2826 | { | ||
2827 | platform_driver_unregister(&udc_driver); | ||
2828 | } | ||
2829 | |||
2830 | module_init(qe_udc_init); | ||
2831 | module_exit(qe_udc_exit); | ||
2832 | 2818 | ||
2833 | MODULE_DESCRIPTION(DRIVER_DESC); | 2819 | MODULE_DESCRIPTION(DRIVER_DESC); |
2834 | MODULE_AUTHOR(DRIVER_AUTHOR); | 2820 | MODULE_AUTHOR(DRIVER_AUTHOR); |
diff --git a/drivers/usb/gadget/fsl_udc_core.c b/drivers/usb/gadget/fsl_udc_core.c index b2c44e1d5813..d7ea6c076ce9 100644 --- a/drivers/usb/gadget/fsl_udc_core.c +++ b/drivers/usb/gadget/fsl_udc_core.c | |||
@@ -696,12 +696,31 @@ static void fsl_free_request(struct usb_ep *_ep, struct usb_request *_req) | |||
696 | kfree(req); | 696 | kfree(req); |
697 | } | 697 | } |
698 | 698 | ||
699 | /*-------------------------------------------------------------------------*/ | 699 | /* Actually add a dTD chain to an empty dQH and let go */ |
700 | static void fsl_prime_ep(struct fsl_ep *ep, struct ep_td_struct *td) | ||
701 | { | ||
702 | struct ep_queue_head *qh = get_qh_by_ep(ep); | ||
703 | |||
704 | /* Write dQH next pointer and terminate bit to 0 */ | ||
705 | qh->next_dtd_ptr = cpu_to_hc32(td->td_dma | ||
706 | & EP_QUEUE_HEAD_NEXT_POINTER_MASK); | ||
707 | |||
708 | /* Clear active and halt bit */ | ||
709 | qh->size_ioc_int_sts &= cpu_to_hc32(~(EP_QUEUE_HEAD_STATUS_ACTIVE | ||
710 | | EP_QUEUE_HEAD_STATUS_HALT)); | ||
711 | |||
712 | /* Ensure that updates to the QH will occur before priming. */ | ||
713 | wmb(); | ||
714 | |||
715 | /* Prime endpoint by writing correct bit to ENDPTPRIME */ | ||
716 | fsl_writel(ep_is_in(ep) ? (1 << (ep_index(ep) + 16)) | ||
717 | : (1 << (ep_index(ep))), &dr_regs->endpointprime); | ||
718 | } | ||
719 | |||
720 | /* Add dTD chain to the dQH of an EP */ | ||
700 | static void fsl_queue_td(struct fsl_ep *ep, struct fsl_req *req) | 721 | static void fsl_queue_td(struct fsl_ep *ep, struct fsl_req *req) |
701 | { | 722 | { |
702 | int i = ep_index(ep) * 2 + ep_is_in(ep); | ||
703 | u32 temp, bitmask, tmp_stat; | 723 | u32 temp, bitmask, tmp_stat; |
704 | struct ep_queue_head *dQH = &ep->udc->ep_qh[i]; | ||
705 | 724 | ||
706 | /* VDBG("QH addr Register 0x%8x", dr_regs->endpointlistaddr); | 725 | /* VDBG("QH addr Register 0x%8x", dr_regs->endpointlistaddr); |
707 | VDBG("ep_qh[%d] addr is 0x%8x", i, (u32)&(ep->udc->ep_qh[i])); */ | 726 | VDBG("ep_qh[%d] addr is 0x%8x", i, (u32)&(ep->udc->ep_qh[i])); */ |
@@ -719,7 +738,7 @@ static void fsl_queue_td(struct fsl_ep *ep, struct fsl_req *req) | |||
719 | cpu_to_hc32(req->head->td_dma & DTD_ADDR_MASK); | 738 | cpu_to_hc32(req->head->td_dma & DTD_ADDR_MASK); |
720 | /* Read prime bit, if 1 goto done */ | 739 | /* Read prime bit, if 1 goto done */ |
721 | if (fsl_readl(&dr_regs->endpointprime) & bitmask) | 740 | if (fsl_readl(&dr_regs->endpointprime) & bitmask) |
722 | goto out; | 741 | return; |
723 | 742 | ||
724 | do { | 743 | do { |
725 | /* Set ATDTW bit in USBCMD */ | 744 | /* Set ATDTW bit in USBCMD */ |
@@ -736,28 +755,10 @@ static void fsl_queue_td(struct fsl_ep *ep, struct fsl_req *req) | |||
736 | fsl_writel(temp & ~USB_CMD_ATDTW, &dr_regs->usbcmd); | 755 | fsl_writel(temp & ~USB_CMD_ATDTW, &dr_regs->usbcmd); |
737 | 756 | ||
738 | if (tmp_stat) | 757 | if (tmp_stat) |
739 | goto out; | 758 | return; |
740 | } | 759 | } |
741 | 760 | ||
742 | /* Write dQH next pointer and terminate bit to 0 */ | 761 | fsl_prime_ep(ep, req->head); |
743 | temp = req->head->td_dma & EP_QUEUE_HEAD_NEXT_POINTER_MASK; | ||
744 | dQH->next_dtd_ptr = cpu_to_hc32(temp); | ||
745 | |||
746 | /* Clear active and halt bit */ | ||
747 | temp = cpu_to_hc32(~(EP_QUEUE_HEAD_STATUS_ACTIVE | ||
748 | | EP_QUEUE_HEAD_STATUS_HALT)); | ||
749 | dQH->size_ioc_int_sts &= temp; | ||
750 | |||
751 | /* Ensure that updates to the QH will occur before priming. */ | ||
752 | wmb(); | ||
753 | |||
754 | /* Prime endpoint by writing 1 to ENDPTPRIME */ | ||
755 | temp = ep_is_in(ep) | ||
756 | ? (1 << (ep_index(ep) + 16)) | ||
757 | : (1 << (ep_index(ep))); | ||
758 | fsl_writel(temp, &dr_regs->endpointprime); | ||
759 | out: | ||
760 | return; | ||
761 | } | 762 | } |
762 | 763 | ||
763 | /* Fill in the dTD structure | 764 | /* Fill in the dTD structure |
@@ -877,7 +878,7 @@ fsl_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags) | |||
877 | VDBG("%s, bad ep", __func__); | 878 | VDBG("%s, bad ep", __func__); |
878 | return -EINVAL; | 879 | return -EINVAL; |
879 | } | 880 | } |
880 | if (ep->desc->bmAttributes == USB_ENDPOINT_XFER_ISOC) { | 881 | if (usb_endpoint_xfer_isoc(ep->desc)) { |
881 | if (req->req.length > ep->ep.maxpacket) | 882 | if (req->req.length > ep->ep.maxpacket) |
882 | return -EMSGSIZE; | 883 | return -EMSGSIZE; |
883 | } | 884 | } |
@@ -973,25 +974,20 @@ static int fsl_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req) | |||
973 | 974 | ||
974 | /* The request isn't the last request in this ep queue */ | 975 | /* The request isn't the last request in this ep queue */ |
975 | if (req->queue.next != &ep->queue) { | 976 | if (req->queue.next != &ep->queue) { |
976 | struct ep_queue_head *qh; | ||
977 | struct fsl_req *next_req; | 977 | struct fsl_req *next_req; |
978 | 978 | ||
979 | qh = ep->qh; | ||
980 | next_req = list_entry(req->queue.next, struct fsl_req, | 979 | next_req = list_entry(req->queue.next, struct fsl_req, |
981 | queue); | 980 | queue); |
982 | 981 | ||
983 | /* Point the QH to the first TD of next request */ | 982 | /* prime with dTD of next request */ |
984 | fsl_writel((u32) next_req->head, &qh->curr_dtd_ptr); | 983 | fsl_prime_ep(ep, next_req->head); |
985 | } | 984 | } |
986 | 985 | /* The request hasn't been processed, patch up the TD chain */ | |
987 | /* The request hasn't been processed, patch up the TD chain */ | ||
988 | } else { | 986 | } else { |
989 | struct fsl_req *prev_req; | 987 | struct fsl_req *prev_req; |
990 | 988 | ||
991 | prev_req = list_entry(req->queue.prev, struct fsl_req, queue); | 989 | prev_req = list_entry(req->queue.prev, struct fsl_req, queue); |
992 | fsl_writel(fsl_readl(&req->tail->next_td_ptr), | 990 | prev_req->tail->next_td_ptr = req->tail->next_td_ptr; |
993 | &prev_req->tail->next_td_ptr); | ||
994 | |||
995 | } | 991 | } |
996 | 992 | ||
997 | done(ep, req, -ECONNRESET); | 993 | done(ep, req, -ECONNRESET); |
@@ -1032,7 +1028,7 @@ static int fsl_ep_set_halt(struct usb_ep *_ep, int value) | |||
1032 | goto out; | 1028 | goto out; |
1033 | } | 1029 | } |
1034 | 1030 | ||
1035 | if (ep->desc->bmAttributes == USB_ENDPOINT_XFER_ISOC) { | 1031 | if (usb_endpoint_xfer_isoc(ep->desc)) { |
1036 | status = -EOPNOTSUPP; | 1032 | status = -EOPNOTSUPP; |
1037 | goto out; | 1033 | goto out; |
1038 | } | 1034 | } |
@@ -1068,7 +1064,7 @@ static int fsl_ep_fifo_status(struct usb_ep *_ep) | |||
1068 | struct fsl_udc *udc; | 1064 | struct fsl_udc *udc; |
1069 | int size = 0; | 1065 | int size = 0; |
1070 | u32 bitmask; | 1066 | u32 bitmask; |
1071 | struct ep_queue_head *d_qh; | 1067 | struct ep_queue_head *qh; |
1072 | 1068 | ||
1073 | ep = container_of(_ep, struct fsl_ep, ep); | 1069 | ep = container_of(_ep, struct fsl_ep, ep); |
1074 | if (!_ep || (!ep->desc && ep_index(ep) != 0)) | 1070 | if (!_ep || (!ep->desc && ep_index(ep) != 0)) |
@@ -1079,13 +1075,13 @@ static int fsl_ep_fifo_status(struct usb_ep *_ep) | |||
1079 | if (!udc->driver || udc->gadget.speed == USB_SPEED_UNKNOWN) | 1075 | if (!udc->driver || udc->gadget.speed == USB_SPEED_UNKNOWN) |
1080 | return -ESHUTDOWN; | 1076 | return -ESHUTDOWN; |
1081 | 1077 | ||
1082 | d_qh = &ep->udc->ep_qh[ep_index(ep) * 2 + ep_is_in(ep)]; | 1078 | qh = get_qh_by_ep(ep); |
1083 | 1079 | ||
1084 | bitmask = (ep_is_in(ep)) ? (1 << (ep_index(ep) + 16)) : | 1080 | bitmask = (ep_is_in(ep)) ? (1 << (ep_index(ep) + 16)) : |
1085 | (1 << (ep_index(ep))); | 1081 | (1 << (ep_index(ep))); |
1086 | 1082 | ||
1087 | if (fsl_readl(&dr_regs->endptstatus) & bitmask) | 1083 | if (fsl_readl(&dr_regs->endptstatus) & bitmask) |
1088 | size = (d_qh->size_ioc_int_sts & DTD_PACKET_SIZE) | 1084 | size = (qh->size_ioc_int_sts & DTD_PACKET_SIZE) |
1089 | >> DTD_LENGTH_BIT_POS; | 1085 | >> DTD_LENGTH_BIT_POS; |
1090 | 1086 | ||
1091 | pr_debug("%s %u\n", __func__, size); | 1087 | pr_debug("%s %u\n", __func__, size); |
@@ -1717,7 +1713,7 @@ static void dtd_complete_irq(struct fsl_udc *udc) | |||
1717 | 1713 | ||
1718 | static inline enum usb_device_speed portscx_device_speed(u32 reg) | 1714 | static inline enum usb_device_speed portscx_device_speed(u32 reg) |
1719 | { | 1715 | { |
1720 | switch (speed & PORTSCX_PORT_SPEED_MASK) { | 1716 | switch (reg & PORTSCX_PORT_SPEED_MASK) { |
1721 | case PORTSCX_PORT_SPEED_HIGH: | 1717 | case PORTSCX_PORT_SPEED_HIGH: |
1722 | return USB_SPEED_HIGH; | 1718 | return USB_SPEED_HIGH; |
1723 | case PORTSCX_PORT_SPEED_FULL: | 1719 | case PORTSCX_PORT_SPEED_FULL: |
@@ -1938,8 +1934,7 @@ static int fsl_start(struct usb_gadget_driver *driver, | |||
1938 | if (!udc_controller) | 1934 | if (!udc_controller) |
1939 | return -ENODEV; | 1935 | return -ENODEV; |
1940 | 1936 | ||
1941 | if (!driver || (driver->speed != USB_SPEED_FULL | 1937 | if (!driver || driver->max_speed < USB_SPEED_FULL |
1942 | && driver->speed != USB_SPEED_HIGH) | ||
1943 | || !bind || !driver->disconnect || !driver->setup) | 1938 | || !bind || !driver->disconnect || !driver->setup) |
1944 | return -EINVAL; | 1939 | return -EINVAL; |
1945 | 1940 | ||
@@ -2480,8 +2475,7 @@ static int __init fsl_udc_probe(struct platform_device *pdev) | |||
2480 | 2475 | ||
2481 | #ifndef CONFIG_ARCH_MXC | 2476 | #ifndef CONFIG_ARCH_MXC |
2482 | if (pdata->have_sysif_regs) | 2477 | if (pdata->have_sysif_regs) |
2483 | usb_sys_regs = (struct usb_sys_interface *) | 2478 | usb_sys_regs = (void *)dr_regs + USB_DR_SYS_OFFSET; |
2484 | ((u32)dr_regs + USB_DR_SYS_OFFSET); | ||
2485 | #endif | 2479 | #endif |
2486 | 2480 | ||
2487 | /* Initialize USB clocks */ | 2481 | /* Initialize USB clocks */ |
@@ -2531,7 +2525,7 @@ static int __init fsl_udc_probe(struct platform_device *pdev) | |||
2531 | 2525 | ||
2532 | /* Setup gadget structure */ | 2526 | /* Setup gadget structure */ |
2533 | udc_controller->gadget.ops = &fsl_gadget_ops; | 2527 | udc_controller->gadget.ops = &fsl_gadget_ops; |
2534 | udc_controller->gadget.is_dualspeed = 1; | 2528 | udc_controller->gadget.max_speed = USB_SPEED_HIGH; |
2535 | udc_controller->gadget.ep0 = &udc_controller->eps[0].ep; | 2529 | udc_controller->gadget.ep0 = &udc_controller->eps[0].ep; |
2536 | INIT_LIST_HEAD(&udc_controller->gadget.ep_list); | 2530 | INIT_LIST_HEAD(&udc_controller->gadget.ep_list); |
2537 | udc_controller->gadget.speed = USB_SPEED_UNKNOWN; | 2531 | udc_controller->gadget.speed = USB_SPEED_UNKNOWN; |
diff --git a/drivers/usb/gadget/fsl_usb2_udc.h b/drivers/usb/gadget/fsl_usb2_udc.h index 1d51be83fda8..f781f5dec417 100644 --- a/drivers/usb/gadget/fsl_usb2_udc.h +++ b/drivers/usb/gadget/fsl_usb2_udc.h | |||
@@ -569,6 +569,16 @@ static void dump_msg(const char *label, const u8 * buf, unsigned int length) | |||
569 | * 2 + ((windex & USB_DIR_IN) ? 1 : 0)) | 569 | * 2 + ((windex & USB_DIR_IN) ? 1 : 0)) |
570 | #define get_pipe_by_ep(EP) (ep_index(EP) * 2 + ep_is_in(EP)) | 570 | #define get_pipe_by_ep(EP) (ep_index(EP) * 2 + ep_is_in(EP)) |
571 | 571 | ||
572 | static inline struct ep_queue_head *get_qh_by_ep(struct fsl_ep *ep) | ||
573 | { | ||
574 | /* we only have one ep0 structure but two queue heads */ | ||
575 | if (ep_index(ep) != 0) | ||
576 | return ep->qh; | ||
577 | else | ||
578 | return &ep->udc->ep_qh[(ep->udc->ep0_dir == | ||
579 | USB_DIR_IN) ? 1 : 0]; | ||
580 | } | ||
581 | |||
572 | struct platform_device; | 582 | struct platform_device; |
573 | #ifdef CONFIG_ARCH_MXC | 583 | #ifdef CONFIG_ARCH_MXC |
574 | int fsl_udc_clk_init(struct platform_device *pdev); | 584 | int fsl_udc_clk_init(struct platform_device *pdev); |
diff --git a/drivers/usb/gadget/fusb300_udc.c b/drivers/usb/gadget/fusb300_udc.c index 74da206c8406..5831cb4a0b35 100644 --- a/drivers/usb/gadget/fusb300_udc.c +++ b/drivers/usb/gadget/fusb300_udc.c | |||
@@ -1317,7 +1317,7 @@ static int fusb300_udc_start(struct usb_gadget_driver *driver, | |||
1317 | int retval; | 1317 | int retval; |
1318 | 1318 | ||
1319 | if (!driver | 1319 | if (!driver |
1320 | || driver->speed < USB_SPEED_FULL | 1320 | || driver->max_speed < USB_SPEED_FULL |
1321 | || !bind | 1321 | || !bind |
1322 | || !driver->setup) | 1322 | || !driver->setup) |
1323 | return -EINVAL; | 1323 | return -EINVAL; |
@@ -1463,7 +1463,7 @@ static int __init fusb300_probe(struct platform_device *pdev) | |||
1463 | 1463 | ||
1464 | dev_set_name(&fusb300->gadget.dev, "gadget"); | 1464 | dev_set_name(&fusb300->gadget.dev, "gadget"); |
1465 | 1465 | ||
1466 | fusb300->gadget.is_dualspeed = 1; | 1466 | fusb300->gadget.max_speed = USB_SPEED_HIGH; |
1467 | fusb300->gadget.dev.parent = &pdev->dev; | 1467 | fusb300->gadget.dev.parent = &pdev->dev; |
1468 | fusb300->gadget.dev.dma_mask = pdev->dev.dma_mask; | 1468 | fusb300->gadget.dev.dma_mask = pdev->dev.dma_mask; |
1469 | fusb300->gadget.dev.release = pdev->dev.release; | 1469 | fusb300->gadget.dev.release = pdev->dev.release; |
diff --git a/drivers/usb/gadget/goku_udc.c b/drivers/usb/gadget/goku_udc.c index 7f87805cddc4..5af70fcce139 100644 --- a/drivers/usb/gadget/goku_udc.c +++ b/drivers/usb/gadget/goku_udc.c | |||
@@ -1357,7 +1357,7 @@ static int goku_start(struct usb_gadget_driver *driver, | |||
1357 | int retval; | 1357 | int retval; |
1358 | 1358 | ||
1359 | if (!driver | 1359 | if (!driver |
1360 | || driver->speed < USB_SPEED_FULL | 1360 | || driver->max_speed < USB_SPEED_FULL |
1361 | || !bind | 1361 | || !bind |
1362 | || !driver->disconnect | 1362 | || !driver->disconnect |
1363 | || !driver->setup) | 1363 | || !driver->setup) |
@@ -1796,6 +1796,7 @@ static int goku_probe(struct pci_dev *pdev, const struct pci_device_id *id) | |||
1796 | spin_lock_init(&dev->lock); | 1796 | spin_lock_init(&dev->lock); |
1797 | dev->pdev = pdev; | 1797 | dev->pdev = pdev; |
1798 | dev->gadget.ops = &goku_ops; | 1798 | dev->gadget.ops = &goku_ops; |
1799 | dev->gadget.max_speed = USB_SPEED_FULL; | ||
1799 | 1800 | ||
1800 | /* the "gadget" abstracts/virtualizes the controller */ | 1801 | /* the "gadget" abstracts/virtualizes the controller */ |
1801 | dev_set_name(&dev->gadget.dev, "gadget"); | 1802 | dev_set_name(&dev->gadget.dev, "gadget"); |
diff --git a/drivers/usb/gadget/imx_udc.c b/drivers/usb/gadget/imx_udc.c index 2d978c0e7ced..8d1c75abd73d 100644 --- a/drivers/usb/gadget/imx_udc.c +++ b/drivers/usb/gadget/imx_udc.c | |||
@@ -1336,7 +1336,7 @@ static int imx_udc_start(struct usb_gadget_driver *driver, | |||
1336 | int retval; | 1336 | int retval; |
1337 | 1337 | ||
1338 | if (!driver | 1338 | if (!driver |
1339 | || driver->speed < USB_SPEED_FULL | 1339 | || driver->max_speed < USB_SPEED_FULL |
1340 | || !bind | 1340 | || !bind |
1341 | || !driver->disconnect | 1341 | || !driver->disconnect |
1342 | || !driver->setup) | 1342 | || !driver->setup) |
diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c index a392ec0d2d51..ae04266dba1b 100644 --- a/drivers/usb/gadget/inode.c +++ b/drivers/usb/gadget/inode.c | |||
@@ -1730,8 +1730,9 @@ static void | |||
1730 | gadgetfs_disconnect (struct usb_gadget *gadget) | 1730 | gadgetfs_disconnect (struct usb_gadget *gadget) |
1731 | { | 1731 | { |
1732 | struct dev_data *dev = get_gadget_data (gadget); | 1732 | struct dev_data *dev = get_gadget_data (gadget); |
1733 | unsigned long flags; | ||
1733 | 1734 | ||
1734 | spin_lock (&dev->lock); | 1735 | spin_lock_irqsave (&dev->lock, flags); |
1735 | if (dev->state == STATE_DEV_UNCONNECTED) | 1736 | if (dev->state == STATE_DEV_UNCONNECTED) |
1736 | goto exit; | 1737 | goto exit; |
1737 | dev->state = STATE_DEV_UNCONNECTED; | 1738 | dev->state = STATE_DEV_UNCONNECTED; |
@@ -1740,7 +1741,7 @@ gadgetfs_disconnect (struct usb_gadget *gadget) | |||
1740 | next_event (dev, GADGETFS_DISCONNECT); | 1741 | next_event (dev, GADGETFS_DISCONNECT); |
1741 | ep0_readable (dev); | 1742 | ep0_readable (dev); |
1742 | exit: | 1743 | exit: |
1743 | spin_unlock (&dev->lock); | 1744 | spin_unlock_irqrestore (&dev->lock, flags); |
1744 | } | 1745 | } |
1745 | 1746 | ||
1746 | static void | 1747 | static void |
@@ -1765,9 +1766,9 @@ gadgetfs_suspend (struct usb_gadget *gadget) | |||
1765 | 1766 | ||
1766 | static struct usb_gadget_driver gadgetfs_driver = { | 1767 | static struct usb_gadget_driver gadgetfs_driver = { |
1767 | #ifdef CONFIG_USB_GADGET_DUALSPEED | 1768 | #ifdef CONFIG_USB_GADGET_DUALSPEED |
1768 | .speed = USB_SPEED_HIGH, | 1769 | .max_speed = USB_SPEED_HIGH, |
1769 | #else | 1770 | #else |
1770 | .speed = USB_SPEED_FULL, | 1771 | .max_speed = USB_SPEED_FULL, |
1771 | #endif | 1772 | #endif |
1772 | .function = (char *) driver_desc, | 1773 | .function = (char *) driver_desc, |
1773 | .unbind = gadgetfs_unbind, | 1774 | .unbind = gadgetfs_unbind, |
@@ -1791,7 +1792,7 @@ static int gadgetfs_probe (struct usb_gadget *gadget) | |||
1791 | } | 1792 | } |
1792 | 1793 | ||
1793 | static struct usb_gadget_driver probe_driver = { | 1794 | static struct usb_gadget_driver probe_driver = { |
1794 | .speed = USB_SPEED_HIGH, | 1795 | .max_speed = USB_SPEED_HIGH, |
1795 | .unbind = gadgetfs_nop, | 1796 | .unbind = gadgetfs_nop, |
1796 | .setup = (void *)gadgetfs_nop, | 1797 | .setup = (void *)gadgetfs_nop, |
1797 | .disconnect = gadgetfs_nop, | 1798 | .disconnect = gadgetfs_nop, |
@@ -2034,7 +2035,6 @@ static int | |||
2034 | gadgetfs_fill_super (struct super_block *sb, void *opts, int silent) | 2035 | gadgetfs_fill_super (struct super_block *sb, void *opts, int silent) |
2035 | { | 2036 | { |
2036 | struct inode *inode; | 2037 | struct inode *inode; |
2037 | struct dentry *d; | ||
2038 | struct dev_data *dev; | 2038 | struct dev_data *dev; |
2039 | 2039 | ||
2040 | if (the_device) | 2040 | if (the_device) |
@@ -2057,24 +2057,27 @@ gadgetfs_fill_super (struct super_block *sb, void *opts, int silent) | |||
2057 | NULL, &simple_dir_operations, | 2057 | NULL, &simple_dir_operations, |
2058 | S_IFDIR | S_IRUGO | S_IXUGO); | 2058 | S_IFDIR | S_IRUGO | S_IXUGO); |
2059 | if (!inode) | 2059 | if (!inode) |
2060 | goto enomem0; | 2060 | goto Enomem; |
2061 | inode->i_op = &simple_dir_inode_operations; | 2061 | inode->i_op = &simple_dir_inode_operations; |
2062 | if (!(d = d_alloc_root (inode))) | 2062 | if (!(sb->s_root = d_alloc_root (inode))) { |
2063 | goto enomem1; | 2063 | iput(inode); |
2064 | sb->s_root = d; | 2064 | goto Enomem; |
2065 | } | ||
2065 | 2066 | ||
2066 | /* the ep0 file is named after the controller we expect; | 2067 | /* the ep0 file is named after the controller we expect; |
2067 | * user mode code can use it for sanity checks, like we do. | 2068 | * user mode code can use it for sanity checks, like we do. |
2068 | */ | 2069 | */ |
2069 | dev = dev_new (); | 2070 | dev = dev_new (); |
2070 | if (!dev) | 2071 | if (!dev) |
2071 | goto enomem2; | 2072 | goto Enomem; |
2072 | 2073 | ||
2073 | dev->sb = sb; | 2074 | dev->sb = sb; |
2074 | if (!gadgetfs_create_file (sb, CHIP, | 2075 | if (!gadgetfs_create_file (sb, CHIP, |
2075 | dev, &dev_init_operations, | 2076 | dev, &dev_init_operations, |
2076 | &dev->dentry)) | 2077 | &dev->dentry)) { |
2077 | goto enomem3; | 2078 | put_dev(dev); |
2079 | goto Enomem; | ||
2080 | } | ||
2078 | 2081 | ||
2079 | /* other endpoint files are available after hardware setup, | 2082 | /* other endpoint files are available after hardware setup, |
2080 | * from binding to a controller. | 2083 | * from binding to a controller. |
@@ -2082,13 +2085,7 @@ gadgetfs_fill_super (struct super_block *sb, void *opts, int silent) | |||
2082 | the_device = dev; | 2085 | the_device = dev; |
2083 | return 0; | 2086 | return 0; |
2084 | 2087 | ||
2085 | enomem3: | 2088 | Enomem: |
2086 | put_dev (dev); | ||
2087 | enomem2: | ||
2088 | dput (d); | ||
2089 | enomem1: | ||
2090 | iput (inode); | ||
2091 | enomem0: | ||
2092 | return -ENOMEM; | 2089 | return -ENOMEM; |
2093 | } | 2090 | } |
2094 | 2091 | ||
diff --git a/drivers/usb/gadget/langwell_udc.c b/drivers/usb/gadget/langwell_udc.c index c9fa3bf5b377..fa0fcc11263f 100644 --- a/drivers/usb/gadget/langwell_udc.c +++ b/drivers/usb/gadget/langwell_udc.c | |||
@@ -3267,7 +3267,7 @@ static int langwell_udc_probe(struct pci_dev *pdev, | |||
3267 | dev->gadget.ep0 = &dev->ep[0].ep; /* gadget ep0 */ | 3267 | dev->gadget.ep0 = &dev->ep[0].ep; /* gadget ep0 */ |
3268 | INIT_LIST_HEAD(&dev->gadget.ep_list); /* ep_list */ | 3268 | INIT_LIST_HEAD(&dev->gadget.ep_list); /* ep_list */ |
3269 | dev->gadget.speed = USB_SPEED_UNKNOWN; /* speed */ | 3269 | dev->gadget.speed = USB_SPEED_UNKNOWN; /* speed */ |
3270 | dev->gadget.is_dualspeed = 1; /* support dual speed */ | 3270 | dev->gadget.max_speed = USB_SPEED_HIGH; /* support dual speed */ |
3271 | #ifdef OTG_TRANSCEIVER | 3271 | #ifdef OTG_TRANSCEIVER |
3272 | dev->gadget.is_otg = 1; /* support otg mode */ | 3272 | dev->gadget.is_otg = 1; /* support otg mode */ |
3273 | #endif | 3273 | #endif |
diff --git a/drivers/usb/gadget/m66592-udc.c b/drivers/usb/gadget/m66592-udc.c index 91d0af2a24a8..3608b3bd5732 100644 --- a/drivers/usb/gadget/m66592-udc.c +++ b/drivers/usb/gadget/m66592-udc.c | |||
@@ -1472,7 +1472,7 @@ static int m66592_start(struct usb_gadget_driver *driver, | |||
1472 | int retval; | 1472 | int retval; |
1473 | 1473 | ||
1474 | if (!driver | 1474 | if (!driver |
1475 | || driver->speed != USB_SPEED_HIGH | 1475 | || driver->max_speed < USB_SPEED_HIGH |
1476 | || !bind | 1476 | || !bind |
1477 | || !driver->setup) | 1477 | || !driver->setup) |
1478 | return -EINVAL; | 1478 | return -EINVAL; |
@@ -1653,7 +1653,7 @@ static int __init m66592_probe(struct platform_device *pdev) | |||
1653 | m66592->gadget.ops = &m66592_gadget_ops; | 1653 | m66592->gadget.ops = &m66592_gadget_ops; |
1654 | device_initialize(&m66592->gadget.dev); | 1654 | device_initialize(&m66592->gadget.dev); |
1655 | dev_set_name(&m66592->gadget.dev, "gadget"); | 1655 | dev_set_name(&m66592->gadget.dev, "gadget"); |
1656 | m66592->gadget.is_dualspeed = 1; | 1656 | m66592->gadget.max_speed = USB_SPEED_HIGH; |
1657 | m66592->gadget.dev.parent = &pdev->dev; | 1657 | m66592->gadget.dev.parent = &pdev->dev; |
1658 | m66592->gadget.dev.dma_mask = pdev->dev.dma_mask; | 1658 | m66592->gadget.dev.dma_mask = pdev->dev.dma_mask; |
1659 | m66592->gadget.dev.release = pdev->dev.release; | 1659 | m66592->gadget.dev.release = pdev->dev.release; |
diff --git a/drivers/usb/gadget/mv_udc.h b/drivers/usb/gadget/mv_udc.h index daa75c12f336..34aadfae723d 100644 --- a/drivers/usb/gadget/mv_udc.h +++ b/drivers/usb/gadget/mv_udc.h | |||
@@ -180,7 +180,7 @@ struct mv_udc { | |||
180 | 180 | ||
181 | struct mv_cap_regs __iomem *cap_regs; | 181 | struct mv_cap_regs __iomem *cap_regs; |
182 | struct mv_op_regs __iomem *op_regs; | 182 | struct mv_op_regs __iomem *op_regs; |
183 | unsigned int phy_regs; | 183 | void __iomem *phy_regs; |
184 | unsigned int max_eps; | 184 | unsigned int max_eps; |
185 | struct mv_dqh *ep_dqh; | 185 | struct mv_dqh *ep_dqh; |
186 | size_t ep_dqh_size; | 186 | size_t ep_dqh_size; |
@@ -211,11 +211,14 @@ struct mv_udc { | |||
211 | softconnected:1, | 211 | softconnected:1, |
212 | force_fs:1, | 212 | force_fs:1, |
213 | clock_gating:1, | 213 | clock_gating:1, |
214 | active:1; | 214 | active:1, |
215 | stopped:1; /* stop bit is setted */ | ||
215 | 216 | ||
216 | struct work_struct vbus_work; | 217 | struct work_struct vbus_work; |
217 | struct workqueue_struct *qwork; | 218 | struct workqueue_struct *qwork; |
218 | 219 | ||
220 | struct otg_transceiver *transceiver; | ||
221 | |||
219 | struct mv_usb_platform_data *pdata; | 222 | struct mv_usb_platform_data *pdata; |
220 | 223 | ||
221 | /* some SOC has mutiple clock sources for USB*/ | 224 | /* some SOC has mutiple clock sources for USB*/ |
diff --git a/drivers/usb/gadget/mv_udc_core.c b/drivers/usb/gadget/mv_udc_core.c index 892412103dd8..f97e737d26f7 100644 --- a/drivers/usb/gadget/mv_udc_core.c +++ b/drivers/usb/gadget/mv_udc_core.c | |||
@@ -276,11 +276,12 @@ static void done(struct mv_ep *ep, struct mv_req *req, int status) | |||
276 | 276 | ||
277 | static int queue_dtd(struct mv_ep *ep, struct mv_req *req) | 277 | static int queue_dtd(struct mv_ep *ep, struct mv_req *req) |
278 | { | 278 | { |
279 | u32 tmp, epstatus, bit_pos, direction; | ||
280 | struct mv_udc *udc; | 279 | struct mv_udc *udc; |
281 | struct mv_dqh *dqh; | 280 | struct mv_dqh *dqh; |
281 | u32 bit_pos, direction; | ||
282 | u32 usbcmd, epstatus; | ||
282 | unsigned int loops; | 283 | unsigned int loops; |
283 | int readsafe, retval = 0; | 284 | int retval = 0; |
284 | 285 | ||
285 | udc = ep->udc; | 286 | udc = ep->udc; |
286 | direction = ep_dir(ep); | 287 | direction = ep_dir(ep); |
@@ -293,30 +294,18 @@ static int queue_dtd(struct mv_ep *ep, struct mv_req *req) | |||
293 | lastreq = list_entry(ep->queue.prev, struct mv_req, queue); | 294 | lastreq = list_entry(ep->queue.prev, struct mv_req, queue); |
294 | lastreq->tail->dtd_next = | 295 | lastreq->tail->dtd_next = |
295 | req->head->td_dma & EP_QUEUE_HEAD_NEXT_POINTER_MASK; | 296 | req->head->td_dma & EP_QUEUE_HEAD_NEXT_POINTER_MASK; |
296 | if (readl(&udc->op_regs->epprime) & bit_pos) { | 297 | |
297 | loops = LOOPS(PRIME_TIMEOUT); | 298 | wmb(); |
298 | while (readl(&udc->op_regs->epprime) & bit_pos) { | 299 | |
299 | if (loops == 0) { | 300 | if (readl(&udc->op_regs->epprime) & bit_pos) |
300 | retval = -ETIME; | 301 | goto done; |
301 | goto done; | 302 | |
302 | } | ||
303 | udelay(LOOPS_USEC); | ||
304 | loops--; | ||
305 | } | ||
306 | if (readl(&udc->op_regs->epstatus) & bit_pos) | ||
307 | goto done; | ||
308 | } | ||
309 | readsafe = 0; | ||
310 | loops = LOOPS(READSAFE_TIMEOUT); | 303 | loops = LOOPS(READSAFE_TIMEOUT); |
311 | while (readsafe == 0) { | 304 | while (1) { |
312 | if (loops == 0) { | ||
313 | retval = -ETIME; | ||
314 | goto done; | ||
315 | } | ||
316 | /* start with setting the semaphores */ | 305 | /* start with setting the semaphores */ |
317 | tmp = readl(&udc->op_regs->usbcmd); | 306 | usbcmd = readl(&udc->op_regs->usbcmd); |
318 | tmp |= USBCMD_ATDTW_TRIPWIRE_SET; | 307 | usbcmd |= USBCMD_ATDTW_TRIPWIRE_SET; |
319 | writel(tmp, &udc->op_regs->usbcmd); | 308 | writel(usbcmd, &udc->op_regs->usbcmd); |
320 | 309 | ||
321 | /* read the endpoint status */ | 310 | /* read the endpoint status */ |
322 | epstatus = readl(&udc->op_regs->epstatus) & bit_pos; | 311 | epstatus = readl(&udc->op_regs->epstatus) & bit_pos; |
@@ -329,98 +318,46 @@ static int queue_dtd(struct mv_ep *ep, struct mv_req *req) | |||
329 | * primed. | 318 | * primed. |
330 | */ | 319 | */ |
331 | if (readl(&udc->op_regs->usbcmd) | 320 | if (readl(&udc->op_regs->usbcmd) |
332 | & USBCMD_ATDTW_TRIPWIRE_SET) { | 321 | & USBCMD_ATDTW_TRIPWIRE_SET) |
333 | readsafe = 1; | 322 | break; |
334 | } | 323 | |
335 | loops--; | 324 | loops--; |
325 | if (loops == 0) { | ||
326 | dev_err(&udc->dev->dev, | ||
327 | "Timeout for ATDTW_TRIPWIRE...\n"); | ||
328 | retval = -ETIME; | ||
329 | goto done; | ||
330 | } | ||
336 | udelay(LOOPS_USEC); | 331 | udelay(LOOPS_USEC); |
337 | } | 332 | } |
338 | 333 | ||
339 | /* Clear the semaphore */ | 334 | /* Clear the semaphore */ |
340 | tmp = readl(&udc->op_regs->usbcmd); | 335 | usbcmd = readl(&udc->op_regs->usbcmd); |
341 | tmp &= USBCMD_ATDTW_TRIPWIRE_CLEAR; | 336 | usbcmd &= USBCMD_ATDTW_TRIPWIRE_CLEAR; |
342 | writel(tmp, &udc->op_regs->usbcmd); | 337 | writel(usbcmd, &udc->op_regs->usbcmd); |
343 | |||
344 | /* If endpoint is not active, we activate it now. */ | ||
345 | if (!epstatus) { | ||
346 | if (direction == EP_DIR_IN) { | ||
347 | struct mv_dtd *curr_dtd = dma_to_virt( | ||
348 | &udc->dev->dev, dqh->curr_dtd_ptr); | ||
349 | |||
350 | loops = LOOPS(DTD_TIMEOUT); | ||
351 | while (curr_dtd->size_ioc_sts | ||
352 | & DTD_STATUS_ACTIVE) { | ||
353 | if (loops == 0) { | ||
354 | retval = -ETIME; | ||
355 | goto done; | ||
356 | } | ||
357 | loops--; | ||
358 | udelay(LOOPS_USEC); | ||
359 | } | ||
360 | } | ||
361 | /* No other transfers on the queue */ | ||
362 | 338 | ||
363 | /* Write dQH next pointer and terminate bit to 0 */ | 339 | if (epstatus) |
364 | dqh->next_dtd_ptr = req->head->td_dma | 340 | goto done; |
365 | & EP_QUEUE_HEAD_NEXT_POINTER_MASK; | 341 | } |
366 | dqh->size_ioc_int_sts = 0; | ||
367 | 342 | ||
368 | /* | 343 | /* Write dQH next pointer and terminate bit to 0 */ |
369 | * Ensure that updates to the QH will | 344 | dqh->next_dtd_ptr = req->head->td_dma |
370 | * occur before priming. | 345 | & EP_QUEUE_HEAD_NEXT_POINTER_MASK; |
371 | */ | ||
372 | wmb(); | ||
373 | 346 | ||
374 | /* Prime the Endpoint */ | 347 | /* clear active and halt bit, in case set from a previous error */ |
375 | writel(bit_pos, &udc->op_regs->epprime); | 348 | dqh->size_ioc_int_sts &= ~(DTD_STATUS_ACTIVE | DTD_STATUS_HALTED); |
376 | } | ||
377 | } else { | ||
378 | /* Write dQH next pointer and terminate bit to 0 */ | ||
379 | dqh->next_dtd_ptr = req->head->td_dma | ||
380 | & EP_QUEUE_HEAD_NEXT_POINTER_MASK; | ||
381 | dqh->size_ioc_int_sts = 0; | ||
382 | 349 | ||
383 | /* Ensure that updates to the QH will occur before priming. */ | 350 | /* Ensure that updates to the QH will occure before priming. */ |
384 | wmb(); | 351 | wmb(); |
385 | 352 | ||
386 | /* Prime the Endpoint */ | 353 | /* Prime the Endpoint */ |
387 | writel(bit_pos, &udc->op_regs->epprime); | 354 | writel(bit_pos, &udc->op_regs->epprime); |
388 | 355 | ||
389 | if (direction == EP_DIR_IN) { | ||
390 | /* FIXME add status check after prime the IN ep */ | ||
391 | int prime_again; | ||
392 | u32 curr_dtd_ptr = dqh->curr_dtd_ptr; | ||
393 | |||
394 | loops = LOOPS(DTD_TIMEOUT); | ||
395 | prime_again = 0; | ||
396 | while ((curr_dtd_ptr != req->head->td_dma)) { | ||
397 | curr_dtd_ptr = dqh->curr_dtd_ptr; | ||
398 | if (loops == 0) { | ||
399 | dev_err(&udc->dev->dev, | ||
400 | "failed to prime %s\n", | ||
401 | ep->name); | ||
402 | retval = -ETIME; | ||
403 | goto done; | ||
404 | } | ||
405 | loops--; | ||
406 | udelay(LOOPS_USEC); | ||
407 | |||
408 | if (loops == (LOOPS(DTD_TIMEOUT) >> 2)) { | ||
409 | if (prime_again) | ||
410 | goto done; | ||
411 | dev_info(&udc->dev->dev, | ||
412 | "prime again\n"); | ||
413 | writel(bit_pos, | ||
414 | &udc->op_regs->epprime); | ||
415 | prime_again = 1; | ||
416 | } | ||
417 | } | ||
418 | } | ||
419 | } | ||
420 | done: | 356 | done: |
421 | return retval; | 357 | return retval; |
422 | } | 358 | } |
423 | 359 | ||
360 | |||
424 | static struct mv_dtd *build_dtd(struct mv_req *req, unsigned *length, | 361 | static struct mv_dtd *build_dtd(struct mv_req *req, unsigned *length, |
425 | dma_addr_t *dma, int *is_last) | 362 | dma_addr_t *dma, int *is_last) |
426 | { | 363 | { |
@@ -841,6 +778,27 @@ mv_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags) | |||
841 | return 0; | 778 | return 0; |
842 | } | 779 | } |
843 | 780 | ||
781 | static void mv_prime_ep(struct mv_ep *ep, struct mv_req *req) | ||
782 | { | ||
783 | struct mv_dqh *dqh = ep->dqh; | ||
784 | u32 bit_pos; | ||
785 | |||
786 | /* Write dQH next pointer and terminate bit to 0 */ | ||
787 | dqh->next_dtd_ptr = req->head->td_dma | ||
788 | & EP_QUEUE_HEAD_NEXT_POINTER_MASK; | ||
789 | |||
790 | /* clear active and halt bit, in case set from a previous error */ | ||
791 | dqh->size_ioc_int_sts &= ~(DTD_STATUS_ACTIVE | DTD_STATUS_HALTED); | ||
792 | |||
793 | /* Ensure that updates to the QH will occure before priming. */ | ||
794 | wmb(); | ||
795 | |||
796 | bit_pos = 1 << (((ep_dir(ep) == EP_DIR_OUT) ? 0 : 16) + ep->ep_num); | ||
797 | |||
798 | /* Prime the Endpoint */ | ||
799 | writel(bit_pos, &ep->udc->op_regs->epprime); | ||
800 | } | ||
801 | |||
844 | /* dequeues (cancels, unlinks) an I/O request from an endpoint */ | 802 | /* dequeues (cancels, unlinks) an I/O request from an endpoint */ |
845 | static int mv_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req) | 803 | static int mv_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req) |
846 | { | 804 | { |
@@ -883,15 +841,13 @@ static int mv_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req) | |||
883 | 841 | ||
884 | /* The request isn't the last request in this ep queue */ | 842 | /* The request isn't the last request in this ep queue */ |
885 | if (req->queue.next != &ep->queue) { | 843 | if (req->queue.next != &ep->queue) { |
886 | struct mv_dqh *qh; | ||
887 | struct mv_req *next_req; | 844 | struct mv_req *next_req; |
888 | 845 | ||
889 | qh = ep->dqh; | 846 | next_req = list_entry(req->queue.next, |
890 | next_req = list_entry(req->queue.next, struct mv_req, | 847 | struct mv_req, queue); |
891 | queue); | ||
892 | 848 | ||
893 | /* Point the QH to the first TD of next request */ | 849 | /* Point the QH to the first TD of next request */ |
894 | writel((u32) next_req->head, &qh->curr_dtd_ptr); | 850 | mv_prime_ep(ep, next_req); |
895 | } else { | 851 | } else { |
896 | struct mv_dqh *qh; | 852 | struct mv_dqh *qh; |
897 | 853 | ||
@@ -1056,6 +1012,8 @@ static void udc_stop(struct mv_udc *udc) | |||
1056 | USBINTR_PORT_CHANGE_DETECT_EN | USBINTR_RESET_EN); | 1012 | USBINTR_PORT_CHANGE_DETECT_EN | USBINTR_RESET_EN); |
1057 | writel(tmp, &udc->op_regs->usbintr); | 1013 | writel(tmp, &udc->op_regs->usbintr); |
1058 | 1014 | ||
1015 | udc->stopped = 1; | ||
1016 | |||
1059 | /* Reset the Run the bit in the command register to stop VUSB */ | 1017 | /* Reset the Run the bit in the command register to stop VUSB */ |
1060 | tmp = readl(&udc->op_regs->usbcmd); | 1018 | tmp = readl(&udc->op_regs->usbcmd); |
1061 | tmp &= ~USBCMD_RUN_STOP; | 1019 | tmp &= ~USBCMD_RUN_STOP; |
@@ -1072,6 +1030,8 @@ static void udc_start(struct mv_udc *udc) | |||
1072 | /* Enable interrupts */ | 1030 | /* Enable interrupts */ |
1073 | writel(usbintr, &udc->op_regs->usbintr); | 1031 | writel(usbintr, &udc->op_regs->usbintr); |
1074 | 1032 | ||
1033 | udc->stopped = 0; | ||
1034 | |||
1075 | /* Set the Run bit in the command register */ | 1035 | /* Set the Run bit in the command register */ |
1076 | writel(USBCMD_RUN_STOP, &udc->op_regs->usbcmd); | 1036 | writel(USBCMD_RUN_STOP, &udc->op_regs->usbcmd); |
1077 | } | 1037 | } |
@@ -1134,11 +1094,11 @@ static int udc_reset(struct mv_udc *udc) | |||
1134 | return 0; | 1094 | return 0; |
1135 | } | 1095 | } |
1136 | 1096 | ||
1137 | static int mv_udc_enable(struct mv_udc *udc) | 1097 | static int mv_udc_enable_internal(struct mv_udc *udc) |
1138 | { | 1098 | { |
1139 | int retval; | 1099 | int retval; |
1140 | 1100 | ||
1141 | if (udc->clock_gating == 0 || udc->active) | 1101 | if (udc->active) |
1142 | return 0; | 1102 | return 0; |
1143 | 1103 | ||
1144 | dev_dbg(&udc->dev->dev, "enable udc\n"); | 1104 | dev_dbg(&udc->dev->dev, "enable udc\n"); |
@@ -1157,9 +1117,17 @@ static int mv_udc_enable(struct mv_udc *udc) | |||
1157 | return 0; | 1117 | return 0; |
1158 | } | 1118 | } |
1159 | 1119 | ||
1160 | static void mv_udc_disable(struct mv_udc *udc) | 1120 | static int mv_udc_enable(struct mv_udc *udc) |
1161 | { | 1121 | { |
1162 | if (udc->clock_gating && udc->active) { | 1122 | if (udc->clock_gating) |
1123 | return mv_udc_enable_internal(udc); | ||
1124 | |||
1125 | return 0; | ||
1126 | } | ||
1127 | |||
1128 | static void mv_udc_disable_internal(struct mv_udc *udc) | ||
1129 | { | ||
1130 | if (udc->active) { | ||
1163 | dev_dbg(&udc->dev->dev, "disable udc\n"); | 1131 | dev_dbg(&udc->dev->dev, "disable udc\n"); |
1164 | if (udc->pdata->phy_deinit) | 1132 | if (udc->pdata->phy_deinit) |
1165 | udc->pdata->phy_deinit(udc->phy_regs); | 1133 | udc->pdata->phy_deinit(udc->phy_regs); |
@@ -1168,6 +1136,12 @@ static void mv_udc_disable(struct mv_udc *udc) | |||
1168 | } | 1136 | } |
1169 | } | 1137 | } |
1170 | 1138 | ||
1139 | static void mv_udc_disable(struct mv_udc *udc) | ||
1140 | { | ||
1141 | if (udc->clock_gating) | ||
1142 | mv_udc_disable_internal(udc); | ||
1143 | } | ||
1144 | |||
1171 | static int mv_udc_get_frame(struct usb_gadget *gadget) | 1145 | static int mv_udc_get_frame(struct usb_gadget *gadget) |
1172 | { | 1146 | { |
1173 | struct mv_udc *udc; | 1147 | struct mv_udc *udc; |
@@ -1178,7 +1152,7 @@ static int mv_udc_get_frame(struct usb_gadget *gadget) | |||
1178 | 1152 | ||
1179 | udc = container_of(gadget, struct mv_udc, gadget); | 1153 | udc = container_of(gadget, struct mv_udc, gadget); |
1180 | 1154 | ||
1181 | retval = readl(udc->op_regs->frindex) & USB_FRINDEX_MASKS; | 1155 | retval = readl(&udc->op_regs->frindex) & USB_FRINDEX_MASKS; |
1182 | 1156 | ||
1183 | return retval; | 1157 | return retval; |
1184 | } | 1158 | } |
@@ -1212,10 +1186,11 @@ static int mv_udc_vbus_session(struct usb_gadget *gadget, int is_active) | |||
1212 | udc = container_of(gadget, struct mv_udc, gadget); | 1186 | udc = container_of(gadget, struct mv_udc, gadget); |
1213 | spin_lock_irqsave(&udc->lock, flags); | 1187 | spin_lock_irqsave(&udc->lock, flags); |
1214 | 1188 | ||
1189 | udc->vbus_active = (is_active != 0); | ||
1190 | |||
1215 | dev_dbg(&udc->dev->dev, "%s: softconnect %d, vbus_active %d\n", | 1191 | dev_dbg(&udc->dev->dev, "%s: softconnect %d, vbus_active %d\n", |
1216 | __func__, udc->softconnect, udc->vbus_active); | 1192 | __func__, udc->softconnect, udc->vbus_active); |
1217 | 1193 | ||
1218 | udc->vbus_active = (is_active != 0); | ||
1219 | if (udc->driver && udc->softconnect && udc->vbus_active) { | 1194 | if (udc->driver && udc->softconnect && udc->vbus_active) { |
1220 | retval = mv_udc_enable(udc); | 1195 | retval = mv_udc_enable(udc); |
1221 | if (retval == 0) { | 1196 | if (retval == 0) { |
@@ -1244,10 +1219,11 @@ static int mv_udc_pullup(struct usb_gadget *gadget, int is_on) | |||
1244 | udc = container_of(gadget, struct mv_udc, gadget); | 1219 | udc = container_of(gadget, struct mv_udc, gadget); |
1245 | spin_lock_irqsave(&udc->lock, flags); | 1220 | spin_lock_irqsave(&udc->lock, flags); |
1246 | 1221 | ||
1222 | udc->softconnect = (is_on != 0); | ||
1223 | |||
1247 | dev_dbg(&udc->dev->dev, "%s: softconnect %d, vbus_active %d\n", | 1224 | dev_dbg(&udc->dev->dev, "%s: softconnect %d, vbus_active %d\n", |
1248 | __func__, udc->softconnect, udc->vbus_active); | 1225 | __func__, udc->softconnect, udc->vbus_active); |
1249 | 1226 | ||
1250 | udc->softconnect = (is_on != 0); | ||
1251 | if (udc->driver && udc->softconnect && udc->vbus_active) { | 1227 | if (udc->driver && udc->softconnect && udc->vbus_active) { |
1252 | retval = mv_udc_enable(udc); | 1228 | retval = mv_udc_enable(udc); |
1253 | if (retval == 0) { | 1229 | if (retval == 0) { |
@@ -1407,6 +1383,20 @@ static int mv_udc_start(struct usb_gadget_driver *driver, | |||
1407 | return retval; | 1383 | return retval; |
1408 | } | 1384 | } |
1409 | 1385 | ||
1386 | if (udc->transceiver) { | ||
1387 | retval = otg_set_peripheral(udc->transceiver, &udc->gadget); | ||
1388 | if (retval) { | ||
1389 | dev_err(&udc->dev->dev, | ||
1390 | "unable to register peripheral to otg\n"); | ||
1391 | if (driver->unbind) { | ||
1392 | driver->unbind(&udc->gadget); | ||
1393 | udc->gadget.dev.driver = NULL; | ||
1394 | udc->driver = NULL; | ||
1395 | } | ||
1396 | return retval; | ||
1397 | } | ||
1398 | } | ||
1399 | |||
1410 | /* pullup is always on */ | 1400 | /* pullup is always on */ |
1411 | mv_udc_pullup(&udc->gadget, 1); | 1401 | mv_udc_pullup(&udc->gadget, 1); |
1412 | 1402 | ||
@@ -2026,6 +2016,10 @@ static irqreturn_t mv_udc_irq(int irq, void *dev) | |||
2026 | struct mv_udc *udc = (struct mv_udc *)dev; | 2016 | struct mv_udc *udc = (struct mv_udc *)dev; |
2027 | u32 status, intr; | 2017 | u32 status, intr; |
2028 | 2018 | ||
2019 | /* Disable ISR when stopped bit is set */ | ||
2020 | if (udc->stopped) | ||
2021 | return IRQ_NONE; | ||
2022 | |||
2029 | spin_lock(&udc->lock); | 2023 | spin_lock(&udc->lock); |
2030 | 2024 | ||
2031 | status = readl(&udc->op_regs->usbsts); | 2025 | status = readl(&udc->op_regs->usbsts); |
@@ -2109,7 +2103,12 @@ static int __devexit mv_udc_remove(struct platform_device *dev) | |||
2109 | destroy_workqueue(udc->qwork); | 2103 | destroy_workqueue(udc->qwork); |
2110 | } | 2104 | } |
2111 | 2105 | ||
2112 | if (udc->pdata && udc->pdata->vbus && udc->clock_gating) | 2106 | /* |
2107 | * If we have transceiver inited, | ||
2108 | * then vbus irq will not be requested in udc driver. | ||
2109 | */ | ||
2110 | if (udc->pdata && udc->pdata->vbus | ||
2111 | && udc->clock_gating && udc->transceiver == NULL) | ||
2113 | free_irq(udc->pdata->vbus->irq, &dev->dev); | 2112 | free_irq(udc->pdata->vbus->irq, &dev->dev); |
2114 | 2113 | ||
2115 | /* free memory allocated in probe */ | 2114 | /* free memory allocated in probe */ |
@@ -2129,11 +2128,9 @@ static int __devexit mv_udc_remove(struct platform_device *dev) | |||
2129 | 2128 | ||
2130 | if (udc->cap_regs) | 2129 | if (udc->cap_regs) |
2131 | iounmap(udc->cap_regs); | 2130 | iounmap(udc->cap_regs); |
2132 | udc->cap_regs = NULL; | ||
2133 | 2131 | ||
2134 | if (udc->phy_regs) | 2132 | if (udc->phy_regs) |
2135 | iounmap((void *)udc->phy_regs); | 2133 | iounmap(udc->phy_regs); |
2136 | udc->phy_regs = 0; | ||
2137 | 2134 | ||
2138 | if (udc->status_req) { | 2135 | if (udc->status_req) { |
2139 | kfree(udc->status_req->req.buf); | 2136 | kfree(udc->status_req->req.buf); |
@@ -2182,6 +2179,11 @@ static int __devinit mv_udc_probe(struct platform_device *dev) | |||
2182 | 2179 | ||
2183 | udc->dev = dev; | 2180 | udc->dev = dev; |
2184 | 2181 | ||
2182 | #ifdef CONFIG_USB_OTG_UTILS | ||
2183 | if (pdata->mode == MV_USB_MODE_OTG) | ||
2184 | udc->transceiver = otg_get_transceiver(); | ||
2185 | #endif | ||
2186 | |||
2185 | udc->clknum = pdata->clknum; | 2187 | udc->clknum = pdata->clknum; |
2186 | for (clk_i = 0; clk_i < udc->clknum; clk_i++) { | 2188 | for (clk_i = 0; clk_i < udc->clknum; clk_i++) { |
2187 | udc->clk[clk_i] = clk_get(&dev->dev, pdata->clkname[clk_i]); | 2189 | udc->clk[clk_i] = clk_get(&dev->dev, pdata->clkname[clk_i]); |
@@ -2213,24 +2215,20 @@ static int __devinit mv_udc_probe(struct platform_device *dev) | |||
2213 | goto err_iounmap_capreg; | 2215 | goto err_iounmap_capreg; |
2214 | } | 2216 | } |
2215 | 2217 | ||
2216 | udc->phy_regs = (unsigned int)ioremap(r->start, resource_size(r)); | 2218 | udc->phy_regs = ioremap(r->start, resource_size(r)); |
2217 | if (udc->phy_regs == 0) { | 2219 | if (udc->phy_regs == NULL) { |
2218 | dev_err(&dev->dev, "failed to map phy I/O memory\n"); | 2220 | dev_err(&dev->dev, "failed to map phy I/O memory\n"); |
2219 | retval = -EBUSY; | 2221 | retval = -EBUSY; |
2220 | goto err_iounmap_capreg; | 2222 | goto err_iounmap_capreg; |
2221 | } | 2223 | } |
2222 | 2224 | ||
2223 | /* we will acces controller register, so enable the clk */ | 2225 | /* we will acces controller register, so enable the clk */ |
2224 | udc_clock_enable(udc); | 2226 | retval = mv_udc_enable_internal(udc); |
2225 | if (pdata->phy_init) { | 2227 | if (retval) |
2226 | retval = pdata->phy_init(udc->phy_regs); | 2228 | goto err_iounmap_phyreg; |
2227 | if (retval) { | ||
2228 | dev_err(&dev->dev, "phy init error %d\n", retval); | ||
2229 | goto err_iounmap_phyreg; | ||
2230 | } | ||
2231 | } | ||
2232 | 2229 | ||
2233 | udc->op_regs = (struct mv_op_regs __iomem *)((u32)udc->cap_regs | 2230 | udc->op_regs = |
2231 | (struct mv_op_regs __iomem *)((unsigned long)udc->cap_regs | ||
2234 | + (readl(&udc->cap_regs->caplength_hciversion) | 2232 | + (readl(&udc->cap_regs->caplength_hciversion) |
2235 | & CAPLENGTH_MASK)); | 2233 | & CAPLENGTH_MASK)); |
2236 | udc->max_eps = readl(&udc->cap_regs->dccparams) & DCCPARAMS_DEN_MASK; | 2234 | udc->max_eps = readl(&udc->cap_regs->dccparams) & DCCPARAMS_DEN_MASK; |
@@ -2312,7 +2310,7 @@ static int __devinit mv_udc_probe(struct platform_device *dev) | |||
2312 | udc->gadget.ep0 = &udc->eps[0].ep; /* gadget ep0 */ | 2310 | udc->gadget.ep0 = &udc->eps[0].ep; /* gadget ep0 */ |
2313 | INIT_LIST_HEAD(&udc->gadget.ep_list); /* ep_list */ | 2311 | INIT_LIST_HEAD(&udc->gadget.ep_list); /* ep_list */ |
2314 | udc->gadget.speed = USB_SPEED_UNKNOWN; /* speed */ | 2312 | udc->gadget.speed = USB_SPEED_UNKNOWN; /* speed */ |
2315 | udc->gadget.is_dualspeed = 1; /* support dual speed */ | 2313 | udc->gadget.max_speed = USB_SPEED_HIGH; /* support dual speed */ |
2316 | 2314 | ||
2317 | /* the "gadget" abstracts/virtualizes the controller */ | 2315 | /* the "gadget" abstracts/virtualizes the controller */ |
2318 | dev_set_name(&udc->gadget.dev, "gadget"); | 2316 | dev_set_name(&udc->gadget.dev, "gadget"); |
@@ -2328,7 +2326,9 @@ static int __devinit mv_udc_probe(struct platform_device *dev) | |||
2328 | eps_init(udc); | 2326 | eps_init(udc); |
2329 | 2327 | ||
2330 | /* VBUS detect: we can disable/enable clock on demand.*/ | 2328 | /* VBUS detect: we can disable/enable clock on demand.*/ |
2331 | if (pdata->vbus) { | 2329 | if (udc->transceiver) |
2330 | udc->clock_gating = 1; | ||
2331 | else if (pdata->vbus) { | ||
2332 | udc->clock_gating = 1; | 2332 | udc->clock_gating = 1; |
2333 | retval = request_threaded_irq(pdata->vbus->irq, NULL, | 2333 | retval = request_threaded_irq(pdata->vbus->irq, NULL, |
2334 | mv_udc_vbus_irq, IRQF_ONESHOT, "vbus", udc); | 2334 | mv_udc_vbus_irq, IRQF_ONESHOT, "vbus", udc); |
@@ -2354,11 +2354,9 @@ static int __devinit mv_udc_probe(struct platform_device *dev) | |||
2354 | * If not, it means that VBUS detection is not supported, we | 2354 | * If not, it means that VBUS detection is not supported, we |
2355 | * have to enable vbus active all the time to let controller work. | 2355 | * have to enable vbus active all the time to let controller work. |
2356 | */ | 2356 | */ |
2357 | if (udc->clock_gating) { | 2357 | if (udc->clock_gating) |
2358 | if (udc->pdata->phy_deinit) | 2358 | mv_udc_disable_internal(udc); |
2359 | udc->pdata->phy_deinit(udc->phy_regs); | 2359 | else |
2360 | udc_clock_disable(udc); | ||
2361 | } else | ||
2362 | udc->vbus_active = 1; | 2360 | udc->vbus_active = 1; |
2363 | 2361 | ||
2364 | retval = usb_add_gadget_udc(&dev->dev, &udc->gadget); | 2362 | retval = usb_add_gadget_udc(&dev->dev, &udc->gadget); |
@@ -2371,7 +2369,8 @@ static int __devinit mv_udc_probe(struct platform_device *dev) | |||
2371 | return 0; | 2369 | return 0; |
2372 | 2370 | ||
2373 | err_unregister: | 2371 | err_unregister: |
2374 | if (udc->pdata && udc->pdata->vbus && udc->clock_gating) | 2372 | if (udc->pdata && udc->pdata->vbus |
2373 | && udc->clock_gating && udc->transceiver == NULL) | ||
2375 | free_irq(pdata->vbus->irq, &dev->dev); | 2374 | free_irq(pdata->vbus->irq, &dev->dev); |
2376 | device_unregister(&udc->gadget.dev); | 2375 | device_unregister(&udc->gadget.dev); |
2377 | err_free_irq: | 2376 | err_free_irq: |
@@ -2387,11 +2386,9 @@ err_free_dma: | |||
2387 | dma_free_coherent(&dev->dev, udc->ep_dqh_size, | 2386 | dma_free_coherent(&dev->dev, udc->ep_dqh_size, |
2388 | udc->ep_dqh, udc->ep_dqh_dma); | 2387 | udc->ep_dqh, udc->ep_dqh_dma); |
2389 | err_disable_clock: | 2388 | err_disable_clock: |
2390 | if (udc->pdata->phy_deinit) | 2389 | mv_udc_disable_internal(udc); |
2391 | udc->pdata->phy_deinit(udc->phy_regs); | ||
2392 | udc_clock_disable(udc); | ||
2393 | err_iounmap_phyreg: | 2390 | err_iounmap_phyreg: |
2394 | iounmap((void *)udc->phy_regs); | 2391 | iounmap(udc->phy_regs); |
2395 | err_iounmap_capreg: | 2392 | err_iounmap_capreg: |
2396 | iounmap(udc->cap_regs); | 2393 | iounmap(udc->cap_regs); |
2397 | err_put_clk: | 2394 | err_put_clk: |
@@ -2407,7 +2404,30 @@ static int mv_udc_suspend(struct device *_dev) | |||
2407 | { | 2404 | { |
2408 | struct mv_udc *udc = the_controller; | 2405 | struct mv_udc *udc = the_controller; |
2409 | 2406 | ||
2410 | udc_stop(udc); | 2407 | /* if OTG is enabled, the following will be done in OTG driver*/ |
2408 | if (udc->transceiver) | ||
2409 | return 0; | ||
2410 | |||
2411 | if (udc->pdata->vbus && udc->pdata->vbus->poll) | ||
2412 | if (udc->pdata->vbus->poll() == VBUS_HIGH) { | ||
2413 | dev_info(&udc->dev->dev, "USB cable is connected!\n"); | ||
2414 | return -EAGAIN; | ||
2415 | } | ||
2416 | |||
2417 | /* | ||
2418 | * only cable is unplugged, udc can suspend. | ||
2419 | * So do not care about clock_gating == 1. | ||
2420 | */ | ||
2421 | if (!udc->clock_gating) { | ||
2422 | udc_stop(udc); | ||
2423 | |||
2424 | spin_lock_irq(&udc->lock); | ||
2425 | /* stop all usb activities */ | ||
2426 | stop_activity(udc, udc->driver); | ||
2427 | spin_unlock_irq(&udc->lock); | ||
2428 | |||
2429 | mv_udc_disable_internal(udc); | ||
2430 | } | ||
2411 | 2431 | ||
2412 | return 0; | 2432 | return 0; |
2413 | } | 2433 | } |
@@ -2417,20 +2437,22 @@ static int mv_udc_resume(struct device *_dev) | |||
2417 | struct mv_udc *udc = the_controller; | 2437 | struct mv_udc *udc = the_controller; |
2418 | int retval; | 2438 | int retval; |
2419 | 2439 | ||
2420 | if (udc->pdata->phy_init) { | 2440 | /* if OTG is enabled, the following will be done in OTG driver*/ |
2421 | retval = udc->pdata->phy_init(udc->phy_regs); | 2441 | if (udc->transceiver) |
2422 | if (retval) { | 2442 | return 0; |
2423 | dev_err(&udc->dev->dev, | 2443 | |
2424 | "init phy error %d when resume back\n", | 2444 | if (!udc->clock_gating) { |
2425 | retval); | 2445 | retval = mv_udc_enable_internal(udc); |
2446 | if (retval) | ||
2426 | return retval; | 2447 | return retval; |
2448 | |||
2449 | if (udc->driver && udc->softconnect) { | ||
2450 | udc_reset(udc); | ||
2451 | ep0_reset(udc); | ||
2452 | udc_start(udc); | ||
2427 | } | 2453 | } |
2428 | } | 2454 | } |
2429 | 2455 | ||
2430 | udc_reset(udc); | ||
2431 | ep0_reset(udc); | ||
2432 | udc_start(udc); | ||
2433 | |||
2434 | return 0; | 2456 | return 0; |
2435 | } | 2457 | } |
2436 | 2458 | ||
@@ -2457,30 +2479,16 @@ static struct platform_driver udc_driver = { | |||
2457 | .shutdown = mv_udc_shutdown, | 2479 | .shutdown = mv_udc_shutdown, |
2458 | .driver = { | 2480 | .driver = { |
2459 | .owner = THIS_MODULE, | 2481 | .owner = THIS_MODULE, |
2460 | .name = "pxa-u2o", | 2482 | .name = "mv-udc", |
2461 | #ifdef CONFIG_PM | 2483 | #ifdef CONFIG_PM |
2462 | .pm = &mv_udc_pm_ops, | 2484 | .pm = &mv_udc_pm_ops, |
2463 | #endif | 2485 | #endif |
2464 | }, | 2486 | }, |
2465 | }; | 2487 | }; |
2466 | MODULE_ALIAS("platform:pxa-u2o"); | ||
2467 | 2488 | ||
2489 | module_platform_driver(udc_driver); | ||
2490 | MODULE_ALIAS("platform:mv-udc"); | ||
2468 | MODULE_DESCRIPTION(DRIVER_DESC); | 2491 | MODULE_DESCRIPTION(DRIVER_DESC); |
2469 | MODULE_AUTHOR("Chao Xie <chao.xie@marvell.com>"); | 2492 | MODULE_AUTHOR("Chao Xie <chao.xie@marvell.com>"); |
2470 | MODULE_VERSION(DRIVER_VERSION); | 2493 | MODULE_VERSION(DRIVER_VERSION); |
2471 | MODULE_LICENSE("GPL"); | 2494 | MODULE_LICENSE("GPL"); |
2472 | |||
2473 | |||
2474 | static int __init init(void) | ||
2475 | { | ||
2476 | return platform_driver_register(&udc_driver); | ||
2477 | } | ||
2478 | module_init(init); | ||
2479 | |||
2480 | |||
2481 | static void __exit cleanup(void) | ||
2482 | { | ||
2483 | platform_driver_unregister(&udc_driver); | ||
2484 | } | ||
2485 | module_exit(cleanup); | ||
2486 | |||
diff --git a/drivers/usb/gadget/net2272.c b/drivers/usb/gadget/net2272.c index d1b76368472f..7322d293213e 100644 --- a/drivers/usb/gadget/net2272.c +++ b/drivers/usb/gadget/net2272.c | |||
@@ -69,7 +69,7 @@ static const char * const ep_name[] = { | |||
69 | * | 69 | * |
70 | * If use_dma is disabled, pio will be used instead. | 70 | * If use_dma is disabled, pio will be used instead. |
71 | */ | 71 | */ |
72 | static int use_dma = 0; | 72 | static bool use_dma = 0; |
73 | module_param(use_dma, bool, 0644); | 73 | module_param(use_dma, bool, 0644); |
74 | 74 | ||
75 | /* | 75 | /* |
@@ -1459,7 +1459,7 @@ static int net2272_start(struct usb_gadget *_gadget, | |||
1459 | unsigned i; | 1459 | unsigned i; |
1460 | 1460 | ||
1461 | if (!driver || !driver->unbind || !driver->setup || | 1461 | if (!driver || !driver->unbind || !driver->setup || |
1462 | driver->speed != USB_SPEED_HIGH) | 1462 | driver->max_speed != USB_SPEED_HIGH) |
1463 | return -EINVAL; | 1463 | return -EINVAL; |
1464 | 1464 | ||
1465 | dev = container_of(_gadget, struct net2272, gadget); | 1465 | dev = container_of(_gadget, struct net2272, gadget); |
@@ -2235,7 +2235,7 @@ net2272_probe_init(struct device *dev, unsigned int irq) | |||
2235 | ret->irq = irq; | 2235 | ret->irq = irq; |
2236 | ret->dev = dev; | 2236 | ret->dev = dev; |
2237 | ret->gadget.ops = &net2272_ops; | 2237 | ret->gadget.ops = &net2272_ops; |
2238 | ret->gadget.is_dualspeed = 1; | 2238 | ret->gadget.max_speed = USB_SPEED_HIGH; |
2239 | 2239 | ||
2240 | /* the "gadget" abstracts/virtualizes the controller */ | 2240 | /* the "gadget" abstracts/virtualizes the controller */ |
2241 | dev_set_name(&ret->gadget.dev, "gadget"); | 2241 | dev_set_name(&ret->gadget.dev, "gadget"); |
diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c index 7f1bc9a73cda..cdedd1336745 100644 --- a/drivers/usb/gadget/net2280.c +++ b/drivers/usb/gadget/net2280.c | |||
@@ -90,8 +90,8 @@ static const char *const ep_name [] = { | |||
90 | * Some gadget drivers work better with the dma support here than others. | 90 | * Some gadget drivers work better with the dma support here than others. |
91 | * These two parameters let you use PIO or more aggressive DMA. | 91 | * These two parameters let you use PIO or more aggressive DMA. |
92 | */ | 92 | */ |
93 | static int use_dma = 1; | 93 | static bool use_dma = 1; |
94 | static int use_dma_chaining = 0; | 94 | static bool use_dma_chaining = 0; |
95 | 95 | ||
96 | /* "modprobe net2280 use_dma=n" etc */ | 96 | /* "modprobe net2280 use_dma=n" etc */ |
97 | module_param (use_dma, bool, S_IRUGO); | 97 | module_param (use_dma, bool, S_IRUGO); |
@@ -112,7 +112,7 @@ module_param (fifo_mode, ushort, 0644); | |||
112 | * USB suspend requests will be ignored. This is acceptable for | 112 | * USB suspend requests will be ignored. This is acceptable for |
113 | * self-powered devices | 113 | * self-powered devices |
114 | */ | 114 | */ |
115 | static int enable_suspend = 0; | 115 | static bool enable_suspend = 0; |
116 | 116 | ||
117 | /* "modprobe net2280 enable_suspend=1" etc */ | 117 | /* "modprobe net2280 enable_suspend=1" etc */ |
118 | module_param (enable_suspend, bool, S_IRUGO); | 118 | module_param (enable_suspend, bool, S_IRUGO); |
@@ -1881,7 +1881,7 @@ static int net2280_start(struct usb_gadget *_gadget, | |||
1881 | * (dev->usb->xcvrdiag & FORCE_FULL_SPEED_MODE) | 1881 | * (dev->usb->xcvrdiag & FORCE_FULL_SPEED_MODE) |
1882 | * "must not be used in normal operation" | 1882 | * "must not be used in normal operation" |
1883 | */ | 1883 | */ |
1884 | if (!driver || driver->speed != USB_SPEED_HIGH | 1884 | if (!driver || driver->max_speed < USB_SPEED_HIGH |
1885 | || !driver->setup) | 1885 | || !driver->setup) |
1886 | return -EINVAL; | 1886 | return -EINVAL; |
1887 | 1887 | ||
@@ -2698,7 +2698,7 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id) | |||
2698 | spin_lock_init (&dev->lock); | 2698 | spin_lock_init (&dev->lock); |
2699 | dev->pdev = pdev; | 2699 | dev->pdev = pdev; |
2700 | dev->gadget.ops = &net2280_ops; | 2700 | dev->gadget.ops = &net2280_ops; |
2701 | dev->gadget.is_dualspeed = 1; | 2701 | dev->gadget.max_speed = USB_SPEED_HIGH; |
2702 | 2702 | ||
2703 | /* the "gadget" abstracts/virtualizes the controller */ | 2703 | /* the "gadget" abstracts/virtualizes the controller */ |
2704 | dev_set_name(&dev->gadget.dev, "gadget"); | 2704 | dev_set_name(&dev->gadget.dev, "gadget"); |
diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c index 788989a10223..576cd8578b45 100644 --- a/drivers/usb/gadget/omap_udc.c +++ b/drivers/usb/gadget/omap_udc.c | |||
@@ -98,7 +98,7 @@ module_param (fifo_mode, uint, 0); | |||
98 | MODULE_PARM_DESC (fifo_mode, "endpoint configuration"); | 98 | MODULE_PARM_DESC (fifo_mode, "endpoint configuration"); |
99 | 99 | ||
100 | #ifdef USE_DMA | 100 | #ifdef USE_DMA |
101 | static unsigned use_dma = 1; | 101 | static bool use_dma = 1; |
102 | 102 | ||
103 | /* "modprobe omap_udc use_dma=y", or else as a kernel | 103 | /* "modprobe omap_udc use_dma=y", or else as a kernel |
104 | * boot parameter "omap_udc:use_dma=y" | 104 | * boot parameter "omap_udc:use_dma=y" |
@@ -2110,7 +2110,7 @@ static int omap_udc_start(struct usb_gadget_driver *driver, | |||
2110 | return -ENODEV; | 2110 | return -ENODEV; |
2111 | if (!driver | 2111 | if (!driver |
2112 | // FIXME if otg, check: driver->is_otg | 2112 | // FIXME if otg, check: driver->is_otg |
2113 | || driver->speed < USB_SPEED_FULL | 2113 | || driver->max_speed < USB_SPEED_FULL |
2114 | || !bind || !driver->setup) | 2114 | || !bind || !driver->setup) |
2115 | return -EINVAL; | 2115 | return -EINVAL; |
2116 | 2116 | ||
@@ -2676,6 +2676,7 @@ omap_udc_setup(struct platform_device *odev, struct otg_transceiver *xceiv) | |||
2676 | INIT_LIST_HEAD(&udc->gadget.ep_list); | 2676 | INIT_LIST_HEAD(&udc->gadget.ep_list); |
2677 | INIT_LIST_HEAD(&udc->iso); | 2677 | INIT_LIST_HEAD(&udc->iso); |
2678 | udc->gadget.speed = USB_SPEED_UNKNOWN; | 2678 | udc->gadget.speed = USB_SPEED_UNKNOWN; |
2679 | udc->gadget.max_speed = USB_SPEED_FULL; | ||
2679 | udc->gadget.name = driver_name; | 2680 | udc->gadget.name = driver_name; |
2680 | 2681 | ||
2681 | device_initialize(&udc->gadget.dev); | 2682 | device_initialize(&udc->gadget.dev); |
diff --git a/drivers/usb/gadget/pch_udc.c b/drivers/usb/gadget/pch_udc.c index 550d6dcdf104..a3fcaae4bc2a 100644 --- a/drivers/usb/gadget/pch_udc.c +++ b/drivers/usb/gadget/pch_udc.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2010 OKI SEMICONDUCTOR CO., LTD. | 2 | * Copyright (C) 2011 LAPIS Semiconductor Co., Ltd. |
3 | * | 3 | * |
4 | * This program is free software; you can redistribute it and/or modify | 4 | * This program is free software; you can redistribute it and/or modify |
5 | * it under the terms of the GNU General Public License as published by | 5 | * it under the terms of the GNU General Public License as published by |
@@ -354,11 +354,12 @@ struct pch_udc_dev { | |||
354 | #define PCI_DEVICE_ID_INTEL_EG20T_UDC 0x8808 | 354 | #define PCI_DEVICE_ID_INTEL_EG20T_UDC 0x8808 |
355 | #define PCI_VENDOR_ID_ROHM 0x10DB | 355 | #define PCI_VENDOR_ID_ROHM 0x10DB |
356 | #define PCI_DEVICE_ID_ML7213_IOH_UDC 0x801D | 356 | #define PCI_DEVICE_ID_ML7213_IOH_UDC 0x801D |
357 | #define PCI_DEVICE_ID_ML7831_IOH_UDC 0x8808 | ||
357 | 358 | ||
358 | static const char ep0_string[] = "ep0in"; | 359 | static const char ep0_string[] = "ep0in"; |
359 | static DEFINE_SPINLOCK(udc_stall_spinlock); /* stall spin lock */ | 360 | static DEFINE_SPINLOCK(udc_stall_spinlock); /* stall spin lock */ |
360 | struct pch_udc_dev *pch_udc; /* pointer to device object */ | 361 | struct pch_udc_dev *pch_udc; /* pointer to device object */ |
361 | static int speed_fs; | 362 | static bool speed_fs; |
362 | module_param_named(speed_fs, speed_fs, bool, S_IRUGO); | 363 | module_param_named(speed_fs, speed_fs, bool, S_IRUGO); |
363 | MODULE_PARM_DESC(speed_fs, "true for Full speed operation"); | 364 | MODULE_PARM_DESC(speed_fs, "true for Full speed operation"); |
364 | 365 | ||
@@ -2692,7 +2693,7 @@ static int pch_udc_start(struct usb_gadget_driver *driver, | |||
2692 | struct pch_udc_dev *dev = pch_udc; | 2693 | struct pch_udc_dev *dev = pch_udc; |
2693 | int retval; | 2694 | int retval; |
2694 | 2695 | ||
2695 | if (!driver || (driver->speed == USB_SPEED_UNKNOWN) || !bind || | 2696 | if (!driver || (driver->max_speed == USB_SPEED_UNKNOWN) || !bind || |
2696 | !driver->setup || !driver->unbind || !driver->disconnect) { | 2697 | !driver->setup || !driver->unbind || !driver->disconnect) { |
2697 | dev_err(&dev->pdev->dev, | 2698 | dev_err(&dev->pdev->dev, |
2698 | "%s: invalid driver parameter\n", __func__); | 2699 | "%s: invalid driver parameter\n", __func__); |
@@ -2940,7 +2941,7 @@ static int pch_udc_probe(struct pci_dev *pdev, | |||
2940 | dev->gadget.dev.dma_mask = pdev->dev.dma_mask; | 2941 | dev->gadget.dev.dma_mask = pdev->dev.dma_mask; |
2941 | dev->gadget.dev.release = gadget_release; | 2942 | dev->gadget.dev.release = gadget_release; |
2942 | dev->gadget.name = KBUILD_MODNAME; | 2943 | dev->gadget.name = KBUILD_MODNAME; |
2943 | dev->gadget.is_dualspeed = 1; | 2944 | dev->gadget.max_speed = USB_SPEED_HIGH; |
2944 | 2945 | ||
2945 | retval = device_register(&dev->gadget.dev); | 2946 | retval = device_register(&dev->gadget.dev); |
2946 | if (retval) | 2947 | if (retval) |
@@ -2970,6 +2971,11 @@ static DEFINE_PCI_DEVICE_TABLE(pch_udc_pcidev_id) = { | |||
2970 | .class = (PCI_CLASS_SERIAL_USB << 8) | 0xfe, | 2971 | .class = (PCI_CLASS_SERIAL_USB << 8) | 0xfe, |
2971 | .class_mask = 0xffffffff, | 2972 | .class_mask = 0xffffffff, |
2972 | }, | 2973 | }, |
2974 | { | ||
2975 | PCI_DEVICE(PCI_VENDOR_ID_ROHM, PCI_DEVICE_ID_ML7831_IOH_UDC), | ||
2976 | .class = (PCI_CLASS_SERIAL_USB << 8) | 0xfe, | ||
2977 | .class_mask = 0xffffffff, | ||
2978 | }, | ||
2973 | { 0 }, | 2979 | { 0 }, |
2974 | }; | 2980 | }; |
2975 | 2981 | ||
@@ -2999,5 +3005,5 @@ static void __exit pch_udc_pci_exit(void) | |||
2999 | module_exit(pch_udc_pci_exit); | 3005 | module_exit(pch_udc_pci_exit); |
3000 | 3006 | ||
3001 | MODULE_DESCRIPTION("Intel EG20T USB Device Controller"); | 3007 | MODULE_DESCRIPTION("Intel EG20T USB Device Controller"); |
3002 | MODULE_AUTHOR("OKI SEMICONDUCTOR, <toshiharu-linux@dsn.okisemi.com>"); | 3008 | MODULE_AUTHOR("LAPIS Semiconductor, <tomoya-linux@dsn.lapis-semi.com>"); |
3003 | MODULE_LICENSE("GPL"); | 3009 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/usb/gadget/printer.c b/drivers/usb/gadget/printer.c index 65a8834f274b..d83134b0f78a 100644 --- a/drivers/usb/gadget/printer.c +++ b/drivers/usb/gadget/printer.c | |||
@@ -1141,7 +1141,7 @@ printer_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) | |||
1141 | break; | 1141 | break; |
1142 | #ifdef CONFIG_USB_GADGET_DUALSPEED | 1142 | #ifdef CONFIG_USB_GADGET_DUALSPEED |
1143 | case USB_DT_DEVICE_QUALIFIER: | 1143 | case USB_DT_DEVICE_QUALIFIER: |
1144 | if (!gadget->is_dualspeed) | 1144 | if (!gadget_is_dualspeed(gadget)) |
1145 | break; | 1145 | break; |
1146 | /* | 1146 | /* |
1147 | * assumes ep0 uses the same value for both | 1147 | * assumes ep0 uses the same value for both |
@@ -1155,7 +1155,7 @@ printer_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) | |||
1155 | break; | 1155 | break; |
1156 | 1156 | ||
1157 | case USB_DT_OTHER_SPEED_CONFIG: | 1157 | case USB_DT_OTHER_SPEED_CONFIG: |
1158 | if (!gadget->is_dualspeed) | 1158 | if (!gadget_is_dualspeed(gadget)) |
1159 | break; | 1159 | break; |
1160 | /* FALLTHROUGH */ | 1160 | /* FALLTHROUGH */ |
1161 | #endif /* CONFIG_USB_GADGET_DUALSPEED */ | 1161 | #endif /* CONFIG_USB_GADGET_DUALSPEED */ |
@@ -1535,7 +1535,7 @@ fail: | |||
1535 | /*-------------------------------------------------------------------------*/ | 1535 | /*-------------------------------------------------------------------------*/ |
1536 | 1536 | ||
1537 | static struct usb_gadget_driver printer_driver = { | 1537 | static struct usb_gadget_driver printer_driver = { |
1538 | .speed = DEVSPEED, | 1538 | .max_speed = DEVSPEED, |
1539 | 1539 | ||
1540 | .function = (char *) driver_desc, | 1540 | .function = (char *) driver_desc, |
1541 | .unbind = printer_unbind, | 1541 | .unbind = printer_unbind, |
diff --git a/drivers/usb/gadget/pxa25x_udc.c b/drivers/usb/gadget/pxa25x_udc.c index c090a7e3ecf8..dd470635f4f7 100644 --- a/drivers/usb/gadget/pxa25x_udc.c +++ b/drivers/usb/gadget/pxa25x_udc.c | |||
@@ -1264,7 +1264,7 @@ static int pxa25x_start(struct usb_gadget_driver *driver, | |||
1264 | int retval; | 1264 | int retval; |
1265 | 1265 | ||
1266 | if (!driver | 1266 | if (!driver |
1267 | || driver->speed < USB_SPEED_FULL | 1267 | || driver->max_speed < USB_SPEED_FULL |
1268 | || !bind | 1268 | || !bind |
1269 | || !driver->disconnect | 1269 | || !driver->disconnect |
1270 | || !driver->setup) | 1270 | || !driver->setup) |
diff --git a/drivers/usb/gadget/pxa27x_udc.c b/drivers/usb/gadget/pxa27x_udc.c index 18b6b091f2a6..f4c44eb806c3 100644 --- a/drivers/usb/gadget/pxa27x_udc.c +++ b/drivers/usb/gadget/pxa27x_udc.c | |||
@@ -1807,7 +1807,7 @@ static int pxa27x_udc_start(struct usb_gadget_driver *driver, | |||
1807 | struct pxa_udc *udc = the_controller; | 1807 | struct pxa_udc *udc = the_controller; |
1808 | int retval; | 1808 | int retval; |
1809 | 1809 | ||
1810 | if (!driver || driver->speed < USB_SPEED_FULL || !bind | 1810 | if (!driver || driver->max_speed < USB_SPEED_FULL || !bind |
1811 | || !driver->disconnect || !driver->setup) | 1811 | || !driver->disconnect || !driver->setup) |
1812 | return -EINVAL; | 1812 | return -EINVAL; |
1813 | if (!udc) | 1813 | if (!udc) |
diff --git a/drivers/usb/gadget/r8a66597-udc.c b/drivers/usb/gadget/r8a66597-udc.c index 68a826a1b866..f5b8d215e1d5 100644 --- a/drivers/usb/gadget/r8a66597-udc.c +++ b/drivers/usb/gadget/r8a66597-udc.c | |||
@@ -1718,6 +1718,8 @@ static void r8a66597_fifo_flush(struct usb_ep *_ep) | |||
1718 | if (list_empty(&ep->queue) && !ep->busy) { | 1718 | if (list_empty(&ep->queue) && !ep->busy) { |
1719 | pipe_stop(ep->r8a66597, ep->pipenum); | 1719 | pipe_stop(ep->r8a66597, ep->pipenum); |
1720 | r8a66597_bclr(ep->r8a66597, BCLR, ep->fifoctr); | 1720 | r8a66597_bclr(ep->r8a66597, BCLR, ep->fifoctr); |
1721 | r8a66597_write(ep->r8a66597, ACLRM, ep->pipectr); | ||
1722 | r8a66597_write(ep->r8a66597, 0, ep->pipectr); | ||
1721 | } | 1723 | } |
1722 | spin_unlock_irqrestore(&ep->r8a66597->lock, flags); | 1724 | spin_unlock_irqrestore(&ep->r8a66597->lock, flags); |
1723 | } | 1725 | } |
@@ -1742,26 +1744,16 @@ static int r8a66597_start(struct usb_gadget *gadget, | |||
1742 | struct usb_gadget_driver *driver) | 1744 | struct usb_gadget_driver *driver) |
1743 | { | 1745 | { |
1744 | struct r8a66597 *r8a66597 = gadget_to_r8a66597(gadget); | 1746 | struct r8a66597 *r8a66597 = gadget_to_r8a66597(gadget); |
1745 | int retval; | ||
1746 | 1747 | ||
1747 | if (!driver | 1748 | if (!driver |
1748 | || driver->speed != USB_SPEED_HIGH | 1749 | || driver->max_speed < USB_SPEED_HIGH |
1749 | || !driver->setup) | 1750 | || !driver->setup) |
1750 | return -EINVAL; | 1751 | return -EINVAL; |
1751 | if (!r8a66597) | 1752 | if (!r8a66597) |
1752 | return -ENODEV; | 1753 | return -ENODEV; |
1753 | 1754 | ||
1754 | /* hook up the driver */ | 1755 | /* hook up the driver */ |
1755 | driver->driver.bus = NULL; | ||
1756 | r8a66597->driver = driver; | 1756 | r8a66597->driver = driver; |
1757 | r8a66597->gadget.dev.driver = &driver->driver; | ||
1758 | |||
1759 | retval = device_add(&r8a66597->gadget.dev); | ||
1760 | if (retval) { | ||
1761 | dev_err(r8a66597_to_dev(r8a66597), "device_add error (%d)\n", | ||
1762 | retval); | ||
1763 | goto error; | ||
1764 | } | ||
1765 | 1757 | ||
1766 | init_controller(r8a66597); | 1758 | init_controller(r8a66597); |
1767 | r8a66597_bset(r8a66597, VBSE, INTENB0); | 1759 | r8a66597_bset(r8a66597, VBSE, INTENB0); |
@@ -1775,12 +1767,6 @@ static int r8a66597_start(struct usb_gadget *gadget, | |||
1775 | } | 1767 | } |
1776 | 1768 | ||
1777 | return 0; | 1769 | return 0; |
1778 | |||
1779 | error: | ||
1780 | r8a66597->driver = NULL; | ||
1781 | r8a66597->gadget.dev.driver = NULL; | ||
1782 | |||
1783 | return retval; | ||
1784 | } | 1770 | } |
1785 | 1771 | ||
1786 | static int r8a66597_stop(struct usb_gadget *gadget, | 1772 | static int r8a66597_stop(struct usb_gadget *gadget, |
@@ -1794,7 +1780,6 @@ static int r8a66597_stop(struct usb_gadget *gadget, | |||
1794 | disable_controller(r8a66597); | 1780 | disable_controller(r8a66597); |
1795 | spin_unlock_irqrestore(&r8a66597->lock, flags); | 1781 | spin_unlock_irqrestore(&r8a66597->lock, flags); |
1796 | 1782 | ||
1797 | device_del(&r8a66597->gadget.dev); | ||
1798 | r8a66597->driver = NULL; | 1783 | r8a66597->driver = NULL; |
1799 | return 0; | 1784 | return 0; |
1800 | } | 1785 | } |
@@ -1845,6 +1830,7 @@ static int __exit r8a66597_remove(struct platform_device *pdev) | |||
1845 | clk_put(r8a66597->clk); | 1830 | clk_put(r8a66597->clk); |
1846 | } | 1831 | } |
1847 | #endif | 1832 | #endif |
1833 | device_unregister(&r8a66597->gadget.dev); | ||
1848 | kfree(r8a66597); | 1834 | kfree(r8a66597); |
1849 | return 0; | 1835 | return 0; |
1850 | } | 1836 | } |
@@ -1924,13 +1910,17 @@ static int __init r8a66597_probe(struct platform_device *pdev) | |||
1924 | r8a66597->irq_sense_low = irq_trigger == IRQF_TRIGGER_LOW; | 1910 | r8a66597->irq_sense_low = irq_trigger == IRQF_TRIGGER_LOW; |
1925 | 1911 | ||
1926 | r8a66597->gadget.ops = &r8a66597_gadget_ops; | 1912 | r8a66597->gadget.ops = &r8a66597_gadget_ops; |
1927 | device_initialize(&r8a66597->gadget.dev); | ||
1928 | dev_set_name(&r8a66597->gadget.dev, "gadget"); | 1913 | dev_set_name(&r8a66597->gadget.dev, "gadget"); |
1929 | r8a66597->gadget.is_dualspeed = 1; | 1914 | r8a66597->gadget.max_speed = USB_SPEED_HIGH; |
1930 | r8a66597->gadget.dev.parent = &pdev->dev; | 1915 | r8a66597->gadget.dev.parent = &pdev->dev; |
1931 | r8a66597->gadget.dev.dma_mask = pdev->dev.dma_mask; | 1916 | r8a66597->gadget.dev.dma_mask = pdev->dev.dma_mask; |
1932 | r8a66597->gadget.dev.release = pdev->dev.release; | 1917 | r8a66597->gadget.dev.release = pdev->dev.release; |
1933 | r8a66597->gadget.name = udc_name; | 1918 | r8a66597->gadget.name = udc_name; |
1919 | ret = device_register(&r8a66597->gadget.dev); | ||
1920 | if (ret < 0) { | ||
1921 | dev_err(&pdev->dev, "device_register failed\n"); | ||
1922 | goto clean_up; | ||
1923 | } | ||
1934 | 1924 | ||
1935 | init_timer(&r8a66597->timer); | 1925 | init_timer(&r8a66597->timer); |
1936 | r8a66597->timer.function = r8a66597_timer; | 1926 | r8a66597->timer.function = r8a66597_timer; |
@@ -1945,7 +1935,7 @@ static int __init r8a66597_probe(struct platform_device *pdev) | |||
1945 | dev_err(&pdev->dev, "cannot get clock \"%s\"\n", | 1935 | dev_err(&pdev->dev, "cannot get clock \"%s\"\n", |
1946 | clk_name); | 1936 | clk_name); |
1947 | ret = PTR_ERR(r8a66597->clk); | 1937 | ret = PTR_ERR(r8a66597->clk); |
1948 | goto clean_up; | 1938 | goto clean_up_dev; |
1949 | } | 1939 | } |
1950 | clk_enable(r8a66597->clk); | 1940 | clk_enable(r8a66597->clk); |
1951 | } | 1941 | } |
@@ -2014,7 +2004,9 @@ clean_up2: | |||
2014 | clk_disable(r8a66597->clk); | 2004 | clk_disable(r8a66597->clk); |
2015 | clk_put(r8a66597->clk); | 2005 | clk_put(r8a66597->clk); |
2016 | } | 2006 | } |
2007 | clean_up_dev: | ||
2017 | #endif | 2008 | #endif |
2009 | device_unregister(&r8a66597->gadget.dev); | ||
2018 | clean_up: | 2010 | clean_up: |
2019 | if (r8a66597) { | 2011 | if (r8a66597) { |
2020 | if (r8a66597->sudmac_reg) | 2012 | if (r8a66597->sudmac_reg) |
diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c index a552453dc946..69295ba9d99a 100644 --- a/drivers/usb/gadget/s3c-hsotg.c +++ b/drivers/usb/gadget/s3c-hsotg.c | |||
@@ -2586,10 +2586,8 @@ static int s3c_hsotg_start(struct usb_gadget_driver *driver, | |||
2586 | return -EINVAL; | 2586 | return -EINVAL; |
2587 | } | 2587 | } |
2588 | 2588 | ||
2589 | if (driver->speed != USB_SPEED_HIGH && | 2589 | if (driver->max_speed < USB_SPEED_FULL) |
2590 | driver->speed != USB_SPEED_FULL) { | ||
2591 | dev_err(hsotg->dev, "%s: bad speed\n", __func__); | 2590 | dev_err(hsotg->dev, "%s: bad speed\n", __func__); |
2592 | } | ||
2593 | 2591 | ||
2594 | if (!bind || !driver->setup) { | 2592 | if (!bind || !driver->setup) { |
2595 | dev_err(hsotg->dev, "%s: missing entry points\n", __func__); | 2593 | dev_err(hsotg->dev, "%s: missing entry points\n", __func__); |
@@ -3364,7 +3362,7 @@ static int __devinit s3c_hsotg_probe(struct platform_device *pdev) | |||
3364 | 3362 | ||
3365 | dev_set_name(&hsotg->gadget.dev, "gadget"); | 3363 | dev_set_name(&hsotg->gadget.dev, "gadget"); |
3366 | 3364 | ||
3367 | hsotg->gadget.is_dualspeed = 1; | 3365 | hsotg->gadget.max_speed = USB_SPEED_HIGH; |
3368 | hsotg->gadget.ops = &s3c_hsotg_gadget_ops; | 3366 | hsotg->gadget.ops = &s3c_hsotg_gadget_ops; |
3369 | hsotg->gadget.name = dev_name(dev); | 3367 | hsotg->gadget.name = dev_name(dev); |
3370 | 3368 | ||
@@ -3469,18 +3467,7 @@ static struct platform_driver s3c_hsotg_driver = { | |||
3469 | .resume = s3c_hsotg_resume, | 3467 | .resume = s3c_hsotg_resume, |
3470 | }; | 3468 | }; |
3471 | 3469 | ||
3472 | static int __init s3c_hsotg_modinit(void) | 3470 | module_platform_driver(s3c_hsotg_driver); |
3473 | { | ||
3474 | return platform_driver_register(&s3c_hsotg_driver); | ||
3475 | } | ||
3476 | |||
3477 | static void __exit s3c_hsotg_modexit(void) | ||
3478 | { | ||
3479 | platform_driver_unregister(&s3c_hsotg_driver); | ||
3480 | } | ||
3481 | |||
3482 | module_init(s3c_hsotg_modinit); | ||
3483 | module_exit(s3c_hsotg_modexit); | ||
3484 | 3471 | ||
3485 | MODULE_DESCRIPTION("Samsung S3C USB High-speed/OtG device"); | 3472 | MODULE_DESCRIPTION("Samsung S3C USB High-speed/OtG device"); |
3486 | MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>"); | 3473 | MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>"); |
diff --git a/drivers/usb/gadget/s3c-hsudc.c b/drivers/usb/gadget/s3c-hsudc.c index 8d54f893cefe..df8661d266cb 100644 --- a/drivers/usb/gadget/s3c-hsudc.c +++ b/drivers/usb/gadget/s3c-hsudc.c | |||
@@ -28,9 +28,10 @@ | |||
28 | #include <linux/usb/gadget.h> | 28 | #include <linux/usb/gadget.h> |
29 | #include <linux/usb/otg.h> | 29 | #include <linux/usb/otg.h> |
30 | #include <linux/prefetch.h> | 30 | #include <linux/prefetch.h> |
31 | #include <linux/platform_data/s3c-hsudc.h> | ||
32 | #include <linux/regulator/consumer.h> | ||
31 | 33 | ||
32 | #include <mach/regs-s3c2443-clock.h> | 34 | #include <mach/regs-s3c2443-clock.h> |
33 | #include <plat/udc.h> | ||
34 | 35 | ||
35 | #define S3C_HSUDC_REG(x) (x) | 36 | #define S3C_HSUDC_REG(x) (x) |
36 | 37 | ||
@@ -87,6 +88,12 @@ | |||
87 | #define DATA_STATE_XMIT (1) | 88 | #define DATA_STATE_XMIT (1) |
88 | #define DATA_STATE_RECV (2) | 89 | #define DATA_STATE_RECV (2) |
89 | 90 | ||
91 | static const char * const s3c_hsudc_supply_names[] = { | ||
92 | "vdda", /* analog phy supply, 3.3V */ | ||
93 | "vddi", /* digital phy supply, 1.2V */ | ||
94 | "vddosc", /* oscillator supply, 1.8V - 3.3V */ | ||
95 | }; | ||
96 | |||
90 | /** | 97 | /** |
91 | * struct s3c_hsudc_ep - Endpoint representation used by driver. | 98 | * struct s3c_hsudc_ep - Endpoint representation used by driver. |
92 | * @ep: USB gadget layer representation of device endpoint. | 99 | * @ep: USB gadget layer representation of device endpoint. |
@@ -139,6 +146,7 @@ struct s3c_hsudc { | |||
139 | struct device *dev; | 146 | struct device *dev; |
140 | struct s3c24xx_hsudc_platdata *pd; | 147 | struct s3c24xx_hsudc_platdata *pd; |
141 | struct otg_transceiver *transceiver; | 148 | struct otg_transceiver *transceiver; |
149 | struct regulator_bulk_data supplies[ARRAY_SIZE(s3c_hsudc_supply_names)]; | ||
142 | spinlock_t lock; | 150 | spinlock_t lock; |
143 | void __iomem *regs; | 151 | void __iomem *regs; |
144 | struct resource *mem_rsrc; | 152 | struct resource *mem_rsrc; |
@@ -153,7 +161,6 @@ struct s3c_hsudc { | |||
153 | #define ep_index(_ep) ((_ep)->bEndpointAddress & \ | 161 | #define ep_index(_ep) ((_ep)->bEndpointAddress & \ |
154 | USB_ENDPOINT_NUMBER_MASK) | 162 | USB_ENDPOINT_NUMBER_MASK) |
155 | 163 | ||
156 | static struct s3c_hsudc *the_controller; | ||
157 | static const char driver_name[] = "s3c-udc"; | 164 | static const char driver_name[] = "s3c-udc"; |
158 | static const char ep0name[] = "ep0-control"; | 165 | static const char ep0name[] = "ep0-control"; |
159 | 166 | ||
@@ -282,8 +289,7 @@ static void s3c_hsudc_nuke_ep(struct s3c_hsudc_ep *hsep, int status) | |||
282 | * All the endpoints are stopped and any pending transfer requests if any on | 289 | * All the endpoints are stopped and any pending transfer requests if any on |
283 | * the endpoint are terminated. | 290 | * the endpoint are terminated. |
284 | */ | 291 | */ |
285 | static void s3c_hsudc_stop_activity(struct s3c_hsudc *hsudc, | 292 | static void s3c_hsudc_stop_activity(struct s3c_hsudc *hsudc) |
286 | struct usb_gadget_driver *driver) | ||
287 | { | 293 | { |
288 | struct s3c_hsudc_ep *hsep; | 294 | struct s3c_hsudc_ep *hsep; |
289 | int epnum; | 295 | int epnum; |
@@ -295,10 +301,6 @@ static void s3c_hsudc_stop_activity(struct s3c_hsudc *hsudc, | |||
295 | hsep->stopped = 1; | 301 | hsep->stopped = 1; |
296 | s3c_hsudc_nuke_ep(hsep, -ESHUTDOWN); | 302 | s3c_hsudc_nuke_ep(hsep, -ESHUTDOWN); |
297 | } | 303 | } |
298 | |||
299 | spin_unlock(&hsudc->lock); | ||
300 | driver->disconnect(&hsudc->gadget); | ||
301 | spin_lock(&hsudc->lock); | ||
302 | } | 304 | } |
303 | 305 | ||
304 | /** | 306 | /** |
@@ -1135,17 +1137,15 @@ static irqreturn_t s3c_hsudc_irq(int irq, void *_dev) | |||
1135 | return IRQ_HANDLED; | 1137 | return IRQ_HANDLED; |
1136 | } | 1138 | } |
1137 | 1139 | ||
1138 | static int s3c_hsudc_start(struct usb_gadget_driver *driver, | 1140 | static int s3c_hsudc_start(struct usb_gadget *gadget, |
1139 | int (*bind)(struct usb_gadget *)) | 1141 | struct usb_gadget_driver *driver) |
1140 | { | 1142 | { |
1141 | struct s3c_hsudc *hsudc = the_controller; | 1143 | struct s3c_hsudc *hsudc = to_hsudc(gadget); |
1142 | int ret; | 1144 | int ret; |
1143 | 1145 | ||
1144 | if (!driver | 1146 | if (!driver |
1145 | || (driver->speed != USB_SPEED_FULL && | 1147 | || driver->max_speed < USB_SPEED_FULL |
1146 | driver->speed != USB_SPEED_HIGH) | 1148 | || !driver->setup) |
1147 | || !bind | ||
1148 | || !driver->unbind || !driver->disconnect || !driver->setup) | ||
1149 | return -EINVAL; | 1149 | return -EINVAL; |
1150 | 1150 | ||
1151 | if (!hsudc) | 1151 | if (!hsudc) |
@@ -1156,21 +1156,12 @@ static int s3c_hsudc_start(struct usb_gadget_driver *driver, | |||
1156 | 1156 | ||
1157 | hsudc->driver = driver; | 1157 | hsudc->driver = driver; |
1158 | hsudc->gadget.dev.driver = &driver->driver; | 1158 | hsudc->gadget.dev.driver = &driver->driver; |
1159 | hsudc->gadget.speed = USB_SPEED_UNKNOWN; | ||
1160 | ret = device_add(&hsudc->gadget.dev); | ||
1161 | if (ret) { | ||
1162 | dev_err(hsudc->dev, "failed to probe gadget device"); | ||
1163 | return ret; | ||
1164 | } | ||
1165 | 1159 | ||
1166 | ret = bind(&hsudc->gadget); | 1160 | ret = regulator_bulk_enable(ARRAY_SIZE(hsudc->supplies), |
1167 | if (ret) { | 1161 | hsudc->supplies); |
1168 | dev_err(hsudc->dev, "%s: bind failed\n", hsudc->gadget.name); | 1162 | if (ret != 0) { |
1169 | device_del(&hsudc->gadget.dev); | 1163 | dev_err(hsudc->dev, "failed to enable supplies: %d\n", ret); |
1170 | 1164 | goto err_supplies; | |
1171 | hsudc->driver = NULL; | ||
1172 | hsudc->gadget.dev.driver = NULL; | ||
1173 | return ret; | ||
1174 | } | 1165 | } |
1175 | 1166 | ||
1176 | /* connect to bus through transceiver */ | 1167 | /* connect to bus through transceiver */ |
@@ -1179,13 +1170,7 @@ static int s3c_hsudc_start(struct usb_gadget_driver *driver, | |||
1179 | if (ret) { | 1170 | if (ret) { |
1180 | dev_err(hsudc->dev, "%s: can't bind to transceiver\n", | 1171 | dev_err(hsudc->dev, "%s: can't bind to transceiver\n", |
1181 | hsudc->gadget.name); | 1172 | hsudc->gadget.name); |
1182 | driver->unbind(&hsudc->gadget); | 1173 | goto err_otg; |
1183 | |||
1184 | device_del(&hsudc->gadget.dev); | ||
1185 | |||
1186 | hsudc->driver = NULL; | ||
1187 | hsudc->gadget.dev.driver = NULL; | ||
1188 | return ret; | ||
1189 | } | 1174 | } |
1190 | } | 1175 | } |
1191 | 1176 | ||
@@ -1198,34 +1183,43 @@ static int s3c_hsudc_start(struct usb_gadget_driver *driver, | |||
1198 | hsudc->pd->gpio_init(); | 1183 | hsudc->pd->gpio_init(); |
1199 | 1184 | ||
1200 | return 0; | 1185 | return 0; |
1186 | err_otg: | ||
1187 | regulator_bulk_disable(ARRAY_SIZE(hsudc->supplies), hsudc->supplies); | ||
1188 | err_supplies: | ||
1189 | hsudc->driver = NULL; | ||
1190 | hsudc->gadget.dev.driver = NULL; | ||
1191 | return ret; | ||
1201 | } | 1192 | } |
1202 | 1193 | ||
1203 | static int s3c_hsudc_stop(struct usb_gadget_driver *driver) | 1194 | static int s3c_hsudc_stop(struct usb_gadget *gadget, |
1195 | struct usb_gadget_driver *driver) | ||
1204 | { | 1196 | { |
1205 | struct s3c_hsudc *hsudc = the_controller; | 1197 | struct s3c_hsudc *hsudc = to_hsudc(gadget); |
1206 | unsigned long flags; | 1198 | unsigned long flags; |
1207 | 1199 | ||
1208 | if (!hsudc) | 1200 | if (!hsudc) |
1209 | return -ENODEV; | 1201 | return -ENODEV; |
1210 | 1202 | ||
1211 | if (!driver || driver != hsudc->driver || !driver->unbind) | 1203 | if (!driver || driver != hsudc->driver) |
1212 | return -EINVAL; | 1204 | return -EINVAL; |
1213 | 1205 | ||
1214 | spin_lock_irqsave(&hsudc->lock, flags); | 1206 | spin_lock_irqsave(&hsudc->lock, flags); |
1215 | hsudc->driver = 0; | 1207 | hsudc->driver = NULL; |
1208 | hsudc->gadget.dev.driver = NULL; | ||
1209 | hsudc->gadget.speed = USB_SPEED_UNKNOWN; | ||
1216 | s3c_hsudc_uninit_phy(); | 1210 | s3c_hsudc_uninit_phy(); |
1217 | if (hsudc->pd->gpio_uninit) | 1211 | if (hsudc->pd->gpio_uninit) |
1218 | hsudc->pd->gpio_uninit(); | 1212 | hsudc->pd->gpio_uninit(); |
1219 | s3c_hsudc_stop_activity(hsudc, driver); | 1213 | s3c_hsudc_stop_activity(hsudc); |
1220 | spin_unlock_irqrestore(&hsudc->lock, flags); | 1214 | spin_unlock_irqrestore(&hsudc->lock, flags); |
1221 | 1215 | ||
1222 | if (hsudc->transceiver) | 1216 | if (hsudc->transceiver) |
1223 | (void) otg_set_peripheral(hsudc->transceiver, NULL); | 1217 | (void) otg_set_peripheral(hsudc->transceiver, NULL); |
1224 | 1218 | ||
1225 | driver->unbind(&hsudc->gadget); | ||
1226 | device_del(&hsudc->gadget.dev); | ||
1227 | disable_irq(hsudc->irq); | 1219 | disable_irq(hsudc->irq); |
1228 | 1220 | ||
1221 | regulator_bulk_disable(ARRAY_SIZE(hsudc->supplies), hsudc->supplies); | ||
1222 | |||
1229 | dev_info(hsudc->dev, "unregistered gadget driver '%s'\n", | 1223 | dev_info(hsudc->dev, "unregistered gadget driver '%s'\n", |
1230 | driver->driver.name); | 1224 | driver->driver.name); |
1231 | return 0; | 1225 | return 0; |
@@ -1243,7 +1237,7 @@ static int s3c_hsudc_gadget_getframe(struct usb_gadget *gadget) | |||
1243 | 1237 | ||
1244 | static int s3c_hsudc_vbus_draw(struct usb_gadget *gadget, unsigned mA) | 1238 | static int s3c_hsudc_vbus_draw(struct usb_gadget *gadget, unsigned mA) |
1245 | { | 1239 | { |
1246 | struct s3c_hsudc *hsudc = the_controller; | 1240 | struct s3c_hsudc *hsudc = to_hsudc(gadget); |
1247 | 1241 | ||
1248 | if (!hsudc) | 1242 | if (!hsudc) |
1249 | return -ENODEV; | 1243 | return -ENODEV; |
@@ -1256,18 +1250,18 @@ static int s3c_hsudc_vbus_draw(struct usb_gadget *gadget, unsigned mA) | |||
1256 | 1250 | ||
1257 | static struct usb_gadget_ops s3c_hsudc_gadget_ops = { | 1251 | static struct usb_gadget_ops s3c_hsudc_gadget_ops = { |
1258 | .get_frame = s3c_hsudc_gadget_getframe, | 1252 | .get_frame = s3c_hsudc_gadget_getframe, |
1259 | .start = s3c_hsudc_start, | 1253 | .udc_start = s3c_hsudc_start, |
1260 | .stop = s3c_hsudc_stop, | 1254 | .udc_stop = s3c_hsudc_stop, |
1261 | .vbus_draw = s3c_hsudc_vbus_draw, | 1255 | .vbus_draw = s3c_hsudc_vbus_draw, |
1262 | }; | 1256 | }; |
1263 | 1257 | ||
1264 | static int s3c_hsudc_probe(struct platform_device *pdev) | 1258 | static int __devinit s3c_hsudc_probe(struct platform_device *pdev) |
1265 | { | 1259 | { |
1266 | struct device *dev = &pdev->dev; | 1260 | struct device *dev = &pdev->dev; |
1267 | struct resource *res; | 1261 | struct resource *res; |
1268 | struct s3c_hsudc *hsudc; | 1262 | struct s3c_hsudc *hsudc; |
1269 | struct s3c24xx_hsudc_platdata *pd = pdev->dev.platform_data; | 1263 | struct s3c24xx_hsudc_platdata *pd = pdev->dev.platform_data; |
1270 | int ret; | 1264 | int ret, i; |
1271 | 1265 | ||
1272 | hsudc = kzalloc(sizeof(struct s3c_hsudc) + | 1266 | hsudc = kzalloc(sizeof(struct s3c_hsudc) + |
1273 | sizeof(struct s3c_hsudc_ep) * pd->epnum, | 1267 | sizeof(struct s3c_hsudc_ep) * pd->epnum, |
@@ -1277,13 +1271,22 @@ static int s3c_hsudc_probe(struct platform_device *pdev) | |||
1277 | return -ENOMEM; | 1271 | return -ENOMEM; |
1278 | } | 1272 | } |
1279 | 1273 | ||
1280 | the_controller = hsudc; | ||
1281 | platform_set_drvdata(pdev, dev); | 1274 | platform_set_drvdata(pdev, dev); |
1282 | hsudc->dev = dev; | 1275 | hsudc->dev = dev; |
1283 | hsudc->pd = pdev->dev.platform_data; | 1276 | hsudc->pd = pdev->dev.platform_data; |
1284 | 1277 | ||
1285 | hsudc->transceiver = otg_get_transceiver(); | 1278 | hsudc->transceiver = otg_get_transceiver(); |
1286 | 1279 | ||
1280 | for (i = 0; i < ARRAY_SIZE(hsudc->supplies); i++) | ||
1281 | hsudc->supplies[i].supply = s3c_hsudc_supply_names[i]; | ||
1282 | |||
1283 | ret = regulator_bulk_get(dev, ARRAY_SIZE(hsudc->supplies), | ||
1284 | hsudc->supplies); | ||
1285 | if (ret != 0) { | ||
1286 | dev_err(dev, "failed to request supplies: %d\n", ret); | ||
1287 | goto err_supplies; | ||
1288 | } | ||
1289 | |||
1287 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 1290 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
1288 | if (!res) { | 1291 | if (!res) { |
1289 | dev_err(dev, "unable to obtain driver resource data\n"); | 1292 | dev_err(dev, "unable to obtain driver resource data\n"); |
@@ -1308,10 +1311,9 @@ static int s3c_hsudc_probe(struct platform_device *pdev) | |||
1308 | 1311 | ||
1309 | spin_lock_init(&hsudc->lock); | 1312 | spin_lock_init(&hsudc->lock); |
1310 | 1313 | ||
1311 | device_initialize(&hsudc->gadget.dev); | ||
1312 | dev_set_name(&hsudc->gadget.dev, "gadget"); | 1314 | dev_set_name(&hsudc->gadget.dev, "gadget"); |
1313 | 1315 | ||
1314 | hsudc->gadget.is_dualspeed = 1; | 1316 | hsudc->gadget.max_speed = USB_SPEED_HIGH; |
1315 | hsudc->gadget.ops = &s3c_hsudc_gadget_ops; | 1317 | hsudc->gadget.ops = &s3c_hsudc_gadget_ops; |
1316 | hsudc->gadget.name = dev_name(dev); | 1318 | hsudc->gadget.name = dev_name(dev); |
1317 | hsudc->gadget.dev.parent = dev; | 1319 | hsudc->gadget.dev.parent = dev; |
@@ -1320,6 +1322,7 @@ static int s3c_hsudc_probe(struct platform_device *pdev) | |||
1320 | 1322 | ||
1321 | hsudc->gadget.is_otg = 0; | 1323 | hsudc->gadget.is_otg = 0; |
1322 | hsudc->gadget.is_a_peripheral = 0; | 1324 | hsudc->gadget.is_a_peripheral = 0; |
1325 | hsudc->gadget.speed = USB_SPEED_UNKNOWN; | ||
1323 | 1326 | ||
1324 | s3c_hsudc_setup_ep(hsudc); | 1327 | s3c_hsudc_setup_ep(hsudc); |
1325 | 1328 | ||
@@ -1349,12 +1352,20 @@ static int s3c_hsudc_probe(struct platform_device *pdev) | |||
1349 | disable_irq(hsudc->irq); | 1352 | disable_irq(hsudc->irq); |
1350 | local_irq_enable(); | 1353 | local_irq_enable(); |
1351 | 1354 | ||
1355 | ret = device_register(&hsudc->gadget.dev); | ||
1356 | if (ret) { | ||
1357 | put_device(&hsudc->gadget.dev); | ||
1358 | goto err_add_device; | ||
1359 | } | ||
1360 | |||
1352 | ret = usb_add_gadget_udc(&pdev->dev, &hsudc->gadget); | 1361 | ret = usb_add_gadget_udc(&pdev->dev, &hsudc->gadget); |
1353 | if (ret) | 1362 | if (ret) |
1354 | goto err_add_udc; | 1363 | goto err_add_udc; |
1355 | 1364 | ||
1356 | return 0; | 1365 | return 0; |
1357 | err_add_udc: | 1366 | err_add_udc: |
1367 | device_unregister(&hsudc->gadget.dev); | ||
1368 | err_add_device: | ||
1358 | clk_disable(hsudc->uclk); | 1369 | clk_disable(hsudc->uclk); |
1359 | clk_put(hsudc->uclk); | 1370 | clk_put(hsudc->uclk); |
1360 | err_clk: | 1371 | err_clk: |
@@ -1363,10 +1374,13 @@ err_irq: | |||
1363 | iounmap(hsudc->regs); | 1374 | iounmap(hsudc->regs); |
1364 | 1375 | ||
1365 | err_remap: | 1376 | err_remap: |
1366 | release_resource(hsudc->mem_rsrc); | 1377 | release_mem_region(res->start, resource_size(res)); |
1367 | kfree(hsudc->mem_rsrc); | ||
1368 | |||
1369 | err_res: | 1378 | err_res: |
1379 | if (hsudc->transceiver) | ||
1380 | otg_put_transceiver(hsudc->transceiver); | ||
1381 | |||
1382 | regulator_bulk_free(ARRAY_SIZE(hsudc->supplies), hsudc->supplies); | ||
1383 | err_supplies: | ||
1370 | kfree(hsudc); | 1384 | kfree(hsudc); |
1371 | return ret; | 1385 | return ret; |
1372 | } | 1386 | } |
@@ -1378,21 +1392,10 @@ static struct platform_driver s3c_hsudc_driver = { | |||
1378 | }, | 1392 | }, |
1379 | .probe = s3c_hsudc_probe, | 1393 | .probe = s3c_hsudc_probe, |
1380 | }; | 1394 | }; |
1381 | MODULE_ALIAS("platform:s3c-hsudc"); | ||
1382 | |||
1383 | static int __init s3c_hsudc_modinit(void) | ||
1384 | { | ||
1385 | return platform_driver_register(&s3c_hsudc_driver); | ||
1386 | } | ||
1387 | 1395 | ||
1388 | static void __exit s3c_hsudc_modexit(void) | 1396 | module_platform_driver(s3c_hsudc_driver); |
1389 | { | ||
1390 | platform_driver_unregister(&s3c_hsudc_driver); | ||
1391 | } | ||
1392 | |||
1393 | module_init(s3c_hsudc_modinit); | ||
1394 | module_exit(s3c_hsudc_modexit); | ||
1395 | 1397 | ||
1396 | MODULE_DESCRIPTION("Samsung S3C24XX USB high-speed controller driver"); | 1398 | MODULE_DESCRIPTION("Samsung S3C24XX USB high-speed controller driver"); |
1397 | MODULE_AUTHOR("Thomas Abraham <thomas.ab@samsung.com>"); | 1399 | MODULE_AUTHOR("Thomas Abraham <thomas.ab@samsung.com>"); |
1398 | MODULE_LICENSE("GPL"); | 1400 | MODULE_LICENSE("GPL"); |
1401 | MODULE_ALIAS("platform:s3c-hsudc"); | ||
diff --git a/drivers/usb/gadget/s3c2410_udc.c b/drivers/usb/gadget/s3c2410_udc.c index b8643771fa80..3f87cb9344bb 100644 --- a/drivers/usb/gadget/s3c2410_udc.c +++ b/drivers/usb/gadget/s3c2410_udc.c | |||
@@ -3,7 +3,7 @@ | |||
3 | * | 3 | * |
4 | * Samsung S3C24xx series on-chip full speed USB device controllers | 4 | * Samsung S3C24xx series on-chip full speed USB device controllers |
5 | * | 5 | * |
6 | * Copyright (C) 2004-2007 Herbert Pötzl - Arnaud Patard | 6 | * Copyright (C) 2004-2007 Herbert Pötzl - Arnaud Patard |
7 | * Additional cleanups by Ben Dooks <ben-linux@fluff.org> | 7 | * Additional cleanups by Ben Dooks <ben-linux@fluff.org> |
8 | * | 8 | * |
9 | * This program is free software; you can redistribute it and/or modify | 9 | * This program is free software; you can redistribute it and/or modify |
@@ -51,7 +51,7 @@ | |||
51 | 51 | ||
52 | #define DRIVER_DESC "S3C2410 USB Device Controller Gadget" | 52 | #define DRIVER_DESC "S3C2410 USB Device Controller Gadget" |
53 | #define DRIVER_VERSION "29 Apr 2007" | 53 | #define DRIVER_VERSION "29 Apr 2007" |
54 | #define DRIVER_AUTHOR "Herbert Pötzl <herbert@13thfloor.at>, " \ | 54 | #define DRIVER_AUTHOR "Herbert Pötzl <herbert@13thfloor.at>, " \ |
55 | "Arnaud Patard <arnaud.patard@rtp-net.org>" | 55 | "Arnaud Patard <arnaud.patard@rtp-net.org>" |
56 | 56 | ||
57 | static const char gadget_name[] = "s3c2410_udc"; | 57 | static const char gadget_name[] = "s3c2410_udc"; |
@@ -1683,9 +1683,9 @@ static int s3c2410_udc_start(struct usb_gadget_driver *driver, | |||
1683 | if (udc->driver) | 1683 | if (udc->driver) |
1684 | return -EBUSY; | 1684 | return -EBUSY; |
1685 | 1685 | ||
1686 | if (!bind || !driver->setup || driver->speed < USB_SPEED_FULL) { | 1686 | if (!bind || !driver->setup || driver->max_speed < USB_SPEED_FULL) { |
1687 | printk(KERN_ERR "Invalid driver: bind %p setup %p speed %d\n", | 1687 | printk(KERN_ERR "Invalid driver: bind %p setup %p speed %d\n", |
1688 | bind, driver->setup, driver->speed); | 1688 | bind, driver->setup, driver->max_speed); |
1689 | return -EINVAL; | 1689 | return -EINVAL; |
1690 | } | 1690 | } |
1691 | #if defined(MODULE) | 1691 | #if defined(MODULE) |
diff --git a/drivers/usb/gadget/s3c2410_udc.h b/drivers/usb/gadget/s3c2410_udc.h index a48f619cb1cc..1653bae08b80 100644 --- a/drivers/usb/gadget/s3c2410_udc.h +++ b/drivers/usb/gadget/s3c2410_udc.h | |||
@@ -2,7 +2,7 @@ | |||
2 | * linux/drivers/usb/gadget/s3c2410_udc.h | 2 | * linux/drivers/usb/gadget/s3c2410_udc.h |
3 | * Samsung on-chip full speed USB device controllers | 3 | * Samsung on-chip full speed USB device controllers |
4 | * | 4 | * |
5 | * Copyright (C) 2004-2007 Herbert Pötzl - Arnaud Patard | 5 | * Copyright (C) 2004-2007 Herbert Pötzl - Arnaud Patard |
6 | * Additional cleanups by Ben Dooks <ben-linux@fluff.org> | 6 | * Additional cleanups by Ben Dooks <ben-linux@fluff.org> |
7 | * | 7 | * |
8 | * This program is free software; you can redistribute it and/or modify | 8 | * This program is free software; you can redistribute it and/or modify |
diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c index ed1b816e58d8..ad9e5b2df642 100644 --- a/drivers/usb/gadget/serial.c +++ b/drivers/usb/gadget/serial.c | |||
@@ -123,11 +123,11 @@ MODULE_AUTHOR("Al Borchers"); | |||
123 | MODULE_AUTHOR("David Brownell"); | 123 | MODULE_AUTHOR("David Brownell"); |
124 | MODULE_LICENSE("GPL"); | 124 | MODULE_LICENSE("GPL"); |
125 | 125 | ||
126 | static int use_acm = true; | 126 | static bool use_acm = true; |
127 | module_param(use_acm, bool, 0); | 127 | module_param(use_acm, bool, 0); |
128 | MODULE_PARM_DESC(use_acm, "Use CDC ACM, default=yes"); | 128 | MODULE_PARM_DESC(use_acm, "Use CDC ACM, default=yes"); |
129 | 129 | ||
130 | static int use_obex = false; | 130 | static bool use_obex = false; |
131 | module_param(use_obex, bool, 0); | 131 | module_param(use_obex, bool, 0); |
132 | MODULE_PARM_DESC(use_obex, "Use CDC OBEX, default=no"); | 132 | MODULE_PARM_DESC(use_obex, "Use CDC OBEX, default=no"); |
133 | 133 | ||
diff --git a/drivers/usb/gadget/udc-core.c b/drivers/usb/gadget/udc-core.c index 022baeca7c94..0b0d12ccc487 100644 --- a/drivers/usb/gadget/udc-core.c +++ b/drivers/usb/gadget/udc-core.c | |||
@@ -210,10 +210,10 @@ static void usb_gadget_remove_driver(struct usb_udc *udc) | |||
210 | kobject_uevent(&udc->dev.kobj, KOBJ_CHANGE); | 210 | kobject_uevent(&udc->dev.kobj, KOBJ_CHANGE); |
211 | 211 | ||
212 | if (udc_is_newstyle(udc)) { | 212 | if (udc_is_newstyle(udc)) { |
213 | usb_gadget_disconnect(udc->gadget); | 213 | udc->driver->disconnect(udc->gadget); |
214 | udc->driver->unbind(udc->gadget); | 214 | udc->driver->unbind(udc->gadget); |
215 | usb_gadget_udc_stop(udc->gadget, udc->driver); | 215 | usb_gadget_udc_stop(udc->gadget, udc->driver); |
216 | 216 | usb_gadget_disconnect(udc->gadget); | |
217 | } else { | 217 | } else { |
218 | usb_gadget_stop(udc->gadget, udc->driver); | 218 | usb_gadget_stop(udc->gadget, udc->driver); |
219 | } | 219 | } |
@@ -344,7 +344,7 @@ EXPORT_SYMBOL_GPL(usb_gadget_unregister_driver); | |||
344 | static ssize_t usb_udc_srp_store(struct device *dev, | 344 | static ssize_t usb_udc_srp_store(struct device *dev, |
345 | struct device_attribute *attr, const char *buf, size_t n) | 345 | struct device_attribute *attr, const char *buf, size_t n) |
346 | { | 346 | { |
347 | struct usb_udc *udc = dev_get_drvdata(dev); | 347 | struct usb_udc *udc = container_of(dev, struct usb_udc, dev); |
348 | 348 | ||
349 | if (sysfs_streq(buf, "1")) | 349 | if (sysfs_streq(buf, "1")) |
350 | usb_gadget_wakeup(udc->gadget); | 350 | usb_gadget_wakeup(udc->gadget); |
@@ -371,14 +371,28 @@ static ssize_t usb_udc_softconn_store(struct device *dev, | |||
371 | } | 371 | } |
372 | static DEVICE_ATTR(soft_connect, S_IWUSR, NULL, usb_udc_softconn_store); | 372 | static DEVICE_ATTR(soft_connect, S_IWUSR, NULL, usb_udc_softconn_store); |
373 | 373 | ||
374 | static ssize_t usb_udc_speed_show(struct device *dev, | 374 | #define USB_UDC_SPEED_ATTR(name, param) \ |
375 | ssize_t usb_udc_##param##_show(struct device *dev, \ | ||
376 | struct device_attribute *attr, char *buf) \ | ||
377 | { \ | ||
378 | struct usb_udc *udc = container_of(dev, struct usb_udc, dev); \ | ||
379 | return snprintf(buf, PAGE_SIZE, "%s\n", \ | ||
380 | usb_speed_string(udc->gadget->param)); \ | ||
381 | } \ | ||
382 | static DEVICE_ATTR(name, S_IRUSR, usb_udc_##param##_show, NULL) | ||
383 | |||
384 | static USB_UDC_SPEED_ATTR(current_speed, speed); | ||
385 | static USB_UDC_SPEED_ATTR(maximum_speed, max_speed); | ||
386 | |||
387 | /* TODO: Scheduled for removal in 3.8. */ | ||
388 | static ssize_t usb_udc_is_dualspeed_show(struct device *dev, | ||
375 | struct device_attribute *attr, char *buf) | 389 | struct device_attribute *attr, char *buf) |
376 | { | 390 | { |
377 | struct usb_udc *udc = container_of(dev, struct usb_udc, dev); | 391 | struct usb_udc *udc = container_of(dev, struct usb_udc, dev); |
378 | return snprintf(buf, PAGE_SIZE, "%s\n", | 392 | return snprintf(buf, PAGE_SIZE, "%d\n", |
379 | usb_speed_string(udc->gadget->speed)); | 393 | gadget_is_dualspeed(udc->gadget)); |
380 | } | 394 | } |
381 | static DEVICE_ATTR(speed, S_IRUSR, usb_udc_speed_show, NULL); | 395 | static DEVICE_ATTR(is_dualspeed, S_IRUSR, usb_udc_is_dualspeed_show, NULL); |
382 | 396 | ||
383 | #define USB_UDC_ATTR(name) \ | 397 | #define USB_UDC_ATTR(name) \ |
384 | ssize_t usb_udc_##name##_show(struct device *dev, \ | 398 | ssize_t usb_udc_##name##_show(struct device *dev, \ |
@@ -389,9 +403,8 @@ ssize_t usb_udc_##name##_show(struct device *dev, \ | |||
389 | \ | 403 | \ |
390 | return snprintf(buf, PAGE_SIZE, "%d\n", gadget->name); \ | 404 | return snprintf(buf, PAGE_SIZE, "%d\n", gadget->name); \ |
391 | } \ | 405 | } \ |
392 | static DEVICE_ATTR(name, S_IRUSR, usb_udc_##name##_show, NULL) | 406 | static DEVICE_ATTR(name, S_IRUGO, usb_udc_##name##_show, NULL) |
393 | 407 | ||
394 | static USB_UDC_ATTR(is_dualspeed); | ||
395 | static USB_UDC_ATTR(is_otg); | 408 | static USB_UDC_ATTR(is_otg); |
396 | static USB_UDC_ATTR(is_a_peripheral); | 409 | static USB_UDC_ATTR(is_a_peripheral); |
397 | static USB_UDC_ATTR(b_hnp_enable); | 410 | static USB_UDC_ATTR(b_hnp_enable); |
@@ -401,7 +414,8 @@ static USB_UDC_ATTR(a_alt_hnp_support); | |||
401 | static struct attribute *usb_udc_attrs[] = { | 414 | static struct attribute *usb_udc_attrs[] = { |
402 | &dev_attr_srp.attr, | 415 | &dev_attr_srp.attr, |
403 | &dev_attr_soft_connect.attr, | 416 | &dev_attr_soft_connect.attr, |
404 | &dev_attr_speed.attr, | 417 | &dev_attr_current_speed.attr, |
418 | &dev_attr_maximum_speed.attr, | ||
405 | 419 | ||
406 | &dev_attr_is_dualspeed.attr, | 420 | &dev_attr_is_dualspeed.attr, |
407 | &dev_attr_is_otg.attr, | 421 | &dev_attr_is_otg.attr, |
diff --git a/drivers/usb/gadget/usbstring.c b/drivers/usb/gadget/usbstring.c index 58c4d37d312a..4d25b9009edf 100644 --- a/drivers/usb/gadget/usbstring.c +++ b/drivers/usb/gadget/usbstring.c | |||
@@ -13,82 +13,17 @@ | |||
13 | #include <linux/string.h> | 13 | #include <linux/string.h> |
14 | #include <linux/device.h> | 14 | #include <linux/device.h> |
15 | #include <linux/init.h> | 15 | #include <linux/init.h> |
16 | #include <linux/nls.h> | ||
16 | 17 | ||
17 | #include <linux/usb/ch9.h> | 18 | #include <linux/usb/ch9.h> |
18 | #include <linux/usb/gadget.h> | 19 | #include <linux/usb/gadget.h> |
19 | 20 | ||
20 | #include <asm/unaligned.h> | ||
21 | |||
22 | |||
23 | static int utf8_to_utf16le(const char *s, __le16 *cp, unsigned len) | ||
24 | { | ||
25 | int count = 0; | ||
26 | u8 c; | ||
27 | u16 uchar; | ||
28 | |||
29 | /* this insists on correct encodings, though not minimal ones. | ||
30 | * BUT it currently rejects legit 4-byte UTF-8 code points, | ||
31 | * which need surrogate pairs. (Unicode 3.1 can use them.) | ||
32 | */ | ||
33 | while (len != 0 && (c = (u8) *s++) != 0) { | ||
34 | if (unlikely(c & 0x80)) { | ||
35 | // 2-byte sequence: | ||
36 | // 00000yyyyyxxxxxx = 110yyyyy 10xxxxxx | ||
37 | if ((c & 0xe0) == 0xc0) { | ||
38 | uchar = (c & 0x1f) << 6; | ||
39 | |||
40 | c = (u8) *s++; | ||
41 | if ((c & 0xc0) != 0x80) | ||
42 | goto fail; | ||
43 | c &= 0x3f; | ||
44 | uchar |= c; | ||
45 | |||
46 | // 3-byte sequence (most CJKV characters): | ||
47 | // zzzzyyyyyyxxxxxx = 1110zzzz 10yyyyyy 10xxxxxx | ||
48 | } else if ((c & 0xf0) == 0xe0) { | ||
49 | uchar = (c & 0x0f) << 12; | ||
50 | |||
51 | c = (u8) *s++; | ||
52 | if ((c & 0xc0) != 0x80) | ||
53 | goto fail; | ||
54 | c &= 0x3f; | ||
55 | uchar |= c << 6; | ||
56 | |||
57 | c = (u8) *s++; | ||
58 | if ((c & 0xc0) != 0x80) | ||
59 | goto fail; | ||
60 | c &= 0x3f; | ||
61 | uchar |= c; | ||
62 | |||
63 | /* no bogus surrogates */ | ||
64 | if (0xd800 <= uchar && uchar <= 0xdfff) | ||
65 | goto fail; | ||
66 | |||
67 | // 4-byte sequence (surrogate pairs, currently rare): | ||
68 | // 11101110wwwwzzzzyy + 110111yyyyxxxxxx | ||
69 | // = 11110uuu 10uuzzzz 10yyyyyy 10xxxxxx | ||
70 | // (uuuuu = wwww + 1) | ||
71 | // FIXME accept the surrogate code points (only) | ||
72 | |||
73 | } else | ||
74 | goto fail; | ||
75 | } else | ||
76 | uchar = c; | ||
77 | put_unaligned_le16(uchar, cp++); | ||
78 | count++; | ||
79 | len--; | ||
80 | } | ||
81 | return count; | ||
82 | fail: | ||
83 | return -1; | ||
84 | } | ||
85 | |||
86 | 21 | ||
87 | /** | 22 | /** |
88 | * usb_gadget_get_string - fill out a string descriptor | 23 | * usb_gadget_get_string - fill out a string descriptor |
89 | * @table: of c strings encoded using UTF-8 | 24 | * @table: of c strings encoded using UTF-8 |
90 | * @id: string id, from low byte of wValue in get string descriptor | 25 | * @id: string id, from low byte of wValue in get string descriptor |
91 | * @buf: at least 256 bytes | 26 | * @buf: at least 256 bytes, must be 16-bit aligned |
92 | * | 27 | * |
93 | * Finds the UTF-8 string matching the ID, and converts it into a | 28 | * Finds the UTF-8 string matching the ID, and converts it into a |
94 | * string descriptor in utf16-le. | 29 | * string descriptor in utf16-le. |
@@ -125,8 +60,8 @@ usb_gadget_get_string (struct usb_gadget_strings *table, int id, u8 *buf) | |||
125 | 60 | ||
126 | /* string descriptors have length, tag, then UTF16-LE text */ | 61 | /* string descriptors have length, tag, then UTF16-LE text */ |
127 | len = min ((size_t) 126, strlen (s->s)); | 62 | len = min ((size_t) 126, strlen (s->s)); |
128 | memset (buf + 2, 0, 2 * len); /* zero all the bytes */ | 63 | len = utf8s_to_utf16s(s->s, len, UTF16_LITTLE_ENDIAN, |
129 | len = utf8_to_utf16le(s->s, (__le16 *)&buf[2], len); | 64 | (wchar_t *) &buf[2], 126); |
130 | if (len < 0) | 65 | if (len < 0) |
131 | return -EINVAL; | 66 | return -EINVAL; |
132 | buf [0] = (len + 1) * 2; | 67 | buf [0] = (len + 1) * 2; |
diff --git a/drivers/usb/gadget/zero.c b/drivers/usb/gadget/zero.c index 20697cc132d1..31d34832907e 100644 --- a/drivers/usb/gadget/zero.c +++ b/drivers/usb/gadget/zero.c | |||
@@ -81,7 +81,7 @@ module_param(buflen, uint, 0); | |||
81 | * work better with hosts where config changes are problematic or | 81 | * work better with hosts where config changes are problematic or |
82 | * controllers (like original superh) that only support one config. | 82 | * controllers (like original superh) that only support one config. |
83 | */ | 83 | */ |
84 | static int loopdefault = 0; | 84 | static bool loopdefault = 0; |
85 | module_param(loopdefault, bool, S_IRUGO|S_IWUSR); | 85 | module_param(loopdefault, bool, S_IRUGO|S_IWUSR); |
86 | 86 | ||
87 | /*-------------------------------------------------------------------------*/ | 87 | /*-------------------------------------------------------------------------*/ |
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index 060e0e2b1ae6..91413cac97be 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig | |||
@@ -194,6 +194,15 @@ config USB_EHCI_S5P | |||
194 | help | 194 | help |
195 | Enable support for the S5P SOC's on-chip EHCI controller. | 195 | Enable support for the S5P SOC's on-chip EHCI controller. |
196 | 196 | ||
197 | config USB_EHCI_MV | ||
198 | bool "EHCI support for Marvell on-chip controller" | ||
199 | depends on USB_EHCI_HCD | ||
200 | select USB_EHCI_ROOT_HUB_TT | ||
201 | ---help--- | ||
202 | Enables support for Marvell (including PXA and MMP series) on-chip | ||
203 | USB SPH and OTG controller. SPH is a single port host, and it can | ||
204 | only be EHCI host. OTG is controller that can switch to host mode. | ||
205 | |||
197 | config USB_W90X900_EHCI | 206 | config USB_W90X900_EHCI |
198 | bool "W90X900(W90P910) EHCI support" | 207 | bool "W90X900(W90P910) EHCI support" |
199 | depends on USB_EHCI_HCD && ARCH_W90X900 | 208 | depends on USB_EHCI_HCD && ARCH_W90X900 |
@@ -210,7 +219,7 @@ config USB_CNS3XXX_EHCI | |||
210 | 219 | ||
211 | config USB_EHCI_ATH79 | 220 | config USB_EHCI_ATH79 |
212 | bool "EHCI support for AR7XXX/AR9XXX SoCs" | 221 | bool "EHCI support for AR7XXX/AR9XXX SoCs" |
213 | depends on USB_EHCI_HCD && (SOC_AR71XX || SOC_AR724X || SOC_AR913X) | 222 | depends on USB_EHCI_HCD && (SOC_AR71XX || SOC_AR724X || SOC_AR913X || SOC_AR933X) |
214 | select USB_EHCI_ROOT_HUB_TT | 223 | select USB_EHCI_ROOT_HUB_TT |
215 | default y | 224 | default y |
216 | ---help--- | 225 | ---help--- |
@@ -371,6 +380,12 @@ config USB_OHCI_SH | |||
371 | Enables support for the on-chip OHCI controller on the SuperH. | 380 | Enables support for the on-chip OHCI controller on the SuperH. |
372 | If you use the PCI OHCI controller, this option is not necessary. | 381 | If you use the PCI OHCI controller, this option is not necessary. |
373 | 382 | ||
383 | config USB_OHCI_EXYNOS | ||
384 | boolean "OHCI support for Samsung EXYNOS SoC Series" | ||
385 | depends on USB_OHCI_HCD && ARCH_EXYNOS | ||
386 | help | ||
387 | Enable support for the Samsung Exynos SOC's on-chip OHCI controller. | ||
388 | |||
374 | config USB_CNS3XXX_OHCI | 389 | config USB_CNS3XXX_OHCI |
375 | bool "Cavium CNS3XXX OHCI Module" | 390 | bool "Cavium CNS3XXX OHCI Module" |
376 | depends on USB_OHCI_HCD && ARCH_CNS3XXX | 391 | depends on USB_OHCI_HCD && ARCH_CNS3XXX |
diff --git a/drivers/usb/host/alchemy-common.c b/drivers/usb/host/alchemy-common.c index b4192c964d0d..936af8359fb2 100644 --- a/drivers/usb/host/alchemy-common.c +++ b/drivers/usb/host/alchemy-common.c | |||
@@ -52,9 +52,263 @@ | |||
52 | USBCFG_EBE | USBCFG_EME | USBCFG_OBE | \ | 52 | USBCFG_EBE | USBCFG_EME | USBCFG_OBE | \ |
53 | USBCFG_OME) | 53 | USBCFG_OME) |
54 | 54 | ||
55 | /* Au1300 USB config registers */ | ||
56 | #define USB_DWC_CTRL1 0x00 | ||
57 | #define USB_DWC_CTRL2 0x04 | ||
58 | #define USB_VBUS_TIMER 0x10 | ||
59 | #define USB_SBUS_CTRL 0x14 | ||
60 | #define USB_MSR_ERR 0x18 | ||
61 | #define USB_DWC_CTRL3 0x1C | ||
62 | #define USB_DWC_CTRL4 0x20 | ||
63 | #define USB_OTG_STATUS 0x28 | ||
64 | #define USB_DWC_CTRL5 0x2C | ||
65 | #define USB_DWC_CTRL6 0x30 | ||
66 | #define USB_DWC_CTRL7 0x34 | ||
67 | #define USB_PHY_STATUS 0xC0 | ||
68 | #define USB_INT_STATUS 0xC4 | ||
69 | #define USB_INT_ENABLE 0xC8 | ||
70 | |||
71 | #define USB_DWC_CTRL1_OTGD 0x04 /* set to DISable OTG */ | ||
72 | #define USB_DWC_CTRL1_HSTRS 0x02 /* set to ENable EHCI */ | ||
73 | #define USB_DWC_CTRL1_DCRS 0x01 /* set to ENable UDC */ | ||
74 | |||
75 | #define USB_DWC_CTRL2_PHY1RS 0x04 /* set to enable PHY1 */ | ||
76 | #define USB_DWC_CTRL2_PHY0RS 0x02 /* set to enable PHY0 */ | ||
77 | #define USB_DWC_CTRL2_PHYRS 0x01 /* set to enable PHY */ | ||
78 | |||
79 | #define USB_DWC_CTRL3_OHCI1_CKEN (1 << 19) | ||
80 | #define USB_DWC_CTRL3_OHCI0_CKEN (1 << 18) | ||
81 | #define USB_DWC_CTRL3_EHCI0_CKEN (1 << 17) | ||
82 | #define USB_DWC_CTRL3_OTG0_CKEN (1 << 16) | ||
83 | |||
84 | #define USB_SBUS_CTRL_SBCA 0x04 /* coherent access */ | ||
85 | |||
86 | #define USB_INTEN_FORCE 0x20 | ||
87 | #define USB_INTEN_PHY 0x10 | ||
88 | #define USB_INTEN_UDC 0x08 | ||
89 | #define USB_INTEN_EHCI 0x04 | ||
90 | #define USB_INTEN_OHCI1 0x02 | ||
91 | #define USB_INTEN_OHCI0 0x01 | ||
55 | 92 | ||
56 | static DEFINE_SPINLOCK(alchemy_usb_lock); | 93 | static DEFINE_SPINLOCK(alchemy_usb_lock); |
57 | 94 | ||
95 | static inline void __au1300_usb_phyctl(void __iomem *base, int enable) | ||
96 | { | ||
97 | unsigned long r, s; | ||
98 | |||
99 | r = __raw_readl(base + USB_DWC_CTRL2); | ||
100 | s = __raw_readl(base + USB_DWC_CTRL3); | ||
101 | |||
102 | s &= USB_DWC_CTRL3_OHCI1_CKEN | USB_DWC_CTRL3_OHCI0_CKEN | | ||
103 | USB_DWC_CTRL3_EHCI0_CKEN | USB_DWC_CTRL3_OTG0_CKEN; | ||
104 | |||
105 | if (enable) { | ||
106 | /* simply enable all PHYs */ | ||
107 | r |= USB_DWC_CTRL2_PHY1RS | USB_DWC_CTRL2_PHY0RS | | ||
108 | USB_DWC_CTRL2_PHYRS; | ||
109 | __raw_writel(r, base + USB_DWC_CTRL2); | ||
110 | wmb(); | ||
111 | } else if (!s) { | ||
112 | /* no USB block active, do disable all PHYs */ | ||
113 | r &= ~(USB_DWC_CTRL2_PHY1RS | USB_DWC_CTRL2_PHY0RS | | ||
114 | USB_DWC_CTRL2_PHYRS); | ||
115 | __raw_writel(r, base + USB_DWC_CTRL2); | ||
116 | wmb(); | ||
117 | } | ||
118 | } | ||
119 | |||
120 | static inline void __au1300_ohci_control(void __iomem *base, int enable, int id) | ||
121 | { | ||
122 | unsigned long r; | ||
123 | |||
124 | if (enable) { | ||
125 | __raw_writel(1, base + USB_DWC_CTRL7); /* start OHCI clock */ | ||
126 | wmb(); | ||
127 | |||
128 | r = __raw_readl(base + USB_DWC_CTRL3); /* enable OHCI block */ | ||
129 | r |= (id == 0) ? USB_DWC_CTRL3_OHCI0_CKEN | ||
130 | : USB_DWC_CTRL3_OHCI1_CKEN; | ||
131 | __raw_writel(r, base + USB_DWC_CTRL3); | ||
132 | wmb(); | ||
133 | |||
134 | __au1300_usb_phyctl(base, enable); /* power up the PHYs */ | ||
135 | |||
136 | r = __raw_readl(base + USB_INT_ENABLE); | ||
137 | r |= (id == 0) ? USB_INTEN_OHCI0 : USB_INTEN_OHCI1; | ||
138 | __raw_writel(r, base + USB_INT_ENABLE); | ||
139 | wmb(); | ||
140 | |||
141 | /* reset the OHCI start clock bit */ | ||
142 | __raw_writel(0, base + USB_DWC_CTRL7); | ||
143 | wmb(); | ||
144 | } else { | ||
145 | r = __raw_readl(base + USB_INT_ENABLE); | ||
146 | r &= ~((id == 0) ? USB_INTEN_OHCI0 : USB_INTEN_OHCI1); | ||
147 | __raw_writel(r, base + USB_INT_ENABLE); | ||
148 | wmb(); | ||
149 | |||
150 | r = __raw_readl(base + USB_DWC_CTRL3); | ||
151 | r &= ~((id == 0) ? USB_DWC_CTRL3_OHCI0_CKEN | ||
152 | : USB_DWC_CTRL3_OHCI1_CKEN); | ||
153 | __raw_writel(r, base + USB_DWC_CTRL3); | ||
154 | wmb(); | ||
155 | |||
156 | __au1300_usb_phyctl(base, enable); | ||
157 | } | ||
158 | } | ||
159 | |||
160 | static inline void __au1300_ehci_control(void __iomem *base, int enable) | ||
161 | { | ||
162 | unsigned long r; | ||
163 | |||
164 | if (enable) { | ||
165 | r = __raw_readl(base + USB_DWC_CTRL3); | ||
166 | r |= USB_DWC_CTRL3_EHCI0_CKEN; | ||
167 | __raw_writel(r, base + USB_DWC_CTRL3); | ||
168 | wmb(); | ||
169 | |||
170 | r = __raw_readl(base + USB_DWC_CTRL1); | ||
171 | r |= USB_DWC_CTRL1_HSTRS; | ||
172 | __raw_writel(r, base + USB_DWC_CTRL1); | ||
173 | wmb(); | ||
174 | |||
175 | __au1300_usb_phyctl(base, enable); | ||
176 | |||
177 | r = __raw_readl(base + USB_INT_ENABLE); | ||
178 | r |= USB_INTEN_EHCI; | ||
179 | __raw_writel(r, base + USB_INT_ENABLE); | ||
180 | wmb(); | ||
181 | } else { | ||
182 | r = __raw_readl(base + USB_INT_ENABLE); | ||
183 | r &= ~USB_INTEN_EHCI; | ||
184 | __raw_writel(r, base + USB_INT_ENABLE); | ||
185 | wmb(); | ||
186 | |||
187 | r = __raw_readl(base + USB_DWC_CTRL1); | ||
188 | r &= ~USB_DWC_CTRL1_HSTRS; | ||
189 | __raw_writel(r, base + USB_DWC_CTRL1); | ||
190 | wmb(); | ||
191 | |||
192 | r = __raw_readl(base + USB_DWC_CTRL3); | ||
193 | r &= ~USB_DWC_CTRL3_EHCI0_CKEN; | ||
194 | __raw_writel(r, base + USB_DWC_CTRL3); | ||
195 | wmb(); | ||
196 | |||
197 | __au1300_usb_phyctl(base, enable); | ||
198 | } | ||
199 | } | ||
200 | |||
201 | static inline void __au1300_udc_control(void __iomem *base, int enable) | ||
202 | { | ||
203 | unsigned long r; | ||
204 | |||
205 | if (enable) { | ||
206 | r = __raw_readl(base + USB_DWC_CTRL1); | ||
207 | r |= USB_DWC_CTRL1_DCRS; | ||
208 | __raw_writel(r, base + USB_DWC_CTRL1); | ||
209 | wmb(); | ||
210 | |||
211 | __au1300_usb_phyctl(base, enable); | ||
212 | |||
213 | r = __raw_readl(base + USB_INT_ENABLE); | ||
214 | r |= USB_INTEN_UDC; | ||
215 | __raw_writel(r, base + USB_INT_ENABLE); | ||
216 | wmb(); | ||
217 | } else { | ||
218 | r = __raw_readl(base + USB_INT_ENABLE); | ||
219 | r &= ~USB_INTEN_UDC; | ||
220 | __raw_writel(r, base + USB_INT_ENABLE); | ||
221 | wmb(); | ||
222 | |||
223 | r = __raw_readl(base + USB_DWC_CTRL1); | ||
224 | r &= ~USB_DWC_CTRL1_DCRS; | ||
225 | __raw_writel(r, base + USB_DWC_CTRL1); | ||
226 | wmb(); | ||
227 | |||
228 | __au1300_usb_phyctl(base, enable); | ||
229 | } | ||
230 | } | ||
231 | |||
232 | static inline void __au1300_otg_control(void __iomem *base, int enable) | ||
233 | { | ||
234 | unsigned long r; | ||
235 | if (enable) { | ||
236 | r = __raw_readl(base + USB_DWC_CTRL3); | ||
237 | r |= USB_DWC_CTRL3_OTG0_CKEN; | ||
238 | __raw_writel(r, base + USB_DWC_CTRL3); | ||
239 | wmb(); | ||
240 | |||
241 | r = __raw_readl(base + USB_DWC_CTRL1); | ||
242 | r &= ~USB_DWC_CTRL1_OTGD; | ||
243 | __raw_writel(r, base + USB_DWC_CTRL1); | ||
244 | wmb(); | ||
245 | |||
246 | __au1300_usb_phyctl(base, enable); | ||
247 | } else { | ||
248 | r = __raw_readl(base + USB_DWC_CTRL1); | ||
249 | r |= USB_DWC_CTRL1_OTGD; | ||
250 | __raw_writel(r, base + USB_DWC_CTRL1); | ||
251 | wmb(); | ||
252 | |||
253 | r = __raw_readl(base + USB_DWC_CTRL3); | ||
254 | r &= ~USB_DWC_CTRL3_OTG0_CKEN; | ||
255 | __raw_writel(r, base + USB_DWC_CTRL3); | ||
256 | wmb(); | ||
257 | |||
258 | __au1300_usb_phyctl(base, enable); | ||
259 | } | ||
260 | } | ||
261 | |||
262 | static inline int au1300_usb_control(int block, int enable) | ||
263 | { | ||
264 | void __iomem *base = | ||
265 | (void __iomem *)KSEG1ADDR(AU1300_USB_CTL_PHYS_ADDR); | ||
266 | int ret = 0; | ||
267 | |||
268 | switch (block) { | ||
269 | case ALCHEMY_USB_OHCI0: | ||
270 | __au1300_ohci_control(base, enable, 0); | ||
271 | break; | ||
272 | case ALCHEMY_USB_OHCI1: | ||
273 | __au1300_ohci_control(base, enable, 1); | ||
274 | break; | ||
275 | case ALCHEMY_USB_EHCI0: | ||
276 | __au1300_ehci_control(base, enable); | ||
277 | break; | ||
278 | case ALCHEMY_USB_UDC0: | ||
279 | __au1300_udc_control(base, enable); | ||
280 | break; | ||
281 | case ALCHEMY_USB_OTG0: | ||
282 | __au1300_otg_control(base, enable); | ||
283 | break; | ||
284 | default: | ||
285 | ret = -ENODEV; | ||
286 | } | ||
287 | return ret; | ||
288 | } | ||
289 | |||
290 | static inline void au1300_usb_init(void) | ||
291 | { | ||
292 | void __iomem *base = | ||
293 | (void __iomem *)KSEG1ADDR(AU1300_USB_CTL_PHYS_ADDR); | ||
294 | |||
295 | /* set some sane defaults. Note: we don't fiddle with DWC_CTRL4 | ||
296 | * here at all: Port 2 routing (EHCI or UDC) must be set either | ||
297 | * by boot firmware or platform init code; I can't autodetect | ||
298 | * a sane setting. | ||
299 | */ | ||
300 | __raw_writel(0, base + USB_INT_ENABLE); /* disable all USB irqs */ | ||
301 | wmb(); | ||
302 | __raw_writel(0, base + USB_DWC_CTRL3); /* disable all clocks */ | ||
303 | wmb(); | ||
304 | __raw_writel(~0, base + USB_MSR_ERR); /* clear all errors */ | ||
305 | wmb(); | ||
306 | __raw_writel(~0, base + USB_INT_STATUS); /* clear int status */ | ||
307 | wmb(); | ||
308 | /* set coherent access bit */ | ||
309 | __raw_writel(USB_SBUS_CTRL_SBCA, base + USB_SBUS_CTRL); | ||
310 | wmb(); | ||
311 | } | ||
58 | 312 | ||
59 | static inline void __au1200_ohci_control(void __iomem *base, int enable) | 313 | static inline void __au1200_ohci_control(void __iomem *base, int enable) |
60 | { | 314 | { |
@@ -233,6 +487,9 @@ int alchemy_usb_control(int block, int enable) | |||
233 | case ALCHEMY_CPU_AU1200: | 487 | case ALCHEMY_CPU_AU1200: |
234 | ret = au1200_usb_control(block, enable); | 488 | ret = au1200_usb_control(block, enable); |
235 | break; | 489 | break; |
490 | case ALCHEMY_CPU_AU1300: | ||
491 | ret = au1300_usb_control(block, enable); | ||
492 | break; | ||
236 | default: | 493 | default: |
237 | ret = -ENODEV; | 494 | ret = -ENODEV; |
238 | } | 495 | } |
@@ -281,6 +538,20 @@ static void au1200_usb_pm(int susp) | |||
281 | } | 538 | } |
282 | } | 539 | } |
283 | 540 | ||
541 | static void au1300_usb_pm(int susp) | ||
542 | { | ||
543 | void __iomem *base = | ||
544 | (void __iomem *)KSEG1ADDR(AU1300_USB_CTL_PHYS_ADDR); | ||
545 | /* remember Port2 routing */ | ||
546 | if (susp) { | ||
547 | alchemy_usb_pmdata[0] = __raw_readl(base + USB_DWC_CTRL4); | ||
548 | } else { | ||
549 | au1300_usb_init(); | ||
550 | __raw_writel(alchemy_usb_pmdata[0], base + USB_DWC_CTRL4); | ||
551 | wmb(); | ||
552 | } | ||
553 | } | ||
554 | |||
284 | static void alchemy_usb_pm(int susp) | 555 | static void alchemy_usb_pm(int susp) |
285 | { | 556 | { |
286 | switch (alchemy_get_cputype()) { | 557 | switch (alchemy_get_cputype()) { |
@@ -295,6 +566,9 @@ static void alchemy_usb_pm(int susp) | |||
295 | case ALCHEMY_CPU_AU1200: | 566 | case ALCHEMY_CPU_AU1200: |
296 | au1200_usb_pm(susp); | 567 | au1200_usb_pm(susp); |
297 | break; | 568 | break; |
569 | case ALCHEMY_CPU_AU1300: | ||
570 | au1300_usb_pm(susp); | ||
571 | break; | ||
298 | } | 572 | } |
299 | } | 573 | } |
300 | 574 | ||
@@ -328,6 +602,9 @@ static int __init alchemy_usb_init(void) | |||
328 | case ALCHEMY_CPU_AU1200: | 602 | case ALCHEMY_CPU_AU1200: |
329 | au1200_usb_init(); | 603 | au1200_usb_init(); |
330 | break; | 604 | break; |
605 | case ALCHEMY_CPU_AU1300: | ||
606 | au1300_usb_init(); | ||
607 | break; | ||
331 | } | 608 | } |
332 | 609 | ||
333 | register_syscore_ops(&alchemy_usb_pm_ops); | 610 | register_syscore_ops(&alchemy_usb_pm_ops); |
diff --git a/drivers/usb/host/ehci-ath79.c b/drivers/usb/host/ehci-ath79.c index afb6743cf094..f1424f9bc363 100644 --- a/drivers/usb/host/ehci-ath79.c +++ b/drivers/usb/host/ehci-ath79.c | |||
@@ -33,6 +33,10 @@ static const struct platform_device_id ehci_ath79_id_table[] = { | |||
33 | .driver_data = EHCI_ATH79_IP_V2, | 33 | .driver_data = EHCI_ATH79_IP_V2, |
34 | }, | 34 | }, |
35 | { | 35 | { |
36 | .name = "ar933x-ehci", | ||
37 | .driver_data = EHCI_ATH79_IP_V2, | ||
38 | }, | ||
39 | { | ||
36 | /* terminating entry */ | 40 | /* terminating entry */ |
37 | }, | 41 | }, |
38 | }; | 42 | }; |
diff --git a/drivers/usb/host/ehci-au1xxx.c b/drivers/usb/host/ehci-au1xxx.c index 18bafa99fe57..bf7441afed16 100644 --- a/drivers/usb/host/ehci-au1xxx.c +++ b/drivers/usb/host/ehci-au1xxx.c | |||
@@ -23,6 +23,7 @@ static int au1xxx_ehci_setup(struct usb_hcd *hcd) | |||
23 | int ret = ehci_init(hcd); | 23 | int ret = ehci_init(hcd); |
24 | 24 | ||
25 | ehci->need_io_watchdog = 0; | 25 | ehci->need_io_watchdog = 0; |
26 | ehci_reset(ehci); | ||
26 | return ret; | 27 | return ret; |
27 | } | 28 | } |
28 | 29 | ||
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index 3ff9f82f7263..a007a9fe0f87 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c | |||
@@ -48,6 +48,10 @@ | |||
48 | #include <asm/system.h> | 48 | #include <asm/system.h> |
49 | #include <asm/unaligned.h> | 49 | #include <asm/unaligned.h> |
50 | 50 | ||
51 | #if defined(CONFIG_PPC_PS3) | ||
52 | #include <asm/firmware.h> | ||
53 | #endif | ||
54 | |||
51 | /*-------------------------------------------------------------------------*/ | 55 | /*-------------------------------------------------------------------------*/ |
52 | 56 | ||
53 | /* | 57 | /* |
@@ -108,7 +112,7 @@ module_param (park, uint, S_IRUGO); | |||
108 | MODULE_PARM_DESC (park, "park setting; 1-3 back-to-back async packets"); | 112 | MODULE_PARM_DESC (park, "park setting; 1-3 back-to-back async packets"); |
109 | 113 | ||
110 | /* for flakey hardware, ignore overcurrent indicators */ | 114 | /* for flakey hardware, ignore overcurrent indicators */ |
111 | static int ignore_oc = 0; | 115 | static bool ignore_oc = 0; |
112 | module_param (ignore_oc, bool, S_IRUGO); | 116 | module_param (ignore_oc, bool, S_IRUGO); |
113 | MODULE_PARM_DESC (ignore_oc, "ignore bogus hardware overcurrent indications"); | 117 | MODULE_PARM_DESC (ignore_oc, "ignore bogus hardware overcurrent indications"); |
114 | 118 | ||
@@ -230,12 +234,58 @@ static int ehci_halt (struct ehci_hcd *ehci) | |||
230 | STS_HALT, STS_HALT, 16 * 125); | 234 | STS_HALT, STS_HALT, 16 * 125); |
231 | } | 235 | } |
232 | 236 | ||
237 | #if defined(CONFIG_USB_SUSPEND) && defined(CONFIG_PPC_PS3) | ||
238 | |||
239 | /* | ||
240 | * The EHCI controller of the Cell Super Companion Chip used in the | ||
241 | * PS3 will stop the root hub after all root hub ports are suspended. | ||
242 | * When in this condition handshake will return -ETIMEDOUT. The | ||
243 | * STS_HLT bit will not be set, so inspection of the frame index is | ||
244 | * used here to test for the condition. If the condition is found | ||
245 | * return success to allow the USB suspend to complete. | ||
246 | */ | ||
247 | |||
248 | static int handshake_for_broken_root_hub(struct ehci_hcd *ehci, | ||
249 | void __iomem *ptr, u32 mask, u32 done, | ||
250 | int usec) | ||
251 | { | ||
252 | unsigned int old_index; | ||
253 | int error; | ||
254 | |||
255 | if (!firmware_has_feature(FW_FEATURE_PS3_LV1)) | ||
256 | return -ETIMEDOUT; | ||
257 | |||
258 | old_index = ehci_read_frame_index(ehci); | ||
259 | |||
260 | error = handshake(ehci, ptr, mask, done, usec); | ||
261 | |||
262 | if (error == -ETIMEDOUT && ehci_read_frame_index(ehci) == old_index) | ||
263 | return 0; | ||
264 | |||
265 | return error; | ||
266 | } | ||
267 | |||
268 | #else | ||
269 | |||
270 | static int handshake_for_broken_root_hub(struct ehci_hcd *ehci, | ||
271 | void __iomem *ptr, u32 mask, u32 done, | ||
272 | int usec) | ||
273 | { | ||
274 | return -ETIMEDOUT; | ||
275 | } | ||
276 | |||
277 | #endif | ||
278 | |||
233 | static int handshake_on_error_set_halt(struct ehci_hcd *ehci, void __iomem *ptr, | 279 | static int handshake_on_error_set_halt(struct ehci_hcd *ehci, void __iomem *ptr, |
234 | u32 mask, u32 done, int usec) | 280 | u32 mask, u32 done, int usec) |
235 | { | 281 | { |
236 | int error; | 282 | int error; |
237 | 283 | ||
238 | error = handshake(ehci, ptr, mask, done, usec); | 284 | error = handshake(ehci, ptr, mask, done, usec); |
285 | if (error == -ETIMEDOUT) | ||
286 | error = handshake_for_broken_root_hub(ehci, ptr, mask, done, | ||
287 | usec); | ||
288 | |||
239 | if (error) { | 289 | if (error) { |
240 | ehci_halt(ehci); | 290 | ehci_halt(ehci); |
241 | ehci->rh_state = EHCI_RH_HALTED; | 291 | ehci->rh_state = EHCI_RH_HALTED; |
@@ -620,6 +670,7 @@ static int ehci_init(struct usb_hcd *hcd) | |||
620 | hw = ehci->async->hw; | 670 | hw = ehci->async->hw; |
621 | hw->hw_next = QH_NEXT(ehci, ehci->async->qh_dma); | 671 | hw->hw_next = QH_NEXT(ehci, ehci->async->qh_dma); |
622 | hw->hw_info1 = cpu_to_hc32(ehci, QH_HEAD); | 672 | hw->hw_info1 = cpu_to_hc32(ehci, QH_HEAD); |
673 | hw->hw_info1 |= cpu_to_hc32(ehci, (1 << 7)); /* I = 1 */ | ||
623 | hw->hw_token = cpu_to_hc32(ehci, QTD_STS_HALT); | 674 | hw->hw_token = cpu_to_hc32(ehci, QTD_STS_HALT); |
624 | hw->hw_qtd_next = EHCI_LIST_END(ehci); | 675 | hw->hw_qtd_next = EHCI_LIST_END(ehci); |
625 | ehci->async->qh_state = QH_STATE_LINKED; | 676 | ehci->async->qh_state = QH_STATE_LINKED; |
@@ -677,22 +728,13 @@ static int ehci_init(struct usb_hcd *hcd) | |||
677 | static int ehci_run (struct usb_hcd *hcd) | 728 | static int ehci_run (struct usb_hcd *hcd) |
678 | { | 729 | { |
679 | struct ehci_hcd *ehci = hcd_to_ehci (hcd); | 730 | struct ehci_hcd *ehci = hcd_to_ehci (hcd); |
680 | int retval; | ||
681 | u32 temp; | 731 | u32 temp; |
682 | u32 hcc_params; | 732 | u32 hcc_params; |
683 | 733 | ||
684 | hcd->uses_new_polling = 1; | 734 | hcd->uses_new_polling = 1; |
685 | 735 | ||
686 | /* EHCI spec section 4.1 */ | 736 | /* EHCI spec section 4.1 */ |
687 | /* | 737 | |
688 | * TDI driver does the ehci_reset in their reset callback. | ||
689 | * Don't reset here, because configuration settings will | ||
690 | * vanish. | ||
691 | */ | ||
692 | if (!ehci_is_TDI(ehci) && (retval = ehci_reset(ehci)) != 0) { | ||
693 | ehci_mem_cleanup(ehci); | ||
694 | return retval; | ||
695 | } | ||
696 | ehci_writel(ehci, ehci->periodic_dma, &ehci->regs->frame_list); | 738 | ehci_writel(ehci, ehci->periodic_dma, &ehci->regs->frame_list); |
697 | ehci_writel(ehci, (u32)ehci->async->qh_dma, &ehci->regs->async_next); | 739 | ehci_writel(ehci, (u32)ehci->async->qh_dma, &ehci->regs->async_next); |
698 | 740 | ||
@@ -1324,11 +1366,16 @@ MODULE_LICENSE ("GPL"); | |||
1324 | #define PLATFORM_DRIVER ehci_pxa168_driver | 1366 | #define PLATFORM_DRIVER ehci_pxa168_driver |
1325 | #endif | 1367 | #endif |
1326 | 1368 | ||
1327 | #ifdef CONFIG_NLM_XLR | 1369 | #ifdef CONFIG_CPU_XLR |
1328 | #include "ehci-xls.c" | 1370 | #include "ehci-xls.c" |
1329 | #define PLATFORM_DRIVER ehci_xls_driver | 1371 | #define PLATFORM_DRIVER ehci_xls_driver |
1330 | #endif | 1372 | #endif |
1331 | 1373 | ||
1374 | #ifdef CONFIG_USB_EHCI_MV | ||
1375 | #include "ehci-mv.c" | ||
1376 | #define PLATFORM_DRIVER ehci_mv_driver | ||
1377 | #endif | ||
1378 | |||
1332 | #if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) && \ | 1379 | #if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) && \ |
1333 | !defined(PS3_SYSTEM_BUS_DRIVER) && !defined(OF_PLATFORM_DRIVER) && \ | 1380 | !defined(PS3_SYSTEM_BUS_DRIVER) && !defined(OF_PLATFORM_DRIVER) && \ |
1334 | !defined(XILINX_OF_PLATFORM_DRIVER) | 1381 | !defined(XILINX_OF_PLATFORM_DRIVER) |
diff --git a/drivers/usb/host/ehci-mv.c b/drivers/usb/host/ehci-mv.c new file mode 100644 index 000000000000..52a604fb9321 --- /dev/null +++ b/drivers/usb/host/ehci-mv.c | |||
@@ -0,0 +1,391 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2011 Marvell International Ltd. All rights reserved. | ||
3 | * Author: Chao Xie <chao.xie@marvell.com> | ||
4 | * Neil Zhang <zhangwm@marvell.com> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify it | ||
7 | * under the terms of the GNU General Public License as published by the | ||
8 | * Free Software Foundation; either version 2 of the License, or (at your | ||
9 | * option) any later version. | ||
10 | */ | ||
11 | |||
12 | #include <linux/kernel.h> | ||
13 | #include <linux/module.h> | ||
14 | #include <linux/platform_device.h> | ||
15 | #include <linux/clk.h> | ||
16 | #include <linux/usb/otg.h> | ||
17 | #include <linux/platform_data/mv_usb.h> | ||
18 | |||
19 | #define CAPLENGTH_MASK (0xff) | ||
20 | |||
21 | struct ehci_hcd_mv { | ||
22 | struct usb_hcd *hcd; | ||
23 | |||
24 | /* Which mode does this ehci running OTG/Host ? */ | ||
25 | int mode; | ||
26 | |||
27 | void __iomem *phy_regs; | ||
28 | void __iomem *cap_regs; | ||
29 | void __iomem *op_regs; | ||
30 | |||
31 | struct otg_transceiver *otg; | ||
32 | |||
33 | struct mv_usb_platform_data *pdata; | ||
34 | |||
35 | /* clock source and total clock number */ | ||
36 | unsigned int clknum; | ||
37 | struct clk *clk[0]; | ||
38 | }; | ||
39 | |||
40 | static void ehci_clock_enable(struct ehci_hcd_mv *ehci_mv) | ||
41 | { | ||
42 | unsigned int i; | ||
43 | |||
44 | for (i = 0; i < ehci_mv->clknum; i++) | ||
45 | clk_enable(ehci_mv->clk[i]); | ||
46 | } | ||
47 | |||
48 | static void ehci_clock_disable(struct ehci_hcd_mv *ehci_mv) | ||
49 | { | ||
50 | unsigned int i; | ||
51 | |||
52 | for (i = 0; i < ehci_mv->clknum; i++) | ||
53 | clk_disable(ehci_mv->clk[i]); | ||
54 | } | ||
55 | |||
56 | static int mv_ehci_enable(struct ehci_hcd_mv *ehci_mv) | ||
57 | { | ||
58 | int retval; | ||
59 | |||
60 | ehci_clock_enable(ehci_mv); | ||
61 | if (ehci_mv->pdata->phy_init) { | ||
62 | retval = ehci_mv->pdata->phy_init(ehci_mv->phy_regs); | ||
63 | if (retval) | ||
64 | return retval; | ||
65 | } | ||
66 | |||
67 | return 0; | ||
68 | } | ||
69 | |||
70 | static void mv_ehci_disable(struct ehci_hcd_mv *ehci_mv) | ||
71 | { | ||
72 | if (ehci_mv->pdata->phy_deinit) | ||
73 | ehci_mv->pdata->phy_deinit(ehci_mv->phy_regs); | ||
74 | ehci_clock_disable(ehci_mv); | ||
75 | } | ||
76 | |||
77 | static int mv_ehci_reset(struct usb_hcd *hcd) | ||
78 | { | ||
79 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | ||
80 | struct device *dev = hcd->self.controller; | ||
81 | struct ehci_hcd_mv *ehci_mv = dev_get_drvdata(dev); | ||
82 | int retval; | ||
83 | |||
84 | if (ehci_mv == NULL) { | ||
85 | dev_err(dev, "Can not find private ehci data\n"); | ||
86 | return -ENODEV; | ||
87 | } | ||
88 | |||
89 | /* | ||
90 | * data structure init | ||
91 | */ | ||
92 | retval = ehci_init(hcd); | ||
93 | if (retval) { | ||
94 | dev_err(dev, "ehci_init failed %d\n", retval); | ||
95 | return retval; | ||
96 | } | ||
97 | |||
98 | hcd->has_tt = 1; | ||
99 | ehci->sbrn = 0x20; | ||
100 | |||
101 | retval = ehci_reset(ehci); | ||
102 | if (retval) { | ||
103 | dev_err(dev, "ehci_reset failed %d\n", retval); | ||
104 | return retval; | ||
105 | } | ||
106 | |||
107 | return 0; | ||
108 | } | ||
109 | |||
110 | static const struct hc_driver mv_ehci_hc_driver = { | ||
111 | .description = hcd_name, | ||
112 | .product_desc = "Marvell EHCI", | ||
113 | .hcd_priv_size = sizeof(struct ehci_hcd), | ||
114 | |||
115 | /* | ||
116 | * generic hardware linkage | ||
117 | */ | ||
118 | .irq = ehci_irq, | ||
119 | .flags = HCD_MEMORY | HCD_USB2, | ||
120 | |||
121 | /* | ||
122 | * basic lifecycle operations | ||
123 | */ | ||
124 | .reset = mv_ehci_reset, | ||
125 | .start = ehci_run, | ||
126 | .stop = ehci_stop, | ||
127 | .shutdown = ehci_shutdown, | ||
128 | |||
129 | /* | ||
130 | * managing i/o requests and associated device resources | ||
131 | */ | ||
132 | .urb_enqueue = ehci_urb_enqueue, | ||
133 | .urb_dequeue = ehci_urb_dequeue, | ||
134 | .endpoint_disable = ehci_endpoint_disable, | ||
135 | .endpoint_reset = ehci_endpoint_reset, | ||
136 | .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, | ||
137 | |||
138 | /* | ||
139 | * scheduling support | ||
140 | */ | ||
141 | .get_frame_number = ehci_get_frame, | ||
142 | |||
143 | /* | ||
144 | * root hub support | ||
145 | */ | ||
146 | .hub_status_data = ehci_hub_status_data, | ||
147 | .hub_control = ehci_hub_control, | ||
148 | .bus_suspend = ehci_bus_suspend, | ||
149 | .bus_resume = ehci_bus_resume, | ||
150 | }; | ||
151 | |||
152 | static int mv_ehci_probe(struct platform_device *pdev) | ||
153 | { | ||
154 | struct mv_usb_platform_data *pdata = pdev->dev.platform_data; | ||
155 | struct usb_hcd *hcd; | ||
156 | struct ehci_hcd *ehci; | ||
157 | struct ehci_hcd_mv *ehci_mv; | ||
158 | struct resource *r; | ||
159 | int clk_i, retval = -ENODEV; | ||
160 | u32 offset; | ||
161 | size_t size; | ||
162 | |||
163 | if (!pdata) { | ||
164 | dev_err(&pdev->dev, "missing platform_data\n"); | ||
165 | return -ENODEV; | ||
166 | } | ||
167 | |||
168 | if (usb_disabled()) | ||
169 | return -ENODEV; | ||
170 | |||
171 | hcd = usb_create_hcd(&mv_ehci_hc_driver, &pdev->dev, "mv ehci"); | ||
172 | if (!hcd) | ||
173 | return -ENOMEM; | ||
174 | |||
175 | size = sizeof(*ehci_mv) + sizeof(struct clk *) * pdata->clknum; | ||
176 | ehci_mv = kzalloc(size, GFP_KERNEL); | ||
177 | if (ehci_mv == NULL) { | ||
178 | dev_err(&pdev->dev, "cannot allocate ehci_hcd_mv\n"); | ||
179 | retval = -ENOMEM; | ||
180 | goto err_put_hcd; | ||
181 | } | ||
182 | |||
183 | platform_set_drvdata(pdev, ehci_mv); | ||
184 | ehci_mv->pdata = pdata; | ||
185 | ehci_mv->hcd = hcd; | ||
186 | |||
187 | ehci_mv->clknum = pdata->clknum; | ||
188 | for (clk_i = 0; clk_i < ehci_mv->clknum; clk_i++) { | ||
189 | ehci_mv->clk[clk_i] = | ||
190 | clk_get(&pdev->dev, pdata->clkname[clk_i]); | ||
191 | if (IS_ERR(ehci_mv->clk[clk_i])) { | ||
192 | dev_err(&pdev->dev, "error get clck \"%s\"\n", | ||
193 | pdata->clkname[clk_i]); | ||
194 | retval = PTR_ERR(ehci_mv->clk[clk_i]); | ||
195 | goto err_put_clk; | ||
196 | } | ||
197 | } | ||
198 | |||
199 | r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "phyregs"); | ||
200 | if (r == NULL) { | ||
201 | dev_err(&pdev->dev, "no phy I/O memory resource defined\n"); | ||
202 | retval = -ENODEV; | ||
203 | goto err_put_clk; | ||
204 | } | ||
205 | |||
206 | ehci_mv->phy_regs = ioremap(r->start, resource_size(r)); | ||
207 | if (ehci_mv->phy_regs == 0) { | ||
208 | dev_err(&pdev->dev, "failed to map phy I/O memory\n"); | ||
209 | retval = -EFAULT; | ||
210 | goto err_put_clk; | ||
211 | } | ||
212 | |||
213 | r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "capregs"); | ||
214 | if (!r) { | ||
215 | dev_err(&pdev->dev, "no I/O memory resource defined\n"); | ||
216 | retval = -ENODEV; | ||
217 | goto err_iounmap_phyreg; | ||
218 | } | ||
219 | |||
220 | ehci_mv->cap_regs = ioremap(r->start, resource_size(r)); | ||
221 | if (ehci_mv->cap_regs == NULL) { | ||
222 | dev_err(&pdev->dev, "failed to map I/O memory\n"); | ||
223 | retval = -EFAULT; | ||
224 | goto err_iounmap_phyreg; | ||
225 | } | ||
226 | |||
227 | retval = mv_ehci_enable(ehci_mv); | ||
228 | if (retval) { | ||
229 | dev_err(&pdev->dev, "init phy error %d\n", retval); | ||
230 | goto err_iounmap_capreg; | ||
231 | } | ||
232 | |||
233 | offset = readl(ehci_mv->cap_regs) & CAPLENGTH_MASK; | ||
234 | ehci_mv->op_regs = | ||
235 | (void __iomem *) ((unsigned long) ehci_mv->cap_regs + offset); | ||
236 | |||
237 | hcd->rsrc_start = r->start; | ||
238 | hcd->rsrc_len = r->end - r->start + 1; | ||
239 | hcd->regs = ehci_mv->op_regs; | ||
240 | |||
241 | hcd->irq = platform_get_irq(pdev, 0); | ||
242 | if (!hcd->irq) { | ||
243 | dev_err(&pdev->dev, "Cannot get irq."); | ||
244 | retval = -ENODEV; | ||
245 | goto err_disable_clk; | ||
246 | } | ||
247 | |||
248 | ehci = hcd_to_ehci(hcd); | ||
249 | ehci->caps = (struct ehci_caps *) ehci_mv->cap_regs; | ||
250 | ehci->regs = (struct ehci_regs *) ehci_mv->op_regs; | ||
251 | ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params); | ||
252 | |||
253 | ehci_mv->mode = pdata->mode; | ||
254 | if (ehci_mv->mode == MV_USB_MODE_OTG) { | ||
255 | #ifdef CONFIG_USB_OTG_UTILS | ||
256 | ehci_mv->otg = otg_get_transceiver(); | ||
257 | if (!ehci_mv->otg) { | ||
258 | dev_err(&pdev->dev, | ||
259 | "unable to find transceiver\n"); | ||
260 | retval = -ENODEV; | ||
261 | goto err_disable_clk; | ||
262 | } | ||
263 | |||
264 | retval = otg_set_host(ehci_mv->otg, &hcd->self); | ||
265 | if (retval < 0) { | ||
266 | dev_err(&pdev->dev, | ||
267 | "unable to register with transceiver\n"); | ||
268 | retval = -ENODEV; | ||
269 | goto err_put_transceiver; | ||
270 | } | ||
271 | /* otg will enable clock before use as host */ | ||
272 | mv_ehci_disable(ehci_mv); | ||
273 | #else | ||
274 | dev_info(&pdev->dev, "MV_USB_MODE_OTG " | ||
275 | "must have CONFIG_USB_OTG_UTILS enabled\n"); | ||
276 | goto err_disable_clk; | ||
277 | #endif | ||
278 | } else { | ||
279 | if (pdata->set_vbus) | ||
280 | pdata->set_vbus(1); | ||
281 | |||
282 | retval = usb_add_hcd(hcd, hcd->irq, IRQF_SHARED); | ||
283 | if (retval) { | ||
284 | dev_err(&pdev->dev, | ||
285 | "failed to add hcd with err %d\n", retval); | ||
286 | goto err_set_vbus; | ||
287 | } | ||
288 | } | ||
289 | |||
290 | if (pdata->private_init) | ||
291 | pdata->private_init(ehci_mv->op_regs, ehci_mv->phy_regs); | ||
292 | |||
293 | dev_info(&pdev->dev, | ||
294 | "successful find EHCI device with regs 0x%p irq %d" | ||
295 | " working in %s mode\n", hcd->regs, hcd->irq, | ||
296 | ehci_mv->mode == MV_USB_MODE_OTG ? "OTG" : "Host"); | ||
297 | |||
298 | return 0; | ||
299 | |||
300 | err_set_vbus: | ||
301 | if (pdata->set_vbus) | ||
302 | pdata->set_vbus(0); | ||
303 | #ifdef CONFIG_USB_OTG_UTILS | ||
304 | err_put_transceiver: | ||
305 | if (ehci_mv->otg) | ||
306 | otg_put_transceiver(ehci_mv->otg); | ||
307 | #endif | ||
308 | err_disable_clk: | ||
309 | mv_ehci_disable(ehci_mv); | ||
310 | err_iounmap_capreg: | ||
311 | iounmap(ehci_mv->cap_regs); | ||
312 | err_iounmap_phyreg: | ||
313 | iounmap(ehci_mv->phy_regs); | ||
314 | err_put_clk: | ||
315 | for (clk_i--; clk_i >= 0; clk_i--) | ||
316 | clk_put(ehci_mv->clk[clk_i]); | ||
317 | platform_set_drvdata(pdev, NULL); | ||
318 | kfree(ehci_mv); | ||
319 | err_put_hcd: | ||
320 | usb_put_hcd(hcd); | ||
321 | |||
322 | return retval; | ||
323 | } | ||
324 | |||
325 | static int mv_ehci_remove(struct platform_device *pdev) | ||
326 | { | ||
327 | struct ehci_hcd_mv *ehci_mv = platform_get_drvdata(pdev); | ||
328 | struct usb_hcd *hcd = ehci_mv->hcd; | ||
329 | int clk_i; | ||
330 | |||
331 | if (hcd->rh_registered) | ||
332 | usb_remove_hcd(hcd); | ||
333 | |||
334 | if (ehci_mv->otg) { | ||
335 | otg_set_host(ehci_mv->otg, NULL); | ||
336 | otg_put_transceiver(ehci_mv->otg); | ||
337 | } | ||
338 | |||
339 | if (ehci_mv->mode == MV_USB_MODE_HOST) { | ||
340 | if (ehci_mv->pdata->set_vbus) | ||
341 | ehci_mv->pdata->set_vbus(0); | ||
342 | |||
343 | mv_ehci_disable(ehci_mv); | ||
344 | } | ||
345 | |||
346 | iounmap(ehci_mv->cap_regs); | ||
347 | iounmap(ehci_mv->phy_regs); | ||
348 | |||
349 | for (clk_i = 0; clk_i < ehci_mv->clknum; clk_i++) | ||
350 | clk_put(ehci_mv->clk[clk_i]); | ||
351 | |||
352 | platform_set_drvdata(pdev, NULL); | ||
353 | |||
354 | kfree(ehci_mv); | ||
355 | usb_put_hcd(hcd); | ||
356 | |||
357 | return 0; | ||
358 | } | ||
359 | |||
360 | MODULE_ALIAS("mv-ehci"); | ||
361 | |||
362 | static const struct platform_device_id ehci_id_table[] = { | ||
363 | {"pxa-u2oehci", PXA_U2OEHCI}, | ||
364 | {"pxa-sph", PXA_SPH}, | ||
365 | {"mmp3-hsic", MMP3_HSIC}, | ||
366 | {"mmp3-fsic", MMP3_FSIC}, | ||
367 | {}, | ||
368 | }; | ||
369 | |||
370 | static void mv_ehci_shutdown(struct platform_device *pdev) | ||
371 | { | ||
372 | struct ehci_hcd_mv *ehci_mv = platform_get_drvdata(pdev); | ||
373 | struct usb_hcd *hcd = ehci_mv->hcd; | ||
374 | |||
375 | if (!hcd->rh_registered) | ||
376 | return; | ||
377 | |||
378 | if (hcd->driver->shutdown) | ||
379 | hcd->driver->shutdown(hcd); | ||
380 | } | ||
381 | |||
382 | static struct platform_driver ehci_mv_driver = { | ||
383 | .probe = mv_ehci_probe, | ||
384 | .remove = mv_ehci_remove, | ||
385 | .shutdown = mv_ehci_shutdown, | ||
386 | .driver = { | ||
387 | .name = "mv-ehci", | ||
388 | .bus = &platform_bus_type, | ||
389 | }, | ||
390 | .id_table = ehci_id_table, | ||
391 | }; | ||
diff --git a/drivers/usb/host/ehci-octeon.c b/drivers/usb/host/ehci-octeon.c index ba1f51361134..c0104882c72d 100644 --- a/drivers/usb/host/ehci-octeon.c +++ b/drivers/usb/host/ehci-octeon.c | |||
@@ -155,6 +155,8 @@ static int ehci_octeon_drv_probe(struct platform_device *pdev) | |||
155 | /* cache this readonly data; minimize chip reads */ | 155 | /* cache this readonly data; minimize chip reads */ |
156 | ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params); | 156 | ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params); |
157 | 157 | ||
158 | ehci_reset(ehci); | ||
159 | |||
158 | ret = usb_add_hcd(hcd, irq, IRQF_SHARED); | 160 | ret = usb_add_hcd(hcd, irq, IRQF_SHARED); |
159 | if (ret) { | 161 | if (ret) { |
160 | dev_dbg(&pdev->dev, "failed to add hcd with err %d\n", ret); | 162 | dev_dbg(&pdev->dev, "failed to add hcd with err %d\n", ret); |
diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c index e39b0297bad1..bba9850f32f0 100644 --- a/drivers/usb/host/ehci-omap.c +++ b/drivers/usb/host/ehci-omap.c | |||
@@ -41,6 +41,7 @@ | |||
41 | #include <linux/usb/ulpi.h> | 41 | #include <linux/usb/ulpi.h> |
42 | #include <plat/usb.h> | 42 | #include <plat/usb.h> |
43 | #include <linux/regulator/consumer.h> | 43 | #include <linux/regulator/consumer.h> |
44 | #include <linux/pm_runtime.h> | ||
44 | 45 | ||
45 | /* EHCI Register Set */ | 46 | /* EHCI Register Set */ |
46 | #define EHCI_INSNREG04 (0xA0) | 47 | #define EHCI_INSNREG04 (0xA0) |
@@ -190,11 +191,8 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev) | |||
190 | } | 191 | } |
191 | } | 192 | } |
192 | 193 | ||
193 | ret = omap_usbhs_enable(dev); | 194 | pm_runtime_enable(dev); |
194 | if (ret) { | 195 | pm_runtime_get_sync(dev); |
195 | dev_err(dev, "failed to start usbhs with err %d\n", ret); | ||
196 | goto err_enable; | ||
197 | } | ||
198 | 196 | ||
199 | /* | 197 | /* |
200 | * An undocumented "feature" in the OMAP3 EHCI controller, | 198 | * An undocumented "feature" in the OMAP3 EHCI controller, |
@@ -228,6 +226,8 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev) | |||
228 | /* cache this readonly data; minimize chip reads */ | 226 | /* cache this readonly data; minimize chip reads */ |
229 | omap_ehci->hcs_params = readl(&omap_ehci->caps->hcs_params); | 227 | omap_ehci->hcs_params = readl(&omap_ehci->caps->hcs_params); |
230 | 228 | ||
229 | ehci_reset(omap_ehci); | ||
230 | |||
231 | ret = usb_add_hcd(hcd, irq, IRQF_SHARED); | 231 | ret = usb_add_hcd(hcd, irq, IRQF_SHARED); |
232 | if (ret) { | 232 | if (ret) { |
233 | dev_err(dev, "failed to add hcd with err %d\n", ret); | 233 | dev_err(dev, "failed to add hcd with err %d\n", ret); |
@@ -240,11 +240,8 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev) | |||
240 | return 0; | 240 | return 0; |
241 | 241 | ||
242 | err_add_hcd: | 242 | err_add_hcd: |
243 | omap_usbhs_disable(dev); | ||
244 | |||
245 | err_enable: | ||
246 | disable_put_regulator(pdata); | 243 | disable_put_regulator(pdata); |
247 | usb_put_hcd(hcd); | 244 | pm_runtime_put_sync(dev); |
248 | 245 | ||
249 | err_io: | 246 | err_io: |
250 | iounmap(regs); | 247 | iounmap(regs); |
@@ -266,10 +263,12 @@ static int ehci_hcd_omap_remove(struct platform_device *pdev) | |||
266 | struct usb_hcd *hcd = dev_get_drvdata(dev); | 263 | struct usb_hcd *hcd = dev_get_drvdata(dev); |
267 | 264 | ||
268 | usb_remove_hcd(hcd); | 265 | usb_remove_hcd(hcd); |
269 | omap_usbhs_disable(dev); | ||
270 | disable_put_regulator(dev->platform_data); | 266 | disable_put_regulator(dev->platform_data); |
271 | iounmap(hcd->regs); | 267 | iounmap(hcd->regs); |
272 | usb_put_hcd(hcd); | 268 | usb_put_hcd(hcd); |
269 | pm_runtime_put_sync(dev); | ||
270 | pm_runtime_disable(dev); | ||
271 | |||
273 | return 0; | 272 | return 0; |
274 | } | 273 | } |
275 | 274 | ||
diff --git a/drivers/usb/host/ehci-orion.c b/drivers/usb/host/ehci-orion.c index a68a2a5c4b83..6c6a5a3b4ea7 100644 --- a/drivers/usb/host/ehci-orion.c +++ b/drivers/usb/host/ehci-orion.c | |||
@@ -172,7 +172,7 @@ static const struct hc_driver ehci_orion_hc_driver = { | |||
172 | 172 | ||
173 | static void __init | 173 | static void __init |
174 | ehci_orion_conf_mbus_windows(struct usb_hcd *hcd, | 174 | ehci_orion_conf_mbus_windows(struct usb_hcd *hcd, |
175 | struct mbus_dram_target_info *dram) | 175 | const struct mbus_dram_target_info *dram) |
176 | { | 176 | { |
177 | int i; | 177 | int i; |
178 | 178 | ||
@@ -182,7 +182,7 @@ ehci_orion_conf_mbus_windows(struct usb_hcd *hcd, | |||
182 | } | 182 | } |
183 | 183 | ||
184 | for (i = 0; i < dram->num_cs; i++) { | 184 | for (i = 0; i < dram->num_cs; i++) { |
185 | struct mbus_dram_window *cs = dram->cs + i; | 185 | const struct mbus_dram_window *cs = dram->cs + i; |
186 | 186 | ||
187 | wrl(USB_WINDOW_CTRL(i), ((cs->size - 1) & 0xffff0000) | | 187 | wrl(USB_WINDOW_CTRL(i), ((cs->size - 1) & 0xffff0000) | |
188 | (cs->mbus_attr << 8) | | 188 | (cs->mbus_attr << 8) | |
@@ -194,6 +194,7 @@ ehci_orion_conf_mbus_windows(struct usb_hcd *hcd, | |||
194 | static int __devinit ehci_orion_drv_probe(struct platform_device *pdev) | 194 | static int __devinit ehci_orion_drv_probe(struct platform_device *pdev) |
195 | { | 195 | { |
196 | struct orion_ehci_data *pd = pdev->dev.platform_data; | 196 | struct orion_ehci_data *pd = pdev->dev.platform_data; |
197 | const struct mbus_dram_target_info *dram; | ||
197 | struct resource *res; | 198 | struct resource *res; |
198 | struct usb_hcd *hcd; | 199 | struct usb_hcd *hcd; |
199 | struct ehci_hcd *ehci; | 200 | struct ehci_hcd *ehci; |
@@ -259,8 +260,9 @@ static int __devinit ehci_orion_drv_probe(struct platform_device *pdev) | |||
259 | /* | 260 | /* |
260 | * (Re-)program MBUS remapping windows if we are asked to. | 261 | * (Re-)program MBUS remapping windows if we are asked to. |
261 | */ | 262 | */ |
262 | if (pd != NULL && pd->dram != NULL) | 263 | dram = mv_mbus_dram_info(); |
263 | ehci_orion_conf_mbus_windows(hcd, pd->dram); | 264 | if (dram) |
265 | ehci_orion_conf_mbus_windows(hcd, dram); | ||
264 | 266 | ||
265 | /* | 267 | /* |
266 | * setup Orion USB controller. | 268 | * setup Orion USB controller. |
diff --git a/drivers/usb/host/ehci-ps3.c b/drivers/usb/host/ehci-ps3.c index 2dc32da75cfc..a20e496eb479 100644 --- a/drivers/usb/host/ehci-ps3.c +++ b/drivers/usb/host/ehci-ps3.c | |||
@@ -21,6 +21,34 @@ | |||
21 | #include <asm/firmware.h> | 21 | #include <asm/firmware.h> |
22 | #include <asm/ps3.h> | 22 | #include <asm/ps3.h> |
23 | 23 | ||
24 | static void ps3_ehci_setup_insnreg(struct ehci_hcd *ehci) | ||
25 | { | ||
26 | /* PS3 HC internal setup register offsets. */ | ||
27 | |||
28 | enum ps3_ehci_hc_insnreg { | ||
29 | ps3_ehci_hc_insnreg01 = 0x084, | ||
30 | ps3_ehci_hc_insnreg02 = 0x088, | ||
31 | ps3_ehci_hc_insnreg03 = 0x08c, | ||
32 | }; | ||
33 | |||
34 | /* PS3 EHCI HC errata fix 316 - The PS3 EHCI HC will reset its | ||
35 | * internal INSNREGXX setup regs back to the chip default values | ||
36 | * on Host Controller Reset (CMD_RESET) or Light Host Controller | ||
37 | * Reset (CMD_LRESET). The work-around for this is for the HC | ||
38 | * driver to re-initialise these regs when ever the HC is reset. | ||
39 | */ | ||
40 | |||
41 | /* Set burst transfer counts to 256 out, 32 in. */ | ||
42 | |||
43 | writel_be(0x01000020, (void __iomem *)ehci->regs + | ||
44 | ps3_ehci_hc_insnreg01); | ||
45 | |||
46 | /* Enable burst transfer counts. */ | ||
47 | |||
48 | writel_be(0x00000001, (void __iomem *)ehci->regs + | ||
49 | ps3_ehci_hc_insnreg03); | ||
50 | } | ||
51 | |||
24 | static int ps3_ehci_hc_reset(struct usb_hcd *hcd) | 52 | static int ps3_ehci_hc_reset(struct usb_hcd *hcd) |
25 | { | 53 | { |
26 | int result; | 54 | int result; |
@@ -49,6 +77,8 @@ static int ps3_ehci_hc_reset(struct usb_hcd *hcd) | |||
49 | 77 | ||
50 | ehci_reset(ehci); | 78 | ehci_reset(ehci); |
51 | 79 | ||
80 | ps3_ehci_setup_insnreg(ehci); | ||
81 | |||
52 | return result; | 82 | return result; |
53 | } | 83 | } |
54 | 84 | ||
diff --git a/drivers/usb/host/ehci-pxa168.c b/drivers/usb/host/ehci-pxa168.c index ac0c16e8f539..8d0e7a22e711 100644 --- a/drivers/usb/host/ehci-pxa168.c +++ b/drivers/usb/host/ehci-pxa168.c | |||
@@ -299,7 +299,7 @@ static int __devinit ehci_pxa168_drv_probe(struct platform_device *pdev) | |||
299 | ehci = hcd_to_ehci(hcd); | 299 | ehci = hcd_to_ehci(hcd); |
300 | ehci->caps = hcd->regs + 0x100; | 300 | ehci->caps = hcd->regs + 0x100; |
301 | ehci->regs = hcd->regs + 0x100 + | 301 | ehci->regs = hcd->regs + 0x100 + |
302 | HC_LENGTH(ehci_readl(ehci, &ehci->caps->hc_capbase)); | 302 | HC_LENGTH(ehci, ehci_readl(ehci, &ehci->caps->hc_capbase)); |
303 | ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params); | 303 | ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params); |
304 | hcd->has_tt = 1; | 304 | hcd->has_tt = 1; |
305 | ehci->sbrn = 0x20; | 305 | ehci->sbrn = 0x20; |
diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c index 4e4066c35a09..36ca5077cdf7 100644 --- a/drivers/usb/host/ehci-q.c +++ b/drivers/usb/host/ehci-q.c | |||
@@ -373,6 +373,17 @@ qh_completions (struct ehci_hcd *ehci, struct ehci_qh *qh) | |||
373 | retry_xacterr: | 373 | retry_xacterr: |
374 | if ((token & QTD_STS_ACTIVE) == 0) { | 374 | if ((token & QTD_STS_ACTIVE) == 0) { |
375 | 375 | ||
376 | /* Report Data Buffer Error: non-fatal but useful */ | ||
377 | if (token & QTD_STS_DBE) | ||
378 | ehci_dbg(ehci, | ||
379 | "detected DataBufferErr for urb %p ep%d%s len %d, qtd %p [qh %p]\n", | ||
380 | urb, | ||
381 | usb_endpoint_num(&urb->ep->desc), | ||
382 | usb_endpoint_dir_in(&urb->ep->desc) ? "in" : "out", | ||
383 | urb->transfer_buffer_length, | ||
384 | qtd, | ||
385 | qh); | ||
386 | |||
376 | /* on STALL, error, and short reads this urb must | 387 | /* on STALL, error, and short reads this urb must |
377 | * complete and all its qtds must be recycled. | 388 | * complete and all its qtds must be recycled. |
378 | */ | 389 | */ |
@@ -647,7 +658,7 @@ qh_urb_transaction ( | |||
647 | /* | 658 | /* |
648 | * data transfer stage: buffer setup | 659 | * data transfer stage: buffer setup |
649 | */ | 660 | */ |
650 | i = urb->num_sgs; | 661 | i = urb->num_mapped_sgs; |
651 | if (len > 0 && i > 0) { | 662 | if (len > 0 && i > 0) { |
652 | sg = urb->sg; | 663 | sg = urb->sg; |
653 | buf = sg_dma_address(sg); | 664 | buf = sg_dma_address(sg); |
diff --git a/drivers/usb/host/ehci-s5p.c b/drivers/usb/host/ehci-s5p.c index 024b65c4990d..293f7412992e 100644 --- a/drivers/usb/host/ehci-s5p.c +++ b/drivers/usb/host/ehci-s5p.c | |||
@@ -14,8 +14,6 @@ | |||
14 | 14 | ||
15 | #include <linux/clk.h> | 15 | #include <linux/clk.h> |
16 | #include <linux/platform_device.h> | 16 | #include <linux/platform_device.h> |
17 | #include <mach/regs-pmu.h> | ||
18 | #include <plat/cpu.h> | ||
19 | #include <plat/ehci.h> | 17 | #include <plat/ehci.h> |
20 | #include <plat/usb-phy.h> | 18 | #include <plat/usb-phy.h> |
21 | 19 | ||
@@ -136,6 +134,8 @@ static int __devinit s5p_ehci_probe(struct platform_device *pdev) | |||
136 | /* cache this readonly data; minimize chip reads */ | 134 | /* cache this readonly data; minimize chip reads */ |
137 | ehci->hcs_params = readl(&ehci->caps->hcs_params); | 135 | ehci->hcs_params = readl(&ehci->caps->hcs_params); |
138 | 136 | ||
137 | ehci_reset(ehci); | ||
138 | |||
139 | err = usb_add_hcd(hcd, irq, IRQF_SHARED); | 139 | err = usb_add_hcd(hcd, irq, IRQF_SHARED); |
140 | if (err) { | 140 | if (err) { |
141 | dev_err(&pdev->dev, "Failed to add USB HCD\n"); | 141 | dev_err(&pdev->dev, "Failed to add USB HCD\n"); |
diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c index 2e829fae6482..a60679cbbf85 100644 --- a/drivers/usb/host/ehci-sched.c +++ b/drivers/usb/host/ehci-sched.c | |||
@@ -1475,30 +1475,36 @@ iso_stream_schedule ( | |||
1475 | * jump until after the queue is primed. | 1475 | * jump until after the queue is primed. |
1476 | */ | 1476 | */ |
1477 | else { | 1477 | else { |
1478 | int done = 0; | ||
1478 | start = SCHEDULE_SLOP + (now & ~0x07); | 1479 | start = SCHEDULE_SLOP + (now & ~0x07); |
1479 | 1480 | ||
1480 | /* NOTE: assumes URB_ISO_ASAP, to limit complexity/bugs */ | 1481 | /* NOTE: assumes URB_ISO_ASAP, to limit complexity/bugs */ |
1481 | 1482 | ||
1482 | /* find a uframe slot with enough bandwidth */ | 1483 | /* find a uframe slot with enough bandwidth. |
1483 | next = start + period; | 1484 | * Early uframes are more precious because full-speed |
1484 | for (; start < next; start++) { | 1485 | * iso IN transfers can't use late uframes, |
1485 | 1486 | * and therefore they should be allocated last. | |
1487 | */ | ||
1488 | next = start; | ||
1489 | start += period; | ||
1490 | do { | ||
1491 | start--; | ||
1486 | /* check schedule: enough space? */ | 1492 | /* check schedule: enough space? */ |
1487 | if (stream->highspeed) { | 1493 | if (stream->highspeed) { |
1488 | if (itd_slot_ok(ehci, mod, start, | 1494 | if (itd_slot_ok(ehci, mod, start, |
1489 | stream->usecs, period)) | 1495 | stream->usecs, period)) |
1490 | break; | 1496 | done = 1; |
1491 | } else { | 1497 | } else { |
1492 | if ((start % 8) >= 6) | 1498 | if ((start % 8) >= 6) |
1493 | continue; | 1499 | continue; |
1494 | if (sitd_slot_ok(ehci, mod, stream, | 1500 | if (sitd_slot_ok(ehci, mod, stream, |
1495 | start, sched, period)) | 1501 | start, sched, period)) |
1496 | break; | 1502 | done = 1; |
1497 | } | 1503 | } |
1498 | } | 1504 | } while (start > next && !done); |
1499 | 1505 | ||
1500 | /* no room in the schedule */ | 1506 | /* no room in the schedule */ |
1501 | if (start == next) { | 1507 | if (!done) { |
1502 | ehci_dbg(ehci, "iso resched full %p (now %d max %d)\n", | 1508 | ehci_dbg(ehci, "iso resched full %p (now %d max %d)\n", |
1503 | urb, now, now + mod); | 1509 | urb, now, now + mod); |
1504 | status = -ENOSPC; | 1510 | status = -ENOSPC; |
diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c index db9d1b4bfbdc..dbc7fe8ca9e7 100644 --- a/drivers/usb/host/ehci-tegra.c +++ b/drivers/usb/host/ehci-tegra.c | |||
@@ -21,7 +21,12 @@ | |||
21 | #include <linux/platform_data/tegra_usb.h> | 21 | #include <linux/platform_data/tegra_usb.h> |
22 | #include <linux/irq.h> | 22 | #include <linux/irq.h> |
23 | #include <linux/usb/otg.h> | 23 | #include <linux/usb/otg.h> |
24 | #include <linux/gpio.h> | ||
25 | #include <linux/of.h> | ||
26 | #include <linux/of_gpio.h> | ||
27 | |||
24 | #include <mach/usb_phy.h> | 28 | #include <mach/usb_phy.h> |
29 | #include <mach/iomap.h> | ||
25 | 30 | ||
26 | #define TEGRA_USB_DMA_ALIGN 32 | 31 | #define TEGRA_USB_DMA_ALIGN 32 |
27 | 32 | ||
@@ -574,6 +579,35 @@ static const struct hc_driver tegra_ehci_hc_driver = { | |||
574 | .port_handed_over = ehci_port_handed_over, | 579 | .port_handed_over = ehci_port_handed_over, |
575 | }; | 580 | }; |
576 | 581 | ||
582 | static int setup_vbus_gpio(struct platform_device *pdev) | ||
583 | { | ||
584 | int err = 0; | ||
585 | int gpio; | ||
586 | |||
587 | if (!pdev->dev.of_node) | ||
588 | return 0; | ||
589 | |||
590 | gpio = of_get_named_gpio(pdev->dev.of_node, "nvidia,vbus-gpio", 0); | ||
591 | if (!gpio_is_valid(gpio)) | ||
592 | return 0; | ||
593 | |||
594 | err = gpio_request(gpio, "vbus_gpio"); | ||
595 | if (err) { | ||
596 | dev_err(&pdev->dev, "can't request vbus gpio %d", gpio); | ||
597 | return err; | ||
598 | } | ||
599 | err = gpio_direction_output(gpio, 1); | ||
600 | if (err) { | ||
601 | dev_err(&pdev->dev, "can't enable vbus\n"); | ||
602 | return err; | ||
603 | } | ||
604 | gpio_set_value(gpio, 1); | ||
605 | |||
606 | return err; | ||
607 | } | ||
608 | |||
609 | static u64 tegra_ehci_dma_mask = DMA_BIT_MASK(32); | ||
610 | |||
577 | static int tegra_ehci_probe(struct platform_device *pdev) | 611 | static int tegra_ehci_probe(struct platform_device *pdev) |
578 | { | 612 | { |
579 | struct resource *res; | 613 | struct resource *res; |
@@ -590,6 +624,15 @@ static int tegra_ehci_probe(struct platform_device *pdev) | |||
590 | return -EINVAL; | 624 | return -EINVAL; |
591 | } | 625 | } |
592 | 626 | ||
627 | /* Right now device-tree probed devices don't get dma_mask set. | ||
628 | * Since shared usb code relies on it, set it here for now. | ||
629 | * Once we have dma capability bindings this can go away. | ||
630 | */ | ||
631 | if (!pdev->dev.dma_mask) | ||
632 | pdev->dev.dma_mask = &tegra_ehci_dma_mask; | ||
633 | |||
634 | setup_vbus_gpio(pdev); | ||
635 | |||
593 | tegra = kzalloc(sizeof(struct tegra_ehci_hcd), GFP_KERNEL); | 636 | tegra = kzalloc(sizeof(struct tegra_ehci_hcd), GFP_KERNEL); |
594 | if (!tegra) | 637 | if (!tegra) |
595 | return -ENOMEM; | 638 | return -ENOMEM; |
@@ -640,6 +683,28 @@ static int tegra_ehci_probe(struct platform_device *pdev) | |||
640 | goto fail_io; | 683 | goto fail_io; |
641 | } | 684 | } |
642 | 685 | ||
686 | /* This is pretty ugly and needs to be fixed when we do only | ||
687 | * device-tree probing. Old code relies on the platform_device | ||
688 | * numbering that we lack for device-tree-instantiated devices. | ||
689 | */ | ||
690 | if (instance < 0) { | ||
691 | switch (res->start) { | ||
692 | case TEGRA_USB_BASE: | ||
693 | instance = 0; | ||
694 | break; | ||
695 | case TEGRA_USB2_BASE: | ||
696 | instance = 1; | ||
697 | break; | ||
698 | case TEGRA_USB3_BASE: | ||
699 | instance = 2; | ||
700 | break; | ||
701 | default: | ||
702 | err = -ENODEV; | ||
703 | dev_err(&pdev->dev, "unknown usb instance\n"); | ||
704 | goto fail_phy; | ||
705 | } | ||
706 | } | ||
707 | |||
643 | tegra->phy = tegra_usb_phy_open(instance, hcd->regs, pdata->phy_config, | 708 | tegra->phy = tegra_usb_phy_open(instance, hcd->regs, pdata->phy_config, |
644 | TEGRA_USB_PHY_MODE_HOST); | 709 | TEGRA_USB_PHY_MODE_HOST); |
645 | if (IS_ERR(tegra->phy)) { | 710 | if (IS_ERR(tegra->phy)) { |
@@ -773,6 +838,11 @@ static void tegra_ehci_hcd_shutdown(struct platform_device *pdev) | |||
773 | hcd->driver->shutdown(hcd); | 838 | hcd->driver->shutdown(hcd); |
774 | } | 839 | } |
775 | 840 | ||
841 | static struct of_device_id tegra_ehci_of_match[] __devinitdata = { | ||
842 | { .compatible = "nvidia,tegra20-ehci", }, | ||
843 | { }, | ||
844 | }; | ||
845 | |||
776 | static struct platform_driver tegra_ehci_driver = { | 846 | static struct platform_driver tegra_ehci_driver = { |
777 | .probe = tegra_ehci_probe, | 847 | .probe = tegra_ehci_probe, |
778 | .remove = tegra_ehci_remove, | 848 | .remove = tegra_ehci_remove, |
@@ -783,5 +853,6 @@ static struct platform_driver tegra_ehci_driver = { | |||
783 | .shutdown = tegra_ehci_hcd_shutdown, | 853 | .shutdown = tegra_ehci_hcd_shutdown, |
784 | .driver = { | 854 | .driver = { |
785 | .name = "tegra-ehci", | 855 | .name = "tegra-ehci", |
856 | .of_match_table = tegra_ehci_of_match, | ||
786 | } | 857 | } |
787 | }; | 858 | }; |
diff --git a/drivers/usb/host/ehci-vt8500.c b/drivers/usb/host/ehci-vt8500.c index 54d1ab8aec49..c1eda73916cd 100644 --- a/drivers/usb/host/ehci-vt8500.c +++ b/drivers/usb/host/ehci-vt8500.c | |||
@@ -132,6 +132,8 @@ static int vt8500_ehci_drv_probe(struct platform_device *pdev) | |||
132 | 132 | ||
133 | ehci_port_power(ehci, 1); | 133 | ehci_port_power(ehci, 1); |
134 | 134 | ||
135 | ehci_reset(ehci); | ||
136 | |||
135 | ret = usb_add_hcd(hcd, pdev->resource[1].start, | 137 | ret = usb_add_hcd(hcd, pdev->resource[1].start, |
136 | IRQF_SHARED); | 138 | IRQF_SHARED); |
137 | if (ret == 0) { | 139 | if (ret == 0) { |
diff --git a/drivers/usb/host/ehci-w90x900.c b/drivers/usb/host/ehci-w90x900.c index d661cf7de140..3d2e26cbb34c 100644 --- a/drivers/usb/host/ehci-w90x900.c +++ b/drivers/usb/host/ehci-w90x900.c | |||
@@ -78,6 +78,8 @@ static int __devinit usb_w90x900_probe(const struct hc_driver *driver, | |||
78 | if (irq < 0) | 78 | if (irq < 0) |
79 | goto err4; | 79 | goto err4; |
80 | 80 | ||
81 | ehci_reset(ehci); | ||
82 | |||
81 | retval = usb_add_hcd(hcd, irq, IRQF_SHARED); | 83 | retval = usb_add_hcd(hcd, irq, IRQF_SHARED); |
82 | if (retval != 0) | 84 | if (retval != 0) |
83 | goto err4; | 85 | goto err4; |
diff --git a/drivers/usb/host/ehci-xilinx-of.c b/drivers/usb/host/ehci-xilinx-of.c index 32793ce3d9e9..9c2cc4633894 100644 --- a/drivers/usb/host/ehci-xilinx-of.c +++ b/drivers/usb/host/ehci-xilinx-of.c | |||
@@ -183,7 +183,7 @@ static int __devinit ehci_hcd_xilinx_of_probe(struct platform_device *op) | |||
183 | } | 183 | } |
184 | 184 | ||
185 | irq = irq_of_parse_and_map(dn, 0); | 185 | irq = irq_of_parse_and_map(dn, 0); |
186 | if (irq == NO_IRQ) { | 186 | if (!irq) { |
187 | printk(KERN_ERR "%s: irq_of_parse_and_map failed\n", __FILE__); | 187 | printk(KERN_ERR "%s: irq_of_parse_and_map failed\n", __FILE__); |
188 | rv = -EBUSY; | 188 | rv = -EBUSY; |
189 | goto err_irq; | 189 | goto err_irq; |
diff --git a/drivers/usb/host/ehci-xls.c b/drivers/usb/host/ehci-xls.c index fe74bd676018..72f08196f8cd 100644 --- a/drivers/usb/host/ehci-xls.c +++ b/drivers/usb/host/ehci-xls.c | |||
@@ -19,7 +19,7 @@ static int ehci_xls_setup(struct usb_hcd *hcd) | |||
19 | 19 | ||
20 | ehci->caps = hcd->regs; | 20 | ehci->caps = hcd->regs; |
21 | ehci->regs = hcd->regs + | 21 | ehci->regs = hcd->regs + |
22 | HC_LENGTH(ehci_readl(ehci, &ehci->caps->hc_capbase)); | 22 | HC_LENGTH(ehci, ehci_readl(ehci, &ehci->caps->hc_capbase)); |
23 | dbg_hcs_params(ehci, "reset"); | 23 | dbg_hcs_params(ehci, "reset"); |
24 | dbg_hcc_params(ehci, "reset"); | 24 | dbg_hcc_params(ehci, "reset"); |
25 | 25 | ||
@@ -69,7 +69,7 @@ int ehci_xls_probe_internal(const struct hc_driver *driver, | |||
69 | } | 69 | } |
70 | 70 | ||
71 | hcd->rsrc_start = res->start; | 71 | hcd->rsrc_start = res->start; |
72 | hcd->rsrc_len = res->end - res->start + 1; | 72 | hcd->rsrc_len = resource_size(res); |
73 | 73 | ||
74 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, | 74 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, |
75 | driver->description)) { | 75 | driver->description)) { |
diff --git a/drivers/usb/host/fhci-hcd.c b/drivers/usb/host/fhci-hcd.c index 4ed6d19f2a54..d2623747b489 100644 --- a/drivers/usb/host/fhci-hcd.c +++ b/drivers/usb/host/fhci-hcd.c | |||
@@ -824,17 +824,7 @@ static struct platform_driver of_fhci_driver = { | |||
824 | .remove = __devexit_p(of_fhci_remove), | 824 | .remove = __devexit_p(of_fhci_remove), |
825 | }; | 825 | }; |
826 | 826 | ||
827 | static int __init fhci_module_init(void) | 827 | module_platform_driver(of_fhci_driver); |
828 | { | ||
829 | return platform_driver_register(&of_fhci_driver); | ||
830 | } | ||
831 | module_init(fhci_module_init); | ||
832 | |||
833 | static void __exit fhci_module_exit(void) | ||
834 | { | ||
835 | platform_driver_unregister(&of_fhci_driver); | ||
836 | } | ||
837 | module_exit(fhci_module_exit); | ||
838 | 828 | ||
839 | MODULE_DESCRIPTION("USB Freescale Host Controller Interface Driver"); | 829 | MODULE_DESCRIPTION("USB Freescale Host Controller Interface Driver"); |
840 | MODULE_AUTHOR("Shlomi Gridish <gridish@freescale.com>, " | 830 | MODULE_AUTHOR("Shlomi Gridish <gridish@freescale.com>, " |
diff --git a/drivers/usb/host/fsl-mph-dr-of.c b/drivers/usb/host/fsl-mph-dr-of.c index 9037035ad1e4..7916e56a725e 100644 --- a/drivers/usb/host/fsl-mph-dr-of.c +++ b/drivers/usb/host/fsl-mph-dr-of.c | |||
@@ -297,17 +297,7 @@ static struct platform_driver fsl_usb2_mph_dr_driver = { | |||
297 | .remove = __devexit_p(fsl_usb2_mph_dr_of_remove), | 297 | .remove = __devexit_p(fsl_usb2_mph_dr_of_remove), |
298 | }; | 298 | }; |
299 | 299 | ||
300 | static int __init fsl_usb2_mph_dr_init(void) | 300 | module_platform_driver(fsl_usb2_mph_dr_driver); |
301 | { | ||
302 | return platform_driver_register(&fsl_usb2_mph_dr_driver); | ||
303 | } | ||
304 | module_init(fsl_usb2_mph_dr_init); | ||
305 | |||
306 | static void __exit fsl_usb2_mph_dr_exit(void) | ||
307 | { | ||
308 | platform_driver_unregister(&fsl_usb2_mph_dr_driver); | ||
309 | } | ||
310 | module_exit(fsl_usb2_mph_dr_exit); | ||
311 | 301 | ||
312 | MODULE_DESCRIPTION("FSL MPH DR OF devices driver"); | 302 | MODULE_DESCRIPTION("FSL MPH DR OF devices driver"); |
313 | MODULE_AUTHOR("Anatolij Gustschin <agust@denx.de>"); | 303 | MODULE_AUTHOR("Anatolij Gustschin <agust@denx.de>"); |
diff --git a/drivers/usb/host/hwa-hc.c b/drivers/usb/host/hwa-hc.c index 9bfac657572e..104730dabd2d 100644 --- a/drivers/usb/host/hwa-hc.c +++ b/drivers/usb/host/hwa-hc.c | |||
@@ -481,7 +481,7 @@ static int __hwahc_op_set_ptk(struct wusbhc *wusbhc, u8 port_idx, u32 tkid, | |||
481 | encryption_value = 0; | 481 | encryption_value = 0; |
482 | } | 482 | } |
483 | 483 | ||
484 | /* Set the encryption type for commmunicating with the device */ | 484 | /* Set the encryption type for communicating with the device */ |
485 | result = usb_control_msg(wa->usb_dev, usb_sndctrlpipe(wa->usb_dev, 0), | 485 | result = usb_control_msg(wa->usb_dev, usb_sndctrlpipe(wa->usb_dev, 0), |
486 | USB_REQ_SET_ENCRYPTION, | 486 | USB_REQ_SET_ENCRYPTION, |
487 | USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE, | 487 | USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE, |
@@ -776,7 +776,6 @@ static int hwahc_probe(struct usb_interface *usb_iface, | |||
776 | goto error_alloc; | 776 | goto error_alloc; |
777 | } | 777 | } |
778 | usb_hcd->wireless = 1; | 778 | usb_hcd->wireless = 1; |
779 | set_bit(HCD_FLAG_SAW_IRQ, &usb_hcd->flags); | ||
780 | wusbhc = usb_hcd_to_wusbhc(usb_hcd); | 779 | wusbhc = usb_hcd_to_wusbhc(usb_hcd); |
781 | hwahc = container_of(wusbhc, struct hwahc, wusbhc); | 780 | hwahc = container_of(wusbhc, struct hwahc, wusbhc); |
782 | hwahc_init(hwahc); | 781 | hwahc_init(hwahc); |
@@ -837,18 +836,7 @@ static struct usb_driver hwahc_driver = { | |||
837 | .id_table = hwahc_id_table, | 836 | .id_table = hwahc_id_table, |
838 | }; | 837 | }; |
839 | 838 | ||
840 | static int __init hwahc_driver_init(void) | 839 | module_usb_driver(hwahc_driver); |
841 | { | ||
842 | return usb_register(&hwahc_driver); | ||
843 | } | ||
844 | module_init(hwahc_driver_init); | ||
845 | |||
846 | static void __exit hwahc_driver_exit(void) | ||
847 | { | ||
848 | usb_deregister(&hwahc_driver); | ||
849 | } | ||
850 | module_exit(hwahc_driver_exit); | ||
851 | |||
852 | 840 | ||
853 | MODULE_AUTHOR("Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>"); | 841 | MODULE_AUTHOR("Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>"); |
854 | MODULE_DESCRIPTION("Host Wired Adapter USB Host Control Driver"); | 842 | MODULE_DESCRIPTION("Host Wired Adapter USB Host Control Driver"); |
diff --git a/drivers/usb/host/imx21-hcd.c b/drivers/usb/host/imx21-hcd.c index 2ee18cfa1efe..ff471c1c165e 100644 --- a/drivers/usb/host/imx21-hcd.c +++ b/drivers/usb/host/imx21-hcd.c | |||
@@ -473,7 +473,7 @@ static void free_epdmem(struct imx21 *imx21, struct usb_host_endpoint *ep) | |||
473 | /* End handling */ | 473 | /* End handling */ |
474 | /* =========================================== */ | 474 | /* =========================================== */ |
475 | 475 | ||
476 | /* Endpoint now idle - release it's ETD(s) or asssign to queued request */ | 476 | /* Endpoint now idle - release its ETD(s) or assign to queued request */ |
477 | static void ep_idle(struct imx21 *imx21, struct ep_priv *ep_priv) | 477 | static void ep_idle(struct imx21 *imx21, struct ep_priv *ep_priv) |
478 | { | 478 | { |
479 | int i; | 479 | int i; |
@@ -1924,18 +1924,7 @@ static struct platform_driver imx21_hcd_driver = { | |||
1924 | .resume = NULL, | 1924 | .resume = NULL, |
1925 | }; | 1925 | }; |
1926 | 1926 | ||
1927 | static int __init imx21_hcd_init(void) | 1927 | module_platform_driver(imx21_hcd_driver); |
1928 | { | ||
1929 | return platform_driver_register(&imx21_hcd_driver); | ||
1930 | } | ||
1931 | |||
1932 | static void __exit imx21_hcd_cleanup(void) | ||
1933 | { | ||
1934 | platform_driver_unregister(&imx21_hcd_driver); | ||
1935 | } | ||
1936 | |||
1937 | module_init(imx21_hcd_init); | ||
1938 | module_exit(imx21_hcd_cleanup); | ||
1939 | 1928 | ||
1940 | MODULE_DESCRIPTION("i.MX21 USB Host controller"); | 1929 | MODULE_DESCRIPTION("i.MX21 USB Host controller"); |
1941 | MODULE_AUTHOR("Martin Fuzzey"); | 1930 | MODULE_AUTHOR("Martin Fuzzey"); |
diff --git a/drivers/usb/host/isp1760-hcd.c b/drivers/usb/host/isp1760-hcd.c index 27dfab80ed8f..fc72d44bf787 100644 --- a/drivers/usb/host/isp1760-hcd.c +++ b/drivers/usb/host/isp1760-hcd.c | |||
@@ -32,6 +32,13 @@ static struct kmem_cache *qtd_cachep; | |||
32 | static struct kmem_cache *qh_cachep; | 32 | static struct kmem_cache *qh_cachep; |
33 | static struct kmem_cache *urb_listitem_cachep; | 33 | static struct kmem_cache *urb_listitem_cachep; |
34 | 34 | ||
35 | enum queue_head_types { | ||
36 | QH_CONTROL, | ||
37 | QH_BULK, | ||
38 | QH_INTERRUPT, | ||
39 | QH_END | ||
40 | }; | ||
41 | |||
35 | struct isp1760_hcd { | 42 | struct isp1760_hcd { |
36 | u32 hcs_params; | 43 | u32 hcs_params; |
37 | spinlock_t lock; | 44 | spinlock_t lock; |
@@ -40,7 +47,7 @@ struct isp1760_hcd { | |||
40 | struct slotinfo int_slots[32]; | 47 | struct slotinfo int_slots[32]; |
41 | int int_done_map; | 48 | int int_done_map; |
42 | struct memory_chunk memory_pool[BLOCKS]; | 49 | struct memory_chunk memory_pool[BLOCKS]; |
43 | struct list_head controlqhs, bulkqhs, interruptqhs; | 50 | struct list_head qh_list[QH_END]; |
44 | 51 | ||
45 | /* periodic schedule support */ | 52 | /* periodic schedule support */ |
46 | #define DEFAULT_I_TDPS 1024 | 53 | #define DEFAULT_I_TDPS 1024 |
@@ -406,12 +413,12 @@ static int priv_init(struct usb_hcd *hcd) | |||
406 | { | 413 | { |
407 | struct isp1760_hcd *priv = hcd_to_priv(hcd); | 414 | struct isp1760_hcd *priv = hcd_to_priv(hcd); |
408 | u32 hcc_params; | 415 | u32 hcc_params; |
416 | int i; | ||
409 | 417 | ||
410 | spin_lock_init(&priv->lock); | 418 | spin_lock_init(&priv->lock); |
411 | 419 | ||
412 | INIT_LIST_HEAD(&priv->interruptqhs); | 420 | for (i = 0; i < QH_END; i++) |
413 | INIT_LIST_HEAD(&priv->controlqhs); | 421 | INIT_LIST_HEAD(&priv->qh_list[i]); |
414 | INIT_LIST_HEAD(&priv->bulkqhs); | ||
415 | 422 | ||
416 | /* | 423 | /* |
417 | * hw default: 1K periodic list heads, one per frame. | 424 | * hw default: 1K periodic list heads, one per frame. |
@@ -930,9 +937,9 @@ void schedule_ptds(struct usb_hcd *hcd) | |||
930 | struct isp1760_hcd *priv; | 937 | struct isp1760_hcd *priv; |
931 | struct isp1760_qh *qh, *qh_next; | 938 | struct isp1760_qh *qh, *qh_next; |
932 | struct list_head *ep_queue; | 939 | struct list_head *ep_queue; |
933 | struct usb_host_endpoint *ep; | ||
934 | LIST_HEAD(urb_list); | 940 | LIST_HEAD(urb_list); |
935 | struct urb_listitem *urb_listitem, *urb_listitem_next; | 941 | struct urb_listitem *urb_listitem, *urb_listitem_next; |
942 | int i; | ||
936 | 943 | ||
937 | if (!hcd) { | 944 | if (!hcd) { |
938 | WARN_ON(1); | 945 | WARN_ON(1); |
@@ -944,28 +951,13 @@ void schedule_ptds(struct usb_hcd *hcd) | |||
944 | /* | 951 | /* |
945 | * check finished/retired xfers, transfer payloads, call urb_done() | 952 | * check finished/retired xfers, transfer payloads, call urb_done() |
946 | */ | 953 | */ |
947 | ep_queue = &priv->interruptqhs; | 954 | for (i = 0; i < QH_END; i++) { |
948 | while (ep_queue) { | 955 | ep_queue = &priv->qh_list[i]; |
949 | list_for_each_entry_safe(qh, qh_next, ep_queue, qh_list) { | 956 | list_for_each_entry_safe(qh, qh_next, ep_queue, qh_list) { |
950 | ep = list_entry(qh->qtd_list.next, struct isp1760_qtd, | ||
951 | qtd_list)->urb->ep; | ||
952 | collect_qtds(hcd, qh, &urb_list); | 957 | collect_qtds(hcd, qh, &urb_list); |
953 | if (list_empty(&qh->qtd_list)) { | 958 | if (list_empty(&qh->qtd_list)) |
954 | list_del(&qh->qh_list); | 959 | list_del(&qh->qh_list); |
955 | if (ep->hcpriv == NULL) { | ||
956 | /* Endpoint has been disabled, so we | ||
957 | can free the associated queue head. */ | ||
958 | qh_free(qh); | ||
959 | } | ||
960 | } | ||
961 | } | 960 | } |
962 | |||
963 | if (ep_queue == &priv->interruptqhs) | ||
964 | ep_queue = &priv->controlqhs; | ||
965 | else if (ep_queue == &priv->controlqhs) | ||
966 | ep_queue = &priv->bulkqhs; | ||
967 | else | ||
968 | ep_queue = NULL; | ||
969 | } | 961 | } |
970 | 962 | ||
971 | list_for_each_entry_safe(urb_listitem, urb_listitem_next, &urb_list, | 963 | list_for_each_entry_safe(urb_listitem, urb_listitem_next, &urb_list, |
@@ -998,17 +990,10 @@ void schedule_ptds(struct usb_hcd *hcd) | |||
998 | * | 990 | * |
999 | * I'm sure this scheme could be improved upon! | 991 | * I'm sure this scheme could be improved upon! |
1000 | */ | 992 | */ |
1001 | ep_queue = &priv->controlqhs; | 993 | for (i = 0; i < QH_END; i++) { |
1002 | while (ep_queue) { | 994 | ep_queue = &priv->qh_list[i]; |
1003 | list_for_each_entry_safe(qh, qh_next, ep_queue, qh_list) | 995 | list_for_each_entry_safe(qh, qh_next, ep_queue, qh_list) |
1004 | enqueue_qtds(hcd, qh); | 996 | enqueue_qtds(hcd, qh); |
1005 | |||
1006 | if (ep_queue == &priv->controlqhs) | ||
1007 | ep_queue = &priv->interruptqhs; | ||
1008 | else if (ep_queue == &priv->interruptqhs) | ||
1009 | ep_queue = &priv->bulkqhs; | ||
1010 | else | ||
1011 | ep_queue = NULL; | ||
1012 | } | 997 | } |
1013 | } | 998 | } |
1014 | 999 | ||
@@ -1543,16 +1528,16 @@ static int isp1760_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, | |||
1543 | 1528 | ||
1544 | switch (usb_pipetype(urb->pipe)) { | 1529 | switch (usb_pipetype(urb->pipe)) { |
1545 | case PIPE_CONTROL: | 1530 | case PIPE_CONTROL: |
1546 | ep_queue = &priv->controlqhs; | 1531 | ep_queue = &priv->qh_list[QH_CONTROL]; |
1547 | break; | 1532 | break; |
1548 | case PIPE_BULK: | 1533 | case PIPE_BULK: |
1549 | ep_queue = &priv->bulkqhs; | 1534 | ep_queue = &priv->qh_list[QH_BULK]; |
1550 | break; | 1535 | break; |
1551 | case PIPE_INTERRUPT: | 1536 | case PIPE_INTERRUPT: |
1552 | if (urb->interval < 0) | 1537 | if (urb->interval < 0) |
1553 | return -EINVAL; | 1538 | return -EINVAL; |
1554 | /* FIXME: Check bandwidth */ | 1539 | /* FIXME: Check bandwidth */ |
1555 | ep_queue = &priv->interruptqhs; | 1540 | ep_queue = &priv->qh_list[QH_INTERRUPT]; |
1556 | break; | 1541 | break; |
1557 | case PIPE_ISOCHRONOUS: | 1542 | case PIPE_ISOCHRONOUS: |
1558 | dev_err(hcd->self.controller, "%s: isochronous USB packets " | 1543 | dev_err(hcd->self.controller, "%s: isochronous USB packets " |
@@ -1714,8 +1699,8 @@ static void isp1760_endpoint_disable(struct usb_hcd *hcd, | |||
1714 | { | 1699 | { |
1715 | struct isp1760_hcd *priv = hcd_to_priv(hcd); | 1700 | struct isp1760_hcd *priv = hcd_to_priv(hcd); |
1716 | unsigned long spinflags; | 1701 | unsigned long spinflags; |
1717 | struct isp1760_qh *qh; | 1702 | struct isp1760_qh *qh, *qh_iter; |
1718 | struct isp1760_qtd *qtd; | 1703 | int i; |
1719 | 1704 | ||
1720 | spin_lock_irqsave(&priv->lock, spinflags); | 1705 | spin_lock_irqsave(&priv->lock, spinflags); |
1721 | 1706 | ||
@@ -1723,14 +1708,17 @@ static void isp1760_endpoint_disable(struct usb_hcd *hcd, | |||
1723 | if (!qh) | 1708 | if (!qh) |
1724 | goto out; | 1709 | goto out; |
1725 | 1710 | ||
1726 | list_for_each_entry(qtd, &qh->qtd_list, qtd_list) | 1711 | WARN_ON(!list_empty(&qh->qtd_list)); |
1727 | if (qtd->status != QTD_RETIRE) { | ||
1728 | dequeue_urb_from_qtd(hcd, qh, qtd); | ||
1729 | qtd->urb->status = -ECONNRESET; | ||
1730 | } | ||
1731 | 1712 | ||
1713 | for (i = 0; i < QH_END; i++) | ||
1714 | list_for_each_entry(qh_iter, &priv->qh_list[i], qh_list) | ||
1715 | if (qh_iter == qh) { | ||
1716 | list_del(&qh_iter->qh_list); | ||
1717 | i = QH_END; | ||
1718 | break; | ||
1719 | } | ||
1720 | qh_free(qh); | ||
1732 | ep->hcpriv = NULL; | 1721 | ep->hcpriv = NULL; |
1733 | /* Cannot free qh here since it will be parsed by schedule_ptds() */ | ||
1734 | 1722 | ||
1735 | schedule_ptds(hcd); | 1723 | schedule_ptds(hcd); |
1736 | 1724 | ||
diff --git a/drivers/usb/host/isp1760-if.c b/drivers/usb/host/isp1760-if.c index a7dc1e1d45f2..4592dc17a9f9 100644 --- a/drivers/usb/host/isp1760-if.c +++ b/drivers/usb/host/isp1760-if.c | |||
@@ -18,7 +18,7 @@ | |||
18 | 18 | ||
19 | #include "isp1760-hcd.h" | 19 | #include "isp1760-hcd.h" |
20 | 20 | ||
21 | #ifdef CONFIG_OF | 21 | #if defined(CONFIG_OF) && defined(CONFIG_OF_IRQ) |
22 | #include <linux/slab.h> | 22 | #include <linux/slab.h> |
23 | #include <linux/of.h> | 23 | #include <linux/of.h> |
24 | #include <linux/of_platform.h> | 24 | #include <linux/of_platform.h> |
@@ -31,7 +31,7 @@ | |||
31 | #include <linux/pci.h> | 31 | #include <linux/pci.h> |
32 | #endif | 32 | #endif |
33 | 33 | ||
34 | #ifdef CONFIG_OF | 34 | #if defined(CONFIG_OF) && defined(CONFIG_OF_IRQ) |
35 | struct isp1760 { | 35 | struct isp1760 { |
36 | struct usb_hcd *hcd; | 36 | struct usb_hcd *hcd; |
37 | int rst_gpio; | 37 | int rst_gpio; |
@@ -47,23 +47,27 @@ static int of_isp1760_probe(struct platform_device *dev) | |||
47 | int virq; | 47 | int virq; |
48 | resource_size_t res_len; | 48 | resource_size_t res_len; |
49 | int ret; | 49 | int ret; |
50 | const unsigned int *prop; | ||
51 | unsigned int devflags = 0; | 50 | unsigned int devflags = 0; |
52 | enum of_gpio_flags gpio_flags; | 51 | enum of_gpio_flags gpio_flags; |
52 | u32 bus_width = 0; | ||
53 | 53 | ||
54 | drvdata = kzalloc(sizeof(*drvdata), GFP_KERNEL); | 54 | drvdata = kzalloc(sizeof(*drvdata), GFP_KERNEL); |
55 | if (!drvdata) | 55 | if (!drvdata) |
56 | return -ENOMEM; | 56 | return -ENOMEM; |
57 | 57 | ||
58 | ret = of_address_to_resource(dp, 0, &memory); | 58 | ret = of_address_to_resource(dp, 0, &memory); |
59 | if (ret) | 59 | if (ret) { |
60 | return -ENXIO; | 60 | ret = -ENXIO; |
61 | goto free_data; | ||
62 | } | ||
61 | 63 | ||
62 | res_len = resource_size(&memory); | 64 | res_len = resource_size(&memory); |
63 | 65 | ||
64 | res = request_mem_region(memory.start, res_len, dev_name(&dev->dev)); | 66 | res = request_mem_region(memory.start, res_len, dev_name(&dev->dev)); |
65 | if (!res) | 67 | if (!res) { |
66 | return -EBUSY; | 68 | ret = -EBUSY; |
69 | goto free_data; | ||
70 | } | ||
67 | 71 | ||
68 | if (of_irq_map_one(dp, 0, &oirq)) { | 72 | if (of_irq_map_one(dp, 0, &oirq)) { |
69 | ret = -ENODEV; | 73 | ret = -ENODEV; |
@@ -77,8 +81,8 @@ static int of_isp1760_probe(struct platform_device *dev) | |||
77 | devflags |= ISP1760_FLAG_ISP1761; | 81 | devflags |= ISP1760_FLAG_ISP1761; |
78 | 82 | ||
79 | /* Some systems wire up only 16 of the 32 data lines */ | 83 | /* Some systems wire up only 16 of the 32 data lines */ |
80 | prop = of_get_property(dp, "bus-width", NULL); | 84 | of_property_read_u32(dp, "bus-width", &bus_width); |
81 | if (prop && *prop == 16) | 85 | if (bus_width == 16) |
82 | devflags |= ISP1760_FLAG_BUS_WIDTH_16; | 86 | devflags |= ISP1760_FLAG_BUS_WIDTH_16; |
83 | 87 | ||
84 | if (of_get_property(dp, "port1-otg", NULL) != NULL) | 88 | if (of_get_property(dp, "port1-otg", NULL) != NULL) |
@@ -125,6 +129,7 @@ free_gpio: | |||
125 | gpio_free(drvdata->rst_gpio); | 129 | gpio_free(drvdata->rst_gpio); |
126 | release_reg: | 130 | release_reg: |
127 | release_mem_region(memory.start, res_len); | 131 | release_mem_region(memory.start, res_len); |
132 | free_data: | ||
128 | kfree(drvdata); | 133 | kfree(drvdata); |
129 | return ret; | 134 | return ret; |
130 | } | 135 | } |
@@ -437,7 +442,7 @@ static int __init isp1760_init(void) | |||
437 | ret = platform_driver_register(&isp1760_plat_driver); | 442 | ret = platform_driver_register(&isp1760_plat_driver); |
438 | if (!ret) | 443 | if (!ret) |
439 | any_ret = 0; | 444 | any_ret = 0; |
440 | #ifdef CONFIG_OF | 445 | #if defined(CONFIG_OF) && defined(CONFIG_OF_IRQ) |
441 | ret = platform_driver_register(&isp1760_of_driver); | 446 | ret = platform_driver_register(&isp1760_of_driver); |
442 | if (!ret) | 447 | if (!ret) |
443 | any_ret = 0; | 448 | any_ret = 0; |
@@ -457,7 +462,7 @@ module_init(isp1760_init); | |||
457 | static void __exit isp1760_exit(void) | 462 | static void __exit isp1760_exit(void) |
458 | { | 463 | { |
459 | platform_driver_unregister(&isp1760_plat_driver); | 464 | platform_driver_unregister(&isp1760_plat_driver); |
460 | #ifdef CONFIG_OF | 465 | #if defined(CONFIG_OF) && defined(CONFIG_OF_IRQ) |
461 | platform_driver_unregister(&isp1760_of_driver); | 466 | platform_driver_unregister(&isp1760_of_driver); |
462 | #endif | 467 | #endif |
463 | #ifdef CONFIG_PCI | 468 | #ifdef CONFIG_PCI |
diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c index ba3a46b78b75..5df0b0e3392b 100644 --- a/drivers/usb/host/ohci-at91.c +++ b/drivers/usb/host/ohci-at91.c | |||
@@ -223,6 +223,9 @@ static void ohci_at91_usb_set_power(struct at91_usbh_data *pdata, int port, int | |||
223 | if (port < 0 || port >= 2) | 223 | if (port < 0 || port >= 2) |
224 | return; | 224 | return; |
225 | 225 | ||
226 | if (!gpio_is_valid(pdata->vbus_pin[port])) | ||
227 | return; | ||
228 | |||
226 | gpio_set_value(pdata->vbus_pin[port], !pdata->vbus_pin_inverted ^ enable); | 229 | gpio_set_value(pdata->vbus_pin[port], !pdata->vbus_pin_inverted ^ enable); |
227 | } | 230 | } |
228 | 231 | ||
@@ -231,6 +234,9 @@ static int ohci_at91_usb_get_power(struct at91_usbh_data *pdata, int port) | |||
231 | if (port < 0 || port >= 2) | 234 | if (port < 0 || port >= 2) |
232 | return -EINVAL; | 235 | return -EINVAL; |
233 | 236 | ||
237 | if (!gpio_is_valid(pdata->vbus_pin[port])) | ||
238 | return -EINVAL; | ||
239 | |||
234 | return gpio_get_value(pdata->vbus_pin[port]) ^ !pdata->vbus_pin_inverted; | 240 | return gpio_get_value(pdata->vbus_pin[port]) ^ !pdata->vbus_pin_inverted; |
235 | } | 241 | } |
236 | 242 | ||
@@ -459,7 +465,7 @@ static int ohci_hcd_at91_drv_probe(struct platform_device *pdev) | |||
459 | 465 | ||
460 | if (pdata) { | 466 | if (pdata) { |
461 | for (i = 0; i < ARRAY_SIZE(pdata->vbus_pin); i++) { | 467 | for (i = 0; i < ARRAY_SIZE(pdata->vbus_pin); i++) { |
462 | if (pdata->vbus_pin[i] <= 0) | 468 | if (!gpio_is_valid(pdata->vbus_pin[i])) |
463 | continue; | 469 | continue; |
464 | gpio_request(pdata->vbus_pin[i], "ohci_vbus"); | 470 | gpio_request(pdata->vbus_pin[i], "ohci_vbus"); |
465 | ohci_at91_usb_set_power(pdata, i, 1); | 471 | ohci_at91_usb_set_power(pdata, i, 1); |
@@ -468,7 +474,7 @@ static int ohci_hcd_at91_drv_probe(struct platform_device *pdev) | |||
468 | for (i = 0; i < ARRAY_SIZE(pdata->overcurrent_pin); i++) { | 474 | for (i = 0; i < ARRAY_SIZE(pdata->overcurrent_pin); i++) { |
469 | int ret; | 475 | int ret; |
470 | 476 | ||
471 | if (pdata->overcurrent_pin[i] <= 0) | 477 | if (!gpio_is_valid(pdata->overcurrent_pin[i])) |
472 | continue; | 478 | continue; |
473 | gpio_request(pdata->overcurrent_pin[i], "ohci_overcurrent"); | 479 | gpio_request(pdata->overcurrent_pin[i], "ohci_overcurrent"); |
474 | 480 | ||
@@ -493,14 +499,14 @@ static int ohci_hcd_at91_drv_remove(struct platform_device *pdev) | |||
493 | 499 | ||
494 | if (pdata) { | 500 | if (pdata) { |
495 | for (i = 0; i < ARRAY_SIZE(pdata->vbus_pin); i++) { | 501 | for (i = 0; i < ARRAY_SIZE(pdata->vbus_pin); i++) { |
496 | if (pdata->vbus_pin[i] <= 0) | 502 | if (!gpio_is_valid(pdata->vbus_pin[i])) |
497 | continue; | 503 | continue; |
498 | ohci_at91_usb_set_power(pdata, i, 0); | 504 | ohci_at91_usb_set_power(pdata, i, 0); |
499 | gpio_free(pdata->vbus_pin[i]); | 505 | gpio_free(pdata->vbus_pin[i]); |
500 | } | 506 | } |
501 | 507 | ||
502 | for (i = 0; i < ARRAY_SIZE(pdata->overcurrent_pin); i++) { | 508 | for (i = 0; i < ARRAY_SIZE(pdata->overcurrent_pin); i++) { |
503 | if (pdata->overcurrent_pin[i] <= 0) | 509 | if (!gpio_is_valid(pdata->overcurrent_pin[i])) |
504 | continue; | 510 | continue; |
505 | free_irq(gpio_to_irq(pdata->overcurrent_pin[i]), pdev); | 511 | free_irq(gpio_to_irq(pdata->overcurrent_pin[i]), pdev); |
506 | gpio_free(pdata->overcurrent_pin[i]); | 512 | gpio_free(pdata->overcurrent_pin[i]); |
diff --git a/drivers/usb/host/ohci-au1xxx.c b/drivers/usb/host/ohci-au1xxx.c index 9b66df8278f3..4ea63b2cac42 100644 --- a/drivers/usb/host/ohci-au1xxx.c +++ b/drivers/usb/host/ohci-au1xxx.c | |||
@@ -89,7 +89,7 @@ static const struct hc_driver ohci_au1xxx_hc_driver = { | |||
89 | 89 | ||
90 | static int ohci_hcd_au1xxx_drv_probe(struct platform_device *pdev) | 90 | static int ohci_hcd_au1xxx_drv_probe(struct platform_device *pdev) |
91 | { | 91 | { |
92 | int ret; | 92 | int ret, unit; |
93 | struct usb_hcd *hcd; | 93 | struct usb_hcd *hcd; |
94 | 94 | ||
95 | if (usb_disabled()) | 95 | if (usb_disabled()) |
@@ -120,7 +120,9 @@ static int ohci_hcd_au1xxx_drv_probe(struct platform_device *pdev) | |||
120 | goto err2; | 120 | goto err2; |
121 | } | 121 | } |
122 | 122 | ||
123 | if (alchemy_usb_control(ALCHEMY_USB_OHCI0, 1)) { | 123 | unit = (hcd->rsrc_start == AU1300_USB_OHCI1_PHYS_ADDR) ? |
124 | ALCHEMY_USB_OHCI1 : ALCHEMY_USB_OHCI0; | ||
125 | if (alchemy_usb_control(unit, 1)) { | ||
124 | printk(KERN_INFO "%s: controller init failed!\n", pdev->name); | 126 | printk(KERN_INFO "%s: controller init failed!\n", pdev->name); |
125 | ret = -ENODEV; | 127 | ret = -ENODEV; |
126 | goto err3; | 128 | goto err3; |
@@ -135,7 +137,7 @@ static int ohci_hcd_au1xxx_drv_probe(struct platform_device *pdev) | |||
135 | return ret; | 137 | return ret; |
136 | } | 138 | } |
137 | 139 | ||
138 | alchemy_usb_control(ALCHEMY_USB_OHCI0, 0); | 140 | alchemy_usb_control(unit, 0); |
139 | err3: | 141 | err3: |
140 | iounmap(hcd->regs); | 142 | iounmap(hcd->regs); |
141 | err2: | 143 | err2: |
@@ -148,9 +150,12 @@ err1: | |||
148 | static int ohci_hcd_au1xxx_drv_remove(struct platform_device *pdev) | 150 | static int ohci_hcd_au1xxx_drv_remove(struct platform_device *pdev) |
149 | { | 151 | { |
150 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | 152 | struct usb_hcd *hcd = platform_get_drvdata(pdev); |
153 | int unit; | ||
151 | 154 | ||
155 | unit = (hcd->rsrc_start == AU1300_USB_OHCI1_PHYS_ADDR) ? | ||
156 | ALCHEMY_USB_OHCI1 : ALCHEMY_USB_OHCI0; | ||
152 | usb_remove_hcd(hcd); | 157 | usb_remove_hcd(hcd); |
153 | alchemy_usb_control(ALCHEMY_USB_OHCI0, 0); | 158 | alchemy_usb_control(unit, 0); |
154 | iounmap(hcd->regs); | 159 | iounmap(hcd->regs); |
155 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | 160 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); |
156 | usb_put_hcd(hcd); | 161 | usb_put_hcd(hcd); |
@@ -173,12 +178,9 @@ static int ohci_hcd_au1xxx_drv_suspend(struct device *dev) | |||
173 | * mark HW unaccessible, bail out if RH has been resumed. Use | 178 | * mark HW unaccessible, bail out if RH has been resumed. Use |
174 | * the spinlock to properly synchronize with possible pending | 179 | * the spinlock to properly synchronize with possible pending |
175 | * RH suspend or resume activity. | 180 | * RH suspend or resume activity. |
176 | * | ||
177 | * This is still racy as hcd->state is manipulated outside of | ||
178 | * any locks =P But that will be a different fix. | ||
179 | */ | 181 | */ |
180 | spin_lock_irqsave(&ohci->lock, flags); | 182 | spin_lock_irqsave(&ohci->lock, flags); |
181 | if (hcd->state != HC_STATE_SUSPENDED) { | 183 | if (ohci->rh_state != OHCI_RH_SUSPENDED) { |
182 | rc = -EINVAL; | 184 | rc = -EINVAL; |
183 | goto bail; | 185 | goto bail; |
184 | } | 186 | } |
diff --git a/drivers/usb/host/ohci-dbg.c b/drivers/usb/host/ohci-dbg.c index d7d34492934a..5179fcd73d8a 100644 --- a/drivers/usb/host/ohci-dbg.c +++ b/drivers/usb/host/ohci-dbg.c | |||
@@ -127,6 +127,19 @@ static char *hcfs2string (int state) | |||
127 | return "?"; | 127 | return "?"; |
128 | } | 128 | } |
129 | 129 | ||
130 | static const char *rh_state_string(struct ohci_hcd *ohci) | ||
131 | { | ||
132 | switch (ohci->rh_state) { | ||
133 | case OHCI_RH_HALTED: | ||
134 | return "halted"; | ||
135 | case OHCI_RH_SUSPENDED: | ||
136 | return "suspended"; | ||
137 | case OHCI_RH_RUNNING: | ||
138 | return "running"; | ||
139 | } | ||
140 | return "?"; | ||
141 | } | ||
142 | |||
130 | // dump control and status registers | 143 | // dump control and status registers |
131 | static void | 144 | static void |
132 | ohci_dump_status (struct ohci_hcd *controller, char **next, unsigned *size) | 145 | ohci_dump_status (struct ohci_hcd *controller, char **next, unsigned *size) |
@@ -136,9 +149,10 @@ ohci_dump_status (struct ohci_hcd *controller, char **next, unsigned *size) | |||
136 | 149 | ||
137 | temp = ohci_readl (controller, ®s->revision) & 0xff; | 150 | temp = ohci_readl (controller, ®s->revision) & 0xff; |
138 | ohci_dbg_sw (controller, next, size, | 151 | ohci_dbg_sw (controller, next, size, |
139 | "OHCI %d.%d, %s legacy support registers\n", | 152 | "OHCI %d.%d, %s legacy support registers, rh state %s\n", |
140 | 0x03 & (temp >> 4), (temp & 0x0f), | 153 | 0x03 & (temp >> 4), (temp & 0x0f), |
141 | (temp & 0x0100) ? "with" : "NO"); | 154 | (temp & 0x0100) ? "with" : "NO", |
155 | rh_state_string(controller)); | ||
142 | 156 | ||
143 | temp = ohci_readl (controller, ®s->control); | 157 | temp = ohci_readl (controller, ®s->control); |
144 | ohci_dbg_sw (controller, next, size, | 158 | ohci_dbg_sw (controller, next, size, |
diff --git a/drivers/usb/host/ohci-ep93xx.c b/drivers/usb/host/ohci-ep93xx.c index dc45d489d00e..3d63574d2c7e 100644 --- a/drivers/usb/host/ohci-ep93xx.c +++ b/drivers/usb/host/ohci-ep93xx.c | |||
@@ -179,8 +179,6 @@ static int ohci_hcd_ep93xx_drv_suspend(struct platform_device *pdev, pm_message_ | |||
179 | ohci->next_statechange = jiffies; | 179 | ohci->next_statechange = jiffies; |
180 | 180 | ||
181 | ep93xx_stop_hc(&pdev->dev); | 181 | ep93xx_stop_hc(&pdev->dev); |
182 | hcd->state = HC_STATE_SUSPENDED; | ||
183 | |||
184 | return 0; | 182 | return 0; |
185 | } | 183 | } |
186 | 184 | ||
diff --git a/drivers/usb/host/ohci-exynos.c b/drivers/usb/host/ohci-exynos.c new file mode 100644 index 000000000000..55aa35aa3d7b --- /dev/null +++ b/drivers/usb/host/ohci-exynos.c | |||
@@ -0,0 +1,274 @@ | |||
1 | /* | ||
2 | * SAMSUNG EXYNOS USB HOST OHCI Controller | ||
3 | * | ||
4 | * Copyright (C) 2011 Samsung Electronics Co.Ltd | ||
5 | * Author: Jingoo Han <jg1.han@samsung.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify it | ||
8 | * under the terms of the GNU General Public License as published by the | ||
9 | * Free Software Foundation; either version 2 of the License, or (at your | ||
10 | * option) any later version. | ||
11 | * | ||
12 | */ | ||
13 | |||
14 | #include <linux/clk.h> | ||
15 | #include <linux/platform_device.h> | ||
16 | #include <mach/ohci.h> | ||
17 | #include <plat/usb-phy.h> | ||
18 | |||
19 | struct exynos_ohci_hcd { | ||
20 | struct device *dev; | ||
21 | struct usb_hcd *hcd; | ||
22 | struct clk *clk; | ||
23 | }; | ||
24 | |||
25 | static int ohci_exynos_start(struct usb_hcd *hcd) | ||
26 | { | ||
27 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); | ||
28 | int ret; | ||
29 | |||
30 | ohci_dbg(ohci, "ohci_exynos_start, ohci:%p", ohci); | ||
31 | |||
32 | ret = ohci_init(ohci); | ||
33 | if (ret < 0) | ||
34 | return ret; | ||
35 | |||
36 | ret = ohci_run(ohci); | ||
37 | if (ret < 0) { | ||
38 | err("can't start %s", hcd->self.bus_name); | ||
39 | ohci_stop(hcd); | ||
40 | return ret; | ||
41 | } | ||
42 | |||
43 | return 0; | ||
44 | } | ||
45 | |||
46 | static const struct hc_driver exynos_ohci_hc_driver = { | ||
47 | .description = hcd_name, | ||
48 | .product_desc = "EXYNOS OHCI Host Controller", | ||
49 | .hcd_priv_size = sizeof(struct ohci_hcd), | ||
50 | |||
51 | .irq = ohci_irq, | ||
52 | .flags = HCD_MEMORY|HCD_USB11, | ||
53 | |||
54 | .start = ohci_exynos_start, | ||
55 | .stop = ohci_stop, | ||
56 | .shutdown = ohci_shutdown, | ||
57 | |||
58 | .get_frame_number = ohci_get_frame, | ||
59 | |||
60 | .urb_enqueue = ohci_urb_enqueue, | ||
61 | .urb_dequeue = ohci_urb_dequeue, | ||
62 | .endpoint_disable = ohci_endpoint_disable, | ||
63 | |||
64 | .hub_status_data = ohci_hub_status_data, | ||
65 | .hub_control = ohci_hub_control, | ||
66 | #ifdef CONFIG_PM | ||
67 | .bus_suspend = ohci_bus_suspend, | ||
68 | .bus_resume = ohci_bus_resume, | ||
69 | #endif | ||
70 | .start_port_reset = ohci_start_port_reset, | ||
71 | }; | ||
72 | |||
73 | static int __devinit exynos_ohci_probe(struct platform_device *pdev) | ||
74 | { | ||
75 | struct exynos4_ohci_platdata *pdata; | ||
76 | struct exynos_ohci_hcd *exynos_ohci; | ||
77 | struct usb_hcd *hcd; | ||
78 | struct ohci_hcd *ohci; | ||
79 | struct resource *res; | ||
80 | int irq; | ||
81 | int err; | ||
82 | |||
83 | pdata = pdev->dev.platform_data; | ||
84 | if (!pdata) { | ||
85 | dev_err(&pdev->dev, "No platform data defined\n"); | ||
86 | return -EINVAL; | ||
87 | } | ||
88 | |||
89 | exynos_ohci = kzalloc(sizeof(struct exynos_ohci_hcd), GFP_KERNEL); | ||
90 | if (!exynos_ohci) | ||
91 | return -ENOMEM; | ||
92 | |||
93 | exynos_ohci->dev = &pdev->dev; | ||
94 | |||
95 | hcd = usb_create_hcd(&exynos_ohci_hc_driver, &pdev->dev, | ||
96 | dev_name(&pdev->dev)); | ||
97 | if (!hcd) { | ||
98 | dev_err(&pdev->dev, "Unable to create HCD\n"); | ||
99 | err = -ENOMEM; | ||
100 | goto fail_hcd; | ||
101 | } | ||
102 | |||
103 | exynos_ohci->hcd = hcd; | ||
104 | exynos_ohci->clk = clk_get(&pdev->dev, "usbhost"); | ||
105 | |||
106 | if (IS_ERR(exynos_ohci->clk)) { | ||
107 | dev_err(&pdev->dev, "Failed to get usbhost clock\n"); | ||
108 | err = PTR_ERR(exynos_ohci->clk); | ||
109 | goto fail_clk; | ||
110 | } | ||
111 | |||
112 | err = clk_enable(exynos_ohci->clk); | ||
113 | if (err) | ||
114 | goto fail_clken; | ||
115 | |||
116 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
117 | if (!res) { | ||
118 | dev_err(&pdev->dev, "Failed to get I/O memory\n"); | ||
119 | err = -ENXIO; | ||
120 | goto fail_io; | ||
121 | } | ||
122 | |||
123 | hcd->rsrc_start = res->start; | ||
124 | hcd->rsrc_len = resource_size(res); | ||
125 | hcd->regs = ioremap(res->start, resource_size(res)); | ||
126 | if (!hcd->regs) { | ||
127 | dev_err(&pdev->dev, "Failed to remap I/O memory\n"); | ||
128 | err = -ENOMEM; | ||
129 | goto fail_io; | ||
130 | } | ||
131 | |||
132 | irq = platform_get_irq(pdev, 0); | ||
133 | if (!irq) { | ||
134 | dev_err(&pdev->dev, "Failed to get IRQ\n"); | ||
135 | err = -ENODEV; | ||
136 | goto fail; | ||
137 | } | ||
138 | |||
139 | if (pdata->phy_init) | ||
140 | pdata->phy_init(pdev, S5P_USB_PHY_HOST); | ||
141 | |||
142 | ohci = hcd_to_ohci(hcd); | ||
143 | ohci_hcd_init(ohci); | ||
144 | |||
145 | err = usb_add_hcd(hcd, irq, IRQF_SHARED); | ||
146 | if (err) { | ||
147 | dev_err(&pdev->dev, "Failed to add USB HCD\n"); | ||
148 | goto fail; | ||
149 | } | ||
150 | |||
151 | platform_set_drvdata(pdev, exynos_ohci); | ||
152 | |||
153 | return 0; | ||
154 | |||
155 | fail: | ||
156 | iounmap(hcd->regs); | ||
157 | fail_io: | ||
158 | clk_disable(exynos_ohci->clk); | ||
159 | fail_clken: | ||
160 | clk_put(exynos_ohci->clk); | ||
161 | fail_clk: | ||
162 | usb_put_hcd(hcd); | ||
163 | fail_hcd: | ||
164 | kfree(exynos_ohci); | ||
165 | return err; | ||
166 | } | ||
167 | |||
168 | static int __devexit exynos_ohci_remove(struct platform_device *pdev) | ||
169 | { | ||
170 | struct exynos4_ohci_platdata *pdata = pdev->dev.platform_data; | ||
171 | struct exynos_ohci_hcd *exynos_ohci = platform_get_drvdata(pdev); | ||
172 | struct usb_hcd *hcd = exynos_ohci->hcd; | ||
173 | |||
174 | usb_remove_hcd(hcd); | ||
175 | |||
176 | if (pdata && pdata->phy_exit) | ||
177 | pdata->phy_exit(pdev, S5P_USB_PHY_HOST); | ||
178 | |||
179 | iounmap(hcd->regs); | ||
180 | |||
181 | clk_disable(exynos_ohci->clk); | ||
182 | clk_put(exynos_ohci->clk); | ||
183 | |||
184 | usb_put_hcd(hcd); | ||
185 | kfree(exynos_ohci); | ||
186 | |||
187 | return 0; | ||
188 | } | ||
189 | |||
190 | static void exynos_ohci_shutdown(struct platform_device *pdev) | ||
191 | { | ||
192 | struct exynos_ohci_hcd *exynos_ohci = platform_get_drvdata(pdev); | ||
193 | struct usb_hcd *hcd = exynos_ohci->hcd; | ||
194 | |||
195 | if (hcd->driver->shutdown) | ||
196 | hcd->driver->shutdown(hcd); | ||
197 | } | ||
198 | |||
199 | #ifdef CONFIG_PM | ||
200 | static int exynos_ohci_suspend(struct device *dev) | ||
201 | { | ||
202 | struct exynos_ohci_hcd *exynos_ohci = dev_get_drvdata(dev); | ||
203 | struct usb_hcd *hcd = exynos_ohci->hcd; | ||
204 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); | ||
205 | struct platform_device *pdev = to_platform_device(dev); | ||
206 | struct exynos4_ohci_platdata *pdata = pdev->dev.platform_data; | ||
207 | unsigned long flags; | ||
208 | int rc = 0; | ||
209 | |||
210 | /* | ||
211 | * Root hub was already suspended. Disable irq emission and | ||
212 | * mark HW unaccessible, bail out if RH has been resumed. Use | ||
213 | * the spinlock to properly synchronize with possible pending | ||
214 | * RH suspend or resume activity. | ||
215 | * | ||
216 | * This is still racy as hcd->state is manipulated outside of | ||
217 | * any locks =P But that will be a different fix. | ||
218 | */ | ||
219 | spin_lock_irqsave(&ohci->lock, flags); | ||
220 | if (hcd->state != HC_STATE_SUSPENDED && hcd->state != HC_STATE_HALT) { | ||
221 | rc = -EINVAL; | ||
222 | goto fail; | ||
223 | } | ||
224 | |||
225 | clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); | ||
226 | |||
227 | if (pdata && pdata->phy_exit) | ||
228 | pdata->phy_exit(pdev, S5P_USB_PHY_HOST); | ||
229 | fail: | ||
230 | spin_unlock_irqrestore(&ohci->lock, flags); | ||
231 | |||
232 | return rc; | ||
233 | } | ||
234 | |||
235 | static int exynos_ohci_resume(struct device *dev) | ||
236 | { | ||
237 | struct exynos_ohci_hcd *exynos_ohci = dev_get_drvdata(dev); | ||
238 | struct usb_hcd *hcd = exynos_ohci->hcd; | ||
239 | struct platform_device *pdev = to_platform_device(dev); | ||
240 | struct exynos4_ohci_platdata *pdata = pdev->dev.platform_data; | ||
241 | |||
242 | if (pdata && pdata->phy_init) | ||
243 | pdata->phy_init(pdev, S5P_USB_PHY_HOST); | ||
244 | |||
245 | /* Mark hardware accessible again as we are out of D3 state by now */ | ||
246 | set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); | ||
247 | |||
248 | ohci_finish_controller_resume(hcd); | ||
249 | |||
250 | return 0; | ||
251 | } | ||
252 | #else | ||
253 | #define exynos_ohci_suspend NULL | ||
254 | #define exynos_ohci_resume NULL | ||
255 | #endif | ||
256 | |||
257 | static const struct dev_pm_ops exynos_ohci_pm_ops = { | ||
258 | .suspend = exynos_ohci_suspend, | ||
259 | .resume = exynos_ohci_resume, | ||
260 | }; | ||
261 | |||
262 | static struct platform_driver exynos_ohci_driver = { | ||
263 | .probe = exynos_ohci_probe, | ||
264 | .remove = __devexit_p(exynos_ohci_remove), | ||
265 | .shutdown = exynos_ohci_shutdown, | ||
266 | .driver = { | ||
267 | .name = "exynos-ohci", | ||
268 | .owner = THIS_MODULE, | ||
269 | .pm = &exynos_ohci_pm_ops, | ||
270 | } | ||
271 | }; | ||
272 | |||
273 | MODULE_ALIAS("platform:exynos-ohci"); | ||
274 | MODULE_AUTHOR("Jingoo Han <jg1.han@samsung.com>"); | ||
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index 34efd479e068..34b9edd86651 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c | |||
@@ -115,13 +115,13 @@ static inline void sb800_prefetch(struct ohci_hcd *ohci, int on) | |||
115 | 115 | ||
116 | 116 | ||
117 | /* Some boards misreport power switching/overcurrent */ | 117 | /* Some boards misreport power switching/overcurrent */ |
118 | static int distrust_firmware = 1; | 118 | static bool distrust_firmware = 1; |
119 | module_param (distrust_firmware, bool, 0); | 119 | module_param (distrust_firmware, bool, 0); |
120 | MODULE_PARM_DESC (distrust_firmware, | 120 | MODULE_PARM_DESC (distrust_firmware, |
121 | "true to distrust firmware power/overcurrent setup"); | 121 | "true to distrust firmware power/overcurrent setup"); |
122 | 122 | ||
123 | /* Some boards leave IR set wrongly, since they fail BIOS/SMM handshakes */ | 123 | /* Some boards leave IR set wrongly, since they fail BIOS/SMM handshakes */ |
124 | static int no_handshake = 0; | 124 | static bool no_handshake = 0; |
125 | module_param (no_handshake, bool, 0); | 125 | module_param (no_handshake, bool, 0); |
126 | MODULE_PARM_DESC (no_handshake, "true (not default) disables BIOS handshake"); | 126 | MODULE_PARM_DESC (no_handshake, "true (not default) disables BIOS handshake"); |
127 | 127 | ||
@@ -209,7 +209,7 @@ static int ohci_urb_enqueue ( | |||
209 | retval = -ENODEV; | 209 | retval = -ENODEV; |
210 | goto fail; | 210 | goto fail; |
211 | } | 211 | } |
212 | if (!HC_IS_RUNNING(hcd->state)) { | 212 | if (ohci->rh_state != OHCI_RH_RUNNING) { |
213 | retval = -ENODEV; | 213 | retval = -ENODEV; |
214 | goto fail; | 214 | goto fail; |
215 | } | 215 | } |
@@ -274,7 +274,7 @@ static int ohci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) | |||
274 | rc = usb_hcd_check_unlink_urb(hcd, urb, status); | 274 | rc = usb_hcd_check_unlink_urb(hcd, urb, status); |
275 | if (rc) { | 275 | if (rc) { |
276 | ; /* Do nothing */ | 276 | ; /* Do nothing */ |
277 | } else if (HC_IS_RUNNING(hcd->state)) { | 277 | } else if (ohci->rh_state == OHCI_RH_RUNNING) { |
278 | urb_priv_t *urb_priv; | 278 | urb_priv_t *urb_priv; |
279 | 279 | ||
280 | /* Unless an IRQ completed the unlink while it was being | 280 | /* Unless an IRQ completed the unlink while it was being |
@@ -321,7 +321,7 @@ ohci_endpoint_disable (struct usb_hcd *hcd, struct usb_host_endpoint *ep) | |||
321 | rescan: | 321 | rescan: |
322 | spin_lock_irqsave (&ohci->lock, flags); | 322 | spin_lock_irqsave (&ohci->lock, flags); |
323 | 323 | ||
324 | if (!HC_IS_RUNNING (hcd->state)) { | 324 | if (ohci->rh_state != OHCI_RH_RUNNING) { |
325 | sanitize: | 325 | sanitize: |
326 | ed->state = ED_IDLE; | 326 | ed->state = ED_IDLE; |
327 | if (quirk_zfmicro(ohci) && ed->type == PIPE_INTERRUPT) | 327 | if (quirk_zfmicro(ohci) && ed->type == PIPE_INTERRUPT) |
@@ -377,6 +377,7 @@ static void ohci_usb_reset (struct ohci_hcd *ohci) | |||
377 | ohci->hc_control = ohci_readl (ohci, &ohci->regs->control); | 377 | ohci->hc_control = ohci_readl (ohci, &ohci->regs->control); |
378 | ohci->hc_control &= OHCI_CTRL_RWC; | 378 | ohci->hc_control &= OHCI_CTRL_RWC; |
379 | ohci_writel (ohci, ohci->hc_control, &ohci->regs->control); | 379 | ohci_writel (ohci, ohci->hc_control, &ohci->regs->control); |
380 | ohci->rh_state = OHCI_RH_HALTED; | ||
380 | } | 381 | } |
381 | 382 | ||
382 | /* ohci_shutdown forcibly disables IRQs and DMA, helping kexec and | 383 | /* ohci_shutdown forcibly disables IRQs and DMA, helping kexec and |
@@ -389,17 +390,14 @@ ohci_shutdown (struct usb_hcd *hcd) | |||
389 | struct ohci_hcd *ohci; | 390 | struct ohci_hcd *ohci; |
390 | 391 | ||
391 | ohci = hcd_to_ohci (hcd); | 392 | ohci = hcd_to_ohci (hcd); |
392 | ohci_writel (ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable); | 393 | ohci_writel(ohci, (u32) ~0, &ohci->regs->intrdisable); |
393 | ohci->hc_control = ohci_readl(ohci, &ohci->regs->control); | ||
394 | 394 | ||
395 | /* If the SHUTDOWN quirk is set, don't put the controller in RESET */ | 395 | /* Software reset, after which the controller goes into SUSPEND */ |
396 | ohci->hc_control &= (ohci->flags & OHCI_QUIRK_SHUTDOWN ? | 396 | ohci_writel(ohci, OHCI_HCR, &ohci->regs->cmdstatus); |
397 | OHCI_CTRL_RWC | OHCI_CTRL_HCFS : | 397 | ohci_readl(ohci, &ohci->regs->cmdstatus); /* flush the writes */ |
398 | OHCI_CTRL_RWC); | 398 | udelay(10); |
399 | ohci_writel(ohci, ohci->hc_control, &ohci->regs->control); | ||
400 | 399 | ||
401 | /* flush the writes */ | 400 | ohci_writel(ohci, ohci->fminterval, &ohci->regs->fminterval); |
402 | (void) ohci_readl (ohci, &ohci->regs->control); | ||
403 | } | 401 | } |
404 | 402 | ||
405 | static int check_ed(struct ohci_hcd *ohci, struct ed *ed) | 403 | static int check_ed(struct ohci_hcd *ohci, struct ed *ed) |
@@ -503,7 +501,7 @@ static int ohci_init (struct ohci_hcd *ohci) | |||
503 | if (distrust_firmware) | 501 | if (distrust_firmware) |
504 | ohci->flags |= OHCI_QUIRK_HUB_POWER; | 502 | ohci->flags |= OHCI_QUIRK_HUB_POWER; |
505 | 503 | ||
506 | disable (ohci); | 504 | ohci->rh_state = OHCI_RH_HALTED; |
507 | ohci->regs = hcd->regs; | 505 | ohci->regs = hcd->regs; |
508 | 506 | ||
509 | /* REVISIT this BIOS handshake is now moved into PCI "quirks", and | 507 | /* REVISIT this BIOS handshake is now moved into PCI "quirks", and |
@@ -578,7 +576,7 @@ static int ohci_run (struct ohci_hcd *ohci) | |||
578 | int first = ohci->fminterval == 0; | 576 | int first = ohci->fminterval == 0; |
579 | struct usb_hcd *hcd = ohci_to_hcd(ohci); | 577 | struct usb_hcd *hcd = ohci_to_hcd(ohci); |
580 | 578 | ||
581 | disable (ohci); | 579 | ohci->rh_state = OHCI_RH_HALTED; |
582 | 580 | ||
583 | /* boot firmware should have set this up (5.1.1.3.1) */ | 581 | /* boot firmware should have set this up (5.1.1.3.1) */ |
584 | if (first) { | 582 | if (first) { |
@@ -691,7 +689,7 @@ retry: | |||
691 | ohci->hc_control &= OHCI_CTRL_RWC; | 689 | ohci->hc_control &= OHCI_CTRL_RWC; |
692 | ohci->hc_control |= OHCI_CONTROL_INIT | OHCI_USB_OPER; | 690 | ohci->hc_control |= OHCI_CONTROL_INIT | OHCI_USB_OPER; |
693 | ohci_writel (ohci, ohci->hc_control, &ohci->regs->control); | 691 | ohci_writel (ohci, ohci->hc_control, &ohci->regs->control); |
694 | hcd->state = HC_STATE_RUNNING; | 692 | ohci->rh_state = OHCI_RH_RUNNING; |
695 | 693 | ||
696 | /* wake on ConnectStatusChange, matching external hubs */ | 694 | /* wake on ConnectStatusChange, matching external hubs */ |
697 | ohci_writel (ohci, RH_HS_DRWE, &ohci->regs->roothub.status); | 695 | ohci_writel (ohci, RH_HS_DRWE, &ohci->regs->roothub.status); |
@@ -728,7 +726,6 @@ retry: | |||
728 | 726 | ||
729 | // POTPGT delay is bits 24-31, in 2 ms units. | 727 | // POTPGT delay is bits 24-31, in 2 ms units. |
730 | mdelay ((val >> 23) & 0x1fe); | 728 | mdelay ((val >> 23) & 0x1fe); |
731 | hcd->state = HC_STATE_RUNNING; | ||
732 | 729 | ||
733 | if (quirk_zfmicro(ohci)) { | 730 | if (quirk_zfmicro(ohci)) { |
734 | /* Create timer to watch for bad queue state on ZF Micro */ | 731 | /* Create timer to watch for bad queue state on ZF Micro */ |
@@ -764,7 +761,7 @@ static irqreturn_t ohci_irq (struct usb_hcd *hcd) | |||
764 | * of dead, unclocked, or unplugged (CardBus...) devices | 761 | * of dead, unclocked, or unplugged (CardBus...) devices |
765 | */ | 762 | */ |
766 | if (ints == ~(u32)0) { | 763 | if (ints == ~(u32)0) { |
767 | disable (ohci); | 764 | ohci->rh_state = OHCI_RH_HALTED; |
768 | ohci_dbg (ohci, "device removed!\n"); | 765 | ohci_dbg (ohci, "device removed!\n"); |
769 | usb_hc_died(hcd); | 766 | usb_hc_died(hcd); |
770 | return IRQ_HANDLED; | 767 | return IRQ_HANDLED; |
@@ -774,7 +771,7 @@ static irqreturn_t ohci_irq (struct usb_hcd *hcd) | |||
774 | ints &= ohci_readl(ohci, ®s->intrenable); | 771 | ints &= ohci_readl(ohci, ®s->intrenable); |
775 | 772 | ||
776 | /* interrupt for some other device? */ | 773 | /* interrupt for some other device? */ |
777 | if (ints == 0 || unlikely(hcd->state == HC_STATE_HALT)) | 774 | if (ints == 0 || unlikely(ohci->rh_state == OHCI_RH_HALTED)) |
778 | return IRQ_NOTMINE; | 775 | return IRQ_NOTMINE; |
779 | 776 | ||
780 | if (ints & OHCI_INTR_UE) { | 777 | if (ints & OHCI_INTR_UE) { |
@@ -789,8 +786,8 @@ static irqreturn_t ohci_irq (struct usb_hcd *hcd) | |||
789 | 786 | ||
790 | schedule_work (&ohci->nec_work); | 787 | schedule_work (&ohci->nec_work); |
791 | } else { | 788 | } else { |
792 | disable (ohci); | ||
793 | ohci_err (ohci, "OHCI Unrecoverable Error, disabled\n"); | 789 | ohci_err (ohci, "OHCI Unrecoverable Error, disabled\n"); |
790 | ohci->rh_state = OHCI_RH_HALTED; | ||
794 | usb_hc_died(hcd); | 791 | usb_hc_died(hcd); |
795 | } | 792 | } |
796 | 793 | ||
@@ -874,11 +871,11 @@ static irqreturn_t ohci_irq (struct usb_hcd *hcd) | |||
874 | if ((ints & OHCI_INTR_SF) != 0 | 871 | if ((ints & OHCI_INTR_SF) != 0 |
875 | && !ohci->ed_rm_list | 872 | && !ohci->ed_rm_list |
876 | && !ohci->ed_to_check | 873 | && !ohci->ed_to_check |
877 | && HC_IS_RUNNING(hcd->state)) | 874 | && ohci->rh_state == OHCI_RH_RUNNING) |
878 | ohci_writel (ohci, OHCI_INTR_SF, ®s->intrdisable); | 875 | ohci_writel (ohci, OHCI_INTR_SF, ®s->intrdisable); |
879 | spin_unlock (&ohci->lock); | 876 | spin_unlock (&ohci->lock); |
880 | 877 | ||
881 | if (HC_IS_RUNNING(hcd->state)) { | 878 | if (ohci->rh_state == OHCI_RH_RUNNING) { |
882 | ohci_writel (ohci, ints, ®s->intrstatus); | 879 | ohci_writel (ohci, ints, ®s->intrstatus); |
883 | ohci_writel (ohci, OHCI_INTR_MIE, ®s->intrenable); | 880 | ohci_writel (ohci, OHCI_INTR_MIE, ®s->intrenable); |
884 | // flush those writes | 881 | // flush those writes |
@@ -932,7 +929,7 @@ static int ohci_restart (struct ohci_hcd *ohci) | |||
932 | struct urb_priv *priv; | 929 | struct urb_priv *priv; |
933 | 930 | ||
934 | spin_lock_irq(&ohci->lock); | 931 | spin_lock_irq(&ohci->lock); |
935 | disable (ohci); | 932 | ohci->rh_state = OHCI_RH_HALTED; |
936 | 933 | ||
937 | /* Recycle any "live" eds/tds (and urbs). */ | 934 | /* Recycle any "live" eds/tds (and urbs). */ |
938 | if (!list_empty (&ohci->pending)) | 935 | if (!list_empty (&ohci->pending)) |
@@ -1008,6 +1005,11 @@ MODULE_LICENSE ("GPL"); | |||
1008 | #define PLATFORM_DRIVER ohci_hcd_s3c2410_driver | 1005 | #define PLATFORM_DRIVER ohci_hcd_s3c2410_driver |
1009 | #endif | 1006 | #endif |
1010 | 1007 | ||
1008 | #ifdef CONFIG_USB_OHCI_EXYNOS | ||
1009 | #include "ohci-exynos.c" | ||
1010 | #define PLATFORM_DRIVER exynos_ohci_driver | ||
1011 | #endif | ||
1012 | |||
1011 | #ifdef CONFIG_USB_OHCI_HCD_OMAP1 | 1013 | #ifdef CONFIG_USB_OHCI_HCD_OMAP1 |
1012 | #include "ohci-omap.c" | 1014 | #include "ohci-omap.c" |
1013 | #define OMAP1_PLATFORM_DRIVER ohci_hcd_omap_driver | 1015 | #define OMAP1_PLATFORM_DRIVER ohci_hcd_omap_driver |
@@ -1114,7 +1116,7 @@ MODULE_LICENSE ("GPL"); | |||
1114 | #define PLATFORM_DRIVER ohci_hcd_ath79_driver | 1116 | #define PLATFORM_DRIVER ohci_hcd_ath79_driver |
1115 | #endif | 1117 | #endif |
1116 | 1118 | ||
1117 | #ifdef CONFIG_NLM_XLR | 1119 | #ifdef CONFIG_CPU_XLR |
1118 | #include "ohci-xls.c" | 1120 | #include "ohci-xls.c" |
1119 | #define PLATFORM_DRIVER ohci_xls_driver | 1121 | #define PLATFORM_DRIVER ohci_xls_driver |
1120 | #endif | 1122 | #endif |
diff --git a/drivers/usb/host/ohci-hub.c b/drivers/usb/host/ohci-hub.c index 2f00040fc408..836772dfabd3 100644 --- a/drivers/usb/host/ohci-hub.c +++ b/drivers/usb/host/ohci-hub.c | |||
@@ -111,6 +111,7 @@ __acquires(ohci->lock) | |||
111 | if (!autostop) { | 111 | if (!autostop) { |
112 | ohci->next_statechange = jiffies + msecs_to_jiffies (5); | 112 | ohci->next_statechange = jiffies + msecs_to_jiffies (5); |
113 | ohci->autostop = 0; | 113 | ohci->autostop = 0; |
114 | ohci->rh_state = OHCI_RH_SUSPENDED; | ||
114 | } | 115 | } |
115 | 116 | ||
116 | done: | 117 | done: |
@@ -140,7 +141,7 @@ __acquires(ohci->lock) | |||
140 | 141 | ||
141 | if (ohci->hc_control & (OHCI_CTRL_IR | OHCI_SCHED_ENABLES)) { | 142 | if (ohci->hc_control & (OHCI_CTRL_IR | OHCI_SCHED_ENABLES)) { |
142 | /* this can happen after resuming a swsusp snapshot */ | 143 | /* this can happen after resuming a swsusp snapshot */ |
143 | if (hcd->state == HC_STATE_RESUMING) { | 144 | if (ohci->rh_state != OHCI_RH_RUNNING) { |
144 | ohci_dbg (ohci, "BIOS/SMM active, control %03x\n", | 145 | ohci_dbg (ohci, "BIOS/SMM active, control %03x\n", |
145 | ohci->hc_control); | 146 | ohci->hc_control); |
146 | status = -EBUSY; | 147 | status = -EBUSY; |
@@ -274,6 +275,7 @@ skip_resume: | |||
274 | (void) ohci_readl (ohci, &ohci->regs->control); | 275 | (void) ohci_readl (ohci, &ohci->regs->control); |
275 | } | 276 | } |
276 | 277 | ||
278 | ohci->rh_state = OHCI_RH_RUNNING; | ||
277 | return 0; | 279 | return 0; |
278 | } | 280 | } |
279 | 281 | ||
@@ -336,11 +338,8 @@ static void ohci_finish_controller_resume(struct usb_hcd *hcd) | |||
336 | /* If needed, reinitialize and suspend the root hub */ | 338 | /* If needed, reinitialize and suspend the root hub */ |
337 | if (need_reinit) { | 339 | if (need_reinit) { |
338 | spin_lock_irq(&ohci->lock); | 340 | spin_lock_irq(&ohci->lock); |
339 | hcd->state = HC_STATE_RESUMING; | ||
340 | ohci_rh_resume(ohci); | 341 | ohci_rh_resume(ohci); |
341 | hcd->state = HC_STATE_QUIESCING; | ||
342 | ohci_rh_suspend(ohci, 0); | 342 | ohci_rh_suspend(ohci, 0); |
343 | hcd->state = HC_STATE_SUSPENDED; | ||
344 | spin_unlock_irq(&ohci->lock); | 343 | spin_unlock_irq(&ohci->lock); |
345 | } | 344 | } |
346 | 345 | ||
diff --git a/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c index e4b8782cc6e2..db3968656d21 100644 --- a/drivers/usb/host/ohci-omap.c +++ b/drivers/usb/host/ohci-omap.c | |||
@@ -516,7 +516,6 @@ static int ohci_omap_suspend(struct platform_device *dev, pm_message_t message) | |||
516 | ohci->next_statechange = jiffies; | 516 | ohci->next_statechange = jiffies; |
517 | 517 | ||
518 | omap_ohci_clock_power(0); | 518 | omap_ohci_clock_power(0); |
519 | ohci_to_hcd(ohci)->state = HC_STATE_SUSPENDED; | ||
520 | return 0; | 519 | return 0; |
521 | } | 520 | } |
522 | 521 | ||
diff --git a/drivers/usb/host/ohci-omap3.c b/drivers/usb/host/ohci-omap3.c index 516ebc4d6cc2..1b8133b6e451 100644 --- a/drivers/usb/host/ohci-omap3.c +++ b/drivers/usb/host/ohci-omap3.c | |||
@@ -31,6 +31,7 @@ | |||
31 | 31 | ||
32 | #include <linux/platform_device.h> | 32 | #include <linux/platform_device.h> |
33 | #include <plat/usb.h> | 33 | #include <plat/usb.h> |
34 | #include <linux/pm_runtime.h> | ||
34 | 35 | ||
35 | /*-------------------------------------------------------------------------*/ | 36 | /*-------------------------------------------------------------------------*/ |
36 | 37 | ||
@@ -134,7 +135,7 @@ static int __devinit ohci_hcd_omap3_probe(struct platform_device *pdev) | |||
134 | int irq; | 135 | int irq; |
135 | 136 | ||
136 | if (usb_disabled()) | 137 | if (usb_disabled()) |
137 | goto err_end; | 138 | return -ENODEV; |
138 | 139 | ||
139 | if (!dev->parent) { | 140 | if (!dev->parent) { |
140 | dev_err(dev, "Missing parent device\n"); | 141 | dev_err(dev, "Missing parent device\n"); |
@@ -172,11 +173,8 @@ static int __devinit ohci_hcd_omap3_probe(struct platform_device *pdev) | |||
172 | hcd->rsrc_len = resource_size(res); | 173 | hcd->rsrc_len = resource_size(res); |
173 | hcd->regs = regs; | 174 | hcd->regs = regs; |
174 | 175 | ||
175 | ret = omap_usbhs_enable(dev); | 176 | pm_runtime_enable(dev); |
176 | if (ret) { | 177 | pm_runtime_get_sync(dev); |
177 | dev_dbg(dev, "failed to start ohci\n"); | ||
178 | goto err_end; | ||
179 | } | ||
180 | 178 | ||
181 | ohci_hcd_init(hcd_to_ohci(hcd)); | 179 | ohci_hcd_init(hcd_to_ohci(hcd)); |
182 | 180 | ||
@@ -189,9 +187,7 @@ static int __devinit ohci_hcd_omap3_probe(struct platform_device *pdev) | |||
189 | return 0; | 187 | return 0; |
190 | 188 | ||
191 | err_add_hcd: | 189 | err_add_hcd: |
192 | omap_usbhs_disable(dev); | 190 | pm_runtime_put_sync(dev); |
193 | |||
194 | err_end: | ||
195 | usb_put_hcd(hcd); | 191 | usb_put_hcd(hcd); |
196 | 192 | ||
197 | err_io: | 193 | err_io: |
@@ -220,9 +216,9 @@ static int __devexit ohci_hcd_omap3_remove(struct platform_device *pdev) | |||
220 | 216 | ||
221 | iounmap(hcd->regs); | 217 | iounmap(hcd->regs); |
222 | usb_remove_hcd(hcd); | 218 | usb_remove_hcd(hcd); |
223 | omap_usbhs_disable(dev); | 219 | pm_runtime_put_sync(dev); |
220 | pm_runtime_disable(dev); | ||
224 | usb_put_hcd(hcd); | 221 | usb_put_hcd(hcd); |
225 | |||
226 | return 0; | 222 | return 0; |
227 | } | 223 | } |
228 | 224 | ||
diff --git a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c index ad8166c681e2..6109810cc2d3 100644 --- a/drivers/usb/host/ohci-pci.c +++ b/drivers/usb/host/ohci-pci.c | |||
@@ -175,28 +175,6 @@ static int ohci_quirk_amd700(struct usb_hcd *hcd) | |||
175 | return 0; | 175 | return 0; |
176 | } | 176 | } |
177 | 177 | ||
178 | /* nVidia controllers continue to drive Reset signalling on the bus | ||
179 | * even after system shutdown, wasting power. This flag tells the | ||
180 | * shutdown routine to leave the controller OPERATIONAL instead of RESET. | ||
181 | */ | ||
182 | static int ohci_quirk_nvidia_shutdown(struct usb_hcd *hcd) | ||
183 | { | ||
184 | struct pci_dev *pdev = to_pci_dev(hcd->self.controller); | ||
185 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); | ||
186 | |||
187 | /* Evidently nVidia fixed their later hardware; this is a guess at | ||
188 | * the changeover point. | ||
189 | */ | ||
190 | #define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_USB 0x026d | ||
191 | |||
192 | if (pdev->device < PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_USB) { | ||
193 | ohci->flags |= OHCI_QUIRK_SHUTDOWN; | ||
194 | ohci_dbg(ohci, "enabled nVidia shutdown quirk\n"); | ||
195 | } | ||
196 | |||
197 | return 0; | ||
198 | } | ||
199 | |||
200 | static void sb800_prefetch(struct ohci_hcd *ohci, int on) | 178 | static void sb800_prefetch(struct ohci_hcd *ohci, int on) |
201 | { | 179 | { |
202 | struct pci_dev *pdev; | 180 | struct pci_dev *pdev; |
@@ -260,10 +238,6 @@ static const struct pci_device_id ohci_pci_quirks[] = { | |||
260 | PCI_DEVICE(PCI_VENDOR_ID_ATI, 0x4399), | 238 | PCI_DEVICE(PCI_VENDOR_ID_ATI, 0x4399), |
261 | .driver_data = (unsigned long)ohci_quirk_amd700, | 239 | .driver_data = (unsigned long)ohci_quirk_amd700, |
262 | }, | 240 | }, |
263 | { | ||
264 | PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID), | ||
265 | .driver_data = (unsigned long) ohci_quirk_nvidia_shutdown, | ||
266 | }, | ||
267 | 241 | ||
268 | /* FIXME for some of the early AMD 760 southbridges, OHCI | 242 | /* FIXME for some of the early AMD 760 southbridges, OHCI |
269 | * won't work at all. blacklist them. | 243 | * won't work at all. blacklist them. |
@@ -334,12 +308,9 @@ static int ohci_pci_suspend(struct usb_hcd *hcd, bool do_wakeup) | |||
334 | * mark HW unaccessible, bail out if RH has been resumed. Use | 308 | * mark HW unaccessible, bail out if RH has been resumed. Use |
335 | * the spinlock to properly synchronize with possible pending | 309 | * the spinlock to properly synchronize with possible pending |
336 | * RH suspend or resume activity. | 310 | * RH suspend or resume activity. |
337 | * | ||
338 | * This is still racy as hcd->state is manipulated outside of | ||
339 | * any locks =P But that will be a different fix. | ||
340 | */ | 311 | */ |
341 | spin_lock_irqsave (&ohci->lock, flags); | 312 | spin_lock_irqsave (&ohci->lock, flags); |
342 | if (hcd->state != HC_STATE_SUSPENDED) { | 313 | if (ohci->rh_state != OHCI_RH_SUSPENDED) { |
343 | rc = -EINVAL; | 314 | rc = -EINVAL; |
344 | goto bail; | 315 | goto bail; |
345 | } | 316 | } |
diff --git a/drivers/usb/host/ohci-pxa27x.c b/drivers/usb/host/ohci-pxa27x.c index 29dfefe1c726..6313e4439f37 100644 --- a/drivers/usb/host/ohci-pxa27x.c +++ b/drivers/usb/host/ohci-pxa27x.c | |||
@@ -502,8 +502,6 @@ static int ohci_hcd_pxa27x_drv_suspend(struct device *dev) | |||
502 | ohci->ohci.next_statechange = jiffies; | 502 | ohci->ohci.next_statechange = jiffies; |
503 | 503 | ||
504 | pxa27x_stop_hc(ohci, dev); | 504 | pxa27x_stop_hc(ohci, dev); |
505 | hcd->state = HC_STATE_SUSPENDED; | ||
506 | |||
507 | return 0; | 505 | return 0; |
508 | } | 506 | } |
509 | 507 | ||
diff --git a/drivers/usb/host/ohci-q.c b/drivers/usb/host/ohci-q.c index 15dc51ded61a..c5a1ea9145fa 100644 --- a/drivers/usb/host/ohci-q.c +++ b/drivers/usb/host/ohci-q.c | |||
@@ -912,7 +912,7 @@ rescan_all: | |||
912 | /* only take off EDs that the HC isn't using, accounting for | 912 | /* only take off EDs that the HC isn't using, accounting for |
913 | * frame counter wraps and EDs with partially retired TDs | 913 | * frame counter wraps and EDs with partially retired TDs |
914 | */ | 914 | */ |
915 | if (likely (HC_IS_RUNNING(ohci_to_hcd(ohci)->state))) { | 915 | if (likely(ohci->rh_state == OHCI_RH_RUNNING)) { |
916 | if (tick_before (tick, ed->tick)) { | 916 | if (tick_before (tick, ed->tick)) { |
917 | skip_ed: | 917 | skip_ed: |
918 | last = &ed->ed_next; | 918 | last = &ed->ed_next; |
@@ -1012,7 +1012,7 @@ rescan_this: | |||
1012 | 1012 | ||
1013 | /* but if there's work queued, reschedule */ | 1013 | /* but if there's work queued, reschedule */ |
1014 | if (!list_empty (&ed->td_list)) { | 1014 | if (!list_empty (&ed->td_list)) { |
1015 | if (HC_IS_RUNNING(ohci_to_hcd(ohci)->state)) | 1015 | if (ohci->rh_state == OHCI_RH_RUNNING) |
1016 | ed_schedule (ohci, ed); | 1016 | ed_schedule (ohci, ed); |
1017 | } | 1017 | } |
1018 | 1018 | ||
@@ -1021,9 +1021,7 @@ rescan_this: | |||
1021 | } | 1021 | } |
1022 | 1022 | ||
1023 | /* maybe reenable control and bulk lists */ | 1023 | /* maybe reenable control and bulk lists */ |
1024 | if (HC_IS_RUNNING(ohci_to_hcd(ohci)->state) | 1024 | if (ohci->rh_state == OHCI_RH_RUNNING && !ohci->ed_rm_list) { |
1025 | && ohci_to_hcd(ohci)->state != HC_STATE_QUIESCING | ||
1026 | && !ohci->ed_rm_list) { | ||
1027 | u32 command = 0, control = 0; | 1025 | u32 command = 0, control = 0; |
1028 | 1026 | ||
1029 | if (ohci->ed_controltail) { | 1027 | if (ohci->ed_controltail) { |
diff --git a/drivers/usb/host/ohci-s3c2410.c b/drivers/usb/host/ohci-s3c2410.c index a1877c47601e..56dcf069246d 100644 --- a/drivers/usb/host/ohci-s3c2410.c +++ b/drivers/usb/host/ohci-s3c2410.c | |||
@@ -486,15 +486,66 @@ static int __devexit ohci_hcd_s3c2410_drv_remove(struct platform_device *pdev) | |||
486 | return 0; | 486 | return 0; |
487 | } | 487 | } |
488 | 488 | ||
489 | #ifdef CONFIG_PM | ||
490 | static int ohci_hcd_s3c2410_drv_suspend(struct device *dev) | ||
491 | { | ||
492 | struct usb_hcd *hcd = dev_get_drvdata(dev); | ||
493 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); | ||
494 | struct platform_device *pdev = to_platform_device(dev); | ||
495 | unsigned long flags; | ||
496 | int rc = 0; | ||
497 | |||
498 | /* | ||
499 | * Root hub was already suspended. Disable irq emission and | ||
500 | * mark HW unaccessible, bail out if RH has been resumed. Use | ||
501 | * the spinlock to properly synchronize with possible pending | ||
502 | * RH suspend or resume activity. | ||
503 | */ | ||
504 | spin_lock_irqsave(&ohci->lock, flags); | ||
505 | if (ohci->rh_state != OHCI_RH_SUSPENDED) { | ||
506 | rc = -EINVAL; | ||
507 | goto bail; | ||
508 | } | ||
509 | |||
510 | clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); | ||
511 | |||
512 | s3c2410_stop_hc(pdev); | ||
513 | bail: | ||
514 | spin_unlock_irqrestore(&ohci->lock, flags); | ||
515 | |||
516 | return rc; | ||
517 | } | ||
518 | |||
519 | static int ohci_hcd_s3c2410_drv_resume(struct device *dev) | ||
520 | { | ||
521 | struct usb_hcd *hcd = dev_get_drvdata(dev); | ||
522 | struct platform_device *pdev = to_platform_device(dev); | ||
523 | |||
524 | s3c2410_start_hc(pdev, hcd); | ||
525 | |||
526 | set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); | ||
527 | ohci_finish_controller_resume(hcd); | ||
528 | |||
529 | return 0; | ||
530 | } | ||
531 | #else | ||
532 | #define ohci_hcd_s3c2410_drv_suspend NULL | ||
533 | #define ohci_hcd_s3c2410_drv_resume NULL | ||
534 | #endif | ||
535 | |||
536 | static const struct dev_pm_ops ohci_hcd_s3c2410_pm_ops = { | ||
537 | .suspend = ohci_hcd_s3c2410_drv_suspend, | ||
538 | .resume = ohci_hcd_s3c2410_drv_resume, | ||
539 | }; | ||
540 | |||
489 | static struct platform_driver ohci_hcd_s3c2410_driver = { | 541 | static struct platform_driver ohci_hcd_s3c2410_driver = { |
490 | .probe = ohci_hcd_s3c2410_drv_probe, | 542 | .probe = ohci_hcd_s3c2410_drv_probe, |
491 | .remove = __devexit_p(ohci_hcd_s3c2410_drv_remove), | 543 | .remove = __devexit_p(ohci_hcd_s3c2410_drv_remove), |
492 | .shutdown = usb_hcd_platform_shutdown, | 544 | .shutdown = usb_hcd_platform_shutdown, |
493 | /*.suspend = ohci_hcd_s3c2410_drv_suspend, */ | ||
494 | /*.resume = ohci_hcd_s3c2410_drv_resume, */ | ||
495 | .driver = { | 545 | .driver = { |
496 | .owner = THIS_MODULE, | 546 | .owner = THIS_MODULE, |
497 | .name = "s3c2410-ohci", | 547 | .name = "s3c2410-ohci", |
548 | .pm = &ohci_hcd_s3c2410_pm_ops, | ||
498 | }, | 549 | }, |
499 | }; | 550 | }; |
500 | 551 | ||
diff --git a/drivers/usb/host/ohci-sh.c b/drivers/usb/host/ohci-sh.c index afc4eb6bb9d0..84686d90805b 100644 --- a/drivers/usb/host/ohci-sh.c +++ b/drivers/usb/host/ohci-sh.c | |||
@@ -29,7 +29,6 @@ static int ohci_sh_start(struct usb_hcd *hcd) | |||
29 | ohci_hcd_init(ohci); | 29 | ohci_hcd_init(ohci); |
30 | ohci_init(ohci); | 30 | ohci_init(ohci); |
31 | ohci_run(ohci); | 31 | ohci_run(ohci); |
32 | hcd->state = HC_STATE_RUNNING; | ||
33 | return 0; | 32 | return 0; |
34 | } | 33 | } |
35 | 34 | ||
diff --git a/drivers/usb/host/ohci-sm501.c b/drivers/usb/host/ohci-sm501.c index 968cea2b6d4e..5596ac2ba1ca 100644 --- a/drivers/usb/host/ohci-sm501.c +++ b/drivers/usb/host/ohci-sm501.c | |||
@@ -224,7 +224,6 @@ static int ohci_sm501_suspend(struct platform_device *pdev, pm_message_t msg) | |||
224 | ohci->next_statechange = jiffies; | 224 | ohci->next_statechange = jiffies; |
225 | 225 | ||
226 | sm501_unit_power(dev->parent, SM501_GATE_USB_HOST, 0); | 226 | sm501_unit_power(dev->parent, SM501_GATE_USB_HOST, 0); |
227 | ohci_to_hcd(ohci)->state = HC_STATE_SUSPENDED; | ||
228 | return 0; | 227 | return 0; |
229 | } | 228 | } |
230 | 229 | ||
diff --git a/drivers/usb/host/ohci-spear.c b/drivers/usb/host/ohci-spear.c index 69874654f3b5..95c16489e883 100644 --- a/drivers/usb/host/ohci-spear.c +++ b/drivers/usb/host/ohci-spear.c | |||
@@ -203,7 +203,6 @@ static int spear_ohci_hcd_drv_suspend(struct platform_device *dev, | |||
203 | ohci->next_statechange = jiffies; | 203 | ohci->next_statechange = jiffies; |
204 | 204 | ||
205 | spear_stop_ohci(ohci_p); | 205 | spear_stop_ohci(ohci_p); |
206 | ohci_to_hcd(ohci)->state = HC_STATE_SUSPENDED; | ||
207 | return 0; | 206 | return 0; |
208 | } | 207 | } |
209 | 208 | ||
diff --git a/drivers/usb/host/ohci-tmio.c b/drivers/usb/host/ohci-tmio.c index 06331d931171..120bfe6ede38 100644 --- a/drivers/usb/host/ohci-tmio.c +++ b/drivers/usb/host/ohci-tmio.c | |||
@@ -318,9 +318,6 @@ static int ohci_hcd_tmio_drv_suspend(struct platform_device *dev, pm_message_t s | |||
318 | if (ret) | 318 | if (ret) |
319 | return ret; | 319 | return ret; |
320 | } | 320 | } |
321 | |||
322 | hcd->state = HC_STATE_SUSPENDED; | ||
323 | |||
324 | return 0; | 321 | return 0; |
325 | } | 322 | } |
326 | 323 | ||
diff --git a/drivers/usb/host/ohci-xls.c b/drivers/usb/host/ohci-xls.c index a3a9c6f45b91..a2247867af86 100644 --- a/drivers/usb/host/ohci-xls.c +++ b/drivers/usb/host/ohci-xls.c | |||
@@ -40,7 +40,7 @@ static int ohci_xls_probe_internal(const struct hc_driver *driver, | |||
40 | goto err1; | 40 | goto err1; |
41 | } | 41 | } |
42 | hcd->rsrc_start = res->start; | 42 | hcd->rsrc_start = res->start; |
43 | hcd->rsrc_len = res->end - res->start + 1; | 43 | hcd->rsrc_len = resource_size(res); |
44 | 44 | ||
45 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, | 45 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, |
46 | driver->description)) { | 46 | driver->description)) { |
diff --git a/drivers/usb/host/ohci.h b/drivers/usb/host/ohci.h index 35e5fd640ce7..8ff6f7ea96fd 100644 --- a/drivers/usb/host/ohci.h +++ b/drivers/usb/host/ohci.h | |||
@@ -344,6 +344,12 @@ typedef struct urb_priv { | |||
344 | * a subset of what the full implementation needs. (Linus) | 344 | * a subset of what the full implementation needs. (Linus) |
345 | */ | 345 | */ |
346 | 346 | ||
347 | enum ohci_rh_state { | ||
348 | OHCI_RH_HALTED, | ||
349 | OHCI_RH_SUSPENDED, | ||
350 | OHCI_RH_RUNNING | ||
351 | }; | ||
352 | |||
347 | struct ohci_hcd { | 353 | struct ohci_hcd { |
348 | spinlock_t lock; | 354 | spinlock_t lock; |
349 | 355 | ||
@@ -384,6 +390,7 @@ struct ohci_hcd { | |||
384 | /* | 390 | /* |
385 | * driver state | 391 | * driver state |
386 | */ | 392 | */ |
393 | enum ohci_rh_state rh_state; | ||
387 | int num_ports; | 394 | int num_ports; |
388 | int load [NUM_INTS]; | 395 | int load [NUM_INTS]; |
389 | u32 hc_control; /* copy of hc control reg */ | 396 | u32 hc_control; /* copy of hc control reg */ |
@@ -403,7 +410,6 @@ struct ohci_hcd { | |||
403 | #define OHCI_QUIRK_HUB_POWER 0x100 /* distrust firmware power/oc setup */ | 410 | #define OHCI_QUIRK_HUB_POWER 0x100 /* distrust firmware power/oc setup */ |
404 | #define OHCI_QUIRK_AMD_PLL 0x200 /* AMD PLL quirk*/ | 411 | #define OHCI_QUIRK_AMD_PLL 0x200 /* AMD PLL quirk*/ |
405 | #define OHCI_QUIRK_AMD_PREFETCH 0x400 /* pre-fetch for ISO transfer */ | 412 | #define OHCI_QUIRK_AMD_PREFETCH 0x400 /* pre-fetch for ISO transfer */ |
406 | #define OHCI_QUIRK_SHUTDOWN 0x800 /* nVidia power bug */ | ||
407 | // there are also chip quirks/bugs in init logic | 413 | // there are also chip quirks/bugs in init logic |
408 | 414 | ||
409 | struct work_struct nec_work; /* Worker for NEC quirk */ | 415 | struct work_struct nec_work; /* Worker for NEC quirk */ |
@@ -680,11 +686,6 @@ static inline u16 ohci_hwPSW(const struct ohci_hcd *ohci, | |||
680 | 686 | ||
681 | /*-------------------------------------------------------------------------*/ | 687 | /*-------------------------------------------------------------------------*/ |
682 | 688 | ||
683 | static inline void disable (struct ohci_hcd *ohci) | ||
684 | { | ||
685 | ohci_to_hcd(ohci)->state = HC_STATE_HALT; | ||
686 | } | ||
687 | |||
688 | #define FI 0x2edf /* 12000 bits per frame (-1) */ | 689 | #define FI 0x2edf /* 12000 bits per frame (-1) */ |
689 | #define FSMP(fi) (0x7fff & ((6 * ((fi) - 210)) / 7)) | 690 | #define FSMP(fi) (0x7fff & ((6 * ((fi) - 210)) / 7)) |
690 | #define FIT (1 << 31) | 691 | #define FIT (1 << 31) |
@@ -708,7 +709,7 @@ static inline void periodic_reinit (struct ohci_hcd *ohci) | |||
708 | #define read_roothub(hc, register, mask) ({ \ | 709 | #define read_roothub(hc, register, mask) ({ \ |
709 | u32 temp = ohci_readl (hc, &hc->regs->roothub.register); \ | 710 | u32 temp = ohci_readl (hc, &hc->regs->roothub.register); \ |
710 | if (temp == -1) \ | 711 | if (temp == -1) \ |
711 | disable (hc); \ | 712 | hc->rh_state = OHCI_RH_HALTED; \ |
712 | else if (hc->flags & OHCI_QUIRK_AMD756) \ | 713 | else if (hc->flags & OHCI_QUIRK_AMD756) \ |
713 | while (temp & mask) \ | 714 | while (temp & mask) \ |
714 | temp = ohci_readl (hc, &hc->regs->roothub.register); \ | 715 | temp = ohci_readl (hc, &hc->regs->roothub.register); \ |
diff --git a/drivers/usb/host/oxu210hp-hcd.c b/drivers/usb/host/oxu210hp-hcd.c index dcd889803f0f..015c7c62ed49 100644 --- a/drivers/usb/host/oxu210hp-hcd.c +++ b/drivers/usb/host/oxu210hp-hcd.c | |||
@@ -233,7 +233,7 @@ module_param(park, uint, S_IRUGO); | |||
233 | MODULE_PARM_DESC(park, "park setting; 1-3 back-to-back async packets"); | 233 | MODULE_PARM_DESC(park, "park setting; 1-3 back-to-back async packets"); |
234 | 234 | ||
235 | /* For flakey hardware, ignore overcurrent indicators */ | 235 | /* For flakey hardware, ignore overcurrent indicators */ |
236 | static int ignore_oc; | 236 | static bool ignore_oc; |
237 | module_param(ignore_oc, bool, S_IRUGO); | 237 | module_param(ignore_oc, bool, S_IRUGO); |
238 | MODULE_PARM_DESC(ignore_oc, "ignore bogus hardware overcurrent indications"); | 238 | MODULE_PARM_DESC(ignore_oc, "ignore bogus hardware overcurrent indications"); |
239 | 239 | ||
@@ -3951,24 +3951,7 @@ static struct platform_driver oxu_driver = { | |||
3951 | } | 3951 | } |
3952 | }; | 3952 | }; |
3953 | 3953 | ||
3954 | static int __init oxu_module_init(void) | 3954 | module_platform_driver(oxu_driver); |
3955 | { | ||
3956 | int retval = 0; | ||
3957 | |||
3958 | retval = platform_driver_register(&oxu_driver); | ||
3959 | if (retval < 0) | ||
3960 | return retval; | ||
3961 | |||
3962 | return retval; | ||
3963 | } | ||
3964 | |||
3965 | static void __exit oxu_module_cleanup(void) | ||
3966 | { | ||
3967 | platform_driver_unregister(&oxu_driver); | ||
3968 | } | ||
3969 | |||
3970 | module_init(oxu_module_init); | ||
3971 | module_exit(oxu_module_cleanup); | ||
3972 | 3955 | ||
3973 | MODULE_DESCRIPTION("Oxford OXU210HP HCD driver - ver. " DRIVER_VERSION); | 3956 | MODULE_DESCRIPTION("Oxford OXU210HP HCD driver - ver. " DRIVER_VERSION); |
3974 | MODULE_AUTHOR("Rodolfo Giometti <giometti@linux.it>"); | 3957 | MODULE_AUTHOR("Rodolfo Giometti <giometti@linux.it>"); |
diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c index 27a3dec32fa2..caf87428ca43 100644 --- a/drivers/usb/host/pci-quirks.c +++ b/drivers/usb/host/pci-quirks.c | |||
@@ -37,6 +37,7 @@ | |||
37 | #define OHCI_INTRENABLE 0x10 | 37 | #define OHCI_INTRENABLE 0x10 |
38 | #define OHCI_INTRDISABLE 0x14 | 38 | #define OHCI_INTRDISABLE 0x14 |
39 | #define OHCI_FMINTERVAL 0x34 | 39 | #define OHCI_FMINTERVAL 0x34 |
40 | #define OHCI_HCFS (3 << 6) /* hc functional state */ | ||
40 | #define OHCI_HCR (1 << 0) /* host controller reset */ | 41 | #define OHCI_HCR (1 << 0) /* host controller reset */ |
41 | #define OHCI_OCR (1 << 3) /* ownership change request */ | 42 | #define OHCI_OCR (1 << 3) /* ownership change request */ |
42 | #define OHCI_CTRL_RWC (1 << 9) /* remote wakeup connected */ | 43 | #define OHCI_CTRL_RWC (1 << 9) /* remote wakeup connected */ |
@@ -466,6 +467,8 @@ static void __devinit quirk_usb_handoff_ohci(struct pci_dev *pdev) | |||
466 | { | 467 | { |
467 | void __iomem *base; | 468 | void __iomem *base; |
468 | u32 control; | 469 | u32 control; |
470 | u32 fminterval; | ||
471 | int cnt; | ||
469 | 472 | ||
470 | if (!mmio_resource_enabled(pdev, 0)) | 473 | if (!mmio_resource_enabled(pdev, 0)) |
471 | return; | 474 | return; |
@@ -498,41 +501,32 @@ static void __devinit quirk_usb_handoff_ohci(struct pci_dev *pdev) | |||
498 | } | 501 | } |
499 | #endif | 502 | #endif |
500 | 503 | ||
501 | /* reset controller, preserving RWC (and possibly IR) */ | 504 | /* disable interrupts */ |
502 | writel(control & OHCI_CTRL_MASK, base + OHCI_CONTROL); | 505 | writel((u32) ~0, base + OHCI_INTRDISABLE); |
503 | readl(base + OHCI_CONTROL); | ||
504 | 506 | ||
505 | /* Some NVIDIA controllers stop working if kept in RESET for too long */ | 507 | /* Reset the USB bus, if the controller isn't already in RESET */ |
506 | if (pdev->vendor == PCI_VENDOR_ID_NVIDIA) { | 508 | if (control & OHCI_HCFS) { |
507 | u32 fminterval; | 509 | /* Go into RESET, preserving RWC (and possibly IR) */ |
508 | int cnt; | 510 | writel(control & OHCI_CTRL_MASK, base + OHCI_CONTROL); |
511 | readl(base + OHCI_CONTROL); | ||
509 | 512 | ||
510 | /* drive reset for at least 50 ms (7.1.7.5) */ | 513 | /* drive bus reset for at least 50 ms (7.1.7.5) */ |
511 | msleep(50); | 514 | msleep(50); |
515 | } | ||
512 | 516 | ||
513 | /* software reset of the controller, preserving HcFmInterval */ | 517 | /* software reset of the controller, preserving HcFmInterval */ |
514 | fminterval = readl(base + OHCI_FMINTERVAL); | 518 | fminterval = readl(base + OHCI_FMINTERVAL); |
515 | writel(OHCI_HCR, base + OHCI_CMDSTATUS); | 519 | writel(OHCI_HCR, base + OHCI_CMDSTATUS); |
516 | 520 | ||
517 | /* reset requires max 10 us delay */ | 521 | /* reset requires max 10 us delay */ |
518 | for (cnt = 30; cnt > 0; --cnt) { /* ... allow extra time */ | 522 | for (cnt = 30; cnt > 0; --cnt) { /* ... allow extra time */ |
519 | if ((readl(base + OHCI_CMDSTATUS) & OHCI_HCR) == 0) | 523 | if ((readl(base + OHCI_CMDSTATUS) & OHCI_HCR) == 0) |
520 | break; | 524 | break; |
521 | udelay(1); | 525 | udelay(1); |
522 | } | ||
523 | writel(fminterval, base + OHCI_FMINTERVAL); | ||
524 | |||
525 | /* Now we're in the SUSPEND state with all devices reset | ||
526 | * and wakeups and interrupts disabled | ||
527 | */ | ||
528 | } | 526 | } |
527 | writel(fminterval, base + OHCI_FMINTERVAL); | ||
529 | 528 | ||
530 | /* | 529 | /* Now the controller is safely in SUSPEND and nothing can wake it up */ |
531 | * disable interrupts | ||
532 | */ | ||
533 | writel(~(u32)0, base + OHCI_INTRDISABLE); | ||
534 | writel(~(u32)0, base + OHCI_INTRSTATUS); | ||
535 | |||
536 | iounmap(base); | 530 | iounmap(base); |
537 | } | 531 | } |
538 | 532 | ||
@@ -627,7 +621,7 @@ static void __devinit quirk_usb_disable_ehci(struct pci_dev *pdev) | |||
627 | void __iomem *base, *op_reg_base; | 621 | void __iomem *base, *op_reg_base; |
628 | u32 hcc_params, cap, val; | 622 | u32 hcc_params, cap, val; |
629 | u8 offset, cap_length; | 623 | u8 offset, cap_length; |
630 | int wait_time, delta, count = 256/4; | 624 | int wait_time, count = 256/4; |
631 | 625 | ||
632 | if (!mmio_resource_enabled(pdev, 0)) | 626 | if (!mmio_resource_enabled(pdev, 0)) |
633 | return; | 627 | return; |
@@ -673,11 +667,10 @@ static void __devinit quirk_usb_disable_ehci(struct pci_dev *pdev) | |||
673 | writel(val, op_reg_base + EHCI_USBCMD); | 667 | writel(val, op_reg_base + EHCI_USBCMD); |
674 | 668 | ||
675 | wait_time = 2000; | 669 | wait_time = 2000; |
676 | delta = 100; | ||
677 | do { | 670 | do { |
678 | writel(0x3f, op_reg_base + EHCI_USBSTS); | 671 | writel(0x3f, op_reg_base + EHCI_USBSTS); |
679 | udelay(delta); | 672 | udelay(100); |
680 | wait_time -= delta; | 673 | wait_time -= 100; |
681 | val = readl(op_reg_base + EHCI_USBSTS); | 674 | val = readl(op_reg_base + EHCI_USBSTS); |
682 | if ((val == ~(u32)0) || (val & EHCI_USBSTS_HALTED)) { | 675 | if ((val == ~(u32)0) || (val & EHCI_USBSTS_HALTED)) { |
683 | break; | 676 | break; |
diff --git a/drivers/usb/host/u132-hcd.c b/drivers/usb/host/u132-hcd.c index 533d12cca371..16dd6a6abf00 100644 --- a/drivers/usb/host/u132-hcd.c +++ b/drivers/usb/host/u132-hcd.c | |||
@@ -74,7 +74,7 @@ MODULE_LICENSE("GPL"); | |||
74 | #define INT_MODULE_PARM(n, v) static int n = v;module_param(n, int, 0444) | 74 | #define INT_MODULE_PARM(n, v) static int n = v;module_param(n, int, 0444) |
75 | INT_MODULE_PARM(testing, 0); | 75 | INT_MODULE_PARM(testing, 0); |
76 | /* Some boards misreport power switching/overcurrent*/ | 76 | /* Some boards misreport power switching/overcurrent*/ |
77 | static int distrust_firmware = 1; | 77 | static bool distrust_firmware = 1; |
78 | module_param(distrust_firmware, bool, 0); | 78 | module_param(distrust_firmware, bool, 0); |
79 | MODULE_PARM_DESC(distrust_firmware, "true to distrust firmware power/overcurren" | 79 | MODULE_PARM_DESC(distrust_firmware, "true to distrust firmware power/overcurren" |
80 | "t setup"); | 80 | "t setup"); |
diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c index c8ae199cfbb8..6b5eb1017e2c 100644 --- a/drivers/usb/host/uhci-hcd.c +++ b/drivers/usb/host/uhci-hcd.c | |||
@@ -59,7 +59,7 @@ | |||
59 | #define DRIVER_DESC "USB Universal Host Controller Interface driver" | 59 | #define DRIVER_DESC "USB Universal Host Controller Interface driver" |
60 | 60 | ||
61 | /* for flakey hardware, ignore overcurrent indicators */ | 61 | /* for flakey hardware, ignore overcurrent indicators */ |
62 | static int ignore_oc; | 62 | static bool ignore_oc; |
63 | module_param(ignore_oc, bool, S_IRUGO); | 63 | module_param(ignore_oc, bool, S_IRUGO); |
64 | MODULE_PARM_DESC(ignore_oc, "ignore hardware overcurrent indications"); | 64 | MODULE_PARM_DESC(ignore_oc, "ignore hardware overcurrent indications"); |
65 | 65 | ||
diff --git a/drivers/usb/host/uhci-q.c b/drivers/usb/host/uhci-q.c index f6ca80ee4cec..d2c6f5ac4626 100644 --- a/drivers/usb/host/uhci-q.c +++ b/drivers/usb/host/uhci-q.c | |||
@@ -943,7 +943,7 @@ static int uhci_submit_common(struct uhci_hcd *uhci, struct urb *urb, | |||
943 | if (usb_pipein(urb->pipe)) | 943 | if (usb_pipein(urb->pipe)) |
944 | status |= TD_CTRL_SPD; | 944 | status |= TD_CTRL_SPD; |
945 | 945 | ||
946 | i = urb->num_sgs; | 946 | i = urb->num_mapped_sgs; |
947 | if (len > 0 && i > 0) { | 947 | if (len > 0 && i > 0) { |
948 | sg = urb->sg; | 948 | sg = urb->sg; |
949 | data = sg_dma_address(sg); | 949 | data = sg_dma_address(sg); |
diff --git a/drivers/usb/host/whci/qset.c b/drivers/usb/host/whci/qset.c index d6e175428618..76083ae92138 100644 --- a/drivers/usb/host/whci/qset.c +++ b/drivers/usb/host/whci/qset.c | |||
@@ -124,7 +124,7 @@ void qset_clear(struct whc *whc, struct whc_qset *qset) | |||
124 | { | 124 | { |
125 | qset->td_start = qset->td_end = qset->ntds = 0; | 125 | qset->td_start = qset->td_end = qset->ntds = 0; |
126 | 126 | ||
127 | qset->qh.link = cpu_to_le32(QH_LINK_NTDS(8) | QH_LINK_T); | 127 | qset->qh.link = cpu_to_le64(QH_LINK_NTDS(8) | QH_LINK_T); |
128 | qset->qh.status = qset->qh.status & QH_STATUS_SEQ_MASK; | 128 | qset->qh.status = qset->qh.status & QH_STATUS_SEQ_MASK; |
129 | qset->qh.err_count = 0; | 129 | qset->qh.err_count = 0; |
130 | qset->qh.scratch[0] = 0; | 130 | qset->qh.scratch[0] = 0; |
@@ -443,7 +443,7 @@ static int qset_add_urb_sg(struct whc *whc, struct whc_qset *qset, struct urb *u | |||
443 | 443 | ||
444 | remaining = urb->transfer_buffer_length; | 444 | remaining = urb->transfer_buffer_length; |
445 | 445 | ||
446 | for_each_sg(urb->sg, sg, urb->num_sgs, i) { | 446 | for_each_sg(urb->sg, sg, urb->num_mapped_sgs, i) { |
447 | dma_addr_t dma_addr; | 447 | dma_addr_t dma_addr; |
448 | size_t dma_remaining; | 448 | size_t dma_remaining; |
449 | dma_addr_t sp, ep; | 449 | dma_addr_t sp, ep; |
@@ -561,7 +561,7 @@ static int qset_add_urb_sg_linearize(struct whc *whc, struct whc_qset *qset, | |||
561 | 561 | ||
562 | remaining = urb->transfer_buffer_length; | 562 | remaining = urb->transfer_buffer_length; |
563 | 563 | ||
564 | for_each_sg(urb->sg, sg, urb->num_sgs, i) { | 564 | for_each_sg(urb->sg, sg, urb->num_mapped_sgs, i) { |
565 | size_t len; | 565 | size_t len; |
566 | size_t sg_remaining; | 566 | size_t sg_remaining; |
567 | void *orig; | 567 | void *orig; |
diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c index 430e88fd3f6c..35e257f79c7b 100644 --- a/drivers/usb/host/xhci-hub.c +++ b/drivers/usb/host/xhci-hub.c | |||
@@ -57,17 +57,15 @@ static void xhci_common_hub_descriptor(struct xhci_hcd *xhci, | |||
57 | desc->bHubContrCurrent = 0; | 57 | desc->bHubContrCurrent = 0; |
58 | 58 | ||
59 | desc->bNbrPorts = ports; | 59 | desc->bNbrPorts = ports; |
60 | /* Ugh, these should be #defines, FIXME */ | ||
61 | /* Using table 11-13 in USB 2.0 spec. */ | ||
62 | temp = 0; | 60 | temp = 0; |
63 | /* Bits 1:0 - support port power switching, or power always on */ | 61 | /* Bits 1:0 - support per-port power switching, or power always on */ |
64 | if (HCC_PPC(xhci->hcc_params)) | 62 | if (HCC_PPC(xhci->hcc_params)) |
65 | temp |= 0x0001; | 63 | temp |= HUB_CHAR_INDV_PORT_LPSM; |
66 | else | 64 | else |
67 | temp |= 0x0002; | 65 | temp |= HUB_CHAR_NO_LPSM; |
68 | /* Bit 2 - root hubs are not part of a compound device */ | 66 | /* Bit 2 - root hubs are not part of a compound device */ |
69 | /* Bits 4:3 - individual port over current protection */ | 67 | /* Bits 4:3 - individual port over current protection */ |
70 | temp |= 0x0008; | 68 | temp |= HUB_CHAR_INDV_PORT_OCPM; |
71 | /* Bits 6:5 - no TTs in root ports */ | 69 | /* Bits 6:5 - no TTs in root ports */ |
72 | /* Bit 7 - no port indicators */ | 70 | /* Bit 7 - no port indicators */ |
73 | desc->wHubCharacteristics = cpu_to_le16(temp); | 71 | desc->wHubCharacteristics = cpu_to_le16(temp); |
@@ -86,9 +84,9 @@ static void xhci_usb2_hub_descriptor(struct usb_hcd *hcd, struct xhci_hcd *xhci, | |||
86 | ports = xhci->num_usb2_ports; | 84 | ports = xhci->num_usb2_ports; |
87 | 85 | ||
88 | xhci_common_hub_descriptor(xhci, desc, ports); | 86 | xhci_common_hub_descriptor(xhci, desc, ports); |
89 | desc->bDescriptorType = 0x29; | 87 | desc->bDescriptorType = USB_DT_HUB; |
90 | temp = 1 + (ports / 8); | 88 | temp = 1 + (ports / 8); |
91 | desc->bDescLength = 7 + 2 * temp; | 89 | desc->bDescLength = USB_DT_HUB_NONVAR_SIZE + 2 * temp; |
92 | 90 | ||
93 | /* The Device Removable bits are reported on a byte granularity. | 91 | /* The Device Removable bits are reported on a byte granularity. |
94 | * If the port doesn't exist within that byte, the bit is set to 0. | 92 | * If the port doesn't exist within that byte, the bit is set to 0. |
@@ -137,8 +135,8 @@ static void xhci_usb3_hub_descriptor(struct usb_hcd *hcd, struct xhci_hcd *xhci, | |||
137 | 135 | ||
138 | ports = xhci->num_usb3_ports; | 136 | ports = xhci->num_usb3_ports; |
139 | xhci_common_hub_descriptor(xhci, desc, ports); | 137 | xhci_common_hub_descriptor(xhci, desc, ports); |
140 | desc->bDescriptorType = 0x2a; | 138 | desc->bDescriptorType = USB_DT_SS_HUB; |
141 | desc->bDescLength = 12; | 139 | desc->bDescLength = USB_DT_SS_HUB_SIZE; |
142 | 140 | ||
143 | /* header decode latency should be zero for roothubs, | 141 | /* header decode latency should be zero for roothubs, |
144 | * see section 4.23.5.2. | 142 | * see section 4.23.5.2. |
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index 42a22b8e6922..36cbe2226a44 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c | |||
@@ -42,15 +42,12 @@ static struct xhci_segment *xhci_segment_alloc(struct xhci_hcd *xhci, gfp_t flag | |||
42 | seg = kzalloc(sizeof *seg, flags); | 42 | seg = kzalloc(sizeof *seg, flags); |
43 | if (!seg) | 43 | if (!seg) |
44 | return NULL; | 44 | return NULL; |
45 | xhci_dbg(xhci, "Allocating priv segment structure at %p\n", seg); | ||
46 | 45 | ||
47 | seg->trbs = dma_pool_alloc(xhci->segment_pool, flags, &dma); | 46 | seg->trbs = dma_pool_alloc(xhci->segment_pool, flags, &dma); |
48 | if (!seg->trbs) { | 47 | if (!seg->trbs) { |
49 | kfree(seg); | 48 | kfree(seg); |
50 | return NULL; | 49 | return NULL; |
51 | } | 50 | } |
52 | xhci_dbg(xhci, "// Allocating segment at %p (virtual) 0x%llx (DMA)\n", | ||
53 | seg->trbs, (unsigned long long)dma); | ||
54 | 51 | ||
55 | memset(seg->trbs, 0, SEGMENT_SIZE); | 52 | memset(seg->trbs, 0, SEGMENT_SIZE); |
56 | seg->dma = dma; | 53 | seg->dma = dma; |
@@ -62,12 +59,9 @@ static struct xhci_segment *xhci_segment_alloc(struct xhci_hcd *xhci, gfp_t flag | |||
62 | static void xhci_segment_free(struct xhci_hcd *xhci, struct xhci_segment *seg) | 59 | static void xhci_segment_free(struct xhci_hcd *xhci, struct xhci_segment *seg) |
63 | { | 60 | { |
64 | if (seg->trbs) { | 61 | if (seg->trbs) { |
65 | xhci_dbg(xhci, "Freeing DMA segment at %p (virtual) 0x%llx (DMA)\n", | ||
66 | seg->trbs, (unsigned long long)seg->dma); | ||
67 | dma_pool_free(xhci->segment_pool, seg->trbs, seg->dma); | 62 | dma_pool_free(xhci->segment_pool, seg->trbs, seg->dma); |
68 | seg->trbs = NULL; | 63 | seg->trbs = NULL; |
69 | } | 64 | } |
70 | xhci_dbg(xhci, "Freeing priv segment structure at %p\n", seg); | ||
71 | kfree(seg); | 65 | kfree(seg); |
72 | } | 66 | } |
73 | 67 | ||
@@ -101,9 +95,6 @@ static void xhci_link_segments(struct xhci_hcd *xhci, struct xhci_segment *prev, | |||
101 | val |= TRB_CHAIN; | 95 | val |= TRB_CHAIN; |
102 | prev->trbs[TRBS_PER_SEGMENT-1].link.control = cpu_to_le32(val); | 96 | prev->trbs[TRBS_PER_SEGMENT-1].link.control = cpu_to_le32(val); |
103 | } | 97 | } |
104 | xhci_dbg(xhci, "Linking segment 0x%llx to segment 0x%llx (DMA)\n", | ||
105 | (unsigned long long)prev->dma, | ||
106 | (unsigned long long)next->dma); | ||
107 | } | 98 | } |
108 | 99 | ||
109 | /* XXX: Do we need the hcd structure in all these functions? */ | 100 | /* XXX: Do we need the hcd structure in all these functions? */ |
@@ -117,7 +108,6 @@ void xhci_ring_free(struct xhci_hcd *xhci, struct xhci_ring *ring) | |||
117 | if (ring->first_seg) { | 108 | if (ring->first_seg) { |
118 | first_seg = ring->first_seg; | 109 | first_seg = ring->first_seg; |
119 | seg = first_seg->next; | 110 | seg = first_seg->next; |
120 | xhci_dbg(xhci, "Freeing ring at %p\n", ring); | ||
121 | while (seg != first_seg) { | 111 | while (seg != first_seg) { |
122 | struct xhci_segment *next = seg->next; | 112 | struct xhci_segment *next = seg->next; |
123 | xhci_segment_free(xhci, seg); | 113 | xhci_segment_free(xhci, seg); |
@@ -160,7 +150,6 @@ static struct xhci_ring *xhci_ring_alloc(struct xhci_hcd *xhci, | |||
160 | struct xhci_segment *prev; | 150 | struct xhci_segment *prev; |
161 | 151 | ||
162 | ring = kzalloc(sizeof *(ring), flags); | 152 | ring = kzalloc(sizeof *(ring), flags); |
163 | xhci_dbg(xhci, "Allocating ring at %p\n", ring); | ||
164 | if (!ring) | 153 | if (!ring) |
165 | return NULL; | 154 | return NULL; |
166 | 155 | ||
@@ -191,9 +180,6 @@ static struct xhci_ring *xhci_ring_alloc(struct xhci_hcd *xhci, | |||
191 | /* See section 4.9.2.1 and 6.4.4.1 */ | 180 | /* See section 4.9.2.1 and 6.4.4.1 */ |
192 | prev->trbs[TRBS_PER_SEGMENT-1].link.control |= | 181 | prev->trbs[TRBS_PER_SEGMENT-1].link.control |= |
193 | cpu_to_le32(LINK_TOGGLE); | 182 | cpu_to_le32(LINK_TOGGLE); |
194 | xhci_dbg(xhci, "Wrote link toggle flag to" | ||
195 | " segment %p (virtual), 0x%llx (DMA)\n", | ||
196 | prev, (unsigned long long)prev->dma); | ||
197 | } | 183 | } |
198 | xhci_initialize_ring_info(ring); | 184 | xhci_initialize_ring_info(ring); |
199 | return ring; | 185 | return ring; |
@@ -982,7 +968,6 @@ int xhci_setup_addressable_virt_dev(struct xhci_hcd *xhci, struct usb_device *ud | |||
982 | struct xhci_virt_device *dev; | 968 | struct xhci_virt_device *dev; |
983 | struct xhci_ep_ctx *ep0_ctx; | 969 | struct xhci_ep_ctx *ep0_ctx; |
984 | struct xhci_slot_ctx *slot_ctx; | 970 | struct xhci_slot_ctx *slot_ctx; |
985 | struct xhci_input_control_ctx *ctrl_ctx; | ||
986 | u32 port_num; | 971 | u32 port_num; |
987 | struct usb_device *top_dev; | 972 | struct usb_device *top_dev; |
988 | 973 | ||
@@ -994,12 +979,8 @@ int xhci_setup_addressable_virt_dev(struct xhci_hcd *xhci, struct usb_device *ud | |||
994 | return -EINVAL; | 979 | return -EINVAL; |
995 | } | 980 | } |
996 | ep0_ctx = xhci_get_ep_ctx(xhci, dev->in_ctx, 0); | 981 | ep0_ctx = xhci_get_ep_ctx(xhci, dev->in_ctx, 0); |
997 | ctrl_ctx = xhci_get_input_control_ctx(xhci, dev->in_ctx); | ||
998 | slot_ctx = xhci_get_slot_ctx(xhci, dev->in_ctx); | 982 | slot_ctx = xhci_get_slot_ctx(xhci, dev->in_ctx); |
999 | 983 | ||
1000 | /* 2) New slot context and endpoint 0 context are valid*/ | ||
1001 | ctrl_ctx->add_flags = cpu_to_le32(SLOT_FLAG | EP0_FLAG); | ||
1002 | |||
1003 | /* 3) Only the control endpoint is valid - one endpoint context */ | 984 | /* 3) Only the control endpoint is valid - one endpoint context */ |
1004 | slot_ctx->dev_info |= cpu_to_le32(LAST_CTX(1) | udev->route); | 985 | slot_ctx->dev_info |= cpu_to_le32(LAST_CTX(1) | udev->route); |
1005 | switch (udev->speed) { | 986 | switch (udev->speed) { |
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 940321b3ec68..b90e1386418b 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c | |||
@@ -155,10 +155,6 @@ static void inc_deq(struct xhci_hcd *xhci, struct xhci_ring *ring, bool consumer | |||
155 | while (last_trb(xhci, ring, ring->deq_seg, next)) { | 155 | while (last_trb(xhci, ring, ring->deq_seg, next)) { |
156 | if (consumer && last_trb_on_last_seg(xhci, ring, ring->deq_seg, next)) { | 156 | if (consumer && last_trb_on_last_seg(xhci, ring, ring->deq_seg, next)) { |
157 | ring->cycle_state = (ring->cycle_state ? 0 : 1); | 157 | ring->cycle_state = (ring->cycle_state ? 0 : 1); |
158 | if (!in_interrupt()) | ||
159 | xhci_dbg(xhci, "Toggle cycle state for ring %p = %i\n", | ||
160 | ring, | ||
161 | (unsigned int) ring->cycle_state); | ||
162 | } | 158 | } |
163 | ring->deq_seg = ring->deq_seg->next; | 159 | ring->deq_seg = ring->deq_seg->next; |
164 | ring->dequeue = ring->deq_seg->trbs; | 160 | ring->dequeue = ring->deq_seg->trbs; |
@@ -231,10 +227,6 @@ static void inc_enq(struct xhci_hcd *xhci, struct xhci_ring *ring, | |||
231 | /* Toggle the cycle bit after the last ring segment. */ | 227 | /* Toggle the cycle bit after the last ring segment. */ |
232 | if (last_trb_on_last_seg(xhci, ring, ring->enq_seg, next)) { | 228 | if (last_trb_on_last_seg(xhci, ring, ring->enq_seg, next)) { |
233 | ring->cycle_state = (ring->cycle_state ? 0 : 1); | 229 | ring->cycle_state = (ring->cycle_state ? 0 : 1); |
234 | if (!in_interrupt()) | ||
235 | xhci_dbg(xhci, "Toggle cycle state for ring %p = %i\n", | ||
236 | ring, | ||
237 | (unsigned int) ring->cycle_state); | ||
238 | } | 230 | } |
239 | } | 231 | } |
240 | ring->enq_seg = ring->enq_seg->next; | 232 | ring->enq_seg = ring->enq_seg->next; |
@@ -560,12 +552,9 @@ static void td_to_noop(struct xhci_hcd *xhci, struct xhci_ring *ep_ring, | |||
560 | cpu_to_le32(TRB_CYCLE); | 552 | cpu_to_le32(TRB_CYCLE); |
561 | cur_trb->generic.field[3] |= cpu_to_le32( | 553 | cur_trb->generic.field[3] |= cpu_to_le32( |
562 | TRB_TYPE(TRB_TR_NOOP)); | 554 | TRB_TYPE(TRB_TR_NOOP)); |
563 | xhci_dbg(xhci, "Cancel TRB %p (0x%llx dma) " | 555 | xhci_dbg(xhci, "TRB to noop at offset 0x%llx\n", |
564 | "in seg %p (0x%llx dma)\n", | 556 | (unsigned long long) |
565 | cur_trb, | 557 | xhci_trb_virt_to_dma(cur_seg, cur_trb)); |
566 | (unsigned long long)xhci_trb_virt_to_dma(cur_seg, cur_trb), | ||
567 | cur_seg, | ||
568 | (unsigned long long)cur_seg->dma); | ||
569 | } | 558 | } |
570 | if (cur_trb == cur_td->last_trb) | 559 | if (cur_trb == cur_td->last_trb) |
571 | break; | 560 | break; |
@@ -705,9 +694,9 @@ static void handle_stopped_endpoint(struct xhci_hcd *xhci, | |||
705 | */ | 694 | */ |
706 | list_for_each(entry, &ep->cancelled_td_list) { | 695 | list_for_each(entry, &ep->cancelled_td_list) { |
707 | cur_td = list_entry(entry, struct xhci_td, cancelled_td_list); | 696 | cur_td = list_entry(entry, struct xhci_td, cancelled_td_list); |
708 | xhci_dbg(xhci, "Cancelling TD starting at %p, 0x%llx (dma).\n", | 697 | xhci_dbg(xhci, "Removing canceled TD starting at 0x%llx (dma).\n", |
709 | cur_td->first_trb, | 698 | (unsigned long long)xhci_trb_virt_to_dma( |
710 | (unsigned long long)xhci_trb_virt_to_dma(cur_td->start_seg, cur_td->first_trb)); | 699 | cur_td->start_seg, cur_td->first_trb)); |
711 | ep_ring = xhci_urb_to_transfer_ring(xhci, cur_td->urb); | 700 | ep_ring = xhci_urb_to_transfer_ring(xhci, cur_td->urb); |
712 | if (!ep_ring) { | 701 | if (!ep_ring) { |
713 | /* This shouldn't happen unless a driver is mucking | 702 | /* This shouldn't happen unless a driver is mucking |
@@ -816,23 +805,24 @@ void xhci_stop_endpoint_command_watchdog(unsigned long arg) | |||
816 | struct xhci_ring *ring; | 805 | struct xhci_ring *ring; |
817 | struct xhci_td *cur_td; | 806 | struct xhci_td *cur_td; |
818 | int ret, i, j; | 807 | int ret, i, j; |
808 | unsigned long flags; | ||
819 | 809 | ||
820 | ep = (struct xhci_virt_ep *) arg; | 810 | ep = (struct xhci_virt_ep *) arg; |
821 | xhci = ep->xhci; | 811 | xhci = ep->xhci; |
822 | 812 | ||
823 | spin_lock(&xhci->lock); | 813 | spin_lock_irqsave(&xhci->lock, flags); |
824 | 814 | ||
825 | ep->stop_cmds_pending--; | 815 | ep->stop_cmds_pending--; |
826 | if (xhci->xhc_state & XHCI_STATE_DYING) { | 816 | if (xhci->xhc_state & XHCI_STATE_DYING) { |
827 | xhci_dbg(xhci, "Stop EP timer ran, but another timer marked " | 817 | xhci_dbg(xhci, "Stop EP timer ran, but another timer marked " |
828 | "xHCI as DYING, exiting.\n"); | 818 | "xHCI as DYING, exiting.\n"); |
829 | spin_unlock(&xhci->lock); | 819 | spin_unlock_irqrestore(&xhci->lock, flags); |
830 | return; | 820 | return; |
831 | } | 821 | } |
832 | if (!(ep->stop_cmds_pending == 0 && (ep->ep_state & EP_HALT_PENDING))) { | 822 | if (!(ep->stop_cmds_pending == 0 && (ep->ep_state & EP_HALT_PENDING))) { |
833 | xhci_dbg(xhci, "Stop EP timer ran, but no command pending, " | 823 | xhci_dbg(xhci, "Stop EP timer ran, but no command pending, " |
834 | "exiting.\n"); | 824 | "exiting.\n"); |
835 | spin_unlock(&xhci->lock); | 825 | spin_unlock_irqrestore(&xhci->lock, flags); |
836 | return; | 826 | return; |
837 | } | 827 | } |
838 | 828 | ||
@@ -844,11 +834,11 @@ void xhci_stop_endpoint_command_watchdog(unsigned long arg) | |||
844 | xhci->xhc_state |= XHCI_STATE_DYING; | 834 | xhci->xhc_state |= XHCI_STATE_DYING; |
845 | /* Disable interrupts from the host controller and start halting it */ | 835 | /* Disable interrupts from the host controller and start halting it */ |
846 | xhci_quiesce(xhci); | 836 | xhci_quiesce(xhci); |
847 | spin_unlock(&xhci->lock); | 837 | spin_unlock_irqrestore(&xhci->lock, flags); |
848 | 838 | ||
849 | ret = xhci_halt(xhci); | 839 | ret = xhci_halt(xhci); |
850 | 840 | ||
851 | spin_lock(&xhci->lock); | 841 | spin_lock_irqsave(&xhci->lock, flags); |
852 | if (ret < 0) { | 842 | if (ret < 0) { |
853 | /* This is bad; the host is not responding to commands and it's | 843 | /* This is bad; the host is not responding to commands and it's |
854 | * not allowing itself to be halted. At least interrupts are | 844 | * not allowing itself to be halted. At least interrupts are |
@@ -896,7 +886,7 @@ void xhci_stop_endpoint_command_watchdog(unsigned long arg) | |||
896 | } | 886 | } |
897 | } | 887 | } |
898 | } | 888 | } |
899 | spin_unlock(&xhci->lock); | 889 | spin_unlock_irqrestore(&xhci->lock, flags); |
900 | xhci_dbg(xhci, "Calling usb_hc_died()\n"); | 890 | xhci_dbg(xhci, "Calling usb_hc_died()\n"); |
901 | usb_hc_died(xhci_to_hcd(xhci)->primary_hcd); | 891 | usb_hc_died(xhci_to_hcd(xhci)->primary_hcd); |
902 | xhci_dbg(xhci, "xHCI host controller is dead.\n"); | 892 | xhci_dbg(xhci, "xHCI host controller is dead.\n"); |
@@ -1626,7 +1616,6 @@ static int process_ctrl_td(struct xhci_hcd *xhci, struct xhci_td *td, | |||
1626 | ep_ctx = xhci_get_ep_ctx(xhci, xdev->out_ctx, ep_index); | 1616 | ep_ctx = xhci_get_ep_ctx(xhci, xdev->out_ctx, ep_index); |
1627 | trb_comp_code = GET_COMP_CODE(le32_to_cpu(event->transfer_len)); | 1617 | trb_comp_code = GET_COMP_CODE(le32_to_cpu(event->transfer_len)); |
1628 | 1618 | ||
1629 | xhci_debug_trb(xhci, xhci->event_ring->dequeue); | ||
1630 | switch (trb_comp_code) { | 1619 | switch (trb_comp_code) { |
1631 | case COMP_SUCCESS: | 1620 | case COMP_SUCCESS: |
1632 | if (event_trb == ep_ring->dequeue) { | 1621 | if (event_trb == ep_ring->dequeue) { |
@@ -1642,7 +1631,6 @@ static int process_ctrl_td(struct xhci_hcd *xhci, struct xhci_td *td, | |||
1642 | } | 1631 | } |
1643 | break; | 1632 | break; |
1644 | case COMP_SHORT_TX: | 1633 | case COMP_SHORT_TX: |
1645 | xhci_warn(xhci, "WARN: short transfer on control ep\n"); | ||
1646 | if (td->urb->transfer_flags & URB_SHORT_NOT_OK) | 1634 | if (td->urb->transfer_flags & URB_SHORT_NOT_OK) |
1647 | *status = -EREMOTEIO; | 1635 | *status = -EREMOTEIO; |
1648 | else | 1636 | else |
@@ -1945,6 +1933,16 @@ static int handle_tx_event(struct xhci_hcd *xhci, | |||
1945 | xdev = xhci->devs[slot_id]; | 1933 | xdev = xhci->devs[slot_id]; |
1946 | if (!xdev) { | 1934 | if (!xdev) { |
1947 | xhci_err(xhci, "ERROR Transfer event pointed to bad slot\n"); | 1935 | xhci_err(xhci, "ERROR Transfer event pointed to bad slot\n"); |
1936 | xhci_err(xhci, "@%016llx %08x %08x %08x %08x\n", | ||
1937 | (unsigned long long) xhci_trb_virt_to_dma( | ||
1938 | xhci->event_ring->deq_seg, | ||
1939 | xhci->event_ring->dequeue), | ||
1940 | lower_32_bits(le64_to_cpu(event->buffer)), | ||
1941 | upper_32_bits(le64_to_cpu(event->buffer)), | ||
1942 | le32_to_cpu(event->transfer_len), | ||
1943 | le32_to_cpu(event->flags)); | ||
1944 | xhci_dbg(xhci, "Event ring:\n"); | ||
1945 | xhci_debug_segment(xhci, xhci->event_ring->deq_seg); | ||
1948 | return -ENODEV; | 1946 | return -ENODEV; |
1949 | } | 1947 | } |
1950 | 1948 | ||
@@ -1958,6 +1956,16 @@ static int handle_tx_event(struct xhci_hcd *xhci, | |||
1958 | EP_STATE_DISABLED) { | 1956 | EP_STATE_DISABLED) { |
1959 | xhci_err(xhci, "ERROR Transfer event for disabled endpoint " | 1957 | xhci_err(xhci, "ERROR Transfer event for disabled endpoint " |
1960 | "or incorrect stream ring\n"); | 1958 | "or incorrect stream ring\n"); |
1959 | xhci_err(xhci, "@%016llx %08x %08x %08x %08x\n", | ||
1960 | (unsigned long long) xhci_trb_virt_to_dma( | ||
1961 | xhci->event_ring->deq_seg, | ||
1962 | xhci->event_ring->dequeue), | ||
1963 | lower_32_bits(le64_to_cpu(event->buffer)), | ||
1964 | upper_32_bits(le64_to_cpu(event->buffer)), | ||
1965 | le32_to_cpu(event->transfer_len), | ||
1966 | le32_to_cpu(event->flags)); | ||
1967 | xhci_dbg(xhci, "Event ring:\n"); | ||
1968 | xhci_debug_segment(xhci, xhci->event_ring->deq_seg); | ||
1961 | return -ENODEV; | 1969 | return -ENODEV; |
1962 | } | 1970 | } |
1963 | 1971 | ||
@@ -1984,7 +1992,7 @@ static int handle_tx_event(struct xhci_hcd *xhci, | |||
1984 | xhci_dbg(xhci, "Stopped on No-op or Link TRB\n"); | 1992 | xhci_dbg(xhci, "Stopped on No-op or Link TRB\n"); |
1985 | break; | 1993 | break; |
1986 | case COMP_STALL: | 1994 | case COMP_STALL: |
1987 | xhci_warn(xhci, "WARN: Stalled endpoint\n"); | 1995 | xhci_dbg(xhci, "Stalled endpoint\n"); |
1988 | ep->ep_state |= EP_HALTED; | 1996 | ep->ep_state |= EP_HALTED; |
1989 | status = -EPIPE; | 1997 | status = -EPIPE; |
1990 | break; | 1998 | break; |
@@ -1994,11 +2002,11 @@ static int handle_tx_event(struct xhci_hcd *xhci, | |||
1994 | break; | 2002 | break; |
1995 | case COMP_SPLIT_ERR: | 2003 | case COMP_SPLIT_ERR: |
1996 | case COMP_TX_ERR: | 2004 | case COMP_TX_ERR: |
1997 | xhci_warn(xhci, "WARN: transfer error on endpoint\n"); | 2005 | xhci_dbg(xhci, "Transfer error on endpoint\n"); |
1998 | status = -EPROTO; | 2006 | status = -EPROTO; |
1999 | break; | 2007 | break; |
2000 | case COMP_BABBLE: | 2008 | case COMP_BABBLE: |
2001 | xhci_warn(xhci, "WARN: babble error on endpoint\n"); | 2009 | xhci_dbg(xhci, "Babble error on endpoint\n"); |
2002 | status = -EOVERFLOW; | 2010 | status = -EOVERFLOW; |
2003 | break; | 2011 | break; |
2004 | case COMP_DB_ERR: | 2012 | case COMP_DB_ERR: |
@@ -2389,17 +2397,7 @@ hw_died: | |||
2389 | 2397 | ||
2390 | irqreturn_t xhci_msi_irq(int irq, struct usb_hcd *hcd) | 2398 | irqreturn_t xhci_msi_irq(int irq, struct usb_hcd *hcd) |
2391 | { | 2399 | { |
2392 | irqreturn_t ret; | 2400 | return xhci_irq(hcd); |
2393 | struct xhci_hcd *xhci; | ||
2394 | |||
2395 | xhci = hcd_to_xhci(hcd); | ||
2396 | set_bit(HCD_FLAG_SAW_IRQ, &hcd->flags); | ||
2397 | if (xhci->shared_hcd) | ||
2398 | set_bit(HCD_FLAG_SAW_IRQ, &xhci->shared_hcd->flags); | ||
2399 | |||
2400 | ret = xhci_irq(hcd); | ||
2401 | |||
2402 | return ret; | ||
2403 | } | 2401 | } |
2404 | 2402 | ||
2405 | /**** Endpoint Ring Operations ****/ | 2403 | /**** Endpoint Ring Operations ****/ |
@@ -2487,11 +2485,6 @@ static int prepare_ring(struct xhci_hcd *xhci, struct xhci_ring *ep_ring, | |||
2487 | /* Toggle the cycle bit after the last ring segment. */ | 2485 | /* Toggle the cycle bit after the last ring segment. */ |
2488 | if (last_trb_on_last_seg(xhci, ring, ring->enq_seg, next)) { | 2486 | if (last_trb_on_last_seg(xhci, ring, ring->enq_seg, next)) { |
2489 | ring->cycle_state = (ring->cycle_state ? 0 : 1); | 2487 | ring->cycle_state = (ring->cycle_state ? 0 : 1); |
2490 | if (!in_interrupt()) { | ||
2491 | xhci_dbg(xhci, "queue_trb: Toggle cycle " | ||
2492 | "state for ring %p = %i\n", | ||
2493 | ring, (unsigned int)ring->cycle_state); | ||
2494 | } | ||
2495 | } | 2488 | } |
2496 | ring->enq_seg = ring->enq_seg->next; | 2489 | ring->enq_seg = ring->enq_seg->next; |
2497 | ring->enqueue = ring->enq_seg->trbs; | 2490 | ring->enqueue = ring->enq_seg->trbs; |
@@ -2560,13 +2553,11 @@ static unsigned int count_sg_trbs_needed(struct xhci_hcd *xhci, struct urb *urb) | |||
2560 | struct scatterlist *sg; | 2553 | struct scatterlist *sg; |
2561 | 2554 | ||
2562 | sg = NULL; | 2555 | sg = NULL; |
2563 | num_sgs = urb->num_sgs; | 2556 | num_sgs = urb->num_mapped_sgs; |
2564 | temp = urb->transfer_buffer_length; | 2557 | temp = urb->transfer_buffer_length; |
2565 | 2558 | ||
2566 | xhci_dbg(xhci, "count sg list trbs: \n"); | ||
2567 | num_trbs = 0; | 2559 | num_trbs = 0; |
2568 | for_each_sg(urb->sg, sg, num_sgs, i) { | 2560 | for_each_sg(urb->sg, sg, num_sgs, i) { |
2569 | unsigned int previous_total_trbs = num_trbs; | ||
2570 | unsigned int len = sg_dma_len(sg); | 2561 | unsigned int len = sg_dma_len(sg); |
2571 | 2562 | ||
2572 | /* Scatter gather list entries may cross 64KB boundaries */ | 2563 | /* Scatter gather list entries may cross 64KB boundaries */ |
@@ -2581,22 +2572,11 @@ static unsigned int count_sg_trbs_needed(struct xhci_hcd *xhci, struct urb *urb) | |||
2581 | num_trbs++; | 2572 | num_trbs++; |
2582 | running_total += TRB_MAX_BUFF_SIZE; | 2573 | running_total += TRB_MAX_BUFF_SIZE; |
2583 | } | 2574 | } |
2584 | xhci_dbg(xhci, " sg #%d: dma = %#llx, len = %#x (%d), num_trbs = %d\n", | ||
2585 | i, (unsigned long long)sg_dma_address(sg), | ||
2586 | len, len, num_trbs - previous_total_trbs); | ||
2587 | |||
2588 | len = min_t(int, len, temp); | 2575 | len = min_t(int, len, temp); |
2589 | temp -= len; | 2576 | temp -= len; |
2590 | if (temp == 0) | 2577 | if (temp == 0) |
2591 | break; | 2578 | break; |
2592 | } | 2579 | } |
2593 | xhci_dbg(xhci, "\n"); | ||
2594 | if (!in_interrupt()) | ||
2595 | xhci_dbg(xhci, "ep %#x - urb len = %d, sglist used, " | ||
2596 | "num_trbs = %d\n", | ||
2597 | urb->ep->desc.bEndpointAddress, | ||
2598 | urb->transfer_buffer_length, | ||
2599 | num_trbs); | ||
2600 | return num_trbs; | 2580 | return num_trbs; |
2601 | } | 2581 | } |
2602 | 2582 | ||
@@ -2744,7 +2724,7 @@ static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
2744 | return -EINVAL; | 2724 | return -EINVAL; |
2745 | 2725 | ||
2746 | num_trbs = count_sg_trbs_needed(xhci, urb); | 2726 | num_trbs = count_sg_trbs_needed(xhci, urb); |
2747 | num_sgs = urb->num_sgs; | 2727 | num_sgs = urb->num_mapped_sgs; |
2748 | total_packet_count = roundup(urb->transfer_buffer_length, | 2728 | total_packet_count = roundup(urb->transfer_buffer_length, |
2749 | usb_endpoint_maxp(&urb->ep->desc)); | 2729 | usb_endpoint_maxp(&urb->ep->desc)); |
2750 | 2730 | ||
@@ -2782,8 +2762,6 @@ static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
2782 | trb_buff_len = min_t(int, trb_buff_len, this_sg_len); | 2762 | trb_buff_len = min_t(int, trb_buff_len, this_sg_len); |
2783 | if (trb_buff_len > urb->transfer_buffer_length) | 2763 | if (trb_buff_len > urb->transfer_buffer_length) |
2784 | trb_buff_len = urb->transfer_buffer_length; | 2764 | trb_buff_len = urb->transfer_buffer_length; |
2785 | xhci_dbg(xhci, "First length to xfer from 1st sglist entry = %u\n", | ||
2786 | trb_buff_len); | ||
2787 | 2765 | ||
2788 | first_trb = true; | 2766 | first_trb = true; |
2789 | /* Queue the first TRB, even if it's zero-length */ | 2767 | /* Queue the first TRB, even if it's zero-length */ |
@@ -2815,11 +2793,6 @@ static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
2815 | if (usb_urb_dir_in(urb)) | 2793 | if (usb_urb_dir_in(urb)) |
2816 | field |= TRB_ISP; | 2794 | field |= TRB_ISP; |
2817 | 2795 | ||
2818 | xhci_dbg(xhci, " sg entry: dma = %#x, len = %#x (%d), " | ||
2819 | "64KB boundary at %#x, end dma = %#x\n", | ||
2820 | (unsigned int) addr, trb_buff_len, trb_buff_len, | ||
2821 | (unsigned int) (addr + TRB_MAX_BUFF_SIZE) & ~(TRB_MAX_BUFF_SIZE - 1), | ||
2822 | (unsigned int) addr + trb_buff_len); | ||
2823 | if (TRB_MAX_BUFF_SIZE - | 2796 | if (TRB_MAX_BUFF_SIZE - |
2824 | (addr & (TRB_MAX_BUFF_SIZE - 1)) < trb_buff_len) { | 2797 | (addr & (TRB_MAX_BUFF_SIZE - 1)) < trb_buff_len) { |
2825 | xhci_warn(xhci, "WARN: sg dma xfer crosses 64KB boundaries!\n"); | 2798 | xhci_warn(xhci, "WARN: sg dma xfer crosses 64KB boundaries!\n"); |
@@ -2925,15 +2898,6 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
2925 | } | 2898 | } |
2926 | /* FIXME: this doesn't deal with URB_ZERO_PACKET - need one more */ | 2899 | /* FIXME: this doesn't deal with URB_ZERO_PACKET - need one more */ |
2927 | 2900 | ||
2928 | if (!in_interrupt()) | ||
2929 | xhci_dbg(xhci, "ep %#x - urb len = %#x (%d), " | ||
2930 | "addr = %#llx, num_trbs = %d\n", | ||
2931 | urb->ep->desc.bEndpointAddress, | ||
2932 | urb->transfer_buffer_length, | ||
2933 | urb->transfer_buffer_length, | ||
2934 | (unsigned long long)urb->transfer_dma, | ||
2935 | num_trbs); | ||
2936 | |||
2937 | ret = prepare_transfer(xhci, xhci->devs[slot_id], | 2901 | ret = prepare_transfer(xhci, xhci->devs[slot_id], |
2938 | ep_index, urb->stream_id, | 2902 | ep_index, urb->stream_id, |
2939 | num_trbs, urb, 0, false, mem_flags); | 2903 | num_trbs, urb, 0, false, mem_flags); |
@@ -3054,9 +3018,6 @@ int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
3054 | if (!urb->setup_packet) | 3018 | if (!urb->setup_packet) |
3055 | return -EINVAL; | 3019 | return -EINVAL; |
3056 | 3020 | ||
3057 | if (!in_interrupt()) | ||
3058 | xhci_dbg(xhci, "Queueing ctrl tx for slot id %d, ep %d\n", | ||
3059 | slot_id, ep_index); | ||
3060 | /* 1 TRB for setup, 1 for status */ | 3021 | /* 1 TRB for setup, 1 for status */ |
3061 | num_trbs = 2; | 3022 | num_trbs = 2; |
3062 | /* | 3023 | /* |
@@ -3248,15 +3209,6 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
3248 | return -EINVAL; | 3209 | return -EINVAL; |
3249 | } | 3210 | } |
3250 | 3211 | ||
3251 | if (!in_interrupt()) | ||
3252 | xhci_dbg(xhci, "ep %#x - urb len = %#x (%d)," | ||
3253 | " addr = %#llx, num_tds = %d\n", | ||
3254 | urb->ep->desc.bEndpointAddress, | ||
3255 | urb->transfer_buffer_length, | ||
3256 | urb->transfer_buffer_length, | ||
3257 | (unsigned long long)urb->transfer_dma, | ||
3258 | num_tds); | ||
3259 | |||
3260 | start_addr = (u64) urb->transfer_dma; | 3212 | start_addr = (u64) urb->transfer_dma; |
3261 | start_trb = &ep_ring->enqueue->generic; | 3213 | start_trb = &ep_ring->enqueue->generic; |
3262 | start_cycle = ep_ring->cycle_state; | 3214 | start_cycle = ep_ring->cycle_state; |
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 1ff95a0df576..6bbe3c3a7111 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c | |||
@@ -200,14 +200,14 @@ static int xhci_setup_msi(struct xhci_hcd *xhci) | |||
200 | 200 | ||
201 | ret = pci_enable_msi(pdev); | 201 | ret = pci_enable_msi(pdev); |
202 | if (ret) { | 202 | if (ret) { |
203 | xhci_err(xhci, "failed to allocate MSI entry\n"); | 203 | xhci_dbg(xhci, "failed to allocate MSI entry\n"); |
204 | return ret; | 204 | return ret; |
205 | } | 205 | } |
206 | 206 | ||
207 | ret = request_irq(pdev->irq, (irq_handler_t)xhci_msi_irq, | 207 | ret = request_irq(pdev->irq, (irq_handler_t)xhci_msi_irq, |
208 | 0, "xhci_hcd", xhci_to_hcd(xhci)); | 208 | 0, "xhci_hcd", xhci_to_hcd(xhci)); |
209 | if (ret) { | 209 | if (ret) { |
210 | xhci_err(xhci, "disable MSI interrupt\n"); | 210 | xhci_dbg(xhci, "disable MSI interrupt\n"); |
211 | pci_disable_msi(pdev); | 211 | pci_disable_msi(pdev); |
212 | } | 212 | } |
213 | 213 | ||
@@ -270,7 +270,7 @@ static int xhci_setup_msix(struct xhci_hcd *xhci) | |||
270 | 270 | ||
271 | ret = pci_enable_msix(pdev, xhci->msix_entries, xhci->msix_count); | 271 | ret = pci_enable_msix(pdev, xhci->msix_entries, xhci->msix_count); |
272 | if (ret) { | 272 | if (ret) { |
273 | xhci_err(xhci, "Failed to enable MSI-X\n"); | 273 | xhci_dbg(xhci, "Failed to enable MSI-X\n"); |
274 | goto free_entries; | 274 | goto free_entries; |
275 | } | 275 | } |
276 | 276 | ||
@@ -286,7 +286,7 @@ static int xhci_setup_msix(struct xhci_hcd *xhci) | |||
286 | return ret; | 286 | return ret; |
287 | 287 | ||
288 | disable_msix: | 288 | disable_msix: |
289 | xhci_err(xhci, "disable MSI-X interrupt\n"); | 289 | xhci_dbg(xhci, "disable MSI-X interrupt\n"); |
290 | xhci_free_irq(xhci); | 290 | xhci_free_irq(xhci); |
291 | pci_disable_msix(pdev); | 291 | pci_disable_msix(pdev); |
292 | free_entries: | 292 | free_entries: |
@@ -711,7 +711,10 @@ static void xhci_clear_command_ring(struct xhci_hcd *xhci) | |||
711 | ring = xhci->cmd_ring; | 711 | ring = xhci->cmd_ring; |
712 | seg = ring->deq_seg; | 712 | seg = ring->deq_seg; |
713 | do { | 713 | do { |
714 | memset(seg->trbs, 0, SEGMENT_SIZE); | 714 | memset(seg->trbs, 0, |
715 | sizeof(union xhci_trb) * (TRBS_PER_SEGMENT - 1)); | ||
716 | seg->trbs[TRBS_PER_SEGMENT - 1].link.control &= | ||
717 | cpu_to_le32(~TRB_CYCLE); | ||
715 | seg = seg->next; | 718 | seg = seg->next; |
716 | } while (seg != ring->deq_seg); | 719 | } while (seg != ring->deq_seg); |
717 | 720 | ||
@@ -799,7 +802,7 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated) | |||
799 | u32 command, temp = 0; | 802 | u32 command, temp = 0; |
800 | struct usb_hcd *hcd = xhci_to_hcd(xhci); | 803 | struct usb_hcd *hcd = xhci_to_hcd(xhci); |
801 | struct usb_hcd *secondary_hcd; | 804 | struct usb_hcd *secondary_hcd; |
802 | int retval; | 805 | int retval = 0; |
803 | 806 | ||
804 | /* Wait a bit if either of the roothubs need to settle from the | 807 | /* Wait a bit if either of the roothubs need to settle from the |
805 | * transition into bus suspend. | 808 | * transition into bus suspend. |
@@ -809,6 +812,9 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated) | |||
809 | xhci->bus_state[1].next_statechange)) | 812 | xhci->bus_state[1].next_statechange)) |
810 | msleep(100); | 813 | msleep(100); |
811 | 814 | ||
815 | set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); | ||
816 | set_bit(HCD_FLAG_HW_ACCESSIBLE, &xhci->shared_hcd->flags); | ||
817 | |||
812 | spin_lock_irq(&xhci->lock); | 818 | spin_lock_irq(&xhci->lock); |
813 | if (xhci->quirks & XHCI_RESET_ON_RESUME) | 819 | if (xhci->quirks & XHCI_RESET_ON_RESUME) |
814 | hibernated = true; | 820 | hibernated = true; |
@@ -878,20 +884,13 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated) | |||
878 | return retval; | 884 | return retval; |
879 | xhci_dbg(xhci, "Start the primary HCD\n"); | 885 | xhci_dbg(xhci, "Start the primary HCD\n"); |
880 | retval = xhci_run(hcd->primary_hcd); | 886 | retval = xhci_run(hcd->primary_hcd); |
881 | if (retval) | ||
882 | goto failed_restart; | ||
883 | |||
884 | xhci_dbg(xhci, "Start the secondary HCD\n"); | ||
885 | retval = xhci_run(secondary_hcd); | ||
886 | if (!retval) { | 887 | if (!retval) { |
887 | set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); | 888 | xhci_dbg(xhci, "Start the secondary HCD\n"); |
888 | set_bit(HCD_FLAG_HW_ACCESSIBLE, | 889 | retval = xhci_run(secondary_hcd); |
889 | &xhci->shared_hcd->flags); | ||
890 | } | 890 | } |
891 | failed_restart: | ||
892 | hcd->state = HC_STATE_SUSPENDED; | 891 | hcd->state = HC_STATE_SUSPENDED; |
893 | xhci->shared_hcd->state = HC_STATE_SUSPENDED; | 892 | xhci->shared_hcd->state = HC_STATE_SUSPENDED; |
894 | return retval; | 893 | goto done; |
895 | } | 894 | } |
896 | 895 | ||
897 | /* step 4: set Run/Stop bit */ | 896 | /* step 4: set Run/Stop bit */ |
@@ -910,11 +909,14 @@ failed_restart: | |||
910 | * Running endpoints by ringing their doorbells | 909 | * Running endpoints by ringing their doorbells |
911 | */ | 910 | */ |
912 | 911 | ||
913 | set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); | ||
914 | set_bit(HCD_FLAG_HW_ACCESSIBLE, &xhci->shared_hcd->flags); | ||
915 | |||
916 | spin_unlock_irq(&xhci->lock); | 912 | spin_unlock_irq(&xhci->lock); |
917 | return 0; | 913 | |
914 | done: | ||
915 | if (retval == 0) { | ||
916 | usb_hcd_resume_root_hub(hcd); | ||
917 | usb_hcd_resume_root_hub(xhci->shared_hcd); | ||
918 | } | ||
919 | return retval; | ||
918 | } | 920 | } |
919 | #endif /* CONFIG_PM */ | 921 | #endif /* CONFIG_PM */ |
920 | 922 | ||
@@ -1331,9 +1333,6 @@ int xhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) | |||
1331 | goto done; | 1333 | goto done; |
1332 | } | 1334 | } |
1333 | 1335 | ||
1334 | xhci_dbg(xhci, "Cancel URB %p\n", urb); | ||
1335 | xhci_dbg(xhci, "Event ring:\n"); | ||
1336 | xhci_debug_ring(xhci, xhci->event_ring); | ||
1337 | ep_index = xhci_get_endpoint_index(&urb->ep->desc); | 1336 | ep_index = xhci_get_endpoint_index(&urb->ep->desc); |
1338 | ep = &xhci->devs[urb->dev->slot_id]->eps[ep_index]; | 1337 | ep = &xhci->devs[urb->dev->slot_id]->eps[ep_index]; |
1339 | ep_ring = xhci_urb_to_transfer_ring(xhci, urb); | 1338 | ep_ring = xhci_urb_to_transfer_ring(xhci, urb); |
@@ -1342,12 +1341,18 @@ int xhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) | |||
1342 | goto done; | 1341 | goto done; |
1343 | } | 1342 | } |
1344 | 1343 | ||
1345 | xhci_dbg(xhci, "Endpoint ring:\n"); | ||
1346 | xhci_debug_ring(xhci, ep_ring); | ||
1347 | |||
1348 | urb_priv = urb->hcpriv; | 1344 | urb_priv = urb->hcpriv; |
1349 | 1345 | i = urb_priv->td_cnt; | |
1350 | for (i = urb_priv->td_cnt; i < urb_priv->length; i++) { | 1346 | if (i < urb_priv->length) |
1347 | xhci_dbg(xhci, "Cancel URB %p, dev %s, ep 0x%x, " | ||
1348 | "starting at offset 0x%llx\n", | ||
1349 | urb, urb->dev->devpath, | ||
1350 | urb->ep->desc.bEndpointAddress, | ||
1351 | (unsigned long long) xhci_trb_virt_to_dma( | ||
1352 | urb_priv->td[i]->start_seg, | ||
1353 | urb_priv->td[i]->first_trb)); | ||
1354 | |||
1355 | for (; i < urb_priv->length; i++) { | ||
1351 | td = urb_priv->td[i]; | 1356 | td = urb_priv->td[i]; |
1352 | list_add_tail(&td->cancelled_td_list, &ep->cancelled_td_list); | 1357 | list_add_tail(&td->cancelled_td_list, &ep->cancelled_td_list); |
1353 | } | 1358 | } |
@@ -1618,6 +1623,7 @@ static int xhci_configure_endpoint_result(struct xhci_hcd *xhci, | |||
1618 | /* FIXME: can we allocate more resources for the HC? */ | 1623 | /* FIXME: can we allocate more resources for the HC? */ |
1619 | break; | 1624 | break; |
1620 | case COMP_BW_ERR: | 1625 | case COMP_BW_ERR: |
1626 | case COMP_2ND_BW_ERR: | ||
1621 | dev_warn(&udev->dev, "Not enough bandwidth " | 1627 | dev_warn(&udev->dev, "Not enough bandwidth " |
1622 | "for new device state.\n"); | 1628 | "for new device state.\n"); |
1623 | ret = -ENOSPC; | 1629 | ret = -ENOSPC; |
@@ -2794,8 +2800,7 @@ static int xhci_calculate_streams_and_bitmask(struct xhci_hcd *xhci, | |||
2794 | if (ret < 0) | 2800 | if (ret < 0) |
2795 | return ret; | 2801 | return ret; |
2796 | 2802 | ||
2797 | max_streams = USB_SS_MAX_STREAMS( | 2803 | max_streams = usb_ss_max_streams(&eps[i]->ss_ep_comp); |
2798 | eps[i]->ss_ep_comp.bmAttributes); | ||
2799 | if (max_streams < (*num_streams - 1)) { | 2804 | if (max_streams < (*num_streams - 1)) { |
2800 | xhci_dbg(xhci, "Ep 0x%x only supports %u stream IDs.\n", | 2805 | xhci_dbg(xhci, "Ep 0x%x only supports %u stream IDs.\n", |
2801 | eps[i]->desc.bEndpointAddress, | 2806 | eps[i]->desc.bEndpointAddress, |
@@ -3504,6 +3509,10 @@ int xhci_address_device(struct usb_hcd *hcd, struct usb_device *udev) | |||
3504 | /* Otherwise, update the control endpoint ring enqueue pointer. */ | 3509 | /* Otherwise, update the control endpoint ring enqueue pointer. */ |
3505 | else | 3510 | else |
3506 | xhci_copy_ep0_dequeue_into_input_ctx(xhci, udev); | 3511 | xhci_copy_ep0_dequeue_into_input_ctx(xhci, udev); |
3512 | ctrl_ctx = xhci_get_input_control_ctx(xhci, virt_dev->in_ctx); | ||
3513 | ctrl_ctx->add_flags = cpu_to_le32(SLOT_FLAG | EP0_FLAG); | ||
3514 | ctrl_ctx->drop_flags = 0; | ||
3515 | |||
3507 | xhci_dbg(xhci, "Slot ID %d Input Context:\n", udev->slot_id); | 3516 | xhci_dbg(xhci, "Slot ID %d Input Context:\n", udev->slot_id); |
3508 | xhci_dbg_ctx(xhci, virt_dev->in_ctx, 2); | 3517 | xhci_dbg_ctx(xhci, virt_dev->in_ctx, 2); |
3509 | 3518 | ||
@@ -3585,7 +3594,6 @@ int xhci_address_device(struct usb_hcd *hcd, struct usb_device *udev) | |||
3585 | virt_dev->address = (le32_to_cpu(slot_ctx->dev_state) & DEV_ADDR_MASK) | 3594 | virt_dev->address = (le32_to_cpu(slot_ctx->dev_state) & DEV_ADDR_MASK) |
3586 | + 1; | 3595 | + 1; |
3587 | /* Zero the input context control for later use */ | 3596 | /* Zero the input context control for later use */ |
3588 | ctrl_ctx = xhci_get_input_control_ctx(xhci, virt_dev->in_ctx); | ||
3589 | ctrl_ctx->add_flags = 0; | 3597 | ctrl_ctx->add_flags = 0; |
3590 | ctrl_ctx->drop_flags = 0; | 3598 | ctrl_ctx->drop_flags = 0; |
3591 | 3599 | ||
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 3c8fbd2772ea..fb99c8379142 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h | |||
@@ -1033,7 +1033,6 @@ struct xhci_transfer_event { | |||
1033 | /* Invalid Stream ID Error */ | 1033 | /* Invalid Stream ID Error */ |
1034 | #define COMP_STRID_ERR 34 | 1034 | #define COMP_STRID_ERR 34 |
1035 | /* Secondary Bandwidth Error - may be returned by a Configure Endpoint cmd */ | 1035 | /* Secondary Bandwidth Error - may be returned by a Configure Endpoint cmd */ |
1036 | /* FIXME - check for this */ | ||
1037 | #define COMP_2ND_BW_ERR 35 | 1036 | #define COMP_2ND_BW_ERR 35 |
1038 | /* Split Transaction Error */ | 1037 | /* Split Transaction Error */ |
1039 | #define COMP_SPLIT_ERR 36 | 1038 | #define COMP_SPLIT_ERR 36 |
@@ -1356,7 +1355,7 @@ static inline unsigned int hcd_index(struct usb_hcd *hcd) | |||
1356 | return 1; | 1355 | return 1; |
1357 | } | 1356 | } |
1358 | 1357 | ||
1359 | /* There is one ehci_hci structure per controller */ | 1358 | /* There is one xhci_hcd structure per controller */ |
1360 | struct xhci_hcd { | 1359 | struct xhci_hcd { |
1361 | struct usb_hcd *main_hcd; | 1360 | struct usb_hcd *main_hcd; |
1362 | struct usb_hcd *shared_hcd; | 1361 | struct usb_hcd *shared_hcd; |
diff --git a/drivers/usb/image/microtek.c b/drivers/usb/image/microtek.c index 27e209a7222f..9c0f8caba3be 100644 --- a/drivers/usb/image/microtek.c +++ b/drivers/usb/image/microtek.c | |||
@@ -809,19 +809,7 @@ static void mts_usb_disconnect (struct usb_interface *intf) | |||
809 | kfree(desc); | 809 | kfree(desc); |
810 | } | 810 | } |
811 | 811 | ||
812 | 812 | module_usb_driver(mts_usb_driver); | |
813 | static int __init microtek_drv_init(void) | ||
814 | { | ||
815 | return usb_register(&mts_usb_driver); | ||
816 | } | ||
817 | |||
818 | static void __exit microtek_drv_exit(void) | ||
819 | { | ||
820 | usb_deregister(&mts_usb_driver); | ||
821 | } | ||
822 | |||
823 | module_init(microtek_drv_init); | ||
824 | module_exit(microtek_drv_exit); | ||
825 | 813 | ||
826 | MODULE_AUTHOR( DRIVER_AUTHOR ); | 814 | MODULE_AUTHOR( DRIVER_AUTHOR ); |
827 | MODULE_DESCRIPTION( DRIVER_DESC ); | 815 | MODULE_DESCRIPTION( DRIVER_DESC ); |
diff --git a/drivers/usb/misc/adutux.c b/drivers/usb/misc/adutux.c index fe858711651c..284b85461410 100644 --- a/drivers/usb/misc/adutux.c +++ b/drivers/usb/misc/adutux.c | |||
@@ -885,40 +885,7 @@ static struct usb_driver adu_driver = { | |||
885 | .id_table = device_table, | 885 | .id_table = device_table, |
886 | }; | 886 | }; |
887 | 887 | ||
888 | static int __init adu_init(void) | 888 | module_usb_driver(adu_driver); |
889 | { | ||
890 | int result; | ||
891 | |||
892 | dbg(2," %s : enter", __func__); | ||
893 | |||
894 | /* register this driver with the USB subsystem */ | ||
895 | result = usb_register(&adu_driver); | ||
896 | if (result < 0) { | ||
897 | printk(KERN_ERR "usb_register failed for the "__FILE__ | ||
898 | " driver. Error number %d\n", result); | ||
899 | goto exit; | ||
900 | } | ||
901 | |||
902 | printk(KERN_INFO "adutux " DRIVER_DESC " " DRIVER_VERSION "\n"); | ||
903 | printk(KERN_INFO "adutux is an experimental driver. " | ||
904 | "Use at your own risk\n"); | ||
905 | |||
906 | exit: | ||
907 | dbg(2," %s : leave, return value %d", __func__, result); | ||
908 | |||
909 | return result; | ||
910 | } | ||
911 | |||
912 | static void __exit adu_exit(void) | ||
913 | { | ||
914 | dbg(2," %s : enter", __func__); | ||
915 | /* deregister this driver with the USB subsystem */ | ||
916 | usb_deregister(&adu_driver); | ||
917 | dbg(2," %s : leave", __func__); | ||
918 | } | ||
919 | |||
920 | module_init(adu_init); | ||
921 | module_exit(adu_exit); | ||
922 | 889 | ||
923 | MODULE_AUTHOR(DRIVER_AUTHOR); | 890 | MODULE_AUTHOR(DRIVER_AUTHOR); |
924 | MODULE_DESCRIPTION(DRIVER_DESC); | 891 | MODULE_DESCRIPTION(DRIVER_DESC); |
diff --git a/drivers/usb/misc/cypress_cy7c63.c b/drivers/usb/misc/cypress_cy7c63.c index 9251773ecef4..3f7c1a92579f 100644 --- a/drivers/usb/misc/cypress_cy7c63.c +++ b/drivers/usb/misc/cypress_cy7c63.c | |||
@@ -271,27 +271,7 @@ static struct usb_driver cypress_driver = { | |||
271 | .id_table = cypress_table, | 271 | .id_table = cypress_table, |
272 | }; | 272 | }; |
273 | 273 | ||
274 | static int __init cypress_init(void) | 274 | module_usb_driver(cypress_driver); |
275 | { | ||
276 | int result; | ||
277 | |||
278 | /* register this driver with the USB subsystem */ | ||
279 | result = usb_register(&cypress_driver); | ||
280 | if (result) | ||
281 | printk(KERN_ERR KBUILD_MODNAME ": usb_register failed! " | ||
282 | "Error number: %d\n", result); | ||
283 | |||
284 | return result; | ||
285 | } | ||
286 | |||
287 | static void __exit cypress_exit(void) | ||
288 | { | ||
289 | /* deregister this driver with the USB subsystem */ | ||
290 | usb_deregister(&cypress_driver); | ||
291 | } | ||
292 | |||
293 | module_init(cypress_init); | ||
294 | module_exit(cypress_exit); | ||
295 | 275 | ||
296 | MODULE_AUTHOR(DRIVER_AUTHOR); | 276 | MODULE_AUTHOR(DRIVER_AUTHOR); |
297 | MODULE_DESCRIPTION(DRIVER_DESC); | 277 | MODULE_DESCRIPTION(DRIVER_DESC); |
diff --git a/drivers/usb/misc/cytherm.c b/drivers/usb/misc/cytherm.c index 1d7251bc1b5f..5b9831b95d97 100644 --- a/drivers/usb/misc/cytherm.c +++ b/drivers/usb/misc/cytherm.c | |||
@@ -417,31 +417,7 @@ static void cytherm_disconnect(struct usb_interface *interface) | |||
417 | dev_info(&interface->dev, "Cypress thermometer now disconnected\n"); | 417 | dev_info(&interface->dev, "Cypress thermometer now disconnected\n"); |
418 | } | 418 | } |
419 | 419 | ||
420 | 420 | module_usb_driver(cytherm_driver); | |
421 | static int __init usb_cytherm_init(void) | ||
422 | { | ||
423 | int result; | ||
424 | |||
425 | result = usb_register(&cytherm_driver); | ||
426 | if (result) { | ||
427 | printk(KERN_ERR KBUILD_MODNAME ": usb_register failed! " | ||
428 | "Error number: %d\n", result); | ||
429 | return result; | ||
430 | } | ||
431 | |||
432 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" | ||
433 | DRIVER_DESC "\n"); | ||
434 | return 0; | ||
435 | } | ||
436 | |||
437 | static void __exit usb_cytherm_exit(void) | ||
438 | { | ||
439 | usb_deregister(&cytherm_driver); | ||
440 | } | ||
441 | |||
442 | |||
443 | module_init (usb_cytherm_init); | ||
444 | module_exit (usb_cytherm_exit); | ||
445 | 421 | ||
446 | MODULE_AUTHOR(DRIVER_AUTHOR); | 422 | MODULE_AUTHOR(DRIVER_AUTHOR); |
447 | MODULE_DESCRIPTION(DRIVER_DESC); | 423 | MODULE_DESCRIPTION(DRIVER_DESC); |
diff --git a/drivers/usb/misc/emi26.c b/drivers/usb/misc/emi26.c index a6521c95f683..d9b6a0355443 100644 --- a/drivers/usb/misc/emi26.c +++ b/drivers/usb/misc/emi26.c | |||
@@ -276,18 +276,7 @@ static struct usb_driver emi26_driver = { | |||
276 | .id_table = id_table, | 276 | .id_table = id_table, |
277 | }; | 277 | }; |
278 | 278 | ||
279 | static int __init emi26_init (void) | 279 | module_usb_driver(emi26_driver); |
280 | { | ||
281 | return usb_register(&emi26_driver); | ||
282 | } | ||
283 | |||
284 | static void __exit emi26_exit (void) | ||
285 | { | ||
286 | usb_deregister (&emi26_driver); | ||
287 | } | ||
288 | |||
289 | module_init(emi26_init); | ||
290 | module_exit(emi26_exit); | ||
291 | 280 | ||
292 | MODULE_AUTHOR("Tapio Laxström"); | 281 | MODULE_AUTHOR("Tapio Laxström"); |
293 | MODULE_DESCRIPTION("Emagic EMI 2|6 firmware loader."); | 282 | MODULE_DESCRIPTION("Emagic EMI 2|6 firmware loader."); |
diff --git a/drivers/usb/misc/emi62.c b/drivers/usb/misc/emi62.c index fc15ad4c3139..9f39062ebb08 100644 --- a/drivers/usb/misc/emi62.c +++ b/drivers/usb/misc/emi62.c | |||
@@ -290,22 +290,7 @@ static struct usb_driver emi62_driver = { | |||
290 | .id_table = id_table, | 290 | .id_table = id_table, |
291 | }; | 291 | }; |
292 | 292 | ||
293 | static int __init emi62_init (void) | 293 | module_usb_driver(emi62_driver); |
294 | { | ||
295 | int retval; | ||
296 | retval = usb_register (&emi62_driver); | ||
297 | if (retval) | ||
298 | printk(KERN_ERR "adi-emi: registration failed\n"); | ||
299 | return retval; | ||
300 | } | ||
301 | |||
302 | static void __exit emi62_exit (void) | ||
303 | { | ||
304 | usb_deregister (&emi62_driver); | ||
305 | } | ||
306 | |||
307 | module_init(emi62_init); | ||
308 | module_exit(emi62_exit); | ||
309 | 294 | ||
310 | MODULE_AUTHOR("Tapio Laxström"); | 295 | MODULE_AUTHOR("Tapio Laxström"); |
311 | MODULE_DESCRIPTION("Emagic EMI 6|2m firmware loader."); | 296 | MODULE_DESCRIPTION("Emagic EMI 6|2m firmware loader."); |
diff --git a/drivers/usb/misc/ftdi-elan.c b/drivers/usb/misc/ftdi-elan.c index 2dbe600fbc11..a4a3c7cd4a11 100644 --- a/drivers/usb/misc/ftdi-elan.c +++ b/drivers/usb/misc/ftdi-elan.c | |||
@@ -53,7 +53,7 @@ MODULE_AUTHOR("Tony Olech"); | |||
53 | MODULE_DESCRIPTION("FTDI ELAN driver"); | 53 | MODULE_DESCRIPTION("FTDI ELAN driver"); |
54 | MODULE_LICENSE("GPL"); | 54 | MODULE_LICENSE("GPL"); |
55 | #define INT_MODULE_PARM(n, v) static int n = v;module_param(n, int, 0444) | 55 | #define INT_MODULE_PARM(n, v) static int n = v;module_param(n, int, 0444) |
56 | static int distrust_firmware = 1; | 56 | static bool distrust_firmware = 1; |
57 | module_param(distrust_firmware, bool, 0); | 57 | module_param(distrust_firmware, bool, 0); |
58 | MODULE_PARM_DESC(distrust_firmware, "true to distrust firmware power/overcurren" | 58 | MODULE_PARM_DESC(distrust_firmware, "true to distrust firmware power/overcurren" |
59 | "t setup"); | 59 | "t setup"); |
diff --git a/drivers/usb/misc/idmouse.c b/drivers/usb/misc/idmouse.c index 515b67fffab1..0dee24698504 100644 --- a/drivers/usb/misc/idmouse.c +++ b/drivers/usb/misc/idmouse.c | |||
@@ -428,29 +428,7 @@ static void idmouse_disconnect(struct usb_interface *interface) | |||
428 | dev_info(&interface->dev, "disconnected\n"); | 428 | dev_info(&interface->dev, "disconnected\n"); |
429 | } | 429 | } |
430 | 430 | ||
431 | static int __init usb_idmouse_init(void) | 431 | module_usb_driver(idmouse_driver); |
432 | { | ||
433 | int result; | ||
434 | |||
435 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" | ||
436 | DRIVER_DESC "\n"); | ||
437 | |||
438 | /* register this driver with the USB subsystem */ | ||
439 | result = usb_register(&idmouse_driver); | ||
440 | if (result) | ||
441 | err("Unable to register device (error %d).", result); | ||
442 | |||
443 | return result; | ||
444 | } | ||
445 | |||
446 | static void __exit usb_idmouse_exit(void) | ||
447 | { | ||
448 | /* deregister this driver with the USB subsystem */ | ||
449 | usb_deregister(&idmouse_driver); | ||
450 | } | ||
451 | |||
452 | module_init(usb_idmouse_init); | ||
453 | module_exit(usb_idmouse_exit); | ||
454 | 432 | ||
455 | MODULE_AUTHOR(DRIVER_AUTHOR); | 433 | MODULE_AUTHOR(DRIVER_AUTHOR); |
456 | MODULE_DESCRIPTION(DRIVER_DESC); | 434 | MODULE_DESCRIPTION(DRIVER_DESC); |
diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c index 81457904d6ba..4fd0dc835ae5 100644 --- a/drivers/usb/misc/iowarrior.c +++ b/drivers/usb/misc/iowarrior.c | |||
@@ -62,7 +62,7 @@ MODULE_LICENSE("GPL"); | |||
62 | 62 | ||
63 | /* Module parameters */ | 63 | /* Module parameters */ |
64 | static DEFINE_MUTEX(iowarrior_mutex); | 64 | static DEFINE_MUTEX(iowarrior_mutex); |
65 | static int debug = 0; | 65 | static bool debug = 0; |
66 | module_param(debug, bool, 0644); | 66 | module_param(debug, bool, 0644); |
67 | MODULE_PARM_DESC(debug, "debug=1 enables debugging messages"); | 67 | MODULE_PARM_DESC(debug, "debug=1 enables debugging messages"); |
68 | 68 | ||
@@ -734,7 +734,7 @@ static const struct file_operations iowarrior_fops = { | |||
734 | .llseek = noop_llseek, | 734 | .llseek = noop_llseek, |
735 | }; | 735 | }; |
736 | 736 | ||
737 | static char *iowarrior_devnode(struct device *dev, mode_t *mode) | 737 | static char *iowarrior_devnode(struct device *dev, umode_t *mode) |
738 | { | 738 | { |
739 | return kasprintf(GFP_KERNEL, "usb/%s", dev_name(dev)); | 739 | return kasprintf(GFP_KERNEL, "usb/%s", dev_name(dev)); |
740 | } | 740 | } |
@@ -927,15 +927,4 @@ static struct usb_driver iowarrior_driver = { | |||
927 | .id_table = iowarrior_ids, | 927 | .id_table = iowarrior_ids, |
928 | }; | 928 | }; |
929 | 929 | ||
930 | static int __init iowarrior_init(void) | 930 | module_usb_driver(iowarrior_driver); |
931 | { | ||
932 | return usb_register(&iowarrior_driver); | ||
933 | } | ||
934 | |||
935 | static void __exit iowarrior_exit(void) | ||
936 | { | ||
937 | usb_deregister(&iowarrior_driver); | ||
938 | } | ||
939 | |||
940 | module_init(iowarrior_init); | ||
941 | module_exit(iowarrior_exit); | ||
diff --git a/drivers/usb/misc/isight_firmware.c b/drivers/usb/misc/isight_firmware.c index fe1d44319d0a..1c61830e96f9 100644 --- a/drivers/usb/misc/isight_firmware.c +++ b/drivers/usb/misc/isight_firmware.c | |||
@@ -55,8 +55,9 @@ static int isight_firmware_load(struct usb_interface *intf, | |||
55 | 55 | ||
56 | ptr = firmware->data; | 56 | ptr = firmware->data; |
57 | 57 | ||
58 | buf[0] = 0x01; | ||
58 | if (usb_control_msg | 59 | if (usb_control_msg |
59 | (dev, usb_sndctrlpipe(dev, 0), 0xa0, 0x40, 0xe600, 0, "\1", 1, | 60 | (dev, usb_sndctrlpipe(dev, 0), 0xa0, 0x40, 0xe600, 0, buf, 1, |
60 | 300) != 1) { | 61 | 300) != 1) { |
61 | printk(KERN_ERR | 62 | printk(KERN_ERR |
62 | "Failed to initialise isight firmware loader\n"); | 63 | "Failed to initialise isight firmware loader\n"); |
@@ -100,8 +101,9 @@ static int isight_firmware_load(struct usb_interface *intf, | |||
100 | } | 101 | } |
101 | } | 102 | } |
102 | 103 | ||
104 | buf[0] = 0x00; | ||
103 | if (usb_control_msg | 105 | if (usb_control_msg |
104 | (dev, usb_sndctrlpipe(dev, 0), 0xa0, 0x40, 0xe600, 0, "\0", 1, | 106 | (dev, usb_sndctrlpipe(dev, 0), 0xa0, 0x40, 0xe600, 0, buf, 1, |
105 | 300) != 1) { | 107 | 300) != 1) { |
106 | printk(KERN_ERR "isight firmware loading completion failed\n"); | 108 | printk(KERN_ERR "isight firmware loading completion failed\n"); |
107 | ret = -ENODEV; | 109 | ret = -ENODEV; |
@@ -126,18 +128,7 @@ static struct usb_driver isight_firmware_driver = { | |||
126 | .id_table = id_table, | 128 | .id_table = id_table, |
127 | }; | 129 | }; |
128 | 130 | ||
129 | static int __init isight_firmware_init(void) | 131 | module_usb_driver(isight_firmware_driver); |
130 | { | ||
131 | return usb_register(&isight_firmware_driver); | ||
132 | } | ||
133 | |||
134 | static void __exit isight_firmware_exit(void) | ||
135 | { | ||
136 | usb_deregister(&isight_firmware_driver); | ||
137 | } | ||
138 | |||
139 | module_init(isight_firmware_init); | ||
140 | module_exit(isight_firmware_exit); | ||
141 | 132 | ||
142 | MODULE_LICENSE("GPL"); | 133 | MODULE_LICENSE("GPL"); |
143 | MODULE_AUTHOR("Matthew Garrett <mjg@redhat.com>"); | 134 | MODULE_AUTHOR("Matthew Garrett <mjg@redhat.com>"); |
diff --git a/drivers/usb/misc/ldusb.c b/drivers/usb/misc/ldusb.c index 48c166f0d764..5db4ab52061e 100644 --- a/drivers/usb/misc/ldusb.c +++ b/drivers/usb/misc/ldusb.c | |||
@@ -821,30 +821,5 @@ static struct usb_driver ld_usb_driver = { | |||
821 | .id_table = ld_usb_table, | 821 | .id_table = ld_usb_table, |
822 | }; | 822 | }; |
823 | 823 | ||
824 | /** | 824 | module_usb_driver(ld_usb_driver); |
825 | * ld_usb_init | ||
826 | */ | ||
827 | static int __init ld_usb_init(void) | ||
828 | { | ||
829 | int retval; | ||
830 | |||
831 | /* register this driver with the USB subsystem */ | ||
832 | retval = usb_register(&ld_usb_driver); | ||
833 | if (retval) | ||
834 | err("usb_register failed for the %s driver. Error number %d\n", __FILE__, retval); | ||
835 | |||
836 | return retval; | ||
837 | } | ||
838 | |||
839 | /** | ||
840 | * ld_usb_exit | ||
841 | */ | ||
842 | static void __exit ld_usb_exit(void) | ||
843 | { | ||
844 | /* deregister this driver with the USB subsystem */ | ||
845 | usb_deregister(&ld_usb_driver); | ||
846 | } | ||
847 | |||
848 | module_init(ld_usb_init); | ||
849 | module_exit(ld_usb_exit); | ||
850 | 825 | ||
diff --git a/drivers/usb/misc/legousbtower.c b/drivers/usb/misc/legousbtower.c index a989356f693e..575222042767 100644 --- a/drivers/usb/misc/legousbtower.c +++ b/drivers/usb/misc/legousbtower.c | |||
@@ -269,7 +269,7 @@ static const struct file_operations tower_fops = { | |||
269 | .llseek = tower_llseek, | 269 | .llseek = tower_llseek, |
270 | }; | 270 | }; |
271 | 271 | ||
272 | static char *legousbtower_devnode(struct device *dev, mode_t *mode) | 272 | static char *legousbtower_devnode(struct device *dev, umode_t *mode) |
273 | { | 273 | { |
274 | return kasprintf(GFP_KERNEL, "usb/%s", dev_name(dev)); | 274 | return kasprintf(GFP_KERNEL, "usb/%s", dev_name(dev)); |
275 | } | 275 | } |
@@ -1043,51 +1043,7 @@ static void tower_disconnect (struct usb_interface *interface) | |||
1043 | dbg(2, "%s: leave", __func__); | 1043 | dbg(2, "%s: leave", __func__); |
1044 | } | 1044 | } |
1045 | 1045 | ||
1046 | 1046 | module_usb_driver(tower_driver); | |
1047 | |||
1048 | /** | ||
1049 | * lego_usb_tower_init | ||
1050 | */ | ||
1051 | static int __init lego_usb_tower_init(void) | ||
1052 | { | ||
1053 | int result; | ||
1054 | int retval = 0; | ||
1055 | |||
1056 | dbg(2, "%s: enter", __func__); | ||
1057 | |||
1058 | /* register this driver with the USB subsystem */ | ||
1059 | result = usb_register(&tower_driver); | ||
1060 | if (result < 0) { | ||
1061 | err("usb_register failed for the %s driver. Error number %d", __FILE__, result); | ||
1062 | retval = -1; | ||
1063 | goto exit; | ||
1064 | } | ||
1065 | |||
1066 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" | ||
1067 | DRIVER_DESC "\n"); | ||
1068 | |||
1069 | exit: | ||
1070 | dbg(2, "%s: leave, return value %d", __func__, retval); | ||
1071 | |||
1072 | return retval; | ||
1073 | } | ||
1074 | |||
1075 | |||
1076 | /** | ||
1077 | * lego_usb_tower_exit | ||
1078 | */ | ||
1079 | static void __exit lego_usb_tower_exit(void) | ||
1080 | { | ||
1081 | dbg(2, "%s: enter", __func__); | ||
1082 | |||
1083 | /* deregister this driver with the USB subsystem */ | ||
1084 | usb_deregister (&tower_driver); | ||
1085 | |||
1086 | dbg(2, "%s: leave", __func__); | ||
1087 | } | ||
1088 | |||
1089 | module_init (lego_usb_tower_init); | ||
1090 | module_exit (lego_usb_tower_exit); | ||
1091 | 1047 | ||
1092 | MODULE_AUTHOR(DRIVER_AUTHOR); | 1048 | MODULE_AUTHOR(DRIVER_AUTHOR); |
1093 | MODULE_DESCRIPTION(DRIVER_DESC); | 1049 | MODULE_DESCRIPTION(DRIVER_DESC); |
diff --git a/drivers/usb/misc/rio500.c b/drivers/usb/misc/rio500.c index 4e23d3841b43..487a8ce0775e 100644 --- a/drivers/usb/misc/rio500.c +++ b/drivers/usb/misc/rio500.c | |||
@@ -531,33 +531,7 @@ static struct usb_driver rio_driver = { | |||
531 | .id_table = rio_table, | 531 | .id_table = rio_table, |
532 | }; | 532 | }; |
533 | 533 | ||
534 | static int __init usb_rio_init(void) | 534 | module_usb_driver(rio_driver); |
535 | { | ||
536 | int retval; | ||
537 | retval = usb_register(&rio_driver); | ||
538 | if (retval) | ||
539 | goto out; | ||
540 | |||
541 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" | ||
542 | DRIVER_DESC "\n"); | ||
543 | |||
544 | out: | ||
545 | return retval; | ||
546 | } | ||
547 | |||
548 | |||
549 | static void __exit usb_rio_cleanup(void) | ||
550 | { | ||
551 | struct rio_usb_data *rio = &rio_instance; | ||
552 | |||
553 | rio->present = 0; | ||
554 | usb_deregister(&rio_driver); | ||
555 | |||
556 | |||
557 | } | ||
558 | |||
559 | module_init(usb_rio_init); | ||
560 | module_exit(usb_rio_cleanup); | ||
561 | 535 | ||
562 | MODULE_AUTHOR( DRIVER_AUTHOR ); | 536 | MODULE_AUTHOR( DRIVER_AUTHOR ); |
563 | MODULE_DESCRIPTION( DRIVER_DESC ); | 537 | MODULE_DESCRIPTION( DRIVER_DESC ); |
diff --git a/drivers/usb/misc/trancevibrator.c b/drivers/usb/misc/trancevibrator.c index f63776a48e2a..741efed4a236 100644 --- a/drivers/usb/misc/trancevibrator.c +++ b/drivers/usb/misc/trancevibrator.c | |||
@@ -137,26 +137,7 @@ static struct usb_driver tv_driver = { | |||
137 | .id_table = id_table, | 137 | .id_table = id_table, |
138 | }; | 138 | }; |
139 | 139 | ||
140 | static int __init tv_init(void) | 140 | module_usb_driver(tv_driver); |
141 | { | ||
142 | int retval = usb_register(&tv_driver); | ||
143 | if (retval) { | ||
144 | err("usb_register failed. Error number %d", retval); | ||
145 | return retval; | ||
146 | } | ||
147 | |||
148 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" | ||
149 | DRIVER_DESC "\n"); | ||
150 | return 0; | ||
151 | } | ||
152 | |||
153 | static void __exit tv_exit(void) | ||
154 | { | ||
155 | usb_deregister(&tv_driver); | ||
156 | } | ||
157 | |||
158 | module_init (tv_init); | ||
159 | module_exit (tv_exit); | ||
160 | 141 | ||
161 | MODULE_AUTHOR(DRIVER_AUTHOR); | 142 | MODULE_AUTHOR(DRIVER_AUTHOR); |
162 | MODULE_DESCRIPTION(DRIVER_DESC); | 143 | MODULE_DESCRIPTION(DRIVER_DESC); |
diff --git a/drivers/usb/misc/usblcd.c b/drivers/usb/misc/usblcd.c index 1871cdf10da3..e2b4bd31c2b6 100644 --- a/drivers/usb/misc/usblcd.c +++ b/drivers/usb/misc/usblcd.c | |||
@@ -450,25 +450,7 @@ static struct usb_driver lcd_driver = { | |||
450 | .supports_autosuspend = 1, | 450 | .supports_autosuspend = 1, |
451 | }; | 451 | }; |
452 | 452 | ||
453 | static int __init usb_lcd_init(void) | 453 | module_usb_driver(lcd_driver); |
454 | { | ||
455 | int result; | ||
456 | |||
457 | result = usb_register(&lcd_driver); | ||
458 | if (result) | ||
459 | err("usb_register failed. Error number %d", result); | ||
460 | |||
461 | return result; | ||
462 | } | ||
463 | |||
464 | |||
465 | static void __exit usb_lcd_exit(void) | ||
466 | { | ||
467 | usb_deregister(&lcd_driver); | ||
468 | } | ||
469 | |||
470 | module_init(usb_lcd_init); | ||
471 | module_exit(usb_lcd_exit); | ||
472 | 454 | ||
473 | MODULE_AUTHOR("Georges Toth <g.toth@e-biz.lu>"); | 455 | MODULE_AUTHOR("Georges Toth <g.toth@e-biz.lu>"); |
474 | MODULE_DESCRIPTION(DRIVER_VERSION); | 456 | MODULE_DESCRIPTION(DRIVER_VERSION); |
diff --git a/drivers/usb/misc/usbled.c b/drivers/usb/misc/usbled.c index 43f84e50d514..12d03e7ad636 100644 --- a/drivers/usb/misc/usbled.c +++ b/drivers/usb/misc/usbled.c | |||
@@ -31,6 +31,8 @@ static const struct usb_device_id id_table[] = { | |||
31 | .driver_info = DELCOM_VISUAL_SIGNAL_INDICATOR }, | 31 | .driver_info = DELCOM_VISUAL_SIGNAL_INDICATOR }, |
32 | { USB_DEVICE(0x1d34, 0x0004), | 32 | { USB_DEVICE(0x1d34, 0x0004), |
33 | .driver_info = DREAM_CHEEKY_WEBMAIL_NOTIFIER }, | 33 | .driver_info = DREAM_CHEEKY_WEBMAIL_NOTIFIER }, |
34 | { USB_DEVICE(0x1d34, 0x000a), | ||
35 | .driver_info = DREAM_CHEEKY_WEBMAIL_NOTIFIER }, | ||
34 | { }, | 36 | { }, |
35 | }; | 37 | }; |
36 | MODULE_DEVICE_TABLE(usb, id_table); | 38 | MODULE_DEVICE_TABLE(usb, id_table); |
@@ -231,23 +233,7 @@ static struct usb_driver led_driver = { | |||
231 | .id_table = id_table, | 233 | .id_table = id_table, |
232 | }; | 234 | }; |
233 | 235 | ||
234 | static int __init usb_led_init(void) | 236 | module_usb_driver(led_driver); |
235 | { | ||
236 | int retval = 0; | ||
237 | |||
238 | retval = usb_register(&led_driver); | ||
239 | if (retval) | ||
240 | err("usb_register failed. Error number %d", retval); | ||
241 | return retval; | ||
242 | } | ||
243 | |||
244 | static void __exit usb_led_exit(void) | ||
245 | { | ||
246 | usb_deregister(&led_driver); | ||
247 | } | ||
248 | |||
249 | module_init(usb_led_init); | ||
250 | module_exit(usb_led_exit); | ||
251 | 237 | ||
252 | MODULE_AUTHOR(DRIVER_AUTHOR); | 238 | MODULE_AUTHOR(DRIVER_AUTHOR); |
253 | MODULE_DESCRIPTION(DRIVER_DESC); | 239 | MODULE_DESCRIPTION(DRIVER_DESC); |
diff --git a/drivers/usb/misc/usbsevseg.c b/drivers/usb/misc/usbsevseg.c index 417b8f207e8b..107bf13b1cf1 100644 --- a/drivers/usb/misc/usbsevseg.c +++ b/drivers/usb/misc/usbsevseg.c | |||
@@ -437,23 +437,7 @@ static struct usb_driver sevseg_driver = { | |||
437 | .supports_autosuspend = 1, | 437 | .supports_autosuspend = 1, |
438 | }; | 438 | }; |
439 | 439 | ||
440 | static int __init usb_sevseg_init(void) | 440 | module_usb_driver(sevseg_driver); |
441 | { | ||
442 | int rc = 0; | ||
443 | |||
444 | rc = usb_register(&sevseg_driver); | ||
445 | if (rc) | ||
446 | err("usb_register failed. Error number %d", rc); | ||
447 | return rc; | ||
448 | } | ||
449 | |||
450 | static void __exit usb_sevseg_exit(void) | ||
451 | { | ||
452 | usb_deregister(&sevseg_driver); | ||
453 | } | ||
454 | |||
455 | module_init(usb_sevseg_init); | ||
456 | module_exit(usb_sevseg_exit); | ||
457 | 441 | ||
458 | MODULE_AUTHOR(DRIVER_AUTHOR); | 442 | MODULE_AUTHOR(DRIVER_AUTHOR); |
459 | MODULE_DESCRIPTION(DRIVER_DESC); | 443 | MODULE_DESCRIPTION(DRIVER_DESC); |
diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c index bd6d00802eab..959145baf3cf 100644 --- a/drivers/usb/misc/usbtest.c +++ b/drivers/usb/misc/usbtest.c | |||
@@ -1765,7 +1765,6 @@ static int test_unaligned_bulk( | |||
1765 | * off just killing the userspace task and waiting for it to exit. | 1765 | * off just killing the userspace task and waiting for it to exit. |
1766 | */ | 1766 | */ |
1767 | 1767 | ||
1768 | /* No BKL needed */ | ||
1769 | static int | 1768 | static int |
1770 | usbtest_ioctl(struct usb_interface *intf, unsigned int code, void *buf) | 1769 | usbtest_ioctl(struct usb_interface *intf, unsigned int code, void *buf) |
1771 | { | 1770 | { |
diff --git a/drivers/usb/misc/yurex.c b/drivers/usb/misc/yurex.c index ac5bfd619e62..897edda42270 100644 --- a/drivers/usb/misc/yurex.c +++ b/drivers/usb/misc/yurex.c | |||
@@ -539,26 +539,6 @@ static const struct file_operations yurex_fops = { | |||
539 | .llseek = default_llseek, | 539 | .llseek = default_llseek, |
540 | }; | 540 | }; |
541 | 541 | ||
542 | 542 | module_usb_driver(yurex_driver); | |
543 | static int __init usb_yurex_init(void) | ||
544 | { | ||
545 | int result; | ||
546 | |||
547 | /* register this driver with the USB subsystem */ | ||
548 | result = usb_register(&yurex_driver); | ||
549 | if (result) | ||
550 | err("usb_register failed. Error number %d", result); | ||
551 | |||
552 | return result; | ||
553 | } | ||
554 | |||
555 | static void __exit usb_yurex_exit(void) | ||
556 | { | ||
557 | /* deregister this driver with the USB subsystem */ | ||
558 | usb_deregister(&yurex_driver); | ||
559 | } | ||
560 | |||
561 | module_init(usb_yurex_init); | ||
562 | module_exit(usb_yurex_exit); | ||
563 | 543 | ||
564 | MODULE_LICENSE("GPL"); | 544 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig index fc34b8b11910..f70cab3beeec 100644 --- a/drivers/usb/musb/Kconfig +++ b/drivers/usb/musb/Kconfig | |||
@@ -5,13 +5,13 @@ | |||
5 | 5 | ||
6 | # (M)HDRC = (Multipoint) Highspeed Dual-Role Controller | 6 | # (M)HDRC = (Multipoint) Highspeed Dual-Role Controller |
7 | config USB_MUSB_HDRC | 7 | config USB_MUSB_HDRC |
8 | tristate 'Inventra Highspeed Dual Role Controller (TI, ADI, ...)' | ||
8 | depends on USB && USB_GADGET | 9 | depends on USB && USB_GADGET |
9 | depends on (ARM || (BF54x && !BF544) || (BF52x && !BF522 && !BF523)) | ||
10 | select NOP_USB_XCEIV if (ARCH_DAVINCI || MACH_OMAP3EVM || BLACKFIN) | 10 | select NOP_USB_XCEIV if (ARCH_DAVINCI || MACH_OMAP3EVM || BLACKFIN) |
11 | select TWL4030_USB if MACH_OMAP_3430SDP | 11 | select TWL4030_USB if MACH_OMAP_3430SDP |
12 | select TWL6030_USB if MACH_OMAP_4430SDP || MACH_OMAP4_PANDA | 12 | select TWL6030_USB if MACH_OMAP_4430SDP || MACH_OMAP4_PANDA |
13 | select USB_OTG_UTILS | 13 | select USB_OTG_UTILS |
14 | tristate 'Inventra Highspeed Dual Role Controller (TI, ADI, ...)' | 14 | select USB_GADGET_DUALSPEED |
15 | help | 15 | help |
16 | Say Y here if your system has a dual role high speed USB | 16 | Say Y here if your system has a dual role high speed USB |
17 | controller based on the Mentor Graphics silicon IP. Then | 17 | controller based on the Mentor Graphics silicon IP. Then |
@@ -30,9 +30,10 @@ config USB_MUSB_HDRC | |||
30 | To compile this driver as a module, choose M here; the | 30 | To compile this driver as a module, choose M here; the |
31 | module will be called "musb-hdrc". | 31 | module will be called "musb-hdrc". |
32 | 32 | ||
33 | if USB_MUSB_HDRC | ||
34 | |||
33 | choice | 35 | choice |
34 | prompt "Platform Glue Layer" | 36 | prompt "Platform Glue Layer" |
35 | depends on USB_MUSB_HDRC | ||
36 | 37 | ||
37 | config USB_MUSB_DAVINCI | 38 | config USB_MUSB_DAVINCI |
38 | tristate "DaVinci" | 39 | tristate "DaVinci" |
@@ -44,7 +45,6 @@ config USB_MUSB_DA8XX | |||
44 | 45 | ||
45 | config USB_MUSB_TUSB6010 | 46 | config USB_MUSB_TUSB6010 |
46 | tristate "TUSB6010" | 47 | tristate "TUSB6010" |
47 | depends on ARCH_OMAP | ||
48 | 48 | ||
49 | config USB_MUSB_OMAP2PLUS | 49 | config USB_MUSB_OMAP2PLUS |
50 | tristate "OMAP2430 and onwards" | 50 | tristate "OMAP2430 and onwards" |
@@ -60,50 +60,58 @@ config USB_MUSB_BLACKFIN | |||
60 | 60 | ||
61 | config USB_MUSB_UX500 | 61 | config USB_MUSB_UX500 |
62 | tristate "U8500 and U5500" | 62 | tristate "U8500 and U5500" |
63 | depends on (ARCH_U8500 && AB8500_USB) || (ARCH_U5500) | 63 | depends on (ARCH_U8500 && AB8500_USB) |
64 | 64 | ||
65 | endchoice | 65 | endchoice |
66 | 66 | ||
67 | config MUSB_PIO_ONLY | 67 | choice |
68 | bool 'Disable DMA (always use PIO)' | 68 | prompt 'MUSB DMA mode' |
69 | depends on USB_MUSB_HDRC | 69 | default USB_UX500_DMA if USB_MUSB_UX500 |
70 | default USB_MUSB_TUSB6010 || USB_MUSB_DA8XX || USB_MUSB_AM35X | 70 | default USB_INVENTRA_DMA if USB_MUSB_OMAP2PLUS || USB_MUSB_BLACKFIN |
71 | default USB_TI_CPPI_DMA if USB_MUSB_DAVINCI | ||
72 | default USB_TUSB_OMAP_DMA if USB_MUSB_TUSB6010 | ||
73 | default MUSB_PIO_ONLY if USB_MUSB_TUSB6010 || USB_MUSB_DA8XX || USB_MUSB_AM35X | ||
71 | help | 74 | help |
72 | All data is copied between memory and FIFO by the CPU. | 75 | Unfortunately, only one option can be enabled here. Ideally one |
73 | DMA controllers are ignored. | 76 | should be able to build all these drivers into one kernel to |
74 | 77 | allow using DMA on multiplatform kernels. | |
75 | Do not select 'n' here unless DMA support for your SOC or board | ||
76 | is unavailable (or unstable). When DMA is enabled at compile time, | ||
77 | you can still disable it at run time using the "use_dma=n" module | ||
78 | parameter. | ||
79 | 78 | ||
80 | config USB_UX500_DMA | 79 | config USB_UX500_DMA |
81 | bool | 80 | bool 'ST Ericsson U8500 and U5500' |
82 | depends on USB_MUSB_HDRC && !MUSB_PIO_ONLY | 81 | depends on USB_MUSB_UX500 |
83 | default USB_MUSB_UX500 | ||
84 | help | 82 | help |
85 | Enable DMA transfers on UX500 platforms. | 83 | Enable DMA transfers on UX500 platforms. |
86 | 84 | ||
87 | config USB_INVENTRA_DMA | 85 | config USB_INVENTRA_DMA |
88 | bool | 86 | bool 'Inventra' |
89 | depends on USB_MUSB_HDRC && !MUSB_PIO_ONLY | 87 | depends on USB_MUSB_OMAP2PLUS || USB_MUSB_BLACKFIN |
90 | default USB_MUSB_OMAP2PLUS || USB_MUSB_BLACKFIN | ||
91 | help | 88 | help |
92 | Enable DMA transfers using Mentor's engine. | 89 | Enable DMA transfers using Mentor's engine. |
93 | 90 | ||
94 | config USB_TI_CPPI_DMA | 91 | config USB_TI_CPPI_DMA |
95 | bool | 92 | bool 'TI CPPI (Davinci)' |
96 | depends on USB_MUSB_HDRC && !MUSB_PIO_ONLY | 93 | depends on USB_MUSB_DAVINCI |
97 | default USB_MUSB_DAVINCI | ||
98 | help | 94 | help |
99 | Enable DMA transfers when TI CPPI DMA is available. | 95 | Enable DMA transfers when TI CPPI DMA is available. |
100 | 96 | ||
101 | config USB_TUSB_OMAP_DMA | 97 | config USB_TUSB_OMAP_DMA |
102 | bool | 98 | bool 'TUSB 6010' |
103 | depends on USB_MUSB_HDRC && !MUSB_PIO_ONLY | ||
104 | depends on USB_MUSB_TUSB6010 | 99 | depends on USB_MUSB_TUSB6010 |
105 | depends on ARCH_OMAP | 100 | depends on ARCH_OMAP |
106 | default y | ||
107 | help | 101 | help |
108 | Enable DMA transfers on TUSB 6010 when OMAP DMA is available. | 102 | Enable DMA transfers on TUSB 6010 when OMAP DMA is available. |
109 | 103 | ||
104 | config MUSB_PIO_ONLY | ||
105 | bool 'Disable DMA (always use PIO)' | ||
106 | help | ||
107 | All data is copied between memory and FIFO by the CPU. | ||
108 | DMA controllers are ignored. | ||
109 | |||
110 | Do not choose this unless DMA support for your SOC or board | ||
111 | is unavailable (or unstable). When DMA is enabled at compile time, | ||
112 | you can still disable it at run time using the "use_dma=n" module | ||
113 | parameter. | ||
114 | |||
115 | endchoice | ||
116 | |||
117 | endif # USB_MUSB_HDRC | ||
diff --git a/drivers/usb/musb/Makefile b/drivers/usb/musb/Makefile index d8fd9d092dec..88bfb9dee4bf 100644 --- a/drivers/usb/musb/Makefile +++ b/drivers/usb/musb/Makefile | |||
@@ -24,25 +24,7 @@ obj-$(CONFIG_USB_MUSB_UX500) += ux500.o | |||
24 | # PIO only, or DMA (several potential schemes). | 24 | # PIO only, or DMA (several potential schemes). |
25 | # though PIO is always there to back up DMA, and for ep0 | 25 | # though PIO is always there to back up DMA, and for ep0 |
26 | 26 | ||
27 | ifneq ($(CONFIG_MUSB_PIO_ONLY),y) | 27 | musb_hdrc-$(CONFIG_USB_INVENTRA_DMA) += musbhsdma.o |
28 | 28 | musb_hdrc-$(CONFIG_USB_TI_CPPI_DMA) += cppi_dma.o | |
29 | ifeq ($(CONFIG_USB_INVENTRA_DMA),y) | 29 | musb_hdrc-$(CONFIG_USB_TUSB_OMAP_DMA) += tusb6010_omap.o |
30 | musb_hdrc-y += musbhsdma.o | 30 | musb_hdrc-$(CONFIG_USB_UX500_DMA) += ux500_dma.o |
31 | |||
32 | else | ||
33 | ifeq ($(CONFIG_USB_TI_CPPI_DMA),y) | ||
34 | musb_hdrc-y += cppi_dma.o | ||
35 | |||
36 | else | ||
37 | ifeq ($(CONFIG_USB_TUSB_OMAP_DMA),y) | ||
38 | musb_hdrc-y += tusb6010_omap.o | ||
39 | |||
40 | else | ||
41 | ifeq ($(CONFIG_USB_UX500_DMA),y) | ||
42 | musb_hdrc-y += ux500_dma.o | ||
43 | |||
44 | endif | ||
45 | endif | ||
46 | endif | ||
47 | endif | ||
48 | endif | ||
diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c index 08f1d0b662a3..e233d2b7d335 100644 --- a/drivers/usb/musb/am35x.c +++ b/drivers/usb/musb/am35x.c | |||
@@ -27,6 +27,7 @@ | |||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <linux/init.h> | 29 | #include <linux/init.h> |
30 | #include <linux/module.h> | ||
30 | #include <linux/clk.h> | 31 | #include <linux/clk.h> |
31 | #include <linux/io.h> | 32 | #include <linux/io.h> |
32 | #include <linux/platform_device.h> | 33 | #include <linux/platform_device.h> |
diff --git a/drivers/usb/musb/cppi_dma.c b/drivers/usb/musb/cppi_dma.c index 318fb4e8a885..66bc376005d2 100644 --- a/drivers/usb/musb/cppi_dma.c +++ b/drivers/usb/musb/cppi_dma.c | |||
@@ -513,7 +513,7 @@ static inline int cppi_autoreq_update(struct cppi_channel *rx, | |||
513 | if (!(val & MUSB_RXCSR_H_REQPKT)) { | 513 | if (!(val & MUSB_RXCSR_H_REQPKT)) { |
514 | val |= MUSB_RXCSR_H_REQPKT | MUSB_RXCSR_H_WZC_BITS; | 514 | val |= MUSB_RXCSR_H_REQPKT | MUSB_RXCSR_H_WZC_BITS; |
515 | musb_writew(regs, MUSB_RXCSR, val); | 515 | musb_writew(regs, MUSB_RXCSR, val); |
516 | /* flush writebufer */ | 516 | /* flush writebuffer */ |
517 | val = musb_readw(regs, MUSB_RXCSR); | 517 | val = musb_readw(regs, MUSB_RXCSR); |
518 | } | 518 | } |
519 | } | 519 | } |
@@ -750,7 +750,7 @@ cppi_next_tx_segment(struct musb *musb, struct cppi_channel *tx) | |||
750 | * So this module parameter lets the heuristic be disabled. When using | 750 | * So this module parameter lets the heuristic be disabled. When using |
751 | * gadgetfs, the heuristic will probably need to be disabled. | 751 | * gadgetfs, the heuristic will probably need to be disabled. |
752 | */ | 752 | */ |
753 | static int cppi_rx_rndis = 1; | 753 | static bool cppi_rx_rndis = 1; |
754 | 754 | ||
755 | module_param(cppi_rx_rndis, bool, 0); | 755 | module_param(cppi_rx_rndis, bool, 0); |
756 | MODULE_PARM_DESC(cppi_rx_rndis, "enable/disable RX RNDIS heuristic"); | 756 | MODULE_PARM_DESC(cppi_rx_rndis, "enable/disable RX RNDIS heuristic"); |
diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c index 4da7492ddbdb..2613bfdb09b6 100644 --- a/drivers/usb/musb/da8xx.c +++ b/drivers/usb/musb/da8xx.c | |||
@@ -27,6 +27,7 @@ | |||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <linux/init.h> | 29 | #include <linux/init.h> |
30 | #include <linux/module.h> | ||
30 | #include <linux/clk.h> | 31 | #include <linux/clk.h> |
31 | #include <linux/io.h> | 32 | #include <linux/io.h> |
32 | #include <linux/platform_device.h> | 33 | #include <linux/platform_device.h> |
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index 20a28731c338..56cf0243979e 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c | |||
@@ -661,7 +661,6 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, | |||
661 | 661 | ||
662 | handled = IRQ_HANDLED; | 662 | handled = IRQ_HANDLED; |
663 | musb->is_active = 1; | 663 | musb->is_active = 1; |
664 | set_bit(HCD_FLAG_SAW_IRQ, &hcd->flags); | ||
665 | 664 | ||
666 | musb->ep0_stage = MUSB_EP0_START; | 665 | musb->ep0_stage = MUSB_EP0_START; |
667 | 666 | ||
@@ -1432,7 +1431,7 @@ static int __init musb_core_init(u16 musb_type, struct musb *musb) | |||
1432 | struct musb_hw_ep *hw_ep = musb->endpoints + i; | 1431 | struct musb_hw_ep *hw_ep = musb->endpoints + i; |
1433 | 1432 | ||
1434 | hw_ep->fifo = MUSB_FIFO_OFFSET(i) + mbase; | 1433 | hw_ep->fifo = MUSB_FIFO_OFFSET(i) + mbase; |
1435 | #ifdef CONFIG_USB_MUSB_TUSB6010 | 1434 | #if defined(CONFIG_USB_MUSB_TUSB6010) || defined (CONFIG_USB_MUSB_TUSB6010_MODULE) |
1436 | hw_ep->fifo_async = musb->async + 0x400 + MUSB_FIFO_OFFSET(i); | 1435 | hw_ep->fifo_async = musb->async + 0x400 + MUSB_FIFO_OFFSET(i); |
1437 | hw_ep->fifo_sync = musb->sync + 0x400 + MUSB_FIFO_OFFSET(i); | 1436 | hw_ep->fifo_sync = musb->sync + 0x400 + MUSB_FIFO_OFFSET(i); |
1438 | hw_ep->fifo_sync_va = | 1437 | hw_ep->fifo_sync_va = |
@@ -1477,8 +1476,7 @@ static int __init musb_core_init(u16 musb_type, struct musb *musb) | |||
1477 | /*-------------------------------------------------------------------------*/ | 1476 | /*-------------------------------------------------------------------------*/ |
1478 | 1477 | ||
1479 | #if defined(CONFIG_SOC_OMAP2430) || defined(CONFIG_SOC_OMAP3430) || \ | 1478 | #if defined(CONFIG_SOC_OMAP2430) || defined(CONFIG_SOC_OMAP3430) || \ |
1480 | defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_ARCH_U8500) || \ | 1479 | defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_ARCH_U8500) |
1481 | defined(CONFIG_ARCH_U5500) | ||
1482 | 1480 | ||
1483 | static irqreturn_t generic_interrupt(int irq, void *__hci) | 1481 | static irqreturn_t generic_interrupt(int irq, void *__hci) |
1484 | { | 1482 | { |
@@ -1588,7 +1586,7 @@ irqreturn_t musb_interrupt(struct musb *musb) | |||
1588 | EXPORT_SYMBOL_GPL(musb_interrupt); | 1586 | EXPORT_SYMBOL_GPL(musb_interrupt); |
1589 | 1587 | ||
1590 | #ifndef CONFIG_MUSB_PIO_ONLY | 1588 | #ifndef CONFIG_MUSB_PIO_ONLY |
1591 | static int __initdata use_dma = 1; | 1589 | static bool __initdata use_dma = 1; |
1592 | 1590 | ||
1593 | /* "modprobe ... use_dma=0" etc */ | 1591 | /* "modprobe ... use_dma=0" etc */ |
1594 | module_param(use_dma, bool, 0); | 1592 | module_param(use_dma, bool, 0); |
@@ -1632,6 +1630,7 @@ void musb_dma_completion(struct musb *musb, u8 epnum, u8 transmit) | |||
1632 | } | 1630 | } |
1633 | } | 1631 | } |
1634 | } | 1632 | } |
1633 | EXPORT_SYMBOL_GPL(musb_dma_completion); | ||
1635 | 1634 | ||
1636 | #else | 1635 | #else |
1637 | #define use_dma 0 | 1636 | #define use_dma 0 |
@@ -2013,8 +2012,6 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl) | |||
2013 | if (status < 0) | 2012 | if (status < 0) |
2014 | goto fail3; | 2013 | goto fail3; |
2015 | 2014 | ||
2016 | pm_runtime_put(musb->controller); | ||
2017 | |||
2018 | status = musb_init_debugfs(musb); | 2015 | status = musb_init_debugfs(musb); |
2019 | if (status < 0) | 2016 | if (status < 0) |
2020 | goto fail4; | 2017 | goto fail4; |
@@ -2159,6 +2156,7 @@ static void musb_save_context(struct musb *musb) | |||
2159 | if (!epio) | 2156 | if (!epio) |
2160 | continue; | 2157 | continue; |
2161 | 2158 | ||
2159 | musb_writeb(musb_base, MUSB_INDEX, i); | ||
2162 | musb->context.index_regs[i].txmaxp = | 2160 | musb->context.index_regs[i].txmaxp = |
2163 | musb_readw(epio, MUSB_TXMAXP); | 2161 | musb_readw(epio, MUSB_TXMAXP); |
2164 | musb->context.index_regs[i].txcsr = | 2162 | musb->context.index_regs[i].txcsr = |
@@ -2234,6 +2232,7 @@ static void musb_restore_context(struct musb *musb) | |||
2234 | if (!epio) | 2232 | if (!epio) |
2235 | continue; | 2233 | continue; |
2236 | 2234 | ||
2235 | musb_writeb(musb_base, MUSB_INDEX, i); | ||
2237 | musb_writew(epio, MUSB_TXMAXP, | 2236 | musb_writew(epio, MUSB_TXMAXP, |
2238 | musb->context.index_regs[i].txmaxp); | 2237 | musb->context.index_regs[i].txmaxp); |
2239 | musb_writew(epio, MUSB_TXCSR, | 2238 | musb_writew(epio, MUSB_TXCSR, |
@@ -2302,18 +2301,12 @@ static int musb_suspend(struct device *dev) | |||
2302 | */ | 2301 | */ |
2303 | } | 2302 | } |
2304 | 2303 | ||
2305 | musb_save_context(musb); | ||
2306 | |||
2307 | spin_unlock_irqrestore(&musb->lock, flags); | 2304 | spin_unlock_irqrestore(&musb->lock, flags); |
2308 | return 0; | 2305 | return 0; |
2309 | } | 2306 | } |
2310 | 2307 | ||
2311 | static int musb_resume_noirq(struct device *dev) | 2308 | static int musb_resume_noirq(struct device *dev) |
2312 | { | 2309 | { |
2313 | struct musb *musb = dev_to_musb(dev); | ||
2314 | |||
2315 | musb_restore_context(musb); | ||
2316 | |||
2317 | /* for static cmos like DaVinci, register values were preserved | 2310 | /* for static cmos like DaVinci, register values were preserved |
2318 | * unless for some reason the whole soc powered down or the USB | 2311 | * unless for some reason the whole soc powered down or the USB |
2319 | * module got reset through the PSC (vs just being disabled). | 2312 | * module got reset through the PSC (vs just being disabled). |
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h index b3c065ab9dbc..3d28fb8a2dc9 100644 --- a/drivers/usb/musb/musb_core.h +++ b/drivers/usb/musb/musb_core.h | |||
@@ -40,7 +40,6 @@ | |||
40 | #include <linux/interrupt.h> | 40 | #include <linux/interrupt.h> |
41 | #include <linux/errno.h> | 41 | #include <linux/errno.h> |
42 | #include <linux/timer.h> | 42 | #include <linux/timer.h> |
43 | #include <linux/clk.h> | ||
44 | #include <linux/device.h> | 43 | #include <linux/device.h> |
45 | #include <linux/usb/ch9.h> | 44 | #include <linux/usb/ch9.h> |
46 | #include <linux/usb/gadget.h> | 45 | #include <linux/usb/gadget.h> |
@@ -311,6 +310,7 @@ struct musb_context_registers { | |||
311 | u8 index, testmode; | 310 | u8 index, testmode; |
312 | 311 | ||
313 | u8 devctl, busctl, misc; | 312 | u8 devctl, busctl, misc; |
313 | u32 otg_interfsel; | ||
314 | 314 | ||
315 | struct musb_csr_regs index_regs[MUSB_C_NUM_EPS]; | 315 | struct musb_csr_regs index_regs[MUSB_C_NUM_EPS]; |
316 | }; | 316 | }; |
@@ -327,6 +327,7 @@ struct musb { | |||
327 | 327 | ||
328 | irqreturn_t (*isr)(int, void *); | 328 | irqreturn_t (*isr)(int, void *); |
329 | struct work_struct irq_work; | 329 | struct work_struct irq_work; |
330 | struct work_struct otg_notifier_work; | ||
330 | u16 hwvers; | 331 | u16 hwvers; |
331 | 332 | ||
332 | /* this hub status bit is reserved by USB 2.0 and not seen by usbcore */ | 333 | /* this hub status bit is reserved by USB 2.0 and not seen by usbcore */ |
@@ -372,6 +373,7 @@ struct musb { | |||
372 | u16 int_tx; | 373 | u16 int_tx; |
373 | 374 | ||
374 | struct otg_transceiver *xceiv; | 375 | struct otg_transceiver *xceiv; |
376 | u8 xceiv_event; | ||
375 | 377 | ||
376 | int nIrq; | 378 | int nIrq; |
377 | unsigned irq_wake:1; | 379 | unsigned irq_wake:1; |
diff --git a/drivers/usb/musb/musb_debug.h b/drivers/usb/musb/musb_debug.h index 742eada5002e..27ba8f799462 100644 --- a/drivers/usb/musb/musb_debug.h +++ b/drivers/usb/musb/musb_debug.h | |||
@@ -43,8 +43,8 @@ | |||
43 | #define ERR(fmt, args...) yprintk(KERN_ERR, fmt, ## args) | 43 | #define ERR(fmt, args...) yprintk(KERN_ERR, fmt, ## args) |
44 | 44 | ||
45 | #ifdef CONFIG_DEBUG_FS | 45 | #ifdef CONFIG_DEBUG_FS |
46 | extern int musb_init_debugfs(struct musb *musb); | 46 | int musb_init_debugfs(struct musb *musb); |
47 | extern void musb_exit_debugfs(struct musb *musb); | 47 | void musb_exit_debugfs(struct musb *musb); |
48 | #else | 48 | #else |
49 | static inline int musb_init_debugfs(struct musb *musb) | 49 | static inline int musb_init_debugfs(struct musb *musb) |
50 | { | 50 | { |
diff --git a/drivers/usb/musb/musb_debugfs.c b/drivers/usb/musb/musb_debugfs.c index 61f4ee466df7..13d9af9bf920 100644 --- a/drivers/usb/musb/musb_debugfs.c +++ b/drivers/usb/musb/musb_debugfs.c | |||
@@ -33,11 +33,7 @@ | |||
33 | 33 | ||
34 | #include <linux/module.h> | 34 | #include <linux/module.h> |
35 | #include <linux/kernel.h> | 35 | #include <linux/kernel.h> |
36 | #include <linux/sched.h> | ||
37 | #include <linux/init.h> | 36 | #include <linux/init.h> |
38 | #include <linux/list.h> | ||
39 | #include <linux/platform_device.h> | ||
40 | #include <linux/io.h> | ||
41 | #include <linux/debugfs.h> | 37 | #include <linux/debugfs.h> |
42 | #include <linux/seq_file.h> | 38 | #include <linux/seq_file.h> |
43 | 39 | ||
@@ -46,10 +42,6 @@ | |||
46 | #include "musb_core.h" | 42 | #include "musb_core.h" |
47 | #include "musb_debug.h" | 43 | #include "musb_debug.h" |
48 | 44 | ||
49 | #ifdef CONFIG_ARCH_DAVINCI | ||
50 | #include "davinci.h" | ||
51 | #endif | ||
52 | |||
53 | struct musb_register_map { | 45 | struct musb_register_map { |
54 | char *name; | 46 | char *name; |
55 | unsigned offset; | 47 | unsigned offset; |
diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c index ae4a20acef6c..ac3d2eec20fe 100644 --- a/drivers/usb/musb/musb_gadget.c +++ b/drivers/usb/musb/musb_gadget.c | |||
@@ -40,8 +40,6 @@ | |||
40 | #include <linux/smp.h> | 40 | #include <linux/smp.h> |
41 | #include <linux/spinlock.h> | 41 | #include <linux/spinlock.h> |
42 | #include <linux/delay.h> | 42 | #include <linux/delay.h> |
43 | #include <linux/moduleparam.h> | ||
44 | #include <linux/stat.h> | ||
45 | #include <linux/dma-mapping.h> | 43 | #include <linux/dma-mapping.h> |
46 | #include <linux/slab.h> | 44 | #include <linux/slab.h> |
47 | 45 | ||
@@ -1844,7 +1842,7 @@ int __init musb_gadget_setup(struct musb *musb) | |||
1844 | */ | 1842 | */ |
1845 | 1843 | ||
1846 | musb->g.ops = &musb_gadget_operations; | 1844 | musb->g.ops = &musb_gadget_operations; |
1847 | musb->g.is_dualspeed = 1; | 1845 | musb->g.max_speed = USB_SPEED_HIGH; |
1848 | musb->g.speed = USB_SPEED_UNKNOWN; | 1846 | musb->g.speed = USB_SPEED_UNKNOWN; |
1849 | 1847 | ||
1850 | /* this "gadget" abstracts/virtualizes the controller */ | 1848 | /* this "gadget" abstracts/virtualizes the controller */ |
@@ -1903,7 +1901,7 @@ static int musb_gadget_start(struct usb_gadget *g, | |||
1903 | unsigned long flags; | 1901 | unsigned long flags; |
1904 | int retval = -EINVAL; | 1902 | int retval = -EINVAL; |
1905 | 1903 | ||
1906 | if (driver->speed != USB_SPEED_HIGH) | 1904 | if (driver->max_speed < USB_SPEED_HIGH) |
1907 | goto err0; | 1905 | goto err0; |
1908 | 1906 | ||
1909 | pm_runtime_get_sync(musb->controller); | 1907 | pm_runtime_get_sync(musb->controller); |
@@ -1999,10 +1997,6 @@ static void stop_activity(struct musb *musb, struct usb_gadget_driver *driver) | |||
1999 | nuke(&hw_ep->ep_out, -ESHUTDOWN); | 1997 | nuke(&hw_ep->ep_out, -ESHUTDOWN); |
2000 | } | 1998 | } |
2001 | } | 1999 | } |
2002 | |||
2003 | spin_unlock(&musb->lock); | ||
2004 | driver->disconnect(&musb->g); | ||
2005 | spin_lock(&musb->lock); | ||
2006 | } | 2000 | } |
2007 | } | 2001 | } |
2008 | 2002 | ||
diff --git a/drivers/usb/musb/musb_gadget_ep0.c b/drivers/usb/musb/musb_gadget_ep0.c index 6a0d0467ec74..e40d7647caf1 100644 --- a/drivers/usb/musb/musb_gadget_ep0.c +++ b/drivers/usb/musb/musb_gadget_ep0.c | |||
@@ -37,7 +37,6 @@ | |||
37 | #include <linux/list.h> | 37 | #include <linux/list.h> |
38 | #include <linux/timer.h> | 38 | #include <linux/timer.h> |
39 | #include <linux/spinlock.h> | 39 | #include <linux/spinlock.h> |
40 | #include <linux/init.h> | ||
41 | #include <linux/device.h> | 40 | #include <linux/device.h> |
42 | #include <linux/interrupt.h> | 41 | #include <linux/interrupt.h> |
43 | 42 | ||
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c index 60ddba8066ea..79cb0af779fa 100644 --- a/drivers/usb/musb/musb_host.c +++ b/drivers/usb/musb/musb_host.c | |||
@@ -774,6 +774,10 @@ static void musb_ep_program(struct musb *musb, u8 epnum, | |||
774 | if (musb->double_buffer_not_ok) | 774 | if (musb->double_buffer_not_ok) |
775 | musb_writew(epio, MUSB_TXMAXP, | 775 | musb_writew(epio, MUSB_TXMAXP, |
776 | hw_ep->max_packet_sz_tx); | 776 | hw_ep->max_packet_sz_tx); |
777 | else if (can_bulk_split(musb, qh->type)) | ||
778 | musb_writew(epio, MUSB_TXMAXP, packet_sz | ||
779 | | ((hw_ep->max_packet_sz_tx / | ||
780 | packet_sz) - 1) << 11); | ||
777 | else | 781 | else |
778 | musb_writew(epio, MUSB_TXMAXP, | 782 | musb_writew(epio, MUSB_TXMAXP, |
779 | qh->maxpacket | | 783 | qh->maxpacket | |
diff --git a/drivers/usb/musb/musb_io.h b/drivers/usb/musb/musb_io.h index 03c6ccdbb3be..e61aa95f2d2a 100644 --- a/drivers/usb/musb/musb_io.h +++ b/drivers/usb/musb/musb_io.h | |||
@@ -74,7 +74,7 @@ static inline void musb_writel(void __iomem *addr, unsigned offset, u32 data) | |||
74 | { __raw_writel(data, addr + offset); } | 74 | { __raw_writel(data, addr + offset); } |
75 | 75 | ||
76 | 76 | ||
77 | #ifdef CONFIG_USB_MUSB_TUSB6010 | 77 | #if defined(CONFIG_USB_MUSB_TUSB6010) || defined (CONFIG_USB_MUSB_TUSB6010_MODULE) |
78 | 78 | ||
79 | /* | 79 | /* |
80 | * TUSB6010 doesn't allow 8-bit access; 16-bit access is the minimum. | 80 | * TUSB6010 doesn't allow 8-bit access; 16-bit access is the minimum. |
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c index ba85f273e487..c27bbbf32b52 100644 --- a/drivers/usb/musb/omap2430.c +++ b/drivers/usb/musb/omap2430.c | |||
@@ -29,7 +29,6 @@ | |||
29 | #include <linux/sched.h> | 29 | #include <linux/sched.h> |
30 | #include <linux/init.h> | 30 | #include <linux/init.h> |
31 | #include <linux/list.h> | 31 | #include <linux/list.h> |
32 | #include <linux/clk.h> | ||
33 | #include <linux/io.h> | 32 | #include <linux/io.h> |
34 | #include <linux/platform_device.h> | 33 | #include <linux/platform_device.h> |
35 | #include <linux/dma-mapping.h> | 34 | #include <linux/dma-mapping.h> |
@@ -228,21 +227,25 @@ static int musb_otg_notifications(struct notifier_block *nb, | |||
228 | unsigned long event, void *unused) | 227 | unsigned long event, void *unused) |
229 | { | 228 | { |
230 | struct musb *musb = container_of(nb, struct musb, nb); | 229 | struct musb *musb = container_of(nb, struct musb, nb); |
230 | |||
231 | musb->xceiv_event = event; | ||
232 | schedule_work(&musb->otg_notifier_work); | ||
233 | |||
234 | return 0; | ||
235 | } | ||
236 | |||
237 | static void musb_otg_notifier_work(struct work_struct *data_notifier_work) | ||
238 | { | ||
239 | struct musb *musb = container_of(data_notifier_work, struct musb, otg_notifier_work); | ||
231 | struct device *dev = musb->controller; | 240 | struct device *dev = musb->controller; |
232 | struct musb_hdrc_platform_data *pdata = dev->platform_data; | 241 | struct musb_hdrc_platform_data *pdata = dev->platform_data; |
233 | struct omap_musb_board_data *data = pdata->board_data; | 242 | struct omap_musb_board_data *data = pdata->board_data; |
234 | 243 | ||
235 | switch (event) { | 244 | switch (musb->xceiv_event) { |
236 | case USB_EVENT_ID: | 245 | case USB_EVENT_ID: |
237 | dev_dbg(musb->controller, "ID GND\n"); | 246 | dev_dbg(musb->controller, "ID GND\n"); |
238 | 247 | ||
239 | if (is_otg_enabled(musb)) { | 248 | if (!is_otg_enabled(musb) || musb->gadget_driver) { |
240 | if (musb->gadget_driver) { | ||
241 | pm_runtime_get_sync(musb->controller); | ||
242 | otg_init(musb->xceiv); | ||
243 | omap2430_musb_set_vbus(musb, 1); | ||
244 | } | ||
245 | } else { | ||
246 | pm_runtime_get_sync(musb->controller); | 249 | pm_runtime_get_sync(musb->controller); |
247 | otg_init(musb->xceiv); | 250 | otg_init(musb->xceiv); |
248 | omap2430_musb_set_vbus(musb, 1); | 251 | omap2430_musb_set_vbus(musb, 1); |
@@ -274,10 +277,7 @@ static int musb_otg_notifications(struct notifier_block *nb, | |||
274 | break; | 277 | break; |
275 | default: | 278 | default: |
276 | dev_dbg(musb->controller, "ID float\n"); | 279 | dev_dbg(musb->controller, "ID float\n"); |
277 | return NOTIFY_DONE; | ||
278 | } | 280 | } |
279 | |||
280 | return NOTIFY_OK; | ||
281 | } | 281 | } |
282 | 282 | ||
283 | static int omap2430_musb_init(struct musb *musb) | 283 | static int omap2430_musb_init(struct musb *musb) |
@@ -297,6 +297,8 @@ static int omap2430_musb_init(struct musb *musb) | |||
297 | return -ENODEV; | 297 | return -ENODEV; |
298 | } | 298 | } |
299 | 299 | ||
300 | INIT_WORK(&musb->otg_notifier_work, musb_otg_notifier_work); | ||
301 | |||
300 | status = pm_runtime_get_sync(dev); | 302 | status = pm_runtime_get_sync(dev); |
301 | if (status < 0) { | 303 | if (status < 0) { |
302 | dev_err(dev, "pm_runtime_get_sync FAILED"); | 304 | dev_err(dev, "pm_runtime_get_sync FAILED"); |
@@ -334,7 +336,6 @@ static int omap2430_musb_init(struct musb *musb) | |||
334 | return 0; | 336 | return 0; |
335 | 337 | ||
336 | err1: | 338 | err1: |
337 | pm_runtime_disable(dev); | ||
338 | return status; | 339 | return status; |
339 | } | 340 | } |
340 | 341 | ||
@@ -350,20 +351,19 @@ static void omap2430_musb_enable(struct musb *musb) | |||
350 | 351 | ||
351 | case USB_EVENT_ID: | 352 | case USB_EVENT_ID: |
352 | otg_init(musb->xceiv); | 353 | otg_init(musb->xceiv); |
353 | if (data->interface_type == MUSB_INTERFACE_UTMI) { | 354 | if (data->interface_type != MUSB_INTERFACE_UTMI) |
354 | devctl = musb_readb(musb->mregs, MUSB_DEVCTL); | 355 | break; |
355 | /* start the session */ | 356 | devctl = musb_readb(musb->mregs, MUSB_DEVCTL); |
356 | devctl |= MUSB_DEVCTL_SESSION; | 357 | /* start the session */ |
357 | musb_writeb(musb->mregs, MUSB_DEVCTL, devctl); | 358 | devctl |= MUSB_DEVCTL_SESSION; |
358 | while (musb_readb(musb->mregs, MUSB_DEVCTL) & | 359 | musb_writeb(musb->mregs, MUSB_DEVCTL, devctl); |
359 | MUSB_DEVCTL_BDEVICE) { | 360 | while (musb_readb(musb->mregs, MUSB_DEVCTL) & |
360 | cpu_relax(); | 361 | MUSB_DEVCTL_BDEVICE) { |
361 | 362 | cpu_relax(); | |
362 | if (time_after(jiffies, timeout)) { | 363 | |
363 | dev_err(musb->controller, | 364 | if (time_after(jiffies, timeout)) { |
364 | "configured as A device timeout"); | 365 | dev_err(dev, "configured as A device timeout"); |
365 | break; | 366 | break; |
366 | } | ||
367 | } | 367 | } |
368 | } | 368 | } |
369 | break; | 369 | break; |
@@ -478,7 +478,6 @@ static int __exit omap2430_remove(struct platform_device *pdev) | |||
478 | platform_device_del(glue->musb); | 478 | platform_device_del(glue->musb); |
479 | platform_device_put(glue->musb); | 479 | platform_device_put(glue->musb); |
480 | pm_runtime_put(&pdev->dev); | 480 | pm_runtime_put(&pdev->dev); |
481 | pm_runtime_disable(&pdev->dev); | ||
482 | kfree(glue); | 481 | kfree(glue); |
483 | 482 | ||
484 | return 0; | 483 | return 0; |
@@ -491,6 +490,9 @@ static int omap2430_runtime_suspend(struct device *dev) | |||
491 | struct omap2430_glue *glue = dev_get_drvdata(dev); | 490 | struct omap2430_glue *glue = dev_get_drvdata(dev); |
492 | struct musb *musb = glue_to_musb(glue); | 491 | struct musb *musb = glue_to_musb(glue); |
493 | 492 | ||
493 | musb->context.otg_interfsel = musb_readl(musb->mregs, | ||
494 | OTG_INTERFSEL); | ||
495 | |||
494 | omap2430_low_level_exit(musb); | 496 | omap2430_low_level_exit(musb); |
495 | otg_set_suspend(musb->xceiv, 1); | 497 | otg_set_suspend(musb->xceiv, 1); |
496 | 498 | ||
@@ -503,6 +505,9 @@ static int omap2430_runtime_resume(struct device *dev) | |||
503 | struct musb *musb = glue_to_musb(glue); | 505 | struct musb *musb = glue_to_musb(glue); |
504 | 506 | ||
505 | omap2430_low_level_init(musb); | 507 | omap2430_low_level_init(musb); |
508 | musb_writel(musb->mregs, OTG_INTERFSEL, | ||
509 | musb->context.otg_interfsel); | ||
510 | |||
506 | otg_set_suspend(musb->xceiv, 0); | 511 | otg_set_suspend(musb->xceiv, 0); |
507 | 512 | ||
508 | return 0; | 513 | return 0; |
diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c index ec1480191f78..1f405616e6cd 100644 --- a/drivers/usb/musb/tusb6010.c +++ b/drivers/usb/musb/tusb6010.c | |||
@@ -56,6 +56,7 @@ u8 tusb_get_revision(struct musb *musb) | |||
56 | 56 | ||
57 | return rev; | 57 | return rev; |
58 | } | 58 | } |
59 | EXPORT_SYMBOL_GPL(tusb_get_revision); | ||
59 | 60 | ||
60 | static int tusb_print_revision(struct musb *musb) | 61 | static int tusb_print_revision(struct musb *musb) |
61 | { | 62 | { |
diff --git a/drivers/usb/musb/ux500_dma.c b/drivers/usb/musb/ux500_dma.c index f8fd0ddee14a..97cb45916c43 100644 --- a/drivers/usb/musb/ux500_dma.c +++ b/drivers/usb/musb/ux500_dma.c | |||
@@ -37,7 +37,6 @@ struct ux500_dma_channel { | |||
37 | struct dma_channel channel; | 37 | struct dma_channel channel; |
38 | struct ux500_dma_controller *controller; | 38 | struct ux500_dma_controller *controller; |
39 | struct musb_hw_ep *hw_ep; | 39 | struct musb_hw_ep *hw_ep; |
40 | struct work_struct channel_work; | ||
41 | struct dma_chan *dma_chan; | 40 | struct dma_chan *dma_chan; |
42 | unsigned int cur_len; | 41 | unsigned int cur_len; |
43 | dma_cookie_t cookie; | 42 | dma_cookie_t cookie; |
@@ -56,31 +55,11 @@ struct ux500_dma_controller { | |||
56 | dma_addr_t phy_base; | 55 | dma_addr_t phy_base; |
57 | }; | 56 | }; |
58 | 57 | ||
59 | /* Work function invoked from DMA callback to handle tx transfers. */ | ||
60 | static void ux500_tx_work(struct work_struct *data) | ||
61 | { | ||
62 | struct ux500_dma_channel *ux500_channel = container_of(data, | ||
63 | struct ux500_dma_channel, channel_work); | ||
64 | struct musb_hw_ep *hw_ep = ux500_channel->hw_ep; | ||
65 | struct musb *musb = hw_ep->musb; | ||
66 | unsigned long flags; | ||
67 | |||
68 | dev_dbg(musb->controller, "DMA tx transfer done on hw_ep=%d\n", | ||
69 | hw_ep->epnum); | ||
70 | |||
71 | spin_lock_irqsave(&musb->lock, flags); | ||
72 | ux500_channel->channel.actual_len = ux500_channel->cur_len; | ||
73 | ux500_channel->channel.status = MUSB_DMA_STATUS_FREE; | ||
74 | musb_dma_completion(musb, hw_ep->epnum, | ||
75 | ux500_channel->is_tx); | ||
76 | spin_unlock_irqrestore(&musb->lock, flags); | ||
77 | } | ||
78 | |||
79 | /* Work function invoked from DMA callback to handle rx transfers. */ | 58 | /* Work function invoked from DMA callback to handle rx transfers. */ |
80 | static void ux500_rx_work(struct work_struct *data) | 59 | void ux500_dma_callback(void *private_data) |
81 | { | 60 | { |
82 | struct ux500_dma_channel *ux500_channel = container_of(data, | 61 | struct dma_channel *channel = private_data; |
83 | struct ux500_dma_channel, channel_work); | 62 | struct ux500_dma_channel *ux500_channel = channel->private_data; |
84 | struct musb_hw_ep *hw_ep = ux500_channel->hw_ep; | 63 | struct musb_hw_ep *hw_ep = ux500_channel->hw_ep; |
85 | struct musb *musb = hw_ep->musb; | 64 | struct musb *musb = hw_ep->musb; |
86 | unsigned long flags; | 65 | unsigned long flags; |
@@ -94,14 +73,7 @@ static void ux500_rx_work(struct work_struct *data) | |||
94 | musb_dma_completion(musb, hw_ep->epnum, | 73 | musb_dma_completion(musb, hw_ep->epnum, |
95 | ux500_channel->is_tx); | 74 | ux500_channel->is_tx); |
96 | spin_unlock_irqrestore(&musb->lock, flags); | 75 | spin_unlock_irqrestore(&musb->lock, flags); |
97 | } | ||
98 | |||
99 | void ux500_dma_callback(void *private_data) | ||
100 | { | ||
101 | struct dma_channel *channel = (struct dma_channel *)private_data; | ||
102 | struct ux500_dma_channel *ux500_channel = channel->private_data; | ||
103 | 76 | ||
104 | schedule_work(&ux500_channel->channel_work); | ||
105 | } | 77 | } |
106 | 78 | ||
107 | static bool ux500_configure_channel(struct dma_channel *channel, | 79 | static bool ux500_configure_channel(struct dma_channel *channel, |
@@ -330,7 +302,6 @@ static int ux500_dma_controller_start(struct dma_controller *c) | |||
330 | void **param_array; | 302 | void **param_array; |
331 | struct ux500_dma_channel *channel_array; | 303 | struct ux500_dma_channel *channel_array; |
332 | u32 ch_count; | 304 | u32 ch_count; |
333 | void (*musb_channel_work)(struct work_struct *); | ||
334 | dma_cap_mask_t mask; | 305 | dma_cap_mask_t mask; |
335 | 306 | ||
336 | if ((data->num_rx_channels > UX500_MUSB_DMA_NUM_RX_CHANNELS) || | 307 | if ((data->num_rx_channels > UX500_MUSB_DMA_NUM_RX_CHANNELS) || |
@@ -347,7 +318,6 @@ static int ux500_dma_controller_start(struct dma_controller *c) | |||
347 | channel_array = controller->rx_channel; | 318 | channel_array = controller->rx_channel; |
348 | ch_count = data->num_rx_channels; | 319 | ch_count = data->num_rx_channels; |
349 | param_array = data->dma_rx_param_array; | 320 | param_array = data->dma_rx_param_array; |
350 | musb_channel_work = ux500_rx_work; | ||
351 | 321 | ||
352 | for (dir = 0; dir < 2; dir++) { | 322 | for (dir = 0; dir < 2; dir++) { |
353 | for (ch_num = 0; ch_num < ch_count; ch_num++) { | 323 | for (ch_num = 0; ch_num < ch_count; ch_num++) { |
@@ -374,15 +344,12 @@ static int ux500_dma_controller_start(struct dma_controller *c) | |||
374 | return -EBUSY; | 344 | return -EBUSY; |
375 | } | 345 | } |
376 | 346 | ||
377 | INIT_WORK(&ux500_channel->channel_work, | ||
378 | musb_channel_work); | ||
379 | } | 347 | } |
380 | 348 | ||
381 | /* Prepare the loop for TX channels */ | 349 | /* Prepare the loop for TX channels */ |
382 | channel_array = controller->tx_channel; | 350 | channel_array = controller->tx_channel; |
383 | ch_count = data->num_tx_channels; | 351 | ch_count = data->num_tx_channels; |
384 | param_array = data->dma_tx_param_array; | 352 | param_array = data->dma_tx_param_array; |
385 | musb_channel_work = ux500_tx_work; | ||
386 | is_tx = 1; | 353 | is_tx = 1; |
387 | } | 354 | } |
388 | 355 | ||
diff --git a/drivers/usb/otg/Kconfig b/drivers/usb/otg/Kconfig index c66481ad98d7..2a25955881fc 100644 --- a/drivers/usb/otg/Kconfig +++ b/drivers/usb/otg/Kconfig | |||
@@ -82,9 +82,9 @@ config NOP_USB_XCEIV | |||
82 | tristate "NOP USB Transceiver Driver" | 82 | tristate "NOP USB Transceiver Driver" |
83 | select USB_OTG_UTILS | 83 | select USB_OTG_UTILS |
84 | help | 84 | help |
85 | this driver is to be used by all the usb transceiver which are either | 85 | This driver is to be used by all the usb transceiver which are either |
86 | built-in with usb ip or which are autonomous and doesn't require any | 86 | built-in with usb ip or which are autonomous and doesn't require any |
87 | phy programming such as ISP1x04 etc. | 87 | phy programming such as ISP1x04 etc. |
88 | 88 | ||
89 | config USB_LANGWELL_OTG | 89 | config USB_LANGWELL_OTG |
90 | tristate "Intel Langwell USB OTG dual-role support" | 90 | tristate "Intel Langwell USB OTG dual-role support" |
@@ -114,13 +114,13 @@ config USB_MSM_OTG | |||
114 | has an external PHY. | 114 | has an external PHY. |
115 | 115 | ||
116 | config AB8500_USB | 116 | config AB8500_USB |
117 | tristate "AB8500 USB Transceiver Driver" | 117 | tristate "AB8500 USB Transceiver Driver" |
118 | depends on AB8500_CORE | 118 | depends on AB8500_CORE |
119 | select USB_OTG_UTILS | 119 | select USB_OTG_UTILS |
120 | help | 120 | help |
121 | Enable this to support the USB OTG transceiver in AB8500 chip. | 121 | Enable this to support the USB OTG transceiver in AB8500 chip. |
122 | This transceiver supports high and full speed devices plus, | 122 | This transceiver supports high and full speed devices plus, |
123 | in host mode, low speed. | 123 | in host mode, low speed. |
124 | 124 | ||
125 | config FSL_USB2_OTG | 125 | config FSL_USB2_OTG |
126 | bool "Freescale USB OTG Transceiver Driver" | 126 | bool "Freescale USB OTG Transceiver Driver" |
@@ -130,4 +130,16 @@ config FSL_USB2_OTG | |||
130 | help | 130 | help |
131 | Enable this to support Freescale USB OTG transceiver. | 131 | Enable this to support Freescale USB OTG transceiver. |
132 | 132 | ||
133 | config USB_MV_OTG | ||
134 | tristate "Marvell USB OTG support" | ||
135 | depends on USB_MV_UDC | ||
136 | select USB_OTG | ||
137 | select USB_OTG_UTILS | ||
138 | help | ||
139 | Say Y here if you want to build Marvell USB OTG transciever | ||
140 | driver in kernel (including PXA and MMP series). This driver | ||
141 | implements role switch between EHCI host driver and gadget driver. | ||
142 | |||
143 | To compile this driver as a module, choose M here. | ||
144 | |||
133 | endif # USB || OTG | 145 | endif # USB || OTG |
diff --git a/drivers/usb/otg/Makefile b/drivers/usb/otg/Makefile index 566655c53331..b2c5a9598637 100644 --- a/drivers/usb/otg/Makefile +++ b/drivers/usb/otg/Makefile | |||
@@ -21,3 +21,4 @@ obj-$(CONFIG_USB_MSM_OTG) += msm_otg.o | |||
21 | obj-$(CONFIG_AB8500_USB) += ab8500-usb.o | 21 | obj-$(CONFIG_AB8500_USB) += ab8500-usb.o |
22 | fsl_usb2_otg-objs := fsl_otg.o otg_fsm.o | 22 | fsl_usb2_otg-objs := fsl_otg.o otg_fsm.o |
23 | obj-$(CONFIG_FSL_USB2_OTG) += fsl_usb2_otg.o | 23 | obj-$(CONFIG_FSL_USB2_OTG) += fsl_usb2_otg.o |
24 | obj-$(CONFIG_USB_MV_OTG) += mv_otg.o | ||
diff --git a/drivers/usb/otg/ab8500-usb.c b/drivers/usb/otg/ab8500-usb.c index 07ccea9ada40..74fe6e62e0f7 100644 --- a/drivers/usb/otg/ab8500-usb.c +++ b/drivers/usb/otg/ab8500-usb.c | |||
@@ -30,7 +30,7 @@ | |||
30 | #include <linux/interrupt.h> | 30 | #include <linux/interrupt.h> |
31 | #include <linux/delay.h> | 31 | #include <linux/delay.h> |
32 | #include <linux/mfd/abx500.h> | 32 | #include <linux/mfd/abx500.h> |
33 | #include <linux/mfd/ab8500.h> | 33 | #include <linux/mfd/abx500/ab8500.h> |
34 | 34 | ||
35 | #define AB8500_MAIN_WD_CTRL_REG 0x01 | 35 | #define AB8500_MAIN_WD_CTRL_REG 0x01 |
36 | #define AB8500_USB_LINE_STAT_REG 0x80 | 36 | #define AB8500_USB_LINE_STAT_REG 0x80 |
diff --git a/drivers/usb/otg/fsl_otg.c b/drivers/usb/otg/fsl_otg.c index 0f420b25e9a9..a190850d2d3b 100644 --- a/drivers/usb/otg/fsl_otg.c +++ b/drivers/usb/otg/fsl_otg.c | |||
@@ -639,7 +639,7 @@ static int fsl_otg_set_power(struct otg_transceiver *otg_p, unsigned mA) | |||
639 | * Delayed pin detect interrupt processing. | 639 | * Delayed pin detect interrupt processing. |
640 | * | 640 | * |
641 | * When the Mini-A cable is disconnected from the board, | 641 | * When the Mini-A cable is disconnected from the board, |
642 | * the pin-detect interrupt happens before the disconnnect | 642 | * the pin-detect interrupt happens before the disconnect |
643 | * interrupts for the connected device(s). In order to | 643 | * interrupts for the connected device(s). In order to |
644 | * process the disconnect interrupt(s) prior to switching | 644 | * process the disconnect interrupt(s) prior to switching |
645 | * roles, the pin-detect interrupts are delayed, and handled | 645 | * roles, the pin-detect interrupts are delayed, and handled |
@@ -1151,18 +1151,7 @@ struct platform_driver fsl_otg_driver = { | |||
1151 | }, | 1151 | }, |
1152 | }; | 1152 | }; |
1153 | 1153 | ||
1154 | static int __init fsl_usb_otg_init(void) | 1154 | module_platform_driver(fsl_otg_driver); |
1155 | { | ||
1156 | pr_info(DRIVER_INFO "\n"); | ||
1157 | return platform_driver_register(&fsl_otg_driver); | ||
1158 | } | ||
1159 | module_init(fsl_usb_otg_init); | ||
1160 | |||
1161 | static void __exit fsl_usb_otg_exit(void) | ||
1162 | { | ||
1163 | platform_driver_unregister(&fsl_otg_driver); | ||
1164 | } | ||
1165 | module_exit(fsl_usb_otg_exit); | ||
1166 | 1155 | ||
1167 | MODULE_DESCRIPTION(DRIVER_INFO); | 1156 | MODULE_DESCRIPTION(DRIVER_INFO); |
1168 | MODULE_AUTHOR(DRIVER_AUTHOR); | 1157 | MODULE_AUTHOR(DRIVER_AUTHOR); |
diff --git a/drivers/usb/otg/mv_otg.c b/drivers/usb/otg/mv_otg.c new file mode 100644 index 000000000000..db0d4fcdc8e2 --- /dev/null +++ b/drivers/usb/otg/mv_otg.c | |||
@@ -0,0 +1,957 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2011 Marvell International Ltd. All rights reserved. | ||
3 | * Author: Chao Xie <chao.xie@marvell.com> | ||
4 | * Neil Zhang <zhangwm@marvell.com> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify it | ||
7 | * under the terms of the GNU General Public License as published by the | ||
8 | * Free Software Foundation; either version 2 of the License, or (at your | ||
9 | * option) any later version. | ||
10 | */ | ||
11 | |||
12 | #include <linux/module.h> | ||
13 | #include <linux/kernel.h> | ||
14 | #include <linux/init.h> | ||
15 | #include <linux/io.h> | ||
16 | #include <linux/uaccess.h> | ||
17 | #include <linux/device.h> | ||
18 | #include <linux/proc_fs.h> | ||
19 | #include <linux/clk.h> | ||
20 | #include <linux/workqueue.h> | ||
21 | #include <linux/platform_device.h> | ||
22 | |||
23 | #include <linux/usb.h> | ||
24 | #include <linux/usb/ch9.h> | ||
25 | #include <linux/usb/otg.h> | ||
26 | #include <linux/usb/gadget.h> | ||
27 | #include <linux/usb/hcd.h> | ||
28 | #include <linux/platform_data/mv_usb.h> | ||
29 | |||
30 | #include "mv_otg.h" | ||
31 | |||
32 | #define DRIVER_DESC "Marvell USB OTG transceiver driver" | ||
33 | #define DRIVER_VERSION "Jan 20, 2010" | ||
34 | |||
35 | MODULE_DESCRIPTION(DRIVER_DESC); | ||
36 | MODULE_VERSION(DRIVER_VERSION); | ||
37 | MODULE_LICENSE("GPL"); | ||
38 | |||
39 | static const char driver_name[] = "mv-otg"; | ||
40 | |||
41 | static char *state_string[] = { | ||
42 | "undefined", | ||
43 | "b_idle", | ||
44 | "b_srp_init", | ||
45 | "b_peripheral", | ||
46 | "b_wait_acon", | ||
47 | "b_host", | ||
48 | "a_idle", | ||
49 | "a_wait_vrise", | ||
50 | "a_wait_bcon", | ||
51 | "a_host", | ||
52 | "a_suspend", | ||
53 | "a_peripheral", | ||
54 | "a_wait_vfall", | ||
55 | "a_vbus_err" | ||
56 | }; | ||
57 | |||
58 | static int mv_otg_set_vbus(struct otg_transceiver *otg, bool on) | ||
59 | { | ||
60 | struct mv_otg *mvotg = container_of(otg, struct mv_otg, otg); | ||
61 | if (mvotg->pdata->set_vbus == NULL) | ||
62 | return -ENODEV; | ||
63 | |||
64 | return mvotg->pdata->set_vbus(on); | ||
65 | } | ||
66 | |||
67 | static int mv_otg_set_host(struct otg_transceiver *otg, | ||
68 | struct usb_bus *host) | ||
69 | { | ||
70 | otg->host = host; | ||
71 | |||
72 | return 0; | ||
73 | } | ||
74 | |||
75 | static int mv_otg_set_peripheral(struct otg_transceiver *otg, | ||
76 | struct usb_gadget *gadget) | ||
77 | { | ||
78 | otg->gadget = gadget; | ||
79 | |||
80 | return 0; | ||
81 | } | ||
82 | |||
83 | static void mv_otg_run_state_machine(struct mv_otg *mvotg, | ||
84 | unsigned long delay) | ||
85 | { | ||
86 | dev_dbg(&mvotg->pdev->dev, "transceiver is updated\n"); | ||
87 | if (!mvotg->qwork) | ||
88 | return; | ||
89 | |||
90 | queue_delayed_work(mvotg->qwork, &mvotg->work, delay); | ||
91 | } | ||
92 | |||
93 | static void mv_otg_timer_await_bcon(unsigned long data) | ||
94 | { | ||
95 | struct mv_otg *mvotg = (struct mv_otg *) data; | ||
96 | |||
97 | mvotg->otg_ctrl.a_wait_bcon_timeout = 1; | ||
98 | |||
99 | dev_info(&mvotg->pdev->dev, "B Device No Response!\n"); | ||
100 | |||
101 | if (spin_trylock(&mvotg->wq_lock)) { | ||
102 | mv_otg_run_state_machine(mvotg, 0); | ||
103 | spin_unlock(&mvotg->wq_lock); | ||
104 | } | ||
105 | } | ||
106 | |||
107 | static int mv_otg_cancel_timer(struct mv_otg *mvotg, unsigned int id) | ||
108 | { | ||
109 | struct timer_list *timer; | ||
110 | |||
111 | if (id >= OTG_TIMER_NUM) | ||
112 | return -EINVAL; | ||
113 | |||
114 | timer = &mvotg->otg_ctrl.timer[id]; | ||
115 | |||
116 | if (timer_pending(timer)) | ||
117 | del_timer(timer); | ||
118 | |||
119 | return 0; | ||
120 | } | ||
121 | |||
122 | static int mv_otg_set_timer(struct mv_otg *mvotg, unsigned int id, | ||
123 | unsigned long interval, | ||
124 | void (*callback) (unsigned long)) | ||
125 | { | ||
126 | struct timer_list *timer; | ||
127 | |||
128 | if (id >= OTG_TIMER_NUM) | ||
129 | return -EINVAL; | ||
130 | |||
131 | timer = &mvotg->otg_ctrl.timer[id]; | ||
132 | if (timer_pending(timer)) { | ||
133 | dev_err(&mvotg->pdev->dev, "Timer%d is already running\n", id); | ||
134 | return -EBUSY; | ||
135 | } | ||
136 | |||
137 | init_timer(timer); | ||
138 | timer->data = (unsigned long) mvotg; | ||
139 | timer->function = callback; | ||
140 | timer->expires = jiffies + interval; | ||
141 | add_timer(timer); | ||
142 | |||
143 | return 0; | ||
144 | } | ||
145 | |||
146 | static int mv_otg_reset(struct mv_otg *mvotg) | ||
147 | { | ||
148 | unsigned int loops; | ||
149 | u32 tmp; | ||
150 | |||
151 | /* Stop the controller */ | ||
152 | tmp = readl(&mvotg->op_regs->usbcmd); | ||
153 | tmp &= ~USBCMD_RUN_STOP; | ||
154 | writel(tmp, &mvotg->op_regs->usbcmd); | ||
155 | |||
156 | /* Reset the controller to get default values */ | ||
157 | writel(USBCMD_CTRL_RESET, &mvotg->op_regs->usbcmd); | ||
158 | |||
159 | loops = 500; | ||
160 | while (readl(&mvotg->op_regs->usbcmd) & USBCMD_CTRL_RESET) { | ||
161 | if (loops == 0) { | ||
162 | dev_err(&mvotg->pdev->dev, | ||
163 | "Wait for RESET completed TIMEOUT\n"); | ||
164 | return -ETIMEDOUT; | ||
165 | } | ||
166 | loops--; | ||
167 | udelay(20); | ||
168 | } | ||
169 | |||
170 | writel(0x0, &mvotg->op_regs->usbintr); | ||
171 | tmp = readl(&mvotg->op_regs->usbsts); | ||
172 | writel(tmp, &mvotg->op_regs->usbsts); | ||
173 | |||
174 | return 0; | ||
175 | } | ||
176 | |||
177 | static void mv_otg_init_irq(struct mv_otg *mvotg) | ||
178 | { | ||
179 | u32 otgsc; | ||
180 | |||
181 | mvotg->irq_en = OTGSC_INTR_A_SESSION_VALID | ||
182 | | OTGSC_INTR_A_VBUS_VALID; | ||
183 | mvotg->irq_status = OTGSC_INTSTS_A_SESSION_VALID | ||
184 | | OTGSC_INTSTS_A_VBUS_VALID; | ||
185 | |||
186 | if (mvotg->pdata->vbus == NULL) { | ||
187 | mvotg->irq_en |= OTGSC_INTR_B_SESSION_VALID | ||
188 | | OTGSC_INTR_B_SESSION_END; | ||
189 | mvotg->irq_status |= OTGSC_INTSTS_B_SESSION_VALID | ||
190 | | OTGSC_INTSTS_B_SESSION_END; | ||
191 | } | ||
192 | |||
193 | if (mvotg->pdata->id == NULL) { | ||
194 | mvotg->irq_en |= OTGSC_INTR_USB_ID; | ||
195 | mvotg->irq_status |= OTGSC_INTSTS_USB_ID; | ||
196 | } | ||
197 | |||
198 | otgsc = readl(&mvotg->op_regs->otgsc); | ||
199 | otgsc |= mvotg->irq_en; | ||
200 | writel(otgsc, &mvotg->op_regs->otgsc); | ||
201 | } | ||
202 | |||
203 | static void mv_otg_start_host(struct mv_otg *mvotg, int on) | ||
204 | { | ||
205 | struct otg_transceiver *otg = &mvotg->otg; | ||
206 | struct usb_hcd *hcd; | ||
207 | |||
208 | if (!otg->host) | ||
209 | return; | ||
210 | |||
211 | dev_info(&mvotg->pdev->dev, "%s host\n", on ? "start" : "stop"); | ||
212 | |||
213 | hcd = bus_to_hcd(otg->host); | ||
214 | |||
215 | if (on) | ||
216 | usb_add_hcd(hcd, hcd->irq, IRQF_SHARED); | ||
217 | else | ||
218 | usb_remove_hcd(hcd); | ||
219 | } | ||
220 | |||
221 | static void mv_otg_start_periphrals(struct mv_otg *mvotg, int on) | ||
222 | { | ||
223 | struct otg_transceiver *otg = &mvotg->otg; | ||
224 | |||
225 | if (!otg->gadget) | ||
226 | return; | ||
227 | |||
228 | dev_info(otg->dev, "gadget %s\n", on ? "on" : "off"); | ||
229 | |||
230 | if (on) | ||
231 | usb_gadget_vbus_connect(otg->gadget); | ||
232 | else | ||
233 | usb_gadget_vbus_disconnect(otg->gadget); | ||
234 | } | ||
235 | |||
236 | static void otg_clock_enable(struct mv_otg *mvotg) | ||
237 | { | ||
238 | unsigned int i; | ||
239 | |||
240 | for (i = 0; i < mvotg->clknum; i++) | ||
241 | clk_enable(mvotg->clk[i]); | ||
242 | } | ||
243 | |||
244 | static void otg_clock_disable(struct mv_otg *mvotg) | ||
245 | { | ||
246 | unsigned int i; | ||
247 | |||
248 | for (i = 0; i < mvotg->clknum; i++) | ||
249 | clk_disable(mvotg->clk[i]); | ||
250 | } | ||
251 | |||
252 | static int mv_otg_enable_internal(struct mv_otg *mvotg) | ||
253 | { | ||
254 | int retval = 0; | ||
255 | |||
256 | if (mvotg->active) | ||
257 | return 0; | ||
258 | |||
259 | dev_dbg(&mvotg->pdev->dev, "otg enabled\n"); | ||
260 | |||
261 | otg_clock_enable(mvotg); | ||
262 | if (mvotg->pdata->phy_init) { | ||
263 | retval = mvotg->pdata->phy_init(mvotg->phy_regs); | ||
264 | if (retval) { | ||
265 | dev_err(&mvotg->pdev->dev, | ||
266 | "init phy error %d\n", retval); | ||
267 | otg_clock_disable(mvotg); | ||
268 | return retval; | ||
269 | } | ||
270 | } | ||
271 | mvotg->active = 1; | ||
272 | |||
273 | return 0; | ||
274 | |||
275 | } | ||
276 | |||
277 | static int mv_otg_enable(struct mv_otg *mvotg) | ||
278 | { | ||
279 | if (mvotg->clock_gating) | ||
280 | return mv_otg_enable_internal(mvotg); | ||
281 | |||
282 | return 0; | ||
283 | } | ||
284 | |||
285 | static void mv_otg_disable_internal(struct mv_otg *mvotg) | ||
286 | { | ||
287 | if (mvotg->active) { | ||
288 | dev_dbg(&mvotg->pdev->dev, "otg disabled\n"); | ||
289 | if (mvotg->pdata->phy_deinit) | ||
290 | mvotg->pdata->phy_deinit(mvotg->phy_regs); | ||
291 | otg_clock_disable(mvotg); | ||
292 | mvotg->active = 0; | ||
293 | } | ||
294 | } | ||
295 | |||
296 | static void mv_otg_disable(struct mv_otg *mvotg) | ||
297 | { | ||
298 | if (mvotg->clock_gating) | ||
299 | mv_otg_disable_internal(mvotg); | ||
300 | } | ||
301 | |||
302 | static void mv_otg_update_inputs(struct mv_otg *mvotg) | ||
303 | { | ||
304 | struct mv_otg_ctrl *otg_ctrl = &mvotg->otg_ctrl; | ||
305 | u32 otgsc; | ||
306 | |||
307 | otgsc = readl(&mvotg->op_regs->otgsc); | ||
308 | |||
309 | if (mvotg->pdata->vbus) { | ||
310 | if (mvotg->pdata->vbus->poll() == VBUS_HIGH) { | ||
311 | otg_ctrl->b_sess_vld = 1; | ||
312 | otg_ctrl->b_sess_end = 0; | ||
313 | } else { | ||
314 | otg_ctrl->b_sess_vld = 0; | ||
315 | otg_ctrl->b_sess_end = 1; | ||
316 | } | ||
317 | } else { | ||
318 | otg_ctrl->b_sess_vld = !!(otgsc & OTGSC_STS_B_SESSION_VALID); | ||
319 | otg_ctrl->b_sess_end = !!(otgsc & OTGSC_STS_B_SESSION_END); | ||
320 | } | ||
321 | |||
322 | if (mvotg->pdata->id) | ||
323 | otg_ctrl->id = !!mvotg->pdata->id->poll(); | ||
324 | else | ||
325 | otg_ctrl->id = !!(otgsc & OTGSC_STS_USB_ID); | ||
326 | |||
327 | if (mvotg->pdata->otg_force_a_bus_req && !otg_ctrl->id) | ||
328 | otg_ctrl->a_bus_req = 1; | ||
329 | |||
330 | otg_ctrl->a_sess_vld = !!(otgsc & OTGSC_STS_A_SESSION_VALID); | ||
331 | otg_ctrl->a_vbus_vld = !!(otgsc & OTGSC_STS_A_VBUS_VALID); | ||
332 | |||
333 | dev_dbg(&mvotg->pdev->dev, "%s: ", __func__); | ||
334 | dev_dbg(&mvotg->pdev->dev, "id %d\n", otg_ctrl->id); | ||
335 | dev_dbg(&mvotg->pdev->dev, "b_sess_vld %d\n", otg_ctrl->b_sess_vld); | ||
336 | dev_dbg(&mvotg->pdev->dev, "b_sess_end %d\n", otg_ctrl->b_sess_end); | ||
337 | dev_dbg(&mvotg->pdev->dev, "a_vbus_vld %d\n", otg_ctrl->a_vbus_vld); | ||
338 | dev_dbg(&mvotg->pdev->dev, "a_sess_vld %d\n", otg_ctrl->a_sess_vld); | ||
339 | } | ||
340 | |||
341 | static void mv_otg_update_state(struct mv_otg *mvotg) | ||
342 | { | ||
343 | struct mv_otg_ctrl *otg_ctrl = &mvotg->otg_ctrl; | ||
344 | struct otg_transceiver *otg = &mvotg->otg; | ||
345 | int old_state = otg->state; | ||
346 | |||
347 | switch (old_state) { | ||
348 | case OTG_STATE_UNDEFINED: | ||
349 | otg->state = OTG_STATE_B_IDLE; | ||
350 | /* FALL THROUGH */ | ||
351 | case OTG_STATE_B_IDLE: | ||
352 | if (otg_ctrl->id == 0) | ||
353 | otg->state = OTG_STATE_A_IDLE; | ||
354 | else if (otg_ctrl->b_sess_vld) | ||
355 | otg->state = OTG_STATE_B_PERIPHERAL; | ||
356 | break; | ||
357 | case OTG_STATE_B_PERIPHERAL: | ||
358 | if (!otg_ctrl->b_sess_vld || otg_ctrl->id == 0) | ||
359 | otg->state = OTG_STATE_B_IDLE; | ||
360 | break; | ||
361 | case OTG_STATE_A_IDLE: | ||
362 | if (otg_ctrl->id) | ||
363 | otg->state = OTG_STATE_B_IDLE; | ||
364 | else if (!(otg_ctrl->a_bus_drop) && | ||
365 | (otg_ctrl->a_bus_req || otg_ctrl->a_srp_det)) | ||
366 | otg->state = OTG_STATE_A_WAIT_VRISE; | ||
367 | break; | ||
368 | case OTG_STATE_A_WAIT_VRISE: | ||
369 | if (otg_ctrl->a_vbus_vld) | ||
370 | otg->state = OTG_STATE_A_WAIT_BCON; | ||
371 | break; | ||
372 | case OTG_STATE_A_WAIT_BCON: | ||
373 | if (otg_ctrl->id || otg_ctrl->a_bus_drop | ||
374 | || otg_ctrl->a_wait_bcon_timeout) { | ||
375 | mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER); | ||
376 | mvotg->otg_ctrl.a_wait_bcon_timeout = 0; | ||
377 | otg->state = OTG_STATE_A_WAIT_VFALL; | ||
378 | otg_ctrl->a_bus_req = 0; | ||
379 | } else if (!otg_ctrl->a_vbus_vld) { | ||
380 | mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER); | ||
381 | mvotg->otg_ctrl.a_wait_bcon_timeout = 0; | ||
382 | otg->state = OTG_STATE_A_VBUS_ERR; | ||
383 | } else if (otg_ctrl->b_conn) { | ||
384 | mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER); | ||
385 | mvotg->otg_ctrl.a_wait_bcon_timeout = 0; | ||
386 | otg->state = OTG_STATE_A_HOST; | ||
387 | } | ||
388 | break; | ||
389 | case OTG_STATE_A_HOST: | ||
390 | if (otg_ctrl->id || !otg_ctrl->b_conn | ||
391 | || otg_ctrl->a_bus_drop) | ||
392 | otg->state = OTG_STATE_A_WAIT_BCON; | ||
393 | else if (!otg_ctrl->a_vbus_vld) | ||
394 | otg->state = OTG_STATE_A_VBUS_ERR; | ||
395 | break; | ||
396 | case OTG_STATE_A_WAIT_VFALL: | ||
397 | if (otg_ctrl->id | ||
398 | || (!otg_ctrl->b_conn && otg_ctrl->a_sess_vld) | ||
399 | || otg_ctrl->a_bus_req) | ||
400 | otg->state = OTG_STATE_A_IDLE; | ||
401 | break; | ||
402 | case OTG_STATE_A_VBUS_ERR: | ||
403 | if (otg_ctrl->id || otg_ctrl->a_clr_err | ||
404 | || otg_ctrl->a_bus_drop) { | ||
405 | otg_ctrl->a_clr_err = 0; | ||
406 | otg->state = OTG_STATE_A_WAIT_VFALL; | ||
407 | } | ||
408 | break; | ||
409 | default: | ||
410 | break; | ||
411 | } | ||
412 | } | ||
413 | |||
414 | static void mv_otg_work(struct work_struct *work) | ||
415 | { | ||
416 | struct mv_otg *mvotg; | ||
417 | struct otg_transceiver *otg; | ||
418 | int old_state; | ||
419 | |||
420 | mvotg = container_of((struct delayed_work *)work, struct mv_otg, work); | ||
421 | |||
422 | run: | ||
423 | /* work queue is single thread, or we need spin_lock to protect */ | ||
424 | otg = &mvotg->otg; | ||
425 | old_state = otg->state; | ||
426 | |||
427 | if (!mvotg->active) | ||
428 | return; | ||
429 | |||
430 | mv_otg_update_inputs(mvotg); | ||
431 | mv_otg_update_state(mvotg); | ||
432 | |||
433 | if (old_state != otg->state) { | ||
434 | dev_info(&mvotg->pdev->dev, "change from state %s to %s\n", | ||
435 | state_string[old_state], | ||
436 | state_string[otg->state]); | ||
437 | |||
438 | switch (otg->state) { | ||
439 | case OTG_STATE_B_IDLE: | ||
440 | mvotg->otg.default_a = 0; | ||
441 | if (old_state == OTG_STATE_B_PERIPHERAL) | ||
442 | mv_otg_start_periphrals(mvotg, 0); | ||
443 | mv_otg_reset(mvotg); | ||
444 | mv_otg_disable(mvotg); | ||
445 | break; | ||
446 | case OTG_STATE_B_PERIPHERAL: | ||
447 | mv_otg_enable(mvotg); | ||
448 | mv_otg_start_periphrals(mvotg, 1); | ||
449 | break; | ||
450 | case OTG_STATE_A_IDLE: | ||
451 | mvotg->otg.default_a = 1; | ||
452 | mv_otg_enable(mvotg); | ||
453 | if (old_state == OTG_STATE_A_WAIT_VFALL) | ||
454 | mv_otg_start_host(mvotg, 0); | ||
455 | mv_otg_reset(mvotg); | ||
456 | break; | ||
457 | case OTG_STATE_A_WAIT_VRISE: | ||
458 | mv_otg_set_vbus(&mvotg->otg, 1); | ||
459 | break; | ||
460 | case OTG_STATE_A_WAIT_BCON: | ||
461 | if (old_state != OTG_STATE_A_HOST) | ||
462 | mv_otg_start_host(mvotg, 1); | ||
463 | mv_otg_set_timer(mvotg, A_WAIT_BCON_TIMER, | ||
464 | T_A_WAIT_BCON, | ||
465 | mv_otg_timer_await_bcon); | ||
466 | /* | ||
467 | * Now, we directly enter A_HOST. So set b_conn = 1 | ||
468 | * here. In fact, it need host driver to notify us. | ||
469 | */ | ||
470 | mvotg->otg_ctrl.b_conn = 1; | ||
471 | break; | ||
472 | case OTG_STATE_A_HOST: | ||
473 | break; | ||
474 | case OTG_STATE_A_WAIT_VFALL: | ||
475 | /* | ||
476 | * Now, we has exited A_HOST. So set b_conn = 0 | ||
477 | * here. In fact, it need host driver to notify us. | ||
478 | */ | ||
479 | mvotg->otg_ctrl.b_conn = 0; | ||
480 | mv_otg_set_vbus(&mvotg->otg, 0); | ||
481 | break; | ||
482 | case OTG_STATE_A_VBUS_ERR: | ||
483 | break; | ||
484 | default: | ||
485 | break; | ||
486 | } | ||
487 | goto run; | ||
488 | } | ||
489 | } | ||
490 | |||
491 | static irqreturn_t mv_otg_irq(int irq, void *dev) | ||
492 | { | ||
493 | struct mv_otg *mvotg = dev; | ||
494 | u32 otgsc; | ||
495 | |||
496 | otgsc = readl(&mvotg->op_regs->otgsc); | ||
497 | writel(otgsc, &mvotg->op_regs->otgsc); | ||
498 | |||
499 | /* | ||
500 | * if we have vbus, then the vbus detection for B-device | ||
501 | * will be done by mv_otg_inputs_irq(). | ||
502 | */ | ||
503 | if (mvotg->pdata->vbus) | ||
504 | if ((otgsc & OTGSC_STS_USB_ID) && | ||
505 | !(otgsc & OTGSC_INTSTS_USB_ID)) | ||
506 | return IRQ_NONE; | ||
507 | |||
508 | if ((otgsc & mvotg->irq_status) == 0) | ||
509 | return IRQ_NONE; | ||
510 | |||
511 | mv_otg_run_state_machine(mvotg, 0); | ||
512 | |||
513 | return IRQ_HANDLED; | ||
514 | } | ||
515 | |||
516 | static irqreturn_t mv_otg_inputs_irq(int irq, void *dev) | ||
517 | { | ||
518 | struct mv_otg *mvotg = dev; | ||
519 | |||
520 | /* The clock may disabled at this time */ | ||
521 | if (!mvotg->active) { | ||
522 | mv_otg_enable(mvotg); | ||
523 | mv_otg_init_irq(mvotg); | ||
524 | } | ||
525 | |||
526 | mv_otg_run_state_machine(mvotg, 0); | ||
527 | |||
528 | return IRQ_HANDLED; | ||
529 | } | ||
530 | |||
531 | static ssize_t | ||
532 | get_a_bus_req(struct device *dev, struct device_attribute *attr, char *buf) | ||
533 | { | ||
534 | struct mv_otg *mvotg = dev_get_drvdata(dev); | ||
535 | return scnprintf(buf, PAGE_SIZE, "%d\n", | ||
536 | mvotg->otg_ctrl.a_bus_req); | ||
537 | } | ||
538 | |||
539 | static ssize_t | ||
540 | set_a_bus_req(struct device *dev, struct device_attribute *attr, | ||
541 | const char *buf, size_t count) | ||
542 | { | ||
543 | struct mv_otg *mvotg = dev_get_drvdata(dev); | ||
544 | |||
545 | if (count > 2) | ||
546 | return -1; | ||
547 | |||
548 | /* We will use this interface to change to A device */ | ||
549 | if (mvotg->otg.state != OTG_STATE_B_IDLE | ||
550 | && mvotg->otg.state != OTG_STATE_A_IDLE) | ||
551 | return -1; | ||
552 | |||
553 | /* The clock may disabled and we need to set irq for ID detected */ | ||
554 | mv_otg_enable(mvotg); | ||
555 | mv_otg_init_irq(mvotg); | ||
556 | |||
557 | if (buf[0] == '1') { | ||
558 | mvotg->otg_ctrl.a_bus_req = 1; | ||
559 | mvotg->otg_ctrl.a_bus_drop = 0; | ||
560 | dev_dbg(&mvotg->pdev->dev, | ||
561 | "User request: a_bus_req = 1\n"); | ||
562 | |||
563 | if (spin_trylock(&mvotg->wq_lock)) { | ||
564 | mv_otg_run_state_machine(mvotg, 0); | ||
565 | spin_unlock(&mvotg->wq_lock); | ||
566 | } | ||
567 | } | ||
568 | |||
569 | return count; | ||
570 | } | ||
571 | |||
572 | static DEVICE_ATTR(a_bus_req, S_IRUGO | S_IWUSR, get_a_bus_req, | ||
573 | set_a_bus_req); | ||
574 | |||
575 | static ssize_t | ||
576 | set_a_clr_err(struct device *dev, struct device_attribute *attr, | ||
577 | const char *buf, size_t count) | ||
578 | { | ||
579 | struct mv_otg *mvotg = dev_get_drvdata(dev); | ||
580 | if (!mvotg->otg.default_a) | ||
581 | return -1; | ||
582 | |||
583 | if (count > 2) | ||
584 | return -1; | ||
585 | |||
586 | if (buf[0] == '1') { | ||
587 | mvotg->otg_ctrl.a_clr_err = 1; | ||
588 | dev_dbg(&mvotg->pdev->dev, | ||
589 | "User request: a_clr_err = 1\n"); | ||
590 | } | ||
591 | |||
592 | if (spin_trylock(&mvotg->wq_lock)) { | ||
593 | mv_otg_run_state_machine(mvotg, 0); | ||
594 | spin_unlock(&mvotg->wq_lock); | ||
595 | } | ||
596 | |||
597 | return count; | ||
598 | } | ||
599 | |||
600 | static DEVICE_ATTR(a_clr_err, S_IWUSR, NULL, set_a_clr_err); | ||
601 | |||
602 | static ssize_t | ||
603 | get_a_bus_drop(struct device *dev, struct device_attribute *attr, | ||
604 | char *buf) | ||
605 | { | ||
606 | struct mv_otg *mvotg = dev_get_drvdata(dev); | ||
607 | return scnprintf(buf, PAGE_SIZE, "%d\n", | ||
608 | mvotg->otg_ctrl.a_bus_drop); | ||
609 | } | ||
610 | |||
611 | static ssize_t | ||
612 | set_a_bus_drop(struct device *dev, struct device_attribute *attr, | ||
613 | const char *buf, size_t count) | ||
614 | { | ||
615 | struct mv_otg *mvotg = dev_get_drvdata(dev); | ||
616 | if (!mvotg->otg.default_a) | ||
617 | return -1; | ||
618 | |||
619 | if (count > 2) | ||
620 | return -1; | ||
621 | |||
622 | if (buf[0] == '0') { | ||
623 | mvotg->otg_ctrl.a_bus_drop = 0; | ||
624 | dev_dbg(&mvotg->pdev->dev, | ||
625 | "User request: a_bus_drop = 0\n"); | ||
626 | } else if (buf[0] == '1') { | ||
627 | mvotg->otg_ctrl.a_bus_drop = 1; | ||
628 | mvotg->otg_ctrl.a_bus_req = 0; | ||
629 | dev_dbg(&mvotg->pdev->dev, | ||
630 | "User request: a_bus_drop = 1\n"); | ||
631 | dev_dbg(&mvotg->pdev->dev, | ||
632 | "User request: and a_bus_req = 0\n"); | ||
633 | } | ||
634 | |||
635 | if (spin_trylock(&mvotg->wq_lock)) { | ||
636 | mv_otg_run_state_machine(mvotg, 0); | ||
637 | spin_unlock(&mvotg->wq_lock); | ||
638 | } | ||
639 | |||
640 | return count; | ||
641 | } | ||
642 | |||
643 | static DEVICE_ATTR(a_bus_drop, S_IRUGO | S_IWUSR, | ||
644 | get_a_bus_drop, set_a_bus_drop); | ||
645 | |||
646 | static struct attribute *inputs_attrs[] = { | ||
647 | &dev_attr_a_bus_req.attr, | ||
648 | &dev_attr_a_clr_err.attr, | ||
649 | &dev_attr_a_bus_drop.attr, | ||
650 | NULL, | ||
651 | }; | ||
652 | |||
653 | static struct attribute_group inputs_attr_group = { | ||
654 | .name = "inputs", | ||
655 | .attrs = inputs_attrs, | ||
656 | }; | ||
657 | |||
658 | int mv_otg_remove(struct platform_device *pdev) | ||
659 | { | ||
660 | struct mv_otg *mvotg = platform_get_drvdata(pdev); | ||
661 | int clk_i; | ||
662 | |||
663 | sysfs_remove_group(&mvotg->pdev->dev.kobj, &inputs_attr_group); | ||
664 | |||
665 | if (mvotg->irq) | ||
666 | free_irq(mvotg->irq, mvotg); | ||
667 | |||
668 | if (mvotg->pdata->vbus) | ||
669 | free_irq(mvotg->pdata->vbus->irq, mvotg); | ||
670 | if (mvotg->pdata->id) | ||
671 | free_irq(mvotg->pdata->id->irq, mvotg); | ||
672 | |||
673 | if (mvotg->qwork) { | ||
674 | flush_workqueue(mvotg->qwork); | ||
675 | destroy_workqueue(mvotg->qwork); | ||
676 | } | ||
677 | |||
678 | mv_otg_disable(mvotg); | ||
679 | |||
680 | if (mvotg->cap_regs) | ||
681 | iounmap(mvotg->cap_regs); | ||
682 | |||
683 | if (mvotg->phy_regs) | ||
684 | iounmap(mvotg->phy_regs); | ||
685 | |||
686 | for (clk_i = 0; clk_i <= mvotg->clknum; clk_i++) | ||
687 | clk_put(mvotg->clk[clk_i]); | ||
688 | |||
689 | otg_set_transceiver(NULL); | ||
690 | platform_set_drvdata(pdev, NULL); | ||
691 | |||
692 | kfree(mvotg); | ||
693 | |||
694 | return 0; | ||
695 | } | ||
696 | |||
697 | static int mv_otg_probe(struct platform_device *pdev) | ||
698 | { | ||
699 | struct mv_usb_platform_data *pdata = pdev->dev.platform_data; | ||
700 | struct mv_otg *mvotg; | ||
701 | struct resource *r; | ||
702 | int retval = 0, clk_i, i; | ||
703 | size_t size; | ||
704 | |||
705 | if (pdata == NULL) { | ||
706 | dev_err(&pdev->dev, "failed to get platform data\n"); | ||
707 | return -ENODEV; | ||
708 | } | ||
709 | |||
710 | size = sizeof(*mvotg) + sizeof(struct clk *) * pdata->clknum; | ||
711 | mvotg = kzalloc(size, GFP_KERNEL); | ||
712 | if (!mvotg) { | ||
713 | dev_err(&pdev->dev, "failed to allocate memory!\n"); | ||
714 | return -ENOMEM; | ||
715 | } | ||
716 | |||
717 | platform_set_drvdata(pdev, mvotg); | ||
718 | |||
719 | mvotg->pdev = pdev; | ||
720 | mvotg->pdata = pdata; | ||
721 | |||
722 | mvotg->clknum = pdata->clknum; | ||
723 | for (clk_i = 0; clk_i < mvotg->clknum; clk_i++) { | ||
724 | mvotg->clk[clk_i] = clk_get(&pdev->dev, pdata->clkname[clk_i]); | ||
725 | if (IS_ERR(mvotg->clk[clk_i])) { | ||
726 | retval = PTR_ERR(mvotg->clk[clk_i]); | ||
727 | goto err_put_clk; | ||
728 | } | ||
729 | } | ||
730 | |||
731 | mvotg->qwork = create_singlethread_workqueue("mv_otg_queue"); | ||
732 | if (!mvotg->qwork) { | ||
733 | dev_dbg(&pdev->dev, "cannot create workqueue for OTG\n"); | ||
734 | retval = -ENOMEM; | ||
735 | goto err_put_clk; | ||
736 | } | ||
737 | |||
738 | INIT_DELAYED_WORK(&mvotg->work, mv_otg_work); | ||
739 | |||
740 | /* OTG common part */ | ||
741 | mvotg->pdev = pdev; | ||
742 | mvotg->otg.dev = &pdev->dev; | ||
743 | mvotg->otg.label = driver_name; | ||
744 | mvotg->otg.set_host = mv_otg_set_host; | ||
745 | mvotg->otg.set_peripheral = mv_otg_set_peripheral; | ||
746 | mvotg->otg.set_vbus = mv_otg_set_vbus; | ||
747 | mvotg->otg.state = OTG_STATE_UNDEFINED; | ||
748 | |||
749 | for (i = 0; i < OTG_TIMER_NUM; i++) | ||
750 | init_timer(&mvotg->otg_ctrl.timer[i]); | ||
751 | |||
752 | r = platform_get_resource_byname(mvotg->pdev, | ||
753 | IORESOURCE_MEM, "phyregs"); | ||
754 | if (r == NULL) { | ||
755 | dev_err(&pdev->dev, "no phy I/O memory resource defined\n"); | ||
756 | retval = -ENODEV; | ||
757 | goto err_destroy_workqueue; | ||
758 | } | ||
759 | |||
760 | mvotg->phy_regs = ioremap(r->start, resource_size(r)); | ||
761 | if (mvotg->phy_regs == NULL) { | ||
762 | dev_err(&pdev->dev, "failed to map phy I/O memory\n"); | ||
763 | retval = -EFAULT; | ||
764 | goto err_destroy_workqueue; | ||
765 | } | ||
766 | |||
767 | r = platform_get_resource_byname(mvotg->pdev, | ||
768 | IORESOURCE_MEM, "capregs"); | ||
769 | if (r == NULL) { | ||
770 | dev_err(&pdev->dev, "no I/O memory resource defined\n"); | ||
771 | retval = -ENODEV; | ||
772 | goto err_unmap_phyreg; | ||
773 | } | ||
774 | |||
775 | mvotg->cap_regs = ioremap(r->start, resource_size(r)); | ||
776 | if (mvotg->cap_regs == NULL) { | ||
777 | dev_err(&pdev->dev, "failed to map I/O memory\n"); | ||
778 | retval = -EFAULT; | ||
779 | goto err_unmap_phyreg; | ||
780 | } | ||
781 | |||
782 | /* we will acces controller register, so enable the udc controller */ | ||
783 | retval = mv_otg_enable_internal(mvotg); | ||
784 | if (retval) { | ||
785 | dev_err(&pdev->dev, "mv otg enable error %d\n", retval); | ||
786 | goto err_unmap_capreg; | ||
787 | } | ||
788 | |||
789 | mvotg->op_regs = | ||
790 | (struct mv_otg_regs __iomem *) ((unsigned long) mvotg->cap_regs | ||
791 | + (readl(mvotg->cap_regs) & CAPLENGTH_MASK)); | ||
792 | |||
793 | if (pdata->id) { | ||
794 | retval = request_threaded_irq(pdata->id->irq, NULL, | ||
795 | mv_otg_inputs_irq, | ||
796 | IRQF_ONESHOT, "id", mvotg); | ||
797 | if (retval) { | ||
798 | dev_info(&pdev->dev, | ||
799 | "Failed to request irq for ID\n"); | ||
800 | pdata->id = NULL; | ||
801 | } | ||
802 | } | ||
803 | |||
804 | if (pdata->vbus) { | ||
805 | mvotg->clock_gating = 1; | ||
806 | retval = request_threaded_irq(pdata->vbus->irq, NULL, | ||
807 | mv_otg_inputs_irq, | ||
808 | IRQF_ONESHOT, "vbus", mvotg); | ||
809 | if (retval) { | ||
810 | dev_info(&pdev->dev, | ||
811 | "Failed to request irq for VBUS, " | ||
812 | "disable clock gating\n"); | ||
813 | mvotg->clock_gating = 0; | ||
814 | pdata->vbus = NULL; | ||
815 | } | ||
816 | } | ||
817 | |||
818 | if (pdata->disable_otg_clock_gating) | ||
819 | mvotg->clock_gating = 0; | ||
820 | |||
821 | mv_otg_reset(mvotg); | ||
822 | mv_otg_init_irq(mvotg); | ||
823 | |||
824 | r = platform_get_resource(mvotg->pdev, IORESOURCE_IRQ, 0); | ||
825 | if (r == NULL) { | ||
826 | dev_err(&pdev->dev, "no IRQ resource defined\n"); | ||
827 | retval = -ENODEV; | ||
828 | goto err_disable_clk; | ||
829 | } | ||
830 | |||
831 | mvotg->irq = r->start; | ||
832 | if (request_irq(mvotg->irq, mv_otg_irq, IRQF_SHARED, | ||
833 | driver_name, mvotg)) { | ||
834 | dev_err(&pdev->dev, "Request irq %d for OTG failed\n", | ||
835 | mvotg->irq); | ||
836 | mvotg->irq = 0; | ||
837 | retval = -ENODEV; | ||
838 | goto err_disable_clk; | ||
839 | } | ||
840 | |||
841 | retval = otg_set_transceiver(&mvotg->otg); | ||
842 | if (retval < 0) { | ||
843 | dev_err(&pdev->dev, "can't register transceiver, %d\n", | ||
844 | retval); | ||
845 | goto err_free_irq; | ||
846 | } | ||
847 | |||
848 | retval = sysfs_create_group(&pdev->dev.kobj, &inputs_attr_group); | ||
849 | if (retval < 0) { | ||
850 | dev_dbg(&pdev->dev, | ||
851 | "Can't register sysfs attr group: %d\n", retval); | ||
852 | goto err_set_transceiver; | ||
853 | } | ||
854 | |||
855 | spin_lock_init(&mvotg->wq_lock); | ||
856 | if (spin_trylock(&mvotg->wq_lock)) { | ||
857 | mv_otg_run_state_machine(mvotg, 2 * HZ); | ||
858 | spin_unlock(&mvotg->wq_lock); | ||
859 | } | ||
860 | |||
861 | dev_info(&pdev->dev, | ||
862 | "successful probe OTG device %s clock gating.\n", | ||
863 | mvotg->clock_gating ? "with" : "without"); | ||
864 | |||
865 | return 0; | ||
866 | |||
867 | err_set_transceiver: | ||
868 | otg_set_transceiver(NULL); | ||
869 | err_free_irq: | ||
870 | free_irq(mvotg->irq, mvotg); | ||
871 | err_disable_clk: | ||
872 | if (pdata->vbus) | ||
873 | free_irq(pdata->vbus->irq, mvotg); | ||
874 | if (pdata->id) | ||
875 | free_irq(pdata->id->irq, mvotg); | ||
876 | mv_otg_disable_internal(mvotg); | ||
877 | err_unmap_capreg: | ||
878 | iounmap(mvotg->cap_regs); | ||
879 | err_unmap_phyreg: | ||
880 | iounmap(mvotg->phy_regs); | ||
881 | err_destroy_workqueue: | ||
882 | flush_workqueue(mvotg->qwork); | ||
883 | destroy_workqueue(mvotg->qwork); | ||
884 | err_put_clk: | ||
885 | for (clk_i--; clk_i >= 0; clk_i--) | ||
886 | clk_put(mvotg->clk[clk_i]); | ||
887 | |||
888 | platform_set_drvdata(pdev, NULL); | ||
889 | kfree(mvotg); | ||
890 | |||
891 | return retval; | ||
892 | } | ||
893 | |||
894 | #ifdef CONFIG_PM | ||
895 | static int mv_otg_suspend(struct platform_device *pdev, pm_message_t state) | ||
896 | { | ||
897 | struct mv_otg *mvotg = platform_get_drvdata(pdev); | ||
898 | |||
899 | if (mvotg->otg.state != OTG_STATE_B_IDLE) { | ||
900 | dev_info(&pdev->dev, | ||
901 | "OTG state is not B_IDLE, it is %d!\n", | ||
902 | mvotg->otg.state); | ||
903 | return -EAGAIN; | ||
904 | } | ||
905 | |||
906 | if (!mvotg->clock_gating) | ||
907 | mv_otg_disable_internal(mvotg); | ||
908 | |||
909 | return 0; | ||
910 | } | ||
911 | |||
912 | static int mv_otg_resume(struct platform_device *pdev) | ||
913 | { | ||
914 | struct mv_otg *mvotg = platform_get_drvdata(pdev); | ||
915 | u32 otgsc; | ||
916 | |||
917 | if (!mvotg->clock_gating) { | ||
918 | mv_otg_enable_internal(mvotg); | ||
919 | |||
920 | otgsc = readl(&mvotg->op_regs->otgsc); | ||
921 | otgsc |= mvotg->irq_en; | ||
922 | writel(otgsc, &mvotg->op_regs->otgsc); | ||
923 | |||
924 | if (spin_trylock(&mvotg->wq_lock)) { | ||
925 | mv_otg_run_state_machine(mvotg, 0); | ||
926 | spin_unlock(&mvotg->wq_lock); | ||
927 | } | ||
928 | } | ||
929 | return 0; | ||
930 | } | ||
931 | #endif | ||
932 | |||
933 | static struct platform_driver mv_otg_driver = { | ||
934 | .probe = mv_otg_probe, | ||
935 | .remove = __exit_p(mv_otg_remove), | ||
936 | .driver = { | ||
937 | .owner = THIS_MODULE, | ||
938 | .name = driver_name, | ||
939 | }, | ||
940 | #ifdef CONFIG_PM | ||
941 | .suspend = mv_otg_suspend, | ||
942 | .resume = mv_otg_resume, | ||
943 | #endif | ||
944 | }; | ||
945 | |||
946 | static int __init mv_otg_init(void) | ||
947 | { | ||
948 | return platform_driver_register(&mv_otg_driver); | ||
949 | } | ||
950 | |||
951 | static void __exit mv_otg_exit(void) | ||
952 | { | ||
953 | platform_driver_unregister(&mv_otg_driver); | ||
954 | } | ||
955 | |||
956 | module_init(mv_otg_init); | ||
957 | module_exit(mv_otg_exit); | ||
diff --git a/drivers/usb/otg/mv_otg.h b/drivers/usb/otg/mv_otg.h new file mode 100644 index 000000000000..be6ca1437645 --- /dev/null +++ b/drivers/usb/otg/mv_otg.h | |||
@@ -0,0 +1,165 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2011 Marvell International Ltd. All rights reserved. | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify it | ||
5 | * under the terms of the GNU General Public License as published by the | ||
6 | * Free Software Foundation; either version 2 of the License, or (at your | ||
7 | * option) any later version. | ||
8 | */ | ||
9 | |||
10 | #ifndef __MV_USB_OTG_CONTROLLER__ | ||
11 | #define __MV_USB_OTG_CONTROLLER__ | ||
12 | |||
13 | #include <linux/types.h> | ||
14 | |||
15 | /* Command Register Bit Masks */ | ||
16 | #define USBCMD_RUN_STOP (0x00000001) | ||
17 | #define USBCMD_CTRL_RESET (0x00000002) | ||
18 | |||
19 | /* otgsc Register Bit Masks */ | ||
20 | #define OTGSC_CTRL_VUSB_DISCHARGE 0x00000001 | ||
21 | #define OTGSC_CTRL_VUSB_CHARGE 0x00000002 | ||
22 | #define OTGSC_CTRL_OTG_TERM 0x00000008 | ||
23 | #define OTGSC_CTRL_DATA_PULSING 0x00000010 | ||
24 | #define OTGSC_STS_USB_ID 0x00000100 | ||
25 | #define OTGSC_STS_A_VBUS_VALID 0x00000200 | ||
26 | #define OTGSC_STS_A_SESSION_VALID 0x00000400 | ||
27 | #define OTGSC_STS_B_SESSION_VALID 0x00000800 | ||
28 | #define OTGSC_STS_B_SESSION_END 0x00001000 | ||
29 | #define OTGSC_STS_1MS_TOGGLE 0x00002000 | ||
30 | #define OTGSC_STS_DATA_PULSING 0x00004000 | ||
31 | #define OTGSC_INTSTS_USB_ID 0x00010000 | ||
32 | #define OTGSC_INTSTS_A_VBUS_VALID 0x00020000 | ||
33 | #define OTGSC_INTSTS_A_SESSION_VALID 0x00040000 | ||
34 | #define OTGSC_INTSTS_B_SESSION_VALID 0x00080000 | ||
35 | #define OTGSC_INTSTS_B_SESSION_END 0x00100000 | ||
36 | #define OTGSC_INTSTS_1MS 0x00200000 | ||
37 | #define OTGSC_INTSTS_DATA_PULSING 0x00400000 | ||
38 | #define OTGSC_INTR_USB_ID 0x01000000 | ||
39 | #define OTGSC_INTR_A_VBUS_VALID 0x02000000 | ||
40 | #define OTGSC_INTR_A_SESSION_VALID 0x04000000 | ||
41 | #define OTGSC_INTR_B_SESSION_VALID 0x08000000 | ||
42 | #define OTGSC_INTR_B_SESSION_END 0x10000000 | ||
43 | #define OTGSC_INTR_1MS_TIMER 0x20000000 | ||
44 | #define OTGSC_INTR_DATA_PULSING 0x40000000 | ||
45 | |||
46 | #define CAPLENGTH_MASK (0xff) | ||
47 | |||
48 | /* Timer's interval, unit 10ms */ | ||
49 | #define T_A_WAIT_VRISE 100 | ||
50 | #define T_A_WAIT_BCON 2000 | ||
51 | #define T_A_AIDL_BDIS 100 | ||
52 | #define T_A_BIDL_ADIS 20 | ||
53 | #define T_B_ASE0_BRST 400 | ||
54 | #define T_B_SE0_SRP 300 | ||
55 | #define T_B_SRP_FAIL 2000 | ||
56 | #define T_B_DATA_PLS 10 | ||
57 | #define T_B_SRP_INIT 100 | ||
58 | #define T_A_SRP_RSPNS 10 | ||
59 | #define T_A_DRV_RSM 5 | ||
60 | |||
61 | enum otg_function { | ||
62 | OTG_B_DEVICE = 0, | ||
63 | OTG_A_DEVICE | ||
64 | }; | ||
65 | |||
66 | enum mv_otg_timer { | ||
67 | A_WAIT_BCON_TIMER = 0, | ||
68 | OTG_TIMER_NUM | ||
69 | }; | ||
70 | |||
71 | /* PXA OTG state machine */ | ||
72 | struct mv_otg_ctrl { | ||
73 | /* internal variables */ | ||
74 | u8 a_set_b_hnp_en; /* A-Device set b_hnp_en */ | ||
75 | u8 b_srp_done; | ||
76 | u8 b_hnp_en; | ||
77 | |||
78 | /* OTG inputs */ | ||
79 | u8 a_bus_drop; | ||
80 | u8 a_bus_req; | ||
81 | u8 a_clr_err; | ||
82 | u8 a_bus_resume; | ||
83 | u8 a_bus_suspend; | ||
84 | u8 a_conn; | ||
85 | u8 a_sess_vld; | ||
86 | u8 a_srp_det; | ||
87 | u8 a_vbus_vld; | ||
88 | u8 b_bus_req; /* B-Device Require Bus */ | ||
89 | u8 b_bus_resume; | ||
90 | u8 b_bus_suspend; | ||
91 | u8 b_conn; | ||
92 | u8 b_se0_srp; | ||
93 | u8 b_sess_end; | ||
94 | u8 b_sess_vld; | ||
95 | u8 id; | ||
96 | u8 a_suspend_req; | ||
97 | |||
98 | /*Timer event */ | ||
99 | u8 a_aidl_bdis_timeout; | ||
100 | u8 b_ase0_brst_timeout; | ||
101 | u8 a_bidl_adis_timeout; | ||
102 | u8 a_wait_bcon_timeout; | ||
103 | |||
104 | struct timer_list timer[OTG_TIMER_NUM]; | ||
105 | }; | ||
106 | |||
107 | #define VUSBHS_MAX_PORTS 8 | ||
108 | |||
109 | struct mv_otg_regs { | ||
110 | u32 usbcmd; /* Command register */ | ||
111 | u32 usbsts; /* Status register */ | ||
112 | u32 usbintr; /* Interrupt enable */ | ||
113 | u32 frindex; /* Frame index */ | ||
114 | u32 reserved1[1]; | ||
115 | u32 deviceaddr; /* Device Address */ | ||
116 | u32 eplistaddr; /* Endpoint List Address */ | ||
117 | u32 ttctrl; /* HOST TT status and control */ | ||
118 | u32 burstsize; /* Programmable Burst Size */ | ||
119 | u32 txfilltuning; /* Host Transmit Pre-Buffer Packet Tuning */ | ||
120 | u32 reserved[4]; | ||
121 | u32 epnak; /* Endpoint NAK */ | ||
122 | u32 epnaken; /* Endpoint NAK Enable */ | ||
123 | u32 configflag; /* Configured Flag register */ | ||
124 | u32 portsc[VUSBHS_MAX_PORTS]; /* Port Status/Control x, x = 1..8 */ | ||
125 | u32 otgsc; | ||
126 | u32 usbmode; /* USB Host/Device mode */ | ||
127 | u32 epsetupstat; /* Endpoint Setup Status */ | ||
128 | u32 epprime; /* Endpoint Initialize */ | ||
129 | u32 epflush; /* Endpoint De-initialize */ | ||
130 | u32 epstatus; /* Endpoint Status */ | ||
131 | u32 epcomplete; /* Endpoint Interrupt On Complete */ | ||
132 | u32 epctrlx[16]; /* Endpoint Control, where x = 0.. 15 */ | ||
133 | u32 mcr; /* Mux Control */ | ||
134 | u32 isr; /* Interrupt Status */ | ||
135 | u32 ier; /* Interrupt Enable */ | ||
136 | }; | ||
137 | |||
138 | struct mv_otg { | ||
139 | struct otg_transceiver otg; | ||
140 | struct mv_otg_ctrl otg_ctrl; | ||
141 | |||
142 | /* base address */ | ||
143 | void __iomem *phy_regs; | ||
144 | void __iomem *cap_regs; | ||
145 | struct mv_otg_regs __iomem *op_regs; | ||
146 | |||
147 | struct platform_device *pdev; | ||
148 | int irq; | ||
149 | u32 irq_status; | ||
150 | u32 irq_en; | ||
151 | |||
152 | struct delayed_work work; | ||
153 | struct workqueue_struct *qwork; | ||
154 | |||
155 | spinlock_t wq_lock; | ||
156 | |||
157 | struct mv_usb_platform_data *pdata; | ||
158 | |||
159 | unsigned int active; | ||
160 | unsigned int clock_gating; | ||
161 | unsigned int clknum; | ||
162 | struct clk *clk[0]; | ||
163 | }; | ||
164 | |||
165 | #endif | ||
diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c index d2e2efaba658..e9a5b1d2615e 100644 --- a/drivers/usb/renesas_usbhs/common.c +++ b/drivers/usb/renesas_usbhs/common.c | |||
@@ -95,25 +95,15 @@ struct usbhs_priv *usbhs_pdev_to_priv(struct platform_device *pdev) | |||
95 | /* | 95 | /* |
96 | * syscfg functions | 96 | * syscfg functions |
97 | */ | 97 | */ |
98 | void usbhs_sys_clock_ctrl(struct usbhs_priv *priv, int enable) | 98 | static void usbhs_sys_clock_ctrl(struct usbhs_priv *priv, int enable) |
99 | { | 99 | { |
100 | usbhs_bset(priv, SYSCFG, SCKE, enable ? SCKE : 0); | 100 | usbhs_bset(priv, SYSCFG, SCKE, enable ? SCKE : 0); |
101 | } | 101 | } |
102 | 102 | ||
103 | void usbhs_sys_hispeed_ctrl(struct usbhs_priv *priv, int enable) | ||
104 | { | ||
105 | usbhs_bset(priv, SYSCFG, HSE, enable ? HSE : 0); | ||
106 | } | ||
107 | |||
108 | void usbhs_sys_usb_ctrl(struct usbhs_priv *priv, int enable) | ||
109 | { | ||
110 | usbhs_bset(priv, SYSCFG, USBE, enable ? USBE : 0); | ||
111 | } | ||
112 | |||
113 | void usbhs_sys_host_ctrl(struct usbhs_priv *priv, int enable) | 103 | void usbhs_sys_host_ctrl(struct usbhs_priv *priv, int enable) |
114 | { | 104 | { |
115 | u16 mask = DCFM | DRPD | DPRPU; | 105 | u16 mask = DCFM | DRPD | DPRPU | HSE | USBE; |
116 | u16 val = DCFM | DRPD; | 106 | u16 val = DCFM | DRPD | HSE | USBE; |
117 | int has_otg = usbhs_get_dparam(priv, has_otg); | 107 | int has_otg = usbhs_get_dparam(priv, has_otg); |
118 | 108 | ||
119 | if (has_otg) | 109 | if (has_otg) |
@@ -130,8 +120,8 @@ void usbhs_sys_host_ctrl(struct usbhs_priv *priv, int enable) | |||
130 | 120 | ||
131 | void usbhs_sys_function_ctrl(struct usbhs_priv *priv, int enable) | 121 | void usbhs_sys_function_ctrl(struct usbhs_priv *priv, int enable) |
132 | { | 122 | { |
133 | u16 mask = DCFM | DRPD | DPRPU; | 123 | u16 mask = DCFM | DRPD | DPRPU | HSE | USBE; |
134 | u16 val = DPRPU; | 124 | u16 val = DPRPU | HSE | USBE; |
135 | 125 | ||
136 | /* | 126 | /* |
137 | * if enable | 127 | * if enable |
@@ -142,6 +132,11 @@ void usbhs_sys_function_ctrl(struct usbhs_priv *priv, int enable) | |||
142 | usbhs_bset(priv, SYSCFG, mask, enable ? val : 0); | 132 | usbhs_bset(priv, SYSCFG, mask, enable ? val : 0); |
143 | } | 133 | } |
144 | 134 | ||
135 | void usbhs_sys_set_test_mode(struct usbhs_priv *priv, u16 mode) | ||
136 | { | ||
137 | usbhs_write(priv, TESTMODE, mode); | ||
138 | } | ||
139 | |||
145 | /* | 140 | /* |
146 | * frame functions | 141 | * frame functions |
147 | */ | 142 | */ |
@@ -229,7 +224,7 @@ static void usbhsc_bus_init(struct usbhs_priv *priv) | |||
229 | /* | 224 | /* |
230 | * device configuration | 225 | * device configuration |
231 | */ | 226 | */ |
232 | int usbhs_set_device_speed(struct usbhs_priv *priv, int devnum, | 227 | int usbhs_set_device_config(struct usbhs_priv *priv, int devnum, |
233 | u16 upphub, u16 hubport, u16 speed) | 228 | u16 upphub, u16 hubport, u16 speed) |
234 | { | 229 | { |
235 | struct device *dev = usbhs_priv_to_dev(priv); | 230 | struct device *dev = usbhs_priv_to_dev(priv); |
@@ -301,18 +296,25 @@ static u32 usbhsc_default_pipe_type[] = { | |||
301 | */ | 296 | */ |
302 | static void usbhsc_power_ctrl(struct usbhs_priv *priv, int enable) | 297 | static void usbhsc_power_ctrl(struct usbhs_priv *priv, int enable) |
303 | { | 298 | { |
299 | struct platform_device *pdev = usbhs_priv_to_pdev(priv); | ||
304 | struct device *dev = usbhs_priv_to_dev(priv); | 300 | struct device *dev = usbhs_priv_to_dev(priv); |
305 | 301 | ||
306 | if (enable) { | 302 | if (enable) { |
307 | /* enable PM */ | 303 | /* enable PM */ |
308 | pm_runtime_get_sync(dev); | 304 | pm_runtime_get_sync(dev); |
309 | 305 | ||
306 | /* enable platform power */ | ||
307 | usbhs_platform_call(priv, power_ctrl, pdev, priv->base, enable); | ||
308 | |||
310 | /* USB on */ | 309 | /* USB on */ |
311 | usbhs_sys_clock_ctrl(priv, enable); | 310 | usbhs_sys_clock_ctrl(priv, enable); |
312 | } else { | 311 | } else { |
313 | /* USB off */ | 312 | /* USB off */ |
314 | usbhs_sys_clock_ctrl(priv, enable); | 313 | usbhs_sys_clock_ctrl(priv, enable); |
315 | 314 | ||
315 | /* disable platform power */ | ||
316 | usbhs_platform_call(priv, power_ctrl, pdev, priv->base, enable); | ||
317 | |||
316 | /* disable PM */ | 318 | /* disable PM */ |
317 | pm_runtime_put_sync(dev); | 319 | pm_runtime_put_sync(dev); |
318 | } | 320 | } |
@@ -388,7 +390,7 @@ static void usbhsc_notify_hotplug(struct work_struct *work) | |||
388 | usbhsc_hotplug(priv); | 390 | usbhsc_hotplug(priv); |
389 | } | 391 | } |
390 | 392 | ||
391 | int usbhsc_drvcllbck_notify_hotplug(struct platform_device *pdev) | 393 | static int usbhsc_drvcllbck_notify_hotplug(struct platform_device *pdev) |
392 | { | 394 | { |
393 | struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev); | 395 | struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev); |
394 | int delay = usbhs_get_dparam(priv, detection_delay); | 396 | int delay = usbhs_get_dparam(priv, detection_delay); |
@@ -398,14 +400,15 @@ int usbhsc_drvcllbck_notify_hotplug(struct platform_device *pdev) | |||
398 | * To make sure safety context, | 400 | * To make sure safety context, |
399 | * use workqueue for usbhs_notify_hotplug | 401 | * use workqueue for usbhs_notify_hotplug |
400 | */ | 402 | */ |
401 | schedule_delayed_work(&priv->notify_hotplug_work, delay); | 403 | schedule_delayed_work(&priv->notify_hotplug_work, |
404 | msecs_to_jiffies(delay)); | ||
402 | return 0; | 405 | return 0; |
403 | } | 406 | } |
404 | 407 | ||
405 | /* | 408 | /* |
406 | * platform functions | 409 | * platform functions |
407 | */ | 410 | */ |
408 | static int __devinit usbhs_probe(struct platform_device *pdev) | 411 | static int usbhs_probe(struct platform_device *pdev) |
409 | { | 412 | { |
410 | struct renesas_usbhs_platform_info *info = pdev->dev.platform_data; | 413 | struct renesas_usbhs_platform_info *info = pdev->dev.platform_data; |
411 | struct renesas_usbhs_driver_callback *dfunc; | 414 | struct renesas_usbhs_driver_callback *dfunc; |
@@ -637,18 +640,7 @@ static struct platform_driver renesas_usbhs_driver = { | |||
637 | .remove = __devexit_p(usbhs_remove), | 640 | .remove = __devexit_p(usbhs_remove), |
638 | }; | 641 | }; |
639 | 642 | ||
640 | static int __init usbhs_init(void) | 643 | module_platform_driver(renesas_usbhs_driver); |
641 | { | ||
642 | return platform_driver_register(&renesas_usbhs_driver); | ||
643 | } | ||
644 | |||
645 | static void __exit usbhs_exit(void) | ||
646 | { | ||
647 | platform_driver_unregister(&renesas_usbhs_driver); | ||
648 | } | ||
649 | |||
650 | module_init(usbhs_init); | ||
651 | module_exit(usbhs_exit); | ||
652 | 644 | ||
653 | MODULE_LICENSE("GPL"); | 645 | MODULE_LICENSE("GPL"); |
654 | MODULE_DESCRIPTION("Renesas USB driver"); | 646 | MODULE_DESCRIPTION("Renesas USB driver"); |
diff --git a/drivers/usb/renesas_usbhs/common.h b/drivers/usb/renesas_usbhs/common.h index 8729da5c3be6..d79b3e27db95 100644 --- a/drivers/usb/renesas_usbhs/common.h +++ b/drivers/usb/renesas_usbhs/common.h | |||
@@ -33,6 +33,7 @@ struct usbhs_priv; | |||
33 | #define SYSCFG 0x0000 | 33 | #define SYSCFG 0x0000 |
34 | #define BUSWAIT 0x0002 | 34 | #define BUSWAIT 0x0002 |
35 | #define DVSTCTR 0x0008 | 35 | #define DVSTCTR 0x0008 |
36 | #define TESTMODE 0x000C | ||
36 | #define CFIFO 0x0014 | 37 | #define CFIFO 0x0014 |
37 | #define CFIFOSEL 0x0020 | 38 | #define CFIFOSEL 0x0020 |
38 | #define CFIFOCTR 0x0022 | 39 | #define CFIFOCTR 0x0022 |
@@ -275,19 +276,15 @@ u16 usbhs_read(struct usbhs_priv *priv, u32 reg); | |||
275 | void usbhs_write(struct usbhs_priv *priv, u32 reg, u16 data); | 276 | void usbhs_write(struct usbhs_priv *priv, u32 reg, u16 data); |
276 | void usbhs_bset(struct usbhs_priv *priv, u32 reg, u16 mask, u16 data); | 277 | void usbhs_bset(struct usbhs_priv *priv, u32 reg, u16 mask, u16 data); |
277 | 278 | ||
278 | int usbhsc_drvcllbck_notify_hotplug(struct platform_device *pdev); | ||
279 | |||
280 | #define usbhs_lock(p, f) spin_lock_irqsave(usbhs_priv_to_lock(p), f) | 279 | #define usbhs_lock(p, f) spin_lock_irqsave(usbhs_priv_to_lock(p), f) |
281 | #define usbhs_unlock(p, f) spin_unlock_irqrestore(usbhs_priv_to_lock(p), f) | 280 | #define usbhs_unlock(p, f) spin_unlock_irqrestore(usbhs_priv_to_lock(p), f) |
282 | 281 | ||
283 | /* | 282 | /* |
284 | * sysconfig | 283 | * sysconfig |
285 | */ | 284 | */ |
286 | void usbhs_sys_clock_ctrl(struct usbhs_priv *priv, int enable); | ||
287 | void usbhs_sys_hispeed_ctrl(struct usbhs_priv *priv, int enable); | ||
288 | void usbhs_sys_usb_ctrl(struct usbhs_priv *priv, int enable); | ||
289 | void usbhs_sys_host_ctrl(struct usbhs_priv *priv, int enable); | 285 | void usbhs_sys_host_ctrl(struct usbhs_priv *priv, int enable); |
290 | void usbhs_sys_function_ctrl(struct usbhs_priv *priv, int enable); | 286 | void usbhs_sys_function_ctrl(struct usbhs_priv *priv, int enable); |
287 | void usbhs_sys_set_test_mode(struct usbhs_priv *priv, u16 mode); | ||
291 | 288 | ||
292 | /* | 289 | /* |
293 | * usb request | 290 | * usb request |
@@ -311,7 +308,7 @@ int usbhs_frame_get_num(struct usbhs_priv *priv); | |||
311 | /* | 308 | /* |
312 | * device config | 309 | * device config |
313 | */ | 310 | */ |
314 | int usbhs_set_device_speed(struct usbhs_priv *priv, int devnum, u16 upphub, | 311 | int usbhs_set_device_config(struct usbhs_priv *priv, int devnum, u16 upphub, |
315 | u16 hubport, u16 speed); | 312 | u16 hubport, u16 speed); |
316 | 313 | ||
317 | /* | 314 | /* |
diff --git a/drivers/usb/renesas_usbhs/fifo.c b/drivers/usb/renesas_usbhs/fifo.c index e2f22d4b8c3a..72339bd6fcab 100644 --- a/drivers/usb/renesas_usbhs/fifo.c +++ b/drivers/usb/renesas_usbhs/fifo.c | |||
@@ -56,7 +56,7 @@ static struct usbhs_pkt_handle usbhsf_null_handler = { | |||
56 | void usbhs_pkt_push(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt, | 56 | void usbhs_pkt_push(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt, |
57 | void (*done)(struct usbhs_priv *priv, | 57 | void (*done)(struct usbhs_priv *priv, |
58 | struct usbhs_pkt *pkt), | 58 | struct usbhs_pkt *pkt), |
59 | void *buf, int len, int zero) | 59 | void *buf, int len, int zero, int sequence) |
60 | { | 60 | { |
61 | struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe); | 61 | struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe); |
62 | struct device *dev = usbhs_priv_to_dev(priv); | 62 | struct device *dev = usbhs_priv_to_dev(priv); |
@@ -90,6 +90,7 @@ void usbhs_pkt_push(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt, | |||
90 | pkt->zero = zero; | 90 | pkt->zero = zero; |
91 | pkt->actual = 0; | 91 | pkt->actual = 0; |
92 | pkt->done = done; | 92 | pkt->done = done; |
93 | pkt->sequence = sequence; | ||
93 | 94 | ||
94 | usbhs_unlock(priv, flags); | 95 | usbhs_unlock(priv, flags); |
95 | /******************** spin unlock ******************/ | 96 | /******************** spin unlock ******************/ |
@@ -481,6 +482,9 @@ static int usbhsf_pio_try_push(struct usbhs_pkt *pkt, int *is_done) | |||
481 | int i, ret, len; | 482 | int i, ret, len; |
482 | int is_short; | 483 | int is_short; |
483 | 484 | ||
485 | usbhs_pipe_data_sequence(pipe, pkt->sequence); | ||
486 | pkt->sequence = -1; /* -1 sequence will be ignored */ | ||
487 | |||
484 | ret = usbhsf_fifo_select(pipe, fifo, 1); | 488 | ret = usbhsf_fifo_select(pipe, fifo, 1); |
485 | if (ret < 0) | 489 | if (ret < 0) |
486 | return 0; | 490 | return 0; |
@@ -584,6 +588,8 @@ static int usbhsf_prepare_pop(struct usbhs_pkt *pkt, int *is_done) | |||
584 | /* | 588 | /* |
585 | * pipe enable to prepare packet receive | 589 | * pipe enable to prepare packet receive |
586 | */ | 590 | */ |
591 | usbhs_pipe_data_sequence(pipe, pkt->sequence); | ||
592 | pkt->sequence = -1; /* -1 sequence will be ignored */ | ||
587 | 593 | ||
588 | usbhs_pipe_enable(pipe); | 594 | usbhs_pipe_enable(pipe); |
589 | usbhsf_rx_irq_ctrl(pipe, 1); | 595 | usbhsf_rx_irq_ctrl(pipe, 1); |
@@ -641,6 +647,7 @@ static int usbhsf_pio_try_pop(struct usbhs_pkt *pkt, int *is_done) | |||
641 | * "Operation" - "FIFO Buffer Memory" - "FIFO Port Function" | 647 | * "Operation" - "FIFO Buffer Memory" - "FIFO Port Function" |
642 | */ | 648 | */ |
643 | if (0 == rcv_len) { | 649 | if (0 == rcv_len) { |
650 | pkt->zero = 1; | ||
644 | usbhsf_fifo_clear(pipe, fifo); | 651 | usbhsf_fifo_clear(pipe, fifo); |
645 | goto usbhs_fifo_read_end; | 652 | goto usbhs_fifo_read_end; |
646 | } | 653 | } |
@@ -820,7 +827,7 @@ static int usbhsf_dma_prepare_push(struct usbhs_pkt *pkt, int *is_done) | |||
820 | if (len % 4) /* 32bit alignment */ | 827 | if (len % 4) /* 32bit alignment */ |
821 | goto usbhsf_pio_prepare_push; | 828 | goto usbhsf_pio_prepare_push; |
822 | 829 | ||
823 | if ((*(u32 *) pkt->buf + pkt->actual) & 0x7) /* 8byte alignment */ | 830 | if ((uintptr_t)(pkt->buf + pkt->actual) & 0x7) /* 8byte alignment */ |
824 | goto usbhsf_pio_prepare_push; | 831 | goto usbhsf_pio_prepare_push; |
825 | 832 | ||
826 | /* get enable DMA fifo */ | 833 | /* get enable DMA fifo */ |
@@ -897,7 +904,7 @@ static int usbhsf_dma_try_pop(struct usbhs_pkt *pkt, int *is_done) | |||
897 | if (!fifo) | 904 | if (!fifo) |
898 | goto usbhsf_pio_prepare_pop; | 905 | goto usbhsf_pio_prepare_pop; |
899 | 906 | ||
900 | if ((*(u32 *) pkt->buf + pkt->actual) & 0x7) /* 8byte alignment */ | 907 | if ((uintptr_t)(pkt->buf + pkt->actual) & 0x7) /* 8byte alignment */ |
901 | goto usbhsf_pio_prepare_pop; | 908 | goto usbhsf_pio_prepare_pop; |
902 | 909 | ||
903 | ret = usbhsf_fifo_select(pipe, fifo, 0); | 910 | ret = usbhsf_fifo_select(pipe, fifo, 0); |
diff --git a/drivers/usb/renesas_usbhs/fifo.h b/drivers/usb/renesas_usbhs/fifo.h index 32a7b246b28d..f68609c0f489 100644 --- a/drivers/usb/renesas_usbhs/fifo.h +++ b/drivers/usb/renesas_usbhs/fifo.h | |||
@@ -59,6 +59,7 @@ struct usbhs_pkt { | |||
59 | int trans; | 59 | int trans; |
60 | int actual; | 60 | int actual; |
61 | int zero; | 61 | int zero; |
62 | int sequence; | ||
62 | }; | 63 | }; |
63 | 64 | ||
64 | struct usbhs_pkt_handle { | 65 | struct usbhs_pkt_handle { |
@@ -95,7 +96,7 @@ void usbhs_pkt_init(struct usbhs_pkt *pkt); | |||
95 | void usbhs_pkt_push(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt, | 96 | void usbhs_pkt_push(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt, |
96 | void (*done)(struct usbhs_priv *priv, | 97 | void (*done)(struct usbhs_priv *priv, |
97 | struct usbhs_pkt *pkt), | 98 | struct usbhs_pkt *pkt), |
98 | void *buf, int len, int zero); | 99 | void *buf, int len, int zero, int sequence); |
99 | struct usbhs_pkt *usbhs_pkt_pop(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt); | 100 | struct usbhs_pkt *usbhs_pkt_pop(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt); |
100 | void usbhs_pkt_start(struct usbhs_pipe *pipe); | 101 | void usbhs_pkt_start(struct usbhs_pipe *pipe); |
101 | 102 | ||
diff --git a/drivers/usb/renesas_usbhs/mod.c b/drivers/usb/renesas_usbhs/mod.c index 053f86d70009..1b97fb12694b 100644 --- a/drivers/usb/renesas_usbhs/mod.c +++ b/drivers/usb/renesas_usbhs/mod.c | |||
@@ -50,7 +50,9 @@ static int usbhsm_autonomy_irq_vbus(struct usbhs_priv *priv, | |||
50 | { | 50 | { |
51 | struct platform_device *pdev = usbhs_priv_to_pdev(priv); | 51 | struct platform_device *pdev = usbhs_priv_to_pdev(priv); |
52 | 52 | ||
53 | return usbhsc_drvcllbck_notify_hotplug(pdev); | 53 | renesas_usbhs_call_notify_hotplug(pdev); |
54 | |||
55 | return 0; | ||
54 | } | 56 | } |
55 | 57 | ||
56 | void usbhs_mod_autonomy_mode(struct usbhs_priv *priv) | 58 | void usbhs_mod_autonomy_mode(struct usbhs_priv *priv) |
@@ -349,7 +351,7 @@ void usbhs_irq_callback_update(struct usbhs_priv *priv, struct usbhs_mod *mod) | |||
349 | if (mod->irq_attch) | 351 | if (mod->irq_attch) |
350 | intenb1 |= ATTCHE; | 352 | intenb1 |= ATTCHE; |
351 | 353 | ||
352 | if (mod->irq_attch) | 354 | if (mod->irq_dtch) |
353 | intenb1 |= DTCHE; | 355 | intenb1 |= DTCHE; |
354 | 356 | ||
355 | if (mod->irq_sign) | 357 | if (mod->irq_sign) |
diff --git a/drivers/usb/renesas_usbhs/mod.h b/drivers/usb/renesas_usbhs/mod.h index 8ae3733031cd..6c6875533f01 100644 --- a/drivers/usb/renesas_usbhs/mod.h +++ b/drivers/usb/renesas_usbhs/mod.h | |||
@@ -143,8 +143,8 @@ void usbhs_irq_callback_update(struct usbhs_priv *priv, struct usbhs_mod *mod); | |||
143 | */ | 143 | */ |
144 | #if defined(CONFIG_USB_RENESAS_USBHS_HCD) || \ | 144 | #if defined(CONFIG_USB_RENESAS_USBHS_HCD) || \ |
145 | defined(CONFIG_USB_RENESAS_USBHS_HCD_MODULE) | 145 | defined(CONFIG_USB_RENESAS_USBHS_HCD_MODULE) |
146 | extern int __devinit usbhs_mod_host_probe(struct usbhs_priv *priv); | 146 | extern int usbhs_mod_host_probe(struct usbhs_priv *priv); |
147 | extern int __devexit usbhs_mod_host_remove(struct usbhs_priv *priv); | 147 | extern int usbhs_mod_host_remove(struct usbhs_priv *priv); |
148 | #else | 148 | #else |
149 | static inline int usbhs_mod_host_probe(struct usbhs_priv *priv) | 149 | static inline int usbhs_mod_host_probe(struct usbhs_priv *priv) |
150 | { | 150 | { |
@@ -157,8 +157,8 @@ static inline void usbhs_mod_host_remove(struct usbhs_priv *priv) | |||
157 | 157 | ||
158 | #if defined(CONFIG_USB_RENESAS_USBHS_UDC) || \ | 158 | #if defined(CONFIG_USB_RENESAS_USBHS_UDC) || \ |
159 | defined(CONFIG_USB_RENESAS_USBHS_UDC_MODULE) | 159 | defined(CONFIG_USB_RENESAS_USBHS_UDC_MODULE) |
160 | extern int __devinit usbhs_mod_gadget_probe(struct usbhs_priv *priv); | 160 | extern int usbhs_mod_gadget_probe(struct usbhs_priv *priv); |
161 | extern void __devexit usbhs_mod_gadget_remove(struct usbhs_priv *priv); | 161 | extern void usbhs_mod_gadget_remove(struct usbhs_priv *priv); |
162 | #else | 162 | #else |
163 | static inline int usbhs_mod_gadget_probe(struct usbhs_priv *priv) | 163 | static inline int usbhs_mod_gadget_probe(struct usbhs_priv *priv) |
164 | { | 164 | { |
diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c b/drivers/usb/renesas_usbhs/mod_gadget.c index 4cc7ee0babc6..528691d5f3e2 100644 --- a/drivers/usb/renesas_usbhs/mod_gadget.c +++ b/drivers/usb/renesas_usbhs/mod_gadget.c | |||
@@ -14,6 +14,7 @@ | |||
14 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | 14 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * | 15 | * |
16 | */ | 16 | */ |
17 | #include <linux/delay.h> | ||
17 | #include <linux/dma-mapping.h> | 18 | #include <linux/dma-mapping.h> |
18 | #include <linux/io.h> | 19 | #include <linux/io.h> |
19 | #include <linux/module.h> | 20 | #include <linux/module.h> |
@@ -44,7 +45,6 @@ struct usbhsg_uep { | |||
44 | struct usbhsg_gpriv { | 45 | struct usbhsg_gpriv { |
45 | struct usb_gadget gadget; | 46 | struct usb_gadget gadget; |
46 | struct usbhs_mod mod; | 47 | struct usbhs_mod mod; |
47 | struct list_head link; | ||
48 | 48 | ||
49 | struct usbhsg_uep *uep; | 49 | struct usbhsg_uep *uep; |
50 | int uep_size; | 50 | int uep_size; |
@@ -114,16 +114,6 @@ struct usbhsg_recip_handle { | |||
114 | #define usbhsg_status_clr(gp, b) (gp->status &= ~b) | 114 | #define usbhsg_status_clr(gp, b) (gp->status &= ~b) |
115 | #define usbhsg_status_has(gp, b) (gp->status & b) | 115 | #define usbhsg_status_has(gp, b) (gp->status & b) |
116 | 116 | ||
117 | /* controller */ | ||
118 | LIST_HEAD(the_controller_link); | ||
119 | |||
120 | #define usbhsg_for_each_controller(gpriv)\ | ||
121 | list_for_each_entry(gpriv, &the_controller_link, link) | ||
122 | #define usbhsg_controller_register(gpriv)\ | ||
123 | list_add_tail(&(gpriv)->link, &the_controller_link) | ||
124 | #define usbhsg_controller_unregister(gpriv)\ | ||
125 | list_del_init(&(gpriv)->link) | ||
126 | |||
127 | /* | 117 | /* |
128 | * queue push/pop | 118 | * queue push/pop |
129 | */ | 119 | */ |
@@ -164,7 +154,7 @@ static void usbhsg_queue_push(struct usbhsg_uep *uep, | |||
164 | req->actual = 0; | 154 | req->actual = 0; |
165 | req->status = -EINPROGRESS; | 155 | req->status = -EINPROGRESS; |
166 | usbhs_pkt_push(pipe, pkt, usbhsg_queue_done, | 156 | usbhs_pkt_push(pipe, pkt, usbhsg_queue_done, |
167 | req->buf, req->length, req->zero); | 157 | req->buf, req->length, req->zero, -1); |
168 | usbhs_pkt_start(pipe); | 158 | usbhs_pkt_start(pipe); |
169 | 159 | ||
170 | dev_dbg(dev, "pipe %d : queue push (%d)\n", | 160 | dev_dbg(dev, "pipe %d : queue push (%d)\n", |
@@ -195,7 +185,7 @@ static int usbhsg_dma_map(struct device *dev, | |||
195 | } | 185 | } |
196 | 186 | ||
197 | if (dma_mapping_error(dev, pkt->dma)) { | 187 | if (dma_mapping_error(dev, pkt->dma)) { |
198 | dev_err(dev, "dma mapping error %x\n", pkt->dma); | 188 | dev_err(dev, "dma mapping error %llx\n", (u64)pkt->dma); |
199 | return -EIO; | 189 | return -EIO; |
200 | } | 190 | } |
201 | 191 | ||
@@ -271,6 +261,8 @@ static int usbhsg_recip_handler_std_clear_endpoint(struct usbhs_priv *priv, | |||
271 | 261 | ||
272 | usbhsg_recip_handler_std_control_done(priv, uep, ctrl); | 262 | usbhsg_recip_handler_std_control_done(priv, uep, ctrl); |
273 | 263 | ||
264 | usbhs_pkt_start(pipe); | ||
265 | |||
274 | return 0; | 266 | return 0; |
275 | } | 267 | } |
276 | 268 | ||
@@ -282,6 +274,145 @@ struct usbhsg_recip_handle req_clear_feature = { | |||
282 | }; | 274 | }; |
283 | 275 | ||
284 | /* | 276 | /* |
277 | * USB_TYPE_STANDARD / set feature functions | ||
278 | */ | ||
279 | static int usbhsg_recip_handler_std_set_device(struct usbhs_priv *priv, | ||
280 | struct usbhsg_uep *uep, | ||
281 | struct usb_ctrlrequest *ctrl) | ||
282 | { | ||
283 | switch (le16_to_cpu(ctrl->wValue)) { | ||
284 | case USB_DEVICE_TEST_MODE: | ||
285 | usbhsg_recip_handler_std_control_done(priv, uep, ctrl); | ||
286 | udelay(100); | ||
287 | usbhs_sys_set_test_mode(priv, le16_to_cpu(ctrl->wIndex >> 8)); | ||
288 | break; | ||
289 | default: | ||
290 | usbhsg_recip_handler_std_control_done(priv, uep, ctrl); | ||
291 | break; | ||
292 | } | ||
293 | |||
294 | return 0; | ||
295 | } | ||
296 | |||
297 | static int usbhsg_recip_handler_std_set_endpoint(struct usbhs_priv *priv, | ||
298 | struct usbhsg_uep *uep, | ||
299 | struct usb_ctrlrequest *ctrl) | ||
300 | { | ||
301 | struct usbhs_pipe *pipe = usbhsg_uep_to_pipe(uep); | ||
302 | |||
303 | usbhs_pipe_stall(pipe); | ||
304 | |||
305 | usbhsg_recip_handler_std_control_done(priv, uep, ctrl); | ||
306 | |||
307 | return 0; | ||
308 | } | ||
309 | |||
310 | struct usbhsg_recip_handle req_set_feature = { | ||
311 | .name = "set feature", | ||
312 | .device = usbhsg_recip_handler_std_set_device, | ||
313 | .interface = usbhsg_recip_handler_std_control_done, | ||
314 | .endpoint = usbhsg_recip_handler_std_set_endpoint, | ||
315 | }; | ||
316 | |||
317 | /* | ||
318 | * USB_TYPE_STANDARD / get status functions | ||
319 | */ | ||
320 | static void __usbhsg_recip_send_complete(struct usb_ep *ep, | ||
321 | struct usb_request *req) | ||
322 | { | ||
323 | struct usbhsg_request *ureq = usbhsg_req_to_ureq(req); | ||
324 | |||
325 | /* free allocated recip-buffer/usb_request */ | ||
326 | kfree(ureq->pkt.buf); | ||
327 | usb_ep_free_request(ep, req); | ||
328 | } | ||
329 | |||
330 | static void __usbhsg_recip_send_status(struct usbhsg_gpriv *gpriv, | ||
331 | unsigned short status) | ||
332 | { | ||
333 | struct usbhsg_uep *dcp = usbhsg_gpriv_to_dcp(gpriv); | ||
334 | struct usbhs_pipe *pipe = usbhsg_uep_to_pipe(dcp); | ||
335 | struct device *dev = usbhsg_gpriv_to_dev(gpriv); | ||
336 | struct usb_request *req; | ||
337 | unsigned short *buf; | ||
338 | |||
339 | /* alloc new usb_request for recip */ | ||
340 | req = usb_ep_alloc_request(&dcp->ep, GFP_ATOMIC); | ||
341 | if (!req) { | ||
342 | dev_err(dev, "recip request allocation fail\n"); | ||
343 | return; | ||
344 | } | ||
345 | |||
346 | /* alloc recip data buffer */ | ||
347 | buf = kmalloc(sizeof(*buf), GFP_ATOMIC); | ||
348 | if (!buf) { | ||
349 | usb_ep_free_request(&dcp->ep, req); | ||
350 | dev_err(dev, "recip data allocation fail\n"); | ||
351 | return; | ||
352 | } | ||
353 | |||
354 | /* recip data is status */ | ||
355 | *buf = cpu_to_le16(status); | ||
356 | |||
357 | /* allocated usb_request/buffer will be freed */ | ||
358 | req->complete = __usbhsg_recip_send_complete; | ||
359 | req->buf = buf; | ||
360 | req->length = sizeof(*buf); | ||
361 | req->zero = 0; | ||
362 | |||
363 | /* push packet */ | ||
364 | pipe->handler = &usbhs_fifo_pio_push_handler; | ||
365 | usbhsg_queue_push(dcp, usbhsg_req_to_ureq(req)); | ||
366 | } | ||
367 | |||
368 | static int usbhsg_recip_handler_std_get_device(struct usbhs_priv *priv, | ||
369 | struct usbhsg_uep *uep, | ||
370 | struct usb_ctrlrequest *ctrl) | ||
371 | { | ||
372 | struct usbhsg_gpriv *gpriv = usbhsg_uep_to_gpriv(uep); | ||
373 | unsigned short status = 1 << USB_DEVICE_SELF_POWERED; | ||
374 | |||
375 | __usbhsg_recip_send_status(gpriv, status); | ||
376 | |||
377 | return 0; | ||
378 | } | ||
379 | |||
380 | static int usbhsg_recip_handler_std_get_interface(struct usbhs_priv *priv, | ||
381 | struct usbhsg_uep *uep, | ||
382 | struct usb_ctrlrequest *ctrl) | ||
383 | { | ||
384 | struct usbhsg_gpriv *gpriv = usbhsg_uep_to_gpriv(uep); | ||
385 | unsigned short status = 0; | ||
386 | |||
387 | __usbhsg_recip_send_status(gpriv, status); | ||
388 | |||
389 | return 0; | ||
390 | } | ||
391 | |||
392 | static int usbhsg_recip_handler_std_get_endpoint(struct usbhs_priv *priv, | ||
393 | struct usbhsg_uep *uep, | ||
394 | struct usb_ctrlrequest *ctrl) | ||
395 | { | ||
396 | struct usbhsg_gpriv *gpriv = usbhsg_uep_to_gpriv(uep); | ||
397 | struct usbhs_pipe *pipe = usbhsg_uep_to_pipe(uep); | ||
398 | unsigned short status = 0; | ||
399 | |||
400 | if (usbhs_pipe_is_stall(pipe)) | ||
401 | status = 1 << USB_ENDPOINT_HALT; | ||
402 | |||
403 | __usbhsg_recip_send_status(gpriv, status); | ||
404 | |||
405 | return 0; | ||
406 | } | ||
407 | |||
408 | struct usbhsg_recip_handle req_get_status = { | ||
409 | .name = "get status", | ||
410 | .device = usbhsg_recip_handler_std_get_device, | ||
411 | .interface = usbhsg_recip_handler_std_get_interface, | ||
412 | .endpoint = usbhsg_recip_handler_std_get_endpoint, | ||
413 | }; | ||
414 | |||
415 | /* | ||
285 | * USB_TYPE handler | 416 | * USB_TYPE handler |
286 | */ | 417 | */ |
287 | static int usbhsg_recip_run_handle(struct usbhs_priv *priv, | 418 | static int usbhsg_recip_run_handle(struct usbhs_priv *priv, |
@@ -303,8 +434,7 @@ static int usbhsg_recip_run_handle(struct usbhs_priv *priv, | |||
303 | pipe = usbhsg_uep_to_pipe(uep); | 434 | pipe = usbhsg_uep_to_pipe(uep); |
304 | if (!pipe) { | 435 | if (!pipe) { |
305 | dev_err(dev, "wrong recip request\n"); | 436 | dev_err(dev, "wrong recip request\n"); |
306 | ret = -EINVAL; | 437 | return -EINVAL; |
307 | goto usbhsg_recip_run_handle_end; | ||
308 | } | 438 | } |
309 | 439 | ||
310 | switch (recip) { | 440 | switch (recip) { |
@@ -327,20 +457,10 @@ static int usbhsg_recip_run_handle(struct usbhs_priv *priv, | |||
327 | } | 457 | } |
328 | 458 | ||
329 | if (func) { | 459 | if (func) { |
330 | unsigned long flags; | ||
331 | |||
332 | dev_dbg(dev, "%s (pipe %d :%s)\n", handler->name, nth, msg); | 460 | dev_dbg(dev, "%s (pipe %d :%s)\n", handler->name, nth, msg); |
333 | |||
334 | /******************** spin lock ********************/ | ||
335 | usbhs_lock(priv, flags); | ||
336 | ret = func(priv, uep, ctrl); | 461 | ret = func(priv, uep, ctrl); |
337 | usbhs_unlock(priv, flags); | ||
338 | /******************** spin unlock ******************/ | ||
339 | } | 462 | } |
340 | 463 | ||
341 | usbhsg_recip_run_handle_end: | ||
342 | usbhs_pkt_start(pipe); | ||
343 | |||
344 | return ret; | 464 | return ret; |
345 | } | 465 | } |
346 | 466 | ||
@@ -412,6 +532,12 @@ static int usbhsg_irq_ctrl_stage(struct usbhs_priv *priv, | |||
412 | case USB_REQ_CLEAR_FEATURE: | 532 | case USB_REQ_CLEAR_FEATURE: |
413 | recip_handler = &req_clear_feature; | 533 | recip_handler = &req_clear_feature; |
414 | break; | 534 | break; |
535 | case USB_REQ_SET_FEATURE: | ||
536 | recip_handler = &req_set_feature; | ||
537 | break; | ||
538 | case USB_REQ_GET_STATUS: | ||
539 | recip_handler = &req_get_status; | ||
540 | break; | ||
415 | } | 541 | } |
416 | } | 542 | } |
417 | 543 | ||
@@ -439,14 +565,16 @@ static int usbhsg_pipe_disable(struct usbhsg_uep *uep) | |||
439 | struct usbhs_pipe *pipe = usbhsg_uep_to_pipe(uep); | 565 | struct usbhs_pipe *pipe = usbhsg_uep_to_pipe(uep); |
440 | struct usbhs_pkt *pkt; | 566 | struct usbhs_pkt *pkt; |
441 | 567 | ||
442 | usbhs_pipe_disable(pipe); | ||
443 | |||
444 | while (1) { | 568 | while (1) { |
445 | pkt = usbhs_pkt_pop(pipe, NULL); | 569 | pkt = usbhs_pkt_pop(pipe, NULL); |
446 | if (!pkt) | 570 | if (!pkt) |
447 | break; | 571 | break; |
572 | |||
573 | usbhsg_queue_pop(uep, usbhsg_pkt_to_ureq(pkt), -ECONNRESET); | ||
448 | } | 574 | } |
449 | 575 | ||
576 | usbhs_pipe_disable(pipe); | ||
577 | |||
450 | return 0; | 578 | return 0; |
451 | } | 579 | } |
452 | 580 | ||
@@ -681,9 +809,7 @@ static int usbhsg_try_start(struct usbhs_priv *priv, u32 status) | |||
681 | * - function | 809 | * - function |
682 | * - usb module | 810 | * - usb module |
683 | */ | 811 | */ |
684 | usbhs_sys_hispeed_ctrl(priv, 1); | ||
685 | usbhs_sys_function_ctrl(priv, 1); | 812 | usbhs_sys_function_ctrl(priv, 1); |
686 | usbhs_sys_usb_ctrl(priv, 1); | ||
687 | 813 | ||
688 | /* | 814 | /* |
689 | * enable irq callback | 815 | * enable irq callback |
@@ -731,9 +857,8 @@ static int usbhsg_try_stop(struct usbhs_priv *priv, u32 status) | |||
731 | gpriv->gadget.speed = USB_SPEED_UNKNOWN; | 857 | gpriv->gadget.speed = USB_SPEED_UNKNOWN; |
732 | 858 | ||
733 | /* disable sys */ | 859 | /* disable sys */ |
734 | usbhs_sys_hispeed_ctrl(priv, 0); | 860 | usbhs_sys_set_test_mode(priv, 0); |
735 | usbhs_sys_function_ctrl(priv, 0); | 861 | usbhs_sys_function_ctrl(priv, 0); |
736 | usbhs_sys_usb_ctrl(priv, 0); | ||
737 | 862 | ||
738 | usbhsg_pipe_disable(dcp); | 863 | usbhsg_pipe_disable(dcp); |
739 | 864 | ||
@@ -751,53 +876,32 @@ static int usbhsg_gadget_start(struct usb_gadget *gadget, | |||
751 | struct usb_gadget_driver *driver) | 876 | struct usb_gadget_driver *driver) |
752 | { | 877 | { |
753 | struct usbhsg_gpriv *gpriv = usbhsg_gadget_to_gpriv(gadget); | 878 | struct usbhsg_gpriv *gpriv = usbhsg_gadget_to_gpriv(gadget); |
754 | struct usbhs_priv *priv; | 879 | struct usbhs_priv *priv = usbhsg_gpriv_to_priv(gpriv); |
755 | struct device *dev; | ||
756 | int ret; | ||
757 | 880 | ||
758 | if (!driver || | 881 | if (!driver || |
759 | !driver->setup || | 882 | !driver->setup || |
760 | driver->speed != USB_SPEED_HIGH) | 883 | driver->max_speed < USB_SPEED_FULL) |
761 | return -EINVAL; | 884 | return -EINVAL; |
762 | 885 | ||
763 | dev = usbhsg_gpriv_to_dev(gpriv); | ||
764 | priv = usbhsg_gpriv_to_priv(gpriv); | ||
765 | |||
766 | /* first hook up the driver ... */ | 886 | /* first hook up the driver ... */ |
767 | gpriv->driver = driver; | 887 | gpriv->driver = driver; |
768 | gpriv->gadget.dev.driver = &driver->driver; | 888 | gpriv->gadget.dev.driver = &driver->driver; |
769 | 889 | ||
770 | ret = device_add(&gpriv->gadget.dev); | ||
771 | if (ret) { | ||
772 | dev_err(dev, "device_add error %d\n", ret); | ||
773 | goto add_fail; | ||
774 | } | ||
775 | |||
776 | return usbhsg_try_start(priv, USBHSG_STATUS_REGISTERD); | 890 | return usbhsg_try_start(priv, USBHSG_STATUS_REGISTERD); |
777 | |||
778 | add_fail: | ||
779 | gpriv->driver = NULL; | ||
780 | gpriv->gadget.dev.driver = NULL; | ||
781 | |||
782 | return ret; | ||
783 | } | 891 | } |
784 | 892 | ||
785 | static int usbhsg_gadget_stop(struct usb_gadget *gadget, | 893 | static int usbhsg_gadget_stop(struct usb_gadget *gadget, |
786 | struct usb_gadget_driver *driver) | 894 | struct usb_gadget_driver *driver) |
787 | { | 895 | { |
788 | struct usbhsg_gpriv *gpriv = usbhsg_gadget_to_gpriv(gadget); | 896 | struct usbhsg_gpriv *gpriv = usbhsg_gadget_to_gpriv(gadget); |
789 | struct usbhs_priv *priv; | 897 | struct usbhs_priv *priv = usbhsg_gpriv_to_priv(gpriv); |
790 | struct device *dev; | ||
791 | 898 | ||
792 | if (!driver || | 899 | if (!driver || |
793 | !driver->unbind) | 900 | !driver->unbind) |
794 | return -EINVAL; | 901 | return -EINVAL; |
795 | 902 | ||
796 | dev = usbhsg_gpriv_to_dev(gpriv); | ||
797 | priv = usbhsg_gpriv_to_priv(gpriv); | ||
798 | |||
799 | usbhsg_try_stop(priv, USBHSG_STATUS_REGISTERD); | 903 | usbhsg_try_stop(priv, USBHSG_STATUS_REGISTERD); |
800 | device_del(&gpriv->gadget.dev); | 904 | gpriv->gadget.dev.driver = NULL; |
801 | gpriv->driver = NULL; | 905 | gpriv->driver = NULL; |
802 | 906 | ||
803 | return 0; | 907 | return 0; |
@@ -827,10 +931,17 @@ static int usbhsg_start(struct usbhs_priv *priv) | |||
827 | 931 | ||
828 | static int usbhsg_stop(struct usbhs_priv *priv) | 932 | static int usbhsg_stop(struct usbhs_priv *priv) |
829 | { | 933 | { |
934 | struct usbhsg_gpriv *gpriv = usbhsg_priv_to_gpriv(priv); | ||
935 | |||
936 | /* cable disconnect */ | ||
937 | if (gpriv->driver && | ||
938 | gpriv->driver->disconnect) | ||
939 | gpriv->driver->disconnect(&gpriv->gadget); | ||
940 | |||
830 | return usbhsg_try_stop(priv, USBHSG_STATUS_STARTED); | 941 | return usbhsg_try_stop(priv, USBHSG_STATUS_STARTED); |
831 | } | 942 | } |
832 | 943 | ||
833 | int __devinit usbhs_mod_gadget_probe(struct usbhs_priv *priv) | 944 | int usbhs_mod_gadget_probe(struct usbhs_priv *priv) |
834 | { | 945 | { |
835 | struct usbhsg_gpriv *gpriv; | 946 | struct usbhsg_gpriv *gpriv; |
836 | struct usbhsg_uep *uep; | 947 | struct usbhsg_uep *uep; |
@@ -876,12 +987,14 @@ int __devinit usbhs_mod_gadget_probe(struct usbhs_priv *priv) | |||
876 | /* | 987 | /* |
877 | * init gadget | 988 | * init gadget |
878 | */ | 989 | */ |
879 | device_initialize(&gpriv->gadget.dev); | ||
880 | dev_set_name(&gpriv->gadget.dev, "gadget"); | 990 | dev_set_name(&gpriv->gadget.dev, "gadget"); |
881 | gpriv->gadget.dev.parent = dev; | 991 | gpriv->gadget.dev.parent = dev; |
882 | gpriv->gadget.name = "renesas_usbhs_udc"; | 992 | gpriv->gadget.name = "renesas_usbhs_udc"; |
883 | gpriv->gadget.ops = &usbhsg_gadget_ops; | 993 | gpriv->gadget.ops = &usbhsg_gadget_ops; |
884 | gpriv->gadget.is_dualspeed = 1; | 994 | gpriv->gadget.max_speed = USB_SPEED_HIGH; |
995 | ret = device_register(&gpriv->gadget.dev); | ||
996 | if (ret < 0) | ||
997 | goto err_add_udc; | ||
885 | 998 | ||
886 | INIT_LIST_HEAD(&gpriv->gadget.ep_list); | 999 | INIT_LIST_HEAD(&gpriv->gadget.ep_list); |
887 | 1000 | ||
@@ -908,16 +1021,17 @@ int __devinit usbhs_mod_gadget_probe(struct usbhs_priv *priv) | |||
908 | } | 1021 | } |
909 | } | 1022 | } |
910 | 1023 | ||
911 | usbhsg_controller_register(gpriv); | ||
912 | |||
913 | ret = usb_add_gadget_udc(dev, &gpriv->gadget); | 1024 | ret = usb_add_gadget_udc(dev, &gpriv->gadget); |
914 | if (ret) | 1025 | if (ret) |
915 | goto err_add_udc; | 1026 | goto err_register; |
916 | 1027 | ||
917 | 1028 | ||
918 | dev_info(dev, "gadget probed\n"); | 1029 | dev_info(dev, "gadget probed\n"); |
919 | 1030 | ||
920 | return 0; | 1031 | return 0; |
1032 | |||
1033 | err_register: | ||
1034 | device_unregister(&gpriv->gadget.dev); | ||
921 | err_add_udc: | 1035 | err_add_udc: |
922 | kfree(gpriv->uep); | 1036 | kfree(gpriv->uep); |
923 | 1037 | ||
@@ -927,13 +1041,13 @@ usbhs_mod_gadget_probe_err_gpriv: | |||
927 | return ret; | 1041 | return ret; |
928 | } | 1042 | } |
929 | 1043 | ||
930 | void __devexit usbhs_mod_gadget_remove(struct usbhs_priv *priv) | 1044 | void usbhs_mod_gadget_remove(struct usbhs_priv *priv) |
931 | { | 1045 | { |
932 | struct usbhsg_gpriv *gpriv = usbhsg_priv_to_gpriv(priv); | 1046 | struct usbhsg_gpriv *gpriv = usbhsg_priv_to_gpriv(priv); |
933 | 1047 | ||
934 | usb_del_gadget_udc(&gpriv->gadget); | 1048 | usb_del_gadget_udc(&gpriv->gadget); |
935 | 1049 | ||
936 | usbhsg_controller_unregister(gpriv); | 1050 | device_unregister(&gpriv->gadget.dev); |
937 | 1051 | ||
938 | kfree(gpriv->uep); | 1052 | kfree(gpriv->uep); |
939 | kfree(gpriv); | 1053 | kfree(gpriv); |
diff --git a/drivers/usb/renesas_usbhs/mod_host.c b/drivers/usb/renesas_usbhs/mod_host.c index 1a7208a50afc..1834cf50888c 100644 --- a/drivers/usb/renesas_usbhs/mod_host.c +++ b/drivers/usb/renesas_usbhs/mod_host.c | |||
@@ -45,36 +45,34 @@ | |||
45 | * | 45 | * |
46 | * +--------+ pipes are reused for each uep. | 46 | * +--------+ pipes are reused for each uep. |
47 | * | udev 1 |-+- [uep 0 (dcp) ] --+ pipe will be switched when | 47 | * | udev 1 |-+- [uep 0 (dcp) ] --+ pipe will be switched when |
48 | * +--------+ | | target device was changed | 48 | * +--------+ | | other device requested |
49 | * +- [uep 1 (bulk)] --|---+ +--------------+ | 49 | * +- [uep 1 (bulk)] --|---+ +--------------+ |
50 | * | +--------------> | pipe0 (dcp) | | 50 | * | +--------------> | pipe0 (dcp) | |
51 | * +- [uep 2 (bulk)] --|---|---+ +--------------+ | 51 | * +- [uep 2 (bulk)] -@ | +--------------+ |
52 | * | | | | pipe1 (isoc) | | 52 | * | | pipe1 (isoc) | |
53 | * +--------+ | | | +--------------+ | 53 | * +--------+ | +--------------+ |
54 | * | udev 2 |-+- [uep 0 (dcp) ] --+ +-- |------> | pipe2 (bulk) | | 54 | * | udev 2 |-+- [uep 0 (dcp) ] -@ +----------> | pipe2 (bulk) | |
55 | * +--------+ | | | | +--------------+ | 55 | * +--------+ | +--------------+ |
56 | * +- [uep 1 (int) ] --|-+ | +------> | pipe3 (bulk) | | 56 | * +- [uep 1 (int) ] ----+ +------> | pipe3 (bulk) | |
57 | * | | | | +--------------+ | 57 | * | | +--------------+ |
58 | * +--------+ | +-|---|------> | pipe4 (int) | | 58 | * +--------+ +-----|------> | pipe4 (int) | |
59 | * | udev 3 |-+- [uep 0 (dcp) ] --+ | | +--------------+ | 59 | * | udev 3 |-+- [uep 0 (dcp) ] -@ | +--------------+ |
60 | * +--------+ | | | | .... | | 60 | * +--------+ | | | .... | |
61 | * +- [uep 1 (bulk)] ------+ | | .... | | 61 | * +- [uep 1 (bulk)] -@ | | .... | |
62 | * | | | 62 | * | | |
63 | * +- [uep 2 (bulk)]-----------+ | 63 | * +- [uep 2 (bulk)]-----------+ |
64 | * | ||
65 | * @ : uep requested free pipe, but all have been used. | ||
66 | * now it is waiting for free pipe | ||
64 | */ | 67 | */ |
65 | 68 | ||
66 | 69 | ||
67 | /* | 70 | /* |
68 | * struct | 71 | * struct |
69 | */ | 72 | */ |
70 | struct usbhsh_pipe_info { | ||
71 | unsigned int usr_cnt; /* see usbhsh_endpoint_alloc() */ | ||
72 | }; | ||
73 | |||
74 | struct usbhsh_request { | 73 | struct usbhsh_request { |
75 | struct urb *urb; | 74 | struct urb *urb; |
76 | struct usbhs_pkt pkt; | 75 | struct usbhs_pkt pkt; |
77 | struct list_head ureq_link; /* see hpriv :: ureq_link_xxx */ | ||
78 | }; | 76 | }; |
79 | 77 | ||
80 | struct usbhsh_device { | 78 | struct usbhsh_device { |
@@ -83,11 +81,10 @@ struct usbhsh_device { | |||
83 | }; | 81 | }; |
84 | 82 | ||
85 | struct usbhsh_ep { | 83 | struct usbhsh_ep { |
86 | struct usbhs_pipe *pipe; | 84 | struct usbhs_pipe *pipe; /* attached pipe */ |
87 | struct usbhsh_device *udev; /* attached udev */ | 85 | struct usbhsh_device *udev; /* attached udev */ |
86 | struct usb_host_endpoint *ep; | ||
88 | struct list_head ep_list; /* list to usbhsh_device */ | 87 | struct list_head ep_list; /* list to usbhsh_device */ |
89 | |||
90 | int maxp; | ||
91 | }; | 88 | }; |
92 | 89 | ||
93 | #define USBHSH_DEVICE_MAX 10 /* see DEVADDn / DCPMAXP / PIPEMAXP */ | 90 | #define USBHSH_DEVICE_MAX 10 /* see DEVADDn / DCPMAXP / PIPEMAXP */ |
@@ -98,16 +95,9 @@ struct usbhsh_hpriv { | |||
98 | 95 | ||
99 | struct usbhsh_device udev[USBHSH_DEVICE_MAX]; | 96 | struct usbhsh_device udev[USBHSH_DEVICE_MAX]; |
100 | 97 | ||
101 | struct usbhsh_pipe_info *pipe_info; | ||
102 | int pipe_size; | ||
103 | |||
104 | u32 port_stat; /* USB_PORT_STAT_xxx */ | 98 | u32 port_stat; /* USB_PORT_STAT_xxx */ |
105 | 99 | ||
106 | struct completion *done; | 100 | struct completion setup_ack_done; |
107 | |||
108 | /* see usbhsh_req_alloc/free */ | ||
109 | struct list_head ureq_link_active; | ||
110 | struct list_head ureq_link_free; | ||
111 | }; | 101 | }; |
112 | 102 | ||
113 | 103 | ||
@@ -119,17 +109,6 @@ static const char usbhsh_hcd_name[] = "renesas_usbhs host"; | |||
119 | #define usbhsh_priv_to_hpriv(priv) \ | 109 | #define usbhsh_priv_to_hpriv(priv) \ |
120 | container_of(usbhs_mod_get(priv, USBHS_HOST), struct usbhsh_hpriv, mod) | 110 | container_of(usbhs_mod_get(priv, USBHS_HOST), struct usbhsh_hpriv, mod) |
121 | 111 | ||
122 | #define __usbhsh_for_each_hpipe(start, pos, h, i) \ | ||
123 | for (i = start, pos = (h)->hpipe + i; \ | ||
124 | i < (h)->hpipe_size; \ | ||
125 | i++, pos = (h)->hpipe + i) | ||
126 | |||
127 | #define usbhsh_for_each_hpipe(pos, hpriv, i) \ | ||
128 | __usbhsh_for_each_hpipe(1, pos, hpriv, i) | ||
129 | |||
130 | #define usbhsh_for_each_hpipe_with_dcp(pos, hpriv, i) \ | ||
131 | __usbhsh_for_each_hpipe(0, pos, hpriv, i) | ||
132 | |||
133 | #define __usbhsh_for_each_udev(start, pos, h, i) \ | 112 | #define __usbhsh_for_each_udev(start, pos, h, i) \ |
134 | for (i = start, pos = (h)->udev + i; \ | 113 | for (i = start, pos = (h)->udev + i; \ |
135 | i < USBHSH_DEVICE_MAX; \ | 114 | i < USBHSH_DEVICE_MAX; \ |
@@ -152,15 +131,20 @@ static const char usbhsh_hcd_name[] = "renesas_usbhs host"; | |||
152 | #define usbhsh_ep_to_uep(u) ((u)->hcpriv) | 131 | #define usbhsh_ep_to_uep(u) ((u)->hcpriv) |
153 | #define usbhsh_uep_to_pipe(u) ((u)->pipe) | 132 | #define usbhsh_uep_to_pipe(u) ((u)->pipe) |
154 | #define usbhsh_uep_to_udev(u) ((u)->udev) | 133 | #define usbhsh_uep_to_udev(u) ((u)->udev) |
134 | #define usbhsh_uep_to_ep(u) ((u)->ep) | ||
135 | |||
155 | #define usbhsh_urb_to_ureq(u) ((u)->hcpriv) | 136 | #define usbhsh_urb_to_ureq(u) ((u)->hcpriv) |
156 | #define usbhsh_urb_to_usbv(u) ((u)->dev) | 137 | #define usbhsh_urb_to_usbv(u) ((u)->dev) |
157 | 138 | ||
158 | #define usbhsh_usbv_to_udev(d) dev_get_drvdata(&(d)->dev) | 139 | #define usbhsh_usbv_to_udev(d) dev_get_drvdata(&(d)->dev) |
159 | 140 | ||
160 | #define usbhsh_udev_to_usbv(h) ((h)->usbv) | 141 | #define usbhsh_udev_to_usbv(h) ((h)->usbv) |
142 | #define usbhsh_udev_is_used(h) usbhsh_udev_to_usbv(h) | ||
161 | 143 | ||
162 | #define usbhsh_pipe_info(p) ((p)->mod_private) | 144 | #define usbhsh_pipe_to_uep(p) ((p)->mod_private) |
163 | 145 | ||
146 | #define usbhsh_device_parent(d) (usbhsh_usbv_to_udev((d)->usbv->parent)) | ||
147 | #define usbhsh_device_hubport(d) ((d)->usbv->portnum) | ||
164 | #define usbhsh_device_number(h, d) ((int)((d) - (h)->udev)) | 148 | #define usbhsh_device_number(h, d) ((int)((d) - (h)->udev)) |
165 | #define usbhsh_device_nth(h, d) ((h)->udev + d) | 149 | #define usbhsh_device_nth(h, d) ((h)->udev + d) |
166 | #define usbhsh_device0(h) usbhsh_device_nth(h, 0) | 150 | #define usbhsh_device0(h) usbhsh_device_nth(h, 0) |
@@ -170,156 +154,428 @@ static const char usbhsh_hcd_name[] = "renesas_usbhs host"; | |||
170 | #define usbhsh_port_stat_clear(h, s) ((h)->port_stat &= ~(s)) | 154 | #define usbhsh_port_stat_clear(h, s) ((h)->port_stat &= ~(s)) |
171 | #define usbhsh_port_stat_get(h) ((h)->port_stat) | 155 | #define usbhsh_port_stat_get(h) ((h)->port_stat) |
172 | 156 | ||
173 | #define usbhsh_pkt_to_req(p) \ | 157 | #define usbhsh_pkt_to_ureq(p) \ |
174 | container_of((void *)p, struct usbhsh_request, pkt) | 158 | container_of((void *)p, struct usbhsh_request, pkt) |
175 | 159 | ||
176 | /* | 160 | /* |
177 | * req alloc/free | 161 | * req alloc/free |
178 | */ | 162 | */ |
179 | static void usbhsh_req_list_init(struct usbhsh_hpriv *hpriv) | 163 | static struct usbhsh_request *usbhsh_ureq_alloc(struct usbhsh_hpriv *hpriv, |
164 | struct urb *urb, | ||
165 | gfp_t mem_flags) | ||
180 | { | 166 | { |
181 | INIT_LIST_HEAD(&hpriv->ureq_link_active); | 167 | struct usbhsh_request *ureq; |
182 | INIT_LIST_HEAD(&hpriv->ureq_link_free); | 168 | struct usbhs_priv *priv = usbhsh_hpriv_to_priv(hpriv); |
169 | struct device *dev = usbhs_priv_to_dev(priv); | ||
170 | |||
171 | ureq = kzalloc(sizeof(struct usbhsh_request), mem_flags); | ||
172 | if (!ureq) { | ||
173 | dev_err(dev, "ureq alloc fail\n"); | ||
174 | return NULL; | ||
175 | } | ||
176 | |||
177 | usbhs_pkt_init(&ureq->pkt); | ||
178 | ureq->urb = urb; | ||
179 | usbhsh_urb_to_ureq(urb) = ureq; | ||
180 | |||
181 | return ureq; | ||
183 | } | 182 | } |
184 | 183 | ||
185 | static void usbhsh_req_list_quit(struct usbhsh_hpriv *hpriv) | 184 | static void usbhsh_ureq_free(struct usbhsh_hpriv *hpriv, |
185 | struct usbhsh_request *ureq) | ||
186 | { | 186 | { |
187 | struct usb_hcd *hcd = usbhsh_hpriv_to_hcd(hpriv); | 187 | usbhsh_urb_to_ureq(ureq->urb) = NULL; |
188 | struct device *dev = usbhsh_hcd_to_dev(hcd); | 188 | ureq->urb = NULL; |
189 | struct usbhsh_request *ureq, *next; | ||
190 | |||
191 | /* kfree all active ureq */ | ||
192 | list_for_each_entry_safe(ureq, next, | ||
193 | &hpriv->ureq_link_active, | ||
194 | ureq_link) { | ||
195 | dev_err(dev, "active ureq (%p) is force freed\n", ureq); | ||
196 | kfree(ureq); | ||
197 | } | ||
198 | 189 | ||
199 | /* kfree all free ureq */ | 190 | kfree(ureq); |
200 | list_for_each_entry_safe(ureq, next, &hpriv->ureq_link_free, ureq_link) | ||
201 | kfree(ureq); | ||
202 | } | 191 | } |
203 | 192 | ||
204 | static struct usbhsh_request *usbhsh_req_alloc(struct usbhsh_hpriv *hpriv, | 193 | /* |
205 | struct urb *urb, | 194 | * status |
206 | gfp_t mem_flags) | 195 | */ |
196 | static int usbhsh_is_running(struct usbhsh_hpriv *hpriv) | ||
197 | { | ||
198 | /* | ||
199 | * we can decide some device is attached or not | ||
200 | * by checking mod.irq_attch | ||
201 | * see | ||
202 | * usbhsh_irq_attch() | ||
203 | * usbhsh_irq_dtch() | ||
204 | */ | ||
205 | return (hpriv->mod.irq_attch == NULL); | ||
206 | } | ||
207 | |||
208 | /* | ||
209 | * pipe control | ||
210 | */ | ||
211 | static void usbhsh_endpoint_sequence_save(struct usbhsh_hpriv *hpriv, | ||
212 | struct urb *urb, | ||
213 | struct usbhs_pkt *pkt) | ||
214 | { | ||
215 | int len = urb->actual_length; | ||
216 | int maxp = usb_endpoint_maxp(&urb->ep->desc); | ||
217 | int t = 0; | ||
218 | |||
219 | /* DCP is out of sequence control */ | ||
220 | if (usb_pipecontrol(urb->pipe)) | ||
221 | return; | ||
222 | |||
223 | /* | ||
224 | * renesas_usbhs pipe has a limitation in a number. | ||
225 | * So, driver should re-use the limited pipe for each device/endpoint. | ||
226 | * DATA0/1 sequence should be saved for it. | ||
227 | * see [image of mod_host] | ||
228 | * [HARDWARE LIMITATION] | ||
229 | */ | ||
230 | |||
231 | /* | ||
232 | * next sequence depends on actual_length | ||
233 | * | ||
234 | * ex) actual_length = 1147, maxp = 512 | ||
235 | * data0 : 512 | ||
236 | * data1 : 512 | ||
237 | * data0 : 123 | ||
238 | * data1 is the next sequence | ||
239 | */ | ||
240 | t = len / maxp; | ||
241 | if (len % maxp) | ||
242 | t++; | ||
243 | if (pkt->zero) | ||
244 | t++; | ||
245 | t %= 2; | ||
246 | |||
247 | if (t) | ||
248 | usb_dotoggle(urb->dev, | ||
249 | usb_pipeendpoint(urb->pipe), | ||
250 | usb_pipeout(urb->pipe)); | ||
251 | } | ||
252 | |||
253 | static struct usbhsh_device *usbhsh_device_get(struct usbhsh_hpriv *hpriv, | ||
254 | struct urb *urb); | ||
255 | |||
256 | static int usbhsh_pipe_attach(struct usbhsh_hpriv *hpriv, | ||
257 | struct urb *urb) | ||
207 | { | 258 | { |
208 | struct usbhsh_request *ureq; | ||
209 | struct usbhs_priv *priv = usbhsh_hpriv_to_priv(hpriv); | 259 | struct usbhs_priv *priv = usbhsh_hpriv_to_priv(hpriv); |
260 | struct usbhsh_ep *uep = usbhsh_ep_to_uep(urb->ep); | ||
261 | struct usbhsh_device *udev = usbhsh_device_get(hpriv, urb); | ||
262 | struct usbhs_pipe *pipe; | ||
263 | struct usb_endpoint_descriptor *desc = &urb->ep->desc; | ||
210 | struct device *dev = usbhs_priv_to_dev(priv); | 264 | struct device *dev = usbhs_priv_to_dev(priv); |
265 | unsigned long flags; | ||
266 | int dir_in_req = !!usb_pipein(urb->pipe); | ||
267 | int is_dcp = usb_endpoint_xfer_control(desc); | ||
268 | int i, dir_in; | ||
269 | int ret = -EBUSY; | ||
270 | |||
271 | /******************** spin lock ********************/ | ||
272 | usbhs_lock(priv, flags); | ||
273 | |||
274 | if (unlikely(usbhsh_uep_to_pipe(uep))) { | ||
275 | dev_err(dev, "uep already has pipe\n"); | ||
276 | goto usbhsh_pipe_attach_done; | ||
277 | } | ||
278 | |||
279 | usbhs_for_each_pipe_with_dcp(pipe, priv, i) { | ||
280 | |||
281 | /* check pipe type */ | ||
282 | if (!usbhs_pipe_type_is(pipe, usb_endpoint_type(desc))) | ||
283 | continue; | ||
284 | |||
285 | /* check pipe direction if normal pipe */ | ||
286 | if (!is_dcp) { | ||
287 | dir_in = !!usbhs_pipe_is_dir_in(pipe); | ||
288 | if (0 != (dir_in - dir_in_req)) | ||
289 | continue; | ||
290 | } | ||
291 | |||
292 | /* check pipe is free */ | ||
293 | if (usbhsh_pipe_to_uep(pipe)) | ||
294 | continue; | ||
211 | 295 | ||
212 | if (list_empty(&hpriv->ureq_link_free)) { | ||
213 | /* | 296 | /* |
214 | * create new one if there is no free ureq | 297 | * attach pipe to uep |
298 | * | ||
299 | * usbhs_pipe_config_update() should be called after | ||
300 | * usbhs_set_device_config() | ||
301 | * see | ||
302 | * DCPMAXP/PIPEMAXP | ||
215 | */ | 303 | */ |
216 | ureq = kzalloc(sizeof(struct usbhsh_request), mem_flags); | 304 | usbhsh_uep_to_pipe(uep) = pipe; |
217 | if (ureq) | 305 | usbhsh_pipe_to_uep(pipe) = uep; |
218 | INIT_LIST_HEAD(&ureq->ureq_link); | 306 | |
307 | usbhs_pipe_config_update(pipe, | ||
308 | usbhsh_device_number(hpriv, udev), | ||
309 | usb_endpoint_num(desc), | ||
310 | usb_endpoint_maxp(desc)); | ||
311 | |||
312 | dev_dbg(dev, "%s [%d-%d(%s:%s)]\n", __func__, | ||
313 | usbhsh_device_number(hpriv, udev), | ||
314 | usb_endpoint_num(desc), | ||
315 | usbhs_pipe_name(pipe), | ||
316 | dir_in_req ? "in" : "out"); | ||
317 | |||
318 | ret = 0; | ||
319 | break; | ||
320 | } | ||
321 | |||
322 | usbhsh_pipe_attach_done: | ||
323 | usbhs_unlock(priv, flags); | ||
324 | /******************** spin unlock ******************/ | ||
325 | |||
326 | return ret; | ||
327 | } | ||
328 | |||
329 | static void usbhsh_pipe_detach(struct usbhsh_hpriv *hpriv, | ||
330 | struct usbhsh_ep *uep) | ||
331 | { | ||
332 | struct usbhs_priv *priv = usbhsh_hpriv_to_priv(hpriv); | ||
333 | struct usbhs_pipe *pipe; | ||
334 | struct device *dev = usbhs_priv_to_dev(priv); | ||
335 | unsigned long flags; | ||
336 | |||
337 | /******************** spin lock ********************/ | ||
338 | usbhs_lock(priv, flags); | ||
339 | |||
340 | pipe = usbhsh_uep_to_pipe(uep); | ||
341 | |||
342 | if (unlikely(!pipe)) { | ||
343 | dev_err(dev, "uep doens't have pipe\n"); | ||
219 | } else { | 344 | } else { |
220 | /* | 345 | struct usb_host_endpoint *ep = usbhsh_uep_to_ep(uep); |
221 | * reuse "free" ureq if exist | 346 | struct usbhsh_device *udev = usbhsh_uep_to_udev(uep); |
222 | */ | 347 | |
223 | ureq = list_entry(hpriv->ureq_link_free.next, | 348 | /* detach pipe from uep */ |
224 | struct usbhsh_request, | 349 | usbhsh_uep_to_pipe(uep) = NULL; |
225 | ureq_link); | 350 | usbhsh_pipe_to_uep(pipe) = NULL; |
226 | if (ureq) | 351 | |
227 | list_del_init(&ureq->ureq_link); | 352 | dev_dbg(dev, "%s [%d-%d(%s)]\n", __func__, |
353 | usbhsh_device_number(hpriv, udev), | ||
354 | usb_endpoint_num(&ep->desc), | ||
355 | usbhs_pipe_name(pipe)); | ||
228 | } | 356 | } |
229 | 357 | ||
230 | if (!ureq) { | 358 | usbhs_unlock(priv, flags); |
231 | dev_err(dev, "ureq alloc fail\n"); | 359 | /******************** spin unlock ******************/ |
232 | return NULL; | 360 | } |
361 | |||
362 | /* | ||
363 | * endpoint control | ||
364 | */ | ||
365 | static int usbhsh_endpoint_attach(struct usbhsh_hpriv *hpriv, | ||
366 | struct urb *urb, | ||
367 | gfp_t mem_flags) | ||
368 | { | ||
369 | struct usbhs_priv *priv = usbhsh_hpriv_to_priv(hpriv); | ||
370 | struct usbhsh_device *udev = usbhsh_device_get(hpriv, urb); | ||
371 | struct usb_host_endpoint *ep = urb->ep; | ||
372 | struct usbhsh_ep *uep; | ||
373 | struct device *dev = usbhs_priv_to_dev(priv); | ||
374 | struct usb_endpoint_descriptor *desc = &ep->desc; | ||
375 | unsigned long flags; | ||
376 | |||
377 | uep = kzalloc(sizeof(struct usbhsh_ep), mem_flags); | ||
378 | if (!uep) { | ||
379 | dev_err(dev, "usbhsh_ep alloc fail\n"); | ||
380 | return -ENOMEM; | ||
233 | } | 381 | } |
234 | 382 | ||
235 | usbhs_pkt_init(&ureq->pkt); | 383 | /******************** spin lock ********************/ |
384 | usbhs_lock(priv, flags); | ||
236 | 385 | ||
237 | /* | 386 | /* |
238 | * push it to "active" list | 387 | * init endpoint |
239 | */ | 388 | */ |
240 | list_add_tail(&ureq->ureq_link, &hpriv->ureq_link_active); | 389 | INIT_LIST_HEAD(&uep->ep_list); |
241 | ureq->urb = urb; | 390 | list_add_tail(&uep->ep_list, &udev->ep_list_head); |
242 | 391 | ||
243 | return ureq; | 392 | usbhsh_uep_to_udev(uep) = udev; |
393 | usbhsh_uep_to_ep(uep) = ep; | ||
394 | usbhsh_ep_to_uep(ep) = uep; | ||
395 | |||
396 | usbhs_unlock(priv, flags); | ||
397 | /******************** spin unlock ******************/ | ||
398 | |||
399 | dev_dbg(dev, "%s [%d-%d]\n", __func__, | ||
400 | usbhsh_device_number(hpriv, udev), | ||
401 | usb_endpoint_num(desc)); | ||
402 | |||
403 | return 0; | ||
244 | } | 404 | } |
245 | 405 | ||
246 | static void usbhsh_req_free(struct usbhsh_hpriv *hpriv, | 406 | static void usbhsh_endpoint_detach(struct usbhsh_hpriv *hpriv, |
247 | struct usbhsh_request *ureq) | 407 | struct usb_host_endpoint *ep) |
248 | { | 408 | { |
249 | struct usbhs_pkt *pkt = &ureq->pkt; | 409 | struct usbhs_priv *priv = usbhsh_hpriv_to_priv(hpriv); |
410 | struct device *dev = usbhs_priv_to_dev(priv); | ||
411 | struct usbhsh_ep *uep = usbhsh_ep_to_uep(ep); | ||
412 | unsigned long flags; | ||
250 | 413 | ||
251 | usbhs_pkt_init(pkt); | 414 | if (!uep) |
415 | return; | ||
252 | 416 | ||
253 | /* | 417 | dev_dbg(dev, "%s [%d-%d]\n", __func__, |
254 | * removed from "active" list, | 418 | usbhsh_device_number(hpriv, usbhsh_uep_to_udev(uep)), |
255 | * and push it to "free" list | 419 | usb_endpoint_num(&ep->desc)); |
256 | */ | 420 | |
257 | ureq->urb = NULL; | 421 | if (usbhsh_uep_to_pipe(uep)) |
258 | list_del_init(&ureq->ureq_link); | 422 | usbhsh_pipe_detach(hpriv, uep); |
259 | list_add_tail(&ureq->ureq_link, &hpriv->ureq_link_free); | 423 | |
424 | /******************** spin lock ********************/ | ||
425 | usbhs_lock(priv, flags); | ||
426 | |||
427 | /* remove this endpoint from udev */ | ||
428 | list_del_init(&uep->ep_list); | ||
429 | |||
430 | usbhsh_uep_to_udev(uep) = NULL; | ||
431 | usbhsh_uep_to_ep(uep) = NULL; | ||
432 | usbhsh_ep_to_uep(ep) = NULL; | ||
433 | |||
434 | usbhs_unlock(priv, flags); | ||
435 | /******************** spin unlock ******************/ | ||
436 | |||
437 | kfree(uep); | ||
438 | } | ||
439 | |||
440 | static void usbhsh_endpoint_detach_all(struct usbhsh_hpriv *hpriv, | ||
441 | struct usbhsh_device *udev) | ||
442 | { | ||
443 | struct usbhsh_ep *uep, *next; | ||
444 | |||
445 | list_for_each_entry_safe(uep, next, &udev->ep_list_head, ep_list) | ||
446 | usbhsh_endpoint_detach(hpriv, usbhsh_uep_to_ep(uep)); | ||
260 | } | 447 | } |
261 | 448 | ||
262 | /* | 449 | /* |
263 | * device control | 450 | * device control |
264 | */ | 451 | */ |
452 | static int usbhsh_connected_to_rhdev(struct usb_hcd *hcd, | ||
453 | struct usbhsh_device *udev) | ||
454 | { | ||
455 | struct usb_device *usbv = usbhsh_udev_to_usbv(udev); | ||
456 | |||
457 | return hcd->self.root_hub == usbv->parent; | ||
458 | } | ||
265 | 459 | ||
266 | static int usbhsh_device_has_endpoint(struct usbhsh_device *udev) | 460 | static int usbhsh_device_has_endpoint(struct usbhsh_device *udev) |
267 | { | 461 | { |
268 | return !list_empty(&udev->ep_list_head); | 462 | return !list_empty(&udev->ep_list_head); |
269 | } | 463 | } |
270 | 464 | ||
271 | static struct usbhsh_device *usbhsh_device_alloc(struct usbhsh_hpriv *hpriv, | 465 | static struct usbhsh_device *usbhsh_device_get(struct usbhsh_hpriv *hpriv, |
466 | struct urb *urb) | ||
467 | { | ||
468 | struct usb_device *usbv = usbhsh_urb_to_usbv(urb); | ||
469 | struct usbhsh_device *udev = usbhsh_usbv_to_udev(usbv); | ||
470 | |||
471 | /* usbhsh_device_attach() is still not called */ | ||
472 | if (!udev) | ||
473 | return NULL; | ||
474 | |||
475 | /* if it is device0, return it */ | ||
476 | if (0 == usb_pipedevice(urb->pipe)) | ||
477 | return usbhsh_device0(hpriv); | ||
478 | |||
479 | /* return attached device */ | ||
480 | return udev; | ||
481 | } | ||
482 | |||
483 | static struct usbhsh_device *usbhsh_device_attach(struct usbhsh_hpriv *hpriv, | ||
272 | struct urb *urb) | 484 | struct urb *urb) |
273 | { | 485 | { |
274 | struct usbhsh_device *udev = NULL; | 486 | struct usbhsh_device *udev = NULL; |
487 | struct usbhsh_device *udev0 = usbhsh_device0(hpriv); | ||
488 | struct usbhsh_device *pos; | ||
275 | struct usb_hcd *hcd = usbhsh_hpriv_to_hcd(hpriv); | 489 | struct usb_hcd *hcd = usbhsh_hpriv_to_hcd(hpriv); |
276 | struct device *dev = usbhsh_hcd_to_dev(hcd); | 490 | struct device *dev = usbhsh_hcd_to_dev(hcd); |
277 | struct usb_device *usbv = usbhsh_urb_to_usbv(urb); | 491 | struct usb_device *usbv = usbhsh_urb_to_usbv(urb); |
278 | struct usbhs_priv *priv = usbhsh_hpriv_to_priv(hpriv); | 492 | struct usbhs_priv *priv = usbhsh_hpriv_to_priv(hpriv); |
493 | unsigned long flags; | ||
494 | u16 upphub, hubport; | ||
279 | int i; | 495 | int i; |
280 | 496 | ||
281 | /* | 497 | /* |
282 | * device 0 | 498 | * This function should be called only while urb is pointing to device0. |
499 | * It will attach unused usbhsh_device to urb (usbv), | ||
500 | * and initialize device0. | ||
501 | * You can use usbhsh_device_get() to get "current" udev, | ||
502 | * and usbhsh_usbv_to_udev() is for "attached" udev. | ||
283 | */ | 503 | */ |
284 | if (0 == usb_pipedevice(urb->pipe)) { | 504 | if (0 != usb_pipedevice(urb->pipe)) { |
285 | udev = usbhsh_device0(hpriv); | 505 | dev_err(dev, "%s fail: urb isn't pointing device0\n", __func__); |
286 | goto usbhsh_device_find; | 506 | return NULL; |
287 | } | 507 | } |
288 | 508 | ||
509 | /******************** spin lock ********************/ | ||
510 | usbhs_lock(priv, flags); | ||
511 | |||
289 | /* | 512 | /* |
290 | * find unused device | 513 | * find unused device |
291 | */ | 514 | */ |
292 | usbhsh_for_each_udev(udev, hpriv, i) { | 515 | usbhsh_for_each_udev(pos, hpriv, i) { |
293 | if (usbhsh_udev_to_usbv(udev)) | 516 | if (usbhsh_udev_is_used(pos)) |
294 | continue; | 517 | continue; |
295 | goto usbhsh_device_find; | 518 | udev = pos; |
519 | break; | ||
520 | } | ||
521 | |||
522 | if (udev) { | ||
523 | /* | ||
524 | * usbhsh_usbv_to_udev() | ||
525 | * usbhsh_udev_to_usbv() | ||
526 | * will be enable | ||
527 | */ | ||
528 | dev_set_drvdata(&usbv->dev, udev); | ||
529 | udev->usbv = usbv; | ||
296 | } | 530 | } |
297 | 531 | ||
298 | dev_err(dev, "no free usbhsh_device\n"); | 532 | usbhs_unlock(priv, flags); |
533 | /******************** spin unlock ******************/ | ||
299 | 534 | ||
300 | return NULL; | 535 | if (!udev) { |
536 | dev_err(dev, "no free usbhsh_device\n"); | ||
537 | return NULL; | ||
538 | } | ||
301 | 539 | ||
302 | usbhsh_device_find: | 540 | if (usbhsh_device_has_endpoint(udev)) { |
303 | if (usbhsh_device_has_endpoint(udev)) | ||
304 | dev_warn(dev, "udev have old endpoint\n"); | 541 | dev_warn(dev, "udev have old endpoint\n"); |
542 | usbhsh_endpoint_detach_all(hpriv, udev); | ||
543 | } | ||
544 | |||
545 | if (usbhsh_device_has_endpoint(udev0)) { | ||
546 | dev_warn(dev, "udev0 have old endpoint\n"); | ||
547 | usbhsh_endpoint_detach_all(hpriv, udev0); | ||
548 | } | ||
305 | 549 | ||
306 | /* uep will be attached */ | 550 | /* uep will be attached */ |
551 | INIT_LIST_HEAD(&udev0->ep_list_head); | ||
307 | INIT_LIST_HEAD(&udev->ep_list_head); | 552 | INIT_LIST_HEAD(&udev->ep_list_head); |
308 | 553 | ||
309 | /* | 554 | /* |
310 | * usbhsh_usbv_to_udev() | 555 | * set device0 config |
311 | * usbhsh_udev_to_usbv() | ||
312 | * will be enable | ||
313 | */ | 556 | */ |
314 | dev_set_drvdata(&usbv->dev, udev); | 557 | usbhs_set_device_config(priv, |
315 | udev->usbv = usbv; | 558 | 0, 0, 0, usbv->speed); |
316 | 559 | ||
317 | /* set device config */ | 560 | /* |
318 | usbhs_set_device_speed(priv, | 561 | * set new device config |
319 | usbhsh_device_number(hpriv, udev), | 562 | */ |
563 | upphub = 0; | ||
564 | hubport = 0; | ||
565 | if (!usbhsh_connected_to_rhdev(hcd, udev)) { | ||
566 | /* if udev is not connected to rhdev, it means parent is Hub */ | ||
567 | struct usbhsh_device *parent = usbhsh_device_parent(udev); | ||
568 | |||
569 | upphub = usbhsh_device_number(hpriv, parent); | ||
570 | hubport = usbhsh_device_hubport(udev); | ||
571 | |||
572 | dev_dbg(dev, "%s connecte to Hub [%d:%d](%p)\n", __func__, | ||
573 | upphub, hubport, parent); | ||
574 | } | ||
575 | |||
576 | usbhs_set_device_config(priv, | ||
320 | usbhsh_device_number(hpriv, udev), | 577 | usbhsh_device_number(hpriv, udev), |
321 | 0, /* FIXME no parent */ | 578 | upphub, hubport, usbv->speed); |
322 | usbv->speed); | ||
323 | 579 | ||
324 | dev_dbg(dev, "%s [%d](%p)\n", __func__, | 580 | dev_dbg(dev, "%s [%d](%p)\n", __func__, |
325 | usbhsh_device_number(hpriv, udev), udev); | 581 | usbhsh_device_number(hpriv, udev), udev); |
@@ -327,139 +583,45 @@ usbhsh_device_find: | |||
327 | return udev; | 583 | return udev; |
328 | } | 584 | } |
329 | 585 | ||
330 | static void usbhsh_device_free(struct usbhsh_hpriv *hpriv, | 586 | static void usbhsh_device_detach(struct usbhsh_hpriv *hpriv, |
331 | struct usbhsh_device *udev) | 587 | struct usbhsh_device *udev) |
332 | { | 588 | { |
333 | struct usb_hcd *hcd = usbhsh_hpriv_to_hcd(hpriv); | 589 | struct usb_hcd *hcd = usbhsh_hpriv_to_hcd(hpriv); |
590 | struct usbhs_priv *priv = usbhsh_hpriv_to_priv(hpriv); | ||
334 | struct device *dev = usbhsh_hcd_to_dev(hcd); | 591 | struct device *dev = usbhsh_hcd_to_dev(hcd); |
335 | struct usb_device *usbv = usbhsh_udev_to_usbv(udev); | 592 | struct usb_device *usbv = usbhsh_udev_to_usbv(udev); |
593 | unsigned long flags; | ||
336 | 594 | ||
337 | dev_dbg(dev, "%s [%d](%p)\n", __func__, | 595 | dev_dbg(dev, "%s [%d](%p)\n", __func__, |
338 | usbhsh_device_number(hpriv, udev), udev); | 596 | usbhsh_device_number(hpriv, udev), udev); |
339 | 597 | ||
340 | if (usbhsh_device_has_endpoint(udev)) | 598 | if (usbhsh_device_has_endpoint(udev)) { |
341 | dev_warn(dev, "udev still have endpoint\n"); | 599 | dev_warn(dev, "udev still have endpoint\n"); |
342 | 600 | usbhsh_endpoint_detach_all(hpriv, udev); | |
343 | /* | ||
344 | * usbhsh_usbv_to_udev() | ||
345 | * usbhsh_udev_to_usbv() | ||
346 | * will be disable | ||
347 | */ | ||
348 | dev_set_drvdata(&usbv->dev, NULL); | ||
349 | udev->usbv = NULL; | ||
350 | } | ||
351 | |||
352 | /* | ||
353 | * end-point control | ||
354 | */ | ||
355 | struct usbhsh_ep *usbhsh_endpoint_alloc(struct usbhsh_hpriv *hpriv, | ||
356 | struct usbhsh_device *udev, | ||
357 | struct usb_host_endpoint *ep, | ||
358 | gfp_t mem_flags) | ||
359 | { | ||
360 | struct usbhs_priv *priv = usbhsh_hpriv_to_priv(hpriv); | ||
361 | struct usb_hcd *hcd = usbhsh_hpriv_to_hcd(hpriv); | ||
362 | struct usbhsh_ep *uep; | ||
363 | struct usbhsh_pipe_info *info; | ||
364 | struct usbhs_pipe *pipe, *best_pipe; | ||
365 | struct device *dev = usbhsh_hcd_to_dev(hcd); | ||
366 | struct usb_endpoint_descriptor *desc = &ep->desc; | ||
367 | int type, i; | ||
368 | unsigned int min_usr; | ||
369 | |||
370 | uep = kzalloc(sizeof(struct usbhsh_ep), mem_flags); | ||
371 | if (!uep) { | ||
372 | dev_err(dev, "usbhsh_ep alloc fail\n"); | ||
373 | return NULL; | ||
374 | } | 601 | } |
375 | type = usb_endpoint_type(desc); | ||
376 | 602 | ||
377 | /* | 603 | /* |
378 | * find best pipe for endpoint | 604 | * There is nothing to do if it is device0. |
379 | * see | 605 | * see |
380 | * HARDWARE LIMITATION | 606 | * usbhsh_device_attach() |
381 | */ | 607 | * usbhsh_device_get() |
382 | min_usr = ~0; | ||
383 | best_pipe = NULL; | ||
384 | usbhs_for_each_pipe_with_dcp(pipe, priv, i) { | ||
385 | if (!usbhs_pipe_type_is(pipe, type)) | ||
386 | continue; | ||
387 | |||
388 | info = usbhsh_pipe_info(pipe); | ||
389 | |||
390 | if (min_usr > info->usr_cnt) { | ||
391 | min_usr = info->usr_cnt; | ||
392 | best_pipe = pipe; | ||
393 | } | ||
394 | } | ||
395 | |||
396 | if (unlikely(!best_pipe)) { | ||
397 | dev_err(dev, "couldn't find best pipe\n"); | ||
398 | kfree(uep); | ||
399 | return NULL; | ||
400 | } | ||
401 | |||
402 | /* | ||
403 | * init uep | ||
404 | */ | ||
405 | uep->pipe = best_pipe; | ||
406 | uep->maxp = usb_endpoint_maxp(desc); | ||
407 | usbhsh_uep_to_udev(uep) = udev; | ||
408 | usbhsh_ep_to_uep(ep) = uep; | ||
409 | |||
410 | /* | ||
411 | * update pipe user count | ||
412 | */ | 608 | */ |
413 | info = usbhsh_pipe_info(best_pipe); | 609 | if (0 == usbhsh_device_number(hpriv, udev)) |
414 | info->usr_cnt++; | 610 | return; |
415 | 611 | ||
416 | /* init this endpoint, and attach it to udev */ | 612 | /******************** spin lock ********************/ |
417 | INIT_LIST_HEAD(&uep->ep_list); | 613 | usbhs_lock(priv, flags); |
418 | list_add_tail(&uep->ep_list, &udev->ep_list_head); | ||
419 | 614 | ||
420 | /* | 615 | /* |
421 | * usbhs_pipe_config_update() should be called after | 616 | * usbhsh_usbv_to_udev() |
422 | * usbhs_device_config() | 617 | * usbhsh_udev_to_usbv() |
423 | * see | 618 | * will be disable |
424 | * DCPMAXP/PIPEMAXP | ||
425 | */ | 619 | */ |
426 | usbhs_pipe_config_update(uep->pipe, | 620 | dev_set_drvdata(&usbv->dev, NULL); |
427 | usbhsh_device_number(hpriv, udev), | 621 | udev->usbv = NULL; |
428 | usb_endpoint_num(desc), | ||
429 | uep->maxp); | ||
430 | |||
431 | dev_dbg(dev, "%s [%d-%s](%p)\n", __func__, | ||
432 | usbhsh_device_number(hpriv, udev), | ||
433 | usbhs_pipe_name(pipe), uep); | ||
434 | |||
435 | return uep; | ||
436 | } | ||
437 | |||
438 | void usbhsh_endpoint_free(struct usbhsh_hpriv *hpriv, | ||
439 | struct usb_host_endpoint *ep) | ||
440 | { | ||
441 | struct usbhs_priv *priv = usbhsh_hpriv_to_priv(hpriv); | ||
442 | struct device *dev = usbhs_priv_to_dev(priv); | ||
443 | struct usbhsh_ep *uep = usbhsh_ep_to_uep(ep); | ||
444 | struct usbhsh_pipe_info *info; | ||
445 | |||
446 | if (!uep) | ||
447 | return; | ||
448 | |||
449 | dev_dbg(dev, "%s [%d-%s](%p)\n", __func__, | ||
450 | usbhsh_device_number(hpriv, usbhsh_uep_to_udev(uep)), | ||
451 | usbhs_pipe_name(uep->pipe), uep); | ||
452 | |||
453 | info = usbhsh_pipe_info(uep->pipe); | ||
454 | info->usr_cnt--; | ||
455 | |||
456 | /* remove this endpoint from udev */ | ||
457 | list_del_init(&uep->ep_list); | ||
458 | |||
459 | usbhsh_uep_to_udev(uep) = NULL; | ||
460 | usbhsh_ep_to_uep(ep) = NULL; | ||
461 | 622 | ||
462 | kfree(uep); | 623 | usbhs_unlock(priv, flags); |
624 | /******************** spin unlock ******************/ | ||
463 | } | 625 | } |
464 | 626 | ||
465 | /* | 627 | /* |
@@ -467,11 +629,12 @@ void usbhsh_endpoint_free(struct usbhsh_hpriv *hpriv, | |||
467 | */ | 629 | */ |
468 | static void usbhsh_queue_done(struct usbhs_priv *priv, struct usbhs_pkt *pkt) | 630 | static void usbhsh_queue_done(struct usbhs_priv *priv, struct usbhs_pkt *pkt) |
469 | { | 631 | { |
470 | struct usbhsh_request *ureq = usbhsh_pkt_to_req(pkt); | 632 | struct usbhsh_request *ureq = usbhsh_pkt_to_ureq(pkt); |
471 | struct usbhsh_hpriv *hpriv = usbhsh_priv_to_hpriv(priv); | 633 | struct usbhsh_hpriv *hpriv = usbhsh_priv_to_hpriv(priv); |
472 | struct usb_hcd *hcd = usbhsh_hpriv_to_hcd(hpriv); | 634 | struct usb_hcd *hcd = usbhsh_hpriv_to_hcd(hpriv); |
473 | struct urb *urb = ureq->urb; | 635 | struct urb *urb = ureq->urb; |
474 | struct device *dev = usbhs_priv_to_dev(priv); | 636 | struct device *dev = usbhs_priv_to_dev(priv); |
637 | int status = 0; | ||
475 | 638 | ||
476 | dev_dbg(dev, "%s\n", __func__); | 639 | dev_dbg(dev, "%s\n", __func__); |
477 | 640 | ||
@@ -480,29 +643,43 @@ static void usbhsh_queue_done(struct usbhs_priv *priv, struct usbhs_pkt *pkt) | |||
480 | return; | 643 | return; |
481 | } | 644 | } |
482 | 645 | ||
646 | if (!usbhsh_is_running(hpriv)) | ||
647 | status = -ESHUTDOWN; | ||
648 | |||
483 | urb->actual_length = pkt->actual; | 649 | urb->actual_length = pkt->actual; |
484 | usbhsh_req_free(hpriv, ureq); | 650 | usbhsh_ureq_free(hpriv, ureq); |
485 | usbhsh_urb_to_ureq(urb) = NULL; | 651 | |
652 | usbhsh_endpoint_sequence_save(hpriv, urb, pkt); | ||
653 | usbhsh_pipe_detach(hpriv, usbhsh_ep_to_uep(urb->ep)); | ||
486 | 654 | ||
487 | usb_hcd_unlink_urb_from_ep(hcd, urb); | 655 | usb_hcd_unlink_urb_from_ep(hcd, urb); |
488 | usb_hcd_giveback_urb(hcd, urb, 0); | 656 | usb_hcd_giveback_urb(hcd, urb, status); |
489 | } | 657 | } |
490 | 658 | ||
491 | static int usbhsh_queue_push(struct usb_hcd *hcd, | 659 | static int usbhsh_queue_push(struct usb_hcd *hcd, |
492 | struct usbhs_pipe *pipe, | 660 | struct urb *urb, |
493 | struct urb *urb) | 661 | gfp_t mem_flags) |
494 | { | 662 | { |
495 | struct usbhsh_request *ureq = usbhsh_urb_to_ureq(urb); | 663 | struct usbhsh_hpriv *hpriv = usbhsh_hcd_to_hpriv(hcd); |
496 | struct usbhs_pkt *pkt = &ureq->pkt; | 664 | struct usbhsh_ep *uep = usbhsh_ep_to_uep(urb->ep); |
665 | struct usbhs_pipe *pipe = usbhsh_uep_to_pipe(uep); | ||
497 | struct device *dev = usbhsh_hcd_to_dev(hcd); | 666 | struct device *dev = usbhsh_hcd_to_dev(hcd); |
667 | struct usbhsh_request *ureq; | ||
498 | void *buf; | 668 | void *buf; |
499 | int len; | 669 | int len, sequence; |
500 | 670 | ||
501 | if (usb_pipeisoc(urb->pipe)) { | 671 | if (usb_pipeisoc(urb->pipe)) { |
502 | dev_err(dev, "pipe iso is not supported now\n"); | 672 | dev_err(dev, "pipe iso is not supported now\n"); |
503 | return -EIO; | 673 | return -EIO; |
504 | } | 674 | } |
505 | 675 | ||
676 | /* this ureq will be freed on usbhsh_queue_done() */ | ||
677 | ureq = usbhsh_ureq_alloc(hpriv, urb, mem_flags); | ||
678 | if (unlikely(!ureq)) { | ||
679 | dev_err(dev, "ureq alloc fail\n"); | ||
680 | return -ENOMEM; | ||
681 | } | ||
682 | |||
506 | if (usb_pipein(urb->pipe)) | 683 | if (usb_pipein(urb->pipe)) |
507 | pipe->handler = &usbhs_fifo_pio_pop_handler; | 684 | pipe->handler = &usbhs_fifo_pio_pop_handler; |
508 | else | 685 | else |
@@ -511,25 +688,59 @@ static int usbhsh_queue_push(struct usb_hcd *hcd, | |||
511 | buf = (void *)(urb->transfer_buffer + urb->actual_length); | 688 | buf = (void *)(urb->transfer_buffer + urb->actual_length); |
512 | len = urb->transfer_buffer_length - urb->actual_length; | 689 | len = urb->transfer_buffer_length - urb->actual_length; |
513 | 690 | ||
691 | sequence = usb_gettoggle(urb->dev, | ||
692 | usb_pipeendpoint(urb->pipe), | ||
693 | usb_pipeout(urb->pipe)); | ||
694 | |||
514 | dev_dbg(dev, "%s\n", __func__); | 695 | dev_dbg(dev, "%s\n", __func__); |
515 | usbhs_pkt_push(pipe, pkt, usbhsh_queue_done, | 696 | usbhs_pkt_push(pipe, &ureq->pkt, usbhsh_queue_done, |
516 | buf, len, (urb->transfer_flags & URB_ZERO_PACKET)); | 697 | buf, len, (urb->transfer_flags & URB_ZERO_PACKET), |
698 | sequence); | ||
699 | |||
517 | usbhs_pkt_start(pipe); | 700 | usbhs_pkt_start(pipe); |
518 | 701 | ||
519 | return 0; | 702 | return 0; |
520 | } | 703 | } |
521 | 704 | ||
705 | static void usbhsh_queue_force_pop(struct usbhs_priv *priv, | ||
706 | struct usbhs_pipe *pipe) | ||
707 | { | ||
708 | struct usbhs_pkt *pkt; | ||
709 | |||
710 | while (1) { | ||
711 | pkt = usbhs_pkt_pop(pipe, NULL); | ||
712 | if (!pkt) | ||
713 | break; | ||
714 | |||
715 | /* | ||
716 | * if all packet are gone, usbhsh_endpoint_disable() | ||
717 | * will be called. | ||
718 | * then, attached device/endpoint/pipe will be detached | ||
719 | */ | ||
720 | usbhsh_queue_done(priv, pkt); | ||
721 | } | ||
722 | } | ||
723 | |||
724 | static void usbhsh_queue_force_pop_all(struct usbhs_priv *priv) | ||
725 | { | ||
726 | struct usbhs_pipe *pos; | ||
727 | int i; | ||
728 | |||
729 | usbhs_for_each_pipe_with_dcp(pos, priv, i) | ||
730 | usbhsh_queue_force_pop(priv, pos); | ||
731 | } | ||
732 | |||
522 | /* | 733 | /* |
523 | * DCP setup stage | 734 | * DCP setup stage |
524 | */ | 735 | */ |
525 | static int usbhsh_is_request_address(struct urb *urb) | 736 | static int usbhsh_is_request_address(struct urb *urb) |
526 | { | 737 | { |
527 | struct usb_ctrlrequest *cmd; | 738 | struct usb_ctrlrequest *req; |
528 | 739 | ||
529 | cmd = (struct usb_ctrlrequest *)urb->setup_packet; | 740 | req = (struct usb_ctrlrequest *)urb->setup_packet; |
530 | 741 | ||
531 | if ((DeviceOutRequest == cmd->bRequestType << 8) && | 742 | if ((DeviceOutRequest == req->bRequestType << 8) && |
532 | (USB_REQ_SET_ADDRESS == cmd->bRequest)) | 743 | (USB_REQ_SET_ADDRESS == req->bRequest)) |
533 | return 1; | 744 | return 1; |
534 | else | 745 | else |
535 | return 0; | 746 | return 0; |
@@ -549,8 +760,7 @@ static void usbhsh_setup_stage_packet_push(struct usbhsh_hpriv *hpriv, | |||
549 | * usbhsh_irq_setup_ack() | 760 | * usbhsh_irq_setup_ack() |
550 | * usbhsh_irq_setup_err() | 761 | * usbhsh_irq_setup_err() |
551 | */ | 762 | */ |
552 | DECLARE_COMPLETION(done); | 763 | init_completion(&hpriv->setup_ack_done); |
553 | hpriv->done = &done; | ||
554 | 764 | ||
555 | /* copy original request */ | 765 | /* copy original request */ |
556 | memcpy(&req, urb->setup_packet, sizeof(struct usb_ctrlrequest)); | 766 | memcpy(&req, urb->setup_packet, sizeof(struct usb_ctrlrequest)); |
@@ -558,11 +768,15 @@ static void usbhsh_setup_stage_packet_push(struct usbhsh_hpriv *hpriv, | |||
558 | /* | 768 | /* |
559 | * renesas_usbhs can not use original usb address. | 769 | * renesas_usbhs can not use original usb address. |
560 | * see HARDWARE LIMITATION. | 770 | * see HARDWARE LIMITATION. |
561 | * modify usb address here. | 771 | * modify usb address here to use attached device. |
772 | * see usbhsh_device_attach() | ||
562 | */ | 773 | */ |
563 | if (usbhsh_is_request_address(urb)) { | 774 | if (usbhsh_is_request_address(urb)) { |
564 | /* FIXME */ | 775 | struct usb_device *usbv = usbhsh_urb_to_usbv(urb); |
565 | req.wValue = 1; | 776 | struct usbhsh_device *udev = usbhsh_usbv_to_udev(usbv); |
777 | |||
778 | /* udev is a attached device */ | ||
779 | req.wValue = usbhsh_device_number(hpriv, udev); | ||
566 | dev_dbg(dev, "create new address - %d\n", req.wValue); | 780 | dev_dbg(dev, "create new address - %d\n", req.wValue); |
567 | } | 781 | } |
568 | 782 | ||
@@ -572,8 +786,7 @@ static void usbhsh_setup_stage_packet_push(struct usbhsh_hpriv *hpriv, | |||
572 | /* | 786 | /* |
573 | * wait setup packet ACK | 787 | * wait setup packet ACK |
574 | */ | 788 | */ |
575 | wait_for_completion(&done); | 789 | wait_for_completion(&hpriv->setup_ack_done); |
576 | hpriv->done = NULL; | ||
577 | 790 | ||
578 | dev_dbg(dev, "%s done\n", __func__); | 791 | dev_dbg(dev, "%s done\n", __func__); |
579 | } | 792 | } |
@@ -584,82 +797,80 @@ static void usbhsh_setup_stage_packet_push(struct usbhsh_hpriv *hpriv, | |||
584 | static void usbhsh_data_stage_packet_done(struct usbhs_priv *priv, | 797 | static void usbhsh_data_stage_packet_done(struct usbhs_priv *priv, |
585 | struct usbhs_pkt *pkt) | 798 | struct usbhs_pkt *pkt) |
586 | { | 799 | { |
587 | struct usbhsh_request *ureq = usbhsh_pkt_to_req(pkt); | 800 | struct usbhsh_request *ureq = usbhsh_pkt_to_ureq(pkt); |
588 | struct usbhsh_hpriv *hpriv = usbhsh_priv_to_hpriv(priv); | 801 | struct usbhsh_hpriv *hpriv = usbhsh_priv_to_hpriv(priv); |
589 | struct urb *urb = ureq->urb; | ||
590 | 802 | ||
591 | /* this ureq was connected to urb when usbhsh_urb_enqueue() */ | 803 | /* this ureq was connected to urb when usbhsh_urb_enqueue() */ |
592 | 804 | ||
593 | usbhsh_req_free(hpriv, ureq); | 805 | usbhsh_ureq_free(hpriv, ureq); |
594 | usbhsh_urb_to_ureq(urb) = NULL; | ||
595 | } | 806 | } |
596 | 807 | ||
597 | static void usbhsh_data_stage_packet_push(struct usbhsh_hpriv *hpriv, | 808 | static int usbhsh_data_stage_packet_push(struct usbhsh_hpriv *hpriv, |
598 | struct urb *urb, | 809 | struct urb *urb, |
599 | struct usbhs_pipe *pipe) | 810 | struct usbhs_pipe *pipe, |
811 | gfp_t mem_flags) | ||
812 | |||
600 | { | 813 | { |
601 | struct usbhsh_request *ureq; | 814 | struct usbhsh_request *ureq; |
602 | struct usbhs_pkt *pkt; | ||
603 | 815 | ||
604 | /* | 816 | /* this ureq will be freed on usbhsh_data_stage_packet_done() */ |
605 | * FIXME | 817 | ureq = usbhsh_ureq_alloc(hpriv, urb, mem_flags); |
606 | * | 818 | if (unlikely(!ureq)) |
607 | * data stage uses ureq which is connected to urb | 819 | return -ENOMEM; |
608 | * see usbhsh_urb_enqueue() :: alloc new request. | ||
609 | * it will be freed in usbhsh_data_stage_packet_done() | ||
610 | */ | ||
611 | ureq = usbhsh_urb_to_ureq(urb); | ||
612 | pkt = &ureq->pkt; | ||
613 | 820 | ||
614 | if (usb_pipein(urb->pipe)) | 821 | if (usb_pipein(urb->pipe)) |
615 | pipe->handler = &usbhs_dcp_data_stage_in_handler; | 822 | pipe->handler = &usbhs_dcp_data_stage_in_handler; |
616 | else | 823 | else |
617 | pipe->handler = &usbhs_dcp_data_stage_out_handler; | 824 | pipe->handler = &usbhs_dcp_data_stage_out_handler; |
618 | 825 | ||
619 | usbhs_pkt_push(pipe, pkt, | 826 | usbhs_pkt_push(pipe, &ureq->pkt, |
620 | usbhsh_data_stage_packet_done, | 827 | usbhsh_data_stage_packet_done, |
621 | urb->transfer_buffer, | 828 | urb->transfer_buffer, |
622 | urb->transfer_buffer_length, | 829 | urb->transfer_buffer_length, |
623 | (urb->transfer_flags & URB_ZERO_PACKET)); | 830 | (urb->transfer_flags & URB_ZERO_PACKET), |
831 | -1); | ||
832 | |||
833 | return 0; | ||
624 | } | 834 | } |
625 | 835 | ||
626 | /* | 836 | /* |
627 | * DCP status stage | 837 | * DCP status stage |
628 | */ | 838 | */ |
629 | static void usbhsh_status_stage_packet_push(struct usbhsh_hpriv *hpriv, | 839 | static int usbhsh_status_stage_packet_push(struct usbhsh_hpriv *hpriv, |
630 | struct urb *urb, | 840 | struct urb *urb, |
631 | struct usbhs_pipe *pipe) | 841 | struct usbhs_pipe *pipe, |
842 | gfp_t mem_flags) | ||
632 | { | 843 | { |
633 | struct usbhsh_request *ureq; | 844 | struct usbhsh_request *ureq; |
634 | struct usbhs_pkt *pkt; | ||
635 | 845 | ||
636 | /* | 846 | /* This ureq will be freed on usbhsh_queue_done() */ |
637 | * FIXME | 847 | ureq = usbhsh_ureq_alloc(hpriv, urb, mem_flags); |
638 | * | 848 | if (unlikely(!ureq)) |
639 | * status stage uses allocated ureq. | 849 | return -ENOMEM; |
640 | * it will be freed on usbhsh_queue_done() | ||
641 | */ | ||
642 | ureq = usbhsh_req_alloc(hpriv, urb, GFP_KERNEL); | ||
643 | pkt = &ureq->pkt; | ||
644 | 850 | ||
645 | if (usb_pipein(urb->pipe)) | 851 | if (usb_pipein(urb->pipe)) |
646 | pipe->handler = &usbhs_dcp_status_stage_in_handler; | 852 | pipe->handler = &usbhs_dcp_status_stage_in_handler; |
647 | else | 853 | else |
648 | pipe->handler = &usbhs_dcp_status_stage_out_handler; | 854 | pipe->handler = &usbhs_dcp_status_stage_out_handler; |
649 | 855 | ||
650 | usbhs_pkt_push(pipe, pkt, | 856 | usbhs_pkt_push(pipe, &ureq->pkt, |
651 | usbhsh_queue_done, | 857 | usbhsh_queue_done, |
652 | NULL, | 858 | NULL, |
653 | urb->transfer_buffer_length, | 859 | urb->transfer_buffer_length, |
654 | 0); | 860 | 0, -1); |
861 | |||
862 | return 0; | ||
655 | } | 863 | } |
656 | 864 | ||
657 | static int usbhsh_dcp_queue_push(struct usb_hcd *hcd, | 865 | static int usbhsh_dcp_queue_push(struct usb_hcd *hcd, |
658 | struct usbhsh_hpriv *hpriv, | 866 | struct urb *urb, |
659 | struct usbhs_pipe *pipe, | 867 | gfp_t mflags) |
660 | struct urb *urb) | ||
661 | { | 868 | { |
869 | struct usbhsh_hpriv *hpriv = usbhsh_hcd_to_hpriv(hcd); | ||
870 | struct usbhsh_ep *uep = usbhsh_ep_to_uep(urb->ep); | ||
871 | struct usbhs_pipe *pipe = usbhsh_uep_to_pipe(uep); | ||
662 | struct device *dev = usbhsh_hcd_to_dev(hcd); | 872 | struct device *dev = usbhsh_hcd_to_dev(hcd); |
873 | int ret; | ||
663 | 874 | ||
664 | dev_dbg(dev, "%s\n", __func__); | 875 | dev_dbg(dev, "%s\n", __func__); |
665 | 876 | ||
@@ -675,13 +886,22 @@ static int usbhsh_dcp_queue_push(struct usb_hcd *hcd, | |||
675 | * | 886 | * |
676 | * It is pushed only when urb has buffer. | 887 | * It is pushed only when urb has buffer. |
677 | */ | 888 | */ |
678 | if (urb->transfer_buffer_length) | 889 | if (urb->transfer_buffer_length) { |
679 | usbhsh_data_stage_packet_push(hpriv, urb, pipe); | 890 | ret = usbhsh_data_stage_packet_push(hpriv, urb, pipe, mflags); |
891 | if (ret < 0) { | ||
892 | dev_err(dev, "data stage failed\n"); | ||
893 | return ret; | ||
894 | } | ||
895 | } | ||
680 | 896 | ||
681 | /* | 897 | /* |
682 | * status stage | 898 | * status stage |
683 | */ | 899 | */ |
684 | usbhsh_status_stage_packet_push(hpriv, urb, pipe); | 900 | ret = usbhsh_status_stage_packet_push(hpriv, urb, pipe, mflags); |
901 | if (ret < 0) { | ||
902 | dev_err(dev, "status stage failed\n"); | ||
903 | return ret; | ||
904 | } | ||
685 | 905 | ||
686 | /* | 906 | /* |
687 | * start pushed packets | 907 | * start pushed packets |
@@ -718,70 +938,82 @@ static int usbhsh_urb_enqueue(struct usb_hcd *hcd, | |||
718 | struct usbhsh_hpriv *hpriv = usbhsh_hcd_to_hpriv(hcd); | 938 | struct usbhsh_hpriv *hpriv = usbhsh_hcd_to_hpriv(hcd); |
719 | struct usbhs_priv *priv = usbhsh_hpriv_to_priv(hpriv); | 939 | struct usbhs_priv *priv = usbhsh_hpriv_to_priv(hpriv); |
720 | struct device *dev = usbhs_priv_to_dev(priv); | 940 | struct device *dev = usbhs_priv_to_dev(priv); |
721 | struct usb_device *usbv = usbhsh_urb_to_usbv(urb); | ||
722 | struct usb_host_endpoint *ep = urb->ep; | 941 | struct usb_host_endpoint *ep = urb->ep; |
723 | struct usbhsh_request *ureq; | 942 | struct usbhsh_device *new_udev = NULL; |
724 | struct usbhsh_device *udev, *new_udev = NULL; | 943 | int is_dir_in = usb_pipein(urb->pipe); |
725 | struct usbhs_pipe *pipe; | 944 | int i; |
726 | struct usbhsh_ep *uep; | ||
727 | |||
728 | int ret; | 945 | int ret; |
729 | 946 | ||
730 | dev_dbg(dev, "%s (%s)\n", | 947 | dev_dbg(dev, "%s (%s)\n", __func__, is_dir_in ? "in" : "out"); |
731 | __func__, usb_pipein(urb->pipe) ? "in" : "out"); | 948 | |
949 | if (!usbhsh_is_running(hpriv)) { | ||
950 | ret = -EIO; | ||
951 | dev_err(dev, "host is not running\n"); | ||
952 | goto usbhsh_urb_enqueue_error_not_linked; | ||
953 | } | ||
732 | 954 | ||
733 | ret = usb_hcd_link_urb_to_ep(hcd, urb); | 955 | ret = usb_hcd_link_urb_to_ep(hcd, urb); |
734 | if (ret) | 956 | if (ret) { |
957 | dev_err(dev, "urb link failed\n"); | ||
735 | goto usbhsh_urb_enqueue_error_not_linked; | 958 | goto usbhsh_urb_enqueue_error_not_linked; |
959 | } | ||
736 | 960 | ||
737 | /* | 961 | /* |
738 | * get udev | 962 | * attach udev if needed |
963 | * see [image of mod_host] | ||
739 | */ | 964 | */ |
740 | udev = usbhsh_usbv_to_udev(usbv); | 965 | if (!usbhsh_device_get(hpriv, urb)) { |
741 | if (!udev) { | 966 | new_udev = usbhsh_device_attach(hpriv, urb); |
742 | new_udev = usbhsh_device_alloc(hpriv, urb); | 967 | if (!new_udev) { |
743 | if (!new_udev) | 968 | ret = -EIO; |
969 | dev_err(dev, "device attach failed\n"); | ||
744 | goto usbhsh_urb_enqueue_error_not_linked; | 970 | goto usbhsh_urb_enqueue_error_not_linked; |
745 | 971 | } | |
746 | udev = new_udev; | ||
747 | } | 972 | } |
748 | 973 | ||
749 | /* | 974 | /* |
750 | * get uep | 975 | * attach endpoint if needed |
976 | * see [image of mod_host] | ||
751 | */ | 977 | */ |
752 | uep = usbhsh_ep_to_uep(ep); | 978 | if (!usbhsh_ep_to_uep(ep)) { |
753 | if (!uep) { | 979 | ret = usbhsh_endpoint_attach(hpriv, urb, mem_flags); |
754 | uep = usbhsh_endpoint_alloc(hpriv, udev, ep, mem_flags); | 980 | if (ret < 0) { |
755 | if (!uep) | 981 | dev_err(dev, "endpoint attach failed\n"); |
756 | goto usbhsh_urb_enqueue_error_free_device; | 982 | goto usbhsh_urb_enqueue_error_free_device; |
983 | } | ||
757 | } | 984 | } |
758 | pipe = usbhsh_uep_to_pipe(uep); | ||
759 | 985 | ||
760 | /* | 986 | /* |
761 | * alloc new request | 987 | * attach pipe to endpoint |
988 | * see [image of mod_host] | ||
762 | */ | 989 | */ |
763 | ureq = usbhsh_req_alloc(hpriv, urb, mem_flags); | 990 | for (i = 0; i < 1024; i++) { |
764 | if (unlikely(!ureq)) { | 991 | ret = usbhsh_pipe_attach(hpriv, urb); |
765 | ret = -ENOMEM; | 992 | if (ret < 0) |
993 | msleep(100); | ||
994 | else | ||
995 | break; | ||
996 | } | ||
997 | if (ret < 0) { | ||
998 | dev_err(dev, "pipe attach failed\n"); | ||
766 | goto usbhsh_urb_enqueue_error_free_endpoint; | 999 | goto usbhsh_urb_enqueue_error_free_endpoint; |
767 | } | 1000 | } |
768 | usbhsh_urb_to_ureq(urb) = ureq; | ||
769 | 1001 | ||
770 | /* | 1002 | /* |
771 | * push packet | 1003 | * push packet |
772 | */ | 1004 | */ |
773 | if (usb_pipecontrol(urb->pipe)) | 1005 | if (usb_pipecontrol(urb->pipe)) |
774 | usbhsh_dcp_queue_push(hcd, hpriv, pipe, urb); | 1006 | ret = usbhsh_dcp_queue_push(hcd, urb, mem_flags); |
775 | else | 1007 | else |
776 | usbhsh_queue_push(hcd, pipe, urb); | 1008 | ret = usbhsh_queue_push(hcd, urb, mem_flags); |
777 | 1009 | ||
778 | return 0; | 1010 | return ret; |
779 | 1011 | ||
780 | usbhsh_urb_enqueue_error_free_endpoint: | 1012 | usbhsh_urb_enqueue_error_free_endpoint: |
781 | usbhsh_endpoint_free(hpriv, ep); | 1013 | usbhsh_endpoint_detach(hpriv, ep); |
782 | usbhsh_urb_enqueue_error_free_device: | 1014 | usbhsh_urb_enqueue_error_free_device: |
783 | if (new_udev) | 1015 | if (new_udev) |
784 | usbhsh_device_free(hpriv, new_udev); | 1016 | usbhsh_device_detach(hpriv, new_udev); |
785 | usbhsh_urb_enqueue_error_not_linked: | 1017 | usbhsh_urb_enqueue_error_not_linked: |
786 | 1018 | ||
787 | dev_dbg(dev, "%s error\n", __func__); | 1019 | dev_dbg(dev, "%s error\n", __func__); |
@@ -795,8 +1027,11 @@ static int usbhsh_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) | |||
795 | struct usbhsh_request *ureq = usbhsh_urb_to_ureq(urb); | 1027 | struct usbhsh_request *ureq = usbhsh_urb_to_ureq(urb); |
796 | 1028 | ||
797 | if (ureq) { | 1029 | if (ureq) { |
798 | usbhsh_req_free(hpriv, ureq); | 1030 | struct usbhs_priv *priv = usbhsh_hpriv_to_priv(hpriv); |
799 | usbhsh_urb_to_ureq(urb) = NULL; | 1031 | struct usbhs_pkt *pkt = &ureq->pkt; |
1032 | |||
1033 | usbhs_pkt_pop(pkt->pipe, pkt); | ||
1034 | usbhsh_queue_done(priv, pkt); | ||
800 | } | 1035 | } |
801 | 1036 | ||
802 | return 0; | 1037 | return 0; |
@@ -811,7 +1046,7 @@ static void usbhsh_endpoint_disable(struct usb_hcd *hcd, | |||
811 | 1046 | ||
812 | /* | 1047 | /* |
813 | * this function might be called manytimes by same hcd/ep | 1048 | * this function might be called manytimes by same hcd/ep |
814 | * in-endpoitn == out-endpoint if ep == dcp. | 1049 | * in-endpoint == out-endpoint if ep == dcp. |
815 | */ | 1050 | */ |
816 | if (!uep) | 1051 | if (!uep) |
817 | return; | 1052 | return; |
@@ -819,15 +1054,14 @@ static void usbhsh_endpoint_disable(struct usb_hcd *hcd, | |||
819 | udev = usbhsh_uep_to_udev(uep); | 1054 | udev = usbhsh_uep_to_udev(uep); |
820 | hpriv = usbhsh_hcd_to_hpriv(hcd); | 1055 | hpriv = usbhsh_hcd_to_hpriv(hcd); |
821 | 1056 | ||
822 | usbhsh_endpoint_free(hpriv, ep); | 1057 | usbhsh_endpoint_detach(hpriv, ep); |
823 | ep->hcpriv = NULL; | ||
824 | 1058 | ||
825 | /* | 1059 | /* |
826 | * if there is no endpoint, | 1060 | * if there is no endpoint, |
827 | * free device | 1061 | * free device |
828 | */ | 1062 | */ |
829 | if (!usbhsh_device_has_endpoint(udev)) | 1063 | if (!usbhsh_device_has_endpoint(udev)) |
830 | usbhsh_device_free(hpriv, udev); | 1064 | usbhsh_device_detach(hpriv, udev); |
831 | } | 1065 | } |
832 | 1066 | ||
833 | static int usbhsh_hub_status_data(struct usb_hcd *hcd, char *buf) | 1067 | static int usbhsh_hub_status_data(struct usb_hcd *hcd, char *buf) |
@@ -907,6 +1141,8 @@ static int __usbhsh_hub_port_feature(struct usbhsh_hpriv *hpriv, | |||
907 | USB_PORT_STAT_HIGH_SPEED | | 1141 | USB_PORT_STAT_HIGH_SPEED | |
908 | USB_PORT_STAT_LOW_SPEED); | 1142 | USB_PORT_STAT_LOW_SPEED); |
909 | 1143 | ||
1144 | usbhsh_queue_force_pop_all(priv); | ||
1145 | |||
910 | usbhs_bus_send_reset(priv); | 1146 | usbhs_bus_send_reset(priv); |
911 | msleep(20); | 1147 | msleep(20); |
912 | usbhs_bus_send_sof_enable(priv); | 1148 | usbhs_bus_send_sof_enable(priv); |
@@ -1070,6 +1306,20 @@ static int usbhsh_irq_attch(struct usbhs_priv *priv, | |||
1070 | usbhsh_port_stat_set(hpriv, USB_PORT_STAT_CONNECTION); | 1306 | usbhsh_port_stat_set(hpriv, USB_PORT_STAT_CONNECTION); |
1071 | usbhsh_port_stat_set(hpriv, USB_PORT_STAT_C_CONNECTION << 16); | 1307 | usbhsh_port_stat_set(hpriv, USB_PORT_STAT_C_CONNECTION << 16); |
1072 | 1308 | ||
1309 | /* | ||
1310 | * attch interrupt might happen infinitely on some device | ||
1311 | * (on self power USB hub ?) | ||
1312 | * disable it here. | ||
1313 | * | ||
1314 | * usbhsh_is_running() becomes effective | ||
1315 | * according to this process. | ||
1316 | * see | ||
1317 | * usbhsh_is_running() | ||
1318 | * usbhsh_urb_enqueue() | ||
1319 | */ | ||
1320 | hpriv->mod.irq_attch = NULL; | ||
1321 | usbhs_irq_callback_update(priv, &hpriv->mod); | ||
1322 | |||
1073 | return 0; | 1323 | return 0; |
1074 | } | 1324 | } |
1075 | 1325 | ||
@@ -1084,6 +1334,24 @@ static int usbhsh_irq_dtch(struct usbhs_priv *priv, | |||
1084 | usbhsh_port_stat_clear(hpriv, USB_PORT_STAT_CONNECTION); | 1334 | usbhsh_port_stat_clear(hpriv, USB_PORT_STAT_CONNECTION); |
1085 | usbhsh_port_stat_set(hpriv, USB_PORT_STAT_C_CONNECTION << 16); | 1335 | usbhsh_port_stat_set(hpriv, USB_PORT_STAT_C_CONNECTION << 16); |
1086 | 1336 | ||
1337 | /* | ||
1338 | * enable attch interrupt again | ||
1339 | * | ||
1340 | * usbhsh_is_running() becomes invalid | ||
1341 | * according to this process. | ||
1342 | * see | ||
1343 | * usbhsh_is_running() | ||
1344 | * usbhsh_urb_enqueue() | ||
1345 | */ | ||
1346 | hpriv->mod.irq_attch = usbhsh_irq_attch; | ||
1347 | usbhs_irq_callback_update(priv, &hpriv->mod); | ||
1348 | |||
1349 | /* | ||
1350 | * usbhsh_queue_force_pop_all() should be called | ||
1351 | * after usbhsh_is_running() becomes invalid. | ||
1352 | */ | ||
1353 | usbhsh_queue_force_pop_all(priv); | ||
1354 | |||
1087 | return 0; | 1355 | return 0; |
1088 | } | 1356 | } |
1089 | 1357 | ||
@@ -1095,10 +1363,7 @@ static int usbhsh_irq_setup_ack(struct usbhs_priv *priv, | |||
1095 | 1363 | ||
1096 | dev_dbg(dev, "setup packet OK\n"); | 1364 | dev_dbg(dev, "setup packet OK\n"); |
1097 | 1365 | ||
1098 | if (unlikely(!hpriv->done)) | 1366 | complete(&hpriv->setup_ack_done); /* see usbhsh_urb_enqueue() */ |
1099 | dev_err(dev, "setup ack happen without necessary data\n"); | ||
1100 | else | ||
1101 | complete(hpriv->done); /* see usbhsh_urb_enqueue() */ | ||
1102 | 1367 | ||
1103 | return 0; | 1368 | return 0; |
1104 | } | 1369 | } |
@@ -1111,10 +1376,7 @@ static int usbhsh_irq_setup_err(struct usbhs_priv *priv, | |||
1111 | 1376 | ||
1112 | dev_dbg(dev, "setup packet Err\n"); | 1377 | dev_dbg(dev, "setup packet Err\n"); |
1113 | 1378 | ||
1114 | if (unlikely(!hpriv->done)) | 1379 | complete(&hpriv->setup_ack_done); /* see usbhsh_urb_enqueue() */ |
1115 | dev_err(dev, "setup err happen without necessary data\n"); | ||
1116 | else | ||
1117 | complete(hpriv->done); /* see usbhsh_urb_enqueue() */ | ||
1118 | 1380 | ||
1119 | return 0; | 1381 | return 0; |
1120 | } | 1382 | } |
@@ -1125,7 +1387,6 @@ static int usbhsh_irq_setup_err(struct usbhs_priv *priv, | |||
1125 | static void usbhsh_pipe_init_for_host(struct usbhs_priv *priv) | 1387 | static void usbhsh_pipe_init_for_host(struct usbhs_priv *priv) |
1126 | { | 1388 | { |
1127 | struct usbhsh_hpriv *hpriv = usbhsh_priv_to_hpriv(priv); | 1389 | struct usbhsh_hpriv *hpriv = usbhsh_priv_to_hpriv(priv); |
1128 | struct usbhsh_pipe_info *pipe_info = hpriv->pipe_info; | ||
1129 | struct usbhs_pipe *pipe; | 1390 | struct usbhs_pipe *pipe; |
1130 | u32 *pipe_type = usbhs_get_dparam(priv, pipe_type); | 1391 | u32 *pipe_type = usbhs_get_dparam(priv, pipe_type); |
1131 | int pipe_size = usbhs_get_dparam(priv, pipe_size); | 1392 | int pipe_size = usbhs_get_dparam(priv, pipe_size); |
@@ -1134,7 +1395,6 @@ static void usbhsh_pipe_init_for_host(struct usbhs_priv *priv) | |||
1134 | /* init all pipe */ | 1395 | /* init all pipe */ |
1135 | old_type = USB_ENDPOINT_XFER_CONTROL; | 1396 | old_type = USB_ENDPOINT_XFER_CONTROL; |
1136 | for (i = 0; i < pipe_size; i++) { | 1397 | for (i = 0; i < pipe_size; i++) { |
1137 | pipe_info[i].usr_cnt = 0; | ||
1138 | 1398 | ||
1139 | /* | 1399 | /* |
1140 | * data "output" will be finished as soon as possible, | 1400 | * data "output" will be finished as soon as possible, |
@@ -1168,7 +1428,7 @@ static void usbhsh_pipe_init_for_host(struct usbhs_priv *priv) | |||
1168 | dir_in); | 1428 | dir_in); |
1169 | } | 1429 | } |
1170 | 1430 | ||
1171 | pipe->mod_private = pipe_info + i; | 1431 | pipe->mod_private = NULL; |
1172 | } | 1432 | } |
1173 | } | 1433 | } |
1174 | 1434 | ||
@@ -1199,9 +1459,7 @@ static int usbhsh_start(struct usbhs_priv *priv) | |||
1199 | * - host | 1459 | * - host |
1200 | * - usb module | 1460 | * - usb module |
1201 | */ | 1461 | */ |
1202 | usbhs_sys_hispeed_ctrl(priv, 1); | ||
1203 | usbhs_sys_host_ctrl(priv, 1); | 1462 | usbhs_sys_host_ctrl(priv, 1); |
1204 | usbhs_sys_usb_ctrl(priv, 1); | ||
1205 | 1463 | ||
1206 | /* | 1464 | /* |
1207 | * enable irq callback | 1465 | * enable irq callback |
@@ -1221,28 +1479,34 @@ static int usbhsh_stop(struct usbhs_priv *priv) | |||
1221 | { | 1479 | { |
1222 | struct usbhsh_hpriv *hpriv = usbhsh_priv_to_hpriv(priv); | 1480 | struct usbhsh_hpriv *hpriv = usbhsh_priv_to_hpriv(priv); |
1223 | struct usb_hcd *hcd = usbhsh_hpriv_to_hcd(hpriv); | 1481 | struct usb_hcd *hcd = usbhsh_hpriv_to_hcd(hpriv); |
1482 | struct usbhs_mod *mod = usbhs_mod_get_current(priv); | ||
1224 | struct device *dev = usbhs_priv_to_dev(priv); | 1483 | struct device *dev = usbhs_priv_to_dev(priv); |
1225 | 1484 | ||
1485 | /* | ||
1486 | * disable irq callback | ||
1487 | */ | ||
1488 | mod->irq_attch = NULL; | ||
1489 | mod->irq_dtch = NULL; | ||
1490 | mod->irq_sack = NULL; | ||
1491 | mod->irq_sign = NULL; | ||
1492 | usbhs_irq_callback_update(priv, mod); | ||
1493 | |||
1226 | usb_remove_hcd(hcd); | 1494 | usb_remove_hcd(hcd); |
1227 | 1495 | ||
1228 | /* disable sys */ | 1496 | /* disable sys */ |
1229 | usbhs_sys_hispeed_ctrl(priv, 0); | ||
1230 | usbhs_sys_host_ctrl(priv, 0); | 1497 | usbhs_sys_host_ctrl(priv, 0); |
1231 | usbhs_sys_usb_ctrl(priv, 0); | ||
1232 | 1498 | ||
1233 | dev_dbg(dev, "quit host\n"); | 1499 | dev_dbg(dev, "quit host\n"); |
1234 | 1500 | ||
1235 | return 0; | 1501 | return 0; |
1236 | } | 1502 | } |
1237 | 1503 | ||
1238 | int __devinit usbhs_mod_host_probe(struct usbhs_priv *priv) | 1504 | int usbhs_mod_host_probe(struct usbhs_priv *priv) |
1239 | { | 1505 | { |
1240 | struct usbhsh_hpriv *hpriv; | 1506 | struct usbhsh_hpriv *hpriv; |
1241 | struct usb_hcd *hcd; | 1507 | struct usb_hcd *hcd; |
1242 | struct usbhsh_pipe_info *pipe_info; | ||
1243 | struct usbhsh_device *udev; | 1508 | struct usbhsh_device *udev; |
1244 | struct device *dev = usbhs_priv_to_dev(priv); | 1509 | struct device *dev = usbhs_priv_to_dev(priv); |
1245 | int pipe_size = usbhs_get_dparam(priv, pipe_size); | ||
1246 | int i; | 1510 | int i; |
1247 | 1511 | ||
1248 | /* initialize hcd */ | 1512 | /* initialize hcd */ |
@@ -1251,12 +1515,7 @@ int __devinit usbhs_mod_host_probe(struct usbhs_priv *priv) | |||
1251 | dev_err(dev, "Failed to create hcd\n"); | 1515 | dev_err(dev, "Failed to create hcd\n"); |
1252 | return -ENOMEM; | 1516 | return -ENOMEM; |
1253 | } | 1517 | } |
1254 | 1518 | hcd->has_tt = 1; /* for low/full speed */ | |
1255 | pipe_info = kzalloc(sizeof(*pipe_info) * pipe_size, GFP_KERNEL); | ||
1256 | if (!pipe_info) { | ||
1257 | dev_err(dev, "Could not allocate pipe_info\n"); | ||
1258 | goto usbhs_mod_host_probe_err; | ||
1259 | } | ||
1260 | 1519 | ||
1261 | /* | 1520 | /* |
1262 | * CAUTION | 1521 | * CAUTION |
@@ -1277,10 +1536,6 @@ int __devinit usbhs_mod_host_probe(struct usbhs_priv *priv) | |||
1277 | hpriv->mod.name = "host"; | 1536 | hpriv->mod.name = "host"; |
1278 | hpriv->mod.start = usbhsh_start; | 1537 | hpriv->mod.start = usbhsh_start; |
1279 | hpriv->mod.stop = usbhsh_stop; | 1538 | hpriv->mod.stop = usbhsh_stop; |
1280 | hpriv->pipe_info = pipe_info; | ||
1281 | hpriv->pipe_size = pipe_size; | ||
1282 | hpriv->done = NULL; | ||
1283 | usbhsh_req_list_init(hpriv); | ||
1284 | usbhsh_port_stat_init(hpriv); | 1539 | usbhsh_port_stat_init(hpriv); |
1285 | 1540 | ||
1286 | /* init all device */ | 1541 | /* init all device */ |
@@ -1292,20 +1547,13 @@ int __devinit usbhs_mod_host_probe(struct usbhs_priv *priv) | |||
1292 | dev_info(dev, "host probed\n"); | 1547 | dev_info(dev, "host probed\n"); |
1293 | 1548 | ||
1294 | return 0; | 1549 | return 0; |
1295 | |||
1296 | usbhs_mod_host_probe_err: | ||
1297 | usb_put_hcd(hcd); | ||
1298 | |||
1299 | return -ENOMEM; | ||
1300 | } | 1550 | } |
1301 | 1551 | ||
1302 | int __devexit usbhs_mod_host_remove(struct usbhs_priv *priv) | 1552 | int usbhs_mod_host_remove(struct usbhs_priv *priv) |
1303 | { | 1553 | { |
1304 | struct usbhsh_hpriv *hpriv = usbhsh_priv_to_hpriv(priv); | 1554 | struct usbhsh_hpriv *hpriv = usbhsh_priv_to_hpriv(priv); |
1305 | struct usb_hcd *hcd = usbhsh_hpriv_to_hcd(hpriv); | 1555 | struct usb_hcd *hcd = usbhsh_hpriv_to_hcd(hpriv); |
1306 | 1556 | ||
1307 | usbhsh_req_list_quit(hpriv); | ||
1308 | |||
1309 | usb_put_hcd(hcd); | 1557 | usb_put_hcd(hcd); |
1310 | 1558 | ||
1311 | return 0; | 1559 | return 0; |
diff --git a/drivers/usb/renesas_usbhs/pipe.c b/drivers/usb/renesas_usbhs/pipe.c index c74389ce2177..feb06d6d2814 100644 --- a/drivers/usb/renesas_usbhs/pipe.c +++ b/drivers/usb/renesas_usbhs/pipe.c | |||
@@ -257,6 +257,13 @@ void usbhs_pipe_stall(struct usbhs_pipe *pipe) | |||
257 | } | 257 | } |
258 | } | 258 | } |
259 | 259 | ||
260 | int usbhs_pipe_is_stall(struct usbhs_pipe *pipe) | ||
261 | { | ||
262 | u16 pid = usbhsp_pipectrl_get(pipe) & PID_MASK; | ||
263 | |||
264 | return (int)(pid == PID_STALL10 || pid == PID_STALL11); | ||
265 | } | ||
266 | |||
260 | /* | 267 | /* |
261 | * pipe setup | 268 | * pipe setup |
262 | */ | 269 | */ |
@@ -323,8 +330,7 @@ static u16 usbhsp_setup_pipecfg(struct usbhs_pipe *pipe, | |||
323 | if (dir_in) | 330 | if (dir_in) |
324 | usbhsp_flags_set(pipe, IS_DIR_HOST); | 331 | usbhsp_flags_set(pipe, IS_DIR_HOST); |
325 | 332 | ||
326 | if ((is_host && !dir_in) || | 333 | if (!!is_host ^ !!dir_in) |
327 | (!is_host && dir_in)) | ||
328 | dir |= DIR_OUT; | 334 | dir |= DIR_OUT; |
329 | 335 | ||
330 | if (!dir) | 336 | if (!dir) |
@@ -471,10 +477,27 @@ int usbhs_pipe_is_dir_host(struct usbhs_pipe *pipe) | |||
471 | return usbhsp_flags_has(pipe, IS_DIR_HOST); | 477 | return usbhsp_flags_has(pipe, IS_DIR_HOST); |
472 | } | 478 | } |
473 | 479 | ||
474 | void usbhs_pipe_data_sequence(struct usbhs_pipe *pipe, int data) | 480 | void usbhs_pipe_data_sequence(struct usbhs_pipe *pipe, int sequence) |
475 | { | 481 | { |
476 | u16 mask = (SQCLR | SQSET); | 482 | u16 mask = (SQCLR | SQSET); |
477 | u16 val = (data) ? SQSET : SQCLR; | 483 | u16 val; |
484 | |||
485 | /* | ||
486 | * sequence | ||
487 | * 0 : data0 | ||
488 | * 1 : data1 | ||
489 | * -1 : no change | ||
490 | */ | ||
491 | switch (sequence) { | ||
492 | case 0: | ||
493 | val = SQCLR; | ||
494 | break; | ||
495 | case 1: | ||
496 | val = SQSET; | ||
497 | break; | ||
498 | default: | ||
499 | return; | ||
500 | } | ||
478 | 501 | ||
479 | usbhsp_pipectrl_set(pipe, mask, val); | 502 | usbhsp_pipectrl_set(pipe, mask, val); |
480 | } | 503 | } |
diff --git a/drivers/usb/renesas_usbhs/pipe.h b/drivers/usb/renesas_usbhs/pipe.h index 6334fc644cc0..fa18b7dc2b2a 100644 --- a/drivers/usb/renesas_usbhs/pipe.h +++ b/drivers/usb/renesas_usbhs/pipe.h | |||
@@ -87,6 +87,7 @@ int usbhs_pipe_is_accessible(struct usbhs_pipe *pipe); | |||
87 | void usbhs_pipe_enable(struct usbhs_pipe *pipe); | 87 | void usbhs_pipe_enable(struct usbhs_pipe *pipe); |
88 | void usbhs_pipe_disable(struct usbhs_pipe *pipe); | 88 | void usbhs_pipe_disable(struct usbhs_pipe *pipe); |
89 | void usbhs_pipe_stall(struct usbhs_pipe *pipe); | 89 | void usbhs_pipe_stall(struct usbhs_pipe *pipe); |
90 | int usbhs_pipe_is_stall(struct usbhs_pipe *pipe); | ||
90 | void usbhs_pipe_select_fifo(struct usbhs_pipe *pipe, struct usbhs_fifo *fifo); | 91 | void usbhs_pipe_select_fifo(struct usbhs_pipe *pipe, struct usbhs_fifo *fifo); |
91 | void usbhs_pipe_config_update(struct usbhs_pipe *pipe, u16 devsel, | 92 | void usbhs_pipe_config_update(struct usbhs_pipe *pipe, u16 devsel, |
92 | u16 epnum, u16 maxp); | 93 | u16 epnum, u16 maxp); |
diff --git a/drivers/usb/serial/ChangeLog.history b/drivers/usb/serial/ChangeLog.history deleted file mode 100644 index f13fd488ebec..000000000000 --- a/drivers/usb/serial/ChangeLog.history +++ /dev/null | |||
@@ -1,730 +0,0 @@ | |||
1 | This is the contents of some of the drivers/usb/serial/ files that had old | ||
2 | changelog comments. They were quite old, and out of date, and we don't keep | ||
3 | them anymore, so I've put them here, away from the source files, in case | ||
4 | people still care to see them. | ||
5 | |||
6 | - Greg Kroah-Hartman <greg@kroah.com> October 20, 2005 | ||
7 | |||
8 | ----------------------------------------------------------------------- | ||
9 | usb-serial.h Change Log comments: | ||
10 | |||
11 | (03/26/2002) gkh | ||
12 | removed the port->tty check from port_paranoia_check() due to serial | ||
13 | consoles not having a tty device assigned to them. | ||
14 | |||
15 | (12/03/2001) gkh | ||
16 | removed active from the port structure. | ||
17 | added documentation to the usb_serial_device_type structure | ||
18 | |||
19 | (10/10/2001) gkh | ||
20 | added vendor and product to serial structure. Needed to determine device | ||
21 | owner when the device is disconnected. | ||
22 | |||
23 | (05/30/2001) gkh | ||
24 | added sem to port structure and removed port_lock | ||
25 | |||
26 | (10/05/2000) gkh | ||
27 | Added interrupt_in_endpointAddress and bulk_in_endpointAddress to help | ||
28 | fix bug with urb->dev not being set properly, now that the usb core | ||
29 | needs it. | ||
30 | |||
31 | (09/11/2000) gkh | ||
32 | Added usb_serial_debug_data function to help get rid of #DEBUG in the | ||
33 | drivers. | ||
34 | |||
35 | (08/28/2000) gkh | ||
36 | Added port_lock to port structure. | ||
37 | |||
38 | (08/08/2000) gkh | ||
39 | Added open_count to port structure. | ||
40 | |||
41 | (07/23/2000) gkh | ||
42 | Added bulk_out_endpointAddress to port structure. | ||
43 | |||
44 | (07/19/2000) gkh, pberger, and borchers | ||
45 | Modifications to allow usb-serial drivers to be modules. | ||
46 | |||
47 | ----------------------------------------------------------------------- | ||
48 | usb-serial.c Change Log comments: | ||
49 | |||
50 | (12/10/2002) gkh | ||
51 | Split the ports off into their own struct device, and added a | ||
52 | usb-serial bus driver. | ||
53 | |||
54 | (11/19/2002) gkh | ||
55 | removed a few #ifdefs for the generic code and cleaned up the failure | ||
56 | logic in initialization. | ||
57 | |||
58 | (10/02/2002) gkh | ||
59 | moved the console code to console.c and out of this file. | ||
60 | |||
61 | (06/05/2002) gkh | ||
62 | moved location of startup() call in serial_probe() until after all | ||
63 | of the port information and endpoints are initialized. This makes | ||
64 | things easier for some drivers. | ||
65 | |||
66 | (04/10/2002) gkh | ||
67 | added serial_read_proc function which creates a | ||
68 | /proc/tty/driver/usb-serial file. | ||
69 | |||
70 | (03/27/2002) gkh | ||
71 | Got USB serial console code working properly and merged into the main | ||
72 | version of the tree. Thanks to Randy Dunlap for the initial version | ||
73 | of this code, and for pushing me to finish it up. | ||
74 | The USB serial console works with any usb serial driver device. | ||
75 | |||
76 | (03/21/2002) gkh | ||
77 | Moved all manipulation of port->open_count into the core. Now the | ||
78 | individual driver's open and close functions are called only when the | ||
79 | first open() and last close() is called. Making the drivers a bit | ||
80 | smaller and simpler. | ||
81 | Fixed a bug if a driver didn't have the owner field set. | ||
82 | |||
83 | (02/26/2002) gkh | ||
84 | Moved all locking into the main serial_* functions, instead of having | ||
85 | the individual drivers have to grab the port semaphore. This should | ||
86 | reduce races. | ||
87 | Reworked the MOD_INC logic a bit to always increment and decrement, even | ||
88 | if the generic driver is being used. | ||
89 | |||
90 | (10/10/2001) gkh | ||
91 | usb_serial_disconnect() now sets the serial->dev pointer is to NULL to | ||
92 | help prevent child drivers from accessing the device since it is now | ||
93 | gone. | ||
94 | |||
95 | (09/13/2001) gkh | ||
96 | Moved generic driver initialize after we have registered with the USB | ||
97 | core. Thanks to Randy Dunlap for pointing this problem out. | ||
98 | |||
99 | (07/03/2001) gkh | ||
100 | Fixed module paramater size. Thanks to John Brockmeyer for the pointer. | ||
101 | Fixed vendor and product getting defined through the MODULE_PARM macro | ||
102 | if the Generic driver wasn't compiled in. | ||
103 | Fixed problem with generic_shutdown() not being called for drivers that | ||
104 | don't have a shutdown() function. | ||
105 | |||
106 | (06/06/2001) gkh | ||
107 | added evil hack that is needed for the prolific pl2303 device due to the | ||
108 | crazy way its endpoints are set up. | ||
109 | |||
110 | (05/30/2001) gkh | ||
111 | switched from using spinlock to a semaphore, which fixes lots of problems. | ||
112 | |||
113 | (04/08/2001) gb | ||
114 | Identify version on module load. | ||
115 | |||
116 | 2001_02_05 gkh | ||
117 | Fixed buffer overflows bug with the generic serial driver. Thanks to | ||
118 | Todd Squires <squirest@ct0.com> for fixing this. | ||
119 | |||
120 | (01/10/2001) gkh | ||
121 | Fixed bug where the generic serial adaptor grabbed _any_ device that was | ||
122 | offered to it. | ||
123 | |||
124 | (12/12/2000) gkh | ||
125 | Removed MOD_INC and MOD_DEC from poll and disconnect functions, and | ||
126 | moved them to the serial_open and serial_close functions. | ||
127 | Also fixed bug with there not being a MOD_DEC for the generic driver | ||
128 | (thanks to Gary Brubaker for finding this.) | ||
129 | |||
130 | (11/29/2000) gkh | ||
131 | Small NULL pointer initialization cleanup which saves a bit of disk image | ||
132 | |||
133 | (11/01/2000) Adam J. Richter | ||
134 | instead of using idVendor/idProduct pairs, usb serial drivers | ||
135 | now identify their hardware interest with usb_device_id tables, | ||
136 | which they usually have anyhow for use with MODULE_DEVICE_TABLE. | ||
137 | |||
138 | (10/05/2000) gkh | ||
139 | Fixed bug with urb->dev not being set properly, now that the usb | ||
140 | core needs it. | ||
141 | |||
142 | (09/11/2000) gkh | ||
143 | Removed DEBUG #ifdefs with call to usb_serial_debug_data | ||
144 | |||
145 | (08/28/2000) gkh | ||
146 | Added port_lock to port structure. | ||
147 | Added locks for SMP safeness to generic driver | ||
148 | Fixed the ability to open a generic device's port more than once. | ||
149 | |||
150 | (07/23/2000) gkh | ||
151 | Added bulk_out_endpointAddress to port structure. | ||
152 | |||
153 | (07/19/2000) gkh, pberger, and borchers | ||
154 | Modifications to allow usb-serial drivers to be modules. | ||
155 | |||
156 | (07/03/2000) gkh | ||
157 | Added more debugging to serial_ioctl call | ||
158 | |||
159 | (06/25/2000) gkh | ||
160 | Changed generic_write_bulk_callback to not call wake_up_interruptible | ||
161 | directly, but to have port_softint do it at a safer time. | ||
162 | |||
163 | (06/23/2000) gkh | ||
164 | Cleaned up debugging statements in a quest to find UHCI timeout bug. | ||
165 | |||
166 | (05/22/2000) gkh | ||
167 | Changed the makefile, enabling the big CONFIG_USB_SERIAL_SOMTHING to be | ||
168 | removed from the individual device source files. | ||
169 | |||
170 | (05/03/2000) gkh | ||
171 | Added the Digi Acceleport driver from Al Borchers and Peter Berger. | ||
172 | |||
173 | (05/02/2000) gkh | ||
174 | Changed devfs and tty register code to work properly now. This was based on | ||
175 | the ACM driver changes by Vojtech Pavlik. | ||
176 | |||
177 | (04/27/2000) Ryan VanderBijl | ||
178 | Put calls to *_paranoia_checks into one function. | ||
179 | |||
180 | (04/23/2000) gkh | ||
181 | Fixed bug that Randy Dunlap found for Generic devices with no bulk out ports. | ||
182 | Moved when the startup code printed out the devices that are supported. | ||
183 | |||
184 | (04/19/2000) gkh | ||
185 | Added driver for ZyXEL omni.net lcd plus ISDN TA | ||
186 | Made startup info message specify which drivers were compiled in. | ||
187 | |||
188 | (04/03/2000) gkh | ||
189 | Changed the probe process to remove the module unload races. | ||
190 | Changed where the tty layer gets initialized to have devfs work nicer. | ||
191 | Added initial devfs support. | ||
192 | |||
193 | (03/26/2000) gkh | ||
194 | Split driver up into device specific pieces. | ||
195 | |||
196 | (03/19/2000) gkh | ||
197 | Fixed oops that could happen when device was removed while a program | ||
198 | was talking to the device. | ||
199 | Removed the static urbs and now all urbs are created and destroyed | ||
200 | dynamically. | ||
201 | Reworked the internal interface. Now everything is based on the | ||
202 | usb_serial_port structure instead of the larger usb_serial structure. | ||
203 | This fixes the bug that a multiport device could not have more than | ||
204 | one port open at one time. | ||
205 | |||
206 | (03/17/2000) gkh | ||
207 | Added config option for debugging messages. | ||
208 | Added patch for keyspan pda from Brian Warner. | ||
209 | |||
210 | (03/06/2000) gkh | ||
211 | Added the keyspan pda code from Brian Warner <warner@lothar.com> | ||
212 | Moved a bunch of the port specific stuff into its own structure. This | ||
213 | is in anticipation of the true multiport devices (there's a bug if you | ||
214 | try to access more than one port of any multiport device right now) | ||
215 | |||
216 | (02/21/2000) gkh | ||
217 | Made it so that any serial devices only have to specify which functions | ||
218 | they want to overload from the generic function calls (great, | ||
219 | inheritance in C, in a driver, just what I wanted...) | ||
220 | Added support for set_termios and ioctl function calls. No drivers take | ||
221 | advantage of this yet. | ||
222 | Removed the #ifdef MODULE, now there is no module specific code. | ||
223 | Cleaned up a few comments in usb-serial.h that were wrong (thanks again | ||
224 | to Miles Lott). | ||
225 | Small fix to get_free_serial. | ||
226 | |||
227 | (02/14/2000) gkh | ||
228 | Removed the Belkin and Peracom functionality from the driver due to | ||
229 | the lack of support from the vendor, and me not wanting people to | ||
230 | accidenatly buy the device, expecting it to work with Linux. | ||
231 | Added read_bulk_callback and write_bulk_callback to the type structure | ||
232 | for the needs of the FTDI and WhiteHEAT driver. | ||
233 | Changed all reverences to FTDI to FTDI_SIO at the request of Bill | ||
234 | Ryder. | ||
235 | Changed the output urb size back to the max endpoint size to make | ||
236 | the ftdi_sio driver have it easier, and due to the fact that it didn't | ||
237 | really increase the speed any. | ||
238 | |||
239 | (02/11/2000) gkh | ||
240 | Added VISOR_FUNCTION_CONSOLE to the visor startup function. This was a | ||
241 | patch from Miles Lott (milos@insync.net). | ||
242 | Fixed bug with not restoring the minor range that a device grabs, if | ||
243 | the startup function fails (thanks Miles for finding this). | ||
244 | |||
245 | (02/05/2000) gkh | ||
246 | Added initial framework for the Keyspan PDA serial converter so that | ||
247 | Brian Warner has a place to put his code. | ||
248 | Made the ezusb specific functions generic enough that different | ||
249 | devices can use them (whiteheat and keyspan_pda both need them). | ||
250 | Split out a whole bunch of structure and other stuff to a separate | ||
251 | usb-serial.h file. | ||
252 | Made the Visor connection messages a little more understandable, now | ||
253 | that Miles Lott (milos@insync.net) has gotten the Generic channel to | ||
254 | work. Also made them always show up in the log file. | ||
255 | |||
256 | (01/25/2000) gkh | ||
257 | Added initial framework for FTDI serial converter so that Bill Ryder | ||
258 | has a place to put his code. | ||
259 | Added the vendor specific info from Handspring. Now we can print out | ||
260 | informational debug messages as well as understand what is happening. | ||
261 | |||
262 | (01/23/2000) gkh | ||
263 | Fixed problem of crash when trying to open a port that didn't have a | ||
264 | device assigned to it. Made the minor node finding a little smarter, | ||
265 | now it looks to find a continuous space for the new device. | ||
266 | |||
267 | (01/21/2000) gkh | ||
268 | Fixed bug in visor_startup with patch from Miles Lott (milos@insync.net) | ||
269 | Fixed get_serial_by_minor which was all messed up for multi port | ||
270 | devices. Fixed multi port problem for generic devices. Now the number | ||
271 | of ports is determined by the number of bulk out endpoints for the | ||
272 | generic device. | ||
273 | |||
274 | (01/19/2000) gkh | ||
275 | Removed lots of cruft that was around from the old (pre urb) driver | ||
276 | interface. | ||
277 | Made the serial_table dynamic. This should save lots of memory when | ||
278 | the number of minor nodes goes up to 256. | ||
279 | Added initial support for devices that have more than one port. | ||
280 | Added more debugging comments for the Visor, and added a needed | ||
281 | set_configuration call. | ||
282 | |||
283 | (01/17/2000) gkh | ||
284 | Fixed the WhiteHEAT firmware (my processing tool had a bug) | ||
285 | and added new debug loader firmware for it. | ||
286 | Removed the put_char function as it isn't really needed. | ||
287 | Added visor startup commands as found by the Win98 dump. | ||
288 | |||
289 | (01/13/2000) gkh | ||
290 | Fixed the vendor id for the generic driver to the one I meant it to be. | ||
291 | |||
292 | (01/12/2000) gkh | ||
293 | Forget the version numbering...that's pretty useless... | ||
294 | Made the driver able to be compiled so that the user can select which | ||
295 | converter they want to use. This allows people who only want the Visor | ||
296 | support to not pay the memory size price of the WhiteHEAT. | ||
297 | Fixed bug where the generic driver (idVendor=0000 and idProduct=0000) | ||
298 | grabbed the root hub. Not good. | ||
299 | |||
300 | version 0.4.0 (01/10/2000) gkh | ||
301 | Added whiteheat.h containing the firmware for the ConnectTech WhiteHEAT | ||
302 | device. Added startup function to allow firmware to be downloaded to | ||
303 | a device if it needs to be. | ||
304 | Added firmware download logic to the WhiteHEAT device. | ||
305 | Started to add #defines to split up the different drivers for potential | ||
306 | configuration option. | ||
307 | |||
308 | version 0.3.1 (12/30/99) gkh | ||
309 | Fixed problems with urb for bulk out. | ||
310 | Added initial support for multiple sets of endpoints. This enables | ||
311 | the Handspring Visor to be attached successfully. Only the first | ||
312 | bulk in / bulk out endpoint pair is being used right now. | ||
313 | |||
314 | version 0.3.0 (12/27/99) gkh | ||
315 | Added initial support for the Handspring Visor based on a patch from | ||
316 | Miles Lott (milos@sneety.insync.net) | ||
317 | Cleaned up the code a bunch and converted over to using urbs only. | ||
318 | |||
319 | version 0.2.3 (12/21/99) gkh | ||
320 | Added initial support for the Connect Tech WhiteHEAT converter. | ||
321 | Incremented the number of ports in expectation of getting the | ||
322 | WhiteHEAT to work properly (4 ports per connection). | ||
323 | Added notification on insertion and removal of what port the | ||
324 | device is/was connected to (and what kind of device it was). | ||
325 | |||
326 | version 0.2.2 (12/16/99) gkh | ||
327 | Changed major number to the new allocated number. We're legal now! | ||
328 | |||
329 | version 0.2.1 (12/14/99) gkh | ||
330 | Fixed bug that happens when device node is opened when there isn't a | ||
331 | device attached to it. Thanks to marek@webdesign.no for noticing this. | ||
332 | |||
333 | version 0.2.0 (11/10/99) gkh | ||
334 | Split up internals to make it easier to add different types of serial | ||
335 | converters to the code. | ||
336 | Added a "generic" driver that gets it's vendor and product id | ||
337 | from when the module is loaded. Thanks to David E. Nelson (dnelson@jump.net) | ||
338 | for the idea and sample code (from the usb scanner driver.) | ||
339 | Cleared up any licensing questions by releasing it under the GNU GPL. | ||
340 | |||
341 | version 0.1.2 (10/25/99) gkh | ||
342 | Fixed bug in detecting device. | ||
343 | |||
344 | version 0.1.1 (10/05/99) gkh | ||
345 | Changed the major number to not conflict with anything else. | ||
346 | |||
347 | version 0.1 (09/28/99) gkh | ||
348 | Can recognize the two different devices and start up a read from | ||
349 | device when asked to. Writes also work. No control signals yet, this | ||
350 | all is vendor specific data (i.e. no spec), also no control for | ||
351 | different baud rates or other bit settings. | ||
352 | Currently we are using the same devid as the acm driver. This needs | ||
353 | to change. | ||
354 | |||
355 | ----------------------------------------------------------------------- | ||
356 | visor.c Change Log comments: | ||
357 | |||
358 | (06/03/2003) Judd Montgomery <judd at jpilot.org> | ||
359 | Added support for module parameter options for untested/unknown | ||
360 | devices. | ||
361 | |||
362 | (03/09/2003) gkh | ||
363 | Added support for the Sony Clie NZ90V device. Thanks to Martin Brachtl | ||
364 | <brachtl@redgrep.cz> for the information. | ||
365 | |||
366 | (03/05/2003) gkh | ||
367 | Think Treo support is now working. | ||
368 | |||
369 | (04/03/2002) gkh | ||
370 | Added support for the Sony OS 4.1 devices. Thanks to Hiroyuki ARAKI | ||
371 | <hiro@zob.ne.jp> for the information. | ||
372 | |||
373 | (03/27/2002) gkh | ||
374 | Removed assumptions that port->tty was always valid (is not true | ||
375 | for usb serial console devices.) | ||
376 | |||
377 | (03/23/2002) gkh | ||
378 | Added support for the Palm i705 device, thanks to Thomas Riemer | ||
379 | <tom@netmech.com> for the information. | ||
380 | |||
381 | (03/21/2002) gkh | ||
382 | Added support for the Palm m130 device, thanks to Udo Eisenbarth | ||
383 | <udo.eisenbarth@web.de> for the information. | ||
384 | |||
385 | (02/27/2002) gkh | ||
386 | Reworked the urb handling logic. We have no more pool, but dynamically | ||
387 | allocate the urb and the transfer buffer on the fly. In testing this | ||
388 | does not incure any measurable overhead. This also relies on the fact | ||
389 | that we have proper reference counting logic for urbs. | ||
390 | |||
391 | (02/21/2002) SilaS | ||
392 | Added initial support for the Palm m515 devices. | ||
393 | |||
394 | (02/14/2002) gkh | ||
395 | Added support for the Clie S-360 device. | ||
396 | |||
397 | (12/18/2001) gkh | ||
398 | Added better Clie support for 3.5 devices. Thanks to Geoffrey Levand | ||
399 | for the patch. | ||
400 | |||
401 | (11/11/2001) gkh | ||
402 | Added support for the m125 devices, and added check to prevent oopses | ||
403 | for Clié devices that lie about the number of ports they have. | ||
404 | |||
405 | (08/30/2001) gkh | ||
406 | Added support for the Clie devices, both the 3.5 and 4.0 os versions. | ||
407 | Many thanks to Daniel Burke, and Bryan Payne for helping with this. | ||
408 | |||
409 | (08/23/2001) gkh | ||
410 | fixed a few potential bugs pointed out by Oliver Neukum. | ||
411 | |||
412 | (05/30/2001) gkh | ||
413 | switched from using spinlock to a semaphore, which fixes lots of problems. | ||
414 | |||
415 | (05/28/2000) gkh | ||
416 | Added initial support for the Palm m500 and Palm m505 devices. | ||
417 | |||
418 | (04/08/2001) gb | ||
419 | Identify version on module load. | ||
420 | |||
421 | (01/21/2000) gkh | ||
422 | Added write_room and chars_in_buffer, as they were previously using the | ||
423 | generic driver versions which is all wrong now that we are using an urb | ||
424 | pool. Thanks to Wolfgang Grandegger for pointing this out to me. | ||
425 | Removed count assignment in the write function, which was not needed anymore | ||
426 | either. Thanks to Al Borchers for pointing this out. | ||
427 | |||
428 | (12/12/2000) gkh | ||
429 | Moved MOD_DEC to end of visor_close to be nicer, as the final write | ||
430 | message can sleep. | ||
431 | |||
432 | (11/12/2000) gkh | ||
433 | Fixed bug with data being dropped on the floor by forcing tty->low_latency | ||
434 | to be on. Hopefully this fixes the OHCI issue! | ||
435 | |||
436 | (11/01/2000) Adam J. Richter | ||
437 | usb_device_id table support | ||
438 | |||
439 | (10/05/2000) gkh | ||
440 | Fixed bug with urb->dev not being set properly, now that the usb | ||
441 | core needs it. | ||
442 | |||
443 | (09/11/2000) gkh | ||
444 | Got rid of always calling kmalloc for every urb we wrote out to the | ||
445 | device. | ||
446 | Added visor_read_callback so we can keep track of bytes in and out for | ||
447 | those people who like to know the speed of their device. | ||
448 | Removed DEBUG #ifdefs with call to usb_serial_debug_data | ||
449 | |||
450 | (09/06/2000) gkh | ||
451 | Fixed oops in visor_exit. Need to uncomment usb_unlink_urb call _after_ | ||
452 | the host controller drivers set urb->dev = NULL when the urb is finished. | ||
453 | |||
454 | (08/28/2000) gkh | ||
455 | Added locks for SMP safeness. | ||
456 | |||
457 | (08/08/2000) gkh | ||
458 | Fixed endian problem in visor_startup. | ||
459 | Fixed MOD_INC and MOD_DEC logic and the ability to open a port more | ||
460 | than once. | ||
461 | |||
462 | (07/23/2000) gkh | ||
463 | Added pool of write urbs to speed up transfers to the visor. | ||
464 | |||
465 | (07/19/2000) gkh | ||
466 | Added module_init and module_exit functions to handle the fact that this | ||
467 | driver is a loadable module now. | ||
468 | |||
469 | (07/03/2000) gkh | ||
470 | Added visor_set_ioctl and visor_set_termios functions (they don't do much | ||
471 | of anything, but are good for debugging.) | ||
472 | |||
473 | (06/25/2000) gkh | ||
474 | Fixed bug in visor_unthrottle that should help with the disconnect in PPP | ||
475 | bug that people have been reporting. | ||
476 | |||
477 | (06/23/2000) gkh | ||
478 | Cleaned up debugging statements in a quest to find UHCI timeout bug. | ||
479 | |||
480 | (04/27/2000) Ryan VanderBijl | ||
481 | Fixed memory leak in visor_close | ||
482 | |||
483 | (03/26/2000) gkh | ||
484 | Split driver up into device specific pieces. | ||
485 | |||
486 | ----------------------------------------------------------------------- | ||
487 | pl2303.c Change Log comments: | ||
488 | |||
489 | 2002_Mar_26 gkh | ||
490 | allowed driver to work properly if there is no tty assigned to a port | ||
491 | (this happens for serial console devices.) | ||
492 | |||
493 | 2001_Oct_06 gkh | ||
494 | Added RTS and DTR line control. Thanks to joe@bndlg.de for parts of it. | ||
495 | |||
496 | 2001_Sep_19 gkh | ||
497 | Added break support. | ||
498 | |||
499 | 2001_Aug_30 gkh | ||
500 | fixed oops in write_bulk_callback. | ||
501 | |||
502 | 2001_Aug_28 gkh | ||
503 | reworked buffer logic to be like other usb-serial drivers. Hopefully | ||
504 | removing some reported problems. | ||
505 | |||
506 | 2001_Jun_06 gkh | ||
507 | finished porting to 2.4 format. | ||
508 | |||
509 | |||
510 | ----------------------------------------------------------------------- | ||
511 | io_edgeport.c Change Log comments: | ||
512 | |||
513 | 2003_04_03 al borchers | ||
514 | - fixed a bug (that shows up with dosemu) where the tty struct is | ||
515 | used in a callback after it has been freed | ||
516 | |||
517 | 2.3 2002_03_08 greg kroah-hartman | ||
518 | - fixed bug when multiple devices were attached at the same time. | ||
519 | |||
520 | 2.2 2001_11_14 greg kroah-hartman | ||
521 | - fixed bug in edge_close that kept the port from being used more | ||
522 | than once. | ||
523 | - fixed memory leak on device removal. | ||
524 | - fixed potential double free of memory when command urb submitting | ||
525 | failed. | ||
526 | - other small cleanups when the device is removed | ||
527 | |||
528 | 2.1 2001_07_09 greg kroah-hartman | ||
529 | - added support for TIOCMBIS and TIOCMBIC. | ||
530 | |||
531 | (04/08/2001) gb | ||
532 | - Identify version on module load. | ||
533 | |||
534 | 2.0 2001_03_05 greg kroah-hartman | ||
535 | - reworked entire driver to fit properly in with the other usb-serial | ||
536 | drivers. Occasional oopses still happen, but it's a good start. | ||
537 | |||
538 | 1.2.3 (02/23/2001) greg kroah-hartman | ||
539 | - changed device table to work properly for 2.4.x final format. | ||
540 | - fixed problem with dropping data at high data rates. | ||
541 | |||
542 | 1.2.2 (11/27/2000) greg kroah-hartman | ||
543 | - cleaned up more NTisms. | ||
544 | - Added device table for 2.4.0-test11 | ||
545 | |||
546 | 1.2.1 (11/08/2000) greg kroah-hartman | ||
547 | - Started to clean up NTisms. | ||
548 | - Fixed problem with dev field of urb for kernels >= 2.4.0-test9 | ||
549 | |||
550 | 1.2 (10/17/2000) David Iacovelli | ||
551 | Remove all EPIC code and GPL source | ||
552 | Fix RELEVANT_IFLAG macro to include flow control | ||
553 | changes port configuration changes. | ||
554 | Fix redefinition of SERIAL_MAGIC | ||
555 | Change all timeout values to 5 seconds | ||
556 | Tried to fix the UHCI multiple urb submission, but failed miserably. | ||
557 | it seems to work fine with OHCI. | ||
558 | ( Greg take a look at the #if 0 at end of WriteCmdUsb() we must | ||
559 | find a way to work arount this UHCI bug ) | ||
560 | |||
561 | 1.1 (10/11/2000) David Iacovelli | ||
562 | Fix XON/XOFF flow control to support both IXON and IXOFF | ||
563 | |||
564 | 0.9.27 (06/30/2000) David Iacovelli | ||
565 | Added transmit queue and now allocate urb for command writes. | ||
566 | |||
567 | 0.9.26 (06/29/2000) David Iacovelli | ||
568 | Add support for 80251 based edgeport | ||
569 | |||
570 | 0.9.25 (06/27/2000) David Iacovelli | ||
571 | Do not close the port if it has multiple opens. | ||
572 | |||
573 | 0.9.24 (05/26/2000) David Iacovelli | ||
574 | Add IOCTLs to support RXTX and JAVA POS | ||
575 | and first cut at running BlackBox Demo | ||
576 | |||
577 | 0.9.23 (05/24/2000) David Iacovelli | ||
578 | Add IOCTLs to support RXTX and JAVA POS | ||
579 | |||
580 | 0.9.22 (05/23/2000) David Iacovelli | ||
581 | fixed bug in enumeration. If epconfig turns on mapping by | ||
582 | path after a device is already plugged in, we now update | ||
583 | the mapping correctly | ||
584 | |||
585 | 0.9.21 (05/16/2000) David Iacovelli | ||
586 | Added BlockUntilChaseResp() to also wait for txcredits | ||
587 | Updated the way we allocate and handle write URBs | ||
588 | Add debug code to dump buffers | ||
589 | |||
590 | 0.9.20 (05/01/2000) David Iacovelli | ||
591 | change driver to use usb/tts/ | ||
592 | |||
593 | 0.9.19 (05/01/2000) David Iacovelli | ||
594 | Update code to compile if DEBUG is off | ||
595 | |||
596 | 0.9.18 (04/28/2000) David Iacovelli | ||
597 | cleanup and test tty_register with devfs | ||
598 | |||
599 | 0.9.17 (04/27/2000) greg kroah-hartman | ||
600 | changed tty_register around to be like the way it | ||
601 | was before, but now it works properly with devfs. | ||
602 | |||
603 | 0.9.16 (04/26/2000) david iacovelli | ||
604 | Fixed bug in GetProductInfo() | ||
605 | |||
606 | 0.9.15 (04/25/2000) david iacovelli | ||
607 | Updated enumeration | ||
608 | |||
609 | 0.9.14 (04/24/2000) david iacovelli | ||
610 | Removed all config/status IOCTLS and | ||
611 | converted to using /proc/edgeport | ||
612 | still playing with devfs | ||
613 | |||
614 | 0.9.13 (04/24/2000) david iacovelli | ||
615 | Removed configuration based on ttyUSB0 | ||
616 | Added support for configuration using /prod/edgeport | ||
617 | first attempt at using devfs (not working yet!) | ||
618 | Added IOCTL to GetProductInfo() | ||
619 | Added support for custom baud rates | ||
620 | Add support for random port numbers | ||
621 | |||
622 | 0.9.12 (04/18/2000) david iacovelli | ||
623 | added additional configuration IOCTLs | ||
624 | use ttyUSB0 for configuration | ||
625 | |||
626 | 0.9.11 (04/17/2000) greg kroah-hartman | ||
627 | fixed module initialization race conditions. | ||
628 | made all urbs dynamically allocated. | ||
629 | made driver devfs compatible. now it only registers the tty device | ||
630 | when the device is actually plugged in. | ||
631 | |||
632 | 0.9.10 (04/13/2000) greg kroah-hartman | ||
633 | added proc interface framework. | ||
634 | |||
635 | 0.9.9 (04/13/2000) david iacovelli | ||
636 | added enumeration code and ioctls to configure the device | ||
637 | |||
638 | 0.9.8 (04/12/2000) david iacovelli | ||
639 | Change interrupt read start when device is plugged in | ||
640 | and stop when device is removed | ||
641 | process interrupt reads when all ports are closed | ||
642 | (keep value of rxBytesAvail consistent with the edgeport) | ||
643 | set the USB_BULK_QUEUE flag so that we can shove a bunch | ||
644 | of urbs at once down the pipe | ||
645 | |||
646 | 0.9.7 (04/10/2000) david iacovelli | ||
647 | start to add enumeration code. | ||
648 | generate serial number for epic devices | ||
649 | add support for kdb | ||
650 | |||
651 | 0.9.6 (03/30/2000) david iacovelli | ||
652 | add IOCTL to get string, manufacture, and boot descriptors | ||
653 | |||
654 | 0.9.5 (03/14/2000) greg kroah-hartman | ||
655 | more error checking added to SerialOpen to try to fix UHCI open problem | ||
656 | |||
657 | 0.9.4 (03/09/2000) greg kroah-hartman | ||
658 | added more error checking to handle oops when data is hanging | ||
659 | around and tty is abruptly closed. | ||
660 | |||
661 | 0.9.3 (03/09/2000) david iacovelli | ||
662 | Add epic support for xon/xoff chars | ||
663 | play with performance | ||
664 | |||
665 | 0.9.2 (03/08/2000) greg kroah-hartman | ||
666 | changed most "info" calls to "dbg" | ||
667 | implemented flow control properly in the termios call | ||
668 | |||
669 | 0.9.1 (03/08/2000) david iacovelli | ||
670 | added EPIC support | ||
671 | enabled bootloader update | ||
672 | |||
673 | 0.9 (03/08/2000) greg kroah-hartman | ||
674 | Release to IO networks. | ||
675 | Integrated changes that David made | ||
676 | made getting urbs for writing SMP safe | ||
677 | |||
678 | 0.8 (03/07/2000) greg kroah-hartman | ||
679 | Release to IO networks. | ||
680 | Fixed problems that were seen in code by David. | ||
681 | Now both Edgeport/4 and Edgeport/2 works properly. | ||
682 | Changed most of the functions to use port instead of serial. | ||
683 | |||
684 | 0.7 (02/27/2000) greg kroah-hartman | ||
685 | Milestone 3 release. | ||
686 | Release to IO Networks | ||
687 | ioctl for waiting on line change implemented. | ||
688 | ioctl for getting statistics implemented. | ||
689 | multiport support working. | ||
690 | lsr and msr registers are now handled properly. | ||
691 | change break now hooked up and working. | ||
692 | support for all known Edgeport devices. | ||
693 | |||
694 | 0.6 (02/22/2000) greg kroah-hartman | ||
695 | Release to IO networks. | ||
696 | CHASE is implemented correctly when port is closed. | ||
697 | SerialOpen now blocks correctly until port is fully opened. | ||
698 | |||
699 | 0.5 (02/20/2000) greg kroah-hartman | ||
700 | Release to IO networks. | ||
701 | Known problems: | ||
702 | modem status register changes are not sent on to the user | ||
703 | CHASE is not implemented when the port is closed. | ||
704 | |||
705 | 0.4 (02/16/2000) greg kroah-hartman | ||
706 | Second cut at the CeBit demo. | ||
707 | Doesn't leak memory on every write to the port | ||
708 | Still small leaks on startup. | ||
709 | Added support for Edgeport/2 and Edgeport/8 | ||
710 | |||
711 | 0.3 (02/15/2000) greg kroah-hartman | ||
712 | CeBit demo release. | ||
713 | Force the line settings to 4800, 8, 1, e for the demo. | ||
714 | Warning! This version leaks memory like crazy! | ||
715 | |||
716 | 0.2 (01/30/2000) greg kroah-hartman | ||
717 | Milestone 1 release. | ||
718 | Device is found by USB subsystem, enumerated, firmware is downloaded | ||
719 | and the descriptors are printed to the debug log, config is set, and | ||
720 | green light starts to blink. Open port works, and data can be sent | ||
721 | and received at the default settings of the UART. Loopback connector | ||
722 | and debug log confirms this. | ||
723 | |||
724 | 0.1 (01/23/2000) greg kroah-hartman | ||
725 | Initial release to help IO Networks try to set up their test system. | ||
726 | Edgeport4 is recognized, firmware is downloaded, config is set so | ||
727 | device blinks green light every 3 sec. Port is bound, but opening, | ||
728 | closing, and sending data do not work properly. | ||
729 | |||
730 | |||
diff --git a/drivers/usb/serial/aircable.c b/drivers/usb/serial/aircable.c index b43d07df4c44..123bf9155339 100644 --- a/drivers/usb/serial/aircable.c +++ b/drivers/usb/serial/aircable.c | |||
@@ -52,7 +52,7 @@ | |||
52 | #include <linux/usb.h> | 52 | #include <linux/usb.h> |
53 | #include <linux/usb/serial.h> | 53 | #include <linux/usb/serial.h> |
54 | 54 | ||
55 | static int debug; | 55 | static bool debug; |
56 | 56 | ||
57 | /* Vendor and Product ID */ | 57 | /* Vendor and Product ID */ |
58 | #define AIRCABLE_VID 0x16CA | 58 | #define AIRCABLE_VID 0x16CA |
diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c index 5cdb9d912275..69328dcfd91a 100644 --- a/drivers/usb/serial/ark3116.c +++ b/drivers/usb/serial/ark3116.c | |||
@@ -37,12 +37,12 @@ | |||
37 | #include <linux/mutex.h> | 37 | #include <linux/mutex.h> |
38 | #include <linux/spinlock.h> | 38 | #include <linux/spinlock.h> |
39 | 39 | ||
40 | static int debug; | 40 | static bool debug; |
41 | /* | 41 | /* |
42 | * Version information | 42 | * Version information |
43 | */ | 43 | */ |
44 | 44 | ||
45 | #define DRIVER_VERSION "v0.6" | 45 | #define DRIVER_VERSION "v0.7" |
46 | #define DRIVER_AUTHOR "Bart Hartgers <bart.hartgers+ark3116@gmail.com>" | 46 | #define DRIVER_AUTHOR "Bart Hartgers <bart.hartgers+ark3116@gmail.com>" |
47 | #define DRIVER_DESC "USB ARK3116 serial/IrDA driver" | 47 | #define DRIVER_DESC "USB ARK3116 serial/IrDA driver" |
48 | #define DRIVER_DEV_DESC "ARK3116 RS232/IrDA" | 48 | #define DRIVER_DEV_DESC "ARK3116 RS232/IrDA" |
@@ -380,10 +380,6 @@ static int ark3116_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
380 | goto err_out; | 380 | goto err_out; |
381 | } | 381 | } |
382 | 382 | ||
383 | /* setup termios */ | ||
384 | if (tty) | ||
385 | ark3116_set_termios(tty, port, NULL); | ||
386 | |||
387 | /* remove any data still left: also clears error state */ | 383 | /* remove any data still left: also clears error state */ |
388 | ark3116_read_reg(serial, UART_RX, buf); | 384 | ark3116_read_reg(serial, UART_RX, buf); |
389 | 385 | ||
@@ -406,6 +402,10 @@ static int ark3116_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
406 | /* enable DMA */ | 402 | /* enable DMA */ |
407 | ark3116_write_reg(port->serial, UART_FCR, UART_FCR_DMA_SELECT); | 403 | ark3116_write_reg(port->serial, UART_FCR, UART_FCR_DMA_SELECT); |
408 | 404 | ||
405 | /* setup termios */ | ||
406 | if (tty) | ||
407 | ark3116_set_termios(tty, port, NULL); | ||
408 | |||
409 | err_out: | 409 | err_out: |
410 | kfree(buf); | 410 | kfree(buf); |
411 | return result; | 411 | return result; |
diff --git a/drivers/usb/serial/belkin_sa.c b/drivers/usb/serial/belkin_sa.c index d6921fa1403c..29ffeb6279c7 100644 --- a/drivers/usb/serial/belkin_sa.c +++ b/drivers/usb/serial/belkin_sa.c | |||
@@ -20,50 +20,7 @@ | |||
20 | * TODO: | 20 | * TODO: |
21 | * -- Add true modem contol line query capability. Currently we track the | 21 | * -- Add true modem contol line query capability. Currently we track the |
22 | * states reported by the interrupt and the states we request. | 22 | * states reported by the interrupt and the states we request. |
23 | * -- Add error reporting back to application for UART error conditions. | ||
24 | * Just point me at how to implement this and I'll do it. I've put the | ||
25 | * framework in, but haven't analyzed the "tty_flip" interface yet. | ||
26 | * -- Add support for flush commands | 23 | * -- Add support for flush commands |
27 | * -- Add everything that is missing :) | ||
28 | * | ||
29 | * 27-Nov-2001 gkh | ||
30 | * compressed all the differnent device entries into 1. | ||
31 | * | ||
32 | * 30-May-2001 gkh | ||
33 | * switched from using spinlock to a semaphore, which fixes lots of | ||
34 | * problems. | ||
35 | * | ||
36 | * 08-Apr-2001 gb | ||
37 | * - Identify version on module load. | ||
38 | * | ||
39 | * 12-Mar-2001 gkh | ||
40 | * - Added support for the GoHubs GO-COM232 device which is the same as the | ||
41 | * Peracom device. | ||
42 | * | ||
43 | * 06-Nov-2000 gkh | ||
44 | * - Added support for the old Belkin and Peracom devices. | ||
45 | * - Made the port able to be opened multiple times. | ||
46 | * - Added some defaults incase the line settings are things these devices | ||
47 | * can't support. | ||
48 | * | ||
49 | * 18-Oct-2000 William Greathouse | ||
50 | * Released into the wild (linux-usb-devel) | ||
51 | * | ||
52 | * 17-Oct-2000 William Greathouse | ||
53 | * Add code to recognize firmware version and set hardware flow control | ||
54 | * appropriately. Belkin states that firmware prior to 3.05 does not | ||
55 | * operate correctly in hardware handshake mode. I have verified this | ||
56 | * on firmware 2.05 -- for both RTS and DTR input flow control, the control | ||
57 | * line is not reset. The test performed by the Belkin Win* driver is | ||
58 | * to enable hardware flow control for firmware 2.06 or greater and | ||
59 | * for 1.00 or prior. I am only enabling for 2.06 or greater. | ||
60 | * | ||
61 | * 12-Oct-2000 William Greathouse | ||
62 | * First cut at supporting Belkin USB Serial Adapter F5U103 | ||
63 | * I did not have a copy of the original work to support this | ||
64 | * adapter, so pardon any stupid mistakes. All of the information | ||
65 | * I am using to write this driver was acquired by using a modified | ||
66 | * UsbSnoop on Windows2000 and from examining the other USB drivers. | ||
67 | */ | 24 | */ |
68 | 25 | ||
69 | #include <linux/kernel.h> | 26 | #include <linux/kernel.h> |
@@ -80,7 +37,7 @@ | |||
80 | #include <linux/usb/serial.h> | 37 | #include <linux/usb/serial.h> |
81 | #include "belkin_sa.h" | 38 | #include "belkin_sa.h" |
82 | 39 | ||
83 | static int debug; | 40 | static bool debug; |
84 | 41 | ||
85 | /* | 42 | /* |
86 | * Version Information | 43 | * Version Information |
diff --git a/drivers/usb/serial/ch341.c b/drivers/usb/serial/ch341.c index 6ae1c0688b5e..5e53cc59e652 100644 --- a/drivers/usb/serial/ch341.c +++ b/drivers/usb/serial/ch341.c | |||
@@ -70,7 +70,7 @@ | |||
70 | #define CH341_NBREAK_BITS_REG2 0x40 | 70 | #define CH341_NBREAK_BITS_REG2 0x40 |
71 | 71 | ||
72 | 72 | ||
73 | static int debug; | 73 | static bool debug; |
74 | 74 | ||
75 | static const struct usb_device_id id_table[] = { | 75 | static const struct usb_device_id id_table[] = { |
76 | { USB_DEVICE(0x4348, 0x5523) }, | 76 | { USB_DEVICE(0x4348, 0x5523) }, |
@@ -335,13 +335,12 @@ static int ch341_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
335 | goto out; | 335 | goto out; |
336 | 336 | ||
337 | dbg("%s - submitting interrupt urb", __func__); | 337 | dbg("%s - submitting interrupt urb", __func__); |
338 | port->interrupt_in_urb->dev = serial->dev; | ||
339 | r = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); | 338 | r = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); |
340 | if (r) { | 339 | if (r) { |
341 | dev_err(&port->dev, "%s - failed submitting interrupt urb," | 340 | dev_err(&port->dev, "%s - failed submitting interrupt urb," |
342 | " error %d\n", __func__, r); | 341 | " error %d\n", __func__, r); |
343 | ch341_close(port); | 342 | ch341_close(port); |
344 | return -EPROTO; | 343 | goto out; |
345 | } | 344 | } |
346 | 345 | ||
347 | r = usb_serial_generic_open(tty, port); | 346 | r = usb_serial_generic_open(tty, port); |
diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c index fd67cc53545b..fba1147ed916 100644 --- a/drivers/usb/serial/cp210x.c +++ b/drivers/usb/serial/cp210x.c | |||
@@ -49,7 +49,7 @@ static void cp210x_break_ctl(struct tty_struct *, int); | |||
49 | static int cp210x_startup(struct usb_serial *); | 49 | static int cp210x_startup(struct usb_serial *); |
50 | static void cp210x_dtr_rts(struct usb_serial_port *p, int on); | 50 | static void cp210x_dtr_rts(struct usb_serial_port *p, int on); |
51 | 51 | ||
52 | static int debug; | 52 | static bool debug; |
53 | 53 | ||
54 | static const struct usb_device_id id_table[] = { | 54 | static const struct usb_device_id id_table[] = { |
55 | { USB_DEVICE(0x045B, 0x0053) }, /* Renesas RX610 RX-Stick */ | 55 | { USB_DEVICE(0x045B, 0x0053) }, /* Renesas RX610 RX-Stick */ |
@@ -92,6 +92,7 @@ static const struct usb_device_id id_table[] = { | |||
92 | { USB_DEVICE(0x10C4, 0x818B) }, /* AVIT Research USB to TTL */ | 92 | { USB_DEVICE(0x10C4, 0x818B) }, /* AVIT Research USB to TTL */ |
93 | { USB_DEVICE(0x10C4, 0x819F) }, /* MJS USB Toslink Switcher */ | 93 | { USB_DEVICE(0x10C4, 0x819F) }, /* MJS USB Toslink Switcher */ |
94 | { USB_DEVICE(0x10C4, 0x81A6) }, /* ThinkOptics WavIt */ | 94 | { USB_DEVICE(0x10C4, 0x81A6) }, /* ThinkOptics WavIt */ |
95 | { USB_DEVICE(0x10C4, 0x81A9) }, /* Multiplex RC Interface */ | ||
95 | { USB_DEVICE(0x10C4, 0x81AC) }, /* MSD Dash Hawk */ | 96 | { USB_DEVICE(0x10C4, 0x81AC) }, /* MSD Dash Hawk */ |
96 | { USB_DEVICE(0x10C4, 0x81AD) }, /* INSYS USB Modem */ | 97 | { USB_DEVICE(0x10C4, 0x81AD) }, /* INSYS USB Modem */ |
97 | { USB_DEVICE(0x10C4, 0x81C8) }, /* Lipowsky Industrie Elektronik GmbH, Baby-JTAG */ | 98 | { USB_DEVICE(0x10C4, 0x81C8) }, /* Lipowsky Industrie Elektronik GmbH, Baby-JTAG */ |
@@ -280,7 +281,10 @@ static int cp210x_get_config(struct usb_serial_port *port, u8 request, | |||
280 | dbg("%s - Unable to send config request, " | 281 | dbg("%s - Unable to send config request, " |
281 | "request=0x%x size=%d result=%d\n", | 282 | "request=0x%x size=%d result=%d\n", |
282 | __func__, request, size, result); | 283 | __func__, request, size, result); |
283 | return -EPROTO; | 284 | if (result > 0) |
285 | result = -EPROTO; | ||
286 | |||
287 | return result; | ||
284 | } | 288 | } |
285 | 289 | ||
286 | return 0; | 290 | return 0; |
@@ -331,7 +335,10 @@ static int cp210x_set_config(struct usb_serial_port *port, u8 request, | |||
331 | dbg("%s - Unable to send request, " | 335 | dbg("%s - Unable to send request, " |
332 | "request=0x%x size=%d result=%d\n", | 336 | "request=0x%x size=%d result=%d\n", |
333 | __func__, request, size, result); | 337 | __func__, request, size, result); |
334 | return -EPROTO; | 338 | if (result > 0) |
339 | result = -EPROTO; | ||
340 | |||
341 | return result; | ||
335 | } | 342 | } |
336 | 343 | ||
337 | return 0; | 344 | return 0; |
@@ -395,10 +402,11 @@ static int cp210x_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
395 | 402 | ||
396 | dbg("%s - port %d", __func__, port->number); | 403 | dbg("%s - port %d", __func__, port->number); |
397 | 404 | ||
398 | if (cp210x_set_config_single(port, CP210X_IFC_ENABLE, UART_ENABLE)) { | 405 | result = cp210x_set_config_single(port, CP210X_IFC_ENABLE, |
399 | dev_err(&port->dev, "%s - Unable to enable UART\n", | 406 | UART_ENABLE); |
400 | __func__); | 407 | if (result) { |
401 | return -EPROTO; | 408 | dev_err(&port->dev, "%s - Unable to enable UART\n", __func__); |
409 | return result; | ||
402 | } | 410 | } |
403 | 411 | ||
404 | result = usb_serial_generic_open(tty, port); | 412 | result = usb_serial_generic_open(tty, port); |
@@ -520,18 +528,13 @@ static void cp210x_get_termios_port(struct usb_serial_port *port, | |||
520 | cflag |= PARENB; | 528 | cflag |= PARENB; |
521 | break; | 529 | break; |
522 | case BITS_PARITY_MARK: | 530 | case BITS_PARITY_MARK: |
523 | dbg("%s - parity = MARK (not supported, disabling parity)", | 531 | dbg("%s - parity = MARK", __func__); |
524 | __func__); | 532 | cflag |= (PARENB|PARODD|CMSPAR); |
525 | cflag &= ~PARENB; | ||
526 | bits &= ~BITS_PARITY_MASK; | ||
527 | cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2); | ||
528 | break; | 533 | break; |
529 | case BITS_PARITY_SPACE: | 534 | case BITS_PARITY_SPACE: |
530 | dbg("%s - parity = SPACE (not supported, disabling parity)", | 535 | dbg("%s - parity = SPACE", __func__); |
531 | __func__); | 536 | cflag &= ~PARODD; |
532 | cflag &= ~PARENB; | 537 | cflag |= (PARENB|CMSPAR); |
533 | bits &= ~BITS_PARITY_MASK; | ||
534 | cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2); | ||
535 | break; | 538 | break; |
536 | default: | 539 | default: |
537 | dbg("%s - Unknown parity mode, disabling parity", __func__); | 540 | dbg("%s - Unknown parity mode, disabling parity", __func__); |
@@ -588,7 +591,6 @@ static void cp210x_set_termios(struct tty_struct *tty, | |||
588 | if (!tty) | 591 | if (!tty) |
589 | return; | 592 | return; |
590 | 593 | ||
591 | tty->termios->c_cflag &= ~CMSPAR; | ||
592 | cflag = tty->termios->c_cflag; | 594 | cflag = tty->termios->c_cflag; |
593 | old_cflag = old_termios->c_cflag; | 595 | old_cflag = old_termios->c_cflag; |
594 | baud = cp210x_quantise_baudrate(tty_get_baud_rate(tty)); | 596 | baud = cp210x_quantise_baudrate(tty_get_baud_rate(tty)); |
@@ -643,16 +645,27 @@ static void cp210x_set_termios(struct tty_struct *tty, | |||
643 | "not supported by device\n"); | 645 | "not supported by device\n"); |
644 | } | 646 | } |
645 | 647 | ||
646 | if ((cflag & (PARENB|PARODD)) != (old_cflag & (PARENB|PARODD))) { | 648 | if ((cflag & (PARENB|PARODD|CMSPAR)) != |
649 | (old_cflag & (PARENB|PARODD|CMSPAR))) { | ||
647 | cp210x_get_config(port, CP210X_GET_LINE_CTL, &bits, 2); | 650 | cp210x_get_config(port, CP210X_GET_LINE_CTL, &bits, 2); |
648 | bits &= ~BITS_PARITY_MASK; | 651 | bits &= ~BITS_PARITY_MASK; |
649 | if (cflag & PARENB) { | 652 | if (cflag & PARENB) { |
650 | if (cflag & PARODD) { | 653 | if (cflag & CMSPAR) { |
651 | bits |= BITS_PARITY_ODD; | 654 | if (cflag & PARODD) { |
652 | dbg("%s - parity = ODD", __func__); | 655 | bits |= BITS_PARITY_MARK; |
656 | dbg("%s - parity = MARK", __func__); | ||
657 | } else { | ||
658 | bits |= BITS_PARITY_SPACE; | ||
659 | dbg("%s - parity = SPACE", __func__); | ||
660 | } | ||
653 | } else { | 661 | } else { |
654 | bits |= BITS_PARITY_EVEN; | 662 | if (cflag & PARODD) { |
655 | dbg("%s - parity = EVEN", __func__); | 663 | bits |= BITS_PARITY_ODD; |
664 | dbg("%s - parity = ODD", __func__); | ||
665 | } else { | ||
666 | bits |= BITS_PARITY_EVEN; | ||
667 | dbg("%s - parity = EVEN", __func__); | ||
668 | } | ||
656 | } | 669 | } |
657 | } | 670 | } |
658 | if (cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2)) | 671 | if (cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2)) |
diff --git a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c index f744ab7a3b19..6bc3802a581a 100644 --- a/drivers/usb/serial/cyberjack.c +++ b/drivers/usb/serial/cyberjack.c | |||
@@ -43,7 +43,7 @@ | |||
43 | 43 | ||
44 | #define CYBERJACK_LOCAL_BUF_SIZE 32 | 44 | #define CYBERJACK_LOCAL_BUF_SIZE 32 |
45 | 45 | ||
46 | static int debug; | 46 | static bool debug; |
47 | 47 | ||
48 | /* | 48 | /* |
49 | * Version Information | 49 | * Version Information |
@@ -138,7 +138,6 @@ static int cyberjack_startup(struct usb_serial *serial) | |||
138 | 138 | ||
139 | for (i = 0; i < serial->num_ports; ++i) { | 139 | for (i = 0; i < serial->num_ports; ++i) { |
140 | int result; | 140 | int result; |
141 | serial->port[i]->interrupt_in_urb->dev = serial->dev; | ||
142 | result = usb_submit_urb(serial->port[i]->interrupt_in_urb, | 141 | result = usb_submit_urb(serial->port[i]->interrupt_in_urb, |
143 | GFP_KERNEL); | 142 | GFP_KERNEL); |
144 | if (result) | 143 | if (result) |
@@ -208,7 +207,6 @@ static void cyberjack_close(struct usb_serial_port *port) | |||
208 | static int cyberjack_write(struct tty_struct *tty, | 207 | static int cyberjack_write(struct tty_struct *tty, |
209 | struct usb_serial_port *port, const unsigned char *buf, int count) | 208 | struct usb_serial_port *port, const unsigned char *buf, int count) |
210 | { | 209 | { |
211 | struct usb_serial *serial = port->serial; | ||
212 | struct cyberjack_private *priv = usb_get_serial_port_data(port); | 210 | struct cyberjack_private *priv = usb_get_serial_port_data(port); |
213 | unsigned long flags; | 211 | unsigned long flags; |
214 | int result; | 212 | int result; |
@@ -221,22 +219,18 @@ static int cyberjack_write(struct tty_struct *tty, | |||
221 | return 0; | 219 | return 0; |
222 | } | 220 | } |
223 | 221 | ||
224 | spin_lock_bh(&port->lock); | 222 | if (!test_and_clear_bit(0, &port->write_urbs_free)) { |
225 | if (port->write_urb_busy) { | ||
226 | spin_unlock_bh(&port->lock); | ||
227 | dbg("%s - already writing", __func__); | 223 | dbg("%s - already writing", __func__); |
228 | return 0; | 224 | return 0; |
229 | } | 225 | } |
230 | port->write_urb_busy = 1; | ||
231 | spin_unlock_bh(&port->lock); | ||
232 | 226 | ||
233 | spin_lock_irqsave(&priv->lock, flags); | 227 | spin_lock_irqsave(&priv->lock, flags); |
234 | 228 | ||
235 | if (count+priv->wrfilled > sizeof(priv->wrbuf)) { | 229 | if (count+priv->wrfilled > sizeof(priv->wrbuf)) { |
236 | /* To much data for buffer. Reset buffer. */ | 230 | /* To much data for buffer. Reset buffer. */ |
237 | priv->wrfilled = 0; | 231 | priv->wrfilled = 0; |
238 | port->write_urb_busy = 0; | ||
239 | spin_unlock_irqrestore(&priv->lock, flags); | 232 | spin_unlock_irqrestore(&priv->lock, flags); |
233 | set_bit(0, &port->write_urbs_free); | ||
240 | return 0; | 234 | return 0; |
241 | } | 235 | } |
242 | 236 | ||
@@ -265,13 +259,7 @@ static int cyberjack_write(struct tty_struct *tty, | |||
265 | priv->wrsent = length; | 259 | priv->wrsent = length; |
266 | 260 | ||
267 | /* set up our urb */ | 261 | /* set up our urb */ |
268 | usb_fill_bulk_urb(port->write_urb, serial->dev, | 262 | port->write_urb->transfer_buffer_length = length; |
269 | usb_sndbulkpipe(serial->dev, port->bulk_out_endpointAddress), | ||
270 | port->write_urb->transfer_buffer, length, | ||
271 | ((serial->type->write_bulk_callback) ? | ||
272 | serial->type->write_bulk_callback : | ||
273 | cyberjack_write_bulk_callback), | ||
274 | port); | ||
275 | 263 | ||
276 | /* send the data out the bulk port */ | 264 | /* send the data out the bulk port */ |
277 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); | 265 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); |
@@ -283,7 +271,7 @@ static int cyberjack_write(struct tty_struct *tty, | |||
283 | priv->wrfilled = 0; | 271 | priv->wrfilled = 0; |
284 | priv->wrsent = 0; | 272 | priv->wrsent = 0; |
285 | spin_unlock_irqrestore(&priv->lock, flags); | 273 | spin_unlock_irqrestore(&priv->lock, flags); |
286 | port->write_urb_busy = 0; | 274 | set_bit(0, &port->write_urbs_free); |
287 | return 0; | 275 | return 0; |
288 | } | 276 | } |
289 | 277 | ||
@@ -351,7 +339,6 @@ static void cyberjack_read_int_callback(struct urb *urb) | |||
351 | spin_unlock(&priv->lock); | 339 | spin_unlock(&priv->lock); |
352 | 340 | ||
353 | if (!old_rdtodo) { | 341 | if (!old_rdtodo) { |
354 | port->read_urb->dev = port->serial->dev; | ||
355 | result = usb_submit_urb(port->read_urb, GFP_ATOMIC); | 342 | result = usb_submit_urb(port->read_urb, GFP_ATOMIC); |
356 | if (result) | 343 | if (result) |
357 | dev_err(&port->dev, "%s - failed resubmitting " | 344 | dev_err(&port->dev, "%s - failed resubmitting " |
@@ -362,7 +349,6 @@ static void cyberjack_read_int_callback(struct urb *urb) | |||
362 | } | 349 | } |
363 | 350 | ||
364 | resubmit: | 351 | resubmit: |
365 | port->interrupt_in_urb->dev = port->serial->dev; | ||
366 | result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); | 352 | result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); |
367 | if (result) | 353 | if (result) |
368 | dev_err(&port->dev, "usb_submit_urb(read int) failed\n"); | 354 | dev_err(&port->dev, "usb_submit_urb(read int) failed\n"); |
@@ -415,7 +401,6 @@ static void cyberjack_read_bulk_callback(struct urb *urb) | |||
415 | 401 | ||
416 | /* Continue to read if we have still urbs to do. */ | 402 | /* Continue to read if we have still urbs to do. */ |
417 | if (todo /* || (urb->actual_length==port->bulk_in_endpointAddress)*/) { | 403 | if (todo /* || (urb->actual_length==port->bulk_in_endpointAddress)*/) { |
418 | port->read_urb->dev = port->serial->dev; | ||
419 | result = usb_submit_urb(port->read_urb, GFP_ATOMIC); | 404 | result = usb_submit_urb(port->read_urb, GFP_ATOMIC); |
420 | if (result) | 405 | if (result) |
421 | dev_err(&port->dev, "%s - failed resubmitting read " | 406 | dev_err(&port->dev, "%s - failed resubmitting read " |
@@ -432,7 +417,7 @@ static void cyberjack_write_bulk_callback(struct urb *urb) | |||
432 | 417 | ||
433 | dbg("%s - port %d", __func__, port->number); | 418 | dbg("%s - port %d", __func__, port->number); |
434 | 419 | ||
435 | port->write_urb_busy = 0; | 420 | set_bit(0, &port->write_urbs_free); |
436 | if (status) { | 421 | if (status) { |
437 | dbg("%s - nonzero write bulk status received: %d", | 422 | dbg("%s - nonzero write bulk status received: %d", |
438 | __func__, status); | 423 | __func__, status); |
@@ -455,13 +440,7 @@ static void cyberjack_write_bulk_callback(struct urb *urb) | |||
455 | priv->wrsent += length; | 440 | priv->wrsent += length; |
456 | 441 | ||
457 | /* set up our urb */ | 442 | /* set up our urb */ |
458 | usb_fill_bulk_urb(port->write_urb, port->serial->dev, | 443 | port->write_urb->transfer_buffer_length = length; |
459 | usb_sndbulkpipe(port->serial->dev, port->bulk_out_endpointAddress), | ||
460 | port->write_urb->transfer_buffer, length, | ||
461 | ((port->serial->type->write_bulk_callback) ? | ||
462 | port->serial->type->write_bulk_callback : | ||
463 | cyberjack_write_bulk_callback), | ||
464 | port); | ||
465 | 444 | ||
466 | /* send the data out the bulk port */ | 445 | /* send the data out the bulk port */ |
467 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); | 446 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); |
diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c index d9906eb9d16a..3bdeafa29c24 100644 --- a/drivers/usb/serial/cypress_m8.c +++ b/drivers/usb/serial/cypress_m8.c | |||
@@ -16,32 +16,6 @@ | |||
16 | * | 16 | * |
17 | * See http://geocities.com/i0xox0i for information on this driver and the | 17 | * See http://geocities.com/i0xox0i for information on this driver and the |
18 | * earthmate usb device. | 18 | * earthmate usb device. |
19 | * | ||
20 | * Lonnie Mendez <dignome@gmail.com> | ||
21 | * 4-29-2005 | ||
22 | * Fixed problem where setting or retreiving the serial config would fail | ||
23 | * with EPIPE. Removed CRTS toggling so the driver behaves more like | ||
24 | * other usbserial adapters. Issued new interval of 1ms instead of the | ||
25 | * default 10ms. As a result, transfer speed has been substantially | ||
26 | * increased from avg. 850bps to avg. 3300bps. initial termios has also | ||
27 | * been modified. Cleaned up code and formatting issues so it is more | ||
28 | * readable. Replaced the C++ style comments. | ||
29 | * | ||
30 | * Lonnie Mendez <dignome@gmail.com> | ||
31 | * 12-15-2004 | ||
32 | * Incorporated write buffering from pl2303 driver. Fixed bug with line | ||
33 | * handling so both lines are raised in cypress_open. (was dropping rts) | ||
34 | * Various code cleanups made as well along with other misc bug fixes. | ||
35 | * | ||
36 | * Lonnie Mendez <dignome@gmail.com> | ||
37 | * 04-10-2004 | ||
38 | * Driver modified to support dynamic line settings. Various improvements | ||
39 | * and features. | ||
40 | * | ||
41 | * Neil Whelchel | ||
42 | * 10-2003 | ||
43 | * Driver first released. | ||
44 | * | ||
45 | */ | 19 | */ |
46 | 20 | ||
47 | /* Thanks to Neil Whelchel for writing the first cypress m8 implementation | 21 | /* Thanks to Neil Whelchel for writing the first cypress m8 implementation |
@@ -72,10 +46,10 @@ | |||
72 | #include "cypress_m8.h" | 46 | #include "cypress_m8.h" |
73 | 47 | ||
74 | 48 | ||
75 | static int debug; | 49 | static bool debug; |
76 | static int stats; | 50 | static bool stats; |
77 | static int interval; | 51 | static int interval; |
78 | static int unstable_bauds; | 52 | static bool unstable_bauds; |
79 | 53 | ||
80 | /* | 54 | /* |
81 | * Version Information | 55 | * Version Information |
@@ -1162,8 +1136,6 @@ static void cypress_unthrottle(struct tty_struct *tty) | |||
1162 | return; | 1136 | return; |
1163 | 1137 | ||
1164 | if (actually_throttled) { | 1138 | if (actually_throttled) { |
1165 | port->interrupt_in_urb->dev = port->serial->dev; | ||
1166 | |||
1167 | result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); | 1139 | result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); |
1168 | if (result) { | 1140 | if (result) { |
1169 | dev_err(&port->dev, "%s - failed submitting read urb, " | 1141 | dev_err(&port->dev, "%s - failed submitting read urb, " |
@@ -1352,7 +1324,6 @@ static void cypress_write_int_callback(struct urb *urb) | |||
1352 | dbg("%s - nonzero write bulk status received: %d", | 1324 | dbg("%s - nonzero write bulk status received: %d", |
1353 | __func__, status); | 1325 | __func__, status); |
1354 | port->interrupt_out_urb->transfer_buffer_length = 1; | 1326 | port->interrupt_out_urb->transfer_buffer_length = 1; |
1355 | port->interrupt_out_urb->dev = port->serial->dev; | ||
1356 | result = usb_submit_urb(port->interrupt_out_urb, GFP_ATOMIC); | 1327 | result = usb_submit_urb(port->interrupt_out_urb, GFP_ATOMIC); |
1357 | if (!result) | 1328 | if (!result) |
1358 | return; | 1329 | return; |
diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c index e92cbefc0f88..b23bebd721a1 100644 --- a/drivers/usb/serial/digi_acceleport.c +++ b/drivers/usb/serial/digi_acceleport.c | |||
@@ -13,222 +13,6 @@ | |||
13 | * | 13 | * |
14 | * Peter Berger (pberger@brimson.com) | 14 | * Peter Berger (pberger@brimson.com) |
15 | * Al Borchers (borchers@steinerpoint.com) | 15 | * Al Borchers (borchers@steinerpoint.com) |
16 | * | ||
17 | * (12/03/2001) gkh | ||
18 | * switched to using port->port.count instead of private version. | ||
19 | * Removed port->active | ||
20 | * | ||
21 | * (04/08/2001) gb | ||
22 | * Identify version on module load. | ||
23 | * | ||
24 | * (11/01/2000) Adam J. Richter | ||
25 | * usb_device_id table support | ||
26 | * | ||
27 | * (11/01/2000) pberger and borchers | ||
28 | * -- Turned off the USB_DISABLE_SPD flag for write bulk urbs--it caused | ||
29 | * USB 4 ports to hang on startup. | ||
30 | * -- Serialized access to write urbs by adding the dp_write_urb_in_use | ||
31 | * flag; otherwise, the driver caused SMP system hangs. Watching the | ||
32 | * urb status is not sufficient. | ||
33 | * | ||
34 | * (10/05/2000) gkh | ||
35 | * -- Fixed bug with urb->dev not being set properly, now that the usb | ||
36 | * core needs it. | ||
37 | * | ||
38 | * (8/8/2000) pberger and borchers | ||
39 | * -- Fixed close so that | ||
40 | * - it can timeout while waiting for transmit idle, if needed; | ||
41 | * - it ignores interrupts when flushing the port, turning | ||
42 | * of modem signalling, and so on; | ||
43 | * - it waits for the flush to really complete before returning. | ||
44 | * -- Read_bulk_callback and write_bulk_callback check for a closed | ||
45 | * port before using the tty struct or writing to the port. | ||
46 | * -- The two changes above fix the oops caused by interrupted closes. | ||
47 | * -- Added interruptible args to write_oob_command and set_modem_signals | ||
48 | * and added a timeout arg to transmit_idle; needed for fixes to | ||
49 | * close. | ||
50 | * -- Added code for rx_throttle and rx_unthrottle so that input flow | ||
51 | * control works. | ||
52 | * -- Added code to set overrun, parity, framing, and break errors | ||
53 | * (untested). | ||
54 | * -- Set USB_DISABLE_SPD flag for write bulk urbs, so no 0 length | ||
55 | * bulk writes are done. These hung the Digi USB device. The | ||
56 | * 0 length bulk writes were a new feature of usb-uhci added in | ||
57 | * the 2.4.0-test6 kernels. | ||
58 | * -- Fixed mod inc race in open; do mod inc before sleeping to wait | ||
59 | * for a close to finish. | ||
60 | * | ||
61 | * (7/31/2000) pberger | ||
62 | * -- Fixed bugs with hardware handshaking: | ||
63 | * - Added code to set/clear tty->hw_stopped in digi_read_oob_callback() | ||
64 | * and digi_set_termios() | ||
65 | * -- Added code in digi_set_termios() to | ||
66 | * - add conditional in code handling transition from B0 to only | ||
67 | * set RTS if RTS/CTS flow control is either not in use or if | ||
68 | * the port is not currently throttled. | ||
69 | * - handle turning off CRTSCTS. | ||
70 | * | ||
71 | * (7/30/2000) borchers | ||
72 | * -- Added support for more than one Digi USB device by moving | ||
73 | * globals to a private structure in the pointed to from the | ||
74 | * usb_serial structure. | ||
75 | * -- Moved the modem change and transmit idle wait queues into | ||
76 | * the port private structure, so each port has its own queue | ||
77 | * rather than sharing global queues. | ||
78 | * -- Added support for break signals. | ||
79 | * | ||
80 | * (7/25/2000) pberger | ||
81 | * -- Added USB-2 support. Note: the USB-2 supports 3 devices: two | ||
82 | * serial and a parallel port. The parallel port is implemented | ||
83 | * as a serial-to-parallel converter. That is, the driver actually | ||
84 | * presents all three USB-2 interfaces as serial ports, but the third | ||
85 | * one physically connects to a parallel device. Thus, for example, | ||
86 | * one could plug a parallel printer into the USB-2's third port, | ||
87 | * but from the kernel's (and userland's) point of view what's | ||
88 | * actually out there is a serial device. | ||
89 | * | ||
90 | * (7/15/2000) borchers | ||
91 | * -- Fixed race in open when a close is in progress. | ||
92 | * -- Keep count of opens and dec the module use count for each | ||
93 | * outstanding open when shutdown is called (on disconnect). | ||
94 | * -- Fixed sanity checks in read_bulk_callback and write_bulk_callback | ||
95 | * so pointers are checked before use. | ||
96 | * -- Split read bulk callback into in band and out of band | ||
97 | * callbacks, and no longer restart read chains if there is | ||
98 | * a status error or a sanity error. This fixed the seg | ||
99 | * faults and other errors we used to get on disconnect. | ||
100 | * -- Port->active is once again a flag as usb-serial intended it | ||
101 | * to be, not a count. Since it was only a char it would | ||
102 | * have been limited to 256 simultaneous opens. Now the open | ||
103 | * count is kept in the port private structure in dp_open_count. | ||
104 | * -- Added code for modularization of the digi_acceleport driver. | ||
105 | * | ||
106 | * (6/27/2000) pberger and borchers | ||
107 | * -- Zeroed out sync field in the wakeup_task before first use; | ||
108 | * otherwise the uninitialized value might prevent the task from | ||
109 | * being scheduled. | ||
110 | * -- Initialized ret value to 0 in write_bulk_callback, otherwise | ||
111 | * the uninitialized value could cause a spurious debugging message. | ||
112 | * | ||
113 | * (6/22/2000) pberger and borchers | ||
114 | * -- Made cond_wait_... inline--apparently on SPARC the flags arg | ||
115 | * to spin_lock_irqsave cannot be passed to another function | ||
116 | * to call spin_unlock_irqrestore. Thanks to Pauline Middelink. | ||
117 | * -- In digi_set_modem_signals the inner nested spin locks use just | ||
118 | * spin_lock() rather than spin_lock_irqsave(). The old code | ||
119 | * mistakenly left interrupts off. Thanks to Pauline Middelink. | ||
120 | * -- copy_from_user (which can sleep) is no longer called while a | ||
121 | * spinlock is held. We copy to a local buffer before getting | ||
122 | * the spinlock--don't like the extra copy but the code is simpler. | ||
123 | * -- Printk and dbg are no longer called while a spin lock is held. | ||
124 | * | ||
125 | * (6/4/2000) pberger and borchers | ||
126 | * -- Replaced separate calls to spin_unlock_irqrestore and | ||
127 | * interruptible_sleep_on_timeout with a new function | ||
128 | * cond_wait_interruptible_timeout_irqrestore. This eliminates | ||
129 | * the race condition where the wake up could happen after | ||
130 | * the unlock and before the sleep. | ||
131 | * -- Close now waits for output to drain. | ||
132 | * -- Open waits until any close in progress is finished. | ||
133 | * -- All out of band responses are now processed, not just the | ||
134 | * first in a USB packet. | ||
135 | * -- Fixed a bug that prevented the driver from working when the | ||
136 | * first Digi port was not the first USB serial port--the driver | ||
137 | * was mistakenly using the external USB serial port number to | ||
138 | * try to index into its internal ports. | ||
139 | * -- Fixed an SMP bug -- write_bulk_callback is called directly from | ||
140 | * an interrupt, so spin_lock_irqsave/spin_unlock_irqrestore are | ||
141 | * needed for locks outside write_bulk_callback that are also | ||
142 | * acquired by write_bulk_callback to prevent deadlocks. | ||
143 | * -- Fixed support for select() by making digi_chars_in_buffer() | ||
144 | * return 256 when -EINPROGRESS is set, as the line discipline | ||
145 | * code in n_tty.c expects. | ||
146 | * -- Fixed an include file ordering problem that prevented debugging | ||
147 | * messages from working. | ||
148 | * -- Fixed an intermittent timeout problem that caused writes to | ||
149 | * sometimes get stuck on some machines on some kernels. It turns | ||
150 | * out in these circumstances write_chan() (in n_tty.c) was | ||
151 | * asleep waiting for our wakeup call. Even though we call | ||
152 | * wake_up_interruptible() in digi_write_bulk_callback(), there is | ||
153 | * a race condition that could cause the wakeup to fail: if our | ||
154 | * wake_up_interruptible() call occurs between the time that our | ||
155 | * driver write routine finishes and write_chan() sets current->state | ||
156 | * to TASK_INTERRUPTIBLE, the effect of our wakeup setting the state | ||
157 | * to TASK_RUNNING will be lost and write_chan's subsequent call to | ||
158 | * schedule() will never return (unless it catches a signal). | ||
159 | * This race condition occurs because write_bulk_callback() (and thus | ||
160 | * the wakeup) are called asynchronously from an interrupt, rather than | ||
161 | * from the scheduler. We can avoid the race by calling the wakeup | ||
162 | * from the scheduler queue and that's our fix: Now, at the end of | ||
163 | * write_bulk_callback() we queue up a wakeup call on the scheduler | ||
164 | * task queue. We still also invoke the wakeup directly since that | ||
165 | * squeezes a bit more performance out of the driver, and any lost | ||
166 | * race conditions will get cleaned up at the next scheduler run. | ||
167 | * | ||
168 | * NOTE: The problem also goes away if you comment out | ||
169 | * the two code lines in write_chan() where current->state | ||
170 | * is set to TASK_RUNNING just before calling driver.write() and to | ||
171 | * TASK_INTERRUPTIBLE immediately afterwards. This is why the | ||
172 | * problem did not show up with the 2.2 kernels -- they do not | ||
173 | * include that code. | ||
174 | * | ||
175 | * (5/16/2000) pberger and borchers | ||
176 | * -- Added timeouts to sleeps, to defend against lost wake ups. | ||
177 | * -- Handle transition to/from B0 baud rate in digi_set_termios. | ||
178 | * | ||
179 | * (5/13/2000) pberger and borchers | ||
180 | * -- All commands now sent on out of band port, using | ||
181 | * digi_write_oob_command. | ||
182 | * -- Get modem control signals whenever they change, support TIOCMGET/ | ||
183 | * SET/BIS/BIC ioctls. | ||
184 | * -- digi_set_termios now supports parity, word size, stop bits, and | ||
185 | * receive enable. | ||
186 | * -- Cleaned up open and close, use digi_set_termios and | ||
187 | * digi_write_oob_command to set port parameters. | ||
188 | * -- Added digi_startup_device to start read chains on all ports. | ||
189 | * -- Write buffer is only used when count==1, to be sure put_char can | ||
190 | * write a char (unless the buffer is full). | ||
191 | * | ||
192 | * (5/10/2000) pberger and borchers | ||
193 | * -- Added MOD_INC_USE_COUNT/MOD_DEC_USE_COUNT calls on open/close. | ||
194 | * -- Fixed problem where the first incoming character is lost on | ||
195 | * port opens after the first close on that port. Now we keep | ||
196 | * the read_urb chain open until shutdown. | ||
197 | * -- Added more port conditioning calls in digi_open and digi_close. | ||
198 | * -- Convert port->active to a use count so that we can deal with multiple | ||
199 | * opens and closes properly. | ||
200 | * -- Fixed some problems with the locking code. | ||
201 | * | ||
202 | * (5/3/2000) pberger and borchers | ||
203 | * -- First alpha version of the driver--many known limitations and bugs. | ||
204 | * | ||
205 | * | ||
206 | * Locking and SMP | ||
207 | * | ||
208 | * - Each port, including the out-of-band port, has a lock used to | ||
209 | * serialize all access to the port's private structure. | ||
210 | * - The port lock is also used to serialize all writes and access to | ||
211 | * the port's URB. | ||
212 | * - The port lock is also used for the port write_wait condition | ||
213 | * variable. Holding the port lock will prevent a wake up on the | ||
214 | * port's write_wait; this can be used with cond_wait_... to be sure | ||
215 | * the wake up is not lost in a race when dropping the lock and | ||
216 | * sleeping waiting for the wakeup. | ||
217 | * - digi_write() does not sleep, since it is sometimes called on | ||
218 | * interrupt time. | ||
219 | * - digi_write_bulk_callback() and digi_read_bulk_callback() are | ||
220 | * called directly from interrupts. Hence spin_lock_irqsave() | ||
221 | * and spin_unlock_irqrestore() are used in the rest of the code | ||
222 | * for any locks they acquire. | ||
223 | * - digi_write_bulk_callback() gets the port lock before waking up | ||
224 | * processes sleeping on the port write_wait. It also schedules | ||
225 | * wake ups so they happen from the scheduler, because the tty | ||
226 | * system can miss wake ups from interrupts. | ||
227 | * - All sleeps use a timeout of DIGI_RETRY_TIMEOUT before looping to | ||
228 | * recheck the condition they are sleeping on. This is defensive, | ||
229 | * in case a wake up is lost. | ||
230 | * - Following Documentation/DocBook/kernel-locking.tmpl no spin locks | ||
231 | * are held when calling copy_to/from_user or printk. | ||
232 | */ | 16 | */ |
233 | 17 | ||
234 | #include <linux/kernel.h> | 18 | #include <linux/kernel.h> |
@@ -467,7 +251,7 @@ static int digi_read_oob_callback(struct urb *urb); | |||
467 | 251 | ||
468 | /* Statics */ | 252 | /* Statics */ |
469 | 253 | ||
470 | static int debug; | 254 | static bool debug; |
471 | 255 | ||
472 | static const struct usb_device_id id_table_combined[] = { | 256 | static const struct usb_device_id id_table_combined[] = { |
473 | { USB_DEVICE(DIGI_VENDOR_ID, DIGI_2_ID) }, | 257 | { USB_DEVICE(DIGI_VENDOR_ID, DIGI_2_ID) }, |
@@ -654,7 +438,6 @@ static int digi_write_oob_command(struct usb_serial_port *port, | |||
654 | len &= ~3; | 438 | len &= ~3; |
655 | memcpy(oob_port->write_urb->transfer_buffer, buf, len); | 439 | memcpy(oob_port->write_urb->transfer_buffer, buf, len); |
656 | oob_port->write_urb->transfer_buffer_length = len; | 440 | oob_port->write_urb->transfer_buffer_length = len; |
657 | oob_port->write_urb->dev = port->serial->dev; | ||
658 | ret = usb_submit_urb(oob_port->write_urb, GFP_ATOMIC); | 441 | ret = usb_submit_urb(oob_port->write_urb, GFP_ATOMIC); |
659 | if (ret == 0) { | 442 | if (ret == 0) { |
660 | oob_priv->dp_write_urb_in_use = 1; | 443 | oob_priv->dp_write_urb_in_use = 1; |
@@ -732,7 +515,6 @@ static int digi_write_inb_command(struct usb_serial_port *port, | |||
732 | memcpy(data, buf, len); | 515 | memcpy(data, buf, len); |
733 | port->write_urb->transfer_buffer_length = len; | 516 | port->write_urb->transfer_buffer_length = len; |
734 | } | 517 | } |
735 | port->write_urb->dev = port->serial->dev; | ||
736 | 518 | ||
737 | ret = usb_submit_urb(port->write_urb, GFP_ATOMIC); | 519 | ret = usb_submit_urb(port->write_urb, GFP_ATOMIC); |
738 | if (ret == 0) { | 520 | if (ret == 0) { |
@@ -803,7 +585,6 @@ static int digi_set_modem_signals(struct usb_serial_port *port, | |||
803 | data[7] = 0; | 585 | data[7] = 0; |
804 | 586 | ||
805 | oob_port->write_urb->transfer_buffer_length = 8; | 587 | oob_port->write_urb->transfer_buffer_length = 8; |
806 | oob_port->write_urb->dev = port->serial->dev; | ||
807 | 588 | ||
808 | ret = usb_submit_urb(oob_port->write_urb, GFP_ATOMIC); | 589 | ret = usb_submit_urb(oob_port->write_urb, GFP_ATOMIC); |
809 | if (ret == 0) { | 590 | if (ret == 0) { |
@@ -899,10 +680,8 @@ static void digi_rx_unthrottle(struct tty_struct *tty) | |||
899 | spin_lock_irqsave(&priv->dp_port_lock, flags); | 680 | spin_lock_irqsave(&priv->dp_port_lock, flags); |
900 | 681 | ||
901 | /* restart read chain */ | 682 | /* restart read chain */ |
902 | if (priv->dp_throttle_restart) { | 683 | if (priv->dp_throttle_restart) |
903 | port->read_urb->dev = port->serial->dev; | ||
904 | ret = usb_submit_urb(port->read_urb, GFP_ATOMIC); | 684 | ret = usb_submit_urb(port->read_urb, GFP_ATOMIC); |
905 | } | ||
906 | 685 | ||
907 | /* turn throttle off */ | 686 | /* turn throttle off */ |
908 | priv->dp_throttled = 0; | 687 | priv->dp_throttled = 0; |
@@ -1195,7 +974,6 @@ static int digi_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
1195 | } | 974 | } |
1196 | 975 | ||
1197 | port->write_urb->transfer_buffer_length = data_len+2; | 976 | port->write_urb->transfer_buffer_length = data_len+2; |
1198 | port->write_urb->dev = port->serial->dev; | ||
1199 | 977 | ||
1200 | *data++ = DIGI_CMD_SEND_DATA; | 978 | *data++ = DIGI_CMD_SEND_DATA; |
1201 | *data++ = data_len; | 979 | *data++ = data_len; |
@@ -1271,7 +1049,6 @@ static void digi_write_bulk_callback(struct urb *urb) | |||
1271 | = (unsigned char)priv->dp_out_buf_len; | 1049 | = (unsigned char)priv->dp_out_buf_len; |
1272 | port->write_urb->transfer_buffer_length = | 1050 | port->write_urb->transfer_buffer_length = |
1273 | priv->dp_out_buf_len + 2; | 1051 | priv->dp_out_buf_len + 2; |
1274 | port->write_urb->dev = serial->dev; | ||
1275 | memcpy(port->write_urb->transfer_buffer + 2, priv->dp_out_buf, | 1052 | memcpy(port->write_urb->transfer_buffer + 2, priv->dp_out_buf, |
1276 | priv->dp_out_buf_len); | 1053 | priv->dp_out_buf_len); |
1277 | ret = usb_submit_urb(port->write_urb, GFP_ATOMIC); | 1054 | ret = usb_submit_urb(port->write_urb, GFP_ATOMIC); |
@@ -1473,7 +1250,6 @@ static int digi_startup_device(struct usb_serial *serial) | |||
1473 | /* set USB_DISABLE_SPD flag for write bulk urbs */ | 1250 | /* set USB_DISABLE_SPD flag for write bulk urbs */ |
1474 | for (i = 0; i < serial->type->num_ports + 1; i++) { | 1251 | for (i = 0; i < serial->type->num_ports + 1; i++) { |
1475 | port = serial->port[i]; | 1252 | port = serial->port[i]; |
1476 | port->write_urb->dev = port->serial->dev; | ||
1477 | ret = usb_submit_urb(port->read_urb, GFP_KERNEL); | 1253 | ret = usb_submit_urb(port->read_urb, GFP_KERNEL); |
1478 | if (ret != 0) { | 1254 | if (ret != 0) { |
1479 | dev_err(&port->dev, | 1255 | dev_err(&port->dev, |
@@ -1616,7 +1392,6 @@ static void digi_read_bulk_callback(struct urb *urb) | |||
1616 | } | 1392 | } |
1617 | 1393 | ||
1618 | /* continue read */ | 1394 | /* continue read */ |
1619 | urb->dev = port->serial->dev; | ||
1620 | ret = usb_submit_urb(urb, GFP_ATOMIC); | 1395 | ret = usb_submit_urb(urb, GFP_ATOMIC); |
1621 | if (ret != 0 && ret != -EPERM) { | 1396 | if (ret != 0 && ret != -EPERM) { |
1622 | dev_err(&port->dev, | 1397 | dev_err(&port->dev, |
diff --git a/drivers/usb/serial/empeg.c b/drivers/usb/serial/empeg.c index 504b5585ea45..aced6817bf95 100644 --- a/drivers/usb/serial/empeg.c +++ b/drivers/usb/serial/empeg.c | |||
@@ -28,7 +28,7 @@ | |||
28 | #include <linux/usb.h> | 28 | #include <linux/usb.h> |
29 | #include <linux/usb/serial.h> | 29 | #include <linux/usb/serial.h> |
30 | 30 | ||
31 | static int debug; | 31 | static bool debug; |
32 | 32 | ||
33 | /* | 33 | /* |
34 | * Version Information | 34 | * Version Information |
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index 8fe034d2d3e7..01b6404df395 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c | |||
@@ -55,7 +55,7 @@ | |||
55 | #define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>, Bill Ryder <bryder@sgi.com>, Kuba Ober <kuba@mareimbrium.org>, Andreas Mohr, Johan Hovold <jhovold@gmail.com>" | 55 | #define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>, Bill Ryder <bryder@sgi.com>, Kuba Ober <kuba@mareimbrium.org>, Andreas Mohr, Johan Hovold <jhovold@gmail.com>" |
56 | #define DRIVER_DESC "USB FTDI Serial Converters Driver" | 56 | #define DRIVER_DESC "USB FTDI Serial Converters Driver" |
57 | 57 | ||
58 | static int debug; | 58 | static bool debug; |
59 | static __u16 vendor = FTDI_VID; | 59 | static __u16 vendor = FTDI_VID; |
60 | static __u16 product; | 60 | static __u16 product; |
61 | 61 | ||
@@ -736,6 +736,7 @@ static struct usb_device_id id_table_combined [] = { | |||
736 | { USB_DEVICE(TML_VID, TML_USB_SERIAL_PID) }, | 736 | { USB_DEVICE(TML_VID, TML_USB_SERIAL_PID) }, |
737 | { USB_DEVICE(FTDI_VID, FTDI_ELSTER_UNICOM_PID) }, | 737 | { USB_DEVICE(FTDI_VID, FTDI_ELSTER_UNICOM_PID) }, |
738 | { USB_DEVICE(FTDI_VID, FTDI_PROPOX_JTAGCABLEII_PID) }, | 738 | { USB_DEVICE(FTDI_VID, FTDI_PROPOX_JTAGCABLEII_PID) }, |
739 | { USB_DEVICE(FTDI_VID, FTDI_PROPOX_ISPCABLEIII_PID) }, | ||
739 | { USB_DEVICE(OLIMEX_VID, OLIMEX_ARM_USB_OCD_PID), | 740 | { USB_DEVICE(OLIMEX_VID, OLIMEX_ARM_USB_OCD_PID), |
740 | .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, | 741 | .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, |
741 | { USB_DEVICE(OLIMEX_VID, OLIMEX_ARM_USB_OCD_H_PID), | 742 | { USB_DEVICE(OLIMEX_VID, OLIMEX_ARM_USB_OCD_H_PID), |
@@ -2104,13 +2105,23 @@ static void ftdi_set_termios(struct tty_struct *tty, | |||
2104 | 2105 | ||
2105 | cflag = termios->c_cflag; | 2106 | cflag = termios->c_cflag; |
2106 | 2107 | ||
2107 | /* FIXME -For this cut I don't care if the line is really changing or | 2108 | if (old_termios == 0) |
2108 | not - so just do the change regardless - should be able to | 2109 | goto no_skip; |
2109 | compare old_termios and tty->termios */ | 2110 | |
2111 | if (old_termios->c_cflag == termios->c_cflag | ||
2112 | && old_termios->c_ispeed == termios->c_ispeed | ||
2113 | && old_termios->c_ospeed == termios->c_ospeed) | ||
2114 | goto no_c_cflag_changes; | ||
2115 | |||
2110 | /* NOTE These routines can get interrupted by | 2116 | /* NOTE These routines can get interrupted by |
2111 | ftdi_sio_read_bulk_callback - need to examine what this means - | 2117 | ftdi_sio_read_bulk_callback - need to examine what this means - |
2112 | don't see any problems yet */ | 2118 | don't see any problems yet */ |
2113 | 2119 | ||
2120 | if ((old_termios->c_cflag & (CSIZE|PARODD|PARENB|CMSPAR|CSTOPB)) == | ||
2121 | (termios->c_cflag & (CSIZE|PARODD|PARENB|CMSPAR|CSTOPB))) | ||
2122 | goto no_data_parity_stop_changes; | ||
2123 | |||
2124 | no_skip: | ||
2114 | /* Set number of data bits, parity, stop bits */ | 2125 | /* Set number of data bits, parity, stop bits */ |
2115 | 2126 | ||
2116 | urb_value = 0; | 2127 | urb_value = 0; |
@@ -2151,6 +2162,7 @@ static void ftdi_set_termios(struct tty_struct *tty, | |||
2151 | } | 2162 | } |
2152 | 2163 | ||
2153 | /* Now do the baudrate */ | 2164 | /* Now do the baudrate */ |
2165 | no_data_parity_stop_changes: | ||
2154 | if ((cflag & CBAUD) == B0) { | 2166 | if ((cflag & CBAUD) == B0) { |
2155 | /* Disable flow control */ | 2167 | /* Disable flow control */ |
2156 | if (usb_control_msg(dev, usb_sndctrlpipe(dev, 0), | 2168 | if (usb_control_msg(dev, usb_sndctrlpipe(dev, 0), |
@@ -2178,6 +2190,7 @@ static void ftdi_set_termios(struct tty_struct *tty, | |||
2178 | 2190 | ||
2179 | /* Set flow control */ | 2191 | /* Set flow control */ |
2180 | /* Note device also supports DTR/CD (ugh) and Xon/Xoff in hardware */ | 2192 | /* Note device also supports DTR/CD (ugh) and Xon/Xoff in hardware */ |
2193 | no_c_cflag_changes: | ||
2181 | if (cflag & CRTSCTS) { | 2194 | if (cflag & CRTSCTS) { |
2182 | dbg("%s Setting to CRTSCTS flow control", __func__); | 2195 | dbg("%s Setting to CRTSCTS flow control", __func__); |
2183 | if (usb_control_msg(dev, | 2196 | if (usb_control_msg(dev, |
diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h index 571fa96b49c7..df1d7da933ec 100644 --- a/drivers/usb/serial/ftdi_sio_ids.h +++ b/drivers/usb/serial/ftdi_sio_ids.h | |||
@@ -2,7 +2,7 @@ | |||
2 | * vendor/product IDs (VID/PID) of devices using FTDI USB serial converters. | 2 | * vendor/product IDs (VID/PID) of devices using FTDI USB serial converters. |
3 | * Please keep numerically sorted within individual areas, thanks! | 3 | * Please keep numerically sorted within individual areas, thanks! |
4 | * | 4 | * |
5 | * Philipp Gühring - pg@futureware.at - added the Device ID of the USB relais | 5 | * Philipp Gühring - pg@futureware.at - added the Device ID of the USB relais |
6 | * from Rudolf Gugler | 6 | * from Rudolf Gugler |
7 | * | 7 | * |
8 | */ | 8 | */ |
@@ -78,7 +78,7 @@ | |||
78 | */ | 78 | */ |
79 | #define FTDI_ASK_RDR400_PID 0xC991 /* ASK RDR 400 series card reader */ | 79 | #define FTDI_ASK_RDR400_PID 0xC991 /* ASK RDR 400 series card reader */ |
80 | 80 | ||
81 | /* www.starting-point-systems.com µChameleon device */ | 81 | /* www.starting-point-systems.com µChameleon device */ |
82 | #define FTDI_MICRO_CHAMELEON_PID 0xCAA0 /* Product Id */ | 82 | #define FTDI_MICRO_CHAMELEON_PID 0xCAA0 /* Product Id */ |
83 | 83 | ||
84 | /* | 84 | /* |
@@ -112,6 +112,7 @@ | |||
112 | 112 | ||
113 | /* Propox devices */ | 113 | /* Propox devices */ |
114 | #define FTDI_PROPOX_JTAGCABLEII_PID 0xD738 | 114 | #define FTDI_PROPOX_JTAGCABLEII_PID 0xD738 |
115 | #define FTDI_PROPOX_ISPCABLEIII_PID 0xD739 | ||
115 | 116 | ||
116 | /* Lenz LI-USB Computer Interface. */ | 117 | /* Lenz LI-USB Computer Interface. */ |
117 | #define FTDI_LENZ_LIUSB_PID 0xD780 | 118 | #define FTDI_LENZ_LIUSB_PID 0xD780 |
@@ -290,7 +291,7 @@ | |||
290 | 291 | ||
291 | /* | 292 | /* |
292 | * Teratronik product ids. | 293 | * Teratronik product ids. |
293 | * Submitted by O. Wölfelschneider. | 294 | * Submitted by O. Wölfelschneider. |
294 | */ | 295 | */ |
295 | #define FTDI_TERATRONIK_VCP_PID 0xEC88 /* Teratronik device (preferring VCP driver on windows) */ | 296 | #define FTDI_TERATRONIK_VCP_PID 0xEC88 /* Teratronik device (preferring VCP driver on windows) */ |
296 | #define FTDI_TERATRONIK_D2XX_PID 0xEC89 /* Teratronik device (preferring D2XX driver on windows) */ | 297 | #define FTDI_TERATRONIK_D2XX_PID 0xEC89 /* Teratronik device (preferring D2XX driver on windows) */ |
diff --git a/drivers/usb/serial/funsoft.c b/drivers/usb/serial/funsoft.c index e21ce9ddfc63..5d4b099dcf8b 100644 --- a/drivers/usb/serial/funsoft.c +++ b/drivers/usb/serial/funsoft.c | |||
@@ -16,7 +16,7 @@ | |||
16 | #include <linux/usb/serial.h> | 16 | #include <linux/usb/serial.h> |
17 | #include <linux/uaccess.h> | 17 | #include <linux/uaccess.h> |
18 | 18 | ||
19 | static int debug; | 19 | static bool debug; |
20 | 20 | ||
21 | static const struct usb_device_id id_table[] = { | 21 | static const struct usb_device_id id_table[] = { |
22 | { USB_DEVICE(0x1404, 0xcddc) }, | 22 | { USB_DEVICE(0x1404, 0xcddc) }, |
diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c index 1a49ca9c8ea5..21343378c322 100644 --- a/drivers/usb/serial/garmin_gps.c +++ b/drivers/usb/serial/garmin_gps.c | |||
@@ -42,7 +42,7 @@ | |||
42 | static int initial_mode = 1; | 42 | static int initial_mode = 1; |
43 | 43 | ||
44 | /* debug flag */ | 44 | /* debug flag */ |
45 | static int debug; | 45 | static bool debug; |
46 | 46 | ||
47 | #define GARMIN_VENDOR_ID 0x091E | 47 | #define GARMIN_VENDOR_ID 0x091E |
48 | 48 | ||
@@ -901,7 +901,6 @@ static int garmin_init_session(struct usb_serial_port *port) | |||
901 | usb_kill_urb(port->interrupt_in_urb); | 901 | usb_kill_urb(port->interrupt_in_urb); |
902 | 902 | ||
903 | dbg("%s - adding interrupt input", __func__); | 903 | dbg("%s - adding interrupt input", __func__); |
904 | port->interrupt_in_urb->dev = serial->dev; | ||
905 | status = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); | 904 | status = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); |
906 | if (status) | 905 | if (status) |
907 | dev_err(&serial->dev->dev, | 906 | dev_err(&serial->dev->dev, |
@@ -1277,7 +1276,6 @@ static void garmin_read_int_callback(struct urb *urb) | |||
1277 | unsigned long flags; | 1276 | unsigned long flags; |
1278 | int retval; | 1277 | int retval; |
1279 | struct usb_serial_port *port = urb->context; | 1278 | struct usb_serial_port *port = urb->context; |
1280 | struct usb_serial *serial = port->serial; | ||
1281 | struct garmin_data *garmin_data_p = usb_get_serial_port_data(port); | 1279 | struct garmin_data *garmin_data_p = usb_get_serial_port_data(port); |
1282 | unsigned char *data = urb->transfer_buffer; | 1280 | unsigned char *data = urb->transfer_buffer; |
1283 | int status = urb->status; | 1281 | int status = urb->status; |
@@ -1311,12 +1309,6 @@ static void garmin_read_int_callback(struct urb *urb) | |||
1311 | if (0 == (garmin_data_p->flags & FLAGS_BULK_IN_ACTIVE)) { | 1309 | if (0 == (garmin_data_p->flags & FLAGS_BULK_IN_ACTIVE)) { |
1312 | 1310 | ||
1313 | /* bulk data available */ | 1311 | /* bulk data available */ |
1314 | usb_fill_bulk_urb(port->read_urb, serial->dev, | ||
1315 | usb_rcvbulkpipe(serial->dev, | ||
1316 | port->bulk_in_endpointAddress), | ||
1317 | port->read_urb->transfer_buffer, | ||
1318 | port->read_urb->transfer_buffer_length, | ||
1319 | garmin_read_bulk_callback, port); | ||
1320 | retval = usb_submit_urb(port->read_urb, GFP_ATOMIC); | 1312 | retval = usb_submit_urb(port->read_urb, GFP_ATOMIC); |
1321 | if (retval) { | 1313 | if (retval) { |
1322 | dev_err(&port->dev, | 1314 | dev_err(&port->dev, |
@@ -1353,7 +1345,6 @@ static void garmin_read_int_callback(struct urb *urb) | |||
1353 | 1345 | ||
1354 | garmin_read_process(garmin_data_p, data, urb->actual_length, 0); | 1346 | garmin_read_process(garmin_data_p, data, urb->actual_length, 0); |
1355 | 1347 | ||
1356 | port->interrupt_in_urb->dev = port->serial->dev; | ||
1357 | retval = usb_submit_urb(urb, GFP_ATOMIC); | 1348 | retval = usb_submit_urb(urb, GFP_ATOMIC); |
1358 | if (retval) | 1349 | if (retval) |
1359 | dev_err(&urb->dev->dev, | 1350 | dev_err(&urb->dev->dev, |
diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c index e4db5ad2bc55..f7403576f99f 100644 --- a/drivers/usb/serial/generic.c +++ b/drivers/usb/serial/generic.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * USB Serial Converter Generic functions | 2 | * USB Serial Converter Generic functions |
3 | * | 3 | * |
4 | * Copyright (C) 2010 Johan Hovold (jhovold@gmail.com) | 4 | * Copyright (C) 2010 - 2011 Johan Hovold (jhovold@gmail.com) |
5 | * Copyright (C) 1999 - 2002 Greg Kroah-Hartman (greg@kroah.com) | 5 | * Copyright (C) 1999 - 2002 Greg Kroah-Hartman (greg@kroah.com) |
6 | * | 6 | * |
7 | * This program is free software; you can redistribute it and/or | 7 | * This program is free software; you can redistribute it and/or |
@@ -132,7 +132,7 @@ int usb_serial_generic_open(struct tty_struct *tty, struct usb_serial_port *port | |||
132 | 132 | ||
133 | /* if we have a bulk endpoint, start reading from it */ | 133 | /* if we have a bulk endpoint, start reading from it */ |
134 | if (port->bulk_in_size) | 134 | if (port->bulk_in_size) |
135 | result = usb_serial_generic_submit_read_urb(port, GFP_KERNEL); | 135 | result = usb_serial_generic_submit_read_urbs(port, GFP_KERNEL); |
136 | 136 | ||
137 | return result; | 137 | return result; |
138 | } | 138 | } |
@@ -157,8 +157,10 @@ static void generic_cleanup(struct usb_serial_port *port) | |||
157 | kfifo_reset_out(&port->write_fifo); | 157 | kfifo_reset_out(&port->write_fifo); |
158 | spin_unlock_irqrestore(&port->lock, flags); | 158 | spin_unlock_irqrestore(&port->lock, flags); |
159 | } | 159 | } |
160 | if (port->bulk_in_size) | 160 | if (port->bulk_in_size) { |
161 | usb_kill_urb(port->read_urb); | 161 | for (i = 0; i < ARRAY_SIZE(port->read_urbs); ++i) |
162 | usb_kill_urb(port->read_urbs[i]); | ||
163 | } | ||
162 | } | 164 | } |
163 | } | 165 | } |
164 | 166 | ||
@@ -308,19 +310,52 @@ int usb_serial_generic_chars_in_buffer(struct tty_struct *tty) | |||
308 | return chars; | 310 | return chars; |
309 | } | 311 | } |
310 | 312 | ||
311 | int usb_serial_generic_submit_read_urb(struct usb_serial_port *port, | 313 | static int usb_serial_generic_submit_read_urb(struct usb_serial_port *port, |
314 | int index, gfp_t mem_flags) | ||
315 | { | ||
316 | int res; | ||
317 | |||
318 | if (!test_and_clear_bit(index, &port->read_urbs_free)) | ||
319 | return 0; | ||
320 | |||
321 | dbg("%s - port %d, urb %d\n", __func__, port->number, index); | ||
322 | |||
323 | res = usb_submit_urb(port->read_urbs[index], mem_flags); | ||
324 | if (res) { | ||
325 | if (res != -EPERM) { | ||
326 | dev_err(&port->dev, | ||
327 | "%s - usb_submit_urb failed: %d\n", | ||
328 | __func__, res); | ||
329 | } | ||
330 | set_bit(index, &port->read_urbs_free); | ||
331 | return res; | ||
332 | } | ||
333 | |||
334 | return 0; | ||
335 | } | ||
336 | |||
337 | int usb_serial_generic_submit_read_urbs(struct usb_serial_port *port, | ||
312 | gfp_t mem_flags) | 338 | gfp_t mem_flags) |
313 | { | 339 | { |
314 | int result; | 340 | int res; |
341 | int i; | ||
315 | 342 | ||
316 | result = usb_submit_urb(port->read_urb, mem_flags); | 343 | dbg("%s - port %d", __func__, port->number); |
317 | if (result && result != -EPERM) { | 344 | |
318 | dev_err(&port->dev, "%s - error submitting urb: %d\n", | 345 | for (i = 0; i < ARRAY_SIZE(port->read_urbs); ++i) { |
319 | __func__, result); | 346 | res = usb_serial_generic_submit_read_urb(port, i, mem_flags); |
347 | if (res) | ||
348 | goto err; | ||
320 | } | 349 | } |
321 | return result; | 350 | |
351 | return 0; | ||
352 | err: | ||
353 | for (; i >= 0; --i) | ||
354 | usb_kill_urb(port->read_urbs[i]); | ||
355 | |||
356 | return res; | ||
322 | } | 357 | } |
323 | EXPORT_SYMBOL_GPL(usb_serial_generic_submit_read_urb); | 358 | EXPORT_SYMBOL_GPL(usb_serial_generic_submit_read_urbs); |
324 | 359 | ||
325 | void usb_serial_generic_process_read_urb(struct urb *urb) | 360 | void usb_serial_generic_process_read_urb(struct urb *urb) |
326 | { | 361 | { |
@@ -356,14 +391,19 @@ void usb_serial_generic_read_bulk_callback(struct urb *urb) | |||
356 | { | 391 | { |
357 | struct usb_serial_port *port = urb->context; | 392 | struct usb_serial_port *port = urb->context; |
358 | unsigned char *data = urb->transfer_buffer; | 393 | unsigned char *data = urb->transfer_buffer; |
359 | int status = urb->status; | ||
360 | unsigned long flags; | 394 | unsigned long flags; |
395 | int i; | ||
361 | 396 | ||
362 | dbg("%s - port %d", __func__, port->number); | 397 | for (i = 0; i < ARRAY_SIZE(port->read_urbs); ++i) { |
398 | if (urb == port->read_urbs[i]) | ||
399 | break; | ||
400 | } | ||
401 | set_bit(i, &port->read_urbs_free); | ||
363 | 402 | ||
364 | if (unlikely(status != 0)) { | 403 | dbg("%s - port %d, urb %d, len %d\n", __func__, port->number, i, |
365 | dbg("%s - nonzero read bulk status received: %d", | 404 | urb->actual_length); |
366 | __func__, status); | 405 | if (urb->status) { |
406 | dbg("%s - non-zero urb status: %d\n", __func__, urb->status); | ||
367 | return; | 407 | return; |
368 | } | 408 | } |
369 | 409 | ||
@@ -376,7 +416,7 @@ void usb_serial_generic_read_bulk_callback(struct urb *urb) | |||
376 | port->throttled = port->throttle_req; | 416 | port->throttled = port->throttle_req; |
377 | if (!port->throttled) { | 417 | if (!port->throttled) { |
378 | spin_unlock_irqrestore(&port->lock, flags); | 418 | spin_unlock_irqrestore(&port->lock, flags); |
379 | usb_serial_generic_submit_read_urb(port, GFP_ATOMIC); | 419 | usb_serial_generic_submit_read_urb(port, i, GFP_ATOMIC); |
380 | } else | 420 | } else |
381 | spin_unlock_irqrestore(&port->lock, flags); | 421 | spin_unlock_irqrestore(&port->lock, flags); |
382 | } | 422 | } |
@@ -443,7 +483,7 @@ void usb_serial_generic_unthrottle(struct tty_struct *tty) | |||
443 | spin_unlock_irq(&port->lock); | 483 | spin_unlock_irq(&port->lock); |
444 | 484 | ||
445 | if (was_throttled) | 485 | if (was_throttled) |
446 | usb_serial_generic_submit_read_urb(port, GFP_KERNEL); | 486 | usb_serial_generic_submit_read_urbs(port, GFP_KERNEL); |
447 | } | 487 | } |
448 | EXPORT_SYMBOL_GPL(usb_serial_generic_unthrottle); | 488 | EXPORT_SYMBOL_GPL(usb_serial_generic_unthrottle); |
449 | 489 | ||
@@ -509,8 +549,9 @@ int usb_serial_generic_resume(struct usb_serial *serial) | |||
509 | if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) | 549 | if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) |
510 | continue; | 550 | continue; |
511 | 551 | ||
512 | if (port->read_urb) { | 552 | if (port->bulk_in_size) { |
513 | r = usb_submit_urb(port->read_urb, GFP_NOIO); | 553 | r = usb_serial_generic_submit_read_urbs(port, |
554 | GFP_NOIO); | ||
514 | if (r < 0) | 555 | if (r < 0) |
515 | c++; | 556 | c++; |
516 | } | 557 | } |
diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c index 2ee807523f53..0497575e4799 100644 --- a/drivers/usb/serial/io_edgeport.c +++ b/drivers/usb/serial/io_edgeport.c | |||
@@ -191,7 +191,7 @@ static const struct divisor_table_entry divisor_table[] = { | |||
191 | }; | 191 | }; |
192 | 192 | ||
193 | /* local variables */ | 193 | /* local variables */ |
194 | static int debug; | 194 | static bool debug; |
195 | 195 | ||
196 | static atomic_t CmdUrbs; /* Number of outstanding Command Write Urbs */ | 196 | static atomic_t CmdUrbs; /* Number of outstanding Command Write Urbs */ |
197 | 197 | ||
@@ -610,7 +610,6 @@ static void edge_interrupt_callback(struct urb *urb) | |||
610 | 610 | ||
611 | /* we have pending bytes on the | 611 | /* we have pending bytes on the |
612 | bulk in pipe, send a request */ | 612 | bulk in pipe, send a request */ |
613 | edge_serial->read_urb->dev = edge_serial->serial->dev; | ||
614 | result = usb_submit_urb(edge_serial->read_urb, GFP_ATOMIC); | 613 | result = usb_submit_urb(edge_serial->read_urb, GFP_ATOMIC); |
615 | if (result) { | 614 | if (result) { |
616 | dev_err(&edge_serial->serial->dev->dev, "%s - usb_submit_urb(read bulk) failed with result = %d\n", __func__, result); | 615 | dev_err(&edge_serial->serial->dev->dev, "%s - usb_submit_urb(read bulk) failed with result = %d\n", __func__, result); |
@@ -711,7 +710,6 @@ static void edge_bulk_in_callback(struct urb *urb) | |||
711 | /* check to see if there's any more data for us to read */ | 710 | /* check to see if there's any more data for us to read */ |
712 | if (edge_serial->rxBytesAvail > 0) { | 711 | if (edge_serial->rxBytesAvail > 0) { |
713 | dbg("%s - posting a read", __func__); | 712 | dbg("%s - posting a read", __func__); |
714 | edge_serial->read_urb->dev = edge_serial->serial->dev; | ||
715 | retval = usb_submit_urb(edge_serial->read_urb, GFP_ATOMIC); | 713 | retval = usb_submit_urb(edge_serial->read_urb, GFP_ATOMIC); |
716 | if (retval) { | 714 | if (retval) { |
717 | dev_err(&urb->dev->dev, | 715 | dev_err(&urb->dev->dev, |
@@ -1330,7 +1328,6 @@ static void send_more_port_data(struct edgeport_serial *edge_serial, | |||
1330 | edge_port->txCredits -= count; | 1328 | edge_port->txCredits -= count; |
1331 | edge_port->icount.tx += count; | 1329 | edge_port->icount.tx += count; |
1332 | 1330 | ||
1333 | urb->dev = edge_serial->serial->dev; | ||
1334 | status = usb_submit_urb(urb, GFP_ATOMIC); | 1331 | status = usb_submit_urb(urb, GFP_ATOMIC); |
1335 | if (status) { | 1332 | if (status) { |
1336 | /* something went wrong */ | 1333 | /* something went wrong */ |
diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c index 0aac00afb5c8..65bf06aa591a 100644 --- a/drivers/usb/serial/io_ti.c +++ b/drivers/usb/serial/io_ti.c | |||
@@ -15,13 +15,6 @@ | |||
15 | * For questions or problems with this driver, contact Inside Out | 15 | * For questions or problems with this driver, contact Inside Out |
16 | * Networks technical support, or Peter Berger <pberger@brimson.com>, | 16 | * Networks technical support, or Peter Berger <pberger@brimson.com>, |
17 | * or Al Borchers <alborchers@steinerpoint.com>. | 17 | * or Al Borchers <alborchers@steinerpoint.com>. |
18 | * | ||
19 | * Version history: | ||
20 | * | ||
21 | * July 11, 2002 Removed 4 port device structure since all TI UMP | ||
22 | * chips have only 2 ports | ||
23 | * David Iacovelli (davidi@ionetworks.com) | ||
24 | * | ||
25 | */ | 18 | */ |
26 | 19 | ||
27 | #include <linux/kernel.h> | 20 | #include <linux/kernel.h> |
@@ -217,10 +210,10 @@ static unsigned char OperationalMajorVersion; | |||
217 | static unsigned char OperationalMinorVersion; | 210 | static unsigned char OperationalMinorVersion; |
218 | static unsigned short OperationalBuildNumber; | 211 | static unsigned short OperationalBuildNumber; |
219 | 212 | ||
220 | static int debug; | 213 | static bool debug; |
221 | 214 | ||
222 | static int closing_wait = EDGE_CLOSING_WAIT; | 215 | static int closing_wait = EDGE_CLOSING_WAIT; |
223 | static int ignore_cpu_rev; | 216 | static bool ignore_cpu_rev; |
224 | static int default_uart_mode; /* RS232 */ | 217 | static int default_uart_mode; /* RS232 */ |
225 | 218 | ||
226 | static void edge_tty_recv(struct device *dev, struct tty_struct *tty, | 219 | static void edge_tty_recv(struct device *dev, struct tty_struct *tty, |
@@ -1777,12 +1770,11 @@ static void edge_bulk_in_callback(struct urb *urb) | |||
1777 | exit: | 1770 | exit: |
1778 | /* continue read unless stopped */ | 1771 | /* continue read unless stopped */ |
1779 | spin_lock(&edge_port->ep_lock); | 1772 | spin_lock(&edge_port->ep_lock); |
1780 | if (edge_port->ep_read_urb_state == EDGE_READ_URB_RUNNING) { | 1773 | if (edge_port->ep_read_urb_state == EDGE_READ_URB_RUNNING) |
1781 | urb->dev = edge_port->port->serial->dev; | ||
1782 | retval = usb_submit_urb(urb, GFP_ATOMIC); | 1774 | retval = usb_submit_urb(urb, GFP_ATOMIC); |
1783 | } else if (edge_port->ep_read_urb_state == EDGE_READ_URB_STOPPING) { | 1775 | else if (edge_port->ep_read_urb_state == EDGE_READ_URB_STOPPING) |
1784 | edge_port->ep_read_urb_state = EDGE_READ_URB_STOPPED; | 1776 | edge_port->ep_read_urb_state = EDGE_READ_URB_STOPPED; |
1785 | } | 1777 | |
1786 | spin_unlock(&edge_port->ep_lock); | 1778 | spin_unlock(&edge_port->ep_lock); |
1787 | if (retval) | 1779 | if (retval) |
1788 | dev_err(&urb->dev->dev, | 1780 | dev_err(&urb->dev->dev, |
@@ -1959,9 +1951,7 @@ static int edge_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
1959 | status = -EINVAL; | 1951 | status = -EINVAL; |
1960 | goto release_es_lock; | 1952 | goto release_es_lock; |
1961 | } | 1953 | } |
1962 | urb->complete = edge_interrupt_callback; | ||
1963 | urb->context = edge_serial; | 1954 | urb->context = edge_serial; |
1964 | urb->dev = dev; | ||
1965 | status = usb_submit_urb(urb, GFP_KERNEL); | 1955 | status = usb_submit_urb(urb, GFP_KERNEL); |
1966 | if (status) { | 1956 | if (status) { |
1967 | dev_err(&port->dev, | 1957 | dev_err(&port->dev, |
@@ -1987,9 +1977,7 @@ static int edge_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
1987 | goto unlink_int_urb; | 1977 | goto unlink_int_urb; |
1988 | } | 1978 | } |
1989 | edge_port->ep_read_urb_state = EDGE_READ_URB_RUNNING; | 1979 | edge_port->ep_read_urb_state = EDGE_READ_URB_RUNNING; |
1990 | urb->complete = edge_bulk_in_callback; | ||
1991 | urb->context = edge_port; | 1980 | urb->context = edge_port; |
1992 | urb->dev = dev; | ||
1993 | status = usb_submit_urb(urb, GFP_KERNEL); | 1981 | status = usb_submit_urb(urb, GFP_KERNEL); |
1994 | if (status) { | 1982 | if (status) { |
1995 | dev_err(&port->dev, | 1983 | dev_err(&port->dev, |
@@ -2118,12 +2106,7 @@ static void edge_send(struct tty_struct *tty) | |||
2118 | port->write_urb->transfer_buffer); | 2106 | port->write_urb->transfer_buffer); |
2119 | 2107 | ||
2120 | /* set up our urb */ | 2108 | /* set up our urb */ |
2121 | usb_fill_bulk_urb(port->write_urb, port->serial->dev, | 2109 | port->write_urb->transfer_buffer_length = count; |
2122 | usb_sndbulkpipe(port->serial->dev, | ||
2123 | port->bulk_out_endpointAddress), | ||
2124 | port->write_urb->transfer_buffer, count, | ||
2125 | edge_bulk_out_callback, | ||
2126 | port); | ||
2127 | 2110 | ||
2128 | /* send the data out the bulk port */ | 2111 | /* send the data out the bulk port */ |
2129 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); | 2112 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); |
@@ -2267,9 +2250,6 @@ static int restart_read(struct edgeport_port *edge_port) | |||
2267 | 2250 | ||
2268 | if (edge_port->ep_read_urb_state == EDGE_READ_URB_STOPPED) { | 2251 | if (edge_port->ep_read_urb_state == EDGE_READ_URB_STOPPED) { |
2269 | urb = edge_port->port->read_urb; | 2252 | urb = edge_port->port->read_urb; |
2270 | urb->complete = edge_bulk_in_callback; | ||
2271 | urb->context = edge_port; | ||
2272 | urb->dev = edge_port->port->serial->dev; | ||
2273 | status = usb_submit_urb(urb, GFP_ATOMIC); | 2253 | status = usb_submit_urb(urb, GFP_ATOMIC); |
2274 | } | 2254 | } |
2275 | edge_port->ep_read_urb_state = EDGE_READ_URB_RUNNING; | 2255 | edge_port->ep_read_urb_state = EDGE_READ_URB_RUNNING; |
diff --git a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c index 4735931b4c7b..06053a920dd8 100644 --- a/drivers/usb/serial/ipaq.c +++ b/drivers/usb/serial/ipaq.c | |||
@@ -8,40 +8,6 @@ | |||
8 | * it under the terms of the GNU General Public License as published by | 8 | * it under the terms of the GNU General Public License as published by |
9 | * the Free Software Foundation; either version 2 of the License, or | 9 | * the Free Software Foundation; either version 2 of the License, or |
10 | * (at your option) any later version. | 10 | * (at your option) any later version. |
11 | * | ||
12 | * (12/12/2002) ganesh | ||
13 | * Added support for practically all devices supported by ActiveSync | ||
14 | * on Windows. Thanks to Wes Cilldhaire <billybobjoehenrybob@hotmail.com>. | ||
15 | * | ||
16 | * (26/11/2002) ganesh | ||
17 | * Added insmod options to specify product and vendor id. | ||
18 | * Use modprobe ipaq vendor=0xfoo product=0xbar | ||
19 | * | ||
20 | * (26/7/2002) ganesh | ||
21 | * Fixed up broken error handling in ipaq_open. Retry the "kickstart" | ||
22 | * packet much harder - this drastically reduces connection failures. | ||
23 | * | ||
24 | * (30/4/2002) ganesh | ||
25 | * Added support for the Casio EM500. Completely untested. Thanks | ||
26 | * to info from Nathan <wfilardo@fuse.net> | ||
27 | * | ||
28 | * (19/3/2002) ganesh | ||
29 | * Don't submit urbs while holding spinlocks. Not strictly necessary | ||
30 | * in 2.5.x. | ||
31 | * | ||
32 | * (8/3/2002) ganesh | ||
33 | * The ipaq sometimes emits a '\0' before the CLIENT string. At this | ||
34 | * point of time, the ppp ldisc is not yet attached to the tty, so | ||
35 | * n_tty echoes "^ " to the ipaq, which messes up the chat. In 2.5.6-pre2 | ||
36 | * this causes a panic because echo_char() tries to sleep in interrupt | ||
37 | * context. | ||
38 | * The fix is to tell the upper layers that this is a raw device so that | ||
39 | * echoing is suppressed. Thanks to Lyle Lindholm for a detailed bug | ||
40 | * report. | ||
41 | * | ||
42 | * (25/2/2002) ganesh | ||
43 | * Added support for the HP Jornada 548 and 568. Completely untested. | ||
44 | * Thanks to info from Heath Robinson and Arieh Davidoff. | ||
45 | */ | 11 | */ |
46 | 12 | ||
47 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
@@ -68,7 +34,7 @@ | |||
68 | #define DRIVER_DESC "USB PocketPC PDA driver" | 34 | #define DRIVER_DESC "USB PocketPC PDA driver" |
69 | 35 | ||
70 | static __u16 product, vendor; | 36 | static __u16 product, vendor; |
71 | static int debug; | 37 | static bool debug; |
72 | static int connect_retries = KP_RETRIES; | 38 | static int connect_retries = KP_RETRIES; |
73 | static int initial_wait; | 39 | static int initial_wait; |
74 | 40 | ||
diff --git a/drivers/usb/serial/ipw.c b/drivers/usb/serial/ipw.c index 5170799d6e94..6f9356f3f99e 100644 --- a/drivers/usb/serial/ipw.c +++ b/drivers/usb/serial/ipw.c | |||
@@ -147,7 +147,7 @@ static struct usb_driver usb_ipw_driver = { | |||
147 | .no_dynamic_id = 1, | 147 | .no_dynamic_id = 1, |
148 | }; | 148 | }; |
149 | 149 | ||
150 | static int debug; | 150 | static bool debug; |
151 | 151 | ||
152 | static int ipw_open(struct tty_struct *tty, struct usb_serial_port *port) | 152 | static int ipw_open(struct tty_struct *tty, struct usb_serial_port *port) |
153 | { | 153 | { |
diff --git a/drivers/usb/serial/ir-usb.c b/drivers/usb/serial/ir-usb.c index ccbce4066d04..84a396e83671 100644 --- a/drivers/usb/serial/ir-usb.c +++ b/drivers/usb/serial/ir-usb.c | |||
@@ -22,38 +22,6 @@ | |||
22 | * | 22 | * |
23 | * See Documentation/usb/usb-serial.txt for more information on using this | 23 | * See Documentation/usb/usb-serial.txt for more information on using this |
24 | * driver | 24 | * driver |
25 | * | ||
26 | * 2008_Jun_02 Felipe Balbi <me@felipebalbi.com> | ||
27 | * Introduced common header to be used also in USB Gadget Framework. | ||
28 | * Still needs some other style fixes. | ||
29 | * | ||
30 | * 2007_Jun_21 Alan Cox <alan@lxorguk.ukuu.org.uk> | ||
31 | * Minimal cleanups for some of the driver problens and tty layer abuse. | ||
32 | * Still needs fixing to allow multiple dongles. | ||
33 | * | ||
34 | * 2002_Mar_07 greg kh | ||
35 | * moved some needed structures and #define values from the | ||
36 | * net/irda/irda-usb.h file into our file, as we don't want to depend on | ||
37 | * that codebase compiling correctly :) | ||
38 | * | ||
39 | * 2002_Jan_14 gb | ||
40 | * Added module parameter to force specific number of XBOFs. | ||
41 | * Added ir_xbof_change(). | ||
42 | * Reorganized read_bulk_callback error handling. | ||
43 | * Switched from FILL_BULK_URB() to usb_fill_bulk_urb(). | ||
44 | * | ||
45 | * 2001_Nov_08 greg kh | ||
46 | * Changed the irda_usb_find_class_desc() function based on comments and | ||
47 | * code from Martin Diehl. | ||
48 | * | ||
49 | * 2001_Nov_01 greg kh | ||
50 | * Added support for more IrDA USB devices. | ||
51 | * Added support for zero packet. Added buffer override paramater, so | ||
52 | * users can transfer larger packets at once if they wish. Both patches | ||
53 | * came from Dag Brattli <dag@obexcode.com>. | ||
54 | * | ||
55 | * 2001_Oct_07 greg kh | ||
56 | * initial version released. | ||
57 | */ | 25 | */ |
58 | 26 | ||
59 | #include <linux/kernel.h> | 27 | #include <linux/kernel.h> |
@@ -77,7 +45,7 @@ | |||
77 | #define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>, Johan Hovold <jhovold@gmail.com>" | 45 | #define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>, Johan Hovold <jhovold@gmail.com>" |
78 | #define DRIVER_DESC "USB IR Dongle driver" | 46 | #define DRIVER_DESC "USB IR Dongle driver" |
79 | 47 | ||
80 | static int debug; | 48 | static bool debug; |
81 | 49 | ||
82 | /* if overridden by the user, then use their value for the size of the read and | 50 | /* if overridden by the user, then use their value for the size of the read and |
83 | * write urbs */ | 51 | * write urbs */ |
diff --git a/drivers/usb/serial/iuu_phoenix.c b/drivers/usb/serial/iuu_phoenix.c index 6aca631a407a..3077a4436976 100644 --- a/drivers/usb/serial/iuu_phoenix.c +++ b/drivers/usb/serial/iuu_phoenix.c | |||
@@ -34,9 +34,9 @@ | |||
34 | 34 | ||
35 | 35 | ||
36 | #ifdef CONFIG_USB_SERIAL_DEBUG | 36 | #ifdef CONFIG_USB_SERIAL_DEBUG |
37 | static int debug = 1; | 37 | static bool debug = 1; |
38 | #else | 38 | #else |
39 | static int debug; | 39 | static bool debug; |
40 | #endif | 40 | #endif |
41 | 41 | ||
42 | /* | 42 | /* |
@@ -65,7 +65,7 @@ static int clockmode = 1; | |||
65 | static int cdmode = 1; | 65 | static int cdmode = 1; |
66 | static int iuu_cardin; | 66 | static int iuu_cardin; |
67 | static int iuu_cardout; | 67 | static int iuu_cardout; |
68 | static int xmas; | 68 | static bool xmas; |
69 | static int vcc_default = 5; | 69 | static int vcc_default = 5; |
70 | 70 | ||
71 | static void read_rxcmd_callback(struct urb *urb); | 71 | static void read_rxcmd_callback(struct urb *urb); |
@@ -1168,15 +1168,14 @@ static int iuu_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
1168 | port->write_urb->transfer_buffer, 1, | 1168 | port->write_urb->transfer_buffer, 1, |
1169 | read_rxcmd_callback, port); | 1169 | read_rxcmd_callback, port); |
1170 | result = usb_submit_urb(port->write_urb, GFP_KERNEL); | 1170 | result = usb_submit_urb(port->write_urb, GFP_KERNEL); |
1171 | |||
1172 | if (result) { | 1171 | if (result) { |
1173 | dev_err(&port->dev, "%s - failed submitting read urb," | 1172 | dev_err(&port->dev, "%s - failed submitting read urb," |
1174 | " error %d\n", __func__, result); | 1173 | " error %d\n", __func__, result); |
1175 | iuu_close(port); | 1174 | iuu_close(port); |
1176 | return -EPROTO; | ||
1177 | } else { | 1175 | } else { |
1178 | dbg("%s - rxcmd OK", __func__); | 1176 | dbg("%s - rxcmd OK", __func__); |
1179 | } | 1177 | } |
1178 | |||
1180 | return result; | 1179 | return result; |
1181 | } | 1180 | } |
1182 | 1181 | ||
diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c index a442352d7b61..4cc36c761801 100644 --- a/drivers/usb/serial/keyspan.c +++ b/drivers/usb/serial/keyspan.c | |||
@@ -25,73 +25,6 @@ | |||
25 | 25 | ||
26 | Tip 'o the hat to IBM (and previously Linuxcare :) for supporting | 26 | Tip 'o the hat to IBM (and previously Linuxcare :) for supporting |
27 | staff in their work on open source projects. | 27 | staff in their work on open source projects. |
28 | |||
29 | Change History | ||
30 | |||
31 | 2003sep04 LPM (Keyspan) add support for new single port product USA19HS. | ||
32 | Improve setup message handling for all devices. | ||
33 | |||
34 | Wed Feb 19 22:00:00 PST 2003 (Jeffrey S. Laing <keyspan@jsl.com>) | ||
35 | Merged the current (1/31/03) Keyspan code with the current (2.4.21-pre4) | ||
36 | Linux source tree. The Linux tree lacked support for the 49WLC and | ||
37 | others. The Keyspan patches didn't work with the current kernel. | ||
38 | |||
39 | 2003jan30 LPM add support for the 49WLC and MPR | ||
40 | |||
41 | Wed Apr 25 12:00:00 PST 2002 (Keyspan) | ||
42 | Started with Hugh Blemings' code dated Jan 17, 2002. All adapters | ||
43 | now supported (including QI and QW). Modified port open, port | ||
44 | close, and send setup() logic to fix various data and endpoint | ||
45 | synchronization bugs and device LED status bugs. Changed keyspan_ | ||
46 | write_room() to accurately return transmit buffer availability. | ||
47 | Changed forwardingLength from 1 to 16 for all adapters. | ||
48 | |||
49 | Fri Oct 12 16:45:00 EST 2001 | ||
50 | Preliminary USA-19QI and USA-28 support (both test OK for me, YMMV) | ||
51 | |||
52 | Wed Apr 25 12:00:00 PST 2002 (Keyspan) | ||
53 | Started with Hugh Blemings' code dated Jan 17, 2002. All adapters | ||
54 | now supported (including QI and QW). Modified port open, port | ||
55 | close, and send setup() logic to fix various data and endpoint | ||
56 | synchronization bugs and device LED status bugs. Changed keyspan_ | ||
57 | write_room() to accurately return transmit buffer availability. | ||
58 | Changed forwardingLength from 1 to 16 for all adapters. | ||
59 | |||
60 | Fri Oct 12 16:45:00 EST 2001 | ||
61 | Preliminary USA-19QI and USA-28 support (both test OK for me, YMMV) | ||
62 | |||
63 | Mon Oct 8 14:29:00 EST 2001 hugh | ||
64 | Fixed bug that prevented mulitport devices operating correctly | ||
65 | if they weren't the first unit attached. | ||
66 | |||
67 | Sat Oct 6 12:31:21 EST 2001 hugh | ||
68 | Added support for USA-28XA and -28XB, misc cleanups, break support | ||
69 | for usa26 based models thanks to David Gibson. | ||
70 | |||
71 | Thu May 31 11:56:42 PDT 2001 gkh | ||
72 | switched from using spinlock to a semaphore | ||
73 | |||
74 | (04/08/2001) gb | ||
75 | Identify version on module load. | ||
76 | |||
77 | (11/01/2000) Adam J. Richter | ||
78 | usb_device_id table support. | ||
79 | |||
80 | Tue Oct 10 23:15:33 EST 2000 Hugh | ||
81 | Merged Paul's changes with my USA-49W mods. Work in progress | ||
82 | still... | ||
83 | |||
84 | Wed Jul 19 14:00:42 EST 2000 gkh | ||
85 | Added module_init and module_exit functions to handle the fact that | ||
86 | this driver is a loadable module now. | ||
87 | |||
88 | Tue Jul 18 16:14:52 EST 2000 Hugh | ||
89 | Basic character input/output for USA-19 now mostly works, | ||
90 | fixed at 9600 baud for the moment. | ||
91 | |||
92 | Sat Jul 8 11:11:48 EST 2000 Hugh | ||
93 | First public release - nothing works except the firmware upload. | ||
94 | Tested on PPC and x86 architectures, seems to behave... | ||
95 | */ | 28 | */ |
96 | 29 | ||
97 | 30 | ||
@@ -112,7 +45,7 @@ | |||
112 | #include <linux/usb/serial.h> | 45 | #include <linux/usb/serial.h> |
113 | #include "keyspan.h" | 46 | #include "keyspan.h" |
114 | 47 | ||
115 | static int debug; | 48 | static bool debug; |
116 | 49 | ||
117 | /* | 50 | /* |
118 | * Version Information | 51 | * Version Information |
@@ -397,7 +330,6 @@ static int keyspan_write(struct tty_struct *tty, | |||
397 | /* send the data out the bulk port */ | 330 | /* send the data out the bulk port */ |
398 | this_urb->transfer_buffer_length = todo + dataOffset; | 331 | this_urb->transfer_buffer_length = todo + dataOffset; |
399 | 332 | ||
400 | this_urb->dev = port->serial->dev; | ||
401 | err = usb_submit_urb(this_urb, GFP_ATOMIC); | 333 | err = usb_submit_urb(this_urb, GFP_ATOMIC); |
402 | if (err != 0) | 334 | if (err != 0) |
403 | dbg("usb_submit_urb(write bulk) failed (%d)", err); | 335 | dbg("usb_submit_urb(write bulk) failed (%d)", err); |
@@ -463,7 +395,6 @@ static void usa26_indat_callback(struct urb *urb) | |||
463 | tty_kref_put(tty); | 395 | tty_kref_put(tty); |
464 | 396 | ||
465 | /* Resubmit urb so we continue receiving */ | 397 | /* Resubmit urb so we continue receiving */ |
466 | urb->dev = port->serial->dev; | ||
467 | err = usb_submit_urb(urb, GFP_ATOMIC); | 398 | err = usb_submit_urb(urb, GFP_ATOMIC); |
468 | if (err != 0) | 399 | if (err != 0) |
469 | dbg("%s - resubmit read urb failed. (%d)", __func__, err); | 400 | dbg("%s - resubmit read urb failed. (%d)", __func__, err); |
@@ -559,7 +490,6 @@ static void usa26_instat_callback(struct urb *urb) | |||
559 | } | 490 | } |
560 | 491 | ||
561 | /* Resubmit urb so we continue receiving */ | 492 | /* Resubmit urb so we continue receiving */ |
562 | urb->dev = serial->dev; | ||
563 | err = usb_submit_urb(urb, GFP_ATOMIC); | 493 | err = usb_submit_urb(urb, GFP_ATOMIC); |
564 | if (err != 0) | 494 | if (err != 0) |
565 | dbg("%s - resubmit read urb failed. (%d)", __func__, err); | 495 | dbg("%s - resubmit read urb failed. (%d)", __func__, err); |
@@ -609,7 +539,6 @@ static void usa28_indat_callback(struct urb *urb) | |||
609 | tty_kref_put(tty); | 539 | tty_kref_put(tty); |
610 | 540 | ||
611 | /* Resubmit urb so we continue receiving */ | 541 | /* Resubmit urb so we continue receiving */ |
612 | urb->dev = port->serial->dev; | ||
613 | err = usb_submit_urb(urb, GFP_ATOMIC); | 542 | err = usb_submit_urb(urb, GFP_ATOMIC); |
614 | if (err != 0) | 543 | if (err != 0) |
615 | dbg("%s - resubmit read urb failed. (%d)", | 544 | dbg("%s - resubmit read urb failed. (%d)", |
@@ -694,7 +623,6 @@ static void usa28_instat_callback(struct urb *urb) | |||
694 | } | 623 | } |
695 | 624 | ||
696 | /* Resubmit urb so we continue receiving */ | 625 | /* Resubmit urb so we continue receiving */ |
697 | urb->dev = serial->dev; | ||
698 | err = usb_submit_urb(urb, GFP_ATOMIC); | 626 | err = usb_submit_urb(urb, GFP_ATOMIC); |
699 | if (err != 0) | 627 | if (err != 0) |
700 | dbg("%s - resubmit read urb failed. (%d)", __func__, err); | 628 | dbg("%s - resubmit read urb failed. (%d)", __func__, err); |
@@ -789,8 +717,6 @@ static void usa49_instat_callback(struct urb *urb) | |||
789 | } | 717 | } |
790 | 718 | ||
791 | /* Resubmit urb so we continue receiving */ | 719 | /* Resubmit urb so we continue receiving */ |
792 | urb->dev = serial->dev; | ||
793 | |||
794 | err = usb_submit_urb(urb, GFP_ATOMIC); | 720 | err = usb_submit_urb(urb, GFP_ATOMIC); |
795 | if (err != 0) | 721 | if (err != 0) |
796 | dbg("%s - resubmit read urb failed. (%d)", __func__, err); | 722 | dbg("%s - resubmit read urb failed. (%d)", __func__, err); |
@@ -848,7 +774,6 @@ static void usa49_indat_callback(struct urb *urb) | |||
848 | tty_kref_put(tty); | 774 | tty_kref_put(tty); |
849 | 775 | ||
850 | /* Resubmit urb so we continue receiving */ | 776 | /* Resubmit urb so we continue receiving */ |
851 | urb->dev = port->serial->dev; | ||
852 | err = usb_submit_urb(urb, GFP_ATOMIC); | 777 | err = usb_submit_urb(urb, GFP_ATOMIC); |
853 | if (err != 0) | 778 | if (err != 0) |
854 | dbg("%s - resubmit read urb failed. (%d)", __func__, err); | 779 | dbg("%s - resubmit read urb failed. (%d)", __func__, err); |
@@ -919,8 +844,6 @@ static void usa49wg_indat_callback(struct urb *urb) | |||
919 | } | 844 | } |
920 | 845 | ||
921 | /* Resubmit urb so we continue receiving */ | 846 | /* Resubmit urb so we continue receiving */ |
922 | urb->dev = serial->dev; | ||
923 | |||
924 | err = usb_submit_urb(urb, GFP_ATOMIC); | 847 | err = usb_submit_urb(urb, GFP_ATOMIC); |
925 | if (err != 0) | 848 | if (err != 0) |
926 | dbg("%s - resubmit read urb failed. (%d)", __func__, err); | 849 | dbg("%s - resubmit read urb failed. (%d)", __func__, err); |
@@ -996,7 +919,6 @@ static void usa90_indat_callback(struct urb *urb) | |||
996 | } | 919 | } |
997 | 920 | ||
998 | /* Resubmit urb so we continue receiving */ | 921 | /* Resubmit urb so we continue receiving */ |
999 | urb->dev = port->serial->dev; | ||
1000 | err = usb_submit_urb(urb, GFP_ATOMIC); | 922 | err = usb_submit_urb(urb, GFP_ATOMIC); |
1001 | if (err != 0) | 923 | if (err != 0) |
1002 | dbg("%s - resubmit read urb failed. (%d)", __func__, err); | 924 | dbg("%s - resubmit read urb failed. (%d)", __func__, err); |
@@ -1047,7 +969,6 @@ static void usa90_instat_callback(struct urb *urb) | |||
1047 | } | 969 | } |
1048 | 970 | ||
1049 | /* Resubmit urb so we continue receiving */ | 971 | /* Resubmit urb so we continue receiving */ |
1050 | urb->dev = serial->dev; | ||
1051 | err = usb_submit_urb(urb, GFP_ATOMIC); | 972 | err = usb_submit_urb(urb, GFP_ATOMIC); |
1052 | if (err != 0) | 973 | if (err != 0) |
1053 | dbg("%s - resubmit read urb failed. (%d)", __func__, err); | 974 | dbg("%s - resubmit read urb failed. (%d)", __func__, err); |
@@ -1123,7 +1044,6 @@ static void usa67_instat_callback(struct urb *urb) | |||
1123 | } | 1044 | } |
1124 | 1045 | ||
1125 | /* Resubmit urb so we continue receiving */ | 1046 | /* Resubmit urb so we continue receiving */ |
1126 | urb->dev = serial->dev; | ||
1127 | err = usb_submit_urb(urb, GFP_ATOMIC); | 1047 | err = usb_submit_urb(urb, GFP_ATOMIC); |
1128 | if (err != 0) | 1048 | if (err != 0) |
1129 | dbg("%s - resubmit read urb failed. (%d)", __func__, err); | 1049 | dbg("%s - resubmit read urb failed. (%d)", __func__, err); |
@@ -1223,7 +1143,6 @@ static int keyspan_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
1223 | urb = p_priv->in_urbs[i]; | 1143 | urb = p_priv->in_urbs[i]; |
1224 | if (urb == NULL) | 1144 | if (urb == NULL) |
1225 | continue; | 1145 | continue; |
1226 | urb->dev = serial->dev; | ||
1227 | 1146 | ||
1228 | /* make sure endpoint data toggle is synchronized | 1147 | /* make sure endpoint data toggle is synchronized |
1229 | with the device */ | 1148 | with the device */ |
@@ -1239,7 +1158,6 @@ static int keyspan_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
1239 | urb = p_priv->out_urbs[i]; | 1158 | urb = p_priv->out_urbs[i]; |
1240 | if (urb == NULL) | 1159 | if (urb == NULL) |
1241 | continue; | 1160 | continue; |
1242 | urb->dev = serial->dev; | ||
1243 | /* usb_settoggle(urb->dev, usb_pipeendpoint(urb->pipe), | 1161 | /* usb_settoggle(urb->dev, usb_pipeendpoint(urb->pipe), |
1244 | usb_pipeout(urb->pipe), 0); */ | 1162 | usb_pipeout(urb->pipe), 0); */ |
1245 | } | 1163 | } |
@@ -1956,7 +1874,6 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial, | |||
1956 | /* send the data out the device on control endpoint */ | 1874 | /* send the data out the device on control endpoint */ |
1957 | this_urb->transfer_buffer_length = sizeof(msg); | 1875 | this_urb->transfer_buffer_length = sizeof(msg); |
1958 | 1876 | ||
1959 | this_urb->dev = serial->dev; | ||
1960 | err = usb_submit_urb(this_urb, GFP_ATOMIC); | 1877 | err = usb_submit_urb(this_urb, GFP_ATOMIC); |
1961 | if (err != 0) | 1878 | if (err != 0) |
1962 | dbg("%s - usb_submit_urb(setup) failed (%d)", __func__, err); | 1879 | dbg("%s - usb_submit_urb(setup) failed (%d)", __func__, err); |
@@ -2084,7 +2001,6 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial, | |||
2084 | /* send the data out the device on control endpoint */ | 2001 | /* send the data out the device on control endpoint */ |
2085 | this_urb->transfer_buffer_length = sizeof(msg); | 2002 | this_urb->transfer_buffer_length = sizeof(msg); |
2086 | 2003 | ||
2087 | this_urb->dev = serial->dev; | ||
2088 | err = usb_submit_urb(this_urb, GFP_ATOMIC); | 2004 | err = usb_submit_urb(this_urb, GFP_ATOMIC); |
2089 | if (err != 0) | 2005 | if (err != 0) |
2090 | dbg("%s - usb_submit_urb(setup) failed", __func__); | 2006 | dbg("%s - usb_submit_urb(setup) failed", __func__); |
@@ -2271,8 +2187,6 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial, | |||
2271 | 2187 | ||
2272 | /* send the data out the device on control endpoint */ | 2188 | /* send the data out the device on control endpoint */ |
2273 | this_urb->transfer_buffer_length = sizeof(msg); | 2189 | this_urb->transfer_buffer_length = sizeof(msg); |
2274 | |||
2275 | this_urb->dev = serial->dev; | ||
2276 | } | 2190 | } |
2277 | err = usb_submit_urb(this_urb, GFP_ATOMIC); | 2191 | err = usb_submit_urb(this_urb, GFP_ATOMIC); |
2278 | if (err != 0) | 2192 | if (err != 0) |
@@ -2415,7 +2329,6 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial, | |||
2415 | /* send the data out the device on control endpoint */ | 2329 | /* send the data out the device on control endpoint */ |
2416 | this_urb->transfer_buffer_length = sizeof(msg); | 2330 | this_urb->transfer_buffer_length = sizeof(msg); |
2417 | 2331 | ||
2418 | this_urb->dev = serial->dev; | ||
2419 | err = usb_submit_urb(this_urb, GFP_ATOMIC); | 2332 | err = usb_submit_urb(this_urb, GFP_ATOMIC); |
2420 | if (err != 0) | 2333 | if (err != 0) |
2421 | dbg("%s - usb_submit_urb(setup) failed (%d)", __func__, err); | 2334 | dbg("%s - usb_submit_urb(setup) failed (%d)", __func__, err); |
@@ -2561,7 +2474,6 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial, | |||
2561 | 2474 | ||
2562 | /* send the data out the device on control endpoint */ | 2475 | /* send the data out the device on control endpoint */ |
2563 | this_urb->transfer_buffer_length = sizeof(msg); | 2476 | this_urb->transfer_buffer_length = sizeof(msg); |
2564 | this_urb->dev = serial->dev; | ||
2565 | 2477 | ||
2566 | err = usb_submit_urb(this_urb, GFP_ATOMIC); | 2478 | err = usb_submit_urb(this_urb, GFP_ATOMIC); |
2567 | if (err != 0) | 2479 | if (err != 0) |
@@ -2650,14 +2562,12 @@ static int keyspan_startup(struct usb_serial *serial) | |||
2650 | keyspan_setup_urbs(serial); | 2562 | keyspan_setup_urbs(serial); |
2651 | 2563 | ||
2652 | if (s_priv->instat_urb != NULL) { | 2564 | if (s_priv->instat_urb != NULL) { |
2653 | s_priv->instat_urb->dev = serial->dev; | ||
2654 | err = usb_submit_urb(s_priv->instat_urb, GFP_KERNEL); | 2565 | err = usb_submit_urb(s_priv->instat_urb, GFP_KERNEL); |
2655 | if (err != 0) | 2566 | if (err != 0) |
2656 | dbg("%s - submit instat urb failed %d", __func__, | 2567 | dbg("%s - submit instat urb failed %d", __func__, |
2657 | err); | 2568 | err); |
2658 | } | 2569 | } |
2659 | if (s_priv->indat_urb != NULL) { | 2570 | if (s_priv->indat_urb != NULL) { |
2660 | s_priv->indat_urb->dev = serial->dev; | ||
2661 | err = usb_submit_urb(s_priv->indat_urb, GFP_KERNEL); | 2571 | err = usb_submit_urb(s_priv->indat_urb, GFP_KERNEL); |
2662 | if (err != 0) | 2572 | if (err != 0) |
2663 | dbg("%s - submit indat urb failed %d", __func__, | 2573 | dbg("%s - submit indat urb failed %d", __func__, |
diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c index d5c0c6ab4966..7c62a7048302 100644 --- a/drivers/usb/serial/keyspan_pda.c +++ b/drivers/usb/serial/keyspan_pda.c | |||
@@ -12,59 +12,6 @@ | |||
12 | * | 12 | * |
13 | * See Documentation/usb/usb-serial.txt for more information on using this | 13 | * See Documentation/usb/usb-serial.txt for more information on using this |
14 | * driver | 14 | * driver |
15 | * | ||
16 | * (09/07/2001) gkh | ||
17 | * cleaned up the Xircom support. Added ids for Entregra device which is | ||
18 | * the same as the Xircom device. Enabled the code to be compiled for | ||
19 | * either Xircom or Keyspan devices. | ||
20 | * | ||
21 | * (08/11/2001) Cristian M. Craciunescu | ||
22 | * support for Xircom PGSDB9 | ||
23 | * | ||
24 | * (05/31/2001) gkh | ||
25 | * switched from using spinlock to a semaphore, which fixes lots of | ||
26 | * problems. | ||
27 | * | ||
28 | * (04/08/2001) gb | ||
29 | * Identify version on module load. | ||
30 | * | ||
31 | * (11/01/2000) Adam J. Richter | ||
32 | * usb_device_id table support | ||
33 | * | ||
34 | * (10/05/2000) gkh | ||
35 | * Fixed bug with urb->dev not being set properly, now that the usb | ||
36 | * core needs it. | ||
37 | * | ||
38 | * (08/28/2000) gkh | ||
39 | * Added locks for SMP safeness. | ||
40 | * Fixed MOD_INC and MOD_DEC logic and the ability to open a port more | ||
41 | * than once. | ||
42 | * | ||
43 | * (07/20/2000) borchers | ||
44 | * - keyspan_pda_write no longer sleeps if it is called on interrupt time; | ||
45 | * PPP and the line discipline with stty echo on can call write on | ||
46 | * interrupt time and this would cause an oops if write slept | ||
47 | * - if keyspan_pda_write is in an interrupt, it will not call | ||
48 | * usb_control_msg (which sleeps) to query the room in the device | ||
49 | * buffer, it simply uses the current room value it has | ||
50 | * - if the urb is busy or if it is throttled keyspan_pda_write just | ||
51 | * returns 0, rather than sleeping to wait for this to change; the | ||
52 | * write_chan code in n_tty.c will sleep if needed before calling | ||
53 | * keyspan_pda_write again | ||
54 | * - if the device needs to be unthrottled, write now queues up the | ||
55 | * call to usb_control_msg (which sleeps) to unthrottle the device | ||
56 | * - the wakeups from keyspan_pda_write_bulk_callback are queued rather | ||
57 | * than done directly from the callback to avoid the race in write_chan | ||
58 | * - keyspan_pda_chars_in_buffer also indicates its buffer is full if the | ||
59 | * urb status is -EINPROGRESS, meaning it cannot write at the moment | ||
60 | * | ||
61 | * (07/19/2000) gkh | ||
62 | * Added module_init and module_exit functions to handle the fact that this | ||
63 | * driver is a loadable module now. | ||
64 | * | ||
65 | * (03/26/2000) gkh | ||
66 | * Split driver up into device specific pieces. | ||
67 | * | ||
68 | */ | 15 | */ |
69 | 16 | ||
70 | 17 | ||
@@ -84,7 +31,7 @@ | |||
84 | #include <linux/usb.h> | 31 | #include <linux/usb.h> |
85 | #include <linux/usb/serial.h> | 32 | #include <linux/usb/serial.h> |
86 | 33 | ||
87 | static int debug; | 34 | static bool debug; |
88 | 35 | ||
89 | /* make a simple define to handle if we are compiling keyspan_pda or xircom support */ | 36 | /* make a simple define to handle if we are compiling keyspan_pda or xircom support */ |
90 | #if defined(CONFIG_USB_SERIAL_KEYSPAN_PDA) || defined(CONFIG_USB_SERIAL_KEYSPAN_PDA_MODULE) | 37 | #if defined(CONFIG_USB_SERIAL_KEYSPAN_PDA) || defined(CONFIG_USB_SERIAL_KEYSPAN_PDA_MODULE) |
@@ -290,7 +237,6 @@ static void keyspan_pda_rx_unthrottle(struct tty_struct *tty) | |||
290 | struct usb_serial_port *port = tty->driver_data; | 237 | struct usb_serial_port *port = tty->driver_data; |
291 | /* just restart the receive interrupt URB */ | 238 | /* just restart the receive interrupt URB */ |
292 | dbg("keyspan_pda_rx_unthrottle port %d", port->number); | 239 | dbg("keyspan_pda_rx_unthrottle port %d", port->number); |
293 | port->interrupt_in_urb->dev = port->serial->dev; | ||
294 | if (usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL)) | 240 | if (usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL)) |
295 | dbg(" usb_submit_urb(read urb) failed"); | 241 | dbg(" usb_submit_urb(read urb) failed"); |
296 | } | 242 | } |
@@ -532,11 +478,11 @@ static int keyspan_pda_write(struct tty_struct *tty, | |||
532 | the device is full (wait until it says there is room) | 478 | the device is full (wait until it says there is room) |
533 | */ | 479 | */ |
534 | spin_lock_bh(&port->lock); | 480 | spin_lock_bh(&port->lock); |
535 | if (port->write_urb_busy || priv->tx_throttled) { | 481 | if (!test_bit(0, &port->write_urbs_free) || priv->tx_throttled) { |
536 | spin_unlock_bh(&port->lock); | 482 | spin_unlock_bh(&port->lock); |
537 | return 0; | 483 | return 0; |
538 | } | 484 | } |
539 | port->write_urb_busy = 1; | 485 | clear_bit(0, &port->write_urbs_free); |
540 | spin_unlock_bh(&port->lock); | 486 | spin_unlock_bh(&port->lock); |
541 | 487 | ||
542 | /* At this point the URB is in our control, nobody else can submit it | 488 | /* At this point the URB is in our control, nobody else can submit it |
@@ -598,7 +544,6 @@ static int keyspan_pda_write(struct tty_struct *tty, | |||
598 | 544 | ||
599 | priv->tx_room -= count; | 545 | priv->tx_room -= count; |
600 | 546 | ||
601 | port->write_urb->dev = port->serial->dev; | ||
602 | rc = usb_submit_urb(port->write_urb, GFP_ATOMIC); | 547 | rc = usb_submit_urb(port->write_urb, GFP_ATOMIC); |
603 | if (rc) { | 548 | if (rc) { |
604 | dbg(" usb_submit_urb(write bulk) failed"); | 549 | dbg(" usb_submit_urb(write bulk) failed"); |
@@ -618,7 +563,7 @@ static int keyspan_pda_write(struct tty_struct *tty, | |||
618 | rc = count; | 563 | rc = count; |
619 | exit: | 564 | exit: |
620 | if (rc < 0) | 565 | if (rc < 0) |
621 | port->write_urb_busy = 0; | 566 | set_bit(0, &port->write_urbs_free); |
622 | return rc; | 567 | return rc; |
623 | } | 568 | } |
624 | 569 | ||
@@ -628,7 +573,7 @@ static void keyspan_pda_write_bulk_callback(struct urb *urb) | |||
628 | struct usb_serial_port *port = urb->context; | 573 | struct usb_serial_port *port = urb->context; |
629 | struct keyspan_pda_private *priv; | 574 | struct keyspan_pda_private *priv; |
630 | 575 | ||
631 | port->write_urb_busy = 0; | 576 | set_bit(0, &port->write_urbs_free); |
632 | priv = usb_get_serial_port_data(port); | 577 | priv = usb_get_serial_port_data(port); |
633 | 578 | ||
634 | /* queue up a wakeup at scheduler time */ | 579 | /* queue up a wakeup at scheduler time */ |
@@ -661,7 +606,7 @@ static int keyspan_pda_chars_in_buffer(struct tty_struct *tty) | |||
661 | n_tty.c:normal_poll() ) that we're not writeable. */ | 606 | n_tty.c:normal_poll() ) that we're not writeable. */ |
662 | 607 | ||
663 | spin_lock_irqsave(&port->lock, flags); | 608 | spin_lock_irqsave(&port->lock, flags); |
664 | if (port->write_urb_busy || priv->tx_throttled) | 609 | if (!test_bit(0, &port->write_urbs_free) || priv->tx_throttled) |
665 | ret = 256; | 610 | ret = 256; |
666 | spin_unlock_irqrestore(&port->lock, flags); | 611 | spin_unlock_irqrestore(&port->lock, flags); |
667 | return ret; | 612 | return ret; |
@@ -717,7 +662,6 @@ static int keyspan_pda_open(struct tty_struct *tty, | |||
717 | priv->tx_throttled = *room ? 0 : 1; | 662 | priv->tx_throttled = *room ? 0 : 1; |
718 | 663 | ||
719 | /*Start reading from the device*/ | 664 | /*Start reading from the device*/ |
720 | port->interrupt_in_urb->dev = serial->dev; | ||
721 | rc = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); | 665 | rc = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); |
722 | if (rc) { | 666 | if (rc) { |
723 | dbg("%s - usb_submit_urb(read int) failed", __func__); | 667 | dbg("%s - usb_submit_urb(read int) failed", __func__); |
diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c index 19373cb7c5bf..fc064e1442ca 100644 --- a/drivers/usb/serial/kl5kusb105.c +++ b/drivers/usb/serial/kl5kusb105.c | |||
@@ -49,7 +49,7 @@ | |||
49 | #include <linux/usb/serial.h> | 49 | #include <linux/usb/serial.h> |
50 | #include "kl5kusb105.h" | 50 | #include "kl5kusb105.h" |
51 | 51 | ||
52 | static int debug; | 52 | static bool debug; |
53 | 53 | ||
54 | /* | 54 | /* |
55 | * Version Information | 55 | * Version Information |
diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c index ddd146300ddb..5d3beeeb5fd9 100644 --- a/drivers/usb/serial/kobil_sct.c +++ b/drivers/usb/serial/kobil_sct.c | |||
@@ -20,18 +20,6 @@ | |||
20 | * | 20 | * |
21 | * Supported readers: USB TWIN, KAAN Standard Plus and SecOVID Reader Plus | 21 | * Supported readers: USB TWIN, KAAN Standard Plus and SecOVID Reader Plus |
22 | * (Adapter K), B1 Professional and KAAN Professional (Adapter B) | 22 | * (Adapter K), B1 Professional and KAAN Professional (Adapter B) |
23 | * | ||
24 | * (21/05/2004) tw | ||
25 | * Fix bug with P'n'P readers | ||
26 | * | ||
27 | * (28/05/2003) tw | ||
28 | * Add support for KAAN SIM | ||
29 | * | ||
30 | * (12/09/2002) tw | ||
31 | * Adapted to 2.5. | ||
32 | * | ||
33 | * (11/08/2002) tw | ||
34 | * Initial version. | ||
35 | */ | 23 | */ |
36 | 24 | ||
37 | 25 | ||
@@ -231,9 +219,6 @@ static int kobil_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
231 | dbg("%s - port %d", __func__, port->number); | 219 | dbg("%s - port %d", __func__, port->number); |
232 | priv = usb_get_serial_port_data(port); | 220 | priv = usb_get_serial_port_data(port); |
233 | 221 | ||
234 | /* someone sets the dev to 0 if the close method has been called */ | ||
235 | port->interrupt_in_urb->dev = port->serial->dev; | ||
236 | |||
237 | /* allocate memory for transfer buffer */ | 222 | /* allocate memory for transfer buffer */ |
238 | transfer_buffer = kzalloc(transfer_buffer_length, GFP_KERNEL); | 223 | transfer_buffer = kzalloc(transfer_buffer_length, GFP_KERNEL); |
239 | if (!transfer_buffer) | 224 | if (!transfer_buffer) |
@@ -393,8 +378,6 @@ static void kobil_read_int_callback(struct urb *urb) | |||
393 | tty_flip_buffer_push(tty); | 378 | tty_flip_buffer_push(tty); |
394 | } | 379 | } |
395 | tty_kref_put(tty); | 380 | tty_kref_put(tty); |
396 | /* someone sets the dev to 0 if the close method has been called */ | ||
397 | port->interrupt_in_urb->dev = port->serial->dev; | ||
398 | 381 | ||
399 | result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); | 382 | result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); |
400 | dbg("%s - port %d Send read URB returns: %i", | 383 | dbg("%s - port %d Send read URB returns: %i", |
@@ -475,17 +458,9 @@ static int kobil_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
475 | priv->filled = 0; | 458 | priv->filled = 0; |
476 | priv->cur_pos = 0; | 459 | priv->cur_pos = 0; |
477 | 460 | ||
478 | /* someone sets the dev to 0 if the close method | ||
479 | has been called */ | ||
480 | port->interrupt_in_urb->dev = port->serial->dev; | ||
481 | |||
482 | /* start reading (except TWIN and KAAN SIM) */ | 461 | /* start reading (except TWIN and KAAN SIM) */ |
483 | if (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID || | 462 | if (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID || |
484 | priv->device_type == KOBIL_ADAPTER_K_PRODUCT_ID) { | 463 | priv->device_type == KOBIL_ADAPTER_K_PRODUCT_ID) { |
485 | /* someone sets the dev to 0 if the close method has | ||
486 | been called */ | ||
487 | port->interrupt_in_urb->dev = port->serial->dev; | ||
488 | |||
489 | result = usb_submit_urb(port->interrupt_in_urb, | 464 | result = usb_submit_urb(port->interrupt_in_urb, |
490 | GFP_NOIO); | 465 | GFP_NOIO); |
491 | dbg("%s - port %d Send read URB returns: %i", | 466 | dbg("%s - port %d Send read URB returns: %i", |
diff --git a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c index ba0d28727ccb..27fa9c8a77b0 100644 --- a/drivers/usb/serial/mct_u232.c +++ b/drivers/usb/serial/mct_u232.c | |||
@@ -19,50 +19,6 @@ | |||
19 | * DTR/RTS signal handling may be incomplete or incorrect. I have mainly | 19 | * DTR/RTS signal handling may be incomplete or incorrect. I have mainly |
20 | * implemented what I have seen with SniffUSB or found in belkin_sa.c. | 20 | * implemented what I have seen with SniffUSB or found in belkin_sa.c. |
21 | * For further TODOs check also belkin_sa.c. | 21 | * For further TODOs check also belkin_sa.c. |
22 | * | ||
23 | * TEST STATUS: | ||
24 | * Basic tests have been performed with minicom/zmodem transfers and | ||
25 | * modem dialing under Linux 2.4.0-test10 (for me it works fine). | ||
26 | * | ||
27 | * 04-Nov-2003 Bill Marr <marr at flex dot com> | ||
28 | * - Mimic Windows driver by sending 2 USB 'device request' messages | ||
29 | * following normal 'baud rate change' message. This allows data to be | ||
30 | * transmitted to RS-232 devices which don't assert the 'CTS' signal. | ||
31 | * | ||
32 | * 10-Nov-2001 Wolfgang Grandegger | ||
33 | * - Fixed an endianess problem with the baudrate selection for PowerPC. | ||
34 | * | ||
35 | * 06-Dec-2001 Martin Hamilton <martinh@gnu.org> | ||
36 | * - Added support for the Belkin F5U109 DB9 adaptor | ||
37 | * | ||
38 | * 30-May-2001 Greg Kroah-Hartman | ||
39 | * - switched from using spinlock to a semaphore, which fixes lots of | ||
40 | * problems. | ||
41 | * | ||
42 | * 04-May-2001 Stelian Pop | ||
43 | * - Set the maximum bulk output size for Sitecom U232-P25 model to 16 bytes | ||
44 | * instead of the device reported 32 (using 32 bytes causes many data | ||
45 | * loss, Windows driver uses 16 too). | ||
46 | * | ||
47 | * 02-May-2001 Stelian Pop | ||
48 | * - Fixed the baud calculation for Sitecom U232-P25 model | ||
49 | * | ||
50 | * 08-Apr-2001 gb | ||
51 | * - Identify version on module load. | ||
52 | * | ||
53 | * 06-Jan-2001 Cornel Ciocirlan | ||
54 | * - Added support for Sitecom U232-P25 model (Product Id 0x0230) | ||
55 | * - Added support for D-Link DU-H3SP USB BAY (Product Id 0x0200) | ||
56 | * | ||
57 | * 29-Nov-2000 Greg Kroah-Hartman | ||
58 | * - Added device id table to fit with 2.4.0-test11 structure. | ||
59 | * - took out DEAL_WITH_TWO_INT_IN_ENDPOINTS #define as it's not needed | ||
60 | * (lots of things will change if/when the usb-serial core changes to | ||
61 | * handle these issues. | ||
62 | * | ||
63 | * 27-Nov-2000 Wolfgang Grandegge | ||
64 | * A version for kernel 2.4.0-test10 released to the Linux community | ||
65 | * (via linux-usb-devel). | ||
66 | */ | 22 | */ |
67 | 23 | ||
68 | #include <linux/kernel.h> | 24 | #include <linux/kernel.h> |
@@ -89,7 +45,7 @@ | |||
89 | #define DRIVER_AUTHOR "Wolfgang Grandegger <wolfgang@ces.ch>" | 45 | #define DRIVER_AUTHOR "Wolfgang Grandegger <wolfgang@ces.ch>" |
90 | #define DRIVER_DESC "Magic Control Technology USB-RS232 converter driver" | 46 | #define DRIVER_DESC "Magic Control Technology USB-RS232 converter driver" |
91 | 47 | ||
92 | static int debug; | 48 | static bool debug; |
93 | 49 | ||
94 | /* | 50 | /* |
95 | * Function prototypes | 51 | * Function prototypes |
@@ -526,7 +482,6 @@ static int mct_u232_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
526 | mct_u232_msr_to_state(&priv->control_state, priv->last_msr); | 482 | mct_u232_msr_to_state(&priv->control_state, priv->last_msr); |
527 | spin_unlock_irqrestore(&priv->lock, flags); | 483 | spin_unlock_irqrestore(&priv->lock, flags); |
528 | 484 | ||
529 | port->read_urb->dev = port->serial->dev; | ||
530 | retval = usb_submit_urb(port->read_urb, GFP_KERNEL); | 485 | retval = usb_submit_urb(port->read_urb, GFP_KERNEL); |
531 | if (retval) { | 486 | if (retval) { |
532 | dev_err(&port->dev, | 487 | dev_err(&port->dev, |
@@ -535,7 +490,6 @@ static int mct_u232_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
535 | goto error; | 490 | goto error; |
536 | } | 491 | } |
537 | 492 | ||
538 | port->interrupt_in_urb->dev = port->serial->dev; | ||
539 | retval = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); | 493 | retval = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); |
540 | if (retval) { | 494 | if (retval) { |
541 | usb_kill_urb(port->read_urb); | 495 | usb_kill_urb(port->read_urb); |
diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c index 3524a105d042..4554ee49e635 100644 --- a/drivers/usb/serial/mos7720.c +++ b/drivers/usb/serial/mos7720.c | |||
@@ -71,7 +71,7 @@ struct moschip_port { | |||
71 | struct urb *write_urb_pool[NUM_URBS]; | 71 | struct urb *write_urb_pool[NUM_URBS]; |
72 | }; | 72 | }; |
73 | 73 | ||
74 | static int debug; | 74 | static bool debug; |
75 | 75 | ||
76 | static struct usb_serial_driver moschip7720_2port_driver; | 76 | static struct usb_serial_driver moschip7720_2port_driver; |
77 | 77 | ||
@@ -939,14 +939,7 @@ static void mos7720_bulk_in_callback(struct urb *urb) | |||
939 | } | 939 | } |
940 | tty_kref_put(tty); | 940 | tty_kref_put(tty); |
941 | 941 | ||
942 | if (!port->read_urb) { | ||
943 | dbg("URB KILLED !!!"); | ||
944 | return; | ||
945 | } | ||
946 | |||
947 | if (port->read_urb->status != -EINPROGRESS) { | 942 | if (port->read_urb->status != -EINPROGRESS) { |
948 | port->read_urb->dev = port->serial->dev; | ||
949 | |||
950 | retval = usb_submit_urb(port->read_urb, GFP_ATOMIC); | 943 | retval = usb_submit_urb(port->read_urb, GFP_ATOMIC); |
951 | if (retval) | 944 | if (retval) |
952 | dbg("usb_submit_urb(read bulk) failed, retval = %d", | 945 | dbg("usb_submit_urb(read bulk) failed, retval = %d", |
@@ -1014,7 +1007,6 @@ static int mos77xx_calc_num_ports(struct usb_serial *serial) | |||
1014 | static int mos7720_open(struct tty_struct *tty, struct usb_serial_port *port) | 1007 | static int mos7720_open(struct tty_struct *tty, struct usb_serial_port *port) |
1015 | { | 1008 | { |
1016 | struct usb_serial *serial; | 1009 | struct usb_serial *serial; |
1017 | struct usb_serial_port *port0; | ||
1018 | struct urb *urb; | 1010 | struct urb *urb; |
1019 | struct moschip_port *mos7720_port; | 1011 | struct moschip_port *mos7720_port; |
1020 | int response; | 1012 | int response; |
@@ -1029,8 +1021,6 @@ static int mos7720_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
1029 | if (mos7720_port == NULL) | 1021 | if (mos7720_port == NULL) |
1030 | return -ENODEV; | 1022 | return -ENODEV; |
1031 | 1023 | ||
1032 | port0 = serial->port[0]; | ||
1033 | |||
1034 | usb_clear_halt(serial->dev, port->write_urb->pipe); | 1024 | usb_clear_halt(serial->dev, port->write_urb->pipe); |
1035 | usb_clear_halt(serial->dev, port->read_urb->pipe); | 1025 | usb_clear_halt(serial->dev, port->read_urb->pipe); |
1036 | 1026 | ||
@@ -1735,8 +1725,6 @@ static void change_port_settings(struct tty_struct *tty, | |||
1735 | write_mos_reg(serial, port_number, IER, 0x0c); | 1725 | write_mos_reg(serial, port_number, IER, 0x0c); |
1736 | 1726 | ||
1737 | if (port->read_urb->status != -EINPROGRESS) { | 1727 | if (port->read_urb->status != -EINPROGRESS) { |
1738 | port->read_urb->dev = serial->dev; | ||
1739 | |||
1740 | status = usb_submit_urb(port->read_urb, GFP_ATOMIC); | 1728 | status = usb_submit_urb(port->read_urb, GFP_ATOMIC); |
1741 | if (status) | 1729 | if (status) |
1742 | dbg("usb_submit_urb(read bulk) failed, status = %d", | 1730 | dbg("usb_submit_urb(read bulk) failed, status = %d", |
@@ -1786,13 +1774,7 @@ static void mos7720_set_termios(struct tty_struct *tty, | |||
1786 | /* change the port settings to the new ones specified */ | 1774 | /* change the port settings to the new ones specified */ |
1787 | change_port_settings(tty, mos7720_port, old_termios); | 1775 | change_port_settings(tty, mos7720_port, old_termios); |
1788 | 1776 | ||
1789 | if (!port->read_urb) { | ||
1790 | dbg("%s", "URB KILLED !!!!!"); | ||
1791 | return; | ||
1792 | } | ||
1793 | |||
1794 | if (port->read_urb->status != -EINPROGRESS) { | 1777 | if (port->read_urb->status != -EINPROGRESS) { |
1795 | port->read_urb->dev = serial->dev; | ||
1796 | status = usb_submit_urb(port->read_urb, GFP_ATOMIC); | 1778 | status = usb_submit_urb(port->read_urb, GFP_ATOMIC); |
1797 | if (status) | 1779 | if (status) |
1798 | dbg("usb_submit_urb(read bulk) failed, status = %d", | 1780 | dbg("usb_submit_urb(read bulk) failed, status = %d", |
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c index c72abd524983..03b5e249e95e 100644 --- a/drivers/usb/serial/mos7840.c +++ b/drivers/usb/serial/mos7840.c | |||
@@ -263,7 +263,7 @@ struct moschip_port { | |||
263 | }; | 263 | }; |
264 | 264 | ||
265 | 265 | ||
266 | static int debug; | 266 | static bool debug; |
267 | 267 | ||
268 | /* | 268 | /* |
269 | * mos7840_set_reg_sync | 269 | * mos7840_set_reg_sync |
@@ -792,8 +792,6 @@ static void mos7840_bulk_in_callback(struct urb *urb) | |||
792 | } | 792 | } |
793 | 793 | ||
794 | 794 | ||
795 | mos7840_port->read_urb->dev = serial->dev; | ||
796 | |||
797 | mos7840_port->read_urb_busy = true; | 795 | mos7840_port->read_urb_busy = true; |
798 | retval = usb_submit_urb(mos7840_port->read_urb, GFP_ATOMIC); | 796 | retval = usb_submit_urb(mos7840_port->read_urb, GFP_ATOMIC); |
799 | 797 | ||
@@ -2058,7 +2056,6 @@ static void mos7840_change_port_settings(struct tty_struct *tty, | |||
2058 | mos7840_set_uart_reg(port, INTERRUPT_ENABLE_REGISTER, Data); | 2056 | mos7840_set_uart_reg(port, INTERRUPT_ENABLE_REGISTER, Data); |
2059 | 2057 | ||
2060 | if (mos7840_port->read_urb_busy == false) { | 2058 | if (mos7840_port->read_urb_busy == false) { |
2061 | mos7840_port->read_urb->dev = serial->dev; | ||
2062 | mos7840_port->read_urb_busy = true; | 2059 | mos7840_port->read_urb_busy = true; |
2063 | status = usb_submit_urb(mos7840_port->read_urb, GFP_ATOMIC); | 2060 | status = usb_submit_urb(mos7840_port->read_urb, GFP_ATOMIC); |
2064 | if (status) { | 2061 | if (status) { |
@@ -2130,7 +2127,6 @@ static void mos7840_set_termios(struct tty_struct *tty, | |||
2130 | } | 2127 | } |
2131 | 2128 | ||
2132 | if (mos7840_port->read_urb_busy == false) { | 2129 | if (mos7840_port->read_urb_busy == false) { |
2133 | mos7840_port->read_urb->dev = serial->dev; | ||
2134 | mos7840_port->read_urb_busy = true; | 2130 | mos7840_port->read_urb_busy = true; |
2135 | status = usb_submit_urb(mos7840_port->read_urb, GFP_ATOMIC); | 2131 | status = usb_submit_urb(mos7840_port->read_urb, GFP_ATOMIC); |
2136 | if (status) { | 2132 | if (status) { |
diff --git a/drivers/usb/serial/navman.c b/drivers/usb/serial/navman.c index 1f00f243c26c..b28f1db0195f 100644 --- a/drivers/usb/serial/navman.c +++ b/drivers/usb/serial/navman.c | |||
@@ -21,7 +21,7 @@ | |||
21 | #include <linux/usb.h> | 21 | #include <linux/usb.h> |
22 | #include <linux/usb/serial.h> | 22 | #include <linux/usb/serial.h> |
23 | 23 | ||
24 | static int debug; | 24 | static bool debug; |
25 | 25 | ||
26 | static const struct usb_device_id id_table[] = { | 26 | static const struct usb_device_id id_table[] = { |
27 | { USB_DEVICE(0x0a99, 0x0001) }, /* Talon Technology device */ | 27 | { USB_DEVICE(0x0a99, 0x0001) }, /* Talon Technology device */ |
diff --git a/drivers/usb/serial/omninet.c b/drivers/usb/serial/omninet.c index 60f38d5e64fc..8b8d58a2ac12 100644 --- a/drivers/usb/serial/omninet.c +++ b/drivers/usb/serial/omninet.c | |||
@@ -9,31 +9,6 @@ | |||
9 | * driver | 9 | * driver |
10 | * | 10 | * |
11 | * Please report both successes and troubles to the author at omninet@kroah.com | 11 | * Please report both successes and troubles to the author at omninet@kroah.com |
12 | * | ||
13 | * (05/30/2001) gkh | ||
14 | * switched from using spinlock to a semaphore, which fixes lots of | ||
15 | * problems. | ||
16 | * | ||
17 | * (04/08/2001) gb | ||
18 | * Identify version on module load. | ||
19 | * | ||
20 | * (11/01/2000) Adam J. Richter | ||
21 | * usb_device_id table support | ||
22 | * | ||
23 | * (10/05/2000) gkh | ||
24 | * Fixed bug with urb->dev not being set properly, now that the usb | ||
25 | * core needs it. | ||
26 | * | ||
27 | * (08/28/2000) gkh | ||
28 | * Added locks for SMP safeness. | ||
29 | * Fixed MOD_INC and MOD_DEC logic and the ability to open a port more | ||
30 | * than once. | ||
31 | * Fixed potential race in omninet_write_bulk_callback | ||
32 | * | ||
33 | * (07/19/2000) gkh | ||
34 | * Added module_init and module_exit functions to handle the fact that this | ||
35 | * driver is a loadable module now. | ||
36 | * | ||
37 | */ | 12 | */ |
38 | 13 | ||
39 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
@@ -44,12 +19,11 @@ | |||
44 | #include <linux/tty_driver.h> | 19 | #include <linux/tty_driver.h> |
45 | #include <linux/tty_flip.h> | 20 | #include <linux/tty_flip.h> |
46 | #include <linux/module.h> | 21 | #include <linux/module.h> |
47 | #include <linux/spinlock.h> | ||
48 | #include <linux/uaccess.h> | 22 | #include <linux/uaccess.h> |
49 | #include <linux/usb.h> | 23 | #include <linux/usb.h> |
50 | #include <linux/usb/serial.h> | 24 | #include <linux/usb/serial.h> |
51 | 25 | ||
52 | static int debug; | 26 | static bool debug; |
53 | 27 | ||
54 | /* | 28 | /* |
55 | * Version Information | 29 | * Version Information |
@@ -174,12 +148,6 @@ static int omninet_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
174 | tty_port_tty_set(&wport->port, tty); | 148 | tty_port_tty_set(&wport->port, tty); |
175 | 149 | ||
176 | /* Start reading from the device */ | 150 | /* Start reading from the device */ |
177 | usb_fill_bulk_urb(port->read_urb, serial->dev, | ||
178 | usb_rcvbulkpipe(serial->dev, | ||
179 | port->bulk_in_endpointAddress), | ||
180 | port->read_urb->transfer_buffer, | ||
181 | port->read_urb->transfer_buffer_length, | ||
182 | omninet_read_bulk_callback, port); | ||
183 | result = usb_submit_urb(port->read_urb, GFP_KERNEL); | 151 | result = usb_submit_urb(port->read_urb, GFP_KERNEL); |
184 | if (result) | 152 | if (result) |
185 | dev_err(&port->dev, | 153 | dev_err(&port->dev, |
@@ -236,11 +204,6 @@ static void omninet_read_bulk_callback(struct urb *urb) | |||
236 | } | 204 | } |
237 | 205 | ||
238 | /* Continue trying to always read */ | 206 | /* Continue trying to always read */ |
239 | usb_fill_bulk_urb(urb, port->serial->dev, | ||
240 | usb_rcvbulkpipe(port->serial->dev, | ||
241 | port->bulk_in_endpointAddress), | ||
242 | urb->transfer_buffer, urb->transfer_buffer_length, | ||
243 | omninet_read_bulk_callback, port); | ||
244 | result = usb_submit_urb(urb, GFP_ATOMIC); | 207 | result = usb_submit_urb(urb, GFP_ATOMIC); |
245 | if (result) | 208 | if (result) |
246 | dev_err(&port->dev, | 209 | dev_err(&port->dev, |
@@ -267,14 +230,10 @@ static int omninet_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
267 | return 0; | 230 | return 0; |
268 | } | 231 | } |
269 | 232 | ||
270 | spin_lock_bh(&wport->lock); | 233 | if (!test_and_clear_bit(0, &port->write_urbs_free)) { |
271 | if (wport->write_urb_busy) { | ||
272 | spin_unlock_bh(&wport->lock); | ||
273 | dbg("%s - already writing", __func__); | 234 | dbg("%s - already writing", __func__); |
274 | return 0; | 235 | return 0; |
275 | } | 236 | } |
276 | wport->write_urb_busy = 1; | ||
277 | spin_unlock_bh(&wport->lock); | ||
278 | 237 | ||
279 | count = (count > OMNINET_BULKOUTSIZE) ? OMNINET_BULKOUTSIZE : count; | 238 | count = (count > OMNINET_BULKOUTSIZE) ? OMNINET_BULKOUTSIZE : count; |
280 | 239 | ||
@@ -292,10 +251,9 @@ static int omninet_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
292 | /* send the data out the bulk port, always 64 bytes */ | 251 | /* send the data out the bulk port, always 64 bytes */ |
293 | wport->write_urb->transfer_buffer_length = 64; | 252 | wport->write_urb->transfer_buffer_length = 64; |
294 | 253 | ||
295 | wport->write_urb->dev = serial->dev; | ||
296 | result = usb_submit_urb(wport->write_urb, GFP_ATOMIC); | 254 | result = usb_submit_urb(wport->write_urb, GFP_ATOMIC); |
297 | if (result) { | 255 | if (result) { |
298 | wport->write_urb_busy = 0; | 256 | set_bit(0, &wport->write_urbs_free); |
299 | dev_err(&port->dev, | 257 | dev_err(&port->dev, |
300 | "%s - failed submitting write urb, error %d\n", | 258 | "%s - failed submitting write urb, error %d\n", |
301 | __func__, result); | 259 | __func__, result); |
@@ -314,8 +272,7 @@ static int omninet_write_room(struct tty_struct *tty) | |||
314 | 272 | ||
315 | int room = 0; /* Default: no room */ | 273 | int room = 0; /* Default: no room */ |
316 | 274 | ||
317 | /* FIXME: no consistent locking for write_urb_busy */ | 275 | if (test_bit(0, &wport->write_urbs_free)) |
318 | if (wport->write_urb_busy) | ||
319 | room = wport->bulk_out_size - OMNINET_HEADERLEN; | 276 | room = wport->bulk_out_size - OMNINET_HEADERLEN; |
320 | 277 | ||
321 | dbg("%s - returns %d", __func__, room); | 278 | dbg("%s - returns %d", __func__, room); |
@@ -332,7 +289,7 @@ static void omninet_write_bulk_callback(struct urb *urb) | |||
332 | 289 | ||
333 | dbg("%s - port %0x", __func__, port->number); | 290 | dbg("%s - port %0x", __func__, port->number); |
334 | 291 | ||
335 | port->write_urb_busy = 0; | 292 | set_bit(0, &port->write_urbs_free); |
336 | if (status) { | 293 | if (status) { |
337 | dbg("%s - nonzero write bulk status received: %d", | 294 | dbg("%s - nonzero write bulk status received: %d", |
338 | __func__, status); | 295 | __func__, status); |
diff --git a/drivers/usb/serial/opticon.c b/drivers/usb/serial/opticon.c index c248a9147439..262ded9e076b 100644 --- a/drivers/usb/serial/opticon.c +++ b/drivers/usb/serial/opticon.c | |||
@@ -32,7 +32,7 @@ | |||
32 | * an examples of 1D barcode types are EAN, UPC, Code39, IATA etc.. */ | 32 | * an examples of 1D barcode types are EAN, UPC, Code39, IATA etc.. */ |
33 | #define DRIVER_DESC "Opticon USB barcode to serial driver (1D)" | 33 | #define DRIVER_DESC "Opticon USB barcode to serial driver (1D)" |
34 | 34 | ||
35 | static int debug; | 35 | static bool debug; |
36 | 36 | ||
37 | static const struct usb_device_id id_table[] = { | 37 | static const struct usb_device_id id_table[] = { |
38 | { USB_DEVICE(0x065a, 0x0009) }, | 38 | { USB_DEVICE(0x065a, 0x0009) }, |
@@ -384,7 +384,6 @@ static void opticon_unthrottle(struct tty_struct *tty) | |||
384 | priv->actually_throttled = false; | 384 | priv->actually_throttled = false; |
385 | spin_unlock_irqrestore(&priv->lock, flags); | 385 | spin_unlock_irqrestore(&priv->lock, flags); |
386 | 386 | ||
387 | priv->bulk_read_urb->dev = port->serial->dev; | ||
388 | if (was_throttled) { | 387 | if (was_throttled) { |
389 | result = usb_submit_urb(priv->bulk_read_urb, GFP_ATOMIC); | 388 | result = usb_submit_urb(priv->bulk_read_urb, GFP_ATOMIC); |
390 | if (result) | 389 | if (result) |
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index 89ae1f65e1b1..420d9857394a 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c | |||
@@ -156,6 +156,7 @@ static void option_instat_callback(struct urb *urb); | |||
156 | #define HUAWEI_PRODUCT_K4511 0x14CC | 156 | #define HUAWEI_PRODUCT_K4511 0x14CC |
157 | #define HUAWEI_PRODUCT_ETS1220 0x1803 | 157 | #define HUAWEI_PRODUCT_ETS1220 0x1803 |
158 | #define HUAWEI_PRODUCT_E353 0x1506 | 158 | #define HUAWEI_PRODUCT_E353 0x1506 |
159 | #define HUAWEI_PRODUCT_E173S 0x1C05 | ||
159 | 160 | ||
160 | #define QUANTA_VENDOR_ID 0x0408 | 161 | #define QUANTA_VENDOR_ID 0x0408 |
161 | #define QUANTA_PRODUCT_Q101 0xEA02 | 162 | #define QUANTA_PRODUCT_Q101 0xEA02 |
@@ -316,6 +317,9 @@ static void option_instat_callback(struct urb *urb); | |||
316 | #define ZTE_PRODUCT_AC8710 0xfff1 | 317 | #define ZTE_PRODUCT_AC8710 0xfff1 |
317 | #define ZTE_PRODUCT_AC2726 0xfff5 | 318 | #define ZTE_PRODUCT_AC2726 0xfff5 |
318 | #define ZTE_PRODUCT_AC8710T 0xffff | 319 | #define ZTE_PRODUCT_AC8710T 0xffff |
320 | #define ZTE_PRODUCT_MC2718 0xffe8 | ||
321 | #define ZTE_PRODUCT_AD3812 0xffeb | ||
322 | #define ZTE_PRODUCT_MC2716 0xffed | ||
319 | 323 | ||
320 | #define BENQ_VENDOR_ID 0x04a5 | 324 | #define BENQ_VENDOR_ID 0x04a5 |
321 | #define BENQ_PRODUCT_H10 0x4068 | 325 | #define BENQ_PRODUCT_H10 0x4068 |
@@ -468,6 +472,14 @@ static void option_instat_callback(struct urb *urb); | |||
468 | #define YUGA_PRODUCT_CLU528 0x260D | 472 | #define YUGA_PRODUCT_CLU528 0x260D |
469 | #define YUGA_PRODUCT_CLU526 0x260F | 473 | #define YUGA_PRODUCT_CLU526 0x260F |
470 | 474 | ||
475 | /* Viettel products */ | ||
476 | #define VIETTEL_VENDOR_ID 0x2262 | ||
477 | #define VIETTEL_PRODUCT_VT1000 0x0002 | ||
478 | |||
479 | /* ZD Incorporated */ | ||
480 | #define ZD_VENDOR_ID 0x0685 | ||
481 | #define ZD_PRODUCT_7000 0x7000 | ||
482 | |||
471 | /* some devices interfaces need special handling due to a number of reasons */ | 483 | /* some devices interfaces need special handling due to a number of reasons */ |
472 | enum option_blacklist_reason { | 484 | enum option_blacklist_reason { |
473 | OPTION_BLACKLIST_NONE = 0, | 485 | OPTION_BLACKLIST_NONE = 0, |
@@ -500,6 +512,18 @@ static const struct option_blacklist_info zte_k3765_z_blacklist = { | |||
500 | .reserved = BIT(4), | 512 | .reserved = BIT(4), |
501 | }; | 513 | }; |
502 | 514 | ||
515 | static const struct option_blacklist_info zte_ad3812_z_blacklist = { | ||
516 | .sendsetup = BIT(0) | BIT(1) | BIT(2), | ||
517 | }; | ||
518 | |||
519 | static const struct option_blacklist_info zte_mc2718_z_blacklist = { | ||
520 | .sendsetup = BIT(1) | BIT(2) | BIT(3) | BIT(4), | ||
521 | }; | ||
522 | |||
523 | static const struct option_blacklist_info zte_mc2716_z_blacklist = { | ||
524 | .sendsetup = BIT(1) | BIT(2) | BIT(3), | ||
525 | }; | ||
526 | |||
503 | static const struct option_blacklist_info huawei_cdc12_blacklist = { | 527 | static const struct option_blacklist_info huawei_cdc12_blacklist = { |
504 | .reserved = BIT(1) | BIT(2), | 528 | .reserved = BIT(1) | BIT(2), |
505 | }; | 529 | }; |
@@ -622,6 +646,7 @@ static const struct usb_device_id option_ids[] = { | |||
622 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E143D, 0xff, 0xff, 0xff) }, | 646 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E143D, 0xff, 0xff, 0xff) }, |
623 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E143E, 0xff, 0xff, 0xff) }, | 647 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E143E, 0xff, 0xff, 0xff) }, |
624 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E143F, 0xff, 0xff, 0xff) }, | 648 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E143F, 0xff, 0xff, 0xff) }, |
649 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E173S, 0xff, 0xff, 0xff) }, | ||
625 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_K4505, 0xff, 0xff, 0xff), | 650 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_K4505, 0xff, 0xff, 0xff), |
626 | .driver_info = (kernel_ulong_t) &huawei_cdc12_blacklist }, | 651 | .driver_info = (kernel_ulong_t) &huawei_cdc12_blacklist }, |
627 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_K3765, 0xff, 0xff, 0xff), | 652 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_K3765, 0xff, 0xff, 0xff), |
@@ -640,6 +665,14 @@ static const struct usb_device_id option_ids[] = { | |||
640 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_K4511, 0xff, 0x01, 0x31) }, | 665 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_K4511, 0xff, 0x01, 0x31) }, |
641 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_K4511, 0xff, 0x01, 0x32) }, | 666 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_K4511, 0xff, 0x01, 0x32) }, |
642 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E353, 0xff, 0x01, 0x01) }, | 667 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E353, 0xff, 0x01, 0x01) }, |
668 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E353, 0xff, 0x01, 0x02) }, | ||
669 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E353, 0xff, 0x01, 0x03) }, | ||
670 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E353, 0xff, 0x01, 0x10) }, | ||
671 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E353, 0xff, 0x01, 0x12) }, | ||
672 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E353, 0xff, 0x01, 0x13) }, | ||
673 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E353, 0xff, 0x02, 0x01) }, /* E398 3G Modem */ | ||
674 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E353, 0xff, 0x02, 0x02) }, /* E398 3G PC UI Interface */ | ||
675 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E353, 0xff, 0x02, 0x03) }, /* E398 3G Application Interface */ | ||
643 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_V640) }, | 676 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_V640) }, |
644 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_V620) }, | 677 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_V620) }, |
645 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_V740) }, | 678 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_V740) }, |
@@ -726,6 +759,7 @@ static const struct usb_device_id option_ids[] = { | |||
726 | { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC680) }, | 759 | { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC680) }, |
727 | { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6000)}, /* ZTE AC8700 */ | 760 | { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6000)}, /* ZTE AC8700 */ |
728 | { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6613)}, /* Onda H600/ZTE MF330 */ | 761 | { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6613)}, /* Onda H600/ZTE MF330 */ |
762 | { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x9000)}, /* SIMCom SIM5218 */ | ||
729 | { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6280) }, /* BP3-USB & BP3-EXT HSDPA */ | 763 | { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6280) }, /* BP3-USB & BP3-EXT HSDPA */ |
730 | { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6008) }, | 764 | { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6008) }, |
731 | { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UC864E) }, | 765 | { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UC864E) }, |
@@ -1043,6 +1077,12 @@ static const struct usb_device_id option_ids[] = { | |||
1043 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC8710, 0xff, 0xff, 0xff) }, | 1077 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC8710, 0xff, 0xff, 0xff) }, |
1044 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC2726, 0xff, 0xff, 0xff) }, | 1078 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC2726, 0xff, 0xff, 0xff) }, |
1045 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC8710T, 0xff, 0xff, 0xff) }, | 1079 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC8710T, 0xff, 0xff, 0xff) }, |
1080 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MC2718, 0xff, 0xff, 0xff), | ||
1081 | .driver_info = (kernel_ulong_t)&zte_mc2718_z_blacklist }, | ||
1082 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AD3812, 0xff, 0xff, 0xff), | ||
1083 | .driver_info = (kernel_ulong_t)&zte_ad3812_z_blacklist }, | ||
1084 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MC2716, 0xff, 0xff, 0xff), | ||
1085 | .driver_info = (kernel_ulong_t)&zte_mc2716_z_blacklist }, | ||
1046 | { USB_DEVICE(BENQ_VENDOR_ID, BENQ_PRODUCT_H10) }, | 1086 | { USB_DEVICE(BENQ_VENDOR_ID, BENQ_PRODUCT_H10) }, |
1047 | { USB_DEVICE(DLINK_VENDOR_ID, DLINK_PRODUCT_DWM_652) }, | 1087 | { USB_DEVICE(DLINK_VENDOR_ID, DLINK_PRODUCT_DWM_652) }, |
1048 | { USB_DEVICE(ALINK_VENDOR_ID, DLINK_PRODUCT_DWM_652_U5) }, /* Yes, ALINK_VENDOR_ID */ | 1088 | { USB_DEVICE(ALINK_VENDOR_ID, DLINK_PRODUCT_DWM_652_U5) }, /* Yes, ALINK_VENDOR_ID */ |
@@ -1141,6 +1181,8 @@ static const struct usb_device_id option_ids[] = { | |||
1141 | { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CLU516) }, | 1181 | { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CLU516) }, |
1142 | { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CLU528) }, | 1182 | { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CLU528) }, |
1143 | { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CLU526) }, | 1183 | { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CLU526) }, |
1184 | { USB_DEVICE_AND_INTERFACE_INFO(VIETTEL_VENDOR_ID, VIETTEL_PRODUCT_VT1000, 0xff, 0xff, 0xff) }, | ||
1185 | { USB_DEVICE_AND_INTERFACE_INFO(ZD_VENDOR_ID, ZD_PRODUCT_7000, 0xff, 0xff, 0xff) }, | ||
1144 | { } /* Terminating entry */ | 1186 | { } /* Terminating entry */ |
1145 | }; | 1187 | }; |
1146 | MODULE_DEVICE_TABLE(usb, option_ids); | 1188 | MODULE_DEVICE_TABLE(usb, option_ids); |
@@ -1192,7 +1234,7 @@ static struct usb_serial_driver option_1port_device = { | |||
1192 | #endif | 1234 | #endif |
1193 | }; | 1235 | }; |
1194 | 1236 | ||
1195 | static int debug; | 1237 | static bool debug; |
1196 | 1238 | ||
1197 | /* per port private data */ | 1239 | /* per port private data */ |
1198 | 1240 | ||
diff --git a/drivers/usb/serial/oti6858.c b/drivers/usb/serial/oti6858.c index 4c29e6c2bda7..e287fd32682c 100644 --- a/drivers/usb/serial/oti6858.c +++ b/drivers/usb/serial/oti6858.c | |||
@@ -74,7 +74,7 @@ static struct usb_driver oti6858_driver = { | |||
74 | .no_dynamic_id = 1, | 74 | .no_dynamic_id = 1, |
75 | }; | 75 | }; |
76 | 76 | ||
77 | static int debug; | 77 | static bool debug; |
78 | 78 | ||
79 | /* requests */ | 79 | /* requests */ |
80 | #define OTI6858_REQ_GET_STATUS (USB_DIR_IN | USB_TYPE_VENDOR | 0x00) | 80 | #define OTI6858_REQ_GET_STATUS (USB_DIR_IN | USB_TYPE_VENDOR | 0x00) |
@@ -264,7 +264,6 @@ static void setup_line(struct work_struct *work) | |||
264 | spin_unlock_irqrestore(&priv->lock, flags); | 264 | spin_unlock_irqrestore(&priv->lock, flags); |
265 | 265 | ||
266 | dbg("%s(): submitting interrupt urb", __func__); | 266 | dbg("%s(): submitting interrupt urb", __func__); |
267 | port->interrupt_in_urb->dev = port->serial->dev; | ||
268 | result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); | 267 | result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); |
269 | if (result != 0) { | 268 | if (result != 0) { |
270 | dev_err(&port->dev, "%s(): usb_submit_urb() failed" | 269 | dev_err(&port->dev, "%s(): usb_submit_urb() failed" |
@@ -321,7 +320,6 @@ static void send_data(struct work_struct *work) | |||
321 | priv->flags.write_urb_in_use = 0; | 320 | priv->flags.write_urb_in_use = 0; |
322 | 321 | ||
323 | dbg("%s(): submitting interrupt urb", __func__); | 322 | dbg("%s(): submitting interrupt urb", __func__); |
324 | port->interrupt_in_urb->dev = port->serial->dev; | ||
325 | result = usb_submit_urb(port->interrupt_in_urb, GFP_NOIO); | 323 | result = usb_submit_urb(port->interrupt_in_urb, GFP_NOIO); |
326 | if (result != 0) { | 324 | if (result != 0) { |
327 | dev_err(&port->dev, "%s(): usb_submit_urb() failed" | 325 | dev_err(&port->dev, "%s(): usb_submit_urb() failed" |
@@ -334,7 +332,6 @@ static void send_data(struct work_struct *work) | |||
334 | port->write_urb->transfer_buffer, | 332 | port->write_urb->transfer_buffer, |
335 | count, &port->lock); | 333 | count, &port->lock); |
336 | port->write_urb->transfer_buffer_length = count; | 334 | port->write_urb->transfer_buffer_length = count; |
337 | port->write_urb->dev = port->serial->dev; | ||
338 | result = usb_submit_urb(port->write_urb, GFP_NOIO); | 335 | result = usb_submit_urb(port->write_urb, GFP_NOIO); |
339 | if (result != 0) { | 336 | if (result != 0) { |
340 | dev_err(&port->dev, "%s(): usb_submit_urb() failed" | 337 | dev_err(&port->dev, "%s(): usb_submit_urb() failed" |
@@ -583,13 +580,12 @@ static int oti6858_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
583 | kfree(buf); | 580 | kfree(buf); |
584 | 581 | ||
585 | dbg("%s(): submitting interrupt urb", __func__); | 582 | dbg("%s(): submitting interrupt urb", __func__); |
586 | port->interrupt_in_urb->dev = serial->dev; | ||
587 | result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); | 583 | result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); |
588 | if (result != 0) { | 584 | if (result != 0) { |
589 | dev_err(&port->dev, "%s(): usb_submit_urb() failed" | 585 | dev_err(&port->dev, "%s(): usb_submit_urb() failed" |
590 | " with error %d\n", __func__, result); | 586 | " with error %d\n", __func__, result); |
591 | oti6858_close(port); | 587 | oti6858_close(port); |
592 | return -EPROTO; | 588 | return result; |
593 | } | 589 | } |
594 | 590 | ||
595 | /* setup termios */ | 591 | /* setup termios */ |
@@ -837,7 +833,6 @@ static void oti6858_read_int_callback(struct urb *urb) | |||
837 | if (can_recv) { | 833 | if (can_recv) { |
838 | int result; | 834 | int result; |
839 | 835 | ||
840 | port->read_urb->dev = port->serial->dev; | ||
841 | result = usb_submit_urb(port->read_urb, GFP_ATOMIC); | 836 | result = usb_submit_urb(port->read_urb, GFP_ATOMIC); |
842 | if (result != 0) { | 837 | if (result != 0) { |
843 | priv->flags.read_urb_in_use = 0; | 838 | priv->flags.read_urb_in_use = 0; |
@@ -866,7 +861,6 @@ static void oti6858_read_int_callback(struct urb *urb) | |||
866 | int result; | 861 | int result; |
867 | 862 | ||
868 | /* dbg("%s(): submitting interrupt urb", __func__); */ | 863 | /* dbg("%s(): submitting interrupt urb", __func__); */ |
869 | urb->dev = port->serial->dev; | ||
870 | result = usb_submit_urb(urb, GFP_ATOMIC); | 864 | result = usb_submit_urb(urb, GFP_ATOMIC); |
871 | if (result != 0) { | 865 | if (result != 0) { |
872 | dev_err(&urb->dev->dev, | 866 | dev_err(&urb->dev->dev, |
@@ -894,18 +888,6 @@ static void oti6858_read_bulk_callback(struct urb *urb) | |||
894 | spin_unlock_irqrestore(&priv->lock, flags); | 888 | spin_unlock_irqrestore(&priv->lock, flags); |
895 | 889 | ||
896 | if (status != 0) { | 890 | if (status != 0) { |
897 | /* | ||
898 | if (status == -EPROTO) { | ||
899 | * PL2303 mysteriously fails with -EPROTO reschedule | ||
900 | the read * | ||
901 | dbg("%s - caught -EPROTO, resubmitting the urb", | ||
902 | __func__); | ||
903 | result = usb_submit_urb(urb, GFP_ATOMIC); | ||
904 | if (result) | ||
905 | dev_err(&urb->dev->dev, "%s - failed resubmitting read urb, error %d\n", __func__, result); | ||
906 | return; | ||
907 | } | ||
908 | */ | ||
909 | dbg("%s(): unable to handle the error, exiting", __func__); | 891 | dbg("%s(): unable to handle the error, exiting", __func__); |
910 | return; | 892 | return; |
911 | } | 893 | } |
@@ -918,7 +900,6 @@ static void oti6858_read_bulk_callback(struct urb *urb) | |||
918 | tty_kref_put(tty); | 900 | tty_kref_put(tty); |
919 | 901 | ||
920 | /* schedule the interrupt urb */ | 902 | /* schedule the interrupt urb */ |
921 | port->interrupt_in_urb->dev = port->serial->dev; | ||
922 | result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); | 903 | result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); |
923 | if (result != 0 && result != -EPERM) { | 904 | if (result != 0 && result != -EPERM) { |
924 | dev_err(&port->dev, "%s(): usb_submit_urb() failed," | 905 | dev_err(&port->dev, "%s(): usb_submit_urb() failed," |
@@ -955,7 +936,6 @@ static void oti6858_write_bulk_callback(struct urb *urb) | |||
955 | dbg("%s(): overflow in write", __func__); | 936 | dbg("%s(): overflow in write", __func__); |
956 | 937 | ||
957 | port->write_urb->transfer_buffer_length = 1; | 938 | port->write_urb->transfer_buffer_length = 1; |
958 | port->write_urb->dev = port->serial->dev; | ||
959 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); | 939 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); |
960 | if (result) { | 940 | if (result) { |
961 | dev_err(&port->dev, "%s(): usb_submit_urb() failed," | 941 | dev_err(&port->dev, "%s(): usb_submit_urb() failed," |
@@ -968,7 +948,6 @@ static void oti6858_write_bulk_callback(struct urb *urb) | |||
968 | priv->flags.write_urb_in_use = 0; | 948 | priv->flags.write_urb_in_use = 0; |
969 | 949 | ||
970 | /* schedule the interrupt urb if we are still open */ | 950 | /* schedule the interrupt urb if we are still open */ |
971 | port->interrupt_in_urb->dev = port->serial->dev; | ||
972 | dbg("%s(): submitting interrupt urb", __func__); | 951 | dbg("%s(): submitting interrupt urb", __func__); |
973 | result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); | 952 | result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); |
974 | if (result != 0) { | 953 | if (result != 0) { |
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index 9083d1e616b4..3d8cda57ce7a 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c | |||
@@ -36,7 +36,7 @@ | |||
36 | */ | 36 | */ |
37 | #define DRIVER_DESC "Prolific PL2303 USB to serial adaptor driver" | 37 | #define DRIVER_DESC "Prolific PL2303 USB to serial adaptor driver" |
38 | 38 | ||
39 | static int debug; | 39 | static bool debug; |
40 | 40 | ||
41 | #define PL2303_CLOSING_WAIT (30*HZ) | 41 | #define PL2303_CLOSING_WAIT (30*HZ) |
42 | 42 | ||
@@ -91,7 +91,6 @@ static const struct usb_device_id id_table[] = { | |||
91 | { USB_DEVICE(SONY_VENDOR_ID, SONY_QN3USB_PRODUCT_ID) }, | 91 | { USB_DEVICE(SONY_VENDOR_ID, SONY_QN3USB_PRODUCT_ID) }, |
92 | { USB_DEVICE(SANWA_VENDOR_ID, SANWA_PRODUCT_ID) }, | 92 | { USB_DEVICE(SANWA_VENDOR_ID, SANWA_PRODUCT_ID) }, |
93 | { USB_DEVICE(ADLINK_VENDOR_ID, ADLINK_ND6530_PRODUCT_ID) }, | 93 | { USB_DEVICE(ADLINK_VENDOR_ID, ADLINK_ND6530_PRODUCT_ID) }, |
94 | { USB_DEVICE(WINCHIPHEAD_VENDOR_ID, WINCHIPHEAD_USBSER_PRODUCT_ID) }, | ||
95 | { USB_DEVICE(SMART_VENDOR_ID, SMART_PRODUCT_ID) }, | 94 | { USB_DEVICE(SMART_VENDOR_ID, SMART_PRODUCT_ID) }, |
96 | { } /* Terminating entry */ | 95 | { } /* Terminating entry */ |
97 | }; | 96 | }; |
@@ -503,21 +502,20 @@ static int pl2303_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
503 | if (tty) | 502 | if (tty) |
504 | pl2303_set_termios(tty, port, &tmp_termios); | 503 | pl2303_set_termios(tty, port, &tmp_termios); |
505 | 504 | ||
506 | dbg("%s - submitting read urb", __func__); | ||
507 | result = usb_serial_generic_submit_read_urb(port, GFP_KERNEL); | ||
508 | if (result) { | ||
509 | pl2303_close(port); | ||
510 | return -EPROTO; | ||
511 | } | ||
512 | |||
513 | dbg("%s - submitting interrupt urb", __func__); | 505 | dbg("%s - submitting interrupt urb", __func__); |
514 | result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); | 506 | result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); |
515 | if (result) { | 507 | if (result) { |
516 | dev_err(&port->dev, "%s - failed submitting interrupt urb," | 508 | dev_err(&port->dev, "%s - failed submitting interrupt urb," |
517 | " error %d\n", __func__, result); | 509 | " error %d\n", __func__, result); |
518 | pl2303_close(port); | 510 | return result; |
519 | return -EPROTO; | ||
520 | } | 511 | } |
512 | |||
513 | result = usb_serial_generic_open(tty, port); | ||
514 | if (result) { | ||
515 | usb_kill_urb(port->interrupt_in_urb); | ||
516 | return result; | ||
517 | } | ||
518 | |||
521 | port->port.drain_delay = 256; | 519 | port->port.drain_delay = 256; |
522 | return 0; | 520 | return 0; |
523 | } | 521 | } |
diff --git a/drivers/usb/serial/pl2303.h b/drivers/usb/serial/pl2303.h index 3d10d7f02072..c38b8c00c06f 100644 --- a/drivers/usb/serial/pl2303.h +++ b/drivers/usb/serial/pl2303.h | |||
@@ -145,10 +145,6 @@ | |||
145 | #define ADLINK_VENDOR_ID 0x0b63 | 145 | #define ADLINK_VENDOR_ID 0x0b63 |
146 | #define ADLINK_ND6530_PRODUCT_ID 0x6530 | 146 | #define ADLINK_ND6530_PRODUCT_ID 0x6530 |
147 | 147 | ||
148 | /* WinChipHead USB->RS 232 adapter */ | ||
149 | #define WINCHIPHEAD_VENDOR_ID 0x4348 | ||
150 | #define WINCHIPHEAD_USBSER_PRODUCT_ID 0x5523 | ||
151 | |||
152 | /* SMART USB Serial Adapter */ | 148 | /* SMART USB Serial Adapter */ |
153 | #define SMART_VENDOR_ID 0x0b8c | 149 | #define SMART_VENDOR_ID 0x0b8c |
154 | #define SMART_PRODUCT_ID 0x2303 | 150 | #define SMART_PRODUCT_ID 0x2303 |
diff --git a/drivers/usb/serial/qcserial.c b/drivers/usb/serial/qcserial.c index aa9367f5b421..1d5deee3be52 100644 --- a/drivers/usb/serial/qcserial.c +++ b/drivers/usb/serial/qcserial.c | |||
@@ -22,7 +22,7 @@ | |||
22 | #define DRIVER_AUTHOR "Qualcomm Inc" | 22 | #define DRIVER_AUTHOR "Qualcomm Inc" |
23 | #define DRIVER_DESC "Qualcomm USB Serial driver" | 23 | #define DRIVER_DESC "Qualcomm USB Serial driver" |
24 | 24 | ||
25 | static int debug; | 25 | static bool debug; |
26 | 26 | ||
27 | static const struct usb_device_id id_table[] = { | 27 | static const struct usb_device_id id_table[] = { |
28 | {USB_DEVICE(0x05c6, 0x9211)}, /* Acer Gobi QDL device */ | 28 | {USB_DEVICE(0x05c6, 0x9211)}, /* Acer Gobi QDL device */ |
diff --git a/drivers/usb/serial/safe_serial.c b/drivers/usb/serial/safe_serial.c index a36e2313eed0..d074b3740dcb 100644 --- a/drivers/usb/serial/safe_serial.c +++ b/drivers/usb/serial/safe_serial.c | |||
@@ -81,9 +81,9 @@ | |||
81 | #define CONFIG_USB_SERIAL_SAFE_PADDED 0 | 81 | #define CONFIG_USB_SERIAL_SAFE_PADDED 0 |
82 | #endif | 82 | #endif |
83 | 83 | ||
84 | static int debug; | 84 | static bool debug; |
85 | static int safe = 1; | 85 | static bool safe = 1; |
86 | static int padded = CONFIG_USB_SERIAL_SAFE_PADDED; | 86 | static bool padded = CONFIG_USB_SERIAL_SAFE_PADDED; |
87 | 87 | ||
88 | #define DRIVER_VERSION "v0.1" | 88 | #define DRIVER_VERSION "v0.1" |
89 | #define DRIVER_AUTHOR "sl@lineo.com, tbr@lineo.com, Johan Hovold <jhovold@gmail.com>" | 89 | #define DRIVER_AUTHOR "sl@lineo.com, tbr@lineo.com, Johan Hovold <jhovold@gmail.com>" |
diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c index b18179bda0d8..fdae0a4407cb 100644 --- a/drivers/usb/serial/sierra.c +++ b/drivers/usb/serial/sierra.c | |||
@@ -46,8 +46,8 @@ | |||
46 | allocations > PAGE_SIZE and the number of packets in a page | 46 | allocations > PAGE_SIZE and the number of packets in a page |
47 | is an integer 512 is the largest possible packet on EHCI */ | 47 | is an integer 512 is the largest possible packet on EHCI */ |
48 | 48 | ||
49 | static int debug; | 49 | static bool debug; |
50 | static int nmea; | 50 | static bool nmea; |
51 | 51 | ||
52 | /* Used in interface blacklisting */ | 52 | /* Used in interface blacklisting */ |
53 | struct sierra_iface_info { | 53 | struct sierra_iface_info { |
@@ -681,7 +681,6 @@ static void sierra_instat_callback(struct urb *urb) | |||
681 | /* Resubmit urb so we continue receiving IRQ data */ | 681 | /* Resubmit urb so we continue receiving IRQ data */ |
682 | if (status != -ESHUTDOWN && status != -ENOENT) { | 682 | if (status != -ESHUTDOWN && status != -ENOENT) { |
683 | usb_mark_last_busy(serial->dev); | 683 | usb_mark_last_busy(serial->dev); |
684 | urb->dev = serial->dev; | ||
685 | err = usb_submit_urb(urb, GFP_ATOMIC); | 684 | err = usb_submit_urb(urb, GFP_ATOMIC); |
686 | if (err && err != -EPERM) | 685 | if (err && err != -EPERM) |
687 | dev_err(&port->dev, "%s: resubmit intr urb " | 686 | dev_err(&port->dev, "%s: resubmit intr urb " |
diff --git a/drivers/usb/serial/spcp8x5.c b/drivers/usb/serial/spcp8x5.c index 180ea6c7911c..d7f5eee18f00 100644 --- a/drivers/usb/serial/spcp8x5.c +++ b/drivers/usb/serial/spcp8x5.c | |||
@@ -33,7 +33,7 @@ | |||
33 | #define DRIVER_VERSION "v0.10" | 33 | #define DRIVER_VERSION "v0.10" |
34 | #define DRIVER_DESC "SPCP8x5 USB to serial adaptor driver" | 34 | #define DRIVER_DESC "SPCP8x5 USB to serial adaptor driver" |
35 | 35 | ||
36 | static int debug; | 36 | static bool debug; |
37 | 37 | ||
38 | #define SPCP8x5_007_VID 0x04FC | 38 | #define SPCP8x5_007_VID 0x04FC |
39 | #define SPCP8x5_007_PID 0x0201 | 39 | #define SPCP8x5_007_PID 0x0201 |
diff --git a/drivers/usb/serial/ssu100.c b/drivers/usb/serial/ssu100.c index 87362e48796e..7697858d8858 100644 --- a/drivers/usb/serial/ssu100.c +++ b/drivers/usb/serial/ssu100.c | |||
@@ -46,7 +46,7 @@ | |||
46 | #define FULLPWRBIT 0x00000080 | 46 | #define FULLPWRBIT 0x00000080 |
47 | #define NEXT_BOARD_POWER_BIT 0x00000004 | 47 | #define NEXT_BOARD_POWER_BIT 0x00000004 |
48 | 48 | ||
49 | static int debug; | 49 | static bool debug; |
50 | 50 | ||
51 | /* Version Information */ | 51 | /* Version Information */ |
52 | #define DRIVER_VERSION "v0.1" | 52 | #define DRIVER_VERSION "v0.1" |
diff --git a/drivers/usb/serial/symbolserial.c b/drivers/usb/serial/symbolserial.c index 7096f799b071..50651cf4fc61 100644 --- a/drivers/usb/serial/symbolserial.c +++ b/drivers/usb/serial/symbolserial.c | |||
@@ -20,7 +20,7 @@ | |||
20 | #include <linux/usb/serial.h> | 20 | #include <linux/usb/serial.h> |
21 | #include <linux/uaccess.h> | 21 | #include <linux/uaccess.h> |
22 | 22 | ||
23 | static int debug; | 23 | static bool debug; |
24 | 24 | ||
25 | static const struct usb_device_id id_table[] = { | 25 | static const struct usb_device_id id_table[] = { |
26 | { USB_DEVICE(0x05e0, 0x0600) }, | 26 | { USB_DEVICE(0x05e0, 0x0600) }, |
@@ -182,7 +182,6 @@ static void symbol_unthrottle(struct tty_struct *tty) | |||
182 | priv->actually_throttled = false; | 182 | priv->actually_throttled = false; |
183 | spin_unlock_irq(&priv->lock); | 183 | spin_unlock_irq(&priv->lock); |
184 | 184 | ||
185 | priv->int_urb->dev = port->serial->dev; | ||
186 | if (was_throttled) { | 185 | if (was_throttled) { |
187 | result = usb_submit_urb(priv->int_urb, GFP_KERNEL); | 186 | result = usb_submit_urb(priv->int_urb, GFP_KERNEL); |
188 | if (result) | 187 | if (result) |
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c index ea8445689c85..8468eb769a29 100644 --- a/drivers/usb/serial/ti_usb_3410_5052.c +++ b/drivers/usb/serial/ti_usb_3410_5052.c | |||
@@ -150,7 +150,7 @@ static int ti_download_firmware(struct ti_device *tdev); | |||
150 | /* Data */ | 150 | /* Data */ |
151 | 151 | ||
152 | /* module parameters */ | 152 | /* module parameters */ |
153 | static int debug; | 153 | static bool debug; |
154 | static int closing_wait = TI_DEFAULT_CLOSING_WAIT; | 154 | static int closing_wait = TI_DEFAULT_CLOSING_WAIT; |
155 | static ushort vendor_3410[TI_EXTRA_VID_PID_COUNT]; | 155 | static ushort vendor_3410[TI_EXTRA_VID_PID_COUNT]; |
156 | static unsigned int vendor_3410_count; | 156 | static unsigned int vendor_3410_count; |
@@ -535,9 +535,7 @@ static int ti_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
535 | status = -EINVAL; | 535 | status = -EINVAL; |
536 | goto release_lock; | 536 | goto release_lock; |
537 | } | 537 | } |
538 | urb->complete = ti_interrupt_callback; | ||
539 | urb->context = tdev; | 538 | urb->context = tdev; |
540 | urb->dev = dev; | ||
541 | status = usb_submit_urb(urb, GFP_KERNEL); | 539 | status = usb_submit_urb(urb, GFP_KERNEL); |
542 | if (status) { | 540 | if (status) { |
543 | dev_err(&port->dev, | 541 | dev_err(&port->dev, |
@@ -619,9 +617,7 @@ static int ti_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
619 | goto unlink_int_urb; | 617 | goto unlink_int_urb; |
620 | } | 618 | } |
621 | tport->tp_read_urb_state = TI_READ_URB_RUNNING; | 619 | tport->tp_read_urb_state = TI_READ_URB_RUNNING; |
622 | urb->complete = ti_bulk_in_callback; | ||
623 | urb->context = tport; | 620 | urb->context = tport; |
624 | urb->dev = dev; | ||
625 | status = usb_submit_urb(urb, GFP_KERNEL); | 621 | status = usb_submit_urb(urb, GFP_KERNEL); |
626 | if (status) { | 622 | if (status) { |
627 | dev_err(&port->dev, "%s - submit read urb failed, %d\n", | 623 | dev_err(&port->dev, "%s - submit read urb failed, %d\n", |
@@ -1236,12 +1232,11 @@ static void ti_bulk_in_callback(struct urb *urb) | |||
1236 | exit: | 1232 | exit: |
1237 | /* continue to read unless stopping */ | 1233 | /* continue to read unless stopping */ |
1238 | spin_lock(&tport->tp_lock); | 1234 | spin_lock(&tport->tp_lock); |
1239 | if (tport->tp_read_urb_state == TI_READ_URB_RUNNING) { | 1235 | if (tport->tp_read_urb_state == TI_READ_URB_RUNNING) |
1240 | urb->dev = port->serial->dev; | ||
1241 | retval = usb_submit_urb(urb, GFP_ATOMIC); | 1236 | retval = usb_submit_urb(urb, GFP_ATOMIC); |
1242 | } else if (tport->tp_read_urb_state == TI_READ_URB_STOPPING) { | 1237 | else if (tport->tp_read_urb_state == TI_READ_URB_STOPPING) |
1243 | tport->tp_read_urb_state = TI_READ_URB_STOPPED; | 1238 | tport->tp_read_urb_state = TI_READ_URB_STOPPED; |
1244 | } | 1239 | |
1245 | spin_unlock(&tport->tp_lock); | 1240 | spin_unlock(&tport->tp_lock); |
1246 | if (retval) | 1241 | if (retval) |
1247 | dev_err(dev, "%s - resubmit read urb failed, %d\n", | 1242 | dev_err(dev, "%s - resubmit read urb failed, %d\n", |
@@ -1574,9 +1569,7 @@ static int ti_restart_read(struct ti_port *tport, struct tty_struct *tty) | |||
1574 | tport->tp_read_urb_state = TI_READ_URB_RUNNING; | 1569 | tport->tp_read_urb_state = TI_READ_URB_RUNNING; |
1575 | urb = tport->tp_port->read_urb; | 1570 | urb = tport->tp_port->read_urb; |
1576 | spin_unlock_irqrestore(&tport->tp_lock, flags); | 1571 | spin_unlock_irqrestore(&tport->tp_lock, flags); |
1577 | urb->complete = ti_bulk_in_callback; | ||
1578 | urb->context = tport; | 1572 | urb->context = tport; |
1579 | urb->dev = tport->tp_port->serial->dev; | ||
1580 | status = usb_submit_urb(urb, GFP_KERNEL); | 1573 | status = usb_submit_urb(urb, GFP_KERNEL); |
1581 | } else { | 1574 | } else { |
1582 | tport->tp_read_urb_state = TI_READ_URB_RUNNING; | 1575 | tport->tp_read_urb_state = TI_READ_URB_RUNNING; |
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index cc274fdf2627..611b206591cb 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c | |||
@@ -50,7 +50,7 @@ static struct usb_driver usb_serial_driver = { | |||
50 | .disconnect = usb_serial_disconnect, | 50 | .disconnect = usb_serial_disconnect, |
51 | .suspend = usb_serial_suspend, | 51 | .suspend = usb_serial_suspend, |
52 | .resume = usb_serial_resume, | 52 | .resume = usb_serial_resume, |
53 | .no_dynamic_id = 1, | 53 | .no_dynamic_id = 1, |
54 | .supports_autosuspend = 1, | 54 | .supports_autosuspend = 1, |
55 | }; | 55 | }; |
56 | 56 | ||
@@ -61,7 +61,7 @@ static struct usb_driver usb_serial_driver = { | |||
61 | drivers depend on it. | 61 | drivers depend on it. |
62 | */ | 62 | */ |
63 | 63 | ||
64 | static int debug; | 64 | static bool debug; |
65 | /* initially all NULL */ | 65 | /* initially all NULL */ |
66 | static struct usb_serial *serial_table[SERIAL_TTY_MINORS]; | 66 | static struct usb_serial *serial_table[SERIAL_TTY_MINORS]; |
67 | static DEFINE_MUTEX(table_lock); | 67 | static DEFINE_MUTEX(table_lock); |
@@ -260,6 +260,10 @@ static int serial_activate(struct tty_port *tport, struct tty_struct *tty) | |||
260 | else | 260 | else |
261 | retval = port->serial->type->open(tty, port); | 261 | retval = port->serial->type->open(tty, port); |
262 | mutex_unlock(&serial->disc_mutex); | 262 | mutex_unlock(&serial->disc_mutex); |
263 | |||
264 | if (retval < 0) | ||
265 | retval = usb_translate_errors(retval); | ||
266 | |||
263 | return retval; | 267 | return retval; |
264 | } | 268 | } |
265 | 269 | ||
@@ -360,7 +364,8 @@ static int serial_write(struct tty_struct *tty, const unsigned char *buf, | |||
360 | 364 | ||
361 | /* pass on to the driver specific version of this function */ | 365 | /* pass on to the driver specific version of this function */ |
362 | retval = port->serial->type->write(tty, port, buf, count); | 366 | retval = port->serial->type->write(tty, port, buf, count); |
363 | 367 | if (retval < 0) | |
368 | retval = usb_translate_errors(retval); | ||
364 | exit: | 369 | exit: |
365 | return retval; | 370 | return retval; |
366 | } | 371 | } |
@@ -562,8 +567,8 @@ static void kill_traffic(struct usb_serial_port *port) | |||
562 | { | 567 | { |
563 | int i; | 568 | int i; |
564 | 569 | ||
565 | usb_kill_urb(port->read_urb); | 570 | for (i = 0; i < ARRAY_SIZE(port->read_urbs); ++i) |
566 | usb_kill_urb(port->write_urb); | 571 | usb_kill_urb(port->read_urbs[i]); |
567 | for (i = 0; i < ARRAY_SIZE(port->write_urbs); ++i) | 572 | for (i = 0; i < ARRAY_SIZE(port->write_urbs); ++i) |
568 | usb_kill_urb(port->write_urbs[i]); | 573 | usb_kill_urb(port->write_urbs[i]); |
569 | /* | 574 | /* |
@@ -595,17 +600,17 @@ static void port_release(struct device *dev) | |||
595 | kill_traffic(port); | 600 | kill_traffic(port); |
596 | cancel_work_sync(&port->work); | 601 | cancel_work_sync(&port->work); |
597 | 602 | ||
598 | usb_free_urb(port->read_urb); | ||
599 | usb_free_urb(port->write_urb); | ||
600 | usb_free_urb(port->interrupt_in_urb); | 603 | usb_free_urb(port->interrupt_in_urb); |
601 | usb_free_urb(port->interrupt_out_urb); | 604 | usb_free_urb(port->interrupt_out_urb); |
605 | for (i = 0; i < ARRAY_SIZE(port->read_urbs); ++i) { | ||
606 | usb_free_urb(port->read_urbs[i]); | ||
607 | kfree(port->bulk_in_buffers[i]); | ||
608 | } | ||
602 | for (i = 0; i < ARRAY_SIZE(port->write_urbs); ++i) { | 609 | for (i = 0; i < ARRAY_SIZE(port->write_urbs); ++i) { |
603 | usb_free_urb(port->write_urbs[i]); | 610 | usb_free_urb(port->write_urbs[i]); |
604 | kfree(port->bulk_out_buffers[i]); | 611 | kfree(port->bulk_out_buffers[i]); |
605 | } | 612 | } |
606 | kfifo_free(&port->write_fifo); | 613 | kfifo_free(&port->write_fifo); |
607 | kfree(port->bulk_in_buffer); | ||
608 | kfree(port->bulk_out_buffer); | ||
609 | kfree(port->interrupt_in_buffer); | 614 | kfree(port->interrupt_in_buffer); |
610 | kfree(port->interrupt_out_buffer); | 615 | kfree(port->interrupt_out_buffer); |
611 | kfree(port); | 616 | kfree(port); |
@@ -686,16 +691,18 @@ static int serial_carrier_raised(struct tty_port *port) | |||
686 | { | 691 | { |
687 | struct usb_serial_port *p = container_of(port, struct usb_serial_port, port); | 692 | struct usb_serial_port *p = container_of(port, struct usb_serial_port, port); |
688 | struct usb_serial_driver *drv = p->serial->type; | 693 | struct usb_serial_driver *drv = p->serial->type; |
694 | |||
689 | if (drv->carrier_raised) | 695 | if (drv->carrier_raised) |
690 | return drv->carrier_raised(p); | 696 | return drv->carrier_raised(p); |
691 | /* No carrier control - don't block */ | 697 | /* No carrier control - don't block */ |
692 | return 1; | 698 | return 1; |
693 | } | 699 | } |
694 | 700 | ||
695 | static void serial_dtr_rts(struct tty_port *port, int on) | 701 | static void serial_dtr_rts(struct tty_port *port, int on) |
696 | { | 702 | { |
697 | struct usb_serial_port *p = container_of(port, struct usb_serial_port, port); | 703 | struct usb_serial_port *p = container_of(port, struct usb_serial_port, port); |
698 | struct usb_serial_driver *drv = p->serial->type; | 704 | struct usb_serial_driver *drv = p->serial->type; |
705 | |||
699 | if (drv->dtr_rts) | 706 | if (drv->dtr_rts) |
700 | drv->dtr_rts(p, on); | 707 | drv->dtr_rts(p, on); |
701 | } | 708 | } |
@@ -724,6 +731,7 @@ int usb_serial_probe(struct usb_interface *interface, | |||
724 | unsigned int minor; | 731 | unsigned int minor; |
725 | int buffer_size; | 732 | int buffer_size; |
726 | int i; | 733 | int i; |
734 | int j; | ||
727 | int num_interrupt_in = 0; | 735 | int num_interrupt_in = 0; |
728 | int num_interrupt_out = 0; | 736 | int num_interrupt_out = 0; |
729 | int num_bulk_in = 0; | 737 | int num_bulk_in = 0; |
@@ -906,38 +914,41 @@ int usb_serial_probe(struct usb_interface *interface, | |||
906 | for (i = 0; i < num_bulk_in; ++i) { | 914 | for (i = 0; i < num_bulk_in; ++i) { |
907 | endpoint = bulk_in_endpoint[i]; | 915 | endpoint = bulk_in_endpoint[i]; |
908 | port = serial->port[i]; | 916 | port = serial->port[i]; |
909 | port->read_urb = usb_alloc_urb(0, GFP_KERNEL); | ||
910 | if (!port->read_urb) { | ||
911 | dev_err(&interface->dev, "No free urbs available\n"); | ||
912 | goto probe_error; | ||
913 | } | ||
914 | buffer_size = max_t(int, serial->type->bulk_in_size, | 917 | buffer_size = max_t(int, serial->type->bulk_in_size, |
915 | usb_endpoint_maxp(endpoint)); | 918 | usb_endpoint_maxp(endpoint)); |
916 | port->bulk_in_size = buffer_size; | 919 | port->bulk_in_size = buffer_size; |
917 | port->bulk_in_endpointAddress = endpoint->bEndpointAddress; | 920 | port->bulk_in_endpointAddress = endpoint->bEndpointAddress; |
918 | port->bulk_in_buffer = kmalloc(buffer_size, GFP_KERNEL); | 921 | |
919 | if (!port->bulk_in_buffer) { | 922 | for (j = 0; j < ARRAY_SIZE(port->read_urbs); ++j) { |
920 | dev_err(&interface->dev, | 923 | set_bit(j, &port->read_urbs_free); |
924 | port->read_urbs[j] = usb_alloc_urb(0, GFP_KERNEL); | ||
925 | if (!port->read_urbs[j]) { | ||
926 | dev_err(&interface->dev, | ||
927 | "No free urbs available\n"); | ||
928 | goto probe_error; | ||
929 | } | ||
930 | port->bulk_in_buffers[j] = kmalloc(buffer_size, | ||
931 | GFP_KERNEL); | ||
932 | if (!port->bulk_in_buffers[j]) { | ||
933 | dev_err(&interface->dev, | ||
921 | "Couldn't allocate bulk_in_buffer\n"); | 934 | "Couldn't allocate bulk_in_buffer\n"); |
922 | goto probe_error; | 935 | goto probe_error; |
923 | } | 936 | } |
924 | usb_fill_bulk_urb(port->read_urb, dev, | 937 | usb_fill_bulk_urb(port->read_urbs[j], dev, |
925 | usb_rcvbulkpipe(dev, | 938 | usb_rcvbulkpipe(dev, |
926 | endpoint->bEndpointAddress), | 939 | endpoint->bEndpointAddress), |
927 | port->bulk_in_buffer, buffer_size, | 940 | port->bulk_in_buffers[j], buffer_size, |
928 | serial->type->read_bulk_callback, port); | 941 | serial->type->read_bulk_callback, |
942 | port); | ||
943 | } | ||
944 | |||
945 | port->read_urb = port->read_urbs[0]; | ||
946 | port->bulk_in_buffer = port->bulk_in_buffers[0]; | ||
929 | } | 947 | } |
930 | 948 | ||
931 | for (i = 0; i < num_bulk_out; ++i) { | 949 | for (i = 0; i < num_bulk_out; ++i) { |
932 | int j; | ||
933 | |||
934 | endpoint = bulk_out_endpoint[i]; | 950 | endpoint = bulk_out_endpoint[i]; |
935 | port = serial->port[i]; | 951 | port = serial->port[i]; |
936 | port->write_urb = usb_alloc_urb(0, GFP_KERNEL); | ||
937 | if (!port->write_urb) { | ||
938 | dev_err(&interface->dev, "No free urbs available\n"); | ||
939 | goto probe_error; | ||
940 | } | ||
941 | if (kfifo_alloc(&port->write_fifo, PAGE_SIZE, GFP_KERNEL)) | 952 | if (kfifo_alloc(&port->write_fifo, PAGE_SIZE, GFP_KERNEL)) |
942 | goto probe_error; | 953 | goto probe_error; |
943 | buffer_size = serial->type->bulk_out_size; | 954 | buffer_size = serial->type->bulk_out_size; |
@@ -945,17 +956,7 @@ int usb_serial_probe(struct usb_interface *interface, | |||
945 | buffer_size = usb_endpoint_maxp(endpoint); | 956 | buffer_size = usb_endpoint_maxp(endpoint); |
946 | port->bulk_out_size = buffer_size; | 957 | port->bulk_out_size = buffer_size; |
947 | port->bulk_out_endpointAddress = endpoint->bEndpointAddress; | 958 | port->bulk_out_endpointAddress = endpoint->bEndpointAddress; |
948 | port->bulk_out_buffer = kmalloc(buffer_size, GFP_KERNEL); | 959 | |
949 | if (!port->bulk_out_buffer) { | ||
950 | dev_err(&interface->dev, | ||
951 | "Couldn't allocate bulk_out_buffer\n"); | ||
952 | goto probe_error; | ||
953 | } | ||
954 | usb_fill_bulk_urb(port->write_urb, dev, | ||
955 | usb_sndbulkpipe(dev, | ||
956 | endpoint->bEndpointAddress), | ||
957 | port->bulk_out_buffer, buffer_size, | ||
958 | serial->type->write_bulk_callback, port); | ||
959 | for (j = 0; j < ARRAY_SIZE(port->write_urbs); ++j) { | 960 | for (j = 0; j < ARRAY_SIZE(port->write_urbs); ++j) { |
960 | set_bit(j, &port->write_urbs_free); | 961 | set_bit(j, &port->write_urbs_free); |
961 | port->write_urbs[j] = usb_alloc_urb(0, GFP_KERNEL); | 962 | port->write_urbs[j] = usb_alloc_urb(0, GFP_KERNEL); |
@@ -978,6 +979,9 @@ int usb_serial_probe(struct usb_interface *interface, | |||
978 | serial->type->write_bulk_callback, | 979 | serial->type->write_bulk_callback, |
979 | port); | 980 | port); |
980 | } | 981 | } |
982 | |||
983 | port->write_urb = port->write_urbs[0]; | ||
984 | port->bulk_out_buffer = port->bulk_out_buffers[0]; | ||
981 | } | 985 | } |
982 | 986 | ||
983 | if (serial->type->read_int_callback) { | 987 | if (serial->type->read_int_callback) { |
@@ -1196,7 +1200,7 @@ static const struct tty_operations serial_ops = { | |||
1196 | .open = serial_open, | 1200 | .open = serial_open, |
1197 | .close = serial_close, | 1201 | .close = serial_close, |
1198 | .write = serial_write, | 1202 | .write = serial_write, |
1199 | .hangup = serial_hangup, | 1203 | .hangup = serial_hangup, |
1200 | .write_room = serial_write_room, | 1204 | .write_room = serial_write_room, |
1201 | .ioctl = serial_ioctl, | 1205 | .ioctl = serial_ioctl, |
1202 | .set_termios = serial_set_termios, | 1206 | .set_termios = serial_set_termios, |
@@ -1206,9 +1210,9 @@ static const struct tty_operations serial_ops = { | |||
1206 | .chars_in_buffer = serial_chars_in_buffer, | 1210 | .chars_in_buffer = serial_chars_in_buffer, |
1207 | .tiocmget = serial_tiocmget, | 1211 | .tiocmget = serial_tiocmget, |
1208 | .tiocmset = serial_tiocmset, | 1212 | .tiocmset = serial_tiocmset, |
1209 | .get_icount = serial_get_icount, | 1213 | .get_icount = serial_get_icount, |
1210 | .cleanup = serial_cleanup, | 1214 | .cleanup = serial_cleanup, |
1211 | .install = serial_install, | 1215 | .install = serial_install, |
1212 | .proc_fops = &serial_proc_fops, | 1216 | .proc_fops = &serial_proc_fops, |
1213 | }; | 1217 | }; |
1214 | 1218 | ||
@@ -1237,7 +1241,7 @@ static int __init usb_serial_init(void) | |||
1237 | 1241 | ||
1238 | usb_serial_tty_driver->owner = THIS_MODULE; | 1242 | usb_serial_tty_driver->owner = THIS_MODULE; |
1239 | usb_serial_tty_driver->driver_name = "usbserial"; | 1243 | usb_serial_tty_driver->driver_name = "usbserial"; |
1240 | usb_serial_tty_driver->name = "ttyUSB"; | 1244 | usb_serial_tty_driver->name = "ttyUSB"; |
1241 | usb_serial_tty_driver->major = SERIAL_TTY_MAJOR; | 1245 | usb_serial_tty_driver->major = SERIAL_TTY_MAJOR; |
1242 | usb_serial_tty_driver->minor_start = 0; | 1246 | usb_serial_tty_driver->minor_start = 0; |
1243 | usb_serial_tty_driver->type = TTY_DRIVER_TYPE_SERIAL; | 1247 | usb_serial_tty_driver->type = TTY_DRIVER_TYPE_SERIAL; |
@@ -1336,7 +1340,6 @@ static void fixup_generic(struct usb_serial_driver *device) | |||
1336 | 1340 | ||
1337 | int usb_serial_register(struct usb_serial_driver *driver) | 1341 | int usb_serial_register(struct usb_serial_driver *driver) |
1338 | { | 1342 | { |
1339 | /* must be called with BKL held */ | ||
1340 | int retval; | 1343 | int retval; |
1341 | 1344 | ||
1342 | if (usb_disabled()) | 1345 | if (usb_disabled()) |
@@ -1374,7 +1377,6 @@ EXPORT_SYMBOL_GPL(usb_serial_register); | |||
1374 | 1377 | ||
1375 | void usb_serial_deregister(struct usb_serial_driver *device) | 1378 | void usb_serial_deregister(struct usb_serial_driver *device) |
1376 | { | 1379 | { |
1377 | /* must be called with BKL held */ | ||
1378 | printk(KERN_INFO "USB Serial deregistering driver %s\n", | 1380 | printk(KERN_INFO "USB Serial deregistering driver %s\n", |
1379 | device->description); | 1381 | device->description); |
1380 | mutex_lock(&table_lock); | 1382 | mutex_lock(&table_lock); |
diff --git a/drivers/usb/serial/usb_debug.c b/drivers/usb/serial/usb_debug.c index 95a82148ee81..9b632e753210 100644 --- a/drivers/usb/serial/usb_debug.c +++ b/drivers/usb/serial/usb_debug.c | |||
@@ -40,7 +40,7 @@ static struct usb_driver debug_driver = { | |||
40 | .probe = usb_serial_probe, | 40 | .probe = usb_serial_probe, |
41 | .disconnect = usb_serial_disconnect, | 41 | .disconnect = usb_serial_disconnect, |
42 | .id_table = id_table, | 42 | .id_table = id_table, |
43 | .no_dynamic_id = 1, | 43 | .no_dynamic_id = 1, |
44 | }; | 44 | }; |
45 | 45 | ||
46 | /* This HW really does not support a serial break, so one will be | 46 | /* This HW really does not support a serial break, so one will be |
@@ -54,19 +54,18 @@ static void usb_debug_break_ctl(struct tty_struct *tty, int break_state) | |||
54 | usb_serial_generic_write(tty, port, USB_DEBUG_BRK, USB_DEBUG_BRK_SIZE); | 54 | usb_serial_generic_write(tty, port, USB_DEBUG_BRK, USB_DEBUG_BRK_SIZE); |
55 | } | 55 | } |
56 | 56 | ||
57 | static void usb_debug_read_bulk_callback(struct urb *urb) | 57 | static void usb_debug_process_read_urb(struct urb *urb) |
58 | { | 58 | { |
59 | struct usb_serial_port *port = urb->context; | 59 | struct usb_serial_port *port = urb->context; |
60 | 60 | ||
61 | if (urb->actual_length == USB_DEBUG_BRK_SIZE && | 61 | if (urb->actual_length == USB_DEBUG_BRK_SIZE && |
62 | memcmp(urb->transfer_buffer, USB_DEBUG_BRK, | 62 | memcmp(urb->transfer_buffer, USB_DEBUG_BRK, |
63 | USB_DEBUG_BRK_SIZE) == 0) { | 63 | USB_DEBUG_BRK_SIZE) == 0) { |
64 | usb_serial_handle_break(port); | 64 | usb_serial_handle_break(port); |
65 | usb_serial_generic_submit_read_urb(port, GFP_ATOMIC); | ||
66 | return; | 65 | return; |
67 | } | 66 | } |
68 | 67 | ||
69 | usb_serial_generic_read_bulk_callback(urb); | 68 | usb_serial_generic_process_read_urb(urb); |
70 | } | 69 | } |
71 | 70 | ||
72 | static struct usb_serial_driver debug_device = { | 71 | static struct usb_serial_driver debug_device = { |
@@ -79,7 +78,7 @@ static struct usb_serial_driver debug_device = { | |||
79 | .num_ports = 1, | 78 | .num_ports = 1, |
80 | .bulk_out_size = USB_DEBUG_MAX_PACKET_SIZE, | 79 | .bulk_out_size = USB_DEBUG_MAX_PACKET_SIZE, |
81 | .break_ctl = usb_debug_break_ctl, | 80 | .break_ctl = usb_debug_break_ctl, |
82 | .read_bulk_callback = usb_debug_read_bulk_callback, | 81 | .process_read_urb = usb_debug_process_read_urb, |
83 | }; | 82 | }; |
84 | 83 | ||
85 | static int __init debug_init(void) | 84 | static int __init debug_init(void) |
diff --git a/drivers/usb/serial/usb_wwan.c b/drivers/usb/serial/usb_wwan.c index d555ca9567b8..c88657dd31c8 100644 --- a/drivers/usb/serial/usb_wwan.c +++ b/drivers/usb/serial/usb_wwan.c | |||
@@ -37,7 +37,7 @@ | |||
37 | #include <linux/serial.h> | 37 | #include <linux/serial.h> |
38 | #include "usb-wwan.h" | 38 | #include "usb-wwan.h" |
39 | 39 | ||
40 | static int debug; | 40 | static bool debug; |
41 | 41 | ||
42 | void usb_wwan_dtr_rts(struct usb_serial_port *port, int on) | 42 | void usb_wwan_dtr_rts(struct usb_serial_port *port, int on) |
43 | { | 43 | { |
diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c index 1c11959a7d58..210e4b10dc11 100644 --- a/drivers/usb/serial/visor.c +++ b/drivers/usb/serial/visor.c | |||
@@ -52,7 +52,7 @@ static int palm_os_4_probe(struct usb_serial *serial, | |||
52 | const struct usb_device_id *id); | 52 | const struct usb_device_id *id); |
53 | 53 | ||
54 | /* Parameters that may be passed into the module. */ | 54 | /* Parameters that may be passed into the module. */ |
55 | static int debug; | 55 | static bool debug; |
56 | static __u16 vendor; | 56 | static __u16 vendor; |
57 | static __u16 product; | 57 | static __u16 product; |
58 | 58 | ||
diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c index 5b073bcc807b..7e0acf5c8e38 100644 --- a/drivers/usb/serial/whiteheat.c +++ b/drivers/usb/serial/whiteheat.c | |||
@@ -14,57 +14,6 @@ | |||
14 | * | 14 | * |
15 | * See Documentation/usb/usb-serial.txt for more information on using this | 15 | * See Documentation/usb/usb-serial.txt for more information on using this |
16 | * driver | 16 | * driver |
17 | * | ||
18 | * (10/09/2002) Stuart MacDonald (stuartm@connecttech.com) | ||
19 | * Upgrade to full working driver | ||
20 | * | ||
21 | * (05/30/2001) gkh | ||
22 | * switched from using spinlock to a semaphore, which fixes lots of | ||
23 | * problems. | ||
24 | * | ||
25 | * (04/08/2001) gb | ||
26 | * Identify version on module load. | ||
27 | * | ||
28 | * 2001_Mar_19 gkh | ||
29 | * Fixed MOD_INC and MOD_DEC logic, the ability to open a port more | ||
30 | * than once, and the got the proper usb_device_id table entries so | ||
31 | * the driver works again. | ||
32 | * | ||
33 | * (11/01/2000) Adam J. Richter | ||
34 | * usb_device_id table support | ||
35 | * | ||
36 | * (10/05/2000) gkh | ||
37 | * Fixed bug with urb->dev not being set properly, now that the usb | ||
38 | * core needs it. | ||
39 | * | ||
40 | * (10/03/2000) smd | ||
41 | * firmware is improved to guard against crap sent to device | ||
42 | * firmware now replies CMD_FAILURE on bad things | ||
43 | * read_callback fix you provided for private info struct | ||
44 | * command_finished now indicates success or fail | ||
45 | * setup_port struct now packed to avoid gcc padding | ||
46 | * firmware uses 1 based port numbering, driver now handles that | ||
47 | * | ||
48 | * (09/11/2000) gkh | ||
49 | * Removed DEBUG #ifdefs with call to usb_serial_debug_data | ||
50 | * | ||
51 | * (07/19/2000) gkh | ||
52 | * Added module_init and module_exit functions to handle the fact that this | ||
53 | * driver is a loadable module now. | ||
54 | * Fixed bug with port->minor that was found by Al Borchers | ||
55 | * | ||
56 | * (07/04/2000) gkh | ||
57 | * Added support for port settings. Baud rate can now be changed. Line | ||
58 | * signals are not transferred to and from the tty layer yet, but things | ||
59 | * seem to be working well now. | ||
60 | * | ||
61 | * (05/04/2000) gkh | ||
62 | * First cut at open and close commands. Data can flow through the ports at | ||
63 | * default speeds now. | ||
64 | * | ||
65 | * (03/26/2000) gkh | ||
66 | * Split driver up into device specific pieces. | ||
67 | * | ||
68 | */ | 17 | */ |
69 | 18 | ||
70 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
@@ -87,7 +36,7 @@ | |||
87 | #include <linux/ihex.h> | 36 | #include <linux/ihex.h> |
88 | #include "whiteheat.h" /* WhiteHEAT specific commands */ | 37 | #include "whiteheat.h" /* WhiteHEAT specific commands */ |
89 | 38 | ||
90 | static int debug; | 39 | static bool debug; |
91 | 40 | ||
92 | #ifndef CMSPAR | 41 | #ifndef CMSPAR |
93 | #define CMSPAR 0 | 42 | #define CMSPAR 0 |
@@ -753,7 +702,6 @@ static void whiteheat_close(struct usb_serial_port *port) | |||
753 | static int whiteheat_write(struct tty_struct *tty, | 702 | static int whiteheat_write(struct tty_struct *tty, |
754 | struct usb_serial_port *port, const unsigned char *buf, int count) | 703 | struct usb_serial_port *port, const unsigned char *buf, int count) |
755 | { | 704 | { |
756 | struct usb_serial *serial = port->serial; | ||
757 | struct whiteheat_private *info = usb_get_serial_port_data(port); | 705 | struct whiteheat_private *info = usb_get_serial_port_data(port); |
758 | struct whiteheat_urb_wrap *wrap; | 706 | struct whiteheat_urb_wrap *wrap; |
759 | struct urb *urb; | 707 | struct urb *urb; |
@@ -789,7 +737,6 @@ static int whiteheat_write(struct tty_struct *tty, | |||
789 | usb_serial_debug_data(debug, &port->dev, | 737 | usb_serial_debug_data(debug, &port->dev, |
790 | __func__, bytes, urb->transfer_buffer); | 738 | __func__, bytes, urb->transfer_buffer); |
791 | 739 | ||
792 | urb->dev = serial->dev; | ||
793 | urb->transfer_buffer_length = bytes; | 740 | urb->transfer_buffer_length = bytes; |
794 | result = usb_submit_urb(urb, GFP_ATOMIC); | 741 | result = usb_submit_urb(urb, GFP_ATOMIC); |
795 | if (result) { | 742 | if (result) { |
@@ -1035,7 +982,6 @@ static void command_port_read_callback(struct urb *urb) | |||
1035 | dbg("%s - bad reply from firmware", __func__); | 982 | dbg("%s - bad reply from firmware", __func__); |
1036 | 983 | ||
1037 | /* Continue trying to always read */ | 984 | /* Continue trying to always read */ |
1038 | command_port->read_urb->dev = command_port->serial->dev; | ||
1039 | result = usb_submit_urb(command_port->read_urb, GFP_ATOMIC); | 985 | result = usb_submit_urb(command_port->read_urb, GFP_ATOMIC); |
1040 | if (result) | 986 | if (result) |
1041 | dbg("%s - failed resubmitting read urb, error %d", | 987 | dbg("%s - failed resubmitting read urb, error %d", |
@@ -1141,7 +1087,6 @@ static int firm_send_command(struct usb_serial_port *port, __u8 command, | |||
1141 | transfer_buffer[0] = command; | 1087 | transfer_buffer[0] = command; |
1142 | memcpy(&transfer_buffer[1], data, datasize); | 1088 | memcpy(&transfer_buffer[1], data, datasize); |
1143 | command_port->write_urb->transfer_buffer_length = datasize + 1; | 1089 | command_port->write_urb->transfer_buffer_length = datasize + 1; |
1144 | command_port->write_urb->dev = port->serial->dev; | ||
1145 | retval = usb_submit_urb(command_port->write_urb, GFP_NOIO); | 1090 | retval = usb_submit_urb(command_port->write_urb, GFP_NOIO); |
1146 | if (retval) { | 1091 | if (retval) { |
1147 | dbg("%s - submit urb failed", __func__); | 1092 | dbg("%s - submit urb failed", __func__); |
@@ -1362,7 +1307,6 @@ static int start_command_port(struct usb_serial *serial) | |||
1362 | /* Work around HCD bugs */ | 1307 | /* Work around HCD bugs */ |
1363 | usb_clear_halt(serial->dev, command_port->read_urb->pipe); | 1308 | usb_clear_halt(serial->dev, command_port->read_urb->pipe); |
1364 | 1309 | ||
1365 | command_port->read_urb->dev = serial->dev; | ||
1366 | retval = usb_submit_urb(command_port->read_urb, GFP_KERNEL); | 1310 | retval = usb_submit_urb(command_port->read_urb, GFP_KERNEL); |
1367 | if (retval) { | 1311 | if (retval) { |
1368 | dev_err(&serial->dev->dev, | 1312 | dev_err(&serial->dev->dev, |
@@ -1410,7 +1354,6 @@ static int start_port_read(struct usb_serial_port *port) | |||
1410 | list_del(tmp); | 1354 | list_del(tmp); |
1411 | wrap = list_entry(tmp, struct whiteheat_urb_wrap, list); | 1355 | wrap = list_entry(tmp, struct whiteheat_urb_wrap, list); |
1412 | urb = wrap->urb; | 1356 | urb = wrap->urb; |
1413 | urb->dev = port->serial->dev; | ||
1414 | spin_unlock_irqrestore(&info->lock, flags); | 1357 | spin_unlock_irqrestore(&info->lock, flags); |
1415 | retval = usb_submit_urb(urb, GFP_KERNEL); | 1358 | retval = usb_submit_urb(urb, GFP_KERNEL); |
1416 | if (retval) { | 1359 | if (retval) { |
@@ -1490,7 +1433,6 @@ static void rx_data_softint(struct work_struct *work) | |||
1490 | sent += tty_insert_flip_string(tty, | 1433 | sent += tty_insert_flip_string(tty, |
1491 | urb->transfer_buffer, urb->actual_length); | 1434 | urb->transfer_buffer, urb->actual_length); |
1492 | 1435 | ||
1493 | urb->dev = port->serial->dev; | ||
1494 | result = usb_submit_urb(urb, GFP_ATOMIC); | 1436 | result = usb_submit_urb(urb, GFP_ATOMIC); |
1495 | if (result) { | 1437 | if (result) { |
1496 | dev_err(&port->dev, | 1438 | dev_err(&port->dev, |
diff --git a/drivers/usb/storage/alauda.c b/drivers/usb/storage/alauda.c index 42d0eaed4a01..51af2fee2efd 100644 --- a/drivers/usb/storage/alauda.c +++ b/drivers/usb/storage/alauda.c | |||
@@ -139,7 +139,7 @@ static int init_alauda(struct us_data *us); | |||
139 | { USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \ | 139 | { USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \ |
140 | .driver_info = (flags)|(USB_US_TYPE_STOR<<24) } | 140 | .driver_info = (flags)|(USB_US_TYPE_STOR<<24) } |
141 | 141 | ||
142 | struct usb_device_id alauda_usb_ids[] = { | 142 | static struct usb_device_id alauda_usb_ids[] = { |
143 | # include "unusual_alauda.h" | 143 | # include "unusual_alauda.h" |
144 | { } /* Terminating entry */ | 144 | { } /* Terminating entry */ |
145 | }; | 145 | }; |
@@ -1278,15 +1278,4 @@ static struct usb_driver alauda_driver = { | |||
1278 | .soft_unbind = 1, | 1278 | .soft_unbind = 1, |
1279 | }; | 1279 | }; |
1280 | 1280 | ||
1281 | static int __init alauda_init(void) | 1281 | module_usb_driver(alauda_driver); |
1282 | { | ||
1283 | return usb_register(&alauda_driver); | ||
1284 | } | ||
1285 | |||
1286 | static void __exit alauda_exit(void) | ||
1287 | { | ||
1288 | usb_deregister(&alauda_driver); | ||
1289 | } | ||
1290 | |||
1291 | module_init(alauda_init); | ||
1292 | module_exit(alauda_exit); | ||
diff --git a/drivers/usb/storage/cypress_atacb.c b/drivers/usb/storage/cypress_atacb.c index c84471821183..387cbd47acc9 100644 --- a/drivers/usb/storage/cypress_atacb.c +++ b/drivers/usb/storage/cypress_atacb.c | |||
@@ -43,7 +43,7 @@ MODULE_LICENSE("GPL"); | |||
43 | { USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \ | 43 | { USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \ |
44 | .driver_info = (flags)|(USB_US_TYPE_STOR<<24) } | 44 | .driver_info = (flags)|(USB_US_TYPE_STOR<<24) } |
45 | 45 | ||
46 | struct usb_device_id cypress_usb_ids[] = { | 46 | static struct usb_device_id cypress_usb_ids[] = { |
47 | # include "unusual_cypress.h" | 47 | # include "unusual_cypress.h" |
48 | { } /* Terminating entry */ | 48 | { } /* Terminating entry */ |
49 | }; | 49 | }; |
@@ -274,15 +274,4 @@ static struct usb_driver cypress_driver = { | |||
274 | .soft_unbind = 1, | 274 | .soft_unbind = 1, |
275 | }; | 275 | }; |
276 | 276 | ||
277 | static int __init cypress_init(void) | 277 | module_usb_driver(cypress_driver); |
278 | { | ||
279 | return usb_register(&cypress_driver); | ||
280 | } | ||
281 | |||
282 | static void __exit cypress_exit(void) | ||
283 | { | ||
284 | usb_deregister(&cypress_driver); | ||
285 | } | ||
286 | |||
287 | module_init(cypress_init); | ||
288 | module_exit(cypress_exit); | ||
diff --git a/drivers/usb/storage/datafab.c b/drivers/usb/storage/datafab.c index ded836b02d7b..15d41f2b3d6f 100644 --- a/drivers/usb/storage/datafab.c +++ b/drivers/usb/storage/datafab.c | |||
@@ -88,7 +88,7 @@ static int datafab_determine_lun(struct us_data *us, | |||
88 | { USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \ | 88 | { USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \ |
89 | .driver_info = (flags)|(USB_US_TYPE_STOR<<24) } | 89 | .driver_info = (flags)|(USB_US_TYPE_STOR<<24) } |
90 | 90 | ||
91 | struct usb_device_id datafab_usb_ids[] = { | 91 | static struct usb_device_id datafab_usb_ids[] = { |
92 | # include "unusual_datafab.h" | 92 | # include "unusual_datafab.h" |
93 | { } /* Terminating entry */ | 93 | { } /* Terminating entry */ |
94 | }; | 94 | }; |
@@ -753,15 +753,4 @@ static struct usb_driver datafab_driver = { | |||
753 | .soft_unbind = 1, | 753 | .soft_unbind = 1, |
754 | }; | 754 | }; |
755 | 755 | ||
756 | static int __init datafab_init(void) | 756 | module_usb_driver(datafab_driver); |
757 | { | ||
758 | return usb_register(&datafab_driver); | ||
759 | } | ||
760 | |||
761 | static void __exit datafab_exit(void) | ||
762 | { | ||
763 | usb_deregister(&datafab_driver); | ||
764 | } | ||
765 | |||
766 | module_init(datafab_init); | ||
767 | module_exit(datafab_exit); | ||
diff --git a/drivers/usb/storage/ene_ub6250.c b/drivers/usb/storage/ene_ub6250.c index 4dca3ef0668c..a6ade4071a9a 100644 --- a/drivers/usb/storage/ene_ub6250.c +++ b/drivers/usb/storage/ene_ub6250.c | |||
@@ -42,7 +42,7 @@ MODULE_LICENSE("GPL"); | |||
42 | { USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \ | 42 | { USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \ |
43 | .driver_info = (flags)|(USB_US_TYPE_STOR<<24) } | 43 | .driver_info = (flags)|(USB_US_TYPE_STOR<<24) } |
44 | 44 | ||
45 | struct usb_device_id ene_ub6250_usb_ids[] = { | 45 | static struct usb_device_id ene_ub6250_usb_ids[] = { |
46 | # include "unusual_ene_ub6250.h" | 46 | # include "unusual_ene_ub6250.h" |
47 | { } /* Terminating entry */ | 47 | { } /* Terminating entry */ |
48 | }; | 48 | }; |
@@ -607,8 +607,8 @@ static int sd_scsi_mode_sense(struct us_data *us, struct scsi_cmnd *srb) | |||
607 | 607 | ||
608 | static int sd_scsi_read_capacity(struct us_data *us, struct scsi_cmnd *srb) | 608 | static int sd_scsi_read_capacity(struct us_data *us, struct scsi_cmnd *srb) |
609 | { | 609 | { |
610 | u32 bl_num; | 610 | u32 bl_num; |
611 | u16 bl_len; | 611 | u32 bl_len; |
612 | unsigned int offset = 0; | 612 | unsigned int offset = 0; |
613 | unsigned char buf[8]; | 613 | unsigned char buf[8]; |
614 | struct scatterlist *sg = NULL; | 614 | struct scatterlist *sg = NULL; |
@@ -622,7 +622,7 @@ static int sd_scsi_read_capacity(struct us_data *us, struct scsi_cmnd *srb) | |||
622 | else | 622 | else |
623 | bl_num = (info->HC_C_SIZE + 1) * 1024 - 1; | 623 | bl_num = (info->HC_C_SIZE + 1) * 1024 - 1; |
624 | } else { | 624 | } else { |
625 | bl_len = 1<<(info->SD_READ_BL_LEN); | 625 | bl_len = 1 << (info->SD_READ_BL_LEN); |
626 | bl_num = info->SD_Block_Mult * (info->SD_C_SIZE + 1) | 626 | bl_num = info->SD_Block_Mult * (info->SD_C_SIZE + 1) |
627 | * (1 << (info->SD_C_SIZE_MULT + 2)) - 1; | 627 | * (1 << (info->SD_C_SIZE_MULT + 2)) - 1; |
628 | } | 628 | } |
@@ -777,7 +777,7 @@ static int ms_lib_free_logicalmap(struct us_data *us) | |||
777 | return 0; | 777 | return 0; |
778 | } | 778 | } |
779 | 779 | ||
780 | int ms_lib_alloc_logicalmap(struct us_data *us) | 780 | static int ms_lib_alloc_logicalmap(struct us_data *us) |
781 | { | 781 | { |
782 | u32 i; | 782 | u32 i; |
783 | struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra; | 783 | struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra; |
@@ -1762,10 +1762,9 @@ static int ms_scsi_write(struct us_data *us, struct scsi_cmnd *srb) | |||
1762 | result = ene_send_scsi_cmd(us, FDIR_WRITE, scsi_sglist(srb), 1); | 1762 | result = ene_send_scsi_cmd(us, FDIR_WRITE, scsi_sglist(srb), 1); |
1763 | } else { | 1763 | } else { |
1764 | void *buf; | 1764 | void *buf; |
1765 | int offset; | 1765 | int offset = 0; |
1766 | u16 PhyBlockAddr; | 1766 | u16 PhyBlockAddr; |
1767 | u8 PageNum; | 1767 | u8 PageNum; |
1768 | u32 result; | ||
1769 | u16 len, oldphy, newphy; | 1768 | u16 len, oldphy, newphy; |
1770 | 1769 | ||
1771 | buf = kmalloc(blenByte, GFP_KERNEL); | 1770 | buf = kmalloc(blenByte, GFP_KERNEL); |
@@ -2249,7 +2248,7 @@ static int sd_scsi_irp(struct us_data *us, struct scsi_cmnd *srb) | |||
2249 | /* | 2248 | /* |
2250 | * ms_scsi_irp() | 2249 | * ms_scsi_irp() |
2251 | */ | 2250 | */ |
2252 | int ms_scsi_irp(struct us_data *us, struct scsi_cmnd *srb) | 2251 | static int ms_scsi_irp(struct us_data *us, struct scsi_cmnd *srb) |
2253 | { | 2252 | { |
2254 | int result; | 2253 | int result; |
2255 | struct ene_ub6250_info *info = (struct ene_ub6250_info *)us->extra; | 2254 | struct ene_ub6250_info *info = (struct ene_ub6250_info *)us->extra; |
@@ -2410,15 +2409,4 @@ static struct usb_driver ene_ub6250_driver = { | |||
2410 | .soft_unbind = 1, | 2409 | .soft_unbind = 1, |
2411 | }; | 2410 | }; |
2412 | 2411 | ||
2413 | static int __init ene_ub6250_init(void) | 2412 | module_usb_driver(ene_ub6250_driver); |
2414 | { | ||
2415 | return usb_register(&ene_ub6250_driver); | ||
2416 | } | ||
2417 | |||
2418 | static void __exit ene_ub6250_exit(void) | ||
2419 | { | ||
2420 | usb_deregister(&ene_ub6250_driver); | ||
2421 | } | ||
2422 | |||
2423 | module_init(ene_ub6250_init); | ||
2424 | module_exit(ene_ub6250_exit); | ||
diff --git a/drivers/usb/storage/freecom.c b/drivers/usb/storage/freecom.c index 6542ca40d505..fa1615748475 100644 --- a/drivers/usb/storage/freecom.c +++ b/drivers/usb/storage/freecom.c | |||
@@ -119,7 +119,7 @@ static int init_freecom(struct us_data *us); | |||
119 | { USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \ | 119 | { USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \ |
120 | .driver_info = (flags)|(USB_US_TYPE_STOR<<24) } | 120 | .driver_info = (flags)|(USB_US_TYPE_STOR<<24) } |
121 | 121 | ||
122 | struct usb_device_id freecom_usb_ids[] = { | 122 | static struct usb_device_id freecom_usb_ids[] = { |
123 | # include "unusual_freecom.h" | 123 | # include "unusual_freecom.h" |
124 | { } /* Terminating entry */ | 124 | { } /* Terminating entry */ |
125 | }; | 125 | }; |
@@ -555,15 +555,4 @@ static struct usb_driver freecom_driver = { | |||
555 | .soft_unbind = 1, | 555 | .soft_unbind = 1, |
556 | }; | 556 | }; |
557 | 557 | ||
558 | static int __init freecom_init(void) | 558 | module_usb_driver(freecom_driver); |
559 | { | ||
560 | return usb_register(&freecom_driver); | ||
561 | } | ||
562 | |||
563 | static void __exit freecom_exit(void) | ||
564 | { | ||
565 | usb_deregister(&freecom_driver); | ||
566 | } | ||
567 | |||
568 | module_init(freecom_init); | ||
569 | module_exit(freecom_exit); | ||
diff --git a/drivers/usb/storage/isd200.c b/drivers/usb/storage/isd200.c index ffc4193e9505..bd5502700831 100644 --- a/drivers/usb/storage/isd200.c +++ b/drivers/usb/storage/isd200.c | |||
@@ -61,7 +61,7 @@ | |||
61 | #include "scsiglue.h" | 61 | #include "scsiglue.h" |
62 | 62 | ||
63 | MODULE_DESCRIPTION("Driver for In-System Design, Inc. ISD200 ASIC"); | 63 | MODULE_DESCRIPTION("Driver for In-System Design, Inc. ISD200 ASIC"); |
64 | MODULE_AUTHOR("Björn Stenberg <bjorn@haxx.se>"); | 64 | MODULE_AUTHOR("Björn Stenberg <bjorn@haxx.se>"); |
65 | MODULE_LICENSE("GPL"); | 65 | MODULE_LICENSE("GPL"); |
66 | 66 | ||
67 | static int isd200_Initialization(struct us_data *us); | 67 | static int isd200_Initialization(struct us_data *us); |
@@ -76,7 +76,7 @@ static int isd200_Initialization(struct us_data *us); | |||
76 | { USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \ | 76 | { USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \ |
77 | .driver_info = (flags)|(USB_US_TYPE_STOR<<24) } | 77 | .driver_info = (flags)|(USB_US_TYPE_STOR<<24) } |
78 | 78 | ||
79 | struct usb_device_id isd200_usb_ids[] = { | 79 | static struct usb_device_id isd200_usb_ids[] = { |
80 | # include "unusual_isd200.h" | 80 | # include "unusual_isd200.h" |
81 | { } /* Terminating entry */ | 81 | { } /* Terminating entry */ |
82 | }; | 82 | }; |
@@ -1568,15 +1568,4 @@ static struct usb_driver isd200_driver = { | |||
1568 | .soft_unbind = 1, | 1568 | .soft_unbind = 1, |
1569 | }; | 1569 | }; |
1570 | 1570 | ||
1571 | static int __init isd200_init(void) | 1571 | module_usb_driver(isd200_driver); |
1572 | { | ||
1573 | return usb_register(&isd200_driver); | ||
1574 | } | ||
1575 | |||
1576 | static void __exit isd200_exit(void) | ||
1577 | { | ||
1578 | usb_deregister(&isd200_driver); | ||
1579 | } | ||
1580 | |||
1581 | module_init(isd200_init); | ||
1582 | module_exit(isd200_exit); | ||
diff --git a/drivers/usb/storage/jumpshot.c b/drivers/usb/storage/jumpshot.c index 6168596c5ac6..a19211b5c265 100644 --- a/drivers/usb/storage/jumpshot.c +++ b/drivers/usb/storage/jumpshot.c | |||
@@ -71,7 +71,7 @@ MODULE_LICENSE("GPL"); | |||
71 | { USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \ | 71 | { USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \ |
72 | .driver_info = (flags)|(USB_US_TYPE_STOR<<24) } | 72 | .driver_info = (flags)|(USB_US_TYPE_STOR<<24) } |
73 | 73 | ||
74 | struct usb_device_id jumpshot_usb_ids[] = { | 74 | static struct usb_device_id jumpshot_usb_ids[] = { |
75 | # include "unusual_jumpshot.h" | 75 | # include "unusual_jumpshot.h" |
76 | { } /* Terminating entry */ | 76 | { } /* Terminating entry */ |
77 | }; | 77 | }; |
@@ -679,15 +679,4 @@ static struct usb_driver jumpshot_driver = { | |||
679 | .soft_unbind = 1, | 679 | .soft_unbind = 1, |
680 | }; | 680 | }; |
681 | 681 | ||
682 | static int __init jumpshot_init(void) | 682 | module_usb_driver(jumpshot_driver); |
683 | { | ||
684 | return usb_register(&jumpshot_driver); | ||
685 | } | ||
686 | |||
687 | static void __exit jumpshot_exit(void) | ||
688 | { | ||
689 | usb_deregister(&jumpshot_driver); | ||
690 | } | ||
691 | |||
692 | module_init(jumpshot_init); | ||
693 | module_exit(jumpshot_exit); | ||
diff --git a/drivers/usb/storage/karma.c b/drivers/usb/storage/karma.c index ba1b78906880..e720f8ebdf9f 100644 --- a/drivers/usb/storage/karma.c +++ b/drivers/usb/storage/karma.c | |||
@@ -59,7 +59,7 @@ static int rio_karma_init(struct us_data *us); | |||
59 | { USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \ | 59 | { USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \ |
60 | .driver_info = (flags)|(USB_US_TYPE_STOR<<24) } | 60 | .driver_info = (flags)|(USB_US_TYPE_STOR<<24) } |
61 | 61 | ||
62 | struct usb_device_id karma_usb_ids[] = { | 62 | static struct usb_device_id karma_usb_ids[] = { |
63 | # include "unusual_karma.h" | 63 | # include "unusual_karma.h" |
64 | { } /* Terminating entry */ | 64 | { } /* Terminating entry */ |
65 | }; | 65 | }; |
@@ -232,15 +232,4 @@ static struct usb_driver karma_driver = { | |||
232 | .soft_unbind = 1, | 232 | .soft_unbind = 1, |
233 | }; | 233 | }; |
234 | 234 | ||
235 | static int __init karma_init(void) | 235 | module_usb_driver(karma_driver); |
236 | { | ||
237 | return usb_register(&karma_driver); | ||
238 | } | ||
239 | |||
240 | static void __exit karma_exit(void) | ||
241 | { | ||
242 | usb_deregister(&karma_driver); | ||
243 | } | ||
244 | |||
245 | module_init(karma_init); | ||
246 | module_exit(karma_exit); | ||
diff --git a/drivers/usb/storage/onetouch.c b/drivers/usb/storage/onetouch.c index 1943be5a2914..d75155c38200 100644 --- a/drivers/usb/storage/onetouch.c +++ b/drivers/usb/storage/onetouch.c | |||
@@ -69,7 +69,7 @@ struct usb_onetouch { | |||
69 | { USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \ | 69 | { USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \ |
70 | .driver_info = (flags)|(USB_US_TYPE_STOR<<24) } | 70 | .driver_info = (flags)|(USB_US_TYPE_STOR<<24) } |
71 | 71 | ||
72 | struct usb_device_id onetouch_usb_ids[] = { | 72 | static struct usb_device_id onetouch_usb_ids[] = { |
73 | # include "unusual_onetouch.h" | 73 | # include "unusual_onetouch.h" |
74 | { } /* Terminating entry */ | 74 | { } /* Terminating entry */ |
75 | }; | 75 | }; |
@@ -314,15 +314,4 @@ static struct usb_driver onetouch_driver = { | |||
314 | .soft_unbind = 1, | 314 | .soft_unbind = 1, |
315 | }; | 315 | }; |
316 | 316 | ||
317 | static int __init onetouch_init(void) | 317 | module_usb_driver(onetouch_driver); |
318 | { | ||
319 | return usb_register(&onetouch_driver); | ||
320 | } | ||
321 | |||
322 | static void __exit onetouch_exit(void) | ||
323 | { | ||
324 | usb_deregister(&onetouch_driver); | ||
325 | } | ||
326 | |||
327 | module_init(onetouch_init); | ||
328 | module_exit(onetouch_exit); | ||
diff --git a/drivers/usb/storage/protocol.c b/drivers/usb/storage/protocol.c index 93c1a4d86f51..82dd834709c7 100644 --- a/drivers/usb/storage/protocol.c +++ b/drivers/usb/storage/protocol.c | |||
@@ -59,7 +59,9 @@ | |||
59 | 59 | ||
60 | void usb_stor_pad12_command(struct scsi_cmnd *srb, struct us_data *us) | 60 | void usb_stor_pad12_command(struct scsi_cmnd *srb, struct us_data *us) |
61 | { | 61 | { |
62 | /* Pad the SCSI command with zeros out to 12 bytes | 62 | /* |
63 | * Pad the SCSI command with zeros out to 12 bytes. If the | ||
64 | * command already is 12 bytes or longer, leave it alone. | ||
63 | * | 65 | * |
64 | * NOTE: This only works because a scsi_cmnd struct field contains | 66 | * NOTE: This only works because a scsi_cmnd struct field contains |
65 | * a unsigned char cmnd[16], so we know we have storage available | 67 | * a unsigned char cmnd[16], so we know we have storage available |
@@ -67,9 +69,6 @@ void usb_stor_pad12_command(struct scsi_cmnd *srb, struct us_data *us) | |||
67 | for (; srb->cmd_len<12; srb->cmd_len++) | 69 | for (; srb->cmd_len<12; srb->cmd_len++) |
68 | srb->cmnd[srb->cmd_len] = 0; | 70 | srb->cmnd[srb->cmd_len] = 0; |
69 | 71 | ||
70 | /* set command length to 12 bytes */ | ||
71 | srb->cmd_len = 12; | ||
72 | |||
73 | /* send the command to the transport layer */ | 72 | /* send the command to the transport layer */ |
74 | usb_stor_invoke_transport(srb, us); | 73 | usb_stor_invoke_transport(srb, us); |
75 | } | 74 | } |
diff --git a/drivers/usb/storage/realtek_cr.c b/drivers/usb/storage/realtek_cr.c index 0ce5f79197e7..1f62723ef1a8 100644 --- a/drivers/usb/storage/realtek_cr.c +++ b/drivers/usb/storage/realtek_cr.c | |||
@@ -398,10 +398,9 @@ static int rts51x_write_mem(struct us_data *us, u16 addr, u8 *data, u16 len) | |||
398 | u8 cmnd[12] = { 0 }; | 398 | u8 cmnd[12] = { 0 }; |
399 | u8 *buf; | 399 | u8 *buf; |
400 | 400 | ||
401 | buf = kmalloc(len, GFP_NOIO); | 401 | buf = kmemdup(data, len, GFP_NOIO); |
402 | if (buf == NULL) | 402 | if (buf == NULL) |
403 | return USB_STOR_TRANSPORT_ERROR; | 403 | return USB_STOR_TRANSPORT_ERROR; |
404 | memcpy(buf, data, len); | ||
405 | 404 | ||
406 | US_DEBUGP("%s, addr = 0x%x, len = %d\n", __func__, addr, len); | 405 | US_DEBUGP("%s, addr = 0x%x, len = %d\n", __func__, addr, len); |
407 | 406 | ||
@@ -507,15 +506,14 @@ static int enable_oscillator(struct us_data *us) | |||
507 | static int __do_config_autodelink(struct us_data *us, u8 *data, u16 len) | 506 | static int __do_config_autodelink(struct us_data *us, u8 *data, u16 len) |
508 | { | 507 | { |
509 | int retval; | 508 | int retval; |
510 | u16 addr = 0xFE47; | ||
511 | u8 cmnd[12] = {0}; | 509 | u8 cmnd[12] = {0}; |
512 | 510 | ||
513 | US_DEBUGP("%s, addr = 0x%x, len = %d\n", __FUNCTION__, addr, len); | 511 | US_DEBUGP("%s, addr = 0xfe47, len = %d\n", __FUNCTION__, len); |
514 | 512 | ||
515 | cmnd[0] = 0xF0; | 513 | cmnd[0] = 0xF0; |
516 | cmnd[1] = 0x0E; | 514 | cmnd[1] = 0x0E; |
517 | cmnd[2] = (u8)(addr >> 8); | 515 | cmnd[2] = 0xfe; |
518 | cmnd[3] = (u8)addr; | 516 | cmnd[3] = 0x47; |
519 | cmnd[4] = (u8)(len >> 8); | 517 | cmnd[4] = (u8)(len >> 8); |
520 | cmnd[5] = (u8)len; | 518 | cmnd[5] = (u8)len; |
521 | 519 | ||
@@ -818,7 +816,7 @@ static inline int working_scsi(struct scsi_cmnd *srb) | |||
818 | return 1; | 816 | return 1; |
819 | } | 817 | } |
820 | 818 | ||
821 | void rts51x_invoke_transport(struct scsi_cmnd *srb, struct us_data *us) | 819 | static void rts51x_invoke_transport(struct scsi_cmnd *srb, struct us_data *us) |
822 | { | 820 | { |
823 | struct rts51x_chip *chip = (struct rts51x_chip *)(us->extra); | 821 | struct rts51x_chip *chip = (struct rts51x_chip *)(us->extra); |
824 | static int card_first_show = 1; | 822 | static int card_first_show = 1; |
@@ -977,7 +975,7 @@ static void realtek_cr_destructor(void *extra) | |||
977 | } | 975 | } |
978 | 976 | ||
979 | #ifdef CONFIG_PM | 977 | #ifdef CONFIG_PM |
980 | int realtek_cr_suspend(struct usb_interface *iface, pm_message_t message) | 978 | static int realtek_cr_suspend(struct usb_interface *iface, pm_message_t message) |
981 | { | 979 | { |
982 | struct us_data *us = usb_get_intfdata(iface); | 980 | struct us_data *us = usb_get_intfdata(iface); |
983 | 981 | ||
@@ -1104,15 +1102,4 @@ static struct usb_driver realtek_cr_driver = { | |||
1104 | .supports_autosuspend = 1, | 1102 | .supports_autosuspend = 1, |
1105 | }; | 1103 | }; |
1106 | 1104 | ||
1107 | static int __init realtek_cr_init(void) | 1105 | module_usb_driver(realtek_cr_driver); |
1108 | { | ||
1109 | return usb_register(&realtek_cr_driver); | ||
1110 | } | ||
1111 | |||
1112 | static void __exit realtek_cr_exit(void) | ||
1113 | { | ||
1114 | usb_deregister(&realtek_cr_driver); | ||
1115 | } | ||
1116 | |||
1117 | module_init(realtek_cr_init); | ||
1118 | module_exit(realtek_cr_exit); | ||
diff --git a/drivers/usb/storage/sddr09.c b/drivers/usb/storage/sddr09.c index bcb9a709d349..425df7df2e56 100644 --- a/drivers/usb/storage/sddr09.c +++ b/drivers/usb/storage/sddr09.c | |||
@@ -71,7 +71,7 @@ static int usb_stor_sddr09_init(struct us_data *us); | |||
71 | { USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \ | 71 | { USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \ |
72 | .driver_info = (flags)|(USB_US_TYPE_STOR<<24) } | 72 | .driver_info = (flags)|(USB_US_TYPE_STOR<<24) } |
73 | 73 | ||
74 | struct usb_device_id sddr09_usb_ids[] = { | 74 | static struct usb_device_id sddr09_usb_ids[] = { |
75 | # include "unusual_sddr09.h" | 75 | # include "unusual_sddr09.h" |
76 | { } /* Terminating entry */ | 76 | { } /* Terminating entry */ |
77 | }; | 77 | }; |
@@ -1789,15 +1789,4 @@ static struct usb_driver sddr09_driver = { | |||
1789 | .soft_unbind = 1, | 1789 | .soft_unbind = 1, |
1790 | }; | 1790 | }; |
1791 | 1791 | ||
1792 | static int __init sddr09_init(void) | 1792 | module_usb_driver(sddr09_driver); |
1793 | { | ||
1794 | return usb_register(&sddr09_driver); | ||
1795 | } | ||
1796 | |||
1797 | static void __exit sddr09_exit(void) | ||
1798 | { | ||
1799 | usb_deregister(&sddr09_driver); | ||
1800 | } | ||
1801 | |||
1802 | module_init(sddr09_init); | ||
1803 | module_exit(sddr09_exit); | ||
diff --git a/drivers/usb/storage/sddr55.c b/drivers/usb/storage/sddr55.c index 44dfed7754ed..e4ca5fcb7cc3 100644 --- a/drivers/usb/storage/sddr55.c +++ b/drivers/usb/storage/sddr55.c | |||
@@ -48,7 +48,7 @@ MODULE_LICENSE("GPL"); | |||
48 | { USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \ | 48 | { USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \ |
49 | .driver_info = (flags)|(USB_US_TYPE_STOR<<24) } | 49 | .driver_info = (flags)|(USB_US_TYPE_STOR<<24) } |
50 | 50 | ||
51 | struct usb_device_id sddr55_usb_ids[] = { | 51 | static struct usb_device_id sddr55_usb_ids[] = { |
52 | # include "unusual_sddr55.h" | 52 | # include "unusual_sddr55.h" |
53 | { } /* Terminating entry */ | 53 | { } /* Terminating entry */ |
54 | }; | 54 | }; |
@@ -1008,15 +1008,4 @@ static struct usb_driver sddr55_driver = { | |||
1008 | .soft_unbind = 1, | 1008 | .soft_unbind = 1, |
1009 | }; | 1009 | }; |
1010 | 1010 | ||
1011 | static int __init sddr55_init(void) | 1011 | module_usb_driver(sddr55_driver); |
1012 | { | ||
1013 | return usb_register(&sddr55_driver); | ||
1014 | } | ||
1015 | |||
1016 | static void __exit sddr55_exit(void) | ||
1017 | { | ||
1018 | usb_deregister(&sddr55_driver); | ||
1019 | } | ||
1020 | |||
1021 | module_init(sddr55_init); | ||
1022 | module_exit(sddr55_exit); | ||
diff --git a/drivers/usb/storage/shuttle_usbat.c b/drivers/usb/storage/shuttle_usbat.c index 0b00091d2ae9..1369d2590616 100644 --- a/drivers/usb/storage/shuttle_usbat.c +++ b/drivers/usb/storage/shuttle_usbat.c | |||
@@ -170,7 +170,7 @@ static int init_usbat_flash(struct us_data *us); | |||
170 | { USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \ | 170 | { USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \ |
171 | .driver_info = (flags)|(USB_US_TYPE_STOR<<24) } | 171 | .driver_info = (flags)|(USB_US_TYPE_STOR<<24) } |
172 | 172 | ||
173 | struct usb_device_id usbat_usb_ids[] = { | 173 | static struct usb_device_id usbat_usb_ids[] = { |
174 | # include "unusual_usbat.h" | 174 | # include "unusual_usbat.h" |
175 | { } /* Terminating entry */ | 175 | { } /* Terminating entry */ |
176 | }; | 176 | }; |
@@ -1865,15 +1865,4 @@ static struct usb_driver usbat_driver = { | |||
1865 | .soft_unbind = 1, | 1865 | .soft_unbind = 1, |
1866 | }; | 1866 | }; |
1867 | 1867 | ||
1868 | static int __init usbat_init(void) | 1868 | module_usb_driver(usbat_driver); |
1869 | { | ||
1870 | return usb_register(&usbat_driver); | ||
1871 | } | ||
1872 | |||
1873 | static void __exit usbat_exit(void) | ||
1874 | { | ||
1875 | usb_deregister(&usbat_driver); | ||
1876 | } | ||
1877 | |||
1878 | module_init(usbat_init); | ||
1879 | module_exit(usbat_exit); | ||
diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c index 1d10d5b8204c..a33ead5dce20 100644 --- a/drivers/usb/storage/uas.c +++ b/drivers/usb/storage/uas.c | |||
@@ -760,18 +760,7 @@ static struct usb_driver uas_driver = { | |||
760 | .id_table = uas_usb_ids, | 760 | .id_table = uas_usb_ids, |
761 | }; | 761 | }; |
762 | 762 | ||
763 | static int uas_init(void) | 763 | module_usb_driver(uas_driver); |
764 | { | ||
765 | return usb_register(&uas_driver); | ||
766 | } | ||
767 | |||
768 | static void uas_exit(void) | ||
769 | { | ||
770 | usb_deregister(&uas_driver); | ||
771 | } | ||
772 | |||
773 | module_init(uas_init); | ||
774 | module_exit(uas_exit); | ||
775 | 764 | ||
776 | MODULE_LICENSE("GPL"); | 765 | MODULE_LICENSE("GPL"); |
777 | MODULE_AUTHOR("Matthew Wilcox and Sarah Sharp"); | 766 | MODULE_AUTHOR("Matthew Wilcox and Sarah Sharp"); |
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h index 3041a974faf3..856ad92c40de 100644 --- a/drivers/usb/storage/unusual_devs.h +++ b/drivers/usb/storage/unusual_devs.h | |||
@@ -1854,6 +1854,13 @@ UNUSUAL_DEV( 0x1370, 0x6828, 0x0110, 0x0110, | |||
1854 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | 1854 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
1855 | US_FL_IGNORE_RESIDUE ), | 1855 | US_FL_IGNORE_RESIDUE ), |
1856 | 1856 | ||
1857 | /* Reported by Qinglin Ye <yestyle@gmail.com> */ | ||
1858 | UNUSUAL_DEV( 0x13fe, 0x3600, 0x0100, 0x0100, | ||
1859 | "Kingston", | ||
1860 | "DT 101 G2", | ||
1861 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | ||
1862 | US_FL_BULK_IGNORE_TAG ), | ||
1863 | |||
1857 | /* Reported by Francesco Foresti <frafore@tiscali.it> */ | 1864 | /* Reported by Francesco Foresti <frafore@tiscali.it> */ |
1858 | UNUSUAL_DEV( 0x14cd, 0x6600, 0x0201, 0x0201, | 1865 | UNUSUAL_DEV( 0x14cd, 0x6600, 0x0201, 0x0201, |
1859 | "Super Top", | 1866 | "Super Top", |
@@ -1907,7 +1914,7 @@ UNUSUAL_DEV( 0x1b1c, 0x1ab5, 0x0200, 0x0200, | |||
1907 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | 1914 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
1908 | US_FL_INITIAL_READ10 ), | 1915 | US_FL_INITIAL_READ10 ), |
1909 | 1916 | ||
1910 | /* Patch by Richard Schütz <r.schtz@t-online.de> | 1917 | /* Patch by Richard Schütz <r.schtz@t-online.de> |
1911 | * This external hard drive enclosure uses a JMicron chip which | 1918 | * This external hard drive enclosure uses a JMicron chip which |
1912 | * needs the US_FL_IGNORE_RESIDUE flag to work properly. */ | 1919 | * needs the US_FL_IGNORE_RESIDUE flag to work properly. */ |
1913 | UNUSUAL_DEV( 0x1e68, 0x001b, 0x0000, 0x0000, | 1920 | UNUSUAL_DEV( 0x1e68, 0x001b, 0x0000, 0x0000, |
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c index c325e69415a1..3dd7da9fd504 100644 --- a/drivers/usb/storage/usb.c +++ b/drivers/usb/storage/usb.c | |||
@@ -831,7 +831,8 @@ static int usb_stor_scan_thread(void * __us) | |||
831 | 831 | ||
832 | dev_dbg(dev, "device found\n"); | 832 | dev_dbg(dev, "device found\n"); |
833 | 833 | ||
834 | set_freezable_with_signal(); | 834 | set_freezable(); |
835 | |||
835 | /* | 836 | /* |
836 | * Wait for the timeout to expire or for a disconnect | 837 | * Wait for the timeout to expire or for a disconnect |
837 | * | 838 | * |
@@ -839,16 +840,16 @@ static int usb_stor_scan_thread(void * __us) | |||
839 | * fail to freeze, but we can't be non-freezable either. Nor can | 840 | * fail to freeze, but we can't be non-freezable either. Nor can |
840 | * khubd freeze while waiting for scanning to complete as it may | 841 | * khubd freeze while waiting for scanning to complete as it may |
841 | * hold the device lock, causing a hang when suspending devices. | 842 | * hold the device lock, causing a hang when suspending devices. |
842 | * So we request a fake signal when freezing and use | 843 | * So instead of using wait_event_freezable(), explicitly test |
843 | * interruptible sleep to kick us out of our wait early when | 844 | * for (DONT_SCAN || freezing) in interruptible wait and proceed |
844 | * freezing happens. | 845 | * if any of DONT_SCAN, freezing or timeout has happened. |
845 | */ | 846 | */ |
846 | if (delay_use > 0) { | 847 | if (delay_use > 0) { |
847 | dev_dbg(dev, "waiting for device to settle " | 848 | dev_dbg(dev, "waiting for device to settle " |
848 | "before scanning\n"); | 849 | "before scanning\n"); |
849 | wait_event_interruptible_timeout(us->delay_wait, | 850 | wait_event_interruptible_timeout(us->delay_wait, |
850 | test_bit(US_FLIDX_DONT_SCAN, &us->dflags), | 851 | test_bit(US_FLIDX_DONT_SCAN, &us->dflags) || |
851 | delay_use * HZ); | 852 | freezing(current), delay_use * HZ); |
852 | } | 853 | } |
853 | 854 | ||
854 | /* If the device is still connected, perform the scanning */ | 855 | /* If the device is still connected, perform the scanning */ |
@@ -1073,6 +1074,7 @@ static struct usb_driver usb_storage_driver = { | |||
1073 | .id_table = usb_storage_usb_ids, | 1074 | .id_table = usb_storage_usb_ids, |
1074 | .supports_autosuspend = 1, | 1075 | .supports_autosuspend = 1, |
1075 | .soft_unbind = 1, | 1076 | .soft_unbind = 1, |
1077 | .no_dynamic_id = 1, | ||
1076 | }; | 1078 | }; |
1077 | 1079 | ||
1078 | static int __init usb_stor_init(void) | 1080 | static int __init usb_stor_init(void) |
diff --git a/drivers/usb/usb-skeleton.c b/drivers/usb/usb-skeleton.c index 32d6fc953904..8efeae24764f 100644 --- a/drivers/usb/usb-skeleton.c +++ b/drivers/usb/usb-skeleton.c | |||
@@ -27,6 +27,8 @@ | |||
27 | #define USB_SKEL_VENDOR_ID 0xfff0 | 27 | #define USB_SKEL_VENDOR_ID 0xfff0 |
28 | #define USB_SKEL_PRODUCT_ID 0xfff0 | 28 | #define USB_SKEL_PRODUCT_ID 0xfff0 |
29 | 29 | ||
30 | static DEFINE_MUTEX(skel_mutex); | ||
31 | |||
30 | /* table of devices that work with this driver */ | 32 | /* table of devices that work with this driver */ |
31 | static const struct usb_device_id skel_table[] = { | 33 | static const struct usb_device_id skel_table[] = { |
32 | { USB_DEVICE(USB_SKEL_VENDOR_ID, USB_SKEL_PRODUCT_ID) }, | 34 | { USB_DEVICE(USB_SKEL_VENDOR_ID, USB_SKEL_PRODUCT_ID) }, |
@@ -60,7 +62,6 @@ struct usb_skel { | |||
60 | __u8 bulk_in_endpointAddr; /* the address of the bulk in endpoint */ | 62 | __u8 bulk_in_endpointAddr; /* the address of the bulk in endpoint */ |
61 | __u8 bulk_out_endpointAddr; /* the address of the bulk out endpoint */ | 63 | __u8 bulk_out_endpointAddr; /* the address of the bulk out endpoint */ |
62 | int errors; /* the last request tanked */ | 64 | int errors; /* the last request tanked */ |
63 | int open_count; /* count the number of openers */ | ||
64 | bool ongoing_read; /* a read is going on */ | 65 | bool ongoing_read; /* a read is going on */ |
65 | bool processed_urb; /* indicates we haven't processed the urb */ | 66 | bool processed_urb; /* indicates we haven't processed the urb */ |
66 | spinlock_t err_lock; /* lock for errors */ | 67 | spinlock_t err_lock; /* lock for errors */ |
@@ -100,39 +101,37 @@ static int skel_open(struct inode *inode, struct file *file) | |||
100 | goto exit; | 101 | goto exit; |
101 | } | 102 | } |
102 | 103 | ||
104 | mutex_lock(&skel_mutex); | ||
103 | dev = usb_get_intfdata(interface); | 105 | dev = usb_get_intfdata(interface); |
104 | if (!dev) { | 106 | if (!dev) { |
107 | mutex_unlock(&skel_mutex); | ||
105 | retval = -ENODEV; | 108 | retval = -ENODEV; |
106 | goto exit; | 109 | goto exit; |
107 | } | 110 | } |
108 | 111 | ||
109 | /* increment our usage count for the device */ | 112 | /* increment our usage count for the device */ |
110 | kref_get(&dev->kref); | 113 | kref_get(&dev->kref); |
114 | mutex_unlock(&skel_mutex); | ||
111 | 115 | ||
112 | /* lock the device to allow correctly handling errors | 116 | /* lock the device to allow correctly handling errors |
113 | * in resumption */ | 117 | * in resumption */ |
114 | mutex_lock(&dev->io_mutex); | 118 | mutex_lock(&dev->io_mutex); |
119 | if (!dev->interface) { | ||
120 | retval = -ENODEV; | ||
121 | goto out_err; | ||
122 | } | ||
115 | 123 | ||
116 | if (!dev->open_count++) { | 124 | retval = usb_autopm_get_interface(interface); |
117 | retval = usb_autopm_get_interface(interface); | 125 | if (retval) |
118 | if (retval) { | 126 | goto out_err; |
119 | dev->open_count--; | ||
120 | mutex_unlock(&dev->io_mutex); | ||
121 | kref_put(&dev->kref, skel_delete); | ||
122 | goto exit; | ||
123 | } | ||
124 | } /* else { //uncomment this block if you want exclusive open | ||
125 | retval = -EBUSY; | ||
126 | dev->open_count--; | ||
127 | mutex_unlock(&dev->io_mutex); | ||
128 | kref_put(&dev->kref, skel_delete); | ||
129 | goto exit; | ||
130 | } */ | ||
131 | /* prevent the device from being autosuspended */ | ||
132 | 127 | ||
133 | /* save our object in the file's private structure */ | 128 | /* save our object in the file's private structure */ |
134 | file->private_data = dev; | 129 | file->private_data = dev; |
130 | |||
131 | out_err: | ||
135 | mutex_unlock(&dev->io_mutex); | 132 | mutex_unlock(&dev->io_mutex); |
133 | if (retval) | ||
134 | kref_put(&dev->kref, skel_delete); | ||
136 | 135 | ||
137 | exit: | 136 | exit: |
138 | return retval; | 137 | return retval; |
@@ -148,7 +147,7 @@ static int skel_release(struct inode *inode, struct file *file) | |||
148 | 147 | ||
149 | /* allow the device to be autosuspended */ | 148 | /* allow the device to be autosuspended */ |
150 | mutex_lock(&dev->io_mutex); | 149 | mutex_lock(&dev->io_mutex); |
151 | if (!--dev->open_count && dev->interface) | 150 | if (dev->interface) |
152 | usb_autopm_put_interface(dev->interface); | 151 | usb_autopm_put_interface(dev->interface); |
153 | mutex_unlock(&dev->io_mutex); | 152 | mutex_unlock(&dev->io_mutex); |
154 | 153 | ||
@@ -612,7 +611,6 @@ static void skel_disconnect(struct usb_interface *interface) | |||
612 | int minor = interface->minor; | 611 | int minor = interface->minor; |
613 | 612 | ||
614 | dev = usb_get_intfdata(interface); | 613 | dev = usb_get_intfdata(interface); |
615 | usb_set_intfdata(interface, NULL); | ||
616 | 614 | ||
617 | /* give back our minor */ | 615 | /* give back our minor */ |
618 | usb_deregister_dev(interface, &skel_class); | 616 | usb_deregister_dev(interface, &skel_class); |
@@ -624,8 +622,12 @@ static void skel_disconnect(struct usb_interface *interface) | |||
624 | 622 | ||
625 | usb_kill_anchored_urbs(&dev->submitted); | 623 | usb_kill_anchored_urbs(&dev->submitted); |
626 | 624 | ||
625 | mutex_lock(&skel_mutex); | ||
626 | usb_set_intfdata(interface, NULL); | ||
627 | |||
627 | /* decrement our usage count */ | 628 | /* decrement our usage count */ |
628 | kref_put(&dev->kref, skel_delete); | 629 | kref_put(&dev->kref, skel_delete); |
630 | mutex_unlock(&skel_mutex); | ||
629 | 631 | ||
630 | dev_info(&interface->dev, "USB Skeleton #%d now disconnected", minor); | 632 | dev_info(&interface->dev, "USB Skeleton #%d now disconnected", minor); |
631 | } | 633 | } |
@@ -688,25 +690,6 @@ static struct usb_driver skel_driver = { | |||
688 | .supports_autosuspend = 1, | 690 | .supports_autosuspend = 1, |
689 | }; | 691 | }; |
690 | 692 | ||
691 | static int __init usb_skel_init(void) | 693 | module_usb_driver(skel_driver); |
692 | { | ||
693 | int result; | ||
694 | |||
695 | /* register this driver with the USB subsystem */ | ||
696 | result = usb_register(&skel_driver); | ||
697 | if (result) | ||
698 | err("usb_register failed. Error number %d", result); | ||
699 | |||
700 | return result; | ||
701 | } | ||
702 | |||
703 | static void __exit usb_skel_exit(void) | ||
704 | { | ||
705 | /* deregister this driver with the USB subsystem */ | ||
706 | usb_deregister(&skel_driver); | ||
707 | } | ||
708 | |||
709 | module_init(usb_skel_init); | ||
710 | module_exit(usb_skel_exit); | ||
711 | 694 | ||
712 | MODULE_LICENSE("GPL"); | 695 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/usb/wusbcore/Kconfig b/drivers/usb/wusbcore/Kconfig index eb09a0a14a80..0ead8826ec79 100644 --- a/drivers/usb/wusbcore/Kconfig +++ b/drivers/usb/wusbcore/Kconfig | |||
@@ -5,6 +5,7 @@ config USB_WUSB | |||
5 | tristate "Enable Wireless USB extensions (EXPERIMENTAL)" | 5 | tristate "Enable Wireless USB extensions (EXPERIMENTAL)" |
6 | depends on EXPERIMENTAL | 6 | depends on EXPERIMENTAL |
7 | depends on USB | 7 | depends on USB |
8 | depends on PCI | ||
8 | select UWB | 9 | select UWB |
9 | select CRYPTO | 10 | select CRYPTO |
10 | select CRYPTO_BLKCIPHER | 11 | select CRYPTO_BLKCIPHER |
diff --git a/drivers/usb/wusbcore/cbaf.c b/drivers/usb/wusbcore/cbaf.c index 200fd7c6c7d5..7f78f300f8fb 100644 --- a/drivers/usb/wusbcore/cbaf.c +++ b/drivers/usb/wusbcore/cbaf.c | |||
@@ -655,17 +655,7 @@ static struct usb_driver cbaf_driver = { | |||
655 | .disconnect = cbaf_disconnect, | 655 | .disconnect = cbaf_disconnect, |
656 | }; | 656 | }; |
657 | 657 | ||
658 | static int __init cbaf_driver_init(void) | 658 | module_usb_driver(cbaf_driver); |
659 | { | ||
660 | return usb_register(&cbaf_driver); | ||
661 | } | ||
662 | module_init(cbaf_driver_init); | ||
663 | |||
664 | static void __exit cbaf_driver_exit(void) | ||
665 | { | ||
666 | usb_deregister(&cbaf_driver); | ||
667 | } | ||
668 | module_exit(cbaf_driver_exit); | ||
669 | 659 | ||
670 | MODULE_AUTHOR("Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>"); | 660 | MODULE_AUTHOR("Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>"); |
671 | MODULE_DESCRIPTION("Wireless USB Cable Based Association"); | 661 | MODULE_DESCRIPTION("Wireless USB Cable Based Association"); |
diff --git a/drivers/usb/wusbcore/security.c b/drivers/usb/wusbcore/security.c index 371f61733f05..fa810a83e830 100644 --- a/drivers/usb/wusbcore/security.c +++ b/drivers/usb/wusbcore/security.c | |||
@@ -354,7 +354,7 @@ int wusb_dev_4way_handshake(struct wusbhc *wusbhc, struct wusb_dev *wusb_dev, | |||
354 | struct wusb_keydvt_in keydvt_in; | 354 | struct wusb_keydvt_in keydvt_in; |
355 | struct wusb_keydvt_out keydvt_out; | 355 | struct wusb_keydvt_out keydvt_out; |
356 | 356 | ||
357 | hs = kzalloc(3*sizeof(hs[0]), GFP_KERNEL); | 357 | hs = kcalloc(3, sizeof(hs[0]), GFP_KERNEL); |
358 | if (hs == NULL) { | 358 | if (hs == NULL) { |
359 | dev_err(dev, "can't allocate handshake data\n"); | 359 | dev_err(dev, "can't allocate handshake data\n"); |
360 | goto error_kzalloc; | 360 | goto error_kzalloc; |