Skip to content

Commit e25adcc

Browse files
Heikki Krogerusgregkh
authored andcommitted
usb: typec: ucsi: Fix reuse of completion structure
The role swapping completion variable is reused, so it needs to be reinitialised every time. Otherwise it will be marked as done after the first time it's used and completing immediately. Link: https://lore.kernel.org/linux-usb/20220325203959.GA19752@jackp-linux.qualcomm.com/ Fixes: 6df475f ("usb: typec: ucsi: Start using struct typec_operations") Cc: stable@vger.kernel.org Reported-and-suggested-by: Jack Pham <quic_jackp@quicinc.com> Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Link: https://lore.kernel.org/r/20220405134824.68067-2-heikki.krogerus@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 8771039 commit e25adcc

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

drivers/usb/typec/ucsi/ucsi.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -949,6 +949,8 @@ static int ucsi_dr_swap(struct typec_port *port, enum typec_data_role role)
949949
role == TYPEC_HOST))
950950
goto out_unlock;
951951

952+
reinit_completion(&con->complete);
953+
952954
command = UCSI_SET_UOR | UCSI_CONNECTOR_NUMBER(con->num);
953955
command |= UCSI_SET_UOR_ROLE(role);
954956
command |= UCSI_SET_UOR_ACCEPT_ROLE_SWAPS;
@@ -985,6 +987,8 @@ static int ucsi_pr_swap(struct typec_port *port, enum typec_role role)
985987
if (cur_role == role)
986988
goto out_unlock;
987989

990+
reinit_completion(&con->complete);
991+
988992
command = UCSI_SET_PDR | UCSI_CONNECTOR_NUMBER(con->num);
989993
command |= UCSI_SET_PDR_ROLE(role);
990994
command |= UCSI_SET_PDR_ACCEPT_ROLE_SWAPS;

0 commit comments

Comments
 (0)