Source
/*
* lsgpio - example on how to list the GPIO lines on a system
*
* Copyright (C) 2015 Linus Walleij
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published by
* the Free Software Foundation.
*
* Usage:
* lsgpio <-n device-name>
*/
struct gpio_flag {
char *name;
unsigned long mask;
};
struct gpio_flag flagnames[] = {
{
.name = "kernel",
.mask = GPIOLINE_FLAG_KERNEL,
},
{
.name = "output",
.mask = GPIOLINE_FLAG_IS_OUT,
},
{
.name = "active-low",
.mask = GPIOLINE_FLAG_ACTIVE_LOW,
},
{
.name = "open-drain",
.mask = GPIOLINE_FLAG_OPEN_DRAIN,
},
{
.name = "open-source",
.mask = GPIOLINE_FLAG_OPEN_SOURCE,
},
};
void print_flags(unsigned long flags)
{
int i;
int printed = 0;
for (i = 0; i < ARRAY_SIZE(flagnames); i++) {
if (flags & flagnames[i].mask) {