diff mbox series

[1/4] platform/chrome: cros_ec_typec: Move mux flag checks

Message ID 20220207214026.1526151-2-pmalani@chromium.org (mailing list archive)
State Superseded
Headers show
Series platform/chrome: cros_ec_typec: Reorganize mux configuration | expand

Commit Message

Prashant Malani Feb. 7, 2022, 9:40 p.m. UTC
Move mux and role flag checks inside of cros_typec_configure_mux(),
which is a more logical location for them.

Signed-off-by: Prashant Malani <pmalani@chromium.org>
---
 drivers/platform/chrome/cros_ec_typec.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

Comments

Tzung-Bi Shih Feb. 8, 2022, 5:33 a.m. UTC | #1
On Mon, Feb 07, 2022 at 09:40:24PM +0000, Prashant Malani wrote:
> Move mux and role flag checks inside of cros_typec_configure_mux(),
> which is a more logical location for them.

nit: s/Move/Moves/.

> @@ -519,7 +519,14 @@ static int cros_typec_configure_mux(struct cros_typec_data *typec, int port_num,
>  	struct cros_typec_port *port = typec->ports[port_num];
>  	struct ec_params_usb_pd_mux_ack mux_ack;
>  	enum typec_orientation orientation;
> -	int ret;
> +	int ret = 0;

The change looks irrelevant to the patch.
Prashant Malani Feb. 8, 2022, 6:03 a.m. UTC | #2
Hi Tzung-Bi,

On Mon, Feb 7, 2022 at 9:33 PM Tzung-Bi Shih <tzungbi@google.com> wrote:
>
> On Mon, Feb 07, 2022 at 09:40:24PM +0000, Prashant Malani wrote:
> > Move mux and role flag checks inside of cros_typec_configure_mux(),
> > which is a more logical location for them.
>
> nit: s/Move/Moves/.

Move is fine. Please see:
https://www.kernel.org/doc/html/v4.17/process/submitting-patches.html#describe-your-changes

Quoting from the above: " Describe your changes in imperative mood,"

>
> > @@ -519,7 +519,14 @@ static int cros_typec_configure_mux(struct cros_typec_data *typec, int port_num,
> >       struct cros_typec_port *port = typec->ports[port_num];
> >       struct ec_params_usb_pd_mux_ack mux_ack;
> >       enum typec_orientation orientation;
> > -     int ret;
> > +     int ret = 0;
>
> The change looks irrelevant to the patch.
Ack, I missed eliminating this while cleaning up the patches. Will fix
it in the next version.
diff mbox series

Patch

diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
index c6f17e3ef72d..445da4f122e7 100644
--- a/drivers/platform/chrome/cros_ec_typec.c
+++ b/drivers/platform/chrome/cros_ec_typec.c
@@ -519,7 +519,14 @@  static int cros_typec_configure_mux(struct cros_typec_data *typec, int port_num,
 	struct cros_typec_port *port = typec->ports[port_num];
 	struct ec_params_usb_pd_mux_ack mux_ack;
 	enum typec_orientation orientation;
-	int ret;
+	int ret = 0;
+
+	/* No change needs to be made, let's exit early. */
+	if (port->mux_flags == mux_flags && port->role == pd_ctrl->role)
+		return 0;
+
+	port->mux_flags = mux_flags;
+	port->role = pd_ctrl->role;
 
 	if (mux_flags == USB_PD_MUX_NONE) {
 		ret = cros_typec_usb_disconnect_state(port);
@@ -983,13 +990,6 @@  static int cros_typec_port_update(struct cros_typec_data *typec, int port_num)
 		return 0;
 	}
 
-	/* No change needs to be made, let's exit early. */
-	if (typec->ports[port_num]->mux_flags == mux_resp.flags &&
-	    typec->ports[port_num]->role == resp.role)
-		return 0;
-
-	typec->ports[port_num]->mux_flags = mux_resp.flags;
-	typec->ports[port_num]->role = resp.role;
 	ret = cros_typec_configure_mux(typec, port_num, mux_resp.flags, &resp);
 	if (ret)
 		dev_warn(typec->dev, "Configure muxes failed, err = %d\n", ret);