core: implement gpiod_line_is_free()
authorBartosz Golaszewski <bartekgola@gmail.com>
Mon, 9 Jan 2017 14:03:55 +0000 (15:03 +0100)
committerBartosz Golaszewski <bartekgola@gmail.com>
Mon, 9 Jan 2017 14:05:00 +0000 (15:05 +0100)
This routine allows the user to check if neither ownership nor any
event notifications were requested for this line.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
core.c
gpiod.h

diff --git a/core.c b/core.c
index 085094b8f81fa9be0d17a8aac7e975fdc106ff61..eefcff72a21640bf18234d972da0f571b0411535 100644 (file)
--- 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 473f41e01636c91c41f55cbb3dd4013071b89582..dbb103bd692db36303854cabd44b4ec59f5c3d96 100644 (file)
--- 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.