From: Bartosz Golaszewski Date: Wed, 11 Oct 2017 16:33:03 +0000 (+0200) Subject: simple-api: modify the order of arguments in simple loop routines X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=996e9c37c47ad5e135bea05590843f2963cfa257;p=qemu-gpiodev%2Flibgpiod.git simple-api: modify the order of arguments in simple loop routines Move the consumer string after the active_low property. Signed-off-by: Bartosz Golaszewski --- diff --git a/include/gpiod.h b/include/gpiod.h index bc39aa9..0f2839d 100644 --- a/include/gpiod.h +++ b/include/gpiod.h @@ -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, diff --git a/src/lib/simple.c b/src/lib/simple.c index 8f386c3..b77088a 100644 --- a/src/lib/simple.c +++ b/src/lib/simple.c @@ -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, diff --git a/src/tools/gpiomon.c b/src/tools/gpiomon.c index 838c5b2..9652f29 100644 --- a/src/tools/gpiomon.c +++ b/src/tools/gpiomon.c @@ -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) diff --git a/tests/tests-simple-api.c b/tests/tests-simple-api.c index 0decf88..6006203 100644 --- a/tests/tests-simple-api.c +++ b/tests/tests-simple-api.c @@ -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);