Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1916948rdb; Tue, 20 Feb 2024 10:43:27 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXdsPAtRmIIXrm7DuIMtRihKrpMf0y/R8QnsW4C+dPyMZ8L86oFolXTx4lJER8KXQrlPEHW2M02JhWSBQboaOGjp+awyshOIjAnxMVG0w== X-Google-Smtp-Source: AGHT+IG6qyFyEEeNqVFmwZA3l7LLfpIvSPmgwqVv4DPK1k4Puptm4fHk1QiZxbxbJ6F+o6upzSyo X-Received: by 2002:ad4:5c49:0:b0:68f:8234:bb27 with SMTP id a9-20020ad45c49000000b0068f8234bb27mr5822037qva.26.1708454607473; Tue, 20 Feb 2024 10:43:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708454607; cv=pass; d=google.com; s=arc-20160816; b=Dv5XLOAw0p0IZmOO08RAJH9ctWBONe0XEZpJBPcFYX/Tix/GzbHA9TFCG7ALguKmbZ fjicL88gTvxe/ApbAI2B6V7mev2SXgKV0ti1BrGltBzqCZCeaFZ9zR0mCRf34dVtLjE/ uJuufUgeS/QBFf0JmMtdc3One3tdsZXlp+K/CCMhxo2/hpvmEPsIfTYKaBOHMWXqW+L1 0UAcazYAbvakl0WQdPuHINR+OAj22SlL7P4YC/mK6noO4UKDC12RcEso4LpxTfPogrf3 dVTMh5TOBXXprRfqgWBHbAZghY0tNhTTAiH/O8a8E91qF0CuWbUUV5k7hnhpH9LZKh4x iBaw== 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=3aN+Do2Vm+gV4n5drRYBltMQr5b0yzMBmZzBYY1BSHQ=; fh=1vUu/d1GTjraph6G+ET+Z0z13QVrf6oL/IrrK9zaTF8=; b=UcOxCpp8Zd1azqE5/s8fLRl38elHIGULURaMAf/nTzT0vxpYx7R21IGlgVJnGvPjhC y6bdaKw8A68Xes2L47u11fFWNIXKzvRJlE7kvRgJWWDaxu6A3WMVJ2KkcngI5eZLTwRF ipyO1SQOBJus8daJj7gX8aGDMJXXKXllKXBFcMFCvYv4qThJPahzU8Vw5kbsyzgs3QkJ 8Kbo/FUNCVOmIzKH8ga8gmFSjJOIWPICmxinHUntVQHJLuU2SA4hTzSfauS41r9R0buk CtATRr7jUgjva4aTMUAbDPnVr4S06zftkcue7yJacJPLuxH8kKJpubxRzagXpzL7Gdrc BEKQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=CQaKaP65; 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-73529-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73529-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id jl6-20020ad45e86000000b006846c97c980si9494148qvb.579.2024.02.20.10.43.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 10:43:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-73529-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=CQaKaP65; 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-73529-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73529-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 3F7C01C2240A for ; Tue, 20 Feb 2024 18:43:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 98D4514A4E7; Tue, 20 Feb 2024 18:42:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="CQaKaP65" Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) (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 8094A13342A; Tue, 20 Feb 2024 18:42:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.195 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708454551; cv=none; b=K6DDnlrnV8MLZXRdv6c+go4YF4yqWlmUkk+ivt/ZUC5q8yP+L6/hvO10k+vqVS318wEW1r/Txr+vxHIb1lZAIOt+qqfs+IIwMBCbJi65/21ewgIdhzDiamV6703Qmff6vURDxuXDnhFhx9cnNYYXomzwb2L62Wdu7jltZfWmfQw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708454551; c=relaxed/simple; bh=N7zX1b9QujjnwAyXWeCiTGbJkCf6zWTLACTR9p9HYkU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lllAM2X+H+1pGq51e0LJXBnxfFdzaG+gbqRwdg0Oh06AKpODe1iAGtMGmVM9XakoteQYuOT/3goW7OQHeUA/eMN5V9AftZf3DjNO8KR1mcS8n2NHQFd0fz/H93N4bf4GAhz6vXSojh+bmnACM1wMVPLMqsZLEIW4nZKqAKBTQaU= 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=CQaKaP65; arc=none smtp.client-ip=217.70.183.195 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 B1A746000C; Tue, 20 Feb 2024 18:42:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1708454547; 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=3aN+Do2Vm+gV4n5drRYBltMQr5b0yzMBmZzBYY1BSHQ=; b=CQaKaP65P5yp/NONqWPtkjATjMaSfrnTS+2jUouAx7CmbZMkW40FmRqr483l9skOD+xKV4 q/XUWgahrkwiZoCx3PjRV1We0cH3G/xQ4X3kq+W2cuLMnpsNFrQYljSIpalii7iaKkUTvf X4m1BHBJ3poWjfudfaCX5lhy4hWjX9se98EFPZz+tVK1yBrE1d6eZqm4muOEqN11mG6pJP orBNk2zsuXNj8ZttouDL6pHUTOXH8Hc60nTuGp5bTUhQ0Uw5YWDcTr6S4RLBpE36qCe1SM Zg5SlIwSuGxWqGGhlwZz0xhGOa2pWbq3x+VgMVq95e2k4T0SyUHk4FoZ8tx4GQ== 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 v8 04/13] net: sfp: Add helper to return the SFP bus name Date: Tue, 20 Feb 2024 19:42:07 +0100 Message-ID: <20240220184217.3689988-5-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240220184217.3689988-1-maxime.chevallier@bootlin.com> References: <20240220184217.3689988-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 --- V8: - No changes V7: - No changes V6: - No changes V5: - Added Andrew's R-b V4: - No changes 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 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