simple-api: modify the order of arguments in set value routines
authorBartosz Golaszewski <bartekgola@gmail.com>
Wed, 11 Oct 2017 16:10:31 +0000 (18:10 +0200)
committerBartosz Golaszewski <bartekgola@gmail.com>
Wed, 11 Oct 2017 16:10:31 +0000 (18:10 +0200)
Move the consumer string after the active_low property.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
include/gpiod.h
src/lib/simple.c
src/tools/gpioset.c
tests/tests-gpioget.c
tests/tests-simple-api.c

index 81713697f51cc894f68fa3b16545618d3c40e85b..bc39aa90d7be26eb2fcdd84b7ac9da36321d03ee 100644 (file)
@@ -99,38 +99,38 @@ typedef void (*gpiod_simple_set_value_cb)(void *);
 
 /**
  * @brief Set value of a single GPIO line.
- * @param consumer Name of the consumer.
  * @param device Name, path or number of the gpiochip.
  * @param offset GPIO line offset on the chip.
  * @param value New value.
  * @param active_low The active state of this line - true if low.
+ * @param consumer Name of the consumer.
  * @param cb Callback function that will be called right after the value is
  *        set. Users can use this, for example, to pause the execution after
  *        toggling a GPIO.
  * @param data User data that will be passed to the callback function.
  * @return 0 if the operation succeeds, -1 on error.
  */
