diff options
Diffstat (limited to 'drivers/usb')
254 files changed, 10363 insertions, 5847 deletions
diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig index 7065df6036ca..2564b546ba8a 100644 --- a/drivers/usb/Kconfig +++ b/drivers/usb/Kconfig | |||
@@ -48,6 +48,7 @@ config USB_ARCH_HAS_EHCI | |||
48 | default y if SPARC_LEON | 48 | default y if SPARC_LEON |
49 | default y if ARCH_MMP | 49 | default y if ARCH_MMP |
50 | default y if MACH_LOONGSON1 | 50 | default y if MACH_LOONGSON1 |
51 | default y if PLAT_ORION | ||
51 | default PCI | 52 | default PCI |
52 | 53 | ||
53 | # some non-PCI HCDs implement xHCI | 54 | # some non-PCI HCDs implement xHCI |
diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c index d7e422dc0ef7..e1f8b2c973fe 100644 --- a/drivers/usb/atm/ueagle-atm.c +++ b/drivers/usb/atm/ueagle-atm.c | |||
@@ -307,6 +307,34 @@ enum { | |||
307 | #define FW_GET_BYTE(p) (*((__u8 *) (p))) | 307 | #define FW_GET_BYTE(p) (*((__u8 *) (p))) |
308 | 308 | ||
309 | #define FW_DIR "ueagle-atm/" | 309 | #define FW_DIR "ueagle-atm/" |
310 | #define EAGLE_FIRMWARE FW_DIR "eagle.fw" | ||
311 | #define ADI930_FIRMWARE FW_DIR "adi930.fw" | ||
312 | #define EAGLE_I_FIRMWARE FW_DIR "eagleI.fw" | ||
313 | #define EAGLE_II_FIRMWARE FW_DIR "eagleII.fw" | ||
314 | #define EAGLE_III_FIRMWARE FW_DIR "eagleIII.fw" | ||
315 | #define EAGLE_IV_FIRMWARE FW_DIR "eagleIV.fw" | ||
316 | |||
317 | #define DSP4I_FIRMWARE FW_DIR "DSP4i.bin" | ||
318 | #define DSP4P_FIRMWARE FW_DIR "DSP4p.bin" | ||
319 | #define DSP9I_FIRMWARE FW_DIR "DSP9i.bin" | ||
320 | #define DSP9P_FIRMWARE FW_DIR "DSP9p.bin" | ||
321 | #define DSPEI_FIRMWARE FW_DIR "DSPei.bin" | ||
322 | #define DSPEP_FIRMWARE FW_DIR "DSPep.bin" | ||
323 | #define FPGA930_FIRMWARE FW_DIR "930-fpga.bin" | ||
324 | |||
325 | #define CMV4P_FIRMWARE FW_DIR "CMV4p.bin" | ||
326 | #define CMV4PV2_FIRMWARE FW_DIR "CMV4p.bin.v2" | ||
327 | #define CMV4I_FIRMWARE FW_DIR "CMV4i.bin" | ||
328 | #define CMV4IV2_FIRMWARE FW_DIR "CMV4i.bin.v2" | ||
329 | #define CMV9P_FIRMWARE FW_DIR "CMV9p.bin" | ||
330 | #define CMV9PV2_FIRMWARE FW_DIR "CMV9p.bin.v2" | ||
331 | #define CMV9I_FIRMWARE FW_DIR "CMV9i.bin" | ||
332 | #define CMV9IV2_FIRMWARE FW_DIR "CMV9i.bin.v2" | ||
333 | #define CMVEP_FIRMWARE FW_DIR "CMVep.bin" | ||
334 | #define CMVEPV2_FIRMWARE FW_DIR "CMVep.bin.v2" | ||
335 | #define CMVEI_FIRMWARE FW_DIR "CMVei.bin" | ||
336 | #define CMVEIV2_FIRMWARE FW_DIR "CMVei.bin.v2" | ||
337 | |||
310 | #define UEA_FW_NAME_MAX 30 | 338 | #define UEA_FW_NAME_MAX 30 |
311 | #define NB_MODEM 4 | 339 | #define NB_MODEM 4 |
312 | 340 | ||
@@ -694,26 +722,26 @@ err: | |||
694 | static int uea_load_firmware(struct usb_device *usb, unsigned int ver) | 722 | static int uea_load_firmware(struct usb_device *usb, unsigned int ver) |
695 | { | 723 | { |
696 | int ret; | 724 | int ret; |
697 | char *fw_name = FW_DIR "eagle.fw"; | 725 | char *fw_name = EAGLE_FIRMWARE; |
698 | 726 | ||
699 | uea_enters(usb); | 727 | uea_enters(usb); |
700 | uea_info(usb, "pre-firmware device, uploading firmware\n"); | 728 | uea_info(usb, "pre-firmware device, uploading firmware\n"); |
701 | 729 | ||
702 | switch (ver) { | 730 | switch (ver) { |
703 | case ADI930: | 731 | case ADI930: |
704 | fw_name = FW_DIR "adi930.fw"; | 732 | fw_name = ADI930_FIRMWARE; |
705 | break; | 733 | break; |
706 | case EAGLE_I: | 734 | case EAGLE_I: |
707 | fw_name = FW_DIR "eagleI.fw"; | 735 | fw_name = EAGLE_I_FIRMWARE; |
708 | break; | 736 | break; |
709 | case EAGLE_II: | 737 | case EAGLE_II: |
710 | fw_name = FW_DIR "eagleII.fw"; | 738 | fw_name = EAGLE_II_FIRMWARE; |
711 | break; | 739 | break; |
712 | case EAGLE_III: | 740 | case EAGLE_III: |
713 | fw_name = FW_DIR "eagleIII.fw"; | 741 | fw_name = EAGLE_III_FIRMWARE; |
714 | break; | 742 | break; |
715 | case EAGLE_IV: | 743 | case EAGLE_IV: |
716 | fw_name = FW_DIR "eagleIV.fw"; | 744 | fw_name = EAGLE_IV_FIRMWARE; |
717 | break; | 745 | break; |
718 | } | 746 | } |
719 | 747 | ||
@@ -869,19 +897,19 @@ static int request_dsp(struct uea_softc *sc) | |||
869 | 897 | ||
870 | if (UEA_CHIP_VERSION(sc) == EAGLE_IV) { | 898 | if (UEA_CHIP_VERSION(sc) == EAGLE_IV) { |
871 | if (IS_ISDN(sc)) | 899 | if (IS_ISDN(sc)) |
872 | dsp_name = FW_DIR "DSP4i.bin"; | 900 | dsp_name = DSP4I_FIRMWARE; |
873 | else | 901 | else |
874 | dsp_name = FW_DIR "DSP4p.bin"; | 902 | dsp_name = DSP4P_FIRMWARE; |
875 | } else if (UEA_CHIP_VERSION(sc) == ADI930) { | 903 | } else if (UEA_CHIP_VERSION(sc) == ADI930) { |
876 | if (IS_ISDN(sc)) | 904 | if (IS_ISDN(sc)) |
877 | dsp_name = FW_DIR "DSP9i.bin"; | 905 | dsp_name = DSP9I_FIRMWARE; |
878 | else | 906 | else |
879 | dsp_name = FW_DIR "DSP9p.bin"; | 907 | dsp_name = DSP9P_FIRMWARE; |
880 | } else { | 908 | } else { |
881 | if (IS_ISDN(sc)) | 909 | if (IS_ISDN(sc)) |
882 | dsp_name = FW_DIR "DSPei.bin"; | 910 | dsp_name = DSPEI_FIRMWARE; |
883 | else | 911 | else |
884 | dsp_name = FW_DIR "DSPep.bin"; | 912 | dsp_name = DSPEP_FIRMWARE; |
885 | } | 913 | } |
886 | 914 | ||
887 | ret = request_firmware(&sc->dsp_firm, dsp_name, &sc->usb_dev->dev); | 915 | ret = request_firmware(&sc->dsp_firm, dsp_name, &sc->usb_dev->dev); |
@@ -1925,7 +1953,7 @@ static int load_XILINX_firmware(struct uea_softc *sc) | |||
1925 | int ret, size, u, ln; | 1953 | int ret, size, u, ln; |
1926 | const u8 *pfw; | 1954 | const u8 *pfw; |
1927 | u8 value; | 1955 | u8 value; |
1928 | char *fw_name = FW_DIR "930-fpga.bin"; | 1956 | char *fw_name = FPGA930_FIRMWARE; |
1929 | 1957 | ||
1930 | uea_enters(INS_TO_USBDEV(sc)); | 1958 | uea_enters(INS_TO_USBDEV(sc)); |
1931 | 1959 | ||
@@ -2753,3 +2781,28 @@ module_usb_driver(uea_driver); | |||
2753 | MODULE_AUTHOR("Damien Bergamini/Matthieu Castet/Stanislaw W. Gruszka"); | 2781 | MODULE_AUTHOR("Damien Bergamini/Matthieu Castet/Stanislaw W. Gruszka"); |
2754 | MODULE_DESCRIPTION("ADI 930/Eagle USB ADSL Modem driver"); | 2782 | MODULE_DESCRIPTION("ADI 930/Eagle USB ADSL Modem driver"); |
2755 | MODULE_LICENSE("Dual BSD/GPL"); | 2783 | MODULE_LICENSE("Dual BSD/GPL"); |
2784 | MODULE_FIRMWARE(EAGLE_FIRMWARE); | ||
2785 | MODULE_FIRMWARE(ADI930_FIRMWARE); | ||
2786 | MODULE_FIRMWARE(EAGLE_I_FIRMWARE); | ||
2787 | MODULE_FIRMWARE(EAGLE_II_FIRMWARE); | ||
2788 | MODULE_FIRMWARE(EAGLE_III_FIRMWARE); | ||
2789 | MODULE_FIRMWARE(EAGLE_IV_FIRMWARE); | ||
2790 | MODULE_FIRMWARE(DSP4I_FIRMWARE); | ||
2791 | MODULE_FIRMWARE(DSP4P_FIRMWARE); | ||
2792 | MODULE_FIRMWARE(DSP9I_FIRMWARE); | ||
2793 | MODULE_FIRMWARE(DSP9P_FIRMWARE); | ||
2794 | MODULE_FIRMWARE(DSPEI_FIRMWARE); | ||
2795 | MODULE_FIRMWARE(DSPEP_FIRMWARE); | ||
2796 | MODULE_FIRMWARE(FPGA930_FIRMWARE); | ||
2797 | MODULE_FIRMWARE(CMV4P_FIRMWARE); | ||
2798 | MODULE_FIRMWARE(CMV4PV2_FIRMWARE); | ||
2799 | MODULE_FIRMWARE(CMV4I_FIRMWARE); | ||
2800 | MODULE_FIRMWARE(CMV4IV2_FIRMWARE); | ||
2801 | MODULE_FIRMWARE(CMV9P_FIRMWARE); | ||
2802 | MODULE_FIRMWARE(CMV9PV2_FIRMWARE); | ||
2803 | MODULE_FIRMWARE(CMV9I_FIRMWARE); | ||
2804 | MODULE_FIRMWARE(CMV9IV2_FIRMWARE); | ||
2805 | MODULE_FIRMWARE(CMVEP_FIRMWARE); | ||
2806 | MODULE_FIRMWARE(CMVEPV2_FIRMWARE); | ||
2807 | MODULE_FIRMWARE(CMVEI_FIRMWARE); | ||
2808 | MODULE_FIRMWARE(CMVEIV2_FIRMWARE); | ||
diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c index ee62b3576f94..35f10bfe15db 100644 --- a/drivers/usb/atm/usbatm.c +++ b/drivers/usb/atm/usbatm.c | |||
@@ -84,7 +84,7 @@ | |||
84 | #include <linux/ratelimit.h> | 84 | #include <linux/ratelimit.h> |
85 | 85 | ||
86 | #ifdef VERBOSE_DEBUG | 86 | #ifdef VERBOSE_DEBUG |
87 | static int usbatm_print_packet(const unsigned char *data, int len); | 87 | static int usbatm_print_packet(struct usbatm_data *instance, const unsigned char *data, int len); |
88 | #define PACKETDEBUG(arg...) usbatm_print_packet(arg) | 88 | #define PACKETDEBUG(arg...) usbatm_print_packet(arg) |
89 | #define vdbg(arg...) dev_dbg(arg) | 89 | #define vdbg(arg...) dev_dbg(arg) |
90 | #else | 90 | #else |
@@ -230,8 +230,8 @@ static int usbatm_submit_urb(struct urb *urb) | |||
230 | struct usbatm_channel *channel = urb->context; | 230 | struct usbatm_channel *channel = urb->context; |
231 | int ret; | 231 | int ret; |
232 | 232 | ||
233 | vdbg("%s: submitting urb 0x%p, size %u", | 233 | /* vdbg("%s: submitting urb 0x%p, size %u", |
234 | __func__, urb, urb->transfer_buffer_length); | 234 | __func__, urb, urb->transfer_buffer_length); */ |
235 | 235 | ||
236 | ret = usb_submit_urb(urb, GFP_ATOMIC); | 236 | ret = usb_submit_urb(urb, GFP_ATOMIC); |
237 | if (ret) { | 237 | if (ret) { |
@@ -261,8 +261,8 @@ static void usbatm_complete(struct urb *urb) | |||
261 | unsigned long flags; | 261 | unsigned long flags; |
262 | int status = urb->status; | 262 | int status = urb->status; |
263 | 263 | ||
264 | vdbg("%s: urb 0x%p, status %d, actual_length %d", | 264 | /* vdbg("%s: urb 0x%p, status %d, actual_length %d", |
265 | __func__, urb, status, urb->actual_length); | 265 | __func__, urb, status, urb->actual_length); */ |
266 | 266 | ||
267 | /* usually in_interrupt(), but not always */ | 267 | /* usually in_interrupt(), but not always */ |
268 | spin_lock_irqsave(&channel->lock, flags); | 268 | spin_lock_irqsave(&channel->lock, flags); |
@@ -311,7 +311,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char | |||
311 | int vci = ((source[1] & 0x0f) << 12) | (source[2] << 4) | (source[3] >> 4); | 311 | int vci = ((source[1] & 0x0f) << 12) | (source[2] << 4) | (source[3] >> 4); |
312 | u8 pti = ((source[3] & 0xe) >> 1); | 312 | u8 pti = ((source[3] & 0xe) >> 1); |
313 | 313 | ||
314 | vdbg("%s: vpi %hd, vci %d, pti %d", __func__, vpi, vci, pti); | 314 | vdbg(&instance->usb_intf->dev, "%s: vpi %hd, vci %d, pti %d", __func__, vpi, vci, pti); |
315 | 315 | ||
316 | if ((vci != instance->cached_vci) || (vpi != instance->cached_vpi)) { | 316 | if ((vci != instance->cached_vci) || (vpi != instance->cached_vpi)) { |
317 | instance->cached_vpi = vpi; | 317 | instance->cached_vpi = vpi; |
@@ -381,7 +381,9 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char | |||
381 | goto out; | 381 | goto out; |
382 | } | 382 | } |
383 | 383 | ||
384 | vdbg("%s: got packet (length: %u, pdu_length: %u, vcc: 0x%p)", __func__, length, pdu_length, vcc); | 384 | vdbg(&instance->usb_intf->dev, |
385 | "%s: got packet (length: %u, pdu_length: %u, vcc: 0x%p)", | ||
386 | __func__, length, pdu_length, vcc); | ||
385 | 387 | ||
386 | if (!(skb = dev_alloc_skb(length))) { | 388 | if (!(skb = dev_alloc_skb(length))) { |
387 | if (printk_ratelimit()) | 389 | if (printk_ratelimit()) |
@@ -391,7 +393,9 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char | |||
391 | goto out; | 393 | goto out; |
392 | } | 394 | } |
393 | 395 | ||
394 | vdbg("%s: allocated new sk_buff (skb: 0x%p, skb->truesize: %u)", __func__, skb, skb->truesize); | 396 | vdbg(&instance->usb_intf->dev, |
397 | "%s: allocated new sk_buff (skb: 0x%p, skb->truesize: %u)", | ||
398 | __func__, skb, skb->truesize); | ||
395 | 399 | ||
396 | if (!atm_charge(vcc, skb->truesize)) { | 400 | if (!atm_charge(vcc, skb->truesize)) { |
397 | atm_rldbg(instance, "%s: failed atm_charge (skb->truesize: %u)!\n", | 401 | atm_rldbg(instance, "%s: failed atm_charge (skb->truesize: %u)!\n", |
@@ -405,10 +409,11 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char | |||
405 | length); | 409 | length); |
406 | __skb_put(skb, length); | 410 | __skb_put(skb, length); |
407 | 411 | ||
408 | vdbg("%s: sending skb 0x%p, skb->len %u, skb->truesize %u", | 412 | vdbg(&instance->usb_intf->dev, |
413 | "%s: sending skb 0x%p, skb->len %u, skb->truesize %u", | ||
409 | __func__, skb, skb->len, skb->truesize); | 414 | __func__, skb, skb->len, skb->truesize); |
410 | 415 | ||
411 | PACKETDEBUG(skb->data, skb->len); | 416 | PACKETDEBUG(instance, skb->data, skb->len); |
412 | 417 | ||
413 | vcc->push(vcc, skb); | 418 | vcc->push(vcc, skb); |
414 | 419 | ||
@@ -474,7 +479,8 @@ static unsigned int usbatm_write_cells(struct usbatm_data *instance, | |||
474 | unsigned int bytes_written; | 479 | unsigned int bytes_written; |
475 | unsigned int stride = instance->tx_channel.stride; | 480 | unsigned int stride = instance->tx_channel.stride; |
476 | 481 | ||
477 | vdbg("%s: skb->len=%d, avail_space=%u", __func__, skb->len, avail_space); | 482 | vdbg(&instance->usb_intf->dev, "%s: skb->len=%d, avail_space=%u", |
483 | __func__, skb->len, avail_space); | ||
478 | UDSL_ASSERT(instance, !(avail_space % stride)); | 484 | UDSL_ASSERT(instance, !(avail_space % stride)); |
479 | 485 | ||
480 | for (bytes_written = 0; bytes_written < avail_space && ctrl->len; | 486 | for (bytes_written = 0; bytes_written < avail_space && ctrl->len; |
@@ -534,7 +540,8 @@ static void usbatm_rx_process(unsigned long data) | |||
534 | struct urb *urb; | 540 | struct urb *urb; |
535 | 541 | ||
536 | while ((urb = usbatm_pop_urb(&instance->rx_channel))) { | 542 | while ((urb = usbatm_pop_urb(&instance->rx_channel))) { |
537 | vdbg("%s: processing urb 0x%p", __func__, urb); | 543 | vdbg(&instance->usb_intf->dev, |
544 | "%s: processing urb 0x%p", __func__, urb); | ||
538 | 545 | ||
539 | if (usb_pipeisoc(urb->pipe)) { | 546 | if (usb_pipeisoc(urb->pipe)) { |
540 | unsigned char *merge_start = NULL; | 547 | unsigned char *merge_start = NULL; |
@@ -608,7 +615,8 @@ static void usbatm_tx_process(unsigned long data) | |||
608 | buffer + bytes_written, | 615 | buffer + bytes_written, |
609 | buf_size - bytes_written); | 616 | buf_size - bytes_written); |
610 | 617 | ||
611 | vdbg("%s: wrote %u bytes from skb 0x%p to urb 0x%p", | 618 | vdbg(&instance->usb_intf->dev, |
619 | "%s: wrote %u bytes from skb 0x%p to urb 0x%p", | ||
612 | __func__, bytes_written, skb, urb); | 620 | __func__, bytes_written, skb, urb); |
613 | 621 | ||
614 | if (!UDSL_SKB(skb)->len) { | 622 | if (!UDSL_SKB(skb)->len) { |
@@ -664,7 +672,8 @@ static int usbatm_atm_send(struct atm_vcc *vcc, struct sk_buff *skb) | |||
664 | struct usbatm_control *ctrl = UDSL_SKB(skb); | 672 | struct usbatm_control *ctrl = UDSL_SKB(skb); |
665 | int err; | 673 | int err; |
666 | 674 | ||
667 | vdbg("%s called (skb 0x%p, len %u)", __func__, skb, skb->len); | 675 | vdbg(&instance->usb_intf->dev, "%s called (skb 0x%p, len %u)", __func__, |
676 | skb, skb->len); | ||
668 | 677 | ||
669 | /* racy disconnection check - fine */ | 678 | /* racy disconnection check - fine */ |
670 | if (!instance || instance->disconnected) { | 679 | if (!instance || instance->disconnected) { |
@@ -688,7 +697,7 @@ static int usbatm_atm_send(struct atm_vcc *vcc, struct sk_buff *skb) | |||
688 | goto fail; | 697 | goto fail; |
689 | } | 698 | } |
690 | 699 | ||
691 | PACKETDEBUG(skb->data, skb->len); | 700 | PACKETDEBUG(instance, skb->data, skb->len); |
692 | 701 | ||
693 | /* initialize the control block */ | 702 | /* initialize the control block */ |
694 | ctrl->atm.vcc = vcc; | 703 | ctrl->atm.vcc = vcc; |
@@ -1202,7 +1211,7 @@ int usbatm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id, | |||
1202 | if (i >= num_rcv_urbs) | 1211 | if (i >= num_rcv_urbs) |
1203 | list_add_tail(&urb->urb_list, &channel->list); | 1212 | list_add_tail(&urb->urb_list, &channel->list); |
1204 | 1213 | ||
1205 | vdbg("%s: alloced buffer 0x%p buf size %u urb 0x%p", | 1214 | vdbg(&intf->dev, "%s: alloced buffer 0x%p buf size %u urb 0x%p", |
1206 | __func__, urb->transfer_buffer, urb->transfer_buffer_length, urb); | 1215 | __func__, urb->transfer_buffer, urb->transfer_buffer_length, urb); |
1207 | } | 1216 | } |
1208 | 1217 | ||
@@ -1359,7 +1368,8 @@ MODULE_VERSION(DRIVER_VERSION); | |||
1359 | ************/ | 1368 | ************/ |
1360 | 1369 | ||
1361 | #ifdef VERBOSE_DEBUG | 1370 | #ifdef VERBOSE_DEBUG |
1362 | static int usbatm_print_packet(const unsigned char *data, int len) | 1371 | static int usbatm_print_packet(struct usbatm_data *instance, |
1372 | const unsigned char *data, int len) | ||
1363 | { | 1373 | { |
1364 | unsigned char buffer[256]; | 1374 | unsigned char buffer[256]; |
1365 | int i = 0, j = 0; | 1375 | int i = 0, j = 0; |
@@ -1369,7 +1379,7 @@ static int usbatm_print_packet(const unsigned char *data, int len) | |||
1369 | sprintf(buffer, "%.3d :", i); | 1379 | sprintf(buffer, "%.3d :", i); |
1370 | for (j = 0; (j < 16) && (i < len); j++, i++) | 1380 | for (j = 0; (j < 16) && (i < len); j++, i++) |
1371 | sprintf(buffer, "%s %2.2x", buffer, data[i]); | 1381 | sprintf(buffer, "%s %2.2x", buffer, data[i]); |
1372 | dbg("%s", buffer); | 1382 | dev_dbg(&instance->usb_intf->dev, "%s", buffer); |
1373 | } | 1383 | } |
1374 | return i; | 1384 | return i; |
1375 | } | 1385 | } |
diff --git a/drivers/usb/chipidea/Kconfig b/drivers/usb/chipidea/Kconfig index 47e499c9c0b6..1ea932a13685 100644 --- a/drivers/usb/chipidea/Kconfig +++ b/drivers/usb/chipidea/Kconfig | |||
@@ -13,7 +13,6 @@ if USB_CHIPIDEA | |||
13 | config USB_CHIPIDEA_UDC | 13 | config USB_CHIPIDEA_UDC |
14 | bool "ChipIdea device controller" | 14 | bool "ChipIdea device controller" |
15 | depends on USB_GADGET=y || USB_GADGET=USB_CHIPIDEA | 15 | depends on USB_GADGET=y || USB_GADGET=USB_CHIPIDEA |
16 | select USB_GADGET_DUALSPEED | ||
17 | help | 16 | help |
18 | Say Y here to enable device controller functionality of the | 17 | Say Y here to enable device controller functionality of the |
19 | ChipIdea driver. | 18 | ChipIdea driver. |
diff --git a/drivers/usb/chipidea/Makefile b/drivers/usb/chipidea/Makefile index 5c66d9c330ca..d92ca325b104 100644 --- a/drivers/usb/chipidea/Makefile +++ b/drivers/usb/chipidea/Makefile | |||
@@ -1,3 +1,5 @@ | |||
1 | ccflags-$(CONFIG_USB_CHIPIDEA_DEBUG) := -DDEBUG | ||
2 | |||
1 | obj-$(CONFIG_USB_CHIPIDEA) += ci_hdrc.o | 3 | obj-$(CONFIG_USB_CHIPIDEA) += ci_hdrc.o |
2 | 4 | ||
3 | ci_hdrc-y := core.o | 5 | ci_hdrc-y := core.o |
@@ -15,5 +17,5 @@ ifneq ($(CONFIG_PCI),) | |||
15 | endif | 17 | endif |
16 | 18 | ||
17 | ifneq ($(CONFIG_OF_DEVICE),) | 19 | ifneq ($(CONFIG_OF_DEVICE),) |
18 | obj-$(CONFIG_USB_CHIPIDEA) += ci13xxx_imx.o | 20 | obj-$(CONFIG_USB_CHIPIDEA) += ci13xxx_imx.o usbmisc_imx6q.o |
19 | endif | 21 | endif |
diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h index d738603a2757..e25d1263da13 100644 --- a/drivers/usb/chipidea/ci.h +++ b/drivers/usb/chipidea/ci.h | |||
@@ -139,6 +139,7 @@ struct ci13xxx { | |||
139 | enum ci_role role; | 139 | enum ci_role role; |
140 | bool is_otg; | 140 | bool is_otg; |
141 | struct work_struct work; | 141 | struct work_struct work; |
142 | struct work_struct vbus_work; | ||
142 | struct workqueue_struct *wq; | 143 | struct workqueue_struct *wq; |
143 | 144 | ||
144 | struct dma_pool *qh_pool; | 145 | struct dma_pool *qh_pool; |
diff --git a/drivers/usb/chipidea/ci13xxx_imx.c b/drivers/usb/chipidea/ci13xxx_imx.c index ef60d06835d0..0f5ca4bea17f 100644 --- a/drivers/usb/chipidea/ci13xxx_imx.c +++ b/drivers/usb/chipidea/ci13xxx_imx.c | |||
@@ -20,8 +20,10 @@ | |||
20 | #include <linux/usb/chipidea.h> | 20 | #include <linux/usb/chipidea.h> |
21 | #include <linux/clk.h> | 21 | #include <linux/clk.h> |
22 | #include <linux/regulator/consumer.h> | 22 | #include <linux/regulator/consumer.h> |
23 | #include <linux/pinctrl/consumer.h> | ||
23 | 24 | ||
24 | #include "ci.h" | 25 | #include "ci.h" |
26 | #include "ci13xxx_imx.h" | ||
25 | 27 | ||
26 | #define pdev_to_phy(pdev) \ | 28 | #define pdev_to_phy(pdev) \ |
27 | ((struct usb_phy *)platform_get_drvdata(pdev)) | 29 | ((struct usb_phy *)platform_get_drvdata(pdev)) |
@@ -34,6 +36,55 @@ struct ci13xxx_imx_data { | |||
34 | struct regulator *reg_vbus; | 36 | struct regulator *reg_vbus; |
35 | }; | 37 | }; |
36 | 38 | ||
39 | static const struct usbmisc_ops *usbmisc_ops; | ||
40 | |||
41 | /* Common functions shared by usbmisc drivers */ | ||
42 | |||
43 | int usbmisc_set_ops(const struct usbmisc_ops *ops) | ||
44 | { | ||
45 | if (usbmisc_ops) | ||
46 | return -EBUSY; | ||
47 | |||
48 | usbmisc_ops = ops; | ||
49 | |||
50 | return 0; | ||
51 | } | ||
52 | EXPORT_SYMBOL_GPL(usbmisc_set_ops); | ||
53 | |||
54 | void usbmisc_unset_ops(const struct usbmisc_ops *ops) | ||
55 | { | ||
56 | usbmisc_ops = NULL; | ||
57 | } | ||
58 | EXPORT_SYMBOL_GPL(usbmisc_unset_ops); | ||
59 | |||
60 | int usbmisc_get_init_data(struct device *dev, struct usbmisc_usb_device *usbdev) | ||
61 | { | ||
62 | struct device_node *np = dev->of_node; | ||
63 | struct of_phandle_args args; | ||
64 | int ret; | ||
65 | |||
66 | usbdev->dev = dev; | ||
67 | |||
68 | ret = of_parse_phandle_with_args(np, "fsl,usbmisc", "#index-cells", | ||
69 | 0, &args); | ||
70 | if (ret) { | ||
71 | dev_err(dev, "Failed to parse property fsl,usbmisc, errno %d\n", | ||
72 | ret); | ||
73 | memset(usbdev, 0, sizeof(*usbdev)); | ||
74 | return ret; | ||
75 | } | ||
76 | usbdev->index = args.args[0]; | ||
77 | of_node_put(args.np); | ||
78 | |||
79 | if (of_find_property(np, "disable-over-current", NULL)) | ||
80 | usbdev->disable_oc = 1; | ||
81 | |||
82 | return 0; | ||
83 | } | ||
84 | EXPORT_SYMBOL_GPL(usbmisc_get_init_data); | ||
85 | |||
86 | /* End of common functions shared by usbmisc drivers*/ | ||
87 | |||
37 | static struct ci13xxx_platform_data ci13xxx_imx_platdata __devinitdata = { | 88 | static struct ci13xxx_platform_data ci13xxx_imx_platdata __devinitdata = { |
38 | .name = "ci13xxx_imx", | 89 | .name = "ci13xxx_imx", |
39 | .flags = CI13XXX_REQUIRE_TRANSCEIVER | | 90 | .flags = CI13XXX_REQUIRE_TRANSCEIVER | |
@@ -49,8 +100,13 @@ static int __devinit ci13xxx_imx_probe(struct platform_device *pdev) | |||
49 | struct device_node *phy_np; | 100 | struct device_node *phy_np; |
50 | struct resource *res; | 101 | struct resource *res; |
51 | struct regulator *reg_vbus; | 102 | struct regulator *reg_vbus; |
103 | struct pinctrl *pinctrl; | ||
52 | int ret; | 104 | int ret; |
53 | 105 | ||
106 | if (of_find_property(pdev->dev.of_node, "fsl,usbmisc", NULL) | ||
107 | && !usbmisc_ops) | ||
108 | return -EPROBE_DEFER; | ||
109 | |||
54 | data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); | 110 | data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); |
55 | if (!data) { | 111 | if (!data) { |
56 | dev_err(&pdev->dev, "Failed to allocate CI13xxx-IMX data!\n"); | 112 | dev_err(&pdev->dev, "Failed to allocate CI13xxx-IMX data!\n"); |
@@ -63,6 +119,11 @@ static int __devinit ci13xxx_imx_probe(struct platform_device *pdev) | |||
63 | return -ENOENT; | 119 | return -ENOENT; |
64 | } | 120 | } |
65 | 121 | ||
122 | pinctrl = devm_pinctrl_get_select_default(&pdev->dev); | ||
123 | if (IS_ERR(pinctrl)) | ||
124 | dev_warn(&pdev->dev, "pinctrl get/select failed, err=%ld\n", | ||
125 | PTR_ERR(pinctrl)); | ||
126 | |||
66 | data->clk = devm_clk_get(&pdev->dev, NULL); | 127 | data->clk = devm_clk_get(&pdev->dev, NULL); |
67 | if (IS_ERR(data->clk)) { | 128 | if (IS_ERR(data->clk)) { |
68 | dev_err(&pdev->dev, | 129 | dev_err(&pdev->dev, |
@@ -120,6 +181,16 @@ static int __devinit ci13xxx_imx_probe(struct platform_device *pdev) | |||
120 | *pdev->dev.dma_mask = DMA_BIT_MASK(32); | 181 | *pdev->dev.dma_mask = DMA_BIT_MASK(32); |
121 | dma_set_coherent_mask(&pdev->dev, *pdev->dev.dma_mask); | 182 | dma_set_coherent_mask(&pdev->dev, *pdev->dev.dma_mask); |
122 | } | 183 | } |
184 | |||
185 | if (usbmisc_ops && usbmisc_ops->init) { | ||
186 | ret = usbmisc_ops->init(&pdev->dev); | ||
187 | if (ret) { | ||
188 | dev_err(&pdev->dev, | ||
189 | "usbmisc init failed, ret=%d\n", ret); | ||
190 | goto err; | ||
191 | } | ||
192 | } | ||
193 | |||
123 | plat_ci = ci13xxx_add_device(&pdev->dev, | 194 | plat_ci = ci13xxx_add_device(&pdev->dev, |
124 | pdev->resource, pdev->num_resources, | 195 | pdev->resource, pdev->num_resources, |
125 | &ci13xxx_imx_platdata); | 196 | &ci13xxx_imx_platdata); |
diff --git a/drivers/usb/chipidea/ci13xxx_imx.h b/drivers/usb/chipidea/ci13xxx_imx.h new file mode 100644 index 000000000000..2e88accb3d67 --- /dev/null +++ b/drivers/usb/chipidea/ci13xxx_imx.h | |||
@@ -0,0 +1,28 @@ | |||
1 | /* | ||
2 | * Copyright 2012 Freescale Semiconductor, Inc. | ||
3 | * | ||
4 | * The code contained herein is licensed under the GNU General Public | ||
5 | * License. You may obtain a copy of the GNU General Public License | ||
6 | * Version 2 or later at the following locations: | ||
7 | * | ||
8 | * http://www.opensource.org/licenses/gpl-license.html | ||
9 | * http://www.gnu.org/copyleft/gpl.html | ||
10 | */ | ||
11 | |||
12 | /* Used to set SoC specific callbacks */ | ||
13 | struct usbmisc_ops { | ||
14 | /* It's called once when probe a usb device */ | ||
15 | int (*init)(struct device *dev); | ||
16 | }; | ||
17 | |||
18 | struct usbmisc_usb_device { | ||
19 | struct device *dev; /* usb controller device */ | ||
20 | int index; | ||
21 | |||
22 | int disable_oc:1; /* over current detect disabled */ | ||
23 | }; | ||
24 | |||
25 | int usbmisc_set_ops(const struct usbmisc_ops *ops); | ||
26 | void usbmisc_unset_ops(const struct usbmisc_ops *ops); | ||
27 | int | ||
28 | usbmisc_get_init_data(struct device *dev, struct usbmisc_usb_device *usbdev); | ||
diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c index 1083585fad00..f69d029b4607 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c | |||
@@ -273,14 +273,13 @@ static void ci_role_work(struct work_struct *work) | |||
273 | struct ci13xxx *ci = container_of(work, struct ci13xxx, work); | 273 | struct ci13xxx *ci = container_of(work, struct ci13xxx, work); |
274 | enum ci_role role = ci_otg_role(ci); | 274 | enum ci_role role = ci_otg_role(ci); |
275 | 275 | ||
276 | hw_write(ci, OP_OTGSC, OTGSC_IDIS, OTGSC_IDIS); | ||
277 | |||
278 | if (role != ci->role) { | 276 | if (role != ci->role) { |
279 | dev_dbg(ci->dev, "switching from %s to %s\n", | 277 | dev_dbg(ci->dev, "switching from %s to %s\n", |
280 | ci_role(ci)->name, ci->roles[role]->name); | 278 | ci_role(ci)->name, ci->roles[role]->name); |
281 | 279 | ||
282 | ci_role_stop(ci); | 280 | ci_role_stop(ci); |
283 | ci_role_start(ci, role); | 281 | ci_role_start(ci, role); |
282 | enable_irq(ci->irq); | ||
284 | } | 283 | } |
285 | } | 284 | } |
286 | 285 | ||
@@ -320,17 +319,22 @@ static irqreturn_t ci_irq(int irq, void *data) | |||
320 | { | 319 | { |
321 | struct ci13xxx *ci = data; | 320 | struct ci13xxx *ci = data; |
322 | irqreturn_t ret = IRQ_NONE; | 321 | irqreturn_t ret = IRQ_NONE; |
322 | u32 otgsc = 0; | ||
323 | |||
324 | if (ci->is_otg) | ||
325 | otgsc = hw_read(ci, OP_OTGSC, ~0); | ||
323 | 326 | ||
324 | if (ci->is_otg) { | 327 | if (ci->role != CI_ROLE_END) |
325 | u32 sts = hw_read(ci, OP_OTGSC, ~0); | 328 | ret = ci_role(ci)->irq(ci); |
326 | 329 | ||
327 | if (sts & OTGSC_IDIS) { | 330 | if (ci->is_otg && (otgsc & OTGSC_IDIS)) { |
328 | queue_work(ci->wq, &ci->work); | 331 | hw_write(ci, OP_OTGSC, OTGSC_IDIS, OTGSC_IDIS); |
329 | ret = IRQ_HANDLED; | 332 | disable_irq_nosync(ci->irq); |
330 | } | 333 | queue_work(ci->wq, &ci->work); |
334 | ret = IRQ_HANDLED; | ||
331 | } | 335 | } |
332 | 336 | ||
333 | return ci->role == CI_ROLE_END ? ret : ci_role(ci)->irq(ci); | 337 | return ret; |
334 | } | 338 | } |
335 | 339 | ||
336 | static DEFINE_IDA(ci_ida); | 340 | static DEFINE_IDA(ci_ida); |
@@ -462,6 +466,8 @@ static int __devinit ci_hdrc_probe(struct platform_device *pdev) | |||
462 | 466 | ||
463 | if (ci->roles[CI_ROLE_HOST] && ci->roles[CI_ROLE_GADGET]) { | 467 | if (ci->roles[CI_ROLE_HOST] && ci->roles[CI_ROLE_GADGET]) { |
464 | ci->is_otg = true; | 468 | ci->is_otg = true; |
469 | /* ID pin needs 1ms debouce time, we delay 2ms for safe */ | ||
470 | mdelay(2); | ||
465 | ci->role = ci_otg_role(ci); | 471 | ci->role = ci_otg_role(ci); |
466 | } else { | 472 | } else { |
467 | ci->role = ci->roles[CI_ROLE_HOST] | 473 | ci->role = ci->roles[CI_ROLE_HOST] |
diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c index d214448b677e..2f45bba8561d 100644 --- a/drivers/usb/chipidea/udc.c +++ b/drivers/usb/chipidea/udc.c | |||
@@ -305,6 +305,18 @@ static u32 hw_test_and_clear_intr_active(struct ci13xxx *ci) | |||
305 | return reg; | 305 | return reg; |
306 | } | 306 | } |
307 | 307 | ||
308 | static void hw_enable_vbus_intr(struct ci13xxx *ci) | ||
309 | { | ||
310 | hw_write(ci, OP_OTGSC, OTGSC_AVVIS, OTGSC_AVVIS); | ||
311 | hw_write(ci, OP_OTGSC, OTGSC_AVVIE, OTGSC_AVVIE); | ||
312 | queue_work(ci->wq, &ci->vbus_work); | ||
313 | } | ||
314 | |||
315 | static void hw_disable_vbus_intr(struct ci13xxx *ci) | ||
316 | { | ||
317 | hw_write(ci, OP_OTGSC, OTGSC_AVVIE, 0); | ||
318 | } | ||
319 | |||
308 | /** | 320 | /** |
309 | * hw_test_and_clear_setup_guard: test & clear setup guard (execute without | 321 | * hw_test_and_clear_setup_guard: test & clear setup guard (execute without |
310 | * interruption) | 322 | * interruption) |
@@ -371,6 +383,16 @@ static int hw_usb_reset(struct ci13xxx *ci) | |||
371 | return 0; | 383 | return 0; |
372 | } | 384 | } |
373 | 385 | ||
386 | static void vbus_work(struct work_struct *work) | ||
387 | { | ||
388 | struct ci13xxx *ci = container_of(work, struct ci13xxx, vbus_work); | ||
389 | |||
390 | if (hw_read(ci, OP_OTGSC, OTGSC_AVV)) | ||
391 | usb_gadget_vbus_connect(&ci->gadget); | ||
392 | else | ||
393 | usb_gadget_vbus_disconnect(&ci->gadget); | ||
394 | } | ||
395 | |||
374 | /****************************************************************************** | 396 | /****************************************************************************** |
375 | * UTIL block | 397 | * UTIL block |
376 | *****************************************************************************/ | 398 | *****************************************************************************/ |
@@ -1370,6 +1392,7 @@ static int ci13xxx_vbus_session(struct usb_gadget *_gadget, int is_active) | |||
1370 | if (is_active) { | 1392 | if (is_active) { |
1371 | pm_runtime_get_sync(&_gadget->dev); | 1393 | pm_runtime_get_sync(&_gadget->dev); |
1372 | hw_device_reset(ci, USBMODE_CM_DC); | 1394 | hw_device_reset(ci, USBMODE_CM_DC); |
1395 | hw_enable_vbus_intr(ci); | ||
1373 | hw_device_state(ci, ci->ep0out->qh.dma); | 1396 | hw_device_state(ci, ci->ep0out->qh.dma); |
1374 | } else { | 1397 | } else { |
1375 | hw_device_state(ci, 0); | 1398 | hw_device_state(ci, 0); |
@@ -1544,8 +1567,10 @@ static int ci13xxx_start(struct usb_gadget *gadget, | |||
1544 | pm_runtime_get_sync(&ci->gadget.dev); | 1567 | pm_runtime_get_sync(&ci->gadget.dev); |
1545 | if (ci->platdata->flags & CI13XXX_PULLUP_ON_VBUS) { | 1568 | if (ci->platdata->flags & CI13XXX_PULLUP_ON_VBUS) { |
1546 | if (ci->vbus_active) { | 1569 | if (ci->vbus_active) { |
1547 | if (ci->platdata->flags & CI13XXX_REGS_SHARED) | 1570 | if (ci->platdata->flags & CI13XXX_REGS_SHARED) { |
1548 | hw_device_reset(ci, USBMODE_CM_DC); | 1571 | hw_device_reset(ci, USBMODE_CM_DC); |
1572 | hw_enable_vbus_intr(ci); | ||
1573 | } | ||
1549 | } else { | 1574 | } else { |
1550 | pm_runtime_put_sync(&ci->gadget.dev); | 1575 | pm_runtime_put_sync(&ci->gadget.dev); |
1551 | goto done; | 1576 | goto done; |
@@ -1651,6 +1676,13 @@ static irqreturn_t udc_irq(struct ci13xxx *ci) | |||
1651 | } else { | 1676 | } else { |
1652 | retval = IRQ_NONE; | 1677 | retval = IRQ_NONE; |
1653 | } | 1678 | } |
1679 | |||
1680 | intr = hw_read(ci, OP_OTGSC, ~0); | ||
1681 | hw_write(ci, OP_OTGSC, ~0, intr); | ||
1682 | |||
1683 | if (intr & (OTGSC_AVVIE & OTGSC_AVVIS)) | ||
1684 | queue_work(ci->wq, &ci->vbus_work); | ||
1685 | |||
1654 | spin_unlock(&ci->lock); | 1686 | spin_unlock(&ci->lock); |
1655 | 1687 | ||
1656 | return retval; | 1688 | return retval; |
@@ -1726,6 +1758,7 @@ static int udc_start(struct ci13xxx *ci) | |||
1726 | retval = hw_device_reset(ci, USBMODE_CM_DC); | 1758 | retval = hw_device_reset(ci, USBMODE_CM_DC); |
1727 | if (retval) | 1759 | if (retval) |
1728 | goto put_transceiver; | 1760 | goto put_transceiver; |
1761 | hw_enable_vbus_intr(ci); | ||
1729 | } | 1762 | } |
1730 | 1763 | ||
1731 | retval = device_register(&ci->gadget.dev); | 1764 | retval = device_register(&ci->gadget.dev); |
@@ -1788,6 +1821,9 @@ static void udc_stop(struct ci13xxx *ci) | |||
1788 | if (ci == NULL) | 1821 | if (ci == NULL) |
1789 | return; | 1822 | return; |
1790 | 1823 | ||
1824 | hw_disable_vbus_intr(ci); | ||
1825 | cancel_work_sync(&ci->vbus_work); | ||
1826 | |||
1791 | usb_del_gadget_udc(&ci->gadget); | 1827 | usb_del_gadget_udc(&ci->gadget); |
1792 | 1828 | ||
1793 | destroy_eps(ci); | 1829 | destroy_eps(ci); |
@@ -1828,6 +1864,7 @@ int ci_hdrc_gadget_init(struct ci13xxx *ci) | |||
1828 | rdrv->irq = udc_irq; | 1864 | rdrv->irq = udc_irq; |
1829 | rdrv->name = "gadget"; | 1865 | rdrv->name = "gadget"; |
1830 | ci->roles[CI_ROLE_GADGET] = rdrv; | 1866 | ci->roles[CI_ROLE_GADGET] = rdrv; |
1867 | INIT_WORK(&ci->vbus_work, vbus_work); | ||
1831 | 1868 | ||
1832 | return 0; | 1869 | return 0; |
1833 | } | 1870 | } |
diff --git a/drivers/usb/chipidea/usbmisc_imx6q.c b/drivers/usb/chipidea/usbmisc_imx6q.c new file mode 100644 index 000000000000..416e3fc58fd0 --- /dev/null +++ b/drivers/usb/chipidea/usbmisc_imx6q.c | |||
@@ -0,0 +1,162 @@ | |||
1 | /* | ||
2 | * Copyright 2012 Freescale Semiconductor, Inc. | ||
3 | * | ||
4 | * The code contained herein is licensed under the GNU General Public | ||
5 | * License. You may obtain a copy of the GNU General Public License | ||
6 | * Version 2 or later at the following locations: | ||
7 | * | ||
8 | * http://www.opensource.org/licenses/gpl-license.html | ||
9 | * http://www.gnu.org/copyleft/gpl.html | ||
10 | */ | ||
11 | |||
12 | #include <linux/module.h> | ||
13 | #include <linux/of_platform.h> | ||
14 | #include <linux/clk.h> | ||
15 | #include <linux/err.h> | ||
16 | #include <linux/io.h> | ||
17 | |||
18 | #include "ci13xxx_imx.h" | ||
19 | |||
20 | #define USB_DEV_MAX 4 | ||
21 | |||
22 | #define BM_OVER_CUR_DIS BIT(7) | ||
23 | |||
24 | struct imx6q_usbmisc { | ||
25 | void __iomem *base; | ||
26 | spinlock_t lock; | ||
27 | struct clk *clk; | ||
28 | struct usbmisc_usb_device usbdev[USB_DEV_MAX]; | ||
29 | }; | ||
30 | |||
31 | static struct imx6q_usbmisc *usbmisc; | ||
32 | |||
33 | static struct usbmisc_usb_device *get_usbdev(struct device *dev) | ||
34 | { | ||
35 | int i, ret; | ||
36 | |||
37 | for (i = 0; i < USB_DEV_MAX; i++) { | ||
38 | if (usbmisc->usbdev[i].dev == dev) | ||
39 | return &usbmisc->usbdev[i]; | ||
40 | else if (!usbmisc->usbdev[i].dev) | ||
41 | break; | ||
42 | } | ||
43 | |||
44 | if (i >= USB_DEV_MAX) | ||
45 | return ERR_PTR(-EBUSY); | ||
46 | |||
47 | ret = usbmisc_get_init_data(dev, &usbmisc->usbdev[i]); | ||
48 | if (ret) | ||
49 | return ERR_PTR(ret); | ||
50 | |||
51 | return &usbmisc->usbdev[i]; | ||
52 | } | ||
53 | |||
54 | static int usbmisc_imx6q_init(struct device *dev) | ||
55 | { | ||
56 | |||
57 | struct usbmisc_usb_device *usbdev; | ||
58 | unsigned long flags; | ||
59 | u32 reg; | ||
60 | |||
61 | usbdev = get_usbdev(dev); | ||
62 | if (IS_ERR(usbdev)) | ||
63 | return PTR_ERR(usbdev); | ||
64 | |||
65 | if (usbdev->disable_oc) { | ||
66 | spin_lock_irqsave(&usbmisc->lock, flags); | ||
67 | reg = readl(usbmisc->base + usbdev->index * 4); | ||
68 | writel(reg | BM_OVER_CUR_DIS, | ||
69 | usbmisc->base + usbdev->index * 4); | ||
70 | spin_unlock_irqrestore(&usbmisc->lock, flags); | ||
71 | } | ||
72 | |||
73 | return 0; | ||
74 | } | ||
75 | |||
76 | static const struct usbmisc_ops imx6q_usbmisc_ops = { | ||
77 | .init = usbmisc_imx6q_init, | ||
78 | }; | ||
79 | |||
80 | static const struct of_device_id usbmisc_imx6q_dt_ids[] = { | ||
81 | { .compatible = "fsl,imx6q-usbmisc"}, | ||
82 | { /* sentinel */ } | ||
83 | }; | ||
84 | |||
85 | static int __devinit usbmisc_imx6q_probe(struct platform_device *pdev) | ||
86 | { | ||
87 | struct resource *res; | ||
88 | struct imx6q_usbmisc *data; | ||
89 | int ret; | ||
90 | |||
91 | if (usbmisc) | ||
92 | return -EBUSY; | ||
93 | |||
94 | data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); | ||
95 | if (!data) | ||
96 | return -ENOMEM; | ||
97 | |||
98 | spin_lock_init(&data->lock); | ||
99 | |||
100 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
101 | data->base = devm_request_and_ioremap(&pdev->dev, res); | ||
102 | if (!data->base) | ||
103 | return -EADDRNOTAVAIL; | ||
104 | |||
105 | data->clk = devm_clk_get(&pdev->dev, NULL); | ||
106 | if (IS_ERR(data->clk)) { | ||
107 | dev_err(&pdev->dev, | ||
108 | "failed to get clock, err=%ld\n", PTR_ERR(data->clk)); | ||
109 | return PTR_ERR(data->clk); | ||
110 | } | ||
111 | |||
112 | ret = clk_prepare_enable(data->clk); | ||
113 | if (ret) { | ||
114 | dev_err(&pdev->dev, | ||
115 | "clk_prepare_enable failed, err=%d\n", ret); | ||
116 | return ret; | ||
117 | } | ||
118 | |||
119 | ret = usbmisc_set_ops(&imx6q_usbmisc_ops); | ||
120 | if (ret) { | ||
121 | clk_disable_unprepare(data->clk); | ||
122 | return ret; | ||
123 | } | ||
124 | |||
125 | usbmisc = data; | ||
126 | |||
127 | return 0; | ||
128 | } | ||
129 | |||
130 | static int __devexit usbmisc_imx6q_remove(struct platform_device *pdev) | ||
131 | { | ||
132 | usbmisc_unset_ops(&imx6q_usbmisc_ops); | ||
133 | clk_disable_unprepare(usbmisc->clk); | ||
134 | return 0; | ||
135 | } | ||
136 | |||
137 | static struct platform_driver usbmisc_imx6q_driver = { | ||
138 | .probe = usbmisc_imx6q_probe, | ||
139 | .remove = __devexit_p(usbmisc_imx6q_remove), | ||
140 | .driver = { | ||
141 | .name = "usbmisc_imx6q", | ||
142 | .owner = THIS_MODULE, | ||
143 | .of_match_table = usbmisc_imx6q_dt_ids, | ||
144 | }, | ||
145 | }; | ||
146 | |||
147 | int __init usbmisc_imx6q_drv_init(void) | ||
148 | { | ||
149 | return platform_driver_register(&usbmisc_imx6q_driver); | ||
150 | } | ||
151 | subsys_initcall(usbmisc_imx6q_drv_init); | ||
152 | |||
153 | void __exit usbmisc_imx6q_drv_exit(void) | ||
154 | { | ||
155 | platform_driver_unregister(&usbmisc_imx6q_driver); | ||
156 | } | ||
157 | module_exit(usbmisc_imx6q_drv_exit); | ||
158 | |||
159 | MODULE_ALIAS("platform:usbmisc-imx6q"); | ||
160 | MODULE_LICENSE("GPL v2"); | ||
161 | MODULE_DESCRIPTION("driver for imx6q usb non-core registers"); | ||
162 | MODULE_AUTHOR("Richard Zhao <richard.zhao@freescale.com>"); | ||
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c index ff7b5a8d501c..36f2be4def2f 100644 --- a/drivers/usb/class/cdc-acm.c +++ b/drivers/usb/class/cdc-acm.c | |||
@@ -39,7 +39,6 @@ | |||
39 | #include <linux/serial.h> | 39 | #include <linux/serial.h> |
40 | #include <linux/tty_driver.h> | 40 | #include <linux/tty_driver.h> |
41 | #include <linux/tty_flip.h> | 41 | #include <linux/tty_flip.h> |
42 | #include <linux/serial.h> | ||
43 | #include <linux/module.h> | 42 | #include <linux/module.h> |
44 | #include <linux/mutex.h> | 43 | #include <linux/mutex.h> |
45 | #include <linux/uaccess.h> | 44 | #include <linux/uaccess.h> |
diff --git a/drivers/usb/core/Kconfig b/drivers/usb/core/Kconfig index 9981984b365b..f70c1a1694ad 100644 --- a/drivers/usb/core/Kconfig +++ b/drivers/usb/core/Kconfig | |||
@@ -56,7 +56,7 @@ config USB_SUSPEND | |||
56 | 56 | ||
57 | config USB_OTG | 57 | config USB_OTG |
58 | bool "OTG support" | 58 | bool "OTG support" |
59 | depends on USB && EXPERIMENTAL | 59 | depends on USB |
60 | depends on USB_SUSPEND | 60 | depends on USB_SUSPEND |
61 | default n | 61 | default n |
62 | help | 62 | help |
diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c index f4bdd0ce8d56..7199adccf444 100644 --- a/drivers/usb/core/config.c +++ b/drivers/usb/core/config.c | |||
@@ -702,6 +702,8 @@ int usb_get_configuration(struct usb_device *dev) | |||
702 | if (result < 0) { | 702 | if (result < 0) { |
703 | dev_err(ddev, "unable to read config index %d " | 703 | dev_err(ddev, "unable to read config index %d " |
704 | "descriptor/%s: %d\n", cfgno, "start", result); | 704 | "descriptor/%s: %d\n", cfgno, "start", result); |
705 | if (result != -EPIPE) | ||
706 | goto err; | ||
705 | dev_err(ddev, "chopping to %d config(s)\n", cfgno); | 707 | dev_err(ddev, "chopping to %d config(s)\n", cfgno); |
706 | dev->descriptor.bNumConfigurations = cfgno; | 708 | dev->descriptor.bNumConfigurations = cfgno; |
707 | break; | 709 | break; |
diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c index 3440812b4a84..f460de31acee 100644 --- a/drivers/usb/core/devices.c +++ b/drivers/usb/core/devices.c | |||
@@ -496,6 +496,7 @@ static ssize_t usb_device_dump(char __user **buffer, size_t *nbytes, | |||
496 | char *pages_start, *data_end, *speed; | 496 | char *pages_start, *data_end, *speed; |
497 | unsigned int length; | 497 | unsigned int length; |
498 | ssize_t total_written = 0; | 498 | ssize_t total_written = 0; |
499 | struct usb_device *childdev = NULL; | ||
499 | 500 | ||
500 | /* don't bother with anything else if we're not writing any data */ | 501 | /* don't bother with anything else if we're not writing any data */ |
501 | if (*nbytes <= 0) | 502 | if (*nbytes <= 0) |
@@ -589,14 +590,12 @@ static ssize_t usb_device_dump(char __user **buffer, size_t *nbytes, | |||
589 | free_pages((unsigned long)pages_start, 1); | 590 | free_pages((unsigned long)pages_start, 1); |
590 | 591 | ||
591 | /* Now look at all of this device's children. */ | 592 | /* Now look at all of this device's children. */ |
592 | for (chix = 0; chix < usbdev->maxchild; chix++) { | 593 | usb_hub_for_each_child(usbdev, chix, childdev) { |
593 | struct usb_device *childdev = usbdev->children[chix]; | ||
594 | |||
595 | if (childdev) { | 594 | if (childdev) { |
596 | usb_lock_device(childdev); | 595 | usb_lock_device(childdev); |
597 | ret = usb_device_dump(buffer, nbytes, skip_bytes, | 596 | ret = usb_device_dump(buffer, nbytes, skip_bytes, |
598 | file_offset, childdev, bus, | 597 | file_offset, childdev, bus, |
599 | level + 1, chix, ++cnt); | 598 | level + 1, chix - 1, ++cnt); |
600 | usb_unlock_device(childdev); | 599 | usb_unlock_device(childdev); |
601 | if (ret == -EFAULT) | 600 | if (ret == -EFAULT) |
602 | return total_written; | 601 | return total_written; |
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c index ebb8a9de8b5f..e0356cb859b5 100644 --- a/drivers/usb/core/devio.c +++ b/drivers/usb/core/devio.c | |||
@@ -1928,6 +1928,38 @@ static int proc_get_capabilities(struct dev_state *ps, void __user *arg) | |||
1928 | return 0; | 1928 | return 0; |
1929 | } | 1929 | } |
1930 | 1930 | ||
1931 | static int proc_disconnect_claim(struct dev_state *ps, void __user *arg) | ||
1932 | { | ||
1933 | struct usbdevfs_disconnect_claim dc; | ||
1934 | struct usb_interface *intf; | ||
1935 | |||
1936 | if (copy_from_user(&dc, arg, sizeof(dc))) | ||
1937 | return -EFAULT; | ||
1938 | |||
1939 | intf = usb_ifnum_to_if(ps->dev, dc.interface); | ||
1940 | if (!intf) | ||
1941 | return -EINVAL; | ||
1942 | |||
1943 | if (intf->dev.driver) { | ||
1944 | struct usb_driver *driver = to_usb_driver(intf->dev.driver); | ||
1945 | |||
1946 | if ((dc.flags & USBDEVFS_DISCONNECT_CLAIM_IF_DRIVER) && | ||
1947 | strncmp(dc.driver, intf->dev.driver->name, | ||
1948 | sizeof(dc.driver)) != 0) | ||
1949 | return -EBUSY; | ||
1950 | |||
1951 | if ((dc.flags & USBDEVFS_DISCONNECT_CLAIM_EXCEPT_DRIVER) && | ||
1952 | strncmp(dc.driver, intf->dev.driver->name, | ||
1953 | sizeof(dc.driver)) == 0) | ||
1954 | return -EBUSY; | ||
1955 | |||
1956 | dev_dbg(&intf->dev, "disconnect by usbfs\n"); | ||
1957 | usb_driver_release_interface(driver, intf); | ||
1958 | } | ||
1959 | |||
1960 | return claimintf(ps, dc.interface); | ||
1961 | } | ||
1962 | |||
1931 | /* | 1963 | /* |
1932 | * NOTE: All requests here that have interface numbers as parameters | 1964 | * NOTE: All requests here that have interface numbers as parameters |
1933 | * are assuming that somehow the configuration has been prevented from | 1965 | * are assuming that somehow the configuration has been prevented from |
@@ -2101,6 +2133,9 @@ static long usbdev_do_ioctl(struct file *file, unsigned int cmd, | |||
2101 | case USBDEVFS_GET_CAPABILITIES: | 2133 | case USBDEVFS_GET_CAPABILITIES: |
2102 | ret = proc_get_capabilities(ps, p); | 2134 | ret = proc_get_capabilities(ps, p); |
2103 | break; | 2135 | break; |
2136 | case USBDEVFS_DISCONNECT_CLAIM: | ||
2137 | ret = proc_disconnect_claim(ps, p); | ||
2138 | break; | ||
2104 | } | 2139 | } |
2105 | usb_unlock_device(dev); | 2140 | usb_unlock_device(dev); |
2106 | if (ret >= 0) | 2141 | if (ret >= 0) |
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c index 445455a4429b..ddd820d25288 100644 --- a/drivers/usb/core/driver.c +++ b/drivers/usb/core/driver.c | |||
@@ -125,10 +125,9 @@ store_remove_id(struct device_driver *driver, const char *buf, size_t count) | |||
125 | { | 125 | { |
126 | struct usb_dynid *dynid, *n; | 126 | struct usb_dynid *dynid, *n; |
127 | struct usb_driver *usb_driver = to_usb_driver(driver); | 127 | struct usb_driver *usb_driver = to_usb_driver(driver); |
128 | u32 idVendor = 0; | 128 | u32 idVendor; |
129 | u32 idProduct = 0; | 129 | u32 idProduct; |
130 | int fields = 0; | 130 | int fields; |
131 | int retval = 0; | ||
132 | 131 | ||
133 | fields = sscanf(buf, "%x %x", &idVendor, &idProduct); | 132 | fields = sscanf(buf, "%x %x", &idVendor, &idProduct); |
134 | if (fields < 2) | 133 | if (fields < 2) |
@@ -141,14 +140,10 @@ store_remove_id(struct device_driver *driver, const char *buf, size_t count) | |||
141 | (id->idProduct == idProduct)) { | 140 | (id->idProduct == idProduct)) { |
142 | list_del(&dynid->node); | 141 | list_del(&dynid->node); |
143 | kfree(dynid); | 142 | kfree(dynid); |
144 | retval = 0; | ||
145 | break; | 143 | break; |
146 | } | 144 | } |
147 | } | 145 | } |
148 | spin_unlock(&usb_driver->dynids.lock); | 146 | spin_unlock(&usb_driver->dynids.lock); |
149 | |||
150 | if (retval) | ||
151 | return retval; | ||
152 | return count; | 147 | return count; |
153 | } | 148 | } |
154 | static DRIVER_ATTR(remove_id, S_IRUGO | S_IWUSR, show_dynids, store_remove_id); | 149 | static DRIVER_ATTR(remove_id, S_IRUGO | S_IWUSR, show_dynids, store_remove_id); |
diff --git a/drivers/usb/core/endpoint.c b/drivers/usb/core/endpoint.c index db7fe50c23d4..68cc6532e749 100644 --- a/drivers/usb/core/endpoint.c +++ b/drivers/usb/core/endpoint.c | |||
@@ -24,10 +24,6 @@ struct ep_device { | |||
24 | #define to_ep_device(_dev) \ | 24 | #define to_ep_device(_dev) \ |
25 | container_of(_dev, struct ep_device, dev) | 25 | container_of(_dev, struct ep_device, dev) |
26 | 26 | ||
27 | struct device_type usb_ep_device_type = { | ||
28 | .name = "usb_endpoint", | ||
29 | }; | ||
30 | |||
31 | struct ep_attribute { | 27 | struct ep_attribute { |
32 | struct attribute attr; | 28 | struct attribute attr; |
33 | ssize_t (*show)(struct usb_device *, | 29 | ssize_t (*show)(struct usb_device *, |
@@ -172,6 +168,11 @@ static void ep_device_release(struct device *dev) | |||
172 | kfree(ep_dev); | 168 | kfree(ep_dev); |
173 | } | 169 | } |
174 | 170 | ||
171 | struct device_type usb_ep_device_type = { | ||
172 | .name = "usb_endpoint", | ||
173 | .release = ep_device_release, | ||
174 | }; | ||
175 | |||
175 | int usb_create_ep_devs(struct device *parent, | 176 | int usb_create_ep_devs(struct device *parent, |
176 | struct usb_host_endpoint *endpoint, | 177 | struct usb_host_endpoint *endpoint, |
177 | struct usb_device *udev) | 178 | struct usb_device *udev) |
@@ -190,7 +191,6 @@ int usb_create_ep_devs(struct device *parent, | |||
190 | ep_dev->dev.groups = ep_dev_groups; | 191 | ep_dev->dev.groups = ep_dev_groups; |
191 | ep_dev->dev.type = &usb_ep_device_type; | 192 | ep_dev->dev.type = &usb_ep_device_type; |
192 | ep_dev->dev.parent = parent; | 193 | ep_dev->dev.parent = parent; |
193 | ep_dev->dev.release = ep_device_release; | ||
194 | dev_set_name(&ep_dev->dev, "ep_%02x", endpoint->desc.bEndpointAddress); | 194 | dev_set_name(&ep_dev->dev, "ep_%02x", endpoint->desc.bEndpointAddress); |
195 | 195 | ||
196 | retval = device_register(&ep_dev->dev); | 196 | retval = device_register(&ep_dev->dev); |
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index 75ba2091f9b4..1e741bca0265 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c | |||
@@ -22,6 +22,7 @@ | |||
22 | * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 22 | * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include <linux/bcd.h> | ||
25 | #include <linux/module.h> | 26 | #include <linux/module.h> |
26 | #include <linux/version.h> | 27 | #include <linux/version.h> |
27 | #include <linux/kernel.h> | 28 | #include <linux/kernel.h> |
@@ -123,9 +124,8 @@ static inline int is_root_hub(struct usb_device *udev) | |||
123 | */ | 124 | */ |
124 | 125 | ||
125 | /*-------------------------------------------------------------------------*/ | 126 | /*-------------------------------------------------------------------------*/ |
126 | 127 | #define KERNEL_REL bin2bcd(((LINUX_VERSION_CODE >> 16) & 0x0ff)) | |
127 | #define KERNEL_REL ((LINUX_VERSION_CODE >> 16) & 0x0ff) | 128 | #define KERNEL_VER bin2bcd(((LINUX_VERSION_CODE >> 8) & 0x0ff)) |
128 | #define KERNEL_VER ((LINUX_VERSION_CODE >> 8) & 0x0ff) | ||
129 | 129 | ||
130 | /* usb 3.0 root hub device descriptor */ | 130 | /* usb 3.0 root hub device descriptor */ |
131 | static const u8 usb3_rh_dev_descriptor[18] = { | 131 | static const u8 usb3_rh_dev_descriptor[18] = { |
@@ -2151,15 +2151,8 @@ EXPORT_SYMBOL_GPL(usb_bus_start_enum); | |||
2151 | irqreturn_t usb_hcd_irq (int irq, void *__hcd) | 2151 | irqreturn_t usb_hcd_irq (int irq, void *__hcd) |
2152 | { | 2152 | { |
2153 | struct usb_hcd *hcd = __hcd; | 2153 | struct usb_hcd *hcd = __hcd; |
2154 | unsigned long flags; | ||
2155 | irqreturn_t rc; | 2154 | irqreturn_t rc; |
2156 | 2155 | ||
2157 | /* IRQF_DISABLED doesn't work correctly with shared IRQs | ||
2158 | * when the first handler doesn't use it. So let's just | ||
2159 | * assume it's never used. | ||
2160 | */ | ||
2161 | local_irq_save(flags); | ||
2162 | |||
2163 | if (unlikely(HCD_DEAD(hcd) || !HCD_HW_ACCESSIBLE(hcd))) | 2156 | if (unlikely(HCD_DEAD(hcd) || !HCD_HW_ACCESSIBLE(hcd))) |
2164 | rc = IRQ_NONE; | 2157 | rc = IRQ_NONE; |
2165 | else if (hcd->driver->irq(hcd) == IRQ_NONE) | 2158 | else if (hcd->driver->irq(hcd) == IRQ_NONE) |
@@ -2167,7 +2160,6 @@ irqreturn_t usb_hcd_irq (int irq, void *__hcd) | |||
2167 | else | 2160 | else |
2168 | rc = IRQ_HANDLED; | 2161 | rc = IRQ_HANDLED; |
2169 | 2162 | ||
2170 | local_irq_restore(flags); | ||
2171 | return rc; | 2163 | return rc; |
2172 | } | 2164 | } |
2173 | EXPORT_SYMBOL_GPL(usb_hcd_irq); | 2165 | EXPORT_SYMBOL_GPL(usb_hcd_irq); |
@@ -2355,14 +2347,6 @@ static int usb_hcd_request_irqs(struct usb_hcd *hcd, | |||
2355 | int retval; | 2347 | int retval; |
2356 | 2348 | ||
2357 | if (hcd->driver->irq) { | 2349 | if (hcd->driver->irq) { |
2358 | |||
2359 | /* IRQF_DISABLED doesn't work as advertised when used together | ||
2360 | * with IRQF_SHARED. As usb_hcd_irq() will always disable | ||
2361 | * interrupts we can remove it here. | ||
2362 | */ | ||
2363 | if (irqflags & IRQF_SHARED) | ||
2364 | irqflags &= ~IRQF_DISABLED; | ||
2365 | |||
2366 | snprintf(hcd->irq_descr, sizeof(hcd->irq_descr), "%s:usb%d", | 2350 | snprintf(hcd->irq_descr, sizeof(hcd->irq_descr), "%s:usb%d", |
2367 | hcd->driver->description, hcd->self.busnum); | 2351 | hcd->driver->description, hcd->self.busnum); |
2368 | retval = request_irq(irqnum, &usb_hcd_irq, irqflags, | 2352 | retval = request_irq(irqnum, &usb_hcd_irq, irqflags, |
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 128a804c42f4..673ee4696262 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c | |||
@@ -39,6 +39,13 @@ | |||
39 | #endif | 39 | #endif |
40 | #endif | 40 | #endif |
41 | 41 | ||
42 | struct usb_port { | ||
43 | struct usb_device *child; | ||
44 | struct device dev; | ||
45 | struct dev_state *port_owner; | ||
46 | enum usb_port_connect_type connect_type; | ||
47 | }; | ||
48 | |||
42 | struct usb_hub { | 49 | struct usb_hub { |
43 | struct device *intfdev; /* the "interface" device */ | 50 | struct device *intfdev; /* the "interface" device */ |
44 | struct usb_device *hdev; | 51 | struct usb_device *hdev; |
@@ -83,7 +90,7 @@ struct usb_hub { | |||
83 | u8 indicator[USB_MAXCHILDREN]; | 90 | u8 indicator[USB_MAXCHILDREN]; |
84 | struct delayed_work leds; | 91 | struct delayed_work leds; |
85 | struct delayed_work init_work; | 92 | struct delayed_work init_work; |
86 | struct dev_state **port_owners; | 93 | struct usb_port **ports; |
87 | }; | 94 | }; |
88 | 95 | ||
89 | static inline int hub_is_superspeed(struct usb_device *hdev) | 96 | static inline int hub_is_superspeed(struct usb_device *hdev) |
@@ -156,6 +163,8 @@ EXPORT_SYMBOL_GPL(ehci_cf_port_reset_rwsem); | |||
156 | #define HUB_DEBOUNCE_STEP 25 | 163 | #define HUB_DEBOUNCE_STEP 25 |
157 | #define HUB_DEBOUNCE_STABLE 100 | 164 | #define HUB_DEBOUNCE_STABLE 100 |
158 | 165 | ||
166 | #define to_usb_port(_dev) \ | ||
167 | container_of(_dev, struct usb_port, dev) | ||
159 | 168 | ||
160 | static int usb_reset_and_verify_device(struct usb_device *udev); | 169 | static int usb_reset_and_verify_device(struct usb_device *udev); |
161 | 170 | ||
@@ -174,7 +183,7 @@ static inline char *portspeed(struct usb_hub *hub, int portstatus) | |||
174 | /* Note that hdev or one of its children must be locked! */ | 183 | /* Note that hdev or one of its children must be locked! */ |
175 | static struct usb_hub *hdev_to_hub(struct usb_device *hdev) | 184 | static struct usb_hub *hdev_to_hub(struct usb_device *hdev) |
176 | { | 185 | { |
177 | if (!hdev || !hdev->actconfig) | 186 | if (!hdev || !hdev->actconfig || !hdev->maxchild) |
178 | return NULL; | 187 | return NULL; |
179 | return usb_get_intfdata(hdev->actconfig->interface[0]); | 188 | return usb_get_intfdata(hdev->actconfig->interface[0]); |
180 | } | 189 | } |
@@ -869,8 +878,8 @@ static int hub_port_disable(struct usb_hub *hub, int port1, int set_state) | |||
869 | struct usb_device *hdev = hub->hdev; | 878 | struct usb_device *hdev = hub->hdev; |
870 | int ret = 0; | 879 | int ret = 0; |
871 | 880 | ||
872 | if (hdev->children[port1-1] && set_state) | 881 | if (hub->ports[port1 - 1]->child && set_state) |
873 | usb_set_device_state(hdev->children[port1-1], | 882 | usb_set_device_state(hub->ports[port1 - 1]->child, |
874 | USB_STATE_NOTATTACHED); | 883 | USB_STATE_NOTATTACHED); |
875 | if (!hub->error && !hub_is_superspeed(hub->hdev)) | 884 | if (!hub->error && !hub_is_superspeed(hub->hdev)) |
876 | ret = clear_port_feature(hdev, port1, USB_PORT_FEAT_ENABLE); | 885 | ret = clear_port_feature(hdev, port1, USB_PORT_FEAT_ENABLE); |
@@ -1026,7 +1035,7 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type) | |||
1026 | * which ports need attention. | 1035 | * which ports need attention. |
1027 | */ | 1036 | */ |
1028 | for (port1 = 1; port1 <= hdev->maxchild; ++port1) { | 1037 | for (port1 = 1; port1 <= hdev->maxchild; ++port1) { |
1029 | struct usb_device *udev = hdev->children[port1-1]; | 1038 | struct usb_device *udev = hub->ports[port1 - 1]->child; |
1030 | u16 portstatus, portchange; | 1039 | u16 portstatus, portchange; |
1031 | 1040 | ||
1032 | portstatus = portchange = 0; | 1041 | portstatus = portchange = 0; |
@@ -1191,8 +1200,8 @@ static void hub_quiesce(struct usb_hub *hub, enum hub_quiescing_type type) | |||
1191 | if (type != HUB_SUSPEND) { | 1200 | if (type != HUB_SUSPEND) { |
1192 | /* Disconnect all the children */ | 1201 | /* Disconnect all the children */ |
1193 | for (i = 0; i < hdev->maxchild; ++i) { | 1202 | for (i = 0; i < hdev->maxchild; ++i) { |
1194 | if (hdev->children[i]) | 1203 | if (hub->ports[i]->child) |
1195 | usb_disconnect(&hdev->children[i]); | 1204 | usb_disconnect(&hub->ports[i]->child); |
1196 | } | 1205 | } |
1197 | } | 1206 | } |
1198 | 1207 | ||
@@ -1222,6 +1231,52 @@ static int hub_post_reset(struct usb_interface *intf) | |||
1222 | return 0; | 1231 | return 0; |
1223 | } | 1232 | } |
1224 | 1233 | ||
1234 | static void usb_port_device_release(struct device *dev) | ||
1235 | { | ||
1236 | struct usb_port *port_dev = to_usb_port(dev); | ||
1237 | |||
1238 | kfree(port_dev); | ||
1239 | } | ||
1240 | |||
1241 | static void usb_hub_remove_port_device(struct usb_hub *hub, | ||
1242 | int port1) | ||
1243 | { | ||
1244 | device_unregister(&hub->ports[port1 - 1]->dev); | ||
1245 | } | ||
1246 | |||
1247 | struct device_type usb_port_device_type = { | ||
1248 | .name = "usb_port", | ||
1249 | .release = usb_port_device_release, | ||
1250 | }; | ||
1251 | |||
1252 | static int usb_hub_create_port_device(struct usb_hub *hub, | ||
1253 | int port1) | ||
1254 | { | ||
1255 | struct usb_port *port_dev = NULL; | ||
1256 | int retval; | ||
1257 | |||
1258 | port_dev = kzalloc(sizeof(*port_dev), GFP_KERNEL); | ||
1259 | if (!port_dev) { | ||
1260 | retval = -ENOMEM; | ||
1261 | goto exit; | ||
1262 | } | ||
1263 | |||
1264 | hub->ports[port1 - 1] = port_dev; | ||
1265 | port_dev->dev.parent = hub->intfdev; | ||
1266 | port_dev->dev.type = &usb_port_device_type; | ||
1267 | dev_set_name(&port_dev->dev, "port%d", port1); | ||
1268 | |||
1269 | retval = device_register(&port_dev->dev); | ||
1270 | if (retval) | ||
1271 | goto error_register; | ||
1272 | return 0; | ||
1273 | |||
1274 | error_register: | ||
1275 | put_device(&port_dev->dev); | ||
1276 | exit: | ||
1277 | return retval; | ||
1278 | } | ||
1279 | |||
1225 | static int hub_configure(struct usb_hub *hub, | 1280 | static int hub_configure(struct usb_hub *hub, |
1226 | struct usb_endpoint_descriptor *endpoint) | 1281 | struct usb_endpoint_descriptor *endpoint) |
1227 | { | 1282 | { |
@@ -1231,7 +1286,7 @@ static int hub_configure(struct usb_hub *hub, | |||
1231 | u16 hubstatus, hubchange; | 1286 | u16 hubstatus, hubchange; |
1232 | u16 wHubCharacteristics; | 1287 | u16 wHubCharacteristics; |
1233 | unsigned int pipe; | 1288 | unsigned int pipe; |
1234 | int maxp, ret; | 1289 | int maxp, ret, i; |
1235 | char *message = "out of memory"; | 1290 | char *message = "out of memory"; |
1236 | 1291 | ||
1237 | hub->buffer = kmalloc(sizeof(*hub->buffer), GFP_KERNEL); | 1292 | hub->buffer = kmalloc(sizeof(*hub->buffer), GFP_KERNEL); |
@@ -1271,11 +1326,9 @@ static int hub_configure(struct usb_hub *hub, | |||
1271 | dev_info (hub_dev, "%d port%s detected\n", hdev->maxchild, | 1326 | dev_info (hub_dev, "%d port%s detected\n", hdev->maxchild, |
1272 | (hdev->maxchild == 1) ? "" : "s"); | 1327 | (hdev->maxchild == 1) ? "" : "s"); |
1273 | 1328 | ||
1274 | hdev->children = kzalloc(hdev->maxchild * | 1329 | hub->ports = kzalloc(hdev->maxchild * sizeof(struct usb_port *), |
1275 | sizeof(struct usb_device *), GFP_KERNEL); | 1330 | GFP_KERNEL); |
1276 | hub->port_owners = kzalloc(hdev->maxchild * sizeof(struct dev_state *), | 1331 | if (!hub->ports) { |
1277 | GFP_KERNEL); | ||
1278 | if (!hdev->children || !hub->port_owners) { | ||
1279 | ret = -ENOMEM; | 1332 | ret = -ENOMEM; |
1280 | goto fail; | 1333 | goto fail; |
1281 | } | 1334 | } |
@@ -1484,6 +1537,11 @@ static int hub_configure(struct usb_hub *hub, | |||
1484 | if (hub->has_indicators && blinkenlights) | 1537 | if (hub->has_indicators && blinkenlights) |
1485 | hub->indicator [0] = INDICATOR_CYCLE; | 1538 | hub->indicator [0] = INDICATOR_CYCLE; |
1486 | 1539 | ||
1540 | for (i = 0; i < hdev->maxchild; i++) | ||
1541 | if (usb_hub_create_port_device(hub, i + 1) < 0) | ||
1542 | dev_err(hub->intfdev, | ||
1543 | "couldn't create port%d device.\n", i + 1); | ||
1544 | |||
1487 | hub_activate(hub, HUB_INIT); | 1545 | hub_activate(hub, HUB_INIT); |
1488 | return 0; | 1546 | return 0; |
1489 | 1547 | ||
@@ -1508,6 +1566,7 @@ static void hub_disconnect(struct usb_interface *intf) | |||
1508 | { | 1566 | { |
1509 | struct usb_hub *hub = usb_get_intfdata(intf); | 1567 | struct usb_hub *hub = usb_get_intfdata(intf); |
1510 | struct usb_device *hdev = interface_to_usbdev(intf); | 1568 | struct usb_device *hdev = interface_to_usbdev(intf); |
1569 | int i; | ||
1511 | 1570 | ||
1512 | /* Take the hub off the event list and don't let it be added again */ | 1571 | /* Take the hub off the event list and don't let it be added again */ |
1513 | spin_lock_irq(&hub_event_lock); | 1572 | spin_lock_irq(&hub_event_lock); |
@@ -1523,14 +1582,16 @@ static void hub_disconnect(struct usb_interface *intf) | |||
1523 | hub_quiesce(hub, HUB_DISCONNECT); | 1582 | hub_quiesce(hub, HUB_DISCONNECT); |
1524 | 1583 | ||
1525 | usb_set_intfdata (intf, NULL); | 1584 | usb_set_intfdata (intf, NULL); |
1585 | |||
1586 | for (i = 0; i < hdev->maxchild; i++) | ||
1587 | usb_hub_remove_port_device(hub, i + 1); | ||
1526 | hub->hdev->maxchild = 0; | 1588 | hub->hdev->maxchild = 0; |
1527 | 1589 | ||
1528 | if (hub->hdev->speed == USB_SPEED_HIGH) | 1590 | if (hub->hdev->speed == USB_SPEED_HIGH) |
1529 | highspeed_hubs--; | 1591 | highspeed_hubs--; |
1530 | 1592 | ||
1531 | usb_free_urb(hub->urb); | 1593 | usb_free_urb(hub->urb); |
1532 | kfree(hdev->children); | 1594 | kfree(hub->ports); |
1533 | kfree(hub->port_owners); | ||
1534 | kfree(hub->descriptor); | 1595 | kfree(hub->descriptor); |
1535 | kfree(hub->status); | 1596 | kfree(hub->status); |
1536 | kfree(hub->buffer); | 1597 | kfree(hub->buffer); |
@@ -1617,6 +1678,7 @@ static int | |||
1617 | hub_ioctl(struct usb_interface *intf, unsigned int code, void *user_data) | 1678 | hub_ioctl(struct usb_interface *intf, unsigned int code, void *user_data) |
1618 | { | 1679 | { |
1619 | struct usb_device *hdev = interface_to_usbdev (intf); | 1680 | struct usb_device *hdev = interface_to_usbdev (intf); |
1681 | struct usb_hub *hub = hdev_to_hub(hdev); | ||
1620 | 1682 | ||
1621 | /* assert ifno == 0 (part of hub spec) */ | 1683 | /* assert ifno == 0 (part of hub spec) */ |
1622 | switch (code) { | 1684 | switch (code) { |
@@ -1630,11 +1692,11 @@ hub_ioctl(struct usb_interface *intf, unsigned int code, void *user_data) | |||
1630 | else { | 1692 | else { |
1631 | info->nports = hdev->maxchild; | 1693 | info->nports = hdev->maxchild; |
1632 | for (i = 0; i < info->nports; i++) { | 1694 | for (i = 0; i < info->nports; i++) { |
1633 | if (hdev->children[i] == NULL) | 1695 | if (hub->ports[i]->child == NULL) |
1634 | info->port[i] = 0; | 1696 | info->port[i] = 0; |
1635 | else | 1697 | else |
1636 | info->port[i] = | 1698 | info->port[i] = |
1637 | hdev->children[i]->devnum; | 1699 | hub->ports[i]->child->devnum; |
1638 | } | 1700 | } |
1639 | } | 1701 | } |
1640 | spin_unlock_irq(&device_state_lock); | 1702 | spin_unlock_irq(&device_state_lock); |
@@ -1662,7 +1724,7 @@ static int find_port_owner(struct usb_device *hdev, unsigned port1, | |||
1662 | /* This assumes that devices not managed by the hub driver | 1724 | /* This assumes that devices not managed by the hub driver |
1663 | * will always have maxchild equal to 0. | 1725 | * will always have maxchild equal to 0. |
1664 | */ | 1726 | */ |
1665 | *ppowner = &(hdev_to_hub(hdev)->port_owners[port1 - 1]); | 1727 | *ppowner = &(hdev_to_hub(hdev)->ports[port1 - 1]->port_owner); |
1666 | return 0; | 1728 | return 0; |
1667 | } | 1729 | } |
1668 | 1730 | ||
@@ -1699,16 +1761,14 @@ int usb_hub_release_port(struct usb_device *hdev, unsigned port1, | |||
1699 | 1761 | ||
1700 | void usb_hub_release_all_ports(struct usb_device *hdev, struct dev_state *owner) | 1762 | void usb_hub_release_all_ports(struct usb_device *hdev, struct dev_state *owner) |
1701 | { | 1763 | { |
1764 | struct usb_hub *hub = hdev_to_hub(hdev); | ||
1702 | int n; | 1765 | int n; |
1703 | struct dev_state **powner; | ||
1704 | 1766 | ||
1705 | n = find_port_owner(hdev, 1, &powner); | 1767 | for (n = 0; n < hdev->maxchild; n++) { |
1706 | if (n == 0) { | 1768 | if (hub->ports[n]->port_owner == owner) |
1707 | for (; n < hdev->maxchild; (++n, ++powner)) { | 1769 | hub->ports[n]->port_owner = NULL; |
1708 | if (*powner == owner) | ||
1709 | *powner = NULL; | ||
1710 | } | ||
1711 | } | 1770 | } |
1771 | |||
1712 | } | 1772 | } |
1713 | 1773 | ||
1714 | /* The caller must hold udev's lock */ | 1774 | /* The caller must hold udev's lock */ |
@@ -1719,17 +1779,17 @@ bool usb_device_is_owned(struct usb_device *udev) | |||
1719 | if (udev->state == USB_STATE_NOTATTACHED || !udev->parent) | 1779 | if (udev->state == USB_STATE_NOTATTACHED || !udev->parent) |
1720 | return false; | 1780 | return false; |
1721 | hub = hdev_to_hub(udev->parent); | 1781 | hub = hdev_to_hub(udev->parent); |
1722 | return !!hub->port_owners[udev->portnum - 1]; | 1782 | return !!hub->ports[udev->portnum - 1]->port_owner; |
1723 | } | 1783 | } |
1724 | 1784 | ||
1725 | |||
1726 | static void recursively_mark_NOTATTACHED(struct usb_device *udev) | 1785 | static void recursively_mark_NOTATTACHED(struct usb_device *udev) |
1727 | { | 1786 | { |
1787 | struct usb_hub *hub = hdev_to_hub(udev); | ||
1728 | int i; | 1788 | int i; |
1729 | 1789 | ||
1730 | for (i = 0; i < udev->maxchild; ++i) { | 1790 | for (i = 0; i < udev->maxchild; ++i) { |
1731 | if (udev->children[i]) | 1791 | if (hub->ports[i]->child) |
1732 | recursively_mark_NOTATTACHED(udev->children[i]); | 1792 | recursively_mark_NOTATTACHED(hub->ports[i]->child); |
1733 | } | 1793 | } |
1734 | if (udev->state == USB_STATE_SUSPENDED) | 1794 | if (udev->state == USB_STATE_SUSPENDED) |
1735 | udev->active_duration -= jiffies; | 1795 | udev->active_duration -= jiffies; |
@@ -1893,6 +1953,7 @@ static void hub_free_dev(struct usb_device *udev) | |||
1893 | void usb_disconnect(struct usb_device **pdev) | 1953 | void usb_disconnect(struct usb_device **pdev) |
1894 | { | 1954 | { |
1895 | struct usb_device *udev = *pdev; | 1955 | struct usb_device *udev = *pdev; |
1956 | struct usb_hub *hub = hdev_to_hub(udev); | ||
1896 | int i; | 1957 | int i; |
1897 | 1958 | ||
1898 | /* mark the device as inactive, so any further urb submissions for | 1959 | /* mark the device as inactive, so any further urb submissions for |
@@ -1907,8 +1968,8 @@ void usb_disconnect(struct usb_device **pdev) | |||
1907 | 1968 | ||
1908 | /* Free up all the children before we remove this device */ | 1969 | /* Free up all the children before we remove this device */ |
1909 | for (i = 0; i < udev->maxchild; i++) { | 1970 | for (i = 0; i < udev->maxchild; i++) { |
1910 | if (udev->children[i]) | 1971 | if (hub->ports[i]->child) |
1911 | usb_disconnect(&udev->children[i]); | 1972 | usb_disconnect(&hub->ports[i]->child); |
1912 | } | 1973 | } |
1913 | 1974 | ||
1914 | /* deallocate hcd/hardware state ... nuking all pending urbs and | 1975 | /* deallocate hcd/hardware state ... nuking all pending urbs and |
@@ -2113,7 +2174,8 @@ static void set_usb_port_removable(struct usb_device *udev) | |||
2113 | return; | 2174 | return; |
2114 | 2175 | ||
2115 | if (hub_is_superspeed(hdev)) { | 2176 | if (hub_is_superspeed(hdev)) { |
2116 | if (hub->descriptor->u.ss.DeviceRemovable & (1 << port)) | 2177 | if (le16_to_cpu(hub->descriptor->u.ss.DeviceRemovable) |
2178 | & (1 << port)) | ||
2117 | removable = false; | 2179 | removable = false; |
2118 | } else { | 2180 | } else { |
2119 | if (hub->descriptor->u.hs.DeviceRemovable[port / 8] & (1 << (port % 8))) | 2181 | if (hub->descriptor->u.hs.DeviceRemovable[port / 8] & (1 << (port % 8))) |
@@ -3072,7 +3134,7 @@ static int hub_suspend(struct usb_interface *intf, pm_message_t msg) | |||
3072 | for (port1 = 1; port1 <= hdev->maxchild; port1++) { | 3134 | for (port1 = 1; port1 <= hdev->maxchild; port1++) { |
3073 | struct usb_device *udev; | 3135 | struct usb_device *udev; |
3074 | 3136 | ||
3075 | udev = hdev->children [port1-1]; | 3137 | udev = hub->ports[port1 - 1]->child; |
3076 | if (udev && udev->can_submit) { | 3138 | if (udev && udev->can_submit) { |
3077 | dev_warn(&intf->dev, "port %d nyet suspended\n", port1); | 3139 | dev_warn(&intf->dev, "port %d nyet suspended\n", port1); |
3078 | if (PMSG_IS_AUTO(msg)) | 3140 | if (PMSG_IS_AUTO(msg)) |
@@ -3999,7 +4061,7 @@ hub_power_remaining (struct usb_hub *hub) | |||
3999 | 4061 | ||
4000 | remaining = hdev->bus_mA - hub->descriptor->bHubContrCurrent; | 4062 | remaining = hdev->bus_mA - hub->descriptor->bHubContrCurrent; |
4001 | for (port1 = 1; port1 <= hdev->maxchild; ++port1) { | 4063 | for (port1 = 1; port1 <= hdev->maxchild; ++port1) { |
4002 | struct usb_device *udev = hdev->children[port1 - 1]; | 4064 | struct usb_device *udev = hub->ports[port1 - 1]->child; |
4003 | int delta; | 4065 | int delta; |
4004 | 4066 | ||
4005 | if (!udev) | 4067 | if (!udev) |
@@ -4063,7 +4125,7 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1, | |||
4063 | #endif | 4125 | #endif |
4064 | 4126 | ||
4065 | /* Try to resuscitate an existing device */ | 4127 | /* Try to resuscitate an existing device */ |
4066 | udev = hdev->children[port1-1]; | 4128 | udev = hub->ports[port1 - 1]->child; |
4067 | if ((portstatus & USB_PORT_STAT_CONNECTION) && udev && | 4129 | if ((portstatus & USB_PORT_STAT_CONNECTION) && udev && |
4068 | udev->state != USB_STATE_NOTATTACHED) { | 4130 | udev->state != USB_STATE_NOTATTACHED) { |
4069 | usb_lock_device(udev); | 4131 | usb_lock_device(udev); |
@@ -4092,7 +4154,7 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1, | |||
4092 | 4154 | ||
4093 | /* Disconnect any existing devices under this port */ | 4155 | /* Disconnect any existing devices under this port */ |
4094 | if (udev) | 4156 | if (udev) |
4095 | usb_disconnect(&hdev->children[port1-1]); | 4157 | usb_disconnect(&hub->ports[port1 - 1]->child); |
4096 | clear_bit(port1, hub->change_bits); | 4158 | clear_bit(port1, hub->change_bits); |
4097 | 4159 | ||
4098 | /* We can forget about a "removed" device when there's a physical | 4160 | /* We can forget about a "removed" device when there's a physical |
@@ -4228,7 +4290,7 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1, | |||
4228 | if (hdev->state == USB_STATE_NOTATTACHED) | 4290 | if (hdev->state == USB_STATE_NOTATTACHED) |
4229 | status = -ENOTCONN; | 4291 | status = -ENOTCONN; |
4230 | else | 4292 | else |
4231 | hdev->children[port1-1] = udev; | 4293 | hub->ports[port1 - 1]->child = udev; |
4232 | spin_unlock_irq(&device_state_lock); | 4294 | spin_unlock_irq(&device_state_lock); |
4233 | 4295 | ||
4234 | /* Run it through the hoops (find a driver, etc) */ | 4296 | /* Run it through the hoops (find a driver, etc) */ |
@@ -4236,7 +4298,7 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1, | |||
4236 | status = usb_new_device(udev); | 4298 | status = usb_new_device(udev); |
4237 | if (status) { | 4299 | if (status) { |
4238 | spin_lock_irq(&device_state_lock); | 4300 | spin_lock_irq(&device_state_lock); |
4239 | hdev->children[port1-1] = NULL; | 4301 | hub->ports[port1 - 1]->child = NULL; |
4240 | spin_unlock_irq(&device_state_lock); | 4302 | spin_unlock_irq(&device_state_lock); |
4241 | } | 4303 | } |
4242 | } | 4304 | } |
@@ -4282,7 +4344,7 @@ static int hub_handle_remote_wakeup(struct usb_hub *hub, unsigned int port, | |||
4282 | int ret; | 4344 | int ret; |
4283 | 4345 | ||
4284 | hdev = hub->hdev; | 4346 | hdev = hub->hdev; |
4285 | udev = hdev->children[port-1]; | 4347 | udev = hub->ports[port - 1]->child; |
4286 | if (!hub_is_superspeed(hdev)) { | 4348 | if (!hub_is_superspeed(hdev)) { |
4287 | if (!(portchange & USB_PORT_STAT_C_SUSPEND)) | 4349 | if (!(portchange & USB_PORT_STAT_C_SUSPEND)) |
4288 | return 0; | 4350 | return 0; |
@@ -4436,7 +4498,7 @@ static void hub_events(void) | |||
4436 | */ | 4498 | */ |
4437 | if (!(portstatus & USB_PORT_STAT_ENABLE) | 4499 | if (!(portstatus & USB_PORT_STAT_ENABLE) |
4438 | && !connect_change | 4500 | && !connect_change |
4439 | && hdev->children[i-1]) { | 4501 | && hub->ports[i - 1]->child) { |
4440 | dev_err (hub_dev, | 4502 | dev_err (hub_dev, |
4441 | "port %i " | 4503 | "port %i " |
4442 | "disabled by hub (EMI?), " | 4504 | "disabled by hub (EMI?), " |
@@ -4993,3 +5055,75 @@ void usb_queue_reset_device(struct usb_interface *iface) | |||
4993 | schedule_work(&iface->reset_ws); | 5055 | schedule_work(&iface->reset_ws); |
4994 | } | 5056 | } |
4995 | EXPORT_SYMBOL_GPL(usb_queue_reset_device); | 5057 | EXPORT_SYMBOL_GPL(usb_queue_reset_device); |
5058 | |||
5059 | /** | ||
5060 | * usb_hub_find_child - Get the pointer of child device | ||
5061 | * attached to the port which is specified by @port1. | ||
5062 | * @hdev: USB device belonging to the usb hub | ||
5063 | * @port1: port num to indicate which port the child device | ||
5064 | * is attached to. | ||
5065 | * | ||
5066 | * USB drivers call this function to get hub's child device | ||
5067 | * pointer. | ||
5068 | * | ||
5069 | * Return NULL if input param is invalid and | ||
5070 | * child's usb_device pointer if non-NULL. | ||
5071 | */ | ||
5072 | struct usb_device *usb_hub_find_child(struct usb_device *hdev, | ||
5073 | int port1) | ||
5074 | { | ||
5075 | struct usb_hub *hub = hdev_to_hub(hdev); | ||
5076 | |||
5077 | if (port1 < 1 || port1 > hdev->maxchild) | ||
5078 | return NULL; | ||
5079 | return hub->ports[port1 - 1]->child; | ||
5080 | } | ||
5081 | EXPORT_SYMBOL_GPL(usb_hub_find_child); | ||
5082 | |||
5083 | /** | ||
5084 | * usb_set_hub_port_connect_type - set hub port connect type. | ||
5085 | * @hdev: USB device belonging to the usb hub | ||
5086 | * @port1: port num of the port | ||
5087 | * @type: connect type of the port | ||
5088 | */ | ||
5089 | void usb_set_hub_port_connect_type(struct usb_device *hdev, int port1, | ||
5090 | enum usb_port_connect_type type) | ||
5091 | { | ||
5092 | struct usb_hub *hub = hdev_to_hub(hdev); | ||
5093 | |||
5094 | hub->ports[port1 - 1]->connect_type = type; | ||
5095 | } | ||
5096 | |||
5097 | /** | ||
5098 | * usb_get_hub_port_connect_type - Get the port's connect type | ||
5099 | * @hdev: USB device belonging to the usb hub | ||
5100 | * @port1: port num of the port | ||
5101 | * | ||
5102 | * Return connect type of the port and if input params are | ||
5103 | * invalid, return USB_PORT_CONNECT_TYPE_UNKNOWN. | ||
5104 | */ | ||
5105 | enum usb_port_connect_type | ||
5106 | usb_get_hub_port_connect_type(struct usb_device *hdev, int port1) | ||
5107 | { | ||
5108 | struct usb_hub *hub = hdev_to_hub(hdev); | ||
5109 | |||
5110 | return hub->ports[port1 - 1]->connect_type; | ||
5111 | } | ||
5112 | |||
5113 | #ifdef CONFIG_ACPI | ||
5114 | /** | ||
5115 | * usb_get_hub_port_acpi_handle - Get the usb port's acpi handle | ||
5116 | * @hdev: USB device belonging to the usb hub | ||
5117 | * @port1: port num of the port | ||
5118 | * | ||
5119 | * Return port's acpi handle if successful, NULL if params are | ||
5120 | * invaild. | ||
5121 | */ | ||
5122 | acpi_handle usb_get_hub_port_acpi_handle(struct usb_device *hdev, | ||
5123 | int port1) | ||
5124 | { | ||
5125 | struct usb_hub *hub = hdev_to_hub(hdev); | ||
5126 | |||
5127 | return DEVICE_ACPI_HANDLE(&hub->ports[port1 - 1]->dev); | ||
5128 | } | ||
5129 | #endif | ||
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index 0ab7da2283e3..1ed5afd91e6d 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c | |||
@@ -146,8 +146,6 @@ int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request, | |||
146 | dr->wIndex = cpu_to_le16(index); | 146 | dr->wIndex = cpu_to_le16(index); |
147 | dr->wLength = cpu_to_le16(size); | 147 | dr->wLength = cpu_to_le16(size); |
148 | 148 | ||
149 | /* dbg("usb_control_msg"); */ | ||
150 | |||
151 | ret = usb_internal_control_msg(dev, pipe, dr, data, size, timeout); | 149 | ret = usb_internal_control_msg(dev, pipe, dr, data, size, timeout); |
152 | 150 | ||
153 | kfree(dr); | 151 | kfree(dr); |
diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c index e77a8e8eaa23..fdefd9c7f7af 100644 --- a/drivers/usb/core/quirks.c +++ b/drivers/usb/core/quirks.c | |||
@@ -209,7 +209,7 @@ void usb_detect_quirks(struct usb_device *udev) | |||
209 | * for all devices. It will affect things like hub resets | 209 | * for all devices. It will affect things like hub resets |
210 | * and EMF-related port disables. | 210 | * and EMF-related port disables. |
211 | */ | 211 | */ |
212 | if (!(udev->quirks & USB_QUIRK_RESET_MORPHS)) | 212 | if (!(udev->quirks & USB_QUIRK_RESET)) |
213 | udev->persist_enabled = 1; | 213 | udev->persist_enabled = 1; |
214 | #endif /* CONFIG_PM */ | 214 | #endif /* CONFIG_PM */ |
215 | } | 215 | } |
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c index 682e8256b95d..818e4a024d0d 100644 --- a/drivers/usb/core/sysfs.c +++ b/drivers/usb/core/sysfs.c | |||
@@ -196,7 +196,7 @@ show_avoid_reset_quirk(struct device *dev, struct device_attribute *attr, char * | |||
196 | struct usb_device *udev; | 196 | struct usb_device *udev; |
197 | 197 | ||
198 | udev = to_usb_device(dev); | 198 | udev = to_usb_device(dev); |
199 | return sprintf(buf, "%d\n", !!(udev->quirks & USB_QUIRK_RESET_MORPHS)); | 199 | return sprintf(buf, "%d\n", !!(udev->quirks & USB_QUIRK_RESET)); |
200 | } | 200 | } |
201 | 201 | ||
202 | static ssize_t | 202 | static ssize_t |
@@ -204,15 +204,15 @@ set_avoid_reset_quirk(struct device *dev, struct device_attribute *attr, | |||
204 | const char *buf, size_t count) | 204 | const char *buf, size_t count) |
205 | { | 205 | { |
206 | struct usb_device *udev = to_usb_device(dev); | 206 | struct usb_device *udev = to_usb_device(dev); |
207 | int config; | 207 | int val; |
208 | 208 | ||
209 | if (sscanf(buf, "%d", &config) != 1 || config < 0 || config > 1) | 209 | if (sscanf(buf, "%d", &val) != 1 || val < 0 || val > 1) |
210 | return -EINVAL; | 210 | return -EINVAL; |
211 | usb_lock_device(udev); | 211 | usb_lock_device(udev); |
212 | if (config) | 212 | if (val) |
213 | udev->quirks |= USB_QUIRK_RESET_MORPHS; | 213 | udev->quirks |= USB_QUIRK_RESET; |
214 | else | 214 | else |
215 | udev->quirks &= ~USB_QUIRK_RESET_MORPHS; | 215 | udev->quirks &= ~USB_QUIRK_RESET; |
216 | usb_unlock_device(udev); | 216 | usb_unlock_device(udev); |
217 | return count; | 217 | return count; |
218 | } | 218 | } |
diff --git a/drivers/usb/core/usb-acpi.c b/drivers/usb/core/usb-acpi.c index 8947b203d5a4..0ef7d42d8abe 100644 --- a/drivers/usb/core/usb-acpi.c +++ b/drivers/usb/core/usb-acpi.c | |||
@@ -19,20 +19,91 @@ | |||
19 | 19 | ||
20 | #include "usb.h" | 20 | #include "usb.h" |
21 | 21 | ||
22 | static int usb_acpi_check_upc(struct usb_device *udev, acpi_handle handle) | 22 | /** |
23 | * usb_acpi_power_manageable - check whether usb port has | ||
24 | * acpi power resource. | ||
25 | * @hdev: USB device belonging to the usb hub | ||
26 | * @index: port index based zero | ||
27 | * | ||
28 | * Return true if the port has acpi power resource and false if no. | ||
29 | */ | ||
30 | bool usb_acpi_power_manageable(struct usb_device *hdev, int index) | ||
31 | { | ||
32 | acpi_handle port_handle; | ||
33 | int port1 = index + 1; | ||
34 | |||
35 | port_handle = usb_get_hub_port_acpi_handle(hdev, | ||
36 | port1); | ||
37 | if (port_handle) | ||
38 | return acpi_bus_power_manageable(port_handle); | ||
39 | else | ||
40 | return false; | ||
41 | } | ||
42 | EXPORT_SYMBOL_GPL(usb_acpi_power_manageable); | ||
43 | |||
44 | /** | ||
45 | * usb_acpi_set_power_state - control usb port's power via acpi power | ||
46 | * resource | ||
47 | * @hdev: USB device belonging to the usb hub | ||
48 | * @index: port index based zero | ||
49 | * @enable: power state expected to be set | ||
50 | * | ||
51 | * Notice to use usb_acpi_power_manageable() to check whether the usb port | ||
52 | * has acpi power resource before invoking this function. | ||
53 | * | ||
54 | * Returns 0 on success, else negative errno. | ||
55 | */ | ||
56 | int usb_acpi_set_power_state(struct usb_device *hdev, int index, bool enable) | ||
57 | { | ||
58 | acpi_handle port_handle; | ||
59 | unsigned char state; | ||
60 | int port1 = index + 1; | ||
61 | int error = -EINVAL; | ||
62 | |||
63 | port_handle = (acpi_handle)usb_get_hub_port_acpi_handle(hdev, | ||
64 | port1); | ||
65 | if (!port_handle) | ||
66 | return error; | ||
67 | |||
68 | if (enable) | ||
69 | state = ACPI_STATE_D0; | ||
70 | else | ||
71 | state = ACPI_STATE_D3_COLD; | ||
72 | |||
73 | error = acpi_bus_set_power(port_handle, state); | ||
74 | if (!error) | ||
75 | dev_dbg(&hdev->dev, "The power of hub port %d was set to %d\n", | ||
76 | port1, enable); | ||
77 | else | ||
78 | dev_dbg(&hdev->dev, "The power of hub port failed to be set\n"); | ||
79 | |||
80 | return error; | ||
81 | } | ||
82 | EXPORT_SYMBOL_GPL(usb_acpi_set_power_state); | ||
83 | |||
84 | static int usb_acpi_check_port_connect_type(struct usb_device *hdev, | ||
85 | acpi_handle handle, int port1) | ||
23 | { | 86 | { |
24 | acpi_status status; | 87 | acpi_status status; |
25 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; | 88 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; |
26 | union acpi_object *upc; | 89 | union acpi_object *upc; |
90 | struct acpi_pld pld; | ||
27 | int ret = 0; | 91 | int ret = 0; |
28 | 92 | ||
29 | status = acpi_evaluate_object(handle, "_UPC", NULL, &buffer); | 93 | /* |
30 | 94 | * Accoding to ACPI Spec 9.13. PLD indicates whether usb port is | |
95 | * user visible and _UPC indicates whether it is connectable. If | ||
96 | * the port was visible and connectable, it could be freely connected | ||
97 | * and disconnected with USB devices. If no visible and connectable, | ||
98 | * a usb device is directly hard-wired to the port. If no visible and | ||
99 | * no connectable, the port would be not used. | ||
100 | */ | ||
101 | status = acpi_get_physical_device_location(handle, &pld); | ||
31 | if (ACPI_FAILURE(status)) | 102 | if (ACPI_FAILURE(status)) |
32 | return -ENODEV; | 103 | return -ENODEV; |
33 | 104 | ||
105 | status = acpi_evaluate_object(handle, "_UPC", NULL, &buffer); | ||
34 | upc = buffer.pointer; | 106 | upc = buffer.pointer; |
35 | |||
36 | if (!upc || (upc->type != ACPI_TYPE_PACKAGE) | 107 | if (!upc || (upc->type != ACPI_TYPE_PACKAGE) |
37 | || upc->package.count != 4) { | 108 | || upc->package.count != 4) { |
38 | ret = -EINVAL; | 109 | ret = -EINVAL; |
@@ -40,69 +111,107 @@ static int usb_acpi_check_upc(struct usb_device *udev, acpi_handle handle) | |||
40 | } | 111 | } |
41 | 112 | ||
42 | if (upc->package.elements[0].integer.value) | 113 | if (upc->package.elements[0].integer.value) |
43 | udev->removable = USB_DEVICE_REMOVABLE; | 114 | if (pld.user_visible) |
44 | else | 115 | usb_set_hub_port_connect_type(hdev, port1, |
45 | udev->removable = USB_DEVICE_FIXED; | 116 | USB_PORT_CONNECT_TYPE_HOT_PLUG); |
117 | else | ||
118 | usb_set_hub_port_connect_type(hdev, port1, | ||
119 | USB_PORT_CONNECT_TYPE_HARD_WIRED); | ||
120 | else if (!pld.user_visible) | ||
121 | usb_set_hub_port_connect_type(hdev, port1, USB_PORT_NOT_USED); | ||
46 | 122 | ||
47 | out: | 123 | out: |
48 | kfree(upc); | 124 | kfree(upc); |
49 | return ret; | 125 | return ret; |
50 | } | 126 | } |
51 | 127 | ||
52 | static int usb_acpi_check_pld(struct usb_device *udev, acpi_handle handle) | ||
53 | { | ||
54 | acpi_status status; | ||
55 | struct acpi_pld pld; | ||
56 | |||
57 | status = acpi_get_physical_device_location(handle, &pld); | ||
58 | |||
59 | if (ACPI_FAILURE(status)) | ||
60 | return -ENODEV; | ||
61 | |||
62 | if (pld.user_visible) | ||
63 | udev->removable = USB_DEVICE_REMOVABLE; | ||
64 | else | ||
65 | udev->removable = USB_DEVICE_FIXED; | ||
66 | |||
67 | return 0; | ||
68 | } | ||
69 | |||
70 | static int usb_acpi_find_device(struct device *dev, acpi_handle *handle) | 128 | static int usb_acpi_find_device(struct device *dev, acpi_handle *handle) |
71 | { | 129 | { |
72 | struct usb_device *udev; | 130 | struct usb_device *udev; |
73 | struct device *parent; | ||
74 | acpi_handle *parent_handle; | 131 | acpi_handle *parent_handle; |
75 | 132 | int port_num; | |
76 | if (!is_usb_device(dev)) | ||
77 | return -ENODEV; | ||
78 | |||
79 | udev = to_usb_device(dev); | ||
80 | parent = dev->parent; | ||
81 | parent_handle = DEVICE_ACPI_HANDLE(parent); | ||
82 | |||
83 | if (!parent_handle) | ||
84 | return -ENODEV; | ||
85 | |||
86 | *handle = acpi_get_child(parent_handle, udev->portnum); | ||
87 | |||
88 | if (!*handle) | ||
89 | return -ENODEV; | ||
90 | 133 | ||
91 | /* | 134 | /* |
92 | * PLD will tell us whether a port is removable to the user or | 135 | * In the ACPI DSDT table, only usb root hub and usb ports are |
93 | * not. If we don't get an answer from PLD (it's not present | 136 | * acpi device nodes. The hierarchy like following. |
94 | * or it's malformed) then try to infer it from UPC. If a | 137 | * Device (EHC1) |
95 | * device isn't connectable then it's probably not removable. | 138 | * Device (HUBN) |
139 | * Device (PR01) | ||
140 | * Device (PR11) | ||
141 | * Device (PR12) | ||
142 | * Device (PR13) | ||
143 | * ... | ||
144 | * So all binding process is divided into two parts. binding | ||
145 | * root hub and usb ports. | ||
96 | */ | 146 | */ |
97 | if (usb_acpi_check_pld(udev, *handle) != 0) | 147 | if (is_usb_device(dev)) { |
98 | usb_acpi_check_upc(udev, *handle); | 148 | udev = to_usb_device(dev); |
149 | if (udev->parent) { | ||
150 | enum usb_port_connect_type type; | ||
151 | |||
152 | /* | ||
153 | * According usb port's connect type to set usb device's | ||
154 | * removability. | ||
155 | */ | ||
156 | type = usb_get_hub_port_connect_type(udev->parent, | ||
157 | udev->portnum); | ||
158 | switch (type) { | ||
159 | case USB_PORT_CONNECT_TYPE_HOT_PLUG: | ||
160 | udev->removable = USB_DEVICE_REMOVABLE; | ||
161 | break; | ||
162 | case USB_PORT_CONNECT_TYPE_HARD_WIRED: | ||
163 | udev->removable = USB_DEVICE_FIXED; | ||
164 | break; | ||
165 | default: | ||
166 | udev->removable = USB_DEVICE_REMOVABLE_UNKNOWN; | ||
167 | break; | ||
168 | } | ||
169 | |||
170 | return -ENODEV; | ||
171 | } | ||
172 | |||
173 | /* root hub's parent is the usb hcd. */ | ||
174 | parent_handle = DEVICE_ACPI_HANDLE(dev->parent); | ||
175 | *handle = acpi_get_child(parent_handle, udev->portnum); | ||
176 | if (!*handle) | ||
177 | return -ENODEV; | ||
178 | return 0; | ||
179 | } else if (is_usb_port(dev)) { | ||
180 | sscanf(dev_name(dev), "port%d", &port_num); | ||
181 | /* Get the struct usb_device point of port's hub */ | ||
182 | udev = to_usb_device(dev->parent->parent); | ||
183 | |||
184 | /* | ||
185 | * The root hub ports' parent is the root hub. The non-root-hub | ||
186 | * ports' parent is the parent hub port which the hub is | ||
187 | * connected to. | ||
188 | */ | ||
189 | if (!udev->parent) { | ||
190 | *handle = acpi_get_child(DEVICE_ACPI_HANDLE(&udev->dev), | ||
191 | port_num); | ||
192 | if (!*handle) | ||
193 | return -ENODEV; | ||
194 | } else { | ||
195 | parent_handle = | ||
196 | usb_get_hub_port_acpi_handle(udev->parent, | ||
197 | udev->portnum); | ||
198 | if (!parent_handle) | ||
199 | return -ENODEV; | ||
200 | |||
201 | *handle = acpi_get_child(parent_handle, port_num); | ||
202 | if (!*handle) | ||
203 | return -ENODEV; | ||
204 | } | ||
205 | usb_acpi_check_port_connect_type(udev, *handle, port_num); | ||
206 | } else | ||
207 | return -ENODEV; | ||
99 | 208 | ||
100 | return 0; | 209 | return 0; |
101 | } | 210 | } |
102 | 211 | ||
103 | static struct acpi_bus_type usb_acpi_bus = { | 212 | static struct acpi_bus_type usb_acpi_bus = { |
104 | .bus = &usb_bus_type, | 213 | .bus = &usb_bus_type, |
105 | .find_bridge = NULL, | 214 | .find_bridge = usb_acpi_find_device, |
106 | .find_device = usb_acpi_find_device, | 215 | .find_device = usb_acpi_find_device, |
107 | }; | 216 | }; |
108 | 217 | ||
diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h index acb103c5c391..1c528c1bf0be 100644 --- a/drivers/usb/core/usb.h +++ b/drivers/usb/core/usb.h | |||
@@ -1,4 +1,5 @@ | |||
1 | #include <linux/pm.h> | 1 | #include <linux/pm.h> |
2 | #include <linux/acpi.h> | ||
2 | 3 | ||
3 | struct dev_state; | 4 | struct dev_state; |
4 | 5 | ||
@@ -115,6 +116,7 @@ extern struct bus_type usb_bus_type; | |||
115 | extern struct device_type usb_device_type; | 116 | extern struct device_type usb_device_type; |
116 | extern struct device_type usb_if_device_type; | 117 | extern struct device_type usb_if_device_type; |
117 | extern struct device_type usb_ep_device_type; | 118 | extern struct device_type usb_ep_device_type; |
119 | extern struct device_type usb_port_device_type; | ||
118 | extern struct usb_device_driver usb_generic_driver; | 120 | extern struct usb_device_driver usb_generic_driver; |
119 | 121 | ||
120 | static inline int is_usb_device(const struct device *dev) | 122 | static inline int is_usb_device(const struct device *dev) |
@@ -132,6 +134,11 @@ static inline int is_usb_endpoint(const struct device *dev) | |||
132 | return dev->type == &usb_ep_device_type; | 134 | return dev->type == &usb_ep_device_type; |
133 | } | 135 | } |
134 | 136 | ||
137 | static inline int is_usb_port(const struct device *dev) | ||
138 | { | ||
139 | return dev->type == &usb_port_device_type; | ||
140 | } | ||
141 | |||
135 | /* Do the same for device drivers and interface drivers. */ | 142 | /* Do the same for device drivers and interface drivers. */ |
136 | 143 | ||
137 | static inline int is_usb_device_driver(struct device_driver *drv) | 144 | static inline int is_usb_device_driver(struct device_driver *drv) |
@@ -162,10 +169,16 @@ extern void usb_notify_add_device(struct usb_device *udev); | |||
162 | extern void usb_notify_remove_device(struct usb_device *udev); | 169 | extern void usb_notify_remove_device(struct usb_device *udev); |
163 | extern void usb_notify_add_bus(struct usb_bus *ubus); | 170 | extern void usb_notify_add_bus(struct usb_bus *ubus); |
164 | extern void usb_notify_remove_bus(struct usb_bus *ubus); | 171 | extern void usb_notify_remove_bus(struct usb_bus *ubus); |
172 | extern enum usb_port_connect_type | ||
173 | usb_get_hub_port_connect_type(struct usb_device *hdev, int port1); | ||
174 | extern void usb_set_hub_port_connect_type(struct usb_device *hdev, int port1, | ||
175 | enum usb_port_connect_type type); | ||
165 | 176 | ||
166 | #ifdef CONFIG_ACPI | 177 | #ifdef CONFIG_ACPI |
167 | extern int usb_acpi_register(void); | 178 | extern int usb_acpi_register(void); |
168 | extern void usb_acpi_unregister(void); | 179 | extern void usb_acpi_unregister(void); |
180 | extern acpi_handle usb_get_hub_port_acpi_handle(struct usb_device *hdev, | ||
181 | int port1); | ||
169 | #else | 182 | #else |
170 | static inline int usb_acpi_register(void) { return 0; }; | 183 | static inline int usb_acpi_register(void) { return 0; }; |
171 | static inline void usb_acpi_unregister(void) { }; | 184 | static inline void usb_acpi_unregister(void) { }; |
diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig index d13c60f42139..f6a6e070c2ac 100644 --- a/drivers/usb/dwc3/Kconfig +++ b/drivers/usb/dwc3/Kconfig | |||
@@ -2,8 +2,6 @@ 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 if USB_SUPPORT && USB_XHCI_HCD | 5 | select USB_XHCI_PLATFORM if USB_SUPPORT && USB_XHCI_HCD |
8 | help | 6 | help |
9 | Say Y or M here if your system has a Dual Role SuperSpeed | 7 | Say Y or M here if your system has a Dual Role SuperSpeed |
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index a68ff53124dc..b415c0c859d3 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c | |||
@@ -50,6 +50,7 @@ | |||
50 | #include <linux/dma-mapping.h> | 50 | #include <linux/dma-mapping.h> |
51 | #include <linux/of.h> | 51 | #include <linux/of.h> |
52 | 52 | ||
53 | #include <linux/usb/otg.h> | ||
53 | #include <linux/usb/ch9.h> | 54 | #include <linux/usb/ch9.h> |
54 | #include <linux/usb/gadget.h> | 55 | #include <linux/usb/gadget.h> |
55 | 56 | ||
@@ -99,6 +100,7 @@ void dwc3_put_device_id(int id) | |||
99 | 100 | ||
100 | ret = test_bit(id, dwc3_devs); | 101 | ret = test_bit(id, dwc3_devs); |
101 | WARN(!ret, "dwc3: ID %d not in use\n", id); | 102 | WARN(!ret, "dwc3: ID %d not in use\n", id); |
103 | smp_mb__before_clear_bit(); | ||
102 | clear_bit(id, dwc3_devs); | 104 | clear_bit(id, dwc3_devs); |
103 | } | 105 | } |
104 | EXPORT_SYMBOL_GPL(dwc3_put_device_id); | 106 | EXPORT_SYMBOL_GPL(dwc3_put_device_id); |
@@ -136,6 +138,8 @@ static void dwc3_core_soft_reset(struct dwc3 *dwc) | |||
136 | reg |= DWC3_GUSB2PHYCFG_PHYSOFTRST; | 138 | reg |= DWC3_GUSB2PHYCFG_PHYSOFTRST; |
137 | dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg); | 139 | dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg); |
138 | 140 | ||
141 | usb_phy_init(dwc->usb2_phy); | ||
142 | usb_phy_init(dwc->usb3_phy); | ||
139 | mdelay(100); | 143 | mdelay(100); |
140 | 144 | ||
141 | /* Clear USB3 PHY reset */ | 145 | /* Clear USB3 PHY reset */ |
@@ -464,12 +468,24 @@ static int __devinit dwc3_probe(struct platform_device *pdev) | |||
464 | return -ENOMEM; | 468 | return -ENOMEM; |
465 | } | 469 | } |
466 | 470 | ||
467 | regs = devm_ioremap(dev, res->start, resource_size(res)); | 471 | regs = devm_ioremap_nocache(dev, res->start, resource_size(res)); |
468 | if (!regs) { | 472 | if (!regs) { |
469 | dev_err(dev, "ioremap failed\n"); | 473 | dev_err(dev, "ioremap failed\n"); |
470 | return -ENOMEM; | 474 | return -ENOMEM; |
471 | } | 475 | } |
472 | 476 | ||
477 | dwc->usb2_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2); | ||
478 | if (IS_ERR_OR_NULL(dwc->usb2_phy)) { | ||
479 | dev_err(dev, "no usb2 phy configured\n"); | ||
480 | return -EPROBE_DEFER; | ||
481 | } | ||
482 | |||
483 | dwc->usb3_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB3); | ||
484 | if (IS_ERR_OR_NULL(dwc->usb3_phy)) { | ||
485 | dev_err(dev, "no usb3 phy configured\n"); | ||
486 | return -EPROBE_DEFER; | ||
487 | } | ||
488 | |||
473 | spin_lock_init(&dwc->lock); | 489 | spin_lock_init(&dwc->lock); |
474 | platform_set_drvdata(pdev, dwc); | 490 | platform_set_drvdata(pdev, dwc); |
475 | 491 | ||
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 151eca876dfd..243affc93431 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h | |||
@@ -457,7 +457,6 @@ enum dwc3_phy { | |||
457 | enum dwc3_ep0_next { | 457 | enum dwc3_ep0_next { |
458 | DWC3_EP0_UNKNOWN = 0, | 458 | DWC3_EP0_UNKNOWN = 0, |
459 | DWC3_EP0_COMPLETE, | 459 | DWC3_EP0_COMPLETE, |
460 | DWC3_EP0_NRDY_SETUP, | ||
461 | DWC3_EP0_NRDY_DATA, | 460 | DWC3_EP0_NRDY_DATA, |
462 | DWC3_EP0_NRDY_STATUS, | 461 | DWC3_EP0_NRDY_STATUS, |
463 | }; | 462 | }; |
@@ -624,6 +623,8 @@ struct dwc3_scratchpad_array { | |||
624 | * @maximum_speed: maximum speed requested (mainly for testing purposes) | 623 | * @maximum_speed: maximum speed requested (mainly for testing purposes) |
625 | * @revision: revision register contents | 624 | * @revision: revision register contents |
626 | * @mode: mode of operation | 625 | * @mode: mode of operation |
626 | * @usb2_phy: pointer to USB2 PHY | ||
627 | * @usb3_phy: pointer to USB3 PHY | ||
627 | * @is_selfpowered: true when we are selfpowered | 628 | * @is_selfpowered: true when we are selfpowered |
628 | * @three_stage_setup: set if we perform a three phase setup | 629 | * @three_stage_setup: set if we perform a three phase setup |
629 | * @ep0_bounced: true when we used bounce buffer | 630 | * @ep0_bounced: true when we used bounce buffer |
@@ -667,6 +668,9 @@ struct dwc3 { | |||
667 | struct usb_gadget gadget; | 668 | struct usb_gadget gadget; |
668 | struct usb_gadget_driver *gadget_driver; | 669 | struct usb_gadget_driver *gadget_driver; |
669 | 670 | ||
671 | struct usb_phy *usb2_phy; | ||
672 | struct usb_phy *usb3_phy; | ||
673 | |||
670 | void __iomem *regs; | 674 | void __iomem *regs; |
671 | size_t regs_size; | 675 | size_t regs_size; |
672 | 676 | ||
@@ -779,7 +783,6 @@ struct dwc3_event_depevt { | |||
779 | #define DEPEVT_STREAMEVT_NOTFOUND 2 | 783 | #define DEPEVT_STREAMEVT_NOTFOUND 2 |
780 | 784 | ||
781 | /* Control-only Status */ | 785 | /* Control-only Status */ |
782 | #define DEPEVT_STATUS_CONTROL_SETUP 0 | ||
783 | #define DEPEVT_STATUS_CONTROL_DATA 1 | 786 | #define DEPEVT_STATUS_CONTROL_DATA 1 |
784 | #define DEPEVT_STATUS_CONTROL_STATUS 2 | 787 | #define DEPEVT_STATUS_CONTROL_STATUS 2 |
785 | 788 | ||
diff --git a/drivers/usb/dwc3/dwc3-exynos.c b/drivers/usb/dwc3/dwc3-exynos.c index b8f00389fa34..ca6597853f90 100644 --- a/drivers/usb/dwc3/dwc3-exynos.c +++ b/drivers/usb/dwc3/dwc3-exynos.c | |||
@@ -19,16 +19,74 @@ | |||
19 | #include <linux/platform_data/dwc3-exynos.h> | 19 | #include <linux/platform_data/dwc3-exynos.h> |
20 | #include <linux/dma-mapping.h> | 20 | #include <linux/dma-mapping.h> |
21 | #include <linux/clk.h> | 21 | #include <linux/clk.h> |
22 | #include <linux/usb/otg.h> | ||
23 | #include <linux/usb/nop-usb-xceiv.h> | ||
22 | 24 | ||
23 | #include "core.h" | 25 | #include "core.h" |
24 | 26 | ||
25 | struct dwc3_exynos { | 27 | struct dwc3_exynos { |
26 | struct platform_device *dwc3; | 28 | struct platform_device *dwc3; |
29 | struct platform_device *usb2_phy; | ||
30 | struct platform_device *usb3_phy; | ||
27 | struct device *dev; | 31 | struct device *dev; |
28 | 32 | ||
29 | struct clk *clk; | 33 | struct clk *clk; |
30 | }; | 34 | }; |
31 | 35 | ||
36 | static int __devinit dwc3_exynos_register_phys(struct dwc3_exynos *exynos) | ||
37 | { | ||
38 | struct nop_usb_xceiv_platform_data pdata; | ||
39 | struct platform_device *pdev; | ||
40 | int ret; | ||
41 | |||
42 | memset(&pdata, 0x00, sizeof(pdata)); | ||
43 | |||
44 | pdev = platform_device_alloc("nop_usb_xceiv", 0); | ||
45 | if (!pdev) | ||
46 | return -ENOMEM; | ||
47 | |||
48 | exynos->usb2_phy = pdev; | ||
49 | pdata.type = USB_PHY_TYPE_USB2; | ||
50 | |||
51 | ret = platform_device_add_data(exynos->usb2_phy, &pdata, sizeof(pdata)); | ||
52 | if (ret) | ||
53 | goto err1; | ||
54 | |||
55 | pdev = platform_device_alloc("nop_usb_xceiv", 1); | ||
56 | if (!pdev) { | ||
57 | ret = -ENOMEM; | ||
58 | goto err1; | ||
59 | } | ||
60 | |||
61 | exynos->usb3_phy = pdev; | ||
62 | pdata.type = USB_PHY_TYPE_USB3; | ||
63 | |||
64 | ret = platform_device_add_data(exynos->usb3_phy, &pdata, sizeof(pdata)); | ||
65 | if (ret) | ||
66 | goto err2; | ||
67 | |||
68 | ret = platform_device_add(exynos->usb2_phy); | ||
69 | if (ret) | ||
70 | goto err2; | ||
71 | |||
72 | ret = platform_device_add(exynos->usb3_phy); | ||
73 | if (ret) | ||
74 | goto err3; | ||
75 | |||
76 | return 0; | ||
77 | |||
78 | err3: | ||
79 | platform_device_del(exynos->usb2_phy); | ||
80 | |||
81 | err2: | ||
82 | platform_device_put(exynos->usb3_phy); | ||
83 | |||
84 | err1: | ||
85 | platform_device_put(exynos->usb2_phy); | ||
86 | |||
87 | return ret; | ||
88 | } | ||
89 | |||
32 | static int __devinit dwc3_exynos_probe(struct platform_device *pdev) | 90 | static int __devinit dwc3_exynos_probe(struct platform_device *pdev) |
33 | { | 91 | { |
34 | struct dwc3_exynos_data *pdata = pdev->dev.platform_data; | 92 | struct dwc3_exynos_data *pdata = pdev->dev.platform_data; |
@@ -51,6 +109,12 @@ static int __devinit dwc3_exynos_probe(struct platform_device *pdev) | |||
51 | if (devid < 0) | 109 | if (devid < 0) |
52 | goto err1; | 110 | goto err1; |
53 | 111 | ||
112 | ret = dwc3_exynos_register_phys(exynos); | ||
113 | if (ret) { | ||
114 | dev_err(&pdev->dev, "couldn't register PHYs\n"); | ||
115 | goto err1; | ||
116 | } | ||
117 | |||
54 | dwc3 = platform_device_alloc("dwc3", devid); | 118 | dwc3 = platform_device_alloc("dwc3", devid); |
55 | if (!dwc3) { | 119 | if (!dwc3) { |
56 | dev_err(&pdev->dev, "couldn't allocate dwc3 device\n"); | 120 | dev_err(&pdev->dev, "couldn't allocate dwc3 device\n"); |
@@ -120,6 +184,8 @@ static int __devexit dwc3_exynos_remove(struct platform_device *pdev) | |||
120 | struct dwc3_exynos_data *pdata = pdev->dev.platform_data; | 184 | struct dwc3_exynos_data *pdata = pdev->dev.platform_data; |
121 | 185 | ||
122 | platform_device_unregister(exynos->dwc3); | 186 | platform_device_unregister(exynos->dwc3); |
187 | platform_device_unregister(exynos->usb2_phy); | ||
188 | platform_device_unregister(exynos->usb3_phy); | ||
123 | 189 | ||
124 | dwc3_put_device_id(exynos->dwc3->id); | 190 | dwc3_put_device_id(exynos->dwc3->id); |
125 | 191 | ||
diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c index 479dc047da3a..ee57a10d90d0 100644 --- a/drivers/usb/dwc3/dwc3-omap.c +++ b/drivers/usb/dwc3/dwc3-omap.c | |||
@@ -48,6 +48,9 @@ | |||
48 | #include <linux/io.h> | 48 | #include <linux/io.h> |
49 | #include <linux/of.h> | 49 | #include <linux/of.h> |
50 | 50 | ||
51 | #include <linux/usb/otg.h> | ||
52 | #include <linux/usb/nop-usb-xceiv.h> | ||
53 | |||
51 | #include "core.h" | 54 | #include "core.h" |
52 | 55 | ||
53 | /* | 56 | /* |
@@ -131,6 +134,8 @@ struct dwc3_omap { | |||
131 | spinlock_t lock; | 134 | spinlock_t lock; |
132 | 135 | ||
133 | struct platform_device *dwc3; | 136 | struct platform_device *dwc3; |
137 | struct platform_device *usb2_phy; | ||
138 | struct platform_device *usb3_phy; | ||
134 | struct device *dev; | 139 | struct device *dev; |
135 | 140 | ||
136 | int irq; | 141 | int irq; |
@@ -152,6 +157,59 @@ static inline void dwc3_omap_writel(void __iomem *base, u32 offset, u32 value) | |||
152 | writel(value, base + offset); | 157 | writel(value, base + offset); |
153 | } | 158 | } |
154 | 159 | ||
160 | static int __devinit dwc3_omap_register_phys(struct dwc3_omap *omap) | ||
161 | { | ||
162 | struct nop_usb_xceiv_platform_data pdata; | ||
163 | struct platform_device *pdev; | ||
164 | int ret; | ||
165 | |||
166 | memset(&pdata, 0x00, sizeof(pdata)); | ||
167 | |||
168 | pdev = platform_device_alloc("nop_usb_xceiv", 0); | ||
169 | if (!pdev) | ||
170 | return -ENOMEM; | ||
171 | |||
172 | omap->usb2_phy = pdev; | ||
173 | pdata.type = USB_PHY_TYPE_USB2; | ||
174 | |||
175 | ret = platform_device_add_data(omap->usb2_phy, &pdata, sizeof(pdata)); | ||
176 | if (ret) | ||
177 | goto err1; | ||
178 | |||
179 | pdev = platform_device_alloc("nop_usb_xceiv", 1); | ||
180 | if (!pdev) { | ||
181 | ret = -ENOMEM; | ||
182 | goto err1; | ||
183 | } | ||
184 | |||
185 | omap->usb3_phy = pdev; | ||
186 | pdata.type = USB_PHY_TYPE_USB3; | ||
187 | |||
188 | ret = platform_device_add_data(omap->usb3_phy, &pdata, sizeof(pdata)); | ||
189 | if (ret) | ||
190 | goto err2; | ||
191 | |||
192 | ret = platform_device_add(omap->usb2_phy); | ||
193 | if (ret) | ||
194 | goto err2; | ||
195 | |||
196 | ret = platform_device_add(omap->usb3_phy); | ||
197 | if (ret) | ||
198 | goto err3; | ||
199 | |||
200 | return 0; | ||
201 | |||
202 | err3: | ||
203 | platform_device_del(omap->usb2_phy); | ||
204 | |||
205 | err2: | ||
206 | platform_device_put(omap->usb3_phy); | ||
207 | |||
208 | err1: | ||
209 | platform_device_put(omap->usb2_phy); | ||
210 | |||
211 | return ret; | ||
212 | } | ||
155 | 213 | ||
156 | static irqreturn_t dwc3_omap_interrupt(int irq, void *_omap) | 214 | static irqreturn_t dwc3_omap_interrupt(int irq, void *_omap) |
157 | { | 215 | { |
@@ -251,6 +309,12 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev) | |||
251 | return -ENOMEM; | 309 | return -ENOMEM; |
252 | } | 310 | } |
253 | 311 | ||
312 | ret = dwc3_omap_register_phys(omap); | ||
313 | if (ret) { | ||
314 | dev_err(dev, "couldn't register PHYs\n"); | ||
315 | return ret; | ||
316 | } | ||
317 | |||
254 | devid = dwc3_get_device_id(); | 318 | devid = dwc3_get_device_id(); |
255 | if (devid < 0) | 319 | if (devid < 0) |
256 | return -ENODEV; | 320 | return -ENODEV; |
@@ -371,6 +435,8 @@ static int __devexit dwc3_omap_remove(struct platform_device *pdev) | |||
371 | struct dwc3_omap *omap = platform_get_drvdata(pdev); | 435 | struct dwc3_omap *omap = platform_get_drvdata(pdev); |
372 | 436 | ||
373 | platform_device_unregister(omap->dwc3); | 437 | platform_device_unregister(omap->dwc3); |
438 | platform_device_unregister(omap->usb2_phy); | ||
439 | platform_device_unregister(omap->usb3_phy); | ||
374 | 440 | ||
375 | dwc3_put_device_id(omap->dwc3->id); | 441 | dwc3_put_device_id(omap->dwc3->id); |
376 | 442 | ||
diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c index a9ca9adba391..94f550e37f98 100644 --- a/drivers/usb/dwc3/dwc3-pci.c +++ b/drivers/usb/dwc3/dwc3-pci.c | |||
@@ -42,6 +42,9 @@ | |||
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 <linux/usb/otg.h> | ||
46 | #include <linux/usb/nop-usb-xceiv.h> | ||
47 | |||
45 | #include "core.h" | 48 | #include "core.h" |
46 | 49 | ||
47 | /* FIXME define these in <linux/pci_ids.h> */ | 50 | /* FIXME define these in <linux/pci_ids.h> */ |
@@ -51,8 +54,64 @@ | |||
51 | struct dwc3_pci { | 54 | struct dwc3_pci { |
52 | struct device *dev; | 55 | struct device *dev; |
53 | struct platform_device *dwc3; | 56 | struct platform_device *dwc3; |
57 | struct platform_device *usb2_phy; | ||
58 | struct platform_device *usb3_phy; | ||
54 | }; | 59 | }; |
55 | 60 | ||
61 | static int __devinit dwc3_pci_register_phys(struct dwc3_pci *glue) | ||
62 | { | ||
63 | struct nop_usb_xceiv_platform_data pdata; | ||
64 | struct platform_device *pdev; | ||
65 | int ret; | ||
66 | |||
67 | memset(&pdata, 0x00, sizeof(pdata)); | ||
68 | |||
69 | pdev = platform_device_alloc("nop_usb_xceiv", 0); | ||
70 | if (!pdev) | ||
71 | return -ENOMEM; | ||
72 | |||
73 | glue->usb2_phy = pdev; | ||
74 | pdata.type = USB_PHY_TYPE_USB2; | ||
75 | |||
76 | ret = platform_device_add_data(glue->usb2_phy, &pdata, sizeof(pdata)); | ||
77 | if (ret) | ||
78 | goto err1; | ||
79 | |||
80 | pdev = platform_device_alloc("nop_usb_xceiv", 1); | ||
81 | if (!pdev) { | ||
82 | ret = -ENOMEM; | ||
83 | goto err1; | ||
84 | } | ||
85 | |||
86 | glue->usb3_phy = pdev; | ||
87 | pdata.type = USB_PHY_TYPE_USB3; | ||
88 | |||
89 | ret = platform_device_add_data(glue->usb3_phy, &pdata, sizeof(pdata)); | ||
90 | if (ret) | ||
91 | goto err2; | ||
92 | |||
93 | ret = platform_device_add(glue->usb2_phy); | ||
94 | if (ret) | ||
95 | goto err2; | ||
96 | |||
97 | ret = platform_device_add(glue->usb3_phy); | ||
98 | if (ret) | ||
99 | goto err3; | ||
100 | |||
101 | return 0; | ||
102 | |||
103 | err3: | ||
104 | platform_device_del(glue->usb2_phy); | ||
105 | |||
106 | err2: | ||
107 | platform_device_put(glue->usb3_phy); | ||
108 | |||
109 | err1: | ||
110 | platform_device_put(glue->usb2_phy); | ||
111 | |||
112 | return ret; | ||
113 | } | ||
114 | |||
56 | static int __devinit dwc3_pci_probe(struct pci_dev *pci, | 115 | static int __devinit dwc3_pci_probe(struct pci_dev *pci, |
57 | const struct pci_device_id *id) | 116 | const struct pci_device_id *id) |
58 | { | 117 | { |
@@ -80,6 +139,12 @@ static int __devinit dwc3_pci_probe(struct pci_dev *pci, | |||
80 | pci_set_power_state(pci, PCI_D0); | 139 | pci_set_power_state(pci, PCI_D0); |
81 | pci_set_master(pci); | 140 | pci_set_master(pci); |
82 | 141 | ||
142 | ret = dwc3_pci_register_phys(glue); | ||
143 | if (ret) { | ||
144 | dev_err(dev, "couldn't register PHYs\n"); | ||
145 | return ret; | ||
146 | } | ||
147 | |||
83 | devid = dwc3_get_device_id(); | 148 | devid = dwc3_get_device_id(); |
84 | if (devid < 0) { | 149 | if (devid < 0) { |
85 | ret = -ENOMEM; | 150 | ret = -ENOMEM; |
@@ -144,6 +209,8 @@ static void __devexit dwc3_pci_remove(struct pci_dev *pci) | |||
144 | { | 209 | { |
145 | struct dwc3_pci *glue = pci_get_drvdata(pci); | 210 | struct dwc3_pci *glue = pci_get_drvdata(pci); |
146 | 211 | ||
212 | platform_device_unregister(glue->usb2_phy); | ||
213 | platform_device_unregister(glue->usb3_phy); | ||
147 | dwc3_put_device_id(glue->dwc3->id); | 214 | dwc3_put_device_id(glue->dwc3->id); |
148 | platform_device_unregister(glue->dwc3); | 215 | platform_device_unregister(glue->dwc3); |
149 | pci_set_drvdata(pci, NULL); | 216 | pci_set_drvdata(pci, NULL); |
diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c index e4d5ca86b9da..d7da073a23fe 100644 --- a/drivers/usb/dwc3/ep0.c +++ b/drivers/usb/dwc3/ep0.c | |||
@@ -125,7 +125,6 @@ static int __dwc3_gadget_ep0_queue(struct dwc3_ep *dep, | |||
125 | struct dwc3_request *req) | 125 | struct dwc3_request *req) |
126 | { | 126 | { |
127 | struct dwc3 *dwc = dep->dwc; | 127 | struct dwc3 *dwc = dep->dwc; |
128 | int ret = 0; | ||
129 | 128 | ||
130 | req->request.actual = 0; | 129 | req->request.actual = 0; |
131 | req->request.status = -EINPROGRESS; | 130 | req->request.status = -EINPROGRESS; |
@@ -156,16 +155,72 @@ static int __dwc3_gadget_ep0_queue(struct dwc3_ep *dep, | |||
156 | 155 | ||
157 | dep->flags &= ~(DWC3_EP_PENDING_REQUEST | | 156 | dep->flags &= ~(DWC3_EP_PENDING_REQUEST | |
158 | DWC3_EP0_DIR_IN); | 157 | DWC3_EP0_DIR_IN); |
159 | } else if (dwc->delayed_status) { | 158 | |
159 | return 0; | ||
160 | } | ||
161 | |||
162 | /* | ||
163 | * In case gadget driver asked us to delay the STATUS phase, | ||
164 | * handle it here. | ||
165 | */ | ||
166 | if (dwc->delayed_status) { | ||
167 | unsigned direction; | ||
168 | |||
169 | direction = !dwc->ep0_expect_in; | ||
160 | dwc->delayed_status = false; | 170 | dwc->delayed_status = false; |
161 | 171 | ||
162 | if (dwc->ep0state == EP0_STATUS_PHASE) | 172 | if (dwc->ep0state == EP0_STATUS_PHASE) |
163 | __dwc3_ep0_do_control_status(dwc, dwc->eps[1]); | 173 | __dwc3_ep0_do_control_status(dwc, dwc->eps[direction]); |
164 | else | 174 | else |
165 | dev_dbg(dwc->dev, "too early for delayed status\n"); | 175 | dev_dbg(dwc->dev, "too early for delayed status\n"); |
176 | |||
177 | return 0; | ||
166 | } | 178 | } |
167 | 179 | ||
168 | return ret; | 180 | /* |
181 | * Unfortunately we have uncovered a limitation wrt the Data Phase. | ||
182 | * | ||
183 | * Section 9.4 says we can wait for the XferNotReady(DATA) event to | ||
184 | * come before issueing Start Transfer command, but if we do, we will | ||
185 | * miss situations where the host starts another SETUP phase instead of | ||
186 | * the DATA phase. Such cases happen at least on TD.7.6 of the Link | ||
187 | * Layer Compliance Suite. | ||
188 | * | ||
189 | * The problem surfaces due to the fact that in case of back-to-back | ||
190 | * SETUP packets there will be no XferNotReady(DATA) generated and we | ||
191 | * will be stuck waiting for XferNotReady(DATA) forever. | ||
192 | * | ||
193 | * By looking at tables 9-13 and 9-14 of the Databook, we can see that | ||
194 | * it tells us to start Data Phase right away. It also mentions that if | ||
195 | * we receive a SETUP phase instead of the DATA phase, core will issue | ||
196 | * XferComplete for the DATA phase, before actually initiating it in | ||
197 | * the wire, with the TRB's status set to "SETUP_PENDING". Such status | ||
198 | * can only be used to print some debugging logs, as the core expects | ||
199 | * us to go through to the STATUS phase and start a CONTROL_STATUS TRB, | ||
200 | * just so it completes right away, without transferring anything and, | ||
201 | * only then, we can go back to the SETUP phase. | ||
202 | * | ||
203 | * Because of this scenario, SNPS decided to change the programming | ||
204 | * model of control transfers and support on-demand transfers only for | ||
205 | * the STATUS phase. To fix the issue we have now, we will always wait | ||
206 | * for gadget driver to queue the DATA phase's struct usb_request, then | ||
207 | * start it right away. | ||
208 | * | ||
209 | * If we're actually in a 2-stage transfer, we will wait for | ||
210 | * XferNotReady(STATUS). | ||
211 | */ | ||
212 | if (dwc->three_stage_setup) { | ||
213 | unsigned direction; | ||
214 | |||
215 | direction = dwc->ep0_expect_in; | ||
216 | dwc->ep0state = EP0_DATA_PHASE; | ||
217 | |||
218 | __dwc3_ep0_do_control_data(dwc, dwc->eps[direction], req); | ||
219 | |||
220 | dep->flags &= ~DWC3_EP0_DIR_IN; | ||
221 | } | ||
222 | |||
223 | return 0; | ||
169 | } | 224 | } |
170 | 225 | ||
171 | int dwc3_gadget_ep0_queue(struct usb_ep *ep, struct usb_request *request, | 226 | int dwc3_gadget_ep0_queue(struct usb_ep *ep, struct usb_request *request, |
@@ -207,9 +262,14 @@ out: | |||
207 | 262 | ||
208 | static void dwc3_ep0_stall_and_restart(struct dwc3 *dwc) | 263 | static void dwc3_ep0_stall_and_restart(struct dwc3 *dwc) |
209 | { | 264 | { |
210 | struct dwc3_ep *dep = dwc->eps[0]; | 265 | struct dwc3_ep *dep; |
266 | |||
267 | /* reinitialize physical ep1 */ | ||
268 | dep = dwc->eps[1]; | ||
269 | dep->flags = DWC3_EP_ENABLED; | ||
211 | 270 | ||
212 | /* stall is always issued on EP0 */ | 271 | /* stall is always issued on EP0 */ |
272 | dep = dwc->eps[0]; | ||
213 | __dwc3_gadget_ep_set_halt(dep, 1); | 273 | __dwc3_gadget_ep_set_halt(dep, 1); |
214 | dep->flags = DWC3_EP_ENABLED; | 274 | dep->flags = DWC3_EP_ENABLED; |
215 | dwc->delayed_status = false; | 275 | dwc->delayed_status = false; |
@@ -698,6 +758,7 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc, | |||
698 | struct dwc3_trb *trb; | 758 | struct dwc3_trb *trb; |
699 | struct dwc3_ep *ep0; | 759 | struct dwc3_ep *ep0; |
700 | u32 transferred; | 760 | u32 transferred; |
761 | u32 status; | ||
701 | u32 length; | 762 | u32 length; |
702 | u8 epnum; | 763 | u8 epnum; |
703 | 764 | ||
@@ -710,6 +771,17 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc, | |||
710 | ur = &r->request; | 771 | ur = &r->request; |
711 | 772 | ||
712 | trb = dwc->ep0_trb; | 773 | trb = dwc->ep0_trb; |
774 | |||
775 | status = DWC3_TRB_SIZE_TRBSTS(trb->size); | ||
776 | if (status == DWC3_TRBSTS_SETUP_PENDING) { | ||
777 | dev_dbg(dwc->dev, "Setup Pending received\n"); | ||
778 | |||
779 | if (r) | ||
780 | dwc3_gadget_giveback(ep0, r, -ECONNRESET); | ||
781 | |||
782 | return; | ||
783 | } | ||
784 | |||
713 | length = trb->size & DWC3_TRB_SIZE_MASK; | 785 | length = trb->size & DWC3_TRB_SIZE_MASK; |
714 | 786 | ||
715 | if (dwc->ep0_bounced) { | 787 | if (dwc->ep0_bounced) { |
@@ -745,8 +817,11 @@ static void dwc3_ep0_complete_status(struct dwc3 *dwc, | |||
745 | { | 817 | { |
746 | struct dwc3_request *r; | 818 | struct dwc3_request *r; |
747 | struct dwc3_ep *dep; | 819 | struct dwc3_ep *dep; |
820 | struct dwc3_trb *trb; | ||
821 | u32 status; | ||
748 | 822 | ||
749 | dep = dwc->eps[0]; | 823 | dep = dwc->eps[0]; |
824 | trb = dwc->ep0_trb; | ||
750 | 825 | ||
751 | if (!list_empty(&dep->request_list)) { | 826 | if (!list_empty(&dep->request_list)) { |
752 | r = next_request(&dep->request_list); | 827 | r = next_request(&dep->request_list); |
@@ -766,6 +841,10 @@ static void dwc3_ep0_complete_status(struct dwc3 *dwc, | |||
766 | } | 841 | } |
767 | } | 842 | } |
768 | 843 | ||
844 | status = DWC3_TRB_SIZE_TRBSTS(trb->size); | ||
845 | if (status == DWC3_TRBSTS_SETUP_PENDING) | ||
846 | dev_dbg(dwc->dev, "Setup Pending received\n"); | ||
847 | |||
769 | dwc->ep0state = EP0_SETUP_PHASE; | 848 | dwc->ep0state = EP0_SETUP_PHASE; |
770 | dwc3_ep0_out_start(dwc); | 849 | dwc3_ep0_out_start(dwc); |
771 | } | 850 | } |
@@ -799,12 +878,6 @@ static void dwc3_ep0_xfer_complete(struct dwc3 *dwc, | |||
799 | } | 878 | } |
800 | } | 879 | } |
801 | 880 | ||
802 | static void dwc3_ep0_do_control_setup(struct dwc3 *dwc, | ||
803 | const struct dwc3_event_depevt *event) | ||
804 | { | ||
805 | dwc3_ep0_out_start(dwc); | ||
806 | } | ||
807 | |||
808 | static void __dwc3_ep0_do_control_data(struct dwc3 *dwc, | 881 | static void __dwc3_ep0_do_control_data(struct dwc3 *dwc, |
809 | struct dwc3_ep *dep, struct dwc3_request *req) | 882 | struct dwc3_ep *dep, struct dwc3_request *req) |
810 | { | 883 | { |
@@ -857,29 +930,6 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc, | |||
857 | WARN_ON(ret < 0); | 930 | WARN_ON(ret < 0); |
858 | } | 931 | } |
859 | 932 | ||
860 | static void dwc3_ep0_do_control_data(struct dwc3 *dwc, | ||
861 | const struct dwc3_event_depevt *event) | ||
862 | { | ||
863 | struct dwc3_ep *dep; | ||
864 | struct dwc3_request *req; | ||
865 | |||
866 | dep = dwc->eps[0]; | ||
867 | |||
868 | if (list_empty(&dep->request_list)) { | ||
869 | dev_vdbg(dwc->dev, "pending request for EP0 Data phase\n"); | ||
870 | dep->flags |= DWC3_EP_PENDING_REQUEST; | ||
871 | |||
872 | if (event->endpoint_number) | ||
873 | dep->flags |= DWC3_EP0_DIR_IN; | ||
874 | return; | ||
875 | } | ||
876 | |||
877 | req = next_request(&dep->request_list); | ||
878 | dep = dwc->eps[event->endpoint_number]; | ||
879 | |||
880 | __dwc3_ep0_do_control_data(dwc, dep, req); | ||
881 | } | ||
882 | |||
883 | static int dwc3_ep0_start_control_status(struct dwc3_ep *dep) | 933 | static int dwc3_ep0_start_control_status(struct dwc3_ep *dep) |
884 | { | 934 | { |
885 | struct dwc3 *dwc = dep->dwc; | 935 | struct dwc3 *dwc = dep->dwc; |
@@ -911,100 +961,61 @@ static void dwc3_ep0_do_control_status(struct dwc3 *dwc, | |||
911 | __dwc3_ep0_do_control_status(dwc, dep); | 961 | __dwc3_ep0_do_control_status(dwc, dep); |
912 | } | 962 | } |
913 | 963 | ||
914 | static void dwc3_ep0_xfernotready(struct dwc3 *dwc, | 964 | static void dwc3_ep0_end_control_data(struct dwc3 *dwc, struct dwc3_ep *dep) |
915 | const struct dwc3_event_depevt *event) | ||
916 | { | 965 | { |
917 | dwc->setup_packet_pending = true; | 966 | struct dwc3_gadget_ep_cmd_params params; |
918 | 967 | u32 cmd; | |
919 | /* | 968 | int ret; |
920 | * This part is very tricky: If we have just handled | ||
921 | * XferNotReady(Setup) and we're now expecting a | ||
922 | * XferComplete but, instead, we receive another | ||
923 | * XferNotReady(Setup), we should STALL and restart | ||
924 | * the state machine. | ||
925 | * | ||
926 | * In all other cases, we just continue waiting | ||
927 | * for the XferComplete event. | ||
928 | * | ||
929 | * We are a little bit unsafe here because we're | ||
930 | * not trying to ensure that last event was, indeed, | ||
931 | * XferNotReady(Setup). | ||
932 | * | ||
933 | * Still, we don't expect any condition where that | ||
934 | * should happen and, even if it does, it would be | ||
935 | * another error condition. | ||
936 | */ | ||
937 | if (dwc->ep0_next_event == DWC3_EP0_COMPLETE) { | ||
938 | switch (event->status) { | ||
939 | case DEPEVT_STATUS_CONTROL_SETUP: | ||
940 | dev_vdbg(dwc->dev, "Unexpected XferNotReady(Setup)\n"); | ||
941 | dwc3_ep0_stall_and_restart(dwc); | ||
942 | break; | ||
943 | case DEPEVT_STATUS_CONTROL_DATA: | ||
944 | /* FALLTHROUGH */ | ||
945 | case DEPEVT_STATUS_CONTROL_STATUS: | ||
946 | /* FALLTHROUGH */ | ||
947 | default: | ||
948 | dev_vdbg(dwc->dev, "waiting for XferComplete\n"); | ||
949 | } | ||
950 | 969 | ||
970 | if (!dep->resource_index) | ||
951 | return; | 971 | return; |
952 | } | ||
953 | |||
954 | switch (event->status) { | ||
955 | case DEPEVT_STATUS_CONTROL_SETUP: | ||
956 | dev_vdbg(dwc->dev, "Control Setup\n"); | ||
957 | 972 | ||
958 | dwc->ep0state = EP0_SETUP_PHASE; | 973 | cmd = DWC3_DEPCMD_ENDTRANSFER; |
974 | cmd |= DWC3_DEPCMD_CMDIOC; | ||
975 | cmd |= DWC3_DEPCMD_PARAM(dep->resource_index); | ||
976 | memset(¶ms, 0, sizeof(params)); | ||
977 | ret = dwc3_send_gadget_ep_cmd(dwc, dep->number, cmd, ¶ms); | ||
978 | WARN_ON_ONCE(ret); | ||
979 | dep->resource_index = 0; | ||
980 | } | ||
959 | 981 | ||
960 | dwc3_ep0_do_control_setup(dwc, event); | 982 | static void dwc3_ep0_xfernotready(struct dwc3 *dwc, |
961 | break; | 983 | const struct dwc3_event_depevt *event) |
984 | { | ||
985 | dwc->setup_packet_pending = true; | ||
962 | 986 | ||
987 | switch (event->status) { | ||
963 | case DEPEVT_STATUS_CONTROL_DATA: | 988 | case DEPEVT_STATUS_CONTROL_DATA: |
964 | dev_vdbg(dwc->dev, "Control Data\n"); | 989 | dev_vdbg(dwc->dev, "Control Data\n"); |
965 | 990 | ||
966 | dwc->ep0state = EP0_DATA_PHASE; | ||
967 | |||
968 | if (dwc->ep0_next_event != DWC3_EP0_NRDY_DATA) { | ||
969 | dev_vdbg(dwc->dev, "Expected %d got %d\n", | ||
970 | dwc->ep0_next_event, | ||
971 | DWC3_EP0_NRDY_DATA); | ||
972 | |||
973 | dwc3_ep0_stall_and_restart(dwc); | ||
974 | return; | ||
975 | } | ||
976 | |||
977 | /* | 991 | /* |
978 | * One of the possible error cases is when Host _does_ | 992 | * We already have a DATA transfer in the controller's cache, |
979 | * request for Data Phase, but it does so on the wrong | 993 | * if we receive a XferNotReady(DATA) we will ignore it, unless |
980 | * direction. | 994 | * it's for the wrong direction. |
981 | * | 995 | * |
982 | * Here, we already know ep0_next_event is DATA (see above), | 996 | * In that case, we must issue END_TRANSFER command to the Data |
983 | * so we only need to check for direction. | 997 | * Phase we already have started and issue SetStall on the |
998 | * control endpoint. | ||
984 | */ | 999 | */ |
985 | if (dwc->ep0_expect_in != event->endpoint_number) { | 1000 | if (dwc->ep0_expect_in != event->endpoint_number) { |
1001 | struct dwc3_ep *dep = dwc->eps[dwc->ep0_expect_in]; | ||
1002 | |||
986 | dev_vdbg(dwc->dev, "Wrong direction for Data phase\n"); | 1003 | dev_vdbg(dwc->dev, "Wrong direction for Data phase\n"); |
1004 | dwc3_ep0_end_control_data(dwc, dep); | ||
987 | dwc3_ep0_stall_and_restart(dwc); | 1005 | dwc3_ep0_stall_and_restart(dwc); |
988 | return; | 1006 | return; |
989 | } | 1007 | } |
990 | 1008 | ||
991 | dwc3_ep0_do_control_data(dwc, event); | ||
992 | break; | 1009 | break; |
993 | 1010 | ||
994 | case DEPEVT_STATUS_CONTROL_STATUS: | 1011 | case DEPEVT_STATUS_CONTROL_STATUS: |
1012 | if (dwc->ep0_next_event != DWC3_EP0_NRDY_STATUS) | ||
1013 | return; | ||
1014 | |||
995 | dev_vdbg(dwc->dev, "Control Status\n"); | 1015 | dev_vdbg(dwc->dev, "Control Status\n"); |
996 | 1016 | ||
997 | dwc->ep0state = EP0_STATUS_PHASE; | 1017 | dwc->ep0state = EP0_STATUS_PHASE; |
998 | 1018 | ||
999 | if (dwc->ep0_next_event != DWC3_EP0_NRDY_STATUS) { | ||
1000 | dev_vdbg(dwc->dev, "Expected %d got %d\n", | ||
1001 | dwc->ep0_next_event, | ||
1002 | DWC3_EP0_NRDY_STATUS); | ||
1003 | |||
1004 | dwc3_ep0_stall_and_restart(dwc); | ||
1005 | return; | ||
1006 | } | ||
1007 | |||
1008 | if (dwc->delayed_status) { | 1019 | if (dwc->delayed_status) { |
1009 | WARN_ON_ONCE(event->endpoint_number != 1); | 1020 | WARN_ON_ONCE(event->endpoint_number != 1); |
1010 | dev_vdbg(dwc->dev, "Mass Storage delayed status\n"); | 1021 | dev_vdbg(dwc->dev, "Mass Storage delayed status\n"); |
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index c2813c2b005a..c9e729a4bf65 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c | |||
@@ -434,15 +434,25 @@ static int dwc3_gadget_start_config(struct dwc3 *dwc, struct dwc3_ep *dep) | |||
434 | 434 | ||
435 | static int dwc3_gadget_set_ep_config(struct dwc3 *dwc, struct dwc3_ep *dep, | 435 | static int dwc3_gadget_set_ep_config(struct dwc3 *dwc, struct dwc3_ep *dep, |
436 | const struct usb_endpoint_descriptor *desc, | 436 | const struct usb_endpoint_descriptor *desc, |
437 | const struct usb_ss_ep_comp_descriptor *comp_desc) | 437 | const struct usb_ss_ep_comp_descriptor *comp_desc, |
438 | bool ignore) | ||
438 | { | 439 | { |
439 | struct dwc3_gadget_ep_cmd_params params; | 440 | struct dwc3_gadget_ep_cmd_params params; |
440 | 441 | ||
441 | memset(¶ms, 0x00, sizeof(params)); | 442 | memset(¶ms, 0x00, sizeof(params)); |
442 | 443 | ||
443 | params.param0 = DWC3_DEPCFG_EP_TYPE(usb_endpoint_type(desc)) | 444 | params.param0 = DWC3_DEPCFG_EP_TYPE(usb_endpoint_type(desc)) |
444 | | DWC3_DEPCFG_MAX_PACKET_SIZE(usb_endpoint_maxp(desc)) | 445 | | DWC3_DEPCFG_MAX_PACKET_SIZE(usb_endpoint_maxp(desc)); |
445 | | DWC3_DEPCFG_BURST_SIZE(dep->endpoint.maxburst - 1); | 446 | |
447 | /* Burst size is only needed in SuperSpeed mode */ | ||
448 | if (dwc->gadget.speed == USB_SPEED_SUPER) { | ||
449 | u32 burst = dep->endpoint.maxburst - 1; | ||
450 | |||
451 | params.param0 |= DWC3_DEPCFG_BURST_SIZE(burst); | ||
452 | } | ||
453 | |||
454 | if (ignore) | ||
455 | params.param0 |= DWC3_DEPCFG_IGN_SEQ_NUM; | ||
446 | 456 | ||
447 | params.param1 = DWC3_DEPCFG_XFER_COMPLETE_EN | 457 | params.param1 = DWC3_DEPCFG_XFER_COMPLETE_EN |
448 | | DWC3_DEPCFG_XFER_NOT_READY_EN; | 458 | | DWC3_DEPCFG_XFER_NOT_READY_EN; |
@@ -501,7 +511,8 @@ static int dwc3_gadget_set_xfer_resource(struct dwc3 *dwc, struct dwc3_ep *dep) | |||
501 | */ | 511 | */ |
502 | static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep, | 512 | static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep, |
503 | const struct usb_endpoint_descriptor *desc, | 513 | const struct usb_endpoint_descriptor *desc, |
504 | const struct usb_ss_ep_comp_descriptor *comp_desc) | 514 | const struct usb_ss_ep_comp_descriptor *comp_desc, |
515 | bool ignore) | ||
505 | { | 516 | { |
506 | struct dwc3 *dwc = dep->dwc; | 517 | struct dwc3 *dwc = dep->dwc; |
507 | u32 reg; | 518 | u32 reg; |
@@ -513,7 +524,7 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep, | |||
513 | return ret; | 524 | return ret; |
514 | } | 525 | } |
515 | 526 | ||
516 | ret = dwc3_gadget_set_ep_config(dwc, dep, desc, comp_desc); | 527 | ret = dwc3_gadget_set_ep_config(dwc, dep, desc, comp_desc, ignore); |
517 | if (ret) | 528 | if (ret) |
518 | return ret; | 529 | return ret; |
519 | 530 | ||
@@ -561,27 +572,7 @@ static void dwc3_remove_requests(struct dwc3 *dwc, struct dwc3_ep *dep) | |||
561 | if (!list_empty(&dep->req_queued)) { | 572 | if (!list_empty(&dep->req_queued)) { |
562 | dwc3_stop_active_transfer(dwc, dep->number); | 573 | dwc3_stop_active_transfer(dwc, dep->number); |
563 | 574 | ||
564 | /* | 575 | /* - giveback all requests to gadget driver */ |
565 | * NOTICE: We are violating what the Databook says about the | ||
566 | * EndTransfer command. Ideally we would _always_ wait for the | ||
567 | * EndTransfer Command Completion IRQ, but that's causing too | ||
568 | * much trouble synchronizing between us and gadget driver. | ||
569 | * | ||
570 | * We have discussed this with the IP Provider and it was | ||
571 | * suggested to giveback all requests here, but give HW some | ||
572 | * extra time to synchronize with the interconnect. We're using | ||
573 | * an arbitraty 100us delay for that. | ||
574 | * | ||
575 | * Note also that a similar handling was tested by Synopsys | ||
576 | * (thanks a lot Paul) and nothing bad has come out of it. | ||
577 | * In short, what we're doing is: | ||
578 | * | ||
579 | * - Issue EndTransfer WITH CMDIOC bit set | ||
580 | * - Wait 100us | ||
581 | * - giveback all requests to gadget driver | ||
582 | */ | ||
583 | udelay(100); | ||
584 | |||
585 | while (!list_empty(&dep->req_queued)) { | 576 | while (!list_empty(&dep->req_queued)) { |
586 | req = next_request(&dep->req_queued); | 577 | req = next_request(&dep->req_queued); |
587 | 578 | ||
@@ -660,6 +651,12 @@ static int dwc3_gadget_ep_enable(struct usb_ep *ep, | |||
660 | dep = to_dwc3_ep(ep); | 651 | dep = to_dwc3_ep(ep); |
661 | dwc = dep->dwc; | 652 | dwc = dep->dwc; |
662 | 653 | ||
654 | if (dep->flags & DWC3_EP_ENABLED) { | ||
655 | dev_WARN_ONCE(dwc->dev, true, "%s is already enabled\n", | ||
656 | dep->name); | ||
657 | return 0; | ||
658 | } | ||
659 | |||
663 | switch (usb_endpoint_type(desc)) { | 660 | switch (usb_endpoint_type(desc)) { |
664 | case USB_ENDPOINT_XFER_CONTROL: | 661 | case USB_ENDPOINT_XFER_CONTROL: |
665 | strlcat(dep->name, "-control", sizeof(dep->name)); | 662 | strlcat(dep->name, "-control", sizeof(dep->name)); |
@@ -677,16 +674,10 @@ static int dwc3_gadget_ep_enable(struct usb_ep *ep, | |||
677 | dev_err(dwc->dev, "invalid endpoint transfer type\n"); | 674 | dev_err(dwc->dev, "invalid endpoint transfer type\n"); |
678 | } | 675 | } |
679 | 676 | ||
680 | if (dep->flags & DWC3_EP_ENABLED) { | ||
681 | dev_WARN_ONCE(dwc->dev, true, "%s is already enabled\n", | ||
682 | dep->name); | ||
683 | return 0; | ||
684 | } | ||
685 | |||
686 | dev_vdbg(dwc->dev, "Enabling %s\n", dep->name); | 677 | dev_vdbg(dwc->dev, "Enabling %s\n", dep->name); |
687 | 678 | ||
688 | spin_lock_irqsave(&dwc->lock, flags); | 679 | spin_lock_irqsave(&dwc->lock, flags); |
689 | ret = __dwc3_gadget_ep_enable(dep, desc, ep->comp_desc); | 680 | ret = __dwc3_gadget_ep_enable(dep, desc, ep->comp_desc, false); |
690 | spin_unlock_irqrestore(&dwc->lock, flags); | 681 | spin_unlock_irqrestore(&dwc->lock, flags); |
691 | 682 | ||
692 | return ret; | 683 | return ret; |
@@ -1105,12 +1096,9 @@ static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, struct dwc3_request *req) | |||
1105 | } | 1096 | } |
1106 | 1097 | ||
1107 | ret = __dwc3_gadget_kick_transfer(dep, 0, true); | 1098 | ret = __dwc3_gadget_kick_transfer(dep, 0, true); |
1108 | if (ret && ret != -EBUSY) { | 1099 | if (ret && ret != -EBUSY) |
1109 | struct dwc3 *dwc = dep->dwc; | ||
1110 | |||
1111 | dev_dbg(dwc->dev, "%s: failed to kick transfers\n", | 1100 | dev_dbg(dwc->dev, "%s: failed to kick transfers\n", |
1112 | dep->name); | 1101 | dep->name); |
1113 | } | ||
1114 | } | 1102 | } |
1115 | 1103 | ||
1116 | /* | 1104 | /* |
@@ -1119,16 +1107,14 @@ static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, struct dwc3_request *req) | |||
1119 | * core may not see the modified TRB(s). | 1107 | * core may not see the modified TRB(s). |
1120 | */ | 1108 | */ |
1121 | if (usb_endpoint_xfer_isoc(dep->endpoint.desc) && | 1109 | if (usb_endpoint_xfer_isoc(dep->endpoint.desc) && |
1122 | (dep->flags & DWC3_EP_BUSY)) { | 1110 | (dep->flags & DWC3_EP_BUSY) && |
1111 | !(dep->flags & DWC3_EP_MISSED_ISOC)) { | ||
1123 | WARN_ON_ONCE(!dep->resource_index); | 1112 | WARN_ON_ONCE(!dep->resource_index); |
1124 | ret = __dwc3_gadget_kick_transfer(dep, dep->resource_index, | 1113 | ret = __dwc3_gadget_kick_transfer(dep, dep->resource_index, |
1125 | false); | 1114 | false); |
1126 | if (ret && ret != -EBUSY) { | 1115 | if (ret && ret != -EBUSY) |
1127 | struct dwc3 *dwc = dep->dwc; | ||
1128 | |||
1129 | dev_dbg(dwc->dev, "%s: failed to kick transfers\n", | 1116 | dev_dbg(dwc->dev, "%s: failed to kick transfers\n", |
1130 | dep->name); | 1117 | dep->name); |
1131 | } | ||
1132 | } | 1118 | } |
1133 | 1119 | ||
1134 | /* | 1120 | /* |
@@ -1533,14 +1519,14 @@ static int dwc3_gadget_start(struct usb_gadget *g, | |||
1533 | dwc3_gadget_ep0_desc.wMaxPacketSize = cpu_to_le16(512); | 1519 | dwc3_gadget_ep0_desc.wMaxPacketSize = cpu_to_le16(512); |
1534 | 1520 | ||
1535 | dep = dwc->eps[0]; | 1521 | dep = dwc->eps[0]; |
1536 | ret = __dwc3_gadget_ep_enable(dep, &dwc3_gadget_ep0_desc, NULL); | 1522 | ret = __dwc3_gadget_ep_enable(dep, &dwc3_gadget_ep0_desc, NULL, false); |
1537 | if (ret) { | 1523 | if (ret) { |
1538 | dev_err(dwc->dev, "failed to enable %s\n", dep->name); | 1524 | dev_err(dwc->dev, "failed to enable %s\n", dep->name); |
1539 | goto err0; | 1525 | goto err0; |
1540 | } | 1526 | } |
1541 | 1527 | ||
1542 | dep = dwc->eps[1]; | 1528 | dep = dwc->eps[1]; |
1543 | ret = __dwc3_gadget_ep_enable(dep, &dwc3_gadget_ep0_desc, NULL); | 1529 | ret = __dwc3_gadget_ep_enable(dep, &dwc3_gadget_ep0_desc, NULL, false); |
1544 | if (ret) { | 1530 | if (ret) { |
1545 | dev_err(dwc->dev, "failed to enable %s\n", dep->name); | 1531 | dev_err(dwc->dev, "failed to enable %s\n", dep->name); |
1546 | goto err1; | 1532 | goto err1; |
@@ -1765,7 +1751,7 @@ static void dwc3_endpoint_transfer_complete(struct dwc3 *dwc, | |||
1765 | int i; | 1751 | int i; |
1766 | 1752 | ||
1767 | for (i = 0; i < DWC3_ENDPOINTS_NUM; i++) { | 1753 | for (i = 0; i < DWC3_ENDPOINTS_NUM; i++) { |
1768 | struct dwc3_ep *dep = dwc->eps[i]; | 1754 | dep = dwc->eps[i]; |
1769 | 1755 | ||
1770 | if (!(dep->flags & DWC3_EP_ENABLED)) | 1756 | if (!(dep->flags & DWC3_EP_ENABLED)) |
1771 | continue; | 1757 | continue; |
@@ -1892,6 +1878,25 @@ static void dwc3_stop_active_transfer(struct dwc3 *dwc, u32 epnum) | |||
1892 | if (!dep->resource_index) | 1878 | if (!dep->resource_index) |
1893 | return; | 1879 | return; |
1894 | 1880 | ||
1881 | /* | ||
1882 | * NOTICE: We are violating what the Databook says about the | ||
1883 | * EndTransfer command. Ideally we would _always_ wait for the | ||
1884 | * EndTransfer Command Completion IRQ, but that's causing too | ||
1885 | * much trouble synchronizing between us and gadget driver. | ||
1886 | * | ||
1887 | * We have discussed this with the IP Provider and it was | ||
1888 | * suggested to giveback all requests here, but give HW some | ||
1889 | * extra time to synchronize with the interconnect. We're using | ||
1890 | * an arbitraty 100us delay for that. | ||
1891 | * | ||
1892 | * Note also that a similar handling was tested by Synopsys | ||
1893 | * (thanks a lot Paul) and nothing bad has come out of it. | ||
1894 | * In short, what we're doing is: | ||
1895 | * | ||
1896 | * - Issue EndTransfer WITH CMDIOC bit set | ||
1897 | * - Wait 100us | ||
1898 | */ | ||
1899 | |||
1895 | cmd = DWC3_DEPCMD_ENDTRANSFER; | 1900 | cmd = DWC3_DEPCMD_ENDTRANSFER; |
1896 | cmd |= DWC3_DEPCMD_HIPRI_FORCERM | DWC3_DEPCMD_CMDIOC; | 1901 | cmd |= DWC3_DEPCMD_HIPRI_FORCERM | DWC3_DEPCMD_CMDIOC; |
1897 | cmd |= DWC3_DEPCMD_PARAM(dep->resource_index); | 1902 | cmd |= DWC3_DEPCMD_PARAM(dep->resource_index); |
@@ -1899,6 +1904,8 @@ static void dwc3_stop_active_transfer(struct dwc3 *dwc, u32 epnum) | |||
1899 | ret = dwc3_send_gadget_ep_cmd(dwc, dep->number, cmd, ¶ms); | 1904 | ret = dwc3_send_gadget_ep_cmd(dwc, dep->number, cmd, ¶ms); |
1900 | WARN_ON_ONCE(ret); | 1905 | WARN_ON_ONCE(ret); |
1901 | dep->resource_index = 0; | 1906 | dep->resource_index = 0; |
1907 | |||
1908 | udelay(100); | ||
1902 | } | 1909 | } |
1903 | 1910 | ||
1904 | static void dwc3_stop_active_transfers(struct dwc3 *dwc) | 1911 | static void dwc3_stop_active_transfers(struct dwc3 *dwc) |
@@ -2156,14 +2163,14 @@ static void dwc3_gadget_conndone_interrupt(struct dwc3 *dwc) | |||
2156 | } | 2163 | } |
2157 | 2164 | ||
2158 | dep = dwc->eps[0]; | 2165 | dep = dwc->eps[0]; |
2159 | ret = __dwc3_gadget_ep_enable(dep, &dwc3_gadget_ep0_desc, NULL); | 2166 | ret = __dwc3_gadget_ep_enable(dep, &dwc3_gadget_ep0_desc, NULL, true); |
2160 | if (ret) { | 2167 | if (ret) { |
2161 | dev_err(dwc->dev, "failed to enable %s\n", dep->name); | 2168 | dev_err(dwc->dev, "failed to enable %s\n", dep->name); |
2162 | return; | 2169 | return; |
2163 | } | 2170 | } |
2164 | 2171 | ||
2165 | dep = dwc->eps[1]; | 2172 | dep = dwc->eps[1]; |
2166 | ret = __dwc3_gadget_ep_enable(dep, &dwc3_gadget_ep0_desc, NULL); | 2173 | ret = __dwc3_gadget_ep_enable(dep, &dwc3_gadget_ep0_desc, NULL, true); |
2167 | if (ret) { | 2174 | if (ret) { |
2168 | dev_err(dwc->dev, "failed to enable %s\n", dep->name); | 2175 | dev_err(dwc->dev, "failed to enable %s\n", dep->name); |
2169 | return; | 2176 | return; |
diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c index 89dcf155d57e..e426ad626d74 100644 --- a/drivers/usb/early/ehci-dbgp.c +++ b/drivers/usb/early/ehci-dbgp.c | |||
@@ -491,7 +491,7 @@ static int ehci_wait_for_port(int port); | |||
491 | * Return -ENODEV for any general failure | 491 | * Return -ENODEV for any general failure |
492 | * Return -EIO if wait for port fails | 492 | * Return -EIO if wait for port fails |
493 | */ | 493 | */ |
494 | int dbgp_external_startup(void) | 494 | static int _dbgp_external_startup(void) |
495 | { | 495 | { |
496 | int devnum; | 496 | int devnum; |
497 | struct usb_debug_descriptor dbgp_desc; | 497 | struct usb_debug_descriptor dbgp_desc; |
@@ -613,6 +613,11 @@ err: | |||
613 | goto try_again; | 613 | goto try_again; |
614 | return -ENODEV; | 614 | return -ENODEV; |
615 | } | 615 | } |
616 | |||
617 | int dbgp_external_startup(struct usb_hcd *hcd) | ||
618 | { | ||
619 | return xen_dbgp_external_startup(hcd) ?: _dbgp_external_startup(); | ||
620 | } | ||
616 | EXPORT_SYMBOL_GPL(dbgp_external_startup); | 621 | EXPORT_SYMBOL_GPL(dbgp_external_startup); |
617 | 622 | ||
618 | static int ehci_reset_port(int port) | 623 | static int ehci_reset_port(int port) |
@@ -804,7 +809,7 @@ try_next_port: | |||
804 | dbgp_ehci_status("ehci skip - already configured"); | 809 | dbgp_ehci_status("ehci skip - already configured"); |
805 | } | 810 | } |
806 | 811 | ||
807 | ret = dbgp_external_startup(); | 812 | ret = _dbgp_external_startup(); |
808 | if (ret == -EIO) | 813 | if (ret == -EIO) |
809 | goto next_debug_port; | 814 | goto next_debug_port; |
810 | 815 | ||
@@ -934,7 +939,7 @@ static void early_dbgp_write(struct console *con, const char *str, u32 n) | |||
934 | ctrl = readl(&ehci_debug->control); | 939 | ctrl = readl(&ehci_debug->control); |
935 | if (!(ctrl & DBGP_ENABLED)) { | 940 | if (!(ctrl & DBGP_ENABLED)) { |
936 | dbgp_not_safe = 1; | 941 | dbgp_not_safe = 1; |
937 | dbgp_external_startup(); | 942 | _dbgp_external_startup(); |
938 | } else { | 943 | } else { |
939 | cmd |= CMD_RUN; | 944 | cmd |= CMD_RUN; |
940 | writel(cmd, &ehci_regs->command); | 945 | writel(cmd, &ehci_regs->command); |
@@ -974,10 +979,14 @@ struct console early_dbgp_console = { | |||
974 | .index = -1, | 979 | .index = -1, |
975 | }; | 980 | }; |
976 | 981 | ||
977 | int dbgp_reset_prep(void) | 982 | int dbgp_reset_prep(struct usb_hcd *hcd) |
978 | { | 983 | { |
984 | int ret = xen_dbgp_reset_prep(hcd); | ||
979 | u32 ctrl; | 985 | u32 ctrl; |
980 | 986 | ||
987 | if (ret) | ||
988 | return ret; | ||
989 | |||
981 | dbgp_not_safe = 1; | 990 | dbgp_not_safe = 1; |
982 | if (!ehci_debug) | 991 | if (!ehci_debug) |
983 | return 0; | 992 | return 0; |
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index 51ab5fd5d468..dfb51a45496c 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig | |||
@@ -154,16 +154,25 @@ config USB_LPC32XX | |||
154 | 154 | ||
155 | config USB_ATMEL_USBA | 155 | config USB_ATMEL_USBA |
156 | tristate "Atmel USBA" | 156 | tristate "Atmel USBA" |
157 | select USB_GADGET_DUALSPEED | ||
158 | depends on AVR32 || ARCH_AT91SAM9RL || ARCH_AT91SAM9G45 | 157 | depends on AVR32 || ARCH_AT91SAM9RL || ARCH_AT91SAM9G45 |
159 | help | 158 | help |
160 | USBA is the integrated high-speed USB Device controller on | 159 | USBA is the integrated high-speed USB Device controller on |
161 | the AT32AP700x, some AT91SAM9 and AT91CAP9 processors from Atmel. | 160 | the AT32AP700x, some AT91SAM9 and AT91CAP9 processors from Atmel. |
162 | 161 | ||
162 | config USB_BCM63XX_UDC | ||
163 | tristate "Broadcom BCM63xx Peripheral Controller" | ||
164 | depends on BCM63XX | ||
165 | help | ||
166 | Many Broadcom BCM63xx chipsets (such as the BCM6328) have a | ||
167 | high speed USB Device Port with support for four fixed endpoints | ||
168 | (plus endpoint zero). | ||
169 | |||
170 | Say "y" to link the driver statically, or "m" to build a | ||
171 | dynamically linked module called "bcm63xx_udc". | ||
172 | |||
163 | config USB_FSL_USB2 | 173 | config USB_FSL_USB2 |
164 | tristate "Freescale Highspeed USB DR Peripheral Controller" | 174 | tristate "Freescale Highspeed USB DR Peripheral Controller" |
165 | depends on FSL_SOC || ARCH_MXC | 175 | depends on FSL_SOC || ARCH_MXC |
166 | select USB_GADGET_DUALSPEED | ||
167 | select USB_FSL_MPH_DR_OF if OF | 176 | select USB_FSL_MPH_DR_OF if OF |
168 | help | 177 | help |
169 | Some of Freescale PowerPC and i.MX processors have a High Speed | 178 | Some of Freescale PowerPC and i.MX processors have a High Speed |
@@ -179,7 +188,6 @@ config USB_FSL_USB2 | |||
179 | config USB_FUSB300 | 188 | config USB_FUSB300 |
180 | tristate "Faraday FUSB300 USB Peripheral Controller" | 189 | tristate "Faraday FUSB300 USB Peripheral Controller" |
181 | depends on !PHYS_ADDR_T_64BIT | 190 | depends on !PHYS_ADDR_T_64BIT |
182 | select USB_GADGET_DUALSPEED | ||
183 | help | 191 | help |
184 | Faraday usb device controller FUSB300 driver | 192 | Faraday usb device controller FUSB300 driver |
185 | 193 | ||
@@ -227,7 +235,6 @@ config USB_PXA25X_SMALL | |||
227 | 235 | ||
228 | config USB_R8A66597 | 236 | config USB_R8A66597 |
229 | tristate "Renesas R8A66597 USB Peripheral Controller" | 237 | tristate "Renesas R8A66597 USB Peripheral Controller" |
230 | select USB_GADGET_DUALSPEED | ||
231 | help | 238 | help |
232 | R8A66597 is a discrete USB host and peripheral controller chip that | 239 | R8A66597 is a discrete USB host and peripheral controller chip that |
233 | supports both full and high speed USB 2.0 data transfers. | 240 | supports both full and high speed USB 2.0 data transfers. |
@@ -240,7 +247,6 @@ config USB_R8A66597 | |||
240 | config USB_RENESAS_USBHS_UDC | 247 | config USB_RENESAS_USBHS_UDC |
241 | tristate 'Renesas USBHS controller' | 248 | tristate 'Renesas USBHS controller' |
242 | depends on USB_RENESAS_USBHS | 249 | depends on USB_RENESAS_USBHS |
243 | select USB_GADGET_DUALSPEED | ||
244 | help | 250 | help |
245 | Renesas USBHS is a discrete USB host and peripheral controller chip | 251 | Renesas USBHS is a discrete USB host and peripheral controller chip |
246 | that supports both full and high speed USB 2.0 data transfers. | 252 | that supports both full and high speed USB 2.0 data transfers. |
@@ -268,7 +274,6 @@ config USB_PXA27X | |||
268 | config USB_S3C_HSOTG | 274 | config USB_S3C_HSOTG |
269 | tristate "S3C HS/OtG USB Device controller" | 275 | tristate "S3C HS/OtG USB Device controller" |
270 | depends on S3C_DEV_USB_HSOTG | 276 | depends on S3C_DEV_USB_HSOTG |
271 | select USB_GADGET_DUALSPEED | ||
272 | help | 277 | help |
273 | The Samsung S3C64XX USB2.0 high-speed gadget controller | 278 | The Samsung S3C64XX USB2.0 high-speed gadget controller |
274 | integrated into the S3C64XX series SoC. | 279 | integrated into the S3C64XX series SoC. |
@@ -305,7 +310,6 @@ config USB_S3C2410_DEBUG | |||
305 | config USB_S3C_HSUDC | 310 | config USB_S3C_HSUDC |
306 | tristate "S3C2416, S3C2443 and S3C2450 USB Device Controller" | 311 | tristate "S3C2416, S3C2443 and S3C2450 USB Device Controller" |
307 | depends on ARCH_S3C24XX | 312 | depends on ARCH_S3C24XX |
308 | select USB_GADGET_DUALSPEED | ||
309 | help | 313 | help |
310 | Samsung's S3C2416, S3C2443 and S3C2450 is an ARM9 based SoC | 314 | Samsung's S3C2416, S3C2443 and S3C2450 is an ARM9 based SoC |
311 | integrated with dual speed USB 2.0 device controller. It has | 315 | integrated with dual speed USB 2.0 device controller. It has |
@@ -315,7 +319,6 @@ config USB_S3C_HSUDC | |||
315 | 319 | ||
316 | config USB_MV_UDC | 320 | config USB_MV_UDC |
317 | tristate "Marvell USB2.0 Device Controller" | 321 | tristate "Marvell USB2.0 Device Controller" |
318 | select USB_GADGET_DUALSPEED | ||
319 | help | 322 | help |
320 | Marvell Socs (including PXA and MMP series) include a high speed | 323 | Marvell Socs (including PXA and MMP series) include a high speed |
321 | USB2.0 OTG controller, which can be configured as high speed or | 324 | USB2.0 OTG controller, which can be configured as high speed or |
@@ -338,14 +341,12 @@ config USB_MV_U3D | |||
338 | config USB_GADGET_MUSB_HDRC | 341 | config USB_GADGET_MUSB_HDRC |
339 | tristate "Inventra HDRC USB Peripheral (TI, ADI, ...)" | 342 | tristate "Inventra HDRC USB Peripheral (TI, ADI, ...)" |
340 | depends on USB_MUSB_HDRC | 343 | depends on USB_MUSB_HDRC |
341 | select USB_GADGET_DUALSPEED | ||
342 | help | 344 | help |
343 | This OTG-capable silicon IP is used in dual designs including | 345 | This OTG-capable silicon IP is used in dual designs including |
344 | the TI DaVinci, OMAP 243x, OMAP 343x, TUSB 6010, and ADI Blackfin | 346 | the TI DaVinci, OMAP 243x, OMAP 343x, TUSB 6010, and ADI Blackfin |
345 | 347 | ||
346 | config USB_M66592 | 348 | config USB_M66592 |
347 | tristate "Renesas M66592 USB Peripheral Controller" | 349 | tristate "Renesas M66592 USB Peripheral Controller" |
348 | select USB_GADGET_DUALSPEED | ||
349 | help | 350 | help |
350 | M66592 is a discrete USB peripheral controller chip that | 351 | M66592 is a discrete USB peripheral controller chip that |
351 | supports both full and high speed USB 2.0 data transfers. | 352 | supports both full and high speed USB 2.0 data transfers. |
@@ -362,7 +363,6 @@ config USB_M66592 | |||
362 | config USB_AMD5536UDC | 363 | config USB_AMD5536UDC |
363 | tristate "AMD5536 UDC" | 364 | tristate "AMD5536 UDC" |
364 | depends on PCI | 365 | depends on PCI |
365 | select USB_GADGET_DUALSPEED | ||
366 | help | 366 | help |
367 | The AMD5536 UDC is part of the AMD Geode CS5536, an x86 southbridge. | 367 | The AMD5536 UDC is part of the AMD Geode CS5536, an x86 southbridge. |
368 | It is a USB Highspeed DMA capable USB device controller. Beside ep0 | 368 | It is a USB Highspeed DMA capable USB device controller. Beside ep0 |
@@ -389,7 +389,6 @@ config USB_FSL_QE | |||
389 | 389 | ||
390 | config USB_NET2272 | 390 | config USB_NET2272 |
391 | tristate "PLX NET2272" | 391 | tristate "PLX NET2272" |
392 | select USB_GADGET_DUALSPEED | ||
393 | help | 392 | help |
394 | PLX NET2272 is a USB peripheral controller which supports | 393 | PLX NET2272 is a USB peripheral controller which supports |
395 | both full and high speed USB 2.0 data transfers. | 394 | both full and high speed USB 2.0 data transfers. |
@@ -413,7 +412,6 @@ config USB_NET2272_DMA | |||
413 | config USB_NET2280 | 412 | config USB_NET2280 |
414 | tristate "NetChip 228x" | 413 | tristate "NetChip 228x" |
415 | depends on PCI | 414 | depends on PCI |
416 | select USB_GADGET_DUALSPEED | ||
417 | help | 415 | help |
418 | NetChip 2280 / 2282 is a PCI based USB peripheral controller which | 416 | NetChip 2280 / 2282 is a PCI based USB peripheral controller which |
419 | supports both full and high speed USB 2.0 data transfers. | 417 | supports both full and high speed USB 2.0 data transfers. |
@@ -443,7 +441,6 @@ config USB_GOKU | |||
443 | config USB_EG20T | 441 | config USB_EG20T |
444 | tristate "Intel EG20T PCH/LAPIS Semiconductor IOH(ML7213/ML7831) UDC" | 442 | tristate "Intel EG20T PCH/LAPIS Semiconductor IOH(ML7213/ML7831) UDC" |
445 | depends on PCI | 443 | depends on PCI |
446 | select USB_GADGET_DUALSPEED | ||
447 | help | 444 | help |
448 | This is a USB device driver for EG20T PCH. | 445 | This is a USB device driver for EG20T PCH. |
449 | EG20T PCH is the platform controller hub that is used in Intel's | 446 | EG20T PCH is the platform controller hub that is used in Intel's |
@@ -470,8 +467,6 @@ config USB_EG20T | |||
470 | config USB_DUMMY_HCD | 467 | config USB_DUMMY_HCD |
471 | tristate "Dummy HCD (DEVELOPMENT)" | 468 | tristate "Dummy HCD (DEVELOPMENT)" |
472 | depends on USB=y || (USB=m && USB_GADGET=m) | 469 | depends on USB=y || (USB=m && USB_GADGET=m) |
473 | select USB_GADGET_DUALSPEED | ||
474 | select USB_GADGET_SUPERSPEED | ||
475 | help | 470 | help |
476 | This host controller driver emulates USB, looping all data transfer | 471 | This host controller driver emulates USB, looping all data transfer |
477 | requests back to a USB "gadget driver" in the same host. The host | 472 | requests back to a USB "gadget driver" in the same host. The host |
@@ -496,18 +491,15 @@ config USB_DUMMY_HCD | |||
496 | 491 | ||
497 | endmenu | 492 | endmenu |
498 | 493 | ||
499 | # Selected by UDC drivers that support high-speed operation. | ||
500 | config USB_GADGET_DUALSPEED | ||
501 | bool | ||
502 | |||
503 | # Selected by UDC drivers that support super-speed opperation | ||
504 | config USB_GADGET_SUPERSPEED | ||
505 | bool | ||
506 | depends on USB_GADGET_DUALSPEED | ||
507 | |||
508 | # | 494 | # |
509 | # USB Gadget Drivers | 495 | # USB Gadget Drivers |
510 | # | 496 | # |
497 | |||
498 | # composite based drivers | ||
499 | config USB_LIBCOMPOSITE | ||
500 | tristate | ||
501 | depends on USB_GADGET | ||
502 | |||
511 | choice | 503 | choice |
512 | tristate "USB Gadget Drivers" | 504 | tristate "USB Gadget Drivers" |
513 | default USB_ETH | 505 | default USB_ETH |
@@ -531,6 +523,7 @@ choice | |||
531 | 523 | ||
532 | config USB_ZERO | 524 | config USB_ZERO |
533 | tristate "Gadget Zero (DEVELOPMENT)" | 525 | tristate "Gadget Zero (DEVELOPMENT)" |
526 | select USB_LIBCOMPOSITE | ||
534 | help | 527 | help |
535 | Gadget Zero is a two-configuration device. It either sinks and | 528 | Gadget Zero is a two-configuration device. It either sinks and |
536 | sources bulk data; or it loops back a configurable number of | 529 | sources bulk data; or it loops back a configurable number of |
@@ -564,8 +557,9 @@ config USB_ZERO_HNPTEST | |||
564 | one serve as the USB host instead (in the "B-Host" role). | 557 | one serve as the USB host instead (in the "B-Host" role). |
565 | 558 | ||
566 | config USB_AUDIO | 559 | config USB_AUDIO |
567 | tristate "Audio Gadget (EXPERIMENTAL)" | 560 | tristate "Audio Gadget" |
568 | depends on SND | 561 | depends on SND |
562 | select USB_LIBCOMPOSITE | ||
569 | select SND_PCM | 563 | select SND_PCM |
570 | help | 564 | help |
571 | This Gadget Audio driver is compatible with USB Audio Class | 565 | This Gadget Audio driver is compatible with USB Audio Class |
@@ -594,6 +588,7 @@ config GADGET_UAC1 | |||
594 | config USB_ETH | 588 | config USB_ETH |
595 | tristate "Ethernet Gadget (with CDC Ethernet support)" | 589 | tristate "Ethernet Gadget (with CDC Ethernet support)" |
596 | depends on NET | 590 | depends on NET |
591 | select USB_LIBCOMPOSITE | ||
597 | select CRC32 | 592 | select CRC32 |
598 | help | 593 | help |
599 | This driver implements Ethernet style communication, in one of | 594 | This driver implements Ethernet style communication, in one of |
@@ -629,6 +624,7 @@ config USB_ETH | |||
629 | config USB_ETH_RNDIS | 624 | config USB_ETH_RNDIS |
630 | bool "RNDIS support" | 625 | bool "RNDIS support" |
631 | depends on USB_ETH | 626 | depends on USB_ETH |
627 | select USB_LIBCOMPOSITE | ||
632 | default y | 628 | default y |
633 | help | 629 | help |
634 | Microsoft Windows XP bundles the "Remote NDIS" (RNDIS) protocol, | 630 | Microsoft Windows XP bundles the "Remote NDIS" (RNDIS) protocol, |
@@ -647,6 +643,7 @@ config USB_ETH_RNDIS | |||
647 | config USB_ETH_EEM | 643 | config USB_ETH_EEM |
648 | bool "Ethernet Emulation Model (EEM) support" | 644 | bool "Ethernet Emulation Model (EEM) support" |
649 | depends on USB_ETH | 645 | depends on USB_ETH |
646 | select USB_LIBCOMPOSITE | ||
650 | default n | 647 | default n |
651 | help | 648 | help |
652 | CDC EEM is a newer USB standard that is somewhat simpler than CDC ECM | 649 | CDC EEM is a newer USB standard that is somewhat simpler than CDC ECM |
@@ -663,6 +660,7 @@ config USB_ETH_EEM | |||
663 | config USB_G_NCM | 660 | config USB_G_NCM |
664 | tristate "Network Control Model (NCM) support" | 661 | tristate "Network Control Model (NCM) support" |
665 | depends on NET | 662 | depends on NET |
663 | select USB_LIBCOMPOSITE | ||
666 | select CRC32 | 664 | select CRC32 |
667 | help | 665 | help |
668 | This driver implements USB CDC NCM subclass standard. NCM is | 666 | This driver implements USB CDC NCM subclass standard. NCM is |
@@ -674,8 +672,7 @@ config USB_G_NCM | |||
674 | dynamically linked module called "g_ncm". | 672 | dynamically linked module called "g_ncm". |
675 | 673 | ||
676 | config USB_GADGETFS | 674 | config USB_GADGETFS |
677 | tristate "Gadget Filesystem (EXPERIMENTAL)" | 675 | tristate "Gadget Filesystem" |
678 | depends on EXPERIMENTAL | ||
679 | help | 676 | help |
680 | This driver provides a filesystem based API that lets user mode | 677 | This driver provides a filesystem based API that lets user mode |
681 | programs implement a single-configuration USB device, including | 678 | programs implement a single-configuration USB device, including |
@@ -683,15 +680,12 @@ config USB_GADGETFS | |||
683 | All endpoints, transfer speeds, and transfer types supported by | 680 | All endpoints, transfer speeds, and transfer types supported by |
684 | the hardware are available, through read() and write() calls. | 681 | the hardware are available, through read() and write() calls. |
685 | 682 | ||
686 | Currently, this option is still labelled as EXPERIMENTAL because | ||
687 | of existing race conditions in the underlying in-kernel AIO core. | ||
688 | |||
689 | Say "y" to link the driver statically, or "m" to build a | 683 | Say "y" to link the driver statically, or "m" to build a |
690 | dynamically linked module called "gadgetfs". | 684 | dynamically linked module called "gadgetfs". |
691 | 685 | ||
692 | config USB_FUNCTIONFS | 686 | config USB_FUNCTIONFS |
693 | tristate "Function Filesystem (EXPERIMENTAL)" | 687 | tristate "Function Filesystem" |
694 | depends on EXPERIMENTAL | 688 | select USB_LIBCOMPOSITE |
695 | select USB_FUNCTIONFS_GENERIC if !(USB_FUNCTIONFS_ETH || USB_FUNCTIONFS_RNDIS) | 689 | select USB_FUNCTIONFS_GENERIC if !(USB_FUNCTIONFS_ETH || USB_FUNCTIONFS_RNDIS) |
696 | help | 690 | help |
697 | The Function Filesystem (FunctionFS) lets one create USB | 691 | The Function Filesystem (FunctionFS) lets one create USB |
@@ -755,6 +749,7 @@ config USB_FILE_STORAGE_TEST | |||
755 | config USB_MASS_STORAGE | 749 | config USB_MASS_STORAGE |
756 | tristate "Mass Storage Gadget" | 750 | tristate "Mass Storage Gadget" |
757 | depends on BLOCK | 751 | depends on BLOCK |
752 | select USB_LIBCOMPOSITE | ||
758 | help | 753 | help |
759 | The Mass Storage Gadget acts as a USB Mass Storage disk drive. | 754 | The Mass Storage Gadget acts as a USB Mass Storage disk drive. |
760 | As its storage repository it can use a regular file or a block | 755 | As its storage repository it can use a regular file or a block |
@@ -770,6 +765,7 @@ config USB_MASS_STORAGE | |||
770 | config USB_GADGET_TARGET | 765 | config USB_GADGET_TARGET |
771 | tristate "USB Gadget Target Fabric Module" | 766 | tristate "USB Gadget Target Fabric Module" |
772 | depends on TARGET_CORE | 767 | depends on TARGET_CORE |
768 | select USB_LIBCOMPOSITE | ||
773 | help | 769 | help |
774 | This fabric is an USB gadget. Two USB protocols are supported that is | 770 | This fabric is an USB gadget. Two USB protocols are supported that is |
775 | BBB or BOT (Bulk Only Transport) and UAS (USB Attached SCSI). BOT is | 771 | BBB or BOT (Bulk Only Transport) and UAS (USB Attached SCSI). BOT is |
@@ -779,6 +775,7 @@ config USB_GADGET_TARGET | |||
779 | 775 | ||
780 | config USB_G_SERIAL | 776 | config USB_G_SERIAL |
781 | tristate "Serial Gadget (with CDC ACM and CDC OBEX support)" | 777 | tristate "Serial Gadget (with CDC ACM and CDC OBEX support)" |
778 | select USB_LIBCOMPOSITE | ||
782 | help | 779 | help |
783 | The Serial Gadget talks to the Linux-USB generic serial driver. | 780 | The Serial Gadget talks to the Linux-USB generic serial driver. |
784 | This driver supports a CDC-ACM module option, which can be used | 781 | This driver supports a CDC-ACM module option, which can be used |
@@ -797,8 +794,9 @@ config USB_G_SERIAL | |||
797 | make MS-Windows work with CDC ACM. | 794 | make MS-Windows work with CDC ACM. |
798 | 795 | ||
799 | config USB_MIDI_GADGET | 796 | config USB_MIDI_GADGET |
800 | tristate "MIDI Gadget (EXPERIMENTAL)" | 797 | tristate "MIDI Gadget" |
801 | depends on SND && EXPERIMENTAL | 798 | depends on SND |
799 | select USB_LIBCOMPOSITE | ||
802 | select SND_RAWMIDI | 800 | select SND_RAWMIDI |
803 | help | 801 | help |
804 | The MIDI Gadget acts as a USB Audio device, with one MIDI | 802 | The MIDI Gadget acts as a USB Audio device, with one MIDI |
@@ -812,6 +810,7 @@ config USB_MIDI_GADGET | |||
812 | 810 | ||
813 | config USB_G_PRINTER | 811 | config USB_G_PRINTER |
814 | tristate "Printer Gadget" | 812 | tristate "Printer Gadget" |
813 | select USB_LIBCOMPOSITE | ||
815 | help | 814 | help |
816 | The Printer Gadget channels data between the USB host and a | 815 | The Printer Gadget channels data between the USB host and a |
817 | userspace program driving the print engine. The user space | 816 | userspace program driving the print engine. The user space |
@@ -828,6 +827,7 @@ config USB_G_PRINTER | |||
828 | config USB_CDC_COMPOSITE | 827 | config USB_CDC_COMPOSITE |
829 | tristate "CDC Composite Device (Ethernet and ACM)" | 828 | tristate "CDC Composite Device (Ethernet and ACM)" |
830 | depends on NET | 829 | depends on NET |
830 | select USB_LIBCOMPOSITE | ||
831 | help | 831 | help |
832 | This driver provides two functions in one configuration: | 832 | This driver provides two functions in one configuration: |
833 | a CDC Ethernet (ECM) link, and a CDC ACM (serial port) link. | 833 | a CDC Ethernet (ECM) link, and a CDC ACM (serial port) link. |
@@ -842,6 +842,7 @@ config USB_CDC_COMPOSITE | |||
842 | config USB_G_NOKIA | 842 | config USB_G_NOKIA |
843 | tristate "Nokia composite gadget" | 843 | tristate "Nokia composite gadget" |
844 | depends on PHONET | 844 | depends on PHONET |
845 | select USB_LIBCOMPOSITE | ||
845 | help | 846 | help |
846 | The Nokia composite gadget provides support for acm, obex | 847 | The Nokia composite gadget provides support for acm, obex |
847 | and phonet in only one composite gadget driver. | 848 | and phonet in only one composite gadget driver. |
@@ -852,6 +853,7 @@ config USB_G_NOKIA | |||
852 | config USB_G_ACM_MS | 853 | config USB_G_ACM_MS |
853 | tristate "CDC Composite Device (ACM and mass storage)" | 854 | tristate "CDC Composite Device (ACM and mass storage)" |
854 | depends on BLOCK | 855 | depends on BLOCK |
856 | select USB_LIBCOMPOSITE | ||
855 | help | 857 | help |
856 | This driver provides two functions in one configuration: | 858 | This driver provides two functions in one configuration: |
857 | a mass storage, and a CDC ACM (serial port) link. | 859 | a mass storage, and a CDC ACM (serial port) link. |
@@ -860,9 +862,10 @@ config USB_G_ACM_MS | |||
860 | dynamically linked module called "g_acm_ms". | 862 | dynamically linked module called "g_acm_ms". |
861 | 863 | ||
862 | config USB_G_MULTI | 864 | config USB_G_MULTI |
863 | tristate "Multifunction Composite Gadget (EXPERIMENTAL)" | 865 | tristate "Multifunction Composite Gadget" |
864 | depends on BLOCK && NET | 866 | depends on BLOCK && NET |
865 | select USB_G_MULTI_CDC if !USB_G_MULTI_RNDIS | 867 | select USB_G_MULTI_CDC if !USB_G_MULTI_RNDIS |
868 | select USB_LIBCOMPOSITE | ||
866 | help | 869 | help |
867 | The Multifunction Composite Gadget provides Ethernet (RNDIS | 870 | The Multifunction Composite Gadget provides Ethernet (RNDIS |
868 | and/or CDC Ethernet), mass storage and ACM serial link | 871 | and/or CDC Ethernet), mass storage and ACM serial link |
@@ -903,6 +906,7 @@ config USB_G_MULTI_CDC | |||
903 | 906 | ||
904 | config USB_G_HID | 907 | config USB_G_HID |
905 | tristate "HID Gadget" | 908 | tristate "HID Gadget" |
909 | select USB_LIBCOMPOSITE | ||
906 | help | 910 | help |
907 | The HID gadget driver provides generic emulation of USB | 911 | The HID gadget driver provides generic emulation of USB |
908 | Human Interface Devices (HID). | 912 | Human Interface Devices (HID). |
@@ -913,8 +917,10 @@ config USB_G_HID | |||
913 | Say "y" to link the driver statically, or "m" to build a | 917 | Say "y" to link the driver statically, or "m" to build a |
914 | dynamically linked module called "g_hid". | 918 | dynamically linked module called "g_hid". |
915 | 919 | ||
920 | # Standalone / single function gadgets | ||
916 | config USB_G_DBGP | 921 | config USB_G_DBGP |
917 | tristate "EHCI Debug Device Gadget" | 922 | tristate "EHCI Debug Device Gadget" |
923 | select USB_LIBCOMPOSITE | ||
918 | help | 924 | help |
919 | This gadget emulates an EHCI Debug device. This is useful when you want | 925 | This gadget emulates an EHCI Debug device. This is useful when you want |
920 | to interact with an EHCI Debug Port. | 926 | to interact with an EHCI Debug Port. |
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile index 3fd8cd09d2c1..307be5fa824c 100644 --- a/drivers/usb/gadget/Makefile +++ b/drivers/usb/gadget/Makefile | |||
@@ -4,6 +4,9 @@ | |||
4 | ccflags-$(CONFIG_USB_GADGET_DEBUG) := -DDEBUG | 4 | ccflags-$(CONFIG_USB_GADGET_DEBUG) := -DDEBUG |
5 | 5 | ||
6 | obj-$(CONFIG_USB_GADGET) += udc-core.o | 6 | obj-$(CONFIG_USB_GADGET) += udc-core.o |
7 | obj-$(CONFIG_USB_LIBCOMPOSITE) += libcomposite.o | ||
8 | libcomposite-y := usbstring.o config.o epautoconf.o | ||
9 | libcomposite-y += composite.o | ||
7 | obj-$(CONFIG_USB_DUMMY_HCD) += dummy_hcd.o | 10 | obj-$(CONFIG_USB_DUMMY_HCD) += dummy_hcd.o |
8 | obj-$(CONFIG_USB_NET2272) += net2272.o | 11 | obj-$(CONFIG_USB_NET2272) += net2272.o |
9 | obj-$(CONFIG_USB_NET2280) += net2280.o | 12 | obj-$(CONFIG_USB_NET2280) += net2280.o |
@@ -16,6 +19,7 @@ obj-$(CONFIG_USB_OMAP) += omap_udc.o | |||
16 | obj-$(CONFIG_USB_S3C2410) += s3c2410_udc.o | 19 | obj-$(CONFIG_USB_S3C2410) += s3c2410_udc.o |
17 | obj-$(CONFIG_USB_AT91) += at91_udc.o | 20 | obj-$(CONFIG_USB_AT91) += at91_udc.o |
18 | obj-$(CONFIG_USB_ATMEL_USBA) += atmel_usba_udc.o | 21 | obj-$(CONFIG_USB_ATMEL_USBA) += atmel_usba_udc.o |
22 | obj-$(CONFIG_USB_BCM63XX_UDC) += bcm63xx_udc.o | ||
19 | obj-$(CONFIG_USB_FSL_USB2) += fsl_usb2_udc.o | 23 | obj-$(CONFIG_USB_FSL_USB2) += fsl_usb2_udc.o |
20 | fsl_usb2_udc-y := fsl_udc_core.o | 24 | fsl_usb2_udc-y := fsl_udc_core.o |
21 | fsl_usb2_udc-$(CONFIG_ARCH_MXC) += fsl_mxc_udc.o | 25 | fsl_usb2_udc-$(CONFIG_ARCH_MXC) += fsl_mxc_udc.o |
diff --git a/drivers/usb/gadget/acm_ms.c b/drivers/usb/gadget/acm_ms.c index 75b8a691fd00..5a7f289805ff 100644 --- a/drivers/usb/gadget/acm_ms.c +++ b/drivers/usb/gadget/acm_ms.c | |||
@@ -15,7 +15,7 @@ | |||
15 | */ | 15 | */ |
16 | 16 | ||
17 | #include <linux/kernel.h> | 17 | #include <linux/kernel.h> |
18 | #include <linux/utsname.h> | 18 | #include <linux/module.h> |
19 | 19 | ||
20 | #include "u_serial.h" | 20 | #include "u_serial.h" |
21 | 21 | ||
@@ -41,15 +41,12 @@ | |||
41 | * a "gcc --combine ... part1.c part2.c part3.c ... " build would. | 41 | * a "gcc --combine ... part1.c part2.c part3.c ... " build would. |
42 | */ | 42 | */ |
43 | 43 | ||
44 | #include "composite.c" | ||
45 | #include "usbstring.c" | ||
46 | #include "config.c" | ||
47 | #include "epautoconf.c" | ||
48 | #include "u_serial.c" | 44 | #include "u_serial.c" |
49 | #include "f_acm.c" | 45 | #include "f_acm.c" |
50 | #include "f_mass_storage.c" | 46 | #include "f_mass_storage.c" |
51 | 47 | ||
52 | /*-------------------------------------------------------------------------*/ | 48 | /*-------------------------------------------------------------------------*/ |
49 | USB_GADGET_COMPOSITE_OPTIONS(); | ||
53 | 50 | ||
54 | static struct usb_device_descriptor device_desc = { | 51 | static struct usb_device_descriptor device_desc = { |
55 | .bLength = sizeof device_desc, | 52 | .bLength = sizeof device_desc, |
@@ -89,17 +86,11 @@ static const struct usb_descriptor_header *otg_desc[] = { | |||
89 | NULL, | 86 | NULL, |
90 | }; | 87 | }; |
91 | 88 | ||
92 | |||
93 | /* string IDs are assigned dynamically */ | 89 | /* string IDs are assigned dynamically */ |
94 | |||
95 | #define STRING_MANUFACTURER_IDX 0 | ||
96 | #define STRING_PRODUCT_IDX 1 | ||
97 | |||
98 | static char manufacturer[50]; | ||
99 | |||
100 | static struct usb_string strings_dev[] = { | 90 | static struct usb_string strings_dev[] = { |
101 | [STRING_MANUFACTURER_IDX].s = manufacturer, | 91 | [USB_GADGET_MANUFACTURER_IDX].s = "", |
102 | [STRING_PRODUCT_IDX].s = DRIVER_DESC, | 92 | [USB_GADGET_PRODUCT_IDX].s = DRIVER_DESC, |
93 | [USB_GADGET_SERIAL_IDX].s = "", | ||
103 | { } /* end of list */ | 94 | { } /* end of list */ |
104 | }; | 95 | }; |
105 | 96 | ||
@@ -157,7 +148,6 @@ static struct usb_configuration acm_ms_config_driver = { | |||
157 | 148 | ||
158 | static int __init acm_ms_bind(struct usb_composite_dev *cdev) | 149 | static int __init acm_ms_bind(struct usb_composite_dev *cdev) |
159 | { | 150 | { |
160 | int gcnum; | ||
161 | struct usb_gadget *gadget = cdev->gadget; | 151 | struct usb_gadget *gadget = cdev->gadget; |
162 | int status; | 152 | int status; |
163 | void *retp; | 153 | void *retp; |
@@ -174,44 +164,22 @@ static int __init acm_ms_bind(struct usb_composite_dev *cdev) | |||
174 | goto fail0; | 164 | goto fail0; |
175 | } | 165 | } |
176 | 166 | ||
177 | /* set bcdDevice */ | ||
178 | gcnum = usb_gadget_controller_number(gadget); | ||
179 | if (gcnum >= 0) { | ||
180 | device_desc.bcdDevice = cpu_to_le16(0x0300 | gcnum); | ||
181 | } else { | ||
182 | WARNING(cdev, "controller '%s' not recognized; trying %s\n", | ||
183 | gadget->name, | ||
184 | acm_ms_config_driver.label); | ||
185 | device_desc.bcdDevice = | ||
186 | cpu_to_le16(0x0300 | 0x0099); | ||
187 | } | ||
188 | |||
189 | /* | 167 | /* |
190 | * Allocate string descriptor numbers ... note that string | 168 | * Allocate string descriptor numbers ... note that string |
191 | * contents can be overridden by the composite_dev glue. | 169 | * contents can be overridden by the composite_dev glue. |
192 | */ | 170 | */ |
193 | 171 | status = usb_string_ids_tab(cdev, strings_dev); | |
194 | /* device descriptor strings: manufacturer, product */ | ||
195 | snprintf(manufacturer, sizeof manufacturer, "%s %s with %s", | ||
196 | init_utsname()->sysname, init_utsname()->release, | ||
197 | gadget->name); | ||
198 | status = usb_string_id(cdev); | ||
199 | if (status < 0) | ||
200 | goto fail1; | ||
201 | strings_dev[STRING_MANUFACTURER_IDX].id = status; | ||
202 | device_desc.iManufacturer = status; | ||
203 | |||
204 | status = usb_string_id(cdev); | ||
205 | if (status < 0) | 172 | if (status < 0) |
206 | goto fail1; | 173 | goto fail1; |
207 | strings_dev[STRING_PRODUCT_IDX].id = status; | 174 | device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id; |
208 | device_desc.iProduct = status; | 175 | device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; |
209 | 176 | ||
210 | /* register our configuration */ | 177 | /* register our configuration */ |
211 | status = usb_add_config(cdev, &acm_ms_config_driver, acm_ms_do_config); | 178 | status = usb_add_config(cdev, &acm_ms_config_driver, acm_ms_do_config); |
212 | if (status < 0) | 179 | if (status < 0) |
213 | goto fail1; | 180 | goto fail1; |
214 | 181 | ||
182 | usb_composite_overwrite_options(cdev, &coverwrite); | ||
215 | dev_info(&gadget->dev, "%s, version: " DRIVER_VERSION "\n", | 183 | dev_info(&gadget->dev, "%s, version: " DRIVER_VERSION "\n", |
216 | DRIVER_DESC); | 184 | DRIVER_DESC); |
217 | fsg_common_put(&fsg_common); | 185 | fsg_common_put(&fsg_common); |
@@ -232,11 +200,12 @@ static int __exit acm_ms_unbind(struct usb_composite_dev *cdev) | |||
232 | return 0; | 200 | return 0; |
233 | } | 201 | } |
234 | 202 | ||
235 | static struct usb_composite_driver acm_ms_driver = { | 203 | static __refdata struct usb_composite_driver acm_ms_driver = { |
236 | .name = "g_acm_ms", | 204 | .name = "g_acm_ms", |
237 | .dev = &device_desc, | 205 | .dev = &device_desc, |
238 | .max_speed = USB_SPEED_SUPER, | 206 | .max_speed = USB_SPEED_SUPER, |
239 | .strings = dev_strings, | 207 | .strings = dev_strings, |
208 | .bind = acm_ms_bind, | ||
240 | .unbind = __exit_p(acm_ms_unbind), | 209 | .unbind = __exit_p(acm_ms_unbind), |
241 | }; | 210 | }; |
242 | 211 | ||
@@ -246,7 +215,7 @@ MODULE_LICENSE("GPL v2"); | |||
246 | 215 | ||
247 | static int __init init(void) | 216 | static int __init init(void) |
248 | { | 217 | { |
249 | return usb_composite_probe(&acm_ms_driver, acm_ms_bind); | 218 | return usb_composite_probe(&acm_ms_driver); |
250 | } | 219 | } |
251 | module_init(init); | 220 | module_init(init); |
252 | 221 | ||
diff --git a/drivers/usb/gadget/amd5536udc.c b/drivers/usb/gadget/amd5536udc.c index 187d21181cd5..fc0ec5e0d58e 100644 --- a/drivers/usb/gadget/amd5536udc.c +++ b/drivers/usb/gadget/amd5536udc.c | |||
@@ -1401,7 +1401,7 @@ static int udc_wakeup(struct usb_gadget *gadget) | |||
1401 | } | 1401 | } |
1402 | 1402 | ||
1403 | static int amd5536_start(struct usb_gadget_driver *driver, | 1403 | static int amd5536_start(struct usb_gadget_driver *driver, |
1404 | int (*bind)(struct usb_gadget *)); | 1404 | int (*bind)(struct usb_gadget *, struct usb_gadget_driver *)); |
1405 | static int amd5536_stop(struct usb_gadget_driver *driver); | 1405 | static int amd5536_stop(struct usb_gadget_driver *driver); |
1406 | /* gadget operations */ | 1406 | /* gadget operations */ |
1407 | static const struct usb_gadget_ops udc_ops = { | 1407 | static const struct usb_gadget_ops udc_ops = { |
@@ -1914,7 +1914,7 @@ static int setup_ep0(struct udc *dev) | |||
1914 | 1914 | ||
1915 | /* Called by gadget driver to register itself */ | 1915 | /* Called by gadget driver to register itself */ |
1916 | static int amd5536_start(struct usb_gadget_driver *driver, | 1916 | static int amd5536_start(struct usb_gadget_driver *driver, |
1917 | int (*bind)(struct usb_gadget *)) | 1917 | int (*bind)(struct usb_gadget *, struct usb_gadget_driver *)) |
1918 | { | 1918 | { |
1919 | struct udc *dev = udc; | 1919 | struct udc *dev = udc; |
1920 | int retval; | 1920 | int retval; |
@@ -1932,7 +1932,7 @@ static int amd5536_start(struct usb_gadget_driver *driver, | |||
1932 | dev->driver = driver; | 1932 | dev->driver = driver; |
1933 | dev->gadget.dev.driver = &driver->driver; | 1933 | dev->gadget.dev.driver = &driver->driver; |
1934 | 1934 | ||
1935 | retval = bind(&dev->gadget); | 1935 | retval = bind(&dev->gadget, driver); |
1936 | 1936 | ||
1937 | /* Some gadget drivers use both ep0 directions. | 1937 | /* Some gadget drivers use both ep0 directions. |
1938 | * NOTE: to gadget driver, ep0 is just one endpoint... | 1938 | * NOTE: to gadget driver, ep0 is just one endpoint... |
diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c index 1e35963bd4ed..89d90b5fb787 100644 --- a/drivers/usb/gadget/at91_udc.c +++ b/drivers/usb/gadget/at91_udc.c | |||
@@ -469,7 +469,7 @@ static int at91_ep_enable(struct usb_ep *_ep, | |||
469 | const struct usb_endpoint_descriptor *desc) | 469 | const struct usb_endpoint_descriptor *desc) |
470 | { | 470 | { |
471 | struct at91_ep *ep = container_of(_ep, struct at91_ep, ep); | 471 | struct at91_ep *ep = container_of(_ep, struct at91_ep, ep); |
472 | struct at91_udc *udc = ep->udc; | 472 | struct at91_udc *udc; |
473 | u16 maxpacket; | 473 | u16 maxpacket; |
474 | u32 tmp; | 474 | u32 tmp; |
475 | unsigned long flags; | 475 | unsigned long flags; |
@@ -483,6 +483,7 @@ static int at91_ep_enable(struct usb_ep *_ep, | |||
483 | return -EINVAL; | 483 | return -EINVAL; |
484 | } | 484 | } |
485 | 485 | ||
486 | udc = ep->udc; | ||
486 | if (!udc->driver || udc->gadget.speed == USB_SPEED_UNKNOWN) { | 487 | if (!udc->driver || udc->gadget.speed == USB_SPEED_UNKNOWN) { |
487 | DBG("bogus device state\n"); | 488 | DBG("bogus device state\n"); |
488 | return -ESHUTDOWN; | 489 | return -ESHUTDOWN; |
@@ -1699,7 +1700,7 @@ static int __devinit at91udc_probe(struct platform_device *pdev) | |||
1699 | int retval; | 1700 | int retval; |
1700 | struct resource *res; | 1701 | struct resource *res; |
1701 | 1702 | ||
1702 | if (!dev->platform_data) { | 1703 | if (!dev->platform_data && !pdev->dev.of_node) { |
1703 | /* small (so we copy it) but critical! */ | 1704 | /* small (so we copy it) but critical! */ |
1704 | DBG("missing platform_data\n"); | 1705 | DBG("missing platform_data\n"); |
1705 | return -ENODEV; | 1706 | return -ENODEV; |
diff --git a/drivers/usb/gadget/audio.c b/drivers/usb/gadget/audio.c index 98899244860e..231b0efe8fdc 100644 --- a/drivers/usb/gadget/audio.c +++ b/drivers/usb/gadget/audio.c | |||
@@ -12,35 +12,21 @@ | |||
12 | /* #define VERBOSE_DEBUG */ | 12 | /* #define VERBOSE_DEBUG */ |
13 | 13 | ||
14 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
15 | #include <linux/utsname.h> | 15 | #include <linux/module.h> |
16 | #include <linux/usb/composite.h> | ||
16 | 17 | ||
18 | #include "gadget_chips.h" | ||
17 | #define DRIVER_DESC "Linux USB Audio Gadget" | 19 | #define DRIVER_DESC "Linux USB Audio Gadget" |
18 | #define DRIVER_VERSION "Feb 2, 2012" | 20 | #define DRIVER_VERSION "Feb 2, 2012" |
19 | 21 | ||
20 | /*-------------------------------------------------------------------------*/ | 22 | USB_GADGET_COMPOSITE_OPTIONS(); |
21 | |||
22 | /* | ||
23 | * Kbuild is not very cooperative with respect to linking separately | ||
24 | * compiled library objects into one module. So for now we won't use | ||
25 | * separate compilation ... ensuring init/exit sections work to shrink | ||
26 | * the runtime footprint, and giving us at least some parts of what | ||
27 | * a "gcc --combine ... part1.c part2.c part3.c ... " build would. | ||
28 | */ | ||
29 | #include "composite.c" | ||
30 | #include "usbstring.c" | ||
31 | #include "config.c" | ||
32 | #include "epautoconf.c" | ||
33 | 23 | ||
34 | /* string IDs are assigned dynamically */ | 24 | /* string IDs are assigned dynamically */ |
35 | 25 | ||
36 | #define STRING_MANUFACTURER_IDX 0 | ||
37 | #define STRING_PRODUCT_IDX 1 | ||
38 | |||
39 | static char manufacturer[50]; | ||
40 | |||
41 | static struct usb_string strings_dev[] = { | 26 | static struct usb_string strings_dev[] = { |
42 | [STRING_MANUFACTURER_IDX].s = manufacturer, | 27 | [USB_GADGET_MANUFACTURER_IDX].s = "", |
43 | [STRING_PRODUCT_IDX].s = DRIVER_DESC, | 28 | [USB_GADGET_PRODUCT_IDX].s = DRIVER_DESC, |
29 | [USB_GADGET_SERIAL_IDX].s = "", | ||
44 | { } /* end of list */ | 30 | { } /* end of list */ |
45 | }; | 31 | }; |
46 | 32 | ||
@@ -149,39 +135,18 @@ static struct usb_configuration audio_config_driver = { | |||
149 | 135 | ||
150 | static int __init audio_bind(struct usb_composite_dev *cdev) | 136 | static int __init audio_bind(struct usb_composite_dev *cdev) |
151 | { | 137 | { |
152 | int gcnum; | ||
153 | int status; | 138 | int status; |
154 | 139 | ||
155 | gcnum = usb_gadget_controller_number(cdev->gadget); | 140 | status = usb_string_ids_tab(cdev, strings_dev); |
156 | if (gcnum >= 0) | ||
157 | device_desc.bcdDevice = cpu_to_le16(0x0300 | gcnum); | ||
158 | else { | ||
159 | ERROR(cdev, "controller '%s' not recognized; trying %s\n", | ||
160 | cdev->gadget->name, | ||
161 | audio_config_driver.label); | ||
162 | device_desc.bcdDevice = | ||
163 | __constant_cpu_to_le16(0x0300 | 0x0099); | ||
164 | } | ||
165 | |||
166 | /* device descriptor strings: manufacturer, product */ | ||
167 | snprintf(manufacturer, sizeof manufacturer, "%s %s with %s", | ||
168 | init_utsname()->sysname, init_utsname()->release, | ||
169 | cdev->gadget->name); | ||
170 | status = usb_string_id(cdev); | ||
171 | if (status < 0) | ||
172 | goto fail; | ||
173 | strings_dev[STRING_MANUFACTURER_IDX].id = status; | ||
174 | device_desc.iManufacturer = status; | ||
175 | |||
176 | status = usb_string_id(cdev); | ||
177 | if (status < 0) | 141 | if (status < 0) |
178 | goto fail; | 142 | goto fail; |
179 | strings_dev[STRING_PRODUCT_IDX].id = status; | 143 | device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id; |
180 | device_desc.iProduct = status; | 144 | device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; |
181 | 145 | ||
182 | status = usb_add_config(cdev, &audio_config_driver, audio_do_config); | 146 | status = usb_add_config(cdev, &audio_config_driver, audio_do_config); |
183 | if (status < 0) | 147 | if (status < 0) |
184 | goto fail; | 148 | goto fail; |
149 | usb_composite_overwrite_options(cdev, &coverwrite); | ||
185 | 150 | ||
186 | INFO(cdev, "%s, version: %s\n", DRIVER_DESC, DRIVER_VERSION); | 151 | INFO(cdev, "%s, version: %s\n", DRIVER_DESC, DRIVER_VERSION); |
187 | return 0; | 152 | return 0; |
@@ -198,17 +163,18 @@ static int __exit audio_unbind(struct usb_composite_dev *cdev) | |||
198 | return 0; | 163 | return 0; |
199 | } | 164 | } |
200 | 165 | ||
201 | static struct usb_composite_driver audio_driver = { | 166 | static __refdata struct usb_composite_driver audio_driver = { |
202 | .name = "g_audio", | 167 | .name = "g_audio", |
203 | .dev = &device_desc, | 168 | .dev = &device_desc, |
204 | .strings = audio_strings, | 169 | .strings = audio_strings, |
205 | .max_speed = USB_SPEED_HIGH, | 170 | .max_speed = USB_SPEED_HIGH, |
171 | .bind = audio_bind, | ||
206 | .unbind = __exit_p(audio_unbind), | 172 | .unbind = __exit_p(audio_unbind), |
207 | }; | 173 | }; |
208 | 174 | ||
209 | static int __init init(void) | 175 | static int __init init(void) |
210 | { | 176 | { |
211 | return usb_composite_probe(&audio_driver, audio_bind); | 177 | return usb_composite_probe(&audio_driver); |
212 | } | 178 | } |
213 | module_init(init); | 179 | module_init(init); |
214 | 180 | ||
diff --git a/drivers/usb/gadget/bcm63xx_udc.c b/drivers/usb/gadget/bcm63xx_udc.c new file mode 100644 index 000000000000..9ca792224cd4 --- /dev/null +++ b/drivers/usb/gadget/bcm63xx_udc.c | |||
@@ -0,0 +1,2464 @@ | |||
1 | /* | ||
2 | * bcm63xx_udc.c -- BCM63xx UDC high/full speed USB device controller | ||
3 | * | ||
4 | * Copyright (C) 2012 Kevin Cernekee <cernekee@gmail.com> | ||
5 | * Copyright (C) 2012 Broadcom Corporation | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
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 | ||
10 | * (at your option) any later version. | ||
11 | */ | ||
12 | |||
13 | #include <linux/bitops.h> | ||
14 | #include <linux/bug.h> | ||
15 | #include <linux/clk.h> | ||
16 | #include <linux/compiler.h> | ||
17 | #include <linux/debugfs.h> | ||
18 | #include <linux/delay.h> | ||
19 | #include <linux/device.h> | ||
20 | #include <linux/dma-mapping.h> | ||
21 | #include <linux/errno.h> | ||
22 | #include <linux/init.h> | ||
23 | #include <linux/interrupt.h> | ||
24 | #include <linux/ioport.h> | ||
25 | #include <linux/kconfig.h> | ||
26 | #include <linux/kernel.h> | ||
27 | #include <linux/list.h> | ||
28 | #include <linux/module.h> | ||
29 | #include <linux/moduleparam.h> | ||
30 | #include <linux/platform_device.h> | ||
31 | #include <linux/sched.h> | ||
32 | #include <linux/seq_file.h> | ||
33 | #include <linux/slab.h> | ||
34 | #include <linux/timer.h> | ||
35 | #include <linux/usb/ch9.h> | ||
36 | #include <linux/usb/gadget.h> | ||
37 | #include <linux/workqueue.h> | ||
38 | |||
39 | #include <bcm63xx_cpu.h> | ||
40 | #include <bcm63xx_iudma.h> | ||
41 | #include <bcm63xx_dev_usb_usbd.h> | ||
42 | #include <bcm63xx_io.h> | ||
43 | #include <bcm63xx_regs.h> | ||
44 | |||
45 | #define DRV_MODULE_NAME "bcm63xx_udc" | ||
46 | |||
47 | static const char bcm63xx_ep0name[] = "ep0"; | ||
48 | static const char *const bcm63xx_ep_name[] = { | ||
49 | bcm63xx_ep0name, | ||
50 | "ep1in-bulk", "ep2out-bulk", "ep3in-int", "ep4out-int", | ||
51 | }; | ||
52 | |||
53 | static bool use_fullspeed; | ||
54 | module_param(use_fullspeed, bool, S_IRUGO); | ||
55 | MODULE_PARM_DESC(use_fullspeed, "true for fullspeed only"); | ||
56 | |||
57 | /* | ||
58 | * RX IRQ coalescing options: | ||
59 | * | ||
60 | * false (default) - one IRQ per DATAx packet. Slow but reliable. The | ||
61 | * driver is able to pass the "testusb" suite and recover from conditions like: | ||
62 | * | ||
63 | * 1) Device queues up a 2048-byte RX IUDMA transaction on an OUT bulk ep | ||
64 | * 2) Host sends 512 bytes of data | ||
65 | * 3) Host decides to reconfigure the device and sends SET_INTERFACE | ||
66 | * 4) Device shuts down the endpoint and cancels the RX transaction | ||
67 | * | ||
68 | * true - one IRQ per transfer, for transfers <= 2048B. Generates | ||
69 | * considerably fewer IRQs, but error recovery is less robust. Does not | ||
70 | * reliably pass "testusb". | ||
71 | * | ||
72 | * TX always uses coalescing, because we can cancel partially complete TX | ||
73 | * transfers by repeatedly flushing the FIFO. The hardware doesn't allow | ||
74 | * this on RX. | ||
75 | */ | ||
76 | static bool irq_coalesce; | ||
77 | module_param(irq_coalesce, bool, S_IRUGO); | ||
78 | MODULE_PARM_DESC(irq_coalesce, "take one IRQ per RX transfer"); | ||
79 | |||
80 | #define BCM63XX_NUM_EP 5 | ||
81 | #define BCM63XX_NUM_IUDMA 6 | ||
82 | #define BCM63XX_NUM_FIFO_PAIRS 3 | ||
83 | |||
84 | #define IUDMA_RESET_TIMEOUT_US 10000 | ||
85 | |||
86 | #define IUDMA_EP0_RXCHAN 0 | ||
87 | #define IUDMA_EP0_TXCHAN 1 | ||
88 | |||
89 | #define IUDMA_MAX_FRAGMENT 2048 | ||
90 | #define BCM63XX_MAX_CTRL_PKT 64 | ||
91 | |||
92 | #define BCMEP_CTRL 0x00 | ||
93 | #define BCMEP_ISOC 0x01 | ||
94 | #define BCMEP_BULK 0x02 | ||
95 | #define BCMEP_INTR 0x03 | ||
96 | |||
97 | #define BCMEP_OUT 0x00 | ||
98 | #define BCMEP_IN 0x01 | ||
99 | |||
100 | #define BCM63XX_SPD_FULL 1 | ||
101 | #define BCM63XX_SPD_HIGH 0 | ||
102 | |||
103 | #define IUDMA_DMAC_OFFSET 0x200 | ||
104 | #define IUDMA_DMAS_OFFSET 0x400 | ||
105 | |||
106 | enum bcm63xx_ep0_state { | ||
107 | EP0_REQUEUE, | ||
108 | EP0_IDLE, | ||
109 | EP0_IN_DATA_PHASE_SETUP, | ||
110 | EP0_IN_DATA_PHASE_COMPLETE, | ||
111 | EP0_OUT_DATA_PHASE_SETUP, | ||
112 | EP0_OUT_DATA_PHASE_COMPLETE, | ||
113 | EP0_OUT_STATUS_PHASE, | ||
114 | EP0_IN_FAKE_STATUS_PHASE, | ||
115 | EP0_SHUTDOWN, | ||
116 | }; | ||
117 | |||
118 | static const char __maybe_unused bcm63xx_ep0_state_names[][32] = { | ||
119 | "REQUEUE", | ||
120 | "IDLE", | ||
121 | "IN_DATA_PHASE_SETUP", | ||
122 | "IN_DATA_PHASE_COMPLETE", | ||
123 | "OUT_DATA_PHASE_SETUP", | ||
124 | "OUT_DATA_PHASE_COMPLETE", | ||
125 | "OUT_STATUS_PHASE", | ||
126 | "IN_FAKE_STATUS_PHASE", | ||
127 | "SHUTDOWN", | ||
128 | }; | ||
129 | |||
130 | /** | ||
131 | * struct iudma_ch_cfg - Static configuration for an IUDMA channel. | ||
132 | * @ep_num: USB endpoint number. | ||
133 | * @n_bds: Number of buffer descriptors in the ring. | ||
134 | * @ep_type: Endpoint type (control, bulk, interrupt). | ||
135 | * @dir: Direction (in, out). | ||
136 | * @n_fifo_slots: Number of FIFO entries to allocate for this channel. | ||
137 | * @max_pkt_hs: Maximum packet size in high speed mode. | ||
138 | * @max_pkt_fs: Maximum packet size in full speed mode. | ||
139 | */ | ||
140 | struct iudma_ch_cfg { | ||
141 | int ep_num; | ||
142 | int n_bds; | ||
143 | int ep_type; | ||
144 | int dir; | ||
145 | int n_fifo_slots; | ||
146 | int max_pkt_hs; | ||
147 | int max_pkt_fs; | ||
148 | }; | ||
149 | |||
150 | static const struct iudma_ch_cfg iudma_defaults[] = { | ||
151 | |||
152 | /* This controller was designed to support a CDC/RNDIS application. | ||
153 | It may be possible to reconfigure some of the endpoints, but | ||
154 | the hardware limitations (FIFO sizing and number of DMA channels) | ||
155 | may significantly impact flexibility and/or stability. Change | ||
156 | these values at your own risk. | ||
157 | |||
158 | ep_num ep_type n_fifo_slots max_pkt_fs | ||
159 | idx | n_bds | dir | max_pkt_hs | | ||
160 | | | | | | | | | */ | ||
161 | [0] = { -1, 4, BCMEP_CTRL, BCMEP_OUT, 32, 64, 64 }, | ||
162 | [1] = { 0, 4, BCMEP_CTRL, BCMEP_OUT, 32, 64, 64 }, | ||
163 | [2] = { 2, 16, BCMEP_BULK, BCMEP_OUT, 128, 512, 64 }, | ||
164 | [3] = { 1, 16, BCMEP_BULK, BCMEP_IN, 128, 512, 64 }, | ||
165 | [4] = { 4, 4, BCMEP_INTR, BCMEP_OUT, 32, 64, 64 }, | ||
166 | [5] = { 3, 4, BCMEP_INTR, BCMEP_IN, 32, 64, 64 }, | ||
167 | }; | ||
168 | |||
169 | struct bcm63xx_udc; | ||
170 | |||
171 | /** | ||
172 | * struct iudma_ch - Represents the current state of a single IUDMA channel. | ||
173 | * @ch_idx: IUDMA channel index (0 to BCM63XX_NUM_IUDMA-1). | ||
174 | * @ep_num: USB endpoint number. -1 for ep0 RX. | ||
175 | * @enabled: Whether bcm63xx_ep_enable() has been called. | ||
176 | * @max_pkt: "Chunk size" on the USB interface. Based on interface speed. | ||
177 | * @is_tx: true for TX, false for RX. | ||
178 | * @bep: Pointer to the associated endpoint. NULL for ep0 RX. | ||
179 | * @udc: Reference to the device controller. | ||
180 | * @read_bd: Next buffer descriptor to reap from the hardware. | ||
181 | * @write_bd: Next BD available for a new packet. | ||
182 | * @end_bd: Points to the final BD in the ring. | ||
183 | * @n_bds_used: Number of BD entries currently occupied. | ||
184 | * @bd_ring: Base pointer to the BD ring. | ||
185 | * @bd_ring_dma: Physical (DMA) address of bd_ring. | ||
186 | * @n_bds: Total number of BDs in the ring. | ||
187 | * | ||
188 | * ep0 has two IUDMA channels (IUDMA_EP0_RXCHAN and IUDMA_EP0_TXCHAN), as it is | ||
189 | * bidirectional. The "struct usb_ep" associated with ep0 is for TX (IN) | ||
190 | * only. | ||
191 | * | ||
192 | * Each bulk/intr endpoint has a single IUDMA channel and a single | ||
193 | * struct usb_ep. | ||
194 | */ | ||
195 | struct iudma_ch { | ||
196 | unsigned int ch_idx; | ||
197 | int ep_num; | ||
198 | bool enabled; | ||
199 | int max_pkt; | ||
200 | bool is_tx; | ||
201 | struct bcm63xx_ep *bep; | ||
202 | struct bcm63xx_udc *udc; | ||
203 | |||
204 | struct bcm_enet_desc *read_bd; | ||
205 | struct bcm_enet_desc *write_bd; | ||
206 | struct bcm_enet_desc *end_bd; | ||
207 | int n_bds_used; | ||
208 | |||
209 | struct bcm_enet_desc *bd_ring; | ||
210 | dma_addr_t bd_ring_dma; | ||
211 | unsigned int n_bds; | ||
212 | }; | ||
213 | |||
214 | /** | ||
215 | * struct bcm63xx_ep - Internal (driver) state of a single endpoint. | ||
216 | * @ep_num: USB endpoint number. | ||
217 | * @iudma: Pointer to IUDMA channel state. | ||
218 | * @ep: USB gadget layer representation of the EP. | ||
219 | * @udc: Reference to the device controller. | ||
220 | * @queue: Linked list of outstanding requests for this EP. | ||
221 | * @halted: 1 if the EP is stalled; 0 otherwise. | ||
222 | */ | ||
223 | struct bcm63xx_ep { | ||
224 | unsigned int ep_num; | ||
225 | struct iudma_ch *iudma; | ||
226 | struct usb_ep ep; | ||
227 | struct bcm63xx_udc *udc; | ||
228 | struct list_head queue; | ||
229 | unsigned halted:1; | ||
230 | }; | ||
231 | |||
232 | /** | ||
233 | * struct bcm63xx_req - Internal (driver) state of a single request. | ||
234 | * @queue: Links back to the EP's request list. | ||
235 | * @req: USB gadget layer representation of the request. | ||
236 | * @offset: Current byte offset into the data buffer (next byte to queue). | ||
237 | * @bd_bytes: Number of data bytes in outstanding BD entries. | ||
238 | * @iudma: IUDMA channel used for the request. | ||
239 | */ | ||
240 | struct bcm63xx_req { | ||
241 | struct list_head queue; /* ep's requests */ | ||
242 | struct usb_request req; | ||
243 | unsigned int offset; | ||
244 | unsigned int bd_bytes; | ||
245 | struct iudma_ch *iudma; | ||
246 | }; | ||
247 | |||
248 | /** | ||
249 | * struct bcm63xx_udc - Driver/hardware private context. | ||
250 | * @lock: Spinlock to mediate access to this struct, and (most) HW regs. | ||
251 | * @dev: Generic Linux device structure. | ||
252 | * @pd: Platform data (board/port info). | ||
253 | * @usbd_clk: Clock descriptor for the USB device block. | ||
254 | * @usbh_clk: Clock descriptor for the USB host block. | ||
255 | * @gadget: USB slave device. | ||
256 | * @driver: Driver for USB slave devices. | ||
257 | * @usbd_regs: Base address of the USBD/USB20D block. | ||
258 | * @iudma_regs: Base address of the USBD's associated IUDMA block. | ||
259 | * @bep: Array of endpoints, including ep0. | ||
260 | * @iudma: Array of all IUDMA channels used by this controller. | ||
261 | * @cfg: USB configuration number, from SET_CONFIGURATION wValue. | ||
262 | * @iface: USB interface number, from SET_INTERFACE wIndex. | ||
263 | * @alt_iface: USB alt interface number, from SET_INTERFACE wValue. | ||
264 | * @ep0_ctrl_req: Request object for bcm63xx_udc-initiated ep0 transactions. | ||
265 | * @ep0_ctrl_buf: Data buffer for ep0_ctrl_req. | ||
266 | * @ep0state: Current state of the ep0 state machine. | ||
267 | * @ep0_wq: Workqueue struct used to wake up the ep0 state machine. | ||
268 | * @wedgemap: Bitmap of wedged endpoints. | ||
269 | * @ep0_req_reset: USB reset is pending. | ||
270 | * @ep0_req_set_cfg: Need to spoof a SET_CONFIGURATION packet. | ||
271 | * @ep0_req_set_iface: Need to spoof a SET_INTERFACE packet. | ||
272 | * @ep0_req_shutdown: Driver is shutting down; requesting ep0 to halt activity. | ||
273 | * @ep0_req_completed: ep0 request has completed; worker has not seen it yet. | ||
274 | * @ep0_reply: Pending reply from gadget driver. | ||
275 | * @ep0_request: Outstanding ep0 request. | ||
276 | * @debugfs_root: debugfs directory: /sys/kernel/debug/<DRV_MODULE_NAME>. | ||
277 | * @debugfs_usbd: debugfs file "usbd" for controller state. | ||
278 | * @debugfs_iudma: debugfs file "usbd" for IUDMA state. | ||
279 | */ | ||
280 | struct bcm63xx_udc { | ||
281 | spinlock_t lock; | ||
282 | |||
283 | struct device *dev; | ||
284 | struct bcm63xx_usbd_platform_data *pd; | ||
285 | struct clk *usbd_clk; | ||
286 | struct clk *usbh_clk; | ||
287 | |||
288 | struct usb_gadget gadget; | ||
289 | struct usb_gadget_driver *driver; | ||
290 | |||
291 | void __iomem *usbd_regs; | ||
292 | void __iomem *iudma_regs; | ||
293 | |||
294 | struct bcm63xx_ep bep[BCM63XX_NUM_EP]; | ||
295 | struct iudma_ch iudma[BCM63XX_NUM_IUDMA]; | ||
296 | |||
297 | int cfg; | ||
298 | int iface; | ||
299 | int alt_iface; | ||
300 | |||
301 | struct bcm63xx_req ep0_ctrl_req; | ||
302 | u8 *ep0_ctrl_buf; | ||
303 | |||
304 | int ep0state; | ||
305 | struct work_struct ep0_wq; | ||
306 | |||
307 | unsigned long wedgemap; | ||
308 | |||
309 | unsigned ep0_req_reset:1; | ||
310 | unsigned ep0_req_set_cfg:1; | ||
311 | unsigned ep0_req_set_iface:1; | ||
312 | unsigned ep0_req_shutdown:1; | ||
313 | |||
314 | unsigned ep0_req_completed:1; | ||
315 | struct usb_request *ep0_reply; | ||
316 | struct usb_request *ep0_request; | ||
317 | |||
318 | struct dentry *debugfs_root; | ||
319 | struct dentry *debugfs_usbd; | ||
320 | struct dentry *debugfs_iudma; | ||
321 | }; | ||
322 | |||
323 | static const struct usb_ep_ops bcm63xx_udc_ep_ops; | ||
324 | |||
325 | /*********************************************************************** | ||
326 | * Convenience functions | ||
327 | ***********************************************************************/ | ||
328 | |||
329 | static inline struct bcm63xx_udc *gadget_to_udc(struct usb_gadget *g) | ||
330 | { | ||
331 | return container_of(g, struct bcm63xx_udc, gadget); | ||
332 | } | ||
333 | |||
334 | static inline struct bcm63xx_ep *our_ep(struct usb_ep *ep) | ||
335 | { | ||
336 | return container_of(ep, struct bcm63xx_ep, ep); | ||
337 | } | ||
338 | |||
339 | static inline struct bcm63xx_req *our_req(struct usb_request *req) | ||
340 | { | ||
341 | return container_of(req, struct bcm63xx_req, req); | ||
342 | } | ||
343 | |||
344 | static inline u32 usbd_readl(struct bcm63xx_udc *udc, u32 off) | ||
345 | { | ||
346 | return bcm_readl(udc->usbd_regs + off); | ||
347 | } | ||
348 | |||
349 | static inline void usbd_writel(struct bcm63xx_udc *udc, u32 val, u32 off) | ||
350 | { | ||
351 | bcm_writel(val, udc->usbd_regs + off); | ||
352 | } | ||
353 | |||
354 | static inline u32 usb_dma_readl(struct bcm63xx_udc *udc, u32 off) | ||
355 | { | ||
356 | return bcm_readl(udc->iudma_regs + off); | ||
357 | } | ||
358 | |||
359 | static inline void usb_dma_writel(struct bcm63xx_udc *udc, u32 val, u32 off) | ||
360 | { | ||
361 | bcm_writel(val, udc->iudma_regs + off); | ||
362 | } | ||
363 | |||
364 | static inline u32 usb_dmac_readl(struct bcm63xx_udc *udc, u32 off) | ||
365 | { | ||
366 | return bcm_readl(udc->iudma_regs + IUDMA_DMAC_OFFSET + off); | ||
367 | } | ||
368 | |||
369 | static inline void usb_dmac_writel(struct bcm63xx_udc *udc, u32 val, u32 off) | ||
370 | { | ||
371 | bcm_writel(val, udc->iudma_regs + IUDMA_DMAC_OFFSET + off); | ||
372 | } | ||
373 | |||
374 | static inline u32 usb_dmas_readl(struct bcm63xx_udc *udc, u32 off) | ||
375 | { | ||
376 | return bcm_readl(udc->iudma_regs + IUDMA_DMAS_OFFSET + off); | ||
377 | } | ||
378 | |||
379 | static inline void usb_dmas_writel(struct bcm63xx_udc *udc, u32 val, u32 off) | ||
380 | { | ||
381 | bcm_writel(val, udc->iudma_regs + IUDMA_DMAS_OFFSET + off); | ||
382 | } | ||
383 | |||
384 | static inline void set_clocks(struct bcm63xx_udc *udc, bool is_enabled) | ||
385 | { | ||
386 | if (is_enabled) { | ||
387 | clk_enable(udc->usbh_clk); | ||
388 | clk_enable(udc->usbd_clk); | ||
389 | udelay(10); | ||
390 | } else { | ||
391 | clk_disable(udc->usbd_clk); | ||
392 | clk_disable(udc->usbh_clk); | ||
393 | } | ||
394 | } | ||
395 | |||
396 | /*********************************************************************** | ||
397 | * Low-level IUDMA / FIFO operations | ||
398 | ***********************************************************************/ | ||
399 | |||
400 | /** | ||
401 | * bcm63xx_ep_dma_select - Helper function to set up the init_sel signal. | ||
402 | * @udc: Reference to the device controller. | ||
403 | * @idx: Desired init_sel value. | ||
404 | * | ||
405 | * The "init_sel" signal is used as a selection index for both endpoints | ||
406 | * and IUDMA channels. Since these do not map 1:1, the use of this signal | ||
407 | * depends on the context. | ||
408 | */ | ||
409 | static void bcm63xx_ep_dma_select(struct bcm63xx_udc *udc, int idx) | ||
410 | { | ||
411 | u32 val = usbd_readl(udc, USBD_CONTROL_REG); | ||
412 | |||
413 | val &= ~USBD_CONTROL_INIT_SEL_MASK; | ||
414 | val |= idx << USBD_CONTROL_INIT_SEL_SHIFT; | ||
415 | usbd_writel(udc, val, USBD_CONTROL_REG); | ||
416 | } | ||
417 | |||
418 | /** | ||
419 | * bcm63xx_set_stall - Enable/disable stall on one endpoint. | ||
420 | * @udc: Reference to the device controller. | ||
421 | * @bep: Endpoint on which to operate. | ||
422 | * @is_stalled: true to enable stall, false to disable. | ||
423 | * | ||
424 | * See notes in bcm63xx_update_wedge() regarding automatic clearing of | ||
425 | * halt/stall conditions. | ||
426 | */ | ||
427 | static void bcm63xx_set_stall(struct bcm63xx_udc *udc, struct bcm63xx_ep *bep, | ||
428 | bool is_stalled) | ||
429 | { | ||
430 | u32 val; | ||
431 | |||
432 | val = USBD_STALL_UPDATE_MASK | | ||
433 | (is_stalled ? USBD_STALL_ENABLE_MASK : 0) | | ||
434 | (bep->ep_num << USBD_STALL_EPNUM_SHIFT); | ||
435 | usbd_writel(udc, val, USBD_STALL_REG); | ||
436 | } | ||
437 | |||
438 | /** | ||
439 | * bcm63xx_fifo_setup - (Re)initialize FIFO boundaries and settings. | ||
440 | * @udc: Reference to the device controller. | ||
441 | * | ||
442 | * These parameters depend on the USB link speed. Settings are | ||
443 | * per-IUDMA-channel-pair. | ||
444 | */ | ||
445 | static void bcm63xx_fifo_setup(struct bcm63xx_udc *udc) | ||
446 | { | ||
447 | int is_hs = udc->gadget.speed == USB_SPEED_HIGH; | ||
448 | u32 i, val, rx_fifo_slot, tx_fifo_slot; | ||
449 | |||
450 | /* set up FIFO boundaries and packet sizes; this is done in pairs */ | ||
451 | rx_fifo_slot = tx_fifo_slot = 0; | ||
452 | for (i = 0; i < BCM63XX_NUM_IUDMA; i += 2) { | ||
453 | const struct iudma_ch_cfg *rx_cfg = &iudma_defaults[i]; | ||
454 | const struct iudma_ch_cfg *tx_cfg = &iudma_defaults[i + 1]; | ||
455 | |||
456 | bcm63xx_ep_dma_select(udc, i >> 1); | ||
457 | |||
458 | val = (rx_fifo_slot << USBD_RXFIFO_CONFIG_START_SHIFT) | | ||
459 | ((rx_fifo_slot + rx_cfg->n_fifo_slots - 1) << | ||
460 | USBD_RXFIFO_CONFIG_END_SHIFT); | ||
461 | rx_fifo_slot += rx_cfg->n_fifo_slots; | ||
462 | usbd_writel(udc, val, USBD_RXFIFO_CONFIG_REG); | ||
463 | usbd_writel(udc, | ||
464 | is_hs ? rx_cfg->max_pkt_hs : rx_cfg->max_pkt_fs, | ||
465 | USBD_RXFIFO_EPSIZE_REG); | ||
466 | |||
467 | val = (tx_fifo_slot << USBD_TXFIFO_CONFIG_START_SHIFT) | | ||
468 | ((tx_fifo_slot + tx_cfg->n_fifo_slots - 1) << | ||
469 | USBD_TXFIFO_CONFIG_END_SHIFT); | ||
470 | tx_fifo_slot += tx_cfg->n_fifo_slots; | ||
471 | usbd_writel(udc, val, USBD_TXFIFO_CONFIG_REG); | ||
472 | usbd_writel(udc, | ||
473 | is_hs ? tx_cfg->max_pkt_hs : tx_cfg->max_pkt_fs, | ||
474 | USBD_TXFIFO_EPSIZE_REG); | ||
475 | |||
476 | usbd_readl(udc, USBD_TXFIFO_EPSIZE_REG); | ||
477 | } | ||
478 | } | ||
479 | |||
480 | /** | ||
481 | * bcm63xx_fifo_reset_ep - Flush a single endpoint's FIFO. | ||
482 | * @udc: Reference to the device controller. | ||
483 | * @ep_num: Endpoint number. | ||
484 | */ | ||
485 | static void bcm63xx_fifo_reset_ep(struct bcm63xx_udc *udc, int ep_num) | ||
486 | { | ||
487 | u32 val; | ||
488 | |||
489 | bcm63xx_ep_dma_select(udc, ep_num); | ||
490 | |||
491 | val = usbd_readl(udc, USBD_CONTROL_REG); | ||
492 | val |= USBD_CONTROL_FIFO_RESET_MASK; | ||
493 | usbd_writel(udc, val, USBD_CONTROL_REG); | ||
494 | usbd_readl(udc, USBD_CONTROL_REG); | ||
495 | } | ||
496 | |||
497 | /** | ||
498 | * bcm63xx_fifo_reset - Flush all hardware FIFOs. | ||
499 | * @udc: Reference to the device controller. | ||
500 | */ | ||
501 | static void bcm63xx_fifo_reset(struct bcm63xx_udc *udc) | ||
502 | { | ||
503 | int i; | ||
504 | |||
505 | for (i = 0; i < BCM63XX_NUM_FIFO_PAIRS; i++) | ||
506 | bcm63xx_fifo_reset_ep(udc, i); | ||
507 | } | ||
508 | |||
509 | /** | ||
510 | * bcm63xx_ep_init - Initial (one-time) endpoint initialization. | ||
511 | * @udc: Reference to the device controller. | ||
512 | */ | ||
513 | static void bcm63xx_ep_init(struct bcm63xx_udc *udc) | ||
514 | { | ||
515 | u32 i, val; | ||
516 | |||
517 | for (i = 0; i < BCM63XX_NUM_IUDMA; i++) { | ||
518 | const struct iudma_ch_cfg *cfg = &iudma_defaults[i]; | ||
519 | |||
520 | if (cfg->ep_num < 0) | ||
521 | continue; | ||
522 | |||
523 | bcm63xx_ep_dma_select(udc, cfg->ep_num); | ||
524 | val = (cfg->ep_type << USBD_EPNUM_TYPEMAP_TYPE_SHIFT) | | ||
525 | ((i >> 1) << USBD_EPNUM_TYPEMAP_DMA_CH_SHIFT); | ||
526 | usbd_writel(udc, val, USBD_EPNUM_TYPEMAP_REG); | ||
527 | } | ||
528 | } | ||
529 | |||
530 | /** | ||
531 | * bcm63xx_ep_setup - Configure per-endpoint settings. | ||
532 | * @udc: Reference to the device controller. | ||
533 | * | ||
534 | * This needs to be rerun if the speed/cfg/intf/altintf changes. | ||
535 | */ | ||
536 | static void bcm63xx_ep_setup(struct bcm63xx_udc *udc) | ||
537 | { | ||
538 | u32 val, i; | ||
539 | |||
540 | usbd_writel(udc, USBD_CSR_SETUPADDR_DEF, USBD_CSR_SETUPADDR_REG); | ||
541 | |||
542 | for (i = 0; i < BCM63XX_NUM_IUDMA; i++) { | ||
543 | const struct iudma_ch_cfg *cfg = &iudma_defaults[i]; | ||
544 | int max_pkt = udc->gadget.speed == USB_SPEED_HIGH ? | ||
545 | cfg->max_pkt_hs : cfg->max_pkt_fs; | ||
546 | int idx = cfg->ep_num; | ||
547 | |||
548 | udc->iudma[i].max_pkt = max_pkt; | ||
549 | |||
550 | if (idx < 0) | ||
551 | continue; | ||
552 | udc->bep[idx].ep.maxpacket = max_pkt; | ||
553 | |||
554 | val = (idx << USBD_CSR_EP_LOG_SHIFT) | | ||
555 | (cfg->dir << USBD_CSR_EP_DIR_SHIFT) | | ||
556 | (cfg->ep_type << USBD_CSR_EP_TYPE_SHIFT) | | ||
557 | (udc->cfg << USBD_CSR_EP_CFG_SHIFT) | | ||
558 | (udc->iface << USBD_CSR_EP_IFACE_SHIFT) | | ||
559 | (udc->alt_iface << USBD_CSR_EP_ALTIFACE_SHIFT) | | ||
560 | (max_pkt << USBD_CSR_EP_MAXPKT_SHIFT); | ||
561 | usbd_writel(udc, val, USBD_CSR_EP_REG(idx)); | ||
562 | } | ||
563 | } | ||
564 | |||
565 | /** | ||
566 | * iudma_write - Queue a single IUDMA transaction. | ||
567 | * @udc: Reference to the device controller. | ||
568 | * @iudma: IUDMA channel to use. | ||
569 | * @breq: Request containing the transaction data. | ||
570 | * | ||
571 | * For RX IUDMA, this will queue a single buffer descriptor, as RX IUDMA | ||
572 | * does not honor SOP/EOP so the handling of multiple buffers is ambiguous. | ||
573 | * So iudma_write() may be called several times to fulfill a single | ||
574 | * usb_request. | ||
575 | * | ||
576 | * For TX IUDMA, this can queue multiple buffer descriptors if needed. | ||
577 | */ | ||
578 | static void iudma_write(struct bcm63xx_udc *udc, struct iudma_ch *iudma, | ||
579 | struct bcm63xx_req *breq) | ||
580 | { | ||
581 | int first_bd = 1, last_bd = 0, extra_zero_pkt = 0; | ||
582 | unsigned int bytes_left = breq->req.length - breq->offset; | ||
583 | const int max_bd_bytes = !irq_coalesce && !iudma->is_tx ? | ||
584 | iudma->max_pkt : IUDMA_MAX_FRAGMENT; | ||
585 | |||
586 | iudma->n_bds_used = 0; | ||
587 | breq->bd_bytes = 0; | ||
588 | breq->iudma = iudma; | ||
589 | |||
590 | if ((bytes_left % iudma->max_pkt == 0) && bytes_left && breq->req.zero) | ||
591 | extra_zero_pkt = 1; | ||
592 | |||
593 | do { | ||
594 | struct bcm_enet_desc *d = iudma->write_bd; | ||
595 | u32 dmaflags = 0; | ||
596 | unsigned int n_bytes; | ||
597 | |||
598 | if (d == iudma->end_bd) { | ||
599 | dmaflags |= DMADESC_WRAP_MASK; | ||
600 | iudma->write_bd = iudma->bd_ring; | ||
601 | } else { | ||
602 | iudma->write_bd++; | ||
603 | } | ||
604 | iudma->n_bds_used++; | ||
605 | |||
606 | n_bytes = min_t(int, bytes_left, max_bd_bytes); | ||
607 | if (n_bytes) | ||
608 | dmaflags |= n_bytes << DMADESC_LENGTH_SHIFT; | ||
609 | else | ||
610 | dmaflags |= (1 << DMADESC_LENGTH_SHIFT) | | ||
611 | DMADESC_USB_ZERO_MASK; | ||
612 | |||
613 | dmaflags |= DMADESC_OWNER_MASK; | ||
614 | if (first_bd) { | ||
615 | dmaflags |= DMADESC_SOP_MASK; | ||
616 | first_bd = 0; | ||
617 | } | ||
618 | |||
619 | /* | ||
620 | * extra_zero_pkt forces one more iteration through the loop | ||
621 | * after all data is queued up, to send the zero packet | ||
622 | */ | ||
623 | if (extra_zero_pkt && !bytes_left) | ||
624 | extra_zero_pkt = 0; | ||
625 | |||
626 | if (!iudma->is_tx || iudma->n_bds_used == iudma->n_bds || | ||
627 | (n_bytes == bytes_left && !extra_zero_pkt)) { | ||
628 | last_bd = 1; | ||
629 | dmaflags |= DMADESC_EOP_MASK; | ||
630 | } | ||
631 | |||
632 | d->address = breq->req.dma + breq->offset; | ||
633 | mb(); | ||
634 | d->len_stat = dmaflags; | ||
635 | |||
636 | breq->offset += n_bytes; | ||
637 | breq->bd_bytes += n_bytes; | ||
638 | bytes_left -= n_bytes; | ||
639 | } while (!last_bd); | ||
640 | |||
641 | usb_dmac_writel(udc, ENETDMAC_CHANCFG_EN_MASK, | ||
642 | ENETDMAC_CHANCFG_REG(iudma->ch_idx)); | ||
643 | } | ||
644 | |||
645 | /** | ||
646 | * iudma_read - Check for IUDMA buffer completion. | ||
647 | * @udc: Reference to the device controller. | ||
648 | * @iudma: IUDMA channel to use. | ||
649 | * | ||
650 | * This checks to see if ALL of the outstanding BDs on the DMA channel | ||
651 | * have been filled. If so, it returns the actual transfer length; | ||
652 | * otherwise it returns -EBUSY. | ||
653 | */ | ||
654 | static int iudma_read(struct bcm63xx_udc *udc, struct iudma_ch *iudma) | ||
655 | { | ||
656 | int i, actual_len = 0; | ||
657 | struct bcm_enet_desc *d = iudma->read_bd; | ||
658 | |||
659 | if (!iudma->n_bds_used) | ||
660 | return -EINVAL; | ||
661 | |||
662 | for (i = 0; i < iudma->n_bds_used; i++) { | ||
663 | u32 dmaflags; | ||
664 | |||
665 | dmaflags = d->len_stat; | ||
666 | |||
667 | if (dmaflags & DMADESC_OWNER_MASK) | ||
668 | return -EBUSY; | ||
669 | |||
670 | actual_len += (dmaflags & DMADESC_LENGTH_MASK) >> | ||
671 | DMADESC_LENGTH_SHIFT; | ||
672 | if (d == iudma->end_bd) | ||
673 | d = iudma->bd_ring; | ||
674 | else | ||
675 | d++; | ||
676 | } | ||
677 | |||
678 | iudma->read_bd = d; | ||
679 | iudma->n_bds_used = 0; | ||
680 | return actual_len; | ||
681 | } | ||
682 | |||
683 | /** | ||
684 | * iudma_reset_channel - Stop DMA on a single channel. | ||
685 | * @udc: Reference to the device controller. | ||
686 | * @iudma: IUDMA channel to reset. | ||
687 | */ | ||
688 | static void iudma_reset_channel(struct bcm63xx_udc *udc, struct iudma_ch *iudma) | ||
689 | { | ||
690 | int timeout = IUDMA_RESET_TIMEOUT_US; | ||
691 | struct bcm_enet_desc *d; | ||
692 | int ch_idx = iudma->ch_idx; | ||
693 | |||
694 | if (!iudma->is_tx) | ||
695 | bcm63xx_fifo_reset_ep(udc, max(0, iudma->ep_num)); | ||
696 | |||
697 | /* stop DMA, then wait for the hardware to wrap up */ | ||
698 | usb_dmac_writel(udc, 0, ENETDMAC_CHANCFG_REG(ch_idx)); | ||
699 | |||
700 | while (usb_dmac_readl(udc, ENETDMAC_CHANCFG_REG(ch_idx)) & | ||
701 | ENETDMAC_CHANCFG_EN_MASK) { | ||
702 | udelay(1); | ||
703 | |||
704 | /* repeatedly flush the FIFO data until the BD completes */ | ||
705 | if (iudma->is_tx && iudma->ep_num >= 0) | ||
706 | bcm63xx_fifo_reset_ep(udc, iudma->ep_num); | ||
707 | |||
708 | if (!timeout--) { | ||
709 | dev_err(udc->dev, "can't reset IUDMA channel %d\n", | ||
710 | ch_idx); | ||
711 | break; | ||
712 | } | ||
713 | if (timeout == IUDMA_RESET_TIMEOUT_US / 2) { | ||
714 | dev_warn(udc->dev, "forcibly halting IUDMA channel %d\n", | ||
715 | ch_idx); | ||
716 | usb_dmac_writel(udc, ENETDMAC_CHANCFG_BUFHALT_MASK, | ||
717 | ENETDMAC_CHANCFG_REG(ch_idx)); | ||
718 | } | ||
719 | } | ||
720 | usb_dmac_writel(udc, ~0, ENETDMAC_IR_REG(ch_idx)); | ||
721 | |||
722 | /* don't leave "live" HW-owned entries for the next guy to step on */ | ||
723 | for (d = iudma->bd_ring; d <= iudma->end_bd; d++) | ||
724 | d->len_stat = 0; | ||
725 | mb(); | ||
726 | |||
727 | iudma->read_bd = iudma->write_bd = iudma->bd_ring; | ||
728 | iudma->n_bds_used = 0; | ||
729 | |||
730 | /* set up IRQs, UBUS burst size, and BD base for this channel */ | ||
731 | usb_dmac_writel(udc, ENETDMAC_IR_BUFDONE_MASK, | ||
732 | ENETDMAC_IRMASK_REG(ch_idx)); | ||
733 | usb_dmac_writel(udc, 8, ENETDMAC_MAXBURST_REG(ch_idx)); | ||
734 | |||
735 | usb_dmas_writel(udc, iudma->bd_ring_dma, ENETDMAS_RSTART_REG(ch_idx)); | ||
736 | usb_dmas_writel(udc, 0, ENETDMAS_SRAM2_REG(ch_idx)); | ||
737 | } | ||
738 | |||
739 | /** | ||
740 | * iudma_init_channel - One-time IUDMA channel initialization. | ||
741 | * @udc: Reference to the device controller. | ||
742 | * @ch_idx: Channel to initialize. | ||
743 | */ | ||
744 | static int iudma_init_channel(struct bcm63xx_udc *udc, unsigned int ch_idx) | ||
745 | { | ||
746 | struct iudma_ch *iudma = &udc->iudma[ch_idx]; | ||
747 | const struct iudma_ch_cfg *cfg = &iudma_defaults[ch_idx]; | ||
748 | unsigned int n_bds = cfg->n_bds; | ||
749 | struct bcm63xx_ep *bep = NULL; | ||
750 | |||
751 | iudma->ep_num = cfg->ep_num; | ||
752 | iudma->ch_idx = ch_idx; | ||
753 | iudma->is_tx = !!(ch_idx & 0x01); | ||
754 | if (iudma->ep_num >= 0) { | ||
755 | bep = &udc->bep[iudma->ep_num]; | ||
756 | bep->iudma = iudma; | ||
757 | INIT_LIST_HEAD(&bep->queue); | ||
758 | } | ||
759 | |||
760 | iudma->bep = bep; | ||
761 | iudma->udc = udc; | ||
762 | |||
763 | /* ep0 is always active; others are controlled by the gadget driver */ | ||
764 | if (iudma->ep_num <= 0) | ||
765 | iudma->enabled = true; | ||
766 | |||
767 | iudma->n_bds = n_bds; | ||
768 | iudma->bd_ring = dmam_alloc_coherent(udc->dev, | ||
769 | n_bds * sizeof(struct bcm_enet_desc), | ||
770 | &iudma->bd_ring_dma, GFP_KERNEL); | ||
771 | if (!iudma->bd_ring) | ||
772 | return -ENOMEM; | ||
773 | iudma->end_bd = &iudma->bd_ring[n_bds - 1]; | ||
774 | |||
775 | return 0; | ||
776 | } | ||
777 | |||
778 | /** | ||
779 | * iudma_init - One-time initialization of all IUDMA channels. | ||
780 | * @udc: Reference to the device controller. | ||
781 | * | ||
782 | * Enable DMA, flush channels, and enable global IUDMA IRQs. | ||
783 | */ | ||
784 | static int iudma_init(struct bcm63xx_udc *udc) | ||
785 | { | ||
786 | int i, rc; | ||
787 | |||
788 | usb_dma_writel(udc, ENETDMA_CFG_EN_MASK, ENETDMA_CFG_REG); | ||
789 | |||
790 | for (i = 0; i < BCM63XX_NUM_IUDMA; i++) { | ||
791 | rc = iudma_init_channel(udc, i); | ||
792 | if (rc) | ||
793 | return rc; | ||
794 | iudma_reset_channel(udc, &udc->iudma[i]); | ||
795 | } | ||
796 | |||
797 | usb_dma_writel(udc, BIT(BCM63XX_NUM_IUDMA)-1, ENETDMA_GLB_IRQMASK_REG); | ||
798 | return 0; | ||
799 | } | ||
800 | |||
801 | /** | ||
802 | * iudma_uninit - Uninitialize IUDMA channels. | ||
803 | * @udc: Reference to the device controller. | ||
804 | * | ||
805 | * Kill global IUDMA IRQs, flush channels, and kill DMA. | ||
806 | */ | ||
807 | static void iudma_uninit(struct bcm63xx_udc *udc) | ||
808 | { | ||
809 | int i; | ||
810 | |||
811 | usb_dma_writel(udc, 0, ENETDMA_GLB_IRQMASK_REG); | ||
812 | |||
813 | for (i = 0; i < BCM63XX_NUM_IUDMA; i++) | ||
814 | iudma_reset_channel(udc, &udc->iudma[i]); | ||
815 | |||
816 | usb_dma_writel(udc, 0, ENETDMA_CFG_REG); | ||
817 | } | ||
818 | |||
819 | /*********************************************************************** | ||
820 | * Other low-level USBD operations | ||
821 | ***********************************************************************/ | ||
822 | |||
823 | /** | ||
824 | * bcm63xx_set_ctrl_irqs - Mask/unmask control path interrupts. | ||
825 | * @udc: Reference to the device controller. | ||
826 | * @enable_irqs: true to enable, false to disable. | ||
827 | */ | ||
828 | static void bcm63xx_set_ctrl_irqs(struct bcm63xx_udc *udc, bool enable_irqs) | ||
829 | { | ||
830 | u32 val; | ||
831 | |||
832 | usbd_writel(udc, 0, USBD_STATUS_REG); | ||
833 | |||
834 | val = BIT(USBD_EVENT_IRQ_USB_RESET) | | ||
835 | BIT(USBD_EVENT_IRQ_SETUP) | | ||
836 | BIT(USBD_EVENT_IRQ_SETCFG) | | ||
837 | BIT(USBD_EVENT_IRQ_SETINTF) | | ||
838 | BIT(USBD_EVENT_IRQ_USB_LINK); | ||
839 | usbd_writel(udc, enable_irqs ? val : 0, USBD_EVENT_IRQ_MASK_REG); | ||
840 | usbd_writel(udc, val, USBD_EVENT_IRQ_STATUS_REG); | ||
841 | } | ||
842 | |||
843 | /** | ||
844 | * bcm63xx_select_phy_mode - Select between USB device and host mode. | ||
845 | * @udc: Reference to the device controller. | ||
846 | * @is_device: true for device, false for host. | ||
847 | * | ||
848 | * This should probably be reworked to use the drivers/usb/otg | ||
849 | * infrastructure. | ||
850 | * | ||
851 | * By default, the AFE/pullups are disabled in device mode, until | ||
852 | * bcm63xx_select_pullup() is called. | ||
853 | */ | ||
854 | static void bcm63xx_select_phy_mode(struct bcm63xx_udc *udc, bool is_device) | ||
855 | { | ||
856 | u32 val, portmask = BIT(udc->pd->port_no); | ||
857 | |||
858 | if (BCMCPU_IS_6328()) { | ||
859 | /* configure pinmux to sense VBUS signal */ | ||
860 | val = bcm_gpio_readl(GPIO_PINMUX_OTHR_REG); | ||
861 | val &= ~GPIO_PINMUX_OTHR_6328_USB_MASK; | ||
862 | val |= is_device ? GPIO_PINMUX_OTHR_6328_USB_DEV : | ||
863 | GPIO_PINMUX_OTHR_6328_USB_HOST; | ||
864 | bcm_gpio_writel(val, GPIO_PINMUX_OTHR_REG); | ||
865 | } | ||
866 | |||
867 | val = bcm_rset_readl(RSET_USBH_PRIV, USBH_PRIV_UTMI_CTL_6368_REG); | ||
868 | if (is_device) { | ||
869 | val |= (portmask << USBH_PRIV_UTMI_CTL_HOSTB_SHIFT); | ||
870 | val |= (portmask << USBH_PRIV_UTMI_CTL_NODRIV_SHIFT); | ||
871 | } else { | ||
872 | val &= ~(portmask << USBH_PRIV_UTMI_CTL_HOSTB_SHIFT); | ||
873 | val &= ~(portmask << USBH_PRIV_UTMI_CTL_NODRIV_SHIFT); | ||
874 | } | ||
875 | bcm_rset_writel(RSET_USBH_PRIV, val, USBH_PRIV_UTMI_CTL_6368_REG); | ||
876 | |||
877 | val = bcm_rset_readl(RSET_USBH_PRIV, USBH_PRIV_SWAP_6368_REG); | ||
878 | if (is_device) | ||
879 | val |= USBH_PRIV_SWAP_USBD_MASK; | ||
880 | else | ||
881 | val &= ~USBH_PRIV_SWAP_USBD_MASK; | ||
882 | bcm_rset_writel(RSET_USBH_PRIV, val, USBH_PRIV_SWAP_6368_REG); | ||
883 | } | ||
884 | |||
885 | /** | ||
886 | * bcm63xx_select_pullup - Enable/disable the pullup on D+ | ||
887 | * @udc: Reference to the device controller. | ||
888 | * @is_on: true to enable the pullup, false to disable. | ||
889 | * | ||
890 | * If the pullup is active, the host will sense a FS/HS device connected to | ||
891 | * the port. If the pullup is inactive, the host will think the USB | ||
892 | * device has been disconnected. | ||
893 | */ | ||
894 | static void bcm63xx_select_pullup(struct bcm63xx_udc *udc, bool is_on) | ||
895 | { | ||
896 | u32 val, portmask = BIT(udc->pd->port_no); | ||
897 | |||
898 | val = bcm_rset_readl(RSET_USBH_PRIV, USBH_PRIV_UTMI_CTL_6368_REG); | ||
899 | if (is_on) | ||
900 | val &= ~(portmask << USBH_PRIV_UTMI_CTL_NODRIV_SHIFT); | ||
901 | else | ||
902 | val |= (portmask << USBH_PRIV_UTMI_CTL_NODRIV_SHIFT); | ||
903 | bcm_rset_writel(RSET_USBH_PRIV, val, USBH_PRIV_UTMI_CTL_6368_REG); | ||
904 | } | ||
905 | |||
906 | /** | ||
907 | * bcm63xx_uninit_udc_hw - Shut down the hardware prior to driver removal. | ||
908 | * @udc: Reference to the device controller. | ||
909 | * | ||
910 | * This just masks the IUDMA IRQs and releases the clocks. It is assumed | ||
911 | * that bcm63xx_udc_stop() has already run, and the clocks are stopped. | ||
912 | */ | ||
913 | static void bcm63xx_uninit_udc_hw(struct bcm63xx_udc *udc) | ||
914 | { | ||
915 | set_clocks(udc, true); | ||
916 | iudma_uninit(udc); | ||
917 | set_clocks(udc, false); | ||
918 | |||
919 | clk_put(udc->usbd_clk); | ||
920 | clk_put(udc->usbh_clk); | ||
921 | } | ||
922 | |||
923 | /** | ||
924 | * bcm63xx_init_udc_hw - Initialize the controller hardware and data structures. | ||
925 | * @udc: Reference to the device controller. | ||
926 | */ | ||
927 | static int bcm63xx_init_udc_hw(struct bcm63xx_udc *udc) | ||
928 | { | ||
929 | int i, rc = 0; | ||
930 | u32 val; | ||
931 | |||
932 | udc->ep0_ctrl_buf = devm_kzalloc(udc->dev, BCM63XX_MAX_CTRL_PKT, | ||
933 | GFP_KERNEL); | ||
934 | if (!udc->ep0_ctrl_buf) | ||
935 | return -ENOMEM; | ||
936 | |||
937 | INIT_LIST_HEAD(&udc->gadget.ep_list); | ||
938 | for (i = 0; i < BCM63XX_NUM_EP; i++) { | ||
939 | struct bcm63xx_ep *bep = &udc->bep[i]; | ||
940 | |||
941 | bep->ep.name = bcm63xx_ep_name[i]; | ||
942 | bep->ep_num = i; | ||
943 | bep->ep.ops = &bcm63xx_udc_ep_ops; | ||
944 | list_add_tail(&bep->ep.ep_list, &udc->gadget.ep_list); | ||
945 | bep->halted = 0; | ||
946 | bep->ep.maxpacket = BCM63XX_MAX_CTRL_PKT; | ||
947 | bep->udc = udc; | ||
948 | bep->ep.desc = NULL; | ||
949 | INIT_LIST_HEAD(&bep->queue); | ||
950 | } | ||
951 | |||
952 | udc->gadget.ep0 = &udc->bep[0].ep; | ||
953 | list_del(&udc->bep[0].ep.ep_list); | ||
954 | |||
955 | udc->gadget.speed = USB_SPEED_UNKNOWN; | ||
956 | udc->ep0state = EP0_SHUTDOWN; | ||
957 | |||
958 | udc->usbh_clk = clk_get(udc->dev, "usbh"); | ||
959 | if (IS_ERR(udc->usbh_clk)) | ||
960 | return -EIO; | ||
961 | |||
962 | udc->usbd_clk = clk_get(udc->dev, "usbd"); | ||
963 | if (IS_ERR(udc->usbd_clk)) { | ||
964 | clk_put(udc->usbh_clk); | ||
965 | return -EIO; | ||
966 | } | ||
967 | |||
968 | set_clocks(udc, true); | ||
969 | |||
970 | val = USBD_CONTROL_AUTO_CSRS_MASK | | ||
971 | USBD_CONTROL_DONE_CSRS_MASK | | ||
972 | (irq_coalesce ? USBD_CONTROL_RXZSCFG_MASK : 0); | ||
973 | usbd_writel(udc, val, USBD_CONTROL_REG); | ||
974 | |||
975 | val = USBD_STRAPS_APP_SELF_PWR_MASK | | ||
976 | USBD_STRAPS_APP_RAM_IF_MASK | | ||
977 | USBD_STRAPS_APP_CSRPRGSUP_MASK | | ||
978 | USBD_STRAPS_APP_8BITPHY_MASK | | ||
979 | USBD_STRAPS_APP_RMTWKUP_MASK; | ||
980 | |||
981 | if (udc->gadget.max_speed == USB_SPEED_HIGH) | ||
982 | val |= (BCM63XX_SPD_HIGH << USBD_STRAPS_SPEED_SHIFT); | ||
983 | else | ||
984 | val |= (BCM63XX_SPD_FULL << USBD_STRAPS_SPEED_SHIFT); | ||
985 | usbd_writel(udc, val, USBD_STRAPS_REG); | ||
986 | |||
987 | bcm63xx_set_ctrl_irqs(udc, false); | ||
988 | |||
989 | usbd_writel(udc, 0, USBD_EVENT_IRQ_CFG_LO_REG); | ||
990 | |||
991 | val = USBD_EVENT_IRQ_CFG_FALLING(USBD_EVENT_IRQ_ENUM_ON) | | ||
992 | USBD_EVENT_IRQ_CFG_FALLING(USBD_EVENT_IRQ_SET_CSRS); | ||
993 | usbd_writel(udc, val, USBD_EVENT_IRQ_CFG_HI_REG); | ||
994 | |||
995 | rc = iudma_init(udc); | ||
996 | set_clocks(udc, false); | ||
997 | if (rc) | ||
998 | bcm63xx_uninit_udc_hw(udc); | ||
999 | |||
1000 | return 0; | ||
1001 | } | ||
1002 | |||
1003 | /*********************************************************************** | ||
1004 | * Standard EP gadget operations | ||
1005 | ***********************************************************************/ | ||
1006 | |||
1007 | /** | ||
1008 | * bcm63xx_ep_enable - Enable one endpoint. | ||
1009 | * @ep: Endpoint to enable. | ||
1010 | * @desc: Contains max packet, direction, etc. | ||
1011 | * | ||
1012 | * Most of the endpoint parameters are fixed in this controller, so there | ||
1013 | * isn't much for this function to do. | ||
1014 | */ | ||
1015 | static int bcm63xx_ep_enable(struct usb_ep *ep, | ||
1016 | const struct usb_endpoint_descriptor *desc) | ||
1017 | { | ||
1018 | struct bcm63xx_ep *bep = our_ep(ep); | ||
1019 | struct bcm63xx_udc *udc = bep->udc; | ||
1020 | struct iudma_ch *iudma = bep->iudma; | ||
1021 | unsigned long flags; | ||
1022 | |||
1023 | if (!ep || !desc || ep->name == bcm63xx_ep0name) | ||
1024 | return -EINVAL; | ||
1025 | |||
1026 | if (!udc->driver) | ||
1027 | return -ESHUTDOWN; | ||
1028 | |||
1029 | spin_lock_irqsave(&udc->lock, flags); | ||
1030 | if (iudma->enabled) { | ||
1031 | spin_unlock_irqrestore(&udc->lock, flags); | ||
1032 | return -EINVAL; | ||
1033 | } | ||
1034 | |||
1035 | iudma->enabled = true; | ||
1036 | BUG_ON(!list_empty(&bep->queue)); | ||
1037 | |||
1038 | iudma_reset_channel(udc, iudma); | ||
1039 | |||
1040 | bep->halted = 0; | ||
1041 | bcm63xx_set_stall(udc, bep, false); | ||
1042 | clear_bit(bep->ep_num, &udc->wedgemap); | ||
1043 | |||
1044 | ep->desc = desc; | ||
1045 | ep->maxpacket = usb_endpoint_maxp(desc); | ||
1046 | |||
1047 | spin_unlock_irqrestore(&udc->lock, flags); | ||
1048 | return 0; | ||
1049 | } | ||
1050 | |||
1051 | /** | ||
1052 | * bcm63xx_ep_disable - Disable one endpoint. | ||
1053 | * @ep: Endpoint to disable. | ||
1054 | */ | ||
1055 | static int bcm63xx_ep_disable(struct usb_ep *ep) | ||
1056 | { | ||
1057 | struct bcm63xx_ep *bep = our_ep(ep); | ||
1058 | struct bcm63xx_udc *udc = bep->udc; | ||
1059 | struct iudma_ch *iudma = bep->iudma; | ||
1060 | struct list_head *pos, *n; | ||
1061 | unsigned long flags; | ||
1062 | |||
1063 | if (!ep || !ep->desc) | ||
1064 | return -EINVAL; | ||
1065 | |||
1066 | spin_lock_irqsave(&udc->lock, flags); | ||
1067 | if (!iudma->enabled) { | ||
1068 | spin_unlock_irqrestore(&udc->lock, flags); | ||
1069 | return -EINVAL; | ||
1070 | } | ||
1071 | iudma->enabled = false; | ||
1072 | |||
1073 | iudma_reset_channel(udc, iudma); | ||
1074 | |||
1075 | if (!list_empty(&bep->queue)) { | ||
1076 | list_for_each_safe(pos, n, &bep->queue) { | ||
1077 | struct bcm63xx_req *breq = | ||
1078 | list_entry(pos, struct bcm63xx_req, queue); | ||
1079 | |||
1080 | usb_gadget_unmap_request(&udc->gadget, &breq->req, | ||
1081 | iudma->is_tx); | ||
1082 | list_del(&breq->queue); | ||
1083 | breq->req.status = -ESHUTDOWN; | ||
1084 | |||
1085 | spin_unlock_irqrestore(&udc->lock, flags); | ||
1086 | breq->req.complete(&iudma->bep->ep, &breq->req); | ||
1087 | spin_lock_irqsave(&udc->lock, flags); | ||
1088 | } | ||
1089 | } | ||
1090 | ep->desc = NULL; | ||
1091 | |||
1092 | spin_unlock_irqrestore(&udc->lock, flags); | ||
1093 | return 0; | ||
1094 | } | ||
1095 | |||
1096 | /** | ||
1097 | * bcm63xx_udc_alloc_request - Allocate a new request. | ||
1098 | * @ep: Endpoint associated with the request. | ||
1099 | * @mem_flags: Flags to pass to kzalloc(). | ||
1100 | */ | ||
1101 | static struct usb_request *bcm63xx_udc_alloc_request(struct usb_ep *ep, | ||
1102 | gfp_t mem_flags) | ||
1103 | { | ||
1104 | struct bcm63xx_req *breq; | ||
1105 | |||
1106 | breq = kzalloc(sizeof(*breq), mem_flags); | ||
1107 | if (!breq) | ||
1108 | return NULL; | ||
1109 | return &breq->req; | ||
1110 | } | ||
1111 | |||
1112 | /** | ||
1113 | * bcm63xx_udc_free_request - Free a request. | ||
1114 | * @ep: Endpoint associated with the request. | ||
1115 | * @req: Request to free. | ||
1116 | */ | ||
1117 | static void bcm63xx_udc_free_request(struct usb_ep *ep, | ||
1118 | struct usb_request *req) | ||
1119 | { | ||
1120 | struct bcm63xx_req *breq = our_req(req); | ||
1121 | kfree(breq); | ||
1122 | } | ||
1123 | |||
1124 | /** | ||
1125 | * bcm63xx_udc_queue - Queue up a new request. | ||
1126 | * @ep: Endpoint associated with the request. | ||
1127 | * @req: Request to add. | ||
1128 | * @mem_flags: Unused. | ||
1129 | * | ||
1130 | * If the queue is empty, start this request immediately. Otherwise, add | ||
1131 | * it to the list. | ||
1132 | * | ||
1133 | * ep0 replies are sent through this function from the gadget driver, but | ||
1134 | * they are treated differently because they need to be handled by the ep0 | ||
1135 | * state machine. (Sometimes they are replies to control requests that | ||
1136 | * were spoofed by this driver, and so they shouldn't be transmitted at all.) | ||
1137 | */ | ||
1138 | static int bcm63xx_udc_queue(struct usb_ep *ep, struct usb_request *req, | ||
1139 | gfp_t mem_flags) | ||
1140 | { | ||
1141 | struct bcm63xx_ep *bep = our_ep(ep); | ||
1142 | struct bcm63xx_udc *udc = bep->udc; | ||
1143 | struct bcm63xx_req *breq = our_req(req); | ||
1144 | unsigned long flags; | ||
1145 | int rc = 0; | ||
1146 | |||
1147 | if (unlikely(!req || !req->complete || !req->buf || !ep)) | ||
1148 | return -EINVAL; | ||
1149 | |||
1150 | req->actual = 0; | ||
1151 | req->status = 0; | ||
1152 | breq->offset = 0; | ||
1153 | |||
1154 | if (bep == &udc->bep[0]) { | ||
1155 | /* only one reply per request, please */ | ||
1156 | if (udc->ep0_reply) | ||
1157 | return -EINVAL; | ||
1158 | |||
1159 | udc->ep0_reply = req; | ||
1160 | schedule_work(&udc->ep0_wq); | ||
1161 | return 0; | ||
1162 | } | ||
1163 | |||
1164 | spin_lock_irqsave(&udc->lock, flags); | ||
1165 | if (!bep->iudma->enabled) { | ||
1166 | rc = -ESHUTDOWN; | ||
1167 | goto out; | ||
1168 | } | ||
1169 | |||
1170 | rc = usb_gadget_map_request(&udc->gadget, req, bep->iudma->is_tx); | ||
1171 | if (rc == 0) { | ||
1172 | list_add_tail(&breq->queue, &bep->queue); | ||
1173 | if (list_is_singular(&bep->queue)) | ||
1174 | iudma_write(udc, bep->iudma, breq); | ||
1175 | } | ||
1176 | |||
1177 | out: | ||
1178 | spin_unlock_irqrestore(&udc->lock, flags); | ||
1179 | return rc; | ||
1180 | } | ||
1181 | |||
1182 | /** | ||
1183 | * bcm63xx_udc_dequeue - Remove a pending request from the queue. | ||
1184 | * @ep: Endpoint associated with the request. | ||
1185 | * @req: Request to remove. | ||
1186 | * | ||
1187 | * If the request is not at the head of the queue, this is easy - just nuke | ||
1188 | * it. If the request is at the head of the queue, we'll need to stop the | ||
1189 | * DMA transaction and then queue up the successor. | ||
1190 | */ | ||
1191 | static int bcm63xx_udc_dequeue(struct usb_ep *ep, struct usb_request *req) | ||
1192 | { | ||
1193 | struct bcm63xx_ep *bep = our_ep(ep); | ||
1194 | struct bcm63xx_udc *udc = bep->udc; | ||
1195 | struct bcm63xx_req *breq = our_req(req), *cur; | ||
1196 | unsigned long flags; | ||
1197 | int rc = 0; | ||
1198 | |||
1199 | spin_lock_irqsave(&udc->lock, flags); | ||
1200 | if (list_empty(&bep->queue)) { | ||
1201 | rc = -EINVAL; | ||
1202 | goto out; | ||
1203 | } | ||
1204 | |||
1205 | cur = list_first_entry(&bep->queue, struct bcm63xx_req, queue); | ||
1206 | usb_gadget_unmap_request(&udc->gadget, &breq->req, bep->iudma->is_tx); | ||
1207 | |||
1208 | if (breq == cur) { | ||
1209 | iudma_reset_channel(udc, bep->iudma); | ||
1210 | list_del(&breq->queue); | ||
1211 | |||
1212 | if (!list_empty(&bep->queue)) { | ||
1213 | struct bcm63xx_req *next; | ||
1214 | |||
1215 | next = list_first_entry(&bep->queue, | ||
1216 | struct bcm63xx_req, queue); | ||
1217 | iudma_write(udc, bep->iudma, next); | ||
1218 | } | ||
1219 | } else { | ||
1220 | list_del(&breq->queue); | ||
1221 | } | ||
1222 | |||
1223 | out: | ||
1224 | spin_unlock_irqrestore(&udc->lock, flags); | ||
1225 | |||
1226 | req->status = -ESHUTDOWN; | ||
1227 | req->complete(ep, req); | ||
1228 | |||
1229 | return rc; | ||
1230 | } | ||
1231 | |||
1232 | /** | ||
1233 | * bcm63xx_udc_set_halt - Enable/disable STALL flag in the hardware. | ||
1234 | * @ep: Endpoint to halt. | ||
1235 | * @value: Zero to clear halt; nonzero to set halt. | ||
1236 | * | ||
1237 | * See comments in bcm63xx_update_wedge(). | ||
1238 | */ | ||
1239 | static int bcm63xx_udc_set_halt(struct usb_ep *ep, int value) | ||
1240 | { | ||
1241 | struct bcm63xx_ep *bep = our_ep(ep); | ||
1242 | struct bcm63xx_udc *udc = bep->udc; | ||
1243 | unsigned long flags; | ||
1244 | |||
1245 | spin_lock_irqsave(&udc->lock, flags); | ||
1246 | bcm63xx_set_stall(udc, bep, !!value); | ||
1247 | bep->halted = value; | ||
1248 | spin_unlock_irqrestore(&udc->lock, flags); | ||
1249 | |||
1250 | return 0; | ||
1251 | } | ||
1252 | |||
1253 | /** | ||
1254 | * bcm63xx_udc_set_wedge - Stall the endpoint until the next reset. | ||
1255 | * @ep: Endpoint to wedge. | ||
1256 | * | ||
1257 | * See comments in bcm63xx_update_wedge(). | ||
1258 | */ | ||
1259 | static int bcm63xx_udc_set_wedge(struct usb_ep *ep) | ||
1260 | { | ||
1261 | struct bcm63xx_ep *bep = our_ep(ep); | ||
1262 | struct bcm63xx_udc *udc = bep->udc; | ||
1263 | unsigned long flags; | ||
1264 | |||
1265 | spin_lock_irqsave(&udc->lock, flags); | ||
1266 | set_bit(bep->ep_num, &udc->wedgemap); | ||
1267 | bcm63xx_set_stall(udc, bep, true); | ||
1268 | spin_unlock_irqrestore(&udc->lock, flags); | ||
1269 | |||
1270 | return 0; | ||
1271 | } | ||
1272 | |||
1273 | static const struct usb_ep_ops bcm63xx_udc_ep_ops = { | ||
1274 | .enable = bcm63xx_ep_enable, | ||
1275 | .disable = bcm63xx_ep_disable, | ||
1276 | |||
1277 | .alloc_request = bcm63xx_udc_alloc_request, | ||
1278 | .free_request = bcm63xx_udc_free_request, | ||
1279 | |||
1280 | .queue = bcm63xx_udc_queue, | ||
1281 | .dequeue = bcm63xx_udc_dequeue, | ||
1282 | |||
1283 | .set_halt = bcm63xx_udc_set_halt, | ||
1284 | .set_wedge = bcm63xx_udc_set_wedge, | ||
1285 | }; | ||
1286 | |||
1287 | /*********************************************************************** | ||
1288 | * EP0 handling | ||
1289 | ***********************************************************************/ | ||
1290 | |||
1291 | /** | ||
1292 | * bcm63xx_ep0_setup_callback - Drop spinlock to invoke ->setup callback. | ||
1293 | * @udc: Reference to the device controller. | ||
1294 | * @ctrl: 8-byte SETUP request. | ||
1295 | */ | ||
1296 | static int bcm63xx_ep0_setup_callback(struct bcm63xx_udc *udc, | ||
1297 | struct usb_ctrlrequest *ctrl) | ||
1298 | { | ||
1299 | int rc; | ||
1300 | |||
1301 | spin_unlock_irq(&udc->lock); | ||
1302 | rc = udc->driver->setup(&udc->gadget, ctrl); | ||
1303 | spin_lock_irq(&udc->lock); | ||
1304 | return rc; | ||
1305 | } | ||
1306 | |||
1307 | /** | ||
1308 | * bcm63xx_ep0_spoof_set_cfg - Synthesize a SET_CONFIGURATION request. | ||
1309 | * @udc: Reference to the device controller. | ||
1310 | * | ||
1311 | * Many standard requests are handled automatically in the hardware, but | ||
1312 | * we still need to pass them to the gadget driver so that it can | ||
1313 | * reconfigure the interfaces/endpoints if necessary. | ||
1314 | * | ||
1315 | * Unfortunately we are not able to send a STALL response if the host | ||
1316 | * requests an invalid configuration. If this happens, we'll have to be | ||
1317 | * content with printing a warning. | ||
1318 | */ | ||
1319 | static int bcm63xx_ep0_spoof_set_cfg(struct bcm63xx_udc *udc) | ||
1320 | { | ||
1321 | struct usb_ctrlrequest ctrl; | ||
1322 | int rc; | ||
1323 | |||
1324 | ctrl.bRequestType = USB_DIR_OUT | USB_RECIP_DEVICE; | ||
1325 | ctrl.bRequest = USB_REQ_SET_CONFIGURATION; | ||
1326 | ctrl.wValue = cpu_to_le16(udc->cfg); | ||
1327 | ctrl.wIndex = 0; | ||
1328 | ctrl.wLength = 0; | ||
1329 | |||
1330 | rc = bcm63xx_ep0_setup_callback(udc, &ctrl); | ||
1331 | if (rc < 0) { | ||
1332 | dev_warn_ratelimited(udc->dev, | ||
1333 | "hardware auto-acked bad SET_CONFIGURATION(%d) request\n", | ||
1334 | udc->cfg); | ||
1335 | } | ||
1336 | return rc; | ||
1337 | } | ||
1338 | |||
1339 | /** | ||
1340 | * bcm63xx_ep0_spoof_set_iface - Synthesize a SET_INTERFACE request. | ||
1341 | * @udc: Reference to the device controller. | ||
1342 | */ | ||
1343 | static int bcm63xx_ep0_spoof_set_iface(struct bcm63xx_udc *udc) | ||
1344 | { | ||
1345 | struct usb_ctrlrequest ctrl; | ||
1346 | int rc; | ||
1347 | |||
1348 | ctrl.bRequestType = USB_DIR_OUT | USB_RECIP_INTERFACE; | ||
1349 | ctrl.bRequest = USB_REQ_SET_INTERFACE; | ||
1350 | ctrl.wValue = cpu_to_le16(udc->alt_iface); | ||
1351 | ctrl.wIndex = cpu_to_le16(udc->iface); | ||
1352 | ctrl.wLength = 0; | ||
1353 | |||
1354 | rc = bcm63xx_ep0_setup_callback(udc, &ctrl); | ||
1355 | if (rc < 0) { | ||
1356 | dev_warn_ratelimited(udc->dev, | ||
1357 | "hardware auto-acked bad SET_INTERFACE(%d,%d) request\n", | ||
1358 | udc->iface, udc->alt_iface); | ||
1359 | } | ||
1360 | return rc; | ||
1361 | } | ||
1362 | |||
1363 | /** | ||
1364 | * bcm63xx_ep0_map_write - dma_map and iudma_write a single request. | ||
1365 | * @udc: Reference to the device controller. | ||
1366 | * @ch_idx: IUDMA channel number. | ||
1367 | * @req: USB gadget layer representation of the request. | ||
1368 | */ | ||
1369 | static void bcm63xx_ep0_map_write(struct bcm63xx_udc *udc, int ch_idx, | ||
1370 | struct usb_request *req) | ||
1371 | { | ||
1372 | struct bcm63xx_req *breq = our_req(req); | ||
1373 | struct iudma_ch *iudma = &udc->iudma[ch_idx]; | ||
1374 | |||
1375 | BUG_ON(udc->ep0_request); | ||
1376 | udc->ep0_request = req; | ||
1377 | |||
1378 | req->actual = 0; | ||
1379 | breq->offset = 0; | ||
1380 | usb_gadget_map_request(&udc->gadget, req, iudma->is_tx); | ||
1381 | iudma_write(udc, iudma, breq); | ||
1382 | } | ||
1383 | |||
1384 | /** | ||
1385 | * bcm63xx_ep0_complete - Set completion status and "stage" the callback. | ||
1386 | * @udc: Reference to the device controller. | ||
1387 | * @req: USB gadget layer representation of the request. | ||
1388 | * @status: Status to return to the gadget driver. | ||
1389 | */ | ||
1390 | static void bcm63xx_ep0_complete(struct bcm63xx_udc *udc, | ||
1391 | struct usb_request *req, int status) | ||
1392 | { | ||
1393 | req->status = status; | ||
1394 | if (status) | ||
1395 | req->actual = 0; | ||
1396 | if (req->complete) { | ||
1397 | spin_unlock_irq(&udc->lock); | ||
1398 | req->complete(&udc->bep[0].ep, req); | ||
1399 | spin_lock_irq(&udc->lock); | ||
1400 | } | ||
1401 | } | ||
1402 | |||
1403 | /** | ||
1404 | * bcm63xx_ep0_nuke_reply - Abort request from the gadget driver due to | ||
1405 | * reset/shutdown. | ||
1406 | * @udc: Reference to the device controller. | ||
1407 | * @is_tx: Nonzero for TX (IN), zero for RX (OUT). | ||
1408 | */ | ||
1409 | static void bcm63xx_ep0_nuke_reply(struct bcm63xx_udc *udc, int is_tx) | ||
1410 | { | ||
1411 | struct usb_request *req = udc->ep0_reply; | ||
1412 | |||
1413 | udc->ep0_reply = NULL; | ||
1414 | usb_gadget_unmap_request(&udc->gadget, req, is_tx); | ||
1415 | if (udc->ep0_request == req) { | ||
1416 | udc->ep0_req_completed = 0; | ||
1417 | udc->ep0_request = NULL; | ||
1418 | } | ||
1419 | bcm63xx_ep0_complete(udc, req, -ESHUTDOWN); | ||
1420 | } | ||
1421 | |||
1422 | /** | ||
1423 | * bcm63xx_ep0_read_complete - Close out the pending ep0 request; return | ||
1424 | * transfer len. | ||
1425 | * @udc: Reference to the device controller. | ||
1426 | */ | ||
1427 | static int bcm63xx_ep0_read_complete(struct bcm63xx_udc *udc) | ||
1428 | { | ||
1429 | struct usb_request *req = udc->ep0_request; | ||
1430 | |||
1431 | udc->ep0_req_completed = 0; | ||
1432 | udc->ep0_request = NULL; | ||
1433 | |||
1434 | return req->actual; | ||
1435 | } | ||
1436 | |||
1437 | /** | ||
1438 | * bcm63xx_ep0_internal_request - Helper function to submit an ep0 request. | ||
1439 | * @udc: Reference to the device controller. | ||
1440 | * @ch_idx: IUDMA channel number. | ||
1441 | * @length: Number of bytes to TX/RX. | ||
1442 | * | ||
1443 | * Used for simple transfers performed by the ep0 worker. This will always | ||
1444 | * use ep0_ctrl_req / ep0_ctrl_buf. | ||
1445 | */ | ||
1446 | static void bcm63xx_ep0_internal_request(struct bcm63xx_udc *udc, int ch_idx, | ||
1447 | int length) | ||
1448 | { | ||
1449 | struct usb_request *req = &udc->ep0_ctrl_req.req; | ||
1450 | |||
1451 | req->buf = udc->ep0_ctrl_buf; | ||
1452 | req->length = length; | ||
1453 | req->complete = NULL; | ||
1454 | |||
1455 | bcm63xx_ep0_map_write(udc, ch_idx, req); | ||
1456 | } | ||
1457 | |||
1458 | /** | ||
1459 | * bcm63xx_ep0_do_setup - Parse new SETUP packet and decide how to handle it. | ||
1460 | * @udc: Reference to the device controller. | ||
1461 | * | ||
1462 | * EP0_IDLE probably shouldn't ever happen. EP0_REQUEUE means we're ready | ||
1463 | * for the next packet. Anything else means the transaction requires multiple | ||
1464 | * stages of handling. | ||
1465 | */ | ||
1466 | static enum bcm63xx_ep0_state bcm63xx_ep0_do_setup(struct bcm63xx_udc *udc) | ||
1467 | { | ||
1468 | int rc; | ||
1469 | struct usb_ctrlrequest *ctrl = (void *)udc->ep0_ctrl_buf; | ||
1470 | |||
1471 | rc = bcm63xx_ep0_read_complete(udc); | ||
1472 | |||
1473 | if (rc < 0) { | ||
1474 | dev_err(udc->dev, "missing SETUP packet\n"); | ||
1475 | return EP0_IDLE; | ||
1476 | } | ||
1477 | |||
1478 | /* | ||
1479 | * Handle 0-byte IN STATUS acknowledgement. The hardware doesn't | ||
1480 | * ALWAYS deliver these 100% of the time, so if we happen to see one, | ||
1481 | * just throw it away. | ||
1482 | */ | ||
1483 | if (rc == 0) | ||
1484 | return EP0_REQUEUE; | ||
1485 | |||
1486 | /* Drop malformed SETUP packets */ | ||
1487 | if (rc != sizeof(*ctrl)) { | ||
1488 | dev_warn_ratelimited(udc->dev, | ||
1489 | "malformed SETUP packet (%d bytes)\n", rc); | ||
1490 | return EP0_REQUEUE; | ||
1491 | } | ||
1492 | |||
1493 | /* Process new SETUP packet arriving on ep0 */ | ||
1494 | rc = bcm63xx_ep0_setup_callback(udc, ctrl); | ||
1495 | if (rc < 0) { | ||
1496 | bcm63xx_set_stall(udc, &udc->bep[0], true); | ||
1497 | return EP0_REQUEUE; | ||
1498 | } | ||
1499 | |||
1500 | if (!ctrl->wLength) | ||
1501 | return EP0_REQUEUE; | ||
1502 | else if (ctrl->bRequestType & USB_DIR_IN) | ||
1503 | return EP0_IN_DATA_PHASE_SETUP; | ||
1504 | else | ||
1505 | return EP0_OUT_DATA_PHASE_SETUP; | ||
1506 | } | ||
1507 | |||
1508 | /** | ||
1509 | * bcm63xx_ep0_do_idle - Check for outstanding requests if ep0 is idle. | ||
1510 | * @udc: Reference to the device controller. | ||
1511 | * | ||
1512 | * In state EP0_IDLE, the RX descriptor is either pending, or has been | ||
1513 | * filled with a SETUP packet from the host. This function handles new | ||
1514 | * SETUP packets, control IRQ events (which can generate fake SETUP packets), | ||
1515 | * and reset/shutdown events. | ||
1516 | * | ||
1517 | * Returns 0 if work was done; -EAGAIN if nothing to do. | ||
1518 | */ | ||
1519 | static int bcm63xx_ep0_do_idle(struct bcm63xx_udc *udc) | ||
1520 | { | ||
1521 | if (udc->ep0_req_reset) { | ||
1522 | udc->ep0_req_reset = 0; | ||
1523 | } else if (udc->ep0_req_set_cfg) { | ||
1524 | udc->ep0_req_set_cfg = 0; | ||
1525 | if (bcm63xx_ep0_spoof_set_cfg(udc) >= 0) | ||
1526 | udc->ep0state = EP0_IN_FAKE_STATUS_PHASE; | ||
1527 | } else if (udc->ep0_req_set_iface) { | ||
1528 | udc->ep0_req_set_iface = 0; | ||
1529 | if (bcm63xx_ep0_spoof_set_iface(udc) >= 0) | ||
1530 | udc->ep0state = EP0_IN_FAKE_STATUS_PHASE; | ||
1531 | } else if (udc->ep0_req_completed) { | ||
1532 | udc->ep0state = bcm63xx_ep0_do_setup(udc); | ||
1533 | return udc->ep0state == EP0_IDLE ? -EAGAIN : 0; | ||
1534 | } else if (udc->ep0_req_shutdown) { | ||
1535 | udc->ep0_req_shutdown = 0; | ||
1536 | udc->ep0_req_completed = 0; | ||
1537 | udc->ep0_request = NULL; | ||
1538 | iudma_reset_channel(udc, &udc->iudma[IUDMA_EP0_RXCHAN]); | ||
1539 | usb_gadget_unmap_request(&udc->gadget, | ||
1540 | &udc->ep0_ctrl_req.req, 0); | ||
1541 | |||
1542 | /* bcm63xx_udc_pullup() is waiting for this */ | ||
1543 | mb(); | ||
1544 | udc->ep0state = EP0_SHUTDOWN; | ||
1545 | } else if (udc->ep0_reply) { | ||
1546 | /* | ||
1547 | * This could happen if a USB RESET shows up during an ep0 | ||
1548 | * transaction (especially if a laggy driver like gadgetfs | ||
1549 | * is in use). | ||
1550 | */ | ||
1551 | dev_warn(udc->dev, "nuking unexpected reply\n"); | ||
1552 | bcm63xx_ep0_nuke_reply(udc, 0); | ||
1553 | } else { | ||
1554 | return -EAGAIN; | ||
1555 | } | ||
1556 | |||
1557 | return 0; | ||
1558 | } | ||
1559 | |||
1560 | /** | ||
1561 | * bcm63xx_ep0_one_round - Handle the current ep0 state. | ||
1562 | * @udc: Reference to the device controller. | ||
1563 | * | ||
1564 | * Returns 0 if work was done; -EAGAIN if nothing to do. | ||
1565 | */ | ||
1566 | static int bcm63xx_ep0_one_round(struct bcm63xx_udc *udc) | ||
1567 | { | ||
1568 | enum bcm63xx_ep0_state ep0state = udc->ep0state; | ||
1569 | bool shutdown = udc->ep0_req_reset || udc->ep0_req_shutdown; | ||
1570 | |||
1571 | switch (udc->ep0state) { | ||
1572 | case EP0_REQUEUE: | ||
1573 | /* set up descriptor to receive SETUP packet */ | ||
1574 | bcm63xx_ep0_internal_request(udc, IUDMA_EP0_RXCHAN, | ||
1575 | BCM63XX_MAX_CTRL_PKT); | ||
1576 | ep0state = EP0_IDLE; | ||
1577 | break; | ||
1578 | case EP0_IDLE: | ||
1579 | return bcm63xx_ep0_do_idle(udc); | ||
1580 | case EP0_IN_DATA_PHASE_SETUP: | ||
1581 | /* | ||
1582 | * Normal case: TX request is in ep0_reply (queued by the | ||
1583 | * callback), or will be queued shortly. When it's here, | ||
1584 | * send it to the HW and go to EP0_IN_DATA_PHASE_COMPLETE. | ||
1585 | * | ||
1586 | * Shutdown case: Stop waiting for the reply. Just | ||
1587 | * REQUEUE->IDLE. The gadget driver is NOT expected to | ||
1588 | * queue anything else now. | ||
1589 | */ | ||
1590 | if (udc->ep0_reply) { | ||
1591 | bcm63xx_ep0_map_write(udc, IUDMA_EP0_TXCHAN, | ||
1592 | udc->ep0_reply); | ||
1593 | ep0state = EP0_IN_DATA_PHASE_COMPLETE; | ||
1594 | } else if (shutdown) { | ||
1595 | ep0state = EP0_REQUEUE; | ||
1596 | } | ||
1597 | break; | ||
1598 | case EP0_IN_DATA_PHASE_COMPLETE: { | ||
1599 | /* | ||
1600 | * Normal case: TX packet (ep0_reply) is in flight; wait for | ||
1601 | * it to finish, then go back to REQUEUE->IDLE. | ||
1602 | * | ||
1603 | * Shutdown case: Reset the TX channel, send -ESHUTDOWN | ||
1604 | * completion to the gadget driver, then REQUEUE->IDLE. | ||
1605 | */ | ||
1606 | if (udc->ep0_req_completed) { | ||
1607 | udc->ep0_reply = NULL; | ||
1608 | bcm63xx_ep0_read_complete(udc); | ||
1609 | /* | ||
1610 | * the "ack" sometimes gets eaten (see | ||
1611 | * bcm63xx_ep0_do_idle) | ||
1612 | */ | ||
1613 | ep0state = EP0_REQUEUE; | ||
1614 | } else if (shutdown) { | ||
1615 | iudma_reset_channel(udc, &udc->iudma[IUDMA_EP0_TXCHAN]); | ||
1616 | bcm63xx_ep0_nuke_reply(udc, 1); | ||
1617 | ep0state = EP0_REQUEUE; | ||
1618 | } | ||
1619 | break; | ||
1620 | } | ||
1621 | case EP0_OUT_DATA_PHASE_SETUP: | ||
1622 | /* Similar behavior to EP0_IN_DATA_PHASE_SETUP */ | ||
1623 | if (udc->ep0_reply) { | ||
1624 | bcm63xx_ep0_map_write(udc, IUDMA_EP0_RXCHAN, | ||
1625 | udc->ep0_reply); | ||
1626 | ep0state = EP0_OUT_DATA_PHASE_COMPLETE; | ||
1627 | } else if (shutdown) { | ||
1628 | ep0state = EP0_REQUEUE; | ||
1629 | } | ||
1630 | break; | ||
1631 | case EP0_OUT_DATA_PHASE_COMPLETE: { | ||
1632 | /* Similar behavior to EP0_IN_DATA_PHASE_COMPLETE */ | ||
1633 | if (udc->ep0_req_completed) { | ||
1634 | udc->ep0_reply = NULL; | ||
1635 | bcm63xx_ep0_read_complete(udc); | ||
1636 | |||
1637 | /* send 0-byte ack to host */ | ||
1638 | bcm63xx_ep0_internal_request(udc, IUDMA_EP0_TXCHAN, 0); | ||
1639 | ep0state = EP0_OUT_STATUS_PHASE; | ||
1640 | } else if (shutdown) { | ||
1641 | iudma_reset_channel(udc, &udc->iudma[IUDMA_EP0_RXCHAN]); | ||
1642 | bcm63xx_ep0_nuke_reply(udc, 0); | ||
1643 | ep0state = EP0_REQUEUE; | ||
1644 | } | ||
1645 | break; | ||
1646 | } | ||
1647 | case EP0_OUT_STATUS_PHASE: | ||
1648 | /* | ||
1649 | * Normal case: 0-byte OUT ack packet is in flight; wait | ||
1650 | * for it to finish, then go back to REQUEUE->IDLE. | ||
1651 | * | ||
1652 | * Shutdown case: just cancel the transmission. Don't bother | ||
1653 | * calling the completion, because it originated from this | ||
1654 | * function anyway. Then go back to REQUEUE->IDLE. | ||
1655 | */ | ||
1656 | if (udc->ep0_req_completed) { | ||
1657 | bcm63xx_ep0_read_complete(udc); | ||
1658 | ep0state = EP0_REQUEUE; | ||
1659 | } else if (shutdown) { | ||
1660 | iudma_reset_channel(udc, &udc->iudma[IUDMA_EP0_TXCHAN]); | ||
1661 | udc->ep0_request = NULL; | ||
1662 | ep0state = EP0_REQUEUE; | ||
1663 | } | ||
1664 | break; | ||
1665 | case EP0_IN_FAKE_STATUS_PHASE: { | ||
1666 | /* | ||
1667 | * Normal case: we spoofed a SETUP packet and are now | ||
1668 | * waiting for the gadget driver to send a 0-byte reply. | ||
1669 | * This doesn't actually get sent to the HW because the | ||
1670 | * HW has already sent its own reply. Once we get the | ||
1671 | * response, return to IDLE. | ||
1672 | * | ||
1673 | * Shutdown case: return to IDLE immediately. | ||
1674 | * | ||
1675 | * Note that the ep0 RX descriptor has remained queued | ||
1676 | * (and possibly unfilled) during this entire transaction. | ||
1677 | * The HW datapath (IUDMA) never even sees SET_CONFIGURATION | ||
1678 | * or SET_INTERFACE transactions. | ||
1679 | */ | ||
1680 | struct usb_request *r = udc->ep0_reply; | ||
1681 | |||
1682 | if (!r) { | ||
1683 | if (shutdown) | ||
1684 | ep0state = EP0_IDLE; | ||
1685 | break; | ||
1686 | } | ||
1687 | |||
1688 | bcm63xx_ep0_complete(udc, r, 0); | ||
1689 | udc->ep0_reply = NULL; | ||
1690 | ep0state = EP0_IDLE; | ||
1691 | break; | ||
1692 | } | ||
1693 | case EP0_SHUTDOWN: | ||
1694 | break; | ||
1695 | } | ||
1696 | |||
1697 | if (udc->ep0state == ep0state) | ||
1698 | return -EAGAIN; | ||
1699 | |||
1700 | udc->ep0state = ep0state; | ||
1701 | return 0; | ||
1702 | } | ||
1703 | |||
1704 | /** | ||
1705 | * bcm63xx_ep0_process - ep0 worker thread / state machine. | ||
1706 | * @w: Workqueue struct. | ||
1707 | * | ||
1708 | * bcm63xx_ep0_process is triggered any time an event occurs on ep0. It | ||
1709 | * is used to synchronize ep0 events and ensure that both HW and SW events | ||
1710 | * occur in a well-defined order. When the ep0 IUDMA queues are idle, it may | ||
1711 | * synthesize SET_CONFIGURATION / SET_INTERFACE requests that were consumed | ||
1712 | * by the USBD hardware. | ||
1713 | * | ||
1714 | * The worker function will continue iterating around the state machine | ||
1715 | * until there is nothing left to do. Usually "nothing left to do" means | ||
1716 | * that we're waiting for a new event from the hardware. | ||
1717 | */ | ||
1718 | static void bcm63xx_ep0_process(struct work_struct *w) | ||
1719 | { | ||
1720 | struct bcm63xx_udc *udc = container_of(w, struct bcm63xx_udc, ep0_wq); | ||
1721 | spin_lock_irq(&udc->lock); | ||
1722 | while (bcm63xx_ep0_one_round(udc) == 0) | ||
1723 | ; | ||
1724 | spin_unlock_irq(&udc->lock); | ||
1725 | } | ||
1726 | |||
1727 | /*********************************************************************** | ||
1728 | * Standard UDC gadget operations | ||
1729 | ***********************************************************************/ | ||
1730 | |||
1731 | /** | ||
1732 | * bcm63xx_udc_get_frame - Read current SOF frame number from the HW. | ||
1733 | * @gadget: USB slave device. | ||
1734 | */ | ||
1735 | static int bcm63xx_udc_get_frame(struct usb_gadget *gadget) | ||
1736 | { | ||
1737 | struct bcm63xx_udc *udc = gadget_to_udc(gadget); | ||
1738 | |||
1739 | return (usbd_readl(udc, USBD_STATUS_REG) & | ||
1740 | USBD_STATUS_SOF_MASK) >> USBD_STATUS_SOF_SHIFT; | ||
1741 | } | ||
1742 | |||
1743 | /** | ||
1744 | * bcm63xx_udc_pullup - Enable/disable pullup on D+ line. | ||
1745 | * @gadget: USB slave device. | ||
1746 | * @is_on: 0 to disable pullup, 1 to enable. | ||
1747 | * | ||
1748 | * See notes in bcm63xx_select_pullup(). | ||
1749 | */ | ||
1750 | static int bcm63xx_udc_pullup(struct usb_gadget *gadget, int is_on) | ||
1751 | { | ||
1752 | struct bcm63xx_udc *udc = gadget_to_udc(gadget); | ||
1753 | unsigned long flags; | ||
1754 | int i, rc = -EINVAL; | ||
1755 | |||
1756 | spin_lock_irqsave(&udc->lock, flags); | ||
1757 | if (is_on && udc->ep0state == EP0_SHUTDOWN) { | ||
1758 | udc->gadget.speed = USB_SPEED_UNKNOWN; | ||
1759 | udc->ep0state = EP0_REQUEUE; | ||
1760 | bcm63xx_fifo_setup(udc); | ||
1761 | bcm63xx_fifo_reset(udc); | ||
1762 | bcm63xx_ep_setup(udc); | ||
1763 | |||
1764 | bitmap_zero(&udc->wedgemap, BCM63XX_NUM_EP); | ||
1765 | for (i = 0; i < BCM63XX_NUM_EP; i++) | ||
1766 | bcm63xx_set_stall(udc, &udc->bep[i], false); | ||
1767 | |||
1768 | bcm63xx_set_ctrl_irqs(udc, true); | ||
1769 | bcm63xx_select_pullup(gadget_to_udc(gadget), true); | ||
1770 | rc = 0; | ||
1771 | } else if (!is_on && udc->ep0state != EP0_SHUTDOWN) { | ||
1772 | bcm63xx_select_pullup(gadget_to_udc(gadget), false); | ||
1773 | |||
1774 | udc->ep0_req_shutdown = 1; | ||
1775 | spin_unlock_irqrestore(&udc->lock, flags); | ||
1776 | |||
1777 | while (1) { | ||
1778 | schedule_work(&udc->ep0_wq); | ||
1779 | if (udc->ep0state == EP0_SHUTDOWN) | ||
1780 | break; | ||
1781 | msleep(50); | ||
1782 | } | ||
1783 | bcm63xx_set_ctrl_irqs(udc, false); | ||
1784 | cancel_work_sync(&udc->ep0_wq); | ||
1785 | return 0; | ||
1786 | } | ||
1787 | |||
1788 | spin_unlock_irqrestore(&udc->lock, flags); | ||
1789 | return rc; | ||
1790 | } | ||
1791 | |||
1792 | /** | ||
1793 | * bcm63xx_udc_start - Start the controller. | ||
1794 | * @gadget: USB slave device. | ||
1795 | * @driver: Driver for USB slave devices. | ||
1796 | */ | ||
1797 | static int bcm63xx_udc_start(struct usb_gadget *gadget, | ||
1798 | struct usb_gadget_driver *driver) | ||
1799 | { | ||
1800 | struct bcm63xx_udc *udc = gadget_to_udc(gadget); | ||
1801 | unsigned long flags; | ||
1802 | |||
1803 | if (!driver || driver->max_speed < USB_SPEED_HIGH || | ||
1804 | !driver->setup) | ||
1805 | return -EINVAL; | ||
1806 | if (!udc) | ||
1807 | return -ENODEV; | ||
1808 | if (udc->driver) | ||
1809 | return -EBUSY; | ||
1810 | |||
1811 | spin_lock_irqsave(&udc->lock, flags); | ||
1812 | |||
1813 | set_clocks(udc, true); | ||
1814 | bcm63xx_fifo_setup(udc); | ||
1815 | bcm63xx_ep_init(udc); | ||
1816 | bcm63xx_ep_setup(udc); | ||
1817 | bcm63xx_fifo_reset(udc); | ||
1818 | bcm63xx_select_phy_mode(udc, true); | ||
1819 | |||
1820 | udc->driver = driver; | ||
1821 | driver->driver.bus = NULL; | ||
1822 | udc->gadget.dev.driver = &driver->driver; | ||
1823 | udc->gadget.dev.of_node = udc->dev->of_node; | ||
1824 | |||
1825 | spin_unlock_irqrestore(&udc->lock, flags); | ||
1826 | |||
1827 | return 0; | ||
1828 | } | ||
1829 | |||
1830 | /** | ||
1831 | * bcm63xx_udc_stop - Shut down the controller. | ||
1832 | * @gadget: USB slave device. | ||
1833 | * @driver: Driver for USB slave devices. | ||
1834 | */ | ||
1835 | static int bcm63xx_udc_stop(struct usb_gadget *gadget, | ||
1836 | struct usb_gadget_driver *driver) | ||
1837 | { | ||
1838 | struct bcm63xx_udc *udc = gadget_to_udc(gadget); | ||
1839 | unsigned long flags; | ||
1840 | |||
1841 | spin_lock_irqsave(&udc->lock, flags); | ||
1842 | |||
1843 | udc->driver = NULL; | ||
1844 | udc->gadget.dev.driver = NULL; | ||
1845 | |||
1846 | /* | ||
1847 | * If we switch the PHY too abruptly after dropping D+, the host | ||
1848 | * will often complain: | ||
1849 | * | ||
1850 | * hub 1-0:1.0: port 1 disabled by hub (EMI?), re-enabling... | ||
1851 | */ | ||
1852 | msleep(100); | ||
1853 | |||
1854 | bcm63xx_select_phy_mode(udc, false); | ||
1855 | set_clocks(udc, false); | ||
1856 | |||
1857 | spin_unlock_irqrestore(&udc->lock, flags); | ||
1858 | |||
1859 | return 0; | ||
1860 | } | ||
1861 | |||
1862 | static const struct usb_gadget_ops bcm63xx_udc_ops = { | ||
1863 | .get_frame = bcm63xx_udc_get_frame, | ||
1864 | .pullup = bcm63xx_udc_pullup, | ||
1865 | .udc_start = bcm63xx_udc_start, | ||
1866 | .udc_stop = bcm63xx_udc_stop, | ||
1867 | }; | ||
1868 | |||
1869 | /*********************************************************************** | ||
1870 | * IRQ handling | ||
1871 | ***********************************************************************/ | ||
1872 | |||
1873 | /** | ||
1874 | * bcm63xx_update_cfg_iface - Read current configuration/interface settings. | ||
1875 | * @udc: Reference to the device controller. | ||
1876 | * | ||
1877 | * This controller intercepts SET_CONFIGURATION and SET_INTERFACE messages. | ||
1878 | * The driver never sees the raw control packets coming in on the ep0 | ||
1879 | * IUDMA channel, but at least we get an interrupt event to tell us that | ||
1880 | * new values are waiting in the USBD_STATUS register. | ||
1881 | */ | ||
1882 | static void bcm63xx_update_cfg_iface(struct bcm63xx_udc *udc) | ||
1883 | { | ||
1884 | u32 reg = usbd_readl(udc, USBD_STATUS_REG); | ||
1885 | |||
1886 | udc->cfg = (reg & USBD_STATUS_CFG_MASK) >> USBD_STATUS_CFG_SHIFT; | ||
1887 | udc->iface = (reg & USBD_STATUS_INTF_MASK) >> USBD_STATUS_INTF_SHIFT; | ||
1888 | udc->alt_iface = (reg & USBD_STATUS_ALTINTF_MASK) >> | ||
1889 | USBD_STATUS_ALTINTF_SHIFT; | ||
1890 | bcm63xx_ep_setup(udc); | ||
1891 | } | ||
1892 | |||
1893 | /** | ||
1894 | * bcm63xx_update_link_speed - Check to see if the link speed has changed. | ||
1895 | * @udc: Reference to the device controller. | ||
1896 | * | ||
1897 | * The link speed update coincides with a SETUP IRQ. Returns 1 if the | ||
1898 | * speed has changed, so that the caller can update the endpoint settings. | ||
1899 | */ | ||
1900 | static int bcm63xx_update_link_speed(struct bcm63xx_udc *udc) | ||
1901 | { | ||
1902 | u32 reg = usbd_readl(udc, USBD_STATUS_REG); | ||
1903 | enum usb_device_speed oldspeed = udc->gadget.speed; | ||
1904 | |||
1905 | switch ((reg & USBD_STATUS_SPD_MASK) >> USBD_STATUS_SPD_SHIFT) { | ||
1906 | case BCM63XX_SPD_HIGH: | ||
1907 | udc->gadget.speed = USB_SPEED_HIGH; | ||
1908 | break; | ||
1909 | case BCM63XX_SPD_FULL: | ||
1910 | udc->gadget.speed = USB_SPEED_FULL; | ||
1911 | break; | ||
1912 | default: | ||
1913 | /* this should never happen */ | ||
1914 | udc->gadget.speed = USB_SPEED_UNKNOWN; | ||
1915 | dev_err(udc->dev, | ||
1916 | "received SETUP packet with invalid link speed\n"); | ||
1917 | return 0; | ||
1918 | } | ||
1919 | |||
1920 | if (udc->gadget.speed != oldspeed) { | ||
1921 | dev_info(udc->dev, "link up, %s-speed mode\n", | ||
1922 | udc->gadget.speed == USB_SPEED_HIGH ? "high" : "full"); | ||
1923 | return 1; | ||
1924 | } else { | ||
1925 | return 0; | ||
1926 | } | ||
1927 | } | ||
1928 | |||
1929 | /** | ||
1930 | * bcm63xx_update_wedge - Iterate through wedged endpoints. | ||
1931 | * @udc: Reference to the device controller. | ||
1932 | * @new_status: true to "refresh" wedge status; false to clear it. | ||
1933 | * | ||
1934 | * On a SETUP interrupt, we need to manually "refresh" the wedge status | ||
1935 | * because the controller hardware is designed to automatically clear | ||
1936 | * stalls in response to a CLEAR_FEATURE request from the host. | ||
1937 | * | ||
1938 | * On a RESET interrupt, we do want to restore all wedged endpoints. | ||
1939 | */ | ||
1940 | static void bcm63xx_update_wedge(struct bcm63xx_udc *udc, bool new_status) | ||
1941 | { | ||
1942 | int i; | ||
1943 | |||
1944 | for_each_set_bit(i, &udc->wedgemap, BCM63XX_NUM_EP) { | ||
1945 | bcm63xx_set_stall(udc, &udc->bep[i], new_status); | ||
1946 | if (!new_status) | ||
1947 | clear_bit(i, &udc->wedgemap); | ||
1948 | } | ||
1949 | } | ||
1950 | |||
1951 | /** | ||
1952 | * bcm63xx_udc_ctrl_isr - ISR for control path events (USBD). | ||
1953 | * @irq: IRQ number (unused). | ||
1954 | * @dev_id: Reference to the device controller. | ||
1955 | * | ||
1956 | * This is where we handle link (VBUS) down, USB reset, speed changes, | ||
1957 | * SET_CONFIGURATION, and SET_INTERFACE events. | ||
1958 | */ | ||
1959 | static irqreturn_t bcm63xx_udc_ctrl_isr(int irq, void *dev_id) | ||
1960 | { | ||
1961 | struct bcm63xx_udc *udc = dev_id; | ||
1962 | u32 stat; | ||
1963 | bool disconnected = false; | ||
1964 | |||
1965 | stat = usbd_readl(udc, USBD_EVENT_IRQ_STATUS_REG) & | ||
1966 | usbd_readl(udc, USBD_EVENT_IRQ_MASK_REG); | ||
1967 | |||
1968 | usbd_writel(udc, stat, USBD_EVENT_IRQ_STATUS_REG); | ||
1969 | |||
1970 | spin_lock(&udc->lock); | ||
1971 | if (stat & BIT(USBD_EVENT_IRQ_USB_LINK)) { | ||
1972 | /* VBUS toggled */ | ||
1973 | |||
1974 | if (!(usbd_readl(udc, USBD_EVENTS_REG) & | ||
1975 | USBD_EVENTS_USB_LINK_MASK) && | ||
1976 | udc->gadget.speed != USB_SPEED_UNKNOWN) | ||
1977 | dev_info(udc->dev, "link down\n"); | ||
1978 | |||
1979 | udc->gadget.speed = USB_SPEED_UNKNOWN; | ||
1980 | disconnected = true; | ||
1981 | } | ||
1982 | if (stat & BIT(USBD_EVENT_IRQ_USB_RESET)) { | ||
1983 | bcm63xx_fifo_setup(udc); | ||
1984 | bcm63xx_fifo_reset(udc); | ||
1985 | bcm63xx_ep_setup(udc); | ||
1986 | |||
1987 | bcm63xx_update_wedge(udc, false); | ||
1988 | |||
1989 | udc->ep0_req_reset = 1; | ||
1990 | schedule_work(&udc->ep0_wq); | ||
1991 | disconnected = true; | ||
1992 | } | ||
1993 | if (stat & BIT(USBD_EVENT_IRQ_SETUP)) { | ||
1994 | if (bcm63xx_update_link_speed(udc)) { | ||
1995 | bcm63xx_fifo_setup(udc); | ||
1996 | bcm63xx_ep_setup(udc); | ||
1997 | } | ||
1998 | bcm63xx_update_wedge(udc, true); | ||
1999 | } | ||
2000 | if (stat & BIT(USBD_EVENT_IRQ_SETCFG)) { | ||
2001 | bcm63xx_update_cfg_iface(udc); | ||
2002 | udc->ep0_req_set_cfg = 1; | ||
2003 | schedule_work(&udc->ep0_wq); | ||
2004 | } | ||
2005 | if (stat & BIT(USBD_EVENT_IRQ_SETINTF)) { | ||
2006 | bcm63xx_update_cfg_iface(udc); | ||
2007 | udc->ep0_req_set_iface = 1; | ||
2008 | schedule_work(&udc->ep0_wq); | ||
2009 | } | ||
2010 | spin_unlock(&udc->lock); | ||
2011 | |||
2012 | if (disconnected && udc->driver) | ||
2013 | udc->driver->disconnect(&udc->gadget); | ||
2014 | |||
2015 | return IRQ_HANDLED; | ||
2016 | } | ||
2017 | |||
2018 | /** | ||
2019 | * bcm63xx_udc_data_isr - ISR for data path events (IUDMA). | ||
2020 | * @irq: IRQ number (unused). | ||
2021 | * @dev_id: Reference to the IUDMA channel that generated the interrupt. | ||
2022 | * | ||
2023 | * For the two ep0 channels, we have special handling that triggers the | ||
2024 | * ep0 worker thread. For normal bulk/intr channels, either queue up | ||
2025 | * the next buffer descriptor for the transaction (incomplete transaction), | ||
2026 | * or invoke the completion callback (complete transactions). | ||
2027 | */ | ||
2028 | static irqreturn_t bcm63xx_udc_data_isr(int irq, void *dev_id) | ||
2029 | { | ||
2030 | struct iudma_ch *iudma = dev_id; | ||
2031 | struct bcm63xx_udc *udc = iudma->udc; | ||
2032 | struct bcm63xx_ep *bep; | ||
2033 | struct usb_request *req = NULL; | ||
2034 | struct bcm63xx_req *breq = NULL; | ||
2035 | int rc; | ||
2036 | bool is_done = false; | ||
2037 | |||
2038 | spin_lock(&udc->lock); | ||
2039 | |||
2040 | usb_dmac_writel(udc, ENETDMAC_IR_BUFDONE_MASK, | ||
2041 | ENETDMAC_IR_REG(iudma->ch_idx)); | ||
2042 | bep = iudma->bep; | ||
2043 | rc = iudma_read(udc, iudma); | ||
2044 | |||
2045 | /* special handling for EP0 RX (0) and TX (1) */ | ||
2046 | if (iudma->ch_idx == IUDMA_EP0_RXCHAN || | ||
2047 | iudma->ch_idx == IUDMA_EP0_TXCHAN) { | ||
2048 | req = udc->ep0_request; | ||
2049 | breq = our_req(req); | ||
2050 | |||
2051 | /* a single request could require multiple submissions */ | ||
2052 | if (rc >= 0) { | ||
2053 | req->actual += rc; | ||
2054 | |||
2055 | if (req->actual >= req->length || breq->bd_bytes > rc) { | ||
2056 | udc->ep0_req_completed = 1; | ||
2057 | is_done = true; | ||
2058 | schedule_work(&udc->ep0_wq); | ||
2059 | |||
2060 | /* "actual" on a ZLP is 1 byte */ | ||
2061 | req->actual = min(req->actual, req->length); | ||
2062 | } else { | ||
2063 | /* queue up the next BD (same request) */ | ||
2064 | iudma_write(udc, iudma, breq); | ||
2065 | } | ||
2066 | } | ||
2067 | } else if (!list_empty(&bep->queue)) { | ||
2068 | breq = list_first_entry(&bep->queue, struct bcm63xx_req, queue); | ||
2069 | req = &breq->req; | ||
2070 | |||
2071 | if (rc >= 0) { | ||
2072 | req->actual += rc; | ||
2073 | |||
2074 | if (req->actual >= req->length || breq->bd_bytes > rc) { | ||
2075 | is_done = true; | ||
2076 | list_del(&breq->queue); | ||
2077 | |||
2078 | req->actual = min(req->actual, req->length); | ||
2079 | |||
2080 | if (!list_empty(&bep->queue)) { | ||
2081 | struct bcm63xx_req *next; | ||
2082 | |||
2083 | next = list_first_entry(&bep->queue, | ||
2084 | struct bcm63xx_req, queue); | ||
2085 | iudma_write(udc, iudma, next); | ||
2086 | } | ||
2087 | } else { | ||
2088 | iudma_write(udc, iudma, breq); | ||
2089 | } | ||
2090 | } | ||
2091 | } | ||
2092 | spin_unlock(&udc->lock); | ||
2093 | |||
2094 | if (is_done) { | ||
2095 | usb_gadget_unmap_request(&udc->gadget, req, iudma->is_tx); | ||
2096 | if (req->complete) | ||
2097 | req->complete(&bep->ep, req); | ||
2098 | } | ||
2099 | |||
2100 | return IRQ_HANDLED; | ||
2101 | } | ||
2102 | |||
2103 | /*********************************************************************** | ||
2104 | * Debug filesystem | ||
2105 | ***********************************************************************/ | ||
2106 | |||
2107 | /* | ||
2108 | * bcm63xx_usbd_dbg_show - Show USBD controller state. | ||
2109 | * @s: seq_file to which the information will be written. | ||
2110 | * @p: Unused. | ||
2111 | * | ||
2112 | * This file nominally shows up as /sys/kernel/debug/bcm63xx_udc/usbd | ||
2113 | */ | ||
2114 | static int bcm63xx_usbd_dbg_show(struct seq_file *s, void *p) | ||
2115 | { | ||
2116 | struct bcm63xx_udc *udc = s->private; | ||
2117 | |||
2118 | if (!udc->driver) | ||
2119 | return -ENODEV; | ||
2120 | |||
2121 | seq_printf(s, "ep0 state: %s\n", | ||
2122 | bcm63xx_ep0_state_names[udc->ep0state]); | ||
2123 | seq_printf(s, " pending requests: %s%s%s%s%s%s%s\n", | ||
2124 | udc->ep0_req_reset ? "reset " : "", | ||
2125 | udc->ep0_req_set_cfg ? "set_cfg " : "", | ||
2126 | udc->ep0_req_set_iface ? "set_iface " : "", | ||
2127 | udc->ep0_req_shutdown ? "shutdown " : "", | ||
2128 | udc->ep0_request ? "pending " : "", | ||
2129 | udc->ep0_req_completed ? "completed " : "", | ||
2130 | udc->ep0_reply ? "reply " : ""); | ||
2131 | seq_printf(s, "cfg: %d; iface: %d; alt_iface: %d\n", | ||
2132 | udc->cfg, udc->iface, udc->alt_iface); | ||
2133 | seq_printf(s, "regs:\n"); | ||
2134 | seq_printf(s, " control: %08x; straps: %08x; status: %08x\n", | ||
2135 | usbd_readl(udc, USBD_CONTROL_REG), | ||
2136 | usbd_readl(udc, USBD_STRAPS_REG), | ||
2137 | usbd_readl(udc, USBD_STATUS_REG)); | ||
2138 | seq_printf(s, " events: %08x; stall: %08x\n", | ||
2139 | usbd_readl(udc, USBD_EVENTS_REG), | ||
2140 | usbd_readl(udc, USBD_STALL_REG)); | ||
2141 | |||
2142 | return 0; | ||
2143 | } | ||
2144 | |||
2145 | /* | ||
2146 | * bcm63xx_iudma_dbg_show - Show IUDMA status and descriptors. | ||
2147 | * @s: seq_file to which the information will be written. | ||
2148 | * @p: Unused. | ||
2149 | * | ||
2150 | * This file nominally shows up as /sys/kernel/debug/bcm63xx_udc/iudma | ||
2151 | */ | ||
2152 | static int bcm63xx_iudma_dbg_show(struct seq_file *s, void *p) | ||
2153 | { | ||
2154 | struct bcm63xx_udc *udc = s->private; | ||
2155 | int ch_idx, i; | ||
2156 | u32 sram2, sram3; | ||
2157 | |||
2158 | if (!udc->driver) | ||
2159 | return -ENODEV; | ||
2160 | |||
2161 | for (ch_idx = 0; ch_idx < BCM63XX_NUM_IUDMA; ch_idx++) { | ||
2162 | struct iudma_ch *iudma = &udc->iudma[ch_idx]; | ||
2163 | struct list_head *pos; | ||
2164 | |||
2165 | seq_printf(s, "IUDMA channel %d -- ", ch_idx); | ||
2166 | switch (iudma_defaults[ch_idx].ep_type) { | ||
2167 | case BCMEP_CTRL: | ||
2168 | seq_printf(s, "control"); | ||
2169 | break; | ||
2170 | case BCMEP_BULK: | ||
2171 | seq_printf(s, "bulk"); | ||
2172 | break; | ||
2173 | case BCMEP_INTR: | ||
2174 | seq_printf(s, "interrupt"); | ||
2175 | break; | ||
2176 | } | ||
2177 | seq_printf(s, ch_idx & 0x01 ? " tx" : " rx"); | ||
2178 | seq_printf(s, " [ep%d]:\n", | ||
2179 | max_t(int, iudma_defaults[ch_idx].ep_num, 0)); | ||
2180 | seq_printf(s, " cfg: %08x; irqstat: %08x; irqmask: %08x; maxburst: %08x\n", | ||
2181 | usb_dmac_readl(udc, ENETDMAC_CHANCFG_REG(ch_idx)), | ||
2182 | usb_dmac_readl(udc, ENETDMAC_IR_REG(ch_idx)), | ||
2183 | usb_dmac_readl(udc, ENETDMAC_IRMASK_REG(ch_idx)), | ||
2184 | usb_dmac_readl(udc, ENETDMAC_MAXBURST_REG(ch_idx))); | ||
2185 | |||
2186 | sram2 = usb_dmas_readl(udc, ENETDMAS_SRAM2_REG(ch_idx)); | ||
2187 | sram3 = usb_dmas_readl(udc, ENETDMAS_SRAM3_REG(ch_idx)); | ||
2188 | seq_printf(s, " base: %08x; index: %04x_%04x; desc: %04x_%04x %08x\n", | ||
2189 | usb_dmas_readl(udc, ENETDMAS_RSTART_REG(ch_idx)), | ||
2190 | sram2 >> 16, sram2 & 0xffff, | ||
2191 | sram3 >> 16, sram3 & 0xffff, | ||
2192 | usb_dmas_readl(udc, ENETDMAS_SRAM4_REG(ch_idx))); | ||
2193 | seq_printf(s, " desc: %d/%d used", iudma->n_bds_used, | ||
2194 | iudma->n_bds); | ||
2195 | |||
2196 | if (iudma->bep) { | ||
2197 | i = 0; | ||
2198 | list_for_each(pos, &iudma->bep->queue) | ||
2199 | i++; | ||
2200 | seq_printf(s, "; %d queued\n", i); | ||
2201 | } else { | ||
2202 | seq_printf(s, "\n"); | ||
2203 | } | ||
2204 | |||
2205 | for (i = 0; i < iudma->n_bds; i++) { | ||
2206 | struct bcm_enet_desc *d = &iudma->bd_ring[i]; | ||
2207 | |||
2208 | seq_printf(s, " %03x (%02x): len_stat: %04x_%04x; pa %08x", | ||
2209 | i * sizeof(*d), i, | ||
2210 | d->len_stat >> 16, d->len_stat & 0xffff, | ||
2211 | d->address); | ||
2212 | if (d == iudma->read_bd) | ||
2213 | seq_printf(s, " <<RD"); | ||
2214 | if (d == iudma->write_bd) | ||
2215 | seq_printf(s, " <<WR"); | ||
2216 | seq_printf(s, "\n"); | ||
2217 | } | ||
2218 | |||
2219 | seq_printf(s, "\n"); | ||
2220 | } | ||
2221 | |||
2222 | return 0; | ||
2223 | } | ||
2224 | |||
2225 | static int bcm63xx_usbd_dbg_open(struct inode *inode, struct file *file) | ||
2226 | { | ||
2227 | return single_open(file, bcm63xx_usbd_dbg_show, inode->i_private); | ||
2228 | } | ||
2229 | |||
2230 | static int bcm63xx_iudma_dbg_open(struct inode *inode, struct file *file) | ||
2231 | { | ||
2232 | return single_open(file, bcm63xx_iudma_dbg_show, inode->i_private); | ||
2233 | } | ||
2234 | |||
2235 | static const struct file_operations usbd_dbg_fops = { | ||
2236 | .owner = THIS_MODULE, | ||
2237 | .open = bcm63xx_usbd_dbg_open, | ||
2238 | .llseek = seq_lseek, | ||
2239 | .read = seq_read, | ||
2240 | .release = single_release, | ||
2241 | }; | ||
2242 | |||
2243 | static const struct file_operations iudma_dbg_fops = { | ||
2244 | .owner = THIS_MODULE, | ||
2245 | .open = bcm63xx_iudma_dbg_open, | ||
2246 | .llseek = seq_lseek, | ||
2247 | .read = seq_read, | ||
2248 | .release = single_release, | ||
2249 | }; | ||
2250 | |||
2251 | |||
2252 | /** | ||
2253 | * bcm63xx_udc_init_debugfs - Create debugfs entries. | ||
2254 | * @udc: Reference to the device controller. | ||
2255 | */ | ||
2256 | static void bcm63xx_udc_init_debugfs(struct bcm63xx_udc *udc) | ||
2257 | { | ||
2258 | struct dentry *root, *usbd, *iudma; | ||
2259 | |||
2260 | if (!IS_ENABLED(CONFIG_USB_GADGET_DEBUG_FS)) | ||
2261 | return; | ||
2262 | |||
2263 | root = debugfs_create_dir(udc->gadget.name, NULL); | ||
2264 | if (IS_ERR(root) || !root) | ||
2265 | goto err_root; | ||
2266 | |||
2267 | usbd = debugfs_create_file("usbd", 0400, root, udc, | ||
2268 | &usbd_dbg_fops); | ||
2269 | if (!usbd) | ||
2270 | goto err_usbd; | ||
2271 | iudma = debugfs_create_file("iudma", 0400, root, udc, | ||
2272 | &iudma_dbg_fops); | ||
2273 | if (!iudma) | ||
2274 | goto err_iudma; | ||
2275 | |||
2276 | udc->debugfs_root = root; | ||
2277 | udc->debugfs_usbd = usbd; | ||
2278 | udc->debugfs_iudma = iudma; | ||
2279 | return; | ||
2280 | err_iudma: | ||
2281 | debugfs_remove(usbd); | ||
2282 | err_usbd: | ||
2283 | debugfs_remove(root); | ||
2284 | err_root: | ||
2285 | dev_err(udc->dev, "debugfs is not available\n"); | ||
2286 | } | ||
2287 | |||
2288 | /** | ||
2289 | * bcm63xx_udc_cleanup_debugfs - Remove debugfs entries. | ||
2290 | * @udc: Reference to the device controller. | ||
2291 | * | ||
2292 | * debugfs_remove() is safe to call with a NULL argument. | ||
2293 | */ | ||
2294 | static void bcm63xx_udc_cleanup_debugfs(struct bcm63xx_udc *udc) | ||
2295 | { | ||
2296 | debugfs_remove(udc->debugfs_iudma); | ||
2297 | debugfs_remove(udc->debugfs_usbd); | ||
2298 | debugfs_remove(udc->debugfs_root); | ||
2299 | udc->debugfs_iudma = NULL; | ||
2300 | udc->debugfs_usbd = NULL; | ||
2301 | udc->debugfs_root = NULL; | ||
2302 | } | ||
2303 | |||
2304 | /*********************************************************************** | ||
2305 | * Driver init/exit | ||
2306 | ***********************************************************************/ | ||
2307 | |||
2308 | /** | ||
2309 | * bcm63xx_udc_gadget_release - Called from device_release(). | ||
2310 | * @dev: Unused. | ||
2311 | * | ||
2312 | * We get a warning if this function doesn't exist, but it's empty because | ||
2313 | * we don't have to free any of the memory allocated with the devm_* APIs. | ||
2314 | */ | ||
2315 | static void bcm63xx_udc_gadget_release(struct device *dev) | ||
2316 | { | ||
2317 | } | ||
2318 | |||
2319 | /** | ||
2320 | * bcm63xx_udc_probe - Initialize a new instance of the UDC. | ||
2321 | * @pdev: Platform device struct from the bcm63xx BSP code. | ||
2322 | * | ||
2323 | * Note that platform data is required, because pd.port_no varies from chip | ||
2324 | * to chip and is used to switch the correct USB port to device mode. | ||
2325 | */ | ||
2326 | static int __devinit bcm63xx_udc_probe(struct platform_device *pdev) | ||
2327 | { | ||
2328 | struct device *dev = &pdev->dev; | ||
2329 | struct bcm63xx_usbd_platform_data *pd = dev->platform_data; | ||
2330 | struct bcm63xx_udc *udc; | ||
2331 | struct resource *res; | ||
2332 | int rc = -ENOMEM, i, irq; | ||
2333 | |||
2334 | udc = devm_kzalloc(dev, sizeof(*udc), GFP_KERNEL); | ||
2335 | if (!udc) { | ||
2336 | dev_err(dev, "cannot allocate memory\n"); | ||
2337 | return -ENOMEM; | ||
2338 | } | ||
2339 | |||
2340 | platform_set_drvdata(pdev, udc); | ||
2341 | udc->dev = dev; | ||
2342 | udc->pd = pd; | ||
2343 | |||
2344 | if (!pd) { | ||
2345 | dev_err(dev, "missing platform data\n"); | ||
2346 | return -EINVAL; | ||
2347 | } | ||
2348 | |||
2349 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
2350 | if (!res) { | ||
2351 | dev_err(dev, "error finding USBD resource\n"); | ||
2352 | return -ENXIO; | ||
2353 | } | ||
2354 | udc->usbd_regs = devm_request_and_ioremap(dev, res); | ||
2355 | |||
2356 | res = platform_get_resource(pdev, IORESOURCE_MEM, 1); | ||
2357 | if (!res) { | ||
2358 | dev_err(dev, "error finding IUDMA resource\n"); | ||
2359 | return -ENXIO; | ||
2360 | } | ||
2361 | udc->iudma_regs = devm_request_and_ioremap(dev, res); | ||
2362 | |||
2363 | if (!udc->usbd_regs || !udc->iudma_regs) { | ||
2364 | dev_err(dev, "error requesting resources\n"); | ||
2365 | return -ENXIO; | ||
2366 | } | ||
2367 | |||
2368 | spin_lock_init(&udc->lock); | ||
2369 | INIT_WORK(&udc->ep0_wq, bcm63xx_ep0_process); | ||
2370 | dev_set_name(&udc->gadget.dev, "gadget"); | ||
2371 | |||
2372 | udc->gadget.ops = &bcm63xx_udc_ops; | ||
2373 | udc->gadget.name = dev_name(dev); | ||
2374 | udc->gadget.dev.parent = dev; | ||
2375 | udc->gadget.dev.release = bcm63xx_udc_gadget_release; | ||
2376 | udc->gadget.dev.dma_mask = dev->dma_mask; | ||
2377 | |||
2378 | if (!pd->use_fullspeed && !use_fullspeed) | ||
2379 | udc->gadget.max_speed = USB_SPEED_HIGH; | ||
2380 | else | ||
2381 | udc->gadget.max_speed = USB_SPEED_FULL; | ||
2382 | |||
2383 | /* request clocks, allocate buffers, and clear any pending IRQs */ | ||
2384 | rc = bcm63xx_init_udc_hw(udc); | ||
2385 | if (rc) | ||
2386 | return rc; | ||
2387 | |||
2388 | rc = -ENXIO; | ||
2389 | |||
2390 | /* IRQ resource #0: control interrupt (VBUS, speed, etc.) */ | ||
2391 | irq = platform_get_irq(pdev, 0); | ||
2392 | if (irq < 0) { | ||
2393 | dev_err(dev, "missing IRQ resource #0\n"); | ||
2394 | goto out_uninit; | ||
2395 | } | ||
2396 | if (devm_request_irq(dev, irq, &bcm63xx_udc_ctrl_isr, 0, | ||
2397 | dev_name(dev), udc) < 0) { | ||
2398 | dev_err(dev, "error requesting IRQ #%d\n", irq); | ||
2399 | goto out_uninit; | ||
2400 | } | ||
2401 | |||
2402 | /* IRQ resources #1-6: data interrupts for IUDMA channels 0-5 */ | ||
2403 | for (i = 0; i < BCM63XX_NUM_IUDMA; i++) { | ||
2404 | irq = platform_get_irq(pdev, i + 1); | ||
2405 | if (irq < 0) { | ||
2406 | dev_err(dev, "missing IRQ resource #%d\n", i + 1); | ||
2407 | goto out_uninit; | ||
2408 | } | ||
2409 | if (devm_request_irq(dev, irq, &bcm63xx_udc_data_isr, 0, | ||
2410 | dev_name(dev), &udc->iudma[i]) < 0) { | ||
2411 | dev_err(dev, "error requesting IRQ #%d\n", irq); | ||
2412 | goto out_uninit; | ||
2413 | } | ||
2414 | } | ||
2415 | |||
2416 | rc = device_register(&udc->gadget.dev); | ||
2417 | if (rc) | ||
2418 | goto out_uninit; | ||
2419 | |||
2420 | bcm63xx_udc_init_debugfs(udc); | ||
2421 | rc = usb_add_gadget_udc(dev, &udc->gadget); | ||
2422 | if (!rc) | ||
2423 | return 0; | ||
2424 | |||
2425 | bcm63xx_udc_cleanup_debugfs(udc); | ||
2426 | device_unregister(&udc->gadget.dev); | ||
2427 | out_uninit: | ||
2428 | bcm63xx_uninit_udc_hw(udc); | ||
2429 | return rc; | ||
2430 | } | ||
2431 | |||
2432 | /** | ||
2433 | * bcm63xx_udc_remove - Remove the device from the system. | ||
2434 | * @pdev: Platform device struct from the bcm63xx BSP code. | ||
2435 | */ | ||
2436 | static int __devexit bcm63xx_udc_remove(struct platform_device *pdev) | ||
2437 | { | ||
2438 | struct bcm63xx_udc *udc = platform_get_drvdata(pdev); | ||
2439 | |||
2440 | bcm63xx_udc_cleanup_debugfs(udc); | ||
2441 | usb_del_gadget_udc(&udc->gadget); | ||
2442 | device_unregister(&udc->gadget.dev); | ||
2443 | BUG_ON(udc->driver); | ||
2444 | |||
2445 | platform_set_drvdata(pdev, NULL); | ||
2446 | bcm63xx_uninit_udc_hw(udc); | ||
2447 | |||
2448 | return 0; | ||
2449 | } | ||
2450 | |||
2451 | static struct platform_driver bcm63xx_udc_driver = { | ||
2452 | .probe = bcm63xx_udc_probe, | ||
2453 | .remove = __devexit_p(bcm63xx_udc_remove), | ||
2454 | .driver = { | ||
2455 | .name = DRV_MODULE_NAME, | ||
2456 | .owner = THIS_MODULE, | ||
2457 | }, | ||
2458 | }; | ||
2459 | module_platform_driver(bcm63xx_udc_driver); | ||
2460 | |||
2461 | MODULE_DESCRIPTION("BCM63xx USB Peripheral Controller"); | ||
2462 | MODULE_AUTHOR("Kevin Cernekee <cernekee@gmail.com>"); | ||
2463 | MODULE_LICENSE("GPL"); | ||
2464 | MODULE_ALIAS("platform:" DRV_MODULE_NAME); | ||
diff --git a/drivers/usb/gadget/cdc2.c b/drivers/usb/gadget/cdc2.c index 725550f06fab..1e4bb77f00bb 100644 --- a/drivers/usb/gadget/cdc2.c +++ b/drivers/usb/gadget/cdc2.c | |||
@@ -11,7 +11,6 @@ | |||
11 | */ | 11 | */ |
12 | 12 | ||
13 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
14 | #include <linux/utsname.h> | ||
15 | #include <linux/module.h> | 14 | #include <linux/module.h> |
16 | 15 | ||
17 | #include "u_ether.h" | 16 | #include "u_ether.h" |
@@ -34,6 +33,7 @@ | |||
34 | #define CDC_PRODUCT_NUM 0xa4aa /* CDC Composite: ECM + ACM */ | 33 | #define CDC_PRODUCT_NUM 0xa4aa /* CDC Composite: ECM + ACM */ |
35 | 34 | ||
36 | /*-------------------------------------------------------------------------*/ | 35 | /*-------------------------------------------------------------------------*/ |
36 | USB_GADGET_COMPOSITE_OPTIONS(); | ||
37 | 37 | ||
38 | /* | 38 | /* |
39 | * Kbuild is not very cooperative with respect to linking separately | 39 | * Kbuild is not very cooperative with respect to linking separately |
@@ -43,10 +43,6 @@ | |||
43 | * a "gcc --combine ... part1.c part2.c part3.c ... " build would. | 43 | * a "gcc --combine ... part1.c part2.c part3.c ... " build would. |
44 | */ | 44 | */ |
45 | 45 | ||
46 | #include "composite.c" | ||
47 | #include "usbstring.c" | ||
48 | #include "config.c" | ||
49 | #include "epautoconf.c" | ||
50 | #include "u_serial.c" | 46 | #include "u_serial.c" |
51 | #include "f_acm.c" | 47 | #include "f_acm.c" |
52 | #include "f_ecm.c" | 48 | #include "f_ecm.c" |
@@ -92,15 +88,10 @@ static const struct usb_descriptor_header *otg_desc[] = { | |||
92 | 88 | ||
93 | 89 | ||
94 | /* string IDs are assigned dynamically */ | 90 | /* string IDs are assigned dynamically */ |
95 | |||
96 | #define STRING_MANUFACTURER_IDX 0 | ||
97 | #define STRING_PRODUCT_IDX 1 | ||
98 | |||
99 | static char manufacturer[50]; | ||
100 | |||
101 | static struct usb_string strings_dev[] = { | 91 | static struct usb_string strings_dev[] = { |
102 | [STRING_MANUFACTURER_IDX].s = manufacturer, | 92 | [USB_GADGET_MANUFACTURER_IDX].s = "", |
103 | [STRING_PRODUCT_IDX].s = DRIVER_DESC, | 93 | [USB_GADGET_PRODUCT_IDX].s = DRIVER_DESC, |
94 | [USB_GADGET_SERIAL_IDX].s = "", | ||
104 | { } /* end of list */ | 95 | { } /* end of list */ |
105 | }; | 96 | }; |
106 | 97 | ||
@@ -152,7 +143,6 @@ static struct usb_configuration cdc_config_driver = { | |||
152 | 143 | ||
153 | static int __init cdc_bind(struct usb_composite_dev *cdev) | 144 | static int __init cdc_bind(struct usb_composite_dev *cdev) |
154 | { | 145 | { |
155 | int gcnum; | ||
156 | struct usb_gadget *gadget = cdev->gadget; | 146 | struct usb_gadget *gadget = cdev->gadget; |
157 | int status; | 147 | int status; |
158 | 148 | ||
@@ -172,47 +162,22 @@ static int __init cdc_bind(struct usb_composite_dev *cdev) | |||
172 | if (status < 0) | 162 | if (status < 0) |
173 | goto fail0; | 163 | goto fail0; |
174 | 164 | ||
175 | gcnum = usb_gadget_controller_number(gadget); | ||
176 | if (gcnum >= 0) | ||
177 | device_desc.bcdDevice = cpu_to_le16(0x0300 | gcnum); | ||
178 | else { | ||
179 | /* We assume that can_support_ecm() tells the truth; | ||
180 | * but if the controller isn't recognized at all then | ||
181 | * that assumption is a bit more likely to be wrong. | ||
182 | */ | ||
183 | WARNING(cdev, "controller '%s' not recognized; trying %s\n", | ||
184 | gadget->name, | ||
185 | cdc_config_driver.label); | ||
186 | device_desc.bcdDevice = | ||
187 | cpu_to_le16(0x0300 | 0x0099); | ||
188 | } | ||
189 | |||
190 | |||
191 | /* Allocate string descriptor numbers ... note that string | 165 | /* Allocate string descriptor numbers ... note that string |
192 | * contents can be overridden by the composite_dev glue. | 166 | * contents can be overridden by the composite_dev glue. |
193 | */ | 167 | */ |
194 | 168 | ||
195 | /* device descriptor strings: manufacturer, product */ | 169 | status = usb_string_ids_tab(cdev, strings_dev); |
196 | snprintf(manufacturer, sizeof manufacturer, "%s %s with %s", | ||
197 | init_utsname()->sysname, init_utsname()->release, | ||
198 | gadget->name); | ||
199 | status = usb_string_id(cdev); | ||
200 | if (status < 0) | ||
201 | goto fail1; | ||
202 | strings_dev[STRING_MANUFACTURER_IDX].id = status; | ||
203 | device_desc.iManufacturer = status; | ||
204 | |||
205 | status = usb_string_id(cdev); | ||
206 | if (status < 0) | 170 | if (status < 0) |
207 | goto fail1; | 171 | goto fail1; |
208 | strings_dev[STRING_PRODUCT_IDX].id = status; | 172 | device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id; |
209 | device_desc.iProduct = status; | 173 | device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; |
210 | 174 | ||
211 | /* register our configuration */ | 175 | /* register our configuration */ |
212 | status = usb_add_config(cdev, &cdc_config_driver, cdc_do_config); | 176 | status = usb_add_config(cdev, &cdc_config_driver, cdc_do_config); |
213 | if (status < 0) | 177 | if (status < 0) |
214 | goto fail1; | 178 | goto fail1; |
215 | 179 | ||
180 | usb_composite_overwrite_options(cdev, &coverwrite); | ||
216 | dev_info(&gadget->dev, "%s, version: " DRIVER_VERSION "\n", | 181 | dev_info(&gadget->dev, "%s, version: " DRIVER_VERSION "\n", |
217 | DRIVER_DESC); | 182 | DRIVER_DESC); |
218 | 183 | ||
@@ -232,11 +197,12 @@ static int __exit cdc_unbind(struct usb_composite_dev *cdev) | |||
232 | return 0; | 197 | return 0; |
233 | } | 198 | } |
234 | 199 | ||
235 | static struct usb_composite_driver cdc_driver = { | 200 | static __refdata struct usb_composite_driver cdc_driver = { |
236 | .name = "g_cdc", | 201 | .name = "g_cdc", |
237 | .dev = &device_desc, | 202 | .dev = &device_desc, |
238 | .strings = dev_strings, | 203 | .strings = dev_strings, |
239 | .max_speed = USB_SPEED_HIGH, | 204 | .max_speed = USB_SPEED_HIGH, |
205 | .bind = cdc_bind, | ||
240 | .unbind = __exit_p(cdc_unbind), | 206 | .unbind = __exit_p(cdc_unbind), |
241 | }; | 207 | }; |
242 | 208 | ||
@@ -246,7 +212,7 @@ MODULE_LICENSE("GPL"); | |||
246 | 212 | ||
247 | static int __init init(void) | 213 | static int __init init(void) |
248 | { | 214 | { |
249 | return usb_composite_probe(&cdc_driver, cdc_bind); | 215 | return usb_composite_probe(&cdc_driver); |
250 | } | 216 | } |
251 | module_init(init); | 217 | module_init(init); |
252 | 218 | ||
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 3f72110da1b0..957f973dd96a 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c | |||
@@ -28,44 +28,6 @@ | |||
28 | * with the relevant device-wide data. | 28 | * with the relevant device-wide data. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | /* big enough to hold our biggest descriptor */ | ||
32 | #define USB_BUFSIZ 1024 | ||
33 | |||
34 | static struct usb_composite_driver *composite; | ||
35 | static int (*composite_gadget_bind)(struct usb_composite_dev *cdev); | ||
36 | |||
37 | /* Some systems will need runtime overrides for the product identifiers | ||
38 | * published in the device descriptor, either numbers or strings or both. | ||
39 | * String parameters are in UTF-8 (superset of ASCII's 7 bit characters). | ||
40 | */ | ||
41 | |||
42 | static ushort idVendor; | ||
43 | module_param(idVendor, ushort, 0644); | ||
44 | MODULE_PARM_DESC(idVendor, "USB Vendor ID"); | ||
45 | |||
46 | static ushort idProduct; | ||
47 | module_param(idProduct, ushort, 0644); | ||
48 | MODULE_PARM_DESC(idProduct, "USB Product ID"); | ||
49 | |||
50 | static ushort bcdDevice; | ||
51 | module_param(bcdDevice, ushort, 0644); | ||
52 | MODULE_PARM_DESC(bcdDevice, "USB Device version (BCD)"); | ||
53 | |||
54 | static char *iManufacturer; | ||
55 | module_param(iManufacturer, charp, 0644); | ||
56 | MODULE_PARM_DESC(iManufacturer, "USB Manufacturer string"); | ||
57 | |||
58 | static char *iProduct; | ||
59 | module_param(iProduct, charp, 0644); | ||
60 | MODULE_PARM_DESC(iProduct, "USB Product string"); | ||
61 | |||
62 | static char *iSerialNumber; | ||
63 | module_param(iSerialNumber, charp, 0644); | ||
64 | MODULE_PARM_DESC(iSerialNumber, "SerialNumber string"); | ||
65 | |||
66 | static char composite_manufacturer[50]; | ||
67 | |||
68 | /*-------------------------------------------------------------------------*/ | ||
69 | /** | 31 | /** |
70 | * next_ep_desc() - advance to the next EP descriptor | 32 | * next_ep_desc() - advance to the next EP descriptor |
71 | * @t: currect pointer within descriptor array | 33 | * @t: currect pointer within descriptor array |
@@ -192,6 +154,7 @@ ep_found: | |||
192 | } | 154 | } |
193 | return 0; | 155 | return 0; |
194 | } | 156 | } |
157 | EXPORT_SYMBOL_GPL(config_ep_by_speed); | ||
195 | 158 | ||
196 | /** | 159 | /** |
197 | * usb_add_function() - add a function to a configuration | 160 | * usb_add_function() - add a function to a configuration |
@@ -250,6 +213,7 @@ done: | |||
250 | function->name, function, value); | 213 | function->name, function, value); |
251 | return value; | 214 | return value; |
252 | } | 215 | } |
216 | EXPORT_SYMBOL_GPL(usb_add_function); | ||
253 | 217 | ||
254 | /** | 218 | /** |
255 | * usb_function_deactivate - prevent function and gadget enumeration | 219 | * usb_function_deactivate - prevent function and gadget enumeration |
@@ -286,6 +250,7 @@ int usb_function_deactivate(struct usb_function *function) | |||
286 | spin_unlock_irqrestore(&cdev->lock, flags); | 250 | spin_unlock_irqrestore(&cdev->lock, flags); |
287 | return status; | 251 | return status; |
288 | } | 252 | } |
253 | EXPORT_SYMBOL_GPL(usb_function_deactivate); | ||
289 | 254 | ||
290 | /** | 255 | /** |
291 | * usb_function_activate - allow function and gadget enumeration | 256 | * usb_function_activate - allow function and gadget enumeration |
@@ -300,9 +265,10 @@ int usb_function_deactivate(struct usb_function *function) | |||
300 | int usb_function_activate(struct usb_function *function) | 265 | int usb_function_activate(struct usb_function *function) |
301 | { | 266 | { |
302 | struct usb_composite_dev *cdev = function->config->cdev; | 267 | struct usb_composite_dev *cdev = function->config->cdev; |
268 | unsigned long flags; | ||
303 | int status = 0; | 269 | int status = 0; |
304 | 270 | ||
305 | spin_lock(&cdev->lock); | 271 | spin_lock_irqsave(&cdev->lock, flags); |
306 | 272 | ||
307 | if (WARN_ON(cdev->deactivations == 0)) | 273 | if (WARN_ON(cdev->deactivations == 0)) |
308 | status = -EINVAL; | 274 | status = -EINVAL; |
@@ -312,9 +278,10 @@ int usb_function_activate(struct usb_function *function) | |||
312 | status = usb_gadget_connect(cdev->gadget); | 278 | status = usb_gadget_connect(cdev->gadget); |
313 | } | 279 | } |
314 | 280 | ||
315 | spin_unlock(&cdev->lock); | 281 | spin_unlock_irqrestore(&cdev->lock, flags); |
316 | return status; | 282 | return status; |
317 | } | 283 | } |
284 | EXPORT_SYMBOL_GPL(usb_function_activate); | ||
318 | 285 | ||
319 | /** | 286 | /** |
320 | * usb_interface_id() - allocate an unused interface ID | 287 | * usb_interface_id() - allocate an unused interface ID |
@@ -351,16 +318,18 @@ int usb_interface_id(struct usb_configuration *config, | |||
351 | } | 318 | } |
352 | return -ENODEV; | 319 | return -ENODEV; |
353 | } | 320 | } |
321 | EXPORT_SYMBOL_GPL(usb_interface_id); | ||
354 | 322 | ||
355 | static int config_buf(struct usb_configuration *config, | 323 | static int config_buf(struct usb_configuration *config, |
356 | enum usb_device_speed speed, void *buf, u8 type) | 324 | enum usb_device_speed speed, void *buf, u8 type) |
357 | { | 325 | { |
358 | struct usb_config_descriptor *c = buf; | 326 | struct usb_config_descriptor *c = buf; |
359 | void *next = buf + USB_DT_CONFIG_SIZE; | 327 | void *next = buf + USB_DT_CONFIG_SIZE; |
360 | int len = USB_BUFSIZ - USB_DT_CONFIG_SIZE; | 328 | int len; |
361 | struct usb_function *f; | 329 | struct usb_function *f; |
362 | int status; | 330 | int status; |
363 | 331 | ||
332 | len = USB_COMP_EP0_BUFSIZ - USB_DT_CONFIG_SIZE; | ||
364 | /* write the config descriptor */ | 333 | /* write the config descriptor */ |
365 | c = buf; | 334 | c = buf; |
366 | c->bLength = USB_DT_CONFIG_SIZE; | 335 | c->bLength = USB_DT_CONFIG_SIZE; |
@@ -790,6 +759,7 @@ done: | |||
790 | config->bConfigurationValue, status); | 759 | config->bConfigurationValue, status); |
791 | return status; | 760 | return status; |
792 | } | 761 | } |
762 | EXPORT_SYMBOL_GPL(usb_add_config); | ||
793 | 763 | ||
794 | static void remove_config(struct usb_composite_dev *cdev, | 764 | static void remove_config(struct usb_composite_dev *cdev, |
795 | struct usb_configuration *config) | 765 | struct usb_configuration *config) |
@@ -889,10 +859,10 @@ static int lookup_string( | |||
889 | static int get_string(struct usb_composite_dev *cdev, | 859 | static int get_string(struct usb_composite_dev *cdev, |
890 | void *buf, u16 language, int id) | 860 | void *buf, u16 language, int id) |
891 | { | 861 | { |
862 | struct usb_composite_driver *composite = cdev->driver; | ||
892 | struct usb_configuration *c; | 863 | struct usb_configuration *c; |
893 | struct usb_function *f; | 864 | struct usb_function *f; |
894 | int len; | 865 | int len; |
895 | const char *str; | ||
896 | 866 | ||
897 | /* Yes, not only is USB's I18N support probably more than most | 867 | /* Yes, not only is USB's I18N support probably more than most |
898 | * folk will ever care about ... also, it's all supported here. | 868 | * folk will ever care about ... also, it's all supported here. |
@@ -932,26 +902,6 @@ static int get_string(struct usb_composite_dev *cdev, | |||
932 | return s->bLength; | 902 | return s->bLength; |
933 | } | 903 | } |
934 | 904 | ||
935 | /* Otherwise, look up and return a specified string. First | ||
936 | * check if the string has not been overridden. | ||
937 | */ | ||
938 | if (cdev->manufacturer_override == id) | ||
939 | str = iManufacturer ?: composite->iManufacturer ?: | ||
940 | composite_manufacturer; | ||
941 | else if (cdev->product_override == id) | ||
942 | str = iProduct ?: composite->iProduct; | ||
943 | else if (cdev->serial_override == id) | ||
944 | str = iSerialNumber ?: composite->iSerialNumber; | ||
945 | else | ||
946 | str = NULL; | ||
947 | if (str) { | ||
948 | struct usb_gadget_strings strings = { | ||
949 | .language = language, | ||
950 | .strings = &(struct usb_string) { 0xff, str } | ||
951 | }; | ||
952 | return usb_gadget_get_string(&strings, 0xff, buf); | ||
953 | } | ||
954 | |||
955 | /* String IDs are device-scoped, so we look up each string | 905 | /* String IDs are device-scoped, so we look up each string |
956 | * table we're told about. These lookups are infrequent; | 906 | * table we're told about. These lookups are infrequent; |
957 | * simpler-is-better here. | 907 | * simpler-is-better here. |
@@ -1003,6 +953,7 @@ int usb_string_id(struct usb_composite_dev *cdev) | |||
1003 | } | 953 | } |
1004 | return -ENODEV; | 954 | return -ENODEV; |
1005 | } | 955 | } |
956 | EXPORT_SYMBOL_GPL(usb_string_id); | ||
1006 | 957 | ||
1007 | /** | 958 | /** |
1008 | * usb_string_ids() - allocate unused string IDs in batch | 959 | * usb_string_ids() - allocate unused string IDs in batch |
@@ -1034,6 +985,7 @@ int usb_string_ids_tab(struct usb_composite_dev *cdev, struct usb_string *str) | |||
1034 | 985 | ||
1035 | return 0; | 986 | return 0; |
1036 | } | 987 | } |
988 | EXPORT_SYMBOL_GPL(usb_string_ids_tab); | ||
1037 | 989 | ||
1038 | /** | 990 | /** |
1039 | * usb_string_ids_n() - allocate unused string IDs in batch | 991 | * usb_string_ids_n() - allocate unused string IDs in batch |
@@ -1062,7 +1014,7 @@ int usb_string_ids_n(struct usb_composite_dev *c, unsigned n) | |||
1062 | c->next_string_id += n; | 1014 | c->next_string_id += n; |
1063 | return next + 1; | 1015 | return next + 1; |
1064 | } | 1016 | } |
1065 | 1017 | EXPORT_SYMBOL_GPL(usb_string_ids_n); | |
1066 | 1018 | ||
1067 | /*-------------------------------------------------------------------------*/ | 1019 | /*-------------------------------------------------------------------------*/ |
1068 | 1020 | ||
@@ -1359,8 +1311,8 @@ static void composite_disconnect(struct usb_gadget *gadget) | |||
1359 | spin_lock_irqsave(&cdev->lock, flags); | 1311 | spin_lock_irqsave(&cdev->lock, flags); |
1360 | if (cdev->config) | 1312 | if (cdev->config) |
1361 | reset_config(cdev); | 1313 | reset_config(cdev); |
1362 | if (composite->disconnect) | 1314 | if (cdev->driver->disconnect) |
1363 | composite->disconnect(cdev); | 1315 | cdev->driver->disconnect(cdev); |
1364 | spin_unlock_irqrestore(&cdev->lock, flags); | 1316 | spin_unlock_irqrestore(&cdev->lock, flags); |
1365 | } | 1317 | } |
1366 | 1318 | ||
@@ -1396,35 +1348,67 @@ composite_unbind(struct usb_gadget *gadget) | |||
1396 | struct usb_configuration, list); | 1348 | struct usb_configuration, list); |
1397 | remove_config(cdev, c); | 1349 | remove_config(cdev, c); |
1398 | } | 1350 | } |
1399 | if (composite->unbind) | 1351 | if (cdev->driver->unbind) |
1400 | composite->unbind(cdev); | 1352 | cdev->driver->unbind(cdev); |
1401 | 1353 | ||
1402 | if (cdev->req) { | 1354 | if (cdev->req) { |
1403 | kfree(cdev->req->buf); | 1355 | kfree(cdev->req->buf); |
1404 | usb_ep_free_request(gadget->ep0, cdev->req); | 1356 | usb_ep_free_request(gadget->ep0, cdev->req); |
1405 | } | 1357 | } |
1406 | device_remove_file(&gadget->dev, &dev_attr_suspended); | 1358 | device_remove_file(&gadget->dev, &dev_attr_suspended); |
1359 | kfree(cdev->def_manufacturer); | ||
1407 | kfree(cdev); | 1360 | kfree(cdev); |
1408 | set_gadget_data(gadget, NULL); | 1361 | set_gadget_data(gadget, NULL); |
1409 | composite = NULL; | ||
1410 | } | 1362 | } |
1411 | 1363 | ||
1412 | static u8 override_id(struct usb_composite_dev *cdev, u8 *desc) | 1364 | static void update_unchanged_dev_desc(struct usb_device_descriptor *new, |
1365 | const struct usb_device_descriptor *old) | ||
1413 | { | 1366 | { |
1414 | if (!*desc) { | 1367 | __le16 idVendor; |
1415 | int ret = usb_string_id(cdev); | 1368 | __le16 idProduct; |
1416 | if (unlikely(ret < 0)) | 1369 | __le16 bcdDevice; |
1417 | WARNING(cdev, "failed to override string ID\n"); | 1370 | u8 iSerialNumber; |
1418 | else | 1371 | u8 iManufacturer; |
1419 | *desc = ret; | 1372 | u8 iProduct; |
1420 | } | ||
1421 | 1373 | ||
1422 | return *desc; | 1374 | /* |
1375 | * these variables may have been set in | ||
1376 | * usb_composite_overwrite_options() | ||
1377 | */ | ||
1378 | idVendor = new->idVendor; | ||
1379 | idProduct = new->idProduct; | ||
1380 | bcdDevice = new->bcdDevice; | ||
1381 | iSerialNumber = new->iSerialNumber; | ||
1382 | iManufacturer = new->iManufacturer; | ||
1383 | iProduct = new->iProduct; | ||
1384 | |||
1385 | *new = *old; | ||
1386 | if (idVendor) | ||
1387 | new->idVendor = idVendor; | ||
1388 | if (idProduct) | ||
1389 | new->idProduct = idProduct; | ||
1390 | if (bcdDevice) | ||
1391 | new->bcdDevice = bcdDevice; | ||
1392 | else | ||
1393 | new->bcdDevice = cpu_to_le16(get_default_bcdDevice()); | ||
1394 | if (iSerialNumber) | ||
1395 | new->iSerialNumber = iSerialNumber; | ||
1396 | if (iManufacturer) | ||
1397 | new->iManufacturer = iManufacturer; | ||
1398 | if (iProduct) | ||
1399 | new->iProduct = iProduct; | ||
1423 | } | 1400 | } |
1424 | 1401 | ||
1425 | static int composite_bind(struct usb_gadget *gadget) | 1402 | static struct usb_composite_driver *to_cdriver(struct usb_gadget_driver *gdrv) |
1403 | { | ||
1404 | return container_of(gdrv, struct usb_composite_driver, gadget_driver); | ||
1405 | } | ||
1406 | |||
1407 | static int composite_bind(struct usb_gadget *gadget, | ||
1408 | struct usb_gadget_driver *gdriver) | ||
1426 | { | 1409 | { |
1427 | struct usb_composite_dev *cdev; | 1410 | struct usb_composite_dev *cdev; |
1411 | struct usb_composite_driver *composite = to_cdriver(gdriver); | ||
1428 | int status = -ENOMEM; | 1412 | int status = -ENOMEM; |
1429 | 1413 | ||
1430 | cdev = kzalloc(sizeof *cdev, GFP_KERNEL); | 1414 | cdev = kzalloc(sizeof *cdev, GFP_KERNEL); |
@@ -1440,13 +1424,12 @@ static int composite_bind(struct usb_gadget *gadget) | |||
1440 | cdev->req = usb_ep_alloc_request(gadget->ep0, GFP_KERNEL); | 1424 | cdev->req = usb_ep_alloc_request(gadget->ep0, GFP_KERNEL); |
1441 | if (!cdev->req) | 1425 | if (!cdev->req) |
1442 | goto fail; | 1426 | goto fail; |
1443 | cdev->req->buf = kmalloc(USB_BUFSIZ, GFP_KERNEL); | 1427 | cdev->req->buf = kmalloc(USB_COMP_EP0_BUFSIZ, GFP_KERNEL); |
1444 | if (!cdev->req->buf) | 1428 | if (!cdev->req->buf) |
1445 | goto fail; | 1429 | goto fail; |
1446 | cdev->req->complete = composite_setup_complete; | 1430 | cdev->req->complete = composite_setup_complete; |
1447 | gadget->ep0->driver_data = cdev; | 1431 | gadget->ep0->driver_data = cdev; |
1448 | 1432 | ||
1449 | cdev->bufsiz = USB_BUFSIZ; | ||
1450 | cdev->driver = composite; | 1433 | cdev->driver = composite; |
1451 | 1434 | ||
1452 | /* | 1435 | /* |
@@ -1467,49 +1450,11 @@ static int composite_bind(struct usb_gadget *gadget) | |||
1467 | * serial number), register function drivers, potentially update | 1450 | * serial number), register function drivers, potentially update |
1468 | * power state and consumption, etc | 1451 | * power state and consumption, etc |
1469 | */ | 1452 | */ |
1470 | status = composite_gadget_bind(cdev); | 1453 | status = composite->bind(cdev); |
1471 | if (status < 0) | 1454 | if (status < 0) |
1472 | goto fail; | 1455 | goto fail; |
1473 | 1456 | ||
1474 | cdev->desc = *composite->dev; | 1457 | update_unchanged_dev_desc(&cdev->desc, composite->dev); |
1475 | |||
1476 | /* standardized runtime overrides for device ID data */ | ||
1477 | if (idVendor) | ||
1478 | cdev->desc.idVendor = cpu_to_le16(idVendor); | ||
1479 | else | ||
1480 | idVendor = le16_to_cpu(cdev->desc.idVendor); | ||
1481 | if (idProduct) | ||
1482 | cdev->desc.idProduct = cpu_to_le16(idProduct); | ||
1483 | else | ||
1484 | idProduct = le16_to_cpu(cdev->desc.idProduct); | ||
1485 | if (bcdDevice) | ||
1486 | cdev->desc.bcdDevice = cpu_to_le16(bcdDevice); | ||
1487 | else | ||
1488 | bcdDevice = le16_to_cpu(cdev->desc.bcdDevice); | ||
1489 | |||
1490 | /* string overrides */ | ||
1491 | if (iManufacturer || !cdev->desc.iManufacturer) { | ||
1492 | if (!iManufacturer && !composite->iManufacturer && | ||
1493 | !*composite_manufacturer) | ||
1494 | snprintf(composite_manufacturer, | ||
1495 | sizeof composite_manufacturer, | ||
1496 | "%s %s with %s", | ||
1497 | init_utsname()->sysname, | ||
1498 | init_utsname()->release, | ||
1499 | gadget->name); | ||
1500 | |||
1501 | cdev->manufacturer_override = | ||
1502 | override_id(cdev, &cdev->desc.iManufacturer); | ||
1503 | } | ||
1504 | |||
1505 | if (iProduct || (!cdev->desc.iProduct && composite->iProduct)) | ||
1506 | cdev->product_override = | ||
1507 | override_id(cdev, &cdev->desc.iProduct); | ||
1508 | |||
1509 | if (iSerialNumber || | ||
1510 | (!cdev->desc.iSerialNumber && composite->iSerialNumber)) | ||
1511 | cdev->serial_override = | ||
1512 | override_id(cdev, &cdev->desc.iSerialNumber); | ||
1513 | 1458 | ||
1514 | /* has userspace failed to provide a serial number? */ | 1459 | /* has userspace failed to provide a serial number? */ |
1515 | if (composite->needs_serial && !cdev->desc.iSerialNumber) | 1460 | if (composite->needs_serial && !cdev->desc.iSerialNumber) |
@@ -1546,8 +1491,8 @@ composite_suspend(struct usb_gadget *gadget) | |||
1546 | f->suspend(f); | 1491 | f->suspend(f); |
1547 | } | 1492 | } |
1548 | } | 1493 | } |
1549 | if (composite->suspend) | 1494 | if (cdev->driver->suspend) |
1550 | composite->suspend(cdev); | 1495 | cdev->driver->suspend(cdev); |
1551 | 1496 | ||
1552 | cdev->suspended = 1; | 1497 | cdev->suspended = 1; |
1553 | 1498 | ||
@@ -1565,8 +1510,8 @@ composite_resume(struct usb_gadget *gadget) | |||
1565 | * suspend/resume callbacks? | 1510 | * suspend/resume callbacks? |
1566 | */ | 1511 | */ |
1567 | DBG(cdev, "resume\n"); | 1512 | DBG(cdev, "resume\n"); |
1568 | if (composite->resume) | 1513 | if (cdev->driver->resume) |
1569 | composite->resume(cdev); | 1514 | cdev->driver->resume(cdev); |
1570 | if (cdev->config) { | 1515 | if (cdev->config) { |
1571 | list_for_each_entry(f, &cdev->config->functions, list) { | 1516 | list_for_each_entry(f, &cdev->config->functions, list) { |
1572 | if (f->resume) | 1517 | if (f->resume) |
@@ -1584,13 +1529,8 @@ composite_resume(struct usb_gadget *gadget) | |||
1584 | 1529 | ||
1585 | /*-------------------------------------------------------------------------*/ | 1530 | /*-------------------------------------------------------------------------*/ |
1586 | 1531 | ||
1587 | static struct usb_gadget_driver composite_driver = { | 1532 | static const struct usb_gadget_driver composite_driver_template = { |
1588 | #ifdef CONFIG_USB_GADGET_SUPERSPEED | 1533 | .bind = composite_bind, |
1589 | .max_speed = USB_SPEED_SUPER, | ||
1590 | #else | ||
1591 | .max_speed = USB_SPEED_HIGH, | ||
1592 | #endif | ||
1593 | |||
1594 | .unbind = composite_unbind, | 1534 | .unbind = composite_unbind, |
1595 | 1535 | ||
1596 | .setup = composite_setup, | 1536 | .setup = composite_setup, |
@@ -1623,25 +1563,26 @@ static struct usb_gadget_driver composite_driver = { | |||
1623 | * while it was binding. That would usually be done in order to wait for | 1563 | * while it was binding. That would usually be done in order to wait for |
1624 | * some userspace participation. | 1564 | * some userspace participation. |
1625 | */ | 1565 | */ |
1626 | int usb_composite_probe(struct usb_composite_driver *driver, | 1566 | int usb_composite_probe(struct usb_composite_driver *driver) |
1627 | int (*bind)(struct usb_composite_dev *cdev)) | ||
1628 | { | 1567 | { |
1629 | if (!driver || !driver->dev || !bind || composite) | 1568 | struct usb_gadget_driver *gadget_driver; |
1569 | |||
1570 | if (!driver || !driver->dev || !driver->bind) | ||
1630 | return -EINVAL; | 1571 | return -EINVAL; |
1631 | 1572 | ||
1632 | if (!driver->name) | 1573 | if (!driver->name) |
1633 | driver->name = "composite"; | 1574 | driver->name = "composite"; |
1634 | if (!driver->iProduct) | 1575 | |
1635 | driver->iProduct = driver->name; | 1576 | driver->gadget_driver = composite_driver_template; |
1636 | composite_driver.function = (char *) driver->name; | 1577 | gadget_driver = &driver->gadget_driver; |
1637 | composite_driver.driver.name = driver->name; | 1578 | |
1638 | composite_driver.max_speed = | 1579 | gadget_driver->function = (char *) driver->name; |
1639 | min_t(u8, composite_driver.max_speed, driver->max_speed); | 1580 | gadget_driver->driver.name = driver->name; |
1640 | composite = driver; | 1581 | gadget_driver->max_speed = driver->max_speed; |
1641 | composite_gadget_bind = bind; | 1582 | |
1642 | 1583 | return usb_gadget_probe_driver(gadget_driver); | |
1643 | return usb_gadget_probe_driver(&composite_driver, composite_bind); | ||
1644 | } | 1584 | } |
1585 | EXPORT_SYMBOL_GPL(usb_composite_probe); | ||
1645 | 1586 | ||
1646 | /** | 1587 | /** |
1647 | * usb_composite_unregister() - unregister a composite driver | 1588 | * usb_composite_unregister() - unregister a composite driver |
@@ -1652,10 +1593,9 @@ int usb_composite_probe(struct usb_composite_driver *driver, | |||
1652 | */ | 1593 | */ |
1653 | void usb_composite_unregister(struct usb_composite_driver *driver) | 1594 | void usb_composite_unregister(struct usb_composite_driver *driver) |
1654 | { | 1595 | { |
1655 | if (composite != driver) | 1596 | usb_gadget_unregister_driver(&driver->gadget_driver); |
1656 | return; | ||
1657 | usb_gadget_unregister_driver(&composite_driver); | ||
1658 | } | 1597 | } |
1598 | EXPORT_SYMBOL_GPL(usb_composite_unregister); | ||
1659 | 1599 | ||
1660 | /** | 1600 | /** |
1661 | * usb_composite_setup_continue() - Continue with the control transfer | 1601 | * usb_composite_setup_continue() - Continue with the control transfer |
@@ -1692,4 +1632,60 @@ void usb_composite_setup_continue(struct usb_composite_dev *cdev) | |||
1692 | 1632 | ||
1693 | spin_unlock_irqrestore(&cdev->lock, flags); | 1633 | spin_unlock_irqrestore(&cdev->lock, flags); |
1694 | } | 1634 | } |
1635 | EXPORT_SYMBOL_GPL(usb_composite_setup_continue); | ||
1636 | |||
1637 | static char *composite_default_mfr(struct usb_gadget *gadget) | ||
1638 | { | ||
1639 | char *mfr; | ||
1640 | int len; | ||
1641 | |||
1642 | len = snprintf(NULL, 0, "%s %s with %s", init_utsname()->sysname, | ||
1643 | init_utsname()->release, gadget->name); | ||
1644 | len++; | ||
1645 | mfr = kmalloc(len, GFP_KERNEL); | ||
1646 | if (!mfr) | ||
1647 | return NULL; | ||
1648 | snprintf(mfr, len, "%s %s with %s", init_utsname()->sysname, | ||
1649 | init_utsname()->release, gadget->name); | ||
1650 | return mfr; | ||
1651 | } | ||
1652 | |||
1653 | void usb_composite_overwrite_options(struct usb_composite_dev *cdev, | ||
1654 | struct usb_composite_overwrite *covr) | ||
1655 | { | ||
1656 | struct usb_device_descriptor *desc = &cdev->desc; | ||
1657 | struct usb_gadget_strings *gstr = cdev->driver->strings[0]; | ||
1658 | struct usb_string *dev_str = gstr->strings; | ||
1659 | |||
1660 | if (covr->idVendor) | ||
1661 | desc->idVendor = cpu_to_le16(covr->idVendor); | ||
1662 | |||
1663 | if (covr->idProduct) | ||
1664 | desc->idProduct = cpu_to_le16(covr->idProduct); | ||
1665 | |||
1666 | if (covr->bcdDevice) | ||
1667 | desc->bcdDevice = cpu_to_le16(covr->bcdDevice); | ||
1668 | |||
1669 | if (covr->serial_number) { | ||
1670 | desc->iSerialNumber = dev_str[USB_GADGET_SERIAL_IDX].id; | ||
1671 | dev_str[USB_GADGET_SERIAL_IDX].s = covr->serial_number; | ||
1672 | } | ||
1673 | if (covr->manufacturer) { | ||
1674 | desc->iManufacturer = dev_str[USB_GADGET_MANUFACTURER_IDX].id; | ||
1675 | dev_str[USB_GADGET_MANUFACTURER_IDX].s = covr->manufacturer; | ||
1676 | |||
1677 | } else if (!strlen(dev_str[USB_GADGET_MANUFACTURER_IDX].s)) { | ||
1678 | desc->iManufacturer = dev_str[USB_GADGET_MANUFACTURER_IDX].id; | ||
1679 | cdev->def_manufacturer = composite_default_mfr(cdev->gadget); | ||
1680 | dev_str[USB_GADGET_MANUFACTURER_IDX].s = cdev->def_manufacturer; | ||
1681 | } | ||
1682 | |||
1683 | if (covr->product) { | ||
1684 | desc->iProduct = dev_str[USB_GADGET_PRODUCT_IDX].id; | ||
1685 | dev_str[USB_GADGET_PRODUCT_IDX].s = covr->product; | ||
1686 | } | ||
1687 | } | ||
1688 | EXPORT_SYMBOL_GPL(usb_composite_overwrite_options); | ||
1695 | 1689 | ||
1690 | MODULE_LICENSE("GPL"); | ||
1691 | MODULE_AUTHOR("David Brownell"); | ||
diff --git a/drivers/usb/gadget/config.c b/drivers/usb/gadget/config.c index 7542a72ce51a..e3a98929d346 100644 --- a/drivers/usb/gadget/config.c +++ b/drivers/usb/gadget/config.c | |||
@@ -12,6 +12,7 @@ | |||
12 | #include <linux/errno.h> | 12 | #include <linux/errno.h> |
13 | #include <linux/slab.h> | 13 | #include <linux/slab.h> |
14 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
15 | #include <linux/module.h> | ||
15 | #include <linux/list.h> | 16 | #include <linux/list.h> |
16 | #include <linux/string.h> | 17 | #include <linux/string.h> |
17 | #include <linux/device.h> | 18 | #include <linux/device.h> |
@@ -53,7 +54,7 @@ usb_descriptor_fillbuf(void *buf, unsigned buflen, | |||
53 | } | 54 | } |
54 | return dest - (u8 *)buf; | 55 | return dest - (u8 *)buf; |
55 | } | 56 | } |
56 | 57 | EXPORT_SYMBOL_GPL(usb_descriptor_fillbuf); | |
57 | 58 | ||
58 | /** | 59 | /** |
59 | * usb_gadget_config_buf - builts a complete configuration descriptor | 60 | * usb_gadget_config_buf - builts a complete configuration descriptor |
@@ -106,6 +107,7 @@ int usb_gadget_config_buf( | |||
106 | cp->bmAttributes |= USB_CONFIG_ATT_ONE; | 107 | cp->bmAttributes |= USB_CONFIG_ATT_ONE; |
107 | return len; | 108 | return len; |
108 | } | 109 | } |
110 | EXPORT_SYMBOL_GPL(usb_gadget_config_buf); | ||
109 | 111 | ||
110 | /** | 112 | /** |
111 | * usb_copy_descriptors - copy a vector of USB descriptors | 113 | * usb_copy_descriptors - copy a vector of USB descriptors |
@@ -155,4 +157,4 @@ usb_copy_descriptors(struct usb_descriptor_header **src) | |||
155 | 157 | ||
156 | return ret; | 158 | return ret; |
157 | } | 159 | } |
158 | 160 | EXPORT_SYMBOL_GPL(usb_copy_descriptors); | |
diff --git a/drivers/usb/gadget/dbgp.c b/drivers/usb/gadget/dbgp.c index 19d7bb0df75a..87d165028162 100644 --- a/drivers/usb/gadget/dbgp.c +++ b/drivers/usb/gadget/dbgp.c | |||
@@ -13,9 +13,6 @@ | |||
13 | #include <linux/usb/ch9.h> | 13 | #include <linux/usb/ch9.h> |
14 | #include <linux/usb/gadget.h> | 14 | #include <linux/usb/gadget.h> |
15 | 15 | ||
16 | /* See comments in "zero.c" */ | ||
17 | #include "epautoconf.c" | ||
18 | |||
19 | #ifdef CONFIG_USB_G_DBGP_SERIAL | 16 | #ifdef CONFIG_USB_G_DBGP_SERIAL |
20 | #include "u_serial.c" | 17 | #include "u_serial.c" |
21 | #endif | 18 | #endif |
@@ -292,7 +289,8 @@ fail_1: | |||
292 | return -ENODEV; | 289 | return -ENODEV; |
293 | } | 290 | } |
294 | 291 | ||
295 | static int __init dbgp_bind(struct usb_gadget *gadget) | 292 | static int __init dbgp_bind(struct usb_gadget *gadget, |
293 | struct usb_gadget_driver *driver) | ||
296 | { | 294 | { |
297 | int err, stp; | 295 | int err, stp; |
298 | 296 | ||
@@ -402,9 +400,10 @@ fail: | |||
402 | return err; | 400 | return err; |
403 | } | 401 | } |
404 | 402 | ||
405 | static struct usb_gadget_driver dbgp_driver = { | 403 | static __refdata struct usb_gadget_driver dbgp_driver = { |
406 | .function = "dbgp", | 404 | .function = "dbgp", |
407 | .max_speed = USB_SPEED_HIGH, | 405 | .max_speed = USB_SPEED_HIGH, |
406 | .bind = dbgp_bind, | ||
408 | .unbind = dbgp_unbind, | 407 | .unbind = dbgp_unbind, |
409 | .setup = dbgp_setup, | 408 | .setup = dbgp_setup, |
410 | .disconnect = dbgp_disconnect, | 409 | .disconnect = dbgp_disconnect, |
@@ -416,7 +415,7 @@ static struct usb_gadget_driver dbgp_driver = { | |||
416 | 415 | ||
417 | static int __init dbgp_init(void) | 416 | static int __init dbgp_init(void) |
418 | { | 417 | { |
419 | return usb_gadget_probe_driver(&dbgp_driver, dbgp_bind); | 418 | return usb_gadget_probe_driver(&dbgp_driver); |
420 | } | 419 | } |
421 | 420 | ||
422 | static void __exit dbgp_exit(void) | 421 | static void __exit dbgp_exit(void) |
diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c index afdbb1cbf5d9..0f7541be28f3 100644 --- a/drivers/usb/gadget/dummy_hcd.c +++ b/drivers/usb/gadget/dummy_hcd.c | |||
@@ -909,6 +909,7 @@ static int dummy_udc_start(struct usb_gadget *g, | |||
909 | dum->devstatus = 0; | 909 | dum->devstatus = 0; |
910 | 910 | ||
911 | dum->driver = driver; | 911 | dum->driver = driver; |
912 | dum->gadget.dev.driver = &driver->driver; | ||
912 | dev_dbg(udc_dev(dum), "binding gadget driver '%s'\n", | 913 | dev_dbg(udc_dev(dum), "binding gadget driver '%s'\n", |
913 | driver->driver.name); | 914 | driver->driver.name); |
914 | return 0; | 915 | return 0; |
@@ -923,6 +924,7 @@ static int dummy_udc_stop(struct usb_gadget *g, | |||
923 | dev_dbg(udc_dev(dum), "unregister gadget driver '%s'\n", | 924 | dev_dbg(udc_dev(dum), "unregister gadget driver '%s'\n", |
924 | driver->driver.name); | 925 | driver->driver.name); |
925 | 926 | ||
927 | dum->gadget.dev.driver = NULL; | ||
926 | dum->driver = NULL; | 928 | dum->driver = NULL; |
927 | 929 | ||
928 | return 0; | 930 | return 0; |
diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c index 51f3d42f5a64..a777f7bd11b4 100644 --- a/drivers/usb/gadget/epautoconf.c +++ b/drivers/usb/gadget/epautoconf.c | |||
@@ -10,6 +10,7 @@ | |||
10 | */ | 10 | */ |
11 | 11 | ||
12 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
13 | #include <linux/module.h> | ||
13 | #include <linux/init.h> | 14 | #include <linux/init.h> |
14 | #include <linux/types.h> | 15 | #include <linux/types.h> |
15 | #include <linux/device.h> | 16 | #include <linux/device.h> |
@@ -22,17 +23,6 @@ | |||
22 | 23 | ||
23 | #include "gadget_chips.h" | 24 | #include "gadget_chips.h" |
24 | 25 | ||
25 | |||
26 | /* we must assign addresses for configurable endpoints (like net2280) */ | ||
27 | static unsigned epnum; | ||
28 | |||
29 | // #define MANY_ENDPOINTS | ||
30 | #ifdef MANY_ENDPOINTS | ||
31 | /* more than 15 configurable endpoints */ | ||
32 | static unsigned in_epnum; | ||
33 | #endif | ||
34 | |||
35 | |||
36 | /* | 26 | /* |
37 | * This should work with endpoints from controller drivers sharing the | 27 | * This should work with endpoints from controller drivers sharing the |
38 | * same endpoint naming convention. By example: | 28 | * same endpoint naming convention. By example: |
@@ -176,16 +166,14 @@ ep_matches ( | |||
176 | if (isdigit (ep->name [2])) { | 166 | if (isdigit (ep->name [2])) { |
177 | u8 num = simple_strtoul (&ep->name [2], NULL, 10); | 167 | u8 num = simple_strtoul (&ep->name [2], NULL, 10); |
178 | desc->bEndpointAddress |= num; | 168 | desc->bEndpointAddress |= num; |
179 | #ifdef MANY_ENDPOINTS | ||
180 | } else if (desc->bEndpointAddress & USB_DIR_IN) { | 169 | } else if (desc->bEndpointAddress & USB_DIR_IN) { |
181 | if (++in_epnum > 15) | 170 | if (++gadget->in_epnum > 15) |
182 | return 0; | 171 | return 0; |
183 | desc->bEndpointAddress = USB_DIR_IN | in_epnum; | 172 | desc->bEndpointAddress = USB_DIR_IN | gadget->in_epnum; |
184 | #endif | ||
185 | } else { | 173 | } else { |
186 | if (++epnum > 15) | 174 | if (++gadget->out_epnum > 15) |
187 | return 0; | 175 | return 0; |
188 | desc->bEndpointAddress |= epnum; | 176 | desc->bEndpointAddress |= gadget->out_epnum; |
189 | } | 177 | } |
190 | 178 | ||
191 | /* report (variable) full speed bulk maxpacket */ | 179 | /* report (variable) full speed bulk maxpacket */ |
@@ -328,6 +316,7 @@ found_ep: | |||
328 | ep->comp_desc = NULL; | 316 | ep->comp_desc = NULL; |
329 | return ep; | 317 | return ep; |
330 | } | 318 | } |
319 | EXPORT_SYMBOL_GPL(usb_ep_autoconfig_ss); | ||
331 | 320 | ||
332 | /** | 321 | /** |
333 | * usb_ep_autoconfig() - choose an endpoint matching the | 322 | * usb_ep_autoconfig() - choose an endpoint matching the |
@@ -367,7 +356,7 @@ struct usb_ep *usb_ep_autoconfig( | |||
367 | { | 356 | { |
368 | return usb_ep_autoconfig_ss(gadget, desc, NULL); | 357 | return usb_ep_autoconfig_ss(gadget, desc, NULL); |
369 | } | 358 | } |
370 | 359 | EXPORT_SYMBOL_GPL(usb_ep_autoconfig); | |
371 | 360 | ||
372 | /** | 361 | /** |
373 | * usb_ep_autoconfig_reset - reset endpoint autoconfig state | 362 | * usb_ep_autoconfig_reset - reset endpoint autoconfig state |
@@ -385,9 +374,7 @@ void usb_ep_autoconfig_reset (struct usb_gadget *gadget) | |||
385 | list_for_each_entry (ep, &gadget->ep_list, ep_list) { | 374 | list_for_each_entry (ep, &gadget->ep_list, ep_list) { |
386 | ep->driver_data = NULL; | 375 | ep->driver_data = NULL; |
387 | } | 376 | } |
388 | #ifdef MANY_ENDPOINTS | 377 | gadget->in_epnum = 0; |
389 | in_epnum = 0; | 378 | gadget->out_epnum = 0; |
390 | #endif | ||
391 | epnum = 0; | ||
392 | } | 379 | } |
393 | 380 | EXPORT_SYMBOL_GPL(usb_ep_autoconfig_reset); | |
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c index a28f6ffcd0f3..18c3f423706e 100644 --- a/drivers/usb/gadget/ether.c +++ b/drivers/usb/gadget/ether.c | |||
@@ -14,8 +14,6 @@ | |||
14 | /* #define VERBOSE_DEBUG */ | 14 | /* #define VERBOSE_DEBUG */ |
15 | 15 | ||
16 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
17 | #include <linux/utsname.h> | ||
18 | |||
19 | 17 | ||
20 | #if defined USB_ETH_RNDIS | 18 | #if defined USB_ETH_RNDIS |
21 | # undef USB_ETH_RNDIS | 19 | # undef USB_ETH_RNDIS |
@@ -102,11 +100,6 @@ static inline bool has_rndis(void) | |||
102 | * the runtime footprint, and giving us at least some parts of what | 100 | * the runtime footprint, and giving us at least some parts of what |
103 | * a "gcc --combine ... part1.c part2.c part3.c ... " build would. | 101 | * a "gcc --combine ... part1.c part2.c part3.c ... " build would. |
104 | */ | 102 | */ |
105 | #include "composite.c" | ||
106 | #include "usbstring.c" | ||
107 | #include "config.c" | ||
108 | #include "epautoconf.c" | ||
109 | |||
110 | #include "f_ecm.c" | 103 | #include "f_ecm.c" |
111 | #include "f_subset.c" | 104 | #include "f_subset.c" |
112 | #ifdef USB_ETH_RNDIS | 105 | #ifdef USB_ETH_RNDIS |
@@ -117,6 +110,7 @@ static inline bool has_rndis(void) | |||
117 | #include "u_ether.c" | 110 | #include "u_ether.c" |
118 | 111 | ||
119 | /*-------------------------------------------------------------------------*/ | 112 | /*-------------------------------------------------------------------------*/ |
113 | USB_GADGET_COMPOSITE_OPTIONS(); | ||
120 | 114 | ||
121 | /* DO NOT REUSE THESE IDs with a protocol-incompatible driver!! Ever!! | 115 | /* DO NOT REUSE THESE IDs with a protocol-incompatible driver!! Ever!! |
122 | * Instead: allocate your own, using normal USB-IF procedures. | 116 | * Instead: allocate your own, using normal USB-IF procedures. |
@@ -195,17 +189,10 @@ static const struct usb_descriptor_header *otg_desc[] = { | |||
195 | NULL, | 189 | NULL, |
196 | }; | 190 | }; |
197 | 191 | ||
198 | |||
199 | /* string IDs are assigned dynamically */ | ||
200 | |||
201 | #define STRING_MANUFACTURER_IDX 0 | ||
202 | #define STRING_PRODUCT_IDX 1 | ||
203 | |||
204 | static char manufacturer[50]; | ||
205 | |||
206 | static struct usb_string strings_dev[] = { | 192 | static struct usb_string strings_dev[] = { |
207 | [STRING_MANUFACTURER_IDX].s = manufacturer, | 193 | [USB_GADGET_MANUFACTURER_IDX].s = "", |
208 | [STRING_PRODUCT_IDX].s = PREFIX DRIVER_DESC, | 194 | [USB_GADGET_PRODUCT_IDX].s = PREFIX DRIVER_DESC, |
195 | [USB_GADGET_SERIAL_IDX].s = "", | ||
209 | { } /* end of list */ | 196 | { } /* end of list */ |
210 | }; | 197 | }; |
211 | 198 | ||
@@ -288,7 +275,6 @@ static struct usb_configuration eth_config_driver = { | |||
288 | 275 | ||
289 | static int __init eth_bind(struct usb_composite_dev *cdev) | 276 | static int __init eth_bind(struct usb_composite_dev *cdev) |
290 | { | 277 | { |
291 | int gcnum; | ||
292 | struct usb_gadget *gadget = cdev->gadget; | 278 | struct usb_gadget *gadget = cdev->gadget; |
293 | int status; | 279 | int status; |
294 | 280 | ||
@@ -323,42 +309,15 @@ static int __init eth_bind(struct usb_composite_dev *cdev) | |||
323 | device_desc.bNumConfigurations = 2; | 309 | device_desc.bNumConfigurations = 2; |
324 | } | 310 | } |
325 | 311 | ||
326 | gcnum = usb_gadget_controller_number(gadget); | ||
327 | if (gcnum >= 0) | ||
328 | device_desc.bcdDevice = cpu_to_le16(0x0300 | gcnum); | ||
329 | else { | ||
330 | /* We assume that can_support_ecm() tells the truth; | ||
331 | * but if the controller isn't recognized at all then | ||
332 | * that assumption is a bit more likely to be wrong. | ||
333 | */ | ||
334 | dev_warn(&gadget->dev, | ||
335 | "controller '%s' not recognized; trying %s\n", | ||
336 | gadget->name, | ||
337 | eth_config_driver.label); | ||
338 | device_desc.bcdDevice = | ||
339 | cpu_to_le16(0x0300 | 0x0099); | ||
340 | } | ||
341 | |||
342 | |||
343 | /* Allocate string descriptor numbers ... note that string | 312 | /* Allocate string descriptor numbers ... note that string |
344 | * contents can be overridden by the composite_dev glue. | 313 | * contents can be overridden by the composite_dev glue. |
345 | */ | 314 | */ |
346 | 315 | ||
347 | /* device descriptor strings: manufacturer, product */ | 316 | status = usb_string_ids_tab(cdev, strings_dev); |
348 | snprintf(manufacturer, sizeof manufacturer, "%s %s with %s", | ||
349 | init_utsname()->sysname, init_utsname()->release, | ||
350 | gadget->name); | ||
351 | status = usb_string_id(cdev); | ||
352 | if (status < 0) | ||
353 | goto fail; | ||
354 | strings_dev[STRING_MANUFACTURER_IDX].id = status; | ||
355 | device_desc.iManufacturer = status; | ||
356 | |||
357 | status = usb_string_id(cdev); | ||
358 | if (status < 0) | 317 | if (status < 0) |
359 | goto fail; | 318 | goto fail; |
360 | strings_dev[STRING_PRODUCT_IDX].id = status; | 319 | device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id; |
361 | device_desc.iProduct = status; | 320 | device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; |
362 | 321 | ||
363 | /* register our configuration(s); RNDIS first, if it's used */ | 322 | /* register our configuration(s); RNDIS first, if it's used */ |
364 | if (has_rndis()) { | 323 | if (has_rndis()) { |
@@ -372,6 +331,7 @@ static int __init eth_bind(struct usb_composite_dev *cdev) | |||
372 | if (status < 0) | 331 | if (status < 0) |
373 | goto fail; | 332 | goto fail; |
374 | 333 | ||
334 | usb_composite_overwrite_options(cdev, &coverwrite); | ||
375 | dev_info(&gadget->dev, "%s, version: " DRIVER_VERSION "\n", | 335 | dev_info(&gadget->dev, "%s, version: " DRIVER_VERSION "\n", |
376 | DRIVER_DESC); | 336 | DRIVER_DESC); |
377 | 337 | ||
@@ -388,11 +348,12 @@ static int __exit eth_unbind(struct usb_composite_dev *cdev) | |||
388 | return 0; | 348 | return 0; |
389 | } | 349 | } |
390 | 350 | ||
391 | static struct usb_composite_driver eth_driver = { | 351 | static __refdata struct usb_composite_driver eth_driver = { |
392 | .name = "g_ether", | 352 | .name = "g_ether", |
393 | .dev = &device_desc, | 353 | .dev = &device_desc, |
394 | .strings = dev_strings, | 354 | .strings = dev_strings, |
395 | .max_speed = USB_SPEED_SUPER, | 355 | .max_speed = USB_SPEED_SUPER, |
356 | .bind = eth_bind, | ||
396 | .unbind = __exit_p(eth_unbind), | 357 | .unbind = __exit_p(eth_unbind), |
397 | }; | 358 | }; |
398 | 359 | ||
@@ -402,7 +363,7 @@ MODULE_LICENSE("GPL"); | |||
402 | 363 | ||
403 | static int __init init(void) | 364 | static int __init init(void) |
404 | { | 365 | { |
405 | return usb_composite_probe(ð_driver, eth_bind); | 366 | return usb_composite_probe(ð_driver); |
406 | } | 367 | } |
407 | module_init(init); | 368 | module_init(init); |
408 | 369 | ||
diff --git a/drivers/usb/gadget/f_ecm.c b/drivers/usb/gadget/f_ecm.c index 30b908f2a53d..95bc94f8e570 100644 --- a/drivers/usb/gadget/f_ecm.c +++ b/drivers/usb/gadget/f_ecm.c | |||
@@ -897,10 +897,7 @@ ecm_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN]) | |||
897 | return -ENOMEM; | 897 | return -ENOMEM; |
898 | 898 | ||
899 | /* export host's Ethernet address in CDC format */ | 899 | /* export host's Ethernet address in CDC format */ |
900 | snprintf(ecm->ethaddr, sizeof ecm->ethaddr, | 900 | snprintf(ecm->ethaddr, sizeof ecm->ethaddr, "%pm", ethaddr); |
901 | "%02X%02X%02X%02X%02X%02X", | ||
902 | ethaddr[0], ethaddr[1], ethaddr[2], | ||
903 | ethaddr[3], ethaddr[4], ethaddr[5]); | ||
904 | ecm_string_defs[1].s = ecm->ethaddr; | 901 | ecm_string_defs[1].s = ecm->ethaddr; |
905 | 902 | ||
906 | ecm->port.cdc_filter = DEFAULT_FILTER; | 903 | ecm->port.cdc_filter = DEFAULT_FILTER; |
diff --git a/drivers/usb/gadget/f_hid.c b/drivers/usb/gadget/f_hid.c index 16a8b1c15c62..511e527178e2 100644 --- a/drivers/usb/gadget/f_hid.c +++ b/drivers/usb/gadget/f_hid.c | |||
@@ -10,7 +10,6 @@ | |||
10 | */ | 10 | */ |
11 | 11 | ||
12 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
13 | #include <linux/utsname.h> | ||
14 | #include <linux/module.h> | 13 | #include <linux/module.h> |
15 | #include <linux/hid.h> | 14 | #include <linux/hid.h> |
16 | #include <linux/cdev.h> | 15 | #include <linux/cdev.h> |
@@ -18,6 +17,7 @@ | |||
18 | #include <linux/poll.h> | 17 | #include <linux/poll.h> |
19 | #include <linux/uaccess.h> | 18 | #include <linux/uaccess.h> |
20 | #include <linux/wait.h> | 19 | #include <linux/wait.h> |
20 | #include <linux/sched.h> | ||
21 | #include <linux/usb/g_hid.h> | 21 | #include <linux/usb/g_hid.h> |
22 | 22 | ||
23 | static int major, minors; | 23 | static int major, minors; |
diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index 4f1142efa6d1..3a7668bde3ef 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c | |||
@@ -213,7 +213,6 @@ | |||
213 | #include <linux/spinlock.h> | 213 | #include <linux/spinlock.h> |
214 | #include <linux/string.h> | 214 | #include <linux/string.h> |
215 | #include <linux/freezer.h> | 215 | #include <linux/freezer.h> |
216 | #include <linux/utsname.h> | ||
217 | 216 | ||
218 | #include <linux/usb/ch9.h> | 217 | #include <linux/usb/ch9.h> |
219 | #include <linux/usb/gadget.h> | 218 | #include <linux/usb/gadget.h> |
@@ -349,7 +348,6 @@ struct fsg_config { | |||
349 | 348 | ||
350 | const char *vendor_name; /* 8 characters or less */ | 349 | const char *vendor_name; /* 8 characters or less */ |
351 | const char *product_name; /* 16 characters or less */ | 350 | const char *product_name; /* 16 characters or less */ |
352 | u16 release; | ||
353 | 351 | ||
354 | char can_stall; | 352 | char can_stall; |
355 | }; | 353 | }; |
@@ -2773,18 +2771,7 @@ buffhds_first_it: | |||
2773 | bh->next = common->buffhds; | 2771 | bh->next = common->buffhds; |
2774 | 2772 | ||
2775 | /* Prepare inquiryString */ | 2773 | /* Prepare inquiryString */ |
2776 | if (cfg->release != 0xffff) { | 2774 | i = get_default_bcdDevice(); |
2777 | i = cfg->release; | ||
2778 | } else { | ||
2779 | i = usb_gadget_controller_number(gadget); | ||
2780 | if (i >= 0) { | ||
2781 | i = 0x0300 + i; | ||
2782 | } else { | ||
2783 | WARNING(common, "controller '%s' not recognized\n", | ||
2784 | gadget->name); | ||
2785 | i = 0x0399; | ||
2786 | } | ||
2787 | } | ||
2788 | snprintf(common->inquiry_string, sizeof common->inquiry_string, | 2775 | snprintf(common->inquiry_string, sizeof common->inquiry_string, |
2789 | "%-8s%-16s%04x", cfg->vendor_name ?: "Linux", | 2776 | "%-8s%-16s%04x", cfg->vendor_name ?: "Linux", |
2790 | /* Assume product name dependent on the first LUN */ | 2777 | /* Assume product name dependent on the first LUN */ |
@@ -3110,7 +3097,6 @@ fsg_config_from_params(struct fsg_config *cfg, | |||
3110 | /* Let MSF use defaults */ | 3097 | /* Let MSF use defaults */ |
3111 | cfg->vendor_name = 0; | 3098 | cfg->vendor_name = 0; |
3112 | cfg->product_name = 0; | 3099 | cfg->product_name = 0; |
3113 | cfg->release = 0xffff; | ||
3114 | 3100 | ||
3115 | cfg->ops = NULL; | 3101 | cfg->ops = NULL; |
3116 | cfg->private_data = NULL; | 3102 | cfg->private_data = NULL; |
diff --git a/drivers/usb/gadget/f_midi.c b/drivers/usb/gadget/f_midi.c index 2f7e8f2930cc..8ed1259fe80d 100644 --- a/drivers/usb/gadget/f_midi.c +++ b/drivers/usb/gadget/f_midi.c | |||
@@ -21,7 +21,6 @@ | |||
21 | 21 | ||
22 | #include <linux/kernel.h> | 22 | #include <linux/kernel.h> |
23 | #include <linux/slab.h> | 23 | #include <linux/slab.h> |
24 | #include <linux/utsname.h> | ||
25 | #include <linux/device.h> | 24 | #include <linux/device.h> |
26 | 25 | ||
27 | #include <sound/core.h> | 26 | #include <sound/core.h> |
diff --git a/drivers/usb/gadget/f_ncm.c b/drivers/usb/gadget/f_ncm.c index aab8eded045b..b651b529c67f 100644 --- a/drivers/usb/gadget/f_ncm.c +++ b/drivers/usb/gadget/f_ncm.c | |||
@@ -1346,10 +1346,7 @@ int __init ncm_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN]) | |||
1346 | return -ENOMEM; | 1346 | return -ENOMEM; |
1347 | 1347 | ||
1348 | /* export host's Ethernet address in CDC format */ | 1348 | /* export host's Ethernet address in CDC format */ |
1349 | snprintf(ncm->ethaddr, sizeof ncm->ethaddr, | 1349 | snprintf(ncm->ethaddr, sizeof ncm->ethaddr, "%pm", ethaddr); |
1350 | "%02X%02X%02X%02X%02X%02X", | ||
1351 | ethaddr[0], ethaddr[1], ethaddr[2], | ||
1352 | ethaddr[3], ethaddr[4], ethaddr[5]); | ||
1353 | ncm_string_defs[1].s = ncm->ethaddr; | 1350 | ncm_string_defs[1].s = ncm->ethaddr; |
1354 | 1351 | ||
1355 | spin_lock_init(&ncm->lock); | 1352 | spin_lock_init(&ncm->lock); |
diff --git a/drivers/usb/gadget/f_sourcesink.c b/drivers/usb/gadget/f_sourcesink.c index 5c1b68b63c98..3c126fde6e7e 100644 --- a/drivers/usb/gadget/f_sourcesink.c +++ b/drivers/usb/gadget/f_sourcesink.c | |||
@@ -795,7 +795,7 @@ static int sourcesink_setup(struct usb_configuration *c, | |||
795 | u16 w_value = le16_to_cpu(ctrl->wValue); | 795 | u16 w_value = le16_to_cpu(ctrl->wValue); |
796 | u16 w_length = le16_to_cpu(ctrl->wLength); | 796 | u16 w_length = le16_to_cpu(ctrl->wLength); |
797 | 797 | ||
798 | req->length = USB_BUFSIZ; | 798 | req->length = USB_COMP_EP0_BUFSIZ; |
799 | 799 | ||
800 | /* composite driver infrastructure handles everything except | 800 | /* composite driver infrastructure handles everything except |
801 | * the two control test requests. | 801 | * the two control test requests. |
diff --git a/drivers/usb/gadget/f_subset.c b/drivers/usb/gadget/f_subset.c index 21ab474aca07..4060c0bd9785 100644 --- a/drivers/usb/gadget/f_subset.c +++ b/drivers/usb/gadget/f_subset.c | |||
@@ -436,10 +436,7 @@ int geth_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN]) | |||
436 | return -ENOMEM; | 436 | return -ENOMEM; |
437 | 437 | ||
438 | /* export host's Ethernet address in CDC format */ | 438 | /* export host's Ethernet address in CDC format */ |
439 | snprintf(geth->ethaddr, sizeof geth->ethaddr, | 439 | snprintf(geth->ethaddr, sizeof geth->ethaddr, "%pm", ethaddr); |
440 | "%02X%02X%02X%02X%02X%02X", | ||
441 | ethaddr[0], ethaddr[1], ethaddr[2], | ||
442 | ethaddr[3], ethaddr[4], ethaddr[5]); | ||
443 | geth_string_defs[1].s = geth->ethaddr; | 440 | geth_string_defs[1].s = geth->ethaddr; |
444 | 441 | ||
445 | geth->port.cdc_filter = DEFAULT_FILTER; | 442 | geth->port.cdc_filter = DEFAULT_FILTER; |
diff --git a/drivers/usb/gadget/f_uac2.c b/drivers/usb/gadget/f_uac2.c index e7cc4de93e33..d3c6cffccb72 100644 --- a/drivers/usb/gadget/f_uac2.c +++ b/drivers/usb/gadget/f_uac2.c | |||
@@ -463,7 +463,7 @@ snd_fail: | |||
463 | return err; | 463 | return err; |
464 | } | 464 | } |
465 | 465 | ||
466 | static int __devexit snd_uac2_remove(struct platform_device *pdev) | 466 | static int snd_uac2_remove(struct platform_device *pdev) |
467 | { | 467 | { |
468 | struct snd_card *card = platform_get_drvdata(pdev); | 468 | struct snd_card *card = platform_get_drvdata(pdev); |
469 | 469 | ||
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c index a896d73f7a93..3f7d640b6758 100644 --- a/drivers/usb/gadget/file_storage.c +++ b/drivers/usb/gadget/file_storage.c | |||
@@ -251,26 +251,12 @@ | |||
251 | #include <linux/freezer.h> | 251 | #include <linux/freezer.h> |
252 | #include <linux/utsname.h> | 252 | #include <linux/utsname.h> |
253 | 253 | ||
254 | #include <linux/usb/composite.h> | ||
254 | #include <linux/usb/ch9.h> | 255 | #include <linux/usb/ch9.h> |
255 | #include <linux/usb/gadget.h> | 256 | #include <linux/usb/gadget.h> |
256 | 257 | ||
257 | #include "gadget_chips.h" | 258 | #include "gadget_chips.h" |
258 | 259 | ||
259 | |||
260 | |||
261 | /* | ||
262 | * Kbuild is not very cooperative with respect to linking separately | ||
263 | * compiled library objects into one module. So for now we won't use | ||
264 | * separate compilation ... ensuring init/exit sections work to shrink | ||
265 | * the runtime footprint, and giving us at least some parts of what | ||
266 | * a "gcc --combine ... part1.c part2.c part3.c ... " build would. | ||
267 | */ | ||
268 | #include "usbstring.c" | ||
269 | #include "config.c" | ||
270 | #include "epautoconf.c" | ||
271 | |||
272 | /*-------------------------------------------------------------------------*/ | ||
273 | |||
274 | #define DRIVER_DESC "File-backed Storage Gadget" | 260 | #define DRIVER_DESC "File-backed Storage Gadget" |
275 | #define DRIVER_NAME "g_file_storage" | 261 | #define DRIVER_NAME "g_file_storage" |
276 | #define DRIVER_VERSION "1 September 2010" | 262 | #define DRIVER_VERSION "1 September 2010" |
@@ -3213,7 +3199,6 @@ static void /* __init_or_exit */ fsg_unbind(struct usb_gadget *gadget) | |||
3213 | static int __init check_parameters(struct fsg_dev *fsg) | 3199 | static int __init check_parameters(struct fsg_dev *fsg) |
3214 | { | 3200 | { |
3215 | int prot; | 3201 | int prot; |
3216 | int gcnum; | ||
3217 | 3202 | ||
3218 | /* Store the default values */ | 3203 | /* Store the default values */ |
3219 | mod_data.transport_type = USB_PR_BULK; | 3204 | mod_data.transport_type = USB_PR_BULK; |
@@ -3228,16 +3213,8 @@ static int __init check_parameters(struct fsg_dev *fsg) | |||
3228 | if (gadget_is_at91(fsg->gadget)) | 3213 | if (gadget_is_at91(fsg->gadget)) |
3229 | mod_data.can_stall = 0; | 3214 | mod_data.can_stall = 0; |
3230 | 3215 | ||
3231 | if (mod_data.release == 0xffff) { // Parameter wasn't set | 3216 | if (mod_data.release == 0xffff) |
3232 | gcnum = usb_gadget_controller_number(fsg->gadget); | 3217 | mod_data.release = get_default_bcdDevice(); |
3233 | if (gcnum >= 0) | ||
3234 | mod_data.release = 0x0300 + gcnum; | ||
3235 | else { | ||
3236 | WARNING(fsg, "controller '%s' not recognized\n", | ||
3237 | fsg->gadget->name); | ||
3238 | mod_data.release = 0x0399; | ||
3239 | } | ||
3240 | } | ||
3241 | 3218 | ||
3242 | prot = simple_strtol(mod_data.protocol_parm, NULL, 0); | 3219 | prot = simple_strtol(mod_data.protocol_parm, NULL, 0); |
3243 | 3220 | ||
@@ -3331,7 +3308,8 @@ static int __init check_parameters(struct fsg_dev *fsg) | |||
3331 | } | 3308 | } |
3332 | 3309 | ||
3333 | 3310 | ||
3334 | static int __init fsg_bind(struct usb_gadget *gadget) | 3311 | static int __init fsg_bind(struct usb_gadget *gadget, |
3312 | struct usb_gadget_driver *driver) | ||
3335 | { | 3313 | { |
3336 | struct fsg_dev *fsg = the_fsg; | 3314 | struct fsg_dev *fsg = the_fsg; |
3337 | int rc; | 3315 | int rc; |
@@ -3603,9 +3581,10 @@ static void fsg_resume(struct usb_gadget *gadget) | |||
3603 | 3581 | ||
3604 | /*-------------------------------------------------------------------------*/ | 3582 | /*-------------------------------------------------------------------------*/ |
3605 | 3583 | ||
3606 | static struct usb_gadget_driver fsg_driver = { | 3584 | static __refdata struct usb_gadget_driver fsg_driver = { |
3607 | .max_speed = USB_SPEED_SUPER, | 3585 | .max_speed = USB_SPEED_SUPER, |
3608 | .function = (char *) fsg_string_product, | 3586 | .function = (char *) fsg_string_product, |
3587 | .bind = fsg_bind, | ||
3609 | .unbind = fsg_unbind, | 3588 | .unbind = fsg_unbind, |
3610 | .disconnect = fsg_disconnect, | 3589 | .disconnect = fsg_disconnect, |
3611 | .setup = fsg_setup, | 3590 | .setup = fsg_setup, |
@@ -3653,7 +3632,8 @@ static int __init fsg_init(void) | |||
3653 | if ((rc = fsg_alloc()) != 0) | 3632 | if ((rc = fsg_alloc()) != 0) |
3654 | return rc; | 3633 | return rc; |
3655 | fsg = the_fsg; | 3634 | fsg = the_fsg; |
3656 | if ((rc = usb_gadget_probe_driver(&fsg_driver, fsg_bind)) != 0) | 3635 | rc = usb_gadget_probe_driver(&fsg_driver); |
3636 | if (rc != 0) | ||
3657 | kref_put(&fsg->ref, fsg_release); | 3637 | kref_put(&fsg->ref, fsg_release); |
3658 | return rc; | 3638 | return rc; |
3659 | } | 3639 | } |
diff --git a/drivers/usb/gadget/fsl_udc_core.c b/drivers/usb/gadget/fsl_udc_core.c index 3def828f85e7..6ae70cba0c4a 100644 --- a/drivers/usb/gadget/fsl_udc_core.c +++ b/drivers/usb/gadget/fsl_udc_core.c | |||
@@ -1255,7 +1255,7 @@ static int fsl_pullup(struct usb_gadget *gadget, int is_on) | |||
1255 | } | 1255 | } |
1256 | 1256 | ||
1257 | static int fsl_start(struct usb_gadget_driver *driver, | 1257 | static int fsl_start(struct usb_gadget_driver *driver, |
1258 | int (*bind)(struct usb_gadget *)); | 1258 | int (*bind)(struct usb_gadget *, struct usb_gadget_driver *)); |
1259 | static int fsl_stop(struct usb_gadget_driver *driver); | 1259 | static int fsl_stop(struct usb_gadget_driver *driver); |
1260 | /* defined in gadget.h */ | 1260 | /* defined in gadget.h */ |
1261 | static struct usb_gadget_ops fsl_gadget_ops = { | 1261 | static struct usb_gadget_ops fsl_gadget_ops = { |
@@ -1951,7 +1951,7 @@ static irqreturn_t fsl_udc_irq(int irq, void *_udc) | |||
1951 | * Called by initialization code of gadget drivers | 1951 | * Called by initialization code of gadget drivers |
1952 | *----------------------------------------------------------------*/ | 1952 | *----------------------------------------------------------------*/ |
1953 | static int fsl_start(struct usb_gadget_driver *driver, | 1953 | static int fsl_start(struct usb_gadget_driver *driver, |
1954 | int (*bind)(struct usb_gadget *)) | 1954 | int (*bind)(struct usb_gadget *, struct usb_gadget_driver *)) |
1955 | { | 1955 | { |
1956 | int retval = -ENODEV; | 1956 | int retval = -ENODEV; |
1957 | unsigned long flags = 0; | 1957 | unsigned long flags = 0; |
@@ -1976,7 +1976,7 @@ static int fsl_start(struct usb_gadget_driver *driver, | |||
1976 | spin_unlock_irqrestore(&udc_controller->lock, flags); | 1976 | spin_unlock_irqrestore(&udc_controller->lock, flags); |
1977 | 1977 | ||
1978 | /* bind udc driver to gadget driver */ | 1978 | /* bind udc driver to gadget driver */ |
1979 | retval = bind(&udc_controller->gadget); | 1979 | retval = bind(&udc_controller->gadget, driver); |
1980 | if (retval) { | 1980 | if (retval) { |
1981 | VDBG("bind to %s --> %d", driver->driver.name, retval); | 1981 | VDBG("bind to %s --> %d", driver->driver.name, retval); |
1982 | udc_controller->gadget.dev.driver = NULL; | 1982 | udc_controller->gadget.dev.driver = NULL; |
diff --git a/drivers/usb/gadget/fusb300_udc.c b/drivers/usb/gadget/fusb300_udc.c index cdd94540e1cd..72cd5e6719db 100644 --- a/drivers/usb/gadget/fusb300_udc.c +++ b/drivers/usb/gadget/fusb300_udc.c | |||
@@ -1311,7 +1311,7 @@ static void init_controller(struct fusb300 *fusb300) | |||
1311 | static struct fusb300 *the_controller; | 1311 | static struct fusb300 *the_controller; |
1312 | 1312 | ||
1313 | static int fusb300_udc_start(struct usb_gadget_driver *driver, | 1313 | static int fusb300_udc_start(struct usb_gadget_driver *driver, |
1314 | int (*bind)(struct usb_gadget *)) | 1314 | int (*bind)(struct usb_gadget *, struct usb_gadget_driver *)) |
1315 | { | 1315 | { |
1316 | struct fusb300 *fusb300 = the_controller; | 1316 | struct fusb300 *fusb300 = the_controller; |
1317 | int retval; | 1317 | int retval; |
@@ -1339,7 +1339,7 @@ static int fusb300_udc_start(struct usb_gadget_driver *driver, | |||
1339 | goto error; | 1339 | goto error; |
1340 | } | 1340 | } |
1341 | 1341 | ||
1342 | retval = bind(&fusb300->gadget); | 1342 | retval = bind(&fusb300->gadget, driver); |
1343 | if (retval) { | 1343 | if (retval) { |
1344 | pr_err("bind to driver error (%d)\n", retval); | 1344 | pr_err("bind to driver error (%d)\n", retval); |
1345 | device_del(&fusb300->gadget.dev); | 1345 | device_del(&fusb300->gadget.dev); |
diff --git a/drivers/usb/gadget/g_ffs.c b/drivers/usb/gadget/g_ffs.c index d3ace9002a6a..3953dd4d7186 100644 --- a/drivers/usb/gadget/g_ffs.c +++ b/drivers/usb/gadget/g_ffs.c | |||
@@ -13,7 +13,6 @@ | |||
13 | #define pr_fmt(fmt) "g_ffs: " fmt | 13 | #define pr_fmt(fmt) "g_ffs: " fmt |
14 | 14 | ||
15 | #include <linux/module.h> | 15 | #include <linux/module.h> |
16 | #include <linux/utsname.h> | ||
17 | 16 | ||
18 | /* | 17 | /* |
19 | * kbuild is not very cooperative with respect to linking separately | 18 | * kbuild is not very cooperative with respect to linking separately |
@@ -22,12 +21,6 @@ | |||
22 | * the runtime footprint, and giving us at least some parts of what | 21 | * the runtime footprint, and giving us at least some parts of what |
23 | * a "gcc --combine ... part1.c part2.c part3.c ... " build would. | 22 | * a "gcc --combine ... part1.c part2.c part3.c ... " build would. |
24 | */ | 23 | */ |
25 | |||
26 | #include "composite.c" | ||
27 | #include "usbstring.c" | ||
28 | #include "config.c" | ||
29 | #include "epautoconf.c" | ||
30 | |||
31 | #if defined CONFIG_USB_FUNCTIONFS_ETH || defined CONFIG_USB_FUNCTIONFS_RNDIS | 24 | #if defined CONFIG_USB_FUNCTIONFS_ETH || defined CONFIG_USB_FUNCTIONFS_RNDIS |
32 | # if defined USB_ETH_RNDIS | 25 | # if defined USB_ETH_RNDIS |
33 | # undef USB_ETH_RNDIS | 26 | # undef USB_ETH_RNDIS |
@@ -76,6 +69,8 @@ struct gfs_ffs_obj { | |||
76 | struct ffs_data *ffs_data; | 69 | struct ffs_data *ffs_data; |
77 | }; | 70 | }; |
78 | 71 | ||
72 | USB_GADGET_COMPOSITE_OPTIONS(); | ||
73 | |||
79 | static struct usb_device_descriptor gfs_dev_desc = { | 74 | static struct usb_device_descriptor gfs_dev_desc = { |
80 | .bLength = sizeof gfs_dev_desc, | 75 | .bLength = sizeof gfs_dev_desc, |
81 | .bDescriptorType = USB_DT_DEVICE, | 76 | .bDescriptorType = USB_DT_DEVICE, |
@@ -117,6 +112,9 @@ static const struct usb_descriptor_header *gfs_otg_desc[] = { | |||
117 | 112 | ||
118 | /* String IDs are assigned dynamically */ | 113 | /* String IDs are assigned dynamically */ |
119 | static struct usb_string gfs_strings[] = { | 114 | static struct usb_string gfs_strings[] = { |
115 | [USB_GADGET_MANUFACTURER_IDX].s = "", | ||
116 | [USB_GADGET_PRODUCT_IDX].s = DRIVER_DESC, | ||
117 | [USB_GADGET_SERIAL_IDX].s = "", | ||
120 | #ifdef CONFIG_USB_FUNCTIONFS_RNDIS | 118 | #ifdef CONFIG_USB_FUNCTIONFS_RNDIS |
121 | { .s = "FunctionFS + RNDIS" }, | 119 | { .s = "FunctionFS + RNDIS" }, |
122 | #endif | 120 | #endif |
@@ -163,13 +161,13 @@ static int gfs_bind(struct usb_composite_dev *cdev); | |||
163 | static int gfs_unbind(struct usb_composite_dev *cdev); | 161 | static int gfs_unbind(struct usb_composite_dev *cdev); |
164 | static int gfs_do_config(struct usb_configuration *c); | 162 | static int gfs_do_config(struct usb_configuration *c); |
165 | 163 | ||
166 | static struct usb_composite_driver gfs_driver = { | 164 | static __refdata struct usb_composite_driver gfs_driver = { |
167 | .name = DRIVER_NAME, | 165 | .name = DRIVER_NAME, |
168 | .dev = &gfs_dev_desc, | 166 | .dev = &gfs_dev_desc, |
169 | .strings = gfs_dev_strings, | 167 | .strings = gfs_dev_strings, |
170 | .max_speed = USB_SPEED_HIGH, | 168 | .max_speed = USB_SPEED_HIGH, |
169 | .bind = gfs_bind, | ||
171 | .unbind = gfs_unbind, | 170 | .unbind = gfs_unbind, |
172 | .iProduct = DRIVER_DESC, | ||
173 | }; | 171 | }; |
174 | 172 | ||
175 | static DEFINE_MUTEX(gfs_lock); | 173 | static DEFINE_MUTEX(gfs_lock); |
@@ -268,7 +266,7 @@ static int functionfs_ready_callback(struct ffs_data *ffs) | |||
268 | } | 266 | } |
269 | gfs_registered = true; | 267 | gfs_registered = true; |
270 | 268 | ||
271 | ret = usb_composite_probe(&gfs_driver, gfs_bind); | 269 | ret = usb_composite_probe(&gfs_driver); |
272 | if (unlikely(ret < 0)) | 270 | if (unlikely(ret < 0)) |
273 | gfs_registered = false; | 271 | gfs_registered = false; |
274 | 272 | ||
@@ -357,6 +355,7 @@ static int gfs_bind(struct usb_composite_dev *cdev) | |||
357 | ret = usb_string_ids_tab(cdev, gfs_strings); | 355 | ret = usb_string_ids_tab(cdev, gfs_strings); |
358 | if (unlikely(ret < 0)) | 356 | if (unlikely(ret < 0)) |
359 | goto error; | 357 | goto error; |
358 | gfs_dev_desc.iProduct = gfs_strings[USB_GADGET_PRODUCT_IDX].id; | ||
360 | 359 | ||
361 | for (i = func_num; --i; ) { | 360 | for (i = func_num; --i; ) { |
362 | ret = functionfs_bind(ffs_tab[i].ffs_data, cdev); | 361 | ret = functionfs_bind(ffs_tab[i].ffs_data, cdev); |
@@ -369,9 +368,10 @@ static int gfs_bind(struct usb_composite_dev *cdev) | |||
369 | 368 | ||
370 | for (i = 0; i < ARRAY_SIZE(gfs_configurations); ++i) { | 369 | for (i = 0; i < ARRAY_SIZE(gfs_configurations); ++i) { |
371 | struct gfs_configuration *c = gfs_configurations + i; | 370 | struct gfs_configuration *c = gfs_configurations + i; |
371 | int sid = USB_GADGET_FIRST_AVAIL_IDX + i; | ||
372 | 372 | ||
373 | c->c.label = gfs_strings[i].s; | 373 | c->c.label = gfs_strings[sid].s; |
374 | c->c.iConfiguration = gfs_strings[i].id; | 374 | c->c.iConfiguration = gfs_strings[sid].id; |
375 | c->c.bConfigurationValue = 1 + i; | 375 | c->c.bConfigurationValue = 1 + i; |
376 | c->c.bmAttributes = USB_CONFIG_ATT_SELFPOWER; | 376 | c->c.bmAttributes = USB_CONFIG_ATT_SELFPOWER; |
377 | 377 | ||
@@ -379,7 +379,7 @@ static int gfs_bind(struct usb_composite_dev *cdev) | |||
379 | if (unlikely(ret < 0)) | 379 | if (unlikely(ret < 0)) |
380 | goto error_unbind; | 380 | goto error_unbind; |
381 | } | 381 | } |
382 | 382 | usb_composite_overwrite_options(cdev, &coverwrite); | |
383 | return 0; | 383 | return 0; |
384 | 384 | ||
385 | error_unbind: | 385 | error_unbind: |
diff --git a/drivers/usb/gadget/gadget_chips.h b/drivers/usb/gadget/gadget_chips.h index b8b3a3411218..bcd04bc66b98 100644 --- a/drivers/usb/gadget/gadget_chips.h +++ b/drivers/usb/gadget/gadget_chips.h | |||
@@ -15,6 +15,8 @@ | |||
15 | #ifndef __GADGET_CHIPS_H | 15 | #ifndef __GADGET_CHIPS_H |
16 | #define __GADGET_CHIPS_H | 16 | #define __GADGET_CHIPS_H |
17 | 17 | ||
18 | #include <linux/usb/gadget.h> | ||
19 | |||
18 | /* | 20 | /* |
19 | * NOTICE: the entries below are alphabetical and should be kept | 21 | * NOTICE: the entries below are alphabetical and should be kept |
20 | * that way. | 22 | * that way. |
@@ -25,106 +27,12 @@ | |||
25 | * If you have forgotten the alphabetical order let VIM/EMACS | 27 | * If you have forgotten the alphabetical order let VIM/EMACS |
26 | * do that for you. | 28 | * do that for you. |
27 | */ | 29 | */ |
28 | #define gadget_is_amd5536udc(g) (!strcmp("amd5536udc", (g)->name)) | ||
29 | #define gadget_is_at91(g) (!strcmp("at91_udc", (g)->name)) | 30 | #define gadget_is_at91(g) (!strcmp("at91_udc", (g)->name)) |
30 | #define gadget_is_atmel_usba(g) (!strcmp("atmel_usba_udc", (g)->name)) | ||
31 | #define gadget_is_ci13xxx_msm(g) (!strcmp("ci13xxx_msm", (g)->name)) | ||
32 | #define gadget_is_ci13xxx_pci(g) (!strcmp("ci13xxx_pci", (g)->name)) | ||
33 | #define gadget_is_dummy(g) (!strcmp("dummy_udc", (g)->name)) | ||
34 | #define gadget_is_dwc3(g) (!strcmp("dwc3-gadget", (g)->name)) | ||
35 | #define gadget_is_fsl_qe(g) (!strcmp("fsl_qe_udc", (g)->name)) | ||
36 | #define gadget_is_fsl_usb2(g) (!strcmp("fsl-usb2-udc", (g)->name)) | ||
37 | #define gadget_is_goku(g) (!strcmp("goku_udc", (g)->name)) | 31 | #define gadget_is_goku(g) (!strcmp("goku_udc", (g)->name)) |
38 | #define gadget_is_imx(g) (!strcmp("imx_udc", (g)->name)) | ||
39 | #define gadget_is_langwell(g) (!strcmp("langwell_udc", (g)->name)) | ||
40 | #define gadget_is_lpc32xx(g) (!strcmp("lpc32xx_udc", (g)->name)) | ||
41 | #define gadget_is_m66592(g) (!strcmp("m66592_udc", (g)->name)) | ||
42 | #define gadget_is_musbhdrc(g) (!strcmp("musb-hdrc", (g)->name)) | 32 | #define gadget_is_musbhdrc(g) (!strcmp("musb-hdrc", (g)->name)) |
43 | #define gadget_is_net2272(g) (!strcmp("net2272", (g)->name)) | ||
44 | #define gadget_is_net2280(g) (!strcmp("net2280", (g)->name)) | 33 | #define gadget_is_net2280(g) (!strcmp("net2280", (g)->name)) |
45 | #define gadget_is_omap(g) (!strcmp("omap_udc", (g)->name)) | ||
46 | #define gadget_is_pch(g) (!strcmp("pch_udc", (g)->name)) | ||
47 | #define gadget_is_pxa(g) (!strcmp("pxa25x_udc", (g)->name)) | 34 | #define gadget_is_pxa(g) (!strcmp("pxa25x_udc", (g)->name)) |
48 | #define gadget_is_pxa27x(g) (!strcmp("pxa27x_udc", (g)->name)) | 35 | #define gadget_is_pxa27x(g) (!strcmp("pxa27x_udc", (g)->name)) |
49 | #define gadget_is_r8a66597(g) (!strcmp("r8a66597_udc", (g)->name)) | ||
50 | #define gadget_is_renesas_usbhs(g) (!strcmp("renesas_usbhs_udc", (g)->name)) | ||
51 | #define gadget_is_s3c2410(g) (!strcmp("s3c2410_udc", (g)->name)) | ||
52 | #define gadget_is_s3c_hsotg(g) (!strcmp("s3c-hsotg", (g)->name)) | ||
53 | #define gadget_is_s3c_hsudc(g) (!strcmp("s3c-hsudc", (g)->name)) | ||
54 | |||
55 | /** | ||
56 | * usb_gadget_controller_number - support bcdDevice id convention | ||
57 | * @gadget: the controller being driven | ||
58 | * | ||
59 | * Return a 2-digit BCD value associated with the peripheral controller, | ||
60 | * suitable for use as part of a bcdDevice value, or a negative error code. | ||
61 | * | ||
62 | * NOTE: this convention is purely optional, and has no meaning in terms of | ||
63 | * any USB specification. If you want to use a different convention in your | ||
64 | * gadget driver firmware -- maybe a more formal revision ID -- feel free. | ||
65 | * | ||
66 | * Hosts see these bcdDevice numbers, and are allowed (but not encouraged!) | ||
67 | * to change their behavior accordingly. For example it might help avoiding | ||
68 | * some chip bug. | ||
69 | */ | ||
70 | static inline int usb_gadget_controller_number(struct usb_gadget *gadget) | ||
71 | { | ||
72 | if (gadget_is_net2280(gadget)) | ||
73 | return 0x01; | ||
74 | else if (gadget_is_dummy(gadget)) | ||
75 | return 0x02; | ||
76 | else if (gadget_is_pxa(gadget)) | ||
77 | return 0x03; | ||
78 | else if (gadget_is_goku(gadget)) | ||
79 | return 0x06; | ||
80 | else if (gadget_is_omap(gadget)) | ||
81 | return 0x08; | ||
82 | else if (gadget_is_pxa27x(gadget)) | ||
83 | return 0x11; | ||
84 | else if (gadget_is_s3c2410(gadget)) | ||
85 | return 0x12; | ||
86 | else if (gadget_is_at91(gadget)) | ||
87 | return 0x13; | ||
88 | else if (gadget_is_imx(gadget)) | ||
89 | return 0x14; | ||
90 | else if (gadget_is_musbhdrc(gadget)) | ||
91 | return 0x16; | ||
92 | else if (gadget_is_atmel_usba(gadget)) | ||
93 | return 0x18; | ||
94 | else if (gadget_is_fsl_usb2(gadget)) | ||
95 | return 0x19; | ||
96 | else if (gadget_is_amd5536udc(gadget)) | ||
97 | return 0x20; | ||
98 | else if (gadget_is_m66592(gadget)) | ||
99 | return 0x21; | ||
100 | else if (gadget_is_fsl_qe(gadget)) | ||
101 | return 0x22; | ||
102 | else if (gadget_is_ci13xxx_pci(gadget)) | ||
103 | return 0x23; | ||
104 | else if (gadget_is_langwell(gadget)) | ||
105 | return 0x24; | ||
106 | else if (gadget_is_r8a66597(gadget)) | ||
107 | return 0x25; | ||
108 | else if (gadget_is_s3c_hsotg(gadget)) | ||
109 | return 0x26; | ||
110 | else if (gadget_is_pch(gadget)) | ||
111 | return 0x27; | ||
112 | else if (gadget_is_ci13xxx_msm(gadget)) | ||
113 | return 0x28; | ||
114 | else if (gadget_is_renesas_usbhs(gadget)) | ||
115 | return 0x29; | ||
116 | else if (gadget_is_s3c_hsudc(gadget)) | ||
117 | return 0x30; | ||
118 | else if (gadget_is_net2272(gadget)) | ||
119 | return 0x31; | ||
120 | else if (gadget_is_dwc3(gadget)) | ||
121 | return 0x32; | ||
122 | else if (gadget_is_lpc32xx(gadget)) | ||
123 | return 0x33; | ||
124 | |||
125 | return -ENOENT; | ||
126 | } | ||
127 | |||
128 | 36 | ||
129 | /** | 37 | /** |
130 | * gadget_supports_altsettings - return true if altsettings work | 38 | * gadget_supports_altsettings - return true if altsettings work |
diff --git a/drivers/usb/gadget/gmidi.c b/drivers/usb/gadget/gmidi.c index 681bd038b1d8..881aab86ae99 100644 --- a/drivers/usb/gadget/gmidi.c +++ b/drivers/usb/gadget/gmidi.c | |||
@@ -22,7 +22,6 @@ | |||
22 | 22 | ||
23 | #include <linux/kernel.h> | 23 | #include <linux/kernel.h> |
24 | #include <linux/slab.h> | 24 | #include <linux/slab.h> |
25 | #include <linux/utsname.h> | ||
26 | #include <linux/module.h> | 25 | #include <linux/module.h> |
27 | #include <linux/device.h> | 26 | #include <linux/device.h> |
28 | 27 | ||
@@ -31,16 +30,13 @@ | |||
31 | #include <sound/rawmidi.h> | 30 | #include <sound/rawmidi.h> |
32 | 31 | ||
33 | #include <linux/usb/ch9.h> | 32 | #include <linux/usb/ch9.h> |
33 | #include <linux/usb/composite.h> | ||
34 | #include <linux/usb/gadget.h> | 34 | #include <linux/usb/gadget.h> |
35 | #include <linux/usb/audio.h> | 35 | #include <linux/usb/audio.h> |
36 | #include <linux/usb/midi.h> | 36 | #include <linux/usb/midi.h> |
37 | 37 | ||
38 | #include "gadget_chips.h" | 38 | #include "gadget_chips.h" |
39 | 39 | ||
40 | #include "composite.c" | ||
41 | #include "usbstring.c" | ||
42 | #include "config.c" | ||
43 | #include "epautoconf.c" | ||
44 | #include "f_midi.c" | 40 | #include "f_midi.c" |
45 | 41 | ||
46 | /*-------------------------------------------------------------------------*/ | 42 | /*-------------------------------------------------------------------------*/ |
@@ -51,6 +47,8 @@ MODULE_LICENSE("GPL v2"); | |||
51 | static const char shortname[] = "g_midi"; | 47 | static const char shortname[] = "g_midi"; |
52 | static const char longname[] = "MIDI Gadget"; | 48 | static const char longname[] = "MIDI Gadget"; |
53 | 49 | ||
50 | USB_GADGET_COMPOSITE_OPTIONS(); | ||
51 | |||
54 | static int index = SNDRV_DEFAULT_IDX1; | 52 | static int index = SNDRV_DEFAULT_IDX1; |
55 | module_param(index, int, S_IRUGO); | 53 | module_param(index, int, S_IRUGO); |
56 | MODULE_PARM_DESC(index, "Index value for the USB MIDI Gadget adapter."); | 54 | MODULE_PARM_DESC(index, "Index value for the USB MIDI Gadget adapter."); |
@@ -85,9 +83,7 @@ MODULE_PARM_DESC(out_ports, "Number of MIDI output ports"); | |||
85 | 83 | ||
86 | /* string IDs are assigned dynamically */ | 84 | /* string IDs are assigned dynamically */ |
87 | 85 | ||
88 | #define STRING_MANUFACTURER_IDX 0 | 86 | #define STRING_DESCRIPTION_IDX USB_GADGET_FIRST_AVAIL_IDX |
89 | #define STRING_PRODUCT_IDX 1 | ||
90 | #define STRING_DESCRIPTION_IDX 2 | ||
91 | 87 | ||
92 | static struct usb_device_descriptor device_desc = { | 88 | static struct usb_device_descriptor device_desc = { |
93 | .bLength = USB_DT_DEVICE_SIZE, | 89 | .bLength = USB_DT_DEVICE_SIZE, |
@@ -102,8 +98,9 @@ static struct usb_device_descriptor device_desc = { | |||
102 | }; | 98 | }; |
103 | 99 | ||
104 | static struct usb_string strings_dev[] = { | 100 | static struct usb_string strings_dev[] = { |
105 | [STRING_MANUFACTURER_IDX].s = "Grey Innovation", | 101 | [USB_GADGET_MANUFACTURER_IDX].s = "Grey Innovation", |
106 | [STRING_PRODUCT_IDX].s = "MIDI Gadget", | 102 | [USB_GADGET_PRODUCT_IDX].s = "MIDI Gadget", |
103 | [USB_GADGET_SERIAL_IDX].s = "", | ||
107 | [STRING_DESCRIPTION_IDX].s = "MIDI", | 104 | [STRING_DESCRIPTION_IDX].s = "MIDI", |
108 | { } /* end of list */ | 105 | { } /* end of list */ |
109 | }; | 106 | }; |
@@ -140,61 +137,35 @@ static int __init midi_bind_config(struct usb_configuration *c) | |||
140 | 137 | ||
141 | static int __init midi_bind(struct usb_composite_dev *cdev) | 138 | static int __init midi_bind(struct usb_composite_dev *cdev) |
142 | { | 139 | { |
143 | struct usb_gadget *gadget = cdev->gadget; | 140 | int status; |
144 | int gcnum, status; | ||
145 | |||
146 | status = usb_string_id(cdev); | ||
147 | if (status < 0) | ||
148 | return status; | ||
149 | strings_dev[STRING_MANUFACTURER_IDX].id = status; | ||
150 | device_desc.iManufacturer = status; | ||
151 | 141 | ||
152 | status = usb_string_id(cdev); | 142 | status = usb_string_ids_tab(cdev, strings_dev); |
153 | if (status < 0) | 143 | if (status < 0) |
154 | return status; | 144 | return status; |
155 | strings_dev[STRING_PRODUCT_IDX].id = status; | 145 | device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id; |
156 | device_desc.iProduct = status; | 146 | device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; |
157 | 147 | midi_config.iConfiguration = strings_dev[STRING_DESCRIPTION_IDX].id; | |
158 | /* config description */ | ||
159 | status = usb_string_id(cdev); | ||
160 | if (status < 0) | ||
161 | return status; | ||
162 | strings_dev[STRING_DESCRIPTION_IDX].id = status; | ||
163 | |||
164 | midi_config.iConfiguration = status; | ||
165 | |||
166 | gcnum = usb_gadget_controller_number(gadget); | ||
167 | if (gcnum < 0) { | ||
168 | /* gmidi is so simple (no altsettings) that | ||
169 | * it SHOULD NOT have problems with bulk-capable hardware. | ||
170 | * so warn about unrecognized controllers, don't panic. | ||
171 | */ | ||
172 | pr_warning("%s: controller '%s' not recognized\n", | ||
173 | __func__, gadget->name); | ||
174 | device_desc.bcdDevice = cpu_to_le16(0x9999); | ||
175 | } else { | ||
176 | device_desc.bcdDevice = cpu_to_le16(0x0200 + gcnum); | ||
177 | } | ||
178 | 148 | ||
179 | status = usb_add_config(cdev, &midi_config, midi_bind_config); | 149 | status = usb_add_config(cdev, &midi_config, midi_bind_config); |
180 | if (status < 0) | 150 | if (status < 0) |
181 | return status; | 151 | return status; |
182 | 152 | usb_composite_overwrite_options(cdev, &coverwrite); | |
183 | pr_info("%s\n", longname); | 153 | pr_info("%s\n", longname); |
184 | return 0; | 154 | return 0; |
185 | } | 155 | } |
186 | 156 | ||
187 | static struct usb_composite_driver midi_driver = { | 157 | static __refdata struct usb_composite_driver midi_driver = { |
188 | .name = (char *) longname, | 158 | .name = (char *) longname, |
189 | .dev = &device_desc, | 159 | .dev = &device_desc, |
190 | .strings = dev_strings, | 160 | .strings = dev_strings, |
191 | .max_speed = USB_SPEED_HIGH, | 161 | .max_speed = USB_SPEED_HIGH, |
162 | .bind = midi_bind, | ||
192 | .unbind = __exit_p(midi_unbind), | 163 | .unbind = __exit_p(midi_unbind), |
193 | }; | 164 | }; |
194 | 165 | ||
195 | static int __init midi_init(void) | 166 | static int __init midi_init(void) |
196 | { | 167 | { |
197 | return usb_composite_probe(&midi_driver, midi_bind); | 168 | return usb_composite_probe(&midi_driver); |
198 | } | 169 | } |
199 | module_init(midi_init); | 170 | module_init(midi_init); |
200 | 171 | ||
diff --git a/drivers/usb/gadget/goku_udc.c b/drivers/usb/gadget/goku_udc.c index 9fd7886cfa9a..51037cb78604 100644 --- a/drivers/usb/gadget/goku_udc.c +++ b/drivers/usb/gadget/goku_udc.c | |||
@@ -994,7 +994,7 @@ static int goku_get_frame(struct usb_gadget *_gadget) | |||
994 | } | 994 | } |
995 | 995 | ||
996 | static int goku_start(struct usb_gadget_driver *driver, | 996 | static int goku_start(struct usb_gadget_driver *driver, |
997 | int (*bind)(struct usb_gadget *)); | 997 | int (*bind)(struct usb_gadget *, struct usb_gadget_driver *)); |
998 | static int goku_stop(struct usb_gadget_driver *driver); | 998 | static int goku_stop(struct usb_gadget_driver *driver); |
999 | 999 | ||
1000 | static const struct usb_gadget_ops goku_ops = { | 1000 | static const struct usb_gadget_ops goku_ops = { |
@@ -1348,7 +1348,7 @@ static struct goku_udc *the_controller; | |||
1348 | * the driver might get unbound. | 1348 | * the driver might get unbound. |
1349 | */ | 1349 | */ |
1350 | static int goku_start(struct usb_gadget_driver *driver, | 1350 | static int goku_start(struct usb_gadget_driver *driver, |
1351 | int (*bind)(struct usb_gadget *)) | 1351 | int (*bind)(struct usb_gadget *, struct usb_gadget_driver *)) |
1352 | { | 1352 | { |
1353 | struct goku_udc *dev = the_controller; | 1353 | struct goku_udc *dev = the_controller; |
1354 | int retval; | 1354 | int retval; |
@@ -1368,7 +1368,7 @@ static int goku_start(struct usb_gadget_driver *driver, | |||
1368 | driver->driver.bus = NULL; | 1368 | driver->driver.bus = NULL; |
1369 | dev->driver = driver; | 1369 | dev->driver = driver; |
1370 | dev->gadget.dev.driver = &driver->driver; | 1370 | dev->gadget.dev.driver = &driver->driver; |
1371 | retval = bind(&dev->gadget); | 1371 | retval = bind(&dev->gadget, driver); |
1372 | if (retval) { | 1372 | if (retval) { |
1373 | DBG(dev, "bind to driver %s --> error %d\n", | 1373 | DBG(dev, "bind to driver %s --> error %d\n", |
1374 | driver->driver.name, retval); | 1374 | driver->driver.name, retval); |
diff --git a/drivers/usb/gadget/hid.c b/drivers/usb/gadget/hid.c index 3493adf064f5..74130f6c12c0 100644 --- a/drivers/usb/gadget/hid.c +++ b/drivers/usb/gadget/hid.c | |||
@@ -15,7 +15,10 @@ | |||
15 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
16 | #include <linux/platform_device.h> | 16 | #include <linux/platform_device.h> |
17 | #include <linux/list.h> | 17 | #include <linux/list.h> |
18 | #include <linux/module.h> | ||
19 | #include <linux/usb/composite.h> | ||
18 | 20 | ||
21 | #include "gadget_chips.h" | ||
19 | #define DRIVER_DESC "HID Gadget" | 22 | #define DRIVER_DESC "HID Gadget" |
20 | #define DRIVER_VERSION "2010/03/16" | 23 | #define DRIVER_VERSION "2010/03/16" |
21 | 24 | ||
@@ -33,12 +36,6 @@ | |||
33 | * the runtime footprint, and giving us at least some parts of what | 36 | * the runtime footprint, and giving us at least some parts of what |
34 | * a "gcc --combine ... part1.c part2.c part3.c ... " build would. | 37 | * a "gcc --combine ... part1.c part2.c part3.c ... " build would. |
35 | */ | 38 | */ |
36 | |||
37 | #include "composite.c" | ||
38 | #include "usbstring.c" | ||
39 | #include "config.c" | ||
40 | #include "epautoconf.c" | ||
41 | |||
42 | #include "f_hid.c" | 39 | #include "f_hid.c" |
43 | 40 | ||
44 | 41 | ||
@@ -50,6 +47,7 @@ struct hidg_func_node { | |||
50 | static LIST_HEAD(hidg_func_list); | 47 | static LIST_HEAD(hidg_func_list); |
51 | 48 | ||
52 | /*-------------------------------------------------------------------------*/ | 49 | /*-------------------------------------------------------------------------*/ |
50 | USB_GADGET_COMPOSITE_OPTIONS(); | ||
53 | 51 | ||
54 | static struct usb_device_descriptor device_desc = { | 52 | static struct usb_device_descriptor device_desc = { |
55 | .bLength = sizeof device_desc, | 53 | .bLength = sizeof device_desc, |
@@ -92,15 +90,10 @@ static const struct usb_descriptor_header *otg_desc[] = { | |||
92 | 90 | ||
93 | 91 | ||
94 | /* string IDs are assigned dynamically */ | 92 | /* string IDs are assigned dynamically */ |
95 | |||
96 | #define STRING_MANUFACTURER_IDX 0 | ||
97 | #define STRING_PRODUCT_IDX 1 | ||
98 | |||
99 | static char manufacturer[50]; | ||
100 | |||
101 | static struct usb_string strings_dev[] = { | 93 | static struct usb_string strings_dev[] = { |
102 | [STRING_MANUFACTURER_IDX].s = manufacturer, | 94 | [USB_GADGET_MANUFACTURER_IDX].s = "", |
103 | [STRING_PRODUCT_IDX].s = DRIVER_DESC, | 95 | [USB_GADGET_PRODUCT_IDX].s = DRIVER_DESC, |
96 | [USB_GADGET_SERIAL_IDX].s = "", | ||
104 | { } /* end of list */ | 97 | { } /* end of list */ |
105 | }; | 98 | }; |
106 | 99 | ||
@@ -150,7 +143,7 @@ static int __init hid_bind(struct usb_composite_dev *cdev) | |||
150 | { | 143 | { |
151 | struct usb_gadget *gadget = cdev->gadget; | 144 | struct usb_gadget *gadget = cdev->gadget; |
152 | struct list_head *tmp; | 145 | struct list_head *tmp; |
153 | int status, gcnum, funcs = 0; | 146 | int status, funcs = 0; |
154 | 147 | ||
155 | list_for_each(tmp, &hidg_func_list) | 148 | list_for_each(tmp, &hidg_func_list) |
156 | funcs++; | 149 | funcs++; |
@@ -163,38 +156,22 @@ static int __init hid_bind(struct usb_composite_dev *cdev) | |||
163 | if (status < 0) | 156 | if (status < 0) |
164 | return status; | 157 | return status; |
165 | 158 | ||
166 | gcnum = usb_gadget_controller_number(gadget); | ||
167 | if (gcnum >= 0) | ||
168 | device_desc.bcdDevice = cpu_to_le16(0x0300 | gcnum); | ||
169 | else | ||
170 | device_desc.bcdDevice = cpu_to_le16(0x0300 | 0x0099); | ||
171 | |||
172 | |||
173 | /* Allocate string descriptor numbers ... note that string | 159 | /* Allocate string descriptor numbers ... note that string |
174 | * contents can be overridden by the composite_dev glue. | 160 | * contents can be overridden by the composite_dev glue. |
175 | */ | 161 | */ |
176 | 162 | ||
177 | /* device descriptor strings: manufacturer, product */ | 163 | status = usb_string_ids_tab(cdev, strings_dev); |
178 | snprintf(manufacturer, sizeof manufacturer, "%s %s with %s", | ||
179 | init_utsname()->sysname, init_utsname()->release, | ||
180 | gadget->name); | ||
181 | status = usb_string_id(cdev); | ||
182 | if (status < 0) | ||
183 | return status; | ||
184 | strings_dev[STRING_MANUFACTURER_IDX].id = status; | ||
185 | device_desc.iManufacturer = status; | ||
186 | |||
187 | status = usb_string_id(cdev); | ||
188 | if (status < 0) | 164 | if (status < 0) |
189 | return status; | 165 | return status; |
190 | strings_dev[STRING_PRODUCT_IDX].id = status; | 166 | device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id; |
191 | device_desc.iProduct = status; | 167 | device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; |
192 | 168 | ||
193 | /* register our configuration */ | 169 | /* register our configuration */ |
194 | status = usb_add_config(cdev, &config_driver, do_config); | 170 | status = usb_add_config(cdev, &config_driver, do_config); |
195 | if (status < 0) | 171 | if (status < 0) |
196 | return status; | 172 | return status; |
197 | 173 | ||
174 | usb_composite_overwrite_options(cdev, &coverwrite); | ||
198 | dev_info(&gadget->dev, DRIVER_DESC ", version: " DRIVER_VERSION "\n"); | 175 | dev_info(&gadget->dev, DRIVER_DESC ", version: " DRIVER_VERSION "\n"); |
199 | 176 | ||
200 | return 0; | 177 | return 0; |
@@ -242,11 +219,12 @@ static int __devexit hidg_plat_driver_remove(struct platform_device *pdev) | |||
242 | /****************************** Some noise ******************************/ | 219 | /****************************** Some noise ******************************/ |
243 | 220 | ||
244 | 221 | ||
245 | static struct usb_composite_driver hidg_driver = { | 222 | static __refdata struct usb_composite_driver hidg_driver = { |
246 | .name = "g_hid", | 223 | .name = "g_hid", |
247 | .dev = &device_desc, | 224 | .dev = &device_desc, |
248 | .strings = dev_strings, | 225 | .strings = dev_strings, |
249 | .max_speed = USB_SPEED_HIGH, | 226 | .max_speed = USB_SPEED_HIGH, |
227 | .bind = hid_bind, | ||
250 | .unbind = __exit_p(hid_unbind), | 228 | .unbind = __exit_p(hid_unbind), |
251 | }; | 229 | }; |
252 | 230 | ||
@@ -272,7 +250,7 @@ static int __init hidg_init(void) | |||
272 | if (status < 0) | 250 | if (status < 0) |
273 | return status; | 251 | return status; |
274 | 252 | ||
275 | status = usb_composite_probe(&hidg_driver, hid_bind); | 253 | status = usb_composite_probe(&hidg_driver); |
276 | if (status < 0) | 254 | if (status < 0) |
277 | platform_driver_unregister(&hidg_plat_driver); | 255 | platform_driver_unregister(&hidg_plat_driver); |
278 | 256 | ||
diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c index e58b16442971..4bb6d53f2de3 100644 --- a/drivers/usb/gadget/inode.c +++ b/drivers/usb/gadget/inode.c | |||
@@ -828,7 +828,6 @@ ep_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr) | |||
828 | if (value == 0) | 828 | if (value == 0) |
829 | data->state = STATE_EP_ENABLED; | 829 | data->state = STATE_EP_ENABLED; |
830 | break; | 830 | break; |
831 | #ifdef CONFIG_USB_GADGET_DUALSPEED | ||
832 | case USB_SPEED_HIGH: | 831 | case USB_SPEED_HIGH: |
833 | /* fails if caller didn't provide that descriptor... */ | 832 | /* fails if caller didn't provide that descriptor... */ |
834 | ep->desc = &data->hs_desc; | 833 | ep->desc = &data->hs_desc; |
@@ -836,7 +835,6 @@ ep_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr) | |||
836 | if (value == 0) | 835 | if (value == 0) |
837 | data->state = STATE_EP_ENABLED; | 836 | data->state = STATE_EP_ENABLED; |
838 | break; | 837 | break; |
839 | #endif | ||
840 | default: | 838 | default: |
841 | DBG(data->dev, "unconnected, %s init abandoned\n", | 839 | DBG(data->dev, "unconnected, %s init abandoned\n", |
842 | data->name); | 840 | data->name); |
@@ -1324,7 +1322,6 @@ static const struct file_operations ep0_io_operations = { | |||
1324 | * Unrecognized ep0 requests may be handled in user space. | 1322 | * Unrecognized ep0 requests may be handled in user space. |
1325 | */ | 1323 | */ |
1326 | 1324 | ||
1327 | #ifdef CONFIG_USB_GADGET_DUALSPEED | ||
1328 | static void make_qualifier (struct dev_data *dev) | 1325 | static void make_qualifier (struct dev_data *dev) |
1329 | { | 1326 | { |
1330 | struct usb_qualifier_descriptor qual; | 1327 | struct usb_qualifier_descriptor qual; |
@@ -1347,7 +1344,6 @@ static void make_qualifier (struct dev_data *dev) | |||
1347 | 1344 | ||
1348 | memcpy (dev->rbuf, &qual, sizeof qual); | 1345 | memcpy (dev->rbuf, &qual, sizeof qual); |
1349 | } | 1346 | } |
1350 | #endif | ||
1351 | 1347 | ||
1352 | static int | 1348 | static int |
1353 | config_buf (struct dev_data *dev, u8 type, unsigned index) | 1349 | config_buf (struct dev_data *dev, u8 type, unsigned index) |
@@ -1427,7 +1423,6 @@ gadgetfs_setup (struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) | |||
1427 | dev->dev->bMaxPacketSize0 = dev->gadget->ep0->maxpacket; | 1423 | dev->dev->bMaxPacketSize0 = dev->gadget->ep0->maxpacket; |
1428 | req->buf = dev->dev; | 1424 | req->buf = dev->dev; |
1429 | break; | 1425 | break; |
1430 | #ifdef CONFIG_USB_GADGET_DUALSPEED | ||
1431 | case USB_DT_DEVICE_QUALIFIER: | 1426 | case USB_DT_DEVICE_QUALIFIER: |
1432 | if (!dev->hs_config) | 1427 | if (!dev->hs_config) |
1433 | break; | 1428 | break; |
@@ -1437,7 +1432,6 @@ gadgetfs_setup (struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) | |||
1437 | break; | 1432 | break; |
1438 | case USB_DT_OTHER_SPEED_CONFIG: | 1433 | case USB_DT_OTHER_SPEED_CONFIG: |
1439 | // FALLTHROUGH | 1434 | // FALLTHROUGH |
1440 | #endif | ||
1441 | case USB_DT_CONFIG: | 1435 | case USB_DT_CONFIG: |
1442 | value = config_buf (dev, | 1436 | value = config_buf (dev, |
1443 | w_value >> 8, | 1437 | w_value >> 8, |
@@ -1685,8 +1679,8 @@ gadgetfs_unbind (struct usb_gadget *gadget) | |||
1685 | 1679 | ||
1686 | static struct dev_data *the_device; | 1680 | static struct dev_data *the_device; |
1687 | 1681 | ||
1688 | static int | 1682 | static int gadgetfs_bind(struct usb_gadget *gadget, |
1689 | gadgetfs_bind (struct usb_gadget *gadget) | 1683 | struct usb_gadget_driver *driver) |
1690 | { | 1684 | { |
1691 | struct dev_data *dev = the_device; | 1685 | struct dev_data *dev = the_device; |
1692 | 1686 | ||
@@ -1763,12 +1757,8 @@ gadgetfs_suspend (struct usb_gadget *gadget) | |||
1763 | } | 1757 | } |
1764 | 1758 | ||
1765 | static struct usb_gadget_driver gadgetfs_driver = { | 1759 | static struct usb_gadget_driver gadgetfs_driver = { |
1766 | #ifdef CONFIG_USB_GADGET_DUALSPEED | ||
1767 | .max_speed = USB_SPEED_HIGH, | ||
1768 | #else | ||
1769 | .max_speed = USB_SPEED_FULL, | ||
1770 | #endif | ||
1771 | .function = (char *) driver_desc, | 1760 | .function = (char *) driver_desc, |
1761 | .bind = gadgetfs_bind, | ||
1772 | .unbind = gadgetfs_unbind, | 1762 | .unbind = gadgetfs_unbind, |
1773 | .setup = gadgetfs_setup, | 1763 | .setup = gadgetfs_setup, |
1774 | .disconnect = gadgetfs_disconnect, | 1764 | .disconnect = gadgetfs_disconnect, |
@@ -1783,7 +1773,8 @@ static struct usb_gadget_driver gadgetfs_driver = { | |||
1783 | 1773 | ||
1784 | static void gadgetfs_nop(struct usb_gadget *arg) { } | 1774 | static void gadgetfs_nop(struct usb_gadget *arg) { } |
1785 | 1775 | ||
1786 | static int gadgetfs_probe (struct usb_gadget *gadget) | 1776 | static int gadgetfs_probe(struct usb_gadget *gadget, |
1777 | struct usb_gadget_driver *driver) | ||
1787 | { | 1778 | { |
1788 | CHIP = gadget->name; | 1779 | CHIP = gadget->name; |
1789 | return -EISNAM; | 1780 | return -EISNAM; |
@@ -1791,6 +1782,7 @@ static int gadgetfs_probe (struct usb_gadget *gadget) | |||
1791 | 1782 | ||
1792 | static struct usb_gadget_driver probe_driver = { | 1783 | static struct usb_gadget_driver probe_driver = { |
1793 | .max_speed = USB_SPEED_HIGH, | 1784 | .max_speed = USB_SPEED_HIGH, |
1785 | .bind = gadgetfs_probe, | ||
1794 | .unbind = gadgetfs_nop, | 1786 | .unbind = gadgetfs_nop, |
1795 | .setup = (void *)gadgetfs_nop, | 1787 | .setup = (void *)gadgetfs_nop, |
1796 | .disconnect = gadgetfs_nop, | 1788 | .disconnect = gadgetfs_nop, |
@@ -1900,7 +1892,12 @@ dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr) | |||
1900 | 1892 | ||
1901 | /* triggers gadgetfs_bind(); then we can enumerate. */ | 1893 | /* triggers gadgetfs_bind(); then we can enumerate. */ |
1902 | spin_unlock_irq (&dev->lock); | 1894 | spin_unlock_irq (&dev->lock); |
1903 | value = usb_gadget_probe_driver(&gadgetfs_driver, gadgetfs_bind); | 1895 | if (dev->hs_config) |
1896 | gadgetfs_driver.max_speed = USB_SPEED_HIGH; | ||
1897 | else | ||
1898 | gadgetfs_driver.max_speed = USB_SPEED_FULL; | ||
1899 | |||
1900 | value = usb_gadget_probe_driver(&gadgetfs_driver); | ||
1904 | if (value != 0) { | 1901 | if (value != 0) { |
1905 | kfree (dev->buf); | 1902 | kfree (dev->buf); |
1906 | dev->buf = NULL; | 1903 | dev->buf = NULL; |
@@ -2039,7 +2036,7 @@ gadgetfs_fill_super (struct super_block *sb, void *opts, int silent) | |||
2039 | return -ESRCH; | 2036 | return -ESRCH; |
2040 | 2037 | ||
2041 | /* fake probe to determine $CHIP */ | 2038 | /* fake probe to determine $CHIP */ |
2042 | (void) usb_gadget_probe_driver(&probe_driver, gadgetfs_probe); | 2039 | usb_gadget_probe_driver(&probe_driver); |
2043 | if (!CHIP) | 2040 | if (!CHIP) |
2044 | return -ENODEV; | 2041 | return -ENODEV; |
2045 | 2042 | ||
diff --git a/drivers/usb/gadget/lpc32xx_udc.c b/drivers/usb/gadget/lpc32xx_udc.c index f1ec99e69cb7..f696fb9b136d 100644 --- a/drivers/usb/gadget/lpc32xx_udc.c +++ b/drivers/usb/gadget/lpc32xx_udc.c | |||
@@ -141,8 +141,6 @@ struct lpc32xx_ep { | |||
141 | u32 totalints; | 141 | u32 totalints; |
142 | 142 | ||
143 | bool wedge; | 143 | bool wedge; |
144 | |||
145 | const struct usb_endpoint_descriptor *desc; | ||
146 | }; | 144 | }; |
147 | 145 | ||
148 | /* | 146 | /* |
@@ -556,10 +554,8 @@ static int proc_udc_show(struct seq_file *s, void *unused) | |||
556 | 554 | ||
557 | if (udc->enabled && udc->vbus) { | 555 | if (udc->enabled && udc->vbus) { |
558 | proc_ep_show(s, &udc->ep[0]); | 556 | proc_ep_show(s, &udc->ep[0]); |
559 | list_for_each_entry(ep, &udc->gadget.ep_list, ep.ep_list) { | 557 | list_for_each_entry(ep, &udc->gadget.ep_list, ep.ep_list) |
560 | if (ep->desc) | 558 | proc_ep_show(s, ep); |
561 | proc_ep_show(s, ep); | ||
562 | } | ||
563 | } | 559 | } |
564 | 560 | ||
565 | spin_unlock_irqrestore(&udc->lock, flags); | 561 | spin_unlock_irqrestore(&udc->lock, flags); |
@@ -1453,7 +1449,6 @@ static void udc_reinit(struct lpc32xx_udc *udc) | |||
1453 | 1449 | ||
1454 | if (i != 0) | 1450 | if (i != 0) |
1455 | list_add_tail(&ep->ep.ep_list, &udc->gadget.ep_list); | 1451 | list_add_tail(&ep->ep.ep_list, &udc->gadget.ep_list); |
1456 | ep->desc = NULL; | ||
1457 | ep->ep.maxpacket = ep->maxpacket; | 1452 | ep->ep.maxpacket = ep->maxpacket; |
1458 | INIT_LIST_HEAD(&ep->queue); | 1453 | INIT_LIST_HEAD(&ep->queue); |
1459 | ep->req_pending = 0; | 1454 | ep->req_pending = 0; |
@@ -1515,7 +1510,7 @@ static void nuke(struct lpc32xx_ep *ep, int status) | |||
1515 | done(ep, req, status); | 1510 | done(ep, req, status); |
1516 | } | 1511 | } |
1517 | 1512 | ||
1518 | if (ep->desc && status == -ESHUTDOWN) { | 1513 | if (status == -ESHUTDOWN) { |
1519 | uda_disable_hwepint(ep->udc, ep->hwep_num); | 1514 | uda_disable_hwepint(ep->udc, ep->hwep_num); |
1520 | udc_disable_hwep(ep->udc, ep->hwep_num); | 1515 | udc_disable_hwep(ep->udc, ep->hwep_num); |
1521 | } | 1516 | } |
@@ -1658,9 +1653,6 @@ static int lpc32xx_ep_disable(struct usb_ep *_ep) | |||
1658 | 1653 | ||
1659 | nuke(ep, -ESHUTDOWN); | 1654 | nuke(ep, -ESHUTDOWN); |
1660 | 1655 | ||
1661 | /* restore the endpoint's pristine config */ | ||
1662 | ep->desc = NULL; | ||
1663 | |||
1664 | /* Clear all DMA statuses for this EP */ | 1656 | /* Clear all DMA statuses for this EP */ |
1665 | udc_ep_dma_disable(udc, ep->hwep_num); | 1657 | udc_ep_dma_disable(udc, ep->hwep_num); |
1666 | writel(1 << ep->hwep_num, USBD_EOTINTCLR(udc->udp_baseaddr)); | 1658 | writel(1 << ep->hwep_num, USBD_EOTINTCLR(udc->udp_baseaddr)); |
@@ -1696,7 +1688,7 @@ static int lpc32xx_ep_enable(struct usb_ep *_ep, | |||
1696 | unsigned long flags; | 1688 | unsigned long flags; |
1697 | 1689 | ||
1698 | /* Verify EP data */ | 1690 | /* Verify EP data */ |
1699 | if ((!_ep) || (!ep) || (!desc) || (ep->desc) || | 1691 | if ((!_ep) || (!ep) || (!desc) || |
1700 | (desc->bDescriptorType != USB_DT_ENDPOINT)) { | 1692 | (desc->bDescriptorType != USB_DT_ENDPOINT)) { |
1701 | dev_dbg(udc->dev, "bad ep or descriptor\n"); | 1693 | dev_dbg(udc->dev, "bad ep or descriptor\n"); |
1702 | return -EINVAL; | 1694 | return -EINVAL; |
@@ -1754,7 +1746,6 @@ static int lpc32xx_ep_enable(struct usb_ep *_ep, | |||
1754 | 1746 | ||
1755 | /* Initialize endpoint to match the selected descriptor */ | 1747 | /* Initialize endpoint to match the selected descriptor */ |
1756 | ep->is_in = (desc->bEndpointAddress & USB_DIR_IN) != 0; | 1748 | ep->is_in = (desc->bEndpointAddress & USB_DIR_IN) != 0; |
1757 | ep->desc = desc; | ||
1758 | ep->ep.maxpacket = maxpacket; | 1749 | ep->ep.maxpacket = maxpacket; |
1759 | 1750 | ||
1760 | /* Map hardware endpoint from base and direction */ | 1751 | /* Map hardware endpoint from base and direction */ |
@@ -1837,7 +1828,7 @@ static int lpc32xx_ep_queue(struct usb_ep *_ep, | |||
1837 | 1828 | ||
1838 | udc = ep->udc; | 1829 | udc = ep->udc; |
1839 | 1830 | ||
1840 | if (!_ep || (!ep->desc && ep->hwep_num_base != 0)) { | 1831 | if (!_ep) { |
1841 | dev_dbg(udc->dev, "invalid ep\n"); | 1832 | dev_dbg(udc->dev, "invalid ep\n"); |
1842 | return -EINVAL; | 1833 | return -EINVAL; |
1843 | } | 1834 | } |
@@ -1976,7 +1967,7 @@ static int lpc32xx_ep_set_halt(struct usb_ep *_ep, int value) | |||
1976 | struct lpc32xx_udc *udc = ep->udc; | 1967 | struct lpc32xx_udc *udc = ep->udc; |
1977 | unsigned long flags; | 1968 | unsigned long flags; |
1978 | 1969 | ||
1979 | if ((!ep) || (ep->desc == NULL) || (ep->hwep_num <= 1)) | 1970 | if ((!ep) || (ep->hwep_num <= 1)) |
1980 | return -EINVAL; | 1971 | return -EINVAL; |
1981 | 1972 | ||
1982 | /* Don't halt an IN EP */ | 1973 | /* Don't halt an IN EP */ |
@@ -2262,7 +2253,7 @@ static int udc_get_status(struct lpc32xx_udc *udc, u16 reqtype, u16 wIndex) | |||
2262 | case USB_RECIP_ENDPOINT: | 2253 | case USB_RECIP_ENDPOINT: |
2263 | tmp = wIndex & USB_ENDPOINT_NUMBER_MASK; | 2254 | tmp = wIndex & USB_ENDPOINT_NUMBER_MASK; |
2264 | ep = &udc->ep[tmp]; | 2255 | ep = &udc->ep[tmp]; |
2265 | if ((tmp == 0) || (tmp >= NUM_ENDPOINTS) || (tmp && !ep->desc)) | 2256 | if ((tmp == 0) || (tmp >= NUM_ENDPOINTS)) |
2266 | return -EOPNOTSUPP; | 2257 | return -EOPNOTSUPP; |
2267 | 2258 | ||
2268 | if (wIndex & USB_DIR_IN) { | 2259 | if (wIndex & USB_DIR_IN) { |
@@ -2599,9 +2590,8 @@ static int lpc32xx_pullup(struct usb_gadget *gadget, int is_on) | |||
2599 | return 0; | 2590 | return 0; |
2600 | } | 2591 | } |
2601 | 2592 | ||
2602 | static int lpc32xx_start(struct usb_gadget_driver *driver, | 2593 | static int lpc32xx_start(struct usb_gadget *, struct usb_gadget_driver *); |
2603 | int (*bind)(struct usb_gadget *)); | 2594 | static int lpc32xx_stop(struct usb_gadget *, struct usb_gadget_driver *); |
2604 | static int lpc32xx_stop(struct usb_gadget_driver *driver); | ||
2605 | 2595 | ||
2606 | static const struct usb_gadget_ops lpc32xx_udc_ops = { | 2596 | static const struct usb_gadget_ops lpc32xx_udc_ops = { |
2607 | .get_frame = lpc32xx_get_frame, | 2597 | .get_frame = lpc32xx_get_frame, |
@@ -2609,8 +2599,8 @@ static const struct usb_gadget_ops lpc32xx_udc_ops = { | |||
2609 | .set_selfpowered = lpc32xx_set_selfpowered, | 2599 | .set_selfpowered = lpc32xx_set_selfpowered, |
2610 | .vbus_session = lpc32xx_vbus_session, | 2600 | .vbus_session = lpc32xx_vbus_session, |
2611 | .pullup = lpc32xx_pullup, | 2601 | .pullup = lpc32xx_pullup, |
2612 | .start = lpc32xx_start, | 2602 | .udc_start = lpc32xx_start, |
2613 | .stop = lpc32xx_stop, | 2603 | .udc_stop = lpc32xx_stop, |
2614 | }; | 2604 | }; |
2615 | 2605 | ||
2616 | static void nop_release(struct device *dev) | 2606 | static void nop_release(struct device *dev) |
@@ -2618,10 +2608,9 @@ static void nop_release(struct device *dev) | |||
2618 | /* nothing to free */ | 2608 | /* nothing to free */ |
2619 | } | 2609 | } |
2620 | 2610 | ||
2621 | static struct lpc32xx_udc controller = { | 2611 | static const struct lpc32xx_udc controller_template = { |
2622 | .gadget = { | 2612 | .gadget = { |
2623 | .ops = &lpc32xx_udc_ops, | 2613 | .ops = &lpc32xx_udc_ops, |
2624 | .ep0 = &controller.ep[0].ep, | ||
2625 | .name = driver_name, | 2614 | .name = driver_name, |
2626 | .dev = { | 2615 | .dev = { |
2627 | .init_name = "gadget", | 2616 | .init_name = "gadget", |
@@ -2633,7 +2622,6 @@ static struct lpc32xx_udc controller = { | |||
2633 | .name = "ep0", | 2622 | .name = "ep0", |
2634 | .ops = &lpc32xx_ep_ops, | 2623 | .ops = &lpc32xx_ep_ops, |
2635 | }, | 2624 | }, |
2636 | .udc = &controller, | ||
2637 | .maxpacket = 64, | 2625 | .maxpacket = 64, |
2638 | .hwep_num_base = 0, | 2626 | .hwep_num_base = 0, |
2639 | .hwep_num = 0, /* Can be 0 or 1, has special handling */ | 2627 | .hwep_num = 0, /* Can be 0 or 1, has special handling */ |
@@ -2645,7 +2633,6 @@ static struct lpc32xx_udc controller = { | |||
2645 | .name = "ep1-int", | 2633 | .name = "ep1-int", |
2646 | .ops = &lpc32xx_ep_ops, | 2634 | .ops = &lpc32xx_ep_ops, |
2647 | }, | 2635 | }, |
2648 | .udc = &controller, | ||
2649 | .maxpacket = 64, | 2636 | .maxpacket = 64, |
2650 | .hwep_num_base = 2, | 2637 | .hwep_num_base = 2, |
2651 | .hwep_num = 0, /* 2 or 3, will be set later */ | 2638 | .hwep_num = 0, /* 2 or 3, will be set later */ |
@@ -2657,7 +2644,6 @@ static struct lpc32xx_udc controller = { | |||
2657 | .name = "ep2-bulk", | 2644 | .name = "ep2-bulk", |
2658 | .ops = &lpc32xx_ep_ops, | 2645 | .ops = &lpc32xx_ep_ops, |
2659 | }, | 2646 | }, |
2660 | .udc = &controller, | ||
2661 | .maxpacket = 64, | 2647 | .maxpacket = 64, |
2662 | .hwep_num_base = 4, | 2648 | .hwep_num_base = 4, |
2663 | .hwep_num = 0, /* 4 or 5, will be set later */ | 2649 | .hwep_num = 0, /* 4 or 5, will be set later */ |
@@ -2669,7 +2655,6 @@ static struct lpc32xx_udc controller = { | |||
2669 | .name = "ep3-iso", | 2655 | .name = "ep3-iso", |
2670 | .ops = &lpc32xx_ep_ops, | 2656 | .ops = &lpc32xx_ep_ops, |
2671 | }, | 2657 | }, |
2672 | .udc = &controller, | ||
2673 | .maxpacket = 1023, | 2658 | .maxpacket = 1023, |
2674 | .hwep_num_base = 6, | 2659 | .hwep_num_base = 6, |
2675 | .hwep_num = 0, /* 6 or 7, will be set later */ | 2660 | .hwep_num = 0, /* 6 or 7, will be set later */ |
@@ -2681,7 +2666,6 @@ static struct lpc32xx_udc controller = { | |||
2681 | .name = "ep4-int", | 2666 | .name = "ep4-int", |
2682 | .ops = &lpc32xx_ep_ops, | 2667 | .ops = &lpc32xx_ep_ops, |
2683 | }, | 2668 | }, |
2684 | .udc = &controller, | ||
2685 | .maxpacket = 64, | 2669 | .maxpacket = 64, |
2686 | .hwep_num_base = 8, | 2670 | .hwep_num_base = 8, |
2687 | .hwep_num = 0, /* 8 or 9, will be set later */ | 2671 | .hwep_num = 0, /* 8 or 9, will be set later */ |
@@ -2693,7 +2677,6 @@ static struct lpc32xx_udc controller = { | |||
2693 | .name = "ep5-bulk", | 2677 | .name = "ep5-bulk", |
2694 | .ops = &lpc32xx_ep_ops, | 2678 | .ops = &lpc32xx_ep_ops, |
2695 | }, | 2679 | }, |
2696 | .udc = &controller, | ||
2697 | .maxpacket = 64, | 2680 | .maxpacket = 64, |
2698 | .hwep_num_base = 10, | 2681 | .hwep_num_base = 10, |
2699 | .hwep_num = 0, /* 10 or 11, will be set later */ | 2682 | .hwep_num = 0, /* 10 or 11, will be set later */ |
@@ -2705,7 +2688,6 @@ static struct lpc32xx_udc controller = { | |||
2705 | .name = "ep6-iso", | 2688 | .name = "ep6-iso", |
2706 | .ops = &lpc32xx_ep_ops, | 2689 | .ops = &lpc32xx_ep_ops, |
2707 | }, | 2690 | }, |
2708 | .udc = &controller, | ||
2709 | .maxpacket = 1023, | 2691 | .maxpacket = 1023, |
2710 | .hwep_num_base = 12, | 2692 | .hwep_num_base = 12, |
2711 | .hwep_num = 0, /* 12 or 13, will be set later */ | 2693 | .hwep_num = 0, /* 12 or 13, will be set later */ |
@@ -2717,7 +2699,6 @@ static struct lpc32xx_udc controller = { | |||
2717 | .name = "ep7-int", | 2699 | .name = "ep7-int", |
2718 | .ops = &lpc32xx_ep_ops, | 2700 | .ops = &lpc32xx_ep_ops, |
2719 | }, | 2701 | }, |
2720 | .udc = &controller, | ||
2721 | .maxpacket = 64, | 2702 | .maxpacket = 64, |
2722 | .hwep_num_base = 14, | 2703 | .hwep_num_base = 14, |
2723 | .hwep_num = 0, | 2704 | .hwep_num = 0, |
@@ -2729,7 +2710,6 @@ static struct lpc32xx_udc controller = { | |||
2729 | .name = "ep8-bulk", | 2710 | .name = "ep8-bulk", |
2730 | .ops = &lpc32xx_ep_ops, | 2711 | .ops = &lpc32xx_ep_ops, |
2731 | }, | 2712 | }, |
2732 | .udc = &controller, | ||
2733 | .maxpacket = 64, | 2713 | .maxpacket = 64, |
2734 | .hwep_num_base = 16, | 2714 | .hwep_num_base = 16, |
2735 | .hwep_num = 0, | 2715 | .hwep_num = 0, |
@@ -2741,7 +2721,6 @@ static struct lpc32xx_udc controller = { | |||
2741 | .name = "ep9-iso", | 2721 | .name = "ep9-iso", |
2742 | .ops = &lpc32xx_ep_ops, | 2722 | .ops = &lpc32xx_ep_ops, |
2743 | }, | 2723 | }, |
2744 | .udc = &controller, | ||
2745 | .maxpacket = 1023, | 2724 | .maxpacket = 1023, |
2746 | .hwep_num_base = 18, | 2725 | .hwep_num_base = 18, |
2747 | .hwep_num = 0, | 2726 | .hwep_num = 0, |
@@ -2753,7 +2732,6 @@ static struct lpc32xx_udc controller = { | |||
2753 | .name = "ep10-int", | 2732 | .name = "ep10-int", |
2754 | .ops = &lpc32xx_ep_ops, | 2733 | .ops = &lpc32xx_ep_ops, |
2755 | }, | 2734 | }, |
2756 | .udc = &controller, | ||
2757 | .maxpacket = 64, | 2735 | .maxpacket = 64, |
2758 | .hwep_num_base = 20, | 2736 | .hwep_num_base = 20, |
2759 | .hwep_num = 0, | 2737 | .hwep_num = 0, |
@@ -2765,7 +2743,6 @@ static struct lpc32xx_udc controller = { | |||
2765 | .name = "ep11-bulk", | 2743 | .name = "ep11-bulk", |
2766 | .ops = &lpc32xx_ep_ops, | 2744 | .ops = &lpc32xx_ep_ops, |
2767 | }, | 2745 | }, |
2768 | .udc = &controller, | ||
2769 | .maxpacket = 64, | 2746 | .maxpacket = 64, |
2770 | .hwep_num_base = 22, | 2747 | .hwep_num_base = 22, |
2771 | .hwep_num = 0, | 2748 | .hwep_num = 0, |
@@ -2777,7 +2754,6 @@ static struct lpc32xx_udc controller = { | |||
2777 | .name = "ep12-iso", | 2754 | .name = "ep12-iso", |
2778 | .ops = &lpc32xx_ep_ops, | 2755 | .ops = &lpc32xx_ep_ops, |
2779 | }, | 2756 | }, |
2780 | .udc = &controller, | ||
2781 | .maxpacket = 1023, | 2757 | .maxpacket = 1023, |
2782 | .hwep_num_base = 24, | 2758 | .hwep_num_base = 24, |
2783 | .hwep_num = 0, | 2759 | .hwep_num = 0, |
@@ -2789,7 +2765,6 @@ static struct lpc32xx_udc controller = { | |||
2789 | .name = "ep13-int", | 2765 | .name = "ep13-int", |
2790 | .ops = &lpc32xx_ep_ops, | 2766 | .ops = &lpc32xx_ep_ops, |
2791 | }, | 2767 | }, |
2792 | .udc = &controller, | ||
2793 | .maxpacket = 64, | 2768 | .maxpacket = 64, |
2794 | .hwep_num_base = 26, | 2769 | .hwep_num_base = 26, |
2795 | .hwep_num = 0, | 2770 | .hwep_num = 0, |
@@ -2801,7 +2776,6 @@ static struct lpc32xx_udc controller = { | |||
2801 | .name = "ep14-bulk", | 2776 | .name = "ep14-bulk", |
2802 | .ops = &lpc32xx_ep_ops, | 2777 | .ops = &lpc32xx_ep_ops, |
2803 | }, | 2778 | }, |
2804 | .udc = &controller, | ||
2805 | .maxpacket = 64, | 2779 | .maxpacket = 64, |
2806 | .hwep_num_base = 28, | 2780 | .hwep_num_base = 28, |
2807 | .hwep_num = 0, | 2781 | .hwep_num = 0, |
@@ -2813,7 +2787,6 @@ static struct lpc32xx_udc controller = { | |||
2813 | .name = "ep15-bulk", | 2787 | .name = "ep15-bulk", |
2814 | .ops = &lpc32xx_ep_ops, | 2788 | .ops = &lpc32xx_ep_ops, |
2815 | }, | 2789 | }, |
2816 | .udc = &controller, | ||
2817 | .maxpacket = 1023, | 2790 | .maxpacket = 1023, |
2818 | .hwep_num_base = 30, | 2791 | .hwep_num_base = 30, |
2819 | .hwep_num = 0, | 2792 | .hwep_num = 0, |
@@ -2987,14 +2960,13 @@ static irqreturn_t lpc32xx_usb_vbus_irq(int irq, void *_udc) | |||
2987 | return IRQ_HANDLED; | 2960 | return IRQ_HANDLED; |
2988 | } | 2961 | } |
2989 | 2962 | ||
2990 | static int lpc32xx_start(struct usb_gadget_driver *driver, | 2963 | static int lpc32xx_start(struct usb_gadget *gadget, |
2991 | int (*bind)(struct usb_gadget *)) | 2964 | struct usb_gadget_driver *driver) |
2992 | { | 2965 | { |
2993 | struct lpc32xx_udc *udc = &controller; | 2966 | struct lpc32xx_udc *udc = to_udc(gadget); |
2994 | int retval, i; | 2967 | int i; |
2995 | 2968 | ||
2996 | if (!driver || driver->max_speed < USB_SPEED_FULL || | 2969 | if (!driver || driver->max_speed < USB_SPEED_FULL || !driver->setup) { |
2997 | !bind || !driver->setup) { | ||
2998 | dev_err(udc->dev, "bad parameter.\n"); | 2970 | dev_err(udc->dev, "bad parameter.\n"); |
2999 | return -EINVAL; | 2971 | return -EINVAL; |
3000 | } | 2972 | } |
@@ -3011,18 +2983,6 @@ static int lpc32xx_start(struct usb_gadget_driver *driver, | |||
3011 | udc->selfpowered = 1; | 2983 | udc->selfpowered = 1; |
3012 | udc->vbus = 0; | 2984 | udc->vbus = 0; |
3013 | 2985 | ||
3014 | retval = bind(&udc->gadget); | ||
3015 | if (retval) { | ||
3016 | dev_err(udc->dev, "bind() returned %d\n", retval); | ||
3017 | udc->enabled = 0; | ||
3018 | udc->selfpowered = 0; | ||
3019 | udc->driver = NULL; | ||
3020 | udc->gadget.dev.driver = NULL; | ||
3021 | return retval; | ||
3022 | } | ||
3023 | |||
3024 | dev_dbg(udc->dev, "bound to %s\n", driver->driver.name); | ||
3025 | |||
3026 | /* Force VBUS process once to check for cable insertion */ | 2986 | /* Force VBUS process once to check for cable insertion */ |
3027 | udc->last_vbus = udc->vbus = 0; | 2987 | udc->last_vbus = udc->vbus = 0; |
3028 | schedule_work(&udc->vbus_job); | 2988 | schedule_work(&udc->vbus_job); |
@@ -3034,22 +2994,19 @@ static int lpc32xx_start(struct usb_gadget_driver *driver, | |||
3034 | return 0; | 2994 | return 0; |
3035 | } | 2995 | } |
3036 | 2996 | ||
3037 | static int lpc32xx_stop(struct usb_gadget_driver *driver) | 2997 | static int lpc32xx_stop(struct usb_gadget *gadget, |
2998 | struct usb_gadget_driver *driver) | ||
3038 | { | 2999 | { |
3039 | int i; | 3000 | int i; |
3040 | struct lpc32xx_udc *udc = &controller; | 3001 | struct lpc32xx_udc *udc = to_udc(gadget); |
3041 | 3002 | ||
3042 | if (!driver || driver != udc->driver || !driver->unbind) | 3003 | if (!driver || driver != udc->driver) |
3043 | return -EINVAL; | 3004 | return -EINVAL; |
3044 | 3005 | ||
3045 | /* Disable USB pullup */ | ||
3046 | isp1301_pullup_enable(udc, 0, 1); | ||
3047 | |||
3048 | for (i = IRQ_USB_LP; i <= IRQ_USB_ATX; i++) | 3006 | for (i = IRQ_USB_LP; i <= IRQ_USB_ATX; i++) |
3049 | disable_irq(udc->udp_irq[i]); | 3007 | disable_irq(udc->udp_irq[i]); |
3050 | 3008 | ||
3051 | if (udc->clocked) { | 3009 | if (udc->clocked) { |
3052 | |||
3053 | spin_lock(&udc->lock); | 3010 | spin_lock(&udc->lock); |
3054 | stop_activity(udc); | 3011 | stop_activity(udc); |
3055 | spin_unlock(&udc->lock); | 3012 | spin_unlock(&udc->lock); |
@@ -3069,20 +3026,16 @@ static int lpc32xx_stop(struct usb_gadget_driver *driver) | |||
3069 | } | 3026 | } |
3070 | 3027 | ||
3071 | udc->enabled = 0; | 3028 | udc->enabled = 0; |
3072 | pullup(udc, 0); | ||
3073 | |||
3074 | driver->unbind(&udc->gadget); | ||
3075 | udc->gadget.dev.driver = NULL; | 3029 | udc->gadget.dev.driver = NULL; |
3076 | udc->driver = NULL; | 3030 | udc->driver = NULL; |
3077 | 3031 | ||
3078 | dev_dbg(udc->dev, "unbound from %s\n", driver->driver.name); | ||
3079 | return 0; | 3032 | return 0; |
3080 | } | 3033 | } |
3081 | 3034 | ||
3082 | static void lpc32xx_udc_shutdown(struct platform_device *dev) | 3035 | static void lpc32xx_udc_shutdown(struct platform_device *dev) |
3083 | { | 3036 | { |
3084 | /* Force disconnect on reboot */ | 3037 | /* Force disconnect on reboot */ |
3085 | struct lpc32xx_udc *udc = &controller; | 3038 | struct lpc32xx_udc *udc = platform_get_drvdata(dev); |
3086 | 3039 | ||
3087 | pullup(udc, 0); | 3040 | pullup(udc, 0); |
3088 | } | 3041 | } |
@@ -3120,12 +3073,21 @@ static u64 lpc32xx_usbd_dmamask = ~(u32) 0x7F; | |||
3120 | static int __init lpc32xx_udc_probe(struct platform_device *pdev) | 3073 | static int __init lpc32xx_udc_probe(struct platform_device *pdev) |
3121 | { | 3074 | { |
3122 | struct device *dev = &pdev->dev; | 3075 | struct device *dev = &pdev->dev; |
3123 | struct lpc32xx_udc *udc = &controller; | 3076 | struct lpc32xx_udc *udc; |
3124 | int retval, i; | 3077 | int retval, i; |
3125 | struct resource *res; | 3078 | struct resource *res; |
3126 | dma_addr_t dma_handle; | 3079 | dma_addr_t dma_handle; |
3127 | struct device_node *isp1301_node; | 3080 | struct device_node *isp1301_node; |
3128 | 3081 | ||
3082 | udc = kzalloc(sizeof(*udc), GFP_KERNEL); | ||
3083 | if (!udc) | ||
3084 | return -ENOMEM; | ||
3085 | |||
3086 | memcpy(udc, &controller_template, sizeof(*udc)); | ||
3087 | for (i = 0; i <= 15; i++) | ||
3088 | udc->ep[i].udc = udc; | ||
3089 | udc->gadget.ep0 = &udc->ep[0].ep; | ||
3090 | |||
3129 | /* init software state */ | 3091 | /* init software state */ |
3130 | udc->gadget.dev.parent = dev; | 3092 | udc->gadget.dev.parent = dev; |
3131 | udc->pdev = pdev; | 3093 | udc->pdev = pdev; |
@@ -3140,8 +3102,10 @@ static int __init lpc32xx_udc_probe(struct platform_device *pdev) | |||
3140 | } | 3102 | } |
3141 | 3103 | ||
3142 | udc->isp1301_i2c_client = isp1301_get_client(isp1301_node); | 3104 | udc->isp1301_i2c_client = isp1301_get_client(isp1301_node); |
3143 | if (!udc->isp1301_i2c_client) | 3105 | if (!udc->isp1301_i2c_client) { |
3144 | return -EPROBE_DEFER; | 3106 | retval = -EPROBE_DEFER; |
3107 | goto phy_fail; | ||
3108 | } | ||
3145 | 3109 | ||
3146 | dev_info(udc->dev, "ISP1301 I2C device at address 0x%x\n", | 3110 | dev_info(udc->dev, "ISP1301 I2C device at address 0x%x\n", |
3147 | udc->isp1301_i2c_client->addr); | 3111 | udc->isp1301_i2c_client->addr); |
@@ -3160,8 +3124,10 @@ static int __init lpc32xx_udc_probe(struct platform_device *pdev) | |||
3160 | * IORESOURCE_IRQ, USB transceiver interrupt number | 3124 | * IORESOURCE_IRQ, USB transceiver interrupt number |
3161 | */ | 3125 | */ |
3162 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 3126 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
3163 | if (!res) | 3127 | if (!res) { |
3164 | return -ENXIO; | 3128 | retval = -ENXIO; |
3129 | goto resource_fail; | ||
3130 | } | ||
3165 | 3131 | ||
3166 | spin_lock_init(&udc->lock); | 3132 | spin_lock_init(&udc->lock); |
3167 | 3133 | ||
@@ -3171,7 +3137,8 @@ static int __init lpc32xx_udc_probe(struct platform_device *pdev) | |||
3171 | if (udc->udp_irq[i] < 0) { | 3137 | if (udc->udp_irq[i] < 0) { |
3172 | dev_err(udc->dev, | 3138 | dev_err(udc->dev, |
3173 | "irq resource %d not available!\n", i); | 3139 | "irq resource %d not available!\n", i); |
3174 | return udc->udp_irq[i]; | 3140 | retval = udc->udp_irq[i]; |
3141 | goto irq_fail; | ||
3175 | } | 3142 | } |
3176 | } | 3143 | } |
3177 | 3144 | ||
@@ -3179,7 +3146,8 @@ static int __init lpc32xx_udc_probe(struct platform_device *pdev) | |||
3179 | udc->io_p_size = resource_size(res); | 3146 | udc->io_p_size = resource_size(res); |
3180 | if (!request_mem_region(udc->io_p_start, udc->io_p_size, driver_name)) { | 3147 | if (!request_mem_region(udc->io_p_start, udc->io_p_size, driver_name)) { |
3181 | dev_err(udc->dev, "someone's using UDC memory\n"); | 3148 | dev_err(udc->dev, "someone's using UDC memory\n"); |
3182 | return -EBUSY; | 3149 | retval = -EBUSY; |
3150 | goto request_mem_region_fail; | ||
3183 | } | 3151 | } |
3184 | 3152 | ||
3185 | udc->udp_baseaddr = ioremap(udc->io_p_start, udc->io_p_size); | 3153 | udc->udp_baseaddr = ioremap(udc->io_p_start, udc->io_p_size); |
@@ -3208,7 +3176,7 @@ static int __init lpc32xx_udc_probe(struct platform_device *pdev) | |||
3208 | udc->usb_otg_clk = clk_get(&pdev->dev, "ck_usb_otg"); | 3176 | udc->usb_otg_clk = clk_get(&pdev->dev, "ck_usb_otg"); |
3209 | if (IS_ERR(udc->usb_otg_clk)) { | 3177 | if (IS_ERR(udc->usb_otg_clk)) { |
3210 | dev_err(udc->dev, "failed to acquire USB otg clock\n"); | 3178 | dev_err(udc->dev, "failed to acquire USB otg clock\n"); |
3211 | retval = PTR_ERR(udc->usb_slv_clk); | 3179 | retval = PTR_ERR(udc->usb_otg_clk); |
3212 | goto usb_otg_clk_get_fail; | 3180 | goto usb_otg_clk_get_fail; |
3213 | } | 3181 | } |
3214 | 3182 | ||
@@ -3376,7 +3344,11 @@ pll_get_fail: | |||
3376 | io_map_fail: | 3344 | io_map_fail: |
3377 | release_mem_region(udc->io_p_start, udc->io_p_size); | 3345 | release_mem_region(udc->io_p_start, udc->io_p_size); |
3378 | dev_err(udc->dev, "%s probe failed, %d\n", driver_name, retval); | 3346 | dev_err(udc->dev, "%s probe failed, %d\n", driver_name, retval); |
3379 | 3347 | request_mem_region_fail: | |
3348 | irq_fail: | ||
3349 | resource_fail: | ||
3350 | phy_fail: | ||
3351 | kfree(udc); | ||
3380 | return retval; | 3352 | return retval; |
3381 | } | 3353 | } |
3382 | 3354 | ||
@@ -3414,6 +3386,7 @@ static int __devexit lpc32xx_udc_remove(struct platform_device *pdev) | |||
3414 | clk_put(udc->usb_pll_clk); | 3386 | clk_put(udc->usb_pll_clk); |
3415 | iounmap(udc->udp_baseaddr); | 3387 | iounmap(udc->udp_baseaddr); |
3416 | release_mem_region(udc->io_p_start, udc->io_p_size); | 3388 | release_mem_region(udc->io_p_start, udc->io_p_size); |
3389 | kfree(udc); | ||
3417 | 3390 | ||
3418 | return 0; | 3391 | return 0; |
3419 | } | 3392 | } |
diff --git a/drivers/usb/gadget/m66592-udc.c b/drivers/usb/gadget/m66592-udc.c index cf6bd626f3fe..b6401f1b56ce 100644 --- a/drivers/usb/gadget/m66592-udc.c +++ b/drivers/usb/gadget/m66592-udc.c | |||
@@ -1466,7 +1466,7 @@ static struct usb_ep_ops m66592_ep_ops = { | |||
1466 | static struct m66592 *the_controller; | 1466 | static struct m66592 *the_controller; |
1467 | 1467 | ||
1468 | static int m66592_start(struct usb_gadget_driver *driver, | 1468 | static int m66592_start(struct usb_gadget_driver *driver, |
1469 | int (*bind)(struct usb_gadget *)) | 1469 | int (*bind)(struct usb_gadget *, struct usb_gadget_driver *)) |
1470 | { | 1470 | { |
1471 | struct m66592 *m66592 = the_controller; | 1471 | struct m66592 *m66592 = the_controller; |
1472 | int retval; | 1472 | int retval; |
@@ -1492,7 +1492,7 @@ static int m66592_start(struct usb_gadget_driver *driver, | |||
1492 | goto error; | 1492 | goto error; |
1493 | } | 1493 | } |
1494 | 1494 | ||
1495 | retval = bind(&m66592->gadget); | 1495 | retval = bind(&m66592->gadget, driver); |
1496 | if (retval) { | 1496 | if (retval) { |
1497 | pr_err("bind to driver error (%d)\n", retval); | 1497 | pr_err("bind to driver error (%d)\n", retval); |
1498 | device_del(&m66592->gadget.dev); | 1498 | device_del(&m66592->gadget.dev); |
diff --git a/drivers/usb/gadget/mass_storage.c b/drivers/usb/gadget/mass_storage.c index 1f376eba31f6..080e577773d5 100644 --- a/drivers/usb/gadget/mass_storage.c +++ b/drivers/usb/gadget/mass_storage.c | |||
@@ -29,9 +29,8 @@ | |||
29 | 29 | ||
30 | 30 | ||
31 | #include <linux/kernel.h> | 31 | #include <linux/kernel.h> |
32 | #include <linux/utsname.h> | ||
33 | #include <linux/usb/ch9.h> | 32 | #include <linux/usb/ch9.h> |
34 | 33 | #include <linux/module.h> | |
35 | 34 | ||
36 | /*-------------------------------------------------------------------------*/ | 35 | /*-------------------------------------------------------------------------*/ |
37 | 36 | ||
@@ -47,14 +46,10 @@ | |||
47 | * the runtime footprint, and giving us at least some parts of what | 46 | * the runtime footprint, and giving us at least some parts of what |
48 | * a "gcc --combine ... part1.c part2.c part3.c ... " build would. | 47 | * a "gcc --combine ... part1.c part2.c part3.c ... " build would. |
49 | */ | 48 | */ |
50 | |||
51 | #include "composite.c" | ||
52 | #include "usbstring.c" | ||
53 | #include "config.c" | ||
54 | #include "epautoconf.c" | ||
55 | #include "f_mass_storage.c" | 49 | #include "f_mass_storage.c" |
56 | 50 | ||
57 | /*-------------------------------------------------------------------------*/ | 51 | /*-------------------------------------------------------------------------*/ |
52 | USB_GADGET_COMPOSITE_OPTIONS(); | ||
58 | 53 | ||
59 | static struct usb_device_descriptor msg_device_desc = { | 54 | static struct usb_device_descriptor msg_device_desc = { |
60 | .bLength = sizeof msg_device_desc, | 55 | .bLength = sizeof msg_device_desc, |
@@ -85,6 +80,22 @@ static const struct usb_descriptor_header *otg_desc[] = { | |||
85 | NULL, | 80 | NULL, |
86 | }; | 81 | }; |
87 | 82 | ||
83 | static struct usb_string strings_dev[] = { | ||
84 | [USB_GADGET_MANUFACTURER_IDX].s = "", | ||
85 | [USB_GADGET_PRODUCT_IDX].s = DRIVER_DESC, | ||
86 | [USB_GADGET_SERIAL_IDX].s = "", | ||
87 | { } /* end of list */ | ||
88 | }; | ||
89 | |||
90 | static struct usb_gadget_strings stringtab_dev = { | ||
91 | .language = 0x0409, /* en-us */ | ||
92 | .strings = strings_dev, | ||
93 | }; | ||
94 | |||
95 | static struct usb_gadget_strings *dev_strings[] = { | ||
96 | &stringtab_dev, | ||
97 | NULL, | ||
98 | }; | ||
88 | 99 | ||
89 | /****************************** Configurations ******************************/ | 100 | /****************************** Configurations ******************************/ |
90 | 101 | ||
@@ -143,10 +154,15 @@ static int __init msg_bind(struct usb_composite_dev *cdev) | |||
143 | { | 154 | { |
144 | int status; | 155 | int status; |
145 | 156 | ||
146 | status = usb_add_config(cdev, &msg_config_driver, msg_do_config); | 157 | status = usb_string_ids_tab(cdev, strings_dev); |
147 | if (status < 0) | 158 | if (status < 0) |
148 | return status; | 159 | return status; |
160 | msg_device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; | ||
149 | 161 | ||
162 | status = usb_add_config(cdev, &msg_config_driver, msg_do_config); | ||
163 | if (status < 0) | ||
164 | return status; | ||
165 | usb_composite_overwrite_options(cdev, &coverwrite); | ||
150 | dev_info(&cdev->gadget->dev, | 166 | dev_info(&cdev->gadget->dev, |
151 | DRIVER_DESC ", version: " DRIVER_VERSION "\n"); | 167 | DRIVER_DESC ", version: " DRIVER_VERSION "\n"); |
152 | set_bit(0, &msg_registered); | 168 | set_bit(0, &msg_registered); |
@@ -156,12 +172,13 @@ static int __init msg_bind(struct usb_composite_dev *cdev) | |||
156 | 172 | ||
157 | /****************************** Some noise ******************************/ | 173 | /****************************** Some noise ******************************/ |
158 | 174 | ||
159 | static struct usb_composite_driver msg_driver = { | 175 | static __refdata struct usb_composite_driver msg_driver = { |
160 | .name = "g_mass_storage", | 176 | .name = "g_mass_storage", |
161 | .dev = &msg_device_desc, | 177 | .dev = &msg_device_desc, |
162 | .iProduct = DRIVER_DESC, | ||
163 | .max_speed = USB_SPEED_SUPER, | 178 | .max_speed = USB_SPEED_SUPER, |
164 | .needs_serial = 1, | 179 | .needs_serial = 1, |
180 | .strings = dev_strings, | ||
181 | .bind = msg_bind, | ||
165 | }; | 182 | }; |
166 | 183 | ||
167 | MODULE_DESCRIPTION(DRIVER_DESC); | 184 | MODULE_DESCRIPTION(DRIVER_DESC); |
@@ -170,7 +187,7 @@ MODULE_LICENSE("GPL"); | |||
170 | 187 | ||
171 | static int __init msg_init(void) | 188 | static int __init msg_init(void) |
172 | { | 189 | { |
173 | return usb_composite_probe(&msg_driver, msg_bind); | 190 | return usb_composite_probe(&msg_driver); |
174 | } | 191 | } |
175 | module_init(msg_init); | 192 | module_init(msg_init); |
176 | 193 | ||
diff --git a/drivers/usb/gadget/multi.c b/drivers/usb/gadget/multi.c index c37fb33a3d1b..88472bf7dbb7 100644 --- a/drivers/usb/gadget/multi.c +++ b/drivers/usb/gadget/multi.c | |||
@@ -14,10 +14,8 @@ | |||
14 | 14 | ||
15 | 15 | ||
16 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
17 | #include <linux/utsname.h> | ||
18 | #include <linux/module.h> | 17 | #include <linux/module.h> |
19 | 18 | ||
20 | |||
21 | #if defined USB_ETH_RNDIS | 19 | #if defined USB_ETH_RNDIS |
22 | # undef USB_ETH_RNDIS | 20 | # undef USB_ETH_RNDIS |
23 | #endif | 21 | #endif |
@@ -42,12 +40,6 @@ MODULE_LICENSE("GPL"); | |||
42 | * the runtime footprint, and giving us at least some parts of what | 40 | * the runtime footprint, and giving us at least some parts of what |
43 | * a "gcc --combine ... part1.c part2.c part3.c ... " build would. | 41 | * a "gcc --combine ... part1.c part2.c part3.c ... " build would. |
44 | */ | 42 | */ |
45 | |||
46 | #include "composite.c" | ||
47 | #include "usbstring.c" | ||
48 | #include "config.c" | ||
49 | #include "epautoconf.c" | ||
50 | |||
51 | #include "f_mass_storage.c" | 43 | #include "f_mass_storage.c" |
52 | 44 | ||
53 | #include "u_serial.c" | 45 | #include "u_serial.c" |
@@ -61,7 +53,7 @@ MODULE_LICENSE("GPL"); | |||
61 | #endif | 53 | #endif |
62 | #include "u_ether.c" | 54 | #include "u_ether.c" |
63 | 55 | ||
64 | 56 | USB_GADGET_COMPOSITE_OPTIONS(); | |
65 | 57 | ||
66 | /***************************** Device Descriptor ****************************/ | 58 | /***************************** Device Descriptor ****************************/ |
67 | 59 | ||
@@ -112,21 +104,16 @@ static const struct usb_descriptor_header *otg_desc[] = { | |||
112 | 104 | ||
113 | 105 | ||
114 | enum { | 106 | enum { |
115 | #ifdef CONFIG_USB_G_MULTI_RNDIS | 107 | MULTI_STRING_RNDIS_CONFIG_IDX = USB_GADGET_FIRST_AVAIL_IDX, |
116 | MULTI_STRING_RNDIS_CONFIG_IDX, | ||
117 | #endif | ||
118 | #ifdef CONFIG_USB_G_MULTI_CDC | ||
119 | MULTI_STRING_CDC_CONFIG_IDX, | 108 | MULTI_STRING_CDC_CONFIG_IDX, |
120 | #endif | ||
121 | }; | 109 | }; |
122 | 110 | ||
123 | static struct usb_string strings_dev[] = { | 111 | static struct usb_string strings_dev[] = { |
124 | #ifdef CONFIG_USB_G_MULTI_RNDIS | 112 | [USB_GADGET_MANUFACTURER_IDX].s = "", |
113 | [USB_GADGET_PRODUCT_IDX].s = DRIVER_DESC, | ||
114 | [USB_GADGET_SERIAL_IDX].s = "", | ||
125 | [MULTI_STRING_RNDIS_CONFIG_IDX].s = "Multifunction with RNDIS", | 115 | [MULTI_STRING_RNDIS_CONFIG_IDX].s = "Multifunction with RNDIS", |
126 | #endif | ||
127 | #ifdef CONFIG_USB_G_MULTI_CDC | ||
128 | [MULTI_STRING_CDC_CONFIG_IDX].s = "Multifunction with CDC ECM", | 116 | [MULTI_STRING_CDC_CONFIG_IDX].s = "Multifunction with CDC ECM", |
129 | #endif | ||
130 | { } /* end of list */ | 117 | { } /* end of list */ |
131 | }; | 118 | }; |
132 | 119 | ||
@@ -260,7 +247,7 @@ static int cdc_config_register(struct usb_composite_dev *cdev) | |||
260 | static int __ref multi_bind(struct usb_composite_dev *cdev) | 247 | static int __ref multi_bind(struct usb_composite_dev *cdev) |
261 | { | 248 | { |
262 | struct usb_gadget *gadget = cdev->gadget; | 249 | struct usb_gadget *gadget = cdev->gadget; |
263 | int status, gcnum; | 250 | int status; |
264 | 251 | ||
265 | if (!can_support_ecm(cdev->gadget)) { | 252 | if (!can_support_ecm(cdev->gadget)) { |
266 | dev_err(&gadget->dev, "controller '%s' not usable\n", | 253 | dev_err(&gadget->dev, "controller '%s' not usable\n", |
@@ -288,19 +275,11 @@ static int __ref multi_bind(struct usb_composite_dev *cdev) | |||
288 | } | 275 | } |
289 | } | 276 | } |
290 | 277 | ||
291 | /* set bcdDevice */ | ||
292 | gcnum = usb_gadget_controller_number(gadget); | ||
293 | if (gcnum >= 0) { | ||
294 | device_desc.bcdDevice = cpu_to_le16(0x0300 | gcnum); | ||
295 | } else { | ||
296 | WARNING(cdev, "controller '%s' not recognized\n", gadget->name); | ||
297 | device_desc.bcdDevice = cpu_to_le16(0x0300 | 0x0099); | ||
298 | } | ||
299 | |||
300 | /* allocate string IDs */ | 278 | /* allocate string IDs */ |
301 | status = usb_string_ids_tab(cdev, strings_dev); | 279 | status = usb_string_ids_tab(cdev, strings_dev); |
302 | if (unlikely(status < 0)) | 280 | if (unlikely(status < 0)) |
303 | goto fail2; | 281 | goto fail2; |
282 | device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; | ||
304 | 283 | ||
305 | /* register configurations */ | 284 | /* register configurations */ |
306 | status = rndis_config_register(cdev); | 285 | status = rndis_config_register(cdev); |
@@ -310,6 +289,7 @@ static int __ref multi_bind(struct usb_composite_dev *cdev) | |||
310 | status = cdc_config_register(cdev); | 289 | status = cdc_config_register(cdev); |
311 | if (unlikely(status < 0)) | 290 | if (unlikely(status < 0)) |
312 | goto fail2; | 291 | goto fail2; |
292 | usb_composite_overwrite_options(cdev, &coverwrite); | ||
313 | 293 | ||
314 | /* we're done */ | 294 | /* we're done */ |
315 | dev_info(&gadget->dev, DRIVER_DESC "\n"); | 295 | dev_info(&gadget->dev, DRIVER_DESC "\n"); |
@@ -338,20 +318,20 @@ static int __exit multi_unbind(struct usb_composite_dev *cdev) | |||
338 | /****************************** Some noise ******************************/ | 318 | /****************************** Some noise ******************************/ |
339 | 319 | ||
340 | 320 | ||
341 | static struct usb_composite_driver multi_driver = { | 321 | static __refdata struct usb_composite_driver multi_driver = { |
342 | .name = "g_multi", | 322 | .name = "g_multi", |
343 | .dev = &device_desc, | 323 | .dev = &device_desc, |
344 | .strings = dev_strings, | 324 | .strings = dev_strings, |
345 | .max_speed = USB_SPEED_HIGH, | 325 | .max_speed = USB_SPEED_HIGH, |
326 | .bind = multi_bind, | ||
346 | .unbind = __exit_p(multi_unbind), | 327 | .unbind = __exit_p(multi_unbind), |
347 | .iProduct = DRIVER_DESC, | ||
348 | .needs_serial = 1, | 328 | .needs_serial = 1, |
349 | }; | 329 | }; |
350 | 330 | ||
351 | 331 | ||
352 | static int __init multi_init(void) | 332 | static int __init multi_init(void) |
353 | { | 333 | { |
354 | return usb_composite_probe(&multi_driver, multi_bind); | 334 | return usb_composite_probe(&multi_driver); |
355 | } | 335 | } |
356 | module_init(multi_init); | 336 | module_init(multi_init); |
357 | 337 | ||
diff --git a/drivers/usb/gadget/mv_udc_core.c b/drivers/usb/gadget/mv_udc_core.c index 75db2c306cea..ea45224f78c8 100644 --- a/drivers/usb/gadget/mv_udc_core.c +++ b/drivers/usb/gadget/mv_udc_core.c | |||
@@ -51,9 +51,8 @@ | |||
51 | #define EPSTATUS_TIMEOUT 10000 | 51 | #define EPSTATUS_TIMEOUT 10000 |
52 | #define PRIME_TIMEOUT 10000 | 52 | #define PRIME_TIMEOUT 10000 |
53 | #define READSAFE_TIMEOUT 1000 | 53 | #define READSAFE_TIMEOUT 1000 |
54 | #define DTD_TIMEOUT 1000 | ||
55 | 54 | ||
56 | #define LOOPS_USEC_SHIFT 4 | 55 | #define LOOPS_USEC_SHIFT 1 |
57 | #define LOOPS_USEC (1 << LOOPS_USEC_SHIFT) | 56 | #define LOOPS_USEC (1 << LOOPS_USEC_SHIFT) |
58 | #define LOOPS(timeout) ((timeout) >> LOOPS_USEC_SHIFT) | 57 | #define LOOPS(timeout) ((timeout) >> LOOPS_USEC_SHIFT) |
59 | 58 | ||
@@ -64,7 +63,6 @@ static const char driver_desc[] = DRIVER_DESC; | |||
64 | 63 | ||
65 | /* controller device global variable */ | 64 | /* controller device global variable */ |
66 | static struct mv_udc *the_controller; | 65 | static struct mv_udc *the_controller; |
67 | int mv_usb_otgsc; | ||
68 | 66 | ||
69 | static void nuke(struct mv_ep *ep, int status); | 67 | static void nuke(struct mv_ep *ep, int status); |
70 | static void stop_activity(struct mv_udc *udc, struct usb_gadget_driver *driver); | 68 | static void stop_activity(struct mv_udc *udc, struct usb_gadget_driver *driver); |
@@ -357,17 +355,24 @@ done: | |||
357 | return retval; | 355 | return retval; |
358 | } | 356 | } |
359 | 357 | ||
360 | |||
361 | static struct mv_dtd *build_dtd(struct mv_req *req, unsigned *length, | 358 | static struct mv_dtd *build_dtd(struct mv_req *req, unsigned *length, |
362 | dma_addr_t *dma, int *is_last) | 359 | dma_addr_t *dma, int *is_last) |
363 | { | 360 | { |
364 | u32 temp; | ||
365 | struct mv_dtd *dtd; | 361 | struct mv_dtd *dtd; |
366 | struct mv_udc *udc; | 362 | struct mv_udc *udc; |
363 | struct mv_dqh *dqh; | ||
364 | u32 temp, mult = 0; | ||
367 | 365 | ||
368 | /* how big will this transfer be? */ | 366 | /* how big will this transfer be? */ |
369 | *length = min(req->req.length - req->req.actual, | 367 | if (usb_endpoint_xfer_isoc(req->ep->ep.desc)) { |
370 | (unsigned)EP_MAX_LENGTH_TRANSFER); | 368 | dqh = req->ep->dqh; |
369 | mult = (dqh->max_packet_length >> EP_QUEUE_HEAD_MULT_POS) | ||
370 | & 0x3; | ||
371 | *length = min(req->req.length - req->req.actual, | ||
372 | (unsigned)(mult * req->ep->ep.maxpacket)); | ||
373 | } else | ||
374 | *length = min(req->req.length - req->req.actual, | ||
375 | (unsigned)EP_MAX_LENGTH_TRANSFER); | ||
371 | 376 | ||
372 | udc = req->ep->udc; | 377 | udc = req->ep->udc; |
373 | 378 | ||
@@ -375,7 +380,7 @@ static struct mv_dtd *build_dtd(struct mv_req *req, unsigned *length, | |||
375 | * Be careful that no _GFP_HIGHMEM is set, | 380 | * Be careful that no _GFP_HIGHMEM is set, |
376 | * or we can not use dma_to_virt | 381 | * or we can not use dma_to_virt |
377 | */ | 382 | */ |
378 | dtd = dma_pool_alloc(udc->dtd_pool, GFP_KERNEL, dma); | 383 | dtd = dma_pool_alloc(udc->dtd_pool, GFP_ATOMIC, dma); |
379 | if (dtd == NULL) | 384 | if (dtd == NULL) |
380 | return dtd; | 385 | return dtd; |
381 | 386 | ||
@@ -409,6 +414,8 @@ static struct mv_dtd *build_dtd(struct mv_req *req, unsigned *length, | |||
409 | if (*is_last && !req->req.no_interrupt) | 414 | if (*is_last && !req->req.no_interrupt) |
410 | temp |= DTD_IOC; | 415 | temp |= DTD_IOC; |
411 | 416 | ||
417 | temp |= mult << 10; | ||
418 | |||
412 | dtd->size_ioc_sts = temp; | 419 | dtd->size_ioc_sts = temp; |
413 | 420 | ||
414 | mb(); | 421 | mb(); |
@@ -708,6 +715,7 @@ mv_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags) | |||
708 | struct mv_req *req = container_of(_req, struct mv_req, req); | 715 | struct mv_req *req = container_of(_req, struct mv_req, req); |
709 | struct mv_udc *udc = ep->udc; | 716 | struct mv_udc *udc = ep->udc; |
710 | unsigned long flags; | 717 | unsigned long flags; |
718 | int retval; | ||
711 | 719 | ||
712 | /* catch various bogus parameters */ | 720 | /* catch various bogus parameters */ |
713 | if (!_req || !req->req.complete || !req->req.buf | 721 | if (!_req || !req->req.complete || !req->req.buf |
@@ -719,10 +727,6 @@ mv_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags) | |||
719 | dev_err(&udc->dev->dev, "%s, bad ep", __func__); | 727 | dev_err(&udc->dev->dev, "%s, bad ep", __func__); |
720 | return -EINVAL; | 728 | return -EINVAL; |
721 | } | 729 | } |
722 | if (ep->ep.desc->bmAttributes == USB_ENDPOINT_XFER_ISOC) { | ||
723 | if (req->req.length > ep->ep.maxpacket) | ||
724 | return -EMSGSIZE; | ||
725 | } | ||
726 | 730 | ||
727 | udc = ep->udc; | 731 | udc = ep->udc; |
728 | if (!udc->driver || udc->gadget.speed == USB_SPEED_UNKNOWN) | 732 | if (!udc->driver || udc->gadget.speed == USB_SPEED_UNKNOWN) |
@@ -755,15 +759,17 @@ mv_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags) | |||
755 | 759 | ||
756 | /* build dtds and push them to device queue */ | 760 | /* build dtds and push them to device queue */ |
757 | if (!req_to_dtd(req)) { | 761 | if (!req_to_dtd(req)) { |
758 | int retval; | ||
759 | retval = queue_dtd(ep, req); | 762 | retval = queue_dtd(ep, req); |
760 | if (retval) { | 763 | if (retval) { |
761 | spin_unlock_irqrestore(&udc->lock, flags); | 764 | spin_unlock_irqrestore(&udc->lock, flags); |
762 | return retval; | 765 | dev_err(&udc->dev->dev, "Failed to queue dtd\n"); |
766 | goto err_unmap_dma; | ||
763 | } | 767 | } |
764 | } else { | 768 | } else { |
765 | spin_unlock_irqrestore(&udc->lock, flags); | 769 | spin_unlock_irqrestore(&udc->lock, flags); |
766 | return -ENOMEM; | 770 | dev_err(&udc->dev->dev, "Failed to dma_pool_alloc\n"); |
771 | retval = -ENOMEM; | ||
772 | goto err_unmap_dma; | ||
767 | } | 773 | } |
768 | 774 | ||
769 | /* Update ep0 state */ | 775 | /* Update ep0 state */ |
@@ -775,6 +781,22 @@ mv_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags) | |||
775 | spin_unlock_irqrestore(&udc->lock, flags); | 781 | spin_unlock_irqrestore(&udc->lock, flags); |
776 | 782 | ||
777 | return 0; | 783 | return 0; |
784 | |||
785 | err_unmap_dma: | ||
786 | if (req->mapped) { | ||
787 | dma_unmap_single(ep->udc->gadget.dev.parent, | ||
788 | req->req.dma, req->req.length, | ||
789 | ((ep_dir(ep) == EP_DIR_IN) ? | ||
790 | DMA_TO_DEVICE : DMA_FROM_DEVICE)); | ||
791 | req->req.dma = DMA_ADDR_INVALID; | ||
792 | req->mapped = 0; | ||
793 | } else | ||
794 | dma_sync_single_for_cpu(ep->udc->gadget.dev.parent, | ||
795 | req->req.dma, req->req.length, | ||
796 | ((ep_dir(ep) == EP_DIR_IN) ? | ||
797 | DMA_TO_DEVICE : DMA_FROM_DEVICE)); | ||
798 | |||
799 | return retval; | ||
778 | } | 800 | } |
779 | 801 | ||
780 | static void mv_prime_ep(struct mv_ep *ep, struct mv_req *req) | 802 | static void mv_prime_ep(struct mv_ep *ep, struct mv_req *req) |
@@ -1065,7 +1087,7 @@ static int udc_reset(struct mv_udc *udc) | |||
1065 | tmp |= USBMODE_CTRL_MODE_DEVICE; | 1087 | tmp |= USBMODE_CTRL_MODE_DEVICE; |
1066 | 1088 | ||
1067 | /* turn setup lockout off, require setup tripwire in usbcmd */ | 1089 | /* turn setup lockout off, require setup tripwire in usbcmd */ |
1068 | tmp |= USBMODE_SETUP_LOCK_OFF | USBMODE_STREAM_DISABLE; | 1090 | tmp |= USBMODE_SETUP_LOCK_OFF; |
1069 | 1091 | ||
1070 | writel(tmp, &udc->op_regs->usbmode); | 1092 | writel(tmp, &udc->op_regs->usbmode); |
1071 | 1093 | ||
@@ -1199,12 +1221,16 @@ static int mv_udc_vbus_session(struct usb_gadget *gadget, int is_active) | |||
1199 | udc_start(udc); | 1221 | udc_start(udc); |
1200 | } | 1222 | } |
1201 | } else if (udc->driver && udc->softconnect) { | 1223 | } else if (udc->driver && udc->softconnect) { |
1224 | if (!udc->active) | ||
1225 | goto out; | ||
1226 | |||
1202 | /* stop all the transfer in queue*/ | 1227 | /* stop all the transfer in queue*/ |
1203 | stop_activity(udc, udc->driver); | 1228 | stop_activity(udc, udc->driver); |
1204 | udc_stop(udc); | 1229 | udc_stop(udc); |
1205 | mv_udc_disable(udc); | 1230 | mv_udc_disable(udc); |
1206 | } | 1231 | } |
1207 | 1232 | ||
1233 | out: | ||
1208 | spin_unlock_irqrestore(&udc->lock, flags); | 1234 | spin_unlock_irqrestore(&udc->lock, flags); |
1209 | return retval; | 1235 | return retval; |
1210 | } | 1236 | } |
@@ -1243,7 +1269,7 @@ static int mv_udc_pullup(struct usb_gadget *gadget, int is_on) | |||
1243 | } | 1269 | } |
1244 | 1270 | ||
1245 | static int mv_udc_start(struct usb_gadget_driver *driver, | 1271 | static int mv_udc_start(struct usb_gadget_driver *driver, |
1246 | int (*bind)(struct usb_gadget *)); | 1272 | int (*bind)(struct usb_gadget *, struct usb_gadget_driver *)); |
1247 | static int mv_udc_stop(struct usb_gadget_driver *driver); | 1273 | static int mv_udc_stop(struct usb_gadget_driver *driver); |
1248 | /* device controller usb_gadget_ops structure */ | 1274 | /* device controller usb_gadget_ops structure */ |
1249 | static const struct usb_gadget_ops mv_ops = { | 1275 | static const struct usb_gadget_ops mv_ops = { |
@@ -1348,7 +1374,7 @@ static void stop_activity(struct mv_udc *udc, struct usb_gadget_driver *driver) | |||
1348 | } | 1374 | } |
1349 | 1375 | ||
1350 | static int mv_udc_start(struct usb_gadget_driver *driver, | 1376 | static int mv_udc_start(struct usb_gadget_driver *driver, |
1351 | int (*bind)(struct usb_gadget *)) | 1377 | int (*bind)(struct usb_gadget *, struct usb_gadget_driver *)) |
1352 | { | 1378 | { |
1353 | struct mv_udc *udc = the_controller; | 1379 | struct mv_udc *udc = the_controller; |
1354 | int retval = 0; | 1380 | int retval = 0; |
@@ -1373,7 +1399,7 @@ static int mv_udc_start(struct usb_gadget_driver *driver, | |||
1373 | 1399 | ||
1374 | spin_unlock_irqrestore(&udc->lock, flags); | 1400 | spin_unlock_irqrestore(&udc->lock, flags); |
1375 | 1401 | ||
1376 | retval = bind(&udc->gadget); | 1402 | retval = bind(&udc->gadget, driver); |
1377 | if (retval) { | 1403 | if (retval) { |
1378 | dev_err(&udc->dev->dev, "bind to driver %s --> %d\n", | 1404 | dev_err(&udc->dev->dev, "bind to driver %s --> %d\n", |
1379 | driver->driver.name, retval); | 1405 | driver->driver.name, retval); |
@@ -1499,15 +1525,17 @@ udc_prime_status(struct mv_udc *udc, u8 direction, u16 status, bool empty) | |||
1499 | } | 1525 | } |
1500 | 1526 | ||
1501 | /* prime the data phase */ | 1527 | /* prime the data phase */ |
1502 | if (!req_to_dtd(req)) | 1528 | if (!req_to_dtd(req)) { |
1503 | retval = queue_dtd(ep, req); | 1529 | retval = queue_dtd(ep, req); |
1504 | else{ /* no mem */ | 1530 | if (retval) { |
1531 | dev_err(&udc->dev->dev, | ||
1532 | "Failed to queue dtd when prime status\n"); | ||
1533 | goto out; | ||
1534 | } | ||
1535 | } else{ /* no mem */ | ||
1505 | retval = -ENOMEM; | 1536 | retval = -ENOMEM; |
1506 | goto out; | 1537 | dev_err(&udc->dev->dev, |
1507 | } | 1538 | "Failed to dma_pool_alloc when prime status\n"); |
1508 | |||
1509 | if (retval) { | ||
1510 | dev_err(&udc->dev->dev, "response error on GET_STATUS request\n"); | ||
1511 | goto out; | 1539 | goto out; |
1512 | } | 1540 | } |
1513 | 1541 | ||
@@ -1515,6 +1543,15 @@ udc_prime_status(struct mv_udc *udc, u8 direction, u16 status, bool empty) | |||
1515 | 1543 | ||
1516 | return 0; | 1544 | return 0; |
1517 | out: | 1545 | out: |
1546 | if (req->mapped) { | ||
1547 | dma_unmap_single(ep->udc->gadget.dev.parent, | ||
1548 | req->req.dma, req->req.length, | ||
1549 | ((ep_dir(ep) == EP_DIR_IN) ? | ||
1550 | DMA_TO_DEVICE : DMA_FROM_DEVICE)); | ||
1551 | req->req.dma = DMA_ADDR_INVALID; | ||
1552 | req->mapped = 0; | ||
1553 | } | ||
1554 | |||
1518 | return retval; | 1555 | return retval; |
1519 | } | 1556 | } |
1520 | 1557 | ||
@@ -2468,9 +2505,11 @@ static void mv_udc_shutdown(struct platform_device *dev) | |||
2468 | u32 mode; | 2505 | u32 mode; |
2469 | 2506 | ||
2470 | /* reset controller mode to IDLE */ | 2507 | /* reset controller mode to IDLE */ |
2508 | mv_udc_enable(udc); | ||
2471 | mode = readl(&udc->op_regs->usbmode); | 2509 | mode = readl(&udc->op_regs->usbmode); |
2472 | mode &= ~3; | 2510 | mode &= ~3; |
2473 | writel(mode, &udc->op_regs->usbmode); | 2511 | writel(mode, &udc->op_regs->usbmode); |
2512 | mv_udc_disable(udc); | ||
2474 | } | 2513 | } |
2475 | 2514 | ||
2476 | static struct platform_driver udc_driver = { | 2515 | static struct platform_driver udc_driver = { |
diff --git a/drivers/usb/gadget/ncm.c b/drivers/usb/gadget/ncm.c index 89530034dff1..a22ad9af0565 100644 --- a/drivers/usb/gadget/ncm.c +++ b/drivers/usb/gadget/ncm.c | |||
@@ -20,8 +20,8 @@ | |||
20 | /* #define VERBOSE_DEBUG */ | 20 | /* #define VERBOSE_DEBUG */ |
21 | 21 | ||
22 | #include <linux/kernel.h> | 22 | #include <linux/kernel.h> |
23 | #include <linux/utsname.h> | 23 | #include <linux/module.h> |
24 | 24 | #include <linux/usb/composite.h> | |
25 | 25 | ||
26 | #include "u_ether.h" | 26 | #include "u_ether.h" |
27 | 27 | ||
@@ -36,11 +36,6 @@ | |||
36 | * the runtime footprint, and giving us at least some parts of what | 36 | * the runtime footprint, and giving us at least some parts of what |
37 | * a "gcc --combine ... part1.c part2.c part3.c ... " build would. | 37 | * a "gcc --combine ... part1.c part2.c part3.c ... " build would. |
38 | */ | 38 | */ |
39 | #include "composite.c" | ||
40 | #include "usbstring.c" | ||
41 | #include "config.c" | ||
42 | #include "epautoconf.c" | ||
43 | |||
44 | #include "f_ncm.c" | 39 | #include "f_ncm.c" |
45 | #include "u_ether.c" | 40 | #include "u_ether.c" |
46 | 41 | ||
@@ -57,6 +52,7 @@ | |||
57 | #define CDC_PRODUCT_NUM 0xa4a1 /* Linux-USB Ethernet Gadget */ | 52 | #define CDC_PRODUCT_NUM 0xa4a1 /* Linux-USB Ethernet Gadget */ |
58 | 53 | ||
59 | /*-------------------------------------------------------------------------*/ | 54 | /*-------------------------------------------------------------------------*/ |
55 | USB_GADGET_COMPOSITE_OPTIONS(); | ||
60 | 56 | ||
61 | static struct usb_device_descriptor device_desc = { | 57 | static struct usb_device_descriptor device_desc = { |
62 | .bLength = sizeof device_desc, | 58 | .bLength = sizeof device_desc, |
@@ -97,17 +93,11 @@ static const struct usb_descriptor_header *otg_desc[] = { | |||
97 | NULL, | 93 | NULL, |
98 | }; | 94 | }; |
99 | 95 | ||
100 | |||
101 | /* string IDs are assigned dynamically */ | 96 | /* string IDs are assigned dynamically */ |
102 | |||
103 | #define STRING_MANUFACTURER_IDX 0 | ||
104 | #define STRING_PRODUCT_IDX 1 | ||
105 | |||
106 | static char manufacturer[50]; | ||
107 | |||
108 | static struct usb_string strings_dev[] = { | 97 | static struct usb_string strings_dev[] = { |
109 | [STRING_MANUFACTURER_IDX].s = manufacturer, | 98 | [USB_GADGET_MANUFACTURER_IDX].s = "", |
110 | [STRING_PRODUCT_IDX].s = DRIVER_DESC, | 99 | [USB_GADGET_PRODUCT_IDX].s = DRIVER_DESC, |
100 | [USB_GADGET_SERIAL_IDX].s = "", | ||
111 | { } /* end of list */ | 101 | { } /* end of list */ |
112 | }; | 102 | }; |
113 | 103 | ||
@@ -149,7 +139,6 @@ static struct usb_configuration ncm_config_driver = { | |||
149 | 139 | ||
150 | static int __init gncm_bind(struct usb_composite_dev *cdev) | 140 | static int __init gncm_bind(struct usb_composite_dev *cdev) |
151 | { | 141 | { |
152 | int gcnum; | ||
153 | struct usb_gadget *gadget = cdev->gadget; | 142 | struct usb_gadget *gadget = cdev->gadget; |
154 | int status; | 143 | int status; |
155 | 144 | ||
@@ -158,48 +147,22 @@ static int __init gncm_bind(struct usb_composite_dev *cdev) | |||
158 | if (status < 0) | 147 | if (status < 0) |
159 | return status; | 148 | return status; |
160 | 149 | ||
161 | gcnum = usb_gadget_controller_number(gadget); | ||
162 | if (gcnum >= 0) | ||
163 | device_desc.bcdDevice = cpu_to_le16(0x0300 | gcnum); | ||
164 | else { | ||
165 | /* We assume that can_support_ecm() tells the truth; | ||
166 | * but if the controller isn't recognized at all then | ||
167 | * that assumption is a bit more likely to be wrong. | ||
168 | */ | ||
169 | dev_warn(&gadget->dev, | ||
170 | "controller '%s' not recognized; trying %s\n", | ||
171 | gadget->name, | ||
172 | ncm_config_driver.label); | ||
173 | device_desc.bcdDevice = | ||
174 | cpu_to_le16(0x0300 | 0x0099); | ||
175 | } | ||
176 | |||
177 | |||
178 | /* Allocate string descriptor numbers ... note that string | 150 | /* Allocate string descriptor numbers ... note that string |
179 | * contents can be overridden by the composite_dev glue. | 151 | * contents can be overridden by the composite_dev glue. |
180 | */ | 152 | */ |
181 | 153 | ||
182 | /* device descriptor strings: manufacturer, product */ | 154 | status = usb_string_ids_tab(cdev, strings_dev); |
183 | snprintf(manufacturer, sizeof manufacturer, "%s %s with %s", | ||
184 | init_utsname()->sysname, init_utsname()->release, | ||
185 | gadget->name); | ||
186 | status = usb_string_id(cdev); | ||
187 | if (status < 0) | ||
188 | goto fail; | ||
189 | strings_dev[STRING_MANUFACTURER_IDX].id = status; | ||
190 | device_desc.iManufacturer = status; | ||
191 | |||
192 | status = usb_string_id(cdev); | ||
193 | if (status < 0) | 155 | if (status < 0) |
194 | goto fail; | 156 | goto fail; |
195 | strings_dev[STRING_PRODUCT_IDX].id = status; | 157 | device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id; |
196 | device_desc.iProduct = status; | 158 | device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; |
197 | 159 | ||
198 | status = usb_add_config(cdev, &ncm_config_driver, | 160 | status = usb_add_config(cdev, &ncm_config_driver, |
199 | ncm_do_config); | 161 | ncm_do_config); |
200 | if (status < 0) | 162 | if (status < 0) |
201 | goto fail; | 163 | goto fail; |
202 | 164 | ||
165 | usb_composite_overwrite_options(cdev, &coverwrite); | ||
203 | dev_info(&gadget->dev, "%s\n", DRIVER_DESC); | 166 | dev_info(&gadget->dev, "%s\n", DRIVER_DESC); |
204 | 167 | ||
205 | return 0; | 168 | return 0; |
@@ -215,11 +178,12 @@ static int __exit gncm_unbind(struct usb_composite_dev *cdev) | |||
215 | return 0; | 178 | return 0; |
216 | } | 179 | } |
217 | 180 | ||
218 | static struct usb_composite_driver ncm_driver = { | 181 | static __refdata struct usb_composite_driver ncm_driver = { |
219 | .name = "g_ncm", | 182 | .name = "g_ncm", |
220 | .dev = &device_desc, | 183 | .dev = &device_desc, |
221 | .strings = dev_strings, | 184 | .strings = dev_strings, |
222 | .max_speed = USB_SPEED_HIGH, | 185 | .max_speed = USB_SPEED_HIGH, |
186 | .bind = gncm_bind, | ||
223 | .unbind = __exit_p(gncm_unbind), | 187 | .unbind = __exit_p(gncm_unbind), |
224 | }; | 188 | }; |
225 | 189 | ||
@@ -229,7 +193,7 @@ MODULE_LICENSE("GPL"); | |||
229 | 193 | ||
230 | static int __init init(void) | 194 | static int __init init(void) |
231 | { | 195 | { |
232 | return usb_composite_probe(&ncm_driver, gncm_bind); | 196 | return usb_composite_probe(&ncm_driver); |
233 | } | 197 | } |
234 | module_init(init); | 198 | module_init(init); |
235 | 199 | ||
diff --git a/drivers/usb/gadget/nokia.c b/drivers/usb/gadget/nokia.c index c7fb7723c014..661600abace8 100644 --- a/drivers/usb/gadget/nokia.c +++ b/drivers/usb/gadget/nokia.c | |||
@@ -16,7 +16,6 @@ | |||
16 | */ | 16 | */ |
17 | 17 | ||
18 | #include <linux/kernel.h> | 18 | #include <linux/kernel.h> |
19 | #include <linux/utsname.h> | ||
20 | #include <linux/device.h> | 19 | #include <linux/device.h> |
21 | 20 | ||
22 | #include "u_serial.h" | 21 | #include "u_serial.h" |
@@ -38,11 +37,6 @@ | |||
38 | * the runtime footprint, and giving us at least some parts of what | 37 | * the runtime footprint, and giving us at least some parts of what |
39 | * a "gcc --combine ... part1.c part2.c part3.c ... " build would. | 38 | * a "gcc --combine ... part1.c part2.c part3.c ... " build would. |
40 | */ | 39 | */ |
41 | #include "composite.c" | ||
42 | #include "usbstring.c" | ||
43 | #include "config.c" | ||
44 | #include "epautoconf.c" | ||
45 | |||
46 | #include "u_serial.c" | 40 | #include "u_serial.c" |
47 | #include "f_acm.c" | 41 | #include "f_acm.c" |
48 | #include "f_ecm.c" | 42 | #include "f_ecm.c" |
@@ -52,23 +46,23 @@ | |||
52 | #include "u_ether.c" | 46 | #include "u_ether.c" |
53 | 47 | ||
54 | /*-------------------------------------------------------------------------*/ | 48 | /*-------------------------------------------------------------------------*/ |
49 | USB_GADGET_COMPOSITE_OPTIONS(); | ||
55 | 50 | ||
56 | #define NOKIA_VENDOR_ID 0x0421 /* Nokia */ | 51 | #define NOKIA_VENDOR_ID 0x0421 /* Nokia */ |
57 | #define NOKIA_PRODUCT_ID 0x01c8 /* Nokia Gadget */ | 52 | #define NOKIA_PRODUCT_ID 0x01c8 /* Nokia Gadget */ |
58 | 53 | ||
59 | /* string IDs are assigned dynamically */ | 54 | /* string IDs are assigned dynamically */ |
60 | 55 | ||
61 | #define STRING_MANUFACTURER_IDX 0 | 56 | #define STRING_DESCRIPTION_IDX USB_GADGET_FIRST_AVAIL_IDX |
62 | #define STRING_PRODUCT_IDX 1 | ||
63 | #define STRING_DESCRIPTION_IDX 2 | ||
64 | 57 | ||
65 | static char manufacturer_nokia[] = "Nokia"; | 58 | static char manufacturer_nokia[] = "Nokia"; |
66 | static const char product_nokia[] = NOKIA_LONG_NAME; | 59 | static const char product_nokia[] = NOKIA_LONG_NAME; |
67 | static const char description_nokia[] = "PC-Suite Configuration"; | 60 | static const char description_nokia[] = "PC-Suite Configuration"; |
68 | 61 | ||
69 | static struct usb_string strings_dev[] = { | 62 | static struct usb_string strings_dev[] = { |
70 | [STRING_MANUFACTURER_IDX].s = manufacturer_nokia, | 63 | [USB_GADGET_MANUFACTURER_IDX].s = manufacturer_nokia, |
71 | [STRING_PRODUCT_IDX].s = NOKIA_LONG_NAME, | 64 | [USB_GADGET_PRODUCT_IDX].s = NOKIA_LONG_NAME, |
65 | [USB_GADGET_SERIAL_IDX].s = "", | ||
72 | [STRING_DESCRIPTION_IDX].s = description_nokia, | 66 | [STRING_DESCRIPTION_IDX].s = description_nokia, |
73 | { } /* end of list */ | 67 | { } /* end of list */ |
74 | }; | 68 | }; |
@@ -90,6 +84,7 @@ static struct usb_device_descriptor device_desc = { | |||
90 | .bDeviceClass = USB_CLASS_COMM, | 84 | .bDeviceClass = USB_CLASS_COMM, |
91 | .idVendor = __constant_cpu_to_le16(NOKIA_VENDOR_ID), | 85 | .idVendor = __constant_cpu_to_le16(NOKIA_VENDOR_ID), |
92 | .idProduct = __constant_cpu_to_le16(NOKIA_PRODUCT_ID), | 86 | .idProduct = __constant_cpu_to_le16(NOKIA_PRODUCT_ID), |
87 | .bcdDevice = cpu_to_le16(NOKIA_VERSION_NUM), | ||
93 | /* .iManufacturer = DYNAMIC */ | 88 | /* .iManufacturer = DYNAMIC */ |
94 | /* .iProduct = DYNAMIC */ | 89 | /* .iProduct = DYNAMIC */ |
95 | .bNumConfigurations = 1, | 90 | .bNumConfigurations = 1, |
@@ -151,7 +146,6 @@ static struct usb_configuration nokia_config_100ma_driver = { | |||
151 | 146 | ||
152 | static int __init nokia_bind(struct usb_composite_dev *cdev) | 147 | static int __init nokia_bind(struct usb_composite_dev *cdev) |
153 | { | 148 | { |
154 | int gcnum; | ||
155 | struct usb_gadget *gadget = cdev->gadget; | 149 | struct usb_gadget *gadget = cdev->gadget; |
156 | int status; | 150 | int status; |
157 | 151 | ||
@@ -167,41 +161,17 @@ static int __init nokia_bind(struct usb_composite_dev *cdev) | |||
167 | if (status < 0) | 161 | if (status < 0) |
168 | goto err_ether; | 162 | goto err_ether; |
169 | 163 | ||
170 | status = usb_string_id(cdev); | 164 | status = usb_string_ids_tab(cdev, strings_dev); |
171 | if (status < 0) | ||
172 | goto err_usb; | ||
173 | strings_dev[STRING_MANUFACTURER_IDX].id = status; | ||
174 | |||
175 | device_desc.iManufacturer = status; | ||
176 | |||
177 | status = usb_string_id(cdev); | ||
178 | if (status < 0) | 165 | if (status < 0) |
179 | goto err_usb; | 166 | goto err_usb; |
180 | strings_dev[STRING_PRODUCT_IDX].id = status; | 167 | device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id; |
181 | 168 | device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; | |
182 | device_desc.iProduct = status; | 169 | status = strings_dev[STRING_DESCRIPTION_IDX].id; |
183 | |||
184 | /* config description */ | ||
185 | status = usb_string_id(cdev); | ||
186 | if (status < 0) | ||
187 | goto err_usb; | ||
188 | strings_dev[STRING_DESCRIPTION_IDX].id = status; | ||
189 | |||
190 | nokia_config_500ma_driver.iConfiguration = status; | 170 | nokia_config_500ma_driver.iConfiguration = status; |
191 | nokia_config_100ma_driver.iConfiguration = status; | 171 | nokia_config_100ma_driver.iConfiguration = status; |
192 | 172 | ||
193 | /* set up other descriptors */ | 173 | if (!gadget_supports_altsettings(gadget)) |
194 | gcnum = usb_gadget_controller_number(gadget); | ||
195 | if (gcnum >= 0) | ||
196 | device_desc.bcdDevice = cpu_to_le16(NOKIA_VERSION_NUM); | ||
197 | else { | ||
198 | /* this should only work with hw that supports altsettings | ||
199 | * and several endpoints, anything else, panic. | ||
200 | */ | ||
201 | pr_err("nokia_bind: controller '%s' not recognized\n", | ||
202 | gadget->name); | ||
203 | goto err_usb; | 174 | goto err_usb; |
204 | } | ||
205 | 175 | ||
206 | /* finally register the configuration */ | 176 | /* finally register the configuration */ |
207 | status = usb_add_config(cdev, &nokia_config_500ma_driver, | 177 | status = usb_add_config(cdev, &nokia_config_500ma_driver, |
@@ -214,6 +184,7 @@ static int __init nokia_bind(struct usb_composite_dev *cdev) | |||
214 | if (status < 0) | 184 | if (status < 0) |
215 | goto err_usb; | 185 | goto err_usb; |
216 | 186 | ||
187 | usb_composite_overwrite_options(cdev, &coverwrite); | ||
217 | dev_info(&gadget->dev, "%s\n", NOKIA_LONG_NAME); | 188 | dev_info(&gadget->dev, "%s\n", NOKIA_LONG_NAME); |
218 | 189 | ||
219 | return 0; | 190 | return 0; |
@@ -237,17 +208,18 @@ static int __exit nokia_unbind(struct usb_composite_dev *cdev) | |||
237 | return 0; | 208 | return 0; |
238 | } | 209 | } |
239 | 210 | ||
240 | static struct usb_composite_driver nokia_driver = { | 211 | static __refdata struct usb_composite_driver nokia_driver = { |
241 | .name = "g_nokia", | 212 | .name = "g_nokia", |
242 | .dev = &device_desc, | 213 | .dev = &device_desc, |
243 | .strings = dev_strings, | 214 | .strings = dev_strings, |
244 | .max_speed = USB_SPEED_HIGH, | 215 | .max_speed = USB_SPEED_HIGH, |
216 | .bind = nokia_bind, | ||
245 | .unbind = __exit_p(nokia_unbind), | 217 | .unbind = __exit_p(nokia_unbind), |
246 | }; | 218 | }; |
247 | 219 | ||
248 | static int __init nokia_init(void) | 220 | static int __init nokia_init(void) |
249 | { | 221 | { |
250 | return usb_composite_probe(&nokia_driver, nokia_bind); | 222 | return usb_composite_probe(&nokia_driver); |
251 | } | 223 | } |
252 | module_init(nokia_init); | 224 | module_init(nokia_init); |
253 | 225 | ||
diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c index f9132ada53b5..2a4749c3eb3f 100644 --- a/drivers/usb/gadget/omap_udc.c +++ b/drivers/usb/gadget/omap_udc.c | |||
@@ -1308,7 +1308,7 @@ static int omap_pullup(struct usb_gadget *gadget, int is_on) | |||
1308 | } | 1308 | } |
1309 | 1309 | ||
1310 | static int omap_udc_start(struct usb_gadget_driver *driver, | 1310 | static int omap_udc_start(struct usb_gadget_driver *driver, |
1311 | int (*bind)(struct usb_gadget *)); | 1311 | int (*bind)(struct usb_gadget *, struct usb_gadget_driver *)); |
1312 | static int omap_udc_stop(struct usb_gadget_driver *driver); | 1312 | static int omap_udc_stop(struct usb_gadget_driver *driver); |
1313 | 1313 | ||
1314 | static struct usb_gadget_ops omap_gadget_ops = { | 1314 | static struct usb_gadget_ops omap_gadget_ops = { |
@@ -2040,7 +2040,7 @@ static inline int machine_without_vbus_sense(void) | |||
2040 | } | 2040 | } |
2041 | 2041 | ||
2042 | static int omap_udc_start(struct usb_gadget_driver *driver, | 2042 | static int omap_udc_start(struct usb_gadget_driver *driver, |
2043 | int (*bind)(struct usb_gadget *)) | 2043 | int (*bind)(struct usb_gadget *, struct usb_gadget_driver *)) |
2044 | { | 2044 | { |
2045 | int status = -ENODEV; | 2045 | int status = -ENODEV; |
2046 | struct omap_ep *ep; | 2046 | struct omap_ep *ep; |
@@ -2082,7 +2082,7 @@ static int omap_udc_start(struct usb_gadget_driver *driver, | |||
2082 | if (udc->dc_clk != NULL) | 2082 | if (udc->dc_clk != NULL) |
2083 | omap_udc_enable_clock(1); | 2083 | omap_udc_enable_clock(1); |
2084 | 2084 | ||
2085 | status = bind(&udc->gadget); | 2085 | status = bind(&udc->gadget, driver); |
2086 | if (status) { | 2086 | if (status) { |
2087 | DBG("bind to %s --> %d\n", driver->driver.name, status); | 2087 | DBG("bind to %s --> %d\n", driver->driver.name, status); |
2088 | udc->gadget.dev.driver = NULL; | 2088 | udc->gadget.dev.driver = NULL; |
diff --git a/drivers/usb/gadget/pch_udc.c b/drivers/usb/gadget/pch_udc.c index f4fb71c9ae08..6490c0040e3a 100644 --- a/drivers/usb/gadget/pch_udc.c +++ b/drivers/usb/gadget/pch_udc.c | |||
@@ -1236,7 +1236,7 @@ static int pch_udc_pcd_vbus_draw(struct usb_gadget *gadget, unsigned int mA) | |||
1236 | } | 1236 | } |
1237 | 1237 | ||
1238 | static int pch_udc_start(struct usb_gadget_driver *driver, | 1238 | static int pch_udc_start(struct usb_gadget_driver *driver, |
1239 | int (*bind)(struct usb_gadget *)); | 1239 | int (*bind)(struct usb_gadget *, struct usb_gadget_driver *)); |
1240 | static int pch_udc_stop(struct usb_gadget_driver *driver); | 1240 | static int pch_udc_stop(struct usb_gadget_driver *driver); |
1241 | static const struct usb_gadget_ops pch_udc_ops = { | 1241 | static const struct usb_gadget_ops pch_udc_ops = { |
1242 | .get_frame = pch_udc_pcd_get_frame, | 1242 | .get_frame = pch_udc_pcd_get_frame, |
@@ -2982,7 +2982,7 @@ static int init_dma_pools(struct pch_udc_dev *dev) | |||
2982 | } | 2982 | } |
2983 | 2983 | ||
2984 | static int pch_udc_start(struct usb_gadget_driver *driver, | 2984 | static int pch_udc_start(struct usb_gadget_driver *driver, |
2985 | int (*bind)(struct usb_gadget *)) | 2985 | int (*bind)(struct usb_gadget *, struct usb_gadget_driver *)) |
2986 | { | 2986 | { |
2987 | struct pch_udc_dev *dev = pch_udc; | 2987 | struct pch_udc_dev *dev = pch_udc; |
2988 | int retval; | 2988 | int retval; |
@@ -3006,7 +3006,7 @@ static int pch_udc_start(struct usb_gadget_driver *driver, | |||
3006 | dev->gadget.dev.driver = &driver->driver; | 3006 | dev->gadget.dev.driver = &driver->driver; |
3007 | 3007 | ||
3008 | /* Invoke the bind routine of the gadget driver */ | 3008 | /* Invoke the bind routine of the gadget driver */ |
3009 | retval = bind(&dev->gadget); | 3009 | retval = bind(&dev->gadget, driver); |
3010 | 3010 | ||
3011 | if (retval) { | 3011 | if (retval) { |
3012 | dev_err(&dev->pdev->dev, "%s: binding to %s returning %d\n", | 3012 | dev_err(&dev->pdev->dev, "%s: binding to %s returning %d\n", |
diff --git a/drivers/usb/gadget/printer.c b/drivers/usb/gadget/printer.c index f1f9290a2f47..e156e3f26727 100644 --- a/drivers/usb/gadget/printer.c +++ b/drivers/usb/gadget/printer.c | |||
@@ -22,7 +22,6 @@ | |||
22 | #include <linux/timer.h> | 22 | #include <linux/timer.h> |
23 | #include <linux/list.h> | 23 | #include <linux/list.h> |
24 | #include <linux/interrupt.h> | 24 | #include <linux/interrupt.h> |
25 | #include <linux/utsname.h> | ||
26 | #include <linux/device.h> | 25 | #include <linux/device.h> |
27 | #include <linux/moduleparam.h> | 26 | #include <linux/moduleparam.h> |
28 | #include <linux/fs.h> | 27 | #include <linux/fs.h> |
@@ -38,25 +37,13 @@ | |||
38 | #include <asm/unaligned.h> | 37 | #include <asm/unaligned.h> |
39 | 38 | ||
40 | #include <linux/usb/ch9.h> | 39 | #include <linux/usb/ch9.h> |
40 | #include <linux/usb/composite.h> | ||
41 | #include <linux/usb/gadget.h> | 41 | #include <linux/usb/gadget.h> |
42 | #include <linux/usb/g_printer.h> | 42 | #include <linux/usb/g_printer.h> |
43 | 43 | ||
44 | #include "gadget_chips.h" | 44 | #include "gadget_chips.h" |
45 | 45 | ||
46 | 46 | USB_GADGET_COMPOSITE_OPTIONS(); | |
47 | /* | ||
48 | * Kbuild is not very cooperative with respect to linking separately | ||
49 | * compiled library objects into one module. So for now we won't use | ||
50 | * separate compilation ... ensuring init/exit sections work to shrink | ||
51 | * the runtime footprint, and giving us at least some parts of what | ||
52 | * a "gcc --combine ... part1.c part2.c part3.c ... " build would. | ||
53 | */ | ||
54 | #include "composite.c" | ||
55 | #include "usbstring.c" | ||
56 | #include "config.c" | ||
57 | #include "epautoconf.c" | ||
58 | |||
59 | /*-------------------------------------------------------------------------*/ | ||
60 | 47 | ||
61 | #define DRIVER_DESC "Printer Gadget" | 48 | #define DRIVER_DESC "Printer Gadget" |
62 | #define DRIVER_VERSION "2007 OCT 06" | 49 | #define DRIVER_VERSION "2007 OCT 06" |
@@ -120,8 +107,7 @@ static struct printer_dev usb_printer_gadget; | |||
120 | * parameters are in UTF-8 (superset of ASCII's 7 bit characters). | 107 | * parameters are in UTF-8 (superset of ASCII's 7 bit characters). |
121 | */ | 108 | */ |
122 | 109 | ||
123 | static char *iSerialNum; | 110 | module_param_named(iSerialNum, coverwrite.serial_number, charp, S_IRUGO); |
124 | module_param(iSerialNum, charp, S_IRUGO); | ||
125 | MODULE_PARM_DESC(iSerialNum, "1"); | 111 | MODULE_PARM_DESC(iSerialNum, "1"); |
126 | 112 | ||
127 | static char *iPNPstring; | 113 | static char *iPNPstring; |
@@ -141,18 +127,10 @@ module_param(qlen, uint, S_IRUGO|S_IWUSR); | |||
141 | * descriptors are built on demand. | 127 | * descriptors are built on demand. |
142 | */ | 128 | */ |
143 | 129 | ||
144 | #define STRING_MANUFACTURER 1 | ||
145 | #define STRING_PRODUCT 2 | ||
146 | #define STRING_SERIALNUM 3 | ||
147 | |||
148 | /* holds our biggest descriptor */ | 130 | /* holds our biggest descriptor */ |
149 | #define USB_DESC_BUFSIZE 256 | 131 | #define USB_DESC_BUFSIZE 256 |
150 | #define USB_BUFSIZE 8192 | 132 | #define USB_BUFSIZE 8192 |
151 | 133 | ||
152 | /* This device advertises one configuration. */ | ||
153 | #define DEV_CONFIG_VALUE 1 | ||
154 | #define PRINTER_INTERFACE 0 | ||
155 | |||
156 | static struct usb_device_descriptor device_desc = { | 134 | static struct usb_device_descriptor device_desc = { |
157 | .bLength = sizeof device_desc, | 135 | .bLength = sizeof device_desc, |
158 | .bDescriptorType = USB_DT_DEVICE, | 136 | .bDescriptorType = USB_DT_DEVICE, |
@@ -162,16 +140,12 @@ static struct usb_device_descriptor device_desc = { | |||
162 | .bDeviceProtocol = 0, | 140 | .bDeviceProtocol = 0, |
163 | .idVendor = cpu_to_le16(PRINTER_VENDOR_NUM), | 141 | .idVendor = cpu_to_le16(PRINTER_VENDOR_NUM), |
164 | .idProduct = cpu_to_le16(PRINTER_PRODUCT_NUM), | 142 | .idProduct = cpu_to_le16(PRINTER_PRODUCT_NUM), |
165 | .iManufacturer = STRING_MANUFACTURER, | ||
166 | .iProduct = STRING_PRODUCT, | ||
167 | .iSerialNumber = STRING_SERIALNUM, | ||
168 | .bNumConfigurations = 1 | 143 | .bNumConfigurations = 1 |
169 | }; | 144 | }; |
170 | 145 | ||
171 | static struct usb_interface_descriptor intf_desc = { | 146 | static struct usb_interface_descriptor intf_desc = { |
172 | .bLength = sizeof intf_desc, | 147 | .bLength = sizeof intf_desc, |
173 | .bDescriptorType = USB_DT_INTERFACE, | 148 | .bDescriptorType = USB_DT_INTERFACE, |
174 | .bInterfaceNumber = PRINTER_INTERFACE, | ||
175 | .bNumEndpoints = 2, | 149 | .bNumEndpoints = 2, |
176 | .bInterfaceClass = USB_CLASS_PRINTER, | 150 | .bInterfaceClass = USB_CLASS_PRINTER, |
177 | .bInterfaceSubClass = 1, /* Printer Sub-Class */ | 151 | .bInterfaceSubClass = 1, /* Printer Sub-Class */ |
@@ -252,7 +226,6 @@ static const struct usb_descriptor_header *otg_desc[] = { | |||
252 | 226 | ||
253 | /* descriptors that are built on-demand */ | 227 | /* descriptors that are built on-demand */ |
254 | 228 | ||
255 | static char manufacturer [50]; | ||
256 | static char product_desc [40] = DRIVER_DESC; | 229 | static char product_desc [40] = DRIVER_DESC; |
257 | static char serial_num [40] = "1"; | 230 | static char serial_num [40] = "1"; |
258 | static char pnp_string [1024] = | 231 | static char pnp_string [1024] = |
@@ -260,9 +233,9 @@ static char pnp_string [1024] = | |||
260 | 233 | ||
261 | /* static strings, in UTF-8 */ | 234 | /* static strings, in UTF-8 */ |
262 | static struct usb_string strings [] = { | 235 | static struct usb_string strings [] = { |
263 | { STRING_MANUFACTURER, manufacturer, }, | 236 | [USB_GADGET_MANUFACTURER_IDX].s = "", |
264 | { STRING_PRODUCT, product_desc, }, | 237 | [USB_GADGET_PRODUCT_IDX].s = product_desc, |
265 | { STRING_SERIALNUM, serial_num, }, | 238 | [USB_GADGET_SERIAL_IDX].s = serial_num, |
266 | { } /* end of list */ | 239 | { } /* end of list */ |
267 | }; | 240 | }; |
268 | 241 | ||
@@ -871,25 +844,13 @@ static int set_interface(struct printer_dev *dev, unsigned number) | |||
871 | int result = 0; | 844 | int result = 0; |
872 | 845 | ||
873 | /* Free the current interface */ | 846 | /* Free the current interface */ |
874 | switch (dev->interface) { | 847 | printer_reset_interface(dev); |
875 | case PRINTER_INTERFACE: | ||
876 | printer_reset_interface(dev); | ||
877 | break; | ||
878 | } | ||
879 | 848 | ||
880 | switch (number) { | 849 | result = set_printer_interface(dev); |
881 | case PRINTER_INTERFACE: | 850 | if (result) |
882 | result = set_printer_interface(dev); | 851 | printer_reset_interface(dev); |
883 | if (result) { | 852 | else |
884 | printer_reset_interface(dev); | 853 | dev->interface = number; |
885 | } else { | ||
886 | dev->interface = PRINTER_INTERFACE; | ||
887 | } | ||
888 | break; | ||
889 | default: | ||
890 | result = -EINVAL; | ||
891 | /* FALL THROUGH */ | ||
892 | } | ||
893 | 854 | ||
894 | if (!result) | 855 | if (!result) |
895 | INFO(dev, "Using interface %x\n", number); | 856 | INFO(dev, "Using interface %x\n", number); |
@@ -972,7 +933,7 @@ static int printer_func_setup(struct usb_function *f, | |||
972 | switch (ctrl->bRequest) { | 933 | switch (ctrl->bRequest) { |
973 | case 0: /* Get the IEEE-1284 PNP String */ | 934 | case 0: /* Get the IEEE-1284 PNP String */ |
974 | /* Only one printer interface is supported. */ | 935 | /* Only one printer interface is supported. */ |
975 | if ((wIndex>>8) != PRINTER_INTERFACE) | 936 | if ((wIndex>>8) != dev->interface) |
976 | break; | 937 | break; |
977 | 938 | ||
978 | value = (pnp_string[0]<<8)|pnp_string[1]; | 939 | value = (pnp_string[0]<<8)|pnp_string[1]; |
@@ -983,7 +944,7 @@ static int printer_func_setup(struct usb_function *f, | |||
983 | 944 | ||
984 | case 1: /* Get Port Status */ | 945 | case 1: /* Get Port Status */ |
985 | /* Only one printer interface is supported. */ | 946 | /* Only one printer interface is supported. */ |
986 | if (wIndex != PRINTER_INTERFACE) | 947 | if (wIndex != dev->interface) |
987 | break; | 948 | break; |
988 | 949 | ||
989 | *(u8 *)req->buf = dev->printer_status; | 950 | *(u8 *)req->buf = dev->printer_status; |
@@ -992,7 +953,7 @@ static int printer_func_setup(struct usb_function *f, | |||
992 | 953 | ||
993 | case 2: /* Soft Reset */ | 954 | case 2: /* Soft Reset */ |
994 | /* Only one printer interface is supported. */ | 955 | /* Only one printer interface is supported. */ |
995 | if (wIndex != PRINTER_INTERFACE) | 956 | if (wIndex != dev->interface) |
996 | break; | 957 | break; |
997 | 958 | ||
998 | printer_soft_reset(dev); | 959 | printer_soft_reset(dev); |
@@ -1020,6 +981,37 @@ unknown: | |||
1020 | static int __init printer_func_bind(struct usb_configuration *c, | 981 | static int __init printer_func_bind(struct usb_configuration *c, |
1021 | struct usb_function *f) | 982 | struct usb_function *f) |
1022 | { | 983 | { |
984 | struct printer_dev *dev = container_of(f, struct printer_dev, function); | ||
985 | struct usb_composite_dev *cdev = c->cdev; | ||
986 | struct usb_ep *in_ep, *out_ep; | ||
987 | int id; | ||
988 | |||
989 | id = usb_interface_id(c, f); | ||
990 | if (id < 0) | ||
991 | return id; | ||
992 | intf_desc.bInterfaceNumber = id; | ||
993 | |||
994 | /* all we really need is bulk IN/OUT */ | ||
995 | in_ep = usb_ep_autoconfig(cdev->gadget, &fs_ep_in_desc); | ||
996 | if (!in_ep) { | ||
997 | autoconf_fail: | ||
998 | dev_err(&cdev->gadget->dev, "can't autoconfigure on %s\n", | ||
999 | cdev->gadget->name); | ||
1000 | return -ENODEV; | ||
1001 | } | ||
1002 | in_ep->driver_data = in_ep; /* claim */ | ||
1003 | |||
1004 | out_ep = usb_ep_autoconfig(cdev->gadget, &fs_ep_out_desc); | ||
1005 | if (!out_ep) | ||
1006 | goto autoconf_fail; | ||
1007 | out_ep->driver_data = out_ep; /* claim */ | ||
1008 | |||
1009 | /* assumes that all endpoints are dual-speed */ | ||
1010 | hs_ep_in_desc.bEndpointAddress = fs_ep_in_desc.bEndpointAddress; | ||
1011 | hs_ep_out_desc.bEndpointAddress = fs_ep_out_desc.bEndpointAddress; | ||
1012 | |||
1013 | dev->in_ep = in_ep; | ||
1014 | dev->out_ep = out_ep; | ||
1023 | return 0; | 1015 | return 0; |
1024 | } | 1016 | } |
1025 | 1017 | ||
@@ -1035,7 +1027,8 @@ static int printer_func_set_alt(struct usb_function *f, | |||
1035 | int ret = -ENOTSUPP; | 1027 | int ret = -ENOTSUPP; |
1036 | 1028 | ||
1037 | if (!alt) | 1029 | if (!alt) |
1038 | ret = set_interface(dev, PRINTER_INTERFACE); | 1030 | ret = set_interface(dev, intf); |
1031 | |||
1039 | return ret; | 1032 | return ret; |
1040 | } | 1033 | } |
1041 | 1034 | ||
@@ -1107,13 +1100,13 @@ static int __init printer_bind_config(struct usb_configuration *c) | |||
1107 | { | 1100 | { |
1108 | struct usb_gadget *gadget = c->cdev->gadget; | 1101 | struct usb_gadget *gadget = c->cdev->gadget; |
1109 | struct printer_dev *dev; | 1102 | struct printer_dev *dev; |
1110 | struct usb_ep *in_ep, *out_ep; | ||
1111 | int status = -ENOMEM; | 1103 | int status = -ENOMEM; |
1112 | int gcnum; | ||
1113 | size_t len; | 1104 | size_t len; |
1114 | u32 i; | 1105 | u32 i; |
1115 | struct usb_request *req; | 1106 | struct usb_request *req; |
1116 | 1107 | ||
1108 | usb_ep_autoconfig_reset(gadget); | ||
1109 | |||
1117 | dev = &usb_printer_gadget; | 1110 | dev = &usb_printer_gadget; |
1118 | 1111 | ||
1119 | dev->function.name = shortname; | 1112 | dev->function.name = shortname; |
@@ -1125,6 +1118,10 @@ static int __init printer_bind_config(struct usb_configuration *c) | |||
1125 | dev->function.set_alt = printer_func_set_alt; | 1118 | dev->function.set_alt = printer_func_set_alt; |
1126 | dev->function.disable = printer_func_disable; | 1119 | dev->function.disable = printer_func_disable; |
1127 | 1120 | ||
1121 | status = usb_add_function(c, &dev->function); | ||
1122 | if (status) | ||
1123 | return status; | ||
1124 | |||
1128 | /* Setup the sysfs files for the printer gadget. */ | 1125 | /* Setup the sysfs files for the printer gadget. */ |
1129 | dev->pdev = device_create(usb_gadget_class, NULL, g_printer_devno, | 1126 | dev->pdev = device_create(usb_gadget_class, NULL, g_printer_devno, |
1130 | NULL, "g_printer"); | 1127 | NULL, "g_printer"); |
@@ -1145,23 +1142,6 @@ static int __init printer_bind_config(struct usb_configuration *c) | |||
1145 | goto fail; | 1142 | goto fail; |
1146 | } | 1143 | } |
1147 | 1144 | ||
1148 | gcnum = usb_gadget_controller_number(gadget); | ||
1149 | if (gcnum >= 0) { | ||
1150 | device_desc.bcdDevice = cpu_to_le16(0x0200 + gcnum); | ||
1151 | } else { | ||
1152 | dev_warn(&gadget->dev, "controller '%s' not recognized\n", | ||
1153 | gadget->name); | ||
1154 | /* unrecognized, but safe unless bulk is REALLY quirky */ | ||
1155 | device_desc.bcdDevice = | ||
1156 | cpu_to_le16(0xFFFF); | ||
1157 | } | ||
1158 | snprintf(manufacturer, sizeof(manufacturer), "%s %s with %s", | ||
1159 | init_utsname()->sysname, init_utsname()->release, | ||
1160 | gadget->name); | ||
1161 | |||
1162 | if (iSerialNum) | ||
1163 | strlcpy(serial_num, iSerialNum, sizeof serial_num); | ||
1164 | |||
1165 | if (iPNPstring) | 1145 | if (iPNPstring) |
1166 | strlcpy(&pnp_string[2], iPNPstring, (sizeof pnp_string)-2); | 1146 | strlcpy(&pnp_string[2], iPNPstring, (sizeof pnp_string)-2); |
1167 | 1147 | ||
@@ -1169,26 +1149,6 @@ static int __init printer_bind_config(struct usb_configuration *c) | |||
1169 | pnp_string[0] = (len >> 8) & 0xFF; | 1149 | pnp_string[0] = (len >> 8) & 0xFF; |
1170 | pnp_string[1] = len & 0xFF; | 1150 | pnp_string[1] = len & 0xFF; |
1171 | 1151 | ||
1172 | /* all we really need is bulk IN/OUT */ | ||
1173 | usb_ep_autoconfig_reset(gadget); | ||
1174 | in_ep = usb_ep_autoconfig(gadget, &fs_ep_in_desc); | ||
1175 | if (!in_ep) { | ||
1176 | autoconf_fail: | ||
1177 | dev_err(&gadget->dev, "can't autoconfigure on %s\n", | ||
1178 | gadget->name); | ||
1179 | return -ENODEV; | ||
1180 | } | ||
1181 | in_ep->driver_data = in_ep; /* claim */ | ||
1182 | |||
1183 | out_ep = usb_ep_autoconfig(gadget, &fs_ep_out_desc); | ||
1184 | if (!out_ep) | ||
1185 | goto autoconf_fail; | ||
1186 | out_ep->driver_data = out_ep; /* claim */ | ||
1187 | |||
1188 | /* assumes that all endpoints are dual-speed */ | ||
1189 | hs_ep_in_desc.bEndpointAddress = fs_ep_in_desc.bEndpointAddress; | ||
1190 | hs_ep_out_desc.bEndpointAddress = fs_ep_out_desc.bEndpointAddress; | ||
1191 | |||
1192 | usb_gadget_set_selfpowered(gadget); | 1152 | usb_gadget_set_selfpowered(gadget); |
1193 | 1153 | ||
1194 | if (gadget->is_otg) { | 1154 | if (gadget->is_otg) { |
@@ -1215,9 +1175,6 @@ autoconf_fail: | |||
1215 | dev->current_rx_bytes = 0; | 1175 | dev->current_rx_bytes = 0; |
1216 | dev->current_rx_buf = NULL; | 1176 | dev->current_rx_buf = NULL; |
1217 | 1177 | ||
1218 | dev->in_ep = in_ep; | ||
1219 | dev->out_ep = out_ep; | ||
1220 | |||
1221 | for (i = 0; i < QLEN; i++) { | 1178 | for (i = 0; i < QLEN; i++) { |
1222 | req = printer_req_alloc(dev->in_ep, USB_BUFSIZE, GFP_KERNEL); | 1179 | req = printer_req_alloc(dev->in_ep, USB_BUFSIZE, GFP_KERNEL); |
1223 | if (!req) { | 1180 | if (!req) { |
@@ -1250,8 +1207,6 @@ autoconf_fail: | |||
1250 | dev->gadget = gadget; | 1207 | dev->gadget = gadget; |
1251 | 1208 | ||
1252 | INFO(dev, "%s, version: " DRIVER_VERSION "\n", driver_desc); | 1209 | INFO(dev, "%s, version: " DRIVER_VERSION "\n", driver_desc); |
1253 | INFO(dev, "using %s, OUT %s IN %s\n", gadget->name, out_ep->name, | ||
1254 | in_ep->name); | ||
1255 | return 0; | 1210 | return 0; |
1256 | 1211 | ||
1257 | fail: | 1212 | fail: |
@@ -1266,14 +1221,28 @@ static int printer_unbind(struct usb_composite_dev *cdev) | |||
1266 | 1221 | ||
1267 | static int __init printer_bind(struct usb_composite_dev *cdev) | 1222 | static int __init printer_bind(struct usb_composite_dev *cdev) |
1268 | { | 1223 | { |
1269 | return usb_add_config(cdev, &printer_cfg_driver, printer_bind_config); | 1224 | int ret; |
1225 | |||
1226 | ret = usb_string_ids_tab(cdev, strings); | ||
1227 | if (ret < 0) | ||
1228 | return ret; | ||
1229 | device_desc.iManufacturer = strings[USB_GADGET_MANUFACTURER_IDX].id; | ||
1230 | device_desc.iProduct = strings[USB_GADGET_PRODUCT_IDX].id; | ||
1231 | device_desc.iSerialNumber = strings[USB_GADGET_SERIAL_IDX].id; | ||
1232 | |||
1233 | ret = usb_add_config(cdev, &printer_cfg_driver, printer_bind_config); | ||
1234 | if (ret) | ||
1235 | return ret; | ||
1236 | usb_composite_overwrite_options(cdev, &coverwrite); | ||
1237 | return ret; | ||
1270 | } | 1238 | } |
1271 | 1239 | ||
1272 | static struct usb_composite_driver printer_driver = { | 1240 | static __refdata struct usb_composite_driver printer_driver = { |
1273 | .name = shortname, | 1241 | .name = shortname, |
1274 | .dev = &device_desc, | 1242 | .dev = &device_desc, |
1275 | .strings = dev_strings, | 1243 | .strings = dev_strings, |
1276 | .max_speed = USB_SPEED_HIGH, | 1244 | .max_speed = USB_SPEED_HIGH, |
1245 | .bind = printer_bind, | ||
1277 | .unbind = printer_unbind, | 1246 | .unbind = printer_unbind, |
1278 | }; | 1247 | }; |
1279 | 1248 | ||
@@ -1297,7 +1266,7 @@ init(void) | |||
1297 | return status; | 1266 | return status; |
1298 | } | 1267 | } |
1299 | 1268 | ||
1300 | status = usb_composite_probe(&printer_driver, printer_bind); | 1269 | status = usb_composite_probe(&printer_driver); |
1301 | if (status) { | 1270 | if (status) { |
1302 | class_destroy(usb_gadget_class); | 1271 | class_destroy(usb_gadget_class); |
1303 | unregister_chrdev_region(g_printer_devno, 1); | 1272 | unregister_chrdev_region(g_printer_devno, 1); |
diff --git a/drivers/usb/gadget/pxa25x_udc.c b/drivers/usb/gadget/pxa25x_udc.c index 907ad3ecb341..8efbf08c3561 100644 --- a/drivers/usb/gadget/pxa25x_udc.c +++ b/drivers/usb/gadget/pxa25x_udc.c | |||
@@ -33,7 +33,6 @@ | |||
33 | #include <linux/dma-mapping.h> | 33 | #include <linux/dma-mapping.h> |
34 | #include <linux/irq.h> | 34 | #include <linux/irq.h> |
35 | #include <linux/clk.h> | 35 | #include <linux/clk.h> |
36 | #include <linux/err.h> | ||
37 | #include <linux/seq_file.h> | 36 | #include <linux/seq_file.h> |
38 | #include <linux/debugfs.h> | 37 | #include <linux/debugfs.h> |
39 | #include <linux/io.h> | 38 | #include <linux/io.h> |
@@ -1000,7 +999,7 @@ static int pxa25x_udc_vbus_draw(struct usb_gadget *_gadget, unsigned mA) | |||
1000 | } | 999 | } |
1001 | 1000 | ||
1002 | static int pxa25x_start(struct usb_gadget_driver *driver, | 1001 | static int pxa25x_start(struct usb_gadget_driver *driver, |
1003 | int (*bind)(struct usb_gadget *)); | 1002 | int (*bind)(struct usb_gadget *, struct usb_gadget_driver *)); |
1004 | static int pxa25x_stop(struct usb_gadget_driver *driver); | 1003 | static int pxa25x_stop(struct usb_gadget_driver *driver); |
1005 | 1004 | ||
1006 | static const struct usb_gadget_ops pxa25x_udc_ops = { | 1005 | static const struct usb_gadget_ops pxa25x_udc_ops = { |
@@ -1258,7 +1257,7 @@ static void udc_enable (struct pxa25x_udc *dev) | |||
1258 | * the driver might get unbound. | 1257 | * the driver might get unbound. |
1259 | */ | 1258 | */ |
1260 | static int pxa25x_start(struct usb_gadget_driver *driver, | 1259 | static int pxa25x_start(struct usb_gadget_driver *driver, |
1261 | int (*bind)(struct usb_gadget *)) | 1260 | int (*bind)(struct usb_gadget *, struct usb_gadget_driver *)) |
1262 | { | 1261 | { |
1263 | struct pxa25x_udc *dev = the_controller; | 1262 | struct pxa25x_udc *dev = the_controller; |
1264 | int retval; | 1263 | int retval; |
@@ -1286,7 +1285,7 @@ fail: | |||
1286 | dev->gadget.dev.driver = NULL; | 1285 | dev->gadget.dev.driver = NULL; |
1287 | return retval; | 1286 | return retval; |
1288 | } | 1287 | } |
1289 | retval = bind(&dev->gadget); | 1288 | retval = bind(&dev->gadget, driver); |
1290 | if (retval) { | 1289 | if (retval) { |
1291 | DMSG("bind to driver %s --> error %d\n", | 1290 | DMSG("bind to driver %s --> error %d\n", |
1292 | driver->driver.name, retval); | 1291 | driver->driver.name, retval); |
diff --git a/drivers/usb/gadget/pxa25x_udc.h b/drivers/usb/gadget/pxa25x_udc.h index 861f4df6ea22..2eca1e71fecd 100644 --- a/drivers/usb/gadget/pxa25x_udc.h +++ b/drivers/usb/gadget/pxa25x_udc.h | |||
@@ -225,7 +225,7 @@ dump_state(struct pxa25x_udc *dev) | |||
225 | dev->stats.read.bytes, dev->stats.read.ops); | 225 | dev->stats.read.bytes, dev->stats.read.ops); |
226 | 226 | ||
227 | for (i = 1; i < PXA_UDC_NUM_ENDPOINTS; i++) { | 227 | for (i = 1; i < PXA_UDC_NUM_ENDPOINTS; i++) { |
228 | if (dev->ep [i].desc == NULL) | 228 | if (dev->ep[i].ep.desc == NULL) |
229 | continue; | 229 | continue; |
230 | DMSG ("udccs%d = %02x\n", i, *dev->ep->reg_udccs); | 230 | DMSG ("udccs%d = %02x\n", i, *dev->ep->reg_udccs); |
231 | } | 231 | } |
diff --git a/drivers/usb/gadget/pxa27x_udc.c b/drivers/usb/gadget/pxa27x_udc.c index 644b4305cb99..979ddaddb0f8 100644 --- a/drivers/usb/gadget/pxa27x_udc.c +++ b/drivers/usb/gadget/pxa27x_udc.c | |||
@@ -1672,7 +1672,7 @@ static int pxa_udc_vbus_draw(struct usb_gadget *_gadget, unsigned mA) | |||
1672 | } | 1672 | } |
1673 | 1673 | ||
1674 | static int pxa27x_udc_start(struct usb_gadget_driver *driver, | 1674 | static int pxa27x_udc_start(struct usb_gadget_driver *driver, |
1675 | int (*bind)(struct usb_gadget *)); | 1675 | int (*bind)(struct usb_gadget *, struct usb_gadget_driver *)); |
1676 | static int pxa27x_udc_stop(struct usb_gadget_driver *driver); | 1676 | static int pxa27x_udc_stop(struct usb_gadget_driver *driver); |
1677 | 1677 | ||
1678 | static const struct usb_gadget_ops pxa_udc_ops = { | 1678 | static const struct usb_gadget_ops pxa_udc_ops = { |
@@ -1803,7 +1803,7 @@ static void udc_enable(struct pxa_udc *udc) | |||
1803 | * Returns 0 if no error, -EINVAL, -ENODEV, -EBUSY otherwise | 1803 | * Returns 0 if no error, -EINVAL, -ENODEV, -EBUSY otherwise |
1804 | */ | 1804 | */ |
1805 | static int pxa27x_udc_start(struct usb_gadget_driver *driver, | 1805 | static int pxa27x_udc_start(struct usb_gadget_driver *driver, |
1806 | int (*bind)(struct usb_gadget *)) | 1806 | int (*bind)(struct usb_gadget *, struct usb_gadget_driver *)) |
1807 | { | 1807 | { |
1808 | struct pxa_udc *udc = the_controller; | 1808 | struct pxa_udc *udc = the_controller; |
1809 | int retval; | 1809 | int retval; |
@@ -1826,7 +1826,7 @@ static int pxa27x_udc_start(struct usb_gadget_driver *driver, | |||
1826 | dev_err(udc->dev, "device_add error %d\n", retval); | 1826 | dev_err(udc->dev, "device_add error %d\n", retval); |
1827 | goto add_fail; | 1827 | goto add_fail; |
1828 | } | 1828 | } |
1829 | retval = bind(&udc->gadget); | 1829 | retval = bind(&udc->gadget, driver); |
1830 | if (retval) { | 1830 | if (retval) { |
1831 | dev_err(udc->dev, "bind to driver %s --> error %d\n", | 1831 | dev_err(udc->dev, "bind to driver %s --> error %d\n", |
1832 | driver->driver.name, retval); | 1832 | driver->driver.name, retval); |
diff --git a/drivers/usb/gadget/rndis.c b/drivers/usb/gadget/rndis.c index b35babed6fcb..e4192b887de9 100644 --- a/drivers/usb/gadget/rndis.c +++ b/drivers/usb/gadget/rndis.c | |||
@@ -863,26 +863,8 @@ int rndis_msg_parser(u8 configNr, u8 *buf) | |||
863 | */ | 863 | */ |
864 | pr_warning("%s: unknown RNDIS message 0x%08X len %d\n", | 864 | pr_warning("%s: unknown RNDIS message 0x%08X len %d\n", |
865 | __func__, MsgType, MsgLength); | 865 | __func__, MsgType, MsgLength); |
866 | { | 866 | print_hex_dump_bytes(__func__, DUMP_PREFIX_OFFSET, |
867 | unsigned i; | 867 | buf, MsgLength); |
868 | for (i = 0; i < MsgLength; i += 16) { | ||
869 | pr_debug("%03d: " | ||
870 | " %02x %02x %02x %02x" | ||
871 | " %02x %02x %02x %02x" | ||
872 | " %02x %02x %02x %02x" | ||
873 | " %02x %02x %02x %02x" | ||
874 | "\n", | ||
875 | i, | ||
876 | buf[i], buf [i+1], | ||
877 | buf[i+2], buf[i+3], | ||
878 | buf[i+4], buf [i+5], | ||
879 | buf[i+6], buf[i+7], | ||
880 | buf[i+8], buf [i+9], | ||
881 | buf[i+10], buf[i+11], | ||
882 | buf[i+12], buf [i+13], | ||
883 | buf[i+14], buf[i+15]); | ||
884 | } | ||
885 | } | ||
886 | break; | 868 | break; |
887 | } | 869 | } |
888 | 870 | ||
diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c index 0bb617e1dda2..6f696ee8b817 100644 --- a/drivers/usb/gadget/s3c-hsotg.c +++ b/drivers/usb/gadget/s3c-hsotg.c | |||
@@ -2197,7 +2197,7 @@ static int s3c_hsotg_corereset(struct s3c_hsotg *hsotg) | |||
2197 | /* issue soft reset */ | 2197 | /* issue soft reset */ |
2198 | writel(GRSTCTL_CSftRst, hsotg->regs + GRSTCTL); | 2198 | writel(GRSTCTL_CSftRst, hsotg->regs + GRSTCTL); |
2199 | 2199 | ||
2200 | timeout = 1000; | 2200 | timeout = 10000; |
2201 | do { | 2201 | do { |
2202 | grstctl = readl(hsotg->regs + GRSTCTL); | 2202 | grstctl = readl(hsotg->regs + GRSTCTL); |
2203 | } while ((grstctl & GRSTCTL_CSftRst) && timeout-- > 0); | 2203 | } while ((grstctl & GRSTCTL_CSftRst) && timeout-- > 0); |
@@ -2207,7 +2207,7 @@ static int s3c_hsotg_corereset(struct s3c_hsotg *hsotg) | |||
2207 | return -EINVAL; | 2207 | return -EINVAL; |
2208 | } | 2208 | } |
2209 | 2209 | ||
2210 | timeout = 1000; | 2210 | timeout = 10000; |
2211 | 2211 | ||
2212 | while (1) { | 2212 | while (1) { |
2213 | u32 grstctl = readl(hsotg->regs + GRSTCTL); | 2213 | u32 grstctl = readl(hsotg->regs + GRSTCTL); |
@@ -3516,7 +3516,7 @@ static int __devinit s3c_hsotg_probe(struct platform_device *pdev) | |||
3516 | hsotg->dev = dev; | 3516 | hsotg->dev = dev; |
3517 | hsotg->plat = plat; | 3517 | hsotg->plat = plat; |
3518 | 3518 | ||
3519 | hsotg->clk = clk_get(&pdev->dev, "otg"); | 3519 | hsotg->clk = devm_clk_get(&pdev->dev, "otg"); |
3520 | if (IS_ERR(hsotg->clk)) { | 3520 | if (IS_ERR(hsotg->clk)) { |
3521 | dev_err(dev, "cannot get otg clock\n"); | 3521 | dev_err(dev, "cannot get otg clock\n"); |
3522 | return PTR_ERR(hsotg->clk); | 3522 | return PTR_ERR(hsotg->clk); |
@@ -3667,7 +3667,6 @@ err_supplies: | |||
3667 | 3667 | ||
3668 | err_clk: | 3668 | err_clk: |
3669 | clk_disable_unprepare(hsotg->clk); | 3669 | clk_disable_unprepare(hsotg->clk); |
3670 | clk_put(hsotg->clk); | ||
3671 | 3670 | ||
3672 | return ret; | 3671 | return ret; |
3673 | } | 3672 | } |
@@ -3693,7 +3692,6 @@ static int __devexit s3c_hsotg_remove(struct platform_device *pdev) | |||
3693 | regulator_bulk_free(ARRAY_SIZE(hsotg->supplies), hsotg->supplies); | 3692 | regulator_bulk_free(ARRAY_SIZE(hsotg->supplies), hsotg->supplies); |
3694 | 3693 | ||
3695 | clk_disable_unprepare(hsotg->clk); | 3694 | clk_disable_unprepare(hsotg->clk); |
3696 | clk_put(hsotg->clk); | ||
3697 | 3695 | ||
3698 | device_unregister(&hsotg->gadget.dev); | 3696 | device_unregister(&hsotg->gadget.dev); |
3699 | return 0; | 3697 | return 0; |
diff --git a/drivers/usb/gadget/s3c-hsudc.c b/drivers/usb/gadget/s3c-hsudc.c index e26a4e7ed2bf..d8e785d4ad59 100644 --- a/drivers/usb/gadget/s3c-hsudc.c +++ b/drivers/usb/gadget/s3c-hsudc.c | |||
@@ -135,7 +135,6 @@ struct s3c_hsudc_req { | |||
135 | * @dev: The device reference used by probe function. | 135 | * @dev: The device reference used by probe function. |
136 | * @lock: Lock to synchronize the usage of Endpoints (EP's are indexed). | 136 | * @lock: Lock to synchronize the usage of Endpoints (EP's are indexed). |
137 | * @regs: Remapped base address of controller's register space. | 137 | * @regs: Remapped base address of controller's register space. |
138 | * @mem_rsrc: Device memory resource used for remapping device register space. | ||
139 | * irq: IRQ number used by the controller. | 138 | * irq: IRQ number used by the controller. |
140 | * uclk: Reference to the controller clock. | 139 | * uclk: Reference to the controller clock. |
141 | * ep0state: Current state of EP0. | 140 | * ep0state: Current state of EP0. |
@@ -150,7 +149,6 @@ struct s3c_hsudc { | |||
150 | struct regulator_bulk_data supplies[ARRAY_SIZE(s3c_hsudc_supply_names)]; | 149 | struct regulator_bulk_data supplies[ARRAY_SIZE(s3c_hsudc_supply_names)]; |
151 | spinlock_t lock; | 150 | spinlock_t lock; |
152 | void __iomem *regs; | 151 | void __iomem *regs; |
153 | struct resource *mem_rsrc; | ||
154 | int irq; | 152 | int irq; |
155 | struct clk *uclk; | 153 | struct clk *uclk; |
156 | int ep0state; | 154 | int ep0state; |
@@ -835,9 +833,9 @@ static struct usb_request *s3c_hsudc_alloc_request(struct usb_ep *_ep, | |||
835 | { | 833 | { |
836 | struct s3c_hsudc_req *hsreq; | 834 | struct s3c_hsudc_req *hsreq; |
837 | 835 | ||
838 | hsreq = kzalloc(sizeof *hsreq, gfp_flags); | 836 | hsreq = kzalloc(sizeof(*hsreq), gfp_flags); |
839 | if (!hsreq) | 837 | if (!hsreq) |
840 | return 0; | 838 | return NULL; |
841 | 839 | ||
842 | INIT_LIST_HEAD(&hsreq->queue); | 840 | INIT_LIST_HEAD(&hsreq->queue); |
843 | return &hsreq->req; | 841 | return &hsreq->req; |
@@ -906,16 +904,16 @@ static int s3c_hsudc_queue(struct usb_ep *_ep, struct usb_request *_req, | |||
906 | csr = readl((u32)hsudc->regs + offset); | 904 | csr = readl((u32)hsudc->regs + offset); |
907 | if (!(csr & S3C_ESR_TX_SUCCESS) && | 905 | if (!(csr & S3C_ESR_TX_SUCCESS) && |
908 | (s3c_hsudc_write_fifo(hsep, hsreq) == 1)) | 906 | (s3c_hsudc_write_fifo(hsep, hsreq) == 1)) |
909 | hsreq = 0; | 907 | hsreq = NULL; |
910 | } else { | 908 | } else { |
911 | csr = readl((u32)hsudc->regs + offset); | 909 | csr = readl((u32)hsudc->regs + offset); |
912 | if ((csr & S3C_ESR_RX_SUCCESS) | 910 | if ((csr & S3C_ESR_RX_SUCCESS) |
913 | && (s3c_hsudc_read_fifo(hsep, hsreq) == 1)) | 911 | && (s3c_hsudc_read_fifo(hsep, hsreq) == 1)) |
914 | hsreq = 0; | 912 | hsreq = NULL; |
915 | } | 913 | } |
916 | } | 914 | } |
917 | 915 | ||
918 | if (hsreq != 0) | 916 | if (hsreq) |
919 | list_add_tail(&hsreq->queue, &hsep->queue); | 917 | list_add_tail(&hsreq->queue, &hsep->queue); |
920 | 918 | ||
921 | spin_unlock_irqrestore(&hsudc->lock, flags); | 919 | spin_unlock_irqrestore(&hsudc->lock, flags); |
@@ -1271,7 +1269,7 @@ static int __devinit s3c_hsudc_probe(struct platform_device *pdev) | |||
1271 | struct s3c24xx_hsudc_platdata *pd = pdev->dev.platform_data; | 1269 | struct s3c24xx_hsudc_platdata *pd = pdev->dev.platform_data; |
1272 | int ret, i; | 1270 | int ret, i; |
1273 | 1271 | ||
1274 | hsudc = kzalloc(sizeof(struct s3c_hsudc) + | 1272 | hsudc = devm_kzalloc(&pdev->dev, sizeof(struct s3c_hsudc) + |
1275 | sizeof(struct s3c_hsudc_ep) * pd->epnum, | 1273 | sizeof(struct s3c_hsudc_ep) * pd->epnum, |
1276 | GFP_KERNEL); | 1274 | GFP_KERNEL); |
1277 | if (!hsudc) { | 1275 | if (!hsudc) { |
@@ -1296,25 +1294,12 @@ static int __devinit s3c_hsudc_probe(struct platform_device *pdev) | |||
1296 | } | 1294 | } |
1297 | 1295 | ||
1298 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 1296 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
1299 | if (!res) { | ||
1300 | dev_err(dev, "unable to obtain driver resource data\n"); | ||
1301 | ret = -ENODEV; | ||
1302 | goto err_res; | ||
1303 | } | ||
1304 | |||
1305 | hsudc->mem_rsrc = request_mem_region(res->start, resource_size(res), | ||
1306 | dev_name(&pdev->dev)); | ||
1307 | if (!hsudc->mem_rsrc) { | ||
1308 | dev_err(dev, "failed to reserve register area\n"); | ||
1309 | ret = -ENODEV; | ||
1310 | goto err_res; | ||
1311 | } | ||
1312 | 1297 | ||
1313 | hsudc->regs = ioremap(res->start, resource_size(res)); | 1298 | hsudc->regs = devm_request_and_ioremap(&pdev->dev, res); |
1314 | if (!hsudc->regs) { | 1299 | if (!hsudc->regs) { |
1315 | dev_err(dev, "error mapping device register area\n"); | 1300 | dev_err(dev, "error mapping device register area\n"); |
1316 | ret = -EBUSY; | 1301 | ret = -EBUSY; |
1317 | goto err_remap; | 1302 | goto err_res; |
1318 | } | 1303 | } |
1319 | 1304 | ||
1320 | spin_lock_init(&hsudc->lock); | 1305 | spin_lock_init(&hsudc->lock); |
@@ -1337,21 +1322,22 @@ static int __devinit s3c_hsudc_probe(struct platform_device *pdev) | |||
1337 | ret = platform_get_irq(pdev, 0); | 1322 | ret = platform_get_irq(pdev, 0); |
1338 | if (ret < 0) { | 1323 | if (ret < 0) { |
1339 | dev_err(dev, "unable to obtain IRQ number\n"); | 1324 | dev_err(dev, "unable to obtain IRQ number\n"); |
1340 | goto err_irq; | 1325 | goto err_res; |
1341 | } | 1326 | } |
1342 | hsudc->irq = ret; | 1327 | hsudc->irq = ret; |
1343 | 1328 | ||
1344 | ret = request_irq(hsudc->irq, s3c_hsudc_irq, 0, driver_name, hsudc); | 1329 | ret = devm_request_irq(&pdev->dev, hsudc->irq, s3c_hsudc_irq, 0, |
1330 | driver_name, hsudc); | ||
1345 | if (ret < 0) { | 1331 | if (ret < 0) { |
1346 | dev_err(dev, "irq request failed\n"); | 1332 | dev_err(dev, "irq request failed\n"); |
1347 | goto err_irq; | 1333 | goto err_res; |
1348 | } | 1334 | } |
1349 | 1335 | ||
1350 | hsudc->uclk = clk_get(&pdev->dev, "usb-device"); | 1336 | hsudc->uclk = devm_clk_get(&pdev->dev, "usb-device"); |
1351 | if (IS_ERR(hsudc->uclk)) { | 1337 | if (IS_ERR(hsudc->uclk)) { |
1352 | dev_err(dev, "failed to find usb-device clock source\n"); | 1338 | dev_err(dev, "failed to find usb-device clock source\n"); |
1353 | ret = PTR_ERR(hsudc->uclk); | 1339 | ret = PTR_ERR(hsudc->uclk); |
1354 | goto err_clk; | 1340 | goto err_res; |
1355 | } | 1341 | } |
1356 | clk_enable(hsudc->uclk); | 1342 | clk_enable(hsudc->uclk); |
1357 | 1343 | ||
@@ -1377,21 +1363,12 @@ err_add_udc: | |||
1377 | device_unregister(&hsudc->gadget.dev); | 1363 | device_unregister(&hsudc->gadget.dev); |
1378 | err_add_device: | 1364 | err_add_device: |
1379 | clk_disable(hsudc->uclk); | 1365 | clk_disable(hsudc->uclk); |
1380 | clk_put(hsudc->uclk); | ||
1381 | err_clk: | ||
1382 | free_irq(hsudc->irq, hsudc); | ||
1383 | err_irq: | ||
1384 | iounmap(hsudc->regs); | ||
1385 | |||
1386 | err_remap: | ||
1387 | release_mem_region(res->start, resource_size(res)); | ||
1388 | err_res: | 1366 | err_res: |
1389 | if (!IS_ERR_OR_NULL(hsudc->transceiver)) | 1367 | if (!IS_ERR_OR_NULL(hsudc->transceiver)) |
1390 | usb_put_phy(hsudc->transceiver); | 1368 | usb_put_phy(hsudc->transceiver); |
1391 | 1369 | ||
1392 | regulator_bulk_free(ARRAY_SIZE(hsudc->supplies), hsudc->supplies); | 1370 | regulator_bulk_free(ARRAY_SIZE(hsudc->supplies), hsudc->supplies); |
1393 | err_supplies: | 1371 | err_supplies: |
1394 | kfree(hsudc); | ||
1395 | return ret; | 1372 | return ret; |
1396 | } | 1373 | } |
1397 | 1374 | ||
diff --git a/drivers/usb/gadget/s3c2410_udc.c b/drivers/usb/gadget/s3c2410_udc.c index f2e51f50e528..c33e942d119c 100644 --- a/drivers/usb/gadget/s3c2410_udc.c +++ b/drivers/usb/gadget/s3c2410_udc.c | |||
@@ -12,6 +12,8 @@ | |||
12 | * (at your option) any later version. | 12 | * (at your option) any later version. |
13 | */ | 13 | */ |
14 | 14 | ||
15 | #define pr_fmt(fmt) "s3c2410_udc: " fmt | ||
16 | |||
15 | #include <linux/module.h> | 17 | #include <linux/module.h> |
16 | #include <linux/kernel.h> | 18 | #include <linux/kernel.h> |
17 | #include <linux/delay.h> | 19 | #include <linux/delay.h> |
@@ -27,6 +29,7 @@ | |||
27 | #include <linux/clk.h> | 29 | #include <linux/clk.h> |
28 | #include <linux/gpio.h> | 30 | #include <linux/gpio.h> |
29 | #include <linux/prefetch.h> | 31 | #include <linux/prefetch.h> |
32 | #include <linux/io.h> | ||
30 | 33 | ||
31 | #include <linux/debugfs.h> | 34 | #include <linux/debugfs.h> |
32 | #include <linux/seq_file.h> | 35 | #include <linux/seq_file.h> |
@@ -35,7 +38,6 @@ | |||
35 | #include <linux/usb/gadget.h> | 38 | #include <linux/usb/gadget.h> |
36 | 39 | ||
37 | #include <asm/byteorder.h> | 40 | #include <asm/byteorder.h> |
38 | #include <asm/io.h> | ||
39 | #include <asm/irq.h> | 41 | #include <asm/irq.h> |
40 | #include <asm/unaligned.h> | 42 | #include <asm/unaligned.h> |
41 | #include <mach/irqs.h> | 43 | #include <mach/irqs.h> |
@@ -115,7 +117,7 @@ static int dprintk(int level, const char *fmt, ...) | |||
115 | sizeof(printk_buf)-len, fmt, args); | 117 | sizeof(printk_buf)-len, fmt, args); |
116 | va_end(args); | 118 | va_end(args); |
117 | 119 | ||
118 | return printk(KERN_DEBUG "%s", printk_buf); | 120 | return pr_debug("%s", printk_buf); |
119 | } | 121 | } |
120 | #else | 122 | #else |
121 | static int dprintk(int level, const char *fmt, ...) | 123 | static int dprintk(int level, const char *fmt, ...) |
@@ -125,10 +127,10 @@ static int dprintk(int level, const char *fmt, ...) | |||
125 | #endif | 127 | #endif |
126 | static int s3c2410_udc_debugfs_seq_show(struct seq_file *m, void *p) | 128 | static int s3c2410_udc_debugfs_seq_show(struct seq_file *m, void *p) |
127 | { | 129 | { |
128 | u32 addr_reg,pwr_reg,ep_int_reg,usb_int_reg; | 130 | u32 addr_reg, pwr_reg, ep_int_reg, usb_int_reg; |
129 | u32 ep_int_en_reg, usb_int_en_reg, ep0_csr; | 131 | u32 ep_int_en_reg, usb_int_en_reg, ep0_csr; |
130 | u32 ep1_i_csr1,ep1_i_csr2,ep1_o_csr1,ep1_o_csr2; | 132 | u32 ep1_i_csr1, ep1_i_csr2, ep1_o_csr1, ep1_o_csr2; |
131 | u32 ep2_i_csr1,ep2_i_csr2,ep2_o_csr1,ep2_o_csr2; | 133 | u32 ep2_i_csr1, ep2_i_csr2, ep2_o_csr1, ep2_o_csr2; |
132 | 134 | ||
133 | addr_reg = udc_read(S3C2410_UDC_FUNC_ADDR_REG); | 135 | addr_reg = udc_read(S3C2410_UDC_FUNC_ADDR_REG); |
134 | pwr_reg = udc_read(S3C2410_UDC_PWR_REG); | 136 | pwr_reg = udc_read(S3C2410_UDC_PWR_REG); |
@@ -164,10 +166,10 @@ static int s3c2410_udc_debugfs_seq_show(struct seq_file *m, void *p) | |||
164 | "EP2_I_CSR2 : 0x%04X\n" | 166 | "EP2_I_CSR2 : 0x%04X\n" |
165 | "EP2_O_CSR1 : 0x%04X\n" | 167 | "EP2_O_CSR1 : 0x%04X\n" |
166 | "EP2_O_CSR2 : 0x%04X\n", | 168 | "EP2_O_CSR2 : 0x%04X\n", |
167 | addr_reg,pwr_reg,ep_int_reg,usb_int_reg, | 169 | addr_reg, pwr_reg, ep_int_reg, usb_int_reg, |
168 | ep_int_en_reg, usb_int_en_reg, ep0_csr, | 170 | ep_int_en_reg, usb_int_en_reg, ep0_csr, |
169 | ep1_i_csr1,ep1_i_csr2,ep1_o_csr1,ep1_o_csr2, | 171 | ep1_i_csr1, ep1_i_csr2, ep1_o_csr1, ep1_o_csr2, |
170 | ep2_i_csr1,ep2_i_csr2,ep2_o_csr1,ep2_o_csr2 | 172 | ep2_i_csr1, ep2_i_csr2, ep2_o_csr1, ep2_o_csr2 |
171 | ); | 173 | ); |
172 | 174 | ||
173 | return 0; | 175 | return 0; |
@@ -230,7 +232,7 @@ static inline void s3c2410_udc_set_ep0_de_out(void __iomem *base) | |||
230 | { | 232 | { |
231 | udc_writeb(base, S3C2410_UDC_INDEX_EP0, S3C2410_UDC_INDEX_REG); | 233 | udc_writeb(base, S3C2410_UDC_INDEX_EP0, S3C2410_UDC_INDEX_REG); |
232 | 234 | ||
233 | udc_writeb(base,(S3C2410_UDC_EP0_CSR_SOPKTRDY | 235 | udc_writeb(base, (S3C2410_UDC_EP0_CSR_SOPKTRDY |
234 | | S3C2410_UDC_EP0_CSR_DE), | 236 | | S3C2410_UDC_EP0_CSR_DE), |
235 | S3C2410_UDC_EP0_CSR_REG); | 237 | S3C2410_UDC_EP0_CSR_REG); |
236 | } | 238 | } |
@@ -263,7 +265,7 @@ static void s3c2410_udc_done(struct s3c2410_ep *ep, | |||
263 | 265 | ||
264 | list_del_init(&req->queue); | 266 | list_del_init(&req->queue); |
265 | 267 | ||
266 | if (likely (req->req.status == -EINPROGRESS)) | 268 | if (likely(req->req.status == -EINPROGRESS)) |
267 | req->req.status = status; | 269 | req->req.status = status; |
268 | else | 270 | else |
269 | status = req->req.status; | 271 | status = req->req.status; |
@@ -280,9 +282,9 @@ static void s3c2410_udc_nuke(struct s3c2410_udc *udc, | |||
280 | if (&ep->queue == NULL) | 282 | if (&ep->queue == NULL) |
281 | return; | 283 | return; |
282 | 284 | ||
283 | while (!list_empty (&ep->queue)) { | 285 | while (!list_empty(&ep->queue)) { |
284 | struct s3c2410_request *req; | 286 | struct s3c2410_request *req; |
285 | req = list_entry (ep->queue.next, struct s3c2410_request, | 287 | req = list_entry(ep->queue.next, struct s3c2410_request, |
286 | queue); | 288 | queue); |
287 | s3c2410_udc_done(ep, req, status); | 289 | s3c2410_udc_done(ep, req, status); |
288 | } | 290 | } |
@@ -389,10 +391,10 @@ static int s3c2410_udc_write_fifo(struct s3c2410_ep *ep, | |||
389 | 391 | ||
390 | if (idx == 0) { | 392 | if (idx == 0) { |
391 | /* Reset signal => no need to say 'data sent' */ | 393 | /* Reset signal => no need to say 'data sent' */ |
392 | if (! (udc_read(S3C2410_UDC_USB_INT_REG) | 394 | if (!(udc_read(S3C2410_UDC_USB_INT_REG) |
393 | & S3C2410_UDC_USBINT_RESET)) | 395 | & S3C2410_UDC_USBINT_RESET)) |
394 | s3c2410_udc_set_ep0_de_in(base_addr); | 396 | s3c2410_udc_set_ep0_de_in(base_addr); |
395 | ep->dev->ep0state=EP0_IDLE; | 397 | ep->dev->ep0state = EP0_IDLE; |
396 | } else { | 398 | } else { |
397 | udc_write(idx, S3C2410_UDC_INDEX_REG); | 399 | udc_write(idx, S3C2410_UDC_INDEX_REG); |
398 | ep_csr = udc_read(S3C2410_UDC_IN_CSR1_REG); | 400 | ep_csr = udc_read(S3C2410_UDC_IN_CSR1_REG); |
@@ -406,7 +408,7 @@ static int s3c2410_udc_write_fifo(struct s3c2410_ep *ep, | |||
406 | } else { | 408 | } else { |
407 | if (idx == 0) { | 409 | if (idx == 0) { |
408 | /* Reset signal => no need to say 'data sent' */ | 410 | /* Reset signal => no need to say 'data sent' */ |
409 | if (! (udc_read(S3C2410_UDC_USB_INT_REG) | 411 | if (!(udc_read(S3C2410_UDC_USB_INT_REG) |
410 | & S3C2410_UDC_USBINT_RESET)) | 412 | & S3C2410_UDC_USBINT_RESET)) |
411 | s3c2410_udc_set_ep0_ipr(base_addr); | 413 | s3c2410_udc_set_ep0_ipr(base_addr); |
412 | } else { | 414 | } else { |
@@ -442,7 +444,7 @@ static int s3c2410_udc_read_fifo(struct s3c2410_ep *ep, | |||
442 | u8 *buf; | 444 | u8 *buf; |
443 | u32 ep_csr; | 445 | u32 ep_csr; |
444 | unsigned bufferspace; | 446 | unsigned bufferspace; |
445 | int is_last=1; | 447 | int is_last = 1; |
446 | unsigned avail; | 448 | unsigned avail; |
447 | int fifo_count = 0; | 449 | int fifo_count = 0; |
448 | u32 idx; | 450 | u32 idx; |
@@ -510,7 +512,7 @@ static int s3c2410_udc_read_fifo(struct s3c2410_ep *ep, | |||
510 | /* Only ep0 debug messages are interesting */ | 512 | /* Only ep0 debug messages are interesting */ |
511 | if (idx == 0) | 513 | if (idx == 0) |
512 | dprintk(DEBUG_VERBOSE, "%s fifo count : %d [last %d]\n", | 514 | dprintk(DEBUG_VERBOSE, "%s fifo count : %d [last %d]\n", |
513 | __func__, fifo_count,is_last); | 515 | __func__, fifo_count, is_last); |
514 | 516 | ||
515 | if (is_last) { | 517 | if (is_last) { |
516 | if (idx == 0) { | 518 | if (idx == 0) { |
@@ -542,7 +544,7 @@ static int s3c2410_udc_read_fifo(struct s3c2410_ep *ep, | |||
542 | 544 | ||
543 | static int s3c2410_udc_read_fifo_crq(struct usb_ctrlrequest *crq) | 545 | static int s3c2410_udc_read_fifo_crq(struct usb_ctrlrequest *crq) |
544 | { | 546 | { |
545 | unsigned char *outbuf = (unsigned char*)crq; | 547 | unsigned char *outbuf = (unsigned char *)crq; |
546 | int bytes_read = 0; | 548 | int bytes_read = 0; |
547 | 549 | ||
548 | udc_write(0, S3C2410_UDC_INDEX_REG); | 550 | udc_write(0, S3C2410_UDC_INDEX_REG); |
@@ -648,7 +650,7 @@ static void s3c2410_udc_handle_ep0_idle(struct s3c2410_udc *dev, | |||
648 | 650 | ||
649 | switch (crq->bRequest) { | 651 | switch (crq->bRequest) { |
650 | case USB_REQ_SET_CONFIGURATION: | 652 | case USB_REQ_SET_CONFIGURATION: |
651 | dprintk(DEBUG_NORMAL, "USB_REQ_SET_CONFIGURATION ... \n"); | 653 | dprintk(DEBUG_NORMAL, "USB_REQ_SET_CONFIGURATION ...\n"); |
652 | 654 | ||
653 | if (crq->bRequestType == USB_RECIP_DEVICE) { | 655 | if (crq->bRequestType == USB_RECIP_DEVICE) { |
654 | dev->req_config = 1; | 656 | dev->req_config = 1; |
@@ -657,7 +659,7 @@ static void s3c2410_udc_handle_ep0_idle(struct s3c2410_udc *dev, | |||
657 | break; | 659 | break; |
658 | 660 | ||
659 | case USB_REQ_SET_INTERFACE: | 661 | case USB_REQ_SET_INTERFACE: |
660 | dprintk(DEBUG_NORMAL, "USB_REQ_SET_INTERFACE ... \n"); | 662 | dprintk(DEBUG_NORMAL, "USB_REQ_SET_INTERFACE ...\n"); |
661 | 663 | ||
662 | if (crq->bRequestType == USB_RECIP_INTERFACE) { | 664 | if (crq->bRequestType == USB_RECIP_INTERFACE) { |
663 | dev->req_config = 1; | 665 | dev->req_config = 1; |
@@ -666,7 +668,7 @@ static void s3c2410_udc_handle_ep0_idle(struct s3c2410_udc *dev, | |||
666 | break; | 668 | break; |
667 | 669 | ||
668 | case USB_REQ_SET_ADDRESS: | 670 | case USB_REQ_SET_ADDRESS: |
669 | dprintk(DEBUG_NORMAL, "USB_REQ_SET_ADDRESS ... \n"); | 671 | dprintk(DEBUG_NORMAL, "USB_REQ_SET_ADDRESS ...\n"); |
670 | 672 | ||
671 | if (crq->bRequestType == USB_RECIP_DEVICE) { | 673 | if (crq->bRequestType == USB_RECIP_DEVICE) { |
672 | tmp = crq->wValue & 0x7F; | 674 | tmp = crq->wValue & 0x7F; |
@@ -679,13 +681,12 @@ static void s3c2410_udc_handle_ep0_idle(struct s3c2410_udc *dev, | |||
679 | break; | 681 | break; |
680 | 682 | ||
681 | case USB_REQ_GET_STATUS: | 683 | case USB_REQ_GET_STATUS: |
682 | dprintk(DEBUG_NORMAL, "USB_REQ_GET_STATUS ... \n"); | 684 | dprintk(DEBUG_NORMAL, "USB_REQ_GET_STATUS ...\n"); |
683 | s3c2410_udc_clear_ep0_opr(base_addr); | 685 | s3c2410_udc_clear_ep0_opr(base_addr); |
684 | 686 | ||
685 | if (dev->req_std) { | 687 | if (dev->req_std) { |
686 | if (!s3c2410_udc_get_status(dev, crq)) { | 688 | if (!s3c2410_udc_get_status(dev, crq)) |
687 | return; | 689 | return; |
688 | } | ||
689 | } | 690 | } |
690 | break; | 691 | break; |
691 | 692 | ||
@@ -750,7 +751,7 @@ static void s3c2410_udc_handle_ep0_idle(struct s3c2410_udc *dev, | |||
750 | /* deferred i/o == no response yet */ | 751 | /* deferred i/o == no response yet */ |
751 | } else if (dev->req_pending) { | 752 | } else if (dev->req_pending) { |
752 | dprintk(DEBUG_VERBOSE, "dev->req_pending... what now?\n"); | 753 | dprintk(DEBUG_VERBOSE, "dev->req_pending... what now?\n"); |
753 | dev->req_pending=0; | 754 | dev->req_pending = 0; |
754 | } | 755 | } |
755 | 756 | ||
756 | dprintk(DEBUG_VERBOSE, "ep0state %s\n", ep0states[dev->ep0state]); | 757 | dprintk(DEBUG_VERBOSE, "ep0state %s\n", ep0states[dev->ep0state]); |
@@ -801,16 +802,14 @@ static void s3c2410_udc_handle_ep0(struct s3c2410_udc *dev) | |||
801 | 802 | ||
802 | case EP0_IN_DATA_PHASE: /* GET_DESCRIPTOR etc */ | 803 | case EP0_IN_DATA_PHASE: /* GET_DESCRIPTOR etc */ |
803 | dprintk(DEBUG_NORMAL, "EP0_IN_DATA_PHASE ... what now?\n"); | 804 | dprintk(DEBUG_NORMAL, "EP0_IN_DATA_PHASE ... what now?\n"); |
804 | if (!(ep0csr & S3C2410_UDC_EP0_CSR_IPKRDY) && req) { | 805 | if (!(ep0csr & S3C2410_UDC_EP0_CSR_IPKRDY) && req) |
805 | s3c2410_udc_write_fifo(ep, req); | 806 | s3c2410_udc_write_fifo(ep, req); |
806 | } | ||
807 | break; | 807 | break; |
808 | 808 | ||
809 | case EP0_OUT_DATA_PHASE: /* SET_DESCRIPTOR etc */ | 809 | case EP0_OUT_DATA_PHASE: /* SET_DESCRIPTOR etc */ |
810 | dprintk(DEBUG_NORMAL, "EP0_OUT_DATA_PHASE ... what now?\n"); | 810 | dprintk(DEBUG_NORMAL, "EP0_OUT_DATA_PHASE ... what now?\n"); |
811 | if ((ep0csr & S3C2410_UDC_EP0_CSR_OPKRDY) && req ) { | 811 | if ((ep0csr & S3C2410_UDC_EP0_CSR_OPKRDY) && req) |
812 | s3c2410_udc_read_fifo(ep,req); | 812 | s3c2410_udc_read_fifo(ep, req); |
813 | } | ||
814 | break; | 813 | break; |
815 | 814 | ||
816 | case EP0_END_XFER: | 815 | case EP0_END_XFER: |
@@ -836,7 +835,7 @@ static void s3c2410_udc_handle_ep(struct s3c2410_ep *ep) | |||
836 | u32 ep_csr1; | 835 | u32 ep_csr1; |
837 | u32 idx; | 836 | u32 idx; |
838 | 837 | ||
839 | if (likely (!list_empty(&ep->queue))) | 838 | if (likely(!list_empty(&ep->queue))) |
840 | req = list_entry(ep->queue.next, | 839 | req = list_entry(ep->queue.next, |
841 | struct s3c2410_request, queue); | 840 | struct s3c2410_request, queue); |
842 | else | 841 | else |
@@ -858,9 +857,8 @@ static void s3c2410_udc_handle_ep(struct s3c2410_ep *ep) | |||
858 | return; | 857 | return; |
859 | } | 858 | } |
860 | 859 | ||
861 | if (!(ep_csr1 & S3C2410_UDC_ICSR1_PKTRDY) && req) { | 860 | if (!(ep_csr1 & S3C2410_UDC_ICSR1_PKTRDY) && req) |
862 | s3c2410_udc_write_fifo(ep,req); | 861 | s3c2410_udc_write_fifo(ep, req); |
863 | } | ||
864 | } else { | 862 | } else { |
865 | udc_write(idx, S3C2410_UDC_INDEX_REG); | 863 | udc_write(idx, S3C2410_UDC_INDEX_REG); |
866 | ep_csr1 = udc_read(S3C2410_UDC_OUT_CSR1_REG); | 864 | ep_csr1 = udc_read(S3C2410_UDC_OUT_CSR1_REG); |
@@ -873,9 +871,8 @@ static void s3c2410_udc_handle_ep(struct s3c2410_ep *ep) | |||
873 | return; | 871 | return; |
874 | } | 872 | } |
875 | 873 | ||
876 | if ((ep_csr1 & S3C2410_UDC_OCSR1_PKTRDY) && req) { | 874 | if ((ep_csr1 & S3C2410_UDC_OCSR1_PKTRDY) && req) |
877 | s3c2410_udc_read_fifo(ep,req); | 875 | s3c2410_udc_read_fifo(ep, req); |
878 | } | ||
879 | } | 876 | } |
880 | } | 877 | } |
881 | 878 | ||
@@ -1057,7 +1054,7 @@ static int s3c2410_udc_ep_enable(struct usb_ep *_ep, | |||
1057 | struct s3c2410_ep *ep; | 1054 | struct s3c2410_ep *ep; |
1058 | u32 max, tmp; | 1055 | u32 max, tmp; |
1059 | unsigned long flags; | 1056 | unsigned long flags; |
1060 | u32 csr1,csr2; | 1057 | u32 csr1, csr2; |
1061 | u32 int_en_reg; | 1058 | u32 int_en_reg; |
1062 | 1059 | ||
1063 | ep = to_s3c2410_ep(_ep); | 1060 | ep = to_s3c2410_ep(_ep); |
@@ -1073,7 +1070,7 @@ static int s3c2410_udc_ep_enable(struct usb_ep *_ep, | |||
1073 | 1070 | ||
1074 | max = usb_endpoint_maxp(desc) & 0x1fff; | 1071 | max = usb_endpoint_maxp(desc) & 0x1fff; |
1075 | 1072 | ||
1076 | local_irq_save (flags); | 1073 | local_irq_save(flags); |
1077 | _ep->maxpacket = max & 0x7ff; | 1074 | _ep->maxpacket = max & 0x7ff; |
1078 | ep->ep.desc = desc; | 1075 | ep->ep.desc = desc; |
1079 | ep->halted = 0; | 1076 | ep->halted = 0; |
@@ -1117,11 +1114,11 @@ static int s3c2410_udc_ep_enable(struct usb_ep *_ep, | |||
1117 | 1114 | ||
1118 | /* print some debug message */ | 1115 | /* print some debug message */ |
1119 | tmp = desc->bEndpointAddress; | 1116 | tmp = desc->bEndpointAddress; |
1120 | dprintk (DEBUG_NORMAL, "enable %s(%d) ep%x%s-blk max %02x\n", | 1117 | dprintk(DEBUG_NORMAL, "enable %s(%d) ep%x%s-blk max %02x\n", |
1121 | _ep->name,ep->num, tmp, | 1118 | _ep->name, ep->num, tmp, |
1122 | desc->bEndpointAddress & USB_DIR_IN ? "in" : "out", max); | 1119 | desc->bEndpointAddress & USB_DIR_IN ? "in" : "out", max); |
1123 | 1120 | ||
1124 | local_irq_restore (flags); | 1121 | local_irq_restore(flags); |
1125 | s3c2410_udc_set_halt(_ep, 0); | 1122 | s3c2410_udc_set_halt(_ep, 0); |
1126 | 1123 | ||
1127 | return 0; | 1124 | return 0; |
@@ -1149,7 +1146,7 @@ static int s3c2410_udc_ep_disable(struct usb_ep *_ep) | |||
1149 | ep->ep.desc = NULL; | 1146 | ep->ep.desc = NULL; |
1150 | ep->halted = 1; | 1147 | ep->halted = 1; |
1151 | 1148 | ||
1152 | s3c2410_udc_nuke (ep->dev, ep, -ESHUTDOWN); | 1149 | s3c2410_udc_nuke(ep->dev, ep, -ESHUTDOWN); |
1153 | 1150 | ||
1154 | /* disable irqs */ | 1151 | /* disable irqs */ |
1155 | int_en_reg = udc_read(S3C2410_UDC_EP_INT_EN_REG); | 1152 | int_en_reg = udc_read(S3C2410_UDC_EP_INT_EN_REG); |
@@ -1170,16 +1167,16 @@ s3c2410_udc_alloc_request(struct usb_ep *_ep, gfp_t mem_flags) | |||
1170 | { | 1167 | { |
1171 | struct s3c2410_request *req; | 1168 | struct s3c2410_request *req; |
1172 | 1169 | ||
1173 | dprintk(DEBUG_VERBOSE,"%s(%p,%d)\n", __func__, _ep, mem_flags); | 1170 | dprintk(DEBUG_VERBOSE, "%s(%p,%d)\n", __func__, _ep, mem_flags); |
1174 | 1171 | ||
1175 | if (!_ep) | 1172 | if (!_ep) |
1176 | return NULL; | 1173 | return NULL; |
1177 | 1174 | ||
1178 | req = kzalloc (sizeof(struct s3c2410_request), mem_flags); | 1175 | req = kzalloc(sizeof(struct s3c2410_request), mem_flags); |
1179 | if (!req) | 1176 | if (!req) |
1180 | return NULL; | 1177 | return NULL; |
1181 | 1178 | ||
1182 | INIT_LIST_HEAD (&req->queue); | 1179 | INIT_LIST_HEAD(&req->queue); |
1183 | return &req->req; | 1180 | return &req->req; |
1184 | } | 1181 | } |
1185 | 1182 | ||
@@ -1197,7 +1194,7 @@ s3c2410_udc_free_request(struct usb_ep *_ep, struct usb_request *_req) | |||
1197 | if (!ep || !_req || (!ep->ep.desc && _ep->name != ep0name)) | 1194 | if (!ep || !_req || (!ep->ep.desc && _ep->name != ep0name)) |
1198 | return; | 1195 | return; |
1199 | 1196 | ||
1200 | WARN_ON (!list_empty (&req->queue)); | 1197 | WARN_ON(!list_empty(&req->queue)); |
1201 | kfree(req); | 1198 | kfree(req); |
1202 | } | 1199 | } |
1203 | 1200 | ||
@@ -1220,12 +1217,12 @@ static int s3c2410_udc_queue(struct usb_ep *_ep, struct usb_request *_req, | |||
1220 | } | 1217 | } |
1221 | 1218 | ||
1222 | dev = ep->dev; | 1219 | dev = ep->dev; |
1223 | if (unlikely (!dev->driver | 1220 | if (unlikely(!dev->driver |
1224 | || dev->gadget.speed == USB_SPEED_UNKNOWN)) { | 1221 | || dev->gadget.speed == USB_SPEED_UNKNOWN)) { |
1225 | return -ESHUTDOWN; | 1222 | return -ESHUTDOWN; |
1226 | } | 1223 | } |
1227 | 1224 | ||
1228 | local_irq_save (flags); | 1225 | local_irq_save(flags); |
1229 | 1226 | ||
1230 | if (unlikely(!_req || !_req->complete | 1227 | if (unlikely(!_req || !_req->complete |
1231 | || !_req->buf || !list_empty(&req->queue))) { | 1228 | || !_req->buf || !list_empty(&req->queue))) { |
@@ -1233,7 +1230,7 @@ static int s3c2410_udc_queue(struct usb_ep *_ep, struct usb_request *_req, | |||
1233 | dprintk(DEBUG_NORMAL, "%s: 1 X X X\n", __func__); | 1230 | dprintk(DEBUG_NORMAL, "%s: 1 X X X\n", __func__); |
1234 | else { | 1231 | else { |
1235 | dprintk(DEBUG_NORMAL, "%s: 0 %01d %01d %01d\n", | 1232 | dprintk(DEBUG_NORMAL, "%s: 0 %01d %01d %01d\n", |
1236 | __func__, !_req->complete,!_req->buf, | 1233 | __func__, !_req->complete, !_req->buf, |
1237 | !list_empty(&req->queue)); | 1234 | !list_empty(&req->queue)); |
1238 | } | 1235 | } |
1239 | 1236 | ||
@@ -1299,7 +1296,7 @@ static int s3c2410_udc_queue(struct usb_ep *_ep, struct usb_request *_req, | |||
1299 | } | 1296 | } |
1300 | 1297 | ||
1301 | /* pio or dma irq handler advances the queue. */ | 1298 | /* pio or dma irq handler advances the queue. */ |
1302 | if (likely (req != 0)) | 1299 | if (likely(req)) |
1303 | list_add_tail(&req->queue, &ep->queue); | 1300 | list_add_tail(&req->queue, &ep->queue); |
1304 | 1301 | ||
1305 | local_irq_restore(flags); | 1302 | local_irq_restore(flags); |
@@ -1329,11 +1326,11 @@ static int s3c2410_udc_dequeue(struct usb_ep *_ep, struct usb_request *_req) | |||
1329 | 1326 | ||
1330 | udc = to_s3c2410_udc(ep->gadget); | 1327 | udc = to_s3c2410_udc(ep->gadget); |
1331 | 1328 | ||
1332 | local_irq_save (flags); | 1329 | local_irq_save(flags); |
1333 | 1330 | ||
1334 | list_for_each_entry (req, &ep->queue, queue) { | 1331 | list_for_each_entry(req, &ep->queue, queue) { |
1335 | if (&req->req == _req) { | 1332 | if (&req->req == _req) { |
1336 | list_del_init (&req->queue); | 1333 | list_del_init(&req->queue); |
1337 | _req->status = -ECONNRESET; | 1334 | _req->status = -ECONNRESET; |
1338 | retval = 0; | 1335 | retval = 0; |
1339 | break; | 1336 | break; |
@@ -1348,7 +1345,7 @@ static int s3c2410_udc_dequeue(struct usb_ep *_ep, struct usb_request *_req) | |||
1348 | s3c2410_udc_done(ep, req, -ECONNRESET); | 1345 | s3c2410_udc_done(ep, req, -ECONNRESET); |
1349 | } | 1346 | } |
1350 | 1347 | ||
1351 | local_irq_restore (flags); | 1348 | local_irq_restore(flags); |
1352 | return retval; | 1349 | return retval; |
1353 | } | 1350 | } |
1354 | 1351 | ||
@@ -1367,7 +1364,7 @@ static int s3c2410_udc_set_halt(struct usb_ep *_ep, int value) | |||
1367 | return -EINVAL; | 1364 | return -EINVAL; |
1368 | } | 1365 | } |
1369 | 1366 | ||
1370 | local_irq_save (flags); | 1367 | local_irq_save(flags); |
1371 | 1368 | ||
1372 | idx = ep->bEndpointAddress & 0x7F; | 1369 | idx = ep->bEndpointAddress & 0x7F; |
1373 | 1370 | ||
@@ -1376,7 +1373,7 @@ static int s3c2410_udc_set_halt(struct usb_ep *_ep, int value) | |||
1376 | s3c2410_udc_set_ep0_de_out(base_addr); | 1373 | s3c2410_udc_set_ep0_de_out(base_addr); |
1377 | } else { | 1374 | } else { |
1378 | udc_write(idx, S3C2410_UDC_INDEX_REG); | 1375 | udc_write(idx, S3C2410_UDC_INDEX_REG); |
1379 | ep_csr = udc_read((ep->bEndpointAddress &USB_DIR_IN) | 1376 | ep_csr = udc_read((ep->bEndpointAddress & USB_DIR_IN) |
1380 | ? S3C2410_UDC_IN_CSR1_REG | 1377 | ? S3C2410_UDC_IN_CSR1_REG |
1381 | : S3C2410_UDC_OUT_CSR1_REG); | 1378 | : S3C2410_UDC_OUT_CSR1_REG); |
1382 | 1379 | ||
@@ -1404,7 +1401,7 @@ static int s3c2410_udc_set_halt(struct usb_ep *_ep, int value) | |||
1404 | } | 1401 | } |
1405 | 1402 | ||
1406 | ep->halted = value ? 1 : 0; | 1403 | ep->halted = value ? 1 : 0; |
1407 | local_irq_restore (flags); | 1404 | local_irq_restore(flags); |
1408 | 1405 | ||
1409 | return 0; | 1406 | return 0; |
1410 | } | 1407 | } |
@@ -1484,9 +1481,9 @@ static int s3c2410_udc_set_pullup(struct s3c2410_udc *udc, int is_on) | |||
1484 | } | 1481 | } |
1485 | s3c2410_udc_disable(udc); | 1482 | s3c2410_udc_disable(udc); |
1486 | } | 1483 | } |
1487 | } | 1484 | } else { |
1488 | else | ||
1489 | return -EOPNOTSUPP; | 1485 | return -EOPNOTSUPP; |
1486 | } | ||
1490 | 1487 | ||
1491 | return 0; | 1488 | return 0; |
1492 | } | 1489 | } |
@@ -1542,7 +1539,7 @@ static int s3c2410_vbus_draw(struct usb_gadget *_gadget, unsigned ma) | |||
1542 | } | 1539 | } |
1543 | 1540 | ||
1544 | static int s3c2410_udc_start(struct usb_gadget_driver *driver, | 1541 | static int s3c2410_udc_start(struct usb_gadget_driver *driver, |
1545 | int (*bind)(struct usb_gadget *)); | 1542 | int (*bind)(struct usb_gadget *, struct usb_gadget_driver *)); |
1546 | static int s3c2410_udc_stop(struct usb_gadget_driver *driver); | 1543 | static int s3c2410_udc_stop(struct usb_gadget_driver *driver); |
1547 | 1544 | ||
1548 | static const struct usb_gadget_ops s3c2410_ops = { | 1545 | static const struct usb_gadget_ops s3c2410_ops = { |
@@ -1617,20 +1614,20 @@ static void s3c2410_udc_reinit(struct s3c2410_udc *dev) | |||
1617 | u32 i; | 1614 | u32 i; |
1618 | 1615 | ||
1619 | /* device/ep0 records init */ | 1616 | /* device/ep0 records init */ |
1620 | INIT_LIST_HEAD (&dev->gadget.ep_list); | 1617 | INIT_LIST_HEAD(&dev->gadget.ep_list); |
1621 | INIT_LIST_HEAD (&dev->gadget.ep0->ep_list); | 1618 | INIT_LIST_HEAD(&dev->gadget.ep0->ep_list); |
1622 | dev->ep0state = EP0_IDLE; | 1619 | dev->ep0state = EP0_IDLE; |
1623 | 1620 | ||
1624 | for (i = 0; i < S3C2410_ENDPOINTS; i++) { | 1621 | for (i = 0; i < S3C2410_ENDPOINTS; i++) { |
1625 | struct s3c2410_ep *ep = &dev->ep[i]; | 1622 | struct s3c2410_ep *ep = &dev->ep[i]; |
1626 | 1623 | ||
1627 | if (i != 0) | 1624 | if (i != 0) |
1628 | list_add_tail (&ep->ep.ep_list, &dev->gadget.ep_list); | 1625 | list_add_tail(&ep->ep.ep_list, &dev->gadget.ep_list); |
1629 | 1626 | ||
1630 | ep->dev = dev; | 1627 | ep->dev = dev; |
1631 | ep->ep.desc = NULL; | 1628 | ep->ep.desc = NULL; |
1632 | ep->halted = 0; | 1629 | ep->halted = 0; |
1633 | INIT_LIST_HEAD (&ep->queue); | 1630 | INIT_LIST_HEAD(&ep->queue); |
1634 | } | 1631 | } |
1635 | } | 1632 | } |
1636 | 1633 | ||
@@ -1668,7 +1665,7 @@ static void s3c2410_udc_enable(struct s3c2410_udc *dev) | |||
1668 | } | 1665 | } |
1669 | 1666 | ||
1670 | static int s3c2410_udc_start(struct usb_gadget_driver *driver, | 1667 | static int s3c2410_udc_start(struct usb_gadget_driver *driver, |
1671 | int (*bind)(struct usb_gadget *)) | 1668 | int (*bind)(struct usb_gadget *, struct usb_gadget_driver *)) |
1672 | { | 1669 | { |
1673 | struct s3c2410_udc *udc = the_controller; | 1670 | struct s3c2410_udc *udc = the_controller; |
1674 | int retval; | 1671 | int retval; |
@@ -1683,13 +1680,13 @@ static int s3c2410_udc_start(struct usb_gadget_driver *driver, | |||
1683 | return -EBUSY; | 1680 | return -EBUSY; |
1684 | 1681 | ||
1685 | if (!bind || !driver->setup || driver->max_speed < USB_SPEED_FULL) { | 1682 | if (!bind || !driver->setup || driver->max_speed < USB_SPEED_FULL) { |
1686 | printk(KERN_ERR "Invalid driver: bind %p setup %p speed %d\n", | 1683 | dev_err(&udc->gadget.dev, "Invalid driver: bind %p setup %p speed %d\n", |
1687 | bind, driver->setup, driver->max_speed); | 1684 | bind, driver->setup, driver->max_speed); |
1688 | return -EINVAL; | 1685 | return -EINVAL; |
1689 | } | 1686 | } |
1690 | #if defined(MODULE) | 1687 | #if defined(MODULE) |
1691 | if (!driver->unbind) { | 1688 | if (!driver->unbind) { |
1692 | printk(KERN_ERR "Invalid driver: no unbind method\n"); | 1689 | dev_err(&udc->gadget.dev, "Invalid driver: no unbind method\n"); |
1693 | return -EINVAL; | 1690 | return -EINVAL; |
1694 | } | 1691 | } |
1695 | #endif | 1692 | #endif |
@@ -1699,15 +1696,17 @@ static int s3c2410_udc_start(struct usb_gadget_driver *driver, | |||
1699 | udc->gadget.dev.driver = &driver->driver; | 1696 | udc->gadget.dev.driver = &driver->driver; |
1700 | 1697 | ||
1701 | /* Bind the driver */ | 1698 | /* Bind the driver */ |
1702 | if ((retval = device_add(&udc->gadget.dev)) != 0) { | 1699 | retval = device_add(&udc->gadget.dev); |
1703 | printk(KERN_ERR "Error in device_add() : %d\n",retval); | 1700 | if (retval) { |
1701 | dev_err(&udc->gadget.dev, "Error in device_add() : %d\n", retval); | ||
1704 | goto register_error; | 1702 | goto register_error; |
1705 | } | 1703 | } |
1706 | 1704 | ||
1707 | dprintk(DEBUG_NORMAL, "binding gadget driver '%s'\n", | 1705 | dprintk(DEBUG_NORMAL, "binding gadget driver '%s'\n", |
1708 | driver->driver.name); | 1706 | driver->driver.name); |
1709 | 1707 | ||
1710 | if ((retval = bind(&udc->gadget)) != 0) { | 1708 | retval = bind(&udc->gadget, driver); |
1709 | if (retval) { | ||
1711 | device_del(&udc->gadget.dev); | 1710 | device_del(&udc->gadget.dev); |
1712 | goto register_error; | 1711 | goto register_error; |
1713 | } | 1712 | } |
@@ -1865,7 +1864,7 @@ static int s3c2410_udc_probe(struct platform_device *pdev) | |||
1865 | memory.ep[4].fifo_size = S3C2440_EP_FIFO_SIZE; | 1864 | memory.ep[4].fifo_size = S3C2440_EP_FIFO_SIZE; |
1866 | } | 1865 | } |
1867 | 1866 | ||
1868 | spin_lock_init (&udc->lock); | 1867 | spin_lock_init(&udc->lock); |
1869 | udc_info = pdev->dev.platform_data; | 1868 | udc_info = pdev->dev.platform_data; |
1870 | 1869 | ||
1871 | rsrc_start = S3C2410_PA_USBDEV; | 1870 | rsrc_start = S3C2410_PA_USBDEV; |
@@ -2028,7 +2027,8 @@ static int s3c2410_udc_remove(struct platform_device *pdev) | |||
2028 | } | 2027 | } |
2029 | 2028 | ||
2030 | #ifdef CONFIG_PM | 2029 | #ifdef CONFIG_PM |
2031 | static int s3c2410_udc_suspend(struct platform_device *pdev, pm_message_t message) | 2030 | static int |
2031 | s3c2410_udc_suspend(struct platform_device *pdev, pm_message_t message) | ||
2032 | { | 2032 | { |
2033 | s3c2410_udc_command(S3C2410_UDC_P_DISABLE); | 2033 | s3c2410_udc_command(S3C2410_UDC_P_DISABLE); |
2034 | 2034 | ||
@@ -2073,7 +2073,7 @@ static int __init udc_init(void) | |||
2073 | 2073 | ||
2074 | s3c2410_udc_debugfs_root = debugfs_create_dir(gadget_name, NULL); | 2074 | s3c2410_udc_debugfs_root = debugfs_create_dir(gadget_name, NULL); |
2075 | if (IS_ERR(s3c2410_udc_debugfs_root)) { | 2075 | if (IS_ERR(s3c2410_udc_debugfs_root)) { |
2076 | printk(KERN_ERR "%s: debugfs dir creation failed %ld\n", | 2076 | pr_err("%s: debugfs dir creation failed %ld\n", |
2077 | gadget_name, PTR_ERR(s3c2410_udc_debugfs_root)); | 2077 | gadget_name, PTR_ERR(s3c2410_udc_debugfs_root)); |
2078 | s3c2410_udc_debugfs_root = NULL; | 2078 | s3c2410_udc_debugfs_root = NULL; |
2079 | } | 2079 | } |
diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c index 665c07422c26..44752f531e85 100644 --- a/drivers/usb/gadget/serial.c +++ b/drivers/usb/gadget/serial.c | |||
@@ -11,7 +11,6 @@ | |||
11 | */ | 11 | */ |
12 | 12 | ||
13 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
14 | #include <linux/utsname.h> | ||
15 | #include <linux/device.h> | 14 | #include <linux/device.h> |
16 | #include <linux/tty.h> | 15 | #include <linux/tty.h> |
17 | #include <linux/tty_flip.h> | 16 | #include <linux/tty_flip.h> |
@@ -37,17 +36,13 @@ | |||
37 | * the runtime footprint, and giving us at least some parts of what | 36 | * the runtime footprint, and giving us at least some parts of what |
38 | * a "gcc --combine ... part1.c part2.c part3.c ... " build would. | 37 | * a "gcc --combine ... part1.c part2.c part3.c ... " build would. |
39 | */ | 38 | */ |
40 | #include "composite.c" | ||
41 | #include "usbstring.c" | ||
42 | #include "config.c" | ||
43 | #include "epautoconf.c" | ||
44 | |||
45 | #include "f_acm.c" | 39 | #include "f_acm.c" |
46 | #include "f_obex.c" | 40 | #include "f_obex.c" |
47 | #include "f_serial.c" | 41 | #include "f_serial.c" |
48 | #include "u_serial.c" | 42 | #include "u_serial.c" |
49 | 43 | ||
50 | /*-------------------------------------------------------------------------*/ | 44 | /*-------------------------------------------------------------------------*/ |
45 | USB_GADGET_COMPOSITE_OPTIONS(); | ||
51 | 46 | ||
52 | /* Thanks to NetChip Technologies for donating this product ID. | 47 | /* Thanks to NetChip Technologies for donating this product ID. |
53 | * | 48 | * |
@@ -61,15 +56,12 @@ | |||
61 | 56 | ||
62 | /* string IDs are assigned dynamically */ | 57 | /* string IDs are assigned dynamically */ |
63 | 58 | ||
64 | #define STRING_MANUFACTURER_IDX 0 | 59 | #define STRING_DESCRIPTION_IDX USB_GADGET_FIRST_AVAIL_IDX |
65 | #define STRING_PRODUCT_IDX 1 | ||
66 | #define STRING_DESCRIPTION_IDX 2 | ||
67 | |||
68 | static char manufacturer[50]; | ||
69 | 60 | ||
70 | static struct usb_string strings_dev[] = { | 61 | static struct usb_string strings_dev[] = { |
71 | [STRING_MANUFACTURER_IDX].s = manufacturer, | 62 | [USB_GADGET_MANUFACTURER_IDX].s = "", |
72 | [STRING_PRODUCT_IDX].s = GS_VERSION_NAME, | 63 | [USB_GADGET_PRODUCT_IDX].s = GS_VERSION_NAME, |
64 | [USB_GADGET_SERIAL_IDX].s = "", | ||
73 | [STRING_DESCRIPTION_IDX].s = NULL /* updated; f(use_acm) */, | 65 | [STRING_DESCRIPTION_IDX].s = NULL /* updated; f(use_acm) */, |
74 | { } /* end of list */ | 66 | { } /* end of list */ |
75 | }; | 67 | }; |
@@ -94,7 +86,7 @@ static struct usb_device_descriptor device_desc = { | |||
94 | /* .bMaxPacketSize0 = f(hardware) */ | 86 | /* .bMaxPacketSize0 = f(hardware) */ |
95 | .idVendor = cpu_to_le16(GS_VENDOR_ID), | 87 | .idVendor = cpu_to_le16(GS_VENDOR_ID), |
96 | /* .idProduct = f(use_acm) */ | 88 | /* .idProduct = f(use_acm) */ |
97 | /* .bcdDevice = f(hardware) */ | 89 | .bcdDevice = cpu_to_le16(GS_VERSION_NUM), |
98 | /* .iManufacturer = DYNAMIC */ | 90 | /* .iManufacturer = DYNAMIC */ |
99 | /* .iProduct = DYNAMIC */ | 91 | /* .iProduct = DYNAMIC */ |
100 | .bNumConfigurations = 1, | 92 | .bNumConfigurations = 1, |
@@ -162,8 +154,6 @@ static struct usb_configuration serial_config_driver = { | |||
162 | 154 | ||
163 | static int __init gs_bind(struct usb_composite_dev *cdev) | 155 | static int __init gs_bind(struct usb_composite_dev *cdev) |
164 | { | 156 | { |
165 | int gcnum; | ||
166 | struct usb_gadget *gadget = cdev->gadget; | ||
167 | int status; | 157 | int status; |
168 | 158 | ||
169 | status = gserial_setup(cdev->gadget, n_ports); | 159 | status = gserial_setup(cdev->gadget, n_ports); |
@@ -174,50 +164,14 @@ static int __init gs_bind(struct usb_composite_dev *cdev) | |||
174 | * contents can be overridden by the composite_dev glue. | 164 | * contents can be overridden by the composite_dev glue. |
175 | */ | 165 | */ |
176 | 166 | ||
177 | /* device description: manufacturer, product */ | 167 | status = usb_string_ids_tab(cdev, strings_dev); |
178 | snprintf(manufacturer, sizeof manufacturer, "%s %s with %s", | ||
179 | init_utsname()->sysname, init_utsname()->release, | ||
180 | gadget->name); | ||
181 | status = usb_string_id(cdev); | ||
182 | if (status < 0) | 168 | if (status < 0) |
183 | goto fail; | 169 | goto fail; |
184 | strings_dev[STRING_MANUFACTURER_IDX].id = status; | 170 | device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id; |
185 | 171 | device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; | |
186 | device_desc.iManufacturer = status; | 172 | status = strings_dev[STRING_DESCRIPTION_IDX].id; |
187 | |||
188 | status = usb_string_id(cdev); | ||
189 | if (status < 0) | ||
190 | goto fail; | ||
191 | strings_dev[STRING_PRODUCT_IDX].id = status; | ||
192 | |||
193 | device_desc.iProduct = status; | ||
194 | |||
195 | /* config description */ | ||
196 | status = usb_string_id(cdev); | ||
197 | if (status < 0) | ||
198 | goto fail; | ||
199 | strings_dev[STRING_DESCRIPTION_IDX].id = status; | ||
200 | |||
201 | serial_config_driver.iConfiguration = status; | 173 | serial_config_driver.iConfiguration = status; |
202 | 174 | ||
203 | /* set up other descriptors */ | ||
204 | gcnum = usb_gadget_controller_number(gadget); | ||
205 | if (gcnum >= 0) | ||
206 | device_desc.bcdDevice = cpu_to_le16(GS_VERSION_NUM | gcnum); | ||
207 | else { | ||
208 | /* this is so simple (for now, no altsettings) that it | ||
209 | * SHOULD NOT have problems with bulk-capable hardware. | ||
210 | * so warn about unrcognized controllers -- don't panic. | ||
211 | * | ||
212 | * things like configuration and altsetting numbering | ||
213 | * can need hardware-specific attention though. | ||
214 | */ | ||
215 | pr_warning("gs_bind: controller '%s' not recognized\n", | ||
216 | gadget->name); | ||
217 | device_desc.bcdDevice = | ||
218 | cpu_to_le16(GS_VERSION_NUM | 0x0099); | ||
219 | } | ||
220 | |||
221 | if (gadget_is_otg(cdev->gadget)) { | 175 | if (gadget_is_otg(cdev->gadget)) { |
222 | serial_config_driver.descriptors = otg_desc; | 176 | serial_config_driver.descriptors = otg_desc; |
223 | serial_config_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP; | 177 | serial_config_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP; |
@@ -229,6 +183,7 @@ static int __init gs_bind(struct usb_composite_dev *cdev) | |||
229 | if (status < 0) | 183 | if (status < 0) |
230 | goto fail; | 184 | goto fail; |
231 | 185 | ||
186 | usb_composite_overwrite_options(cdev, &coverwrite); | ||
232 | INFO(cdev, "%s\n", GS_VERSION_NAME); | 187 | INFO(cdev, "%s\n", GS_VERSION_NAME); |
233 | 188 | ||
234 | return 0; | 189 | return 0; |
@@ -238,11 +193,12 @@ fail: | |||
238 | return status; | 193 | return status; |
239 | } | 194 | } |
240 | 195 | ||
241 | static struct usb_composite_driver gserial_driver = { | 196 | static __refdata struct usb_composite_driver gserial_driver = { |
242 | .name = "g_serial", | 197 | .name = "g_serial", |
243 | .dev = &device_desc, | 198 | .dev = &device_desc, |
244 | .strings = dev_strings, | 199 | .strings = dev_strings, |
245 | .max_speed = USB_SPEED_SUPER, | 200 | .max_speed = USB_SPEED_SUPER, |
201 | .bind = gs_bind, | ||
246 | }; | 202 | }; |
247 | 203 | ||
248 | static int __init init(void) | 204 | static int __init init(void) |
@@ -271,7 +227,7 @@ static int __init init(void) | |||
271 | } | 227 | } |
272 | strings_dev[STRING_DESCRIPTION_IDX].s = serial_config_driver.label; | 228 | strings_dev[STRING_DESCRIPTION_IDX].s = serial_config_driver.label; |
273 | 229 | ||
274 | return usb_composite_probe(&gserial_driver, gs_bind); | 230 | return usb_composite_probe(&gserial_driver); |
275 | } | 231 | } |
276 | module_init(init); | 232 | module_init(init); |
277 | 233 | ||
diff --git a/drivers/usb/gadget/tcm_usb_gadget.c b/drivers/usb/gadget/tcm_usb_gadget.c index 5444866e13ef..eaa1005377fc 100644 --- a/drivers/usb/gadget/tcm_usb_gadget.c +++ b/drivers/usb/gadget/tcm_usb_gadget.c | |||
@@ -25,13 +25,10 @@ | |||
25 | #include <target/configfs_macros.h> | 25 | #include <target/configfs_macros.h> |
26 | #include <asm/unaligned.h> | 26 | #include <asm/unaligned.h> |
27 | 27 | ||
28 | #include "usbstring.c" | ||
29 | #include "epautoconf.c" | ||
30 | #include "config.c" | ||
31 | #include "composite.c" | ||
32 | |||
33 | #include "tcm_usb_gadget.h" | 28 | #include "tcm_usb_gadget.h" |
34 | 29 | ||
30 | USB_GADGET_COMPOSITE_OPTIONS(); | ||
31 | |||
35 | static struct target_fabric_configfs *usbg_fabric_configfs; | 32 | static struct target_fabric_configfs *usbg_fabric_configfs; |
36 | 33 | ||
37 | static inline struct f_uas *to_f_uas(struct usb_function *f) | 34 | static inline struct f_uas *to_f_uas(struct usb_function *f) |
@@ -1977,7 +1974,6 @@ static struct usb_interface_descriptor bot_intf_desc = { | |||
1977 | .bInterfaceClass = USB_CLASS_MASS_STORAGE, | 1974 | .bInterfaceClass = USB_CLASS_MASS_STORAGE, |
1978 | .bInterfaceSubClass = USB_SC_SCSI, | 1975 | .bInterfaceSubClass = USB_SC_SCSI, |
1979 | .bInterfaceProtocol = USB_PR_BULK, | 1976 | .bInterfaceProtocol = USB_PR_BULK, |
1980 | .iInterface = USB_G_STR_INT_UAS, | ||
1981 | }; | 1977 | }; |
1982 | 1978 | ||
1983 | static struct usb_interface_descriptor uasp_intf_desc = { | 1979 | static struct usb_interface_descriptor uasp_intf_desc = { |
@@ -1988,7 +1984,6 @@ static struct usb_interface_descriptor uasp_intf_desc = { | |||
1988 | .bInterfaceClass = USB_CLASS_MASS_STORAGE, | 1984 | .bInterfaceClass = USB_CLASS_MASS_STORAGE, |
1989 | .bInterfaceSubClass = USB_SC_SCSI, | 1985 | .bInterfaceSubClass = USB_SC_SCSI, |
1990 | .bInterfaceProtocol = USB_PR_UAS, | 1986 | .bInterfaceProtocol = USB_PR_UAS, |
1991 | .iInterface = USB_G_STR_INT_BBB, | ||
1992 | }; | 1987 | }; |
1993 | 1988 | ||
1994 | static struct usb_endpoint_descriptor uasp_bi_desc = { | 1989 | static struct usb_endpoint_descriptor uasp_bi_desc = { |
@@ -2209,20 +2204,16 @@ static struct usb_device_descriptor usbg_device_desc = { | |||
2209 | .bDeviceClass = USB_CLASS_PER_INTERFACE, | 2204 | .bDeviceClass = USB_CLASS_PER_INTERFACE, |
2210 | .idVendor = cpu_to_le16(UAS_VENDOR_ID), | 2205 | .idVendor = cpu_to_le16(UAS_VENDOR_ID), |
2211 | .idProduct = cpu_to_le16(UAS_PRODUCT_ID), | 2206 | .idProduct = cpu_to_le16(UAS_PRODUCT_ID), |
2212 | .iManufacturer = USB_G_STR_MANUFACTOR, | ||
2213 | .iProduct = USB_G_STR_PRODUCT, | ||
2214 | .iSerialNumber = USB_G_STR_SERIAL, | ||
2215 | |||
2216 | .bNumConfigurations = 1, | 2207 | .bNumConfigurations = 1, |
2217 | }; | 2208 | }; |
2218 | 2209 | ||
2219 | static struct usb_string usbg_us_strings[] = { | 2210 | static struct usb_string usbg_us_strings[] = { |
2220 | { USB_G_STR_MANUFACTOR, "Target Manufactor"}, | 2211 | [USB_GADGET_MANUFACTURER_IDX].s = "Target Manufactor", |
2221 | { USB_G_STR_PRODUCT, "Target Product"}, | 2212 | [USB_GADGET_PRODUCT_IDX].s = "Target Product", |
2222 | { USB_G_STR_SERIAL, "000000000001"}, | 2213 | [USB_GADGET_SERIAL_IDX].s = "000000000001", |
2223 | { USB_G_STR_CONFIG, "default config"}, | 2214 | [USB_G_STR_CONFIG].s = "default config", |
2224 | { USB_G_STR_INT_UAS, "USB Attached SCSI"}, | 2215 | [USB_G_STR_INT_UAS].s = "USB Attached SCSI", |
2225 | { USB_G_STR_INT_BBB, "Bulk Only Transport"}, | 2216 | [USB_G_STR_INT_BBB].s = "Bulk Only Transport", |
2226 | { }, | 2217 | { }, |
2227 | }; | 2218 | }; |
2228 | 2219 | ||
@@ -2244,7 +2235,6 @@ static int guas_unbind(struct usb_composite_dev *cdev) | |||
2244 | static struct usb_configuration usbg_config_driver = { | 2235 | static struct usb_configuration usbg_config_driver = { |
2245 | .label = "Linux Target", | 2236 | .label = "Linux Target", |
2246 | .bConfigurationValue = 1, | 2237 | .bConfigurationValue = 1, |
2247 | .iConfiguration = USB_G_STR_CONFIG, | ||
2248 | .bmAttributes = USB_CONFIG_ATT_SELFPOWER, | 2238 | .bmAttributes = USB_CONFIG_ATT_SELFPOWER, |
2249 | }; | 2239 | }; |
2250 | 2240 | ||
@@ -2417,6 +2407,9 @@ static int usbg_cfg_bind(struct usb_configuration *c) | |||
2417 | fu->function.disable = usbg_disable; | 2407 | fu->function.disable = usbg_disable; |
2418 | fu->tpg = the_only_tpg_I_currently_have; | 2408 | fu->tpg = the_only_tpg_I_currently_have; |
2419 | 2409 | ||
2410 | bot_intf_desc.iInterface = usbg_us_strings[USB_G_STR_INT_BBB].id; | ||
2411 | uasp_intf_desc.iInterface = usbg_us_strings[USB_G_STR_INT_UAS].id; | ||
2412 | |||
2420 | ret = usb_add_function(c, &fu->function); | 2413 | ret = usb_add_function(c, &fu->function); |
2421 | if (ret) | 2414 | if (ret) |
2422 | goto err; | 2415 | goto err; |
@@ -2431,22 +2424,38 @@ static int usb_target_bind(struct usb_composite_dev *cdev) | |||
2431 | { | 2424 | { |
2432 | int ret; | 2425 | int ret; |
2433 | 2426 | ||
2427 | ret = usb_string_ids_tab(cdev, usbg_us_strings); | ||
2428 | if (ret) | ||
2429 | return ret; | ||
2430 | |||
2431 | usbg_device_desc.iManufacturer = | ||
2432 | usbg_us_strings[USB_GADGET_MANUFACTURER_IDX].id; | ||
2433 | usbg_device_desc.iProduct = usbg_us_strings[USB_GADGET_PRODUCT_IDX].id; | ||
2434 | usbg_device_desc.iSerialNumber = | ||
2435 | usbg_us_strings[USB_GADGET_SERIAL_IDX].id; | ||
2436 | usbg_config_driver.iConfiguration = | ||
2437 | usbg_us_strings[USB_G_STR_CONFIG].id; | ||
2438 | |||
2434 | ret = usb_add_config(cdev, &usbg_config_driver, | 2439 | ret = usb_add_config(cdev, &usbg_config_driver, |
2435 | usbg_cfg_bind); | 2440 | usbg_cfg_bind); |
2441 | if (ret) | ||
2442 | return ret; | ||
2443 | usb_composite_overwrite_options(cdev, &coverwrite); | ||
2436 | return 0; | 2444 | return 0; |
2437 | } | 2445 | } |
2438 | 2446 | ||
2439 | static struct usb_composite_driver usbg_driver = { | 2447 | static __refdata struct usb_composite_driver usbg_driver = { |
2440 | .name = "g_target", | 2448 | .name = "g_target", |
2441 | .dev = &usbg_device_desc, | 2449 | .dev = &usbg_device_desc, |
2442 | .strings = usbg_strings, | 2450 | .strings = usbg_strings, |
2443 | .max_speed = USB_SPEED_SUPER, | 2451 | .max_speed = USB_SPEED_SUPER, |
2452 | .bind = usb_target_bind, | ||
2444 | .unbind = guas_unbind, | 2453 | .unbind = guas_unbind, |
2445 | }; | 2454 | }; |
2446 | 2455 | ||
2447 | static int usbg_attach(struct usbg_tpg *tpg) | 2456 | static int usbg_attach(struct usbg_tpg *tpg) |
2448 | { | 2457 | { |
2449 | return usb_composite_probe(&usbg_driver, usb_target_bind); | 2458 | return usb_composite_probe(&usbg_driver); |
2450 | } | 2459 | } |
2451 | 2460 | ||
2452 | static void usbg_detach(struct usbg_tpg *tpg) | 2461 | static void usbg_detach(struct usbg_tpg *tpg) |
diff --git a/drivers/usb/gadget/tcm_usb_gadget.h b/drivers/usb/gadget/tcm_usb_gadget.h index bb18999a9a8d..8289219925b8 100644 --- a/drivers/usb/gadget/tcm_usb_gadget.h +++ b/drivers/usb/gadget/tcm_usb_gadget.h | |||
@@ -16,12 +16,11 @@ | |||
16 | #define UASP_SS_EP_COMP_LOG_STREAMS 4 | 16 | #define UASP_SS_EP_COMP_LOG_STREAMS 4 |
17 | #define UASP_SS_EP_COMP_NUM_STREAMS (1 << UASP_SS_EP_COMP_LOG_STREAMS) | 17 | #define UASP_SS_EP_COMP_NUM_STREAMS (1 << UASP_SS_EP_COMP_LOG_STREAMS) |
18 | 18 | ||
19 | #define USB_G_STR_MANUFACTOR 1 | 19 | enum { |
20 | #define USB_G_STR_PRODUCT 2 | 20 | USB_G_STR_CONFIG = USB_GADGET_FIRST_AVAIL_IDX, |
21 | #define USB_G_STR_SERIAL 3 | 21 | USB_G_STR_INT_UAS, |
22 | #define USB_G_STR_CONFIG 4 | 22 | USB_G_STR_INT_BBB, |
23 | #define USB_G_STR_INT_UAS 5 | 23 | }; |
24 | #define USB_G_STR_INT_BBB 6 | ||
25 | 24 | ||
26 | #define USB_G_ALT_INT_BBB 0 | 25 | #define USB_G_ALT_INT_BBB 0 |
27 | #define USB_G_ALT_INT_UAS 1 | 26 | #define USB_G_ALT_INT_UAS 1 |
diff --git a/drivers/usb/gadget/u_ether.c b/drivers/usb/gadget/u_ether.c index 0e5230926154..b9c46900c2c1 100644 --- a/drivers/usb/gadget/u_ether.c +++ b/drivers/usb/gadget/u_ether.c | |||
@@ -14,6 +14,7 @@ | |||
14 | /* #define VERBOSE_DEBUG */ | 14 | /* #define VERBOSE_DEBUG */ |
15 | 15 | ||
16 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
17 | #include <linux/module.h> | ||
17 | #include <linux/gfp.h> | 18 | #include <linux/gfp.h> |
18 | #include <linux/device.h> | 19 | #include <linux/device.h> |
19 | #include <linux/ctype.h> | 20 | #include <linux/ctype.h> |
@@ -83,17 +84,10 @@ struct eth_dev { | |||
83 | 84 | ||
84 | #define DEFAULT_QLEN 2 /* double buffering by default */ | 85 | #define DEFAULT_QLEN 2 /* double buffering by default */ |
85 | 86 | ||
86 | |||
87 | #ifdef CONFIG_USB_GADGET_DUALSPEED | ||
88 | |||
89 | static unsigned qmult = 5; | 87 | static unsigned qmult = 5; |
90 | module_param(qmult, uint, S_IRUGO|S_IWUSR); | 88 | module_param(qmult, uint, S_IRUGO|S_IWUSR); |
91 | MODULE_PARM_DESC(qmult, "queue length multiplier at high/super speed"); | 89 | MODULE_PARM_DESC(qmult, "queue length multiplier at high/super speed"); |
92 | 90 | ||
93 | #else /* full speed (low speed doesn't do bulk) */ | ||
94 | #define qmult 1 | ||
95 | #endif | ||
96 | |||
97 | /* for dual-speed hardware, use deeper queues at high/super speed */ | 91 | /* for dual-speed hardware, use deeper queues at high/super speed */ |
98 | static inline int qlen(struct usb_gadget *gadget) | 92 | static inline int qlen(struct usb_gadget *gadget) |
99 | { | 93 | { |
diff --git a/drivers/usb/gadget/udc-core.c b/drivers/usb/gadget/udc-core.c index e5e44f8cde9a..f3cd9690b101 100644 --- a/drivers/usb/gadget/udc-core.c +++ b/drivers/usb/gadget/udc-core.c | |||
@@ -118,7 +118,7 @@ EXPORT_SYMBOL_GPL(usb_gadget_unmap_request); | |||
118 | */ | 118 | */ |
119 | static inline int usb_gadget_start(struct usb_gadget *gadget, | 119 | static inline int usb_gadget_start(struct usb_gadget *gadget, |
120 | struct usb_gadget_driver *driver, | 120 | struct usb_gadget_driver *driver, |
121 | int (*bind)(struct usb_gadget *)) | 121 | int (*bind)(struct usb_gadget *, struct usb_gadget_driver *)) |
122 | { | 122 | { |
123 | return gadget->ops->start(driver, bind); | 123 | return gadget->ops->start(driver, bind); |
124 | } | 124 | } |
@@ -262,8 +262,8 @@ static void usb_gadget_remove_driver(struct usb_udc *udc) | |||
262 | kobject_uevent(&udc->dev.kobj, KOBJ_CHANGE); | 262 | kobject_uevent(&udc->dev.kobj, KOBJ_CHANGE); |
263 | 263 | ||
264 | if (udc_is_newstyle(udc)) { | 264 | if (udc_is_newstyle(udc)) { |
265 | udc->driver->disconnect(udc->gadget); | ||
266 | usb_gadget_disconnect(udc->gadget); | 265 | usb_gadget_disconnect(udc->gadget); |
266 | udc->driver->disconnect(udc->gadget); | ||
267 | udc->driver->unbind(udc->gadget); | 267 | udc->driver->unbind(udc->gadget); |
268 | usb_gadget_udc_stop(udc->gadget, udc->driver); | 268 | usb_gadget_udc_stop(udc->gadget, udc->driver); |
269 | } else { | 269 | } else { |
@@ -311,13 +311,12 @@ EXPORT_SYMBOL_GPL(usb_del_gadget_udc); | |||
311 | 311 | ||
312 | /* ------------------------------------------------------------------------- */ | 312 | /* ------------------------------------------------------------------------- */ |
313 | 313 | ||
314 | int usb_gadget_probe_driver(struct usb_gadget_driver *driver, | 314 | int usb_gadget_probe_driver(struct usb_gadget_driver *driver) |
315 | int (*bind)(struct usb_gadget *)) | ||
316 | { | 315 | { |
317 | struct usb_udc *udc = NULL; | 316 | struct usb_udc *udc = NULL; |
318 | int ret; | 317 | int ret; |
319 | 318 | ||
320 | if (!driver || !bind || !driver->setup) | 319 | if (!driver || !driver->bind || !driver->setup) |
321 | return -EINVAL; | 320 | return -EINVAL; |
322 | 321 | ||
323 | mutex_lock(&udc_lock); | 322 | mutex_lock(&udc_lock); |
@@ -339,7 +338,7 @@ found: | |||
339 | udc->dev.driver = &driver->driver; | 338 | udc->dev.driver = &driver->driver; |
340 | 339 | ||
341 | if (udc_is_newstyle(udc)) { | 340 | if (udc_is_newstyle(udc)) { |
342 | ret = bind(udc->gadget); | 341 | ret = driver->bind(udc->gadget, driver); |
343 | if (ret) | 342 | if (ret) |
344 | goto err1; | 343 | goto err1; |
345 | ret = usb_gadget_udc_start(udc->gadget, driver); | 344 | ret = usb_gadget_udc_start(udc->gadget, driver); |
@@ -350,7 +349,7 @@ found: | |||
350 | usb_gadget_connect(udc->gadget); | 349 | usb_gadget_connect(udc->gadget); |
351 | } else { | 350 | } else { |
352 | 351 | ||
353 | ret = usb_gadget_start(udc->gadget, driver, bind); | 352 | ret = usb_gadget_start(udc->gadget, driver, driver->bind); |
354 | if (ret) | 353 | if (ret) |
355 | goto err1; | 354 | goto err1; |
356 | 355 | ||
diff --git a/drivers/usb/gadget/usbstring.c b/drivers/usb/gadget/usbstring.c index 4d25b9009edf..1f49fce0f0b7 100644 --- a/drivers/usb/gadget/usbstring.c +++ b/drivers/usb/gadget/usbstring.c | |||
@@ -9,6 +9,7 @@ | |||
9 | 9 | ||
10 | #include <linux/errno.h> | 10 | #include <linux/errno.h> |
11 | #include <linux/kernel.h> | 11 | #include <linux/kernel.h> |
12 | #include <linux/module.h> | ||
12 | #include <linux/list.h> | 13 | #include <linux/list.h> |
13 | #include <linux/string.h> | 14 | #include <linux/string.h> |
14 | #include <linux/device.h> | 15 | #include <linux/device.h> |
@@ -68,4 +69,4 @@ usb_gadget_get_string (struct usb_gadget_strings *table, int id, u8 *buf) | |||
68 | buf [1] = USB_DT_STRING; | 69 | buf [1] = USB_DT_STRING; |
69 | return buf [0]; | 70 | return buf [0]; |
70 | } | 71 | } |
71 | 72 | EXPORT_SYMBOL_GPL(usb_gadget_get_string); | |
diff --git a/drivers/usb/gadget/webcam.c b/drivers/usb/gadget/webcam.c index 120e134e805e..69cf5c2cd335 100644 --- a/drivers/usb/gadget/webcam.c +++ b/drivers/usb/gadget/webcam.c | |||
@@ -23,16 +23,12 @@ | |||
23 | * the runtime footprint, and giving us at least some parts of what | 23 | * the runtime footprint, and giving us at least some parts of what |
24 | * a "gcc --combine ... part1.c part2.c part3.c ... " build would. | 24 | * a "gcc --combine ... part1.c part2.c part3.c ... " build would. |
25 | */ | 25 | */ |
26 | #include "composite.c" | ||
27 | #include "usbstring.c" | ||
28 | #include "config.c" | ||
29 | #include "epautoconf.c" | ||
30 | |||
31 | #include "uvc_queue.c" | 26 | #include "uvc_queue.c" |
32 | #include "uvc_video.c" | 27 | #include "uvc_video.c" |
33 | #include "uvc_v4l2.c" | 28 | #include "uvc_v4l2.c" |
34 | #include "f_uvc.c" | 29 | #include "f_uvc.c" |
35 | 30 | ||
31 | USB_GADGET_COMPOSITE_OPTIONS(); | ||
36 | /* -------------------------------------------------------------------------- | 32 | /* -------------------------------------------------------------------------- |
37 | * Device descriptor | 33 | * Device descriptor |
38 | */ | 34 | */ |
@@ -47,13 +43,12 @@ static char webcam_config_label[] = "Video"; | |||
47 | 43 | ||
48 | /* string IDs are assigned dynamically */ | 44 | /* string IDs are assigned dynamically */ |
49 | 45 | ||
50 | #define STRING_MANUFACTURER_IDX 0 | 46 | #define STRING_DESCRIPTION_IDX USB_GADGET_FIRST_AVAIL_IDX |
51 | #define STRING_PRODUCT_IDX 1 | ||
52 | #define STRING_DESCRIPTION_IDX 2 | ||
53 | 47 | ||
54 | static struct usb_string webcam_strings[] = { | 48 | static struct usb_string webcam_strings[] = { |
55 | [STRING_MANUFACTURER_IDX].s = webcam_vendor_label, | 49 | [USB_GADGET_MANUFACTURER_IDX].s = webcam_vendor_label, |
56 | [STRING_PRODUCT_IDX].s = webcam_product_label, | 50 | [USB_GADGET_PRODUCT_IDX].s = webcam_product_label, |
51 | [USB_GADGET_SERIAL_IDX].s = "", | ||
57 | [STRING_DESCRIPTION_IDX].s = webcam_config_label, | 52 | [STRING_DESCRIPTION_IDX].s = webcam_config_label, |
58 | { } | 53 | { } |
59 | }; | 54 | }; |
@@ -358,26 +353,22 @@ webcam_bind(struct usb_composite_dev *cdev) | |||
358 | /* Allocate string descriptor numbers ... note that string contents | 353 | /* Allocate string descriptor numbers ... note that string contents |
359 | * can be overridden by the composite_dev glue. | 354 | * can be overridden by the composite_dev glue. |
360 | */ | 355 | */ |
361 | if ((ret = usb_string_id(cdev)) < 0) | 356 | ret = usb_string_ids_tab(cdev, webcam_strings); |
362 | goto error; | 357 | if (ret < 0) |
363 | webcam_strings[STRING_MANUFACTURER_IDX].id = ret; | ||
364 | webcam_device_descriptor.iManufacturer = ret; | ||
365 | |||
366 | if ((ret = usb_string_id(cdev)) < 0) | ||
367 | goto error; | ||
368 | webcam_strings[STRING_PRODUCT_IDX].id = ret; | ||
369 | webcam_device_descriptor.iProduct = ret; | ||
370 | |||
371 | if ((ret = usb_string_id(cdev)) < 0) | ||
372 | goto error; | 358 | goto error; |
373 | webcam_strings[STRING_DESCRIPTION_IDX].id = ret; | 359 | webcam_device_descriptor.iManufacturer = |
374 | webcam_config_driver.iConfiguration = ret; | 360 | webcam_strings[USB_GADGET_MANUFACTURER_IDX].id; |
361 | webcam_device_descriptor.iProduct = | ||
362 | webcam_strings[USB_GADGET_PRODUCT_IDX].id; | ||
363 | webcam_config_driver.iConfiguration = | ||
364 | webcam_strings[STRING_DESCRIPTION_IDX].id; | ||
375 | 365 | ||
376 | /* Register our configuration. */ | 366 | /* Register our configuration. */ |
377 | if ((ret = usb_add_config(cdev, &webcam_config_driver, | 367 | if ((ret = usb_add_config(cdev, &webcam_config_driver, |
378 | webcam_config_bind)) < 0) | 368 | webcam_config_bind)) < 0) |
379 | goto error; | 369 | goto error; |
380 | 370 | ||
371 | usb_composite_overwrite_options(cdev, &coverwrite); | ||
381 | INFO(cdev, "Webcam Video Gadget\n"); | 372 | INFO(cdev, "Webcam Video Gadget\n"); |
382 | return 0; | 373 | return 0; |
383 | 374 | ||
@@ -390,18 +381,19 @@ error: | |||
390 | * Driver | 381 | * Driver |
391 | */ | 382 | */ |
392 | 383 | ||
393 | static struct usb_composite_driver webcam_driver = { | 384 | static __refdata struct usb_composite_driver webcam_driver = { |
394 | .name = "g_webcam", | 385 | .name = "g_webcam", |
395 | .dev = &webcam_device_descriptor, | 386 | .dev = &webcam_device_descriptor, |
396 | .strings = webcam_device_strings, | 387 | .strings = webcam_device_strings, |
397 | .max_speed = USB_SPEED_SUPER, | 388 | .max_speed = USB_SPEED_SUPER, |
389 | .bind = webcam_bind, | ||
398 | .unbind = webcam_unbind, | 390 | .unbind = webcam_unbind, |
399 | }; | 391 | }; |
400 | 392 | ||
401 | static int __init | 393 | static int __init |
402 | webcam_init(void) | 394 | webcam_init(void) |
403 | { | 395 | { |
404 | return usb_composite_probe(&webcam_driver, webcam_bind); | 396 | return usb_composite_probe(&webcam_driver); |
405 | } | 397 | } |
406 | 398 | ||
407 | static void __exit | 399 | static void __exit |
diff --git a/drivers/usb/gadget/zero.c b/drivers/usb/gadget/zero.c index 12ad516ada77..6bf4c0611365 100644 --- a/drivers/usb/gadget/zero.c +++ b/drivers/usb/gadget/zero.c | |||
@@ -42,7 +42,6 @@ | |||
42 | 42 | ||
43 | #include <linux/kernel.h> | 43 | #include <linux/kernel.h> |
44 | #include <linux/slab.h> | 44 | #include <linux/slab.h> |
45 | #include <linux/utsname.h> | ||
46 | #include <linux/device.h> | 45 | #include <linux/device.h> |
47 | 46 | ||
48 | #include "g_zero.h" | 47 | #include "g_zero.h" |
@@ -58,15 +57,11 @@ | |||
58 | * the runtime footprint, and giving us at least some parts of what | 57 | * the runtime footprint, and giving us at least some parts of what |
59 | * a "gcc --combine ... part1.c part2.c part3.c ... " build would. | 58 | * a "gcc --combine ... part1.c part2.c part3.c ... " build would. |
60 | */ | 59 | */ |
61 | #include "composite.c" | ||
62 | #include "usbstring.c" | ||
63 | #include "config.c" | ||
64 | #include "epautoconf.c" | ||
65 | |||
66 | #include "f_sourcesink.c" | 60 | #include "f_sourcesink.c" |
67 | #include "f_loopback.c" | 61 | #include "f_loopback.c" |
68 | 62 | ||
69 | /*-------------------------------------------------------------------------*/ | 63 | /*-------------------------------------------------------------------------*/ |
64 | USB_GADGET_COMPOSITE_OPTIONS(); | ||
70 | 65 | ||
71 | #define DRIVER_VERSION "Cinco de Mayo 2008" | 66 | #define DRIVER_VERSION "Cinco de Mayo 2008" |
72 | 67 | ||
@@ -141,20 +136,13 @@ const struct usb_descriptor_header *otg_desc[] = { | |||
141 | #endif | 136 | #endif |
142 | 137 | ||
143 | /* string IDs are assigned dynamically */ | 138 | /* string IDs are assigned dynamically */ |
144 | |||
145 | #define STRING_MANUFACTURER_IDX 0 | ||
146 | #define STRING_PRODUCT_IDX 1 | ||
147 | #define STRING_SERIAL_IDX 2 | ||
148 | |||
149 | static char manufacturer[50]; | ||
150 | |||
151 | /* default serial number takes at least two packets */ | 139 | /* default serial number takes at least two packets */ |
152 | static char serial[] = "0123456789.0123456789.0123456789"; | 140 | static char serial[] = "0123456789.0123456789.0123456789"; |
153 | 141 | ||
154 | static struct usb_string strings_dev[] = { | 142 | static struct usb_string strings_dev[] = { |
155 | [STRING_MANUFACTURER_IDX].s = manufacturer, | 143 | [USB_GADGET_MANUFACTURER_IDX].s = "", |
156 | [STRING_PRODUCT_IDX].s = longname, | 144 | [USB_GADGET_PRODUCT_IDX].s = longname, |
157 | [STRING_SERIAL_IDX].s = serial, | 145 | [USB_GADGET_SERIAL_IDX].s = serial, |
158 | { } /* end of list */ | 146 | { } /* end of list */ |
159 | }; | 147 | }; |
160 | 148 | ||
@@ -265,30 +253,18 @@ static void zero_resume(struct usb_composite_dev *cdev) | |||
265 | 253 | ||
266 | static int __init zero_bind(struct usb_composite_dev *cdev) | 254 | static int __init zero_bind(struct usb_composite_dev *cdev) |
267 | { | 255 | { |
268 | int gcnum; | 256 | int status; |
269 | struct usb_gadget *gadget = cdev->gadget; | ||
270 | int id; | ||
271 | 257 | ||
272 | /* Allocate string descriptor numbers ... note that string | 258 | /* Allocate string descriptor numbers ... note that string |
273 | * contents can be overridden by the composite_dev glue. | 259 | * contents can be overridden by the composite_dev glue. |
274 | */ | 260 | */ |
275 | id = usb_string_id(cdev); | 261 | status = usb_string_ids_tab(cdev, strings_dev); |
276 | if (id < 0) | 262 | if (status < 0) |
277 | return id; | 263 | return status; |
278 | strings_dev[STRING_MANUFACTURER_IDX].id = id; | 264 | |
279 | device_desc.iManufacturer = id; | 265 | device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id; |
280 | 266 | device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; | |
281 | id = usb_string_id(cdev); | 267 | device_desc.iSerialNumber = strings_dev[USB_GADGET_SERIAL_IDX].id; |
282 | if (id < 0) | ||
283 | return id; | ||
284 | strings_dev[STRING_PRODUCT_IDX].id = id; | ||
285 | device_desc.iProduct = id; | ||
286 | |||
287 | id = usb_string_id(cdev); | ||
288 | if (id < 0) | ||
289 | return id; | ||
290 | strings_dev[STRING_SERIAL_IDX].id = id; | ||
291 | device_desc.iSerialNumber = id; | ||
292 | 268 | ||
293 | setup_timer(&autoresume_timer, zero_autoresume, (unsigned long) cdev); | 269 | setup_timer(&autoresume_timer, zero_autoresume, (unsigned long) cdev); |
294 | 270 | ||
@@ -303,28 +279,10 @@ static int __init zero_bind(struct usb_composite_dev *cdev) | |||
303 | loopback_add(cdev, autoresume != 0); | 279 | loopback_add(cdev, autoresume != 0); |
304 | } | 280 | } |
305 | 281 | ||
306 | gcnum = usb_gadget_controller_number(gadget); | 282 | usb_composite_overwrite_options(cdev, &coverwrite); |
307 | if (gcnum >= 0) | ||
308 | device_desc.bcdDevice = cpu_to_le16(0x0200 + gcnum); | ||
309 | else { | ||
310 | /* gadget zero is so simple (for now, no altsettings) that | ||
311 | * it SHOULD NOT have problems with bulk-capable hardware. | ||
312 | * so just warn about unrcognized controllers -- don't panic. | ||
313 | * | ||
314 | * things like configuration and altsetting numbering | ||
315 | * can need hardware-specific attention though. | ||
316 | */ | ||
317 | pr_warning("%s: controller '%s' not recognized\n", | ||
318 | longname, gadget->name); | ||
319 | device_desc.bcdDevice = cpu_to_le16(0x9999); | ||
320 | } | ||
321 | 283 | ||
322 | INFO(cdev, "%s, version: " DRIVER_VERSION "\n", longname); | 284 | INFO(cdev, "%s, version: " DRIVER_VERSION "\n", longname); |
323 | 285 | ||
324 | snprintf(manufacturer, sizeof manufacturer, "%s %s with %s", | ||
325 | init_utsname()->sysname, init_utsname()->release, | ||
326 | gadget->name); | ||
327 | |||
328 | return 0; | 286 | return 0; |
329 | } | 287 | } |
330 | 288 | ||
@@ -334,11 +292,12 @@ static int zero_unbind(struct usb_composite_dev *cdev) | |||
334 | return 0; | 292 | return 0; |
335 | } | 293 | } |
336 | 294 | ||
337 | static struct usb_composite_driver zero_driver = { | 295 | static __refdata struct usb_composite_driver zero_driver = { |
338 | .name = "zero", | 296 | .name = "zero", |
339 | .dev = &device_desc, | 297 | .dev = &device_desc, |
340 | .strings = dev_strings, | 298 | .strings = dev_strings, |
341 | .max_speed = USB_SPEED_SUPER, | 299 | .max_speed = USB_SPEED_SUPER, |
300 | .bind = zero_bind, | ||
342 | .unbind = zero_unbind, | 301 | .unbind = zero_unbind, |
343 | .suspend = zero_suspend, | 302 | .suspend = zero_suspend, |
344 | .resume = zero_resume, | 303 | .resume = zero_resume, |
@@ -349,7 +308,7 @@ MODULE_LICENSE("GPL"); | |||
349 | 308 | ||
350 | static int __init init(void) | 309 | static int __init init(void) |
351 | { | 310 | { |
352 | return usb_composite_probe(&zero_driver, zero_bind); | 311 | return usb_composite_probe(&zero_driver); |
353 | } | 312 | } |
354 | module_init(init); | 313 | module_init(init); |
355 | 314 | ||
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index 075d2eca8108..b1deb0fd4197 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig | |||
@@ -18,8 +18,8 @@ config USB_C67X00_HCD | |||
18 | module will be called c67x00. | 18 | module will be called c67x00. |
19 | 19 | ||
20 | config USB_XHCI_HCD | 20 | config USB_XHCI_HCD |
21 | tristate "xHCI HCD (USB 3.0) support (EXPERIMENTAL)" | 21 | tristate "xHCI HCD (USB 3.0) support" |
22 | depends on USB && USB_ARCH_HAS_XHCI && EXPERIMENTAL | 22 | depends on USB && USB_ARCH_HAS_XHCI |
23 | ---help--- | 23 | ---help--- |
24 | The eXtensible Host Controller Interface (xHCI) is standard for USB 3.0 | 24 | The eXtensible Host Controller Interface (xHCI) is standard for USB 3.0 |
25 | "SuperSpeed" host controller hardware. | 25 | "SuperSpeed" host controller hardware. |
@@ -262,7 +262,7 @@ config USB_ISP116X_HCD | |||
262 | 262 | ||
263 | config USB_ISP1760_HCD | 263 | config USB_ISP1760_HCD |
264 | tristate "ISP 1760 HCD support" | 264 | tristate "ISP 1760 HCD support" |
265 | depends on USB && EXPERIMENTAL | 265 | depends on USB |
266 | ---help--- | 266 | ---help--- |
267 | The ISP1760 chip is a USB 2.0 host controller. | 267 | The ISP1760 chip is a USB 2.0 host controller. |
268 | 268 | ||
@@ -292,7 +292,7 @@ config USB_OHCI_HCD | |||
292 | depends on USB && USB_ARCH_HAS_OHCI | 292 | depends on USB && USB_ARCH_HAS_OHCI |
293 | select ISP1301_OMAP if MACH_OMAP_H2 || MACH_OMAP_H3 | 293 | select ISP1301_OMAP if MACH_OMAP_H2 || MACH_OMAP_H3 |
294 | select USB_OTG_UTILS if ARCH_OMAP | 294 | select USB_OTG_UTILS if ARCH_OMAP |
295 | select USB_ISP1301 if ARCH_LPC32XX || ARCH_PNX4008 | 295 | depends on USB_ISP1301 || !(ARCH_LPC32XX || ARCH_PNX4008) |
296 | ---help--- | 296 | ---help--- |
297 | The Open Host Controller Interface (OHCI) is a standard for accessing | 297 | The Open Host Controller Interface (OHCI) is a standard for accessing |
298 | USB 1.1 host controller hardware. It does more in hardware than Intel's | 298 | USB 1.1 host controller hardware. It does more in hardware than Intel's |
@@ -376,7 +376,7 @@ config USB_OHCI_HCD_PCI | |||
376 | 376 | ||
377 | config USB_OHCI_HCD_SSB | 377 | config USB_OHCI_HCD_SSB |
378 | bool "OHCI support for Broadcom SSB OHCI core (DEPRECATED)" | 378 | bool "OHCI support for Broadcom SSB OHCI core (DEPRECATED)" |
379 | depends on USB_OHCI_HCD && (SSB = y || SSB = USB_OHCI_HCD) && EXPERIMENTAL | 379 | depends on USB_OHCI_HCD && (SSB = y || SSB = USB_OHCI_HCD) |
380 | select USB_HCD_SSB | 380 | select USB_HCD_SSB |
381 | select USB_OHCI_HCD_PLATFORM | 381 | select USB_OHCI_HCD_PLATFORM |
382 | default n | 382 | default n |
@@ -414,21 +414,21 @@ config USB_CNS3XXX_OHCI | |||
414 | 414 | ||
415 | config USB_OHCI_HCD_PLATFORM | 415 | config USB_OHCI_HCD_PLATFORM |
416 | bool "Generic OHCI driver for a platform device" | 416 | bool "Generic OHCI driver for a platform device" |
417 | depends on USB_OHCI_HCD && EXPERIMENTAL | 417 | depends on USB_OHCI_HCD |
418 | default n | 418 | default n |
419 | ---help--- | 419 | ---help--- |
420 | Adds an OHCI host driver for a generic platform device, which | 420 | Adds an OHCI host driver for a generic platform device, which |
421 | provieds a memory space and an irq. | 421 | provides a memory space and an irq. |
422 | 422 | ||
423 | If unsure, say N. | 423 | If unsure, say N. |
424 | 424 | ||
425 | config USB_EHCI_HCD_PLATFORM | 425 | config USB_EHCI_HCD_PLATFORM |
426 | bool "Generic EHCI driver for a platform device" | 426 | bool "Generic EHCI driver for a platform device" |
427 | depends on USB_EHCI_HCD && EXPERIMENTAL | 427 | depends on USB_EHCI_HCD |
428 | default n | 428 | default n |
429 | ---help--- | 429 | ---help--- |
430 | Adds an EHCI host driver for a generic platform device, which | 430 | Adds an EHCI host driver for a generic platform device, which |
431 | provieds a memory space and an irq. | 431 | provides a memory space and an irq. |
432 | 432 | ||
433 | If unsure, say N. | 433 | If unsure, say N. |
434 | 434 | ||
@@ -450,7 +450,7 @@ config USB_OHCI_LITTLE_ENDIAN | |||
450 | 450 | ||
451 | config USB_UHCI_HCD | 451 | config USB_UHCI_HCD |
452 | tristate "UHCI HCD (most Intel and VIA) support" | 452 | tristate "UHCI HCD (most Intel and VIA) support" |
453 | depends on USB && (PCI || SPARC_LEON) | 453 | depends on USB && (PCI || SPARC_LEON || ARCH_VT8500) |
454 | ---help--- | 454 | ---help--- |
455 | The Universal Host Controller Interface is a standard by Intel for | 455 | The Universal Host Controller Interface is a standard by Intel for |
456 | accessing the USB hardware in the PC (which is also called the USB | 456 | accessing the USB hardware in the PC (which is also called the USB |
@@ -468,7 +468,15 @@ config USB_UHCI_HCD | |||
468 | config USB_UHCI_SUPPORT_NON_PCI_HC | 468 | config USB_UHCI_SUPPORT_NON_PCI_HC |
469 | bool | 469 | bool |
470 | depends on USB_UHCI_HCD | 470 | depends on USB_UHCI_HCD |
471 | default y if SPARC_LEON | 471 | default y if (SPARC_LEON || ARCH_VT8500) |
472 | |||
473 | config USB_UHCI_PLATFORM | ||
474 | bool "Generic UHCI Platform Driver support" | ||
475 | depends on USB_UHCI_SUPPORT_NON_PCI_HC | ||
476 | default y if ARCH_VT8500 | ||
477 | ---help--- | ||
478 | Enable support for generic UHCI platform devices that require no | ||
479 | additional configuration. | ||
472 | 480 | ||
473 | config USB_UHCI_BIG_ENDIAN_MMIO | 481 | config USB_UHCI_BIG_ENDIAN_MMIO |
474 | bool | 482 | bool |
@@ -583,8 +591,7 @@ config USB_RENESAS_USBHS_HCD | |||
583 | module will be called renesas-usbhs. | 591 | module will be called renesas-usbhs. |
584 | 592 | ||
585 | config USB_WHCI_HCD | 593 | config USB_WHCI_HCD |
586 | tristate "Wireless USB Host Controller Interface (WHCI) driver (EXPERIMENTAL)" | 594 | tristate "Wireless USB Host Controller Interface (WHCI) driver" |
587 | depends on EXPERIMENTAL | ||
588 | depends on PCI && USB && UWB | 595 | depends on PCI && USB && UWB |
589 | select USB_WUSB | 596 | select USB_WUSB |
590 | select UWB_WHCI | 597 | select UWB_WHCI |
@@ -596,8 +603,7 @@ config USB_WHCI_HCD | |||
596 | will be called "whci-hcd". | 603 | will be called "whci-hcd". |
597 | 604 | ||
598 | config USB_HWA_HCD | 605 | config USB_HWA_HCD |
599 | tristate "Host Wire Adapter (HWA) driver (EXPERIMENTAL)" | 606 | tristate "Host Wire Adapter (HWA) driver" |
600 | depends on EXPERIMENTAL | ||
601 | depends on USB && UWB | 607 | depends on USB && UWB |
602 | select USB_WUSB | 608 | select USB_WUSB |
603 | select UWB_HWA | 609 | select UWB_HWA |
@@ -648,7 +654,7 @@ config USB_OCTEON2_COMMON | |||
648 | 654 | ||
649 | config USB_HCD_BCMA | 655 | config USB_HCD_BCMA |
650 | tristate "BCMA usb host driver" | 656 | tristate "BCMA usb host driver" |
651 | depends on BCMA && EXPERIMENTAL | 657 | depends on BCMA |
652 | select USB_OHCI_HCD_PLATFORM if USB_OHCI_HCD | 658 | select USB_OHCI_HCD_PLATFORM if USB_OHCI_HCD |
653 | select USB_EHCI_HCD_PLATFORM if USB_EHCI_HCD | 659 | select USB_EHCI_HCD_PLATFORM if USB_EHCI_HCD |
654 | help | 660 | help |
@@ -660,7 +666,7 @@ config USB_HCD_BCMA | |||
660 | 666 | ||
661 | config USB_HCD_SSB | 667 | config USB_HCD_SSB |
662 | tristate "SSB usb host driver" | 668 | tristate "SSB usb host driver" |
663 | depends on SSB && EXPERIMENTAL | 669 | depends on SSB |
664 | select USB_OHCI_HCD_PLATFORM if USB_OHCI_HCD | 670 | select USB_OHCI_HCD_PLATFORM if USB_OHCI_HCD |
665 | select USB_EHCI_HCD_PLATFORM if USB_EHCI_HCD | 671 | select USB_EHCI_HCD_PLATFORM if USB_EHCI_HCD |
666 | help | 672 | help |
diff --git a/drivers/usb/host/ehci-atmel.c b/drivers/usb/host/ehci-atmel.c index a47e2cffaaf8..411bb74152eb 100644 --- a/drivers/usb/host/ehci-atmel.c +++ b/drivers/usb/host/ehci-atmel.c | |||
@@ -150,31 +150,24 @@ static int __devinit ehci_atmel_drv_probe(struct platform_device *pdev) | |||
150 | hcd->rsrc_start = res->start; | 150 | hcd->rsrc_start = res->start; |
151 | hcd->rsrc_len = resource_size(res); | 151 | hcd->rsrc_len = resource_size(res); |
152 | 152 | ||
153 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, | 153 | hcd->regs = devm_request_and_ioremap(&pdev->dev, res); |
154 | driver->description)) { | ||
155 | dev_dbg(&pdev->dev, "controller already in use\n"); | ||
156 | retval = -EBUSY; | ||
157 | goto fail_request_resource; | ||
158 | } | ||
159 | |||
160 | hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len); | ||
161 | if (hcd->regs == NULL) { | 154 | if (hcd->regs == NULL) { |
162 | dev_dbg(&pdev->dev, "error mapping memory\n"); | 155 | dev_dbg(&pdev->dev, "error mapping memory\n"); |
163 | retval = -EFAULT; | 156 | retval = -EFAULT; |
164 | goto fail_ioremap; | 157 | goto fail_request_resource; |
165 | } | 158 | } |
166 | 159 | ||
167 | iclk = clk_get(&pdev->dev, "ehci_clk"); | 160 | iclk = devm_clk_get(&pdev->dev, "ehci_clk"); |
168 | if (IS_ERR(iclk)) { | 161 | if (IS_ERR(iclk)) { |
169 | dev_err(&pdev->dev, "Error getting interface clock\n"); | 162 | dev_err(&pdev->dev, "Error getting interface clock\n"); |
170 | retval = -ENOENT; | 163 | retval = -ENOENT; |
171 | goto fail_get_iclk; | 164 | goto fail_request_resource; |
172 | } | 165 | } |
173 | fclk = clk_get(&pdev->dev, "uhpck"); | 166 | fclk = devm_clk_get(&pdev->dev, "uhpck"); |
174 | if (IS_ERR(fclk)) { | 167 | if (IS_ERR(fclk)) { |
175 | dev_err(&pdev->dev, "Error getting function clock\n"); | 168 | dev_err(&pdev->dev, "Error getting function clock\n"); |
176 | retval = -ENOENT; | 169 | retval = -ENOENT; |
177 | goto fail_get_fclk; | 170 | goto fail_request_resource; |
178 | } | 171 | } |
179 | 172 | ||
180 | atmel_start_ehci(pdev); | 173 | atmel_start_ehci(pdev); |
@@ -187,13 +180,6 @@ static int __devinit ehci_atmel_drv_probe(struct platform_device *pdev) | |||
187 | 180 | ||
188 | fail_add_hcd: | 181 | fail_add_hcd: |
189 | atmel_stop_ehci(pdev); | 182 | atmel_stop_ehci(pdev); |
190 | clk_put(fclk); | ||
191 | fail_get_fclk: | ||
192 | clk_put(iclk); | ||
193 | fail_get_iclk: | ||
194 | iounmap(hcd->regs); | ||
195 | fail_ioremap: | ||
196 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
197 | fail_request_resource: | 183 | fail_request_resource: |
198 | usb_put_hcd(hcd); | 184 | usb_put_hcd(hcd); |
199 | fail_create_hcd: | 185 | fail_create_hcd: |
@@ -209,13 +195,9 @@ static int __devexit ehci_atmel_drv_remove(struct platform_device *pdev) | |||
209 | 195 | ||
210 | ehci_shutdown(hcd); | 196 | ehci_shutdown(hcd); |
211 | usb_remove_hcd(hcd); | 197 | usb_remove_hcd(hcd); |
212 | iounmap(hcd->regs); | ||
213 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
214 | usb_put_hcd(hcd); | 198 | usb_put_hcd(hcd); |
215 | 199 | ||
216 | atmel_stop_ehci(pdev); | 200 | atmel_stop_ehci(pdev); |
217 | clk_put(fclk); | ||
218 | clk_put(iclk); | ||
219 | fclk = iclk = NULL; | 201 | fclk = iclk = NULL; |
220 | 202 | ||
221 | return 0; | 203 | return 0; |
diff --git a/drivers/usb/host/ehci-au1xxx.c b/drivers/usb/host/ehci-au1xxx.c index cba10d625a5d..65c945eb4144 100644 --- a/drivers/usb/host/ehci-au1xxx.c +++ b/drivers/usb/host/ehci-au1xxx.c | |||
@@ -98,23 +98,17 @@ static int ehci_hcd_au1xxx_drv_probe(struct platform_device *pdev) | |||
98 | hcd->rsrc_start = res->start; | 98 | hcd->rsrc_start = res->start; |
99 | hcd->rsrc_len = resource_size(res); | 99 | hcd->rsrc_len = resource_size(res); |
100 | 100 | ||
101 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { | 101 | hcd->regs = devm_request_and_ioremap(&pdev->dev, res); |
102 | pr_debug("request_mem_region failed"); | ||
103 | ret = -EBUSY; | ||
104 | goto err1; | ||
105 | } | ||
106 | |||
107 | hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); | ||
108 | if (!hcd->regs) { | 102 | if (!hcd->regs) { |
109 | pr_debug("ioremap failed"); | 103 | pr_debug("devm_request_and_ioremap failed"); |
110 | ret = -ENOMEM; | 104 | ret = -ENOMEM; |
111 | goto err2; | 105 | goto err1; |
112 | } | 106 | } |
113 | 107 | ||
114 | if (alchemy_usb_control(ALCHEMY_USB_EHCI0, 1)) { | 108 | if (alchemy_usb_control(ALCHEMY_USB_EHCI0, 1)) { |
115 | printk(KERN_INFO "%s: controller init failed!\n", pdev->name); | 109 | printk(KERN_INFO "%s: controller init failed!\n", pdev->name); |
116 | ret = -ENODEV; | 110 | ret = -ENODEV; |
117 | goto err3; | 111 | goto err1; |
118 | } | 112 | } |
119 | 113 | ||
120 | ret = usb_add_hcd(hcd, pdev->resource[1].start, | 114 | ret = usb_add_hcd(hcd, pdev->resource[1].start, |
@@ -125,10 +119,6 @@ static int ehci_hcd_au1xxx_drv_probe(struct platform_device *pdev) | |||
125 | } | 119 | } |
126 | 120 | ||
127 | alchemy_usb_control(ALCHEMY_USB_EHCI0, 0); | 121 | alchemy_usb_control(ALCHEMY_USB_EHCI0, 0); |
128 | err3: | ||
129 | iounmap(hcd->regs); | ||
130 | err2: | ||
131 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
132 | err1: | 122 | err1: |
133 | usb_put_hcd(hcd); | 123 | usb_put_hcd(hcd); |
134 | return ret; | 124 | return ret; |
@@ -140,8 +130,6 @@ static int ehci_hcd_au1xxx_drv_remove(struct platform_device *pdev) | |||
140 | 130 | ||
141 | usb_remove_hcd(hcd); | 131 | usb_remove_hcd(hcd); |
142 | alchemy_usb_control(ALCHEMY_USB_EHCI0, 0); | 132 | alchemy_usb_control(ALCHEMY_USB_EHCI0, 0); |
143 | iounmap(hcd->regs); | ||
144 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
145 | usb_put_hcd(hcd); | 133 | usb_put_hcd(hcd); |
146 | platform_set_drvdata(pdev, NULL); | 134 | platform_set_drvdata(pdev, NULL); |
147 | 135 | ||
diff --git a/drivers/usb/host/ehci-cns3xxx.c b/drivers/usb/host/ehci-cns3xxx.c index caaa3e5be334..d91708d2e729 100644 --- a/drivers/usb/host/ehci-cns3xxx.c +++ b/drivers/usb/host/ehci-cns3xxx.c | |||
@@ -105,27 +105,17 @@ static int cns3xxx_ehci_probe(struct platform_device *pdev) | |||
105 | hcd->rsrc_start = res->start; | 105 | hcd->rsrc_start = res->start; |
106 | hcd->rsrc_len = resource_size(res); | 106 | hcd->rsrc_len = resource_size(res); |
107 | 107 | ||
108 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, | 108 | hcd->regs = devm_request_and_ioremap(&pdev->dev, res); |
109 | driver->description)) { | ||
110 | dev_dbg(dev, "controller already in use\n"); | ||
111 | retval = -EBUSY; | ||
112 | goto err1; | ||
113 | } | ||
114 | |||
115 | hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); | ||
116 | if (hcd->regs == NULL) { | 109 | if (hcd->regs == NULL) { |
117 | dev_dbg(dev, "error mapping memory\n"); | 110 | dev_dbg(dev, "error mapping memory\n"); |
118 | retval = -EFAULT; | 111 | retval = -EFAULT; |
119 | goto err2; | 112 | goto err1; |
120 | } | 113 | } |
121 | 114 | ||
122 | retval = usb_add_hcd(hcd, irq, IRQF_SHARED); | 115 | retval = usb_add_hcd(hcd, irq, IRQF_SHARED); |
123 | if (retval == 0) | 116 | if (retval == 0) |
124 | return retval; | 117 | return retval; |
125 | 118 | ||
126 | iounmap(hcd->regs); | ||
127 | err2: | ||
128 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
129 | err1: | 119 | err1: |
130 | usb_put_hcd(hcd); | 120 | usb_put_hcd(hcd); |
131 | 121 | ||
@@ -137,8 +127,6 @@ static int cns3xxx_ehci_remove(struct platform_device *pdev) | |||
137 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | 127 | struct usb_hcd *hcd = platform_get_drvdata(pdev); |
138 | 128 | ||
139 | usb_remove_hcd(hcd); | 129 | usb_remove_hcd(hcd); |
140 | iounmap(hcd->regs); | ||
141 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
142 | 130 | ||
143 | /* | 131 | /* |
144 | * EHCI and OHCI share the same clock and power, | 132 | * EHCI and OHCI share the same clock and power, |
diff --git a/drivers/usb/host/ehci-dbg.c b/drivers/usb/host/ehci-dbg.c index f0c00de035ef..1599806e3d47 100644 --- a/drivers/usb/host/ehci-dbg.c +++ b/drivers/usb/host/ehci-dbg.c | |||
@@ -653,10 +653,8 @@ static ssize_t fill_periodic_buffer(struct debug_buffer *buf) | |||
653 | seen [seen_count++].qh = p.qh; | 653 | seen [seen_count++].qh = p.qh; |
654 | } else | 654 | } else |
655 | temp = 0; | 655 | temp = 0; |
656 | if (p.qh) { | 656 | tag = Q_NEXT_TYPE(ehci, hw->hw_next); |
657 | tag = Q_NEXT_TYPE(ehci, hw->hw_next); | 657 | p = p.qh->qh_next; |
658 | p = p.qh->qh_next; | ||
659 | } | ||
660 | break; | 658 | break; |
661 | case Q_TYPE_FSTN: | 659 | case Q_TYPE_FSTN: |
662 | temp = scnprintf (next, size, | 660 | temp = scnprintf (next, size, |
diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c index b7451b29c5ac..9bfde82078ec 100644 --- a/drivers/usb/host/ehci-fsl.c +++ b/drivers/usb/host/ehci-fsl.c | |||
@@ -210,11 +210,11 @@ static void usb_hcd_fsl_remove(struct usb_hcd *hcd, | |||
210 | usb_put_hcd(hcd); | 210 | usb_put_hcd(hcd); |
211 | } | 211 | } |
212 | 212 | ||
213 | static void ehci_fsl_setup_phy(struct usb_hcd *hcd, | 213 | static int ehci_fsl_setup_phy(struct usb_hcd *hcd, |
214 | enum fsl_usb2_phy_modes phy_mode, | 214 | enum fsl_usb2_phy_modes phy_mode, |
215 | unsigned int port_offset) | 215 | unsigned int port_offset) |
216 | { | 216 | { |
217 | u32 portsc, temp; | 217 | u32 portsc; |
218 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | 218 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); |
219 | void __iomem *non_ehci = hcd->regs; | 219 | void __iomem *non_ehci = hcd->regs; |
220 | struct device *dev = hcd->self.controller; | 220 | struct device *dev = hcd->self.controller; |
@@ -232,9 +232,15 @@ static void ehci_fsl_setup_phy(struct usb_hcd *hcd, | |||
232 | case FSL_USB2_PHY_ULPI: | 232 | case FSL_USB2_PHY_ULPI: |
233 | if (pdata->controller_ver) { | 233 | if (pdata->controller_ver) { |
234 | /* controller version 1.6 or above */ | 234 | /* controller version 1.6 or above */ |
235 | temp = in_be32(non_ehci + FSL_SOC_USB_CTRL); | 235 | setbits32(non_ehci + FSL_SOC_USB_CTRL, |
236 | out_be32(non_ehci + FSL_SOC_USB_CTRL, temp | | 236 | ULPI_PHY_CLK_SEL); |
237 | USB_CTRL_USB_EN | ULPI_PHY_CLK_SEL); | 237 | /* |
238 | * Due to controller issue of PHY_CLK_VALID in ULPI | ||
239 | * mode, we set USB_CTRL_USB_EN before checking | ||
240 | * PHY_CLK_VALID, otherwise PHY_CLK_VALID doesn't work. | ||
241 | */ | ||
242 | clrsetbits_be32(non_ehci + FSL_SOC_USB_CTRL, | ||
243 | UTMI_PHY_EN, USB_CTRL_USB_EN); | ||
238 | } | 244 | } |
239 | portsc |= PORT_PTS_ULPI; | 245 | portsc |= PORT_PTS_ULPI; |
240 | break; | 246 | break; |
@@ -247,9 +253,7 @@ static void ehci_fsl_setup_phy(struct usb_hcd *hcd, | |||
247 | case FSL_USB2_PHY_UTMI: | 253 | case FSL_USB2_PHY_UTMI: |
248 | if (pdata->controller_ver) { | 254 | if (pdata->controller_ver) { |
249 | /* controller version 1.6 or above */ | 255 | /* controller version 1.6 or above */ |
250 | temp = in_be32(non_ehci + FSL_SOC_USB_CTRL); | 256 | setbits32(non_ehci + FSL_SOC_USB_CTRL, UTMI_PHY_EN); |
251 | out_be32(non_ehci + FSL_SOC_USB_CTRL, temp | | ||
252 | UTMI_PHY_EN | USB_CTRL_USB_EN); | ||
253 | mdelay(FSL_UTMI_PHY_DLY); /* Delay for UTMI PHY CLK to | 257 | mdelay(FSL_UTMI_PHY_DLY); /* Delay for UTMI PHY CLK to |
254 | become stable - 10ms*/ | 258 | become stable - 10ms*/ |
255 | } | 259 | } |
@@ -262,23 +266,33 @@ static void ehci_fsl_setup_phy(struct usb_hcd *hcd, | |||
262 | case FSL_USB2_PHY_NONE: | 266 | case FSL_USB2_PHY_NONE: |
263 | break; | 267 | break; |
264 | } | 268 | } |
269 | |||
270 | if (pdata->controller_ver && (phy_mode == FSL_USB2_PHY_ULPI)) { | ||
271 | /* check PHY_CLK_VALID to get phy clk valid */ | ||
272 | if (!spin_event_timeout(in_be32(non_ehci + FSL_SOC_USB_CTRL) & | ||
273 | PHY_CLK_VALID, FSL_USB_PHY_CLK_TIMEOUT, 0)) { | ||
274 | printk(KERN_WARNING "fsl-ehci: USB PHY clock invalid\n"); | ||
275 | return -EINVAL; | ||
276 | } | ||
277 | } | ||
278 | |||
265 | ehci_writel(ehci, portsc, &ehci->regs->port_status[port_offset]); | 279 | ehci_writel(ehci, portsc, &ehci->regs->port_status[port_offset]); |
280 | |||
281 | if (phy_mode != FSL_USB2_PHY_ULPI) | ||
282 | setbits32(non_ehci + FSL_SOC_USB_CTRL, USB_CTRL_USB_EN); | ||
283 | |||
284 | return 0; | ||
266 | } | 285 | } |
267 | 286 | ||
268 | static void ehci_fsl_usb_setup(struct ehci_hcd *ehci) | 287 | static int ehci_fsl_usb_setup(struct ehci_hcd *ehci) |
269 | { | 288 | { |
270 | struct usb_hcd *hcd = ehci_to_hcd(ehci); | 289 | struct usb_hcd *hcd = ehci_to_hcd(ehci); |
271 | struct fsl_usb2_platform_data *pdata; | 290 | struct fsl_usb2_platform_data *pdata; |
272 | void __iomem *non_ehci = hcd->regs; | 291 | void __iomem *non_ehci = hcd->regs; |
273 | u32 temp; | ||
274 | 292 | ||
275 | pdata = hcd->self.controller->platform_data; | 293 | pdata = hcd->self.controller->platform_data; |
276 | 294 | ||
277 | /* Enable PHY interface in the control reg. */ | ||
278 | if (pdata->have_sysif_regs) { | 295 | if (pdata->have_sysif_regs) { |
279 | temp = in_be32(non_ehci + FSL_SOC_USB_CTRL); | ||
280 | out_be32(non_ehci + FSL_SOC_USB_CTRL, temp | 0x00000004); | ||
281 | |||
282 | /* | 296 | /* |
283 | * Turn on cache snooping hardware, since some PowerPC platforms | 297 | * Turn on cache snooping hardware, since some PowerPC platforms |
284 | * wholly rely on hardware to deal with cache coherent | 298 | * wholly rely on hardware to deal with cache coherent |
@@ -293,7 +307,8 @@ static void ehci_fsl_usb_setup(struct ehci_hcd *ehci) | |||
293 | 307 | ||
294 | if ((pdata->operating_mode == FSL_USB2_DR_HOST) || | 308 | if ((pdata->operating_mode == FSL_USB2_DR_HOST) || |
295 | (pdata->operating_mode == FSL_USB2_DR_OTG)) | 309 | (pdata->operating_mode == FSL_USB2_DR_OTG)) |
296 | ehci_fsl_setup_phy(hcd, pdata->phy_mode, 0); | 310 | if (ehci_fsl_setup_phy(hcd, pdata->phy_mode, 0)) |
311 | return -EINVAL; | ||
297 | 312 | ||
298 | if (pdata->operating_mode == FSL_USB2_MPH_HOST) { | 313 | if (pdata->operating_mode == FSL_USB2_MPH_HOST) { |
299 | unsigned int chip, rev, svr; | 314 | unsigned int chip, rev, svr; |
@@ -307,9 +322,12 @@ static void ehci_fsl_usb_setup(struct ehci_hcd *ehci) | |||
307 | ehci->has_fsl_port_bug = 1; | 322 | ehci->has_fsl_port_bug = 1; |
308 | 323 | ||
309 | if (pdata->port_enables & FSL_USB2_PORT0_ENABLED) | 324 | if (pdata->port_enables & FSL_USB2_PORT0_ENABLED) |
310 | ehci_fsl_setup_phy(hcd, pdata->phy_mode, 0); | 325 | if (ehci_fsl_setup_phy(hcd, pdata->phy_mode, 0)) |
326 | return -EINVAL; | ||
327 | |||
311 | if (pdata->port_enables & FSL_USB2_PORT1_ENABLED) | 328 | if (pdata->port_enables & FSL_USB2_PORT1_ENABLED) |
312 | ehci_fsl_setup_phy(hcd, pdata->phy_mode, 1); | 329 | if (ehci_fsl_setup_phy(hcd, pdata->phy_mode, 1)) |
330 | return -EINVAL; | ||
313 | } | 331 | } |
314 | 332 | ||
315 | if (pdata->have_sysif_regs) { | 333 | if (pdata->have_sysif_regs) { |
@@ -322,12 +340,15 @@ static void ehci_fsl_usb_setup(struct ehci_hcd *ehci) | |||
322 | #endif | 340 | #endif |
323 | out_be32(non_ehci + FSL_SOC_USB_SICTRL, 0x00000001); | 341 | out_be32(non_ehci + FSL_SOC_USB_SICTRL, 0x00000001); |
324 | } | 342 | } |
343 | |||
344 | return 0; | ||
325 | } | 345 | } |
326 | 346 | ||
327 | /* called after powerup, by probe or system-pm "wakeup" */ | 347 | /* called after powerup, by probe or system-pm "wakeup" */ |
328 | static int ehci_fsl_reinit(struct ehci_hcd *ehci) | 348 | static int ehci_fsl_reinit(struct ehci_hcd *ehci) |
329 | { | 349 | { |
330 | ehci_fsl_usb_setup(ehci); | 350 | if (ehci_fsl_usb_setup(ehci)) |
351 | return -EINVAL; | ||
331 | ehci_port_power(ehci, 0); | 352 | ehci_port_power(ehci, 0); |
332 | 353 | ||
333 | return 0; | 354 | return 0; |
diff --git a/drivers/usb/host/ehci-fsl.h b/drivers/usb/host/ehci-fsl.h index 88403684d10b..dbd292e9f0a7 100644 --- a/drivers/usb/host/ehci-fsl.h +++ b/drivers/usb/host/ehci-fsl.h | |||
@@ -61,4 +61,5 @@ | |||
61 | #define PLL_RESET (1<<8) | 61 | #define PLL_RESET (1<<8) |
62 | #define UTMI_PHY_EN (1<<9) | 62 | #define UTMI_PHY_EN (1<<9) |
63 | #define ULPI_PHY_CLK_SEL (1<<10) | 63 | #define ULPI_PHY_CLK_SEL (1<<10) |
64 | #define PHY_CLK_VALID (1<<17) | ||
64 | #endif /* _EHCI_FSL_H */ | 65 | #endif /* _EHCI_FSL_H */ |
diff --git a/drivers/usb/host/ehci-grlib.c b/drivers/usb/host/ehci-grlib.c index 22ca45c079a4..3180cb3624d9 100644 --- a/drivers/usb/host/ehci-grlib.c +++ b/drivers/usb/host/ehci-grlib.c | |||
@@ -127,12 +127,6 @@ static int __devinit ehci_hcd_grlib_probe(struct platform_device *op) | |||
127 | hcd->rsrc_start = res.start; | 127 | hcd->rsrc_start = res.start; |
128 | hcd->rsrc_len = resource_size(&res); | 128 | hcd->rsrc_len = resource_size(&res); |
129 | 129 | ||
130 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { | ||
131 | printk(KERN_ERR "%s: request_mem_region failed\n", __FILE__); | ||
132 | rv = -EBUSY; | ||
133 | goto err_rmr; | ||
134 | } | ||
135 | |||
136 | irq = irq_of_parse_and_map(dn, 0); | 130 | irq = irq_of_parse_and_map(dn, 0); |
137 | if (irq == NO_IRQ) { | 131 | if (irq == NO_IRQ) { |
138 | printk(KERN_ERR "%s: irq_of_parse_and_map failed\n", __FILE__); | 132 | printk(KERN_ERR "%s: irq_of_parse_and_map failed\n", __FILE__); |
@@ -140,9 +134,9 @@ static int __devinit ehci_hcd_grlib_probe(struct platform_device *op) | |||
140 | goto err_irq; | 134 | goto err_irq; |
141 | } | 135 | } |
142 | 136 | ||
143 | hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); | 137 | hcd->regs = devm_request_and_ioremap(&op->dev, &res); |
144 | if (!hcd->regs) { | 138 | if (!hcd->regs) { |
145 | printk(KERN_ERR "%s: ioremap failed\n", __FILE__); | 139 | pr_err("%s: devm_request_and_ioremap failed\n", __FILE__); |
146 | rv = -ENOMEM; | 140 | rv = -ENOMEM; |
147 | goto err_ioremap; | 141 | goto err_ioremap; |
148 | } | 142 | } |
@@ -161,17 +155,13 @@ static int __devinit ehci_hcd_grlib_probe(struct platform_device *op) | |||
161 | 155 | ||
162 | rv = usb_add_hcd(hcd, irq, 0); | 156 | rv = usb_add_hcd(hcd, irq, 0); |
163 | if (rv) | 157 | if (rv) |
164 | goto err_ehci; | 158 | goto err_ioremap; |
165 | 159 | ||
166 | return 0; | 160 | return 0; |
167 | 161 | ||
168 | err_ehci: | ||
169 | iounmap(hcd->regs); | ||
170 | err_ioremap: | 162 | err_ioremap: |
171 | irq_dispose_mapping(irq); | 163 | irq_dispose_mapping(irq); |
172 | err_irq: | 164 | err_irq: |
173 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
174 | err_rmr: | ||
175 | usb_put_hcd(hcd); | 165 | usb_put_hcd(hcd); |
176 | 166 | ||
177 | return rv; | 167 | return rv; |
@@ -188,9 +178,7 @@ static int ehci_hcd_grlib_remove(struct platform_device *op) | |||
188 | 178 | ||
189 | usb_remove_hcd(hcd); | 179 | usb_remove_hcd(hcd); |
190 | 180 | ||
191 | iounmap(hcd->regs); | ||
192 | irq_dispose_mapping(hcd->irq); | 181 | irq_dispose_mapping(hcd->irq); |
193 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
194 | 182 | ||
195 | usb_put_hcd(hcd); | 183 | usb_put_hcd(hcd); |
196 | 184 | ||
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index b05c6865b610..6bf6c42481e8 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c | |||
@@ -228,7 +228,7 @@ static int ehci_reset (struct ehci_hcd *ehci) | |||
228 | 228 | ||
229 | /* If the EHCI debug controller is active, special care must be | 229 | /* If the EHCI debug controller is active, special care must be |
230 | * taken before and after a host controller reset */ | 230 | * taken before and after a host controller reset */ |
231 | if (ehci->debug && !dbgp_reset_prep()) | 231 | if (ehci->debug && !dbgp_reset_prep(ehci_to_hcd(ehci))) |
232 | ehci->debug = NULL; | 232 | ehci->debug = NULL; |
233 | 233 | ||
234 | command |= CMD_RESET; | 234 | command |= CMD_RESET; |
@@ -251,7 +251,7 @@ static int ehci_reset (struct ehci_hcd *ehci) | |||
251 | tdi_reset (ehci); | 251 | tdi_reset (ehci); |
252 | 252 | ||
253 | if (ehci->debug) | 253 | if (ehci->debug) |
254 | dbgp_external_startup(); | 254 | dbgp_external_startup(ehci_to_hcd(ehci)); |
255 | 255 | ||
256 | ehci->port_c_suspend = ehci->suspended_ports = | 256 | ehci->port_c_suspend = ehci->suspended_ports = |
257 | ehci->resuming_ports = 0; | 257 | ehci->resuming_ports = 0; |
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c index c7880223738a..914ce9370e70 100644 --- a/drivers/usb/host/ehci-hub.c +++ b/drivers/usb/host/ehci-hub.c | |||
@@ -353,10 +353,10 @@ static int ehci_bus_resume (struct usb_hcd *hcd) | |||
353 | goto shutdown; | 353 | goto shutdown; |
354 | 354 | ||
355 | if (unlikely(ehci->debug)) { | 355 | if (unlikely(ehci->debug)) { |
356 | if (!dbgp_reset_prep()) | 356 | if (!dbgp_reset_prep(hcd)) |
357 | ehci->debug = NULL; | 357 | ehci->debug = NULL; |
358 | else | 358 | else |
359 | dbgp_external_startup(); | 359 | dbgp_external_startup(hcd); |
360 | } | 360 | } |
361 | 361 | ||
362 | /* Ideally and we've got a real resume here, and no port's power | 362 | /* Ideally and we've got a real resume here, and no port's power |
diff --git a/drivers/usb/host/ehci-ixp4xx.c b/drivers/usb/host/ehci-ixp4xx.c index 488d401942e9..f224c0a48bed 100644 --- a/drivers/usb/host/ehci-ixp4xx.c +++ b/drivers/usb/host/ehci-ixp4xx.c | |||
@@ -98,30 +98,19 @@ static int ixp4xx_ehci_probe(struct platform_device *pdev) | |||
98 | hcd->rsrc_start = res->start; | 98 | hcd->rsrc_start = res->start; |
99 | hcd->rsrc_len = resource_size(res); | 99 | hcd->rsrc_len = resource_size(res); |
100 | 100 | ||
101 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, | 101 | hcd->regs = devm_request_and_ioremap(&pdev->dev, res); |
102 | driver->description)) { | ||
103 | dev_dbg(&pdev->dev, "controller already in use\n"); | ||
104 | retval = -EBUSY; | ||
105 | goto fail_request_resource; | ||
106 | } | ||
107 | |||
108 | hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len); | ||
109 | if (hcd->regs == NULL) { | 102 | if (hcd->regs == NULL) { |
110 | dev_dbg(&pdev->dev, "error mapping memory\n"); | 103 | dev_dbg(&pdev->dev, "error mapping memory\n"); |
111 | retval = -EFAULT; | 104 | retval = -EFAULT; |
112 | goto fail_ioremap; | 105 | goto fail_request_resource; |
113 | } | 106 | } |
114 | 107 | ||
115 | retval = usb_add_hcd(hcd, irq, IRQF_SHARED); | 108 | retval = usb_add_hcd(hcd, irq, IRQF_SHARED); |
116 | if (retval) | 109 | if (retval) |
117 | goto fail_add_hcd; | 110 | goto fail_request_resource; |
118 | 111 | ||
119 | return retval; | 112 | return retval; |
120 | 113 | ||
121 | fail_add_hcd: | ||
122 | iounmap(hcd->regs); | ||
123 | fail_ioremap: | ||
124 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
125 | fail_request_resource: | 114 | fail_request_resource: |
126 | usb_put_hcd(hcd); | 115 | usb_put_hcd(hcd); |
127 | fail_create_hcd: | 116 | fail_create_hcd: |
@@ -134,8 +123,6 @@ static int ixp4xx_ehci_remove(struct platform_device *pdev) | |||
134 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | 123 | struct usb_hcd *hcd = platform_get_drvdata(pdev); |
135 | 124 | ||
136 | usb_remove_hcd(hcd); | 125 | usb_remove_hcd(hcd); |
137 | iounmap(hcd->regs); | ||
138 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
139 | usb_put_hcd(hcd); | 126 | usb_put_hcd(hcd); |
140 | 127 | ||
141 | return 0; | 128 | return 0; |
diff --git a/drivers/usb/host/ehci-ls1x.c b/drivers/usb/host/ehci-ls1x.c index a283e59709d6..ca759652626b 100644 --- a/drivers/usb/host/ehci-ls1x.c +++ b/drivers/usb/host/ehci-ls1x.c | |||
@@ -106,29 +106,19 @@ static int ehci_hcd_ls1x_probe(struct platform_device *pdev) | |||
106 | hcd->rsrc_start = res->start; | 106 | hcd->rsrc_start = res->start; |
107 | hcd->rsrc_len = resource_size(res); | 107 | hcd->rsrc_len = resource_size(res); |
108 | 108 | ||
109 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { | 109 | hcd->regs = devm_request_and_ioremap(&pdev->dev, res); |
110 | dev_dbg(&pdev->dev, "controller already in use\n"); | ||
111 | ret = -EBUSY; | ||
112 | goto err_put_hcd; | ||
113 | } | ||
114 | |||
115 | hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); | ||
116 | if (hcd->regs == NULL) { | 110 | if (hcd->regs == NULL) { |
117 | dev_dbg(&pdev->dev, "error mapping memory\n"); | 111 | dev_dbg(&pdev->dev, "error mapping memory\n"); |
118 | ret = -EFAULT; | 112 | ret = -EFAULT; |
119 | goto err_release_region; | 113 | goto err_put_hcd; |
120 | } | 114 | } |
121 | 115 | ||
122 | ret = usb_add_hcd(hcd, irq, IRQF_DISABLED | IRQF_SHARED); | 116 | ret = usb_add_hcd(hcd, irq, IRQF_SHARED); |
123 | if (ret) | 117 | if (ret) |
124 | goto err_iounmap; | 118 | goto err_put_hcd; |
125 | 119 | ||
126 | return ret; | 120 | return ret; |
127 | 121 | ||
128 | err_iounmap: | ||
129 | iounmap(hcd->regs); | ||
130 | err_release_region: | ||
131 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
132 | err_put_hcd: | 122 | err_put_hcd: |
133 | usb_put_hcd(hcd); | 123 | usb_put_hcd(hcd); |
134 | return ret; | 124 | return ret; |
@@ -139,8 +129,6 @@ static int ehci_hcd_ls1x_remove(struct platform_device *pdev) | |||
139 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | 129 | struct usb_hcd *hcd = platform_get_drvdata(pdev); |
140 | 130 | ||
141 | usb_remove_hcd(hcd); | 131 | usb_remove_hcd(hcd); |
142 | iounmap(hcd->regs); | ||
143 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
144 | usb_put_hcd(hcd); | 132 | usb_put_hcd(hcd); |
145 | 133 | ||
146 | return 0; | 134 | return 0; |
diff --git a/drivers/usb/host/ehci-msm.c b/drivers/usb/host/ehci-msm.c index 17dd9e94001e..4af4dc5b618c 100644 --- a/drivers/usb/host/ehci-msm.c +++ b/drivers/usb/host/ehci-msm.c | |||
@@ -133,7 +133,7 @@ static int ehci_msm_probe(struct platform_device *pdev) | |||
133 | 133 | ||
134 | hcd->rsrc_start = res->start; | 134 | hcd->rsrc_start = res->start; |
135 | hcd->rsrc_len = resource_size(res); | 135 | hcd->rsrc_len = resource_size(res); |
136 | hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); | 136 | hcd->regs = devm_ioremap(&pdev->dev, hcd->rsrc_start, hcd->rsrc_len); |
137 | if (!hcd->regs) { | 137 | if (!hcd->regs) { |
138 | dev_err(&pdev->dev, "ioremap failed\n"); | 138 | dev_err(&pdev->dev, "ioremap failed\n"); |
139 | ret = -ENOMEM; | 139 | ret = -ENOMEM; |
@@ -145,17 +145,17 @@ static int ehci_msm_probe(struct platform_device *pdev) | |||
145 | * powering up VBUS, mapping of registers address space and power | 145 | * powering up VBUS, mapping of registers address space and power |
146 | * management. | 146 | * management. |
147 | */ | 147 | */ |
148 | phy = usb_get_phy(USB_PHY_TYPE_USB2); | 148 | phy = devm_usb_get_phy(&pdev->dev, USB_PHY_TYPE_USB2); |
149 | if (IS_ERR_OR_NULL(phy)) { | 149 | if (IS_ERR_OR_NULL(phy)) { |
150 | dev_err(&pdev->dev, "unable to find transceiver\n"); | 150 | dev_err(&pdev->dev, "unable to find transceiver\n"); |
151 | ret = -ENODEV; | 151 | ret = -ENODEV; |
152 | goto unmap; | 152 | goto put_hcd; |
153 | } | 153 | } |
154 | 154 | ||
155 | ret = otg_set_host(phy->otg, &hcd->self); | 155 | ret = otg_set_host(phy->otg, &hcd->self); |
156 | if (ret < 0) { | 156 | if (ret < 0) { |
157 | dev_err(&pdev->dev, "unable to register with transceiver\n"); | 157 | dev_err(&pdev->dev, "unable to register with transceiver\n"); |
158 | goto put_transceiver; | 158 | goto put_hcd; |
159 | } | 159 | } |
160 | 160 | ||
161 | device_init_wakeup(&pdev->dev, 1); | 161 | device_init_wakeup(&pdev->dev, 1); |
@@ -168,10 +168,6 @@ static int ehci_msm_probe(struct platform_device *pdev) | |||
168 | 168 | ||
169 | return 0; | 169 | return 0; |
170 | 170 | ||
171 | put_transceiver: | ||
172 | usb_put_phy(phy); | ||
173 | unmap: | ||
174 | iounmap(hcd->regs); | ||
175 | put_hcd: | 171 | put_hcd: |
176 | usb_put_hcd(hcd); | 172 | usb_put_hcd(hcd); |
177 | 173 | ||
@@ -187,7 +183,6 @@ static int __devexit ehci_msm_remove(struct platform_device *pdev) | |||
187 | pm_runtime_set_suspended(&pdev->dev); | 183 | pm_runtime_set_suspended(&pdev->dev); |
188 | 184 | ||
189 | otg_set_host(phy->otg, NULL); | 185 | otg_set_host(phy->otg, NULL); |
190 | usb_put_phy(phy); | ||
191 | 186 | ||
192 | usb_put_hcd(hcd); | 187 | usb_put_hcd(hcd); |
193 | 188 | ||
diff --git a/drivers/usb/host/ehci-mv.c b/drivers/usb/host/ehci-mv.c index f6df1ccc9617..f7bfc0b898b9 100644 --- a/drivers/usb/host/ehci-mv.c +++ b/drivers/usb/host/ehci-mv.c | |||
@@ -161,7 +161,7 @@ static int mv_ehci_probe(struct platform_device *pdev) | |||
161 | return -ENOMEM; | 161 | return -ENOMEM; |
162 | 162 | ||
163 | size = sizeof(*ehci_mv) + sizeof(struct clk *) * pdata->clknum; | 163 | size = sizeof(*ehci_mv) + sizeof(struct clk *) * pdata->clknum; |
164 | ehci_mv = kzalloc(size, GFP_KERNEL); | 164 | ehci_mv = devm_kzalloc(&pdev->dev, size, GFP_KERNEL); |
165 | if (ehci_mv == NULL) { | 165 | if (ehci_mv == NULL) { |
166 | dev_err(&pdev->dev, "cannot allocate ehci_hcd_mv\n"); | 166 | dev_err(&pdev->dev, "cannot allocate ehci_hcd_mv\n"); |
167 | retval = -ENOMEM; | 167 | retval = -ENOMEM; |
@@ -175,12 +175,12 @@ static int mv_ehci_probe(struct platform_device *pdev) | |||
175 | ehci_mv->clknum = pdata->clknum; | 175 | ehci_mv->clknum = pdata->clknum; |
176 | for (clk_i = 0; clk_i < ehci_mv->clknum; clk_i++) { | 176 | for (clk_i = 0; clk_i < ehci_mv->clknum; clk_i++) { |
177 | ehci_mv->clk[clk_i] = | 177 | ehci_mv->clk[clk_i] = |
178 | clk_get(&pdev->dev, pdata->clkname[clk_i]); | 178 | devm_clk_get(&pdev->dev, pdata->clkname[clk_i]); |
179 | if (IS_ERR(ehci_mv->clk[clk_i])) { | 179 | if (IS_ERR(ehci_mv->clk[clk_i])) { |
180 | dev_err(&pdev->dev, "error get clck \"%s\"\n", | 180 | dev_err(&pdev->dev, "error get clck \"%s\"\n", |
181 | pdata->clkname[clk_i]); | 181 | pdata->clkname[clk_i]); |
182 | retval = PTR_ERR(ehci_mv->clk[clk_i]); | 182 | retval = PTR_ERR(ehci_mv->clk[clk_i]); |
183 | goto err_put_clk; | 183 | goto err_clear_drvdata; |
184 | } | 184 | } |
185 | } | 185 | } |
186 | 186 | ||
@@ -188,34 +188,36 @@ static int mv_ehci_probe(struct platform_device *pdev) | |||
188 | if (r == NULL) { | 188 | if (r == NULL) { |
189 | dev_err(&pdev->dev, "no phy I/O memory resource defined\n"); | 189 | dev_err(&pdev->dev, "no phy I/O memory resource defined\n"); |
190 | retval = -ENODEV; | 190 | retval = -ENODEV; |
191 | goto err_put_clk; | 191 | goto err_clear_drvdata; |
192 | } | 192 | } |
193 | 193 | ||
194 | ehci_mv->phy_regs = ioremap(r->start, resource_size(r)); | 194 | ehci_mv->phy_regs = devm_ioremap(&pdev->dev, r->start, |
195 | resource_size(r)); | ||
195 | if (ehci_mv->phy_regs == 0) { | 196 | if (ehci_mv->phy_regs == 0) { |
196 | dev_err(&pdev->dev, "failed to map phy I/O memory\n"); | 197 | dev_err(&pdev->dev, "failed to map phy I/O memory\n"); |
197 | retval = -EFAULT; | 198 | retval = -EFAULT; |
198 | goto err_put_clk; | 199 | goto err_clear_drvdata; |
199 | } | 200 | } |
200 | 201 | ||
201 | r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "capregs"); | 202 | r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "capregs"); |
202 | if (!r) { | 203 | if (!r) { |
203 | dev_err(&pdev->dev, "no I/O memory resource defined\n"); | 204 | dev_err(&pdev->dev, "no I/O memory resource defined\n"); |
204 | retval = -ENODEV; | 205 | retval = -ENODEV; |
205 | goto err_iounmap_phyreg; | 206 | goto err_clear_drvdata; |
206 | } | 207 | } |
207 | 208 | ||
208 | ehci_mv->cap_regs = ioremap(r->start, resource_size(r)); | 209 | ehci_mv->cap_regs = devm_ioremap(&pdev->dev, r->start, |
210 | resource_size(r)); | ||
209 | if (ehci_mv->cap_regs == NULL) { | 211 | if (ehci_mv->cap_regs == NULL) { |
210 | dev_err(&pdev->dev, "failed to map I/O memory\n"); | 212 | dev_err(&pdev->dev, "failed to map I/O memory\n"); |
211 | retval = -EFAULT; | 213 | retval = -EFAULT; |
212 | goto err_iounmap_phyreg; | 214 | goto err_clear_drvdata; |
213 | } | 215 | } |
214 | 216 | ||
215 | retval = mv_ehci_enable(ehci_mv); | 217 | retval = mv_ehci_enable(ehci_mv); |
216 | if (retval) { | 218 | if (retval) { |
217 | dev_err(&pdev->dev, "init phy error %d\n", retval); | 219 | dev_err(&pdev->dev, "init phy error %d\n", retval); |
218 | goto err_iounmap_capreg; | 220 | goto err_clear_drvdata; |
219 | } | 221 | } |
220 | 222 | ||
221 | offset = readl(ehci_mv->cap_regs) & CAPLENGTH_MASK; | 223 | offset = readl(ehci_mv->cap_regs) & CAPLENGTH_MASK; |
@@ -239,7 +241,7 @@ static int mv_ehci_probe(struct platform_device *pdev) | |||
239 | ehci_mv->mode = pdata->mode; | 241 | ehci_mv->mode = pdata->mode; |
240 | if (ehci_mv->mode == MV_USB_MODE_OTG) { | 242 | if (ehci_mv->mode == MV_USB_MODE_OTG) { |
241 | #ifdef CONFIG_USB_OTG_UTILS | 243 | #ifdef CONFIG_USB_OTG_UTILS |
242 | ehci_mv->otg = usb_get_phy(USB_PHY_TYPE_USB2); | 244 | ehci_mv->otg = devm_usb_get_phy(&pdev->dev, USB_PHY_TYPE_USB2); |
243 | if (IS_ERR_OR_NULL(ehci_mv->otg)) { | 245 | if (IS_ERR_OR_NULL(ehci_mv->otg)) { |
244 | dev_err(&pdev->dev, | 246 | dev_err(&pdev->dev, |
245 | "unable to find transceiver\n"); | 247 | "unable to find transceiver\n"); |
@@ -252,7 +254,7 @@ static int mv_ehci_probe(struct platform_device *pdev) | |||
252 | dev_err(&pdev->dev, | 254 | dev_err(&pdev->dev, |
253 | "unable to register with transceiver\n"); | 255 | "unable to register with transceiver\n"); |
254 | retval = -ENODEV; | 256 | retval = -ENODEV; |
255 | goto err_put_transceiver; | 257 | goto err_disable_clk; |
256 | } | 258 | } |
257 | /* otg will enable clock before use as host */ | 259 | /* otg will enable clock before use as host */ |
258 | mv_ehci_disable(ehci_mv); | 260 | mv_ehci_disable(ehci_mv); |
@@ -286,22 +288,10 @@ static int mv_ehci_probe(struct platform_device *pdev) | |||
286 | err_set_vbus: | 288 | err_set_vbus: |
287 | if (pdata->set_vbus) | 289 | if (pdata->set_vbus) |
288 | pdata->set_vbus(0); | 290 | pdata->set_vbus(0); |
289 | #ifdef CONFIG_USB_OTG_UTILS | ||
290 | err_put_transceiver: | ||
291 | if (!IS_ERR_OR_NULL(ehci_mv->otg)) | ||
292 | usb_put_phy(ehci_mv->otg); | ||
293 | #endif | ||
294 | err_disable_clk: | 291 | err_disable_clk: |
295 | mv_ehci_disable(ehci_mv); | 292 | mv_ehci_disable(ehci_mv); |
296 | err_iounmap_capreg: | 293 | err_clear_drvdata: |
297 | iounmap(ehci_mv->cap_regs); | ||
298 | err_iounmap_phyreg: | ||
299 | iounmap(ehci_mv->phy_regs); | ||
300 | err_put_clk: | ||
301 | for (clk_i--; clk_i >= 0; clk_i--) | ||
302 | clk_put(ehci_mv->clk[clk_i]); | ||
303 | platform_set_drvdata(pdev, NULL); | 294 | platform_set_drvdata(pdev, NULL); |
304 | kfree(ehci_mv); | ||
305 | err_put_hcd: | 295 | err_put_hcd: |
306 | usb_put_hcd(hcd); | 296 | usb_put_hcd(hcd); |
307 | 297 | ||
@@ -317,10 +307,8 @@ static int mv_ehci_remove(struct platform_device *pdev) | |||
317 | if (hcd->rh_registered) | 307 | if (hcd->rh_registered) |
318 | usb_remove_hcd(hcd); | 308 | usb_remove_hcd(hcd); |
319 | 309 | ||
320 | if (!IS_ERR_OR_NULL(ehci_mv->otg)) { | 310 | if (!IS_ERR_OR_NULL(ehci_mv->otg)) |
321 | otg_set_host(ehci_mv->otg->otg, NULL); | 311 | otg_set_host(ehci_mv->otg->otg, NULL); |
322 | usb_put_phy(ehci_mv->otg); | ||
323 | } | ||
324 | 312 | ||
325 | if (ehci_mv->mode == MV_USB_MODE_HOST) { | 313 | if (ehci_mv->mode == MV_USB_MODE_HOST) { |
326 | if (ehci_mv->pdata->set_vbus) | 314 | if (ehci_mv->pdata->set_vbus) |
@@ -329,15 +317,8 @@ static int mv_ehci_remove(struct platform_device *pdev) | |||
329 | mv_ehci_disable(ehci_mv); | 317 | mv_ehci_disable(ehci_mv); |
330 | } | 318 | } |
331 | 319 | ||
332 | iounmap(ehci_mv->cap_regs); | ||
333 | iounmap(ehci_mv->phy_regs); | ||
334 | |||
335 | for (clk_i = 0; clk_i < ehci_mv->clknum; clk_i++) | ||
336 | clk_put(ehci_mv->clk[clk_i]); | ||
337 | |||
338 | platform_set_drvdata(pdev, NULL); | 320 | platform_set_drvdata(pdev, NULL); |
339 | 321 | ||
340 | kfree(ehci_mv); | ||
341 | usb_put_hcd(hcd); | 322 | usb_put_hcd(hcd); |
342 | 323 | ||
343 | return 0; | 324 | return 0; |
diff --git a/drivers/usb/host/ehci-mxc.c b/drivers/usb/host/ehci-mxc.c index 34201372c85f..959e1a4c3491 100644 --- a/drivers/usb/host/ehci-mxc.c +++ b/drivers/usb/host/ehci-mxc.c | |||
@@ -121,7 +121,7 @@ static int ehci_mxc_drv_probe(struct platform_device *pdev) | |||
121 | if (!hcd) | 121 | if (!hcd) |
122 | return -ENOMEM; | 122 | return -ENOMEM; |
123 | 123 | ||
124 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); | 124 | priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); |
125 | if (!priv) { | 125 | if (!priv) { |
126 | ret = -ENOMEM; | 126 | ret = -ENOMEM; |
127 | goto err_alloc; | 127 | goto err_alloc; |
@@ -131,34 +131,28 @@ static int ehci_mxc_drv_probe(struct platform_device *pdev) | |||
131 | if (!res) { | 131 | if (!res) { |
132 | dev_err(dev, "Found HC with no register addr. Check setup!\n"); | 132 | dev_err(dev, "Found HC with no register addr. Check setup!\n"); |
133 | ret = -ENODEV; | 133 | ret = -ENODEV; |
134 | goto err_get_resource; | 134 | goto err_alloc; |
135 | } | 135 | } |
136 | 136 | ||
137 | hcd->rsrc_start = res->start; | 137 | hcd->rsrc_start = res->start; |
138 | hcd->rsrc_len = resource_size(res); | 138 | hcd->rsrc_len = resource_size(res); |
139 | 139 | ||
140 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { | 140 | hcd->regs = devm_request_and_ioremap(&pdev->dev, res); |
141 | dev_dbg(dev, "controller already in use\n"); | ||
142 | ret = -EBUSY; | ||
143 | goto err_request_mem; | ||
144 | } | ||
145 | |||
146 | hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); | ||
147 | if (!hcd->regs) { | 141 | if (!hcd->regs) { |
148 | dev_err(dev, "error mapping memory\n"); | 142 | dev_err(dev, "error mapping memory\n"); |
149 | ret = -EFAULT; | 143 | ret = -EFAULT; |
150 | goto err_ioremap; | 144 | goto err_alloc; |
151 | } | 145 | } |
152 | 146 | ||
153 | /* enable clocks */ | 147 | /* enable clocks */ |
154 | priv->usbclk = clk_get(dev, "ipg"); | 148 | priv->usbclk = devm_clk_get(&pdev->dev, "ipg"); |
155 | if (IS_ERR(priv->usbclk)) { | 149 | if (IS_ERR(priv->usbclk)) { |
156 | ret = PTR_ERR(priv->usbclk); | 150 | ret = PTR_ERR(priv->usbclk); |
157 | goto err_clk; | 151 | goto err_alloc; |
158 | } | 152 | } |
159 | clk_prepare_enable(priv->usbclk); | 153 | clk_prepare_enable(priv->usbclk); |
160 | 154 | ||
161 | priv->ahbclk = clk_get(dev, "ahb"); | 155 | priv->ahbclk = devm_clk_get(&pdev->dev, "ahb"); |
162 | if (IS_ERR(priv->ahbclk)) { | 156 | if (IS_ERR(priv->ahbclk)) { |
163 | ret = PTR_ERR(priv->ahbclk); | 157 | ret = PTR_ERR(priv->ahbclk); |
164 | goto err_clk_ahb; | 158 | goto err_clk_ahb; |
@@ -166,7 +160,7 @@ static int ehci_mxc_drv_probe(struct platform_device *pdev) | |||
166 | clk_prepare_enable(priv->ahbclk); | 160 | clk_prepare_enable(priv->ahbclk); |
167 | 161 | ||
168 | /* "dr" device has its own clock on i.MX51 */ | 162 | /* "dr" device has its own clock on i.MX51 */ |
169 | priv->phyclk = clk_get(dev, "phy"); | 163 | priv->phyclk = devm_clk_get(&pdev->dev, "phy"); |
170 | if (IS_ERR(priv->phyclk)) | 164 | if (IS_ERR(priv->phyclk)) |
171 | priv->phyclk = NULL; | 165 | priv->phyclk = NULL; |
172 | if (priv->phyclk) | 166 | if (priv->phyclk) |
@@ -245,23 +239,12 @@ err_add: | |||
245 | if (pdata && pdata->exit) | 239 | if (pdata && pdata->exit) |
246 | pdata->exit(pdev); | 240 | pdata->exit(pdev); |
247 | err_init: | 241 | err_init: |
248 | if (priv->phyclk) { | 242 | if (priv->phyclk) |
249 | clk_disable_unprepare(priv->phyclk); | 243 | clk_disable_unprepare(priv->phyclk); |
250 | clk_put(priv->phyclk); | ||
251 | } | ||
252 | 244 | ||
253 | clk_disable_unprepare(priv->ahbclk); | 245 | clk_disable_unprepare(priv->ahbclk); |
254 | clk_put(priv->ahbclk); | ||
255 | err_clk_ahb: | 246 | err_clk_ahb: |
256 | clk_disable_unprepare(priv->usbclk); | 247 | clk_disable_unprepare(priv->usbclk); |
257 | clk_put(priv->usbclk); | ||
258 | err_clk: | ||
259 | iounmap(hcd->regs); | ||
260 | err_ioremap: | ||
261 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
262 | err_request_mem: | ||
263 | err_get_resource: | ||
264 | kfree(priv); | ||
265 | err_alloc: | 248 | err_alloc: |
266 | usb_put_hcd(hcd); | 249 | usb_put_hcd(hcd); |
267 | return ret; | 250 | return ret; |
@@ -280,22 +263,14 @@ static int __exit ehci_mxc_drv_remove(struct platform_device *pdev) | |||
280 | usb_phy_shutdown(pdata->otg); | 263 | usb_phy_shutdown(pdata->otg); |
281 | 264 | ||
282 | usb_remove_hcd(hcd); | 265 | usb_remove_hcd(hcd); |
283 | iounmap(hcd->regs); | ||
284 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
285 | usb_put_hcd(hcd); | 266 | usb_put_hcd(hcd); |
286 | platform_set_drvdata(pdev, NULL); | 267 | platform_set_drvdata(pdev, NULL); |
287 | 268 | ||
288 | clk_disable_unprepare(priv->usbclk); | 269 | clk_disable_unprepare(priv->usbclk); |
289 | clk_put(priv->usbclk); | ||
290 | clk_disable_unprepare(priv->ahbclk); | 270 | clk_disable_unprepare(priv->ahbclk); |
291 | clk_put(priv->ahbclk); | ||
292 | 271 | ||
293 | if (priv->phyclk) { | 272 | if (priv->phyclk) |
294 | clk_disable_unprepare(priv->phyclk); | 273 | clk_disable_unprepare(priv->phyclk); |
295 | clk_put(priv->phyclk); | ||
296 | } | ||
297 | |||
298 | kfree(priv); | ||
299 | 274 | ||
300 | return 0; | 275 | return 0; |
301 | } | 276 | } |
diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c index 4b1d896d5a22..764e0100b6f4 100644 --- a/drivers/usb/host/ehci-platform.c +++ b/drivers/usb/host/ehci-platform.c | |||
@@ -82,10 +82,14 @@ static int __devinit ehci_platform_probe(struct platform_device *dev) | |||
82 | { | 82 | { |
83 | struct usb_hcd *hcd; | 83 | struct usb_hcd *hcd; |
84 | struct resource *res_mem; | 84 | struct resource *res_mem; |
85 | struct usb_ehci_pdata *pdata = dev->dev.platform_data; | ||
85 | int irq; | 86 | int irq; |
86 | int err = -ENOMEM; | 87 | int err = -ENOMEM; |
87 | 88 | ||
88 | BUG_ON(!dev->dev.platform_data); | 89 | if (!pdata) { |
90 | WARN_ON(1); | ||
91 | return -ENODEV; | ||
92 | } | ||
89 | 93 | ||
90 | if (usb_disabled()) | 94 | if (usb_disabled()) |
91 | return -ENODEV; | 95 | return -ENODEV; |
@@ -101,10 +105,18 @@ static int __devinit ehci_platform_probe(struct platform_device *dev) | |||
101 | return -ENXIO; | 105 | return -ENXIO; |
102 | } | 106 | } |
103 | 107 | ||
108 | if (pdata->power_on) { | ||
109 | err = pdata->power_on(dev); | ||
110 | if (err < 0) | ||
111 | return err; | ||
112 | } | ||
113 | |||
104 | hcd = usb_create_hcd(&ehci_platform_hc_driver, &dev->dev, | 114 | hcd = usb_create_hcd(&ehci_platform_hc_driver, &dev->dev, |
105 | dev_name(&dev->dev)); | 115 | dev_name(&dev->dev)); |
106 | if (!hcd) | 116 | if (!hcd) { |
107 | return -ENOMEM; | 117 | err = -ENOMEM; |
118 | goto err_power; | ||
119 | } | ||
108 | 120 | ||
109 | hcd->rsrc_start = res_mem->start; | 121 | hcd->rsrc_start = res_mem->start; |
110 | hcd->rsrc_len = resource_size(res_mem); | 122 | hcd->rsrc_len = resource_size(res_mem); |
@@ -116,8 +128,10 @@ static int __devinit ehci_platform_probe(struct platform_device *dev) | |||
116 | } | 128 | } |
117 | 129 | ||
118 | hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len); | 130 | hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len); |
119 | if (!hcd->regs) | 131 | if (!hcd->regs) { |
132 | err = -ENOMEM; | ||
120 | goto err_release_region; | 133 | goto err_release_region; |
134 | } | ||
121 | err = usb_add_hcd(hcd, irq, IRQF_SHARED); | 135 | err = usb_add_hcd(hcd, irq, IRQF_SHARED); |
122 | if (err) | 136 | if (err) |
123 | goto err_iounmap; | 137 | goto err_iounmap; |
@@ -132,12 +146,17 @@ err_release_region: | |||
132 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | 146 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); |
133 | err_put_hcd: | 147 | err_put_hcd: |
134 | usb_put_hcd(hcd); | 148 | usb_put_hcd(hcd); |
149 | err_power: | ||
150 | if (pdata->power_off) | ||
151 | pdata->power_off(dev); | ||
152 | |||
135 | return err; | 153 | return err; |
136 | } | 154 | } |
137 | 155 | ||
138 | static int __devexit ehci_platform_remove(struct platform_device *dev) | 156 | static int __devexit ehci_platform_remove(struct platform_device *dev) |
139 | { | 157 | { |
140 | struct usb_hcd *hcd = platform_get_drvdata(dev); | 158 | struct usb_hcd *hcd = platform_get_drvdata(dev); |
159 | struct usb_ehci_pdata *pdata = dev->dev.platform_data; | ||
141 | 160 | ||
142 | usb_remove_hcd(hcd); | 161 | usb_remove_hcd(hcd); |
143 | iounmap(hcd->regs); | 162 | iounmap(hcd->regs); |
@@ -145,6 +164,9 @@ static int __devexit ehci_platform_remove(struct platform_device *dev) | |||
145 | usb_put_hcd(hcd); | 164 | usb_put_hcd(hcd); |
146 | platform_set_drvdata(dev, NULL); | 165 | platform_set_drvdata(dev, NULL); |
147 | 166 | ||
167 | if (pdata->power_off) | ||
168 | pdata->power_off(dev); | ||
169 | |||
148 | return 0; | 170 | return 0; |
149 | } | 171 | } |
150 | 172 | ||
@@ -153,14 +175,32 @@ static int __devexit ehci_platform_remove(struct platform_device *dev) | |||
153 | static int ehci_platform_suspend(struct device *dev) | 175 | static int ehci_platform_suspend(struct device *dev) |
154 | { | 176 | { |
155 | struct usb_hcd *hcd = dev_get_drvdata(dev); | 177 | struct usb_hcd *hcd = dev_get_drvdata(dev); |
178 | struct usb_ehci_pdata *pdata = dev->platform_data; | ||
179 | struct platform_device *pdev = | ||
180 | container_of(dev, struct platform_device, dev); | ||
156 | bool do_wakeup = device_may_wakeup(dev); | 181 | bool do_wakeup = device_may_wakeup(dev); |
182 | int ret; | ||
183 | |||
184 | ret = ehci_suspend(hcd, do_wakeup); | ||
157 | 185 | ||
158 | return ehci_suspend(hcd, do_wakeup); | 186 | if (pdata->power_suspend) |
187 | pdata->power_suspend(pdev); | ||
188 | |||
189 | return ret; | ||
159 | } | 190 | } |
160 | 191 | ||
161 | static int ehci_platform_resume(struct device *dev) | 192 | static int ehci_platform_resume(struct device *dev) |
162 | { | 193 | { |
163 | struct usb_hcd *hcd = dev_get_drvdata(dev); | 194 | struct usb_hcd *hcd = dev_get_drvdata(dev); |
195 | struct usb_ehci_pdata *pdata = dev->platform_data; | ||
196 | struct platform_device *pdev = | ||
197 | container_of(dev, struct platform_device, dev); | ||
198 | |||
199 | if (pdata->power_on) { | ||
200 | int err = pdata->power_on(pdev); | ||
201 | if (err < 0) | ||
202 | return err; | ||
203 | } | ||
164 | 204 | ||
165 | ehci_resume(hcd, false); | 205 | ehci_resume(hcd, false); |
166 | return 0; | 206 | return 0; |
diff --git a/drivers/usb/host/ehci-ppc-of.c b/drivers/usb/host/ehci-ppc-of.c index bbbe89dfd886..fa937d05a02b 100644 --- a/drivers/usb/host/ehci-ppc-of.c +++ b/drivers/usb/host/ehci-ppc-of.c | |||
@@ -114,12 +114,6 @@ static int __devinit ehci_hcd_ppc_of_probe(struct platform_device *op) | |||
114 | hcd->rsrc_start = res.start; | 114 | hcd->rsrc_start = res.start; |
115 | hcd->rsrc_len = resource_size(&res); | 115 | hcd->rsrc_len = resource_size(&res); |
116 | 116 | ||
117 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { | ||
118 | printk(KERN_ERR "%s: request_mem_region failed\n", __FILE__); | ||
119 | rv = -EBUSY; | ||
120 | goto err_rmr; | ||
121 | } | ||
122 | |||
123 | irq = irq_of_parse_and_map(dn, 0); | 117 | irq = irq_of_parse_and_map(dn, 0); |
124 | if (irq == NO_IRQ) { | 118 | if (irq == NO_IRQ) { |
125 | printk(KERN_ERR "%s: irq_of_parse_and_map failed\n", __FILE__); | 119 | printk(KERN_ERR "%s: irq_of_parse_and_map failed\n", __FILE__); |
@@ -127,9 +121,9 @@ static int __devinit ehci_hcd_ppc_of_probe(struct platform_device *op) | |||
127 | goto err_irq; | 121 | goto err_irq; |
128 | } | 122 | } |
129 | 123 | ||
130 | hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); | 124 | hcd->regs = devm_request_and_ioremap(&op->dev, &res); |
131 | if (!hcd->regs) { | 125 | if (!hcd->regs) { |
132 | printk(KERN_ERR "%s: ioremap failed\n", __FILE__); | 126 | pr_err("%s: devm_request_and_ioremap failed\n", __FILE__); |
133 | rv = -ENOMEM; | 127 | rv = -ENOMEM; |
134 | goto err_ioremap; | 128 | goto err_ioremap; |
135 | } | 129 | } |
@@ -139,8 +133,10 @@ static int __devinit ehci_hcd_ppc_of_probe(struct platform_device *op) | |||
139 | if (np != NULL) { | 133 | if (np != NULL) { |
140 | /* claim we really affected by usb23 erratum */ | 134 | /* claim we really affected by usb23 erratum */ |
141 | if (!of_address_to_resource(np, 0, &res)) | 135 | if (!of_address_to_resource(np, 0, &res)) |
142 | ehci->ohci_hcctrl_reg = ioremap(res.start + | 136 | ehci->ohci_hcctrl_reg = |
143 | OHCI_HCCTRL_OFFSET, OHCI_HCCTRL_LEN); | 137 | devm_ioremap(&op->dev, |
138 | res.start + OHCI_HCCTRL_OFFSET, | ||
139 | OHCI_HCCTRL_LEN); | ||
144 | else | 140 | else |
145 | pr_debug("%s: no ohci offset in fdt\n", __FILE__); | 141 | pr_debug("%s: no ohci offset in fdt\n", __FILE__); |
146 | if (!ehci->ohci_hcctrl_reg) { | 142 | if (!ehci->ohci_hcctrl_reg) { |
@@ -169,19 +165,13 @@ static int __devinit ehci_hcd_ppc_of_probe(struct platform_device *op) | |||
169 | 165 | ||
170 | rv = usb_add_hcd(hcd, irq, 0); | 166 | rv = usb_add_hcd(hcd, irq, 0); |
171 | if (rv) | 167 | if (rv) |
172 | goto err_ehci; | 168 | goto err_ioremap; |
173 | 169 | ||
174 | return 0; | 170 | return 0; |
175 | 171 | ||
176 | err_ehci: | ||
177 | if (ehci->has_amcc_usb23) | ||
178 | iounmap(ehci->ohci_hcctrl_reg); | ||
179 | iounmap(hcd->regs); | ||
180 | err_ioremap: | 172 | err_ioremap: |
181 | irq_dispose_mapping(irq); | 173 | irq_dispose_mapping(irq); |
182 | err_irq: | 174 | err_irq: |
183 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
184 | err_rmr: | ||
185 | usb_put_hcd(hcd); | 175 | usb_put_hcd(hcd); |
186 | 176 | ||
187 | return rv; | 177 | return rv; |
@@ -202,9 +192,7 @@ static int ehci_hcd_ppc_of_remove(struct platform_device *op) | |||
202 | 192 | ||
203 | usb_remove_hcd(hcd); | 193 | usb_remove_hcd(hcd); |
204 | 194 | ||
205 | iounmap(hcd->regs); | ||
206 | irq_dispose_mapping(hcd->irq); | 195 | irq_dispose_mapping(hcd->irq); |
207 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
208 | 196 | ||
209 | /* use request_mem_region to test if the ohci driver is loaded. if so | 197 | /* use request_mem_region to test if the ohci driver is loaded. if so |
210 | * ensure the ohci core is operational. | 198 | * ensure the ohci core is operational. |
@@ -222,8 +210,6 @@ static int ehci_hcd_ppc_of_remove(struct platform_device *op) | |||
222 | pr_debug("%s: no ohci offset in fdt\n", __FILE__); | 210 | pr_debug("%s: no ohci offset in fdt\n", __FILE__); |
223 | of_node_put(np); | 211 | of_node_put(np); |
224 | } | 212 | } |
225 | |||
226 | iounmap(ehci->ohci_hcctrl_reg); | ||
227 | } | 213 | } |
228 | usb_put_hcd(hcd); | 214 | usb_put_hcd(hcd); |
229 | 215 | ||
diff --git a/drivers/usb/host/ehci-s5p.c b/drivers/usb/host/ehci-s5p.c index 9d8f1dd57cb3..d055503e4183 100644 --- a/drivers/usb/host/ehci-s5p.c +++ b/drivers/usb/host/ehci-s5p.c | |||
@@ -128,7 +128,7 @@ static int __devinit s5p_ehci_probe(struct platform_device *pdev) | |||
128 | } | 128 | } |
129 | 129 | ||
130 | s5p_ehci->hcd = hcd; | 130 | s5p_ehci->hcd = hcd; |
131 | s5p_ehci->clk = clk_get(&pdev->dev, "usbhost"); | 131 | s5p_ehci->clk = devm_clk_get(&pdev->dev, "usbhost"); |
132 | 132 | ||
133 | if (IS_ERR(s5p_ehci->clk)) { | 133 | if (IS_ERR(s5p_ehci->clk)) { |
134 | dev_err(&pdev->dev, "Failed to get usbhost clock\n"); | 134 | dev_err(&pdev->dev, "Failed to get usbhost clock\n"); |
@@ -138,7 +138,7 @@ static int __devinit s5p_ehci_probe(struct platform_device *pdev) | |||
138 | 138 | ||
139 | err = clk_enable(s5p_ehci->clk); | 139 | err = clk_enable(s5p_ehci->clk); |
140 | if (err) | 140 | if (err) |
141 | goto fail_clken; | 141 | goto fail_clk; |
142 | 142 | ||
143 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 143 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
144 | if (!res) { | 144 | if (!res) { |
@@ -184,8 +184,6 @@ static int __devinit s5p_ehci_probe(struct platform_device *pdev) | |||
184 | 184 | ||
185 | fail_io: | 185 | fail_io: |
186 | clk_disable(s5p_ehci->clk); | 186 | clk_disable(s5p_ehci->clk); |
187 | fail_clken: | ||
188 | clk_put(s5p_ehci->clk); | ||
189 | fail_clk: | 187 | fail_clk: |
190 | usb_put_hcd(hcd); | 188 | usb_put_hcd(hcd); |
191 | return err; | 189 | return err; |
@@ -203,7 +201,6 @@ static int __devexit s5p_ehci_remove(struct platform_device *pdev) | |||
203 | pdata->phy_exit(pdev, S5P_USB_PHY_HOST); | 201 | pdata->phy_exit(pdev, S5P_USB_PHY_HOST); |
204 | 202 | ||
205 | clk_disable(s5p_ehci->clk); | 203 | clk_disable(s5p_ehci->clk); |
206 | clk_put(s5p_ehci->clk); | ||
207 | 204 | ||
208 | usb_put_hcd(hcd); | 205 | usb_put_hcd(hcd); |
209 | 206 | ||
diff --git a/drivers/usb/host/ehci-sead3.c b/drivers/usb/host/ehci-sead3.c index 0c9e43cfaff5..efad02d947f2 100644 --- a/drivers/usb/host/ehci-sead3.c +++ b/drivers/usb/host/ehci-sead3.c | |||
@@ -112,17 +112,11 @@ static int ehci_hcd_sead3_drv_probe(struct platform_device *pdev) | |||
112 | hcd->rsrc_start = res->start; | 112 | hcd->rsrc_start = res->start; |
113 | hcd->rsrc_len = resource_size(res); | 113 | hcd->rsrc_len = resource_size(res); |
114 | 114 | ||
115 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { | 115 | hcd->regs = devm_request_and_ioremap(&pdev->dev, res); |
116 | pr_debug("request_mem_region failed"); | ||
117 | ret = -EBUSY; | ||
118 | goto err1; | ||
119 | } | ||
120 | |||
121 | hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); | ||
122 | if (!hcd->regs) { | 116 | if (!hcd->regs) { |
123 | pr_debug("ioremap failed"); | 117 | pr_debug("ioremap failed"); |
124 | ret = -ENOMEM; | 118 | ret = -ENOMEM; |
125 | goto err2; | 119 | goto err1; |
126 | } | 120 | } |
127 | 121 | ||
128 | /* Root hub has integrated TT. */ | 122 | /* Root hub has integrated TT. */ |
@@ -135,9 +129,6 @@ static int ehci_hcd_sead3_drv_probe(struct platform_device *pdev) | |||
135 | return ret; | 129 | return ret; |
136 | } | 130 | } |
137 | 131 | ||
138 | iounmap(hcd->regs); | ||
139 | err2: | ||
140 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
141 | err1: | 132 | err1: |
142 | usb_put_hcd(hcd); | 133 | usb_put_hcd(hcd); |
143 | return ret; | 134 | return ret; |
@@ -148,8 +139,6 @@ static int ehci_hcd_sead3_drv_remove(struct platform_device *pdev) | |||
148 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | 139 | struct usb_hcd *hcd = platform_get_drvdata(pdev); |
149 | 140 | ||
150 | usb_remove_hcd(hcd); | 141 | usb_remove_hcd(hcd); |
151 | iounmap(hcd->regs); | ||
152 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
153 | usb_put_hcd(hcd); | 142 | usb_put_hcd(hcd); |
154 | platform_set_drvdata(pdev, NULL); | 143 | platform_set_drvdata(pdev, NULL); |
155 | 144 | ||
diff --git a/drivers/usb/host/ehci-sh.c b/drivers/usb/host/ehci-sh.c index b3f1e3650da0..6081e1ed3ac9 100644 --- a/drivers/usb/host/ehci-sh.c +++ b/drivers/usb/host/ehci-sh.c | |||
@@ -125,33 +125,27 @@ static int ehci_hcd_sh_probe(struct platform_device *pdev) | |||
125 | hcd->rsrc_start = res->start; | 125 | hcd->rsrc_start = res->start; |
126 | hcd->rsrc_len = resource_size(res); | 126 | hcd->rsrc_len = resource_size(res); |
127 | 127 | ||
128 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, | 128 | hcd->regs = devm_request_and_ioremap(&pdev->dev, res); |
129 | driver->description)) { | ||
130 | dev_dbg(&pdev->dev, "controller already in use\n"); | ||
131 | ret = -EBUSY; | ||
132 | goto fail_request_resource; | ||
133 | } | ||
134 | |||
135 | hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len); | ||
136 | if (hcd->regs == NULL) { | 129 | if (hcd->regs == NULL) { |
137 | dev_dbg(&pdev->dev, "error mapping memory\n"); | 130 | dev_dbg(&pdev->dev, "error mapping memory\n"); |
138 | ret = -ENXIO; | 131 | ret = -ENXIO; |
139 | goto fail_ioremap; | 132 | goto fail_request_resource; |
140 | } | 133 | } |
141 | 134 | ||
142 | priv = kmalloc(sizeof(struct ehci_sh_priv), GFP_KERNEL); | 135 | priv = devm_kzalloc(&pdev->dev, sizeof(struct ehci_sh_priv), |
136 | GFP_KERNEL); | ||
143 | if (!priv) { | 137 | if (!priv) { |
144 | dev_dbg(&pdev->dev, "error allocating priv data\n"); | 138 | dev_dbg(&pdev->dev, "error allocating priv data\n"); |
145 | ret = -ENOMEM; | 139 | ret = -ENOMEM; |
146 | goto fail_alloc; | 140 | goto fail_request_resource; |
147 | } | 141 | } |
148 | 142 | ||
149 | /* These are optional, we don't care if they fail */ | 143 | /* These are optional, we don't care if they fail */ |
150 | priv->fclk = clk_get(&pdev->dev, "usb_fck"); | 144 | priv->fclk = devm_clk_get(&pdev->dev, "usb_fck"); |
151 | if (IS_ERR(priv->fclk)) | 145 | if (IS_ERR(priv->fclk)) |
152 | priv->fclk = NULL; | 146 | priv->fclk = NULL; |
153 | 147 | ||
154 | priv->iclk = clk_get(&pdev->dev, "usb_ick"); | 148 | priv->iclk = devm_clk_get(&pdev->dev, "usb_ick"); |
155 | if (IS_ERR(priv->iclk)) | 149 | if (IS_ERR(priv->iclk)) |
156 | priv->iclk = NULL; | 150 | priv->iclk = NULL; |
157 | 151 | ||
@@ -176,14 +170,6 @@ fail_add_hcd: | |||
176 | clk_disable(priv->iclk); | 170 | clk_disable(priv->iclk); |
177 | clk_disable(priv->fclk); | 171 | clk_disable(priv->fclk); |
178 | 172 | ||
179 | clk_put(priv->iclk); | ||
180 | clk_put(priv->fclk); | ||
181 | |||
182 | kfree(priv); | ||
183 | fail_alloc: | ||
184 | iounmap(hcd->regs); | ||
185 | fail_ioremap: | ||
186 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
187 | fail_request_resource: | 173 | fail_request_resource: |
188 | usb_put_hcd(hcd); | 174 | usb_put_hcd(hcd); |
189 | fail_create_hcd: | 175 | fail_create_hcd: |
@@ -198,19 +184,12 @@ static int __exit ehci_hcd_sh_remove(struct platform_device *pdev) | |||
198 | struct usb_hcd *hcd = priv->hcd; | 184 | struct usb_hcd *hcd = priv->hcd; |
199 | 185 | ||
200 | usb_remove_hcd(hcd); | 186 | usb_remove_hcd(hcd); |
201 | iounmap(hcd->regs); | ||
202 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
203 | usb_put_hcd(hcd); | 187 | usb_put_hcd(hcd); |
204 | platform_set_drvdata(pdev, NULL); | 188 | platform_set_drvdata(pdev, NULL); |
205 | 189 | ||
206 | clk_disable(priv->fclk); | 190 | clk_disable(priv->fclk); |
207 | clk_disable(priv->iclk); | 191 | clk_disable(priv->iclk); |
208 | 192 | ||
209 | clk_put(priv->fclk); | ||
210 | clk_put(priv->iclk); | ||
211 | |||
212 | kfree(priv); | ||
213 | |||
214 | return 0; | 193 | return 0; |
215 | } | 194 | } |
216 | 195 | ||
diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c index 26dedb30ad0b..6223d1757848 100644 --- a/drivers/usb/host/ehci-tegra.c +++ b/drivers/usb/host/ehci-tegra.c | |||
@@ -27,7 +27,7 @@ | |||
27 | #include <linux/of_gpio.h> | 27 | #include <linux/of_gpio.h> |
28 | #include <linux/pm_runtime.h> | 28 | #include <linux/pm_runtime.h> |
29 | 29 | ||
30 | #include <mach/usb_phy.h> | 30 | #include <linux/usb/tegra_usb_phy.h> |
31 | #include <mach/iomap.h> | 31 | #include <mach/iomap.h> |
32 | 32 | ||
33 | #define TEGRA_USB_DMA_ALIGN 32 | 33 | #define TEGRA_USB_DMA_ALIGN 32 |
@@ -49,7 +49,7 @@ static void tegra_ehci_power_up(struct usb_hcd *hcd) | |||
49 | 49 | ||
50 | clk_prepare_enable(tegra->emc_clk); | 50 | clk_prepare_enable(tegra->emc_clk); |
51 | clk_prepare_enable(tegra->clk); | 51 | clk_prepare_enable(tegra->clk); |
52 | tegra_usb_phy_power_on(tegra->phy); | 52 | usb_phy_set_suspend(&tegra->phy->u_phy, 0); |
53 | tegra->host_resumed = 1; | 53 | tegra->host_resumed = 1; |
54 | } | 54 | } |
55 | 55 | ||
@@ -58,7 +58,7 @@ static void tegra_ehci_power_down(struct usb_hcd *hcd) | |||
58 | struct tegra_ehci_hcd *tegra = dev_get_drvdata(hcd->self.controller); | 58 | struct tegra_ehci_hcd *tegra = dev_get_drvdata(hcd->self.controller); |
59 | 59 | ||
60 | tegra->host_resumed = 0; | 60 | tegra->host_resumed = 0; |
61 | tegra_usb_phy_power_off(tegra->phy); | 61 | usb_phy_set_suspend(&tegra->phy->u_phy, 1); |
62 | clk_disable_unprepare(tegra->clk); | 62 | clk_disable_unprepare(tegra->clk); |
63 | clk_disable_unprepare(tegra->emc_clk); | 63 | clk_disable_unprepare(tegra->emc_clk); |
64 | } | 64 | } |
@@ -634,7 +634,8 @@ static int tegra_ehci_probe(struct platform_device *pdev) | |||
634 | 634 | ||
635 | setup_vbus_gpio(pdev, pdata); | 635 | setup_vbus_gpio(pdev, pdata); |
636 | 636 | ||
637 | tegra = kzalloc(sizeof(struct tegra_ehci_hcd), GFP_KERNEL); | 637 | tegra = devm_kzalloc(&pdev->dev, sizeof(struct tegra_ehci_hcd), |
638 | GFP_KERNEL); | ||
638 | if (!tegra) | 639 | if (!tegra) |
639 | return -ENOMEM; | 640 | return -ENOMEM; |
640 | 641 | ||
@@ -642,13 +643,12 @@ static int tegra_ehci_probe(struct platform_device *pdev) | |||
642 | dev_name(&pdev->dev)); | 643 | dev_name(&pdev->dev)); |
643 | if (!hcd) { | 644 | if (!hcd) { |
644 | dev_err(&pdev->dev, "Unable to create HCD\n"); | 645 | dev_err(&pdev->dev, "Unable to create HCD\n"); |
645 | err = -ENOMEM; | 646 | return -ENOMEM; |
646 | goto fail_hcd; | ||
647 | } | 647 | } |
648 | 648 | ||
649 | platform_set_drvdata(pdev, tegra); | 649 | platform_set_drvdata(pdev, tegra); |
650 | 650 | ||
651 | tegra->clk = clk_get(&pdev->dev, NULL); | 651 | tegra->clk = devm_clk_get(&pdev->dev, NULL); |
652 | if (IS_ERR(tegra->clk)) { | 652 | if (IS_ERR(tegra->clk)) { |
653 | dev_err(&pdev->dev, "Can't get ehci clock\n"); | 653 | dev_err(&pdev->dev, "Can't get ehci clock\n"); |
654 | err = PTR_ERR(tegra->clk); | 654 | err = PTR_ERR(tegra->clk); |
@@ -657,9 +657,9 @@ static int tegra_ehci_probe(struct platform_device *pdev) | |||
657 | 657 | ||
658 | err = clk_prepare_enable(tegra->clk); | 658 | err = clk_prepare_enable(tegra->clk); |
659 | if (err) | 659 | if (err) |
660 | goto fail_clken; | 660 | goto fail_clk; |
661 | 661 | ||
662 | tegra->emc_clk = clk_get(&pdev->dev, "emc"); | 662 | tegra->emc_clk = devm_clk_get(&pdev->dev, "emc"); |
663 | if (IS_ERR(tegra->emc_clk)) { | 663 | if (IS_ERR(tegra->emc_clk)) { |
664 | dev_err(&pdev->dev, "Can't get emc clock\n"); | 664 | dev_err(&pdev->dev, "Can't get emc clock\n"); |
665 | err = PTR_ERR(tegra->emc_clk); | 665 | err = PTR_ERR(tegra->emc_clk); |
@@ -677,7 +677,7 @@ static int tegra_ehci_probe(struct platform_device *pdev) | |||
677 | } | 677 | } |
678 | hcd->rsrc_start = res->start; | 678 | hcd->rsrc_start = res->start; |
679 | hcd->rsrc_len = resource_size(res); | 679 | hcd->rsrc_len = resource_size(res); |
680 | hcd->regs = ioremap(res->start, resource_size(res)); | 680 | hcd->regs = devm_ioremap(&pdev->dev, res->start, resource_size(res)); |
681 | if (!hcd->regs) { | 681 | if (!hcd->regs) { |
682 | dev_err(&pdev->dev, "Failed to remap I/O memory\n"); | 682 | dev_err(&pdev->dev, "Failed to remap I/O memory\n"); |
683 | err = -ENOMEM; | 683 | err = -ENOMEM; |
@@ -702,7 +702,7 @@ static int tegra_ehci_probe(struct platform_device *pdev) | |||
702 | default: | 702 | default: |
703 | err = -ENODEV; | 703 | err = -ENODEV; |
704 | dev_err(&pdev->dev, "unknown usb instance\n"); | 704 | dev_err(&pdev->dev, "unknown usb instance\n"); |
705 | goto fail_phy; | 705 | goto fail_io; |
706 | } | 706 | } |
707 | } | 707 | } |
708 | 708 | ||
@@ -712,10 +712,12 @@ static int tegra_ehci_probe(struct platform_device *pdev) | |||
712 | if (IS_ERR(tegra->phy)) { | 712 | if (IS_ERR(tegra->phy)) { |
713 | dev_err(&pdev->dev, "Failed to open USB phy\n"); | 713 | dev_err(&pdev->dev, "Failed to open USB phy\n"); |
714 | err = -ENXIO; | 714 | err = -ENXIO; |
715 | goto fail_phy; | 715 | goto fail_io; |
716 | } | 716 | } |
717 | 717 | ||
718 | err = tegra_usb_phy_power_on(tegra->phy); | 718 | usb_phy_init(&tegra->phy->u_phy); |
719 | |||
720 | err = usb_phy_set_suspend(&tegra->phy->u_phy, 0); | ||
719 | if (err) { | 721 | if (err) { |
720 | dev_err(&pdev->dev, "Failed to power on the phy\n"); | 722 | dev_err(&pdev->dev, "Failed to power on the phy\n"); |
721 | goto fail; | 723 | goto fail; |
@@ -733,7 +735,8 @@ static int tegra_ehci_probe(struct platform_device *pdev) | |||
733 | 735 | ||
734 | #ifdef CONFIG_USB_OTG_UTILS | 736 | #ifdef CONFIG_USB_OTG_UTILS |
735 | if (pdata->operating_mode == TEGRA_USB_OTG) { | 737 | if (pdata->operating_mode == TEGRA_USB_OTG) { |
736 | tegra->transceiver = usb_get_phy(USB_PHY_TYPE_USB2); | 738 | tegra->transceiver = |
739 | devm_usb_get_phy(&pdev->dev, USB_PHY_TYPE_USB2); | ||
737 | if (!IS_ERR_OR_NULL(tegra->transceiver)) | 740 | if (!IS_ERR_OR_NULL(tegra->transceiver)) |
738 | otg_set_host(tegra->transceiver->otg, &hcd->self); | 741 | otg_set_host(tegra->transceiver->otg, &hcd->self); |
739 | } | 742 | } |
@@ -757,25 +760,16 @@ static int tegra_ehci_probe(struct platform_device *pdev) | |||
757 | 760 | ||
758 | fail: | 761 | fail: |
759 | #ifdef CONFIG_USB_OTG_UTILS | 762 | #ifdef CONFIG_USB_OTG_UTILS |
760 | if (!IS_ERR_OR_NULL(tegra->transceiver)) { | 763 | if (!IS_ERR_OR_NULL(tegra->transceiver)) |
761 | otg_set_host(tegra->transceiver->otg, NULL); | 764 | otg_set_host(tegra->transceiver->otg, NULL); |
762 | usb_put_phy(tegra->transceiver); | ||
763 | } | ||
764 | #endif | 765 | #endif |
765 | tegra_usb_phy_close(tegra->phy); | 766 | usb_phy_shutdown(&tegra->phy->u_phy); |
766 | fail_phy: | ||
767 | iounmap(hcd->regs); | ||
768 | fail_io: | 767 | fail_io: |
769 | clk_disable_unprepare(tegra->emc_clk); | 768 | clk_disable_unprepare(tegra->emc_clk); |
770 | clk_put(tegra->emc_clk); | ||
771 | fail_emc_clk: | 769 | fail_emc_clk: |
772 | clk_disable_unprepare(tegra->clk); | 770 | clk_disable_unprepare(tegra->clk); |
773 | fail_clken: | ||
774 | clk_put(tegra->clk); | ||
775 | fail_clk: | 771 | fail_clk: |
776 | usb_put_hcd(hcd); | 772 | usb_put_hcd(hcd); |
777 | fail_hcd: | ||
778 | kfree(tegra); | ||
779 | return err; | 773 | return err; |
780 | } | 774 | } |
781 | 775 | ||
@@ -792,26 +786,19 @@ static int tegra_ehci_remove(struct platform_device *pdev) | |||
792 | pm_runtime_put_noidle(&pdev->dev); | 786 | pm_runtime_put_noidle(&pdev->dev); |
793 | 787 | ||
794 | #ifdef CONFIG_USB_OTG_UTILS | 788 | #ifdef CONFIG_USB_OTG_UTILS |
795 | if (!IS_ERR_OR_NULL(tegra->transceiver)) { | 789 | if (!IS_ERR_OR_NULL(tegra->transceiver)) |
796 | otg_set_host(tegra->transceiver->otg, NULL); | 790 | otg_set_host(tegra->transceiver->otg, NULL); |
797 | usb_put_phy(tegra->transceiver); | ||
798 | } | ||
799 | #endif | 791 | #endif |
800 | 792 | ||
801 | usb_remove_hcd(hcd); | 793 | usb_remove_hcd(hcd); |
802 | |||
803 | tegra_usb_phy_close(tegra->phy); | ||
804 | iounmap(hcd->regs); | ||
805 | |||
806 | usb_put_hcd(hcd); | 794 | usb_put_hcd(hcd); |
807 | 795 | ||
796 | usb_phy_shutdown(&tegra->phy->u_phy); | ||
797 | |||
808 | clk_disable_unprepare(tegra->clk); | 798 | clk_disable_unprepare(tegra->clk); |
809 | clk_put(tegra->clk); | ||
810 | 799 | ||
811 | clk_disable_unprepare(tegra->emc_clk); | 800 | clk_disable_unprepare(tegra->emc_clk); |
812 | clk_put(tegra->emc_clk); | ||
813 | 801 | ||
814 | kfree(tegra); | ||
815 | return 0; | 802 | return 0; |
816 | } | 803 | } |
817 | 804 | ||
diff --git a/drivers/usb/host/ehci-timer.c b/drivers/usb/host/ehci-timer.c index eb896a2c8f2e..20dbdcbe9b0f 100644 --- a/drivers/usb/host/ehci-timer.c +++ b/drivers/usb/host/ehci-timer.c | |||
@@ -118,7 +118,8 @@ static void ehci_poll_ASS(struct ehci_hcd *ehci) | |||
118 | ehci_enable_event(ehci, EHCI_HRTIMER_POLL_ASS, true); | 118 | ehci_enable_event(ehci, EHCI_HRTIMER_POLL_ASS, true); |
119 | return; | 119 | return; |
120 | } | 120 | } |
121 | ehci_warn(ehci, "Waited too long for the async schedule status, giving up\n"); | 121 | ehci_dbg(ehci, "Waited too long for the async schedule status (%x/%x), giving up\n", |
122 | want, actual); | ||
122 | } | 123 | } |
123 | ehci->ASS_poll_count = 0; | 124 | ehci->ASS_poll_count = 0; |
124 | 125 | ||
@@ -163,7 +164,8 @@ static void ehci_poll_PSS(struct ehci_hcd *ehci) | |||
163 | ehci_enable_event(ehci, EHCI_HRTIMER_POLL_PSS, true); | 164 | ehci_enable_event(ehci, EHCI_HRTIMER_POLL_PSS, true); |
164 | return; | 165 | return; |
165 | } | 166 | } |
166 | ehci_warn(ehci, "Waited too long for the periodic schedule status, giving up\n"); | 167 | ehci_dbg(ehci, "Waited too long for the periodic schedule status (%x/%x), giving up\n", |
168 | want, actual); | ||
167 | } | 169 | } |
168 | ehci->PSS_poll_count = 0; | 170 | ehci->PSS_poll_count = 0; |
169 | 171 | ||
diff --git a/drivers/usb/host/ehci-vt8500.c b/drivers/usb/host/ehci-vt8500.c index 4d147c4e33f5..96722bfebc84 100644 --- a/drivers/usb/host/ehci-vt8500.c +++ b/drivers/usb/host/ehci-vt8500.c | |||
@@ -16,6 +16,7 @@ | |||
16 | * | 16 | * |
17 | */ | 17 | */ |
18 | 18 | ||
19 | #include <linux/of.h> | ||
19 | #include <linux/platform_device.h> | 20 | #include <linux/platform_device.h> |
20 | 21 | ||
21 | static int ehci_update_device(struct usb_hcd *hcd, struct usb_device *udev) | 22 | static int ehci_update_device(struct usb_hcd *hcd, struct usb_device *udev) |
@@ -106,17 +107,11 @@ static int vt8500_ehci_drv_probe(struct platform_device *pdev) | |||
106 | hcd->rsrc_start = res->start; | 107 | hcd->rsrc_start = res->start; |
107 | hcd->rsrc_len = resource_size(res); | 108 | hcd->rsrc_len = resource_size(res); |
108 | 109 | ||
109 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { | 110 | hcd->regs = devm_request_and_ioremap(&pdev->dev, res); |
110 | pr_debug("request_mem_region failed"); | ||
111 | ret = -EBUSY; | ||
112 | goto err1; | ||
113 | } | ||
114 | |||
115 | hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); | ||
116 | if (!hcd->regs) { | 111 | if (!hcd->regs) { |
117 | pr_debug("ioremap failed"); | 112 | pr_debug("ioremap failed"); |
118 | ret = -ENOMEM; | 113 | ret = -ENOMEM; |
119 | goto err2; | 114 | goto err1; |
120 | } | 115 | } |
121 | 116 | ||
122 | ehci = hcd_to_ehci(hcd); | 117 | ehci = hcd_to_ehci(hcd); |
@@ -129,9 +124,6 @@ static int vt8500_ehci_drv_probe(struct platform_device *pdev) | |||
129 | return ret; | 124 | return ret; |
130 | } | 125 | } |
131 | 126 | ||
132 | iounmap(hcd->regs); | ||
133 | err2: | ||
134 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
135 | err1: | 127 | err1: |
136 | usb_put_hcd(hcd); | 128 | usb_put_hcd(hcd); |
137 | return ret; | 129 | return ret; |
@@ -142,14 +134,18 @@ static int vt8500_ehci_drv_remove(struct platform_device *pdev) | |||
142 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | 134 | struct usb_hcd *hcd = platform_get_drvdata(pdev); |
143 | 135 | ||
144 | usb_remove_hcd(hcd); | 136 | usb_remove_hcd(hcd); |
145 | iounmap(hcd->regs); | ||
146 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
147 | usb_put_hcd(hcd); | 137 | usb_put_hcd(hcd); |
148 | platform_set_drvdata(pdev, NULL); | 138 | platform_set_drvdata(pdev, NULL); |
149 | 139 | ||
150 | return 0; | 140 | return 0; |
151 | } | 141 | } |
152 | 142 | ||
143 | static const struct of_device_id vt8500_ehci_ids[] = { | ||
144 | { .compatible = "via,vt8500-ehci", }, | ||
145 | { .compatible = "wm,prizm-ehci", }, | ||
146 | {} | ||
147 | }; | ||
148 | |||
153 | static struct platform_driver vt8500_ehci_driver = { | 149 | static struct platform_driver vt8500_ehci_driver = { |
154 | .probe = vt8500_ehci_drv_probe, | 150 | .probe = vt8500_ehci_drv_probe, |
155 | .remove = vt8500_ehci_drv_remove, | 151 | .remove = vt8500_ehci_drv_remove, |
@@ -157,7 +153,9 @@ static struct platform_driver vt8500_ehci_driver = { | |||
157 | .driver = { | 153 | .driver = { |
158 | .name = "vt8500-ehci", | 154 | .name = "vt8500-ehci", |
159 | .owner = THIS_MODULE, | 155 | .owner = THIS_MODULE, |
156 | .of_match_table = of_match_ptr(vt8500_ehci_ids), | ||
160 | } | 157 | } |
161 | }; | 158 | }; |
162 | 159 | ||
163 | MODULE_ALIAS("platform:vt8500-ehci"); | 160 | MODULE_ALIAS("platform:vt8500-ehci"); |
161 | MODULE_DEVICE_TABLE(of, vt8500_ehci_ids); | ||
diff --git a/drivers/usb/host/ehci-xilinx-of.c b/drivers/usb/host/ehci-xilinx-of.c index 39f24fa37ebe..6a3f921a5d76 100644 --- a/drivers/usb/host/ehci-xilinx-of.c +++ b/drivers/usb/host/ehci-xilinx-of.c | |||
@@ -152,12 +152,6 @@ static int __devinit ehci_hcd_xilinx_of_probe(struct platform_device *op) | |||
152 | hcd->rsrc_start = res.start; | 152 | hcd->rsrc_start = res.start; |
153 | hcd->rsrc_len = resource_size(&res); | 153 | hcd->rsrc_len = resource_size(&res); |
154 | 154 | ||
155 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { | ||
156 | printk(KERN_ERR "%s: request_mem_region failed\n", __FILE__); | ||
157 | rv = -EBUSY; | ||
158 | goto err_rmr; | ||
159 | } | ||
160 | |||
161 | irq = irq_of_parse_and_map(dn, 0); | 155 | irq = irq_of_parse_and_map(dn, 0); |
162 | if (!irq) { | 156 | if (!irq) { |
163 | printk(KERN_ERR "%s: irq_of_parse_and_map failed\n", __FILE__); | 157 | printk(KERN_ERR "%s: irq_of_parse_and_map failed\n", __FILE__); |
@@ -165,11 +159,11 @@ static int __devinit ehci_hcd_xilinx_of_probe(struct platform_device *op) | |||
165 | goto err_irq; | 159 | goto err_irq; |
166 | } | 160 | } |
167 | 161 | ||
168 | hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); | 162 | hcd->regs = devm_request_and_ioremap(&op->dev, &res); |
169 | if (!hcd->regs) { | 163 | if (!hcd->regs) { |
170 | printk(KERN_ERR "%s: ioremap failed\n", __FILE__); | 164 | pr_err("%s: devm_request_and_ioremap failed\n", __FILE__); |
171 | rv = -ENOMEM; | 165 | rv = -ENOMEM; |
172 | goto err_ioremap; | 166 | goto err_irq; |
173 | } | 167 | } |
174 | 168 | ||
175 | ehci = hcd_to_ehci(hcd); | 169 | ehci = hcd_to_ehci(hcd); |
@@ -200,12 +194,7 @@ static int __devinit ehci_hcd_xilinx_of_probe(struct platform_device *op) | |||
200 | if (rv == 0) | 194 | if (rv == 0) |
201 | return 0; | 195 | return 0; |
202 | 196 | ||
203 | iounmap(hcd->regs); | ||
204 | |||
205 | err_ioremap: | ||
206 | err_irq: | 197 | err_irq: |
207 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
208 | err_rmr: | ||
209 | usb_put_hcd(hcd); | 198 | usb_put_hcd(hcd); |
210 | 199 | ||
211 | return rv; | 200 | return rv; |
@@ -227,9 +216,6 @@ static int ehci_hcd_xilinx_of_remove(struct platform_device *op) | |||
227 | 216 | ||
228 | usb_remove_hcd(hcd); | 217 | usb_remove_hcd(hcd); |
229 | 218 | ||
230 | iounmap(hcd->regs); | ||
231 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
232 | |||
233 | usb_put_hcd(hcd); | 219 | usb_put_hcd(hcd); |
234 | 220 | ||
235 | return 0; | 221 | return 0; |
diff --git a/drivers/usb/host/fhci-sched.c b/drivers/usb/host/fhci-sched.c index 2dc8a40e39d7..8f18538e0ff7 100644 --- a/drivers/usb/host/fhci-sched.c +++ b/drivers/usb/host/fhci-sched.c | |||
@@ -261,8 +261,7 @@ static void move_head_to_tail(struct list_head *list) | |||
261 | struct list_head *node = list->next; | 261 | struct list_head *node = list->next; |
262 | 262 | ||
263 | if (!list_empty(list)) { | 263 | if (!list_empty(list)) { |
264 | list_del(node); | 264 | list_move_tail(node, list); |
265 | list_add_tail(node, list); | ||
266 | } | 265 | } |
267 | } | 266 | } |
268 | 267 | ||
diff --git a/drivers/usb/host/fsl-mph-dr-of.c b/drivers/usb/host/fsl-mph-dr-of.c index 22ff6b3a676f..1e771292383f 100644 --- a/drivers/usb/host/fsl-mph-dr-of.c +++ b/drivers/usb/host/fsl-mph-dr-of.c | |||
@@ -133,6 +133,8 @@ static int usb_get_ver_info(struct device_node *np) | |||
133 | ver = FSL_USB_VER_1_6; | 133 | ver = FSL_USB_VER_1_6; |
134 | else if (of_device_is_compatible(np, "fsl-usb2-dr-v2.2")) | 134 | else if (of_device_is_compatible(np, "fsl-usb2-dr-v2.2")) |
135 | ver = FSL_USB_VER_2_2; | 135 | ver = FSL_USB_VER_2_2; |
136 | else if (of_device_is_compatible(np, "fsl-usb2-dr-v2.4")) | ||
137 | ver = FSL_USB_VER_2_4; | ||
136 | else /* for previous controller versions */ | 138 | else /* for previous controller versions */ |
137 | ver = FSL_USB_VER_OLD; | 139 | ver = FSL_USB_VER_OLD; |
138 | 140 | ||
diff --git a/drivers/usb/host/ohci-nxp.c b/drivers/usb/host/ohci-nxp.c index a446386bf779..c60066a63606 100644 --- a/drivers/usb/host/ohci-nxp.c +++ b/drivers/usb/host/ohci-nxp.c | |||
@@ -355,7 +355,7 @@ static int __devinit usb_hcd_nxp_probe(struct platform_device *pdev) | |||
355 | usb_otg_clk = clk_get(&pdev->dev, "ck_usb_otg"); | 355 | usb_otg_clk = clk_get(&pdev->dev, "ck_usb_otg"); |
356 | if (IS_ERR(usb_otg_clk)) { | 356 | if (IS_ERR(usb_otg_clk)) { |
357 | dev_err(&pdev->dev, "failed to acquire USB DEV Clock\n"); | 357 | dev_err(&pdev->dev, "failed to acquire USB DEV Clock\n"); |
358 | ret = PTR_ERR(usb_dev_clk); | 358 | ret = PTR_ERR(usb_otg_clk); |
359 | goto out6; | 359 | goto out6; |
360 | } | 360 | } |
361 | 361 | ||
diff --git a/drivers/usb/host/ohci-platform.c b/drivers/usb/host/ohci-platform.c index 670c7059c9ae..e24ec9f79164 100644 --- a/drivers/usb/host/ohci-platform.c +++ b/drivers/usb/host/ohci-platform.c | |||
@@ -83,10 +83,14 @@ static int __devinit ohci_platform_probe(struct platform_device *dev) | |||
83 | { | 83 | { |
84 | struct usb_hcd *hcd; | 84 | struct usb_hcd *hcd; |
85 | struct resource *res_mem; | 85 | struct resource *res_mem; |
86 | struct usb_ohci_pdata *pdata = dev->dev.platform_data; | ||
86 | int irq; | 87 | int irq; |
87 | int err = -ENOMEM; | 88 | int err = -ENOMEM; |
88 | 89 | ||
89 | BUG_ON(!dev->dev.platform_data); | 90 | if (!pdata) { |
91 | WARN_ON(1); | ||
92 | return -ENODEV; | ||
93 | } | ||
90 | 94 | ||
91 | if (usb_disabled()) | 95 | if (usb_disabled()) |
92 | return -ENODEV; | 96 | return -ENODEV; |
@@ -103,10 +107,18 @@ static int __devinit ohci_platform_probe(struct platform_device *dev) | |||
103 | return -ENXIO; | 107 | return -ENXIO; |
104 | } | 108 | } |
105 | 109 | ||
110 | if (pdata->power_on) { | ||
111 | err = pdata->power_on(dev); | ||
112 | if (err < 0) | ||
113 | return err; | ||
114 | } | ||
115 | |||
106 | hcd = usb_create_hcd(&ohci_platform_hc_driver, &dev->dev, | 116 | hcd = usb_create_hcd(&ohci_platform_hc_driver, &dev->dev, |
107 | dev_name(&dev->dev)); | 117 | dev_name(&dev->dev)); |
108 | if (!hcd) | 118 | if (!hcd) { |
109 | return -ENOMEM; | 119 | err = -ENOMEM; |
120 | goto err_power; | ||
121 | } | ||
110 | 122 | ||
111 | hcd->rsrc_start = res_mem->start; | 123 | hcd->rsrc_start = res_mem->start; |
112 | hcd->rsrc_len = resource_size(res_mem); | 124 | hcd->rsrc_len = resource_size(res_mem); |
@@ -118,8 +130,10 @@ static int __devinit ohci_platform_probe(struct platform_device *dev) | |||
118 | } | 130 | } |
119 | 131 | ||
120 | hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len); | 132 | hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len); |
121 | if (!hcd->regs) | 133 | if (!hcd->regs) { |
134 | err = -ENOMEM; | ||
122 | goto err_release_region; | 135 | goto err_release_region; |
136 | } | ||
123 | err = usb_add_hcd(hcd, irq, IRQF_SHARED); | 137 | err = usb_add_hcd(hcd, irq, IRQF_SHARED); |
124 | if (err) | 138 | if (err) |
125 | goto err_iounmap; | 139 | goto err_iounmap; |
@@ -134,12 +148,17 @@ err_release_region: | |||
134 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | 148 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); |
135 | err_put_hcd: | 149 | err_put_hcd: |
136 | usb_put_hcd(hcd); | 150 | usb_put_hcd(hcd); |
151 | err_power: | ||
152 | if (pdata->power_off) | ||
153 | pdata->power_off(dev); | ||
154 | |||
137 | return err; | 155 | return err; |
138 | } | 156 | } |
139 | 157 | ||
140 | static int __devexit ohci_platform_remove(struct platform_device *dev) | 158 | static int __devexit ohci_platform_remove(struct platform_device *dev) |
141 | { | 159 | { |
142 | struct usb_hcd *hcd = platform_get_drvdata(dev); | 160 | struct usb_hcd *hcd = platform_get_drvdata(dev); |
161 | struct usb_ohci_pdata *pdata = dev->dev.platform_data; | ||
143 | 162 | ||
144 | usb_remove_hcd(hcd); | 163 | usb_remove_hcd(hcd); |
145 | iounmap(hcd->regs); | 164 | iounmap(hcd->regs); |
@@ -147,6 +166,9 @@ static int __devexit ohci_platform_remove(struct platform_device *dev) | |||
147 | usb_put_hcd(hcd); | 166 | usb_put_hcd(hcd); |
148 | platform_set_drvdata(dev, NULL); | 167 | platform_set_drvdata(dev, NULL); |
149 | 168 | ||
169 | if (pdata->power_off) | ||
170 | pdata->power_off(dev); | ||
171 | |||
150 | return 0; | 172 | return 0; |
151 | } | 173 | } |
152 | 174 | ||
@@ -154,12 +176,28 @@ static int __devexit ohci_platform_remove(struct platform_device *dev) | |||
154 | 176 | ||
155 | static int ohci_platform_suspend(struct device *dev) | 177 | static int ohci_platform_suspend(struct device *dev) |
156 | { | 178 | { |
179 | struct usb_ohci_pdata *pdata = dev->platform_data; | ||
180 | struct platform_device *pdev = | ||
181 | container_of(dev, struct platform_device, dev); | ||
182 | |||
183 | if (pdata->power_suspend) | ||
184 | pdata->power_suspend(pdev); | ||
185 | |||
157 | return 0; | 186 | return 0; |
158 | } | 187 | } |
159 | 188 | ||
160 | static int ohci_platform_resume(struct device *dev) | 189 | static int ohci_platform_resume(struct device *dev) |
161 | { | 190 | { |
162 | struct usb_hcd *hcd = dev_get_drvdata(dev); | 191 | struct usb_hcd *hcd = dev_get_drvdata(dev); |
192 | struct usb_ohci_pdata *pdata = dev->platform_data; | ||
193 | struct platform_device *pdev = | ||
194 | container_of(dev, struct platform_device, dev); | ||
195 | |||
196 | if (pdata->power_on) { | ||
197 | int err = pdata->power_on(pdev); | ||
198 | if (err < 0) | ||
199 | return err; | ||
200 | } | ||
163 | 201 | ||
164 | ohci_finish_controller_resume(hcd); | 202 | ohci_finish_controller_resume(hcd); |
165 | return 0; | 203 | return 0; |
diff --git a/drivers/usb/host/ohci-pxa27x.c b/drivers/usb/host/ohci-pxa27x.c index e1a3cc6d28dc..77f4402aca03 100644 --- a/drivers/usb/host/ohci-pxa27x.c +++ b/drivers/usb/host/ohci-pxa27x.c | |||
@@ -23,6 +23,8 @@ | |||
23 | #include <linux/signal.h> | 23 | #include <linux/signal.h> |
24 | #include <linux/platform_device.h> | 24 | #include <linux/platform_device.h> |
25 | #include <linux/clk.h> | 25 | #include <linux/clk.h> |
26 | #include <linux/of_platform.h> | ||
27 | #include <linux/of_gpio.h> | ||
26 | #include <mach/hardware.h> | 28 | #include <mach/hardware.h> |
27 | #include <mach/ohci.h> | 29 | #include <mach/ohci.h> |
28 | #include <mach/pxa3xx-u2d.h> | 30 | #include <mach/pxa3xx-u2d.h> |
@@ -272,6 +274,67 @@ static void pxa27x_stop_hc(struct pxa27x_ohci *ohci, struct device *dev) | |||
272 | clk_disable_unprepare(ohci->clk); | 274 | clk_disable_unprepare(ohci->clk); |
273 | } | 275 | } |
274 | 276 | ||
277 | #ifdef CONFIG_OF | ||
278 | static const struct of_device_id pxa_ohci_dt_ids[] = { | ||
279 | { .compatible = "marvell,pxa-ohci" }, | ||
280 | { } | ||
281 | }; | ||
282 | |||
283 | MODULE_DEVICE_TABLE(of, pxa_ohci_dt_ids); | ||
284 | |||
285 | static u64 pxa_ohci_dma_mask = DMA_BIT_MASK(32); | ||
286 | |||
287 | static int __devinit ohci_pxa_of_init(struct platform_device *pdev) | ||
288 | { | ||
289 | struct device_node *np = pdev->dev.of_node; | ||
290 | struct pxaohci_platform_data *pdata; | ||
291 | u32 tmp; | ||
292 | |||
293 | if (!np) | ||
294 | return 0; | ||
295 | |||
296 | /* Right now device-tree probed devices don't get dma_mask set. | ||
297 | * Since shared usb code relies on it, set it here for now. | ||
298 | * Once we have dma capability bindings this can go away. | ||
299 | */ | ||
300 | if (!pdev->dev.dma_mask) | ||
301 | pdev->dev.dma_mask = &pxa_ohci_dma_mask; | ||
302 | |||
303 | pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); | ||
304 | if (!pdata) | ||
305 | return -ENOMEM; | ||
306 | |||
307 | if (of_get_property(np, "marvell,enable-port1", NULL)) | ||
308 | pdata->flags |= ENABLE_PORT1; | ||
309 | if (of_get_property(np, "marvell,enable-port2", NULL)) | ||
310 | pdata->flags |= ENABLE_PORT2; | ||
311 | if (of_get_property(np, "marvell,enable-port3", NULL)) | ||
312 | pdata->flags |= ENABLE_PORT3; | ||
313 | if (of_get_property(np, "marvell,port-sense-low", NULL)) | ||
314 | pdata->flags |= POWER_SENSE_LOW; | ||
315 | if (of_get_property(np, "marvell,power-control-low", NULL)) | ||
316 | pdata->flags |= POWER_CONTROL_LOW; | ||
317 | if (of_get_property(np, "marvell,no-oc-protection", NULL)) | ||
318 | pdata->flags |= NO_OC_PROTECTION; | ||
319 | if (of_get_property(np, "marvell,oc-mode-perport", NULL)) | ||
320 | pdata->flags |= OC_MODE_PERPORT; | ||
321 | if (!of_property_read_u32(np, "marvell,power-on-delay", &tmp)) | ||
322 | pdata->power_on_delay = tmp; | ||
323 | if (!of_property_read_u32(np, "marvell,port-mode", &tmp)) | ||
324 | pdata->port_mode = tmp; | ||
325 | if (!of_property_read_u32(np, "marvell,power-budget", &tmp)) | ||
326 | pdata->power_budget = tmp; | ||
327 | |||
328 | pdev->dev.platform_data = pdata; | ||
329 | |||
330 | return 0; | ||
331 | } | ||
332 | #else | ||
333 | static int __devinit ohci_pxa_of_init(struct platform_device *pdev) | ||
334 | { | ||
335 | return 0; | ||
336 | } | ||
337 | #endif | ||
275 | 338 | ||
276 | /*-------------------------------------------------------------------------*/ | 339 | /*-------------------------------------------------------------------------*/ |
277 | 340 | ||
@@ -297,6 +360,10 @@ int usb_hcd_pxa27x_probe (const struct hc_driver *driver, struct platform_device | |||
297 | struct resource *r; | 360 | struct resource *r; |
298 | struct clk *usb_clk; | 361 | struct clk *usb_clk; |
299 | 362 | ||
363 | retval = ohci_pxa_of_init(pdev); | ||
364 | if (retval) | ||
365 | return retval; | ||
366 | |||
300 | inf = pdev->dev.platform_data; | 367 | inf = pdev->dev.platform_data; |
301 | 368 | ||
302 | if (!inf) | 369 | if (!inf) |
@@ -544,6 +611,7 @@ static struct platform_driver ohci_hcd_pxa27x_driver = { | |||
544 | .driver = { | 611 | .driver = { |
545 | .name = "pxa27x-ohci", | 612 | .name = "pxa27x-ohci", |
546 | .owner = THIS_MODULE, | 613 | .owner = THIS_MODULE, |
614 | .of_match_table = of_match_ptr(pxa_ohci_dt_ids), | ||
547 | #ifdef CONFIG_PM | 615 | #ifdef CONFIG_PM |
548 | .pm = &ohci_hcd_pxa27x_pm_ops, | 616 | .pm = &ohci_hcd_pxa27x_pm_ops, |
549 | #endif | 617 | #endif |
diff --git a/drivers/usb/host/ohci-xls.c b/drivers/usb/host/ohci-xls.c index 41e378f17c66..84201cd1a472 100644 --- a/drivers/usb/host/ohci-xls.c +++ b/drivers/usb/host/ohci-xls.c | |||
@@ -56,7 +56,7 @@ static int ohci_xls_probe_internal(const struct hc_driver *driver, | |||
56 | goto err3; | 56 | goto err3; |
57 | } | 57 | } |
58 | 58 | ||
59 | retval = usb_add_hcd(hcd, irq, IRQF_DISABLED | IRQF_SHARED); | 59 | retval = usb_add_hcd(hcd, irq, IRQF_SHARED); |
60 | if (retval != 0) | 60 | if (retval != 0) |
61 | goto err4; | 61 | goto err4; |
62 | return retval; | 62 | return retval; |
diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c index 4c634eb56358..fcc09e5ec0ad 100644 --- a/drivers/usb/host/r8a66597-hcd.c +++ b/drivers/usb/host/r8a66597-hcd.c | |||
@@ -2029,15 +2029,14 @@ static int r8a66597_get_frame(struct usb_hcd *hcd) | |||
2029 | static void collect_usb_address_map(struct usb_device *udev, unsigned long *map) | 2029 | static void collect_usb_address_map(struct usb_device *udev, unsigned long *map) |
2030 | { | 2030 | { |
2031 | int chix; | 2031 | int chix; |
2032 | struct usb_device *childdev; | ||
2032 | 2033 | ||
2033 | if (udev->state == USB_STATE_CONFIGURED && | 2034 | if (udev->state == USB_STATE_CONFIGURED && |
2034 | udev->parent && udev->parent->devnum > 1 && | 2035 | udev->parent && udev->parent->devnum > 1 && |
2035 | udev->parent->descriptor.bDeviceClass == USB_CLASS_HUB) | 2036 | udev->parent->descriptor.bDeviceClass == USB_CLASS_HUB) |
2036 | map[udev->devnum/32] |= (1 << (udev->devnum % 32)); | 2037 | map[udev->devnum/32] |= (1 << (udev->devnum % 32)); |
2037 | 2038 | ||
2038 | for (chix = 0; chix < udev->maxchild; chix++) { | 2039 | usb_hub_for_each_child(udev, chix, childdev) { |
2039 | struct usb_device *childdev = udev->children[chix]; | ||
2040 | |||
2041 | if (childdev) | 2040 | if (childdev) |
2042 | collect_usb_address_map(childdev, map); | 2041 | collect_usb_address_map(childdev, map); |
2043 | } | 2042 | } |
diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c index 91ce1c02e617..619b05f42d4f 100644 --- a/drivers/usb/host/sl811-hcd.c +++ b/drivers/usb/host/sl811-hcd.c | |||
@@ -156,7 +156,7 @@ static void setup_packet( | |||
156 | writeb(SL_SETUP /* | ep->epnum */, data_reg); | 156 | writeb(SL_SETUP /* | ep->epnum */, data_reg); |
157 | writeb(usb_pipedevice(urb->pipe), data_reg); | 157 | writeb(usb_pipedevice(urb->pipe), data_reg); |
158 | 158 | ||
159 | /* always OUT/data0 */ ; | 159 | /* always OUT/data0 */ |
160 | sl811_write(sl811, bank + SL11H_HOSTCTLREG, | 160 | sl811_write(sl811, bank + SL11H_HOSTCTLREG, |
161 | control | SL11H_HCTLMASK_OUT); | 161 | control | SL11H_HCTLMASK_OUT); |
162 | ep->length = 0; | 162 | ep->length = 0; |
diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c index e4db350602b8..4b9e9aba2665 100644 --- a/drivers/usb/host/uhci-hcd.c +++ b/drivers/usb/host/uhci-hcd.c | |||
@@ -846,6 +846,11 @@ static const char hcd_name[] = "uhci_hcd"; | |||
846 | #define PLATFORM_DRIVER uhci_grlib_driver | 846 | #define PLATFORM_DRIVER uhci_grlib_driver |
847 | #endif | 847 | #endif |
848 | 848 | ||
849 | #ifdef CONFIG_USB_UHCI_PLATFORM | ||
850 | #include "uhci-platform.c" | ||
851 | #define PLATFORM_DRIVER uhci_platform_driver | ||
852 | #endif | ||
853 | |||
849 | #if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) | 854 | #if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) |
850 | #error "missing bus glue for uhci-hcd" | 855 | #error "missing bus glue for uhci-hcd" |
851 | #endif | 856 | #endif |
diff --git a/drivers/usb/host/uhci-platform.c b/drivers/usb/host/uhci-platform.c new file mode 100644 index 000000000000..e4780491df4a --- /dev/null +++ b/drivers/usb/host/uhci-platform.c | |||
@@ -0,0 +1,157 @@ | |||
1 | /* | ||
2 | * Generic UHCI HCD (Host Controller Driver) for Platform Devices | ||
3 | * | ||
4 | * Copyright (c) 2011 Tony Prisk <linux@prisktech.co.nz> | ||
5 | * | ||
6 | * This file is based on uhci-grlib.c | ||
7 | * (C) Copyright 2004-2007 Alan Stern, stern@rowland.harvard.edu | ||
8 | */ | ||
9 | |||
10 | #include <linux/of.h> | ||
11 | #include <linux/platform_device.h> | ||
12 | |||
13 | static int uhci_platform_init(struct usb_hcd *hcd) | ||
14 | { | ||
15 | struct uhci_hcd *uhci = hcd_to_uhci(hcd); | ||
16 | |||
17 | uhci->rh_numports = uhci_count_ports(hcd); | ||
18 | |||
19 | /* Set up pointers to to generic functions */ | ||
20 | uhci->reset_hc = uhci_generic_reset_hc; | ||
21 | uhci->check_and_reset_hc = uhci_generic_check_and_reset_hc; | ||
22 | |||
23 | /* No special actions need to be taken for the functions below */ | ||
24 | uhci->configure_hc = NULL; | ||
25 | uhci->resume_detect_interrupts_are_broken = NULL; | ||
26 | uhci->global_suspend_mode_is_broken = NULL; | ||
27 | |||
28 | /* Reset if the controller isn't already safely quiescent. */ | ||
29 | check_and_reset_hc(uhci); | ||
30 | return 0; | ||
31 | } | ||
32 | |||
33 | static const struct hc_driver uhci_platform_hc_driver = { | ||
34 | .description = hcd_name, | ||
35 | .product_desc = "Generic UHCI Host Controller", | ||
36 | .hcd_priv_size = sizeof(struct uhci_hcd), | ||
37 | |||
38 | /* Generic hardware linkage */ | ||
39 | .irq = uhci_irq, | ||
40 | .flags = HCD_MEMORY | HCD_USB11, | ||
41 | |||
42 | /* Basic lifecycle operations */ | ||
43 | .reset = uhci_platform_init, | ||
44 | .start = uhci_start, | ||
45 | #ifdef CONFIG_PM | ||
46 | .pci_suspend = NULL, | ||
47 | .pci_resume = NULL, | ||
48 | .bus_suspend = uhci_rh_suspend, | ||
49 | .bus_resume = uhci_rh_resume, | ||
50 | #endif | ||
51 | .stop = uhci_stop, | ||
52 | |||
53 | .urb_enqueue = uhci_urb_enqueue, | ||
54 | .urb_dequeue = uhci_urb_dequeue, | ||
55 | |||
56 | .endpoint_disable = uhci_hcd_endpoint_disable, | ||
57 | .get_frame_number = uhci_hcd_get_frame_number, | ||
58 | |||
59 | .hub_status_data = uhci_hub_status_data, | ||
60 | .hub_control = uhci_hub_control, | ||
61 | }; | ||
62 | |||
63 | |||
64 | static int __devinit uhci_hcd_platform_probe(struct platform_device *pdev) | ||
65 | { | ||
66 | struct usb_hcd *hcd; | ||
67 | struct uhci_hcd *uhci; | ||
68 | struct resource *res; | ||
69 | int ret; | ||
70 | |||
71 | if (usb_disabled()) | ||
72 | return -ENODEV; | ||
73 | |||
74 | hcd = usb_create_hcd(&uhci_platform_hc_driver, &pdev->dev, | ||
75 | pdev->name); | ||
76 | if (!hcd) | ||
77 | return -ENOMEM; | ||
78 | |||
79 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
80 | hcd->rsrc_start = res->start; | ||
81 | hcd->rsrc_len = resource_size(res); | ||
82 | |||
83 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { | ||
84 | pr_err("%s: request_mem_region failed\n", __func__); | ||
85 | ret = -EBUSY; | ||
86 | goto err_rmr; | ||
87 | } | ||
88 | |||
89 | hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); | ||
90 | if (!hcd->regs) { | ||
91 | pr_err("%s: ioremap failed\n", __func__); | ||
92 | ret = -ENOMEM; | ||
93 | goto err_irq; | ||
94 | } | ||
95 | uhci = hcd_to_uhci(hcd); | ||
96 | |||
97 | uhci->regs = hcd->regs; | ||
98 | |||
99 | ret = usb_add_hcd(hcd, pdev->resource[1].start, IRQF_DISABLED | | ||
100 | IRQF_SHARED); | ||
101 | if (ret) | ||
102 | goto err_uhci; | ||
103 | |||
104 | return 0; | ||
105 | |||
106 | err_uhci: | ||
107 | iounmap(hcd->regs); | ||
108 | err_irq: | ||
109 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
110 | err_rmr: | ||
111 | usb_put_hcd(hcd); | ||
112 | |||
113 | return ret; | ||
114 | } | ||
115 | |||
116 | static int uhci_hcd_platform_remove(struct platform_device *pdev) | ||
117 | { | ||
118 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | ||
119 | |||
120 | usb_remove_hcd(hcd); | ||
121 | iounmap(hcd->regs); | ||
122 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
123 | usb_put_hcd(hcd); | ||
124 | platform_set_drvdata(pdev, NULL); | ||
125 | |||
126 | return 0; | ||
127 | } | ||
128 | |||
129 | /* Make sure the controller is quiescent and that we're not using it | ||
130 | * any more. This is mainly for the benefit of programs which, like kexec, | ||
131 | * expect the hardware to be idle: not doing DMA or generating IRQs. | ||
132 | * | ||
133 | * This routine may be called in a damaged or failing kernel. Hence we | ||
134 | * do not acquire the spinlock before shutting down the controller. | ||
135 | */ | ||
136 | static void uhci_hcd_platform_shutdown(struct platform_device *op) | ||
137 | { | ||
138 | struct usb_hcd *hcd = dev_get_drvdata(&op->dev); | ||
139 | |||
140 | uhci_hc_died(hcd_to_uhci(hcd)); | ||
141 | } | ||
142 | |||
143 | static const struct of_device_id platform_uhci_ids[] = { | ||
144 | { .compatible = "platform-uhci", }, | ||
145 | {} | ||
146 | }; | ||
147 | |||
148 | static struct platform_driver uhci_platform_driver = { | ||
149 | .probe = uhci_hcd_platform_probe, | ||
150 | .remove = uhci_hcd_platform_remove, | ||
151 | .shutdown = uhci_hcd_platform_shutdown, | ||
152 | .driver = { | ||
153 | .name = "platform-uhci", | ||
154 | .owner = THIS_MODULE, | ||
155 | .of_match_table = of_match_ptr(platform_uhci_ids), | ||
156 | }, | ||
157 | }; | ||
diff --git a/drivers/usb/host/whci/hcd.c b/drivers/usb/host/whci/hcd.c index 1e141f755b26..c3a647816af0 100644 --- a/drivers/usb/host/whci/hcd.c +++ b/drivers/usb/host/whci/hcd.c | |||
@@ -238,16 +238,16 @@ static struct hc_driver whc_hc_driver = { | |||
238 | 238 | ||
239 | static int whc_probe(struct umc_dev *umc) | 239 | static int whc_probe(struct umc_dev *umc) |
240 | { | 240 | { |
241 | int ret = -ENOMEM; | 241 | int ret; |
242 | struct usb_hcd *usb_hcd; | 242 | struct usb_hcd *usb_hcd; |
243 | struct wusbhc *wusbhc = NULL; | 243 | struct wusbhc *wusbhc; |
244 | struct whc *whc = NULL; | 244 | struct whc *whc; |
245 | struct device *dev = &umc->dev; | 245 | struct device *dev = &umc->dev; |
246 | 246 | ||
247 | usb_hcd = usb_create_hcd(&whc_hc_driver, dev, "whci"); | 247 | usb_hcd = usb_create_hcd(&whc_hc_driver, dev, "whci"); |
248 | if (usb_hcd == NULL) { | 248 | if (usb_hcd == NULL) { |
249 | dev_err(dev, "unable to create hcd\n"); | 249 | dev_err(dev, "unable to create hcd\n"); |
250 | goto error; | 250 | return -ENOMEM; |
251 | } | 251 | } |
252 | 252 | ||
253 | usb_hcd->wireless = 1; | 253 | usb_hcd->wireless = 1; |
diff --git a/drivers/usb/host/whci/qset.c b/drivers/usb/host/whci/qset.c index 76083ae92138..dc31c425ce01 100644 --- a/drivers/usb/host/whci/qset.c +++ b/drivers/usb/host/whci/qset.c | |||
@@ -436,7 +436,7 @@ static int qset_add_urb_sg(struct whc *whc, struct whc_qset *qset, struct urb *u | |||
436 | int i; | 436 | int i; |
437 | int ntds = 0; | 437 | int ntds = 0; |
438 | struct whc_std *std = NULL; | 438 | struct whc_std *std = NULL; |
439 | struct whc_page_list_entry *entry; | 439 | struct whc_page_list_entry *new_pl_virt; |
440 | dma_addr_t prev_end = 0; | 440 | dma_addr_t prev_end = 0; |
441 | size_t pl_len; | 441 | size_t pl_len; |
442 | int p = 0; | 442 | int p = 0; |
@@ -508,12 +508,15 @@ static int qset_add_urb_sg(struct whc *whc, struct whc_qset *qset, struct urb *u | |||
508 | 508 | ||
509 | pl_len = std->num_pointers * sizeof(struct whc_page_list_entry); | 509 | pl_len = std->num_pointers * sizeof(struct whc_page_list_entry); |
510 | 510 | ||
511 | std->pl_virt = krealloc(std->pl_virt, pl_len, mem_flags); | 511 | new_pl_virt = krealloc(std->pl_virt, pl_len, mem_flags); |
512 | if (std->pl_virt == NULL) { | 512 | if (new_pl_virt == NULL) { |
513 | kfree(std->pl_virt); | ||
514 | std->pl_virt = NULL; | ||
513 | return -ENOMEM; | 515 | return -ENOMEM; |
514 | } | 516 | } |
517 | std->pl_virt = new_pl_virt; | ||
515 | 518 | ||
516 | for (;p < std->num_pointers; p++, entry++) { | 519 | for (;p < std->num_pointers; p++) { |
517 | std->pl_virt[p].buf_ptr = cpu_to_le64(dma_addr); | 520 | std->pl_virt[p].buf_ptr = cpu_to_le64(dma_addr); |
518 | dma_addr = (dma_addr + WHCI_PAGE_SIZE) & ~(WHCI_PAGE_SIZE-1); | 521 | dma_addr = (dma_addr + WHCI_PAGE_SIZE) & ~(WHCI_PAGE_SIZE-1); |
519 | } | 522 | } |
diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c index d5eb357aa5c4..aa90ad4d4fd5 100644 --- a/drivers/usb/host/xhci-hub.c +++ b/drivers/usb/host/xhci-hub.c | |||
@@ -29,7 +29,7 @@ | |||
29 | #define PORT_RWC_BITS (PORT_CSC | PORT_PEC | PORT_WRC | PORT_OCC | \ | 29 | #define PORT_RWC_BITS (PORT_CSC | PORT_PEC | PORT_WRC | PORT_OCC | \ |
30 | PORT_RC | PORT_PLC | PORT_PE) | 30 | PORT_RC | PORT_PLC | PORT_PE) |
31 | 31 | ||
32 | /* usb 1.1 root hub device descriptor */ | 32 | /* USB 3.0 BOS descriptor and a capability descriptor, combined */ |
33 | static u8 usb_bos_descriptor [] = { | 33 | static u8 usb_bos_descriptor [] = { |
34 | USB_DT_BOS_SIZE, /* __u8 bLength, 5 bytes */ | 34 | USB_DT_BOS_SIZE, /* __u8 bLength, 5 bytes */ |
35 | USB_DT_BOS, /* __u8 bDescriptorType */ | 35 | USB_DT_BOS, /* __u8 bDescriptorType */ |
@@ -422,7 +422,7 @@ void xhci_set_link_state(struct xhci_hcd *xhci, __le32 __iomem **port_array, | |||
422 | xhci_writel(xhci, temp, port_array[port_id]); | 422 | xhci_writel(xhci, temp, port_array[port_id]); |
423 | } | 423 | } |
424 | 424 | ||
425 | void xhci_set_remote_wake_mask(struct xhci_hcd *xhci, | 425 | static void xhci_set_remote_wake_mask(struct xhci_hcd *xhci, |
426 | __le32 __iomem **port_array, int port_id, u16 wake_mask) | 426 | __le32 __iomem **port_array, int port_id, u16 wake_mask) |
427 | { | 427 | { |
428 | u32 temp; | 428 | u32 temp; |
@@ -808,6 +808,12 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, | |||
808 | 808 | ||
809 | temp = xhci_readl(xhci, port_array[wIndex]); | 809 | temp = xhci_readl(xhci, port_array[wIndex]); |
810 | xhci_dbg(xhci, "set port power, actual port %d status = 0x%x\n", wIndex, temp); | 810 | xhci_dbg(xhci, "set port power, actual port %d status = 0x%x\n", wIndex, temp); |
811 | |||
812 | temp = usb_acpi_power_manageable(hcd->self.root_hub, | ||
813 | wIndex); | ||
814 | if (temp) | ||
815 | usb_acpi_set_power_state(hcd->self.root_hub, | ||
816 | wIndex, true); | ||
811 | break; | 817 | break; |
812 | case USB_PORT_FEAT_RESET: | 818 | case USB_PORT_FEAT_RESET: |
813 | temp = (temp | PORT_RESET); | 819 | temp = (temp | PORT_RESET); |
@@ -907,6 +913,16 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, | |||
907 | xhci_disable_port(hcd, xhci, wIndex, | 913 | xhci_disable_port(hcd, xhci, wIndex, |
908 | port_array[wIndex], temp); | 914 | port_array[wIndex], temp); |
909 | break; | 915 | break; |
916 | case USB_PORT_FEAT_POWER: | ||
917 | xhci_writel(xhci, temp & ~PORT_POWER, | ||
918 | port_array[wIndex]); | ||
919 | |||
920 | temp = usb_acpi_power_manageable(hcd->self.root_hub, | ||
921 | wIndex); | ||
922 | if (temp) | ||
923 | usb_acpi_set_power_state(hcd->self.root_hub, | ||
924 | wIndex, false); | ||
925 | break; | ||
910 | default: | 926 | default: |
911 | goto error; | 927 | goto error; |
912 | } | 928 | } |
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index 77689bd64cac..487bc083dead 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c | |||
@@ -1772,6 +1772,7 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci) | |||
1772 | { | 1772 | { |
1773 | struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller); | 1773 | struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller); |
1774 | struct dev_info *dev_info, *next; | 1774 | struct dev_info *dev_info, *next; |
1775 | struct xhci_cd *cur_cd, *next_cd; | ||
1775 | unsigned long flags; | 1776 | unsigned long flags; |
1776 | int size; | 1777 | int size; |
1777 | int i, j, num_ports; | 1778 | int i, j, num_ports; |
@@ -1795,6 +1796,11 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci) | |||
1795 | xhci_ring_free(xhci, xhci->cmd_ring); | 1796 | xhci_ring_free(xhci, xhci->cmd_ring); |
1796 | xhci->cmd_ring = NULL; | 1797 | xhci->cmd_ring = NULL; |
1797 | xhci_dbg(xhci, "Freed command ring\n"); | 1798 | xhci_dbg(xhci, "Freed command ring\n"); |
1799 | list_for_each_entry_safe(cur_cd, next_cd, | ||
1800 | &xhci->cancel_cmd_list, cancel_cmd_list) { | ||
1801 | list_del(&cur_cd->cancel_cmd_list); | ||
1802 | kfree(cur_cd); | ||
1803 | } | ||
1798 | 1804 | ||
1799 | for (i = 1; i < MAX_HC_SLOTS; ++i) | 1805 | for (i = 1; i < MAX_HC_SLOTS; ++i) |
1800 | xhci_free_virt_device(xhci, i); | 1806 | xhci_free_virt_device(xhci, i); |
@@ -2340,6 +2346,7 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags) | |||
2340 | xhci->cmd_ring = xhci_ring_alloc(xhci, 1, 1, TYPE_COMMAND, flags); | 2346 | xhci->cmd_ring = xhci_ring_alloc(xhci, 1, 1, TYPE_COMMAND, flags); |
2341 | if (!xhci->cmd_ring) | 2347 | if (!xhci->cmd_ring) |
2342 | goto fail; | 2348 | goto fail; |
2349 | INIT_LIST_HEAD(&xhci->cancel_cmd_list); | ||
2343 | xhci_dbg(xhci, "Allocated command ring at %p\n", xhci->cmd_ring); | 2350 | xhci_dbg(xhci, "Allocated command ring at %p\n", xhci->cmd_ring); |
2344 | xhci_dbg(xhci, "First segment DMA is 0x%llx\n", | 2351 | xhci_dbg(xhci, "First segment DMA is 0x%llx\n", |
2345 | (unsigned long long)xhci->cmd_ring->first_seg->dma); | 2352 | (unsigned long long)xhci->cmd_ring->first_seg->dma); |
diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c index 9bfd4ca1153c..8345d7c23061 100644 --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c | |||
@@ -103,6 +103,7 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci) | |||
103 | * PPT chipsets. | 103 | * PPT chipsets. |
104 | */ | 104 | */ |
105 | xhci->quirks |= XHCI_SPURIOUS_REBOOT; | 105 | xhci->quirks |= XHCI_SPURIOUS_REBOOT; |
106 | xhci->quirks |= XHCI_AVOID_BEI; | ||
106 | } | 107 | } |
107 | if (pdev->vendor == PCI_VENDOR_ID_ETRON && | 108 | if (pdev->vendor == PCI_VENDOR_ID_ETRON && |
108 | pdev->device == PCI_DEVICE_ID_ASROCK_P67) { | 109 | pdev->device == PCI_DEVICE_ID_ASROCK_P67) { |
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 643c2f3f3e73..c6ebb176dc4f 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c | |||
@@ -280,12 +280,123 @@ static inline int room_on_ring(struct xhci_hcd *xhci, struct xhci_ring *ring, | |||
280 | /* Ring the host controller doorbell after placing a command on the ring */ | 280 | /* Ring the host controller doorbell after placing a command on the ring */ |
281 | void xhci_ring_cmd_db(struct xhci_hcd *xhci) | 281 | void xhci_ring_cmd_db(struct xhci_hcd *xhci) |
282 | { | 282 | { |
283 | if (!(xhci->cmd_ring_state & CMD_RING_STATE_RUNNING)) | ||
284 | return; | ||
285 | |||
283 | xhci_dbg(xhci, "// Ding dong!\n"); | 286 | xhci_dbg(xhci, "// Ding dong!\n"); |
284 | xhci_writel(xhci, DB_VALUE_HOST, &xhci->dba->doorbell[0]); | 287 | xhci_writel(xhci, DB_VALUE_HOST, &xhci->dba->doorbell[0]); |
285 | /* Flush PCI posted writes */ | 288 | /* Flush PCI posted writes */ |
286 | xhci_readl(xhci, &xhci->dba->doorbell[0]); | 289 | xhci_readl(xhci, &xhci->dba->doorbell[0]); |
287 | } | 290 | } |
288 | 291 | ||
292 | static int xhci_abort_cmd_ring(struct xhci_hcd *xhci) | ||
293 | { | ||
294 | u64 temp_64; | ||
295 | int ret; | ||
296 | |||
297 | xhci_dbg(xhci, "Abort command ring\n"); | ||
298 | |||
299 | if (!(xhci->cmd_ring_state & CMD_RING_STATE_RUNNING)) { | ||
300 | xhci_dbg(xhci, "The command ring isn't running, " | ||
301 | "Have the command ring been stopped?\n"); | ||
302 | return 0; | ||
303 | } | ||
304 | |||
305 | temp_64 = xhci_read_64(xhci, &xhci->op_regs->cmd_ring); | ||
306 | if (!(temp_64 & CMD_RING_RUNNING)) { | ||
307 | xhci_dbg(xhci, "Command ring had been stopped\n"); | ||
308 | return 0; | ||
309 | } | ||
310 | xhci->cmd_ring_state = CMD_RING_STATE_ABORTED; | ||
311 | xhci_write_64(xhci, temp_64 | CMD_RING_ABORT, | ||
312 | &xhci->op_regs->cmd_ring); | ||
313 | |||
314 | /* Section 4.6.1.2 of xHCI 1.0 spec says software should | ||
315 | * time the completion od all xHCI commands, including | ||
316 | * the Command Abort operation. If software doesn't see | ||
317 | * CRR negated in a timely manner (e.g. longer than 5 | ||
318 | * seconds), then it should assume that the there are | ||
319 | * larger problems with the xHC and assert HCRST. | ||
320 | */ | ||
321 | ret = handshake(xhci, &xhci->op_regs->cmd_ring, | ||
322 | CMD_RING_RUNNING, 0, 5 * 1000 * 1000); | ||
323 | if (ret < 0) { | ||
324 | xhci_err(xhci, "Stopped the command ring failed, " | ||
325 | "maybe the host is dead\n"); | ||
326 | xhci->xhc_state |= XHCI_STATE_DYING; | ||
327 | xhci_quiesce(xhci); | ||
328 | xhci_halt(xhci); | ||
329 | return -ESHUTDOWN; | ||
330 | } | ||
331 | |||
332 | return 0; | ||
333 | } | ||
334 | |||
335 | static int xhci_queue_cd(struct xhci_hcd *xhci, | ||
336 | struct xhci_command *command, | ||
337 | union xhci_trb *cmd_trb) | ||
338 | { | ||
339 | struct xhci_cd *cd; | ||
340 | cd = kzalloc(sizeof(struct xhci_cd), GFP_ATOMIC); | ||
341 | if (!cd) | ||
342 | return -ENOMEM; | ||
343 | INIT_LIST_HEAD(&cd->cancel_cmd_list); | ||
344 | |||
345 | cd->command = command; | ||
346 | cd->cmd_trb = cmd_trb; | ||
347 | list_add_tail(&cd->cancel_cmd_list, &xhci->cancel_cmd_list); | ||
348 | |||
349 | return 0; | ||
350 | } | ||
351 | |||
352 | /* | ||
353 | * Cancel the command which has issue. | ||
354 | * | ||
355 | * Some commands may hang due to waiting for acknowledgement from | ||
356 | * usb device. It is outside of the xHC's ability to control and | ||
357 | * will cause the command ring is blocked. When it occurs software | ||
358 | * should intervene to recover the command ring. | ||
359 | * See Section 4.6.1.1 and 4.6.1.2 | ||
360 | */ | ||
361 | int xhci_cancel_cmd(struct xhci_hcd *xhci, struct xhci_command *command, | ||
362 | union xhci_trb *cmd_trb) | ||
363 | { | ||
364 | int retval = 0; | ||
365 | unsigned long flags; | ||
366 | |||
367 | spin_lock_irqsave(&xhci->lock, flags); | ||
368 | |||
369 | if (xhci->xhc_state & XHCI_STATE_DYING) { | ||
370 | xhci_warn(xhci, "Abort the command ring," | ||
371 | " but the xHCI is dead.\n"); | ||
372 | retval = -ESHUTDOWN; | ||
373 | goto fail; | ||
374 | } | ||
375 | |||
376 | /* queue the cmd desriptor to cancel_cmd_list */ | ||
377 | retval = xhci_queue_cd(xhci, command, cmd_trb); | ||
378 | if (retval) { | ||
379 | xhci_warn(xhci, "Queuing command descriptor failed.\n"); | ||
380 | goto fail; | ||
381 | } | ||
382 | |||
383 | /* abort command ring */ | ||
384 | retval = xhci_abort_cmd_ring(xhci); | ||
385 | if (retval) { | ||
386 | xhci_err(xhci, "Abort command ring failed\n"); | ||
387 | if (unlikely(retval == -ESHUTDOWN)) { | ||
388 | spin_unlock_irqrestore(&xhci->lock, flags); | ||
389 | usb_hc_died(xhci_to_hcd(xhci)->primary_hcd); | ||
390 | xhci_dbg(xhci, "xHCI host controller is dead.\n"); | ||
391 | return retval; | ||
392 | } | ||
393 | } | ||
394 | |||
395 | fail: | ||
396 | spin_unlock_irqrestore(&xhci->lock, flags); | ||
397 | return retval; | ||
398 | } | ||
399 | |||
289 | void xhci_ring_ep_doorbell(struct xhci_hcd *xhci, | 400 | void xhci_ring_ep_doorbell(struct xhci_hcd *xhci, |
290 | unsigned int slot_id, | 401 | unsigned int slot_id, |
291 | unsigned int ep_index, | 402 | unsigned int ep_index, |
@@ -1059,6 +1170,20 @@ static void handle_reset_ep_completion(struct xhci_hcd *xhci, | |||
1059 | } | 1170 | } |
1060 | } | 1171 | } |
1061 | 1172 | ||
1173 | /* Complete the command and detele it from the devcie's command queue. | ||
1174 | */ | ||
1175 | static void xhci_complete_cmd_in_cmd_wait_list(struct xhci_hcd *xhci, | ||
1176 | struct xhci_command *command, u32 status) | ||
1177 | { | ||
1178 | command->status = status; | ||
1179 | list_del(&command->cmd_list); | ||
1180 | if (command->completion) | ||
1181 | complete(command->completion); | ||
1182 | else | ||
1183 | xhci_free_command(xhci, command); | ||
1184 | } | ||
1185 | |||
1186 | |||
1062 | /* Check to see if a command in the device's command queue matches this one. | 1187 | /* Check to see if a command in the device's command queue matches this one. |
1063 | * Signal the completion or free the command, and return 1. Return 0 if the | 1188 | * Signal the completion or free the command, and return 1. Return 0 if the |
1064 | * completed command isn't at the head of the command list. | 1189 | * completed command isn't at the head of the command list. |
@@ -1077,15 +1202,144 @@ static int handle_cmd_in_cmd_wait_list(struct xhci_hcd *xhci, | |||
1077 | if (xhci->cmd_ring->dequeue != command->command_trb) | 1202 | if (xhci->cmd_ring->dequeue != command->command_trb) |
1078 | return 0; | 1203 | return 0; |
1079 | 1204 | ||
1080 | command->status = GET_COMP_CODE(le32_to_cpu(event->status)); | 1205 | xhci_complete_cmd_in_cmd_wait_list(xhci, command, |
1081 | list_del(&command->cmd_list); | 1206 | GET_COMP_CODE(le32_to_cpu(event->status))); |
1082 | if (command->completion) | ||
1083 | complete(command->completion); | ||
1084 | else | ||
1085 | xhci_free_command(xhci, command); | ||
1086 | return 1; | 1207 | return 1; |
1087 | } | 1208 | } |
1088 | 1209 | ||
1210 | /* | ||
1211 | * Finding the command trb need to be cancelled and modifying it to | ||
1212 | * NO OP command. And if the command is in device's command wait | ||
1213 | * list, finishing and freeing it. | ||
1214 | * | ||
1215 | * If we can't find the command trb, we think it had already been | ||
1216 | * executed. | ||
1217 | */ | ||
1218 | static void xhci_cmd_to_noop(struct xhci_hcd *xhci, struct xhci_cd *cur_cd) | ||
1219 | { | ||
1220 | struct xhci_segment *cur_seg; | ||
1221 | union xhci_trb *cmd_trb; | ||
1222 | u32 cycle_state; | ||
1223 | |||
1224 | if (xhci->cmd_ring->dequeue == xhci->cmd_ring->enqueue) | ||
1225 | return; | ||
1226 | |||
1227 | /* find the current segment of command ring */ | ||
1228 | cur_seg = find_trb_seg(xhci->cmd_ring->first_seg, | ||
1229 | xhci->cmd_ring->dequeue, &cycle_state); | ||
1230 | |||
1231 | /* find the command trb matched by cd from command ring */ | ||
1232 | for (cmd_trb = xhci->cmd_ring->dequeue; | ||
1233 | cmd_trb != xhci->cmd_ring->enqueue; | ||
1234 | next_trb(xhci, xhci->cmd_ring, &cur_seg, &cmd_trb)) { | ||
1235 | /* If the trb is link trb, continue */ | ||
1236 | if (TRB_TYPE_LINK_LE32(cmd_trb->generic.field[3])) | ||
1237 | continue; | ||
1238 | |||
1239 | if (cur_cd->cmd_trb == cmd_trb) { | ||
1240 | |||
1241 | /* If the command in device's command list, we should | ||
1242 | * finish it and free the command structure. | ||
1243 | */ | ||
1244 | if (cur_cd->command) | ||
1245 | xhci_complete_cmd_in_cmd_wait_list(xhci, | ||
1246 | cur_cd->command, COMP_CMD_STOP); | ||
1247 | |||
1248 | /* get cycle state from the origin command trb */ | ||
1249 | cycle_state = le32_to_cpu(cmd_trb->generic.field[3]) | ||
1250 | & TRB_CYCLE; | ||
1251 | |||
1252 | /* modify the command trb to NO OP command */ | ||
1253 | cmd_trb->generic.field[0] = 0; | ||
1254 | cmd_trb->generic.field[1] = 0; | ||
1255 | cmd_trb->generic.field[2] = 0; | ||
1256 | cmd_trb->generic.field[3] = cpu_to_le32( | ||
1257 | TRB_TYPE(TRB_CMD_NOOP) | cycle_state); | ||
1258 | break; | ||
1259 | } | ||
1260 | } | ||
1261 | } | ||
1262 | |||
1263 | static void xhci_cancel_cmd_in_cd_list(struct xhci_hcd *xhci) | ||
1264 | { | ||
1265 | struct xhci_cd *cur_cd, *next_cd; | ||
1266 | |||
1267 | if (list_empty(&xhci->cancel_cmd_list)) | ||
1268 | return; | ||
1269 | |||
1270 | list_for_each_entry_safe(cur_cd, next_cd, | ||
1271 | &xhci->cancel_cmd_list, cancel_cmd_list) { | ||
1272 | xhci_cmd_to_noop(xhci, cur_cd); | ||
1273 | list_del(&cur_cd->cancel_cmd_list); | ||
1274 | kfree(cur_cd); | ||
1275 | } | ||
1276 | } | ||
1277 | |||
1278 | /* | ||
1279 | * traversing the cancel_cmd_list. If the command descriptor according | ||
1280 | * to cmd_trb is found, the function free it and return 1, otherwise | ||
1281 | * return 0. | ||
1282 | */ | ||
1283 | static int xhci_search_cmd_trb_in_cd_list(struct xhci_hcd *xhci, | ||
1284 | union xhci_trb *cmd_trb) | ||
1285 | { | ||
1286 | struct xhci_cd *cur_cd, *next_cd; | ||
1287 | |||
1288 | if (list_empty(&xhci->cancel_cmd_list)) | ||
1289 | return 0; | ||
1290 | |||
1291 | list_for_each_entry_safe(cur_cd, next_cd, | ||
1292 | &xhci->cancel_cmd_list, cancel_cmd_list) { | ||
1293 | if (cur_cd->cmd_trb == cmd_trb) { | ||
1294 | if (cur_cd->command) | ||
1295 | xhci_complete_cmd_in_cmd_wait_list(xhci, | ||
1296 | cur_cd->command, COMP_CMD_STOP); | ||
1297 | list_del(&cur_cd->cancel_cmd_list); | ||
1298 | kfree(cur_cd); | ||
1299 | return 1; | ||
1300 | } | ||
1301 | } | ||
1302 | |||
1303 | return 0; | ||
1304 | } | ||
1305 | |||
1306 | /* | ||
1307 | * If the cmd_trb_comp_code is COMP_CMD_ABORT, we just check whether the | ||
1308 | * trb pointed by the command ring dequeue pointer is the trb we want to | ||
1309 | * cancel or not. And if the cmd_trb_comp_code is COMP_CMD_STOP, we will | ||
1310 | * traverse the cancel_cmd_list to trun the all of the commands according | ||
1311 | * to command descriptor to NO-OP trb. | ||
1312 | */ | ||
1313 | static int handle_stopped_cmd_ring(struct xhci_hcd *xhci, | ||
1314 | int cmd_trb_comp_code) | ||
1315 | { | ||
1316 | int cur_trb_is_good = 0; | ||
1317 | |||
1318 | /* Searching the cmd trb pointed by the command ring dequeue | ||
1319 | * pointer in command descriptor list. If it is found, free it. | ||
1320 | */ | ||
1321 | cur_trb_is_good = xhci_search_cmd_trb_in_cd_list(xhci, | ||
1322 | xhci->cmd_ring->dequeue); | ||
1323 | |||
1324 | if (cmd_trb_comp_code == COMP_CMD_ABORT) | ||
1325 | xhci->cmd_ring_state = CMD_RING_STATE_STOPPED; | ||
1326 | else if (cmd_trb_comp_code == COMP_CMD_STOP) { | ||
1327 | /* traversing the cancel_cmd_list and canceling | ||
1328 | * the command according to command descriptor | ||
1329 | */ | ||
1330 | xhci_cancel_cmd_in_cd_list(xhci); | ||
1331 | |||
1332 | xhci->cmd_ring_state = CMD_RING_STATE_RUNNING; | ||
1333 | /* | ||
1334 | * ring command ring doorbell again to restart the | ||
1335 | * command ring | ||
1336 | */ | ||
1337 | if (xhci->cmd_ring->dequeue != xhci->cmd_ring->enqueue) | ||
1338 | xhci_ring_cmd_db(xhci); | ||
1339 | } | ||
1340 | return cur_trb_is_good; | ||
1341 | } | ||
1342 | |||
1089 | static void handle_cmd_completion(struct xhci_hcd *xhci, | 1343 | static void handle_cmd_completion(struct xhci_hcd *xhci, |
1090 | struct xhci_event_cmd *event) | 1344 | struct xhci_event_cmd *event) |
1091 | { | 1345 | { |
@@ -1111,6 +1365,22 @@ static void handle_cmd_completion(struct xhci_hcd *xhci, | |||
1111 | xhci->error_bitmask |= 1 << 5; | 1365 | xhci->error_bitmask |= 1 << 5; |
1112 | return; | 1366 | return; |
1113 | } | 1367 | } |
1368 | |||
1369 | if ((GET_COMP_CODE(le32_to_cpu(event->status)) == COMP_CMD_ABORT) || | ||
1370 | (GET_COMP_CODE(le32_to_cpu(event->status)) == COMP_CMD_STOP)) { | ||
1371 | /* If the return value is 0, we think the trb pointed by | ||
1372 | * command ring dequeue pointer is a good trb. The good | ||
1373 | * trb means we don't want to cancel the trb, but it have | ||
1374 | * been stopped by host. So we should handle it normally. | ||
1375 | * Otherwise, driver should invoke inc_deq() and return. | ||
1376 | */ | ||
1377 | if (handle_stopped_cmd_ring(xhci, | ||
1378 | GET_COMP_CODE(le32_to_cpu(event->status)))) { | ||
1379 | inc_deq(xhci, xhci->cmd_ring); | ||
1380 | return; | ||
1381 | } | ||
1382 | } | ||
1383 | |||
1114 | switch (le32_to_cpu(xhci->cmd_ring->dequeue->generic.field[3]) | 1384 | switch (le32_to_cpu(xhci->cmd_ring->dequeue->generic.field[3]) |
1115 | & TRB_TYPE_BITMASK) { | 1385 | & TRB_TYPE_BITMASK) { |
1116 | case TRB_TYPE(TRB_ENABLE_SLOT): | 1386 | case TRB_TYPE(TRB_ENABLE_SLOT): |
@@ -2003,6 +2273,8 @@ static int process_bulk_intr_td(struct xhci_hcd *xhci, struct xhci_td *td, | |||
2003 | */ | 2273 | */ |
2004 | static int handle_tx_event(struct xhci_hcd *xhci, | 2274 | static int handle_tx_event(struct xhci_hcd *xhci, |
2005 | struct xhci_transfer_event *event) | 2275 | struct xhci_transfer_event *event) |
2276 | __releases(&xhci->lock) | ||
2277 | __acquires(&xhci->lock) | ||
2006 | { | 2278 | { |
2007 | struct xhci_virt_device *xdev; | 2279 | struct xhci_virt_device *xdev; |
2008 | struct xhci_virt_ep *ep; | 2280 | struct xhci_virt_ep *ep; |
@@ -2580,7 +2852,7 @@ static int prepare_ring(struct xhci_hcd *xhci, struct xhci_ring *ep_ring, | |||
2580 | xhci_err(xhci, "Ring expansion failed\n"); | 2852 | xhci_err(xhci, "Ring expansion failed\n"); |
2581 | return -ENOMEM; | 2853 | return -ENOMEM; |
2582 | } | 2854 | } |
2583 | }; | 2855 | } |
2584 | 2856 | ||
2585 | if (enqueue_is_link_trb(ep_ring)) { | 2857 | if (enqueue_is_link_trb(ep_ring)) { |
2586 | struct xhci_ring *ring = ep_ring; | 2858 | struct xhci_ring *ring = ep_ring; |
@@ -3400,7 +3672,9 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
3400 | } else { | 3672 | } else { |
3401 | td->last_trb = ep_ring->enqueue; | 3673 | td->last_trb = ep_ring->enqueue; |
3402 | field |= TRB_IOC; | 3674 | field |= TRB_IOC; |
3403 | if (xhci->hci_version == 0x100) { | 3675 | if (xhci->hci_version == 0x100 && |
3676 | !(xhci->quirks & | ||
3677 | XHCI_AVOID_BEI)) { | ||
3404 | /* Set BEI bit except for the last td */ | 3678 | /* Set BEI bit except for the last td */ |
3405 | if (i < num_tds - 1) | 3679 | if (i < num_tds - 1) |
3406 | field |= TRB_BEI; | 3680 | field |= TRB_BEI; |
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 6ece0ed288d4..8d7fcbbe6ade 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c | |||
@@ -52,7 +52,7 @@ MODULE_PARM_DESC(link_quirk, "Don't clear the chain bit on a link TRB"); | |||
52 | * handshake done). There are two failure modes: "usec" have passed (major | 52 | * handshake done). There are two failure modes: "usec" have passed (major |
53 | * hardware flakeout), or the register reads as all-ones (hardware removed). | 53 | * hardware flakeout), or the register reads as all-ones (hardware removed). |
54 | */ | 54 | */ |
55 | static int handshake(struct xhci_hcd *xhci, void __iomem *ptr, | 55 | int handshake(struct xhci_hcd *xhci, void __iomem *ptr, |
56 | u32 mask, u32 done, int usec) | 56 | u32 mask, u32 done, int usec) |
57 | { | 57 | { |
58 | u32 result; | 58 | u32 result; |
@@ -105,9 +105,10 @@ int xhci_halt(struct xhci_hcd *xhci) | |||
105 | 105 | ||
106 | ret = handshake(xhci, &xhci->op_regs->status, | 106 | ret = handshake(xhci, &xhci->op_regs->status, |
107 | STS_HALT, STS_HALT, XHCI_MAX_HALT_USEC); | 107 | STS_HALT, STS_HALT, XHCI_MAX_HALT_USEC); |
108 | if (!ret) | 108 | if (!ret) { |
109 | xhci->xhc_state |= XHCI_STATE_HALTED; | 109 | xhci->xhc_state |= XHCI_STATE_HALTED; |
110 | else | 110 | xhci->cmd_ring_state = CMD_RING_STATE_STOPPED; |
111 | } else | ||
111 | xhci_warn(xhci, "Host not halted after %u microseconds.\n", | 112 | xhci_warn(xhci, "Host not halted after %u microseconds.\n", |
112 | XHCI_MAX_HALT_USEC); | 113 | XHCI_MAX_HALT_USEC); |
113 | return ret; | 114 | return ret; |
@@ -470,6 +471,8 @@ static bool compliance_mode_recovery_timer_quirk_check(void) | |||
470 | 471 | ||
471 | dmi_product_name = dmi_get_system_info(DMI_PRODUCT_NAME); | 472 | dmi_product_name = dmi_get_system_info(DMI_PRODUCT_NAME); |
472 | dmi_sys_vendor = dmi_get_system_info(DMI_SYS_VENDOR); | 473 | dmi_sys_vendor = dmi_get_system_info(DMI_SYS_VENDOR); |
474 | if (!dmi_product_name || !dmi_sys_vendor) | ||
475 | return false; | ||
473 | 476 | ||
474 | if (!(strstr(dmi_sys_vendor, "Hewlett-Packard"))) | 477 | if (!(strstr(dmi_sys_vendor, "Hewlett-Packard"))) |
475 | return false; | 478 | return false; |
@@ -581,6 +584,7 @@ static int xhci_run_finished(struct xhci_hcd *xhci) | |||
581 | return -ENODEV; | 584 | return -ENODEV; |
582 | } | 585 | } |
583 | xhci->shared_hcd->state = HC_STATE_RUNNING; | 586 | xhci->shared_hcd->state = HC_STATE_RUNNING; |
587 | xhci->cmd_ring_state = CMD_RING_STATE_RUNNING; | ||
584 | 588 | ||
585 | if (xhci->quirks & XHCI_NEC_HOST) | 589 | if (xhci->quirks & XHCI_NEC_HOST) |
586 | xhci_ring_cmd_db(xhci); | 590 | xhci_ring_cmd_db(xhci); |
@@ -886,7 +890,7 @@ int xhci_suspend(struct xhci_hcd *xhci) | |||
886 | command &= ~CMD_RUN; | 890 | command &= ~CMD_RUN; |
887 | xhci_writel(xhci, command, &xhci->op_regs->command); | 891 | xhci_writel(xhci, command, &xhci->op_regs->command); |
888 | if (handshake(xhci, &xhci->op_regs->status, | 892 | if (handshake(xhci, &xhci->op_regs->status, |
889 | STS_HALT, STS_HALT, 100*100)) { | 893 | STS_HALT, STS_HALT, XHCI_MAX_HALT_USEC)) { |
890 | xhci_warn(xhci, "WARN: xHC CMD_RUN timeout\n"); | 894 | xhci_warn(xhci, "WARN: xHC CMD_RUN timeout\n"); |
891 | spin_unlock_irq(&xhci->lock); | 895 | spin_unlock_irq(&xhci->lock); |
892 | return -ETIMEDOUT; | 896 | return -ETIMEDOUT; |
@@ -1948,7 +1952,7 @@ static void xhci_finish_resource_reservation(struct xhci_hcd *xhci, | |||
1948 | xhci->num_active_eps); | 1952 | xhci->num_active_eps); |
1949 | } | 1953 | } |
1950 | 1954 | ||
1951 | unsigned int xhci_get_block_size(struct usb_device *udev) | 1955 | static unsigned int xhci_get_block_size(struct usb_device *udev) |
1952 | { | 1956 | { |
1953 | switch (udev->speed) { | 1957 | switch (udev->speed) { |
1954 | case USB_SPEED_LOW: | 1958 | case USB_SPEED_LOW: |
@@ -1966,7 +1970,8 @@ unsigned int xhci_get_block_size(struct usb_device *udev) | |||
1966 | } | 1970 | } |
1967 | } | 1971 | } |
1968 | 1972 | ||
1969 | unsigned int xhci_get_largest_overhead(struct xhci_interval_bw *interval_bw) | 1973 | static unsigned int |
1974 | xhci_get_largest_overhead(struct xhci_interval_bw *interval_bw) | ||
1970 | { | 1975 | { |
1971 | if (interval_bw->overhead[LS_OVERHEAD_TYPE]) | 1976 | if (interval_bw->overhead[LS_OVERHEAD_TYPE]) |
1972 | return LS_OVERHEAD; | 1977 | return LS_OVERHEAD; |
@@ -2521,6 +2526,7 @@ static int xhci_configure_endpoint(struct xhci_hcd *xhci, | |||
2521 | struct completion *cmd_completion; | 2526 | struct completion *cmd_completion; |
2522 | u32 *cmd_status; | 2527 | u32 *cmd_status; |
2523 | struct xhci_virt_device *virt_dev; | 2528 | struct xhci_virt_device *virt_dev; |
2529 | union xhci_trb *cmd_trb; | ||
2524 | 2530 | ||
2525 | spin_lock_irqsave(&xhci->lock, flags); | 2531 | spin_lock_irqsave(&xhci->lock, flags); |
2526 | virt_dev = xhci->devs[udev->slot_id]; | 2532 | virt_dev = xhci->devs[udev->slot_id]; |
@@ -2566,6 +2572,7 @@ static int xhci_configure_endpoint(struct xhci_hcd *xhci, | |||
2566 | } | 2572 | } |
2567 | init_completion(cmd_completion); | 2573 | init_completion(cmd_completion); |
2568 | 2574 | ||
2575 | cmd_trb = xhci->cmd_ring->dequeue; | ||
2569 | if (!ctx_change) | 2576 | if (!ctx_change) |
2570 | ret = xhci_queue_configure_endpoint(xhci, in_ctx->dma, | 2577 | ret = xhci_queue_configure_endpoint(xhci, in_ctx->dma, |
2571 | udev->slot_id, must_succeed); | 2578 | udev->slot_id, must_succeed); |
@@ -2587,14 +2594,17 @@ static int xhci_configure_endpoint(struct xhci_hcd *xhci, | |||
2587 | /* Wait for the configure endpoint command to complete */ | 2594 | /* Wait for the configure endpoint command to complete */ |
2588 | timeleft = wait_for_completion_interruptible_timeout( | 2595 | timeleft = wait_for_completion_interruptible_timeout( |
2589 | cmd_completion, | 2596 | cmd_completion, |
2590 | USB_CTRL_SET_TIMEOUT); | 2597 | XHCI_CMD_DEFAULT_TIMEOUT); |
2591 | if (timeleft <= 0) { | 2598 | if (timeleft <= 0) { |
2592 | xhci_warn(xhci, "%s while waiting for %s command\n", | 2599 | xhci_warn(xhci, "%s while waiting for %s command\n", |
2593 | timeleft == 0 ? "Timeout" : "Signal", | 2600 | timeleft == 0 ? "Timeout" : "Signal", |
2594 | ctx_change == 0 ? | 2601 | ctx_change == 0 ? |
2595 | "configure endpoint" : | 2602 | "configure endpoint" : |
2596 | "evaluate context"); | 2603 | "evaluate context"); |
2597 | /* FIXME cancel the configure endpoint command */ | 2604 | /* cancel the configure endpoint command */ |
2605 | ret = xhci_cancel_cmd(xhci, command, cmd_trb); | ||
2606 | if (ret < 0) | ||
2607 | return ret; | ||
2598 | return -ETIME; | 2608 | return -ETIME; |
2599 | } | 2609 | } |
2600 | 2610 | ||
@@ -3543,8 +3553,10 @@ int xhci_alloc_dev(struct usb_hcd *hcd, struct usb_device *udev) | |||
3543 | unsigned long flags; | 3553 | unsigned long flags; |
3544 | int timeleft; | 3554 | int timeleft; |
3545 | int ret; | 3555 | int ret; |
3556 | union xhci_trb *cmd_trb; | ||
3546 | 3557 | ||
3547 | spin_lock_irqsave(&xhci->lock, flags); | 3558 | spin_lock_irqsave(&xhci->lock, flags); |
3559 | cmd_trb = xhci->cmd_ring->dequeue; | ||
3548 | ret = xhci_queue_slot_control(xhci, TRB_ENABLE_SLOT, 0); | 3560 | ret = xhci_queue_slot_control(xhci, TRB_ENABLE_SLOT, 0); |
3549 | if (ret) { | 3561 | if (ret) { |
3550 | spin_unlock_irqrestore(&xhci->lock, flags); | 3562 | spin_unlock_irqrestore(&xhci->lock, flags); |
@@ -3556,12 +3568,12 @@ int xhci_alloc_dev(struct usb_hcd *hcd, struct usb_device *udev) | |||
3556 | 3568 | ||
3557 | /* XXX: how much time for xHC slot assignment? */ | 3569 | /* XXX: how much time for xHC slot assignment? */ |
3558 | timeleft = wait_for_completion_interruptible_timeout(&xhci->addr_dev, | 3570 | timeleft = wait_for_completion_interruptible_timeout(&xhci->addr_dev, |
3559 | USB_CTRL_SET_TIMEOUT); | 3571 | XHCI_CMD_DEFAULT_TIMEOUT); |
3560 | if (timeleft <= 0) { | 3572 | if (timeleft <= 0) { |
3561 | xhci_warn(xhci, "%s while waiting for a slot\n", | 3573 | xhci_warn(xhci, "%s while waiting for a slot\n", |
3562 | timeleft == 0 ? "Timeout" : "Signal"); | 3574 | timeleft == 0 ? "Timeout" : "Signal"); |
3563 | /* FIXME cancel the enable slot request */ | 3575 | /* cancel the enable slot request */ |
3564 | return 0; | 3576 | return xhci_cancel_cmd(xhci, NULL, cmd_trb); |
3565 | } | 3577 | } |
3566 | 3578 | ||
3567 | if (!xhci->slot_id) { | 3579 | if (!xhci->slot_id) { |
@@ -3622,6 +3634,7 @@ int xhci_address_device(struct usb_hcd *hcd, struct usb_device *udev) | |||
3622 | struct xhci_slot_ctx *slot_ctx; | 3634 | struct xhci_slot_ctx *slot_ctx; |
3623 | struct xhci_input_control_ctx *ctrl_ctx; | 3635 | struct xhci_input_control_ctx *ctrl_ctx; |
3624 | u64 temp_64; | 3636 | u64 temp_64; |
3637 | union xhci_trb *cmd_trb; | ||
3625 | 3638 | ||
3626 | if (!udev->slot_id) { | 3639 | if (!udev->slot_id) { |
3627 | xhci_dbg(xhci, "Bad Slot ID %d\n", udev->slot_id); | 3640 | xhci_dbg(xhci, "Bad Slot ID %d\n", udev->slot_id); |
@@ -3660,6 +3673,7 @@ int xhci_address_device(struct usb_hcd *hcd, struct usb_device *udev) | |||
3660 | xhci_dbg_ctx(xhci, virt_dev->in_ctx, 2); | 3673 | xhci_dbg_ctx(xhci, virt_dev->in_ctx, 2); |
3661 | 3674 | ||
3662 | spin_lock_irqsave(&xhci->lock, flags); | 3675 | spin_lock_irqsave(&xhci->lock, flags); |
3676 | cmd_trb = xhci->cmd_ring->dequeue; | ||
3663 | ret = xhci_queue_address_device(xhci, virt_dev->in_ctx->dma, | 3677 | ret = xhci_queue_address_device(xhci, virt_dev->in_ctx->dma, |
3664 | udev->slot_id); | 3678 | udev->slot_id); |
3665 | if (ret) { | 3679 | if (ret) { |
@@ -3672,7 +3686,7 @@ int xhci_address_device(struct usb_hcd *hcd, struct usb_device *udev) | |||
3672 | 3686 | ||
3673 | /* ctrl tx can take up to 5 sec; XXX: need more time for xHC? */ | 3687 | /* ctrl tx can take up to 5 sec; XXX: need more time for xHC? */ |
3674 | timeleft = wait_for_completion_interruptible_timeout(&xhci->addr_dev, | 3688 | timeleft = wait_for_completion_interruptible_timeout(&xhci->addr_dev, |
3675 | USB_CTRL_SET_TIMEOUT); | 3689 | XHCI_CMD_DEFAULT_TIMEOUT); |
3676 | /* FIXME: From section 4.3.4: "Software shall be responsible for timing | 3690 | /* FIXME: From section 4.3.4: "Software shall be responsible for timing |
3677 | * the SetAddress() "recovery interval" required by USB and aborting the | 3691 | * the SetAddress() "recovery interval" required by USB and aborting the |
3678 | * command on a timeout. | 3692 | * command on a timeout. |
@@ -3680,7 +3694,10 @@ int xhci_address_device(struct usb_hcd *hcd, struct usb_device *udev) | |||
3680 | if (timeleft <= 0) { | 3694 | if (timeleft <= 0) { |
3681 | xhci_warn(xhci, "%s while waiting for address device command\n", | 3695 | xhci_warn(xhci, "%s while waiting for address device command\n", |
3682 | timeleft == 0 ? "Timeout" : "Signal"); | 3696 | timeleft == 0 ? "Timeout" : "Signal"); |
3683 | /* FIXME cancel the address device command */ | 3697 | /* cancel the address device command */ |
3698 | ret = xhci_cancel_cmd(xhci, NULL, cmd_trb); | ||
3699 | if (ret < 0) | ||
3700 | return ret; | ||
3684 | return -ETIME; | 3701 | return -ETIME; |
3685 | } | 3702 | } |
3686 | 3703 | ||
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 1a05908c6673..53df4e70ca07 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h | |||
@@ -1256,6 +1256,16 @@ struct xhci_td { | |||
1256 | union xhci_trb *last_trb; | 1256 | union xhci_trb *last_trb; |
1257 | }; | 1257 | }; |
1258 | 1258 | ||
1259 | /* xHCI command default timeout value */ | ||
1260 | #define XHCI_CMD_DEFAULT_TIMEOUT (5 * HZ) | ||
1261 | |||
1262 | /* command descriptor */ | ||
1263 | struct xhci_cd { | ||
1264 | struct list_head cancel_cmd_list; | ||
1265 | struct xhci_command *command; | ||
1266 | union xhci_trb *cmd_trb; | ||
1267 | }; | ||
1268 | |||
1259 | struct xhci_dequeue_state { | 1269 | struct xhci_dequeue_state { |
1260 | struct xhci_segment *new_deq_seg; | 1270 | struct xhci_segment *new_deq_seg; |
1261 | union xhci_trb *new_deq_ptr; | 1271 | union xhci_trb *new_deq_ptr; |
@@ -1421,6 +1431,11 @@ struct xhci_hcd { | |||
1421 | /* data structures */ | 1431 | /* data structures */ |
1422 | struct xhci_device_context_array *dcbaa; | 1432 | struct xhci_device_context_array *dcbaa; |
1423 | struct xhci_ring *cmd_ring; | 1433 | struct xhci_ring *cmd_ring; |
1434 | unsigned int cmd_ring_state; | ||
1435 | #define CMD_RING_STATE_RUNNING (1 << 0) | ||
1436 | #define CMD_RING_STATE_ABORTED (1 << 1) | ||
1437 | #define CMD_RING_STATE_STOPPED (1 << 2) | ||
1438 | struct list_head cancel_cmd_list; | ||
1424 | unsigned int cmd_ring_reserved_trbs; | 1439 | unsigned int cmd_ring_reserved_trbs; |
1425 | struct xhci_ring *event_ring; | 1440 | struct xhci_ring *event_ring; |
1426 | struct xhci_erst erst; | 1441 | struct xhci_erst erst; |
@@ -1496,6 +1511,7 @@ struct xhci_hcd { | |||
1496 | #define XHCI_INTEL_HOST (1 << 12) | 1511 | #define XHCI_INTEL_HOST (1 << 12) |
1497 | #define XHCI_SPURIOUS_REBOOT (1 << 13) | 1512 | #define XHCI_SPURIOUS_REBOOT (1 << 13) |
1498 | #define XHCI_COMP_MODE_QUIRK (1 << 14) | 1513 | #define XHCI_COMP_MODE_QUIRK (1 << 14) |
1514 | #define XHCI_AVOID_BEI (1 << 15) | ||
1499 | unsigned int num_active_eps; | 1515 | unsigned int num_active_eps; |
1500 | unsigned int limit_active_eps; | 1516 | unsigned int limit_active_eps; |
1501 | /* There are two roothubs to keep track of bus suspend info for */ | 1517 | /* There are two roothubs to keep track of bus suspend info for */ |
@@ -1704,6 +1720,8 @@ static inline void xhci_unregister_plat(void) | |||
1704 | 1720 | ||
1705 | /* xHCI host controller glue */ | 1721 | /* xHCI host controller glue */ |
1706 | typedef void (*xhci_get_quirks_t)(struct device *, struct xhci_hcd *); | 1722 | typedef void (*xhci_get_quirks_t)(struct device *, struct xhci_hcd *); |
1723 | int handshake(struct xhci_hcd *xhci, void __iomem *ptr, | ||
1724 | u32 mask, u32 done, int usec); | ||
1707 | void xhci_quiesce(struct xhci_hcd *xhci); | 1725 | void xhci_quiesce(struct xhci_hcd *xhci); |
1708 | int xhci_halt(struct xhci_hcd *xhci); | 1726 | int xhci_halt(struct xhci_hcd *xhci); |
1709 | int xhci_reset(struct xhci_hcd *xhci); | 1727 | int xhci_reset(struct xhci_hcd *xhci); |
@@ -1794,6 +1812,8 @@ void xhci_queue_config_ep_quirk(struct xhci_hcd *xhci, | |||
1794 | unsigned int slot_id, unsigned int ep_index, | 1812 | unsigned int slot_id, unsigned int ep_index, |
1795 | struct xhci_dequeue_state *deq_state); | 1813 | struct xhci_dequeue_state *deq_state); |
1796 | void xhci_stop_endpoint_command_watchdog(unsigned long arg); | 1814 | void xhci_stop_endpoint_command_watchdog(unsigned long arg); |
1815 | int xhci_cancel_cmd(struct xhci_hcd *xhci, struct xhci_command *command, | ||
1816 | union xhci_trb *cmd_trb); | ||
1797 | void xhci_ring_ep_doorbell(struct xhci_hcd *xhci, unsigned int slot_id, | 1817 | void xhci_ring_ep_doorbell(struct xhci_hcd *xhci, unsigned int slot_id, |
1798 | unsigned int ep_index, unsigned int stream_id); | 1818 | unsigned int ep_index, unsigned int stream_id); |
1799 | 1819 | ||
diff --git a/drivers/usb/misc/Kconfig b/drivers/usb/misc/Kconfig index 1bfcd02ebeb5..a8f05239350e 100644 --- a/drivers/usb/misc/Kconfig +++ b/drivers/usb/misc/Kconfig | |||
@@ -244,3 +244,8 @@ config USB_YUREX | |||
244 | To compile this driver as a module, choose M here: the | 244 | To compile this driver as a module, choose M here: the |
245 | module will be called yurex. | 245 | module will be called yurex. |
246 | 246 | ||
247 | config USB_EZUSB_FX2 | ||
248 | tristate "Functions for loading firmware on EZUSB chips" | ||
249 | help | ||
250 | Say Y here if you need EZUSB device support. | ||
251 | (Cypress FX/FX2/FX2LP microcontrollers) | ||
diff --git a/drivers/usb/misc/Makefile b/drivers/usb/misc/Makefile index 796ce7ebccc8..3e99a643294b 100644 --- a/drivers/usb/misc/Makefile +++ b/drivers/usb/misc/Makefile | |||
@@ -11,6 +11,7 @@ obj-$(CONFIG_USB_CYPRESS_CY7C63) += cypress_cy7c63.o | |||
11 | obj-$(CONFIG_USB_CYTHERM) += cytherm.o | 11 | obj-$(CONFIG_USB_CYTHERM) += cytherm.o |
12 | obj-$(CONFIG_USB_EMI26) += emi26.o | 12 | obj-$(CONFIG_USB_EMI26) += emi26.o |
13 | obj-$(CONFIG_USB_EMI62) += emi62.o | 13 | obj-$(CONFIG_USB_EMI62) += emi62.o |
14 | obj-$(CONFIG_USB_EZUSB_FX2) += ezusb.o | ||
14 | obj-$(CONFIG_USB_FTDI_ELAN) += ftdi-elan.o | 15 | obj-$(CONFIG_USB_FTDI_ELAN) += ftdi-elan.o |
15 | obj-$(CONFIG_USB_IDMOUSE) += idmouse.o | 16 | obj-$(CONFIG_USB_IDMOUSE) += idmouse.o |
16 | obj-$(CONFIG_USB_IOWARRIOR) += iowarrior.o | 17 | obj-$(CONFIG_USB_IOWARRIOR) += iowarrior.o |
diff --git a/drivers/usb/misc/ezusb.c b/drivers/usb/misc/ezusb.c new file mode 100644 index 000000000000..4223d761223d --- /dev/null +++ b/drivers/usb/misc/ezusb.c | |||
@@ -0,0 +1,160 @@ | |||
1 | /* | ||
2 | * EZ-USB specific functions used by some of the USB to Serial drivers. | ||
3 | * | ||
4 | * Copyright (C) 1999 - 2002 Greg Kroah-Hartman (greg@kroah.com) | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License version | ||
8 | * 2 as published by the Free Software Foundation. | ||
9 | */ | ||
10 | |||
11 | #include <linux/kernel.h> | ||
12 | #include <linux/init.h> | ||
13 | #include <linux/slab.h> | ||
14 | #include <linux/module.h> | ||
15 | #include <linux/usb.h> | ||
16 | #include <linux/firmware.h> | ||
17 | #include <linux/ihex.h> | ||
18 | |||
19 | struct ezusb_fx_type { | ||
20 | /* EZ-USB Control and Status Register. Bit 0 controls 8051 reset */ | ||
21 | unsigned short cpucs_reg; | ||
22 | unsigned short max_internal_adress; | ||
23 | }; | ||
24 | |||
25 | struct ezusb_fx_type ezusb_fx1 = { | ||
26 | .cpucs_reg = 0x7F92, | ||
27 | .max_internal_adress = 0x1B3F, | ||
28 | }; | ||
29 | |||
30 | struct ezusb_fx_type ezusb_fx2 = { | ||
31 | .cpucs_reg = 0xE600, | ||
32 | .max_internal_adress = 0x3FFF, | ||
33 | }; | ||
34 | |||
35 | /* Commands for writing to memory */ | ||
36 | #define WRITE_INT_RAM 0xA0 | ||
37 | #define WRITE_EXT_RAM 0xA3 | ||
38 | |||
39 | int ezusb_writememory(struct usb_device *dev, int address, | ||
40 | unsigned char *data, int length, __u8 request) | ||
41 | { | ||
42 | int result; | ||
43 | unsigned char *transfer_buffer; | ||
44 | |||
45 | if (!dev) | ||
46 | return -ENODEV; | ||
47 | |||
48 | transfer_buffer = kmemdup(data, length, GFP_KERNEL); | ||
49 | if (!transfer_buffer) { | ||
50 | dev_err(&dev->dev, "%s - kmalloc(%d) failed.\n", | ||
51 | __func__, length); | ||
52 | return -ENOMEM; | ||
53 | } | ||
54 | result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), request, | ||
55 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | ||
56 | address, 0, transfer_buffer, length, 3000); | ||
57 | |||
58 | kfree(transfer_buffer); | ||
59 | return result; | ||
60 | } | ||
61 | EXPORT_SYMBOL_GPL(ezusb_writememory); | ||
62 | |||
63 | int ezusb_set_reset(struct usb_device *dev, unsigned short cpucs_reg, | ||
64 | unsigned char reset_bit) | ||
65 | { | ||
66 | int response = ezusb_writememory(dev, cpucs_reg, &reset_bit, 1, WRITE_INT_RAM); | ||
67 | if (response < 0) | ||
68 | dev_err(&dev->dev, "%s-%d failed: %d\n", | ||
69 | __func__, reset_bit, response); | ||
70 | return response; | ||
71 | } | ||
72 | |||
73 | int ezusb_fx1_set_reset(struct usb_device *dev, unsigned char reset_bit) | ||
74 | { | ||
75 | return ezusb_set_reset(dev, ezusb_fx1.cpucs_reg, reset_bit); | ||
76 | } | ||
77 | EXPORT_SYMBOL_GPL(ezusb_fx1_set_reset); | ||
78 | |||
79 | int ezusb_fx2_set_reset(struct usb_device *dev, unsigned char reset_bit) | ||
80 | { | ||
81 | return ezusb_set_reset(dev, ezusb_fx2.cpucs_reg, reset_bit); | ||
82 | } | ||
83 | EXPORT_SYMBOL_GPL(ezusb_fx2_set_reset); | ||
84 | |||
85 | static int ezusb_ihex_firmware_download(struct usb_device *dev, | ||
86 | struct ezusb_fx_type fx, | ||
87 | const char *firmware_path) | ||
88 | { | ||
89 | int ret = -ENOENT; | ||
90 | const struct firmware *firmware = NULL; | ||
91 | const struct ihex_binrec *record; | ||
92 | |||
93 | if (request_ihex_firmware(&firmware, firmware_path, | ||
94 | &dev->dev)) { | ||
95 | dev_err(&dev->dev, | ||
96 | "%s - request \"%s\" failed\n", | ||
97 | __func__, firmware_path); | ||
98 | goto out; | ||
99 | } | ||
100 | |||
101 | ret = ezusb_set_reset(dev, fx.cpucs_reg, 0); | ||
102 | if (ret < 0) | ||
103 | goto out; | ||
104 | |||
105 | record = (const struct ihex_binrec *)firmware->data; | ||
106 | for (; record; record = ihex_next_binrec(record)) { | ||
107 | if (be32_to_cpu(record->addr) > fx.max_internal_adress) { | ||
108 | ret = ezusb_writememory(dev, be32_to_cpu(record->addr), | ||
109 | (unsigned char *)record->data, | ||
110 | be16_to_cpu(record->len), WRITE_EXT_RAM); | ||
111 | if (ret < 0) { | ||
112 | dev_err(&dev->dev, "%s - ezusb_writememory " | ||
113 | "failed writing internal memory " | ||
114 | "(%d %04X %p %d)\n", __func__, ret, | ||
115 | be32_to_cpu(record->addr), record->data, | ||
116 | be16_to_cpu(record->len)); | ||
117 | goto out; | ||
118 | } | ||
119 | } | ||
120 | } | ||
121 | |||
122 | ret = ezusb_set_reset(dev, fx.cpucs_reg, 1); | ||
123 | if (ret < 0) | ||
124 | goto out; | ||
125 | record = (const struct ihex_binrec *)firmware->data; | ||
126 | for (; record; record = ihex_next_binrec(record)) { | ||
127 | if (be32_to_cpu(record->addr) <= fx.max_internal_adress) { | ||
128 | ret = ezusb_writememory(dev, be32_to_cpu(record->addr), | ||
129 | (unsigned char *)record->data, | ||
130 | be16_to_cpu(record->len), WRITE_INT_RAM); | ||
131 | if (ret < 0) { | ||
132 | dev_err(&dev->dev, "%s - ezusb_writememory " | ||
133 | "failed writing external memory " | ||
134 | "(%d %04X %p %d)\n", __func__, ret, | ||
135 | be32_to_cpu(record->addr), record->data, | ||
136 | be16_to_cpu(record->len)); | ||
137 | goto out; | ||
138 | } | ||
139 | } | ||
140 | } | ||
141 | ret = ezusb_set_reset(dev, fx.cpucs_reg, 0); | ||
142 | out: | ||
143 | release_firmware(firmware); | ||
144 | return ret; | ||
145 | } | ||
146 | |||
147 | int ezusb_fx1_ihex_firmware_download(struct usb_device *dev, | ||
148 | const char *firmware_path) | ||
149 | { | ||
150 | return ezusb_ihex_firmware_download(dev, ezusb_fx1, firmware_path); | ||
151 | } | ||
152 | EXPORT_SYMBOL_GPL(ezusb_fx1_ihex_firmware_download); | ||
153 | |||
154 | int ezusb_fx2_ihex_firmware_download(struct usb_device *dev, | ||
155 | const char *firmware_path) | ||
156 | { | ||
157 | return ezusb_ihex_firmware_download(dev, ezusb_fx2, firmware_path); | ||
158 | } | ||
159 | EXPORT_SYMBOL_GPL(ezusb_fx2_ihex_firmware_download); | ||
160 | |||
diff --git a/drivers/usb/misc/legousbtower.c b/drivers/usb/misc/legousbtower.c index a2702cbfe804..80894791c020 100644 --- a/drivers/usb/misc/legousbtower.c +++ b/drivers/usb/misc/legousbtower.c | |||
@@ -868,9 +868,6 @@ static int tower_probe (struct usb_interface *interface, const struct usb_device | |||
868 | 868 | ||
869 | dbg(2, "%s: enter", __func__); | 869 | dbg(2, "%s: enter", __func__); |
870 | 870 | ||
871 | if (udev == NULL) | ||
872 | dev_info(&interface->dev, "udev is NULL.\n"); | ||
873 | |||
874 | /* allocate memory for our device state and initialize it */ | 871 | /* allocate memory for our device state and initialize it */ |
875 | 872 | ||
876 | dev = kmalloc (sizeof(struct lego_usb_tower), GFP_KERNEL); | 873 | dev = kmalloc (sizeof(struct lego_usb_tower), GFP_KERNEL); |
diff --git a/drivers/usb/misc/rio500.c b/drivers/usb/misc/rio500.c index 1084124c4a44..b9b356a9dd11 100644 --- a/drivers/usb/misc/rio500.c +++ b/drivers/usb/misc/rio500.c | |||
@@ -338,7 +338,7 @@ write_rio(struct file *file, const char __user *buffer, | |||
338 | thistime -= partial; | 338 | thistime -= partial; |
339 | } else | 339 | } else |
340 | break; | 340 | break; |
341 | }; | 341 | } |
342 | if (result) { | 342 | if (result) { |
343 | dev_err(&rio->rio_dev->dev, "Write Whoops - %x\n", | 343 | dev_err(&rio->rio_dev->dev, "Write Whoops - %x\n", |
344 | result); | 344 | result); |
diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig index 6259f0d99324..23a0b7f0892d 100644 --- a/drivers/usb/musb/Kconfig +++ b/drivers/usb/musb/Kconfig | |||
@@ -12,7 +12,6 @@ config USB_MUSB_HDRC | |||
12 | select TWL4030_USB if MACH_OMAP_3430SDP | 12 | select TWL4030_USB if MACH_OMAP_3430SDP |
13 | select TWL6030_USB if MACH_OMAP_4430SDP || MACH_OMAP4_PANDA | 13 | select TWL6030_USB if MACH_OMAP_4430SDP || MACH_OMAP4_PANDA |
14 | select USB_OTG_UTILS | 14 | select USB_OTG_UTILS |
15 | select USB_GADGET_DUALSPEED | ||
16 | help | 15 | help |
17 | 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 |
18 | controller based on the Mentor Graphics silicon IP. Then | 17 | controller based on the Mentor Graphics silicon IP. Then |
@@ -20,7 +19,7 @@ config USB_MUSB_HDRC | |||
20 | it's being used with, including the USB peripheral role, | 19 | it's being used with, including the USB peripheral role, |
21 | or the USB host role, or both. | 20 | or the USB host role, or both. |
22 | 21 | ||
23 | Texas Instruments familiies using this IP include DaVinci | 22 | Texas Instruments families using this IP include DaVinci |
24 | (35x, 644x ...), OMAP 243x, OMAP 3, and TUSB 6010. | 23 | (35x, 644x ...), OMAP 243x, OMAP 3, and TUSB 6010. |
25 | 24 | ||
26 | Analog Devices parts using this IP include Blackfin BF54x, | 25 | Analog Devices parts using this IP include Blackfin BF54x, |
diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c index 7a95ab87ac00..457f25e62c51 100644 --- a/drivers/usb/musb/am35x.c +++ b/drivers/usb/musb/am35x.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/io.h> | 33 | #include <linux/io.h> |
34 | #include <linux/platform_device.h> | 34 | #include <linux/platform_device.h> |
35 | #include <linux/dma-mapping.h> | 35 | #include <linux/dma-mapping.h> |
36 | #include <linux/usb/nop-usb-xceiv.h> | ||
36 | 37 | ||
37 | #include <plat/usb.h> | 38 | #include <plat/usb.h> |
38 | 39 | ||
@@ -107,9 +108,8 @@ static void am35x_musb_enable(struct musb *musb) | |||
107 | musb_writel(reg_base, CORE_INTR_MASK_SET_REG, AM35X_INTR_USB_MASK); | 108 | musb_writel(reg_base, CORE_INTR_MASK_SET_REG, AM35X_INTR_USB_MASK); |
108 | 109 | ||
109 | /* Force the DRVVBUS IRQ so we can start polling for ID change. */ | 110 | /* Force the DRVVBUS IRQ so we can start polling for ID change. */ |
110 | if (is_otg_enabled(musb)) | 111 | musb_writel(reg_base, CORE_INTR_SRC_SET_REG, |
111 | musb_writel(reg_base, CORE_INTR_SRC_SET_REG, | 112 | AM35X_INTR_DRVVBUS << AM35X_INTR_USB_SHIFT); |
112 | AM35X_INTR_DRVVBUS << AM35X_INTR_USB_SHIFT); | ||
113 | } | 113 | } |
114 | 114 | ||
115 | /* | 115 | /* |
@@ -173,9 +173,6 @@ static void otg_timer(unsigned long _musb) | |||
173 | MUSB_INTR_VBUSERROR << AM35X_INTR_USB_SHIFT); | 173 | MUSB_INTR_VBUSERROR << AM35X_INTR_USB_SHIFT); |
174 | break; | 174 | break; |
175 | case OTG_STATE_B_IDLE: | 175 | case OTG_STATE_B_IDLE: |
176 | if (!is_peripheral_enabled(musb)) | ||
177 | break; | ||
178 | |||
179 | devctl = musb_readb(mregs, MUSB_DEVCTL); | 176 | devctl = musb_readb(mregs, MUSB_DEVCTL); |
180 | if (devctl & MUSB_DEVCTL_BDEVICE) | 177 | if (devctl & MUSB_DEVCTL_BDEVICE) |
181 | mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ); | 178 | mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ); |
@@ -192,9 +189,6 @@ static void am35x_musb_try_idle(struct musb *musb, unsigned long timeout) | |||
192 | { | 189 | { |
193 | static unsigned long last_timer; | 190 | static unsigned long last_timer; |
194 | 191 | ||
195 | if (!is_otg_enabled(musb)) | ||
196 | return; | ||
197 | |||
198 | if (timeout == 0) | 192 | if (timeout == 0) |
199 | timeout = jiffies + msecs_to_jiffies(3); | 193 | timeout = jiffies + msecs_to_jiffies(3); |
200 | 194 | ||
@@ -271,8 +265,7 @@ static irqreturn_t am35x_musb_interrupt(int irq, void *hci) | |||
271 | u8 devctl = musb_readb(mregs, MUSB_DEVCTL); | 265 | u8 devctl = musb_readb(mregs, MUSB_DEVCTL); |
272 | int err; | 266 | int err; |
273 | 267 | ||
274 | err = is_host_enabled(musb) && (musb->int_usb & | 268 | err = musb->int_usb & MUSB_INTR_VBUSERROR; |
275 | MUSB_INTR_VBUSERROR); | ||
276 | if (err) { | 269 | if (err) { |
277 | /* | 270 | /* |
278 | * The Mentor core doesn't debounce VBUS as needed | 271 | * The Mentor core doesn't debounce VBUS as needed |
@@ -289,7 +282,7 @@ static irqreturn_t am35x_musb_interrupt(int irq, void *hci) | |||
289 | musb->xceiv->state = OTG_STATE_A_WAIT_VFALL; | 282 | musb->xceiv->state = OTG_STATE_A_WAIT_VFALL; |
290 | mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ); | 283 | mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ); |
291 | WARNING("VBUS error workaround (delay coming)\n"); | 284 | WARNING("VBUS error workaround (delay coming)\n"); |
292 | } else if (is_host_enabled(musb) && drvvbus) { | 285 | } else if (drvvbus) { |
293 | MUSB_HST_MODE(musb); | 286 | MUSB_HST_MODE(musb); |
294 | otg->default_a = 1; | 287 | otg->default_a = 1; |
295 | musb->xceiv->state = OTG_STATE_A_WAIT_VRISE; | 288 | musb->xceiv->state = OTG_STATE_A_WAIT_VRISE; |
@@ -326,7 +319,7 @@ eoi: | |||
326 | } | 319 | } |
327 | 320 | ||
328 | /* Poll for ID change */ | 321 | /* Poll for ID change */ |
329 | if (is_otg_enabled(musb) && musb->xceiv->state == OTG_STATE_B_IDLE) | 322 | if (musb->xceiv->state == OTG_STATE_B_IDLE) |
330 | mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ); | 323 | mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ); |
331 | 324 | ||
332 | spin_unlock_irqrestore(&musb->lock, flags); | 325 | spin_unlock_irqrestore(&musb->lock, flags); |
@@ -369,8 +362,7 @@ static int am35x_musb_init(struct musb *musb) | |||
369 | if (IS_ERR_OR_NULL(musb->xceiv)) | 362 | if (IS_ERR_OR_NULL(musb->xceiv)) |
370 | return -ENODEV; | 363 | return -ENODEV; |
371 | 364 | ||
372 | if (is_host_enabled(musb)) | 365 | setup_timer(&otg_workaround, otg_timer, (unsigned long) musb); |
373 | setup_timer(&otg_workaround, otg_timer, (unsigned long) musb); | ||
374 | 366 | ||
375 | /* Reset the musb */ | 367 | /* Reset the musb */ |
376 | if (data->reset) | 368 | if (data->reset) |
@@ -400,8 +392,7 @@ static int am35x_musb_exit(struct musb *musb) | |||
400 | struct musb_hdrc_platform_data *plat = dev->platform_data; | 392 | struct musb_hdrc_platform_data *plat = dev->platform_data; |
401 | struct omap_musb_board_data *data = plat->board_data; | 393 | struct omap_musb_board_data *data = plat->board_data; |
402 | 394 | ||
403 | if (is_host_enabled(musb)) | 395 | del_timer_sync(&otg_workaround); |
404 | del_timer_sync(&otg_workaround); | ||
405 | 396 | ||
406 | /* Shutdown the on-chip PHY and its PLL. */ | 397 | /* Shutdown the on-chip PHY and its PLL. */ |
407 | if (data->set_phy_power) | 398 | if (data->set_phy_power) |
@@ -468,6 +459,7 @@ static int __devinit am35x_probe(struct platform_device *pdev) | |||
468 | struct clk *clk; | 459 | struct clk *clk; |
469 | 460 | ||
470 | int ret = -ENOMEM; | 461 | int ret = -ENOMEM; |
462 | int musbid; | ||
471 | 463 | ||
472 | glue = kzalloc(sizeof(*glue), GFP_KERNEL); | 464 | glue = kzalloc(sizeof(*glue), GFP_KERNEL); |
473 | if (!glue) { | 465 | if (!glue) { |
@@ -475,38 +467,47 @@ static int __devinit am35x_probe(struct platform_device *pdev) | |||
475 | goto err0; | 467 | goto err0; |
476 | } | 468 | } |
477 | 469 | ||
478 | musb = platform_device_alloc("musb-hdrc", -1); | 470 | /* get the musb id */ |
471 | musbid = musb_get_id(&pdev->dev, GFP_KERNEL); | ||
472 | if (musbid < 0) { | ||
473 | dev_err(&pdev->dev, "failed to allocate musb id\n"); | ||
474 | ret = -ENOMEM; | ||
475 | goto err1; | ||
476 | } | ||
477 | |||
478 | musb = platform_device_alloc("musb-hdrc", musbid); | ||
479 | if (!musb) { | 479 | if (!musb) { |
480 | dev_err(&pdev->dev, "failed to allocate musb device\n"); | 480 | dev_err(&pdev->dev, "failed to allocate musb device\n"); |
481 | goto err1; | 481 | goto err2; |
482 | } | 482 | } |
483 | 483 | ||
484 | phy_clk = clk_get(&pdev->dev, "fck"); | 484 | phy_clk = clk_get(&pdev->dev, "fck"); |
485 | if (IS_ERR(phy_clk)) { | 485 | if (IS_ERR(phy_clk)) { |
486 | dev_err(&pdev->dev, "failed to get PHY clock\n"); | 486 | dev_err(&pdev->dev, "failed to get PHY clock\n"); |
487 | ret = PTR_ERR(phy_clk); | 487 | ret = PTR_ERR(phy_clk); |
488 | goto err2; | 488 | goto err3; |
489 | } | 489 | } |
490 | 490 | ||
491 | clk = clk_get(&pdev->dev, "ick"); | 491 | clk = clk_get(&pdev->dev, "ick"); |
492 | if (IS_ERR(clk)) { | 492 | if (IS_ERR(clk)) { |
493 | dev_err(&pdev->dev, "failed to get clock\n"); | 493 | dev_err(&pdev->dev, "failed to get clock\n"); |
494 | ret = PTR_ERR(clk); | 494 | ret = PTR_ERR(clk); |
495 | goto err3; | 495 | goto err4; |
496 | } | 496 | } |
497 | 497 | ||
498 | ret = clk_enable(phy_clk); | 498 | ret = clk_enable(phy_clk); |
499 | if (ret) { | 499 | if (ret) { |
500 | dev_err(&pdev->dev, "failed to enable PHY clock\n"); | 500 | dev_err(&pdev->dev, "failed to enable PHY clock\n"); |
501 | goto err4; | 501 | goto err5; |
502 | } | 502 | } |
503 | 503 | ||
504 | ret = clk_enable(clk); | 504 | ret = clk_enable(clk); |
505 | if (ret) { | 505 | if (ret) { |
506 | dev_err(&pdev->dev, "failed to enable clock\n"); | 506 | dev_err(&pdev->dev, "failed to enable clock\n"); |
507 | goto err5; | 507 | goto err6; |
508 | } | 508 | } |
509 | 509 | ||
510 | musb->id = musbid; | ||
510 | musb->dev.parent = &pdev->dev; | 511 | musb->dev.parent = &pdev->dev; |
511 | musb->dev.dma_mask = &am35x_dmamask; | 512 | musb->dev.dma_mask = &am35x_dmamask; |
512 | musb->dev.coherent_dma_mask = am35x_dmamask; | 513 | musb->dev.coherent_dma_mask = am35x_dmamask; |
@@ -524,38 +525,41 @@ static int __devinit am35x_probe(struct platform_device *pdev) | |||
524 | pdev->num_resources); | 525 | pdev->num_resources); |
525 | if (ret) { | 526 | if (ret) { |
526 | dev_err(&pdev->dev, "failed to add resources\n"); | 527 | dev_err(&pdev->dev, "failed to add resources\n"); |
527 | goto err6; | 528 | goto err7; |
528 | } | 529 | } |
529 | 530 | ||
530 | ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); | 531 | ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); |
531 | if (ret) { | 532 | if (ret) { |
532 | dev_err(&pdev->dev, "failed to add platform_data\n"); | 533 | dev_err(&pdev->dev, "failed to add platform_data\n"); |
533 | goto err6; | 534 | goto err7; |
534 | } | 535 | } |
535 | 536 | ||
536 | ret = platform_device_add(musb); | 537 | ret = platform_device_add(musb); |
537 | if (ret) { | 538 | if (ret) { |
538 | dev_err(&pdev->dev, "failed to register musb device\n"); | 539 | dev_err(&pdev->dev, "failed to register musb device\n"); |
539 | goto err6; | 540 | goto err7; |
540 | } | 541 | } |
541 | 542 | ||
542 | return 0; | 543 | return 0; |
543 | 544 | ||
544 | err6: | 545 | err7: |
545 | clk_disable(clk); | 546 | clk_disable(clk); |
546 | 547 | ||
547 | err5: | 548 | err6: |
548 | clk_disable(phy_clk); | 549 | clk_disable(phy_clk); |
549 | 550 | ||
550 | err4: | 551 | err5: |
551 | clk_put(clk); | 552 | clk_put(clk); |
552 | 553 | ||
553 | err3: | 554 | err4: |
554 | clk_put(phy_clk); | 555 | clk_put(phy_clk); |
555 | 556 | ||
556 | err2: | 557 | err3: |
557 | platform_device_put(musb); | 558 | platform_device_put(musb); |
558 | 559 | ||
560 | err2: | ||
561 | musb_put_id(&pdev->dev, musbid); | ||
562 | |||
559 | err1: | 563 | err1: |
560 | kfree(glue); | 564 | kfree(glue); |
561 | 565 | ||
@@ -567,6 +571,7 @@ static int __devexit am35x_remove(struct platform_device *pdev) | |||
567 | { | 571 | { |
568 | struct am35x_glue *glue = platform_get_drvdata(pdev); | 572 | struct am35x_glue *glue = platform_get_drvdata(pdev); |
569 | 573 | ||
574 | musb_put_id(&pdev->dev, glue->musb->id); | ||
570 | platform_device_del(glue->musb); | 575 | platform_device_del(glue->musb); |
571 | platform_device_put(glue->musb); | 576 | platform_device_put(glue->musb); |
572 | clk_disable(glue->clk); | 577 | clk_disable(glue->clk); |
diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c index 428e6aa3e78a..e8cff9bb9d23 100644 --- a/drivers/usb/musb/blackfin.c +++ b/drivers/usb/musb/blackfin.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/platform_device.h> | 19 | #include <linux/platform_device.h> |
20 | #include <linux/dma-mapping.h> | 20 | #include <linux/dma-mapping.h> |
21 | #include <linux/prefetch.h> | 21 | #include <linux/prefetch.h> |
22 | #include <linux/usb/nop-usb-xceiv.h> | ||
22 | 23 | ||
23 | #include <asm/cacheflush.h> | 24 | #include <asm/cacheflush.h> |
24 | 25 | ||
@@ -184,8 +185,8 @@ static irqreturn_t blackfin_interrupt(int irq, void *__hci) | |||
184 | } | 185 | } |
185 | 186 | ||
186 | /* Start sampling ID pin, when plug is removed from MUSB */ | 187 | /* Start sampling ID pin, when plug is removed from MUSB */ |
187 | if ((is_otg_enabled(musb) && (musb->xceiv->state == OTG_STATE_B_IDLE | 188 | if ((musb->xceiv->state == OTG_STATE_B_IDLE |
188 | || musb->xceiv->state == OTG_STATE_A_WAIT_BCON)) || | 189 | || musb->xceiv->state == OTG_STATE_A_WAIT_BCON) || |
189 | (musb->int_usb & MUSB_INTR_DISCONNECT && is_host_active(musb))) { | 190 | (musb->int_usb & MUSB_INTR_DISCONNECT && is_host_active(musb))) { |
190 | mod_timer(&musb_conn_timer, jiffies + TIMER_DELAY); | 191 | mod_timer(&musb_conn_timer, jiffies + TIMER_DELAY); |
191 | musb->a_wait_bcon = TIMER_DELAY; | 192 | musb->a_wait_bcon = TIMER_DELAY; |
@@ -228,18 +229,13 @@ static void musb_conn_timer_handler(unsigned long _musb) | |||
228 | 229 | ||
229 | val = MUSB_INTR_SUSPEND | MUSB_INTR_VBUSERROR; | 230 | val = MUSB_INTR_SUSPEND | MUSB_INTR_VBUSERROR; |
230 | musb_writeb(musb->mregs, MUSB_INTRUSB, val); | 231 | musb_writeb(musb->mregs, MUSB_INTRUSB, val); |
231 | if (is_otg_enabled(musb)) | 232 | musb->xceiv->state = OTG_STATE_B_IDLE; |
232 | musb->xceiv->state = OTG_STATE_B_IDLE; | ||
233 | else | ||
234 | musb_writeb(musb->mregs, MUSB_POWER, MUSB_POWER_HSENAB); | ||
235 | } | 233 | } |
236 | mod_timer(&musb_conn_timer, jiffies + TIMER_DELAY); | 234 | mod_timer(&musb_conn_timer, jiffies + TIMER_DELAY); |
237 | break; | 235 | break; |
238 | case OTG_STATE_B_IDLE: | 236 | case OTG_STATE_B_IDLE: |
239 | 237 | /* | |
240 | if (!is_peripheral_enabled(musb)) | 238 | * Start a new session. It seems that MUSB needs taking |
241 | break; | ||
242 | /* Start a new session. It seems that MUSB needs taking | ||
243 | * some time to recognize the type of the plug inserted? | 239 | * some time to recognize the type of the plug inserted? |
244 | */ | 240 | */ |
245 | val = musb_readw(musb->mregs, MUSB_DEVCTL); | 241 | val = musb_readw(musb->mregs, MUSB_DEVCTL); |
@@ -295,10 +291,7 @@ static void musb_conn_timer_handler(unsigned long _musb) | |||
295 | 291 | ||
296 | static void bfin_musb_enable(struct musb *musb) | 292 | static void bfin_musb_enable(struct musb *musb) |
297 | { | 293 | { |
298 | if (!is_otg_enabled(musb) && is_host_enabled(musb)) { | 294 | /* REVISIT is this really correct ? */ |
299 | mod_timer(&musb_conn_timer, jiffies + TIMER_DELAY); | ||
300 | musb->a_wait_bcon = TIMER_DELAY; | ||
301 | } | ||
302 | } | 295 | } |
303 | 296 | ||
304 | static void bfin_musb_disable(struct musb *musb) | 297 | static void bfin_musb_disable(struct musb *musb) |
@@ -323,12 +316,6 @@ static int bfin_musb_set_power(struct usb_phy *x, unsigned mA) | |||
323 | return 0; | 316 | return 0; |
324 | } | 317 | } |
325 | 318 | ||
326 | static void bfin_musb_try_idle(struct musb *musb, unsigned long timeout) | ||
327 | { | ||
328 | if (!is_otg_enabled(musb) && is_host_enabled(musb)) | ||
329 | mod_timer(&musb_conn_timer, jiffies + TIMER_DELAY); | ||
330 | } | ||
331 | |||
332 | static int bfin_musb_vbus_status(struct musb *musb) | 319 | static int bfin_musb_vbus_status(struct musb *musb) |
333 | { | 320 | { |
334 | return 0; | 321 | return 0; |
@@ -424,12 +411,10 @@ static int bfin_musb_init(struct musb *musb) | |||
424 | 411 | ||
425 | bfin_musb_reg_init(musb); | 412 | bfin_musb_reg_init(musb); |
426 | 413 | ||
427 | if (is_host_enabled(musb)) { | 414 | setup_timer(&musb_conn_timer, musb_conn_timer_handler, |
428 | setup_timer(&musb_conn_timer, | 415 | (unsigned long) musb); |
429 | musb_conn_timer_handler, (unsigned long) musb); | 416 | |
430 | } | 417 | musb->xceiv->set_power = bfin_musb_set_power; |
431 | if (is_peripheral_enabled(musb)) | ||
432 | musb->xceiv->set_power = bfin_musb_set_power; | ||
433 | 418 | ||
434 | musb->isr = blackfin_interrupt; | 419 | musb->isr = blackfin_interrupt; |
435 | musb->double_buffer_not_ok = true; | 420 | musb->double_buffer_not_ok = true; |
@@ -454,7 +439,6 @@ static const struct musb_platform_ops bfin_ops = { | |||
454 | .disable = bfin_musb_disable, | 439 | .disable = bfin_musb_disable, |
455 | 440 | ||
456 | .set_mode = bfin_musb_set_mode, | 441 | .set_mode = bfin_musb_set_mode, |
457 | .try_idle = bfin_musb_try_idle, | ||
458 | 442 | ||
459 | .vbus_status = bfin_musb_vbus_status, | 443 | .vbus_status = bfin_musb_vbus_status, |
460 | .set_vbus = bfin_musb_set_vbus, | 444 | .set_vbus = bfin_musb_set_vbus, |
@@ -471,6 +455,7 @@ static int __devinit bfin_probe(struct platform_device *pdev) | |||
471 | struct bfin_glue *glue; | 455 | struct bfin_glue *glue; |
472 | 456 | ||
473 | int ret = -ENOMEM; | 457 | int ret = -ENOMEM; |
458 | int musbid; | ||
474 | 459 | ||
475 | glue = kzalloc(sizeof(*glue), GFP_KERNEL); | 460 | glue = kzalloc(sizeof(*glue), GFP_KERNEL); |
476 | if (!glue) { | 461 | if (!glue) { |
@@ -478,12 +463,21 @@ static int __devinit bfin_probe(struct platform_device *pdev) | |||
478 | goto err0; | 463 | goto err0; |
479 | } | 464 | } |
480 | 465 | ||
481 | musb = platform_device_alloc("musb-hdrc", -1); | 466 | /* get the musb id */ |
467 | musbid = musb_get_id(&pdev->dev, GFP_KERNEL); | ||
468 | if (musbid < 0) { | ||
469 | dev_err(&pdev->dev, "failed to allocate musb id\n"); | ||
470 | ret = -ENOMEM; | ||
471 | goto err1; | ||
472 | } | ||
473 | |||
474 | musb = platform_device_alloc("musb-hdrc", musbid); | ||
482 | if (!musb) { | 475 | if (!musb) { |
483 | dev_err(&pdev->dev, "failed to allocate musb device\n"); | 476 | dev_err(&pdev->dev, "failed to allocate musb device\n"); |
484 | goto err1; | 477 | goto err2; |
485 | } | 478 | } |
486 | 479 | ||
480 | musb->id = musbid; | ||
487 | musb->dev.parent = &pdev->dev; | 481 | musb->dev.parent = &pdev->dev; |
488 | musb->dev.dma_mask = &bfin_dmamask; | 482 | musb->dev.dma_mask = &bfin_dmamask; |
489 | musb->dev.coherent_dma_mask = bfin_dmamask; | 483 | musb->dev.coherent_dma_mask = bfin_dmamask; |
@@ -499,26 +493,29 @@ static int __devinit bfin_probe(struct platform_device *pdev) | |||
499 | pdev->num_resources); | 493 | pdev->num_resources); |
500 | if (ret) { | 494 | if (ret) { |
501 | dev_err(&pdev->dev, "failed to add resources\n"); | 495 | dev_err(&pdev->dev, "failed to add resources\n"); |
502 | goto err2; | 496 | goto err3; |
503 | } | 497 | } |
504 | 498 | ||
505 | ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); | 499 | ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); |
506 | if (ret) { | 500 | if (ret) { |
507 | dev_err(&pdev->dev, "failed to add platform_data\n"); | 501 | dev_err(&pdev->dev, "failed to add platform_data\n"); |
508 | goto err2; | 502 | goto err3; |
509 | } | 503 | } |
510 | 504 | ||
511 | ret = platform_device_add(musb); | 505 | ret = platform_device_add(musb); |
512 | if (ret) { | 506 | if (ret) { |
513 | dev_err(&pdev->dev, "failed to register musb device\n"); | 507 | dev_err(&pdev->dev, "failed to register musb device\n"); |
514 | goto err2; | 508 | goto err3; |
515 | } | 509 | } |
516 | 510 | ||
517 | return 0; | 511 | return 0; |
518 | 512 | ||
519 | err2: | 513 | err3: |
520 | platform_device_put(musb); | 514 | platform_device_put(musb); |
521 | 515 | ||
516 | err2: | ||
517 | musb_put_id(&pdev->dev, musbid); | ||
518 | |||
522 | err1: | 519 | err1: |
523 | kfree(glue); | 520 | kfree(glue); |
524 | 521 | ||
@@ -530,6 +527,7 @@ static int __devexit bfin_remove(struct platform_device *pdev) | |||
530 | { | 527 | { |
531 | struct bfin_glue *glue = platform_get_drvdata(pdev); | 528 | struct bfin_glue *glue = platform_get_drvdata(pdev); |
532 | 529 | ||
530 | musb_put_id(&pdev->dev, glue->musb->id); | ||
533 | platform_device_del(glue->musb); | 531 | platform_device_del(glue->musb); |
534 | platform_device_put(glue->musb); | 532 | platform_device_put(glue->musb); |
535 | kfree(glue); | 533 | kfree(glue); |
diff --git a/drivers/usb/musb/cppi_dma.c b/drivers/usb/musb/cppi_dma.c index 8637c1f69fc3..e19da82b4782 100644 --- a/drivers/usb/musb/cppi_dma.c +++ b/drivers/usb/musb/cppi_dma.c | |||
@@ -1316,7 +1316,7 @@ irqreturn_t cppi_interrupt(int irq, void *dev_id) | |||
1316 | } | 1316 | } |
1317 | 1317 | ||
1318 | /* Instantiate a software object representing a DMA controller. */ | 1318 | /* Instantiate a software object representing a DMA controller. */ |
1319 | struct dma_controller *__init | 1319 | struct dma_controller *__devinit |
1320 | dma_controller_create(struct musb *musb, void __iomem *mregs) | 1320 | dma_controller_create(struct musb *musb, void __iomem *mregs) |
1321 | { | 1321 | { |
1322 | struct cppi *controller; | 1322 | struct cppi *controller; |
diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c index 0f9fcec4e1d3..ce11d20b90f4 100644 --- a/drivers/usb/musb/da8xx.c +++ b/drivers/usb/musb/da8xx.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/io.h> | 33 | #include <linux/io.h> |
34 | #include <linux/platform_device.h> | 34 | #include <linux/platform_device.h> |
35 | #include <linux/dma-mapping.h> | 35 | #include <linux/dma-mapping.h> |
36 | #include <linux/usb/nop-usb-xceiv.h> | ||
36 | 37 | ||
37 | #include <mach/da8xx.h> | 38 | #include <mach/da8xx.h> |
38 | #include <mach/usb.h> | 39 | #include <mach/usb.h> |
@@ -155,9 +156,8 @@ static void da8xx_musb_enable(struct musb *musb) | |||
155 | musb_writel(reg_base, DA8XX_USB_INTR_MASK_SET_REG, mask); | 156 | musb_writel(reg_base, DA8XX_USB_INTR_MASK_SET_REG, mask); |
156 | 157 | ||
157 | /* Force the DRVVBUS IRQ so we can start polling for ID change. */ | 158 | /* Force the DRVVBUS IRQ so we can start polling for ID change. */ |
158 | if (is_otg_enabled(musb)) | 159 | musb_writel(reg_base, DA8XX_USB_INTR_SRC_SET_REG, |
159 | musb_writel(reg_base, DA8XX_USB_INTR_SRC_SET_REG, | 160 | DA8XX_INTR_DRVVBUS << DA8XX_INTR_USB_SHIFT); |
160 | DA8XX_INTR_DRVVBUS << DA8XX_INTR_USB_SHIFT); | ||
161 | } | 161 | } |
162 | 162 | ||
163 | /** | 163 | /** |
@@ -231,9 +231,6 @@ static void otg_timer(unsigned long _musb) | |||
231 | MUSB_INTR_VBUSERROR << DA8XX_INTR_USB_SHIFT); | 231 | MUSB_INTR_VBUSERROR << DA8XX_INTR_USB_SHIFT); |
232 | break; | 232 | break; |
233 | case OTG_STATE_B_IDLE: | 233 | case OTG_STATE_B_IDLE: |
234 | if (!is_peripheral_enabled(musb)) | ||
235 | break; | ||
236 | |||
237 | /* | 234 | /* |
238 | * There's no ID-changed IRQ, so we have no good way to tell | 235 | * There's no ID-changed IRQ, so we have no good way to tell |
239 | * when to switch to the A-Default state machine (by setting | 236 | * when to switch to the A-Default state machine (by setting |
@@ -263,9 +260,6 @@ static void da8xx_musb_try_idle(struct musb *musb, unsigned long timeout) | |||
263 | { | 260 | { |
264 | static unsigned long last_timer; | 261 | static unsigned long last_timer; |
265 | 262 | ||
266 | if (!is_otg_enabled(musb)) | ||
267 | return; | ||
268 | |||
269 | if (timeout == 0) | 263 | if (timeout == 0) |
270 | timeout = jiffies + msecs_to_jiffies(3); | 264 | timeout = jiffies + msecs_to_jiffies(3); |
271 | 265 | ||
@@ -333,8 +327,7 @@ static irqreturn_t da8xx_musb_interrupt(int irq, void *hci) | |||
333 | u8 devctl = musb_readb(mregs, MUSB_DEVCTL); | 327 | u8 devctl = musb_readb(mregs, MUSB_DEVCTL); |
334 | int err; | 328 | int err; |
335 | 329 | ||
336 | err = is_host_enabled(musb) && (musb->int_usb & | 330 | err = musb->int_usb & USB_INTR_VBUSERROR; |
337 | MUSB_INTR_VBUSERROR); | ||
338 | if (err) { | 331 | if (err) { |
339 | /* | 332 | /* |
340 | * The Mentor core doesn't debounce VBUS as needed | 333 | * The Mentor core doesn't debounce VBUS as needed |
@@ -351,7 +344,7 @@ static irqreturn_t da8xx_musb_interrupt(int irq, void *hci) | |||
351 | musb->xceiv->state = OTG_STATE_A_WAIT_VFALL; | 344 | musb->xceiv->state = OTG_STATE_A_WAIT_VFALL; |
352 | mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ); | 345 | mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ); |
353 | WARNING("VBUS error workaround (delay coming)\n"); | 346 | WARNING("VBUS error workaround (delay coming)\n"); |
354 | } else if (is_host_enabled(musb) && drvvbus) { | 347 | } else if (drvvbus) { |
355 | MUSB_HST_MODE(musb); | 348 | MUSB_HST_MODE(musb); |
356 | otg->default_a = 1; | 349 | otg->default_a = 1; |
357 | musb->xceiv->state = OTG_STATE_A_WAIT_VRISE; | 350 | musb->xceiv->state = OTG_STATE_A_WAIT_VRISE; |
@@ -382,7 +375,7 @@ static irqreturn_t da8xx_musb_interrupt(int irq, void *hci) | |||
382 | musb_writel(reg_base, DA8XX_USB_END_OF_INTR_REG, 0); | 375 | musb_writel(reg_base, DA8XX_USB_END_OF_INTR_REG, 0); |
383 | 376 | ||
384 | /* Poll for ID change */ | 377 | /* Poll for ID change */ |
385 | if (is_otg_enabled(musb) && musb->xceiv->state == OTG_STATE_B_IDLE) | 378 | if (musb->xceiv->state == OTG_STATE_B_IDLE) |
386 | mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ); | 379 | mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ); |
387 | 380 | ||
388 | spin_unlock_irqrestore(&musb->lock, flags); | 381 | spin_unlock_irqrestore(&musb->lock, flags); |
@@ -430,8 +423,7 @@ static int da8xx_musb_init(struct musb *musb) | |||
430 | if (IS_ERR_OR_NULL(musb->xceiv)) | 423 | if (IS_ERR_OR_NULL(musb->xceiv)) |
431 | goto fail; | 424 | goto fail; |
432 | 425 | ||
433 | if (is_host_enabled(musb)) | 426 | setup_timer(&otg_workaround, otg_timer, (unsigned long)musb); |
434 | setup_timer(&otg_workaround, otg_timer, (unsigned long)musb); | ||
435 | 427 | ||
436 | /* Reset the controller */ | 428 | /* Reset the controller */ |
437 | musb_writel(reg_base, DA8XX_USB_CTRL_REG, DA8XX_SOFT_RESET_MASK); | 429 | musb_writel(reg_base, DA8XX_USB_CTRL_REG, DA8XX_SOFT_RESET_MASK); |
@@ -454,8 +446,7 @@ fail: | |||
454 | 446 | ||
455 | static int da8xx_musb_exit(struct musb *musb) | 447 | static int da8xx_musb_exit(struct musb *musb) |
456 | { | 448 | { |
457 | if (is_host_enabled(musb)) | 449 | del_timer_sync(&otg_workaround); |
458 | del_timer_sync(&otg_workaround); | ||
459 | 450 | ||
460 | phy_off(); | 451 | phy_off(); |
461 | 452 | ||
@@ -489,6 +480,7 @@ static int __devinit da8xx_probe(struct platform_device *pdev) | |||
489 | struct clk *clk; | 480 | struct clk *clk; |
490 | 481 | ||
491 | int ret = -ENOMEM; | 482 | int ret = -ENOMEM; |
483 | int musbid; | ||
492 | 484 | ||
493 | glue = kzalloc(sizeof(*glue), GFP_KERNEL); | 485 | glue = kzalloc(sizeof(*glue), GFP_KERNEL); |
494 | if (!glue) { | 486 | if (!glue) { |
@@ -496,25 +488,34 @@ static int __devinit da8xx_probe(struct platform_device *pdev) | |||
496 | goto err0; | 488 | goto err0; |
497 | } | 489 | } |
498 | 490 | ||
499 | musb = platform_device_alloc("musb-hdrc", -1); | 491 | /* get the musb id */ |
492 | musbid = musb_get_id(&pdev->dev, GFP_KERNEL); | ||
493 | if (musbid < 0) { | ||
494 | dev_err(&pdev->dev, "failed to allocate musb id\n"); | ||
495 | ret = -ENOMEM; | ||
496 | goto err1; | ||
497 | } | ||
498 | |||
499 | musb = platform_device_alloc("musb-hdrc", musbid); | ||
500 | if (!musb) { | 500 | if (!musb) { |
501 | dev_err(&pdev->dev, "failed to allocate musb device\n"); | 501 | dev_err(&pdev->dev, "failed to allocate musb device\n"); |
502 | goto err1; | 502 | goto err2; |
503 | } | 503 | } |
504 | 504 | ||
505 | clk = clk_get(&pdev->dev, "usb20"); | 505 | clk = clk_get(&pdev->dev, "usb20"); |
506 | if (IS_ERR(clk)) { | 506 | if (IS_ERR(clk)) { |
507 | dev_err(&pdev->dev, "failed to get clock\n"); | 507 | dev_err(&pdev->dev, "failed to get clock\n"); |
508 | ret = PTR_ERR(clk); | 508 | ret = PTR_ERR(clk); |
509 | goto err2; | 509 | goto err3; |
510 | } | 510 | } |
511 | 511 | ||
512 | ret = clk_enable(clk); | 512 | ret = clk_enable(clk); |
513 | if (ret) { | 513 | if (ret) { |
514 | dev_err(&pdev->dev, "failed to enable clock\n"); | 514 | dev_err(&pdev->dev, "failed to enable clock\n"); |
515 | goto err3; | 515 | goto err4; |
516 | } | 516 | } |
517 | 517 | ||
518 | musb->id = musbid; | ||
518 | musb->dev.parent = &pdev->dev; | 519 | musb->dev.parent = &pdev->dev; |
519 | musb->dev.dma_mask = &da8xx_dmamask; | 520 | musb->dev.dma_mask = &da8xx_dmamask; |
520 | musb->dev.coherent_dma_mask = da8xx_dmamask; | 521 | musb->dev.coherent_dma_mask = da8xx_dmamask; |
@@ -531,32 +532,35 @@ static int __devinit da8xx_probe(struct platform_device *pdev) | |||
531 | pdev->num_resources); | 532 | pdev->num_resources); |
532 | if (ret) { | 533 | if (ret) { |
533 | dev_err(&pdev->dev, "failed to add resources\n"); | 534 | dev_err(&pdev->dev, "failed to add resources\n"); |
534 | goto err4; | 535 | goto err5; |
535 | } | 536 | } |
536 | 537 | ||
537 | ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); | 538 | ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); |
538 | if (ret) { | 539 | if (ret) { |
539 | dev_err(&pdev->dev, "failed to add platform_data\n"); | 540 | dev_err(&pdev->dev, "failed to add platform_data\n"); |
540 | goto err4; | 541 | goto err5; |
541 | } | 542 | } |
542 | 543 | ||
543 | ret = platform_device_add(musb); | 544 | ret = platform_device_add(musb); |
544 | if (ret) { | 545 | if (ret) { |
545 | dev_err(&pdev->dev, "failed to register musb device\n"); | 546 | dev_err(&pdev->dev, "failed to register musb device\n"); |
546 | goto err4; | 547 | goto err5; |
547 | } | 548 | } |
548 | 549 | ||
549 | return 0; | 550 | return 0; |
550 | 551 | ||
551 | err4: | 552 | err5: |
552 | clk_disable(clk); | 553 | clk_disable(clk); |
553 | 554 | ||
554 | err3: | 555 | err4: |
555 | clk_put(clk); | 556 | clk_put(clk); |
556 | 557 | ||
557 | err2: | 558 | err3: |
558 | platform_device_put(musb); | 559 | platform_device_put(musb); |
559 | 560 | ||
561 | err2: | ||
562 | musb_put_id(&pdev->dev, musbid); | ||
563 | |||
560 | err1: | 564 | err1: |
561 | kfree(glue); | 565 | kfree(glue); |
562 | 566 | ||
@@ -568,6 +572,7 @@ static int __devexit da8xx_remove(struct platform_device *pdev) | |||
568 | { | 572 | { |
569 | struct da8xx_glue *glue = platform_get_drvdata(pdev); | 573 | struct da8xx_glue *glue = platform_get_drvdata(pdev); |
570 | 574 | ||
575 | musb_put_id(&pdev->dev, glue->musb->id); | ||
571 | platform_device_del(glue->musb); | 576 | platform_device_del(glue->musb); |
572 | platform_device_put(glue->musb); | 577 | platform_device_put(glue->musb); |
573 | clk_disable(glue->clk); | 578 | clk_disable(glue->clk); |
diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c index 472c8b42d38b..606bfd00cde6 100644 --- a/drivers/usb/musb/davinci.c +++ b/drivers/usb/musb/davinci.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/gpio.h> | 33 | #include <linux/gpio.h> |
34 | #include <linux/platform_device.h> | 34 | #include <linux/platform_device.h> |
35 | #include <linux/dma-mapping.h> | 35 | #include <linux/dma-mapping.h> |
36 | #include <linux/usb/nop-usb-xceiv.h> | ||
36 | 37 | ||
37 | #include <mach/cputype.h> | 38 | #include <mach/cputype.h> |
38 | #include <mach/hardware.h> | 39 | #include <mach/hardware.h> |
@@ -115,8 +116,7 @@ static void davinci_musb_enable(struct musb *musb) | |||
115 | dma_off = 0; | 116 | dma_off = 0; |
116 | 117 | ||
117 | /* force a DRVVBUS irq so we can start polling for ID change */ | 118 | /* force a DRVVBUS irq so we can start polling for ID change */ |
118 | if (is_otg_enabled(musb)) | 119 | musb_writel(musb->ctrl_base, DAVINCI_USB_INT_SET_REG, |
119 | musb_writel(musb->ctrl_base, DAVINCI_USB_INT_SET_REG, | ||
120 | DAVINCI_INTR_DRVVBUS << DAVINCI_USB_USBINT_SHIFT); | 120 | DAVINCI_INTR_DRVVBUS << DAVINCI_USB_USBINT_SHIFT); |
121 | } | 121 | } |
122 | 122 | ||
@@ -234,10 +234,8 @@ static void otg_timer(unsigned long _musb) | |||
234 | MUSB_INTR_VBUSERROR << DAVINCI_USB_USBINT_SHIFT); | 234 | MUSB_INTR_VBUSERROR << DAVINCI_USB_USBINT_SHIFT); |
235 | break; | 235 | break; |
236 | case OTG_STATE_B_IDLE: | 236 | case OTG_STATE_B_IDLE: |
237 | if (!is_peripheral_enabled(musb)) | 237 | /* |
238 | break; | 238 | * There's no ID-changed IRQ, so we have no good way to tell |
239 | |||
240 | /* There's no ID-changed IRQ, so we have no good way to tell | ||
241 | * when to switch to the A-Default state machine (by setting | 239 | * when to switch to the A-Default state machine (by setting |
242 | * the DEVCTL.SESSION flag). | 240 | * the DEVCTL.SESSION flag). |
243 | * | 241 | * |
@@ -315,8 +313,7 @@ static irqreturn_t davinci_musb_interrupt(int irq, void *__hci) | |||
315 | u8 devctl = musb_readb(mregs, MUSB_DEVCTL); | 313 | u8 devctl = musb_readb(mregs, MUSB_DEVCTL); |
316 | int err = musb->int_usb & MUSB_INTR_VBUSERROR; | 314 | int err = musb->int_usb & MUSB_INTR_VBUSERROR; |
317 | 315 | ||
318 | err = is_host_enabled(musb) | 316 | err = musb->int_usb & MUSB_INTR_VBUSERROR; |
319 | && (musb->int_usb & MUSB_INTR_VBUSERROR); | ||
320 | if (err) { | 317 | if (err) { |
321 | /* The Mentor core doesn't debounce VBUS as needed | 318 | /* The Mentor core doesn't debounce VBUS as needed |
322 | * to cope with device connect current spikes. This | 319 | * to cope with device connect current spikes. This |
@@ -332,7 +329,7 @@ static irqreturn_t davinci_musb_interrupt(int irq, void *__hci) | |||
332 | musb->xceiv->state = OTG_STATE_A_WAIT_VFALL; | 329 | musb->xceiv->state = OTG_STATE_A_WAIT_VFALL; |
333 | mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ); | 330 | mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ); |
334 | WARNING("VBUS error workaround (delay coming)\n"); | 331 | WARNING("VBUS error workaround (delay coming)\n"); |
335 | } else if (is_host_enabled(musb) && drvvbus) { | 332 | } else if (drvvbus) { |
336 | MUSB_HST_MODE(musb); | 333 | MUSB_HST_MODE(musb); |
337 | otg->default_a = 1; | 334 | otg->default_a = 1; |
338 | musb->xceiv->state = OTG_STATE_A_WAIT_VRISE; | 335 | musb->xceiv->state = OTG_STATE_A_WAIT_VRISE; |
@@ -365,8 +362,7 @@ static irqreturn_t davinci_musb_interrupt(int irq, void *__hci) | |||
365 | musb_writel(tibase, DAVINCI_USB_EOI_REG, 0); | 362 | musb_writel(tibase, DAVINCI_USB_EOI_REG, 0); |
366 | 363 | ||
367 | /* poll for ID change */ | 364 | /* poll for ID change */ |
368 | if (is_otg_enabled(musb) | 365 | if (musb->xceiv->state == OTG_STATE_B_IDLE) |
369 | && musb->xceiv->state == OTG_STATE_B_IDLE) | ||
370 | mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ); | 366 | mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ); |
371 | 367 | ||
372 | spin_unlock_irqrestore(&musb->lock, flags); | 368 | spin_unlock_irqrestore(&musb->lock, flags); |
@@ -397,8 +393,7 @@ static int davinci_musb_init(struct musb *musb) | |||
397 | if (revision == 0) | 393 | if (revision == 0) |
398 | goto fail; | 394 | goto fail; |
399 | 395 | ||
400 | if (is_host_enabled(musb)) | 396 | setup_timer(&otg_workaround, otg_timer, (unsigned long) musb); |
401 | setup_timer(&otg_workaround, otg_timer, (unsigned long) musb); | ||
402 | 397 | ||
403 | davinci_musb_source_power(musb, 0, 1); | 398 | davinci_musb_source_power(musb, 0, 1); |
404 | 399 | ||
@@ -419,12 +414,7 @@ static int davinci_musb_init(struct musb *musb) | |||
419 | if (cpu_is_davinci_dm355()) { | 414 | if (cpu_is_davinci_dm355()) { |
420 | u32 deepsleep = __raw_readl(DM355_DEEPSLEEP); | 415 | u32 deepsleep = __raw_readl(DM355_DEEPSLEEP); |
421 | 416 | ||
422 | if (is_host_enabled(musb)) { | 417 | deepsleep &= ~DRVVBUS_FORCE; |
423 | deepsleep &= ~DRVVBUS_OVERRIDE; | ||
424 | } else { | ||
425 | deepsleep &= ~DRVVBUS_FORCE; | ||
426 | deepsleep |= DRVVBUS_OVERRIDE; | ||
427 | } | ||
428 | __raw_writel(deepsleep, DM355_DEEPSLEEP); | 418 | __raw_writel(deepsleep, DM355_DEEPSLEEP); |
429 | } | 419 | } |
430 | 420 | ||
@@ -453,8 +443,7 @@ unregister: | |||
453 | 443 | ||
454 | static int davinci_musb_exit(struct musb *musb) | 444 | static int davinci_musb_exit(struct musb *musb) |
455 | { | 445 | { |
456 | if (is_host_enabled(musb)) | 446 | del_timer_sync(&otg_workaround); |
457 | del_timer_sync(&otg_workaround); | ||
458 | 447 | ||
459 | /* force VBUS off */ | 448 | /* force VBUS off */ |
460 | if (cpu_is_davinci_dm355()) { | 449 | if (cpu_is_davinci_dm355()) { |
@@ -468,7 +457,7 @@ static int davinci_musb_exit(struct musb *musb) | |||
468 | davinci_musb_source_power(musb, 0 /*off*/, 1); | 457 | davinci_musb_source_power(musb, 0 /*off*/, 1); |
469 | 458 | ||
470 | /* delay, to avoid problems with module reload */ | 459 | /* delay, to avoid problems with module reload */ |
471 | if (is_host_enabled(musb) && musb->xceiv->otg->default_a) { | 460 | if (musb->xceiv->otg->default_a) { |
472 | int maxdelay = 30; | 461 | int maxdelay = 30; |
473 | u8 devctl, warn = 0; | 462 | u8 devctl, warn = 0; |
474 | 463 | ||
@@ -523,6 +512,7 @@ static int __devinit davinci_probe(struct platform_device *pdev) | |||
523 | struct clk *clk; | 512 | struct clk *clk; |
524 | 513 | ||
525 | int ret = -ENOMEM; | 514 | int ret = -ENOMEM; |
515 | int musbid; | ||
526 | 516 | ||
527 | glue = kzalloc(sizeof(*glue), GFP_KERNEL); | 517 | glue = kzalloc(sizeof(*glue), GFP_KERNEL); |
528 | if (!glue) { | 518 | if (!glue) { |
@@ -530,25 +520,34 @@ static int __devinit davinci_probe(struct platform_device *pdev) | |||
530 | goto err0; | 520 | goto err0; |
531 | } | 521 | } |
532 | 522 | ||
533 | musb = platform_device_alloc("musb-hdrc", -1); | 523 | /* get the musb id */ |
524 | musbid = musb_get_id(&pdev->dev, GFP_KERNEL); | ||
525 | if (musbid < 0) { | ||
526 | dev_err(&pdev->dev, "failed to allocate musb id\n"); | ||
527 | ret = -ENOMEM; | ||
528 | goto err1; | ||
529 | } | ||
530 | |||
531 | musb = platform_device_alloc("musb-hdrc", musbid); | ||
534 | if (!musb) { | 532 | if (!musb) { |
535 | dev_err(&pdev->dev, "failed to allocate musb device\n"); | 533 | dev_err(&pdev->dev, "failed to allocate musb device\n"); |
536 | goto err1; | 534 | goto err2; |
537 | } | 535 | } |
538 | 536 | ||
539 | clk = clk_get(&pdev->dev, "usb"); | 537 | clk = clk_get(&pdev->dev, "usb"); |
540 | if (IS_ERR(clk)) { | 538 | if (IS_ERR(clk)) { |
541 | dev_err(&pdev->dev, "failed to get clock\n"); | 539 | dev_err(&pdev->dev, "failed to get clock\n"); |
542 | ret = PTR_ERR(clk); | 540 | ret = PTR_ERR(clk); |
543 | goto err2; | 541 | goto err3; |
544 | } | 542 | } |
545 | 543 | ||
546 | ret = clk_enable(clk); | 544 | ret = clk_enable(clk); |
547 | if (ret) { | 545 | if (ret) { |
548 | dev_err(&pdev->dev, "failed to enable clock\n"); | 546 | dev_err(&pdev->dev, "failed to enable clock\n"); |
549 | goto err3; | 547 | goto err4; |
550 | } | 548 | } |
551 | 549 | ||
550 | musb->id = musbid; | ||
552 | musb->dev.parent = &pdev->dev; | 551 | musb->dev.parent = &pdev->dev; |
553 | musb->dev.dma_mask = &davinci_dmamask; | 552 | musb->dev.dma_mask = &davinci_dmamask; |
554 | musb->dev.coherent_dma_mask = davinci_dmamask; | 553 | musb->dev.coherent_dma_mask = davinci_dmamask; |
@@ -565,32 +564,35 @@ static int __devinit davinci_probe(struct platform_device *pdev) | |||
565 | pdev->num_resources); | 564 | pdev->num_resources); |
566 | if (ret) { | 565 | if (ret) { |
567 | dev_err(&pdev->dev, "failed to add resources\n"); | 566 | dev_err(&pdev->dev, "failed to add resources\n"); |
568 | goto err4; | 567 | goto err5; |
569 | } | 568 | } |
570 | 569 | ||
571 | ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); | 570 | ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); |
572 | if (ret) { | 571 | if (ret) { |
573 | dev_err(&pdev->dev, "failed to add platform_data\n"); | 572 | dev_err(&pdev->dev, "failed to add platform_data\n"); |
574 | goto err4; | 573 | goto err5; |
575 | } | 574 | } |
576 | 575 | ||
577 | ret = platform_device_add(musb); | 576 | ret = platform_device_add(musb); |
578 | if (ret) { | 577 | if (ret) { |
579 | dev_err(&pdev->dev, "failed to register musb device\n"); | 578 | dev_err(&pdev->dev, "failed to register musb device\n"); |
580 | goto err4; | 579 | goto err5; |
581 | } | 580 | } |
582 | 581 | ||
583 | return 0; | 582 | return 0; |
584 | 583 | ||
585 | err4: | 584 | err5: |
586 | clk_disable(clk); | 585 | clk_disable(clk); |
587 | 586 | ||
588 | err3: | 587 | err4: |
589 | clk_put(clk); | 588 | clk_put(clk); |
590 | 589 | ||
591 | err2: | 590 | err3: |
592 | platform_device_put(musb); | 591 | platform_device_put(musb); |
593 | 592 | ||
593 | err2: | ||
594 | musb_put_id(&pdev->dev, musbid); | ||
595 | |||
594 | err1: | 596 | err1: |
595 | kfree(glue); | 597 | kfree(glue); |
596 | 598 | ||
@@ -602,6 +604,7 @@ static int __devexit davinci_remove(struct platform_device *pdev) | |||
602 | { | 604 | { |
603 | struct davinci_glue *glue = platform_get_drvdata(pdev); | 605 | struct davinci_glue *glue = platform_get_drvdata(pdev); |
604 | 606 | ||
607 | musb_put_id(&pdev->dev, glue->musb->id); | ||
605 | platform_device_del(glue->musb); | 608 | platform_device_del(glue->musb); |
606 | platform_device_put(glue->musb); | 609 | platform_device_put(glue->musb); |
607 | clk_disable(glue->clk); | 610 | clk_disable(glue->clk); |
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index 26f1befb4896..bb56a0e8b23b 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c | |||
@@ -99,6 +99,8 @@ | |||
99 | #include <linux/prefetch.h> | 99 | #include <linux/prefetch.h> |
100 | #include <linux/platform_device.h> | 100 | #include <linux/platform_device.h> |
101 | #include <linux/io.h> | 101 | #include <linux/io.h> |
102 | #include <linux/idr.h> | ||
103 | #include <linux/dma-mapping.h> | ||
102 | 104 | ||
103 | #include "musb_core.h" | 105 | #include "musb_core.h" |
104 | 106 | ||
@@ -114,6 +116,7 @@ | |||
114 | 116 | ||
115 | #define MUSB_DRIVER_NAME "musb-hdrc" | 117 | #define MUSB_DRIVER_NAME "musb-hdrc" |
116 | const char musb_driver_name[] = MUSB_DRIVER_NAME; | 118 | const char musb_driver_name[] = MUSB_DRIVER_NAME; |
119 | static DEFINE_IDA(musb_ida); | ||
117 | 120 | ||
118 | MODULE_DESCRIPTION(DRIVER_INFO); | 121 | MODULE_DESCRIPTION(DRIVER_INFO); |
119 | MODULE_AUTHOR(DRIVER_AUTHOR); | 122 | MODULE_AUTHOR(DRIVER_AUTHOR); |
@@ -130,6 +133,35 @@ static inline struct musb *dev_to_musb(struct device *dev) | |||
130 | 133 | ||
131 | /*-------------------------------------------------------------------------*/ | 134 | /*-------------------------------------------------------------------------*/ |
132 | 135 | ||
136 | int musb_get_id(struct device *dev, gfp_t gfp_mask) | ||
137 | { | ||
138 | int ret; | ||
139 | int id; | ||
140 | |||
141 | ret = ida_pre_get(&musb_ida, gfp_mask); | ||
142 | if (!ret) { | ||
143 | dev_err(dev, "failed to reserve resource for id\n"); | ||
144 | return -ENOMEM; | ||
145 | } | ||
146 | |||
147 | ret = ida_get_new(&musb_ida, &id); | ||
148 | if (ret < 0) { | ||
149 | dev_err(dev, "failed to allocate a new id\n"); | ||
150 | return ret; | ||
151 | } | ||
152 | |||
153 | return id; | ||
154 | } | ||
155 | EXPORT_SYMBOL_GPL(musb_get_id); | ||
156 | |||
157 | void musb_put_id(struct device *dev, int id) | ||
158 | { | ||
159 | |||
160 | dev_dbg(dev, "removing id %d\n", id); | ||
161 | ida_remove(&musb_ida, id); | ||
162 | } | ||
163 | EXPORT_SYMBOL_GPL(musb_put_id); | ||
164 | |||
133 | #ifndef CONFIG_BLACKFIN | 165 | #ifndef CONFIG_BLACKFIN |
134 | static int musb_ulpi_read(struct usb_phy *phy, u32 offset) | 166 | static int musb_ulpi_read(struct usb_phy *phy, u32 offset) |
135 | { | 167 | { |
@@ -234,6 +266,9 @@ void musb_write_fifo(struct musb_hw_ep *hw_ep, u16 len, const u8 *src) | |||
234 | struct musb *musb = hw_ep->musb; | 266 | struct musb *musb = hw_ep->musb; |
235 | void __iomem *fifo = hw_ep->fifo; | 267 | void __iomem *fifo = hw_ep->fifo; |
236 | 268 | ||
269 | if (unlikely(len == 0)) | ||
270 | return; | ||
271 | |||
237 | prefetch((u8 *)src); | 272 | prefetch((u8 *)src); |
238 | 273 | ||
239 | dev_dbg(musb->controller, "%cX ep%d fifo %p count %d buf %p\n", | 274 | dev_dbg(musb->controller, "%cX ep%d fifo %p count %d buf %p\n", |
@@ -276,6 +311,9 @@ void musb_read_fifo(struct musb_hw_ep *hw_ep, u16 len, u8 *dst) | |||
276 | struct musb *musb = hw_ep->musb; | 311 | struct musb *musb = hw_ep->musb; |
277 | void __iomem *fifo = hw_ep->fifo; | 312 | void __iomem *fifo = hw_ep->fifo; |
278 | 313 | ||
314 | if (unlikely(len == 0)) | ||
315 | return; | ||
316 | |||
279 | dev_dbg(musb->controller, "%cX ep%d fifo %p count %d buf %p\n", | 317 | dev_dbg(musb->controller, "%cX ep%d fifo %p count %d buf %p\n", |
280 | 'R', hw_ep->epnum, fifo, len, dst); | 318 | 'R', hw_ep->epnum, fifo, len, dst); |
281 | 319 | ||
@@ -348,7 +386,7 @@ void musb_load_testpacket(struct musb *musb) | |||
348 | /* | 386 | /* |
349 | * Handles OTG hnp timeouts, such as b_ase0_brst | 387 | * Handles OTG hnp timeouts, such as b_ase0_brst |
350 | */ | 388 | */ |
351 | void musb_otg_timer_func(unsigned long data) | 389 | static void musb_otg_timer_func(unsigned long data) |
352 | { | 390 | { |
353 | struct musb *musb = (struct musb *)data; | 391 | struct musb *musb = (struct musb *)data; |
354 | unsigned long flags; | 392 | unsigned long flags; |
@@ -643,8 +681,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, | |||
643 | break; | 681 | break; |
644 | case OTG_STATE_B_PERIPHERAL: | 682 | case OTG_STATE_B_PERIPHERAL: |
645 | musb_g_suspend(musb); | 683 | musb_g_suspend(musb); |
646 | musb->is_active = is_otg_enabled(musb) | 684 | musb->is_active = otg->gadget->b_hnp_enable; |
647 | && otg->gadget->b_hnp_enable; | ||
648 | if (musb->is_active) { | 685 | if (musb->is_active) { |
649 | musb->xceiv->state = OTG_STATE_B_WAIT_ACON; | 686 | musb->xceiv->state = OTG_STATE_B_WAIT_ACON; |
650 | dev_dbg(musb->controller, "HNP: Setting timer for b_ase0_brst\n"); | 687 | dev_dbg(musb->controller, "HNP: Setting timer for b_ase0_brst\n"); |
@@ -660,8 +697,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, | |||
660 | break; | 697 | break; |
661 | case OTG_STATE_A_HOST: | 698 | case OTG_STATE_A_HOST: |
662 | musb->xceiv->state = OTG_STATE_A_SUSPEND; | 699 | musb->xceiv->state = OTG_STATE_A_SUSPEND; |
663 | musb->is_active = is_otg_enabled(musb) | 700 | musb->is_active = otg->host->b_hnp_enable; |
664 | && otg->host->b_hnp_enable; | ||
665 | break; | 701 | break; |
666 | case OTG_STATE_B_HOST: | 702 | case OTG_STATE_B_HOST: |
667 | /* Transition to B_PERIPHERAL, see 6.8.2.6 p 44 */ | 703 | /* Transition to B_PERIPHERAL, see 6.8.2.6 p 44 */ |
@@ -749,7 +785,7 @@ b_host: | |||
749 | case OTG_STATE_A_SUSPEND: | 785 | case OTG_STATE_A_SUSPEND: |
750 | usb_hcd_resume_root_hub(musb_to_hcd(musb)); | 786 | usb_hcd_resume_root_hub(musb_to_hcd(musb)); |
751 | musb_root_disconnect(musb); | 787 | musb_root_disconnect(musb); |
752 | if (musb->a_wait_bcon != 0 && is_otg_enabled(musb)) | 788 | if (musb->a_wait_bcon != 0) |
753 | musb_platform_try_idle(musb, jiffies | 789 | musb_platform_try_idle(musb, jiffies |
754 | + msecs_to_jiffies(musb->a_wait_bcon)); | 790 | + msecs_to_jiffies(musb->a_wait_bcon)); |
755 | break; | 791 | break; |
@@ -787,7 +823,7 @@ b_host: | |||
787 | */ | 823 | */ |
788 | if (int_usb & MUSB_INTR_RESET) { | 824 | if (int_usb & MUSB_INTR_RESET) { |
789 | handled = IRQ_HANDLED; | 825 | handled = IRQ_HANDLED; |
790 | if (is_host_capable() && (devctl & MUSB_DEVCTL_HM) != 0) { | 826 | if ((devctl & MUSB_DEVCTL_HM) != 0) { |
791 | /* | 827 | /* |
792 | * Looks like non-HS BABBLE can be ignored, but | 828 | * Looks like non-HS BABBLE can be ignored, but |
793 | * HS BABBLE is an error condition. For HS the solution | 829 | * HS BABBLE is an error condition. For HS the solution |
@@ -801,7 +837,7 @@ b_host: | |||
801 | ERR("Stopping host session -- babble\n"); | 837 | ERR("Stopping host session -- babble\n"); |
802 | musb_writeb(musb->mregs, MUSB_DEVCTL, 0); | 838 | musb_writeb(musb->mregs, MUSB_DEVCTL, 0); |
803 | } | 839 | } |
804 | } else if (is_peripheral_capable()) { | 840 | } else { |
805 | dev_dbg(musb->controller, "BUS RESET as %s\n", | 841 | dev_dbg(musb->controller, "BUS RESET as %s\n", |
806 | otg_state_string(musb->xceiv->state)); | 842 | otg_state_string(musb->xceiv->state)); |
807 | switch (musb->xceiv->state) { | 843 | switch (musb->xceiv->state) { |
@@ -925,25 +961,16 @@ void musb_start(struct musb *musb) | |||
925 | devctl = musb_readb(regs, MUSB_DEVCTL); | 961 | devctl = musb_readb(regs, MUSB_DEVCTL); |
926 | devctl &= ~MUSB_DEVCTL_SESSION; | 962 | devctl &= ~MUSB_DEVCTL_SESSION; |
927 | 963 | ||
928 | if (is_otg_enabled(musb)) { | 964 | /* session started after: |
929 | /* session started after: | 965 | * (a) ID-grounded irq, host mode; |
930 | * (a) ID-grounded irq, host mode; | 966 | * (b) vbus present/connect IRQ, peripheral mode; |
931 | * (b) vbus present/connect IRQ, peripheral mode; | 967 | * (c) peripheral initiates, using SRP |
932 | * (c) peripheral initiates, using SRP | 968 | */ |
933 | */ | 969 | if ((devctl & MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS) |
934 | if ((devctl & MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS) | 970 | musb->is_active = 1; |
935 | musb->is_active = 1; | 971 | else |
936 | else | ||
937 | devctl |= MUSB_DEVCTL_SESSION; | ||
938 | |||
939 | } else if (is_host_enabled(musb)) { | ||
940 | /* assume ID pin is hard-wired to ground */ | ||
941 | devctl |= MUSB_DEVCTL_SESSION; | 972 | devctl |= MUSB_DEVCTL_SESSION; |
942 | 973 | ||
943 | } else /* peripheral is enabled */ { | ||
944 | if ((devctl & MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS) | ||
945 | musb->is_active = 1; | ||
946 | } | ||
947 | musb_platform_enable(musb); | 974 | musb_platform_enable(musb); |
948 | musb_writeb(regs, MUSB_DEVCTL, devctl); | 975 | musb_writeb(regs, MUSB_DEVCTL, devctl); |
949 | } | 976 | } |
@@ -1007,8 +1034,6 @@ static void musb_shutdown(struct platform_device *pdev) | |||
1007 | musb_generic_disable(musb); | 1034 | musb_generic_disable(musb); |
1008 | spin_unlock_irqrestore(&musb->lock, flags); | 1035 | spin_unlock_irqrestore(&musb->lock, flags); |
1009 | 1036 | ||
1010 | if (!is_otg_enabled(musb) && is_host_enabled(musb)) | ||
1011 | usb_remove_hcd(musb_to_hcd(musb)); | ||
1012 | musb_writeb(musb->mregs, MUSB_DEVCTL, 0); | 1037 | musb_writeb(musb->mregs, MUSB_DEVCTL, 0); |
1013 | musb_platform_exit(musb); | 1038 | musb_platform_exit(musb); |
1014 | 1039 | ||
@@ -1302,7 +1327,7 @@ done: | |||
1302 | if (offset < 0) { | 1327 | if (offset < 0) { |
1303 | pr_debug("%s: mem overrun, ep %d\n", | 1328 | pr_debug("%s: mem overrun, ep %d\n", |
1304 | musb_driver_name, epn); | 1329 | musb_driver_name, epn); |
1305 | return -EINVAL; | 1330 | return offset; |
1306 | } | 1331 | } |
1307 | epn++; | 1332 | epn++; |
1308 | musb->nr_endpoints = max(epn, musb->nr_endpoints); | 1333 | musb->nr_endpoints = max(epn, musb->nr_endpoints); |
@@ -1330,7 +1355,7 @@ static int __devinit ep_config_from_hw(struct musb *musb) | |||
1330 | { | 1355 | { |
1331 | u8 epnum = 0; | 1356 | u8 epnum = 0; |
1332 | struct musb_hw_ep *hw_ep; | 1357 | struct musb_hw_ep *hw_ep; |
1333 | void *mbase = musb->mregs; | 1358 | void __iomem *mbase = musb->mregs; |
1334 | int ret = 0; | 1359 | int ret = 0; |
1335 | 1360 | ||
1336 | dev_dbg(musb->controller, "<== static silicon ep config\n"); | 1361 | dev_dbg(musb->controller, "<== static silicon ep config\n"); |
@@ -1571,13 +1596,10 @@ irqreturn_t musb_interrupt(struct musb *musb) | |||
1571 | /* musb_ep_select(musb->mregs, ep_num); */ | 1596 | /* musb_ep_select(musb->mregs, ep_num); */ |
1572 | /* REVISIT just retval = ep->rx_irq(...) */ | 1597 | /* REVISIT just retval = ep->rx_irq(...) */ |
1573 | retval = IRQ_HANDLED; | 1598 | retval = IRQ_HANDLED; |
1574 | if (devctl & MUSB_DEVCTL_HM) { | 1599 | if (devctl & MUSB_DEVCTL_HM) |
1575 | if (is_host_capable()) | 1600 | musb_host_rx(musb, ep_num); |
1576 | musb_host_rx(musb, ep_num); | 1601 | else |
1577 | } else { | 1602 | musb_g_rx(musb, ep_num); |
1578 | if (is_peripheral_capable()) | ||
1579 | musb_g_rx(musb, ep_num); | ||
1580 | } | ||
1581 | } | 1603 | } |
1582 | 1604 | ||
1583 | reg >>= 1; | 1605 | reg >>= 1; |
@@ -1592,13 +1614,10 @@ irqreturn_t musb_interrupt(struct musb *musb) | |||
1592 | /* musb_ep_select(musb->mregs, ep_num); */ | 1614 | /* musb_ep_select(musb->mregs, ep_num); */ |
1593 | /* REVISIT just retval |= ep->tx_irq(...) */ | 1615 | /* REVISIT just retval |= ep->tx_irq(...) */ |
1594 | retval = IRQ_HANDLED; | 1616 | retval = IRQ_HANDLED; |
1595 | if (devctl & MUSB_DEVCTL_HM) { | 1617 | if (devctl & MUSB_DEVCTL_HM) |
1596 | if (is_host_capable()) | 1618 | musb_host_tx(musb, ep_num); |
1597 | musb_host_tx(musb, ep_num); | 1619 | else |
1598 | } else { | 1620 | musb_g_tx(musb, ep_num); |
1599 | if (is_peripheral_capable()) | ||
1600 | musb_g_tx(musb, ep_num); | ||
1601 | } | ||
1602 | } | 1621 | } |
1603 | reg >>= 1; | 1622 | reg >>= 1; |
1604 | ep_num++; | 1623 | ep_num++; |
@@ -1634,22 +1653,16 @@ void musb_dma_completion(struct musb *musb, u8 epnum, u8 transmit) | |||
1634 | } else { | 1653 | } else { |
1635 | /* endpoints 1..15 */ | 1654 | /* endpoints 1..15 */ |
1636 | if (transmit) { | 1655 | if (transmit) { |
1637 | if (devctl & MUSB_DEVCTL_HM) { | 1656 | if (devctl & MUSB_DEVCTL_HM) |
1638 | if (is_host_capable()) | 1657 | musb_host_tx(musb, epnum); |
1639 | musb_host_tx(musb, epnum); | 1658 | else |
1640 | } else { | 1659 | musb_g_tx(musb, epnum); |
1641 | if (is_peripheral_capable()) | ||
1642 | musb_g_tx(musb, epnum); | ||
1643 | } | ||
1644 | } else { | 1660 | } else { |
1645 | /* receive */ | 1661 | /* receive */ |
1646 | if (devctl & MUSB_DEVCTL_HM) { | 1662 | if (devctl & MUSB_DEVCTL_HM) |
1647 | if (is_host_capable()) | 1663 | musb_host_rx(musb, epnum); |
1648 | musb_host_rx(musb, epnum); | 1664 | else |
1649 | } else { | 1665 | musb_g_rx(musb, epnum); |
1650 | if (is_peripheral_capable()) | ||
1651 | musb_g_rx(musb, epnum); | ||
1652 | } | ||
1653 | } | 1666 | } |
1654 | } | 1667 | } |
1655 | } | 1668 | } |
@@ -1785,10 +1798,9 @@ static const struct attribute_group musb_attr_group = { | |||
1785 | static void musb_irq_work(struct work_struct *data) | 1798 | static void musb_irq_work(struct work_struct *data) |
1786 | { | 1799 | { |
1787 | struct musb *musb = container_of(data, struct musb, irq_work); | 1800 | struct musb *musb = container_of(data, struct musb, irq_work); |
1788 | static int old_state; | ||
1789 | 1801 | ||
1790 | if (musb->xceiv->state != old_state) { | 1802 | if (musb->xceiv->state != musb->xceiv_old_state) { |
1791 | old_state = musb->xceiv->state; | 1803 | musb->xceiv_old_state = musb->xceiv->state; |
1792 | sysfs_notify(&musb->controller->kobj, NULL, "mode"); | 1804 | sysfs_notify(&musb->controller->kobj, NULL, "mode"); |
1793 | } | 1805 | } |
1794 | } | 1806 | } |
@@ -1862,15 +1874,15 @@ static void musb_free(struct musb *musb) | |||
1862 | dma_controller_destroy(c); | 1874 | dma_controller_destroy(c); |
1863 | } | 1875 | } |
1864 | 1876 | ||
1865 | kfree(musb); | 1877 | usb_put_hcd(musb_to_hcd(musb)); |
1866 | } | 1878 | } |
1867 | 1879 | ||
1868 | /* | 1880 | /* |
1869 | * Perform generic per-controller initialization. | 1881 | * Perform generic per-controller initialization. |
1870 | * | 1882 | * |
1871 | * @pDevice: the controller (already clocked, etc) | 1883 | * @dev: the controller (already clocked, etc) |
1872 | * @nIrq: irq | 1884 | * @nIrq: IRQ number |
1873 | * @mregs: virtual address of controller registers, | 1885 | * @ctrl: virtual address of controller registers, |
1874 | * not yet corrected for platform-specific offsets | 1886 | * not yet corrected for platform-specific offsets |
1875 | */ | 1887 | */ |
1876 | static int __devinit | 1888 | static int __devinit |
@@ -1879,6 +1891,7 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl) | |||
1879 | int status; | 1891 | int status; |
1880 | struct musb *musb; | 1892 | struct musb *musb; |
1881 | struct musb_hdrc_platform_data *plat = dev->platform_data; | 1893 | struct musb_hdrc_platform_data *plat = dev->platform_data; |
1894 | struct usb_hcd *hcd; | ||
1882 | 1895 | ||
1883 | /* The driver might handle more features than the board; OK. | 1896 | /* The driver might handle more features than the board; OK. |
1884 | * Fail when the board needs a feature that's not enabled. | 1897 | * Fail when the board needs a feature that's not enabled. |
@@ -1901,7 +1914,6 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl) | |||
1901 | pm_runtime_enable(musb->controller); | 1914 | pm_runtime_enable(musb->controller); |
1902 | 1915 | ||
1903 | spin_lock_init(&musb->lock); | 1916 | spin_lock_init(&musb->lock); |
1904 | musb->board_mode = plat->mode; | ||
1905 | musb->board_set_power = plat->set_power; | 1917 | musb->board_set_power = plat->set_power; |
1906 | musb->min_power = plat->min_power; | 1918 | musb->min_power = plat->min_power; |
1907 | musb->ops = plat->platform_ops; | 1919 | musb->ops = plat->platform_ops; |
@@ -1972,7 +1984,7 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl) | |||
1972 | goto fail3; | 1984 | goto fail3; |
1973 | } | 1985 | } |
1974 | musb->nIrq = nIrq; | 1986 | musb->nIrq = nIrq; |
1975 | /* FIXME this handles wakeup irqs wrong */ | 1987 | /* FIXME this handles wakeup irqs wrong */ |
1976 | if (enable_irq_wake(nIrq) == 0) { | 1988 | if (enable_irq_wake(nIrq) == 0) { |
1977 | musb->irq_wake = 1; | 1989 | musb->irq_wake = 1; |
1978 | device_init_wakeup(dev, 1); | 1990 | device_init_wakeup(dev, 1); |
@@ -1981,58 +1993,25 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl) | |||
1981 | } | 1993 | } |
1982 | 1994 | ||
1983 | /* host side needs more setup */ | 1995 | /* host side needs more setup */ |
1984 | if (is_host_enabled(musb)) { | 1996 | hcd = musb_to_hcd(musb); |
1985 | struct usb_hcd *hcd = musb_to_hcd(musb); | 1997 | otg_set_host(musb->xceiv->otg, &hcd->self); |
1986 | 1998 | hcd->self.otg_port = 1; | |
1987 | otg_set_host(musb->xceiv->otg, &hcd->self); | 1999 | musb->xceiv->otg->host = &hcd->self; |
1988 | 2000 | hcd->power_budget = 2 * (plat->power ? : 250); | |
1989 | if (is_otg_enabled(musb)) | 2001 | |
1990 | hcd->self.otg_port = 1; | 2002 | /* program PHY to use external vBus if required */ |
1991 | musb->xceiv->otg->host = &hcd->self; | 2003 | if (plat->extvbus) { |
1992 | hcd->power_budget = 2 * (plat->power ? : 250); | 2004 | u8 busctl = musb_read_ulpi_buscontrol(musb->mregs); |
1993 | 2005 | busctl |= MUSB_ULPI_USE_EXTVBUS; | |
1994 | /* program PHY to use external vBus if required */ | 2006 | musb_write_ulpi_buscontrol(musb->mregs, busctl); |
1995 | if (plat->extvbus) { | ||
1996 | u8 busctl = musb_read_ulpi_buscontrol(musb->mregs); | ||
1997 | busctl |= MUSB_ULPI_USE_EXTVBUS; | ||
1998 | musb_write_ulpi_buscontrol(musb->mregs, busctl); | ||
1999 | } | ||
2000 | } | 2007 | } |
2001 | 2008 | ||
2002 | /* For the host-only role, we can activate right away. | 2009 | MUSB_DEV_MODE(musb); |
2003 | * (We expect the ID pin to be forcibly grounded!!) | 2010 | musb->xceiv->otg->default_a = 0; |
2004 | * Otherwise, wait till the gadget driver hooks up. | 2011 | musb->xceiv->state = OTG_STATE_B_IDLE; |
2005 | */ | ||
2006 | if (!is_otg_enabled(musb) && is_host_enabled(musb)) { | ||
2007 | struct usb_hcd *hcd = musb_to_hcd(musb); | ||
2008 | |||
2009 | MUSB_HST_MODE(musb); | ||
2010 | musb->xceiv->otg->default_a = 1; | ||
2011 | musb->xceiv->state = OTG_STATE_A_IDLE; | ||
2012 | |||
2013 | status = usb_add_hcd(musb_to_hcd(musb), 0, 0); | ||
2014 | |||
2015 | hcd->self.uses_pio_for_control = 1; | ||
2016 | dev_dbg(musb->controller, "%s mode, status %d, devctl %02x %c\n", | ||
2017 | "HOST", status, | ||
2018 | musb_readb(musb->mregs, MUSB_DEVCTL), | ||
2019 | (musb_readb(musb->mregs, MUSB_DEVCTL) | ||
2020 | & MUSB_DEVCTL_BDEVICE | ||
2021 | ? 'B' : 'A')); | ||
2022 | |||
2023 | } else /* peripheral is enabled */ { | ||
2024 | MUSB_DEV_MODE(musb); | ||
2025 | musb->xceiv->otg->default_a = 0; | ||
2026 | musb->xceiv->state = OTG_STATE_B_IDLE; | ||
2027 | |||
2028 | status = musb_gadget_setup(musb); | ||
2029 | 2012 | ||
2030 | dev_dbg(musb->controller, "%s mode, status %d, dev%02x\n", | 2013 | status = musb_gadget_setup(musb); |
2031 | is_otg_enabled(musb) ? "OTG" : "PERIPHERAL", | ||
2032 | status, | ||
2033 | musb_readb(musb->mregs, MUSB_DEVCTL)); | ||
2034 | 2014 | ||
2035 | } | ||
2036 | if (status < 0) | 2015 | if (status < 0) |
2037 | goto fail3; | 2016 | goto fail3; |
2038 | 2017 | ||
@@ -2048,28 +2027,13 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl) | |||
2048 | 2027 | ||
2049 | pm_runtime_put(musb->controller); | 2028 | pm_runtime_put(musb->controller); |
2050 | 2029 | ||
2051 | dev_info(dev, "USB %s mode controller at %p using %s, IRQ %d\n", | ||
2052 | ({char *s; | ||
2053 | switch (musb->board_mode) { | ||
2054 | case MUSB_HOST: s = "Host"; break; | ||
2055 | case MUSB_PERIPHERAL: s = "Peripheral"; break; | ||
2056 | default: s = "OTG"; break; | ||
2057 | }; s; }), | ||
2058 | ctrl, | ||
2059 | (is_dma_capable() && musb->dma_controller) | ||
2060 | ? "DMA" : "PIO", | ||
2061 | musb->nIrq); | ||
2062 | |||
2063 | return 0; | 2030 | return 0; |
2064 | 2031 | ||
2065 | fail5: | 2032 | fail5: |
2066 | musb_exit_debugfs(musb); | 2033 | musb_exit_debugfs(musb); |
2067 | 2034 | ||
2068 | fail4: | 2035 | fail4: |
2069 | if (!is_otg_enabled(musb) && is_host_enabled(musb)) | 2036 | musb_gadget_cleanup(musb); |
2070 | usb_remove_hcd(musb_to_hcd(musb)); | ||
2071 | else | ||
2072 | musb_gadget_cleanup(musb); | ||
2073 | 2037 | ||
2074 | fail3: | 2038 | fail3: |
2075 | pm_runtime_put_sync(musb->controller); | 2039 | pm_runtime_put_sync(musb->controller); |
@@ -2096,11 +2060,6 @@ fail0: | |||
2096 | /* all implementations (PCI bridge to FPGA, VLYNQ, etc) should just | 2060 | /* all implementations (PCI bridge to FPGA, VLYNQ, etc) should just |
2097 | * bridge to a platform device; this driver then suffices. | 2061 | * bridge to a platform device; this driver then suffices. |
2098 | */ | 2062 | */ |
2099 | |||
2100 | #ifndef CONFIG_MUSB_PIO_ONLY | ||
2101 | static u64 *orig_dma_mask; | ||
2102 | #endif | ||
2103 | |||
2104 | static int __devinit musb_probe(struct platform_device *pdev) | 2063 | static int __devinit musb_probe(struct platform_device *pdev) |
2105 | { | 2064 | { |
2106 | struct device *dev = &pdev->dev; | 2065 | struct device *dev = &pdev->dev; |
@@ -2119,10 +2078,6 @@ static int __devinit musb_probe(struct platform_device *pdev) | |||
2119 | return -ENOMEM; | 2078 | return -ENOMEM; |
2120 | } | 2079 | } |
2121 | 2080 | ||
2122 | #ifndef CONFIG_MUSB_PIO_ONLY | ||
2123 | /* clobbered by use_dma=n */ | ||
2124 | orig_dma_mask = dev->dma_mask; | ||
2125 | #endif | ||
2126 | status = musb_init_controller(dev, irq, base); | 2081 | status = musb_init_controller(dev, irq, base); |
2127 | if (status < 0) | 2082 | if (status < 0) |
2128 | iounmap(base); | 2083 | iounmap(base); |
@@ -2132,7 +2087,8 @@ static int __devinit musb_probe(struct platform_device *pdev) | |||
2132 | 2087 | ||
2133 | static int __devexit musb_remove(struct platform_device *pdev) | 2088 | static int __devexit musb_remove(struct platform_device *pdev) |
2134 | { | 2089 | { |
2135 | struct musb *musb = dev_to_musb(&pdev->dev); | 2090 | struct device *dev = &pdev->dev; |
2091 | struct musb *musb = dev_to_musb(dev); | ||
2136 | void __iomem *ctrl_base = musb->ctrl_base; | 2092 | void __iomem *ctrl_base = musb->ctrl_base; |
2137 | 2093 | ||
2138 | /* this gets called on rmmod. | 2094 | /* this gets called on rmmod. |
@@ -2145,9 +2101,9 @@ static int __devexit musb_remove(struct platform_device *pdev) | |||
2145 | 2101 | ||
2146 | musb_free(musb); | 2102 | musb_free(musb); |
2147 | iounmap(ctrl_base); | 2103 | iounmap(ctrl_base); |
2148 | device_init_wakeup(&pdev->dev, 0); | 2104 | device_init_wakeup(dev, 0); |
2149 | #ifndef CONFIG_MUSB_PIO_ONLY | 2105 | #ifndef CONFIG_MUSB_PIO_ONLY |
2150 | pdev->dev.dma_mask = orig_dma_mask; | 2106 | dma_set_mask(dev, *dev->parent->dma_mask); |
2151 | #endif | 2107 | #endif |
2152 | return 0; | 2108 | return 0; |
2153 | } | 2109 | } |
@@ -2160,11 +2116,9 @@ static void musb_save_context(struct musb *musb) | |||
2160 | void __iomem *musb_base = musb->mregs; | 2116 | void __iomem *musb_base = musb->mregs; |
2161 | void __iomem *epio; | 2117 | void __iomem *epio; |
2162 | 2118 | ||
2163 | if (is_host_enabled(musb)) { | 2119 | musb->context.frame = musb_readw(musb_base, MUSB_FRAME); |
2164 | musb->context.frame = musb_readw(musb_base, MUSB_FRAME); | 2120 | musb->context.testmode = musb_readb(musb_base, MUSB_TESTMODE); |
2165 | musb->context.testmode = musb_readb(musb_base, MUSB_TESTMODE); | 2121 | musb->context.busctl = musb_read_ulpi_buscontrol(musb->mregs); |
2166 | musb->context.busctl = musb_read_ulpi_buscontrol(musb->mregs); | ||
2167 | } | ||
2168 | musb->context.power = musb_readb(musb_base, MUSB_POWER); | 2122 | musb->context.power = musb_readb(musb_base, MUSB_POWER); |
2169 | musb->context.intrtxe = musb_readw(musb_base, MUSB_INTRTXE); | 2123 | musb->context.intrtxe = musb_readw(musb_base, MUSB_INTRTXE); |
2170 | musb->context.intrrxe = musb_readw(musb_base, MUSB_INTRRXE); | 2124 | musb->context.intrrxe = musb_readw(musb_base, MUSB_INTRRXE); |
@@ -2203,30 +2157,29 @@ static void musb_save_context(struct musb *musb) | |||
2203 | musb->context.index_regs[i].rxfifosz = | 2157 | musb->context.index_regs[i].rxfifosz = |
2204 | musb_read_rxfifosz(musb_base); | 2158 | musb_read_rxfifosz(musb_base); |
2205 | } | 2159 | } |
2206 | if (is_host_enabled(musb)) { | 2160 | |
2207 | musb->context.index_regs[i].txtype = | 2161 | musb->context.index_regs[i].txtype = |
2208 | musb_readb(epio, MUSB_TXTYPE); | 2162 | musb_readb(epio, MUSB_TXTYPE); |
2209 | musb->context.index_regs[i].txinterval = | 2163 | musb->context.index_regs[i].txinterval = |
2210 | musb_readb(epio, MUSB_TXINTERVAL); | 2164 | musb_readb(epio, MUSB_TXINTERVAL); |
2211 | musb->context.index_regs[i].rxtype = | 2165 | musb->context.index_regs[i].rxtype = |
2212 | musb_readb(epio, MUSB_RXTYPE); | 2166 | musb_readb(epio, MUSB_RXTYPE); |
2213 | musb->context.index_regs[i].rxinterval = | 2167 | musb->context.index_regs[i].rxinterval = |
2214 | musb_readb(epio, MUSB_RXINTERVAL); | 2168 | musb_readb(epio, MUSB_RXINTERVAL); |
2215 | 2169 | ||
2216 | musb->context.index_regs[i].txfunaddr = | 2170 | musb->context.index_regs[i].txfunaddr = |
2217 | musb_read_txfunaddr(musb_base, i); | 2171 | musb_read_txfunaddr(musb_base, i); |
2218 | musb->context.index_regs[i].txhubaddr = | 2172 | musb->context.index_regs[i].txhubaddr = |
2219 | musb_read_txhubaddr(musb_base, i); | 2173 | musb_read_txhubaddr(musb_base, i); |
2220 | musb->context.index_regs[i].txhubport = | 2174 | musb->context.index_regs[i].txhubport = |
2221 | musb_read_txhubport(musb_base, i); | 2175 | musb_read_txhubport(musb_base, i); |
2222 | 2176 | ||
2223 | musb->context.index_regs[i].rxfunaddr = | 2177 | musb->context.index_regs[i].rxfunaddr = |
2224 | musb_read_rxfunaddr(musb_base, i); | 2178 | musb_read_rxfunaddr(musb_base, i); |
2225 | musb->context.index_regs[i].rxhubaddr = | 2179 | musb->context.index_regs[i].rxhubaddr = |
2226 | musb_read_rxhubaddr(musb_base, i); | 2180 | musb_read_rxhubaddr(musb_base, i); |
2227 | musb->context.index_regs[i].rxhubport = | 2181 | musb->context.index_regs[i].rxhubport = |
2228 | musb_read_rxhubport(musb_base, i); | 2182 | musb_read_rxhubport(musb_base, i); |
2229 | } | ||
2230 | } | 2183 | } |
2231 | } | 2184 | } |
2232 | 2185 | ||
@@ -2237,11 +2190,9 @@ static void musb_restore_context(struct musb *musb) | |||
2237 | void __iomem *ep_target_regs; | 2190 | void __iomem *ep_target_regs; |
2238 | void __iomem *epio; | 2191 | void __iomem *epio; |
2239 | 2192 | ||
2240 | if (is_host_enabled(musb)) { | 2193 | musb_writew(musb_base, MUSB_FRAME, musb->context.frame); |
2241 | musb_writew(musb_base, MUSB_FRAME, musb->context.frame); | 2194 | musb_writeb(musb_base, MUSB_TESTMODE, musb->context.testmode); |
2242 | musb_writeb(musb_base, MUSB_TESTMODE, musb->context.testmode); | 2195 | musb_write_ulpi_buscontrol(musb->mregs, musb->context.busctl); |
2243 | musb_write_ulpi_buscontrol(musb->mregs, musb->context.busctl); | ||
2244 | } | ||
2245 | musb_writeb(musb_base, MUSB_POWER, musb->context.power); | 2196 | musb_writeb(musb_base, MUSB_POWER, musb->context.power); |
2246 | musb_writew(musb_base, MUSB_INTRTXE, musb->context.intrtxe); | 2197 | musb_writew(musb_base, MUSB_INTRTXE, musb->context.intrtxe); |
2247 | musb_writew(musb_base, MUSB_INTRRXE, musb->context.intrrxe); | 2198 | musb_writew(musb_base, MUSB_INTRRXE, musb->context.intrrxe); |
@@ -2280,33 +2231,31 @@ static void musb_restore_context(struct musb *musb) | |||
2280 | musb->context.index_regs[i].rxfifoadd); | 2231 | musb->context.index_regs[i].rxfifoadd); |
2281 | } | 2232 | } |
2282 | 2233 | ||
2283 | if (is_host_enabled(musb)) { | 2234 | musb_writeb(epio, MUSB_TXTYPE, |
2284 | musb_writeb(epio, MUSB_TXTYPE, | ||
2285 | musb->context.index_regs[i].txtype); | 2235 | musb->context.index_regs[i].txtype); |
2286 | musb_writeb(epio, MUSB_TXINTERVAL, | 2236 | musb_writeb(epio, MUSB_TXINTERVAL, |
2287 | musb->context.index_regs[i].txinterval); | 2237 | musb->context.index_regs[i].txinterval); |
2288 | musb_writeb(epio, MUSB_RXTYPE, | 2238 | musb_writeb(epio, MUSB_RXTYPE, |
2289 | musb->context.index_regs[i].rxtype); | 2239 | musb->context.index_regs[i].rxtype); |
2290 | musb_writeb(epio, MUSB_RXINTERVAL, | 2240 | musb_writeb(epio, MUSB_RXINTERVAL, |
2291 | 2241 | ||
2292 | musb->context.index_regs[i].rxinterval); | 2242 | musb->context.index_regs[i].rxinterval); |
2293 | musb_write_txfunaddr(musb_base, i, | 2243 | musb_write_txfunaddr(musb_base, i, |
2294 | musb->context.index_regs[i].txfunaddr); | 2244 | musb->context.index_regs[i].txfunaddr); |
2295 | musb_write_txhubaddr(musb_base, i, | 2245 | musb_write_txhubaddr(musb_base, i, |
2296 | musb->context.index_regs[i].txhubaddr); | 2246 | musb->context.index_regs[i].txhubaddr); |
2297 | musb_write_txhubport(musb_base, i, | 2247 | musb_write_txhubport(musb_base, i, |
2298 | musb->context.index_regs[i].txhubport); | 2248 | musb->context.index_regs[i].txhubport); |
2299 | 2249 | ||
2300 | ep_target_regs = | 2250 | ep_target_regs = |
2301 | musb_read_target_reg_base(i, musb_base); | 2251 | musb_read_target_reg_base(i, musb_base); |
2302 | 2252 | ||
2303 | musb_write_rxfunaddr(ep_target_regs, | 2253 | musb_write_rxfunaddr(ep_target_regs, |
2304 | musb->context.index_regs[i].rxfunaddr); | 2254 | musb->context.index_regs[i].rxfunaddr); |
2305 | musb_write_rxhubaddr(ep_target_regs, | 2255 | musb_write_rxhubaddr(ep_target_regs, |
2306 | musb->context.index_regs[i].rxhubaddr); | 2256 | musb->context.index_regs[i].rxhubaddr); |
2307 | musb_write_rxhubport(ep_target_regs, | 2257 | musb_write_rxhubport(ep_target_regs, |
2308 | musb->context.index_regs[i].rxhubport); | 2258 | musb->context.index_regs[i].rxhubport); |
2309 | } | ||
2310 | } | 2259 | } |
2311 | musb_writeb(musb_base, MUSB_INDEX, musb->context.index); | 2260 | musb_writeb(musb_base, MUSB_INDEX, musb->context.index); |
2312 | } | 2261 | } |
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h index 586105b55a7c..c158aacd6de8 100644 --- a/drivers/usb/musb/musb_core.h +++ b/drivers/usb/musb/musb_core.h | |||
@@ -71,10 +71,6 @@ struct musb_ep; | |||
71 | #include <linux/usb/hcd.h> | 71 | #include <linux/usb/hcd.h> |
72 | #include "musb_host.h" | 72 | #include "musb_host.h" |
73 | 73 | ||
74 | #define is_peripheral_enabled(musb) ((musb)->board_mode != MUSB_HOST) | ||
75 | #define is_host_enabled(musb) ((musb)->board_mode != MUSB_PERIPHERAL) | ||
76 | #define is_otg_enabled(musb) ((musb)->board_mode == MUSB_OTG) | ||
77 | |||
78 | /* NOTE: otg and peripheral-only state machines start at B_IDLE. | 74 | /* NOTE: otg and peripheral-only state machines start at B_IDLE. |
79 | * OTG or host-only go to A_IDLE when ID is sensed. | 75 | * OTG or host-only go to A_IDLE when ID is sensed. |
80 | */ | 76 | */ |
@@ -88,8 +84,6 @@ struct musb_ep; | |||
88 | 84 | ||
89 | /****************************** PERIPHERAL ROLE *****************************/ | 85 | /****************************** PERIPHERAL ROLE *****************************/ |
90 | 86 | ||
91 | #define is_peripheral_capable() (1) | ||
92 | |||
93 | extern irqreturn_t musb_g_ep0_irq(struct musb *); | 87 | extern irqreturn_t musb_g_ep0_irq(struct musb *); |
94 | extern void musb_g_tx(struct musb *, u8); | 88 | extern void musb_g_tx(struct musb *, u8); |
95 | extern void musb_g_rx(struct musb *, u8); | 89 | extern void musb_g_rx(struct musb *, u8); |
@@ -101,8 +95,6 @@ extern void musb_g_disconnect(struct musb *); | |||
101 | 95 | ||
102 | /****************************** HOST ROLE ***********************************/ | 96 | /****************************** HOST ROLE ***********************************/ |
103 | 97 | ||
104 | #define is_host_capable() (1) | ||
105 | |||
106 | extern irqreturn_t musb_h_ep0_irq(struct musb *); | 98 | extern irqreturn_t musb_h_ep0_irq(struct musb *); |
107 | extern void musb_host_tx(struct musb *, u8); | 99 | extern void musb_host_tx(struct musb *, u8); |
108 | extern void musb_host_rx(struct musb *, u8); | 100 | extern void musb_host_rx(struct musb *, u8); |
@@ -376,7 +368,6 @@ struct musb { | |||
376 | u16 epmask; | 368 | u16 epmask; |
377 | u8 nr_endpoints; | 369 | u8 nr_endpoints; |
378 | 370 | ||
379 | u8 board_mode; /* enum musb_mode */ | ||
380 | int (*board_set_power)(int state); | 371 | int (*board_set_power)(int state); |
381 | 372 | ||
382 | u8 min_power; /* vbus for periph, in mA/2 */ | 373 | u8 min_power; /* vbus for periph, in mA/2 */ |
@@ -446,6 +437,10 @@ struct musb { | |||
446 | #ifdef MUSB_CONFIG_PROC_FS | 437 | #ifdef MUSB_CONFIG_PROC_FS |
447 | struct proc_dir_entry *proc_entry; | 438 | struct proc_dir_entry *proc_entry; |
448 | #endif | 439 | #endif |
440 | int xceiv_old_state; | ||
441 | #ifdef CONFIG_DEBUG_FS | ||
442 | struct dentry *debugfs_root; | ||
443 | #endif | ||
449 | }; | 444 | }; |
450 | 445 | ||
451 | static inline struct musb *gadget_to_musb(struct usb_gadget *g) | 446 | static inline struct musb *gadget_to_musb(struct usb_gadget *g) |
@@ -484,7 +479,7 @@ static inline void musb_configure_ep0(struct musb *musb) | |||
484 | static inline int musb_read_fifosize(struct musb *musb, | 479 | static inline int musb_read_fifosize(struct musb *musb, |
485 | struct musb_hw_ep *hw_ep, u8 epnum) | 480 | struct musb_hw_ep *hw_ep, u8 epnum) |
486 | { | 481 | { |
487 | void *mbase = musb->mregs; | 482 | void __iomem *mbase = musb->mregs; |
488 | u8 reg = 0; | 483 | u8 reg = 0; |
489 | 484 | ||
490 | /* read from core using indexed model */ | 485 | /* read from core using indexed model */ |
@@ -526,6 +521,8 @@ extern const char musb_driver_name[]; | |||
526 | 521 | ||
527 | extern void musb_start(struct musb *musb); | 522 | extern void musb_start(struct musb *musb); |
528 | extern void musb_stop(struct musb *musb); | 523 | extern void musb_stop(struct musb *musb); |
524 | extern int musb_get_id(struct device *dev, gfp_t gfp_mask); | ||
525 | extern void musb_put_id(struct device *dev, int id); | ||
529 | 526 | ||
530 | extern void musb_write_fifo(struct musb_hw_ep *ep, u16 len, const u8 *src); | 527 | extern void musb_write_fifo(struct musb_hw_ep *ep, u16 len, const u8 *src); |
531 | extern void musb_read_fifo(struct musb_hw_ep *ep, u16 len, u8 *dst); | 528 | extern void musb_read_fifo(struct musb_hw_ep *ep, u16 len, u8 *dst); |
diff --git a/drivers/usb/musb/musb_debugfs.c b/drivers/usb/musb/musb_debugfs.c index 40a37c91cc10..1d6e8af94c06 100644 --- a/drivers/usb/musb/musb_debugfs.c +++ b/drivers/usb/musb/musb_debugfs.c | |||
@@ -103,8 +103,6 @@ static const struct musb_register_map musb_regmap[] = { | |||
103 | { } /* Terminating Entry */ | 103 | { } /* Terminating Entry */ |
104 | }; | 104 | }; |
105 | 105 | ||
106 | static struct dentry *musb_debugfs_root; | ||
107 | |||
108 | static int musb_regdump_show(struct seq_file *s, void *unused) | 106 | static int musb_regdump_show(struct seq_file *s, void *unused) |
109 | { | 107 | { |
110 | struct musb *musb = s->private; | 108 | struct musb *musb = s->private; |
@@ -241,7 +239,7 @@ int __devinit musb_init_debugfs(struct musb *musb) | |||
241 | struct dentry *file; | 239 | struct dentry *file; |
242 | int ret; | 240 | int ret; |
243 | 241 | ||
244 | root = debugfs_create_dir("musb", NULL); | 242 | root = debugfs_create_dir(dev_name(musb->controller), NULL); |
245 | if (!root) { | 243 | if (!root) { |
246 | ret = -ENOMEM; | 244 | ret = -ENOMEM; |
247 | goto err0; | 245 | goto err0; |
@@ -261,7 +259,7 @@ int __devinit musb_init_debugfs(struct musb *musb) | |||
261 | goto err1; | 259 | goto err1; |
262 | } | 260 | } |
263 | 261 | ||
264 | musb_debugfs_root = root; | 262 | musb->debugfs_root = root; |
265 | 263 | ||
266 | return 0; | 264 | return 0; |
267 | 265 | ||
@@ -274,5 +272,5 @@ err0: | |||
274 | 272 | ||
275 | void /* __init_or_exit */ musb_exit_debugfs(struct musb *musb) | 273 | void /* __init_or_exit */ musb_exit_debugfs(struct musb *musb) |
276 | { | 274 | { |
277 | debugfs_remove_recursive(musb_debugfs_root); | 275 | debugfs_remove_recursive(musb->debugfs_root); |
278 | } | 276 | } |
diff --git a/drivers/usb/musb/musb_dma.h b/drivers/usb/musb/musb_dma.h index 3a97c4e2d4f5..24d39210d4ab 100644 --- a/drivers/usb/musb/musb_dma.h +++ b/drivers/usb/musb/musb_dma.h | |||
@@ -178,7 +178,7 @@ struct dma_controller { | |||
178 | extern void musb_dma_completion(struct musb *musb, u8 epnum, u8 transmit); | 178 | extern void musb_dma_completion(struct musb *musb, u8 epnum, u8 transmit); |
179 | 179 | ||
180 | 180 | ||
181 | extern struct dma_controller *__init | 181 | extern struct dma_controller *__devinit |
182 | dma_controller_create(struct musb *, void __iomem *); | 182 | dma_controller_create(struct musb *, void __iomem *); |
183 | 183 | ||
184 | extern void dma_controller_destroy(struct dma_controller *); | 184 | extern void dma_controller_destroy(struct dma_controller *); |
diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c index 494772fc9e23..444346e1e10d 100644 --- a/drivers/usb/musb/musb_dsps.c +++ b/drivers/usb/musb/musb_dsps.c | |||
@@ -31,11 +31,13 @@ | |||
31 | 31 | ||
32 | #include <linux/init.h> | 32 | #include <linux/init.h> |
33 | #include <linux/io.h> | 33 | #include <linux/io.h> |
34 | #include <linux/of.h> | ||
34 | #include <linux/err.h> | 35 | #include <linux/err.h> |
35 | #include <linux/platform_device.h> | 36 | #include <linux/platform_device.h> |
36 | #include <linux/dma-mapping.h> | 37 | #include <linux/dma-mapping.h> |
37 | #include <linux/pm_runtime.h> | 38 | #include <linux/pm_runtime.h> |
38 | #include <linux/module.h> | 39 | #include <linux/module.h> |
40 | #include <linux/usb/nop-usb-xceiv.h> | ||
39 | 41 | ||
40 | #include <linux/of.h> | 42 | #include <linux/of.h> |
41 | #include <linux/of_device.h> | 43 | #include <linux/of_device.h> |
@@ -45,6 +47,10 @@ | |||
45 | 47 | ||
46 | #include "musb_core.h" | 48 | #include "musb_core.h" |
47 | 49 | ||
50 | #ifdef CONFIG_OF | ||
51 | static const struct of_device_id musb_dsps_of_match[]; | ||
52 | #endif | ||
53 | |||
48 | /** | 54 | /** |
49 | * avoid using musb_readx()/musb_writex() as glue layer should not be | 55 | * avoid using musb_readx()/musb_writex() as glue layer should not be |
50 | * dependent on musb core layer symbols. | 56 | * dependent on musb core layer symbols. |
@@ -105,6 +111,8 @@ struct dsps_musb_wrapper { | |||
105 | /* miscellaneous stuff */ | 111 | /* miscellaneous stuff */ |
106 | u32 musb_core_offset; | 112 | u32 musb_core_offset; |
107 | u8 poll_seconds; | 113 | u8 poll_seconds; |
114 | /* number of musb instances */ | ||
115 | u8 instances; | ||
108 | }; | 116 | }; |
109 | 117 | ||
110 | /** | 118 | /** |
@@ -112,9 +120,10 @@ struct dsps_musb_wrapper { | |||
112 | */ | 120 | */ |
113 | struct dsps_glue { | 121 | struct dsps_glue { |
114 | struct device *dev; | 122 | struct device *dev; |
115 | struct platform_device *musb; /* child musb pdev */ | 123 | struct platform_device *musb[2]; /* child musb pdev */ |
116 | const struct dsps_musb_wrapper *wrp; /* wrapper register offsets */ | 124 | const struct dsps_musb_wrapper *wrp; /* wrapper register offsets */ |
117 | struct timer_list timer; /* otg_workaround timer */ | 125 | struct timer_list timer[2]; /* otg_workaround timer */ |
126 | unsigned long last_timer[2]; /* last timer data for each instance */ | ||
118 | }; | 127 | }; |
119 | 128 | ||
120 | /** | 129 | /** |
@@ -137,9 +146,8 @@ static void dsps_musb_enable(struct musb *musb) | |||
137 | dsps_writel(reg_base, wrp->epintr_set, epmask); | 146 | dsps_writel(reg_base, wrp->epintr_set, epmask); |
138 | dsps_writel(reg_base, wrp->coreintr_set, coremask); | 147 | dsps_writel(reg_base, wrp->coreintr_set, coremask); |
139 | /* Force the DRVVBUS IRQ so we can start polling for ID change. */ | 148 | /* Force the DRVVBUS IRQ so we can start polling for ID change. */ |
140 | if (is_otg_enabled(musb)) | 149 | dsps_writel(reg_base, wrp->coreintr_set, |
141 | dsps_writel(reg_base, wrp->coreintr_set, | 150 | (1 << wrp->drvvbus) << wrp->usb_shift); |
142 | (1 << wrp->drvvbus) << wrp->usb_shift); | ||
143 | } | 151 | } |
144 | 152 | ||
145 | /** | 153 | /** |
@@ -165,8 +173,8 @@ static void otg_timer(unsigned long _musb) | |||
165 | struct musb *musb = (void *)_musb; | 173 | struct musb *musb = (void *)_musb; |
166 | void __iomem *mregs = musb->mregs; | 174 | void __iomem *mregs = musb->mregs; |
167 | struct device *dev = musb->controller; | 175 | struct device *dev = musb->controller; |
168 | struct platform_device *pdev = to_platform_device(dev->parent); | 176 | struct platform_device *pdev = to_platform_device(dev); |
169 | struct dsps_glue *glue = platform_get_drvdata(pdev); | 177 | struct dsps_glue *glue = dev_get_drvdata(dev->parent); |
170 | const struct dsps_musb_wrapper *wrp = glue->wrp; | 178 | const struct dsps_musb_wrapper *wrp = glue->wrp; |
171 | u8 devctl; | 179 | u8 devctl; |
172 | unsigned long flags; | 180 | unsigned long flags; |
@@ -200,12 +208,9 @@ static void otg_timer(unsigned long _musb) | |||
200 | MUSB_INTR_VBUSERROR << wrp->usb_shift); | 208 | MUSB_INTR_VBUSERROR << wrp->usb_shift); |
201 | break; | 209 | break; |
202 | case OTG_STATE_B_IDLE: | 210 | case OTG_STATE_B_IDLE: |
203 | if (!is_peripheral_enabled(musb)) | ||
204 | break; | ||
205 | |||
206 | devctl = dsps_readb(mregs, MUSB_DEVCTL); | 211 | devctl = dsps_readb(mregs, MUSB_DEVCTL); |
207 | if (devctl & MUSB_DEVCTL_BDEVICE) | 212 | if (devctl & MUSB_DEVCTL_BDEVICE) |
208 | mod_timer(&glue->timer, | 213 | mod_timer(&glue->timer[pdev->id], |
209 | jiffies + wrp->poll_seconds * HZ); | 214 | jiffies + wrp->poll_seconds * HZ); |
210 | else | 215 | else |
211 | musb->xceiv->state = OTG_STATE_A_IDLE; | 216 | musb->xceiv->state = OTG_STATE_A_IDLE; |
@@ -219,12 +224,8 @@ static void otg_timer(unsigned long _musb) | |||
219 | static void dsps_musb_try_idle(struct musb *musb, unsigned long timeout) | 224 | static void dsps_musb_try_idle(struct musb *musb, unsigned long timeout) |
220 | { | 225 | { |
221 | struct device *dev = musb->controller; | 226 | struct device *dev = musb->controller; |
222 | struct platform_device *pdev = to_platform_device(dev->parent); | 227 | struct platform_device *pdev = to_platform_device(dev); |
223 | struct dsps_glue *glue = platform_get_drvdata(pdev); | 228 | struct dsps_glue *glue = dev_get_drvdata(dev->parent); |
224 | static unsigned long last_timer; | ||
225 | |||
226 | if (!is_otg_enabled(musb)) | ||
227 | return; | ||
228 | 229 | ||
229 | if (timeout == 0) | 230 | if (timeout == 0) |
230 | timeout = jiffies + msecs_to_jiffies(3); | 231 | timeout = jiffies + msecs_to_jiffies(3); |
@@ -234,22 +235,23 @@ static void dsps_musb_try_idle(struct musb *musb, unsigned long timeout) | |||
234 | musb->xceiv->state == OTG_STATE_A_WAIT_BCON)) { | 235 | musb->xceiv->state == OTG_STATE_A_WAIT_BCON)) { |
235 | dev_dbg(musb->controller, "%s active, deleting timer\n", | 236 | dev_dbg(musb->controller, "%s active, deleting timer\n", |
236 | otg_state_string(musb->xceiv->state)); | 237 | otg_state_string(musb->xceiv->state)); |
237 | del_timer(&glue->timer); | 238 | del_timer(&glue->timer[pdev->id]); |
238 | last_timer = jiffies; | 239 | glue->last_timer[pdev->id] = jiffies; |
239 | return; | 240 | return; |
240 | } | 241 | } |
241 | 242 | ||
242 | if (time_after(last_timer, timeout) && timer_pending(&glue->timer)) { | 243 | if (time_after(glue->last_timer[pdev->id], timeout) && |
244 | timer_pending(&glue->timer[pdev->id])) { | ||
243 | dev_dbg(musb->controller, | 245 | dev_dbg(musb->controller, |
244 | "Longer idle timer already pending, ignoring...\n"); | 246 | "Longer idle timer already pending, ignoring...\n"); |
245 | return; | 247 | return; |
246 | } | 248 | } |
247 | last_timer = timeout; | 249 | glue->last_timer[pdev->id] = timeout; |
248 | 250 | ||
249 | dev_dbg(musb->controller, "%s inactive, starting idle timer for %u ms\n", | 251 | dev_dbg(musb->controller, "%s inactive, starting idle timer for %u ms\n", |
250 | otg_state_string(musb->xceiv->state), | 252 | otg_state_string(musb->xceiv->state), |
251 | jiffies_to_msecs(timeout - jiffies)); | 253 | jiffies_to_msecs(timeout - jiffies)); |
252 | mod_timer(&glue->timer, timeout); | 254 | mod_timer(&glue->timer[pdev->id], timeout); |
253 | } | 255 | } |
254 | 256 | ||
255 | static irqreturn_t dsps_interrupt(int irq, void *hci) | 257 | static irqreturn_t dsps_interrupt(int irq, void *hci) |
@@ -257,8 +259,8 @@ static irqreturn_t dsps_interrupt(int irq, void *hci) | |||
257 | struct musb *musb = hci; | 259 | struct musb *musb = hci; |
258 | void __iomem *reg_base = musb->ctrl_base; | 260 | void __iomem *reg_base = musb->ctrl_base; |
259 | struct device *dev = musb->controller; | 261 | struct device *dev = musb->controller; |
260 | struct platform_device *pdev = to_platform_device(dev->parent); | 262 | struct platform_device *pdev = to_platform_device(dev); |
261 | struct dsps_glue *glue = platform_get_drvdata(pdev); | 263 | struct dsps_glue *glue = dev_get_drvdata(dev->parent); |
262 | const struct dsps_musb_wrapper *wrp = glue->wrp; | 264 | const struct dsps_musb_wrapper *wrp = glue->wrp; |
263 | unsigned long flags; | 265 | unsigned long flags; |
264 | irqreturn_t ret = IRQ_NONE; | 266 | irqreturn_t ret = IRQ_NONE; |
@@ -293,7 +295,7 @@ static irqreturn_t dsps_interrupt(int irq, void *hci) | |||
293 | * value but DEVCTL.BDEVICE is invalid without DEVCTL.SESSION set. | 295 | * value but DEVCTL.BDEVICE is invalid without DEVCTL.SESSION set. |
294 | * Also, DRVVBUS pulses for SRP (but not at 5V) ... | 296 | * Also, DRVVBUS pulses for SRP (but not at 5V) ... |
295 | */ | 297 | */ |
296 | if ((usbintr & MUSB_INTR_BABBLE) && is_host_enabled(musb)) | 298 | if (usbintr & MUSB_INTR_BABBLE) |
297 | pr_info("CAUTION: musb: Babble Interrupt Occured\n"); | 299 | pr_info("CAUTION: musb: Babble Interrupt Occured\n"); |
298 | 300 | ||
299 | if (usbintr & ((1 << wrp->drvvbus) << wrp->usb_shift)) { | 301 | if (usbintr & ((1 << wrp->drvvbus) << wrp->usb_shift)) { |
@@ -302,8 +304,7 @@ static irqreturn_t dsps_interrupt(int irq, void *hci) | |||
302 | u8 devctl = dsps_readb(mregs, MUSB_DEVCTL); | 304 | u8 devctl = dsps_readb(mregs, MUSB_DEVCTL); |
303 | int err; | 305 | int err; |
304 | 306 | ||
305 | err = is_host_enabled(musb) && (musb->int_usb & | 307 | err = musb->int_usb & MUSB_INTR_VBUSERROR; |
306 | MUSB_INTR_VBUSERROR); | ||
307 | if (err) { | 308 | if (err) { |
308 | /* | 309 | /* |
309 | * The Mentor core doesn't debounce VBUS as needed | 310 | * The Mentor core doesn't debounce VBUS as needed |
@@ -318,15 +319,15 @@ static irqreturn_t dsps_interrupt(int irq, void *hci) | |||
318 | */ | 319 | */ |
319 | musb->int_usb &= ~MUSB_INTR_VBUSERROR; | 320 | musb->int_usb &= ~MUSB_INTR_VBUSERROR; |
320 | musb->xceiv->state = OTG_STATE_A_WAIT_VFALL; | 321 | musb->xceiv->state = OTG_STATE_A_WAIT_VFALL; |
321 | mod_timer(&glue->timer, | 322 | mod_timer(&glue->timer[pdev->id], |
322 | jiffies + wrp->poll_seconds * HZ); | 323 | jiffies + wrp->poll_seconds * HZ); |
323 | WARNING("VBUS error workaround (delay coming)\n"); | 324 | WARNING("VBUS error workaround (delay coming)\n"); |
324 | } else if (is_host_enabled(musb) && drvvbus) { | 325 | } else if (drvvbus) { |
325 | musb->is_active = 1; | 326 | musb->is_active = 1; |
326 | MUSB_HST_MODE(musb); | 327 | MUSB_HST_MODE(musb); |
327 | musb->xceiv->otg->default_a = 1; | 328 | musb->xceiv->otg->default_a = 1; |
328 | musb->xceiv->state = OTG_STATE_A_WAIT_VRISE; | 329 | musb->xceiv->state = OTG_STATE_A_WAIT_VRISE; |
329 | del_timer(&glue->timer); | 330 | del_timer(&glue->timer[pdev->id]); |
330 | } else { | 331 | } else { |
331 | musb->is_active = 0; | 332 | musb->is_active = 0; |
332 | MUSB_DEV_MODE(musb); | 333 | MUSB_DEV_MODE(musb); |
@@ -352,8 +353,9 @@ static irqreturn_t dsps_interrupt(int irq, void *hci) | |||
352 | dsps_writel(reg_base, wrp->eoi, 1); | 353 | dsps_writel(reg_base, wrp->eoi, 1); |
353 | 354 | ||
354 | /* Poll for ID change */ | 355 | /* Poll for ID change */ |
355 | if (is_otg_enabled(musb) && musb->xceiv->state == OTG_STATE_B_IDLE) | 356 | if (musb->xceiv->state == OTG_STATE_B_IDLE) |
356 | mod_timer(&glue->timer, jiffies + wrp->poll_seconds * HZ); | 357 | mod_timer(&glue->timer[pdev->id], |
358 | jiffies + wrp->poll_seconds * HZ); | ||
357 | 359 | ||
358 | spin_unlock_irqrestore(&musb->lock, flags); | 360 | spin_unlock_irqrestore(&musb->lock, flags); |
359 | 361 | ||
@@ -364,8 +366,8 @@ static int dsps_musb_init(struct musb *musb) | |||
364 | { | 366 | { |
365 | struct device *dev = musb->controller; | 367 | struct device *dev = musb->controller; |
366 | struct musb_hdrc_platform_data *plat = dev->platform_data; | 368 | struct musb_hdrc_platform_data *plat = dev->platform_data; |
367 | struct platform_device *pdev = to_platform_device(dev->parent); | 369 | struct platform_device *pdev = to_platform_device(dev); |
368 | struct dsps_glue *glue = platform_get_drvdata(pdev); | 370 | struct dsps_glue *glue = dev_get_drvdata(dev->parent); |
369 | const struct dsps_musb_wrapper *wrp = glue->wrp; | 371 | const struct dsps_musb_wrapper *wrp = glue->wrp; |
370 | struct omap_musb_board_data *data = plat->board_data; | 372 | struct omap_musb_board_data *data = plat->board_data; |
371 | void __iomem *reg_base = musb->ctrl_base; | 373 | void __iomem *reg_base = musb->ctrl_base; |
@@ -375,8 +377,7 @@ static int dsps_musb_init(struct musb *musb) | |||
375 | /* mentor core register starts at offset of 0x400 from musb base */ | 377 | /* mentor core register starts at offset of 0x400 from musb base */ |
376 | musb->mregs += wrp->musb_core_offset; | 378 | musb->mregs += wrp->musb_core_offset; |
377 | 379 | ||
378 | /* NOP driver needs change if supporting dual instance */ | 380 | /* Get the NOP PHY */ |
379 | usb_nop_xceiv_register(); | ||
380 | musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2); | 381 | musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2); |
381 | if (IS_ERR_OR_NULL(musb->xceiv)) | 382 | if (IS_ERR_OR_NULL(musb->xceiv)) |
382 | return -ENODEV; | 383 | return -ENODEV; |
@@ -388,8 +389,7 @@ static int dsps_musb_init(struct musb *musb) | |||
388 | goto err0; | 389 | goto err0; |
389 | } | 390 | } |
390 | 391 | ||
391 | if (is_host_enabled(musb)) | 392 | setup_timer(&glue->timer[pdev->id], otg_timer, (unsigned long) musb); |
392 | setup_timer(&glue->timer, otg_timer, (unsigned long) musb); | ||
393 | 393 | ||
394 | /* Reset the musb */ | 394 | /* Reset the musb */ |
395 | dsps_writel(reg_base, wrp->control, (1 << wrp->reset)); | 395 | dsps_writel(reg_base, wrp->control, (1 << wrp->reset)); |
@@ -420,11 +420,10 @@ static int dsps_musb_exit(struct musb *musb) | |||
420 | struct device *dev = musb->controller; | 420 | struct device *dev = musb->controller; |
421 | struct musb_hdrc_platform_data *plat = dev->platform_data; | 421 | struct musb_hdrc_platform_data *plat = dev->platform_data; |
422 | struct omap_musb_board_data *data = plat->board_data; | 422 | struct omap_musb_board_data *data = plat->board_data; |
423 | struct platform_device *pdev = to_platform_device(dev->parent); | 423 | struct platform_device *pdev = to_platform_device(dev); |
424 | struct dsps_glue *glue = platform_get_drvdata(pdev); | 424 | struct dsps_glue *glue = dev_get_drvdata(dev->parent); |
425 | 425 | ||
426 | if (is_host_enabled(musb)) | 426 | del_timer_sync(&glue->timer[pdev->id]); |
427 | del_timer_sync(&glue->timer); | ||
428 | 427 | ||
429 | /* Shutdown the on-chip PHY and its PLL. */ | 428 | /* Shutdown the on-chip PHY and its PLL. */ |
430 | if (data->set_phy_power) | 429 | if (data->set_phy_power) |
@@ -454,11 +453,13 @@ static int __devinit dsps_create_musb_pdev(struct dsps_glue *glue, u8 id) | |||
454 | struct device *dev = glue->dev; | 453 | struct device *dev = glue->dev; |
455 | struct platform_device *pdev = to_platform_device(dev); | 454 | struct platform_device *pdev = to_platform_device(dev); |
456 | struct musb_hdrc_platform_data *pdata = dev->platform_data; | 455 | struct musb_hdrc_platform_data *pdata = dev->platform_data; |
456 | struct device_node *np = pdev->dev.of_node; | ||
457 | struct musb_hdrc_config *config; | ||
457 | struct platform_device *musb; | 458 | struct platform_device *musb; |
458 | struct resource *res; | 459 | struct resource *res; |
459 | struct resource resources[2]; | 460 | struct resource resources[2]; |
460 | char res_name[10]; | 461 | char res_name[10]; |
461 | int ret; | 462 | int ret, musbid; |
462 | 463 | ||
463 | /* get memory resource */ | 464 | /* get memory resource */ |
464 | sprintf(res_name, "musb%d", id); | 465 | sprintf(res_name, "musb%d", id); |
@@ -483,62 +484,107 @@ static int __devinit dsps_create_musb_pdev(struct dsps_glue *glue, u8 id) | |||
483 | resources[1] = *res; | 484 | resources[1] = *res; |
484 | resources[1].name = "mc"; | 485 | resources[1].name = "mc"; |
485 | 486 | ||
487 | /* get the musb id */ | ||
488 | musbid = musb_get_id(dev, GFP_KERNEL); | ||
489 | if (musbid < 0) { | ||
490 | dev_err(dev, "failed to allocate musb id\n"); | ||
491 | ret = -ENOMEM; | ||
492 | goto err0; | ||
493 | } | ||
486 | /* allocate the child platform device */ | 494 | /* allocate the child platform device */ |
487 | musb = platform_device_alloc("musb-hdrc", -1); | 495 | musb = platform_device_alloc("musb-hdrc", musbid); |
488 | if (!musb) { | 496 | if (!musb) { |
489 | dev_err(dev, "failed to allocate musb device\n"); | 497 | dev_err(dev, "failed to allocate musb device\n"); |
490 | ret = -ENOMEM; | 498 | ret = -ENOMEM; |
491 | goto err0; | 499 | goto err1; |
492 | } | 500 | } |
493 | 501 | ||
502 | musb->id = musbid; | ||
494 | musb->dev.parent = dev; | 503 | musb->dev.parent = dev; |
495 | musb->dev.dma_mask = &musb_dmamask; | 504 | musb->dev.dma_mask = &musb_dmamask; |
496 | musb->dev.coherent_dma_mask = musb_dmamask; | 505 | musb->dev.coherent_dma_mask = musb_dmamask; |
497 | 506 | ||
498 | glue->musb = musb; | 507 | glue->musb[id] = musb; |
499 | |||
500 | pdata->platform_ops = &dsps_ops; | ||
501 | 508 | ||
502 | ret = platform_device_add_resources(musb, resources, 2); | 509 | ret = platform_device_add_resources(musb, resources, 2); |
503 | if (ret) { | 510 | if (ret) { |
504 | dev_err(dev, "failed to add resources\n"); | 511 | dev_err(dev, "failed to add resources\n"); |
505 | goto err1; | 512 | goto err2; |
506 | } | 513 | } |
507 | 514 | ||
515 | if (np) { | ||
516 | pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); | ||
517 | if (!pdata) { | ||
518 | dev_err(&pdev->dev, | ||
519 | "failed to allocate musb platfrom data\n"); | ||
520 | ret = -ENOMEM; | ||
521 | goto err2; | ||
522 | } | ||
523 | |||
524 | config = devm_kzalloc(&pdev->dev, sizeof(*config), GFP_KERNEL); | ||
525 | if (!config) { | ||
526 | dev_err(&pdev->dev, | ||
527 | "failed to allocate musb hdrc config\n"); | ||
528 | goto err2; | ||
529 | } | ||
530 | |||
531 | of_property_read_u32(np, "num-eps", (u32 *)&config->num_eps); | ||
532 | of_property_read_u32(np, "ram-bits", (u32 *)&config->ram_bits); | ||
533 | sprintf(res_name, "port%d-mode", id); | ||
534 | of_property_read_u32(np, res_name, (u32 *)&pdata->mode); | ||
535 | of_property_read_u32(np, "power", (u32 *)&pdata->power); | ||
536 | config->multipoint = of_property_read_bool(np, "multipoint"); | ||
537 | |||
538 | pdata->config = config; | ||
539 | } | ||
540 | |||
541 | pdata->platform_ops = &dsps_ops; | ||
542 | |||
508 | ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); | 543 | ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); |
509 | if (ret) { | 544 | if (ret) { |
510 | dev_err(dev, "failed to add platform_data\n"); | 545 | dev_err(dev, "failed to add platform_data\n"); |
511 | goto err1; | 546 | goto err2; |
512 | } | 547 | } |
513 | 548 | ||
514 | ret = platform_device_add(musb); | 549 | ret = platform_device_add(musb); |
515 | if (ret) { | 550 | if (ret) { |
516 | dev_err(dev, "failed to register musb device\n"); | 551 | dev_err(dev, "failed to register musb device\n"); |
517 | goto err1; | 552 | goto err2; |
518 | } | 553 | } |
519 | 554 | ||
520 | return 0; | 555 | return 0; |
521 | 556 | ||
522 | err1: | 557 | err2: |
523 | platform_device_put(musb); | 558 | platform_device_put(musb); |
559 | err1: | ||
560 | musb_put_id(dev, musbid); | ||
524 | err0: | 561 | err0: |
525 | return ret; | 562 | return ret; |
526 | } | 563 | } |
527 | 564 | ||
528 | static void __devexit dsps_delete_musb_pdev(struct dsps_glue *glue) | 565 | static void dsps_delete_musb_pdev(struct dsps_glue *glue, u8 id) |
529 | { | 566 | { |
530 | platform_device_del(glue->musb); | 567 | musb_put_id(glue->dev, glue->musb[id]->id); |
531 | platform_device_put(glue->musb); | 568 | platform_device_del(glue->musb[id]); |
569 | platform_device_put(glue->musb[id]); | ||
532 | } | 570 | } |
533 | 571 | ||
534 | static int __devinit dsps_probe(struct platform_device *pdev) | 572 | static int __devinit dsps_probe(struct platform_device *pdev) |
535 | { | 573 | { |
536 | const struct platform_device_id *id = platform_get_device_id(pdev); | 574 | struct device_node *np = pdev->dev.of_node; |
537 | const struct dsps_musb_wrapper *wrp = | 575 | const struct of_device_id *match; |
538 | (struct dsps_musb_wrapper *)id->driver_data; | 576 | const struct dsps_musb_wrapper *wrp; |
539 | struct dsps_glue *glue; | 577 | struct dsps_glue *glue; |
540 | struct resource *iomem; | 578 | struct resource *iomem; |
541 | int ret; | 579 | int ret, i; |
580 | |||
581 | match = of_match_node(musb_dsps_of_match, np); | ||
582 | if (!match) { | ||
583 | dev_err(&pdev->dev, "fail to get matching of_match struct\n"); | ||
584 | ret = -EINVAL; | ||
585 | goto err0; | ||
586 | } | ||
587 | wrp = match->data; | ||
542 | 588 | ||
543 | /* allocate glue */ | 589 | /* allocate glue */ |
544 | glue = kzalloc(sizeof(*glue), GFP_KERNEL); | 590 | glue = kzalloc(sizeof(*glue), GFP_KERNEL); |
@@ -575,11 +621,16 @@ static int __devinit dsps_probe(struct platform_device *pdev) | |||
575 | goto err2; | 621 | goto err2; |
576 | } | 622 | } |
577 | 623 | ||
578 | /* create the child platform device for first instances of musb */ | 624 | /* create the child platform device for all instances of musb */ |
579 | ret = dsps_create_musb_pdev(glue, 0); | 625 | for (i = 0; i < wrp->instances ; i++) { |
580 | if (ret != 0) { | 626 | ret = dsps_create_musb_pdev(glue, i); |
581 | dev_err(&pdev->dev, "failed to create child pdev\n"); | 627 | if (ret != 0) { |
582 | goto err3; | 628 | dev_err(&pdev->dev, "failed to create child pdev\n"); |
629 | /* release resources of previously created instances */ | ||
630 | for (i--; i >= 0 ; i--) | ||
631 | dsps_delete_musb_pdev(glue, i); | ||
632 | goto err3; | ||
633 | } | ||
583 | } | 634 | } |
584 | 635 | ||
585 | return 0; | 636 | return 0; |
@@ -597,9 +648,12 @@ err0: | |||
597 | static int __devexit dsps_remove(struct platform_device *pdev) | 648 | static int __devexit dsps_remove(struct platform_device *pdev) |
598 | { | 649 | { |
599 | struct dsps_glue *glue = platform_get_drvdata(pdev); | 650 | struct dsps_glue *glue = platform_get_drvdata(pdev); |
651 | const struct dsps_musb_wrapper *wrp = glue->wrp; | ||
652 | int i; | ||
600 | 653 | ||
601 | /* delete the child platform device */ | 654 | /* delete the child platform device */ |
602 | dsps_delete_musb_pdev(glue); | 655 | for (i = 0; i < wrp->instances ; i++) |
656 | dsps_delete_musb_pdev(glue, i); | ||
603 | 657 | ||
604 | /* disable usbss clocks */ | 658 | /* disable usbss clocks */ |
605 | pm_runtime_put(&pdev->dev); | 659 | pm_runtime_put(&pdev->dev); |
@@ -665,6 +719,7 @@ static const struct dsps_musb_wrapper ti81xx_driver_data __devinitconst = { | |||
665 | .rxep_bitmap = (0xfffe << 16), | 719 | .rxep_bitmap = (0xfffe << 16), |
666 | .musb_core_offset = 0x400, | 720 | .musb_core_offset = 0x400, |
667 | .poll_seconds = 2, | 721 | .poll_seconds = 2, |
722 | .instances = 2, | ||
668 | }; | 723 | }; |
669 | 724 | ||
670 | static const struct platform_device_id musb_dsps_id_table[] __devinitconst = { | 725 | static const struct platform_device_id musb_dsps_id_table[] __devinitconst = { |
@@ -676,13 +731,14 @@ static const struct platform_device_id musb_dsps_id_table[] __devinitconst = { | |||
676 | }; | 731 | }; |
677 | MODULE_DEVICE_TABLE(platform, musb_dsps_id_table); | 732 | MODULE_DEVICE_TABLE(platform, musb_dsps_id_table); |
678 | 733 | ||
734 | #ifdef CONFIG_OF | ||
679 | static const struct of_device_id musb_dsps_of_match[] __devinitconst = { | 735 | static const struct of_device_id musb_dsps_of_match[] __devinitconst = { |
680 | { .compatible = "musb-ti81xx", }, | 736 | { .compatible = "ti,musb-am33xx", |
681 | { .compatible = "ti,ti81xx-musb", }, | 737 | .data = (void *) &ti81xx_driver_data, }, |
682 | { .compatible = "ti,am335x-musb", }, | ||
683 | { }, | 738 | { }, |
684 | }; | 739 | }; |
685 | MODULE_DEVICE_TABLE(of, musb_dsps_of_match); | 740 | MODULE_DEVICE_TABLE(of, musb_dsps_of_match); |
741 | #endif | ||
686 | 742 | ||
687 | static struct platform_driver dsps_usbss_driver = { | 743 | static struct platform_driver dsps_usbss_driver = { |
688 | .probe = dsps_probe, | 744 | .probe = dsps_probe, |
@@ -690,7 +746,7 @@ static struct platform_driver dsps_usbss_driver = { | |||
690 | .driver = { | 746 | .driver = { |
691 | .name = "musb-dsps", | 747 | .name = "musb-dsps", |
692 | .pm = &dsps_pm_ops, | 748 | .pm = &dsps_pm_ops, |
693 | .of_match_table = musb_dsps_of_match, | 749 | .of_match_table = of_match_ptr(musb_dsps_of_match), |
694 | }, | 750 | }, |
695 | .id_table = musb_dsps_id_table, | 751 | .id_table = musb_dsps_id_table, |
696 | }; | 752 | }; |
diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c index f7194cf65aba..d0b87e7b4abf 100644 --- a/drivers/usb/musb/musb_gadget.c +++ b/drivers/usb/musb/musb_gadget.c | |||
@@ -373,7 +373,7 @@ static void txstate(struct musb *musb, struct musb_request *req) | |||
373 | request_size = min_t(size_t, request->length - request->actual, | 373 | request_size = min_t(size_t, request->length - request->actual, |
374 | musb_ep->dma->max_len); | 374 | musb_ep->dma->max_len); |
375 | 375 | ||
376 | use_dma = (request->dma != DMA_ADDR_INVALID); | 376 | use_dma = (request->dma != DMA_ADDR_INVALID && request_size); |
377 | 377 | ||
378 | /* MUSB_TXCSR_P_ISO is still set correctly */ | 378 | /* MUSB_TXCSR_P_ISO is still set correctly */ |
379 | 379 | ||
@@ -644,8 +644,8 @@ static void rxstate(struct musb *musb, struct musb_request *req) | |||
644 | struct usb_request *request = &req->request; | 644 | struct usb_request *request = &req->request; |
645 | struct musb_ep *musb_ep; | 645 | struct musb_ep *musb_ep; |
646 | void __iomem *epio = musb->endpoints[epnum].regs; | 646 | void __iomem *epio = musb->endpoints[epnum].regs; |
647 | unsigned fifo_count = 0; | 647 | unsigned len = 0; |
648 | u16 len; | 648 | u16 fifo_count; |
649 | u16 csr = musb_readw(epio, MUSB_RXCSR); | 649 | u16 csr = musb_readw(epio, MUSB_RXCSR); |
650 | struct musb_hw_ep *hw_ep = &musb->endpoints[epnum]; | 650 | struct musb_hw_ep *hw_ep = &musb->endpoints[epnum]; |
651 | u8 use_mode_1; | 651 | u8 use_mode_1; |
@@ -655,7 +655,7 @@ static void rxstate(struct musb *musb, struct musb_request *req) | |||
655 | else | 655 | else |
656 | musb_ep = &hw_ep->ep_out; | 656 | musb_ep = &hw_ep->ep_out; |
657 | 657 | ||
658 | len = musb_ep->packet_sz; | 658 | fifo_count = musb_ep->packet_sz; |
659 | 659 | ||
660 | /* Check if EP is disabled */ | 660 | /* Check if EP is disabled */ |
661 | if (!musb_ep->desc) { | 661 | if (!musb_ep->desc) { |
@@ -704,15 +704,14 @@ static void rxstate(struct musb *musb, struct musb_request *req) | |||
704 | } | 704 | } |
705 | 705 | ||
706 | if (csr & MUSB_RXCSR_RXPKTRDY) { | 706 | if (csr & MUSB_RXCSR_RXPKTRDY) { |
707 | len = musb_readw(epio, MUSB_RXCOUNT); | 707 | fifo_count = musb_readw(epio, MUSB_RXCOUNT); |
708 | 708 | ||
709 | /* | 709 | /* |
710 | * Enable Mode 1 on RX transfers only when short_not_ok flag | 710 | * use mode 1 only if we expect data of at least ep packet_sz |
711 | * is set. Currently short_not_ok flag is set only from | 711 | * and have not yet received a short packet |
712 | * file_storage and f_mass_storage drivers | ||
713 | */ | 712 | */ |
714 | 713 | if ((request->length - request->actual >= musb_ep->packet_sz) && | |
715 | if (request->short_not_ok && len == musb_ep->packet_sz) | 714 | (fifo_count >= musb_ep->packet_sz)) |
716 | use_mode_1 = 1; | 715 | use_mode_1 = 1; |
717 | else | 716 | else |
718 | use_mode_1 = 0; | 717 | use_mode_1 = 0; |
@@ -723,31 +722,11 @@ static void rxstate(struct musb *musb, struct musb_request *req) | |||
723 | struct dma_controller *c; | 722 | struct dma_controller *c; |
724 | struct dma_channel *channel; | 723 | struct dma_channel *channel; |
725 | int use_dma = 0; | 724 | int use_dma = 0; |
725 | int transfer_size; | ||
726 | 726 | ||
727 | c = musb->dma_controller; | 727 | c = musb->dma_controller; |
728 | channel = musb_ep->dma; | 728 | channel = musb_ep->dma; |
729 | 729 | ||
730 | /* We use DMA Req mode 0 in rx_csr, and DMA controller operates in | ||
731 | * mode 0 only. So we do not get endpoint interrupts due to DMA | ||
732 | * completion. We only get interrupts from DMA controller. | ||
733 | * | ||
734 | * We could operate in DMA mode 1 if we knew the size of the tranfer | ||
735 | * in advance. For mass storage class, request->length = what the host | ||
736 | * sends, so that'd work. But for pretty much everything else, | ||
737 | * request->length is routinely more than what the host sends. For | ||
738 | * most these gadgets, end of is signified either by a short packet, | ||
739 | * or filling the last byte of the buffer. (Sending extra data in | ||
740 | * that last pckate should trigger an overflow fault.) But in mode 1, | ||
741 | * we don't get DMA completion interrupt for short packets. | ||
742 | * | ||
743 | * Theoretically, we could enable DMAReq irq (MUSB_RXCSR_DMAMODE = 1), | ||
744 | * to get endpoint interrupt on every DMA req, but that didn't seem | ||
745 | * to work reliably. | ||
746 | * | ||
747 | * REVISIT an updated g_file_storage can set req->short_not_ok, which | ||
748 | * then becomes usable as a runtime "use mode 1" hint... | ||
749 | */ | ||
750 | |||
751 | /* Experimental: Mode1 works with mass storage use cases */ | 730 | /* Experimental: Mode1 works with mass storage use cases */ |
752 | if (use_mode_1) { | 731 | if (use_mode_1) { |
753 | csr |= MUSB_RXCSR_AUTOCLEAR; | 732 | csr |= MUSB_RXCSR_AUTOCLEAR; |
@@ -764,35 +743,30 @@ static void rxstate(struct musb *musb, struct musb_request *req) | |||
764 | csr | MUSB_RXCSR_DMAMODE); | 743 | csr | MUSB_RXCSR_DMAMODE); |
765 | musb_writew(epio, MUSB_RXCSR, csr); | 744 | musb_writew(epio, MUSB_RXCSR, csr); |
766 | 745 | ||
746 | transfer_size = min(request->length - request->actual, | ||
747 | channel->max_len); | ||
748 | musb_ep->dma->desired_mode = 1; | ||
749 | |||
767 | } else { | 750 | } else { |
768 | if (!musb_ep->hb_mult && | 751 | if (!musb_ep->hb_mult && |
769 | musb_ep->hw_ep->rx_double_buffered) | 752 | musb_ep->hw_ep->rx_double_buffered) |
770 | csr |= MUSB_RXCSR_AUTOCLEAR; | 753 | csr |= MUSB_RXCSR_AUTOCLEAR; |
771 | csr |= MUSB_RXCSR_DMAENAB; | 754 | csr |= MUSB_RXCSR_DMAENAB; |
772 | musb_writew(epio, MUSB_RXCSR, csr); | 755 | musb_writew(epio, MUSB_RXCSR, csr); |
773 | } | ||
774 | 756 | ||
775 | if (request->actual < request->length) { | 757 | transfer_size = min(request->length - request->actual, |
776 | int transfer_size = 0; | 758 | (unsigned)fifo_count); |
777 | if (use_mode_1) { | 759 | musb_ep->dma->desired_mode = 0; |
778 | transfer_size = min(request->length - request->actual, | ||
779 | channel->max_len); | ||
780 | musb_ep->dma->desired_mode = 1; | ||
781 | } else { | ||
782 | transfer_size = min(request->length - request->actual, | ||
783 | (unsigned)len); | ||
784 | musb_ep->dma->desired_mode = 0; | ||
785 | } | ||
786 | |||
787 | use_dma = c->channel_program( | ||
788 | channel, | ||
789 | musb_ep->packet_sz, | ||
790 | channel->desired_mode, | ||
791 | request->dma | ||
792 | + request->actual, | ||
793 | transfer_size); | ||
794 | } | 760 | } |
795 | 761 | ||
762 | use_dma = c->channel_program( | ||
763 | channel, | ||
764 | musb_ep->packet_sz, | ||
765 | channel->desired_mode, | ||
766 | request->dma | ||
767 | + request->actual, | ||
768 | transfer_size); | ||
769 | |||
796 | if (use_dma) | 770 | if (use_dma) |
797 | return; | 771 | return; |
798 | } | 772 | } |
@@ -808,8 +782,8 @@ static void rxstate(struct musb *musb, struct musb_request *req) | |||
808 | channel = musb_ep->dma; | 782 | channel = musb_ep->dma; |
809 | 783 | ||
810 | /* In case first packet is short */ | 784 | /* In case first packet is short */ |
811 | if (len < musb_ep->packet_sz) | 785 | if (fifo_count < musb_ep->packet_sz) |
812 | transfer_size = len; | 786 | transfer_size = fifo_count; |
813 | else if (request->short_not_ok) | 787 | else if (request->short_not_ok) |
814 | transfer_size = min(request->length - | 788 | transfer_size = min(request->length - |
815 | request->actual, | 789 | request->actual, |
@@ -817,7 +791,7 @@ static void rxstate(struct musb *musb, struct musb_request *req) | |||
817 | else | 791 | else |
818 | transfer_size = min(request->length - | 792 | transfer_size = min(request->length - |
819 | request->actual, | 793 | request->actual, |
820 | (unsigned)len); | 794 | (unsigned)fifo_count); |
821 | 795 | ||
822 | csr &= ~MUSB_RXCSR_DMAMODE; | 796 | csr &= ~MUSB_RXCSR_DMAMODE; |
823 | csr |= (MUSB_RXCSR_DMAENAB | | 797 | csr |= (MUSB_RXCSR_DMAENAB | |
@@ -845,10 +819,10 @@ static void rxstate(struct musb *musb, struct musb_request *req) | |||
845 | } | 819 | } |
846 | #endif /* Mentor's DMA */ | 820 | #endif /* Mentor's DMA */ |
847 | 821 | ||
848 | fifo_count = request->length - request->actual; | 822 | len = request->length - request->actual; |
849 | dev_dbg(musb->controller, "%s OUT/RX pio fifo %d/%d, maxpacket %d\n", | 823 | dev_dbg(musb->controller, "%s OUT/RX pio fifo %d/%d, maxpacket %d\n", |
850 | musb_ep->end_point.name, | 824 | musb_ep->end_point.name, |
851 | len, fifo_count, | 825 | fifo_count, len, |
852 | musb_ep->packet_sz); | 826 | musb_ep->packet_sz); |
853 | 827 | ||
854 | fifo_count = min_t(unsigned, len, fifo_count); | 828 | fifo_count = min_t(unsigned, len, fifo_count); |
@@ -901,7 +875,8 @@ static void rxstate(struct musb *musb, struct musb_request *req) | |||
901 | } | 875 | } |
902 | 876 | ||
903 | /* reach the end or short packet detected */ | 877 | /* reach the end or short packet detected */ |
904 | if (request->actual == request->length || len < musb_ep->packet_sz) | 878 | if (request->actual == request->length || |
879 | fifo_count < musb_ep->packet_sz) | ||
905 | musb_g_giveback(musb_ep, request, 0); | 880 | musb_g_giveback(musb_ep, request, 0); |
906 | } | 881 | } |
907 | 882 | ||
@@ -1885,8 +1860,7 @@ int __devinit musb_gadget_setup(struct musb *musb) | |||
1885 | musb->g.dev.release = musb_gadget_release; | 1860 | musb->g.dev.release = musb_gadget_release; |
1886 | musb->g.name = musb_driver_name; | 1861 | musb->g.name = musb_driver_name; |
1887 | 1862 | ||
1888 | if (is_otg_enabled(musb)) | 1863 | musb->g.is_otg = 1; |
1889 | musb->g.is_otg = 1; | ||
1890 | 1864 | ||
1891 | musb_g_init_endpoints(musb); | 1865 | musb_g_init_endpoints(musb); |
1892 | 1866 | ||
@@ -1932,11 +1906,14 @@ static int musb_gadget_start(struct usb_gadget *g, | |||
1932 | { | 1906 | { |
1933 | struct musb *musb = gadget_to_musb(g); | 1907 | struct musb *musb = gadget_to_musb(g); |
1934 | struct usb_otg *otg = musb->xceiv->otg; | 1908 | struct usb_otg *otg = musb->xceiv->otg; |
1909 | struct usb_hcd *hcd = musb_to_hcd(musb); | ||
1935 | unsigned long flags; | 1910 | unsigned long flags; |
1936 | int retval = -EINVAL; | 1911 | int retval = 0; |
1937 | 1912 | ||
1938 | if (driver->max_speed < USB_SPEED_HIGH) | 1913 | if (driver->max_speed < USB_SPEED_HIGH) { |
1939 | goto err0; | 1914 | retval = -EINVAL; |
1915 | goto err; | ||
1916 | } | ||
1940 | 1917 | ||
1941 | pm_runtime_get_sync(musb->controller); | 1918 | pm_runtime_get_sync(musb->controller); |
1942 | 1919 | ||
@@ -1950,49 +1927,30 @@ static int musb_gadget_start(struct usb_gadget *g, | |||
1950 | 1927 | ||
1951 | otg_set_peripheral(otg, &musb->g); | 1928 | otg_set_peripheral(otg, &musb->g); |
1952 | musb->xceiv->state = OTG_STATE_B_IDLE; | 1929 | musb->xceiv->state = OTG_STATE_B_IDLE; |
1953 | |||
1954 | /* | ||
1955 | * FIXME this ignores the softconnect flag. Drivers are | ||
1956 | * allowed hold the peripheral inactive until for example | ||
1957 | * userspace hooks up printer hardware or DSP codecs, so | ||
1958 | * hosts only see fully functional devices. | ||
1959 | */ | ||
1960 | |||
1961 | if (!is_otg_enabled(musb)) | ||
1962 | musb_start(musb); | ||
1963 | |||
1964 | spin_unlock_irqrestore(&musb->lock, flags); | 1930 | spin_unlock_irqrestore(&musb->lock, flags); |
1965 | 1931 | ||
1966 | if (is_otg_enabled(musb)) { | 1932 | /* REVISIT: funcall to other code, which also |
1967 | struct usb_hcd *hcd = musb_to_hcd(musb); | 1933 | * handles power budgeting ... this way also |
1968 | 1934 | * ensures HdrcStart is indirectly called. | |
1969 | dev_dbg(musb->controller, "OTG startup...\n"); | 1935 | */ |
1936 | retval = usb_add_hcd(hcd, 0, 0); | ||
1937 | if (retval < 0) { | ||
1938 | dev_dbg(musb->controller, "add_hcd failed, %d\n", retval); | ||
1939 | goto err; | ||
1940 | } | ||
1970 | 1941 | ||
1971 | /* REVISIT: funcall to other code, which also | 1942 | if ((musb->xceiv->last_event == USB_EVENT_ID) |
1972 | * handles power budgeting ... this way also | 1943 | && otg->set_vbus) |
1973 | * ensures HdrcStart is indirectly called. | 1944 | otg_set_vbus(otg, 1); |
1974 | */ | ||
1975 | retval = usb_add_hcd(musb_to_hcd(musb), 0, 0); | ||
1976 | if (retval < 0) { | ||
1977 | dev_dbg(musb->controller, "add_hcd failed, %d\n", retval); | ||
1978 | goto err2; | ||
1979 | } | ||
1980 | 1945 | ||
1981 | if ((musb->xceiv->last_event == USB_EVENT_ID) | 1946 | hcd->self.uses_pio_for_control = 1; |
1982 | && otg->set_vbus) | ||
1983 | otg_set_vbus(otg, 1); | ||
1984 | 1947 | ||
1985 | hcd->self.uses_pio_for_control = 1; | ||
1986 | } | ||
1987 | if (musb->xceiv->last_event == USB_EVENT_NONE) | 1948 | if (musb->xceiv->last_event == USB_EVENT_NONE) |
1988 | pm_runtime_put(musb->controller); | 1949 | pm_runtime_put(musb->controller); |
1989 | 1950 | ||
1990 | return 0; | 1951 | return 0; |
1991 | 1952 | ||
1992 | err2: | 1953 | err: |
1993 | if (!is_otg_enabled(musb)) | ||
1994 | musb_stop(musb); | ||
1995 | err0: | ||
1996 | return retval; | 1954 | return retval; |
1997 | } | 1955 | } |
1998 | 1956 | ||
@@ -2070,16 +2028,12 @@ static int musb_gadget_stop(struct usb_gadget *g, | |||
2070 | musb_platform_try_idle(musb, 0); | 2028 | musb_platform_try_idle(musb, 0); |
2071 | spin_unlock_irqrestore(&musb->lock, flags); | 2029 | spin_unlock_irqrestore(&musb->lock, flags); |
2072 | 2030 | ||
2073 | if (is_otg_enabled(musb)) { | 2031 | usb_remove_hcd(musb_to_hcd(musb)); |
2074 | usb_remove_hcd(musb_to_hcd(musb)); | 2032 | /* |
2075 | /* FIXME we need to be able to register another | 2033 | * FIXME we need to be able to register another |
2076 | * gadget driver here and have everything work; | 2034 | * gadget driver here and have everything work; |
2077 | * that currently misbehaves. | 2035 | * that currently misbehaves. |
2078 | */ | 2036 | */ |
2079 | } | ||
2080 | |||
2081 | if (!is_otg_enabled(musb)) | ||
2082 | musb_stop(musb); | ||
2083 | 2037 | ||
2084 | pm_runtime_put(musb->controller); | 2038 | pm_runtime_put(musb->controller); |
2085 | 2039 | ||
@@ -2241,13 +2195,11 @@ __acquires(musb->lock) | |||
2241 | if (devctl & MUSB_DEVCTL_BDEVICE) { | 2195 | if (devctl & MUSB_DEVCTL_BDEVICE) { |
2242 | musb->xceiv->state = OTG_STATE_B_PERIPHERAL; | 2196 | musb->xceiv->state = OTG_STATE_B_PERIPHERAL; |
2243 | musb->g.is_a_peripheral = 0; | 2197 | musb->g.is_a_peripheral = 0; |
2244 | } else if (is_otg_enabled(musb)) { | 2198 | } else { |
2245 | musb->xceiv->state = OTG_STATE_A_PERIPHERAL; | 2199 | musb->xceiv->state = OTG_STATE_A_PERIPHERAL; |
2246 | musb->g.is_a_peripheral = 1; | 2200 | musb->g.is_a_peripheral = 1; |
2247 | } else | 2201 | } |
2248 | WARN_ON(1); | ||
2249 | 2202 | ||
2250 | /* start with default limits on VBUS power draw */ | 2203 | /* start with default limits on VBUS power draw */ |
2251 | (void) musb_gadget_vbus_draw(&musb->g, | 2204 | (void) musb_gadget_vbus_draw(&musb->g, 8); |
2252 | is_otg_enabled(musb) ? 8 : 100); | ||
2253 | } | 2205 | } |
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c index 1ae378d5fc6f..3df6a76b851d 100644 --- a/drivers/usb/musb/musb_host.c +++ b/drivers/usb/musb/musb_host.c | |||
@@ -693,6 +693,8 @@ static void musb_ep_program(struct musb *musb, u8 epnum, | |||
693 | void __iomem *epio = hw_ep->regs; | 693 | void __iomem *epio = hw_ep->regs; |
694 | struct musb_qh *qh = musb_ep_get_qh(hw_ep, !is_out); | 694 | struct musb_qh *qh = musb_ep_get_qh(hw_ep, !is_out); |
695 | u16 packet_sz = qh->maxpacket; | 695 | u16 packet_sz = qh->maxpacket; |
696 | u8 use_dma = 1; | ||
697 | u16 csr; | ||
696 | 698 | ||
697 | dev_dbg(musb->controller, "%s hw%d urb %p spd%d dev%d ep%d%s " | 699 | dev_dbg(musb->controller, "%s hw%d urb %p spd%d dev%d ep%d%s " |
698 | "h_addr%02x h_port%02x bytes %d\n", | 700 | "h_addr%02x h_port%02x bytes %d\n", |
@@ -704,9 +706,17 @@ static void musb_ep_program(struct musb *musb, u8 epnum, | |||
704 | 706 | ||
705 | musb_ep_select(mbase, epnum); | 707 | musb_ep_select(mbase, epnum); |
706 | 708 | ||
709 | if (is_out && !len) { | ||
710 | use_dma = 0; | ||
711 | csr = musb_readw(epio, MUSB_TXCSR); | ||
712 | csr &= ~MUSB_TXCSR_DMAENAB; | ||
713 | musb_writew(epio, MUSB_TXCSR, csr); | ||
714 | hw_ep->tx_channel = NULL; | ||
715 | } | ||
716 | |||
707 | /* candidate for DMA? */ | 717 | /* candidate for DMA? */ |
708 | dma_controller = musb->dma_controller; | 718 | dma_controller = musb->dma_controller; |
709 | if (is_dma_capable() && epnum && dma_controller) { | 719 | if (use_dma && is_dma_capable() && epnum && dma_controller) { |
710 | dma_channel = is_out ? hw_ep->tx_channel : hw_ep->rx_channel; | 720 | dma_channel = is_out ? hw_ep->tx_channel : hw_ep->rx_channel; |
711 | if (!dma_channel) { | 721 | if (!dma_channel) { |
712 | dma_channel = dma_controller->channel_alloc( | 722 | dma_channel = dma_controller->channel_alloc( |
@@ -813,9 +823,28 @@ static void musb_ep_program(struct musb *musb, u8 epnum, | |||
813 | if (load_count) { | 823 | if (load_count) { |
814 | /* PIO to load FIFO */ | 824 | /* PIO to load FIFO */ |
815 | qh->segsize = load_count; | 825 | qh->segsize = load_count; |
816 | musb_write_fifo(hw_ep, load_count, buf); | 826 | if (!buf) { |
827 | sg_miter_start(&qh->sg_miter, urb->sg, 1, | ||
828 | SG_MITER_ATOMIC | ||
829 | | SG_MITER_FROM_SG); | ||
830 | if (!sg_miter_next(&qh->sg_miter)) { | ||
831 | dev_err(musb->controller, | ||
832 | "error: sg" | ||
833 | "list empty\n"); | ||
834 | sg_miter_stop(&qh->sg_miter); | ||
835 | goto finish; | ||
836 | } | ||
837 | buf = qh->sg_miter.addr + urb->sg->offset + | ||
838 | urb->actual_length; | ||
839 | load_count = min_t(u32, load_count, | ||
840 | qh->sg_miter.length); | ||
841 | musb_write_fifo(hw_ep, load_count, buf); | ||
842 | qh->sg_miter.consumed = load_count; | ||
843 | sg_miter_stop(&qh->sg_miter); | ||
844 | } else | ||
845 | musb_write_fifo(hw_ep, load_count, buf); | ||
817 | } | 846 | } |
818 | 847 | finish: | |
819 | /* re-enable interrupt */ | 848 | /* re-enable interrupt */ |
820 | musb_writew(mbase, MUSB_INTRTXE, int_txe); | 849 | musb_writew(mbase, MUSB_INTRTXE, int_txe); |
821 | 850 | ||
@@ -882,6 +911,73 @@ static void musb_ep_program(struct musb *musb, u8 epnum, | |||
882 | } | 911 | } |
883 | } | 912 | } |
884 | 913 | ||
914 | /* Schedule next QH from musb->in_bulk/out_bulk and move the current qh to | ||
915 | * the end; avoids starvation for other endpoints. | ||
916 | */ | ||
917 | static void musb_bulk_nak_timeout(struct musb *musb, struct musb_hw_ep *ep, | ||
918 | int is_in) | ||
919 | { | ||
920 | struct dma_channel *dma; | ||
921 | struct urb *urb; | ||
922 | void __iomem *mbase = musb->mregs; | ||
923 | void __iomem *epio = ep->regs; | ||
924 | struct musb_qh *cur_qh, *next_qh; | ||
925 | u16 rx_csr, tx_csr; | ||
926 | |||
927 | musb_ep_select(mbase, ep->epnum); | ||
928 | if (is_in) { | ||
929 | dma = is_dma_capable() ? ep->rx_channel : NULL; | ||
930 | |||
931 | /* clear nak timeout bit */ | ||
932 | rx_csr = musb_readw(epio, MUSB_RXCSR); | ||
933 | rx_csr |= MUSB_RXCSR_H_WZC_BITS; | ||
934 | rx_csr &= ~MUSB_RXCSR_DATAERROR; | ||
935 | musb_writew(epio, MUSB_RXCSR, rx_csr); | ||
936 | |||
937 | cur_qh = first_qh(&musb->in_bulk); | ||
938 | } else { | ||
939 | dma = is_dma_capable() ? ep->tx_channel : NULL; | ||
940 | |||
941 | /* clear nak timeout bit */ | ||
942 | tx_csr = musb_readw(epio, MUSB_TXCSR); | ||
943 | tx_csr |= MUSB_TXCSR_H_WZC_BITS; | ||
944 | tx_csr &= ~MUSB_TXCSR_H_NAKTIMEOUT; | ||
945 | musb_writew(epio, MUSB_TXCSR, tx_csr); | ||
946 | |||
947 | cur_qh = first_qh(&musb->out_bulk); | ||
948 | } | ||
949 | if (cur_qh) { | ||
950 | urb = next_urb(cur_qh); | ||
951 | if (dma_channel_status(dma) == MUSB_DMA_STATUS_BUSY) { | ||
952 | dma->status = MUSB_DMA_STATUS_CORE_ABORT; | ||
953 | musb->dma_controller->channel_abort(dma); | ||
954 | urb->actual_length += dma->actual_len; | ||
955 | dma->actual_len = 0L; | ||
956 | } | ||
957 | musb_save_toggle(cur_qh, is_in, urb); | ||
958 | |||
959 | if (is_in) { | ||
960 | /* move cur_qh to end of queue */ | ||
961 | list_move_tail(&cur_qh->ring, &musb->in_bulk); | ||
962 | |||
963 | /* get the next qh from musb->in_bulk */ | ||
964 | next_qh = first_qh(&musb->in_bulk); | ||
965 | |||
966 | /* set rx_reinit and schedule the next qh */ | ||
967 | ep->rx_reinit = 1; | ||
968 | } else { | ||
969 | /* move cur_qh to end of queue */ | ||
970 | list_move_tail(&cur_qh->ring, &musb->out_bulk); | ||
971 | |||
972 | /* get the next qh from musb->out_bulk */ | ||
973 | next_qh = first_qh(&musb->out_bulk); | ||
974 | |||
975 | /* set tx_reinit and schedule the next qh */ | ||
976 | ep->tx_reinit = 1; | ||
977 | } | ||
978 | musb_start_urb(musb, is_in, next_qh); | ||
979 | } | ||
980 | } | ||
885 | 981 | ||
886 | /* | 982 | /* |
887 | * Service the default endpoint (ep0) as host. | 983 | * Service the default endpoint (ep0) as host. |
@@ -1116,6 +1212,7 @@ void musb_host_tx(struct musb *musb, u8 epnum) | |||
1116 | void __iomem *mbase = musb->mregs; | 1212 | void __iomem *mbase = musb->mregs; |
1117 | struct dma_channel *dma; | 1213 | struct dma_channel *dma; |
1118 | bool transfer_pending = false; | 1214 | bool transfer_pending = false; |
1215 | static bool use_sg; | ||
1119 | 1216 | ||
1120 | musb_ep_select(mbase, epnum); | 1217 | musb_ep_select(mbase, epnum); |
1121 | tx_csr = musb_readw(epio, MUSB_TXCSR); | 1218 | tx_csr = musb_readw(epio, MUSB_TXCSR); |
@@ -1146,23 +1243,31 @@ void musb_host_tx(struct musb *musb, u8 epnum) | |||
1146 | status = -ETIMEDOUT; | 1243 | status = -ETIMEDOUT; |
1147 | 1244 | ||
1148 | } else if (tx_csr & MUSB_TXCSR_H_NAKTIMEOUT) { | 1245 | } else if (tx_csr & MUSB_TXCSR_H_NAKTIMEOUT) { |
1149 | dev_dbg(musb->controller, "TX end=%d device not responding\n", epnum); | 1246 | if (USB_ENDPOINT_XFER_BULK == qh->type && qh->mux == 1 |
1150 | 1247 | && !list_is_singular(&musb->out_bulk)) { | |
1151 | /* NOTE: this code path would be a good place to PAUSE a | 1248 | dev_dbg(musb->controller, |
1152 | * transfer, if there's some other (nonperiodic) tx urb | 1249 | "NAK timeout on TX%d ep\n", epnum); |
1153 | * that could use this fifo. (dma complicates it...) | 1250 | musb_bulk_nak_timeout(musb, hw_ep, 0); |
1154 | * That's already done for bulk RX transfers. | 1251 | } else { |
1155 | * | 1252 | dev_dbg(musb->controller, |
1156 | * if (bulk && qh->ring.next != &musb->out_bulk), then | 1253 | "TX end=%d device not responding\n", epnum); |
1157 | * we have a candidate... NAKing is *NOT* an error | 1254 | /* NOTE: this code path would be a good place to PAUSE a |
1158 | */ | 1255 | * transfer, if there's some other (nonperiodic) tx urb |
1159 | musb_ep_select(mbase, epnum); | 1256 | * that could use this fifo. (dma complicates it...) |
1160 | musb_writew(epio, MUSB_TXCSR, | 1257 | * That's already done for bulk RX transfers. |
1161 | MUSB_TXCSR_H_WZC_BITS | 1258 | * |
1162 | | MUSB_TXCSR_TXPKTRDY); | 1259 | * if (bulk && qh->ring.next != &musb->out_bulk), then |
1163 | return; | 1260 | * we have a candidate... NAKing is *NOT* an error |
1261 | */ | ||
1262 | musb_ep_select(mbase, epnum); | ||
1263 | musb_writew(epio, MUSB_TXCSR, | ||
1264 | MUSB_TXCSR_H_WZC_BITS | ||
1265 | | MUSB_TXCSR_TXPKTRDY); | ||
1266 | } | ||
1267 | return; | ||
1164 | } | 1268 | } |
1165 | 1269 | ||
1270 | done: | ||
1166 | if (status) { | 1271 | if (status) { |
1167 | if (dma_channel_status(dma) == MUSB_DMA_STATUS_BUSY) { | 1272 | if (dma_channel_status(dma) == MUSB_DMA_STATUS_BUSY) { |
1168 | dma->status = MUSB_DMA_STATUS_CORE_ABORT; | 1273 | dma->status = MUSB_DMA_STATUS_CORE_ABORT; |
@@ -1332,9 +1437,38 @@ void musb_host_tx(struct musb *musb, u8 epnum) | |||
1332 | length = qh->maxpacket; | 1437 | length = qh->maxpacket; |
1333 | /* Unmap the buffer so that CPU can use it */ | 1438 | /* Unmap the buffer so that CPU can use it */ |
1334 | usb_hcd_unmap_urb_for_dma(musb_to_hcd(musb), urb); | 1439 | usb_hcd_unmap_urb_for_dma(musb_to_hcd(musb), urb); |
1335 | musb_write_fifo(hw_ep, length, urb->transfer_buffer + offset); | 1440 | |
1441 | /* | ||
1442 | * We need to map sg if the transfer_buffer is | ||
1443 | * NULL. | ||
1444 | */ | ||
1445 | if (!urb->transfer_buffer) | ||
1446 | use_sg = true; | ||
1447 | |||
1448 | if (use_sg) { | ||
1449 | /* sg_miter_start is already done in musb_ep_program */ | ||
1450 | if (!sg_miter_next(&qh->sg_miter)) { | ||
1451 | dev_err(musb->controller, "error: sg list empty\n"); | ||
1452 | sg_miter_stop(&qh->sg_miter); | ||
1453 | status = -EINVAL; | ||
1454 | goto done; | ||
1455 | } | ||
1456 | urb->transfer_buffer = qh->sg_miter.addr; | ||
1457 | length = min_t(u32, length, qh->sg_miter.length); | ||
1458 | musb_write_fifo(hw_ep, length, urb->transfer_buffer); | ||
1459 | qh->sg_miter.consumed = length; | ||
1460 | sg_miter_stop(&qh->sg_miter); | ||
1461 | } else { | ||
1462 | musb_write_fifo(hw_ep, length, urb->transfer_buffer + offset); | ||
1463 | } | ||
1464 | |||
1336 | qh->segsize = length; | 1465 | qh->segsize = length; |
1337 | 1466 | ||
1467 | if (use_sg) { | ||
1468 | if (offset + length >= urb->transfer_buffer_length) | ||
1469 | use_sg = false; | ||
1470 | } | ||
1471 | |||
1338 | musb_ep_select(mbase, epnum); | 1472 | musb_ep_select(mbase, epnum); |
1339 | musb_writew(epio, MUSB_TXCSR, | 1473 | musb_writew(epio, MUSB_TXCSR, |
1340 | MUSB_TXCSR_H_WZC_BITS | MUSB_TXCSR_TXPKTRDY); | 1474 | MUSB_TXCSR_H_WZC_BITS | MUSB_TXCSR_TXPKTRDY); |
@@ -1380,50 +1514,6 @@ void musb_host_tx(struct musb *musb, u8 epnum) | |||
1380 | 1514 | ||
1381 | #endif | 1515 | #endif |
1382 | 1516 | ||
1383 | /* Schedule next QH from musb->in_bulk and move the current qh to | ||
1384 | * the end; avoids starvation for other endpoints. | ||
1385 | */ | ||
1386 | static void musb_bulk_rx_nak_timeout(struct musb *musb, struct musb_hw_ep *ep) | ||
1387 | { | ||
1388 | struct dma_channel *dma; | ||
1389 | struct urb *urb; | ||
1390 | void __iomem *mbase = musb->mregs; | ||
1391 | void __iomem *epio = ep->regs; | ||
1392 | struct musb_qh *cur_qh, *next_qh; | ||
1393 | u16 rx_csr; | ||
1394 | |||
1395 | musb_ep_select(mbase, ep->epnum); | ||
1396 | dma = is_dma_capable() ? ep->rx_channel : NULL; | ||
1397 | |||
1398 | /* clear nak timeout bit */ | ||
1399 | rx_csr = musb_readw(epio, MUSB_RXCSR); | ||
1400 | rx_csr |= MUSB_RXCSR_H_WZC_BITS; | ||
1401 | rx_csr &= ~MUSB_RXCSR_DATAERROR; | ||
1402 | musb_writew(epio, MUSB_RXCSR, rx_csr); | ||
1403 | |||
1404 | cur_qh = first_qh(&musb->in_bulk); | ||
1405 | if (cur_qh) { | ||
1406 | urb = next_urb(cur_qh); | ||
1407 | if (dma_channel_status(dma) == MUSB_DMA_STATUS_BUSY) { | ||
1408 | dma->status = MUSB_DMA_STATUS_CORE_ABORT; | ||
1409 | musb->dma_controller->channel_abort(dma); | ||
1410 | urb->actual_length += dma->actual_len; | ||
1411 | dma->actual_len = 0L; | ||
1412 | } | ||
1413 | musb_save_toggle(cur_qh, 1, urb); | ||
1414 | |||
1415 | /* move cur_qh to end of queue */ | ||
1416 | list_move_tail(&cur_qh->ring, &musb->in_bulk); | ||
1417 | |||
1418 | /* get the next qh from musb->in_bulk */ | ||
1419 | next_qh = first_qh(&musb->in_bulk); | ||
1420 | |||
1421 | /* set rx_reinit and schedule the next qh */ | ||
1422 | ep->rx_reinit = 1; | ||
1423 | musb_start_urb(musb, 1, next_qh); | ||
1424 | } | ||
1425 | } | ||
1426 | |||
1427 | /* | 1517 | /* |
1428 | * Service an RX interrupt for the given IN endpoint; docs cover bulk, iso, | 1518 | * Service an RX interrupt for the given IN endpoint; docs cover bulk, iso, |
1429 | * and high-bandwidth IN transfer cases. | 1519 | * and high-bandwidth IN transfer cases. |
@@ -1442,6 +1532,8 @@ void musb_host_rx(struct musb *musb, u8 epnum) | |||
1442 | bool done = false; | 1532 | bool done = false; |
1443 | u32 status; | 1533 | u32 status; |
1444 | struct dma_channel *dma; | 1534 | struct dma_channel *dma; |
1535 | static bool use_sg; | ||
1536 | unsigned int sg_flags = SG_MITER_ATOMIC | SG_MITER_TO_SG; | ||
1445 | 1537 | ||
1446 | musb_ep_select(mbase, epnum); | 1538 | musb_ep_select(mbase, epnum); |
1447 | 1539 | ||
@@ -1500,7 +1592,7 @@ void musb_host_rx(struct musb *musb, u8 epnum) | |||
1500 | if (usb_pipebulk(urb->pipe) | 1592 | if (usb_pipebulk(urb->pipe) |
1501 | && qh->mux == 1 | 1593 | && qh->mux == 1 |
1502 | && !list_is_singular(&musb->in_bulk)) { | 1594 | && !list_is_singular(&musb->in_bulk)) { |
1503 | musb_bulk_rx_nak_timeout(musb, hw_ep); | 1595 | musb_bulk_nak_timeout(musb, hw_ep, 1); |
1504 | return; | 1596 | return; |
1505 | } | 1597 | } |
1506 | musb_ep_select(mbase, epnum); | 1598 | musb_ep_select(mbase, epnum); |
@@ -1756,10 +1848,43 @@ void musb_host_rx(struct musb *musb, u8 epnum) | |||
1756 | #endif /* Mentor DMA */ | 1848 | #endif /* Mentor DMA */ |
1757 | 1849 | ||
1758 | if (!dma) { | 1850 | if (!dma) { |
1851 | unsigned int received_len; | ||
1852 | |||
1759 | /* Unmap the buffer so that CPU can use it */ | 1853 | /* Unmap the buffer so that CPU can use it */ |
1760 | usb_hcd_unmap_urb_for_dma(musb_to_hcd(musb), urb); | 1854 | usb_hcd_unmap_urb_for_dma(musb_to_hcd(musb), urb); |
1761 | done = musb_host_packet_rx(musb, urb, | 1855 | |
1762 | epnum, iso_err); | 1856 | /* |
1857 | * We need to map sg if the transfer_buffer is | ||
1858 | * NULL. | ||
1859 | */ | ||
1860 | if (!urb->transfer_buffer) { | ||
1861 | use_sg = true; | ||
1862 | sg_miter_start(&qh->sg_miter, urb->sg, 1, | ||
1863 | sg_flags); | ||
1864 | } | ||
1865 | |||
1866 | if (use_sg) { | ||
1867 | if (!sg_miter_next(&qh->sg_miter)) { | ||
1868 | dev_err(musb->controller, "error: sg list empty\n"); | ||
1869 | sg_miter_stop(&qh->sg_miter); | ||
1870 | status = -EINVAL; | ||
1871 | done = true; | ||
1872 | goto finish; | ||
1873 | } | ||
1874 | urb->transfer_buffer = qh->sg_miter.addr; | ||
1875 | received_len = urb->actual_length; | ||
1876 | qh->offset = 0x0; | ||
1877 | done = musb_host_packet_rx(musb, urb, epnum, | ||
1878 | iso_err); | ||
1879 | /* Calculate the number of bytes received */ | ||
1880 | received_len = urb->actual_length - | ||
1881 | received_len; | ||
1882 | qh->sg_miter.consumed = received_len; | ||
1883 | sg_miter_stop(&qh->sg_miter); | ||
1884 | } else { | ||
1885 | done = musb_host_packet_rx(musb, urb, | ||
1886 | epnum, iso_err); | ||
1887 | } | ||
1763 | dev_dbg(musb->controller, "read %spacket\n", done ? "last " : ""); | 1888 | dev_dbg(musb->controller, "read %spacket\n", done ? "last " : ""); |
1764 | } | 1889 | } |
1765 | } | 1890 | } |
@@ -1768,6 +1893,9 @@ finish: | |||
1768 | urb->actual_length += xfer_len; | 1893 | urb->actual_length += xfer_len; |
1769 | qh->offset += xfer_len; | 1894 | qh->offset += xfer_len; |
1770 | if (done) { | 1895 | if (done) { |
1896 | if (use_sg) | ||
1897 | use_sg = false; | ||
1898 | |||
1771 | if (urb->status == -EINPROGRESS) | 1899 | if (urb->status == -EINPROGRESS) |
1772 | urb->status = status; | 1900 | urb->status = status; |
1773 | musb_advance_schedule(musb, urb, hw_ep, USB_DIR_IN); | 1901 | musb_advance_schedule(musb, urb, hw_ep, USB_DIR_IN); |
@@ -1863,14 +1991,14 @@ static int musb_schedule( | |||
1863 | else | 1991 | else |
1864 | head = &musb->out_bulk; | 1992 | head = &musb->out_bulk; |
1865 | 1993 | ||
1866 | /* Enable bulk RX NAK timeout scheme when bulk requests are | 1994 | /* Enable bulk RX/TX NAK timeout scheme when bulk requests are |
1867 | * multiplexed. This scheme doen't work in high speed to full | 1995 | * multiplexed. This scheme doen't work in high speed to full |
1868 | * speed scenario as NAK interrupts are not coming from a | 1996 | * speed scenario as NAK interrupts are not coming from a |
1869 | * full speed device connected to a high speed device. | 1997 | * full speed device connected to a high speed device. |
1870 | * NAK timeout interval is 8 (128 uframe or 16ms) for HS and | 1998 | * NAK timeout interval is 8 (128 uframe or 16ms) for HS and |
1871 | * 4 (8 frame or 8ms) for FS device. | 1999 | * 4 (8 frame or 8ms) for FS device. |
1872 | */ | 2000 | */ |
1873 | if (is_in && qh->dev) | 2001 | if (qh->dev) |
1874 | qh->intv_reg = | 2002 | qh->intv_reg = |
1875 | (USB_SPEED_HIGH == qh->dev->speed) ? 8 : 4; | 2003 | (USB_SPEED_HIGH == qh->dev->speed) ? 8 : 4; |
1876 | goto success; | 2004 | goto success; |
diff --git a/drivers/usb/musb/musb_host.h b/drivers/usb/musb/musb_host.h index 622d09fb9aba..5a9c8feec10c 100644 --- a/drivers/usb/musb/musb_host.h +++ b/drivers/usb/musb/musb_host.h | |||
@@ -35,6 +35,8 @@ | |||
35 | #ifndef _MUSB_HOST_H | 35 | #ifndef _MUSB_HOST_H |
36 | #define _MUSB_HOST_H | 36 | #define _MUSB_HOST_H |
37 | 37 | ||
38 | #include <linux/scatterlist.h> | ||
39 | |||
38 | static inline struct usb_hcd *musb_to_hcd(struct musb *musb) | 40 | static inline struct usb_hcd *musb_to_hcd(struct musb *musb) |
39 | { | 41 | { |
40 | return container_of((void *) musb, struct usb_hcd, hcd_priv); | 42 | return container_of((void *) musb, struct usb_hcd, hcd_priv); |
@@ -71,6 +73,7 @@ struct musb_qh { | |||
71 | u16 maxpacket; | 73 | u16 maxpacket; |
72 | u16 frame; /* for periodic schedule */ | 74 | u16 frame; /* for periodic schedule */ |
73 | unsigned iso_idx; /* in urb->iso_frame_desc[] */ | 75 | unsigned iso_idx; /* in urb->iso_frame_desc[] */ |
76 | struct sg_mapping_iter sg_miter; /* for highmem in PIO mode */ | ||
74 | }; | 77 | }; |
75 | 78 | ||
76 | /* map from control or bulk queue head to the first qh on that ring */ | 79 | /* map from control or bulk queue head to the first qh on that ring */ |
diff --git a/drivers/usb/musb/musb_virthub.c b/drivers/usb/musb/musb_virthub.c index 22ec3e379980..f70579154ded 100644 --- a/drivers/usb/musb/musb_virthub.c +++ b/drivers/usb/musb/musb_virthub.c | |||
@@ -81,8 +81,7 @@ static void musb_port_suspend(struct musb *musb, bool do_suspend) | |||
81 | switch (musb->xceiv->state) { | 81 | switch (musb->xceiv->state) { |
82 | case OTG_STATE_A_HOST: | 82 | case OTG_STATE_A_HOST: |
83 | musb->xceiv->state = OTG_STATE_A_SUSPEND; | 83 | musb->xceiv->state = OTG_STATE_A_SUSPEND; |
84 | musb->is_active = is_otg_enabled(musb) | 84 | musb->is_active = otg->host->b_hnp_enable; |
85 | && otg->host->b_hnp_enable; | ||
86 | if (musb->is_active) | 85 | if (musb->is_active) |
87 | mod_timer(&musb->otg_timer, jiffies | 86 | mod_timer(&musb->otg_timer, jiffies |
88 | + msecs_to_jiffies( | 87 | + msecs_to_jiffies( |
@@ -91,8 +90,7 @@ static void musb_port_suspend(struct musb *musb, bool do_suspend) | |||
91 | break; | 90 | break; |
92 | case OTG_STATE_B_HOST: | 91 | case OTG_STATE_B_HOST: |
93 | musb->xceiv->state = OTG_STATE_B_WAIT_ACON; | 92 | musb->xceiv->state = OTG_STATE_B_WAIT_ACON; |
94 | musb->is_active = is_otg_enabled(musb) | 93 | musb->is_active = otg->host->b_hnp_enable; |
95 | && otg->host->b_hnp_enable; | ||
96 | musb_platform_try_idle(musb, 0); | 94 | musb_platform_try_idle(musb, 0); |
97 | break; | 95 | break; |
98 | default: | 96 | default: |
@@ -190,8 +188,7 @@ void musb_root_disconnect(struct musb *musb) | |||
190 | 188 | ||
191 | switch (musb->xceiv->state) { | 189 | switch (musb->xceiv->state) { |
192 | case OTG_STATE_A_SUSPEND: | 190 | case OTG_STATE_A_SUSPEND: |
193 | if (is_otg_enabled(musb) | 191 | if (otg->host->b_hnp_enable) { |
194 | && otg->host->b_hnp_enable) { | ||
195 | musb->xceiv->state = OTG_STATE_A_PERIPHERAL; | 192 | musb->xceiv->state = OTG_STATE_A_PERIPHERAL; |
196 | musb->g.is_a_peripheral = 1; | 193 | musb->g.is_a_peripheral = 1; |
197 | break; | 194 | break; |
@@ -273,7 +270,7 @@ int musb_hub_control( | |||
273 | musb_port_suspend(musb, false); | 270 | musb_port_suspend(musb, false); |
274 | break; | 271 | break; |
275 | case USB_PORT_FEAT_POWER: | 272 | case USB_PORT_FEAT_POWER: |
276 | if (!(is_otg_enabled(musb) && hcd->self.is_b_host)) | 273 | if (!hcd->self.is_b_host) |
277 | musb_platform_set_vbus(musb, 0); | 274 | musb_platform_set_vbus(musb, 0); |
278 | break; | 275 | break; |
279 | case USB_PORT_FEAT_C_CONNECTION: | 276 | case USB_PORT_FEAT_C_CONNECTION: |
@@ -369,7 +366,7 @@ int musb_hub_control( | |||
369 | * initialization logic, e.g. for OTG, or change any | 366 | * initialization logic, e.g. for OTG, or change any |
370 | * logic relating to VBUS power-up. | 367 | * logic relating to VBUS power-up. |
371 | */ | 368 | */ |
372 | if (!(is_otg_enabled(musb) && hcd->self.is_b_host)) | 369 | if (!hcd->self.is_b_host) |
373 | musb_start(musb); | 370 | musb_start(musb); |
374 | break; | 371 | break; |
375 | case USB_PORT_FEAT_RESET: | 372 | case USB_PORT_FEAT_RESET: |
diff --git a/drivers/usb/musb/musbhsdma.c b/drivers/usb/musb/musbhsdma.c index c1be687e00ec..0fc6ca6bc60a 100644 --- a/drivers/usb/musb/musbhsdma.c +++ b/drivers/usb/musb/musbhsdma.c | |||
@@ -380,7 +380,7 @@ void dma_controller_destroy(struct dma_controller *c) | |||
380 | kfree(controller); | 380 | kfree(controller); |
381 | } | 381 | } |
382 | 382 | ||
383 | struct dma_controller *__init | 383 | struct dma_controller *__devinit |
384 | dma_controller_create(struct musb *musb, void __iomem *base) | 384 | dma_controller_create(struct musb *musb, void __iomem *base) |
385 | { | 385 | { |
386 | struct musb_dma_controller *controller; | 386 | struct musb_dma_controller *controller; |
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c index 5fdb9da8dd56..a538fe17a966 100644 --- a/drivers/usb/musb/omap2430.c +++ b/drivers/usb/musb/omap2430.c | |||
@@ -30,10 +30,12 @@ | |||
30 | #include <linux/init.h> | 30 | #include <linux/init.h> |
31 | #include <linux/list.h> | 31 | #include <linux/list.h> |
32 | #include <linux/io.h> | 32 | #include <linux/io.h> |
33 | #include <linux/of.h> | ||
33 | #include <linux/platform_device.h> | 34 | #include <linux/platform_device.h> |
34 | #include <linux/dma-mapping.h> | 35 | #include <linux/dma-mapping.h> |
35 | #include <linux/pm_runtime.h> | 36 | #include <linux/pm_runtime.h> |
36 | #include <linux/err.h> | 37 | #include <linux/err.h> |
38 | #include <linux/delay.h> | ||
37 | #include <linux/usb/musb-omap.h> | 39 | #include <linux/usb/musb-omap.h> |
38 | 40 | ||
39 | #include "musb_core.h" | 41 | #include "musb_core.h" |
@@ -44,6 +46,7 @@ struct omap2430_glue { | |||
44 | struct platform_device *musb; | 46 | struct platform_device *musb; |
45 | enum omap_musb_vbus_id_status status; | 47 | enum omap_musb_vbus_id_status status; |
46 | struct work_struct omap_musb_mailbox_work; | 48 | struct work_struct omap_musb_mailbox_work; |
49 | u32 __iomem *control_otghs; | ||
47 | }; | 50 | }; |
48 | #define glue_to_musb(g) platform_get_drvdata(g->musb) | 51 | #define glue_to_musb(g) platform_get_drvdata(g->musb) |
49 | 52 | ||
@@ -51,6 +54,26 @@ struct omap2430_glue *_glue; | |||
51 | 54 | ||
52 | static struct timer_list musb_idle_timer; | 55 | static struct timer_list musb_idle_timer; |
53 | 56 | ||
57 | /** | ||
58 | * omap4_usb_phy_mailbox - write to usb otg mailbox | ||
59 | * @glue: struct omap2430_glue * | ||
60 | * @val: the value to be written to the mailbox | ||
61 | * | ||
62 | * On detection of a device (ID pin is grounded), this API should be called | ||
63 | * to set AVALID, VBUSVALID and ID pin is grounded. | ||
64 | * | ||
65 | * When OMAP is connected to a host (OMAP in device mode), this API | ||
66 | * is called to set AVALID, VBUSVALID and ID pin in high impedance. | ||
67 | * | ||
68 | * XXX: This function will be removed once we have a seperate driver for | ||
69 | * control module | ||
70 | */ | ||
71 | static void omap4_usb_phy_mailbox(struct omap2430_glue *glue, u32 val) | ||
72 | { | ||
73 | if (glue->control_otghs) | ||
74 | writel(val, glue->control_otghs); | ||
75 | } | ||
76 | |||
54 | static void musb_do_idle(unsigned long _musb) | 77 | static void musb_do_idle(unsigned long _musb) |
55 | { | 78 | { |
56 | struct musb *musb = (void *)_musb; | 79 | struct musb *musb = (void *)_musb; |
@@ -140,7 +163,6 @@ static void omap2430_musb_set_vbus(struct musb *musb, int is_on) | |||
140 | struct usb_otg *otg = musb->xceiv->otg; | 163 | struct usb_otg *otg = musb->xceiv->otg; |
141 | u8 devctl; | 164 | u8 devctl; |
142 | unsigned long timeout = jiffies + msecs_to_jiffies(1000); | 165 | unsigned long timeout = jiffies + msecs_to_jiffies(1000); |
143 | int ret = 1; | ||
144 | /* HDRC controls CPEN, but beware current surges during device | 166 | /* HDRC controls CPEN, but beware current surges during device |
145 | * connect. They can trigger transient overcurrent conditions | 167 | * connect. They can trigger transient overcurrent conditions |
146 | * that must be ignored. | 168 | * that must be ignored. |
@@ -150,6 +172,7 @@ static void omap2430_musb_set_vbus(struct musb *musb, int is_on) | |||
150 | 172 | ||
151 | if (is_on) { | 173 | if (is_on) { |
152 | if (musb->xceiv->state == OTG_STATE_A_IDLE) { | 174 | if (musb->xceiv->state == OTG_STATE_A_IDLE) { |
175 | int loops = 100; | ||
153 | /* start the session */ | 176 | /* start the session */ |
154 | devctl |= MUSB_DEVCTL_SESSION; | 177 | devctl |= MUSB_DEVCTL_SESSION; |
155 | musb_writeb(musb->mregs, MUSB_DEVCTL, devctl); | 178 | musb_writeb(musb->mregs, MUSB_DEVCTL, devctl); |
@@ -159,17 +182,18 @@ static void omap2430_musb_set_vbus(struct musb *musb, int is_on) | |||
159 | */ | 182 | */ |
160 | while (musb_readb(musb->mregs, MUSB_DEVCTL) & 0x80) { | 183 | while (musb_readb(musb->mregs, MUSB_DEVCTL) & 0x80) { |
161 | 184 | ||
185 | mdelay(5); | ||
162 | cpu_relax(); | 186 | cpu_relax(); |
163 | 187 | ||
164 | if (time_after(jiffies, timeout)) { | 188 | if (time_after(jiffies, timeout) |
189 | || loops-- <= 0) { | ||
165 | dev_err(musb->controller, | 190 | dev_err(musb->controller, |
166 | "configured as A device timeout"); | 191 | "configured as A device timeout"); |
167 | ret = -EINVAL; | ||
168 | break; | 192 | break; |
169 | } | 193 | } |
170 | } | 194 | } |
171 | 195 | ||
172 | if (ret && otg->set_vbus) | 196 | if (otg->set_vbus) |
173 | otg_set_vbus(otg, 1); | 197 | otg_set_vbus(otg, 1); |
174 | } else { | 198 | } else { |
175 | musb->is_active = 1; | 199 | musb->is_active = 1; |
@@ -245,6 +269,7 @@ EXPORT_SYMBOL_GPL(omap_musb_mailbox); | |||
245 | 269 | ||
246 | static void omap_musb_set_mailbox(struct omap2430_glue *glue) | 270 | static void omap_musb_set_mailbox(struct omap2430_glue *glue) |
247 | { | 271 | { |
272 | u32 val; | ||
248 | struct musb *musb = glue_to_musb(glue); | 273 | struct musb *musb = glue_to_musb(glue); |
249 | struct device *dev = musb->controller; | 274 | struct device *dev = musb->controller; |
250 | struct musb_hdrc_platform_data *pdata = dev->platform_data; | 275 | struct musb_hdrc_platform_data *pdata = dev->platform_data; |
@@ -258,9 +283,10 @@ static void omap_musb_set_mailbox(struct omap2430_glue *glue) | |||
258 | otg->default_a = true; | 283 | otg->default_a = true; |
259 | musb->xceiv->state = OTG_STATE_A_IDLE; | 284 | musb->xceiv->state = OTG_STATE_A_IDLE; |
260 | musb->xceiv->last_event = USB_EVENT_ID; | 285 | musb->xceiv->last_event = USB_EVENT_ID; |
261 | if (!is_otg_enabled(musb) || musb->gadget_driver) { | 286 | if (musb->gadget_driver) { |
262 | pm_runtime_get_sync(dev); | 287 | pm_runtime_get_sync(dev); |
263 | usb_phy_init(musb->xceiv); | 288 | val = AVALID | VBUSVALID; |
289 | omap4_usb_phy_mailbox(glue, val); | ||
264 | omap2430_musb_set_vbus(musb, 1); | 290 | omap2430_musb_set_vbus(musb, 1); |
265 | } | 291 | } |
266 | break; | 292 | break; |
@@ -273,7 +299,8 @@ static void omap_musb_set_mailbox(struct omap2430_glue *glue) | |||
273 | musb->xceiv->last_event = USB_EVENT_VBUS; | 299 | musb->xceiv->last_event = USB_EVENT_VBUS; |
274 | if (musb->gadget_driver) | 300 | if (musb->gadget_driver) |
275 | pm_runtime_get_sync(dev); | 301 | pm_runtime_get_sync(dev); |
276 | usb_phy_init(musb->xceiv); | 302 | val = IDDIG | AVALID | VBUSVALID; |
303 | omap4_usb_phy_mailbox(glue, val); | ||
277 | break; | 304 | break; |
278 | 305 | ||
279 | case OMAP_MUSB_ID_FLOAT: | 306 | case OMAP_MUSB_ID_FLOAT: |
@@ -281,17 +308,17 @@ static void omap_musb_set_mailbox(struct omap2430_glue *glue) | |||
281 | dev_dbg(dev, "VBUS Disconnect\n"); | 308 | dev_dbg(dev, "VBUS Disconnect\n"); |
282 | 309 | ||
283 | musb->xceiv->last_event = USB_EVENT_NONE; | 310 | musb->xceiv->last_event = USB_EVENT_NONE; |
284 | if (is_otg_enabled(musb) || is_peripheral_enabled(musb)) | 311 | if (musb->gadget_driver) { |
285 | if (musb->gadget_driver) { | 312 | pm_runtime_mark_last_busy(dev); |
286 | pm_runtime_mark_last_busy(dev); | 313 | pm_runtime_put_autosuspend(dev); |
287 | pm_runtime_put_autosuspend(dev); | 314 | } |
288 | } | ||
289 | 315 | ||
290 | if (data->interface_type == MUSB_INTERFACE_UTMI) { | 316 | if (data->interface_type == MUSB_INTERFACE_UTMI) { |
291 | if (musb->xceiv->otg->set_vbus) | 317 | if (musb->xceiv->otg->set_vbus) |
292 | otg_set_vbus(musb->xceiv->otg, 0); | 318 | otg_set_vbus(musb->xceiv->otg, 0); |
293 | } | 319 | } |
294 | usb_phy_shutdown(musb->xceiv); | 320 | val = SESSEND | IDDIG; |
321 | omap4_usb_phy_mailbox(glue, val); | ||
295 | break; | 322 | break; |
296 | default: | 323 | default: |
297 | dev_dbg(dev, "ID float\n"); | 324 | dev_dbg(dev, "ID float\n"); |
@@ -366,6 +393,7 @@ err1: | |||
366 | static void omap2430_musb_enable(struct musb *musb) | 393 | static void omap2430_musb_enable(struct musb *musb) |
367 | { | 394 | { |
368 | u8 devctl; | 395 | u8 devctl; |
396 | u32 val; | ||
369 | unsigned long timeout = jiffies + msecs_to_jiffies(1000); | 397 | unsigned long timeout = jiffies + msecs_to_jiffies(1000); |
370 | struct device *dev = musb->controller; | 398 | struct device *dev = musb->controller; |
371 | struct omap2430_glue *glue = dev_get_drvdata(dev->parent); | 399 | struct omap2430_glue *glue = dev_get_drvdata(dev->parent); |
@@ -375,7 +403,8 @@ static void omap2430_musb_enable(struct musb *musb) | |||
375 | switch (glue->status) { | 403 | switch (glue->status) { |
376 | 404 | ||
377 | case OMAP_MUSB_ID_GROUND: | 405 | case OMAP_MUSB_ID_GROUND: |
378 | usb_phy_init(musb->xceiv); | 406 | val = AVALID | VBUSVALID; |
407 | omap4_usb_phy_mailbox(glue, val); | ||
379 | if (data->interface_type != MUSB_INTERFACE_UTMI) | 408 | if (data->interface_type != MUSB_INTERFACE_UTMI) |
380 | break; | 409 | break; |
381 | devctl = musb_readb(musb->mregs, MUSB_DEVCTL); | 410 | devctl = musb_readb(musb->mregs, MUSB_DEVCTL); |
@@ -394,7 +423,8 @@ static void omap2430_musb_enable(struct musb *musb) | |||
394 | break; | 423 | break; |
395 | 424 | ||
396 | case OMAP_MUSB_VBUS_VALID: | 425 | case OMAP_MUSB_VBUS_VALID: |
397 | usb_phy_init(musb->xceiv); | 426 | val = IDDIG | AVALID | VBUSVALID; |
427 | omap4_usb_phy_mailbox(glue, val); | ||
398 | break; | 428 | break; |
399 | 429 | ||
400 | default: | 430 | default: |
@@ -404,11 +434,14 @@ static void omap2430_musb_enable(struct musb *musb) | |||
404 | 434 | ||
405 | static void omap2430_musb_disable(struct musb *musb) | 435 | static void omap2430_musb_disable(struct musb *musb) |
406 | { | 436 | { |
437 | u32 val; | ||
407 | struct device *dev = musb->controller; | 438 | struct device *dev = musb->controller; |
408 | struct omap2430_glue *glue = dev_get_drvdata(dev->parent); | 439 | struct omap2430_glue *glue = dev_get_drvdata(dev->parent); |
409 | 440 | ||
410 | if (glue->status != OMAP_MUSB_UNKNOWN) | 441 | if (glue->status != OMAP_MUSB_UNKNOWN) { |
411 | usb_phy_shutdown(musb->xceiv); | 442 | val = SESSEND | IDDIG; |
443 | omap4_usb_phy_mailbox(glue, val); | ||
444 | } | ||
412 | } | 445 | } |
413 | 446 | ||
414 | static int omap2430_musb_exit(struct musb *musb) | 447 | static int omap2430_musb_exit(struct musb *musb) |
@@ -438,9 +471,14 @@ static u64 omap2430_dmamask = DMA_BIT_MASK(32); | |||
438 | static int __devinit omap2430_probe(struct platform_device *pdev) | 471 | static int __devinit omap2430_probe(struct platform_device *pdev) |
439 | { | 472 | { |
440 | struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; | 473 | struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; |
474 | struct omap_musb_board_data *data; | ||
441 | struct platform_device *musb; | 475 | struct platform_device *musb; |
442 | struct omap2430_glue *glue; | 476 | struct omap2430_glue *glue; |
477 | struct device_node *np = pdev->dev.of_node; | ||
478 | struct musb_hdrc_config *config; | ||
479 | struct resource *res; | ||
443 | int ret = -ENOMEM; | 480 | int ret = -ENOMEM; |
481 | int musbid; | ||
444 | 482 | ||
445 | glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL); | 483 | glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL); |
446 | if (!glue) { | 484 | if (!glue) { |
@@ -448,12 +486,21 @@ static int __devinit omap2430_probe(struct platform_device *pdev) | |||
448 | goto err0; | 486 | goto err0; |
449 | } | 487 | } |
450 | 488 | ||
451 | musb = platform_device_alloc("musb-hdrc", -1); | 489 | /* get the musb id */ |
490 | musbid = musb_get_id(&pdev->dev, GFP_KERNEL); | ||
491 | if (musbid < 0) { | ||
492 | dev_err(&pdev->dev, "failed to allocate musb id\n"); | ||
493 | ret = -ENOMEM; | ||
494 | goto err0; | ||
495 | } | ||
496 | |||
497 | musb = platform_device_alloc("musb-hdrc", musbid); | ||
452 | if (!musb) { | 498 | if (!musb) { |
453 | dev_err(&pdev->dev, "failed to allocate musb device\n"); | 499 | dev_err(&pdev->dev, "failed to allocate musb device\n"); |
454 | goto err0; | 500 | goto err1; |
455 | } | 501 | } |
456 | 502 | ||
503 | musb->id = musbid; | ||
457 | musb->dev.parent = &pdev->dev; | 504 | musb->dev.parent = &pdev->dev; |
458 | musb->dev.dma_mask = &omap2430_dmamask; | 505 | musb->dev.dma_mask = &omap2430_dmamask; |
459 | musb->dev.coherent_dma_mask = omap2430_dmamask; | 506 | musb->dev.coherent_dma_mask = omap2430_dmamask; |
@@ -462,6 +509,48 @@ static int __devinit omap2430_probe(struct platform_device *pdev) | |||
462 | glue->musb = musb; | 509 | glue->musb = musb; |
463 | glue->status = OMAP_MUSB_UNKNOWN; | 510 | glue->status = OMAP_MUSB_UNKNOWN; |
464 | 511 | ||
512 | res = platform_get_resource(pdev, IORESOURCE_MEM, 1); | ||
513 | |||
514 | glue->control_otghs = devm_request_and_ioremap(&pdev->dev, res); | ||
515 | if (glue->control_otghs == NULL) | ||
516 | dev_dbg(&pdev->dev, "Failed to obtain control memory\n"); | ||
517 | |||
518 | if (np) { | ||
519 | pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); | ||
520 | if (!pdata) { | ||
521 | dev_err(&pdev->dev, | ||
522 | "failed to allocate musb platfrom data\n"); | ||
523 | ret = -ENOMEM; | ||
524 | goto err1; | ||
525 | } | ||
526 | |||
527 | data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); | ||
528 | if (!data) { | ||
529 | dev_err(&pdev->dev, | ||
530 | "failed to allocate musb board data\n"); | ||
531 | ret = -ENOMEM; | ||
532 | goto err1; | ||
533 | } | ||
534 | |||
535 | config = devm_kzalloc(&pdev->dev, sizeof(*config), GFP_KERNEL); | ||
536 | if (!data) { | ||
537 | dev_err(&pdev->dev, | ||
538 | "failed to allocate musb hdrc config\n"); | ||
539 | goto err1; | ||
540 | } | ||
541 | |||
542 | of_property_read_u32(np, "mode", (u32 *)&pdata->mode); | ||
543 | of_property_read_u32(np, "interface_type", | ||
544 | (u32 *)&data->interface_type); | ||
545 | of_property_read_u32(np, "num_eps", (u32 *)&config->num_eps); | ||
546 | of_property_read_u32(np, "ram_bits", (u32 *)&config->ram_bits); | ||
547 | of_property_read_u32(np, "power", (u32 *)&pdata->power); | ||
548 | config->multipoint = of_property_read_bool(np, "multipoint"); | ||
549 | |||
550 | pdata->board_data = data; | ||
551 | pdata->config = config; | ||
552 | } | ||
553 | |||
465 | pdata->platform_ops = &omap2430_ops; | 554 | pdata->platform_ops = &omap2430_ops; |
466 | 555 | ||
467 | platform_set_drvdata(pdev, glue); | 556 | platform_set_drvdata(pdev, glue); |
@@ -478,13 +567,13 @@ static int __devinit omap2430_probe(struct platform_device *pdev) | |||
478 | pdev->num_resources); | 567 | pdev->num_resources); |
479 | if (ret) { | 568 | if (ret) { |
480 | dev_err(&pdev->dev, "failed to add resources\n"); | 569 | dev_err(&pdev->dev, "failed to add resources\n"); |
481 | goto err1; | 570 | goto err2; |
482 | } | 571 | } |
483 | 572 | ||
484 | ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); | 573 | ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); |
485 | if (ret) { | 574 | if (ret) { |
486 | dev_err(&pdev->dev, "failed to add platform_data\n"); | 575 | dev_err(&pdev->dev, "failed to add platform_data\n"); |
487 | goto err1; | 576 | goto err2; |
488 | } | 577 | } |
489 | 578 | ||
490 | pm_runtime_enable(&pdev->dev); | 579 | pm_runtime_enable(&pdev->dev); |
@@ -492,14 +581,17 @@ static int __devinit omap2430_probe(struct platform_device *pdev) | |||
492 | ret = platform_device_add(musb); | 581 | ret = platform_device_add(musb); |
493 | if (ret) { | 582 | if (ret) { |
494 | dev_err(&pdev->dev, "failed to register musb device\n"); | 583 | dev_err(&pdev->dev, "failed to register musb device\n"); |
495 | goto err1; | 584 | goto err2; |
496 | } | 585 | } |
497 | 586 | ||
498 | return 0; | 587 | return 0; |
499 | 588 | ||
500 | err1: | 589 | err2: |
501 | platform_device_put(musb); | 590 | platform_device_put(musb); |
502 | 591 | ||
592 | err1: | ||
593 | musb_put_id(&pdev->dev, musbid); | ||
594 | |||
503 | err0: | 595 | err0: |
504 | return ret; | 596 | return ret; |
505 | } | 597 | } |
@@ -509,8 +601,8 @@ static int __devexit omap2430_remove(struct platform_device *pdev) | |||
509 | struct omap2430_glue *glue = platform_get_drvdata(pdev); | 601 | struct omap2430_glue *glue = platform_get_drvdata(pdev); |
510 | 602 | ||
511 | cancel_work_sync(&glue->omap_musb_mailbox_work); | 603 | cancel_work_sync(&glue->omap_musb_mailbox_work); |
512 | platform_device_del(glue->musb); | 604 | musb_put_id(&pdev->dev, glue->musb->id); |
513 | platform_device_put(glue->musb); | 605 | platform_device_unregister(glue->musb); |
514 | 606 | ||
515 | return 0; | 607 | return 0; |
516 | } | 608 | } |
@@ -559,12 +651,26 @@ static struct dev_pm_ops omap2430_pm_ops = { | |||
559 | #define DEV_PM_OPS NULL | 651 | #define DEV_PM_OPS NULL |
560 | #endif | 652 | #endif |
561 | 653 | ||
654 | #ifdef CONFIG_OF | ||
655 | static const struct of_device_id omap2430_id_table[] = { | ||
656 | { | ||
657 | .compatible = "ti,omap4-musb" | ||
658 | }, | ||
659 | { | ||
660 | .compatible = "ti,omap3-musb" | ||
661 | }, | ||
662 | {}, | ||
663 | }; | ||
664 | MODULE_DEVICE_TABLE(of, omap2430_id_table); | ||
665 | #endif | ||
666 | |||
562 | static struct platform_driver omap2430_driver = { | 667 | static struct platform_driver omap2430_driver = { |
563 | .probe = omap2430_probe, | 668 | .probe = omap2430_probe, |
564 | .remove = __devexit_p(omap2430_remove), | 669 | .remove = __devexit_p(omap2430_remove), |
565 | .driver = { | 670 | .driver = { |
566 | .name = "musb-omap2430", | 671 | .name = "musb-omap2430", |
567 | .pm = DEV_PM_OPS, | 672 | .pm = DEV_PM_OPS, |
673 | .of_match_table = of_match_ptr(omap2430_id_table), | ||
568 | }, | 674 | }, |
569 | }; | 675 | }; |
570 | 676 | ||
diff --git a/drivers/usb/musb/omap2430.h b/drivers/usb/musb/omap2430.h index 40b3c02ae9f0..b85f3973e78c 100644 --- a/drivers/usb/musb/omap2430.h +++ b/drivers/usb/musb/omap2430.h | |||
@@ -49,4 +49,13 @@ | |||
49 | #define OTG_FORCESTDBY 0x414 | 49 | #define OTG_FORCESTDBY 0x414 |
50 | # define ENABLEFORCE (1 << 0) | 50 | # define ENABLEFORCE (1 << 0) |
51 | 51 | ||
52 | /* | ||
53 | * Control Module bit definitions | ||
54 | * XXX: Will be removed once we have a driver for control module. | ||
55 | */ | ||
56 | #define AVALID BIT(0) | ||
57 | #define BVALID BIT(1) | ||
58 | #define VBUSVALID BIT(2) | ||
59 | #define SESSEND BIT(3) | ||
60 | #define IDDIG BIT(4) | ||
52 | #endif /* __MUSB_OMAP243X_H__ */ | 61 | #endif /* __MUSB_OMAP243X_H__ */ |
diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c index 341625442377..dc4d75ea13ad 100644 --- a/drivers/usb/musb/tusb6010.c +++ b/drivers/usb/musb/tusb6010.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/irq.h> | 24 | #include <linux/irq.h> |
25 | #include <linux/platform_device.h> | 25 | #include <linux/platform_device.h> |
26 | #include <linux/dma-mapping.h> | 26 | #include <linux/dma-mapping.h> |
27 | #include <linux/usb/nop-usb-xceiv.h> | ||
27 | 28 | ||
28 | #include "musb_core.h" | 29 | #include "musb_core.h" |
29 | 30 | ||
@@ -153,7 +154,7 @@ tusb_fifo_write_unaligned(void __iomem *fifo, const u8 *buf, u16 len) | |||
153 | } | 154 | } |
154 | 155 | ||
155 | static inline void tusb_fifo_read_unaligned(void __iomem *fifo, | 156 | static inline void tusb_fifo_read_unaligned(void __iomem *fifo, |
156 | void __iomem *buf, u16 len) | 157 | void *buf, u16 len) |
157 | { | 158 | { |
158 | u32 val; | 159 | u32 val; |
159 | int i; | 160 | int i; |
@@ -437,14 +438,13 @@ static void musb_do_idle(unsigned long _musb) | |||
437 | if (is_host_active(musb) && (musb->port1_status >> 16)) | 438 | if (is_host_active(musb) && (musb->port1_status >> 16)) |
438 | goto done; | 439 | goto done; |
439 | 440 | ||
440 | if (is_peripheral_enabled(musb) && !musb->gadget_driver) { | 441 | if (!musb->gadget_driver) { |
441 | wakeups = 0; | 442 | wakeups = 0; |
442 | } else { | 443 | } else { |
443 | wakeups = TUSB_PRCM_WHOSTDISCON | 444 | wakeups = TUSB_PRCM_WHOSTDISCON |
444 | | TUSB_PRCM_WBUS | 445 | | TUSB_PRCM_WBUS |
445 | | TUSB_PRCM_WVBUS; | 446 | | TUSB_PRCM_WVBUS; |
446 | if (is_otg_enabled(musb)) | 447 | wakeups |= TUSB_PRCM_WID; |
447 | wakeups |= TUSB_PRCM_WID; | ||
448 | } | 448 | } |
449 | tusb_allow_idle(musb, wakeups); | 449 | tusb_allow_idle(musb, wakeups); |
450 | } | 450 | } |
@@ -582,21 +582,12 @@ static void tusb_musb_set_vbus(struct musb *musb, int is_on) | |||
582 | * | 582 | * |
583 | * Note that if a mini-A cable is plugged in the ID line will stay down as | 583 | * Note that if a mini-A cable is plugged in the ID line will stay down as |
584 | * the weak ID pull-up is not able to pull the ID up. | 584 | * the weak ID pull-up is not able to pull the ID up. |
585 | * | ||
586 | * REVISIT: It would be possible to add support for changing between host | ||
587 | * and peripheral modes in non-OTG configurations by reconfiguring hardware | ||
588 | * and then setting musb->board_mode. For now, only support OTG mode. | ||
589 | */ | 585 | */ |
590 | static int tusb_musb_set_mode(struct musb *musb, u8 musb_mode) | 586 | static int tusb_musb_set_mode(struct musb *musb, u8 musb_mode) |
591 | { | 587 | { |
592 | void __iomem *tbase = musb->ctrl_base; | 588 | void __iomem *tbase = musb->ctrl_base; |
593 | u32 otg_stat, phy_otg_ctrl, phy_otg_ena, dev_conf; | 589 | u32 otg_stat, phy_otg_ctrl, phy_otg_ena, dev_conf; |
594 | 590 | ||
595 | if (musb->board_mode != MUSB_OTG) { | ||
596 | ERR("Changing mode currently only supported in OTG mode\n"); | ||
597 | return -EINVAL; | ||
598 | } | ||
599 | |||
600 | otg_stat = musb_readl(tbase, TUSB_DEV_OTG_STAT); | 591 | otg_stat = musb_readl(tbase, TUSB_DEV_OTG_STAT); |
601 | phy_otg_ctrl = musb_readl(tbase, TUSB_PHY_OTG_CTRL); | 592 | phy_otg_ctrl = musb_readl(tbase, TUSB_PHY_OTG_CTRL); |
602 | phy_otg_ena = musb_readl(tbase, TUSB_PHY_OTG_CTRL_ENABLE); | 593 | phy_otg_ena = musb_readl(tbase, TUSB_PHY_OTG_CTRL_ENABLE); |
@@ -652,10 +643,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase) | |||
652 | if ((int_src & TUSB_INT_SRC_ID_STATUS_CHNG)) { | 643 | if ((int_src & TUSB_INT_SRC_ID_STATUS_CHNG)) { |
653 | int default_a; | 644 | int default_a; |
654 | 645 | ||
655 | if (is_otg_enabled(musb)) | 646 | default_a = !(otg_stat & TUSB_DEV_OTG_STAT_ID_STATUS); |
656 | default_a = !(otg_stat & TUSB_DEV_OTG_STAT_ID_STATUS); | ||
657 | else | ||
658 | default_a = is_host_enabled(musb); | ||
659 | dev_dbg(musb->controller, "Default-%c\n", default_a ? 'A' : 'B'); | 647 | dev_dbg(musb->controller, "Default-%c\n", default_a ? 'A' : 'B'); |
660 | otg->default_a = default_a; | 648 | otg->default_a = default_a; |
661 | tusb_musb_set_vbus(musb, default_a); | 649 | tusb_musb_set_vbus(musb, default_a); |
@@ -669,8 +657,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase) | |||
669 | if (int_src & TUSB_INT_SRC_VBUS_SENSE_CHNG) { | 657 | if (int_src & TUSB_INT_SRC_VBUS_SENSE_CHNG) { |
670 | 658 | ||
671 | /* B-dev state machine: no vbus ~= disconnect */ | 659 | /* B-dev state machine: no vbus ~= disconnect */ |
672 | if ((is_otg_enabled(musb) && !otg->default_a) | 660 | if (!otg->default_a) { |
673 | || !is_host_enabled(musb)) { | ||
674 | /* ? musb_root_disconnect(musb); */ | 661 | /* ? musb_root_disconnect(musb); */ |
675 | musb->port1_status &= | 662 | musb->port1_status &= |
676 | ~(USB_PORT_STAT_CONNECTION | 663 | ~(USB_PORT_STAT_CONNECTION |
@@ -1119,10 +1106,8 @@ static int tusb_musb_init(struct musb *musb) | |||
1119 | } | 1106 | } |
1120 | musb->isr = tusb_musb_interrupt; | 1107 | musb->isr = tusb_musb_interrupt; |
1121 | 1108 | ||
1122 | if (is_peripheral_enabled(musb)) { | 1109 | musb->xceiv->set_power = tusb_draw_power; |
1123 | musb->xceiv->set_power = tusb_draw_power; | 1110 | the_musb = musb; |
1124 | the_musb = musb; | ||
1125 | } | ||
1126 | 1111 | ||
1127 | setup_timer(&musb_idle_timer, musb_do_idle, (unsigned long) musb); | 1112 | setup_timer(&musb_idle_timer, musb_do_idle, (unsigned long) musb); |
1128 | 1113 | ||
@@ -1175,6 +1160,7 @@ static int __devinit tusb_probe(struct platform_device *pdev) | |||
1175 | struct tusb6010_glue *glue; | 1160 | struct tusb6010_glue *glue; |
1176 | 1161 | ||
1177 | int ret = -ENOMEM; | 1162 | int ret = -ENOMEM; |
1163 | int musbid; | ||
1178 | 1164 | ||
1179 | glue = kzalloc(sizeof(*glue), GFP_KERNEL); | 1165 | glue = kzalloc(sizeof(*glue), GFP_KERNEL); |
1180 | if (!glue) { | 1166 | if (!glue) { |
@@ -1182,12 +1168,21 @@ static int __devinit tusb_probe(struct platform_device *pdev) | |||
1182 | goto err0; | 1168 | goto err0; |
1183 | } | 1169 | } |
1184 | 1170 | ||
1185 | musb = platform_device_alloc("musb-hdrc", -1); | 1171 | /* get the musb id */ |
1172 | musbid = musb_get_id(&pdev->dev, GFP_KERNEL); | ||
1173 | if (musbid < 0) { | ||
1174 | dev_err(&pdev->dev, "failed to allocate musb id\n"); | ||
1175 | ret = -ENOMEM; | ||
1176 | goto err1; | ||
1177 | } | ||
1178 | |||
1179 | musb = platform_device_alloc("musb-hdrc", musbid); | ||
1186 | if (!musb) { | 1180 | if (!musb) { |
1187 | dev_err(&pdev->dev, "failed to allocate musb device\n"); | 1181 | dev_err(&pdev->dev, "failed to allocate musb device\n"); |
1188 | goto err1; | 1182 | goto err2; |
1189 | } | 1183 | } |
1190 | 1184 | ||
1185 | musb->id = musbid; | ||
1191 | musb->dev.parent = &pdev->dev; | 1186 | musb->dev.parent = &pdev->dev; |
1192 | musb->dev.dma_mask = &tusb_dmamask; | 1187 | musb->dev.dma_mask = &tusb_dmamask; |
1193 | musb->dev.coherent_dma_mask = tusb_dmamask; | 1188 | musb->dev.coherent_dma_mask = tusb_dmamask; |
@@ -1203,26 +1198,29 @@ static int __devinit tusb_probe(struct platform_device *pdev) | |||
1203 | pdev->num_resources); | 1198 | pdev->num_resources); |
1204 | if (ret) { | 1199 | if (ret) { |
1205 | dev_err(&pdev->dev, "failed to add resources\n"); | 1200 | dev_err(&pdev->dev, "failed to add resources\n"); |
1206 | goto err2; | 1201 | goto err3; |
1207 | } | 1202 | } |
1208 | 1203 | ||
1209 | ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); | 1204 | ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); |
1210 | if (ret) { | 1205 | if (ret) { |
1211 | dev_err(&pdev->dev, "failed to add platform_data\n"); | 1206 | dev_err(&pdev->dev, "failed to add platform_data\n"); |
1212 | goto err2; | 1207 | goto err3; |
1213 | } | 1208 | } |
1214 | 1209 | ||
1215 | ret = platform_device_add(musb); | 1210 | ret = platform_device_add(musb); |
1216 | if (ret) { | 1211 | if (ret) { |
1217 | dev_err(&pdev->dev, "failed to register musb device\n"); | 1212 | dev_err(&pdev->dev, "failed to register musb device\n"); |
1218 | goto err2; | 1213 | goto err3; |
1219 | } | 1214 | } |
1220 | 1215 | ||
1221 | return 0; | 1216 | return 0; |
1222 | 1217 | ||
1223 | err2: | 1218 | err3: |
1224 | platform_device_put(musb); | 1219 | platform_device_put(musb); |
1225 | 1220 | ||
1221 | err2: | ||
1222 | musb_put_id(&pdev->dev, musbid); | ||
1223 | |||
1226 | err1: | 1224 | err1: |
1227 | kfree(glue); | 1225 | kfree(glue); |
1228 | 1226 | ||
@@ -1234,6 +1232,7 @@ static int __devexit tusb_remove(struct platform_device *pdev) | |||
1234 | { | 1232 | { |
1235 | struct tusb6010_glue *glue = platform_get_drvdata(pdev); | 1233 | struct tusb6010_glue *glue = platform_get_drvdata(pdev); |
1236 | 1234 | ||
1235 | musb_put_id(&pdev->dev, glue->musb->id); | ||
1237 | platform_device_del(glue->musb); | 1236 | platform_device_del(glue->musb); |
1238 | platform_device_put(glue->musb); | 1237 | platform_device_put(glue->musb); |
1239 | kfree(glue); | 1238 | kfree(glue); |
diff --git a/drivers/usb/musb/tusb6010_omap.c b/drivers/usb/musb/tusb6010_omap.c index b67b4bc596c1..53e25968ed0c 100644 --- a/drivers/usb/musb/tusb6010_omap.c +++ b/drivers/usb/musb/tusb6010_omap.c | |||
@@ -662,7 +662,7 @@ void dma_controller_destroy(struct dma_controller *c) | |||
662 | kfree(tusb_dma); | 662 | kfree(tusb_dma); |
663 | } | 663 | } |
664 | 664 | ||
665 | struct dma_controller *__init | 665 | struct dma_controller *__devinit |
666 | dma_controller_create(struct musb *musb, void __iomem *base) | 666 | dma_controller_create(struct musb *musb, void __iomem *base) |
667 | { | 667 | { |
668 | void __iomem *tbase = musb->ctrl_base; | 668 | void __iomem *tbase = musb->ctrl_base; |
diff --git a/drivers/usb/musb/ux500.c b/drivers/usb/musb/ux500.c index a8c0fadce1b0..d62a91fedc22 100644 --- a/drivers/usb/musb/ux500.c +++ b/drivers/usb/musb/ux500.c | |||
@@ -74,25 +74,34 @@ static int __devinit ux500_probe(struct platform_device *pdev) | |||
74 | goto err0; | 74 | goto err0; |
75 | } | 75 | } |
76 | 76 | ||
77 | musb = platform_device_alloc("musb-hdrc", -1); | 77 | /* get the musb id */ |
78 | musbid = musb_get_id(&pdev->dev, GFP_KERNEL); | ||
79 | if (musbid < 0) { | ||
80 | dev_err(&pdev->dev, "failed to allocate musb id\n"); | ||
81 | ret = -ENOMEM; | ||
82 | goto err1; | ||
83 | } | ||
84 | |||
85 | musb = platform_device_alloc("musb-hdrc", musbid); | ||
78 | if (!musb) { | 86 | if (!musb) { |
79 | dev_err(&pdev->dev, "failed to allocate musb device\n"); | 87 | dev_err(&pdev->dev, "failed to allocate musb device\n"); |
80 | goto err1; | 88 | goto err2; |
81 | } | 89 | } |
82 | 90 | ||
83 | clk = clk_get(&pdev->dev, "usb"); | 91 | clk = clk_get(&pdev->dev, "usb"); |
84 | if (IS_ERR(clk)) { | 92 | if (IS_ERR(clk)) { |
85 | dev_err(&pdev->dev, "failed to get clock\n"); | 93 | dev_err(&pdev->dev, "failed to get clock\n"); |
86 | ret = PTR_ERR(clk); | 94 | ret = PTR_ERR(clk); |
87 | goto err2; | 95 | goto err3; |
88 | } | 96 | } |
89 | 97 | ||
90 | ret = clk_enable(clk); | 98 | ret = clk_enable(clk); |
91 | if (ret) { | 99 | if (ret) { |
92 | dev_err(&pdev->dev, "failed to enable clock\n"); | 100 | dev_err(&pdev->dev, "failed to enable clock\n"); |
93 | goto err3; | 101 | goto err4; |
94 | } | 102 | } |
95 | 103 | ||
104 | musb->id = musbid; | ||
96 | musb->dev.parent = &pdev->dev; | 105 | musb->dev.parent = &pdev->dev; |
97 | musb->dev.dma_mask = pdev->dev.dma_mask; | 106 | musb->dev.dma_mask = pdev->dev.dma_mask; |
98 | musb->dev.coherent_dma_mask = pdev->dev.coherent_dma_mask; | 107 | musb->dev.coherent_dma_mask = pdev->dev.coherent_dma_mask; |
@@ -109,32 +118,35 @@ static int __devinit ux500_probe(struct platform_device *pdev) | |||
109 | pdev->num_resources); | 118 | pdev->num_resources); |
110 | if (ret) { | 119 | if (ret) { |
111 | dev_err(&pdev->dev, "failed to add resources\n"); | 120 | dev_err(&pdev->dev, "failed to add resources\n"); |
112 | goto err4; | 121 | goto err5; |
113 | } | 122 | } |
114 | 123 | ||
115 | ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); | 124 | ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); |
116 | if (ret) { | 125 | if (ret) { |
117 | dev_err(&pdev->dev, "failed to add platform_data\n"); | 126 | dev_err(&pdev->dev, "failed to add platform_data\n"); |
118 | goto err4; | 127 | goto err5; |
119 | } | 128 | } |
120 | 129 | ||
121 | ret = platform_device_add(musb); | 130 | ret = platform_device_add(musb); |
122 | if (ret) { | 131 | if (ret) { |
123 | dev_err(&pdev->dev, "failed to register musb device\n"); | 132 | dev_err(&pdev->dev, "failed to register musb device\n"); |
124 | goto err4; | 133 | goto err5; |
125 | } | 134 | } |
126 | 135 | ||
127 | return 0; | 136 | return 0; |
128 | 137 | ||
129 | err4: | 138 | err5: |
130 | clk_disable(clk); | 139 | clk_disable(clk); |
131 | 140 | ||
132 | err3: | 141 | err4: |
133 | clk_put(clk); | 142 | clk_put(clk); |
134 | 143 | ||
135 | err2: | 144 | err3: |
136 | platform_device_put(musb); | 145 | platform_device_put(musb); |
137 | 146 | ||
147 | err2: | ||
148 | musb_put_id(&pdev->dev, musbid); | ||
149 | |||
138 | err1: | 150 | err1: |
139 | kfree(glue); | 151 | kfree(glue); |
140 | 152 | ||
@@ -146,6 +158,7 @@ static int __devexit ux500_remove(struct platform_device *pdev) | |||
146 | { | 158 | { |
147 | struct ux500_glue *glue = platform_get_drvdata(pdev); | 159 | struct ux500_glue *glue = platform_get_drvdata(pdev); |
148 | 160 | ||
161 | musb_put_id(&pdev->dev, glue->musb->id); | ||
149 | platform_device_del(glue->musb); | 162 | platform_device_del(glue->musb); |
150 | platform_device_put(glue->musb); | 163 | platform_device_put(glue->musb); |
151 | clk_disable(glue->clk); | 164 | clk_disable(glue->clk); |
diff --git a/drivers/usb/musb/ux500_dma.c b/drivers/usb/musb/ux500_dma.c index d05c7fbbb703..639d58ee24f9 100644 --- a/drivers/usb/musb/ux500_dma.c +++ b/drivers/usb/musb/ux500_dma.c | |||
@@ -364,7 +364,7 @@ void dma_controller_destroy(struct dma_controller *c) | |||
364 | kfree(controller); | 364 | kfree(controller); |
365 | } | 365 | } |
366 | 366 | ||
367 | struct dma_controller *__init | 367 | struct dma_controller *__devinit |
368 | dma_controller_create(struct musb *musb, void __iomem *base) | 368 | dma_controller_create(struct musb *musb, void __iomem *base) |
369 | { | 369 | { |
370 | struct ux500_dma_controller *controller; | 370 | struct ux500_dma_controller *controller; |
diff --git a/drivers/usb/otg/Kconfig b/drivers/usb/otg/Kconfig index 13fd1ddf742f..d8c8a42bff3e 100644 --- a/drivers/usb/otg/Kconfig +++ b/drivers/usb/otg/Kconfig | |||
@@ -68,7 +68,7 @@ config TWL4030_USB | |||
68 | 68 | ||
69 | config TWL6030_USB | 69 | config TWL6030_USB |
70 | tristate "TWL6030 USB Transceiver Driver" | 70 | tristate "TWL6030 USB Transceiver Driver" |
71 | depends on TWL4030_CORE | 71 | depends on TWL4030_CORE && OMAP_USB2 |
72 | select USB_OTG_UTILS | 72 | select USB_OTG_UTILS |
73 | help | 73 | help |
74 | Enable this to support the USB OTG transceiver on TWL6030 | 74 | Enable this to support the USB OTG transceiver on TWL6030 |
diff --git a/drivers/usb/otg/fsl_otg.c b/drivers/usb/otg/fsl_otg.c index 23c798cb2d7f..c19d1d7173a9 100644 --- a/drivers/usb/otg/fsl_otg.c +++ b/drivers/usb/otg/fsl_otg.c | |||
@@ -544,9 +544,13 @@ int fsl_otg_start_gadget(struct otg_fsm *fsm, int on) | |||
544 | */ | 544 | */ |
545 | static int fsl_otg_set_host(struct usb_otg *otg, struct usb_bus *host) | 545 | static int fsl_otg_set_host(struct usb_otg *otg, struct usb_bus *host) |
546 | { | 546 | { |
547 | struct fsl_otg *otg_dev = container_of(otg->phy, struct fsl_otg, phy); | 547 | struct fsl_otg *otg_dev; |
548 | |||
549 | if (!otg) | ||
550 | return -ENODEV; | ||
548 | 551 | ||
549 | if (!otg || otg_dev != fsl_otg_dev) | 552 | otg_dev = container_of(otg->phy, struct fsl_otg, phy); |
553 | if (otg_dev != fsl_otg_dev) | ||
550 | return -ENODEV; | 554 | return -ENODEV; |
551 | 555 | ||
552 | otg->host = host; | 556 | otg->host = host; |
@@ -590,12 +594,15 @@ static int fsl_otg_set_host(struct usb_otg *otg, struct usb_bus *host) | |||
590 | static int fsl_otg_set_peripheral(struct usb_otg *otg, | 594 | static int fsl_otg_set_peripheral(struct usb_otg *otg, |
591 | struct usb_gadget *gadget) | 595 | struct usb_gadget *gadget) |
592 | { | 596 | { |
593 | struct fsl_otg *otg_dev = container_of(otg->phy, struct fsl_otg, phy); | 597 | struct fsl_otg *otg_dev; |
594 | 598 | ||
599 | if (!otg) | ||
600 | return -ENODEV; | ||
601 | |||
602 | otg_dev = container_of(otg->phy, struct fsl_otg, phy); | ||
595 | VDBG("otg_dev 0x%x\n", (int)otg_dev); | 603 | VDBG("otg_dev 0x%x\n", (int)otg_dev); |
596 | VDBG("fsl_otg_dev 0x%x\n", (int)fsl_otg_dev); | 604 | VDBG("fsl_otg_dev 0x%x\n", (int)fsl_otg_dev); |
597 | 605 | if (otg_dev != fsl_otg_dev) | |
598 | if (!otg || otg_dev != fsl_otg_dev) | ||
599 | return -ENODEV; | 606 | return -ENODEV; |
600 | 607 | ||
601 | if (!gadget) { | 608 | if (!gadget) { |
@@ -660,10 +667,13 @@ static void fsl_otg_event(struct work_struct *work) | |||
660 | /* B-device start SRP */ | 667 | /* B-device start SRP */ |
661 | static int fsl_otg_start_srp(struct usb_otg *otg) | 668 | static int fsl_otg_start_srp(struct usb_otg *otg) |
662 | { | 669 | { |
663 | struct fsl_otg *otg_dev = container_of(otg->phy, struct fsl_otg, phy); | 670 | struct fsl_otg *otg_dev; |
671 | |||
672 | if (!otg || otg->phy->state != OTG_STATE_B_IDLE) | ||
673 | return -ENODEV; | ||
664 | 674 | ||
665 | if (!otg || otg_dev != fsl_otg_dev | 675 | otg_dev = container_of(otg->phy, struct fsl_otg, phy); |
666 | || otg->phy->state != OTG_STATE_B_IDLE) | 676 | if (otg_dev != fsl_otg_dev) |
667 | return -ENODEV; | 677 | return -ENODEV; |
668 | 678 | ||
669 | otg_dev->fsm.b_bus_req = 1; | 679 | otg_dev->fsm.b_bus_req = 1; |
@@ -675,9 +685,13 @@ static int fsl_otg_start_srp(struct usb_otg *otg) | |||
675 | /* A_host suspend will call this function to start hnp */ | 685 | /* A_host suspend will call this function to start hnp */ |
676 | static int fsl_otg_start_hnp(struct usb_otg *otg) | 686 | static int fsl_otg_start_hnp(struct usb_otg *otg) |
677 | { | 687 | { |
678 | struct fsl_otg *otg_dev = container_of(otg->phy, struct fsl_otg, phy); | 688 | struct fsl_otg *otg_dev; |
689 | |||
690 | if (!otg) | ||
691 | return -ENODEV; | ||
679 | 692 | ||
680 | if (!otg || otg_dev != fsl_otg_dev) | 693 | otg_dev = container_of(otg->phy, struct fsl_otg, phy); |
694 | if (otg_dev != fsl_otg_dev) | ||
681 | return -ENODEV; | 695 | return -ENODEV; |
682 | 696 | ||
683 | DBG("start_hnp...n"); | 697 | DBG("start_hnp...n"); |
diff --git a/drivers/usb/otg/mxs-phy.c b/drivers/usb/otg/mxs-phy.c index c1a67cb8e244..88db976647cf 100644 --- a/drivers/usb/otg/mxs-phy.c +++ b/drivers/usb/otg/mxs-phy.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/delay.h> | 20 | #include <linux/delay.h> |
21 | #include <linux/err.h> | 21 | #include <linux/err.h> |
22 | #include <linux/io.h> | 22 | #include <linux/io.h> |
23 | #include <linux/workqueue.h> | ||
23 | 24 | ||
24 | #define DRIVER_NAME "mxs_phy" | 25 | #define DRIVER_NAME "mxs_phy" |
25 | 26 | ||
@@ -34,9 +35,16 @@ | |||
34 | #define BM_USBPHY_CTRL_ENUTMILEVEL2 BIT(14) | 35 | #define BM_USBPHY_CTRL_ENUTMILEVEL2 BIT(14) |
35 | #define BM_USBPHY_CTRL_ENHOSTDISCONDETECT BIT(1) | 36 | #define BM_USBPHY_CTRL_ENHOSTDISCONDETECT BIT(1) |
36 | 37 | ||
38 | /* | ||
39 | * Amount of delay in miliseconds to safely enable ENHOSTDISCONDETECT bit | ||
40 | * so that connection and reset processing can be completed for the root hub. | ||
41 | */ | ||
42 | #define MXY_PHY_ENHOSTDISCONDETECT_DELAY 250 | ||
43 | |||
37 | struct mxs_phy { | 44 | struct mxs_phy { |
38 | struct usb_phy phy; | 45 | struct usb_phy phy; |
39 | struct clk *clk; | 46 | struct clk *clk; |
47 | struct delayed_work enhostdiscondetect_work; | ||
40 | }; | 48 | }; |
41 | 49 | ||
42 | #define to_mxs_phy(p) container_of((p), struct mxs_phy, phy) | 50 | #define to_mxs_phy(p) container_of((p), struct mxs_phy, phy) |
@@ -62,6 +70,7 @@ static int mxs_phy_init(struct usb_phy *phy) | |||
62 | 70 | ||
63 | clk_prepare_enable(mxs_phy->clk); | 71 | clk_prepare_enable(mxs_phy->clk); |
64 | mxs_phy_hw_init(mxs_phy); | 72 | mxs_phy_hw_init(mxs_phy); |
73 | INIT_DELAYED_WORK(&mxs_phy->enhostdiscondetect_work, NULL); | ||
65 | 74 | ||
66 | return 0; | 75 | return 0; |
67 | } | 76 | } |
@@ -76,13 +85,34 @@ static void mxs_phy_shutdown(struct usb_phy *phy) | |||
76 | clk_disable_unprepare(mxs_phy->clk); | 85 | clk_disable_unprepare(mxs_phy->clk); |
77 | } | 86 | } |
78 | 87 | ||
88 | static void mxs_phy_enhostdiscondetect_delay(struct work_struct *ws) | ||
89 | { | ||
90 | struct mxs_phy *mxs_phy = container_of(ws, struct mxs_phy, | ||
91 | enhostdiscondetect_work.work); | ||
92 | |||
93 | /* Enable HOSTDISCONDETECT after delay. */ | ||
94 | dev_dbg(mxs_phy->phy.dev, "Setting ENHOSTDISCONDETECT\n"); | ||
95 | writel_relaxed(BM_USBPHY_CTRL_ENHOSTDISCONDETECT, | ||
96 | mxs_phy->phy.io_priv + HW_USBPHY_CTRL_SET); | ||
97 | } | ||
98 | |||
79 | static int mxs_phy_on_connect(struct usb_phy *phy, int port) | 99 | static int mxs_phy_on_connect(struct usb_phy *phy, int port) |
80 | { | 100 | { |
101 | struct mxs_phy *mxs_phy = to_mxs_phy(phy); | ||
102 | |||
81 | dev_dbg(phy->dev, "Connect on port %d\n", port); | 103 | dev_dbg(phy->dev, "Connect on port %d\n", port); |
82 | 104 | ||
83 | mxs_phy_hw_init(to_mxs_phy(phy)); | 105 | mxs_phy_hw_init(mxs_phy); |
84 | writel_relaxed(BM_USBPHY_CTRL_ENHOSTDISCONDETECT, | 106 | |
85 | phy->io_priv + HW_USBPHY_CTRL_SET); | 107 | /* |
108 | * Delay enabling ENHOSTDISCONDETECT so that connection and | ||
109 | * reset processing can be completed for the root hub. | ||
110 | */ | ||
111 | dev_dbg(phy->dev, "Delaying setting ENHOSTDISCONDETECT\n"); | ||
112 | PREPARE_DELAYED_WORK(&mxs_phy->enhostdiscondetect_work, | ||
113 | mxs_phy_enhostdiscondetect_delay); | ||
114 | schedule_delayed_work(&mxs_phy->enhostdiscondetect_work, | ||
115 | msecs_to_jiffies(MXY_PHY_ENHOSTDISCONDETECT_DELAY)); | ||
86 | 116 | ||
87 | return 0; | 117 | return 0; |
88 | } | 118 | } |
@@ -91,6 +121,8 @@ static int mxs_phy_on_disconnect(struct usb_phy *phy, int port) | |||
91 | { | 121 | { |
92 | dev_dbg(phy->dev, "Disconnect on port %d\n", port); | 122 | dev_dbg(phy->dev, "Disconnect on port %d\n", port); |
93 | 123 | ||
124 | /* No need to delay before clearing ENHOSTDISCONDETECT. */ | ||
125 | dev_dbg(phy->dev, "Clearing ENHOSTDISCONDETECT\n"); | ||
94 | writel_relaxed(BM_USBPHY_CTRL_ENHOSTDISCONDETECT, | 126 | writel_relaxed(BM_USBPHY_CTRL_ENHOSTDISCONDETECT, |
95 | phy->io_priv + HW_USBPHY_CTRL_CLR); | 127 | phy->io_priv + HW_USBPHY_CTRL_CLR); |
96 | 128 | ||
diff --git a/drivers/usb/otg/nop-usb-xceiv.c b/drivers/usb/otg/nop-usb-xceiv.c index 803f958f4133..e52e35e7adaf 100644 --- a/drivers/usb/otg/nop-usb-xceiv.c +++ b/drivers/usb/otg/nop-usb-xceiv.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <linux/platform_device.h> | 30 | #include <linux/platform_device.h> |
31 | #include <linux/dma-mapping.h> | 31 | #include <linux/dma-mapping.h> |
32 | #include <linux/usb/otg.h> | 32 | #include <linux/usb/otg.h> |
33 | #include <linux/usb/nop-usb-xceiv.h> | ||
33 | #include <linux/slab.h> | 34 | #include <linux/slab.h> |
34 | 35 | ||
35 | struct nop_usb_xceiv { | 36 | struct nop_usb_xceiv { |
@@ -94,7 +95,9 @@ static int nop_set_host(struct usb_otg *otg, struct usb_bus *host) | |||
94 | 95 | ||
95 | static int __devinit nop_usb_xceiv_probe(struct platform_device *pdev) | 96 | static int __devinit nop_usb_xceiv_probe(struct platform_device *pdev) |
96 | { | 97 | { |
98 | struct nop_usb_xceiv_platform_data *pdata = pdev->dev.platform_data; | ||
97 | struct nop_usb_xceiv *nop; | 99 | struct nop_usb_xceiv *nop; |
100 | enum usb_phy_type type = USB_PHY_TYPE_USB2; | ||
98 | int err; | 101 | int err; |
99 | 102 | ||
100 | nop = kzalloc(sizeof *nop, GFP_KERNEL); | 103 | nop = kzalloc(sizeof *nop, GFP_KERNEL); |
@@ -107,6 +110,9 @@ static int __devinit nop_usb_xceiv_probe(struct platform_device *pdev) | |||
107 | return -ENOMEM; | 110 | return -ENOMEM; |
108 | } | 111 | } |
109 | 112 | ||
113 | if (pdata) | ||
114 | type = pdata->type; | ||
115 | |||
110 | nop->dev = &pdev->dev; | 116 | nop->dev = &pdev->dev; |
111 | nop->phy.dev = nop->dev; | 117 | nop->phy.dev = nop->dev; |
112 | nop->phy.label = "nop-xceiv"; | 118 | nop->phy.label = "nop-xceiv"; |
@@ -117,7 +123,7 @@ static int __devinit nop_usb_xceiv_probe(struct platform_device *pdev) | |||
117 | nop->phy.otg->set_host = nop_set_host; | 123 | nop->phy.otg->set_host = nop_set_host; |
118 | nop->phy.otg->set_peripheral = nop_set_peripheral; | 124 | nop->phy.otg->set_peripheral = nop_set_peripheral; |
119 | 125 | ||
120 | err = usb_add_phy(&nop->phy, USB_PHY_TYPE_USB2); | 126 | err = usb_add_phy(&nop->phy, type); |
121 | if (err) { | 127 | if (err) { |
122 | dev_err(&pdev->dev, "can't register transceiver, err: %d\n", | 128 | dev_err(&pdev->dev, "can't register transceiver, err: %d\n", |
123 | err); | 129 | err); |
diff --git a/drivers/usb/otg/otg.c b/drivers/usb/otg/otg.c index 1bf60a22595c..a30c04115115 100644 --- a/drivers/usb/otg/otg.c +++ b/drivers/usb/otg/otg.c | |||
@@ -159,7 +159,7 @@ int usb_add_phy(struct usb_phy *x, enum usb_phy_type type) | |||
159 | unsigned long flags; | 159 | unsigned long flags; |
160 | struct usb_phy *phy; | 160 | struct usb_phy *phy; |
161 | 161 | ||
162 | if (x && x->type != USB_PHY_TYPE_UNDEFINED) { | 162 | if (x->type != USB_PHY_TYPE_UNDEFINED) { |
163 | dev_err(x->dev, "not accepting initialized PHY %s\n", x->label); | 163 | dev_err(x->dev, "not accepting initialized PHY %s\n", x->label); |
164 | return -EINVAL; | 164 | return -EINVAL; |
165 | } | 165 | } |
diff --git a/drivers/usb/otg/twl4030-usb.c b/drivers/usb/otg/twl4030-usb.c index 523cad5bfea9..f0d2e7530cfe 100644 --- a/drivers/usb/otg/twl4030-usb.c +++ b/drivers/usb/otg/twl4030-usb.c | |||
@@ -585,23 +585,28 @@ static int __devinit twl4030_usb_probe(struct platform_device *pdev) | |||
585 | struct twl4030_usb *twl; | 585 | struct twl4030_usb *twl; |
586 | int status, err; | 586 | int status, err; |
587 | struct usb_otg *otg; | 587 | struct usb_otg *otg; |
588 | 588 | struct device_node *np = pdev->dev.of_node; | |
589 | if (!pdata) { | ||
590 | dev_dbg(&pdev->dev, "platform_data not available\n"); | ||
591 | return -EINVAL; | ||
592 | } | ||
593 | 589 | ||
594 | twl = devm_kzalloc(&pdev->dev, sizeof *twl, GFP_KERNEL); | 590 | twl = devm_kzalloc(&pdev->dev, sizeof *twl, GFP_KERNEL); |
595 | if (!twl) | 591 | if (!twl) |
596 | return -ENOMEM; | 592 | return -ENOMEM; |
597 | 593 | ||
594 | if (np) | ||
595 | of_property_read_u32(np, "usb_mode", | ||
596 | (enum twl4030_usb_mode *)&twl->usb_mode); | ||
597 | else if (pdata) | ||
598 | twl->usb_mode = pdata->usb_mode; | ||
599 | else { | ||
600 | dev_err(&pdev->dev, "twl4030 initialized without pdata\n"); | ||
601 | return -EINVAL; | ||
602 | } | ||
603 | |||
598 | otg = devm_kzalloc(&pdev->dev, sizeof *otg, GFP_KERNEL); | 604 | otg = devm_kzalloc(&pdev->dev, sizeof *otg, GFP_KERNEL); |
599 | if (!otg) | 605 | if (!otg) |
600 | return -ENOMEM; | 606 | return -ENOMEM; |
601 | 607 | ||
602 | twl->dev = &pdev->dev; | 608 | twl->dev = &pdev->dev; |
603 | twl->irq = platform_get_irq(pdev, 0); | 609 | twl->irq = platform_get_irq(pdev, 0); |
604 | twl->usb_mode = pdata->usb_mode; | ||
605 | twl->vbus_supplied = false; | 610 | twl->vbus_supplied = false; |
606 | twl->asleep = 1; | 611 | twl->asleep = 1; |
607 | twl->linkstat = OMAP_MUSB_UNKNOWN; | 612 | twl->linkstat = OMAP_MUSB_UNKNOWN; |
@@ -690,12 +695,21 @@ static int __exit twl4030_usb_remove(struct platform_device *pdev) | |||
690 | return 0; | 695 | return 0; |
691 | } | 696 | } |
692 | 697 | ||
698 | #ifdef CONFIG_OF | ||
699 | static const struct of_device_id twl4030_usb_id_table[] = { | ||
700 | { .compatible = "ti,twl4030-usb" }, | ||
701 | {} | ||
702 | }; | ||
703 | MODULE_DEVICE_TABLE(of, twl4030_usb_id_table); | ||
704 | #endif | ||
705 | |||
693 | static struct platform_driver twl4030_usb_driver = { | 706 | static struct platform_driver twl4030_usb_driver = { |
694 | .probe = twl4030_usb_probe, | 707 | .probe = twl4030_usb_probe, |
695 | .remove = __exit_p(twl4030_usb_remove), | 708 | .remove = __exit_p(twl4030_usb_remove), |
696 | .driver = { | 709 | .driver = { |
697 | .name = "twl4030_usb", | 710 | .name = "twl4030_usb", |
698 | .owner = THIS_MODULE, | 711 | .owner = THIS_MODULE, |
712 | .of_match_table = of_match_ptr(twl4030_usb_id_table), | ||
699 | }, | 713 | }, |
700 | }; | 714 | }; |
701 | 715 | ||
diff --git a/drivers/usb/otg/twl6030-usb.c b/drivers/usb/otg/twl6030-usb.c index 6907d8df7a27..fcadef7864f1 100644 --- a/drivers/usb/otg/twl6030-usb.c +++ b/drivers/usb/otg/twl6030-usb.c | |||
@@ -25,8 +25,9 @@ | |||
25 | #include <linux/interrupt.h> | 25 | #include <linux/interrupt.h> |
26 | #include <linux/platform_device.h> | 26 | #include <linux/platform_device.h> |
27 | #include <linux/io.h> | 27 | #include <linux/io.h> |
28 | #include <linux/usb/otg.h> | ||
29 | #include <linux/usb/musb-omap.h> | 28 | #include <linux/usb/musb-omap.h> |
29 | #include <linux/usb/phy_companion.h> | ||
30 | #include <linux/usb/omap_usb.h> | ||
30 | #include <linux/i2c/twl.h> | 31 | #include <linux/i2c/twl.h> |
31 | #include <linux/regulator/consumer.h> | 32 | #include <linux/regulator/consumer.h> |
32 | #include <linux/err.h> | 33 | #include <linux/err.h> |
@@ -87,7 +88,7 @@ | |||
87 | #define VBUS_DET BIT(2) | 88 | #define VBUS_DET BIT(2) |
88 | 89 | ||
89 | struct twl6030_usb { | 90 | struct twl6030_usb { |
90 | struct usb_phy phy; | 91 | struct phy_companion comparator; |
91 | struct device *dev; | 92 | struct device *dev; |
92 | 93 | ||
93 | /* for vbus reporting with irqs disabled */ | 94 | /* for vbus reporting with irqs disabled */ |
@@ -104,10 +105,10 @@ struct twl6030_usb { | |||
104 | u8 asleep; | 105 | u8 asleep; |
105 | bool irq_enabled; | 106 | bool irq_enabled; |
106 | bool vbus_enable; | 107 | bool vbus_enable; |
107 | unsigned long features; | 108 | const char *regulator; |
108 | }; | 109 | }; |
109 | 110 | ||
110 | #define phy_to_twl(x) container_of((x), struct twl6030_usb, phy) | 111 | #define comparator_to_twl(x) container_of((x), struct twl6030_usb, comparator) |
111 | 112 | ||
112 | /*-------------------------------------------------------------------------*/ | 113 | /*-------------------------------------------------------------------------*/ |
113 | 114 | ||
@@ -137,50 +138,9 @@ static inline u8 twl6030_readb(struct twl6030_usb *twl, u8 module, u8 address) | |||
137 | return ret; | 138 | return ret; |
138 | } | 139 | } |
139 | 140 | ||
140 | static int twl6030_phy_init(struct usb_phy *x) | 141 | static int twl6030_start_srp(struct phy_companion *comparator) |
141 | { | 142 | { |
142 | struct twl6030_usb *twl; | 143 | struct twl6030_usb *twl = comparator_to_twl(comparator); |
143 | struct device *dev; | ||
144 | struct twl4030_usb_data *pdata; | ||
145 | |||
146 | twl = phy_to_twl(x); | ||
147 | dev = twl->dev; | ||
148 | pdata = dev->platform_data; | ||
149 | |||
150 | if (twl->linkstat == OMAP_MUSB_ID_GROUND) | ||
151 | pdata->phy_power(twl->dev, 1, 1); | ||
152 | else | ||
153 | pdata->phy_power(twl->dev, 0, 1); | ||
154 | |||
155 | return 0; | ||
156 | } | ||
157 | |||
158 | static void twl6030_phy_shutdown(struct usb_phy *x) | ||
159 | { | ||
160 | struct twl6030_usb *twl; | ||
161 | struct device *dev; | ||
162 | struct twl4030_usb_data *pdata; | ||
163 | |||
164 | twl = phy_to_twl(x); | ||
165 | dev = twl->dev; | ||
166 | pdata = dev->platform_data; | ||
167 | pdata->phy_power(twl->dev, 0, 0); | ||
168 | } | ||
169 | |||
170 | static int twl6030_phy_suspend(struct usb_phy *x, int suspend) | ||
171 | { | ||
172 | struct twl6030_usb *twl = phy_to_twl(x); | ||
173 | struct device *dev = twl->dev; | ||
174 | struct twl4030_usb_data *pdata = dev->platform_data; | ||
175 | |||
176 | pdata->phy_suspend(dev, suspend); | ||
177 | |||
178 | return 0; | ||
179 | } | ||
180 | |||
181 | static int twl6030_start_srp(struct usb_otg *otg) | ||
182 | { | ||
183 | struct twl6030_usb *twl = phy_to_twl(otg->phy); | ||
184 | 144 | ||
185 | twl6030_writeb(twl, TWL_MODULE_USB, 0x24, USB_VBUS_CTRL_SET); | 145 | twl6030_writeb(twl, TWL_MODULE_USB, 0x24, USB_VBUS_CTRL_SET); |
186 | twl6030_writeb(twl, TWL_MODULE_USB, 0x84, USB_VBUS_CTRL_SET); | 146 | twl6030_writeb(twl, TWL_MODULE_USB, 0x84, USB_VBUS_CTRL_SET); |
@@ -193,13 +153,6 @@ static int twl6030_start_srp(struct usb_otg *otg) | |||
193 | 153 | ||
194 | static int twl6030_usb_ldo_init(struct twl6030_usb *twl) | 154 | static int twl6030_usb_ldo_init(struct twl6030_usb *twl) |
195 | { | 155 | { |
196 | char *regulator_name; | ||
197 | |||
198 | if (twl->features & TWL6025_SUBCLASS) | ||
199 | regulator_name = "ldousb"; | ||
200 | else | ||
201 | regulator_name = "vusb"; | ||
202 | |||
203 | /* Set to OTG_REV 1.3 and turn on the ID_WAKEUP_COMP */ | 156 | /* Set to OTG_REV 1.3 and turn on the ID_WAKEUP_COMP */ |
204 | twl6030_writeb(twl, TWL6030_MODULE_ID0 , 0x1, TWL6030_BACKUP_REG); | 157 | twl6030_writeb(twl, TWL6030_MODULE_ID0 , 0x1, TWL6030_BACKUP_REG); |
205 | 158 | ||
@@ -209,7 +162,7 @@ static int twl6030_usb_ldo_init(struct twl6030_usb *twl) | |||
209 | /* Program MISC2 register and set bit VUSB_IN_VBAT */ | 162 | /* Program MISC2 register and set bit VUSB_IN_VBAT */ |
210 | twl6030_writeb(twl, TWL6030_MODULE_ID0 , 0x10, TWL6030_MISC2); | 163 | twl6030_writeb(twl, TWL6030_MODULE_ID0 , 0x10, TWL6030_MISC2); |
211 | 164 | ||
212 | twl->usb3v3 = regulator_get(twl->dev, regulator_name); | 165 | twl->usb3v3 = regulator_get(twl->dev, twl->regulator); |
213 | if (IS_ERR(twl->usb3v3)) | 166 | if (IS_ERR(twl->usb3v3)) |
214 | return -ENODEV; | 167 | return -ENODEV; |
215 | 168 | ||
@@ -313,23 +266,8 @@ static irqreturn_t twl6030_usbotg_irq(int irq, void *_twl) | |||
313 | return IRQ_HANDLED; | 266 | return IRQ_HANDLED; |
314 | } | 267 | } |
315 | 268 | ||
316 | static int twl6030_set_peripheral(struct usb_otg *otg, | 269 | static int twl6030_enable_irq(struct twl6030_usb *twl) |
317 | struct usb_gadget *gadget) | ||
318 | { | ||
319 | if (!otg) | ||
320 | return -ENODEV; | ||
321 | |||
322 | otg->gadget = gadget; | ||
323 | if (!gadget) | ||
324 | otg->phy->state = OTG_STATE_UNDEFINED; | ||
325 | |||
326 | return 0; | ||
327 | } | ||
328 | |||
329 | static int twl6030_enable_irq(struct usb_phy *x) | ||
330 | { | 270 | { |
331 | struct twl6030_usb *twl = phy_to_twl(x); | ||
332 | |||
333 | twl6030_writeb(twl, TWL_MODULE_USB, 0x1, USB_ID_INT_EN_HI_SET); | 271 | twl6030_writeb(twl, TWL_MODULE_USB, 0x1, USB_ID_INT_EN_HI_SET); |
334 | twl6030_interrupt_unmask(0x05, REG_INT_MSK_LINE_C); | 272 | twl6030_interrupt_unmask(0x05, REG_INT_MSK_LINE_C); |
335 | twl6030_interrupt_unmask(0x05, REG_INT_MSK_STS_C); | 273 | twl6030_interrupt_unmask(0x05, REG_INT_MSK_STS_C); |
@@ -362,9 +300,9 @@ static void otg_set_vbus_work(struct work_struct *data) | |||
362 | CHARGERUSB_CTRL1); | 300 | CHARGERUSB_CTRL1); |
363 | } | 301 | } |
364 | 302 | ||
365 | static int twl6030_set_vbus(struct usb_otg *otg, bool enabled) | 303 | static int twl6030_set_vbus(struct phy_companion *comparator, bool enabled) |
366 | { | 304 | { |
367 | struct twl6030_usb *twl = phy_to_twl(otg->phy); | 305 | struct twl6030_usb *twl = comparator_to_twl(comparator); |
368 | 306 | ||
369 | twl->vbus_enable = enabled; | 307 | twl->vbus_enable = enabled; |
370 | schedule_work(&twl->set_vbus_work); | 308 | schedule_work(&twl->set_vbus_work); |
@@ -372,52 +310,44 @@ static int twl6030_set_vbus(struct usb_otg *otg, bool enabled) | |||
372 | return 0; | 310 | return 0; |
373 | } | 311 | } |
374 | 312 | ||
375 | static int twl6030_set_host(struct usb_otg *otg, struct usb_bus *host) | ||
376 | { | ||
377 | if (!otg) | ||
378 | return -ENODEV; | ||
379 | |||
380 | otg->host = host; | ||
381 | if (!host) | ||
382 | otg->phy->state = OTG_STATE_UNDEFINED; | ||
383 | return 0; | ||
384 | } | ||
385 | |||
386 | static int __devinit twl6030_usb_probe(struct platform_device *pdev) | 313 | static int __devinit twl6030_usb_probe(struct platform_device *pdev) |
387 | { | 314 | { |
315 | u32 ret; | ||
388 | struct twl6030_usb *twl; | 316 | struct twl6030_usb *twl; |
389 | int status, err; | 317 | int status, err; |
390 | struct twl4030_usb_data *pdata; | 318 | struct device_node *np = pdev->dev.of_node; |
391 | struct usb_otg *otg; | 319 | struct device *dev = &pdev->dev; |
392 | struct device *dev = &pdev->dev; | 320 | struct twl4030_usb_data *pdata = dev->platform_data; |
393 | pdata = dev->platform_data; | ||
394 | 321 | ||
395 | twl = devm_kzalloc(dev, sizeof *twl, GFP_KERNEL); | 322 | twl = devm_kzalloc(dev, sizeof *twl, GFP_KERNEL); |
396 | if (!twl) | 323 | if (!twl) |
397 | return -ENOMEM; | 324 | return -ENOMEM; |
398 | 325 | ||
399 | otg = devm_kzalloc(dev, sizeof *otg, GFP_KERNEL); | ||
400 | if (!otg) | ||
401 | return -ENOMEM; | ||
402 | |||
403 | twl->dev = &pdev->dev; | 326 | twl->dev = &pdev->dev; |
404 | twl->irq1 = platform_get_irq(pdev, 0); | 327 | twl->irq1 = platform_get_irq(pdev, 0); |
405 | twl->irq2 = platform_get_irq(pdev, 1); | 328 | twl->irq2 = platform_get_irq(pdev, 1); |
406 | twl->features = pdata->features; | ||
407 | twl->linkstat = OMAP_MUSB_UNKNOWN; | 329 | twl->linkstat = OMAP_MUSB_UNKNOWN; |
408 | 330 | ||
409 | twl->phy.dev = twl->dev; | 331 | twl->comparator.set_vbus = twl6030_set_vbus; |
410 | twl->phy.label = "twl6030"; | 332 | twl->comparator.start_srp = twl6030_start_srp; |
411 | twl->phy.otg = otg; | 333 | |
412 | twl->phy.init = twl6030_phy_init; | 334 | ret = omap_usb2_set_comparator(&twl->comparator); |
413 | twl->phy.shutdown = twl6030_phy_shutdown; | 335 | if (ret == -ENODEV) { |
414 | twl->phy.set_suspend = twl6030_phy_suspend; | 336 | dev_info(&pdev->dev, "phy not ready, deferring probe"); |
337 | return -EPROBE_DEFER; | ||
338 | } | ||
415 | 339 | ||
416 | otg->phy = &twl->phy; | 340 | if (np) { |
417 | otg->set_host = twl6030_set_host; | 341 | twl->regulator = "usb"; |
418 | otg->set_peripheral = twl6030_set_peripheral; | 342 | } else if (pdata) { |
419 | otg->set_vbus = twl6030_set_vbus; | 343 | if (pdata->features & TWL6025_SUBCLASS) |
420 | otg->start_srp = twl6030_start_srp; | 344 | twl->regulator = "ldousb"; |
345 | else | ||
346 | twl->regulator = "vusb"; | ||
347 | } else { | ||
348 | dev_err(&pdev->dev, "twl6030 initialized without pdata\n"); | ||
349 | return -EINVAL; | ||
350 | } | ||
421 | 351 | ||
422 | /* init spinlock for workqueue */ | 352 | /* init spinlock for workqueue */ |
423 | spin_lock_init(&twl->lock); | 353 | spin_lock_init(&twl->lock); |
@@ -427,7 +357,6 @@ static int __devinit twl6030_usb_probe(struct platform_device *pdev) | |||
427 | dev_err(&pdev->dev, "ldo init failed\n"); | 357 | dev_err(&pdev->dev, "ldo init failed\n"); |
428 | return err; | 358 | return err; |
429 | } | 359 | } |
430 | usb_add_phy(&twl->phy, USB_PHY_TYPE_USB2); | ||
431 | 360 | ||
432 | platform_set_drvdata(pdev, twl); | 361 | platform_set_drvdata(pdev, twl); |
433 | if (device_create_file(&pdev->dev, &dev_attr_vbus)) | 362 | if (device_create_file(&pdev->dev, &dev_attr_vbus)) |
@@ -458,9 +387,7 @@ static int __devinit twl6030_usb_probe(struct platform_device *pdev) | |||
458 | } | 387 | } |
459 | 388 | ||
460 | twl->asleep = 0; | 389 | twl->asleep = 0; |
461 | pdata->phy_init(dev); | 390 | twl6030_enable_irq(twl); |
462 | twl6030_phy_suspend(&twl->phy, 0); | ||
463 | twl6030_enable_irq(&twl->phy); | ||
464 | dev_info(&pdev->dev, "Initialized TWL6030 USB module\n"); | 391 | dev_info(&pdev->dev, "Initialized TWL6030 USB module\n"); |
465 | 392 | ||
466 | return 0; | 393 | return 0; |
@@ -470,10 +397,6 @@ static int __exit twl6030_usb_remove(struct platform_device *pdev) | |||
470 | { | 397 | { |
471 | struct twl6030_usb *twl = platform_get_drvdata(pdev); | 398 | struct twl6030_usb *twl = platform_get_drvdata(pdev); |
472 | 399 | ||
473 | struct twl4030_usb_data *pdata; | ||
474 | struct device *dev = &pdev->dev; | ||
475 | pdata = dev->platform_data; | ||
476 | |||
477 | twl6030_interrupt_mask(TWL6030_USBOTG_INT_MASK, | 400 | twl6030_interrupt_mask(TWL6030_USBOTG_INT_MASK, |
478 | REG_INT_MSK_LINE_C); | 401 | REG_INT_MSK_LINE_C); |
479 | twl6030_interrupt_mask(TWL6030_USBOTG_INT_MASK, | 402 | twl6030_interrupt_mask(TWL6030_USBOTG_INT_MASK, |
@@ -481,19 +404,27 @@ static int __exit twl6030_usb_remove(struct platform_device *pdev) | |||
481 | free_irq(twl->irq1, twl); | 404 | free_irq(twl->irq1, twl); |
482 | free_irq(twl->irq2, twl); | 405 | free_irq(twl->irq2, twl); |
483 | regulator_put(twl->usb3v3); | 406 | regulator_put(twl->usb3v3); |
484 | pdata->phy_exit(twl->dev); | ||
485 | device_remove_file(twl->dev, &dev_attr_vbus); | 407 | device_remove_file(twl->dev, &dev_attr_vbus); |
486 | cancel_work_sync(&twl->set_vbus_work); | 408 | cancel_work_sync(&twl->set_vbus_work); |
487 | 409 | ||
488 | return 0; | 410 | return 0; |
489 | } | 411 | } |
490 | 412 | ||
413 | #ifdef CONFIG_OF | ||
414 | static const struct of_device_id twl6030_usb_id_table[] = { | ||
415 | { .compatible = "ti,twl6030-usb" }, | ||
416 | {} | ||
417 | }; | ||
418 | MODULE_DEVICE_TABLE(of, twl6030_usb_id_table); | ||
419 | #endif | ||
420 | |||
491 | static struct platform_driver twl6030_usb_driver = { | 421 | static struct platform_driver twl6030_usb_driver = { |
492 | .probe = twl6030_usb_probe, | 422 | .probe = twl6030_usb_probe, |
493 | .remove = __exit_p(twl6030_usb_remove), | 423 | .remove = __exit_p(twl6030_usb_remove), |
494 | .driver = { | 424 | .driver = { |
495 | .name = "twl6030_usb", | 425 | .name = "twl6030_usb", |
496 | .owner = THIS_MODULE, | 426 | .owner = THIS_MODULE, |
427 | .of_match_table = of_match_ptr(twl6030_usb_id_table), | ||
497 | }, | 428 | }, |
498 | }; | 429 | }; |
499 | 430 | ||
diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig index e7cf84f0751a..63c339b3e676 100644 --- a/drivers/usb/phy/Kconfig +++ b/drivers/usb/phy/Kconfig | |||
@@ -4,6 +4,15 @@ | |||
4 | comment "USB Physical Layer drivers" | 4 | comment "USB Physical Layer drivers" |
5 | depends on USB || USB_GADGET | 5 | depends on USB || USB_GADGET |
6 | 6 | ||
7 | config OMAP_USB2 | ||
8 | tristate "OMAP USB2 PHY Driver" | ||
9 | select USB_OTG_UTILS | ||
10 | help | ||
11 | Enable this to support the transceiver that is part of SOC. This | ||
12 | driver takes care of all the PHY functionality apart from comparator. | ||
13 | The USB OTG controller communicates with the comparator using this | ||
14 | driver. | ||
15 | |||
7 | config USB_ISP1301 | 16 | config USB_ISP1301 |
8 | tristate "NXP ISP1301 USB transceiver support" | 17 | tristate "NXP ISP1301 USB transceiver support" |
9 | depends on USB || USB_GADGET | 18 | depends on USB || USB_GADGET |
@@ -15,3 +24,11 @@ config USB_ISP1301 | |||
15 | 24 | ||
16 | To compile this driver as a module, choose M here: the | 25 | To compile this driver as a module, choose M here: the |
17 | module will be called isp1301. | 26 | module will be called isp1301. |
27 | |||
28 | config MV_U3D_PHY | ||
29 | bool "Marvell USB 3.0 PHY controller Driver" | ||
30 | depends on USB_MV_U3D | ||
31 | select USB_OTG_UTILS | ||
32 | help | ||
33 | Enable this to support Marvell USB 3.0 phy controller for Marvell | ||
34 | SoC. | ||
diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile index eca095b1a890..b069f29f1225 100644 --- a/drivers/usb/phy/Makefile +++ b/drivers/usb/phy/Makefile | |||
@@ -4,4 +4,7 @@ | |||
4 | 4 | ||
5 | ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG | 5 | ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG |
6 | 6 | ||
7 | obj-$(CONFIG_OMAP_USB2) += omap-usb2.o | ||
7 | obj-$(CONFIG_USB_ISP1301) += isp1301.o | 8 | obj-$(CONFIG_USB_ISP1301) += isp1301.o |
9 | obj-$(CONFIG_MV_U3D_PHY) += mv_u3d_phy.o | ||
10 | obj-$(CONFIG_USB_EHCI_TEGRA) += tegra_usb_phy.o | ||
diff --git a/drivers/usb/phy/isp1301.c b/drivers/usb/phy/isp1301.c index b19f4932a037..18dbf7e37607 100644 --- a/drivers/usb/phy/isp1301.c +++ b/drivers/usb/phy/isp1301.c | |||
@@ -15,12 +15,6 @@ | |||
15 | 15 | ||
16 | #define DRV_NAME "isp1301" | 16 | #define DRV_NAME "isp1301" |
17 | 17 | ||
18 | #define ISP1301_I2C_ADDR 0x2C | ||
19 | |||
20 | static const unsigned short normal_i2c[] = { | ||
21 | ISP1301_I2C_ADDR, ISP1301_I2C_ADDR + 1, I2C_CLIENT_END | ||
22 | }; | ||
23 | |||
24 | static const struct i2c_device_id isp1301_id[] = { | 18 | static const struct i2c_device_id isp1301_id[] = { |
25 | { "isp1301", 0 }, | 19 | { "isp1301", 0 }, |
26 | { } | 20 | { } |
diff --git a/drivers/usb/phy/mv_u3d_phy.c b/drivers/usb/phy/mv_u3d_phy.c new file mode 100644 index 000000000000..9f1c5d3c60ec --- /dev/null +++ b/drivers/usb/phy/mv_u3d_phy.c | |||
@@ -0,0 +1,345 @@ | |||
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 and conditions of the GNU General Public License, | ||
6 | * version 2, as published by the Free Software Foundation. | ||
7 | */ | ||
8 | |||
9 | #include <linux/module.h> | ||
10 | #include <linux/platform_device.h> | ||
11 | #include <linux/clk.h> | ||
12 | #include <linux/delay.h> | ||
13 | #include <linux/err.h> | ||
14 | #include <linux/io.h> | ||
15 | #include <linux/usb/otg.h> | ||
16 | #include <linux/platform_data/mv_usb.h> | ||
17 | |||
18 | #include "mv_u3d_phy.h" | ||
19 | |||
20 | /* | ||
21 | * struct mv_u3d_phy - transceiver driver state | ||
22 | * @phy: transceiver structure | ||
23 | * @dev: The parent device supplied to the probe function | ||
24 | * @clk: usb phy clock | ||
25 | * @base: usb phy register memory base | ||
26 | */ | ||
27 | struct mv_u3d_phy { | ||
28 | struct usb_phy phy; | ||
29 | struct mv_usb_platform_data *plat; | ||
30 | struct device *dev; | ||
31 | struct clk *clk; | ||
32 | void __iomem *base; | ||
33 | }; | ||
34 | |||
35 | static u32 mv_u3d_phy_read(void __iomem *base, u32 reg) | ||
36 | { | ||
37 | void __iomem *addr, *data; | ||
38 | |||
39 | addr = base; | ||
40 | data = base + 0x4; | ||
41 | |||
42 | writel_relaxed(reg, addr); | ||
43 | return readl_relaxed(data); | ||
44 | } | ||
45 | |||
46 | static void mv_u3d_phy_set(void __iomem *base, u32 reg, u32 value) | ||
47 | { | ||
48 | void __iomem *addr, *data; | ||
49 | u32 tmp; | ||
50 | |||
51 | addr = base; | ||
52 | data = base + 0x4; | ||
53 | |||
54 | writel_relaxed(reg, addr); | ||
55 | tmp = readl_relaxed(data); | ||
56 | tmp |= value; | ||
57 | writel_relaxed(tmp, data); | ||
58 | } | ||
59 | |||
60 | static void mv_u3d_phy_clear(void __iomem *base, u32 reg, u32 value) | ||
61 | { | ||
62 | void __iomem *addr, *data; | ||
63 | u32 tmp; | ||
64 | |||
65 | addr = base; | ||
66 | data = base + 0x4; | ||
67 | |||
68 | writel_relaxed(reg, addr); | ||
69 | tmp = readl_relaxed(data); | ||
70 | tmp &= ~value; | ||
71 | writel_relaxed(tmp, data); | ||
72 | } | ||
73 | |||
74 | static void mv_u3d_phy_write(void __iomem *base, u32 reg, u32 value) | ||
75 | { | ||
76 | void __iomem *addr, *data; | ||
77 | |||
78 | addr = base; | ||
79 | data = base + 0x4; | ||
80 | |||
81 | writel_relaxed(reg, addr); | ||
82 | writel_relaxed(value, data); | ||
83 | } | ||
84 | |||
85 | void mv_u3d_phy_shutdown(struct usb_phy *phy) | ||
86 | { | ||
87 | struct mv_u3d_phy *mv_u3d_phy; | ||
88 | void __iomem *base; | ||
89 | u32 val; | ||
90 | |||
91 | mv_u3d_phy = container_of(phy, struct mv_u3d_phy, phy); | ||
92 | base = mv_u3d_phy->base; | ||
93 | |||
94 | /* Power down Reference Analog current, bit 15 | ||
95 | * Power down PLL, bit 14 | ||
96 | * Power down Receiver, bit 13 | ||
97 | * Power down Transmitter, bit 12 | ||
98 | * of USB3_POWER_PLL_CONTROL register | ||
99 | */ | ||
100 | val = mv_u3d_phy_read(base, USB3_POWER_PLL_CONTROL); | ||
101 | val &= ~(USB3_POWER_PLL_CONTROL_PU); | ||
102 | mv_u3d_phy_write(base, USB3_POWER_PLL_CONTROL, val); | ||
103 | |||
104 | if (mv_u3d_phy->clk) | ||
105 | clk_disable(mv_u3d_phy->clk); | ||
106 | } | ||
107 | |||
108 | static int mv_u3d_phy_init(struct usb_phy *phy) | ||
109 | { | ||
110 | struct mv_u3d_phy *mv_u3d_phy; | ||
111 | void __iomem *base; | ||
112 | u32 val, count; | ||
113 | |||
114 | /* enable usb3 phy */ | ||
115 | mv_u3d_phy = container_of(phy, struct mv_u3d_phy, phy); | ||
116 | |||
117 | if (mv_u3d_phy->clk) | ||
118 | clk_enable(mv_u3d_phy->clk); | ||
119 | |||
120 | base = mv_u3d_phy->base; | ||
121 | |||
122 | val = mv_u3d_phy_read(base, USB3_POWER_PLL_CONTROL); | ||
123 | val &= ~(USB3_POWER_PLL_CONTROL_PU_MASK); | ||
124 | val |= 0xF << USB3_POWER_PLL_CONTROL_PU_SHIFT; | ||
125 | mv_u3d_phy_write(base, USB3_POWER_PLL_CONTROL, val); | ||
126 | udelay(100); | ||
127 | |||
128 | mv_u3d_phy_write(base, USB3_RESET_CONTROL, | ||
129 | USB3_RESET_CONTROL_RESET_PIPE); | ||
130 | udelay(100); | ||
131 | |||
132 | mv_u3d_phy_write(base, USB3_RESET_CONTROL, | ||
133 | USB3_RESET_CONTROL_RESET_PIPE | ||
134 | | USB3_RESET_CONTROL_RESET_PHY); | ||
135 | udelay(100); | ||
136 | |||
137 | val = mv_u3d_phy_read(base, USB3_POWER_PLL_CONTROL); | ||
138 | val &= ~(USB3_POWER_PLL_CONTROL_REF_FREF_SEL_MASK | ||
139 | | USB3_POWER_PLL_CONTROL_PHY_MODE_MASK); | ||
140 | val |= (USB3_PLL_25MHZ << USB3_POWER_PLL_CONTROL_REF_FREF_SEL_SHIFT) | ||
141 | | (0x5 << USB3_POWER_PLL_CONTROL_PHY_MODE_SHIFT); | ||
142 | mv_u3d_phy_write(base, USB3_POWER_PLL_CONTROL, val); | ||
143 | udelay(100); | ||
144 | |||
145 | mv_u3d_phy_clear(base, USB3_KVCO_CALI_CONTROL, | ||
146 | USB3_KVCO_CALI_CONTROL_USE_MAX_PLL_RATE_MASK); | ||
147 | udelay(100); | ||
148 | |||
149 | val = mv_u3d_phy_read(base, USB3_SQUELCH_FFE); | ||
150 | val &= ~(USB3_SQUELCH_FFE_FFE_CAP_SEL_MASK | ||
151 | | USB3_SQUELCH_FFE_FFE_RES_SEL_MASK | ||
152 | | USB3_SQUELCH_FFE_SQ_THRESH_IN_MASK); | ||
153 | val |= ((0xD << USB3_SQUELCH_FFE_FFE_CAP_SEL_SHIFT) | ||
154 | | (0x7 << USB3_SQUELCH_FFE_FFE_RES_SEL_SHIFT) | ||
155 | | (0x8 << USB3_SQUELCH_FFE_SQ_THRESH_IN_SHIFT)); | ||
156 | mv_u3d_phy_write(base, USB3_SQUELCH_FFE, val); | ||
157 | udelay(100); | ||
158 | |||
159 | val = mv_u3d_phy_read(base, USB3_GEN1_SET0); | ||
160 | val &= ~USB3_GEN1_SET0_G1_TX_SLEW_CTRL_EN_MASK; | ||
161 | val |= 1 << USB3_GEN1_SET0_G1_TX_EMPH_EN_SHIFT; | ||
162 | mv_u3d_phy_write(base, USB3_GEN1_SET0, val); | ||
163 | udelay(100); | ||
164 | |||
165 | val = mv_u3d_phy_read(base, USB3_GEN2_SET0); | ||
166 | val &= ~(USB3_GEN2_SET0_G2_TX_AMP_MASK | ||
167 | | USB3_GEN2_SET0_G2_TX_EMPH_AMP_MASK | ||
168 | | USB3_GEN2_SET0_G2_TX_SLEW_CTRL_EN_MASK); | ||
169 | val |= ((0x14 << USB3_GEN2_SET0_G2_TX_AMP_SHIFT) | ||
170 | | (1 << USB3_GEN2_SET0_G2_TX_AMP_ADJ_SHIFT) | ||
171 | | (0xA << USB3_GEN2_SET0_G2_TX_EMPH_AMP_SHIFT) | ||
172 | | (1 << USB3_GEN2_SET0_G2_TX_EMPH_EN_SHIFT)); | ||
173 | mv_u3d_phy_write(base, USB3_GEN2_SET0, val); | ||
174 | udelay(100); | ||
175 | |||
176 | mv_u3d_phy_read(base, USB3_TX_EMPPH); | ||
177 | val &= ~(USB3_TX_EMPPH_AMP_MASK | ||
178 | | USB3_TX_EMPPH_EN_MASK | ||
179 | | USB3_TX_EMPPH_AMP_FORCE_MASK | ||
180 | | USB3_TX_EMPPH_PAR1_MASK | ||
181 | | USB3_TX_EMPPH_PAR2_MASK); | ||
182 | val |= ((0xB << USB3_TX_EMPPH_AMP_SHIFT) | ||
183 | | (1 << USB3_TX_EMPPH_EN_SHIFT) | ||
184 | | (1 << USB3_TX_EMPPH_AMP_FORCE_SHIFT) | ||
185 | | (0x1C << USB3_TX_EMPPH_PAR1_SHIFT) | ||
186 | | (1 << USB3_TX_EMPPH_PAR2_SHIFT)); | ||
187 | |||
188 | mv_u3d_phy_write(base, USB3_TX_EMPPH, val); | ||
189 | udelay(100); | ||
190 | |||
191 | val = mv_u3d_phy_read(base, USB3_GEN2_SET1); | ||
192 | val &= ~(USB3_GEN2_SET1_G2_RX_SELMUPI_MASK | ||
193 | | USB3_GEN2_SET1_G2_RX_SELMUPF_MASK | ||
194 | | USB3_GEN2_SET1_G2_RX_SELMUFI_MASK | ||
195 | | USB3_GEN2_SET1_G2_RX_SELMUFF_MASK); | ||
196 | val |= ((1 << USB3_GEN2_SET1_G2_RX_SELMUPI_SHIFT) | ||
197 | | (1 << USB3_GEN2_SET1_G2_RX_SELMUPF_SHIFT) | ||
198 | | (1 << USB3_GEN2_SET1_G2_RX_SELMUFI_SHIFT) | ||
199 | | (1 << USB3_GEN2_SET1_G2_RX_SELMUFF_SHIFT)); | ||
200 | mv_u3d_phy_write(base, USB3_GEN2_SET1, val); | ||
201 | udelay(100); | ||
202 | |||
203 | val = mv_u3d_phy_read(base, USB3_DIGITAL_LOOPBACK_EN); | ||
204 | val &= ~USB3_DIGITAL_LOOPBACK_EN_SEL_BITS_MASK; | ||
205 | val |= 1 << USB3_DIGITAL_LOOPBACK_EN_SEL_BITS_SHIFT; | ||
206 | mv_u3d_phy_write(base, USB3_DIGITAL_LOOPBACK_EN, val); | ||
207 | udelay(100); | ||
208 | |||
209 | val = mv_u3d_phy_read(base, USB3_IMPEDANCE_TX_SSC); | ||
210 | val &= ~USB3_IMPEDANCE_TX_SSC_SSC_AMP_MASK; | ||
211 | val |= 0xC << USB3_IMPEDANCE_TX_SSC_SSC_AMP_SHIFT; | ||
212 | mv_u3d_phy_write(base, USB3_IMPEDANCE_TX_SSC, val); | ||
213 | udelay(100); | ||
214 | |||
215 | val = mv_u3d_phy_read(base, USB3_IMPEDANCE_CALI_CTRL); | ||
216 | val &= ~USB3_IMPEDANCE_CALI_CTRL_IMP_CAL_THR_MASK; | ||
217 | val |= 0x4 << USB3_IMPEDANCE_CALI_CTRL_IMP_CAL_THR_SHIFT; | ||
218 | mv_u3d_phy_write(base, USB3_IMPEDANCE_CALI_CTRL, val); | ||
219 | udelay(100); | ||
220 | |||
221 | val = mv_u3d_phy_read(base, USB3_PHY_ISOLATION_MODE); | ||
222 | val &= ~(USB3_PHY_ISOLATION_MODE_PHY_GEN_RX_MASK | ||
223 | | USB3_PHY_ISOLATION_MODE_PHY_GEN_TX_MASK | ||
224 | | USB3_PHY_ISOLATION_MODE_TX_DRV_IDLE_MASK); | ||
225 | val |= ((1 << USB3_PHY_ISOLATION_MODE_PHY_GEN_RX_SHIFT) | ||
226 | | (1 << USB3_PHY_ISOLATION_MODE_PHY_GEN_TX_SHIFT)); | ||
227 | mv_u3d_phy_write(base, USB3_PHY_ISOLATION_MODE, val); | ||
228 | udelay(100); | ||
229 | |||
230 | val = mv_u3d_phy_read(base, USB3_TXDETRX); | ||
231 | val &= ~(USB3_TXDETRX_VTHSEL_MASK); | ||
232 | val |= 0x1 << USB3_TXDETRX_VTHSEL_SHIFT; | ||
233 | mv_u3d_phy_write(base, USB3_TXDETRX, val); | ||
234 | udelay(100); | ||
235 | |||
236 | dev_dbg(mv_u3d_phy->dev, "start calibration\n"); | ||
237 | |||
238 | calstart: | ||
239 | /* Perform Manual Calibration */ | ||
240 | mv_u3d_phy_set(base, USB3_KVCO_CALI_CONTROL, | ||
241 | 1 << USB3_KVCO_CALI_CONTROL_CAL_START_SHIFT); | ||
242 | |||
243 | mdelay(1); | ||
244 | |||
245 | count = 0; | ||
246 | while (1) { | ||
247 | val = mv_u3d_phy_read(base, USB3_KVCO_CALI_CONTROL); | ||
248 | if (val & (1 << USB3_KVCO_CALI_CONTROL_CAL_DONE_SHIFT)) | ||
249 | break; | ||
250 | else if (count > 50) { | ||
251 | dev_dbg(mv_u3d_phy->dev, "calibration failure, retry...\n"); | ||
252 | goto calstart; | ||
253 | } | ||
254 | count++; | ||
255 | mdelay(1); | ||
256 | } | ||
257 | |||
258 | /* active PIPE interface */ | ||
259 | mv_u3d_phy_write(base, USB3_PIPE_SM_CTRL, | ||
260 | 1 << USB3_PIPE_SM_CTRL_PHY_INIT_DONE); | ||
261 | |||
262 | return 0; | ||
263 | } | ||
264 | |||
265 | static int __devinit mv_u3d_phy_probe(struct platform_device *pdev) | ||
266 | { | ||
267 | struct mv_u3d_phy *mv_u3d_phy; | ||
268 | struct mv_usb_platform_data *pdata; | ||
269 | struct device *dev = &pdev->dev; | ||
270 | struct resource *res; | ||
271 | void __iomem *phy_base; | ||
272 | int ret; | ||
273 | |||
274 | pdata = pdev->dev.platform_data; | ||
275 | if (!pdata) { | ||
276 | dev_err(&pdev->dev, "%s: no platform data defined\n", __func__); | ||
277 | return -EINVAL; | ||
278 | } | ||
279 | |||
280 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
281 | if (!res) { | ||
282 | dev_err(dev, "missing mem resource\n"); | ||
283 | return -ENODEV; | ||
284 | } | ||
285 | |||
286 | phy_base = devm_request_and_ioremap(dev, res); | ||
287 | if (!phy_base) { | ||
288 | dev_err(dev, "%s: register mapping failed\n", __func__); | ||
289 | return -ENXIO; | ||
290 | } | ||
291 | |||
292 | mv_u3d_phy = devm_kzalloc(dev, sizeof(*mv_u3d_phy), GFP_KERNEL); | ||
293 | if (!mv_u3d_phy) | ||
294 | return -ENOMEM; | ||
295 | |||
296 | mv_u3d_phy->dev = &pdev->dev; | ||
297 | mv_u3d_phy->plat = pdata; | ||
298 | mv_u3d_phy->base = phy_base; | ||
299 | mv_u3d_phy->phy.dev = mv_u3d_phy->dev; | ||
300 | mv_u3d_phy->phy.label = "mv-u3d-phy"; | ||
301 | mv_u3d_phy->phy.init = mv_u3d_phy_init; | ||
302 | mv_u3d_phy->phy.shutdown = mv_u3d_phy_shutdown; | ||
303 | |||
304 | ret = usb_add_phy(&mv_u3d_phy->phy, USB_PHY_TYPE_USB3); | ||
305 | if (ret) | ||
306 | goto err; | ||
307 | |||
308 | if (!mv_u3d_phy->clk) | ||
309 | mv_u3d_phy->clk = clk_get(mv_u3d_phy->dev, "u3dphy"); | ||
310 | |||
311 | platform_set_drvdata(pdev, mv_u3d_phy); | ||
312 | |||
313 | dev_info(&pdev->dev, "Initialized Marvell USB 3.0 PHY\n"); | ||
314 | err: | ||
315 | return ret; | ||
316 | } | ||
317 | |||
318 | static int __exit mv_u3d_phy_remove(struct platform_device *pdev) | ||
319 | { | ||
320 | struct mv_u3d_phy *mv_u3d_phy = platform_get_drvdata(pdev); | ||
321 | |||
322 | usb_remove_phy(&mv_u3d_phy->phy); | ||
323 | |||
324 | if (mv_u3d_phy->clk) { | ||
325 | clk_put(mv_u3d_phy->clk); | ||
326 | mv_u3d_phy->clk = NULL; | ||
327 | } | ||
328 | |||
329 | return 0; | ||
330 | } | ||
331 | |||
332 | static struct platform_driver mv_u3d_phy_driver = { | ||
333 | .probe = mv_u3d_phy_probe, | ||
334 | .remove = __devexit_p(mv_u3d_phy_remove), | ||
335 | .driver = { | ||
336 | .name = "mv-u3d-phy", | ||
337 | .owner = THIS_MODULE, | ||
338 | }, | ||
339 | }; | ||
340 | |||
341 | module_platform_driver(mv_u3d_phy_driver); | ||
342 | MODULE_DESCRIPTION("Marvell USB 3.0 PHY controller"); | ||
343 | MODULE_AUTHOR("Yu Xu <yuxu@marvell.com>"); | ||
344 | MODULE_LICENSE("GPL"); | ||
345 | MODULE_ALIAS("platform:mv-u3d-phy"); | ||
diff --git a/drivers/usb/phy/mv_u3d_phy.h b/drivers/usb/phy/mv_u3d_phy.h new file mode 100644 index 000000000000..2a658cb9a527 --- /dev/null +++ b/drivers/usb/phy/mv_u3d_phy.h | |||
@@ -0,0 +1,105 @@ | |||
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 and conditions of the GNU General Public License, | ||
6 | * version 2, as published by the Free Software Foundation. | ||
7 | */ | ||
8 | |||
9 | #ifndef __MV_U3D_PHY_H | ||
10 | #define __MV_U3D_PHY_H | ||
11 | |||
12 | #define USB3_POWER_PLL_CONTROL 0x1 | ||
13 | #define USB3_KVCO_CALI_CONTROL 0x2 | ||
14 | #define USB3_IMPEDANCE_CALI_CTRL 0x3 | ||
15 | #define USB3_IMPEDANCE_TX_SSC 0x4 | ||
16 | #define USB3_SQUELCH_FFE 0x6 | ||
17 | #define USB3_GEN1_SET0 0xD | ||
18 | #define USB3_GEN2_SET0 0xF | ||
19 | #define USB3_GEN2_SET1 0x10 | ||
20 | #define USB3_DIGITAL_LOOPBACK_EN 0x23 | ||
21 | #define USB3_PHY_ISOLATION_MODE 0x26 | ||
22 | #define USB3_TXDETRX 0x48 | ||
23 | #define USB3_TX_EMPPH 0x5E | ||
24 | #define USB3_RESET_CONTROL 0x90 | ||
25 | #define USB3_PIPE_SM_CTRL 0x91 | ||
26 | |||
27 | #define USB3_RESET_CONTROL_RESET_PIPE 0x1 | ||
28 | #define USB3_RESET_CONTROL_RESET_PHY 0x2 | ||
29 | |||
30 | #define USB3_POWER_PLL_CONTROL_REF_FREF_SEL_MASK (0x1F << 0) | ||
31 | #define USB3_POWER_PLL_CONTROL_REF_FREF_SEL_SHIFT 0 | ||
32 | #define USB3_PLL_25MHZ 0x2 | ||
33 | #define USB3_PLL_26MHZ 0x5 | ||
34 | #define USB3_POWER_PLL_CONTROL_PHY_MODE_MASK (0x7 << 5) | ||
35 | #define USB3_POWER_PLL_CONTROL_PHY_MODE_SHIFT 5 | ||
36 | #define USB3_POWER_PLL_CONTROL_PU_MASK (0xF << 12) | ||
37 | #define USB3_POWER_PLL_CONTROL_PU_SHIFT 12 | ||
38 | #define USB3_POWER_PLL_CONTROL_PU (0xF << 12) | ||
39 | |||
40 | #define USB3_KVCO_CALI_CONTROL_USE_MAX_PLL_RATE_MASK (0x1 << 12) | ||
41 | #define USB3_KVCO_CALI_CONTROL_USE_MAX_PLL_RATE_SHIFT 12 | ||
42 | #define USB3_KVCO_CALI_CONTROL_CAL_DONE_SHIFT 14 | ||
43 | #define USB3_KVCO_CALI_CONTROL_CAL_START_SHIFT 15 | ||
44 | |||
45 | #define USB3_SQUELCH_FFE_FFE_CAP_SEL_MASK 0xF | ||
46 | #define USB3_SQUELCH_FFE_FFE_CAP_SEL_SHIFT 0 | ||
47 | #define USB3_SQUELCH_FFE_FFE_RES_SEL_MASK (0x7 << 4) | ||
48 | #define USB3_SQUELCH_FFE_FFE_RES_SEL_SHIFT 4 | ||
49 | #define USB3_SQUELCH_FFE_SQ_THRESH_IN_MASK (0x1F << 8) | ||
50 | #define USB3_SQUELCH_FFE_SQ_THRESH_IN_SHIFT 8 | ||
51 | |||
52 | #define USB3_GEN1_SET0_G1_TX_SLEW_CTRL_EN_MASK (0x1 << 15) | ||
53 | #define USB3_GEN1_SET0_G1_TX_EMPH_EN_SHIFT 11 | ||
54 | |||
55 | #define USB3_GEN2_SET0_G2_TX_AMP_MASK (0x1F << 1) | ||
56 | #define USB3_GEN2_SET0_G2_TX_AMP_SHIFT 1 | ||
57 | #define USB3_GEN2_SET0_G2_TX_AMP_ADJ_SHIFT 6 | ||
58 | #define USB3_GEN2_SET0_G2_TX_EMPH_AMP_MASK (0xF << 7) | ||
59 | #define USB3_GEN2_SET0_G2_TX_EMPH_AMP_SHIFT 7 | ||
60 | #define USB3_GEN2_SET0_G2_TX_EMPH_EN_MASK (0x1 << 11) | ||
61 | #define USB3_GEN2_SET0_G2_TX_EMPH_EN_SHIFT 11 | ||
62 | #define USB3_GEN2_SET0_G2_TX_SLEW_CTRL_EN_MASK (0x1 << 15) | ||
63 | #define USB3_GEN2_SET0_G2_TX_SLEW_CTRL_EN_SHIFT 15 | ||
64 | |||
65 | #define USB3_GEN2_SET1_G2_RX_SELMUPI_MASK (0x7 << 0) | ||
66 | #define USB3_GEN2_SET1_G2_RX_SELMUPI_SHIFT 0 | ||
67 | #define USB3_GEN2_SET1_G2_RX_SELMUPF_MASK (0x7 << 3) | ||
68 | #define USB3_GEN2_SET1_G2_RX_SELMUPF_SHIFT 3 | ||
69 | #define USB3_GEN2_SET1_G2_RX_SELMUFI_MASK (0x3 << 6) | ||
70 | #define USB3_GEN2_SET1_G2_RX_SELMUFI_SHIFT 6 | ||
71 | #define USB3_GEN2_SET1_G2_RX_SELMUFF_MASK (0x3 << 8) | ||
72 | #define USB3_GEN2_SET1_G2_RX_SELMUFF_SHIFT 8 | ||
73 | |||
74 | #define USB3_DIGITAL_LOOPBACK_EN_SEL_BITS_MASK (0x3 << 10) | ||
75 | #define USB3_DIGITAL_LOOPBACK_EN_SEL_BITS_SHIFT 10 | ||
76 | |||
77 | #define USB3_IMPEDANCE_CALI_CTRL_IMP_CAL_THR_MASK (0x7 << 12) | ||
78 | #define USB3_IMPEDANCE_CALI_CTRL_IMP_CAL_THR_SHIFT 12 | ||
79 | |||
80 | #define USB3_IMPEDANCE_TX_SSC_SSC_AMP_MASK (0x3F << 0) | ||
81 | #define USB3_IMPEDANCE_TX_SSC_SSC_AMP_SHIFT 0 | ||
82 | |||
83 | #define USB3_PHY_ISOLATION_MODE_PHY_GEN_RX_MASK 0xF | ||
84 | #define USB3_PHY_ISOLATION_MODE_PHY_GEN_RX_SHIFT 0 | ||
85 | #define USB3_PHY_ISOLATION_MODE_PHY_GEN_TX_MASK (0xF << 4) | ||
86 | #define USB3_PHY_ISOLATION_MODE_PHY_GEN_TX_SHIFT 4 | ||
87 | #define USB3_PHY_ISOLATION_MODE_TX_DRV_IDLE_MASK (0x1 << 8) | ||
88 | |||
89 | #define USB3_TXDETRX_VTHSEL_MASK (0x3 << 4) | ||
90 | #define USB3_TXDETRX_VTHSEL_SHIFT 4 | ||
91 | |||
92 | #define USB3_TX_EMPPH_AMP_MASK (0xF << 0) | ||
93 | #define USB3_TX_EMPPH_AMP_SHIFT 0 | ||
94 | #define USB3_TX_EMPPH_EN_MASK (0x1 << 6) | ||
95 | #define USB3_TX_EMPPH_EN_SHIFT 6 | ||
96 | #define USB3_TX_EMPPH_AMP_FORCE_MASK (0x1 << 7) | ||
97 | #define USB3_TX_EMPPH_AMP_FORCE_SHIFT 7 | ||
98 | #define USB3_TX_EMPPH_PAR1_MASK (0x1F << 8) | ||
99 | #define USB3_TX_EMPPH_PAR1_SHIFT 8 | ||
100 | #define USB3_TX_EMPPH_PAR2_MASK (0x1 << 13) | ||
101 | #define USB3_TX_EMPPH_PAR2_SHIFT 13 | ||
102 | |||
103 | #define USB3_PIPE_SM_CTRL_PHY_INIT_DONE 15 | ||
104 | |||
105 | #endif /* __MV_U3D_PHY_H */ | ||
diff --git a/drivers/usb/phy/omap-usb2.c b/drivers/usb/phy/omap-usb2.c new file mode 100644 index 000000000000..15ab3d6f2e8c --- /dev/null +++ b/drivers/usb/phy/omap-usb2.c | |||
@@ -0,0 +1,271 @@ | |||
1 | /* | ||
2 | * omap-usb2.c - USB PHY, talking to musb controller in OMAP. | ||
3 | * | ||
4 | * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com | ||
5 | * This program is free software; you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; either version 2 of the License, or | ||
8 | * (at your option) any later version. | ||
9 | * | ||
10 | * Author: Kishon Vijay Abraham I <kishon@ti.com> | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | */ | ||
18 | |||
19 | #include <linux/module.h> | ||
20 | #include <linux/platform_device.h> | ||
21 | #include <linux/slab.h> | ||
22 | #include <linux/of.h> | ||
23 | #include <linux/io.h> | ||
24 | #include <linux/usb/omap_usb.h> | ||
25 | #include <linux/usb/phy_companion.h> | ||
26 | #include <linux/clk.h> | ||
27 | #include <linux/err.h> | ||
28 | #include <linux/pm_runtime.h> | ||
29 | #include <linux/delay.h> | ||
30 | |||
31 | /** | ||
32 | * omap_usb2_set_comparator - links the comparator present in the sytem with | ||
33 | * this phy | ||
34 | * @comparator - the companion phy(comparator) for this phy | ||
35 | * | ||
36 | * The phy companion driver should call this API passing the phy_companion | ||
37 | * filled with set_vbus and start_srp to be used by usb phy. | ||
38 | * | ||
39 | * For use by phy companion driver | ||
40 | */ | ||
41 | int omap_usb2_set_comparator(struct phy_companion *comparator) | ||
42 | { | ||
43 | struct omap_usb *phy; | ||
44 | struct usb_phy *x = usb_get_phy(USB_PHY_TYPE_USB2); | ||
45 | |||
46 | if (IS_ERR(x)) | ||
47 | return -ENODEV; | ||
48 | |||
49 | phy = phy_to_omapusb(x); | ||
50 | phy->comparator = comparator; | ||
51 | return 0; | ||
52 | } | ||
53 | EXPORT_SYMBOL_GPL(omap_usb2_set_comparator); | ||
54 | |||
55 | /** | ||
56 | * omap_usb_phy_power - power on/off the phy using control module reg | ||
57 | * @phy: struct omap_usb * | ||
58 | * @on: 0 or 1, based on powering on or off the PHY | ||
59 | * | ||
60 | * XXX: Remove this function once control module driver gets merged | ||
61 | */ | ||
62 | static void omap_usb_phy_power(struct omap_usb *phy, int on) | ||
63 | { | ||
64 | u32 val; | ||
65 | |||
66 | if (on) { | ||
67 | val = readl(phy->control_dev); | ||
68 | if (val & PHY_PD) { | ||
69 | writel(~PHY_PD, phy->control_dev); | ||
70 | /* XXX: add proper documentation for this delay */ | ||
71 | mdelay(200); | ||
72 | } | ||
73 | } else { | ||
74 | writel(PHY_PD, phy->control_dev); | ||
75 | } | ||
76 | } | ||
77 | |||
78 | static int omap_usb_set_vbus(struct usb_otg *otg, bool enabled) | ||
79 | { | ||
80 | struct omap_usb *phy = phy_to_omapusb(otg->phy); | ||
81 | |||
82 | if (!phy->comparator) | ||
83 | return -ENODEV; | ||
84 | |||
85 | return phy->comparator->set_vbus(phy->comparator, enabled); | ||
86 | } | ||
87 | |||
88 | static int omap_usb_start_srp(struct usb_otg *otg) | ||
89 | { | ||
90 | struct omap_usb *phy = phy_to_omapusb(otg->phy); | ||
91 | |||
92 | if (!phy->comparator) | ||
93 | return -ENODEV; | ||
94 | |||
95 | return phy->comparator->start_srp(phy->comparator); | ||
96 | } | ||
97 | |||
98 | static int omap_usb_set_host(struct usb_otg *otg, struct usb_bus *host) | ||
99 | { | ||
100 | struct usb_phy *phy = otg->phy; | ||
101 | |||
102 | otg->host = host; | ||
103 | if (!host) | ||
104 | phy->state = OTG_STATE_UNDEFINED; | ||
105 | |||
106 | return 0; | ||
107 | } | ||
108 | |||
109 | static int omap_usb_set_peripheral(struct usb_otg *otg, | ||
110 | struct usb_gadget *gadget) | ||
111 | { | ||
112 | struct usb_phy *phy = otg->phy; | ||
113 | |||
114 | otg->gadget = gadget; | ||
115 | if (!gadget) | ||
116 | phy->state = OTG_STATE_UNDEFINED; | ||
117 | |||
118 | return 0; | ||
119 | } | ||
120 | |||
121 | static int omap_usb2_suspend(struct usb_phy *x, int suspend) | ||
122 | { | ||
123 | u32 ret; | ||
124 | struct omap_usb *phy = phy_to_omapusb(x); | ||
125 | |||
126 | if (suspend && !phy->is_suspended) { | ||
127 | omap_usb_phy_power(phy, 0); | ||
128 | pm_runtime_put_sync(phy->dev); | ||
129 | phy->is_suspended = 1; | ||
130 | } else if (!suspend && phy->is_suspended) { | ||
131 | ret = pm_runtime_get_sync(phy->dev); | ||
132 | if (ret < 0) { | ||
133 | dev_err(phy->dev, "get_sync failed with err %d\n", | ||
134 | ret); | ||
135 | return ret; | ||
136 | } | ||
137 | omap_usb_phy_power(phy, 1); | ||
138 | phy->is_suspended = 0; | ||
139 | } | ||
140 | |||
141 | return 0; | ||
142 | } | ||
143 | |||
144 | static int __devinit omap_usb2_probe(struct platform_device *pdev) | ||
145 | { | ||
146 | struct omap_usb *phy; | ||
147 | struct usb_otg *otg; | ||
148 | struct resource *res; | ||
149 | |||
150 | phy = devm_kzalloc(&pdev->dev, sizeof(*phy), GFP_KERNEL); | ||
151 | if (!phy) { | ||
152 | dev_err(&pdev->dev, "unable to allocate memory for USB2 PHY\n"); | ||
153 | return -ENOMEM; | ||
154 | } | ||
155 | |||
156 | otg = devm_kzalloc(&pdev->dev, sizeof(*otg), GFP_KERNEL); | ||
157 | if (!otg) { | ||
158 | dev_err(&pdev->dev, "unable to allocate memory for USB OTG\n"); | ||
159 | return -ENOMEM; | ||
160 | } | ||
161 | |||
162 | phy->dev = &pdev->dev; | ||
163 | |||
164 | phy->phy.dev = phy->dev; | ||
165 | phy->phy.label = "omap-usb2"; | ||
166 | phy->phy.set_suspend = omap_usb2_suspend; | ||
167 | phy->phy.otg = otg; | ||
168 | |||
169 | res = platform_get_resource(pdev, IORESOURCE_MEM, 1); | ||
170 | |||
171 | phy->control_dev = devm_request_and_ioremap(&pdev->dev, res); | ||
172 | if (phy->control_dev == NULL) { | ||
173 | dev_err(&pdev->dev, "Failed to obtain io memory\n"); | ||
174 | return -ENXIO; | ||
175 | } | ||
176 | |||
177 | phy->is_suspended = 1; | ||
178 | omap_usb_phy_power(phy, 0); | ||
179 | |||
180 | otg->set_host = omap_usb_set_host; | ||
181 | otg->set_peripheral = omap_usb_set_peripheral; | ||
182 | otg->set_vbus = omap_usb_set_vbus; | ||
183 | otg->start_srp = omap_usb_start_srp; | ||
184 | otg->phy = &phy->phy; | ||
185 | |||
186 | phy->wkupclk = devm_clk_get(phy->dev, "usb_phy_cm_clk32k"); | ||
187 | if (IS_ERR(phy->wkupclk)) { | ||
188 | dev_err(&pdev->dev, "unable to get usb_phy_cm_clk32k\n"); | ||
189 | return PTR_ERR(phy->wkupclk); | ||
190 | } | ||
191 | clk_prepare(phy->wkupclk); | ||
192 | |||
193 | usb_add_phy(&phy->phy, USB_PHY_TYPE_USB2); | ||
194 | |||
195 | platform_set_drvdata(pdev, phy); | ||
196 | |||
197 | pm_runtime_enable(phy->dev); | ||
198 | |||
199 | return 0; | ||
200 | } | ||
201 | |||
202 | static int __devexit omap_usb2_remove(struct platform_device *pdev) | ||
203 | { | ||
204 | struct omap_usb *phy = platform_get_drvdata(pdev); | ||
205 | |||
206 | clk_unprepare(phy->wkupclk); | ||
207 | usb_remove_phy(&phy->phy); | ||
208 | |||
209 | return 0; | ||
210 | } | ||
211 | |||
212 | #ifdef CONFIG_PM_RUNTIME | ||
213 | |||
214 | static int omap_usb2_runtime_suspend(struct device *dev) | ||
215 | { | ||
216 | struct platform_device *pdev = to_platform_device(dev); | ||
217 | struct omap_usb *phy = platform_get_drvdata(pdev); | ||
218 | |||
219 | clk_disable(phy->wkupclk); | ||
220 | |||
221 | return 0; | ||
222 | } | ||
223 | |||
224 | static int omap_usb2_runtime_resume(struct device *dev) | ||
225 | { | ||
226 | u32 ret = 0; | ||
227 | struct platform_device *pdev = to_platform_device(dev); | ||
228 | struct omap_usb *phy = platform_get_drvdata(pdev); | ||
229 | |||
230 | ret = clk_enable(phy->wkupclk); | ||
231 | if (ret < 0) | ||
232 | dev_err(phy->dev, "Failed to enable wkupclk %d\n", ret); | ||
233 | |||
234 | return ret; | ||
235 | } | ||
236 | |||
237 | static const struct dev_pm_ops omap_usb2_pm_ops = { | ||
238 | SET_RUNTIME_PM_OPS(omap_usb2_runtime_suspend, omap_usb2_runtime_resume, | ||
239 | NULL) | ||
240 | }; | ||
241 | |||
242 | #define DEV_PM_OPS (&omap_usb2_pm_ops) | ||
243 | #else | ||
244 | #define DEV_PM_OPS NULL | ||
245 | #endif | ||
246 | |||
247 | #ifdef CONFIG_OF | ||
248 | static const struct of_device_id omap_usb2_id_table[] = { | ||
249 | { .compatible = "ti,omap-usb2" }, | ||
250 | {} | ||
251 | }; | ||
252 | MODULE_DEVICE_TABLE(of, omap_usb2_id_table); | ||
253 | #endif | ||
254 | |||
255 | static struct platform_driver omap_usb2_driver = { | ||
256 | .probe = omap_usb2_probe, | ||
257 | .remove = __devexit_p(omap_usb2_remove), | ||
258 | .driver = { | ||
259 | .name = "omap-usb2", | ||
260 | .owner = THIS_MODULE, | ||
261 | .pm = DEV_PM_OPS, | ||
262 | .of_match_table = of_match_ptr(omap_usb2_id_table), | ||
263 | }, | ||
264 | }; | ||
265 | |||
266 | module_platform_driver(omap_usb2_driver); | ||
267 | |||
268 | MODULE_ALIAS("platform: omap_usb2"); | ||
269 | MODULE_AUTHOR("Texas Instruments Inc."); | ||
270 | MODULE_DESCRIPTION("OMAP USB2 phy driver"); | ||
271 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/usb/phy/tegra_usb_phy.c b/drivers/usb/phy/tegra_usb_phy.c new file mode 100644 index 000000000000..4739903245e8 --- /dev/null +++ b/drivers/usb/phy/tegra_usb_phy.c | |||
@@ -0,0 +1,839 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2010 Google, Inc. | ||
3 | * | ||
4 | * Author: | ||
5 | * Erik Gilling <konkers@google.com> | ||
6 | * Benoit Goby <benoit@android.com> | ||
7 | * | ||
8 | * This software is licensed under the terms of the GNU General Public | ||
9 | * License version 2, as published by the Free Software Foundation, and | ||
10 | * may be copied, distributed, and modified under those terms. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | */ | ||
18 | |||
19 | #include <linux/resource.h> | ||
20 | #include <linux/delay.h> | ||
21 | #include <linux/slab.h> | ||
22 | #include <linux/err.h> | ||
23 | #include <linux/export.h> | ||
24 | #include <linux/platform_device.h> | ||
25 | #include <linux/io.h> | ||
26 | #include <linux/gpio.h> | ||
27 | #include <linux/of_gpio.h> | ||
28 | #include <linux/usb/otg.h> | ||
29 | #include <linux/usb/ulpi.h> | ||
30 | #include <asm/mach-types.h> | ||
31 | #include <mach/gpio-tegra.h> | ||
32 | #include <linux/usb/tegra_usb_phy.h> | ||
33 | #include <mach/iomap.h> | ||
34 | |||
35 | #define ULPI_VIEWPORT 0x170 | ||
36 | |||
37 | #define USB_PORTSC1 0x184 | ||
38 | #define USB_PORTSC1_PTS(x) (((x) & 0x3) << 30) | ||
39 | #define USB_PORTSC1_PSPD(x) (((x) & 0x3) << 26) | ||
40 | #define USB_PORTSC1_PHCD (1 << 23) | ||
41 | #define USB_PORTSC1_WKOC (1 << 22) | ||
42 | #define USB_PORTSC1_WKDS (1 << 21) | ||
43 | #define USB_PORTSC1_WKCN (1 << 20) | ||
44 | #define USB_PORTSC1_PTC(x) (((x) & 0xf) << 16) | ||
45 | #define USB_PORTSC1_PP (1 << 12) | ||
46 | #define USB_PORTSC1_SUSP (1 << 7) | ||
47 | #define USB_PORTSC1_PE (1 << 2) | ||
48 | #define USB_PORTSC1_CCS (1 << 0) | ||
49 | |||
50 | #define USB_SUSP_CTRL 0x400 | ||
51 | #define USB_WAKE_ON_CNNT_EN_DEV (1 << 3) | ||
52 | #define USB_WAKE_ON_DISCON_EN_DEV (1 << 4) | ||
53 | #define USB_SUSP_CLR (1 << 5) | ||
54 | #define USB_PHY_CLK_VALID (1 << 7) | ||
55 | #define UTMIP_RESET (1 << 11) | ||
56 | #define UHSIC_RESET (1 << 11) | ||
57 | #define UTMIP_PHY_ENABLE (1 << 12) | ||
58 | #define ULPI_PHY_ENABLE (1 << 13) | ||
59 | #define USB_SUSP_SET (1 << 14) | ||
60 | #define USB_WAKEUP_DEBOUNCE_COUNT(x) (((x) & 0x7) << 16) | ||
61 | |||
62 | #define USB1_LEGACY_CTRL 0x410 | ||
63 | #define USB1_NO_LEGACY_MODE (1 << 0) | ||
64 | #define USB1_VBUS_SENSE_CTL_MASK (3 << 1) | ||
65 | #define USB1_VBUS_SENSE_CTL_VBUS_WAKEUP (0 << 1) | ||
66 | #define USB1_VBUS_SENSE_CTL_AB_SESS_VLD_OR_VBUS_WAKEUP \ | ||
67 | (1 << 1) | ||
68 | #define USB1_VBUS_SENSE_CTL_AB_SESS_VLD (2 << 1) | ||
69 | #define USB1_VBUS_SENSE_CTL_A_SESS_VLD (3 << 1) | ||
70 | |||
71 | #define ULPI_TIMING_CTRL_0 0x424 | ||
72 | #define ULPI_OUTPUT_PINMUX_BYP (1 << 10) | ||
73 | #define ULPI_CLKOUT_PINMUX_BYP (1 << 11) | ||
74 | |||
75 | #define ULPI_TIMING_CTRL_1 0x428 | ||
76 | #define ULPI_DATA_TRIMMER_LOAD (1 << 0) | ||
77 | #define ULPI_DATA_TRIMMER_SEL(x) (((x) & 0x7) << 1) | ||
78 | #define ULPI_STPDIRNXT_TRIMMER_LOAD (1 << 16) | ||
79 | #define ULPI_STPDIRNXT_TRIMMER_SEL(x) (((x) & 0x7) << 17) | ||
80 | #define ULPI_DIR_TRIMMER_LOAD (1 << 24) | ||
81 | #define ULPI_DIR_TRIMMER_SEL(x) (((x) & 0x7) << 25) | ||
82 | |||
83 | #define UTMIP_PLL_CFG1 0x804 | ||
84 | #define UTMIP_XTAL_FREQ_COUNT(x) (((x) & 0xfff) << 0) | ||
85 | #define UTMIP_PLLU_ENABLE_DLY_COUNT(x) (((x) & 0x1f) << 27) | ||
86 | |||
87 | #define UTMIP_XCVR_CFG0 0x808 | ||
88 | #define UTMIP_XCVR_SETUP(x) (((x) & 0xf) << 0) | ||
89 | #define UTMIP_XCVR_LSRSLEW(x) (((x) & 0x3) << 8) | ||
90 | #define UTMIP_XCVR_LSFSLEW(x) (((x) & 0x3) << 10) | ||
91 | #define UTMIP_FORCE_PD_POWERDOWN (1 << 14) | ||
92 | #define UTMIP_FORCE_PD2_POWERDOWN (1 << 16) | ||
93 | #define UTMIP_FORCE_PDZI_POWERDOWN (1 << 18) | ||
94 | #define UTMIP_XCVR_HSSLEW_MSB(x) (((x) & 0x7f) << 25) | ||
95 | |||
96 | #define UTMIP_BIAS_CFG0 0x80c | ||
97 | #define UTMIP_OTGPD (1 << 11) | ||
98 | #define UTMIP_BIASPD (1 << 10) | ||
99 | |||
100 | #define UTMIP_HSRX_CFG0 0x810 | ||
101 | #define UTMIP_ELASTIC_LIMIT(x) (((x) & 0x1f) << 10) | ||
102 | #define UTMIP_IDLE_WAIT(x) (((x) & 0x1f) << 15) | ||
103 | |||
104 | #define UTMIP_HSRX_CFG1 0x814 | ||
105 | #define UTMIP_HS_SYNC_START_DLY(x) (((x) & 0x1f) << 1) | ||
106 | |||
107 | #define UTMIP_TX_CFG0 0x820 | ||
108 | #define UTMIP_FS_PREABMLE_J (1 << 19) | ||
109 | #define UTMIP_HS_DISCON_DISABLE (1 << 8) | ||
110 | |||
111 | #define UTMIP_MISC_CFG0 0x824 | ||
112 | #define UTMIP_DPDM_OBSERVE (1 << 26) | ||
113 | #define UTMIP_DPDM_OBSERVE_SEL(x) (((x) & 0xf) << 27) | ||
114 | #define UTMIP_DPDM_OBSERVE_SEL_FS_J UTMIP_DPDM_OBSERVE_SEL(0xf) | ||
115 | #define UTMIP_DPDM_OBSERVE_SEL_FS_K UTMIP_DPDM_OBSERVE_SEL(0xe) | ||
116 | #define UTMIP_DPDM_OBSERVE_SEL_FS_SE1 UTMIP_DPDM_OBSERVE_SEL(0xd) | ||
117 | #define UTMIP_DPDM_OBSERVE_SEL_FS_SE0 UTMIP_DPDM_OBSERVE_SEL(0xc) | ||
118 | #define UTMIP_SUSPEND_EXIT_ON_EDGE (1 << 22) | ||
119 | |||
120 | #define UTMIP_MISC_CFG1 0x828 | ||
121 | #define UTMIP_PLL_ACTIVE_DLY_COUNT(x) (((x) & 0x1f) << 18) | ||
122 | #define UTMIP_PLLU_STABLE_COUNT(x) (((x) & 0xfff) << 6) | ||
123 | |||
124 | #define UTMIP_DEBOUNCE_CFG0 0x82c | ||
125 | #define UTMIP_BIAS_DEBOUNCE_A(x) (((x) & 0xffff) << 0) | ||
126 | |||
127 | #define UTMIP_BAT_CHRG_CFG0 0x830 | ||
128 | #define UTMIP_PD_CHRG (1 << 0) | ||
129 | |||
130 | #define UTMIP_SPARE_CFG0 0x834 | ||
131 | #define FUSE_SETUP_SEL (1 << 3) | ||
132 | |||
133 | #define UTMIP_XCVR_CFG1 0x838 | ||
134 | #define UTMIP_FORCE_PDDISC_POWERDOWN (1 << 0) | ||
135 | #define UTMIP_FORCE_PDCHRP_POWERDOWN (1 << 2) | ||
136 | #define UTMIP_FORCE_PDDR_POWERDOWN (1 << 4) | ||
137 | #define UTMIP_XCVR_TERM_RANGE_ADJ(x) (((x) & 0xf) << 18) | ||
138 | |||
139 | #define UTMIP_BIAS_CFG1 0x83c | ||
140 | #define UTMIP_BIAS_PDTRK_COUNT(x) (((x) & 0x1f) << 3) | ||
141 | |||
142 | static DEFINE_SPINLOCK(utmip_pad_lock); | ||
143 | static int utmip_pad_count; | ||
144 | |||
145 | struct tegra_xtal_freq { | ||
146 | int freq; | ||
147 | u8 enable_delay; | ||
148 | u8 stable_count; | ||
149 | u8 active_delay; | ||
150 | u8 xtal_freq_count; | ||
151 | u16 debounce; | ||
152 | }; | ||
153 | |||
154 | static const struct tegra_xtal_freq tegra_freq_table[] = { | ||
155 | { | ||
156 | .freq = 12000000, | ||
157 | .enable_delay = 0x02, | ||
158 | .stable_count = 0x2F, | ||
159 | .active_delay = 0x04, | ||
160 | .xtal_freq_count = 0x76, | ||
161 | .debounce = 0x7530, | ||
162 | }, | ||
163 | { | ||
164 | .freq = 13000000, | ||
165 | .enable_delay = 0x02, | ||
166 | .stable_count = 0x33, | ||
167 | .active_delay = 0x05, | ||
168 | .xtal_freq_count = 0x7F, | ||
169 | .debounce = 0x7EF4, | ||
170 | }, | ||
171 | { | ||
172 | .freq = 19200000, | ||
173 | .enable_delay = 0x03, | ||
174 | .stable_count = 0x4B, | ||
175 | .active_delay = 0x06, | ||
176 | .xtal_freq_count = 0xBB, | ||
177 | .debounce = 0xBB80, | ||
178 | }, | ||
179 | { | ||
180 | .freq = 26000000, | ||
181 | .enable_delay = 0x04, | ||
182 | .stable_count = 0x66, | ||
183 | .active_delay = 0x09, | ||
184 | .xtal_freq_count = 0xFE, | ||
185 | .debounce = 0xFDE8, | ||
186 | }, | ||
187 | }; | ||
188 | |||
189 | static struct tegra_utmip_config utmip_default[] = { | ||
190 | [0] = { | ||
191 | .hssync_start_delay = 9, | ||
192 | .idle_wait_delay = 17, | ||
193 | .elastic_limit = 16, | ||
194 | .term_range_adj = 6, | ||
195 | .xcvr_setup = 9, | ||
196 | .xcvr_lsfslew = 1, | ||
197 | .xcvr_lsrslew = 1, | ||
198 | }, | ||
199 | [2] = { | ||
200 | .hssync_start_delay = 9, | ||
201 | .idle_wait_delay = 17, | ||
202 | .elastic_limit = 16, | ||
203 | .term_range_adj = 6, | ||
204 | .xcvr_setup = 9, | ||
205 | .xcvr_lsfslew = 2, | ||
206 | .xcvr_lsrslew = 2, | ||
207 | }, | ||
208 | }; | ||
209 | |||
210 | static inline bool phy_is_ulpi(struct tegra_usb_phy *phy) | ||
211 | { | ||
212 | return (phy->instance == 1); | ||
213 | } | ||
214 | |||
215 | static int utmip_pad_open(struct tegra_usb_phy *phy) | ||
216 | { | ||
217 | phy->pad_clk = clk_get_sys("utmip-pad", NULL); | ||
218 | if (IS_ERR(phy->pad_clk)) { | ||
219 | pr_err("%s: can't get utmip pad clock\n", __func__); | ||
220 | return PTR_ERR(phy->pad_clk); | ||
221 | } | ||
222 | |||
223 | if (phy->instance == 0) { | ||
224 | phy->pad_regs = phy->regs; | ||
225 | } else { | ||
226 | phy->pad_regs = ioremap(TEGRA_USB_BASE, TEGRA_USB_SIZE); | ||
227 | if (!phy->pad_regs) { | ||
228 | pr_err("%s: can't remap usb registers\n", __func__); | ||
229 | clk_put(phy->pad_clk); | ||
230 | return -ENOMEM; | ||
231 | } | ||
232 | } | ||
233 | return 0; | ||
234 | } | ||
235 | |||
236 | static void utmip_pad_close(struct tegra_usb_phy *phy) | ||
237 | { | ||
238 | if (phy->instance != 0) | ||
239 | iounmap(phy->pad_regs); | ||
240 | clk_put(phy->pad_clk); | ||
241 | } | ||
242 | |||
243 | static void utmip_pad_power_on(struct tegra_usb_phy *phy) | ||
244 | { | ||
245 | unsigned long val, flags; | ||
246 | void __iomem *base = phy->pad_regs; | ||
247 | |||
248 | clk_prepare_enable(phy->pad_clk); | ||
249 | |||
250 | spin_lock_irqsave(&utmip_pad_lock, flags); | ||
251 | |||
252 | if (utmip_pad_count++ == 0) { | ||
253 | val = readl(base + UTMIP_BIAS_CFG0); | ||
254 | val &= ~(UTMIP_OTGPD | UTMIP_BIASPD); | ||
255 | writel(val, base + UTMIP_BIAS_CFG0); | ||
256 | } | ||
257 | |||
258 | spin_unlock_irqrestore(&utmip_pad_lock, flags); | ||
259 | |||
260 | clk_disable_unprepare(phy->pad_clk); | ||
261 | } | ||
262 | |||
263 | static int utmip_pad_power_off(struct tegra_usb_phy *phy) | ||
264 | { | ||
265 | unsigned long val, flags; | ||
266 | void __iomem *base = phy->pad_regs; | ||
267 | |||
268 | if (!utmip_pad_count) { | ||
269 | pr_err("%s: utmip pad already powered off\n", __func__); | ||
270 | return -EINVAL; | ||
271 | } | ||
272 | |||
273 | clk_prepare_enable(phy->pad_clk); | ||
274 | |||
275 | spin_lock_irqsave(&utmip_pad_lock, flags); | ||
276 | |||
277 | if (--utmip_pad_count == 0) { | ||
278 | val = readl(base + UTMIP_BIAS_CFG0); | ||
279 | val |= UTMIP_OTGPD | UTMIP_BIASPD; | ||
280 | writel(val, base + UTMIP_BIAS_CFG0); | ||
281 | } | ||
282 | |||
283 | spin_unlock_irqrestore(&utmip_pad_lock, flags); | ||
284 | |||
285 | clk_disable_unprepare(phy->pad_clk); | ||
286 | |||
287 | return 0; | ||
288 | } | ||
289 | |||
290 | static int utmi_wait_register(void __iomem *reg, u32 mask, u32 result) | ||
291 | { | ||
292 | unsigned long timeout = 2000; | ||
293 | do { | ||
294 | if ((readl(reg) & mask) == result) | ||
295 | return 0; | ||
296 | udelay(1); | ||
297 | timeout--; | ||
298 | } while (timeout); | ||
299 | return -1; | ||
300 | } | ||
301 | |||
302 | static void utmi_phy_clk_disable(struct tegra_usb_phy *phy) | ||
303 | { | ||
304 | unsigned long val; | ||
305 | void __iomem *base = phy->regs; | ||
306 | |||
307 | if (phy->instance == 0) { | ||
308 | val = readl(base + USB_SUSP_CTRL); | ||
309 | val |= USB_SUSP_SET; | ||
310 | writel(val, base + USB_SUSP_CTRL); | ||
311 | |||
312 | udelay(10); | ||
313 | |||
314 | val = readl(base + USB_SUSP_CTRL); | ||
315 | val &= ~USB_SUSP_SET; | ||
316 | writel(val, base + USB_SUSP_CTRL); | ||
317 | } | ||
318 | |||
319 | if (phy->instance == 2) { | ||
320 | val = readl(base + USB_PORTSC1); | ||
321 | val |= USB_PORTSC1_PHCD; | ||
322 | writel(val, base + USB_PORTSC1); | ||
323 | } | ||
324 | |||
325 | if (utmi_wait_register(base + USB_SUSP_CTRL, USB_PHY_CLK_VALID, 0) < 0) | ||
326 | pr_err("%s: timeout waiting for phy to stabilize\n", __func__); | ||
327 | } | ||
328 | |||
329 | static void utmi_phy_clk_enable(struct tegra_usb_phy *phy) | ||
330 | { | ||
331 | unsigned long val; | ||
332 | void __iomem *base = phy->regs; | ||
333 | |||
334 | if (phy->instance == 0) { | ||
335 | val = readl(base + USB_SUSP_CTRL); | ||
336 | val |= USB_SUSP_CLR; | ||
337 | writel(val, base + USB_SUSP_CTRL); | ||
338 | |||
339 | udelay(10); | ||
340 | |||
341 | val = readl(base + USB_SUSP_CTRL); | ||
342 | val &= ~USB_SUSP_CLR; | ||
343 | writel(val, base + USB_SUSP_CTRL); | ||
344 | } | ||
345 | |||
346 | if (phy->instance == 2) { | ||
347 | val = readl(base + USB_PORTSC1); | ||
348 | val &= ~USB_PORTSC1_PHCD; | ||
349 | writel(val, base + USB_PORTSC1); | ||
350 | } | ||
351 | |||
352 | if (utmi_wait_register(base + USB_SUSP_CTRL, USB_PHY_CLK_VALID, | ||
353 | USB_PHY_CLK_VALID)) | ||
354 | pr_err("%s: timeout waiting for phy to stabilize\n", __func__); | ||
355 | } | ||
356 | |||
357 | static int utmi_phy_power_on(struct tegra_usb_phy *phy) | ||
358 | { | ||
359 | unsigned long val; | ||
360 | void __iomem *base = phy->regs; | ||
361 | struct tegra_utmip_config *config = phy->config; | ||
362 | |||
363 | val = readl(base + USB_SUSP_CTRL); | ||
364 | val |= UTMIP_RESET; | ||
365 | writel(val, base + USB_SUSP_CTRL); | ||
366 | |||
367 | if (phy->instance == 0) { | ||
368 | val = readl(base + USB1_LEGACY_CTRL); | ||
369 | val |= USB1_NO_LEGACY_MODE; | ||
370 | writel(val, base + USB1_LEGACY_CTRL); | ||
371 | } | ||
372 | |||
373 | val = readl(base + UTMIP_TX_CFG0); | ||
374 | val &= ~UTMIP_FS_PREABMLE_J; | ||
375 | writel(val, base + UTMIP_TX_CFG0); | ||
376 | |||
377 | val = readl(base + UTMIP_HSRX_CFG0); | ||
378 | val &= ~(UTMIP_IDLE_WAIT(~0) | UTMIP_ELASTIC_LIMIT(~0)); | ||
379 | val |= UTMIP_IDLE_WAIT(config->idle_wait_delay); | ||
380 | val |= UTMIP_ELASTIC_LIMIT(config->elastic_limit); | ||
381 | writel(val, base + UTMIP_HSRX_CFG0); | ||
382 | |||
383 | val = readl(base + UTMIP_HSRX_CFG1); | ||
384 | val &= ~UTMIP_HS_SYNC_START_DLY(~0); | ||
385 | val |= UTMIP_HS_SYNC_START_DLY(config->hssync_start_delay); | ||
386 | writel(val, base + UTMIP_HSRX_CFG1); | ||
387 | |||
388 | val = readl(base + UTMIP_DEBOUNCE_CFG0); | ||
389 | val &= ~UTMIP_BIAS_DEBOUNCE_A(~0); | ||
390 | val |= UTMIP_BIAS_DEBOUNCE_A(phy->freq->debounce); | ||
391 | writel(val, base + UTMIP_DEBOUNCE_CFG0); | ||
392 | |||
393 | val = readl(base + UTMIP_MISC_CFG0); | ||
394 | val &= ~UTMIP_SUSPEND_EXIT_ON_EDGE; | ||
395 | writel(val, base + UTMIP_MISC_CFG0); | ||
396 | |||
397 | val = readl(base + UTMIP_MISC_CFG1); | ||
398 | val &= ~(UTMIP_PLL_ACTIVE_DLY_COUNT(~0) | UTMIP_PLLU_STABLE_COUNT(~0)); | ||
399 | val |= UTMIP_PLL_ACTIVE_DLY_COUNT(phy->freq->active_delay) | | ||
400 | UTMIP_PLLU_STABLE_COUNT(phy->freq->stable_count); | ||
401 | writel(val, base + UTMIP_MISC_CFG1); | ||
402 | |||
403 | val = readl(base + UTMIP_PLL_CFG1); | ||
404 | val &= ~(UTMIP_XTAL_FREQ_COUNT(~0) | UTMIP_PLLU_ENABLE_DLY_COUNT(~0)); | ||
405 | val |= UTMIP_XTAL_FREQ_COUNT(phy->freq->xtal_freq_count) | | ||
406 | UTMIP_PLLU_ENABLE_DLY_COUNT(phy->freq->enable_delay); | ||
407 | writel(val, base + UTMIP_PLL_CFG1); | ||
408 | |||
409 | if (phy->mode == TEGRA_USB_PHY_MODE_DEVICE) { | ||
410 | val = readl(base + USB_SUSP_CTRL); | ||
411 | val &= ~(USB_WAKE_ON_CNNT_EN_DEV | USB_WAKE_ON_DISCON_EN_DEV); | ||
412 | writel(val, base + USB_SUSP_CTRL); | ||
413 | } | ||
414 | |||
415 | utmip_pad_power_on(phy); | ||
416 | |||
417 | val = readl(base + UTMIP_XCVR_CFG0); | ||
418 | val &= ~(UTMIP_FORCE_PD_POWERDOWN | UTMIP_FORCE_PD2_POWERDOWN | | ||
419 | UTMIP_FORCE_PDZI_POWERDOWN | UTMIP_XCVR_SETUP(~0) | | ||
420 | UTMIP_XCVR_LSFSLEW(~0) | UTMIP_XCVR_LSRSLEW(~0) | | ||
421 | UTMIP_XCVR_HSSLEW_MSB(~0)); | ||
422 | val |= UTMIP_XCVR_SETUP(config->xcvr_setup); | ||
423 | val |= UTMIP_XCVR_LSFSLEW(config->xcvr_lsfslew); | ||
424 | val |= UTMIP_XCVR_LSRSLEW(config->xcvr_lsrslew); | ||
425 | writel(val, base + UTMIP_XCVR_CFG0); | ||
426 | |||
427 | val = readl(base + UTMIP_XCVR_CFG1); | ||
428 | val &= ~(UTMIP_FORCE_PDDISC_POWERDOWN | UTMIP_FORCE_PDCHRP_POWERDOWN | | ||
429 | UTMIP_FORCE_PDDR_POWERDOWN | UTMIP_XCVR_TERM_RANGE_ADJ(~0)); | ||
430 | val |= UTMIP_XCVR_TERM_RANGE_ADJ(config->term_range_adj); | ||
431 | writel(val, base + UTMIP_XCVR_CFG1); | ||
432 | |||
433 | val = readl(base + UTMIP_BAT_CHRG_CFG0); | ||
434 | val &= ~UTMIP_PD_CHRG; | ||
435 | writel(val, base + UTMIP_BAT_CHRG_CFG0); | ||
436 | |||
437 | val = readl(base + UTMIP_BIAS_CFG1); | ||
438 | val &= ~UTMIP_BIAS_PDTRK_COUNT(~0); | ||
439 | val |= UTMIP_BIAS_PDTRK_COUNT(0x5); | ||
440 | writel(val, base + UTMIP_BIAS_CFG1); | ||
441 | |||
442 | if (phy->instance == 0) { | ||
443 | val = readl(base + UTMIP_SPARE_CFG0); | ||
444 | if (phy->mode == TEGRA_USB_PHY_MODE_DEVICE) | ||
445 | val &= ~FUSE_SETUP_SEL; | ||
446 | else | ||
447 | val |= FUSE_SETUP_SEL; | ||
448 | writel(val, base + UTMIP_SPARE_CFG0); | ||
449 | } | ||
450 | |||
451 | if (phy->instance == 2) { | ||
452 | val = readl(base + USB_SUSP_CTRL); | ||
453 | val |= UTMIP_PHY_ENABLE; | ||
454 | writel(val, base + USB_SUSP_CTRL); | ||
455 | } | ||
456 | |||
457 | val = readl(base + USB_SUSP_CTRL); | ||
458 | val &= ~UTMIP_RESET; | ||
459 | writel(val, base + USB_SUSP_CTRL); | ||
460 | |||
461 | if (phy->instance == 0) { | ||
462 | val = readl(base + USB1_LEGACY_CTRL); | ||
463 | val &= ~USB1_VBUS_SENSE_CTL_MASK; | ||
464 | val |= USB1_VBUS_SENSE_CTL_A_SESS_VLD; | ||
465 | writel(val, base + USB1_LEGACY_CTRL); | ||
466 | |||
467 | val = readl(base + USB_SUSP_CTRL); | ||
468 | val &= ~USB_SUSP_SET; | ||
469 | writel(val, base + USB_SUSP_CTRL); | ||
470 | } | ||
471 | |||
472 | utmi_phy_clk_enable(phy); | ||
473 | |||
474 | if (phy->instance == 2) { | ||
475 | val = readl(base + USB_PORTSC1); | ||
476 | val &= ~USB_PORTSC1_PTS(~0); | ||
477 | writel(val, base + USB_PORTSC1); | ||
478 | } | ||
479 | |||
480 | return 0; | ||
481 | } | ||
482 | |||
483 | static int utmi_phy_power_off(struct tegra_usb_phy *phy) | ||
484 | { | ||
485 | unsigned long val; | ||
486 | void __iomem *base = phy->regs; | ||
487 | |||
488 | utmi_phy_clk_disable(phy); | ||
489 | |||
490 | if (phy->mode == TEGRA_USB_PHY_MODE_DEVICE) { | ||
491 | val = readl(base + USB_SUSP_CTRL); | ||
492 | val &= ~USB_WAKEUP_DEBOUNCE_COUNT(~0); | ||
493 | val |= USB_WAKE_ON_CNNT_EN_DEV | USB_WAKEUP_DEBOUNCE_COUNT(5); | ||
494 | writel(val, base + USB_SUSP_CTRL); | ||
495 | } | ||
496 | |||
497 | val = readl(base + USB_SUSP_CTRL); | ||
498 | val |= UTMIP_RESET; | ||
499 | writel(val, base + USB_SUSP_CTRL); | ||
500 | |||
501 | val = readl(base + UTMIP_BAT_CHRG_CFG0); | ||
502 | val |= UTMIP_PD_CHRG; | ||
503 | writel(val, base + UTMIP_BAT_CHRG_CFG0); | ||
504 | |||
505 | val = readl(base + UTMIP_XCVR_CFG0); | ||
506 | val |= UTMIP_FORCE_PD_POWERDOWN | UTMIP_FORCE_PD2_POWERDOWN | | ||
507 | UTMIP_FORCE_PDZI_POWERDOWN; | ||
508 | writel(val, base + UTMIP_XCVR_CFG0); | ||
509 | |||
510 | val = readl(base + UTMIP_XCVR_CFG1); | ||
511 | val |= UTMIP_FORCE_PDDISC_POWERDOWN | UTMIP_FORCE_PDCHRP_POWERDOWN | | ||
512 | UTMIP_FORCE_PDDR_POWERDOWN; | ||
513 | writel(val, base + UTMIP_XCVR_CFG1); | ||
514 | |||
515 | return utmip_pad_power_off(phy); | ||
516 | } | ||
517 | |||
518 | static void utmi_phy_preresume(struct tegra_usb_phy *phy) | ||
519 | { | ||
520 | unsigned long val; | ||
521 | void __iomem *base = phy->regs; | ||
522 | |||
523 | val = readl(base + UTMIP_TX_CFG0); | ||
524 | val |= UTMIP_HS_DISCON_DISABLE; | ||
525 | writel(val, base + UTMIP_TX_CFG0); | ||
526 | } | ||
527 | |||
528 | static void utmi_phy_postresume(struct tegra_usb_phy *phy) | ||
529 | { | ||
530 | unsigned long val; | ||
531 | void __iomem *base = phy->regs; | ||
532 | |||
533 | val = readl(base + UTMIP_TX_CFG0); | ||
534 | val &= ~UTMIP_HS_DISCON_DISABLE; | ||
535 | writel(val, base + UTMIP_TX_CFG0); | ||
536 | } | ||
537 | |||
538 | static void utmi_phy_restore_start(struct tegra_usb_phy *phy, | ||
539 | enum tegra_usb_phy_port_speed port_speed) | ||
540 | { | ||
541 | unsigned long val; | ||
542 | void __iomem *base = phy->regs; | ||
543 | |||
544 | val = readl(base + UTMIP_MISC_CFG0); | ||
545 | val &= ~UTMIP_DPDM_OBSERVE_SEL(~0); | ||
546 | if (port_speed == TEGRA_USB_PHY_PORT_SPEED_LOW) | ||
547 | val |= UTMIP_DPDM_OBSERVE_SEL_FS_K; | ||
548 | else | ||
549 | val |= UTMIP_DPDM_OBSERVE_SEL_FS_J; | ||
550 | writel(val, base + UTMIP_MISC_CFG0); | ||
551 | udelay(1); | ||
552 | |||
553 | val = readl(base + UTMIP_MISC_CFG0); | ||
554 | val |= UTMIP_DPDM_OBSERVE; | ||
555 | writel(val, base + UTMIP_MISC_CFG0); | ||
556 | udelay(10); | ||
557 | } | ||
558 | |||
559 | static void utmi_phy_restore_end(struct tegra_usb_phy *phy) | ||
560 | { | ||
561 | unsigned long val; | ||
562 | void __iomem *base = phy->regs; | ||
563 | |||
564 | val = readl(base + UTMIP_MISC_CFG0); | ||
565 | val &= ~UTMIP_DPDM_OBSERVE; | ||
566 | writel(val, base + UTMIP_MISC_CFG0); | ||
567 | udelay(10); | ||
568 | } | ||
569 | |||
570 | static int ulpi_phy_power_on(struct tegra_usb_phy *phy) | ||
571 | { | ||
572 | int ret; | ||
573 | unsigned long val; | ||
574 | void __iomem *base = phy->regs; | ||
575 | struct tegra_ulpi_config *config = phy->config; | ||
576 | |||
577 | gpio_direction_output(config->reset_gpio, 0); | ||
578 | msleep(5); | ||
579 | gpio_direction_output(config->reset_gpio, 1); | ||
580 | |||
581 | clk_prepare_enable(phy->clk); | ||
582 | msleep(1); | ||
583 | |||
584 | val = readl(base + USB_SUSP_CTRL); | ||
585 | val |= UHSIC_RESET; | ||
586 | writel(val, base + USB_SUSP_CTRL); | ||
587 | |||
588 | val = readl(base + ULPI_TIMING_CTRL_0); | ||
589 | val |= ULPI_OUTPUT_PINMUX_BYP | ULPI_CLKOUT_PINMUX_BYP; | ||
590 | writel(val, base + ULPI_TIMING_CTRL_0); | ||
591 | |||
592 | val = readl(base + USB_SUSP_CTRL); | ||
593 | val |= ULPI_PHY_ENABLE; | ||
594 | writel(val, base + USB_SUSP_CTRL); | ||
595 | |||
596 | val = 0; | ||
597 | writel(val, base + ULPI_TIMING_CTRL_1); | ||
598 | |||
599 | val |= ULPI_DATA_TRIMMER_SEL(4); | ||
600 | val |= ULPI_STPDIRNXT_TRIMMER_SEL(4); | ||
601 | val |= ULPI_DIR_TRIMMER_SEL(4); | ||
602 | writel(val, base + ULPI_TIMING_CTRL_1); | ||
603 | udelay(10); | ||
604 | |||
605 | val |= ULPI_DATA_TRIMMER_LOAD; | ||
606 | val |= ULPI_STPDIRNXT_TRIMMER_LOAD; | ||
607 | val |= ULPI_DIR_TRIMMER_LOAD; | ||
608 | writel(val, base + ULPI_TIMING_CTRL_1); | ||
609 | |||
610 | /* Fix VbusInvalid due to floating VBUS */ | ||
611 | ret = usb_phy_io_write(phy->ulpi, 0x40, 0x08); | ||
612 | if (ret) { | ||
613 | pr_err("%s: ulpi write failed\n", __func__); | ||
614 | return ret; | ||
615 | } | ||
616 | |||
617 | ret = usb_phy_io_write(phy->ulpi, 0x80, 0x0B); | ||
618 | if (ret) { | ||
619 | pr_err("%s: ulpi write failed\n", __func__); | ||
620 | return ret; | ||
621 | } | ||
622 | |||
623 | val = readl(base + USB_PORTSC1); | ||
624 | val |= USB_PORTSC1_WKOC | USB_PORTSC1_WKDS | USB_PORTSC1_WKCN; | ||
625 | writel(val, base + USB_PORTSC1); | ||
626 | |||
627 | val = readl(base + USB_SUSP_CTRL); | ||
628 | val |= USB_SUSP_CLR; | ||
629 | writel(val, base + USB_SUSP_CTRL); | ||
630 | udelay(100); | ||
631 | |||
632 | val = readl(base + USB_SUSP_CTRL); | ||
633 | val &= ~USB_SUSP_CLR; | ||
634 | writel(val, base + USB_SUSP_CTRL); | ||
635 | |||
636 | return 0; | ||
637 | } | ||
638 | |||
639 | static int ulpi_phy_power_off(struct tegra_usb_phy *phy) | ||
640 | { | ||
641 | unsigned long val; | ||
642 | void __iomem *base = phy->regs; | ||
643 | struct tegra_ulpi_config *config = phy->config; | ||
644 | |||
645 | /* Clear WKCN/WKDS/WKOC wake-on events that can cause the USB | ||
646 | * Controller to immediately bring the ULPI PHY out of low power | ||
647 | */ | ||
648 | val = readl(base + USB_PORTSC1); | ||
649 | val &= ~(USB_PORTSC1_WKOC | USB_PORTSC1_WKDS | USB_PORTSC1_WKCN); | ||
650 | writel(val, base + USB_PORTSC1); | ||
651 | |||
652 | clk_disable(phy->clk); | ||
653 | return gpio_direction_output(config->reset_gpio, 0); | ||
654 | } | ||
655 | |||
656 | static int tegra_phy_init(struct usb_phy *x) | ||
657 | { | ||
658 | struct tegra_usb_phy *phy = container_of(x, struct tegra_usb_phy, u_phy); | ||
659 | struct tegra_ulpi_config *ulpi_config; | ||
660 | int err; | ||
661 | |||
662 | if (phy_is_ulpi(phy)) { | ||
663 | ulpi_config = phy->config; | ||
664 | phy->clk = clk_get_sys(NULL, ulpi_config->clk); | ||
665 | if (IS_ERR(phy->clk)) { | ||
666 | pr_err("%s: can't get ulpi clock\n", __func__); | ||
667 | err = -ENXIO; | ||
668 | goto err1; | ||
669 | } | ||
670 | if (!gpio_is_valid(ulpi_config->reset_gpio)) | ||
671 | ulpi_config->reset_gpio = | ||
672 | of_get_named_gpio(phy->dev->of_node, | ||
673 | "nvidia,phy-reset-gpio", 0); | ||
674 | if (!gpio_is_valid(ulpi_config->reset_gpio)) { | ||
675 | pr_err("%s: invalid reset gpio: %d\n", __func__, | ||
676 | ulpi_config->reset_gpio); | ||
677 | err = -EINVAL; | ||
678 | goto err1; | ||
679 | } | ||
680 | gpio_request(ulpi_config->reset_gpio, "ulpi_phy_reset_b"); | ||
681 | gpio_direction_output(ulpi_config->reset_gpio, 0); | ||
682 | phy->ulpi = otg_ulpi_create(&ulpi_viewport_access_ops, 0); | ||
683 | phy->ulpi->io_priv = phy->regs + ULPI_VIEWPORT; | ||
684 | } else { | ||
685 | err = utmip_pad_open(phy); | ||
686 | if (err < 0) | ||
687 | goto err1; | ||
688 | } | ||
689 | return 0; | ||
690 | err1: | ||
691 | clk_disable_unprepare(phy->pll_u); | ||
692 | clk_put(phy->pll_u); | ||
693 | return err; | ||
694 | } | ||
695 | |||
696 | static void tegra_usb_phy_close(struct usb_phy *x) | ||
697 | { | ||
698 | struct tegra_usb_phy *phy = container_of(x, struct tegra_usb_phy, u_phy); | ||
699 | |||
700 | if (phy_is_ulpi(phy)) | ||
701 | clk_put(phy->clk); | ||
702 | else | ||
703 | utmip_pad_close(phy); | ||
704 | clk_disable_unprepare(phy->pll_u); | ||
705 | clk_put(phy->pll_u); | ||
706 | kfree(phy); | ||
707 | } | ||
708 | |||
709 | static int tegra_usb_phy_power_on(struct tegra_usb_phy *phy) | ||
710 | { | ||
711 | if (phy_is_ulpi(phy)) | ||
712 | return ulpi_phy_power_on(phy); | ||
713 | else | ||
714 | return utmi_phy_power_on(phy); | ||
715 | } | ||
716 | |||
717 | static int tegra_usb_phy_power_off(struct tegra_usb_phy *phy) | ||
718 | { | ||
719 | if (phy_is_ulpi(phy)) | ||
720 | return ulpi_phy_power_off(phy); | ||
721 | else | ||
722 | return utmi_phy_power_off(phy); | ||
723 | } | ||
724 | |||
725 | static int tegra_usb_phy_suspend(struct usb_phy *x, int suspend) | ||
726 | { | ||
727 | struct tegra_usb_phy *phy = container_of(x, struct tegra_usb_phy, u_phy); | ||
728 | if (suspend) | ||
729 | return tegra_usb_phy_power_off(phy); | ||
730 | else | ||
731 | return tegra_usb_phy_power_on(phy); | ||
732 | } | ||
733 | |||
734 | struct tegra_usb_phy *tegra_usb_phy_open(struct device *dev, int instance, | ||
735 | void __iomem *regs, void *config, enum tegra_usb_phy_mode phy_mode) | ||
736 | { | ||
737 | struct tegra_usb_phy *phy; | ||
738 | unsigned long parent_rate; | ||
739 | int i; | ||
740 | int err; | ||
741 | |||
742 | phy = kmalloc(sizeof(struct tegra_usb_phy), GFP_KERNEL); | ||
743 | if (!phy) | ||
744 | return ERR_PTR(-ENOMEM); | ||
745 | |||
746 | phy->instance = instance; | ||
747 | phy->regs = regs; | ||
748 | phy->config = config; | ||
749 | phy->mode = phy_mode; | ||
750 | phy->dev = dev; | ||
751 | |||
752 | if (!phy->config) { | ||
753 | if (phy_is_ulpi(phy)) { | ||
754 | pr_err("%s: ulpi phy configuration missing", __func__); | ||
755 | err = -EINVAL; | ||
756 | goto err0; | ||
757 | } else { | ||
758 | phy->config = &utmip_default[instance]; | ||
759 | } | ||
760 | } | ||
761 | |||
762 | phy->pll_u = clk_get_sys(NULL, "pll_u"); | ||
763 | if (IS_ERR(phy->pll_u)) { | ||
764 | pr_err("Can't get pll_u clock\n"); | ||
765 | err = PTR_ERR(phy->pll_u); | ||
766 | goto err0; | ||
767 | } | ||
768 | clk_prepare_enable(phy->pll_u); | ||
769 | |||
770 | parent_rate = clk_get_rate(clk_get_parent(phy->pll_u)); | ||
771 | for (i = 0; i < ARRAY_SIZE(tegra_freq_table); i++) { | ||
772 | if (tegra_freq_table[i].freq == parent_rate) { | ||
773 | phy->freq = &tegra_freq_table[i]; | ||
774 | break; | ||
775 | } | ||
776 | } | ||
777 | if (!phy->freq) { | ||
778 | pr_err("invalid pll_u parent rate %ld\n", parent_rate); | ||
779 | err = -EINVAL; | ||
780 | goto err1; | ||
781 | } | ||
782 | |||
783 | phy->u_phy.init = tegra_phy_init; | ||
784 | phy->u_phy.shutdown = tegra_usb_phy_close; | ||
785 | phy->u_phy.set_suspend = tegra_usb_phy_suspend; | ||
786 | |||
787 | return phy; | ||
788 | |||
789 | err1: | ||
790 | clk_disable_unprepare(phy->pll_u); | ||
791 | clk_put(phy->pll_u); | ||
792 | err0: | ||
793 | kfree(phy); | ||
794 | return ERR_PTR(err); | ||
795 | } | ||
796 | EXPORT_SYMBOL_GPL(tegra_usb_phy_open); | ||
797 | |||
798 | void tegra_usb_phy_preresume(struct tegra_usb_phy *phy) | ||
799 | { | ||
800 | if (!phy_is_ulpi(phy)) | ||
801 | utmi_phy_preresume(phy); | ||
802 | } | ||
803 | EXPORT_SYMBOL_GPL(tegra_usb_phy_preresume); | ||
804 | |||
805 | void tegra_usb_phy_postresume(struct tegra_usb_phy *phy) | ||
806 | { | ||
807 | if (!phy_is_ulpi(phy)) | ||
808 | utmi_phy_postresume(phy); | ||
809 | } | ||
810 | EXPORT_SYMBOL_GPL(tegra_usb_phy_postresume); | ||
811 | |||
812 | void tegra_ehci_phy_restore_start(struct tegra_usb_phy *phy, | ||
813 | enum tegra_usb_phy_port_speed port_speed) | ||
814 | { | ||
815 | if (!phy_is_ulpi(phy)) | ||
816 | utmi_phy_restore_start(phy, port_speed); | ||
817 | } | ||
818 | EXPORT_SYMBOL_GPL(tegra_ehci_phy_restore_start); | ||
819 | |||
820 | void tegra_ehci_phy_restore_end(struct tegra_usb_phy *phy) | ||
821 | { | ||
822 | if (!phy_is_ulpi(phy)) | ||
823 | utmi_phy_restore_end(phy); | ||
824 | } | ||
825 | EXPORT_SYMBOL_GPL(tegra_ehci_phy_restore_end); | ||
826 | |||
827 | void tegra_usb_phy_clk_disable(struct tegra_usb_phy *phy) | ||
828 | { | ||
829 | if (!phy_is_ulpi(phy)) | ||
830 | utmi_phy_clk_disable(phy); | ||
831 | } | ||
832 | EXPORT_SYMBOL_GPL(tegra_usb_phy_clk_disable); | ||
833 | |||
834 | void tegra_usb_phy_clk_enable(struct tegra_usb_phy *phy) | ||
835 | { | ||
836 | if (!phy_is_ulpi(phy)) | ||
837 | utmi_phy_clk_enable(phy); | ||
838 | } | ||
839 | EXPORT_SYMBOL_GPL(tegra_usb_phy_clk_enable); | ||
diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c index 681da06170c2..072edc1cc55f 100644 --- a/drivers/usb/renesas_usbhs/common.c +++ b/drivers/usb/renesas_usbhs/common.c | |||
@@ -432,17 +432,16 @@ static int usbhs_probe(struct platform_device *pdev) | |||
432 | } | 432 | } |
433 | 433 | ||
434 | /* usb private data */ | 434 | /* usb private data */ |
435 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); | 435 | priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); |
436 | if (!priv) { | 436 | if (!priv) { |
437 | dev_err(&pdev->dev, "Could not allocate priv\n"); | 437 | dev_err(&pdev->dev, "Could not allocate priv\n"); |
438 | return -ENOMEM; | 438 | return -ENOMEM; |
439 | } | 439 | } |
440 | 440 | ||
441 | priv->base = ioremap_nocache(res->start, resource_size(res)); | 441 | priv->base = devm_request_and_ioremap(&pdev->dev, res); |
442 | if (!priv->base) { | 442 | if (!priv->base) { |
443 | dev_err(&pdev->dev, "ioremap error.\n"); | 443 | dev_err(&pdev->dev, "ioremap error.\n"); |
444 | ret = -ENOMEM; | 444 | return -ENOMEM; |
445 | goto probe_end_kfree; | ||
446 | } | 445 | } |
447 | 446 | ||
448 | /* | 447 | /* |
@@ -485,7 +484,7 @@ static int usbhs_probe(struct platform_device *pdev) | |||
485 | /* call pipe and module init */ | 484 | /* call pipe and module init */ |
486 | ret = usbhs_pipe_probe(priv); | 485 | ret = usbhs_pipe_probe(priv); |
487 | if (ret < 0) | 486 | if (ret < 0) |
488 | goto probe_end_iounmap; | 487 | return ret; |
489 | 488 | ||
490 | ret = usbhs_fifo_probe(priv); | 489 | ret = usbhs_fifo_probe(priv); |
491 | if (ret < 0) | 490 | if (ret < 0) |
@@ -546,10 +545,6 @@ probe_end_fifo_exit: | |||
546 | usbhs_fifo_remove(priv); | 545 | usbhs_fifo_remove(priv); |
547 | probe_end_pipe_exit: | 546 | probe_end_pipe_exit: |
548 | usbhs_pipe_remove(priv); | 547 | usbhs_pipe_remove(priv); |
549 | probe_end_iounmap: | ||
550 | iounmap(priv->base); | ||
551 | probe_end_kfree: | ||
552 | kfree(priv); | ||
553 | 548 | ||
554 | dev_info(&pdev->dev, "probe failed\n"); | 549 | dev_info(&pdev->dev, "probe failed\n"); |
555 | 550 | ||
@@ -576,8 +571,6 @@ static int __devexit usbhs_remove(struct platform_device *pdev) | |||
576 | usbhs_mod_remove(priv); | 571 | usbhs_mod_remove(priv); |
577 | usbhs_fifo_remove(priv); | 572 | usbhs_fifo_remove(priv); |
578 | usbhs_pipe_remove(priv); | 573 | usbhs_pipe_remove(priv); |
579 | iounmap(priv->base); | ||
580 | kfree(priv); | ||
581 | 574 | ||
582 | return 0; | 575 | return 0; |
583 | } | 576 | } |
diff --git a/drivers/usb/renesas_usbhs/mod.c b/drivers/usb/renesas_usbhs/mod.c index 82a628f96c03..35c5208f3249 100644 --- a/drivers/usb/renesas_usbhs/mod.c +++ b/drivers/usb/renesas_usbhs/mod.c | |||
@@ -209,14 +209,18 @@ int usbhs_status_get_ctrl_stage(struct usbhs_irq_state *irq_state) | |||
209 | return (int)irq_state->intsts0 & CTSQ_MASK; | 209 | return (int)irq_state->intsts0 & CTSQ_MASK; |
210 | } | 210 | } |
211 | 211 | ||
212 | static void usbhs_status_get_each_irq(struct usbhs_priv *priv, | 212 | static int usbhs_status_get_each_irq(struct usbhs_priv *priv, |
213 | struct usbhs_irq_state *state) | 213 | struct usbhs_irq_state *state) |
214 | { | 214 | { |
215 | struct usbhs_mod *mod = usbhs_mod_get_current(priv); | 215 | struct usbhs_mod *mod = usbhs_mod_get_current(priv); |
216 | u16 intenb0, intenb1; | ||
216 | 217 | ||
217 | state->intsts0 = usbhs_read(priv, INTSTS0); | 218 | state->intsts0 = usbhs_read(priv, INTSTS0); |
218 | state->intsts1 = usbhs_read(priv, INTSTS1); | 219 | state->intsts1 = usbhs_read(priv, INTSTS1); |
219 | 220 | ||
221 | intenb0 = usbhs_read(priv, INTENB0); | ||
222 | intenb1 = usbhs_read(priv, INTENB1); | ||
223 | |||
220 | /* mask */ | 224 | /* mask */ |
221 | if (mod) { | 225 | if (mod) { |
222 | state->brdysts = usbhs_read(priv, BRDYSTS); | 226 | state->brdysts = usbhs_read(priv, BRDYSTS); |
@@ -226,6 +230,20 @@ static void usbhs_status_get_each_irq(struct usbhs_priv *priv, | |||
226 | state->bempsts &= mod->irq_bempsts; | 230 | state->bempsts &= mod->irq_bempsts; |
227 | state->brdysts &= mod->irq_brdysts; | 231 | state->brdysts &= mod->irq_brdysts; |
228 | } | 232 | } |
233 | |||
234 | /* | ||
235 | * Check whether the irq enable registers and the irq status are set | ||
236 | * when IRQF_SHARED is set. | ||
237 | */ | ||
238 | if (priv->irqflags & IRQF_SHARED) { | ||
239 | if (!(intenb0 & state->intsts0) && | ||
240 | !(intenb1 & state->intsts1) && | ||
241 | !(state->bempsts) && | ||
242 | !(state->brdysts)) | ||
243 | return -EIO; | ||
244 | } | ||
245 | |||
246 | return 0; | ||
229 | } | 247 | } |
230 | 248 | ||
231 | /* | 249 | /* |
@@ -238,7 +256,8 @@ static irqreturn_t usbhs_interrupt(int irq, void *data) | |||
238 | struct usbhs_priv *priv = data; | 256 | struct usbhs_priv *priv = data; |
239 | struct usbhs_irq_state irq_state; | 257 | struct usbhs_irq_state irq_state; |
240 | 258 | ||
241 | usbhs_status_get_each_irq(priv, &irq_state); | 259 | if (usbhs_status_get_each_irq(priv, &irq_state) < 0) |
260 | return IRQ_NONE; | ||
242 | 261 | ||
243 | /* | 262 | /* |
244 | * clear interrupt | 263 | * clear interrupt |
diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig index 325d2910f9f9..76f462241738 100644 --- a/drivers/usb/serial/Kconfig +++ b/drivers/usb/serial/Kconfig | |||
@@ -42,11 +42,6 @@ config USB_SERIAL_CONSOLE | |||
42 | 42 | ||
43 | If unsure, say N. | 43 | If unsure, say N. |
44 | 44 | ||
45 | config USB_EZUSB | ||
46 | bool "Functions for loading firmware on EZUSB chips" | ||
47 | help | ||
48 | Say Y here if you need EZUSB device support. | ||
49 | |||
50 | config USB_SERIAL_GENERIC | 45 | config USB_SERIAL_GENERIC |
51 | bool "USB Generic Serial Driver" | 46 | bool "USB Generic Serial Driver" |
52 | help | 47 | help |
@@ -94,7 +89,7 @@ config USB_SERIAL_CH341 | |||
94 | 89 | ||
95 | config USB_SERIAL_WHITEHEAT | 90 | config USB_SERIAL_WHITEHEAT |
96 | tristate "USB ConnectTech WhiteHEAT Serial Driver" | 91 | tristate "USB ConnectTech WhiteHEAT Serial Driver" |
97 | select USB_EZUSB | 92 | select USB_EZUSB_FX2 |
98 | help | 93 | help |
99 | Say Y here if you want to use a ConnectTech WhiteHEAT 4 port | 94 | Say Y here if you want to use a ConnectTech WhiteHEAT 4 port |
100 | USB to serial converter device. | 95 | USB to serial converter device. |
@@ -281,7 +276,7 @@ config USB_SERIAL_IUU | |||
281 | 276 | ||
282 | config USB_SERIAL_KEYSPAN_PDA | 277 | config USB_SERIAL_KEYSPAN_PDA |
283 | tristate "USB Keyspan PDA Single Port Serial Driver" | 278 | tristate "USB Keyspan PDA Single Port Serial Driver" |
284 | select USB_EZUSB | 279 | select USB_EZUSB_FX2 |
285 | help | 280 | help |
286 | Say Y here if you want to use a Keyspan PDA single port USB to | 281 | Say Y here if you want to use a Keyspan PDA single port USB to |
287 | serial converter device. This driver makes use of firmware | 282 | serial converter device. This driver makes use of firmware |
@@ -292,7 +287,7 @@ config USB_SERIAL_KEYSPAN_PDA | |||
292 | 287 | ||
293 | config USB_SERIAL_KEYSPAN | 288 | config USB_SERIAL_KEYSPAN |
294 | tristate "USB Keyspan USA-xxx Serial Driver" | 289 | tristate "USB Keyspan USA-xxx Serial Driver" |
295 | select USB_EZUSB | 290 | select USB_EZUSB_FX2 |
296 | ---help--- | 291 | ---help--- |
297 | Say Y here if you want to use Keyspan USB to serial converter | 292 | Say Y here if you want to use Keyspan USB to serial converter |
298 | devices. This driver makes use of Keyspan's official firmware | 293 | devices. This driver makes use of Keyspan's official firmware |
@@ -596,7 +591,7 @@ config USB_SERIAL_CYBERJACK | |||
596 | 591 | ||
597 | config USB_SERIAL_XIRCOM | 592 | config USB_SERIAL_XIRCOM |
598 | tristate "USB Xircom / Entregra Single Port Serial Driver" | 593 | tristate "USB Xircom / Entregra Single Port Serial Driver" |
599 | select USB_EZUSB | 594 | select USB_EZUSB_FX2 |
600 | help | 595 | help |
601 | Say Y here if you want to use a Xircom or Entregra single port USB to | 596 | Say Y here if you want to use a Xircom or Entregra single port USB to |
602 | serial converter device. This driver makes use of firmware | 597 | serial converter device. This driver makes use of firmware |
@@ -660,6 +655,14 @@ config USB_SERIAL_ZIO | |||
660 | To compile this driver as a module, choose M here: the | 655 | To compile this driver as a module, choose M here: the |
661 | module will be called zio. | 656 | module will be called zio. |
662 | 657 | ||
658 | config USB_SERIAL_ZTE | ||
659 | tristate "ZTE USB serial driver" | ||
660 | help | ||
661 | Say Y here if you want to use a ZTE USB to serial device. | ||
662 | |||
663 | To compile this driver as a module, choose M here: the | ||
664 | module will be called zte. | ||
665 | |||
663 | config USB_SERIAL_SSU100 | 666 | config USB_SERIAL_SSU100 |
664 | tristate "USB Quatech SSU-100 Single Port Serial Driver" | 667 | tristate "USB Quatech SSU-100 Single Port Serial Driver" |
665 | help | 668 | help |
diff --git a/drivers/usb/serial/Makefile b/drivers/usb/serial/Makefile index 1dc483a8bfc7..3b3e7308d476 100644 --- a/drivers/usb/serial/Makefile +++ b/drivers/usb/serial/Makefile | |||
@@ -9,7 +9,6 @@ obj-$(CONFIG_USB_SERIAL) += usbserial.o | |||
9 | usbserial-y := usb-serial.o generic.o bus.o | 9 | usbserial-y := usb-serial.o generic.o bus.o |
10 | 10 | ||
11 | usbserial-$(CONFIG_USB_SERIAL_CONSOLE) += console.o | 11 | usbserial-$(CONFIG_USB_SERIAL_CONSOLE) += console.o |
12 | usbserial-$(CONFIG_USB_EZUSB) += ezusb.o | ||
13 | 12 | ||
14 | obj-$(CONFIG_USB_SERIAL_AIRCABLE) += aircable.o | 13 | obj-$(CONFIG_USB_SERIAL_AIRCABLE) += aircable.o |
15 | obj-$(CONFIG_USB_SERIAL_ARK3116) += ark3116.o | 14 | obj-$(CONFIG_USB_SERIAL_ARK3116) += ark3116.o |
@@ -63,3 +62,4 @@ obj-$(CONFIG_USB_SERIAL_WHITEHEAT) += whiteheat.o | |||
63 | obj-$(CONFIG_USB_SERIAL_XIRCOM) += keyspan_pda.o | 62 | obj-$(CONFIG_USB_SERIAL_XIRCOM) += keyspan_pda.o |
64 | obj-$(CONFIG_USB_SERIAL_VIVOPAY_SERIAL) += vivopay-serial.o | 63 | obj-$(CONFIG_USB_SERIAL_VIVOPAY_SERIAL) += vivopay-serial.o |
65 | obj-$(CONFIG_USB_SERIAL_ZIO) += zio.o | 64 | obj-$(CONFIG_USB_SERIAL_ZIO) += zio.o |
65 | obj-$(CONFIG_USB_SERIAL_ZTE) += zte_ev.o | ||
diff --git a/drivers/usb/serial/aircable.c b/drivers/usb/serial/aircable.c index d634e6635632..54e1bb6372e7 100644 --- a/drivers/usb/serial/aircable.c +++ b/drivers/usb/serial/aircable.c | |||
@@ -52,8 +52,6 @@ | |||
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 bool debug; | ||
56 | |||
57 | /* Vendor and Product ID */ | 55 | /* Vendor and Product ID */ |
58 | #define AIRCABLE_VID 0x16CA | 56 | #define AIRCABLE_VID 0x16CA |
59 | #define AIRCABLE_USB_PID 0x1502 | 57 | #define AIRCABLE_USB_PID 0x1502 |
@@ -196,6 +194,3 @@ MODULE_AUTHOR(DRIVER_AUTHOR); | |||
196 | MODULE_DESCRIPTION(DRIVER_DESC); | 194 | MODULE_DESCRIPTION(DRIVER_DESC); |
197 | MODULE_VERSION(DRIVER_VERSION); | 195 | MODULE_VERSION(DRIVER_VERSION); |
198 | MODULE_LICENSE("GPL"); | 196 | MODULE_LICENSE("GPL"); |
199 | |||
200 | module_param(debug, bool, S_IRUGO | S_IWUSR); | ||
201 | MODULE_PARM_DESC(debug, "Debug enabled or not"); | ||
diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c index 3b98fb733362..cf2522c397d3 100644 --- a/drivers/usb/serial/ark3116.c +++ b/drivers/usb/serial/ark3116.c | |||
@@ -37,7 +37,6 @@ | |||
37 | #include <linux/mutex.h> | 37 | #include <linux/mutex.h> |
38 | #include <linux/spinlock.h> | 38 | #include <linux/spinlock.h> |
39 | 39 | ||
40 | static bool debug; | ||
41 | /* | 40 | /* |
42 | * Version information | 41 | * Version information |
43 | */ | 42 | */ |
@@ -650,8 +649,7 @@ static void ark3116_read_int_callback(struct urb *urb) | |||
650 | /* | 649 | /* |
651 | * Not sure what this data meant... | 650 | * Not sure what this data meant... |
652 | */ | 651 | */ |
653 | usb_serial_debug_data(debug, &port->dev, | 652 | usb_serial_debug_data(&port->dev, __func__, |
654 | __func__, | ||
655 | urb->actual_length, | 653 | urb->actual_length, |
656 | urb->transfer_buffer); | 654 | urb->transfer_buffer); |
657 | break; | 655 | break; |
@@ -750,9 +748,6 @@ MODULE_LICENSE("GPL"); | |||
750 | MODULE_AUTHOR(DRIVER_AUTHOR); | 748 | MODULE_AUTHOR(DRIVER_AUTHOR); |
751 | MODULE_DESCRIPTION(DRIVER_DESC); | 749 | MODULE_DESCRIPTION(DRIVER_DESC); |
752 | 750 | ||
753 | module_param(debug, bool, S_IRUGO | S_IWUSR); | ||
754 | MODULE_PARM_DESC(debug, "Enable debug"); | ||
755 | |||
756 | /* | 751 | /* |
757 | * The following describes what I learned from studying the old | 752 | * The following describes what I learned from studying the old |
758 | * ark3116.c driver, disassembling the windows driver, and some lucky | 753 | * ark3116.c driver, disassembling the windows driver, and some lucky |
diff --git a/drivers/usb/serial/belkin_sa.c b/drivers/usb/serial/belkin_sa.c index a46df73ee96e..99449424193f 100644 --- a/drivers/usb/serial/belkin_sa.c +++ b/drivers/usb/serial/belkin_sa.c | |||
@@ -37,8 +37,6 @@ | |||
37 | #include <linux/usb/serial.h> | 37 | #include <linux/usb/serial.h> |
38 | #include "belkin_sa.h" | 38 | #include "belkin_sa.h" |
39 | 39 | ||
40 | static bool debug; | ||
41 | |||
42 | /* | 40 | /* |
43 | * Version Information | 41 | * Version Information |
44 | */ | 42 | */ |
@@ -206,8 +204,7 @@ static void belkin_sa_read_int_callback(struct urb *urb) | |||
206 | goto exit; | 204 | goto exit; |
207 | } | 205 | } |
208 | 206 | ||
209 | usb_serial_debug_data(debug, &port->dev, __func__, | 207 | usb_serial_debug_data(&port->dev, __func__, urb->actual_length, data); |
210 | urb->actual_length, data); | ||
211 | 208 | ||
212 | /* Handle known interrupt data */ | 209 | /* Handle known interrupt data */ |
213 | /* ignore data[0] and data[1] */ | 210 | /* ignore data[0] and data[1] */ |
@@ -515,6 +512,3 @@ MODULE_AUTHOR(DRIVER_AUTHOR); | |||
515 | MODULE_DESCRIPTION(DRIVER_DESC); | 512 | MODULE_DESCRIPTION(DRIVER_DESC); |
516 | MODULE_VERSION(DRIVER_VERSION); | 513 | MODULE_VERSION(DRIVER_VERSION); |
517 | MODULE_LICENSE("GPL"); | 514 | MODULE_LICENSE("GPL"); |
518 | |||
519 | module_param(debug, bool, S_IRUGO | S_IWUSR); | ||
520 | MODULE_PARM_DESC(debug, "Debug enabled or not"); | ||
diff --git a/drivers/usb/serial/ch341.c b/drivers/usb/serial/ch341.c index cabd1b15ddce..e9c7046ae355 100644 --- a/drivers/usb/serial/ch341.c +++ b/drivers/usb/serial/ch341.c | |||
@@ -70,8 +70,6 @@ | |||
70 | #define CH341_NBREAK_BITS_REG2 0x40 | 70 | #define CH341_NBREAK_BITS_REG2 0x40 |
71 | 71 | ||
72 | 72 | ||
73 | static bool debug; | ||
74 | |||
75 | static const struct usb_device_id id_table[] = { | 73 | static const struct usb_device_id id_table[] = { |
76 | { USB_DEVICE(0x4348, 0x5523) }, | 74 | { USB_DEVICE(0x4348, 0x5523) }, |
77 | { USB_DEVICE(0x1a86, 0x7523) }, | 75 | { USB_DEVICE(0x1a86, 0x7523) }, |
@@ -93,8 +91,9 @@ static int ch341_control_out(struct usb_device *dev, u8 request, | |||
93 | u16 value, u16 index) | 91 | u16 value, u16 index) |
94 | { | 92 | { |
95 | int r; | 93 | int r; |
96 | dbg("ch341_control_out(%02x,%02x,%04x,%04x)", USB_DIR_OUT|0x40, | 94 | |
97 | (int)request, (int)value, (int)index); | 95 | dev_dbg(&dev->dev, "ch341_control_out(%02x,%02x,%04x,%04x)\n", |
96 | USB_DIR_OUT|0x40, (int)request, (int)value, (int)index); | ||
98 | 97 | ||
99 | r = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), request, | 98 | r = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), request, |
100 | USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, | 99 | USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, |
@@ -108,8 +107,10 @@ static int ch341_control_in(struct usb_device *dev, | |||
108 | char *buf, unsigned bufsize) | 107 | char *buf, unsigned bufsize) |
109 | { | 108 | { |
110 | int r; | 109 | int r; |
111 | dbg("ch341_control_in(%02x,%02x,%04x,%04x,%p,%u)", USB_DIR_IN|0x40, | 110 | |
112 | (int)request, (int)value, (int)index, buf, (int)bufsize); | 111 | dev_dbg(&dev->dev, "ch341_control_in(%02x,%02x,%04x,%04x,%p,%u)\n", |
112 | USB_DIR_IN|0x40, (int)request, (int)value, (int)index, buf, | ||
113 | (int)bufsize); | ||
113 | 114 | ||
114 | r = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), request, | 115 | r = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), request, |
115 | USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, | 116 | USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, |
@@ -320,7 +321,7 @@ static int ch341_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
320 | if (r) | 321 | if (r) |
321 | goto out; | 322 | goto out; |
322 | 323 | ||
323 | dbg("%s - submitting interrupt urb", __func__); | 324 | dev_dbg(&port->dev, "%s - submitting interrupt urb", __func__); |
324 | r = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); | 325 | r = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); |
325 | if (r) { | 326 | if (r) { |
326 | dev_err(&port->dev, "%s - failed submitting interrupt urb," | 327 | dev_err(&port->dev, "%s - failed submitting interrupt urb," |
@@ -390,19 +391,19 @@ static void ch341_break_ctl(struct tty_struct *tty, int break_state) | |||
390 | __func__, r); | 391 | __func__, r); |
391 | goto out; | 392 | goto out; |
392 | } | 393 | } |
393 | dbg("%s - initial ch341 break register contents - reg1: %x, reg2: %x", | 394 | dev_dbg(&port->dev, "%s - initial ch341 break register contents - reg1: %x, reg2: %x\n", |
394 | __func__, break_reg[0], break_reg[1]); | 395 | __func__, break_reg[0], break_reg[1]); |
395 | if (break_state != 0) { | 396 | if (break_state != 0) { |
396 | dbg("%s - Enter break state requested", __func__); | 397 | dev_dbg(&port->dev, "%s - Enter break state requested\n", __func__); |
397 | break_reg[0] &= ~CH341_NBREAK_BITS_REG1; | 398 | break_reg[0] &= ~CH341_NBREAK_BITS_REG1; |
398 | break_reg[1] &= ~CH341_NBREAK_BITS_REG2; | 399 | break_reg[1] &= ~CH341_NBREAK_BITS_REG2; |
399 | } else { | 400 | } else { |
400 | dbg("%s - Leave break state requested", __func__); | 401 | dev_dbg(&port->dev, "%s - Leave break state requested\n", __func__); |
401 | break_reg[0] |= CH341_NBREAK_BITS_REG1; | 402 | break_reg[0] |= CH341_NBREAK_BITS_REG1; |
402 | break_reg[1] |= CH341_NBREAK_BITS_REG2; | 403 | break_reg[1] |= CH341_NBREAK_BITS_REG2; |
403 | } | 404 | } |
404 | dbg("%s - New ch341 break register contents - reg1: %x, reg2: %x", | 405 | dev_dbg(&port->dev, "%s - New ch341 break register contents - reg1: %x, reg2: %x\n", |
405 | __func__, break_reg[0], break_reg[1]); | 406 | __func__, break_reg[0], break_reg[1]); |
406 | reg_contents = get_unaligned_le16(break_reg); | 407 | reg_contents = get_unaligned_le16(break_reg); |
407 | r = ch341_control_out(port->serial->dev, CH341_REQ_WRITE_REG, | 408 | r = ch341_control_out(port->serial->dev, CH341_REQ_WRITE_REG, |
408 | ch341_break_reg, reg_contents); | 409 | ch341_break_reg, reg_contents); |
@@ -451,16 +452,16 @@ static void ch341_read_int_callback(struct urb *urb) | |||
451 | case -ENOENT: | 452 | case -ENOENT: |
452 | case -ESHUTDOWN: | 453 | case -ESHUTDOWN: |
453 | /* this urb is terminated, clean up */ | 454 | /* this urb is terminated, clean up */ |
454 | dbg("%s - urb shutting down with status: %d", __func__, | 455 | dev_dbg(&urb->dev->dev, "%s - urb shutting down with status: %d\n", |
455 | urb->status); | 456 | __func__, urb->status); |
456 | return; | 457 | return; |
457 | default: | 458 | default: |
458 | dbg("%s - nonzero urb status received: %d", __func__, | 459 | dev_dbg(&urb->dev->dev, "%s - nonzero urb status received: %d\n", |
459 | urb->status); | 460 | __func__, urb->status); |
460 | goto exit; | 461 | goto exit; |
461 | } | 462 | } |
462 | 463 | ||
463 | usb_serial_debug_data(debug, &port->dev, __func__, | 464 | usb_serial_debug_data(&port->dev, __func__, |
464 | urb->actual_length, urb->transfer_buffer); | 465 | urb->actual_length, urb->transfer_buffer); |
465 | 466 | ||
466 | if (actual_length >= 4) { | 467 | if (actual_length >= 4) { |
@@ -536,15 +537,16 @@ static int ch341_ioctl(struct tty_struct *tty, | |||
536 | unsigned int cmd, unsigned long arg) | 537 | unsigned int cmd, unsigned long arg) |
537 | { | 538 | { |
538 | struct usb_serial_port *port = tty->driver_data; | 539 | struct usb_serial_port *port = tty->driver_data; |
539 | dbg("%s (%d) cmd = 0x%04x", __func__, port->number, cmd); | 540 | |
541 | dev_dbg(&port->dev, "%s (%d) cmd = 0x%04x\n", __func__, port->number, cmd); | ||
540 | 542 | ||
541 | switch (cmd) { | 543 | switch (cmd) { |
542 | case TIOCMIWAIT: | 544 | case TIOCMIWAIT: |
543 | dbg("%s (%d) TIOCMIWAIT", __func__, port->number); | 545 | dev_dbg(&port->dev, "%s (%d) TIOCMIWAIT\n", __func__, port->number); |
544 | return wait_modem_info(port, arg); | 546 | return wait_modem_info(port, arg); |
545 | 547 | ||
546 | default: | 548 | default: |
547 | dbg("%s not supported = 0x%04x", __func__, cmd); | 549 | dev_dbg(&port->dev, "%s not supported = 0x%04x\n", __func__, cmd); |
548 | break; | 550 | break; |
549 | } | 551 | } |
550 | 552 | ||
@@ -572,7 +574,7 @@ static int ch341_tiocmget(struct tty_struct *tty) | |||
572 | | ((status & CH341_BIT_RI) ? TIOCM_RI : 0) | 574 | | ((status & CH341_BIT_RI) ? TIOCM_RI : 0) |
573 | | ((status & CH341_BIT_DCD) ? TIOCM_CD : 0); | 575 | | ((status & CH341_BIT_DCD) ? TIOCM_CD : 0); |
574 | 576 | ||
575 | dbg("%s - result = %x", __func__, result); | 577 | dev_dbg(&port->dev, "%s - result = %x\n", __func__, result); |
576 | 578 | ||
577 | return result; | 579 | return result; |
578 | } | 580 | } |
@@ -617,6 +619,3 @@ static struct usb_serial_driver * const serial_drivers[] = { | |||
617 | module_usb_serial_driver(serial_drivers, id_table); | 619 | module_usb_serial_driver(serial_drivers, id_table); |
618 | 620 | ||
619 | MODULE_LICENSE("GPL"); | 621 | MODULE_LICENSE("GPL"); |
620 | |||
621 | module_param(debug, bool, S_IRUGO | S_IWUSR); | ||
622 | MODULE_PARM_DESC(debug, "Debug enabled or not"); | ||
diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c index 9a564286bfd7..5f3bcd31e204 100644 --- a/drivers/usb/serial/console.c +++ b/drivers/usb/serial/console.c | |||
@@ -11,6 +11,8 @@ | |||
11 | * | 11 | * |
12 | */ | 12 | */ |
13 | 13 | ||
14 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
15 | |||
14 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
15 | #include <linux/init.h> | 17 | #include <linux/init.h> |
16 | #include <linux/slab.h> | 18 | #include <linux/slab.h> |
@@ -20,8 +22,6 @@ | |||
20 | #include <linux/usb.h> | 22 | #include <linux/usb.h> |
21 | #include <linux/usb/serial.h> | 23 | #include <linux/usb/serial.h> |
22 | 24 | ||
23 | static int debug; | ||
24 | |||
25 | struct usbcons_info { | 25 | struct usbcons_info { |
26 | int magic; | 26 | int magic; |
27 | int break_flag; | 27 | int break_flag; |
@@ -68,8 +68,6 @@ static int usb_console_setup(struct console *co, char *options) | |||
68 | struct tty_struct *tty = NULL; | 68 | struct tty_struct *tty = NULL; |
69 | struct ktermios dummy; | 69 | struct ktermios dummy; |
70 | 70 | ||
71 | dbg("%s", __func__); | ||
72 | |||
73 | if (options) { | 71 | if (options) { |
74 | baud = simple_strtoul(options, NULL, 10); | 72 | baud = simple_strtoul(options, NULL, 10); |
75 | s = options; | 73 | s = options; |
@@ -113,8 +111,7 @@ static int usb_console_setup(struct console *co, char *options) | |||
113 | serial = usb_serial_get_by_index(co->index); | 111 | serial = usb_serial_get_by_index(co->index); |
114 | if (serial == NULL) { | 112 | if (serial == NULL) { |
115 | /* no device is connected yet, sorry :( */ | 113 | /* no device is connected yet, sorry :( */ |
116 | printk(KERN_ERR "No USB device connected to ttyUSB%i\n", | 114 | pr_err("No USB device connected to ttyUSB%i\n", co->index); |
117 | co->index); | ||
118 | return -ENODEV; | 115 | return -ENODEV; |
119 | } | 116 | } |
120 | 117 | ||
@@ -213,10 +210,10 @@ static void usb_console_write(struct console *co, | |||
213 | if (count == 0) | 210 | if (count == 0) |
214 | return; | 211 | return; |
215 | 212 | ||
216 | dbg("%s - port %d, %d byte(s)", __func__, port->number, count); | 213 | pr_debug("%s - port %d, %d byte(s)\n", __func__, port->number, count); |
217 | 214 | ||
218 | if (!port->port.console) { | 215 | if (!port->port.console) { |
219 | dbg("%s - port not opened", __func__); | 216 | pr_debug("%s - port not opened\n", __func__); |
220 | return; | 217 | return; |
221 | } | 218 | } |
222 | 219 | ||
@@ -237,7 +234,7 @@ static void usb_console_write(struct console *co, | |||
237 | retval = serial->type->write(NULL, port, buf, i); | 234 | retval = serial->type->write(NULL, port, buf, i); |
238 | else | 235 | else |
239 | retval = usb_serial_generic_write(NULL, port, buf, i); | 236 | retval = usb_serial_generic_write(NULL, port, buf, i); |
240 | dbg("%s - return value : %d", __func__, retval); | 237 | pr_debug("%s - return value : %d\n", __func__, retval); |
241 | if (lf) { | 238 | if (lf) { |
242 | /* append CR after LF */ | 239 | /* append CR after LF */ |
243 | unsigned char cr = 13; | 240 | unsigned char cr = 13; |
@@ -247,7 +244,7 @@ static void usb_console_write(struct console *co, | |||
247 | else | 244 | else |
248 | retval = usb_serial_generic_write(NULL, | 245 | retval = usb_serial_generic_write(NULL, |
249 | port, &cr, 1); | 246 | port, &cr, 1); |
250 | dbg("%s - return value : %d", __func__, retval); | 247 | pr_debug("%s - return value : %d\n", __func__, retval); |
251 | } | 248 | } |
252 | buf += i; | 249 | buf += i; |
253 | count -= i; | 250 | count -= i; |
@@ -284,10 +281,8 @@ void usb_serial_console_disconnect(struct usb_serial *serial) | |||
284 | } | 281 | } |
285 | } | 282 | } |
286 | 283 | ||
287 | void usb_serial_console_init(int serial_debug, int minor) | 284 | void usb_serial_console_init(int minor) |
288 | { | 285 | { |
289 | debug = serial_debug; | ||
290 | |||
291 | if (minor == 0) { | 286 | if (minor == 0) { |
292 | /* | 287 | /* |
293 | * Call register_console() if this is the first device plugged | 288 | * Call register_console() if this is the first device plugged |
@@ -302,7 +297,7 @@ void usb_serial_console_init(int serial_debug, int minor) | |||
302 | * register_console). console_write() is called immediately | 297 | * register_console). console_write() is called immediately |
303 | * from register_console iff CON_PRINTBUFFER is set in flags. | 298 | * from register_console iff CON_PRINTBUFFER is set in flags. |
304 | */ | 299 | */ |
305 | dbg("registering the USB serial console."); | 300 | pr_debug("registering the USB serial console.\n"); |
306 | register_console(&usbcons); | 301 | register_console(&usbcons); |
307 | } | 302 | } |
308 | } | 303 | } |
diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c index ba5e07e188a0..28af5acc3360 100644 --- a/drivers/usb/serial/cp210x.c +++ b/drivers/usb/serial/cp210x.c | |||
@@ -52,8 +52,6 @@ static int cp210x_startup(struct usb_serial *); | |||
52 | static void cp210x_release(struct usb_serial *); | 52 | static void cp210x_release(struct usb_serial *); |
53 | static void cp210x_dtr_rts(struct usb_serial_port *p, int on); | 53 | static void cp210x_dtr_rts(struct usb_serial_port *p, int on); |
54 | 54 | ||
55 | static bool debug; | ||
56 | |||
57 | static const struct usb_device_id id_table[] = { | 55 | static const struct usb_device_id id_table[] = { |
58 | { USB_DEVICE(0x045B, 0x0053) }, /* Renesas RX610 RX-Stick */ | 56 | { USB_DEVICE(0x045B, 0x0053) }, /* Renesas RX610 RX-Stick */ |
59 | { USB_DEVICE(0x0471, 0x066A) }, /* AKTAKOM ACE-1001 cable */ | 57 | { USB_DEVICE(0x0471, 0x066A) }, /* AKTAKOM ACE-1001 cable */ |
@@ -304,9 +302,8 @@ static int cp210x_get_config(struct usb_serial_port *port, u8 request, | |||
304 | kfree(buf); | 302 | kfree(buf); |
305 | 303 | ||
306 | if (result != size) { | 304 | if (result != size) { |
307 | dbg("%s - Unable to send config request, " | 305 | dev_dbg(&port->dev, "%s - Unable to send config request, request=0x%x size=%d result=%d\n", |
308 | "request=0x%x size=%d result=%d", | 306 | __func__, request, size, result); |
309 | __func__, request, size, result); | ||
310 | if (result > 0) | 307 | if (result > 0) |
311 | result = -EPROTO; | 308 | result = -EPROTO; |
312 | 309 | ||
@@ -361,9 +358,8 @@ static int cp210x_set_config(struct usb_serial_port *port, u8 request, | |||
361 | kfree(buf); | 358 | kfree(buf); |
362 | 359 | ||
363 | if ((size > 2 && result != size) || result < 0) { | 360 | if ((size > 2 && result != size) || result < 0) { |
364 | dbg("%s - Unable to send request, " | 361 | dev_dbg(&port->dev, "%s - Unable to send request, request=0x%x size=%d result=%d\n", |
365 | "request=0x%x size=%d result=%d", | 362 | __func__, request, size, result); |
366 | __func__, request, size, result); | ||
367 | if (result > 0) | 363 | if (result > 0) |
368 | result = -EPROTO; | 364 | result = -EPROTO; |
369 | 365 | ||
@@ -487,13 +483,14 @@ static void cp210x_get_termios(struct tty_struct *tty, | |||
487 | static void cp210x_get_termios_port(struct usb_serial_port *port, | 483 | static void cp210x_get_termios_port(struct usb_serial_port *port, |
488 | unsigned int *cflagp, unsigned int *baudp) | 484 | unsigned int *cflagp, unsigned int *baudp) |
489 | { | 485 | { |
486 | struct device *dev = &port->dev; | ||
490 | unsigned int cflag, modem_ctl[4]; | 487 | unsigned int cflag, modem_ctl[4]; |
491 | unsigned int baud; | 488 | unsigned int baud; |
492 | unsigned int bits; | 489 | unsigned int bits; |
493 | 490 | ||
494 | cp210x_get_config(port, CP210X_GET_BAUDRATE, &baud, 4); | 491 | cp210x_get_config(port, CP210X_GET_BAUDRATE, &baud, 4); |
495 | 492 | ||
496 | dbg("%s - baud rate = %d", __func__, baud); | 493 | dev_dbg(dev, "%s - baud rate = %d\n", __func__, baud); |
497 | *baudp = baud; | 494 | *baudp = baud; |
498 | 495 | ||
499 | cflag = *cflagp; | 496 | cflag = *cflagp; |
@@ -502,31 +499,30 @@ static void cp210x_get_termios_port(struct usb_serial_port *port, | |||
502 | cflag &= ~CSIZE; | 499 | cflag &= ~CSIZE; |
503 | switch (bits & BITS_DATA_MASK) { | 500 | switch (bits & BITS_DATA_MASK) { |
504 | case BITS_DATA_5: | 501 | case BITS_DATA_5: |
505 | dbg("%s - data bits = 5", __func__); | 502 | dev_dbg(dev, "%s - data bits = 5\n", __func__); |
506 | cflag |= CS5; | 503 | cflag |= CS5; |
507 | break; | 504 | break; |
508 | case BITS_DATA_6: | 505 | case BITS_DATA_6: |
509 | dbg("%s - data bits = 6", __func__); | 506 | dev_dbg(dev, "%s - data bits = 6\n", __func__); |
510 | cflag |= CS6; | 507 | cflag |= CS6; |
511 | break; | 508 | break; |
512 | case BITS_DATA_7: | 509 | case BITS_DATA_7: |
513 | dbg("%s - data bits = 7", __func__); | 510 | dev_dbg(dev, "%s - data bits = 7\n", __func__); |
514 | cflag |= CS7; | 511 | cflag |= CS7; |
515 | break; | 512 | break; |
516 | case BITS_DATA_8: | 513 | case BITS_DATA_8: |
517 | dbg("%s - data bits = 8", __func__); | 514 | dev_dbg(dev, "%s - data bits = 8\n", __func__); |
518 | cflag |= CS8; | 515 | cflag |= CS8; |
519 | break; | 516 | break; |
520 | case BITS_DATA_9: | 517 | case BITS_DATA_9: |
521 | dbg("%s - data bits = 9 (not supported, using 8 data bits)", | 518 | dev_dbg(dev, "%s - data bits = 9 (not supported, using 8 data bits)\n", __func__); |
522 | __func__); | ||
523 | cflag |= CS8; | 519 | cflag |= CS8; |
524 | bits &= ~BITS_DATA_MASK; | 520 | bits &= ~BITS_DATA_MASK; |
525 | bits |= BITS_DATA_8; | 521 | bits |= BITS_DATA_8; |
526 | cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2); | 522 | cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2); |
527 | break; | 523 | break; |
528 | default: | 524 | default: |
529 | dbg("%s - Unknown number of data bits, using 8", __func__); | 525 | dev_dbg(dev, "%s - Unknown number of data bits, using 8\n", __func__); |
530 | cflag |= CS8; | 526 | cflag |= CS8; |
531 | bits &= ~BITS_DATA_MASK; | 527 | bits &= ~BITS_DATA_MASK; |
532 | bits |= BITS_DATA_8; | 528 | bits |= BITS_DATA_8; |
@@ -536,29 +532,29 @@ static void cp210x_get_termios_port(struct usb_serial_port *port, | |||
536 | 532 | ||
537 | switch (bits & BITS_PARITY_MASK) { | 533 | switch (bits & BITS_PARITY_MASK) { |
538 | case BITS_PARITY_NONE: | 534 | case BITS_PARITY_NONE: |
539 | dbg("%s - parity = NONE", __func__); | 535 | dev_dbg(dev, "%s - parity = NONE\n", __func__); |
540 | cflag &= ~PARENB; | 536 | cflag &= ~PARENB; |
541 | break; | 537 | break; |
542 | case BITS_PARITY_ODD: | 538 | case BITS_PARITY_ODD: |
543 | dbg("%s - parity = ODD", __func__); | 539 | dev_dbg(dev, "%s - parity = ODD\n", __func__); |
544 | cflag |= (PARENB|PARODD); | 540 | cflag |= (PARENB|PARODD); |
545 | break; | 541 | break; |
546 | case BITS_PARITY_EVEN: | 542 | case BITS_PARITY_EVEN: |
547 | dbg("%s - parity = EVEN", __func__); | 543 | dev_dbg(dev, "%s - parity = EVEN\n", __func__); |
548 | cflag &= ~PARODD; | 544 | cflag &= ~PARODD; |
549 | cflag |= PARENB; | 545 | cflag |= PARENB; |
550 | break; | 546 | break; |
551 | case BITS_PARITY_MARK: | 547 | case BITS_PARITY_MARK: |
552 | dbg("%s - parity = MARK", __func__); | 548 | dev_dbg(dev, "%s - parity = MARK\n", __func__); |
553 | cflag |= (PARENB|PARODD|CMSPAR); | 549 | cflag |= (PARENB|PARODD|CMSPAR); |
554 | break; | 550 | break; |
555 | case BITS_PARITY_SPACE: | 551 | case BITS_PARITY_SPACE: |
556 | dbg("%s - parity = SPACE", __func__); | 552 | dev_dbg(dev, "%s - parity = SPACE\n", __func__); |
557 | cflag &= ~PARODD; | 553 | cflag &= ~PARODD; |
558 | cflag |= (PARENB|CMSPAR); | 554 | cflag |= (PARENB|CMSPAR); |
559 | break; | 555 | break; |
560 | default: | 556 | default: |
561 | dbg("%s - Unknown parity mode, disabling parity", __func__); | 557 | dev_dbg(dev, "%s - Unknown parity mode, disabling parity\n", __func__); |
562 | cflag &= ~PARENB; | 558 | cflag &= ~PARENB; |
563 | bits &= ~BITS_PARITY_MASK; | 559 | bits &= ~BITS_PARITY_MASK; |
564 | cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2); | 560 | cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2); |
@@ -568,21 +564,19 @@ static void cp210x_get_termios_port(struct usb_serial_port *port, | |||
568 | cflag &= ~CSTOPB; | 564 | cflag &= ~CSTOPB; |
569 | switch (bits & BITS_STOP_MASK) { | 565 | switch (bits & BITS_STOP_MASK) { |
570 | case BITS_STOP_1: | 566 | case BITS_STOP_1: |
571 | dbg("%s - stop bits = 1", __func__); | 567 | dev_dbg(dev, "%s - stop bits = 1\n", __func__); |
572 | break; | 568 | break; |
573 | case BITS_STOP_1_5: | 569 | case BITS_STOP_1_5: |
574 | dbg("%s - stop bits = 1.5 (not supported, using 1 stop bit)", | 570 | dev_dbg(dev, "%s - stop bits = 1.5 (not supported, using 1 stop bit)\n", __func__); |
575 | __func__); | ||
576 | bits &= ~BITS_STOP_MASK; | 571 | bits &= ~BITS_STOP_MASK; |
577 | cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2); | 572 | cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2); |
578 | break; | 573 | break; |
579 | case BITS_STOP_2: | 574 | case BITS_STOP_2: |
580 | dbg("%s - stop bits = 2", __func__); | 575 | dev_dbg(dev, "%s - stop bits = 2\n", __func__); |
581 | cflag |= CSTOPB; | 576 | cflag |= CSTOPB; |
582 | break; | 577 | break; |
583 | default: | 578 | default: |
584 | dbg("%s - Unknown number of stop bits, using 1 stop bit", | 579 | dev_dbg(dev, "%s - Unknown number of stop bits, using 1 stop bit\n", __func__); |
585 | __func__); | ||
586 | bits &= ~BITS_STOP_MASK; | 580 | bits &= ~BITS_STOP_MASK; |
587 | cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2); | 581 | cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2); |
588 | break; | 582 | break; |
@@ -590,10 +584,10 @@ static void cp210x_get_termios_port(struct usb_serial_port *port, | |||
590 | 584 | ||
591 | cp210x_get_config(port, CP210X_GET_FLOW, modem_ctl, 16); | 585 | cp210x_get_config(port, CP210X_GET_FLOW, modem_ctl, 16); |
592 | if (modem_ctl[0] & 0x0008) { | 586 | if (modem_ctl[0] & 0x0008) { |
593 | dbg("%s - flow control = CRTSCTS", __func__); | 587 | dev_dbg(dev, "%s - flow control = CRTSCTS\n", __func__); |
594 | cflag |= CRTSCTS; | 588 | cflag |= CRTSCTS; |
595 | } else { | 589 | } else { |
596 | dbg("%s - flow control = NONE", __func__); | 590 | dev_dbg(dev, "%s - flow control = NONE\n", __func__); |
597 | cflag &= ~CRTSCTS; | 591 | cflag &= ~CRTSCTS; |
598 | } | 592 | } |
599 | 593 | ||
@@ -640,7 +634,7 @@ static void cp210x_change_speed(struct tty_struct *tty, | |||
640 | */ | 634 | */ |
641 | baud = cp210x_quantise_baudrate(baud); | 635 | baud = cp210x_quantise_baudrate(baud); |
642 | 636 | ||
643 | dbg("%s - setting baud rate to %u", __func__, baud); | 637 | dev_dbg(&port->dev, "%s - setting baud rate to %u\n", __func__, baud); |
644 | if (cp210x_set_config(port, CP210X_SET_BAUDRATE, &baud, | 638 | if (cp210x_set_config(port, CP210X_SET_BAUDRATE, &baud, |
645 | sizeof(baud))) { | 639 | sizeof(baud))) { |
646 | dev_warn(&port->dev, "failed to set baud rate to %u\n", baud); | 640 | dev_warn(&port->dev, "failed to set baud rate to %u\n", baud); |
@@ -656,11 +650,12 @@ static void cp210x_change_speed(struct tty_struct *tty, | |||
656 | static void cp210x_set_termios(struct tty_struct *tty, | 650 | static void cp210x_set_termios(struct tty_struct *tty, |
657 | struct usb_serial_port *port, struct ktermios *old_termios) | 651 | struct usb_serial_port *port, struct ktermios *old_termios) |
658 | { | 652 | { |
653 | struct device *dev = &port->dev; | ||
659 | unsigned int cflag, old_cflag; | 654 | unsigned int cflag, old_cflag; |
660 | unsigned int bits; | 655 | unsigned int bits; |
661 | unsigned int modem_ctl[4]; | 656 | unsigned int modem_ctl[4]; |
662 | 657 | ||
663 | dbg("%s - port %d", __func__, port->number); | 658 | dev_dbg(dev, "%s - port %d\n", __func__, port->number); |
664 | 659 | ||
665 | if (!tty) | 660 | if (!tty) |
666 | return; | 661 | return; |
@@ -678,34 +673,31 @@ static void cp210x_set_termios(struct tty_struct *tty, | |||
678 | switch (cflag & CSIZE) { | 673 | switch (cflag & CSIZE) { |
679 | case CS5: | 674 | case CS5: |
680 | bits |= BITS_DATA_5; | 675 | bits |= BITS_DATA_5; |
681 | dbg("%s - data bits = 5", __func__); | 676 | dev_dbg(dev, "%s - data bits = 5\n", __func__); |
682 | break; | 677 | break; |
683 | case CS6: | 678 | case CS6: |
684 | bits |= BITS_DATA_6; | 679 | bits |= BITS_DATA_6; |
685 | dbg("%s - data bits = 6", __func__); | 680 | dev_dbg(dev, "%s - data bits = 6\n", __func__); |
686 | break; | 681 | break; |
687 | case CS7: | 682 | case CS7: |
688 | bits |= BITS_DATA_7; | 683 | bits |= BITS_DATA_7; |
689 | dbg("%s - data bits = 7", __func__); | 684 | dev_dbg(dev, "%s - data bits = 7\n", __func__); |
690 | break; | 685 | break; |
691 | case CS8: | 686 | case CS8: |
692 | bits |= BITS_DATA_8; | 687 | bits |= BITS_DATA_8; |
693 | dbg("%s - data bits = 8", __func__); | 688 | dev_dbg(dev, "%s - data bits = 8\n", __func__); |
694 | break; | 689 | break; |
695 | /*case CS9: | 690 | /*case CS9: |
696 | bits |= BITS_DATA_9; | 691 | bits |= BITS_DATA_9; |
697 | dbg("%s - data bits = 9", __func__); | 692 | dev_dbg(dev, "%s - data bits = 9\n", __func__); |
698 | break;*/ | 693 | break;*/ |
699 | default: | 694 | default: |
700 | dbg("cp210x driver does not " | 695 | dev_dbg(dev, "cp210x driver does not support the number of bits requested, using 8 bit mode\n"); |
701 | "support the number of bits requested," | ||
702 | " using 8 bit mode"); | ||
703 | bits |= BITS_DATA_8; | 696 | bits |= BITS_DATA_8; |
704 | break; | 697 | break; |
705 | } | 698 | } |
706 | if (cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2)) | 699 | if (cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2)) |
707 | dbg("Number of data bits requested " | 700 | dev_dbg(dev, "Number of data bits requested not supported by device\n"); |
708 | "not supported by device"); | ||
709 | } | 701 | } |
710 | 702 | ||
711 | if ((cflag & (PARENB|PARODD|CMSPAR)) != | 703 | if ((cflag & (PARENB|PARODD|CMSPAR)) != |
@@ -714,25 +706,25 @@ static void cp210x_set_termios(struct tty_struct *tty, | |||
714 | bits &= ~BITS_PARITY_MASK; | 706 | bits &= ~BITS_PARITY_MASK; |
715 | if (cflag & PARENB) { | 707 | if (cflag & PARENB) { |
716 | if (cflag & CMSPAR) { | 708 | if (cflag & CMSPAR) { |
717 | if (cflag & PARODD) { | 709 | if (cflag & PARODD) { |
718 | bits |= BITS_PARITY_MARK; | 710 | bits |= BITS_PARITY_MARK; |
719 | dbg("%s - parity = MARK", __func__); | 711 | dev_dbg(dev, "%s - parity = MARK\n", __func__); |
720 | } else { | 712 | } else { |
721 | bits |= BITS_PARITY_SPACE; | 713 | bits |= BITS_PARITY_SPACE; |
722 | dbg("%s - parity = SPACE", __func__); | 714 | dev_dbg(dev, "%s - parity = SPACE\n", __func__); |
723 | } | 715 | } |
724 | } else { | 716 | } else { |
725 | if (cflag & PARODD) { | 717 | if (cflag & PARODD) { |
726 | bits |= BITS_PARITY_ODD; | 718 | bits |= BITS_PARITY_ODD; |
727 | dbg("%s - parity = ODD", __func__); | 719 | dev_dbg(dev, "%s - parity = ODD\n", __func__); |
728 | } else { | 720 | } else { |
729 | bits |= BITS_PARITY_EVEN; | 721 | bits |= BITS_PARITY_EVEN; |
730 | dbg("%s - parity = EVEN", __func__); | 722 | dev_dbg(dev, "%s - parity = EVEN\n", __func__); |
731 | } | 723 | } |
732 | } | 724 | } |
733 | } | 725 | } |
734 | if (cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2)) | 726 | if (cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2)) |
735 | dbg("Parity mode not supported by device"); | 727 | dev_dbg(dev, "Parity mode not supported by device\n"); |
736 | } | 728 | } |
737 | 729 | ||
738 | if ((cflag & CSTOPB) != (old_cflag & CSTOPB)) { | 730 | if ((cflag & CSTOPB) != (old_cflag & CSTOPB)) { |
@@ -740,37 +732,36 @@ static void cp210x_set_termios(struct tty_struct *tty, | |||
740 | bits &= ~BITS_STOP_MASK; | 732 | bits &= ~BITS_STOP_MASK; |
741 | if (cflag & CSTOPB) { | 733 | if (cflag & CSTOPB) { |
742 | bits |= BITS_STOP_2; | 734 | bits |= BITS_STOP_2; |
743 | dbg("%s - stop bits = 2", __func__); | 735 | dev_dbg(dev, "%s - stop bits = 2\n", __func__); |
744 | } else { | 736 | } else { |
745 | bits |= BITS_STOP_1; | 737 | bits |= BITS_STOP_1; |
746 | dbg("%s - stop bits = 1", __func__); | 738 | dev_dbg(dev, "%s - stop bits = 1\n", __func__); |
747 | } | 739 | } |
748 | if (cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2)) | 740 | if (cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2)) |
749 | dbg("Number of stop bits requested " | 741 | dev_dbg(dev, "Number of stop bits requested not supported by device\n"); |
750 | "not supported by device"); | ||
751 | } | 742 | } |
752 | 743 | ||
753 | if ((cflag & CRTSCTS) != (old_cflag & CRTSCTS)) { | 744 | if ((cflag & CRTSCTS) != (old_cflag & CRTSCTS)) { |
754 | cp210x_get_config(port, CP210X_GET_FLOW, modem_ctl, 16); | 745 | cp210x_get_config(port, CP210X_GET_FLOW, modem_ctl, 16); |
755 | dbg("%s - read modem controls = 0x%.4x 0x%.4x 0x%.4x 0x%.4x", | 746 | dev_dbg(dev, "%s - read modem controls = 0x%.4x 0x%.4x 0x%.4x 0x%.4x\n", |
756 | __func__, modem_ctl[0], modem_ctl[1], | 747 | __func__, modem_ctl[0], modem_ctl[1], |
757 | modem_ctl[2], modem_ctl[3]); | 748 | modem_ctl[2], modem_ctl[3]); |
758 | 749 | ||
759 | if (cflag & CRTSCTS) { | 750 | if (cflag & CRTSCTS) { |
760 | modem_ctl[0] &= ~0x7B; | 751 | modem_ctl[0] &= ~0x7B; |
761 | modem_ctl[0] |= 0x09; | 752 | modem_ctl[0] |= 0x09; |
762 | modem_ctl[1] = 0x80; | 753 | modem_ctl[1] = 0x80; |
763 | dbg("%s - flow control = CRTSCTS", __func__); | 754 | dev_dbg(dev, "%s - flow control = CRTSCTS\n", __func__); |
764 | } else { | 755 | } else { |
765 | modem_ctl[0] &= ~0x7B; | 756 | modem_ctl[0] &= ~0x7B; |
766 | modem_ctl[0] |= 0x01; | 757 | modem_ctl[0] |= 0x01; |
767 | modem_ctl[1] |= 0x40; | 758 | modem_ctl[1] |= 0x40; |
768 | dbg("%s - flow control = NONE", __func__); | 759 | dev_dbg(dev, "%s - flow control = NONE\n", __func__); |
769 | } | 760 | } |
770 | 761 | ||
771 | dbg("%s - write modem controls = 0x%.4x 0x%.4x 0x%.4x 0x%.4x", | 762 | dev_dbg(dev, "%s - write modem controls = 0x%.4x 0x%.4x 0x%.4x 0x%.4x\n", |
772 | __func__, modem_ctl[0], modem_ctl[1], | 763 | __func__, modem_ctl[0], modem_ctl[1], |
773 | modem_ctl[2], modem_ctl[3]); | 764 | modem_ctl[2], modem_ctl[3]); |
774 | cp210x_set_config(port, CP210X_SET_FLOW, modem_ctl, 16); | 765 | cp210x_set_config(port, CP210X_SET_FLOW, modem_ctl, 16); |
775 | } | 766 | } |
776 | 767 | ||
@@ -805,7 +796,7 @@ static int cp210x_tiocmset_port(struct usb_serial_port *port, | |||
805 | control |= CONTROL_WRITE_DTR; | 796 | control |= CONTROL_WRITE_DTR; |
806 | } | 797 | } |
807 | 798 | ||
808 | dbg("%s - control = 0x%.4x", __func__, control); | 799 | dev_dbg(&port->dev, "%s - control = 0x%.4x\n", __func__, control); |
809 | 800 | ||
810 | return cp210x_set_config(port, CP210X_SET_MHS, &control, 2); | 801 | return cp210x_set_config(port, CP210X_SET_MHS, &control, 2); |
811 | } | 802 | } |
@@ -833,7 +824,7 @@ static int cp210x_tiocmget (struct tty_struct *tty) | |||
833 | |((control & CONTROL_RING)? TIOCM_RI : 0) | 824 | |((control & CONTROL_RING)? TIOCM_RI : 0) |
834 | |((control & CONTROL_DCD) ? TIOCM_CD : 0); | 825 | |((control & CONTROL_DCD) ? TIOCM_CD : 0); |
835 | 826 | ||
836 | dbg("%s - control = 0x%.2x", __func__, control); | 827 | dev_dbg(&port->dev, "%s - control = 0x%.2x\n", __func__, control); |
837 | 828 | ||
838 | return result; | 829 | return result; |
839 | } | 830 | } |
@@ -847,8 +838,8 @@ static void cp210x_break_ctl (struct tty_struct *tty, int break_state) | |||
847 | state = BREAK_OFF; | 838 | state = BREAK_OFF; |
848 | else | 839 | else |
849 | state = BREAK_ON; | 840 | state = BREAK_ON; |
850 | dbg("%s - turning break %s", __func__, | 841 | dev_dbg(&port->dev, "%s - turning break %s\n", __func__, |
851 | state == BREAK_OFF ? "off" : "on"); | 842 | state == BREAK_OFF ? "off" : "on"); |
852 | cp210x_set_config(port, CP210X_SET_BREAK, &state, 2); | 843 | cp210x_set_config(port, CP210X_SET_BREAK, &state, 2); |
853 | } | 844 | } |
854 | 845 | ||
@@ -865,7 +856,6 @@ static int cp210x_startup(struct usb_serial *serial) | |||
865 | if (!port_priv) | 856 | if (!port_priv) |
866 | return -ENOMEM; | 857 | return -ENOMEM; |
867 | 858 | ||
868 | memset(port_priv, 0x00, sizeof(*port_priv)); | ||
869 | port_priv->bInterfaceNumber = | 859 | port_priv->bInterfaceNumber = |
870 | serial->interface->cur_altsetting->desc.bInterfaceNumber; | 860 | serial->interface->cur_altsetting->desc.bInterfaceNumber; |
871 | 861 | ||
@@ -892,6 +882,3 @@ module_usb_serial_driver(serial_drivers, id_table); | |||
892 | MODULE_DESCRIPTION(DRIVER_DESC); | 882 | MODULE_DESCRIPTION(DRIVER_DESC); |
893 | MODULE_VERSION(DRIVER_VERSION); | 883 | MODULE_VERSION(DRIVER_VERSION); |
894 | MODULE_LICENSE("GPL"); | 884 | MODULE_LICENSE("GPL"); |
895 | |||
896 | module_param(debug, bool, S_IRUGO | S_IWUSR); | ||
897 | MODULE_PARM_DESC(debug, "Enable verbose debugging messages"); | ||
diff --git a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c index 3aa0b530f68e..2a7aecc72237 100644 --- a/drivers/usb/serial/cyberjack.c +++ b/drivers/usb/serial/cyberjack.c | |||
@@ -43,8 +43,6 @@ | |||
43 | 43 | ||
44 | #define CYBERJACK_LOCAL_BUF_SIZE 32 | 44 | #define CYBERJACK_LOCAL_BUF_SIZE 32 |
45 | 45 | ||
46 | static bool debug; | ||
47 | |||
48 | /* | 46 | /* |
49 | * Version Information | 47 | * Version Information |
50 | */ | 48 | */ |
@@ -136,7 +134,8 @@ static int cyberjack_startup(struct usb_serial *serial) | |||
136 | if (result) | 134 | if (result) |
137 | dev_err(&serial->dev->dev, | 135 | dev_err(&serial->dev->dev, |
138 | "usb_submit_urb(read int) failed\n"); | 136 | "usb_submit_urb(read int) failed\n"); |
139 | dbg("%s - usb_submit_urb(int urb)", __func__); | 137 | dev_dbg(&serial->dev->dev, "%s - usb_submit_urb(int urb)\n", |
138 | __func__); | ||
140 | } | 139 | } |
141 | 140 | ||
142 | return 0; | 141 | return 0; |
@@ -167,7 +166,7 @@ static int cyberjack_open(struct tty_struct *tty, | |||
167 | unsigned long flags; | 166 | unsigned long flags; |
168 | int result = 0; | 167 | int result = 0; |
169 | 168 | ||
170 | dbg("%s - usb_clear_halt", __func__); | 169 | dev_dbg(&port->dev, "%s - usb_clear_halt\n", __func__); |
171 | usb_clear_halt(port->serial->dev, port->write_urb->pipe); | 170 | usb_clear_halt(port->serial->dev, port->write_urb->pipe); |
172 | 171 | ||
173 | priv = usb_get_serial_port_data(port); | 172 | priv = usb_get_serial_port_data(port); |
@@ -192,18 +191,19 @@ static void cyberjack_close(struct usb_serial_port *port) | |||
192 | static int cyberjack_write(struct tty_struct *tty, | 191 | static int cyberjack_write(struct tty_struct *tty, |
193 | struct usb_serial_port *port, const unsigned char *buf, int count) | 192 | struct usb_serial_port *port, const unsigned char *buf, int count) |
194 | { | 193 | { |
194 | struct device *dev = &port->dev; | ||
195 | struct cyberjack_private *priv = usb_get_serial_port_data(port); | 195 | struct cyberjack_private *priv = usb_get_serial_port_data(port); |
196 | unsigned long flags; | 196 | unsigned long flags; |
197 | int result; | 197 | int result; |
198 | int wrexpected; | 198 | int wrexpected; |
199 | 199 | ||
200 | if (count == 0) { | 200 | if (count == 0) { |
201 | dbg("%s - write request of 0 bytes", __func__); | 201 | dev_dbg(dev, "%s - write request of 0 bytes\n", __func__); |
202 | return 0; | 202 | return 0; |
203 | } | 203 | } |
204 | 204 | ||
205 | if (!test_and_clear_bit(0, &port->write_urbs_free)) { | 205 | if (!test_and_clear_bit(0, &port->write_urbs_free)) { |
206 | dbg("%s - already writing", __func__); | 206 | dev_dbg(dev, "%s - already writing\n", __func__); |
207 | return 0; | 207 | return 0; |
208 | } | 208 | } |
209 | 209 | ||
@@ -220,13 +220,12 @@ static int cyberjack_write(struct tty_struct *tty, | |||
220 | /* Copy data */ | 220 | /* Copy data */ |
221 | memcpy(priv->wrbuf + priv->wrfilled, buf, count); | 221 | memcpy(priv->wrbuf + priv->wrfilled, buf, count); |
222 | 222 | ||
223 | usb_serial_debug_data(debug, &port->dev, __func__, count, | 223 | usb_serial_debug_data(dev, __func__, count, priv->wrbuf + priv->wrfilled); |
224 | priv->wrbuf + priv->wrfilled); | ||
225 | priv->wrfilled += count; | 224 | priv->wrfilled += count; |
226 | 225 | ||
227 | if (priv->wrfilled >= 3) { | 226 | if (priv->wrfilled >= 3) { |
228 | wrexpected = ((int)priv->wrbuf[2]<<8)+priv->wrbuf[1]+3; | 227 | wrexpected = ((int)priv->wrbuf[2]<<8)+priv->wrbuf[1]+3; |
229 | dbg("%s - expected data: %d", __func__, wrexpected); | 228 | dev_dbg(dev, "%s - expected data: %d\n", __func__, wrexpected); |
230 | } else | 229 | } else |
231 | wrexpected = sizeof(priv->wrbuf); | 230 | wrexpected = sizeof(priv->wrbuf); |
232 | 231 | ||
@@ -234,7 +233,7 @@ static int cyberjack_write(struct tty_struct *tty, | |||
234 | /* We have enough data to begin transmission */ | 233 | /* We have enough data to begin transmission */ |
235 | int length; | 234 | int length; |
236 | 235 | ||
237 | dbg("%s - transmitting data (frame 1)", __func__); | 236 | dev_dbg(dev, "%s - transmitting data (frame 1)\n", __func__); |
238 | length = (wrexpected > port->bulk_out_size) ? | 237 | length = (wrexpected > port->bulk_out_size) ? |
239 | port->bulk_out_size : wrexpected; | 238 | port->bulk_out_size : wrexpected; |
240 | 239 | ||
@@ -258,11 +257,11 @@ static int cyberjack_write(struct tty_struct *tty, | |||
258 | return 0; | 257 | return 0; |
259 | } | 258 | } |
260 | 259 | ||
261 | dbg("%s - priv->wrsent=%d", __func__, priv->wrsent); | 260 | dev_dbg(dev, "%s - priv->wrsent=%d\n", __func__, priv->wrsent); |
262 | dbg("%s - priv->wrfilled=%d", __func__, priv->wrfilled); | 261 | dev_dbg(dev, "%s - priv->wrfilled=%d\n", __func__, priv->wrfilled); |
263 | 262 | ||
264 | if (priv->wrsent >= priv->wrfilled) { | 263 | if (priv->wrsent >= priv->wrfilled) { |
265 | dbg("%s - buffer cleaned", __func__); | 264 | dev_dbg(dev, "%s - buffer cleaned\n", __func__); |
266 | memset(priv->wrbuf, 0, sizeof(priv->wrbuf)); | 265 | memset(priv->wrbuf, 0, sizeof(priv->wrbuf)); |
267 | priv->wrfilled = 0; | 266 | priv->wrfilled = 0; |
268 | priv->wrsent = 0; | 267 | priv->wrsent = 0; |
@@ -284,6 +283,7 @@ static void cyberjack_read_int_callback(struct urb *urb) | |||
284 | { | 283 | { |
285 | struct usb_serial_port *port = urb->context; | 284 | struct usb_serial_port *port = urb->context; |
286 | struct cyberjack_private *priv = usb_get_serial_port_data(port); | 285 | struct cyberjack_private *priv = usb_get_serial_port_data(port); |
286 | struct device *dev = &port->dev; | ||
287 | unsigned char *data = urb->transfer_buffer; | 287 | unsigned char *data = urb->transfer_buffer; |
288 | int status = urb->status; | 288 | int status = urb->status; |
289 | int result; | 289 | int result; |
@@ -292,8 +292,7 @@ static void cyberjack_read_int_callback(struct urb *urb) | |||
292 | if (status) | 292 | if (status) |
293 | return; | 293 | return; |
294 | 294 | ||
295 | usb_serial_debug_data(debug, &port->dev, __func__, | 295 | usb_serial_debug_data(dev, __func__, urb->actual_length, data); |
296 | urb->actual_length, data); | ||
297 | 296 | ||
298 | /* React only to interrupts signaling a bulk_in transfer */ | 297 | /* React only to interrupts signaling a bulk_in transfer */ |
299 | if (urb->actual_length == 4 && data[0] == 0x01) { | 298 | if (urb->actual_length == 4 && data[0] == 0x01) { |
@@ -307,7 +306,7 @@ static void cyberjack_read_int_callback(struct urb *urb) | |||
307 | old_rdtodo = priv->rdtodo; | 306 | old_rdtodo = priv->rdtodo; |
308 | 307 | ||
309 | if (old_rdtodo + size < old_rdtodo) { | 308 | if (old_rdtodo + size < old_rdtodo) { |
310 | dbg("To many bulk_in urbs to do."); | 309 | dev_dbg(dev, "To many bulk_in urbs to do.\n"); |
311 | spin_unlock(&priv->lock); | 310 | spin_unlock(&priv->lock); |
312 | goto resubmit; | 311 | goto resubmit; |
313 | } | 312 | } |
@@ -315,17 +314,16 @@ static void cyberjack_read_int_callback(struct urb *urb) | |||
315 | /* "+=" is probably more fault tollerant than "=" */ | 314 | /* "+=" is probably more fault tollerant than "=" */ |
316 | priv->rdtodo += size; | 315 | priv->rdtodo += size; |
317 | 316 | ||
318 | dbg("%s - rdtodo: %d", __func__, priv->rdtodo); | 317 | dev_dbg(dev, "%s - rdtodo: %d\n", __func__, priv->rdtodo); |
319 | 318 | ||
320 | spin_unlock(&priv->lock); | 319 | spin_unlock(&priv->lock); |
321 | 320 | ||
322 | if (!old_rdtodo) { | 321 | if (!old_rdtodo) { |
323 | result = usb_submit_urb(port->read_urb, GFP_ATOMIC); | 322 | result = usb_submit_urb(port->read_urb, GFP_ATOMIC); |
324 | if (result) | 323 | if (result) |
325 | dev_err(&port->dev, "%s - failed resubmitting " | 324 | dev_err(dev, "%s - failed resubmitting read urb, error %d\n", |
326 | "read urb, error %d\n", | ||
327 | __func__, result); | 325 | __func__, result); |
328 | dbg("%s - usb_submit_urb(read urb)", __func__); | 326 | dev_dbg(dev, "%s - usb_submit_urb(read urb)\n", __func__); |
329 | } | 327 | } |
330 | } | 328 | } |
331 | 329 | ||
@@ -333,30 +331,30 @@ resubmit: | |||
333 | result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); | 331 | result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); |
334 | if (result) | 332 | if (result) |
335 | dev_err(&port->dev, "usb_submit_urb(read int) failed\n"); | 333 | dev_err(&port->dev, "usb_submit_urb(read int) failed\n"); |
336 | dbg("%s - usb_submit_urb(int urb)", __func__); | 334 | dev_dbg(dev, "%s - usb_submit_urb(int urb)\n", __func__); |
337 | } | 335 | } |
338 | 336 | ||
339 | static void cyberjack_read_bulk_callback(struct urb *urb) | 337 | static void cyberjack_read_bulk_callback(struct urb *urb) |
340 | { | 338 | { |
341 | struct usb_serial_port *port = urb->context; | 339 | struct usb_serial_port *port = urb->context; |
342 | struct cyberjack_private *priv = usb_get_serial_port_data(port); | 340 | struct cyberjack_private *priv = usb_get_serial_port_data(port); |
341 | struct device *dev = &port->dev; | ||
343 | struct tty_struct *tty; | 342 | struct tty_struct *tty; |
344 | unsigned char *data = urb->transfer_buffer; | 343 | unsigned char *data = urb->transfer_buffer; |
345 | short todo; | 344 | short todo; |
346 | int result; | 345 | int result; |
347 | int status = urb->status; | 346 | int status = urb->status; |
348 | 347 | ||
349 | usb_serial_debug_data(debug, &port->dev, __func__, | 348 | usb_serial_debug_data(dev, __func__, urb->actual_length, data); |
350 | urb->actual_length, data); | ||
351 | if (status) { | 349 | if (status) { |
352 | dbg("%s - nonzero read bulk status received: %d", | 350 | dev_dbg(dev, "%s - nonzero read bulk status received: %d\n", |
353 | __func__, status); | 351 | __func__, status); |
354 | return; | 352 | return; |
355 | } | 353 | } |
356 | 354 | ||
357 | tty = tty_port_tty_get(&port->port); | 355 | tty = tty_port_tty_get(&port->port); |
358 | if (!tty) { | 356 | if (!tty) { |
359 | dbg("%s - ignoring since device not open", __func__); | 357 | dev_dbg(dev, "%s - ignoring since device not open\n", __func__); |
360 | return; | 358 | return; |
361 | } | 359 | } |
362 | if (urb->actual_length) { | 360 | if (urb->actual_length) { |
@@ -376,15 +374,15 @@ static void cyberjack_read_bulk_callback(struct urb *urb) | |||
376 | 374 | ||
377 | spin_unlock(&priv->lock); | 375 | spin_unlock(&priv->lock); |
378 | 376 | ||
379 | dbg("%s - rdtodo: %d", __func__, todo); | 377 | dev_dbg(dev, "%s - rdtodo: %d\n", __func__, todo); |
380 | 378 | ||
381 | /* Continue to read if we have still urbs to do. */ | 379 | /* Continue to read if we have still urbs to do. */ |
382 | if (todo /* || (urb->actual_length==port->bulk_in_endpointAddress)*/) { | 380 | if (todo /* || (urb->actual_length==port->bulk_in_endpointAddress)*/) { |
383 | result = usb_submit_urb(port->read_urb, GFP_ATOMIC); | 381 | result = usb_submit_urb(port->read_urb, GFP_ATOMIC); |
384 | if (result) | 382 | if (result) |
385 | dev_err(&port->dev, "%s - failed resubmitting read " | 383 | dev_err(dev, "%s - failed resubmitting read urb, error %d\n", |
386 | "urb, error %d\n", __func__, result); | 384 | __func__, result); |
387 | dbg("%s - usb_submit_urb(read urb)", __func__); | 385 | dev_dbg(dev, "%s - usb_submit_urb(read urb)\n", __func__); |
388 | } | 386 | } |
389 | } | 387 | } |
390 | 388 | ||
@@ -392,12 +390,13 @@ static void cyberjack_write_bulk_callback(struct urb *urb) | |||
392 | { | 390 | { |
393 | struct usb_serial_port *port = urb->context; | 391 | struct usb_serial_port *port = urb->context; |
394 | struct cyberjack_private *priv = usb_get_serial_port_data(port); | 392 | struct cyberjack_private *priv = usb_get_serial_port_data(port); |
393 | struct device *dev = &port->dev; | ||
395 | int status = urb->status; | 394 | int status = urb->status; |
396 | 395 | ||
397 | set_bit(0, &port->write_urbs_free); | 396 | set_bit(0, &port->write_urbs_free); |
398 | if (status) { | 397 | if (status) { |
399 | dbg("%s - nonzero write bulk status received: %d", | 398 | dev_dbg(dev, "%s - nonzero write bulk status received: %d\n", |
400 | __func__, status); | 399 | __func__, status); |
401 | return; | 400 | return; |
402 | } | 401 | } |
403 | 402 | ||
@@ -407,7 +406,7 @@ static void cyberjack_write_bulk_callback(struct urb *urb) | |||
407 | if (priv->wrfilled) { | 406 | if (priv->wrfilled) { |
408 | int length, blksize, result; | 407 | int length, blksize, result; |
409 | 408 | ||
410 | dbg("%s - transmitting data (frame n)", __func__); | 409 | dev_dbg(dev, "%s - transmitting data (frame n)\n", __func__); |
411 | 410 | ||
412 | length = ((priv->wrfilled - priv->wrsent) > port->bulk_out_size) ? | 411 | length = ((priv->wrfilled - priv->wrsent) > port->bulk_out_size) ? |
413 | port->bulk_out_size : (priv->wrfilled - priv->wrsent); | 412 | port->bulk_out_size : (priv->wrfilled - priv->wrsent); |
@@ -422,8 +421,7 @@ static void cyberjack_write_bulk_callback(struct urb *urb) | |||
422 | /* send the data out the bulk port */ | 421 | /* send the data out the bulk port */ |
423 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); | 422 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); |
424 | if (result) { | 423 | if (result) { |
425 | dev_err(&port->dev, | 424 | dev_err(dev, "%s - failed submitting write urb, error %d\n", |
426 | "%s - failed submitting write urb, error %d\n", | ||
427 | __func__, result); | 425 | __func__, result); |
428 | /* Throw away data. No better idea what to do with it. */ | 426 | /* Throw away data. No better idea what to do with it. */ |
429 | priv->wrfilled = 0; | 427 | priv->wrfilled = 0; |
@@ -431,14 +429,14 @@ static void cyberjack_write_bulk_callback(struct urb *urb) | |||
431 | goto exit; | 429 | goto exit; |
432 | } | 430 | } |
433 | 431 | ||
434 | dbg("%s - priv->wrsent=%d", __func__, priv->wrsent); | 432 | dev_dbg(dev, "%s - priv->wrsent=%d\n", __func__, priv->wrsent); |
435 | dbg("%s - priv->wrfilled=%d", __func__, priv->wrfilled); | 433 | dev_dbg(dev, "%s - priv->wrfilled=%d\n", __func__, priv->wrfilled); |
436 | 434 | ||
437 | blksize = ((int)priv->wrbuf[2]<<8)+priv->wrbuf[1]+3; | 435 | blksize = ((int)priv->wrbuf[2]<<8)+priv->wrbuf[1]+3; |
438 | 436 | ||
439 | if (priv->wrsent >= priv->wrfilled || | 437 | if (priv->wrsent >= priv->wrfilled || |
440 | priv->wrsent >= blksize) { | 438 | priv->wrsent >= blksize) { |
441 | dbg("%s - buffer cleaned", __func__); | 439 | dev_dbg(dev, "%s - buffer cleaned\n", __func__); |
442 | memset(priv->wrbuf, 0, sizeof(priv->wrbuf)); | 440 | memset(priv->wrbuf, 0, sizeof(priv->wrbuf)); |
443 | priv->wrfilled = 0; | 441 | priv->wrfilled = 0; |
444 | priv->wrsent = 0; | 442 | priv->wrsent = 0; |
@@ -456,6 +454,3 @@ MODULE_AUTHOR(DRIVER_AUTHOR); | |||
456 | MODULE_DESCRIPTION(DRIVER_DESC); | 454 | MODULE_DESCRIPTION(DRIVER_DESC); |
457 | MODULE_VERSION(DRIVER_VERSION); | 455 | MODULE_VERSION(DRIVER_VERSION); |
458 | MODULE_LICENSE("GPL"); | 456 | MODULE_LICENSE("GPL"); |
459 | |||
460 | module_param(debug, bool, S_IRUGO | S_IWUSR); | ||
461 | MODULE_PARM_DESC(debug, "Debug enabled or not"); | ||
diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c index be34f153e566..1befce21e173 100644 --- a/drivers/usb/serial/cypress_m8.c +++ b/drivers/usb/serial/cypress_m8.c | |||
@@ -46,7 +46,6 @@ | |||
46 | #include "cypress_m8.h" | 46 | #include "cypress_m8.h" |
47 | 47 | ||
48 | 48 | ||
49 | static bool debug; | ||
50 | static bool stats; | 49 | static bool stats; |
51 | static int interval; | 50 | static int interval; |
52 | static bool unstable_bauds; | 51 | static bool unstable_bauds; |
@@ -263,8 +262,9 @@ static int analyze_baud_rate(struct usb_serial_port *port, speed_t new_rate) | |||
263 | * safest speed for a part like that. | 262 | * safest speed for a part like that. |
264 | */ | 263 | */ |
265 | if (new_rate > 4800) { | 264 | if (new_rate > 4800) { |
266 | dbg("%s - failed setting baud rate, device incapable " | 265 | dev_dbg(&port->dev, |
267 | "speed %d", __func__, new_rate); | 266 | "%s - failed setting baud rate, device incapable speed %d\n", |
267 | __func__, new_rate); | ||
268 | return -1; | 268 | return -1; |
269 | } | 269 | } |
270 | } | 270 | } |
@@ -274,8 +274,9 @@ static int analyze_baud_rate(struct usb_serial_port *port, speed_t new_rate) | |||
274 | /* 300 and 600 baud rates are supported under | 274 | /* 300 and 600 baud rates are supported under |
275 | * the generic firmware, but are not used with | 275 | * the generic firmware, but are not used with |
276 | * NMEA and SiRF protocols */ | 276 | * NMEA and SiRF protocols */ |
277 | dbg("%s - failed setting baud rate, unsupported speed " | 277 | dev_dbg(&port->dev, |
278 | "of %d on Earthmate GPS", __func__, new_rate); | 278 | "%s - failed setting baud rate, unsupported speed of %d on Earthmate GPS", |
279 | __func__, new_rate); | ||
279 | return -1; | 280 | return -1; |
280 | } | 281 | } |
281 | break; | 282 | break; |
@@ -294,6 +295,7 @@ static int cypress_serial_control(struct tty_struct *tty, | |||
294 | { | 295 | { |
295 | int new_baudrate = 0, retval = 0, tries = 0; | 296 | int new_baudrate = 0, retval = 0, tries = 0; |
296 | struct cypress_private *priv; | 297 | struct cypress_private *priv; |
298 | struct device *dev = &port->dev; | ||
297 | u8 *feature_buffer; | 299 | u8 *feature_buffer; |
298 | const unsigned int feature_len = 5; | 300 | const unsigned int feature_len = 5; |
299 | unsigned long flags; | 301 | unsigned long flags; |
@@ -312,16 +314,16 @@ static int cypress_serial_control(struct tty_struct *tty, | |||
312 | /* 0 means 'Hang up' so doesn't change the true bit rate */ | 314 | /* 0 means 'Hang up' so doesn't change the true bit rate */ |
313 | new_baudrate = priv->baud_rate; | 315 | new_baudrate = priv->baud_rate; |
314 | if (baud_rate && baud_rate != priv->baud_rate) { | 316 | if (baud_rate && baud_rate != priv->baud_rate) { |
315 | dbg("%s - baud rate is changing", __func__); | 317 | dev_dbg(dev, "%s - baud rate is changing\n", __func__); |
316 | retval = analyze_baud_rate(port, baud_rate); | 318 | retval = analyze_baud_rate(port, baud_rate); |
317 | if (retval >= 0) { | 319 | if (retval >= 0) { |
318 | new_baudrate = retval; | 320 | new_baudrate = retval; |
319 | dbg("%s - New baud rate set to %d", | 321 | dev_dbg(dev, "%s - New baud rate set to %d\n", |
320 | __func__, new_baudrate); | 322 | __func__, new_baudrate); |
321 | } | 323 | } |
322 | } | 324 | } |
323 | dbg("%s - baud rate is being sent as %d", | 325 | dev_dbg(dev, "%s - baud rate is being sent as %d\n", __func__, |
324 | __func__, new_baudrate); | 326 | new_baudrate); |
325 | 327 | ||
326 | /* fill the feature_buffer with new configuration */ | 328 | /* fill the feature_buffer with new configuration */ |
327 | put_unaligned_le32(new_baudrate, feature_buffer); | 329 | put_unaligned_le32(new_baudrate, feature_buffer); |
@@ -333,9 +335,8 @@ static int cypress_serial_control(struct tty_struct *tty, | |||
333 | /* 1 bit gap */ | 335 | /* 1 bit gap */ |
334 | feature_buffer[4] |= (reset << 7); /* assign reset at end of byte, 1 bit space */ | 336 | feature_buffer[4] |= (reset << 7); /* assign reset at end of byte, 1 bit space */ |
335 | 337 | ||
336 | dbg("%s - device is being sent this feature report:", | 338 | dev_dbg(dev, "%s - device is being sent this feature report:\n", __func__); |
337 | __func__); | 339 | dev_dbg(dev, "%s - %02X - %02X - %02X - %02X - %02X\n", __func__, |
338 | dbg("%s - %02X - %02X - %02X - %02X - %02X", __func__, | ||
339 | feature_buffer[0], feature_buffer[1], | 340 | feature_buffer[0], feature_buffer[1], |
340 | feature_buffer[2], feature_buffer[3], | 341 | feature_buffer[2], feature_buffer[3], |
341 | feature_buffer[4]); | 342 | feature_buffer[4]); |
@@ -355,8 +356,8 @@ static int cypress_serial_control(struct tty_struct *tty, | |||
355 | retval != -ENODEV); | 356 | retval != -ENODEV); |
356 | 357 | ||
357 | if (retval != feature_len) { | 358 | if (retval != feature_len) { |
358 | dev_err(&port->dev, "%s - failed sending serial " | 359 | dev_err(dev, "%s - failed sending serial line settings - %d\n", |
359 | "line settings - %d\n", __func__, retval); | 360 | __func__, retval); |
360 | cypress_set_dead(port); | 361 | cypress_set_dead(port); |
361 | } else { | 362 | } else { |
362 | spin_lock_irqsave(&priv->lock, flags); | 363 | spin_lock_irqsave(&priv->lock, flags); |
@@ -377,7 +378,7 @@ static int cypress_serial_control(struct tty_struct *tty, | |||
377 | retval = -ENOTTY; | 378 | retval = -ENOTTY; |
378 | goto out; | 379 | goto out; |
379 | } | 380 | } |
380 | dbg("%s - retreiving serial line settings", __func__); | 381 | dev_dbg(dev, "%s - retreiving serial line settings\n", __func__); |
381 | do { | 382 | do { |
382 | retval = usb_control_msg(port->serial->dev, | 383 | retval = usb_control_msg(port->serial->dev, |
383 | usb_rcvctrlpipe(port->serial->dev, 0), | 384 | usb_rcvctrlpipe(port->serial->dev, 0), |
@@ -392,8 +393,8 @@ static int cypress_serial_control(struct tty_struct *tty, | |||
392 | && retval != -ENODEV); | 393 | && retval != -ENODEV); |
393 | 394 | ||
394 | if (retval != feature_len) { | 395 | if (retval != feature_len) { |
395 | dev_err(&port->dev, "%s - failed to retrieve serial " | 396 | dev_err(dev, "%s - failed to retrieve serial line settings - %d\n", |
396 | "line settings - %d\n", __func__, retval); | 397 | __func__, retval); |
397 | cypress_set_dead(port); | 398 | cypress_set_dead(port); |
398 | goto out; | 399 | goto out; |
399 | } else { | 400 | } else { |
@@ -474,14 +475,14 @@ static int generic_startup(struct usb_serial *serial) | |||
474 | if (interval > 0) { | 475 | if (interval > 0) { |
475 | priv->write_urb_interval = interval; | 476 | priv->write_urb_interval = interval; |
476 | priv->read_urb_interval = interval; | 477 | priv->read_urb_interval = interval; |
477 | dbg("%s - port %d read & write intervals forced to %d", | 478 | dev_dbg(&port->dev, "%s - read & write intervals forced to %d\n", |
478 | __func__, port->number, interval); | 479 | __func__, interval); |
479 | } else { | 480 | } else { |
480 | priv->write_urb_interval = port->interrupt_out_urb->interval; | 481 | priv->write_urb_interval = port->interrupt_out_urb->interval; |
481 | priv->read_urb_interval = port->interrupt_in_urb->interval; | 482 | priv->read_urb_interval = port->interrupt_in_urb->interval; |
482 | dbg("%s - port %d intervals: read=%d write=%d", | 483 | dev_dbg(&port->dev, "%s - intervals: read=%d write=%d\n", |
483 | __func__, port->number, | 484 | __func__, priv->read_urb_interval, |
484 | priv->read_urb_interval, priv->write_urb_interval); | 485 | priv->write_urb_interval); |
485 | } | 486 | } |
486 | usb_set_serial_port_data(port, priv); | 487 | usb_set_serial_port_data(port, priv); |
487 | 488 | ||
@@ -495,8 +496,7 @@ static int cypress_earthmate_startup(struct usb_serial *serial) | |||
495 | struct usb_serial_port *port = serial->port[0]; | 496 | struct usb_serial_port *port = serial->port[0]; |
496 | 497 | ||
497 | if (generic_startup(serial)) { | 498 | if (generic_startup(serial)) { |
498 | dbg("%s - Failed setting up port %d", __func__, | 499 | dev_dbg(&port->dev, "%s - Failed setting up port\n", __func__); |
499 | port->number); | ||
500 | return 1; | 500 | return 1; |
501 | } | 501 | } |
502 | 502 | ||
@@ -511,8 +511,9 @@ static int cypress_earthmate_startup(struct usb_serial *serial) | |||
511 | handle GET_CONFIG requests; everything they've | 511 | handle GET_CONFIG requests; everything they've |
512 | produced since that time crashes if this command is | 512 | produced since that time crashes if this command is |
513 | attempted :-( */ | 513 | attempted :-( */ |
514 | dbg("%s - Marking this device as unsafe for GET_CONFIG " | 514 | dev_dbg(&port->dev, |
515 | "commands", __func__); | 515 | "%s - Marking this device as unsafe for GET_CONFIG commands\n", |
516 | __func__); | ||
516 | priv->get_cfg_unsafe = !0; | 517 | priv->get_cfg_unsafe = !0; |
517 | } | 518 | } |
518 | 519 | ||
@@ -523,14 +524,14 @@ static int cypress_earthmate_startup(struct usb_serial *serial) | |||
523 | static int cypress_hidcom_startup(struct usb_serial *serial) | 524 | static int cypress_hidcom_startup(struct usb_serial *serial) |
524 | { | 525 | { |
525 | struct cypress_private *priv; | 526 | struct cypress_private *priv; |
527 | struct usb_serial_port *port = serial->port[0]; | ||
526 | 528 | ||
527 | if (generic_startup(serial)) { | 529 | if (generic_startup(serial)) { |
528 | dbg("%s - Failed setting up port %d", __func__, | 530 | dev_dbg(&port->dev, "%s - Failed setting up port\n", __func__); |
529 | serial->port[0]->number); | ||
530 | return 1; | 531 | return 1; |
531 | } | 532 | } |
532 | 533 | ||
533 | priv = usb_get_serial_port_data(serial->port[0]); | 534 | priv = usb_get_serial_port_data(port); |
534 | priv->chiptype = CT_CYPHIDCOM; | 535 | priv->chiptype = CT_CYPHIDCOM; |
535 | 536 | ||
536 | return 0; | 537 | return 0; |
@@ -540,14 +541,14 @@ static int cypress_hidcom_startup(struct usb_serial *serial) | |||
540 | static int cypress_ca42v2_startup(struct usb_serial *serial) | 541 | static int cypress_ca42v2_startup(struct usb_serial *serial) |
541 | { | 542 | { |
542 | struct cypress_private *priv; | 543 | struct cypress_private *priv; |
544 | struct usb_serial_port *port = serial->port[0]; | ||
543 | 545 | ||
544 | if (generic_startup(serial)) { | 546 | if (generic_startup(serial)) { |
545 | dbg("%s - Failed setting up port %d", __func__, | 547 | dev_dbg(&port->dev, "%s - Failed setting up port\n", __func__); |
546 | serial->port[0]->number); | ||
547 | return 1; | 548 | return 1; |
548 | } | 549 | } |
549 | 550 | ||
550 | priv = usb_get_serial_port_data(serial->port[0]); | 551 | priv = usb_get_serial_port_data(port); |
551 | priv->chiptype = CT_CA42V2; | 552 | priv->chiptype = CT_CA42V2; |
552 | 553 | ||
553 | return 0; | 554 | return 0; |
@@ -649,7 +650,7 @@ static void cypress_close(struct usb_serial_port *port) | |||
649 | kfifo_reset_out(&priv->write_fifo); | 650 | kfifo_reset_out(&priv->write_fifo); |
650 | spin_unlock_irqrestore(&priv->lock, flags); | 651 | spin_unlock_irqrestore(&priv->lock, flags); |
651 | 652 | ||
652 | dbg("%s - stopping urbs", __func__); | 653 | dev_dbg(&port->dev, "%s - stopping urbs\n", __func__); |
653 | usb_kill_urb(port->interrupt_in_urb); | 654 | usb_kill_urb(port->interrupt_in_urb); |
654 | usb_kill_urb(port->interrupt_out_urb); | 655 | usb_kill_urb(port->interrupt_out_urb); |
655 | 656 | ||
@@ -665,7 +666,7 @@ static int cypress_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
665 | { | 666 | { |
666 | struct cypress_private *priv = usb_get_serial_port_data(port); | 667 | struct cypress_private *priv = usb_get_serial_port_data(port); |
667 | 668 | ||
668 | dbg("%s - port %d, %d bytes", __func__, port->number, count); | 669 | dev_dbg(&port->dev, "%s - port %d, %d bytes\n", __func__, port->number, count); |
669 | 670 | ||
670 | /* line control commands, which need to be executed immediately, | 671 | /* line control commands, which need to be executed immediately, |
671 | are not put into the buffer for obvious reasons. | 672 | are not put into the buffer for obvious reasons. |
@@ -691,17 +692,18 @@ static void cypress_send(struct usb_serial_port *port) | |||
691 | { | 692 | { |
692 | int count = 0, result, offset, actual_size; | 693 | int count = 0, result, offset, actual_size; |
693 | struct cypress_private *priv = usb_get_serial_port_data(port); | 694 | struct cypress_private *priv = usb_get_serial_port_data(port); |
695 | struct device *dev = &port->dev; | ||
694 | unsigned long flags; | 696 | unsigned long flags; |
695 | 697 | ||
696 | if (!priv->comm_is_ok) | 698 | if (!priv->comm_is_ok) |
697 | return; | 699 | return; |
698 | 700 | ||
699 | dbg("%s - interrupt out size is %d", __func__, | 701 | dev_dbg(dev, "%s - interrupt out size is %d\n", __func__, |
700 | port->interrupt_out_size); | 702 | port->interrupt_out_size); |
701 | 703 | ||
702 | spin_lock_irqsave(&priv->lock, flags); | 704 | spin_lock_irqsave(&priv->lock, flags); |
703 | if (priv->write_urb_in_use) { | 705 | if (priv->write_urb_in_use) { |
704 | dbg("%s - can't write, urb in use", __func__); | 706 | dev_dbg(dev, "%s - can't write, urb in use\n", __func__); |
705 | spin_unlock_irqrestore(&priv->lock, flags); | 707 | spin_unlock_irqrestore(&priv->lock, flags); |
706 | return; | 708 | return; |
707 | } | 709 | } |
@@ -731,7 +733,7 @@ static void cypress_send(struct usb_serial_port *port) | |||
731 | 733 | ||
732 | if (priv->cmd_ctrl) { | 734 | if (priv->cmd_ctrl) { |
733 | priv->cmd_count++; | 735 | priv->cmd_count++; |
734 | dbg("%s - line control command being issued", __func__); | 736 | dev_dbg(dev, "%s - line control command being issued\n", __func__); |
735 | spin_unlock_irqrestore(&priv->lock, flags); | 737 | spin_unlock_irqrestore(&priv->lock, flags); |
736 | goto send; | 738 | goto send; |
737 | } else | 739 | } else |
@@ -753,7 +755,7 @@ static void cypress_send(struct usb_serial_port *port) | |||
753 | port->interrupt_out_buffer[0] |= count; | 755 | port->interrupt_out_buffer[0] |= count; |
754 | } | 756 | } |
755 | 757 | ||
756 | dbg("%s - count is %d", __func__, count); | 758 | dev_dbg(dev, "%s - count is %d\n", __func__, count); |
757 | 759 | ||
758 | send: | 760 | send: |
759 | spin_lock_irqsave(&priv->lock, flags); | 761 | spin_lock_irqsave(&priv->lock, flags); |
@@ -766,9 +768,8 @@ send: | |||
766 | actual_size = count + | 768 | actual_size = count + |
767 | (priv->pkt_fmt == packet_format_1 ? 2 : 1); | 769 | (priv->pkt_fmt == packet_format_1 ? 2 : 1); |
768 | 770 | ||
769 | usb_serial_debug_data(debug, &port->dev, __func__, | 771 | usb_serial_debug_data(dev, __func__, port->interrupt_out_size, |
770 | port->interrupt_out_size, | 772 | port->interrupt_out_urb->transfer_buffer); |
771 | port->interrupt_out_urb->transfer_buffer); | ||
772 | 773 | ||
773 | usb_fill_int_urb(port->interrupt_out_urb, port->serial->dev, | 774 | usb_fill_int_urb(port->interrupt_out_urb, port->serial->dev, |
774 | usb_sndintpipe(port->serial->dev, port->interrupt_out_endpointAddress), | 775 | usb_sndintpipe(port->serial->dev, port->interrupt_out_endpointAddress), |
@@ -807,7 +808,7 @@ static int cypress_write_room(struct tty_struct *tty) | |||
807 | room = kfifo_avail(&priv->write_fifo); | 808 | room = kfifo_avail(&priv->write_fifo); |
808 | spin_unlock_irqrestore(&priv->lock, flags); | 809 | spin_unlock_irqrestore(&priv->lock, flags); |
809 | 810 | ||
810 | dbg("%s - returns %d", __func__, room); | 811 | dev_dbg(&port->dev, "%s - returns %d\n", __func__, room); |
811 | return room; | 812 | return room; |
812 | } | 813 | } |
813 | 814 | ||
@@ -832,7 +833,7 @@ static int cypress_tiocmget(struct tty_struct *tty) | |||
832 | | ((status & UART_RI) ? TIOCM_RI : 0) | 833 | | ((status & UART_RI) ? TIOCM_RI : 0) |
833 | | ((status & UART_CD) ? TIOCM_CD : 0); | 834 | | ((status & UART_CD) ? TIOCM_CD : 0); |
834 | 835 | ||
835 | dbg("%s - result = %x", __func__, result); | 836 | dev_dbg(&port->dev, "%s - result = %x\n", __func__, result); |
836 | 837 | ||
837 | return result; | 838 | return result; |
838 | } | 839 | } |
@@ -867,7 +868,7 @@ static int cypress_ioctl(struct tty_struct *tty, | |||
867 | struct usb_serial_port *port = tty->driver_data; | 868 | struct usb_serial_port *port = tty->driver_data; |
868 | struct cypress_private *priv = usb_get_serial_port_data(port); | 869 | struct cypress_private *priv = usb_get_serial_port_data(port); |
869 | 870 | ||
870 | dbg("%s - port %d, cmd 0x%.4x", __func__, port->number, cmd); | 871 | dev_dbg(&port->dev, "%s - port %d, cmd 0x%.4x\n", __func__, port->number, cmd); |
871 | 872 | ||
872 | switch (cmd) { | 873 | switch (cmd) { |
873 | /* This code comes from drivers/char/serial.c and ftdi_sio.c */ | 874 | /* This code comes from drivers/char/serial.c and ftdi_sio.c */ |
@@ -902,7 +903,7 @@ static int cypress_ioctl(struct tty_struct *tty, | |||
902 | default: | 903 | default: |
903 | break; | 904 | break; |
904 | } | 905 | } |
905 | dbg("%s - arg not supported - it was 0x%04x - check include/asm/ioctls.h", __func__, cmd); | 906 | dev_dbg(&port->dev, "%s - arg not supported - it was 0x%04x - check include/asm/ioctls.h\n", __func__, cmd); |
906 | return -ENOIOCTLCMD; | 907 | return -ENOIOCTLCMD; |
907 | } /* cypress_ioctl */ | 908 | } /* cypress_ioctl */ |
908 | 909 | ||
@@ -911,6 +912,7 @@ static void cypress_set_termios(struct tty_struct *tty, | |||
911 | struct usb_serial_port *port, struct ktermios *old_termios) | 912 | struct usb_serial_port *port, struct ktermios *old_termios) |
912 | { | 913 | { |
913 | struct cypress_private *priv = usb_get_serial_port_data(port); | 914 | struct cypress_private *priv = usb_get_serial_port_data(port); |
915 | struct device *dev = &port->dev; | ||
914 | int data_bits, stop_bits, parity_type, parity_enable; | 916 | int data_bits, stop_bits, parity_type, parity_enable; |
915 | unsigned cflag, iflag; | 917 | unsigned cflag, iflag; |
916 | unsigned long flags; | 918 | unsigned long flags; |
@@ -984,23 +986,21 @@ static void cypress_set_termios(struct tty_struct *tty, | |||
984 | data_bits = 3; | 986 | data_bits = 3; |
985 | break; | 987 | break; |
986 | default: | 988 | default: |
987 | dev_err(&port->dev, "%s - CSIZE was set, but not CS5-CS8\n", | 989 | dev_err(dev, "%s - CSIZE was set, but not CS5-CS8\n", __func__); |
988 | __func__); | ||
989 | data_bits = 3; | 990 | data_bits = 3; |
990 | } | 991 | } |
991 | spin_lock_irqsave(&priv->lock, flags); | 992 | spin_lock_irqsave(&priv->lock, flags); |
992 | oldlines = priv->line_control; | 993 | oldlines = priv->line_control; |
993 | if ((cflag & CBAUD) == B0) { | 994 | if ((cflag & CBAUD) == B0) { |
994 | /* drop dtr and rts */ | 995 | /* drop dtr and rts */ |
995 | dbg("%s - dropping the lines, baud rate 0bps", __func__); | 996 | dev_dbg(dev, "%s - dropping the lines, baud rate 0bps\n", __func__); |
996 | priv->line_control &= ~(CONTROL_DTR | CONTROL_RTS); | 997 | priv->line_control &= ~(CONTROL_DTR | CONTROL_RTS); |
997 | } else | 998 | } else |
998 | priv->line_control = (CONTROL_DTR | CONTROL_RTS); | 999 | priv->line_control = (CONTROL_DTR | CONTROL_RTS); |
999 | spin_unlock_irqrestore(&priv->lock, flags); | 1000 | spin_unlock_irqrestore(&priv->lock, flags); |
1000 | 1001 | ||
1001 | dbg("%s - sending %d stop_bits, %d parity_enable, %d parity_type, " | 1002 | dev_dbg(dev, "%s - sending %d stop_bits, %d parity_enable, %d parity_type, %d data_bits (+5)\n", |
1002 | "%d data_bits (+5)", __func__, stop_bits, | 1003 | __func__, stop_bits, parity_enable, parity_type, data_bits); |
1003 | parity_enable, parity_type, data_bits); | ||
1004 | 1004 | ||
1005 | cypress_serial_control(tty, port, tty_get_baud_rate(tty), | 1005 | cypress_serial_control(tty, port, tty_get_baud_rate(tty), |
1006 | data_bits, stop_bits, | 1006 | data_bits, stop_bits, |
@@ -1017,8 +1017,7 @@ static void cypress_set_termios(struct tty_struct *tty, | |||
1017 | 1017 | ||
1018 | spin_lock_irqsave(&priv->lock, flags); | 1018 | spin_lock_irqsave(&priv->lock, flags); |
1019 | if (priv->chiptype == CT_EARTHMATE && priv->baud_rate == 4800) { | 1019 | if (priv->chiptype == CT_EARTHMATE && priv->baud_rate == 4800) { |
1020 | dbg("Using custom termios settings for a baud rate of " | 1020 | dev_dbg(dev, "Using custom termios settings for a baud rate of 4800bps.\n"); |
1021 | "4800bps."); | ||
1022 | /* define custom termios settings for NMEA protocol */ | 1021 | /* define custom termios settings for NMEA protocol */ |
1023 | 1022 | ||
1024 | tty->termios.c_iflag /* input modes - */ | 1023 | tty->termios.c_iflag /* input modes - */ |
@@ -1067,7 +1066,7 @@ static int cypress_chars_in_buffer(struct tty_struct *tty) | |||
1067 | chars = kfifo_len(&priv->write_fifo); | 1066 | chars = kfifo_len(&priv->write_fifo); |
1068 | spin_unlock_irqrestore(&priv->lock, flags); | 1067 | spin_unlock_irqrestore(&priv->lock, flags); |
1069 | 1068 | ||
1070 | dbg("%s - returns %d", __func__, chars); | 1069 | dev_dbg(&port->dev, "%s - returns %d\n", __func__, chars); |
1071 | return chars; | 1070 | return chars; |
1072 | } | 1071 | } |
1073 | 1072 | ||
@@ -1112,6 +1111,7 @@ static void cypress_read_int_callback(struct urb *urb) | |||
1112 | { | 1111 | { |
1113 | struct usb_serial_port *port = urb->context; | 1112 | struct usb_serial_port *port = urb->context; |
1114 | struct cypress_private *priv = usb_get_serial_port_data(port); | 1113 | struct cypress_private *priv = usb_get_serial_port_data(port); |
1114 | struct device *dev = &urb->dev->dev; | ||
1115 | struct tty_struct *tty; | 1115 | struct tty_struct *tty; |
1116 | unsigned char *data = urb->transfer_buffer; | 1116 | unsigned char *data = urb->transfer_buffer; |
1117 | unsigned long flags; | 1117 | unsigned long flags; |
@@ -1135,16 +1135,15 @@ static void cypress_read_int_callback(struct urb *urb) | |||
1135 | /* FALLS THROUGH */ | 1135 | /* FALLS THROUGH */ |
1136 | default: | 1136 | default: |
1137 | /* something ugly is going on... */ | 1137 | /* something ugly is going on... */ |
1138 | dev_err(&urb->dev->dev, | 1138 | dev_err(dev, "%s - unexpected nonzero read status received: %d\n", |
1139 | "%s - unexpected nonzero read status received: %d\n", | 1139 | __func__, status); |
1140 | __func__, status); | ||
1141 | cypress_set_dead(port); | 1140 | cypress_set_dead(port); |
1142 | return; | 1141 | return; |
1143 | } | 1142 | } |
1144 | 1143 | ||
1145 | spin_lock_irqsave(&priv->lock, flags); | 1144 | spin_lock_irqsave(&priv->lock, flags); |
1146 | if (priv->rx_flags & THROTTLED) { | 1145 | if (priv->rx_flags & THROTTLED) { |
1147 | dbg("%s - now throttling", __func__); | 1146 | dev_dbg(dev, "%s - now throttling\n", __func__); |
1148 | priv->rx_flags |= ACTUALLY_THROTTLED; | 1147 | priv->rx_flags |= ACTUALLY_THROTTLED; |
1149 | spin_unlock_irqrestore(&priv->lock, flags); | 1148 | spin_unlock_irqrestore(&priv->lock, flags); |
1150 | return; | 1149 | return; |
@@ -1153,7 +1152,7 @@ static void cypress_read_int_callback(struct urb *urb) | |||
1153 | 1152 | ||
1154 | tty = tty_port_tty_get(&port->port); | 1153 | tty = tty_port_tty_get(&port->port); |
1155 | if (!tty) { | 1154 | if (!tty) { |
1156 | dbg("%s - bad tty pointer - exiting", __func__); | 1155 | dev_dbg(dev, "%s - bad tty pointer - exiting\n", __func__); |
1157 | return; | 1156 | return; |
1158 | } | 1157 | } |
1159 | 1158 | ||
@@ -1180,13 +1179,13 @@ static void cypress_read_int_callback(struct urb *urb) | |||
1180 | } | 1179 | } |
1181 | spin_unlock_irqrestore(&priv->lock, flags); | 1180 | spin_unlock_irqrestore(&priv->lock, flags); |
1182 | if (result < bytes) { | 1181 | if (result < bytes) { |
1183 | dbg("%s - wrong packet size - received %d bytes but packet " | 1182 | dev_dbg(dev, |
1184 | "said %d bytes", __func__, result, bytes); | 1183 | "%s - wrong packet size - received %d bytes but packet said %d bytes\n", |
1184 | __func__, result, bytes); | ||
1185 | goto continue_read; | 1185 | goto continue_read; |
1186 | } | 1186 | } |
1187 | 1187 | ||
1188 | usb_serial_debug_data(debug, &port->dev, __func__, | 1188 | usb_serial_debug_data(&port->dev, __func__, urb->actual_length, data); |
1189 | urb->actual_length, data); | ||
1190 | 1189 | ||
1191 | spin_lock_irqsave(&priv->lock, flags); | 1190 | spin_lock_irqsave(&priv->lock, flags); |
1192 | /* check to see if status has changed */ | 1191 | /* check to see if status has changed */ |
@@ -1202,7 +1201,7 @@ static void cypress_read_int_callback(struct urb *urb) | |||
1202 | * though */ | 1201 | * though */ |
1203 | if (tty && !(tty->termios.c_cflag & CLOCAL) && | 1202 | if (tty && !(tty->termios.c_cflag & CLOCAL) && |
1204 | !(priv->current_status & UART_CD)) { | 1203 | !(priv->current_status & UART_CD)) { |
1205 | dbg("%s - calling hangup", __func__); | 1204 | dev_dbg(dev, "%s - calling hangup\n", __func__); |
1206 | tty_hangup(tty); | 1205 | tty_hangup(tty); |
1207 | goto continue_read; | 1206 | goto continue_read; |
1208 | } | 1207 | } |
@@ -1215,7 +1214,7 @@ static void cypress_read_int_callback(struct urb *urb) | |||
1215 | if (priv->current_status & CYP_ERROR) { | 1214 | if (priv->current_status & CYP_ERROR) { |
1216 | spin_unlock_irqrestore(&priv->lock, flags); | 1215 | spin_unlock_irqrestore(&priv->lock, flags); |
1217 | tty_flag = TTY_PARITY; | 1216 | tty_flag = TTY_PARITY; |
1218 | dbg("%s - Parity Error detected", __func__); | 1217 | dev_dbg(dev, "%s - Parity Error detected\n", __func__); |
1219 | } else | 1218 | } else |
1220 | spin_unlock_irqrestore(&priv->lock, flags); | 1219 | spin_unlock_irqrestore(&priv->lock, flags); |
1221 | 1220 | ||
@@ -1246,9 +1245,8 @@ continue_read: | |||
1246 | priv->read_urb_interval); | 1245 | priv->read_urb_interval); |
1247 | result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); | 1246 | result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); |
1248 | if (result && result != -EPERM) { | 1247 | if (result && result != -EPERM) { |
1249 | dev_err(&urb->dev->dev, "%s - failed resubmitting " | 1248 | dev_err(dev, "%s - failed resubmitting read urb, error %d\n", |
1250 | "read urb, error %d\n", __func__, | 1249 | __func__, result); |
1251 | result); | ||
1252 | cypress_set_dead(port); | 1250 | cypress_set_dead(port); |
1253 | } | 1251 | } |
1254 | } | 1252 | } |
@@ -1259,6 +1257,7 @@ static void cypress_write_int_callback(struct urb *urb) | |||
1259 | { | 1257 | { |
1260 | struct usb_serial_port *port = urb->context; | 1258 | struct usb_serial_port *port = urb->context; |
1261 | struct cypress_private *priv = usb_get_serial_port_data(port); | 1259 | struct cypress_private *priv = usb_get_serial_port_data(port); |
1260 | struct device *dev = &urb->dev->dev; | ||
1262 | int result; | 1261 | int result; |
1263 | int status = urb->status; | 1262 | int status = urb->status; |
1264 | 1263 | ||
@@ -1270,8 +1269,8 @@ static void cypress_write_int_callback(struct urb *urb) | |||
1270 | case -ENOENT: | 1269 | case -ENOENT: |
1271 | case -ESHUTDOWN: | 1270 | case -ESHUTDOWN: |
1272 | /* this urb is terminated, clean up */ | 1271 | /* this urb is terminated, clean up */ |
1273 | dbg("%s - urb shutting down with status: %d", | 1272 | dev_dbg(dev, "%s - urb shutting down with status: %d\n", |
1274 | __func__, status); | 1273 | __func__, status); |
1275 | priv->write_urb_in_use = 0; | 1274 | priv->write_urb_in_use = 0; |
1276 | return; | 1275 | return; |
1277 | case -EPIPE: /* no break needed; clear halt and resubmit */ | 1276 | case -EPIPE: /* no break needed; clear halt and resubmit */ |
@@ -1279,21 +1278,19 @@ static void cypress_write_int_callback(struct urb *urb) | |||
1279 | break; | 1278 | break; |
1280 | usb_clear_halt(port->serial->dev, 0x02); | 1279 | usb_clear_halt(port->serial->dev, 0x02); |
1281 | /* error in the urb, so we have to resubmit it */ | 1280 | /* error in the urb, so we have to resubmit it */ |
1282 | dbg("%s - nonzero write bulk status received: %d", | 1281 | dev_dbg(dev, "%s - nonzero write bulk status received: %d\n", |
1283 | __func__, status); | 1282 | __func__, status); |
1284 | port->interrupt_out_urb->transfer_buffer_length = 1; | 1283 | port->interrupt_out_urb->transfer_buffer_length = 1; |
1285 | result = usb_submit_urb(port->interrupt_out_urb, GFP_ATOMIC); | 1284 | result = usb_submit_urb(port->interrupt_out_urb, GFP_ATOMIC); |
1286 | if (!result) | 1285 | if (!result) |
1287 | return; | 1286 | return; |
1288 | dev_err(&urb->dev->dev, | 1287 | dev_err(dev, "%s - failed resubmitting write urb, error %d\n", |
1289 | "%s - failed resubmitting write urb, error %d\n", | 1288 | __func__, result); |
1290 | __func__, result); | ||
1291 | cypress_set_dead(port); | 1289 | cypress_set_dead(port); |
1292 | break; | 1290 | break; |
1293 | default: | 1291 | default: |
1294 | dev_err(&urb->dev->dev, | 1292 | dev_err(dev, "%s - unexpected nonzero write status received: %d\n", |
1295 | "%s - unexpected nonzero write status received: %d\n", | 1293 | __func__, status); |
1296 | __func__, status); | ||
1297 | cypress_set_dead(port); | 1294 | cypress_set_dead(port); |
1298 | break; | 1295 | break; |
1299 | } | 1296 | } |
@@ -1310,8 +1307,6 @@ MODULE_DESCRIPTION(DRIVER_DESC); | |||
1310 | MODULE_VERSION(DRIVER_VERSION); | 1307 | MODULE_VERSION(DRIVER_VERSION); |
1311 | MODULE_LICENSE("GPL"); | 1308 | MODULE_LICENSE("GPL"); |
1312 | 1309 | ||
1313 | module_param(debug, bool, S_IRUGO | S_IWUSR); | ||
1314 | MODULE_PARM_DESC(debug, "Debug enabled or not"); | ||
1315 | module_param(stats, bool, S_IRUGO | S_IWUSR); | 1310 | module_param(stats, bool, S_IRUGO | S_IWUSR); |
1316 | MODULE_PARM_DESC(stats, "Enable statistics or not"); | 1311 | MODULE_PARM_DESC(stats, "Enable statistics or not"); |
1317 | module_param(interval, int, S_IRUGO | S_IWUSR); | 1312 | module_param(interval, int, S_IRUGO | S_IWUSR); |
diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c index afd9d2ec577b..c86f68c6b078 100644 --- a/drivers/usb/serial/digi_acceleport.c +++ b/drivers/usb/serial/digi_acceleport.c | |||
@@ -249,10 +249,6 @@ static int digi_read_inb_callback(struct urb *urb); | |||
249 | static int digi_read_oob_callback(struct urb *urb); | 249 | static int digi_read_oob_callback(struct urb *urb); |
250 | 250 | ||
251 | 251 | ||
252 | /* Statics */ | ||
253 | |||
254 | static bool debug; | ||
255 | |||
256 | static const struct usb_device_id id_table_combined[] = { | 252 | static const struct usb_device_id id_table_combined[] = { |
257 | { USB_DEVICE(DIGI_VENDOR_ID, DIGI_2_ID) }, | 253 | { USB_DEVICE(DIGI_VENDOR_ID, DIGI_2_ID) }, |
258 | { USB_DEVICE(DIGI_VENDOR_ID, DIGI_4_ID) }, | 254 | { USB_DEVICE(DIGI_VENDOR_ID, DIGI_4_ID) }, |
@@ -404,14 +400,15 @@ static void digi_wakeup_write(struct usb_serial_port *port) | |||
404 | static int digi_write_oob_command(struct usb_serial_port *port, | 400 | static int digi_write_oob_command(struct usb_serial_port *port, |
405 | unsigned char *buf, int count, int interruptible) | 401 | unsigned char *buf, int count, int interruptible) |
406 | { | 402 | { |
407 | |||
408 | int ret = 0; | 403 | int ret = 0; |
409 | int len; | 404 | int len; |
410 | struct usb_serial_port *oob_port = (struct usb_serial_port *)((struct digi_serial *)(usb_get_serial_data(port->serial)))->ds_oob_port; | 405 | struct usb_serial_port *oob_port = (struct usb_serial_port *)((struct digi_serial *)(usb_get_serial_data(port->serial)))->ds_oob_port; |
411 | struct digi_port *oob_priv = usb_get_serial_port_data(oob_port); | 406 | struct digi_port *oob_priv = usb_get_serial_port_data(oob_port); |
412 | unsigned long flags = 0; | 407 | unsigned long flags = 0; |
413 | 408 | ||
414 | dbg("digi_write_oob_command: TOP: port=%d, count=%d", oob_priv->dp_port_num, count); | 409 | dev_dbg(&port->dev, |
410 | "digi_write_oob_command: TOP: port=%d, count=%d\n", | ||
411 | oob_priv->dp_port_num, count); | ||
415 | 412 | ||
416 | spin_lock_irqsave(&oob_priv->dp_port_lock, flags); | 413 | spin_lock_irqsave(&oob_priv->dp_port_lock, flags); |
417 | while (count > 0) { | 414 | while (count > 0) { |
@@ -467,7 +464,7 @@ static int digi_write_inb_command(struct usb_serial_port *port, | |||
467 | unsigned char *data = port->write_urb->transfer_buffer; | 464 | unsigned char *data = port->write_urb->transfer_buffer; |
468 | unsigned long flags = 0; | 465 | unsigned long flags = 0; |
469 | 466 | ||
470 | dbg("digi_write_inb_command: TOP: port=%d, count=%d", | 467 | dev_dbg(&port->dev, "digi_write_inb_command: TOP: port=%d, count=%d\n", |
471 | priv->dp_port_num, count); | 468 | priv->dp_port_num, count); |
472 | 469 | ||
473 | if (timeout) | 470 | if (timeout) |
@@ -549,7 +546,8 @@ static int digi_set_modem_signals(struct usb_serial_port *port, | |||
549 | unsigned long flags = 0; | 546 | unsigned long flags = 0; |
550 | 547 | ||
551 | 548 | ||
552 | dbg("digi_set_modem_signals: TOP: port=%d, modem_signals=0x%x", | 549 | dev_dbg(&port->dev, |
550 | "digi_set_modem_signals: TOP: port=%d, modem_signals=0x%x\n", | ||
553 | port_priv->dp_port_num, modem_signals); | 551 | port_priv->dp_port_num, modem_signals); |
554 | 552 | ||
555 | spin_lock_irqsave(&oob_priv->dp_port_lock, flags); | 553 | spin_lock_irqsave(&oob_priv->dp_port_lock, flags); |
@@ -687,6 +685,7 @@ static void digi_set_termios(struct tty_struct *tty, | |||
687 | struct usb_serial_port *port, struct ktermios *old_termios) | 685 | struct usb_serial_port *port, struct ktermios *old_termios) |
688 | { | 686 | { |
689 | struct digi_port *priv = usb_get_serial_port_data(port); | 687 | struct digi_port *priv = usb_get_serial_port_data(port); |
688 | struct device *dev = &port->dev; | ||
690 | unsigned int iflag = tty->termios.c_iflag; | 689 | unsigned int iflag = tty->termios.c_iflag; |
691 | unsigned int cflag = tty->termios.c_cflag; | 690 | unsigned int cflag = tty->termios.c_cflag; |
692 | unsigned int old_iflag = old_termios->c_iflag; | 691 | unsigned int old_iflag = old_termios->c_iflag; |
@@ -697,7 +696,9 @@ static void digi_set_termios(struct tty_struct *tty, | |||
697 | int i = 0; | 696 | int i = 0; |
698 | speed_t baud; | 697 | speed_t baud; |
699 | 698 | ||
700 | dbg("digi_set_termios: TOP: port=%d, iflag=0x%x, old_iflag=0x%x, cflag=0x%x, old_cflag=0x%x", priv->dp_port_num, iflag, old_iflag, cflag, old_cflag); | 699 | dev_dbg(dev, |
700 | "digi_set_termios: TOP: port=%d, iflag=0x%x, old_iflag=0x%x, cflag=0x%x, old_cflag=0x%x\n", | ||
701 | priv->dp_port_num, iflag, old_iflag, cflag, old_cflag); | ||
701 | 702 | ||
702 | /* set baud rate */ | 703 | /* set baud rate */ |
703 | baud = tty_get_baud_rate(tty); | 704 | baud = tty_get_baud_rate(tty); |
@@ -773,7 +774,8 @@ static void digi_set_termios(struct tty_struct *tty, | |||
773 | case CS7: arg = DIGI_WORD_SIZE_7; break; | 774 | case CS7: arg = DIGI_WORD_SIZE_7; break; |
774 | case CS8: arg = DIGI_WORD_SIZE_8; break; | 775 | case CS8: arg = DIGI_WORD_SIZE_8; break; |
775 | default: | 776 | default: |
776 | dbg("digi_set_termios: can't handle word size %d", | 777 | dev_dbg(dev, |
778 | "digi_set_termios: can't handle word size %d\n", | ||
777 | (cflag&CSIZE)); | 779 | (cflag&CSIZE)); |
778 | break; | 780 | break; |
779 | } | 781 | } |
@@ -866,7 +868,7 @@ static void digi_set_termios(struct tty_struct *tty, | |||
866 | } | 868 | } |
867 | ret = digi_write_oob_command(port, buf, i, 1); | 869 | ret = digi_write_oob_command(port, buf, i, 1); |
868 | if (ret != 0) | 870 | if (ret != 0) |
869 | dbg("digi_set_termios: write oob failed, ret=%d", ret); | 871 | dev_dbg(dev, "digi_set_termios: write oob failed, ret=%d\n", ret); |
870 | tty_encode_baud_rate(tty, baud, baud); | 872 | tty_encode_baud_rate(tty, baud, baud); |
871 | } | 873 | } |
872 | 874 | ||
@@ -922,7 +924,8 @@ static int digi_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
922 | unsigned char *data = port->write_urb->transfer_buffer; | 924 | unsigned char *data = port->write_urb->transfer_buffer; |
923 | unsigned long flags = 0; | 925 | unsigned long flags = 0; |
924 | 926 | ||
925 | dbg("digi_write: TOP: port=%d, count=%d, in_interrupt=%ld", | 927 | dev_dbg(&port->dev, |
928 | "digi_write: TOP: port=%d, count=%d, in_interrupt=%ld\n", | ||
926 | priv->dp_port_num, count, in_interrupt()); | 929 | priv->dp_port_num, count, in_interrupt()); |
927 | 930 | ||
928 | /* copy user data (which can sleep) before getting spin lock */ | 931 | /* copy user data (which can sleep) before getting spin lock */ |
@@ -981,7 +984,7 @@ static int digi_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
981 | dev_err_console(port, | 984 | dev_err_console(port, |
982 | "%s: usb_submit_urb failed, ret=%d, port=%d\n", | 985 | "%s: usb_submit_urb failed, ret=%d, port=%d\n", |
983 | __func__, ret, priv->dp_port_num); | 986 | __func__, ret, priv->dp_port_num); |
984 | dbg("digi_write: returning %d", ret); | 987 | dev_dbg(&port->dev, "digi_write: returning %d\n", ret); |
985 | return ret; | 988 | return ret; |
986 | 989 | ||
987 | } | 990 | } |
@@ -1012,7 +1015,7 @@ static void digi_write_bulk_callback(struct urb *urb) | |||
1012 | 1015 | ||
1013 | /* handle oob callback */ | 1016 | /* handle oob callback */ |
1014 | if (priv->dp_port_num == serial_priv->ds_oob_port_num) { | 1017 | if (priv->dp_port_num == serial_priv->ds_oob_port_num) { |
1015 | dbg("digi_write_bulk_callback: oob callback"); | 1018 | dev_dbg(&port->dev, "digi_write_bulk_callback: oob callback\n"); |
1016 | spin_lock(&priv->dp_port_lock); | 1019 | spin_lock(&priv->dp_port_lock); |
1017 | priv->dp_write_urb_in_use = 0; | 1020 | priv->dp_write_urb_in_use = 0; |
1018 | wake_up_interruptible(&port->write_wait); | 1021 | wake_up_interruptible(&port->write_wait); |
@@ -1066,7 +1069,7 @@ static int digi_write_room(struct tty_struct *tty) | |||
1066 | room = port->bulk_out_size - 2 - priv->dp_out_buf_len; | 1069 | room = port->bulk_out_size - 2 - priv->dp_out_buf_len; |
1067 | 1070 | ||
1068 | spin_unlock_irqrestore(&priv->dp_port_lock, flags); | 1071 | spin_unlock_irqrestore(&priv->dp_port_lock, flags); |
1069 | dbg("digi_write_room: port=%d, room=%d", priv->dp_port_num, room); | 1072 | dev_dbg(&port->dev, "digi_write_room: port=%d, room=%d\n", priv->dp_port_num, room); |
1070 | return room; | 1073 | return room; |
1071 | 1074 | ||
1072 | } | 1075 | } |
@@ -1077,12 +1080,12 @@ static int digi_chars_in_buffer(struct tty_struct *tty) | |||
1077 | struct digi_port *priv = usb_get_serial_port_data(port); | 1080 | struct digi_port *priv = usb_get_serial_port_data(port); |
1078 | 1081 | ||
1079 | if (priv->dp_write_urb_in_use) { | 1082 | if (priv->dp_write_urb_in_use) { |
1080 | dbg("digi_chars_in_buffer: port=%d, chars=%d", | 1083 | dev_dbg(&port->dev, "digi_chars_in_buffer: port=%d, chars=%d\n", |
1081 | priv->dp_port_num, port->bulk_out_size - 2); | 1084 | priv->dp_port_num, port->bulk_out_size - 2); |
1082 | /* return(port->bulk_out_size - 2); */ | 1085 | /* return(port->bulk_out_size - 2); */ |
1083 | return 256; | 1086 | return 256; |
1084 | } else { | 1087 | } else { |
1085 | dbg("digi_chars_in_buffer: port=%d, chars=%d", | 1088 | dev_dbg(&port->dev, "digi_chars_in_buffer: port=%d, chars=%d\n", |
1086 | priv->dp_port_num, priv->dp_out_buf_len); | 1089 | priv->dp_port_num, priv->dp_out_buf_len); |
1087 | return priv->dp_out_buf_len; | 1090 | return priv->dp_out_buf_len; |
1088 | } | 1091 | } |
@@ -1120,7 +1123,7 @@ static int digi_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
1120 | 1123 | ||
1121 | ret = digi_write_oob_command(port, buf, 8, 1); | 1124 | ret = digi_write_oob_command(port, buf, 8, 1); |
1122 | if (ret != 0) | 1125 | if (ret != 0) |
1123 | dbg("digi_open: write oob failed, ret=%d", ret); | 1126 | dev_dbg(&port->dev, "digi_open: write oob failed, ret=%d\n", ret); |
1124 | 1127 | ||
1125 | /* set termios settings */ | 1128 | /* set termios settings */ |
1126 | if (tty) { | 1129 | if (tty) { |
@@ -1180,7 +1183,7 @@ static void digi_close(struct usb_serial_port *port) | |||
1180 | 1183 | ||
1181 | ret = digi_write_oob_command(port, buf, 20, 0); | 1184 | ret = digi_write_oob_command(port, buf, 20, 0); |
1182 | if (ret != 0) | 1185 | if (ret != 0) |
1183 | dbg("digi_close: write oob failed, ret=%d", ret); | 1186 | dev_dbg(&port->dev, "digi_close: write oob failed, ret=%d\n", ret); |
1184 | 1187 | ||
1185 | /* wait for final commands on oob port to complete */ | 1188 | /* wait for final commands on oob port to complete */ |
1186 | prepare_to_wait(&priv->dp_flush_wait, &wait, | 1189 | prepare_to_wait(&priv->dp_flush_wait, &wait, |
@@ -1448,9 +1451,9 @@ static int digi_read_inb_callback(struct urb *urb) | |||
1448 | tty_kref_put(tty); | 1451 | tty_kref_put(tty); |
1449 | 1452 | ||
1450 | if (opcode == DIGI_CMD_RECEIVE_DISABLE) | 1453 | if (opcode == DIGI_CMD_RECEIVE_DISABLE) |
1451 | dbg("%s: got RECEIVE_DISABLE", __func__); | 1454 | dev_dbg(&port->dev, "%s: got RECEIVE_DISABLE\n", __func__); |
1452 | else if (opcode != DIGI_CMD_RECEIVE_DATA) | 1455 | else if (opcode != DIGI_CMD_RECEIVE_DATA) |
1453 | dbg("%s: unknown opcode: %d", __func__, opcode); | 1456 | dev_dbg(&port->dev, "%s: unknown opcode: %d\n", __func__, opcode); |
1454 | 1457 | ||
1455 | return throttled ? 1 : 0; | 1458 | return throttled ? 1 : 0; |
1456 | 1459 | ||
@@ -1484,7 +1487,7 @@ static int digi_read_oob_callback(struct urb *urb) | |||
1484 | status = ((unsigned char *)urb->transfer_buffer)[i++]; | 1487 | status = ((unsigned char *)urb->transfer_buffer)[i++]; |
1485 | val = ((unsigned char *)urb->transfer_buffer)[i++]; | 1488 | val = ((unsigned char *)urb->transfer_buffer)[i++]; |
1486 | 1489 | ||
1487 | dbg("digi_read_oob_callback: opcode=%d, line=%d, status=%d, val=%d", | 1490 | dev_dbg(&port->dev, "digi_read_oob_callback: opcode=%d, line=%d, status=%d, val=%d\n", |
1488 | opcode, line, status, val); | 1491 | opcode, line, status, val); |
1489 | 1492 | ||
1490 | if (status != 0 || line >= serial->type->num_ports) | 1493 | if (status != 0 || line >= serial->type->num_ports) |
@@ -1552,6 +1555,3 @@ module_usb_serial_driver(serial_drivers, id_table_combined); | |||
1552 | MODULE_AUTHOR(DRIVER_AUTHOR); | 1555 | MODULE_AUTHOR(DRIVER_AUTHOR); |
1553 | MODULE_DESCRIPTION(DRIVER_DESC); | 1556 | MODULE_DESCRIPTION(DRIVER_DESC); |
1554 | MODULE_LICENSE("GPL"); | 1557 | MODULE_LICENSE("GPL"); |
1555 | |||
1556 | module_param(debug, bool, S_IRUGO | S_IWUSR); | ||
1557 | MODULE_PARM_DESC(debug, "Debug enabled or not"); | ||
diff --git a/drivers/usb/serial/empeg.c b/drivers/usb/serial/empeg.c index 34e86383090a..43ede4a1e12c 100644 --- a/drivers/usb/serial/empeg.c +++ b/drivers/usb/serial/empeg.c | |||
@@ -28,8 +28,6 @@ | |||
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 bool debug; | ||
32 | |||
33 | /* | 31 | /* |
34 | * Version Information | 32 | * Version Information |
35 | */ | 33 | */ |
@@ -134,6 +132,3 @@ module_usb_serial_driver(serial_drivers, id_table); | |||
134 | MODULE_AUTHOR(DRIVER_AUTHOR); | 132 | MODULE_AUTHOR(DRIVER_AUTHOR); |
135 | MODULE_DESCRIPTION(DRIVER_DESC); | 133 | MODULE_DESCRIPTION(DRIVER_DESC); |
136 | MODULE_LICENSE("GPL"); | 134 | MODULE_LICENSE("GPL"); |
137 | |||
138 | module_param(debug, bool, S_IRUGO | S_IWUSR); | ||
139 | MODULE_PARM_DESC(debug, "Debug enabled or not"); | ||
diff --git a/drivers/usb/serial/ezusb.c b/drivers/usb/serial/ezusb.c deleted file mode 100644 index 800e8eb60003..000000000000 --- a/drivers/usb/serial/ezusb.c +++ /dev/null | |||
@@ -1,59 +0,0 @@ | |||
1 | /* | ||
2 | * EZ-USB specific functions used by some of the USB to Serial drivers. | ||
3 | * | ||
4 | * Copyright (C) 1999 - 2002 Greg Kroah-Hartman (greg@kroah.com) | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License version | ||
8 | * 2 as published by the Free Software Foundation. | ||
9 | */ | ||
10 | |||
11 | #include <linux/kernel.h> | ||
12 | #include <linux/errno.h> | ||
13 | #include <linux/init.h> | ||
14 | #include <linux/slab.h> | ||
15 | #include <linux/tty.h> | ||
16 | #include <linux/module.h> | ||
17 | #include <linux/usb.h> | ||
18 | #include <linux/usb/serial.h> | ||
19 | |||
20 | /* EZ-USB Control and Status Register. Bit 0 controls 8051 reset */ | ||
21 | #define CPUCS_REG 0x7F92 | ||
22 | |||
23 | int ezusb_writememory(struct usb_serial *serial, int address, | ||
24 | unsigned char *data, int length, __u8 request) | ||
25 | { | ||
26 | int result; | ||
27 | unsigned char *transfer_buffer; | ||
28 | |||
29 | if (!serial->dev) { | ||
30 | printk(KERN_ERR "ezusb: %s - no physical device present, " | ||
31 | "failing.\n", __func__); | ||
32 | return -ENODEV; | ||
33 | } | ||
34 | |||
35 | transfer_buffer = kmemdup(data, length, GFP_KERNEL); | ||
36 | if (!transfer_buffer) { | ||
37 | dev_err(&serial->dev->dev, "%s - kmalloc(%d) failed.\n", | ||
38 | __func__, length); | ||
39 | return -ENOMEM; | ||
40 | } | ||
41 | result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), | ||
42 | request, 0x40, address, 0, transfer_buffer, length, 3000); | ||
43 | kfree(transfer_buffer); | ||
44 | return result; | ||
45 | } | ||
46 | EXPORT_SYMBOL_GPL(ezusb_writememory); | ||
47 | |||
48 | int ezusb_set_reset(struct usb_serial *serial, unsigned char reset_bit) | ||
49 | { | ||
50 | int response; | ||
51 | |||
52 | response = ezusb_writememory(serial, CPUCS_REG, &reset_bit, 1, 0xa0); | ||
53 | if (response < 0) | ||
54 | dev_err(&serial->dev->dev, "%s- %d failed\n", | ||
55 | __func__, reset_bit); | ||
56 | return response; | ||
57 | } | ||
58 | EXPORT_SYMBOL_GPL(ezusb_set_reset); | ||
59 | |||
diff --git a/drivers/usb/serial/f81232.c b/drivers/usb/serial/f81232.c index 79451ee12ca0..244477107e2f 100644 --- a/drivers/usb/serial/f81232.c +++ b/drivers/usb/serial/f81232.c | |||
@@ -25,8 +25,6 @@ | |||
25 | #include <linux/usb.h> | 25 | #include <linux/usb.h> |
26 | #include <linux/usb/serial.h> | 26 | #include <linux/usb/serial.h> |
27 | 27 | ||
28 | static bool debug; | ||
29 | |||
30 | static const struct usb_device_id id_table[] = { | 28 | static const struct usb_device_id id_table[] = { |
31 | { USB_DEVICE(0x1934, 0x0706) }, | 29 | { USB_DEVICE(0x1934, 0x0706) }, |
32 | { } /* Terminating entry */ | 30 | { } /* Terminating entry */ |
@@ -85,7 +83,7 @@ static void f81232_read_int_callback(struct urb *urb) | |||
85 | goto exit; | 83 | goto exit; |
86 | } | 84 | } |
87 | 85 | ||
88 | usb_serial_debug_data(debug, &port->dev, __func__, | 86 | usb_serial_debug_data(&port->dev, __func__, |
89 | urb->actual_length, urb->transfer_buffer); | 87 | urb->actual_length, urb->transfer_buffer); |
90 | 88 | ||
91 | f81232_update_line_status(port, data, actual_length); | 89 | f81232_update_line_status(port, data, actual_length); |
@@ -389,7 +387,3 @@ module_usb_serial_driver(serial_drivers, id_table); | |||
389 | MODULE_DESCRIPTION("Fintek F81232 USB to serial adaptor driver"); | 387 | MODULE_DESCRIPTION("Fintek F81232 USB to serial adaptor driver"); |
390 | MODULE_AUTHOR("Greg Kroah-Hartman <gregkh@linuxfoundation.org"); | 388 | MODULE_AUTHOR("Greg Kroah-Hartman <gregkh@linuxfoundation.org"); |
391 | MODULE_LICENSE("GPL v2"); | 389 | MODULE_LICENSE("GPL v2"); |
392 | |||
393 | module_param(debug, bool, S_IRUGO | S_IWUSR); | ||
394 | MODULE_PARM_DESC(debug, "Debug enabled or not"); | ||
395 | |||
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index 0c8d1c226273..be845873e23d 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c | |||
@@ -48,14 +48,9 @@ | |||
48 | #include "ftdi_sio.h" | 48 | #include "ftdi_sio.h" |
49 | #include "ftdi_sio_ids.h" | 49 | #include "ftdi_sio_ids.h" |
50 | 50 | ||
51 | /* | ||
52 | * Version Information | ||
53 | */ | ||
54 | #define DRIVER_VERSION "v1.6.0" | ||
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>" | 51 | #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" | 52 | #define DRIVER_DESC "USB FTDI Serial Converters Driver" |
57 | 53 | ||
58 | static bool debug; | ||
59 | static __u16 vendor = FTDI_VID; | 54 | static __u16 vendor = FTDI_VID; |
60 | static __u16 product; | 55 | static __u16 product; |
61 | 56 | ||
@@ -584,6 +579,8 @@ static struct usb_device_id id_table_combined [] = { | |||
584 | { USB_DEVICE(FTDI_VID, FTDI_IBS_PEDO_PID) }, | 579 | { USB_DEVICE(FTDI_VID, FTDI_IBS_PEDO_PID) }, |
585 | { USB_DEVICE(FTDI_VID, FTDI_IBS_PROD_PID) }, | 580 | { USB_DEVICE(FTDI_VID, FTDI_IBS_PROD_PID) }, |
586 | { USB_DEVICE(FTDI_VID, FTDI_TAVIR_STK500_PID) }, | 581 | { USB_DEVICE(FTDI_VID, FTDI_TAVIR_STK500_PID) }, |
582 | { USB_DEVICE(FTDI_VID, FTDI_TIAO_UMPA_PID), | ||
583 | .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, | ||
587 | /* | 584 | /* |
588 | * ELV devices: | 585 | * ELV devices: |
589 | */ | 586 | */ |
@@ -1063,11 +1060,12 @@ static int update_mctrl(struct usb_serial_port *port, unsigned int set, | |||
1063 | unsigned int clear) | 1060 | unsigned int clear) |
1064 | { | 1061 | { |
1065 | struct ftdi_private *priv = usb_get_serial_port_data(port); | 1062 | struct ftdi_private *priv = usb_get_serial_port_data(port); |
1063 | struct device *dev = &port->dev; | ||
1066 | unsigned urb_value; | 1064 | unsigned urb_value; |
1067 | int rv; | 1065 | int rv; |
1068 | 1066 | ||
1069 | if (((set | clear) & (TIOCM_DTR | TIOCM_RTS)) == 0) { | 1067 | if (((set | clear) & (TIOCM_DTR | TIOCM_RTS)) == 0) { |
1070 | dbg("%s - DTR|RTS not being set|cleared", __func__); | 1068 | dev_dbg(dev, "%s - DTR|RTS not being set|cleared\n", __func__); |
1071 | return 0; /* no change */ | 1069 | return 0; /* no change */ |
1072 | } | 1070 | } |
1073 | 1071 | ||
@@ -1088,18 +1086,14 @@ static int update_mctrl(struct usb_serial_port *port, unsigned int set, | |||
1088 | urb_value, priv->interface, | 1086 | urb_value, priv->interface, |
1089 | NULL, 0, WDR_TIMEOUT); | 1087 | NULL, 0, WDR_TIMEOUT); |
1090 | if (rv < 0) { | 1088 | if (rv < 0) { |
1091 | dbg("%s Error from MODEM_CTRL urb: DTR %s, RTS %s", | 1089 | dev_dbg(dev, "%s Error from MODEM_CTRL urb: DTR %s, RTS %s\n", |
1092 | __func__, | 1090 | __func__, |
1093 | (set & TIOCM_DTR) ? "HIGH" : | 1091 | (set & TIOCM_DTR) ? "HIGH" : (clear & TIOCM_DTR) ? "LOW" : "unchanged", |
1094 | (clear & TIOCM_DTR) ? "LOW" : "unchanged", | 1092 | (set & TIOCM_RTS) ? "HIGH" : (clear & TIOCM_RTS) ? "LOW" : "unchanged"); |
1095 | (set & TIOCM_RTS) ? "HIGH" : | ||
1096 | (clear & TIOCM_RTS) ? "LOW" : "unchanged"); | ||
1097 | } else { | 1093 | } else { |
1098 | dbg("%s - DTR %s, RTS %s", __func__, | 1094 | dev_dbg(dev, "%s - DTR %s, RTS %s\n", __func__, |
1099 | (set & TIOCM_DTR) ? "HIGH" : | 1095 | (set & TIOCM_DTR) ? "HIGH" : (clear & TIOCM_DTR) ? "LOW" : "unchanged", |
1100 | (clear & TIOCM_DTR) ? "LOW" : "unchanged", | 1096 | (set & TIOCM_RTS) ? "HIGH" : (clear & TIOCM_RTS) ? "LOW" : "unchanged"); |
1101 | (set & TIOCM_RTS) ? "HIGH" : | ||
1102 | (clear & TIOCM_RTS) ? "LOW" : "unchanged"); | ||
1103 | /* FIXME: locking on last_dtr_rts */ | 1097 | /* FIXME: locking on last_dtr_rts */ |
1104 | priv->last_dtr_rts = (priv->last_dtr_rts & ~clear) | set; | 1098 | priv->last_dtr_rts = (priv->last_dtr_rts & ~clear) | set; |
1105 | } | 1099 | } |
@@ -1111,6 +1105,7 @@ static __u32 get_ftdi_divisor(struct tty_struct *tty, | |||
1111 | struct usb_serial_port *port) | 1105 | struct usb_serial_port *port) |
1112 | { | 1106 | { |
1113 | struct ftdi_private *priv = usb_get_serial_port_data(port); | 1107 | struct ftdi_private *priv = usb_get_serial_port_data(port); |
1108 | struct device *dev = &port->dev; | ||
1114 | __u32 div_value = 0; | 1109 | __u32 div_value = 0; |
1115 | int div_okay = 1; | 1110 | int div_okay = 1; |
1116 | int baud; | 1111 | int baud; |
@@ -1146,7 +1141,7 @@ static __u32 get_ftdi_divisor(struct tty_struct *tty, | |||
1146 | alt_speed hack */ | 1141 | alt_speed hack */ |
1147 | 1142 | ||
1148 | baud = tty_get_baud_rate(tty); | 1143 | baud = tty_get_baud_rate(tty); |
1149 | dbg("%s - tty_get_baud_rate reports speed %d", __func__, baud); | 1144 | dev_dbg(dev, "%s - tty_get_baud_rate reports speed %d\n", __func__, baud); |
1150 | 1145 | ||
1151 | /* 2. Observe async-compatible custom_divisor hack, update baudrate | 1146 | /* 2. Observe async-compatible custom_divisor hack, update baudrate |
1152 | if needed */ | 1147 | if needed */ |
@@ -1155,8 +1150,8 @@ static __u32 get_ftdi_divisor(struct tty_struct *tty, | |||
1155 | ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) && | 1150 | ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) && |
1156 | (priv->custom_divisor)) { | 1151 | (priv->custom_divisor)) { |
1157 | baud = priv->baud_base / priv->custom_divisor; | 1152 | baud = priv->baud_base / priv->custom_divisor; |
1158 | dbg("%s - custom divisor %d sets baud rate to %d", | 1153 | dev_dbg(dev, "%s - custom divisor %d sets baud rate to %d\n", |
1159 | __func__, priv->custom_divisor, baud); | 1154 | __func__, priv->custom_divisor, baud); |
1160 | } | 1155 | } |
1161 | 1156 | ||
1162 | /* 3. Convert baudrate to device-specific divisor */ | 1157 | /* 3. Convert baudrate to device-specific divisor */ |
@@ -1178,8 +1173,8 @@ static __u32 get_ftdi_divisor(struct tty_struct *tty, | |||
1178 | case 115200: div_value = ftdi_sio_b115200; break; | 1173 | case 115200: div_value = ftdi_sio_b115200; break; |
1179 | } /* baud */ | 1174 | } /* baud */ |
1180 | if (div_value == 0) { | 1175 | if (div_value == 0) { |
1181 | dbg("%s - Baudrate (%d) requested is not supported", | 1176 | dev_dbg(dev, "%s - Baudrate (%d) requested is not supported\n", |
1182 | __func__, baud); | 1177 | __func__, baud); |
1183 | div_value = ftdi_sio_b9600; | 1178 | div_value = ftdi_sio_b9600; |
1184 | baud = 9600; | 1179 | baud = 9600; |
1185 | div_okay = 0; | 1180 | div_okay = 0; |
@@ -1189,7 +1184,7 @@ static __u32 get_ftdi_divisor(struct tty_struct *tty, | |||
1189 | if (baud <= 3000000) { | 1184 | if (baud <= 3000000) { |
1190 | div_value = ftdi_232am_baud_to_divisor(baud); | 1185 | div_value = ftdi_232am_baud_to_divisor(baud); |
1191 | } else { | 1186 | } else { |
1192 | dbg("%s - Baud rate too high!", __func__); | 1187 | dev_dbg(dev, "%s - Baud rate too high!\n", __func__); |
1193 | baud = 9600; | 1188 | baud = 9600; |
1194 | div_value = ftdi_232am_baud_to_divisor(9600); | 1189 | div_value = ftdi_232am_baud_to_divisor(9600); |
1195 | div_okay = 0; | 1190 | div_okay = 0; |
@@ -1212,7 +1207,7 @@ static __u32 get_ftdi_divisor(struct tty_struct *tty, | |||
1212 | } | 1207 | } |
1213 | div_value = ftdi_232bm_baud_to_divisor(baud); | 1208 | div_value = ftdi_232bm_baud_to_divisor(baud); |
1214 | } else { | 1209 | } else { |
1215 | dbg("%s - Baud rate too high!", __func__); | 1210 | dev_dbg(dev, "%s - Baud rate too high!\n", __func__); |
1216 | div_value = ftdi_232bm_baud_to_divisor(9600); | 1211 | div_value = ftdi_232bm_baud_to_divisor(9600); |
1217 | div_okay = 0; | 1212 | div_okay = 0; |
1218 | baud = 9600; | 1213 | baud = 9600; |
@@ -1226,7 +1221,7 @@ static __u32 get_ftdi_divisor(struct tty_struct *tty, | |||
1226 | } else if (baud < 1200) { | 1221 | } else if (baud < 1200) { |
1227 | div_value = ftdi_232bm_baud_to_divisor(baud); | 1222 | div_value = ftdi_232bm_baud_to_divisor(baud); |
1228 | } else { | 1223 | } else { |
1229 | dbg("%s - Baud rate too high!", __func__); | 1224 | dev_dbg(dev, "%s - Baud rate too high!\n", __func__); |
1230 | div_value = ftdi_232bm_baud_to_divisor(9600); | 1225 | div_value = ftdi_232bm_baud_to_divisor(9600); |
1231 | div_okay = 0; | 1226 | div_okay = 0; |
1232 | baud = 9600; | 1227 | baud = 9600; |
@@ -1235,7 +1230,7 @@ static __u32 get_ftdi_divisor(struct tty_struct *tty, | |||
1235 | } /* priv->chip_type */ | 1230 | } /* priv->chip_type */ |
1236 | 1231 | ||
1237 | if (div_okay) { | 1232 | if (div_okay) { |
1238 | dbg("%s - Baud rate set to %d (divisor 0x%lX) on chip %s", | 1233 | dev_dbg(dev, "%s - Baud rate set to %d (divisor 0x%lX) on chip %s\n", |
1239 | __func__, baud, (unsigned long)div_value, | 1234 | __func__, baud, (unsigned long)div_value, |
1240 | ftdi_chip_name[priv->chip_type]); | 1235 | ftdi_chip_name[priv->chip_type]); |
1241 | } | 1236 | } |
@@ -1281,7 +1276,7 @@ static int write_latency_timer(struct usb_serial_port *port) | |||
1281 | if (priv->flags & ASYNC_LOW_LATENCY) | 1276 | if (priv->flags & ASYNC_LOW_LATENCY) |
1282 | l = 1; | 1277 | l = 1; |
1283 | 1278 | ||
1284 | dbg("%s: setting latency timer = %i", __func__, l); | 1279 | dev_dbg(&port->dev, "%s: setting latency timer = %i\n", __func__, l); |
1285 | 1280 | ||
1286 | rv = usb_control_msg(udev, | 1281 | rv = usb_control_msg(udev, |
1287 | usb_sndctrlpipe(udev, 0), | 1282 | usb_sndctrlpipe(udev, 0), |
@@ -1436,8 +1431,8 @@ static void ftdi_determine_type(struct usb_serial_port *port) | |||
1436 | 1431 | ||
1437 | version = le16_to_cpu(udev->descriptor.bcdDevice); | 1432 | version = le16_to_cpu(udev->descriptor.bcdDevice); |
1438 | interfaces = udev->actconfig->desc.bNumInterfaces; | 1433 | interfaces = udev->actconfig->desc.bNumInterfaces; |
1439 | dbg("%s: bcdDevice = 0x%x, bNumInterfaces = %u", __func__, | 1434 | dev_dbg(&port->dev, "%s: bcdDevice = 0x%x, bNumInterfaces = %u\n", __func__, |
1440 | version, interfaces); | 1435 | version, interfaces); |
1441 | if (interfaces > 1) { | 1436 | if (interfaces > 1) { |
1442 | int inter; | 1437 | int inter; |
1443 | 1438 | ||
@@ -1467,8 +1462,9 @@ static void ftdi_determine_type(struct usb_serial_port *port) | |||
1467 | /* BM-type devices have a bug where bcdDevice gets set | 1462 | /* BM-type devices have a bug where bcdDevice gets set |
1468 | * to 0x200 when iSerialNumber is 0. */ | 1463 | * to 0x200 when iSerialNumber is 0. */ |
1469 | if (version < 0x500) { | 1464 | if (version < 0x500) { |
1470 | dbg("%s: something fishy - bcdDevice too low for multi-interface device", | 1465 | dev_dbg(&port->dev, |
1471 | __func__); | 1466 | "%s: something fishy - bcdDevice too low for multi-interface device\n", |
1467 | __func__); | ||
1472 | } | 1468 | } |
1473 | } else if (version < 0x200) { | 1469 | } else if (version < 0x200) { |
1474 | /* Old device. Assume it's the original SIO. */ | 1470 | /* Old device. Assume it's the original SIO. */ |
@@ -1582,7 +1578,7 @@ static ssize_t store_event_char(struct device *dev, | |||
1582 | int v = simple_strtoul(valbuf, NULL, 10); | 1578 | int v = simple_strtoul(valbuf, NULL, 10); |
1583 | int rv; | 1579 | int rv; |
1584 | 1580 | ||
1585 | dbg("%s: setting event char = %i", __func__, v); | 1581 | dev_dbg(&port->dev, "%s: setting event char = %i\n", __func__, v); |
1586 | 1582 | ||
1587 | rv = usb_control_msg(udev, | 1583 | rv = usb_control_msg(udev, |
1588 | usb_sndctrlpipe(udev, 0), | 1584 | usb_sndctrlpipe(udev, 0), |
@@ -1591,7 +1587,7 @@ static ssize_t store_event_char(struct device *dev, | |||
1591 | v, priv->interface, | 1587 | v, priv->interface, |
1592 | NULL, 0, WDR_TIMEOUT); | 1588 | NULL, 0, WDR_TIMEOUT); |
1593 | if (rv < 0) { | 1589 | if (rv < 0) { |
1594 | dbg("Unable to write event character: %i", rv); | 1590 | dev_dbg(&port->dev, "Unable to write event character: %i\n", rv); |
1595 | return -EIO; | 1591 | return -EIO; |
1596 | } | 1592 | } |
1597 | 1593 | ||
@@ -1610,7 +1606,7 @@ static int create_sysfs_attrs(struct usb_serial_port *port) | |||
1610 | /* XXX I've no idea if the original SIO supports the event_char | 1606 | /* XXX I've no idea if the original SIO supports the event_char |
1611 | * sysfs parameter, so I'm playing it safe. */ | 1607 | * sysfs parameter, so I'm playing it safe. */ |
1612 | if (priv->chip_type != SIO) { | 1608 | if (priv->chip_type != SIO) { |
1613 | dbg("sysfs attributes for %s", ftdi_chip_name[priv->chip_type]); | 1609 | dev_dbg(&port->dev, "sysfs attributes for %s\n", ftdi_chip_name[priv->chip_type]); |
1614 | retval = device_create_file(&port->dev, &dev_attr_event_char); | 1610 | retval = device_create_file(&port->dev, &dev_attr_event_char); |
1615 | if ((!retval) && | 1611 | if ((!retval) && |
1616 | (priv->chip_type == FT232BM || | 1612 | (priv->chip_type == FT232BM || |
@@ -1750,8 +1746,8 @@ static int ftdi_NDI_device_setup(struct usb_serial *serial) | |||
1750 | if (latency > 99) | 1746 | if (latency > 99) |
1751 | latency = 99; | 1747 | latency = 99; |
1752 | 1748 | ||
1753 | dbg("%s setting NDI device latency to %d", __func__, latency); | 1749 | dev_dbg(&udev->dev, "%s setting NDI device latency to %d\n", __func__, latency); |
1754 | dev_info(&udev->dev, "NDI device with a latency value of %d", latency); | 1750 | dev_info(&udev->dev, "NDI device with a latency value of %d\n", latency); |
1755 | 1751 | ||
1756 | /* FIXME: errors are not returned */ | 1752 | /* FIXME: errors are not returned */ |
1757 | usb_control_msg(udev, usb_sndctrlpipe(udev, 0), | 1753 | usb_control_msg(udev, usb_sndctrlpipe(udev, 0), |
@@ -1969,7 +1965,7 @@ static int ftdi_process_packet(struct tty_struct *tty, | |||
1969 | char *ch; | 1965 | char *ch; |
1970 | 1966 | ||
1971 | if (len < 2) { | 1967 | if (len < 2) { |
1972 | dbg("malformed packet"); | 1968 | dev_dbg(&port->dev, "malformed packet\n"); |
1973 | return 0; | 1969 | return 0; |
1974 | } | 1970 | } |
1975 | 1971 | ||
@@ -2084,12 +2080,12 @@ static void ftdi_break_ctl(struct tty_struct *tty, int break_state) | |||
2084 | FTDI_SIO_SET_DATA_REQUEST_TYPE, | 2080 | FTDI_SIO_SET_DATA_REQUEST_TYPE, |
2085 | urb_value , priv->interface, | 2081 | urb_value , priv->interface, |
2086 | NULL, 0, WDR_TIMEOUT) < 0) { | 2082 | NULL, 0, WDR_TIMEOUT) < 0) { |
2087 | dev_err(&port->dev, "%s FAILED to enable/disable break state " | 2083 | dev_err(&port->dev, "%s FAILED to enable/disable break state (state was %d)\n", |
2088 | "(state was %d)\n", __func__, break_state); | 2084 | __func__, break_state); |
2089 | } | 2085 | } |
2090 | 2086 | ||
2091 | dbg("%s break state is %d - urb is %d", __func__, | 2087 | dev_dbg(&port->dev, "%s break state is %d - urb is %d\n", __func__, |
2092 | break_state, urb_value); | 2088 | break_state, urb_value); |
2093 | 2089 | ||
2094 | } | 2090 | } |
2095 | 2091 | ||
@@ -2101,6 +2097,7 @@ static void ftdi_set_termios(struct tty_struct *tty, | |||
2101 | struct usb_serial_port *port, struct ktermios *old_termios) | 2097 | struct usb_serial_port *port, struct ktermios *old_termios) |
2102 | { | 2098 | { |
2103 | struct usb_device *dev = port->serial->dev; | 2099 | struct usb_device *dev = port->serial->dev; |
2100 | struct device *ddev = &port->dev; | ||
2104 | struct ftdi_private *priv = usb_get_serial_port_data(port); | 2101 | struct ftdi_private *priv = usb_get_serial_port_data(port); |
2105 | struct ktermios *termios = &tty->termios; | 2102 | struct ktermios *termios = &tty->termios; |
2106 | unsigned int cflag = termios->c_cflag; | 2103 | unsigned int cflag = termios->c_cflag; |
@@ -2114,20 +2111,20 @@ static void ftdi_set_termios(struct tty_struct *tty, | |||
2114 | /* Force baud rate if this device requires it, unless it is set to | 2111 | /* Force baud rate if this device requires it, unless it is set to |
2115 | B0. */ | 2112 | B0. */ |
2116 | if (priv->force_baud && ((termios->c_cflag & CBAUD) != B0)) { | 2113 | if (priv->force_baud && ((termios->c_cflag & CBAUD) != B0)) { |
2117 | dbg("%s: forcing baud rate for this device", __func__); | 2114 | dev_dbg(ddev, "%s: forcing baud rate for this device\n", __func__); |
2118 | tty_encode_baud_rate(tty, priv->force_baud, | 2115 | tty_encode_baud_rate(tty, priv->force_baud, |
2119 | priv->force_baud); | 2116 | priv->force_baud); |
2120 | } | 2117 | } |
2121 | 2118 | ||
2122 | /* Force RTS-CTS if this device requires it. */ | 2119 | /* Force RTS-CTS if this device requires it. */ |
2123 | if (priv->force_rtscts) { | 2120 | if (priv->force_rtscts) { |
2124 | dbg("%s: forcing rtscts for this device", __func__); | 2121 | dev_dbg(ddev, "%s: forcing rtscts for this device\n", __func__); |
2125 | termios->c_cflag |= CRTSCTS; | 2122 | termios->c_cflag |= CRTSCTS; |
2126 | } | 2123 | } |
2127 | 2124 | ||
2128 | cflag = termios->c_cflag; | 2125 | cflag = termios->c_cflag; |
2129 | 2126 | ||
2130 | if (old_termios == 0) | 2127 | if (!old_termios) |
2131 | goto no_skip; | 2128 | goto no_skip; |
2132 | 2129 | ||
2133 | if (old_termios->c_cflag == termios->c_cflag | 2130 | if (old_termios->c_cflag == termios->c_cflag |
@@ -2163,10 +2160,16 @@ no_skip: | |||
2163 | } | 2160 | } |
2164 | if (cflag & CSIZE) { | 2161 | if (cflag & CSIZE) { |
2165 | switch (cflag & CSIZE) { | 2162 | switch (cflag & CSIZE) { |
2166 | case CS7: urb_value |= 7; dbg("Setting CS7"); break; | 2163 | case CS7: |
2167 | case CS8: urb_value |= 8; dbg("Setting CS8"); break; | 2164 | urb_value |= 7; |
2165 | dev_dbg(ddev, "Setting CS7\n"); | ||
2166 | break; | ||
2167 | case CS8: | ||
2168 | urb_value |= 8; | ||
2169 | dev_dbg(ddev, "Setting CS8\n"); | ||
2170 | break; | ||
2168 | default: | 2171 | default: |
2169 | dev_err(&port->dev, "CSIZE was set but not CS7-CS8\n"); | 2172 | dev_err(ddev, "CSIZE was set but not CS7-CS8\n"); |
2170 | } | 2173 | } |
2171 | } | 2174 | } |
2172 | 2175 | ||
@@ -2179,8 +2182,8 @@ no_skip: | |||
2179 | FTDI_SIO_SET_DATA_REQUEST_TYPE, | 2182 | FTDI_SIO_SET_DATA_REQUEST_TYPE, |
2180 | urb_value , priv->interface, | 2183 | urb_value , priv->interface, |
2181 | NULL, 0, WDR_SHORT_TIMEOUT) < 0) { | 2184 | NULL, 0, WDR_SHORT_TIMEOUT) < 0) { |
2182 | dev_err(&port->dev, "%s FAILED to set " | 2185 | dev_err(ddev, "%s FAILED to set databits/stopbits/parity\n", |
2183 | "databits/stopbits/parity\n", __func__); | 2186 | __func__); |
2184 | } | 2187 | } |
2185 | 2188 | ||
2186 | /* Now do the baudrate */ | 2189 | /* Now do the baudrate */ |
@@ -2192,8 +2195,7 @@ no_data_parity_stop_changes: | |||
2192 | FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, | 2195 | FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, |
2193 | 0, priv->interface, | 2196 | 0, priv->interface, |
2194 | NULL, 0, WDR_TIMEOUT) < 0) { | 2197 | NULL, 0, WDR_TIMEOUT) < 0) { |
2195 | dev_err(&port->dev, | 2198 | dev_err(ddev, "%s error from disable flowcontrol urb\n", |
2196 | "%s error from disable flowcontrol urb\n", | ||
2197 | __func__); | 2199 | __func__); |
2198 | } | 2200 | } |
2199 | /* Drop RTS and DTR */ | 2201 | /* Drop RTS and DTR */ |
@@ -2202,8 +2204,7 @@ no_data_parity_stop_changes: | |||
2202 | /* set the baudrate determined before */ | 2204 | /* set the baudrate determined before */ |
2203 | mutex_lock(&priv->cfg_lock); | 2205 | mutex_lock(&priv->cfg_lock); |
2204 | if (change_speed(tty, port)) | 2206 | if (change_speed(tty, port)) |
2205 | dev_err(&port->dev, "%s urb failed to set baudrate\n", | 2207 | dev_err(ddev, "%s urb failed to set baudrate\n", __func__); |
2206 | __func__); | ||
2207 | mutex_unlock(&priv->cfg_lock); | 2208 | mutex_unlock(&priv->cfg_lock); |
2208 | /* Ensure RTS and DTR are raised when baudrate changed from 0 */ | 2209 | /* Ensure RTS and DTR are raised when baudrate changed from 0 */ |
2209 | if (!old_termios || (old_termios->c_cflag & CBAUD) == B0) | 2210 | if (!old_termios || (old_termios->c_cflag & CBAUD) == B0) |
@@ -2214,17 +2215,15 @@ no_data_parity_stop_changes: | |||
2214 | /* Note device also supports DTR/CD (ugh) and Xon/Xoff in hardware */ | 2215 | /* Note device also supports DTR/CD (ugh) and Xon/Xoff in hardware */ |
2215 | no_c_cflag_changes: | 2216 | no_c_cflag_changes: |
2216 | if (cflag & CRTSCTS) { | 2217 | if (cflag & CRTSCTS) { |
2217 | dbg("%s Setting to CRTSCTS flow control", __func__); | 2218 | dev_dbg(ddev, "%s Setting to CRTSCTS flow control\n", __func__); |
2218 | if (usb_control_msg(dev, | 2219 | if (usb_control_msg(dev, |
2219 | usb_sndctrlpipe(dev, 0), | 2220 | usb_sndctrlpipe(dev, 0), |
2220 | FTDI_SIO_SET_FLOW_CTRL_REQUEST, | 2221 | FTDI_SIO_SET_FLOW_CTRL_REQUEST, |
2221 | FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, | 2222 | FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, |
2222 | 0 , (FTDI_SIO_RTS_CTS_HS | priv->interface), | 2223 | 0 , (FTDI_SIO_RTS_CTS_HS | priv->interface), |
2223 | NULL, 0, WDR_TIMEOUT) < 0) { | 2224 | NULL, 0, WDR_TIMEOUT) < 0) { |
2224 | dev_err(&port->dev, | 2225 | dev_err(ddev, "urb failed to set to rts/cts flow control\n"); |
2225 | "urb failed to set to rts/cts flow control\n"); | ||
2226 | } | 2226 | } |
2227 | |||
2228 | } else { | 2227 | } else { |
2229 | /* | 2228 | /* |
2230 | * Xon/Xoff code | 2229 | * Xon/Xoff code |
@@ -2234,8 +2233,8 @@ no_c_cflag_changes: | |||
2234 | * code is executed. | 2233 | * code is executed. |
2235 | */ | 2234 | */ |
2236 | if (iflag & IXOFF) { | 2235 | if (iflag & IXOFF) { |
2237 | dbg("%s request to enable xonxoff iflag=%04x", | 2236 | dev_dbg(ddev, "%s request to enable xonxoff iflag=%04x\n", |
2238 | __func__, iflag); | 2237 | __func__, iflag); |
2239 | /* Try to enable the XON/XOFF on the ftdi_sio | 2238 | /* Try to enable the XON/XOFF on the ftdi_sio |
2240 | * Set the vstart and vstop -- could have been done up | 2239 | * Set the vstart and vstop -- could have been done up |
2241 | * above where a lot of other dereferencing is done but | 2240 | * above where a lot of other dereferencing is done but |
@@ -2260,18 +2259,16 @@ no_c_cflag_changes: | |||
2260 | /* else clause to only run if cflag ! CRTSCTS and iflag | 2259 | /* else clause to only run if cflag ! CRTSCTS and iflag |
2261 | * ! XOFF. CHECKME Assuming XON/XOFF handled by tty | 2260 | * ! XOFF. CHECKME Assuming XON/XOFF handled by tty |
2262 | * stack - not by device */ | 2261 | * stack - not by device */ |
2263 | dbg("%s Turning off hardware flow control", __func__); | 2262 | dev_dbg(ddev, "%s Turning off hardware flow control\n", __func__); |
2264 | if (usb_control_msg(dev, | 2263 | if (usb_control_msg(dev, |
2265 | usb_sndctrlpipe(dev, 0), | 2264 | usb_sndctrlpipe(dev, 0), |
2266 | FTDI_SIO_SET_FLOW_CTRL_REQUEST, | 2265 | FTDI_SIO_SET_FLOW_CTRL_REQUEST, |
2267 | FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, | 2266 | FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, |
2268 | 0, priv->interface, | 2267 | 0, priv->interface, |
2269 | NULL, 0, WDR_TIMEOUT) < 0) { | 2268 | NULL, 0, WDR_TIMEOUT) < 0) { |
2270 | dev_err(&port->dev, | 2269 | dev_err(ddev, "urb failed to clear flow control\n"); |
2271 | "urb failed to clear flow control\n"); | ||
2272 | } | 2270 | } |
2273 | } | 2271 | } |
2274 | |||
2275 | } | 2272 | } |
2276 | } | 2273 | } |
2277 | 2274 | ||
@@ -2365,7 +2362,7 @@ static int ftdi_ioctl(struct tty_struct *tty, | |||
2365 | struct async_icount cnow; | 2362 | struct async_icount cnow; |
2366 | struct async_icount cprev; | 2363 | struct async_icount cprev; |
2367 | 2364 | ||
2368 | dbg("%s cmd 0x%04x", __func__, cmd); | 2365 | dev_dbg(&port->dev, "%s cmd 0x%04x\n", __func__, cmd); |
2369 | 2366 | ||
2370 | /* Based on code from acm.c and others */ | 2367 | /* Based on code from acm.c and others */ |
2371 | switch (cmd) { | 2368 | switch (cmd) { |
@@ -2413,14 +2410,13 @@ static int ftdi_ioctl(struct tty_struct *tty, | |||
2413 | /* This is not necessarily an error - turns out the higher layers | 2410 | /* This is not necessarily an error - turns out the higher layers |
2414 | * will do some ioctls themselves (see comment above) | 2411 | * will do some ioctls themselves (see comment above) |
2415 | */ | 2412 | */ |
2416 | dbg("%s arg not supported - it was 0x%04x - check /usr/include/asm/ioctls.h", __func__, cmd); | 2413 | dev_dbg(&port->dev, "%s arg not supported - it was 0x%04x - check /usr/include/asm/ioctls.h\n", |
2414 | __func__, cmd); | ||
2417 | return -ENOIOCTLCMD; | 2415 | return -ENOIOCTLCMD; |
2418 | } | 2416 | } |
2419 | 2417 | ||
2420 | static int __init ftdi_init(void) | 2418 | static int __init ftdi_init(void) |
2421 | { | 2419 | { |
2422 | int retval; | ||
2423 | |||
2424 | if (vendor > 0 && product > 0) { | 2420 | if (vendor > 0 && product > 0) { |
2425 | /* Add user specified VID/PID to reserved element of table. */ | 2421 | /* Add user specified VID/PID to reserved element of table. */ |
2426 | int i; | 2422 | int i; |
@@ -2430,11 +2426,7 @@ static int __init ftdi_init(void) | |||
2430 | id_table_combined[i].idVendor = vendor; | 2426 | id_table_combined[i].idVendor = vendor; |
2431 | id_table_combined[i].idProduct = product; | 2427 | id_table_combined[i].idProduct = product; |
2432 | } | 2428 | } |
2433 | retval = usb_serial_register_drivers(serial_drivers, KBUILD_MODNAME, id_table_combined); | 2429 | return usb_serial_register_drivers(serial_drivers, KBUILD_MODNAME, id_table_combined); |
2434 | if (retval == 0) | ||
2435 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" | ||
2436 | DRIVER_DESC "\n"); | ||
2437 | return retval; | ||
2438 | } | 2430 | } |
2439 | 2431 | ||
2440 | static void __exit ftdi_exit(void) | 2432 | static void __exit ftdi_exit(void) |
@@ -2450,8 +2442,6 @@ MODULE_AUTHOR(DRIVER_AUTHOR); | |||
2450 | MODULE_DESCRIPTION(DRIVER_DESC); | 2442 | MODULE_DESCRIPTION(DRIVER_DESC); |
2451 | MODULE_LICENSE("GPL"); | 2443 | MODULE_LICENSE("GPL"); |
2452 | 2444 | ||
2453 | module_param(debug, bool, S_IRUGO | S_IWUSR); | ||
2454 | MODULE_PARM_DESC(debug, "Debug enabled or not"); | ||
2455 | module_param(vendor, ushort, 0); | 2445 | module_param(vendor, ushort, 0); |
2456 | MODULE_PARM_DESC(vendor, "User specified vendor ID (default=" | 2446 | MODULE_PARM_DESC(vendor, "User specified vendor ID (default=" |
2457 | __MODULE_STRING(FTDI_VID)")"); | 2447 | __MODULE_STRING(FTDI_VID)")"); |
diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h index 41fe5826100c..57c12ef6625e 100644 --- a/drivers/usb/serial/ftdi_sio_ids.h +++ b/drivers/usb/serial/ftdi_sio_ids.h | |||
@@ -517,6 +517,11 @@ | |||
517 | */ | 517 | */ |
518 | #define FTDI_TAVIR_STK500_PID 0xFA33 /* STK500 AVR programmer */ | 518 | #define FTDI_TAVIR_STK500_PID 0xFA33 /* STK500 AVR programmer */ |
519 | 519 | ||
520 | /* | ||
521 | * TIAO product ids (FTDI_VID) | ||
522 | * http://www.tiaowiki.com/w/Main_Page | ||
523 | */ | ||
524 | #define FTDI_TIAO_UMPA_PID 0x8a98 /* TIAO/DIYGADGET USB Multi-Protocol Adapter */ | ||
520 | 525 | ||
521 | 526 | ||
522 | /********************************/ | 527 | /********************************/ |
diff --git a/drivers/usb/serial/funsoft.c b/drivers/usb/serial/funsoft.c index 235707961ca3..9362f8fd2385 100644 --- a/drivers/usb/serial/funsoft.c +++ b/drivers/usb/serial/funsoft.c | |||
@@ -16,8 +16,6 @@ | |||
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 bool debug; | ||
20 | |||
21 | static const struct usb_device_id id_table[] = { | 19 | static const struct usb_device_id id_table[] = { |
22 | { USB_DEVICE(0x1404, 0xcddc) }, | 20 | { USB_DEVICE(0x1404, 0xcddc) }, |
23 | { }, | 21 | { }, |
@@ -40,6 +38,3 @@ static struct usb_serial_driver * const serial_drivers[] = { | |||
40 | module_usb_serial_driver(serial_drivers, id_table); | 38 | module_usb_serial_driver(serial_drivers, id_table); |
41 | 39 | ||
42 | MODULE_LICENSE("GPL"); | 40 | MODULE_LICENSE("GPL"); |
43 | |||
44 | module_param(debug, bool, S_IRUGO | S_IWUSR); | ||
45 | MODULE_PARM_DESC(debug, "Debug enabled or not"); | ||
diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c index 346c15a51066..3ee92648c02d 100644 --- a/drivers/usb/serial/garmin_gps.c +++ b/drivers/usb/serial/garmin_gps.c | |||
@@ -41,9 +41,6 @@ | |||
41 | /* the mode to be set when the port ist opened */ | 41 | /* the mode to be set when the port ist opened */ |
42 | static int initial_mode = 1; | 42 | static int initial_mode = 1; |
43 | 43 | ||
44 | /* debug flag */ | ||
45 | static bool debug; | ||
46 | |||
47 | #define GARMIN_VENDOR_ID 0x091E | 44 | #define GARMIN_VENDOR_ID 0x091E |
48 | 45 | ||
49 | /* | 46 | /* |
@@ -258,10 +255,7 @@ static void send_to_tty(struct usb_serial_port *port, | |||
258 | struct tty_struct *tty = tty_port_tty_get(&port->port); | 255 | struct tty_struct *tty = tty_port_tty_get(&port->port); |
259 | 256 | ||
260 | if (tty && actual_length) { | 257 | if (tty && actual_length) { |
261 | 258 | usb_serial_debug_data(&port->dev, __func__, actual_length, data); | |
262 | usb_serial_debug_data(debug, &port->dev, | ||
263 | __func__, actual_length, data); | ||
264 | |||
265 | tty_insert_flip_string(tty, data, actual_length); | 259 | tty_insert_flip_string(tty, data, actual_length); |
266 | tty_flip_buffer_push(tty); | 260 | tty_flip_buffer_push(tty); |
267 | } | 261 | } |
@@ -303,8 +297,9 @@ static int pkt_add(struct garmin_data *garmin_data_p, | |||
303 | state = garmin_data_p->state; | 297 | state = garmin_data_p->state; |
304 | spin_unlock_irqrestore(&garmin_data_p->lock, flags); | 298 | spin_unlock_irqrestore(&garmin_data_p->lock, flags); |
305 | 299 | ||
306 | dbg("%s - added: pkt: %d - %d bytes", | 300 | dev_dbg(&garmin_data_p->port->dev, |
307 | __func__, pkt->seq, data_length); | 301 | "%s - added: pkt: %d - %d bytes\n", __func__, |
302 | pkt->seq, data_length); | ||
308 | 303 | ||
309 | /* in serial mode, if someone is waiting for data from | 304 | /* in serial mode, if someone is waiting for data from |
310 | the device, convert and send the next packet to tty. */ | 305 | the device, convert and send the next packet to tty. */ |
@@ -359,7 +354,8 @@ static int gsp_send_ack(struct garmin_data *garmin_data_p, __u8 pkt_id) | |||
359 | __u8 *ptr = pkt; | 354 | __u8 *ptr = pkt; |
360 | unsigned l = 0; | 355 | unsigned l = 0; |
361 | 356 | ||
362 | dbg("%s - pkt-id: 0x%X.", __func__, 0xFF & pkt_id); | 357 | dev_dbg(&garmin_data_p->port->dev, "%s - pkt-id: 0x%X.\n", __func__, |
358 | 0xFF & pkt_id); | ||
363 | 359 | ||
364 | *ptr++ = DLE; | 360 | *ptr++ = DLE; |
365 | *ptr++ = ACK; | 361 | *ptr++ = ACK; |
@@ -399,20 +395,20 @@ static int gsp_send_ack(struct garmin_data *garmin_data_p, __u8 pkt_id) | |||
399 | */ | 395 | */ |
400 | static int gsp_rec_packet(struct garmin_data *garmin_data_p, int count) | 396 | static int gsp_rec_packet(struct garmin_data *garmin_data_p, int count) |
401 | { | 397 | { |
398 | struct device *dev = &garmin_data_p->port->dev; | ||
402 | unsigned long flags; | 399 | unsigned long flags; |
403 | const __u8 *recpkt = garmin_data_p->inbuffer+GSP_INITIAL_OFFSET; | 400 | const __u8 *recpkt = garmin_data_p->inbuffer+GSP_INITIAL_OFFSET; |
404 | __le32 *usbdata = (__le32 *) garmin_data_p->inbuffer; | 401 | __le32 *usbdata = (__le32 *) garmin_data_p->inbuffer; |
405 | |||
406 | int cksum = 0; | 402 | int cksum = 0; |
407 | int n = 0; | 403 | int n = 0; |
408 | int pktid = recpkt[0]; | 404 | int pktid = recpkt[0]; |
409 | int size = recpkt[1]; | 405 | int size = recpkt[1]; |
410 | 406 | ||
411 | usb_serial_debug_data(debug, &garmin_data_p->port->dev, | 407 | usb_serial_debug_data(&garmin_data_p->port->dev, __func__, |
412 | __func__, count-GSP_INITIAL_OFFSET, recpkt); | 408 | count-GSP_INITIAL_OFFSET, recpkt); |
413 | 409 | ||
414 | if (size != (count-GSP_INITIAL_OFFSET-3)) { | 410 | if (size != (count-GSP_INITIAL_OFFSET-3)) { |
415 | dbg("%s - invalid size, expected %d bytes, got %d", | 411 | dev_dbg(dev, "%s - invalid size, expected %d bytes, got %d\n", |
416 | __func__, size, (count-GSP_INITIAL_OFFSET-3)); | 412 | __func__, size, (count-GSP_INITIAL_OFFSET-3)); |
417 | return -EINVPKT; | 413 | return -EINVPKT; |
418 | } | 414 | } |
@@ -422,8 +418,8 @@ static int gsp_rec_packet(struct garmin_data *garmin_data_p, int count) | |||
422 | 418 | ||
423 | /* sanity check, remove after test ... */ | 419 | /* sanity check, remove after test ... */ |
424 | if ((__u8 *)&(usbdata[3]) != recpkt) { | 420 | if ((__u8 *)&(usbdata[3]) != recpkt) { |
425 | dbg("%s - ptr mismatch %p - %p", | 421 | dev_dbg(dev, "%s - ptr mismatch %p - %p\n", __func__, |
426 | __func__, &(usbdata[4]), recpkt); | 422 | &(usbdata[4]), recpkt); |
427 | return -EINVPKT; | 423 | return -EINVPKT; |
428 | } | 424 | } |
429 | 425 | ||
@@ -433,7 +429,7 @@ static int gsp_rec_packet(struct garmin_data *garmin_data_p, int count) | |||
433 | } | 429 | } |
434 | 430 | ||
435 | if ((0xff & (cksum + *recpkt)) != 0) { | 431 | if ((0xff & (cksum + *recpkt)) != 0) { |
436 | dbg("%s - invalid checksum, expected %02x, got %02x", | 432 | dev_dbg(dev, "%s - invalid checksum, expected %02x, got %02x\n", |
437 | __func__, 0xff & -cksum, 0xff & *recpkt); | 433 | __func__, 0xff & -cksum, 0xff & *recpkt); |
438 | return -EINVPKT; | 434 | return -EINVPKT; |
439 | } | 435 | } |
@@ -480,6 +476,7 @@ static int gsp_rec_packet(struct garmin_data *garmin_data_p, int count) | |||
480 | static int gsp_receive(struct garmin_data *garmin_data_p, | 476 | static int gsp_receive(struct garmin_data *garmin_data_p, |
481 | const unsigned char *buf, int count) | 477 | const unsigned char *buf, int count) |
482 | { | 478 | { |
479 | struct device *dev = &garmin_data_p->port->dev; | ||
483 | unsigned long flags; | 480 | unsigned long flags; |
484 | int offs = 0; | 481 | int offs = 0; |
485 | int ack_or_nak_seen = 0; | 482 | int ack_or_nak_seen = 0; |
@@ -500,7 +497,7 @@ static int gsp_receive(struct garmin_data *garmin_data_p, | |||
500 | skip = garmin_data_p->flags & FLAGS_GSP_SKIP; | 497 | skip = garmin_data_p->flags & FLAGS_GSP_SKIP; |
501 | spin_unlock_irqrestore(&garmin_data_p->lock, flags); | 498 | spin_unlock_irqrestore(&garmin_data_p->lock, flags); |
502 | 499 | ||
503 | /* dbg("%s - dle=%d skip=%d size=%d count=%d", | 500 | /* dev_dbg(dev, "%s - dle=%d skip=%d size=%d count=%d\n", |
504 | __func__, dleSeen, skip, size, count); */ | 501 | __func__, dleSeen, skip, size, count); */ |
505 | 502 | ||
506 | if (size == 0) | 503 | if (size == 0) |
@@ -530,12 +527,12 @@ static int gsp_receive(struct garmin_data *garmin_data_p, | |||
530 | 527 | ||
531 | if (data == ACK) { | 528 | if (data == ACK) { |
532 | ack_or_nak_seen = ACK; | 529 | ack_or_nak_seen = ACK; |
533 | dbg("ACK packet complete."); | 530 | dev_dbg(dev, "ACK packet complete.\n"); |
534 | } else if (data == NAK) { | 531 | } else if (data == NAK) { |
535 | ack_or_nak_seen = NAK; | 532 | ack_or_nak_seen = NAK; |
536 | dbg("NAK packet complete."); | 533 | dev_dbg(dev, "NAK packet complete.\n"); |
537 | } else { | 534 | } else { |
538 | dbg("packet complete - id=0x%X.", | 535 | dev_dbg(dev, "packet complete - id=0x%X.\n", |
539 | 0xFF & data); | 536 | 0xFF & data); |
540 | gsp_rec_packet(garmin_data_p, size); | 537 | gsp_rec_packet(garmin_data_p, size); |
541 | } | 538 | } |
@@ -557,7 +554,7 @@ static int gsp_receive(struct garmin_data *garmin_data_p, | |||
557 | } | 554 | } |
558 | 555 | ||
559 | if (size >= GPS_IN_BUFSIZ) { | 556 | if (size >= GPS_IN_BUFSIZ) { |
560 | dbg("%s - packet too large.", __func__); | 557 | dev_dbg(dev, "%s - packet too large.\n", __func__); |
561 | skip = 1; | 558 | skip = 1; |
562 | size = GSP_INITIAL_OFFSET; | 559 | size = GSP_INITIAL_OFFSET; |
563 | dleSeen = 0; | 560 | dleSeen = 0; |
@@ -602,6 +599,7 @@ static int gsp_receive(struct garmin_data *garmin_data_p, | |||
602 | static int gsp_send(struct garmin_data *garmin_data_p, | 599 | static int gsp_send(struct garmin_data *garmin_data_p, |
603 | const unsigned char *buf, int count) | 600 | const unsigned char *buf, int count) |
604 | { | 601 | { |
602 | struct device *dev = &garmin_data_p->port->dev; | ||
605 | const unsigned char *src; | 603 | const unsigned char *src; |
606 | unsigned char *dst; | 604 | unsigned char *dst; |
607 | int pktid = 0; | 605 | int pktid = 0; |
@@ -610,12 +608,12 @@ static int gsp_send(struct garmin_data *garmin_data_p, | |||
610 | int i = 0; | 608 | int i = 0; |
611 | int k; | 609 | int k; |
612 | 610 | ||
613 | dbg("%s - state %d - %d bytes.", __func__, | 611 | dev_dbg(dev, "%s - state %d - %d bytes.\n", __func__, |
614 | garmin_data_p->state, count); | 612 | garmin_data_p->state, count); |
615 | 613 | ||
616 | k = garmin_data_p->outsize; | 614 | k = garmin_data_p->outsize; |
617 | if ((k+count) > GPS_OUT_BUFSIZ) { | 615 | if ((k+count) > GPS_OUT_BUFSIZ) { |
618 | dbg("packet too large"); | 616 | dev_dbg(dev, "packet too large\n"); |
619 | garmin_data_p->outsize = 0; | 617 | garmin_data_p->outsize = 0; |
620 | return -4; | 618 | return -4; |
621 | } | 619 | } |
@@ -634,28 +632,28 @@ static int gsp_send(struct garmin_data *garmin_data_p, | |||
634 | return 0; | 632 | return 0; |
635 | } | 633 | } |
636 | 634 | ||
637 | dbg("%s - %d bytes in buffer, %d bytes in pkt.", __func__, k, i); | 635 | dev_dbg(dev, "%s - %d bytes in buffer, %d bytes in pkt.\n", __func__, k, i); |
638 | 636 | ||
639 | /* garmin_data_p->outbuffer now contains a complete packet */ | 637 | /* garmin_data_p->outbuffer now contains a complete packet */ |
640 | 638 | ||
641 | usb_serial_debug_data(debug, &garmin_data_p->port->dev, | 639 | usb_serial_debug_data(&garmin_data_p->port->dev, __func__, k, |
642 | __func__, k, garmin_data_p->outbuffer); | 640 | garmin_data_p->outbuffer); |
643 | 641 | ||
644 | garmin_data_p->outsize = 0; | 642 | garmin_data_p->outsize = 0; |
645 | 643 | ||
646 | if (GARMIN_LAYERID_APPL != getLayerId(garmin_data_p->outbuffer)) { | 644 | if (GARMIN_LAYERID_APPL != getLayerId(garmin_data_p->outbuffer)) { |
647 | dbg("not an application packet (%d)", | 645 | dev_dbg(dev, "not an application packet (%d)\n", |
648 | getLayerId(garmin_data_p->outbuffer)); | 646 | getLayerId(garmin_data_p->outbuffer)); |
649 | return -1; | 647 | return -1; |
650 | } | 648 | } |
651 | 649 | ||
652 | if (pktid > 255) { | 650 | if (pktid > 255) { |
653 | dbg("packet-id %d too large", pktid); | 651 | dev_dbg(dev, "packet-id %d too large\n", pktid); |
654 | return -2; | 652 | return -2; |
655 | } | 653 | } |
656 | 654 | ||
657 | if (datalen > 255) { | 655 | if (datalen > 255) { |
658 | dbg("packet-size %d too large", datalen); | 656 | dev_dbg(dev, "packet-size %d too large\n", datalen); |
659 | return -3; | 657 | return -3; |
660 | } | 658 | } |
661 | 659 | ||
@@ -722,7 +720,7 @@ static int gsp_next_packet(struct garmin_data *garmin_data_p) | |||
722 | struct garmin_packet *pkt = NULL; | 720 | struct garmin_packet *pkt = NULL; |
723 | 721 | ||
724 | while ((pkt = pkt_pop(garmin_data_p)) != NULL) { | 722 | while ((pkt = pkt_pop(garmin_data_p)) != NULL) { |
725 | dbg("%s - next pkt: %d", __func__, pkt->seq); | 723 | dev_dbg(&garmin_data_p->port->dev, "%s - next pkt: %d\n", __func__, pkt->seq); |
726 | result = gsp_send(garmin_data_p, pkt->data, pkt->size); | 724 | result = gsp_send(garmin_data_p, pkt->data, pkt->size); |
727 | if (result > 0) { | 725 | if (result > 0) { |
728 | kfree(pkt); | 726 | kfree(pkt); |
@@ -768,7 +766,9 @@ static int nat_receive(struct garmin_data *garmin_data_p, | |||
768 | if (len >= GPS_IN_BUFSIZ) { | 766 | if (len >= GPS_IN_BUFSIZ) { |
769 | /* seems to be an invalid packet, ignore rest | 767 | /* seems to be an invalid packet, ignore rest |
770 | of input */ | 768 | of input */ |
771 | dbg("%s - packet size too large: %d", __func__, len); | 769 | dev_dbg(&garmin_data_p->port->dev, |
770 | "%s - packet size too large: %d\n", | ||
771 | __func__, len); | ||
772 | garmin_data_p->insize = 0; | 772 | garmin_data_p->insize = 0; |
773 | count = 0; | 773 | count = 0; |
774 | result = -EINVPKT; | 774 | result = -EINVPKT; |
@@ -849,10 +849,10 @@ static int process_resetdev_request(struct usb_serial_port *port) | |||
849 | spin_unlock_irqrestore(&garmin_data_p->lock, flags); | 849 | spin_unlock_irqrestore(&garmin_data_p->lock, flags); |
850 | 850 | ||
851 | usb_kill_urb(port->interrupt_in_urb); | 851 | usb_kill_urb(port->interrupt_in_urb); |
852 | dbg("%s - usb_reset_device", __func__); | 852 | dev_dbg(&port->dev, "%s - usb_reset_device\n", __func__); |
853 | status = usb_reset_device(port->serial->dev); | 853 | status = usb_reset_device(port->serial->dev); |
854 | if (status) | 854 | if (status) |
855 | dbg("%s - usb_reset_device failed: %d", | 855 | dev_dbg(&port->dev, "%s - usb_reset_device failed: %d\n", |
856 | __func__, status); | 856 | __func__, status); |
857 | return status; | 857 | return status; |
858 | } | 858 | } |
@@ -889,7 +889,7 @@ static int garmin_init_session(struct usb_serial_port *port) | |||
889 | if (status == 0) { | 889 | if (status == 0) { |
890 | usb_kill_urb(port->interrupt_in_urb); | 890 | usb_kill_urb(port->interrupt_in_urb); |
891 | 891 | ||
892 | dbg("%s - adding interrupt input", __func__); | 892 | dev_dbg(&serial->dev->dev, "%s - adding interrupt input\n", __func__); |
893 | status = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); | 893 | status = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); |
894 | if (status) | 894 | if (status) |
895 | dev_err(&serial->dev->dev, | 895 | dev_err(&serial->dev->dev, |
@@ -902,7 +902,7 @@ static int garmin_init_session(struct usb_serial_port *port) | |||
902 | * gpsbabel/jeeps/gpslibusb.c gusb_reset_toggles() | 902 | * gpsbabel/jeeps/gpslibusb.c gusb_reset_toggles() |
903 | */ | 903 | */ |
904 | if (status == 0) { | 904 | if (status == 0) { |
905 | dbg("%s - starting session ...", __func__); | 905 | dev_dbg(&serial->dev->dev, "%s - starting session ...\n", __func__); |
906 | garmin_data_p->state = STATE_ACTIVE; | 906 | garmin_data_p->state = STATE_ACTIVE; |
907 | 907 | ||
908 | for (i = 0; i < 3; i++) { | 908 | for (i = 0; i < 3; i++) { |
@@ -952,8 +952,8 @@ static void garmin_close(struct usb_serial_port *port) | |||
952 | struct usb_serial *serial = port->serial; | 952 | struct usb_serial *serial = port->serial; |
953 | struct garmin_data *garmin_data_p = usb_get_serial_port_data(port); | 953 | struct garmin_data *garmin_data_p = usb_get_serial_port_data(port); |
954 | 954 | ||
955 | dbg("%s - port %d - mode=%d state=%d flags=0x%X", __func__, | 955 | dev_dbg(&port->dev, "%s - port %d - mode=%d state=%d flags=0x%X\n", |
956 | port->number, garmin_data_p->mode, | 956 | __func__, port->number, garmin_data_p->mode, |
957 | garmin_data_p->state, garmin_data_p->flags); | 957 | garmin_data_p->state, garmin_data_p->flags); |
958 | 958 | ||
959 | if (!serial) | 959 | if (!serial) |
@@ -1032,7 +1032,7 @@ static int garmin_write_bulk(struct usb_serial_port *port, | |||
1032 | 1032 | ||
1033 | memcpy(buffer, buf, count); | 1033 | memcpy(buffer, buf, count); |
1034 | 1034 | ||
1035 | usb_serial_debug_data(debug, &port->dev, __func__, count, buffer); | 1035 | usb_serial_debug_data(&port->dev, __func__, count, buffer); |
1036 | 1036 | ||
1037 | usb_fill_bulk_urb(urb, serial->dev, | 1037 | usb_fill_bulk_urb(urb, serial->dev, |
1038 | usb_sndbulkpipe(serial->dev, | 1038 | usb_sndbulkpipe(serial->dev, |
@@ -1073,11 +1073,12 @@ static int garmin_write_bulk(struct usb_serial_port *port, | |||
1073 | static int garmin_write(struct tty_struct *tty, struct usb_serial_port *port, | 1073 | static int garmin_write(struct tty_struct *tty, struct usb_serial_port *port, |
1074 | const unsigned char *buf, int count) | 1074 | const unsigned char *buf, int count) |
1075 | { | 1075 | { |
1076 | struct device *dev = &port->dev; | ||
1076 | int pktid, pktsiz, len; | 1077 | int pktid, pktsiz, len; |
1077 | struct garmin_data *garmin_data_p = usb_get_serial_port_data(port); | 1078 | struct garmin_data *garmin_data_p = usb_get_serial_port_data(port); |
1078 | __le32 *privpkt = (__le32 *)garmin_data_p->privpkt; | 1079 | __le32 *privpkt = (__le32 *)garmin_data_p->privpkt; |
1079 | 1080 | ||
1080 | usb_serial_debug_data(debug, &port->dev, __func__, count, buf); | 1081 | usb_serial_debug_data(dev, __func__, count, buf); |
1081 | 1082 | ||
1082 | if (garmin_data_p->state == STATE_RESET) | 1083 | if (garmin_data_p->state == STATE_RESET) |
1083 | return -EIO; | 1084 | return -EIO; |
@@ -1097,27 +1098,18 @@ static int garmin_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
1097 | && GARMIN_LAYERID_PRIVATE == | 1098 | && GARMIN_LAYERID_PRIVATE == |
1098 | getLayerId(garmin_data_p->privpkt)) { | 1099 | getLayerId(garmin_data_p->privpkt)) { |
1099 | 1100 | ||
1100 | dbg("%s - processing private request %d", | 1101 | dev_dbg(dev, "%s - processing private request %d\n", |
1101 | __func__, pktid); | 1102 | __func__, pktid); |
1102 | 1103 | ||
1103 | /* drop all unfinished transfers */ | 1104 | /* drop all unfinished transfers */ |
1104 | garmin_clear(garmin_data_p); | 1105 | garmin_clear(garmin_data_p); |
1105 | 1106 | ||
1106 | switch (pktid) { | 1107 | switch (pktid) { |
1107 | |||
1108 | case PRIV_PKTID_SET_DEBUG: | ||
1109 | if (pktsiz != 4) | ||
1110 | return -EINVPKT; | ||
1111 | debug = __le32_to_cpu(privpkt[3]); | ||
1112 | dbg("%s - debug level set to 0x%X", | ||
1113 | __func__, debug); | ||
1114 | break; | ||
1115 | |||
1116 | case PRIV_PKTID_SET_MODE: | 1108 | case PRIV_PKTID_SET_MODE: |
1117 | if (pktsiz != 4) | 1109 | if (pktsiz != 4) |
1118 | return -EINVPKT; | 1110 | return -EINVPKT; |
1119 | garmin_data_p->mode = __le32_to_cpu(privpkt[3]); | 1111 | garmin_data_p->mode = __le32_to_cpu(privpkt[3]); |
1120 | dbg("%s - mode set to %d", | 1112 | dev_dbg(dev, "%s - mode set to %d\n", |
1121 | __func__, garmin_data_p->mode); | 1113 | __func__, garmin_data_p->mode); |
1122 | break; | 1114 | break; |
1123 | 1115 | ||
@@ -1133,7 +1125,7 @@ static int garmin_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
1133 | if (pktsiz != 4) | 1125 | if (pktsiz != 4) |
1134 | return -EINVPKT; | 1126 | return -EINVPKT; |
1135 | initial_mode = __le32_to_cpu(privpkt[3]); | 1127 | initial_mode = __le32_to_cpu(privpkt[3]); |
1136 | dbg("%s - initial_mode set to %d", | 1128 | dev_dbg(dev, "%s - initial_mode set to %d\n", |
1137 | __func__, | 1129 | __func__, |
1138 | garmin_data_p->mode); | 1130 | garmin_data_p->mode); |
1139 | break; | 1131 | break; |
@@ -1169,7 +1161,7 @@ static void garmin_read_process(struct garmin_data *garmin_data_p, | |||
1169 | 1161 | ||
1170 | if (garmin_data_p->flags & FLAGS_DROP_DATA) { | 1162 | if (garmin_data_p->flags & FLAGS_DROP_DATA) { |
1171 | /* abort-transfer cmd is actice */ | 1163 | /* abort-transfer cmd is actice */ |
1172 | dbg("%s - pkt dropped", __func__); | 1164 | dev_dbg(&garmin_data_p->port->dev, "%s - pkt dropped\n", __func__); |
1173 | } else if (garmin_data_p->state != STATE_DISCONNECTED && | 1165 | } else if (garmin_data_p->state != STATE_DISCONNECTED && |
1174 | garmin_data_p->state != STATE_RESET) { | 1166 | garmin_data_p->state != STATE_RESET) { |
1175 | 1167 | ||
@@ -1178,7 +1170,7 @@ static void garmin_read_process(struct garmin_data *garmin_data_p, | |||
1178 | send it directly to the tty port */ | 1170 | send it directly to the tty port */ |
1179 | if (garmin_data_p->flags & FLAGS_QUEUING) { | 1171 | if (garmin_data_p->flags & FLAGS_QUEUING) { |
1180 | pkt_add(garmin_data_p, data, data_length); | 1172 | pkt_add(garmin_data_p, data, data_length); |
1181 | } else if (bulk_data || | 1173 | } else if (bulk_data || |
1182 | getLayerId(data) == GARMIN_LAYERID_APPL) { | 1174 | getLayerId(data) == GARMIN_LAYERID_APPL) { |
1183 | 1175 | ||
1184 | spin_lock_irqsave(&garmin_data_p->lock, flags); | 1176 | spin_lock_irqsave(&garmin_data_p->lock, flags); |
@@ -1208,18 +1200,17 @@ static void garmin_read_bulk_callback(struct urb *urb) | |||
1208 | int retval; | 1200 | int retval; |
1209 | 1201 | ||
1210 | if (!serial) { | 1202 | if (!serial) { |
1211 | dbg("%s - bad serial pointer, exiting", __func__); | 1203 | dev_dbg(&urb->dev->dev, "%s - bad serial pointer, exiting\n", __func__); |
1212 | return; | 1204 | return; |
1213 | } | 1205 | } |
1214 | 1206 | ||
1215 | if (status) { | 1207 | if (status) { |
1216 | dbg("%s - nonzero read bulk status received: %d", | 1208 | dev_dbg(&urb->dev->dev, "%s - nonzero read bulk status received: %d\n", |
1217 | __func__, status); | 1209 | __func__, status); |
1218 | return; | 1210 | return; |
1219 | } | 1211 | } |
1220 | 1212 | ||
1221 | usb_serial_debug_data(debug, &port->dev, | 1213 | usb_serial_debug_data(&port->dev, __func__, urb->actual_length, data); |
1222 | __func__, urb->actual_length, data); | ||
1223 | 1214 | ||
1224 | garmin_read_process(garmin_data_p, data, urb->actual_length, 1); | 1215 | garmin_read_process(garmin_data_p, data, urb->actual_length, 1); |
1225 | 1216 | ||
@@ -1239,11 +1230,11 @@ static void garmin_read_bulk_callback(struct urb *urb) | |||
1239 | retval = usb_submit_urb(port->read_urb, GFP_ATOMIC); | 1230 | retval = usb_submit_urb(port->read_urb, GFP_ATOMIC); |
1240 | if (retval) | 1231 | if (retval) |
1241 | dev_err(&port->dev, | 1232 | dev_err(&port->dev, |
1242 | "%s - failed resubmitting read urb, " | 1233 | "%s - failed resubmitting read urb, error %d\n", |
1243 | "error %d\n", __func__, retval); | 1234 | __func__, retval); |
1244 | } | 1235 | } |
1245 | } else { | 1236 | } else { |
1246 | dbg("%s - end of bulk data", __func__); | 1237 | dev_dbg(&port->dev, "%s - end of bulk data\n", __func__); |
1247 | spin_lock_irqsave(&garmin_data_p->lock, flags); | 1238 | spin_lock_irqsave(&garmin_data_p->lock, flags); |
1248 | garmin_data_p->flags &= ~FLAGS_BULK_IN_ACTIVE; | 1239 | garmin_data_p->flags &= ~FLAGS_BULK_IN_ACTIVE; |
1249 | spin_unlock_irqrestore(&garmin_data_p->lock, flags); | 1240 | spin_unlock_irqrestore(&garmin_data_p->lock, flags); |
@@ -1268,23 +1259,23 @@ static void garmin_read_int_callback(struct urb *urb) | |||
1268 | case -ENOENT: | 1259 | case -ENOENT: |
1269 | case -ESHUTDOWN: | 1260 | case -ESHUTDOWN: |
1270 | /* this urb is terminated, clean up */ | 1261 | /* this urb is terminated, clean up */ |
1271 | dbg("%s - urb shutting down with status: %d", | 1262 | dev_dbg(&urb->dev->dev, "%s - urb shutting down with status: %d\n", |
1272 | __func__, status); | 1263 | __func__, status); |
1273 | return; | 1264 | return; |
1274 | default: | 1265 | default: |
1275 | dbg("%s - nonzero urb status received: %d", | 1266 | dev_dbg(&urb->dev->dev, "%s - nonzero urb status received: %d\n", |
1276 | __func__, status); | 1267 | __func__, status); |
1277 | return; | 1268 | return; |
1278 | } | 1269 | } |
1279 | 1270 | ||
1280 | usb_serial_debug_data(debug, &port->dev, __func__, | 1271 | usb_serial_debug_data(&port->dev, __func__, urb->actual_length, |
1281 | urb->actual_length, urb->transfer_buffer); | 1272 | urb->transfer_buffer); |
1282 | 1273 | ||
1283 | if (urb->actual_length == sizeof(GARMIN_BULK_IN_AVAIL_REPLY) && | 1274 | if (urb->actual_length == sizeof(GARMIN_BULK_IN_AVAIL_REPLY) && |
1284 | 0 == memcmp(data, GARMIN_BULK_IN_AVAIL_REPLY, | 1275 | 0 == memcmp(data, GARMIN_BULK_IN_AVAIL_REPLY, |
1285 | sizeof(GARMIN_BULK_IN_AVAIL_REPLY))) { | 1276 | sizeof(GARMIN_BULK_IN_AVAIL_REPLY))) { |
1286 | 1277 | ||
1287 | dbg("%s - bulk data available.", __func__); | 1278 | dev_dbg(&port->dev, "%s - bulk data available.\n", __func__); |
1288 | 1279 | ||
1289 | if (0 == (garmin_data_p->flags & FLAGS_BULK_IN_ACTIVE)) { | 1280 | if (0 == (garmin_data_p->flags & FLAGS_BULK_IN_ACTIVE)) { |
1290 | 1281 | ||
@@ -1319,7 +1310,7 @@ static void garmin_read_int_callback(struct urb *urb) | |||
1319 | garmin_data_p->serial_num = __le32_to_cpup( | 1310 | garmin_data_p->serial_num = __le32_to_cpup( |
1320 | (__le32 *)(data+GARMIN_PKTHDR_LENGTH)); | 1311 | (__le32 *)(data+GARMIN_PKTHDR_LENGTH)); |
1321 | 1312 | ||
1322 | dbg("%s - start-of-session reply seen - serial %u.", | 1313 | dev_dbg(&port->dev, "%s - start-of-session reply seen - serial %u.\n", |
1323 | __func__, garmin_data_p->serial_num); | 1314 | __func__, garmin_data_p->serial_num); |
1324 | } | 1315 | } |
1325 | 1316 | ||
@@ -1495,7 +1486,5 @@ MODULE_AUTHOR(DRIVER_AUTHOR); | |||
1495 | MODULE_DESCRIPTION(DRIVER_DESC); | 1486 | MODULE_DESCRIPTION(DRIVER_DESC); |
1496 | MODULE_LICENSE("GPL"); | 1487 | MODULE_LICENSE("GPL"); |
1497 | 1488 | ||
1498 | module_param(debug, bool, S_IWUSR | S_IRUGO); | ||
1499 | MODULE_PARM_DESC(debug, "Debug enabled or not"); | ||
1500 | module_param(initial_mode, int, S_IRUGO); | 1489 | module_param(initial_mode, int, S_IRUGO); |
1501 | MODULE_PARM_DESC(initial_mode, "Initial mode"); | 1490 | MODULE_PARM_DESC(initial_mode, "Initial mode"); |
diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c index 9b026bf7afef..296612153ea2 100644 --- a/drivers/usb/serial/generic.c +++ b/drivers/usb/serial/generic.c | |||
@@ -24,8 +24,6 @@ | |||
24 | #include <linux/kfifo.h> | 24 | #include <linux/kfifo.h> |
25 | #include <linux/serial.h> | 25 | #include <linux/serial.h> |
26 | 26 | ||
27 | static int debug; | ||
28 | |||
29 | #ifdef CONFIG_USB_SERIAL_GENERIC | 27 | #ifdef CONFIG_USB_SERIAL_GENERIC |
30 | 28 | ||
31 | static __u16 vendor = 0x05f9; | 29 | static __u16 vendor = 0x05f9; |
@@ -60,11 +58,10 @@ static struct usb_serial_driver * const serial_drivers[] = { | |||
60 | 58 | ||
61 | #endif | 59 | #endif |
62 | 60 | ||
63 | int usb_serial_generic_register(int _debug) | 61 | int usb_serial_generic_register(void) |
64 | { | 62 | { |
65 | int retval = 0; | 63 | int retval = 0; |
66 | 64 | ||
67 | debug = _debug; | ||
68 | #ifdef CONFIG_USB_SERIAL_GENERIC | 65 | #ifdef CONFIG_USB_SERIAL_GENERIC |
69 | generic_device_ids[0].idVendor = vendor; | 66 | generic_device_ids[0].idVendor = vendor; |
70 | generic_device_ids[0].idProduct = product; | 67 | generic_device_ids[0].idProduct = product; |
@@ -171,8 +168,7 @@ retry: | |||
171 | urb->transfer_buffer, | 168 | urb->transfer_buffer, |
172 | port->bulk_out_size); | 169 | port->bulk_out_size); |
173 | urb->transfer_buffer_length = count; | 170 | urb->transfer_buffer_length = count; |
174 | usb_serial_debug_data(debug, &port->dev, __func__, count, | 171 | usb_serial_debug_data(&port->dev, __func__, count, urb->transfer_buffer); |
175 | urb->transfer_buffer); | ||
176 | spin_lock_irqsave(&port->lock, flags); | 172 | spin_lock_irqsave(&port->lock, flags); |
177 | port->tx_bytes += count; | 173 | port->tx_bytes += count; |
178 | spin_unlock_irqrestore(&port->lock, flags); | 174 | spin_unlock_irqrestore(&port->lock, flags); |
@@ -365,8 +361,7 @@ void usb_serial_generic_read_bulk_callback(struct urb *urb) | |||
365 | return; | 361 | return; |
366 | } | 362 | } |
367 | 363 | ||
368 | usb_serial_debug_data(debug, &port->dev, __func__, | 364 | usb_serial_debug_data(&port->dev, __func__, urb->actual_length, data); |
369 | urb->actual_length, data); | ||
370 | port->serial->type->process_read_urb(urb); | 365 | port->serial->type->process_read_urb(urb); |
371 | 366 | ||
372 | /* Throttle the device if requested by tty */ | 367 | /* Throttle the device if requested by tty */ |
diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c index f435575c4e6e..8e6faaf3580c 100644 --- a/drivers/usb/serial/io_edgeport.c +++ b/drivers/usb/serial/io_edgeport.c | |||
@@ -190,9 +190,6 @@ static const struct divisor_table_entry divisor_table[] = { | |||
190 | { 230400, 1}, | 190 | { 230400, 1}, |
191 | }; | 191 | }; |
192 | 192 | ||
193 | /* local variables */ | ||
194 | static bool debug; | ||
195 | |||
196 | /* Number of outstanding Command Write Urbs */ | 193 | /* Number of outstanding Command Write Urbs */ |
197 | static atomic_t CmdUrbs = ATOMIC_INIT(0); | 194 | static atomic_t CmdUrbs = ATOMIC_INIT(0); |
198 | 195 | ||
@@ -244,7 +241,7 @@ static void handle_new_lsr(struct edgeport_port *edge_port, __u8 lsrData, | |||
244 | __u8 lsr, __u8 data); | 241 | __u8 lsr, __u8 data); |
245 | static int send_iosp_ext_cmd(struct edgeport_port *edge_port, __u8 command, | 242 | static int send_iosp_ext_cmd(struct edgeport_port *edge_port, __u8 command, |
246 | __u8 param); | 243 | __u8 param); |
247 | static int calc_baud_rate_divisor(int baud_rate, int *divisor); | 244 | static int calc_baud_rate_divisor(struct device *dev, int baud_rate, int *divisor); |
248 | static int send_cmd_write_baud_rate(struct edgeport_port *edge_port, | 245 | static int send_cmd_write_baud_rate(struct edgeport_port *edge_port, |
249 | int baudRate); | 246 | int baudRate); |
250 | static void change_port_settings(struct tty_struct *tty, | 247 | static void change_port_settings(struct tty_struct *tty, |
@@ -286,6 +283,7 @@ static void unicode_to_ascii(char *string, int buflen, | |||
286 | ************************************************************************/ | 283 | ************************************************************************/ |
287 | static void update_edgeport_E2PROM(struct edgeport_serial *edge_serial) | 284 | static void update_edgeport_E2PROM(struct edgeport_serial *edge_serial) |
288 | { | 285 | { |
286 | struct device *dev = &edge_serial->serial->dev->dev; | ||
289 | __u32 BootCurVer; | 287 | __u32 BootCurVer; |
290 | __u32 BootNewVer; | 288 | __u32 BootNewVer; |
291 | __u8 BootMajorVersion; | 289 | __u8 BootMajorVersion; |
@@ -311,7 +309,7 @@ static void update_edgeport_E2PROM(struct edgeport_serial *edge_serial) | |||
311 | response = request_ihex_firmware(&fw, fw_name, | 309 | response = request_ihex_firmware(&fw, fw_name, |
312 | &edge_serial->serial->dev->dev); | 310 | &edge_serial->serial->dev->dev); |
313 | if (response) { | 311 | if (response) { |
314 | printk(KERN_ERR "Failed to load image \"%s\" err %d\n", | 312 | dev_err(dev, "Failed to load image \"%s\" err %d\n", |
315 | fw_name, response); | 313 | fw_name, response); |
316 | return; | 314 | return; |
317 | } | 315 | } |
@@ -330,20 +328,20 @@ static void update_edgeport_E2PROM(struct edgeport_serial *edge_serial) | |||
330 | (BootMinorVersion << 16) + | 328 | (BootMinorVersion << 16) + |
331 | BootBuildNumber; | 329 | BootBuildNumber; |
332 | 330 | ||
333 | dbg("Current Boot Image version %d.%d.%d", | 331 | dev_dbg(dev, "Current Boot Image version %d.%d.%d\n", |
334 | edge_serial->boot_descriptor.MajorVersion, | 332 | edge_serial->boot_descriptor.MajorVersion, |
335 | edge_serial->boot_descriptor.MinorVersion, | 333 | edge_serial->boot_descriptor.MinorVersion, |
336 | le16_to_cpu(edge_serial->boot_descriptor.BuildNumber)); | 334 | le16_to_cpu(edge_serial->boot_descriptor.BuildNumber)); |
337 | 335 | ||
338 | 336 | ||
339 | if (BootNewVer > BootCurVer) { | 337 | if (BootNewVer > BootCurVer) { |
340 | dbg("**Update Boot Image from %d.%d.%d to %d.%d.%d", | 338 | dev_dbg(dev, "**Update Boot Image from %d.%d.%d to %d.%d.%d\n", |
341 | edge_serial->boot_descriptor.MajorVersion, | 339 | edge_serial->boot_descriptor.MajorVersion, |
342 | edge_serial->boot_descriptor.MinorVersion, | 340 | edge_serial->boot_descriptor.MinorVersion, |
343 | le16_to_cpu(edge_serial->boot_descriptor.BuildNumber), | 341 | le16_to_cpu(edge_serial->boot_descriptor.BuildNumber), |
344 | BootMajorVersion, BootMinorVersion, BootBuildNumber); | 342 | BootMajorVersion, BootMinorVersion, BootBuildNumber); |
345 | 343 | ||
346 | dbg("Downloading new Boot Image"); | 344 | dev_dbg(dev, "Downloading new Boot Image\n"); |
347 | 345 | ||
348 | for (rec = ihex_next_binrec(rec); rec; | 346 | for (rec = ihex_next_binrec(rec); rec; |
349 | rec = ihex_next_binrec(rec)) { | 347 | rec = ihex_next_binrec(rec)) { |
@@ -362,7 +360,7 @@ static void update_edgeport_E2PROM(struct edgeport_serial *edge_serial) | |||
362 | } | 360 | } |
363 | } | 361 | } |
364 | } else { | 362 | } else { |
365 | dbg("Boot Image -- already up to date"); | 363 | dev_dbg(dev, "Boot Image -- already up to date\n"); |
366 | } | 364 | } |
367 | release_firmware(fw); | 365 | release_firmware(fw); |
368 | } | 366 | } |
@@ -379,7 +377,7 @@ static int get_string_desc(struct usb_device *dev, int Id, | |||
379 | struct usb_string_descriptor StringDesc; | 377 | struct usb_string_descriptor StringDesc; |
380 | struct usb_string_descriptor *pStringDesc; | 378 | struct usb_string_descriptor *pStringDesc; |
381 | 379 | ||
382 | dbg("%s - USB String ID = %d", __func__, Id); | 380 | dev_dbg(&dev->dev, "%s - USB String ID = %d\n", __func__, Id); |
383 | 381 | ||
384 | if (!usb_get_descriptor(dev, USB_DT_STRING, Id, &StringDesc, | 382 | if (!usb_get_descriptor(dev, USB_DT_STRING, Id, &StringDesc, |
385 | sizeof(StringDesc))) | 383 | sizeof(StringDesc))) |
@@ -400,34 +398,39 @@ static int get_string_desc(struct usb_device *dev, int Id, | |||
400 | } | 398 | } |
401 | #endif | 399 | #endif |
402 | 400 | ||
403 | static void dump_product_info(struct edgeport_product_info *product_info) | 401 | static void dump_product_info(struct edgeport_serial *edge_serial, |
402 | struct edgeport_product_info *product_info) | ||
404 | { | 403 | { |
404 | struct device *dev = &edge_serial->serial->dev->dev; | ||
405 | |||
405 | /* Dump Product Info structure */ | 406 | /* Dump Product Info structure */ |
406 | dbg("**Product Information:"); | 407 | dev_dbg(dev, "**Product Information:\n"); |
407 | dbg(" ProductId %x", product_info->ProductId); | 408 | dev_dbg(dev, " ProductId %x\n", product_info->ProductId); |
408 | dbg(" NumPorts %d", product_info->NumPorts); | 409 | dev_dbg(dev, " NumPorts %d\n", product_info->NumPorts); |
409 | dbg(" ProdInfoVer %d", product_info->ProdInfoVer); | 410 | dev_dbg(dev, " ProdInfoVer %d\n", product_info->ProdInfoVer); |
410 | dbg(" IsServer %d", product_info->IsServer); | 411 | dev_dbg(dev, " IsServer %d\n", product_info->IsServer); |
411 | dbg(" IsRS232 %d", product_info->IsRS232); | 412 | dev_dbg(dev, " IsRS232 %d\n", product_info->IsRS232); |
412 | dbg(" IsRS422 %d", product_info->IsRS422); | 413 | dev_dbg(dev, " IsRS422 %d\n", product_info->IsRS422); |
413 | dbg(" IsRS485 %d", product_info->IsRS485); | 414 | dev_dbg(dev, " IsRS485 %d\n", product_info->IsRS485); |
414 | dbg(" RomSize %d", product_info->RomSize); | 415 | dev_dbg(dev, " RomSize %d\n", product_info->RomSize); |
415 | dbg(" RamSize %d", product_info->RamSize); | 416 | dev_dbg(dev, " RamSize %d\n", product_info->RamSize); |
416 | dbg(" CpuRev %x", product_info->CpuRev); | 417 | dev_dbg(dev, " CpuRev %x\n", product_info->CpuRev); |
417 | dbg(" BoardRev %x", product_info->BoardRev); | 418 | dev_dbg(dev, " BoardRev %x\n", product_info->BoardRev); |
418 | dbg(" BootMajorVersion %d.%d.%d", product_info->BootMajorVersion, | 419 | dev_dbg(dev, " BootMajorVersion %d.%d.%d\n", |
419 | product_info->BootMinorVersion, | 420 | product_info->BootMajorVersion, |
420 | le16_to_cpu(product_info->BootBuildNumber)); | 421 | product_info->BootMinorVersion, |
421 | dbg(" FirmwareMajorVersion %d.%d.%d", | 422 | le16_to_cpu(product_info->BootBuildNumber)); |
422 | product_info->FirmwareMajorVersion, | 423 | dev_dbg(dev, " FirmwareMajorVersion %d.%d.%d\n", |
423 | product_info->FirmwareMinorVersion, | 424 | product_info->FirmwareMajorVersion, |
424 | le16_to_cpu(product_info->FirmwareBuildNumber)); | 425 | product_info->FirmwareMinorVersion, |
425 | dbg(" ManufactureDescDate %d/%d/%d", | 426 | le16_to_cpu(product_info->FirmwareBuildNumber)); |
426 | product_info->ManufactureDescDate[0], | 427 | dev_dbg(dev, " ManufactureDescDate %d/%d/%d\n", |
427 | product_info->ManufactureDescDate[1], | 428 | product_info->ManufactureDescDate[0], |
428 | product_info->ManufactureDescDate[2]+1900); | 429 | product_info->ManufactureDescDate[1], |
429 | dbg(" iDownloadFile 0x%x", product_info->iDownloadFile); | 430 | product_info->ManufactureDescDate[2]+1900); |
430 | dbg(" EpicVer %d", product_info->EpicVer); | 431 | dev_dbg(dev, " iDownloadFile 0x%x\n", |
432 | product_info->iDownloadFile); | ||
433 | dev_dbg(dev, " EpicVer %d\n", product_info->EpicVer); | ||
431 | } | 434 | } |
432 | 435 | ||
433 | static void get_product_info(struct edgeport_serial *edge_serial) | 436 | static void get_product_info(struct edgeport_serial *edge_serial) |
@@ -462,7 +465,7 @@ static void get_product_info(struct edgeport_serial *edge_serial) | |||
462 | product_info->iDownloadFile = EDGE_DOWNLOAD_FILE_80251; | 465 | product_info->iDownloadFile = EDGE_DOWNLOAD_FILE_80251; |
463 | else | 466 | else |
464 | product_info->iDownloadFile = EDGE_DOWNLOAD_FILE_I930; | 467 | product_info->iDownloadFile = EDGE_DOWNLOAD_FILE_I930; |
465 | 468 | ||
466 | /* Determine Product type and set appropriate flags */ | 469 | /* Determine Product type and set appropriate flags */ |
467 | switch (DEVICE_ID_FROM_USB_PRODUCT_ID(product_info->ProductId)) { | 470 | switch (DEVICE_ID_FROM_USB_PRODUCT_ID(product_info->ProductId)) { |
468 | case ION_DEVICE_ID_EDGEPORT_COMPATIBLE: | 471 | case ION_DEVICE_ID_EDGEPORT_COMPATIBLE: |
@@ -490,7 +493,7 @@ static void get_product_info(struct edgeport_serial *edge_serial) | |||
490 | break; | 493 | break; |
491 | } | 494 | } |
492 | 495 | ||
493 | dump_product_info(product_info); | 496 | dump_product_info(edge_serial, product_info); |
494 | } | 497 | } |
495 | 498 | ||
496 | static int get_epic_descriptor(struct edgeport_serial *ep) | 499 | static int get_epic_descriptor(struct edgeport_serial *ep) |
@@ -500,6 +503,7 @@ static int get_epic_descriptor(struct edgeport_serial *ep) | |||
500 | struct edgeport_product_info *product_info = &ep->product_info; | 503 | struct edgeport_product_info *product_info = &ep->product_info; |
501 | struct edge_compatibility_descriptor *epic = &ep->epic_descriptor; | 504 | struct edge_compatibility_descriptor *epic = &ep->epic_descriptor; |
502 | struct edge_compatibility_bits *bits; | 505 | struct edge_compatibility_bits *bits; |
506 | struct device *dev = &serial->dev->dev; | ||
503 | 507 | ||
504 | ep->is_epic = 0; | 508 | ep->is_epic = 0; |
505 | result = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), | 509 | result = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), |
@@ -509,8 +513,6 @@ static int get_epic_descriptor(struct edgeport_serial *ep) | |||
509 | sizeof(struct edge_compatibility_descriptor), | 513 | sizeof(struct edge_compatibility_descriptor), |
510 | 300); | 514 | 300); |
511 | 515 | ||
512 | dbg("%s result = %d", __func__, result); | ||
513 | |||
514 | if (result > 0) { | 516 | if (result > 0) { |
515 | ep->is_epic = 1; | 517 | ep->is_epic = 1; |
516 | memset(product_info, 0, sizeof(struct edgeport_product_info)); | 518 | memset(product_info, 0, sizeof(struct edgeport_product_info)); |
@@ -524,23 +526,23 @@ static int get_epic_descriptor(struct edgeport_serial *ep) | |||
524 | product_info->EpicVer = epic->EpicVer; | 526 | product_info->EpicVer = epic->EpicVer; |
525 | product_info->Epic = epic->Supports; | 527 | product_info->Epic = epic->Supports; |
526 | product_info->ProductId = ION_DEVICE_ID_EDGEPORT_COMPATIBLE; | 528 | product_info->ProductId = ION_DEVICE_ID_EDGEPORT_COMPATIBLE; |
527 | dump_product_info(product_info); | 529 | dump_product_info(ep, product_info); |
528 | 530 | ||
529 | bits = &ep->epic_descriptor.Supports; | 531 | bits = &ep->epic_descriptor.Supports; |
530 | dbg("**EPIC descriptor:"); | 532 | dev_dbg(dev, "**EPIC descriptor:\n"); |
531 | dbg(" VendEnableSuspend: %s", bits->VendEnableSuspend ? "TRUE": "FALSE"); | 533 | dev_dbg(dev, " VendEnableSuspend: %s\n", bits->VendEnableSuspend ? "TRUE": "FALSE"); |
532 | dbg(" IOSPOpen : %s", bits->IOSPOpen ? "TRUE": "FALSE"); | 534 | dev_dbg(dev, " IOSPOpen : %s\n", bits->IOSPOpen ? "TRUE": "FALSE"); |
533 | dbg(" IOSPClose : %s", bits->IOSPClose ? "TRUE": "FALSE"); | 535 | dev_dbg(dev, " IOSPClose : %s\n", bits->IOSPClose ? "TRUE": "FALSE"); |
534 | dbg(" IOSPChase : %s", bits->IOSPChase ? "TRUE": "FALSE"); | 536 | dev_dbg(dev, " IOSPChase : %s\n", bits->IOSPChase ? "TRUE": "FALSE"); |
535 | dbg(" IOSPSetRxFlow : %s", bits->IOSPSetRxFlow ? "TRUE": "FALSE"); | 537 | dev_dbg(dev, " IOSPSetRxFlow : %s\n", bits->IOSPSetRxFlow ? "TRUE": "FALSE"); |
536 | dbg(" IOSPSetTxFlow : %s", bits->IOSPSetTxFlow ? "TRUE": "FALSE"); | 538 | dev_dbg(dev, " IOSPSetTxFlow : %s\n", bits->IOSPSetTxFlow ? "TRUE": "FALSE"); |
537 | dbg(" IOSPSetXChar : %s", bits->IOSPSetXChar ? "TRUE": "FALSE"); | 539 | dev_dbg(dev, " IOSPSetXChar : %s\n", bits->IOSPSetXChar ? "TRUE": "FALSE"); |
538 | dbg(" IOSPRxCheck : %s", bits->IOSPRxCheck ? "TRUE": "FALSE"); | 540 | dev_dbg(dev, " IOSPRxCheck : %s\n", bits->IOSPRxCheck ? "TRUE": "FALSE"); |
539 | dbg(" IOSPSetClrBreak : %s", bits->IOSPSetClrBreak ? "TRUE": "FALSE"); | 541 | dev_dbg(dev, " IOSPSetClrBreak : %s\n", bits->IOSPSetClrBreak ? "TRUE": "FALSE"); |
540 | dbg(" IOSPWriteMCR : %s", bits->IOSPWriteMCR ? "TRUE": "FALSE"); | 542 | dev_dbg(dev, " IOSPWriteMCR : %s\n", bits->IOSPWriteMCR ? "TRUE": "FALSE"); |
541 | dbg(" IOSPWriteLCR : %s", bits->IOSPWriteLCR ? "TRUE": "FALSE"); | 543 | dev_dbg(dev, " IOSPWriteLCR : %s\n", bits->IOSPWriteLCR ? "TRUE": "FALSE"); |
542 | dbg(" IOSPSetBaudRate : %s", bits->IOSPSetBaudRate ? "TRUE": "FALSE"); | 544 | dev_dbg(dev, " IOSPSetBaudRate : %s\n", bits->IOSPSetBaudRate ? "TRUE": "FALSE"); |
543 | dbg(" TrueEdgeport : %s", bits->TrueEdgeport ? "TRUE": "FALSE"); | 545 | dev_dbg(dev, " TrueEdgeport : %s\n", bits->TrueEdgeport ? "TRUE": "FALSE"); |
544 | } | 546 | } |
545 | 547 | ||
546 | return result; | 548 | return result; |
@@ -561,7 +563,8 @@ static int get_epic_descriptor(struct edgeport_serial *ep) | |||
561 | *****************************************************************************/ | 563 | *****************************************************************************/ |
562 | static void edge_interrupt_callback(struct urb *urb) | 564 | static void edge_interrupt_callback(struct urb *urb) |
563 | { | 565 | { |
564 | struct edgeport_serial *edge_serial = urb->context; | 566 | struct edgeport_serial *edge_serial = urb->context; |
567 | struct device *dev; | ||
565 | struct edgeport_port *edge_port; | 568 | struct edgeport_port *edge_port; |
566 | struct usb_serial_port *port; | 569 | struct usb_serial_port *port; |
567 | struct tty_struct *tty; | 570 | struct tty_struct *tty; |
@@ -574,8 +577,6 @@ static void edge_interrupt_callback(struct urb *urb) | |||
574 | int result; | 577 | int result; |
575 | int status = urb->status; | 578 | int status = urb->status; |
576 | 579 | ||
577 | dbg("%s", __func__); | ||
578 | |||
579 | switch (status) { | 580 | switch (status) { |
580 | case 0: | 581 | case 0: |
581 | /* success */ | 582 | /* success */ |
@@ -584,36 +585,42 @@ static void edge_interrupt_callback(struct urb *urb) | |||
584 | case -ENOENT: | 585 | case -ENOENT: |
585 | case -ESHUTDOWN: | 586 | case -ESHUTDOWN: |
586 | /* this urb is terminated, clean up */ | 587 | /* this urb is terminated, clean up */ |
587 | dbg("%s - urb shutting down with status: %d", | 588 | dev_dbg(&urb->dev->dev, "%s - urb shutting down with status: %d\n", __func__, status); |
588 | __func__, status); | ||
589 | return; | 589 | return; |
590 | default: | 590 | default: |
591 | dbg("%s - nonzero urb status received: %d", __func__, status); | 591 | dev_dbg(&urb->dev->dev, "%s - nonzero urb status received: %d\n", __func__, status); |
592 | goto exit; | 592 | goto exit; |
593 | } | 593 | } |
594 | 594 | ||
595 | dev = &edge_serial->serial->dev->dev; | ||
596 | |||
595 | /* process this interrupt-read even if there are no ports open */ | 597 | /* process this interrupt-read even if there are no ports open */ |
596 | if (length) { | 598 | if (length) { |
597 | usb_serial_debug_data(debug, &edge_serial->serial->dev->dev, | 599 | usb_serial_debug_data(dev, __func__, length, data); |
598 | __func__, length, data); | ||
599 | 600 | ||
600 | if (length > 1) { | 601 | if (length > 1) { |
601 | bytes_avail = data[0] | (data[1] << 8); | 602 | bytes_avail = data[0] | (data[1] << 8); |
602 | if (bytes_avail) { | 603 | if (bytes_avail) { |
603 | spin_lock(&edge_serial->es_lock); | 604 | spin_lock(&edge_serial->es_lock); |
604 | edge_serial->rxBytesAvail += bytes_avail; | 605 | edge_serial->rxBytesAvail += bytes_avail; |
605 | dbg("%s - bytes_avail=%d, rxBytesAvail=%d, read_in_progress=%d", __func__, bytes_avail, edge_serial->rxBytesAvail, edge_serial->read_in_progress); | 606 | dev_dbg(dev, |
607 | "%s - bytes_avail=%d, rxBytesAvail=%d, read_in_progress=%d\n", | ||
608 | __func__, bytes_avail, | ||
609 | edge_serial->rxBytesAvail, | ||
610 | edge_serial->read_in_progress); | ||
606 | 611 | ||
607 | if (edge_serial->rxBytesAvail > 0 && | 612 | if (edge_serial->rxBytesAvail > 0 && |
608 | !edge_serial->read_in_progress) { | 613 | !edge_serial->read_in_progress) { |
609 | dbg("%s - posting a read", __func__); | 614 | dev_dbg(dev, "%s - posting a read\n", __func__); |
610 | edge_serial->read_in_progress = true; | 615 | edge_serial->read_in_progress = true; |
611 | 616 | ||
612 | /* we have pending bytes on the | 617 | /* we have pending bytes on the |
613 | bulk in pipe, send a request */ | 618 | bulk in pipe, send a request */ |
614 | result = usb_submit_urb(edge_serial->read_urb, GFP_ATOMIC); | 619 | result = usb_submit_urb(edge_serial->read_urb, GFP_ATOMIC); |
615 | if (result) { | 620 | if (result) { |
616 | dev_err(&edge_serial->serial->dev->dev, "%s - usb_submit_urb(read bulk) failed with result = %d\n", __func__, result); | 621 | dev_err(dev, |
622 | "%s - usb_submit_urb(read bulk) failed with result = %d\n", | ||
623 | __func__, result); | ||
617 | edge_serial->read_in_progress = false; | 624 | edge_serial->read_in_progress = false; |
618 | } | 625 | } |
619 | } | 626 | } |
@@ -633,9 +640,9 @@ static void edge_interrupt_callback(struct urb *urb) | |||
633 | spin_lock(&edge_port->ep_lock); | 640 | spin_lock(&edge_port->ep_lock); |
634 | edge_port->txCredits += txCredits; | 641 | edge_port->txCredits += txCredits; |
635 | spin_unlock(&edge_port->ep_lock); | 642 | spin_unlock(&edge_port->ep_lock); |
636 | dbg("%s - txcredits for port%d = %d", | 643 | dev_dbg(dev, "%s - txcredits for port%d = %d\n", |
637 | __func__, portNumber, | 644 | __func__, portNumber, |
638 | edge_port->txCredits); | 645 | edge_port->txCredits); |
639 | 646 | ||
640 | /* tell the tty driver that something | 647 | /* tell the tty driver that something |
641 | has changed */ | 648 | has changed */ |
@@ -673,49 +680,48 @@ exit: | |||
673 | static void edge_bulk_in_callback(struct urb *urb) | 680 | static void edge_bulk_in_callback(struct urb *urb) |
674 | { | 681 | { |
675 | struct edgeport_serial *edge_serial = urb->context; | 682 | struct edgeport_serial *edge_serial = urb->context; |
683 | struct device *dev; | ||
676 | unsigned char *data = urb->transfer_buffer; | 684 | unsigned char *data = urb->transfer_buffer; |
677 | int retval; | 685 | int retval; |
678 | __u16 raw_data_length; | 686 | __u16 raw_data_length; |
679 | int status = urb->status; | 687 | int status = urb->status; |
680 | 688 | ||
681 | dbg("%s", __func__); | ||
682 | |||
683 | if (status) { | 689 | if (status) { |
684 | dbg("%s - nonzero read bulk status received: %d", | 690 | dev_dbg(&urb->dev->dev, "%s - nonzero read bulk status received: %d\n", |
685 | __func__, status); | 691 | __func__, status); |
686 | edge_serial->read_in_progress = false; | 692 | edge_serial->read_in_progress = false; |
687 | return; | 693 | return; |
688 | } | 694 | } |
689 | 695 | ||
690 | if (urb->actual_length == 0) { | 696 | if (urb->actual_length == 0) { |
691 | dbg("%s - read bulk callback with no data", __func__); | 697 | dev_dbg(&urb->dev->dev, "%s - read bulk callback with no data\n", __func__); |
692 | edge_serial->read_in_progress = false; | 698 | edge_serial->read_in_progress = false; |
693 | return; | 699 | return; |
694 | } | 700 | } |
695 | 701 | ||
702 | dev = &edge_serial->serial->dev->dev; | ||
696 | raw_data_length = urb->actual_length; | 703 | raw_data_length = urb->actual_length; |
697 | 704 | ||
698 | usb_serial_debug_data(debug, &edge_serial->serial->dev->dev, | 705 | usb_serial_debug_data(dev, __func__, raw_data_length, data); |
699 | __func__, raw_data_length, data); | ||
700 | 706 | ||
701 | spin_lock(&edge_serial->es_lock); | 707 | spin_lock(&edge_serial->es_lock); |
702 | 708 | ||
703 | /* decrement our rxBytes available by the number that we just got */ | 709 | /* decrement our rxBytes available by the number that we just got */ |
704 | edge_serial->rxBytesAvail -= raw_data_length; | 710 | edge_serial->rxBytesAvail -= raw_data_length; |
705 | 711 | ||
706 | dbg("%s - Received = %d, rxBytesAvail %d", __func__, | 712 | dev_dbg(dev, "%s - Received = %d, rxBytesAvail %d\n", __func__, |
707 | raw_data_length, edge_serial->rxBytesAvail); | 713 | raw_data_length, edge_serial->rxBytesAvail); |
708 | 714 | ||
709 | process_rcvd_data(edge_serial, data, urb->actual_length); | 715 | process_rcvd_data(edge_serial, data, urb->actual_length); |
710 | 716 | ||
711 | /* check to see if there's any more data for us to read */ | 717 | /* check to see if there's any more data for us to read */ |
712 | if (edge_serial->rxBytesAvail > 0) { | 718 | if (edge_serial->rxBytesAvail > 0) { |
713 | dbg("%s - posting a read", __func__); | 719 | dev_dbg(dev, "%s - posting a read\n", __func__); |
714 | retval = usb_submit_urb(edge_serial->read_urb, GFP_ATOMIC); | 720 | retval = usb_submit_urb(edge_serial->read_urb, GFP_ATOMIC); |
715 | if (retval) { | 721 | if (retval) { |
716 | dev_err(&urb->dev->dev, | 722 | dev_err(dev, |
717 | "%s - usb_submit_urb(read bulk) failed, " | 723 | "%s - usb_submit_urb(read bulk) failed, retval = %d\n", |
718 | "retval = %d\n", __func__, retval); | 724 | __func__, retval); |
719 | edge_serial->read_in_progress = false; | 725 | edge_serial->read_in_progress = false; |
720 | } | 726 | } |
721 | } else { | 727 | } else { |
@@ -737,11 +743,10 @@ static void edge_bulk_out_data_callback(struct urb *urb) | |||
737 | struct tty_struct *tty; | 743 | struct tty_struct *tty; |
738 | int status = urb->status; | 744 | int status = urb->status; |
739 | 745 | ||
740 | dbg("%s", __func__); | ||
741 | |||
742 | if (status) { | 746 | if (status) { |
743 | dbg("%s - nonzero write bulk status received: %d", | 747 | dev_dbg(&urb->dev->dev, |
744 | __func__, status); | 748 | "%s - nonzero write bulk status received: %d\n", |
749 | __func__, status); | ||
745 | } | 750 | } |
746 | 751 | ||
747 | tty = tty_port_tty_get(&edge_port->port->port); | 752 | tty = tty_port_tty_get(&edge_port->port->port); |
@@ -773,11 +778,9 @@ static void edge_bulk_out_cmd_callback(struct urb *urb) | |||
773 | struct tty_struct *tty; | 778 | struct tty_struct *tty; |
774 | int status = urb->status; | 779 | int status = urb->status; |
775 | 780 | ||
776 | dbg("%s", __func__); | ||
777 | |||
778 | atomic_dec(&CmdUrbs); | 781 | atomic_dec(&CmdUrbs); |
779 | dbg("%s - FREE URB %p (outstanding %d)", __func__, | 782 | dev_dbg(&urb->dev->dev, "%s - FREE URB %p (outstanding %d)\n", |
780 | urb, atomic_read(&CmdUrbs)); | 783 | __func__, urb, atomic_read(&CmdUrbs)); |
781 | 784 | ||
782 | 785 | ||
783 | /* clean up the transfer buffer */ | 786 | /* clean up the transfer buffer */ |
@@ -787,8 +790,9 @@ static void edge_bulk_out_cmd_callback(struct urb *urb) | |||
787 | usb_free_urb(urb); | 790 | usb_free_urb(urb); |
788 | 791 | ||
789 | if (status) { | 792 | if (status) { |
790 | dbg("%s - nonzero write bulk status received: %d", | 793 | dev_dbg(&urb->dev->dev, |
791 | __func__, status); | 794 | "%s - nonzero write bulk status received: %d\n", |
795 | __func__, status); | ||
792 | return; | 796 | return; |
793 | } | 797 | } |
794 | 798 | ||
@@ -819,12 +823,11 @@ static void edge_bulk_out_cmd_callback(struct urb *urb) | |||
819 | static int edge_open(struct tty_struct *tty, struct usb_serial_port *port) | 823 | static int edge_open(struct tty_struct *tty, struct usb_serial_port *port) |
820 | { | 824 | { |
821 | struct edgeport_port *edge_port = usb_get_serial_port_data(port); | 825 | struct edgeport_port *edge_port = usb_get_serial_port_data(port); |
826 | struct device *dev = &port->dev; | ||
822 | struct usb_serial *serial; | 827 | struct usb_serial *serial; |
823 | struct edgeport_serial *edge_serial; | 828 | struct edgeport_serial *edge_serial; |
824 | int response; | 829 | int response; |
825 | 830 | ||
826 | dbg("%s - port %d", __func__, port->number); | ||
827 | |||
828 | if (edge_port == NULL) | 831 | if (edge_port == NULL) |
829 | return -ENODEV; | 832 | return -ENODEV; |
830 | 833 | ||
@@ -875,9 +878,8 @@ static int edge_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
875 | response = usb_submit_urb(edge_serial->interrupt_read_urb, | 878 | response = usb_submit_urb(edge_serial->interrupt_read_urb, |
876 | GFP_KERNEL); | 879 | GFP_KERNEL); |
877 | if (response) { | 880 | if (response) { |
878 | dev_err(&port->dev, | 881 | dev_err(dev, "%s - Error %d submitting control urb\n", |
879 | "%s - Error %d submitting control urb\n", | 882 | __func__, response); |
880 | __func__, response); | ||
881 | } | 883 | } |
882 | } | 884 | } |
883 | 885 | ||
@@ -902,8 +904,7 @@ static int edge_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
902 | response = send_iosp_ext_cmd(edge_port, IOSP_CMD_OPEN_PORT, 0); | 904 | response = send_iosp_ext_cmd(edge_port, IOSP_CMD_OPEN_PORT, 0); |
903 | 905 | ||
904 | if (response < 0) { | 906 | if (response < 0) { |
905 | dev_err(&port->dev, "%s - error sending open port command\n", | 907 | dev_err(dev, "%s - error sending open port command\n", __func__); |
906 | __func__); | ||
907 | edge_port->openPending = false; | 908 | edge_port->openPending = false; |
908 | return -ENODEV; | 909 | return -ENODEV; |
909 | } | 910 | } |
@@ -914,7 +915,7 @@ static int edge_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
914 | 915 | ||
915 | if (!edge_port->open) { | 916 | if (!edge_port->open) { |
916 | /* open timed out */ | 917 | /* open timed out */ |
917 | dbg("%s - open timedout", __func__); | 918 | dev_dbg(dev, "%s - open timedout\n", __func__); |
918 | edge_port->openPending = false; | 919 | edge_port->openPending = false; |
919 | return -ENODEV; | 920 | return -ENODEV; |
920 | } | 921 | } |
@@ -927,7 +928,7 @@ static int edge_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
927 | edge_port->txfifo.fifo = kmalloc(edge_port->maxTxCredits, GFP_KERNEL); | 928 | edge_port->txfifo.fifo = kmalloc(edge_port->maxTxCredits, GFP_KERNEL); |
928 | 929 | ||
929 | if (!edge_port->txfifo.fifo) { | 930 | if (!edge_port->txfifo.fifo) { |
930 | dbg("%s - no memory", __func__); | 931 | dev_dbg(dev, "%s - no memory\n", __func__); |
931 | edge_close(port); | 932 | edge_close(port); |
932 | return -ENOMEM; | 933 | return -ENOMEM; |
933 | } | 934 | } |
@@ -937,15 +938,13 @@ static int edge_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
937 | edge_port->write_in_progress = false; | 938 | edge_port->write_in_progress = false; |
938 | 939 | ||
939 | if (!edge_port->write_urb) { | 940 | if (!edge_port->write_urb) { |
940 | dbg("%s - no memory", __func__); | 941 | dev_dbg(dev, "%s - no memory\n", __func__); |
941 | edge_close(port); | 942 | edge_close(port); |
942 | return -ENOMEM; | 943 | return -ENOMEM; |
943 | } | 944 | } |
944 | 945 | ||
945 | dbg("%s(%d) - Initialize TX fifo to %d bytes", | 946 | dev_dbg(dev, "%s(%d) - Initialize TX fifo to %d bytes\n", |
946 | __func__, port->number, edge_port->maxTxCredits); | 947 | __func__, port->number, edge_port->maxTxCredits); |
947 | |||
948 | dbg("%s exited", __func__); | ||
949 | 948 | ||
950 | return 0; | 949 | return 0; |
951 | } | 950 | } |
@@ -963,6 +962,7 @@ static int edge_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
963 | ************************************************************************/ | 962 | ************************************************************************/ |
964 | static void block_until_chase_response(struct edgeport_port *edge_port) | 963 | static void block_until_chase_response(struct edgeport_port *edge_port) |
965 | { | 964 | { |
965 | struct device *dev = &edge_port->port->dev; | ||
966 | DEFINE_WAIT(wait); | 966 | DEFINE_WAIT(wait); |
967 | __u16 lastCredits; | 967 | __u16 lastCredits; |
968 | int timeout = 1*HZ; | 968 | int timeout = 1*HZ; |
@@ -974,11 +974,11 @@ static void block_until_chase_response(struct edgeport_port *edge_port) | |||
974 | 974 | ||
975 | /* Did we get our Chase response */ | 975 | /* Did we get our Chase response */ |
976 | if (!edge_port->chaseResponsePending) { | 976 | if (!edge_port->chaseResponsePending) { |
977 | dbg("%s - Got Chase Response", __func__); | 977 | dev_dbg(dev, "%s - Got Chase Response\n", __func__); |
978 | 978 | ||
979 | /* did we get all of our credit back? */ | 979 | /* did we get all of our credit back? */ |
980 | if (edge_port->txCredits == edge_port->maxTxCredits) { | 980 | if (edge_port->txCredits == edge_port->maxTxCredits) { |
981 | dbg("%s - Got all credits", __func__); | 981 | dev_dbg(dev, "%s - Got all credits\n", __func__); |
982 | return; | 982 | return; |
983 | } | 983 | } |
984 | } | 984 | } |
@@ -994,12 +994,12 @@ static void block_until_chase_response(struct edgeport_port *edge_port) | |||
994 | loop--; | 994 | loop--; |
995 | if (loop == 0) { | 995 | if (loop == 0) { |
996 | edge_port->chaseResponsePending = false; | 996 | edge_port->chaseResponsePending = false; |
997 | dbg("%s - Chase TIMEOUT", __func__); | 997 | dev_dbg(dev, "%s - Chase TIMEOUT\n", __func__); |
998 | return; | 998 | return; |
999 | } | 999 | } |
1000 | } else { | 1000 | } else { |
1001 | /* Reset timeout value back to 10 seconds */ | 1001 | /* Reset timeout value back to 10 seconds */ |
1002 | dbg("%s - Last %d, Current %d", __func__, | 1002 | dev_dbg(dev, "%s - Last %d, Current %d\n", __func__, |
1003 | lastCredits, edge_port->txCredits); | 1003 | lastCredits, edge_port->txCredits); |
1004 | loop = 10; | 1004 | loop = 10; |
1005 | } | 1005 | } |
@@ -1019,6 +1019,7 @@ static void block_until_chase_response(struct edgeport_port *edge_port) | |||
1019 | ************************************************************************/ | 1019 | ************************************************************************/ |
1020 | static void block_until_tx_empty(struct edgeport_port *edge_port) | 1020 | static void block_until_tx_empty(struct edgeport_port *edge_port) |
1021 | { | 1021 | { |
1022 | struct device *dev = &edge_port->port->dev; | ||
1022 | DEFINE_WAIT(wait); | 1023 | DEFINE_WAIT(wait); |
1023 | struct TxFifo *fifo = &edge_port->txfifo; | 1024 | struct TxFifo *fifo = &edge_port->txfifo; |
1024 | __u32 lastCount; | 1025 | __u32 lastCount; |
@@ -1031,7 +1032,7 @@ static void block_until_tx_empty(struct edgeport_port *edge_port) | |||
1031 | 1032 | ||
1032 | /* Is the Edgeport Buffer empty? */ | 1033 | /* Is the Edgeport Buffer empty? */ |
1033 | if (lastCount == 0) { | 1034 | if (lastCount == 0) { |
1034 | dbg("%s - TX Buffer Empty", __func__); | 1035 | dev_dbg(dev, "%s - TX Buffer Empty\n", __func__); |
1035 | return; | 1036 | return; |
1036 | } | 1037 | } |
1037 | 1038 | ||
@@ -1041,13 +1042,13 @@ static void block_until_tx_empty(struct edgeport_port *edge_port) | |||
1041 | schedule_timeout(timeout); | 1042 | schedule_timeout(timeout); |
1042 | finish_wait(&edge_port->wait_chase, &wait); | 1043 | finish_wait(&edge_port->wait_chase, &wait); |
1043 | 1044 | ||
1044 | dbg("%s wait", __func__); | 1045 | dev_dbg(dev, "%s wait\n", __func__); |
1045 | 1046 | ||
1046 | if (lastCount == fifo->count) { | 1047 | if (lastCount == fifo->count) { |
1047 | /* No activity.. count down. */ | 1048 | /* No activity.. count down. */ |
1048 | loop--; | 1049 | loop--; |
1049 | if (loop == 0) { | 1050 | if (loop == 0) { |
1050 | dbg("%s - TIMEOUT", __func__); | 1051 | dev_dbg(dev, "%s - TIMEOUT\n", __func__); |
1051 | return; | 1052 | return; |
1052 | } | 1053 | } |
1053 | } else { | 1054 | } else { |
@@ -1068,8 +1069,6 @@ static void edge_close(struct usb_serial_port *port) | |||
1068 | struct edgeport_port *edge_port; | 1069 | struct edgeport_port *edge_port; |
1069 | int status; | 1070 | int status; |
1070 | 1071 | ||
1071 | dbg("%s - port %d", __func__, port->number); | ||
1072 | |||
1073 | edge_serial = usb_get_serial_data(port->serial); | 1072 | edge_serial = usb_get_serial_data(port->serial); |
1074 | edge_port = usb_get_serial_port_data(port); | 1073 | edge_port = usb_get_serial_port_data(port); |
1075 | if (edge_serial == NULL || edge_port == NULL) | 1074 | if (edge_serial == NULL || edge_port == NULL) |
@@ -1086,7 +1085,7 @@ static void edge_close(struct usb_serial_port *port) | |||
1086 | /* flush and chase */ | 1085 | /* flush and chase */ |
1087 | edge_port->chaseResponsePending = true; | 1086 | edge_port->chaseResponsePending = true; |
1088 | 1087 | ||
1089 | dbg("%s - Sending IOSP_CMD_CHASE_PORT", __func__); | 1088 | dev_dbg(&port->dev, "%s - Sending IOSP_CMD_CHASE_PORT\n", __func__); |
1090 | status = send_iosp_ext_cmd(edge_port, IOSP_CMD_CHASE_PORT, 0); | 1089 | status = send_iosp_ext_cmd(edge_port, IOSP_CMD_CHASE_PORT, 0); |
1091 | if (status == 0) | 1090 | if (status == 0) |
1092 | /* block until chase finished */ | 1091 | /* block until chase finished */ |
@@ -1099,7 +1098,7 @@ static void edge_close(struct usb_serial_port *port) | |||
1099 | ((edge_serial->is_epic) && | 1098 | ((edge_serial->is_epic) && |
1100 | (edge_serial->epic_descriptor.Supports.IOSPClose))) { | 1099 | (edge_serial->epic_descriptor.Supports.IOSPClose))) { |
1101 | /* close the port */ | 1100 | /* close the port */ |
1102 | dbg("%s - Sending IOSP_CMD_CLOSE_PORT", __func__); | 1101 | dev_dbg(&port->dev, "%s - Sending IOSP_CMD_CLOSE_PORT\n", __func__); |
1103 | send_iosp_ext_cmd(edge_port, IOSP_CMD_CLOSE_PORT, 0); | 1102 | send_iosp_ext_cmd(edge_port, IOSP_CMD_CLOSE_PORT, 0); |
1104 | } | 1103 | } |
1105 | 1104 | ||
@@ -1119,8 +1118,6 @@ static void edge_close(struct usb_serial_port *port) | |||
1119 | } | 1118 | } |
1120 | kfree(edge_port->txfifo.fifo); | 1119 | kfree(edge_port->txfifo.fifo); |
1121 | edge_port->txfifo.fifo = NULL; | 1120 | edge_port->txfifo.fifo = NULL; |
1122 | |||
1123 | dbg("%s exited", __func__); | ||
1124 | } | 1121 | } |
1125 | 1122 | ||
1126 | /***************************************************************************** | 1123 | /***************************************************************************** |
@@ -1141,8 +1138,6 @@ static int edge_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
1141 | int secondhalf; | 1138 | int secondhalf; |
1142 | unsigned long flags; | 1139 | unsigned long flags; |
1143 | 1140 | ||
1144 | dbg("%s - port %d", __func__, port->number); | ||
1145 | |||
1146 | if (edge_port == NULL) | 1141 | if (edge_port == NULL) |
1147 | return -ENODEV; | 1142 | return -ENODEV; |
1148 | 1143 | ||
@@ -1155,14 +1150,14 @@ static int edge_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
1155 | copySize = min((unsigned int)count, | 1150 | copySize = min((unsigned int)count, |
1156 | (edge_port->txCredits - fifo->count)); | 1151 | (edge_port->txCredits - fifo->count)); |
1157 | 1152 | ||
1158 | dbg("%s(%d) of %d byte(s) Fifo room %d -- will copy %d bytes", | 1153 | dev_dbg(&port->dev, "%s(%d) of %d byte(s) Fifo room %d -- will copy %d bytes\n", |
1159 | __func__, port->number, count, | 1154 | __func__, port->number, count, |
1160 | edge_port->txCredits - fifo->count, copySize); | 1155 | edge_port->txCredits - fifo->count, copySize); |
1161 | 1156 | ||
1162 | /* catch writes of 0 bytes which the tty driver likes to give us, | 1157 | /* catch writes of 0 bytes which the tty driver likes to give us, |
1163 | and when txCredits is empty */ | 1158 | and when txCredits is empty */ |
1164 | if (copySize == 0) { | 1159 | if (copySize == 0) { |
1165 | dbg("%s - copySize = Zero", __func__); | 1160 | dev_dbg(&port->dev, "%s - copySize = Zero\n", __func__); |
1166 | goto finish_write; | 1161 | goto finish_write; |
1167 | } | 1162 | } |
1168 | 1163 | ||
@@ -1175,13 +1170,12 @@ static int edge_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
1175 | */ | 1170 | */ |
1176 | bytesleft = fifo->size - fifo->head; | 1171 | bytesleft = fifo->size - fifo->head; |
1177 | firsthalf = min(bytesleft, copySize); | 1172 | firsthalf = min(bytesleft, copySize); |
1178 | dbg("%s - copy %d bytes of %d into fifo ", __func__, | 1173 | dev_dbg(&port->dev, "%s - copy %d bytes of %d into fifo \n", __func__, |
1179 | firsthalf, bytesleft); | 1174 | firsthalf, bytesleft); |
1180 | 1175 | ||
1181 | /* now copy our data */ | 1176 | /* now copy our data */ |
1182 | memcpy(&fifo->fifo[fifo->head], data, firsthalf); | 1177 | memcpy(&fifo->fifo[fifo->head], data, firsthalf); |
1183 | usb_serial_debug_data(debug, &port->dev, __func__, | 1178 | usb_serial_debug_data(&port->dev, __func__, firsthalf, &fifo->fifo[fifo->head]); |
1184 | firsthalf, &fifo->fifo[fifo->head]); | ||
1185 | 1179 | ||
1186 | /* update the index and size */ | 1180 | /* update the index and size */ |
1187 | fifo->head += firsthalf; | 1181 | fifo->head += firsthalf; |
@@ -1194,10 +1188,9 @@ static int edge_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
1194 | secondhalf = copySize-firsthalf; | 1188 | secondhalf = copySize-firsthalf; |
1195 | 1189 | ||
1196 | if (secondhalf) { | 1190 | if (secondhalf) { |
1197 | dbg("%s - copy rest of data %d", __func__, secondhalf); | 1191 | dev_dbg(&port->dev, "%s - copy rest of data %d\n", __func__, secondhalf); |
1198 | memcpy(&fifo->fifo[fifo->head], &data[firsthalf], secondhalf); | 1192 | memcpy(&fifo->fifo[fifo->head], &data[firsthalf], secondhalf); |
1199 | usb_serial_debug_data(debug, &port->dev, __func__, | 1193 | usb_serial_debug_data(&port->dev, __func__, secondhalf, &fifo->fifo[fifo->head]); |
1200 | secondhalf, &fifo->fifo[fifo->head]); | ||
1201 | /* update the index and size */ | 1194 | /* update the index and size */ |
1202 | fifo->count += secondhalf; | 1195 | fifo->count += secondhalf; |
1203 | fifo->head += secondhalf; | 1196 | fifo->head += secondhalf; |
@@ -1212,8 +1205,8 @@ finish_write: | |||
1212 | send_more_port_data((struct edgeport_serial *) | 1205 | send_more_port_data((struct edgeport_serial *) |
1213 | usb_get_serial_data(port->serial), edge_port); | 1206 | usb_get_serial_data(port->serial), edge_port); |
1214 | 1207 | ||
1215 | dbg("%s wrote %d byte(s) TxCredits %d, Fifo %d", __func__, | 1208 | dev_dbg(&port->dev, "%s wrote %d byte(s) TxCredits %d, Fifo %d\n", |
1216 | copySize, edge_port->txCredits, fifo->count); | 1209 | __func__, copySize, edge_port->txCredits, fifo->count); |
1217 | 1210 | ||
1218 | return copySize; | 1211 | return copySize; |
1219 | } | 1212 | } |
@@ -1236,6 +1229,7 @@ static void send_more_port_data(struct edgeport_serial *edge_serial, | |||
1236 | struct edgeport_port *edge_port) | 1229 | struct edgeport_port *edge_port) |
1237 | { | 1230 | { |
1238 | struct TxFifo *fifo = &edge_port->txfifo; | 1231 | struct TxFifo *fifo = &edge_port->txfifo; |
1232 | struct device *dev = &edge_port->port->dev; | ||
1239 | struct urb *urb; | 1233 | struct urb *urb; |
1240 | unsigned char *buffer; | 1234 | unsigned char *buffer; |
1241 | int status; | 1235 | int status; |
@@ -1245,16 +1239,14 @@ static void send_more_port_data(struct edgeport_serial *edge_serial, | |||
1245 | int secondhalf; | 1239 | int secondhalf; |
1246 | unsigned long flags; | 1240 | unsigned long flags; |
1247 | 1241 | ||
1248 | dbg("%s(%d)", __func__, edge_port->port->number); | ||
1249 | |||
1250 | spin_lock_irqsave(&edge_port->ep_lock, flags); | 1242 | spin_lock_irqsave(&edge_port->ep_lock, flags); |
1251 | 1243 | ||
1252 | if (edge_port->write_in_progress || | 1244 | if (edge_port->write_in_progress || |
1253 | !edge_port->open || | 1245 | !edge_port->open || |
1254 | (fifo->count == 0)) { | 1246 | (fifo->count == 0)) { |
1255 | dbg("%s(%d) EXIT - fifo %d, PendingWrite = %d", | 1247 | dev_dbg(dev, "%s(%d) EXIT - fifo %d, PendingWrite = %d\n", |
1256 | __func__, edge_port->port->number, | 1248 | __func__, edge_port->port->number, |
1257 | fifo->count, edge_port->write_in_progress); | 1249 | fifo->count, edge_port->write_in_progress); |
1258 | goto exit_send; | 1250 | goto exit_send; |
1259 | } | 1251 | } |
1260 | 1252 | ||
@@ -1266,7 +1258,7 @@ static void send_more_port_data(struct edgeport_serial *edge_serial, | |||
1266 | * it's better to wait for more credits so we can do a larger write. | 1258 | * it's better to wait for more credits so we can do a larger write. |
1267 | */ | 1259 | */ |
1268 | if (edge_port->txCredits < EDGE_FW_GET_TX_CREDITS_SEND_THRESHOLD(edge_port->maxTxCredits, EDGE_FW_BULK_MAX_PACKET_SIZE)) { | 1260 | if (edge_port->txCredits < EDGE_FW_GET_TX_CREDITS_SEND_THRESHOLD(edge_port->maxTxCredits, EDGE_FW_BULK_MAX_PACKET_SIZE)) { |
1269 | dbg("%s(%d) Not enough credit - fifo %d TxCredit %d", | 1261 | dev_dbg(dev, "%s(%d) Not enough credit - fifo %d TxCredit %d\n", |
1270 | __func__, edge_port->port->number, fifo->count, | 1262 | __func__, edge_port->port->number, fifo->count, |
1271 | edge_port->txCredits); | 1263 | edge_port->txCredits); |
1272 | goto exit_send; | 1264 | goto exit_send; |
@@ -1315,8 +1307,7 @@ static void send_more_port_data(struct edgeport_serial *edge_serial, | |||
1315 | } | 1307 | } |
1316 | 1308 | ||
1317 | if (count) | 1309 | if (count) |
1318 | usb_serial_debug_data(debug, &edge_port->port->dev, | 1310 | usb_serial_debug_data(&edge_port->port->dev, __func__, count, &buffer[2]); |
1319 | __func__, count, &buffer[2]); | ||
1320 | 1311 | ||
1321 | /* fill up the urb with all of our data and submit it */ | 1312 | /* fill up the urb with all of our data and submit it */ |
1322 | usb_fill_bulk_urb(urb, edge_serial->serial->dev, | 1313 | usb_fill_bulk_urb(urb, edge_serial->serial->dev, |
@@ -1341,8 +1332,8 @@ static void send_more_port_data(struct edgeport_serial *edge_serial, | |||
1341 | edge_port->txCredits += count; | 1332 | edge_port->txCredits += count; |
1342 | edge_port->icount.tx -= count; | 1333 | edge_port->icount.tx -= count; |
1343 | } | 1334 | } |
1344 | dbg("%s wrote %d byte(s) TxCredit %d, Fifo %d", | 1335 | dev_dbg(dev, "%s wrote %d byte(s) TxCredit %d, Fifo %d\n", |
1345 | __func__, count, edge_port->txCredits, fifo->count); | 1336 | __func__, count, edge_port->txCredits, fifo->count); |
1346 | 1337 | ||
1347 | exit_send: | 1338 | exit_send: |
1348 | spin_unlock_irqrestore(&edge_port->ep_lock, flags); | 1339 | spin_unlock_irqrestore(&edge_port->ep_lock, flags); |
@@ -1363,17 +1354,13 @@ static int edge_write_room(struct tty_struct *tty) | |||
1363 | int room; | 1354 | int room; |
1364 | unsigned long flags; | 1355 | unsigned long flags; |
1365 | 1356 | ||
1366 | dbg("%s", __func__); | ||
1367 | |||
1368 | if (edge_port == NULL) | 1357 | if (edge_port == NULL) |
1369 | return 0; | 1358 | return 0; |
1370 | if (edge_port->closePending) | 1359 | if (edge_port->closePending) |
1371 | return 0; | 1360 | return 0; |
1372 | 1361 | ||
1373 | dbg("%s - port %d", __func__, port->number); | ||
1374 | |||
1375 | if (!edge_port->open) { | 1362 | if (!edge_port->open) { |
1376 | dbg("%s - port not opened", __func__); | 1363 | dev_dbg(&port->dev, "%s - port not opened\n", __func__); |
1377 | return 0; | 1364 | return 0; |
1378 | } | 1365 | } |
1379 | 1366 | ||
@@ -1382,7 +1369,7 @@ static int edge_write_room(struct tty_struct *tty) | |||
1382 | room = edge_port->txCredits - edge_port->txfifo.count; | 1369 | room = edge_port->txCredits - edge_port->txfifo.count; |
1383 | spin_unlock_irqrestore(&edge_port->ep_lock, flags); | 1370 | spin_unlock_irqrestore(&edge_port->ep_lock, flags); |
1384 | 1371 | ||
1385 | dbg("%s - returns %d", __func__, room); | 1372 | dev_dbg(&port->dev, "%s - returns %d\n", __func__, room); |
1386 | return room; | 1373 | return room; |
1387 | } | 1374 | } |
1388 | 1375 | ||
@@ -1403,15 +1390,13 @@ static int edge_chars_in_buffer(struct tty_struct *tty) | |||
1403 | int num_chars; | 1390 | int num_chars; |
1404 | unsigned long flags; | 1391 | unsigned long flags; |
1405 | 1392 | ||
1406 | dbg("%s", __func__); | ||
1407 | |||
1408 | if (edge_port == NULL) | 1393 | if (edge_port == NULL) |
1409 | return 0; | 1394 | return 0; |
1410 | if (edge_port->closePending) | 1395 | if (edge_port->closePending) |
1411 | return 0; | 1396 | return 0; |
1412 | 1397 | ||
1413 | if (!edge_port->open) { | 1398 | if (!edge_port->open) { |
1414 | dbg("%s - port not opened", __func__); | 1399 | dev_dbg(&port->dev, "%s - port not opened\n", __func__); |
1415 | return 0; | 1400 | return 0; |
1416 | } | 1401 | } |
1417 | 1402 | ||
@@ -1420,8 +1405,8 @@ static int edge_chars_in_buffer(struct tty_struct *tty) | |||
1420 | edge_port->txfifo.count; | 1405 | edge_port->txfifo.count; |
1421 | spin_unlock_irqrestore(&edge_port->ep_lock, flags); | 1406 | spin_unlock_irqrestore(&edge_port->ep_lock, flags); |
1422 | if (num_chars) { | 1407 | if (num_chars) { |
1423 | dbg("%s(port %d) - returns %d", __func__, | 1408 | dev_dbg(&port->dev, "%s(port %d) - returns %d\n", __func__, |
1424 | port->number, num_chars); | 1409 | port->number, num_chars); |
1425 | } | 1410 | } |
1426 | 1411 | ||
1427 | return num_chars; | 1412 | return num_chars; |
@@ -1439,13 +1424,11 @@ static void edge_throttle(struct tty_struct *tty) | |||
1439 | struct edgeport_port *edge_port = usb_get_serial_port_data(port); | 1424 | struct edgeport_port *edge_port = usb_get_serial_port_data(port); |
1440 | int status; | 1425 | int status; |
1441 | 1426 | ||
1442 | dbg("%s - port %d", __func__, port->number); | ||
1443 | |||
1444 | if (edge_port == NULL) | 1427 | if (edge_port == NULL) |
1445 | return; | 1428 | return; |
1446 | 1429 | ||
1447 | if (!edge_port->open) { | 1430 | if (!edge_port->open) { |
1448 | dbg("%s - port not opened", __func__); | 1431 | dev_dbg(&port->dev, "%s - port not opened\n", __func__); |
1449 | return; | 1432 | return; |
1450 | } | 1433 | } |
1451 | 1434 | ||
@@ -1479,13 +1462,11 @@ static void edge_unthrottle(struct tty_struct *tty) | |||
1479 | struct edgeport_port *edge_port = usb_get_serial_port_data(port); | 1462 | struct edgeport_port *edge_port = usb_get_serial_port_data(port); |
1480 | int status; | 1463 | int status; |
1481 | 1464 | ||
1482 | dbg("%s - port %d", __func__, port->number); | ||
1483 | |||
1484 | if (edge_port == NULL) | 1465 | if (edge_port == NULL) |
1485 | return; | 1466 | return; |
1486 | 1467 | ||
1487 | if (!edge_port->open) { | 1468 | if (!edge_port->open) { |
1488 | dbg("%s - port not opened", __func__); | 1469 | dev_dbg(&port->dev, "%s - port not opened\n", __func__); |
1489 | return; | 1470 | return; |
1490 | } | 1471 | } |
1491 | 1472 | ||
@@ -1517,18 +1498,14 @@ static void edge_set_termios(struct tty_struct *tty, | |||
1517 | unsigned int cflag; | 1498 | unsigned int cflag; |
1518 | 1499 | ||
1519 | cflag = tty->termios.c_cflag; | 1500 | cflag = tty->termios.c_cflag; |
1520 | dbg("%s - clfag %08x iflag %08x", __func__, | 1501 | dev_dbg(&port->dev, "%s - clfag %08x iflag %08x\n", __func__, tty->termios.c_cflag, tty->termios.c_iflag); |
1521 | tty->termios.c_cflag, tty->termios.c_iflag); | 1502 | dev_dbg(&port->dev, "%s - old clfag %08x old iflag %08x\n", __func__, old_termios->c_cflag, old_termios->c_iflag); |
1522 | dbg("%s - old clfag %08x old iflag %08x", __func__, | ||
1523 | old_termios->c_cflag, old_termios->c_iflag); | ||
1524 | |||
1525 | dbg("%s - port %d", __func__, port->number); | ||
1526 | 1503 | ||
1527 | if (edge_port == NULL) | 1504 | if (edge_port == NULL) |
1528 | return; | 1505 | return; |
1529 | 1506 | ||
1530 | if (!edge_port->open) { | 1507 | if (!edge_port->open) { |
1531 | dbg("%s - port not opened", __func__); | 1508 | dev_dbg(&port->dev, "%s - port not opened\n", __func__); |
1532 | return; | 1509 | return; |
1533 | } | 1510 | } |
1534 | 1511 | ||
@@ -1556,7 +1533,7 @@ static int get_lsr_info(struct edgeport_port *edge_port, | |||
1556 | spin_lock_irqsave(&edge_port->ep_lock, flags); | 1533 | spin_lock_irqsave(&edge_port->ep_lock, flags); |
1557 | if (edge_port->maxTxCredits == edge_port->txCredits && | 1534 | if (edge_port->maxTxCredits == edge_port->txCredits && |
1558 | edge_port->txfifo.count == 0) { | 1535 | edge_port->txfifo.count == 0) { |
1559 | dbg("%s -- Empty", __func__); | 1536 | dev_dbg(&edge_port->port->dev, "%s -- Empty\n", __func__); |
1560 | result = TIOCSER_TEMT; | 1537 | result = TIOCSER_TEMT; |
1561 | } | 1538 | } |
1562 | spin_unlock_irqrestore(&edge_port->ep_lock, flags); | 1539 | spin_unlock_irqrestore(&edge_port->ep_lock, flags); |
@@ -1573,8 +1550,6 @@ static int edge_tiocmset(struct tty_struct *tty, | |||
1573 | struct edgeport_port *edge_port = usb_get_serial_port_data(port); | 1550 | struct edgeport_port *edge_port = usb_get_serial_port_data(port); |
1574 | unsigned int mcr; | 1551 | unsigned int mcr; |
1575 | 1552 | ||
1576 | dbg("%s - port %d", __func__, port->number); | ||
1577 | |||
1578 | mcr = edge_port->shadowMCR; | 1553 | mcr = edge_port->shadowMCR; |
1579 | if (set & TIOCM_RTS) | 1554 | if (set & TIOCM_RTS) |
1580 | mcr |= MCR_RTS; | 1555 | mcr |= MCR_RTS; |
@@ -1605,8 +1580,6 @@ static int edge_tiocmget(struct tty_struct *tty) | |||
1605 | unsigned int msr; | 1580 | unsigned int msr; |
1606 | unsigned int mcr; | 1581 | unsigned int mcr; |
1607 | 1582 | ||
1608 | dbg("%s - port %d", __func__, port->number); | ||
1609 | |||
1610 | msr = edge_port->shadowMSR; | 1583 | msr = edge_port->shadowMSR; |
1611 | mcr = edge_port->shadowMCR; | 1584 | mcr = edge_port->shadowMCR; |
1612 | result = ((mcr & MCR_DTR) ? TIOCM_DTR: 0) /* 0x002 */ | 1585 | result = ((mcr & MCR_DTR) ? TIOCM_DTR: 0) /* 0x002 */ |
@@ -1616,9 +1589,6 @@ static int edge_tiocmget(struct tty_struct *tty) | |||
1616 | | ((msr & EDGEPORT_MSR_RI) ? TIOCM_RI: 0) /* 0x080 */ | 1589 | | ((msr & EDGEPORT_MSR_RI) ? TIOCM_RI: 0) /* 0x080 */ |
1617 | | ((msr & EDGEPORT_MSR_DSR) ? TIOCM_DSR: 0); /* 0x100 */ | 1590 | | ((msr & EDGEPORT_MSR_DSR) ? TIOCM_DSR: 0); /* 0x100 */ |
1618 | 1591 | ||
1619 | |||
1620 | dbg("%s -- %x", __func__, result); | ||
1621 | |||
1622 | return result; | 1592 | return result; |
1623 | } | 1593 | } |
1624 | 1594 | ||
@@ -1642,8 +1612,8 @@ static int edge_get_icount(struct tty_struct *tty, | |||
1642 | icount->brk = cnow.brk; | 1612 | icount->brk = cnow.brk; |
1643 | icount->buf_overrun = cnow.buf_overrun; | 1613 | icount->buf_overrun = cnow.buf_overrun; |
1644 | 1614 | ||
1645 | dbg("%s (%d) TIOCGICOUNT RX=%d, TX=%d", | 1615 | dev_dbg(&port->dev, "%s (%d) TIOCGICOUNT RX=%d, TX=%d\n", __func__, |
1646 | __func__, port->number, icount->rx, icount->tx); | 1616 | port->number, icount->rx, icount->tx); |
1647 | return 0; | 1617 | return 0; |
1648 | } | 1618 | } |
1649 | 1619 | ||
@@ -1686,19 +1656,19 @@ static int edge_ioctl(struct tty_struct *tty, | |||
1686 | struct async_icount cnow; | 1656 | struct async_icount cnow; |
1687 | struct async_icount cprev; | 1657 | struct async_icount cprev; |
1688 | 1658 | ||
1689 | dbg("%s - port %d, cmd = 0x%x", __func__, port->number, cmd); | 1659 | dev_dbg(&port->dev, "%s - port %d, cmd = 0x%x\n", __func__, port->number, cmd); |
1690 | 1660 | ||
1691 | switch (cmd) { | 1661 | switch (cmd) { |
1692 | case TIOCSERGETLSR: | 1662 | case TIOCSERGETLSR: |
1693 | dbg("%s (%d) TIOCSERGETLSR", __func__, port->number); | 1663 | dev_dbg(&port->dev, "%s (%d) TIOCSERGETLSR\n", __func__, port->number); |
1694 | return get_lsr_info(edge_port, (unsigned int __user *) arg); | 1664 | return get_lsr_info(edge_port, (unsigned int __user *) arg); |
1695 | 1665 | ||
1696 | case TIOCGSERIAL: | 1666 | case TIOCGSERIAL: |
1697 | dbg("%s (%d) TIOCGSERIAL", __func__, port->number); | 1667 | dev_dbg(&port->dev, "%s (%d) TIOCGSERIAL\n", __func__, port->number); |
1698 | return get_serial_info(edge_port, (struct serial_struct __user *) arg); | 1668 | return get_serial_info(edge_port, (struct serial_struct __user *) arg); |
1699 | 1669 | ||
1700 | case TIOCMIWAIT: | 1670 | case TIOCMIWAIT: |
1701 | dbg("%s (%d) TIOCMIWAIT", __func__, port->number); | 1671 | dev_dbg(&port->dev, "%s (%d) TIOCMIWAIT\n", __func__, port->number); |
1702 | cprev = edge_port->icount; | 1672 | cprev = edge_port->icount; |
1703 | while (1) { | 1673 | while (1) { |
1704 | prepare_to_wait(&edge_port->delta_msr_wait, | 1674 | prepare_to_wait(&edge_port->delta_msr_wait, |
@@ -1745,7 +1715,7 @@ static void edge_break(struct tty_struct *tty, int break_state) | |||
1745 | /* flush and chase */ | 1715 | /* flush and chase */ |
1746 | edge_port->chaseResponsePending = true; | 1716 | edge_port->chaseResponsePending = true; |
1747 | 1717 | ||
1748 | dbg("%s - Sending IOSP_CMD_CHASE_PORT", __func__); | 1718 | dev_dbg(&port->dev, "%s - Sending IOSP_CMD_CHASE_PORT\n", __func__); |
1749 | status = send_iosp_ext_cmd(edge_port, IOSP_CMD_CHASE_PORT, 0); | 1719 | status = send_iosp_ext_cmd(edge_port, IOSP_CMD_CHASE_PORT, 0); |
1750 | if (status == 0) { | 1720 | if (status == 0) { |
1751 | /* block until chase finished */ | 1721 | /* block until chase finished */ |
@@ -1759,16 +1729,16 @@ static void edge_break(struct tty_struct *tty, int break_state) | |||
1759 | ((edge_serial->is_epic) && | 1729 | ((edge_serial->is_epic) && |
1760 | (edge_serial->epic_descriptor.Supports.IOSPSetClrBreak))) { | 1730 | (edge_serial->epic_descriptor.Supports.IOSPSetClrBreak))) { |
1761 | if (break_state == -1) { | 1731 | if (break_state == -1) { |
1762 | dbg("%s - Sending IOSP_CMD_SET_BREAK", __func__); | 1732 | dev_dbg(&port->dev, "%s - Sending IOSP_CMD_SET_BREAK\n", __func__); |
1763 | status = send_iosp_ext_cmd(edge_port, | 1733 | status = send_iosp_ext_cmd(edge_port, |
1764 | IOSP_CMD_SET_BREAK, 0); | 1734 | IOSP_CMD_SET_BREAK, 0); |
1765 | } else { | 1735 | } else { |
1766 | dbg("%s - Sending IOSP_CMD_CLEAR_BREAK", __func__); | 1736 | dev_dbg(&port->dev, "%s - Sending IOSP_CMD_CLEAR_BREAK\n", __func__); |
1767 | status = send_iosp_ext_cmd(edge_port, | 1737 | status = send_iosp_ext_cmd(edge_port, |
1768 | IOSP_CMD_CLEAR_BREAK, 0); | 1738 | IOSP_CMD_CLEAR_BREAK, 0); |
1769 | } | 1739 | } |
1770 | if (status) | 1740 | if (status) |
1771 | dbg("%s - error sending break set/clear command.", | 1741 | dev_dbg(&port->dev, "%s - error sending break set/clear command.\n", |
1772 | __func__); | 1742 | __func__); |
1773 | } | 1743 | } |
1774 | } | 1744 | } |
@@ -1781,20 +1751,19 @@ static void edge_break(struct tty_struct *tty, int break_state) | |||
1781 | static void process_rcvd_data(struct edgeport_serial *edge_serial, | 1751 | static void process_rcvd_data(struct edgeport_serial *edge_serial, |
1782 | unsigned char *buffer, __u16 bufferLength) | 1752 | unsigned char *buffer, __u16 bufferLength) |
1783 | { | 1753 | { |
1754 | struct device *dev = &edge_serial->serial->dev->dev; | ||
1784 | struct usb_serial_port *port; | 1755 | struct usb_serial_port *port; |
1785 | struct edgeport_port *edge_port; | 1756 | struct edgeport_port *edge_port; |
1786 | struct tty_struct *tty; | 1757 | struct tty_struct *tty; |
1787 | __u16 lastBufferLength; | 1758 | __u16 lastBufferLength; |
1788 | __u16 rxLen; | 1759 | __u16 rxLen; |
1789 | 1760 | ||
1790 | dbg("%s", __func__); | ||
1791 | |||
1792 | lastBufferLength = bufferLength + 1; | 1761 | lastBufferLength = bufferLength + 1; |
1793 | 1762 | ||
1794 | while (bufferLength > 0) { | 1763 | while (bufferLength > 0) { |
1795 | /* failsafe incase we get a message that we don't understand */ | 1764 | /* failsafe incase we get a message that we don't understand */ |
1796 | if (lastBufferLength == bufferLength) { | 1765 | if (lastBufferLength == bufferLength) { |
1797 | dbg("%s - stuck in loop, exiting it.", __func__); | 1766 | dev_dbg(dev, "%s - stuck in loop, exiting it.\n", __func__); |
1798 | break; | 1767 | break; |
1799 | } | 1768 | } |
1800 | lastBufferLength = bufferLength; | 1769 | lastBufferLength = bufferLength; |
@@ -1815,8 +1784,8 @@ static void process_rcvd_data(struct edgeport_serial *edge_serial, | |||
1815 | ++buffer; | 1784 | ++buffer; |
1816 | --bufferLength; | 1785 | --bufferLength; |
1817 | 1786 | ||
1818 | dbg("%s - Hdr1=%02X Hdr2=%02X", __func__, | 1787 | dev_dbg(dev, "%s - Hdr1=%02X Hdr2=%02X\n", __func__, |
1819 | edge_serial->rxHeader1, edge_serial->rxHeader2); | 1788 | edge_serial->rxHeader1, edge_serial->rxHeader2); |
1820 | /* Process depending on whether this header is | 1789 | /* Process depending on whether this header is |
1821 | * data or status */ | 1790 | * data or status */ |
1822 | 1791 | ||
@@ -1855,10 +1824,10 @@ static void process_rcvd_data(struct edgeport_serial *edge_serial, | |||
1855 | IOSP_GET_HDR_DATA_LEN( | 1824 | IOSP_GET_HDR_DATA_LEN( |
1856 | edge_serial->rxHeader1, | 1825 | edge_serial->rxHeader1, |
1857 | edge_serial->rxHeader2); | 1826 | edge_serial->rxHeader2); |
1858 | dbg("%s - Data for Port %u Len %u", | 1827 | dev_dbg(dev, "%s - Data for Port %u Len %u\n", |
1859 | __func__, | 1828 | __func__, |
1860 | edge_serial->rxPort, | 1829 | edge_serial->rxPort, |
1861 | edge_serial->rxBytesRemaining); | 1830 | edge_serial->rxBytesRemaining); |
1862 | 1831 | ||
1863 | /* ASSERT(DevExt->RxPort < DevExt->NumPorts); | 1832 | /* ASSERT(DevExt->RxPort < DevExt->NumPorts); |
1864 | * ASSERT(DevExt->RxBytesRemaining < | 1833 | * ASSERT(DevExt->RxBytesRemaining < |
@@ -1896,7 +1865,7 @@ static void process_rcvd_data(struct edgeport_serial *edge_serial, | |||
1896 | tty = tty_port_tty_get( | 1865 | tty = tty_port_tty_get( |
1897 | &edge_port->port->port); | 1866 | &edge_port->port->port); |
1898 | if (tty) { | 1867 | if (tty) { |
1899 | dbg("%s - Sending %d bytes to TTY for port %d", | 1868 | dev_dbg(dev, "%s - Sending %d bytes to TTY for port %d\n", |
1900 | __func__, rxLen, edge_serial->rxPort); | 1869 | __func__, rxLen, edge_serial->rxPort); |
1901 | edge_tty_recv(&edge_serial->serial->dev->dev, tty, buffer, rxLen); | 1870 | edge_tty_recv(&edge_serial->serial->dev->dev, tty, buffer, rxLen); |
1902 | tty_kref_put(tty); | 1871 | tty_kref_put(tty); |
@@ -1935,6 +1904,7 @@ static void process_rcvd_status(struct edgeport_serial *edge_serial, | |||
1935 | struct usb_serial_port *port; | 1904 | struct usb_serial_port *port; |
1936 | struct edgeport_port *edge_port; | 1905 | struct edgeport_port *edge_port; |
1937 | struct tty_struct *tty; | 1906 | struct tty_struct *tty; |
1907 | struct device *dev; | ||
1938 | __u8 code = edge_serial->rxStatusCode; | 1908 | __u8 code = edge_serial->rxStatusCode; |
1939 | 1909 | ||
1940 | /* switch the port pointer to the one being currently talked about */ | 1910 | /* switch the port pointer to the one being currently talked about */ |
@@ -1946,16 +1916,15 @@ static void process_rcvd_status(struct edgeport_serial *edge_serial, | |||
1946 | __func__, edge_serial->rxPort); | 1916 | __func__, edge_serial->rxPort); |
1947 | return; | 1917 | return; |
1948 | } | 1918 | } |
1949 | 1919 | dev = &port->dev; | |
1950 | dbg("%s - port %d", __func__, edge_serial->rxPort); | ||
1951 | 1920 | ||
1952 | if (code == IOSP_EXT_STATUS) { | 1921 | if (code == IOSP_EXT_STATUS) { |
1953 | switch (byte2) { | 1922 | switch (byte2) { |
1954 | case IOSP_EXT_STATUS_CHASE_RSP: | 1923 | case IOSP_EXT_STATUS_CHASE_RSP: |
1955 | /* we want to do EXT status regardless of port | 1924 | /* we want to do EXT status regardless of port |
1956 | * open/closed */ | 1925 | * open/closed */ |
1957 | dbg("%s - Port %u EXT CHASE_RSP Data = %02x", | 1926 | dev_dbg(dev, "%s - Port %u EXT CHASE_RSP Data = %02x\n", |
1958 | __func__, edge_serial->rxPort, byte3); | 1927 | __func__, edge_serial->rxPort, byte3); |
1959 | /* Currently, the only EXT_STATUS is Chase, so process | 1928 | /* Currently, the only EXT_STATUS is Chase, so process |
1960 | * here instead of one more call to one more subroutine | 1929 | * here instead of one more call to one more subroutine |
1961 | * If/when more EXT_STATUS, there'll be more work to do | 1930 | * If/when more EXT_STATUS, there'll be more work to do |
@@ -1970,7 +1939,8 @@ static void process_rcvd_status(struct edgeport_serial *edge_serial, | |||
1970 | return; | 1939 | return; |
1971 | 1940 | ||
1972 | case IOSP_EXT_STATUS_RX_CHECK_RSP: | 1941 | case IOSP_EXT_STATUS_RX_CHECK_RSP: |
1973 | dbg("%s ========== Port %u CHECK_RSP Sequence = %02x =============", __func__, edge_serial->rxPort, byte3); | 1942 | dev_dbg(dev, "%s ========== Port %u CHECK_RSP Sequence = %02x =============\n", |
1943 | __func__, edge_serial->rxPort, byte3); | ||
1974 | /* Port->RxCheckRsp = true; */ | 1944 | /* Port->RxCheckRsp = true; */ |
1975 | return; | 1945 | return; |
1976 | } | 1946 | } |
@@ -1979,7 +1949,8 @@ static void process_rcvd_status(struct edgeport_serial *edge_serial, | |||
1979 | if (code == IOSP_STATUS_OPEN_RSP) { | 1949 | if (code == IOSP_STATUS_OPEN_RSP) { |
1980 | edge_port->txCredits = GET_TX_BUFFER_SIZE(byte3); | 1950 | edge_port->txCredits = GET_TX_BUFFER_SIZE(byte3); |
1981 | edge_port->maxTxCredits = edge_port->txCredits; | 1951 | edge_port->maxTxCredits = edge_port->txCredits; |
1982 | dbg("%s - Port %u Open Response Initial MSR = %02x TxBufferSize = %d", __func__, edge_serial->rxPort, byte2, edge_port->txCredits); | 1952 | dev_dbg(dev, "%s - Port %u Open Response Initial MSR = %02x TxBufferSize = %d\n", |
1953 | __func__, edge_serial->rxPort, byte2, edge_port->txCredits); | ||
1983 | handle_new_msr(edge_port, byte2); | 1954 | handle_new_msr(edge_port, byte2); |
1984 | 1955 | ||
1985 | /* send the current line settings to the port so we are | 1956 | /* send the current line settings to the port so we are |
@@ -2008,27 +1979,27 @@ static void process_rcvd_status(struct edgeport_serial *edge_serial, | |||
2008 | switch (code) { | 1979 | switch (code) { |
2009 | /* Not currently sent by Edgeport */ | 1980 | /* Not currently sent by Edgeport */ |
2010 | case IOSP_STATUS_LSR: | 1981 | case IOSP_STATUS_LSR: |
2011 | dbg("%s - Port %u LSR Status = %02x", | 1982 | dev_dbg(dev, "%s - Port %u LSR Status = %02x\n", |
2012 | __func__, edge_serial->rxPort, byte2); | 1983 | __func__, edge_serial->rxPort, byte2); |
2013 | handle_new_lsr(edge_port, false, byte2, 0); | 1984 | handle_new_lsr(edge_port, false, byte2, 0); |
2014 | break; | 1985 | break; |
2015 | 1986 | ||
2016 | case IOSP_STATUS_LSR_DATA: | 1987 | case IOSP_STATUS_LSR_DATA: |
2017 | dbg("%s - Port %u LSR Status = %02x, Data = %02x", | 1988 | dev_dbg(dev, "%s - Port %u LSR Status = %02x, Data = %02x\n", |
2018 | __func__, edge_serial->rxPort, byte2, byte3); | 1989 | __func__, edge_serial->rxPort, byte2, byte3); |
2019 | /* byte2 is LSR Register */ | 1990 | /* byte2 is LSR Register */ |
2020 | /* byte3 is broken data byte */ | 1991 | /* byte3 is broken data byte */ |
2021 | handle_new_lsr(edge_port, true, byte2, byte3); | 1992 | handle_new_lsr(edge_port, true, byte2, byte3); |
2022 | break; | 1993 | break; |
2023 | /* | 1994 | /* |
2024 | * case IOSP_EXT_4_STATUS: | 1995 | * case IOSP_EXT_4_STATUS: |
2025 | * dbg("%s - Port %u LSR Status = %02x Data = %02x", | 1996 | * dev_dbg(dev, "%s - Port %u LSR Status = %02x Data = %02x\n", |
2026 | * __func__, edge_serial->rxPort, byte2, byte3); | 1997 | * __func__, edge_serial->rxPort, byte2, byte3); |
2027 | * break; | 1998 | * break; |
2028 | */ | 1999 | */ |
2029 | case IOSP_STATUS_MSR: | 2000 | case IOSP_STATUS_MSR: |
2030 | dbg("%s - Port %u MSR Status = %02x", | 2001 | dev_dbg(dev, "%s - Port %u MSR Status = %02x\n", |
2031 | __func__, edge_serial->rxPort, byte2); | 2002 | __func__, edge_serial->rxPort, byte2); |
2032 | /* | 2003 | /* |
2033 | * Process this new modem status and generate appropriate | 2004 | * Process this new modem status and generate appropriate |
2034 | * events, etc, based on the new status. This routine | 2005 | * events, etc, based on the new status. This routine |
@@ -2038,7 +2009,7 @@ static void process_rcvd_status(struct edgeport_serial *edge_serial, | |||
2038 | break; | 2009 | break; |
2039 | 2010 | ||
2040 | default: | 2011 | default: |
2041 | dbg("%s - Unrecognized IOSP status code %u", __func__, code); | 2012 | dev_dbg(dev, "%s - Unrecognized IOSP status code %u\n", __func__, code); |
2042 | break; | 2013 | break; |
2043 | } | 2014 | } |
2044 | } | 2015 | } |
@@ -2073,8 +2044,6 @@ static void handle_new_msr(struct edgeport_port *edge_port, __u8 newMsr) | |||
2073 | { | 2044 | { |
2074 | struct async_icount *icount; | 2045 | struct async_icount *icount; |
2075 | 2046 | ||
2076 | dbg("%s %02x", __func__, newMsr); | ||
2077 | |||
2078 | if (newMsr & (EDGEPORT_MSR_DELTA_CTS | EDGEPORT_MSR_DELTA_DSR | | 2047 | if (newMsr & (EDGEPORT_MSR_DELTA_CTS | EDGEPORT_MSR_DELTA_DSR | |
2079 | EDGEPORT_MSR_DELTA_RI | EDGEPORT_MSR_DELTA_CD)) { | 2048 | EDGEPORT_MSR_DELTA_RI | EDGEPORT_MSR_DELTA_CD)) { |
2080 | icount = &edge_port->icount; | 2049 | icount = &edge_port->icount; |
@@ -2107,8 +2076,6 @@ static void handle_new_lsr(struct edgeport_port *edge_port, __u8 lsrData, | |||
2107 | (LSR_OVER_ERR | LSR_PAR_ERR | LSR_FRM_ERR | LSR_BREAK)); | 2076 | (LSR_OVER_ERR | LSR_PAR_ERR | LSR_FRM_ERR | LSR_BREAK)); |
2108 | struct async_icount *icount; | 2077 | struct async_icount *icount; |
2109 | 2078 | ||
2110 | dbg("%s - %02x", __func__, newLsr); | ||
2111 | |||
2112 | edge_port->shadowLSR = lsr; | 2079 | edge_port->shadowLSR = lsr; |
2113 | 2080 | ||
2114 | if (newLsr & LSR_BREAK) { | 2081 | if (newLsr & LSR_BREAK) { |
@@ -2156,7 +2123,7 @@ static int sram_write(struct usb_serial *serial, __u16 extAddr, __u16 addr, | |||
2156 | __u16 current_length; | 2123 | __u16 current_length; |
2157 | unsigned char *transfer_buffer; | 2124 | unsigned char *transfer_buffer; |
2158 | 2125 | ||
2159 | dbg("%s - %x, %x, %d", __func__, extAddr, addr, length); | 2126 | dev_dbg(&serial->dev->dev, "%s - %x, %x, %d\n", __func__, extAddr, addr, length); |
2160 | 2127 | ||
2161 | transfer_buffer = kmalloc(64, GFP_KERNEL); | 2128 | transfer_buffer = kmalloc(64, GFP_KERNEL); |
2162 | if (!transfer_buffer) { | 2129 | if (!transfer_buffer) { |
@@ -2173,8 +2140,7 @@ static int sram_write(struct usb_serial *serial, __u16 extAddr, __u16 addr, | |||
2173 | else | 2140 | else |
2174 | current_length = length; | 2141 | current_length = length; |
2175 | 2142 | ||
2176 | /* dbg("%s - writing %x, %x, %d", __func__, | 2143 | /* dev_dbg(&serial->dev->dev, "%s - writing %x, %x, %d\n", __func__, extAddr, addr, current_length); */ |
2177 | extAddr, addr, current_length); */ | ||
2178 | memcpy(transfer_buffer, data, current_length); | 2144 | memcpy(transfer_buffer, data, current_length); |
2179 | result = usb_control_msg(serial->dev, | 2145 | result = usb_control_msg(serial->dev, |
2180 | usb_sndctrlpipe(serial->dev, 0), | 2146 | usb_sndctrlpipe(serial->dev, 0), |
@@ -2207,8 +2173,6 @@ static int rom_write(struct usb_serial *serial, __u16 extAddr, __u16 addr, | |||
2207 | __u16 current_length; | 2173 | __u16 current_length; |
2208 | unsigned char *transfer_buffer; | 2174 | unsigned char *transfer_buffer; |
2209 | 2175 | ||
2210 | /* dbg("%s - %x, %x, %d", __func__, extAddr, addr, length); */ | ||
2211 | |||
2212 | transfer_buffer = kmalloc(64, GFP_KERNEL); | 2176 | transfer_buffer = kmalloc(64, GFP_KERNEL); |
2213 | if (!transfer_buffer) { | 2177 | if (!transfer_buffer) { |
2214 | dev_err(&serial->dev->dev, "%s - kmalloc(%d) failed.\n", | 2178 | dev_err(&serial->dev->dev, "%s - kmalloc(%d) failed.\n", |
@@ -2223,8 +2187,6 @@ static int rom_write(struct usb_serial *serial, __u16 extAddr, __u16 addr, | |||
2223 | current_length = 64; | 2187 | current_length = 64; |
2224 | else | 2188 | else |
2225 | current_length = length; | 2189 | current_length = length; |
2226 | /* dbg("%s - writing %x, %x, %d", __func__, | ||
2227 | extAddr, addr, current_length); */ | ||
2228 | memcpy(transfer_buffer, data, current_length); | 2190 | memcpy(transfer_buffer, data, current_length); |
2229 | result = usb_control_msg(serial->dev, | 2191 | result = usb_control_msg(serial->dev, |
2230 | usb_sndctrlpipe(serial->dev, 0), | 2192 | usb_sndctrlpipe(serial->dev, 0), |
@@ -2257,8 +2219,6 @@ static int rom_read(struct usb_serial *serial, __u16 extAddr, | |||
2257 | __u16 current_length; | 2219 | __u16 current_length; |
2258 | unsigned char *transfer_buffer; | 2220 | unsigned char *transfer_buffer; |
2259 | 2221 | ||
2260 | dbg("%s - %x, %x, %d", __func__, extAddr, addr, length); | ||
2261 | |||
2262 | transfer_buffer = kmalloc(64, GFP_KERNEL); | 2222 | transfer_buffer = kmalloc(64, GFP_KERNEL); |
2263 | if (!transfer_buffer) { | 2223 | if (!transfer_buffer) { |
2264 | dev_err(&serial->dev->dev, | 2224 | dev_err(&serial->dev->dev, |
@@ -2273,8 +2233,6 @@ static int rom_read(struct usb_serial *serial, __u16 extAddr, | |||
2273 | current_length = 64; | 2233 | current_length = 64; |
2274 | else | 2234 | else |
2275 | current_length = length; | 2235 | current_length = length; |
2276 | /* dbg("%s - %x, %x, %d", __func__, | ||
2277 | extAddr, addr, current_length); */ | ||
2278 | result = usb_control_msg(serial->dev, | 2236 | result = usb_control_msg(serial->dev, |
2279 | usb_rcvctrlpipe(serial->dev, 0), | 2237 | usb_rcvctrlpipe(serial->dev, 0), |
2280 | USB_REQUEST_ION_READ_ROM, | 2238 | USB_REQUEST_ION_READ_ROM, |
@@ -2305,8 +2263,6 @@ static int send_iosp_ext_cmd(struct edgeport_port *edge_port, | |||
2305 | int length = 0; | 2263 | int length = 0; |
2306 | int status = 0; | 2264 | int status = 0; |
2307 | 2265 | ||
2308 | dbg("%s - %d, %d", __func__, command, param); | ||
2309 | |||
2310 | buffer = kmalloc(10, GFP_ATOMIC); | 2266 | buffer = kmalloc(10, GFP_ATOMIC); |
2311 | if (!buffer) { | 2267 | if (!buffer) { |
2312 | dev_err(&edge_port->port->dev, | 2268 | dev_err(&edge_port->port->dev, |
@@ -2339,11 +2295,11 @@ static int write_cmd_usb(struct edgeport_port *edge_port, | |||
2339 | { | 2295 | { |
2340 | struct edgeport_serial *edge_serial = | 2296 | struct edgeport_serial *edge_serial = |
2341 | usb_get_serial_data(edge_port->port->serial); | 2297 | usb_get_serial_data(edge_port->port->serial); |
2298 | struct device *dev = &edge_port->port->dev; | ||
2342 | int status = 0; | 2299 | int status = 0; |
2343 | struct urb *urb; | 2300 | struct urb *urb; |
2344 | 2301 | ||
2345 | usb_serial_debug_data(debug, &edge_port->port->dev, | 2302 | usb_serial_debug_data(dev, __func__, length, buffer); |
2346 | __func__, length, buffer); | ||
2347 | 2303 | ||
2348 | /* Allocate our next urb */ | 2304 | /* Allocate our next urb */ |
2349 | urb = usb_alloc_urb(0, GFP_ATOMIC); | 2305 | urb = usb_alloc_urb(0, GFP_ATOMIC); |
@@ -2351,8 +2307,8 @@ static int write_cmd_usb(struct edgeport_port *edge_port, | |||
2351 | return -ENOMEM; | 2307 | return -ENOMEM; |
2352 | 2308 | ||
2353 | atomic_inc(&CmdUrbs); | 2309 | atomic_inc(&CmdUrbs); |
2354 | dbg("%s - ALLOCATE URB %p (outstanding %d)", | 2310 | dev_dbg(dev, "%s - ALLOCATE URB %p (outstanding %d)\n", |
2355 | __func__, urb, atomic_read(&CmdUrbs)); | 2311 | __func__, urb, atomic_read(&CmdUrbs)); |
2356 | 2312 | ||
2357 | usb_fill_bulk_urb(urb, edge_serial->serial->dev, | 2313 | usb_fill_bulk_urb(urb, edge_serial->serial->dev, |
2358 | usb_sndbulkpipe(edge_serial->serial->dev, | 2314 | usb_sndbulkpipe(edge_serial->serial->dev, |
@@ -2364,9 +2320,8 @@ static int write_cmd_usb(struct edgeport_port *edge_port, | |||
2364 | 2320 | ||
2365 | if (status) { | 2321 | if (status) { |
2366 | /* something went wrong */ | 2322 | /* something went wrong */ |
2367 | dev_err(&edge_port->port->dev, | 2323 | dev_err(dev, "%s - usb_submit_urb(write command) failed, status = %d\n", |
2368 | "%s - usb_submit_urb(write command) failed, status = %d\n", | 2324 | __func__, status); |
2369 | __func__, status); | ||
2370 | usb_kill_urb(urb); | 2325 | usb_kill_urb(urb); |
2371 | usb_free_urb(urb); | 2326 | usb_free_urb(urb); |
2372 | atomic_dec(&CmdUrbs); | 2327 | atomic_dec(&CmdUrbs); |
@@ -2378,7 +2333,7 @@ static int write_cmd_usb(struct edgeport_port *edge_port, | |||
2378 | 2333 | ||
2379 | if (edge_port->commandPending) { | 2334 | if (edge_port->commandPending) { |
2380 | /* command timed out */ | 2335 | /* command timed out */ |
2381 | dbg("%s - command timed out", __func__); | 2336 | dev_dbg(dev, "%s - command timed out\n", __func__); |
2382 | status = -EINVAL; | 2337 | status = -EINVAL; |
2383 | } | 2338 | } |
2384 | #endif | 2339 | #endif |
@@ -2396,6 +2351,7 @@ static int send_cmd_write_baud_rate(struct edgeport_port *edge_port, | |||
2396 | { | 2351 | { |
2397 | struct edgeport_serial *edge_serial = | 2352 | struct edgeport_serial *edge_serial = |
2398 | usb_get_serial_data(edge_port->port->serial); | 2353 | usb_get_serial_data(edge_port->port->serial); |
2354 | struct device *dev = &edge_port->port->dev; | ||
2399 | unsigned char *cmdBuffer; | 2355 | unsigned char *cmdBuffer; |
2400 | unsigned char *currCmd; | 2356 | unsigned char *currCmd; |
2401 | int cmdLen = 0; | 2357 | int cmdLen = 0; |
@@ -2406,26 +2362,24 @@ static int send_cmd_write_baud_rate(struct edgeport_port *edge_port, | |||
2406 | 2362 | ||
2407 | if (edge_serial->is_epic && | 2363 | if (edge_serial->is_epic && |
2408 | !edge_serial->epic_descriptor.Supports.IOSPSetBaudRate) { | 2364 | !edge_serial->epic_descriptor.Supports.IOSPSetBaudRate) { |
2409 | dbg("SendCmdWriteBaudRate - NOT Setting baud rate for port = %d, baud = %d", | 2365 | dev_dbg(dev, "SendCmdWriteBaudRate - NOT Setting baud rate for port = %d, baud = %d\n", |
2410 | edge_port->port->number, baudRate); | 2366 | edge_port->port->number, baudRate); |
2411 | return 0; | 2367 | return 0; |
2412 | } | 2368 | } |
2413 | 2369 | ||
2414 | dbg("%s - port = %d, baud = %d", __func__, | 2370 | dev_dbg(dev, "%s - port = %d, baud = %d\n", __func__, |
2415 | edge_port->port->number, baudRate); | 2371 | edge_port->port->number, baudRate); |
2416 | 2372 | ||
2417 | status = calc_baud_rate_divisor(baudRate, &divisor); | 2373 | status = calc_baud_rate_divisor(dev, baudRate, &divisor); |
2418 | if (status) { | 2374 | if (status) { |
2419 | dev_err(&edge_port->port->dev, "%s - bad baud rate\n", | 2375 | dev_err(dev, "%s - bad baud rate\n", __func__); |
2420 | __func__); | ||
2421 | return status; | 2376 | return status; |
2422 | } | 2377 | } |
2423 | 2378 | ||
2424 | /* Alloc memory for the string of commands. */ | 2379 | /* Alloc memory for the string of commands. */ |
2425 | cmdBuffer = kmalloc(0x100, GFP_ATOMIC); | 2380 | cmdBuffer = kmalloc(0x100, GFP_ATOMIC); |
2426 | if (!cmdBuffer) { | 2381 | if (!cmdBuffer) { |
2427 | dev_err(&edge_port->port->dev, | 2382 | dev_err(dev, "%s - kmalloc(%d) failed.\n", __func__, 0x100); |
2428 | "%s - kmalloc(%d) failed.\n", __func__, 0x100); | ||
2429 | return -ENOMEM; | 2383 | return -ENOMEM; |
2430 | } | 2384 | } |
2431 | currCmd = cmdBuffer; | 2385 | currCmd = cmdBuffer; |
@@ -2456,14 +2410,11 @@ static int send_cmd_write_baud_rate(struct edgeport_port *edge_port, | |||
2456 | * this function calculates the proper baud rate divisor for the specified | 2410 | * this function calculates the proper baud rate divisor for the specified |
2457 | * baud rate. | 2411 | * baud rate. |
2458 | *****************************************************************************/ | 2412 | *****************************************************************************/ |
2459 | static int calc_baud_rate_divisor(int baudrate, int *divisor) | 2413 | static int calc_baud_rate_divisor(struct device *dev, int baudrate, int *divisor) |
2460 | { | 2414 | { |
2461 | int i; | 2415 | int i; |
2462 | __u16 custom; | 2416 | __u16 custom; |
2463 | 2417 | ||
2464 | |||
2465 | dbg("%s - %d", __func__, baudrate); | ||
2466 | |||
2467 | for (i = 0; i < ARRAY_SIZE(divisor_table); i++) { | 2418 | for (i = 0; i < ARRAY_SIZE(divisor_table); i++) { |
2468 | if (divisor_table[i].BaudRate == baudrate) { | 2419 | if (divisor_table[i].BaudRate == baudrate) { |
2469 | *divisor = divisor_table[i].Divisor; | 2420 | *divisor = divisor_table[i].Divisor; |
@@ -2480,7 +2431,7 @@ static int calc_baud_rate_divisor(int baudrate, int *divisor) | |||
2480 | 2431 | ||
2481 | *divisor = custom; | 2432 | *divisor = custom; |
2482 | 2433 | ||
2483 | dbg("%s - Baud %d = %d", __func__, baudrate, custom); | 2434 | dev_dbg(dev, "%s - Baud %d = %d\n", __func__, baudrate, custom); |
2484 | return 0; | 2435 | return 0; |
2485 | } | 2436 | } |
2486 | 2437 | ||
@@ -2497,25 +2448,26 @@ static int send_cmd_write_uart_register(struct edgeport_port *edge_port, | |||
2497 | { | 2448 | { |
2498 | struct edgeport_serial *edge_serial = | 2449 | struct edgeport_serial *edge_serial = |
2499 | usb_get_serial_data(edge_port->port->serial); | 2450 | usb_get_serial_data(edge_port->port->serial); |
2451 | struct device *dev = &edge_port->port->dev; | ||
2500 | unsigned char *cmdBuffer; | 2452 | unsigned char *cmdBuffer; |
2501 | unsigned char *currCmd; | 2453 | unsigned char *currCmd; |
2502 | unsigned long cmdLen = 0; | 2454 | unsigned long cmdLen = 0; |
2503 | int status; | 2455 | int status; |
2504 | 2456 | ||
2505 | dbg("%s - write to %s register 0x%02x", | 2457 | dev_dbg(dev, "%s - write to %s register 0x%02x\n", |
2506 | (regNum == MCR) ? "MCR" : "LCR", __func__, regValue); | 2458 | (regNum == MCR) ? "MCR" : "LCR", __func__, regValue); |
2507 | 2459 | ||
2508 | if (edge_serial->is_epic && | 2460 | if (edge_serial->is_epic && |
2509 | !edge_serial->epic_descriptor.Supports.IOSPWriteMCR && | 2461 | !edge_serial->epic_descriptor.Supports.IOSPWriteMCR && |
2510 | regNum == MCR) { | 2462 | regNum == MCR) { |
2511 | dbg("SendCmdWriteUartReg - Not writing to MCR Register"); | 2463 | dev_dbg(dev, "SendCmdWriteUartReg - Not writing to MCR Register\n"); |
2512 | return 0; | 2464 | return 0; |
2513 | } | 2465 | } |
2514 | 2466 | ||
2515 | if (edge_serial->is_epic && | 2467 | if (edge_serial->is_epic && |
2516 | !edge_serial->epic_descriptor.Supports.IOSPWriteLCR && | 2468 | !edge_serial->epic_descriptor.Supports.IOSPWriteLCR && |
2517 | regNum == LCR) { | 2469 | regNum == LCR) { |
2518 | dbg("SendCmdWriteUartReg - Not writing to LCR Register"); | 2470 | dev_dbg(dev, "SendCmdWriteUartReg - Not writing to LCR Register\n"); |
2519 | return 0; | 2471 | return 0; |
2520 | } | 2472 | } |
2521 | 2473 | ||
@@ -2550,6 +2502,7 @@ static int send_cmd_write_uart_register(struct edgeport_port *edge_port, | |||
2550 | static void change_port_settings(struct tty_struct *tty, | 2502 | static void change_port_settings(struct tty_struct *tty, |
2551 | struct edgeport_port *edge_port, struct ktermios *old_termios) | 2503 | struct edgeport_port *edge_port, struct ktermios *old_termios) |
2552 | { | 2504 | { |
2505 | struct device *dev = &edge_port->port->dev; | ||
2553 | struct edgeport_serial *edge_serial = | 2506 | struct edgeport_serial *edge_serial = |
2554 | usb_get_serial_data(edge_port->port->serial); | 2507 | usb_get_serial_data(edge_port->port->serial); |
2555 | int baud; | 2508 | int baud; |
@@ -2562,11 +2515,11 @@ static void change_port_settings(struct tty_struct *tty, | |||
2562 | __u8 txFlow; | 2515 | __u8 txFlow; |
2563 | int status; | 2516 | int status; |
2564 | 2517 | ||
2565 | dbg("%s - port %d", __func__, edge_port->port->number); | 2518 | dev_dbg(dev, "%s - port %d\n", __func__, edge_port->port->number); |
2566 | 2519 | ||
2567 | if (!edge_port->open && | 2520 | if (!edge_port->open && |
2568 | !edge_port->openPending) { | 2521 | !edge_port->openPending) { |
2569 | dbg("%s - port not opened", __func__); | 2522 | dev_dbg(dev, "%s - port not opened\n", __func__); |
2570 | return; | 2523 | return; |
2571 | } | 2524 | } |
2572 | 2525 | ||
@@ -2575,20 +2528,20 @@ static void change_port_settings(struct tty_struct *tty, | |||
2575 | switch (cflag & CSIZE) { | 2528 | switch (cflag & CSIZE) { |
2576 | case CS5: | 2529 | case CS5: |
2577 | lData = LCR_BITS_5; mask = 0x1f; | 2530 | lData = LCR_BITS_5; mask = 0x1f; |
2578 | dbg("%s - data bits = 5", __func__); | 2531 | dev_dbg(dev, "%s - data bits = 5\n", __func__); |
2579 | break; | 2532 | break; |
2580 | case CS6: | 2533 | case CS6: |
2581 | lData = LCR_BITS_6; mask = 0x3f; | 2534 | lData = LCR_BITS_6; mask = 0x3f; |
2582 | dbg("%s - data bits = 6", __func__); | 2535 | dev_dbg(dev, "%s - data bits = 6\n", __func__); |
2583 | break; | 2536 | break; |
2584 | case CS7: | 2537 | case CS7: |
2585 | lData = LCR_BITS_7; mask = 0x7f; | 2538 | lData = LCR_BITS_7; mask = 0x7f; |
2586 | dbg("%s - data bits = 7", __func__); | 2539 | dev_dbg(dev, "%s - data bits = 7\n", __func__); |
2587 | break; | 2540 | break; |
2588 | default: | 2541 | default: |
2589 | case CS8: | 2542 | case CS8: |
2590 | lData = LCR_BITS_8; | 2543 | lData = LCR_BITS_8; |
2591 | dbg("%s - data bits = 8", __func__); | 2544 | dev_dbg(dev, "%s - data bits = 8\n", __func__); |
2592 | break; | 2545 | break; |
2593 | } | 2546 | } |
2594 | 2547 | ||
@@ -2597,28 +2550,28 @@ static void change_port_settings(struct tty_struct *tty, | |||
2597 | if (cflag & CMSPAR) { | 2550 | if (cflag & CMSPAR) { |
2598 | if (cflag & PARODD) { | 2551 | if (cflag & PARODD) { |
2599 | lParity = LCR_PAR_MARK; | 2552 | lParity = LCR_PAR_MARK; |
2600 | dbg("%s - parity = mark", __func__); | 2553 | dev_dbg(dev, "%s - parity = mark\n", __func__); |
2601 | } else { | 2554 | } else { |
2602 | lParity = LCR_PAR_SPACE; | 2555 | lParity = LCR_PAR_SPACE; |
2603 | dbg("%s - parity = space", __func__); | 2556 | dev_dbg(dev, "%s - parity = space\n", __func__); |
2604 | } | 2557 | } |
2605 | } else if (cflag & PARODD) { | 2558 | } else if (cflag & PARODD) { |
2606 | lParity = LCR_PAR_ODD; | 2559 | lParity = LCR_PAR_ODD; |
2607 | dbg("%s - parity = odd", __func__); | 2560 | dev_dbg(dev, "%s - parity = odd\n", __func__); |
2608 | } else { | 2561 | } else { |
2609 | lParity = LCR_PAR_EVEN; | 2562 | lParity = LCR_PAR_EVEN; |
2610 | dbg("%s - parity = even", __func__); | 2563 | dev_dbg(dev, "%s - parity = even\n", __func__); |
2611 | } | 2564 | } |
2612 | } else { | 2565 | } else { |
2613 | dbg("%s - parity = none", __func__); | 2566 | dev_dbg(dev, "%s - parity = none\n", __func__); |
2614 | } | 2567 | } |
2615 | 2568 | ||
2616 | if (cflag & CSTOPB) { | 2569 | if (cflag & CSTOPB) { |
2617 | lStop = LCR_STOP_2; | 2570 | lStop = LCR_STOP_2; |
2618 | dbg("%s - stop bits = 2", __func__); | 2571 | dev_dbg(dev, "%s - stop bits = 2\n", __func__); |
2619 | } else { | 2572 | } else { |
2620 | lStop = LCR_STOP_1; | 2573 | lStop = LCR_STOP_1; |
2621 | dbg("%s - stop bits = 1", __func__); | 2574 | dev_dbg(dev, "%s - stop bits = 1\n", __func__); |
2622 | } | 2575 | } |
2623 | 2576 | ||
2624 | /* figure out the flow control settings */ | 2577 | /* figure out the flow control settings */ |
@@ -2626,9 +2579,9 @@ static void change_port_settings(struct tty_struct *tty, | |||
2626 | if (cflag & CRTSCTS) { | 2579 | if (cflag & CRTSCTS) { |
2627 | rxFlow |= IOSP_RX_FLOW_RTS; | 2580 | rxFlow |= IOSP_RX_FLOW_RTS; |
2628 | txFlow |= IOSP_TX_FLOW_CTS; | 2581 | txFlow |= IOSP_TX_FLOW_CTS; |
2629 | dbg("%s - RTS/CTS is enabled", __func__); | 2582 | dev_dbg(dev, "%s - RTS/CTS is enabled\n", __func__); |
2630 | } else { | 2583 | } else { |
2631 | dbg("%s - RTS/CTS is disabled", __func__); | 2584 | dev_dbg(dev, "%s - RTS/CTS is disabled\n", __func__); |
2632 | } | 2585 | } |
2633 | 2586 | ||
2634 | /* if we are implementing XON/XOFF, set the start and stop character | 2587 | /* if we are implementing XON/XOFF, set the start and stop character |
@@ -2649,19 +2602,19 @@ static void change_port_settings(struct tty_struct *tty, | |||
2649 | /* if we are implementing INBOUND XON/XOFF */ | 2602 | /* if we are implementing INBOUND XON/XOFF */ |
2650 | if (I_IXOFF(tty)) { | 2603 | if (I_IXOFF(tty)) { |
2651 | rxFlow |= IOSP_RX_FLOW_XON_XOFF; | 2604 | rxFlow |= IOSP_RX_FLOW_XON_XOFF; |
2652 | dbg("%s - INBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x", | 2605 | dev_dbg(dev, "%s - INBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x\n", |
2653 | __func__, start_char, stop_char); | 2606 | __func__, start_char, stop_char); |
2654 | } else { | 2607 | } else { |
2655 | dbg("%s - INBOUND XON/XOFF is disabled", __func__); | 2608 | dev_dbg(dev, "%s - INBOUND XON/XOFF is disabled\n", __func__); |
2656 | } | 2609 | } |
2657 | 2610 | ||
2658 | /* if we are implementing OUTBOUND XON/XOFF */ | 2611 | /* if we are implementing OUTBOUND XON/XOFF */ |
2659 | if (I_IXON(tty)) { | 2612 | if (I_IXON(tty)) { |
2660 | txFlow |= IOSP_TX_FLOW_XON_XOFF; | 2613 | txFlow |= IOSP_TX_FLOW_XON_XOFF; |
2661 | dbg("%s - OUTBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x", | 2614 | dev_dbg(dev, "%s - OUTBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x\n", |
2662 | __func__, start_char, stop_char); | 2615 | __func__, start_char, stop_char); |
2663 | } else { | 2616 | } else { |
2664 | dbg("%s - OUTBOUND XON/XOFF is disabled", __func__); | 2617 | dev_dbg(dev, "%s - OUTBOUND XON/XOFF is disabled\n", __func__); |
2665 | } | 2618 | } |
2666 | } | 2619 | } |
2667 | 2620 | ||
@@ -2704,7 +2657,7 @@ static void change_port_settings(struct tty_struct *tty, | |||
2704 | baud = 9600; | 2657 | baud = 9600; |
2705 | } | 2658 | } |
2706 | 2659 | ||
2707 | dbg("%s - baud rate = %d", __func__, baud); | 2660 | dev_dbg(dev, "%s - baud rate = %d\n", __func__, baud); |
2708 | status = send_cmd_write_baud_rate(edge_port, baud); | 2661 | status = send_cmd_write_baud_rate(edge_port, baud); |
2709 | if (status == -1) { | 2662 | if (status == -1) { |
2710 | /* Speed change was not possible - put back the old speed */ | 2663 | /* Speed change was not possible - put back the old speed */ |
@@ -2746,9 +2699,10 @@ static void unicode_to_ascii(char *string, int buflen, | |||
2746 | ****************************************************************************/ | 2699 | ****************************************************************************/ |
2747 | static void get_manufacturing_desc(struct edgeport_serial *edge_serial) | 2700 | static void get_manufacturing_desc(struct edgeport_serial *edge_serial) |
2748 | { | 2701 | { |
2702 | struct device *dev = &edge_serial->serial->dev->dev; | ||
2749 | int response; | 2703 | int response; |
2750 | 2704 | ||
2751 | dbg("getting manufacturer descriptor"); | 2705 | dev_dbg(dev, "getting manufacturer descriptor\n"); |
2752 | 2706 | ||
2753 | response = rom_read(edge_serial->serial, | 2707 | response = rom_read(edge_serial->serial, |
2754 | (EDGE_MANUF_DESC_ADDR & 0xffff0000) >> 16, | 2708 | (EDGE_MANUF_DESC_ADDR & 0xffff0000) >> 16, |
@@ -2757,42 +2711,41 @@ static void get_manufacturing_desc(struct edgeport_serial *edge_serial) | |||
2757 | (__u8 *)(&edge_serial->manuf_descriptor)); | 2711 | (__u8 *)(&edge_serial->manuf_descriptor)); |
2758 | 2712 | ||
2759 | if (response < 1) | 2713 | if (response < 1) |
2760 | dev_err(&edge_serial->serial->dev->dev, | 2714 | dev_err(dev, "error in getting manufacturer descriptor\n"); |
2761 | "error in getting manufacturer descriptor\n"); | ||
2762 | else { | 2715 | else { |
2763 | char string[30]; | 2716 | char string[30]; |
2764 | dbg("**Manufacturer Descriptor"); | 2717 | dev_dbg(dev, "**Manufacturer Descriptor\n"); |
2765 | dbg(" RomSize: %dK", | 2718 | dev_dbg(dev, " RomSize: %dK\n", |
2766 | edge_serial->manuf_descriptor.RomSize); | 2719 | edge_serial->manuf_descriptor.RomSize); |
2767 | dbg(" RamSize: %dK", | 2720 | dev_dbg(dev, " RamSize: %dK\n", |
2768 | edge_serial->manuf_descriptor.RamSize); | 2721 | edge_serial->manuf_descriptor.RamSize); |
2769 | dbg(" CpuRev: %d", | 2722 | dev_dbg(dev, " CpuRev: %d\n", |
2770 | edge_serial->manuf_descriptor.CpuRev); | 2723 | edge_serial->manuf_descriptor.CpuRev); |
2771 | dbg(" BoardRev: %d", | 2724 | dev_dbg(dev, " BoardRev: %d\n", |
2772 | edge_serial->manuf_descriptor.BoardRev); | 2725 | edge_serial->manuf_descriptor.BoardRev); |
2773 | dbg(" NumPorts: %d", | 2726 | dev_dbg(dev, " NumPorts: %d\n", |
2774 | edge_serial->manuf_descriptor.NumPorts); | 2727 | edge_serial->manuf_descriptor.NumPorts); |
2775 | dbg(" DescDate: %d/%d/%d", | 2728 | dev_dbg(dev, " DescDate: %d/%d/%d\n", |
2776 | edge_serial->manuf_descriptor.DescDate[0], | 2729 | edge_serial->manuf_descriptor.DescDate[0], |
2777 | edge_serial->manuf_descriptor.DescDate[1], | 2730 | edge_serial->manuf_descriptor.DescDate[1], |
2778 | edge_serial->manuf_descriptor.DescDate[2]+1900); | 2731 | edge_serial->manuf_descriptor.DescDate[2]+1900); |
2779 | unicode_to_ascii(string, sizeof(string), | 2732 | unicode_to_ascii(string, sizeof(string), |
2780 | edge_serial->manuf_descriptor.SerialNumber, | 2733 | edge_serial->manuf_descriptor.SerialNumber, |
2781 | edge_serial->manuf_descriptor.SerNumLength/2); | 2734 | edge_serial->manuf_descriptor.SerNumLength/2); |
2782 | dbg(" SerialNumber: %s", string); | 2735 | dev_dbg(dev, " SerialNumber: %s\n", string); |
2783 | unicode_to_ascii(string, sizeof(string), | 2736 | unicode_to_ascii(string, sizeof(string), |
2784 | edge_serial->manuf_descriptor.AssemblyNumber, | 2737 | edge_serial->manuf_descriptor.AssemblyNumber, |
2785 | edge_serial->manuf_descriptor.AssemblyNumLength/2); | 2738 | edge_serial->manuf_descriptor.AssemblyNumLength/2); |
2786 | dbg(" AssemblyNumber: %s", string); | 2739 | dev_dbg(dev, " AssemblyNumber: %s\n", string); |
2787 | unicode_to_ascii(string, sizeof(string), | 2740 | unicode_to_ascii(string, sizeof(string), |
2788 | edge_serial->manuf_descriptor.OemAssyNumber, | 2741 | edge_serial->manuf_descriptor.OemAssyNumber, |
2789 | edge_serial->manuf_descriptor.OemAssyNumLength/2); | 2742 | edge_serial->manuf_descriptor.OemAssyNumLength/2); |
2790 | dbg(" OemAssyNumber: %s", string); | 2743 | dev_dbg(dev, " OemAssyNumber: %s\n", string); |
2791 | dbg(" UartType: %d", | 2744 | dev_dbg(dev, " UartType: %d\n", |
2792 | edge_serial->manuf_descriptor.UartType); | 2745 | edge_serial->manuf_descriptor.UartType); |
2793 | dbg(" IonPid: %d", | 2746 | dev_dbg(dev, " IonPid: %d\n", |
2794 | edge_serial->manuf_descriptor.IonPid); | 2747 | edge_serial->manuf_descriptor.IonPid); |
2795 | dbg(" IonConfig: %d", | 2748 | dev_dbg(dev, " IonConfig: %d\n", |
2796 | edge_serial->manuf_descriptor.IonConfig); | 2749 | edge_serial->manuf_descriptor.IonConfig); |
2797 | } | 2750 | } |
2798 | } | 2751 | } |
@@ -2805,9 +2758,10 @@ static void get_manufacturing_desc(struct edgeport_serial *edge_serial) | |||
2805 | ****************************************************************************/ | 2758 | ****************************************************************************/ |
2806 | static void get_boot_desc(struct edgeport_serial *edge_serial) | 2759 | static void get_boot_desc(struct edgeport_serial *edge_serial) |
2807 | { | 2760 | { |
2761 | struct device *dev = &edge_serial->serial->dev->dev; | ||
2808 | int response; | 2762 | int response; |
2809 | 2763 | ||
2810 | dbg("getting boot descriptor"); | 2764 | dev_dbg(dev, "getting boot descriptor\n"); |
2811 | 2765 | ||
2812 | response = rom_read(edge_serial->serial, | 2766 | response = rom_read(edge_serial->serial, |
2813 | (EDGE_BOOT_DESC_ADDR & 0xffff0000) >> 16, | 2767 | (EDGE_BOOT_DESC_ADDR & 0xffff0000) >> 16, |
@@ -2816,23 +2770,22 @@ static void get_boot_desc(struct edgeport_serial *edge_serial) | |||
2816 | (__u8 *)(&edge_serial->boot_descriptor)); | 2770 | (__u8 *)(&edge_serial->boot_descriptor)); |
2817 | 2771 | ||
2818 | if (response < 1) | 2772 | if (response < 1) |
2819 | dev_err(&edge_serial->serial->dev->dev, | 2773 | dev_err(dev, "error in getting boot descriptor\n"); |
2820 | "error in getting boot descriptor\n"); | ||
2821 | else { | 2774 | else { |
2822 | dbg("**Boot Descriptor:"); | 2775 | dev_dbg(dev, "**Boot Descriptor:\n"); |
2823 | dbg(" BootCodeLength: %d", | 2776 | dev_dbg(dev, " BootCodeLength: %d\n", |
2824 | le16_to_cpu(edge_serial->boot_descriptor.BootCodeLength)); | 2777 | le16_to_cpu(edge_serial->boot_descriptor.BootCodeLength)); |
2825 | dbg(" MajorVersion: %d", | 2778 | dev_dbg(dev, " MajorVersion: %d\n", |
2826 | edge_serial->boot_descriptor.MajorVersion); | 2779 | edge_serial->boot_descriptor.MajorVersion); |
2827 | dbg(" MinorVersion: %d", | 2780 | dev_dbg(dev, " MinorVersion: %d\n", |
2828 | edge_serial->boot_descriptor.MinorVersion); | 2781 | edge_serial->boot_descriptor.MinorVersion); |
2829 | dbg(" BuildNumber: %d", | 2782 | dev_dbg(dev, " BuildNumber: %d\n", |
2830 | le16_to_cpu(edge_serial->boot_descriptor.BuildNumber)); | 2783 | le16_to_cpu(edge_serial->boot_descriptor.BuildNumber)); |
2831 | dbg(" Capabilities: 0x%x", | 2784 | dev_dbg(dev, " Capabilities: 0x%x\n", |
2832 | le16_to_cpu(edge_serial->boot_descriptor.Capabilities)); | 2785 | le16_to_cpu(edge_serial->boot_descriptor.Capabilities)); |
2833 | dbg(" UConfig0: %d", | 2786 | dev_dbg(dev, " UConfig0: %d\n", |
2834 | edge_serial->boot_descriptor.UConfig0); | 2787 | edge_serial->boot_descriptor.UConfig0); |
2835 | dbg(" UConfig1: %d", | 2788 | dev_dbg(dev, " UConfig1: %d\n", |
2836 | edge_serial->boot_descriptor.UConfig1); | 2789 | edge_serial->boot_descriptor.UConfig1); |
2837 | } | 2790 | } |
2838 | } | 2791 | } |
@@ -2844,6 +2797,7 @@ static void get_boot_desc(struct edgeport_serial *edge_serial) | |||
2844 | ****************************************************************************/ | 2797 | ****************************************************************************/ |
2845 | static void load_application_firmware(struct edgeport_serial *edge_serial) | 2798 | static void load_application_firmware(struct edgeport_serial *edge_serial) |
2846 | { | 2799 | { |
2800 | struct device *dev = &edge_serial->serial->dev->dev; | ||
2847 | const struct ihex_binrec *rec; | 2801 | const struct ihex_binrec *rec; |
2848 | const struct firmware *fw; | 2802 | const struct firmware *fw; |
2849 | const char *fw_name; | 2803 | const char *fw_name; |
@@ -2864,7 +2818,7 @@ static void load_application_firmware(struct edgeport_serial *edge_serial) | |||
2864 | break; | 2818 | break; |
2865 | 2819 | ||
2866 | case EDGE_DOWNLOAD_FILE_NONE: | 2820 | case EDGE_DOWNLOAD_FILE_NONE: |
2867 | dbg("No download file specified, skipping download"); | 2821 | dev_dbg(dev, "No download file specified, skipping download\n"); |
2868 | return; | 2822 | return; |
2869 | 2823 | ||
2870 | default: | 2824 | default: |
@@ -2874,7 +2828,7 @@ static void load_application_firmware(struct edgeport_serial *edge_serial) | |||
2874 | response = request_ihex_firmware(&fw, fw_name, | 2828 | response = request_ihex_firmware(&fw, fw_name, |
2875 | &edge_serial->serial->dev->dev); | 2829 | &edge_serial->serial->dev->dev); |
2876 | if (response) { | 2830 | if (response) { |
2877 | printk(KERN_ERR "Failed to load image \"%s\" err %d\n", | 2831 | dev_err(dev, "Failed to load image \"%s\" err %d\n", |
2878 | fw_name, response); | 2832 | fw_name, response); |
2879 | return; | 2833 | return; |
2880 | } | 2834 | } |
@@ -2882,7 +2836,7 @@ static void load_application_firmware(struct edgeport_serial *edge_serial) | |||
2882 | rec = (const struct ihex_binrec *)fw->data; | 2836 | rec = (const struct ihex_binrec *)fw->data; |
2883 | build = (rec->data[2] << 8) | rec->data[3]; | 2837 | build = (rec->data[2] << 8) | rec->data[3]; |
2884 | 2838 | ||
2885 | dbg("%s %d.%d.%d", fw_info, rec->data[0], rec->data[1], build); | 2839 | dev_dbg(dev, "%s %d.%d.%d\n", fw_info, rec->data[0], rec->data[1], build); |
2886 | 2840 | ||
2887 | edge_serial->product_info.FirmwareMajorVersion = rec->data[0]; | 2841 | edge_serial->product_info.FirmwareMajorVersion = rec->data[0]; |
2888 | edge_serial->product_info.FirmwareMinorVersion = rec->data[1]; | 2842 | edge_serial->product_info.FirmwareMinorVersion = rec->data[1]; |
@@ -2905,10 +2859,10 @@ static void load_application_firmware(struct edgeport_serial *edge_serial) | |||
2905 | } | 2859 | } |
2906 | } | 2860 | } |
2907 | 2861 | ||
2908 | dbg("sending exec_dl_code"); | 2862 | dev_dbg(dev, "sending exec_dl_code\n"); |
2909 | response = usb_control_msg (edge_serial->serial->dev, | 2863 | response = usb_control_msg (edge_serial->serial->dev, |
2910 | usb_sndctrlpipe(edge_serial->serial->dev, 0), | 2864 | usb_sndctrlpipe(edge_serial->serial->dev, 0), |
2911 | USB_REQUEST_ION_EXEC_DL_CODE, | 2865 | USB_REQUEST_ION_EXEC_DL_CODE, |
2912 | 0x40, 0x4000, 0x0001, NULL, 0, 3000); | 2866 | 0x40, 0x4000, 0x0001, NULL, 0, 3000); |
2913 | 2867 | ||
2914 | release_firmware(fw); | 2868 | release_firmware(fw); |
@@ -2923,6 +2877,7 @@ static int edge_startup(struct usb_serial *serial) | |||
2923 | struct edgeport_serial *edge_serial; | 2877 | struct edgeport_serial *edge_serial; |
2924 | struct edgeport_port *edge_port; | 2878 | struct edgeport_port *edge_port; |
2925 | struct usb_device *dev; | 2879 | struct usb_device *dev; |
2880 | struct device *ddev = &serial->dev->dev; | ||
2926 | int i, j; | 2881 | int i, j; |
2927 | int response; | 2882 | int response; |
2928 | bool interrupt_in_found; | 2883 | bool interrupt_in_found; |
@@ -2974,32 +2929,31 @@ static int edge_startup(struct usb_serial *serial) | |||
2974 | /* serial->num_ports = serial->product_info.NumPorts; */ | 2929 | /* serial->num_ports = serial->product_info.NumPorts; */ |
2975 | if ((!edge_serial->is_epic) && | 2930 | if ((!edge_serial->is_epic) && |
2976 | (edge_serial->product_info.NumPorts != serial->num_ports)) { | 2931 | (edge_serial->product_info.NumPorts != serial->num_ports)) { |
2977 | dev_warn(&serial->dev->dev, "Device Reported %d serial ports " | 2932 | dev_warn(ddev, |
2978 | "vs. core thinking we have %d ports, email " | 2933 | "Device Reported %d serial ports vs. core thinking we have %d ports, email greg@kroah.com this information.\n", |
2979 | "greg@kroah.com this information.\n", | ||
2980 | edge_serial->product_info.NumPorts, | 2934 | edge_serial->product_info.NumPorts, |
2981 | serial->num_ports); | 2935 | serial->num_ports); |
2982 | } | 2936 | } |
2983 | 2937 | ||
2984 | dbg("%s - time 1 %ld", __func__, jiffies); | 2938 | dev_dbg(ddev, "%s - time 1 %ld\n", __func__, jiffies); |
2985 | 2939 | ||
2986 | /* If not an EPiC device */ | 2940 | /* If not an EPiC device */ |
2987 | if (!edge_serial->is_epic) { | 2941 | if (!edge_serial->is_epic) { |
2988 | /* now load the application firmware into this device */ | 2942 | /* now load the application firmware into this device */ |
2989 | load_application_firmware(edge_serial); | 2943 | load_application_firmware(edge_serial); |
2990 | 2944 | ||
2991 | dbg("%s - time 2 %ld", __func__, jiffies); | 2945 | dev_dbg(ddev, "%s - time 2 %ld\n", __func__, jiffies); |
2992 | 2946 | ||
2993 | /* Check current Edgeport EEPROM and update if necessary */ | 2947 | /* Check current Edgeport EEPROM and update if necessary */ |
2994 | update_edgeport_E2PROM(edge_serial); | 2948 | update_edgeport_E2PROM(edge_serial); |
2995 | 2949 | ||
2996 | dbg("%s - time 3 %ld", __func__, jiffies); | 2950 | dev_dbg(ddev, "%s - time 3 %ld\n", __func__, jiffies); |
2997 | 2951 | ||
2998 | /* set the configuration to use #1 */ | 2952 | /* set the configuration to use #1 */ |
2999 | /* dbg("set_configuration 1"); */ | 2953 | /* dev_dbg(ddev, "set_configuration 1\n"); */ |
3000 | /* usb_set_configuration (dev, 1); */ | 2954 | /* usb_set_configuration (dev, 1); */ |
3001 | } | 2955 | } |
3002 | dbg(" FirmwareMajorVersion %d.%d.%d", | 2956 | dev_dbg(ddev, " FirmwareMajorVersion %d.%d.%d\n", |
3003 | edge_serial->product_info.FirmwareMajorVersion, | 2957 | edge_serial->product_info.FirmwareMajorVersion, |
3004 | edge_serial->product_info.FirmwareMinorVersion, | 2958 | edge_serial->product_info.FirmwareMinorVersion, |
3005 | le16_to_cpu(edge_serial->product_info.FirmwareBuildNumber)); | 2959 | le16_to_cpu(edge_serial->product_info.FirmwareBuildNumber)); |
@@ -3011,8 +2965,7 @@ static int edge_startup(struct usb_serial *serial) | |||
3011 | for (i = 0; i < serial->num_ports; ++i) { | 2965 | for (i = 0; i < serial->num_ports; ++i) { |
3012 | edge_port = kzalloc(sizeof(struct edgeport_port), GFP_KERNEL); | 2966 | edge_port = kzalloc(sizeof(struct edgeport_port), GFP_KERNEL); |
3013 | if (edge_port == NULL) { | 2967 | if (edge_port == NULL) { |
3014 | dev_err(&serial->dev->dev, "%s - Out of memory\n", | 2968 | dev_err(ddev, "%s - Out of memory\n", __func__); |
3015 | __func__); | ||
3016 | for (j = 0; j < i; ++j) { | 2969 | for (j = 0; j < i; ++j) { |
3017 | kfree(usb_get_serial_port_data(serial->port[j])); | 2970 | kfree(usb_get_serial_port_data(serial->port[j])); |
3018 | usb_set_serial_port_data(serial->port[j], | 2971 | usb_set_serial_port_data(serial->port[j], |
@@ -3044,19 +2997,19 @@ static int edge_startup(struct usb_serial *serial) | |||
3044 | if (!interrupt_in_found && | 2997 | if (!interrupt_in_found && |
3045 | (usb_endpoint_is_int_in(endpoint))) { | 2998 | (usb_endpoint_is_int_in(endpoint))) { |
3046 | /* we found a interrupt in endpoint */ | 2999 | /* we found a interrupt in endpoint */ |
3047 | dbg("found interrupt in"); | 3000 | dev_dbg(ddev, "found interrupt in\n"); |
3048 | 3001 | ||
3049 | /* not set up yet, so do it now */ | 3002 | /* not set up yet, so do it now */ |
3050 | edge_serial->interrupt_read_urb = | 3003 | edge_serial->interrupt_read_urb = |
3051 | usb_alloc_urb(0, GFP_KERNEL); | 3004 | usb_alloc_urb(0, GFP_KERNEL); |
3052 | if (!edge_serial->interrupt_read_urb) { | 3005 | if (!edge_serial->interrupt_read_urb) { |
3053 | dev_err(&dev->dev, "out of memory\n"); | 3006 | dev_err(ddev, "out of memory\n"); |
3054 | return -ENOMEM; | 3007 | return -ENOMEM; |
3055 | } | 3008 | } |
3056 | edge_serial->interrupt_in_buffer = | 3009 | edge_serial->interrupt_in_buffer = |
3057 | kmalloc(buffer_size, GFP_KERNEL); | 3010 | kmalloc(buffer_size, GFP_KERNEL); |
3058 | if (!edge_serial->interrupt_in_buffer) { | 3011 | if (!edge_serial->interrupt_in_buffer) { |
3059 | dev_err(&dev->dev, "out of memory\n"); | 3012 | dev_err(ddev, "out of memory\n"); |
3060 | usb_free_urb(edge_serial->interrupt_read_urb); | 3013 | usb_free_urb(edge_serial->interrupt_read_urb); |
3061 | return -ENOMEM; | 3014 | return -ENOMEM; |
3062 | } | 3015 | } |
@@ -3081,13 +3034,13 @@ static int edge_startup(struct usb_serial *serial) | |||
3081 | if (!bulk_in_found && | 3034 | if (!bulk_in_found && |
3082 | (usb_endpoint_is_bulk_in(endpoint))) { | 3035 | (usb_endpoint_is_bulk_in(endpoint))) { |
3083 | /* we found a bulk in endpoint */ | 3036 | /* we found a bulk in endpoint */ |
3084 | dbg("found bulk in"); | 3037 | dev_dbg(ddev, "found bulk in\n"); |
3085 | 3038 | ||
3086 | /* not set up yet, so do it now */ | 3039 | /* not set up yet, so do it now */ |
3087 | edge_serial->read_urb = | 3040 | edge_serial->read_urb = |
3088 | usb_alloc_urb(0, GFP_KERNEL); | 3041 | usb_alloc_urb(0, GFP_KERNEL); |
3089 | if (!edge_serial->read_urb) { | 3042 | if (!edge_serial->read_urb) { |
3090 | dev_err(&dev->dev, "out of memory\n"); | 3043 | dev_err(ddev, "out of memory\n"); |
3091 | return -ENOMEM; | 3044 | return -ENOMEM; |
3092 | } | 3045 | } |
3093 | edge_serial->bulk_in_buffer = | 3046 | edge_serial->bulk_in_buffer = |
@@ -3114,7 +3067,7 @@ static int edge_startup(struct usb_serial *serial) | |||
3114 | if (!bulk_out_found && | 3067 | if (!bulk_out_found && |
3115 | (usb_endpoint_is_bulk_out(endpoint))) { | 3068 | (usb_endpoint_is_bulk_out(endpoint))) { |
3116 | /* we found a bulk out endpoint */ | 3069 | /* we found a bulk out endpoint */ |
3117 | dbg("found bulk out"); | 3070 | dev_dbg(ddev, "found bulk out\n"); |
3118 | edge_serial->bulk_out_endpoint = | 3071 | edge_serial->bulk_out_endpoint = |
3119 | endpoint->bEndpointAddress; | 3072 | endpoint->bEndpointAddress; |
3120 | bulk_out_found = true; | 3073 | bulk_out_found = true; |
@@ -3122,8 +3075,7 @@ static int edge_startup(struct usb_serial *serial) | |||
3122 | } | 3075 | } |
3123 | 3076 | ||
3124 | if (!interrupt_in_found || !bulk_in_found || !bulk_out_found) { | 3077 | if (!interrupt_in_found || !bulk_in_found || !bulk_out_found) { |
3125 | dev_err(&dev->dev, "Error - the proper endpoints " | 3078 | dev_err(ddev, "Error - the proper endpoints were not found!\n"); |
3126 | "were not found!\n"); | ||
3127 | return -ENODEV; | 3079 | return -ENODEV; |
3128 | } | 3080 | } |
3129 | 3081 | ||
@@ -3132,8 +3084,7 @@ static int edge_startup(struct usb_serial *serial) | |||
3132 | response = usb_submit_urb(edge_serial->interrupt_read_urb, | 3084 | response = usb_submit_urb(edge_serial->interrupt_read_urb, |
3133 | GFP_KERNEL); | 3085 | GFP_KERNEL); |
3134 | if (response) | 3086 | if (response) |
3135 | dev_err(&dev->dev, | 3087 | dev_err(ddev, "%s - Error %d submitting control urb\n", |
3136 | "%s - Error %d submitting control urb\n", | ||
3137 | __func__, response); | 3088 | __func__, response); |
3138 | } | 3089 | } |
3139 | return response; | 3090 | return response; |
@@ -3148,8 +3099,6 @@ static void edge_disconnect(struct usb_serial *serial) | |||
3148 | { | 3099 | { |
3149 | struct edgeport_serial *edge_serial = usb_get_serial_data(serial); | 3100 | struct edgeport_serial *edge_serial = usb_get_serial_data(serial); |
3150 | 3101 | ||
3151 | dbg("%s", __func__); | ||
3152 | |||
3153 | /* stop reads and writes on all ports */ | 3102 | /* stop reads and writes on all ports */ |
3154 | /* free up our endpoint stuff */ | 3103 | /* free up our endpoint stuff */ |
3155 | if (edge_serial->is_epic) { | 3104 | if (edge_serial->is_epic) { |
@@ -3173,8 +3122,6 @@ static void edge_release(struct usb_serial *serial) | |||
3173 | struct edgeport_serial *edge_serial = usb_get_serial_data(serial); | 3122 | struct edgeport_serial *edge_serial = usb_get_serial_data(serial); |
3174 | int i; | 3123 | int i; |
3175 | 3124 | ||
3176 | dbg("%s", __func__); | ||
3177 | |||
3178 | for (i = 0; i < serial->num_ports; ++i) | 3125 | for (i = 0; i < serial->num_ports; ++i) |
3179 | kfree(usb_get_serial_port_data(serial->port[i])); | 3126 | kfree(usb_get_serial_port_data(serial->port[i])); |
3180 | 3127 | ||
@@ -3190,6 +3137,3 @@ MODULE_FIRMWARE("edgeport/boot.fw"); | |||
3190 | MODULE_FIRMWARE("edgeport/boot2.fw"); | 3137 | MODULE_FIRMWARE("edgeport/boot2.fw"); |
3191 | MODULE_FIRMWARE("edgeport/down.fw"); | 3138 | MODULE_FIRMWARE("edgeport/down.fw"); |
3192 | MODULE_FIRMWARE("edgeport/down2.fw"); | 3139 | MODULE_FIRMWARE("edgeport/down2.fw"); |
3193 | |||
3194 | module_param(debug, bool, S_IRUGO | S_IWUSR); | ||
3195 | MODULE_PARM_DESC(debug, "Debug enabled or not"); | ||
diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c index 765978ae752e..a2209cd45093 100644 --- a/drivers/usb/serial/io_ti.c +++ b/drivers/usb/serial/io_ti.c | |||
@@ -201,8 +201,6 @@ static unsigned char OperationalMajorVersion; | |||
201 | static unsigned char OperationalMinorVersion; | 201 | static unsigned char OperationalMinorVersion; |
202 | static unsigned short OperationalBuildNumber; | 202 | static unsigned short OperationalBuildNumber; |
203 | 203 | ||
204 | static bool debug; | ||
205 | |||
206 | static int closing_wait = EDGE_CLOSING_WAIT; | 204 | static int closing_wait = EDGE_CLOSING_WAIT; |
207 | static bool ignore_cpu_rev; | 205 | static bool ignore_cpu_rev; |
208 | static int default_uart_mode; /* RS232 */ | 206 | static int default_uart_mode; /* RS232 */ |
@@ -233,8 +231,8 @@ static int ti_vread_sync(struct usb_device *dev, __u8 request, | |||
233 | if (status < 0) | 231 | if (status < 0) |
234 | return status; | 232 | return status; |
235 | if (status != size) { | 233 | if (status != size) { |
236 | dbg("%s - wanted to write %d, but only wrote %d", | 234 | dev_dbg(&dev->dev, "%s - wanted to write %d, but only wrote %d\n", |
237 | __func__, size, status); | 235 | __func__, size, status); |
238 | return -ECOMM; | 236 | return -ECOMM; |
239 | } | 237 | } |
240 | return 0; | 238 | return 0; |
@@ -251,8 +249,8 @@ static int ti_vsend_sync(struct usb_device *dev, __u8 request, | |||
251 | if (status < 0) | 249 | if (status < 0) |
252 | return status; | 250 | return status; |
253 | if (status != size) { | 251 | if (status != size) { |
254 | dbg("%s - wanted to write %d, but only wrote %d", | 252 | dev_dbg(&dev->dev, "%s - wanted to write %d, but only wrote %d\n", |
255 | __func__, size, status); | 253 | __func__, size, status); |
256 | return -ECOMM; | 254 | return -ECOMM; |
257 | } | 255 | } |
258 | return 0; | 256 | return 0; |
@@ -270,7 +268,7 @@ static int purge_port(struct usb_serial_port *port, __u16 mask) | |||
270 | { | 268 | { |
271 | int port_number = port->number - port->serial->minor; | 269 | int port_number = port->number - port->serial->minor; |
272 | 270 | ||
273 | dbg("%s - port %d, mask %x", __func__, port_number, mask); | 271 | dev_dbg(&port->dev, "%s - port %d, mask %x\n", __func__, port_number, mask); |
274 | 272 | ||
275 | return send_cmd(port->serial->dev, | 273 | return send_cmd(port->serial->dev, |
276 | UMPC_PURGE_PORT, | 274 | UMPC_PURGE_PORT, |
@@ -295,7 +293,7 @@ static int read_download_mem(struct usb_device *dev, int start_address, | |||
295 | __u8 read_length; | 293 | __u8 read_length; |
296 | __be16 be_start_address; | 294 | __be16 be_start_address; |
297 | 295 | ||
298 | dbg("%s - @ %x for %d", __func__, start_address, length); | 296 | dev_dbg(&dev->dev, "%s - @ %x for %d\n", __func__, start_address, length); |
299 | 297 | ||
300 | /* Read in blocks of 64 bytes | 298 | /* Read in blocks of 64 bytes |
301 | * (TI firmware can't handle more than 64 byte reads) | 299 | * (TI firmware can't handle more than 64 byte reads) |
@@ -307,8 +305,7 @@ static int read_download_mem(struct usb_device *dev, int start_address, | |||
307 | read_length = (__u8)length; | 305 | read_length = (__u8)length; |
308 | 306 | ||
309 | if (read_length > 1) { | 307 | if (read_length > 1) { |
310 | dbg("%s - @ %x for %d", __func__, | 308 | dev_dbg(&dev->dev, "%s - @ %x for %d\n", __func__, start_address, read_length); |
311 | start_address, read_length); | ||
312 | } | 309 | } |
313 | be_start_address = cpu_to_be16(start_address); | 310 | be_start_address = cpu_to_be16(start_address); |
314 | status = ti_vread_sync(dev, UMPC_MEMORY_READ, | 311 | status = ti_vread_sync(dev, UMPC_MEMORY_READ, |
@@ -317,13 +314,12 @@ static int read_download_mem(struct usb_device *dev, int start_address, | |||
317 | buffer, read_length); | 314 | buffer, read_length); |
318 | 315 | ||
319 | if (status) { | 316 | if (status) { |
320 | dbg("%s - ERROR %x", __func__, status); | 317 | dev_dbg(&dev->dev, "%s - ERROR %x\n", __func__, status); |
321 | return status; | 318 | return status; |
322 | } | 319 | } |
323 | 320 | ||
324 | if (read_length > 1) | 321 | if (read_length > 1) |
325 | usb_serial_debug_data(debug, &dev->dev, __func__, | 322 | usb_serial_debug_data(&dev->dev, __func__, read_length, buffer); |
326 | read_length, buffer); | ||
327 | 323 | ||
328 | /* Update pointers/length */ | 324 | /* Update pointers/length */ |
329 | start_address += read_length; | 325 | start_address += read_length; |
@@ -353,15 +349,14 @@ static int read_boot_mem(struct edgeport_serial *serial, | |||
353 | UMPC_MEMORY_READ, serial->TI_I2C_Type, | 349 | UMPC_MEMORY_READ, serial->TI_I2C_Type, |
354 | (__u16)(start_address+i), &buffer[i], 0x01); | 350 | (__u16)(start_address+i), &buffer[i], 0x01); |
355 | if (status) { | 351 | if (status) { |
356 | dbg("%s - ERROR %x", __func__, status); | 352 | dev_dbg(&serial->serial->dev->dev, "%s - ERROR %x\n", __func__, status); |
357 | return status; | 353 | return status; |
358 | } | 354 | } |
359 | } | 355 | } |
360 | 356 | ||
361 | dbg("%s - start_address = %x, length = %d", | 357 | dev_dbg(&serial->serial->dev->dev, "%s - start_address = %x, length = %d\n", |
362 | __func__, start_address, length); | 358 | __func__, start_address, length); |
363 | usb_serial_debug_data(debug, &serial->serial->dev->dev, | 359 | usb_serial_debug_data(&serial->serial->dev->dev, __func__, length, buffer); |
364 | __func__, length, buffer); | ||
365 | 360 | ||
366 | serial->TiReadI2C = 1; | 361 | serial->TiReadI2C = 1; |
367 | 362 | ||
@@ -398,10 +393,8 @@ static int write_boot_mem(struct edgeport_serial *serial, | |||
398 | return status; | 393 | return status; |
399 | } | 394 | } |
400 | 395 | ||
401 | dbg("%s - start_sddr = %x, length = %d", | 396 | dev_dbg(&serial->serial->dev->dev, "%s - start_sddr = %x, length = %d\n", __func__, start_address, length); |
402 | __func__, start_address, length); | 397 | usb_serial_debug_data(&serial->serial->dev->dev, __func__, length, buffer); |
403 | usb_serial_debug_data(debug, &serial->serial->dev->dev, | ||
404 | __func__, length, buffer); | ||
405 | 398 | ||
406 | return status; | 399 | return status; |
407 | } | 400 | } |
@@ -411,6 +404,7 @@ static int write_boot_mem(struct edgeport_serial *serial, | |||
411 | static int write_i2c_mem(struct edgeport_serial *serial, | 404 | static int write_i2c_mem(struct edgeport_serial *serial, |
412 | int start_address, int length, __u8 address_type, __u8 *buffer) | 405 | int start_address, int length, __u8 address_type, __u8 *buffer) |
413 | { | 406 | { |
407 | struct device *dev = &serial->serial->dev->dev; | ||
414 | int status = 0; | 408 | int status = 0; |
415 | int write_length; | 409 | int write_length; |
416 | __be16 be_start_address; | 410 | __be16 be_start_address; |
@@ -424,10 +418,9 @@ static int write_i2c_mem(struct edgeport_serial *serial, | |||
424 | if (write_length > length) | 418 | if (write_length > length) |
425 | write_length = length; | 419 | write_length = length; |
426 | 420 | ||
427 | dbg("%s - BytesInFirstPage Addr = %x, length = %d", | 421 | dev_dbg(dev, "%s - BytesInFirstPage Addr = %x, length = %d\n", |
428 | __func__, start_address, write_length); | 422 | __func__, start_address, write_length); |
429 | usb_serial_debug_data(debug, &serial->serial->dev->dev, | 423 | usb_serial_debug_data(dev, __func__, write_length, buffer); |
430 | __func__, write_length, buffer); | ||
431 | 424 | ||
432 | /* Write first page */ | 425 | /* Write first page */ |
433 | be_start_address = cpu_to_be16(start_address); | 426 | be_start_address = cpu_to_be16(start_address); |
@@ -436,7 +429,7 @@ static int write_i2c_mem(struct edgeport_serial *serial, | |||
436 | (__force __u16)be_start_address, | 429 | (__force __u16)be_start_address, |
437 | buffer, write_length); | 430 | buffer, write_length); |
438 | if (status) { | 431 | if (status) { |
439 | dbg("%s - ERROR %d", __func__, status); | 432 | dev_dbg(dev, "%s - ERROR %d\n", __func__, status); |
440 | return status; | 433 | return status; |
441 | } | 434 | } |
442 | 435 | ||
@@ -452,10 +445,9 @@ static int write_i2c_mem(struct edgeport_serial *serial, | |||
452 | else | 445 | else |
453 | write_length = length; | 446 | write_length = length; |
454 | 447 | ||
455 | dbg("%s - Page Write Addr = %x, length = %d", | 448 | dev_dbg(dev, "%s - Page Write Addr = %x, length = %d\n", |
456 | __func__, start_address, write_length); | 449 | __func__, start_address, write_length); |
457 | usb_serial_debug_data(debug, &serial->serial->dev->dev, | 450 | usb_serial_debug_data(dev, __func__, write_length, buffer); |
458 | __func__, write_length, buffer); | ||
459 | 451 | ||
460 | /* Write next page */ | 452 | /* Write next page */ |
461 | be_start_address = cpu_to_be16(start_address); | 453 | be_start_address = cpu_to_be16(start_address); |
@@ -464,8 +456,7 @@ static int write_i2c_mem(struct edgeport_serial *serial, | |||
464 | (__force __u16)be_start_address, | 456 | (__force __u16)be_start_address, |
465 | buffer, write_length); | 457 | buffer, write_length); |
466 | if (status) { | 458 | if (status) { |
467 | dev_err(&serial->serial->dev->dev, "%s - ERROR %d\n", | 459 | dev_err(dev, "%s - ERROR %d\n", __func__, status); |
468 | __func__, status); | ||
469 | return status; | 460 | return status; |
470 | } | 461 | } |
471 | 462 | ||
@@ -508,7 +499,7 @@ static int tx_active(struct edgeport_port *port) | |||
508 | if (status) | 499 | if (status) |
509 | goto exit_is_tx_active; | 500 | goto exit_is_tx_active; |
510 | 501 | ||
511 | dbg("%s - XByteCount 0x%X", __func__, oedb->XByteCount); | 502 | dev_dbg(&port->port->dev, "%s - XByteCount 0x%X\n", __func__, oedb->XByteCount); |
512 | 503 | ||
513 | /* and the LSR */ | 504 | /* and the LSR */ |
514 | status = read_ram(port->port->serial->dev, | 505 | status = read_ram(port->port->serial->dev, |
@@ -516,7 +507,7 @@ static int tx_active(struct edgeport_port *port) | |||
516 | 507 | ||
517 | if (status) | 508 | if (status) |
518 | goto exit_is_tx_active; | 509 | goto exit_is_tx_active; |
519 | dbg("%s - LSR = 0x%X", __func__, *lsr); | 510 | dev_dbg(&port->port->dev, "%s - LSR = 0x%X\n", __func__, *lsr); |
520 | 511 | ||
521 | /* If either buffer has data or we are transmitting then return TRUE */ | 512 | /* If either buffer has data or we are transmitting then return TRUE */ |
522 | if ((oedb->XByteCount & 0x80) != 0) | 513 | if ((oedb->XByteCount & 0x80) != 0) |
@@ -527,7 +518,7 @@ static int tx_active(struct edgeport_port *port) | |||
527 | 518 | ||
528 | /* We return Not Active if we get any kind of error */ | 519 | /* We return Not Active if we get any kind of error */ |
529 | exit_is_tx_active: | 520 | exit_is_tx_active: |
530 | dbg("%s - return %d", __func__, bytes_left); | 521 | dev_dbg(&port->port->dev, "%s - return %d\n", __func__, bytes_left); |
531 | 522 | ||
532 | kfree(lsr); | 523 | kfree(lsr); |
533 | kfree(oedb); | 524 | kfree(oedb); |
@@ -599,14 +590,13 @@ static int choose_config(struct usb_device *dev) | |||
599 | * configuration # 1, which is Config Descriptor 0. | 590 | * configuration # 1, which is Config Descriptor 0. |
600 | */ | 591 | */ |
601 | 592 | ||
602 | dbg("%s - Number of Interfaces = %d", | 593 | dev_dbg(&dev->dev, "%s - Number of Interfaces = %d\n", |
603 | __func__, dev->config->desc.bNumInterfaces); | 594 | __func__, dev->config->desc.bNumInterfaces); |
604 | dbg("%s - MAX Power = %d", | 595 | dev_dbg(&dev->dev, "%s - MAX Power = %d\n", |
605 | __func__, dev->config->desc.bMaxPower * 2); | 596 | __func__, dev->config->desc.bMaxPower * 2); |
606 | 597 | ||
607 | if (dev->config->desc.bNumInterfaces != 1) { | 598 | if (dev->config->desc.bNumInterfaces != 1) { |
608 | dev_err(&dev->dev, "%s - bNumInterfaces is not 1, ERROR!\n", | 599 | dev_err(&dev->dev, "%s - bNumInterfaces is not 1, ERROR!\n", __func__); |
609 | __func__); | ||
610 | return -ENODEV; | 600 | return -ENODEV; |
611 | } | 601 | } |
612 | 602 | ||
@@ -684,7 +674,7 @@ static int valid_csum(struct ti_i2c_desc *rom_desc, __u8 *buffer) | |||
684 | cs = (__u8)(cs + buffer[i]); | 674 | cs = (__u8)(cs + buffer[i]); |
685 | 675 | ||
686 | if (cs != rom_desc->CheckSum) { | 676 | if (cs != rom_desc->CheckSum) { |
687 | dbg("%s - Mismatch %x - %x", __func__, rom_desc->CheckSum, cs); | 677 | pr_debug("%s - Mismatch %x - %x", __func__, rom_desc->CheckSum, cs); |
688 | return -EINVAL; | 678 | return -EINVAL; |
689 | } | 679 | } |
690 | return 0; | 680 | return 0; |
@@ -736,11 +726,11 @@ static int check_i2c_image(struct edgeport_serial *serial) | |||
736 | if ((start_address + sizeof(struct ti_i2c_desc) + | 726 | if ((start_address + sizeof(struct ti_i2c_desc) + |
737 | rom_desc->Size) > TI_MAX_I2C_SIZE) { | 727 | rom_desc->Size) > TI_MAX_I2C_SIZE) { |
738 | status = -ENODEV; | 728 | status = -ENODEV; |
739 | dbg("%s - structure too big, erroring out.", __func__); | 729 | dev_dbg(dev, "%s - structure too big, erroring out.\n", __func__); |
740 | break; | 730 | break; |
741 | } | 731 | } |
742 | 732 | ||
743 | dbg("%s Type = 0x%x", __func__, rom_desc->Type); | 733 | dev_dbg(dev, "%s Type = 0x%x\n", __func__, rom_desc->Type); |
744 | 734 | ||
745 | /* Skip type 2 record */ | 735 | /* Skip type 2 record */ |
746 | ttype = rom_desc->Type & 0x0f; | 736 | ttype = rom_desc->Type & 0x0f; |
@@ -779,18 +769,18 @@ static int get_manuf_info(struct edgeport_serial *serial, __u8 *buffer) | |||
779 | int start_address; | 769 | int start_address; |
780 | struct ti_i2c_desc *rom_desc; | 770 | struct ti_i2c_desc *rom_desc; |
781 | struct edge_ti_manuf_descriptor *desc; | 771 | struct edge_ti_manuf_descriptor *desc; |
772 | struct device *dev = &serial->serial->dev->dev; | ||
782 | 773 | ||
783 | rom_desc = kmalloc(sizeof(*rom_desc), GFP_KERNEL); | 774 | rom_desc = kmalloc(sizeof(*rom_desc), GFP_KERNEL); |
784 | if (!rom_desc) { | 775 | if (!rom_desc) { |
785 | dev_err(&serial->serial->dev->dev, "%s - out of memory\n", | 776 | dev_err(dev, "%s - out of memory\n", __func__); |
786 | __func__); | ||
787 | return -ENOMEM; | 777 | return -ENOMEM; |
788 | } | 778 | } |
789 | start_address = get_descriptor_addr(serial, I2C_DESC_TYPE_ION, | 779 | start_address = get_descriptor_addr(serial, I2C_DESC_TYPE_ION, |
790 | rom_desc); | 780 | rom_desc); |
791 | 781 | ||
792 | if (!start_address) { | 782 | if (!start_address) { |
793 | dbg("%s - Edge Descriptor not found in I2C", __func__); | 783 | dev_dbg(dev, "%s - Edge Descriptor not found in I2C\n", __func__); |
794 | status = -ENODEV; | 784 | status = -ENODEV; |
795 | goto exit; | 785 | goto exit; |
796 | } | 786 | } |
@@ -804,12 +794,12 @@ static int get_manuf_info(struct edgeport_serial *serial, __u8 *buffer) | |||
804 | status = valid_csum(rom_desc, buffer); | 794 | status = valid_csum(rom_desc, buffer); |
805 | 795 | ||
806 | desc = (struct edge_ti_manuf_descriptor *)buffer; | 796 | desc = (struct edge_ti_manuf_descriptor *)buffer; |
807 | dbg("%s - IonConfig 0x%x", __func__, desc->IonConfig); | 797 | dev_dbg(dev, "%s - IonConfig 0x%x\n", __func__, desc->IonConfig); |
808 | dbg("%s - Version %d", __func__, desc->Version); | 798 | dev_dbg(dev, "%s - Version %d\n", __func__, desc->Version); |
809 | dbg("%s - Cpu/Board 0x%x", __func__, desc->CpuRev_BoardRev); | 799 | dev_dbg(dev, "%s - Cpu/Board 0x%x\n", __func__, desc->CpuRev_BoardRev); |
810 | dbg("%s - NumPorts %d", __func__, desc->NumPorts); | 800 | dev_dbg(dev, "%s - NumPorts %d\n", __func__, desc->NumPorts); |
811 | dbg("%s - NumVirtualPorts %d", __func__, desc->NumVirtualPorts); | 801 | dev_dbg(dev, "%s - NumVirtualPorts %d\n", __func__, desc->NumVirtualPorts); |
812 | dbg("%s - TotalPorts %d", __func__, desc->TotalPorts); | 802 | dev_dbg(dev, "%s - TotalPorts %d\n", __func__, desc->TotalPorts); |
813 | 803 | ||
814 | exit: | 804 | exit: |
815 | kfree(rom_desc); | 805 | kfree(rom_desc); |
@@ -855,8 +845,8 @@ static int build_i2c_fw_hdr(__u8 *header, struct device *dev) | |||
855 | 845 | ||
856 | err = request_firmware(&fw, fw_name, dev); | 846 | err = request_firmware(&fw, fw_name, dev); |
857 | if (err) { | 847 | if (err) { |
858 | printk(KERN_ERR "Failed to load image \"%s\" err %d\n", | 848 | dev_err(dev, "Failed to load image \"%s\" err %d\n", |
859 | fw_name, err); | 849 | fw_name, err); |
860 | kfree(buffer); | 850 | kfree(buffer); |
861 | return err; | 851 | return err; |
862 | } | 852 | } |
@@ -903,13 +893,13 @@ static int build_i2c_fw_hdr(__u8 *header, struct device *dev) | |||
903 | /* Try to figure out what type of I2c we have */ | 893 | /* Try to figure out what type of I2c we have */ |
904 | static int i2c_type_bootmode(struct edgeport_serial *serial) | 894 | static int i2c_type_bootmode(struct edgeport_serial *serial) |
905 | { | 895 | { |
896 | struct device *dev = &serial->serial->dev->dev; | ||
906 | int status; | 897 | int status; |
907 | u8 *data; | 898 | u8 *data; |
908 | 899 | ||
909 | data = kmalloc(1, GFP_KERNEL); | 900 | data = kmalloc(1, GFP_KERNEL); |
910 | if (!data) { | 901 | if (!data) { |
911 | dev_err(&serial->serial->dev->dev, | 902 | dev_err(dev, "%s - out of memory\n", __func__); |
912 | "%s - out of memory\n", __func__); | ||
913 | return -ENOMEM; | 903 | return -ENOMEM; |
914 | } | 904 | } |
915 | 905 | ||
@@ -917,11 +907,11 @@ static int i2c_type_bootmode(struct edgeport_serial *serial) | |||
917 | status = ti_vread_sync(serial->serial->dev, UMPC_MEMORY_READ, | 907 | status = ti_vread_sync(serial->serial->dev, UMPC_MEMORY_READ, |
918 | DTK_ADDR_SPACE_I2C_TYPE_II, 0, data, 0x01); | 908 | DTK_ADDR_SPACE_I2C_TYPE_II, 0, data, 0x01); |
919 | if (status) | 909 | if (status) |
920 | dbg("%s - read 2 status error = %d", __func__, status); | 910 | dev_dbg(dev, "%s - read 2 status error = %d\n", __func__, status); |
921 | else | 911 | else |
922 | dbg("%s - read 2 data = 0x%x", __func__, *data); | 912 | dev_dbg(dev, "%s - read 2 data = 0x%x\n", __func__, *data); |
923 | if ((!status) && (*data == UMP5152 || *data == UMP3410)) { | 913 | if ((!status) && (*data == UMP5152 || *data == UMP3410)) { |
924 | dbg("%s - ROM_TYPE_II", __func__); | 914 | dev_dbg(dev, "%s - ROM_TYPE_II\n", __func__); |
925 | serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_II; | 915 | serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_II; |
926 | goto out; | 916 | goto out; |
927 | } | 917 | } |
@@ -930,16 +920,16 @@ static int i2c_type_bootmode(struct edgeport_serial *serial) | |||
930 | status = ti_vread_sync(serial->serial->dev, UMPC_MEMORY_READ, | 920 | status = ti_vread_sync(serial->serial->dev, UMPC_MEMORY_READ, |
931 | DTK_ADDR_SPACE_I2C_TYPE_III, 0, data, 0x01); | 921 | DTK_ADDR_SPACE_I2C_TYPE_III, 0, data, 0x01); |
932 | if (status) | 922 | if (status) |
933 | dbg("%s - read 3 status error = %d", __func__, status); | 923 | dev_dbg(dev, "%s - read 3 status error = %d\n", __func__, status); |
934 | else | 924 | else |
935 | dbg("%s - read 2 data = 0x%x", __func__, *data); | 925 | dev_dbg(dev, "%s - read 2 data = 0x%x\n", __func__, *data); |
936 | if ((!status) && (*data == UMP5152 || *data == UMP3410)) { | 926 | if ((!status) && (*data == UMP5152 || *data == UMP3410)) { |
937 | dbg("%s - ROM_TYPE_III", __func__); | 927 | dev_dbg(dev, "%s - ROM_TYPE_III\n", __func__); |
938 | serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_III; | 928 | serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_III; |
939 | goto out; | 929 | goto out; |
940 | } | 930 | } |
941 | 931 | ||
942 | dbg("%s - Unknown", __func__); | 932 | dev_dbg(dev, "%s - Unknown\n", __func__); |
943 | serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_II; | 933 | serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_II; |
944 | status = -ENODEV; | 934 | status = -ENODEV; |
945 | out: | 935 | out: |
@@ -1050,11 +1040,11 @@ static int download_fw(struct edgeport_serial *serial) | |||
1050 | if (serial->product_info.TiMode == TI_MODE_DOWNLOAD) { | 1040 | if (serial->product_info.TiMode == TI_MODE_DOWNLOAD) { |
1051 | struct ti_i2c_desc *rom_desc; | 1041 | struct ti_i2c_desc *rom_desc; |
1052 | 1042 | ||
1053 | dbg("%s - RUNNING IN DOWNLOAD MODE", __func__); | 1043 | dev_dbg(dev, "%s - RUNNING IN DOWNLOAD MODE\n", __func__); |
1054 | 1044 | ||
1055 | status = check_i2c_image(serial); | 1045 | status = check_i2c_image(serial); |
1056 | if (status) { | 1046 | if (status) { |
1057 | dbg("%s - DOWNLOAD MODE -- BAD I2C", __func__); | 1047 | dev_dbg(dev, "%s - DOWNLOAD MODE -- BAD I2C\n", __func__); |
1058 | return status; | 1048 | return status; |
1059 | } | 1049 | } |
1060 | 1050 | ||
@@ -1074,7 +1064,7 @@ static int download_fw(struct edgeport_serial *serial) | |||
1074 | 1064 | ||
1075 | /* Check version number of ION descriptor */ | 1065 | /* Check version number of ION descriptor */ |
1076 | if (!ignore_cpu_rev && ti_cpu_rev(ti_manuf_desc) < 2) { | 1066 | if (!ignore_cpu_rev && ti_cpu_rev(ti_manuf_desc) < 2) { |
1077 | dbg("%s - Wrong CPU Rev %d (Must be 2)", | 1067 | dev_dbg(dev, "%s - Wrong CPU Rev %d (Must be 2)\n", |
1078 | __func__, ti_cpu_rev(ti_manuf_desc)); | 1068 | __func__, ti_cpu_rev(ti_manuf_desc)); |
1079 | kfree(ti_manuf_desc); | 1069 | kfree(ti_manuf_desc); |
1080 | return -EINVAL; | 1070 | return -EINVAL; |
@@ -1094,8 +1084,7 @@ static int download_fw(struct edgeport_serial *serial) | |||
1094 | struct ti_i2c_firmware_rec *firmware_version; | 1084 | struct ti_i2c_firmware_rec *firmware_version; |
1095 | u8 *record; | 1085 | u8 *record; |
1096 | 1086 | ||
1097 | dbg("%s - Found Type FIRMWARE (Type 2) record", | 1087 | dev_dbg(dev, "%s - Found Type FIRMWARE (Type 2) record\n", __func__); |
1098 | __func__); | ||
1099 | 1088 | ||
1100 | firmware_version = kmalloc(sizeof(*firmware_version), | 1089 | firmware_version = kmalloc(sizeof(*firmware_version), |
1101 | GFP_KERNEL); | 1090 | GFP_KERNEL); |
@@ -1127,22 +1116,21 @@ static int download_fw(struct edgeport_serial *serial) | |||
1127 | download_new_ver = (OperationalMajorVersion << 8) + | 1116 | download_new_ver = (OperationalMajorVersion << 8) + |
1128 | (OperationalMinorVersion); | 1117 | (OperationalMinorVersion); |
1129 | 1118 | ||
1130 | dbg("%s - >> FW Versions Device %d.%d Driver %d.%d", | 1119 | dev_dbg(dev, "%s - >> FW Versions Device %d.%d Driver %d.%d\n", |
1131 | __func__, | 1120 | __func__, firmware_version->Ver_Major, |
1132 | firmware_version->Ver_Major, | 1121 | firmware_version->Ver_Minor, |
1133 | firmware_version->Ver_Minor, | 1122 | OperationalMajorVersion, |
1134 | OperationalMajorVersion, | 1123 | OperationalMinorVersion); |
1135 | OperationalMinorVersion); | ||
1136 | 1124 | ||
1137 | /* Check if we have an old version in the I2C and | 1125 | /* Check if we have an old version in the I2C and |
1138 | update if necessary */ | 1126 | update if necessary */ |
1139 | if (download_cur_ver < download_new_ver) { | 1127 | if (download_cur_ver < download_new_ver) { |
1140 | dbg("%s - Update I2C dld from %d.%d to %d.%d", | 1128 | dev_dbg(dev, "%s - Update I2C dld from %d.%d to %d.%d\n", |
1141 | __func__, | 1129 | __func__, |
1142 | firmware_version->Ver_Major, | 1130 | firmware_version->Ver_Major, |
1143 | firmware_version->Ver_Minor, | 1131 | firmware_version->Ver_Minor, |
1144 | OperationalMajorVersion, | 1132 | OperationalMajorVersion, |
1145 | OperationalMinorVersion); | 1133 | OperationalMinorVersion); |
1146 | 1134 | ||
1147 | record = kmalloc(1, GFP_KERNEL); | 1135 | record = kmalloc(1, GFP_KERNEL); |
1148 | if (!record) { | 1136 | if (!record) { |
@@ -1196,9 +1184,7 @@ static int download_fw(struct edgeport_serial *serial) | |||
1196 | } | 1184 | } |
1197 | 1185 | ||
1198 | if (*record != I2C_DESC_TYPE_FIRMWARE_BLANK) { | 1186 | if (*record != I2C_DESC_TYPE_FIRMWARE_BLANK) { |
1199 | dev_err(dev, | 1187 | dev_err(dev, "%s - error resetting device\n", __func__); |
1200 | "%s - error resetting device\n", | ||
1201 | __func__); | ||
1202 | kfree(record); | 1188 | kfree(record); |
1203 | kfree(firmware_version); | 1189 | kfree(firmware_version); |
1204 | kfree(rom_desc); | 1190 | kfree(rom_desc); |
@@ -1206,15 +1192,14 @@ static int download_fw(struct edgeport_serial *serial) | |||
1206 | return -ENODEV; | 1192 | return -ENODEV; |
1207 | } | 1193 | } |
1208 | 1194 | ||
1209 | dbg("%s - HARDWARE RESET", __func__); | 1195 | dev_dbg(dev, "%s - HARDWARE RESET\n", __func__); |
1210 | 1196 | ||
1211 | /* Reset UMP -- Back to BOOT MODE */ | 1197 | /* Reset UMP -- Back to BOOT MODE */ |
1212 | status = ti_vsend_sync(serial->serial->dev, | 1198 | status = ti_vsend_sync(serial->serial->dev, |
1213 | UMPC_HARDWARE_RESET, | 1199 | UMPC_HARDWARE_RESET, |
1214 | 0, 0, NULL, 0); | 1200 | 0, 0, NULL, 0); |
1215 | 1201 | ||
1216 | dbg("%s - HARDWARE RESET return %d", | 1202 | dev_dbg(dev, "%s - HARDWARE RESET return %d\n", __func__, status); |
1217 | __func__, status); | ||
1218 | 1203 | ||
1219 | /* return an error on purpose. */ | 1204 | /* return an error on purpose. */ |
1220 | kfree(record); | 1205 | kfree(record); |
@@ -1249,8 +1234,7 @@ static int download_fw(struct edgeport_serial *serial) | |||
1249 | return -ENOMEM; | 1234 | return -ENOMEM; |
1250 | } | 1235 | } |
1251 | 1236 | ||
1252 | dbg("%s - Found Type BLANK FIRMWARE (Type F2) record", | 1237 | dev_dbg(dev, "%s - Found Type BLANK FIRMWARE (Type F2) record\n", __func__); |
1253 | __func__); | ||
1254 | 1238 | ||
1255 | /* | 1239 | /* |
1256 | * In order to update the I2C firmware we must change | 1240 | * In order to update the I2C firmware we must change |
@@ -1292,7 +1276,7 @@ static int download_fw(struct edgeport_serial *serial) | |||
1292 | HEADER_SIZE, vheader); | 1276 | HEADER_SIZE, vheader); |
1293 | 1277 | ||
1294 | if (status) { | 1278 | if (status) { |
1295 | dbg("%s - can't read header back", __func__); | 1279 | dev_dbg(dev, "%s - can't read header back\n", __func__); |
1296 | kfree(vheader); | 1280 | kfree(vheader); |
1297 | kfree(header); | 1281 | kfree(header); |
1298 | kfree(rom_desc); | 1282 | kfree(rom_desc); |
@@ -1300,8 +1284,7 @@ static int download_fw(struct edgeport_serial *serial) | |||
1300 | return status; | 1284 | return status; |
1301 | } | 1285 | } |
1302 | if (memcmp(vheader, header, HEADER_SIZE)) { | 1286 | if (memcmp(vheader, header, HEADER_SIZE)) { |
1303 | dbg("%s - write download record failed", | 1287 | dev_dbg(dev, "%s - write download record failed\n", __func__); |
1304 | __func__); | ||
1305 | kfree(vheader); | 1288 | kfree(vheader); |
1306 | kfree(header); | 1289 | kfree(header); |
1307 | kfree(rom_desc); | 1290 | kfree(rom_desc); |
@@ -1312,13 +1295,13 @@ static int download_fw(struct edgeport_serial *serial) | |||
1312 | kfree(vheader); | 1295 | kfree(vheader); |
1313 | kfree(header); | 1296 | kfree(header); |
1314 | 1297 | ||
1315 | dbg("%s - Start firmware update", __func__); | 1298 | dev_dbg(dev, "%s - Start firmware update\n", __func__); |
1316 | 1299 | ||
1317 | /* Tell firmware to copy download image into I2C */ | 1300 | /* Tell firmware to copy download image into I2C */ |
1318 | status = ti_vsend_sync(serial->serial->dev, | 1301 | status = ti_vsend_sync(serial->serial->dev, |
1319 | UMPC_COPY_DNLD_TO_I2C, 0, 0, NULL, 0); | 1302 | UMPC_COPY_DNLD_TO_I2C, 0, 0, NULL, 0); |
1320 | 1303 | ||
1321 | dbg("%s - Update complete 0x%x", __func__, status); | 1304 | dev_dbg(dev, "%s - Update complete 0x%x\n", __func__, status); |
1322 | if (status) { | 1305 | if (status) { |
1323 | dev_err(dev, | 1306 | dev_err(dev, |
1324 | "%s - UMPC_COPY_DNLD_TO_I2C failed\n", | 1307 | "%s - UMPC_COPY_DNLD_TO_I2C failed\n", |
@@ -1338,7 +1321,7 @@ static int download_fw(struct edgeport_serial *serial) | |||
1338 | /********************************************************************/ | 1321 | /********************************************************************/ |
1339 | /* Boot Mode */ | 1322 | /* Boot Mode */ |
1340 | /********************************************************************/ | 1323 | /********************************************************************/ |
1341 | dbg("%s - RUNNING IN BOOT MODE", __func__); | 1324 | dev_dbg(dev, "%s - RUNNING IN BOOT MODE\n", __func__); |
1342 | 1325 | ||
1343 | /* Configure the TI device so we can use the BULK pipes for download */ | 1326 | /* Configure the TI device so we can use the BULK pipes for download */ |
1344 | status = config_boot_dev(serial->serial->dev); | 1327 | status = config_boot_dev(serial->serial->dev); |
@@ -1347,8 +1330,8 @@ static int download_fw(struct edgeport_serial *serial) | |||
1347 | 1330 | ||
1348 | if (le16_to_cpu(serial->serial->dev->descriptor.idVendor) | 1331 | if (le16_to_cpu(serial->serial->dev->descriptor.idVendor) |
1349 | != USB_VENDOR_ID_ION) { | 1332 | != USB_VENDOR_ID_ION) { |
1350 | dbg("%s - VID = 0x%x", __func__, | 1333 | dev_dbg(dev, "%s - VID = 0x%x\n", __func__, |
1351 | le16_to_cpu(serial->serial->dev->descriptor.idVendor)); | 1334 | le16_to_cpu(serial->serial->dev->descriptor.idVendor)); |
1352 | serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_II; | 1335 | serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_II; |
1353 | goto stayinbootmode; | 1336 | goto stayinbootmode; |
1354 | } | 1337 | } |
@@ -1385,8 +1368,8 @@ static int download_fw(struct edgeport_serial *serial) | |||
1385 | 1368 | ||
1386 | /* Check for version 2 */ | 1369 | /* Check for version 2 */ |
1387 | if (!ignore_cpu_rev && ti_cpu_rev(ti_manuf_desc) < 2) { | 1370 | if (!ignore_cpu_rev && ti_cpu_rev(ti_manuf_desc) < 2) { |
1388 | dbg("%s - Wrong CPU Rev %d (Must be 2)", | 1371 | dev_dbg(dev, "%s - Wrong CPU Rev %d (Must be 2)\n", |
1389 | __func__, ti_cpu_rev(ti_manuf_desc)); | 1372 | __func__, ti_cpu_rev(ti_manuf_desc)); |
1390 | kfree(ti_manuf_desc); | 1373 | kfree(ti_manuf_desc); |
1391 | goto stayinbootmode; | 1374 | goto stayinbootmode; |
1392 | } | 1375 | } |
@@ -1421,8 +1404,8 @@ static int download_fw(struct edgeport_serial *serial) | |||
1421 | 1404 | ||
1422 | err = request_firmware(&fw, fw_name, dev); | 1405 | err = request_firmware(&fw, fw_name, dev); |
1423 | if (err) { | 1406 | if (err) { |
1424 | printk(KERN_ERR "Failed to load image \"%s\" err %d\n", | 1407 | dev_err(dev, "Failed to load image \"%s\" err %d\n", |
1425 | fw_name, err); | 1408 | fw_name, err); |
1426 | kfree(buffer); | 1409 | kfree(buffer); |
1427 | return err; | 1410 | return err; |
1428 | } | 1411 | } |
@@ -1442,23 +1425,20 @@ static int download_fw(struct edgeport_serial *serial) | |||
1442 | header->CheckSum = cs; | 1425 | header->CheckSum = cs; |
1443 | 1426 | ||
1444 | /* Download the operational code */ | 1427 | /* Download the operational code */ |
1445 | dbg("%s - Downloading operational code image (TI UMP)", | 1428 | dev_dbg(dev, "%s - Downloading operational code image (TI UMP)\n", __func__); |
1446 | __func__); | ||
1447 | status = download_code(serial, buffer, buffer_size); | 1429 | status = download_code(serial, buffer, buffer_size); |
1448 | 1430 | ||
1449 | kfree(buffer); | 1431 | kfree(buffer); |
1450 | 1432 | ||
1451 | if (status) { | 1433 | if (status) { |
1452 | dbg("%s - Error downloading operational code image", | 1434 | dev_dbg(dev, "%s - Error downloading operational code image\n", __func__); |
1453 | __func__); | ||
1454 | return status; | 1435 | return status; |
1455 | } | 1436 | } |
1456 | 1437 | ||
1457 | /* Device will reboot */ | 1438 | /* Device will reboot */ |
1458 | serial->product_info.TiMode = TI_MODE_TRANSITIONING; | 1439 | serial->product_info.TiMode = TI_MODE_TRANSITIONING; |
1459 | 1440 | ||
1460 | dbg("%s - Download successful -- Device rebooting...", | 1441 | dev_dbg(dev, "%s - Download successful -- Device rebooting...\n", __func__); |
1461 | __func__); | ||
1462 | 1442 | ||
1463 | /* return an error on purpose */ | 1443 | /* return an error on purpose */ |
1464 | return -ENODEV; | 1444 | return -ENODEV; |
@@ -1466,7 +1446,7 @@ static int download_fw(struct edgeport_serial *serial) | |||
1466 | 1446 | ||
1467 | stayinbootmode: | 1447 | stayinbootmode: |
1468 | /* Eprom is invalid or blank stay in boot mode */ | 1448 | /* Eprom is invalid or blank stay in boot mode */ |
1469 | dbg("%s - STAYING IN BOOT MODE", __func__); | 1449 | dev_dbg(dev, "%s - STAYING IN BOOT MODE\n", __func__); |
1470 | serial->product_info.TiMode = TI_MODE_BOOT; | 1450 | serial->product_info.TiMode = TI_MODE_BOOT; |
1471 | 1451 | ||
1472 | return 0; | 1452 | return 0; |
@@ -1487,7 +1467,7 @@ static int restore_mcr(struct edgeport_port *port, __u8 mcr) | |||
1487 | { | 1467 | { |
1488 | int status = 0; | 1468 | int status = 0; |
1489 | 1469 | ||
1490 | dbg("%s - %x", __func__, mcr); | 1470 | dev_dbg(&port->port->dev, "%s - %x\n", __func__, mcr); |
1491 | 1471 | ||
1492 | status = ti_do_config(port, UMPC_SET_CLR_DTR, mcr & MCR_DTR); | 1472 | status = ti_do_config(port, UMPC_SET_CLR_DTR, mcr & MCR_DTR); |
1493 | if (status) | 1473 | if (status) |
@@ -1524,7 +1504,7 @@ static void handle_new_msr(struct edgeport_port *edge_port, __u8 msr) | |||
1524 | struct async_icount *icount; | 1504 | struct async_icount *icount; |
1525 | struct tty_struct *tty; | 1505 | struct tty_struct *tty; |
1526 | 1506 | ||
1527 | dbg("%s - %02x", __func__, msr); | 1507 | dev_dbg(&edge_port->port->dev, "%s - %02x\n", __func__, msr); |
1528 | 1508 | ||
1529 | if (msr & (EDGEPORT_MSR_DELTA_CTS | EDGEPORT_MSR_DELTA_DSR | | 1509 | if (msr & (EDGEPORT_MSR_DELTA_CTS | EDGEPORT_MSR_DELTA_DSR | |
1530 | EDGEPORT_MSR_DELTA_RI | EDGEPORT_MSR_DELTA_CD)) { | 1510 | EDGEPORT_MSR_DELTA_RI | EDGEPORT_MSR_DELTA_CD)) { |
@@ -1566,7 +1546,7 @@ static void handle_new_lsr(struct edgeport_port *edge_port, int lsr_data, | |||
1566 | LSR_FRM_ERR | LSR_BREAK)); | 1546 | LSR_FRM_ERR | LSR_BREAK)); |
1567 | struct tty_struct *tty; | 1547 | struct tty_struct *tty; |
1568 | 1548 | ||
1569 | dbg("%s - %02x", __func__, new_lsr); | 1549 | dev_dbg(&edge_port->port->dev, "%s - %02x\n", __func__, new_lsr); |
1570 | 1550 | ||
1571 | edge_port->shadow_lsr = lsr; | 1551 | edge_port->shadow_lsr = lsr; |
1572 | 1552 | ||
@@ -1604,6 +1584,7 @@ static void edge_interrupt_callback(struct urb *urb) | |||
1604 | struct edgeport_serial *edge_serial = urb->context; | 1584 | struct edgeport_serial *edge_serial = urb->context; |
1605 | struct usb_serial_port *port; | 1585 | struct usb_serial_port *port; |
1606 | struct edgeport_port *edge_port; | 1586 | struct edgeport_port *edge_port; |
1587 | struct device *dev; | ||
1607 | unsigned char *data = urb->transfer_buffer; | 1588 | unsigned char *data = urb->transfer_buffer; |
1608 | int length = urb->actual_length; | 1589 | int length = urb->actual_length; |
1609 | int port_number; | 1590 | int port_number; |
@@ -1613,8 +1594,6 @@ static void edge_interrupt_callback(struct urb *urb) | |||
1613 | __u8 msr; | 1594 | __u8 msr; |
1614 | int status = urb->status; | 1595 | int status = urb->status; |
1615 | 1596 | ||
1616 | dbg("%s", __func__); | ||
1617 | |||
1618 | switch (status) { | 1597 | switch (status) { |
1619 | case 0: | 1598 | case 0: |
1620 | /* success */ | 1599 | /* success */ |
@@ -1623,7 +1602,7 @@ static void edge_interrupt_callback(struct urb *urb) | |||
1623 | case -ENOENT: | 1602 | case -ENOENT: |
1624 | case -ESHUTDOWN: | 1603 | case -ESHUTDOWN: |
1625 | /* this urb is terminated, clean up */ | 1604 | /* this urb is terminated, clean up */ |
1626 | dbg("%s - urb shutting down with status: %d", | 1605 | dev_dbg(&urb->dev->dev, "%s - urb shutting down with status: %d\n", |
1627 | __func__, status); | 1606 | __func__, status); |
1628 | return; | 1607 | return; |
1629 | default: | 1608 | default: |
@@ -1633,27 +1612,26 @@ static void edge_interrupt_callback(struct urb *urb) | |||
1633 | } | 1612 | } |
1634 | 1613 | ||
1635 | if (!length) { | 1614 | if (!length) { |
1636 | dbg("%s - no data in urb", __func__); | 1615 | dev_dbg(&urb->dev->dev, "%s - no data in urb\n", __func__); |
1637 | goto exit; | 1616 | goto exit; |
1638 | } | 1617 | } |
1639 | 1618 | ||
1640 | usb_serial_debug_data(debug, &edge_serial->serial->dev->dev, | 1619 | dev = &edge_serial->serial->dev->dev; |
1641 | __func__, length, data); | 1620 | usb_serial_debug_data(dev, __func__, length, data); |
1642 | 1621 | ||
1643 | if (length != 2) { | 1622 | if (length != 2) { |
1644 | dbg("%s - expecting packet of size 2, got %d", | 1623 | dev_dbg(dev, "%s - expecting packet of size 2, got %d\n", __func__, length); |
1645 | __func__, length); | ||
1646 | goto exit; | 1624 | goto exit; |
1647 | } | 1625 | } |
1648 | 1626 | ||
1649 | port_number = TIUMP_GET_PORT_FROM_CODE(data[0]); | 1627 | port_number = TIUMP_GET_PORT_FROM_CODE(data[0]); |
1650 | function = TIUMP_GET_FUNC_FROM_CODE(data[0]); | 1628 | function = TIUMP_GET_FUNC_FROM_CODE(data[0]); |
1651 | dbg("%s - port_number %d, function %d, info 0x%x", | 1629 | dev_dbg(dev, "%s - port_number %d, function %d, info 0x%x\n", __func__, |
1652 | __func__, port_number, function, data[1]); | 1630 | port_number, function, data[1]); |
1653 | port = edge_serial->serial->port[port_number]; | 1631 | port = edge_serial->serial->port[port_number]; |
1654 | edge_port = usb_get_serial_port_data(port); | 1632 | edge_port = usb_get_serial_port_data(port); |
1655 | if (!edge_port) { | 1633 | if (!edge_port) { |
1656 | dbg("%s - edge_port not found", __func__); | 1634 | dev_dbg(dev, "%s - edge_port not found\n", __func__); |
1657 | return; | 1635 | return; |
1658 | } | 1636 | } |
1659 | switch (function) { | 1637 | switch (function) { |
@@ -1662,13 +1640,13 @@ static void edge_interrupt_callback(struct urb *urb) | |||
1662 | if (lsr & UMP_UART_LSR_DATA_MASK) { | 1640 | if (lsr & UMP_UART_LSR_DATA_MASK) { |
1663 | /* Save the LSR event for bulk read | 1641 | /* Save the LSR event for bulk read |
1664 | completion routine */ | 1642 | completion routine */ |
1665 | dbg("%s - LSR Event Port %u LSR Status = %02x", | 1643 | dev_dbg(dev, "%s - LSR Event Port %u LSR Status = %02x\n", |
1666 | __func__, port_number, lsr); | 1644 | __func__, port_number, lsr); |
1667 | edge_port->lsr_event = 1; | 1645 | edge_port->lsr_event = 1; |
1668 | edge_port->lsr_mask = lsr; | 1646 | edge_port->lsr_mask = lsr; |
1669 | } else { | 1647 | } else { |
1670 | dbg("%s - ===== Port %d LSR Status = %02x ======", | 1648 | dev_dbg(dev, "%s - ===== Port %d LSR Status = %02x ======\n", |
1671 | __func__, port_number, lsr); | 1649 | __func__, port_number, lsr); |
1672 | handle_new_lsr(edge_port, 0, lsr, 0); | 1650 | handle_new_lsr(edge_port, 0, lsr, 0); |
1673 | } | 1651 | } |
1674 | break; | 1652 | break; |
@@ -1676,8 +1654,8 @@ static void edge_interrupt_callback(struct urb *urb) | |||
1676 | case TIUMP_INTERRUPT_CODE_MSR: /* MSR */ | 1654 | case TIUMP_INTERRUPT_CODE_MSR: /* MSR */ |
1677 | /* Copy MSR from UMP */ | 1655 | /* Copy MSR from UMP */ |
1678 | msr = data[1]; | 1656 | msr = data[1]; |
1679 | dbg("%s - ===== Port %u MSR Status = %02x ======", | 1657 | dev_dbg(dev, "%s - ===== Port %u MSR Status = %02x ======\n", |
1680 | __func__, port_number, msr); | 1658 | __func__, port_number, msr); |
1681 | handle_new_msr(edge_port, msr); | 1659 | handle_new_msr(edge_port, msr); |
1682 | break; | 1660 | break; |
1683 | 1661 | ||
@@ -1700,14 +1678,13 @@ exit: | |||
1700 | static void edge_bulk_in_callback(struct urb *urb) | 1678 | static void edge_bulk_in_callback(struct urb *urb) |
1701 | { | 1679 | { |
1702 | struct edgeport_port *edge_port = urb->context; | 1680 | struct edgeport_port *edge_port = urb->context; |
1681 | struct device *dev = &edge_port->port->dev; | ||
1703 | unsigned char *data = urb->transfer_buffer; | 1682 | unsigned char *data = urb->transfer_buffer; |
1704 | struct tty_struct *tty; | 1683 | struct tty_struct *tty; |
1705 | int retval = 0; | 1684 | int retval = 0; |
1706 | int port_number; | 1685 | int port_number; |
1707 | int status = urb->status; | 1686 | int status = urb->status; |
1708 | 1687 | ||
1709 | dbg("%s", __func__); | ||
1710 | |||
1711 | switch (status) { | 1688 | switch (status) { |
1712 | case 0: | 1689 | case 0: |
1713 | /* success */ | 1690 | /* success */ |
@@ -1716,13 +1693,10 @@ static void edge_bulk_in_callback(struct urb *urb) | |||
1716 | case -ENOENT: | 1693 | case -ENOENT: |
1717 | case -ESHUTDOWN: | 1694 | case -ESHUTDOWN: |
1718 | /* this urb is terminated, clean up */ | 1695 | /* this urb is terminated, clean up */ |
1719 | dbg("%s - urb shutting down with status: %d", | 1696 | dev_dbg(&urb->dev->dev, "%s - urb shutting down with status: %d\n", __func__, status); |
1720 | __func__, status); | ||
1721 | return; | 1697 | return; |
1722 | default: | 1698 | default: |
1723 | dev_err(&urb->dev->dev, | 1699 | dev_err(&urb->dev->dev, "%s - nonzero read bulk status received: %d\n", __func__, status); |
1724 | "%s - nonzero read bulk status received: %d\n", | ||
1725 | __func__, status); | ||
1726 | } | 1700 | } |
1727 | 1701 | ||
1728 | if (status == -EPIPE) | 1702 | if (status == -EPIPE) |
@@ -1737,8 +1711,8 @@ static void edge_bulk_in_callback(struct urb *urb) | |||
1737 | 1711 | ||
1738 | if (edge_port->lsr_event) { | 1712 | if (edge_port->lsr_event) { |
1739 | edge_port->lsr_event = 0; | 1713 | edge_port->lsr_event = 0; |
1740 | dbg("%s ===== Port %u LSR Status = %02x, Data = %02x ======", | 1714 | dev_dbg(dev, "%s ===== Port %u LSR Status = %02x, Data = %02x ======\n", |
1741 | __func__, port_number, edge_port->lsr_mask, *data); | 1715 | __func__, port_number, edge_port->lsr_mask, *data); |
1742 | handle_new_lsr(edge_port, 1, edge_port->lsr_mask, *data); | 1716 | handle_new_lsr(edge_port, 1, edge_port->lsr_mask, *data); |
1743 | /* Adjust buffer length/pointer */ | 1717 | /* Adjust buffer length/pointer */ |
1744 | --urb->actual_length; | 1718 | --urb->actual_length; |
@@ -1747,14 +1721,12 @@ static void edge_bulk_in_callback(struct urb *urb) | |||
1747 | 1721 | ||
1748 | tty = tty_port_tty_get(&edge_port->port->port); | 1722 | tty = tty_port_tty_get(&edge_port->port->port); |
1749 | if (tty && urb->actual_length) { | 1723 | if (tty && urb->actual_length) { |
1750 | usb_serial_debug_data(debug, &edge_port->port->dev, | 1724 | usb_serial_debug_data(dev, __func__, urb->actual_length, data); |
1751 | __func__, urb->actual_length, data); | ||
1752 | if (edge_port->close_pending) | 1725 | if (edge_port->close_pending) |
1753 | dbg("%s - close pending, dropping data on the floor", | 1726 | dev_dbg(dev, "%s - close pending, dropping data on the floor\n", |
1754 | __func__); | 1727 | __func__); |
1755 | else | 1728 | else |
1756 | edge_tty_recv(&edge_port->port->dev, tty, data, | 1729 | edge_tty_recv(dev, tty, data, urb->actual_length); |
1757 | urb->actual_length); | ||
1758 | edge_port->icount.rx += urb->actual_length; | 1730 | edge_port->icount.rx += urb->actual_length; |
1759 | } | 1731 | } |
1760 | tty_kref_put(tty); | 1732 | tty_kref_put(tty); |
@@ -1769,9 +1741,7 @@ exit: | |||
1769 | 1741 | ||
1770 | spin_unlock(&edge_port->ep_lock); | 1742 | spin_unlock(&edge_port->ep_lock); |
1771 | if (retval) | 1743 | if (retval) |
1772 | dev_err(&urb->dev->dev, | 1744 | dev_err(dev, "%s - usb_submit_urb failed with result %d\n", __func__, retval); |
1773 | "%s - usb_submit_urb failed with result %d\n", | ||
1774 | __func__, retval); | ||
1775 | } | 1745 | } |
1776 | 1746 | ||
1777 | static void edge_tty_recv(struct device *dev, struct tty_struct *tty, | 1747 | static void edge_tty_recv(struct device *dev, struct tty_struct *tty, |
@@ -1793,8 +1763,6 @@ static void edge_bulk_out_callback(struct urb *urb) | |||
1793 | int status = urb->status; | 1763 | int status = urb->status; |
1794 | struct tty_struct *tty; | 1764 | struct tty_struct *tty; |
1795 | 1765 | ||
1796 | dbg("%s - port %d", __func__, port->number); | ||
1797 | |||
1798 | edge_port->ep_write_urb_in_use = 0; | 1766 | edge_port->ep_write_urb_in_use = 0; |
1799 | 1767 | ||
1800 | switch (status) { | 1768 | switch (status) { |
@@ -1805,7 +1773,7 @@ static void edge_bulk_out_callback(struct urb *urb) | |||
1805 | case -ENOENT: | 1773 | case -ENOENT: |
1806 | case -ESHUTDOWN: | 1774 | case -ESHUTDOWN: |
1807 | /* this urb is terminated, clean up */ | 1775 | /* this urb is terminated, clean up */ |
1808 | dbg("%s - urb shutting down with status: %d", | 1776 | dev_dbg(&urb->dev->dev, "%s - urb shutting down with status: %d\n", |
1809 | __func__, status); | 1777 | __func__, status); |
1810 | return; | 1778 | return; |
1811 | default: | 1779 | default: |
@@ -1830,8 +1798,6 @@ static int edge_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
1830 | u16 open_settings; | 1798 | u16 open_settings; |
1831 | u8 transaction_timeout; | 1799 | u8 transaction_timeout; |
1832 | 1800 | ||
1833 | dbg("%s - port %d", __func__, port->number); | ||
1834 | |||
1835 | if (edge_port == NULL) | 1801 | if (edge_port == NULL) |
1836 | return -ENODEV; | 1802 | return -ENODEV; |
1837 | 1803 | ||
@@ -1850,9 +1816,8 @@ static int edge_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
1850 | return -ENODEV; | 1816 | return -ENODEV; |
1851 | } | 1817 | } |
1852 | 1818 | ||
1853 | dbg("%s - port_number = %d, uart_base = %04x, dma_address = %04x", | 1819 | dev_dbg(&port->dev, "%s - port_number = %d, uart_base = %04x, dma_address = %04x\n", |
1854 | __func__, port_number, edge_port->uart_base, | 1820 | __func__, port_number, edge_port->uart_base, edge_port->dma_address); |
1855 | edge_port->dma_address); | ||
1856 | 1821 | ||
1857 | dev = port->serial->dev; | 1822 | dev = port->serial->dev; |
1858 | 1823 | ||
@@ -1885,7 +1850,7 @@ static int edge_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
1885 | UMP_PIPE_TRANS_TIMEOUT_ENA | | 1850 | UMP_PIPE_TRANS_TIMEOUT_ENA | |
1886 | (transaction_timeout << 2)); | 1851 | (transaction_timeout << 2)); |
1887 | 1852 | ||
1888 | dbg("%s - Sending UMPC_OPEN_PORT", __func__); | 1853 | dev_dbg(&port->dev, "%s - Sending UMPC_OPEN_PORT\n", __func__); |
1889 | 1854 | ||
1890 | /* Tell TI to open and start the port */ | 1855 | /* Tell TI to open and start the port */ |
1891 | status = send_cmd(dev, UMPC_OPEN_PORT, | 1856 | status = send_cmd(dev, UMPC_OPEN_PORT, |
@@ -1924,11 +1889,11 @@ static int edge_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
1924 | return status; | 1889 | return status; |
1925 | } | 1890 | } |
1926 | 1891 | ||
1927 | dbg("ShadowMSR 0x%X", edge_port->shadow_msr); | 1892 | dev_dbg(&port->dev, "ShadowMSR 0x%X\n", edge_port->shadow_msr); |
1928 | 1893 | ||
1929 | /* Set Initial MCR */ | 1894 | /* Set Initial MCR */ |
1930 | edge_port->shadow_mcr = MCR_RTS | MCR_DTR; | 1895 | edge_port->shadow_mcr = MCR_RTS | MCR_DTR; |
1931 | dbg("ShadowMCR 0x%X", edge_port->shadow_mcr); | 1896 | dev_dbg(&port->dev, "ShadowMCR 0x%X\n", edge_port->shadow_mcr); |
1932 | 1897 | ||
1933 | edge_serial = edge_port->edge_serial; | 1898 | edge_serial = edge_port->edge_serial; |
1934 | if (mutex_lock_interruptible(&edge_serial->es_lock)) | 1899 | if (mutex_lock_interruptible(&edge_serial->es_lock)) |
@@ -1980,8 +1945,6 @@ static int edge_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
1980 | 1945 | ||
1981 | ++edge_serial->num_ports_open; | 1946 | ++edge_serial->num_ports_open; |
1982 | 1947 | ||
1983 | dbg("%s - exited", __func__); | ||
1984 | |||
1985 | goto release_es_lock; | 1948 | goto release_es_lock; |
1986 | 1949 | ||
1987 | unlink_int_urb: | 1950 | unlink_int_urb: |
@@ -1999,8 +1962,6 @@ static void edge_close(struct usb_serial_port *port) | |||
1999 | struct usb_serial *serial = port->serial; | 1962 | struct usb_serial *serial = port->serial; |
2000 | int port_number; | 1963 | int port_number; |
2001 | 1964 | ||
2002 | dbg("%s - port %d", __func__, port->number); | ||
2003 | |||
2004 | edge_serial = usb_get_serial_data(port->serial); | 1965 | edge_serial = usb_get_serial_data(port->serial); |
2005 | edge_port = usb_get_serial_port_data(port); | 1966 | edge_port = usb_get_serial_port_data(port); |
2006 | if (edge_serial == NULL || edge_port == NULL) | 1967 | if (edge_serial == NULL || edge_port == NULL) |
@@ -2019,7 +1980,7 @@ static void edge_close(struct usb_serial_port *port) | |||
2019 | 1980 | ||
2020 | /* assuming we can still talk to the device, | 1981 | /* assuming we can still talk to the device, |
2021 | * send a close port command to it */ | 1982 | * send a close port command to it */ |
2022 | dbg("%s - send umpc_close_port", __func__); | 1983 | dev_dbg(&port->dev, "%s - send umpc_close_port\n", __func__); |
2023 | port_number = port->number - port->serial->minor; | 1984 | port_number = port->number - port->serial->minor; |
2024 | 1985 | ||
2025 | mutex_lock(&serial->disc_mutex); | 1986 | mutex_lock(&serial->disc_mutex); |
@@ -2042,8 +2003,6 @@ static void edge_close(struct usb_serial_port *port) | |||
2042 | } | 2003 | } |
2043 | mutex_unlock(&edge_serial->es_lock); | 2004 | mutex_unlock(&edge_serial->es_lock); |
2044 | edge_port->close_pending = 0; | 2005 | edge_port->close_pending = 0; |
2045 | |||
2046 | dbg("%s - exited", __func__); | ||
2047 | } | 2006 | } |
2048 | 2007 | ||
2049 | static int edge_write(struct tty_struct *tty, struct usb_serial_port *port, | 2008 | static int edge_write(struct tty_struct *tty, struct usb_serial_port *port, |
@@ -2051,10 +2010,8 @@ static int edge_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
2051 | { | 2010 | { |
2052 | struct edgeport_port *edge_port = usb_get_serial_port_data(port); | 2011 | struct edgeport_port *edge_port = usb_get_serial_port_data(port); |
2053 | 2012 | ||
2054 | dbg("%s - port %d", __func__, port->number); | ||
2055 | |||
2056 | if (count == 0) { | 2013 | if (count == 0) { |
2057 | dbg("%s - write request of 0 bytes", __func__); | 2014 | dev_dbg(&port->dev, "%s - write request of 0 bytes\n", __func__); |
2058 | return 0; | 2015 | return 0; |
2059 | } | 2016 | } |
2060 | 2017 | ||
@@ -2077,9 +2034,6 @@ static void edge_send(struct tty_struct *tty) | |||
2077 | struct edgeport_port *edge_port = usb_get_serial_port_data(port); | 2034 | struct edgeport_port *edge_port = usb_get_serial_port_data(port); |
2078 | unsigned long flags; | 2035 | unsigned long flags; |
2079 | 2036 | ||
2080 | |||
2081 | dbg("%s - port %d", __func__, port->number); | ||
2082 | |||
2083 | spin_lock_irqsave(&edge_port->ep_lock, flags); | 2037 | spin_lock_irqsave(&edge_port->ep_lock, flags); |
2084 | 2038 | ||
2085 | if (edge_port->ep_write_urb_in_use) { | 2039 | if (edge_port->ep_write_urb_in_use) { |
@@ -2100,8 +2054,7 @@ static void edge_send(struct tty_struct *tty) | |||
2100 | 2054 | ||
2101 | spin_unlock_irqrestore(&edge_port->ep_lock, flags); | 2055 | spin_unlock_irqrestore(&edge_port->ep_lock, flags); |
2102 | 2056 | ||
2103 | usb_serial_debug_data(debug, &port->dev, __func__, count, | 2057 | usb_serial_debug_data(&port->dev, __func__, count, port->write_urb->transfer_buffer); |
2104 | port->write_urb->transfer_buffer); | ||
2105 | 2058 | ||
2106 | /* set up our urb */ | 2059 | /* set up our urb */ |
2107 | port->write_urb->transfer_buffer_length = count; | 2060 | port->write_urb->transfer_buffer_length = count; |
@@ -2130,8 +2083,6 @@ static int edge_write_room(struct tty_struct *tty) | |||
2130 | int room = 0; | 2083 | int room = 0; |
2131 | unsigned long flags; | 2084 | unsigned long flags; |
2132 | 2085 | ||
2133 | dbg("%s - port %d", __func__, port->number); | ||
2134 | |||
2135 | if (edge_port == NULL) | 2086 | if (edge_port == NULL) |
2136 | return 0; | 2087 | return 0; |
2137 | if (edge_port->close_pending == 1) | 2088 | if (edge_port->close_pending == 1) |
@@ -2141,7 +2092,7 @@ static int edge_write_room(struct tty_struct *tty) | |||
2141 | room = kfifo_avail(&edge_port->write_fifo); | 2092 | room = kfifo_avail(&edge_port->write_fifo); |
2142 | spin_unlock_irqrestore(&edge_port->ep_lock, flags); | 2093 | spin_unlock_irqrestore(&edge_port->ep_lock, flags); |
2143 | 2094 | ||
2144 | dbg("%s - returns %d", __func__, room); | 2095 | dev_dbg(&port->dev, "%s - returns %d\n", __func__, room); |
2145 | return room; | 2096 | return room; |
2146 | } | 2097 | } |
2147 | 2098 | ||
@@ -2152,8 +2103,6 @@ static int edge_chars_in_buffer(struct tty_struct *tty) | |||
2152 | int chars = 0; | 2103 | int chars = 0; |
2153 | unsigned long flags; | 2104 | unsigned long flags; |
2154 | 2105 | ||
2155 | dbg("%s - port %d", __func__, port->number); | ||
2156 | |||
2157 | if (edge_port == NULL) | 2106 | if (edge_port == NULL) |
2158 | return 0; | 2107 | return 0; |
2159 | if (edge_port->close_pending == 1) | 2108 | if (edge_port->close_pending == 1) |
@@ -2163,7 +2112,7 @@ static int edge_chars_in_buffer(struct tty_struct *tty) | |||
2163 | chars = kfifo_len(&edge_port->write_fifo); | 2112 | chars = kfifo_len(&edge_port->write_fifo); |
2164 | spin_unlock_irqrestore(&edge_port->ep_lock, flags); | 2113 | spin_unlock_irqrestore(&edge_port->ep_lock, flags); |
2165 | 2114 | ||
2166 | dbg("%s - returns %d", __func__, chars); | 2115 | dev_dbg(&port->dev, "%s - returns %d\n", __func__, chars); |
2167 | return chars; | 2116 | return chars; |
2168 | } | 2117 | } |
2169 | 2118 | ||
@@ -2173,8 +2122,6 @@ static void edge_throttle(struct tty_struct *tty) | |||
2173 | struct edgeport_port *edge_port = usb_get_serial_port_data(port); | 2122 | struct edgeport_port *edge_port = usb_get_serial_port_data(port); |
2174 | int status; | 2123 | int status; |
2175 | 2124 | ||
2176 | dbg("%s - port %d", __func__, port->number); | ||
2177 | |||
2178 | if (edge_port == NULL) | 2125 | if (edge_port == NULL) |
2179 | return; | 2126 | return; |
2180 | 2127 | ||
@@ -2200,8 +2147,6 @@ static void edge_unthrottle(struct tty_struct *tty) | |||
2200 | struct edgeport_port *edge_port = usb_get_serial_port_data(port); | 2147 | struct edgeport_port *edge_port = usb_get_serial_port_data(port); |
2201 | int status; | 2148 | int status; |
2202 | 2149 | ||
2203 | dbg("%s - port %d", __func__, port->number); | ||
2204 | |||
2205 | if (edge_port == NULL) | 2150 | if (edge_port == NULL) |
2206 | return; | 2151 | return; |
2207 | 2152 | ||
@@ -2261,6 +2206,7 @@ static int restart_read(struct edgeport_port *edge_port) | |||
2261 | static void change_port_settings(struct tty_struct *tty, | 2206 | static void change_port_settings(struct tty_struct *tty, |
2262 | struct edgeport_port *edge_port, struct ktermios *old_termios) | 2207 | struct edgeport_port *edge_port, struct ktermios *old_termios) |
2263 | { | 2208 | { |
2209 | struct device *dev = &edge_port->port->dev; | ||
2264 | struct ump_uart_config *config; | 2210 | struct ump_uart_config *config; |
2265 | int baud; | 2211 | int baud; |
2266 | unsigned cflag; | 2212 | unsigned cflag; |
@@ -2268,13 +2214,12 @@ static void change_port_settings(struct tty_struct *tty, | |||
2268 | int port_number = edge_port->port->number - | 2214 | int port_number = edge_port->port->number - |
2269 | edge_port->port->serial->minor; | 2215 | edge_port->port->serial->minor; |
2270 | 2216 | ||
2271 | dbg("%s - port %d", __func__, edge_port->port->number); | 2217 | dev_dbg(dev, "%s - port %d\n", __func__, edge_port->port->number); |
2272 | 2218 | ||
2273 | config = kmalloc (sizeof (*config), GFP_KERNEL); | 2219 | config = kmalloc (sizeof (*config), GFP_KERNEL); |
2274 | if (!config) { | 2220 | if (!config) { |
2275 | tty->termios = *old_termios; | 2221 | tty->termios = *old_termios; |
2276 | dev_err(&edge_port->port->dev, "%s - out of memory\n", | 2222 | dev_err(dev, "%s - out of memory\n", __func__); |
2277 | __func__); | ||
2278 | return; | 2223 | return; |
2279 | } | 2224 | } |
2280 | 2225 | ||
@@ -2290,20 +2235,20 @@ static void change_port_settings(struct tty_struct *tty, | |||
2290 | switch (cflag & CSIZE) { | 2235 | switch (cflag & CSIZE) { |
2291 | case CS5: | 2236 | case CS5: |
2292 | config->bDataBits = UMP_UART_CHAR5BITS; | 2237 | config->bDataBits = UMP_UART_CHAR5BITS; |
2293 | dbg("%s - data bits = 5", __func__); | 2238 | dev_dbg(dev, "%s - data bits = 5\n", __func__); |
2294 | break; | 2239 | break; |
2295 | case CS6: | 2240 | case CS6: |
2296 | config->bDataBits = UMP_UART_CHAR6BITS; | 2241 | config->bDataBits = UMP_UART_CHAR6BITS; |
2297 | dbg("%s - data bits = 6", __func__); | 2242 | dev_dbg(dev, "%s - data bits = 6\n", __func__); |
2298 | break; | 2243 | break; |
2299 | case CS7: | 2244 | case CS7: |
2300 | config->bDataBits = UMP_UART_CHAR7BITS; | 2245 | config->bDataBits = UMP_UART_CHAR7BITS; |
2301 | dbg("%s - data bits = 7", __func__); | 2246 | dev_dbg(dev, "%s - data bits = 7\n", __func__); |
2302 | break; | 2247 | break; |
2303 | default: | 2248 | default: |
2304 | case CS8: | 2249 | case CS8: |
2305 | config->bDataBits = UMP_UART_CHAR8BITS; | 2250 | config->bDataBits = UMP_UART_CHAR8BITS; |
2306 | dbg("%s - data bits = 8", __func__); | 2251 | dev_dbg(dev, "%s - data bits = 8\n", __func__); |
2307 | break; | 2252 | break; |
2308 | } | 2253 | } |
2309 | 2254 | ||
@@ -2311,32 +2256,32 @@ static void change_port_settings(struct tty_struct *tty, | |||
2311 | if (cflag & PARODD) { | 2256 | if (cflag & PARODD) { |
2312 | config->wFlags |= UMP_MASK_UART_FLAGS_PARITY; | 2257 | config->wFlags |= UMP_MASK_UART_FLAGS_PARITY; |
2313 | config->bParity = UMP_UART_ODDPARITY; | 2258 | config->bParity = UMP_UART_ODDPARITY; |
2314 | dbg("%s - parity = odd", __func__); | 2259 | dev_dbg(dev, "%s - parity = odd\n", __func__); |
2315 | } else { | 2260 | } else { |
2316 | config->wFlags |= UMP_MASK_UART_FLAGS_PARITY; | 2261 | config->wFlags |= UMP_MASK_UART_FLAGS_PARITY; |
2317 | config->bParity = UMP_UART_EVENPARITY; | 2262 | config->bParity = UMP_UART_EVENPARITY; |
2318 | dbg("%s - parity = even", __func__); | 2263 | dev_dbg(dev, "%s - parity = even\n", __func__); |
2319 | } | 2264 | } |
2320 | } else { | 2265 | } else { |
2321 | config->bParity = UMP_UART_NOPARITY; | 2266 | config->bParity = UMP_UART_NOPARITY; |
2322 | dbg("%s - parity = none", __func__); | 2267 | dev_dbg(dev, "%s - parity = none\n", __func__); |
2323 | } | 2268 | } |
2324 | 2269 | ||
2325 | if (cflag & CSTOPB) { | 2270 | if (cflag & CSTOPB) { |
2326 | config->bStopBits = UMP_UART_STOPBIT2; | 2271 | config->bStopBits = UMP_UART_STOPBIT2; |
2327 | dbg("%s - stop bits = 2", __func__); | 2272 | dev_dbg(dev, "%s - stop bits = 2\n", __func__); |
2328 | } else { | 2273 | } else { |
2329 | config->bStopBits = UMP_UART_STOPBIT1; | 2274 | config->bStopBits = UMP_UART_STOPBIT1; |
2330 | dbg("%s - stop bits = 1", __func__); | 2275 | dev_dbg(dev, "%s - stop bits = 1\n", __func__); |
2331 | } | 2276 | } |
2332 | 2277 | ||
2333 | /* figure out the flow control settings */ | 2278 | /* figure out the flow control settings */ |
2334 | if (cflag & CRTSCTS) { | 2279 | if (cflag & CRTSCTS) { |
2335 | config->wFlags |= UMP_MASK_UART_FLAGS_OUT_X_CTS_FLOW; | 2280 | config->wFlags |= UMP_MASK_UART_FLAGS_OUT_X_CTS_FLOW; |
2336 | config->wFlags |= UMP_MASK_UART_FLAGS_RTS_FLOW; | 2281 | config->wFlags |= UMP_MASK_UART_FLAGS_RTS_FLOW; |
2337 | dbg("%s - RTS/CTS is enabled", __func__); | 2282 | dev_dbg(dev, "%s - RTS/CTS is enabled\n", __func__); |
2338 | } else { | 2283 | } else { |
2339 | dbg("%s - RTS/CTS is disabled", __func__); | 2284 | dev_dbg(dev, "%s - RTS/CTS is disabled\n", __func__); |
2340 | tty->hw_stopped = 0; | 2285 | tty->hw_stopped = 0; |
2341 | restart_read(edge_port); | 2286 | restart_read(edge_port); |
2342 | } | 2287 | } |
@@ -2349,18 +2294,18 @@ static void change_port_settings(struct tty_struct *tty, | |||
2349 | /* if we are implementing INBOUND XON/XOFF */ | 2294 | /* if we are implementing INBOUND XON/XOFF */ |
2350 | if (I_IXOFF(tty)) { | 2295 | if (I_IXOFF(tty)) { |
2351 | config->wFlags |= UMP_MASK_UART_FLAGS_IN_X; | 2296 | config->wFlags |= UMP_MASK_UART_FLAGS_IN_X; |
2352 | dbg("%s - INBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x", | 2297 | dev_dbg(dev, "%s - INBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x\n", |
2353 | __func__, config->cXon, config->cXoff); | 2298 | __func__, config->cXon, config->cXoff); |
2354 | } else | 2299 | } else |
2355 | dbg("%s - INBOUND XON/XOFF is disabled", __func__); | 2300 | dev_dbg(dev, "%s - INBOUND XON/XOFF is disabled\n", __func__); |
2356 | 2301 | ||
2357 | /* if we are implementing OUTBOUND XON/XOFF */ | 2302 | /* if we are implementing OUTBOUND XON/XOFF */ |
2358 | if (I_IXON(tty)) { | 2303 | if (I_IXON(tty)) { |
2359 | config->wFlags |= UMP_MASK_UART_FLAGS_OUT_X; | 2304 | config->wFlags |= UMP_MASK_UART_FLAGS_OUT_X; |
2360 | dbg("%s - OUTBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x", | 2305 | dev_dbg(dev, "%s - OUTBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x\n", |
2361 | __func__, config->cXon, config->cXoff); | 2306 | __func__, config->cXon, config->cXoff); |
2362 | } else | 2307 | } else |
2363 | dbg("%s - OUTBOUND XON/XOFF is disabled", __func__); | 2308 | dev_dbg(dev, "%s - OUTBOUND XON/XOFF is disabled\n", __func__); |
2364 | 2309 | ||
2365 | tty->termios.c_cflag &= ~CMSPAR; | 2310 | tty->termios.c_cflag &= ~CMSPAR; |
2366 | 2311 | ||
@@ -2377,17 +2322,16 @@ static void change_port_settings(struct tty_struct *tty, | |||
2377 | 2322 | ||
2378 | /* FIXME: Recompute actual baud from divisor here */ | 2323 | /* FIXME: Recompute actual baud from divisor here */ |
2379 | 2324 | ||
2380 | dbg("%s - baud rate = %d, wBaudRate = %d", __func__, baud, | 2325 | dev_dbg(dev, "%s - baud rate = %d, wBaudRate = %d\n", __func__, baud, config->wBaudRate); |
2381 | config->wBaudRate); | ||
2382 | 2326 | ||
2383 | dbg("wBaudRate: %d", (int)(461550L / config->wBaudRate)); | 2327 | dev_dbg(dev, "wBaudRate: %d\n", (int)(461550L / config->wBaudRate)); |
2384 | dbg("wFlags: 0x%x", config->wFlags); | 2328 | dev_dbg(dev, "wFlags: 0x%x\n", config->wFlags); |
2385 | dbg("bDataBits: %d", config->bDataBits); | 2329 | dev_dbg(dev, "bDataBits: %d\n", config->bDataBits); |
2386 | dbg("bParity: %d", config->bParity); | 2330 | dev_dbg(dev, "bParity: %d\n", config->bParity); |
2387 | dbg("bStopBits: %d", config->bStopBits); | 2331 | dev_dbg(dev, "bStopBits: %d\n", config->bStopBits); |
2388 | dbg("cXon: %d", config->cXon); | 2332 | dev_dbg(dev, "cXon: %d\n", config->cXon); |
2389 | dbg("cXoff: %d", config->cXoff); | 2333 | dev_dbg(dev, "cXoff: %d\n", config->cXoff); |
2390 | dbg("bUartMode: %d", config->bUartMode); | 2334 | dev_dbg(dev, "bUartMode: %d\n", config->bUartMode); |
2391 | 2335 | ||
2392 | /* move the word values into big endian mode */ | 2336 | /* move the word values into big endian mode */ |
2393 | cpu_to_be16s(&config->wFlags); | 2337 | cpu_to_be16s(&config->wFlags); |
@@ -2397,8 +2341,8 @@ static void change_port_settings(struct tty_struct *tty, | |||
2397 | (__u8)(UMPM_UART1_PORT + port_number), | 2341 | (__u8)(UMPM_UART1_PORT + port_number), |
2398 | 0, (__u8 *)config, sizeof(*config)); | 2342 | 0, (__u8 *)config, sizeof(*config)); |
2399 | if (status) | 2343 | if (status) |
2400 | dbg("%s - error %d when trying to write config to device", | 2344 | dev_dbg(dev, "%s - error %d when trying to write config to device\n", |
2401 | __func__, status); | 2345 | __func__, status); |
2402 | kfree(config); | 2346 | kfree(config); |
2403 | } | 2347 | } |
2404 | 2348 | ||
@@ -2410,11 +2354,11 @@ static void edge_set_termios(struct tty_struct *tty, | |||
2410 | 2354 | ||
2411 | cflag = tty->termios.c_cflag; | 2355 | cflag = tty->termios.c_cflag; |
2412 | 2356 | ||
2413 | dbg("%s - clfag %08x iflag %08x", __func__, | 2357 | dev_dbg(&port->dev, "%s - clfag %08x iflag %08x\n", __func__, |
2414 | tty->termios.c_cflag, tty->termios.c_iflag); | 2358 | tty->termios.c_cflag, tty->termios.c_iflag); |
2415 | dbg("%s - old clfag %08x old iflag %08x", __func__, | 2359 | dev_dbg(&port->dev, "%s - old clfag %08x old iflag %08x\n", __func__, |
2416 | old_termios->c_cflag, old_termios->c_iflag); | 2360 | old_termios->c_cflag, old_termios->c_iflag); |
2417 | dbg("%s - port %d", __func__, port->number); | 2361 | dev_dbg(&port->dev, "%s - port %d\n", __func__, port->number); |
2418 | 2362 | ||
2419 | if (edge_port == NULL) | 2363 | if (edge_port == NULL) |
2420 | return; | 2364 | return; |
@@ -2430,8 +2374,6 @@ static int edge_tiocmset(struct tty_struct *tty, | |||
2430 | unsigned int mcr; | 2374 | unsigned int mcr; |
2431 | unsigned long flags; | 2375 | unsigned long flags; |
2432 | 2376 | ||
2433 | dbg("%s - port %d", __func__, port->number); | ||
2434 | |||
2435 | spin_lock_irqsave(&edge_port->ep_lock, flags); | 2377 | spin_lock_irqsave(&edge_port->ep_lock, flags); |
2436 | mcr = edge_port->shadow_mcr; | 2378 | mcr = edge_port->shadow_mcr; |
2437 | if (set & TIOCM_RTS) | 2379 | if (set & TIOCM_RTS) |
@@ -2464,8 +2406,6 @@ static int edge_tiocmget(struct tty_struct *tty) | |||
2464 | unsigned int mcr; | 2406 | unsigned int mcr; |
2465 | unsigned long flags; | 2407 | unsigned long flags; |
2466 | 2408 | ||
2467 | dbg("%s - port %d", __func__, port->number); | ||
2468 | |||
2469 | spin_lock_irqsave(&edge_port->ep_lock, flags); | 2409 | spin_lock_irqsave(&edge_port->ep_lock, flags); |
2470 | 2410 | ||
2471 | msr = edge_port->shadow_msr; | 2411 | msr = edge_port->shadow_msr; |
@@ -2478,7 +2418,7 @@ static int edge_tiocmget(struct tty_struct *tty) | |||
2478 | | ((msr & EDGEPORT_MSR_DSR) ? TIOCM_DSR: 0); /* 0x100 */ | 2418 | | ((msr & EDGEPORT_MSR_DSR) ? TIOCM_DSR: 0); /* 0x100 */ |
2479 | 2419 | ||
2480 | 2420 | ||
2481 | dbg("%s -- %x", __func__, result); | 2421 | dev_dbg(&port->dev, "%s -- %x\n", __func__, result); |
2482 | spin_unlock_irqrestore(&edge_port->ep_lock, flags); | 2422 | spin_unlock_irqrestore(&edge_port->ep_lock, flags); |
2483 | 2423 | ||
2484 | return result; | 2424 | return result; |
@@ -2538,15 +2478,15 @@ static int edge_ioctl(struct tty_struct *tty, | |||
2538 | struct async_icount cnow; | 2478 | struct async_icount cnow; |
2539 | struct async_icount cprev; | 2479 | struct async_icount cprev; |
2540 | 2480 | ||
2541 | dbg("%s - port %d, cmd = 0x%x", __func__, port->number, cmd); | 2481 | dev_dbg(&port->dev, "%s - port %d, cmd = 0x%x\n", __func__, port->number, cmd); |
2542 | 2482 | ||
2543 | switch (cmd) { | 2483 | switch (cmd) { |
2544 | case TIOCGSERIAL: | 2484 | case TIOCGSERIAL: |
2545 | dbg("%s - (%d) TIOCGSERIAL", __func__, port->number); | 2485 | dev_dbg(&port->dev, "%s - TIOCGSERIAL\n", __func__); |
2546 | return get_serial_info(edge_port, | 2486 | return get_serial_info(edge_port, |
2547 | (struct serial_struct __user *) arg); | 2487 | (struct serial_struct __user *) arg); |
2548 | case TIOCMIWAIT: | 2488 | case TIOCMIWAIT: |
2549 | dbg("%s - (%d) TIOCMIWAIT", __func__, port->number); | 2489 | dev_dbg(&port->dev, "%s - TIOCMIWAIT\n", __func__); |
2550 | cprev = edge_port->icount; | 2490 | cprev = edge_port->icount; |
2551 | while (1) { | 2491 | while (1) { |
2552 | interruptible_sleep_on(&edge_port->delta_msr_wait); | 2492 | interruptible_sleep_on(&edge_port->delta_msr_wait); |
@@ -2578,8 +2518,6 @@ static void edge_break(struct tty_struct *tty, int break_state) | |||
2578 | int status; | 2518 | int status; |
2579 | int bv = 0; /* Off */ | 2519 | int bv = 0; /* Off */ |
2580 | 2520 | ||
2581 | dbg("%s - state = %d", __func__, break_state); | ||
2582 | |||
2583 | /* chase the port close */ | 2521 | /* chase the port close */ |
2584 | chase_port(edge_port, 0, 0); | 2522 | chase_port(edge_port, 0, 0); |
2585 | 2523 | ||
@@ -2587,8 +2525,8 @@ static void edge_break(struct tty_struct *tty, int break_state) | |||
2587 | bv = 1; /* On */ | 2525 | bv = 1; /* On */ |
2588 | status = ti_do_config(edge_port, UMPC_SET_CLR_BREAK, bv); | 2526 | status = ti_do_config(edge_port, UMPC_SET_CLR_BREAK, bv); |
2589 | if (status) | 2527 | if (status) |
2590 | dbg("%s - error %d sending break set/clear command.", | 2528 | dev_dbg(&port->dev, "%s - error %d sending break set/clear command.\n", |
2591 | __func__, status); | 2529 | __func__, status); |
2592 | } | 2530 | } |
2593 | 2531 | ||
2594 | static int edge_startup(struct usb_serial *serial) | 2532 | static int edge_startup(struct usb_serial *serial) |
@@ -2655,7 +2593,6 @@ cleanup: | |||
2655 | 2593 | ||
2656 | static void edge_disconnect(struct usb_serial *serial) | 2594 | static void edge_disconnect(struct usb_serial *serial) |
2657 | { | 2595 | { |
2658 | dbg("%s", __func__); | ||
2659 | } | 2596 | } |
2660 | 2597 | ||
2661 | static void edge_release(struct usb_serial *serial) | 2598 | static void edge_release(struct usb_serial *serial) |
@@ -2663,8 +2600,6 @@ static void edge_release(struct usb_serial *serial) | |||
2663 | int i; | 2600 | int i; |
2664 | struct edgeport_port *edge_port; | 2601 | struct edgeport_port *edge_port; |
2665 | 2602 | ||
2666 | dbg("%s", __func__); | ||
2667 | |||
2668 | for (i = 0; i < serial->num_ports; ++i) { | 2603 | for (i = 0; i < serial->num_ports; ++i) { |
2669 | edge_port = usb_get_serial_port_data(serial->port[i]); | 2604 | edge_port = usb_get_serial_port_data(serial->port[i]); |
2670 | kfifo_free(&edge_port->write_fifo); | 2605 | kfifo_free(&edge_port->write_fifo); |
@@ -2692,7 +2627,7 @@ static ssize_t store_uart_mode(struct device *dev, | |||
2692 | struct edgeport_port *edge_port = usb_get_serial_port_data(port); | 2627 | struct edgeport_port *edge_port = usb_get_serial_port_data(port); |
2693 | unsigned int v = simple_strtoul(valbuf, NULL, 0); | 2628 | unsigned int v = simple_strtoul(valbuf, NULL, 0); |
2694 | 2629 | ||
2695 | dbg("%s: setting uart_mode = %d", __func__, v); | 2630 | dev_dbg(dev, "%s: setting uart_mode = %d\n", __func__, v); |
2696 | 2631 | ||
2697 | if (v < 256) | 2632 | if (v < 256) |
2698 | edge_port->bUartMode = v; | 2633 | edge_port->bUartMode = v; |
@@ -2789,9 +2724,6 @@ MODULE_DESCRIPTION(DRIVER_DESC); | |||
2789 | MODULE_LICENSE("GPL"); | 2724 | MODULE_LICENSE("GPL"); |
2790 | MODULE_FIRMWARE("edgeport/down3.bin"); | 2725 | MODULE_FIRMWARE("edgeport/down3.bin"); |
2791 | 2726 | ||
2792 | module_param(debug, bool, S_IRUGO | S_IWUSR); | ||
2793 | MODULE_PARM_DESC(debug, "Debug enabled or not"); | ||
2794 | |||
2795 | module_param(closing_wait, int, S_IRUGO | S_IWUSR); | 2727 | module_param(closing_wait, int, S_IRUGO | S_IWUSR); |
2796 | MODULE_PARM_DESC(closing_wait, "Maximum wait for data to drain, in .01 secs"); | 2728 | MODULE_PARM_DESC(closing_wait, "Maximum wait for data to drain, in .01 secs"); |
2797 | 2729 | ||
diff --git a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c index c85a7eb87d4e..1068bf22e27e 100644 --- a/drivers/usb/serial/ipaq.c +++ b/drivers/usb/serial/ipaq.c | |||
@@ -33,7 +33,6 @@ | |||
33 | #define DRIVER_AUTHOR "Ganesh Varadarajan <ganesh@veritas.com>" | 33 | #define DRIVER_AUTHOR "Ganesh Varadarajan <ganesh@veritas.com>" |
34 | #define DRIVER_DESC "USB PocketPC PDA driver" | 34 | #define DRIVER_DESC "USB PocketPC PDA driver" |
35 | 35 | ||
36 | static bool debug; | ||
37 | static int connect_retries = KP_RETRIES; | 36 | static int connect_retries = KP_RETRIES; |
38 | static int initial_wait; | 37 | static int initial_wait; |
39 | 38 | ||
@@ -616,9 +615,6 @@ MODULE_AUTHOR(DRIVER_AUTHOR); | |||
616 | MODULE_DESCRIPTION(DRIVER_DESC); | 615 | MODULE_DESCRIPTION(DRIVER_DESC); |
617 | MODULE_LICENSE("GPL"); | 616 | MODULE_LICENSE("GPL"); |
618 | 617 | ||
619 | module_param(debug, bool, S_IRUGO | S_IWUSR); | ||
620 | MODULE_PARM_DESC(debug, "Debug enabled or not"); | ||
621 | |||
622 | module_param(connect_retries, int, S_IRUGO|S_IWUSR); | 618 | module_param(connect_retries, int, S_IRUGO|S_IWUSR); |
623 | MODULE_PARM_DESC(connect_retries, | 619 | MODULE_PARM_DESC(connect_retries, |
624 | "Maximum number of connect retries (one second each)"); | 620 | "Maximum number of connect retries (one second each)"); |
diff --git a/drivers/usb/serial/ipw.c b/drivers/usb/serial/ipw.c index 2cb30c535839..20a132ec39e2 100644 --- a/drivers/usb/serial/ipw.c +++ b/drivers/usb/serial/ipw.c | |||
@@ -138,11 +138,10 @@ static const struct usb_device_id id_table[] = { | |||
138 | }; | 138 | }; |
139 | MODULE_DEVICE_TABLE(usb, id_table); | 139 | MODULE_DEVICE_TABLE(usb, id_table); |
140 | 140 | ||
141 | static bool debug; | ||
142 | |||
143 | static int ipw_open(struct tty_struct *tty, struct usb_serial_port *port) | 141 | static int ipw_open(struct tty_struct *tty, struct usb_serial_port *port) |
144 | { | 142 | { |
145 | struct usb_device *dev = port->serial->dev; | 143 | struct usb_device *udev = port->serial->dev; |
144 | struct device *dev = &port->dev; | ||
146 | u8 buf_flow_static[16] = IPW_BYTES_FLOWINIT; | 145 | u8 buf_flow_static[16] = IPW_BYTES_FLOWINIT; |
147 | u8 *buf_flow_init; | 146 | u8 *buf_flow_init; |
148 | int result; | 147 | int result; |
@@ -154,8 +153,8 @@ static int ipw_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
154 | /* --1: Tell the modem to initialize (we think) From sniffs this is | 153 | /* --1: Tell the modem to initialize (we think) From sniffs this is |
155 | * always the first thing that gets sent to the modem during | 154 | * always the first thing that gets sent to the modem during |
156 | * opening of the device */ | 155 | * opening of the device */ |
157 | dbg("%s: Sending SIO_INIT (we guess)", __func__); | 156 | dev_dbg(dev, "%s: Sending SIO_INIT (we guess)\n", __func__); |
158 | result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), | 157 | result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), |
159 | IPW_SIO_INIT, | 158 | IPW_SIO_INIT, |
160 | USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, | 159 | USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, |
161 | 0, | 160 | 0, |
@@ -164,22 +163,19 @@ static int ipw_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
164 | 0, | 163 | 0, |
165 | 100000); | 164 | 100000); |
166 | if (result < 0) | 165 | if (result < 0) |
167 | dev_err(&port->dev, | 166 | dev_err(dev, "Init of modem failed (error = %d)\n", result); |
168 | "Init of modem failed (error = %d)\n", result); | ||
169 | 167 | ||
170 | /* reset the bulk pipes */ | 168 | /* reset the bulk pipes */ |
171 | usb_clear_halt(dev, | 169 | usb_clear_halt(udev, usb_rcvbulkpipe(udev, port->bulk_in_endpointAddress)); |
172 | usb_rcvbulkpipe(dev, port->bulk_in_endpointAddress)); | 170 | usb_clear_halt(udev, usb_sndbulkpipe(udev, port->bulk_out_endpointAddress)); |
173 | usb_clear_halt(dev, | ||
174 | usb_sndbulkpipe(dev, port->bulk_out_endpointAddress)); | ||
175 | 171 | ||
176 | /*--2: Start reading from the device */ | 172 | /*--2: Start reading from the device */ |
177 | dbg("%s: setting up bulk read callback", __func__); | 173 | dev_dbg(dev, "%s: setting up bulk read callback\n", __func__); |
178 | usb_wwan_open(tty, port); | 174 | usb_wwan_open(tty, port); |
179 | 175 | ||
180 | /*--3: Tell the modem to open the floodgates on the rx bulk channel */ | 176 | /*--3: Tell the modem to open the floodgates on the rx bulk channel */ |
181 | dbg("%s:asking modem for RxRead (RXBULK_ON)", __func__); | 177 | dev_dbg(dev, "%s:asking modem for RxRead (RXBULK_ON)\n", __func__); |
182 | result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), | 178 | result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), |
183 | IPW_SIO_RXCTL, | 179 | IPW_SIO_RXCTL, |
184 | USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, | 180 | USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, |
185 | IPW_RXBULK_ON, | 181 | IPW_RXBULK_ON, |
@@ -188,12 +184,11 @@ static int ipw_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
188 | 0, | 184 | 0, |
189 | 100000); | 185 | 100000); |
190 | if (result < 0) | 186 | if (result < 0) |
191 | dev_err(&port->dev, | 187 | dev_err(dev, "Enabling bulk RxRead failed (error = %d)\n", result); |
192 | "Enabling bulk RxRead failed (error = %d)\n", result); | ||
193 | 188 | ||
194 | /*--4: setup the initial flowcontrol */ | 189 | /*--4: setup the initial flowcontrol */ |
195 | dbg("%s:setting init flowcontrol (%s)", __func__, buf_flow_init); | 190 | dev_dbg(dev, "%s:setting init flowcontrol (%s)\n", __func__, buf_flow_init); |
196 | result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), | 191 | result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), |
197 | IPW_SIO_HANDFLOW, | 192 | IPW_SIO_HANDFLOW, |
198 | USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, | 193 | USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, |
199 | 0, | 194 | 0, |
@@ -202,8 +197,7 @@ static int ipw_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
202 | 0x10, | 197 | 0x10, |
203 | 200000); | 198 | 200000); |
204 | if (result < 0) | 199 | if (result < 0) |
205 | dev_err(&port->dev, | 200 | dev_err(dev, "initial flowcontrol failed (error = %d)\n", result); |
206 | "initial flowcontrol failed (error = %d)\n", result); | ||
207 | 201 | ||
208 | kfree(buf_flow_init); | 202 | kfree(buf_flow_init); |
209 | return 0; | 203 | return 0; |
@@ -233,12 +227,13 @@ static void ipw_release(struct usb_serial *serial) | |||
233 | 227 | ||
234 | static void ipw_dtr_rts(struct usb_serial_port *port, int on) | 228 | static void ipw_dtr_rts(struct usb_serial_port *port, int on) |
235 | { | 229 | { |
236 | struct usb_device *dev = port->serial->dev; | 230 | struct usb_device *udev = port->serial->dev; |
231 | struct device *dev = &port->dev; | ||
237 | int result; | 232 | int result; |
238 | 233 | ||
239 | dbg("%s: on = %d", __func__, on); | 234 | dev_dbg(dev, "%s: on = %d\n", __func__, on); |
240 | 235 | ||
241 | result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), | 236 | result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), |
242 | IPW_SIO_SET_PIN, | 237 | IPW_SIO_SET_PIN, |
243 | USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, | 238 | USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, |
244 | on ? IPW_PIN_SETDTR : IPW_PIN_CLRDTR, | 239 | on ? IPW_PIN_SETDTR : IPW_PIN_CLRDTR, |
@@ -247,10 +242,9 @@ static void ipw_dtr_rts(struct usb_serial_port *port, int on) | |||
247 | 0, | 242 | 0, |
248 | 200000); | 243 | 200000); |
249 | if (result < 0) | 244 | if (result < 0) |
250 | dev_err(&port->dev, "setting dtr failed (error = %d)\n", | 245 | dev_err(dev, "setting dtr failed (error = %d)\n", result); |
251 | result); | ||
252 | 246 | ||
253 | result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), | 247 | result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), |
254 | IPW_SIO_SET_PIN, USB_TYPE_VENDOR | | 248 | IPW_SIO_SET_PIN, USB_TYPE_VENDOR | |
255 | USB_RECIP_INTERFACE | USB_DIR_OUT, | 249 | USB_RECIP_INTERFACE | USB_DIR_OUT, |
256 | on ? IPW_PIN_SETRTS : IPW_PIN_CLRRTS, | 250 | on ? IPW_PIN_SETRTS : IPW_PIN_CLRRTS, |
@@ -259,18 +253,18 @@ static void ipw_dtr_rts(struct usb_serial_port *port, int on) | |||
259 | 0, | 253 | 0, |
260 | 200000); | 254 | 200000); |
261 | if (result < 0) | 255 | if (result < 0) |
262 | dev_err(&port->dev, "setting rts failed (error = %d)\n", | 256 | dev_err(dev, "setting rts failed (error = %d)\n", result); |
263 | result); | ||
264 | } | 257 | } |
265 | 258 | ||
266 | static void ipw_close(struct usb_serial_port *port) | 259 | static void ipw_close(struct usb_serial_port *port) |
267 | { | 260 | { |
268 | struct usb_device *dev = port->serial->dev; | 261 | struct usb_device *udev = port->serial->dev; |
262 | struct device *dev = &port->dev; | ||
269 | int result; | 263 | int result; |
270 | 264 | ||
271 | /*--3: purge */ | 265 | /*--3: purge */ |
272 | dbg("%s:sending purge", __func__); | 266 | dev_dbg(dev, "%s:sending purge\n", __func__); |
273 | result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), | 267 | result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), |
274 | IPW_SIO_PURGE, USB_TYPE_VENDOR | | 268 | IPW_SIO_PURGE, USB_TYPE_VENDOR | |
275 | USB_RECIP_INTERFACE | USB_DIR_OUT, | 269 | USB_RECIP_INTERFACE | USB_DIR_OUT, |
276 | 0x03, | 270 | 0x03, |
@@ -279,12 +273,12 @@ static void ipw_close(struct usb_serial_port *port) | |||
279 | 0, | 273 | 0, |
280 | 200000); | 274 | 200000); |
281 | if (result < 0) | 275 | if (result < 0) |
282 | dev_err(&port->dev, "purge failed (error = %d)\n", result); | 276 | dev_err(dev, "purge failed (error = %d)\n", result); |
283 | 277 | ||
284 | 278 | ||
285 | /* send RXBULK_off (tell modem to stop transmitting bulk data on | 279 | /* send RXBULK_off (tell modem to stop transmitting bulk data on |
286 | rx chan) */ | 280 | rx chan) */ |
287 | result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), | 281 | result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), |
288 | IPW_SIO_RXCTL, | 282 | IPW_SIO_RXCTL, |
289 | USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, | 283 | USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, |
290 | IPW_RXBULK_OFF, | 284 | IPW_RXBULK_OFF, |
@@ -294,8 +288,7 @@ static void ipw_close(struct usb_serial_port *port) | |||
294 | 100000); | 288 | 100000); |
295 | 289 | ||
296 | if (result < 0) | 290 | if (result < 0) |
297 | dev_err(&port->dev, | 291 | dev_err(dev, "Disabling bulk RxRead failed (error = %d)\n", result); |
298 | "Disabling bulk RxRead failed (error = %d)\n", result); | ||
299 | 292 | ||
300 | usb_wwan_close(port); | 293 | usb_wwan_close(port); |
301 | } | 294 | } |
@@ -328,6 +321,3 @@ module_usb_serial_driver(serial_drivers, id_table); | |||
328 | MODULE_AUTHOR(DRIVER_AUTHOR); | 321 | MODULE_AUTHOR(DRIVER_AUTHOR); |
329 | MODULE_DESCRIPTION(DRIVER_DESC); | 322 | MODULE_DESCRIPTION(DRIVER_DESC); |
330 | MODULE_LICENSE("GPL"); | 323 | MODULE_LICENSE("GPL"); |
331 | |||
332 | module_param(debug, bool, S_IRUGO | S_IWUSR); | ||
333 | MODULE_PARM_DESC(debug, "Debug enabled or not"); | ||
diff --git a/drivers/usb/serial/ir-usb.c b/drivers/usb/serial/ir-usb.c index 5a96692b12a2..e24e2d4f4c1b 100644 --- a/drivers/usb/serial/ir-usb.c +++ b/drivers/usb/serial/ir-usb.c | |||
@@ -38,15 +38,9 @@ | |||
38 | #include <linux/usb/serial.h> | 38 | #include <linux/usb/serial.h> |
39 | #include <linux/usb/irda.h> | 39 | #include <linux/usb/irda.h> |
40 | 40 | ||
41 | /* | ||
42 | * Version Information | ||
43 | */ | ||
44 | #define DRIVER_VERSION "v0.5" | ||
45 | #define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>, Johan Hovold <jhovold@gmail.com>" | 41 | #define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>, Johan Hovold <jhovold@gmail.com>" |
46 | #define DRIVER_DESC "USB IR Dongle driver" | 42 | #define DRIVER_DESC "USB IR Dongle driver" |
47 | 43 | ||
48 | static bool debug; | ||
49 | |||
50 | /* if overridden by the user, then use their value for the size of the read and | 44 | /* if overridden by the user, then use their value for the size of the read and |
51 | * write urbs */ | 45 | * write urbs */ |
52 | static int buffer_size; | 46 | static int buffer_size; |
@@ -430,18 +424,12 @@ err_buf: | |||
430 | 424 | ||
431 | static int __init ir_init(void) | 425 | static int __init ir_init(void) |
432 | { | 426 | { |
433 | int retval; | ||
434 | |||
435 | if (buffer_size) { | 427 | if (buffer_size) { |
436 | ir_device.bulk_in_size = buffer_size; | 428 | ir_device.bulk_in_size = buffer_size; |
437 | ir_device.bulk_out_size = buffer_size; | 429 | ir_device.bulk_out_size = buffer_size; |
438 | } | 430 | } |
439 | 431 | ||
440 | retval = usb_serial_register_drivers(serial_drivers, KBUILD_MODNAME, ir_id_table); | 432 | return usb_serial_register_drivers(serial_drivers, KBUILD_MODNAME, ir_id_table); |
441 | if (retval == 0) | ||
442 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" | ||
443 | DRIVER_DESC "\n"); | ||
444 | return retval; | ||
445 | } | 433 | } |
446 | 434 | ||
447 | static void __exit ir_exit(void) | 435 | static void __exit ir_exit(void) |
@@ -457,8 +445,6 @@ MODULE_AUTHOR(DRIVER_AUTHOR); | |||
457 | MODULE_DESCRIPTION(DRIVER_DESC); | 445 | MODULE_DESCRIPTION(DRIVER_DESC); |
458 | MODULE_LICENSE("GPL"); | 446 | MODULE_LICENSE("GPL"); |
459 | 447 | ||
460 | module_param(debug, bool, S_IRUGO | S_IWUSR); | ||
461 | MODULE_PARM_DESC(debug, "Debug enabled or not"); | ||
462 | module_param(xbof, int, 0); | 448 | module_param(xbof, int, 0); |
463 | MODULE_PARM_DESC(xbof, "Force specific number of XBOFs"); | 449 | MODULE_PARM_DESC(xbof, "Force specific number of XBOFs"); |
464 | module_param(buffer_size, int, 0); | 450 | module_param(buffer_size, int, 0); |
diff --git a/drivers/usb/serial/iuu_phoenix.c b/drivers/usb/serial/iuu_phoenix.c index bf3864045c18..01da3ea36e89 100644 --- a/drivers/usb/serial/iuu_phoenix.c +++ b/drivers/usb/serial/iuu_phoenix.c | |||
@@ -32,13 +32,6 @@ | |||
32 | #include "iuu_phoenix.h" | 32 | #include "iuu_phoenix.h" |
33 | #include <linux/random.h> | 33 | #include <linux/random.h> |
34 | 34 | ||
35 | |||
36 | #ifdef CONFIG_USB_SERIAL_DEBUG | ||
37 | static bool debug = 1; | ||
38 | #else | ||
39 | static bool debug; | ||
40 | #endif | ||
41 | |||
42 | /* | 35 | /* |
43 | * Version Information | 36 | * Version Information |
44 | */ | 37 | */ |
@@ -72,7 +65,6 @@ struct iuu_private { | |||
72 | u8 *writebuf; /* buffer for writing to device */ | 65 | u8 *writebuf; /* buffer for writing to device */ |
73 | int writelen; /* num of byte to write to device */ | 66 | int writelen; /* num of byte to write to device */ |
74 | u8 *buf; /* used for initialize speed */ | 67 | u8 *buf; /* used for initialize speed */ |
75 | u8 *dbgbuf; /* debug buffer */ | ||
76 | u8 len; | 68 | u8 len; |
77 | int vcc; /* vcc (either 3 or 5 V) */ | 69 | int vcc; /* vcc (either 3 or 5 V) */ |
78 | u32 baud; | 70 | u32 baud; |
@@ -84,32 +76,31 @@ struct iuu_private { | |||
84 | static void iuu_free_buf(struct iuu_private *priv) | 76 | static void iuu_free_buf(struct iuu_private *priv) |
85 | { | 77 | { |
86 | kfree(priv->buf); | 78 | kfree(priv->buf); |
87 | kfree(priv->dbgbuf); | ||
88 | kfree(priv->writebuf); | 79 | kfree(priv->writebuf); |
89 | } | 80 | } |
90 | 81 | ||
91 | static int iuu_alloc_buf(struct iuu_private *priv) | 82 | static int iuu_alloc_buf(struct usb_serial *serial, struct iuu_private *priv) |
92 | { | 83 | { |
93 | priv->buf = kzalloc(256, GFP_KERNEL); | 84 | priv->buf = kzalloc(256, GFP_KERNEL); |
94 | priv->dbgbuf = kzalloc(256, GFP_KERNEL); | ||
95 | priv->writebuf = kzalloc(256, GFP_KERNEL); | 85 | priv->writebuf = kzalloc(256, GFP_KERNEL); |
96 | if (!priv->buf || !priv->dbgbuf || !priv->writebuf) { | 86 | if (!priv->buf || !priv->writebuf) { |
97 | iuu_free_buf(priv); | 87 | iuu_free_buf(priv); |
98 | dbg("%s problem allocation buffer", __func__); | 88 | dev_dbg(&serial->dev->dev, "%s problem allocation buffer\n", __func__); |
99 | return -ENOMEM; | 89 | return -ENOMEM; |
100 | } | 90 | } |
101 | dbg("%s - Privates buffers allocation success", __func__); | 91 | dev_dbg(&serial->dev->dev, "%s - Privates buffers allocation success\n", __func__); |
102 | return 0; | 92 | return 0; |
103 | } | 93 | } |
104 | 94 | ||
105 | static int iuu_startup(struct usb_serial *serial) | 95 | static int iuu_startup(struct usb_serial *serial) |
106 | { | 96 | { |
107 | struct iuu_private *priv; | 97 | struct iuu_private *priv; |
98 | |||
108 | priv = kzalloc(sizeof(struct iuu_private), GFP_KERNEL); | 99 | priv = kzalloc(sizeof(struct iuu_private), GFP_KERNEL); |
109 | dbg("%s- priv allocation success", __func__); | 100 | dev_dbg(&serial->dev->dev, "%s- priv allocation success\n", __func__); |
110 | if (!priv) | 101 | if (!priv) |
111 | return -ENOMEM; | 102 | return -ENOMEM; |
112 | if (iuu_alloc_buf(priv)) { | 103 | if (iuu_alloc_buf(serial, priv)) { |
113 | kfree(priv); | 104 | kfree(priv); |
114 | return -ENOMEM; | 105 | return -ENOMEM; |
115 | } | 106 | } |
@@ -130,13 +121,13 @@ static void iuu_release(struct usb_serial *serial) | |||
130 | 121 | ||
131 | if (priv) { | 122 | if (priv) { |
132 | iuu_free_buf(priv); | 123 | iuu_free_buf(priv); |
133 | dbg("%s - I will free all", __func__); | 124 | dev_dbg(&port->dev, "%s - I will free all\n", __func__); |
134 | usb_set_serial_port_data(port, NULL); | 125 | usb_set_serial_port_data(port, NULL); |
135 | 126 | ||
136 | dbg("%s - priv is not anymore in port structure", __func__); | 127 | dev_dbg(&port->dev, "%s - priv is not anymore in port structure\n", __func__); |
137 | kfree(priv); | 128 | kfree(priv); |
138 | 129 | ||
139 | dbg("%s priv is now kfree", __func__); | 130 | dev_dbg(&port->dev, "%s priv is now kfree\n", __func__); |
140 | } | 131 | } |
141 | } | 132 | } |
142 | 133 | ||
@@ -148,13 +139,13 @@ static int iuu_tiocmset(struct tty_struct *tty, | |||
148 | unsigned long flags; | 139 | unsigned long flags; |
149 | 140 | ||
150 | /* FIXME: locking on tiomstatus */ | 141 | /* FIXME: locking on tiomstatus */ |
151 | dbg("%s (%d) msg : SET = 0x%04x, CLEAR = 0x%04x ", __func__, | 142 | dev_dbg(&port->dev, "%s msg : SET = 0x%04x, CLEAR = 0x%04x\n", |
152 | port->number, set, clear); | 143 | __func__, set, clear); |
153 | 144 | ||
154 | spin_lock_irqsave(&priv->lock, flags); | 145 | spin_lock_irqsave(&priv->lock, flags); |
155 | 146 | ||
156 | if ((set & TIOCM_RTS) && !(priv->tiostatus == TIOCM_RTS)) { | 147 | if ((set & TIOCM_RTS) && !(priv->tiostatus == TIOCM_RTS)) { |
157 | dbg("%s TIOCMSET RESET called !!!", __func__); | 148 | dev_dbg(&port->dev, "%s TIOCMSET RESET called !!!\n", __func__); |
158 | priv->reset = 1; | 149 | priv->reset = 1; |
159 | } | 150 | } |
160 | if (set & TIOCM_RTS) | 151 | if (set & TIOCM_RTS) |
@@ -190,7 +181,7 @@ static void iuu_rxcmd(struct urb *urb) | |||
190 | int status = urb->status; | 181 | int status = urb->status; |
191 | 182 | ||
192 | if (status) { | 183 | if (status) { |
193 | dbg("%s - status = %d", __func__, status); | 184 | dev_dbg(&port->dev, "%s - status = %d\n", __func__, status); |
194 | /* error stop all */ | 185 | /* error stop all */ |
195 | return; | 186 | return; |
196 | } | 187 | } |
@@ -244,13 +235,13 @@ static void iuu_update_status_callback(struct urb *urb) | |||
244 | int status = urb->status; | 235 | int status = urb->status; |
245 | 236 | ||
246 | if (status) { | 237 | if (status) { |
247 | dbg("%s - status = %d", __func__, status); | 238 | dev_dbg(&port->dev, "%s - status = %d\n", __func__, status); |
248 | /* error stop all */ | 239 | /* error stop all */ |
249 | return; | 240 | return; |
250 | } | 241 | } |
251 | 242 | ||
252 | st = urb->transfer_buffer; | 243 | st = urb->transfer_buffer; |
253 | dbg("%s - enter", __func__); | 244 | dev_dbg(&port->dev, "%s - enter\n", __func__); |
254 | if (urb->actual_length == 1) { | 245 | if (urb->actual_length == 1) { |
255 | switch (st[0]) { | 246 | switch (st[0]) { |
256 | case 0x1: | 247 | case 0x1: |
@@ -272,7 +263,7 @@ static void iuu_status_callback(struct urb *urb) | |||
272 | int result; | 263 | int result; |
273 | int status = urb->status; | 264 | int status = urb->status; |
274 | 265 | ||
275 | dbg("%s - status = %d", __func__, status); | 266 | dev_dbg(&port->dev, "%s - status = %d\n", __func__, status); |
276 | usb_fill_bulk_urb(port->read_urb, port->serial->dev, | 267 | usb_fill_bulk_urb(port->read_urb, port->serial->dev, |
277 | usb_rcvbulkpipe(port->serial->dev, | 268 | usb_rcvbulkpipe(port->serial->dev, |
278 | port->bulk_in_endpointAddress), | 269 | port->bulk_in_endpointAddress), |
@@ -311,9 +302,9 @@ static int bulk_immediate(struct usb_serial_port *port, u8 *buf, u8 count) | |||
311 | count, &actual, HZ * 1); | 302 | count, &actual, HZ * 1); |
312 | 303 | ||
313 | if (status != IUU_OPERATION_OK) | 304 | if (status != IUU_OPERATION_OK) |
314 | dbg("%s - error = %2x", __func__, status); | 305 | dev_dbg(&port->dev, "%s - error = %2x\n", __func__, status); |
315 | else | 306 | else |
316 | dbg("%s - write OK !", __func__); | 307 | dev_dbg(&port->dev, "%s - write OK !\n", __func__); |
317 | return status; | 308 | return status; |
318 | } | 309 | } |
319 | 310 | ||
@@ -331,9 +322,9 @@ static int read_immediate(struct usb_serial_port *port, u8 *buf, u8 count) | |||
331 | count, &actual, HZ * 1); | 322 | count, &actual, HZ * 1); |
332 | 323 | ||
333 | if (status != IUU_OPERATION_OK) | 324 | if (status != IUU_OPERATION_OK) |
334 | dbg("%s - error = %2x", __func__, status); | 325 | dev_dbg(&port->dev, "%s - error = %2x\n", __func__, status); |
335 | else | 326 | else |
336 | dbg("%s - read OK !", __func__); | 327 | dev_dbg(&port->dev, "%s - read OK !\n", __func__); |
337 | return status; | 328 | return status; |
338 | } | 329 | } |
339 | 330 | ||
@@ -357,9 +348,9 @@ static int iuu_led(struct usb_serial_port *port, unsigned int R, | |||
357 | status = bulk_immediate(port, buf, 8); | 348 | status = bulk_immediate(port, buf, 8); |
358 | kfree(buf); | 349 | kfree(buf); |
359 | if (status != IUU_OPERATION_OK) | 350 | if (status != IUU_OPERATION_OK) |
360 | dbg("%s - led error status = %2x", __func__, status); | 351 | dev_dbg(&port->dev, "%s - led error status = %2x\n", __func__, status); |
361 | else | 352 | else |
362 | dbg("%s - led OK !", __func__); | 353 | dev_dbg(&port->dev, "%s - led OK !\n", __func__); |
363 | return IUU_OPERATION_OK; | 354 | return IUU_OPERATION_OK; |
364 | } | 355 | } |
365 | 356 | ||
@@ -445,7 +436,7 @@ static int iuu_clk(struct usb_serial_port *port, int dwFrq) | |||
445 | 436 | ||
446 | status = bulk_immediate(port, (u8 *) priv->buf, Count); | 437 | status = bulk_immediate(port, (u8 *) priv->buf, Count); |
447 | if (status != 0) { | 438 | if (status != 0) { |
448 | dbg("%s - write error ", __func__); | 439 | dev_dbg(&port->dev, "%s - write error\n", __func__); |
449 | return status; | 440 | return status; |
450 | } | 441 | } |
451 | } else if (frq == 3579000) { | 442 | } else if (frq == 3579000) { |
@@ -554,12 +545,13 @@ static int iuu_clk(struct usb_serial_port *port, int dwFrq) | |||
554 | 545 | ||
555 | status = bulk_immediate(port, (u8 *) priv->buf, Count); | 546 | status = bulk_immediate(port, (u8 *) priv->buf, Count); |
556 | if (status != IUU_OPERATION_OK) | 547 | if (status != IUU_OPERATION_OK) |
557 | dbg("%s - write error ", __func__); | 548 | dev_dbg(&port->dev, "%s - write error\n", __func__); |
558 | return status; | 549 | return status; |
559 | } | 550 | } |
560 | 551 | ||
561 | static int iuu_uart_flush(struct usb_serial_port *port) | 552 | static int iuu_uart_flush(struct usb_serial_port *port) |
562 | { | 553 | { |
554 | struct device *dev = &port->dev; | ||
563 | int i; | 555 | int i; |
564 | int status; | 556 | int status; |
565 | u8 rxcmd = IUU_UART_RX; | 557 | u8 rxcmd = IUU_UART_RX; |
@@ -571,27 +563,26 @@ static int iuu_uart_flush(struct usb_serial_port *port) | |||
571 | for (i = 0; i < 2; i++) { | 563 | for (i = 0; i < 2; i++) { |
572 | status = bulk_immediate(port, &rxcmd, 1); | 564 | status = bulk_immediate(port, &rxcmd, 1); |
573 | if (status != IUU_OPERATION_OK) { | 565 | if (status != IUU_OPERATION_OK) { |
574 | dbg("%s - uart_flush_write error", __func__); | 566 | dev_dbg(dev, "%s - uart_flush_write error\n", __func__); |
575 | return status; | 567 | return status; |
576 | } | 568 | } |
577 | 569 | ||
578 | status = read_immediate(port, &priv->len, 1); | 570 | status = read_immediate(port, &priv->len, 1); |
579 | if (status != IUU_OPERATION_OK) { | 571 | if (status != IUU_OPERATION_OK) { |
580 | dbg("%s - uart_flush_read error", __func__); | 572 | dev_dbg(dev, "%s - uart_flush_read error\n", __func__); |
581 | return status; | 573 | return status; |
582 | } | 574 | } |
583 | 575 | ||
584 | if (priv->len > 0) { | 576 | if (priv->len > 0) { |
585 | dbg("%s - uart_flush datalen is : %i ", __func__, | 577 | dev_dbg(dev, "%s - uart_flush datalen is : %i\n", __func__, priv->len); |
586 | priv->len); | ||
587 | status = read_immediate(port, priv->buf, priv->len); | 578 | status = read_immediate(port, priv->buf, priv->len); |
588 | if (status != IUU_OPERATION_OK) { | 579 | if (status != IUU_OPERATION_OK) { |
589 | dbg("%s - uart_flush_read error", __func__); | 580 | dev_dbg(dev, "%s - uart_flush_read error\n", __func__); |
590 | return status; | 581 | return status; |
591 | } | 582 | } |
592 | } | 583 | } |
593 | } | 584 | } |
594 | dbg("%s - uart_flush_read OK!", __func__); | 585 | dev_dbg(dev, "%s - uart_flush_read OK!\n", __func__); |
595 | iuu_led(port, 0, 0xF000, 0, 0xFF); | 586 | iuu_led(port, 0, 0xF000, 0, 0xFF); |
596 | return status; | 587 | return status; |
597 | } | 588 | } |
@@ -610,10 +601,10 @@ static void read_buf_callback(struct urb *urb) | |||
610 | return; | 601 | return; |
611 | } | 602 | } |
612 | 603 | ||
613 | dbg("%s - %i chars to write", __func__, urb->actual_length); | 604 | dev_dbg(&port->dev, "%s - %i chars to write\n", __func__, urb->actual_length); |
614 | tty = tty_port_tty_get(&port->port); | 605 | tty = tty_port_tty_get(&port->port); |
615 | if (data == NULL) | 606 | if (data == NULL) |
616 | dbg("%s - data is NULL !!!", __func__); | 607 | dev_dbg(&port->dev, "%s - data is NULL !!!\n", __func__); |
617 | if (tty && urb->actual_length && data) { | 608 | if (tty && urb->actual_length && data) { |
618 | tty_insert_flip_string(tty, data, urb->actual_length); | 609 | tty_insert_flip_string(tty, data, urb->actual_length); |
619 | tty_flip_buffer_push(tty); | 610 | tty_flip_buffer_push(tty); |
@@ -627,7 +618,6 @@ static int iuu_bulk_write(struct usb_serial_port *port) | |||
627 | struct iuu_private *priv = usb_get_serial_port_data(port); | 618 | struct iuu_private *priv = usb_get_serial_port_data(port); |
628 | unsigned long flags; | 619 | unsigned long flags; |
629 | int result; | 620 | int result; |
630 | int i; | ||
631 | int buf_len; | 621 | int buf_len; |
632 | char *buf_ptr = port->write_urb->transfer_buffer; | 622 | char *buf_ptr = port->write_urb->transfer_buffer; |
633 | 623 | ||
@@ -640,14 +630,8 @@ static int iuu_bulk_write(struct usb_serial_port *port) | |||
640 | buf_len = priv->writelen; | 630 | buf_len = priv->writelen; |
641 | priv->writelen = 0; | 631 | priv->writelen = 0; |
642 | spin_unlock_irqrestore(&priv->lock, flags); | 632 | spin_unlock_irqrestore(&priv->lock, flags); |
643 | if (debug == 1) { | 633 | dev_dbg(&port->dev, "%s - writing %i chars : %*ph\n", __func__, |
644 | for (i = 0; i < buf_len; i++) | 634 | buf_len, buf_len, buf_ptr); |
645 | sprintf(priv->dbgbuf + i*2 , | ||
646 | "%02X", priv->writebuf[i]); | ||
647 | priv->dbgbuf[buf_len+i*2] = 0; | ||
648 | dbg("%s - writing %i chars : %s", __func__, | ||
649 | buf_len, priv->dbgbuf); | ||
650 | } | ||
651 | usb_fill_bulk_urb(port->write_urb, port->serial->dev, | 635 | usb_fill_bulk_urb(port->write_urb, port->serial->dev, |
652 | usb_sndbulkpipe(port->serial->dev, | 636 | usb_sndbulkpipe(port->serial->dev, |
653 | port->bulk_out_endpointAddress), | 637 | port->bulk_out_endpointAddress), |
@@ -683,18 +667,18 @@ static void iuu_uart_read_callback(struct urb *urb) | |||
683 | priv->poll++; | 667 | priv->poll++; |
684 | 668 | ||
685 | if (status) { | 669 | if (status) { |
686 | dbg("%s - status = %d", __func__, status); | 670 | dev_dbg(&port->dev, "%s - status = %d\n", __func__, status); |
687 | /* error stop all */ | 671 | /* error stop all */ |
688 | return; | 672 | return; |
689 | } | 673 | } |
690 | if (data == NULL) | 674 | if (data == NULL) |
691 | dbg("%s - data is NULL !!!", __func__); | 675 | dev_dbg(&port->dev, "%s - data is NULL !!!\n", __func__); |
692 | 676 | ||
693 | if (urb->actual_length == 1 && data != NULL) | 677 | if (urb->actual_length == 1 && data != NULL) |
694 | len = (int) data[0]; | 678 | len = (int) data[0]; |
695 | 679 | ||
696 | if (urb->actual_length > 1) { | 680 | if (urb->actual_length > 1) { |
697 | dbg("%s - urb->actual_length = %i", __func__, | 681 | dev_dbg(&port->dev, "%s - urb->actual_length = %i\n", __func__, |
698 | urb->actual_length); | 682 | urb->actual_length); |
699 | error = 1; | 683 | error = 1; |
700 | return; | 684 | return; |
@@ -702,7 +686,7 @@ static void iuu_uart_read_callback(struct urb *urb) | |||
702 | /* if len > 0 call readbuf */ | 686 | /* if len > 0 call readbuf */ |
703 | 687 | ||
704 | if (len > 0 && error == 0) { | 688 | if (len > 0 && error == 0) { |
705 | dbg("%s - call read buf - len to read is %i ", | 689 | dev_dbg(&port->dev, "%s - call read buf - len to read is %i\n", |
706 | __func__, len); | 690 | __func__, len); |
707 | status = iuu_read_buf(port, len); | 691 | status = iuu_read_buf(port, len); |
708 | return; | 692 | return; |
@@ -729,7 +713,7 @@ static void iuu_uart_read_callback(struct urb *urb) | |||
729 | } | 713 | } |
730 | spin_unlock_irqrestore(&priv->lock, flags); | 714 | spin_unlock_irqrestore(&priv->lock, flags); |
731 | /* if nothing to write call again rxcmd */ | 715 | /* if nothing to write call again rxcmd */ |
732 | dbg("%s - rxcmd recall", __func__); | 716 | dev_dbg(&port->dev, "%s - rxcmd recall\n", __func__); |
733 | iuu_led_activity_off(urb); | 717 | iuu_led_activity_off(urb); |
734 | } | 718 | } |
735 | 719 | ||
@@ -769,7 +753,7 @@ static void read_rxcmd_callback(struct urb *urb) | |||
769 | port->read_urb->transfer_buffer, 256, | 753 | port->read_urb->transfer_buffer, 256, |
770 | iuu_uart_read_callback, port); | 754 | iuu_uart_read_callback, port); |
771 | result = usb_submit_urb(port->read_urb, GFP_ATOMIC); | 755 | result = usb_submit_urb(port->read_urb, GFP_ATOMIC); |
772 | dbg("%s - submit result = %d", __func__, result); | 756 | dev_dbg(&port->dev, "%s - submit result = %d\n", __func__, result); |
773 | } | 757 | } |
774 | 758 | ||
775 | static int iuu_uart_on(struct usb_serial_port *port) | 759 | static int iuu_uart_on(struct usb_serial_port *port) |
@@ -789,13 +773,13 @@ static int iuu_uart_on(struct usb_serial_port *port) | |||
789 | 773 | ||
790 | status = bulk_immediate(port, buf, 4); | 774 | status = bulk_immediate(port, buf, 4); |
791 | if (status != IUU_OPERATION_OK) { | 775 | if (status != IUU_OPERATION_OK) { |
792 | dbg("%s - uart_on error", __func__); | 776 | dev_dbg(&port->dev, "%s - uart_on error\n", __func__); |
793 | goto uart_enable_failed; | 777 | goto uart_enable_failed; |
794 | } | 778 | } |
795 | /* iuu_reset() the card after iuu_uart_on() */ | 779 | /* iuu_reset() the card after iuu_uart_on() */ |
796 | status = iuu_uart_flush(port); | 780 | status = iuu_uart_flush(port); |
797 | if (status != IUU_OPERATION_OK) | 781 | if (status != IUU_OPERATION_OK) |
798 | dbg("%s - uart_flush error", __func__); | 782 | dev_dbg(&port->dev, "%s - uart_flush error\n", __func__); |
799 | uart_enable_failed: | 783 | uart_enable_failed: |
800 | kfree(buf); | 784 | kfree(buf); |
801 | return status; | 785 | return status; |
@@ -813,7 +797,7 @@ static int iuu_uart_off(struct usb_serial_port *port) | |||
813 | 797 | ||
814 | status = bulk_immediate(port, buf, 1); | 798 | status = bulk_immediate(port, buf, 1); |
815 | if (status != IUU_OPERATION_OK) | 799 | if (status != IUU_OPERATION_OK) |
816 | dbg("%s - uart_off error", __func__); | 800 | dev_dbg(&port->dev, "%s - uart_off error\n", __func__); |
817 | 801 | ||
818 | kfree(buf); | 802 | kfree(buf); |
819 | return status; | 803 | return status; |
@@ -830,7 +814,7 @@ static int iuu_uart_baud(struct usb_serial_port *port, u32 baud_base, | |||
830 | u8 T1reload = 0; | 814 | u8 T1reload = 0; |
831 | unsigned int T1FrekvensHZ = 0; | 815 | unsigned int T1FrekvensHZ = 0; |
832 | 816 | ||
833 | dbg("%s - enter baud_base=%d", __func__, baud_base); | 817 | dev_dbg(&port->dev, "%s - enter baud_base=%d\n", __func__, baud_base); |
834 | dataout = kmalloc(sizeof(u8) * 5, GFP_KERNEL); | 818 | dataout = kmalloc(sizeof(u8) * 5, GFP_KERNEL); |
835 | 819 | ||
836 | if (!dataout) | 820 | if (!dataout) |
@@ -911,7 +895,7 @@ static int iuu_uart_baud(struct usb_serial_port *port, u32 baud_base, | |||
911 | 895 | ||
912 | status = bulk_immediate(port, dataout, DataCount); | 896 | status = bulk_immediate(port, dataout, DataCount); |
913 | if (status != IUU_OPERATION_OK) | 897 | if (status != IUU_OPERATION_OK) |
914 | dbg("%s - uart_off error", __func__); | 898 | dev_dbg(&port->dev, "%s - uart_off error\n", __func__); |
915 | kfree(dataout); | 899 | kfree(dataout); |
916 | return status; | 900 | return status; |
917 | } | 901 | } |
@@ -932,7 +916,7 @@ static void iuu_set_termios(struct tty_struct *tty, | |||
932 | /* Just use the ospeed. ispeed should be the same. */ | 916 | /* Just use the ospeed. ispeed should be the same. */ |
933 | baud = tty->termios.c_ospeed; | 917 | baud = tty->termios.c_ospeed; |
934 | 918 | ||
935 | dbg("%s - enter c_ospeed or baud=%d", __func__, baud); | 919 | dev_dbg(&port->dev, "%s - enter c_ospeed or baud=%d\n", __func__, baud); |
936 | 920 | ||
937 | /* compute the parity parameter */ | 921 | /* compute the parity parameter */ |
938 | parity = 0; | 922 | parity = 0; |
@@ -983,7 +967,7 @@ static void iuu_close(struct usb_serial_port *port) | |||
983 | if (serial->dev) { | 967 | if (serial->dev) { |
984 | /* free writebuf */ | 968 | /* free writebuf */ |
985 | /* shutdown our urbs */ | 969 | /* shutdown our urbs */ |
986 | dbg("%s - shutting down urbs", __func__); | 970 | dev_dbg(&port->dev, "%s - shutting down urbs\n", __func__); |
987 | usb_kill_urb(port->write_urb); | 971 | usb_kill_urb(port->write_urb); |
988 | usb_kill_urb(port->read_urb); | 972 | usb_kill_urb(port->read_urb); |
989 | usb_kill_urb(port->interrupt_in_urb); | 973 | usb_kill_urb(port->interrupt_in_urb); |
@@ -1006,6 +990,7 @@ static void iuu_init_termios(struct tty_struct *tty) | |||
1006 | static int iuu_open(struct tty_struct *tty, struct usb_serial_port *port) | 990 | static int iuu_open(struct tty_struct *tty, struct usb_serial_port *port) |
1007 | { | 991 | { |
1008 | struct usb_serial *serial = port->serial; | 992 | struct usb_serial *serial = port->serial; |
993 | struct device *dev = &port->dev; | ||
1009 | u8 *buf; | 994 | u8 *buf; |
1010 | int result; | 995 | int result; |
1011 | int baud; | 996 | int baud; |
@@ -1017,7 +1002,7 @@ static int iuu_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
1017 | /* Re-encode speed */ | 1002 | /* Re-encode speed */ |
1018 | tty_encode_baud_rate(tty, baud, baud); | 1003 | tty_encode_baud_rate(tty, baud, baud); |
1019 | 1004 | ||
1020 | dbg("%s - port %d, baud %d", __func__, port->number, baud); | 1005 | dev_dbg(dev, "%s - baud %d\n", __func__, baud); |
1021 | usb_clear_halt(serial->dev, port->write_urb->pipe); | 1006 | usb_clear_halt(serial->dev, port->write_urb->pipe); |
1022 | usb_clear_halt(serial->dev, port->read_urb->pipe); | 1007 | usb_clear_halt(serial->dev, port->read_urb->pipe); |
1023 | 1008 | ||
@@ -1032,14 +1017,14 @@ static int iuu_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
1032 | result = usb_control_msg(port->serial->dev, \ | 1017 | result = usb_control_msg(port->serial->dev, \ |
1033 | usb_rcvctrlpipe(port->serial->dev, 0), \ | 1018 | usb_rcvctrlpipe(port->serial->dev, 0), \ |
1034 | b, a, c, d, buf, 1, 1000); \ | 1019 | b, a, c, d, buf, 1, 1000); \ |
1035 | dbg("0x%x:0x%x:0x%x:0x%x %d - %x", a, b, c, d, result, \ | 1020 | dev_dbg(dev, "0x%x:0x%x:0x%x:0x%x %d - %x\n", a, b, c, d, result, \ |
1036 | buf[0]); } while (0); | 1021 | buf[0]); } while (0); |
1037 | 1022 | ||
1038 | #define SOUP(a, b, c, d) do { \ | 1023 | #define SOUP(a, b, c, d) do { \ |
1039 | result = usb_control_msg(port->serial->dev, \ | 1024 | result = usb_control_msg(port->serial->dev, \ |
1040 | usb_sndctrlpipe(port->serial->dev, 0), \ | 1025 | usb_sndctrlpipe(port->serial->dev, 0), \ |
1041 | b, a, c, d, NULL, 0, 1000); \ | 1026 | b, a, c, d, NULL, 0, 1000); \ |
1042 | dbg("0x%x:0x%x:0x%x:0x%x %d", a, b, c, d, result); } while (0) | 1027 | dev_dbg(dev, "0x%x:0x%x:0x%x:0x%x %d\n", a, b, c, d, result); } while (0) |
1043 | 1028 | ||
1044 | /* This is not UART related but IUU USB driver related or something */ | 1029 | /* This is not UART related but IUU USB driver related or something */ |
1045 | /* like that. Basically no IUU will accept any commands from the USB */ | 1030 | /* like that. Basically no IUU will accept any commands from the USB */ |
@@ -1119,7 +1104,7 @@ static int iuu_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
1119 | 1104 | ||
1120 | iuu_uart_flush(port); | 1105 | iuu_uart_flush(port); |
1121 | 1106 | ||
1122 | dbg("%s - initialization done", __func__); | 1107 | dev_dbg(dev, "%s - initialization done\n", __func__); |
1123 | 1108 | ||
1124 | memset(port->write_urb->transfer_buffer, IUU_UART_RX, 1); | 1109 | memset(port->write_urb->transfer_buffer, IUU_UART_RX, 1); |
1125 | usb_fill_bulk_urb(port->write_urb, port->serial->dev, | 1110 | usb_fill_bulk_urb(port->write_urb, port->serial->dev, |
@@ -1129,11 +1114,10 @@ static int iuu_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
1129 | read_rxcmd_callback, port); | 1114 | read_rxcmd_callback, port); |
1130 | result = usb_submit_urb(port->write_urb, GFP_KERNEL); | 1115 | result = usb_submit_urb(port->write_urb, GFP_KERNEL); |
1131 | if (result) { | 1116 | if (result) { |
1132 | dev_err(&port->dev, "%s - failed submitting read urb," | 1117 | dev_err(dev, "%s - failed submitting read urb, error %d\n", __func__, result); |
1133 | " error %d\n", __func__, result); | ||
1134 | iuu_close(port); | 1118 | iuu_close(port); |
1135 | } else { | 1119 | } else { |
1136 | dbg("%s - rxcmd OK", __func__); | 1120 | dev_dbg(dev, "%s - rxcmd OK\n", __func__); |
1137 | } | 1121 | } |
1138 | 1122 | ||
1139 | return result; | 1123 | return result; |
@@ -1159,9 +1143,9 @@ static int iuu_vcc_set(struct usb_serial_port *port, unsigned int vcc) | |||
1159 | kfree(buf); | 1143 | kfree(buf); |
1160 | 1144 | ||
1161 | if (status != IUU_OPERATION_OK) | 1145 | if (status != IUU_OPERATION_OK) |
1162 | dbg("%s - vcc error status = %2x", __func__, status); | 1146 | dev_dbg(&port->dev, "%s - vcc error status = %2x\n", __func__, status); |
1163 | else | 1147 | else |
1164 | dbg("%s - vcc OK !", __func__); | 1148 | dev_dbg(&port->dev, "%s - vcc OK !\n", __func__); |
1165 | 1149 | ||
1166 | return status; | 1150 | return status; |
1167 | } | 1151 | } |
@@ -1192,7 +1176,7 @@ static ssize_t store_vcc_mode(struct device *dev, | |||
1192 | goto fail_store_vcc_mode; | 1176 | goto fail_store_vcc_mode; |
1193 | } | 1177 | } |
1194 | 1178 | ||
1195 | dbg("%s: setting vcc_mode = %ld", __func__, v); | 1179 | dev_dbg(dev, "%s: setting vcc_mode = %ld", __func__, v); |
1196 | 1180 | ||
1197 | if ((v != 3) && (v != 5)) { | 1181 | if ((v != 3) && (v != 5)) { |
1198 | dev_err(dev, "%s - vcc_mode %ld is invalid\n", __func__, v); | 1182 | dev_err(dev, "%s - vcc_mode %ld is invalid\n", __func__, v); |
@@ -1257,8 +1241,6 @@ MODULE_DESCRIPTION(DRIVER_DESC); | |||
1257 | MODULE_LICENSE("GPL"); | 1241 | MODULE_LICENSE("GPL"); |
1258 | 1242 | ||
1259 | MODULE_VERSION(DRIVER_VERSION); | 1243 | MODULE_VERSION(DRIVER_VERSION); |
1260 | module_param(debug, bool, S_IRUGO | S_IWUSR); | ||
1261 | MODULE_PARM_DESC(debug, "Debug enabled or not"); | ||
1262 | 1244 | ||
1263 | module_param(xmas, bool, S_IRUGO | S_IWUSR); | 1245 | module_param(xmas, bool, S_IRUGO | S_IWUSR); |
1264 | MODULE_PARM_DESC(xmas, "Xmas colors enabled or not"); | 1246 | MODULE_PARM_DESC(xmas, "Xmas colors enabled or not"); |
diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c index 7bcbb47e1449..29c943d737d0 100644 --- a/drivers/usb/serial/keyspan.c +++ b/drivers/usb/serial/keyspan.c | |||
@@ -38,15 +38,12 @@ | |||
38 | #include <linux/tty_flip.h> | 38 | #include <linux/tty_flip.h> |
39 | #include <linux/module.h> | 39 | #include <linux/module.h> |
40 | #include <linux/spinlock.h> | 40 | #include <linux/spinlock.h> |
41 | #include <linux/firmware.h> | ||
42 | #include <linux/ihex.h> | ||
43 | #include <linux/uaccess.h> | 41 | #include <linux/uaccess.h> |
44 | #include <linux/usb.h> | 42 | #include <linux/usb.h> |
45 | #include <linux/usb/serial.h> | 43 | #include <linux/usb/serial.h> |
44 | #include <linux/usb/ezusb.h> | ||
46 | #include "keyspan.h" | 45 | #include "keyspan.h" |
47 | 46 | ||
48 | static bool debug; | ||
49 | |||
50 | /* | 47 | /* |
51 | * Version Information | 48 | * Version Information |
52 | */ | 49 | */ |
@@ -165,7 +162,7 @@ static void keyspan_set_termios(struct tty_struct *tty, | |||
165 | so other rates can be generated if desired. */ | 162 | so other rates can be generated if desired. */ |
166 | baud_rate = tty_get_baud_rate(tty); | 163 | baud_rate = tty_get_baud_rate(tty); |
167 | /* If no match or invalid, don't change */ | 164 | /* If no match or invalid, don't change */ |
168 | if (d_details->calculate_baud_rate(baud_rate, d_details->baudclk, | 165 | if (d_details->calculate_baud_rate(port, baud_rate, d_details->baudclk, |
169 | NULL, NULL, NULL, device_port) == KEYSPAN_BAUD_RATE_OK) { | 166 | NULL, NULL, NULL, device_port) == KEYSPAN_BAUD_RATE_OK) { |
170 | /* FIXME - more to do here to ensure rate changes cleanly */ | 167 | /* FIXME - more to do here to ensure rate changes cleanly */ |
171 | /* FIXME - calcuate exact rate from divisor ? */ | 168 | /* FIXME - calcuate exact rate from divisor ? */ |
@@ -241,8 +238,8 @@ static int keyspan_write(struct tty_struct *tty, | |||
241 | dataOffset = 1; | 238 | dataOffset = 1; |
242 | } | 239 | } |
243 | 240 | ||
244 | dbg("%s - for port %d (%d chars), flip=%d", | 241 | dev_dbg(&port->dev, "%s - for port %d (%d chars), flip=%d\n", |
245 | __func__, port->number, count, p_priv->out_flip); | 242 | __func__, port->number, count, p_priv->out_flip); |
246 | 243 | ||
247 | for (left = count; left > 0; left -= todo) { | 244 | for (left = count; left > 0; left -= todo) { |
248 | todo = left; | 245 | todo = left; |
@@ -255,11 +252,11 @@ static int keyspan_write(struct tty_struct *tty, | |||
255 | this_urb = p_priv->out_urbs[flip]; | 252 | this_urb = p_priv->out_urbs[flip]; |
256 | if (this_urb == NULL) { | 253 | if (this_urb == NULL) { |
257 | /* no bulk out, so return 0 bytes written */ | 254 | /* no bulk out, so return 0 bytes written */ |
258 | dbg("%s - no output urb :(", __func__); | 255 | dev_dbg(&port->dev, "%s - no output urb :(\n", __func__); |
259 | return count; | 256 | return count; |
260 | } | 257 | } |
261 | 258 | ||
262 | dbg("%s - endpoint %d flip %d", | 259 | dev_dbg(&port->dev, "%s - endpoint %d flip %d\n", |
263 | __func__, usb_pipeendpoint(this_urb->pipe), flip); | 260 | __func__, usb_pipeendpoint(this_urb->pipe), flip); |
264 | 261 | ||
265 | if (this_urb->status == -EINPROGRESS) { | 262 | if (this_urb->status == -EINPROGRESS) { |
@@ -282,7 +279,7 @@ static int keyspan_write(struct tty_struct *tty, | |||
282 | 279 | ||
283 | err = usb_submit_urb(this_urb, GFP_ATOMIC); | 280 | err = usb_submit_urb(this_urb, GFP_ATOMIC); |
284 | if (err != 0) | 281 | if (err != 0) |
285 | dbg("usb_submit_urb(write bulk) failed (%d)", err); | 282 | dev_dbg(&port->dev, "usb_submit_urb(write bulk) failed (%d)\n", err); |
286 | p_priv->tx_start_time[flip] = jiffies; | 283 | p_priv->tx_start_time[flip] = jiffies; |
287 | 284 | ||
288 | /* Flip for next time if usa26 or usa28 interface | 285 | /* Flip for next time if usa26 or usa28 interface |
@@ -305,8 +302,8 @@ static void usa26_indat_callback(struct urb *urb) | |||
305 | endpoint = usb_pipeendpoint(urb->pipe); | 302 | endpoint = usb_pipeendpoint(urb->pipe); |
306 | 303 | ||
307 | if (status) { | 304 | if (status) { |
308 | dbg("%s - nonzero status: %x on endpoint %d.", | 305 | dev_dbg(&urb->dev->dev,"%s - nonzero status: %x on endpoint %d.\n", |
309 | __func__, status, endpoint); | 306 | __func__, status, endpoint); |
310 | return; | 307 | return; |
311 | } | 308 | } |
312 | 309 | ||
@@ -325,7 +322,7 @@ static void usa26_indat_callback(struct urb *urb) | |||
325 | tty_insert_flip_char(tty, data[i], err); | 322 | tty_insert_flip_char(tty, data[i], err); |
326 | } else { | 323 | } else { |
327 | /* some bytes had errors, every byte has status */ | 324 | /* some bytes had errors, every byte has status */ |
328 | dbg("%s - RX error!!!!", __func__); | 325 | dev_dbg(&port->dev, "%s - RX error!!!!\n", __func__); |
329 | for (i = 0; i + 1 < urb->actual_length; i += 2) { | 326 | for (i = 0; i + 1 < urb->actual_length; i += 2) { |
330 | int stat = data[i], flag = 0; | 327 | int stat = data[i], flag = 0; |
331 | if (stat & RXERROR_OVERRUN) | 328 | if (stat & RXERROR_OVERRUN) |
@@ -345,7 +342,7 @@ static void usa26_indat_callback(struct urb *urb) | |||
345 | /* Resubmit urb so we continue receiving */ | 342 | /* Resubmit urb so we continue receiving */ |
346 | err = usb_submit_urb(urb, GFP_ATOMIC); | 343 | err = usb_submit_urb(urb, GFP_ATOMIC); |
347 | if (err != 0) | 344 | if (err != 0) |
348 | dbg("%s - resubmit read urb failed. (%d)", __func__, err); | 345 | dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err); |
349 | } | 346 | } |
350 | 347 | ||
351 | /* Outdat handling is common for all devices */ | 348 | /* Outdat handling is common for all devices */ |
@@ -356,7 +353,7 @@ static void usa2x_outdat_callback(struct urb *urb) | |||
356 | 353 | ||
357 | port = urb->context; | 354 | port = urb->context; |
358 | p_priv = usb_get_serial_port_data(port); | 355 | p_priv = usb_get_serial_port_data(port); |
359 | dbg("%s - urb %d", __func__, urb == p_priv->out_urbs[1]); | 356 | dev_dbg(&port->dev, "%s - urb %d\n", __func__, urb == p_priv->out_urbs[1]); |
360 | 357 | ||
361 | usb_serial_port_softint(port); | 358 | usb_serial_port_softint(port); |
362 | } | 359 | } |
@@ -374,7 +371,7 @@ static void usa26_outcont_callback(struct urb *urb) | |||
374 | p_priv = usb_get_serial_port_data(port); | 371 | p_priv = usb_get_serial_port_data(port); |
375 | 372 | ||
376 | if (p_priv->resend_cont) { | 373 | if (p_priv->resend_cont) { |
377 | dbg("%s - sending setup", __func__); | 374 | dev_dbg(&port->dev, "%s - sending setup\n", __func__); |
378 | keyspan_usa26_send_setup(port->serial, port, | 375 | keyspan_usa26_send_setup(port->serial, port, |
379 | p_priv->resend_cont - 1); | 376 | p_priv->resend_cont - 1); |
380 | } | 377 | } |
@@ -394,20 +391,22 @@ static void usa26_instat_callback(struct urb *urb) | |||
394 | serial = urb->context; | 391 | serial = urb->context; |
395 | 392 | ||
396 | if (status) { | 393 | if (status) { |
397 | dbg("%s - nonzero status: %x", __func__, status); | 394 | dev_dbg(&urb->dev->dev, "%s - nonzero status: %x\n", __func__, status); |
398 | return; | 395 | return; |
399 | } | 396 | } |
400 | if (urb->actual_length != 9) { | 397 | if (urb->actual_length != 9) { |
401 | dbg("%s - %d byte report??", __func__, urb->actual_length); | 398 | dev_dbg(&urb->dev->dev, "%s - %d byte report??\n", __func__, urb->actual_length); |
402 | goto exit; | 399 | goto exit; |
403 | } | 400 | } |
404 | 401 | ||
405 | msg = (struct keyspan_usa26_portStatusMessage *)data; | 402 | msg = (struct keyspan_usa26_portStatusMessage *)data; |
406 | 403 | ||
407 | #if 0 | 404 | #if 0 |
408 | dbg("%s - port status: port %d cts %d dcd %d dsr %d ri %d toff %d txoff %d rxen %d cr %d", | 405 | dev_dbg(&urb->dev->dev, |
409 | __func__, msg->port, msg->hskia_cts, msg->gpia_dcd, msg->dsr, msg->ri, msg->_txOff, | 406 | "%s - port status: port %d cts %d dcd %d dsr %d ri %d toff %d txoff %d rxen %d cr %d", |
410 | msg->_txXoff, msg->rxEnabled, msg->controlResponse); | 407 | __func__, msg->port, msg->hskia_cts, msg->gpia_dcd, msg->dsr, |
408 | msg->ri, msg->_txOff, msg->_txXoff, msg->rxEnabled, | ||
409 | msg->controlResponse); | ||
411 | #endif | 410 | #endif |
412 | 411 | ||
413 | /* Now do something useful with the data */ | 412 | /* Now do something useful with the data */ |
@@ -415,7 +414,7 @@ static void usa26_instat_callback(struct urb *urb) | |||
415 | 414 | ||
416 | /* Check port number from message and retrieve private data */ | 415 | /* Check port number from message and retrieve private data */ |
417 | if (msg->port >= serial->num_ports) { | 416 | if (msg->port >= serial->num_ports) { |
418 | dbg("%s - Unexpected port number %d", __func__, msg->port); | 417 | dev_dbg(&urb->dev->dev, "%s - Unexpected port number %d\n", __func__, msg->port); |
419 | goto exit; | 418 | goto exit; |
420 | } | 419 | } |
421 | port = serial->port[msg->port]; | 420 | port = serial->port[msg->port]; |
@@ -438,7 +437,7 @@ static void usa26_instat_callback(struct urb *urb) | |||
438 | /* Resubmit urb so we continue receiving */ | 437 | /* Resubmit urb so we continue receiving */ |
439 | err = usb_submit_urb(urb, GFP_ATOMIC); | 438 | err = usb_submit_urb(urb, GFP_ATOMIC); |
440 | if (err != 0) | 439 | if (err != 0) |
441 | dbg("%s - resubmit read urb failed. (%d)", __func__, err); | 440 | dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err); |
442 | exit: ; | 441 | exit: ; |
443 | } | 442 | } |
444 | 443 | ||
@@ -465,8 +464,8 @@ static void usa28_indat_callback(struct urb *urb) | |||
465 | 464 | ||
466 | do { | 465 | do { |
467 | if (status) { | 466 | if (status) { |
468 | dbg("%s - nonzero status: %x on endpoint %d.", | 467 | dev_dbg(&urb->dev->dev, "%s - nonzero status: %x on endpoint %d.\n", |
469 | __func__, status, usb_pipeendpoint(urb->pipe)); | 468 | __func__, status, usb_pipeendpoint(urb->pipe)); |
470 | return; | 469 | return; |
471 | } | 470 | } |
472 | 471 | ||
@@ -484,7 +483,7 @@ static void usa28_indat_callback(struct urb *urb) | |||
484 | /* Resubmit urb so we continue receiving */ | 483 | /* Resubmit urb so we continue receiving */ |
485 | err = usb_submit_urb(urb, GFP_ATOMIC); | 484 | err = usb_submit_urb(urb, GFP_ATOMIC); |
486 | if (err != 0) | 485 | if (err != 0) |
487 | dbg("%s - resubmit read urb failed. (%d)", | 486 | dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n", |
488 | __func__, err); | 487 | __func__, err); |
489 | p_priv->in_flip ^= 1; | 488 | p_priv->in_flip ^= 1; |
490 | 489 | ||
@@ -505,7 +504,7 @@ static void usa28_outcont_callback(struct urb *urb) | |||
505 | p_priv = usb_get_serial_port_data(port); | 504 | p_priv = usb_get_serial_port_data(port); |
506 | 505 | ||
507 | if (p_priv->resend_cont) { | 506 | if (p_priv->resend_cont) { |
508 | dbg("%s - sending setup", __func__); | 507 | dev_dbg(&port->dev, "%s - sending setup\n", __func__); |
509 | keyspan_usa28_send_setup(port->serial, port, | 508 | keyspan_usa28_send_setup(port->serial, port, |
510 | p_priv->resend_cont - 1); | 509 | p_priv->resend_cont - 1); |
511 | } | 510 | } |
@@ -526,25 +525,28 @@ static void usa28_instat_callback(struct urb *urb) | |||
526 | serial = urb->context; | 525 | serial = urb->context; |
527 | 526 | ||
528 | if (status) { | 527 | if (status) { |
529 | dbg("%s - nonzero status: %x", __func__, status); | 528 | dev_dbg(&urb->dev->dev, "%s - nonzero status: %x\n", __func__, status); |
530 | return; | 529 | return; |
531 | } | 530 | } |
532 | 531 | ||
533 | if (urb->actual_length != sizeof(struct keyspan_usa28_portStatusMessage)) { | 532 | if (urb->actual_length != sizeof(struct keyspan_usa28_portStatusMessage)) { |
534 | dbg("%s - bad length %d", __func__, urb->actual_length); | 533 | dev_dbg(&urb->dev->dev, "%s - bad length %d\n", __func__, urb->actual_length); |
535 | goto exit; | 534 | goto exit; |
536 | } | 535 | } |
537 | 536 | ||
538 | /*dbg("%s %x %x %x %x %x %x %x %x %x %x %x %x", __func__ | 537 | /* |
539 | data[0], data[1], data[2], data[3], data[4], data[5], | 538 | dev_dbg(&urb->dev->dev, |
540 | data[6], data[7], data[8], data[9], data[10], data[11]);*/ | 539 | "%s %x %x %x %x %x %x %x %x %x %x %x %x", __func__, |
540 | data[0], data[1], data[2], data[3], data[4], data[5], | ||
541 | data[6], data[7], data[8], data[9], data[10], data[11]); | ||
542 | */ | ||
541 | 543 | ||
542 | /* Now do something useful with the data */ | 544 | /* Now do something useful with the data */ |
543 | msg = (struct keyspan_usa28_portStatusMessage *)data; | 545 | msg = (struct keyspan_usa28_portStatusMessage *)data; |
544 | 546 | ||
545 | /* Check port number from message and retrieve private data */ | 547 | /* Check port number from message and retrieve private data */ |
546 | if (msg->port >= serial->num_ports) { | 548 | if (msg->port >= serial->num_ports) { |
547 | dbg("%s - Unexpected port number %d", __func__, msg->port); | 549 | dev_dbg(&urb->dev->dev, "%s - Unexpected port number %d\n", __func__, msg->port); |
548 | goto exit; | 550 | goto exit; |
549 | } | 551 | } |
550 | port = serial->port[msg->port]; | 552 | port = serial->port[msg->port]; |
@@ -567,7 +569,7 @@ static void usa28_instat_callback(struct urb *urb) | |||
567 | /* Resubmit urb so we continue receiving */ | 569 | /* Resubmit urb so we continue receiving */ |
568 | err = usb_submit_urb(urb, GFP_ATOMIC); | 570 | err = usb_submit_urb(urb, GFP_ATOMIC); |
569 | if (err != 0) | 571 | if (err != 0) |
570 | dbg("%s - resubmit read urb failed. (%d)", __func__, err); | 572 | dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err); |
571 | exit: ; | 573 | exit: ; |
572 | } | 574 | } |
573 | 575 | ||
@@ -589,7 +591,7 @@ static void usa49_glocont_callback(struct urb *urb) | |||
589 | p_priv = usb_get_serial_port_data(port); | 591 | p_priv = usb_get_serial_port_data(port); |
590 | 592 | ||
591 | if (p_priv->resend_cont) { | 593 | if (p_priv->resend_cont) { |
592 | dbg("%s - sending setup", __func__); | 594 | dev_dbg(&port->dev, "%s - sending setup\n", __func__); |
593 | keyspan_usa49_send_setup(serial, port, | 595 | keyspan_usa49_send_setup(serial, port, |
594 | p_priv->resend_cont - 1); | 596 | p_priv->resend_cont - 1); |
595 | break; | 597 | break; |
@@ -613,27 +615,29 @@ static void usa49_instat_callback(struct urb *urb) | |||
613 | serial = urb->context; | 615 | serial = urb->context; |
614 | 616 | ||
615 | if (status) { | 617 | if (status) { |
616 | dbg("%s - nonzero status: %x", __func__, status); | 618 | dev_dbg(&urb->dev->dev, "%s - nonzero status: %x\n", __func__, status); |
617 | return; | 619 | return; |
618 | } | 620 | } |
619 | 621 | ||
620 | if (urb->actual_length != | 622 | if (urb->actual_length != |
621 | sizeof(struct keyspan_usa49_portStatusMessage)) { | 623 | sizeof(struct keyspan_usa49_portStatusMessage)) { |
622 | dbg("%s - bad length %d", __func__, urb->actual_length); | 624 | dev_dbg(&urb->dev->dev, "%s - bad length %d\n", __func__, urb->actual_length); |
623 | goto exit; | 625 | goto exit; |
624 | } | 626 | } |
625 | 627 | ||
626 | /*dbg(" %x %x %x %x %x %x %x %x %x %x %x", __func__, | 628 | /* |
627 | data[0], data[1], data[2], data[3], data[4], data[5], | 629 | dev_dbg(&urb->dev->dev, "%s: %x %x %x %x %x %x %x %x %x %x %x", |
628 | data[6], data[7], data[8], data[9], data[10]);*/ | 630 | __func__, data[0], data[1], data[2], data[3], data[4], |
631 | data[5], data[6], data[7], data[8], data[9], data[10]); | ||
632 | */ | ||
629 | 633 | ||
630 | /* Now do something useful with the data */ | 634 | /* Now do something useful with the data */ |
631 | msg = (struct keyspan_usa49_portStatusMessage *)data; | 635 | msg = (struct keyspan_usa49_portStatusMessage *)data; |
632 | 636 | ||
633 | /* Check port number from message and retrieve private data */ | 637 | /* Check port number from message and retrieve private data */ |
634 | if (msg->portNumber >= serial->num_ports) { | 638 | if (msg->portNumber >= serial->num_ports) { |
635 | dbg("%s - Unexpected port number %d", | 639 | dev_dbg(&urb->dev->dev, "%s - Unexpected port number %d\n", |
636 | __func__, msg->portNumber); | 640 | __func__, msg->portNumber); |
637 | goto exit; | 641 | goto exit; |
638 | } | 642 | } |
639 | port = serial->port[msg->portNumber]; | 643 | port = serial->port[msg->portNumber]; |
@@ -656,7 +660,7 @@ static void usa49_instat_callback(struct urb *urb) | |||
656 | /* Resubmit urb so we continue receiving */ | 660 | /* Resubmit urb so we continue receiving */ |
657 | err = usb_submit_urb(urb, GFP_ATOMIC); | 661 | err = usb_submit_urb(urb, GFP_ATOMIC); |
658 | if (err != 0) | 662 | if (err != 0) |
659 | dbg("%s - resubmit read urb failed. (%d)", __func__, err); | 663 | dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err); |
660 | exit: ; | 664 | exit: ; |
661 | } | 665 | } |
662 | 666 | ||
@@ -676,8 +680,8 @@ static void usa49_indat_callback(struct urb *urb) | |||
676 | endpoint = usb_pipeendpoint(urb->pipe); | 680 | endpoint = usb_pipeendpoint(urb->pipe); |
677 | 681 | ||
678 | if (status) { | 682 | if (status) { |
679 | dbg("%s - nonzero status: %x on endpoint %d.", __func__, | 683 | dev_dbg(&urb->dev->dev, "%s - nonzero status: %x on endpoint %d.\n", |
680 | status, endpoint); | 684 | __func__, status, endpoint); |
681 | return; | 685 | return; |
682 | } | 686 | } |
683 | 687 | ||
@@ -710,7 +714,7 @@ static void usa49_indat_callback(struct urb *urb) | |||
710 | /* Resubmit urb so we continue receiving */ | 714 | /* Resubmit urb so we continue receiving */ |
711 | err = usb_submit_urb(urb, GFP_ATOMIC); | 715 | err = usb_submit_urb(urb, GFP_ATOMIC); |
712 | if (err != 0) | 716 | if (err != 0) |
713 | dbg("%s - resubmit read urb failed. (%d)", __func__, err); | 717 | dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err); |
714 | } | 718 | } |
715 | 719 | ||
716 | static void usa49wg_indat_callback(struct urb *urb) | 720 | static void usa49wg_indat_callback(struct urb *urb) |
@@ -725,7 +729,7 @@ static void usa49wg_indat_callback(struct urb *urb) | |||
725 | serial = urb->context; | 729 | serial = urb->context; |
726 | 730 | ||
727 | if (status) { | 731 | if (status) { |
728 | dbg("%s - nonzero status: %x", __func__, status); | 732 | dev_dbg(&urb->dev->dev, "%s - nonzero status: %x\n", __func__, status); |
729 | return; | 733 | return; |
730 | } | 734 | } |
731 | 735 | ||
@@ -738,7 +742,7 @@ static void usa49wg_indat_callback(struct urb *urb) | |||
738 | 742 | ||
739 | /* Check port number from message*/ | 743 | /* Check port number from message*/ |
740 | if (data[i] >= serial->num_ports) { | 744 | if (data[i] >= serial->num_ports) { |
741 | dbg("%s - Unexpected port number %d", | 745 | dev_dbg(&urb->dev->dev, "%s - Unexpected port number %d\n", |
742 | __func__, data[i]); | 746 | __func__, data[i]); |
743 | return; | 747 | return; |
744 | } | 748 | } |
@@ -778,7 +782,7 @@ static void usa49wg_indat_callback(struct urb *urb) | |||
778 | /* Resubmit urb so we continue receiving */ | 782 | /* Resubmit urb so we continue receiving */ |
779 | err = usb_submit_urb(urb, GFP_ATOMIC); | 783 | err = usb_submit_urb(urb, GFP_ATOMIC); |
780 | if (err != 0) | 784 | if (err != 0) |
781 | dbg("%s - resubmit read urb failed. (%d)", __func__, err); | 785 | dev_dbg(&urb->dev->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err); |
782 | } | 786 | } |
783 | 787 | ||
784 | /* not used, usa-49 doesn't have per-port control endpoints */ | 788 | /* not used, usa-49 doesn't have per-port control endpoints */ |
@@ -799,7 +803,7 @@ static void usa90_indat_callback(struct urb *urb) | |||
799 | endpoint = usb_pipeendpoint(urb->pipe); | 803 | endpoint = usb_pipeendpoint(urb->pipe); |
800 | 804 | ||
801 | if (status) { | 805 | if (status) { |
802 | dbg("%s - nonzero status: %x on endpoint %d.", | 806 | dev_dbg(&urb->dev->dev, "%s - nonzero status: %x on endpoint %d.\n", |
803 | __func__, status, endpoint); | 807 | __func__, status, endpoint); |
804 | return; | 808 | return; |
805 | } | 809 | } |
@@ -828,7 +832,7 @@ static void usa90_indat_callback(struct urb *urb) | |||
828 | err); | 832 | err); |
829 | } else { | 833 | } else { |
830 | /* some bytes had errors, every byte has status */ | 834 | /* some bytes had errors, every byte has status */ |
831 | dbg("%s - RX error!!!!", __func__); | 835 | dev_dbg(&port->dev, "%s - RX error!!!!\n", __func__); |
832 | for (i = 0; i + 1 < urb->actual_length; i += 2) { | 836 | for (i = 0; i + 1 < urb->actual_length; i += 2) { |
833 | int stat = data[i], flag = 0; | 837 | int stat = data[i], flag = 0; |
834 | if (stat & RXERROR_OVERRUN) | 838 | if (stat & RXERROR_OVERRUN) |
@@ -850,7 +854,7 @@ static void usa90_indat_callback(struct urb *urb) | |||
850 | /* Resubmit urb so we continue receiving */ | 854 | /* Resubmit urb so we continue receiving */ |
851 | err = usb_submit_urb(urb, GFP_ATOMIC); | 855 | err = usb_submit_urb(urb, GFP_ATOMIC); |
852 | if (err != 0) | 856 | if (err != 0) |
853 | dbg("%s - resubmit read urb failed. (%d)", __func__, err); | 857 | dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err); |
854 | } | 858 | } |
855 | 859 | ||
856 | 860 | ||
@@ -868,11 +872,11 @@ static void usa90_instat_callback(struct urb *urb) | |||
868 | serial = urb->context; | 872 | serial = urb->context; |
869 | 873 | ||
870 | if (status) { | 874 | if (status) { |
871 | dbg("%s - nonzero status: %x", __func__, status); | 875 | dev_dbg(&urb->dev->dev, "%s - nonzero status: %x\n", __func__, status); |
872 | return; | 876 | return; |
873 | } | 877 | } |
874 | if (urb->actual_length < 14) { | 878 | if (urb->actual_length < 14) { |
875 | dbg("%s - %d byte report??", __func__, urb->actual_length); | 879 | dev_dbg(&urb->dev->dev, "%s - %d byte report??\n", __func__, urb->actual_length); |
876 | goto exit; | 880 | goto exit; |
877 | } | 881 | } |
878 | 882 | ||
@@ -900,7 +904,7 @@ static void usa90_instat_callback(struct urb *urb) | |||
900 | /* Resubmit urb so we continue receiving */ | 904 | /* Resubmit urb so we continue receiving */ |
901 | err = usb_submit_urb(urb, GFP_ATOMIC); | 905 | err = usb_submit_urb(urb, GFP_ATOMIC); |
902 | if (err != 0) | 906 | if (err != 0) |
903 | dbg("%s - resubmit read urb failed. (%d)", __func__, err); | 907 | dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err); |
904 | exit: | 908 | exit: |
905 | ; | 909 | ; |
906 | } | 910 | } |
@@ -914,7 +918,7 @@ static void usa90_outcont_callback(struct urb *urb) | |||
914 | p_priv = usb_get_serial_port_data(port); | 918 | p_priv = usb_get_serial_port_data(port); |
915 | 919 | ||
916 | if (p_priv->resend_cont) { | 920 | if (p_priv->resend_cont) { |
917 | dbg("%s - sending setup", __func__); | 921 | dev_dbg(&urb->dev->dev, "%s - sending setup\n", __func__); |
918 | keyspan_usa90_send_setup(port->serial, port, | 922 | keyspan_usa90_send_setup(port->serial, port, |
919 | p_priv->resend_cont - 1); | 923 | p_priv->resend_cont - 1); |
920 | } | 924 | } |
@@ -935,13 +939,13 @@ static void usa67_instat_callback(struct urb *urb) | |||
935 | serial = urb->context; | 939 | serial = urb->context; |
936 | 940 | ||
937 | if (status) { | 941 | if (status) { |
938 | dbg("%s - nonzero status: %x", __func__, status); | 942 | dev_dbg(&urb->dev->dev, "%s - nonzero status: %x\n", __func__, status); |
939 | return; | 943 | return; |
940 | } | 944 | } |
941 | 945 | ||
942 | if (urb->actual_length != | 946 | if (urb->actual_length != |
943 | sizeof(struct keyspan_usa67_portStatusMessage)) { | 947 | sizeof(struct keyspan_usa67_portStatusMessage)) { |
944 | dbg("%s - bad length %d", __func__, urb->actual_length); | 948 | dev_dbg(&urb->dev->dev, "%s - bad length %d\n", __func__, urb->actual_length); |
945 | return; | 949 | return; |
946 | } | 950 | } |
947 | 951 | ||
@@ -951,7 +955,7 @@ static void usa67_instat_callback(struct urb *urb) | |||
951 | 955 | ||
952 | /* Check port number from message and retrieve private data */ | 956 | /* Check port number from message and retrieve private data */ |
953 | if (msg->port >= serial->num_ports) { | 957 | if (msg->port >= serial->num_ports) { |
954 | dbg("%s - Unexpected port number %d", __func__, msg->port); | 958 | dev_dbg(&urb->dev->dev, "%s - Unexpected port number %d\n", __func__, msg->port); |
955 | return; | 959 | return; |
956 | } | 960 | } |
957 | 961 | ||
@@ -973,7 +977,7 @@ static void usa67_instat_callback(struct urb *urb) | |||
973 | /* Resubmit urb so we continue receiving */ | 977 | /* Resubmit urb so we continue receiving */ |
974 | err = usb_submit_urb(urb, GFP_ATOMIC); | 978 | err = usb_submit_urb(urb, GFP_ATOMIC); |
975 | if (err != 0) | 979 | if (err != 0) |
976 | dbg("%s - resubmit read urb failed. (%d)", __func__, err); | 980 | dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err); |
977 | } | 981 | } |
978 | 982 | ||
979 | static void usa67_glocont_callback(struct urb *urb) | 983 | static void usa67_glocont_callback(struct urb *urb) |
@@ -989,7 +993,7 @@ static void usa67_glocont_callback(struct urb *urb) | |||
989 | p_priv = usb_get_serial_port_data(port); | 993 | p_priv = usb_get_serial_port_data(port); |
990 | 994 | ||
991 | if (p_priv->resend_cont) { | 995 | if (p_priv->resend_cont) { |
992 | dbg("%s - sending setup", __func__); | 996 | dev_dbg(&port->dev, "%s - sending setup\n", __func__); |
993 | keyspan_usa67_send_setup(serial, port, | 997 | keyspan_usa67_send_setup(serial, port, |
994 | p_priv->resend_cont - 1); | 998 | p_priv->resend_cont - 1); |
995 | break; | 999 | break; |
@@ -1068,8 +1072,7 @@ static int keyspan_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
1068 | usb_clear_halt(urb->dev, urb->pipe); | 1072 | usb_clear_halt(urb->dev, urb->pipe); |
1069 | err = usb_submit_urb(urb, GFP_KERNEL); | 1073 | err = usb_submit_urb(urb, GFP_KERNEL); |
1070 | if (err != 0) | 1074 | if (err != 0) |
1071 | dbg("%s - submit urb %d failed (%d)", | 1075 | dev_dbg(&port->dev, "%s - submit urb %d failed (%d)\n", __func__, i, err); |
1072 | __func__, i, err); | ||
1073 | } | 1076 | } |
1074 | 1077 | ||
1075 | /* Reset low level data toggle on out endpoints */ | 1078 | /* Reset low level data toggle on out endpoints */ |
@@ -1092,7 +1095,7 @@ static int keyspan_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
1092 | baud_rate = tty_get_baud_rate(tty); | 1095 | baud_rate = tty_get_baud_rate(tty); |
1093 | /* If no match or invalid, leave as default */ | 1096 | /* If no match or invalid, leave as default */ |
1094 | if (baud_rate >= 0 | 1097 | if (baud_rate >= 0 |
1095 | && d_details->calculate_baud_rate(baud_rate, d_details->baudclk, | 1098 | && d_details->calculate_baud_rate(port, baud_rate, d_details->baudclk, |
1096 | NULL, NULL, NULL, device_port) == KEYSPAN_BAUD_RATE_OK) { | 1099 | NULL, NULL, NULL, device_port) == KEYSPAN_BAUD_RATE_OK) { |
1097 | p_priv->baud = baud_rate; | 1100 | p_priv->baud = baud_rate; |
1098 | } | 1101 | } |
@@ -1142,7 +1145,7 @@ static void keyspan_close(struct usb_serial_port *port) | |||
1142 | } | 1145 | } |
1143 | 1146 | ||
1144 | /*while (p_priv->outcont_urb->status == -EINPROGRESS) { | 1147 | /*while (p_priv->outcont_urb->status == -EINPROGRESS) { |
1145 | dbg("%s - urb in progress", __func__); | 1148 | dev_dbg(&port->dev, "%s - urb in progress\n", __func__); |
1146 | }*/ | 1149 | }*/ |
1147 | 1150 | ||
1148 | p_priv->out_flip = 0; | 1151 | p_priv->out_flip = 0; |
@@ -1162,18 +1165,15 @@ static void keyspan_close(struct usb_serial_port *port) | |||
1162 | /* download the firmware to a pre-renumeration device */ | 1165 | /* download the firmware to a pre-renumeration device */ |
1163 | static int keyspan_fake_startup(struct usb_serial *serial) | 1166 | static int keyspan_fake_startup(struct usb_serial *serial) |
1164 | { | 1167 | { |
1165 | int response; | 1168 | char *fw_name; |
1166 | const struct ihex_binrec *record; | ||
1167 | char *fw_name; | ||
1168 | const struct firmware *fw; | ||
1169 | 1169 | ||
1170 | dbg("Keyspan startup version %04x product %04x", | 1170 | dev_dbg(&serial->dev->dev, "Keyspan startup version %04x product %04x\n", |
1171 | le16_to_cpu(serial->dev->descriptor.bcdDevice), | 1171 | le16_to_cpu(serial->dev->descriptor.bcdDevice), |
1172 | le16_to_cpu(serial->dev->descriptor.idProduct)); | 1172 | le16_to_cpu(serial->dev->descriptor.idProduct)); |
1173 | 1173 | ||
1174 | if ((le16_to_cpu(serial->dev->descriptor.bcdDevice) & 0x8000) | 1174 | if ((le16_to_cpu(serial->dev->descriptor.bcdDevice) & 0x8000) |
1175 | != 0x8000) { | 1175 | != 0x8000) { |
1176 | dbg("Firmware already loaded. Quitting."); | 1176 | dev_dbg(&serial->dev->dev, "Firmware already loaded. Quitting.\n"); |
1177 | return 1; | 1177 | return 1; |
1178 | } | 1178 | } |
1179 | 1179 | ||
@@ -1233,34 +1233,16 @@ static int keyspan_fake_startup(struct usb_serial *serial) | |||
1233 | return 1; | 1233 | return 1; |
1234 | } | 1234 | } |
1235 | 1235 | ||
1236 | if (request_ihex_firmware(&fw, fw_name, &serial->dev->dev)) { | 1236 | dev_dbg(&serial->dev->dev, "Uploading Keyspan %s firmware.\n", fw_name); |
1237 | dev_err(&serial->dev->dev, "Required keyspan firmware image (%s) unavailable.\n", fw_name); | ||
1238 | return 1; | ||
1239 | } | ||
1240 | |||
1241 | dbg("Uploading Keyspan %s firmware.", fw_name); | ||
1242 | 1237 | ||
1243 | /* download the firmware image */ | 1238 | if (ezusb_fx1_ihex_firmware_download(serial->dev, fw_name) < 0) { |
1244 | response = ezusb_set_reset(serial, 1); | 1239 | dev_err(&serial->dev->dev, "failed to load firmware \"%s\"\n", |
1245 | 1240 | fw_name); | |
1246 | record = (const struct ihex_binrec *)fw->data; | 1241 | return -ENOENT; |
1247 | |||
1248 | while (record) { | ||
1249 | response = ezusb_writememory(serial, be32_to_cpu(record->addr), | ||
1250 | (unsigned char *)record->data, | ||
1251 | be16_to_cpu(record->len), 0xa0); | ||
1252 | if (response < 0) { | ||
1253 | dev_err(&serial->dev->dev, "ezusb_writememory failed for Keyspan firmware (%d %04X %p %d)\n", | ||
1254 | response, be32_to_cpu(record->addr), | ||
1255 | record->data, be16_to_cpu(record->len)); | ||
1256 | break; | ||
1257 | } | ||
1258 | record = ihex_next_binrec(record); | ||
1259 | } | 1242 | } |
1260 | release_firmware(fw); | 1243 | |
1261 | /* bring device out of reset. Renumeration will occur in a | 1244 | /* after downloading firmware Renumeration will occur in a |
1262 | moment and the new device will bind to the real driver */ | 1245 | moment and the new device will bind to the real driver */ |
1263 | response = ezusb_set_reset(serial, 0); | ||
1264 | 1246 | ||
1265 | /* we don't want this device to have a driver assigned to it. */ | 1247 | /* we don't want this device to have a driver assigned to it. */ |
1266 | return 1; | 1248 | return 1; |
@@ -1296,10 +1278,10 @@ static struct urb *keyspan_setup_urb(struct usb_serial *serial, int endpoint, | |||
1296 | if (endpoint == -1) | 1278 | if (endpoint == -1) |
1297 | return NULL; /* endpoint not needed */ | 1279 | return NULL; /* endpoint not needed */ |
1298 | 1280 | ||
1299 | dbg("%s - alloc for endpoint %d.", __func__, endpoint); | 1281 | dev_dbg(&serial->interface->dev, "%s - alloc for endpoint %d.\n", __func__, endpoint); |
1300 | urb = usb_alloc_urb(0, GFP_KERNEL); /* No ISO */ | 1282 | urb = usb_alloc_urb(0, GFP_KERNEL); /* No ISO */ |
1301 | if (urb == NULL) { | 1283 | if (urb == NULL) { |
1302 | dbg("%s - alloc for endpoint %d failed.", __func__, endpoint); | 1284 | dev_dbg(&serial->interface->dev, "%s - alloc for endpoint %d failed.\n", __func__, endpoint); |
1303 | return NULL; | 1285 | return NULL; |
1304 | } | 1286 | } |
1305 | 1287 | ||
@@ -1332,7 +1314,7 @@ static struct urb *keyspan_setup_urb(struct usb_serial *serial, int endpoint, | |||
1332 | return NULL; | 1314 | return NULL; |
1333 | } | 1315 | } |
1334 | 1316 | ||
1335 | dbg("%s - using urb %p for %s endpoint %x", | 1317 | dev_dbg(&serial->interface->dev, "%s - using urb %p for %s endpoint %x\n", |
1336 | __func__, urb, ep_type_name, endpoint); | 1318 | __func__, urb, ep_type_name, endpoint); |
1337 | return urb; | 1319 | return urb; |
1338 | } | 1320 | } |
@@ -1464,14 +1446,15 @@ static void keyspan_setup_urbs(struct usb_serial *serial) | |||
1464 | } | 1446 | } |
1465 | 1447 | ||
1466 | /* usa19 function doesn't require prescaler */ | 1448 | /* usa19 function doesn't require prescaler */ |
1467 | static int keyspan_usa19_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi, | 1449 | static int keyspan_usa19_calc_baud(struct usb_serial_port *port, |
1450 | u32 baud_rate, u32 baudclk, u8 *rate_hi, | ||
1468 | u8 *rate_low, u8 *prescaler, int portnum) | 1451 | u8 *rate_low, u8 *prescaler, int portnum) |
1469 | { | 1452 | { |
1470 | u32 b16, /* baud rate times 16 (actual rate used internally) */ | 1453 | u32 b16, /* baud rate times 16 (actual rate used internally) */ |
1471 | div, /* divisor */ | 1454 | div, /* divisor */ |
1472 | cnt; /* inverse of divisor (programmed into 8051) */ | 1455 | cnt; /* inverse of divisor (programmed into 8051) */ |
1473 | 1456 | ||
1474 | dbg("%s - %d.", __func__, baud_rate); | 1457 | dev_dbg(&port->dev, "%s - %d.\n", __func__, baud_rate); |
1475 | 1458 | ||
1476 | /* prevent divide by zero... */ | 1459 | /* prevent divide by zero... */ |
1477 | b16 = baud_rate * 16L; | 1460 | b16 = baud_rate * 16L; |
@@ -1498,19 +1481,20 @@ static int keyspan_usa19_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi, | |||
1498 | if (rate_hi) | 1481 | if (rate_hi) |
1499 | *rate_hi = (u8) ((cnt >> 8) & 0xff); | 1482 | *rate_hi = (u8) ((cnt >> 8) & 0xff); |
1500 | if (rate_low && rate_hi) | 1483 | if (rate_low && rate_hi) |
1501 | dbg("%s - %d %02x %02x.", | 1484 | dev_dbg(&port->dev, "%s - %d %02x %02x.\n", |
1502 | __func__, baud_rate, *rate_hi, *rate_low); | 1485 | __func__, baud_rate, *rate_hi, *rate_low); |
1503 | return KEYSPAN_BAUD_RATE_OK; | 1486 | return KEYSPAN_BAUD_RATE_OK; |
1504 | } | 1487 | } |
1505 | 1488 | ||
1506 | /* usa19hs function doesn't require prescaler */ | 1489 | /* usa19hs function doesn't require prescaler */ |
1507 | static int keyspan_usa19hs_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi, | 1490 | static int keyspan_usa19hs_calc_baud(struct usb_serial_port *port, |
1508 | u8 *rate_low, u8 *prescaler, int portnum) | 1491 | u32 baud_rate, u32 baudclk, u8 *rate_hi, |
1492 | u8 *rate_low, u8 *prescaler, int portnum) | ||
1509 | { | 1493 | { |
1510 | u32 b16, /* baud rate times 16 (actual rate used internally) */ | 1494 | u32 b16, /* baud rate times 16 (actual rate used internally) */ |
1511 | div; /* divisor */ | 1495 | div; /* divisor */ |
1512 | 1496 | ||
1513 | dbg("%s - %d.", __func__, baud_rate); | 1497 | dev_dbg(&port->dev, "%s - %d.\n", __func__, baud_rate); |
1514 | 1498 | ||
1515 | /* prevent divide by zero... */ | 1499 | /* prevent divide by zero... */ |
1516 | b16 = baud_rate * 16L; | 1500 | b16 = baud_rate * 16L; |
@@ -1533,13 +1517,14 @@ static int keyspan_usa19hs_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi, | |||
1533 | *rate_hi = (u8) ((div >> 8) & 0xff); | 1517 | *rate_hi = (u8) ((div >> 8) & 0xff); |
1534 | 1518 | ||
1535 | if (rate_low && rate_hi) | 1519 | if (rate_low && rate_hi) |
1536 | dbg("%s - %d %02x %02x.", | 1520 | dev_dbg(&port->dev, "%s - %d %02x %02x.\n", |
1537 | __func__, baud_rate, *rate_hi, *rate_low); | 1521 | __func__, baud_rate, *rate_hi, *rate_low); |
1538 | 1522 | ||
1539 | return KEYSPAN_BAUD_RATE_OK; | 1523 | return KEYSPAN_BAUD_RATE_OK; |
1540 | } | 1524 | } |
1541 | 1525 | ||
1542 | static int keyspan_usa19w_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi, | 1526 | static int keyspan_usa19w_calc_baud(struct usb_serial_port *port, |
1527 | u32 baud_rate, u32 baudclk, u8 *rate_hi, | ||
1543 | u8 *rate_low, u8 *prescaler, int portnum) | 1528 | u8 *rate_low, u8 *prescaler, int portnum) |
1544 | { | 1529 | { |
1545 | u32 b16, /* baud rate times 16 (actual rate used internally) */ | 1530 | u32 b16, /* baud rate times 16 (actual rate used internally) */ |
@@ -1551,7 +1536,7 @@ static int keyspan_usa19w_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi, | |||
1551 | u8 best_prescaler; | 1536 | u8 best_prescaler; |
1552 | int i; | 1537 | int i; |
1553 | 1538 | ||
1554 | dbg("%s - %d.", __func__, baud_rate); | 1539 | dev_dbg(&port->dev, "%s - %d.\n", __func__, baud_rate); |
1555 | 1540 | ||
1556 | /* prevent divide by zero */ | 1541 | /* prevent divide by zero */ |
1557 | b16 = baud_rate * 16L; | 1542 | b16 = baud_rate * 16L; |
@@ -1596,20 +1581,21 @@ static int keyspan_usa19w_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi, | |||
1596 | *rate_hi = (u8) ((div >> 8) & 0xff); | 1581 | *rate_hi = (u8) ((div >> 8) & 0xff); |
1597 | if (prescaler) { | 1582 | if (prescaler) { |
1598 | *prescaler = best_prescaler; | 1583 | *prescaler = best_prescaler; |
1599 | /* dbg("%s - %d %d", __func__, *prescaler, div); */ | 1584 | /* dev_dbg(&port->dev, "%s - %d %d\n", __func__, *prescaler, div); */ |
1600 | } | 1585 | } |
1601 | return KEYSPAN_BAUD_RATE_OK; | 1586 | return KEYSPAN_BAUD_RATE_OK; |
1602 | } | 1587 | } |
1603 | 1588 | ||
1604 | /* USA-28 supports different maximum baud rates on each port */ | 1589 | /* USA-28 supports different maximum baud rates on each port */ |
1605 | static int keyspan_usa28_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi, | 1590 | static int keyspan_usa28_calc_baud(struct usb_serial_port *port, |
1606 | u8 *rate_low, u8 *prescaler, int portnum) | 1591 | u32 baud_rate, u32 baudclk, u8 *rate_hi, |
1592 | u8 *rate_low, u8 *prescaler, int portnum) | ||
1607 | { | 1593 | { |
1608 | u32 b16, /* baud rate times 16 (actual rate used internally) */ | 1594 | u32 b16, /* baud rate times 16 (actual rate used internally) */ |
1609 | div, /* divisor */ | 1595 | div, /* divisor */ |
1610 | cnt; /* inverse of divisor (programmed into 8051) */ | 1596 | cnt; /* inverse of divisor (programmed into 8051) */ |
1611 | 1597 | ||
1612 | dbg("%s - %d.", __func__, baud_rate); | 1598 | dev_dbg(&port->dev, "%s - %d.\n", __func__, baud_rate); |
1613 | 1599 | ||
1614 | /* prevent divide by zero */ | 1600 | /* prevent divide by zero */ |
1615 | b16 = baud_rate * 16L; | 1601 | b16 = baud_rate * 16L; |
@@ -1642,7 +1628,7 @@ static int keyspan_usa28_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi, | |||
1642 | *rate_low = (u8) (cnt & 0xff); | 1628 | *rate_low = (u8) (cnt & 0xff); |
1643 | if (rate_hi) | 1629 | if (rate_hi) |
1644 | *rate_hi = (u8) ((cnt >> 8) & 0xff); | 1630 | *rate_hi = (u8) ((cnt >> 8) & 0xff); |
1645 | dbg("%s - %d OK.", __func__, baud_rate); | 1631 | dev_dbg(&port->dev, "%s - %d OK.\n", __func__, baud_rate); |
1646 | return KEYSPAN_BAUD_RATE_OK; | 1632 | return KEYSPAN_BAUD_RATE_OK; |
1647 | } | 1633 | } |
1648 | 1634 | ||
@@ -1658,7 +1644,7 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial, | |||
1658 | struct urb *this_urb; | 1644 | struct urb *this_urb; |
1659 | int device_port, err; | 1645 | int device_port, err; |
1660 | 1646 | ||
1661 | dbg("%s reset=%d", __func__, reset_port); | 1647 | dev_dbg(&port->dev, "%s reset=%d\n", __func__, reset_port); |
1662 | 1648 | ||
1663 | s_priv = usb_get_serial_data(serial); | 1649 | s_priv = usb_get_serial_data(serial); |
1664 | p_priv = usb_get_serial_port_data(port); | 1650 | p_priv = usb_get_serial_port_data(port); |
@@ -1668,11 +1654,11 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial, | |||
1668 | outcont_urb = d_details->outcont_endpoints[port->number]; | 1654 | outcont_urb = d_details->outcont_endpoints[port->number]; |
1669 | this_urb = p_priv->outcont_urb; | 1655 | this_urb = p_priv->outcont_urb; |
1670 | 1656 | ||
1671 | dbg("%s - endpoint %d", __func__, usb_pipeendpoint(this_urb->pipe)); | 1657 | dev_dbg(&port->dev, "%s - endpoint %d\n", __func__, usb_pipeendpoint(this_urb->pipe)); |
1672 | 1658 | ||
1673 | /* Make sure we have an urb then send the message */ | 1659 | /* Make sure we have an urb then send the message */ |
1674 | if (this_urb == NULL) { | 1660 | if (this_urb == NULL) { |
1675 | dbg("%s - oops no urb.", __func__); | 1661 | dev_dbg(&port->dev, "%s - oops no urb.\n", __func__); |
1676 | return -1; | 1662 | return -1; |
1677 | } | 1663 | } |
1678 | 1664 | ||
@@ -1681,7 +1667,7 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial, | |||
1681 | if ((reset_port + 1) > p_priv->resend_cont) | 1667 | if ((reset_port + 1) > p_priv->resend_cont) |
1682 | p_priv->resend_cont = reset_port + 1; | 1668 | p_priv->resend_cont = reset_port + 1; |
1683 | if (this_urb->status == -EINPROGRESS) { | 1669 | if (this_urb->status == -EINPROGRESS) { |
1684 | /* dbg("%s - already writing", __func__); */ | 1670 | /* dev_dbg(&port->dev, "%s - already writing\n", __func__); */ |
1685 | mdelay(5); | 1671 | mdelay(5); |
1686 | return -1; | 1672 | return -1; |
1687 | } | 1673 | } |
@@ -1692,11 +1678,11 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial, | |||
1692 | if (p_priv->old_baud != p_priv->baud) { | 1678 | if (p_priv->old_baud != p_priv->baud) { |
1693 | p_priv->old_baud = p_priv->baud; | 1679 | p_priv->old_baud = p_priv->baud; |
1694 | msg.setClocking = 0xff; | 1680 | msg.setClocking = 0xff; |
1695 | if (d_details->calculate_baud_rate | 1681 | if (d_details->calculate_baud_rate(port, p_priv->baud, d_details->baudclk, |
1696 | (p_priv->baud, d_details->baudclk, &msg.baudHi, | 1682 | &msg.baudHi, &msg.baudLo, &msg.prescaler, |
1697 | &msg.baudLo, &msg.prescaler, device_port) == KEYSPAN_INVALID_BAUD_RATE) { | 1683 | device_port) == KEYSPAN_INVALID_BAUD_RATE) { |
1698 | dbg("%s - Invalid baud rate %d requested, using 9600.", | 1684 | dev_dbg(&port->dev, "%s - Invalid baud rate %d requested, using 9600.\n", |
1699 | __func__, p_priv->baud); | 1685 | __func__, p_priv->baud); |
1700 | msg.baudLo = 0; | 1686 | msg.baudLo = 0; |
1701 | msg.baudHi = 125; /* Values for 9600 baud */ | 1687 | msg.baudHi = 125; /* Values for 9600 baud */ |
1702 | msg.prescaler = 10; | 1688 | msg.prescaler = 10; |
@@ -1790,12 +1776,12 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial, | |||
1790 | 1776 | ||
1791 | err = usb_submit_urb(this_urb, GFP_ATOMIC); | 1777 | err = usb_submit_urb(this_urb, GFP_ATOMIC); |
1792 | if (err != 0) | 1778 | if (err != 0) |
1793 | dbg("%s - usb_submit_urb(setup) failed (%d)", __func__, err); | 1779 | dev_dbg(&port->dev, "%s - usb_submit_urb(setup) failed (%d)\n", __func__, err); |
1794 | #if 0 | 1780 | #if 0 |
1795 | else { | 1781 | else { |
1796 | dbg("%s - usb_submit_urb(%d) OK %d bytes (end %d)", __func__ | 1782 | dev_dbg(&port->dev, "%s - usb_submit_urb(%d) OK %d bytes (end %d)\n", __func__ |
1797 | outcont_urb, this_urb->transfer_buffer_length, | 1783 | outcont_urb, this_urb->transfer_buffer_length, |
1798 | usb_pipeendpoint(this_urb->pipe)); | 1784 | usb_pipeendpoint(this_urb->pipe)); |
1799 | } | 1785 | } |
1800 | #endif | 1786 | #endif |
1801 | 1787 | ||
@@ -1821,7 +1807,7 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial, | |||
1821 | /* only do something if we have a bulk out endpoint */ | 1807 | /* only do something if we have a bulk out endpoint */ |
1822 | this_urb = p_priv->outcont_urb; | 1808 | this_urb = p_priv->outcont_urb; |
1823 | if (this_urb == NULL) { | 1809 | if (this_urb == NULL) { |
1824 | dbg("%s - oops no urb.", __func__); | 1810 | dev_dbg(&port->dev, "%s - oops no urb.\n", __func__); |
1825 | return -1; | 1811 | return -1; |
1826 | } | 1812 | } |
1827 | 1813 | ||
@@ -1830,7 +1816,7 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial, | |||
1830 | if ((reset_port + 1) > p_priv->resend_cont) | 1816 | if ((reset_port + 1) > p_priv->resend_cont) |
1831 | p_priv->resend_cont = reset_port + 1; | 1817 | p_priv->resend_cont = reset_port + 1; |
1832 | if (this_urb->status == -EINPROGRESS) { | 1818 | if (this_urb->status == -EINPROGRESS) { |
1833 | dbg("%s already writing", __func__); | 1819 | dev_dbg(&port->dev, "%s already writing\n", __func__); |
1834 | mdelay(5); | 1820 | mdelay(5); |
1835 | return -1; | 1821 | return -1; |
1836 | } | 1822 | } |
@@ -1838,9 +1824,10 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial, | |||
1838 | memset(&msg, 0, sizeof(struct keyspan_usa28_portControlMessage)); | 1824 | memset(&msg, 0, sizeof(struct keyspan_usa28_portControlMessage)); |
1839 | 1825 | ||
1840 | msg.setBaudRate = 1; | 1826 | msg.setBaudRate = 1; |
1841 | if (d_details->calculate_baud_rate(p_priv->baud, d_details->baudclk, | 1827 | if (d_details->calculate_baud_rate(port, p_priv->baud, d_details->baudclk, |
1842 | &msg.baudHi, &msg.baudLo, NULL, device_port) == KEYSPAN_INVALID_BAUD_RATE) { | 1828 | &msg.baudHi, &msg.baudLo, NULL, |
1843 | dbg("%s - Invalid baud rate requested %d.", | 1829 | device_port) == KEYSPAN_INVALID_BAUD_RATE) { |
1830 | dev_dbg(&port->dev, "%s - Invalid baud rate requested %d.\n", | ||
1844 | __func__, p_priv->baud); | 1831 | __func__, p_priv->baud); |
1845 | msg.baudLo = 0xff; | 1832 | msg.baudLo = 0xff; |
1846 | msg.baudHi = 0xb2; /* Values for 9600 baud */ | 1833 | msg.baudHi = 0xb2; /* Values for 9600 baud */ |
@@ -1915,10 +1902,10 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial, | |||
1915 | 1902 | ||
1916 | err = usb_submit_urb(this_urb, GFP_ATOMIC); | 1903 | err = usb_submit_urb(this_urb, GFP_ATOMIC); |
1917 | if (err != 0) | 1904 | if (err != 0) |
1918 | dbg("%s - usb_submit_urb(setup) failed", __func__); | 1905 | dev_dbg(&port->dev, "%s - usb_submit_urb(setup) failed\n", __func__); |
1919 | #if 0 | 1906 | #if 0 |
1920 | else { | 1907 | else { |
1921 | dbg("%s - usb_submit_urb(setup) OK %d bytes", __func__, | 1908 | dev_dbg(&port->dev, "%s - usb_submit_urb(setup) OK %d bytes\n", __func__, |
1922 | this_urb->transfer_buffer_length); | 1909 | this_urb->transfer_buffer_length); |
1923 | } | 1910 | } |
1924 | #endif | 1911 | #endif |
@@ -1949,13 +1936,13 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial, | |||
1949 | 1936 | ||
1950 | /* Make sure we have an urb then send the message */ | 1937 | /* Make sure we have an urb then send the message */ |
1951 | if (this_urb == NULL) { | 1938 | if (this_urb == NULL) { |
1952 | dbg("%s - oops no urb for port %d.", __func__, port->number); | 1939 | dev_dbg(&port->dev, "%s - oops no urb for port %d.\n", __func__, port->number); |
1953 | return -1; | 1940 | return -1; |
1954 | } | 1941 | } |
1955 | 1942 | ||
1956 | dbg("%s - endpoint %d port %d (%d)", | 1943 | dev_dbg(&port->dev, "%s - endpoint %d port %d (%d)\n", |
1957 | __func__, usb_pipeendpoint(this_urb->pipe), | 1944 | __func__, usb_pipeendpoint(this_urb->pipe), |
1958 | port->number, device_port); | 1945 | port->number, device_port); |
1959 | 1946 | ||
1960 | /* Save reset port val for resend. | 1947 | /* Save reset port val for resend. |
1961 | Don't overwrite resend for open/close condition. */ | 1948 | Don't overwrite resend for open/close condition. */ |
@@ -1963,7 +1950,7 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial, | |||
1963 | p_priv->resend_cont = reset_port + 1; | 1950 | p_priv->resend_cont = reset_port + 1; |
1964 | 1951 | ||
1965 | if (this_urb->status == -EINPROGRESS) { | 1952 | if (this_urb->status == -EINPROGRESS) { |
1966 | /* dbg("%s - already writing", __func__); */ | 1953 | /* dev_dbg(&port->dev, "%s - already writing\n", __func__); */ |
1967 | mdelay(5); | 1954 | mdelay(5); |
1968 | return -1; | 1955 | return -1; |
1969 | } | 1956 | } |
@@ -1977,11 +1964,11 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial, | |||
1977 | if (p_priv->old_baud != p_priv->baud) { | 1964 | if (p_priv->old_baud != p_priv->baud) { |
1978 | p_priv->old_baud = p_priv->baud; | 1965 | p_priv->old_baud = p_priv->baud; |
1979 | msg.setClocking = 0xff; | 1966 | msg.setClocking = 0xff; |
1980 | if (d_details->calculate_baud_rate | 1967 | if (d_details->calculate_baud_rate(port, p_priv->baud, d_details->baudclk, |
1981 | (p_priv->baud, d_details->baudclk, &msg.baudHi, | 1968 | &msg.baudHi, &msg.baudLo, &msg.prescaler, |
1982 | &msg.baudLo, &msg.prescaler, device_port) == KEYSPAN_INVALID_BAUD_RATE) { | 1969 | device_port) == KEYSPAN_INVALID_BAUD_RATE) { |
1983 | dbg("%s - Invalid baud rate %d requested, using 9600.", | 1970 | dev_dbg(&port->dev, "%s - Invalid baud rate %d requested, using 9600.\n", |
1984 | __func__, p_priv->baud); | 1971 | __func__, p_priv->baud); |
1985 | msg.baudLo = 0; | 1972 | msg.baudLo = 0; |
1986 | msg.baudHi = 125; /* Values for 9600 baud */ | 1973 | msg.baudHi = 125; /* Values for 9600 baud */ |
1987 | msg.prescaler = 10; | 1974 | msg.prescaler = 10; |
@@ -2100,12 +2087,12 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial, | |||
2100 | } | 2087 | } |
2101 | err = usb_submit_urb(this_urb, GFP_ATOMIC); | 2088 | err = usb_submit_urb(this_urb, GFP_ATOMIC); |
2102 | if (err != 0) | 2089 | if (err != 0) |
2103 | dbg("%s - usb_submit_urb(setup) failed (%d)", __func__, err); | 2090 | dev_dbg(&port->dev, "%s - usb_submit_urb(setup) failed (%d)\n", __func__, err); |
2104 | #if 0 | 2091 | #if 0 |
2105 | else { | 2092 | else { |
2106 | dbg("%s - usb_submit_urb(%d) OK %d bytes (end %d)", __func__, | 2093 | dev_dbg(&port->dev, "%s - usb_submit_urb(%d) OK %d bytes (end %d)\n", __func__, |
2107 | outcont_urb, this_urb->transfer_buffer_length, | 2094 | outcont_urb, this_urb->transfer_buffer_length, |
2108 | usb_pipeendpoint(this_urb->pipe)); | 2095 | usb_pipeendpoint(this_urb->pipe)); |
2109 | } | 2096 | } |
2110 | #endif | 2097 | #endif |
2111 | 2098 | ||
@@ -2131,7 +2118,7 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial, | |||
2131 | /* only do something if we have a bulk out endpoint */ | 2118 | /* only do something if we have a bulk out endpoint */ |
2132 | this_urb = p_priv->outcont_urb; | 2119 | this_urb = p_priv->outcont_urb; |
2133 | if (this_urb == NULL) { | 2120 | if (this_urb == NULL) { |
2134 | dbg("%s - oops no urb.", __func__); | 2121 | dev_dbg(&port->dev, "%s - oops no urb.\n", __func__); |
2135 | return -1; | 2122 | return -1; |
2136 | } | 2123 | } |
2137 | 2124 | ||
@@ -2140,7 +2127,7 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial, | |||
2140 | if ((reset_port + 1) > p_priv->resend_cont) | 2127 | if ((reset_port + 1) > p_priv->resend_cont) |
2141 | p_priv->resend_cont = reset_port + 1; | 2128 | p_priv->resend_cont = reset_port + 1; |
2142 | if (this_urb->status == -EINPROGRESS) { | 2129 | if (this_urb->status == -EINPROGRESS) { |
2143 | dbg("%s already writing", __func__); | 2130 | dev_dbg(&port->dev, "%s already writing\n", __func__); |
2144 | mdelay(5); | 2131 | mdelay(5); |
2145 | return -1; | 2132 | return -1; |
2146 | } | 2133 | } |
@@ -2151,13 +2138,12 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial, | |||
2151 | if (p_priv->old_baud != p_priv->baud) { | 2138 | if (p_priv->old_baud != p_priv->baud) { |
2152 | p_priv->old_baud = p_priv->baud; | 2139 | p_priv->old_baud = p_priv->baud; |
2153 | msg.setClocking = 0x01; | 2140 | msg.setClocking = 0x01; |
2154 | if (d_details->calculate_baud_rate | 2141 | if (d_details->calculate_baud_rate(port, p_priv->baud, d_details->baudclk, |
2155 | (p_priv->baud, d_details->baudclk, &msg.baudHi, | 2142 | &msg.baudHi, &msg.baudLo, &prescaler, 0) == KEYSPAN_INVALID_BAUD_RATE) { |
2156 | &msg.baudLo, &prescaler, 0) == KEYSPAN_INVALID_BAUD_RATE) { | 2143 | dev_dbg(&port->dev, "%s - Invalid baud rate %d requested, using 9600.\n", |
2157 | dbg("%s - Invalid baud rate %d requested, using 9600.", | 2144 | __func__, p_priv->baud); |
2158 | __func__, p_priv->baud); | ||
2159 | p_priv->baud = 9600; | 2145 | p_priv->baud = 9600; |
2160 | d_details->calculate_baud_rate(p_priv->baud, d_details->baudclk, | 2146 | d_details->calculate_baud_rate(port, p_priv->baud, d_details->baudclk, |
2161 | &msg.baudHi, &msg.baudLo, &prescaler, 0); | 2147 | &msg.baudHi, &msg.baudLo, &prescaler, 0); |
2162 | } | 2148 | } |
2163 | msg.setRxMode = 1; | 2149 | msg.setRxMode = 1; |
@@ -2239,7 +2225,7 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial, | |||
2239 | 2225 | ||
2240 | err = usb_submit_urb(this_urb, GFP_ATOMIC); | 2226 | err = usb_submit_urb(this_urb, GFP_ATOMIC); |
2241 | if (err != 0) | 2227 | if (err != 0) |
2242 | dbg("%s - usb_submit_urb(setup) failed (%d)", __func__, err); | 2228 | dev_dbg(&port->dev, "%s - usb_submit_urb(setup) failed (%d)\n", __func__, err); |
2243 | return 0; | 2229 | return 0; |
2244 | } | 2230 | } |
2245 | 2231 | ||
@@ -2265,7 +2251,7 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial, | |||
2265 | 2251 | ||
2266 | /* Make sure we have an urb then send the message */ | 2252 | /* Make sure we have an urb then send the message */ |
2267 | if (this_urb == NULL) { | 2253 | if (this_urb == NULL) { |
2268 | dbg("%s - oops no urb for port %d.", __func__, | 2254 | dev_dbg(&port->dev, "%s - oops no urb for port %d.\n", __func__, |
2269 | port->number); | 2255 | port->number); |
2270 | return -1; | 2256 | return -1; |
2271 | } | 2257 | } |
@@ -2275,7 +2261,7 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial, | |||
2275 | if ((reset_port + 1) > p_priv->resend_cont) | 2261 | if ((reset_port + 1) > p_priv->resend_cont) |
2276 | p_priv->resend_cont = reset_port + 1; | 2262 | p_priv->resend_cont = reset_port + 1; |
2277 | if (this_urb->status == -EINPROGRESS) { | 2263 | if (this_urb->status == -EINPROGRESS) { |
2278 | /* dbg("%s - already writing", __func__); */ | 2264 | /* dev_dbg(&port->dev, "%s - already writing\n", __func__); */ |
2279 | mdelay(5); | 2265 | mdelay(5); |
2280 | return -1; | 2266 | return -1; |
2281 | } | 2267 | } |
@@ -2288,11 +2274,11 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial, | |||
2288 | if (p_priv->old_baud != p_priv->baud) { | 2274 | if (p_priv->old_baud != p_priv->baud) { |
2289 | p_priv->old_baud = p_priv->baud; | 2275 | p_priv->old_baud = p_priv->baud; |
2290 | msg.setClocking = 0xff; | 2276 | msg.setClocking = 0xff; |
2291 | if (d_details->calculate_baud_rate | 2277 | if (d_details->calculate_baud_rate(port, p_priv->baud, d_details->baudclk, |
2292 | (p_priv->baud, d_details->baudclk, &msg.baudHi, | 2278 | &msg.baudHi, &msg.baudLo, &msg.prescaler, |
2293 | &msg.baudLo, &msg.prescaler, device_port) == KEYSPAN_INVALID_BAUD_RATE) { | 2279 | device_port) == KEYSPAN_INVALID_BAUD_RATE) { |
2294 | dbg("%s - Invalid baud rate %d requested, using 9600.", | 2280 | dev_dbg(&port->dev, "%s - Invalid baud rate %d requested, using 9600.\n", |
2295 | __func__, p_priv->baud); | 2281 | __func__, p_priv->baud); |
2296 | msg.baudLo = 0; | 2282 | msg.baudLo = 0; |
2297 | msg.baudHi = 125; /* Values for 9600 baud */ | 2283 | msg.baudHi = 125; /* Values for 9600 baud */ |
2298 | msg.prescaler = 10; | 2284 | msg.prescaler = 10; |
@@ -2383,8 +2369,7 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial, | |||
2383 | 2369 | ||
2384 | err = usb_submit_urb(this_urb, GFP_ATOMIC); | 2370 | err = usb_submit_urb(this_urb, GFP_ATOMIC); |
2385 | if (err != 0) | 2371 | if (err != 0) |
2386 | dbg("%s - usb_submit_urb(setup) failed (%d)", __func__, | 2372 | dev_dbg(&port->dev, "%s - usb_submit_urb(setup) failed (%d)\n", __func__, err); |
2387 | err); | ||
2388 | return 0; | 2373 | return 0; |
2389 | } | 2374 | } |
2390 | 2375 | ||
@@ -2440,8 +2425,7 @@ static int keyspan_startup(struct usb_serial *serial) | |||
2440 | /* Setup private data for serial driver */ | 2425 | /* Setup private data for serial driver */ |
2441 | s_priv = kzalloc(sizeof(struct keyspan_serial_private), GFP_KERNEL); | 2426 | s_priv = kzalloc(sizeof(struct keyspan_serial_private), GFP_KERNEL); |
2442 | if (!s_priv) { | 2427 | if (!s_priv) { |
2443 | dbg("%s - kmalloc for keyspan_serial_private failed.", | 2428 | dev_dbg(&serial->dev->dev, "%s - kmalloc for keyspan_serial_private failed.\n", __func__); |
2444 | __func__); | ||
2445 | return -ENOMEM; | 2429 | return -ENOMEM; |
2446 | } | 2430 | } |
2447 | 2431 | ||
@@ -2454,7 +2438,7 @@ static int keyspan_startup(struct usb_serial *serial) | |||
2454 | p_priv = kzalloc(sizeof(struct keyspan_port_private), | 2438 | p_priv = kzalloc(sizeof(struct keyspan_port_private), |
2455 | GFP_KERNEL); | 2439 | GFP_KERNEL); |
2456 | if (!p_priv) { | 2440 | if (!p_priv) { |
2457 | dbg("%s - kmalloc for keyspan_port_private (%d) failed!.", __func__, i); | 2441 | dev_dbg(&port->dev, "%s - kmalloc for keyspan_port_private (%d) failed!.\n", __func__, i); |
2458 | return 1; | 2442 | return 1; |
2459 | } | 2443 | } |
2460 | p_priv->device_details = d_details; | 2444 | p_priv->device_details = d_details; |
@@ -2466,14 +2450,12 @@ static int keyspan_startup(struct usb_serial *serial) | |||
2466 | if (s_priv->instat_urb != NULL) { | 2450 | if (s_priv->instat_urb != NULL) { |
2467 | err = usb_submit_urb(s_priv->instat_urb, GFP_KERNEL); | 2451 | err = usb_submit_urb(s_priv->instat_urb, GFP_KERNEL); |
2468 | if (err != 0) | 2452 | if (err != 0) |
2469 | dbg("%s - submit instat urb failed %d", __func__, | 2453 | dev_dbg(&serial->dev->dev, "%s - submit instat urb failed %d\n", __func__, err); |
2470 | err); | ||
2471 | } | 2454 | } |
2472 | if (s_priv->indat_urb != NULL) { | 2455 | if (s_priv->indat_urb != NULL) { |
2473 | err = usb_submit_urb(s_priv->indat_urb, GFP_KERNEL); | 2456 | err = usb_submit_urb(s_priv->indat_urb, GFP_KERNEL); |
2474 | if (err != 0) | 2457 | if (err != 0) |
2475 | dbg("%s - submit indat urb failed %d", __func__, | 2458 | dev_dbg(&serial->dev->dev, "%s - submit indat urb failed %d\n", __func__, err); |
2476 | err); | ||
2477 | } | 2459 | } |
2478 | 2460 | ||
2479 | return 0; | 2461 | return 0; |
@@ -2527,10 +2509,8 @@ static void keyspan_release(struct usb_serial *serial) | |||
2527 | 2509 | ||
2528 | s_priv = usb_get_serial_data(serial); | 2510 | s_priv = usb_get_serial_data(serial); |
2529 | 2511 | ||
2530 | /* dbg("Freeing serial->private."); */ | ||
2531 | kfree(s_priv); | 2512 | kfree(s_priv); |
2532 | 2513 | ||
2533 | /* dbg("Freeing port->private."); */ | ||
2534 | /* Now free per port private data */ | 2514 | /* Now free per port private data */ |
2535 | for (i = 0; i < serial->num_ports; i++) { | 2515 | for (i = 0; i < serial->num_ports; i++) { |
2536 | port = serial->port[i]; | 2516 | port = serial->port[i]; |
@@ -2554,7 +2534,3 @@ MODULE_FIRMWARE("keyspan/usa18x.fw"); | |||
2554 | MODULE_FIRMWARE("keyspan/usa19w.fw"); | 2534 | MODULE_FIRMWARE("keyspan/usa19w.fw"); |
2555 | MODULE_FIRMWARE("keyspan/usa49w.fw"); | 2535 | MODULE_FIRMWARE("keyspan/usa49w.fw"); |
2556 | MODULE_FIRMWARE("keyspan/usa49wlc.fw"); | 2536 | MODULE_FIRMWARE("keyspan/usa49wlc.fw"); |
2557 | |||
2558 | module_param(debug, bool, S_IRUGO | S_IWUSR); | ||
2559 | MODULE_PARM_DESC(debug, "Debug enabled or not"); | ||
2560 | |||
diff --git a/drivers/usb/serial/keyspan.h b/drivers/usb/serial/keyspan.h index fe1c5d91692c..0a8a40b5711e 100644 --- a/drivers/usb/serial/keyspan.h +++ b/drivers/usb/serial/keyspan.h | |||
@@ -64,19 +64,23 @@ static int keyspan_tiocmset (struct tty_struct *tty, | |||
64 | unsigned int clear); | 64 | unsigned int clear); |
65 | static int keyspan_fake_startup (struct usb_serial *serial); | 65 | static int keyspan_fake_startup (struct usb_serial *serial); |
66 | 66 | ||
67 | static int keyspan_usa19_calc_baud (u32 baud_rate, u32 baudclk, | 67 | static int keyspan_usa19_calc_baud (struct usb_serial_port *port, |
68 | u32 baud_rate, u32 baudclk, | ||
68 | u8 *rate_hi, u8 *rate_low, | 69 | u8 *rate_hi, u8 *rate_low, |
69 | u8 *prescaler, int portnum); | 70 | u8 *prescaler, int portnum); |
70 | 71 | ||
71 | static int keyspan_usa19w_calc_baud (u32 baud_rate, u32 baudclk, | 72 | static int keyspan_usa19w_calc_baud (struct usb_serial_port *port, |
73 | u32 baud_rate, u32 baudclk, | ||
72 | u8 *rate_hi, u8 *rate_low, | 74 | u8 *rate_hi, u8 *rate_low, |
73 | u8 *prescaler, int portnum); | 75 | u8 *prescaler, int portnum); |
74 | 76 | ||
75 | static int keyspan_usa28_calc_baud (u32 baud_rate, u32 baudclk, | 77 | static int keyspan_usa28_calc_baud (struct usb_serial_port *port, |
78 | u32 baud_rate, u32 baudclk, | ||
76 | u8 *rate_hi, u8 *rate_low, | 79 | u8 *rate_hi, u8 *rate_low, |
77 | u8 *prescaler, int portnum); | 80 | u8 *prescaler, int portnum); |
78 | 81 | ||
79 | static int keyspan_usa19hs_calc_baud (u32 baud_rate, u32 baudclk, | 82 | static int keyspan_usa19hs_calc_baud (struct usb_serial_port *port, |
83 | u32 baud_rate, u32 baudclk, | ||
80 | u8 *rate_hi, u8 *rate_low, | 84 | u8 *rate_hi, u8 *rate_low, |
81 | u8 *prescaler, int portnum); | 85 | u8 *prescaler, int portnum); |
82 | 86 | ||
@@ -188,8 +192,9 @@ struct keyspan_device_details { | |||
188 | /* Endpoint used for global control functions */ | 192 | /* Endpoint used for global control functions */ |
189 | int glocont_endpoint; | 193 | int glocont_endpoint; |
190 | 194 | ||
191 | int (*calculate_baud_rate) (u32 baud_rate, u32 baudclk, | 195 | int (*calculate_baud_rate) (struct usb_serial_port *port, |
192 | u8 *rate_hi, u8 *rate_low, u8 *prescaler, int portnum); | 196 | u32 baud_rate, u32 baudclk, |
197 | u8 *rate_hi, u8 *rate_low, u8 *prescaler, int portnum); | ||
193 | u32 baudclk; | 198 | u32 baudclk; |
194 | }; | 199 | }; |
195 | 200 | ||
diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c index dcada8615fcf..ca43ecb4a2bd 100644 --- a/drivers/usb/serial/keyspan_pda.c +++ b/drivers/usb/serial/keyspan_pda.c | |||
@@ -25,13 +25,10 @@ | |||
25 | #include <linux/module.h> | 25 | #include <linux/module.h> |
26 | #include <linux/spinlock.h> | 26 | #include <linux/spinlock.h> |
27 | #include <linux/workqueue.h> | 27 | #include <linux/workqueue.h> |
28 | #include <linux/firmware.h> | ||
29 | #include <linux/ihex.h> | ||
30 | #include <linux/uaccess.h> | 28 | #include <linux/uaccess.h> |
31 | #include <linux/usb.h> | 29 | #include <linux/usb.h> |
32 | #include <linux/usb/serial.h> | 30 | #include <linux/usb/serial.h> |
33 | 31 | #include <linux/usb/ezusb.h> | |
34 | static bool debug; | ||
35 | 32 | ||
36 | /* make a simple define to handle if we are compiling keyspan_pda or xircom support */ | 33 | /* make a simple define to handle if we are compiling keyspan_pda or xircom support */ |
37 | #if defined(CONFIG_USB_SERIAL_KEYSPAN_PDA) || defined(CONFIG_USB_SERIAL_KEYSPAN_PDA_MODULE) | 34 | #if defined(CONFIG_USB_SERIAL_KEYSPAN_PDA) || defined(CONFIG_USB_SERIAL_KEYSPAN_PDA_MODULE) |
@@ -137,8 +134,8 @@ static void keyspan_pda_request_unthrottle(struct work_struct *work) | |||
137 | 0, | 134 | 0, |
138 | 2000); | 135 | 2000); |
139 | if (result < 0) | 136 | if (result < 0) |
140 | dbg("%s - error %d from usb_control_msg", | 137 | dev_dbg(&serial->dev->dev, "%s - error %d from usb_control_msg\n", |
141 | __func__, result); | 138 | __func__, result); |
142 | } | 139 | } |
143 | 140 | ||
144 | 141 | ||
@@ -160,12 +157,10 @@ static void keyspan_pda_rx_interrupt(struct urb *urb) | |||
160 | case -ENOENT: | 157 | case -ENOENT: |
161 | case -ESHUTDOWN: | 158 | case -ESHUTDOWN: |
162 | /* this urb is terminated, clean up */ | 159 | /* this urb is terminated, clean up */ |
163 | dbg("%s - urb shutting down with status: %d", | 160 | dev_dbg(&urb->dev->dev, "%s - urb shutting down with status: %d\n", __func__, status); |
164 | __func__, status); | ||
165 | return; | 161 | return; |
166 | default: | 162 | default: |
167 | dbg("%s - nonzero urb status received: %d", | 163 | dev_dbg(&urb->dev->dev, "%s - nonzero urb status received: %d\n", __func__, status); |
168 | __func__, status); | ||
169 | goto exit; | 164 | goto exit; |
170 | } | 165 | } |
171 | 166 | ||
@@ -183,7 +178,7 @@ static void keyspan_pda_rx_interrupt(struct urb *urb) | |||
183 | break; | 178 | break; |
184 | case 1: | 179 | case 1: |
185 | /* status interrupt */ | 180 | /* status interrupt */ |
186 | dbg(" rx int, d1=%d, d2=%d", data[1], data[2]); | 181 | dev_dbg(&port->dev, "rx int, d1=%d, d2=%d\n", data[1], data[2]); |
187 | switch (data[1]) { | 182 | switch (data[1]) { |
188 | case 1: /* modemline change */ | 183 | case 1: /* modemline change */ |
189 | break; | 184 | break; |
@@ -229,7 +224,7 @@ static void keyspan_pda_rx_unthrottle(struct tty_struct *tty) | |||
229 | /* just restart the receive interrupt URB */ | 224 | /* just restart the receive interrupt URB */ |
230 | 225 | ||
231 | if (usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL)) | 226 | if (usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL)) |
232 | dbg(" usb_submit_urb(read urb) failed"); | 227 | dev_dbg(&port->dev, "usb_submit_urb(read urb) failed\n"); |
233 | } | 228 | } |
234 | 229 | ||
235 | 230 | ||
@@ -308,8 +303,8 @@ static void keyspan_pda_break_ctl(struct tty_struct *tty, int break_state) | |||
308 | USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, | 303 | USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, |
309 | value, 0, NULL, 0, 2000); | 304 | value, 0, NULL, 0, 2000); |
310 | if (result < 0) | 305 | if (result < 0) |
311 | dbg("%s - error %d from usb_control_msg", | 306 | dev_dbg(&port->dev, "%s - error %d from usb_control_msg\n", |
312 | __func__, result); | 307 | __func__, result); |
313 | /* there is something funky about this.. the TCSBRK that 'cu' performs | 308 | /* there is something funky about this.. the TCSBRK that 'cu' performs |
314 | ought to translate into a break_ctl(-1),break_ctl(0) pair HZ/4 | 309 | ought to translate into a break_ctl(-1),break_ctl(0) pair HZ/4 |
315 | seconds apart, but it feels like the break sent isn't as long as it | 310 | seconds apart, but it feels like the break sent isn't as long as it |
@@ -347,7 +342,7 @@ static void keyspan_pda_set_termios(struct tty_struct *tty, | |||
347 | speed = keyspan_pda_setbaud(serial, speed); | 342 | speed = keyspan_pda_setbaud(serial, speed); |
348 | 343 | ||
349 | if (speed == 0) { | 344 | if (speed == 0) { |
350 | dbg("can't handle requested baud rate"); | 345 | dev_dbg(&port->dev, "can't handle requested baud rate\n"); |
351 | /* It hasn't changed so.. */ | 346 | /* It hasn't changed so.. */ |
352 | speed = tty_termios_baud_rate(old_termios); | 347 | speed = tty_termios_baud_rate(old_termios); |
353 | } | 348 | } |
@@ -459,7 +454,7 @@ static int keyspan_pda_write(struct tty_struct *tty, | |||
459 | Block if we can't write anything at all, otherwise write as much as | 454 | Block if we can't write anything at all, otherwise write as much as |
460 | we can. */ | 455 | we can. */ |
461 | if (count == 0) { | 456 | if (count == 0) { |
462 | dbg(" write request of 0 bytes"); | 457 | dev_dbg(&port->dev, "write request of 0 bytes\n"); |
463 | return 0; | 458 | return 0; |
464 | } | 459 | } |
465 | 460 | ||
@@ -505,16 +500,16 @@ static int keyspan_pda_write(struct tty_struct *tty, | |||
505 | 1, | 500 | 1, |
506 | 2000); | 501 | 2000); |
507 | if (rc > 0) { | 502 | if (rc > 0) { |
508 | dbg(" roomquery says %d", *room); | 503 | dev_dbg(&port->dev, "roomquery says %d\n", *room); |
509 | priv->tx_room = *room; | 504 | priv->tx_room = *room; |
510 | } | 505 | } |
511 | kfree(room); | 506 | kfree(room); |
512 | if (rc < 0) { | 507 | if (rc < 0) { |
513 | dbg(" roomquery failed"); | 508 | dev_dbg(&port->dev, "roomquery failed\n"); |
514 | goto exit; | 509 | goto exit; |
515 | } | 510 | } |
516 | if (rc == 0) { | 511 | if (rc == 0) { |
517 | dbg(" roomquery returned 0 bytes"); | 512 | dev_dbg(&port->dev, "roomquery returned 0 bytes\n"); |
518 | rc = -EIO; /* device didn't return any data */ | 513 | rc = -EIO; /* device didn't return any data */ |
519 | goto exit; | 514 | goto exit; |
520 | } | 515 | } |
@@ -536,7 +531,7 @@ static int keyspan_pda_write(struct tty_struct *tty, | |||
536 | 531 | ||
537 | rc = usb_submit_urb(port->write_urb, GFP_ATOMIC); | 532 | rc = usb_submit_urb(port->write_urb, GFP_ATOMIC); |
538 | if (rc) { | 533 | if (rc) { |
539 | dbg(" usb_submit_urb(write bulk) failed"); | 534 | dev_dbg(&port->dev, "usb_submit_urb(write bulk) failed\n"); |
540 | goto exit; | 535 | goto exit; |
541 | } | 536 | } |
542 | } else { | 537 | } else { |
@@ -639,11 +634,11 @@ static int keyspan_pda_open(struct tty_struct *tty, | |||
639 | 1, | 634 | 1, |
640 | 2000); | 635 | 2000); |
641 | if (rc < 0) { | 636 | if (rc < 0) { |
642 | dbg("%s - roomquery failed", __func__); | 637 | dev_dbg(&port->dev, "%s - roomquery failed\n", __func__); |
643 | goto error; | 638 | goto error; |
644 | } | 639 | } |
645 | if (rc == 0) { | 640 | if (rc == 0) { |
646 | dbg("%s - roomquery returned 0 bytes", __func__); | 641 | dev_dbg(&port->dev, "%s - roomquery returned 0 bytes\n", __func__); |
647 | rc = -EIO; | 642 | rc = -EIO; |
648 | goto error; | 643 | goto error; |
649 | } | 644 | } |
@@ -654,7 +649,7 @@ static int keyspan_pda_open(struct tty_struct *tty, | |||
654 | /*Start reading from the device*/ | 649 | /*Start reading from the device*/ |
655 | rc = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); | 650 | rc = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); |
656 | if (rc) { | 651 | if (rc) { |
657 | dbg("%s - usb_submit_urb(read int) failed", __func__); | 652 | dev_dbg(&port->dev, "%s - usb_submit_urb(read int) failed\n", __func__); |
658 | goto error; | 653 | goto error; |
659 | } | 654 | } |
660 | error: | 655 | error: |
@@ -678,11 +673,9 @@ static int keyspan_pda_fake_startup(struct usb_serial *serial) | |||
678 | { | 673 | { |
679 | int response; | 674 | int response; |
680 | const char *fw_name; | 675 | const char *fw_name; |
681 | const struct ihex_binrec *record; | ||
682 | const struct firmware *fw; | ||
683 | 676 | ||
684 | /* download the firmware here ... */ | 677 | /* download the firmware here ... */ |
685 | response = ezusb_set_reset(serial, 1); | 678 | response = ezusb_fx1_set_reset(serial->dev, 1); |
686 | 679 | ||
687 | if (0) { ; } | 680 | if (0) { ; } |
688 | #ifdef KEYSPAN | 681 | #ifdef KEYSPAN |
@@ -699,30 +692,15 @@ static int keyspan_pda_fake_startup(struct usb_serial *serial) | |||
699 | __func__); | 692 | __func__); |
700 | return -ENODEV; | 693 | return -ENODEV; |
701 | } | 694 | } |
702 | if (request_ihex_firmware(&fw, fw_name, &serial->dev->dev)) { | 695 | |
696 | if (ezusb_fx1_ihex_firmware_download(serial->dev, fw_name) < 0) { | ||
703 | dev_err(&serial->dev->dev, "failed to load firmware \"%s\"\n", | 697 | dev_err(&serial->dev->dev, "failed to load firmware \"%s\"\n", |
704 | fw_name); | 698 | fw_name); |
705 | return -ENOENT; | 699 | return -ENOENT; |
706 | } | 700 | } |
707 | record = (const struct ihex_binrec *)fw->data; | 701 | |
708 | 702 | /* after downloading firmware Renumeration will occur in a | |
709 | while (record) { | 703 | moment and the new device will bind to the real driver */ |
710 | response = ezusb_writememory(serial, be32_to_cpu(record->addr), | ||
711 | (unsigned char *)record->data, | ||
712 | be16_to_cpu(record->len), 0xa0); | ||
713 | if (response < 0) { | ||
714 | dev_err(&serial->dev->dev, "ezusb_writememory failed " | ||
715 | "for Keyspan PDA firmware (%d %04X %p %d)\n", | ||
716 | response, be32_to_cpu(record->addr), | ||
717 | record->data, be16_to_cpu(record->len)); | ||
718 | break; | ||
719 | } | ||
720 | record = ihex_next_binrec(record); | ||
721 | } | ||
722 | release_firmware(fw); | ||
723 | /* bring device out of reset. Renumeration will occur in a moment | ||
724 | and the new device will bind to the real driver */ | ||
725 | response = ezusb_set_reset(serial, 0); | ||
726 | 704 | ||
727 | /* we want this device to fail to have a driver assigned to it. */ | 705 | /* we want this device to fail to have a driver assigned to it. */ |
728 | return 1; | 706 | return 1; |
@@ -828,6 +806,3 @@ module_usb_serial_driver(serial_drivers, id_table_combined); | |||
828 | MODULE_AUTHOR(DRIVER_AUTHOR); | 806 | MODULE_AUTHOR(DRIVER_AUTHOR); |
829 | MODULE_DESCRIPTION(DRIVER_DESC); | 807 | MODULE_DESCRIPTION(DRIVER_DESC); |
830 | MODULE_LICENSE("GPL"); | 808 | MODULE_LICENSE("GPL"); |
831 | |||
832 | module_param(debug, bool, S_IRUGO | S_IWUSR); | ||
833 | MODULE_PARM_DESC(debug, "Debug enabled or not"); | ||
diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c index def9ad258715..3f6d7376c02d 100644 --- a/drivers/usb/serial/kl5kusb105.c +++ b/drivers/usb/serial/kl5kusb105.c | |||
@@ -49,8 +49,6 @@ | |||
49 | #include <linux/usb/serial.h> | 49 | #include <linux/usb/serial.h> |
50 | #include "kl5kusb105.h" | 50 | #include "kl5kusb105.h" |
51 | 51 | ||
52 | static bool debug; | ||
53 | |||
54 | /* | 52 | /* |
55 | * Version Information | 53 | * Version Information |
56 | */ | 54 | */ |
@@ -239,7 +237,9 @@ static int klsi_105_startup(struct usb_serial *serial) | |||
239 | priv = kmalloc(sizeof(struct klsi_105_private), | 237 | priv = kmalloc(sizeof(struct klsi_105_private), |
240 | GFP_KERNEL); | 238 | GFP_KERNEL); |
241 | if (!priv) { | 239 | if (!priv) { |
242 | dbg("%skmalloc for klsi_105_private failed.", __func__); | 240 | dev_dbg(&serial->interface->dev, |
241 | "%s - kmalloc for klsi_105_private failed.\n", | ||
242 | __func__); | ||
243 | i--; | 243 | i--; |
244 | goto err_cleanup; | 244 | goto err_cleanup; |
245 | } | 245 | } |
@@ -344,14 +344,14 @@ static int klsi_105_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
344 | dev_err(&port->dev, "Enabling read failed (error = %d)\n", rc); | 344 | dev_err(&port->dev, "Enabling read failed (error = %d)\n", rc); |
345 | retval = rc; | 345 | retval = rc; |
346 | } else | 346 | } else |
347 | dbg("%s - enabled reading", __func__); | 347 | dev_dbg(&port->dev, "%s - enabled reading\n", __func__); |
348 | 348 | ||
349 | rc = klsi_105_get_line_state(port, &line_state); | 349 | rc = klsi_105_get_line_state(port, &line_state); |
350 | if (rc >= 0) { | 350 | if (rc >= 0) { |
351 | spin_lock_irqsave(&priv->lock, flags); | 351 | spin_lock_irqsave(&priv->lock, flags); |
352 | priv->line_state = line_state; | 352 | priv->line_state = line_state; |
353 | spin_unlock_irqrestore(&priv->lock, flags); | 353 | spin_unlock_irqrestore(&priv->lock, flags); |
354 | dbg("%s - read line state 0x%lx", __func__, line_state); | 354 | dev_dbg(&port->dev, "%s - read line state 0x%lx\n", __func__, line_state); |
355 | retval = 0; | 355 | retval = 0; |
356 | } else | 356 | } else |
357 | retval = rc; | 357 | retval = rc; |
@@ -421,7 +421,7 @@ static void klsi_105_process_read_urb(struct urb *urb) | |||
421 | return; | 421 | return; |
422 | 422 | ||
423 | if (urb->actual_length <= KLSI_HDR_LEN) { | 423 | if (urb->actual_length <= KLSI_HDR_LEN) { |
424 | dbg("%s - malformed packet", __func__); | 424 | dev_dbg(&port->dev, "%s - malformed packet\n", __func__); |
425 | return; | 425 | return; |
426 | } | 426 | } |
427 | 427 | ||
@@ -431,7 +431,7 @@ static void klsi_105_process_read_urb(struct urb *urb) | |||
431 | 431 | ||
432 | len = get_unaligned_le16(data); | 432 | len = get_unaligned_le16(data); |
433 | if (len > urb->actual_length - KLSI_HDR_LEN) { | 433 | if (len > urb->actual_length - KLSI_HDR_LEN) { |
434 | dbg("%s - packet length mismatch", __func__); | 434 | dev_dbg(&port->dev, "%s - packet length mismatch\n", __func__); |
435 | len = urb->actual_length - KLSI_HDR_LEN; | 435 | len = urb->actual_length - KLSI_HDR_LEN; |
436 | } | 436 | } |
437 | 437 | ||
@@ -445,6 +445,7 @@ static void klsi_105_set_termios(struct tty_struct *tty, | |||
445 | struct ktermios *old_termios) | 445 | struct ktermios *old_termios) |
446 | { | 446 | { |
447 | struct klsi_105_private *priv = usb_get_serial_port_data(port); | 447 | struct klsi_105_private *priv = usb_get_serial_port_data(port); |
448 | struct device *dev = &port->dev; | ||
448 | unsigned int iflag = tty->termios.c_iflag; | 449 | unsigned int iflag = tty->termios.c_iflag; |
449 | unsigned int old_iflag = old_termios->c_iflag; | 450 | unsigned int old_iflag = old_termios->c_iflag; |
450 | unsigned int cflag = tty->termios.c_cflag; | 451 | unsigned int cflag = tty->termios.c_cflag; |
@@ -455,8 +456,7 @@ static void klsi_105_set_termios(struct tty_struct *tty, | |||
455 | 456 | ||
456 | cfg = kmalloc(sizeof(*cfg), GFP_KERNEL); | 457 | cfg = kmalloc(sizeof(*cfg), GFP_KERNEL); |
457 | if (!cfg) { | 458 | if (!cfg) { |
458 | dev_err(&port->dev, "%s - out of memory for config buffer.\n", | 459 | dev_err(dev, "%s - out of memory for config buffer.\n", __func__); |
459 | __func__); | ||
460 | return; | 460 | return; |
461 | } | 461 | } |
462 | 462 | ||
@@ -471,7 +471,7 @@ static void klsi_105_set_termios(struct tty_struct *tty, | |||
471 | if ((cflag & CBAUD) != (old_cflag & CBAUD)) { | 471 | if ((cflag & CBAUD) != (old_cflag & CBAUD)) { |
472 | /* reassert DTR and (maybe) RTS on transition from B0 */ | 472 | /* reassert DTR and (maybe) RTS on transition from B0 */ |
473 | if ((old_cflag & CBAUD) == B0) { | 473 | if ((old_cflag & CBAUD) == B0) { |
474 | dbg("%s: baud was B0", __func__); | 474 | dev_dbg(dev, "%s: baud was B0\n", __func__); |
475 | #if 0 | 475 | #if 0 |
476 | priv->control_state |= TIOCM_DTR; | 476 | priv->control_state |= TIOCM_DTR; |
477 | /* don't set RTS if using hardware flow control */ | 477 | /* don't set RTS if using hardware flow control */ |
@@ -509,14 +509,13 @@ static void klsi_105_set_termios(struct tty_struct *tty, | |||
509 | priv->cfg.baudrate = kl5kusb105a_sio_b115200; | 509 | priv->cfg.baudrate = kl5kusb105a_sio_b115200; |
510 | break; | 510 | break; |
511 | default: | 511 | default: |
512 | dbg("KLSI USB->Serial converter:" | 512 | dev_dbg(dev, "KLSI USB->Serial converter: unsupported baudrate request, using default of 9600"); |
513 | " unsupported baudrate request, using default of 9600"); | 513 | priv->cfg.baudrate = kl5kusb105a_sio_b9600; |
514 | priv->cfg.baudrate = kl5kusb105a_sio_b9600; | ||
515 | baud = 9600; | 514 | baud = 9600; |
516 | break; | 515 | break; |
517 | } | 516 | } |
518 | if ((cflag & CBAUD) == B0) { | 517 | if ((cflag & CBAUD) == B0) { |
519 | dbg("%s: baud is B0", __func__); | 518 | dev_dbg(dev, "%s: baud is B0\n", __func__); |
520 | /* Drop RTS and DTR */ | 519 | /* Drop RTS and DTR */ |
521 | /* maybe this should be simulated by sending read | 520 | /* maybe this should be simulated by sending read |
522 | * disable and read enable messages? | 521 | * disable and read enable messages? |
@@ -533,11 +532,11 @@ static void klsi_105_set_termios(struct tty_struct *tty, | |||
533 | /* set the number of data bits */ | 532 | /* set the number of data bits */ |
534 | switch (cflag & CSIZE) { | 533 | switch (cflag & CSIZE) { |
535 | case CS5: | 534 | case CS5: |
536 | dbg("%s - 5 bits/byte not supported", __func__); | 535 | dev_dbg(dev, "%s - 5 bits/byte not supported\n", __func__); |
537 | spin_unlock_irqrestore(&priv->lock, flags); | 536 | spin_unlock_irqrestore(&priv->lock, flags); |
538 | goto err; | 537 | goto err; |
539 | case CS6: | 538 | case CS6: |
540 | dbg("%s - 6 bits/byte not supported", __func__); | 539 | dev_dbg(dev, "%s - 6 bits/byte not supported\n", __func__); |
541 | spin_unlock_irqrestore(&priv->lock, flags); | 540 | spin_unlock_irqrestore(&priv->lock, flags); |
542 | goto err; | 541 | goto err; |
543 | case CS7: | 542 | case CS7: |
@@ -547,8 +546,7 @@ static void klsi_105_set_termios(struct tty_struct *tty, | |||
547 | priv->cfg.databits = kl5kusb105a_dtb_8; | 546 | priv->cfg.databits = kl5kusb105a_dtb_8; |
548 | break; | 547 | break; |
549 | default: | 548 | default: |
550 | dev_err(&port->dev, | 549 | dev_err(dev, "CSIZE was not CS5-CS8, using default of 8\n"); |
551 | "CSIZE was not CS5-CS8, using default of 8\n"); | ||
552 | priv->cfg.databits = kl5kusb105a_dtb_8; | 550 | priv->cfg.databits = kl5kusb105a_dtb_8; |
553 | break; | 551 | break; |
554 | } | 552 | } |
@@ -616,7 +614,7 @@ static void mct_u232_break_ctl(struct tty_struct *tty, int break_state) | |||
616 | (struct mct_u232_private *)port->private; | 614 | (struct mct_u232_private *)port->private; |
617 | unsigned char lcr = priv->last_lcr; | 615 | unsigned char lcr = priv->last_lcr; |
618 | 616 | ||
619 | dbg("%sstate=%d", __func__, break_state); | 617 | dev_dbg(&port->dev, "%s - state=%d\n", __func__, break_state); |
620 | 618 | ||
621 | /* LOCKING */ | 619 | /* LOCKING */ |
622 | if (break_state) | 620 | if (break_state) |
@@ -645,7 +643,7 @@ static int klsi_105_tiocmget(struct tty_struct *tty) | |||
645 | spin_lock_irqsave(&priv->lock, flags); | 643 | spin_lock_irqsave(&priv->lock, flags); |
646 | priv->line_state = line_state; | 644 | priv->line_state = line_state; |
647 | spin_unlock_irqrestore(&priv->lock, flags); | 645 | spin_unlock_irqrestore(&priv->lock, flags); |
648 | dbg("%s - read line state 0x%lx", __func__, line_state); | 646 | dev_dbg(&port->dev, "%s - read line state 0x%lx\n", __func__, line_state); |
649 | return (int)line_state; | 647 | return (int)line_state; |
650 | } | 648 | } |
651 | 649 | ||
@@ -681,6 +679,3 @@ module_usb_serial_driver(serial_drivers, id_table); | |||
681 | MODULE_AUTHOR(DRIVER_AUTHOR); | 679 | MODULE_AUTHOR(DRIVER_AUTHOR); |
682 | MODULE_DESCRIPTION(DRIVER_DESC); | 680 | MODULE_DESCRIPTION(DRIVER_DESC); |
683 | MODULE_LICENSE("GPL"); | 681 | MODULE_LICENSE("GPL"); |
684 | |||
685 | module_param(debug, bool, S_IRUGO | S_IWUSR); | ||
686 | MODULE_PARM_DESC(debug, "enable extensive debugging messages"); | ||
diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c index bf5c74965d34..5c4d2fbd4e11 100644 --- a/drivers/usb/serial/kobil_sct.c +++ b/drivers/usb/serial/kobil_sct.c | |||
@@ -38,8 +38,6 @@ | |||
38 | #include <linux/ioctl.h> | 38 | #include <linux/ioctl.h> |
39 | #include "kobil_sct.h" | 39 | #include "kobil_sct.h" |
40 | 40 | ||
41 | static bool debug; | ||
42 | |||
43 | /* Version Information */ | 41 | /* Version Information */ |
44 | #define DRIVER_VERSION "21/05/2004" | 42 | #define DRIVER_VERSION "21/05/2004" |
45 | #define DRIVER_AUTHOR "KOBIL Systems GmbH - http://www.kobil.com" | 43 | #define DRIVER_AUTHOR "KOBIL Systems GmbH - http://www.kobil.com" |
@@ -139,17 +137,16 @@ static int kobil_startup(struct usb_serial *serial) | |||
139 | 137 | ||
140 | switch (priv->device_type) { | 138 | switch (priv->device_type) { |
141 | case KOBIL_ADAPTER_B_PRODUCT_ID: | 139 | case KOBIL_ADAPTER_B_PRODUCT_ID: |
142 | printk(KERN_DEBUG "KOBIL B1 PRO / KAAN PRO detected\n"); | 140 | dev_dbg(&serial->dev->dev, "KOBIL B1 PRO / KAAN PRO detected\n"); |
143 | break; | 141 | break; |
144 | case KOBIL_ADAPTER_K_PRODUCT_ID: | 142 | case KOBIL_ADAPTER_K_PRODUCT_ID: |
145 | printk(KERN_DEBUG | 143 | dev_dbg(&serial->dev->dev, "KOBIL KAAN Standard Plus / SecOVID Reader Plus detected\n"); |
146 | "KOBIL KAAN Standard Plus / SecOVID Reader Plus detected\n"); | ||
147 | break; | 144 | break; |
148 | case KOBIL_USBTWIN_PRODUCT_ID: | 145 | case KOBIL_USBTWIN_PRODUCT_ID: |
149 | printk(KERN_DEBUG "KOBIL USBTWIN detected\n"); | 146 | dev_dbg(&serial->dev->dev, "KOBIL USBTWIN detected\n"); |
150 | break; | 147 | break; |
151 | case KOBIL_KAAN_SIM_PRODUCT_ID: | 148 | case KOBIL_KAAN_SIM_PRODUCT_ID: |
152 | printk(KERN_DEBUG "KOBIL KAAN SIM detected\n"); | 149 | dev_dbg(&serial->dev->dev, "KOBIL KAAN SIM detected\n"); |
153 | break; | 150 | break; |
154 | } | 151 | } |
155 | usb_set_serial_port_data(serial->port[0], priv); | 152 | usb_set_serial_port_data(serial->port[0], priv); |
@@ -164,13 +161,15 @@ static int kobil_startup(struct usb_serial *serial) | |||
164 | for (i = 0; i < altsetting->desc.bNumEndpoints; i++) { | 161 | for (i = 0; i < altsetting->desc.bNumEndpoints; i++) { |
165 | endpoint = &altsetting->endpoint[i]; | 162 | endpoint = &altsetting->endpoint[i]; |
166 | if (usb_endpoint_is_int_out(&endpoint->desc)) { | 163 | if (usb_endpoint_is_int_out(&endpoint->desc)) { |
167 | dbg("%s Found interrupt out endpoint. Address: %d", | 164 | dev_dbg(&serial->dev->dev, |
165 | "%s Found interrupt out endpoint. Address: %d\n", | ||
168 | __func__, endpoint->desc.bEndpointAddress); | 166 | __func__, endpoint->desc.bEndpointAddress); |
169 | priv->write_int_endpoint_address = | 167 | priv->write_int_endpoint_address = |
170 | endpoint->desc.bEndpointAddress; | 168 | endpoint->desc.bEndpointAddress; |
171 | } | 169 | } |
172 | if (usb_endpoint_is_int_in(&endpoint->desc)) { | 170 | if (usb_endpoint_is_int_in(&endpoint->desc)) { |
173 | dbg("%s Found interrupt in endpoint. Address: %d", | 171 | dev_dbg(&serial->dev->dev, |
172 | "%s Found interrupt in endpoint. Address: %d\n", | ||
174 | __func__, endpoint->desc.bEndpointAddress); | 173 | __func__, endpoint->desc.bEndpointAddress); |
175 | priv->read_int_endpoint_address = | 174 | priv->read_int_endpoint_address = |
176 | endpoint->desc.bEndpointAddress; | 175 | endpoint->desc.bEndpointAddress; |
@@ -200,6 +199,7 @@ static void kobil_init_termios(struct tty_struct *tty) | |||
200 | 199 | ||
201 | static int kobil_open(struct tty_struct *tty, struct usb_serial_port *port) | 200 | static int kobil_open(struct tty_struct *tty, struct usb_serial_port *port) |
202 | { | 201 | { |
202 | struct device *dev = &port->dev; | ||
203 | int result = 0; | 203 | int result = 0; |
204 | struct kobil_private *priv; | 204 | struct kobil_private *priv; |
205 | unsigned char *transfer_buffer; | 205 | unsigned char *transfer_buffer; |
@@ -215,12 +215,10 @@ static int kobil_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
215 | 215 | ||
216 | /* allocate write_urb */ | 216 | /* allocate write_urb */ |
217 | if (!port->write_urb) { | 217 | if (!port->write_urb) { |
218 | dbg("%s - port %d Allocating port->write_urb", | 218 | dev_dbg(dev, "%s - Allocating port->write_urb\n", __func__); |
219 | __func__, port->number); | ||
220 | port->write_urb = usb_alloc_urb(0, GFP_KERNEL); | 219 | port->write_urb = usb_alloc_urb(0, GFP_KERNEL); |
221 | if (!port->write_urb) { | 220 | if (!port->write_urb) { |
222 | dbg("%s - port %d usb_alloc_urb failed", | 221 | dev_dbg(dev, "%s - usb_alloc_urb failed\n", __func__); |
223 | __func__, port->number); | ||
224 | kfree(transfer_buffer); | 222 | kfree(transfer_buffer); |
225 | return -ENOMEM; | 223 | return -ENOMEM; |
226 | } | 224 | } |
@@ -247,10 +245,9 @@ static int kobil_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
247 | transfer_buffer_length, | 245 | transfer_buffer_length, |
248 | KOBIL_TIMEOUT | 246 | KOBIL_TIMEOUT |
249 | ); | 247 | ); |
250 | dbg("%s - port %d Send get_HW_version URB returns: %i", | 248 | dev_dbg(dev, "%s - Send get_HW_version URB returns: %i\n", __func__, result); |
251 | __func__, port->number, result); | 249 | dev_dbg(dev, "Harware version: %i.%i.%i\n", transfer_buffer[0], |
252 | dbg("Harware version: %i.%i.%i", | 250 | transfer_buffer[1], transfer_buffer[2]); |
253 | transfer_buffer[0], transfer_buffer[1], transfer_buffer[2]); | ||
254 | 251 | ||
255 | /* get firmware version */ | 252 | /* get firmware version */ |
256 | result = usb_control_msg(port->serial->dev, | 253 | result = usb_control_msg(port->serial->dev, |
@@ -263,10 +260,9 @@ static int kobil_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
263 | transfer_buffer_length, | 260 | transfer_buffer_length, |
264 | KOBIL_TIMEOUT | 261 | KOBIL_TIMEOUT |
265 | ); | 262 | ); |
266 | dbg("%s - port %d Send get_FW_version URB returns: %i", | 263 | dev_dbg(dev, "%s - Send get_FW_version URB returns: %i\n", __func__, result); |
267 | __func__, port->number, result); | 264 | dev_dbg(dev, "Firmware version: %i.%i.%i\n", transfer_buffer[0], |
268 | dbg("Firmware version: %i.%i.%i", | 265 | transfer_buffer[1], transfer_buffer[2]); |
269 | transfer_buffer[0], transfer_buffer[1], transfer_buffer[2]); | ||
270 | 266 | ||
271 | if (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID || | 267 | if (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID || |
272 | priv->device_type == KOBIL_ADAPTER_K_PRODUCT_ID) { | 268 | priv->device_type == KOBIL_ADAPTER_K_PRODUCT_ID) { |
@@ -282,8 +278,7 @@ static int kobil_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
282 | 0, | 278 | 0, |
283 | KOBIL_TIMEOUT | 279 | KOBIL_TIMEOUT |
284 | ); | 280 | ); |
285 | dbg("%s - port %d Send set_baudrate URB returns: %i", | 281 | dev_dbg(dev, "%s - Send set_baudrate URB returns: %i\n", __func__, result); |
286 | __func__, port->number, result); | ||
287 | 282 | ||
288 | /* reset all queues */ | 283 | /* reset all queues */ |
289 | result = usb_control_msg(port->serial->dev, | 284 | result = usb_control_msg(port->serial->dev, |
@@ -296,16 +291,14 @@ static int kobil_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
296 | 0, | 291 | 0, |
297 | KOBIL_TIMEOUT | 292 | KOBIL_TIMEOUT |
298 | ); | 293 | ); |
299 | dbg("%s - port %d Send reset_all_queues URB returns: %i", | 294 | dev_dbg(dev, "%s - Send reset_all_queues URB returns: %i\n", __func__, result); |
300 | __func__, port->number, result); | ||
301 | } | 295 | } |
302 | if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID || | 296 | if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID || |
303 | priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID || | 297 | priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID || |
304 | priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID) { | 298 | priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID) { |
305 | /* start reading (Adapter B 'cause PNP string) */ | 299 | /* start reading (Adapter B 'cause PNP string) */ |
306 | result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); | 300 | result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); |
307 | dbg("%s - port %d Send read URB returns: %i", | 301 | dev_dbg(dev, "%s - Send read URB returns: %i\n", __func__, result); |
308 | __func__, port->number, result); | ||
309 | } | 302 | } |
310 | 303 | ||
311 | kfree(transfer_buffer); | 304 | kfree(transfer_buffer); |
@@ -333,11 +326,9 @@ static void kobil_read_int_callback(struct urb *urb) | |||
333 | struct tty_struct *tty; | 326 | struct tty_struct *tty; |
334 | unsigned char *data = urb->transfer_buffer; | 327 | unsigned char *data = urb->transfer_buffer; |
335 | int status = urb->status; | 328 | int status = urb->status; |
336 | /* char *dbg_data; */ | ||
337 | 329 | ||
338 | if (status) { | 330 | if (status) { |
339 | dbg("%s - port %d Read int status not zero: %d", | 331 | dev_dbg(&port->dev, "%s - Read int status not zero: %d\n", __func__, status); |
340 | __func__, port->number, status); | ||
341 | return; | 332 | return; |
342 | } | 333 | } |
343 | 334 | ||
@@ -346,6 +337,8 @@ static void kobil_read_int_callback(struct urb *urb) | |||
346 | 337 | ||
347 | /* BEGIN DEBUG */ | 338 | /* BEGIN DEBUG */ |
348 | /* | 339 | /* |
340 | char *dbg_data; | ||
341 | |||
349 | dbg_data = kzalloc((3 * purb->actual_length + 10) | 342 | dbg_data = kzalloc((3 * purb->actual_length + 10) |
350 | * sizeof(char), GFP_KERNEL); | 343 | * sizeof(char), GFP_KERNEL); |
351 | if (! dbg_data) { | 344 | if (! dbg_data) { |
@@ -354,7 +347,7 @@ static void kobil_read_int_callback(struct urb *urb) | |||
354 | for (i = 0; i < purb->actual_length; i++) { | 347 | for (i = 0; i < purb->actual_length; i++) { |
355 | sprintf(dbg_data +3*i, "%02X ", data[i]); | 348 | sprintf(dbg_data +3*i, "%02X ", data[i]); |
356 | } | 349 | } |
357 | dbg(" <-- %s", dbg_data); | 350 | dev_dbg(&port->dev, " <-- %s\n", dbg_data); |
358 | kfree(dbg_data); | 351 | kfree(dbg_data); |
359 | */ | 352 | */ |
360 | /* END DEBUG */ | 353 | /* END DEBUG */ |
@@ -365,8 +358,7 @@ static void kobil_read_int_callback(struct urb *urb) | |||
365 | tty_kref_put(tty); | 358 | tty_kref_put(tty); |
366 | 359 | ||
367 | result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); | 360 | result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); |
368 | dbg("%s - port %d Send read URB returns: %i", | 361 | dev_dbg(&port->dev, "%s - Send read URB returns: %i\n", __func__, result); |
369 | __func__, port->number, result); | ||
370 | } | 362 | } |
371 | 363 | ||
372 | 364 | ||
@@ -384,22 +376,20 @@ static int kobil_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
384 | struct kobil_private *priv; | 376 | struct kobil_private *priv; |
385 | 377 | ||
386 | if (count == 0) { | 378 | if (count == 0) { |
387 | dbg("%s - port %d write request of 0 bytes", | 379 | dev_dbg(&port->dev, "%s - write request of 0 bytes\n", __func__); |
388 | __func__, port->number); | ||
389 | return 0; | 380 | return 0; |
390 | } | 381 | } |
391 | 382 | ||
392 | priv = usb_get_serial_port_data(port); | 383 | priv = usb_get_serial_port_data(port); |
393 | 384 | ||
394 | if (count > (KOBIL_BUF_LENGTH - priv->filled)) { | 385 | if (count > (KOBIL_BUF_LENGTH - priv->filled)) { |
395 | dbg("%s - port %d Error: write request bigger than buffer size", __func__, port->number); | 386 | dev_dbg(&port->dev, "%s - Error: write request bigger than buffer size\n", __func__); |
396 | return -ENOMEM; | 387 | return -ENOMEM; |
397 | } | 388 | } |
398 | 389 | ||
399 | /* Copy data to buffer */ | 390 | /* Copy data to buffer */ |
400 | memcpy(priv->buf + priv->filled, buf, count); | 391 | memcpy(priv->buf + priv->filled, buf, count); |
401 | usb_serial_debug_data(debug, &port->dev, __func__, count, | 392 | usb_serial_debug_data(&port->dev, __func__, count, priv->buf + priv->filled); |
402 | priv->buf + priv->filled); | ||
403 | priv->filled = priv->filled + count; | 393 | priv->filled = priv->filled + count; |
404 | 394 | ||
405 | /* only send complete block. TWIN, KAAN SIM and adapter K | 395 | /* only send complete block. TWIN, KAAN SIM and adapter K |
@@ -432,8 +422,7 @@ static int kobil_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
432 | 422 | ||
433 | priv->cur_pos = priv->cur_pos + length; | 423 | priv->cur_pos = priv->cur_pos + length; |
434 | result = usb_submit_urb(port->write_urb, GFP_NOIO); | 424 | result = usb_submit_urb(port->write_urb, GFP_NOIO); |
435 | dbg("%s - port %d Send write URB returns: %i", | 425 | dev_dbg(&port->dev, "%s - Send write URB returns: %i\n", __func__, result); |
436 | __func__, port->number, result); | ||
437 | todo = priv->filled - priv->cur_pos; | 426 | todo = priv->filled - priv->cur_pos; |
438 | 427 | ||
439 | if (todo > 0) | 428 | if (todo > 0) |
@@ -448,8 +437,7 @@ static int kobil_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
448 | priv->device_type == KOBIL_ADAPTER_K_PRODUCT_ID) { | 437 | priv->device_type == KOBIL_ADAPTER_K_PRODUCT_ID) { |
449 | result = usb_submit_urb(port->interrupt_in_urb, | 438 | result = usb_submit_urb(port->interrupt_in_urb, |
450 | GFP_NOIO); | 439 | GFP_NOIO); |
451 | dbg("%s - port %d Send read URB returns: %i", | 440 | dev_dbg(&port->dev, "%s - Send read URB returns: %i\n", __func__, result); |
452 | __func__, port->number, result); | ||
453 | } | 441 | } |
454 | } | 442 | } |
455 | return count; | 443 | return count; |
@@ -493,8 +481,8 @@ static int kobil_tiocmget(struct tty_struct *tty) | |||
493 | transfer_buffer_length, | 481 | transfer_buffer_length, |
494 | KOBIL_TIMEOUT); | 482 | KOBIL_TIMEOUT); |
495 | 483 | ||
496 | dbg("%s - port %d Send get_status_line_state URB returns: %i. Statusline: %02x", | 484 | dev_dbg(&port->dev, "%s - Send get_status_line_state URB returns: %i. Statusline: %02x\n", |
497 | __func__, port->number, result, transfer_buffer[0]); | 485 | __func__, result, transfer_buffer[0]); |
498 | 486 | ||
499 | result = 0; | 487 | result = 0; |
500 | if ((transfer_buffer[0] & SUSBCR_GSL_DSR) != 0) | 488 | if ((transfer_buffer[0] & SUSBCR_GSL_DSR) != 0) |
@@ -507,6 +495,7 @@ static int kobil_tiocmset(struct tty_struct *tty, | |||
507 | unsigned int set, unsigned int clear) | 495 | unsigned int set, unsigned int clear) |
508 | { | 496 | { |
509 | struct usb_serial_port *port = tty->driver_data; | 497 | struct usb_serial_port *port = tty->driver_data; |
498 | struct device *dev = &port->dev; | ||
510 | struct kobil_private *priv; | 499 | struct kobil_private *priv; |
511 | int result; | 500 | int result; |
512 | int dtr = 0; | 501 | int dtr = 0; |
@@ -538,11 +527,9 @@ static int kobil_tiocmset(struct tty_struct *tty, | |||
538 | 527 | ||
539 | if (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID) { | 528 | if (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID) { |
540 | if (dtr != 0) | 529 | if (dtr != 0) |
541 | dbg("%s - port %d Setting DTR", | 530 | dev_dbg(dev, "%s - Setting DTR\n", __func__); |
542 | __func__, port->number); | ||
543 | else | 531 | else |
544 | dbg("%s - port %d Clearing DTR", | 532 | dev_dbg(dev, "%s - Clearing DTR\n", __func__); |
545 | __func__, port->number); | ||
546 | result = usb_control_msg(port->serial->dev, | 533 | result = usb_control_msg(port->serial->dev, |
547 | usb_rcvctrlpipe(port->serial->dev, 0), | 534 | usb_rcvctrlpipe(port->serial->dev, 0), |
548 | SUSBCRequest_SetStatusLinesOrQueues, | 535 | SUSBCRequest_SetStatusLinesOrQueues, |
@@ -554,11 +541,9 @@ static int kobil_tiocmset(struct tty_struct *tty, | |||
554 | KOBIL_TIMEOUT); | 541 | KOBIL_TIMEOUT); |
555 | } else { | 542 | } else { |
556 | if (rts != 0) | 543 | if (rts != 0) |
557 | dbg("%s - port %d Setting RTS", | 544 | dev_dbg(dev, "%s - Setting RTS\n", __func__); |
558 | __func__, port->number); | ||
559 | else | 545 | else |
560 | dbg("%s - port %d Clearing RTS", | 546 | dev_dbg(dev, "%s - Clearing RTS\n", __func__); |
561 | __func__, port->number); | ||
562 | result = usb_control_msg(port->serial->dev, | 547 | result = usb_control_msg(port->serial->dev, |
563 | usb_rcvctrlpipe(port->serial->dev, 0), | 548 | usb_rcvctrlpipe(port->serial->dev, 0), |
564 | SUSBCRequest_SetStatusLinesOrQueues, | 549 | SUSBCRequest_SetStatusLinesOrQueues, |
@@ -569,8 +554,7 @@ static int kobil_tiocmset(struct tty_struct *tty, | |||
569 | 0, | 554 | 0, |
570 | KOBIL_TIMEOUT); | 555 | KOBIL_TIMEOUT); |
571 | } | 556 | } |
572 | dbg("%s - port %d Send set_status_line URB returns: %i", | 557 | dev_dbg(dev, "%s - Send set_status_line URB returns: %i\n", __func__, result); |
573 | __func__, port->number, result); | ||
574 | kfree(transfer_buffer); | 558 | kfree(transfer_buffer); |
575 | return (result < 0) ? result : 0; | 559 | return (result < 0) ? result : 0; |
576 | } | 560 | } |
@@ -658,7 +642,8 @@ static int kobil_ioctl(struct tty_struct *tty, | |||
658 | KOBIL_TIMEOUT | 642 | KOBIL_TIMEOUT |
659 | ); | 643 | ); |
660 | 644 | ||
661 | dbg("%s - port %d Send reset_all_queues (FLUSH) URB returns: %i", __func__, port->number, result); | 645 | dev_dbg(&port->dev, |
646 | "%s - Send reset_all_queues (FLUSH) URB returns: %i", __func__, result); | ||
662 | kfree(transfer_buffer); | 647 | kfree(transfer_buffer); |
663 | return (result < 0) ? -EIO: 0; | 648 | return (result < 0) ? -EIO: 0; |
664 | default: | 649 | default: |
@@ -671,6 +656,3 @@ module_usb_serial_driver(serial_drivers, id_table); | |||
671 | MODULE_AUTHOR(DRIVER_AUTHOR); | 656 | MODULE_AUTHOR(DRIVER_AUTHOR); |
672 | MODULE_DESCRIPTION(DRIVER_DESC); | 657 | MODULE_DESCRIPTION(DRIVER_DESC); |
673 | MODULE_LICENSE("GPL"); | 658 | MODULE_LICENSE("GPL"); |
674 | |||
675 | module_param(debug, bool, S_IRUGO | S_IWUSR); | ||
676 | MODULE_PARM_DESC(debug, "Debug enabled or not"); | ||
diff --git a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c index df98cffdba65..f3947712e137 100644 --- a/drivers/usb/serial/mct_u232.c +++ b/drivers/usb/serial/mct_u232.c | |||
@@ -45,8 +45,6 @@ | |||
45 | #define DRIVER_AUTHOR "Wolfgang Grandegger <wolfgang@ces.ch>" | 45 | #define DRIVER_AUTHOR "Wolfgang Grandegger <wolfgang@ces.ch>" |
46 | #define DRIVER_DESC "Magic Control Technology USB-RS232 converter driver" | 46 | #define DRIVER_DESC "Magic Control Technology USB-RS232 converter driver" |
47 | 47 | ||
48 | static bool debug; | ||
49 | |||
50 | /* | 48 | /* |
51 | * Function prototypes | 49 | * Function prototypes |
52 | */ | 50 | */ |
@@ -214,7 +212,7 @@ static int mct_u232_set_baud_rate(struct tty_struct *tty, | |||
214 | value, rc); | 212 | value, rc); |
215 | else | 213 | else |
216 | tty_encode_baud_rate(tty, speed, speed); | 214 | tty_encode_baud_rate(tty, speed, speed); |
217 | dbg("set_baud_rate: value: 0x%x, divisor: 0x%x", value, divisor); | 215 | dev_dbg(&port->dev, "set_baud_rate: value: 0x%x, divisor: 0x%x\n", value, divisor); |
218 | 216 | ||
219 | /* Mimic the MCT-supplied Windows driver (version 1.21P.0104), which | 217 | /* Mimic the MCT-supplied Windows driver (version 1.21P.0104), which |
220 | always sends two extra USB 'device request' messages after the | 218 | always sends two extra USB 'device request' messages after the |
@@ -247,8 +245,8 @@ static int mct_u232_set_baud_rate(struct tty_struct *tty, | |||
247 | if (port && C_CRTSCTS(tty)) | 245 | if (port && C_CRTSCTS(tty)) |
248 | cts_enable_byte = 1; | 246 | cts_enable_byte = 1; |
249 | 247 | ||
250 | dbg("set_baud_rate: send second control message, data = %02X", | 248 | dev_dbg(&port->dev, "set_baud_rate: send second control message, data = %02X\n", |
251 | cts_enable_byte); | 249 | cts_enable_byte); |
252 | buf[0] = cts_enable_byte; | 250 | buf[0] = cts_enable_byte; |
253 | rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), | 251 | rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), |
254 | MCT_U232_SET_CTS_REQUEST, | 252 | MCT_U232_SET_CTS_REQUEST, |
@@ -263,7 +261,8 @@ static int mct_u232_set_baud_rate(struct tty_struct *tty, | |||
263 | return rc; | 261 | return rc; |
264 | } /* mct_u232_set_baud_rate */ | 262 | } /* mct_u232_set_baud_rate */ |
265 | 263 | ||
266 | static int mct_u232_set_line_ctrl(struct usb_serial *serial, unsigned char lcr) | 264 | static int mct_u232_set_line_ctrl(struct usb_serial_port *port, |
265 | unsigned char lcr) | ||
267 | { | 266 | { |
268 | int rc; | 267 | int rc; |
269 | unsigned char *buf; | 268 | unsigned char *buf; |
@@ -273,20 +272,19 @@ static int mct_u232_set_line_ctrl(struct usb_serial *serial, unsigned char lcr) | |||
273 | return -ENOMEM; | 272 | return -ENOMEM; |
274 | 273 | ||
275 | buf[0] = lcr; | 274 | buf[0] = lcr; |
276 | rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), | 275 | rc = usb_control_msg(port->serial->dev, usb_sndctrlpipe(port->serial->dev, 0), |
277 | MCT_U232_SET_LINE_CTRL_REQUEST, | 276 | MCT_U232_SET_LINE_CTRL_REQUEST, |
278 | MCT_U232_SET_REQUEST_TYPE, | 277 | MCT_U232_SET_REQUEST_TYPE, |
279 | 0, 0, buf, MCT_U232_SET_LINE_CTRL_SIZE, | 278 | 0, 0, buf, MCT_U232_SET_LINE_CTRL_SIZE, |
280 | WDR_TIMEOUT); | 279 | WDR_TIMEOUT); |
281 | if (rc < 0) | 280 | if (rc < 0) |
282 | dev_err(&serial->dev->dev, | 281 | dev_err(&port->dev, "Set LINE CTRL 0x%x failed (error = %d)\n", lcr, rc); |
283 | "Set LINE CTRL 0x%x failed (error = %d)\n", lcr, rc); | 282 | dev_dbg(&port->dev, "set_line_ctrl: 0x%x\n", lcr); |
284 | dbg("set_line_ctrl: 0x%x", lcr); | ||
285 | kfree(buf); | 283 | kfree(buf); |
286 | return rc; | 284 | return rc; |
287 | } /* mct_u232_set_line_ctrl */ | 285 | } /* mct_u232_set_line_ctrl */ |
288 | 286 | ||
289 | static int mct_u232_set_modem_ctrl(struct usb_serial *serial, | 287 | static int mct_u232_set_modem_ctrl(struct usb_serial_port *port, |
290 | unsigned int control_state) | 288 | unsigned int control_state) |
291 | { | 289 | { |
292 | int rc; | 290 | int rc; |
@@ -304,25 +302,24 @@ static int mct_u232_set_modem_ctrl(struct usb_serial *serial, | |||
304 | mcr |= MCT_U232_MCR_RTS; | 302 | mcr |= MCT_U232_MCR_RTS; |
305 | 303 | ||
306 | buf[0] = mcr; | 304 | buf[0] = mcr; |
307 | rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), | 305 | rc = usb_control_msg(port->serial->dev, usb_sndctrlpipe(port->serial->dev, 0), |
308 | MCT_U232_SET_MODEM_CTRL_REQUEST, | 306 | MCT_U232_SET_MODEM_CTRL_REQUEST, |
309 | MCT_U232_SET_REQUEST_TYPE, | 307 | MCT_U232_SET_REQUEST_TYPE, |
310 | 0, 0, buf, MCT_U232_SET_MODEM_CTRL_SIZE, | 308 | 0, 0, buf, MCT_U232_SET_MODEM_CTRL_SIZE, |
311 | WDR_TIMEOUT); | 309 | WDR_TIMEOUT); |
312 | kfree(buf); | 310 | kfree(buf); |
313 | 311 | ||
314 | dbg("set_modem_ctrl: state=0x%x ==> mcr=0x%x", control_state, mcr); | 312 | dev_dbg(&port->dev, "set_modem_ctrl: state=0x%x ==> mcr=0x%x\n", control_state, mcr); |
315 | 313 | ||
316 | if (rc < 0) { | 314 | if (rc < 0) { |
317 | dev_err(&serial->dev->dev, | 315 | dev_err(&port->dev, "Set MODEM CTRL 0x%x failed (error = %d)\n", mcr, rc); |
318 | "Set MODEM CTRL 0x%x failed (error = %d)\n", mcr, rc); | ||
319 | return rc; | 316 | return rc; |
320 | } | 317 | } |
321 | return 0; | 318 | return 0; |
322 | } /* mct_u232_set_modem_ctrl */ | 319 | } /* mct_u232_set_modem_ctrl */ |
323 | 320 | ||
324 | static int mct_u232_get_modem_stat(struct usb_serial *serial, | 321 | static int mct_u232_get_modem_stat(struct usb_serial_port *port, |
325 | unsigned char *msr) | 322 | unsigned char *msr) |
326 | { | 323 | { |
327 | int rc; | 324 | int rc; |
328 | unsigned char *buf; | 325 | unsigned char *buf; |
@@ -332,19 +329,18 @@ static int mct_u232_get_modem_stat(struct usb_serial *serial, | |||
332 | *msr = 0; | 329 | *msr = 0; |
333 | return -ENOMEM; | 330 | return -ENOMEM; |
334 | } | 331 | } |
335 | rc = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), | 332 | rc = usb_control_msg(port->serial->dev, usb_rcvctrlpipe(port->serial->dev, 0), |
336 | MCT_U232_GET_MODEM_STAT_REQUEST, | 333 | MCT_U232_GET_MODEM_STAT_REQUEST, |
337 | MCT_U232_GET_REQUEST_TYPE, | 334 | MCT_U232_GET_REQUEST_TYPE, |
338 | 0, 0, buf, MCT_U232_GET_MODEM_STAT_SIZE, | 335 | 0, 0, buf, MCT_U232_GET_MODEM_STAT_SIZE, |
339 | WDR_TIMEOUT); | 336 | WDR_TIMEOUT); |
340 | if (rc < 0) { | 337 | if (rc < 0) { |
341 | dev_err(&serial->dev->dev, | 338 | dev_err(&port->dev, "Get MODEM STATus failed (error = %d)\n", rc); |
342 | "Get MODEM STATus failed (error = %d)\n", rc); | ||
343 | *msr = 0; | 339 | *msr = 0; |
344 | } else { | 340 | } else { |
345 | *msr = buf[0]; | 341 | *msr = buf[0]; |
346 | } | 342 | } |
347 | dbg("get_modem_stat: 0x%x", *msr); | 343 | dev_dbg(&port->dev, "get_modem_stat: 0x%x\n", *msr); |
348 | kfree(buf); | 344 | kfree(buf); |
349 | return rc; | 345 | return rc; |
350 | } /* mct_u232_get_modem_stat */ | 346 | } /* mct_u232_get_modem_stat */ |
@@ -363,8 +359,8 @@ static void mct_u232_msr_to_icount(struct async_icount *icount, | |||
363 | icount->dcd++; | 359 | icount->dcd++; |
364 | } /* mct_u232_msr_to_icount */ | 360 | } /* mct_u232_msr_to_icount */ |
365 | 361 | ||
366 | static void mct_u232_msr_to_state(unsigned int *control_state, | 362 | static void mct_u232_msr_to_state(struct usb_serial_port *port, |
367 | unsigned char msr) | 363 | unsigned int *control_state, unsigned char msr) |
368 | { | 364 | { |
369 | /* Translate Control Line states */ | 365 | /* Translate Control Line states */ |
370 | if (msr & MCT_U232_MSR_DSR) | 366 | if (msr & MCT_U232_MSR_DSR) |
@@ -383,7 +379,7 @@ static void mct_u232_msr_to_state(unsigned int *control_state, | |||
383 | *control_state |= TIOCM_CD; | 379 | *control_state |= TIOCM_CD; |
384 | else | 380 | else |
385 | *control_state &= ~TIOCM_CD; | 381 | *control_state &= ~TIOCM_CD; |
386 | dbg("msr_to_state: msr=0x%x ==> state=0x%x", msr, *control_state); | 382 | dev_dbg(&port->dev, "msr_to_state: msr=0x%x ==> state=0x%x\n", msr, *control_state); |
387 | } /* mct_u232_msr_to_state */ | 383 | } /* mct_u232_msr_to_state */ |
388 | 384 | ||
389 | /* | 385 | /* |
@@ -465,14 +461,14 @@ static int mct_u232_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
465 | control_state = priv->control_state; | 461 | control_state = priv->control_state; |
466 | last_lcr = priv->last_lcr; | 462 | last_lcr = priv->last_lcr; |
467 | spin_unlock_irqrestore(&priv->lock, flags); | 463 | spin_unlock_irqrestore(&priv->lock, flags); |
468 | mct_u232_set_modem_ctrl(serial, control_state); | 464 | mct_u232_set_modem_ctrl(port, control_state); |
469 | mct_u232_set_line_ctrl(serial, last_lcr); | 465 | mct_u232_set_line_ctrl(port, last_lcr); |
470 | 466 | ||
471 | /* Read modem status and update control state */ | 467 | /* Read modem status and update control state */ |
472 | mct_u232_get_modem_stat(serial, &last_msr); | 468 | mct_u232_get_modem_stat(port, &last_msr); |
473 | spin_lock_irqsave(&priv->lock, flags); | 469 | spin_lock_irqsave(&priv->lock, flags); |
474 | priv->last_msr = last_msr; | 470 | priv->last_msr = last_msr; |
475 | mct_u232_msr_to_state(&priv->control_state, priv->last_msr); | 471 | mct_u232_msr_to_state(port, &priv->control_state, priv->last_msr); |
476 | spin_unlock_irqrestore(&priv->lock, flags); | 472 | spin_unlock_irqrestore(&priv->lock, flags); |
477 | 473 | ||
478 | retval = usb_submit_urb(port->read_urb, GFP_KERNEL); | 474 | retval = usb_submit_urb(port->read_urb, GFP_KERNEL); |
@@ -512,7 +508,7 @@ static void mct_u232_dtr_rts(struct usb_serial_port *port, int on) | |||
512 | priv->control_state &= ~(TIOCM_DTR | TIOCM_RTS); | 508 | priv->control_state &= ~(TIOCM_DTR | TIOCM_RTS); |
513 | control_state = priv->control_state; | 509 | control_state = priv->control_state; |
514 | spin_unlock_irq(&priv->lock); | 510 | spin_unlock_irq(&priv->lock); |
515 | mct_u232_set_modem_ctrl(port->serial, control_state); | 511 | mct_u232_set_modem_ctrl(port, control_state); |
516 | } | 512 | } |
517 | mutex_unlock(&port->serial->disc_mutex); | 513 | mutex_unlock(&port->serial->disc_mutex); |
518 | } | 514 | } |
@@ -532,7 +528,6 @@ static void mct_u232_read_int_callback(struct urb *urb) | |||
532 | { | 528 | { |
533 | struct usb_serial_port *port = urb->context; | 529 | struct usb_serial_port *port = urb->context; |
534 | struct mct_u232_private *priv = usb_get_serial_port_data(port); | 530 | struct mct_u232_private *priv = usb_get_serial_port_data(port); |
535 | struct usb_serial *serial = port->serial; | ||
536 | struct tty_struct *tty; | 531 | struct tty_struct *tty; |
537 | unsigned char *data = urb->transfer_buffer; | 532 | unsigned char *data = urb->transfer_buffer; |
538 | int retval; | 533 | int retval; |
@@ -547,22 +542,16 @@ static void mct_u232_read_int_callback(struct urb *urb) | |||
547 | case -ENOENT: | 542 | case -ENOENT: |
548 | case -ESHUTDOWN: | 543 | case -ESHUTDOWN: |
549 | /* this urb is terminated, clean up */ | 544 | /* this urb is terminated, clean up */ |
550 | dbg("%s - urb shutting down with status: %d", | 545 | dev_dbg(&port->dev, "%s - urb shutting down with status: %d\n", |
551 | __func__, status); | 546 | __func__, status); |
552 | return; | 547 | return; |
553 | default: | 548 | default: |
554 | dbg("%s - nonzero urb status received: %d", | 549 | dev_dbg(&port->dev, "%s - nonzero urb status received: %d\n", |
555 | __func__, status); | 550 | __func__, status); |
556 | goto exit; | 551 | goto exit; |
557 | } | 552 | } |
558 | 553 | ||
559 | if (!serial) { | 554 | usb_serial_debug_data(&port->dev, __func__, urb->actual_length, data); |
560 | dbg("%s - bad serial pointer, exiting", __func__); | ||
561 | return; | ||
562 | } | ||
563 | |||
564 | usb_serial_debug_data(debug, &port->dev, __func__, | ||
565 | urb->actual_length, data); | ||
566 | 555 | ||
567 | /* | 556 | /* |
568 | * Work-a-round: handle the 'usual' bulk-in pipe here | 557 | * Work-a-round: handle the 'usual' bulk-in pipe here |
@@ -588,7 +577,7 @@ static void mct_u232_read_int_callback(struct urb *urb) | |||
588 | priv->last_msr = data[MCT_U232_MSR_INDEX]; | 577 | priv->last_msr = data[MCT_U232_MSR_INDEX]; |
589 | 578 | ||
590 | /* Record Control Line states */ | 579 | /* Record Control Line states */ |
591 | mct_u232_msr_to_state(&priv->control_state, priv->last_msr); | 580 | mct_u232_msr_to_state(port, &priv->control_state, priv->last_msr); |
592 | 581 | ||
593 | mct_u232_msr_to_icount(&priv->icount, priv->last_msr); | 582 | mct_u232_msr_to_icount(&priv->icount, priv->last_msr); |
594 | 583 | ||
@@ -656,18 +645,18 @@ static void mct_u232_set_termios(struct tty_struct *tty, | |||
656 | 645 | ||
657 | /* reassert DTR and RTS on transition from B0 */ | 646 | /* reassert DTR and RTS on transition from B0 */ |
658 | if ((old_cflag & CBAUD) == B0) { | 647 | if ((old_cflag & CBAUD) == B0) { |
659 | dbg("%s: baud was B0", __func__); | 648 | dev_dbg(&port->dev, "%s: baud was B0\n", __func__); |
660 | control_state |= TIOCM_DTR | TIOCM_RTS; | 649 | control_state |= TIOCM_DTR | TIOCM_RTS; |
661 | mct_u232_set_modem_ctrl(serial, control_state); | 650 | mct_u232_set_modem_ctrl(port, control_state); |
662 | } | 651 | } |
663 | 652 | ||
664 | mct_u232_set_baud_rate(tty, serial, port, tty_get_baud_rate(tty)); | 653 | mct_u232_set_baud_rate(tty, serial, port, tty_get_baud_rate(tty)); |
665 | 654 | ||
666 | if ((cflag & CBAUD) == B0) { | 655 | if ((cflag & CBAUD) == B0) { |
667 | dbg("%s: baud is B0", __func__); | 656 | dev_dbg(&port->dev, "%s: baud is B0\n", __func__); |
668 | /* Drop RTS and DTR */ | 657 | /* Drop RTS and DTR */ |
669 | control_state &= ~(TIOCM_DTR | TIOCM_RTS); | 658 | control_state &= ~(TIOCM_DTR | TIOCM_RTS); |
670 | mct_u232_set_modem_ctrl(serial, control_state); | 659 | mct_u232_set_modem_ctrl(port, control_state); |
671 | } | 660 | } |
672 | 661 | ||
673 | /* | 662 | /* |
@@ -704,7 +693,7 @@ static void mct_u232_set_termios(struct tty_struct *tty, | |||
704 | last_lcr |= (cflag & CSTOPB) ? | 693 | last_lcr |= (cflag & CSTOPB) ? |
705 | MCT_U232_STOP_BITS_2 : MCT_U232_STOP_BITS_1; | 694 | MCT_U232_STOP_BITS_2 : MCT_U232_STOP_BITS_1; |
706 | 695 | ||
707 | mct_u232_set_line_ctrl(serial, last_lcr); | 696 | mct_u232_set_line_ctrl(port, last_lcr); |
708 | 697 | ||
709 | /* save off the modified port settings */ | 698 | /* save off the modified port settings */ |
710 | spin_lock_irqsave(&priv->lock, flags); | 699 | spin_lock_irqsave(&priv->lock, flags); |
@@ -716,7 +705,6 @@ static void mct_u232_set_termios(struct tty_struct *tty, | |||
716 | static void mct_u232_break_ctl(struct tty_struct *tty, int break_state) | 705 | static void mct_u232_break_ctl(struct tty_struct *tty, int break_state) |
717 | { | 706 | { |
718 | struct usb_serial_port *port = tty->driver_data; | 707 | struct usb_serial_port *port = tty->driver_data; |
719 | struct usb_serial *serial = port->serial; | ||
720 | struct mct_u232_private *priv = usb_get_serial_port_data(port); | 708 | struct mct_u232_private *priv = usb_get_serial_port_data(port); |
721 | unsigned char lcr; | 709 | unsigned char lcr; |
722 | unsigned long flags; | 710 | unsigned long flags; |
@@ -728,7 +716,7 @@ static void mct_u232_break_ctl(struct tty_struct *tty, int break_state) | |||
728 | lcr |= MCT_U232_SET_BREAK; | 716 | lcr |= MCT_U232_SET_BREAK; |
729 | spin_unlock_irqrestore(&priv->lock, flags); | 717 | spin_unlock_irqrestore(&priv->lock, flags); |
730 | 718 | ||
731 | mct_u232_set_line_ctrl(serial, lcr); | 719 | mct_u232_set_line_ctrl(port, lcr); |
732 | } /* mct_u232_break_ctl */ | 720 | } /* mct_u232_break_ctl */ |
733 | 721 | ||
734 | 722 | ||
@@ -750,7 +738,6 @@ static int mct_u232_tiocmset(struct tty_struct *tty, | |||
750 | unsigned int set, unsigned int clear) | 738 | unsigned int set, unsigned int clear) |
751 | { | 739 | { |
752 | struct usb_serial_port *port = tty->driver_data; | 740 | struct usb_serial_port *port = tty->driver_data; |
753 | struct usb_serial *serial = port->serial; | ||
754 | struct mct_u232_private *priv = usb_get_serial_port_data(port); | 741 | struct mct_u232_private *priv = usb_get_serial_port_data(port); |
755 | unsigned int control_state; | 742 | unsigned int control_state; |
756 | unsigned long flags; | 743 | unsigned long flags; |
@@ -769,7 +756,7 @@ static int mct_u232_tiocmset(struct tty_struct *tty, | |||
769 | 756 | ||
770 | priv->control_state = control_state; | 757 | priv->control_state = control_state; |
771 | spin_unlock_irqrestore(&priv->lock, flags); | 758 | spin_unlock_irqrestore(&priv->lock, flags); |
772 | return mct_u232_set_modem_ctrl(serial, control_state); | 759 | return mct_u232_set_modem_ctrl(port, control_state); |
773 | } | 760 | } |
774 | 761 | ||
775 | static void mct_u232_throttle(struct tty_struct *tty) | 762 | static void mct_u232_throttle(struct tty_struct *tty) |
@@ -784,7 +771,7 @@ static void mct_u232_throttle(struct tty_struct *tty) | |||
784 | priv->control_state &= ~TIOCM_RTS; | 771 | priv->control_state &= ~TIOCM_RTS; |
785 | control_state = priv->control_state; | 772 | control_state = priv->control_state; |
786 | spin_unlock_irq(&priv->lock); | 773 | spin_unlock_irq(&priv->lock); |
787 | (void) mct_u232_set_modem_ctrl(port->serial, control_state); | 774 | mct_u232_set_modem_ctrl(port, control_state); |
788 | } else { | 775 | } else { |
789 | spin_unlock_irq(&priv->lock); | 776 | spin_unlock_irq(&priv->lock); |
790 | } | 777 | } |
@@ -802,7 +789,7 @@ static void mct_u232_unthrottle(struct tty_struct *tty) | |||
802 | priv->control_state |= TIOCM_RTS; | 789 | priv->control_state |= TIOCM_RTS; |
803 | control_state = priv->control_state; | 790 | control_state = priv->control_state; |
804 | spin_unlock_irq(&priv->lock); | 791 | spin_unlock_irq(&priv->lock); |
805 | (void) mct_u232_set_modem_ctrl(port->serial, control_state); | 792 | mct_u232_set_modem_ctrl(port, control_state); |
806 | } else { | 793 | } else { |
807 | spin_unlock_irq(&priv->lock); | 794 | spin_unlock_irq(&priv->lock); |
808 | } | 795 | } |
@@ -817,13 +804,13 @@ static int mct_u232_ioctl(struct tty_struct *tty, | |||
817 | struct async_icount cnow, cprev; | 804 | struct async_icount cnow, cprev; |
818 | unsigned long flags; | 805 | unsigned long flags; |
819 | 806 | ||
820 | dbg("%s - port %d, cmd = 0x%x", __func__, port->number, cmd); | 807 | dev_dbg(&port->dev, "%s - cmd = 0x%x\n", __func__, cmd); |
821 | 808 | ||
822 | switch (cmd) { | 809 | switch (cmd) { |
823 | 810 | ||
824 | case TIOCMIWAIT: | 811 | case TIOCMIWAIT: |
825 | 812 | ||
826 | dbg("%s (%d) TIOCMIWAIT", __func__, port->number); | 813 | dev_dbg(&port->dev, "%s TIOCMIWAIT", __func__); |
827 | 814 | ||
828 | spin_lock_irqsave(&mct_u232_port->lock, flags); | 815 | spin_lock_irqsave(&mct_u232_port->lock, flags); |
829 | cprev = mct_u232_port->icount; | 816 | cprev = mct_u232_port->icount; |
@@ -879,8 +866,8 @@ static int mct_u232_get_icount(struct tty_struct *tty, | |||
879 | 866 | ||
880 | spin_unlock_irqrestore(&mct_u232_port->lock, flags); | 867 | spin_unlock_irqrestore(&mct_u232_port->lock, flags); |
881 | 868 | ||
882 | dbg("%s (%d) TIOCGICOUNT RX=%d, TX=%d", | 869 | dev_dbg(&port->dev, "%s TIOCGICOUNT RX=%d, TX=%d\n", |
883 | __func__, port->number, icount->rx, icount->tx); | 870 | __func__, icount->rx, icount->tx); |
884 | return 0; | 871 | return 0; |
885 | } | 872 | } |
886 | 873 | ||
@@ -889,6 +876,3 @@ module_usb_serial_driver(serial_drivers, id_table); | |||
889 | MODULE_AUTHOR(DRIVER_AUTHOR); | 876 | MODULE_AUTHOR(DRIVER_AUTHOR); |
890 | MODULE_DESCRIPTION(DRIVER_DESC); | 877 | MODULE_DESCRIPTION(DRIVER_DESC); |
891 | MODULE_LICENSE("GPL"); | 878 | MODULE_LICENSE("GPL"); |
892 | |||
893 | module_param(debug, bool, S_IRUGO | S_IWUSR); | ||
894 | MODULE_PARM_DESC(debug, "Debug enabled or not"); | ||
diff --git a/drivers/usb/serial/metro-usb.c b/drivers/usb/serial/metro-usb.c index 2b0627b5fe2c..0b257ddffbdb 100644 --- a/drivers/usb/serial/metro-usb.c +++ b/drivers/usb/serial/metro-usb.c | |||
@@ -52,9 +52,6 @@ static struct usb_device_id id_table[] = { | |||
52 | }; | 52 | }; |
53 | MODULE_DEVICE_TABLE(usb, id_table); | 53 | MODULE_DEVICE_TABLE(usb, id_table); |
54 | 54 | ||
55 | /* Input parameter constants. */ | ||
56 | static bool debug; | ||
57 | |||
58 | /* UNI-Directional mode commands for device configure */ | 55 | /* UNI-Directional mode commands for device configure */ |
59 | #define UNI_CMD_OPEN 0x80 | 56 | #define UNI_CMD_OPEN 0x80 |
60 | #define UNI_CMD_CLOSE 0xFF | 57 | #define UNI_CMD_CLOSE 0xFF |
@@ -436,7 +433,3 @@ MODULE_LICENSE("GPL"); | |||
436 | MODULE_AUTHOR("Philip Nicastro"); | 433 | MODULE_AUTHOR("Philip Nicastro"); |
437 | MODULE_AUTHOR("Aleksey Babahin <tamerlan311@gmail.com>"); | 434 | MODULE_AUTHOR("Aleksey Babahin <tamerlan311@gmail.com>"); |
438 | MODULE_DESCRIPTION(DRIVER_DESC); | 435 | MODULE_DESCRIPTION(DRIVER_DESC); |
439 | |||
440 | /* Module input parameters */ | ||
441 | module_param(debug, bool, S_IRUGO | S_IWUSR); | ||
442 | MODULE_PARM_DESC(debug, "Print debug info (bool 1=on, 0=off)"); | ||
diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c index 012f67b2e4cc..1bf1ad066666 100644 --- a/drivers/usb/serial/mos7720.c +++ b/drivers/usb/serial/mos7720.c | |||
@@ -71,8 +71,6 @@ 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 bool debug; | ||
75 | |||
76 | static struct usb_serial_driver moschip7720_2port_driver; | 74 | static struct usb_serial_driver moschip7720_2port_driver; |
77 | 75 | ||
78 | #define USB_VENDOR_ID_MOSCHIP 0x9710 | 76 | #define USB_VENDOR_ID_MOSCHIP 0x9710 |
@@ -281,16 +279,19 @@ static void send_deferred_urbs(unsigned long _mos_parport) | |||
281 | int ret_val; | 279 | int ret_val; |
282 | unsigned long flags; | 280 | unsigned long flags; |
283 | struct mos7715_parport *mos_parport = (void *)_mos_parport; | 281 | struct mos7715_parport *mos_parport = (void *)_mos_parport; |
284 | struct urbtracker *urbtrack; | 282 | struct urbtracker *urbtrack, *tmp; |
285 | struct list_head *cursor, *next; | 283 | struct list_head *cursor, *next; |
284 | struct device *dev; | ||
286 | 285 | ||
287 | /* if release function ran, game over */ | 286 | /* if release function ran, game over */ |
288 | if (unlikely(mos_parport->serial == NULL)) | 287 | if (unlikely(mos_parport->serial == NULL)) |
289 | return; | 288 | return; |
290 | 289 | ||
290 | dev = &mos_parport->serial->dev->dev; | ||
291 | |||
291 | /* try again to get the mutex */ | 292 | /* try again to get the mutex */ |
292 | if (!mutex_trylock(&mos_parport->serial->disc_mutex)) { | 293 | if (!mutex_trylock(&mos_parport->serial->disc_mutex)) { |
293 | dbg("%s: rescheduling tasklet", __func__); | 294 | dev_dbg(dev, "%s: rescheduling tasklet\n", __func__); |
294 | tasklet_schedule(&mos_parport->urb_tasklet); | 295 | tasklet_schedule(&mos_parport->urb_tasklet); |
295 | return; | 296 | return; |
296 | } | 297 | } |
@@ -305,20 +306,19 @@ static void send_deferred_urbs(unsigned long _mos_parport) | |||
305 | if (list_empty(&mos_parport->deferred_urbs)) { | 306 | if (list_empty(&mos_parport->deferred_urbs)) { |
306 | spin_unlock_irqrestore(&mos_parport->listlock, flags); | 307 | spin_unlock_irqrestore(&mos_parport->listlock, flags); |
307 | mutex_unlock(&mos_parport->serial->disc_mutex); | 308 | mutex_unlock(&mos_parport->serial->disc_mutex); |
308 | dbg("%s: deferred_urbs list empty", __func__); | 309 | dev_dbg(dev, "%s: deferred_urbs list empty\n", __func__); |
309 | return; | 310 | return; |
310 | } | 311 | } |
311 | 312 | ||
312 | /* move contents of deferred_urbs list to active_urbs list and submit */ | 313 | /* move contents of deferred_urbs list to active_urbs list and submit */ |
313 | list_for_each_safe(cursor, next, &mos_parport->deferred_urbs) | 314 | list_for_each_safe(cursor, next, &mos_parport->deferred_urbs) |
314 | list_move_tail(cursor, &mos_parport->active_urbs); | 315 | list_move_tail(cursor, &mos_parport->active_urbs); |
315 | list_for_each_entry(urbtrack, &mos_parport->active_urbs, | 316 | list_for_each_entry_safe(urbtrack, tmp, &mos_parport->active_urbs, |
316 | urblist_entry) { | 317 | urblist_entry) { |
317 | ret_val = usb_submit_urb(urbtrack->urb, GFP_ATOMIC); | 318 | ret_val = usb_submit_urb(urbtrack->urb, GFP_ATOMIC); |
318 | dbg("%s: urb submitted", __func__); | 319 | dev_dbg(dev, "%s: urb submitted\n", __func__); |
319 | if (ret_val) { | 320 | if (ret_val) { |
320 | dev_err(&mos_parport->serial->dev->dev, | 321 | dev_err(dev, "usb_submit_urb() failed: %d\n", ret_val); |
321 | "usb_submit_urb() failed: %d", ret_val); | ||
322 | list_del(&urbtrack->urblist_entry); | 322 | list_del(&urbtrack->urblist_entry); |
323 | kref_put(&urbtrack->ref_count, destroy_urbtracker); | 323 | kref_put(&urbtrack->ref_count, destroy_urbtracker); |
324 | } | 324 | } |
@@ -334,7 +334,7 @@ static void async_complete(struct urb *urb) | |||
334 | int status = urb->status; | 334 | int status = urb->status; |
335 | 335 | ||
336 | if (unlikely(status)) | 336 | if (unlikely(status)) |
337 | dbg("%s - nonzero urb status received: %d", __func__, status); | 337 | dev_dbg(&urb->dev->dev, "%s - nonzero urb status received: %d\n", __func__, status); |
338 | 338 | ||
339 | /* remove the urbtracker from the active_urbs list */ | 339 | /* remove the urbtracker from the active_urbs list */ |
340 | spin_lock(&urbtrack->mos_parport->listlock); | 340 | spin_lock(&urbtrack->mos_parport->listlock); |
@@ -389,7 +389,7 @@ static int write_parport_reg_nonblock(struct mos7715_parport *mos_parport, | |||
389 | &mos_parport->deferred_urbs); | 389 | &mos_parport->deferred_urbs); |
390 | spin_unlock_irqrestore(&mos_parport->listlock, flags); | 390 | spin_unlock_irqrestore(&mos_parport->listlock, flags); |
391 | tasklet_schedule(&mos_parport->urb_tasklet); | 391 | tasklet_schedule(&mos_parport->urb_tasklet); |
392 | dbg("tasklet scheduled"); | 392 | dev_dbg(&usbdev->dev, "tasklet scheduled"); |
393 | return 0; | 393 | return 0; |
394 | } | 394 | } |
395 | 395 | ||
@@ -690,7 +690,7 @@ static int mos7715_parport_init(struct usb_serial *serial) | |||
690 | /* allocate and initialize parallel port control struct */ | 690 | /* allocate and initialize parallel port control struct */ |
691 | mos_parport = kzalloc(sizeof(struct mos7715_parport), GFP_KERNEL); | 691 | mos_parport = kzalloc(sizeof(struct mos7715_parport), GFP_KERNEL); |
692 | if (mos_parport == NULL) { | 692 | if (mos_parport == NULL) { |
693 | dbg("mos7715_parport_init: kzalloc failed"); | 693 | dev_dbg(&serial->dev->dev, "%s: kzalloc failed\n", __func__); |
694 | return -ENOMEM; | 694 | return -ENOMEM; |
695 | } | 695 | } |
696 | mos_parport->msg_pending = false; | 696 | mos_parport->msg_pending = false; |
@@ -743,6 +743,7 @@ static void mos7720_interrupt_callback(struct urb *urb) | |||
743 | int result; | 743 | int result; |
744 | int length; | 744 | int length; |
745 | int status = urb->status; | 745 | int status = urb->status; |
746 | struct device *dev = &urb->dev->dev; | ||
746 | __u8 *data; | 747 | __u8 *data; |
747 | __u8 sp1; | 748 | __u8 sp1; |
748 | __u8 sp2; | 749 | __u8 sp2; |
@@ -755,12 +756,10 @@ static void mos7720_interrupt_callback(struct urb *urb) | |||
755 | case -ENOENT: | 756 | case -ENOENT: |
756 | case -ESHUTDOWN: | 757 | case -ESHUTDOWN: |
757 | /* this urb is terminated, clean up */ | 758 | /* this urb is terminated, clean up */ |
758 | dbg("%s - urb shutting down with status: %d", __func__, | 759 | dev_dbg(dev, "%s - urb shutting down with status: %d\n", __func__, status); |
759 | status); | ||
760 | return; | 760 | return; |
761 | default: | 761 | default: |
762 | dbg("%s - nonzero urb status received: %d", __func__, | 762 | dev_dbg(dev, "%s - nonzero urb status received: %d\n", __func__, status); |
763 | status); | ||
764 | goto exit; | 763 | goto exit; |
765 | } | 764 | } |
766 | 765 | ||
@@ -777,7 +776,7 @@ static void mos7720_interrupt_callback(struct urb *urb) | |||
777 | * oneukum 2007-03-14 */ | 776 | * oneukum 2007-03-14 */ |
778 | 777 | ||
779 | if (unlikely(length != 4)) { | 778 | if (unlikely(length != 4)) { |
780 | dbg("Wrong data !!!"); | 779 | dev_dbg(dev, "Wrong data !!!\n"); |
781 | return; | 780 | return; |
782 | } | 781 | } |
783 | 782 | ||
@@ -786,31 +785,29 @@ static void mos7720_interrupt_callback(struct urb *urb) | |||
786 | 785 | ||
787 | if ((sp1 | sp2) & 0x01) { | 786 | if ((sp1 | sp2) & 0x01) { |
788 | /* No Interrupt Pending in both the ports */ | 787 | /* No Interrupt Pending in both the ports */ |
789 | dbg("No Interrupt !!!"); | 788 | dev_dbg(dev, "No Interrupt !!!\n"); |
790 | } else { | 789 | } else { |
791 | switch (sp1 & 0x0f) { | 790 | switch (sp1 & 0x0f) { |
792 | case SERIAL_IIR_RLS: | 791 | case SERIAL_IIR_RLS: |
793 | dbg("Serial Port 1: Receiver status error or address " | 792 | dev_dbg(dev, "Serial Port 1: Receiver status error or address bit detected in 9-bit mode\n"); |
794 | "bit detected in 9-bit mode\n"); | ||
795 | break; | 793 | break; |
796 | case SERIAL_IIR_CTI: | 794 | case SERIAL_IIR_CTI: |
797 | dbg("Serial Port 1: Receiver time out"); | 795 | dev_dbg(dev, "Serial Port 1: Receiver time out\n"); |
798 | break; | 796 | break; |
799 | case SERIAL_IIR_MS: | 797 | case SERIAL_IIR_MS: |
800 | /* dbg("Serial Port 1: Modem status change"); */ | 798 | /* dev_dbg(dev, "Serial Port 1: Modem status change\n"); */ |
801 | break; | 799 | break; |
802 | } | 800 | } |
803 | 801 | ||
804 | switch (sp2 & 0x0f) { | 802 | switch (sp2 & 0x0f) { |
805 | case SERIAL_IIR_RLS: | 803 | case SERIAL_IIR_RLS: |
806 | dbg("Serial Port 2: Receiver status error or address " | 804 | dev_dbg(dev, "Serial Port 2: Receiver status error or address bit detected in 9-bit mode\n"); |
807 | "bit detected in 9-bit mode"); | ||
808 | break; | 805 | break; |
809 | case SERIAL_IIR_CTI: | 806 | case SERIAL_IIR_CTI: |
810 | dbg("Serial Port 2: Receiver time out"); | 807 | dev_dbg(dev, "Serial Port 2: Receiver time out\n"); |
811 | break; | 808 | break; |
812 | case SERIAL_IIR_MS: | 809 | case SERIAL_IIR_MS: |
813 | /* dbg("Serial Port 2: Modem status change"); */ | 810 | /* dev_dbg(dev, "Serial Port 2: Modem status change\n"); */ |
814 | break; | 811 | break; |
815 | } | 812 | } |
816 | } | 813 | } |
@@ -818,9 +815,7 @@ static void mos7720_interrupt_callback(struct urb *urb) | |||
818 | exit: | 815 | exit: |
819 | result = usb_submit_urb(urb, GFP_ATOMIC); | 816 | result = usb_submit_urb(urb, GFP_ATOMIC); |
820 | if (result) | 817 | if (result) |
821 | dev_err(&urb->dev->dev, | 818 | dev_err(dev, "%s - Error %d submitting control urb\n", __func__, result); |
822 | "%s - Error %d submitting control urb\n", | ||
823 | __func__, result); | ||
824 | } | 819 | } |
825 | 820 | ||
826 | /* | 821 | /* |
@@ -833,6 +828,7 @@ static void mos7715_interrupt_callback(struct urb *urb) | |||
833 | int result; | 828 | int result; |
834 | int length; | 829 | int length; |
835 | int status = urb->status; | 830 | int status = urb->status; |
831 | struct device *dev = &urb->dev->dev; | ||
836 | __u8 *data; | 832 | __u8 *data; |
837 | __u8 iir; | 833 | __u8 iir; |
838 | 834 | ||
@@ -845,12 +841,10 @@ static void mos7715_interrupt_callback(struct urb *urb) | |||
845 | case -ESHUTDOWN: | 841 | case -ESHUTDOWN: |
846 | case -ENODEV: | 842 | case -ENODEV: |
847 | /* this urb is terminated, clean up */ | 843 | /* this urb is terminated, clean up */ |
848 | dbg("%s - urb shutting down with status: %d", __func__, | 844 | dev_dbg(dev, "%s - urb shutting down with status: %d\n", __func__, status); |
849 | status); | ||
850 | return; | 845 | return; |
851 | default: | 846 | default: |
852 | dbg("%s - nonzero urb status received: %d", __func__, | 847 | dev_dbg(dev, "%s - nonzero urb status received: %d\n", __func__, status); |
853 | status); | ||
854 | goto exit; | 848 | goto exit; |
855 | } | 849 | } |
856 | 850 | ||
@@ -864,7 +858,7 @@ static void mos7715_interrupt_callback(struct urb *urb) | |||
864 | * Byte 4: FIFO status for both */ | 858 | * Byte 4: FIFO status for both */ |
865 | 859 | ||
866 | if (unlikely(length != 4)) { | 860 | if (unlikely(length != 4)) { |
867 | dbg("Wrong data !!!"); | 861 | dev_dbg(dev, "Wrong data !!!\n"); |
868 | return; | 862 | return; |
869 | } | 863 | } |
870 | 864 | ||
@@ -872,14 +866,13 @@ static void mos7715_interrupt_callback(struct urb *urb) | |||
872 | if (!(iir & 0x01)) { /* serial port interrupt pending */ | 866 | if (!(iir & 0x01)) { /* serial port interrupt pending */ |
873 | switch (iir & 0x0f) { | 867 | switch (iir & 0x0f) { |
874 | case SERIAL_IIR_RLS: | 868 | case SERIAL_IIR_RLS: |
875 | dbg("Serial Port: Receiver status error or address " | 869 | dev_dbg(dev, "Serial Port: Receiver status error or address bit detected in 9-bit mode\n\n"); |
876 | "bit detected in 9-bit mode\n"); | ||
877 | break; | 870 | break; |
878 | case SERIAL_IIR_CTI: | 871 | case SERIAL_IIR_CTI: |
879 | dbg("Serial Port: Receiver time out"); | 872 | dev_dbg(dev, "Serial Port: Receiver time out\n"); |
880 | break; | 873 | break; |
881 | case SERIAL_IIR_MS: | 874 | case SERIAL_IIR_MS: |
882 | /* dbg("Serial Port: Modem status change"); */ | 875 | /* dev_dbg(dev, "Serial Port: Modem status change\n"); */ |
883 | break; | 876 | break; |
884 | } | 877 | } |
885 | } | 878 | } |
@@ -897,9 +890,7 @@ static void mos7715_interrupt_callback(struct urb *urb) | |||
897 | exit: | 890 | exit: |
898 | result = usb_submit_urb(urb, GFP_ATOMIC); | 891 | result = usb_submit_urb(urb, GFP_ATOMIC); |
899 | if (result) | 892 | if (result) |
900 | dev_err(&urb->dev->dev, | 893 | dev_err(dev, "%s - Error %d submitting control urb\n", __func__, result); |
901 | "%s - Error %d submitting control urb\n", | ||
902 | __func__, result); | ||
903 | } | 894 | } |
904 | 895 | ||
905 | /* | 896 | /* |
@@ -916,13 +907,13 @@ static void mos7720_bulk_in_callback(struct urb *urb) | |||
916 | int status = urb->status; | 907 | int status = urb->status; |
917 | 908 | ||
918 | if (status) { | 909 | if (status) { |
919 | dbg("nonzero read bulk status received: %d", status); | 910 | dev_dbg(&urb->dev->dev, "nonzero read bulk status received: %d\n", status); |
920 | return; | 911 | return; |
921 | } | 912 | } |
922 | 913 | ||
923 | port = urb->context; | 914 | port = urb->context; |
924 | 915 | ||
925 | dbg("Entering...%s", __func__); | 916 | dev_dbg(&port->dev, "Entering...%s\n", __func__); |
926 | 917 | ||
927 | data = urb->transfer_buffer; | 918 | data = urb->transfer_buffer; |
928 | 919 | ||
@@ -936,8 +927,7 @@ static void mos7720_bulk_in_callback(struct urb *urb) | |||
936 | if (port->read_urb->status != -EINPROGRESS) { | 927 | if (port->read_urb->status != -EINPROGRESS) { |
937 | retval = usb_submit_urb(port->read_urb, GFP_ATOMIC); | 928 | retval = usb_submit_urb(port->read_urb, GFP_ATOMIC); |
938 | if (retval) | 929 | if (retval) |
939 | dbg("usb_submit_urb(read bulk) failed, retval = %d", | 930 | dev_dbg(&port->dev, "usb_submit_urb(read bulk) failed, retval = %d\n", retval); |
940 | retval); | ||
941 | } | 931 | } |
942 | } | 932 | } |
943 | 933 | ||
@@ -953,13 +943,13 @@ static void mos7720_bulk_out_data_callback(struct urb *urb) | |||
953 | int status = urb->status; | 943 | int status = urb->status; |
954 | 944 | ||
955 | if (status) { | 945 | if (status) { |
956 | dbg("nonzero write bulk status received:%d", status); | 946 | dev_dbg(&urb->dev->dev, "nonzero write bulk status received:%d\n", status); |
957 | return; | 947 | return; |
958 | } | 948 | } |
959 | 949 | ||
960 | mos7720_port = urb->context; | 950 | mos7720_port = urb->context; |
961 | if (!mos7720_port) { | 951 | if (!mos7720_port) { |
962 | dbg("NULL mos7720_port pointer"); | 952 | dev_dbg(&urb->dev->dev, "NULL mos7720_port pointer\n"); |
963 | return ; | 953 | return ; |
964 | } | 954 | } |
965 | 955 | ||
@@ -1061,9 +1051,7 @@ static int mos7720_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
1061 | port_number = port->number - port->serial->minor; | 1051 | port_number = port->number - port->serial->minor; |
1062 | read_mos_reg(serial, port_number, LSR, &data); | 1052 | read_mos_reg(serial, port_number, LSR, &data); |
1063 | 1053 | ||
1064 | dbg("SS::%p LSR:%x", mos7720_port, data); | 1054 | dev_dbg(&port->dev, "SS::%p LSR:%x\n", mos7720_port, data); |
1065 | |||
1066 | dbg("Check:Sending Command .........."); | ||
1067 | 1055 | ||
1068 | write_mos_reg(serial, dummy, SP1_REG, 0x02); | 1056 | write_mos_reg(serial, dummy, SP1_REG, 0x02); |
1069 | write_mos_reg(serial, dummy, SP2_REG, 0x02); | 1057 | write_mos_reg(serial, dummy, SP2_REG, 0x02); |
@@ -1122,20 +1110,16 @@ static int mos7720_chars_in_buffer(struct tty_struct *tty) | |||
1122 | int chars = 0; | 1110 | int chars = 0; |
1123 | struct moschip_port *mos7720_port; | 1111 | struct moschip_port *mos7720_port; |
1124 | 1112 | ||
1125 | dbg("%s:entering ...........", __func__); | ||
1126 | |||
1127 | mos7720_port = usb_get_serial_port_data(port); | 1113 | mos7720_port = usb_get_serial_port_data(port); |
1128 | if (mos7720_port == NULL) { | 1114 | if (mos7720_port == NULL) |
1129 | dbg("%s:leaving ...........", __func__); | ||
1130 | return 0; | 1115 | return 0; |
1131 | } | ||
1132 | 1116 | ||
1133 | for (i = 0; i < NUM_URBS; ++i) { | 1117 | for (i = 0; i < NUM_URBS; ++i) { |
1134 | if (mos7720_port->write_urb_pool[i] && | 1118 | if (mos7720_port->write_urb_pool[i] && |
1135 | mos7720_port->write_urb_pool[i]->status == -EINPROGRESS) | 1119 | mos7720_port->write_urb_pool[i]->status == -EINPROGRESS) |
1136 | chars += URB_TRANSFER_BUFFER_SIZE; | 1120 | chars += URB_TRANSFER_BUFFER_SIZE; |
1137 | } | 1121 | } |
1138 | dbg("%s - returns %d", __func__, chars); | 1122 | dev_dbg(&port->dev, "%s - returns %d\n", __func__, chars); |
1139 | return chars; | 1123 | return chars; |
1140 | } | 1124 | } |
1141 | 1125 | ||
@@ -1145,8 +1129,6 @@ static void mos7720_close(struct usb_serial_port *port) | |||
1145 | struct moschip_port *mos7720_port; | 1129 | struct moschip_port *mos7720_port; |
1146 | int j; | 1130 | int j; |
1147 | 1131 | ||
1148 | dbg("mos7720_close:entering..."); | ||
1149 | |||
1150 | serial = port->serial; | 1132 | serial = port->serial; |
1151 | 1133 | ||
1152 | mos7720_port = usb_get_serial_port_data(port); | 1134 | mos7720_port = usb_get_serial_port_data(port); |
@@ -1166,9 +1148,7 @@ static void mos7720_close(struct usb_serial_port *port) | |||
1166 | 1148 | ||
1167 | /* While closing port, shutdown all bulk read, write * | 1149 | /* While closing port, shutdown all bulk read, write * |
1168 | * and interrupt read if they exists, otherwise nop */ | 1150 | * and interrupt read if they exists, otherwise nop */ |
1169 | dbg("Shutdown bulk write"); | ||
1170 | usb_kill_urb(port->write_urb); | 1151 | usb_kill_urb(port->write_urb); |
1171 | dbg("Shutdown bulk read"); | ||
1172 | usb_kill_urb(port->read_urb); | 1152 | usb_kill_urb(port->read_urb); |
1173 | 1153 | ||
1174 | mutex_lock(&serial->disc_mutex); | 1154 | mutex_lock(&serial->disc_mutex); |
@@ -1182,8 +1162,6 @@ static void mos7720_close(struct usb_serial_port *port) | |||
1182 | } | 1162 | } |
1183 | mutex_unlock(&serial->disc_mutex); | 1163 | mutex_unlock(&serial->disc_mutex); |
1184 | mos7720_port->open = 0; | 1164 | mos7720_port->open = 0; |
1185 | |||
1186 | dbg("Leaving %s", __func__); | ||
1187 | } | 1165 | } |
1188 | 1166 | ||
1189 | static void mos7720_break(struct tty_struct *tty, int break_state) | 1167 | static void mos7720_break(struct tty_struct *tty, int break_state) |
@@ -1193,8 +1171,6 @@ static void mos7720_break(struct tty_struct *tty, int break_state) | |||
1193 | struct usb_serial *serial; | 1171 | struct usb_serial *serial; |
1194 | struct moschip_port *mos7720_port; | 1172 | struct moschip_port *mos7720_port; |
1195 | 1173 | ||
1196 | dbg("Entering %s", __func__); | ||
1197 | |||
1198 | serial = port->serial; | 1174 | serial = port->serial; |
1199 | 1175 | ||
1200 | mos7720_port = usb_get_serial_port_data(port); | 1176 | mos7720_port = usb_get_serial_port_data(port); |
@@ -1225,13 +1201,9 @@ static int mos7720_write_room(struct tty_struct *tty) | |||
1225 | int room = 0; | 1201 | int room = 0; |
1226 | int i; | 1202 | int i; |
1227 | 1203 | ||
1228 | dbg("%s:entering ...........", __func__); | ||
1229 | |||
1230 | mos7720_port = usb_get_serial_port_data(port); | 1204 | mos7720_port = usb_get_serial_port_data(port); |
1231 | if (mos7720_port == NULL) { | 1205 | if (mos7720_port == NULL) |
1232 | dbg("%s:leaving ...........", __func__); | ||
1233 | return -ENODEV; | 1206 | return -ENODEV; |
1234 | } | ||
1235 | 1207 | ||
1236 | /* FIXME: Locking */ | 1208 | /* FIXME: Locking */ |
1237 | for (i = 0; i < NUM_URBS; ++i) { | 1209 | for (i = 0; i < NUM_URBS; ++i) { |
@@ -1240,7 +1212,7 @@ static int mos7720_write_room(struct tty_struct *tty) | |||
1240 | room += URB_TRANSFER_BUFFER_SIZE; | 1212 | room += URB_TRANSFER_BUFFER_SIZE; |
1241 | } | 1213 | } |
1242 | 1214 | ||
1243 | dbg("%s - returns %d", __func__, room); | 1215 | dev_dbg(&port->dev, "%s - returns %d\n", __func__, room); |
1244 | return room; | 1216 | return room; |
1245 | } | 1217 | } |
1246 | 1218 | ||
@@ -1257,15 +1229,11 @@ static int mos7720_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
1257 | struct urb *urb; | 1229 | struct urb *urb; |
1258 | const unsigned char *current_position = data; | 1230 | const unsigned char *current_position = data; |
1259 | 1231 | ||
1260 | dbg("%s:entering ...........", __func__); | ||
1261 | |||
1262 | serial = port->serial; | 1232 | serial = port->serial; |
1263 | 1233 | ||
1264 | mos7720_port = usb_get_serial_port_data(port); | 1234 | mos7720_port = usb_get_serial_port_data(port); |
1265 | if (mos7720_port == NULL) { | 1235 | if (mos7720_port == NULL) |
1266 | dbg("mos7720_port is NULL"); | ||
1267 | return -ENODEV; | 1236 | return -ENODEV; |
1268 | } | ||
1269 | 1237 | ||
1270 | /* try to find a free urb in the list */ | 1238 | /* try to find a free urb in the list */ |
1271 | urb = NULL; | 1239 | urb = NULL; |
@@ -1274,13 +1242,13 @@ static int mos7720_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
1274 | if (mos7720_port->write_urb_pool[i] && | 1242 | if (mos7720_port->write_urb_pool[i] && |
1275 | mos7720_port->write_urb_pool[i]->status != -EINPROGRESS) { | 1243 | mos7720_port->write_urb_pool[i]->status != -EINPROGRESS) { |
1276 | urb = mos7720_port->write_urb_pool[i]; | 1244 | urb = mos7720_port->write_urb_pool[i]; |
1277 | dbg("URB:%d", i); | 1245 | dev_dbg(&port->dev, "URB:%d\n", i); |
1278 | break; | 1246 | break; |
1279 | } | 1247 | } |
1280 | } | 1248 | } |
1281 | 1249 | ||
1282 | if (urb == NULL) { | 1250 | if (urb == NULL) { |
1283 | dbg("%s - no more free urbs", __func__); | 1251 | dev_dbg(&port->dev, "%s - no more free urbs\n", __func__); |
1284 | goto exit; | 1252 | goto exit; |
1285 | } | 1253 | } |
1286 | 1254 | ||
@@ -1296,7 +1264,7 @@ static int mos7720_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
1296 | transfer_size = min(count, URB_TRANSFER_BUFFER_SIZE); | 1264 | transfer_size = min(count, URB_TRANSFER_BUFFER_SIZE); |
1297 | 1265 | ||
1298 | memcpy(urb->transfer_buffer, current_position, transfer_size); | 1266 | memcpy(urb->transfer_buffer, current_position, transfer_size); |
1299 | usb_serial_debug_data(debug, &port->dev, __func__, transfer_size, | 1267 | usb_serial_debug_data(&port->dev, __func__, transfer_size, |
1300 | urb->transfer_buffer); | 1268 | urb->transfer_buffer); |
1301 | 1269 | ||
1302 | /* fill urb with data and submit */ | 1270 | /* fill urb with data and submit */ |
@@ -1326,20 +1294,16 @@ static void mos7720_throttle(struct tty_struct *tty) | |||
1326 | struct moschip_port *mos7720_port; | 1294 | struct moschip_port *mos7720_port; |
1327 | int status; | 1295 | int status; |
1328 | 1296 | ||
1329 | dbg("%s- port %d", __func__, port->number); | ||
1330 | |||
1331 | mos7720_port = usb_get_serial_port_data(port); | 1297 | mos7720_port = usb_get_serial_port_data(port); |
1332 | 1298 | ||
1333 | if (mos7720_port == NULL) | 1299 | if (mos7720_port == NULL) |
1334 | return; | 1300 | return; |
1335 | 1301 | ||
1336 | if (!mos7720_port->open) { | 1302 | if (!mos7720_port->open) { |
1337 | dbg("port not opened"); | 1303 | dev_dbg(&port->dev, "%s - port not opened\n", __func__); |
1338 | return; | 1304 | return; |
1339 | } | 1305 | } |
1340 | 1306 | ||
1341 | dbg("%s: Entering ..........", __func__); | ||
1342 | |||
1343 | /* if we are implementing XON/XOFF, send the stop character */ | 1307 | /* if we are implementing XON/XOFF, send the stop character */ |
1344 | if (I_IXOFF(tty)) { | 1308 | if (I_IXOFF(tty)) { |
1345 | unsigned char stop_char = STOP_CHAR(tty); | 1309 | unsigned char stop_char = STOP_CHAR(tty); |
@@ -1368,12 +1332,10 @@ static void mos7720_unthrottle(struct tty_struct *tty) | |||
1368 | return; | 1332 | return; |
1369 | 1333 | ||
1370 | if (!mos7720_port->open) { | 1334 | if (!mos7720_port->open) { |
1371 | dbg("%s - port not opened", __func__); | 1335 | dev_dbg(&port->dev, "%s - port not opened\n", __func__); |
1372 | return; | 1336 | return; |
1373 | } | 1337 | } |
1374 | 1338 | ||
1375 | dbg("%s: Entering ..........", __func__); | ||
1376 | |||
1377 | /* if we are implementing XON/XOFF, send the start character */ | 1339 | /* if we are implementing XON/XOFF, send the start character */ |
1378 | if (I_IXOFF(tty)) { | 1340 | if (I_IXOFF(tty)) { |
1379 | unsigned char start_char = START_CHAR(tty); | 1341 | unsigned char start_char = START_CHAR(tty); |
@@ -1409,7 +1371,7 @@ static int set_higher_rates(struct moschip_port *mos7720_port, | |||
1409 | /*********************************************** | 1371 | /*********************************************** |
1410 | * Init Sequence for higher rates | 1372 | * Init Sequence for higher rates |
1411 | ***********************************************/ | 1373 | ***********************************************/ |
1412 | dbg("Sending Setting Commands .........."); | 1374 | dev_dbg(&port->dev, "Sending Setting Commands ..........\n"); |
1413 | port_number = port->number - port->serial->minor; | 1375 | port_number = port->number - port->serial->minor; |
1414 | 1376 | ||
1415 | write_mos_reg(serial, port_number, IER, 0x00); | 1377 | write_mos_reg(serial, port_number, IER, 0x00); |
@@ -1478,7 +1440,7 @@ static struct divisor_table_entry divisor_table[] = { | |||
1478 | * this function calculates the proper baud rate divisor for the specified | 1440 | * this function calculates the proper baud rate divisor for the specified |
1479 | * baud rate. | 1441 | * baud rate. |
1480 | *****************************************************************************/ | 1442 | *****************************************************************************/ |
1481 | static int calc_baud_rate_divisor(int baudrate, int *divisor) | 1443 | static int calc_baud_rate_divisor(struct usb_serial_port *port, int baudrate, int *divisor) |
1482 | { | 1444 | { |
1483 | int i; | 1445 | int i; |
1484 | __u16 custom; | 1446 | __u16 custom; |
@@ -1486,7 +1448,7 @@ static int calc_baud_rate_divisor(int baudrate, int *divisor) | |||
1486 | __u16 round; | 1448 | __u16 round; |
1487 | 1449 | ||
1488 | 1450 | ||
1489 | dbg("%s - %d", __func__, baudrate); | 1451 | dev_dbg(&port->dev, "%s - %d\n", __func__, baudrate); |
1490 | 1452 | ||
1491 | for (i = 0; i < ARRAY_SIZE(divisor_table); i++) { | 1453 | for (i = 0; i < ARRAY_SIZE(divisor_table); i++) { |
1492 | if (divisor_table[i].baudrate == baudrate) { | 1454 | if (divisor_table[i].baudrate == baudrate) { |
@@ -1508,11 +1470,11 @@ static int calc_baud_rate_divisor(int baudrate, int *divisor) | |||
1508 | custom++; | 1470 | custom++; |
1509 | *divisor = custom; | 1471 | *divisor = custom; |
1510 | 1472 | ||
1511 | dbg("Baud %d = %d", baudrate, custom); | 1473 | dev_dbg(&port->dev, "Baud %d = %d\n", baudrate, custom); |
1512 | return 0; | 1474 | return 0; |
1513 | } | 1475 | } |
1514 | 1476 | ||
1515 | dbg("Baud calculation Failed..."); | 1477 | dev_dbg(&port->dev, "Baud calculation Failed...\n"); |
1516 | return -EINVAL; | 1478 | return -EINVAL; |
1517 | } | 1479 | } |
1518 | 1480 | ||
@@ -1536,13 +1498,11 @@ static int send_cmd_write_baud_rate(struct moschip_port *mos7720_port, | |||
1536 | port = mos7720_port->port; | 1498 | port = mos7720_port->port; |
1537 | serial = port->serial; | 1499 | serial = port->serial; |
1538 | 1500 | ||
1539 | dbg("%s: Entering ..........", __func__); | ||
1540 | |||
1541 | number = port->number - port->serial->minor; | 1501 | number = port->number - port->serial->minor; |
1542 | dbg("%s - port = %d, baud = %d", __func__, port->number, baudrate); | 1502 | dev_dbg(&port->dev, "%s - baud = %d\n", __func__, baudrate); |
1543 | 1503 | ||
1544 | /* Calculate the Divisor */ | 1504 | /* Calculate the Divisor */ |
1545 | status = calc_baud_rate_divisor(baudrate, &divisor); | 1505 | status = calc_baud_rate_divisor(port, baudrate, &divisor); |
1546 | if (status) { | 1506 | if (status) { |
1547 | dev_err(&port->dev, "%s - bad baud rate\n", __func__); | 1507 | dev_err(&port->dev, "%s - bad baud rate\n", __func__); |
1548 | return status; | 1508 | return status; |
@@ -1591,15 +1551,11 @@ static void change_port_settings(struct tty_struct *tty, | |||
1591 | serial = port->serial; | 1551 | serial = port->serial; |
1592 | port_number = port->number - port->serial->minor; | 1552 | port_number = port->number - port->serial->minor; |
1593 | 1553 | ||
1594 | dbg("%s - port %d", __func__, port->number); | ||
1595 | |||
1596 | if (!mos7720_port->open) { | 1554 | if (!mos7720_port->open) { |
1597 | dbg("%s - port not opened", __func__); | 1555 | dev_dbg(&port->dev, "%s - port not opened\n", __func__); |
1598 | return; | 1556 | return; |
1599 | } | 1557 | } |
1600 | 1558 | ||
1601 | dbg("%s: Entering ..........", __func__); | ||
1602 | |||
1603 | lData = UART_LCR_WLEN8; | 1559 | lData = UART_LCR_WLEN8; |
1604 | lStop = 0x00; /* 1 stop bit */ | 1560 | lStop = 0x00; /* 1 stop bit */ |
1605 | lParity = 0x00; /* No parity */ | 1561 | lParity = 0x00; /* No parity */ |
@@ -1633,14 +1589,14 @@ static void change_port_settings(struct tty_struct *tty, | |||
1633 | if (cflag & PARENB) { | 1589 | if (cflag & PARENB) { |
1634 | if (cflag & PARODD) { | 1590 | if (cflag & PARODD) { |
1635 | lParity = UART_LCR_PARITY; | 1591 | lParity = UART_LCR_PARITY; |
1636 | dbg("%s - parity = odd", __func__); | 1592 | dev_dbg(&port->dev, "%s - parity = odd\n", __func__); |
1637 | } else { | 1593 | } else { |
1638 | lParity = (UART_LCR_EPAR | UART_LCR_PARITY); | 1594 | lParity = (UART_LCR_EPAR | UART_LCR_PARITY); |
1639 | dbg("%s - parity = even", __func__); | 1595 | dev_dbg(&port->dev, "%s - parity = even\n", __func__); |
1640 | } | 1596 | } |
1641 | 1597 | ||
1642 | } else { | 1598 | } else { |
1643 | dbg("%s - parity = none", __func__); | 1599 | dev_dbg(&port->dev, "%s - parity = none\n", __func__); |
1644 | } | 1600 | } |
1645 | 1601 | ||
1646 | if (cflag & CMSPAR) | 1602 | if (cflag & CMSPAR) |
@@ -1649,10 +1605,10 @@ static void change_port_settings(struct tty_struct *tty, | |||
1649 | /* Change the Stop bit */ | 1605 | /* Change the Stop bit */ |
1650 | if (cflag & CSTOPB) { | 1606 | if (cflag & CSTOPB) { |
1651 | lStop = UART_LCR_STOP; | 1607 | lStop = UART_LCR_STOP; |
1652 | dbg("%s - stop bits = 2", __func__); | 1608 | dev_dbg(&port->dev, "%s - stop bits = 2\n", __func__); |
1653 | } else { | 1609 | } else { |
1654 | lStop = 0x00; | 1610 | lStop = 0x00; |
1655 | dbg("%s - stop bits = 1", __func__); | 1611 | dev_dbg(&port->dev, "%s - stop bits = 1\n", __func__); |
1656 | } | 1612 | } |
1657 | 1613 | ||
1658 | #define LCR_BITS_MASK 0x03 /* Mask for bits/char field */ | 1614 | #define LCR_BITS_MASK 0x03 /* Mask for bits/char field */ |
@@ -1698,7 +1654,7 @@ static void change_port_settings(struct tty_struct *tty, | |||
1698 | baud = tty_get_baud_rate(tty); | 1654 | baud = tty_get_baud_rate(tty); |
1699 | if (!baud) { | 1655 | if (!baud) { |
1700 | /* pick a default, any default... */ | 1656 | /* pick a default, any default... */ |
1701 | dbg("Picked default baud..."); | 1657 | dev_dbg(&port->dev, "Picked default baud...\n"); |
1702 | baud = 9600; | 1658 | baud = 9600; |
1703 | } | 1659 | } |
1704 | 1660 | ||
@@ -1709,7 +1665,7 @@ static void change_port_settings(struct tty_struct *tty, | |||
1709 | return; | 1665 | return; |
1710 | } | 1666 | } |
1711 | 1667 | ||
1712 | dbg("%s - baud rate = %d", __func__, baud); | 1668 | dev_dbg(&port->dev, "%s - baud rate = %d\n", __func__, baud); |
1713 | status = send_cmd_write_baud_rate(mos7720_port, baud); | 1669 | status = send_cmd_write_baud_rate(mos7720_port, baud); |
1714 | /* FIXME: needs to write actual resulting baud back not just | 1670 | /* FIXME: needs to write actual resulting baud back not just |
1715 | blindly do so */ | 1671 | blindly do so */ |
@@ -1721,8 +1677,7 @@ static void change_port_settings(struct tty_struct *tty, | |||
1721 | if (port->read_urb->status != -EINPROGRESS) { | 1677 | if (port->read_urb->status != -EINPROGRESS) { |
1722 | status = usb_submit_urb(port->read_urb, GFP_ATOMIC); | 1678 | status = usb_submit_urb(port->read_urb, GFP_ATOMIC); |
1723 | if (status) | 1679 | if (status) |
1724 | dbg("usb_submit_urb(read bulk) failed, status = %d", | 1680 | dev_dbg(&port->dev, "usb_submit_urb(read bulk) failed, status = %d\n", status); |
1725 | status); | ||
1726 | } | 1681 | } |
1727 | } | 1682 | } |
1728 | 1683 | ||
@@ -1747,23 +1702,19 @@ static void mos7720_set_termios(struct tty_struct *tty, | |||
1747 | return; | 1702 | return; |
1748 | 1703 | ||
1749 | if (!mos7720_port->open) { | 1704 | if (!mos7720_port->open) { |
1750 | dbg("%s - port not opened", __func__); | 1705 | dev_dbg(&port->dev, "%s - port not opened\n", __func__); |
1751 | return; | 1706 | return; |
1752 | } | 1707 | } |
1753 | 1708 | ||
1754 | dbg("%s\n", "setting termios - ASPIRE"); | 1709 | dev_dbg(&port->dev, "setting termios - ASPIRE\n"); |
1755 | 1710 | ||
1756 | cflag = tty->termios.c_cflag; | 1711 | cflag = tty->termios.c_cflag; |
1757 | 1712 | ||
1758 | dbg("%s - cflag %08x iflag %08x", __func__, | 1713 | dev_dbg(&port->dev, "%s - cflag %08x iflag %08x\n", __func__, |
1759 | tty->termios.c_cflag, | 1714 | tty->termios.c_cflag, RELEVANT_IFLAG(tty->termios.c_iflag)); |
1760 | RELEVANT_IFLAG(tty->termios.c_iflag)); | ||
1761 | 1715 | ||
1762 | dbg("%s - old cflag %08x old iflag %08x", __func__, | 1716 | dev_dbg(&port->dev, "%s - old cflag %08x old iflag %08x\n", __func__, |
1763 | old_termios->c_cflag, | 1717 | old_termios->c_cflag, RELEVANT_IFLAG(old_termios->c_iflag)); |
1764 | RELEVANT_IFLAG(old_termios->c_iflag)); | ||
1765 | |||
1766 | dbg("%s - port %d", __func__, port->number); | ||
1767 | 1718 | ||
1768 | /* change the port settings to the new ones specified */ | 1719 | /* change the port settings to the new ones specified */ |
1769 | change_port_settings(tty, mos7720_port, old_termios); | 1720 | change_port_settings(tty, mos7720_port, old_termios); |
@@ -1771,8 +1722,7 @@ static void mos7720_set_termios(struct tty_struct *tty, | |||
1771 | if (port->read_urb->status != -EINPROGRESS) { | 1722 | if (port->read_urb->status != -EINPROGRESS) { |
1772 | status = usb_submit_urb(port->read_urb, GFP_ATOMIC); | 1723 | status = usb_submit_urb(port->read_urb, GFP_ATOMIC); |
1773 | if (status) | 1724 | if (status) |
1774 | dbg("usb_submit_urb(read bulk) failed, status = %d", | 1725 | dev_dbg(&port->dev, "usb_submit_urb(read bulk) failed, status = %d\n", status); |
1775 | status); | ||
1776 | } | 1726 | } |
1777 | } | 1727 | } |
1778 | 1728 | ||
@@ -1800,7 +1750,7 @@ static int get_lsr_info(struct tty_struct *tty, | |||
1800 | read_mos_reg(port->serial, port_number, LSR, &data); | 1750 | read_mos_reg(port->serial, port_number, LSR, &data); |
1801 | if ((data & (UART_LSR_TEMT | UART_LSR_THRE)) | 1751 | if ((data & (UART_LSR_TEMT | UART_LSR_THRE)) |
1802 | == (UART_LSR_TEMT | UART_LSR_THRE)) { | 1752 | == (UART_LSR_TEMT | UART_LSR_THRE)) { |
1803 | dbg("%s -- Empty", __func__); | 1753 | dev_dbg(&port->dev, "%s -- Empty\n", __func__); |
1804 | result = TIOCSER_TEMT; | 1754 | result = TIOCSER_TEMT; |
1805 | } | 1755 | } |
1806 | } | 1756 | } |
@@ -1817,8 +1767,6 @@ static int mos7720_tiocmget(struct tty_struct *tty) | |||
1817 | unsigned int mcr ; | 1767 | unsigned int mcr ; |
1818 | unsigned int msr ; | 1768 | unsigned int msr ; |
1819 | 1769 | ||
1820 | dbg("%s - port %d", __func__, port->number); | ||
1821 | |||
1822 | mcr = mos7720_port->shadowMCR; | 1770 | mcr = mos7720_port->shadowMCR; |
1823 | msr = mos7720_port->shadowMSR; | 1771 | msr = mos7720_port->shadowMSR; |
1824 | 1772 | ||
@@ -1829,8 +1777,6 @@ static int mos7720_tiocmget(struct tty_struct *tty) | |||
1829 | | ((msr & UART_MSR_RI) ? TIOCM_RI : 0) /* 0x080 */ | 1777 | | ((msr & UART_MSR_RI) ? TIOCM_RI : 0) /* 0x080 */ |
1830 | | ((msr & UART_MSR_DSR) ? TIOCM_DSR : 0); /* 0x100 */ | 1778 | | ((msr & UART_MSR_DSR) ? TIOCM_DSR : 0); /* 0x100 */ |
1831 | 1779 | ||
1832 | dbg("%s -- %x", __func__, result); | ||
1833 | |||
1834 | return result; | 1780 | return result; |
1835 | } | 1781 | } |
1836 | 1782 | ||
@@ -1840,8 +1786,6 @@ static int mos7720_tiocmset(struct tty_struct *tty, | |||
1840 | struct usb_serial_port *port = tty->driver_data; | 1786 | struct usb_serial_port *port = tty->driver_data; |
1841 | struct moschip_port *mos7720_port = usb_get_serial_port_data(port); | 1787 | struct moschip_port *mos7720_port = usb_get_serial_port_data(port); |
1842 | unsigned int mcr ; | 1788 | unsigned int mcr ; |
1843 | dbg("%s - port %d", __func__, port->number); | ||
1844 | dbg("he was at tiocmset"); | ||
1845 | 1789 | ||
1846 | mcr = mos7720_port->shadowMCR; | 1790 | mcr = mos7720_port->shadowMCR; |
1847 | 1791 | ||
@@ -1888,8 +1832,8 @@ static int mos7720_get_icount(struct tty_struct *tty, | |||
1888 | icount->brk = cnow.brk; | 1832 | icount->brk = cnow.brk; |
1889 | icount->buf_overrun = cnow.buf_overrun; | 1833 | icount->buf_overrun = cnow.buf_overrun; |
1890 | 1834 | ||
1891 | dbg("%s (%d) TIOCGICOUNT RX=%d, TX=%d", __func__, | 1835 | dev_dbg(&port->dev, "%s TIOCGICOUNT RX=%d, TX=%d\n", __func__, |
1892 | port->number, icount->rx, icount->tx); | 1836 | icount->rx, icount->tx); |
1893 | return 0; | 1837 | return 0; |
1894 | } | 1838 | } |
1895 | 1839 | ||
@@ -1975,29 +1919,28 @@ static int mos7720_ioctl(struct tty_struct *tty, | |||
1975 | if (mos7720_port == NULL) | 1919 | if (mos7720_port == NULL) |
1976 | return -ENODEV; | 1920 | return -ENODEV; |
1977 | 1921 | ||
1978 | dbg("%s - port %d, cmd = 0x%x", __func__, port->number, cmd); | 1922 | dev_dbg(&port->dev, "%s - cmd = 0x%x", __func__, cmd); |
1979 | 1923 | ||
1980 | switch (cmd) { | 1924 | switch (cmd) { |
1981 | case TIOCSERGETLSR: | 1925 | case TIOCSERGETLSR: |
1982 | dbg("%s (%d) TIOCSERGETLSR", __func__, port->number); | 1926 | dev_dbg(&port->dev, "%s TIOCSERGETLSR\n", __func__); |
1983 | return get_lsr_info(tty, mos7720_port, | 1927 | return get_lsr_info(tty, mos7720_port, |
1984 | (unsigned int __user *)arg); | 1928 | (unsigned int __user *)arg); |
1985 | 1929 | ||
1986 | /* FIXME: These should be using the mode methods */ | 1930 | /* FIXME: These should be using the mode methods */ |
1987 | case TIOCMBIS: | 1931 | case TIOCMBIS: |
1988 | case TIOCMBIC: | 1932 | case TIOCMBIC: |
1989 | dbg("%s (%d) TIOCMSET/TIOCMBIC/TIOCMSET", | 1933 | dev_dbg(&port->dev, "%s TIOCMSET/TIOCMBIC/TIOCMSET\n", __func__); |
1990 | __func__, port->number); | ||
1991 | return set_modem_info(mos7720_port, cmd, | 1934 | return set_modem_info(mos7720_port, cmd, |
1992 | (unsigned int __user *)arg); | 1935 | (unsigned int __user *)arg); |
1993 | 1936 | ||
1994 | case TIOCGSERIAL: | 1937 | case TIOCGSERIAL: |
1995 | dbg("%s (%d) TIOCGSERIAL", __func__, port->number); | 1938 | dev_dbg(&port->dev, "%s TIOCGSERIAL\n", __func__); |
1996 | return get_serial_info(mos7720_port, | 1939 | return get_serial_info(mos7720_port, |
1997 | (struct serial_struct __user *)arg); | 1940 | (struct serial_struct __user *)arg); |
1998 | 1941 | ||
1999 | case TIOCMIWAIT: | 1942 | case TIOCMIWAIT: |
2000 | dbg("%s (%d) TIOCMIWAIT", __func__, port->number); | 1943 | dev_dbg(&port->dev, "%s TIOCMIWAIT\n", __func__); |
2001 | cprev = mos7720_port->icount; | 1944 | cprev = mos7720_port->icount; |
2002 | while (1) { | 1945 | while (1) { |
2003 | if (signal_pending(current)) | 1946 | if (signal_pending(current)) |
@@ -2030,13 +1973,6 @@ static int mos7720_startup(struct usb_serial *serial) | |||
2030 | u16 product; | 1973 | u16 product; |
2031 | int ret_val; | 1974 | int ret_val; |
2032 | 1975 | ||
2033 | dbg("%s: Entering ..........", __func__); | ||
2034 | |||
2035 | if (!serial) { | ||
2036 | dbg("Invalid Handler"); | ||
2037 | return -ENODEV; | ||
2038 | } | ||
2039 | |||
2040 | product = le16_to_cpu(serial->dev->descriptor.idProduct); | 1976 | product = le16_to_cpu(serial->dev->descriptor.idProduct); |
2041 | dev = serial->dev; | 1977 | dev = serial->dev; |
2042 | 1978 | ||
@@ -2081,8 +2017,8 @@ static int mos7720_startup(struct usb_serial *serial) | |||
2081 | mos7720_port->port = serial->port[i]; | 2017 | mos7720_port->port = serial->port[i]; |
2082 | usb_set_serial_port_data(serial->port[i], mos7720_port); | 2018 | usb_set_serial_port_data(serial->port[i], mos7720_port); |
2083 | 2019 | ||
2084 | dbg("port number is %d", serial->port[i]->number); | 2020 | dev_dbg(&dev->dev, "port number is %d\n", serial->port[i]->number); |
2085 | dbg("serial number is %d", serial->minor); | 2021 | dev_dbg(&dev->dev, "serial number is %d\n", serial->minor); |
2086 | } | 2022 | } |
2087 | 2023 | ||
2088 | 2024 | ||
@@ -2106,7 +2042,7 @@ static int mos7720_startup(struct usb_serial *serial) | |||
2106 | #endif | 2042 | #endif |
2107 | /* LSR For Port 1 */ | 2043 | /* LSR For Port 1 */ |
2108 | read_mos_reg(serial, 0, LSR, &data); | 2044 | read_mos_reg(serial, 0, LSR, &data); |
2109 | dbg("LSR:%x", data); | 2045 | dev_dbg(&dev->dev, "LSR:%x\n", data); |
2110 | 2046 | ||
2111 | return 0; | 2047 | return 0; |
2112 | } | 2048 | } |
@@ -2195,6 +2131,3 @@ module_usb_serial_driver(serial_drivers, id_table); | |||
2195 | MODULE_AUTHOR(DRIVER_AUTHOR); | 2131 | MODULE_AUTHOR(DRIVER_AUTHOR); |
2196 | MODULE_DESCRIPTION(DRIVER_DESC); | 2132 | MODULE_DESCRIPTION(DRIVER_DESC); |
2197 | MODULE_LICENSE("GPL"); | 2133 | MODULE_LICENSE("GPL"); |
2198 | |||
2199 | module_param(debug, bool, S_IRUGO | S_IWUSR); | ||
2200 | MODULE_PARM_DESC(debug, "Debug enabled or not"); | ||
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c index 402c32d7accb..d6d4eeca8c68 100644 --- a/drivers/usb/serial/mos7840.c +++ b/drivers/usb/serial/mos7840.c | |||
@@ -252,8 +252,6 @@ struct moschip_port { | |||
252 | struct timer_list led_timer2; /* Timer for LED off */ | 252 | struct timer_list led_timer2; /* Timer for LED off */ |
253 | }; | 253 | }; |
254 | 254 | ||
255 | static bool debug; | ||
256 | |||
257 | /* | 255 | /* |
258 | * mos7840_set_reg_sync | 256 | * mos7840_set_reg_sync |
259 | * To set the Control register by calling usb_fill_control_urb function | 257 | * To set the Control register by calling usb_fill_control_urb function |
@@ -265,7 +263,7 @@ static int mos7840_set_reg_sync(struct usb_serial_port *port, __u16 reg, | |||
265 | { | 263 | { |
266 | struct usb_device *dev = port->serial->dev; | 264 | struct usb_device *dev = port->serial->dev; |
267 | val = val & 0x00ff; | 265 | val = val & 0x00ff; |
268 | dbg("mos7840_set_reg_sync offset is %x, value %x", reg, val); | 266 | dev_dbg(&port->dev, "mos7840_set_reg_sync offset is %x, value %x\n", reg, val); |
269 | 267 | ||
270 | return usb_control_msg(dev, usb_sndctrlpipe(dev, 0), MCS_WRREQ, | 268 | return usb_control_msg(dev, usb_sndctrlpipe(dev, 0), MCS_WRREQ, |
271 | MCS_WR_RTYPE, val, reg, NULL, 0, | 269 | MCS_WR_RTYPE, val, reg, NULL, 0, |
@@ -293,7 +291,7 @@ static int mos7840_get_reg_sync(struct usb_serial_port *port, __u16 reg, | |||
293 | MCS_RD_RTYPE, 0, reg, buf, VENDOR_READ_LENGTH, | 291 | MCS_RD_RTYPE, 0, reg, buf, VENDOR_READ_LENGTH, |
294 | MOS_WDR_TIMEOUT); | 292 | MOS_WDR_TIMEOUT); |
295 | *val = buf[0]; | 293 | *val = buf[0]; |
296 | dbg("mos7840_get_reg_sync offset is %x, return val %x", reg, *val); | 294 | dev_dbg(&port->dev, "%s offset is %x, return val %x\n", __func__, reg, *val); |
297 | 295 | ||
298 | kfree(buf); | 296 | kfree(buf); |
299 | return ret; | 297 | return ret; |
@@ -316,21 +314,16 @@ static int mos7840_set_uart_reg(struct usb_serial_port *port, __u16 reg, | |||
316 | if (port->serial->num_ports == 4) { | 314 | if (port->serial->num_ports == 4) { |
317 | val |= (((__u16) port->number - | 315 | val |= (((__u16) port->number - |
318 | (__u16) (port->serial->minor)) + 1) << 8; | 316 | (__u16) (port->serial->minor)) + 1) << 8; |
319 | dbg("mos7840_set_uart_reg application number is %x", val); | ||
320 | } else { | 317 | } else { |
321 | if (((__u16) port->number - (__u16) (port->serial->minor)) == 0) { | 318 | if (((__u16) port->number - (__u16) (port->serial->minor)) == 0) { |
322 | val |= (((__u16) port->number - | 319 | val |= (((__u16) port->number - |
323 | (__u16) (port->serial->minor)) + 1) << 8; | 320 | (__u16) (port->serial->minor)) + 1) << 8; |
324 | dbg("mos7840_set_uart_reg application number is %x", | ||
325 | val); | ||
326 | } else { | 321 | } else { |
327 | val |= | 322 | val |= (((__u16) port->number - |
328 | (((__u16) port->number - | ||
329 | (__u16) (port->serial->minor)) + 2) << 8; | 323 | (__u16) (port->serial->minor)) + 2) << 8; |
330 | dbg("mos7840_set_uart_reg application number is %x", | ||
331 | val); | ||
332 | } | 324 | } |
333 | } | 325 | } |
326 | dev_dbg(&port->dev, "%s application number is %x\n", __func__, val); | ||
334 | return usb_control_msg(dev, usb_sndctrlpipe(dev, 0), MCS_WRREQ, | 327 | return usb_control_msg(dev, usb_sndctrlpipe(dev, 0), MCS_WRREQ, |
335 | MCS_WR_RTYPE, val, reg, NULL, 0, | 328 | MCS_WR_RTYPE, val, reg, NULL, 0, |
336 | MOS_WDR_TIMEOUT); | 329 | MOS_WDR_TIMEOUT); |
@@ -354,27 +347,21 @@ static int mos7840_get_uart_reg(struct usb_serial_port *port, __u16 reg, | |||
354 | if (!buf) | 347 | if (!buf) |
355 | return -ENOMEM; | 348 | return -ENOMEM; |
356 | 349 | ||
357 | /* dbg("application number is %4x", | ||
358 | (((__u16)port->number - (__u16)(port->serial->minor))+1)<<8); */ | ||
359 | /* Wval is same as application number */ | 350 | /* Wval is same as application number */ |
360 | if (port->serial->num_ports == 4) { | 351 | if (port->serial->num_ports == 4) { |
361 | Wval = | 352 | Wval = |
362 | (((__u16) port->number - (__u16) (port->serial->minor)) + | 353 | (((__u16) port->number - (__u16) (port->serial->minor)) + |
363 | 1) << 8; | 354 | 1) << 8; |
364 | dbg("mos7840_get_uart_reg application number is %x", Wval); | ||
365 | } else { | 355 | } else { |
366 | if (((__u16) port->number - (__u16) (port->serial->minor)) == 0) { | 356 | if (((__u16) port->number - (__u16) (port->serial->minor)) == 0) { |
367 | Wval = (((__u16) port->number - | 357 | Wval = (((__u16) port->number - |
368 | (__u16) (port->serial->minor)) + 1) << 8; | 358 | (__u16) (port->serial->minor)) + 1) << 8; |
369 | dbg("mos7840_get_uart_reg application number is %x", | ||
370 | Wval); | ||
371 | } else { | 359 | } else { |
372 | Wval = (((__u16) port->number - | 360 | Wval = (((__u16) port->number - |
373 | (__u16) (port->serial->minor)) + 2) << 8; | 361 | (__u16) (port->serial->minor)) + 2) << 8; |
374 | dbg("mos7840_get_uart_reg application number is %x", | ||
375 | Wval); | ||
376 | } | 362 | } |
377 | } | 363 | } |
364 | dev_dbg(&port->dev, "%s application number is %x\n", __func__, Wval); | ||
378 | ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), MCS_RDREQ, | 365 | ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), MCS_RDREQ, |
379 | MCS_RD_RTYPE, Wval, reg, buf, VENDOR_READ_LENGTH, | 366 | MCS_RD_RTYPE, Wval, reg, buf, VENDOR_READ_LENGTH, |
380 | MOS_WDR_TIMEOUT); | 367 | MOS_WDR_TIMEOUT); |
@@ -384,14 +371,13 @@ static int mos7840_get_uart_reg(struct usb_serial_port *port, __u16 reg, | |||
384 | return ret; | 371 | return ret; |
385 | } | 372 | } |
386 | 373 | ||
387 | static void mos7840_dump_serial_port(struct moschip_port *mos7840_port) | 374 | static void mos7840_dump_serial_port(struct usb_serial_port *port, |
375 | struct moschip_port *mos7840_port) | ||
388 | { | 376 | { |
389 | 377 | ||
390 | dbg("***************************************"); | 378 | dev_dbg(&port->dev, "SpRegOffset is %2x\n", mos7840_port->SpRegOffset); |
391 | dbg("SpRegOffset is %2x", mos7840_port->SpRegOffset); | 379 | dev_dbg(&port->dev, "ControlRegOffset is %2x\n", mos7840_port->ControlRegOffset); |
392 | dbg("ControlRegOffset is %2x", mos7840_port->ControlRegOffset); | 380 | dev_dbg(&port->dev, "DCRRegOffset is %2x\n", mos7840_port->DcrRegOffset); |
393 | dbg("DCRRegOffset is %2x", mos7840_port->DcrRegOffset); | ||
394 | dbg("***************************************"); | ||
395 | 381 | ||
396 | } | 382 | } |
397 | 383 | ||
@@ -450,8 +436,6 @@ static void mos7840_handle_new_lsr(struct moschip_port *port, __u8 new_lsr) | |||
450 | { | 436 | { |
451 | struct async_icount *icount; | 437 | struct async_icount *icount; |
452 | 438 | ||
453 | dbg("%s - %02x", __func__, new_lsr); | ||
454 | |||
455 | if (new_lsr & SERIAL_LSR_BI) { | 439 | if (new_lsr & SERIAL_LSR_BI) { |
456 | /* | 440 | /* |
457 | * Parity and Framing errors only count if they | 441 | * Parity and Framing errors only count if they |
@@ -492,6 +476,7 @@ static void mos7840_control_callback(struct urb *urb) | |||
492 | { | 476 | { |
493 | unsigned char *data; | 477 | unsigned char *data; |
494 | struct moschip_port *mos7840_port; | 478 | struct moschip_port *mos7840_port; |
479 | struct device *dev = &urb->dev->dev; | ||
495 | __u8 regval = 0x0; | 480 | __u8 regval = 0x0; |
496 | int result = 0; | 481 | int result = 0; |
497 | int status = urb->status; | 482 | int status = urb->status; |
@@ -506,21 +491,19 @@ static void mos7840_control_callback(struct urb *urb) | |||
506 | case -ENOENT: | 491 | case -ENOENT: |
507 | case -ESHUTDOWN: | 492 | case -ESHUTDOWN: |
508 | /* this urb is terminated, clean up */ | 493 | /* this urb is terminated, clean up */ |
509 | dbg("%s - urb shutting down with status: %d", __func__, | 494 | dev_dbg(dev, "%s - urb shutting down with status: %d\n", __func__, status); |
510 | status); | ||
511 | return; | 495 | return; |
512 | default: | 496 | default: |
513 | dbg("%s - nonzero urb status received: %d", __func__, | 497 | dev_dbg(dev, "%s - nonzero urb status received: %d\n", __func__, status); |
514 | status); | ||
515 | goto exit; | 498 | goto exit; |
516 | } | 499 | } |
517 | 500 | ||
518 | dbg("%s urb buffer size is %d", __func__, urb->actual_length); | 501 | dev_dbg(dev, "%s urb buffer size is %d\n", __func__, urb->actual_length); |
519 | dbg("%s mos7840_port->MsrLsr is %d port %d", __func__, | 502 | dev_dbg(dev, "%s mos7840_port->MsrLsr is %d port %d\n", __func__, |
520 | mos7840_port->MsrLsr, mos7840_port->port_num); | 503 | mos7840_port->MsrLsr, mos7840_port->port_num); |
521 | data = urb->transfer_buffer; | 504 | data = urb->transfer_buffer; |
522 | regval = (__u8) data[0]; | 505 | regval = (__u8) data[0]; |
523 | dbg("%s data is %x", __func__, regval); | 506 | dev_dbg(dev, "%s data is %x\n", __func__, regval); |
524 | if (mos7840_port->MsrLsr == 0) | 507 | if (mos7840_port->MsrLsr == 0) |
525 | mos7840_handle_new_msr(mos7840_port, regval); | 508 | mos7840_handle_new_msr(mos7840_port, regval); |
526 | else if (mos7840_port->MsrLsr == 1) | 509 | else if (mos7840_port->MsrLsr == 1) |
@@ -532,8 +515,7 @@ exit: | |||
532 | result = usb_submit_urb(mos7840_port->int_urb, GFP_ATOMIC); | 515 | result = usb_submit_urb(mos7840_port->int_urb, GFP_ATOMIC); |
533 | spin_unlock(&mos7840_port->pool_lock); | 516 | spin_unlock(&mos7840_port->pool_lock); |
534 | if (result) { | 517 | if (result) { |
535 | dev_err(&urb->dev->dev, | 518 | dev_err(dev, "%s - Error %d submitting interrupt urb\n", |
536 | "%s - Error %d submitting interrupt urb\n", | ||
537 | __func__, result); | 519 | __func__, result); |
538 | } | 520 | } |
539 | } | 521 | } |
@@ -570,12 +552,12 @@ static void mos7840_set_led_callback(struct urb *urb) | |||
570 | case -ENOENT: | 552 | case -ENOENT: |
571 | case -ESHUTDOWN: | 553 | case -ESHUTDOWN: |
572 | /* This urb is terminated, clean up */ | 554 | /* This urb is terminated, clean up */ |
573 | dbg("%s - urb shutting down with status: %d", __func__, | 555 | dev_dbg(&urb->dev->dev, "%s - urb shutting down with status: %d", |
574 | urb->status); | 556 | __func__, urb->status); |
575 | break; | 557 | break; |
576 | default: | 558 | default: |
577 | dbg("%s - nonzero urb status received: %d", __func__, | 559 | dev_dbg(&urb->dev->dev, "%s - nonzero urb status received: %d", |
578 | urb->status); | 560 | __func__, urb->status); |
579 | } | 561 | } |
580 | } | 562 | } |
581 | 563 | ||
@@ -650,12 +632,12 @@ static void mos7840_interrupt_callback(struct urb *urb) | |||
650 | case -ENOENT: | 632 | case -ENOENT: |
651 | case -ESHUTDOWN: | 633 | case -ESHUTDOWN: |
652 | /* this urb is terminated, clean up */ | 634 | /* this urb is terminated, clean up */ |
653 | dbg("%s - urb shutting down with status: %d", __func__, | 635 | dev_dbg(&urb->dev->dev, "%s - urb shutting down with status: %d\n", |
654 | status); | 636 | __func__, status); |
655 | return; | 637 | return; |
656 | default: | 638 | default: |
657 | dbg("%s - nonzero urb status received: %d", __func__, | 639 | dev_dbg(&urb->dev->dev, "%s - nonzero urb status received: %d\n", |
658 | status); | 640 | __func__, status); |
659 | goto exit; | 641 | goto exit; |
660 | } | 642 | } |
661 | 643 | ||
@@ -672,7 +654,7 @@ static void mos7840_interrupt_callback(struct urb *urb) | |||
672 | * Byte 5 FIFO status for both */ | 654 | * Byte 5 FIFO status for both */ |
673 | 655 | ||
674 | if (length && length > 5) { | 656 | if (length && length > 5) { |
675 | dbg("%s", "Wrong data !!!"); | 657 | dev_dbg(&urb->dev->dev, "%s", "Wrong data !!!\n"); |
676 | return; | 658 | return; |
677 | } | 659 | } |
678 | 660 | ||
@@ -689,17 +671,17 @@ static void mos7840_interrupt_callback(struct urb *urb) | |||
689 | (__u16) (serial->minor)) + 1) << 8; | 671 | (__u16) (serial->minor)) + 1) << 8; |
690 | if (mos7840_port->open) { | 672 | if (mos7840_port->open) { |
691 | if (sp[i] & 0x01) { | 673 | if (sp[i] & 0x01) { |
692 | dbg("SP%d No Interrupt !!!", i); | 674 | dev_dbg(&urb->dev->dev, "SP%d No Interrupt !!!\n", i); |
693 | } else { | 675 | } else { |
694 | switch (sp[i] & 0x0f) { | 676 | switch (sp[i] & 0x0f) { |
695 | case SERIAL_IIR_RLS: | 677 | case SERIAL_IIR_RLS: |
696 | dbg("Serial Port %d: Receiver status error or ", i); | 678 | dev_dbg(&urb->dev->dev, "Serial Port %d: Receiver status error or \n", i); |
697 | dbg("address bit detected in 9-bit mode"); | 679 | dev_dbg(&urb->dev->dev, "address bit detected in 9-bit mode\n"); |
698 | mos7840_port->MsrLsr = 1; | 680 | mos7840_port->MsrLsr = 1; |
699 | wreg = LINE_STATUS_REGISTER; | 681 | wreg = LINE_STATUS_REGISTER; |
700 | break; | 682 | break; |
701 | case SERIAL_IIR_MS: | 683 | case SERIAL_IIR_MS: |
702 | dbg("Serial Port %d: Modem status change", i); | 684 | dev_dbg(&urb->dev->dev, "Serial Port %d: Modem status change\n", i); |
703 | mos7840_port->MsrLsr = 0; | 685 | mos7840_port->MsrLsr = 0; |
704 | wreg = MODEM_STATUS_REGISTER; | 686 | wreg = MODEM_STATUS_REGISTER; |
705 | break; | 687 | break; |
@@ -731,11 +713,11 @@ static int mos7840_port_paranoia_check(struct usb_serial_port *port, | |||
731 | const char *function) | 713 | const char *function) |
732 | { | 714 | { |
733 | if (!port) { | 715 | if (!port) { |
734 | dbg("%s - port == NULL", function); | 716 | pr_debug("%s - port == NULL\n", function); |
735 | return -1; | 717 | return -1; |
736 | } | 718 | } |
737 | if (!port->serial) { | 719 | if (!port->serial) { |
738 | dbg("%s - port->serial == NULL", function); | 720 | pr_debug("%s - port->serial == NULL\n", function); |
739 | return -1; | 721 | return -1; |
740 | } | 722 | } |
741 | 723 | ||
@@ -747,11 +729,11 @@ static int mos7840_serial_paranoia_check(struct usb_serial *serial, | |||
747 | const char *function) | 729 | const char *function) |
748 | { | 730 | { |
749 | if (!serial) { | 731 | if (!serial) { |
750 | dbg("%s - serial == NULL", function); | 732 | pr_debug("%s - serial == NULL\n", function); |
751 | return -1; | 733 | return -1; |
752 | } | 734 | } |
753 | if (!serial->type) { | 735 | if (!serial->type) { |
754 | dbg("%s - serial->type == NULL!", function); | 736 | pr_debug("%s - serial->type == NULL!\n", function); |
755 | return -1; | 737 | return -1; |
756 | } | 738 | } |
757 | 739 | ||
@@ -790,49 +772,44 @@ static void mos7840_bulk_in_callback(struct urb *urb) | |||
790 | int status = urb->status; | 772 | int status = urb->status; |
791 | 773 | ||
792 | mos7840_port = urb->context; | 774 | mos7840_port = urb->context; |
793 | if (!mos7840_port) { | 775 | if (!mos7840_port) |
794 | dbg("%s", "NULL mos7840_port pointer"); | ||
795 | return; | 776 | return; |
796 | } | ||
797 | 777 | ||
798 | if (status) { | 778 | if (status) { |
799 | dbg("nonzero read bulk status received: %d", status); | 779 | dev_dbg(&urb->dev->dev, "nonzero read bulk status received: %d\n", status); |
800 | mos7840_port->read_urb_busy = false; | 780 | mos7840_port->read_urb_busy = false; |
801 | return; | 781 | return; |
802 | } | 782 | } |
803 | 783 | ||
804 | port = (struct usb_serial_port *)mos7840_port->port; | 784 | port = mos7840_port->port; |
805 | if (mos7840_port_paranoia_check(port, __func__)) { | 785 | if (mos7840_port_paranoia_check(port, __func__)) { |
806 | dbg("%s", "Port Paranoia failed"); | ||
807 | mos7840_port->read_urb_busy = false; | 786 | mos7840_port->read_urb_busy = false; |
808 | return; | 787 | return; |
809 | } | 788 | } |
810 | 789 | ||
811 | serial = mos7840_get_usb_serial(port, __func__); | 790 | serial = mos7840_get_usb_serial(port, __func__); |
812 | if (!serial) { | 791 | if (!serial) { |
813 | dbg("%s", "Bad serial pointer"); | ||
814 | mos7840_port->read_urb_busy = false; | 792 | mos7840_port->read_urb_busy = false; |
815 | return; | 793 | return; |
816 | } | 794 | } |
817 | 795 | ||
818 | data = urb->transfer_buffer; | 796 | data = urb->transfer_buffer; |
797 | usb_serial_debug_data(&port->dev, __func__, urb->actual_length, data); | ||
819 | 798 | ||
820 | if (urb->actual_length) { | 799 | if (urb->actual_length) { |
821 | tty = tty_port_tty_get(&mos7840_port->port->port); | 800 | tty = tty_port_tty_get(&mos7840_port->port->port); |
822 | if (tty) { | 801 | if (tty) { |
823 | tty_insert_flip_string(tty, data, urb->actual_length); | 802 | tty_insert_flip_string(tty, data, urb->actual_length); |
824 | dbg(" %s ", data); | ||
825 | tty_flip_buffer_push(tty); | 803 | tty_flip_buffer_push(tty); |
826 | tty_kref_put(tty); | 804 | tty_kref_put(tty); |
827 | } | 805 | } |
828 | mos7840_port->icount.rx += urb->actual_length; | 806 | mos7840_port->icount.rx += urb->actual_length; |
829 | smp_wmb(); | 807 | smp_wmb(); |
830 | dbg("mos7840_port->icount.rx is %d:", | 808 | dev_dbg(&port->dev, "mos7840_port->icount.rx is %d:\n", mos7840_port->icount.rx); |
831 | mos7840_port->icount.rx); | ||
832 | } | 809 | } |
833 | 810 | ||
834 | if (!mos7840_port->read_urb) { | 811 | if (!mos7840_port->read_urb) { |
835 | dbg("%s", "URB KILLED !!!"); | 812 | dev_dbg(&port->dev, "%s", "URB KILLED !!!\n"); |
836 | mos7840_port->read_urb_busy = false; | 813 | mos7840_port->read_urb_busy = false; |
837 | return; | 814 | return; |
838 | } | 815 | } |
@@ -850,7 +827,7 @@ static void mos7840_bulk_in_callback(struct urb *urb) | |||
850 | retval = usb_submit_urb(mos7840_port->read_urb, GFP_ATOMIC); | 827 | retval = usb_submit_urb(mos7840_port->read_urb, GFP_ATOMIC); |
851 | 828 | ||
852 | if (retval) { | 829 | if (retval) { |
853 | dbg("usb_submit_urb(read bulk) failed, retval = %d", retval); | 830 | dev_dbg(&port->dev, "usb_submit_urb(read bulk) failed, retval = %d\n", retval); |
854 | mos7840_port->read_urb_busy = false; | 831 | mos7840_port->read_urb_busy = false; |
855 | } | 832 | } |
856 | } | 833 | } |
@@ -864,11 +841,13 @@ static void mos7840_bulk_in_callback(struct urb *urb) | |||
864 | static void mos7840_bulk_out_data_callback(struct urb *urb) | 841 | static void mos7840_bulk_out_data_callback(struct urb *urb) |
865 | { | 842 | { |
866 | struct moschip_port *mos7840_port; | 843 | struct moschip_port *mos7840_port; |
844 | struct usb_serial_port *port; | ||
867 | struct tty_struct *tty; | 845 | struct tty_struct *tty; |
868 | int status = urb->status; | 846 | int status = urb->status; |
869 | int i; | 847 | int i; |
870 | 848 | ||
871 | mos7840_port = urb->context; | 849 | mos7840_port = urb->context; |
850 | port = mos7840_port->port; | ||
872 | spin_lock(&mos7840_port->pool_lock); | 851 | spin_lock(&mos7840_port->pool_lock); |
873 | for (i = 0; i < NUM_URBS; i++) { | 852 | for (i = 0; i < NUM_URBS; i++) { |
874 | if (urb == mos7840_port->write_urb_pool[i]) { | 853 | if (urb == mos7840_port->write_urb_pool[i]) { |
@@ -879,16 +858,14 @@ static void mos7840_bulk_out_data_callback(struct urb *urb) | |||
879 | spin_unlock(&mos7840_port->pool_lock); | 858 | spin_unlock(&mos7840_port->pool_lock); |
880 | 859 | ||
881 | if (status) { | 860 | if (status) { |
882 | dbg("nonzero write bulk status received:%d", status); | 861 | dev_dbg(&port->dev, "nonzero write bulk status received:%d\n", status); |
883 | return; | 862 | return; |
884 | } | 863 | } |
885 | 864 | ||
886 | if (mos7840_port_paranoia_check(mos7840_port->port, __func__)) { | 865 | if (mos7840_port_paranoia_check(port, __func__)) |
887 | dbg("%s", "Port Paranoia failed"); | ||
888 | return; | 866 | return; |
889 | } | ||
890 | 867 | ||
891 | tty = tty_port_tty_get(&mos7840_port->port->port); | 868 | tty = tty_port_tty_get(&port->port); |
892 | if (tty && mos7840_port->open) | 869 | if (tty && mos7840_port->open) |
893 | tty_wakeup(tty); | 870 | tty_wakeup(tty); |
894 | tty_kref_put(tty); | 871 | tty_kref_put(tty); |
@@ -929,17 +906,13 @@ static int mos7840_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
929 | struct moschip_port *mos7840_port; | 906 | struct moschip_port *mos7840_port; |
930 | struct moschip_port *port0; | 907 | struct moschip_port *port0; |
931 | 908 | ||
932 | if (mos7840_port_paranoia_check(port, __func__)) { | 909 | if (mos7840_port_paranoia_check(port, __func__)) |
933 | dbg("%s", "Port Paranoia failed"); | ||
934 | return -ENODEV; | 910 | return -ENODEV; |
935 | } | ||
936 | 911 | ||
937 | serial = port->serial; | 912 | serial = port->serial; |
938 | 913 | ||
939 | if (mos7840_serial_paranoia_check(serial, __func__)) { | 914 | if (mos7840_serial_paranoia_check(serial, __func__)) |
940 | dbg("%s", "Serial Paranoia failed"); | ||
941 | return -ENODEV; | 915 | return -ENODEV; |
942 | } | ||
943 | 916 | ||
944 | mos7840_port = mos7840_get_port_private(port); | 917 | mos7840_port = mos7840_get_port_private(port); |
945 | port0 = mos7840_get_port_private(serial->port[0]); | 918 | port0 = mos7840_get_port_private(serial->port[0]); |
@@ -990,20 +963,20 @@ static int mos7840_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
990 | Data = 0x0; | 963 | Data = 0x0; |
991 | status = mos7840_get_reg_sync(port, mos7840_port->SpRegOffset, &Data); | 964 | status = mos7840_get_reg_sync(port, mos7840_port->SpRegOffset, &Data); |
992 | if (status < 0) { | 965 | if (status < 0) { |
993 | dbg("Reading Spreg failed"); | 966 | dev_dbg(&port->dev, "Reading Spreg failed\n"); |
994 | return -1; | 967 | return -1; |
995 | } | 968 | } |
996 | Data |= 0x80; | 969 | Data |= 0x80; |
997 | status = mos7840_set_reg_sync(port, mos7840_port->SpRegOffset, Data); | 970 | status = mos7840_set_reg_sync(port, mos7840_port->SpRegOffset, Data); |
998 | if (status < 0) { | 971 | if (status < 0) { |
999 | dbg("writing Spreg failed"); | 972 | dev_dbg(&port->dev, "writing Spreg failed\n"); |
1000 | return -1; | 973 | return -1; |
1001 | } | 974 | } |
1002 | 975 | ||
1003 | Data &= ~0x80; | 976 | Data &= ~0x80; |
1004 | status = mos7840_set_reg_sync(port, mos7840_port->SpRegOffset, Data); | 977 | status = mos7840_set_reg_sync(port, mos7840_port->SpRegOffset, Data); |
1005 | if (status < 0) { | 978 | if (status < 0) { |
1006 | dbg("writing Spreg failed"); | 979 | dev_dbg(&port->dev, "writing Spreg failed\n"); |
1007 | return -1; | 980 | return -1; |
1008 | } | 981 | } |
1009 | /* End of block to be checked */ | 982 | /* End of block to be checked */ |
@@ -1012,7 +985,7 @@ static int mos7840_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
1012 | status = mos7840_get_reg_sync(port, mos7840_port->ControlRegOffset, | 985 | status = mos7840_get_reg_sync(port, mos7840_port->ControlRegOffset, |
1013 | &Data); | 986 | &Data); |
1014 | if (status < 0) { | 987 | if (status < 0) { |
1015 | dbg("Reading Controlreg failed"); | 988 | dev_dbg(&port->dev, "Reading Controlreg failed\n"); |
1016 | return -1; | 989 | return -1; |
1017 | } | 990 | } |
1018 | Data |= 0x08; /* Driver done bit */ | 991 | Data |= 0x08; /* Driver done bit */ |
@@ -1020,7 +993,7 @@ static int mos7840_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
1020 | status = mos7840_set_reg_sync(port, | 993 | status = mos7840_set_reg_sync(port, |
1021 | mos7840_port->ControlRegOffset, Data); | 994 | mos7840_port->ControlRegOffset, Data); |
1022 | if (status < 0) { | 995 | if (status < 0) { |
1023 | dbg("writing Controlreg failed"); | 996 | dev_dbg(&port->dev, "writing Controlreg failed\n"); |
1024 | return -1; | 997 | return -1; |
1025 | } | 998 | } |
1026 | /* do register settings here */ | 999 | /* do register settings here */ |
@@ -1031,21 +1004,21 @@ static int mos7840_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
1031 | Data = 0x00; | 1004 | Data = 0x00; |
1032 | status = mos7840_set_uart_reg(port, INTERRUPT_ENABLE_REGISTER, Data); | 1005 | status = mos7840_set_uart_reg(port, INTERRUPT_ENABLE_REGISTER, Data); |
1033 | if (status < 0) { | 1006 | if (status < 0) { |
1034 | dbg("disabling interrupts failed"); | 1007 | dev_dbg(&port->dev, "disabling interrupts failed\n"); |
1035 | return -1; | 1008 | return -1; |
1036 | } | 1009 | } |
1037 | /* Set FIFO_CONTROL_REGISTER to the default value */ | 1010 | /* Set FIFO_CONTROL_REGISTER to the default value */ |
1038 | Data = 0x00; | 1011 | Data = 0x00; |
1039 | status = mos7840_set_uart_reg(port, FIFO_CONTROL_REGISTER, Data); | 1012 | status = mos7840_set_uart_reg(port, FIFO_CONTROL_REGISTER, Data); |
1040 | if (status < 0) { | 1013 | if (status < 0) { |
1041 | dbg("Writing FIFO_CONTROL_REGISTER failed"); | 1014 | dev_dbg(&port->dev, "Writing FIFO_CONTROL_REGISTER failed\n"); |
1042 | return -1; | 1015 | return -1; |
1043 | } | 1016 | } |
1044 | 1017 | ||
1045 | Data = 0xcf; | 1018 | Data = 0xcf; |
1046 | status = mos7840_set_uart_reg(port, FIFO_CONTROL_REGISTER, Data); | 1019 | status = mos7840_set_uart_reg(port, FIFO_CONTROL_REGISTER, Data); |
1047 | if (status < 0) { | 1020 | if (status < 0) { |
1048 | dbg("Writing FIFO_CONTROL_REGISTER failed"); | 1021 | dev_dbg(&port->dev, "Writing FIFO_CONTROL_REGISTER failed\n"); |
1049 | return -1; | 1022 | return -1; |
1050 | } | 1023 | } |
1051 | 1024 | ||
@@ -1142,12 +1115,12 @@ static int mos7840_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
1142 | * (can't set it up in mos7840_startup as the * | 1115 | * (can't set it up in mos7840_startup as the * |
1143 | * structures were not set up at that time.) */ | 1116 | * structures were not set up at that time.) */ |
1144 | 1117 | ||
1145 | dbg("port number is %d", port->number); | 1118 | dev_dbg(&port->dev, "port number is %d\n", port->number); |
1146 | dbg("serial number is %d", port->serial->minor); | 1119 | dev_dbg(&port->dev, "serial number is %d\n", port->serial->minor); |
1147 | dbg("Bulkin endpoint is %d", port->bulk_in_endpointAddress); | 1120 | dev_dbg(&port->dev, "Bulkin endpoint is %d\n", port->bulk_in_endpointAddress); |
1148 | dbg("BulkOut endpoint is %d", port->bulk_out_endpointAddress); | 1121 | dev_dbg(&port->dev, "BulkOut endpoint is %d\n", port->bulk_out_endpointAddress); |
1149 | dbg("Interrupt endpoint is %d", port->interrupt_in_endpointAddress); | 1122 | dev_dbg(&port->dev, "Interrupt endpoint is %d\n", port->interrupt_in_endpointAddress); |
1150 | dbg("port's number in the device is %d", mos7840_port->port_num); | 1123 | dev_dbg(&port->dev, "port's number in the device is %d\n", mos7840_port->port_num); |
1151 | mos7840_port->read_urb = port->read_urb; | 1124 | mos7840_port->read_urb = port->read_urb; |
1152 | 1125 | ||
1153 | /* set up our bulk in urb */ | 1126 | /* set up our bulk in urb */ |
@@ -1171,8 +1144,7 @@ static int mos7840_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
1171 | mos7840_bulk_in_callback, mos7840_port); | 1144 | mos7840_bulk_in_callback, mos7840_port); |
1172 | } | 1145 | } |
1173 | 1146 | ||
1174 | dbg("mos7840_open: bulkin endpoint is %d", | 1147 | dev_dbg(&port->dev, "%s: bulkin endpoint is %d\n", __func__, port->bulk_in_endpointAddress); |
1175 | port->bulk_in_endpointAddress); | ||
1176 | mos7840_port->read_urb_busy = true; | 1148 | mos7840_port->read_urb_busy = true; |
1177 | response = usb_submit_urb(mos7840_port->read_urb, GFP_KERNEL); | 1149 | response = usb_submit_urb(mos7840_port->read_urb, GFP_KERNEL); |
1178 | if (response) { | 1150 | if (response) { |
@@ -1197,9 +1169,6 @@ static int mos7840_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
1197 | mos7840_port->icount.tx = 0; | 1169 | mos7840_port->icount.tx = 0; |
1198 | mos7840_port->icount.rx = 0; | 1170 | mos7840_port->icount.rx = 0; |
1199 | 1171 | ||
1200 | dbg("usb_serial serial:%p mos7840_port:%p\n usb_serial_port port:%p", | ||
1201 | serial, mos7840_port, port); | ||
1202 | |||
1203 | return 0; | 1172 | return 0; |
1204 | } | 1173 | } |
1205 | 1174 | ||
@@ -1221,10 +1190,8 @@ static int mos7840_chars_in_buffer(struct tty_struct *tty) | |||
1221 | unsigned long flags; | 1190 | unsigned long flags; |
1222 | struct moschip_port *mos7840_port; | 1191 | struct moschip_port *mos7840_port; |
1223 | 1192 | ||
1224 | if (mos7840_port_paranoia_check(port, __func__)) { | 1193 | if (mos7840_port_paranoia_check(port, __func__)) |
1225 | dbg("%s", "Invalid port"); | ||
1226 | return 0; | 1194 | return 0; |
1227 | } | ||
1228 | 1195 | ||
1229 | mos7840_port = mos7840_get_port_private(port); | 1196 | mos7840_port = mos7840_get_port_private(port); |
1230 | if (mos7840_port == NULL) | 1197 | if (mos7840_port == NULL) |
@@ -1238,7 +1205,7 @@ static int mos7840_chars_in_buffer(struct tty_struct *tty) | |||
1238 | } | 1205 | } |
1239 | } | 1206 | } |
1240 | spin_unlock_irqrestore(&mos7840_port->pool_lock, flags); | 1207 | spin_unlock_irqrestore(&mos7840_port->pool_lock, flags); |
1241 | dbg("%s - returns %d", __func__, chars); | 1208 | dev_dbg(&port->dev, "%s - returns %d\n", __func__, chars); |
1242 | return chars; | 1209 | return chars; |
1243 | 1210 | ||
1244 | } | 1211 | } |
@@ -1256,16 +1223,12 @@ static void mos7840_close(struct usb_serial_port *port) | |||
1256 | int j; | 1223 | int j; |
1257 | __u16 Data; | 1224 | __u16 Data; |
1258 | 1225 | ||
1259 | if (mos7840_port_paranoia_check(port, __func__)) { | 1226 | if (mos7840_port_paranoia_check(port, __func__)) |
1260 | dbg("%s", "Port Paranoia failed"); | ||
1261 | return; | 1227 | return; |
1262 | } | ||
1263 | 1228 | ||
1264 | serial = mos7840_get_usb_serial(port, __func__); | 1229 | serial = mos7840_get_usb_serial(port, __func__); |
1265 | if (!serial) { | 1230 | if (!serial) |
1266 | dbg("%s", "Serial Paranoia failed"); | ||
1267 | return; | 1231 | return; |
1268 | } | ||
1269 | 1232 | ||
1270 | mos7840_port = mos7840_get_port_private(port); | 1233 | mos7840_port = mos7840_get_port_private(port); |
1271 | port0 = mos7840_get_port_private(serial->port[0]); | 1234 | port0 = mos7840_get_port_private(serial->port[0]); |
@@ -1291,27 +1254,26 @@ static void mos7840_close(struct usb_serial_port *port) | |||
1291 | * and interrupt read if they exists */ | 1254 | * and interrupt read if they exists */ |
1292 | if (serial->dev) { | 1255 | if (serial->dev) { |
1293 | if (mos7840_port->write_urb) { | 1256 | if (mos7840_port->write_urb) { |
1294 | dbg("%s", "Shutdown bulk write"); | 1257 | dev_dbg(&port->dev, "%s", "Shutdown bulk write\n"); |
1295 | usb_kill_urb(mos7840_port->write_urb); | 1258 | usb_kill_urb(mos7840_port->write_urb); |
1296 | } | 1259 | } |
1297 | if (mos7840_port->read_urb) { | 1260 | if (mos7840_port->read_urb) { |
1298 | dbg("%s", "Shutdown bulk read"); | 1261 | dev_dbg(&port->dev, "%s", "Shutdown bulk read\n"); |
1299 | usb_kill_urb(mos7840_port->read_urb); | 1262 | usb_kill_urb(mos7840_port->read_urb); |
1300 | mos7840_port->read_urb_busy = false; | 1263 | mos7840_port->read_urb_busy = false; |
1301 | } | 1264 | } |
1302 | if ((&mos7840_port->control_urb)) { | 1265 | if ((&mos7840_port->control_urb)) { |
1303 | dbg("%s", "Shutdown control read"); | 1266 | dev_dbg(&port->dev, "%s", "Shutdown control read\n"); |
1304 | /*/ usb_kill_urb (mos7840_port->control_urb); */ | 1267 | /*/ usb_kill_urb (mos7840_port->control_urb); */ |
1305 | } | 1268 | } |
1306 | } | 1269 | } |
1307 | /* if(mos7840_port->ctrl_buf != NULL) */ | 1270 | /* if(mos7840_port->ctrl_buf != NULL) */ |
1308 | /* kfree(mos7840_port->ctrl_buf); */ | 1271 | /* kfree(mos7840_port->ctrl_buf); */ |
1309 | port0->open_ports--; | 1272 | port0->open_ports--; |
1310 | dbg("mos7840_num_open_ports in close%d:in port%d", | 1273 | dev_dbg(&port->dev, "%s in close%d:in port%d\n", __func__, port0->open_ports, port->number); |
1311 | port0->open_ports, port->number); | ||
1312 | if (port0->open_ports == 0) { | 1274 | if (port0->open_ports == 0) { |
1313 | if (serial->port[0]->interrupt_in_urb) { | 1275 | if (serial->port[0]->interrupt_in_urb) { |
1314 | dbg("%s", "Shutdown interrupt_in_urb"); | 1276 | dev_dbg(&port->dev, "Shutdown interrupt_in_urb\n"); |
1315 | usb_kill_urb(serial->port[0]->interrupt_in_urb); | 1277 | usb_kill_urb(serial->port[0]->interrupt_in_urb); |
1316 | } | 1278 | } |
1317 | } | 1279 | } |
@@ -1363,7 +1325,7 @@ static void mos7840_block_until_chase_response(struct tty_struct *tty, | |||
1363 | /* No activity.. count down section */ | 1325 | /* No activity.. count down section */ |
1364 | wait--; | 1326 | wait--; |
1365 | if (wait == 0) { | 1327 | if (wait == 0) { |
1366 | dbg("%s - TIMEOUT", __func__); | 1328 | dev_dbg(&mos7840_port->port->dev, "%s - TIMEOUT\n", __func__); |
1367 | return; | 1329 | return; |
1368 | } else { | 1330 | } else { |
1369 | /* Reset timeout value back to seconds */ | 1331 | /* Reset timeout value back to seconds */ |
@@ -1384,16 +1346,12 @@ static void mos7840_break(struct tty_struct *tty, int break_state) | |||
1384 | struct usb_serial *serial; | 1346 | struct usb_serial *serial; |
1385 | struct moschip_port *mos7840_port; | 1347 | struct moschip_port *mos7840_port; |
1386 | 1348 | ||
1387 | if (mos7840_port_paranoia_check(port, __func__)) { | 1349 | if (mos7840_port_paranoia_check(port, __func__)) |
1388 | dbg("%s", "Port Paranoia failed"); | ||
1389 | return; | 1350 | return; |
1390 | } | ||
1391 | 1351 | ||
1392 | serial = mos7840_get_usb_serial(port, __func__); | 1352 | serial = mos7840_get_usb_serial(port, __func__); |
1393 | if (!serial) { | 1353 | if (!serial) |
1394 | dbg("%s", "Serial Paranoia failed"); | ||
1395 | return; | 1354 | return; |
1396 | } | ||
1397 | 1355 | ||
1398 | mos7840_port = mos7840_get_port_private(port); | 1356 | mos7840_port = mos7840_get_port_private(port); |
1399 | 1357 | ||
@@ -1411,8 +1369,7 @@ static void mos7840_break(struct tty_struct *tty, int break_state) | |||
1411 | 1369 | ||
1412 | /* FIXME: no locking on shadowLCR anywhere in driver */ | 1370 | /* FIXME: no locking on shadowLCR anywhere in driver */ |
1413 | mos7840_port->shadowLCR = data; | 1371 | mos7840_port->shadowLCR = data; |
1414 | dbg("mcs7840_break mos7840_port->shadowLCR is %x", | 1372 | dev_dbg(&port->dev, "%s mos7840_port->shadowLCR is %x\n", __func__, mos7840_port->shadowLCR); |
1415 | mos7840_port->shadowLCR); | ||
1416 | mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, | 1373 | mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, |
1417 | mos7840_port->shadowLCR); | 1374 | mos7840_port->shadowLCR); |
1418 | } | 1375 | } |
@@ -1433,17 +1390,12 @@ static int mos7840_write_room(struct tty_struct *tty) | |||
1433 | unsigned long flags; | 1390 | unsigned long flags; |
1434 | struct moschip_port *mos7840_port; | 1391 | struct moschip_port *mos7840_port; |
1435 | 1392 | ||
1436 | if (mos7840_port_paranoia_check(port, __func__)) { | 1393 | if (mos7840_port_paranoia_check(port, __func__)) |
1437 | dbg("%s", "Invalid port"); | ||
1438 | dbg("%s", " mos7840_write_room:leaving ..........."); | ||
1439 | return -1; | 1394 | return -1; |
1440 | } | ||
1441 | 1395 | ||
1442 | mos7840_port = mos7840_get_port_private(port); | 1396 | mos7840_port = mos7840_get_port_private(port); |
1443 | if (mos7840_port == NULL) { | 1397 | if (mos7840_port == NULL) |
1444 | dbg("%s", "mos7840_break:leaving ..........."); | ||
1445 | return -1; | 1398 | return -1; |
1446 | } | ||
1447 | 1399 | ||
1448 | spin_lock_irqsave(&mos7840_port->pool_lock, flags); | 1400 | spin_lock_irqsave(&mos7840_port->pool_lock, flags); |
1449 | for (i = 0; i < NUM_URBS; ++i) { | 1401 | for (i = 0; i < NUM_URBS; ++i) { |
@@ -1453,7 +1405,7 @@ static int mos7840_write_room(struct tty_struct *tty) | |||
1453 | spin_unlock_irqrestore(&mos7840_port->pool_lock, flags); | 1405 | spin_unlock_irqrestore(&mos7840_port->pool_lock, flags); |
1454 | 1406 | ||
1455 | room = (room == 0) ? 0 : room - URB_TRANSFER_BUFFER_SIZE + 1; | 1407 | room = (room == 0) ? 0 : room - URB_TRANSFER_BUFFER_SIZE + 1; |
1456 | dbg("%s - returns %d", __func__, room); | 1408 | dev_dbg(&mos7840_port->port->dev, "%s - returns %d\n", __func__, room); |
1457 | return room; | 1409 | return room; |
1458 | 1410 | ||
1459 | } | 1411 | } |
@@ -1486,9 +1438,8 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
1486 | Data = 0x00; | 1438 | Data = 0x00; |
1487 | status = mos7840_get_uart_reg(port, LINE_CONTROL_REGISTER, &Data); | 1439 | status = mos7840_get_uart_reg(port, LINE_CONTROL_REGISTER, &Data); |
1488 | mos7840_port->shadowLCR = Data; | 1440 | mos7840_port->shadowLCR = Data; |
1489 | dbg("mos7840_write: LINE_CONTROL_REGISTER is %x", Data); | 1441 | dev_dbg(&port->dev, "%s: LINE_CONTROL_REGISTER is %x\n", __func__, Data); |
1490 | dbg("mos7840_write: mos7840_port->shadowLCR is %x", | 1442 | dev_dbg(&port->dev, "%s: mos7840_port->shadowLCR is %x\n", __func__, mos7840_port->shadowLCR); |
1491 | mos7840_port->shadowLCR); | ||
1492 | 1443 | ||
1493 | /* Data = 0x03; */ | 1444 | /* Data = 0x03; */ |
1494 | /* status = mos7840_set_uart_reg(port,LINE_CONTROL_REGISTER,Data); */ | 1445 | /* status = mos7840_set_uart_reg(port,LINE_CONTROL_REGISTER,Data); */ |
@@ -1501,34 +1452,27 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
1501 | /* status = mos7840_set_uart_reg(port,DIVISOR_LATCH_LSB,Data); */ | 1452 | /* status = mos7840_set_uart_reg(port,DIVISOR_LATCH_LSB,Data); */ |
1502 | Data = 0x00; | 1453 | Data = 0x00; |
1503 | status = mos7840_get_uart_reg(port, DIVISOR_LATCH_LSB, &Data); | 1454 | status = mos7840_get_uart_reg(port, DIVISOR_LATCH_LSB, &Data); |
1504 | dbg("mos7840_write:DLL value is %x", Data); | 1455 | dev_dbg(&port->dev, "%s: DLL value is %x\n", __func__, Data); |
1505 | 1456 | ||
1506 | Data = 0x0; | 1457 | Data = 0x0; |
1507 | status = mos7840_get_uart_reg(port, DIVISOR_LATCH_MSB, &Data); | 1458 | status = mos7840_get_uart_reg(port, DIVISOR_LATCH_MSB, &Data); |
1508 | dbg("mos7840_write:DLM value is %x", Data); | 1459 | dev_dbg(&port->dev, "%s: DLM value is %x\n", __func__, Data); |
1509 | 1460 | ||
1510 | Data = Data & ~SERIAL_LCR_DLAB; | 1461 | Data = Data & ~SERIAL_LCR_DLAB; |
1511 | dbg("mos7840_write: mos7840_port->shadowLCR is %x", | 1462 | dev_dbg(&port->dev, "%s: mos7840_port->shadowLCR is %x\n", __func__, mos7840_port->shadowLCR); |
1512 | mos7840_port->shadowLCR); | ||
1513 | status = mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data); | 1463 | status = mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data); |
1514 | #endif | 1464 | #endif |
1515 | 1465 | ||
1516 | if (mos7840_port_paranoia_check(port, __func__)) { | 1466 | if (mos7840_port_paranoia_check(port, __func__)) |
1517 | dbg("%s", "Port Paranoia failed"); | ||
1518 | return -1; | 1467 | return -1; |
1519 | } | ||
1520 | 1468 | ||
1521 | serial = port->serial; | 1469 | serial = port->serial; |
1522 | if (mos7840_serial_paranoia_check(serial, __func__)) { | 1470 | if (mos7840_serial_paranoia_check(serial, __func__)) |
1523 | dbg("%s", "Serial Paranoia failed"); | ||
1524 | return -1; | 1471 | return -1; |
1525 | } | ||
1526 | 1472 | ||
1527 | mos7840_port = mos7840_get_port_private(port); | 1473 | mos7840_port = mos7840_get_port_private(port); |
1528 | if (mos7840_port == NULL) { | 1474 | if (mos7840_port == NULL) |
1529 | dbg("%s", "mos7840_port is NULL"); | ||
1530 | return -1; | 1475 | return -1; |
1531 | } | ||
1532 | 1476 | ||
1533 | /* try to find a free urb in the list */ | 1477 | /* try to find a free urb in the list */ |
1534 | urb = NULL; | 1478 | urb = NULL; |
@@ -1538,14 +1482,14 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
1538 | if (!mos7840_port->busy[i]) { | 1482 | if (!mos7840_port->busy[i]) { |
1539 | mos7840_port->busy[i] = 1; | 1483 | mos7840_port->busy[i] = 1; |
1540 | urb = mos7840_port->write_urb_pool[i]; | 1484 | urb = mos7840_port->write_urb_pool[i]; |
1541 | dbg("URB:%d", i); | 1485 | dev_dbg(&port->dev, "URB:%d\n", i); |
1542 | break; | 1486 | break; |
1543 | } | 1487 | } |
1544 | } | 1488 | } |
1545 | spin_unlock_irqrestore(&mos7840_port->pool_lock, flags); | 1489 | spin_unlock_irqrestore(&mos7840_port->pool_lock, flags); |
1546 | 1490 | ||
1547 | if (urb == NULL) { | 1491 | if (urb == NULL) { |
1548 | dbg("%s - no more free urbs", __func__); | 1492 | dev_dbg(&port->dev, "%s - no more free urbs\n", __func__); |
1549 | goto exit; | 1493 | goto exit; |
1550 | } | 1494 | } |
1551 | 1495 | ||
@@ -1585,7 +1529,7 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
1585 | } | 1529 | } |
1586 | 1530 | ||
1587 | data1 = urb->transfer_buffer; | 1531 | data1 = urb->transfer_buffer; |
1588 | dbg("bulkout endpoint is %d", port->bulk_out_endpointAddress); | 1532 | dev_dbg(&port->dev, "bulkout endpoint is %d\n", port->bulk_out_endpointAddress); |
1589 | 1533 | ||
1590 | /* Turn on LED */ | 1534 | /* Turn on LED */ |
1591 | if (mos7840_port->has_led && !mos7840_port->led_flag) { | 1535 | if (mos7840_port->has_led && !mos7840_port->led_flag) { |
@@ -1608,7 +1552,7 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
1608 | bytes_sent = transfer_size; | 1552 | bytes_sent = transfer_size; |
1609 | mos7840_port->icount.tx += transfer_size; | 1553 | mos7840_port->icount.tx += transfer_size; |
1610 | smp_wmb(); | 1554 | smp_wmb(); |
1611 | dbg("mos7840_port->icount.tx is %d:", mos7840_port->icount.tx); | 1555 | dev_dbg(&port->dev, "mos7840_port->icount.tx is %d:\n", mos7840_port->icount.tx); |
1612 | exit: | 1556 | exit: |
1613 | return bytes_sent; | 1557 | return bytes_sent; |
1614 | 1558 | ||
@@ -1626,12 +1570,8 @@ static void mos7840_throttle(struct tty_struct *tty) | |||
1626 | struct moschip_port *mos7840_port; | 1570 | struct moschip_port *mos7840_port; |
1627 | int status; | 1571 | int status; |
1628 | 1572 | ||
1629 | if (mos7840_port_paranoia_check(port, __func__)) { | 1573 | if (mos7840_port_paranoia_check(port, __func__)) |
1630 | dbg("%s", "Invalid port"); | ||
1631 | return; | 1574 | return; |
1632 | } | ||
1633 | |||
1634 | dbg("- port %d", port->number); | ||
1635 | 1575 | ||
1636 | mos7840_port = mos7840_get_port_private(port); | 1576 | mos7840_port = mos7840_get_port_private(port); |
1637 | 1577 | ||
@@ -1639,7 +1579,7 @@ static void mos7840_throttle(struct tty_struct *tty) | |||
1639 | return; | 1579 | return; |
1640 | 1580 | ||
1641 | if (!mos7840_port->open) { | 1581 | if (!mos7840_port->open) { |
1642 | dbg("%s", "port not opened"); | 1582 | dev_dbg(&port->dev, "%s", "port not opened\n"); |
1643 | return; | 1583 | return; |
1644 | } | 1584 | } |
1645 | 1585 | ||
@@ -1672,16 +1612,14 @@ static void mos7840_unthrottle(struct tty_struct *tty) | |||
1672 | int status; | 1612 | int status; |
1673 | struct moschip_port *mos7840_port = mos7840_get_port_private(port); | 1613 | struct moschip_port *mos7840_port = mos7840_get_port_private(port); |
1674 | 1614 | ||
1675 | if (mos7840_port_paranoia_check(port, __func__)) { | 1615 | if (mos7840_port_paranoia_check(port, __func__)) |
1676 | dbg("%s", "Invalid port"); | ||
1677 | return; | 1616 | return; |
1678 | } | ||
1679 | 1617 | ||
1680 | if (mos7840_port == NULL) | 1618 | if (mos7840_port == NULL) |
1681 | return; | 1619 | return; |
1682 | 1620 | ||
1683 | if (!mos7840_port->open) { | 1621 | if (!mos7840_port->open) { |
1684 | dbg("%s - port not opened", __func__); | 1622 | dev_dbg(&port->dev, "%s - port not opened\n", __func__); |
1685 | return; | 1623 | return; |
1686 | } | 1624 | } |
1687 | 1625 | ||
@@ -1726,7 +1664,7 @@ static int mos7840_tiocmget(struct tty_struct *tty) | |||
1726 | | ((msr & MOS7840_MSR_RI) ? TIOCM_RI : 0) | 1664 | | ((msr & MOS7840_MSR_RI) ? TIOCM_RI : 0) |
1727 | | ((msr & MOS7840_MSR_DSR) ? TIOCM_DSR : 0); | 1665 | | ((msr & MOS7840_MSR_DSR) ? TIOCM_DSR : 0); |
1728 | 1666 | ||
1729 | dbg("%s - 0x%04X", __func__, result); | 1667 | dev_dbg(&port->dev, "%s - 0x%04X\n", __func__, result); |
1730 | 1668 | ||
1731 | return result; | 1669 | return result; |
1732 | } | 1670 | } |
@@ -1764,7 +1702,7 @@ static int mos7840_tiocmset(struct tty_struct *tty, | |||
1764 | 1702 | ||
1765 | status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, mcr); | 1703 | status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, mcr); |
1766 | if (status < 0) { | 1704 | if (status < 0) { |
1767 | dbg("setting MODEM_CONTROL_REGISTER Failed"); | 1705 | dev_dbg(&port->dev, "setting MODEM_CONTROL_REGISTER Failed\n"); |
1768 | return status; | 1706 | return status; |
1769 | } | 1707 | } |
1770 | 1708 | ||
@@ -1776,10 +1714,11 @@ static int mos7840_tiocmset(struct tty_struct *tty, | |||
1776 | * this function calculates the proper baud rate divisor for the specified | 1714 | * this function calculates the proper baud rate divisor for the specified |
1777 | * baud rate. | 1715 | * baud rate. |
1778 | *****************************************************************************/ | 1716 | *****************************************************************************/ |
1779 | static int mos7840_calc_baud_rate_divisor(int baudRate, int *divisor, | 1717 | static int mos7840_calc_baud_rate_divisor(struct usb_serial_port *port, |
1718 | int baudRate, int *divisor, | ||
1780 | __u16 *clk_sel_val) | 1719 | __u16 *clk_sel_val) |
1781 | { | 1720 | { |
1782 | dbg("%s - %d", __func__, baudRate); | 1721 | dev_dbg(&port->dev, "%s - %d\n", __func__, baudRate); |
1783 | 1722 | ||
1784 | if (baudRate <= 115200) { | 1723 | if (baudRate <= 115200) { |
1785 | *divisor = 115200 / baudRate; | 1724 | *divisor = 115200 / baudRate; |
@@ -1832,11 +1771,11 @@ static int mos7840_calc_baud_rate_divisor(int baudRate, int *divisor, | |||
1832 | custom++; | 1771 | custom++; |
1833 | *divisor = custom; | 1772 | *divisor = custom; |
1834 | 1773 | ||
1835 | dbg(" Baud %d = %d", baudrate, custom); | 1774 | dev_dbg(&port->dev, " Baud %d = %d\n", baudrate, custom); |
1836 | return 0; | 1775 | return 0; |
1837 | } | 1776 | } |
1838 | 1777 | ||
1839 | dbg("%s", " Baud calculation Failed..."); | 1778 | dev_dbg(&port->dev, "%s", " Baud calculation Failed...\n"); |
1840 | return -1; | 1779 | return -1; |
1841 | #endif | 1780 | #endif |
1842 | } | 1781 | } |
@@ -1860,21 +1799,17 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port, | |||
1860 | if (mos7840_port == NULL) | 1799 | if (mos7840_port == NULL) |
1861 | return -1; | 1800 | return -1; |
1862 | 1801 | ||
1863 | port = (struct usb_serial_port *)mos7840_port->port; | 1802 | port = mos7840_port->port; |
1864 | if (mos7840_port_paranoia_check(port, __func__)) { | 1803 | if (mos7840_port_paranoia_check(port, __func__)) |
1865 | dbg("%s", "Invalid port"); | ||
1866 | return -1; | 1804 | return -1; |
1867 | } | ||
1868 | 1805 | ||
1869 | if (mos7840_serial_paranoia_check(port->serial, __func__)) { | 1806 | if (mos7840_serial_paranoia_check(port->serial, __func__)) |
1870 | dbg("%s", "Invalid Serial"); | ||
1871 | return -1; | 1807 | return -1; |
1872 | } | ||
1873 | 1808 | ||
1874 | number = mos7840_port->port->number - mos7840_port->port->serial->minor; | 1809 | number = mos7840_port->port->number - mos7840_port->port->serial->minor; |
1875 | 1810 | ||
1876 | dbg("%s - port = %d, baud = %d", __func__, | 1811 | dev_dbg(&port->dev, "%s - port = %d, baud = %d\n", __func__, |
1877 | mos7840_port->port->number, baudRate); | 1812 | mos7840_port->port->number, baudRate); |
1878 | /* reset clk_uart_sel in spregOffset */ | 1813 | /* reset clk_uart_sel in spregOffset */ |
1879 | if (baudRate > 115200) { | 1814 | if (baudRate > 115200) { |
1880 | #ifdef HW_flow_control | 1815 | #ifdef HW_flow_control |
@@ -1885,7 +1820,7 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port, | |||
1885 | status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, | 1820 | status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, |
1886 | Data); | 1821 | Data); |
1887 | if (status < 0) { | 1822 | if (status < 0) { |
1888 | dbg("Writing spreg failed in set_serial_baud"); | 1823 | dev_dbg(&port->dev, "Writing spreg failed in set_serial_baud\n"); |
1889 | return -1; | 1824 | return -1; |
1890 | } | 1825 | } |
1891 | #endif | 1826 | #endif |
@@ -1898,7 +1833,7 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port, | |||
1898 | status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, | 1833 | status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, |
1899 | Data); | 1834 | Data); |
1900 | if (status < 0) { | 1835 | if (status < 0) { |
1901 | dbg("Writing spreg failed in set_serial_baud"); | 1836 | dev_dbg(&port->dev, "Writing spreg failed in set_serial_baud\n"); |
1902 | return -1; | 1837 | return -1; |
1903 | } | 1838 | } |
1904 | #endif | 1839 | #endif |
@@ -1908,19 +1843,19 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port, | |||
1908 | if (1) { /* baudRate <= 115200) */ | 1843 | if (1) { /* baudRate <= 115200) */ |
1909 | clk_sel_val = 0x0; | 1844 | clk_sel_val = 0x0; |
1910 | Data = 0x0; | 1845 | Data = 0x0; |
1911 | status = mos7840_calc_baud_rate_divisor(baudRate, &divisor, | 1846 | status = mos7840_calc_baud_rate_divisor(port, baudRate, &divisor, |
1912 | &clk_sel_val); | 1847 | &clk_sel_val); |
1913 | status = mos7840_get_reg_sync(port, mos7840_port->SpRegOffset, | 1848 | status = mos7840_get_reg_sync(port, mos7840_port->SpRegOffset, |
1914 | &Data); | 1849 | &Data); |
1915 | if (status < 0) { | 1850 | if (status < 0) { |
1916 | dbg("reading spreg failed in set_serial_baud"); | 1851 | dev_dbg(&port->dev, "reading spreg failed in set_serial_baud\n"); |
1917 | return -1; | 1852 | return -1; |
1918 | } | 1853 | } |
1919 | Data = (Data & 0x8f) | clk_sel_val; | 1854 | Data = (Data & 0x8f) | clk_sel_val; |
1920 | status = mos7840_set_reg_sync(port, mos7840_port->SpRegOffset, | 1855 | status = mos7840_set_reg_sync(port, mos7840_port->SpRegOffset, |
1921 | Data); | 1856 | Data); |
1922 | if (status < 0) { | 1857 | if (status < 0) { |
1923 | dbg("Writing spreg failed in set_serial_baud"); | 1858 | dev_dbg(&port->dev, "Writing spreg failed in set_serial_baud\n"); |
1924 | return -1; | 1859 | return -1; |
1925 | } | 1860 | } |
1926 | /* Calculate the Divisor */ | 1861 | /* Calculate the Divisor */ |
@@ -1936,11 +1871,11 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port, | |||
1936 | 1871 | ||
1937 | /* Write the divisor */ | 1872 | /* Write the divisor */ |
1938 | Data = (unsigned char)(divisor & 0xff); | 1873 | Data = (unsigned char)(divisor & 0xff); |
1939 | dbg("set_serial_baud Value to write DLL is %x", Data); | 1874 | dev_dbg(&port->dev, "set_serial_baud Value to write DLL is %x\n", Data); |
1940 | mos7840_set_uart_reg(port, DIVISOR_LATCH_LSB, Data); | 1875 | mos7840_set_uart_reg(port, DIVISOR_LATCH_LSB, Data); |
1941 | 1876 | ||
1942 | Data = (unsigned char)((divisor & 0xff00) >> 8); | 1877 | Data = (unsigned char)((divisor & 0xff00) >> 8); |
1943 | dbg("set_serial_baud Value to write DLM is %x", Data); | 1878 | dev_dbg(&port->dev, "set_serial_baud Value to write DLM is %x\n", Data); |
1944 | mos7840_set_uart_reg(port, DIVISOR_LATCH_MSB, Data); | 1879 | mos7840_set_uart_reg(port, DIVISOR_LATCH_MSB, Data); |
1945 | 1880 | ||
1946 | /* Disable access to divisor latch */ | 1881 | /* Disable access to divisor latch */ |
@@ -1975,24 +1910,18 @@ static void mos7840_change_port_settings(struct tty_struct *tty, | |||
1975 | if (mos7840_port == NULL) | 1910 | if (mos7840_port == NULL) |
1976 | return; | 1911 | return; |
1977 | 1912 | ||
1978 | port = (struct usb_serial_port *)mos7840_port->port; | 1913 | port = mos7840_port->port; |
1979 | 1914 | ||
1980 | if (mos7840_port_paranoia_check(port, __func__)) { | 1915 | if (mos7840_port_paranoia_check(port, __func__)) |
1981 | dbg("%s", "Invalid port"); | ||
1982 | return; | 1916 | return; |
1983 | } | ||
1984 | 1917 | ||
1985 | if (mos7840_serial_paranoia_check(port->serial, __func__)) { | 1918 | if (mos7840_serial_paranoia_check(port->serial, __func__)) |
1986 | dbg("%s", "Invalid Serial"); | ||
1987 | return; | 1919 | return; |
1988 | } | ||
1989 | 1920 | ||
1990 | serial = port->serial; | 1921 | serial = port->serial; |
1991 | 1922 | ||
1992 | dbg("%s - port %d", __func__, mos7840_port->port->number); | ||
1993 | |||
1994 | if (!mos7840_port->open) { | 1923 | if (!mos7840_port->open) { |
1995 | dbg("%s - port not opened", __func__); | 1924 | dev_dbg(&port->dev, "%s - port not opened\n", __func__); |
1996 | return; | 1925 | return; |
1997 | } | 1926 | } |
1998 | 1927 | ||
@@ -2027,14 +1956,14 @@ static void mos7840_change_port_settings(struct tty_struct *tty, | |||
2027 | if (cflag & PARENB) { | 1956 | if (cflag & PARENB) { |
2028 | if (cflag & PARODD) { | 1957 | if (cflag & PARODD) { |
2029 | lParity = LCR_PAR_ODD; | 1958 | lParity = LCR_PAR_ODD; |
2030 | dbg("%s - parity = odd", __func__); | 1959 | dev_dbg(&port->dev, "%s - parity = odd\n", __func__); |
2031 | } else { | 1960 | } else { |
2032 | lParity = LCR_PAR_EVEN; | 1961 | lParity = LCR_PAR_EVEN; |
2033 | dbg("%s - parity = even", __func__); | 1962 | dev_dbg(&port->dev, "%s - parity = even\n", __func__); |
2034 | } | 1963 | } |
2035 | 1964 | ||
2036 | } else { | 1965 | } else { |
2037 | dbg("%s - parity = none", __func__); | 1966 | dev_dbg(&port->dev, "%s - parity = none\n", __func__); |
2038 | } | 1967 | } |
2039 | 1968 | ||
2040 | if (cflag & CMSPAR) | 1969 | if (cflag & CMSPAR) |
@@ -2043,10 +1972,10 @@ static void mos7840_change_port_settings(struct tty_struct *tty, | |||
2043 | /* Change the Stop bit */ | 1972 | /* Change the Stop bit */ |
2044 | if (cflag & CSTOPB) { | 1973 | if (cflag & CSTOPB) { |
2045 | lStop = LCR_STOP_2; | 1974 | lStop = LCR_STOP_2; |
2046 | dbg("%s - stop bits = 2", __func__); | 1975 | dev_dbg(&port->dev, "%s - stop bits = 2\n", __func__); |
2047 | } else { | 1976 | } else { |
2048 | lStop = LCR_STOP_1; | 1977 | lStop = LCR_STOP_1; |
2049 | dbg("%s - stop bits = 1", __func__); | 1978 | dev_dbg(&port->dev, "%s - stop bits = 1\n", __func__); |
2050 | } | 1979 | } |
2051 | 1980 | ||
2052 | /* Update the LCR with the correct value */ | 1981 | /* Update the LCR with the correct value */ |
@@ -2054,8 +1983,8 @@ static void mos7840_change_port_settings(struct tty_struct *tty, | |||
2054 | ~(LCR_BITS_MASK | LCR_STOP_MASK | LCR_PAR_MASK); | 1983 | ~(LCR_BITS_MASK | LCR_STOP_MASK | LCR_PAR_MASK); |
2055 | mos7840_port->shadowLCR |= (lData | lParity | lStop); | 1984 | mos7840_port->shadowLCR |= (lData | lParity | lStop); |
2056 | 1985 | ||
2057 | dbg("mos7840_change_port_settings mos7840_port->shadowLCR is %x", | 1986 | dev_dbg(&port->dev, "%s - mos7840_port->shadowLCR is %x\n", __func__, |
2058 | mos7840_port->shadowLCR); | 1987 | mos7840_port->shadowLCR); |
2059 | /* Disable Interrupts */ | 1988 | /* Disable Interrupts */ |
2060 | Data = 0x00; | 1989 | Data = 0x00; |
2061 | mos7840_set_uart_reg(port, INTERRUPT_ENABLE_REGISTER, Data); | 1990 | mos7840_set_uart_reg(port, INTERRUPT_ENABLE_REGISTER, Data); |
@@ -2096,11 +2025,11 @@ static void mos7840_change_port_settings(struct tty_struct *tty, | |||
2096 | 2025 | ||
2097 | if (!baud) { | 2026 | if (!baud) { |
2098 | /* pick a default, any default... */ | 2027 | /* pick a default, any default... */ |
2099 | dbg("%s", "Picked default baud..."); | 2028 | dev_dbg(&port->dev, "%s", "Picked default baud...\n"); |
2100 | baud = 9600; | 2029 | baud = 9600; |
2101 | } | 2030 | } |
2102 | 2031 | ||
2103 | dbg("%s - baud rate = %d", __func__, baud); | 2032 | dev_dbg(&port->dev, "%s - baud rate = %d\n", __func__, baud); |
2104 | status = mos7840_send_cmd_write_baud_rate(mos7840_port, baud); | 2033 | status = mos7840_send_cmd_write_baud_rate(mos7840_port, baud); |
2105 | 2034 | ||
2106 | /* Enable Interrupts */ | 2035 | /* Enable Interrupts */ |
@@ -2111,15 +2040,15 @@ static void mos7840_change_port_settings(struct tty_struct *tty, | |||
2111 | mos7840_port->read_urb_busy = true; | 2040 | mos7840_port->read_urb_busy = true; |
2112 | status = usb_submit_urb(mos7840_port->read_urb, GFP_ATOMIC); | 2041 | status = usb_submit_urb(mos7840_port->read_urb, GFP_ATOMIC); |
2113 | if (status) { | 2042 | if (status) { |
2114 | dbg("usb_submit_urb(read bulk) failed, status = %d", | 2043 | dev_dbg(&port->dev, "usb_submit_urb(read bulk) failed, status = %d\n", |
2115 | status); | 2044 | status); |
2116 | mos7840_port->read_urb_busy = false; | 2045 | mos7840_port->read_urb_busy = false; |
2117 | } | 2046 | } |
2118 | } | 2047 | } |
2119 | wake_up(&mos7840_port->delta_msr_wait); | 2048 | wake_up(&mos7840_port->delta_msr_wait); |
2120 | mos7840_port->delta_msr_cond = 1; | 2049 | mos7840_port->delta_msr_cond = 1; |
2121 | dbg("mos7840_change_port_settings mos7840_port->shadowLCR is End %x", | 2050 | dev_dbg(&port->dev, "%s - mos7840_port->shadowLCR is End %x\n", __func__, |
2122 | mos7840_port->shadowLCR); | 2051 | mos7840_port->shadowLCR); |
2123 | } | 2052 | } |
2124 | 2053 | ||
2125 | /***************************************************************************** | 2054 | /***************************************************************************** |
@@ -2137,17 +2066,13 @@ static void mos7840_set_termios(struct tty_struct *tty, | |||
2137 | struct usb_serial *serial; | 2066 | struct usb_serial *serial; |
2138 | struct moschip_port *mos7840_port; | 2067 | struct moschip_port *mos7840_port; |
2139 | 2068 | ||
2140 | if (mos7840_port_paranoia_check(port, __func__)) { | 2069 | if (mos7840_port_paranoia_check(port, __func__)) |
2141 | dbg("%s", "Invalid port"); | ||
2142 | return; | 2070 | return; |
2143 | } | ||
2144 | 2071 | ||
2145 | serial = port->serial; | 2072 | serial = port->serial; |
2146 | 2073 | ||
2147 | if (mos7840_serial_paranoia_check(serial, __func__)) { | 2074 | if (mos7840_serial_paranoia_check(serial, __func__)) |
2148 | dbg("%s", "Invalid Serial"); | ||
2149 | return; | 2075 | return; |
2150 | } | ||
2151 | 2076 | ||
2152 | mos7840_port = mos7840_get_port_private(port); | 2077 | mos7840_port = mos7840_get_port_private(port); |
2153 | 2078 | ||
@@ -2155,26 +2080,26 @@ static void mos7840_set_termios(struct tty_struct *tty, | |||
2155 | return; | 2080 | return; |
2156 | 2081 | ||
2157 | if (!mos7840_port->open) { | 2082 | if (!mos7840_port->open) { |
2158 | dbg("%s - port not opened", __func__); | 2083 | dev_dbg(&port->dev, "%s - port not opened\n", __func__); |
2159 | return; | 2084 | return; |
2160 | } | 2085 | } |
2161 | 2086 | ||
2162 | dbg("%s", "setting termios - "); | 2087 | dev_dbg(&port->dev, "%s", "setting termios - \n"); |
2163 | 2088 | ||
2164 | cflag = tty->termios.c_cflag; | 2089 | cflag = tty->termios.c_cflag; |
2165 | 2090 | ||
2166 | dbg("%s - clfag %08x iflag %08x", __func__, | 2091 | dev_dbg(&port->dev, "%s - clfag %08x iflag %08x\n", __func__, |
2167 | tty->termios.c_cflag, RELEVANT_IFLAG(tty->termios.c_iflag)); | 2092 | tty->termios.c_cflag, RELEVANT_IFLAG(tty->termios.c_iflag)); |
2168 | dbg("%s - old clfag %08x old iflag %08x", __func__, | 2093 | dev_dbg(&port->dev, "%s - old clfag %08x old iflag %08x\n", __func__, |
2169 | old_termios->c_cflag, RELEVANT_IFLAG(old_termios->c_iflag)); | 2094 | old_termios->c_cflag, RELEVANT_IFLAG(old_termios->c_iflag)); |
2170 | dbg("%s - port %d", __func__, port->number); | 2095 | dev_dbg(&port->dev, "%s - port %d\n", __func__, port->number); |
2171 | 2096 | ||
2172 | /* change the port settings to the new ones specified */ | 2097 | /* change the port settings to the new ones specified */ |
2173 | 2098 | ||
2174 | mos7840_change_port_settings(tty, mos7840_port, old_termios); | 2099 | mos7840_change_port_settings(tty, mos7840_port, old_termios); |
2175 | 2100 | ||
2176 | if (!mos7840_port->read_urb) { | 2101 | if (!mos7840_port->read_urb) { |
2177 | dbg("%s", "URB KILLED !!!!!"); | 2102 | dev_dbg(&port->dev, "%s", "URB KILLED !!!!!\n"); |
2178 | return; | 2103 | return; |
2179 | } | 2104 | } |
2180 | 2105 | ||
@@ -2182,7 +2107,7 @@ static void mos7840_set_termios(struct tty_struct *tty, | |||
2182 | mos7840_port->read_urb_busy = true; | 2107 | mos7840_port->read_urb_busy = true; |
2183 | status = usb_submit_urb(mos7840_port->read_urb, GFP_ATOMIC); | 2108 | status = usb_submit_urb(mos7840_port->read_urb, GFP_ATOMIC); |
2184 | if (status) { | 2109 | if (status) { |
2185 | dbg("usb_submit_urb(read bulk) failed, status = %d", | 2110 | dev_dbg(&port->dev, "usb_submit_urb(read bulk) failed, status = %d\n", |
2186 | status); | 2111 | status); |
2187 | mos7840_port->read_urb_busy = false; | 2112 | mos7840_port->read_urb_busy = false; |
2188 | } | 2113 | } |
@@ -2207,10 +2132,8 @@ static int mos7840_get_lsr_info(struct tty_struct *tty, | |||
2207 | unsigned int result = 0; | 2132 | unsigned int result = 0; |
2208 | 2133 | ||
2209 | count = mos7840_chars_in_buffer(tty); | 2134 | count = mos7840_chars_in_buffer(tty); |
2210 | if (count == 0) { | 2135 | if (count == 0) |
2211 | dbg("%s -- Empty", __func__); | ||
2212 | result = TIOCSER_TEMT; | 2136 | result = TIOCSER_TEMT; |
2213 | } | ||
2214 | 2137 | ||
2215 | if (copy_to_user(value, &result, sizeof(int))) | 2138 | if (copy_to_user(value, &result, sizeof(int))) |
2216 | return -EFAULT; | 2139 | return -EFAULT; |
@@ -2273,8 +2196,8 @@ static int mos7840_get_icount(struct tty_struct *tty, | |||
2273 | icount->brk = cnow.brk; | 2196 | icount->brk = cnow.brk; |
2274 | icount->buf_overrun = cnow.buf_overrun; | 2197 | icount->buf_overrun = cnow.buf_overrun; |
2275 | 2198 | ||
2276 | dbg("%s (%d) TIOCGICOUNT RX=%d, TX=%d", __func__, | 2199 | dev_dbg(&port->dev, "%s TIOCGICOUNT RX=%d, TX=%d\n", __func__, |
2277 | port->number, icount->rx, icount->tx); | 2200 | icount->rx, icount->tx); |
2278 | return 0; | 2201 | return 0; |
2279 | } | 2202 | } |
2280 | 2203 | ||
@@ -2293,35 +2216,33 @@ static int mos7840_ioctl(struct tty_struct *tty, | |||
2293 | struct async_icount cnow; | 2216 | struct async_icount cnow; |
2294 | struct async_icount cprev; | 2217 | struct async_icount cprev; |
2295 | 2218 | ||
2296 | if (mos7840_port_paranoia_check(port, __func__)) { | 2219 | if (mos7840_port_paranoia_check(port, __func__)) |
2297 | dbg("%s", "Invalid port"); | ||
2298 | return -1; | 2220 | return -1; |
2299 | } | ||
2300 | 2221 | ||
2301 | mos7840_port = mos7840_get_port_private(port); | 2222 | mos7840_port = mos7840_get_port_private(port); |
2302 | 2223 | ||
2303 | if (mos7840_port == NULL) | 2224 | if (mos7840_port == NULL) |
2304 | return -1; | 2225 | return -1; |
2305 | 2226 | ||
2306 | dbg("%s - port %d, cmd = 0x%x", __func__, port->number, cmd); | 2227 | dev_dbg(&port->dev, "%s - cmd = 0x%x\n", __func__, cmd); |
2307 | 2228 | ||
2308 | switch (cmd) { | 2229 | switch (cmd) { |
2309 | /* return number of bytes available */ | 2230 | /* return number of bytes available */ |
2310 | 2231 | ||
2311 | case TIOCSERGETLSR: | 2232 | case TIOCSERGETLSR: |
2312 | dbg("%s (%d) TIOCSERGETLSR", __func__, port->number); | 2233 | dev_dbg(&port->dev, "%s TIOCSERGETLSR\n", __func__); |
2313 | return mos7840_get_lsr_info(tty, argp); | 2234 | return mos7840_get_lsr_info(tty, argp); |
2314 | 2235 | ||
2315 | case TIOCGSERIAL: | 2236 | case TIOCGSERIAL: |
2316 | dbg("%s (%d) TIOCGSERIAL", __func__, port->number); | 2237 | dev_dbg(&port->dev, "%s TIOCGSERIAL\n", __func__); |
2317 | return mos7840_get_serial_info(mos7840_port, argp); | 2238 | return mos7840_get_serial_info(mos7840_port, argp); |
2318 | 2239 | ||
2319 | case TIOCSSERIAL: | 2240 | case TIOCSSERIAL: |
2320 | dbg("%s (%d) TIOCSSERIAL", __func__, port->number); | 2241 | dev_dbg(&port->dev, "%s TIOCSSERIAL\n", __func__); |
2321 | break; | 2242 | break; |
2322 | 2243 | ||
2323 | case TIOCMIWAIT: | 2244 | case TIOCMIWAIT: |
2324 | dbg("%s (%d) TIOCMIWAIT", __func__, port->number); | 2245 | dev_dbg(&port->dev, "%s TIOCMIWAIT\n", __func__); |
2325 | cprev = mos7840_port->icount; | 2246 | cprev = mos7840_port->icount; |
2326 | while (1) { | 2247 | while (1) { |
2327 | /* interruptible_sleep_on(&mos7840_port->delta_msr_wait); */ | 2248 | /* interruptible_sleep_on(&mos7840_port->delta_msr_wait); */ |
@@ -2437,11 +2358,6 @@ static int mos7840_startup(struct usb_serial *serial) | |||
2437 | int i, status; | 2358 | int i, status; |
2438 | __u16 Data; | 2359 | __u16 Data; |
2439 | 2360 | ||
2440 | if (!serial) { | ||
2441 | dbg("%s", "Invalid Handler"); | ||
2442 | return -1; | ||
2443 | } | ||
2444 | |||
2445 | dev = serial->dev; | 2361 | dev = serial->dev; |
2446 | 2362 | ||
2447 | /* we set up the pointers to the endpoints in the mos7840_open * | 2363 | /* we set up the pointers to the endpoints in the mos7840_open * |
@@ -2449,7 +2365,7 @@ static int mos7840_startup(struct usb_serial *serial) | |||
2449 | 2365 | ||
2450 | /* set up port private structures */ | 2366 | /* set up port private structures */ |
2451 | for (i = 0; i < serial->num_ports; ++i) { | 2367 | for (i = 0; i < serial->num_ports; ++i) { |
2452 | dbg ("mos7840_startup: configuring port %d............", i); | 2368 | dev_dbg(&dev->dev, "mos7840_startup: configuring port %d............\n", i); |
2453 | mos7840_port = kzalloc(sizeof(struct moschip_port), GFP_KERNEL); | 2369 | mos7840_port = kzalloc(sizeof(struct moschip_port), GFP_KERNEL); |
2454 | if (mos7840_port == NULL) { | 2370 | if (mos7840_port == NULL) { |
2455 | dev_err(&dev->dev, "%s - Out of memory\n", __func__); | 2371 | dev_err(&dev->dev, "%s - Out of memory\n", __func__); |
@@ -2470,10 +2386,10 @@ static int mos7840_startup(struct usb_serial *serial) | |||
2470 | * usb-serial.c:get_free_serial() and cannot therefore be used | 2386 | * usb-serial.c:get_free_serial() and cannot therefore be used |
2471 | * to index device instances */ | 2387 | * to index device instances */ |
2472 | mos7840_port->port_num = i + 1; | 2388 | mos7840_port->port_num = i + 1; |
2473 | dbg ("serial->port[i]->number = %d", serial->port[i]->number); | 2389 | dev_dbg(&dev->dev, "serial->port[i]->number = %d\n", serial->port[i]->number); |
2474 | dbg ("serial->port[i]->serial->minor = %d", serial->port[i]->serial->minor); | 2390 | dev_dbg(&dev->dev, "serial->port[i]->serial->minor = %d\n", serial->port[i]->serial->minor); |
2475 | dbg ("mos7840_port->port_num = %d", mos7840_port->port_num); | 2391 | dev_dbg(&dev->dev, "mos7840_port->port_num = %d\n", mos7840_port->port_num); |
2476 | dbg ("serial->minor = %d", serial->minor); | 2392 | dev_dbg(&dev->dev, "serial->minor = %d\n", serial->minor); |
2477 | 2393 | ||
2478 | if (mos7840_port->port_num == 1) { | 2394 | if (mos7840_port->port_num == 1) { |
2479 | mos7840_port->SpRegOffset = 0x0; | 2395 | mos7840_port->SpRegOffset = 0x0; |
@@ -2500,18 +2416,17 @@ static int mos7840_startup(struct usb_serial *serial) | |||
2500 | mos7840_port->ControlRegOffset = 0xd; | 2416 | mos7840_port->ControlRegOffset = 0xd; |
2501 | mos7840_port->DcrRegOffset = 0x1c; | 2417 | mos7840_port->DcrRegOffset = 0x1c; |
2502 | } | 2418 | } |
2503 | mos7840_dump_serial_port(mos7840_port); | 2419 | mos7840_dump_serial_port(serial->port[i], mos7840_port); |
2504 | mos7840_set_port_private(serial->port[i], mos7840_port); | 2420 | mos7840_set_port_private(serial->port[i], mos7840_port); |
2505 | 2421 | ||
2506 | /* enable rx_disable bit in control register */ | 2422 | /* enable rx_disable bit in control register */ |
2507 | status = mos7840_get_reg_sync(serial->port[i], | 2423 | status = mos7840_get_reg_sync(serial->port[i], |
2508 | mos7840_port->ControlRegOffset, &Data); | 2424 | mos7840_port->ControlRegOffset, &Data); |
2509 | if (status < 0) { | 2425 | if (status < 0) { |
2510 | dbg("Reading ControlReg failed status-0x%x", status); | 2426 | dev_dbg(&dev->dev, "Reading ControlReg failed status-0x%x\n", status); |
2511 | break; | 2427 | break; |
2512 | } else | 2428 | } else |
2513 | dbg("ControlReg Reading success val is %x, status%d", | 2429 | dev_dbg(&dev->dev, "ControlReg Reading success val is %x, status%d\n", Data, status); |
2514 | Data, status); | ||
2515 | Data |= 0x08; /* setting driver done bit */ | 2430 | Data |= 0x08; /* setting driver done bit */ |
2516 | Data |= 0x04; /* sp1_bit to have cts change reflect in | 2431 | Data |= 0x04; /* sp1_bit to have cts change reflect in |
2517 | modem status reg */ | 2432 | modem status reg */ |
@@ -2520,11 +2435,10 @@ static int mos7840_startup(struct usb_serial *serial) | |||
2520 | status = mos7840_set_reg_sync(serial->port[i], | 2435 | status = mos7840_set_reg_sync(serial->port[i], |
2521 | mos7840_port->ControlRegOffset, Data); | 2436 | mos7840_port->ControlRegOffset, Data); |
2522 | if (status < 0) { | 2437 | if (status < 0) { |
2523 | dbg("Writing ControlReg failed(rx_disable) status-0x%x", status); | 2438 | dev_dbg(&dev->dev, "Writing ControlReg failed(rx_disable) status-0x%x\n", status); |
2524 | break; | 2439 | break; |
2525 | } else | 2440 | } else |
2526 | dbg("ControlReg Writing success(rx_disable) status%d", | 2441 | dev_dbg(&dev->dev, "ControlReg Writing success(rx_disable) status%d\n", status); |
2527 | status); | ||
2528 | 2442 | ||
2529 | /* Write default values in DCR (i.e 0x01 in DCR0, 0x05 in DCR2 | 2443 | /* Write default values in DCR (i.e 0x01 in DCR0, 0x05 in DCR2 |
2530 | and 0x24 in DCR3 */ | 2444 | and 0x24 in DCR3 */ |
@@ -2532,61 +2446,57 @@ static int mos7840_startup(struct usb_serial *serial) | |||
2532 | status = mos7840_set_reg_sync(serial->port[i], | 2446 | status = mos7840_set_reg_sync(serial->port[i], |
2533 | (__u16) (mos7840_port->DcrRegOffset + 0), Data); | 2447 | (__u16) (mos7840_port->DcrRegOffset + 0), Data); |
2534 | if (status < 0) { | 2448 | if (status < 0) { |
2535 | dbg("Writing DCR0 failed status-0x%x", status); | 2449 | dev_dbg(&dev->dev, "Writing DCR0 failed status-0x%x\n", status); |
2536 | break; | 2450 | break; |
2537 | } else | 2451 | } else |
2538 | dbg("DCR0 Writing success status%d", status); | 2452 | dev_dbg(&dev->dev, "DCR0 Writing success status%d\n", status); |
2539 | 2453 | ||
2540 | Data = 0x05; | 2454 | Data = 0x05; |
2541 | status = mos7840_set_reg_sync(serial->port[i], | 2455 | status = mos7840_set_reg_sync(serial->port[i], |
2542 | (__u16) (mos7840_port->DcrRegOffset + 1), Data); | 2456 | (__u16) (mos7840_port->DcrRegOffset + 1), Data); |
2543 | if (status < 0) { | 2457 | if (status < 0) { |
2544 | dbg("Writing DCR1 failed status-0x%x", status); | 2458 | dev_dbg(&dev->dev, "Writing DCR1 failed status-0x%x\n", status); |
2545 | break; | 2459 | break; |
2546 | } else | 2460 | } else |
2547 | dbg("DCR1 Writing success status%d", status); | 2461 | dev_dbg(&dev->dev, "DCR1 Writing success status%d\n", status); |
2548 | 2462 | ||
2549 | Data = 0x24; | 2463 | Data = 0x24; |
2550 | status = mos7840_set_reg_sync(serial->port[i], | 2464 | status = mos7840_set_reg_sync(serial->port[i], |
2551 | (__u16) (mos7840_port->DcrRegOffset + 2), Data); | 2465 | (__u16) (mos7840_port->DcrRegOffset + 2), Data); |
2552 | if (status < 0) { | 2466 | if (status < 0) { |
2553 | dbg("Writing DCR2 failed status-0x%x", status); | 2467 | dev_dbg(&dev->dev, "Writing DCR2 failed status-0x%x\n", status); |
2554 | break; | 2468 | break; |
2555 | } else | 2469 | } else |
2556 | dbg("DCR2 Writing success status%d", status); | 2470 | dev_dbg(&dev->dev, "DCR2 Writing success status%d\n", status); |
2557 | 2471 | ||
2558 | /* write values in clkstart0x0 and clkmulti 0x20 */ | 2472 | /* write values in clkstart0x0 and clkmulti 0x20 */ |
2559 | Data = 0x0; | 2473 | Data = 0x0; |
2560 | status = mos7840_set_reg_sync(serial->port[i], | 2474 | status = mos7840_set_reg_sync(serial->port[i], |
2561 | CLK_START_VALUE_REGISTER, Data); | 2475 | CLK_START_VALUE_REGISTER, Data); |
2562 | if (status < 0) { | 2476 | if (status < 0) { |
2563 | dbg("Writing CLK_START_VALUE_REGISTER failed status-0x%x", status); | 2477 | dev_dbg(&dev->dev, "Writing CLK_START_VALUE_REGISTER failed status-0x%x\n", status); |
2564 | break; | 2478 | break; |
2565 | } else | 2479 | } else |
2566 | dbg("CLK_START_VALUE_REGISTER Writing success status%d", status); | 2480 | dev_dbg(&dev->dev, "CLK_START_VALUE_REGISTER Writing success status%d\n", status); |
2567 | 2481 | ||
2568 | Data = 0x20; | 2482 | Data = 0x20; |
2569 | status = mos7840_set_reg_sync(serial->port[i], | 2483 | status = mos7840_set_reg_sync(serial->port[i], |
2570 | CLK_MULTI_REGISTER, Data); | 2484 | CLK_MULTI_REGISTER, Data); |
2571 | if (status < 0) { | 2485 | if (status < 0) { |
2572 | dbg("Writing CLK_MULTI_REGISTER failed status-0x%x", | 2486 | dev_dbg(&dev->dev, "Writing CLK_MULTI_REGISTER failed status-0x%x\n", status); |
2573 | status); | ||
2574 | goto error; | 2487 | goto error; |
2575 | } else | 2488 | } else |
2576 | dbg("CLK_MULTI_REGISTER Writing success status%d", | 2489 | dev_dbg(&dev->dev, "CLK_MULTI_REGISTER Writing success status%d\n", status); |
2577 | status); | ||
2578 | 2490 | ||
2579 | /* write value 0x0 to scratchpad register */ | 2491 | /* write value 0x0 to scratchpad register */ |
2580 | Data = 0x00; | 2492 | Data = 0x00; |
2581 | status = mos7840_set_uart_reg(serial->port[i], | 2493 | status = mos7840_set_uart_reg(serial->port[i], |
2582 | SCRATCH_PAD_REGISTER, Data); | 2494 | SCRATCH_PAD_REGISTER, Data); |
2583 | if (status < 0) { | 2495 | if (status < 0) { |
2584 | dbg("Writing SCRATCH_PAD_REGISTER failed status-0x%x", | 2496 | dev_dbg(&dev->dev, "Writing SCRATCH_PAD_REGISTER failed status-0x%x\n", status); |
2585 | status); | ||
2586 | break; | 2497 | break; |
2587 | } else | 2498 | } else |
2588 | dbg("SCRATCH_PAD_REGISTER Writing success status%d", | 2499 | dev_dbg(&dev->dev, "SCRATCH_PAD_REGISTER Writing success status%d\n", status); |
2589 | status); | ||
2590 | 2500 | ||
2591 | /* Zero Length flag register */ | 2501 | /* Zero Length flag register */ |
2592 | if ((mos7840_port->port_num != 1) | 2502 | if ((mos7840_port->port_num != 1) |
@@ -2596,31 +2506,25 @@ static int mos7840_startup(struct usb_serial *serial) | |||
2596 | status = mos7840_set_reg_sync(serial->port[i], | 2506 | status = mos7840_set_reg_sync(serial->port[i], |
2597 | (__u16) (ZLP_REG1 + | 2507 | (__u16) (ZLP_REG1 + |
2598 | ((__u16)mos7840_port->port_num)), Data); | 2508 | ((__u16)mos7840_port->port_num)), Data); |
2599 | dbg("ZLIP offset %x", | 2509 | dev_dbg(&dev->dev, "ZLIP offset %x\n", |
2600 | (__u16) (ZLP_REG1 + | 2510 | (__u16)(ZLP_REG1 + ((__u16) mos7840_port->port_num))); |
2601 | ((__u16) mos7840_port->port_num))); | ||
2602 | if (status < 0) { | 2511 | if (status < 0) { |
2603 | dbg("Writing ZLP_REG%d failed status-0x%x", | 2512 | dev_dbg(&dev->dev, "Writing ZLP_REG%d failed status-0x%x\n", i + 2, status); |
2604 | i + 2, status); | ||
2605 | break; | 2513 | break; |
2606 | } else | 2514 | } else |
2607 | dbg("ZLP_REG%d Writing success status%d", | 2515 | dev_dbg(&dev->dev, "ZLP_REG%d Writing success status%d\n", i + 2, status); |
2608 | i + 2, status); | ||
2609 | } else { | 2516 | } else { |
2610 | Data = 0xff; | 2517 | Data = 0xff; |
2611 | status = mos7840_set_reg_sync(serial->port[i], | 2518 | status = mos7840_set_reg_sync(serial->port[i], |
2612 | (__u16) (ZLP_REG1 + | 2519 | (__u16) (ZLP_REG1 + |
2613 | ((__u16)mos7840_port->port_num) - 0x1), Data); | 2520 | ((__u16)mos7840_port->port_num) - 0x1), Data); |
2614 | dbg("ZLIP offset %x", | 2521 | dev_dbg(&dev->dev, "ZLIP offset %x\n", |
2615 | (__u16) (ZLP_REG1 + | 2522 | (__u16)(ZLP_REG1 + ((__u16) mos7840_port->port_num) - 0x1)); |
2616 | ((__u16) mos7840_port->port_num) - 0x1)); | ||
2617 | if (status < 0) { | 2523 | if (status < 0) { |
2618 | dbg("Writing ZLP_REG%d failed status-0x%x", | 2524 | dev_dbg(&dev->dev, "Writing ZLP_REG%d failed status-0x%x\n", i + 1, status); |
2619 | i + 1, status); | ||
2620 | break; | 2525 | break; |
2621 | } else | 2526 | } else |
2622 | dbg("ZLP_REG%d Writing success status%d", | 2527 | dev_dbg(&dev->dev, "ZLP_REG%d Writing success status%d\n", i + 1, status); |
2623 | i + 1, status); | ||
2624 | 2528 | ||
2625 | } | 2529 | } |
2626 | mos7840_port->control_urb = usb_alloc_urb(0, GFP_KERNEL); | 2530 | mos7840_port->control_urb = usb_alloc_urb(0, GFP_KERNEL); |
@@ -2661,16 +2565,15 @@ static int mos7840_startup(struct usb_serial *serial) | |||
2661 | MODEM_CONTROL_REGISTER, 0x0300); | 2565 | MODEM_CONTROL_REGISTER, 0x0300); |
2662 | } | 2566 | } |
2663 | } | 2567 | } |
2664 | dbg ("mos7840_startup: all ports configured..........."); | ||
2665 | 2568 | ||
2666 | /* Zero Length flag enable */ | 2569 | /* Zero Length flag enable */ |
2667 | Data = 0x0f; | 2570 | Data = 0x0f; |
2668 | status = mos7840_set_reg_sync(serial->port[0], ZLP_REG5, Data); | 2571 | status = mos7840_set_reg_sync(serial->port[0], ZLP_REG5, Data); |
2669 | if (status < 0) { | 2572 | if (status < 0) { |
2670 | dbg("Writing ZLP_REG5 failed status-0x%x", status); | 2573 | dev_dbg(&dev->dev, "Writing ZLP_REG5 failed status-0x%x\n", status); |
2671 | goto error; | 2574 | goto error; |
2672 | } else | 2575 | } else |
2673 | dbg("ZLP_REG5 Writing success status%d", status); | 2576 | dev_dbg(&dev->dev, "ZLP_REG5 Writing success status%d\n", status); |
2674 | 2577 | ||
2675 | /* setting configuration feature to one */ | 2578 | /* setting configuration feature to one */ |
2676 | usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), | 2579 | usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), |
@@ -2700,11 +2603,6 @@ static void mos7840_disconnect(struct usb_serial *serial) | |||
2700 | unsigned long flags; | 2603 | unsigned long flags; |
2701 | struct moschip_port *mos7840_port; | 2604 | struct moschip_port *mos7840_port; |
2702 | 2605 | ||
2703 | if (!serial) { | ||
2704 | dbg("%s", "Invalid Handler"); | ||
2705 | return; | ||
2706 | } | ||
2707 | |||
2708 | /* check for the ports to be closed,close the ports and disconnect */ | 2606 | /* check for the ports to be closed,close the ports and disconnect */ |
2709 | 2607 | ||
2710 | /* free private structure allocated for serial port * | 2608 | /* free private structure allocated for serial port * |
@@ -2712,7 +2610,6 @@ static void mos7840_disconnect(struct usb_serial *serial) | |||
2712 | 2610 | ||
2713 | for (i = 0; i < serial->num_ports; ++i) { | 2611 | for (i = 0; i < serial->num_ports; ++i) { |
2714 | mos7840_port = mos7840_get_port_private(serial->port[i]); | 2612 | mos7840_port = mos7840_get_port_private(serial->port[i]); |
2715 | dbg ("mos7840_port %d = %p", i, mos7840_port); | ||
2716 | if (mos7840_port) { | 2613 | if (mos7840_port) { |
2717 | spin_lock_irqsave(&mos7840_port->pool_lock, flags); | 2614 | spin_lock_irqsave(&mos7840_port->pool_lock, flags); |
2718 | mos7840_port->zombie = 1; | 2615 | mos7840_port->zombie = 1; |
@@ -2732,11 +2629,6 @@ static void mos7840_release(struct usb_serial *serial) | |||
2732 | int i; | 2629 | int i; |
2733 | struct moschip_port *mos7840_port; | 2630 | struct moschip_port *mos7840_port; |
2734 | 2631 | ||
2735 | if (!serial) { | ||
2736 | dbg("%s", "Invalid Handler"); | ||
2737 | return; | ||
2738 | } | ||
2739 | |||
2740 | /* check for the ports to be closed,close the ports and disconnect */ | 2632 | /* check for the ports to be closed,close the ports and disconnect */ |
2741 | 2633 | ||
2742 | /* free private structure allocated for serial port * | 2634 | /* free private structure allocated for serial port * |
@@ -2744,7 +2636,6 @@ static void mos7840_release(struct usb_serial *serial) | |||
2744 | 2636 | ||
2745 | for (i = 0; i < serial->num_ports; ++i) { | 2637 | for (i = 0; i < serial->num_ports; ++i) { |
2746 | mos7840_port = mos7840_get_port_private(serial->port[i]); | 2638 | mos7840_port = mos7840_get_port_private(serial->port[i]); |
2747 | dbg("mos7840_port %d = %p", i, mos7840_port); | ||
2748 | if (mos7840_port) { | 2639 | if (mos7840_port) { |
2749 | if (mos7840_port->has_led) { | 2640 | if (mos7840_port->has_led) { |
2750 | /* Turn off LED */ | 2641 | /* Turn off LED */ |
@@ -2801,6 +2692,3 @@ module_usb_serial_driver(serial_drivers, id_table); | |||
2801 | 2692 | ||
2802 | MODULE_DESCRIPTION(DRIVER_DESC); | 2693 | MODULE_DESCRIPTION(DRIVER_DESC); |
2803 | MODULE_LICENSE("GPL"); | 2694 | MODULE_LICENSE("GPL"); |
2804 | |||
2805 | module_param(debug, bool, S_IRUGO | S_IWUSR); | ||
2806 | MODULE_PARM_DESC(debug, "Debug enabled or not"); | ||
diff --git a/drivers/usb/serial/navman.c b/drivers/usb/serial/navman.c index d95452cc076d..1566f8f500ae 100644 --- a/drivers/usb/serial/navman.c +++ b/drivers/usb/serial/navman.c | |||
@@ -21,8 +21,6 @@ | |||
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 bool debug; | ||
25 | |||
26 | static const struct usb_device_id id_table[] = { | 24 | static const struct usb_device_id id_table[] = { |
27 | { USB_DEVICE(0x0a99, 0x0001) }, /* Talon Technology device */ | 25 | { USB_DEVICE(0x0a99, 0x0001) }, /* Talon Technology device */ |
28 | { USB_DEVICE(0x0df7, 0x0900) }, /* Mobile Action i-gotU */ | 26 | { USB_DEVICE(0x0df7, 0x0900) }, /* Mobile Action i-gotU */ |
@@ -55,8 +53,7 @@ static void navman_read_int_callback(struct urb *urb) | |||
55 | goto exit; | 53 | goto exit; |
56 | } | 54 | } |
57 | 55 | ||
58 | usb_serial_debug_data(debug, &port->dev, __func__, | 56 | usb_serial_debug_data(&port->dev, __func__, urb->actual_length, data); |
59 | urb->actual_length, data); | ||
60 | 57 | ||
61 | tty = tty_port_tty_get(&port->port); | 58 | tty = tty_port_tty_get(&port->port); |
62 | if (tty && urb->actual_length) { | 59 | if (tty && urb->actual_length) { |
@@ -123,6 +120,3 @@ static struct usb_serial_driver * const serial_drivers[] = { | |||
123 | module_usb_serial_driver(serial_drivers, id_table); | 120 | module_usb_serial_driver(serial_drivers, id_table); |
124 | 121 | ||
125 | MODULE_LICENSE("GPL"); | 122 | MODULE_LICENSE("GPL"); |
126 | |||
127 | module_param(debug, bool, S_IRUGO | S_IWUSR); | ||
128 | MODULE_PARM_DESC(debug, "Debug enabled or not"); | ||
diff --git a/drivers/usb/serial/omninet.c b/drivers/usb/serial/omninet.c index 6f3d7051c7f4..6def58b79382 100644 --- a/drivers/usb/serial/omninet.c +++ b/drivers/usb/serial/omninet.c | |||
@@ -23,8 +23,6 @@ | |||
23 | #include <linux/usb.h> | 23 | #include <linux/usb.h> |
24 | #include <linux/usb/serial.h> | 24 | #include <linux/usb/serial.h> |
25 | 25 | ||
26 | static bool debug; | ||
27 | |||
28 | /* | 26 | /* |
29 | * Version Information | 27 | * Version Information |
30 | */ | 28 | */ |
@@ -164,31 +162,21 @@ static void omninet_read_bulk_callback(struct urb *urb) | |||
164 | struct omninet_header *header = (struct omninet_header *) &data[0]; | 162 | struct omninet_header *header = (struct omninet_header *) &data[0]; |
165 | int status = urb->status; | 163 | int status = urb->status; |
166 | int result; | 164 | int result; |
167 | int i; | ||
168 | 165 | ||
169 | if (status) { | 166 | if (status) { |
170 | dbg("%s - nonzero read bulk status received: %d", | 167 | dev_dbg(&port->dev, "%s - nonzero read bulk status received: %d\n", |
171 | __func__, status); | 168 | __func__, status); |
172 | return; | 169 | return; |
173 | } | 170 | } |
174 | 171 | ||
175 | if (debug && header->oh_xxx != 0x30) { | ||
176 | if (urb->actual_length) { | ||
177 | printk(KERN_DEBUG "%s: omninet_read %d: ", | ||
178 | __FILE__, header->oh_len); | ||
179 | for (i = 0; i < (header->oh_len + | ||
180 | OMNINET_HEADERLEN); i++) | ||
181 | printk("%.2x ", data[i]); | ||
182 | printk("\n"); | ||
183 | } | ||
184 | } | ||
185 | |||
186 | if (urb->actual_length && header->oh_len) { | 172 | if (urb->actual_length && header->oh_len) { |
187 | struct tty_struct *tty = tty_port_tty_get(&port->port); | 173 | struct tty_struct *tty = tty_port_tty_get(&port->port); |
188 | tty_insert_flip_string(tty, data + OMNINET_DATAOFFSET, | 174 | if (tty) { |
175 | tty_insert_flip_string(tty, data + OMNINET_DATAOFFSET, | ||
189 | header->oh_len); | 176 | header->oh_len); |
190 | tty_flip_buffer_push(tty); | 177 | tty_flip_buffer_push(tty); |
191 | tty_kref_put(tty); | 178 | tty_kref_put(tty); |
179 | } | ||
192 | } | 180 | } |
193 | 181 | ||
194 | /* Continue trying to always read */ | 182 | /* Continue trying to always read */ |
@@ -212,12 +200,12 @@ static int omninet_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
212 | int result; | 200 | int result; |
213 | 201 | ||
214 | if (count == 0) { | 202 | if (count == 0) { |
215 | dbg("%s - write request of 0 bytes", __func__); | 203 | dev_dbg(&port->dev, "%s - write request of 0 bytes\n", __func__); |
216 | return 0; | 204 | return 0; |
217 | } | 205 | } |
218 | 206 | ||
219 | if (!test_and_clear_bit(0, &port->write_urbs_free)) { | 207 | if (!test_and_clear_bit(0, &port->write_urbs_free)) { |
220 | dbg("%s - already writing", __func__); | 208 | dev_dbg(&port->dev, "%s - already writing\n", __func__); |
221 | return 0; | 209 | return 0; |
222 | } | 210 | } |
223 | 211 | ||
@@ -226,8 +214,8 @@ static int omninet_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
226 | memcpy(wport->write_urb->transfer_buffer + OMNINET_DATAOFFSET, | 214 | memcpy(wport->write_urb->transfer_buffer + OMNINET_DATAOFFSET, |
227 | buf, count); | 215 | buf, count); |
228 | 216 | ||
229 | usb_serial_debug_data(debug, &port->dev, __func__, count, | 217 | usb_serial_debug_data(&port->dev, __func__, count, |
230 | wport->write_urb->transfer_buffer); | 218 | wport->write_urb->transfer_buffer); |
231 | 219 | ||
232 | header->oh_seq = od->od_outseq++; | 220 | header->oh_seq = od->od_outseq++; |
233 | header->oh_len = count; | 221 | header->oh_len = count; |
@@ -261,7 +249,7 @@ static int omninet_write_room(struct tty_struct *tty) | |||
261 | if (test_bit(0, &wport->write_urbs_free)) | 249 | if (test_bit(0, &wport->write_urbs_free)) |
262 | room = wport->bulk_out_size - OMNINET_HEADERLEN; | 250 | room = wport->bulk_out_size - OMNINET_HEADERLEN; |
263 | 251 | ||
264 | dbg("%s - returns %d", __func__, room); | 252 | dev_dbg(&port->dev, "%s - returns %d\n", __func__, room); |
265 | 253 | ||
266 | return room; | 254 | return room; |
267 | } | 255 | } |
@@ -275,8 +263,8 @@ static void omninet_write_bulk_callback(struct urb *urb) | |||
275 | 263 | ||
276 | set_bit(0, &port->write_urbs_free); | 264 | set_bit(0, &port->write_urbs_free); |
277 | if (status) { | 265 | if (status) { |
278 | dbg("%s - nonzero write bulk status received: %d", | 266 | dev_dbg(&port->dev, "%s - nonzero write bulk status received: %d\n", |
279 | __func__, status); | 267 | __func__, status); |
280 | return; | 268 | return; |
281 | } | 269 | } |
282 | 270 | ||
@@ -304,6 +292,3 @@ module_usb_serial_driver(serial_drivers, id_table); | |||
304 | MODULE_AUTHOR(DRIVER_AUTHOR); | 292 | MODULE_AUTHOR(DRIVER_AUTHOR); |
305 | MODULE_DESCRIPTION(DRIVER_DESC); | 293 | MODULE_DESCRIPTION(DRIVER_DESC); |
306 | MODULE_LICENSE("GPL"); | 294 | MODULE_LICENSE("GPL"); |
307 | |||
308 | module_param(debug, bool, S_IRUGO | S_IWUSR); | ||
309 | MODULE_PARM_DESC(debug, "Debug enabled or not"); | ||
diff --git a/drivers/usb/serial/opticon.c b/drivers/usb/serial/opticon.c index 02cb1b7f6559..41b1647306eb 100644 --- a/drivers/usb/serial/opticon.c +++ b/drivers/usb/serial/opticon.c | |||
@@ -32,8 +32,6 @@ | |||
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 bool debug; | ||
36 | |||
37 | static const struct usb_device_id id_table[] = { | 35 | static const struct usb_device_id id_table[] = { |
38 | { USB_DEVICE(0x065a, 0x0009) }, | 36 | { USB_DEVICE(0x065a, 0x0009) }, |
39 | { }, | 37 | { }, |
@@ -78,17 +76,16 @@ static void opticon_read_bulk_callback(struct urb *urb) | |||
78 | case -ENOENT: | 76 | case -ENOENT: |
79 | case -ESHUTDOWN: | 77 | case -ESHUTDOWN: |
80 | /* this urb is terminated, clean up */ | 78 | /* this urb is terminated, clean up */ |
81 | dbg("%s - urb shutting down with status: %d", | 79 | dev_dbg(&priv->udev->dev, "%s - urb shutting down with status: %d\n", |
82 | __func__, status); | 80 | __func__, status); |
83 | return; | 81 | return; |
84 | default: | 82 | default: |
85 | dbg("%s - nonzero urb status received: %d", | 83 | dev_dbg(&priv->udev->dev, "%s - nonzero urb status received: %d\n", |
86 | __func__, status); | 84 | __func__, status); |
87 | goto exit; | 85 | goto exit; |
88 | } | 86 | } |
89 | 87 | ||
90 | usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, | 88 | usb_serial_debug_data(&port->dev, __func__, urb->actual_length, data); |
91 | data); | ||
92 | 89 | ||
93 | if (urb->actual_length > 2) { | 90 | if (urb->actual_length > 2) { |
94 | data_length = urb->actual_length - 2; | 91 | data_length = urb->actual_length - 2; |
@@ -229,8 +226,8 @@ static void opticon_write_control_callback(struct urb *urb) | |||
229 | kfree(urb->setup_packet); | 226 | kfree(urb->setup_packet); |
230 | 227 | ||
231 | if (status) | 228 | if (status) |
232 | dbg("%s - nonzero write bulk status received: %d", | 229 | dev_dbg(&priv->udev->dev, "%s - nonzero write bulk status received: %d\n", |
233 | __func__, status); | 230 | __func__, status); |
234 | 231 | ||
235 | spin_lock_irqsave(&priv->lock, flags); | 232 | spin_lock_irqsave(&priv->lock, flags); |
236 | --priv->outstanding_urbs; | 233 | --priv->outstanding_urbs; |
@@ -253,7 +250,7 @@ static int opticon_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
253 | spin_lock_irqsave(&priv->lock, flags); | 250 | spin_lock_irqsave(&priv->lock, flags); |
254 | if (priv->outstanding_urbs > URB_UPPER_LIMIT) { | 251 | if (priv->outstanding_urbs > URB_UPPER_LIMIT) { |
255 | spin_unlock_irqrestore(&priv->lock, flags); | 252 | spin_unlock_irqrestore(&priv->lock, flags); |
256 | dbg("%s - write limit hit", __func__); | 253 | dev_dbg(&port->dev, "%s - write limit hit\n", __func__); |
257 | return 0; | 254 | return 0; |
258 | } | 255 | } |
259 | priv->outstanding_urbs++; | 256 | priv->outstanding_urbs++; |
@@ -276,7 +273,7 @@ static int opticon_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
276 | 273 | ||
277 | memcpy(buffer, buf, count); | 274 | memcpy(buffer, buf, count); |
278 | 275 | ||
279 | usb_serial_debug_data(debug, &port->dev, __func__, count, buffer); | 276 | usb_serial_debug_data(&port->dev, __func__, count, buffer); |
280 | 277 | ||
281 | /* The conncected devices do not have a bulk write endpoint, | 278 | /* The conncected devices do not have a bulk write endpoint, |
282 | * to transmit data to de barcode device the control endpoint is used */ | 279 | * to transmit data to de barcode device the control endpoint is used */ |
@@ -338,7 +335,7 @@ static int opticon_write_room(struct tty_struct *tty) | |||
338 | spin_lock_irqsave(&priv->lock, flags); | 335 | spin_lock_irqsave(&priv->lock, flags); |
339 | if (priv->outstanding_urbs > URB_UPPER_LIMIT * 2 / 3) { | 336 | if (priv->outstanding_urbs > URB_UPPER_LIMIT * 2 / 3) { |
340 | spin_unlock_irqrestore(&priv->lock, flags); | 337 | spin_unlock_irqrestore(&priv->lock, flags); |
341 | dbg("%s - write limit hit", __func__); | 338 | dev_dbg(&port->dev, "%s - write limit hit\n", __func__); |
342 | return 0; | 339 | return 0; |
343 | } | 340 | } |
344 | spin_unlock_irqrestore(&priv->lock, flags); | 341 | spin_unlock_irqrestore(&priv->lock, flags); |
@@ -394,7 +391,7 @@ static int opticon_tiocmget(struct tty_struct *tty) | |||
394 | result |= TIOCM_CTS; | 391 | result |= TIOCM_CTS; |
395 | spin_unlock_irqrestore(&priv->lock, flags); | 392 | spin_unlock_irqrestore(&priv->lock, flags); |
396 | 393 | ||
397 | dbg("%s - %x", __func__, result); | 394 | dev_dbg(&port->dev, "%s - %x\n", __func__, result); |
398 | return result; | 395 | return result; |
399 | } | 396 | } |
400 | 397 | ||
@@ -466,7 +463,7 @@ static int opticon_ioctl(struct tty_struct *tty, | |||
466 | struct usb_serial_port *port = tty->driver_data; | 463 | struct usb_serial_port *port = tty->driver_data; |
467 | struct opticon_private *priv = usb_get_serial_data(port->serial); | 464 | struct opticon_private *priv = usb_get_serial_data(port->serial); |
468 | 465 | ||
469 | dbg("%s - port %d, cmd = 0x%x", __func__, port->number, cmd); | 466 | dev_dbg(&port->dev, "%s - port %d, cmd = 0x%x\n", __func__, port->number, cmd); |
470 | 467 | ||
471 | switch (cmd) { | 468 | switch (cmd) { |
472 | case TIOCGSERIAL: | 469 | case TIOCGSERIAL: |
@@ -612,6 +609,3 @@ module_usb_serial_driver(serial_drivers, id_table); | |||
612 | 609 | ||
613 | MODULE_DESCRIPTION(DRIVER_DESC); | 610 | MODULE_DESCRIPTION(DRIVER_DESC); |
614 | MODULE_LICENSE("GPL"); | 611 | MODULE_LICENSE("GPL"); |
615 | |||
616 | module_param(debug, bool, S_IRUGO | S_IWUSR); | ||
617 | MODULE_PARM_DESC(debug, "Debug enabled or not"); | ||
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index 5ce88d1bc6f1..30cff03e9f01 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c | |||
@@ -870,7 +870,8 @@ static const struct usb_device_id option_ids[] = { | |||
870 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0153, 0xff, 0xff, 0xff) }, | 870 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0153, 0xff, 0xff, 0xff) }, |
871 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0155, 0xff, 0xff, 0xff) }, | 871 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0155, 0xff, 0xff, 0xff) }, |
872 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0156, 0xff, 0xff, 0xff) }, | 872 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0156, 0xff, 0xff, 0xff) }, |
873 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0157, 0xff, 0xff, 0xff) }, | 873 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0157, 0xff, 0xff, 0xff), |
874 | .driver_info = (kernel_ulong_t)&net_intf5_blacklist }, | ||
874 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0158, 0xff, 0xff, 0xff) }, | 875 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0158, 0xff, 0xff, 0xff) }, |
875 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0159, 0xff, 0xff, 0xff) }, | 876 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0159, 0xff, 0xff, 0xff) }, |
876 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0161, 0xff, 0xff, 0xff) }, | 877 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0161, 0xff, 0xff, 0xff) }, |
@@ -1257,8 +1258,6 @@ static struct usb_serial_driver * const serial_drivers[] = { | |||
1257 | &option_1port_device, NULL | 1258 | &option_1port_device, NULL |
1258 | }; | 1259 | }; |
1259 | 1260 | ||
1260 | static bool debug; | ||
1261 | |||
1262 | struct option_private { | 1261 | struct option_private { |
1263 | u8 bInterfaceNumber; | 1262 | u8 bInterfaceNumber; |
1264 | }; | 1263 | }; |
@@ -1369,18 +1368,19 @@ static void option_instat_callback(struct urb *urb) | |||
1369 | { | 1368 | { |
1370 | int err; | 1369 | int err; |
1371 | int status = urb->status; | 1370 | int status = urb->status; |
1372 | struct usb_serial_port *port = urb->context; | 1371 | struct usb_serial_port *port = urb->context; |
1372 | struct device *dev = &port->dev; | ||
1373 | struct usb_wwan_port_private *portdata = | 1373 | struct usb_wwan_port_private *portdata = |
1374 | usb_get_serial_port_data(port); | 1374 | usb_get_serial_port_data(port); |
1375 | 1375 | ||
1376 | dbg("%s: urb %p port %p has data %p", __func__, urb, port, portdata); | 1376 | dev_dbg(dev, "%s: urb %p port %p has data %p\n", __func__, urb, port, portdata); |
1377 | 1377 | ||
1378 | if (status == 0) { | 1378 | if (status == 0) { |
1379 | struct usb_ctrlrequest *req_pkt = | 1379 | struct usb_ctrlrequest *req_pkt = |
1380 | (struct usb_ctrlrequest *)urb->transfer_buffer; | 1380 | (struct usb_ctrlrequest *)urb->transfer_buffer; |
1381 | 1381 | ||
1382 | if (!req_pkt) { | 1382 | if (!req_pkt) { |
1383 | dbg("%s: NULL req_pkt", __func__); | 1383 | dev_dbg(dev, "%s: NULL req_pkt\n", __func__); |
1384 | return; | 1384 | return; |
1385 | } | 1385 | } |
1386 | if ((req_pkt->bRequestType == 0xA1) && | 1386 | if ((req_pkt->bRequestType == 0xA1) && |
@@ -1390,7 +1390,7 @@ static void option_instat_callback(struct urb *urb) | |||
1390 | urb->transfer_buffer + | 1390 | urb->transfer_buffer + |
1391 | sizeof(struct usb_ctrlrequest)); | 1391 | sizeof(struct usb_ctrlrequest)); |
1392 | 1392 | ||
1393 | dbg("%s: signal x%x", __func__, signals); | 1393 | dev_dbg(dev, "%s: signal x%x\n", __func__, signals); |
1394 | 1394 | ||
1395 | old_dcd_state = portdata->dcd_state; | 1395 | old_dcd_state = portdata->dcd_state; |
1396 | portdata->cts_state = 1; | 1396 | portdata->cts_state = 1; |
@@ -1406,17 +1406,17 @@ static void option_instat_callback(struct urb *urb) | |||
1406 | tty_kref_put(tty); | 1406 | tty_kref_put(tty); |
1407 | } | 1407 | } |
1408 | } else { | 1408 | } else { |
1409 | dbg("%s: type %x req %x", __func__, | 1409 | dev_dbg(dev, "%s: type %x req %x\n", __func__, |
1410 | req_pkt->bRequestType, req_pkt->bRequest); | 1410 | req_pkt->bRequestType, req_pkt->bRequest); |
1411 | } | 1411 | } |
1412 | } else | 1412 | } else |
1413 | dev_err(&port->dev, "%s: error %d\n", __func__, status); | 1413 | dev_err(dev, "%s: error %d\n", __func__, status); |
1414 | 1414 | ||
1415 | /* Resubmit urb so we continue receiving IRQ data */ | 1415 | /* Resubmit urb so we continue receiving IRQ data */ |
1416 | if (status != -ESHUTDOWN && status != -ENOENT) { | 1416 | if (status != -ESHUTDOWN && status != -ENOENT) { |
1417 | err = usb_submit_urb(urb, GFP_ATOMIC); | 1417 | err = usb_submit_urb(urb, GFP_ATOMIC); |
1418 | if (err) | 1418 | if (err) |
1419 | dbg("%s: resubmit intr urb failed. (%d)", | 1419 | dev_dbg(dev, "%s: resubmit intr urb failed. (%d)\n", |
1420 | __func__, err); | 1420 | __func__, err); |
1421 | } | 1421 | } |
1422 | } | 1422 | } |
@@ -1450,6 +1450,3 @@ MODULE_AUTHOR(DRIVER_AUTHOR); | |||
1450 | MODULE_DESCRIPTION(DRIVER_DESC); | 1450 | MODULE_DESCRIPTION(DRIVER_DESC); |
1451 | MODULE_VERSION(DRIVER_VERSION); | 1451 | MODULE_VERSION(DRIVER_VERSION); |
1452 | MODULE_LICENSE("GPL"); | 1452 | MODULE_LICENSE("GPL"); |
1453 | |||
1454 | module_param(debug, bool, S_IRUGO | S_IWUSR); | ||
1455 | MODULE_PARM_DESC(debug, "Debug messages"); | ||
diff --git a/drivers/usb/serial/oti6858.c b/drivers/usb/serial/oti6858.c index 9f555560bfbf..933241f03fd8 100644 --- a/drivers/usb/serial/oti6858.c +++ b/drivers/usb/serial/oti6858.c | |||
@@ -66,8 +66,6 @@ static const struct usb_device_id id_table[] = { | |||
66 | 66 | ||
67 | MODULE_DEVICE_TABLE(usb, id_table); | 67 | MODULE_DEVICE_TABLE(usb, id_table); |
68 | 68 | ||
69 | static bool debug; | ||
70 | |||
71 | /* requests */ | 69 | /* requests */ |
72 | #define OTI6858_REQ_GET_STATUS (USB_DIR_IN | USB_TYPE_VENDOR | 0x00) | 70 | #define OTI6858_REQ_GET_STATUS (USB_DIR_IN | USB_TYPE_VENDOR | 0x00) |
73 | #define OTI6858_REQ_T_GET_STATUS 0x01 | 71 | #define OTI6858_REQ_T_GET_STATUS 0x01 |
@@ -256,11 +254,11 @@ static void setup_line(struct work_struct *work) | |||
256 | priv->setup_done = 1; | 254 | priv->setup_done = 1; |
257 | spin_unlock_irqrestore(&priv->lock, flags); | 255 | spin_unlock_irqrestore(&priv->lock, flags); |
258 | 256 | ||
259 | dbg("%s(): submitting interrupt urb", __func__); | 257 | dev_dbg(&port->dev, "%s(): submitting interrupt urb\n", __func__); |
260 | result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); | 258 | result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); |
261 | if (result != 0) { | 259 | if (result != 0) { |
262 | dev_err(&port->dev, "%s(): usb_submit_urb() failed" | 260 | dev_err(&port->dev, "%s(): usb_submit_urb() failed with error %d\n", |
263 | " with error %d\n", __func__, result); | 261 | __func__, result); |
264 | } | 262 | } |
265 | } | 263 | } |
266 | 264 | ||
@@ -310,11 +308,11 @@ static void send_data(struct work_struct *work) | |||
310 | if (count == 0) { | 308 | if (count == 0) { |
311 | priv->flags.write_urb_in_use = 0; | 309 | priv->flags.write_urb_in_use = 0; |
312 | 310 | ||
313 | dbg("%s(): submitting interrupt urb", __func__); | 311 | dev_dbg(&port->dev, "%s(): submitting interrupt urb\n", __func__); |
314 | result = usb_submit_urb(port->interrupt_in_urb, GFP_NOIO); | 312 | result = usb_submit_urb(port->interrupt_in_urb, GFP_NOIO); |
315 | if (result != 0) { | 313 | if (result != 0) { |
316 | dev_err(&port->dev, "%s(): usb_submit_urb() failed" | 314 | dev_err(&port->dev, "%s(): usb_submit_urb() failed with error %d\n", |
317 | " with error %d\n", __func__, result); | 315 | __func__, result); |
318 | } | 316 | } |
319 | return; | 317 | return; |
320 | } | 318 | } |
@@ -325,8 +323,8 @@ static void send_data(struct work_struct *work) | |||
325 | port->write_urb->transfer_buffer_length = count; | 323 | port->write_urb->transfer_buffer_length = count; |
326 | result = usb_submit_urb(port->write_urb, GFP_NOIO); | 324 | result = usb_submit_urb(port->write_urb, GFP_NOIO); |
327 | if (result != 0) { | 325 | if (result != 0) { |
328 | dev_err_console(port, "%s(): usb_submit_urb() failed" | 326 | dev_err_console(port, "%s(): usb_submit_urb() failed with error %d\n", |
329 | " with error %d\n", __func__, result); | 327 | __func__, result); |
330 | priv->flags.write_urb_in_use = 0; | 328 | priv->flags.write_urb_in_use = 0; |
331 | } | 329 | } |
332 | 330 | ||
@@ -420,10 +418,8 @@ static void oti6858_set_termios(struct tty_struct *tty, | |||
420 | __le16 divisor; | 418 | __le16 divisor; |
421 | int br; | 419 | int br; |
422 | 420 | ||
423 | if (!tty) { | 421 | if (!tty) |
424 | dbg("%s(): no tty structures", __func__); | ||
425 | return; | 422 | return; |
426 | } | ||
427 | 423 | ||
428 | cflag = tty->termios.c_cflag; | 424 | cflag = tty->termios.c_cflag; |
429 | 425 | ||
@@ -560,11 +556,11 @@ static int oti6858_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
560 | spin_unlock_irqrestore(&priv->lock, flags); | 556 | spin_unlock_irqrestore(&priv->lock, flags); |
561 | kfree(buf); | 557 | kfree(buf); |
562 | 558 | ||
563 | dbg("%s(): submitting interrupt urb", __func__); | 559 | dev_dbg(&port->dev, "%s(): submitting interrupt urb\n", __func__); |
564 | result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); | 560 | result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); |
565 | if (result != 0) { | 561 | if (result != 0) { |
566 | dev_err(&port->dev, "%s(): usb_submit_urb() failed" | 562 | dev_err(&port->dev, "%s(): usb_submit_urb() failed with error %d\n", |
567 | " with error %d\n", __func__, result); | 563 | __func__, result); |
568 | oti6858_close(port); | 564 | oti6858_close(port); |
569 | return result; | 565 | return result; |
570 | } | 566 | } |
@@ -586,14 +582,14 @@ static void oti6858_close(struct usb_serial_port *port) | |||
586 | kfifo_reset_out(&port->write_fifo); | 582 | kfifo_reset_out(&port->write_fifo); |
587 | spin_unlock_irqrestore(&port->lock, flags); | 583 | spin_unlock_irqrestore(&port->lock, flags); |
588 | 584 | ||
589 | dbg("%s(): after buf_clear()", __func__); | 585 | dev_dbg(&port->dev, "%s(): after buf_clear()\n", __func__); |
590 | 586 | ||
591 | /* cancel scheduled setup */ | 587 | /* cancel scheduled setup */ |
592 | cancel_delayed_work_sync(&priv->delayed_setup_work); | 588 | cancel_delayed_work_sync(&priv->delayed_setup_work); |
593 | cancel_delayed_work_sync(&priv->delayed_write_work); | 589 | cancel_delayed_work_sync(&priv->delayed_write_work); |
594 | 590 | ||
595 | /* shutdown our urbs */ | 591 | /* shutdown our urbs */ |
596 | dbg("%s(): shutting down urbs", __func__); | 592 | dev_dbg(&port->dev, "%s(): shutting down urbs\n", __func__); |
597 | usb_kill_urb(port->write_urb); | 593 | usb_kill_urb(port->write_urb); |
598 | usb_kill_urb(port->read_urb); | 594 | usb_kill_urb(port->read_urb); |
599 | usb_kill_urb(port->interrupt_in_urb); | 595 | usb_kill_urb(port->interrupt_in_urb); |
@@ -607,8 +603,8 @@ static int oti6858_tiocmset(struct tty_struct *tty, | |||
607 | unsigned long flags; | 603 | unsigned long flags; |
608 | u8 control; | 604 | u8 control; |
609 | 605 | ||
610 | dbg("%s(port = %d, set = 0x%08x, clear = 0x%08x)", | 606 | dev_dbg(&port->dev, "%s(set = 0x%08x, clear = 0x%08x)\n", |
611 | __func__, port->number, set, clear); | 607 | __func__, set, clear); |
612 | 608 | ||
613 | /* FIXME: check if this is correct (active high/low) */ | 609 | /* FIXME: check if this is correct (active high/low) */ |
614 | spin_lock_irqsave(&priv->lock, flags); | 610 | spin_lock_irqsave(&priv->lock, flags); |
@@ -655,7 +651,7 @@ static int oti6858_tiocmget(struct tty_struct *tty) | |||
655 | if ((pin_state & PIN_DCD) != 0) | 651 | if ((pin_state & PIN_DCD) != 0) |
656 | result |= TIOCM_CD; | 652 | result |= TIOCM_CD; |
657 | 653 | ||
658 | dbg("%s() = 0x%08x", __func__, result); | 654 | dev_dbg(&port->dev, "%s() = 0x%08x\n", __func__, result); |
659 | 655 | ||
660 | return result; | 656 | return result; |
661 | } | 657 | } |
@@ -700,15 +696,14 @@ static int oti6858_ioctl(struct tty_struct *tty, | |||
700 | { | 696 | { |
701 | struct usb_serial_port *port = tty->driver_data; | 697 | struct usb_serial_port *port = tty->driver_data; |
702 | 698 | ||
703 | dbg("%s(port = %d, cmd = 0x%04x, arg = 0x%08lx)", | 699 | dev_dbg(&port->dev, "%s(cmd = 0x%04x, arg = 0x%08lx)\n", __func__, cmd, arg); |
704 | __func__, port->number, cmd, arg); | ||
705 | 700 | ||
706 | switch (cmd) { | 701 | switch (cmd) { |
707 | case TIOCMIWAIT: | 702 | case TIOCMIWAIT: |
708 | dbg("%s(): TIOCMIWAIT", __func__); | 703 | dev_dbg(&port->dev, "%s(): TIOCMIWAIT\n", __func__); |
709 | return wait_modem_info(port, arg); | 704 | return wait_modem_info(port, arg); |
710 | default: | 705 | default: |
711 | dbg("%s(): 0x%04x not supported", __func__, cmd); | 706 | dev_dbg(&port->dev, "%s(): 0x%04x not supported\n", __func__, cmd); |
712 | break; | 707 | break; |
713 | } | 708 | } |
714 | return -ENOIOCTLCMD; | 709 | return -ENOIOCTLCMD; |
@@ -738,12 +733,12 @@ static void oti6858_read_int_callback(struct urb *urb) | |||
738 | case -ENOENT: | 733 | case -ENOENT: |
739 | case -ESHUTDOWN: | 734 | case -ESHUTDOWN: |
740 | /* this urb is terminated, clean up */ | 735 | /* this urb is terminated, clean up */ |
741 | dbg("%s(): urb shutting down with status: %d", | 736 | dev_dbg(&urb->dev->dev, "%s(): urb shutting down with status: %d\n", |
742 | __func__, status); | 737 | __func__, status); |
743 | return; | 738 | return; |
744 | default: | 739 | default: |
745 | dbg("%s(): nonzero urb status received: %d", | 740 | dev_dbg(&urb->dev->dev, "%s(): nonzero urb status received: %d\n", |
746 | __func__, status); | 741 | __func__, status); |
747 | break; | 742 | break; |
748 | } | 743 | } |
749 | 744 | ||
@@ -759,8 +754,7 @@ static void oti6858_read_int_callback(struct urb *urb) | |||
759 | priv->transient = 4; | 754 | priv->transient = 4; |
760 | priv->setup_done = 0; | 755 | priv->setup_done = 0; |
761 | resubmit = 0; | 756 | resubmit = 0; |
762 | dbg("%s(): scheduling setup_line()", | 757 | dev_dbg(&port->dev, "%s(): scheduling setup_line()\n", __func__); |
763 | __func__); | ||
764 | schedule_delayed_work(&priv->delayed_setup_work, 0); | 758 | schedule_delayed_work(&priv->delayed_setup_work, 0); |
765 | } | 759 | } |
766 | } | 760 | } |
@@ -774,8 +768,7 @@ static void oti6858_read_int_callback(struct urb *urb) | |||
774 | priv->transient = 4; | 768 | priv->transient = 4; |
775 | priv->setup_done = 0; | 769 | priv->setup_done = 0; |
776 | resubmit = 0; | 770 | resubmit = 0; |
777 | dbg("%s(): scheduling setup_line()", | 771 | dev_dbg(&port->dev, "%s(): scheduling setup_line()\n", __func__); |
778 | __func__); | ||
779 | schedule_delayed_work(&priv->delayed_setup_work, 0); | 772 | schedule_delayed_work(&priv->delayed_setup_work, 0); |
780 | } | 773 | } |
781 | } | 774 | } |
@@ -826,7 +819,7 @@ static void oti6858_read_int_callback(struct urb *urb) | |||
826 | if (resubmit) { | 819 | if (resubmit) { |
827 | int result; | 820 | int result; |
828 | 821 | ||
829 | /* dbg("%s(): submitting interrupt urb", __func__); */ | 822 | /* dev_dbg(&urb->dev->dev, "%s(): submitting interrupt urb\n", __func__); */ |
830 | result = usb_submit_urb(urb, GFP_ATOMIC); | 823 | result = usb_submit_urb(urb, GFP_ATOMIC); |
831 | if (result != 0) { | 824 | if (result != 0) { |
832 | dev_err(&urb->dev->dev, | 825 | dev_err(&urb->dev->dev, |
@@ -851,7 +844,7 @@ static void oti6858_read_bulk_callback(struct urb *urb) | |||
851 | spin_unlock_irqrestore(&priv->lock, flags); | 844 | spin_unlock_irqrestore(&priv->lock, flags); |
852 | 845 | ||
853 | if (status != 0) { | 846 | if (status != 0) { |
854 | dbg("%s(): unable to handle the error, exiting", __func__); | 847 | dev_dbg(&urb->dev->dev, "%s(): unable to handle the error, exiting\n", __func__); |
855 | return; | 848 | return; |
856 | } | 849 | } |
857 | 850 | ||
@@ -885,15 +878,13 @@ static void oti6858_write_bulk_callback(struct urb *urb) | |||
885 | case -ENOENT: | 878 | case -ENOENT: |
886 | case -ESHUTDOWN: | 879 | case -ESHUTDOWN: |
887 | /* this urb is terminated, clean up */ | 880 | /* this urb is terminated, clean up */ |
888 | dbg("%s(): urb shutting down with status: %d", | 881 | dev_dbg(&urb->dev->dev, "%s(): urb shutting down with status: %d\n", __func__, status); |
889 | __func__, status); | ||
890 | priv->flags.write_urb_in_use = 0; | 882 | priv->flags.write_urb_in_use = 0; |
891 | return; | 883 | return; |
892 | default: | 884 | default: |
893 | /* error in the urb, so we have to resubmit it */ | 885 | /* error in the urb, so we have to resubmit it */ |
894 | dbg("%s(): nonzero write bulk status received: %d", | 886 | dev_dbg(&urb->dev->dev, "%s(): nonzero write bulk status received: %d\n", __func__, status); |
895 | __func__, status); | 887 | dev_dbg(&urb->dev->dev, "%s(): overflow in write\n", __func__); |
896 | dbg("%s(): overflow in write", __func__); | ||
897 | 888 | ||
898 | port->write_urb->transfer_buffer_length = 1; | 889 | port->write_urb->transfer_buffer_length = 1; |
899 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); | 890 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); |
@@ -908,7 +899,7 @@ static void oti6858_write_bulk_callback(struct urb *urb) | |||
908 | priv->flags.write_urb_in_use = 0; | 899 | priv->flags.write_urb_in_use = 0; |
909 | 900 | ||
910 | /* schedule the interrupt urb if we are still open */ | 901 | /* schedule the interrupt urb if we are still open */ |
911 | dbg("%s(): submitting interrupt urb", __func__); | 902 | dev_dbg(&port->dev, "%s(): submitting interrupt urb\n", __func__); |
912 | result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); | 903 | result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); |
913 | if (result != 0) { | 904 | if (result != 0) { |
914 | dev_err(&port->dev, "%s(): failed submitting int urb," | 905 | dev_err(&port->dev, "%s(): failed submitting int urb," |
@@ -922,7 +913,3 @@ MODULE_DESCRIPTION(OTI6858_DESCRIPTION); | |||
922 | MODULE_AUTHOR(OTI6858_AUTHOR); | 913 | MODULE_AUTHOR(OTI6858_AUTHOR); |
923 | MODULE_VERSION(OTI6858_VERSION); | 914 | MODULE_VERSION(OTI6858_VERSION); |
924 | MODULE_LICENSE("GPL"); | 915 | MODULE_LICENSE("GPL"); |
925 | |||
926 | module_param(debug, bool, S_IRUGO | S_IWUSR); | ||
927 | MODULE_PARM_DESC(debug, "enable debug output"); | ||
928 | |||
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index 2b9108a8ea64..892ebdc7a364 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c | |||
@@ -36,8 +36,6 @@ | |||
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 bool debug; | ||
40 | |||
41 | static const struct usb_device_id id_table[] = { | 39 | static const struct usb_device_id id_table[] = { |
42 | { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID) }, | 40 | { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID) }, |
43 | { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_RSAQ2) }, | 41 | { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_RSAQ2) }, |
@@ -741,7 +739,7 @@ static void pl2303_read_int_callback(struct urb *urb) | |||
741 | goto exit; | 739 | goto exit; |
742 | } | 740 | } |
743 | 741 | ||
744 | usb_serial_debug_data(debug, &port->dev, __func__, | 742 | usb_serial_debug_data(&port->dev, __func__, |
745 | urb->actual_length, urb->transfer_buffer); | 743 | urb->actual_length, urb->transfer_buffer); |
746 | 744 | ||
747 | pl2303_update_line_status(port, data, actual_length); | 745 | pl2303_update_line_status(port, data, actual_length); |
@@ -839,7 +837,3 @@ module_usb_serial_driver(serial_drivers, id_table); | |||
839 | 837 | ||
840 | MODULE_DESCRIPTION(DRIVER_DESC); | 838 | MODULE_DESCRIPTION(DRIVER_DESC); |
841 | MODULE_LICENSE("GPL"); | 839 | MODULE_LICENSE("GPL"); |
842 | |||
843 | module_param(debug, bool, S_IRUGO | S_IWUSR); | ||
844 | MODULE_PARM_DESC(debug, "Debug enabled or not"); | ||
845 | |||
diff --git a/drivers/usb/serial/qcaux.c b/drivers/usb/serial/qcaux.c index a4edc7ee9c8a..9b1b96f2d095 100644 --- a/drivers/usb/serial/qcaux.c +++ b/drivers/usb/serial/qcaux.c | |||
@@ -36,8 +36,6 @@ | |||
36 | #define UTSTARCOM_PRODUCT_UM175_V1 0x3712 | 36 | #define UTSTARCOM_PRODUCT_UM175_V1 0x3712 |
37 | #define UTSTARCOM_PRODUCT_UM175_V2 0x3714 | 37 | #define UTSTARCOM_PRODUCT_UM175_V2 0x3714 |
38 | #define UTSTARCOM_PRODUCT_UM175_ALLTEL 0x3715 | 38 | #define UTSTARCOM_PRODUCT_UM175_ALLTEL 0x3715 |
39 | #define PANTECH_PRODUCT_UML190_VZW 0x3716 | ||
40 | #define PANTECH_PRODUCT_UML290_VZW 0x3718 | ||
41 | 39 | ||
42 | /* CMOTECH devices */ | 40 | /* CMOTECH devices */ |
43 | #define CMOTECH_VENDOR_ID 0x16d8 | 41 | #define CMOTECH_VENDOR_ID 0x16d8 |
@@ -68,11 +66,9 @@ static struct usb_device_id id_table[] = { | |||
68 | { USB_DEVICE_AND_INTERFACE_INFO(LG_VENDOR_ID, LG_PRODUCT_VX4400_6000, 0xff, 0xff, 0x00) }, | 66 | { USB_DEVICE_AND_INTERFACE_INFO(LG_VENDOR_ID, LG_PRODUCT_VX4400_6000, 0xff, 0xff, 0x00) }, |
69 | { USB_DEVICE_AND_INTERFACE_INFO(SANYO_VENDOR_ID, SANYO_PRODUCT_KATANA_LX, 0xff, 0xff, 0x00) }, | 67 | { USB_DEVICE_AND_INTERFACE_INFO(SANYO_VENDOR_ID, SANYO_PRODUCT_KATANA_LX, 0xff, 0xff, 0x00) }, |
70 | { USB_DEVICE_AND_INTERFACE_INFO(SAMSUNG_VENDOR_ID, SAMSUNG_PRODUCT_U520, 0xff, 0x00, 0x00) }, | 68 | { USB_DEVICE_AND_INTERFACE_INFO(SAMSUNG_VENDOR_ID, SAMSUNG_PRODUCT_U520, 0xff, 0x00, 0x00) }, |
71 | { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, PANTECH_PRODUCT_UML190_VZW, 0xff, 0xff, 0xff) }, | 69 | { USB_VENDOR_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, 0xff, 0xfd, 0xff) }, /* NMEA */ |
72 | { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, PANTECH_PRODUCT_UML190_VZW, 0xff, 0xfe, 0xff) }, | 70 | { USB_VENDOR_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, 0xff, 0xfe, 0xff) }, /* WMC */ |
73 | { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, PANTECH_PRODUCT_UML290_VZW, 0xff, 0xfd, 0xff) }, /* NMEA */ | 71 | { USB_VENDOR_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, 0xff, 0xff, 0xff) }, /* DIAG */ |
74 | { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, PANTECH_PRODUCT_UML290_VZW, 0xff, 0xfe, 0xff) }, /* WMC */ | ||
75 | { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, PANTECH_PRODUCT_UML290_VZW, 0xff, 0xff, 0xff) }, /* DIAG */ | ||
76 | { }, | 72 | { }, |
77 | }; | 73 | }; |
78 | MODULE_DEVICE_TABLE(usb, id_table); | 74 | MODULE_DEVICE_TABLE(usb, id_table); |
diff --git a/drivers/usb/serial/qcserial.c b/drivers/usb/serial/qcserial.c index bfd50779f0c9..c3ddb65c05f2 100644 --- a/drivers/usb/serial/qcserial.c +++ b/drivers/usb/serial/qcserial.c | |||
@@ -22,8 +22,6 @@ | |||
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 bool debug; | ||
26 | |||
27 | #define DEVICE_G1K(v, p) \ | 25 | #define DEVICE_G1K(v, p) \ |
28 | USB_DEVICE(v, p), .driver_info = 1 | 26 | USB_DEVICE(v, p), .driver_info = 1 |
29 | 27 | ||
@@ -305,6 +303,3 @@ module_usb_serial_driver(serial_drivers, id_table); | |||
305 | MODULE_AUTHOR(DRIVER_AUTHOR); | 303 | MODULE_AUTHOR(DRIVER_AUTHOR); |
306 | MODULE_DESCRIPTION(DRIVER_DESC); | 304 | MODULE_DESCRIPTION(DRIVER_DESC); |
307 | MODULE_LICENSE("GPL v2"); | 305 | MODULE_LICENSE("GPL v2"); |
308 | |||
309 | module_param(debug, bool, S_IRUGO | S_IWUSR); | ||
310 | MODULE_PARM_DESC(debug, "Debug enabled or not"); | ||
diff --git a/drivers/usb/serial/quatech2.c b/drivers/usb/serial/quatech2.c index 7df9cdb053ed..2cdfdcc90b37 100644 --- a/drivers/usb/serial/quatech2.c +++ b/drivers/usb/serial/quatech2.c | |||
@@ -27,8 +27,6 @@ | |||
27 | #include <linux/serial_reg.h> | 27 | #include <linux/serial_reg.h> |
28 | #include <linux/uaccess.h> | 28 | #include <linux/uaccess.h> |
29 | 29 | ||
30 | static bool debug; | ||
31 | |||
32 | /* default urb timeout for usb operations */ | 30 | /* default urb timeout for usb operations */ |
33 | #define QT2_USB_TIMEOUT USB_CTRL_SET_TIMEOUT | 31 | #define QT2_USB_TIMEOUT USB_CTRL_SET_TIMEOUT |
34 | 32 | ||
@@ -1089,7 +1087,7 @@ static int qt2_write(struct tty_struct *tty, | |||
1089 | data = write_urb->transfer_buffer; | 1087 | data = write_urb->transfer_buffer; |
1090 | spin_lock_irqsave(&port_priv->urb_lock, flags); | 1088 | spin_lock_irqsave(&port_priv->urb_lock, flags); |
1091 | if (port_priv->urb_in_use == true) { | 1089 | if (port_priv->urb_in_use == true) { |
1092 | printk(KERN_INFO "qt2_write - urb is in use\n"); | 1090 | dev_err(&port->dev, "qt2_write - urb is in use\n"); |
1093 | goto write_out; | 1091 | goto write_out; |
1094 | } | 1092 | } |
1095 | 1093 | ||
@@ -1146,6 +1144,3 @@ module_usb_serial_driver(serial_drivers, id_table); | |||
1146 | 1144 | ||
1147 | MODULE_DESCRIPTION(DRIVER_DESC); | 1145 | MODULE_DESCRIPTION(DRIVER_DESC); |
1148 | MODULE_LICENSE("GPL"); | 1146 | MODULE_LICENSE("GPL"); |
1149 | |||
1150 | module_param(debug, bool, S_IRUGO | S_IWUSR); | ||
1151 | MODULE_PARM_DESC(debug, "Debug enabled or not"); | ||
diff --git a/drivers/usb/serial/safe_serial.c b/drivers/usb/serial/safe_serial.c index 36e9d9fc0618..c949ce6ef0c6 100644 --- a/drivers/usb/serial/safe_serial.c +++ b/drivers/usb/serial/safe_serial.c | |||
@@ -62,6 +62,7 @@ | |||
62 | * | 62 | * |
63 | */ | 63 | */ |
64 | 64 | ||
65 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
65 | 66 | ||
66 | #include <linux/kernel.h> | 67 | #include <linux/kernel.h> |
67 | #include <linux/errno.h> | 68 | #include <linux/errno.h> |
@@ -81,11 +82,9 @@ | |||
81 | #define CONFIG_USB_SERIAL_SAFE_PADDED 0 | 82 | #define CONFIG_USB_SERIAL_SAFE_PADDED 0 |
82 | #endif | 83 | #endif |
83 | 84 | ||
84 | static bool debug; | ||
85 | static bool safe = 1; | 85 | static bool safe = 1; |
86 | static bool padded = CONFIG_USB_SERIAL_SAFE_PADDED; | 86 | static bool padded = CONFIG_USB_SERIAL_SAFE_PADDED; |
87 | 87 | ||
88 | #define DRIVER_VERSION "v0.1" | ||
89 | #define DRIVER_AUTHOR "sl@lineo.com, tbr@lineo.com, Johan Hovold <jhovold@gmail.com>" | 88 | #define DRIVER_AUTHOR "sl@lineo.com, tbr@lineo.com, Johan Hovold <jhovold@gmail.com>" |
90 | #define DRIVER_DESC "USB Safe Encapsulated Serial" | 89 | #define DRIVER_DESC "USB Safe Encapsulated Serial" |
91 | 90 | ||
@@ -100,9 +99,6 @@ MODULE_PARM_DESC(vendor, "User specified USB idVendor (required)"); | |||
100 | module_param(product, ushort, 0); | 99 | module_param(product, ushort, 0); |
101 | MODULE_PARM_DESC(product, "User specified USB idProduct (required)"); | 100 | MODULE_PARM_DESC(product, "User specified USB idProduct (required)"); |
102 | 101 | ||
103 | module_param(debug, bool, S_IRUGO | S_IWUSR); | ||
104 | MODULE_PARM_DESC(debug, "Debug enabled or not"); | ||
105 | |||
106 | module_param(safe, bool, 0); | 102 | module_param(safe, bool, 0); |
107 | MODULE_PARM_DESC(safe, "Turn Safe Encapsulation On/Off"); | 103 | MODULE_PARM_DESC(safe, "Turn Safe Encapsulation On/Off"); |
108 | 104 | ||
@@ -315,13 +311,9 @@ static int __init safe_init(void) | |||
315 | { | 311 | { |
316 | int i; | 312 | int i; |
317 | 313 | ||
318 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" | ||
319 | DRIVER_DESC "\n"); | ||
320 | |||
321 | /* if we have vendor / product parameters patch them into id list */ | 314 | /* if we have vendor / product parameters patch them into id list */ |
322 | if (vendor || product) { | 315 | if (vendor || product) { |
323 | printk(KERN_INFO KBUILD_MODNAME ": vendor: %x product: %x\n", | 316 | pr_info("vendor: %x product: %x\n", vendor, product); |
324 | vendor, product); | ||
325 | 317 | ||
326 | for (i = 0; i < ARRAY_SIZE(id_table); i++) { | 318 | for (i = 0; i < ARRAY_SIZE(id_table); i++) { |
327 | if (!id_table[i].idVendor && !id_table[i].idProduct) { | 319 | if (!id_table[i].idVendor && !id_table[i].idProduct) { |
diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c index b14ebbd73567..01d882cf3775 100644 --- a/drivers/usb/serial/sierra.c +++ b/drivers/usb/serial/sierra.c | |||
@@ -46,7 +46,6 @@ | |||
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 bool debug; | ||
50 | static bool nmea; | 49 | static bool nmea; |
51 | 50 | ||
52 | /* Used in interface blacklisting */ | 51 | /* Used in interface blacklisting */ |
@@ -518,7 +517,7 @@ static int sierra_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
518 | 517 | ||
519 | memcpy(buffer, buf, writesize); | 518 | memcpy(buffer, buf, writesize); |
520 | 519 | ||
521 | usb_serial_debug_data(debug, &port->dev, __func__, writesize, buffer); | 520 | usb_serial_debug_data(&port->dev, __func__, writesize, buffer); |
522 | 521 | ||
523 | usb_fill_bulk_urb(urb, serial->dev, | 522 | usb_fill_bulk_urb(urb, serial->dev, |
524 | usb_sndbulkpipe(serial->dev, | 523 | usb_sndbulkpipe(serial->dev, |
@@ -595,8 +594,8 @@ static void sierra_indat_callback(struct urb *urb) | |||
595 | tty_flip_buffer_push(tty); | 594 | tty_flip_buffer_push(tty); |
596 | 595 | ||
597 | tty_kref_put(tty); | 596 | tty_kref_put(tty); |
598 | usb_serial_debug_data(debug, &port->dev, | 597 | usb_serial_debug_data(&port->dev, __func__, |
599 | __func__, urb->actual_length, data); | 598 | urb->actual_length, data); |
600 | } | 599 | } |
601 | } else { | 600 | } else { |
602 | dev_dbg(&port->dev, "%s: empty read urb" | 601 | dev_dbg(&port->dev, "%s: empty read urb" |
@@ -765,7 +764,6 @@ static struct urb *sierra_setup_urb(struct usb_serial *serial, int endpoint, | |||
765 | usb_sndbulkpipe(serial->dev, endpoint) | dir, | 764 | usb_sndbulkpipe(serial->dev, endpoint) | dir, |
766 | buf, len, callback, ctx); | 765 | buf, len, callback, ctx); |
767 | 766 | ||
768 | /* debug */ | ||
769 | dev_dbg(&serial->dev->dev, "%s %c u : %p d:%p\n", __func__, | 767 | dev_dbg(&serial->dev->dev, "%s %c u : %p d:%p\n", __func__, |
770 | dir == USB_DIR_IN ? 'i' : 'o', urb, buf); | 768 | dir == USB_DIR_IN ? 'i' : 'o', urb, buf); |
771 | } else { | 769 | } else { |
@@ -1082,6 +1080,3 @@ MODULE_LICENSE("GPL"); | |||
1082 | 1080 | ||
1083 | module_param(nmea, bool, S_IRUGO | S_IWUSR); | 1081 | module_param(nmea, bool, S_IRUGO | S_IWUSR); |
1084 | MODULE_PARM_DESC(nmea, "NMEA streaming"); | 1082 | MODULE_PARM_DESC(nmea, "NMEA streaming"); |
1085 | |||
1086 | module_param(debug, bool, S_IRUGO | S_IWUSR); | ||
1087 | MODULE_PARM_DESC(debug, "Debug messages"); | ||
diff --git a/drivers/usb/serial/spcp8x5.c b/drivers/usb/serial/spcp8x5.c index ab68a4d74d61..9716efe92955 100644 --- a/drivers/usb/serial/spcp8x5.c +++ b/drivers/usb/serial/spcp8x5.c | |||
@@ -33,8 +33,6 @@ | |||
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 bool debug; | ||
37 | |||
38 | #define SPCP8x5_007_VID 0x04FC | 36 | #define SPCP8x5_007_VID 0x04FC |
39 | #define SPCP8x5_007_PID 0x0201 | 37 | #define SPCP8x5_007_PID 0x0201 |
40 | #define SPCP8x5_008_VID 0x04fc | 38 | #define SPCP8x5_008_VID 0x04fc |
@@ -665,6 +663,3 @@ module_usb_serial_driver(serial_drivers, id_table); | |||
665 | MODULE_DESCRIPTION(DRIVER_DESC); | 663 | MODULE_DESCRIPTION(DRIVER_DESC); |
666 | MODULE_VERSION(DRIVER_VERSION); | 664 | MODULE_VERSION(DRIVER_VERSION); |
667 | MODULE_LICENSE("GPL"); | 665 | MODULE_LICENSE("GPL"); |
668 | |||
669 | module_param(debug, bool, S_IRUGO | S_IWUSR); | ||
670 | MODULE_PARM_DESC(debug, "Debug enabled or not"); | ||
diff --git a/drivers/usb/serial/ssu100.c b/drivers/usb/serial/ssu100.c index cf2d30cf7588..015810b3785b 100644 --- a/drivers/usb/serial/ssu100.c +++ b/drivers/usb/serial/ssu100.c | |||
@@ -46,8 +46,6 @@ | |||
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 bool debug; | ||
50 | |||
51 | /* Version Information */ | 49 | /* Version Information */ |
52 | #define DRIVER_VERSION "v0.1" | 50 | #define DRIVER_VERSION "v0.1" |
53 | #define DRIVER_DESC "Quatech SSU-100 USB to Serial Driver" | 51 | #define DRIVER_DESC "Quatech SSU-100 USB to Serial Driver" |
@@ -135,7 +133,7 @@ static inline int update_mctrl(struct usb_device *dev, unsigned int set, | |||
135 | int result; | 133 | int result; |
136 | 134 | ||
137 | if (((set | clear) & (TIOCM_DTR | TIOCM_RTS)) == 0) { | 135 | if (((set | clear) & (TIOCM_DTR | TIOCM_RTS)) == 0) { |
138 | dbg("%s - DTR|RTS not being set|cleared", __func__); | 136 | dev_dbg(&dev->dev, "%s - DTR|RTS not being set|cleared\n", __func__); |
139 | return 0; /* no change */ | 137 | return 0; /* no change */ |
140 | } | 138 | } |
141 | 139 | ||
@@ -148,7 +146,7 @@ static inline int update_mctrl(struct usb_device *dev, unsigned int set, | |||
148 | 146 | ||
149 | result = ssu100_setregister(dev, 0, UART_MCR, urb_value); | 147 | result = ssu100_setregister(dev, 0, UART_MCR, urb_value); |
150 | if (result < 0) | 148 | if (result < 0) |
151 | dbg("%s Error from MODEM_CTRL urb", __func__); | 149 | dev_dbg(&dev->dev, "%s Error from MODEM_CTRL urb\n", __func__); |
152 | 150 | ||
153 | return result; | 151 | return result; |
154 | } | 152 | } |
@@ -164,7 +162,7 @@ static int ssu100_initdevice(struct usb_device *dev) | |||
164 | 162 | ||
165 | result = ssu100_getdevice(dev, data); | 163 | result = ssu100_getdevice(dev, data); |
166 | if (result < 0) { | 164 | if (result < 0) { |
167 | dbg("%s - get_device failed %i", __func__, result); | 165 | dev_dbg(&dev->dev, "%s - get_device failed %i\n", __func__, result); |
168 | goto out; | 166 | goto out; |
169 | } | 167 | } |
170 | 168 | ||
@@ -172,25 +170,25 @@ static int ssu100_initdevice(struct usb_device *dev) | |||
172 | 170 | ||
173 | result = ssu100_setdevice(dev, data); | 171 | result = ssu100_setdevice(dev, data); |
174 | if (result < 0) { | 172 | if (result < 0) { |
175 | dbg("%s - setdevice failed %i", __func__, result); | 173 | dev_dbg(&dev->dev, "%s - setdevice failed %i\n", __func__, result); |
176 | goto out; | 174 | goto out; |
177 | } | 175 | } |
178 | 176 | ||
179 | result = ssu100_control_msg(dev, QT_GET_SET_PREBUF_TRIG_LVL, 128, 0); | 177 | result = ssu100_control_msg(dev, QT_GET_SET_PREBUF_TRIG_LVL, 128, 0); |
180 | if (result < 0) { | 178 | if (result < 0) { |
181 | dbg("%s - set prebuffer level failed %i", __func__, result); | 179 | dev_dbg(&dev->dev, "%s - set prebuffer level failed %i\n", __func__, result); |
182 | goto out; | 180 | goto out; |
183 | } | 181 | } |
184 | 182 | ||
185 | result = ssu100_control_msg(dev, QT_SET_ATF, ATC_DISABLED, 0); | 183 | result = ssu100_control_msg(dev, QT_SET_ATF, ATC_DISABLED, 0); |
186 | if (result < 0) { | 184 | if (result < 0) { |
187 | dbg("%s - set ATFprebuffer level failed %i", __func__, result); | 185 | dev_dbg(&dev->dev, "%s - set ATFprebuffer level failed %i\n", __func__, result); |
188 | goto out; | 186 | goto out; |
189 | } | 187 | } |
190 | 188 | ||
191 | result = ssu100_getdevice(dev, data); | 189 | result = ssu100_getdevice(dev, data); |
192 | if (result < 0) { | 190 | if (result < 0) { |
193 | dbg("%s - get_device failed %i", __func__, result); | 191 | dev_dbg(&dev->dev, "%s - get_device failed %i\n", __func__, result); |
194 | goto out; | 192 | goto out; |
195 | } | 193 | } |
196 | 194 | ||
@@ -201,7 +199,7 @@ static int ssu100_initdevice(struct usb_device *dev) | |||
201 | 199 | ||
202 | result = ssu100_setdevice(dev, data); | 200 | result = ssu100_setdevice(dev, data); |
203 | if (result < 0) { | 201 | if (result < 0) { |
204 | dbg("%s - setdevice failed %i", __func__, result); | 202 | dev_dbg(&dev->dev, "%s - setdevice failed %i\n", __func__, result); |
205 | goto out; | 203 | goto out; |
206 | } | 204 | } |
207 | 205 | ||
@@ -249,7 +247,7 @@ static void ssu100_set_termios(struct tty_struct *tty, | |||
249 | if (!baud) | 247 | if (!baud) |
250 | baud = 9600; | 248 | baud = 9600; |
251 | 249 | ||
252 | dbg("%s - got baud = %d\n", __func__, baud); | 250 | dev_dbg(&port->dev, "%s - got baud = %d\n", __func__, baud); |
253 | 251 | ||
254 | 252 | ||
255 | divisor = MAX_BAUD_RATE / baud; | 253 | divisor = MAX_BAUD_RATE / baud; |
@@ -261,7 +259,7 @@ static void ssu100_set_termios(struct tty_struct *tty, | |||
261 | 259 | ||
262 | result = ssu100_control_msg(dev, QT_GET_SET_UART, divisor, urb_value); | 260 | result = ssu100_control_msg(dev, QT_GET_SET_UART, divisor, urb_value); |
263 | if (result < 0) | 261 | if (result < 0) |
264 | dbg("%s - set uart failed", __func__); | 262 | dev_dbg(&port->dev, "%s - set uart failed\n", __func__); |
265 | 263 | ||
266 | if (cflag & CRTSCTS) | 264 | if (cflag & CRTSCTS) |
267 | result = ssu100_control_msg(dev, QT_HW_FLOW_CONTROL_MASK, | 265 | result = ssu100_control_msg(dev, QT_HW_FLOW_CONTROL_MASK, |
@@ -270,7 +268,7 @@ static void ssu100_set_termios(struct tty_struct *tty, | |||
270 | result = ssu100_control_msg(dev, QT_HW_FLOW_CONTROL_MASK, | 268 | result = ssu100_control_msg(dev, QT_HW_FLOW_CONTROL_MASK, |
271 | 0, 0); | 269 | 0, 0); |
272 | if (result < 0) | 270 | if (result < 0) |
273 | dbg("%s - set HW flow control failed", __func__); | 271 | dev_dbg(&port->dev, "%s - set HW flow control failed\n", __func__); |
274 | 272 | ||
275 | if (I_IXOFF(tty) || I_IXON(tty)) { | 273 | if (I_IXOFF(tty) || I_IXON(tty)) { |
276 | u16 x = ((u16)(START_CHAR(tty) << 8) | (u16)(STOP_CHAR(tty))); | 274 | u16 x = ((u16)(START_CHAR(tty) << 8) | (u16)(STOP_CHAR(tty))); |
@@ -282,7 +280,7 @@ static void ssu100_set_termios(struct tty_struct *tty, | |||
282 | 0, 0); | 280 | 0, 0); |
283 | 281 | ||
284 | if (result < 0) | 282 | if (result < 0) |
285 | dbg("%s - set SW flow control failed", __func__); | 283 | dev_dbg(&port->dev, "%s - set SW flow control failed\n", __func__); |
286 | 284 | ||
287 | } | 285 | } |
288 | 286 | ||
@@ -304,7 +302,7 @@ static int ssu100_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
304 | QT_TRANSFER_IN, 0x01, | 302 | QT_TRANSFER_IN, 0x01, |
305 | 0, data, 2, 300); | 303 | 0, data, 2, 300); |
306 | if (result < 0) { | 304 | if (result < 0) { |
307 | dbg("%s - open failed %i", __func__, result); | 305 | dev_dbg(&port->dev, "%s - open failed %i\n", __func__, result); |
308 | kfree(data); | 306 | kfree(data); |
309 | return result; | 307 | return result; |
310 | } | 308 | } |
@@ -319,7 +317,7 @@ static int ssu100_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
319 | /* set to 9600 */ | 317 | /* set to 9600 */ |
320 | result = ssu100_control_msg(dev, QT_GET_SET_UART, 0x30, 0x0300); | 318 | result = ssu100_control_msg(dev, QT_GET_SET_UART, 0x30, 0x0300); |
321 | if (result < 0) | 319 | if (result < 0) |
322 | dbg("%s - set uart failed", __func__); | 320 | dev_dbg(&port->dev, "%s - set uart failed\n", __func__); |
323 | 321 | ||
324 | if (tty) | 322 | if (tty) |
325 | ssu100_set_termios(tty, port, &tty->termios); | 323 | ssu100_set_termios(tty, port, &tty->termios); |
@@ -423,7 +421,7 @@ static int ssu100_ioctl(struct tty_struct *tty, | |||
423 | { | 421 | { |
424 | struct usb_serial_port *port = tty->driver_data; | 422 | struct usb_serial_port *port = tty->driver_data; |
425 | 423 | ||
426 | dbg("%s cmd 0x%04x", __func__, cmd); | 424 | dev_dbg(&port->dev, "%s cmd 0x%04x\n", __func__, cmd); |
427 | 425 | ||
428 | switch (cmd) { | 426 | switch (cmd) { |
429 | case TIOCGSERIAL: | 427 | case TIOCGSERIAL: |
@@ -437,7 +435,7 @@ static int ssu100_ioctl(struct tty_struct *tty, | |||
437 | break; | 435 | break; |
438 | } | 436 | } |
439 | 437 | ||
440 | dbg("%s arg not supported", __func__); | 438 | dev_dbg(&port->dev, "%s arg not supported\n", __func__); |
441 | 439 | ||
442 | return -ENOIOCTLCMD; | 440 | return -ENOIOCTLCMD; |
443 | } | 441 | } |
@@ -668,6 +666,3 @@ module_usb_serial_driver(serial_drivers, id_table); | |||
668 | 666 | ||
669 | MODULE_DESCRIPTION(DRIVER_DESC); | 667 | MODULE_DESCRIPTION(DRIVER_DESC); |
670 | MODULE_LICENSE("GPL"); | 668 | MODULE_LICENSE("GPL"); |
671 | |||
672 | module_param(debug, bool, S_IRUGO | S_IWUSR); | ||
673 | MODULE_PARM_DESC(debug, "Debug enabled or not"); | ||
diff --git a/drivers/usb/serial/symbolserial.c b/drivers/usb/serial/symbolserial.c index e53d2aac35c5..701fffa8431f 100644 --- a/drivers/usb/serial/symbolserial.c +++ b/drivers/usb/serial/symbolserial.c | |||
@@ -20,8 +20,6 @@ | |||
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 bool debug; | ||
24 | |||
25 | static const struct usb_device_id id_table[] = { | 23 | static const struct usb_device_id id_table[] = { |
26 | { USB_DEVICE(0x05e0, 0x0600) }, | 24 | { USB_DEVICE(0x05e0, 0x0600) }, |
27 | { }, | 25 | { }, |
@@ -71,8 +69,7 @@ static void symbol_int_callback(struct urb *urb) | |||
71 | goto exit; | 69 | goto exit; |
72 | } | 70 | } |
73 | 71 | ||
74 | usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, | 72 | usb_serial_debug_data(&port->dev, __func__, urb->actual_length, data); |
75 | data); | ||
76 | 73 | ||
77 | if (urb->actual_length > 1) { | 74 | if (urb->actual_length > 1) { |
78 | data_length = urb->actual_length - 1; | 75 | data_length = urb->actual_length - 1; |
@@ -292,6 +289,3 @@ static struct usb_serial_driver * const serial_drivers[] = { | |||
292 | module_usb_serial_driver(serial_drivers, id_table); | 289 | module_usb_serial_driver(serial_drivers, id_table); |
293 | 290 | ||
294 | MODULE_LICENSE("GPL"); | 291 | MODULE_LICENSE("GPL"); |
295 | |||
296 | module_param(debug, bool, S_IRUGO | S_IWUSR); | ||
297 | MODULE_PARM_DESC(debug, "Debug enabled or not"); | ||
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c index f502a16aac21..6f49392cda5b 100644 --- a/drivers/usb/serial/ti_usb_3410_5052.c +++ b/drivers/usb/serial/ti_usb_3410_5052.c | |||
@@ -40,7 +40,6 @@ | |||
40 | 40 | ||
41 | /* Defines */ | 41 | /* Defines */ |
42 | 42 | ||
43 | #define TI_DRIVER_VERSION "v0.10" | ||
44 | #define TI_DRIVER_AUTHOR "Al Borchers <alborchers@steinerpoint.com>" | 43 | #define TI_DRIVER_AUTHOR "Al Borchers <alborchers@steinerpoint.com>" |
45 | #define TI_DRIVER_DESC "TI USB 3410/5052 Serial Driver" | 44 | #define TI_DRIVER_DESC "TI USB 3410/5052 Serial Driver" |
46 | 45 | ||
@@ -141,8 +140,8 @@ static int ti_command_out_sync(struct ti_device *tdev, __u8 command, | |||
141 | static int ti_command_in_sync(struct ti_device *tdev, __u8 command, | 140 | static int ti_command_in_sync(struct ti_device *tdev, __u8 command, |
142 | __u16 moduleid, __u16 value, __u8 *data, int size); | 141 | __u16 moduleid, __u16 value, __u8 *data, int size); |
143 | 142 | ||
144 | static int ti_write_byte(struct ti_device *tdev, unsigned long addr, | 143 | static int ti_write_byte(struct usb_serial_port *port, struct ti_device *tdev, |
145 | __u8 mask, __u8 byte); | 144 | unsigned long addr, __u8 mask, __u8 byte); |
146 | 145 | ||
147 | static int ti_download_firmware(struct ti_device *tdev); | 146 | static int ti_download_firmware(struct ti_device *tdev); |
148 | 147 | ||
@@ -150,7 +149,6 @@ static int ti_download_firmware(struct ti_device *tdev); | |||
150 | /* Data */ | 149 | /* Data */ |
151 | 150 | ||
152 | /* module parameters */ | 151 | /* module parameters */ |
153 | static bool debug; | ||
154 | static int closing_wait = TI_DEFAULT_CLOSING_WAIT; | 152 | static int closing_wait = TI_DEFAULT_CLOSING_WAIT; |
155 | static ushort vendor_3410[TI_EXTRA_VID_PID_COUNT]; | 153 | static ushort vendor_3410[TI_EXTRA_VID_PID_COUNT]; |
156 | static unsigned int vendor_3410_count; | 154 | static unsigned int vendor_3410_count; |
@@ -277,7 +275,6 @@ static struct usb_serial_driver * const serial_drivers[] = { | |||
277 | 275 | ||
278 | MODULE_AUTHOR(TI_DRIVER_AUTHOR); | 276 | MODULE_AUTHOR(TI_DRIVER_AUTHOR); |
279 | MODULE_DESCRIPTION(TI_DRIVER_DESC); | 277 | MODULE_DESCRIPTION(TI_DRIVER_DESC); |
280 | MODULE_VERSION(TI_DRIVER_VERSION); | ||
281 | MODULE_LICENSE("GPL"); | 278 | MODULE_LICENSE("GPL"); |
282 | 279 | ||
283 | MODULE_FIRMWARE("ti_3410.fw"); | 280 | MODULE_FIRMWARE("ti_3410.fw"); |
@@ -288,9 +285,6 @@ MODULE_FIRMWARE("mts_edge.fw"); | |||
288 | MODULE_FIRMWARE("mts_mt9234mu.fw"); | 285 | MODULE_FIRMWARE("mts_mt9234mu.fw"); |
289 | MODULE_FIRMWARE("mts_mt9234zba.fw"); | 286 | MODULE_FIRMWARE("mts_mt9234zba.fw"); |
290 | 287 | ||
291 | module_param(debug, bool, S_IRUGO | S_IWUSR); | ||
292 | MODULE_PARM_DESC(debug, "Enable debugging, 0=no, 1=yes"); | ||
293 | |||
294 | module_param(closing_wait, int, S_IRUGO | S_IWUSR); | 288 | module_param(closing_wait, int, S_IRUGO | S_IWUSR); |
295 | MODULE_PARM_DESC(closing_wait, | 289 | MODULE_PARM_DESC(closing_wait, |
296 | "Maximum wait for data to drain in close, in .01 secs, default is 4000"); | 290 | "Maximum wait for data to drain in close, in .01 secs, default is 4000"); |
@@ -316,7 +310,6 @@ MODULE_DEVICE_TABLE(usb, ti_id_table_combined); | |||
316 | static int __init ti_init(void) | 310 | static int __init ti_init(void) |
317 | { | 311 | { |
318 | int i, j, c; | 312 | int i, j, c; |
319 | int ret; | ||
320 | 313 | ||
321 | /* insert extra vendor and product ids */ | 314 | /* insert extra vendor and product ids */ |
322 | c = ARRAY_SIZE(ti_id_table_combined) - 2 * TI_EXTRA_VID_PID_COUNT - 1; | 315 | c = ARRAY_SIZE(ti_id_table_combined) - 2 * TI_EXTRA_VID_PID_COUNT - 1; |
@@ -339,11 +332,7 @@ static int __init ti_init(void) | |||
339 | ti_id_table_combined[c].match_flags = USB_DEVICE_ID_MATCH_DEVICE; | 332 | ti_id_table_combined[c].match_flags = USB_DEVICE_ID_MATCH_DEVICE; |
340 | } | 333 | } |
341 | 334 | ||
342 | ret = usb_serial_register_drivers(serial_drivers, KBUILD_MODNAME, ti_id_table_combined); | 335 | return usb_serial_register_drivers(serial_drivers, KBUILD_MODNAME, ti_id_table_combined); |
343 | if (ret == 0) | ||
344 | printk(KERN_INFO KBUILD_MODNAME ": " TI_DRIVER_VERSION ":" | ||
345 | TI_DRIVER_DESC "\n"); | ||
346 | return ret; | ||
347 | } | 336 | } |
348 | 337 | ||
349 | static void __exit ti_exit(void) | 338 | static void __exit ti_exit(void) |
@@ -364,10 +353,11 @@ static int ti_startup(struct usb_serial *serial) | |||
364 | int i; | 353 | int i; |
365 | 354 | ||
366 | 355 | ||
367 | dbg("%s - product 0x%4X, num configurations %d, configuration value %d", | 356 | dev_dbg(&dev->dev, |
368 | __func__, le16_to_cpu(dev->descriptor.idProduct), | 357 | "%s - product 0x%4X, num configurations %d, configuration value %d", |
369 | dev->descriptor.bNumConfigurations, | 358 | __func__, le16_to_cpu(dev->descriptor.idProduct), |
370 | dev->actconfig->desc.bConfigurationValue); | 359 | dev->descriptor.bNumConfigurations, |
360 | dev->actconfig->desc.bConfigurationValue); | ||
371 | 361 | ||
372 | /* create device structure */ | 362 | /* create device structure */ |
373 | tdev = kzalloc(sizeof(struct ti_device), GFP_KERNEL); | 363 | tdev = kzalloc(sizeof(struct ti_device), GFP_KERNEL); |
@@ -382,8 +372,8 @@ static int ti_startup(struct usb_serial *serial) | |||
382 | /* determine device type */ | 372 | /* determine device type */ |
383 | if (usb_match_id(serial->interface, ti_id_table_3410)) | 373 | if (usb_match_id(serial->interface, ti_id_table_3410)) |
384 | tdev->td_is_3410 = 1; | 374 | tdev->td_is_3410 = 1; |
385 | dbg("%s - device type is %s", __func__, | 375 | dev_dbg(&dev->dev, "%s - device type is %s\n", __func__, |
386 | tdev->td_is_3410 ? "3410" : "5052"); | 376 | tdev->td_is_3410 ? "3410" : "5052"); |
387 | 377 | ||
388 | /* if we have only 1 configuration, download firmware */ | 378 | /* if we have only 1 configuration, download firmware */ |
389 | if (dev->descriptor.bNumConfigurations == 1) { | 379 | if (dev->descriptor.bNumConfigurations == 1) { |
@@ -501,20 +491,17 @@ static int ti_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
501 | 491 | ||
502 | /* start interrupt urb the first time a port is opened on this device */ | 492 | /* start interrupt urb the first time a port is opened on this device */ |
503 | if (tdev->td_open_port_count == 0) { | 493 | if (tdev->td_open_port_count == 0) { |
504 | dbg("%s - start interrupt in urb", __func__); | 494 | dev_dbg(&port->dev, "%s - start interrupt in urb\n", __func__); |
505 | urb = tdev->td_serial->port[0]->interrupt_in_urb; | 495 | urb = tdev->td_serial->port[0]->interrupt_in_urb; |
506 | if (!urb) { | 496 | if (!urb) { |
507 | dev_err(&port->dev, "%s - no interrupt urb\n", | 497 | dev_err(&port->dev, "%s - no interrupt urb\n", __func__); |
508 | __func__); | ||
509 | status = -EINVAL; | 498 | status = -EINVAL; |
510 | goto release_lock; | 499 | goto release_lock; |
511 | } | 500 | } |
512 | urb->context = tdev; | 501 | urb->context = tdev; |
513 | status = usb_submit_urb(urb, GFP_KERNEL); | 502 | status = usb_submit_urb(urb, GFP_KERNEL); |
514 | if (status) { | 503 | if (status) { |
515 | dev_err(&port->dev, | 504 | dev_err(&port->dev, "%s - submit interrupt urb failed, %d\n", __func__, status); |
516 | "%s - submit interrupt urb failed, %d\n", | ||
517 | __func__, status); | ||
518 | goto release_lock; | 505 | goto release_lock; |
519 | } | 506 | } |
520 | } | 507 | } |
@@ -522,16 +509,16 @@ static int ti_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
522 | if (tty) | 509 | if (tty) |
523 | ti_set_termios(tty, port, &tty->termios); | 510 | ti_set_termios(tty, port, &tty->termios); |
524 | 511 | ||
525 | dbg("%s - sending TI_OPEN_PORT", __func__); | 512 | dev_dbg(&port->dev, "%s - sending TI_OPEN_PORT\n", __func__); |
526 | status = ti_command_out_sync(tdev, TI_OPEN_PORT, | 513 | status = ti_command_out_sync(tdev, TI_OPEN_PORT, |
527 | (__u8)(TI_UART1_PORT + port_number), open_settings, NULL, 0); | 514 | (__u8)(TI_UART1_PORT + port_number), open_settings, NULL, 0); |
528 | if (status) { | 515 | if (status) { |
529 | dev_err(&port->dev, "%s - cannot send open command, %d\n", | 516 | dev_err(&port->dev, "%s - cannot send open command, %d\n", |
530 | __func__, status); | 517 | __func__, status); |
531 | goto unlink_int_urb; | 518 | goto unlink_int_urb; |
532 | } | 519 | } |
533 | 520 | ||
534 | dbg("%s - sending TI_START_PORT", __func__); | 521 | dev_dbg(&port->dev, "%s - sending TI_START_PORT\n", __func__); |
535 | status = ti_command_out_sync(tdev, TI_START_PORT, | 522 | status = ti_command_out_sync(tdev, TI_START_PORT, |
536 | (__u8)(TI_UART1_PORT + port_number), 0, NULL, 0); | 523 | (__u8)(TI_UART1_PORT + port_number), 0, NULL, 0); |
537 | if (status) { | 524 | if (status) { |
@@ -540,7 +527,7 @@ static int ti_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
540 | goto unlink_int_urb; | 527 | goto unlink_int_urb; |
541 | } | 528 | } |
542 | 529 | ||
543 | dbg("%s - sending TI_PURGE_PORT", __func__); | 530 | dev_dbg(&port->dev, "%s - sending TI_PURGE_PORT\n", __func__); |
544 | status = ti_command_out_sync(tdev, TI_PURGE_PORT, | 531 | status = ti_command_out_sync(tdev, TI_PURGE_PORT, |
545 | (__u8)(TI_UART1_PORT + port_number), TI_PURGE_INPUT, NULL, 0); | 532 | (__u8)(TI_UART1_PORT + port_number), TI_PURGE_INPUT, NULL, 0); |
546 | if (status) { | 533 | if (status) { |
@@ -564,7 +551,7 @@ static int ti_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
564 | if (tty) | 551 | if (tty) |
565 | ti_set_termios(tty, port, &tty->termios); | 552 | ti_set_termios(tty, port, &tty->termios); |
566 | 553 | ||
567 | dbg("%s - sending TI_OPEN_PORT (2)", __func__); | 554 | dev_dbg(&port->dev, "%s - sending TI_OPEN_PORT (2)\n", __func__); |
568 | status = ti_command_out_sync(tdev, TI_OPEN_PORT, | 555 | status = ti_command_out_sync(tdev, TI_OPEN_PORT, |
569 | (__u8)(TI_UART1_PORT + port_number), open_settings, NULL, 0); | 556 | (__u8)(TI_UART1_PORT + port_number), open_settings, NULL, 0); |
570 | if (status) { | 557 | if (status) { |
@@ -573,7 +560,7 @@ static int ti_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
573 | goto unlink_int_urb; | 560 | goto unlink_int_urb; |
574 | } | 561 | } |
575 | 562 | ||
576 | dbg("%s - sending TI_START_PORT (2)", __func__); | 563 | dev_dbg(&port->dev, "%s - sending TI_START_PORT (2)\n", __func__); |
577 | status = ti_command_out_sync(tdev, TI_START_PORT, | 564 | status = ti_command_out_sync(tdev, TI_START_PORT, |
578 | (__u8)(TI_UART1_PORT + port_number), 0, NULL, 0); | 565 | (__u8)(TI_UART1_PORT + port_number), 0, NULL, 0); |
579 | if (status) { | 566 | if (status) { |
@@ -583,7 +570,7 @@ static int ti_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
583 | } | 570 | } |
584 | 571 | ||
585 | /* start read urb */ | 572 | /* start read urb */ |
586 | dbg("%s - start read urb", __func__); | 573 | dev_dbg(&port->dev, "%s - start read urb\n", __func__); |
587 | urb = port->read_urb; | 574 | urb = port->read_urb; |
588 | if (!urb) { | 575 | if (!urb) { |
589 | dev_err(&port->dev, "%s - no read urb\n", __func__); | 576 | dev_err(&port->dev, "%s - no read urb\n", __func__); |
@@ -609,7 +596,7 @@ unlink_int_urb: | |||
609 | usb_kill_urb(port->serial->port[0]->interrupt_in_urb); | 596 | usb_kill_urb(port->serial->port[0]->interrupt_in_urb); |
610 | release_lock: | 597 | release_lock: |
611 | mutex_unlock(&tdev->td_open_close_lock); | 598 | mutex_unlock(&tdev->td_open_close_lock); |
612 | dbg("%s - exit %d", __func__, status); | 599 | dev_dbg(&port->dev, "%s - exit %d\n", __func__, status); |
613 | return status; | 600 | return status; |
614 | } | 601 | } |
615 | 602 | ||
@@ -637,7 +624,7 @@ static void ti_close(struct usb_serial_port *port) | |||
637 | 624 | ||
638 | port_number = port->number - port->serial->minor; | 625 | port_number = port->number - port->serial->minor; |
639 | 626 | ||
640 | dbg("%s - sending TI_CLOSE_PORT", __func__); | 627 | dev_dbg(&port->dev, "%s - sending TI_CLOSE_PORT\n", __func__); |
641 | status = ti_command_out_sync(tdev, TI_CLOSE_PORT, | 628 | status = ti_command_out_sync(tdev, TI_CLOSE_PORT, |
642 | (__u8)(TI_UART1_PORT + port_number), 0, NULL, 0); | 629 | (__u8)(TI_UART1_PORT + port_number), 0, NULL, 0); |
643 | if (status) | 630 | if (status) |
@@ -664,7 +651,7 @@ static int ti_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
664 | struct ti_port *tport = usb_get_serial_port_data(port); | 651 | struct ti_port *tport = usb_get_serial_port_data(port); |
665 | 652 | ||
666 | if (count == 0) { | 653 | if (count == 0) { |
667 | dbg("%s - write request of 0 bytes", __func__); | 654 | dev_dbg(&port->dev, "%s - write request of 0 bytes\n", __func__); |
668 | return 0; | 655 | return 0; |
669 | } | 656 | } |
670 | 657 | ||
@@ -693,7 +680,7 @@ static int ti_write_room(struct tty_struct *tty) | |||
693 | room = kfifo_avail(&tport->write_fifo); | 680 | room = kfifo_avail(&tport->write_fifo); |
694 | spin_unlock_irqrestore(&tport->tp_lock, flags); | 681 | spin_unlock_irqrestore(&tport->tp_lock, flags); |
695 | 682 | ||
696 | dbg("%s - returns %d", __func__, room); | 683 | dev_dbg(&port->dev, "%s - returns %d\n", __func__, room); |
697 | return room; | 684 | return room; |
698 | } | 685 | } |
699 | 686 | ||
@@ -712,7 +699,7 @@ static int ti_chars_in_buffer(struct tty_struct *tty) | |||
712 | chars = kfifo_len(&tport->write_fifo); | 699 | chars = kfifo_len(&tport->write_fifo); |
713 | spin_unlock_irqrestore(&tport->tp_lock, flags); | 700 | spin_unlock_irqrestore(&tport->tp_lock, flags); |
714 | 701 | ||
715 | dbg("%s - returns %d", __func__, chars); | 702 | dev_dbg(&port->dev, "%s - returns %d\n", __func__, chars); |
716 | return chars; | 703 | return chars; |
717 | } | 704 | } |
718 | 705 | ||
@@ -755,8 +742,7 @@ static int ti_get_icount(struct tty_struct *tty, | |||
755 | struct ti_port *tport = usb_get_serial_port_data(port); | 742 | struct ti_port *tport = usb_get_serial_port_data(port); |
756 | struct async_icount cnow = tport->tp_icount; | 743 | struct async_icount cnow = tport->tp_icount; |
757 | 744 | ||
758 | dbg("%s - (%d) TIOCGICOUNT RX=%d, TX=%d", | 745 | dev_dbg(&port->dev, "%s - TIOCGICOUNT RX=%d, TX=%d\n", __func__, |
759 | __func__, port->number, | ||
760 | cnow.rx, cnow.tx); | 746 | cnow.rx, cnow.tx); |
761 | 747 | ||
762 | icount->cts = cnow.cts; | 748 | icount->cts = cnow.cts; |
@@ -782,22 +768,22 @@ static int ti_ioctl(struct tty_struct *tty, | |||
782 | struct async_icount cnow; | 768 | struct async_icount cnow; |
783 | struct async_icount cprev; | 769 | struct async_icount cprev; |
784 | 770 | ||
785 | dbg("%s - port %d, cmd = 0x%04X", __func__, port->number, cmd); | 771 | dev_dbg(&port->dev, "%s - cmd = 0x%04X\n", __func__, cmd); |
786 | 772 | ||
787 | if (tport == NULL) | 773 | if (tport == NULL) |
788 | return -ENODEV; | 774 | return -ENODEV; |
789 | 775 | ||
790 | switch (cmd) { | 776 | switch (cmd) { |
791 | case TIOCGSERIAL: | 777 | case TIOCGSERIAL: |
792 | dbg("%s - (%d) TIOCGSERIAL", __func__, port->number); | 778 | dev_dbg(&port->dev, "%s - TIOCGSERIAL\n", __func__); |
793 | return ti_get_serial_info(tport, | 779 | return ti_get_serial_info(tport, |
794 | (struct serial_struct __user *)arg); | 780 | (struct serial_struct __user *)arg); |
795 | case TIOCSSERIAL: | 781 | case TIOCSSERIAL: |
796 | dbg("%s - (%d) TIOCSSERIAL", __func__, port->number); | 782 | dev_dbg(&port->dev, "%s - TIOCSSERIAL\n", __func__); |
797 | return ti_set_serial_info(tty, tport, | 783 | return ti_set_serial_info(tty, tport, |
798 | (struct serial_struct __user *)arg); | 784 | (struct serial_struct __user *)arg); |
799 | case TIOCMIWAIT: | 785 | case TIOCMIWAIT: |
800 | dbg("%s - (%d) TIOCMIWAIT", __func__, port->number); | 786 | dev_dbg(&port->dev, "%s - TIOCMIWAIT\n", __func__); |
801 | cprev = tport->tp_icount; | 787 | cprev = tport->tp_icount; |
802 | while (1) { | 788 | while (1) { |
803 | interruptible_sleep_on(&tport->tp_msr_wait); | 789 | interruptible_sleep_on(&tport->tp_msr_wait); |
@@ -834,9 +820,9 @@ static void ti_set_termios(struct tty_struct *tty, | |||
834 | cflag = tty->termios.c_cflag; | 820 | cflag = tty->termios.c_cflag; |
835 | iflag = tty->termios.c_iflag; | 821 | iflag = tty->termios.c_iflag; |
836 | 822 | ||
837 | dbg("%s - cflag %08x, iflag %08x", __func__, cflag, iflag); | 823 | dev_dbg(&port->dev, "%s - cflag %08x, iflag %08x\n", __func__, cflag, iflag); |
838 | dbg("%s - old clfag %08x, old iflag %08x", __func__, | 824 | dev_dbg(&port->dev, "%s - old clfag %08x, old iflag %08x\n", __func__, |
839 | old_termios->c_cflag, old_termios->c_iflag); | 825 | old_termios->c_cflag, old_termios->c_iflag); |
840 | 826 | ||
841 | if (tport == NULL) | 827 | if (tport == NULL) |
842 | return; | 828 | return; |
@@ -926,8 +912,11 @@ static void ti_set_termios(struct tty_struct *tty, | |||
926 | if ((cflag & CBAUD) != B0) | 912 | if ((cflag & CBAUD) != B0) |
927 | tty_encode_baud_rate(tty, baud, baud); | 913 | tty_encode_baud_rate(tty, baud, baud); |
928 | 914 | ||
929 | dbg("%s - BaudRate=%d, wBaudRate=%d, wFlags=0x%04X, bDataBits=%d, bParity=%d, bStopBits=%d, cXon=%d, cXoff=%d, bUartMode=%d", | 915 | dev_dbg(&port->dev, |
930 | __func__, baud, config->wBaudRate, config->wFlags, config->bDataBits, config->bParity, config->bStopBits, config->cXon, config->cXoff, config->bUartMode); | 916 | "%s - BaudRate=%d, wBaudRate=%d, wFlags=0x%04X, bDataBits=%d, bParity=%d, bStopBits=%d, cXon=%d, cXoff=%d, bUartMode=%d", |
917 | __func__, baud, config->wBaudRate, config->wFlags, | ||
918 | config->bDataBits, config->bParity, config->bStopBits, | ||
919 | config->cXon, config->cXoff, config->bUartMode); | ||
931 | 920 | ||
932 | cpu_to_be16s(&config->wBaudRate); | 921 | cpu_to_be16s(&config->wBaudRate); |
933 | cpu_to_be16s(&config->wFlags); | 922 | cpu_to_be16s(&config->wFlags); |
@@ -979,7 +968,7 @@ static int ti_tiocmget(struct tty_struct *tty) | |||
979 | | ((msr & TI_MSR_RI) ? TIOCM_RI : 0) | 968 | | ((msr & TI_MSR_RI) ? TIOCM_RI : 0) |
980 | | ((msr & TI_MSR_DSR) ? TIOCM_DSR : 0); | 969 | | ((msr & TI_MSR_DSR) ? TIOCM_DSR : 0); |
981 | 970 | ||
982 | dbg("%s - 0x%04X", __func__, result); | 971 | dev_dbg(&port->dev, "%s - 0x%04X\n", __func__, result); |
983 | 972 | ||
984 | return result; | 973 | return result; |
985 | } | 974 | } |
@@ -1024,19 +1013,19 @@ static void ti_break(struct tty_struct *tty, int break_state) | |||
1024 | struct ti_port *tport = usb_get_serial_port_data(port); | 1013 | struct ti_port *tport = usb_get_serial_port_data(port); |
1025 | int status; | 1014 | int status; |
1026 | 1015 | ||
1027 | dbg("%s - state = %d", __func__, break_state); | 1016 | dev_dbg(&port->dev, "%s - state = %d\n", __func__, break_state); |
1028 | 1017 | ||
1029 | if (tport == NULL) | 1018 | if (tport == NULL) |
1030 | return; | 1019 | return; |
1031 | 1020 | ||
1032 | ti_drain(tport, (tport->tp_closing_wait*HZ)/100, 0); | 1021 | ti_drain(tport, (tport->tp_closing_wait*HZ)/100, 0); |
1033 | 1022 | ||
1034 | status = ti_write_byte(tport->tp_tdev, | 1023 | status = ti_write_byte(port, tport->tp_tdev, |
1035 | tport->tp_uart_base_addr + TI_UART_OFFSET_LCR, | 1024 | tport->tp_uart_base_addr + TI_UART_OFFSET_LCR, |
1036 | TI_LCR_BREAK, break_state == -1 ? TI_LCR_BREAK : 0); | 1025 | TI_LCR_BREAK, break_state == -1 ? TI_LCR_BREAK : 0); |
1037 | 1026 | ||
1038 | if (status) | 1027 | if (status) |
1039 | dbg("%s - error setting break, %d", __func__, status); | 1028 | dev_dbg(&port->dev, "%s - error setting break, %d\n", __func__, status); |
1040 | } | 1029 | } |
1041 | 1030 | ||
1042 | 1031 | ||
@@ -1061,18 +1050,17 @@ static void ti_interrupt_callback(struct urb *urb) | |||
1061 | case -ECONNRESET: | 1050 | case -ECONNRESET: |
1062 | case -ENOENT: | 1051 | case -ENOENT: |
1063 | case -ESHUTDOWN: | 1052 | case -ESHUTDOWN: |
1064 | dbg("%s - urb shutting down, %d", __func__, status); | 1053 | dev_dbg(dev, "%s - urb shutting down, %d\n", __func__, status); |
1065 | tdev->td_urb_error = 1; | 1054 | tdev->td_urb_error = 1; |
1066 | return; | 1055 | return; |
1067 | default: | 1056 | default: |
1068 | dev_err(dev, "%s - nonzero urb status, %d\n", | 1057 | dev_err(dev, "%s - nonzero urb status, %d\n", __func__, status); |
1069 | __func__, status); | ||
1070 | tdev->td_urb_error = 1; | 1058 | tdev->td_urb_error = 1; |
1071 | goto exit; | 1059 | goto exit; |
1072 | } | 1060 | } |
1073 | 1061 | ||
1074 | if (length != 2) { | 1062 | if (length != 2) { |
1075 | dbg("%s - bad packet size, %d", __func__, length); | 1063 | dev_dbg(dev, "%s - bad packet size, %d\n", __func__, length); |
1076 | goto exit; | 1064 | goto exit; |
1077 | } | 1065 | } |
1078 | 1066 | ||
@@ -1084,8 +1072,8 @@ static void ti_interrupt_callback(struct urb *urb) | |||
1084 | port_number = TI_GET_PORT_FROM_CODE(data[0]); | 1072 | port_number = TI_GET_PORT_FROM_CODE(data[0]); |
1085 | function = TI_GET_FUNC_FROM_CODE(data[0]); | 1073 | function = TI_GET_FUNC_FROM_CODE(data[0]); |
1086 | 1074 | ||
1087 | dbg("%s - port_number %d, function %d, data 0x%02X", | 1075 | dev_dbg(dev, "%s - port_number %d, function %d, data 0x%02X\n", |
1088 | __func__, port_number, function, data[1]); | 1076 | __func__, port_number, function, data[1]); |
1089 | 1077 | ||
1090 | if (port_number >= serial->num_ports) { | 1078 | if (port_number >= serial->num_ports) { |
1091 | dev_err(dev, "%s - bad port number, %d\n", | 1079 | dev_err(dev, "%s - bad port number, %d\n", |
@@ -1102,12 +1090,12 @@ static void ti_interrupt_callback(struct urb *urb) | |||
1102 | switch (function) { | 1090 | switch (function) { |
1103 | case TI_CODE_DATA_ERROR: | 1091 | case TI_CODE_DATA_ERROR: |
1104 | dev_err(dev, "%s - DATA ERROR, port %d, data 0x%02X\n", | 1092 | dev_err(dev, "%s - DATA ERROR, port %d, data 0x%02X\n", |
1105 | __func__, port_number, data[1]); | 1093 | __func__, port_number, data[1]); |
1106 | break; | 1094 | break; |
1107 | 1095 | ||
1108 | case TI_CODE_MODEM_STATUS: | 1096 | case TI_CODE_MODEM_STATUS: |
1109 | msr = data[1]; | 1097 | msr = data[1]; |
1110 | dbg("%s - port %d, msr 0x%02X", __func__, port_number, msr); | 1098 | dev_dbg(dev, "%s - port %d, msr 0x%02X\n", __func__, port_number, msr); |
1111 | ti_handle_new_msr(tport, msr); | 1099 | ti_handle_new_msr(tport, msr); |
1112 | break; | 1100 | break; |
1113 | 1101 | ||
@@ -1140,7 +1128,7 @@ static void ti_bulk_in_callback(struct urb *urb) | |||
1140 | case -ECONNRESET: | 1128 | case -ECONNRESET: |
1141 | case -ENOENT: | 1129 | case -ENOENT: |
1142 | case -ESHUTDOWN: | 1130 | case -ESHUTDOWN: |
1143 | dbg("%s - urb shutting down, %d", __func__, status); | 1131 | dev_dbg(dev, "%s - urb shutting down, %d\n", __func__, status); |
1144 | tport->tp_tdev->td_urb_error = 1; | 1132 | tport->tp_tdev->td_urb_error = 1; |
1145 | wake_up_interruptible(&tport->tp_write_wait); | 1133 | wake_up_interruptible(&tport->tp_write_wait); |
1146 | return; | 1134 | return; |
@@ -1162,11 +1150,11 @@ static void ti_bulk_in_callback(struct urb *urb) | |||
1162 | tty = tty_port_tty_get(&port->port); | 1150 | tty = tty_port_tty_get(&port->port); |
1163 | if (tty) { | 1151 | if (tty) { |
1164 | if (urb->actual_length) { | 1152 | if (urb->actual_length) { |
1165 | usb_serial_debug_data(debug, dev, __func__, | 1153 | usb_serial_debug_data(dev, __func__, urb->actual_length, |
1166 | urb->actual_length, urb->transfer_buffer); | 1154 | urb->transfer_buffer); |
1167 | 1155 | ||
1168 | if (!tport->tp_is_open) | 1156 | if (!tport->tp_is_open) |
1169 | dbg("%s - port closed, dropping data", | 1157 | dev_dbg(dev, "%s - port closed, dropping data\n", |
1170 | __func__); | 1158 | __func__); |
1171 | else | 1159 | else |
1172 | ti_recv(&urb->dev->dev, tty, | 1160 | ti_recv(&urb->dev->dev, tty, |
@@ -1208,7 +1196,7 @@ static void ti_bulk_out_callback(struct urb *urb) | |||
1208 | case -ECONNRESET: | 1196 | case -ECONNRESET: |
1209 | case -ENOENT: | 1197 | case -ENOENT: |
1210 | case -ESHUTDOWN: | 1198 | case -ESHUTDOWN: |
1211 | dbg("%s - urb shutting down, %d", __func__, status); | 1199 | dev_dbg(&port->dev, "%s - urb shutting down, %d\n", __func__, status); |
1212 | tport->tp_tdev->td_urb_error = 1; | 1200 | tport->tp_tdev->td_urb_error = 1; |
1213 | wake_up_interruptible(&tport->tp_write_wait); | 1201 | wake_up_interruptible(&tport->tp_write_wait); |
1214 | return; | 1202 | return; |
@@ -1268,8 +1256,8 @@ static void ti_send(struct ti_port *tport) | |||
1268 | 1256 | ||
1269 | spin_unlock_irqrestore(&tport->tp_lock, flags); | 1257 | spin_unlock_irqrestore(&tport->tp_lock, flags); |
1270 | 1258 | ||
1271 | usb_serial_debug_data(debug, &port->dev, __func__, count, | 1259 | usb_serial_debug_data(&port->dev, __func__, count, |
1272 | port->write_urb->transfer_buffer); | 1260 | port->write_urb->transfer_buffer); |
1273 | 1261 | ||
1274 | usb_fill_bulk_urb(port->write_urb, port->serial->dev, | 1262 | usb_fill_bulk_urb(port->write_urb, port->serial->dev, |
1275 | usb_sndbulkpipe(port->serial->dev, | 1263 | usb_sndbulkpipe(port->serial->dev, |
@@ -1307,7 +1295,7 @@ static int ti_set_mcr(struct ti_port *tport, unsigned int mcr) | |||
1307 | unsigned long flags; | 1295 | unsigned long flags; |
1308 | int status; | 1296 | int status; |
1309 | 1297 | ||
1310 | status = ti_write_byte(tport->tp_tdev, | 1298 | status = ti_write_byte(tport->tp_port, tport->tp_tdev, |
1311 | tport->tp_uart_base_addr + TI_UART_OFFSET_MCR, | 1299 | tport->tp_uart_base_addr + TI_UART_OFFSET_MCR, |
1312 | TI_MCR_RTS | TI_MCR_DTR | TI_MCR_LOOP, mcr); | 1300 | TI_MCR_RTS | TI_MCR_DTR | TI_MCR_LOOP, mcr); |
1313 | 1301 | ||
@@ -1344,7 +1332,7 @@ static int ti_get_lsr(struct ti_port *tport) | |||
1344 | goto free_data; | 1332 | goto free_data; |
1345 | } | 1333 | } |
1346 | 1334 | ||
1347 | dbg("%s - lsr 0x%02X", __func__, data->bLSR); | 1335 | dev_dbg(&port->dev, "%s - lsr 0x%02X\n", __func__, data->bLSR); |
1348 | 1336 | ||
1349 | tport->tp_lsr = data->bLSR; | 1337 | tport->tp_lsr = data->bLSR; |
1350 | 1338 | ||
@@ -1401,7 +1389,7 @@ static void ti_handle_new_msr(struct ti_port *tport, __u8 msr) | |||
1401 | struct tty_struct *tty; | 1389 | struct tty_struct *tty; |
1402 | unsigned long flags; | 1390 | unsigned long flags; |
1403 | 1391 | ||
1404 | dbg("%s - msr 0x%02X", __func__, msr); | 1392 | dev_dbg(&tport->tp_port->dev, "%s - msr 0x%02X\n", __func__, msr); |
1405 | 1393 | ||
1406 | if (msr & TI_MSR_DELTA_MASK) { | 1394 | if (msr & TI_MSR_DELTA_MASK) { |
1407 | spin_lock_irqsave(&tport->tp_lock, flags); | 1395 | spin_lock_irqsave(&tport->tp_lock, flags); |
@@ -1560,21 +1548,21 @@ static int ti_command_in_sync(struct ti_device *tdev, __u8 command, | |||
1560 | } | 1548 | } |
1561 | 1549 | ||
1562 | 1550 | ||
1563 | static int ti_write_byte(struct ti_device *tdev, unsigned long addr, | 1551 | static int ti_write_byte(struct usb_serial_port *port, |
1564 | __u8 mask, __u8 byte) | 1552 | struct ti_device *tdev, unsigned long addr, |
1553 | __u8 mask, __u8 byte) | ||
1565 | { | 1554 | { |
1566 | int status; | 1555 | int status; |
1567 | unsigned int size; | 1556 | unsigned int size; |
1568 | struct ti_write_data_bytes *data; | 1557 | struct ti_write_data_bytes *data; |
1569 | struct device *dev = &tdev->td_serial->dev->dev; | ||
1570 | 1558 | ||
1571 | dbg("%s - addr 0x%08lX, mask 0x%02X, byte 0x%02X", | 1559 | dev_dbg(&port->dev, "%s - addr 0x%08lX, mask 0x%02X, byte 0x%02X\n", __func__, |
1572 | __func__, addr, mask, byte); | 1560 | addr, mask, byte); |
1573 | 1561 | ||
1574 | size = sizeof(struct ti_write_data_bytes) + 2; | 1562 | size = sizeof(struct ti_write_data_bytes) + 2; |
1575 | data = kmalloc(size, GFP_KERNEL); | 1563 | data = kmalloc(size, GFP_KERNEL); |
1576 | if (!data) { | 1564 | if (!data) { |
1577 | dev_err(dev, "%s - out of memory\n", __func__); | 1565 | dev_err(&port->dev, "%s - out of memory\n", __func__); |
1578 | return -ENOMEM; | 1566 | return -ENOMEM; |
1579 | } | 1567 | } |
1580 | 1568 | ||
@@ -1590,7 +1578,7 @@ static int ti_write_byte(struct ti_device *tdev, unsigned long addr, | |||
1590 | (__u8 *)data, size); | 1578 | (__u8 *)data, size); |
1591 | 1579 | ||
1592 | if (status < 0) | 1580 | if (status < 0) |
1593 | dev_err(dev, "%s - failed, %d\n", __func__, status); | 1581 | dev_err(&port->dev, "%s - failed, %d\n", __func__, status); |
1594 | 1582 | ||
1595 | kfree(data); | 1583 | kfree(data); |
1596 | 1584 | ||
@@ -1615,7 +1603,7 @@ static int ti_do_download(struct usb_device *dev, int pipe, | |||
1615 | - sizeof(struct ti_firmware_header))); | 1603 | - sizeof(struct ti_firmware_header))); |
1616 | header->bCheckSum = cs; | 1604 | header->bCheckSum = cs; |
1617 | 1605 | ||
1618 | dbg("%s - downloading firmware", __func__); | 1606 | dev_dbg(&dev->dev, "%s - downloading firmware\n", __func__); |
1619 | for (pos = 0; pos < size; pos += done) { | 1607 | for (pos = 0; pos < size; pos += done) { |
1620 | len = min(size - pos, TI_DOWNLOAD_MAX_PACKET_SIZE); | 1608 | len = min(size - pos, TI_DOWNLOAD_MAX_PACKET_SIZE); |
1621 | status = usb_bulk_msg(dev, pipe, buffer + pos, len, | 1609 | status = usb_bulk_msg(dev, pipe, buffer + pos, len, |
@@ -1691,7 +1679,7 @@ static int ti_download_firmware(struct ti_device *tdev) | |||
1691 | status = ti_do_download(dev, pipe, buffer, fw_p->size); | 1679 | status = ti_do_download(dev, pipe, buffer, fw_p->size); |
1692 | kfree(buffer); | 1680 | kfree(buffer); |
1693 | } else { | 1681 | } else { |
1694 | dbg("%s ENOMEM\n", __func__); | 1682 | dev_dbg(&dev->dev, "%s ENOMEM\n", __func__); |
1695 | status = -ENOMEM; | 1683 | status = -ENOMEM; |
1696 | } | 1684 | } |
1697 | release_firmware(fw_p); | 1685 | release_firmware(fw_p); |
@@ -1701,7 +1689,7 @@ static int ti_download_firmware(struct ti_device *tdev) | |||
1701 | return status; | 1689 | return status; |
1702 | } | 1690 | } |
1703 | 1691 | ||
1704 | dbg("%s - download successful", __func__); | 1692 | dev_dbg(&dev->dev, "%s - download successful\n", __func__); |
1705 | 1693 | ||
1706 | return 0; | 1694 | return 0; |
1707 | } | 1695 | } |
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index aa4b0d775992..73b8e0569164 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c | |||
@@ -17,6 +17,8 @@ | |||
17 | * | 17 | * |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
21 | |||
20 | #include <linux/kernel.h> | 22 | #include <linux/kernel.h> |
21 | #include <linux/errno.h> | 23 | #include <linux/errno.h> |
22 | #include <linux/init.h> | 24 | #include <linux/init.h> |
@@ -37,10 +39,7 @@ | |||
37 | #include <linux/kfifo.h> | 39 | #include <linux/kfifo.h> |
38 | #include "pl2303.h" | 40 | #include "pl2303.h" |
39 | 41 | ||
40 | /* | 42 | #define DRIVER_AUTHOR "Greg Kroah-Hartman <gregkh@linuxfoundation.org>" |
41 | * Version Information | ||
42 | */ | ||
43 | #define DRIVER_AUTHOR "Greg Kroah-Hartman, greg@kroah.com, http://www.kroah.com/linux/" | ||
44 | #define DRIVER_DESC "USB Serial Driver core" | 43 | #define DRIVER_DESC "USB Serial Driver core" |
45 | 44 | ||
46 | /* There is no MODULE_DEVICE_TABLE for usbserial.c. Instead | 45 | /* There is no MODULE_DEVICE_TABLE for usbserial.c. Instead |
@@ -50,7 +49,6 @@ | |||
50 | drivers depend on it. | 49 | drivers depend on it. |
51 | */ | 50 | */ |
52 | 51 | ||
53 | static bool debug; | ||
54 | /* initially all NULL */ | 52 | /* initially all NULL */ |
55 | static struct usb_serial *serial_table[SERIAL_TTY_MINORS]; | 53 | static struct usb_serial *serial_table[SERIAL_TTY_MINORS]; |
56 | static DEFINE_MUTEX(table_lock); | 54 | static DEFINE_MUTEX(table_lock); |
@@ -87,7 +85,7 @@ static struct usb_serial *get_free_serial(struct usb_serial *serial, | |||
87 | unsigned int i, j; | 85 | unsigned int i, j; |
88 | int good_spot; | 86 | int good_spot; |
89 | 87 | ||
90 | dbg("%s %d", __func__, num_ports); | 88 | dev_dbg(&serial->interface->dev, "%s %d\n", __func__, num_ports); |
91 | 89 | ||
92 | *minor = 0; | 90 | *minor = 0; |
93 | mutex_lock(&table_lock); | 91 | mutex_lock(&table_lock); |
@@ -107,7 +105,7 @@ static struct usb_serial *get_free_serial(struct usb_serial *serial, | |||
107 | 105 | ||
108 | *minor = i; | 106 | *minor = i; |
109 | j = 0; | 107 | j = 0; |
110 | dbg("%s - minor base = %d", __func__, *minor); | 108 | dev_dbg(&serial->interface->dev, "%s - minor base = %d\n", __func__, *minor); |
111 | for (i = *minor; (i < (*minor + num_ports)) && (i < SERIAL_TTY_MINORS); ++i) { | 109 | for (i = *minor; (i < (*minor + num_ports)) && (i < SERIAL_TTY_MINORS); ++i) { |
112 | serial_table[i] = serial; | 110 | serial_table[i] = serial; |
113 | serial->port[j++]->number = i; | 111 | serial->port[j++]->number = i; |
@@ -123,8 +121,6 @@ static void return_serial(struct usb_serial *serial) | |||
123 | { | 121 | { |
124 | int i; | 122 | int i; |
125 | 123 | ||
126 | dbg("%s", __func__); | ||
127 | |||
128 | mutex_lock(&table_lock); | 124 | mutex_lock(&table_lock); |
129 | for (i = 0; i < serial->num_ports; ++i) | 125 | for (i = 0; i < serial->num_ports; ++i) |
130 | serial_table[serial->minor + i] = NULL; | 126 | serial_table[serial->minor + i] = NULL; |
@@ -139,8 +135,6 @@ static void destroy_serial(struct kref *kref) | |||
139 | 135 | ||
140 | serial = to_usb_serial(kref); | 136 | serial = to_usb_serial(kref); |
141 | 137 | ||
142 | dbg("%s - %s", __func__, serial->type->description); | ||
143 | |||
144 | /* return the minor range that this device had */ | 138 | /* return the minor range that this device had */ |
145 | if (serial->minor != SERIAL_TTY_NO_MINOR) | 139 | if (serial->minor != SERIAL_TTY_NO_MINOR) |
146 | return_serial(serial); | 140 | return_serial(serial); |
@@ -191,8 +185,6 @@ static int serial_install(struct tty_driver *driver, struct tty_struct *tty) | |||
191 | struct usb_serial_port *port; | 185 | struct usb_serial_port *port; |
192 | int retval = -ENODEV; | 186 | int retval = -ENODEV; |
193 | 187 | ||
194 | dbg("%s", __func__); | ||
195 | |||
196 | serial = usb_serial_get_by_index(idx); | 188 | serial = usb_serial_get_by_index(idx); |
197 | if (!serial) | 189 | if (!serial) |
198 | return retval; | 190 | return retval; |
@@ -256,7 +248,7 @@ static int serial_open(struct tty_struct *tty, struct file *filp) | |||
256 | { | 248 | { |
257 | struct usb_serial_port *port = tty->driver_data; | 249 | struct usb_serial_port *port = tty->driver_data; |
258 | 250 | ||
259 | dbg("%s - port %d", __func__, port->number); | 251 | dev_dbg(tty->dev, "%s - port %d\n", __func__, port->number); |
260 | return tty_port_open(&port->port, tty, filp); | 252 | return tty_port_open(&port->port, tty, filp); |
261 | } | 253 | } |
262 | 254 | ||
@@ -287,14 +279,16 @@ static void serial_down(struct tty_port *tport) | |||
287 | static void serial_hangup(struct tty_struct *tty) | 279 | static void serial_hangup(struct tty_struct *tty) |
288 | { | 280 | { |
289 | struct usb_serial_port *port = tty->driver_data; | 281 | struct usb_serial_port *port = tty->driver_data; |
290 | dbg("%s - port %d", __func__, port->number); | 282 | |
283 | dev_dbg(tty->dev, "%s - port %d\n", __func__, port->number); | ||
291 | tty_port_hangup(&port->port); | 284 | tty_port_hangup(&port->port); |
292 | } | 285 | } |
293 | 286 | ||
294 | static void serial_close(struct tty_struct *tty, struct file *filp) | 287 | static void serial_close(struct tty_struct *tty, struct file *filp) |
295 | { | 288 | { |
296 | struct usb_serial_port *port = tty->driver_data; | 289 | struct usb_serial_port *port = tty->driver_data; |
297 | dbg("%s - port %d", __func__, port->number); | 290 | |
291 | dev_dbg(tty->dev, "%s - port %d\n", __func__, port->number); | ||
298 | tty_port_close(&port->port, tty, filp); | 292 | tty_port_close(&port->port, tty, filp); |
299 | } | 293 | } |
300 | 294 | ||
@@ -319,7 +313,7 @@ static void serial_cleanup(struct tty_struct *tty) | |||
319 | if (port->port.console) | 313 | if (port->port.console) |
320 | return; | 314 | return; |
321 | 315 | ||
322 | dbg("%s - port %d", __func__, port->number); | 316 | dev_dbg(tty->dev, "%s - port %d\n", __func__, port->number); |
323 | 317 | ||
324 | tty->driver_data = NULL; | 318 | tty->driver_data = NULL; |
325 | 319 | ||
@@ -344,7 +338,8 @@ static int serial_write(struct tty_struct *tty, const unsigned char *buf, | |||
344 | if (port->serial->dev->state == USB_STATE_NOTATTACHED) | 338 | if (port->serial->dev->state == USB_STATE_NOTATTACHED) |
345 | goto exit; | 339 | goto exit; |
346 | 340 | ||
347 | dbg("%s - port %d, %d byte(s)", __func__, port->number, count); | 341 | dev_dbg(tty->dev, "%s - port %d, %d byte(s)\n", __func__, |
342 | port->number, count); | ||
348 | 343 | ||
349 | /* pass on to the driver specific version of this function */ | 344 | /* pass on to the driver specific version of this function */ |
350 | retval = port->serial->type->write(tty, port, buf, count); | 345 | retval = port->serial->type->write(tty, port, buf, count); |
@@ -357,7 +352,8 @@ exit: | |||
357 | static int serial_write_room(struct tty_struct *tty) | 352 | static int serial_write_room(struct tty_struct *tty) |
358 | { | 353 | { |
359 | struct usb_serial_port *port = tty->driver_data; | 354 | struct usb_serial_port *port = tty->driver_data; |
360 | dbg("%s - port %d", __func__, port->number); | 355 | |
356 | dev_dbg(tty->dev, "%s - port %d\n", __func__, port->number); | ||
361 | /* pass on to the driver specific version of this function */ | 357 | /* pass on to the driver specific version of this function */ |
362 | return port->serial->type->write_room(tty); | 358 | return port->serial->type->write_room(tty); |
363 | } | 359 | } |
@@ -365,7 +361,8 @@ static int serial_write_room(struct tty_struct *tty) | |||
365 | static int serial_chars_in_buffer(struct tty_struct *tty) | 361 | static int serial_chars_in_buffer(struct tty_struct *tty) |
366 | { | 362 | { |
367 | struct usb_serial_port *port = tty->driver_data; | 363 | struct usb_serial_port *port = tty->driver_data; |
368 | dbg("%s - port %d", __func__, port->number); | 364 | |
365 | dev_dbg(tty->dev, "%s - port %d\n", __func__, port->number); | ||
369 | 366 | ||
370 | /* if the device was unplugged then any remaining characters | 367 | /* if the device was unplugged then any remaining characters |
371 | fell out of the connector ;) */ | 368 | fell out of the connector ;) */ |
@@ -378,7 +375,8 @@ static int serial_chars_in_buffer(struct tty_struct *tty) | |||
378 | static void serial_throttle(struct tty_struct *tty) | 375 | static void serial_throttle(struct tty_struct *tty) |
379 | { | 376 | { |
380 | struct usb_serial_port *port = tty->driver_data; | 377 | struct usb_serial_port *port = tty->driver_data; |
381 | dbg("%s - port %d", __func__, port->number); | 378 | |
379 | dev_dbg(tty->dev, "%s - port %d\n", __func__, port->number); | ||
382 | 380 | ||
383 | /* pass on to the driver specific version of this function */ | 381 | /* pass on to the driver specific version of this function */ |
384 | if (port->serial->type->throttle) | 382 | if (port->serial->type->throttle) |
@@ -388,7 +386,8 @@ static void serial_throttle(struct tty_struct *tty) | |||
388 | static void serial_unthrottle(struct tty_struct *tty) | 386 | static void serial_unthrottle(struct tty_struct *tty) |
389 | { | 387 | { |
390 | struct usb_serial_port *port = tty->driver_data; | 388 | struct usb_serial_port *port = tty->driver_data; |
391 | dbg("%s - port %d", __func__, port->number); | 389 | |
390 | dev_dbg(tty->dev, "%s - port %d\n", __func__, port->number); | ||
392 | 391 | ||
393 | /* pass on to the driver specific version of this function */ | 392 | /* pass on to the driver specific version of this function */ |
394 | if (port->serial->type->unthrottle) | 393 | if (port->serial->type->unthrottle) |
@@ -401,7 +400,8 @@ static int serial_ioctl(struct tty_struct *tty, | |||
401 | struct usb_serial_port *port = tty->driver_data; | 400 | struct usb_serial_port *port = tty->driver_data; |
402 | int retval = -ENODEV; | 401 | int retval = -ENODEV; |
403 | 402 | ||
404 | dbg("%s - port %d, cmd 0x%.4x", __func__, port->number, cmd); | 403 | dev_dbg(tty->dev, "%s - port %d, cmd 0x%.4x\n", __func__, |
404 | port->number, cmd); | ||
405 | 405 | ||
406 | /* pass on to the driver specific version of this function | 406 | /* pass on to the driver specific version of this function |
407 | if it is available */ | 407 | if it is available */ |
@@ -415,7 +415,8 @@ static int serial_ioctl(struct tty_struct *tty, | |||
415 | static void serial_set_termios(struct tty_struct *tty, struct ktermios *old) | 415 | static void serial_set_termios(struct tty_struct *tty, struct ktermios *old) |
416 | { | 416 | { |
417 | struct usb_serial_port *port = tty->driver_data; | 417 | struct usb_serial_port *port = tty->driver_data; |
418 | dbg("%s - port %d", __func__, port->number); | 418 | |
419 | dev_dbg(tty->dev, "%s - port %d\n", __func__, port->number); | ||
419 | 420 | ||
420 | /* pass on to the driver specific version of this function | 421 | /* pass on to the driver specific version of this function |
421 | if it is available */ | 422 | if it is available */ |
@@ -429,7 +430,7 @@ static int serial_break(struct tty_struct *tty, int break_state) | |||
429 | { | 430 | { |
430 | struct usb_serial_port *port = tty->driver_data; | 431 | struct usb_serial_port *port = tty->driver_data; |
431 | 432 | ||
432 | dbg("%s - port %d", __func__, port->number); | 433 | dev_dbg(tty->dev, "%s - port %d\n", __func__, port->number); |
433 | 434 | ||
434 | /* pass on to the driver specific version of this function | 435 | /* pass on to the driver specific version of this function |
435 | if it is available */ | 436 | if it is available */ |
@@ -444,7 +445,6 @@ static int serial_proc_show(struct seq_file *m, void *v) | |||
444 | int i; | 445 | int i; |
445 | char tmp[40]; | 446 | char tmp[40]; |
446 | 447 | ||
447 | dbg("%s", __func__); | ||
448 | seq_puts(m, "usbserinfo:1.0 driver:2.0\n"); | 448 | seq_puts(m, "usbserinfo:1.0 driver:2.0\n"); |
449 | for (i = 0; i < SERIAL_TTY_MINORS; ++i) { | 449 | for (i = 0; i < SERIAL_TTY_MINORS; ++i) { |
450 | serial = usb_serial_get_by_index(i); | 450 | serial = usb_serial_get_by_index(i); |
@@ -489,7 +489,7 @@ static int serial_tiocmget(struct tty_struct *tty) | |||
489 | { | 489 | { |
490 | struct usb_serial_port *port = tty->driver_data; | 490 | struct usb_serial_port *port = tty->driver_data; |
491 | 491 | ||
492 | dbg("%s - port %d", __func__, port->number); | 492 | dev_dbg(tty->dev, "%s - port %d\n", __func__, port->number); |
493 | 493 | ||
494 | if (port->serial->type->tiocmget) | 494 | if (port->serial->type->tiocmget) |
495 | return port->serial->type->tiocmget(tty); | 495 | return port->serial->type->tiocmget(tty); |
@@ -501,7 +501,7 @@ static int serial_tiocmset(struct tty_struct *tty, | |||
501 | { | 501 | { |
502 | struct usb_serial_port *port = tty->driver_data; | 502 | struct usb_serial_port *port = tty->driver_data; |
503 | 503 | ||
504 | dbg("%s - port %d", __func__, port->number); | 504 | dev_dbg(tty->dev, "%s - port %d\n", __func__, port->number); |
505 | 505 | ||
506 | if (port->serial->type->tiocmset) | 506 | if (port->serial->type->tiocmset) |
507 | return port->serial->type->tiocmset(tty, set, clear); | 507 | return port->serial->type->tiocmset(tty, set, clear); |
@@ -513,7 +513,7 @@ static int serial_get_icount(struct tty_struct *tty, | |||
513 | { | 513 | { |
514 | struct usb_serial_port *port = tty->driver_data; | 514 | struct usb_serial_port *port = tty->driver_data; |
515 | 515 | ||
516 | dbg("%s - port %d", __func__, port->number); | 516 | dev_dbg(tty->dev, "%s - port %d\n", __func__, port->number); |
517 | 517 | ||
518 | if (port->serial->type->get_icount) | 518 | if (port->serial->type->get_icount) |
519 | return port->serial->type->get_icount(tty, icount); | 519 | return port->serial->type->get_icount(tty, icount); |
@@ -537,12 +537,12 @@ static void usb_serial_port_work(struct work_struct *work) | |||
537 | container_of(work, struct usb_serial_port, work); | 537 | container_of(work, struct usb_serial_port, work); |
538 | struct tty_struct *tty; | 538 | struct tty_struct *tty; |
539 | 539 | ||
540 | dbg("%s - port %d", __func__, port->number); | ||
541 | |||
542 | tty = tty_port_tty_get(&port->port); | 540 | tty = tty_port_tty_get(&port->port); |
543 | if (!tty) | 541 | if (!tty) |
544 | return; | 542 | return; |
545 | 543 | ||
544 | dev_dbg(tty->dev, "%s - port %d\n", __func__, port->number); | ||
545 | |||
546 | tty_wakeup(tty); | 546 | tty_wakeup(tty); |
547 | tty_kref_put(tty); | 547 | tty_kref_put(tty); |
548 | } | 548 | } |
@@ -575,7 +575,7 @@ static void port_release(struct device *dev) | |||
575 | struct usb_serial_port *port = to_usb_serial_port(dev); | 575 | struct usb_serial_port *port = to_usb_serial_port(dev); |
576 | int i; | 576 | int i; |
577 | 577 | ||
578 | dbg ("%s - %s", __func__, dev_name(dev)); | 578 | dev_dbg(dev, "%s\n", __func__); |
579 | 579 | ||
580 | /* | 580 | /* |
581 | * Stop all the traffic before cancelling the work, so that | 581 | * Stop all the traffic before cancelling the work, so that |
@@ -644,12 +644,12 @@ static const struct usb_device_id *get_iface_id(struct usb_serial_driver *drv, | |||
644 | 644 | ||
645 | id = usb_match_id(intf, drv->id_table); | 645 | id = usb_match_id(intf, drv->id_table); |
646 | if (id) { | 646 | if (id) { |
647 | dbg("static descriptor matches"); | 647 | dev_dbg(&intf->dev, "static descriptor matches\n"); |
648 | goto exit; | 648 | goto exit; |
649 | } | 649 | } |
650 | id = match_dynamic_id(intf, drv); | 650 | id = match_dynamic_id(intf, drv); |
651 | if (id) | 651 | if (id) |
652 | dbg("dynamic descriptor matches"); | 652 | dev_dbg(&intf->dev, "dynamic descriptor matches\n"); |
653 | exit: | 653 | exit: |
654 | return id; | 654 | return id; |
655 | } | 655 | } |
@@ -703,6 +703,7 @@ static const struct tty_port_operations serial_port_ops = { | |||
703 | static int usb_serial_probe(struct usb_interface *interface, | 703 | static int usb_serial_probe(struct usb_interface *interface, |
704 | const struct usb_device_id *id) | 704 | const struct usb_device_id *id) |
705 | { | 705 | { |
706 | struct device *ddev = &interface->dev; | ||
706 | struct usb_device *dev = interface_to_usbdev(interface); | 707 | struct usb_device *dev = interface_to_usbdev(interface); |
707 | struct usb_serial *serial = NULL; | 708 | struct usb_serial *serial = NULL; |
708 | struct usb_serial_port *port; | 709 | struct usb_serial_port *port; |
@@ -729,13 +730,13 @@ static int usb_serial_probe(struct usb_interface *interface, | |||
729 | type = search_serial_device(interface); | 730 | type = search_serial_device(interface); |
730 | if (!type) { | 731 | if (!type) { |
731 | mutex_unlock(&table_lock); | 732 | mutex_unlock(&table_lock); |
732 | dbg("none matched"); | 733 | dev_dbg(ddev, "none matched\n"); |
733 | return -ENODEV; | 734 | return -ENODEV; |
734 | } | 735 | } |
735 | 736 | ||
736 | if (!try_module_get(type->driver.owner)) { | 737 | if (!try_module_get(type->driver.owner)) { |
737 | mutex_unlock(&table_lock); | 738 | mutex_unlock(&table_lock); |
738 | dev_err(&interface->dev, "module get failed, exiting\n"); | 739 | dev_err(ddev, "module get failed, exiting\n"); |
739 | return -EIO; | 740 | return -EIO; |
740 | } | 741 | } |
741 | mutex_unlock(&table_lock); | 742 | mutex_unlock(&table_lock); |
@@ -743,7 +744,7 @@ static int usb_serial_probe(struct usb_interface *interface, | |||
743 | serial = create_serial(dev, interface, type); | 744 | serial = create_serial(dev, interface, type); |
744 | if (!serial) { | 745 | if (!serial) { |
745 | module_put(type->driver.owner); | 746 | module_put(type->driver.owner); |
746 | dev_err(&interface->dev, "%s - out of memory\n", __func__); | 747 | dev_err(ddev, "%s - out of memory\n", __func__); |
747 | return -ENOMEM; | 748 | return -ENOMEM; |
748 | } | 749 | } |
749 | 750 | ||
@@ -755,7 +756,7 @@ static int usb_serial_probe(struct usb_interface *interface, | |||
755 | retval = type->probe(serial, id); | 756 | retval = type->probe(serial, id); |
756 | 757 | ||
757 | if (retval) { | 758 | if (retval) { |
758 | dbg("sub driver rejected device"); | 759 | dev_dbg(ddev, "sub driver rejected device\n"); |
759 | usb_serial_put(serial); | 760 | usb_serial_put(serial); |
760 | module_put(type->driver.owner); | 761 | module_put(type->driver.owner); |
761 | return retval; | 762 | return retval; |
@@ -770,28 +771,28 @@ static int usb_serial_probe(struct usb_interface *interface, | |||
770 | 771 | ||
771 | if (usb_endpoint_is_bulk_in(endpoint)) { | 772 | if (usb_endpoint_is_bulk_in(endpoint)) { |
772 | /* we found a bulk in endpoint */ | 773 | /* we found a bulk in endpoint */ |
773 | dbg("found bulk in on endpoint %d", i); | 774 | dev_dbg(ddev, "found bulk in on endpoint %d\n", i); |
774 | bulk_in_endpoint[num_bulk_in] = endpoint; | 775 | bulk_in_endpoint[num_bulk_in] = endpoint; |
775 | ++num_bulk_in; | 776 | ++num_bulk_in; |
776 | } | 777 | } |
777 | 778 | ||
778 | if (usb_endpoint_is_bulk_out(endpoint)) { | 779 | if (usb_endpoint_is_bulk_out(endpoint)) { |
779 | /* we found a bulk out endpoint */ | 780 | /* we found a bulk out endpoint */ |
780 | dbg("found bulk out on endpoint %d", i); | 781 | dev_dbg(ddev, "found bulk out on endpoint %d\n", i); |
781 | bulk_out_endpoint[num_bulk_out] = endpoint; | 782 | bulk_out_endpoint[num_bulk_out] = endpoint; |
782 | ++num_bulk_out; | 783 | ++num_bulk_out; |
783 | } | 784 | } |
784 | 785 | ||
785 | if (usb_endpoint_is_int_in(endpoint)) { | 786 | if (usb_endpoint_is_int_in(endpoint)) { |
786 | /* we found a interrupt in endpoint */ | 787 | /* we found a interrupt in endpoint */ |
787 | dbg("found interrupt in on endpoint %d", i); | 788 | dev_dbg(ddev, "found interrupt in on endpoint %d\n", i); |
788 | interrupt_in_endpoint[num_interrupt_in] = endpoint; | 789 | interrupt_in_endpoint[num_interrupt_in] = endpoint; |
789 | ++num_interrupt_in; | 790 | ++num_interrupt_in; |
790 | } | 791 | } |
791 | 792 | ||
792 | if (usb_endpoint_is_int_out(endpoint)) { | 793 | if (usb_endpoint_is_int_out(endpoint)) { |
793 | /* we found an interrupt out endpoint */ | 794 | /* we found an interrupt out endpoint */ |
794 | dbg("found interrupt out on endpoint %d", i); | 795 | dev_dbg(ddev, "found interrupt out on endpoint %d\n", i); |
795 | interrupt_out_endpoint[num_interrupt_out] = endpoint; | 796 | interrupt_out_endpoint[num_interrupt_out] = endpoint; |
796 | ++num_interrupt_out; | 797 | ++num_interrupt_out; |
797 | } | 798 | } |
@@ -815,7 +816,7 @@ static int usb_serial_probe(struct usb_interface *interface, | |||
815 | endpoint = &iface_desc->endpoint[i].desc; | 816 | endpoint = &iface_desc->endpoint[i].desc; |
816 | if (usb_endpoint_is_int_in(endpoint)) { | 817 | if (usb_endpoint_is_int_in(endpoint)) { |
817 | /* we found a interrupt in endpoint */ | 818 | /* we found a interrupt in endpoint */ |
818 | dbg("found interrupt in for Prolific device on separate interface"); | 819 | dev_dbg(ddev, "found interrupt in for Prolific device on separate interface\n"); |
819 | interrupt_in_endpoint[num_interrupt_in] = endpoint; | 820 | interrupt_in_endpoint[num_interrupt_in] = endpoint; |
820 | ++num_interrupt_in; | 821 | ++num_interrupt_in; |
821 | } | 822 | } |
@@ -827,7 +828,7 @@ static int usb_serial_probe(struct usb_interface *interface, | |||
827 | * properly during a later invocation of usb_serial_probe | 828 | * properly during a later invocation of usb_serial_probe |
828 | */ | 829 | */ |
829 | if (num_bulk_in == 0 || num_bulk_out == 0) { | 830 | if (num_bulk_in == 0 || num_bulk_out == 0) { |
830 | dev_info(&interface->dev, "PL-2303 hack: descriptors matched but endpoints did not\n"); | 831 | dev_info(ddev, "PL-2303 hack: descriptors matched but endpoints did not\n"); |
831 | usb_serial_put(serial); | 832 | usb_serial_put(serial); |
832 | module_put(type->driver.owner); | 833 | module_put(type->driver.owner); |
833 | return -ENODEV; | 834 | return -ENODEV; |
@@ -840,14 +841,13 @@ static int usb_serial_probe(struct usb_interface *interface, | |||
840 | if (type == &usb_serial_generic_device) { | 841 | if (type == &usb_serial_generic_device) { |
841 | num_ports = num_bulk_out; | 842 | num_ports = num_bulk_out; |
842 | if (num_ports == 0) { | 843 | if (num_ports == 0) { |
843 | dev_err(&interface->dev, | 844 | dev_err(ddev, "Generic device with no bulk out, not allowed.\n"); |
844 | "Generic device with no bulk out, not allowed.\n"); | ||
845 | usb_serial_put(serial); | 845 | usb_serial_put(serial); |
846 | module_put(type->driver.owner); | 846 | module_put(type->driver.owner); |
847 | return -EIO; | 847 | return -EIO; |
848 | } | 848 | } |
849 | dev_info(&interface->dev, "The \"generic\" usb-serial driver is only for testing and one-off prototypes.\n"); | 849 | dev_info(ddev, "The \"generic\" usb-serial driver is only for testing and one-off prototypes.\n"); |
850 | dev_info(&interface->dev, "Tell linux-usb@vger.kernel.org to add your device to a proper driver.\n"); | 850 | dev_info(ddev, "Tell linux-usb@vger.kernel.org to add your device to a proper driver.\n"); |
851 | } | 851 | } |
852 | #endif | 852 | #endif |
853 | if (!num_ports) { | 853 | if (!num_ports) { |
@@ -865,8 +865,7 @@ static int usb_serial_probe(struct usb_interface *interface, | |||
865 | serial->num_interrupt_out = num_interrupt_out; | 865 | serial->num_interrupt_out = num_interrupt_out; |
866 | 866 | ||
867 | /* found all that we need */ | 867 | /* found all that we need */ |
868 | dev_info(&interface->dev, "%s converter detected\n", | 868 | dev_info(ddev, "%s converter detected\n", type->description); |
869 | type->description); | ||
870 | 869 | ||
871 | /* create our ports, we need as many as the max endpoints */ | 870 | /* create our ports, we need as many as the max endpoints */ |
872 | /* we don't use num_ports here because some devices have more | 871 | /* we don't use num_ports here because some devices have more |
@@ -877,8 +876,7 @@ static int usb_serial_probe(struct usb_interface *interface, | |||
877 | max_endpoints = max(max_endpoints, (int)serial->num_ports); | 876 | max_endpoints = max(max_endpoints, (int)serial->num_ports); |
878 | serial->num_port_pointers = max_endpoints; | 877 | serial->num_port_pointers = max_endpoints; |
879 | 878 | ||
880 | dbg("%s - setting up %d port structures for this device", | 879 | dev_dbg(ddev, "setting up %d port structures for this device", max_endpoints); |
881 | __func__, max_endpoints); | ||
882 | for (i = 0; i < max_endpoints; ++i) { | 880 | for (i = 0; i < max_endpoints; ++i) { |
883 | port = kzalloc(sizeof(struct usb_serial_port), GFP_KERNEL); | 881 | port = kzalloc(sizeof(struct usb_serial_port), GFP_KERNEL); |
884 | if (!port) | 882 | if (!port) |
@@ -911,15 +909,13 @@ static int usb_serial_probe(struct usb_interface *interface, | |||
911 | set_bit(j, &port->read_urbs_free); | 909 | set_bit(j, &port->read_urbs_free); |
912 | port->read_urbs[j] = usb_alloc_urb(0, GFP_KERNEL); | 910 | port->read_urbs[j] = usb_alloc_urb(0, GFP_KERNEL); |
913 | if (!port->read_urbs[j]) { | 911 | if (!port->read_urbs[j]) { |
914 | dev_err(&interface->dev, | 912 | dev_err(ddev, "No free urbs available\n"); |
915 | "No free urbs available\n"); | ||
916 | goto probe_error; | 913 | goto probe_error; |
917 | } | 914 | } |
918 | port->bulk_in_buffers[j] = kmalloc(buffer_size, | 915 | port->bulk_in_buffers[j] = kmalloc(buffer_size, |
919 | GFP_KERNEL); | 916 | GFP_KERNEL); |
920 | if (!port->bulk_in_buffers[j]) { | 917 | if (!port->bulk_in_buffers[j]) { |
921 | dev_err(&interface->dev, | 918 | dev_err(ddev, "Couldn't allocate bulk_in_buffer\n"); |
922 | "Couldn't allocate bulk_in_buffer\n"); | ||
923 | goto probe_error; | 919 | goto probe_error; |
924 | } | 920 | } |
925 | usb_fill_bulk_urb(port->read_urbs[j], dev, | 921 | usb_fill_bulk_urb(port->read_urbs[j], dev, |
@@ -949,15 +945,13 @@ static int usb_serial_probe(struct usb_interface *interface, | |||
949 | set_bit(j, &port->write_urbs_free); | 945 | set_bit(j, &port->write_urbs_free); |
950 | port->write_urbs[j] = usb_alloc_urb(0, GFP_KERNEL); | 946 | port->write_urbs[j] = usb_alloc_urb(0, GFP_KERNEL); |
951 | if (!port->write_urbs[j]) { | 947 | if (!port->write_urbs[j]) { |
952 | dev_err(&interface->dev, | 948 | dev_err(ddev, "No free urbs available\n"); |
953 | "No free urbs available\n"); | ||
954 | goto probe_error; | 949 | goto probe_error; |
955 | } | 950 | } |
956 | port->bulk_out_buffers[j] = kmalloc(buffer_size, | 951 | port->bulk_out_buffers[j] = kmalloc(buffer_size, |
957 | GFP_KERNEL); | 952 | GFP_KERNEL); |
958 | if (!port->bulk_out_buffers[j]) { | 953 | if (!port->bulk_out_buffers[j]) { |
959 | dev_err(&interface->dev, | 954 | dev_err(ddev, "Couldn't allocate bulk_out_buffer\n"); |
960 | "Couldn't allocate bulk_out_buffer\n"); | ||
961 | goto probe_error; | 955 | goto probe_error; |
962 | } | 956 | } |
963 | usb_fill_bulk_urb(port->write_urbs[j], dev, | 957 | usb_fill_bulk_urb(port->write_urbs[j], dev, |
@@ -978,8 +972,7 @@ static int usb_serial_probe(struct usb_interface *interface, | |||
978 | port = serial->port[i]; | 972 | port = serial->port[i]; |
979 | port->interrupt_in_urb = usb_alloc_urb(0, GFP_KERNEL); | 973 | port->interrupt_in_urb = usb_alloc_urb(0, GFP_KERNEL); |
980 | if (!port->interrupt_in_urb) { | 974 | if (!port->interrupt_in_urb) { |
981 | dev_err(&interface->dev, | 975 | dev_err(ddev, "No free urbs available\n"); |
982 | "No free urbs available\n"); | ||
983 | goto probe_error; | 976 | goto probe_error; |
984 | } | 977 | } |
985 | buffer_size = usb_endpoint_maxp(endpoint); | 978 | buffer_size = usb_endpoint_maxp(endpoint); |
@@ -988,8 +981,7 @@ static int usb_serial_probe(struct usb_interface *interface, | |||
988 | port->interrupt_in_buffer = kmalloc(buffer_size, | 981 | port->interrupt_in_buffer = kmalloc(buffer_size, |
989 | GFP_KERNEL); | 982 | GFP_KERNEL); |
990 | if (!port->interrupt_in_buffer) { | 983 | if (!port->interrupt_in_buffer) { |
991 | dev_err(&interface->dev, | 984 | dev_err(ddev, "Couldn't allocate interrupt_in_buffer\n"); |
992 | "Couldn't allocate interrupt_in_buffer\n"); | ||
993 | goto probe_error; | 985 | goto probe_error; |
994 | } | 986 | } |
995 | usb_fill_int_urb(port->interrupt_in_urb, dev, | 987 | usb_fill_int_urb(port->interrupt_in_urb, dev, |
@@ -1000,7 +992,7 @@ static int usb_serial_probe(struct usb_interface *interface, | |||
1000 | endpoint->bInterval); | 992 | endpoint->bInterval); |
1001 | } | 993 | } |
1002 | } else if (num_interrupt_in) { | 994 | } else if (num_interrupt_in) { |
1003 | dbg("the device claims to support interrupt in transfers, but read_int_callback is not defined"); | 995 | dev_dbg(ddev, "The device claims to support interrupt in transfers, but read_int_callback is not defined\n"); |
1004 | } | 996 | } |
1005 | 997 | ||
1006 | if (serial->type->write_int_callback) { | 998 | if (serial->type->write_int_callback) { |
@@ -1009,8 +1001,7 @@ static int usb_serial_probe(struct usb_interface *interface, | |||
1009 | port = serial->port[i]; | 1001 | port = serial->port[i]; |
1010 | port->interrupt_out_urb = usb_alloc_urb(0, GFP_KERNEL); | 1002 | port->interrupt_out_urb = usb_alloc_urb(0, GFP_KERNEL); |
1011 | if (!port->interrupt_out_urb) { | 1003 | if (!port->interrupt_out_urb) { |
1012 | dev_err(&interface->dev, | 1004 | dev_err(ddev, "No free urbs available\n"); |
1013 | "No free urbs available\n"); | ||
1014 | goto probe_error; | 1005 | goto probe_error; |
1015 | } | 1006 | } |
1016 | buffer_size = usb_endpoint_maxp(endpoint); | 1007 | buffer_size = usb_endpoint_maxp(endpoint); |
@@ -1020,8 +1011,7 @@ static int usb_serial_probe(struct usb_interface *interface, | |||
1020 | port->interrupt_out_buffer = kmalloc(buffer_size, | 1011 | port->interrupt_out_buffer = kmalloc(buffer_size, |
1021 | GFP_KERNEL); | 1012 | GFP_KERNEL); |
1022 | if (!port->interrupt_out_buffer) { | 1013 | if (!port->interrupt_out_buffer) { |
1023 | dev_err(&interface->dev, | 1014 | dev_err(ddev, "Couldn't allocate interrupt_out_buffer\n"); |
1024 | "Couldn't allocate interrupt_out_buffer\n"); | ||
1025 | goto probe_error; | 1015 | goto probe_error; |
1026 | } | 1016 | } |
1027 | usb_fill_int_urb(port->interrupt_out_urb, dev, | 1017 | usb_fill_int_urb(port->interrupt_out_urb, dev, |
@@ -1032,7 +1022,7 @@ static int usb_serial_probe(struct usb_interface *interface, | |||
1032 | endpoint->bInterval); | 1022 | endpoint->bInterval); |
1033 | } | 1023 | } |
1034 | } else if (num_interrupt_out) { | 1024 | } else if (num_interrupt_out) { |
1035 | dbg("the device claims to support interrupt out transfers, but write_int_callback is not defined"); | 1025 | dev_dbg(ddev, "The device claims to support interrupt out transfers, but write_int_callback is not defined\n"); |
1036 | } | 1026 | } |
1037 | 1027 | ||
1038 | usb_set_intfdata(interface, serial); | 1028 | usb_set_intfdata(interface, serial); |
@@ -1060,7 +1050,7 @@ static int usb_serial_probe(struct usb_interface *interface, | |||
1060 | serial->disconnected = 1; | 1050 | serial->disconnected = 1; |
1061 | 1051 | ||
1062 | if (get_free_serial(serial, num_ports, &minor) == NULL) { | 1052 | if (get_free_serial(serial, num_ports, &minor) == NULL) { |
1063 | dev_err(&interface->dev, "No more free serial devices\n"); | 1053 | dev_err(ddev, "No more free serial devices\n"); |
1064 | goto probe_error; | 1054 | goto probe_error; |
1065 | } | 1055 | } |
1066 | serial->minor = minor; | 1056 | serial->minor = minor; |
@@ -1069,18 +1059,17 @@ static int usb_serial_probe(struct usb_interface *interface, | |||
1069 | for (i = 0; i < num_ports; ++i) { | 1059 | for (i = 0; i < num_ports; ++i) { |
1070 | port = serial->port[i]; | 1060 | port = serial->port[i]; |
1071 | dev_set_name(&port->dev, "ttyUSB%d", port->number); | 1061 | dev_set_name(&port->dev, "ttyUSB%d", port->number); |
1072 | dbg ("%s - registering %s", __func__, dev_name(&port->dev)); | 1062 | dev_dbg(ddev, "registering %s", dev_name(&port->dev)); |
1073 | device_enable_async_suspend(&port->dev); | 1063 | device_enable_async_suspend(&port->dev); |
1074 | 1064 | ||
1075 | retval = device_add(&port->dev); | 1065 | retval = device_add(&port->dev); |
1076 | if (retval) | 1066 | if (retval) |
1077 | dev_err(&port->dev, "Error registering port device, " | 1067 | dev_err(ddev, "Error registering port device, continuing\n"); |
1078 | "continuing\n"); | ||
1079 | } | 1068 | } |
1080 | 1069 | ||
1081 | serial->disconnected = 0; | 1070 | serial->disconnected = 0; |
1082 | 1071 | ||
1083 | usb_serial_console_init(debug, minor); | 1072 | usb_serial_console_init(minor); |
1084 | exit: | 1073 | exit: |
1085 | module_put(type->driver.owner); | 1074 | module_put(type->driver.owner); |
1086 | return 0; | 1075 | return 0; |
@@ -1099,7 +1088,6 @@ static void usb_serial_disconnect(struct usb_interface *interface) | |||
1099 | struct usb_serial_port *port; | 1088 | struct usb_serial_port *port; |
1100 | 1089 | ||
1101 | usb_serial_console_disconnect(serial); | 1090 | usb_serial_console_disconnect(serial); |
1102 | dbg("%s", __func__); | ||
1103 | 1091 | ||
1104 | mutex_lock(&serial->disc_mutex); | 1092 | mutex_lock(&serial->disc_mutex); |
1105 | /* must set a flag, to signal subdrivers */ | 1093 | /* must set a flag, to signal subdrivers */ |
@@ -1234,8 +1222,7 @@ static int __init usb_serial_init(void) | |||
1234 | 1222 | ||
1235 | result = bus_register(&usb_serial_bus_type); | 1223 | result = bus_register(&usb_serial_bus_type); |
1236 | if (result) { | 1224 | if (result) { |
1237 | printk(KERN_ERR "usb-serial: %s - registering bus driver " | 1225 | pr_err("%s - registering bus driver failed\n", __func__); |
1238 | "failed\n", __func__); | ||
1239 | goto exit_bus; | 1226 | goto exit_bus; |
1240 | } | 1227 | } |
1241 | 1228 | ||
@@ -1255,29 +1242,24 @@ static int __init usb_serial_init(void) | |||
1255 | tty_set_operations(usb_serial_tty_driver, &serial_ops); | 1242 | tty_set_operations(usb_serial_tty_driver, &serial_ops); |
1256 | result = tty_register_driver(usb_serial_tty_driver); | 1243 | result = tty_register_driver(usb_serial_tty_driver); |
1257 | if (result) { | 1244 | if (result) { |
1258 | printk(KERN_ERR "usb-serial: %s - tty_register_driver failed\n", | 1245 | pr_err("%s - tty_register_driver failed\n", __func__); |
1259 | __func__); | ||
1260 | goto exit_reg_driver; | 1246 | goto exit_reg_driver; |
1261 | } | 1247 | } |
1262 | 1248 | ||
1263 | /* register the USB driver */ | 1249 | /* register the USB driver */ |
1264 | result = usb_register(&usb_serial_driver); | 1250 | result = usb_register(&usb_serial_driver); |
1265 | if (result < 0) { | 1251 | if (result < 0) { |
1266 | printk(KERN_ERR "usb-serial: %s - usb_register failed\n", | 1252 | pr_err("%s - usb_register failed\n", __func__); |
1267 | __func__); | ||
1268 | goto exit_tty; | 1253 | goto exit_tty; |
1269 | } | 1254 | } |
1270 | 1255 | ||
1271 | /* register the generic driver, if we should */ | 1256 | /* register the generic driver, if we should */ |
1272 | result = usb_serial_generic_register(debug); | 1257 | result = usb_serial_generic_register(); |
1273 | if (result < 0) { | 1258 | if (result < 0) { |
1274 | printk(KERN_ERR "usb-serial: %s - registering generic " | 1259 | pr_err("%s - registering generic driver failed\n", __func__); |
1275 | "driver failed\n", __func__); | ||
1276 | goto exit_generic; | 1260 | goto exit_generic; |
1277 | } | 1261 | } |
1278 | 1262 | ||
1279 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_DESC "\n"); | ||
1280 | |||
1281 | return result; | 1263 | return result; |
1282 | 1264 | ||
1283 | exit_generic: | 1265 | exit_generic: |
@@ -1290,8 +1272,7 @@ exit_reg_driver: | |||
1290 | bus_unregister(&usb_serial_bus_type); | 1272 | bus_unregister(&usb_serial_bus_type); |
1291 | 1273 | ||
1292 | exit_bus: | 1274 | exit_bus: |
1293 | printk(KERN_ERR "usb-serial: %s - returning with error %d\n", | 1275 | pr_err("%s - returning with error %d\n", __func__, result); |
1294 | __func__, result); | ||
1295 | put_tty_driver(usb_serial_tty_driver); | 1276 | put_tty_driver(usb_serial_tty_driver); |
1296 | return result; | 1277 | return result; |
1297 | } | 1278 | } |
@@ -1317,7 +1298,7 @@ module_exit(usb_serial_exit); | |||
1317 | do { \ | 1298 | do { \ |
1318 | if (!type->function) { \ | 1299 | if (!type->function) { \ |
1319 | type->function = usb_serial_generic_##function; \ | 1300 | type->function = usb_serial_generic_##function; \ |
1320 | dbg("Had to override the " #function \ | 1301 | pr_debug("Had to override the " #function \ |
1321 | " usb serial operation with the generic one.");\ | 1302 | " usb serial operation with the generic one.");\ |
1322 | } \ | 1303 | } \ |
1323 | } while (0) | 1304 | } while (0) |
@@ -1360,12 +1341,10 @@ static int usb_serial_register(struct usb_serial_driver *driver) | |||
1360 | 1341 | ||
1361 | retval = usb_serial_bus_register(driver); | 1342 | retval = usb_serial_bus_register(driver); |
1362 | if (retval) { | 1343 | if (retval) { |
1363 | printk(KERN_ERR "usb-serial: problem %d when registering " | 1344 | pr_err("problem %d when registering driver %s\n", retval, driver->description); |
1364 | "driver %s\n", retval, driver->description); | ||
1365 | list_del(&driver->driver_list); | 1345 | list_del(&driver->driver_list); |
1366 | } else | 1346 | } else |
1367 | printk(KERN_INFO "USB Serial support registered for %s\n", | 1347 | pr_info("USB Serial support registered for %s\n", driver->description); |
1368 | driver->description); | ||
1369 | 1348 | ||
1370 | mutex_unlock(&table_lock); | 1349 | mutex_unlock(&table_lock); |
1371 | return retval; | 1350 | return retval; |
@@ -1373,8 +1352,7 @@ static int usb_serial_register(struct usb_serial_driver *driver) | |||
1373 | 1352 | ||
1374 | static void usb_serial_deregister(struct usb_serial_driver *device) | 1353 | static void usb_serial_deregister(struct usb_serial_driver *device) |
1375 | { | 1354 | { |
1376 | printk(KERN_INFO "USB Serial deregistering driver %s\n", | 1355 | pr_info("USB Serial deregistering driver %s\n", device->description); |
1377 | device->description); | ||
1378 | mutex_lock(&table_lock); | 1356 | mutex_lock(&table_lock); |
1379 | list_del(&device->driver_list); | 1357 | list_del(&device->driver_list); |
1380 | usb_serial_bus_deregister(device); | 1358 | usb_serial_bus_deregister(device); |
@@ -1425,9 +1403,10 @@ int usb_serial_register_drivers(struct usb_serial_driver *const serial_drivers[] | |||
1425 | 1403 | ||
1426 | /* we only set the reset_resume field if the serial_driver has one */ | 1404 | /* we only set the reset_resume field if the serial_driver has one */ |
1427 | for (sd = serial_drivers; *sd; ++sd) { | 1405 | for (sd = serial_drivers; *sd; ++sd) { |
1428 | if ((*sd)->reset_resume) | 1406 | if ((*sd)->reset_resume) { |
1429 | udriver->reset_resume = usb_serial_reset_resume; | 1407 | udriver->reset_resume = usb_serial_reset_resume; |
1430 | break; | 1408 | break; |
1409 | } | ||
1431 | } | 1410 | } |
1432 | 1411 | ||
1433 | rc = usb_register(udriver); | 1412 | rc = usb_register(udriver); |
@@ -1477,6 +1456,3 @@ EXPORT_SYMBOL_GPL(usb_serial_deregister_drivers); | |||
1477 | MODULE_AUTHOR(DRIVER_AUTHOR); | 1456 | MODULE_AUTHOR(DRIVER_AUTHOR); |
1478 | MODULE_DESCRIPTION(DRIVER_DESC); | 1457 | MODULE_DESCRIPTION(DRIVER_DESC); |
1479 | MODULE_LICENSE("GPL"); | 1458 | MODULE_LICENSE("GPL"); |
1480 | |||
1481 | module_param(debug, bool, S_IRUGO | S_IWUSR); | ||
1482 | MODULE_PARM_DESC(debug, "Debug enabled or not"); | ||
diff --git a/drivers/usb/serial/usb_wwan.c b/drivers/usb/serial/usb_wwan.c index 72b678d90831..e42aa398ed37 100644 --- a/drivers/usb/serial/usb_wwan.c +++ b/drivers/usb/serial/usb_wwan.c | |||
@@ -37,8 +37,6 @@ | |||
37 | #include <linux/serial.h> | 37 | #include <linux/serial.h> |
38 | #include "usb-wwan.h" | 38 | #include "usb-wwan.h" |
39 | 39 | ||
40 | static bool debug; | ||
41 | |||
42 | void usb_wwan_dtr_rts(struct usb_serial_port *port, int on) | 40 | void usb_wwan_dtr_rts(struct usb_serial_port *port, int on) |
43 | { | 41 | { |
44 | struct usb_serial *serial = port->serial; | 42 | struct usb_serial *serial = port->serial; |
@@ -178,7 +176,7 @@ int usb_wwan_ioctl(struct tty_struct *tty, | |||
178 | { | 176 | { |
179 | struct usb_serial_port *port = tty->driver_data; | 177 | struct usb_serial_port *port = tty->driver_data; |
180 | 178 | ||
181 | dbg("%s cmd 0x%04x", __func__, cmd); | 179 | dev_dbg(&port->dev, "%s cmd 0x%04x\n", __func__, cmd); |
182 | 180 | ||
183 | switch (cmd) { | 181 | switch (cmd) { |
184 | case TIOCGSERIAL: | 182 | case TIOCGSERIAL: |
@@ -191,7 +189,7 @@ int usb_wwan_ioctl(struct tty_struct *tty, | |||
191 | break; | 189 | break; |
192 | } | 190 | } |
193 | 191 | ||
194 | dbg("%s arg not supported", __func__); | 192 | dev_dbg(&port->dev, "%s arg not supported\n", __func__); |
195 | 193 | ||
196 | return -ENOIOCTLCMD; | 194 | return -ENOIOCTLCMD; |
197 | } | 195 | } |
@@ -212,7 +210,7 @@ int usb_wwan_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
212 | portdata = usb_get_serial_port_data(port); | 210 | portdata = usb_get_serial_port_data(port); |
213 | intfdata = port->serial->private; | 211 | intfdata = port->serial->private; |
214 | 212 | ||
215 | dbg("%s: write (%d chars)", __func__, count); | 213 | dev_dbg(&port->dev, "%s: write (%d chars)\n", __func__, count); |
216 | 214 | ||
217 | i = 0; | 215 | i = 0; |
218 | left = count; | 216 | left = count; |
@@ -229,8 +227,8 @@ int usb_wwan_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
229 | usb_unlink_urb(this_urb); | 227 | usb_unlink_urb(this_urb); |
230 | continue; | 228 | continue; |
231 | } | 229 | } |
232 | dbg("%s: endpoint %d buf %d", __func__, | 230 | dev_dbg(&port->dev, "%s: endpoint %d buf %d\n", __func__, |
233 | usb_pipeendpoint(this_urb->pipe), i); | 231 | usb_pipeendpoint(this_urb->pipe), i); |
234 | 232 | ||
235 | err = usb_autopm_get_interface_async(port->serial->interface); | 233 | err = usb_autopm_get_interface_async(port->serial->interface); |
236 | if (err < 0) | 234 | if (err < 0) |
@@ -249,8 +247,9 @@ int usb_wwan_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
249 | spin_unlock_irqrestore(&intfdata->susp_lock, flags); | 247 | spin_unlock_irqrestore(&intfdata->susp_lock, flags); |
250 | err = usb_submit_urb(this_urb, GFP_ATOMIC); | 248 | err = usb_submit_urb(this_urb, GFP_ATOMIC); |
251 | if (err) { | 249 | if (err) { |
252 | dbg("usb_submit_urb %p (write bulk) failed " | 250 | dev_dbg(&port->dev, |
253 | "(%d)", this_urb, err); | 251 | "usb_submit_urb %p (write bulk) failed (%d)\n", |
252 | this_urb, err); | ||
254 | clear_bit(i, &portdata->out_busy); | 253 | clear_bit(i, &portdata->out_busy); |
255 | spin_lock_irqsave(&intfdata->susp_lock, flags); | 254 | spin_lock_irqsave(&intfdata->susp_lock, flags); |
256 | intfdata->in_flight--; | 255 | intfdata->in_flight--; |
@@ -267,7 +266,7 @@ int usb_wwan_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
267 | } | 266 | } |
268 | 267 | ||
269 | count -= left; | 268 | count -= left; |
270 | dbg("%s: wrote (did %d)", __func__, count); | 269 | dev_dbg(&port->dev, "%s: wrote (did %d)\n", __func__, count); |
271 | return count; | 270 | return count; |
272 | } | 271 | } |
273 | EXPORT_SYMBOL(usb_wwan_write); | 272 | EXPORT_SYMBOL(usb_wwan_write); |
@@ -278,15 +277,17 @@ static void usb_wwan_indat_callback(struct urb *urb) | |||
278 | int endpoint; | 277 | int endpoint; |
279 | struct usb_serial_port *port; | 278 | struct usb_serial_port *port; |
280 | struct tty_struct *tty; | 279 | struct tty_struct *tty; |
280 | struct device *dev; | ||
281 | unsigned char *data = urb->transfer_buffer; | 281 | unsigned char *data = urb->transfer_buffer; |
282 | int status = urb->status; | 282 | int status = urb->status; |
283 | 283 | ||
284 | endpoint = usb_pipeendpoint(urb->pipe); | 284 | endpoint = usb_pipeendpoint(urb->pipe); |
285 | port = urb->context; | 285 | port = urb->context; |
286 | dev = &port->dev; | ||
286 | 287 | ||
287 | if (status) { | 288 | if (status) { |
288 | dbg("%s: nonzero status: %d on endpoint %02x.", | 289 | dev_dbg(dev, "%s: nonzero status: %d on endpoint %02x.\n", |
289 | __func__, status, endpoint); | 290 | __func__, status, endpoint); |
290 | } else { | 291 | } else { |
291 | tty = tty_port_tty_get(&port->port); | 292 | tty = tty_port_tty_get(&port->port); |
292 | if (tty) { | 293 | if (tty) { |
@@ -295,7 +296,7 @@ static void usb_wwan_indat_callback(struct urb *urb) | |||
295 | urb->actual_length); | 296 | urb->actual_length); |
296 | tty_flip_buffer_push(tty); | 297 | tty_flip_buffer_push(tty); |
297 | } else | 298 | } else |
298 | dbg("%s: empty read urb received", __func__); | 299 | dev_dbg(dev, "%s: empty read urb received\n", __func__); |
299 | tty_kref_put(tty); | 300 | tty_kref_put(tty); |
300 | } | 301 | } |
301 | 302 | ||
@@ -303,8 +304,7 @@ static void usb_wwan_indat_callback(struct urb *urb) | |||
303 | err = usb_submit_urb(urb, GFP_ATOMIC); | 304 | err = usb_submit_urb(urb, GFP_ATOMIC); |
304 | if (err) { | 305 | if (err) { |
305 | if (err != -EPERM) { | 306 | if (err != -EPERM) { |
306 | printk(KERN_ERR "%s: resubmit read urb failed. " | 307 | dev_err(dev, "%s: resubmit read urb failed. (%d)\n", __func__, err); |
307 | "(%d)", __func__, err); | ||
308 | /* busy also in error unless we are killed */ | 308 | /* busy also in error unless we are killed */ |
309 | usb_mark_last_busy(port->serial->dev); | 309 | usb_mark_last_busy(port->serial->dev); |
310 | } | 310 | } |
@@ -356,7 +356,7 @@ int usb_wwan_write_room(struct tty_struct *tty) | |||
356 | data_len += OUT_BUFLEN; | 356 | data_len += OUT_BUFLEN; |
357 | } | 357 | } |
358 | 358 | ||
359 | dbg("%s: %d", __func__, data_len); | 359 | dev_dbg(&port->dev, "%s: %d\n", __func__, data_len); |
360 | return data_len; | 360 | return data_len; |
361 | } | 361 | } |
362 | EXPORT_SYMBOL(usb_wwan_write_room); | 362 | EXPORT_SYMBOL(usb_wwan_write_room); |
@@ -378,7 +378,7 @@ int usb_wwan_chars_in_buffer(struct tty_struct *tty) | |||
378 | if (this_urb && test_bit(i, &portdata->out_busy)) | 378 | if (this_urb && test_bit(i, &portdata->out_busy)) |
379 | data_len += this_urb->transfer_buffer_length; | 379 | data_len += this_urb->transfer_buffer_length; |
380 | } | 380 | } |
381 | dbg("%s: %d", __func__, data_len); | 381 | dev_dbg(&port->dev, "%s: %d\n", __func__, data_len); |
382 | return data_len; | 382 | return data_len; |
383 | } | 383 | } |
384 | EXPORT_SYMBOL(usb_wwan_chars_in_buffer); | 384 | EXPORT_SYMBOL(usb_wwan_chars_in_buffer); |
@@ -401,8 +401,8 @@ int usb_wwan_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
401 | continue; | 401 | continue; |
402 | err = usb_submit_urb(urb, GFP_KERNEL); | 402 | err = usb_submit_urb(urb, GFP_KERNEL); |
403 | if (err) { | 403 | if (err) { |
404 | dbg("%s: submit urb %d failed (%d) %d", | 404 | dev_dbg(&port->dev, "%s: submit urb %d failed (%d) %d\n", |
405 | __func__, i, err, urb->transfer_buffer_length); | 405 | __func__, i, err, urb->transfer_buffer_length); |
406 | } | 406 | } |
407 | } | 407 | } |
408 | 408 | ||
@@ -458,7 +458,9 @@ static struct urb *usb_wwan_setup_urb(struct usb_serial *serial, int endpoint, | |||
458 | 458 | ||
459 | urb = usb_alloc_urb(0, GFP_KERNEL); /* No ISO */ | 459 | urb = usb_alloc_urb(0, GFP_KERNEL); /* No ISO */ |
460 | if (urb == NULL) { | 460 | if (urb == NULL) { |
461 | dbg("%s: alloc for endpoint %d failed.", __func__, endpoint); | 461 | dev_dbg(&serial->interface->dev, |
462 | "%s: alloc for endpoint %d failed.\n", __func__, | ||
463 | endpoint); | ||
462 | return NULL; | 464 | return NULL; |
463 | } | 465 | } |
464 | 466 | ||
@@ -522,8 +524,8 @@ int usb_wwan_startup(struct usb_serial *serial) | |||
522 | port = serial->port[i]; | 524 | port = serial->port[i]; |
523 | portdata = kzalloc(sizeof(*portdata), GFP_KERNEL); | 525 | portdata = kzalloc(sizeof(*portdata), GFP_KERNEL); |
524 | if (!portdata) { | 526 | if (!portdata) { |
525 | dbg("%s: kmalloc for usb_wwan_port_private (%d) failed!.", | 527 | dev_dbg(&port->dev, "%s: kmalloc for usb_wwan_port_private (%d) failed!.\n", |
526 | __func__, i); | 528 | __func__, i); |
527 | return 1; | 529 | return 1; |
528 | } | 530 | } |
529 | init_usb_anchor(&portdata->delayed); | 531 | init_usb_anchor(&portdata->delayed); |
@@ -548,7 +550,8 @@ int usb_wwan_startup(struct usb_serial *serial) | |||
548 | continue; | 550 | continue; |
549 | err = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); | 551 | err = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); |
550 | if (err) | 552 | if (err) |
551 | dbg("%s: submit irq_in urb failed %d", __func__, err); | 553 | dev_dbg(&port->dev, "%s: submit irq_in urb failed %d\n", |
554 | __func__, err); | ||
552 | } | 555 | } |
553 | usb_wwan_setup_urbs(serial); | 556 | usb_wwan_setup_urbs(serial); |
554 | return 0; | 557 | return 0; |
@@ -683,11 +686,11 @@ int usb_wwan_resume(struct usb_serial *serial) | |||
683 | for (i = 0; i < serial->num_ports; i++) { | 686 | for (i = 0; i < serial->num_ports; i++) { |
684 | port = serial->port[i]; | 687 | port = serial->port[i]; |
685 | if (!port->interrupt_in_urb) { | 688 | if (!port->interrupt_in_urb) { |
686 | dbg("%s: No interrupt URB for port %d", __func__, i); | 689 | dev_dbg(&port->dev, "%s: No interrupt URB for port\n", __func__); |
687 | continue; | 690 | continue; |
688 | } | 691 | } |
689 | err = usb_submit_urb(port->interrupt_in_urb, GFP_NOIO); | 692 | err = usb_submit_urb(port->interrupt_in_urb, GFP_NOIO); |
690 | dbg("Submitted interrupt URB for port %d (result %d)", i, err); | 693 | dev_dbg(&port->dev, "Submitted interrupt URB for port (result %d)\n", err); |
691 | if (err < 0) { | 694 | if (err < 0) { |
692 | dev_err(&port->dev, "%s: Error %d for interrupt URB\n", | 695 | dev_err(&port->dev, "%s: Error %d for interrupt URB\n", |
693 | __func__, err); | 696 | __func__, err); |
@@ -733,6 +736,3 @@ MODULE_AUTHOR(DRIVER_AUTHOR); | |||
733 | MODULE_DESCRIPTION(DRIVER_DESC); | 736 | MODULE_DESCRIPTION(DRIVER_DESC); |
734 | MODULE_VERSION(DRIVER_VERSION); | 737 | MODULE_VERSION(DRIVER_VERSION); |
735 | MODULE_LICENSE("GPL"); | 738 | MODULE_LICENSE("GPL"); |
736 | |||
737 | module_param(debug, bool, S_IRUGO | S_IWUSR); | ||
738 | MODULE_PARM_DESC(debug, "Debug messages"); | ||
diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c index f253c91383da..1129aa73c23e 100644 --- a/drivers/usb/serial/visor.c +++ b/drivers/usb/serial/visor.c | |||
@@ -51,9 +51,6 @@ static int palm_os_3_probe(struct usb_serial *serial, | |||
51 | static int palm_os_4_probe(struct usb_serial *serial, | 51 | 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. */ | ||
55 | static bool debug; | ||
56 | |||
57 | static struct usb_device_id id_table [] = { | 54 | static struct usb_device_id id_table [] = { |
58 | { USB_DEVICE(HANDSPRING_VENDOR_ID, HANDSPRING_VISOR_ID), | 55 | { USB_DEVICE(HANDSPRING_VENDOR_ID, HANDSPRING_VISOR_ID), |
59 | .driver_info = (kernel_ulong_t)&palm_os_3_probe }, | 56 | .driver_info = (kernel_ulong_t)&palm_os_3_probe }, |
@@ -310,8 +307,8 @@ static void visor_read_int_callback(struct urb *urb) | |||
310 | * Rumor has it this endpoint is used to notify when data | 307 | * Rumor has it this endpoint is used to notify when data |
311 | * is ready to be read from the bulk ones. | 308 | * is ready to be read from the bulk ones. |
312 | */ | 309 | */ |
313 | usb_serial_debug_data(debug, &port->dev, __func__, | 310 | usb_serial_debug_data(&port->dev, __func__, urb->actual_length, |
314 | urb->actual_length, urb->transfer_buffer); | 311 | urb->transfer_buffer); |
315 | 312 | ||
316 | exit: | 313 | exit: |
317 | result = usb_submit_urb(urb, GFP_ATOMIC); | 314 | result = usb_submit_urb(urb, GFP_ATOMIC); |
@@ -443,8 +440,7 @@ static int palm_os_4_probe(struct usb_serial *serial, | |||
443 | dev_err(dev, "%s - error %d getting connection info\n", | 440 | dev_err(dev, "%s - error %d getting connection info\n", |
444 | __func__, retval); | 441 | __func__, retval); |
445 | else | 442 | else |
446 | usb_serial_debug_data(debug, &serial->dev->dev, __func__, | 443 | usb_serial_debug_data(dev, __func__, retval, transfer_buffer); |
447 | retval, transfer_buffer); | ||
448 | 444 | ||
449 | kfree(transfer_buffer); | 445 | kfree(transfer_buffer); |
450 | return 0; | 446 | return 0; |
@@ -625,6 +621,3 @@ module_usb_serial_driver(serial_drivers, id_table_combined); | |||
625 | MODULE_AUTHOR(DRIVER_AUTHOR); | 621 | MODULE_AUTHOR(DRIVER_AUTHOR); |
626 | MODULE_DESCRIPTION(DRIVER_DESC); | 622 | MODULE_DESCRIPTION(DRIVER_DESC); |
627 | MODULE_LICENSE("GPL"); | 623 | MODULE_LICENSE("GPL"); |
628 | |||
629 | module_param(debug, bool, S_IRUGO | S_IWUSR); | ||
630 | MODULE_PARM_DESC(debug, "Debug enabled or not"); | ||
diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c index b36077de72b9..346c7efc20b0 100644 --- a/drivers/usb/serial/whiteheat.c +++ b/drivers/usb/serial/whiteheat.c | |||
@@ -32,12 +32,9 @@ | |||
32 | #include <linux/serial_reg.h> | 32 | #include <linux/serial_reg.h> |
33 | #include <linux/serial.h> | 33 | #include <linux/serial.h> |
34 | #include <linux/usb/serial.h> | 34 | #include <linux/usb/serial.h> |
35 | #include <linux/firmware.h> | 35 | #include <linux/usb/ezusb.h> |
36 | #include <linux/ihex.h> | ||
37 | #include "whiteheat.h" /* WhiteHEAT specific commands */ | 36 | #include "whiteheat.h" /* WhiteHEAT specific commands */ |
38 | 37 | ||
39 | static bool debug; | ||
40 | |||
41 | #ifndef CMSPAR | 38 | #ifndef CMSPAR |
42 | #define CMSPAR 0 | 39 | #define CMSPAR 0 |
43 | #endif | 40 | #endif |
@@ -195,84 +192,15 @@ static int firm_report_tx_done(struct usb_serial_port *port); | |||
195 | static int whiteheat_firmware_download(struct usb_serial *serial, | 192 | static int whiteheat_firmware_download(struct usb_serial *serial, |
196 | const struct usb_device_id *id) | 193 | const struct usb_device_id *id) |
197 | { | 194 | { |
198 | int response, ret = -ENOENT; | 195 | int response; |
199 | const struct firmware *loader_fw = NULL, *firmware_fw = NULL; | ||
200 | const struct ihex_binrec *record; | ||
201 | 196 | ||
202 | if (request_ihex_firmware(&firmware_fw, "whiteheat.fw", | 197 | response = ezusb_fx1_ihex_firmware_download(serial->dev, "whiteheat_loader.fw"); |
203 | &serial->dev->dev)) { | 198 | if (response >= 0) { |
204 | dev_err(&serial->dev->dev, | 199 | response = ezusb_fx1_ihex_firmware_download(serial->dev, "whiteheat.fw"); |
205 | "%s - request \"whiteheat.fw\" failed\n", __func__); | 200 | if (response >= 0) |
206 | goto out; | 201 | return 0; |
207 | } | ||
208 | if (request_ihex_firmware(&loader_fw, "whiteheat_loader.fw", | ||
209 | &serial->dev->dev)) { | ||
210 | dev_err(&serial->dev->dev, | ||
211 | "%s - request \"whiteheat_loader.fw\" failed\n", | ||
212 | __func__); | ||
213 | goto out; | ||
214 | } | 202 | } |
215 | ret = 0; | 203 | return -ENOENT; |
216 | response = ezusb_set_reset (serial, 1); | ||
217 | |||
218 | record = (const struct ihex_binrec *)loader_fw->data; | ||
219 | while (record) { | ||
220 | response = ezusb_writememory (serial, be32_to_cpu(record->addr), | ||
221 | (unsigned char *)record->data, | ||
222 | be16_to_cpu(record->len), 0xa0); | ||
223 | if (response < 0) { | ||
224 | dev_err(&serial->dev->dev, "%s - ezusb_writememory " | ||
225 | "failed for loader (%d %04X %p %d)\n", | ||
226 | __func__, response, be32_to_cpu(record->addr), | ||
227 | record->data, be16_to_cpu(record->len)); | ||
228 | break; | ||
229 | } | ||
230 | record = ihex_next_binrec(record); | ||
231 | } | ||
232 | |||
233 | response = ezusb_set_reset(serial, 0); | ||
234 | |||
235 | record = (const struct ihex_binrec *)firmware_fw->data; | ||
236 | while (record && be32_to_cpu(record->addr) < 0x1b40) | ||
237 | record = ihex_next_binrec(record); | ||
238 | while (record) { | ||
239 | response = ezusb_writememory (serial, be32_to_cpu(record->addr), | ||
240 | (unsigned char *)record->data, | ||
241 | be16_to_cpu(record->len), 0xa3); | ||
242 | if (response < 0) { | ||
243 | dev_err(&serial->dev->dev, "%s - ezusb_writememory " | ||
244 | "failed for first firmware step " | ||
245 | "(%d %04X %p %d)\n", __func__, response, | ||
246 | be32_to_cpu(record->addr), record->data, | ||
247 | be16_to_cpu(record->len)); | ||
248 | break; | ||
249 | } | ||
250 | ++record; | ||
251 | } | ||
252 | |||
253 | response = ezusb_set_reset(serial, 1); | ||
254 | |||
255 | record = (const struct ihex_binrec *)firmware_fw->data; | ||
256 | while (record && be32_to_cpu(record->addr) < 0x1b40) { | ||
257 | response = ezusb_writememory (serial, be32_to_cpu(record->addr), | ||
258 | (unsigned char *)record->data, | ||
259 | be16_to_cpu(record->len), 0xa0); | ||
260 | if (response < 0) { | ||
261 | dev_err(&serial->dev->dev, "%s - ezusb_writememory " | ||
262 | "failed for second firmware step " | ||
263 | "(%d %04X %p %d)\n", __func__, response, | ||
264 | be32_to_cpu(record->addr), record->data, | ||
265 | be16_to_cpu(record->len)); | ||
266 | break; | ||
267 | } | ||
268 | ++record; | ||
269 | } | ||
270 | ret = 0; | ||
271 | response = ezusb_set_reset (serial, 0); | ||
272 | out: | ||
273 | release_firmware(loader_fw); | ||
274 | release_firmware(firmware_fw); | ||
275 | return ret; | ||
276 | } | 204 | } |
277 | 205 | ||
278 | 206 | ||
@@ -533,7 +461,7 @@ static int whiteheat_ioctl(struct tty_struct *tty, | |||
533 | struct serial_struct serstruct; | 461 | struct serial_struct serstruct; |
534 | void __user *user_arg = (void __user *)arg; | 462 | void __user *user_arg = (void __user *)arg; |
535 | 463 | ||
536 | dbg("%s - port %d, cmd 0x%.4x", __func__, port->number, cmd); | 464 | dev_dbg(&port->dev, "%s - cmd 0x%.4x\n", __func__, cmd); |
537 | 465 | ||
538 | switch (cmd) { | 466 | switch (cmd) { |
539 | case TIOCGSERIAL: | 467 | case TIOCGSERIAL: |
@@ -580,7 +508,7 @@ static void command_port_write_callback(struct urb *urb) | |||
580 | int status = urb->status; | 508 | int status = urb->status; |
581 | 509 | ||
582 | if (status) { | 510 | if (status) { |
583 | dbg("nonzero urb status: %d", status); | 511 | dev_dbg(&urb->dev->dev, "nonzero urb status: %d\n", status); |
584 | return; | 512 | return; |
585 | } | 513 | } |
586 | } | 514 | } |
@@ -596,19 +524,18 @@ static void command_port_read_callback(struct urb *urb) | |||
596 | 524 | ||
597 | command_info = usb_get_serial_port_data(command_port); | 525 | command_info = usb_get_serial_port_data(command_port); |
598 | if (!command_info) { | 526 | if (!command_info) { |
599 | dbg("%s - command_info is NULL, exiting.", __func__); | 527 | dev_dbg(&urb->dev->dev, "%s - command_info is NULL, exiting.\n", __func__); |
600 | return; | 528 | return; |
601 | } | 529 | } |
602 | if (status) { | 530 | if (status) { |
603 | dbg("%s - nonzero urb status: %d", __func__, status); | 531 | dev_dbg(&urb->dev->dev, "%s - nonzero urb status: %d\n", __func__, status); |
604 | if (status != -ENOENT) | 532 | if (status != -ENOENT) |
605 | command_info->command_finished = WHITEHEAT_CMD_FAILURE; | 533 | command_info->command_finished = WHITEHEAT_CMD_FAILURE; |
606 | wake_up(&command_info->wait_command); | 534 | wake_up(&command_info->wait_command); |
607 | return; | 535 | return; |
608 | } | 536 | } |
609 | 537 | ||
610 | usb_serial_debug_data(debug, &command_port->dev, | 538 | usb_serial_debug_data(&command_port->dev, __func__, urb->actual_length, data); |
611 | __func__, urb->actual_length, data); | ||
612 | 539 | ||
613 | if (data[0] == WHITEHEAT_CMD_COMPLETE) { | 540 | if (data[0] == WHITEHEAT_CMD_COMPLETE) { |
614 | command_info->command_finished = WHITEHEAT_CMD_COMPLETE; | 541 | command_info->command_finished = WHITEHEAT_CMD_COMPLETE; |
@@ -619,19 +546,19 @@ static void command_port_read_callback(struct urb *urb) | |||
619 | } else if (data[0] == WHITEHEAT_EVENT) { | 546 | } else if (data[0] == WHITEHEAT_EVENT) { |
620 | /* These are unsolicited reports from the firmware, hence no | 547 | /* These are unsolicited reports from the firmware, hence no |
621 | waiting command to wakeup */ | 548 | waiting command to wakeup */ |
622 | dbg("%s - event received", __func__); | 549 | dev_dbg(&urb->dev->dev, "%s - event received\n", __func__); |
623 | } else if (data[0] == WHITEHEAT_GET_DTR_RTS) { | 550 | } else if (data[0] == WHITEHEAT_GET_DTR_RTS) { |
624 | memcpy(command_info->result_buffer, &data[1], | 551 | memcpy(command_info->result_buffer, &data[1], |
625 | urb->actual_length - 1); | 552 | urb->actual_length - 1); |
626 | command_info->command_finished = WHITEHEAT_CMD_COMPLETE; | 553 | command_info->command_finished = WHITEHEAT_CMD_COMPLETE; |
627 | wake_up(&command_info->wait_command); | 554 | wake_up(&command_info->wait_command); |
628 | } else | 555 | } else |
629 | dbg("%s - bad reply from firmware", __func__); | 556 | dev_dbg(&urb->dev->dev, "%s - bad reply from firmware\n", __func__); |
630 | 557 | ||
631 | /* Continue trying to always read */ | 558 | /* Continue trying to always read */ |
632 | result = usb_submit_urb(command_port->read_urb, GFP_ATOMIC); | 559 | result = usb_submit_urb(command_port->read_urb, GFP_ATOMIC); |
633 | if (result) | 560 | if (result) |
634 | dbg("%s - failed resubmitting read urb, error %d", | 561 | dev_dbg(&urb->dev->dev, "%s - failed resubmitting read urb, error %d\n", |
635 | __func__, result); | 562 | __func__, result); |
636 | } | 563 | } |
637 | 564 | ||
@@ -645,11 +572,12 @@ static int firm_send_command(struct usb_serial_port *port, __u8 command, | |||
645 | struct usb_serial_port *command_port; | 572 | struct usb_serial_port *command_port; |
646 | struct whiteheat_command_private *command_info; | 573 | struct whiteheat_command_private *command_info; |
647 | struct whiteheat_private *info; | 574 | struct whiteheat_private *info; |
575 | struct device *dev = &port->dev; | ||
648 | __u8 *transfer_buffer; | 576 | __u8 *transfer_buffer; |
649 | int retval = 0; | 577 | int retval = 0; |
650 | int t; | 578 | int t; |
651 | 579 | ||
652 | dbg("%s - command %d", __func__, command); | 580 | dev_dbg(dev, "%s - command %d\n", __func__, command); |
653 | 581 | ||
654 | command_port = port->serial->port[COMMAND_PORT]; | 582 | command_port = port->serial->port[COMMAND_PORT]; |
655 | command_info = usb_get_serial_port_data(command_port); | 583 | command_info = usb_get_serial_port_data(command_port); |
@@ -662,7 +590,7 @@ static int firm_send_command(struct usb_serial_port *port, __u8 command, | |||
662 | command_port->write_urb->transfer_buffer_length = datasize + 1; | 590 | command_port->write_urb->transfer_buffer_length = datasize + 1; |
663 | retval = usb_submit_urb(command_port->write_urb, GFP_NOIO); | 591 | retval = usb_submit_urb(command_port->write_urb, GFP_NOIO); |
664 | if (retval) { | 592 | if (retval) { |
665 | dbg("%s - submit urb failed", __func__); | 593 | dev_dbg(dev, "%s - submit urb failed\n", __func__); |
666 | goto exit; | 594 | goto exit; |
667 | } | 595 | } |
668 | 596 | ||
@@ -673,19 +601,19 @@ static int firm_send_command(struct usb_serial_port *port, __u8 command, | |||
673 | usb_kill_urb(command_port->write_urb); | 601 | usb_kill_urb(command_port->write_urb); |
674 | 602 | ||
675 | if (command_info->command_finished == false) { | 603 | if (command_info->command_finished == false) { |
676 | dbg("%s - command timed out.", __func__); | 604 | dev_dbg(dev, "%s - command timed out.\n", __func__); |
677 | retval = -ETIMEDOUT; | 605 | retval = -ETIMEDOUT; |
678 | goto exit; | 606 | goto exit; |
679 | } | 607 | } |
680 | 608 | ||
681 | if (command_info->command_finished == WHITEHEAT_CMD_FAILURE) { | 609 | if (command_info->command_finished == WHITEHEAT_CMD_FAILURE) { |
682 | dbg("%s - command failed.", __func__); | 610 | dev_dbg(dev, "%s - command failed.\n", __func__); |
683 | retval = -EIO; | 611 | retval = -EIO; |
684 | goto exit; | 612 | goto exit; |
685 | } | 613 | } |
686 | 614 | ||
687 | if (command_info->command_finished == WHITEHEAT_CMD_COMPLETE) { | 615 | if (command_info->command_finished == WHITEHEAT_CMD_COMPLETE) { |
688 | dbg("%s - command completed.", __func__); | 616 | dev_dbg(dev, "%s - command completed.\n", __func__); |
689 | switch (command) { | 617 | switch (command) { |
690 | case WHITEHEAT_GET_DTR_RTS: | 618 | case WHITEHEAT_GET_DTR_RTS: |
691 | info = usb_get_serial_port_data(port); | 619 | info = usb_get_serial_port_data(port); |
@@ -723,6 +651,7 @@ static int firm_close(struct usb_serial_port *port) | |||
723 | static void firm_setup_port(struct tty_struct *tty) | 651 | static void firm_setup_port(struct tty_struct *tty) |
724 | { | 652 | { |
725 | struct usb_serial_port *port = tty->driver_data; | 653 | struct usb_serial_port *port = tty->driver_data; |
654 | struct device *dev = &port->dev; | ||
726 | struct whiteheat_port_settings port_settings; | 655 | struct whiteheat_port_settings port_settings; |
727 | unsigned int cflag = tty->termios.c_cflag; | 656 | unsigned int cflag = tty->termios.c_cflag; |
728 | 657 | ||
@@ -736,7 +665,7 @@ static void firm_setup_port(struct tty_struct *tty) | |||
736 | default: | 665 | default: |
737 | case CS8: port_settings.bits = 8; break; | 666 | case CS8: port_settings.bits = 8; break; |
738 | } | 667 | } |
739 | dbg("%s - data bits = %d", __func__, port_settings.bits); | 668 | dev_dbg(dev, "%s - data bits = %d\n", __func__, port_settings.bits); |
740 | 669 | ||
741 | /* determine the parity */ | 670 | /* determine the parity */ |
742 | if (cflag & PARENB) | 671 | if (cflag & PARENB) |
@@ -752,14 +681,14 @@ static void firm_setup_port(struct tty_struct *tty) | |||
752 | port_settings.parity = WHITEHEAT_PAR_EVEN; | 681 | port_settings.parity = WHITEHEAT_PAR_EVEN; |
753 | else | 682 | else |
754 | port_settings.parity = WHITEHEAT_PAR_NONE; | 683 | port_settings.parity = WHITEHEAT_PAR_NONE; |
755 | dbg("%s - parity = %c", __func__, port_settings.parity); | 684 | dev_dbg(dev, "%s - parity = %c\n", __func__, port_settings.parity); |
756 | 685 | ||
757 | /* figure out the stop bits requested */ | 686 | /* figure out the stop bits requested */ |
758 | if (cflag & CSTOPB) | 687 | if (cflag & CSTOPB) |
759 | port_settings.stop = 2; | 688 | port_settings.stop = 2; |
760 | else | 689 | else |
761 | port_settings.stop = 1; | 690 | port_settings.stop = 1; |
762 | dbg("%s - stop bits = %d", __func__, port_settings.stop); | 691 | dev_dbg(dev, "%s - stop bits = %d\n", __func__, port_settings.stop); |
763 | 692 | ||
764 | /* figure out the flow control settings */ | 693 | /* figure out the flow control settings */ |
765 | if (cflag & CRTSCTS) | 694 | if (cflag & CRTSCTS) |
@@ -767,7 +696,7 @@ static void firm_setup_port(struct tty_struct *tty) | |||
767 | WHITEHEAT_HFLOW_RTS); | 696 | WHITEHEAT_HFLOW_RTS); |
768 | else | 697 | else |
769 | port_settings.hflow = WHITEHEAT_HFLOW_NONE; | 698 | port_settings.hflow = WHITEHEAT_HFLOW_NONE; |
770 | dbg("%s - hardware flow control = %s %s %s %s", __func__, | 699 | dev_dbg(dev, "%s - hardware flow control = %s %s %s %s\n", __func__, |
771 | (port_settings.hflow & WHITEHEAT_HFLOW_CTS) ? "CTS" : "", | 700 | (port_settings.hflow & WHITEHEAT_HFLOW_CTS) ? "CTS" : "", |
772 | (port_settings.hflow & WHITEHEAT_HFLOW_RTS) ? "RTS" : "", | 701 | (port_settings.hflow & WHITEHEAT_HFLOW_RTS) ? "RTS" : "", |
773 | (port_settings.hflow & WHITEHEAT_HFLOW_DSR) ? "DSR" : "", | 702 | (port_settings.hflow & WHITEHEAT_HFLOW_DSR) ? "DSR" : "", |
@@ -778,16 +707,15 @@ static void firm_setup_port(struct tty_struct *tty) | |||
778 | port_settings.sflow = WHITEHEAT_SFLOW_RXTX; | 707 | port_settings.sflow = WHITEHEAT_SFLOW_RXTX; |
779 | else | 708 | else |
780 | port_settings.sflow = WHITEHEAT_SFLOW_NONE; | 709 | port_settings.sflow = WHITEHEAT_SFLOW_NONE; |
781 | dbg("%s - software flow control = %c", __func__, port_settings.sflow); | 710 | dev_dbg(dev, "%s - software flow control = %c\n", __func__, port_settings.sflow); |
782 | 711 | ||
783 | port_settings.xon = START_CHAR(tty); | 712 | port_settings.xon = START_CHAR(tty); |
784 | port_settings.xoff = STOP_CHAR(tty); | 713 | port_settings.xoff = STOP_CHAR(tty); |
785 | dbg("%s - XON = %2x, XOFF = %2x", | 714 | dev_dbg(dev, "%s - XON = %2x, XOFF = %2x\n", __func__, port_settings.xon, port_settings.xoff); |
786 | __func__, port_settings.xon, port_settings.xoff); | ||
787 | 715 | ||
788 | /* get the baud rate wanted */ | 716 | /* get the baud rate wanted */ |
789 | port_settings.baud = tty_get_baud_rate(tty); | 717 | port_settings.baud = tty_get_baud_rate(tty); |
790 | dbg("%s - baud rate = %d", __func__, port_settings.baud); | 718 | dev_dbg(dev, "%s - baud rate = %d\n", __func__, port_settings.baud); |
791 | 719 | ||
792 | /* fixme: should set validated settings */ | 720 | /* fixme: should set validated settings */ |
793 | tty_encode_baud_rate(tty, port_settings.baud, port_settings.baud); | 721 | tty_encode_baud_rate(tty, port_settings.baud, port_settings.baud); |
@@ -918,6 +846,3 @@ MODULE_LICENSE("GPL"); | |||
918 | 846 | ||
919 | MODULE_FIRMWARE("whiteheat.fw"); | 847 | MODULE_FIRMWARE("whiteheat.fw"); |
920 | MODULE_FIRMWARE("whiteheat_loader.fw"); | 848 | MODULE_FIRMWARE("whiteheat_loader.fw"); |
921 | |||
922 | module_param(debug, bool, S_IRUGO | S_IWUSR); | ||
923 | MODULE_PARM_DESC(debug, "Debug enabled or not"); | ||
diff --git a/drivers/usb/serial/zte_ev.c b/drivers/usb/serial/zte_ev.c new file mode 100644 index 000000000000..39ee7373b4ee --- /dev/null +++ b/drivers/usb/serial/zte_ev.c | |||
@@ -0,0 +1,307 @@ | |||
1 | /* | ||
2 | * ZTE_EV USB serial driver | ||
3 | * | ||
4 | * Copyright (C) 2012 Greg Kroah-Hartman <gregkh@linuxfoundation.org> | ||
5 | * Copyright (C) 2012 Linux Foundation | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 as | ||
9 | * published by the Free Software Foundation. | ||
10 | * | ||
11 | * This driver is based on code found in a ZTE_ENV patch that modified | ||
12 | * the usb-serial generic driver. Comments were left in that I think | ||
13 | * show the commands used to talk to the device, but I am not sure. | ||
14 | */ | ||
15 | #include <linux/kernel.h> | ||
16 | #include <linux/init.h> | ||
17 | #include <linux/tty.h> | ||
18 | #include <linux/slab.h> | ||
19 | #include <linux/module.h> | ||
20 | #include <linux/usb.h> | ||
21 | #include <linux/usb/serial.h> | ||
22 | #include <linux/uaccess.h> | ||
23 | |||
24 | #define MAX_SETUP_DATA_SIZE 32 | ||
25 | |||
26 | static void debug_data(struct device *dev, const char *function, int len, | ||
27 | const unsigned char *data, int result) | ||
28 | { | ||
29 | dev_dbg(dev, "result = %d\n", result); | ||
30 | if (result == len) | ||
31 | dev_dbg(dev, "%s - length = %d, data = %*ph\n", function, | ||
32 | len, len, data); | ||
33 | } | ||
34 | |||
35 | static int zte_ev_usb_serial_open(struct tty_struct *tty, | ||
36 | struct usb_serial_port *port) | ||
37 | { | ||
38 | struct usb_device *udev = port->serial->dev; | ||
39 | struct device *dev = &port->dev; | ||
40 | int result = 0; | ||
41 | int len; | ||
42 | unsigned char *buf; | ||
43 | |||
44 | if (port->number != 0) | ||
45 | return -ENODEV; | ||
46 | |||
47 | buf = kmalloc(MAX_SETUP_DATA_SIZE, GFP_KERNEL); | ||
48 | if (!buf) | ||
49 | return -ENOMEM; | ||
50 | |||
51 | /* send 1st ctl cmd(CTL 21 22 01 00 00 00 00 00) */ | ||
52 | len = 0; | ||
53 | result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), | ||
54 | 0x22, 0x21, | ||
55 | 0x0001, 0x0000, NULL, len, | ||
56 | HZ * USB_CTRL_GET_TIMEOUT); | ||
57 | dev_dbg(dev, "result = %d\n", result); | ||
58 | |||
59 | /* send 2st cmd and recieve data */ | ||
60 | /* | ||
61 | * 16.0 CTL a1 21 00 00 00 00 07 00 CLASS 25.1.0(5) | ||
62 | * 16.0 DI 00 96 00 00 00 00 08 | ||
63 | */ | ||
64 | len = 0x0007; | ||
65 | result = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), | ||
66 | 0x21, 0xa1, | ||
67 | 0x0000, 0x0000, buf, len, | ||
68 | HZ * USB_CTRL_GET_TIMEOUT); | ||
69 | debug_data(dev, __func__, len, buf, result); | ||
70 | |||
71 | /* send 3 cmd */ | ||
72 | /* | ||
73 | * 16.0 CTL 21 20 00 00 00 00 07 00 CLASS 30.1.0 | ||
74 | * 16.0 DO 80 25 00 00 00 00 08 .%..... 30.2.0 | ||
75 | */ | ||
76 | len = 0x0007; | ||
77 | buf[0] = 0x80; | ||
78 | buf[1] = 0x25; | ||
79 | buf[2] = 0x00; | ||
80 | buf[3] = 0x00; | ||
81 | buf[4] = 0x00; | ||
82 | buf[5] = 0x00; | ||
83 | buf[6] = 0x08; | ||
84 | result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), | ||
85 | 0x20, 0x21, | ||
86 | 0x0000, 0x0000, buf, len, | ||
87 | HZ * USB_CTRL_GET_TIMEOUT); | ||
88 | debug_data(dev, __func__, len, buf, result); | ||
89 | |||
90 | /* send 4 cmd */ | ||
91 | /* | ||
92 | * 16.0 CTL 21 22 03 00 00 00 00 00 | ||
93 | */ | ||
94 | len = 0; | ||
95 | result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), | ||
96 | 0x22, 0x21, | ||
97 | 0x0003, 0x0000, NULL, len, | ||
98 | HZ * USB_CTRL_GET_TIMEOUT); | ||
99 | dev_dbg(dev, "result = %d\n", result); | ||
100 | |||
101 | /* send 5 cmd */ | ||
102 | /* | ||
103 | * 16.0 CTL a1 21 00 00 00 00 07 00 CLASS 33.1.0 | ||
104 | * 16.0 DI 80 25 00 00 00 00 08 | ||
105 | */ | ||
106 | len = 0x0007; | ||
107 | result = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), | ||
108 | 0x21, 0xa1, | ||
109 | 0x0000, 0x0000, buf, len, | ||
110 | HZ * USB_CTRL_GET_TIMEOUT); | ||
111 | debug_data(dev, __func__, len, buf, result); | ||
112 | |||
113 | /* send 6 cmd */ | ||
114 | /* | ||
115 | * 16.0 CTL 21 20 00 00 00 00 07 00 CLASS 34.1.0 | ||
116 | * 16.0 DO 80 25 00 00 00 00 08 | ||
117 | */ | ||
118 | len = 0x0007; | ||
119 | buf[0] = 0x80; | ||
120 | buf[1] = 0x25; | ||
121 | buf[2] = 0x00; | ||
122 | buf[3] = 0x00; | ||
123 | buf[4] = 0x00; | ||
124 | buf[5] = 0x00; | ||
125 | buf[6] = 0x08; | ||
126 | result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), | ||
127 | 0x20, 0x21, | ||
128 | 0x0000, 0x0000, buf, len, | ||
129 | HZ * USB_CTRL_GET_TIMEOUT); | ||
130 | debug_data(dev, __func__, len, buf, result); | ||
131 | kfree(buf); | ||
132 | |||
133 | return usb_serial_generic_open(tty, port); | ||
134 | } | ||
135 | |||
136 | /* | ||
137 | * CTL 21 22 02 00 00 00 00 00 CLASS 338.1.0 | ||
138 | * | ||
139 | * 16.1 DI a1 20 00 00 00 00 02 00 02 00 . ........ 340.1.0 | ||
140 | * 16.0 CTL 21 22 03 00 00 00 00 00 CLASS 341.1.0 | ||
141 | * | ||
142 | * 16.0 CTL a1 21 00 00 00 00 07 00 CLASS 346.1.0(3) | ||
143 | * 16.0 DI 00 08 07 00 00 00 08 ....... 346.2.0 | ||
144 | * | ||
145 | * 16.0 CTL 21 20 00 00 00 00 07 00 CLASS 349.1.0 | ||
146 | * 16.0 DO 00 c2 01 00 00 00 08 ....... 349.2.0 | ||
147 | * | ||
148 | * 16.0 CTL 21 22 03 00 00 00 00 00 CLASS 350.1.0(2) | ||
149 | * | ||
150 | * 16.0 CTL a1 21 00 00 00 00 07 00 CLASS 352.1.0 | ||
151 | * 16.0 DI 00 c2 01 00 00 00 08 ....... 352.2.0 | ||
152 | * | ||
153 | * 16.1 DI a1 20 00 00 00 00 02 00 02 00 . ........ 353.1.0 | ||
154 | * | ||
155 | * 16.0 CTL 21 20 00 00 00 00 07 00 CLASS 354.1.0 | ||
156 | * 16.0 DO 00 c2 01 00 00 00 08 ....... 354.2.0 | ||
157 | * | ||
158 | * 16.0 CTL 21 22 03 00 00 00 00 00 | ||
159 | */ | ||
160 | |||
161 | static void zte_ev_usb_serial_close(struct usb_serial_port *port) | ||
162 | { | ||
163 | struct usb_device *udev = port->serial->dev; | ||
164 | struct device *dev = &port->dev; | ||
165 | int result = 0; | ||
166 | int len; | ||
167 | unsigned char *buf; | ||
168 | |||
169 | if (port->number != 0) | ||
170 | return; | ||
171 | |||
172 | buf = kmalloc(MAX_SETUP_DATA_SIZE, GFP_KERNEL); | ||
173 | if (!buf) | ||
174 | return; | ||
175 | |||
176 | /* send 1st ctl cmd(CTL 21 22 02 00 00 00 00 00) */ | ||
177 | len = 0; | ||
178 | result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), | ||
179 | 0x22, 0x21, | ||
180 | 0x0002, 0x0000, NULL, len, | ||
181 | HZ * USB_CTRL_GET_TIMEOUT); | ||
182 | dev_dbg(dev, "result = %d\n", result); | ||
183 | |||
184 | /* send 2st ctl cmd(CTL 21 22 03 00 00 00 00 00 ) */ | ||
185 | len = 0; | ||
186 | result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), | ||
187 | 0x22, 0x21, | ||
188 | 0x0003, 0x0000, NULL, len, | ||
189 | HZ * USB_CTRL_GET_TIMEOUT); | ||
190 | dev_dbg(dev, "result = %d\n", result); | ||
191 | |||
192 | /* send 3st cmd and recieve data */ | ||
193 | /* | ||
194 | * 16.0 CTL a1 21 00 00 00 00 07 00 CLASS 25.1.0(5) | ||
195 | * 16.0 DI 00 08 07 00 00 00 08 | ||
196 | */ | ||
197 | len = 0x0007; | ||
198 | result = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), | ||
199 | 0x21, 0xa1, | ||
200 | 0x0000, 0x0000, buf, len, | ||
201 | HZ * USB_CTRL_GET_TIMEOUT); | ||
202 | debug_data(dev, __func__, len, buf, result); | ||
203 | |||
204 | /* send 4 cmd */ | ||
205 | /* | ||
206 | * 16.0 CTL 21 20 00 00 00 00 07 00 CLASS 30.1.0 | ||
207 | * 16.0 DO 00 c2 01 00 00 00 08 .%..... 30.2.0 | ||
208 | */ | ||
209 | len = 0x0007; | ||
210 | buf[0] = 0x00; | ||
211 | buf[1] = 0xc2; | ||
212 | buf[2] = 0x01; | ||
213 | buf[3] = 0x00; | ||
214 | buf[4] = 0x00; | ||
215 | buf[5] = 0x00; | ||
216 | buf[6] = 0x08; | ||
217 | result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), | ||
218 | 0x20, 0x21, | ||
219 | 0x0000, 0x0000, buf, len, | ||
220 | HZ * USB_CTRL_GET_TIMEOUT); | ||
221 | debug_data(dev, __func__, len, buf, result); | ||
222 | |||
223 | /* send 5 cmd */ | ||
224 | /* | ||
225 | * 16.0 CTL 21 22 03 00 00 00 00 00 | ||
226 | */ | ||
227 | len = 0; | ||
228 | result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), | ||
229 | 0x22, 0x21, | ||
230 | 0x0003, 0x0000, NULL, len, | ||
231 | HZ * USB_CTRL_GET_TIMEOUT); | ||
232 | dev_dbg(dev, "result = %d\n", result); | ||
233 | |||
234 | /* send 6 cmd */ | ||
235 | /* | ||
236 | * 16.0 CTL a1 21 00 00 00 00 07 00 CLASS 33.1.0 | ||
237 | * 16.0 DI 00 c2 01 00 00 00 08 | ||
238 | */ | ||
239 | len = 0x0007; | ||
240 | result = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), | ||
241 | 0x21, 0xa1, | ||
242 | 0x0000, 0x0000, buf, len, | ||
243 | HZ * USB_CTRL_GET_TIMEOUT); | ||
244 | debug_data(dev, __func__, len, buf, result); | ||
245 | |||
246 | /* send 7 cmd */ | ||
247 | /* | ||
248 | * 16.0 CTL 21 20 00 00 00 00 07 00 CLASS 354.1.0 | ||
249 | * 16.0 DO 00 c2 01 00 00 00 08 ....... 354.2.0 | ||
250 | */ | ||
251 | len = 0x0007; | ||
252 | buf[0] = 0x00; | ||
253 | buf[1] = 0xc2; | ||
254 | buf[2] = 0x01; | ||
255 | buf[3] = 0x00; | ||
256 | buf[4] = 0x00; | ||
257 | buf[5] = 0x00; | ||
258 | buf[6] = 0x08; | ||
259 | result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), | ||
260 | 0x20, 0x21, | ||
261 | 0x0000, 0x0000, buf, len, | ||
262 | HZ * USB_CTRL_GET_TIMEOUT); | ||
263 | debug_data(dev, __func__, len, buf, result); | ||
264 | |||
265 | /* send 8 cmd */ | ||
266 | /* | ||
267 | * 16.0 CTL 21 22 03 00 00 00 00 00 | ||
268 | */ | ||
269 | len = 0; | ||
270 | result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), | ||
271 | 0x22, 0x21, | ||
272 | 0x0003, 0x0000, NULL, len, | ||
273 | HZ * USB_CTRL_GET_TIMEOUT); | ||
274 | dev_dbg(dev, "result = %d\n", result); | ||
275 | |||
276 | kfree(buf); | ||
277 | |||
278 | usb_serial_generic_close(port); | ||
279 | } | ||
280 | |||
281 | static const struct usb_device_id id_table[] = { | ||
282 | { USB_DEVICE(0x19d2, 0xffff) }, /* AC8700 */ | ||
283 | { USB_DEVICE(0x19d2, 0xfffe) }, | ||
284 | { USB_DEVICE(0x19d2, 0xfffd) }, /* MG880 */ | ||
285 | { USB_DEVICE(0x05C6, 0x3197) }, | ||
286 | { USB_DEVICE(0x05C6, 0x6000) }, | ||
287 | { }, | ||
288 | }; | ||
289 | MODULE_DEVICE_TABLE(usb, id_table); | ||
290 | |||
291 | static struct usb_serial_driver zio_device = { | ||
292 | .driver = { | ||
293 | .owner = THIS_MODULE, | ||
294 | .name = "zte_ev", | ||
295 | }, | ||
296 | .id_table = id_table, | ||
297 | .num_ports = 1, | ||
298 | .open = zte_ev_usb_serial_open, | ||
299 | .close = zte_ev_usb_serial_close, | ||
300 | }; | ||
301 | |||
302 | static struct usb_serial_driver * const serial_drivers[] = { | ||
303 | &zio_device, NULL | ||
304 | }; | ||
305 | |||
306 | module_usb_serial_driver(serial_drivers, id_table); | ||
307 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/usb/storage/Kconfig b/drivers/usb/storage/Kconfig index 7691c866637b..0ae7bb64b5ea 100644 --- a/drivers/usb/storage/Kconfig +++ b/drivers/usb/storage/Kconfig | |||
@@ -213,17 +213,3 @@ config USB_UAS | |||
213 | say 'Y' or 'M' here and the kernel will use the right driver. | 213 | say 'Y' or 'M' here and the kernel will use the right driver. |
214 | 214 | ||
215 | If you compile this driver as a module, it will be named uas. | 215 | If you compile this driver as a module, it will be named uas. |
216 | |||
217 | config USB_LIBUSUAL | ||
218 | bool "The shared table of common (or usual) storage devices" | ||
219 | depends on USB | ||
220 | help | ||
221 | This module contains a table of common (or usual) devices | ||
222 | for usb-storage and ub drivers, and allows to switch binding | ||
223 | of these devices without rebuilding modules. | ||
224 | |||
225 | Typical syntax of /etc/modprobe.d/*conf is: | ||
226 | |||
227 | options libusual bias="ub" | ||
228 | |||
229 | If unsure, say N. | ||
diff --git a/drivers/usb/storage/Makefile b/drivers/usb/storage/Makefile index 82e6416a2d47..4cd55481b309 100644 --- a/drivers/usb/storage/Makefile +++ b/drivers/usb/storage/Makefile | |||
@@ -12,16 +12,9 @@ obj-$(CONFIG_USB_STORAGE) += usb-storage.o | |||
12 | 12 | ||
13 | usb-storage-y := scsiglue.o protocol.o transport.o usb.o | 13 | usb-storage-y := scsiglue.o protocol.o transport.o usb.o |
14 | usb-storage-y += initializers.o sierra_ms.o option_ms.o | 14 | usb-storage-y += initializers.o sierra_ms.o option_ms.o |
15 | 15 | usb-storage-y += usual-tables.o | |
16 | usb-storage-$(CONFIG_USB_STORAGE_DEBUG) += debug.o | 16 | usb-storage-$(CONFIG_USB_STORAGE_DEBUG) += debug.o |
17 | 17 | ||
18 | ifeq ($(CONFIG_USB_LIBUSUAL),) | ||
19 | usb-storage-y += usual-tables.o | ||
20 | else | ||
21 | obj-$(CONFIG_USB) += usb-libusual.o | ||
22 | usb-libusual-y := libusual.o usual-tables.o | ||
23 | endif | ||
24 | |||
25 | obj-$(CONFIG_USB_STORAGE_ALAUDA) += ums-alauda.o | 18 | obj-$(CONFIG_USB_STORAGE_ALAUDA) += ums-alauda.o |
26 | obj-$(CONFIG_USB_STORAGE_CYPRESS_ATACB) += ums-cypress.o | 19 | obj-$(CONFIG_USB_STORAGE_CYPRESS_ATACB) += ums-cypress.o |
27 | obj-$(CONFIG_USB_STORAGE_DATAFAB) += ums-datafab.o | 20 | obj-$(CONFIG_USB_STORAGE_DATAFAB) += ums-datafab.o |
diff --git a/drivers/usb/storage/alauda.c b/drivers/usb/storage/alauda.c index bab8c8fe8290..be5564cc8e01 100644 --- a/drivers/usb/storage/alauda.c +++ b/drivers/usb/storage/alauda.c | |||
@@ -137,7 +137,7 @@ static int init_alauda(struct us_data *us); | |||
137 | vendorName, productName, useProtocol, useTransport, \ | 137 | vendorName, productName, useProtocol, useTransport, \ |
138 | initFunction, flags) \ | 138 | initFunction, flags) \ |
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) } |
141 | 141 | ||
142 | static 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" |
diff --git a/drivers/usb/storage/cypress_atacb.c b/drivers/usb/storage/cypress_atacb.c index 5fe451d16e68..070b5c0ebbf9 100644 --- a/drivers/usb/storage/cypress_atacb.c +++ b/drivers/usb/storage/cypress_atacb.c | |||
@@ -41,7 +41,7 @@ MODULE_LICENSE("GPL"); | |||
41 | vendorName, productName, useProtocol, useTransport, \ | 41 | vendorName, productName, useProtocol, useTransport, \ |
42 | initFunction, flags) \ | 42 | initFunction, flags) \ |
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) } |
45 | 45 | ||
46 | static 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" |
diff --git a/drivers/usb/storage/datafab.c b/drivers/usb/storage/datafab.c index 35e9c51e6696..494fee5af41d 100644 --- a/drivers/usb/storage/datafab.c +++ b/drivers/usb/storage/datafab.c | |||
@@ -86,7 +86,7 @@ static int datafab_determine_lun(struct us_data *us, | |||
86 | vendorName, productName, useProtocol, useTransport, \ | 86 | vendorName, productName, useProtocol, useTransport, \ |
87 | initFunction, flags) \ | 87 | initFunction, flags) \ |
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) } |
90 | 90 | ||
91 | static 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" |
diff --git a/drivers/usb/storage/ene_ub6250.c b/drivers/usb/storage/ene_ub6250.c index b28f2ad127d4..118b134a1dad 100644 --- a/drivers/usb/storage/ene_ub6250.c +++ b/drivers/usb/storage/ene_ub6250.c | |||
@@ -29,9 +29,21 @@ | |||
29 | #include "protocol.h" | 29 | #include "protocol.h" |
30 | #include "debug.h" | 30 | #include "debug.h" |
31 | 31 | ||
32 | #define SD_INIT1_FIRMWARE "ene-ub6250/sd_init1.bin" | ||
33 | #define SD_INIT2_FIRMWARE "ene-ub6250/sd_init2.bin" | ||
34 | #define SD_RW_FIRMWARE "ene-ub6250/sd_rdwr.bin" | ||
35 | #define MS_INIT_FIRMWARE "ene-ub6250/ms_init.bin" | ||
36 | #define MSP_RW_FIRMWARE "ene-ub6250/msp_rdwr.bin" | ||
37 | #define MS_RW_FIRMWARE "ene-ub6250/ms_rdwr.bin" | ||
38 | |||
32 | MODULE_DESCRIPTION("Driver for ENE UB6250 reader"); | 39 | MODULE_DESCRIPTION("Driver for ENE UB6250 reader"); |
33 | MODULE_LICENSE("GPL"); | 40 | MODULE_LICENSE("GPL"); |
34 | 41 | MODULE_FIRMWARE(SD_INIT1_FIRMWARE); | |
42 | MODULE_FIRMWARE(SD_INIT2_FIRMWARE); | ||
43 | MODULE_FIRMWARE(SD_RW_FIRMWARE); | ||
44 | MODULE_FIRMWARE(MS_INIT_FIRMWARE); | ||
45 | MODULE_FIRMWARE(MSP_RW_FIRMWARE); | ||
46 | MODULE_FIRMWARE(MS_RW_FIRMWARE); | ||
35 | 47 | ||
36 | /* | 48 | /* |
37 | * The table of devices | 49 | * The table of devices |
@@ -40,7 +52,7 @@ MODULE_LICENSE("GPL"); | |||
40 | vendorName, productName, useProtocol, useTransport, \ | 52 | vendorName, productName, useProtocol, useTransport, \ |
41 | initFunction, flags) \ | 53 | initFunction, flags) \ |
42 | { USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \ | 54 | { USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \ |
43 | .driver_info = (flags)|(USB_US_TYPE_STOR<<24) } | 55 | .driver_info = (flags)} |
44 | 56 | ||
45 | static struct usb_device_id ene_ub6250_usb_ids[] = { | 57 | static struct usb_device_id ene_ub6250_usb_ids[] = { |
46 | # include "unusual_ene_ub6250.h" | 58 | # include "unusual_ene_ub6250.h" |
@@ -1883,28 +1895,28 @@ static int ene_load_bincode(struct us_data *us, unsigned char flag) | |||
1883 | /* For SD */ | 1895 | /* For SD */ |
1884 | case SD_INIT1_PATTERN: | 1896 | case SD_INIT1_PATTERN: |
1885 | US_DEBUGP("SD_INIT1_PATTERN\n"); | 1897 | US_DEBUGP("SD_INIT1_PATTERN\n"); |
1886 | fw_name = "ene-ub6250/sd_init1.bin"; | 1898 | fw_name = SD_INIT1_FIRMWARE; |
1887 | break; | 1899 | break; |
1888 | case SD_INIT2_PATTERN: | 1900 | case SD_INIT2_PATTERN: |
1889 | US_DEBUGP("SD_INIT2_PATTERN\n"); | 1901 | US_DEBUGP("SD_INIT2_PATTERN\n"); |
1890 | fw_name = "ene-ub6250/sd_init2.bin"; | 1902 | fw_name = SD_INIT2_FIRMWARE; |
1891 | break; | 1903 | break; |
1892 | case SD_RW_PATTERN: | 1904 | case SD_RW_PATTERN: |
1893 | US_DEBUGP("SD_RDWR_PATTERN\n"); | 1905 | US_DEBUGP("SD_RW_PATTERN\n"); |
1894 | fw_name = "ene-ub6250/sd_rdwr.bin"; | 1906 | fw_name = SD_RW_FIRMWARE; |
1895 | break; | 1907 | break; |
1896 | /* For MS */ | 1908 | /* For MS */ |
1897 | case MS_INIT_PATTERN: | 1909 | case MS_INIT_PATTERN: |
1898 | US_DEBUGP("MS_INIT_PATTERN\n"); | 1910 | US_DEBUGP("MS_INIT_PATTERN\n"); |
1899 | fw_name = "ene-ub6250/ms_init.bin"; | 1911 | fw_name = MS_INIT_FIRMWARE; |
1900 | break; | 1912 | break; |
1901 | case MSP_RW_PATTERN: | 1913 | case MSP_RW_PATTERN: |
1902 | US_DEBUGP("MSP_RW_PATTERN\n"); | 1914 | US_DEBUGP("MSP_RW_PATTERN\n"); |
1903 | fw_name = "ene-ub6250/msp_rdwr.bin"; | 1915 | fw_name = MSP_RW_FIRMWARE; |
1904 | break; | 1916 | break; |
1905 | case MS_RW_PATTERN: | 1917 | case MS_RW_PATTERN: |
1906 | US_DEBUGP("MS_RW_PATTERN\n"); | 1918 | US_DEBUGP("MS_RW_PATTERN\n"); |
1907 | fw_name = "ene-ub6250/ms_rdwr.bin"; | 1919 | fw_name = MS_RW_FIRMWARE; |
1908 | break; | 1920 | break; |
1909 | default: | 1921 | default: |
1910 | US_DEBUGP("----------- Unknown PATTERN ----------\n"); | 1922 | US_DEBUGP("----------- Unknown PATTERN ----------\n"); |
diff --git a/drivers/usb/storage/freecom.c b/drivers/usb/storage/freecom.c index 042cf9ef3153..e6df087dca9d 100644 --- a/drivers/usb/storage/freecom.c +++ b/drivers/usb/storage/freecom.c | |||
@@ -117,7 +117,7 @@ static int init_freecom(struct us_data *us); | |||
117 | vendorName, productName, useProtocol, useTransport, \ | 117 | vendorName, productName, useProtocol, useTransport, \ |
118 | initFunction, flags) \ | 118 | initFunction, flags) \ |
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) } |
121 | 121 | ||
122 | static 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" |
diff --git a/drivers/usb/storage/isd200.c b/drivers/usb/storage/isd200.c index 31fa24e7e68a..ecea47877364 100644 --- a/drivers/usb/storage/isd200.c +++ b/drivers/usb/storage/isd200.c | |||
@@ -74,7 +74,7 @@ static int isd200_Initialization(struct us_data *us); | |||
74 | vendorName, productName, useProtocol, useTransport, \ | 74 | vendorName, productName, useProtocol, useTransport, \ |
75 | initFunction, flags) \ | 75 | initFunction, flags) \ |
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) } |
78 | 78 | ||
79 | static 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" |
@@ -83,7 +83,6 @@ static struct usb_device_id isd200_usb_ids[] = { | |||
83 | MODULE_DEVICE_TABLE(usb, isd200_usb_ids); | 83 | MODULE_DEVICE_TABLE(usb, isd200_usb_ids); |
84 | 84 | ||
85 | #undef UNUSUAL_DEV | 85 | #undef UNUSUAL_DEV |
86 | #undef USUAL_DEV | ||
87 | 86 | ||
88 | /* | 87 | /* |
89 | * The flags table | 88 | * The flags table |
@@ -105,8 +104,6 @@ static struct us_unusual_dev isd200_unusual_dev_list[] = { | |||
105 | }; | 104 | }; |
106 | 105 | ||
107 | #undef UNUSUAL_DEV | 106 | #undef UNUSUAL_DEV |
108 | #undef USUAL_DEV | ||
109 | |||
110 | 107 | ||
111 | /* Timeout defines (in Seconds) */ | 108 | /* Timeout defines (in Seconds) */ |
112 | 109 | ||
diff --git a/drivers/usb/storage/jumpshot.c b/drivers/usb/storage/jumpshot.c index e3b97383186a..ddc78780b1ad 100644 --- a/drivers/usb/storage/jumpshot.c +++ b/drivers/usb/storage/jumpshot.c | |||
@@ -69,7 +69,7 @@ MODULE_LICENSE("GPL"); | |||
69 | vendorName, productName, useProtocol, useTransport, \ | 69 | vendorName, productName, useProtocol, useTransport, \ |
70 | initFunction, flags) \ | 70 | initFunction, flags) \ |
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) } |
73 | 73 | ||
74 | static 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" |
diff --git a/drivers/usb/storage/karma.c b/drivers/usb/storage/karma.c index a8708eae9788..f085ffb606c8 100644 --- a/drivers/usb/storage/karma.c +++ b/drivers/usb/storage/karma.c | |||
@@ -57,7 +57,7 @@ static int rio_karma_init(struct us_data *us); | |||
57 | vendorName, productName, useProtocol, useTransport, \ | 57 | vendorName, productName, useProtocol, useTransport, \ |
58 | initFunction, flags) \ | 58 | initFunction, flags) \ |
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) } |
61 | 61 | ||
62 | static 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" |
diff --git a/drivers/usb/storage/libusual.c b/drivers/usb/storage/libusual.c deleted file mode 100644 index fe3ffe1459b2..000000000000 --- a/drivers/usb/storage/libusual.c +++ /dev/null | |||
@@ -1,243 +0,0 @@ | |||
1 | /* | ||
2 | * libusual | ||
3 | * | ||
4 | * The libusual contains the table of devices common for ub and usb-storage. | ||
5 | */ | ||
6 | #include <linux/kernel.h> | ||
7 | #include <linux/module.h> | ||
8 | #include <linux/usb.h> | ||
9 | #include <linux/usb_usual.h> | ||
10 | #include <linux/vmalloc.h> | ||
11 | #include <linux/kthread.h> | ||
12 | #include <linux/mutex.h> | ||
13 | |||
14 | /* | ||
15 | */ | ||
16 | #define USU_MOD_FL_THREAD 1 /* Thread is running */ | ||
17 | #define USU_MOD_FL_PRESENT 2 /* The module is loaded */ | ||
18 | |||
19 | struct mod_status { | ||
20 | unsigned long fls; | ||
21 | }; | ||
22 | |||
23 | static struct mod_status stat[3]; | ||
24 | static DEFINE_SPINLOCK(usu_lock); | ||
25 | |||
26 | /* | ||
27 | */ | ||
28 | #define USB_US_DEFAULT_BIAS USB_US_TYPE_STOR | ||
29 | static atomic_t usu_bias = ATOMIC_INIT(USB_US_DEFAULT_BIAS); | ||
30 | |||
31 | #define BIAS_NAME_SIZE (sizeof("usb-storage")) | ||
32 | static const char *bias_names[3] = { "none", "usb-storage", "ub" }; | ||
33 | |||
34 | static DEFINE_MUTEX(usu_probe_mutex); | ||
35 | static DECLARE_COMPLETION(usu_end_notify); | ||
36 | static atomic_t total_threads = ATOMIC_INIT(0); | ||
37 | |||
38 | static int usu_probe_thread(void *arg); | ||
39 | |||
40 | /* | ||
41 | * @type: the module type as an integer | ||
42 | */ | ||
43 | void usb_usual_set_present(int type) | ||
44 | { | ||
45 | struct mod_status *st; | ||
46 | unsigned long flags; | ||
47 | |||
48 | if (type <= 0 || type >= 3) | ||
49 | return; | ||
50 | st = &stat[type]; | ||
51 | spin_lock_irqsave(&usu_lock, flags); | ||
52 | st->fls |= USU_MOD_FL_PRESENT; | ||
53 | spin_unlock_irqrestore(&usu_lock, flags); | ||
54 | } | ||
55 | EXPORT_SYMBOL_GPL(usb_usual_set_present); | ||
56 | |||
57 | void usb_usual_clear_present(int type) | ||
58 | { | ||
59 | struct mod_status *st; | ||
60 | unsigned long flags; | ||
61 | |||
62 | if (type <= 0 || type >= 3) | ||
63 | return; | ||
64 | st = &stat[type]; | ||
65 | spin_lock_irqsave(&usu_lock, flags); | ||
66 | st->fls &= ~USU_MOD_FL_PRESENT; | ||
67 | spin_unlock_irqrestore(&usu_lock, flags); | ||
68 | } | ||
69 | EXPORT_SYMBOL_GPL(usb_usual_clear_present); | ||
70 | |||
71 | /* | ||
72 | * Match the calling driver type against the table. | ||
73 | * Returns: 0 if the device matches. | ||
74 | */ | ||
75 | int usb_usual_check_type(const struct usb_device_id *id, int caller_type) | ||
76 | { | ||
77 | int id_type = USB_US_TYPE(id->driver_info); | ||
78 | |||
79 | if (caller_type <= 0 || caller_type >= 3) | ||
80 | return -EINVAL; | ||
81 | |||
82 | /* Drivers grab fixed assignment devices */ | ||
83 | if (id_type == caller_type) | ||
84 | return 0; | ||
85 | /* Drivers grab devices biased to them */ | ||
86 | if (id_type == USB_US_TYPE_NONE && caller_type == atomic_read(&usu_bias)) | ||
87 | return 0; | ||
88 | return -ENODEV; | ||
89 | } | ||
90 | EXPORT_SYMBOL_GPL(usb_usual_check_type); | ||
91 | |||
92 | /* | ||
93 | */ | ||
94 | static int usu_probe(struct usb_interface *intf, | ||
95 | const struct usb_device_id *id) | ||
96 | { | ||
97 | int rc; | ||
98 | unsigned long type; | ||
99 | struct task_struct* task; | ||
100 | unsigned long flags; | ||
101 | |||
102 | type = USB_US_TYPE(id->driver_info); | ||
103 | if (type == 0) | ||
104 | type = atomic_read(&usu_bias); | ||
105 | |||
106 | spin_lock_irqsave(&usu_lock, flags); | ||
107 | if ((stat[type].fls & (USU_MOD_FL_THREAD|USU_MOD_FL_PRESENT)) != 0) { | ||
108 | spin_unlock_irqrestore(&usu_lock, flags); | ||
109 | return -ENXIO; | ||
110 | } | ||
111 | stat[type].fls |= USU_MOD_FL_THREAD; | ||
112 | spin_unlock_irqrestore(&usu_lock, flags); | ||
113 | |||
114 | task = kthread_run(usu_probe_thread, (void*)type, "libusual_%ld", type); | ||
115 | if (IS_ERR(task)) { | ||
116 | rc = PTR_ERR(task); | ||
117 | printk(KERN_WARNING "libusual: " | ||
118 | "Unable to start the thread for %s: %d\n", | ||
119 | bias_names[type], rc); | ||
120 | spin_lock_irqsave(&usu_lock, flags); | ||
121 | stat[type].fls &= ~USU_MOD_FL_THREAD; | ||
122 | spin_unlock_irqrestore(&usu_lock, flags); | ||
123 | return rc; /* Not being -ENXIO causes a message printed */ | ||
124 | } | ||
125 | atomic_inc(&total_threads); | ||
126 | |||
127 | return -ENXIO; | ||
128 | } | ||
129 | |||
130 | static void usu_disconnect(struct usb_interface *intf) | ||
131 | { | ||
132 | ; /* We should not be here. */ | ||
133 | } | ||
134 | |||
135 | static struct usb_driver usu_driver = { | ||
136 | .name = "libusual", | ||
137 | .probe = usu_probe, | ||
138 | .disconnect = usu_disconnect, | ||
139 | .id_table = usb_storage_usb_ids, | ||
140 | }; | ||
141 | |||
142 | /* | ||
143 | * A whole new thread for a purpose of request_module seems quite stupid. | ||
144 | * The request_module forks once inside again. However, if we attempt | ||
145 | * to load a storage module from our own modprobe thread, that module | ||
146 | * references our symbols, which cannot be resolved until our module is | ||
147 | * initialized. I wish there was a way to wait for the end of initialization. | ||
148 | * The module notifier reports MODULE_STATE_COMING only. | ||
149 | * So, we wait until module->init ends as the next best thing. | ||
150 | */ | ||
151 | static int usu_probe_thread(void *arg) | ||
152 | { | ||
153 | int type = (unsigned long) arg; | ||
154 | struct mod_status *st = &stat[type]; | ||
155 | int rc; | ||
156 | unsigned long flags; | ||
157 | |||
158 | mutex_lock(&usu_probe_mutex); | ||
159 | rc = request_module(bias_names[type]); | ||
160 | spin_lock_irqsave(&usu_lock, flags); | ||
161 | if (rc == 0 && (st->fls & USU_MOD_FL_PRESENT) == 0) { | ||
162 | /* | ||
163 | * This should not happen, but let us keep tabs on it. | ||
164 | */ | ||
165 | printk(KERN_NOTICE "libusual: " | ||
166 | "modprobe for %s succeeded, but module is not present\n", | ||
167 | bias_names[type]); | ||
168 | } | ||
169 | st->fls &= ~USU_MOD_FL_THREAD; | ||
170 | spin_unlock_irqrestore(&usu_lock, flags); | ||
171 | mutex_unlock(&usu_probe_mutex); | ||
172 | |||
173 | complete_and_exit(&usu_end_notify, 0); | ||
174 | } | ||
175 | |||
176 | /* | ||
177 | */ | ||
178 | static int __init usb_usual_init(void) | ||
179 | { | ||
180 | int rc; | ||
181 | |||
182 | mutex_lock(&usu_probe_mutex); | ||
183 | rc = usb_register(&usu_driver); | ||
184 | mutex_unlock(&usu_probe_mutex); | ||
185 | return rc; | ||
186 | } | ||
187 | |||
188 | static void __exit usb_usual_exit(void) | ||
189 | { | ||
190 | /* | ||
191 | * We do not check for any drivers present, because | ||
192 | * they keep us pinned with symbol references. | ||
193 | */ | ||
194 | |||
195 | usb_deregister(&usu_driver); | ||
196 | |||
197 | while (atomic_read(&total_threads) > 0) { | ||
198 | wait_for_completion(&usu_end_notify); | ||
199 | atomic_dec(&total_threads); | ||
200 | } | ||
201 | } | ||
202 | |||
203 | /* | ||
204 | * Validate and accept the bias parameter. | ||
205 | */ | ||
206 | static int usu_set_bias(const char *bias_s, struct kernel_param *kp) | ||
207 | { | ||
208 | int i; | ||
209 | int len; | ||
210 | int bias_n = 0; | ||
211 | |||
212 | len = strlen(bias_s); | ||
213 | if (len == 0) | ||
214 | return -EDOM; | ||
215 | if (bias_s[len-1] == '\n') | ||
216 | --len; | ||
217 | |||
218 | for (i = 1; i < 3; i++) { | ||
219 | if (strncmp(bias_s, bias_names[i], len) == 0) { | ||
220 | bias_n = i; | ||
221 | break; | ||
222 | } | ||
223 | } | ||
224 | if (bias_n == 0) | ||
225 | return -EINVAL; | ||
226 | |||
227 | atomic_set(&usu_bias, bias_n); | ||
228 | return 0; | ||
229 | } | ||
230 | |||
231 | static int usu_get_bias(char *buffer, struct kernel_param *kp) | ||
232 | { | ||
233 | return strlen(strcpy(buffer, bias_names[atomic_read(&usu_bias)])); | ||
234 | } | ||
235 | |||
236 | module_init(usb_usual_init); | ||
237 | module_exit(usb_usual_exit); | ||
238 | |||
239 | module_param_call(bias, usu_set_bias, usu_get_bias, NULL, S_IRUGO|S_IWUSR); | ||
240 | __MODULE_PARM_TYPE(bias, "string"); | ||
241 | MODULE_PARM_DESC(bias, "Bias to usb-storage or ub"); | ||
242 | |||
243 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/usb/storage/onetouch.c b/drivers/usb/storage/onetouch.c index 886567a3806d..cb79de61f4c8 100644 --- a/drivers/usb/storage/onetouch.c +++ b/drivers/usb/storage/onetouch.c | |||
@@ -67,7 +67,7 @@ struct usb_onetouch { | |||
67 | vendorName, productName, useProtocol, useTransport, \ | 67 | vendorName, productName, useProtocol, useTransport, \ |
68 | initFunction, flags) \ | 68 | initFunction, flags) \ |
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) } |
71 | 71 | ||
72 | static 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" |
diff --git a/drivers/usb/storage/realtek_cr.c b/drivers/usb/storage/realtek_cr.c index 63cf2822e299..d36446dd7ae8 100644 --- a/drivers/usb/storage/realtek_cr.c +++ b/drivers/usb/storage/realtek_cr.c | |||
@@ -172,7 +172,7 @@ static int init_realtek_cr(struct us_data *us); | |||
172 | initFunction, flags) \ | 172 | initFunction, flags) \ |
173 | {\ | 173 | {\ |
174 | USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \ | 174 | USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \ |
175 | .driver_info = (flags)|(USB_US_TYPE_STOR<<24)\ | 175 | .driver_info = (flags) \ |
176 | } | 176 | } |
177 | 177 | ||
178 | static const struct usb_device_id realtek_cr_ids[] = { | 178 | static const struct usb_device_id realtek_cr_ids[] = { |
diff --git a/drivers/usb/storage/sddr09.c b/drivers/usb/storage/sddr09.c index 3252a62b31bc..7bd54e0d5120 100644 --- a/drivers/usb/storage/sddr09.c +++ b/drivers/usb/storage/sddr09.c | |||
@@ -69,7 +69,7 @@ static int usb_stor_sddr09_init(struct us_data *us); | |||
69 | vendorName, productName, useProtocol, useTransport, \ | 69 | vendorName, productName, useProtocol, useTransport, \ |
70 | initFunction, flags) \ | 70 | initFunction, flags) \ |
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) } |
73 | 73 | ||
74 | static 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" |
diff --git a/drivers/usb/storage/sddr55.c b/drivers/usb/storage/sddr55.c index c144078065a7..d278c5a99b7a 100644 --- a/drivers/usb/storage/sddr55.c +++ b/drivers/usb/storage/sddr55.c | |||
@@ -46,7 +46,7 @@ MODULE_LICENSE("GPL"); | |||
46 | vendorName, productName, useProtocol, useTransport, \ | 46 | vendorName, productName, useProtocol, useTransport, \ |
47 | initFunction, flags) \ | 47 | initFunction, flags) \ |
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) } |
50 | 50 | ||
51 | static 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" |
diff --git a/drivers/usb/storage/shuttle_usbat.c b/drivers/usb/storage/shuttle_usbat.c index fa1ceebc465c..daf2fc58ae02 100644 --- a/drivers/usb/storage/shuttle_usbat.c +++ b/drivers/usb/storage/shuttle_usbat.c | |||
@@ -168,7 +168,7 @@ static int init_usbat_flash(struct us_data *us); | |||
168 | vendorName, productName, useProtocol, useTransport, \ | 168 | vendorName, productName, useProtocol, useTransport, \ |
169 | initFunction, flags) \ | 169 | initFunction, flags) \ |
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) } |
172 | 172 | ||
173 | static 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" |
diff --git a/drivers/usb/storage/sierra_ms.c b/drivers/usb/storage/sierra_ms.c index 37539c89e3ba..17e36952bced 100644 --- a/drivers/usb/storage/sierra_ms.c +++ b/drivers/usb/storage/sierra_ms.c | |||
@@ -130,14 +130,13 @@ int sierra_ms_init(struct us_data *us) | |||
130 | struct swoc_info *swocInfo; | 130 | struct swoc_info *swocInfo; |
131 | struct usb_device *udev; | 131 | struct usb_device *udev; |
132 | struct Scsi_Host *sh; | 132 | struct Scsi_Host *sh; |
133 | struct scsi_device *sd; | ||
134 | 133 | ||
135 | retries = 3; | 134 | retries = 3; |
136 | result = 0; | 135 | result = 0; |
137 | udev = us->pusb_dev; | 136 | udev = us->pusb_dev; |
138 | 137 | ||
139 | sh = us_to_host(us); | 138 | sh = us_to_host(us); |
140 | sd = scsi_get_host_dev(sh); | 139 | scsi_get_host_dev(sh); |
141 | 140 | ||
142 | US_DEBUGP("SWIMS: sierra_ms_init called\n"); | 141 | US_DEBUGP("SWIMS: sierra_ms_init called\n"); |
143 | 142 | ||
diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c index c70109e5d60b..c0543c83923e 100644 --- a/drivers/usb/storage/transport.c +++ b/drivers/usb/storage/transport.c | |||
@@ -1331,7 +1331,7 @@ int usb_stor_port_reset(struct us_data *us) | |||
1331 | int result; | 1331 | int result; |
1332 | 1332 | ||
1333 | /*for these devices we must use the class specific method */ | 1333 | /*for these devices we must use the class specific method */ |
1334 | if (us->pusb_dev->quirks & USB_QUIRK_RESET_MORPHS) | 1334 | if (us->pusb_dev->quirks & USB_QUIRK_RESET) |
1335 | return -EPERM; | 1335 | return -EPERM; |
1336 | 1336 | ||
1337 | result = usb_lock_device_for_reset(us->pusb_dev, us->pusb_intf); | 1337 | result = usb_lock_device_for_reset(us->pusb_dev, us->pusb_intf); |
diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c index 638cd64f9610..98b98eef7527 100644 --- a/drivers/usb/storage/uas.c +++ b/drivers/usb/storage/uas.c | |||
@@ -41,6 +41,7 @@ struct sense_iu_old { | |||
41 | struct uas_dev_info { | 41 | struct uas_dev_info { |
42 | struct usb_interface *intf; | 42 | struct usb_interface *intf; |
43 | struct usb_device *udev; | 43 | struct usb_device *udev; |
44 | struct usb_anchor cmd_urbs; | ||
44 | struct usb_anchor sense_urbs; | 45 | struct usb_anchor sense_urbs; |
45 | struct usb_anchor data_urbs; | 46 | struct usb_anchor data_urbs; |
46 | int qdepth, resetting; | 47 | int qdepth, resetting; |
@@ -49,6 +50,7 @@ struct uas_dev_info { | |||
49 | unsigned use_streams:1; | 50 | unsigned use_streams:1; |
50 | unsigned uas_sense_old:1; | 51 | unsigned uas_sense_old:1; |
51 | struct scsi_cmnd *cmnd; | 52 | struct scsi_cmnd *cmnd; |
53 | spinlock_t lock; | ||
52 | }; | 54 | }; |
53 | 55 | ||
54 | enum { | 56 | enum { |
@@ -63,13 +65,13 @@ enum { | |||
63 | DATA_IN_URB_INFLIGHT = (1 << 9), | 65 | DATA_IN_URB_INFLIGHT = (1 << 9), |
64 | DATA_OUT_URB_INFLIGHT = (1 << 10), | 66 | DATA_OUT_URB_INFLIGHT = (1 << 10), |
65 | COMMAND_COMPLETED = (1 << 11), | 67 | COMMAND_COMPLETED = (1 << 11), |
68 | COMMAND_ABORTED = (1 << 12), | ||
66 | }; | 69 | }; |
67 | 70 | ||
68 | /* Overrides scsi_pointer */ | 71 | /* Overrides scsi_pointer */ |
69 | struct uas_cmd_info { | 72 | struct uas_cmd_info { |
70 | unsigned int state; | 73 | unsigned int state; |
71 | unsigned int stream; | 74 | unsigned int stream; |
72 | unsigned int aborted; | ||
73 | struct urb *cmd_urb; | 75 | struct urb *cmd_urb; |
74 | struct urb *data_in_urb; | 76 | struct urb *data_in_urb; |
75 | struct urb *data_out_urb; | 77 | struct urb *data_out_urb; |
@@ -90,6 +92,7 @@ static void uas_do_work(struct work_struct *work) | |||
90 | struct uas_cmd_info *cmdinfo; | 92 | struct uas_cmd_info *cmdinfo; |
91 | struct uas_cmd_info *temp; | 93 | struct uas_cmd_info *temp; |
92 | struct list_head list; | 94 | struct list_head list; |
95 | unsigned long flags; | ||
93 | int err; | 96 | int err; |
94 | 97 | ||
95 | spin_lock_irq(&uas_work_lock); | 98 | spin_lock_irq(&uas_work_lock); |
@@ -100,7 +103,10 @@ static void uas_do_work(struct work_struct *work) | |||
100 | struct scsi_pointer *scp = (void *)cmdinfo; | 103 | struct scsi_pointer *scp = (void *)cmdinfo; |
101 | struct scsi_cmnd *cmnd = container_of(scp, | 104 | struct scsi_cmnd *cmnd = container_of(scp, |
102 | struct scsi_cmnd, SCp); | 105 | struct scsi_cmnd, SCp); |
103 | err = uas_submit_urbs(cmnd, cmnd->device->hostdata, GFP_NOIO); | 106 | struct uas_dev_info *devinfo = (void *)cmnd->device->hostdata; |
107 | spin_lock_irqsave(&devinfo->lock, flags); | ||
108 | err = uas_submit_urbs(cmnd, cmnd->device->hostdata, GFP_ATOMIC); | ||
109 | spin_unlock_irqrestore(&devinfo->lock, flags); | ||
104 | if (err) { | 110 | if (err) { |
105 | list_del(&cmdinfo->list); | 111 | list_del(&cmdinfo->list); |
106 | spin_lock_irq(&uas_work_lock); | 112 | spin_lock_irq(&uas_work_lock); |
@@ -162,7 +168,7 @@ static void uas_log_cmd_state(struct scsi_cmnd *cmnd, const char *caller) | |||
162 | struct uas_cmd_info *ci = (void *)&cmnd->SCp; | 168 | struct uas_cmd_info *ci = (void *)&cmnd->SCp; |
163 | 169 | ||
164 | scmd_printk(KERN_INFO, cmnd, "%s %p tag %d, inflight:" | 170 | scmd_printk(KERN_INFO, cmnd, "%s %p tag %d, inflight:" |
165 | "%s%s%s%s%s%s%s%s%s%s%s\n", | 171 | "%s%s%s%s%s%s%s%s%s%s%s%s\n", |
166 | caller, cmnd, cmnd->request->tag, | 172 | caller, cmnd, cmnd->request->tag, |
167 | (ci->state & SUBMIT_STATUS_URB) ? " s-st" : "", | 173 | (ci->state & SUBMIT_STATUS_URB) ? " s-st" : "", |
168 | (ci->state & ALLOC_DATA_IN_URB) ? " a-in" : "", | 174 | (ci->state & ALLOC_DATA_IN_URB) ? " a-in" : "", |
@@ -174,13 +180,16 @@ static void uas_log_cmd_state(struct scsi_cmnd *cmnd, const char *caller) | |||
174 | (ci->state & COMMAND_INFLIGHT) ? " CMD" : "", | 180 | (ci->state & COMMAND_INFLIGHT) ? " CMD" : "", |
175 | (ci->state & DATA_IN_URB_INFLIGHT) ? " IN" : "", | 181 | (ci->state & DATA_IN_URB_INFLIGHT) ? " IN" : "", |
176 | (ci->state & DATA_OUT_URB_INFLIGHT) ? " OUT" : "", | 182 | (ci->state & DATA_OUT_URB_INFLIGHT) ? " OUT" : "", |
177 | (ci->state & COMMAND_COMPLETED) ? " done" : ""); | 183 | (ci->state & COMMAND_COMPLETED) ? " done" : "", |
184 | (ci->state & COMMAND_ABORTED) ? " abort" : ""); | ||
178 | } | 185 | } |
179 | 186 | ||
180 | static int uas_try_complete(struct scsi_cmnd *cmnd, const char *caller) | 187 | static int uas_try_complete(struct scsi_cmnd *cmnd, const char *caller) |
181 | { | 188 | { |
182 | struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp; | 189 | struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp; |
190 | struct uas_dev_info *devinfo = (void *)cmnd->device->hostdata; | ||
183 | 191 | ||
192 | WARN_ON(!spin_is_locked(&devinfo->lock)); | ||
184 | if (cmdinfo->state & (COMMAND_INFLIGHT | | 193 | if (cmdinfo->state & (COMMAND_INFLIGHT | |
185 | DATA_IN_URB_INFLIGHT | | 194 | DATA_IN_URB_INFLIGHT | |
186 | DATA_OUT_URB_INFLIGHT)) | 195 | DATA_OUT_URB_INFLIGHT)) |
@@ -189,6 +198,10 @@ static int uas_try_complete(struct scsi_cmnd *cmnd, const char *caller) | |||
189 | cmdinfo->state |= COMMAND_COMPLETED; | 198 | cmdinfo->state |= COMMAND_COMPLETED; |
190 | usb_free_urb(cmdinfo->data_in_urb); | 199 | usb_free_urb(cmdinfo->data_in_urb); |
191 | usb_free_urb(cmdinfo->data_out_urb); | 200 | usb_free_urb(cmdinfo->data_out_urb); |
201 | if (cmdinfo->state & COMMAND_ABORTED) { | ||
202 | scmd_printk(KERN_INFO, cmnd, "abort completed\n"); | ||
203 | cmnd->result = DID_ABORT << 16; | ||
204 | } | ||
192 | cmnd->scsi_done(cmnd); | 205 | cmnd->scsi_done(cmnd); |
193 | return 0; | 206 | return 0; |
194 | } | 207 | } |
@@ -216,6 +229,7 @@ static void uas_stat_cmplt(struct urb *urb) | |||
216 | struct uas_dev_info *devinfo = (void *)shost->hostdata[0]; | 229 | struct uas_dev_info *devinfo = (void *)shost->hostdata[0]; |
217 | struct scsi_cmnd *cmnd; | 230 | struct scsi_cmnd *cmnd; |
218 | struct uas_cmd_info *cmdinfo; | 231 | struct uas_cmd_info *cmdinfo; |
232 | unsigned long flags; | ||
219 | u16 tag; | 233 | u16 tag; |
220 | 234 | ||
221 | if (urb->status) { | 235 | if (urb->status) { |
@@ -229,20 +243,24 @@ static void uas_stat_cmplt(struct urb *urb) | |||
229 | return; | 243 | return; |
230 | } | 244 | } |
231 | 245 | ||
246 | spin_lock_irqsave(&devinfo->lock, flags); | ||
232 | tag = be16_to_cpup(&iu->tag) - 1; | 247 | tag = be16_to_cpup(&iu->tag) - 1; |
233 | if (tag == 0) | 248 | if (tag == 0) |
234 | cmnd = devinfo->cmnd; | 249 | cmnd = devinfo->cmnd; |
235 | else | 250 | else |
236 | cmnd = scsi_host_find_tag(shost, tag - 1); | 251 | cmnd = scsi_host_find_tag(shost, tag - 1); |
252 | |||
237 | if (!cmnd) { | 253 | if (!cmnd) { |
238 | if (iu->iu_id != IU_ID_RESPONSE) { | 254 | if (iu->iu_id == IU_ID_RESPONSE) { |
239 | usb_free_urb(urb); | 255 | /* store results for uas_eh_task_mgmt() */ |
240 | return; | 256 | memcpy(&devinfo->response, iu, sizeof(devinfo->response)); |
241 | } | 257 | } |
242 | } else { | 258 | usb_free_urb(urb); |
243 | cmdinfo = (void *)&cmnd->SCp; | 259 | spin_unlock_irqrestore(&devinfo->lock, flags); |
260 | return; | ||
244 | } | 261 | } |
245 | 262 | ||
263 | cmdinfo = (void *)&cmnd->SCp; | ||
246 | switch (iu->iu_id) { | 264 | switch (iu->iu_id) { |
247 | case IU_ID_STATUS: | 265 | case IU_ID_STATUS: |
248 | if (devinfo->cmnd == cmnd) | 266 | if (devinfo->cmnd == cmnd) |
@@ -256,10 +274,16 @@ static void uas_stat_cmplt(struct urb *urb) | |||
256 | uas_sense(urb, cmnd); | 274 | uas_sense(urb, cmnd); |
257 | if (cmnd->result != 0) { | 275 | if (cmnd->result != 0) { |
258 | /* cancel data transfers on error */ | 276 | /* cancel data transfers on error */ |
259 | if (cmdinfo->state & DATA_IN_URB_INFLIGHT) | 277 | if (cmdinfo->state & DATA_IN_URB_INFLIGHT) { |
278 | spin_unlock_irqrestore(&devinfo->lock, flags); | ||
260 | usb_unlink_urb(cmdinfo->data_in_urb); | 279 | usb_unlink_urb(cmdinfo->data_in_urb); |
261 | if (cmdinfo->state & DATA_OUT_URB_INFLIGHT) | 280 | spin_lock_irqsave(&devinfo->lock, flags); |
281 | } | ||
282 | if (cmdinfo->state & DATA_OUT_URB_INFLIGHT) { | ||
283 | spin_unlock_irqrestore(&devinfo->lock, flags); | ||
262 | usb_unlink_urb(cmdinfo->data_out_urb); | 284 | usb_unlink_urb(cmdinfo->data_out_urb); |
285 | spin_lock_irqsave(&devinfo->lock, flags); | ||
286 | } | ||
263 | } | 287 | } |
264 | cmdinfo->state &= ~COMMAND_INFLIGHT; | 288 | cmdinfo->state &= ~COMMAND_INFLIGHT; |
265 | uas_try_complete(cmnd, __func__); | 289 | uas_try_complete(cmnd, __func__); |
@@ -270,23 +294,23 @@ static void uas_stat_cmplt(struct urb *urb) | |||
270 | case IU_ID_WRITE_READY: | 294 | case IU_ID_WRITE_READY: |
271 | uas_xfer_data(urb, cmnd, SUBMIT_DATA_OUT_URB); | 295 | uas_xfer_data(urb, cmnd, SUBMIT_DATA_OUT_URB); |
272 | break; | 296 | break; |
273 | case IU_ID_RESPONSE: | ||
274 | /* store results for uas_eh_task_mgmt() */ | ||
275 | memcpy(&devinfo->response, iu, sizeof(devinfo->response)); | ||
276 | break; | ||
277 | default: | 297 | default: |
278 | scmd_printk(KERN_ERR, cmnd, | 298 | scmd_printk(KERN_ERR, cmnd, |
279 | "Bogus IU (%d) received on status pipe\n", iu->iu_id); | 299 | "Bogus IU (%d) received on status pipe\n", iu->iu_id); |
280 | } | 300 | } |
281 | usb_free_urb(urb); | 301 | usb_free_urb(urb); |
302 | spin_unlock_irqrestore(&devinfo->lock, flags); | ||
282 | } | 303 | } |
283 | 304 | ||
284 | static void uas_data_cmplt(struct urb *urb) | 305 | static void uas_data_cmplt(struct urb *urb) |
285 | { | 306 | { |
286 | struct scsi_cmnd *cmnd = urb->context; | 307 | struct scsi_cmnd *cmnd = urb->context; |
287 | struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp; | 308 | struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp; |
309 | struct uas_dev_info *devinfo = (void *)cmnd->device->hostdata; | ||
288 | struct scsi_data_buffer *sdb = NULL; | 310 | struct scsi_data_buffer *sdb = NULL; |
311 | unsigned long flags; | ||
289 | 312 | ||
313 | spin_lock_irqsave(&devinfo->lock, flags); | ||
290 | if (cmdinfo->data_in_urb == urb) { | 314 | if (cmdinfo->data_in_urb == urb) { |
291 | sdb = scsi_in(cmnd); | 315 | sdb = scsi_in(cmnd); |
292 | cmdinfo->state &= ~DATA_IN_URB_INFLIGHT; | 316 | cmdinfo->state &= ~DATA_IN_URB_INFLIGHT; |
@@ -301,10 +325,8 @@ static void uas_data_cmplt(struct urb *urb) | |||
301 | } else { | 325 | } else { |
302 | sdb->resid = sdb->length - urb->actual_length; | 326 | sdb->resid = sdb->length - urb->actual_length; |
303 | } | 327 | } |
304 | if (cmdinfo->aborted) { | ||
305 | return; | ||
306 | } | ||
307 | uas_try_complete(cmnd, __func__); | 328 | uas_try_complete(cmnd, __func__); |
329 | spin_unlock_irqrestore(&devinfo->lock, flags); | ||
308 | } | 330 | } |
309 | 331 | ||
310 | static struct urb *uas_alloc_data_urb(struct uas_dev_info *devinfo, gfp_t gfp, | 332 | static struct urb *uas_alloc_data_urb(struct uas_dev_info *devinfo, gfp_t gfp, |
@@ -431,6 +453,7 @@ static int uas_submit_task_urb(struct scsi_cmnd *cmnd, gfp_t gfp, | |||
431 | err = usb_submit_urb(urb, gfp); | 453 | err = usb_submit_urb(urb, gfp); |
432 | if (err) | 454 | if (err) |
433 | goto err; | 455 | goto err; |
456 | usb_anchor_urb(urb, &devinfo->cmd_urbs); | ||
434 | 457 | ||
435 | return 0; | 458 | return 0; |
436 | 459 | ||
@@ -470,6 +493,7 @@ static int uas_submit_urbs(struct scsi_cmnd *cmnd, | |||
470 | struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp; | 493 | struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp; |
471 | int err; | 494 | int err; |
472 | 495 | ||
496 | WARN_ON(!spin_is_locked(&devinfo->lock)); | ||
473 | if (cmdinfo->state & SUBMIT_STATUS_URB) { | 497 | if (cmdinfo->state & SUBMIT_STATUS_URB) { |
474 | err = uas_submit_sense_urb(cmnd->device->host, gfp, | 498 | err = uas_submit_sense_urb(cmnd->device->host, gfp, |
475 | cmdinfo->stream); | 499 | cmdinfo->stream); |
@@ -521,18 +545,22 @@ static int uas_submit_urbs(struct scsi_cmnd *cmnd, | |||
521 | 545 | ||
522 | if (cmdinfo->state & ALLOC_CMD_URB) { | 546 | if (cmdinfo->state & ALLOC_CMD_URB) { |
523 | cmdinfo->cmd_urb = uas_alloc_cmd_urb(devinfo, gfp, cmnd, | 547 | cmdinfo->cmd_urb = uas_alloc_cmd_urb(devinfo, gfp, cmnd, |
524 | cmdinfo->stream); | 548 | cmdinfo->stream); |
525 | if (!cmdinfo->cmd_urb) | 549 | if (!cmdinfo->cmd_urb) |
526 | return SCSI_MLQUEUE_DEVICE_BUSY; | 550 | return SCSI_MLQUEUE_DEVICE_BUSY; |
527 | cmdinfo->state &= ~ALLOC_CMD_URB; | 551 | cmdinfo->state &= ~ALLOC_CMD_URB; |
528 | } | 552 | } |
529 | 553 | ||
530 | if (cmdinfo->state & SUBMIT_CMD_URB) { | 554 | if (cmdinfo->state & SUBMIT_CMD_URB) { |
555 | usb_get_urb(cmdinfo->cmd_urb); | ||
531 | if (usb_submit_urb(cmdinfo->cmd_urb, gfp)) { | 556 | if (usb_submit_urb(cmdinfo->cmd_urb, gfp)) { |
532 | scmd_printk(KERN_INFO, cmnd, | 557 | scmd_printk(KERN_INFO, cmnd, |
533 | "cmd urb submission failure\n"); | 558 | "cmd urb submission failure\n"); |
534 | return SCSI_MLQUEUE_DEVICE_BUSY; | 559 | return SCSI_MLQUEUE_DEVICE_BUSY; |
535 | } | 560 | } |
561 | usb_anchor_urb(cmdinfo->cmd_urb, &devinfo->cmd_urbs); | ||
562 | usb_put_urb(cmdinfo->cmd_urb); | ||
563 | cmdinfo->cmd_urb = NULL; | ||
536 | cmdinfo->state &= ~SUBMIT_CMD_URB; | 564 | cmdinfo->state &= ~SUBMIT_CMD_URB; |
537 | cmdinfo->state |= COMMAND_INFLIGHT; | 565 | cmdinfo->state |= COMMAND_INFLIGHT; |
538 | } | 566 | } |
@@ -546,12 +574,16 @@ static int uas_queuecommand_lck(struct scsi_cmnd *cmnd, | |||
546 | struct scsi_device *sdev = cmnd->device; | 574 | struct scsi_device *sdev = cmnd->device; |
547 | struct uas_dev_info *devinfo = sdev->hostdata; | 575 | struct uas_dev_info *devinfo = sdev->hostdata; |
548 | struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp; | 576 | struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp; |
577 | unsigned long flags; | ||
549 | int err; | 578 | int err; |
550 | 579 | ||
551 | BUILD_BUG_ON(sizeof(struct uas_cmd_info) > sizeof(struct scsi_pointer)); | 580 | BUILD_BUG_ON(sizeof(struct uas_cmd_info) > sizeof(struct scsi_pointer)); |
552 | 581 | ||
553 | if (devinfo->cmnd) | 582 | spin_lock_irqsave(&devinfo->lock, flags); |
583 | if (devinfo->cmnd) { | ||
584 | spin_unlock_irqrestore(&devinfo->lock, flags); | ||
554 | return SCSI_MLQUEUE_DEVICE_BUSY; | 585 | return SCSI_MLQUEUE_DEVICE_BUSY; |
586 | } | ||
555 | 587 | ||
556 | if (blk_rq_tagged(cmnd->request)) { | 588 | if (blk_rq_tagged(cmnd->request)) { |
557 | cmdinfo->stream = cmnd->request->tag + 2; | 589 | cmdinfo->stream = cmnd->request->tag + 2; |
@@ -564,7 +596,6 @@ static int uas_queuecommand_lck(struct scsi_cmnd *cmnd, | |||
564 | 596 | ||
565 | cmdinfo->state = SUBMIT_STATUS_URB | | 597 | cmdinfo->state = SUBMIT_STATUS_URB | |
566 | ALLOC_CMD_URB | SUBMIT_CMD_URB; | 598 | ALLOC_CMD_URB | SUBMIT_CMD_URB; |
567 | cmdinfo->aborted = 0; | ||
568 | 599 | ||
569 | switch (cmnd->sc_data_direction) { | 600 | switch (cmnd->sc_data_direction) { |
570 | case DMA_FROM_DEVICE: | 601 | case DMA_FROM_DEVICE: |
@@ -587,6 +618,7 @@ static int uas_queuecommand_lck(struct scsi_cmnd *cmnd, | |||
587 | if (err) { | 618 | if (err) { |
588 | /* If we did nothing, give up now */ | 619 | /* If we did nothing, give up now */ |
589 | if (cmdinfo->state & SUBMIT_STATUS_URB) { | 620 | if (cmdinfo->state & SUBMIT_STATUS_URB) { |
621 | spin_unlock_irqrestore(&devinfo->lock, flags); | ||
590 | return SCSI_MLQUEUE_DEVICE_BUSY; | 622 | return SCSI_MLQUEUE_DEVICE_BUSY; |
591 | } | 623 | } |
592 | spin_lock(&uas_work_lock); | 624 | spin_lock(&uas_work_lock); |
@@ -595,6 +627,7 @@ static int uas_queuecommand_lck(struct scsi_cmnd *cmnd, | |||
595 | schedule_work(&uas_work); | 627 | schedule_work(&uas_work); |
596 | } | 628 | } |
597 | 629 | ||
630 | spin_unlock_irqrestore(&devinfo->lock, flags); | ||
598 | return 0; | 631 | return 0; |
599 | } | 632 | } |
600 | 633 | ||
@@ -605,22 +638,28 @@ static int uas_eh_task_mgmt(struct scsi_cmnd *cmnd, | |||
605 | { | 638 | { |
606 | struct Scsi_Host *shost = cmnd->device->host; | 639 | struct Scsi_Host *shost = cmnd->device->host; |
607 | struct uas_dev_info *devinfo = (void *)shost->hostdata[0]; | 640 | struct uas_dev_info *devinfo = (void *)shost->hostdata[0]; |
608 | u16 tag = 9999; /* FIXME */ | 641 | u16 tag = devinfo->qdepth - 1; |
642 | unsigned long flags; | ||
609 | 643 | ||
644 | spin_lock_irqsave(&devinfo->lock, flags); | ||
610 | memset(&devinfo->response, 0, sizeof(devinfo->response)); | 645 | memset(&devinfo->response, 0, sizeof(devinfo->response)); |
611 | if (uas_submit_sense_urb(shost, GFP_NOIO, tag)) { | 646 | if (uas_submit_sense_urb(shost, GFP_ATOMIC, tag)) { |
612 | shost_printk(KERN_INFO, shost, | 647 | shost_printk(KERN_INFO, shost, |
613 | "%s: %s: submit sense urb failed\n", | 648 | "%s: %s: submit sense urb failed\n", |
614 | __func__, fname); | 649 | __func__, fname); |
650 | spin_unlock_irqrestore(&devinfo->lock, flags); | ||
615 | return FAILED; | 651 | return FAILED; |
616 | } | 652 | } |
617 | if (uas_submit_task_urb(cmnd, GFP_NOIO, function, tag)) { | 653 | if (uas_submit_task_urb(cmnd, GFP_ATOMIC, function, tag)) { |
618 | shost_printk(KERN_INFO, shost, | 654 | shost_printk(KERN_INFO, shost, |
619 | "%s: %s: submit task mgmt urb failed\n", | 655 | "%s: %s: submit task mgmt urb failed\n", |
620 | __func__, fname); | 656 | __func__, fname); |
657 | spin_unlock_irqrestore(&devinfo->lock, flags); | ||
621 | return FAILED; | 658 | return FAILED; |
622 | } | 659 | } |
623 | if (0 == usb_wait_anchor_empty_timeout(&devinfo->sense_urbs, 3000)) { | 660 | spin_unlock_irqrestore(&devinfo->lock, flags); |
661 | |||
662 | if (usb_wait_anchor_empty_timeout(&devinfo->sense_urbs, 3000) == 0) { | ||
624 | shost_printk(KERN_INFO, shost, | 663 | shost_printk(KERN_INFO, shost, |
625 | "%s: %s timed out\n", __func__, fname); | 664 | "%s: %s timed out\n", __func__, fname); |
626 | return FAILED; | 665 | return FAILED; |
@@ -643,15 +682,15 @@ static int uas_eh_task_mgmt(struct scsi_cmnd *cmnd, | |||
643 | static int uas_eh_abort_handler(struct scsi_cmnd *cmnd) | 682 | static int uas_eh_abort_handler(struct scsi_cmnd *cmnd) |
644 | { | 683 | { |
645 | struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp; | 684 | struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp; |
685 | struct uas_dev_info *devinfo = (void *)cmnd->device->hostdata; | ||
686 | unsigned long flags; | ||
646 | int ret; | 687 | int ret; |
647 | 688 | ||
648 | uas_log_cmd_state(cmnd, __func__); | 689 | uas_log_cmd_state(cmnd, __func__); |
649 | cmdinfo->aborted = 1; | 690 | spin_lock_irqsave(&devinfo->lock, flags); |
691 | cmdinfo->state |= COMMAND_ABORTED; | ||
692 | spin_unlock_irqrestore(&devinfo->lock, flags); | ||
650 | ret = uas_eh_task_mgmt(cmnd, "ABORT TASK", TMF_ABORT_TASK); | 693 | ret = uas_eh_task_mgmt(cmnd, "ABORT TASK", TMF_ABORT_TASK); |
651 | if (cmdinfo->state & DATA_IN_URB_INFLIGHT) | ||
652 | usb_kill_urb(cmdinfo->data_in_urb); | ||
653 | if (cmdinfo->state & DATA_OUT_URB_INFLIGHT) | ||
654 | usb_kill_urb(cmdinfo->data_out_urb); | ||
655 | return ret; | 694 | return ret; |
656 | } | 695 | } |
657 | 696 | ||
@@ -670,6 +709,7 @@ static int uas_eh_bus_reset_handler(struct scsi_cmnd *cmnd) | |||
670 | int err; | 709 | int err; |
671 | 710 | ||
672 | devinfo->resetting = 1; | 711 | devinfo->resetting = 1; |
712 | usb_kill_anchored_urbs(&devinfo->cmd_urbs); | ||
673 | usb_kill_anchored_urbs(&devinfo->sense_urbs); | 713 | usb_kill_anchored_urbs(&devinfo->sense_urbs); |
674 | usb_kill_anchored_urbs(&devinfo->data_urbs); | 714 | usb_kill_anchored_urbs(&devinfo->data_urbs); |
675 | err = usb_reset_device(udev); | 715 | err = usb_reset_device(udev); |
@@ -694,7 +734,7 @@ static int uas_slave_configure(struct scsi_device *sdev) | |||
694 | { | 734 | { |
695 | struct uas_dev_info *devinfo = sdev->hostdata; | 735 | struct uas_dev_info *devinfo = sdev->hostdata; |
696 | scsi_set_tag_type(sdev, MSG_ORDERED_TAG); | 736 | scsi_set_tag_type(sdev, MSG_ORDERED_TAG); |
697 | scsi_activate_tcq(sdev, devinfo->qdepth - 2); | 737 | scsi_activate_tcq(sdev, devinfo->qdepth - 3); |
698 | return 0; | 738 | return 0; |
699 | } | 739 | } |
700 | 740 | ||
@@ -868,11 +908,13 @@ static int uas_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
868 | devinfo->intf = intf; | 908 | devinfo->intf = intf; |
869 | devinfo->udev = udev; | 909 | devinfo->udev = udev; |
870 | devinfo->resetting = 0; | 910 | devinfo->resetting = 0; |
911 | init_usb_anchor(&devinfo->cmd_urbs); | ||
871 | init_usb_anchor(&devinfo->sense_urbs); | 912 | init_usb_anchor(&devinfo->sense_urbs); |
872 | init_usb_anchor(&devinfo->data_urbs); | 913 | init_usb_anchor(&devinfo->data_urbs); |
914 | spin_lock_init(&devinfo->lock); | ||
873 | uas_configure_endpoints(devinfo); | 915 | uas_configure_endpoints(devinfo); |
874 | 916 | ||
875 | result = scsi_init_shared_tag_map(shost, devinfo->qdepth - 2); | 917 | result = scsi_init_shared_tag_map(shost, devinfo->qdepth - 3); |
876 | if (result) | 918 | if (result) |
877 | goto free; | 919 | goto free; |
878 | 920 | ||
@@ -913,6 +955,7 @@ static void uas_disconnect(struct usb_interface *intf) | |||
913 | struct uas_dev_info *devinfo = (void *)shost->hostdata[0]; | 955 | struct uas_dev_info *devinfo = (void *)shost->hostdata[0]; |
914 | 956 | ||
915 | scsi_remove_host(shost); | 957 | scsi_remove_host(shost); |
958 | usb_kill_anchored_urbs(&devinfo->cmd_urbs); | ||
916 | usb_kill_anchored_urbs(&devinfo->sense_urbs); | 959 | usb_kill_anchored_urbs(&devinfo->sense_urbs); |
917 | usb_kill_anchored_urbs(&devinfo->data_urbs); | 960 | usb_kill_anchored_urbs(&devinfo->data_urbs); |
918 | uas_free_streams(devinfo); | 961 | uas_free_streams(devinfo); |
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h index 62a31bea0634..779cd954abcb 100644 --- a/drivers/usb/storage/unusual_devs.h +++ b/drivers/usb/storage/unusual_devs.h | |||
@@ -2038,25 +2038,25 @@ UNUSUAL_DEV( 0xed10, 0x7636, 0x0001, 0x0001, | |||
2038 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, US_FL_NOT_LOCKABLE ), | 2038 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, US_FL_NOT_LOCKABLE ), |
2039 | 2039 | ||
2040 | /* Control/Bulk transport for all SubClass values */ | 2040 | /* Control/Bulk transport for all SubClass values */ |
2041 | USUAL_DEV(USB_SC_RBC, USB_PR_CB, USB_US_TYPE_STOR), | 2041 | USUAL_DEV(USB_SC_RBC, USB_PR_CB), |
2042 | USUAL_DEV(USB_SC_8020, USB_PR_CB, USB_US_TYPE_STOR), | 2042 | USUAL_DEV(USB_SC_8020, USB_PR_CB), |
2043 | USUAL_DEV(USB_SC_QIC, USB_PR_CB, USB_US_TYPE_STOR), | 2043 | USUAL_DEV(USB_SC_QIC, USB_PR_CB), |
2044 | USUAL_DEV(USB_SC_UFI, USB_PR_CB, USB_US_TYPE_STOR), | 2044 | USUAL_DEV(USB_SC_UFI, USB_PR_CB), |
2045 | USUAL_DEV(USB_SC_8070, USB_PR_CB, USB_US_TYPE_STOR), | 2045 | USUAL_DEV(USB_SC_8070, USB_PR_CB), |
2046 | USUAL_DEV(USB_SC_SCSI, USB_PR_CB, USB_US_TYPE_STOR), | 2046 | USUAL_DEV(USB_SC_SCSI, USB_PR_CB), |
2047 | 2047 | ||
2048 | /* Control/Bulk/Interrupt transport for all SubClass values */ | 2048 | /* Control/Bulk/Interrupt transport for all SubClass values */ |
2049 | USUAL_DEV(USB_SC_RBC, USB_PR_CBI, USB_US_TYPE_STOR), | 2049 | USUAL_DEV(USB_SC_RBC, USB_PR_CBI), |
2050 | USUAL_DEV(USB_SC_8020, USB_PR_CBI, USB_US_TYPE_STOR), | 2050 | USUAL_DEV(USB_SC_8020, USB_PR_CBI), |
2051 | USUAL_DEV(USB_SC_QIC, USB_PR_CBI, USB_US_TYPE_STOR), | 2051 | USUAL_DEV(USB_SC_QIC, USB_PR_CBI), |
2052 | USUAL_DEV(USB_SC_UFI, USB_PR_CBI, USB_US_TYPE_STOR), | 2052 | USUAL_DEV(USB_SC_UFI, USB_PR_CBI), |
2053 | USUAL_DEV(USB_SC_8070, USB_PR_CBI, USB_US_TYPE_STOR), | 2053 | USUAL_DEV(USB_SC_8070, USB_PR_CBI), |
2054 | USUAL_DEV(USB_SC_SCSI, USB_PR_CBI, USB_US_TYPE_STOR), | 2054 | USUAL_DEV(USB_SC_SCSI, USB_PR_CBI), |
2055 | 2055 | ||
2056 | /* Bulk-only transport for all SubClass values */ | 2056 | /* Bulk-only transport for all SubClass values */ |
2057 | USUAL_DEV(USB_SC_RBC, USB_PR_BULK, USB_US_TYPE_STOR), | 2057 | USUAL_DEV(USB_SC_RBC, USB_PR_BULK), |
2058 | USUAL_DEV(USB_SC_8020, USB_PR_BULK, USB_US_TYPE_STOR), | 2058 | USUAL_DEV(USB_SC_8020, USB_PR_BULK), |
2059 | USUAL_DEV(USB_SC_QIC, USB_PR_BULK, USB_US_TYPE_STOR), | 2059 | USUAL_DEV(USB_SC_QIC, USB_PR_BULK), |
2060 | USUAL_DEV(USB_SC_UFI, USB_PR_BULK, USB_US_TYPE_STOR), | 2060 | USUAL_DEV(USB_SC_UFI, USB_PR_BULK), |
2061 | USUAL_DEV(USB_SC_8070, USB_PR_BULK, USB_US_TYPE_STOR), | 2061 | USUAL_DEV(USB_SC_8070, USB_PR_BULK), |
2062 | USUAL_DEV(USB_SC_SCSI, USB_PR_BULK, 0), | 2062 | USUAL_DEV(USB_SC_SCSI, USB_PR_BULK), |
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c index d012fe4329e7..12aa72630aed 100644 --- a/drivers/usb/storage/usb.c +++ b/drivers/usb/storage/usb.c | |||
@@ -114,7 +114,7 @@ MODULE_PARM_DESC(quirks, "supplemental list of device IDs and their quirks"); | |||
114 | 114 | ||
115 | #define COMPLIANT_DEV UNUSUAL_DEV | 115 | #define COMPLIANT_DEV UNUSUAL_DEV |
116 | 116 | ||
117 | #define USUAL_DEV(use_protocol, use_transport, use_type) \ | 117 | #define USUAL_DEV(use_protocol, use_transport) \ |
118 | { \ | 118 | { \ |
119 | .useProtocol = use_protocol, \ | 119 | .useProtocol = use_protocol, \ |
120 | .useTransport = use_transport, \ | 120 | .useTransport = use_transport, \ |
@@ -126,7 +126,7 @@ static struct us_unusual_dev us_unusual_dev_list[] = { | |||
126 | }; | 126 | }; |
127 | 127 | ||
128 | static struct us_unusual_dev for_dynamic_ids = | 128 | static struct us_unusual_dev for_dynamic_ids = |
129 | USUAL_DEV(USB_SC_SCSI, USB_PR_BULK, 0); | 129 | USUAL_DEV(USB_SC_SCSI, USB_PR_BULK); |
130 | 130 | ||
131 | #undef UNUSUAL_DEV | 131 | #undef UNUSUAL_DEV |
132 | #undef COMPLIANT_DEV | 132 | #undef COMPLIANT_DEV |
@@ -564,7 +564,7 @@ static int get_device_info(struct us_data *us, const struct usb_device_id *id, | |||
564 | us->protocol = (unusual_dev->useTransport == USB_PR_DEVICE) ? | 564 | us->protocol = (unusual_dev->useTransport == USB_PR_DEVICE) ? |
565 | idesc->bInterfaceProtocol : | 565 | idesc->bInterfaceProtocol : |
566 | unusual_dev->useTransport; | 566 | unusual_dev->useTransport; |
567 | us->fflags = USB_US_ORIG_FLAGS(id->driver_info); | 567 | us->fflags = id->driver_info; |
568 | adjust_quirks(us); | 568 | adjust_quirks(us); |
569 | 569 | ||
570 | if (us->fflags & US_FL_IGNORE_DEVICE) { | 570 | if (us->fflags & US_FL_IGNORE_DEVICE) { |
@@ -1041,13 +1041,10 @@ static int storage_probe(struct usb_interface *intf, | |||
1041 | int size; | 1041 | int size; |
1042 | 1042 | ||
1043 | /* | 1043 | /* |
1044 | * If libusual is configured, let it decide whether a standard | ||
1045 | * device should be handled by usb-storage or by ub. | ||
1046 | * If the device isn't standard (is handled by a subdriver | 1044 | * If the device isn't standard (is handled by a subdriver |
1047 | * module) then don't accept it. | 1045 | * module) then don't accept it. |
1048 | */ | 1046 | */ |
1049 | if (usb_usual_check_type(id, USB_US_TYPE_STOR) || | 1047 | if (usb_usual_ignore_device(intf)) |
1050 | usb_usual_ignore_device(intf)) | ||
1051 | return -ENXIO; | 1048 | return -ENXIO; |
1052 | 1049 | ||
1053 | /* | 1050 | /* |
@@ -1105,10 +1102,8 @@ static int __init usb_stor_init(void) | |||
1105 | 1102 | ||
1106 | /* register the driver, return usb_register return code if error */ | 1103 | /* register the driver, return usb_register return code if error */ |
1107 | retval = usb_register(&usb_storage_driver); | 1104 | retval = usb_register(&usb_storage_driver); |
1108 | if (retval == 0) { | 1105 | if (retval == 0) |
1109 | pr_info("USB Mass Storage support registered.\n"); | 1106 | pr_info("USB Mass Storage support registered.\n"); |
1110 | usb_usual_set_present(USB_US_TYPE_STOR); | ||
1111 | } | ||
1112 | return retval; | 1107 | return retval; |
1113 | } | 1108 | } |
1114 | 1109 | ||
@@ -1122,8 +1117,6 @@ static void __exit usb_stor_exit(void) | |||
1122 | */ | 1117 | */ |
1123 | US_DEBUGP("-- calling usb_deregister()\n"); | 1118 | US_DEBUGP("-- calling usb_deregister()\n"); |
1124 | usb_deregister(&usb_storage_driver) ; | 1119 | usb_deregister(&usb_storage_driver) ; |
1125 | |||
1126 | usb_usual_clear_present(USB_US_TYPE_STOR); | ||
1127 | } | 1120 | } |
1128 | 1121 | ||
1129 | module_init(usb_stor_init); | 1122 | module_init(usb_stor_init); |
diff --git a/drivers/usb/storage/usual-tables.c b/drivers/usb/storage/usual-tables.c index b96927914f89..b78a526910fb 100644 --- a/drivers/usb/storage/usual-tables.c +++ b/drivers/usb/storage/usual-tables.c | |||
@@ -34,31 +34,23 @@ | |||
34 | vendorName, productName, useProtocol, useTransport, \ | 34 | vendorName, productName, useProtocol, useTransport, \ |
35 | initFunction, flags) \ | 35 | initFunction, flags) \ |
36 | { USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \ | 36 | { USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \ |
37 | .driver_info = (flags)|(USB_US_TYPE_STOR<<24) } | ||
38 | |||
39 | #define COMPLIANT_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \ | ||
40 | vendorName, productName, useProtocol, useTransport, \ | ||
41 | initFunction, flags) \ | ||
42 | { USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \ | ||
43 | .driver_info = (flags) } | 37 | .driver_info = (flags) } |
44 | 38 | ||
45 | #define USUAL_DEV(useProto, useTrans, useType) \ | 39 | #define COMPLIANT_DEV UNUSUAL_DEV |
46 | { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, useProto, useTrans), \ | 40 | |
47 | .driver_info = ((useType)<<24) } | 41 | #define USUAL_DEV(useProto, useTrans) \ |
42 | { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, useProto, useTrans) } | ||
48 | 43 | ||
49 | struct usb_device_id usb_storage_usb_ids[] = { | 44 | struct usb_device_id usb_storage_usb_ids[] = { |
50 | # include "unusual_devs.h" | 45 | # include "unusual_devs.h" |
51 | { } /* Terminating entry */ | 46 | { } /* Terminating entry */ |
52 | }; | 47 | }; |
53 | EXPORT_SYMBOL_GPL(usb_storage_usb_ids); | ||
54 | |||
55 | MODULE_DEVICE_TABLE(usb, usb_storage_usb_ids); | 48 | MODULE_DEVICE_TABLE(usb, usb_storage_usb_ids); |
56 | 49 | ||
57 | #undef UNUSUAL_DEV | 50 | #undef UNUSUAL_DEV |
58 | #undef COMPLIANT_DEV | 51 | #undef COMPLIANT_DEV |
59 | #undef USUAL_DEV | 52 | #undef USUAL_DEV |
60 | 53 | ||
61 | |||
62 | /* | 54 | /* |
63 | * The table of devices to ignore | 55 | * The table of devices to ignore |
64 | */ | 56 | */ |
@@ -95,7 +87,6 @@ static struct ignore_entry ignore_ids[] = { | |||
95 | 87 | ||
96 | #undef UNUSUAL_DEV | 88 | #undef UNUSUAL_DEV |
97 | 89 | ||
98 | |||
99 | /* Return an error if a device is in the ignore_ids list */ | 90 | /* Return an error if a device is in the ignore_ids list */ |
100 | int usb_usual_ignore_device(struct usb_interface *intf) | 91 | int usb_usual_ignore_device(struct usb_interface *intf) |
101 | { | 92 | { |
@@ -115,4 +106,3 @@ int usb_usual_ignore_device(struct usb_interface *intf) | |||
115 | } | 106 | } |
116 | return 0; | 107 | return 0; |
117 | } | 108 | } |
118 | EXPORT_SYMBOL_GPL(usb_usual_ignore_device); | ||
diff --git a/drivers/usb/wusbcore/Kconfig b/drivers/usb/wusbcore/Kconfig index f29fdd7f6d75..8bf19760d447 100644 --- a/drivers/usb/wusbcore/Kconfig +++ b/drivers/usb/wusbcore/Kconfig | |||
@@ -2,8 +2,7 @@ | |||
2 | # Wireless USB Core configuration | 2 | # Wireless USB Core configuration |
3 | # | 3 | # |
4 | config USB_WUSB | 4 | config USB_WUSB |
5 | tristate "Enable Wireless USB extensions (EXPERIMENTAL)" | 5 | tristate "Enable Wireless USB extensions" |
6 | depends on EXPERIMENTAL | ||
7 | depends on USB | 6 | depends on USB |
8 | depends on PCI | 7 | depends on PCI |
9 | depends on UWB | 8 | depends on UWB |
diff --git a/drivers/usb/wusbcore/security.c b/drivers/usb/wusbcore/security.c index fa810a83e830..dd88441c8f78 100644 --- a/drivers/usb/wusbcore/security.c +++ b/drivers/usb/wusbcore/security.c | |||
@@ -202,7 +202,7 @@ int wusb_dev_sec_add(struct wusbhc *wusbhc, | |||
202 | { | 202 | { |
203 | int result, bytes, secd_size; | 203 | int result, bytes, secd_size; |
204 | struct device *dev = &usb_dev->dev; | 204 | struct device *dev = &usb_dev->dev; |
205 | struct usb_security_descriptor *secd; | 205 | struct usb_security_descriptor *secd, *new_secd; |
206 | const struct usb_encryption_descriptor *etd, *ccm1_etd = NULL; | 206 | const struct usb_encryption_descriptor *etd, *ccm1_etd = NULL; |
207 | const void *itr, *top; | 207 | const void *itr, *top; |
208 | char buf[64]; | 208 | char buf[64]; |
@@ -221,11 +221,12 @@ int wusb_dev_sec_add(struct wusbhc *wusbhc, | |||
221 | goto out; | 221 | goto out; |
222 | } | 222 | } |
223 | secd_size = le16_to_cpu(secd->wTotalLength); | 223 | secd_size = le16_to_cpu(secd->wTotalLength); |
224 | secd = krealloc(secd, secd_size, GFP_KERNEL); | 224 | new_secd = krealloc(secd, secd_size, GFP_KERNEL); |
225 | if (secd == NULL) { | 225 | if (new_secd == NULL) { |
226 | dev_err(dev, "Can't allocate space for security descriptors\n"); | 226 | dev_err(dev, "Can't allocate space for security descriptors\n"); |
227 | goto out; | 227 | goto out; |
228 | } | 228 | } |
229 | secd = new_secd; | ||
229 | result = usb_get_descriptor(usb_dev, USB_DT_SECURITY, | 230 | result = usb_get_descriptor(usb_dev, USB_DT_SECURITY, |
230 | 0, secd, secd_size); | 231 | 0, secd, secd_size); |
231 | if (result < secd_size) { | 232 | if (result < secd_size) { |
diff --git a/drivers/usb/wusbcore/wa-hc.c b/drivers/usb/wusbcore/wa-hc.c index 9e4a92461688..a09b65ebd9bb 100644 --- a/drivers/usb/wusbcore/wa-hc.c +++ b/drivers/usb/wusbcore/wa-hc.c | |||
@@ -46,8 +46,10 @@ int wa_create(struct wahc *wa, struct usb_interface *iface) | |||
46 | wa->dto_epd = &iface->cur_altsetting->endpoint[2].desc; | 46 | wa->dto_epd = &iface->cur_altsetting->endpoint[2].desc; |
47 | wa->xfer_result_size = usb_endpoint_maxp(wa->dti_epd); | 47 | wa->xfer_result_size = usb_endpoint_maxp(wa->dti_epd); |
48 | wa->xfer_result = kmalloc(wa->xfer_result_size, GFP_KERNEL); | 48 | wa->xfer_result = kmalloc(wa->xfer_result_size, GFP_KERNEL); |
49 | if (wa->xfer_result == NULL) | 49 | if (wa->xfer_result == NULL) { |
50 | result = -ENOMEM; | ||
50 | goto error_xfer_result_alloc; | 51 | goto error_xfer_result_alloc; |
52 | } | ||
51 | result = wa_nep_create(wa, iface); | 53 | result = wa_nep_create(wa, iface); |
52 | if (result < 0) { | 54 | if (result < 0) { |
53 | dev_err(dev, "WA-CDS: can't initialize notif endpoint: %d\n", | 55 | dev_err(dev, "WA-CDS: can't initialize notif endpoint: %d\n", |