[PATCH 3/8] char: xillybus: Return error in fops read method handler

From: Eli Billauer

Date: Mon Nov 09 2026 - 06:32:01 EST


Be sure to return an error status from the driver's read fops method when
the USB device is unplugged or a hardware error occurs, and all available
data has been delivered.

Before this patch, the return value was zero in this case, meaning EOF,
which didn't expose the reason for ending the data stream.

The existing memory barrier smp_rmb(), together with the assignment of
xdev->error in report_io_error() with a spinlock taken, ensure that
xdev->error has its updated value when the hereby corrected assignment
takes place.

Assisted-by: Sashiko-0.2.5:gemini-3.1-pro-preview
Link: https://sashiko.dev/#/patchset/20260724094302.50761-1-eli.billauer@xxxxxxxxx
Signed-off-by: Eli Billauer <eli.billauer@xxxxxxxxx>
---
drivers/char/xillybus/xillyusb.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/char/xillybus/xillyusb.c b/drivers/char/xillybus/xillyusb.c
index 4c53d808737a..45612fd760f0 100644
--- a/drivers/char/xillybus/xillyusb.c
+++ b/drivers/char/xillybus/xillyusb.c
@@ -1544,7 +1544,7 @@ static ssize_t xillyusb_read(struct file *filp, char __user *userbuf,
if (READ_ONCE(fifo->fill))
continue;

- rc = 0;
+ rc = xdev->error; /* Usually zero, meaning EOF */
break;
}

--
2.17.1