treewide: rename BIAS_AS_IS to BIAS_UNKNOWN
authorBartosz Golaszewski <bgolaszewski@baylibre.com>
Thu, 17 Dec 2020 13:23:59 +0000 (14:23 +0100)
committerBartosz Golaszewski <bgolaszewski@baylibre.com>
Tue, 19 Jan 2021 09:49:15 +0000 (10:49 +0100)
When inspecting the current bias setting of a GPIO line, the AS_IS name
of one of the possible values really means that the kernel GPIO subsystem
can't determine the bias setting because it didn't set it itself (e.g.
the hardware may have internally initialized pull-up or pull-down
resistors). In this case it's better to change the name to BIAS_UNKNOWN
to reflect that.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
bindings/cxx/gpiod.hpp
bindings/cxx/line.cpp
bindings/cxx/tests/tests-line.cpp
bindings/python/gpiodmodule.c
bindings/python/tests/gpiod_py_test.py
include/gpiod.h
lib/core.c
tests/tests-line.c

index 8b4a8f9a48b7ca523137a2aae3aa62524749ddab..fb7f1fa9cc8235a7fe983d6e600c7e6cd8b778d3 100644 (file)
@@ -486,7 +486,7 @@ public:
         * @brief Possible bias settings.
         */
        enum : int {
-               BIAS_AS_IS = 1,
+               BIAS_UNKNOWN = 1,
                /**< Line's bias state is unknown. */
                BIAS_DISABLE,
                /**< Line's internal bias is disabled. */
index 5a907dbd12d6a0065e6c64d90b044edc46ba54b6..c605790f606babfa153e26fc0e9a341bcde6e766 100644 (file)
@@ -17,7 +17,7 @@ const ::std::map<int, int> bias_mapping = {
        { GPIOD_LINE_BIAS_PULL_UP,      line::BIAS_PULL_UP, },
        { GPIOD_LINE_BIAS_PULL_DOWN,    line::BIAS_PULL_DOWN, },
        { GPIOD_LINE_BIAS_DISABLE,      line::BIAS_DISABLE, },
-       { GPIOD_LINE_BIAS_AS_IS,        line::BIAS_AS_IS, },
+       { GPIOD_LINE_BIAS_UNKNOWN,      line::BIAS_UNKNOWN, },
 };
 
 } /* namespace */
index 3c7ea39dbf9311b25cdfe4d8a8288265bbd06acf..7ea9b3a131f5938a02a916ecf461aad233f997af 100644 (file)
@@ -35,7 +35,7 @@ TEST_CASE("Line information can be correctly retrieved", "[line]")
                REQUIRE_FALSE(line.is_used());
                REQUIRE_FALSE(line.is_open_drain());
                REQUIRE_FALSE(line.is_open_source());
-               REQUIRE(line.bias() == ::gpiod::line::BIAS_AS_IS);
+               REQUIRE(line.bias() == ::gpiod::line::BIAS_UNKNOWN);
        }
 
        SECTION("exported line")
@@ -54,7 +54,7 @@ TEST_CASE("Line information can be correctly retrieved", "[line]")
                REQUIRE(line.is_used());
                REQUIRE_FALSE(line.is_open_drain());
                REQUIRE_FALSE(line.is_open_source());
-               REQUIRE(line.bias() == ::gpiod::line::BIAS_AS_IS);
+               REQUIRE(line.bias() == ::gpiod::line::BIAS_UNKNOWN);
        }
 
        SECTION("exported line with flags")
@@ -75,7 +75,7 @@ TEST_CASE("Line information can be correctly retrieved", "[line]")
                REQUIRE(line.is_used());
                REQUIRE(line.is_open_drain());
                REQUIRE_FALSE(line.is_open_source());
-               REQUIRE(line.bias() == ::gpiod::line::BIAS_AS_IS);
+               REQUIRE(line.bias() == ::gpiod::line::BIAS_UNKNOWN);
        }
 
        SECTION("exported open source line")
@@ -95,7 +95,7 @@ TEST_CASE("Line information can be correctly retrieved", "[line]")
                REQUIRE(line.is_used());
                REQUIRE_FALSE(line.is_open_drain());
                REQUIRE(line.is_open_source());
-               REQUIRE(line.bias() == ::gpiod::line::BIAS_AS_IS);
+               REQUIRE(line.bias() == ::gpiod::line::BIAS_UNKNOWN);
        }
 
        SECTION("exported bias disable line")
