diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c index 05a2909e84fd..34b6965ee30b 100644 --- a/drivers/usb/typec/ucsi/ucsi.c +++ b/drivers/usb/typec/ucsi/ucsi.c @@ -669,7 +669,7 @@ static void ucsi_handle_connector_change(struct work_struct *work) struct ucsi *ucsi = con->ucsi; struct ucsi_connector_status pre_ack_status; struct ucsi_connector_status post_ack_status; - enum typec_role role; + enum typec_role role, prev_role; enum usb_role u_role = USB_ROLE_NONE; u16 inferred_changes; u16 changed_flags; @@ -706,6 +706,8 @@ static void ucsi_handle_connector_change(struct work_struct *work) * short transitional changes. */ + prev_role = !!(con->status.flags & UCSI_CONSTAT_PWR_DIR); + /* 1. First UCSI_GET_CONNECTOR_STATUS */ command = UCSI_GET_CONNECTOR_STATUS | UCSI_CONNECTOR_NUMBER(con->num); ret = ucsi_send_command(ucsi, command, &pre_ack_status, @@ -783,7 +785,8 @@ static void ucsi_handle_connector_change(struct work_struct *work) ucsi_port_psy_changed(con); } - if (con->status.change & UCSI_CONSTAT_POWER_DIR_CHANGE) { + if ((con->status.change & UCSI_CONSTAT_POWER_DIR_CHANGE) && + role != prev_role) { typec_set_pwr_role(con->port, role); /* Complete pending power role swap */