Skip to contentSkip to conversation

microchip: lan865x: Fix probing issues

PATCH Applied Stefan Wahren 3 participants 8 messages Aug 27, 2025 – Aug 30, 2025

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

v2 cover microchip: lan865x: Fix probing issues

Recently I setup a customer i.MX93 board which contains a LAN8651 chip. During this process I discovered some probing related issues.

Changes in V2:
- Add Andrew's RB tags
- Also add lan8651 compatible to Patch 3 as suggested by Andrew Lunn
- CCs for stable

Stefan Wahren (3):
net: ethernet: oa_tc6: Handle failure of spi_setup
microchip: lan865x: Fix module autoloading
microchip: lan865x: Fix LAN8651 autoloading

 drivers/net/ethernet/microchip/lan865x/lan865x.c | 7 +++++--
 drivers/net/ethernet/oa_tc6.c                    | 3 ++-
 2 files changed, 7 insertions(+), 3 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH v2 1/3 net: ethernet: oa_tc6: Handle failure of spi_setup

There is no guarantee that spi_setup succeed, so properly handle the error case.

Fixes aa58bec064ab ("net: ethernet: oa_tc6: implement register write operation")
---
 drivers/net/ethernet/oa_tc6.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/oa_tc6.c +2 -1
index db200e4ec284..91a906a7918a 100644
@@ -1249,7 +1249,8 @@ struct oa_tc6 *oa_tc6_init(struct spi_device *spi, struct net_device *netdev)
 
 	/* Set the SPI controller to pump at realtime priority */
 	tc6->spi->rt = true;
