From patchwork Mon Apr 29 13:10:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Chevallier X-Patchwork-Id: 13646941 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C2954C4345F for ; Mon, 29 Apr 2024 13:10:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=P4Cow2vAifiOp8zaly4XBH1zwgQDSmGju5BYMTCEPyE=; b=lmy8Qr/CgtjjOq oeaKVeAzoSk508yCrd4YUtRRSvtyuvf2yjSFlihC8Tz0xid/I7x327roO3X+6xAESVA9hNl92Tsa4 0Oh3KLPJiZX5ItRUMKP4pnJAfgapHDNPsB0UCvUz4WmCEMGRLNYTLitIdyFQDRi3neSamUQvG8xjF HC4EY6xr/zCvsjoBpEOpsSQOqan2P/PxPJLWPID1FLAWEyjlQLW0Na6YC5wtLTiMNbwe5VHJw5trJ b0EzcHSHox8dT/9RyM9s1QHVmcc5GCAJnJnYzJmvPZ/CBX/VyWSLCvPDaqWhjOw0OgAftHJghWRdc ikhWEBE5yTftwzBPy8xg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1Qlz-00000002ra1-03rl; Mon, 29 Apr 2024 13:10:23 +0000 Received: from relay1-d.mail.gandi.net ([2001:4b98:dc4:8::221]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1Qlv-00000002rXD-0FyI for linux-arm-kernel@lists.infradead.org; Mon, 29 Apr 2024 13:10:21 +0000 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_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 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 MIME-Version: 1.0 X-GND-Sasl: maxime.chevallier@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240429_061019_408027_DEEC632C X-CRM114-Status: GOOD ( 12.31 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 */