Received: by 2002:ab2:6d45:0:b0:1fb:d597:ff75 with SMTP id d5csp326260lqr; Wed, 5 Jun 2024 07:16:29 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUTQov2woffdf2U22P0jBVYSX0sh5yB6oOcpLDQ6nJH/sDu0+VaxwPHGvkKZxQp2O7sB92HJINXmh+V0XViHyJ3aX2Tz+88igyqGZTdRQ== X-Google-Smtp-Source: AGHT+IEcS4GZZt9KCTXyZIT1Khx38GepHzWMGzCOjQsNivNiXRmxhm070d1m/gY2MBux49qk41Mi X-Received: by 2002:a17:902:6849:b0:1f6:521a:ba30 with SMTP id d9443c01a7336-1f6937d0751mr74605445ad.15.1717596988841; Wed, 05 Jun 2024 07:16:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717596988; cv=pass; d=google.com; s=arc-20160816; b=Zg6x73tXR6m1LEHhgKhub7zyjOVlK/46y3FV5TsRRHKEJug4e7fOmp1Ym4bcqRQoYf r2ywYdUd83e0ES/BlBzIihuZT/Bt+aoF4M3J7XndxcBPjxW1D58U0N419YJN/7yAQu0B KWC7fv/QCKL9i+jtdwqFfGLcW1SneWx4xrARqhY5RWDnjobVhPFMmmVWQo+ImMBtT74z seqMdG1ZxYw0tksVuY/7MQc9Uk4NuqATWyoEAQow7ZH7B1glzSfCgv7TA7bIvwPly2EZ Om1QoCzGNWwtAxjRmEPQ6f6EJEv2fT6FHyVU9E2eCLNA/+IwaEOdLyrO9G8tZhaz39Mr YHAg== 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=hKHdxKtz8gZyXuViAq6TQ0xR2LJFhg4ERBiqdd38b51vTi6g8PwDbvUrp5bsKteaoY FweVwlA7Dbzw1h466NTaLcL/XIXKUWfSfjH8PvHFlPPNR4QrCcAUhQZ2MFJFKxiUwyar B6CrRl2wyBm2W3bMPdUb3owgrmuhJ+iN/wSPL6Fw72EhvqlCmLT603wzD9aPmPWlvk6v S/xGA2pxQTVmMNTuav0j1Pq73U+ToZxfpjg2E9Qve0MK3/jPHfzXOzwd+M7oT8Yg9U8P vge0MfG2WgG4QlKYngczQQ5crljFi5fxsKbXJhE6m123wuutPqHNdEjNqzxgEUrox8qq O7og==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=oHTZm15d; 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-202646-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202646-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f6a50606e8si17971365ad.263.2024.06.05.07.16.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 07:16:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-202646-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=oHTZm15d; 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-202646-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202646-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id D7292B2D5EE for ; Wed, 5 Jun 2024 13:24:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DAE291AB8F5; Wed, 5 Jun 2024 12:49:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="oHTZm15d" Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) (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 0A3D11A3BDB; Wed, 5 Jun 2024 12:49:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.200 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717591775; cv=none; b=JHvsElXmaxA/IUWHNPeI1WUHusDoyzcL7a4mlwsT7mSI3d+fjuOZCPYrshmFRzZRvXqHmW+Zpjv+oxh3tVo0ebKVn2REmFW7J1UHr2FrRmXZKHeO3/rpodSsHE7EA96lC7NRzDZAdONKopDYykgNS24FTiw2j2C6xTpVQhK4Jfg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717591775; c=relaxed/simple; bh=T66fcYtzCtAtEweNYD/oA/QeJO8ERgYh0dPAiID+if8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=X8pZ7G+bIudAeU27ghz5YznCLnvug7nI2MXa6BQqRcKgf6ZIU1yG3I+0itxBg3xsn2MlELtW5mDELi3zkspDznnsgZTkUY+mDfO/Pw4X/aPyNhcwFxJh00T/HUsz2Z1kREN0hPl+VamK89lxu9bHqrV5AXMXYx9qVsnQDQ3q5MI= 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=oHTZm15d; arc=none smtp.client-ip=217.70.183.200 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 10C3420004; Wed, 5 Jun 2024 12:49:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1717591771; 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=oHTZm15dKLalleiYkta8eYyvtMu7EJDN7JAxhPJSgssoFBS8FigvjbLWL9B8Fs3tmd6H8f YDlopo0ABG4OQbjp9hXeQoOCA9Zgv3nt1TFyhinMfytpYOaqHbpNRD51+qTxm7Hanh/crA QcrbzaquEiV8W3HdTq6rW5eXnMYehSkA1OTsq1BCNlQl47uFXhhb5OkObtKWXsdqF1Ec/v q5dBnPRyNfpD0kIE589i6GeLWwo/W/Tqmm0wYWLcI3XLl2/fzN8u4ChUQKELqXI6um31CW hxUHsvi/aer7QYY8nyPZQDhvfgbsWo+KVrlcB3iGdFniv3d++1FDBELHI41MeQ== 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 v12 04/13] net: sfp: Add helper to return the SFP bus name Date: Wed, 5 Jun 2024 14:49:09 +0200 Message-ID: <20240605124920.720690-5-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240605124920.720690-1-maxime.chevallier@bootlin.com> References: <20240605124920.720690-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