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",
69 .name = "clock-realtime",
80 if (info->flags & flagnames[i].mask) { in print_attributes()
86 if ((info->flags & GPIO_V2_LINE_FLAG_EDGE_RISING) && in print_attributes()
87 (info->flags & GPIO_V2_LINE_FLAG_EDGE_FALLING)) in print_attributes()
88 fprintf(stdout, field_format, "both-edges"); in print_attributes()
89 else if (info->flags & GPIO_V2_LINE_FLAG_EDGE_RISING) in print_attributes()
90 fprintf(stdout, field_format, "rising-edge"); in print_attributes()
91 else if (info->flags & GPIO_V2_LINE_FLAG_EDGE_FALLING) in print_attributes()
92 fprintf(stdout, field_format, "falling-edge"); in print_attributes()
94 for (i = 0; i < info->num_attrs; i++) { in print_attributes()
95 if (info->attrs[i].id == GPIO_V2_LINE_ATTR_ID_DEBOUNCE) in print_attributes()
97 info->attrs[i].debounce_period_us); in print_attributes()
111 return -ENOMEM; in list_device()
114 if (fd == -1) { in list_device()
115 ret = -errno; in list_device()
122 if (ret == -1) { in list_device()
123 ret = -errno; in list_device()
138 if (ret == -1) { in list_device()
139 ret = -errno; in list_device()
162 if (close(fd) == -1) in list_device()
173 " -n <name> List GPIOs on a named device\n" in print_usage()
174 " -? This helptext\n" in print_usage()
184 while ((c = getopt(argc, argv, "n:")) != -1) { in main()
191 return -1; in main()
198 const struct dirent *ent; in main() local
204 ret = -errno; in main()
208 ret = -ENOENT; in main()
209 while (ent = readdir(dp), ent) { in main()
210 if (check_prefix(ent->d_name, "gpiochip")) { in main()
211 ret = list_device(ent->d_name); in main()
218 if (closedir(dp) == -1) { in main()
220 ret = -errno; in main()