mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/5] net: cs8900: simplify buffer read loop
@ 2024-05-27  7:29 Sascha Hauer
  2024-05-27  7:29 ` [PATCH 2/5] net: cs8900: do not read past the receive buffer Sascha Hauer
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Sascha Hauer @ 2024-05-27  7:29 UTC (permalink / raw)
  To: Barebox List; +Cc: jianqiang wang

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@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




^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-05-27  9:35 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-27  7:29 [PATCH 1/5] net: cs8900: simplify buffer read loop Sascha Hauer
2024-05-27  7:29 ` [PATCH 2/5] net: cs8900: do not read past the receive buffer Sascha Hauer
2024-05-27  8:58   ` Jules Maselbas
2024-05-27  9:34     ` Sascha Hauer
2024-05-27  7:29 ` [PATCH 3/5] net: ks8851_mll: " Sascha Hauer
2024-05-27  7:29 ` [PATCH 4/5] net: liteeth: " Sascha Hauer
2024-05-27  7:29 ` [PATCH 5/5] net: smc911x: " Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox