]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - drivers/thunderbolt/path.c
Merge tag 'for-linus-20191129' of git://git.kernel.dk/linux-block
[linux.git] / drivers / thunderbolt / path.c
index 6cf66597d5d852dec915f74a33c05b5c26ac3794..ad58559ea88e518711e9bea8f9bd40f01cd31489 100644 (file)
@@ -557,3 +557,25 @@ bool tb_path_is_invalid(struct tb_path *path)
        }
        return false;
 }
+
+/**
+ * tb_path_switch_on_path() - Does the path go through certain switch
+ * @path: Path to check
+ * @sw: Switch to check
+ *
+ * Goes over all hops on path and checks if @sw is any of them.
+ * Direction does not matter.
+ */
+bool tb_path_switch_on_path(const struct tb_path *path,
+                           const struct tb_switch *sw)
+{
+       int i;
+
+       for (i = 0; i < path->path_length; i++) {
+               if (path->hops[i].in_port->sw == sw ||
+                   path->hops[i].out_port->sw == sw)
+                       return true;
+       }
+
+       return false;
+}