diff options
author | Gil Fine <gil.fine@intel.com> | 2022-09-23 01:30:38 +0300 |
---|---|---|
committer | Mika Westerberg <mika.westerberg@linux.intel.com> | 2023-06-09 12:07:22 +0300 |
commit | 7ce542219b6323764cb922722b677005404d9b60 (patch) | |
tree | 13d0ddb08544c5a34a01cc0ba874756529938a5f /drivers/thunderbolt/tmu.c | |
parent | ef65afa0740e28cb0951fa9012cb78765f883a4a (diff) | |
download | linux-7ce542219b6323764cb922722b677005404d9b60.tar.gz linux-7ce542219b6323764cb922722b677005404d9b60.tar.bz2 linux-7ce542219b6323764cb922722b677005404d9b60.zip |
thunderbolt: Introduce tb_switch_downstream_port()
Introduce tb_switch_downstream_port() helper function that returns the
downstream port of a parent switch that is connected to the upstream
port of specified switch. From now on, we use it all across the driver
where applicable.
While there fix a whitespace in comment and rename 'downstream' to
'down' to be consistent with the rest of the driver.
Signed-off-by: Gil Fine <gil.fine@intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Diffstat (limited to 'drivers/thunderbolt/tmu.c')
-rw-r--r-- | drivers/thunderbolt/tmu.c | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/drivers/thunderbolt/tmu.c b/drivers/thunderbolt/tmu.c index 626aca3124b1..a46203b33c5f 100644 --- a/drivers/thunderbolt/tmu.c +++ b/drivers/thunderbolt/tmu.c @@ -398,11 +398,10 @@ int tb_switch_tmu_disable(struct tb_switch *sw) if (tb_route(sw)) { bool unidirectional = sw->tmu.unidirectional; - struct tb_switch *parent = tb_switch_parent(sw); struct tb_port *down, *up; int ret; - down = tb_port_at(tb_route(sw), parent); + down = tb_switch_downstream_port(sw); up = tb_upstream_port(sw); /* * In case of uni-directional time sync, TMU handshake is @@ -442,10 +441,9 @@ int tb_switch_tmu_disable(struct tb_switch *sw) static void __tb_switch_tmu_off(struct tb_switch *sw, bool unidirectional) { - struct tb_switch *parent = tb_switch_parent(sw); struct tb_port *down, *up; - down = tb_port_at(tb_route(sw), parent); + down = tb_switch_downstream_port(sw); up = tb_upstream_port(sw); /* * In case of any failure in one of the steps when setting @@ -457,7 +455,8 @@ static void __tb_switch_tmu_off(struct tb_switch *sw, bool unidirectional) tb_port_tmu_time_sync_disable(down); tb_port_tmu_time_sync_disable(up); if (unidirectional) - tb_switch_tmu_rate_write(parent, TB_SWITCH_TMU_RATE_OFF); + tb_switch_tmu_rate_write(tb_switch_parent(sw), + TB_SWITCH_TMU_RATE_OFF); else tb_switch_tmu_rate_write(sw, TB_SWITCH_TMU_RATE_OFF); @@ -472,12 +471,11 @@ static void __tb_switch_tmu_off(struct tb_switch *sw, bool unidirectional) */ static int __tb_switch_tmu_enable_bidirectional(struct tb_switch *sw) { - struct tb_switch *parent = tb_switch_parent(sw); struct tb_port *up, *down; int ret; up = tb_upstream_port(sw); - down = tb_port_at(tb_route(sw), parent); + down = tb_switch_downstream_port(sw); ret = tb_port_tmu_unidirectional_disable(up); if (ret) @@ -537,13 +535,13 @@ static int tb_switch_tmu_unidirectional_enable(struct tb_switch *sw) */ static int __tb_switch_tmu_enable_unidirectional(struct tb_switch *sw) { - struct tb_switch *parent = tb_switch_parent(sw); struct tb_port *up, *down; int ret; up = tb_upstream_port(sw); - down = tb_port_at(tb_route(sw), parent); - ret = tb_switch_tmu_rate_write(parent, sw->tmu.rate_request); + down = tb_switch_downstream_port(sw); + ret = tb_switch_tmu_rate_write(tb_switch_parent(sw), + sw->tmu.rate_request); if (ret) return ret; @@ -576,10 +574,9 @@ out: static void __tb_switch_tmu_change_mode_prev(struct tb_switch *sw) { - struct tb_switch *parent = tb_switch_parent(sw); struct tb_port *down, *up; - down = tb_port_at(tb_route(sw), parent); + down = tb_switch_downstream_port(sw); up = tb_upstream_port(sw); /* * In case of any failure in one of the steps when change mode, @@ -589,7 +586,7 @@ static void __tb_switch_tmu_change_mode_prev(struct tb_switch *sw) */ tb_port_tmu_set_unidirectional(down, sw->tmu.unidirectional); if (sw->tmu.unidirectional_request) - tb_switch_tmu_rate_write(parent, sw->tmu.rate); + tb_switch_tmu_rate_write(tb_switch_parent(sw), sw->tmu.rate); else tb_switch_tmu_rate_write(sw, sw->tmu.rate); @@ -599,18 +596,18 @@ static void __tb_switch_tmu_change_mode_prev(struct tb_switch *sw) static int __tb_switch_tmu_change_mode(struct tb_switch *sw) { - struct tb_switch *parent = tb_switch_parent(sw); struct tb_port *up, *down; int ret; up = tb_upstream_port(sw); - down = tb_port_at(tb_route(sw), parent); + down = tb_switch_downstream_port(sw); ret = tb_port_tmu_set_unidirectional(down, sw->tmu.unidirectional_request); if (ret) goto out; if (sw->tmu.unidirectional_request) - ret = tb_switch_tmu_rate_write(parent, sw->tmu.rate_request); + ret = tb_switch_tmu_rate_write(tb_switch_parent(sw), + sw->tmu.rate_request); else ret = tb_switch_tmu_rate_write(sw, sw->tmu.rate_request); if (ret) |