Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp1167807rdb; Fri, 1 Dec 2023 08:37:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IFCyLQovPZhU11h/mdIbKpyz2FGq1nYJlBNh8zG8zNS3o1di71hcCE+traEJpxrW9d0JqSq X-Received: by 2002:a05:6a21:192:b0:18b:5b7e:6b9 with SMTP id le18-20020a056a21019200b0018b5b7e06b9mr35170742pzb.2.1701448655607; Fri, 01 Dec 2023 08:37:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701448655; cv=none; d=google.com; s=arc-20160816; b=FxUQdi7BHx5ZBaDrl16UZxRXLASxZ3fWP3uWD9nYe+kBCra3SFOG6AejWEjDpxIGjg xu2E1k3s7e/A+MX18G70Umrca3ndqO4r/prGwYmYYXRvdVQ85czfShz1vbGRyyeZf63y 2wN3y8bL8i4go8V5t14WRI3+inLLGF3kjVW8llYJnJt83RFqpuKzCklWO+c/YURQOML2 YocBHyc17YciDZKsMj0gJNVuYxR7QPobyIxJsewc3AHzrPoz/0pMIEGsc7yOOOXuqc77 ISNaoDfxWAKMEBYd5Ek7ihZ2RXyisSnVrKFN4uqvxYd0U3UhyHZu1Mic3GzN8DwX96sf xdyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/UJgbGqCn4KZ8wgN6ydYKFmmc8NcXDI2Sqt+FJcDgT4=; fh=01/i7K9ues3Vkkz8uyECvnCPITXmGs/30yOh5FbyFgY=; b=gNN+TSVXhq9syuCdU5colRBAPentOH4rQ0aAT9GqOh4lBzLpMQ+x6YIvDom/2piSfB WukCo6r71fDL1gFWvf5mjyUcAAurbzfEfTKlTREWIYTU6//9Rg3YsYIqa6pbrlAmfiOp BviqsRO8idV7mKoPH/YWAuIqoq1ARBelVd0jqSHwDY7cydTs5qxPUIE9W8zqsXbCm6Xt ZDDs97NP26CVHqrVvDk5xuSZDi36D6nZrN6/dXuNnuOOkNFcVKhPR+7+zPt4Acb/R+ZO 35AgQCC0cUPHRGcfPmfGHht+GtVomuSXN6NUe31Ut01DnWCkxfzRAreHkH3EyGztyufc zXag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=LSXijdMo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id d24-20020a63d718000000b005be1ee5b99fsi3508266pgg.526.2023.12.01.08.37.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 08:37:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=LSXijdMo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 117D6811F13E; Fri, 1 Dec 2023 08:37:34 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378524AbjLAQhS (ORCPT + 99 others); Fri, 1 Dec 2023 11:37:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229539AbjLAQhJ (ORCPT ); Fri, 1 Dec 2023 11:37:09 -0500 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3999EDD; Fri, 1 Dec 2023 08:37:15 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 4067FC000B; Fri, 1 Dec 2023 16:37:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1701448634; 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=/UJgbGqCn4KZ8wgN6ydYKFmmc8NcXDI2Sqt+FJcDgT4=; b=LSXijdMo86F0stdaNqeqqp6yLoIB8nLvjr9ivnTXr0FSEQW2siVYiwb489yXvByvKj+P7X fA1qjbluaAS1Q0aAJCZKsUuMW9cpLne5hIrVCT9Nvp3X4zwp80n/t0G5mSfWfOOoJbKPO2 Qz5WPtXxc9Q+OWyb2YXKNPY2rP7V6MgAnQszNazXYWIDuQ5lq21L2AJzUiKrpucgJ+xBRz XObRKwYhXS52P2MhIWZFjUVJBeRw+r7PHcGpZ15+gcCxrzzk/zuFUB1zsPZVdwBIq1tU5R R0jbni+eCAAb333yyIoXCxIvp3E1KWL8Ki0IUwN7DhabTvnMdxBbPYFSZlZVnw== 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?= Subject: [RFC PATCH net-next v3 04/13] net: sfp: Add helper to return the SFP bus name Date: Fri, 1 Dec 2023 17:36:54 +0100 Message-ID: <20231201163704.1306431-5-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231201163704.1306431-1-maxime.chevallier@bootlin.com> References: <20231201163704.1306431-1-maxime.chevallier@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-GND-Sasl: maxime.chevallier@bootlin.com X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 01 Dec 2023 08:37:34 -0800 (PST) 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 --- 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 3a86c41e1235..fb1c102714b5 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.42.0