Received: by 2002:ab2:2441:0:b0:1f3:1f8c:d0c6 with SMTP id k1csp150641lqe; Thu, 4 Apr 2024 02:31:52 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWHRhIaecE50tukx6nwzEUVDk/iyu9KofwA3+o/AAGtmJrspJTNMw57CjFbGTTgD+O1LH6OSKvxh2qsFf3YPYY1F0oz7Ib+TI+gfBaD9A== X-Google-Smtp-Source: AGHT+IHnJoE2XpYRM5FUFHrMkurruEABxB3Zbgi9hnMflOBYWGmI0jZnMldw4JFZSZAauvcuu2VP X-Received: by 2002:a1f:7c02:0:b0:4d4:1fe2:c398 with SMTP id x2-20020a1f7c02000000b004d41fe2c398mr1719208vkc.2.1712223112351; Thu, 04 Apr 2024 02:31:52 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712223112; cv=pass; d=google.com; s=arc-20160816; b=rBmpvJXG7VMgFicHk8bvZwGErln0xifkvSKWQKsgEYw5dTTyXOExQFh0vSG0gTH64/ Uk2UY2RYLoHsmnMWOnuwKmlVB6axR3qsLiBFLJ7ocEMsy9hcrzIMzL4EoSsL6EFtAyH5 QU4UQm9RBaJ2qpH54lhEJIMM74jwF3o4bGsfd/diqnPRuA41e2f0Cs0958zVIjPKGzGu FCQGzgQSX/PTdAuXmJ+DZsKqGnhyZmxoVmLxFbZW2kEOWun5piucxpf4YfgcNgmHEkAB 3De8f2Wzka/+O8PszXpCDvq4wiq2x5pKUjR4KGw4Tc2kvsqVhNtYk6k9yLrUIm0KH902 PhvA== ARC-Message-Signature: i=2; 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=S1iLmfkC7iV/duSPnT2odwBCnUC2F5PO4YYKfwlTnPY=; fh=1vUu/d1GTjraph6G+ET+Z0z13QVrf6oL/IrrK9zaTF8=; b=v9+OajRWMS9PA5FQKnC56fvQuwuq9ciVljWmqEYd5PloWNBxpbURrAoKQk4iRB2pgS EnzlYjO6NLxB0Y6ZeiZsrf+5GENL56oMNd948O1xHviV3nqrAmA8R75KGyEIAfHzrlr/ ykwUeQHGS1wxlPPHn1cQRx830z1w4dS1T8mAfrHxxkJMitvx3WfhWnnJ3QQ6wWaDtkNz 6+0H9xcV0ZjzhGRJoHVkAoduu95TVYtHhwKUcEySNXfLsGGowu4pGgMs0VCphK1QfLkQ L6Jkbmt5Qw1+CvuUv+IHJyIoKO24I479/3w7rNfoudWA95jTPQvbAIHBcNoqXUrL1E+E bPbA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=mghyWQyp; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-131175-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131175-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id e9-20020ad450c9000000b006967f520537si5317078qvq.169.2024.04.04.02.31.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 02:31:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-131175-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=mghyWQyp; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-131175-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131175-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id EEE4B1C260DC for ; Thu, 4 Apr 2024 09:31:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 659CE81AD1; Thu, 4 Apr 2024 09:30:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="mghyWQyp" 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 4389277F1E; Thu, 4 Apr 2024 09:30:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.198 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712223018; cv=none; b=lO4c9KpbdVKpmLq63gFn8yPIuOHNlCjiKqDTbQEGkrBZje1M8G+9miLBoMAw0cUrdjbOyE+n8645hO1hqlt83gtzqh5KmpkG5jFERMtErWii3m6qaI1T0SRae9If1h07O7tbf9s8S8ZES1LhAWMdeu/cdnqCr5lPSVoTJb6Y/Ig= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712223018; c=relaxed/simple; bh=rK0CM1sBCffF/nr4O17g7ADAmcAbrG7D+QC0dduS4mY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UfnuFTJJVTr2GzZWpI/XVKkEhEYA4cC53f6+Mhojo646upaVj7SPeP0rYlMh0HCRFkQwuKr/8TLQNmjMlI1OhAQtyeqL4U5Ca573EBWAEOVJheERzqhHVR8YwDwnGL/AikkaPn8IwceETMhZTKTa+r/Hhaj3imHDR3kdBXwDQLY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=mghyWQyp; arc=none smtp.client-ip=217.70.183.198 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 5C81BC0002; Thu, 4 Apr 2024 09:30:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1712223014; 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=S1iLmfkC7iV/duSPnT2odwBCnUC2F5PO4YYKfwlTnPY=; b=mghyWQypDL3yl22J/Pwg7sqDOo9dSDbySrwwpurZqolaIutG9+ggzZ/A/equfSOKavMlKQ jjwhihDPFSVPhHr5yCzduSjfY1Qg3cyrhGJX/qi6BwVE4OjeNwoDQYwNircVwWivQTALak DsQ0Yj18KCK1znO8wyRBAlJFW8P7fbhg7jWmZB40Myg8ReWHZPbp3CyqR30nagPnbrsQBp NInMCWv3NtHXS63CmPvPMshOWQ8bYctAB9abqxncEuNESwJKpwxvJnvFeTsEYo7c2trsuM 31XPjQYWyI1f0ql9l/JyIgN74WYSyjaq4tmJSv1zAqN6GecgzoLBWJ3eD/geEw== 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 , mwojtas@chromium.org Subject: [PATCH net-next v11 04/13] net: sfp: Add helper to return the SFP bus name Date: Thu, 4 Apr 2024 11:29:54 +0200 Message-ID: <20240404093004.2552221-5-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240404093004.2552221-1-maxime.chevallier@bootlin.com> References: <20240404093004.2552221-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 --- V11: - No changes V10: - No changes V9: - No changes V8: - No changes V7: - No changes V6: - No changes V5: - Added Andrew's R-b V4: - No changes V3: - Added RTNL assert 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 -- 2.44.0