From patchwork Mon Jul 1 13:17:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Chevallier X-Patchwork-Id: 13718058 X-Patchwork-Delegate: kuba@kernel.org Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) (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 5836315E5A2; Mon, 1 Jul 2024 13:18:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.199 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719839895; cv=none; b=RuLXfhQ+/34aOcnQt4hl7lVpe2JHk6/m75+7G7f3tb3JIPJ9T+fGUneALssx5GEVLQ0Uvqww4orT4tQqi8wOy45XccqTYcu5pdXBWcMHRYO6zypU6yaRa/SII+YiDCFD+0AM41FlMpZgBKnis90ttjbzmPonzMo21znzL8Oo96w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719839895; c=relaxed/simple; bh=hh1i+9dVZXUUJjTf6x+9miLPTLehfB1g2lO/UR8WrI0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fVowUM8yQKnayveu+KyXnpNY+MFhXr/5Dw/6T4VxFc/o6rvvn2EmG9A5Nv9FgrYp2mUyUFh7GM33IEpV93QOGWzH/W9EfkdKpIz7+YxTyl8Omn9O/YZxKQ6/ZWm1RK3JnPYAPoJc/vhYaoH/Dk9gV+Il1KbupCLOQsH0uSNEOIY= 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=lLE/ndvC; arc=none smtp.client-ip=217.70.183.199 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="lLE/ndvC" Received: by mail.gandi.net (Postfix) with ESMTPSA id 36784FF80B; Mon, 1 Jul 2024 13:18:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1719839891; 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=42HRyVnUZZ6yygw+Uuh45E3YKED+dxCVj6t2LrErm3Q=; b=lLE/ndvCrXOr4zkeIpAX15Vkr97rkirGAqZGUuyVRNdvsYHxwSDkDQkYZgapBv7k8nivpQ brBQ3iNP4yfkZgloit37sg8gq/8P3rH2csO4rf5Nt8R2MKTDM9K9OnHanYGvmyTzJTCpi/ 1RTJuURO0mwgNLR3zUGXSHSB5iUS++7vGI7Lyp/cZTL6pFodrmlBlH/Uoi36LYcPlmjsEl n0wXchDMz5rFGUEEn0xPPX9eGeWOVPwswGY6DMxZ6Rm30qfJpl+3e9PfjY8buZ0Yb5R3oN sr62uuKmKQ4713dH6vr8vWp4PsTOybZ9f1sh/unnzHx0eyRdRMd2J6gObPNKkg== 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_Maincent?= , Jesse Brandeburg , =?utf-8?q?Marek_Beh=C3=BAn?= , Piergiorgio Beruto , Oleksij Rempel , =?utf-8?q?Nicol=C3=B2_Veronese?= , Simon Horman , mwojtas@chromium.org, Nathan Chancellor , Antoine Tenart , Marc Kleine-Budde Subject: [PATCH net-next v14 04/13] net: sfp: Add helper to return the SFP bus name Date: Mon, 1 Jul 2024 15:17:50 +0200 Message-ID: <20240701131801.1227740-5-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240701131801.1227740-1-maxime.chevallier@bootlin.com> References: <20240701131801.1227740-1-maxime.chevallier@bootlin.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-Sasl: maxime.chevallier@bootlin.com X-Patchwork-Delegate: kuba@kernel.org 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 54abb4d22b2e..60c65cea74f6 100644 --- a/include/linux/sfp.h +++ b/include/linux/sfp.h @@ -576,6 +576,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, @@ -654,6 +655,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