aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMika Westerberg <mika.westerberg@linux.intel.com>2017-10-02 06:38:33 -0400
committerDavid S. Miller <davem@davemloft.net>2017-10-02 14:24:41 -0400
commite69b71f8458b78a2ef44e3d07374a8f46e45123d (patch)
treef9d0ed77163f829cc1824478f4beda9446254492
parent9e99b9f4d5c36340dabda6d14053195b2a43796b (diff)
thunderbolt: Move tb_switch_phy_port_from_link() to thunderbolt.h
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>
-rw-r--r--drivers/thunderbolt/icm.c2
-rw-r--r--drivers/thunderbolt/tb.h7
-rw-r--r--include/linux/thunderbolt.h7
3 files changed, 8 insertions, 8 deletions
diff --git a/drivers/thunderbolt/icm.c b/drivers/thunderbolt/icm.c
index 53250fc057e1..8c22b91ed040 100644
--- a/drivers/thunderbolt/icm.c
+++ b/drivers/thunderbolt/icm.c
@@ -89,7 +89,7 @@ static inline struct tb *icm_to_tb(struct icm *icm)
89 89
90static inline u8 phy_port_from_route(u64 route, u8 depth) 90static inline u8 phy_port_from_route(u64 route, u8 depth)
91{ 91{
92 return tb_switch_phy_port_from_link(route >> ((depth - 1) * 8)); 92 return tb_phy_port_from_link(route >> ((depth - 1) * 8));
93} 93}
94 94
95static inline u8 dual_link_from_link(u8 link) 95static inline u8 dual_link_from_link(u8 link)
diff --git a/drivers/thunderbolt/tb.h b/drivers/thunderbolt/tb.h
index 2fefe76621ca..ea21d927bd09 100644
--- a/drivers/thunderbolt/tb.h
+++ b/drivers/thunderbolt/tb.h
@@ -40,8 +40,6 @@ struct tb_switch_nvm {
40}; 40};
41 41
42#define TB_SWITCH_KEY_SIZE 32 42#define TB_SWITCH_KEY_SIZE 32
43/* Each physical port contains 2 links on modern controllers */
44#define TB_SWITCH_LINKS_PER_PHY_PORT 2
45 43
46/** 44/**
47 * struct tb_switch - a thunderbolt switch 45 * struct tb_switch - a thunderbolt switch
@@ -367,11 +365,6 @@ struct tb_switch *tb_switch_find_by_link_depth(struct tb *tb, u8 link,
367 u8 depth); 365 u8 depth);
368struct tb_switch *tb_switch_find_by_uuid(struct tb *tb, const uuid_t *uuid); 366struct tb_switch *tb_switch_find_by_uuid(struct tb *tb, const uuid_t *uuid);
369 367
370static inline unsigned int tb_switch_phy_port_from_link(unsigned int link)
371{
372 return (link - 1) / TB_SWITCH_LINKS_PER_PHY_PORT;
373}
374
375static inline void tb_switch_put(struct tb_switch *sw) 368static inline void tb_switch_put(struct tb_switch *sw)
376{ 369{
377 put_device(&sw->dev); 370 put_device(&sw->dev);
diff --git a/include/linux/thunderbolt.h b/include/linux/thunderbolt.h
index 910b1bf92112..43b8d1e09341 100644
--- a/include/linux/thunderbolt.h
+++ b/include/linux/thunderbolt.h
@@ -78,6 +78,13 @@ struct tb {
78 78
79extern struct bus_type tb_bus_type; 79extern struct bus_type tb_bus_type;
80 80
81#define TB_LINKS_PER_PHY_PORT 2
82
83static inline unsigned int tb_phy_port_from_link(unsigned int link)
84{
85 return (link - 1) / TB_LINKS_PER_PHY_PORT;
86}
87
81/** 88/**
82 * struct tb_property_dir - XDomain property directory 89 * struct tb_property_dir - XDomain property directory
83 * @uuid: Directory UUID or %NULL if root directory 90 * @uuid: Directory UUID or %NULL if root directory