Commit 1e08faf9 authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files

Merge branch 'net-ethernet-litex-minor-improvment-for-the-codebase'

Inochi Amaoto says:

====================
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.
====================

Link: https://patch.msgid.link/20260227003351.752934-1-inochiama@gmail.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 57cc8ab3 621e3634
Loading
Loading
Loading
Loading
+7 −14
Original line number Diff line number Diff line
@@ -232,12 +232,13 @@ 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;
	int irq, err;

	netdev = devm_alloc_etherdev(&pdev->dev, sizeof(*priv));
	netdev = devm_alloc_etherdev(dev, sizeof(*priv));
	if (!netdev)
		return -ENOMEM;

@@ -246,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;
@@ -276,15 +277,15 @@ 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);

	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);
		dev_err(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,