-	spi_setup(tc6->spi);
+	if (spi_setup(tc6->spi) < 0)
+		return NULL;
 
 	tc6->spi_ctrl_tx_buf = devm_kzalloc(&tc6->spi->dev,
 					    OA_TC6_CTRL_SPI_BUF_SIZE,
Signature · 1 line
2.34.1
Reviewed-by on v2 1/3
#2 lore raw

Re: [PATCH V2 1/3 net] net: ethernet: oa_tc6: Handle failure of spi_setup

Quoted 16 lines · Stefan Wahren

There is no guarantee that spi_setup succeed, so properly handle the error case.

Fixes aa58bec064ab ("net: ethernet: oa_tc6: implement register write operation")
---
 drivers/net/ethernet/oa_tc6.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/oa_tc6.c +0 -0
index db200e4ec284..91a906a7918a 100644

drivers/net/ethernet/oa_tc6.c struct oa_tc6 *oa_tc6_init(struct spi_device *spi, struct net_device *netdev) · line 1254

Quoted 7 lines
drivers/net/ethernet/oa_tc6.c +2 -1
@@ -1249,7 +1249,8 @@ struct oa_tc6 *oa_tc6_init(struct spi_device *spi, struct net_device *netdev)
 
 	/* Set the SPI controller to pump at realtime priority */
 	tc6->spi->rt = true;
-	spi_setup(tc6->spi);
+	if (spi_setup(tc6->spi) < 0)
+		return NULL;
 

Was thinking this could maybe be a pointer error, but the rest of the function only returns NULL, and that means callers aren't prepped to handle such error pointers. Ok.

I would note that many of the other errors flows come with some logging to indicate what failed, but I don't think thats critical for this fix.

Quoted 2 lines
drivers/net/ethernet/oa_tc6.c +0 -0
 	tc6->spi_ctrl_tx_buf = devm_kzalloc(&tc6->spi->dev,
 					    OA_TC6_CTRL_SPI_BUF_SIZE,
#3 lore raw

PATCH v2 2/3 microchip: lan865x: Fix module autoloading

In reply to Stefan Wahren

Add MODULE_DEVICE_TABLE(), so modules could be properly autoloaded based on the alias from spi_device_id table. While at this, fix the misleading variable name (spidev is unrelated to this driver).

Fixes 5cd2340cb6a3 ("microchip: lan865x: add driver support for Microchip's LAN865X MAC-PHY")
---
 drivers/net/ethernet/microchip/lan865x/lan865x.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/ethernet/microchip/lan865x/lan865x.c +3 -2
index 84c41f193561..9d94c8fb8b91 100644
@@ -423,10 +423,11 @@ static void lan865x_remove(struct spi_device *spi)
 	free_netdev(priv->netdev);
 }
 
-static const struct spi_device_id spidev_spi_ids[] = {
+static const struct spi_device_id lan865x_ids[] = {
 	{ .name = "lan8650" },
 	{},
 };
+MODULE_DEVICE_TABLE(spi, lan865x_ids);
 
 static const struct of_device_id lan865x_dt_ids[] = {
 	{ .compatible = "microchip,lan8650" },
@@ -441,7 +442,7 @@ static struct spi_driver lan865x_driver = {
 	 },
 	.probe = lan865x_probe,
 	.remove = lan865x_remove,
-	.id_table = spidev_spi_ids,
+	.id_table = lan865x_ids,
 };
 module_spi_driver(lan865x_driver);
 
Signature · 1 line
2.34.1
Reviewed-by on v2 2/3
#4 lore raw

Re: [PATCH V2 2/3 net] microchip: lan865x: Fix module autoloading

Quoted 4 lines · Stefan Wahren

Add MODULE_DEVICE_TABLE(), so modules could be properly autoloaded based on the alias from spi_device_id table. While at this, fix the misleading variable name (spidev is unrelated to this driver).

spidev likely is just someone short-handing the spi_device_id. Makes sense to call this by the driver name.

Quoted 13 lines
Fixes 5cd2340cb6a3 ("microchip: lan865x: add driver support for Microchip's LAN865X MAC-PHY")
---
 drivers/net/ethernet/microchip/lan865x/lan865x.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/ethernet/microchip/lan865x/lan865x.c +0 -0
index 84c41f193561..9d94c8fb8b91 100644

drivers/net/ethernet/microchip/lan865x/lan865x.c static void lan865x_remove(struct spi_device *spi) · line 430

Quoted 9 lines
drivers/net/ethernet/microchip/lan865x/lan865x.c +2 -1
@@ -423,10 +423,11 @@ static void lan865x_remove(struct spi_device *spi)
 	free_netdev(priv->netdev);
 }
 
-static const struct spi_device_id spidev_spi_ids[] = {
+static const struct spi_device_id lan865x_ids[] = {
 	{ .name = "lan8650" },
 	{},
 };
+MODULE_DEVICE_TABLE(spi, lan865x_ids);

Right. Without MODULE_DEVICE_TABLE, the tables used by userspace won't populate with this driver. That results in failure to automatically load the module.

Makes sense.

Quoted 12 lines
drivers/net/ethernet/microchip/lan865x/lan865x.c +1 -1
 static const struct of_device_id lan865x_dt_ids[] = {
 	{ .compatible = "microchip,lan8650" },
@@ -441,7 +442,7 @@ static struct spi_driver lan865x_driver = {
 	 },
 	.probe = lan865x_probe,
 	.remove = lan865x_remove,
-	.id_table = spidev_spi_ids,
+	.id_table = lan865x_ids,
 };
 module_spi_driver(lan865x_driver);
 
#5 lore raw

PATCH v2 3/3 microchip: lan865x: Fix LAN8651 autoloading

In reply to Stefan Wahren

Add missing IDs for LAN8651 devices, which are also defined in the DT bindings.

Fixes 5cd2340cb6a3 ("microchip: lan865x: add driver support for Microchip's LAN865X MAC-PHY")
---
 drivers/net/ethernet/microchip/lan865x/lan865x.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/ethernet/microchip/lan865x/lan865x.c +2 -0
index 9d94c8fb8b91..79b800d2b72c 100644
@@ -425,12 +425,14 @@ static void lan865x_remove(struct spi_device *spi)
 
 static const struct spi_device_id lan865x_ids[] = {
 	{ .name = "lan8650" },
+	{ .name = "lan8651" },
 	{},
 };
 MODULE_DEVICE_TABLE(spi, lan865x_ids);
 
 static const struct of_device_id lan865x_dt_ids[] = {
 	{ .compatible = "microchip,lan8650" },
+	{ .compatible = "microchip,lan8651" },
 	{ /* Sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, lan865x_dt_ids);
Signature · 1 line
2.34.1
Reviewed-by on v2 3/3
#6 lore raw

Re: [PATCH V2 3/3 net] microchip: lan865x: Fix LAN8651 autoloading

Quoted 7 lines · Stefan Wahren

Add missing IDs for LAN8651 devices, which are also defined in the DT bindings.

Fixes 5cd2340cb6a3 ("microchip: lan865x: add driver support for Microchip's LAN865X MAC-PHY")

---

Quoted 22 lines
 drivers/net/ethernet/microchip/lan865x/lan865x.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/ethernet/microchip/lan865x/lan865x.c +2 -0
index 9d94c8fb8b91..79b800d2b72c 100644
@@ -425,12 +425,14 @@ static void lan865x_remove(struct spi_device *spi)
 
 static const struct spi_device_id lan865x_ids[] = {
 	{ .name = "lan8650" },
+	{ .name = "lan8651" },
 	{},
 };
 MODULE_DEVICE_TABLE(spi, lan865x_ids);
 
 static const struct of_device_id lan865x_dt_ids[] = {
 	{ .compatible = "microchip,lan8650" },
+	{ .compatible = "microchip,lan8651" },
 	{ /* Sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, lan865x_dt_ids);
#7 lore raw
In reply to Stefan Wahren
This series was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 9 lines · On Wed, 27 Aug 2025 13:53:38 +0200 you wrote:

Recently I setup a customer i.MX93 board which contains a LAN8651 chip. During this process I discovered some probing related issues.

Changes in V2:
- Add Andrew's RB tags
- Also add lan8651 compatible to Patch 3 as suggested by Andrew Lunn
- CCs for stable

[...]

Here is the summary with links:
- [V2,1/3,net] net: ethernet: oa_tc6: Handle failure of spi_setup

    https://git.kernel.org/netdev/net/c/b3852ae3105e
  - [V2,2/3,net] microchip: lan865x: Fix module autoloading
    https://git.kernel.org/netdev/net/c/c7217963eb77
  - [V2,3/3,net] microchip: lan865x: Fix LAN8651 autoloading
    https://git.kernel.org/netdev/net/c/ca47c44d36a9

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html