simple-api: modify the order of arguments in simple loop routines
authorBartosz Golaszewski <bartekgola@gmail.com>
Wed, 11 Oct 2017 16:33:03 +0000 (18:33 +0200)
committerBartosz Golaszewski <bartekgola@gmail.com>
Wed, 11 Oct 2017 16:33:03 +0000 (18:33 +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/gpiomon.c
tests/tests-simple-api.c

index bc39aa90d7be26eb2fcdd84b7ac9da36321d03ee..0f2839d6c475192d951745211288e6f9d3844520 100644 (file)
@@ -211,10 +211,10 @@ typedef int (*gpiod_simple_event_poll_cb)(unsigned int,
 
 /**
  * @brief Wait for events on a single GPIO line.
- * @param consumer Name of the consumer.
  * @param device Name, path or number of the gpiochip.
  * @param offset GPIO line offset to monitor.
  * @param active_low The active state of this line - true if low.
+ * @param consumer Name of the consumer.
  * @param timeout Maximum wait time for each iteration.
  * @param poll_cb Callback function to call when waiting for events.
  * @param event_cb Callback function to call on event occurrence.
@@ -224,8 +224,8 @@ typedef int (*gpiod_simple_event_poll_cb)(unsigned int,
  * The poll callback can be NULL in which case the routine will fall back to
  * a basic, ppoll() based callback.
  */
-int gpiod_simple_event_loop(const char *consumer, const char *device,
-                           unsigned int offset, bool active_low,
+int gpiod_simple_event_loop(const char *device, unsigned int offset,
+                           bool active_low, const char *consumer,
                            const struct timespec *timeout,
                            gpiod_simple_event_poll_cb poll_cb,
                            gpiod_simple_event_handle_cb event_cb,
@@ -233,11 +233,11 @@ int gpiod_simple_event_loop(const char *consumer, const char *device,
 
 /**
  * @brief Wait for events on multiple GPIO lines.
- * @param consumer Name of the consumer.
  * @param device Name, path or number of the gpiochip.
  * @param offsets Array of GPIO line offsets to monitor.
  * @param num_lines Number of lines to monitor.
  * @param active_low The active state of this line - true if low.
+ * @param consumer Name of the consumer.
  * @param timeout Maximum wait time for each iteration.
  * @param poll_cb Callback function to call when waiting for events.
  * @param event_cb Callback function to call on event occurrence.
@@ -246,9 +246,10 @@ int gpiod_simple_event_loop(const char *consumer, const char *device,
  *
  * The callback functions work just like in the single line variant.
  */
-int gpiod_simple_event_loop_multiple(const char *consumer, const char *device,
+int gpiod_simple_event_loop_multiple(const char *device,
                                     const unsigned int *offsets,
                                     unsigned int num_lines, bool active_low,
+                                    const char *consumer,
                                     const struct timespec *timeout,
                                     gpiod_simple_event_poll_cb poll_cb,
                                     gpiod_simple_event_handle_cb event_cb,
index 8f386c3da7c7cfe4f43c2cf93805eec254471235..b77088ad4323ed2bb348349d0995fc85853de0a1 100644 (file)
@@ -177,21 +177,21 @@ static int basic_event_poll(unsigned int num_lines,
        return ret;
 }
 
-int gpiod_simple_event_loop(const char *consumer, const char *device,
-                           unsigned int offset, bool active_low,
+int gpiod_simple_event_loop(const char *device, unsigned int offset,
+                           bool active_low, const char *consumer,
                            const struct timespec *timeout,
                            gpiod_simple_event_poll_cb poll_cb,
-                           gpiod_simple_event_handle_cb event_cb,
-                           void *data)
+                           gpiod_simple_event_handle_cb event_cb, void *data)
 {
-       return gpiod_simple_event_loop_multiple(consumer, device, &offset, 1,
-                                               active_low, timeout, poll_cb,
+       return gpiod_simple_event_loop_multiple(device, &offset, 1, active_low,
+                                               consumer, timeout, poll_cb,
                                                event_cb, data);
 }
 
-int gpiod_simple_event_loop_multiple(const char *consumer, const char *device,
+int gpiod_simple_event_loop_multiple(const char *device,
                                     const unsigned int *offsets,
                                     unsigned int num_lines, bool active_low,
+                                    const char *consumer,
                                     const struct timespec *timeout,
                                     gpiod_simple_event_poll_cb poll_cb,
                                     gpiod_simple_event_handle_cb event_cb,
index 838c5b22a6cf964416bba7dff37052e8dda1abe1..9652f294ef12e7c38dd2849e3ce34d7c7bf6fc30 100644 (file)
@@ -317,8 +317,8 @@ int main(int argc, char **argv)
 
        ctx.sigfd = make_signalfd();
 
-       ret = gpiod_simple_event_loop_multiple("gpiomon", argv[0], offsets,
-                                              num_lines, active_low, &timeout,
+       ret = gpiod_simple_event_loop_multiple(argv[0], offsets, num_lines,
+                                              active_low, "gpiomon", &timeout,
                                               poll_callback,
                                               event_callback, &ctx);
        if (ret)
index 0decf8890267519fab0a4bbfd4a3ddf4e3310eb9..6006203bb69f5122b990399fbe7c5c4d89d71a93 100644 (file)
@@ -152,9 +152,9 @@ static void simple_event_loop(void)
 
        test_set_event(0, 3, TEST_EVENT_ALTERNATING, 100);
 
-       status = gpiod_simple_event_loop(TEST_CONSUMER, test_chip_name(0), 3,
-                                        false, &ts, NULL, simple_event_cb,
-                                        &evdata);
+       status = gpiod_simple_event_loop(test_chip_name(0), 3, false,
+                                        TEST_CONSUMER, &ts, NULL,
+                                        simple_event_cb, &evdata);
 
        TEST_ASSERT_RET_OK(status);
        TEST_ASSERT(evdata.got_rising_edge);
@@ -180,10 +180,10 @@ static void simple_event_loop_multiple(void)
 
        test_set_event(0, 3, TEST_EVENT_ALTERNATING, 100);
 
-       status = gpiod_simple_event_loop_multiple(TEST_CONSUMER,
-                                                 test_chip_name(0), offsets,
-                                                 4, false, &ts, NULL,
-                                                 simple_event_cb, &evdata);
+       status = gpiod_simple_event_loop_multiple(test_chip_name(0), offsets,
+                                                 4, false, TEST_CONSUMER, &ts,
+                                                 NULL, simple_event_cb,
+                                                 &evdata);
 
        TEST_ASSERT_RET_OK(status);
        TEST_ASSERT(evdata.got_rising_edge);
@@ -212,8 +212,9 @@ static void simple_event_loop_indicate_error(void)
 
        test_set_event(0, 3, TEST_EVENT_ALTERNATING, 100);
 
-       rv = gpiod_simple_event_loop(TEST_CONSUMER, test_chip_name(0), 3,
-                                    false, &ts, NULL, error_event_cb, NULL);
+       rv = gpiod_simple_event_loop(test_chip_name(0), 3, false,
+                                    TEST_CONSUMER, &ts, NULL,
+                                    error_event_cb, NULL);
 
        TEST_ASSERT_EQ(rv, -1);
        TEST_ASSERT_ERRNO_IS(ENOTBLK);
@@ -227,8 +228,9 @@ static void simple_event_loop_indicate_error_timeout(void)
        struct timespec ts = { 0, 100000 };
        int rv;
 
-       rv = gpiod_simple_event_loop(TEST_CONSUMER, test_chip_name(0), 3,
-                                    false, &ts, NULL, error_event_cb, NULL);
+       rv = gpiod_simple_event_loop(test_chip_name(0), 3, false,
+                                    TEST_CONSUMER, &ts, NULL,
+                                    error_event_cb, NULL);
 
        TEST_ASSERT_EQ(rv, -1);
        TEST_ASSERT_ERRNO_IS(ENOTBLK);