Give it a few tries, then exit. Prevents a possible endless loop situation.
Showing the changes to drivers/staging/lirc/lirc_zilog.c (1 of 1 file). Show all
Unified · Split
| @@ -897,7 +897,7 @@ static ssize_t read(struct file *filep, char *outbuf, size_t n, loff_t *ppos) · 896 unmodified lines | ||
| 897 | 897 | struct IR *ir = filep->private_data; |
| 898 | 898 | struct IR_rx *rx; |
| 899 | 899 | struct lirc_buffer *rbuf = ir->l.rbuf; |
| 900 | − int ret = 0, written = 0; | |
| 900 | + int ret = 0, written = 0, retries = 0; | |
| 901 | 901 | unsigned int m; |
| 902 | 902 | DECLARE_WAITQUEUE(wait, current); |
| 903 | 903 | |
| @@ -950,6 +950,12 @@ static ssize_t read(struct file *filep, char *outbuf, size_t n, loff_t *ppos) · 46 unmodified lines | ||
| 950 | 950 | ret = copy_to_user((void *)outbuf+written, buf, |
| 951 | 951 | rbuf->chunk_size); |
| 952 | 952 | written += rbuf->chunk_size; |
| 953 | + } else { | |
| 954 | + retries++; | |
| 955 | + } | |
| 956 | + if (retries >= 5) { | |
| 957 | + zilog_error("Buffer read failed!\n"); | |
| 958 | + ret = -EIO; | |
| 953 | 959 | } |
| 954 | 960 | } |
| 955 | 961 | } |