Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp3108601rdb; Tue, 13 Feb 2024 07:10:13 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWheclLZuyZFQwfC7jTbyBpVmtGKiowKSe/09JJc1t50ai8ecxMOF72ENL/mT80g0dUkC0Zue4TIhyXEDx9npcA8oT+q2NibTrGvU3igA== X-Google-Smtp-Source: AGHT+IG1sIEA1BkWSHBU2pEbqqJjdWb4hVGtg+mIwl+sLNOSf7T3slnIXyCx7LTZ7r18ciMOjey+ X-Received: by 2002:a05:622a:60e:b0:42c:3e7b:a1f1 with SMTP id z14-20020a05622a060e00b0042c3e7ba1f1mr10440827qta.4.1707837013245; Tue, 13 Feb 2024 07:10:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707837013; cv=pass; d=google.com; s=arc-20160816; b=iehI9hp5njD14J8AZFDlRjLrwcHL3a5JEsJStq3TzFRml2aAPbFFfFGJRYODaaX1XC TMW2UjuapQoo/AhqpdxgB093a8GgZ+WOsk+f35b79ZD7s2KH3ayBVqqmqlPYdH/0Ef+H JosPZIVDObuqCJ11A/JesBZWLIRKUsfmMS+X7/b829a8grKBrmO/kJbekTXZSZZEoxeT +G/rnz8uk7uFCRLgHNOAd5OgYXRqbi41BONS8CapKlJfD+KpZYui1GuFCGljJiLNKQif YliDla1wPccyHi446CV1oIaTG0p96MbjJPObFRIARJZUiC/ZoWQHftBHGafYNM6gnS0U pkzw== 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=KTmhC9GjYAsePibiU7IujsC7f4CZ9RTCQLK3qNI1ORI=; fh=vH/EgqF+jVHGZ9s62IbObjqcpf4vCluO/8JNt+K+Gvg=; b=RPEgvbIcj0ZmxxYBqs1OMOxK49Wya9cT0smHmfbplOQV+b/JeQaZZ1SLia/RjiDQGg Z+YVsHGAtowWVTF4C3VYVn9ODh78aWpIh1J8m+kb3U1etboJK2K0I/6lYx5+PVQP2w/I I9x2+Bd7MS4f2EYHO28P/h1B6KSr9nxFSKbLIiJ7ePkVjCd++zXz+GGbjYAmZ+MHlvy6 lNN30RsyZ9GXO0ZgpmvQnzidK+piJ1EW0X+R62/unbU1ZzB8QTYfFW+GC+mCbMT0PUGm wK0aw1yWVOm0t3X9Hw8zwEZiHgEVRZVXfwhbRVAUgwQ1fikBiISHYNtV9ak2MRyYotD5 ZQeA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=emmeAh0K; 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-63769-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63769-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com X-Forwarded-Encrypted: i=2; AJvYcCVOjR6ZoWyjqdhKK3hC1DO3Pg2C2jCvDpr4069VQpm8qfbFIcWDlQQOw/ngmda43oXUClLxXkgbWvyrfg1xD7ULRnmPrIW6hGvY4rHlsQ== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id m17-20020a05620a291100b007871dbf90d8si1426048qkp.266.2024.02.13.07.10.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 07:10:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-63769-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=emmeAh0K; 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-63769-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63769-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 155F71C2857E for ; Tue, 13 Feb 2024 15:07:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 12549604BD; Tue, 13 Feb 2024 15:04:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="emmeAh0K" Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (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 05C385EE9B; Tue, 13 Feb 2024 15:04:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707836686; cv=none; b=mfXqMqy9cPeUzgU4qjAc4OClR5HKuTA6t40TFnPKu4G0jPe+Wg76vJ8uU0oAiv3/uLGHZgcDuAERnpEk5rlkaYb8q7gA0bLHH4D4PiHEkRNWycCSFBkfHGM/8OHhaJkodtyJJHTSH9JD6lKVMBAKjW8K5GHcDmPx6hTFOKLlgAs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707836686; c=relaxed/simple; bh=tyo+KC7pg/1rkjnwq9wNNL45hWJwDIjFK1Gq4wwdE0k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fiJjj0bMrSKlAVg/tsHqBp+h12LzFq4XlG3hoFSqo1n8Lc9QxQTyPAnJAlBEV1AA3SiiV3MjfnB+eCrtAZZCxSVgtMT/sCb0DyIwhCVN6mgO3cS957+sDOOLw+uriLKeJR0A3SMnDnMWOvam0sMFFfjGoQjYAyVmpXME+0nV/0s= 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=emmeAh0K; arc=none smtp.client-ip=217.70.183.201 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 1763E1BF208; Tue, 13 Feb 2024 15:04:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1707836682; 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=KTmhC9GjYAsePibiU7IujsC7f4CZ9RTCQLK3qNI1ORI=; b=emmeAh0KnbtvoWUOHUpDn4bsEHHOTy1L69fszsWqCBAjwx6IaxAeVvY2uFVcTikrZGiZiw b6sN6Il3Nfa9tYHQdJD+To12xliNdlgCcgaCyIauoCpCKG0V079fLtAi3eAC37yf+a+ATB lmuWtVP7RoevX8WNl1W7VBHODztLWHCnXAXimx2r9r28lIocrn8Ruxrgl5ngzc54BgQu1Q RiM90Qci4kFS1DjkybbEy0Y2LGldnis9sedvClZoY+CBOiSSqSJJ40XNlwI+9uH/TjnJN2 MhJxb5o6DqZMp9EaGvMxKbWX//9u82ewmMFoowbDnOBFZGiuQf1Hom2OC/y80Q== 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 v7 04/13] net: sfp: Add helper to return the SFP bus name Date: Tue, 13 Feb 2024 16:04:21 +0100 Message-ID: <20240213150431.1796171-5-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240213150431.1796171-1-maxime.chevallier@bootlin.com> References: <20240213150431.1796171-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 --- V7: - No changes 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 -- 2.43.0