This function works nicely with gpiod_line_find_by_name() which
returns a line object whose owning chip must be later freed by the
caller. With this routine the caller can skip creating a temporary
chip object.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
*/
struct gpiod_line * gpiod_line_find_by_name(const char *name) GPIOD_API;
+/**
+ * @brief Close a GPIO chip owning this line and release all resources.
+ * @param line GPIO line object
+ *
+ * After this function returns, the line must no longer be used.
+ */
+void gpiod_line_close_chip(struct gpiod_line *line) GPIOD_API;
+
/**
* @brief Get the handle to the GPIO chip controlling this line.
* @param line The GPIO line object.
return NULL;
}
+void gpiod_line_close_chip(struct gpiod_line *line)
+{
+ struct gpiod_chip *chip = gpiod_line_get_chip(line);
+
+ gpiod_chip_close(chip);
+}
+
int gpiod_line_event_wait(struct gpiod_line *line,
const struct timespec *timeout)
{