Lines Matching +full:ent +full:- +full:gpios
1 // SPDX-License-Identifier: GPL-2.0-only
3 * lsgpio - example on how to list the GPIO lines on a system
8 * lsgpio <-n device-name>
24 #include "gpio-utils.h"
45 .name = "active-low",
49 .name = "open-drain",
53 .name = "open-source",
57 .name = "pull-up",
61 .name = "pull-down",
65 .name = "bias-disabled",
76 if (info->flags & flagnames[i].mask) { in print_attributes()
82 if ((info->flags & GPIO_V2_LINE_FLAG_EDGE_RISING) && in print_attributes()
83 (info->flags & GPIO_V2_LINE_FLAG_EDGE_FALLING)) in print_attributes()
84 fprintf(stdout, field_format, "both-edges"); in print_attributes()
85 else if (info->flags & GPIO_V2_LINE_FLAG_EDGE_RISING) in print_attributes()
86 fprintf(stdout, field_format, "rising-edge"); in print_attributes()
87 else if (info->flags & GPIO_V2_LINE_FLAG_EDGE_FALLING) in print_attributes()
88 fprintf(stdout, field_format, "falling-edge"); in print_attributes()
90 for (i = 0; i < info->num_attrs; i++) { in print_attributes()
91 if (info->attrs[i].id == GPIO_V2_LINE_ATTR_ID_DEBOUNCE) in print_attributes()
93 info->attrs[i].debounce_period_us); in print_attributes()
107 return -ENOMEM; in list_device()
110 if (fd == -1) { in list_device()
111 ret = -errno; in list_device()
118 if (ret == -1) { in list_device()
119 ret = -errno; in list_device()
134 if (ret == -1) { in list_device()
135 ret = -errno; in list_device()
158 if (close(fd) == -1) in list_device()
169 " -n <name> List GPIOs on a named device\n" in print_usage()
170 " -? This helptext\n" in print_usage()
180 while ((c = getopt(argc, argv, "n:")) != -1) { in main()
187 return -1; in main()
194 const struct dirent *ent; in main() local
200 ret = -errno; in main()
204 ret = -ENOENT; in main()
205 while (ent = readdir(dp), ent) { in main()
206 if (check_prefix(ent->d_name, "gpiochip")) { in main()
207 ret = list_device(ent->d_name); in main()
214 if (closedir(dp) == -1) { in main()
216 ret = -errno; in main()