index b48a83a9c73e908df5b9af612764d0a9f6fdf790..e0cfab3ffd4f23f630ae1067c7a971691b938ee1 100644 (file)
@@ -68,7 +68,7 @@ enum {
 };
 
 enum {
-       gpiod_BIAS_AS_IS = 1,
+       gpiod_BIAS_UNKNOWN = 1,
        gpiod_BIAS_DISABLE,
        gpiod_BIAS_PULL_UP,
        gpiod_BIAS_PULL_DOWN,
@@ -374,9 +374,9 @@ static PyObject *gpiod_Line_bias(gpiod_LineObject *self,
                return Py_BuildValue("I", gpiod_BIAS_PULL_DOWN);
        case GPIOD_LINE_BIAS_DISABLE:
                return Py_BuildValue("I", gpiod_BIAS_DISABLE);
-       case GPIOD_LINE_BIAS_AS_IS:
+       case GPIOD_LINE_BIAS_UNKNOWN:
        default:
-               return Py_BuildValue("I", gpiod_BIAS_AS_IS);
+               return Py_BuildValue("I", gpiod_BIAS_UNKNOWN);
        }
 }
 
@@ -2527,8 +2527,8 @@ static gpiod_ConstDescr gpiod_ConstList[] = {
        },
        {
                .typeobj = &gpiod_LineType,
-               .name = "BIAS_AS_IS",
-               .val = gpiod_BIAS_AS_IS,
+               .name = "BIAS_UNKNOWN",
+               .val = gpiod_BIAS_UNKNOWN,
        },
        {
                .typeobj = &gpiod_LineType,
index 3093a1ce5f8387386c0aa6148871922f18f5ddfc..7d790f31311912c7bfa30c1be177cb481d9e5a3c 100755 (executable)
@@ -241,7 +241,7 @@ class LineInfo(MockupTestCase):
             self.assertTrue(line.is_requested())
             self.assertTrue(line.is_open_drain())
             self.assertFalse(line.is_open_source())
-            self.assertEqual(line.bias(), gpiod.Line.BIAS_AS_IS)
+            self.assertEqual(line.bias(), gpiod.Line.BIAS_UNKNOWN)
 
     def test_exported_open_drain_line(self):
         with gpiod.Chip(mockup.chip_path(0)) as chip:
@@ -259,7 +259,7 @@ class LineInfo(MockupTestCase):
             self.assertTrue(line.is_requested())
             self.assertTrue(line.is_open_drain())
             self.assertFalse(line.is_open_source())
-            self.assertEqual(line.bias(), gpiod.Line.BIAS_AS_IS)
+            self.assertEqual(line.bias(), gpiod.Line.BIAS_UNKNOWN)
 
     def test_exported_open_source_line(self):
         with gpiod.Chip(mockup.chip_path(0)) as chip:
@@ -277,7 +277,7 @@ class LineInfo(MockupTestCase):
             self.assertTrue(line.is_requested())
             self.assertFalse(line.is_open_drain())
             self.assertTrue(line.is_open_source())
-            self.assertEqual(line.bias(), gpiod.Line.BIAS_AS_IS)
+            self.assertEqual(line.bias(), gpiod.Line.BIAS_UNKNOWN)
 
     def test_exported_bias_disable_line(self):
         with gpiod.Chip(mockup.chip_path(0)) as chip:
index 75da84c571c6a973b13ce5f0888142668f5b0f9a..1aaa6cd503d992502b48a0f2251078d7cc916f2a 100644 (file)
@@ -284,7 +284,7 @@ enum {
  * @brief Possible internal bias settings.
  */
 enum {
-       GPIOD_LINE_BIAS_AS_IS = 1,
+       GPIOD_LINE_BIAS_UNKNOWN = 1,
        /**< The internal bias state is unknown. */
        GPIOD_LINE_BIAS_DISABLE,
        /**< The internal bias is disabled. */
@@ -337,7 +337,7 @@ bool gpiod_line_is_active_low(struct gpiod_line *line) GPIOD_API;
  * @brief Read the GPIO line bias setting.
  * @param line GPIO line object.
  * @return Returns GPIOD_LINE_BIAS_PULL_UP, GPIOD_LINE_BIAS_PULL_DOWN,
- *         GPIOD_LINE_BIAS_DISABLE or GPIOD_LINE_BIAS_AS_IS.
+ *         GPIOD_LINE_BIAS_DISABLE or GPIOD_LINE_BIAS_UNKNOWN.
  */
 int gpiod_line_bias(struct gpiod_line *line) GPIOD_API;
 
index c6fb4743ba404c2a65e490a3bb2360c1a4c2951a..9ee84cff52319e979d01d39e80153ce133bc52f7 100644 (file)
@@ -485,7 +485,7 @@ int gpiod_line_bias(struct gpiod_line *line)
        if (line->info_flags & GPIOLINE_FLAG_BIAS_PULL_DOWN)
                return GPIOD_LINE_BIAS_PULL_DOWN;
 
-       return GPIOD_LINE_BIAS_AS_IS;
+       return GPIOD_LINE_BIAS_UNKNOWN;
 }
 
 bool gpiod_line_is_used(struct gpiod_line *line)
index d6264af60d417ee2c8cf45936d7ec91e2230be07..88857a0f7f61e37fbb7d3ab319bcabb6e47ea4e9 100644 (file)
@@ -418,7 +418,7 @@ GPIOD_TEST_CASE(set_flags_bias, 0, { 8 })
        ret = gpiod_line_request_input(line, GPIOD_TEST_CONSUMER);
        g_assert_cmpint(ret, ==, 0);
        gpiod_test_return_if_failed();
-       g_assert_cmpint(gpiod_line_bias(line), ==, GPIOD_LINE_BIAS_AS_IS);
+       g_assert_cmpint(gpiod_line_bias(line), ==, GPIOD_LINE_BIAS_UNKNOWN);
 
        ret = gpiod_line_set_flags(line,
                GPIOD_LINE_REQUEST_FLAG_BIAS_DISABLE);
@@ -762,7 +762,7 @@ GPIOD_TEST_CASE(misc_flags, 0, { 8 })
        g_assert_false(gpiod_line_is_used(line));
        g_assert_false(gpiod_line_is_open_drain(line));
        g_assert_false(gpiod_line_is_open_source(line));
-       g_assert_cmpint(gpiod_line_bias(line), ==, GPIOD_LINE_BIAS_AS_IS);
+       g_assert_cmpint(gpiod_line_bias(line), ==, GPIOD_LINE_BIAS_UNKNOWN);
 
        config.request_type = GPIOD_LINE_REQUEST_DIRECTION_OUTPUT;
        config.consumer = GPIOD_TEST_CONSUMER;
@@ -775,7 +775,7 @@ GPIOD_TEST_CASE(misc_flags, 0, { 8 })
        g_assert_true(gpiod_line_is_used(line));
        g_assert_true(gpiod_line_is_open_drain(line));
        g_assert_false(gpiod_line_is_open_source(line));
-       g_assert_cmpint(gpiod_line_bias(line), ==, GPIOD_LINE_BIAS_AS_IS);
+       g_assert_cmpint(gpiod_line_bias(line), ==, GPIOD_LINE_BIAS_UNKNOWN);
        g_assert_cmpint(gpiod_line_direction(line), ==,
                        GPIOD_LINE_DIRECTION_OUTPUT);
 
@@ -790,7 +790,7 @@ GPIOD_TEST_CASE(misc_flags, 0, { 8 })
        g_assert_true(gpiod_line_is_used(line));
        g_assert_false(gpiod_line_is_open_drain(line));
        g_assert_true(gpiod_line_is_open_source(line));
-       g_assert_cmpint(gpiod_line_bias(line), ==, GPIOD_LINE_BIAS_AS_IS);
+       g_assert_cmpint(gpiod_line_bias(line), ==, GPIOD_LINE_BIAS_UNKNOWN);
        g_assert_cmpint(gpiod_line_direction(line), ==,
                        GPIOD_LINE_DIRECTION_OUTPUT);
 
@@ -829,7 +829,7 @@ GPIOD_TEST_CASE(misc_flags_work_together, 0, { 8 })
        g_assert_true(gpiod_line_is_used(line));
        g_assert_true(gpiod_line_is_open_drain(line));
        g_assert_false(gpiod_line_is_open_source(line));
-       g_assert_cmpint(gpiod_line_bias(line), ==, GPIOD_LINE_BIAS_AS_IS);
+       g_assert_cmpint(gpiod_line_bias(line), ==, GPIOD_LINE_BIAS_UNKNOWN);
        g_assert_true(gpiod_line_is_active_low(line));
        g_assert_cmpint(gpiod_line_direction(line), ==,
                        GPIOD_LINE_DIRECTION_OUTPUT);
@@ -846,7 +846,7 @@ GPIOD_TEST_CASE(misc_flags_work_together, 0, { 8 })
        g_assert_true(gpiod_line_is_used(line));
        g_assert_false(gpiod_line_is_open_drain(line));
        g_assert_true(gpiod_line_is_open_source(line));
-       g_assert_cmpint(gpiod_line_bias(line), ==, GPIOD_LINE_BIAS_AS_IS);
+       g_assert_cmpint(gpiod_line_bias(line), ==, GPIOD_LINE_BIAS_UNKNOWN);
        g_assert_true(gpiod_line_is_active_low(line));
 
        gpiod_line_release(line);