Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp603648rdb; Fri, 17 Nov 2023 07:40:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IFa4/rMsl8J141LA7Pt9HCNBjxYyMCQk9SuSeyDQtGErmltaSJolxWbWsH0j7UKU+iHs/HI X-Received: by 2002:a17:903:444:b0:1cc:ee07:1659 with SMTP id iw4-20020a170903044400b001ccee071659mr12348419plb.46.1700235646834; Fri, 17 Nov 2023 07:40:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700235646; cv=none; d=google.com; s=arc-20160816; b=iQ6aSyqVP3FtGnVuqcWKABZ/8BPxWZatAf6GlUmfggk1BCeSiEtdJOlptNxOyVXdfJ T0gMtauTPBw9k49hQ7I8lmVCZY0UVuST276b0nN0pZoN8SPtjHG649tBVl7eUWnXr165 cmZ0YQUX81CqqgvZ1fLRcFrG8W0pIRUM4jtdIemTygPGVbwgr1n4SkimN/QAK3bRG5AW vrdSOkBV3y3TjyFYDWsBc3WwKm56QXet2Zik+MIEBcAEsdhresi/BDFRb6YbzgN5HLcV xf3ZY/oBYvjIwLC6T6hgMMLR5bXRlncWlU+dNbXGFu4PhN1zjqKr/okTBkb7HHrNEF6n bj5g== 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=rRo/pQcZejgRnemKP4uNQxIXQrj56PAQ2aabjMSpgaA=; fh=1WRQxG55ASsvt/9NxVDhUbJ1aQecLyVglFoTAx66NyA=; b=RFCx1k5o5W+cbp7bAexPVKefad1SN/MexW9eloweQ2UAtPt31vjXEHTPRv0Y0/N1vm Sfzn88T7+WUce5rrPxOE7FFqQr760Aooi7zuGETvvmjyb068KLLd73puyTfzcCRQdAfn r5xX6OPH3eksc7oU5v+JeTSg7Apt69FeWVH4P7/MhIiF0dU+khRc6+DhSHx3dw5JtLSc edQsakxay2qkxMOYKMUDLqDYFD+K94H/CSmALKlqUDia5F8DHJVNCBNLCvrUbsSUVm6Y OPfyGmUAbbex0EqYf1iThD9+gix43kRVSvITxosO6JB8tH5v6UFO/D352SeE2Ovf1QCF jX3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=GnhtVcTe; 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 q13-20020a170902dacd00b001ce5f67cfb6si1404568plx.226.2023.11.17.07.40.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 07:40:46 -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=GnhtVcTe; 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 2A710827DFB1; Fri, 17 Nov 2023 07:40:45 -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 S1346064AbjKQPkf (ORCPT + 99 others); Fri, 17 Nov 2023 10:40:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232348AbjKQPk0 (ORCPT ); Fri, 17 Nov 2023 10:40:26 -0500 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92F0910D0; Fri, 17 Nov 2023 07:40:22 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 703451BF211; Fri, 17 Nov 2023 15:40:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1700235621; 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=rRo/pQcZejgRnemKP4uNQxIXQrj56PAQ2aabjMSpgaA=; b=GnhtVcTeeFqGMaAcovX1o3xPo/YAWPfzDS9rVjV7Qcv7xceupy2l5m9E9wXuXb7XB5Nbqz 9zCF+d6vMutig1CM32SZHX3qyFliuI6TSuSU+pVWZVgWEDI2/xoi/oGMO2ns7Di2vVjdUp y6t7kSCWp9Q1M4UefMNzQedp5vrtRrNdRCkEo5wxqU1U6X+Sy7e85y9hux490ttCcCXLpG 6NC5rfPOPYZl4fRe3x/wQQlvnYJsRyS3kEb01suvfauDbSsc++V14l7qEBBDf5KOphcIc3 UnwYdnCOszVKHAyRhxu0SZuYFlAdxgAlo5T1buzTI9GnQyxqzj3tQZQo/5vj2g== 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 Subject: [RFC PATCH net-next v2 04/10] net: sfp: Add helper to return the SFP bus name Date: Fri, 17 Nov 2023 17:23:15 +0100 Message-ID: <20231117162323.626979-5-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231117162323.626979-1-maxime.chevallier@bootlin.com> References: <20231117162323.626979-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_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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, 17 Nov 2023 07:40:45 -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 --- drivers/net/phy/sfp-bus.c | 9 +++++++++ include/linux/sfp.h | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/drivers/net/phy/sfp-bus.c b/drivers/net/phy/sfp-bus.c index f42e9a082935..835fb2271b12 100644 --- a/drivers/net/phy/sfp-bus.c +++ b/drivers/net/phy/sfp-bus.c @@ -859,3 +859,12 @@ 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) +{ + 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..96f7644908bd 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 const char *sfp_get_name(struct sfp_bus *bus) +{ + return NULL; +} #endif #endif -- 2.41.0