diff options
author | Chunfeng Yun <chunfeng.yun@mediatek.com> | 2021-05-25 10:53:05 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-05-27 09:17:18 +0200 |
commit | 73e33008e865e5a7b79282331c2d6e920d5d47f8 (patch) | |
tree | c87cb860d513d1daf9143439ee66322dd21bd2fb /drivers/usb/roles | |
parent | usb: typec: tcpci: Make symbol 'tcpci_apply_rc' static (diff) | |
download | linux-73e33008e865e5a7b79282331c2d6e920d5d47f8.tar.xz linux-73e33008e865e5a7b79282331c2d6e920d5d47f8.zip |
usb: roles: add helper usb_role_string()
Introduces usb_role_string() function, which returns a
human-readable name of provided usb role, it's useful to
make the log readable.
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Link: https://lore.kernel.org/r/1621932786-9335-1-git-send-email-chunfeng.yun@mediatek.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/roles')
-rw-r--r-- | drivers/usb/roles/class.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/usb/roles/class.c b/drivers/usb/roles/class.c index 33b637d0d8d9..dfaed7eee94f 100644 --- a/drivers/usb/roles/class.c +++ b/drivers/usb/roles/class.c @@ -214,6 +214,15 @@ static const char * const usb_roles[] = { [USB_ROLE_DEVICE] = "device", }; +const char *usb_role_string(enum usb_role role) +{ + if (role < 0 || role >= ARRAY_SIZE(usb_roles)) + return "unknown"; + + return usb_roles[role]; +} +EXPORT_SYMBOL_GPL(usb_role_string); + static ssize_t role_show(struct device *dev, struct device_attribute *attr, char *buf) { |