Skip to content

Commit

Permalink
thunderbolt: No need to loop over all retimers if access fails
Browse files Browse the repository at this point in the history
When we read the NVM authentication status or unsetting the inbound SBTX
there is no point to continue the loop after first access to a retimer
fails because there won't be any more retimers after this anyway so bail
out from the loops early.

Signed-off-by: Mika Westerberg <[email protected]>
  • Loading branch information
westeri committed Apr 23, 2024
1 parent c6ca1ac commit d4d336f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions drivers/thunderbolt/retimer.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,10 @@ static void tb_retimer_nvm_authenticate_status(struct tb_port *port, u32 *status
* If the retimer has it set, store it for the new retimer
* device instance.
*/
for (i = 1; i <= TB_MAX_RETIMER_INDEX; i++)
usb4_port_retimer_nvm_authenticate_status(port, i, &status[i]);
for (i = 1; i <= TB_MAX_RETIMER_INDEX; i++) {
if (usb4_port_retimer_nvm_authenticate_status(port, i, &status[i]))
break;
}
}

static void tb_retimer_set_inbound_sbtx(struct tb_port *port)
Expand Down Expand Up @@ -234,8 +236,10 @@ static void tb_retimer_unset_inbound_sbtx(struct tb_port *port)

tb_port_dbg(port, "disabling sideband transactions\n");

for (i = TB_MAX_RETIMER_INDEX; i >= 1; i--)
usb4_port_retimer_unset_inbound_sbtx(port, i);
for (i = TB_MAX_RETIMER_INDEX; i >= 1; i--) {
if (usb4_port_retimer_unset_inbound_sbtx(port, i))
break;
}
}

static ssize_t nvm_authenticate_store(struct device *dev,
Expand Down

0 comments on commit d4d336f

Please sign in to comment.