usb-common.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  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. #include <linux/kernel.h>
  14. #include <linux/module.h>
  15. #include <linux/usb/ch9.h>
  16. const char *usb_speed_string(enum usb_device_speed speed)
  17. {
  18. static const char *const names[] = {
  19. [USB_SPEED_UNKNOWN] = "UNKNOWN",
  20. [USB_SPEED_LOW] = "low-speed",
  21. [USB_SPEED_FULL] = "full-speed",
  22. [USB_SPEED_HIGH] = "high-speed",
  23. [USB_SPEED_WIRELESS] = "wireless",
  24. [USB_SPEED_SUPER] = "super-speed",
  25. };
  26. if (speed < 0 || speed >= ARRAY_SIZE(names))
  27. speed = USB_SPEED_UNKNOWN;
  28. return names[speed];
  29. }
  30. EXPORT_SYMBOL_GPL(usb_speed_string);
  31. MODULE_LICENSE("GPL");