thunderbolt: Expose tb_tunnel_xxx() log macros to the rest of the driver
authorMika Westerberg <mika.westerberg@linux.intel.com>
Tue, 19 Sep 2023 12:00:44 +0000 (15:00 +0300)
committerMika Westerberg <mika.westerberg@linux.intel.com>
Fri, 13 Oct 2023 05:49:13 +0000 (08:49 +0300)
In order to allow more consistent logging of tunnel related information
make these logging macros available to the rest of the driver.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
drivers/thunderbolt/tunnel.c
drivers/thunderbolt/tunnel.h

index 85b1cccf518f7094613928f7203973ded383408a..9775332dee0e52d379e0f708a3c72d034fa49e06 100644 (file)
@@ -58,27 +58,6 @@ MODULE_PARM_DESC(bw_alloc_mode,
 
 static const char * const tb_tunnel_names[] = { "PCI", "DP", "DMA", "USB3" };
 
-#define __TB_TUNNEL_PRINT(level, tunnel, fmt, arg...)                   \
-       do {                                                            \
-               struct tb_tunnel *__tunnel = (tunnel);                  \
-               level(__tunnel->tb, "%llx:%u <-> %llx:%u (%s): " fmt,   \
-                     tb_route(__tunnel->src_port->sw),                 \
-                     __tunnel->src_port->port,                         \
-                     tb_route(__tunnel->dst_port->sw),                 \
-                     __tunnel->dst_port->port,                         \
-                     tb_tunnel_names[__tunnel->type],                  \
-                     ## arg);                                          \
-       } while (0)
-
-#define tb_tunnel_WARN(tunnel, fmt, arg...) \
-       __TB_TUNNEL_PRINT(tb_WARN, tunnel, fmt, ##arg)
-#define tb_tunnel_warn(tunnel, fmt, arg...) \
-       __TB_TUNNEL_PRINT(tb_warn, tunnel, fmt, ##arg)
-#define tb_tunnel_info(tunnel, fmt, arg...) \
-       __TB_TUNNEL_PRINT(tb_info, tunnel, fmt, ##arg)
-#define tb_tunnel_dbg(tunnel, fmt, arg...) \
-       __TB_TUNNEL_PRINT(tb_dbg, tunnel, fmt, ##arg)
-
 static inline unsigned int tb_usable_credits(const struct tb_port *port)
 {
        return port->total_credits - port->ctl_credits;
@@ -2375,3 +2354,8 @@ void tb_tunnel_reclaim_available_bandwidth(struct tb_tunnel *tunnel,
                tunnel->reclaim_available_bandwidth(tunnel, available_up,
                                                    available_down);
 }
+
+const char *tb_tunnel_type_name(const struct tb_tunnel *tunnel)
+{
+       return tb_tunnel_names[tunnel->type];
+}
index bf690f7beeeeba554afabbe7674596c3eb315ebd..750ebb570d9956eda30459f11f84ce41c79068b7 100644 (file)
@@ -137,5 +137,27 @@ static inline bool tb_tunnel_is_usb3(const struct tb_tunnel *tunnel)
        return tunnel->type == TB_TUNNEL_USB3;
 }
 
-#endif
+const char *tb_tunnel_type_name(const struct tb_tunnel *tunnel);
+
+#define __TB_TUNNEL_PRINT(level, tunnel, fmt, arg...)                   \
+       do {                                                            \
+               struct tb_tunnel *__tunnel = (tunnel);                  \
+               level(__tunnel->tb, "%llx:%u <-> %llx:%u (%s): " fmt,   \
+                     tb_route(__tunnel->src_port->sw),                 \
+                     __tunnel->src_port->port,                         \
+                     tb_route(__tunnel->dst_port->sw),                 \
+                     __tunnel->dst_port->port,                         \
+                     tb_tunnel_type_name(__tunnel),                    \
+                     ## arg);                                          \
+       } while (0)
 
+#define tb_tunnel_WARN(tunnel, fmt, arg...) \
+       __TB_TUNNEL_PRINT(tb_WARN, tunnel, fmt, ##arg)
+#define tb_tunnel_warn(tunnel, fmt, arg...) \
+       __TB_TUNNEL_PRINT(tb_warn, tunnel, fmt, ##arg)
+#define tb_tunnel_info(tunnel, fmt, arg...) \
+       __TB_TUNNEL_PRINT(tb_info, tunnel, fmt, ##arg)
+#define tb_tunnel_dbg(tunnel, fmt, arg...) \
+       __TB_TUNNEL_PRINT(tb_dbg, tunnel, fmt, ##arg)
+
+#endif