From nobody Tue Feb 10 08:28:08 2026 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4389277F1E; Thu, 4 Apr 2024 09:30:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.198 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712223018; cv=none; b=lO4c9KpbdVKpmLq63gFn8yPIuOHNlCjiKqDTbQEGkrBZje1M8G+9miLBoMAw0cUrdjbOyE+n8645hO1hqlt83gtzqh5KmpkG5jFERMtErWii3m6qaI1T0SRae9If1h07O7tbf9s8S8ZES1LhAWMdeu/cdnqCr5lPSVoTJb6Y/Ig= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712223018; c=relaxed/simple; bh=rK0CM1sBCffF/nr4O17g7ADAmcAbrG7D+QC0dduS4mY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UfnuFTJJVTr2GzZWpI/XVKkEhEYA4cC53f6+Mhojo646upaVj7SPeP0rYlMh0HCRFkQwuKr/8TLQNmjMlI1OhAQtyeqL4U5Ca573EBWAEOVJheERzqhHVR8YwDwnGL/AikkaPn8IwceETMhZTKTa+r/Hhaj3imHDR3kdBXwDQLY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=mghyWQyp; arc=none smtp.client-ip=217.70.183.198 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="mghyWQyp" Received: by mail.gandi.net (Postfix) with ESMTPSA id 5C81BC0002; Thu, 4 Apr 2024 09:30:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1712223014; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=S1iLmfkC7iV/duSPnT2odwBCnUC2F5PO4YYKfwlTnPY=; b=mghyWQypDL3yl22J/Pwg7sqDOo9dSDbySrwwpurZqolaIutG9+ggzZ/A/equfSOKavMlKQ jjwhihDPFSVPhHr5yCzduSjfY1Qg3cyrhGJX/qi6BwVE4OjeNwoDQYwNircVwWivQTALak DsQ0Yj18KCK1znO8wyRBAlJFW8P7fbhg7jWmZB40Myg8ReWHZPbp3CyqR30nagPnbrsQBp NInMCWv3NtHXS63CmPvPMshOWQ8bYctAB9abqxncEuNESwJKpwxvJnvFeTsEYo7c2trsuM 31XPjQYWyI1f0ql9l/JyIgN74WYSyjaq4tmJSv1zAqN6GecgzoLBWJ3eD/geEw== From: Maxime Chevallier To: davem@davemloft.net Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, Andrew Lunn , Jakub Kicinski , Eric Dumazet , Paolo Abeni , Russell King , linux-arm-kernel@lists.infradead.org, Christophe Leroy , Herve Codina , Florian Fainelli , Heiner Kallweit , Vladimir Oltean , =?UTF-8?q?K=C3=B6ry=20Maincent?= , Jesse Brandeburg , Jonathan Corbet , =?UTF-8?q?Marek=20Beh=C3=BAn?= , Piergiorgio Beruto , Oleksij Rempel , =?UTF-8?q?Nicol=C3=B2=20Veronese?= , Simon Horman , mwojtas@chromium.org Subject: [PATCH net-next v11 04/13] net: sfp: Add helper to return the SFP bus name Date: Thu, 4 Apr 2024 11:29:54 +0200 Message-ID: <20240404093004.2552221-5-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240404093004.2552221-1-maxime.chevallier@bootlin.com> References: <20240404093004.2552221-1-maxime.chevallier@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-GND-Sasl: maxime.chevallier@bootlin.com Content-Type: text/plain; charset="utf-8" Knowing the bus name is helpful when we want to expose the link topology to userspace, add a helper to return the SFP bus name. Signed-off-by: Maxime Chevallier Reviewed-by: Andrew Lunn --- V11: - No changes V10: - No changes V9: - No changes V8: - No changes V7: - No changes V6: - No changes V5: - Added Andrew's R-b V4: - No changes V3: - Added RTNL assert drivers/net/phy/sfp-bus.c | 11 +++++++++++ include/linux/sfp.h | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/drivers/net/phy/sfp-bus.c b/drivers/net/phy/sfp-bus.c index e05013aeecc3..413021619afe 100644 --- a/drivers/net/phy/sfp-bus.c +++ b/drivers/net/phy/sfp-bus.c @@ -859,3 +859,14 @@ void sfp_unregister_socket(struct sfp_bus *bus) sfp_bus_put(bus); } EXPORT_SYMBOL_GPL(sfp_unregister_socket); + +const char *sfp_get_name(struct sfp_bus *bus) +{ + ASSERT_RTNL(); + + if (bus->sfp_dev) + return dev_name(bus->sfp_dev); + + return NULL; +} +EXPORT_SYMBOL_GPL(sfp_get_name); diff --git a/include/linux/sfp.h b/include/linux/sfp.h index 0573e53b0c11..55c0ab17c9e2 100644 --- a/include/linux/sfp.h +++ b/include/linux/sfp.h @@ -570,6 +570,7 @@ struct sfp_bus *sfp_bus_find_fwnode(const struct fwnode= _handle *fwnode); int sfp_bus_add_upstream(struct sfp_bus *bus, void *upstream, const struct sfp_upstream_ops *ops); void sfp_bus_del_upstream(struct sfp_bus *bus); +const char *sfp_get_name(struct sfp_bus *bus); #else static inline int sfp_parse_port(struct sfp_bus *bus, const struct sfp_eeprom_id *id, @@ -648,6 +649,11 @@ static inline int sfp_bus_add_upstream(struct sfp_bus = *bus, void *upstream, static inline void sfp_bus_del_upstream(struct sfp_bus *bus) { } + +static inline const char *sfp_get_name(struct sfp_bus *bus) +{ + return NULL; +} #endif =20 #endif --=20 2.44.0