/**
* @brief Read current value from 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 active_low The active state of this line - true if low.
+ * @param consumer Name of the consumer.
* @return 0 or 1 (GPIO value) if the operation succeeds, -1 on error.
*/
-int gpiod_simple_get_value(const char *consumer, const char *device,
- unsigned int offset, bool active_low) GPIOD_API;
+int gpiod_simple_get_value(const char *device, unsigned int offset,
+ bool active_low, const char *consumer) GPIOD_API;
/**
* @brief Read current values from 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 read.
* @param values A buffer in which the values will be stored.
* @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.
* @return 0 if the operation succeeds, -1 on error.
*/
-int gpiod_simple_get_value_multiple(const char *consumer, const char *device,
+int gpiod_simple_get_value_multiple(const char *device,
const unsigned int *offsets, int *values,
- unsigned int num_lines,
- bool active_low) GPIOD_API;
+ unsigned int num_lines, bool active_low,
+ const char *consumer) GPIOD_API;
/**
* @brief Simple set value callback signature.
#include <errno.h>
#include <poll.h>
-int gpiod_simple_get_value(const char *consumer, const char *device,
- unsigned int offset, bool active_low)
+int gpiod_simple_get_value(const char *device, unsigned int offset,
+ bool active_low, const char *consumer)
{
int value, status;
- status = gpiod_simple_get_value_multiple(consumer, device, &offset,
- &value, 1, active_low);
+ status = gpiod_simple_get_value_multiple(device, &offset, &value,
+ 1, active_low, consumer);
if (status < 0)
return status;
return value;
}
-int gpiod_simple_get_value_multiple(const char *consumer, const char *device,
+int gpiod_simple_get_value_multiple(const char *device,
const unsigned int *offsets, int *values,
- unsigned int num_lines, bool active_low)
+ unsigned int num_lines, bool active_low,
+ const char *consumer)
{
struct gpiod_line_bulk bulk;
struct gpiod_chip *chip;
die("invalid GPIO offset: %s", argv[i + 1]);
}
- status = gpiod_simple_get_value_multiple("gpioset", device,
- offsets, values,
- num_lines, active_low);
+ status = gpiod_simple_get_value_multiple(device, offsets, values,
+ num_lines, active_low,
+ "gpioget");
if (status < 0)
die_perror("error reading GPIO values");
offsets[6] = 6;
offsets[7] = 7;
- rv = gpiod_simple_get_value_multiple(TEST_CONSUMER, test_chip_name(2),
- offsets, values, 8, false);
+ rv = gpiod_simple_get_value_multiple(test_chip_name(2), offsets,
+ values, 8, false, TEST_CONSUMER);
TEST_ASSERT_RET_OK(rv);
TEST_ASSERT_EQ(values[0], 0);
offsets[6] = 6;
offsets[7] = 7;
- rv = gpiod_simple_get_value_multiple(TEST_CONSUMER, test_chip_name(2),
- offsets, values, 8, false);
+ rv = gpiod_simple_get_value_multiple(test_chip_name(2), offsets,
+ values, 8, false, TEST_CONSUMER);
TEST_ASSERT_RET_OK(rv);
TEST_ASSERT_EQ(values[0], 1);
offsets[6] = 6;
offsets[7] = 7;
- rv = gpiod_simple_get_value_multiple(TEST_CONSUMER, test_chip_name(2),
- offsets, values, 8, false);
+ rv = gpiod_simple_get_value_multiple(test_chip_name(2), offsets,
+ values, 8, false, TEST_CONSUMER);
TEST_ASSERT_RET_OK(rv);
TEST_ASSERT_EQ(values[0], 0);
offsets[3] = 6;
offsets[4] = 7;
- rv = gpiod_simple_get_value_multiple(TEST_CONSUMER, test_chip_name(2),
- offsets, values, 5, false);
+ rv = gpiod_simple_get_value_multiple(test_chip_name(2), offsets,
+ values, 5, false, TEST_CONSUMER);
TEST_ASSERT_RET_OK(rv);
TEST_ASSERT_EQ(values[0], 0);
offsets[3] = 6;
offsets[4] = 7;
- rv = gpiod_simple_get_value_multiple(TEST_CONSUMER,
- test_chip_name(2),
+ rv = gpiod_simple_get_value_multiple(test_chip_name(2),
offsets, values,
- 5, false);
+ 5, false, TEST_CONSUMER);
TEST_ASSERT_RET_OK(rv);
TEST_ASSERT_EQ(values[0], 0);
offsets[1] = 2;
offsets[2] = 5;
- rv = gpiod_simple_get_value_multiple(TEST_CONSUMER, test_chip_name(0),
- offsets, values, 3, false);
+ rv = gpiod_simple_get_value_multiple(test_chip_name(0), offsets,
+ values, 3, false, TEST_CONSUMER);
TEST_ASSERT_RET_OK(rv);
TEST_ASSERT_EQ(values[0], 1);
{
int ret;
- ret = gpiod_simple_get_value(TEST_CONSUMER,
- test_chip_name(0), 3, false);
+ ret = gpiod_simple_get_value(test_chip_name(0), 3,
+ false, TEST_CONSUMER);
TEST_ASSERT_EQ(ret, 0);
ret = gpiod_simple_set_value(TEST_CONSUMER, test_chip_name(0),
3, 1, false, NULL, NULL);
TEST_ASSERT_RET_OK(ret);
- ret = gpiod_simple_get_value(TEST_CONSUMER,
- test_chip_name(0), 3, false);
+ ret = gpiod_simple_get_value(test_chip_name(0), 3,
+ false, TEST_CONSUMER);
TEST_ASSERT_EQ(ret, 1);
}
TEST_DEFINE(simple_set_get_value,
static void simple_set_get_value_multiple(void)
{
unsigned int offsets[] = { 0, 1, 2, 3, 4, 5, 6, 12, 13, 15 };
- int values[10], ret;
+ int values[10], rv;
- ret = gpiod_simple_get_value_multiple(TEST_CONSUMER, test_chip_name(0),
- offsets, values, 10, false);
- TEST_ASSERT_RET_OK(ret);
+ rv = gpiod_simple_get_value_multiple(test_chip_name(0), offsets,
+ values, 10, false, TEST_CONSUMER);
+ TEST_ASSERT_RET_OK(rv);
TEST_ASSERT_EQ(values[0], 0);
TEST_ASSERT_EQ(values[1], 0);
values[8] = 0;
values[9] = 0;
- ret = gpiod_simple_set_value_multiple(TEST_CONSUMER, test_chip_name(0),
+ rv = gpiod_simple_set_value_multiple(TEST_CONSUMER, test_chip_name(0),
offsets, values, 10, false,
NULL, NULL);
- TEST_ASSERT_RET_OK(ret);
+ TEST_ASSERT_RET_OK(rv);
- ret = gpiod_simple_get_value_multiple(TEST_CONSUMER, test_chip_name(0),
- offsets, values, 10, false);
- TEST_ASSERT_RET_OK(ret);
+ rv = gpiod_simple_get_value_multiple(test_chip_name(0), offsets,
+ values, 10, false, TEST_CONSUMER);
+ TEST_ASSERT_RET_OK(rv);
TEST_ASSERT_EQ(values[0], 1);
TEST_ASSERT_EQ(values[1], 1);
unsigned int offsets[GPIOD_LINE_BULK_MAX_LINES + 1];
int values[GPIOD_LINE_BULK_MAX_LINES + 1], ret;
- ret = gpiod_simple_get_value_multiple(TEST_CONSUMER, test_chip_name(0),
- offsets, values,
+ ret = gpiod_simple_get_value_multiple(test_chip_name(0), offsets,
+ values,
GPIOD_LINE_BULK_MAX_LINES + 1,
- false);
+ false, TEST_CONSUMER);
TEST_ASSERT_NOTEQ(ret, 0);
TEST_ASSERT_ERRNO_IS(EINVAL);
}