simple: fix the active_low switch in gpiod_simple_event_loop()
authorBartosz Golaszewski <bartekgola@gmail.com>
Sun, 24 Sep 2017 19:11:45 +0000 (21:11 +0200)
committerBartosz Golaszewski <bartekgola@gmail.com>
Sun, 24 Sep 2017 19:11:45 +0000 (21:11 +0200)
We're incorrectly passing the boolean active_low argument to
gpiod_line_request_both_edges_events_flags() as flags. Add the same
conversion as in the other simple API routines.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
src/lib/simple.c

index c141f7b76363e750954fb0f0360fef57f7637887..2b23e4b58b6a7275d7dcdff0fe0f2287735b9446 100644 (file)
@@ -142,9 +142,9 @@ int gpiod_simple_event_loop(const char *consumer, const char *device,
                            gpiod_event_cb callback, void *cbdata)
 {
        struct gpiod_line_event event;
+       int status, evtype, flags;
        struct gpiod_chip *chip;
        struct gpiod_line *line;
-       int status, evtype;
 
        chip = gpiod_chip_open_lookup(device);
        if (!chip)
@@ -156,8 +156,10 @@ int gpiod_simple_event_loop(const char *consumer, const char *device,
                return -1;
        }
 
+       flags = active_low ? GPIOD_REQUEST_ACTIVE_LOW : 0;
+
        status = gpiod_line_request_both_edges_events_flags(line, consumer,
-                                                           active_low);
+                                                           flags);
        if (status < 0) {
                gpiod_chip_close(chip);
                return -1;