All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: linux-usb@vger.kernel.org
Cc: Yehezkel Bernat <YehezkelShB@gmail.com>,
	Michael Jamet <michael.jamet@intel.com>,
	Lukas Wunner <lukas@wunner.de>,
	Andreas Noever <andreas.noever@gmail.com>,
	Gil Fine <gil.fine@linux.intel.com>,
	Mika Westerberg <mika.westerberg@linux.intel.com>
Subject: [PATCH v2 08/10] thunderbolt: Introduce tb_switch_depth()
Date: Fri, 13 Oct 2023 15:06:38 +0300	[thread overview]
Message-ID: <20231013120640.709255-9-mika.westerberg@linux.intel.com> (raw)
In-Reply-To: <20231013120640.709255-1-mika.westerberg@linux.intel.com>

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 <mika.westerberg@linux.intel.com>
---
 drivers/thunderbolt/tb.c | 4 ++--
 drivers/thunderbolt/tb.h | 9 +++++++++
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/thunderbolt/tb.c b/drivers/thunderbolt/tb.c
index e1e2792d14a7..9efe0b1435e8 100644
--- a/drivers/thunderbolt/tb.c
+++ b/drivers/thunderbolt/tb.c
@@ -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;
 
 	/*
diff --git a/drivers/thunderbolt/tb.h b/drivers/thunderbolt/tb.h
index 869ac360e1b5..80e28124f583 100644
--- a/drivers/thunderbolt/tb.h
+++ b/drivers/thunderbolt/tb.h
@@ -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 &&
-- 
2.40.1


  parent reply	other threads:[~2023-10-13 12:06 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-13 12:06 [PATCH v2 00/10] thunderbolt: USB4 v2 asymmetric switching and more Mika Westerberg
2023-10-13 12:06 ` [PATCH v2 01/10] thunderbolt: Use constants for path weight and priority Mika Westerberg
2023-10-13 12:06 ` [PATCH v2 02/10] thunderbolt: Use weight constants in tb_usb3_consumed_bandwidth() Mika Westerberg
2023-10-13 12:06 ` [PATCH v2 03/10] thunderbolt: Make is_gen4_link() available to the rest of the driver Mika Westerberg
2023-10-13 12:06 ` [PATCH v2 04/10] thunderbolt: Change bandwidth reservations to comply USB4 v2 Mika Westerberg
2023-10-13 12:06 ` [PATCH v2 05/10] thunderbolt: Set path power management packet support bit for USB4 v2 routers Mika Westerberg
2023-10-13 12:06 ` [PATCH v2 06/10] thunderbolt: Introduce tb_port_path_direction_downstream() Mika Westerberg
2023-10-13 12:06 ` [PATCH v2 07/10] thunderbolt: Introduce tb_for_each_upstream_port_on_path() Mika Westerberg
2023-10-13 12:06 ` Mika Westerberg [this message]
2023-10-13 12:06 ` [PATCH v2 09/10] thunderbolt: Add support for asymmetric link Mika Westerberg
2023-10-13 12:06 ` [PATCH v2 10/10] thunderbolt: Configure asymmetric link if needed and bandwidth allows Mika Westerberg
2023-10-20 15:24 ` [PATCH v2 00/10] thunderbolt: USB4 v2 asymmetric switching and more Mika Westerberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231013120640.709255-9-mika.westerberg@linux.intel.com \
    --to=mika.westerberg@linux.intel.com \
    --cc=YehezkelShB@gmail.com \
    --cc=andreas.noever@gmail.com \
    --cc=gil.fine@linux.intel.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=lukas@wunner.de \
    --cc=michael.jamet@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.