From patchwork Wed Jul 3 14:07:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Chevallier X-Patchwork-Id: 13722373 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 C8DC5C2BD09 for ; Wed, 3 Jul 2024 14:09:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=42HRyVnUZZ6yygw+Uuh45E3YKED+dxCVj6t2LrErm3Q=; b=5Gii9WjXHnl6tYQTLBD028xm1a MoXJBYuauBFW19TN8erPh0LrmLKhI+hR2QUGFLhT0O0EsJh0V2/+XbACOtUdxALOVrgXTpGowJPs5 EyagpzzxFpqWWD0u+2f6iHfGhQhmZAVgRWDs4yf/YSQ0ShJ9XMVBKsrP6Vk3C7PO6+gXkJYIwelY5 aTfwrUkRlKRN9T94dkrvHLxGZV53Mz6xNwGCZrJZ2bk21jVKiKuHS/AxQUUod/rgjeJeoD0k736fr ovySV2ZEbw0sigHfmQqIqvlPn3eTcO7Ru5QcylZ/atLFJ5hOP8Gru4oOQfh0hSVFib7Mf1d9vK1pY 79mbqWSQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sP0fT-0000000APiM-2Mtk; Wed, 03 Jul 2024 14:09:07 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sP0ej-0000000APUz-0lsR for linux-arm-kernel@bombadil.infradead.org; Wed, 03 Jul 2024 14:08:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=42HRyVnUZZ6yygw+Uuh45E3YKED+dxCVj6t2LrErm3Q=; b=T8hsWZP0dwt7YvsqsBPJPybIQJ AfgLSmw4sxsT73jynScGnxUdnZNJrmpx9jdCmMSQk4gcYs+rPnKqmWO6kFCo+Myc4tWGGwvqsFeY9 F55Z+w0O5P7tB6FG6NtOEyDVCs4d0cWr8aJdQlsknbaBhqiLVbfLux1NJroQeUjQT+d2ApFrwJtow NZ+VD9c0q37lmzRA6bN0t3Qght6fuJ3Wg47/Q96EVIrA1/oBHMlgQ5GIDrhtQ9tI8KVvsjfAMT/lP lhehyUTrCpwRrQ32j3rr56rwM96JHmzUdrjfH7U2YXVu5OKZSjP4MOL0IyiFSPCj49wCFRVAk9Ggu gsXK9Gkg==; Received: from relay4-d.mail.gandi.net ([2001:4b98:dc4:8::224]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sP0ee-0000000A2zn-3AuV for linux-arm-kernel@lists.infradead.org; Wed, 03 Jul 2024 14:08:19 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 9707EE000B; Wed, 3 Jul 2024 14:08:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1720015695; 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=42HRyVnUZZ6yygw+Uuh45E3YKED+dxCVj6t2LrErm3Q=; b=LgakU5bo+IGHB8Krtj8pJ9z0wGTIWWx8npUHZOEYXkeqA3tAlaviD7/4ip5o2Ie8WkRZ5z MG5eaUS6uhnd8CU8LyMTfLpI5JFcm2/18Oi+mFn0eiaMavHAxOLdPYkkC/3adqEvlhG6tX cdEltNOLeYxqUaE8RqFsvmxoWiPfBI9zZF+TGQBEyL4nMuN5sO7YyQNlJ5jlkx53eydgKT Xk7/XKisUboBZYYLKkBPdR1KYDdWmPod2oZFG0NVAbCAa0shPM41Agh6WzjlIk57xPNOMP caDQa1sMgT1gm81yJLeSmHVL62PjN78QbySyyMu5DoLHJoYzwzR/Ww/JYBBIIQ== 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 , =?utf-8?q?Marek_Beh=C3=BAn?= , Piergiorgio Beruto , Oleksij Rempel , =?utf-8?q?Nicol=C3=B2_Veronese?= , Simon Horman , mwojtas@chromium.org, Nathan Chancellor , Antoine Tenart , Marc Kleine-Budde , Dan Carpenter Subject: [PATCH net-next v15 04/14] net: sfp: Add helper to return the SFP bus name Date: Wed, 3 Jul 2024 16:07:54 +0200 Message-ID: <20240703140806.271938-5-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240703140806.271938-1-maxime.chevallier@bootlin.com> References: <20240703140806.271938-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-20240703_150817_110524_3AEEE7FE X-CRM114-Status: UNSURE ( 9.50 ) X-CRM114-Notice: Please train this message. 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 --- 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 56953e66bb7b..37c85f1e6534 100644 --- a/drivers/net/phy/sfp-bus.c +++ b/drivers/net/phy/sfp-bus.c @@ -860,3 +860,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 54abb4d22b2e..60c65cea74f6 100644 --- a/include/linux/sfp.h +++ b/include/linux/sfp.h @@ -576,6 +576,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, @@ -654,6 +655,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