Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1346698lqa; Mon, 29 Apr 2024 06:14:52 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXgu0XgXYbhB+6A1EtCO29STThQScsB30OWnAT1J0aJ/dnNajbmw2tF59eQyWIS57sxcHaobhCHvxw7/GpLNpYDg1uW32BiatJOnFxiBw== X-Google-Smtp-Source: AGHT+IG3Aa4Qrr34f0XXjSh/TbTe+Jgl8Vo1kRtI3iM2aQmOogKeygk6l3boQSf6gMJ/zEO65ePp X-Received: by 2002:ad4:5dc8:0:b0:6a0:c8ac:de5 with SMTP id m8-20020ad45dc8000000b006a0c8ac0de5mr4166730qvh.32.1714396492106; Mon, 29 Apr 2024 06:14:52 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714396492; cv=pass; d=google.com; s=arc-20160816; b=lcwmRvdIHK2NpliC2vxK3KNvV5bcPDGV0X87owmcJLZGSArCTTVx8uj9+vQtQXHrht FI0WzIh/jYFxxBjlUsP43iGwIe3P8fgmqsFS1WcNamUgSKZwclWLUV2NxRqjIF7BvvcA JgZCVgPjmm7COy+Og2SF+Oxcedg+DpLQ+TfO6edm6uV9BKpcpECznG7ii60yBiNhC4M6 rskElRvWFgK/KBEVnHaMqb7EXYrAYKD70OnI3BsAkmWj5saYHhPiey52VTg+cU0g2Cmm WvKjGwJyGo0FbqYt/gLxhAauf5QuDQQsYZo5JuJd3Xq3fAjeVYsy1itoWnitbwhGgkvY KElQ== 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:message-id:date:subject:cc:to :from:dkim-signature; bh=c2nY9oW5/iUT6Zx2N63VDP2nYCyfzTT6a6pD8hndgb8=; fh=Dinp91LF2KcnzfyOXGg1vCezYXJAYX+8GKPCxLQjq1Q=; b=YFg2uGtD717fnZU2wuxetjOISSjK1fd77dkMCFUsd0H8kXhkxZjkjS+u9SVg6CfOdz v9VL584ogjWaxBSWMV+7HZmtniQeixbadvhIyum5ijobCukNnw4xZt55IsaUEjkQY7TX DyJZS8ZjhYyo1wiO+VOHUK0jbt7mLOLt8C+hKMiC5rla3WWsYynipNWbJDCNlcJGWlZk 3AWJ7Wt3MFiW3pGuRcOYpoZDpZvsackxOeiZ2oEQxmXhgXocAaLbgl1nI8AAagLi+Opd c7vg6ceTm3+zb6z332Vdp3XmvLnqs/suAP1u3ACUVsAUM3HydKd7vmysJSgq6CfWZnur wGYg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=G9OxHGn6; 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-162337-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162337-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. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id if11-20020a0562141c4b00b006a047176b50si27005164qvb.388.2024.04.29.06.14.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 06:14:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-162337-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=G9OxHGn6; 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-162337-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162337-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 2DB4A1C237BF for ; Mon, 29 Apr 2024 13:12:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 553DF70CCB; Mon, 29 Apr 2024 13:10:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="G9OxHGn6" Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) (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 7EAA9C2C6; Mon, 29 Apr 2024 13:10:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.193 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714396220; cv=none; b=IYLsTqkSe9Ur1sIp5fdDSXCTd7Auxns2nkTjs3VlXmsE87hJpltKYwDEMzY2cEnd3k01TCCvzI2y7e7v/1P+1HFtdWXir4cLW5GH3nAI9mPIW5/qHf7erlFW8i7D/gGj5A24QV9xNDTss3ucJAQWb+kuJdXxqViGNEfHVoF9Qhw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714396220; c=relaxed/simple; bh=l2ypQGYvXw8D2rq+W/qtidSrfjuL+50QzlaZg2ZjPhU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=k8qSc157Z6lVn97rzYab2V9tsno4IOyns8YF9ujrWBXEo1vF9LrQ49e1Gkp/33VVeQfRPmmwQXWEaqhe3J7BZQt0IIte6V5C+63tnq3H0NEGrvVCcPhx0/cJLCR80BdlbPkprz6wCG5Vh1xVwxXjpWqrohPpiwLTs60HcY2fRZo= 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=G9OxHGn6; arc=none smtp.client-ip=217.70.183.193 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 CA48D240004; Mon, 29 Apr 2024 13:10:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1714396214; 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; bh=c2nY9oW5/iUT6Zx2N63VDP2nYCyfzTT6a6pD8hndgb8=; b=G9OxHGn6e5kmPlbyzBHCQ+YkrA8iFhVI7DgJ4gnbkO81DdHTf4Uhn3awWQ9rcMdpE/NY/A 8+cTE81yeNqg9MHep3OY4Xu9J1bLoFi2NKS0It1lA7TsGPVSDtCP6PGoHadhmeStFzGntm ogVXGm/jMXXqJ0xpj6I4B3XI5W7KtMmo+YE03uKdqloA9vtNuYypXJmkWmdExhIcJhJ7M8 ESVccH7WSn/bFzoQuyilX1S4T0QY4aI6jS/Q7ehFE2soYTaJ2FtsU8How2FCdFEHEbrY2O UXeYT8ZlllNsefzIubBl6RD0jb9Xd76CmXp0J412ZYzNXV3Mqy23UpNQUMe0TQ== 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 , =?UTF-8?q?Marek=20Beh=C3=BAn?= , Piergiorgio Beruto , Oleksij Rempel , =?UTF-8?q?Nicol=C3=B2=20Veronese?= , Simon Horman , mwojtas@chromium.org, Nathan Chancellor , Antoine Tenart Subject: [PATCH net-next] net: phy: Don't conditionally compile the phy_link_topology creation Date: Mon, 29 Apr 2024 15:10:07 +0200 Message-ID: <20240429131008.439231-1-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.44.0 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 The core of the phy_link_topology isn't directly tied to phylib, and at the moment it's initialized, phylib might not be loaded yet. Move the initialization of the topology to the phy_link_topology_core header, which contains the bare minimum so that we can initialize it at netdev creation. Signed-off-by: Maxime Chevallier Closes: https://lore.kernel.org/netdev/2e11b89d-100f-49e7-9c9a-834cc0b82f97@gmail.com/ Closes: https://lore.kernel.org/netdev/20240409201553.GA4124869@dev-arch.thelio-3990X/ --- drivers/net/phy/phy_link_topology.c | 23 -------------------- include/linux/phy_link_topology.h | 5 ----- include/linux/phy_link_topology_core.h | 30 +++++++++++++++++--------- 3 files changed, 20 insertions(+), 38 deletions(-) diff --git a/drivers/net/phy/phy_link_topology.c b/drivers/net/phy/phy_link_topology.c index 985941c5c558..960aedd73308 100644 --- a/drivers/net/phy/phy_link_topology.c +++ b/drivers/net/phy/phy_link_topology.c @@ -12,29 +12,6 @@ #include #include -struct phy_link_topology *phy_link_topo_create(struct net_device *dev) -{ - struct phy_link_topology *topo; - - topo = kzalloc(sizeof(*topo), GFP_KERNEL); - if (!topo) - return ERR_PTR(-ENOMEM); - - xa_init_flags(&topo->phys, XA_FLAGS_ALLOC1); - topo->next_phy_index = 1; - - return topo; -} - -void phy_link_topo_destroy(struct phy_link_topology *topo) -{ - if (!topo) - return; - - xa_destroy(&topo->phys); - kfree(topo); -} - int phy_link_topo_add_phy(struct phy_link_topology *topo, struct phy_device *phy, enum phy_upstream upt, void *upstream) diff --git a/include/linux/phy_link_topology.h b/include/linux/phy_link_topology.h index 6b79feb607e7..ad72d7881257 100644 --- a/include/linux/phy_link_topology.h +++ b/include/linux/phy_link_topology.h @@ -32,11 +32,6 @@ struct phy_device_node { struct phy_device *phy; }; -struct phy_link_topology { - struct xarray phys; - u32 next_phy_index; -}; - static inline struct phy_device * phy_link_topo_get_phy(struct phy_link_topology *topo, u32 phyindex) { diff --git a/include/linux/phy_link_topology_core.h b/include/linux/phy_link_topology_core.h index 0a6479055745..0116ec49cd1b 100644 --- a/include/linux/phy_link_topology_core.h +++ b/include/linux/phy_link_topology_core.h @@ -2,24 +2,34 @@ #ifndef __PHY_LINK_TOPOLOGY_CORE_H #define __PHY_LINK_TOPOLOGY_CORE_H -struct phy_link_topology; +#include -#if IS_REACHABLE(CONFIG_PHYLIB) - -struct phy_link_topology *phy_link_topo_create(struct net_device *dev); -void phy_link_topo_destroy(struct phy_link_topology *topo); - -#else +struct phy_link_topology { + struct xarray phys; + u32 next_phy_index; +}; static inline struct phy_link_topology *phy_link_topo_create(struct net_device *dev) { - return NULL; + struct phy_link_topology *topo; + + topo = kzalloc(sizeof(*topo), GFP_KERNEL); + if (!topo) + return ERR_PTR(-ENOMEM); + + xa_init_flags(&topo->phys, XA_FLAGS_ALLOC1); + topo->next_phy_index = 1; + + return topo; } static inline void phy_link_topo_destroy(struct phy_link_topology *topo) { -} + if (!topo) + return; -#endif + xa_destroy(&topo->phys); + kfree(topo); +} #endif /* __PHY_LINK_TOPOLOGY_CORE_H */ -- 2.44.0