core: change the prefix for line request flags
authorBartosz Golaszewski <bartekgola@gmail.com>
Fri, 17 Nov 2017 16:49:37 +0000 (17:49 +0100)
committerBartosz Golaszewski <bartekgola@gmail.com>
Fri, 17 Nov 2017 16:51:45 +0000 (17:51 +0100)
Make it clear that these are flags and that more than one can be used
simultaneously.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
include/gpiod.h
src/lib/core.c
src/lib/simple.c
tests/tests-event.c
tests/tests-gpioinfo.c
tests/tests-line.c

index 747a2265889f22fb9812c52fc1206296d3ed7d23..bef018fa3db28f43e7c0b56a37a24425cfbeaeed 100644 (file)
@@ -664,11 +664,11 @@ enum {
  * @brief Miscellaneous GPIO request flags.
  */
 enum {
-       GPIOD_LINE_REQUEST_OPEN_DRAIN   = GPIOD_BIT(0),
+       GPIOD_LINE_REQUEST_FLAG_OPEN_DRAIN      = GPIOD_BIT(0),
        /**< The line is an open-drain port. */
-       GPIOD_LINE_REQUEST_OPEN_SOURCE  = GPIOD_BIT(1),
+       GPIOD_LINE_REQUEST_FLAG_OPEN_SOURCE     = GPIOD_BIT(1),
        /**< The line is an open-source port. */
-       GPIOD_LINE_REQUEST_ACTIVE_LOW   = GPIOD_BIT(2),
+       GPIOD_LINE_REQUEST_FLAG_ACTIVE_LOW      = GPIOD_BIT(2),
        /**< The active state of the line is low (high is the default). */
 };
 
index 90666c513156010a5ed169f00ccbac44424a4c88..c17dffa757c4c58de5d9bdd322972b5d9ea071b9 100644 (file)
@@ -337,19 +337,19 @@ static int line_request_values(struct gpiod_line_bulk *bulk,
        int rv, fd;
 
        if ((config->request_type != GPIOD_LINE_REQUEST_DIRECTION_OUTPUT) &&
-           (config->flags & (GPIOD_LINE_REQUEST_OPEN_DRAIN |
-                             GPIOD_LINE_REQUEST_OPEN_SOURCE))) {
+           (config->flags & (GPIOD_LINE_REQUEST_FLAG_OPEN_DRAIN |
+                             GPIOD_LINE_REQUEST_FLAG_OPEN_SOURCE))) {
                errno = EINVAL;
                return -1;
        }
 
        memset(&req, 0, sizeof(req));
 
-       if (config->flags & GPIOD_LINE_REQUEST_OPEN_DRAIN)
+       if (config->flags & GPIOD_LINE_REQUEST_FLAG_OPEN_DRAIN)
                req.flags |= GPIOHANDLE_REQUEST_OPEN_DRAIN;
-       if (config->flags & GPIOD_LINE_REQUEST_OPEN_SOURCE)
+       if (config->flags & GPIOD_LINE_REQUEST_FLAG_OPEN_SOURCE)
                req.flags |= GPIOHANDLE_REQUEST_OPEN_SOURCE;
-       if (config->flags & GPIOD_LINE_REQUEST_ACTIVE_LOW)
+       if (config->flags & GPIOD_LINE_REQUEST_FLAG_ACTIVE_LOW)
                req.flags |= GPIOHANDLE_REQUEST_ACTIVE_LOW;
 
        if (config->request_type == GPIOD_LINE_REQUEST_DIRECTION_INPUT)
@@ -401,11 +401,11 @@ static int line_request_event_single(struct gpiod_line *line,
        req.lineoffset = gpiod_line_offset(line);
        req.handleflags |= GPIOHANDLE_REQUEST_INPUT;
 
-       if (config->flags & GPIOD_LINE_REQUEST_OPEN_DRAIN)
+       if (config->flags & GPIOD_LINE_REQUEST_FLAG_OPEN_DRAIN)
                req.handleflags |= GPIOHANDLE_REQUEST_OPEN_DRAIN;
-       if (config->flags & GPIOD_LINE_REQUEST_OPEN_SOURCE)
+       if (config->flags & GPIOD_LINE_REQUEST_FLAG_OPEN_SOURCE)
                req.handleflags |= GPIOHANDLE_REQUEST_OPEN_SOURCE;
-       if (config->flags & GPIOD_LINE_REQUEST_ACTIVE_LOW)
+       if (config->flags & GPIOD_LINE_REQUEST_FLAG_ACTIVE_LOW)
                req.handleflags |= GPIOHANDLE_REQUEST_ACTIVE_LOW;
 
        if (config->request_type == GPIOD_LINE_REQUEST_EVENT_RISING_EDGE)
index b77088ad4323ed2bb348349d0995fc85853de0a1..866bcd5b3844dcb354f237d60fe3dadbd54b4dc4 100644 (file)
@@ -62,7 +62,7 @@ int gpiod_simple_get_value_multiple(const char *device,
                gpiod_line_bulk_add(&bulk, line);
        }
 
-       flags = active_low ? GPIOD_LINE_REQUEST_ACTIVE_LOW : 0;
+       flags = active_low ? GPIOD_LINE_REQUEST_FLAG_ACTIVE_LOW : 0;
 
        status = gpiod_line_request_bulk_input_flags(&bulk, consumer, flags);
        if (status < 0) {
@@ -119,7 +119,7 @@ int gpiod_simple_set_value_multiple(const char *device,
                gpiod_line_bulk_add(&bulk, line);
        }
 
-       flags = active_low ? GPIOD_LINE_REQUEST_ACTIVE_LOW : 0;
+       flags = active_low ? GPIOD_LINE_REQUEST_FLAG_ACTIVE_LOW : 0;
 
        status = gpiod_line_request_bulk_output_flags(&bulk, consumer,
                                                      flags, values);
@@ -229,7 +229,7 @@ int gpiod_simple_event_loop_multiple(const char *device,
                gpiod_line_bulk_add(&bulk, line);
        }
 
-       flags = active_low ? GPIOD_LINE_REQUEST_ACTIVE_LOW : 0;
+       flags = active_low ? GPIOD_LINE_REQUEST_FLAG_ACTIVE_LOW : 0;
 
        rv = gpiod_line_request_bulk_both_edges_events_flags(&bulk,
                                                              consumer, flags);
index 95a3d012de2806a1586bcbf575af5c089f1fd15e..4c0be5ce9c5238507a2ec5f275f1115d69e18486 100644 (file)
@@ -116,7 +116,7 @@ static void event_rising_edge_active_low(void)
        TEST_ASSERT_NOT_NULL(line);
 
        rv = gpiod_line_request_rising_edge_events_flags(line, TEST_CONSUMER,
-                                               GPIOD_LINE_REQUEST_ACTIVE_LOW);
+                                       GPIOD_LINE_REQUEST_FLAG_ACTIVE_LOW);
        TEST_ASSERT_RET_OK(rv);
 
        test_set_event(0, 7, TEST_EVENT_RISING, 100);
index 8f0babe4c0ff44b328fb973f204acb208f57a89d..7212ed76b0598e1c42a73fede331991ddbcf3623 100644 (file)
@@ -50,7 +50,7 @@ static void gpioinfo_dump_all_chips_one_exported(void)
        TEST_ASSERT_NOT_NULL(line);
 
        rv = gpiod_line_request_input_flags(line, TEST_CONSUMER,
-                                           GPIOD_LINE_REQUEST_ACTIVE_LOW);
+                                           GPIOD_LINE_REQUEST_FLAG_ACTIVE_LOW);
        TEST_ASSERT_RET_OK(rv);
 
        test_tool_run("gpioinfo", (char *)NULL);
index 0acb0c8e6c6e20de9868b1b47da913f1bdf3ed98..2071e8e73b67efdb279dfa073415630b6be77b18 100644 (file)
@@ -435,7 +435,7 @@ static void line_active_state(void)
        gpiod_line_release(line);
 
        status = gpiod_line_request_input_flags(line, TEST_CONSUMER,
-                                               GPIOD_LINE_REQUEST_ACTIVE_LOW);
+                                       GPIOD_LINE_REQUEST_FLAG_ACTIVE_LOW);
        TEST_ASSERT_RET_OK(status);
 
        TEST_ASSERT_EQ(gpiod_line_direction(line), GPIOD_LINE_DIRECTION_INPUT);
@@ -463,7 +463,7 @@ static void line_misc_flags(void)
 
        config.request_type = GPIOD_LINE_REQUEST_DIRECTION_OUTPUT;
        config.consumer = TEST_CONSUMER;
-       config.flags = GPIOD_LINE_REQUEST_OPEN_DRAIN;
+       config.flags = GPIOD_LINE_REQUEST_FLAG_OPEN_DRAIN;
 
        status = gpiod_line_request(line, &config, 0);
        TEST_ASSERT_RET_OK(status);
@@ -474,7 +474,7 @@ static void line_misc_flags(void)
 
        gpiod_line_release(line);
 
-       config.flags = GPIOD_LINE_REQUEST_OPEN_SOURCE;
+       config.flags = GPIOD_LINE_REQUEST_FLAG_OPEN_SOURCE;
 
        status = gpiod_line_request(line, &config, 0);
        TEST_ASSERT_RET_OK(status);
@@ -500,12 +500,12 @@ static void line_open_source_open_drain_input_invalid(void)
        TEST_ASSERT_NOT_NULL(line);
 
        rv = gpiod_line_request_input_flags(line, TEST_CONSUMER,
-                                           GPIOD_LINE_REQUEST_OPEN_DRAIN);
+                                       GPIOD_LINE_REQUEST_FLAG_OPEN_DRAIN);
        TEST_ASSERT_EQ(rv, -1);
        TEST_ASSERT_ERRNO_IS(EINVAL);
 
        rv = gpiod_line_request_input_flags(line, TEST_CONSUMER,
-                                           GPIOD_LINE_REQUEST_OPEN_SOURCE);
+                                       GPIOD_LINE_REQUEST_FLAG_OPEN_SOURCE);
        TEST_ASSERT_EQ(rv, -1);
        TEST_ASSERT_ERRNO_IS(EINVAL);
 }