diff options
author | Michal Nazarewicz <mina86@mina86.com> | 2011-08-30 11:11:19 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-09-18 04:29:04 -0400 |
commit | e538dfdae85244fd2c4231725d82cc1f1bc4942c (patch) | |
tree | f8471dd9af305b95557d29a30f427c85418b1621 /drivers | |
parent | c58a76cdd7ab5a945a44fd2d64f6faf40323f95b (diff) |
usb: Provide usb_speed_string() function
In a few places in the kernel, the code prints
a human-readable USB device speed (eg. "high speed").
This involves a switch statement sometimes wrapped
around in ({ ... }) block leading to code repetition.
To mitigate this issue, this commit introduces
usb_speed_string() function, which returns
a human-readable name of provided speed.
It also changes a few places switch was used to use
this new function. This changes a bit the way the
speed is printed in few instances at the same time
standardising it.
Signed-off-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/usb/Kconfig | 5 | ||||
-rw-r--r-- | drivers/usb/Makefile | 2 | ||||
-rw-r--r-- | drivers/usb/core/hub.c | 27 | ||||
-rw-r--r-- | drivers/usb/gadget/amd5536udc.c | 9 | ||||
-rw-r--r-- | drivers/usb/gadget/atmel_usba_udc.c | 9 | ||||
-rw-r--r-- | drivers/usb/gadget/composite.c | 22 | ||||
-rw-r--r-- | drivers/usb/gadget/file_storage.c | 15 | ||||
-rw-r--r-- | drivers/usb/gadget/fsl_udc_core.c | 53 | ||||
-rw-r--r-- | drivers/usb/gadget/gmidi.c | 11 | ||||
-rw-r--r-- | drivers/usb/gadget/langwell_udc.c | 50 | ||||
-rw-r--r-- | drivers/usb/gadget/net2272.c | 4 | ||||
-rw-r--r-- | drivers/usb/gadget/net2280.c | 4 | ||||
-rw-r--r-- | drivers/usb/gadget/printer.c | 14 | ||||
-rw-r--r-- | drivers/usb/gadget/s3c-hsotg.c | 8 | ||||
-rw-r--r-- | drivers/usb/gadget/udc-core.c | 19 | ||||
-rw-r--r-- | drivers/usb/misc/usbtest.c | 21 | ||||
-rw-r--r-- | drivers/usb/usb-common.c | 35 |
17 files changed, 113 insertions, 195 deletions
diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig index 2651852952be..97c4cc724189 100644 --- a/drivers/usb/Kconfig +++ b/drivers/usb/Kconfig | |||
@@ -12,6 +12,11 @@ menuconfig USB_SUPPORT | |||
12 | 12 | ||
13 | if USB_SUPPORT | 13 | if USB_SUPPORT |
14 | 14 | ||
15 | config USB_COMMON | ||
16 | tristate | ||
17 | default y | ||
18 | depends on USB || USB_GADGET | ||
19 | |||
15 | # Host-side USB depends on having a host controller | 20 | # Host-side USB depends on having a host controller |
16 | # NOTE: dummy_hcd is always an option, but it's ignored here ... | 21 | # NOTE: dummy_hcd is always an option, but it's ignored here ... |
17 | # NOTE: SL-811 option should be board-specific ... | 22 | # NOTE: SL-811 option should be board-specific ... |
diff --git a/drivers/usb/Makefile b/drivers/usb/Makefile index 969b0a50bc98..75eca7645227 100644 --- a/drivers/usb/Makefile +++ b/drivers/usb/Makefile | |||
@@ -53,3 +53,5 @@ obj-$(CONFIG_USB_MUSB_HDRC) += musb/ | |||
53 | obj-$(CONFIG_USB_RENESAS_USBHS) += renesas_usbhs/ | 53 | obj-$(CONFIG_USB_RENESAS_USBHS) += renesas_usbhs/ |
54 | obj-$(CONFIG_USB_OTG_UTILS) += otg/ | 54 | obj-$(CONFIG_USB_OTG_UTILS) += otg/ |
55 | obj-$(CONFIG_USB_GADGET) += gadget/ | 55 | obj-$(CONFIG_USB_GADGET) += gadget/ |
56 | |||
57 | obj-$(CONFIG_USB_COMMON) += usb-common.o | ||
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 338f91ff54cb..3edc01bc41f7 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c | |||
@@ -2793,7 +2793,7 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1, | |||
2793 | int i, j, retval; | 2793 | int i, j, retval; |
2794 | unsigned delay = HUB_SHORT_RESET_TIME; | 2794 | unsigned delay = HUB_SHORT_RESET_TIME; |
2795 | enum usb_device_speed oldspeed = udev->speed; | 2795 | enum usb_device_speed oldspeed = udev->speed; |
2796 | char *speed, *type; | 2796 | const char *speed; |
2797 | int devnum = udev->devnum; | 2797 | int devnum = udev->devnum; |
2798 | 2798 | ||
2799 | /* root hub ports have a slightly longer reset period | 2799 | /* root hub ports have a slightly longer reset period |
@@ -2853,25 +2853,16 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1, | |||
2853 | default: | 2853 | default: |
2854 | goto fail; | 2854 | goto fail; |
2855 | } | 2855 | } |
2856 | 2856 | ||
2857 | type = ""; | 2857 | if (udev->speed == USB_SPEED_WIRELESS) |
2858 | switch (udev->speed) { | 2858 | speed = "variable speed Wireless"; |
2859 | case USB_SPEED_LOW: speed = "low"; break; | 2859 | else |
2860 | case USB_SPEED_FULL: speed = "full"; break; | 2860 | speed = usb_speed_string(udev->speed); |
2861 | case USB_SPEED_HIGH: speed = "high"; break; | 2861 | |
2862 | case USB_SPEED_SUPER: | ||
2863 | speed = "super"; | ||
2864 | break; | ||
2865 | case USB_SPEED_WIRELESS: | ||
2866 | speed = "variable"; | ||
2867 | type = "Wireless "; | ||
2868 | break; | ||
2869 | default: speed = "?"; break; | ||
2870 | } | ||
2871 | if (udev->speed != USB_SPEED_SUPER) | 2862 | if (udev->speed != USB_SPEED_SUPER) |
2872 | dev_info(&udev->dev, | 2863 | dev_info(&udev->dev, |
2873 | "%s %s speed %sUSB device number %d using %s\n", | 2864 | "%s %s USB device number %d using %s\n", |
2874 | (udev->config) ? "reset" : "new", speed, type, | 2865 | (udev->config) ? "reset" : "new", speed, |
2875 | devnum, udev->bus->controller->driver->name); | 2866 | devnum, udev->bus->controller->driver->name); |
2876 | 2867 | ||
2877 | /* Set up TT records, if needed */ | 2868 | /* Set up TT records, if needed */ |
diff --git a/drivers/usb/gadget/amd5536udc.c b/drivers/usb/gadget/amd5536udc.c index ded8d6fddb53..4730016d7cd4 100644 --- a/drivers/usb/gadget/amd5536udc.c +++ b/drivers/usb/gadget/amd5536udc.c | |||
@@ -3005,13 +3005,8 @@ __acquires(dev->lock) | |||
3005 | 3005 | ||
3006 | /* link up all endpoints */ | 3006 | /* link up all endpoints */ |
3007 | udc_setup_endpoints(dev); | 3007 | udc_setup_endpoints(dev); |
3008 | if (dev->gadget.speed == USB_SPEED_HIGH) { | 3008 | dev_info(&dev->pdev->dev, "Connect: %s\n", |
3009 | dev_info(&dev->pdev->dev, "Connect: speed = %s\n", | 3009 | usb_speed_string(dev->gadget.speed)); |
3010 | "high"); | ||
3011 | } else if (dev->gadget.speed == USB_SPEED_FULL) { | ||
3012 | dev_info(&dev->pdev->dev, "Connect: speed = %s\n", | ||
3013 | "full"); | ||
3014 | } | ||
3015 | 3010 | ||
3016 | /* init ep 0 */ | 3011 | /* init ep 0 */ |
3017 | activate_control_endpoints(dev); | 3012 | activate_control_endpoints(dev); |
diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c index 722c468e9b3c..271a9d873608 100644 --- a/drivers/usb/gadget/atmel_usba_udc.c +++ b/drivers/usb/gadget/atmel_usba_udc.c | |||
@@ -1718,13 +1718,12 @@ static irqreturn_t usba_udc_irq(int irq, void *devid) | |||
1718 | spin_lock(&udc->lock); | 1718 | spin_lock(&udc->lock); |
1719 | } | 1719 | } |
1720 | 1720 | ||
1721 | if (status & USBA_HIGH_SPEED) { | 1721 | if (status & USBA_HIGH_SPEED) |
1722 | DBG(DBG_BUS, "High-speed bus reset detected\n"); | ||
1723 | udc->gadget.speed = USB_SPEED_HIGH; | 1722 | udc->gadget.speed = USB_SPEED_HIGH; |
1724 | } else { | 1723 | else |
1725 | DBG(DBG_BUS, "Full-speed bus reset detected\n"); | ||
1726 | udc->gadget.speed = USB_SPEED_FULL; | 1724 | udc->gadget.speed = USB_SPEED_FULL; |
1727 | } | 1725 | DBG(DBG_BUS, "%s bus reset detected\n", |
1726 | usb_speed_string(udc->gadget.speed)); | ||
1728 | 1727 | ||
1729 | ep0 = &usba_ep[0]; | 1728 | ep0 = &usba_ep[0]; |
1730 | ep0->desc = &usba_ep0_desc; | 1729 | ep0->desc = &usba_ep0_desc; |
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index c77aca11ad53..e74fd55c33d9 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c | |||
@@ -617,25 +617,9 @@ static int set_config(struct usb_composite_dev *cdev, | |||
617 | result = 0; | 617 | result = 0; |
618 | } | 618 | } |
619 | 619 | ||
620 | INFO(cdev, "%s speed config #%d: %s\n", | 620 | INFO(cdev, "%s config #%d: %s\n", |
621 | ({ char *speed; | 621 | usb_speed_string(gadget->speed), |
622 | switch (gadget->speed) { | 622 | number, c ? c->label : "unconfigured"); |
623 | case USB_SPEED_LOW: | ||
624 | speed = "low"; | ||
625 | break; | ||
626 | case USB_SPEED_FULL: | ||
627 | speed = "full"; | ||
628 | break; | ||
629 | case USB_SPEED_HIGH: | ||
630 | speed = "high"; | ||
631 | break; | ||
632 | case USB_SPEED_SUPER: | ||
633 | speed = "super"; | ||
634 | break; | ||
635 | default: | ||
636 | speed = "?"; | ||
637 | break; | ||
638 | } ; speed; }), number, c ? c->label : "unconfigured"); | ||
639 | 623 | ||
640 | if (!c) | 624 | if (!c) |
641 | goto done; | 625 | goto done; |
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c index 39ece40a045f..4ac8084b579c 100644 --- a/drivers/usb/gadget/file_storage.c +++ b/drivers/usb/gadget/file_storage.c | |||
@@ -2862,17 +2862,10 @@ static int do_set_config(struct fsg_dev *fsg, u8 new_config) | |||
2862 | fsg->config = new_config; | 2862 | fsg->config = new_config; |
2863 | if ((rc = do_set_interface(fsg, 0)) != 0) | 2863 | if ((rc = do_set_interface(fsg, 0)) != 0) |
2864 | fsg->config = 0; // Reset on errors | 2864 | fsg->config = 0; // Reset on errors |
2865 | else { | 2865 | else |
2866 | char *speed; | 2866 | INFO(fsg, "%s config #%d\n", |
2867 | 2867 | usb_speed_string(fsg->gadget->speed), | |
2868 | switch (fsg->gadget->speed) { | 2868 | fsg->config); |
2869 | case USB_SPEED_LOW: speed = "low"; break; | ||
2870 | case USB_SPEED_FULL: speed = "full"; break; | ||
2871 | case USB_SPEED_HIGH: speed = "high"; break; | ||
2872 | default: speed = "?"; break; | ||
2873 | } | ||
2874 | INFO(fsg, "%s speed config #%d\n", speed, fsg->config); | ||
2875 | } | ||
2876 | } | 2869 | } |
2877 | return rc; | 2870 | return rc; |
2878 | } | 2871 | } |
diff --git a/drivers/usb/gadget/fsl_udc_core.c b/drivers/usb/gadget/fsl_udc_core.c index d6993507165b..b2c44e1d5813 100644 --- a/drivers/usb/gadget/fsl_udc_core.c +++ b/drivers/usb/gadget/fsl_udc_core.c | |||
@@ -1715,34 +1715,31 @@ static void dtd_complete_irq(struct fsl_udc *udc) | |||
1715 | } | 1715 | } |
1716 | } | 1716 | } |
1717 | 1717 | ||
1718 | static inline enum usb_device_speed portscx_device_speed(u32 reg) | ||
1719 | { | ||
1720 | switch (speed & PORTSCX_PORT_SPEED_MASK) { | ||
1721 | case PORTSCX_PORT_SPEED_HIGH: | ||
1722 | return USB_SPEED_HIGH; | ||
1723 | case PORTSCX_PORT_SPEED_FULL: | ||
1724 | return USB_SPEED_FULL; | ||
1725 | case PORTSCX_PORT_SPEED_LOW: | ||
1726 | return USB_SPEED_LOW; | ||
1727 | default: | ||
1728 | return USB_SPEED_UNKNOWN; | ||
1729 | } | ||
1730 | } | ||
1731 | |||
1718 | /* Process a port change interrupt */ | 1732 | /* Process a port change interrupt */ |
1719 | static void port_change_irq(struct fsl_udc *udc) | 1733 | static void port_change_irq(struct fsl_udc *udc) |
1720 | { | 1734 | { |
1721 | u32 speed; | ||
1722 | |||
1723 | if (udc->bus_reset) | 1735 | if (udc->bus_reset) |
1724 | udc->bus_reset = 0; | 1736 | udc->bus_reset = 0; |
1725 | 1737 | ||
1726 | /* Bus resetting is finished */ | 1738 | /* Bus resetting is finished */ |
1727 | if (!(fsl_readl(&dr_regs->portsc1) & PORTSCX_PORT_RESET)) { | 1739 | if (!(fsl_readl(&dr_regs->portsc1) & PORTSCX_PORT_RESET)) |
1728 | /* Get the speed */ | 1740 | /* Get the speed */ |
1729 | speed = (fsl_readl(&dr_regs->portsc1) | 1741 | udc->gadget.speed = |
1730 | & PORTSCX_PORT_SPEED_MASK); | 1742 | portscx_device_speed(fsl_readl(&dr_regs->portsc1)); |
1731 | switch (speed) { | ||
1732 | case PORTSCX_PORT_SPEED_HIGH: | ||
1733 | udc->gadget.speed = USB_SPEED_HIGH; | ||
1734 | break; | ||
1735 | case PORTSCX_PORT_SPEED_FULL: | ||
1736 | udc->gadget.speed = USB_SPEED_FULL; | ||
1737 | break; | ||
1738 | case PORTSCX_PORT_SPEED_LOW: | ||
1739 | udc->gadget.speed = USB_SPEED_LOW; | ||
1740 | break; | ||
1741 | default: | ||
1742 | udc->gadget.speed = USB_SPEED_UNKNOWN; | ||
1743 | break; | ||
1744 | } | ||
1745 | } | ||
1746 | 1743 | ||
1747 | /* Update USB state */ | 1744 | /* Update USB state */ |
1748 | if (!udc->resume_state) | 1745 | if (!udc->resume_state) |
@@ -2167,20 +2164,8 @@ static int fsl_proc_read(char *page, char **start, off_t off, int count, | |||
2167 | default: | 2164 | default: |
2168 | s = "None"; break; | 2165 | s = "None"; break; |
2169 | } | 2166 | } |
2170 | s;} ), ( { | 2167 | s;} ), |
2171 | char *s; | 2168 | usb_speed_string(portscx_device_speed(tmp_reg)), |
2172 | switch (tmp_reg & PORTSCX_PORT_SPEED_UNDEF) { | ||
2173 | case PORTSCX_PORT_SPEED_FULL: | ||
2174 | s = "Full Speed"; break; | ||
2175 | case PORTSCX_PORT_SPEED_LOW: | ||
2176 | s = "Low Speed"; break; | ||
2177 | case PORTSCX_PORT_SPEED_HIGH: | ||
2178 | s = "High Speed"; break; | ||
2179 | default: | ||
2180 | s = "Undefined"; break; | ||
2181 | } | ||
2182 | s; | ||
2183 | } ), | ||
2184 | (tmp_reg & PORTSCX_PHY_LOW_POWER_SPD) ? | 2169 | (tmp_reg & PORTSCX_PHY_LOW_POWER_SPD) ? |
2185 | "Normal PHY mode" : "Low power mode", | 2170 | "Normal PHY mode" : "Low power mode", |
2186 | (tmp_reg & PORTSCX_PORT_RESET) ? "In Reset" : | 2171 | (tmp_reg & PORTSCX_PORT_RESET) ? "In Reset" : |
diff --git a/drivers/usb/gadget/gmidi.c b/drivers/usb/gadget/gmidi.c index 8b9220e128a7..893b967b0aff 100644 --- a/drivers/usb/gadget/gmidi.c +++ b/drivers/usb/gadget/gmidi.c | |||
@@ -640,17 +640,8 @@ gmidi_set_config(struct gmidi_device *dev, unsigned number, gfp_t gfp_flags) | |||
640 | if (result) { | 640 | if (result) { |
641 | gmidi_reset_config(dev); | 641 | gmidi_reset_config(dev); |
642 | } else { | 642 | } else { |
643 | char *speed; | ||
644 | |||
645 | switch (gadget->speed) { | ||
646 | case USB_SPEED_LOW: speed = "low"; break; | ||
647 | case USB_SPEED_FULL: speed = "full"; break; | ||
648 | case USB_SPEED_HIGH: speed = "high"; break; | ||
649 | default: speed = "?"; break; | ||
650 | } | ||
651 | |||
652 | dev->config = number; | 643 | dev->config = number; |
653 | INFO(dev, "%s speed\n", speed); | 644 | INFO(dev, "%s speed\n", usb_speed_string(gadget->speed)); |
654 | } | 645 | } |
655 | return result; | 646 | return result; |
656 | } | 647 | } |
diff --git a/drivers/usb/gadget/langwell_udc.c b/drivers/usb/gadget/langwell_udc.c index 6e444995d398..c88158f307a8 100644 --- a/drivers/usb/gadget/langwell_udc.c +++ b/drivers/usb/gadget/langwell_udc.c | |||
@@ -1690,20 +1690,7 @@ static ssize_t show_langwell_udc(struct device *_dev, | |||
1690 | "BmAttributes: %d\n\n", | 1690 | "BmAttributes: %d\n\n", |
1691 | LPM_PTS(tmp_reg), | 1691 | LPM_PTS(tmp_reg), |
1692 | (tmp_reg & LPM_STS) ? 1 : 0, | 1692 | (tmp_reg & LPM_STS) ? 1 : 0, |
1693 | ({ | 1693 | usb_speed_string(lpm_device_speed(tmp_reg)), |
1694 | char *s; | ||
1695 | switch (LPM_PSPD(tmp_reg)) { | ||
1696 | case LPM_SPEED_FULL: | ||
1697 | s = "Full Speed"; break; | ||
1698 | case LPM_SPEED_LOW: | ||
1699 | s = "Low Speed"; break; | ||
1700 | case LPM_SPEED_HIGH: | ||
1701 | s = "High Speed"; break; | ||
1702 | default: | ||
1703 | s = "Unknown Speed"; break; | ||
1704 | } | ||
1705 | s; | ||
1706 | }), | ||
1707 | (tmp_reg & LPM_PFSC) ? "Force Full Speed" : "Not Force", | 1694 | (tmp_reg & LPM_PFSC) ? "Force Full Speed" : "Not Force", |
1708 | (tmp_reg & LPM_PHCD) ? "Disabled" : "Enabled", | 1695 | (tmp_reg & LPM_PHCD) ? "Disabled" : "Enabled", |
1709 | LPM_BA(tmp_reg)); | 1696 | LPM_BA(tmp_reg)); |
@@ -2647,12 +2634,24 @@ done: | |||
2647 | dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__); | 2634 | dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__); |
2648 | } | 2635 | } |
2649 | 2636 | ||
2637 | static inline enum usb_device_speed lpm_device_speed(u32 reg) | ||
2638 | { | ||
2639 | switch (LPM_PSPD(reg)) { | ||
2640 | case LPM_SPEED_HIGH: | ||
2641 | return USB_SPEED_HIGH; | ||
2642 | case LPM_SPEED_FULL: | ||
2643 | return USB_SPEED_FULL; | ||
2644 | case LPM_SPEED_LOW: | ||
2645 | return USB_SPEED_LOW; | ||
2646 | default: | ||
2647 | return USB_SPEED_UNKNOWN; | ||
2648 | } | ||
2649 | } | ||
2650 | 2650 | ||
2651 | /* port change detect interrupt handler */ | 2651 | /* port change detect interrupt handler */ |
2652 | static void handle_port_change(struct langwell_udc *dev) | 2652 | static void handle_port_change(struct langwell_udc *dev) |
2653 | { | 2653 | { |
2654 | u32 portsc1, devlc; | 2654 | u32 portsc1, devlc; |
2655 | u32 speed; | ||
2656 | 2655 | ||
2657 | dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__); | 2656 | dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__); |
2658 | 2657 | ||
@@ -2667,24 +2666,9 @@ static void handle_port_change(struct langwell_udc *dev) | |||
2667 | /* bus reset is finished */ | 2666 | /* bus reset is finished */ |
2668 | if (!(portsc1 & PORTS_PR)) { | 2667 | if (!(portsc1 & PORTS_PR)) { |
2669 | /* get the speed */ | 2668 | /* get the speed */ |
2670 | speed = LPM_PSPD(devlc); | 2669 | dev->gadget.speed = lpm_device_speed(devlc); |
2671 | switch (speed) { | 2670 | dev_vdbg(&dev->pdev->dev, "dev->gadget.speed = %d\n", |
2672 | case LPM_SPEED_HIGH: | 2671 | dev->gadget.speed); |
2673 | dev->gadget.speed = USB_SPEED_HIGH; | ||
2674 | break; | ||
2675 | case LPM_SPEED_FULL: | ||
2676 | dev->gadget.speed = USB_SPEED_FULL; | ||
2677 | break; | ||
2678 | case LPM_SPEED_LOW: | ||
2679 | dev->gadget.speed = USB_SPEED_LOW; | ||
2680 | break; | ||
2681 | default: | ||
2682 | dev->gadget.speed = USB_SPEED_UNKNOWN; | ||
2683 | break; | ||
2684 | } | ||
2685 | dev_vdbg(&dev->pdev->dev, | ||
2686 | "speed = %d, dev->gadget.speed = %d\n", | ||
2687 | speed, dev->gadget.speed); | ||
2688 | } | 2672 | } |
2689 | 2673 | ||
2690 | /* LPM L0 to L1 */ | 2674 | /* LPM L0 to L1 */ |
diff --git a/drivers/usb/gadget/net2272.c b/drivers/usb/gadget/net2272.c index 6fef1c02448e..08a4a36550d2 100644 --- a/drivers/usb/gadget/net2272.c +++ b/drivers/usb/gadget/net2272.c | |||
@@ -1764,8 +1764,8 @@ net2272_handle_stat0_irqs(struct net2272 *dev, u8 stat) | |||
1764 | dev->gadget.speed = USB_SPEED_HIGH; | 1764 | dev->gadget.speed = USB_SPEED_HIGH; |
1765 | else | 1765 | else |
1766 | dev->gadget.speed = USB_SPEED_FULL; | 1766 | dev->gadget.speed = USB_SPEED_FULL; |
1767 | dev_dbg(dev->dev, "%s speed\n", | 1767 | dev_dbg(dev->dev, "%s\n", |
1768 | (dev->gadget.speed == USB_SPEED_HIGH) ? "high" : "full"); | 1768 | usb_speed_string(dev->gadget.speed)); |
1769 | } | 1769 | } |
1770 | 1770 | ||
1771 | ep = &dev->ep[0]; | 1771 | ep = &dev->ep[0]; |
diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c index 3c14c4ea8efd..db508d0bb3af 100644 --- a/drivers/usb/gadget/net2280.c +++ b/drivers/usb/gadget/net2280.c | |||
@@ -2257,9 +2257,7 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat) | |||
2257 | else | 2257 | else |
2258 | dev->gadget.speed = USB_SPEED_FULL; | 2258 | dev->gadget.speed = USB_SPEED_FULL; |
2259 | net2280_led_speed (dev, dev->gadget.speed); | 2259 | net2280_led_speed (dev, dev->gadget.speed); |
2260 | DEBUG (dev, "%s speed\n", | 2260 | DEBUG(dev, "%s\n", usb_speed_string(dev->gadget.speed)); |
2261 | (dev->gadget.speed == USB_SPEED_HIGH) | ||
2262 | ? "high" : "full"); | ||
2263 | } | 2261 | } |
2264 | 2262 | ||
2265 | ep = &dev->ep [0]; | 2263 | ep = &dev->ep [0]; |
diff --git a/drivers/usb/gadget/printer.c b/drivers/usb/gadget/printer.c index 5d3e697b7d5d..68a0efbc2719 100644 --- a/drivers/usb/gadget/printer.c +++ b/drivers/usb/gadget/printer.c | |||
@@ -962,23 +962,15 @@ printer_set_config(struct printer_dev *dev, unsigned number) | |||
962 | usb_gadget_vbus_draw(dev->gadget, | 962 | usb_gadget_vbus_draw(dev->gadget, |
963 | dev->gadget->is_otg ? 8 : 100); | 963 | dev->gadget->is_otg ? 8 : 100); |
964 | } else { | 964 | } else { |
965 | char *speed; | ||
966 | unsigned power; | 965 | unsigned power; |
967 | 966 | ||
968 | power = 2 * config_desc.bMaxPower; | 967 | power = 2 * config_desc.bMaxPower; |
969 | usb_gadget_vbus_draw(dev->gadget, power); | 968 | usb_gadget_vbus_draw(dev->gadget, power); |
970 | 969 | ||
971 | switch (gadget->speed) { | ||
972 | case USB_SPEED_FULL: speed = "full"; break; | ||
973 | #ifdef CONFIG_USB_GADGET_DUALSPEED | ||
974 | case USB_SPEED_HIGH: speed = "high"; break; | ||
975 | #endif | ||
976 | default: speed = "?"; break; | ||
977 | } | ||
978 | |||
979 | dev->config = number; | 970 | dev->config = number; |
980 | INFO(dev, "%s speed config #%d: %d mA, %s\n", | 971 | INFO(dev, "%s config #%d: %d mA, %s\n", |
981 | speed, number, power, driver_desc); | 972 | usb_speed_string(gadget->speed), |
973 | number, power, driver_desc); | ||
982 | } | 974 | } |
983 | return result; | 975 | return result; |
984 | } | 976 | } |
diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c index 39b134dec94c..a552453dc946 100644 --- a/drivers/usb/gadget/s3c-hsotg.c +++ b/drivers/usb/gadget/s3c-hsotg.c | |||
@@ -1951,30 +1951,26 @@ static void s3c_hsotg_irq_enumdone(struct s3c_hsotg *hsotg) | |||
1951 | case S3C_DSTS_EnumSpd_FS: | 1951 | case S3C_DSTS_EnumSpd_FS: |
1952 | case S3C_DSTS_EnumSpd_FS48: | 1952 | case S3C_DSTS_EnumSpd_FS48: |
1953 | hsotg->gadget.speed = USB_SPEED_FULL; | 1953 | hsotg->gadget.speed = USB_SPEED_FULL; |
1954 | dev_info(hsotg->dev, "new device is full-speed\n"); | ||
1955 | |||
1956 | ep0_mps = EP0_MPS_LIMIT; | 1954 | ep0_mps = EP0_MPS_LIMIT; |
1957 | ep_mps = 64; | 1955 | ep_mps = 64; |
1958 | break; | 1956 | break; |
1959 | 1957 | ||
1960 | case S3C_DSTS_EnumSpd_HS: | 1958 | case S3C_DSTS_EnumSpd_HS: |
1961 | dev_info(hsotg->dev, "new device is high-speed\n"); | ||
1962 | hsotg->gadget.speed = USB_SPEED_HIGH; | 1959 | hsotg->gadget.speed = USB_SPEED_HIGH; |
1963 | |||
1964 | ep0_mps = EP0_MPS_LIMIT; | 1960 | ep0_mps = EP0_MPS_LIMIT; |
1965 | ep_mps = 512; | 1961 | ep_mps = 512; |
1966 | break; | 1962 | break; |
1967 | 1963 | ||
1968 | case S3C_DSTS_EnumSpd_LS: | 1964 | case S3C_DSTS_EnumSpd_LS: |
1969 | hsotg->gadget.speed = USB_SPEED_LOW; | 1965 | hsotg->gadget.speed = USB_SPEED_LOW; |
1970 | dev_info(hsotg->dev, "new device is low-speed\n"); | ||
1971 | |||
1972 | /* note, we don't actually support LS in this driver at the | 1966 | /* note, we don't actually support LS in this driver at the |
1973 | * moment, and the documentation seems to imply that it isn't | 1967 | * moment, and the documentation seems to imply that it isn't |
1974 | * supported by the PHYs on some of the devices. | 1968 | * supported by the PHYs on some of the devices. |
1975 | */ | 1969 | */ |
1976 | break; | 1970 | break; |
1977 | } | 1971 | } |
1972 | dev_info(hsotg->dev, "new device is %s\n", | ||
1973 | usb_speed_string(hsotg->gadget.speed)); | ||
1978 | 1974 | ||
1979 | /* we should now know the maximum packet size for an | 1975 | /* we should now know the maximum packet size for an |
1980 | * endpoint, so set the endpoints to a default value. */ | 1976 | * endpoint, so set the endpoints to a default value. */ |
diff --git a/drivers/usb/gadget/udc-core.c b/drivers/usb/gadget/udc-core.c index 05ba47214361..5e77a46a429a 100644 --- a/drivers/usb/gadget/udc-core.c +++ b/drivers/usb/gadget/udc-core.c | |||
@@ -375,23 +375,8 @@ static ssize_t usb_udc_speed_show(struct device *dev, | |||
375 | struct device_attribute *attr, char *buf) | 375 | struct device_attribute *attr, char *buf) |
376 | { | 376 | { |
377 | struct usb_udc *udc = container_of(dev, struct usb_udc, dev); | 377 | struct usb_udc *udc = container_of(dev, struct usb_udc, dev); |
378 | struct usb_gadget *gadget = udc->gadget; | 378 | return snprintf(buf, PAGE_SIZE, "%s\n", |
379 | 379 | usb_speed_string(udc->gadget->speed)); | |
380 | switch (gadget->speed) { | ||
381 | case USB_SPEED_LOW: | ||
382 | return snprintf(buf, PAGE_SIZE, "low-speed\n"); | ||
383 | case USB_SPEED_FULL: | ||
384 | return snprintf(buf, PAGE_SIZE, "full-speed\n"); | ||
385 | case USB_SPEED_HIGH: | ||
386 | return snprintf(buf, PAGE_SIZE, "high-speed\n"); | ||
387 | case USB_SPEED_WIRELESS: | ||
388 | return snprintf(buf, PAGE_SIZE, "wireless\n"); | ||
389 | case USB_SPEED_SUPER: | ||
390 | return snprintf(buf, PAGE_SIZE, "super-speed\n"); | ||
391 | case USB_SPEED_UNKNOWN: /* FALLTHROUGH */ | ||
392 | default: | ||
393 | return snprintf(buf, PAGE_SIZE, "UNKNOWN\n"); | ||
394 | } | ||
395 | } | 380 | } |
396 | static DEVICE_ATTR(speed, S_IRUSR, usb_udc_speed_show, NULL); | 381 | static DEVICE_ATTR(speed, S_IRUSR, usb_udc_speed_show, NULL); |
397 | 382 | ||
diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c index 930962f49276..bd6d00802eab 100644 --- a/drivers/usb/misc/usbtest.c +++ b/drivers/usb/misc/usbtest.c | |||
@@ -2300,25 +2300,8 @@ usbtest_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
2300 | 2300 | ||
2301 | usb_set_intfdata(intf, dev); | 2301 | usb_set_intfdata(intf, dev); |
2302 | dev_info(&intf->dev, "%s\n", info->name); | 2302 | dev_info(&intf->dev, "%s\n", info->name); |
2303 | dev_info(&intf->dev, "%s speed {control%s%s%s%s%s} tests%s\n", | 2303 | dev_info(&intf->dev, "%s {control%s%s%s%s%s} tests%s\n", |
2304 | ({ char *tmp; | 2304 | usb_speed_string(udev->speed), |
2305 | switch (udev->speed) { | ||
2306 | case USB_SPEED_LOW: | ||
2307 | tmp = "low"; | ||
2308 | break; | ||
2309 | case USB_SPEED_FULL: | ||
2310 | tmp = "full"; | ||
2311 | break; | ||
2312 | case USB_SPEED_HIGH: | ||
2313 | tmp = "high"; | ||
2314 | break; | ||
2315 | case USB_SPEED_SUPER: | ||
2316 | tmp = "super"; | ||
2317 | break; | ||
2318 | default: | ||
2319 | tmp = "unknown"; | ||
2320 | break; | ||
2321 | }; tmp; }), | ||
2322 | info->ctrl_out ? " in/out" : "", | 2305 | info->ctrl_out ? " in/out" : "", |
2323 | rtest, wtest, | 2306 | rtest, wtest, |
2324 | irtest, iwtest, | 2307 | irtest, iwtest, |
diff --git a/drivers/usb/usb-common.c b/drivers/usb/usb-common.c new file mode 100644 index 000000000000..d29503e954ab --- /dev/null +++ b/drivers/usb/usb-common.c | |||
@@ -0,0 +1,35 @@ | |||
1 | /* | ||
2 | * Provides code common for host and device side USB. | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or | ||
5 | * modify it under the terms of the GNU General Public License as | ||
6 | * published by the Free Software Foundation, version 2. | ||
7 | * | ||
8 | * If either host side (ie. CONFIG_USB=y) or device side USB stack | ||
9 | * (ie. CONFIG_USB_GADGET=y) is compiled in the kernel, this module is | ||
10 | * compiled-in as well. Otherwise, if either of the two stacks is | ||
11 | * compiled as module, this file is compiled as module as well. | ||
12 | */ | ||
13 | |||
14 | #include <linux/kernel.h> | ||
15 | #include <linux/module.h> | ||
16 | #include <linux/usb/ch9.h> | ||
17 | |||
18 | const char *usb_speed_string(enum usb_device_speed speed) | ||
19 | { | ||
20 | static const char *const names[] = { | ||
21 | [USB_SPEED_UNKNOWN] = "UNKNOWN", | ||
22 | [USB_SPEED_LOW] = "low-speed", | ||
23 | [USB_SPEED_FULL] = "full-speed", | ||
24 | [USB_SPEED_HIGH] = "high-speed", | ||
25 | [USB_SPEED_WIRELESS] = "wireless", | ||
26 | [USB_SPEED_SUPER] = "super-speed", | ||
27 | }; | ||
28 | |||
29 | if (speed < 0 || speed >= ARRAY_SIZE(names)) | ||
30 | speed = USB_SPEED_UNKNOWN; | ||
31 | return names[speed]; | ||
32 | } | ||
33 | EXPORT_SYMBOL_GPL(usb_speed_string); | ||
34 | |||
35 | MODULE_LICENSE("GPL"); | ||