Skip to content

Commit

Permalink
thunderbolt: Introduce tb_switch_depth()
Browse files Browse the repository at this point in the history
This is useful helper to find out the depth of a connected router.
Convert the existing users to call this helper instead of open-coding.

No functional changes.

Signed-off-by: Mika Westerberg <[email protected]>
  • Loading branch information
westeri committed Oct 20, 2023
1 parent 956c3ab commit c4ff144
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/thunderbolt/tb.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,13 +255,13 @@ static int tb_enable_clx(struct tb_switch *sw)
* this in the future to cover the whole topology if it turns
* out to be beneficial.
*/
while (sw && sw->config.depth > 1)
while (sw && tb_switch_depth(sw) > 1)
sw = tb_switch_parent(sw);

if (!sw)
return 0;

if (sw->config.depth != 1)
if (tb_switch_depth(sw) != 1)
return 0;

/*
Expand Down
9 changes: 9 additions & 0 deletions drivers/thunderbolt/tb.h
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,15 @@ static inline struct tb_port *tb_switch_downstream_port(struct tb_switch *sw)
return tb_port_at(tb_route(sw), tb_switch_parent(sw));
}

/**
* tb_switch_depth() - Returns depth of the connected router
* @sw: Router
*/
static inline int tb_switch_depth(const struct tb_switch *sw)
{
return sw->config.depth;
}

static inline bool tb_switch_is_light_ridge(const struct tb_switch *sw)
{
return sw->config.vendor_id == PCI_VENDOR_ID_INTEL &&
Expand Down

0 comments on commit c4ff144

Please sign in to comment.