usb: introduce usb_ep_type_string() function
In some places, the code prints a human-readable USB endpoint transfer type (e.g. "bulk"). This involves a switch statement sometimes wrapped around in ({ ... }) block leading to code repetition. To make this scenario easier, here introduces usb_ep_type_string() function, which returns a human-readable name of provided endpoint type. It also changes a few places switch was used to use this new function. Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
2a738137b4
commit
4d537f37e0
@@ -16,6 +16,22 @@
|
||||
#include <linux/usb/otg.h>
|
||||
#include <linux/of_platform.h>
|
||||
|
||||
static const char *const ep_type_names[] = {
|
||||
[USB_ENDPOINT_XFER_CONTROL] = "ctrl",
|
||||
[USB_ENDPOINT_XFER_ISOC] = "isoc",
|
||||
[USB_ENDPOINT_XFER_BULK] = "bulk",
|
||||
[USB_ENDPOINT_XFER_INT] = "intr",
|
||||
};
|
||||
|
||||
const char *usb_ep_type_string(int ep_type)
|
||||
{
|
||||
if (ep_type < 0 || ep_type >= ARRAY_SIZE(ep_type_names))
|
||||
return "unknown";
|
||||
|
||||
return ep_type_names[ep_type];
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(usb_ep_type_string);
|
||||
|
||||
const char *usb_otg_state_string(enum usb_otg_state state)
|
||||
{
|
||||
static const char *const names[] = {
|
||||
|
Reference in New Issue
Block a user