aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBartosz Golaszewski <bartekgola@gmail.com>2017-10-11 18:10:31 +0200
committerBartosz Golaszewski <bartekgola@gmail.com>2017-10-11 18:10:31 +0200
commitb493015722eb77940803603ed625389fb9e235f1 (patch)
treecb766ea6169efa96f79699d566831563c3edebd9
parentb3eb355472689c490118d337216d73317f7a74ab (diff)
downloadexternal_libgpiod-b493015722eb77940803603ed625389fb9e235f1.tar.gz
external_libgpiod-b493015722eb77940803603ed625389fb9e235f1.tar.bz2
external_libgpiod-b493015722eb77940803603ed625389fb9e235f1.zip
simple-api: modify the order of arguments in set value routines
Move the consumer string after the active_low property. Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
-rw-r--r--include/gpiod.h12
-rw-r--r--src/lib/simple.c16
-rw-r--r--src/tools/gpioset.c7
-rw-r--r--tests/tests-gpioget.c12
-rw-r--r--tests/tests-simple-api.c16
5 files changed, 31 insertions, 32 deletions
diff --git a/include/gpiod.h b/include/gpiod.h
index 8171369..bc39aa9 100644
--- a/include/gpiod.h
+++ b/include/gpiod.h
@@ -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;
diff --git a/src/lib/simple.c b/src/lib/simple.c
index 8b3561b..8f386c3 100644
--- a/src/lib/simple.c
+++ b/src/lib/simple.c
@@ -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;
diff --git a/src/tools/gpioset.c b/src/tools/gpioset.c
index d1a46c1..1a21530 100644
--- a/src/tools/gpioset.c
+++ b/src/tools/gpioset.c
@@ -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");
diff --git a/tests/tests-gpioget.c b/tests/tests-gpioget.c
index fde9d18..db56991 100644
--- a/tests/tests-gpioget.c
+++ b/tests/tests-gpioget.c
@@ -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);
diff --git a/tests/tests-simple-api.c b/tests/tests-simple-api.c
index 11d1a74..0decf88 100644
--- a/tests/tests-simple-api.c
+++ b/tests/tests-simple-api.c
@@ -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);
}