Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2496645rbb; Wed, 28 Feb 2024 03:55:53 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXW14h3U0aiNBs8b8lGMSoknece5nGJcka6g17qjnchwaherUtaskrPxPlWujHRqXyuQJWr7lC7vDgypRrOGhDBx0ayUwGWNusnq3EgIQ== X-Google-Smtp-Source: AGHT+IH7DP7csFJxDI1vRKyzNHC822GoIEY1gbtMR42n/AYVXm2K9Dz0B0QZMJq9kqQtj07Xa+32 X-Received: by 2002:a17:902:a387:b0:1db:cf57:7bb5 with SMTP id x7-20020a170902a38700b001dbcf577bb5mr2514000pla.8.1709121352960; Wed, 28 Feb 2024 03:55:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709121352; cv=pass; d=google.com; s=arc-20160816; b=IoONFcPe5N+JQWn+fZqMz1QYjYS5c3RRH4zVrwQNU9p46FbeqJtU0aLftIOH9B03LR UVdNJrzPZmLrXGXebVCT0NRY410JOA63PYzFW+zfV0znaySJB3kelN2SQyk90t1zLSQ1 DRyvxKVsLzI/Ii7k0SrofCeM+dmaBeocBgUmCtwnta/tM8B+8OqPIWyRyDb/AVUBh1qS xNvN/uabuzEsJHic3HONuyWsoZ92SwbIOQ6K2Ye91nZfKIlOEWCW2ZwnBs8lbbcg0gMq N/GisprY+C9jDJpj95h7X5OdC/eV4eSs9pOyBsj/S7O7s18AIrQMyAhD7s7HZvtWWPJN XSjQ== 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=3MXNsYf4aMbx/yz5fFqHi9DQsFD4zYWoE+WdbvkPVrE=; fh=1vUu/d1GTjraph6G+ET+Z0z13QVrf6oL/IrrK9zaTF8=; b=Hj8VJLUEHQaVYFFaXQNdR+gpZS7nuhNctGOaLjaCY78CTfKFtuJVzwO/6g2AlFxiQf /h2MX6ge9IH380hRvv6ezJh4yCHEEvv80IfSI1qenOU53UGEuGJnT2qnmNUHCzTnCI8v 7g0y7pooCFMNOvO7DKSYWMXX1XdnHqWp0RhKbBKCktwtaB9EH+ByWMbIMH410ipZ8pdQ RyKnM2gDTL9ptVgZGQt80VBB1LcITqRuHd63ZUs3G8kWPMJmZive7ymemV+2P02Xrv1s JeVUXfwdvwgHA1kG0AyGPFy/IFDokBkNmQnRhMJu9mkF8FAs1FsJK3wSXpZRDKwytzM7 cX+Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=mRqx88Xe; 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-84949-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84949-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. [139.178.88.99]) by mx.google.com with ESMTPS id me16-20020a170902fc5000b001dca62297afsi3263461plb.6.2024.02.28.03.55.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 03:55:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-84949-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=mRqx88Xe; 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-84949-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84949-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 5035F294500 for ; Wed, 28 Feb 2024 11:49:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 72AF31369AB; Wed, 28 Feb 2024 11:47:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="mRqx88Xe" 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 2969E3BBD7; Wed, 28 Feb 2024 11:47:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.197 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709120868; cv=none; b=BoTf/dgUBHm4pWzzfzt3PZOawrtkqtt3NqJdPqSdtS3lu38TlFSq+T+XQwgOXzzFoJQBoKlze+RAYU8CCeRxPaJtWMtQX0xAxbuMfvGIfB088d/ljXfUbcNar+qdoX5/UIfz/jB0yPEe+Of2rZTMzkVq6FTLw0BksXOfzYr29CU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709120868; c=relaxed/simple; bh=u3jKa9Wj8sA1q9aeurSLRH2PPRXCRnJJC4I68PdJRnw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FgcmYR23XaLT2NWuaad7wajcb/JqTZpxneC5GDcTgsviD7vElsYJibfgs0doXX6FfXD4o4ehKofHe0CYx4tfFU84ltx1BW6Ac46WEzeTBRKq/+e7R/tK2ZLqo9POmQJNULgiqkw3Sfoks5VyQxs6QozOOTlEm9eaGvF+UVKnRJ0= 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=mRqx88Xe; arc=none smtp.client-ip=217.70.183.197 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 5EF631C000E; Wed, 28 Feb 2024 11:47:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1709120859; 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=3MXNsYf4aMbx/yz5fFqHi9DQsFD4zYWoE+WdbvkPVrE=; b=mRqx88XegkxLGBxCS0XXZrA73LF1qNcwWzpZHAYiPfL/KwqrhA+id2Kv4xsHqyLmjMdFsO 4imQvWVt5lePLZD/QfyJ3u4adtMUKfTyDBKe0+Ds8wCjzY5VUom01x4asXY6XEbsMAn8bx hyNE8qCw8qRug5cTpJKkJJCLabx9KOVDDqOcBSddoJ7nZKDoSM8DxxbpVPyckBRAiU8Pzo TsfOCQeQ8BpXfjsk0jqFOWoPosifv+pw1EFzVEFofWDbUiuPdK7d8h7sALR17xesPRuZiY XISEwkW4hUbE63nVfaSk+wh3gH7kS8sCuCcrfn23sw4f6nQfVByK6SAgKF6m+g== 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 v9 04/13] net: sfp: Add helper to return the SFP bus name Date: Wed, 28 Feb 2024 12:47:18 +0100 Message-ID: <20240228114728.51861-5-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240228114728.51861-1-maxime.chevallier@bootlin.com> References: <20240228114728.51861-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 --- 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.43.2