Skip to content

Commit d4d336f

Browse files
committed
thunderbolt: No need to loop over all retimers if access fails
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]>
1 parent c6ca1ac commit d4d336f

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

drivers/thunderbolt/retimer.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,10 @@ static void tb_retimer_nvm_authenticate_status(struct tb_port *port, u32 *status
199199
* If the retimer has it set, store it for the new retimer
200200
* device instance.
201201
*/
202-
for (i = 1; i <= TB_MAX_RETIMER_INDEX; i++)
203-
usb4_port_retimer_nvm_authenticate_status(port, i, &status[i]);
202+
for (i = 1; i <= TB_MAX_RETIMER_INDEX; i++) {
203+
if (usb4_port_retimer_nvm_authenticate_status(port, i, &status[i]))
204+
break;
205+
}
204206
}
205207

206208
static void tb_retimer_set_inbound_sbtx(struct tb_port *port)
@@ -234,8 +236,10 @@ static void tb_retimer_unset_inbound_sbtx(struct tb_port *port)
234236

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

237-
for (i = TB_MAX_RETIMER_INDEX; i >= 1; i--)
238-
usb4_port_retimer_unset_inbound_sbtx(port, i);
239+
for (i = TB_MAX_RETIMER_INDEX; i >= 1; i--) {
240+
if (usb4_port_retimer_unset_inbound_sbtx(port, i))
241+
break;
242+
}
239243
}
240244

241245
static ssize_t nvm_authenticate_store(struct device *dev,

0 commit comments

Comments
 (0)