From: Bartosz Golaszewski Date: Sun, 24 Sep 2017 08:48:14 +0000 (+0200) Subject: core: rename gpiod_line_is_used_by_kernel() X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=57fb030d30b5936cc8cc90133435db07d00511c5;p=qemu-gpiodev%2Flibgpiod.git core: rename gpiod_line_is_used_by_kernel() The UAPI flag checked by this routine is called GPIOLINE_FLAG_KERNEL but its name may be a bit misleading. When set, it can mean that the line is used by the kernel or by another user space process. Use a more general name: gpiod_line_is_used(). Signed-off-by: Bartosz Golaszewski --- diff --git a/include/gpiod.h b/include/gpiod.h index d56fb4d..fb173be 100644 --- a/include/gpiod.h +++ b/include/gpiod.h @@ -413,11 +413,15 @@ int gpiod_line_direction(struct gpiod_line *line) GPIOD_API; 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. diff --git a/src/lib/core.c b/src/lib/core.c index c3b06bb..a19ed57 100644 --- a/src/lib/core.c +++ b/src/lib/core.c @@ -321,7 +321,7 @@ int gpiod_line_active_state(struct gpiod_line *line) : 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; } diff --git a/src/tools/gpioinfo.c b/src/tools/gpioinfo.c index 7ae58f8..0ae9f72 100644 --- a/src/tools/gpioinfo.c +++ b/src/tools/gpioinfo.c @@ -24,8 +24,8 @@ struct flag { 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", diff --git a/tests/tests-line.c b/tests/tests-line.c index 596cbb5..0cd1f16 100644 --- a/tests/tests-line.c +++ b/tests/tests-line.c @@ -364,7 +364,7 @@ static void line_misc_flags(void) 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)); @@ -375,7 +375,7 @@ static void line_misc_flags(void) 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)); @@ -386,7 +386,7 @@ static void line_misc_flags(void) 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)); }