int gpiod_line_active_state(struct gpiod_line *line) GPIOD_API;
/**
- * @brief Check if the line is used by the kernel.
+ * @brief Check if the line is currently in use.
* @param line GPIO line object.
- * @return True if the line is used by the kernel, false otherwise.
+ * @return True if the line is in use, false otherwise.
+ *
+ * The user space can't know exactly why a line is busy. It may have been
+ * requested by another process or hogged by the kernel. It only matters that
+ * the line is used and we can't request it.
*/
-bool gpiod_line_is_used_by_kernel(struct gpiod_line *line) GPIOD_API;
+bool gpiod_line_is_used(struct gpiod_line *line) GPIOD_API;
/**
* @brief Check if the line is an open-drain GPIO.
: GPIOD_ACTIVE_STATE_HIGH;
}
-bool gpiod_line_is_used_by_kernel(struct gpiod_line *line)
+bool gpiod_line_is_used(struct gpiod_line *line)
{
return line->info.flags & GPIOLINE_FLAG_KERNEL;
}
static const struct flag flags[] = {
{
- .name = "kernel",
- .is_set = gpiod_line_is_used_by_kernel,
+ .name = "used",
+ .is_set = gpiod_line_is_used,
},
{
.name = "open-drain",
line = gpiod_chip_get_line(chip, 2);
TEST_ASSERT_NOT_NULL(line);
- TEST_ASSERT_FALSE(gpiod_line_is_used_by_kernel(line));
+ TEST_ASSERT_FALSE(gpiod_line_is_used(line));
TEST_ASSERT_FALSE(gpiod_line_is_open_drain(line));
TEST_ASSERT_FALSE(gpiod_line_is_open_source(line));
status = gpiod_line_request(line, &config, 0);
TEST_ASSERT_RET_OK(status);
- TEST_ASSERT(gpiod_line_is_used_by_kernel(line));
+ TEST_ASSERT(gpiod_line_is_used(line));
TEST_ASSERT(gpiod_line_is_open_drain(line));
TEST_ASSERT_FALSE(gpiod_line_is_open_source(line));
status = gpiod_line_request(line, &config, 0);
TEST_ASSERT_RET_OK(status);
- TEST_ASSERT(gpiod_line_is_used_by_kernel(line));
+ TEST_ASSERT(gpiod_line_is_used(line));
TEST_ASSERT_FALSE(gpiod_line_is_open_drain(line));
TEST_ASSERT(gpiod_line_is_open_source(line));
}