gpiodetect: use the correct gpiod_chip_open() flavor
authorBartosz Golaszewski <bartekgola@gmail.com>
Mon, 2 Jan 2017 17:05:19 +0000 (18:05 +0100)
committerBartosz Golaszewski <bartekgola@gmail.com>
Mon, 2 Jan 2017 17:05:19 +0000 (18:05 +0100)
gpiod_chip_iter_next() should use gpiod_chip_open_by_name() internally
when opening chips by dentry->d_name.

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

diff --git a/core.c b/core.c
index 559054c9d87b919df3a89143b11c8557b85587df..4ba7baef926349d8fd34dd0ffd9cb4d1e8169b35 100644 (file)
--- a/core.c
+++ b/core.c
@@ -579,6 +579,7 @@ void gpiod_chip_iter_free(struct gpiod_chip_iter *iter)
 
 struct gpiod_chip * gpiod_chip_iter_next(struct gpiod_chip_iter *iter)
 {
+       struct gpiod_chip *chip;
        struct dirent *dentry;
        int status;
 
@@ -593,7 +594,8 @@ struct gpiod_chip * gpiod_chip_iter_next(struct gpiod_chip_iter *iter)
                status = strncmp(dentry->d_name, cdev_prefix,
                                 sizeof(cdev_prefix) - 1);
                if (status == 0) {
-                       iter->current = gpiod_chip_open(dentry->d_name);
+                       chip = gpiod_chip_open_by_name(dentry->d_name);
+                       iter->current = chip;
                        return iter->current;
                }
        }