* [RFC,3/7] usb: typec: Add API to find mux mode from its string representation
@ 2018-05-01 22:21 Mats Karrman
0 siblings, 0 replies; only message in thread
From: Mats Karrman @ 2018-05-01 22:21 UTC (permalink / raw)
To: Heikki Krogerus, Hans de Goede, Guenter Roeck, Greg Kroah-Hartman
Cc: Rob Herring, linux-usb
Signed-off-by: Mats Karrman <mats.dev.list@gmail.com>
---
drivers/usb/typec/class.c | 22 ++++++++++++++++++++++
include/linux/usb/typec.h | 1 +
2 files changed, 23 insertions(+)
diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
index 53df10d..c5432f4 100644
--- a/drivers/usb/typec/class.c
+++ b/drivers/usb/typec/class.c
@@ -1255,6 +1255,28 @@ EXPORT_SYMBOL_GPL(typec_set_pwr_opmode);
/* ------------------------------------------ */
/* API for Multiplexer/DeMultiplexer Switches */
+static const char * const typec_mux_modes[] = {
+ [TYPEC_MUX_NONE] = "none",
+ [TYPEC_MUX_2CH_USBSS] = "2ch-usbss",
+ [TYPEC_MUX_4CH_AM] = "4ch-am",
+ [TYPEC_MUX_2CH_USBSS_2CH_AM] = "2ch-usbss-2ch-am",
+ [TYPEC_MUX_4CH_USBSS] = "4ch-usbss",
+ [TYPEC_MUX_2CH_USBSS_2CH_AM_B] = "2ch-usbss-2ch-am-b",
+};
+
+/**
+ * typec_find_mux_mode - Get the typec mux mode from its string representation
+ * @name: mux mode string
+ *
+ * Returns typec_mux_mode if success, otherwise negative error code.
+ */
+int typec_find_mux_mode(const char *name)
+{
+ return match_string(typec_mux_modes, ARRAY_SIZE(typec_mux_modes),
+ name);
+}
+EXPORT_SYMBOL_GPL(typec_find_mux_mode);
+
/**
* typec_set_orientation - Set USB Type-C cable plug orientation
* @port: USB Type-C Port
diff --git a/include/linux/usb/typec.h b/include/linux/usb/typec.h
index d356577..72cd4a7 100644
--- a/include/linux/usb/typec.h
+++ b/include/linux/usb/typec.h
@@ -274,6 +274,7 @@ void typec_set_pwr_role(struct typec_port *port, enum typec_role role);
void typec_set_vconn_role(struct typec_port *port, enum typec_role role);
void typec_set_pwr_opmode(struct typec_port *port, enum typec_pwr_opmode mode);
+int typec_find_mux_mode(const char *name);
int typec_set_orientation(struct typec_port *port,
enum typec_orientation orientation);
int typec_set_mode(struct typec_port *port, int mode);
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2018-05-01 22:21 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-01 22:21 [RFC,3/7] usb: typec: Add API to find mux mode from its string representation Mats Karrman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).