thunderbolt: Move tb_switch_phy_port_from_link() to thunderbolt.h
authorMika Westerberg <mika.westerberg@linux.intel.com>
Mon, 2 Oct 2017 10:38:33 +0000 (13:38 +0300)
committerDavid S. Miller <davem@davemloft.net>
Mon, 2 Oct 2017 18:24:41 +0000 (11:24 -0700)
A Thunderbolt service might need to find the physical port from a link
the cable is connected to. For instance networking driver uses this
information to generate MAC address according the Apple ThunderboltIP
protocol.

Move this function to thunderbolt.h and rename it to
tb_phy_port_from_link() to reflect the fact that it does not take switch
as parameter.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Michael Jamet <michael.jamet@intel.com>
Reviewed-by: Yehezkel Bernat <yehezkel.bernat@intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/thunderbolt/icm.c
drivers/thunderbolt/tb.h
include/linux/thunderbolt.h

index 53250fc057e1f355b490286ca545fcc2b8d4fb54..8c22b91ed0405c42a6ef9bb83c0b2faa6fab86bf 100644 (file)
@@ -89,7 +89,7 @@ static inline struct tb *icm_to_tb(struct icm *icm)
 
 static inline u8 phy_port_from_route(u64 route, u8 depth)
 {
-       return tb_switch_phy_port_from_link(route >> ((depth - 1) * 8));
+       return tb_phy_port_from_link(route >> ((depth - 1) * 8));
 }
 
 static inline u8 dual_link_from_link(u8 link)
index 2fefe76621ca343fe5153eabe4d8b98329f868c5..ea21d927bd094e85a4e19f7927a6743eaeb3fc5e 100644 (file)
@@ -40,8 +40,6 @@ struct tb_switch_nvm {
 };
 
 #define TB_SWITCH_KEY_SIZE             32
-/* Each physical port contains 2 links on modern controllers */
-#define TB_SWITCH_LINKS_PER_PHY_PORT   2
 
 /**
  * struct tb_switch - a thunderbolt switch
@@ -367,11 +365,6 @@ struct tb_switch *tb_switch_find_by_link_depth(struct tb *tb, u8 link,
                                               u8 depth);
 struct tb_switch *tb_switch_find_by_uuid(struct tb *tb, const uuid_t *uuid);
 
-static inline unsigned int tb_switch_phy_port_from_link(unsigned int link)
-{
-       return (link - 1) / TB_SWITCH_LINKS_PER_PHY_PORT;
-}
-
 static inline void tb_switch_put(struct tb_switch *sw)
 {
        put_device(&sw->dev);
index 910b1bf92112ef08c7315d04d11040217923a3b0..43b8d1e093411d664707a5353187cd7d59e0bb55 100644 (file)
@@ -78,6 +78,13 @@ struct tb {
 
 extern struct bus_type tb_bus_type;
 
+#define TB_LINKS_PER_PHY_PORT  2
+
+static inline unsigned int tb_phy_port_from_link(unsigned int link)
+{
+       return (link - 1) / TB_LINKS_PER_PHY_PORT;
+}
+
 /**
  * struct tb_property_dir - XDomain property directory
  * @uuid: Directory UUID or %NULL if root directory