* [PATCH net-next v2 1/2] net: ethernet: litex: use devm_register_netdev() to register netdev
2026-01-19 4:04 [PATCH net-next v2 0/2] net: ethernet: litex: minor improvment for the codebase Inochi Amaoto
@ 2026-01-19 4:04 ` Inochi Amaoto
2026-01-21 13:28 ` Andrew Lunn
2026-01-19 4:04 ` [PATCH net-next v2 2/2] net: ethernet: litex: use device pointer to simplify code Inochi Amaoto
1 sibling, 1 reply; 5+ messages in thread
From: Inochi Amaoto @ 2026-01-19 4:04 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Karol Gugala, Mateusz Holenko, Gabriel Somlo,
Joel Stanley
Cc: Inochi Amaoto, netdev, linux-kernel, Yixun Lan, Longbin Li
Use devm_register_netdev to avoid unnecessary remove() callback in
platform_driver structure.
Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
---
drivers/net/ethernet/litex/litex_liteeth.c | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
diff --git a/drivers/net/ethernet/litex/litex_liteeth.c b/drivers/net/ethernet/litex/litex_liteeth.c
index 829a4b828f8e..67ad1058c2ab 100644
--- a/drivers/net/ethernet/litex/litex_liteeth.c
+++ b/drivers/net/ethernet/litex/litex_liteeth.c
@@ -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.52.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH net-next v2 2/2] net: ethernet: litex: use device pointer to simplify code.
2026-01-19 4:04 [PATCH net-next v2 0/2] net: ethernet: litex: minor improvment for the codebase Inochi Amaoto
2026-01-19 4:04 ` [PATCH net-next v2 1/2] net: ethernet: litex: use devm_register_netdev() to register netdev Inochi Amaoto
@ 2026-01-19 4:04 ` Inochi Amaoto
2026-01-21 13:30 ` Andrew Lunn
1 sibling, 1 reply; 5+ messages in thread
From: Inochi Amaoto @ 2026-01-19 4:04 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Karol Gugala, Mateusz Holenko, Gabriel Somlo,
Joel Stanley
Cc: Inochi Amaoto, netdev, linux-kernel, Yixun Lan, Longbin Li
As there is already a device pointer in the probe function, replace
all "&pdev->dev" pattern with this predefined device pointer.
Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
---
drivers/net/ethernet/litex/litex_liteeth.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/litex/litex_liteeth.c b/drivers/net/ethernet/litex/litex_liteeth.c
index 67ad1058c2ab..670f2a406d7d 100644
--- a/drivers/net/ethernet/litex/litex_liteeth.c
+++ b/drivers/net/ethernet/litex/litex_liteeth.c
@@ -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,10 +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,
- struct pcpu_sw_netstats);
+ netdev->tstats = devm_netdev_alloc_pcpu_stats(dev, struct pcpu_sw_netstats);
if (!netdev->tstats)
return -ENOMEM;
@@ -277,7 +276,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 +284,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.52.0
^ permalink raw reply related [flat|nested] 5+ messages in thread