: GPIOD_DIRECTION_IN;
}
-bool gpiod_line_is_active_low(struct gpiod_line *line)
+int gpiod_line_polarity(struct gpiod_line *line)
{
- return line->info.flags & GPIOLINE_FLAG_ACTIVE_LOW;
+ return line->info.flags & GPIOLINE_FLAG_ACTIVE_LOW
+ ? GPIOD_POLARITY_ACTIVE_LOW
+ : GPIOD_POLARITY_ACTIVE_HIGH;
}
bool gpiod_line_is_used_by_kernel(struct gpiod_line *line)
GPIOD_DIRECTION_OUT,
};
+enum {
+ GPIOD_POLARITY_ACTIVE_HIGH,
+ GPIOD_POLARITY_ACTIVE_LOW,
+};
+
enum {
GPIOD_REQUEST_ACTIVE_LOW = GPIOD_BIT(0),
GPIOD_REQUEST_OPEN_DRAIN = GPIOD_BIT(1),
int gpiod_line_direction(struct gpiod_line *line) GPIOD_API;
-bool gpiod_line_is_active_low(struct gpiod_line *line) GPIOD_API;
+int gpiod_line_polarity(struct gpiod_line *line) GPIOD_API;
bool gpiod_line_is_used_by_kernel(struct gpiod_line *line) GPIOD_API;
int main(int argc, char **argv)
{
- int i, direction, flag_printed;
+ int i, direction, flag_printed, polarity;
struct gpiod_line_iter iter;
const char *name, *consumer;
struct gpiod_line *line;
struct gpiod_chip *chip;
- bool active_low;
unsigned int j;
for (i = 1; i < argc; i++) {
name = gpiod_line_name(line);
consumer = gpiod_line_consumer(line);
direction = gpiod_line_direction(line);
- active_low = gpiod_line_is_active_low(line);
+ polarity = gpiod_line_polarity(line);
printf("\tline %2u: ", gpiod_line_offset(line));
printf("%s ", direction == GPIOD_DIRECTION_IN
? "input" : "output");
- printf("%s ", active_low ? "active-low"
- : "active-high");
+ printf("%s ", polarity == GPIOD_POLARITY_ACTIVE_LOW
+ ? "active-low"
+ : "active-high");
flag_printed = false;
for (j = 0; j < ARRAY_SIZE(flags); j++) {