Skip to content

Commit e3db9a4

Browse files
michalsieroncarlescufi
authored andcommitted
ethernet: eth_liteeth: Avoid bitwise operations
With universal LiteX HAL working, there is no need to perform multibyte reads and writes using bitwise operations. Just use appropriate `litex_read*` or `litex_write*` function. Signed-off-by: Michal Sieron <[email protected]>
1 parent 0c738b7 commit e3db9a4

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

drivers/ethernet/eth_liteeth.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,7 @@ static int eth_tx(const struct device *dev, struct net_pkt *pkt)
9494
net_pkt_read(pkt, context->tx_buf[context->txslot], len);
9595

9696
litex_write8(context->txslot, LITEETH_TX_SLOT);
97-
litex_write8(len >> 8, LITEETH_TX_LENGTH);
98-
litex_write8(len & 0xFF, LITEETH_TX_LENGTH + 4);
97+
litex_write16(len, LITEETH_TX_LENGTH);
9998

10099
/* wait for the device to be ready to transmit */
101100
while (litex_read8(LITEETH_TX_READY) == 0) {
@@ -132,10 +131,7 @@ static void eth_rx(const struct device *port)
132131
key = irq_lock();
133132

134133
/* get frame's length */
135-
for (int i = 0; i < 4; i++) {
136-
len <<= 8;
137-
len |= litex_read8(LITEETH_RX_LENGTH + i * 0x4);
138-
}
134+
len = litex_read32(LITEETH_RX_LENGTH);
139135

140136
/* which slot is the frame in */
141137
context->rxslot = litex_read8(LITEETH_RX_SLOT);

0 commit comments

Comments
 (0)