From: Bartosz Golaszewski <bgolaszewski@xxxxxxxxxxxx> We can drop the redundant line state check if we directly call gpiod_line_event_get_fd() from gpiod_line_event_read(). As opposed to line_get_fd() it checks if the line was requested for events. Signed-off-by: Bartosz Golaszewski <bgolaszewski@xxxxxxxxxxxx> --- lib/core.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/core.c b/lib/core.c index b9fd6f4..89f5465 100644 --- a/lib/core.c +++ b/lib/core.c @@ -1012,12 +1012,9 @@ int gpiod_line_event_read(struct gpiod_line *line, { int fd; - if (line->state != LINE_REQUESTED_EVENTS) { - errno = EPERM; + fd = gpiod_line_event_get_fd(line); + if (fd < 0) return -1; - } - - fd = line_get_fd(line); return gpiod_line_event_read_fd(fd, event); } -- 2.23.0