Skip to contentSkip to conversation

net: ethernet: litex: minor improvment for the codebase

PATCH New Inochi Amaoto 2 participants 4 messages Feb 27 – Feb 28

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

v3 cover net: ethernet: litex: minor improvment for the codebase

Improve the litex code for using the device managed function to register netdev and replace all the "pdev->dev" with dev pointer instead.

Change from v2:
- https://lore.kernel.org/netdev/[email protected]
1. Apply Andrew' tag
2. patch 2: wrap the line to match the characters limit

Change from v1:
- https://lore.kernel.org/netdev/[email protected]/
1. separate the original patch into two patches.

Inochi Amaoto (2):
net: ethernet: litex: use devm_register_netdev() to register netdev
net: ethernet: litex: use device pointer to simplify code.

 drivers/net/ethernet/litex/litex_liteeth.c | 21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)

--
2.53.0

#1 lore raw

PATCH v3 1/2 net: ethernet: litex: use devm_register_netdev() to register netdev

Use devm_register_netdev to avoid unnecessary remove() callback in platform_driver structure.

---
 drivers/net/ethernet/litex/litex_liteeth.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)
drivers/net/ethernet/litex/litex_liteeth.c +2 -9
index 829a4b828f8e..67ad1058c2ab 100644
@@ -232,6 +232,7 @@ static void liteeth_setup_slots(struct liteeth *priv)
 
 static int liteeth_probe(struct platform_device *pdev)
 {
+	struct device *dev = &pdev->dev;
 	struct net_device *netdev;
 	void __iomem *buf_base;
 	struct liteeth *priv;
@@ -282,7 +283,7 @@ static int liteeth_probe(struct platform_device *pdev)
 
 	netdev->netdev_ops = &liteeth_netdev_ops;
 
-	err = register_netdev(netdev);
+	err = devm_register_netdev(dev, netdev);
 	if (err) {
 		dev_err(&pdev->dev, "Failed to register netdev %d\n", err);
 		return err;
@@ -294,13 +295,6 @@ static int liteeth_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static void liteeth_remove(struct platform_device *pdev)
-{
-	struct net_device *netdev = platform_get_drvdata(pdev);
-
-	unregister_netdev(netdev);
-}
-
 static const struct of_device_id liteeth_of_match[] = {
 	{ .compatible = "litex,liteeth" },
 	{ }
@@ -309,7 +303,6 @@ MODULE_DEVICE_TABLE(of, liteeth_of_match);
 
 static struct platform_driver liteeth_driver = {
 	.probe = liteeth_probe,
-	.remove = liteeth_remove,
 	.driver = {
 		.name = DRV_NAME,
 		.of_match_table = liteeth_of_match,

--
2.53.0

#2 lore raw

PATCH v3 2/2 net: ethernet: litex: use device pointer to simplify code.

In reply to Inochi Amaoto

As there is already a device pointer in the probe function, replace all "&pdev->dev" pattern with this predefined device pointer.

---
 drivers/net/ethernet/litex/litex_liteeth.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/net/ethernet/litex/litex_liteeth.c +5 -5
index 67ad1058c2ab..108d0a0db206 100644
@@ -238,7 +238,7 @@ static int liteeth_probe(struct platform_device *pdev)
 	struct liteeth *priv;
 	int irq, err;
 
-	netdev = devm_alloc_etherdev(&pdev->dev, sizeof(*priv));
+	netdev = devm_alloc_etherdev(dev, sizeof(*priv));
 	if (!netdev)
 		return -ENOMEM;
 
@@ -247,9 +247,9 @@ static int liteeth_probe(struct platform_device *pdev)
 
 	priv = netdev_priv(netdev);
 	priv->netdev = netdev;
-	priv->dev = &pdev->dev;
+	priv->dev = dev;
 
-	netdev->tstats = devm_netdev_alloc_pcpu_stats(&pdev->dev,
+	netdev->tstats = devm_netdev_alloc_pcpu_stats(dev,
 						      struct pcpu_sw_netstats);
 	if (!netdev->tstats)
 		return -ENOMEM;
@@ -277,7 +277,7 @@ static int liteeth_probe(struct platform_device *pdev)
 	priv->tx_base = buf_base + priv->num_rx_slots * priv->slot_size;
 	priv->tx_slot = 0;
 
-	err = of_get_ethdev_address(pdev->dev.of_node, netdev);
+	err = of_get_ethdev_address(dev->of_node, netdev);
 	if (err)
 		eth_hw_addr_random(netdev);
 
@@ -285,7 +285,7 @@ static int liteeth_probe(struct platform_device *pdev)
 
 	err = devm_register_netdev(dev, netdev);
 	if (err) {
-		dev_err(&pdev->dev, "Failed to register netdev %d\n", err);
+		dev_err(dev, "Failed to register netdev %d\n", err);
 		return err;
 	}
 

--
2.53.0

#3 lore raw
In reply to Inochi Amaoto
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

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

Quoted 9 lines · On Fri, 27 Feb 2026 08:33:46 +0800 you wrote:

Improve the litex code for using the device managed function to register netdev and replace all the "pdev->dev" with dev pointer instead.

Change from v2:
- https://lore.kernel.org/netdev/[email protected]
1. Apply Andrew' tag
2. patch 2: wrap the line to match the characters limit

[...]

Here is the summary with links:
- [net-next,v3,1/2] net: ethernet: litex: use devm_register_netdev() to register netdev (no matching commit)
- [net-next,v3,2/2] net: ethernet: litex: use device pointer to simplify code.

    https://git.kernel.org/netdev/net-next/c/621e3634dfab

You are awesome, thank you!

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