microchip: lan865x: Fix probing issues
Subsystems (5)
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
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.
--- drivers/net/ethernet/oa_tc6.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
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 ; tc6->spi_ctrl_tx_buf = devm_kzalloc(&tc6->spi->dev, OA_TC6_CTRL_SPI_BUF_SIZE,
Signature · 1 line
2.34.1
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_setupsucceed, so properly handle the error case.Fixes aa58bec064ab ("net: ethernet: oa_tc6: implement register write operation")Signed-off-by Stefan Wahren <[email protected]>Reviewed-by Andrew Lunn <[email protected]>--- drivers/net/ethernet/oa_tc6.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/net/ethernet/oa_tc6.c +0
-0
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
-0tc6->spi_ctrl_tx_buf = devm_kzalloc(&tc6->spi->dev, OA_TC6_CTRL_SPI_BUF_SIZE,
PATCH v2 2/3 microchip: lan865x: Fix module autoloading
In reply to Stefan WahrenAdd 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).
--- drivers/net/ethernet/microchip/lan865x/lan865x.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/ethernet/microchip/lan865x/lan865x.c +3 -2
@@ -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
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 fromspi_device_idtable. 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")Signed-off-by Stefan Wahren <[email protected]>Reviewed-by Andrew Lunn <[email protected]>--- drivers/net/ethernet/microchip/lan865x/lan865x.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/net/ethernet/microchip/lan865x/lan865x.c +0
-0
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
-1static 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);
PATCH v2 3/3 microchip: lan865x: Fix LAN8651 autoloading
In reply to Stefan WahrenAdd missing IDs for LAN8651 devices, which are also defined in the DT bindings.
--- drivers/net/ethernet/microchip/lan865x/lan865x.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/microchip/lan865x/lan865x.c +2 -0
@@ -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
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")Signed-off-by Stefan Wahren <[email protected]>---
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@@ -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);
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