The gpiod_ family of kernel functions always assume the logical state for values (i.e. taking active low/high into account). We already have gpio_set_value, so add gpiod_get_value for symmetry. Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx> --- include/gpiod.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/gpiod.h b/include/gpiod.h index f76cc98155e0..8abf86db8682 100644 --- a/include/gpiod.h +++ b/include/gpiod.h @@ -63,4 +63,12 @@ static inline void gpiod_set_value(int gpio, bool value) gpio_direction_active(gpio, value); } +static inline int gpiod_get_value(int gpio) +{ + if (gpio < 0) + return gpio; + + return gpio_is_active(gpio); +} + #endif -- 2.30.2