From: Bartosz Golaszewski Date: Mon, 9 Jan 2017 14:03:55 +0000 (+0100) Subject: core: implement gpiod_line_is_free() X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=5012e3c3d36293084bde71d065bc5c452e07130c;p=qemu-gpiodev%2Flibgpiod.git core: implement gpiod_line_is_free() This routine allows the user to check if neither ownership nor any event notifications were requested for this line. Signed-off-by: Bartosz Golaszewski --- diff --git a/core.c b/core.c index 085094b..eefcff7 100644 --- a/core.c +++ b/core.c @@ -440,6 +440,11 @@ bool gpiod_line_is_reserved(struct gpiod_line *line) return line->reserved_status == LINE_RESERVED; } +bool gpiod_line_is_free(struct gpiod_line *line) +{ + return line->reserved_status == LINE_FREE; +} + static bool line_bulk_is_reserved(struct gpiod_line_bulk *line_bulk) { unsigned int i; diff --git a/gpiod.h b/gpiod.h index 473f41e..dbb103b 100644 --- a/gpiod.h +++ b/gpiod.h @@ -385,6 +385,14 @@ void gpiod_line_release_bulk(struct gpiod_line_bulk *line_bulk) GPIOD_API; */ bool gpiod_line_is_reserved(struct gpiod_line *line) GPIOD_API; +/** + * @brief Check if the calling user has neither requested ownership of this + * line nor configured any event notifications. + * @param line GPIO line object. + * @return True if given line is free, false otherwise. + */ +bool gpiod_line_is_free(struct gpiod_line *line) GPIOD_API; + /** * @brief Read current value of a single GPIO line. * @param line GPIO line object.