From: Marek Vasut Date: Mon, 25 Apr 2022 18:28:05 +0000 (+0200) Subject: net: dm9000: Correctly handle empty FIFO X-Git-Url: http://git.dujemihanovic.xyz/?a=commitdiff_plain;h=ecd8b0371386eb0b1826f5d067a3086ad5184a85;p=u-boot.git 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. Signed-off-by: Marek Vasut Cc: Joe Hershberger Cc: Ramon Fried Reviewed-by: Ramon Fried --- diff --git a/drivers/net/dm9000x.c b/drivers/net/dm9000x.c index 78ce536d4a..07733df533 100644 --- a/drivers/net/dm9000x.c +++ b/drivers/net/dm9000x.c @@ -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)