From patchwork Fri Dec 15 17:12:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Chevallier X-Patchwork-Id: 179450 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp9441488dys; Fri, 15 Dec 2023 09:23:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IFeA7G+4FYUJiFi0hIdPZSV3dATOQU90LGTmhAwg7qwFXPwPGUztMRooeG4srB3e8jJePOG X-Received: by 2002:a17:907:3d8e:b0:a19:a1ba:da4b with SMTP id he14-20020a1709073d8e00b00a19a1bada4bmr7928862ejc.114.1702660980464; Fri, 15 Dec 2023 09:23:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702660980; cv=none; d=google.com; s=arc-20160816; b=HI1wF/oP3jbSLqAsQmrXrSTsfCRWGKCx1CHHaLCIYh6FVFwyQ9UrCHUD/bfxPyvnfE wSz5iWJZlxTqJiiJW2ixBUqzxkOd9nyLvMma4dMaSuwCEdrx+7xPOZnzzSk0OZg3jCI4 yBdIf8OwK7pMIOCKPZULJpBxiOrfvkkTZ4DNPGHQbuP+/+inZ53YZ9VdAZaLT64bMUFJ +5WCu4AlhugyaW9YaJMvTb4t84/yEo8Y+TuqENbbRAc39x9GSRwPmq6KdxJG51eevLbR lg2UHvlXrs7DB73rcV2MehPByyC0KDTgtMENGCTSXbHfhkXkFgTwmd6S8e5SbJjNmokv Bj1A== 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=KoglPoPxMjohGlT19IV2d4irMqcCP5CPPQtgcH9Zsx0=; fh=01/i7K9ues3Vkkz8uyECvnCPITXmGs/30yOh5FbyFgY=; b=BAPazz3Xl3M1AUIAOSTKbBKMZqUXxOrpKJXqbNel1+Hj5qUQPUlW/yICVHwg54HX0U fqO3AYjT/WCUBYv9bVFvM46U2pa89PxHp+bmjGg90MBHLD77ALi31aVfna6uav/vLyPt fYYMt/7focGcKdGyr8bimGcM7sWqgHrOy2RF+DiZhlPE8Ll/veMtuKyVjU2Gj6kwVx+z RvCwEL4AvDFOPZq48NrBVIvvSVjYLsMEHhfRwr+/L6JeetGXFWoNf+ywtFXkrOPyG9sd wRo0U1mupk7r3/U4DsEsFLARubyS7yVKilJ4iA90NAZYhfdsWmfjtX5gED2xZGwuc9Gz fkmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=YLMRoKKn; spf=pass (google.com: domain of linux-kernel+bounces-1396-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1396-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id bi25-20020a170906a25900b00a1e025a7d23si7658645ejb.641.2023.12.15.09.23.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 09:23:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-1396-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=YLMRoKKn; spf=pass (google.com: domain of linux-kernel+bounces-1396-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1396-ouuuleilei=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 am.mirrors.kernel.org (Postfix) with ESMTPS id 139531F2103A for ; Fri, 15 Dec 2023 17:23:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 65E8C7FBA3; Fri, 15 Dec 2023 17:12:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="YLMRoKKn" X-Original-To: linux-kernel@vger.kernel.org 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 0AC4E47F48; Fri, 15 Dec 2023 17:12:47 +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 0C929C0005; Fri, 15 Dec 2023 17:12:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1702660366; 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=KoglPoPxMjohGlT19IV2d4irMqcCP5CPPQtgcH9Zsx0=; b=YLMRoKKnAUa9V7xJHgVwKZv6oJTp8Q2KJuV26+i+wFtvUNqqkuA3FOaYRkp3O8ShbnVuel b4lXchIE17nVN8NXlKNHJvhlsdjJqyNq9XVkIhlBIocsQKgp0Wlzn3ZUSNrZxUIYztSzU6 YtHmA9d3ZuuGN+PzCrZZP2Hr7g5ofViwRa2OAWmv4oNGiUci34JFHNnESgqTrKcQDbIx52 OPZ319L4wF/aC15Yj4gPRtUGIg9ALMfxuOE0X1JwK43yXp1XSufQwKvKxrgy7D1ZuDJ7/A X87uIJ6jYWe+bLmq0hF7Mrn1veS4emcSVovmRZaQ5cIYNkj94NuWM3iVn3og7Q== 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?= Subject: [PATCH net-next v4 04/13] net: sfp: Add helper to return the SFP bus name Date: Fri, 15 Dec 2023 18:12:26 +0100 Message-ID: <20231215171237.1152563-5-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231215171237.1152563-1-maxime.chevallier@bootlin.com> References: <20231215171237.1152563-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 X-GND-Sasl: maxime.chevallier@bootlin.com X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785369440466622555 X-GMAIL-MSGID: 1785369440466622555 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 --- 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