]> Git Repo - J-linux.git/commitdiff
thunderbolt: No need to loop over all retimers if access fails
authorMika Westerberg <[email protected]>
Fri, 5 Apr 2024 04:47:40 +0000 (07:47 +0300)
committerMika Westerberg <[email protected]>
Tue, 23 Apr 2024 05:12:09 +0000 (08:12 +0300)
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]>
drivers/thunderbolt/retimer.c

index 6bb49bdcd6c18e6f1f56b981b40c522f67db0861..6eaaa5074ce82013d1322b0f69de7b316c88e5af 100644 (file)
@@ -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)
@@ -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,
This page took 0.051879 seconds and 4 git commands to generate.