-int gpiod_simple_set_value(const char *consumer, const char *device,
-                          unsigned int offset, int value, bool active_low,
+int gpiod_simple_set_value(const char *device, unsigned int offset, int value,
+                          bool active_low, const char *consumer,
                           gpiod_simple_set_value_cb cb, void *data) GPIOD_API;
 
 /**
  * @brief Set values of a set of a set of GPIO lines.
- * @param consumer Name of the consumer.
  * @param device Name, path or number of the gpiochip.
  * @param offsets An array of offsets of lines whose values should be set.
  * @param values An array of integers containing new values.
  * @param num_lines Number of lines, must be > 0.
  * @param active_low The active state of the lines - true if low.
+ * @param consumer Name of the consumer.
  * @param cb Callback function that will be called right after the values are
  *        set.
  * @param data User data that will be passed to the callback function.
  * @return 0 if the operation succeeds, -1 on error.
  */
-int gpiod_simple_set_value_multiple(const char *consumer, const char *device,
+int gpiod_simple_set_value_multiple(const char *device,
                                    const unsigned int *offsets,
                                    const int *values, unsigned int num_lines,
-                                   bool active_low,
+                                   bool active_low, const char *consumer,
                                    gpiod_simple_set_value_cb cb,
                                    void *data) GPIOD_API;
 
index 8b3561b2f9485f7567edde632901ea7e20ed6abf..8f386c3da7c7cfe4f43c2cf93805eec254471235 100644 (file)
@@ -78,21 +78,19 @@ int gpiod_simple_get_value_multiple(const char *device,
        return status;
 }
 
-int gpiod_simple_set_value(const char *consumer, const char *device,
-                          unsigned int offset, int value, bool active_low,
+int gpiod_simple_set_value(const char *device, unsigned int offset, int value,
+                          bool active_low, const char *consumer,
                           gpiod_simple_set_value_cb cb, void *data)
 {
-       return gpiod_simple_set_value_multiple(consumer, device, &offset,
-                                              &value, 1, active_low,
-                                              cb, data);
+       return gpiod_simple_set_value_multiple(device, &offset, &value, 1,
+                                              active_low, consumer, cb, data);
 }
 
-int gpiod_simple_set_value_multiple(const char *consumer, const char *device,
+int gpiod_simple_set_value_multiple(const char *device,
                                    const unsigned int *offsets,
                                    const int *values, unsigned int num_lines,
-                                   bool active_low,
-                                   gpiod_simple_set_value_cb cb,
-                                   void *data)
+                                   bool active_low, const char *consumer,
+                                   gpiod_simple_set_value_cb cb, void *data)
 {
        struct gpiod_line_bulk bulk;
        struct gpiod_chip *chip;
index d1a46c18f02a92d5b8b19158bfeb36766d7bf41d..1a215305ec9c74e0ef0a65eb0e16ea832d78f1a2 100644 (file)
@@ -264,9 +264,10 @@ int main(int argc, char **argv)
                        die("invalid offset: %s", argv[i + 1]);
        }
 
-       status = gpiod_simple_set_value_multiple("gpioset", device, offsets,
-                                                values, num_lines, active_low,
-                                                mode->callback, &cbdata);
+       status = gpiod_simple_set_value_multiple(device, offsets, values,
+                                                num_lines, active_low,
+                                                "gpioset", mode->callback,
+                                                &cbdata);
        if (status < 0)
                die_perror("error setting the GPIO line values");
 
index fde9d184adc242fcc357b38eeec1d93a1f1f1ac4..db56991d4d1130429c10074deade5f3bb304b1b7 100644 (file)
@@ -34,8 +34,8 @@ static void gpioget_read_all_lines(void)
 
        values[0] = values[1] = values[2] = values[3] = 1;
 
-       rv = gpiod_simple_set_value_multiple(TEST_CONSUMER, test_chip_name(1),
-                                            offsets, values, 4, false,
+       rv = gpiod_simple_set_value_multiple(test_chip_name(1), offsets,
+                                            values, 4, false, TEST_CONSUMER,
                                             NULL, NULL);
        TEST_ASSERT_RET_OK(rv);
 
@@ -75,8 +75,8 @@ static void gpioget_read_all_lines_active_low(void)
 
        values[0] = values[1] = values[2] = values[3] = 1;
 
-       rv = gpiod_simple_set_value_multiple(TEST_CONSUMER, test_chip_name(1),
-                                            offsets, values, 4, false,
+       rv = gpiod_simple_set_value_multiple(test_chip_name(1), offsets,
+                                            values, 4, false, TEST_CONSUMER,
                                             NULL, NULL);
        TEST_ASSERT_RET_OK(rv);
 
@@ -115,8 +115,8 @@ static void gpioget_read_some_lines(void)
 
        values[0] = values[1] = values[2] = 1;
 
-       rv = gpiod_simple_set_value_multiple(TEST_CONSUMER, test_chip_name(1),
-                                            offsets, values, 3, false,
+       rv = gpiod_simple_set_value_multiple(test_chip_name(1), offsets,
+                                            values, 3, false, TEST_CONSUMER,
                                             NULL, NULL);
        TEST_ASSERT_RET_OK(rv);
 
index 11d1a7455212e89e20aec618a412f7a8f626abce..0decf8890267519fab0a4bbfd4a3ddf4e3310eb9 100644 (file)
@@ -22,8 +22,8 @@ static void simple_set_get_value(void)
                                     false, TEST_CONSUMER);
        TEST_ASSERT_EQ(ret, 0);
 
-       ret = gpiod_simple_set_value(TEST_CONSUMER, test_chip_name(0),
-                                    3, 1, false, NULL, NULL);
+       ret = gpiod_simple_set_value(test_chip_name(0), 3, 1,
+                                    false, TEST_CONSUMER, NULL, NULL);
        TEST_ASSERT_RET_OK(ret);
 
        ret = gpiod_simple_get_value(test_chip_name(0), 3,
@@ -65,9 +65,9 @@ static void simple_set_get_value_multiple(void)
        values[8] = 0;
        values[9] = 0;
 
-       rv = gpiod_simple_set_value_multiple(TEST_CONSUMER, test_chip_name(0),
-                                             offsets, values, 10, false,
-                                             NULL, NULL);
+       rv = gpiod_simple_set_value_multiple(test_chip_name(0), offsets,
+                                            values, 10, false, TEST_CONSUMER,
+                                            NULL, NULL);
        TEST_ASSERT_RET_OK(rv);
 
        rv = gpiod_simple_get_value_multiple(test_chip_name(0), offsets,
@@ -110,10 +110,10 @@ static void simple_set_value_multiple_max_lines(void)
        unsigned int offsets[GPIOD_LINE_BULK_MAX_LINES + 1];
        int values[GPIOD_LINE_BULK_MAX_LINES + 1], ret;
 
-       ret = gpiod_simple_set_value_multiple(TEST_CONSUMER, test_chip_name(0),
-                                             offsets, values,
+       ret = gpiod_simple_set_value_multiple(test_chip_name(0), offsets,
+                                             values,
                                              GPIOD_LINE_BULK_MAX_LINES + 1,
-                                             false, NULL, NULL);
+                                             false, TEST_CONSUMER, NULL, NULL);
        TEST_ASSERT_NOTEQ(ret, 0);
        TEST_ASSERT_ERRNO_IS(EINVAL);
 }