[RFC PATCH 2/7] usb: typec: Move mux mode type definition to limit dependency

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

 



To avoid unnecessary dependencies on tcpm.h and to pave the way
for comming patches, move the tcpc_mux_mode enum from tcpm.h to
typec.h and change its name to typec_mux_mode (the enum constants
already follow this naming).

Signed-off-by: Mats Karrman <mats.dev.list@xxxxxxxxx>
---
 drivers/usb/typec/mux/pi3usb30532.c |  6 +++---
 drivers/usb/typec/tcpm.c            |  2 +-
 include/linux/usb/tcpm.h            | 12 ------------
 include/linux/usb/typec.h           | 11 +++++++++++
 include/linux/usb/typec_mux.h       |  4 ++--
 5 files changed, 17 insertions(+), 18 deletions(-)

diff --git a/drivers/usb/typec/mux/pi3usb30532.c b/drivers/usb/typec/mux/pi3usb30532.c
index 279f3c3..d995883 100644
--- a/drivers/usb/typec/mux/pi3usb30532.c
+++ b/drivers/usb/typec/mux/pi3usb30532.c
@@ -9,7 +9,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/mutex.h>
-#include <linux/usb/tcpm.h>
+#include <linux/usb/typec.h>
 #include <linux/usb/typec_mux.h>
 
 #define PI3USB30532_CONF			0x00
@@ -73,7 +73,7 @@ static int pi3usb30532_sw_set(struct typec_switch *sw,
 	return ret;
 }
 
-static int pi3usb30532_mux_set(struct typec_mux *mux, int state)
+static int pi3usb30532_mux_set(struct typec_mux *mux, enum typec_mux_mode mode)
 {
 	struct pi3usb30532 *pi = container_of(mux, struct pi3usb30532, mux);
 	u8 new_conf;
@@ -82,7 +82,7 @@ static int pi3usb30532_mux_set(struct typec_mux *mux, int state)
 	mutex_lock(&pi->lock);
 	new_conf = pi->conf;
 
-	switch (state) {
+	switch (mode) {
 	default:
 	case TYPEC_MUX_NONE:
 		new_conf = PI3USB30532_CONF_OPEN;
diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
index 0451ea0..aaf6d57 100644
--- a/drivers/usb/typec/tcpm.c
+++ b/drivers/usb/typec/tcpm.c
@@ -644,7 +644,7 @@ void tcpm_pd_transmit_complete(struct tcpm_port *port,
 }
 EXPORT_SYMBOL_GPL(tcpm_pd_transmit_complete);
 
-static int tcpm_mux_set(struct tcpm_port *port, enum tcpc_mux_mode mode,
+static int tcpm_mux_set(struct tcpm_port *port, enum typec_mux_mode mode,
 			enum usb_role usb_role,
 			enum typec_orientation orientation)
 {
diff --git a/include/linux/usb/tcpm.h b/include/linux/usb/tcpm.h
index 3518965..e641e21 100644
--- a/include/linux/usb/tcpm.h
+++ b/include/linux/usb/tcpm.h
@@ -93,18 +93,6 @@ struct tcpc_config {
 	const struct typec_altmode_desc *alt_modes;
 };
 
-/* Mux modes */
-enum tcpc_mux_mode {
-	TYPEC_MUX_NONE,				/* Open switch */
-	TYPEC_MUX_2CH_USBSS,			/* 2ch USB SS */
-	TYPEC_MUX_4CH_AM,			/* 4ch Alt Mode */
-	TYPEC_MUX_2CH_USBSS_2CH_AM,		/* 2ch USB SS + 2ch Alt Mode */
-
-	// Example of additional modes that may be needed in future:
-	TYPEC_MUX_4CH_USBSS,			/* 4ch USB SS */
-	TYPEC_MUX_2CH_USBSS_2CH_AM_B,		/* 2ch USB SS + 2ch Alt Mode (e.g. DP GPU2) */
-};
-
 
 /**
  * struct tcpc_dev - Port configuration and callback functions
diff --git a/include/linux/usb/typec.h b/include/linux/usb/typec.h
index 672b39b..d356577 100644
--- a/include/linux/usb/typec.h
+++ b/include/linux/usb/typec.h
@@ -72,6 +72,17 @@ enum typec_orientation {
 	TYPEC_ORIENTATION_REVERSE,
 };
 
+enum typec_mux_mode {
+	TYPEC_MUX_NONE,				/* Open switch */
+	TYPEC_MUX_2CH_USBSS,			/* 2ch USB SS */
+	TYPEC_MUX_4CH_AM,			/* 4ch Alt Mode */
+	TYPEC_MUX_2CH_USBSS_2CH_AM,		/* 2ch USB SS + 2ch Alt Mode */
+
+	// Example of additional modes that may be needed in future:
+	TYPEC_MUX_4CH_USBSS,			/* 4ch USB SS */
+	TYPEC_MUX_2CH_USBSS_2CH_AM_B,		/* 2ch USB SS + 2ch Alt Mode (e.g. DP GPU2) */
+};
+
 /*
  * struct usb_pd_identity - USB Power Delivery identity data
  * @id_header: ID Header VDO
diff --git a/include/linux/usb/typec_mux.h b/include/linux/usb/typec_mux.h
index 12c1b05..e44137d 100644
--- a/include/linux/usb/typec_mux.h
+++ b/include/linux/usb/typec_mux.h
@@ -29,7 +29,7 @@ struct typec_switch {
  * struct typec_switch - USB Type-C connector pin mux
  * @dev: Mux device
  * @entry: List entry
- * @set: Callback to the driver for setting the state of the mux
+ * @set: Callback to the driver for setting the mode of the mux
  *
  * Pin Multiplexer/DeMultiplexer switch routing the USB Type-C connector pins to
  * different components depending on the requested mode of operation. Used with
@@ -39,7 +39,7 @@ struct typec_mux {
 	struct device *dev;
 	struct list_head entry;
 
-	int (*set)(struct typec_mux *mux, int state);
+	int (*set)(struct typec_mux *mux, enum typec_mux_mode mode);
 };
 
 struct typec_switch *typec_switch_get(struct device *dev);
-- 
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