core: fix a default value bug when requesting a GPIO line
authorBartosz Golaszewski <bartekgola@gmail.com>
Mon, 2 Jan 2017 14:49:31 +0000 (15:49 +0100)
committerBartosz Golaszewski <bartekgola@gmail.com>
Mon, 2 Jan 2017 14:49:31 +0000 (15:49 +0100)
The direction is stored in the 'direction' argument, not in flags.

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

diff --git a/core.c b/core.c
index 1a4f8f58fb84e053495763dc09287e7228746443..5e4914cee99c9437186b2d948bfbb80fa6b062f8 100644 (file)
--- a/core.c
+++ b/core.c
@@ -217,9 +217,9 @@ int gpiod_line_request(struct gpiod_line *line, const char *consumer,
 
        req->lineoffsets[0] = line->info.line_offset;
        req->lines = 1;
-       /* FIXME This doesn't seem to work... */
-       if (flags & GPIOD_DIRECTION_OUT)
-               req->default_values[0] = default_val ? 1 : 0;
+
+       if (direction == GPIOD_DIRECTION_OUT)
+               req->default_values[0] = (__u8)default_val;
 
        strncpy(req->consumer_label, consumer,
                sizeof(req->consumer_label) - 1);