diff mbox series

hidraw: Return EPOLLOUT from hidraw_poll

Message ID 3141770d-bb58-e0e9-35ac-84cc23719892@gmail.com (mailing list archive)
State Mainlined
Commit 378b80370aa1fe50f9c48a3ac8af3e416e73b89f
Delegated to: Jiri Kosina
Headers show
Series hidraw: Return EPOLLOUT from hidraw_poll | expand

Commit Message

Fabian Henneke July 9, 2019, 11:03 a.m. UTC
Always return EPOLLOUT from hidraw_poll when a device is connected.
This is safe since writes are always possible (but will always block).

hidraw does not support non-blocking writes and instead always calls
blocking backend functions on write requests. Hence, so far, a call to
poll never returned EPOLLOUT, which confuses tools like socat.

Signed-off-by: Fabian Henneke <fabian.henneke@gmail.com>
In-reply-to: <CA+hv5qkyis03CgYTWeWX9cr0my-d2Oe+aZo+mjmWRXgjrGqyrw@mail.gmail.com>
---
 drivers/hid/hidraw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jiri Kosina July 17, 2019, 11:33 a.m. UTC | #1
On Tue, 9 Jul 2019, Fabian Henneke wrote:

> Always return EPOLLOUT from hidraw_poll when a device is connected.
> This is safe since writes are always possible (but will always block).
> 
> hidraw does not support non-blocking writes and instead always calls
> blocking backend functions on write requests. Hence, so far, a call to
> poll never returned EPOLLOUT, which confuses tools like socat.
> 
> Signed-off-by: Fabian Henneke <fabian.henneke@gmail.com>
> In-reply-to: <CA+hv5qkyis03CgYTWeWX9cr0my-d2Oe+aZo+mjmWRXgjrGqyrw@mail.gmail.com>

Good catch. I believe we need the same for hiddev too, could you please 
look into that as well, given you're fixing things in this area already?

Thanks,
Jiri Kosina Aug. 5, 2019, 12:08 p.m. UTC | #2
On Tue, 9 Jul 2019, Fabian Henneke wrote:

> Always return EPOLLOUT from hidraw_poll when a device is connected.
> This is safe since writes are always possible (but will always block).
> 
> hidraw does not support non-blocking writes and instead always calls
> blocking backend functions on write requests. Hence, so far, a call to
> poll never returned EPOLLOUT, which confuses tools like socat.
> 
> Signed-off-by: Fabian Henneke <fabian.henneke@gmail.com>
> In-reply-to: <CA+hv5qkyis03CgYTWeWX9cr0my-d2Oe+aZo+mjmWRXgjrGqyrw@mail.gmail.com>

Applied (together with the hiddev one) to for-5.4/hidraw-hiddev-epoll 
branch. Thanks,
diff mbox series

Patch

diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c
index 006bd6f4f653..24f40a3ddded 100644
--- a/drivers/hid/hidraw.c
+++ b/drivers/hid/hidraw.c
@@ -252,7 +252,7 @@  static __poll_t hidraw_poll(struct file *file, poll_table *wait)
 
 	poll_wait(file, &list->hidraw->wait, wait);
 	if (list->head != list->tail)
-		return EPOLLIN | EPOLLRDNORM;
+		return EPOLLIN | EPOLLRDNORM | EPOLLOUT;
 	if (!list->hidraw->exist)
 		return EPOLLERR | EPOLLHUP;
 	return 0;