From patchwork Fri Jan 26 18:38:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Chevallier X-Patchwork-Id: 13533201 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8D792C47422 for ; Fri, 26 Jan 2024 18:39:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=V8wWb1uW8fmSBokF5h+dsvUm3tXGRGC6VZfyTDAKZLw=; b=jACXExqMBm71e6 TNogRQdJ24NJkWFAcArCiAsj1WZfdrf0lim1krKpzcwvcMN6eM2TAlDtMzNojiG93/Ja2/uEuPCTp 3N50Y/BEFmA2qOZBYUmc+GsXX5DPz2gwnSUYM6tS7zio2U0GKv9P/qfKu+BX4ogkTclIO2igpvSXe KHnMNJwA0AxHzwRfYkigENhDGdE/75mRLfLYUcthpD7PdVtDjYCPzHQo3HrVAwXrAqRVTqtdLdBWP Mk9saUj9HBZNVO6U6dxiLYqoSfHt5ppZEd8S3pHqs0MBXYvbLRMnJmN6RldDQsiVTZUPfz2qWerk7 8xTsZ+Fe1Z1sZbyqQkkw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rTR6m-000000055uw-3EcJ; Fri, 26 Jan 2024 18:39:20 +0000 Received: from relay9-d.mail.gandi.net ([2001:4b98:dc4:8::229]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rTR6U-000000055le-3Aa9 for linux-arm-kernel@lists.infradead.org; Fri, 26 Jan 2024 18:39:04 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 114BCFF809; Fri, 26 Jan 2024 18:38:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1706294340; 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=P54eW/CeSDVJ7dlNU+SzvMDXqz5aY5hZJ6KJCcDk9sY=; b=ZLgTohUKbSgo3Fu79kGs9Ltzz/EIBzEiXfc2WDMtAK4gEOOISsq/jcA3ZwHoWBYcIogvwt PJB6Etc9iGI1J+MFygJTjNUFoP0Uiy3Ei0bjU5r0RZJyq9b9Q4mXjW4VcsFh2UReLg/0bL PVZdk8VyG+6dCf4DhG0nfitjYi6W+yFQGCJAtDYZJsWm1iHajAeEzOzh8g23Y/3yk1w6ZT sS2eT42nvESV4ln5qitYLVbozn5iM1F6MppLUdpXaU4d7FvkxXdL/wgUS+RYZYbw54lLNg dAw7NKyeE8F513KynjwaK9YukO6zlQXJ7xu/HLPoN/wMRsD/QSyAoaokE54w+Q== 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_Maincent?= , Jesse Brandeburg , Jonathan Corbet , =?utf-8?q?Marek_Beh=C3=BAn?= , Piergiorgio Beruto , Oleksij Rempel , =?utf-8?q?Nicol=C3=B2_Veronese?= , Simon Horman Subject: [PATCH net-next v6 04/13] net: sfp: Add helper to return the SFP bus name Date: Fri, 26 Jan 2024 19:38:41 +0100 Message-ID: <20240126183851.2081418-5-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240126183851.2081418-1-maxime.chevallier@bootlin.com> References: <20240126183851.2081418-1-maxime.chevallier@bootlin.com> MIME-Version: 1.0 X-GND-Sasl: maxime.chevallier@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240126_103903_120094_3A38958A X-CRM114-Status: GOOD ( 10.04 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 --- V6: - No changes V5: - Added Andrew's R-b V4: - No changes V3: - Added RTNL assert - Made the stub inline V2: New patch 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 #endif