core: rename gpiod_line_is_used_by_kernel()
authorBartosz Golaszewski <bartekgola@gmail.com>
Sun, 24 Sep 2017 08:48:14 +0000 (10:48 +0200)
committerBartosz Golaszewski <bartekgola@gmail.com>
Sun, 24 Sep 2017 08:48:14 +0000 (10:48 +0200)
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 <bartekgola@gmail.com>
include/gpiod.h
src/lib/core.c
src/tools/gpioinfo.c
tests/tests-line.c

index d56fb4d67cd0ef318fde04a73d293240406c6cee..fb173be427f1beaa48616b5a56ecfcc7c12f01f2 100644 (file)
@@ -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.
index c3b06bb7b1f2e7c393c256cab108816009d29687..a19ed57ca16aba00a39083d1283014589ffec016 100644 (file)
@@ -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;
 }
index 7ae58f868a161497b1cdd74b4aa502caf0ca2130..0ae9f728b5d67edfd4e54251fbfc83fa90a15f36 100644 (file)
@@ -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",
index 596cbb59e4ad8b9cfa393cc82a4d2d48022c26ef..0cd1f16d1d3ace4680c329319036b5fb95a22d03 100644 (file)
@@ -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));
 }