Skip to contentSkip to conversation

core: Removing unnecessary check for monitoring multiple lines.

PATCH In review Daniel Mor 2 participants 2 messages Feb 8, 2020 – Feb 9, 2020

Subsystems (2)
lore
Share & tools
lore

Daniel Mor

author
#0 lore raw

PATCH 2/2 core: Removing unnecessary check for monitoring multiple lines.

In case when needed to monitor multiple lines on different chips function gpiod_line_event_wait_bulk() blocking it, by checking if
the line`s in a bulk from same chip.
In current state the API forsing the user to wait for notification on multiple threads.

---
 lib/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/core.c +1 -1
index ed63012..2a46074 100644
@@ -977,7 +977,7 @@ int gpiod_line_event_wait_bulk(struct gpiod_line_bulk *bulk,
 	struct gpiod_line *line;
 	int rv;
 
-	if (!line_bulk_same_chip(bulk) || !line_bulk_all_requested(bulk))
+	if (!line_bulk_all_requested(bulk))
 		return -1;
 
 	memset(fds, 0, sizeof(fds));
Signature · 1 line
2.17.1
#1 lore raw

sob., 8 lut 2020 o 11:01 Daniel Mor <[email protected]> napisał(a):

Quoted 25 lines

In case when needed to monitor multiple lines on different chips function gpiod_line_event_wait_bulk() blocking it, by checking if
the line`s in a bulk from same chip.
In current state the API forsing the user to wait for notification on multiple threads.

---
 lib/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/core.c +1 -2
index ed63012..2a46074 100644
@@ -977,7 +977,7 @@ int gpiod_line_event_wait_bulk(struct gpiod_line_bulk *bulk,
        struct gpiod_line *line;
        int rv;
 
-       if (!line_bulk_same_chip(bulk) || !line_bulk_all_requested(bulk))
+       if (!line_bulk_all_requested(bulk))
                return -1;
 
        memset(fds, 0, sizeof(fds));
--
Quoted 2 lines

2.17.1

The subject tag suggests there's another patch in this series but I never got anything and don't see anything on patchwork. For the
future: please also add [libgpiod] tag before [PATCH] to make it easier to spot user-space patches on the list.

I specifically made this function only accept lines from a single chip
- this is the same for all gpiod_line_bulk operations. To do otherwise would lead to redundant code as you would have to retrieve the chip reference from the line every time there's a new event and compare it to something to know which one this is. If you need to modify lines from several chips - please just retrieve the associated file descriptor and use poll() or select() and then you can easily map descriptor numbers to specific lines.

Bartosz