[PATCH v8 4/9] usb: common: add define of usb_speed_string()
Chunfeng Yun
chunfeng.yun at mediatek.com
Wed Oct 14 09:08:28 CEST 2020
There is only declaration of usb_speed_string(), but no definition,
so add it to avoid build error when call it.
Signed-off-by: Chunfeng Yun <chunfeng.yun at mediatek.com>
Reviewed-by: Bin Meng <bmeng.cn at gmail.com>
---
v8: add Reviewed-by Bin
v7: no changes
v6: modify commit message suggested by Roger
v5: no changes
v4: new patch
---
drivers/usb/common/common.c | 7 +++++++
include/linux/usb/ch9.h | 4 ----
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c
index 76f5a9ce60..5e5c3c3e3d 100644
--- a/drivers/usb/common/common.c
+++ b/drivers/usb/common/common.c
@@ -49,6 +49,13 @@ static const char *const speed_names[] = {
[USB_SPEED_SUPER_PLUS] = "super-speed-plus",
};
+const char *usb_speed_string(enum usb_device_speed speed)
+{
+ if (speed < 0 || speed >= ARRAY_SIZE(speed_names))
+ speed = USB_SPEED_UNKNOWN;
+ return speed_names[speed];
+}
+
enum usb_device_speed usb_get_maximum_speed(ofnode node)
{
const char *max_speed;
diff --git a/include/linux/usb/ch9.h b/include/linux/usb/ch9.h
index 7d225ee9cb..a8fa5d7449 100644
--- a/include/linux/usb/ch9.h
+++ b/include/linux/usb/ch9.h
@@ -959,8 +959,6 @@ enum usb_device_speed {
USB_SPEED_SUPER_PLUS, /* usb 3.1 */
};
-#ifdef __KERNEL__
-
/**
* usb_speed_string() - Returns human readable-name of the speed.
* @speed: The speed to return human-readable name for. If it's not
@@ -969,8 +967,6 @@ enum usb_device_speed {
*/
extern const char *usb_speed_string(enum usb_device_speed speed);
-#endif
-
enum usb_device_state {
/* NOTATTACHED isn't in the USB spec, and this state acts
* the same as ATTACHED ... but it's clearer this way.
--
2.18.0
More information about the U-Boot
mailing list