Michal Nazarewicz | e538dfd | 2011-08-30 17:11:19 +0200 | [diff] [blame] | 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 | |
Felipe Balbi | d1e3d75 | 2013-01-24 22:29:48 +0200 | [diff] [blame^] | 35 | const char *usb_state_string(enum usb_device_state state) |
| 36 | { |
| 37 | static const char *const names[] = { |
| 38 | [USB_STATE_NOTATTACHED] = "not attached", |
| 39 | [USB_STATE_ATTACHED] = "attached", |
| 40 | [USB_STATE_POWERED] = "powered", |
| 41 | [USB_STATE_RECONNECTING] = "reconnecting", |
| 42 | [USB_STATE_UNAUTHENTICATED] = "unauthenticated", |
| 43 | [USB_STATE_DEFAULT] = "default", |
| 44 | [USB_STATE_ADDRESS] = "addresssed", |
| 45 | [USB_STATE_CONFIGURED] = "configured", |
| 46 | [USB_STATE_SUSPENDED] = "suspended", |
| 47 | }; |
| 48 | |
| 49 | if (state < 0 || state >= ARRAY_SIZE(names)) |
| 50 | return "UNKNOWN"; |
| 51 | |
| 52 | return names[state]; |
| 53 | } |
| 54 | EXPORT_SYMBOL_GPL(usb_state_string); |
| 55 | |
Michal Nazarewicz | e538dfd | 2011-08-30 17:11:19 +0200 | [diff] [blame] | 56 | MODULE_LICENSE("GPL"); |