Skip to contentSkip to conversation

net: dm9000: Correctly handle empty FIFO

PATCH In review Marek Vasut 3 participants 3 messages Apr 25, 2022 – Aug 8, 2022 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: dm9000: Correctly handle empty FIFO

Assign packet pointer only in case the MAC reports anything in the FIFO. In case the MAC indicates empty FIFO, return 0 to pass that information to the network stack.

Cc Joe Hershberger <[email protected]>
Cc Ramon Fried <[email protected]>
---
 drivers/net/dm9000x.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/dm9000x.c +2 -2
index 78ce536d4a3..07733df533e 100644
@@ -666,10 +666,10 @@ static int dm9000_recv(struct udevice *dev, int flags, uchar **packetp)
 	int ret;
 
 	ret = dm9000_recv_common(db, data);
-	if (ret)
+	if (ret > 0)
 		*packetp = (void *)data;
 
-	return ret ? ret : -EAGAIN;
+	return ret >= 0 ? ret : -EAGAIN;
 }
 
 static int dm9000_write_hwaddr(struct udevice *dev)
Signature · 1 line
2.35.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 30 lines · Marek Vasut

Assign packet pointer only in case the MAC reports anything in the FIFO. In case the MAC indicates empty FIFO, return 0 to pass that information to the network stack.

Cc Joe Hershberger <[email protected]>
Cc Ramon Fried <[email protected]>
---
 drivers/net/dm9000x.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/dm9000x.c +2 -3
index 78ce536d4a3..07733df533e 100644
@@ -666,10 +666,10 @@ static int dm9000_recv(struct udevice *dev, int flags, uchar **packetp)
        int ret;
 
        ret = dm9000_recv_common(db, data);
-       if (ret)
+       if (ret > 0)
                *packetp = (void *)data;
 
-       return ret ? ret : -EAGAIN;
+       return ret >= 0 ? ret : -EAGAIN;
 }
 
 static int dm9000_write_hwaddr(struct udevice *dev)
--
Quoted 2 lines

2.35.1