thunderbolt: Introduce tb_xdomain_downstream_port()
authorMika Westerberg <mika.westerberg@linux.intel.com>
Fri, 30 Sep 2022 08:12:42 +0000 (11:12 +0300)
committerMika Westerberg <mika.westerberg@linux.intel.com>
Fri, 9 Jun 2023 09:07:22 +0000 (12:07 +0300)
In the same way we did for the routers add a function that returns the
parent routers downstream facing port for XDomain devices.

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

index a8e1725b4cb541ad8f514240661391e287288aa7..1e617c6e11aecf80b7881e43963df56b35b292b3 100644 (file)
@@ -1197,6 +1197,17 @@ static inline struct tb_switch *tb_xdomain_parent(struct tb_xdomain *xd)
        return tb_to_switch(xd->dev.parent);
 }
 
+/**
+ * tb_xdomain_downstream_port() - Return downstream facing port of parent router
+ * @xd: Xdomain pointer
+ *
+ * Returns the downstream port the XDomain is connected to.
+ */
+static inline struct tb_port *tb_xdomain_downstream_port(struct tb_xdomain *xd)
+{
+       return tb_port_at(xd->route, tb_xdomain_parent(xd));
+}
+
 int tb_retimer_nvm_read(struct tb_retimer *rt, unsigned int address, void *buf,
                        size_t size);
 int tb_retimer_scan(struct tb_port *port, bool add);
index e2b54887d3313e6a7adc6f9dc3e5bbf7a5946056..8389961b2d45b846cf155d37d915b67f584ecfb7 100644 (file)
@@ -537,9 +537,8 @@ static int tb_xdp_link_state_status_request(struct tb_ctl *ctl, u64 route,
 static int tb_xdp_link_state_status_response(struct tb *tb, struct tb_ctl *ctl,
                                             struct tb_xdomain *xd, u8 sequence)
 {
-       struct tb_switch *sw = tb_to_switch(xd->dev.parent);
        struct tb_xdp_link_state_status_response res;
-       struct tb_port *port = tb_port_at(xd->route, sw);
+       struct tb_port *port = tb_xdomain_downstream_port(xd);
        u32 val[2];
        int ret;
 
@@ -1137,7 +1136,7 @@ static int tb_xdomain_update_link_attributes(struct tb_xdomain *xd)
        struct tb_port *port;
        int ret;
 
-       port = tb_port_at(xd->route, tb_xdomain_parent(xd));
+       port = tb_xdomain_downstream_port(xd);
 
        ret = tb_port_get_link_speed(port);
        if (ret < 0)
@@ -1251,8 +1250,7 @@ static int tb_xdomain_get_link_status(struct tb_xdomain *xd)
 static int tb_xdomain_link_state_change(struct tb_xdomain *xd,
                                        unsigned int width)
 {
-       struct tb_switch *sw = tb_to_switch(xd->dev.parent);
-       struct tb_port *port = tb_port_at(xd->route, sw);
+       struct tb_port *port = tb_xdomain_downstream_port(xd);
        struct tb *tb = xd->tb;
        u8 tlw, tls;
        u32 val;
@@ -1309,7 +1307,7 @@ static int tb_xdomain_bond_lanes_uuid_high(struct tb_xdomain *xd)
                return -ETIMEDOUT;
        }
 
-       port = tb_port_at(xd->route, tb_xdomain_parent(xd));
+       port = tb_xdomain_downstream_port(xd);
 
        /*
         * We can't use tb_xdomain_lane_bonding_enable() here because it
@@ -1425,7 +1423,7 @@ static int tb_xdomain_get_properties(struct tb_xdomain *xd)
                if (xd->bonding_possible) {
                        struct tb_port *port;
 
-                       port = tb_port_at(xd->route, tb_xdomain_parent(xd));
+                       port = tb_xdomain_downstream_port(xd);
                        if (!port->bonded)
                                tb_port_disable(port->dual_link_port);
                }
@@ -1979,7 +1977,7 @@ int tb_xdomain_lane_bonding_enable(struct tb_xdomain *xd)
        struct tb_port *port;
        int ret;
 
-       port = tb_port_at(xd->route, tb_xdomain_parent(xd));
+       port = tb_xdomain_downstream_port(xd);
        if (!port->dual_link_port)
                return -ENODEV;
 
@@ -2024,7 +2022,7 @@ void tb_xdomain_lane_bonding_disable(struct tb_xdomain *xd)
 {
        struct tb_port *port;
 
-       port = tb_port_at(xd->route, tb_xdomain_parent(xd));
+       port = tb_xdomain_downstream_port(xd);
        if (port->dual_link_port) {
                tb_port_lane_bonding_disable(port);
                if (tb_port_wait_for_link_width(port, 1, 100) == -ETIMEDOUT)