[RFC PATCH 3/7] usb: typec: Add API to find mux mode from its string representation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Mats Karrman <mats.dev.list@xxxxxxxxx>
---
 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);
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux