Skip to content

Commit

Permalink
platform/chrome: cros_ec_typec: Move mux flag checks
Browse files Browse the repository at this point in the history
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/
  • Loading branch information
Prashant Malani committed Feb 15, 2022
1 parent ffebd90 commit 53a0023
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions drivers/platform/chrome/cros_ec_typec.c
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,13 @@ static int cros_typec_configure_mux(struct cros_typec_data *typec, int port_num,
enum typec_orientation orientation;
int ret;

/* 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);
goto mux_ack;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 53a0023

Please sign in to comment.