From: Bartosz Golaszewski Date: Fri, 29 Sep 2017 17:18:09 +0000 (+0200) Subject: gpiofind: use gpiod_simple_find_line() internally X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=7a566450fba8be2fb3b49604e078397dc3af2239;p=qemu-gpiodev%2Flibgpiod.git gpiofind: use gpiod_simple_find_line() internally Switch to using the simple API in gpiofind. Signed-off-by: Bartosz Golaszewski --- diff --git a/src/tools/gpiofind.c b/src/tools/gpiofind.c index ac06cfd..15a6278 100644 --- a/src/tools/gpiofind.c +++ b/src/tools/gpiofind.c @@ -34,9 +34,9 @@ static void print_help(void) int main(int argc, char **argv) { - struct gpiod_line *line; - struct gpiod_chip *chip; - int optc, opti; + unsigned int offset; + int optc, opti, rv; + char chip[32]; for (;;) { optc = getopt_long(argc, argv, shortopts, longopts, &opti); @@ -63,15 +63,13 @@ int main(int argc, char **argv) if (argc != 1) die("exactly one GPIO line name must be specified"); - line = gpiod_line_find(argv[0]); - if (!line) + rv = gpiod_simple_find_line(argv[0], chip, sizeof(chip), &offset); + if (rv < 0) + die_perror("error performing the line lookup"); + else if (rv == 0) return EXIT_FAILURE; - chip = gpiod_line_get_chip(line); - - printf("%s %u\n", gpiod_chip_name(chip), gpiod_line_offset(line)); - - gpiod_chip_close(chip); + printf("%s %u\n", chip, offset); return EXIT_SUCCESS; }