Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp320892rdb; Thu, 21 Dec 2023 10:02:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IHzuw6aEX1DnGVn6Z5UyACBcKHAyVVTzaq1Kp/78gsfSqI/28Y/PZzZJGMYKJhInzIhTrRY X-Received: by 2002:a17:90a:4961:b0:28b:e9e9:e0f with SMTP id c88-20020a17090a496100b0028be9e90e0fmr113308pjh.17.1703181749809; Thu, 21 Dec 2023 10:02:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703181749; cv=none; d=google.com; s=arc-20160816; b=j5QC/cOTMC9DuO/Z2dBdZfwW/PiyTs5tdOUZniwBFjSJ1CNsGTGu2X5k+PU9qrrQqx AXLyTMFWIuOfB1lHU5+Zdlv4VkYIT288nQy9sMR5UcW5gXDRDtJkPGyvlYKlMYR+s0rI sFuCrV4LR1mkBib8q7M2RlAebgXQgNvUwUfNl7ym99ZGYNGq0BNDXvxe76uYok/y1LoM BDEoKOvmMX4+9DWo+tQpUWFpeWZTBhx4bREEvO7DppsajLCxoljl6tFUeuQp6djWCemc nkOYuM7um7HvCqlqG+liCjFb/CqXCo1ghv92K3lA8sXk6z/S3x19tsmOJwzfHfelspTN UoXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=ITNuUCoNP4s99jBMgEvKjUP+EuwHLWosDtc700xOI2s=; fh=d3Krop4IPE3x6nBOvh3GY5QHg6bS91zVnQiH59I3hyM=; b=hS3rzFKdfsnX18ZhpfS/47q110SdE5ORfhnM9P3sy8OCTn21fBnQI4o6E0iS0d842F 6HZKBL2j3808tUB4GuO607FeZ1iNYGIpDIt/TZk5jj/iQ7dhG9Ex4koVBSVTG94q6mlm 9otukKfZX6uWqxa7eJ50sHzEJwUXIp04qL149aBxV0e4KCTfGl8YVr8ilzj2PVYeUMph e6GolIS77hAzbPwxfoh+hn+xxt1RfkP07+wb+Dk/AJ/GLcbhQODhAtsiKpW3vXD6Y6QR lxInl3lmnL34/vSKTuZQ/z2pAI7V/h78lJbdiVk/0P+2Hy4YlHdC+sR/AnN9GV9xE7VW MT1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=J31c6vCb; spf=pass (google.com: domain of linux-kernel+bounces-8889-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8889-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id r17-20020a17090aa09100b0028aea7a9f59si5254374pjp.3.2023.12.21.10.02.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 10:02:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-8889-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=J31c6vCb; spf=pass (google.com: domain of linux-kernel+bounces-8889-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8889-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id D7C0E289134 for ; Thu, 21 Dec 2023 18:02:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C62E5745D3; Thu, 21 Dec 2023 18:01:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="J31c6vCb" X-Original-To: linux-kernel@vger.kernel.org Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) (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 1E35064AA0; Thu, 21 Dec 2023 18:00:58 +0000 (UTC) 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 Received: by mail.gandi.net (Postfix) with ESMTPSA id 28CCE1C000C; Thu, 21 Dec 2023 18:00:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1703181657; 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=ITNuUCoNP4s99jBMgEvKjUP+EuwHLWosDtc700xOI2s=; b=J31c6vCbqoze4gmtIRgEynkkjwDAc0ukSww2JVl0+4eJuh6lSzN5FuI82RtvdR4qjZhfbd aL5cnQX5HHhom3E6qhvCdCRc+3jrT1gP0D514dRz0Ob9zOIXMG9fAYJO5rSu5oGwy5z0xO Q3CYN68+R62Ci/Ig7I8MwM9d7Xi0nkkIwUWE6r88yaA0UL/lWJutyDUH0B8NzU78lAzUdb cubYDLSq8/o3aCQ7LguceB0zXqOXxk7jd5ylYJ+2zAUUfOJuxSx+FCECFN4Po0mOR/OQrZ Jm/09zgQlmypxMv+kWBA/J8UdPBAf5cgj9+7ZC1ftCDGUFceVIKZaOPR7ayNdg== 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 Subject: [PATCH net-next v5 04/13] net: sfp: Add helper to return the SFP bus name Date: Thu, 21 Dec 2023 19:00:37 +0100 Message-ID: <20231221180047.1924733-5-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231221180047.1924733-1-maxime.chevallier@bootlin.com> References: <20231221180047.1924733-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: 8bit X-GND-Sasl: maxime.chevallier@bootlin.com 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 --- 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 3a86c41e1235..fb1c102714b5 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 -- 2.43.0