]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
thunderbolt: Introduce tb_for_each_upstream_port_on_path()
authorMika Westerberg <mika.westerberg@linux.intel.com>
Tue, 1 Oct 2024 17:31:05 +0000 (17:31 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 4 Oct 2024 14:30:01 +0000 (16:30 +0200)
[ Upstream commit 956c3abe72fb6a651b8cf77c28462f7e5b6a48b1 ]

This is useful when walking over upstream lane adapters over given path.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Qin Wan <qin.wan@hp.com>
Signed-off-by: Alexandru Gagniuc <alexandru.gagniuc@hp.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/thunderbolt/tb.h

index 6d66dd2a3ab0278094fcad5ea7bbad5fca5e44c9..4cd5f48e3dee647ad33f4e95b213370b9317b472 100644 (file)
@@ -1076,6 +1076,21 @@ static inline bool tb_port_use_credit_allocation(const struct tb_port *port)
        for ((p) = tb_next_port_on_path((src), (dst), NULL); (p);       \
             (p) = tb_next_port_on_path((src), (dst), (p)))
 
+/**
+ * tb_for_each_upstream_port_on_path() - Iterate over each upstreamm port on path
+ * @src: Source port
+ * @dst: Destination port
+ * @p: Port used as iterator
+ *
+ * Walks over each upstream lane adapter on path from @src to @dst.
+ */
+#define tb_for_each_upstream_port_on_path(src, dst, p)                 \
+       for ((p) = tb_next_port_on_path((src), (dst), NULL); (p);       \
+            (p) = tb_next_port_on_path((src), (dst), (p)))             \
+               if (!tb_port_is_null((p)) || !tb_is_upstream_port((p))) {\
+                       continue;                                       \
+               } else
+
 int tb_port_get_link_speed(struct tb_port *port);
 int tb_port_get_link_generation(struct tb_port *port);
 int tb_port_get_link_width(struct tb_port *port);