Skip to content

Commit 53a0023

Browse files
author
Prashant Malani
committed
platform/chrome: cros_ec_typec: Move mux flag checks
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> Reviewed-by: Tzung-Bi Shih <tzungbi@google.com> Link: https://lore.kernel.org/chrome-platform/20220208184721.1697194-2-pmalani@chromium.org/
1 parent ffebd90 commit 53a0023

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

drivers/platform/chrome/cros_ec_typec.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,13 @@ static int cros_typec_configure_mux(struct cros_typec_data *typec, int port_num,
521521
enum typec_orientation orientation;
522522
int ret;
523523

524+
/* No change needs to be made, let's exit early. */
525+
if (port->mux_flags == mux_flags && port->role == pd_ctrl->role)
526+
return 0;
527+
528+
port->mux_flags = mux_flags;
529+
port->role = pd_ctrl->role;
530+
524531
if (mux_flags == USB_PD_MUX_NONE) {
525532
ret = cros_typec_usb_disconnect_state(port);
526533
goto mux_ack;
@@ -983,13 +990,6 @@ static int cros_typec_port_update(struct cros_typec_data *typec, int port_num)
983990
return 0;
984991
}
985992

986-
/* No change needs to be made, let's exit early. */
987-
if (typec->ports[port_num]->mux_flags == mux_resp.flags &&
988-
typec->ports[port_num]->role == resp.role)
989-
return 0;
990-
991-
typec->ports[port_num]->mux_flags = mux_resp.flags;
992-
typec->ports[port_num]->role = resp.role;
993993
ret = cros_typec_configure_mux(typec, port_num, mux_resp.flags, &resp);
994994
if (ret)
995995
dev_warn(typec->dev, "Configure muxes failed, err = %d\n", ret);

0 commit comments

Comments
 (0)