Prefix all constants used by line functions with GPIOD_LINE_.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
* @brief Available types of requests.
*/
enum {
- GPIOD_REQUEST_DIRECTION_AS_IS,
+ GPIOD_LINE_REQUEST_DIRECTION_AS_IS,
/**< Request the line(s), but don't change current direction. */
- GPIOD_REQUEST_DIRECTION_INPUT,
+ GPIOD_LINE_REQUEST_DIRECTION_INPUT,
/**< Request the line(s) for reading the GPIO line state. */
- GPIOD_REQUEST_DIRECTION_OUTPUT,
+ GPIOD_LINE_REQUEST_DIRECTION_OUTPUT,
/**< Request the line(s) for setting the GPIO line state. */
- GPIOD_REQUEST_EVENT_FALLING_EDGE,
+ GPIOD_LINE_REQUEST_EVENT_FALLING_EDGE,
/**< Monitor both types of events. */
- GPIOD_REQUEST_EVENT_RISING_EDGE,
+ GPIOD_LINE_REQUEST_EVENT_RISING_EDGE,
/**< Only watch rising edge events. */
- GPIOD_REQUEST_EVENT_BOTH_EDGES,
+ GPIOD_LINE_REQUEST_EVENT_BOTH_EDGES,
/**< Only watch falling edge events. */
};
* @brief Miscellaneous GPIO flags.
*/
enum {
- GPIOD_REQUEST_OPEN_DRAIN = GPIOD_BIT(0),
+ GPIOD_LINE_REQUEST_OPEN_DRAIN = GPIOD_BIT(0),
/**< The line is an open-drain port. */
- GPIOD_REQUEST_OPEN_SOURCE = GPIOD_BIT(1),
+ GPIOD_LINE_REQUEST_OPEN_SOURCE = GPIOD_BIT(1),
/**< The line is an open-source port. */
- GPIOD_REQUEST_ACTIVE_LOW = GPIOD_BIT(2),
+ GPIOD_LINE_REQUEST_ACTIVE_LOW = GPIOD_BIT(2),
/**< The active state of the line is low (high is the default). */
};
* @brief Possible direction settings.
*/
enum {
- GPIOD_DIRECTION_INPUT,
+ GPIOD_LINE_DIRECTION_INPUT,
/**< Direction is input - we're reading the state of a GPIO line. */
- GPIOD_DIRECTION_OUTPUT,
+ GPIOD_LINE_DIRECTION_OUTPUT,
/**< Direction is output - we're driving the GPIO line. */
};
* @brief Possible active state settings.
*/
enum {
- GPIOD_ACTIVE_STATE_HIGH,
+ GPIOD_LINE_ACTIVE_STATE_HIGH,
/**< The active state of a GPIO is active-high. */
- GPIOD_ACTIVE_STATE_LOW,
+ GPIOD_LINE_ACTIVE_STATE_LOW,
/**< The active state of a GPIO is active-low. */
};
* @brief Event types.
*/
enum {
- GPIOD_EVENT_RISING_EDGE,
+ GPIOD_LINE_EVENT_RISING_EDGE,
/**< Rising edge event. */
- GPIOD_EVENT_FALLING_EDGE,
+ GPIOD_LINE_EVENT_FALLING_EDGE,
/**< Falling edge event. */
};
int gpiod_line_direction(struct gpiod_line *line)
{
- return line->info.flags & GPIOLINE_FLAG_IS_OUT ? GPIOD_DIRECTION_OUTPUT
- : GPIOD_DIRECTION_INPUT;
+ return line->info.flags & GPIOLINE_FLAG_IS_OUT
+ ? GPIOD_LINE_DIRECTION_OUTPUT
+ : GPIOD_LINE_DIRECTION_INPUT;
}
int gpiod_line_active_state(struct gpiod_line *line)
{
return line->info.flags & GPIOLINE_FLAG_ACTIVE_LOW
- ? GPIOD_ACTIVE_STATE_LOW
- : GPIOD_ACTIVE_STATE_HIGH;
+ ? GPIOD_LINE_ACTIVE_STATE_LOW
+ : GPIOD_LINE_ACTIVE_STATE_HIGH;
}
bool gpiod_line_is_used(struct gpiod_line *line)
req = &handle->request;
- if (config->flags & GPIOD_REQUEST_OPEN_DRAIN)
+ if (config->flags & GPIOD_LINE_REQUEST_OPEN_DRAIN)
req->flags |= GPIOHANDLE_REQUEST_OPEN_DRAIN;
- if (config->flags & GPIOD_REQUEST_OPEN_SOURCE)
+ if (config->flags & GPIOD_LINE_REQUEST_OPEN_SOURCE)
req->flags |= GPIOHANDLE_REQUEST_OPEN_SOURCE;
- if (config->flags & GPIOD_REQUEST_ACTIVE_LOW)
+ if (config->flags & GPIOD_LINE_REQUEST_ACTIVE_LOW)
req->flags |= GPIOHANDLE_REQUEST_ACTIVE_LOW;
- if (config->request_type == GPIOD_REQUEST_DIRECTION_INPUT)
+ if (config->request_type == GPIOD_LINE_REQUEST_DIRECTION_INPUT)
req->flags |= GPIOHANDLE_REQUEST_INPUT;
- else if (config->request_type == GPIOD_REQUEST_DIRECTION_OUTPUT)
+ else if (config->request_type == GPIOD_LINE_REQUEST_DIRECTION_OUTPUT)
req->flags |= GPIOHANDLE_REQUEST_OUTPUT;
req->lines = bulk->num_lines;
for (i = 0; i < bulk->num_lines; i++) {
req->lineoffsets[i] = gpiod_line_offset(bulk->lines[i]);
- if (config->request_type == GPIOD_REQUEST_DIRECTION_OUTPUT)
+ if (config->request_type == GPIOD_LINE_REQUEST_DIRECTION_OUTPUT)
req->default_values[i] = !!default_vals[i];
}
req->lineoffset = gpiod_line_offset(line);
req->handleflags |= GPIOHANDLE_REQUEST_INPUT;
- if (config->flags & GPIOD_REQUEST_OPEN_DRAIN)
+ if (config->flags & GPIOD_LINE_REQUEST_OPEN_DRAIN)
req->handleflags |= GPIOHANDLE_REQUEST_OPEN_DRAIN;
- if (config->flags & GPIOD_REQUEST_OPEN_SOURCE)
+ if (config->flags & GPIOD_LINE_REQUEST_OPEN_SOURCE)
req->handleflags |= GPIOHANDLE_REQUEST_OPEN_SOURCE;
- if (config->flags & GPIOD_REQUEST_ACTIVE_LOW)
+ if (config->flags & GPIOD_LINE_REQUEST_ACTIVE_LOW)
req->handleflags |= GPIOHANDLE_REQUEST_ACTIVE_LOW;
- if (config->request_type == GPIOD_REQUEST_EVENT_RISING_EDGE)
+ if (config->request_type == GPIOD_LINE_REQUEST_EVENT_RISING_EDGE)
req->eventflags |= GPIOEVENT_REQUEST_RISING_EDGE;
- else if (config->request_type == GPIOD_REQUEST_EVENT_FALLING_EDGE)
+ else if (config->request_type == GPIOD_LINE_REQUEST_EVENT_FALLING_EDGE)
req->eventflags |= GPIOEVENT_REQUEST_FALLING_EDGE;
- else if (config->request_type == GPIOD_REQUEST_EVENT_BOTH_EDGES)
+ else if (config->request_type == GPIOD_LINE_REQUEST_EVENT_BOTH_EDGES)
req->eventflags |= GPIOEVENT_REQUEST_BOTH_EDGES;
rv = ioctl(line->chip->fd, GPIO_GET_LINEEVENT_IOCTL, req);
{
struct gpiod_line_request_config config = {
.consumer = consumer,
- .request_type = GPIOD_REQUEST_DIRECTION_INPUT,
+ .request_type = GPIOD_LINE_REQUEST_DIRECTION_INPUT,
};
return gpiod_line_request(line, &config, 0);
{
struct gpiod_line_request_config config = {
.consumer = consumer,
- .request_type = GPIOD_REQUEST_DIRECTION_OUTPUT,
+ .request_type = GPIOD_LINE_REQUEST_DIRECTION_OUTPUT,
};
return gpiod_line_request(line, &config, default_val);
{
struct gpiod_line_request_config config = {
.consumer = consumer,
- .request_type = GPIOD_REQUEST_DIRECTION_INPUT,
+ .request_type = GPIOD_LINE_REQUEST_DIRECTION_INPUT,
.flags = flags,
};
{
struct gpiod_line_request_config config = {
.consumer = consumer,
- .request_type = GPIOD_REQUEST_DIRECTION_OUTPUT,
+ .request_type = GPIOD_LINE_REQUEST_DIRECTION_OUTPUT,
.flags = flags,
};
const char *consumer)
{
return line_event_request_type(line, consumer, 0,
- GPIOD_REQUEST_EVENT_RISING_EDGE);
+ GPIOD_LINE_REQUEST_EVENT_RISING_EDGE);
}
int gpiod_line_request_falling_edge_events(struct gpiod_line *line,
const char *consumer)
{
return line_event_request_type(line, consumer, 0,
- GPIOD_REQUEST_EVENT_FALLING_EDGE);
+ GPIOD_LINE_REQUEST_EVENT_FALLING_EDGE);
}
int gpiod_line_request_both_edges_events(struct gpiod_line *line,
const char *consumer)
{
return line_event_request_type(line, consumer, 0,
- GPIOD_REQUEST_EVENT_BOTH_EDGES);
+ GPIOD_LINE_REQUEST_EVENT_BOTH_EDGES);
}
int gpiod_line_request_rising_edge_events_flags(struct gpiod_line *line,
int flags)
{
return line_event_request_type(line, consumer, flags,
- GPIOD_REQUEST_EVENT_RISING_EDGE);
+ GPIOD_LINE_REQUEST_EVENT_RISING_EDGE);
}
int gpiod_line_request_falling_edge_events_flags(struct gpiod_line *line,
int flags)
{
return line_event_request_type(line, consumer, flags,
- GPIOD_REQUEST_EVENT_FALLING_EDGE);
+ GPIOD_LINE_REQUEST_EVENT_FALLING_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_BOTH_EDGES);
+ GPIOD_LINE_REQUEST_EVENT_BOTH_EDGES);
}
static bool line_request_is_direction(int request)
{
- return request == GPIOD_REQUEST_DIRECTION_AS_IS
- || request == GPIOD_REQUEST_DIRECTION_INPUT
- || request == GPIOD_REQUEST_DIRECTION_OUTPUT;
+ return request == GPIOD_LINE_REQUEST_DIRECTION_AS_IS
+ || request == GPIOD_LINE_REQUEST_DIRECTION_INPUT
+ || request == GPIOD_LINE_REQUEST_DIRECTION_OUTPUT;
}
static bool line_request_is_events(int request)
{
- return request == GPIOD_REQUEST_EVENT_FALLING_EDGE
- || request == GPIOD_REQUEST_EVENT_RISING_EDGE
- || request == GPIOD_REQUEST_EVENT_BOTH_EDGES;
+ return request == GPIOD_LINE_REQUEST_EVENT_FALLING_EDGE
+ || request == GPIOD_LINE_REQUEST_EVENT_RISING_EDGE
+ || request == GPIOD_LINE_REQUEST_EVENT_BOTH_EDGES;
}
int gpiod_line_request_bulk(struct gpiod_line_bulk *bulk,
{
struct gpiod_line_request_config config = {
.consumer = consumer,
- .request_type = GPIOD_REQUEST_DIRECTION_INPUT,
+ .request_type = GPIOD_LINE_REQUEST_DIRECTION_INPUT,
};
return gpiod_line_request_bulk(bulk, &config, 0);
{
struct gpiod_line_request_config config = {
.consumer = consumer,
- .request_type = GPIOD_REQUEST_DIRECTION_OUTPUT,
+ .request_type = GPIOD_LINE_REQUEST_DIRECTION_OUTPUT,
};
return gpiod_line_request_bulk(bulk, &config, default_vals);
const char *consumer)
{
return line_event_request_type_bulk(bulk, consumer, 0,
- GPIOD_REQUEST_EVENT_RISING_EDGE);
+ GPIOD_LINE_REQUEST_EVENT_RISING_EDGE);
}
int gpiod_line_request_bulk_falling_edge_events(struct gpiod_line_bulk *bulk,
const char *consumer)
{
return line_event_request_type_bulk(bulk, consumer, 0,
- GPIOD_REQUEST_EVENT_FALLING_EDGE);
+ GPIOD_LINE_REQUEST_EVENT_FALLING_EDGE);
}
int gpiod_line_request_bulk_both_edges_events(struct gpiod_line_bulk *bulk,
const char *consumer)
{
return line_event_request_type_bulk(bulk, consumer, 0,
- GPIOD_REQUEST_EVENT_BOTH_EDGES);
+ GPIOD_LINE_REQUEST_EVENT_BOTH_EDGES);
}
int gpiod_line_request_bulk_input_flags(struct gpiod_line_bulk *bulk,
{
struct gpiod_line_request_config config = {
.consumer = consumer,
- .request_type = GPIOD_REQUEST_DIRECTION_INPUT,
+ .request_type = GPIOD_LINE_REQUEST_DIRECTION_INPUT,
.flags = flags,
};
{
struct gpiod_line_request_config config = {
.consumer = consumer,
- .request_type = GPIOD_REQUEST_DIRECTION_OUTPUT,
+ .request_type = GPIOD_LINE_REQUEST_DIRECTION_OUTPUT,
.flags = flags,
};
const char *consumer, int flags)
{
return line_event_request_type_bulk(bulk, consumer, flags,
- GPIOD_REQUEST_EVENT_RISING_EDGE);
+ GPIOD_LINE_REQUEST_EVENT_RISING_EDGE);
}
int gpiod_line_request_bulk_falling_edge_events_flags(
const char *consumer, int flags)
{
return line_event_request_type_bulk(bulk, consumer, flags,
- GPIOD_REQUEST_EVENT_FALLING_EDGE);
+ GPIOD_LINE_REQUEST_EVENT_FALLING_EDGE);
}
int gpiod_line_request_bulk_both_edges_events_flags(
const char *consumer, int flags)
{
return line_event_request_type_bulk(bulk, consumer, flags,
- GPIOD_REQUEST_EVENT_BOTH_EDGES);
+ GPIOD_LINE_REQUEST_EVENT_BOTH_EDGES);
}
void gpiod_line_release(struct gpiod_line *line)
}
event->event_type = evdata.id == GPIOEVENT_EVENT_RISING_EDGE
- ? GPIOD_EVENT_RISING_EDGE
- : GPIOD_EVENT_FALLING_EDGE;
+ ? GPIOD_LINE_EVENT_RISING_EDGE
+ : GPIOD_LINE_EVENT_FALLING_EDGE;
event->ts.tv_sec = evdata.timestamp / 1000000000ULL;
event->ts.tv_nsec = evdata.timestamp % 1000000000ULL;
gpiod_line_bulk_add(&bulk, line);
}
- flags = active_low ? GPIOD_REQUEST_ACTIVE_LOW : 0;
+ flags = active_low ? GPIOD_LINE_REQUEST_ACTIVE_LOW : 0;
status = gpiod_line_request_bulk_input_flags(&bulk, consumer, flags);
if (status < 0) {
gpiod_line_bulk_add(&bulk, line);
}
- flags = active_low ? GPIOD_REQUEST_ACTIVE_LOW : 0;
+ flags = active_low ? GPIOD_LINE_REQUEST_ACTIVE_LOW : 0;
status = gpiod_line_request_bulk_output_flags(&bulk, consumer,
flags, values);
gpiod_line_bulk_add(&bulk, line);
}
- flags = active_low ? GPIOD_REQUEST_ACTIVE_LOW : 0;
+ flags = active_low ? GPIOD_LINE_REQUEST_ACTIVE_LOW : 0;
ret = gpiod_line_request_bulk_both_edges_events_flags(&bulk,
consumer, flags);
if (ret < 0)
goto out;
- evtype = event.event_type == GPIOD_EVENT_RISING_EDGE
- ? GPIOD_SIMPLE_EVENT_CB_RISING_EDGE
- : GPIOD_SIMPLE_EVENT_CB_FALLING_EDGE;
+ if (event.event_type == GPIOD_LINE_EVENT_RISING_EDGE)
+ evtype = GPIOD_SIMPLE_EVENT_CB_RISING_EDGE;
+ else
+ evtype = GPIOD_SIMPLE_EVENT_CB_FALLING_EDGE;
line_offset = offsets[event_offset];
}
: prinfo(&of, 12, "unused");
printf(" ");
- prinfo(&of, 8, "%s ", direction == GPIOD_DIRECTION_INPUT
- ? "input" : "output");
+ prinfo(&of, 8, "%s ", direction == GPIOD_LINE_DIRECTION_INPUT
+ ? "input" : "output");
prinfo(&of, 13, "%s ",
- active_state == GPIOD_ACTIVE_STATE_LOW
- ? "active-low"
- : "active-high");
+ active_state == GPIOD_LINE_ACTIVE_STATE_LOW
+ ? "active-low"
+ : "active-high");
flag_printed = false;
for (i = 0; i < ARRAY_SIZE(flags); i++) {
rv = gpiod_line_event_read(line, &ev);
TEST_ASSERT_RET_OK(rv);
- TEST_ASSERT_EQ(ev.event_type, GPIOD_EVENT_RISING_EDGE);
+ TEST_ASSERT_EQ(ev.event_type, GPIOD_LINE_EVENT_RISING_EDGE);
}
TEST_DEFINE(event_rising_edge_good,
"events - receive single rising edge event",
rv = gpiod_line_event_read(line, &ev);
TEST_ASSERT_RET_OK(rv);
- TEST_ASSERT_EQ(ev.event_type, GPIOD_EVENT_FALLING_EDGE);
+ TEST_ASSERT_EQ(ev.event_type, GPIOD_LINE_EVENT_FALLING_EDGE);
}
TEST_DEFINE(event_falling_edge_good,
"events - receive single falling edge event",
TEST_ASSERT_NOT_NULL(line);
rv = gpiod_line_request_rising_edge_events_flags(line, TEST_CONSUMER,
- GPIOD_REQUEST_ACTIVE_LOW);
+ GPIOD_LINE_REQUEST_ACTIVE_LOW);
TEST_ASSERT_RET_OK(rv);
test_set_event(0, 7, TEST_EVENT_RISING, 100);
rv = gpiod_line_event_read(line, &ev);
TEST_ASSERT_RET_OK(rv);
- TEST_ASSERT_EQ(ev.event_type, GPIOD_EVENT_RISING_EDGE);
+ TEST_ASSERT_EQ(ev.event_type, GPIOD_LINE_EVENT_RISING_EDGE);
}
TEST_DEFINE(event_rising_edge_active_low,
"events - single rising edge event with low active state",
rv = gpiod_line_event_read(line, &ev);
TEST_ASSERT_RET_OK(rv);
- TEST_ASSERT_EQ(ev.event_type, GPIOD_EVENT_RISING_EDGE);
+ TEST_ASSERT_EQ(ev.event_type, GPIOD_LINE_EVENT_RISING_EDGE);
rv = gpiod_line_get_value(line);
TEST_ASSERT_EQ(rv, 1);
TEST_ASSERT_NOT_NULL(line);
rv = gpiod_line_request_input_flags(line, TEST_CONSUMER,
- GPIOD_REQUEST_ACTIVE_LOW);
+ GPIOD_LINE_REQUEST_ACTIVE_LOW);
TEST_ASSERT_RET_OK(rv);
test_tool_run("gpioinfo", (char *)NULL);
gpiod_line_bulk_add(&bulk, lineB1);
req.consumer = TEST_CONSUMER;
- req.request_type = GPIOD_REQUEST_DIRECTION_INPUT;
- req.flags = GPIOD_ACTIVE_STATE_HIGH;
+ req.request_type = GPIOD_LINE_REQUEST_DIRECTION_INPUT;
+ req.flags = GPIOD_LINE_ACTIVE_STATE_HIGH;
status = gpiod_line_request_bulk(&bulk, &req, NULL);
TEST_ASSERT_NOTEQ(status, 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);
+ TEST_ASSERT_EQ(gpiod_line_direction(line), GPIOD_LINE_DIRECTION_OUTPUT);
gpiod_line_release(line);
status = gpiod_line_request_input(line, TEST_CONSUMER);
TEST_ASSERT_RET_OK(status);
- TEST_ASSERT_EQ(gpiod_line_direction(line), GPIOD_DIRECTION_INPUT);
+ TEST_ASSERT_EQ(gpiod_line_direction(line), GPIOD_LINE_DIRECTION_INPUT);
}
TEST_DEFINE(line_direction,
"gpiod_line_direction() - set & get",
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);
+ TEST_ASSERT_EQ(gpiod_line_active_state(line),
+ GPIOD_LINE_ACTIVE_STATE_HIGH);
gpiod_line_release(line);
status = gpiod_line_request_input_flags(line, TEST_CONSUMER,
- GPIOD_REQUEST_ACTIVE_LOW);
+ GPIOD_LINE_REQUEST_ACTIVE_LOW);
TEST_ASSERT_RET_OK(status);
- TEST_ASSERT_EQ(gpiod_line_direction(line), GPIOD_DIRECTION_INPUT);
+ TEST_ASSERT_EQ(gpiod_line_direction(line), GPIOD_LINE_DIRECTION_INPUT);
}
TEST_DEFINE(line_active_state,
"gpiod_line_active_state() - set & get",
TEST_ASSERT_FALSE(gpiod_line_is_open_drain(line));
TEST_ASSERT_FALSE(gpiod_line_is_open_source(line));
- config.request_type = GPIOD_REQUEST_DIRECTION_INPUT;
+ config.request_type = GPIOD_LINE_REQUEST_DIRECTION_INPUT;
config.consumer = TEST_CONSUMER;
- config.flags = GPIOD_REQUEST_OPEN_DRAIN;
+ config.flags = GPIOD_LINE_REQUEST_OPEN_DRAIN;
status = gpiod_line_request(line, &config, 0);
TEST_ASSERT_RET_OK(status);
gpiod_line_release(line);
- config.flags = GPIOD_REQUEST_OPEN_SOURCE;
+ config.flags = GPIOD_LINE_REQUEST_OPEN_SOURCE;
status = gpiod_line_request(line, &config, 0);
TEST_ASSERT_RET_OK(status);
line = gpiod_chip_get_line(chip, 2);
TEST_ASSERT_NOT_NULL(line);
- config.request_type = GPIOD_REQUEST_DIRECTION_INPUT;
+ config.request_type = GPIOD_LINE_REQUEST_DIRECTION_INPUT;
config.consumer = NULL;
config.flags = 0;
* Internally we use different structures for event requests, so we
* need to test that explicitly too.
*/
- config.request_type = GPIOD_REQUEST_EVENT_BOTH_EDGES;
+ config.request_type = GPIOD_LINE_REQUEST_EVENT_BOTH_EDGES;
rv = gpiod_line_request(line, &config, 0);
TEST_ASSERT_RET_OK(rv);
line = gpiod_chip_get_line(chip, 2);
TEST_ASSERT_NOT_NULL(line);
- config.request_type = GPIOD_REQUEST_DIRECTION_INPUT;
+ config.request_type = GPIOD_LINE_REQUEST_DIRECTION_INPUT;
config.consumer = "";
config.flags = 0;
* Internally we use different structures for event requests, so we
* need to test that explicitly too.
*/
- config.request_type = GPIOD_REQUEST_EVENT_BOTH_EDGES;
+ config.request_type = GPIOD_LINE_REQUEST_EVENT_BOTH_EDGES;
rv = gpiod_line_request(line, &config, 0);
TEST_ASSERT_RET_OK(rv);