Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp865863lqt; Fri, 7 Jun 2024 00:24:04 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVwsv/cKMcnaa4L0TTTQldJvleBYjWjSZAtusCbHM8TwsE7TqGm7ykyMwVhTyGZNnIA+a0L4W022saOX9aCrS5SN6k9pzLlaUWxm6TX4A== X-Google-Smtp-Source: AGHT+IFgLUrCtu/LaDi1KuFfROOe3s5AHtu1ltDBD/G+xn2YcvVs8xNd7XSS4ppVYwd4vvhn7gF3 X-Received: by 2002:a17:90b:1992:b0:2bd:f1d5:8e3f with SMTP id 98e67ed59e1d1-2c2bcc78723mr1556751a91.41.1717745043751; Fri, 07 Jun 2024 00:24:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717745043; cv=pass; d=google.com; s=arc-20160816; b=gXxvup5xvHsjTLPqvDDL/qMdmLhrEyzSDJiai1TdMMYJvHZ9PHyWtO2oz0td1E9pOB lWJhOIS33R2KH2DO4j7YWKGu3y+EQmD5prizC4FsLDbI4uCGY4g2Qs/DaYYu/Ul7KSPW 8DOogNJo7ZWUJAfoPGOXVUNIx6j5uILlpFYUIF4G402tnhrxDRNQV+bNQesUpRvYZvkK YG/FcQbhvM3M35/jM/AtFYWhFyCKMK6g/+YcOenjMlZc9V7VDlvyytImQBZGAAH4KL6l +mpnrT81ONNcfgoLpNjhPj6/mYQAYuhmn+y9b+VsFgfFQHRc7tuVbtGR3imCn9lQ4Byj y6Yw== 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=tpSJrMjUh9de5pwW08kqfCJLNjhMRh3Z5rUBLKmZw60=; fh=Dinp91LF2KcnzfyOXGg1vCezYXJAYX+8GKPCxLQjq1Q=; b=drB2vuR92fBK78quA+I3SfrfjbKSr1+R8wRgKABV0/ZYrhuz8DEQbsw1YxVhphfhga qASZufFx+e2FKEOEKBzc1/aatwxrK4hGSjbJz8ipbo+w84aEHySqYo7YxzdNYhRKsRmI ZZZuROBKdVK+NatNXpX2oZI++I3DxaJrMl5NNH27603u62acz4uFCglnW6gwouj0X+08 X88rA5fD8ZxuDEt56fHeAK0J0uGRPmLnzeGaw6jEd/KlfhMMbe4WG0TWW3KCrw9CYFWj WS7VGAs+SXW9F90TUvDQn4kTZWg22+l3sGWzyK9HBN7SRceMK8QTZs7QfS90poi+xPbj kDSg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=UU+h6Oas; 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-205508-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-205508-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 98e67ed59e1d1-2c29c2189afsi97058a91.71.2024.06.07.00.24.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 00:24:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-205508-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=UU+h6Oas; 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-205508-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-205508-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 A2386288E39 for ; Fri, 7 Jun 2024 07:20:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D96391553B4; Fri, 7 Jun 2024 07:18:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="UU+h6Oas" 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 09031154C11; Fri, 7 Jun 2024 07:18:52 +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=1717744735; cv=none; b=ph4Ydr4mRKGloujEpxeNbr06S0lIQrtJGbPpJFjQmiFhXMmt9D60mAK+H5CnMzhj2AObCP6LTZJ34Rdj5ooYuEfiTRh8QHJjDPYyYxvTQwGQ0vALWTflwINP+ZeOMF9LcgPftpXH8hmZdVt7OG2BiCfjS1y4u0R8oTADzTNzCdk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717744735; c=relaxed/simple; bh=T66fcYtzCtAtEweNYD/oA/QeJO8ERgYh0dPAiID+if8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ryb2Bw96H8w1iD9N3pD8ys/FR0HUYyD03DIeAENYGxX5wdfG2IeuV4HWroL5haxjCXbMh6iJh067IstKHBQ4pD2u7FqlY+R+gxkvGH/dTa0soJA7KEhaqQq86eFdeYQB9t2XlLGBk7gvQI+UWxb3KvtOSXCMFW38p5lxuc1GXAM= 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=UU+h6Oas; 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 5D3F91BF206; Fri, 7 Jun 2024 07:18:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1717744731; 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=tpSJrMjUh9de5pwW08kqfCJLNjhMRh3Z5rUBLKmZw60=; b=UU+h6Oasw090Udn/0AUSfBNHxPmh5y5qJMQ7TlFbUK2+XqZLTdTOzUyMrKWrfw7vryvhVr vdWJTjEJ0/Yp8D+f6IGy87LfRXc+8+H5hH1UdSJaO8fawEDFyx9iMlm8+2dNgogNa9IEj6 rghBQGgCFYPW1cvhtgEv3B0MWix+AEYrfbLMvfJ5QGojSErAriHwRuEsJHxIZceaY9V3zO /ux2W9sgD9fQKV7st1CCV6B5GH0BrOAChV5eeIhvgNifFZJu/aFOJjDwYs59YBFwPumfx3 hMyVIGcsW3JEj5gO5ujOPTTs3U1/wHX13eTOKUBJQ8weaSvM3EeUl4YZ0SEpLA== 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 , =?UTF-8?q?Marek=20Beh=C3=BAn?= , Piergiorgio Beruto , Oleksij Rempel , =?UTF-8?q?Nicol=C3=B2=20Veronese?= , Simon Horman , mwojtas@chromium.org, Nathan Chancellor , Antoine Tenart Subject: [PATCH net-next v13 04/13] net: sfp: Add helper to return the SFP bus name Date: Fri, 7 Jun 2024 09:18:17 +0200 Message-ID: <20240607071836.911403-5-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240607071836.911403-1-maxime.chevallier@bootlin.com> References: <20240607071836.911403-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 --- 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 0de85cadfa7c..5ebc57f78c95 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.45.1