Skip to contentSkip to conversation

hidraw: Fix returning EPOLLOUT from hidraw_poll

PATCH Applied Marcel Holtmann 2 participants 2 messages Dec 4, 2019 – Dec 9, 2019 HID

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hidraw: Fix returning EPOLLOUT from hidraw_poll

When polling a connected /dev/hidrawX device, it is useful to get the EPOLLOUT when writing is possible. Since writing is possible as soon as the device is connected, always return it.

Right now EPOLLOUT is only returned when there are also input reports are available. This works if devices start sending reports when connected, but some HID devices might need an output report first before sending any input reports. This change will allow using EPOLLOUT here as well.

Fixes 378b80370aa1 ("hidraw: Return EPOLLOUT from hidraw_poll")
---
 drivers/hid/hidraw.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/hid/hidraw.c +2 -2
index bbc6ec1aa5cb..c25e95c19cad 100644
@@ -252,10 +252,10 @@ 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 | EPOLLOUT;
+		return EPOLLIN | EPOLLRDNORM;
 	if (!list->hidraw->exist)
 		return EPOLLERR | EPOLLHUP;
-	return 0;
+	return EPOLLOUT | EPOLLWRNORM;
 }
 
 static int hidraw_open(struct inode *inode, struct file *file)
Signature · 1 line
2.23.0
maintainer Applied
#1 lore raw
Quoted 10 lines · Marcel Holtmann

When polling a connected /dev/hidrawX device, it is useful to get the EPOLLOUT when writing is possible. Since writing is possible as soon as the device is connected, always return it.

Right now EPOLLOUT is only returned when there are also input reports are available. This works if devices start sending reports when connected, but some HID devices might need an output report first before sending any input reports. This change will allow using EPOLLOUT here as well.

Quoted 3 lines
Fixes 378b80370aa1 ("hidraw: Return EPOLLOUT from hidraw_poll")

Applied, thanks Marcel.

Signature · 2 lines
Jiri Kosina
SUSE Labs