linux/drivers/usb/usb-common.c
<<
>>
Prefs
   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#include <linux/usb/otg.h>
  18
  19const char *usb_otg_state_string(enum usb_otg_state state)
  20{
  21        static const char *const names[] = {
  22                [OTG_STATE_A_IDLE] = "a_idle",
  23                [OTG_STATE_A_WAIT_VRISE] = "a_wait_vrise",
  24                [OTG_STATE_A_WAIT_BCON] = "a_wait_bcon",
  25                [OTG_STATE_A_HOST] = "a_host",
  26                [OTG_STATE_A_SUSPEND] = "a_suspend",
  27                [OTG_STATE_A_PERIPHERAL] = "a_peripheral",
  28                [OTG_STATE_A_WAIT_VFALL] = "a_wait_vfall",
  29                [OTG_STATE_A_VBUS_ERR] = "a_vbus_err",
  30                [OTG_STATE_B_IDLE] = "b_idle",
  31                [OTG_STATE_B_SRP_INIT] = "b_srp_init",
  32                [OTG_STATE_B_PERIPHERAL] = "b_peripheral",
  33                [OTG_STATE_B_WAIT_ACON] = "b_wait_acon",
  34                [OTG_STATE_B_HOST] = "b_host",
  35        };
  36
  37        if (state < 0 || state >= ARRAY_SIZE(names))
  38                return "UNDEFINED";
  39
  40        return names[state];
  41}
  42EXPORT_SYMBOL_GPL(usb_otg_state_string);
  43
  44const char *usb_speed_string(enum usb_device_speed speed)
  45{
  46        static const char *const names[] = {
  47                [USB_SPEED_UNKNOWN] = "UNKNOWN",
  48                [USB_SPEED_LOW] = "low-speed",
  49                [USB_SPEED_FULL] = "full-speed",
  50                [USB_SPEED_HIGH] = "high-speed",
  51                [USB_SPEED_WIRELESS] = "wireless",
  52                [USB_SPEED_SUPER] = "super-speed",
  53        };
  54
  55        if (speed < 0 || speed >= ARRAY_SIZE(names))
  56                speed = USB_SPEED_UNKNOWN;
  57        return names[speed];
  58}
  59EXPORT_SYMBOL_GPL(usb_speed_string);
  60
  61const char *usb_state_string(enum usb_device_state state)
  62{
  63        static const char *const names[] = {
  64                [USB_STATE_NOTATTACHED] = "not attached",
  65                [USB_STATE_ATTACHED] = "attached",
  66                [USB_STATE_POWERED] = "powered",
  67                [USB_STATE_RECONNECTING] = "reconnecting",
  68                [USB_STATE_UNAUTHENTICATED] = "unauthenticated",
  69                [USB_STATE_DEFAULT] = "default",
  70                [USB_STATE_ADDRESS] = "addresssed",
  71                [USB_STATE_CONFIGURED] = "configured",
  72                [USB_STATE_SUSPENDED] = "suspended",
  73        };
  74
  75        if (state < 0 || state >= ARRAY_SIZE(names))
  76                return "UNKNOWN";
  77
  78        return names[state];
  79}
  80EXPORT_SYMBOL_GPL(usb_state_string);
  81
  82MODULE_LICENSE("GPL");
  83
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.