diff options
author | Chunfeng Yun <chunfeng.yun@mediatek.com> | 2021-07-15 11:07:50 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-07-27 15:58:37 +0200 |
commit | 2037f2991ddedded1ef4aaabe4caf11e306158dc (patch) | |
tree | ce1c353b56fca7a5c917672b38c2ab8f4e853176 /drivers | |
parent | dt-bindings: usb: mtu3: add wakeup interrupt (diff) | |
download | linux-2037f2991ddedded1ef4aaabe4caf11e306158dc.tar.xz linux-2037f2991ddedded1ef4aaabe4caf11e306158dc.zip |
usb: common: add helper to get role-switch-default-mode
Add helper to get "role-switch-default-mode", and convert it
to the corresponding enum usb_dr_mode
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Link: https://lore.kernel.org/r/1626340078-29111-6-git-send-email-chunfeng.yun@mediatek.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/usb/common/common.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c index 347fb3d3894a..c9bdeb4ddcb5 100644 --- a/drivers/usb/common/common.c +++ b/drivers/usb/common/common.c @@ -201,6 +201,26 @@ enum usb_dr_mode usb_get_dr_mode(struct device *dev) EXPORT_SYMBOL_GPL(usb_get_dr_mode); /** + * usb_get_role_switch_default_mode - Get default mode for given device + * @dev: Pointer to the given device + * + * The function gets string from property 'role-switch-default-mode', + * and returns the corresponding enum usb_dr_mode. + */ +enum usb_dr_mode usb_get_role_switch_default_mode(struct device *dev) +{ + const char *str; + int ret; + + ret = device_property_read_string(dev, "role-switch-default-mode", &str); + if (ret < 0) + return USB_DR_MODE_UNKNOWN; + + return usb_get_dr_mode_from_string(str); +} +EXPORT_SYMBOL_GPL(usb_get_role_switch_default_mode); + +/** * usb_decode_interval - Decode bInterval into the time expressed in 1us unit * @epd: The descriptor of the endpoint * @speed: The speed that the endpoint works as |