[PATCH 3/7] net: enc28j60: replace global NetRxPackets with per-interface allocation

Ahmad Fatoum a.fatoum at pengutronix.de
Wed Mar 13 04:07:00 PDT 2024


NetRxPackets is a remnant of times, where a board had at most one
Ethernet controller. This is outdated and we should drop NetRxPackets.

The driver doesn't maintain a queue of packets, so let's just allocate
it per interface.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 drivers/net/enc28j60.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/enc28j60.c b/drivers/net/enc28j60.c
index 51556ae01366..9455c6f5ea99 100644
--- a/drivers/net/enc28j60.c
+++ b/drivers/net/enc28j60.c
@@ -46,6 +46,7 @@ struct enc28j60_net {
 	/* store MAC address here while hardware is in the reset state */
 	u8 hwaddr[ETH_ALEN];
 	struct mii_bus miibus;
+	void *rx_buffer;
 };
 
 /*
@@ -793,9 +794,9 @@ static void enc28j60_hw_rx(struct eth_device *edev)
 		/* copy the packet from the receive buffer */
 		enc28j60_mem_read(priv,
 			rx_packet_start(priv->next_pk_ptr),
-			len, NetRxPackets[0]);
+			len, priv->rx_buffer);
 
-		net_receive(edev, NetRxPackets[0], len);
+		net_receive(edev, priv->rx_buffer, len);
 	}
 
 	/*
@@ -931,6 +932,7 @@ static int enc28j60_probe(struct device *dev)
 	priv = xzalloc(sizeof(*priv));
 
 	priv->spi = (struct spi_device *)dev->type_data;
+	priv->rx_buffer = net_alloc_packet();
 
 	edev = &priv->edev;
 	edev->priv = priv;
-- 
2.39.2




More information about the barebox mailing list