[PATCH 1/5] net: cs8900: simplify buffer read loop

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux