diff mbox series

[2/3] usb: typec: Add wrapper for bus switch set code

Message ID 20230112221609.540754-3-pmalani@chromium.org (mailing list archive)
State Accepted
Commit 2c8cb236ed44d071ef2ed1fbb948eea404551788
Headers show
Series usb: typec: Add retimer support to bus code | expand

Commit Message

Prashant Malani Jan. 12, 2023, 10:16 p.m. UTC
Add a wrapper that calls the set() function for various switches
associated with a port altmode.

Right now, it just wraps the existing typec_mux_set() command,
but it can be expanded to include other switches in future patches.

No functional changes introduced by this patch.

Signed-off-by: Prashant Malani <pmalani@chromium.org>
---
 drivers/usb/typec/bus.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

Comments

Heikki Krogerus Jan. 17, 2023, 11:42 a.m. UTC | #1
On Thu, Jan 12, 2023 at 10:16:07PM +0000, Prashant Malani wrote:
> Add a wrapper that calls the set() function for various switches
> associated with a port altmode.
> 
> Right now, it just wraps the existing typec_mux_set() command,
> but it can be expanded to include other switches in future patches.
> 
> No functional changes introduced by this patch.
> 
> Signed-off-by: Prashant Malani <pmalani@chromium.org>

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
>  drivers/usb/typec/bus.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/typec/bus.c b/drivers/usb/typec/bus.c
> index 31c2a3130cad..9f1bbd26ca47 100644
> --- a/drivers/usb/typec/bus.c
> +++ b/drivers/usb/typec/bus.c
> @@ -27,6 +27,13 @@ typec_altmode_set_mux(struct altmode *alt, unsigned long conf, void *data)
>  	return typec_mux_set(alt->mux, &state);
>  }
>  
> +/* Wrapper to set various Type-C port switches together. */
> +static inline int
> +typec_altmode_set_switches(struct altmode *alt, unsigned long conf, void *data)
> +{
> +	return typec_altmode_set_mux(alt, conf, data);
> +}
> +
>  static int typec_altmode_set_state(struct typec_altmode *adev,
>  				   unsigned long conf, void *data)
>  {
> @@ -35,7 +42,7 @@ static int typec_altmode_set_state(struct typec_altmode *adev,
>  
>  	port_altmode = is_port ? to_altmode(adev) : to_altmode(adev)->partner;
>  
> -	return typec_altmode_set_mux(port_altmode, conf, data);
> +	return typec_altmode_set_switches(port_altmode, conf, data);
>  }
>  
>  /* -------------------------------------------------------------------------- */
> @@ -73,7 +80,7 @@ int typec_altmode_notify(struct typec_altmode *adev,
>  	is_port = is_typec_port(adev->dev.parent);
>  	partner = altmode->partner;
>  
> -	ret = typec_altmode_set_mux(is_port ? altmode : partner, conf, data);
> +	ret = typec_altmode_set_switches(is_port ? altmode : partner, conf, data);
>  	if (ret)
>  		return ret;
>  
> -- 
> 2.39.0.314.g84b9a713c41-goog
diff mbox series

Patch

diff --git a/drivers/usb/typec/bus.c b/drivers/usb/typec/bus.c
index 31c2a3130cad..9f1bbd26ca47 100644
--- a/drivers/usb/typec/bus.c
+++ b/drivers/usb/typec/bus.c
@@ -27,6 +27,13 @@  typec_altmode_set_mux(struct altmode *alt, unsigned long conf, void *data)
 	return typec_mux_set(alt->mux, &state);
 }
 
+/* Wrapper to set various Type-C port switches together. */
+static inline int
+typec_altmode_set_switches(struct altmode *alt, unsigned long conf, void *data)
+{
+	return typec_altmode_set_mux(alt, conf, data);
+}
+
 static int typec_altmode_set_state(struct typec_altmode *adev,
 				   unsigned long conf, void *data)
 {
@@ -35,7 +42,7 @@  static int typec_altmode_set_state(struct typec_altmode *adev,
 
 	port_altmode = is_port ? to_altmode(adev) : to_altmode(adev)->partner;
 
-	return typec_altmode_set_mux(port_altmode, conf, data);
+	return typec_altmode_set_switches(port_altmode, conf, data);
 }
 
 /* -------------------------------------------------------------------------- */
@@ -73,7 +80,7 @@  int typec_altmode_notify(struct typec_altmode *adev,
 	is_port = is_typec_port(adev->dev.parent);
 	partner = altmode->partner;
 
-	ret = typec_altmode_set_mux(is_port ? altmode : partner, conf, data);
+	ret = typec_altmode_set_switches(is_port ? altmode : partner, conf, data);
 	if (ret)
 		return ret;