From: Bartosz Golaszewski Date: Fri, 17 Nov 2017 16:49:37 +0000 (+0100) Subject: core: change the prefix for line request flags X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=57ecc14c4d7f6408062403484f800f78c0dda25c;p=qemu-gpiodev%2Flibgpiod.git core: change the prefix for line request flags Make it clear that these are flags and that more than one can be used simultaneously. Signed-off-by: Bartosz Golaszewski --- diff --git a/include/gpiod.h b/include/gpiod.h index 747a226..bef018f 100644 --- a/include/gpiod.h +++ b/include/gpiod.h @@ -664,11 +664,11 @@ enum { * @brief Miscellaneous GPIO request flags. */ enum { - GPIOD_LINE_REQUEST_OPEN_DRAIN = GPIOD_BIT(0), + GPIOD_LINE_REQUEST_FLAG_OPEN_DRAIN = GPIOD_BIT(0), /**< The line is an open-drain port. */ - GPIOD_LINE_REQUEST_OPEN_SOURCE = GPIOD_BIT(1), + GPIOD_LINE_REQUEST_FLAG_OPEN_SOURCE = GPIOD_BIT(1), /**< The line is an open-source port. */ - GPIOD_LINE_REQUEST_ACTIVE_LOW = GPIOD_BIT(2), + GPIOD_LINE_REQUEST_FLAG_ACTIVE_LOW = GPIOD_BIT(2), /**< The active state of the line is low (high is the default). */ }; diff --git a/src/lib/core.c b/src/lib/core.c index 90666c5..c17dffa 100644 --- a/src/lib/core.c +++ b/src/lib/core.c @@ -337,19 +337,19 @@ static int line_request_values(struct gpiod_line_bulk *bulk, int rv, fd; if ((config->request_type != GPIOD_LINE_REQUEST_DIRECTION_OUTPUT) && - (config->flags & (GPIOD_LINE_REQUEST_OPEN_DRAIN | - GPIOD_LINE_REQUEST_OPEN_SOURCE))) { + (config->flags & (GPIOD_LINE_REQUEST_FLAG_OPEN_DRAIN | + GPIOD_LINE_REQUEST_FLAG_OPEN_SOURCE))) { errno = EINVAL; return -1; } memset(&req, 0, sizeof(req)); - if (config->flags & GPIOD_LINE_REQUEST_OPEN_DRAIN) + if (config->flags & GPIOD_LINE_REQUEST_FLAG_OPEN_DRAIN) req.flags |= GPIOHANDLE_REQUEST_OPEN_DRAIN; - if (config->flags & GPIOD_LINE_REQUEST_OPEN_SOURCE) + if (config->flags & GPIOD_LINE_REQUEST_FLAG_OPEN_SOURCE) req.flags |= GPIOHANDLE_REQUEST_OPEN_SOURCE; - if (config->flags & GPIOD_LINE_REQUEST_ACTIVE_LOW) + if (config->flags & GPIOD_LINE_REQUEST_FLAG_ACTIVE_LOW) req.flags |= GPIOHANDLE_REQUEST_ACTIVE_LOW; if (config->request_type == GPIOD_LINE_REQUEST_DIRECTION_INPUT) @@ -401,11 +401,11 @@ static int line_request_event_single(struct gpiod_line *line, req.lineoffset = gpiod_line_offset(line); req.handleflags |= GPIOHANDLE_REQUEST_INPUT; - if (config->flags & GPIOD_LINE_REQUEST_OPEN_DRAIN) + if (config->flags & GPIOD_LINE_REQUEST_FLAG_OPEN_DRAIN) req.handleflags |= GPIOHANDLE_REQUEST_OPEN_DRAIN; - if (config->flags & GPIOD_LINE_REQUEST_OPEN_SOURCE) + if (config->flags & GPIOD_LINE_REQUEST_FLAG_OPEN_SOURCE) req.handleflags |= GPIOHANDLE_REQUEST_OPEN_SOURCE; - if (config->flags & GPIOD_LINE_REQUEST_ACTIVE_LOW) + if (config->flags & GPIOD_LINE_REQUEST_FLAG_ACTIVE_LOW) req.handleflags |= GPIOHANDLE_REQUEST_ACTIVE_LOW; if (config->request_type == GPIOD_LINE_REQUEST_EVENT_RISING_EDGE) diff --git a/src/lib/simple.c b/src/lib/simple.c index b77088a..866bcd5 100644 --- a/src/lib/simple.c +++ b/src/lib/simple.c @@ -62,7 +62,7 @@ int gpiod_simple_get_value_multiple(const char *device, gpiod_line_bulk_add(&bulk, line); } - flags = active_low ? GPIOD_LINE_REQUEST_ACTIVE_LOW : 0; + flags = active_low ? GPIOD_LINE_REQUEST_FLAG_ACTIVE_LOW : 0; status = gpiod_line_request_bulk_input_flags(&bulk, consumer, flags); if (status < 0) { @@ -119,7 +119,7 @@ int gpiod_simple_set_value_multiple(const char *device, gpiod_line_bulk_add(&bulk, line); } - flags = active_low ? GPIOD_LINE_REQUEST_ACTIVE_LOW : 0; + flags = active_low ? GPIOD_LINE_REQUEST_FLAG_ACTIVE_LOW : 0; status = gpiod_line_request_bulk_output_flags(&bulk, consumer, flags, values); @@ -229,7 +229,7 @@ int gpiod_simple_event_loop_multiple(const char *device, gpiod_line_bulk_add(&bulk, line); } - flags = active_low ? GPIOD_LINE_REQUEST_ACTIVE_LOW : 0; + flags = active_low ? GPIOD_LINE_REQUEST_FLAG_ACTIVE_LOW : 0; rv = gpiod_line_request_bulk_both_edges_events_flags(&bulk, consumer, flags); diff --git a/tests/tests-event.c b/tests/tests-event.c index 95a3d01..4c0be5c 100644 --- a/tests/tests-event.c +++ b/tests/tests-event.c @@ -116,7 +116,7 @@ static void event_rising_edge_active_low(void) TEST_ASSERT_NOT_NULL(line); rv = gpiod_line_request_rising_edge_events_flags(line, TEST_CONSUMER, - GPIOD_LINE_REQUEST_ACTIVE_LOW); + GPIOD_LINE_REQUEST_FLAG_ACTIVE_LOW); TEST_ASSERT_RET_OK(rv); test_set_event(0, 7, TEST_EVENT_RISING, 100); diff --git a/tests/tests-gpioinfo.c b/tests/tests-gpioinfo.c index 8f0babe..7212ed7 100644 --- a/tests/tests-gpioinfo.c +++ b/tests/tests-gpioinfo.c @@ -50,7 +50,7 @@ static void gpioinfo_dump_all_chips_one_exported(void) TEST_ASSERT_NOT_NULL(line); rv = gpiod_line_request_input_flags(line, TEST_CONSUMER, - GPIOD_LINE_REQUEST_ACTIVE_LOW); + GPIOD_LINE_REQUEST_FLAG_ACTIVE_LOW); TEST_ASSERT_RET_OK(rv); test_tool_run("gpioinfo", (char *)NULL); diff --git a/tests/tests-line.c b/tests/tests-line.c index 0acb0c8..2071e8e 100644 --- a/tests/tests-line.c +++ b/tests/tests-line.c @@ -435,7 +435,7 @@ static void line_active_state(void) gpiod_line_release(line); status = gpiod_line_request_input_flags(line, TEST_CONSUMER, - GPIOD_LINE_REQUEST_ACTIVE_LOW); + GPIOD_LINE_REQUEST_FLAG_ACTIVE_LOW); TEST_ASSERT_RET_OK(status); TEST_ASSERT_EQ(gpiod_line_direction(line), GPIOD_LINE_DIRECTION_INPUT); @@ -463,7 +463,7 @@ static void line_misc_flags(void) config.request_type = GPIOD_LINE_REQUEST_DIRECTION_OUTPUT; config.consumer = TEST_CONSUMER; - config.flags = GPIOD_LINE_REQUEST_OPEN_DRAIN; + config.flags = GPIOD_LINE_REQUEST_FLAG_OPEN_DRAIN; status = gpiod_line_request(line, &config, 0); TEST_ASSERT_RET_OK(status); @@ -474,7 +474,7 @@ static void line_misc_flags(void) gpiod_line_release(line); - config.flags = GPIOD_LINE_REQUEST_OPEN_SOURCE; + config.flags = GPIOD_LINE_REQUEST_FLAG_OPEN_SOURCE; status = gpiod_line_request(line, &config, 0); TEST_ASSERT_RET_OK(status); @@ -500,12 +500,12 @@ static void line_open_source_open_drain_input_invalid(void) TEST_ASSERT_NOT_NULL(line); rv = gpiod_line_request_input_flags(line, TEST_CONSUMER, - GPIOD_LINE_REQUEST_OPEN_DRAIN); + GPIOD_LINE_REQUEST_FLAG_OPEN_DRAIN); TEST_ASSERT_EQ(rv, -1); TEST_ASSERT_ERRNO_IS(EINVAL); rv = gpiod_line_request_input_flags(line, TEST_CONSUMER, - GPIOD_LINE_REQUEST_OPEN_SOURCE); + GPIOD_LINE_REQUEST_FLAG_OPEN_SOURCE); TEST_ASSERT_EQ(rv, -1); TEST_ASSERT_ERRNO_IS(EINVAL); }