[PATCH 1/5] net: cs8900: simplify buffer read loop
Sascha Hauer
s.hauer at pengutronix.de
Mon May 27 00:29:11 PDT 2024
Instead of doing an extra read after the buffer read loop when the
packet length is odd, add another iteration to the loop if necessary.
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
drivers/net/cs8900.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/net/cs8900.c b/drivers/net/cs8900.c
index 0dfd3f1303..afb0f3e26e 100644
--- a/drivers/net/cs8900.c
+++ b/drivers/net/cs8900.c
@@ -295,12 +295,9 @@ static int cs8900_recv(struct eth_device *dev)
status = readw(priv->regs + CS8900_RTDATA0);
len = readw(priv->regs + CS8900_RTDATA0);
- for (addr = (u16 *)priv->rx_buf, i = len >> 1; i > 0; i--) {
+ for (addr = (u16 *)priv->rx_buf, i = (len + 1) >> 1; i > 0; i--)
*addr++ = readw(priv->regs + CS8900_RTDATA0);
- }
- if (len & 1) {
- *addr++ = readw(priv->regs + CS8900_RTDATA0);
- }
+
net_receive(dev, priv->rx_buf, len);
return len;
--
2.39.2
More information about the barebox
mailing list