summaryrefslogtreecommitdiff
path: root/drivers/net/smc911x.c
diff options
context:
space:
mode:
authorMarek Vasut <marek.vasut+renesas@gmail.com>2020-03-15 17:02:05 +0100
committermarex <marex@desktop.lan>2020-05-01 12:35:21 +0200
commitb11c8bbfafa998e90fe93ab4e9b08c1a4959bd65 (patch)
tree36f448af0c4bd231e450eca269af6fee378bc2b6 /drivers/net/smc911x.c
parent3dbab926031fe77d794670c05d6c7badcfa77291 (diff)
downloadu-boot-b11c8bbfafa998e90fe93ab4e9b08c1a4959bd65.tar.gz
net: smc911x: Clean up the status handling in smc911x_recv()
Invert the status handling logic in smc911x_recv(), to make the function easier to read, no functional change. Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com> Cc: Joe Hershberger <joe.hershberger@ni.com> Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Diffstat (limited to 'drivers/net/smc911x.c')
-rw-r--r--drivers/net/smc911x.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
index 07066ce108..2d1a9e0f5a 100644
--- a/drivers/net/smc911x.c
+++ b/drivers/net/smc911x.c
@@ -352,23 +352,25 @@ static int smc911x_recv(struct eth_device *dev)
u32 pktlen, tmplen;
u32 status;
- if ((smc911x_reg_read(priv, RX_FIFO_INF) & RX_FIFO_INF_RXSUSED) >> 16) {
- status = smc911x_reg_read(priv, RX_STATUS_FIFO);
- pktlen = (status & RX_STS_PKT_LEN) >> 16;
+ status = smc911x_reg_read(priv, RX_FIFO_INF);
+ if (!(status & RX_FIFO_INF_RXSUSED))
+ return 0;
- smc911x_reg_write(priv, RX_CFG, 0);
+ status = smc911x_reg_read(priv, RX_STATUS_FIFO);
+ pktlen = (status & RX_STS_PKT_LEN) >> 16;
- tmplen = (pktlen + 3) / 4;
- while (tmplen--)
- *data++ = smc911x_reg_read(priv, RX_DATA_FIFO);
+ smc911x_reg_write(priv, RX_CFG, 0);
- if (status & RX_STS_ES)
- printf(DRIVERNAME
- ": dropped bad packet. Status: 0x%08x\n",
- status);
- else
- net_process_received_packet(net_rx_packets[0], pktlen);
- }
+ tmplen = (pktlen + 3) / 4;
+ while (tmplen--)
+ *data++ = smc911x_reg_read(priv, RX_DATA_FIFO);
+
+ if (status & RX_STS_ES)
+ printf(DRIVERNAME
+ ": dropped bad packet. Status: 0x%08x\n",
+ status);
+ else
+ net_process_received_packet(net_rx_packets[0], pktlen);
return 0;
}