* @brief Reserve a single line, set the direction to input.
* @param line GPIO line object.
* @param consumer Name of the consumer.
- * @param active_low Active state of the line (true if low).
* @return 0 if the line was properly reserved, -1 on failure.
*/
int gpiod_line_request_input(struct gpiod_line *line,
- const char *consumer,
- bool active_low) GPIOD_API;
+ const char *consumer) GPIOD_API;
/**
* @brief Reserve a single line, set the direction to output.
* @param line GPIO line object.
* @param consumer Name of the consumer.
- * @param active_low Active state of the line (true if low).
* @param default_val Default line value.
* @return 0 if the line was properly reserved, -1 on failure.
*/
-int gpiod_line_request_output(struct gpiod_line *line, const char *consumer,
- bool active_low, int default_val) GPIOD_API;
+int gpiod_line_request_output(struct gpiod_line *line,
+ const char *consumer, int default_val) GPIOD_API;
/**
* @brief Request rising edge event notifications on a single line.
* @param line GPIO line object.
* @param consumer Name of the consumer.
- * @param active_low Active state of the line - true if low.
* @return 0 if the operation succeeds, -1 on failure.
*/
int gpiod_line_request_rising_edge_events(struct gpiod_line *line,
- const char *consumer,
- bool active_low) GPIOD_API;
+ const char *consumer) GPIOD_API;
/**
* @brief Request falling edge event notifications on a single line.
* @param line GPIO line object.
* @param consumer Name of the consumer.
- * @param active_low Active state of the line - true if low.
* @return 0 if the operation succeeds, -1 on failure.
*/
int gpiod_line_request_falling_edge_events(struct gpiod_line *line,
- const char *consumer,
- bool active_low) GPIOD_API;
+ const char *consumer) GPIOD_API;
/**
* @brief Request all event type notifications on a single line.
* @param line GPIO line object.
* @param consumer Name of the consumer.
- * @param active_low Active state of the line - true if low.
* @return 0 if the operation succeeds, -1 on failure.
*/
int gpiod_line_request_both_edges_events(struct gpiod_line *line,
- const char *consumer,
- bool active_low) GPIOD_API;
+ const char *consumer) GPIOD_API;
+
+/**
+ * @brief Reserve a single line, set the direction to input.
+ * @param line GPIO line object.
+ * @param consumer Name of the consumer.
+ * @param flags Additional request flags.
+ * @return 0 if the line was properly reserved, -1 on failure.
+ */
+int gpiod_line_request_input_flags(struct gpiod_line *line,
+ const char *consumer, int flags) GPIOD_API;
+
+/**
+ * @brief Reserve a single line, set the direction to output.
+ * @param line GPIO line object.
+ * @param consumer Name of the consumer.
+ * @param flags Additional request flags.
+ * @param default_val Default line value.
+ * @return 0 if the line was properly reserved, -1 on failure.
+ */
+int gpiod_line_request_output_flags(struct gpiod_line *line,
+ const char *consumer, int flags,
+ int default_val) GPIOD_API;
+
+/**
+ * @brief Request rising edge event notifications on a single line.
+ * @param line GPIO line object.
+ * @param consumer Name of the consumer.
+ * @param flags Additional request flags.
+ * @return 0 if the operation succeeds, -1 on failure.
+ */
+int gpiod_line_request_rising_edge_events_flags(struct gpiod_line *line,
+ const char *consumer,
+ int flags) GPIOD_API;
+
+/**
+ * @brief Request falling edge event notifications on a single line.
+ * @param line GPIO line object.
+ * @param consumer Name of the consumer.
+ * @param flags Additional request flags.
+ * @return 0 if the operation succeeds, -1 on failure.
+ */
+int gpiod_line_request_falling_edge_events_flags(struct gpiod_line *line,
+ const char *consumer,
+ int flags) GPIOD_API;
+
+/**
+ * @brief Request all event type notifications on a single line.
+ * @param line GPIO line object.
+ * @param consumer Name of the consumer.
+ * @param flags Additional request flags.
+ * @return 0 if the operation succeeds, -1 on failure.
+ */
+int gpiod_line_request_both_edges_events_flags(struct gpiod_line *line,
+ const char *consumer,
+ int flags) GPIOD_API;
/**
* @brief Reserve a set of GPIO lines.
return gpiod_line_request_bulk(&bulk, config, &default_val);
}
-int gpiod_line_request_input(struct gpiod_line *line,
- const char *consumer, bool active_low)
+int gpiod_line_request_input(struct gpiod_line *line, const char *consumer)
{
struct gpiod_line_request_config config = {
.consumer = consumer,
.request_type = GPIOD_REQUEST_DIRECTION_INPUT,
- .flags = active_low ? GPIOD_REQUEST_ACTIVE_LOW : 0,
};
return gpiod_line_request(line, &config, 0);
}
-int gpiod_line_request_output(struct gpiod_line *line, const char *consumer,
- bool active_low, int default_val)
+int gpiod_line_request_output(struct gpiod_line *line,
+ const char *consumer, int default_val)
{
struct gpiod_line_request_config config = {
.consumer = consumer,
.request_type = GPIOD_REQUEST_DIRECTION_OUTPUT,
- .flags = active_low ? GPIOD_REQUEST_ACTIVE_LOW : 0,
+ };
+
+ return gpiod_line_request(line, &config, default_val);
+}
+
+int gpiod_line_request_input_flags(struct gpiod_line *line,
+ const char *consumer, int flags)
+{
+ struct gpiod_line_request_config config = {
+ .consumer = consumer,
+ .request_type = GPIOD_REQUEST_DIRECTION_INPUT,
+ .flags = flags,
+ };
+
+ return gpiod_line_request(line, &config, 0);
+}
+
+int gpiod_line_request_output_flags(struct gpiod_line *line,
+ const char *consumer, int flags,
+ int default_val)
+{
+ struct gpiod_line_request_config config = {
+ .consumer = consumer,
+ .request_type = GPIOD_REQUEST_DIRECTION_OUTPUT,
+ .flags = flags,
};
return gpiod_line_request(line, &config, default_val);
}
static int line_event_request_type(struct gpiod_line *line,
- const char *consumer,
- bool active_low, int type)
+ const char *consumer, int flags, int type)
{
struct gpiod_line_request_config config = {
.consumer = consumer,
.request_type = type,
- .flags = active_low ? GPIOD_REQUEST_ACTIVE_LOW : 0,
+ .flags = flags,
};
return gpiod_line_request(line, &config, 0);
}
int gpiod_line_request_rising_edge_events(struct gpiod_line *line,
- const char *consumer,
- bool active_low)
+ const char *consumer)
{
- return line_event_request_type(line, consumer, active_low,
+ return line_event_request_type(line, consumer, 0,
GPIOD_REQUEST_EVENT_RISING_EDGE);
}
int gpiod_line_request_falling_edge_events(struct gpiod_line *line,
- const char *consumer,
- bool active_low)
+ const char *consumer)
{
- return line_event_request_type(line, consumer, active_low,
+ return line_event_request_type(line, consumer, 0,
GPIOD_REQUEST_EVENT_FALLING_EDGE);
}
int gpiod_line_request_both_edges_events(struct gpiod_line *line,
- const char *consumer, bool active_low)
+ const char *consumer)
{
- return line_event_request_type(line, consumer, active_low,
+ return line_event_request_type(line, consumer, 0,
GPIOD_REQUEST_EVENT_BOTH_EDGES);
}
+int gpiod_line_request_rising_edge_events_flags(struct gpiod_line *line,
+ const char *consumer,
+ int flags)
+{
+ return line_event_request_type(line, consumer, flags,
+ GPIOD_REQUEST_EVENT_RISING_EDGE);
+}
+
+int gpiod_line_request_falling_edge_events_flags(struct gpiod_line *line,
+ const char *consumer,
+ int flags)
+{
+ return line_event_request_type(line, consumer, flags,
+ GPIOD_REQUEST_EVENT_RISING_EDGE);
+}
+
+int gpiod_line_request_both_edges_events_flags(struct gpiod_line *line,
+ const char *consumer, int flags)
+{
+ return line_event_request_type(line, consumer, flags,
+ GPIOD_REQUEST_EVENT_RISING_EDGE);
+}
+
int gpiod_line_event_wait(struct gpiod_line *line,
const struct timespec *timeout)
{
return -1;
}
- status = gpiod_line_request_both_edges_events(line, consumer, active_low);
+ status = gpiod_line_request_both_edges_events_flags(line, consumer,
+ active_low);
if (status < 0) {
gpiod_chip_close(chip);
return -1;
line = gpiod_chip_get_line(chip, 7);
TEST_ASSERT_NOT_NULL(line);
- rv = gpiod_line_request_rising_edge_events(line, TEST_CONSUMER, false);
+ rv = gpiod_line_request_rising_edge_events(line, TEST_CONSUMER);
TEST_ASSERT_RET_OK(rv);
test_set_event(0, 7, TEST_EVENT_RISING, 100);
line = gpiod_chip_get_line(chip, 7);
TEST_ASSERT_NOT_NULL(line);
- rv = gpiod_line_request_falling_edge_events(line,
- TEST_CONSUMER, false);
+ rv = gpiod_line_request_falling_edge_events(line, TEST_CONSUMER);
TEST_ASSERT_RET_OK(rv);
test_set_event(0, 7, TEST_EVENT_FALLING, 100);
line = gpiod_chip_get_line(chip, 7);
TEST_ASSERT_NOT_NULL(line);
- rv = gpiod_line_request_rising_edge_events(line, TEST_CONSUMER, false);
+ rv = gpiod_line_request_rising_edge_events(line, TEST_CONSUMER);
TEST_ASSERT_RET_OK(rv);
test_set_event(0, 7, TEST_EVENT_FALLING, 100);
line = gpiod_chip_get_line(chip, 7);
TEST_ASSERT_NOT_NULL(line);
- rv = gpiod_line_request_rising_edge_events(line, TEST_CONSUMER, true);
+ rv = gpiod_line_request_rising_edge_events_flags(line, TEST_CONSUMER,
+ GPIOD_REQUEST_ACTIVE_LOW);
TEST_ASSERT_RET_OK(rv);
test_set_event(0, 7, TEST_EVENT_RISING, 100);
line = gpiod_chip_get_line(chip, 7);
TEST_ASSERT_NOT_NULL(line);
- rv = gpiod_line_request_rising_edge_events(line, TEST_CONSUMER, false);
+ rv = gpiod_line_request_rising_edge_events(line, TEST_CONSUMER);
TEST_ASSERT_RET_OK(rv);
rv = gpiod_line_get_value(line);
line = gpiod_chip_get_line(chip, 7);
TEST_ASSERT_NOT_NULL(line);
- rv = gpiod_line_request_input(line, TEST_CONSUMER, true);
+ rv = gpiod_line_request_input_flags(line, TEST_CONSUMER,
+ GPIOD_REQUEST_ACTIVE_LOW);
TEST_ASSERT_RET_OK(rv);
test_tool_run("gpioinfo", (char *)NULL);
TEST_ASSERT_NOT_NULL(line_0);
TEST_ASSERT_NOT_NULL(line_1);
- status = gpiod_line_request_output(line_0, TEST_CONSUMER, false, 0);
+ status = gpiod_line_request_output(line_0, TEST_CONSUMER, 0);
TEST_ASSERT_RET_OK(status);
- status = gpiod_line_request_output(line_1, TEST_CONSUMER, false, 1);
+ status = gpiod_line_request_output(line_1, TEST_CONSUMER, 1);
TEST_ASSERT_RET_OK(status);
TEST_ASSERT_EQ(gpiod_line_get_value(line_0), 0);
line = gpiod_chip_get_line(chip, 0);
TEST_ASSERT_NOT_NULL(line);
- status = gpiod_line_request_input(line, TEST_CONSUMER, false);
+ status = gpiod_line_request_input(line, TEST_CONSUMER);
TEST_ASSERT_RET_OK(status);
- status = gpiod_line_request_input(line, TEST_CONSUMER, false);
+ status = gpiod_line_request_input(line, TEST_CONSUMER);
TEST_ASSERT_NOTEQ(status, 0);
TEST_ASSERT_EQ(errno, EBUSY);
}
TEST_ASSERT_NULL(gpiod_line_consumer(line));
- status = gpiod_line_request_input(line, TEST_CONSUMER, false);
+ status = gpiod_line_request_input(line, TEST_CONSUMER);
TEST_ASSERT_RET_OK(status);
TEST_ASSERT(!gpiod_line_needs_update(line));
TEST_ASSERT_NULL(gpiod_line_consumer(line));
status = gpiod_line_request_input(line,
- "consumer string over 32 characters long",
- false);
+ "consumer string over 32 characters long");
TEST_ASSERT_RET_OK(status);
TEST_ASSERT(!gpiod_line_needs_update(line));
line = gpiod_chip_get_line(chip, 2);
TEST_ASSERT_NOT_NULL(line);
- status = gpiod_line_request_output(line, TEST_CONSUMER, false, 0);
+ status = gpiod_line_request_output(line, TEST_CONSUMER, 0);
TEST_ASSERT_RET_OK(status);
TEST_ASSERT_RET_OK(gpiod_line_set_value(line, 1));
line = gpiod_chip_get_line(chip, 5);
TEST_ASSERT_NOT_NULL(line);
- status = gpiod_line_request_output(line, TEST_CONSUMER, false, 0);
+ status = gpiod_line_request_output(line, TEST_CONSUMER, 0);
TEST_ASSERT_RET_OK(status);
TEST_ASSERT_EQ(gpiod_line_direction(line), GPIOD_DIRECTION_OUTPUT);
gpiod_line_release(line);
- status = gpiod_line_request_input(line, TEST_CONSUMER, false);
+ status = gpiod_line_request_input(line, TEST_CONSUMER);
TEST_ASSERT_RET_OK(status);
TEST_ASSERT_EQ(gpiod_line_direction(line), GPIOD_DIRECTION_INPUT);
line = gpiod_chip_get_line(chip, 5);
TEST_ASSERT_NOT_NULL(line);
- status = gpiod_line_request_input(line, TEST_CONSUMER, false);
+ status = gpiod_line_request_input(line, TEST_CONSUMER);
TEST_ASSERT_RET_OK(status);
TEST_ASSERT_EQ(gpiod_line_active_state(line), GPIOD_ACTIVE_STATE_HIGH);
gpiod_line_release(line);
- status = gpiod_line_request_input(line, TEST_CONSUMER, true);
+ status = gpiod_line_request_input_flags(line, TEST_CONSUMER,
+ GPIOD_REQUEST_ACTIVE_LOW);
TEST_ASSERT_RET_OK(status);
TEST_ASSERT_EQ(gpiod_line_direction(line), GPIOD_DIRECTION_INPUT);