From nobody Tue Dec 30 09:59:44 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3485C072A2 for ; Fri, 17 Nov 2023 15:40:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345993AbjKQPkh (ORCPT ); Fri, 17 Nov 2023 10:40:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232348AbjKQPk0 (ORCPT ); Fri, 17 Nov 2023 10:40:26 -0500 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92F0910D0; Fri, 17 Nov 2023 07:40:22 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 703451BF211; Fri, 17 Nov 2023 15:40:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1700235621; 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=rRo/pQcZejgRnemKP4uNQxIXQrj56PAQ2aabjMSpgaA=; b=GnhtVcTeeFqGMaAcovX1o3xPo/YAWPfzDS9rVjV7Qcv7xceupy2l5m9E9wXuXb7XB5Nbqz 9zCF+d6vMutig1CM32SZHX3qyFliuI6TSuSU+pVWZVgWEDI2/xoi/oGMO2ns7Di2vVjdUp y6t7kSCWp9Q1M4UefMNzQedp5vrtRrNdRCkEo5wxqU1U6X+Sy7e85y9hux490ttCcCXLpG 6NC5rfPOPYZl4fRe3x/wQQlvnYJsRyS3kEb01suvfauDbSsc++V14l7qEBBDf5KOphcIc3 UnwYdnCOszVKHAyRhxu0SZuYFlAdxgAlo5T1buzTI9GnQyxqzj3tQZQo/5vj2g== 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 Subject: [RFC PATCH net-next v2 04/10] net: sfp: Add helper to return the SFP bus name Date: Fri, 17 Nov 2023 17:23:15 +0100 Message-ID: <20231117162323.626979-5-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231117162323.626979-1-maxime.chevallier@bootlin.com> References: <20231117162323.626979-1-maxime.chevallier@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-GND-Sasl: maxime.chevallier@bootlin.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/net/phy/sfp-bus.c | 9 +++++++++ include/linux/sfp.h | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/drivers/net/phy/sfp-bus.c b/drivers/net/phy/sfp-bus.c index f42e9a082935..835fb2271b12 100644 --- a/drivers/net/phy/sfp-bus.c +++ b/drivers/net/phy/sfp-bus.c @@ -859,3 +859,12 @@ 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) +{ + 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..96f7644908bd 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 const char *sfp_get_name(struct sfp_bus *bus) +{ + return NULL; +} #endif =20 #endif --=20 2.41.0