From 5012e3c3d36293084bde71d065bc5c452e07130c Mon Sep 17 00:00:00 2001 From: Bartosz Golaszewski Date: Mon, 9 Jan 2017 15:03:55 +0100 Subject: [PATCH] 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 --- core.c | 5 +++++ gpiod.h | 8 ++++++++ 2 files changed, 13 insertions(+) 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. -- 2.30.2