diff options
author | Amelie Delaunay <amelie.delaunay@st.com> | 2020-09-24 11:00:45 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-10-02 15:30:31 +0200 |
commit | 12f3467b0d28369d3add7a0deb65fdac9b503c90 (patch) | |
tree | 063093ea0f10a69f516e80ef5c50abb340a6de48 /drivers/usb | |
parent | a6806e32e7a41c20c6b288009cb6f30929668327 (diff) |
usb: typec: add typec_find_pwr_opmode
This patch adds a function that converts power operation mode string into
power operation mode value.
It is useful to configure power operation mode through device tree
property, as power capabilities may be linked to hardware design.
Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Amelie Delaunay <amelie.delaunay@st.com>
Link: https://lore.kernel.org/r/20200924090049.9041-3-amelie.delaunay@st.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/typec/class.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c index 02655694f200..35eec707cb51 100644 --- a/drivers/usb/typec/class.c +++ b/drivers/usb/typec/class.c @@ -1449,6 +1449,21 @@ void typec_set_pwr_opmode(struct typec_port *port, EXPORT_SYMBOL_GPL(typec_set_pwr_opmode); /** + * typec_find_pwr_opmode - Get the typec power operation mode capability + * @name: power operation mode string + * + * This routine is used to find the typec_pwr_opmode by its string @name. + * + * Returns typec_pwr_opmode if success, otherwise negative error code. + */ +int typec_find_pwr_opmode(const char *name) +{ + return match_string(typec_pwr_opmodes, + ARRAY_SIZE(typec_pwr_opmodes), name); +} +EXPORT_SYMBOL_GPL(typec_find_pwr_opmode); + +/** * typec_find_orientation - Convert orientation string to enum typec_orientation * @name: Orientation string * |