Skip to contentSkip to conversation

net: macb: fix use of at91_default_usrio without CONFIG_OF

PATCH Superseded Conor Dooley 2 participants 2 messages Mar 30

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: macb: fix use of at91_default_usrio without CONFIG_OF

From: Conor Dooley <[email protected]>

If CONFIG_OF is not enabled, at91_default_usrio is used undeclared in gem_default_config. Rather than move the struct around, take the opportunity to rename gem_default_config, as the only compatible it is ever used for is "cdns,macb" - not "cdns,gem" at all! With that done, remove the use of default_gem_config as a fallback in probe, as every device has a specific set of match data.

It pains me a little to leave at91_default_usrio in match data used by "cdns,macb", but this is probably required to avoid regressing anyone.

Fixes a17871778ee28 ("net: macb: rename macb_default_usrio to at91_default_usrio as not all platforms have mii mode control in usrio")

---
lkp also reported this over the weekend, but against the dev copy in my tree. I had thought that CONFIG_OF was standard off on x86, but I guess it isn't, given lkp didn't catch it until randconfigs.

CC Andrew Lunn <[email protected]>
CC David S. Miller <[email protected]>
CC Eric Dumazet <[email protected]>
CC Jakub Kicinski <[email protected]>
CC Paolo Abeni <[email protected]>
CC Nicolas Ferre <[email protected]>
CC Claudiu Beznea <[email protected]>
---
 drivers/net/ethernet/cadence/macb_main.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)
drivers/net/ethernet/cadence/macb_main.c +11 -11
index 12e2b2f4aaf88..4f70e4fcf4606 100644
@@ -5716,9 +5716,18 @@ static const struct macb_config pic64hpsc_config = {
 	.jumbo_max_len = 16383,
 };
 
+static const struct macb_config macb_macb_config = {
+	.caps = MACB_CAPS_GIGABIT_MODE_AVAILABLE |
+		MACB_CAPS_JUMBO |
+		MACB_CAPS_GEM_HAS_PTP,
+	.dma_burst_length = 16,
+	.usrio = &at91_default_usrio,
+	.jumbo_max_len = 10240,
+};
+
 static const struct of_device_id macb_dt_ids[] = {
 	{ .compatible = "cdns,at91sam9260-macb", .data = &at91sam9260_config },
-	{ .compatible = "cdns,macb" },
+	{ .compatible = "cdns,macb", .data = &macb_macb_config},
 	{ .compatible = "cdns,np4-macb", .data = &np4_config },
 	{ .compatible = "cdns,pc302-gem", .data = &pc302gem_config },
 	{ .compatible = "cdns,gem", .data = &pc302gem_config },
@@ -5747,15 +5756,6 @@ static const struct of_device_id macb_dt_ids[] = {
 MODULE_DEVICE_TABLE(of, macb_dt_ids);
 #endif /* CONFIG_OF */
 
-static const struct macb_config default_gem_config = {
-	.caps = MACB_CAPS_GIGABIT_MODE_AVAILABLE |
-		MACB_CAPS_JUMBO |
-		MACB_CAPS_GEM_HAS_PTP,
-	.dma_burst_length = 16,
-	.usrio = &at91_default_usrio,
-	.jumbo_max_len = 10240,
-};
-
 static int macb_probe(struct platform_device *pdev)
 {
 	struct clk *pclk, *hclk = NULL, *tx_clk = NULL, *rx_clk = NULL;
@@ -5778,7 +5778,7 @@ static int macb_probe(struct platform_device *pdev)
 
 	macb_config = of_device_get_match_data(&pdev->dev);
 	if (!macb_config)
-		macb_config = &default_gem_config;
+		return -EINVAL;
 
 	err = macb_clk_init(pdev, &pclk, &hclk, &tx_clk, &rx_clk, &tsu_clk,
 			    macb_config);
Signature · 1 line
2.53.0
maintainer
#1 lore raw

drivers/net/ethernet/cadence/macb_main.c static int macb_probe(struct platform_device *pdev) · line 5782

Quoted 7 lines · On Mon, 30 Mar 2026 10:02:00 +0100 Conor Dooley wrote:
drivers/net/ethernet/cadence/macb_main.c +1 -1
@@ -5778,7 +5778,7 @@ static int macb_probe(struct platform_device *pdev)
 
 	macb_config = of_device_get_match_data(&pdev->dev);
 	if (!macb_config)
-		macb_config = &default_gem_config;
+		return -EINVAL;
 

AI reviewer says this will break macb_pci.c which registers a platform device and will never have match data?

Feel free to post the v2 without the full 24h netdev wait if needed.

Signature · 1 line
pw-bot: cr