Merge branch 'for-3.10' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/percpu
[firefly-linux-kernel-4.4.55.git] / drivers / usb / usb-common.c
index 070b681e5d17afbba8c8c7f8e9065ebb8227407c..0db0a919d72b2a0a7460f2e6fc7aeee639aebf5c 100644 (file)
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/usb/ch9.h>
+#include <linux/usb/otg.h>
+
+const char *usb_otg_state_string(enum usb_otg_state state)
+{
+       static const char *const names[] = {
+               [OTG_STATE_A_IDLE] = "a_idle",
+               [OTG_STATE_A_WAIT_VRISE] = "a_wait_vrise",
+               [OTG_STATE_A_WAIT_BCON] = "a_wait_bcon",
+               [OTG_STATE_A_HOST] = "a_host",
+               [OTG_STATE_A_SUSPEND] = "a_suspend",
+               [OTG_STATE_A_PERIPHERAL] = "a_peripheral",
+               [OTG_STATE_A_WAIT_VFALL] = "a_wait_vfall",
+               [OTG_STATE_A_VBUS_ERR] = "a_vbus_err",
+               [OTG_STATE_B_IDLE] = "b_idle",
+               [OTG_STATE_B_SRP_INIT] = "b_srp_init",
+               [OTG_STATE_B_PERIPHERAL] = "b_peripheral",
+               [OTG_STATE_B_WAIT_ACON] = "b_wait_acon",
+               [OTG_STATE_B_HOST] = "b_host",
+       };
+
+       if (state < 0 || state >= ARRAY_SIZE(names))
+               return "UNDEFINED";
+
+       return names[state];
+}
+EXPORT_SYMBOL_GPL(usb_otg_state_string);
 
 const char *usb_speed_string(enum usb_device_speed speed)
 {