From b179a660aee721827e220fccedcff18c868c991c Mon Sep 17 00:00:00 2001 From: Bartosz Golaszewski Date: Tue, 10 Jan 2017 11:37:40 +0100 Subject: [PATCH] event: rework gpiod_line_event_wait_bulk() Instead of storing the index of the line - store the line handle itself as the third parameter. Signed-off-by: Bartosz Golaszewski --- core.c | 12 ++++++------ gpiod.h | 7 +++---- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/core.c b/core.c index fa89110..c898c73 100644 --- a/core.c +++ b/core.c @@ -652,10 +652,10 @@ static bool line_bulk_is_event_configured(struct gpiod_line_bulk *line_bulk) int gpiod_line_event_wait_bulk(struct gpiod_line_bulk *bulk, const struct timespec *timeout, - unsigned int *index) + struct gpiod_line **line) { struct pollfd fds[GPIOD_REQUEST_MAX_LINES]; - struct gpiod_line *line; + struct gpiod_line *linetmp; unsigned int i; int status; @@ -667,9 +667,9 @@ int gpiod_line_event_wait_bulk(struct gpiod_line_bulk *bulk, memset(fds, 0, sizeof(fds)); for (i = 0; i < bulk->num_lines; i++) { - line = bulk->lines[i]; + linetmp = bulk->lines[i]; - fds[i].fd = line->event.fd; + fds[i].fd = linetmp->event.fd; fds[i].events = POLLIN | POLLPRI; } @@ -682,8 +682,8 @@ int gpiod_line_event_wait_bulk(struct gpiod_line_bulk *bulk, } for (i = 0; !fds[i].revents; i++); - if (index) - *index = i; + if (line) + *line = bulk->lines[i]; return 1; } diff --git a/gpiod.h b/gpiod.h index 2108283..d5245ca 100644 --- a/gpiod.h +++ b/gpiod.h @@ -533,15 +533,14 @@ int gpiod_line_event_wait(struct gpiod_line *line, * @brief Wait for the first event on a set of lines. * @param bulk Set of GPIO lines to monitor. * @param timeout Wait time limit. - * @param index The position of the line on which an event occured is stored - * in this variable. Can be NULL, in which case the index will - * not be stored. + * @param line The handle of the line on which an event occurs is stored + * in this variable. Can be NULL. * @return 0 if wait timed out, -1 if an error occurred, 1 if an event * occurred. */ int gpiod_line_event_wait_bulk(struct gpiod_line_bulk *bulk, const struct timespec *timeout, - unsigned int *index) GPIOD_API; + struct gpiod_line **line) GPIOD_API; /** * @brief Read the last event from the GPIO line. -- 2.30.2