core: code shrink in gpiod_simple_get_value()
authorBartosz Golaszewski <bartekgola@gmail.com>
Wed, 11 Jan 2017 14:53:34 +0000 (15:53 +0100)
committerBartosz Golaszewski <bartekgola@gmail.com>
Wed, 11 Jan 2017 14:53:34 +0000 (15:53 +0100)
Use one of the request helpers for smaller code.

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

diff --git a/core.c b/core.c
index 7928578292a140e3a8b86145c098dbd640eb922c..6db048fdf62e01c9b92846bcc66e94fa41704c24 100644 (file)
--- a/core.c
+++ b/core.c
@@ -161,17 +161,10 @@ const char * gpiod_last_strerror(void)
 int gpiod_simple_get_value(const char *device,
                           unsigned int offset, bool active_low)
 {
-       struct gpiod_line_request_config config;
        struct gpiod_chip *chip;
        struct gpiod_line *line;
        int status, value;
 
-       memset(&config, 0, sizeof(config));
-       config.consumer = libgpiod_consumer;
-       config.direction = GPIOD_DIRECTION_INPUT;
-       config.active_state = active_low ? GPIOD_ACTIVE_STATE_LOW
-                                        : GPIOD_ACTIVE_STATE_HIGH;
-
        chip = gpiod_chip_open_lookup(device);
        if (!chip)
                return -1;
@@ -182,7 +175,7 @@ int gpiod_simple_get_value(const char *device,
                return -1;
        }
 
-       status = gpiod_line_request(line, &config, 0);
+       status = gpiod_line_request_input(line, libgpiod_consumer, active_low);
        if (status < 0) {
                gpiod_chip_close(chip);
                return -1;