Skip to content
Snippets Groups Projects
Commit 3e9a409f authored by Adam Wujek's avatar Adam Wujek
Browse files

[BUG: #212] userspace/wrsw_rtud: fix learning queue errors


Fix errors like:
Read learning queue: error -1

It could happen that the ioctl is interrupted by a signal. Handle such
case correctly.

Signed-off-by: default avatarAdam Wujek <dev_public@wujek.eu>
parent 406b9854
Branches
Tags
No related merge requests found
...@@ -227,6 +227,7 @@ static int irq_disabled = 1; ...@@ -227,6 +227,7 @@ static int irq_disabled = 1;
int rtu_read_learning_queue(struct rtu_request *req) int rtu_read_learning_queue(struct rtu_request *req)
{ {
int err; int err;
int errno_local;
if (irq_disabled) { if (irq_disabled) {
ioctl(fd, WR_RTU_IRQENA); ioctl(fd, WR_RTU_IRQENA);
...@@ -235,8 +236,22 @@ int rtu_read_learning_queue(struct rtu_request *req) ...@@ -235,8 +236,22 @@ int rtu_read_learning_queue(struct rtu_request *req)
// If learning queue is empty, wait for UFIFO IRQ // If learning queue is empty, wait for UFIFO IRQ
if (rtu_ufifo_is_empty()) { if (rtu_ufifo_is_empty()) {
err = ioctl(fd, WR_RTU_IRQWAIT); err = ioctl(fd, WR_RTU_IRQWAIT);
if (err && (err != -EAGAIN)) errno_local = errno;
/* Check if ioctl was interrupted by a signal. Please note that
* the driver's function returns -ERESTARTSYS, but userspace
* gets -1 (and errno == EINTR) from the ioctl call. */
if (err == -1 && errno_local == EINTR)
return 1;
/* IRQ disabled, driver/ioctl sets errno to EAGAIN */
if (err == -1 && errno_local == EAGAIN)
return 2;
/* Other error */
if (err) {
pr_error("%s: error %d errno %s (%d)\n", __func__, err, strerror(errno_local), errno_local);
return err; return err;
}
} }
// read data from mapped IO memory // read data from mapped IO memory
......
...@@ -280,9 +280,11 @@ static int rtu_daemon_learning_process(void) ...@@ -280,9 +280,11 @@ static int rtu_daemon_learning_process(void)
err); err);
break; break;
} }
} else { } else if (err < 0) {
pr_error("Read learning queue: error %d\n", err); pr_error("Read learning queue: error %d\n", err);
} }
/* If err > 0 retry rtu_read_learning_queue in the next loop
* iteration. */
} }
return err; return err;
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment