core: fix gpiod_line_event_request()
authorBartosz Golaszewski <bartekgola@gmail.com>
Mon, 9 Jan 2017 14:12:03 +0000 (15:12 +0100)
committerBartosz Golaszewski <bartekgola@gmail.com>
Mon, 9 Jan 2017 14:12:03 +0000 (15:12 +0100)
Correctly set the last error if the line is busy.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
core.c

diff --git a/core.c b/core.c
index eff1e68f34bc9343184490e0d2e47eb53f264518..006e18bef204e29fb4ddbff6a9bdd01a2c63278f 100644 (file)
--- a/core.c
+++ b/core.c
@@ -576,8 +576,10 @@ int gpiod_line_event_request(struct gpiod_line *line,
        struct gpiod_chip *chip;
        int status, fd;
 
-       if (gpiod_line_event_configured(line))
-               return -EBUSY;
+       if (!gpiod_line_is_free(line)) {
+               set_last_error(GPIOD_ELINEBUSY);
+               return -1;
+       }
 
        req = &line->event;