From patchwork Fri Jan 26 18:38:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Chevallier X-Patchwork-Id: 192749 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2395:b0:106:343:edcb with SMTP id gw21csp75828dyb; Fri, 26 Jan 2024 10:44:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IFeNBUHCsiEHFle4hl113BvZL5miALkSSJOWMNS+o8Jmt0I0aQU/s/25buCU8Wa9AkcC+2g X-Received: by 2002:a17:902:64d0:b0:1d6:f5fe:75be with SMTP id y16-20020a17090264d000b001d6f5fe75bemr165991pli.33.1706294644634; Fri, 26 Jan 2024 10:44:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706294644; cv=pass; d=google.com; s=arc-20160816; b=vpMb1aXIdjvlmOqwupaCpujsWwxwG/QMw8zANDE6dsy3pjM7M0UTq0y2jtzn1Wi6Uq PAhQf0mh2WemxC7eRXl36B0O8ucGBT/Y1cvZ8XXO2sRgLqaM54WLP/hi6Ahxr0iN/YC+ tyJMATkBe5jmLv06I4dfDJBpLfvJUSEUOrGvGdNCHNuyXKiUxptD0cODc4TBAJOYFxm1 GSOdCVxkGrVjwJuki10sOVx4d/ZehqJ0MtBrB9MGUaF9kfc0xB0xNGQZSB2hD19SufY1 7DL17621kV1XOztNGMcZNvCraUJLAvYLDYrhTfEQlB23bnniSXmxb5+E39jQCD2TQMah AvlQ== 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=P54eW/CeSDVJ7dlNU+SzvMDXqz5aY5hZJ6KJCcDk9sY=; fh=d3Krop4IPE3x6nBOvh3GY5QHg6bS91zVnQiH59I3hyM=; b=l9S+ZcLobipCgJ2NI34hm/Y8A6JtKhWZfRweKgUvOFmRXQ458JTY+EH0JUk2yCZ9kI hvO7aTI/efO07keCrpb1sJ1Yxfs062HvoyVrtlEpqkSy+TZfBvs1+JIpAhvT4GgIR7kS pY555GIAGP9Crib3WwVjupTImTbk5SiYg6kcV6bRbEGgfznpl128bST8JUghCIkwXi+P 8Ds3hFgIc2Q33oVnYx/Ln5AIgYemgU6Nfl68Jf0taHynbLuVy45SxLiYbOGwPWGE43Kq daPLaupBjNQmE1h6IN/jlG+fUKbG+r9FWCzkPpeBLPVRQ6ChMV8GwxuOFHeUQHhagfj8 8nFA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=ZLgTohUK; 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-40509-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-40509-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id s17-20020a63ff51000000b005cf1b38c7cesi1528278pgk.732.2024.01.26.10.44.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 10:44:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-40509-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=ZLgTohUK; 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-40509-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-40509-ouuuleilei=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 2F0A42832C3 for ; Fri, 26 Jan 2024 18:42:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 39B6547A5F; Fri, 26 Jan 2024 18:39:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="ZLgTohUK" 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 8874B224D0; Fri, 26 Jan 2024 18:39:07 +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=1706294349; cv=none; b=pQ1iw7Umy2qUbDMuvVHxj2y+HDenOUX35rv9Sr3KqHgKSvFmP5ZH1VRzG8KcOajeB7TTrDtVJFdYNfuLIq+lnSauIQRLeEfzjT+Yx3TS0tBS0l4JydIrgQdwlEkz8c8x0KRAPInqHPr5sq0gJFkskMu/ndezQ303aQXoqBb/jnM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706294349; c=relaxed/simple; bh=9sicFgjEfTgbKhQ5RESFfDTIqvJBiZOTJa9CDj+KIF0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BH8cyhmSaHUnVJTLqdOSudkuy6jvQtREo0IhWaubD8aeMa2wtxFg7m3Ur/XYitNiBvSreX3hjjhMv62tv5BAGaErgjJLG/jKghHasIa6O0RVLOzy7V0rnmVxPnS/ajA5XGG1zQtHxrjShhoedxohLoSWtBGV8nE0Ac5NJl56Xo0= 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=ZLgTohUK; 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 Received: by mail.gandi.net (Postfix) with ESMTPSA id 114BCFF809; Fri, 26 Jan 2024 18:38:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1706294340; 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=P54eW/CeSDVJ7dlNU+SzvMDXqz5aY5hZJ6KJCcDk9sY=; b=ZLgTohUKbSgo3Fu79kGs9Ltzz/EIBzEiXfc2WDMtAK4gEOOISsq/jcA3ZwHoWBYcIogvwt PJB6Etc9iGI1J+MFygJTjNUFoP0Uiy3Ei0bjU5r0RZJyq9b9Q4mXjW4VcsFh2UReLg/0bL PVZdk8VyG+6dCf4DhG0nfitjYi6W+yFQGCJAtDYZJsWm1iHajAeEzOzh8g23Y/3yk1w6ZT sS2eT42nvESV4ln5qitYLVbozn5iM1F6MppLUdpXaU4d7FvkxXdL/wgUS+RYZYbw54lLNg dAw7NKyeE8F513KynjwaK9YukO6zlQXJ7xu/HLPoN/wMRsD/QSyAoaokE54w+Q== 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 , Jonathan Corbet , =?utf-8?q?Marek_Beh=C3=BAn?= , Piergiorgio Beruto , Oleksij Rempel , =?utf-8?q?Nicol=C3=B2_Veronese?= , Simon Horman Subject: [PATCH net-next v6 04/13] net: sfp: Add helper to return the SFP bus name Date: Fri, 26 Jan 2024 19:38:41 +0100 Message-ID: <20240126183851.2081418-5-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240126183851.2081418-1-maxime.chevallier@bootlin.com> References: <20240126183851.2081418-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 X-GND-Sasl: maxime.chevallier@bootlin.com X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789179613237902946 X-GMAIL-MSGID: 1789179613237902946 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 --- 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