Bartosz Golaszewski [Sat, 4 Nov 2017 21:37:38 +0000 (22:37 +0100)]
tests: gpioinfo: don't use static names for GPIO chips
We need to construct the pattern strings using the names supplied by
the testing framework - otherwise we may end up getting false
negatives from these test cases if the chip layout in the system is
different than expected.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Fri, 3 Nov 2017 17:12:50 +0000 (18:12 +0100)]
doc: update the documentation for events and iterators
Various documentation updates for iterator and event routines.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Tue, 31 Oct 2017 15:00:21 +0000 (16:00 +0100)]
iter: use scandir() for chip iterators
Using scandir() instead of opendir() allows us to scan for all
gpiochip devices already when creating the iterator. This simplifies
the code and doesn't require keeping the directory open when
iterating.
Storing the array of all found GPIO chips will also make it easier if
we ever want to implement a reverse iterator (e.g. for C++ bindings).
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Tue, 31 Oct 2017 09:34:21 +0000 (10:34 +0100)]
NEWS: updates for v0.3.2
Add release notes for libgpiod v0.3.2.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Thu, 26 Oct 2017 12:12:51 +0000 (14:12 +0200)]
build: tools: use absolute path in LDADD
Specify the path to libgpiod starting from the top project directory.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Wed, 25 Oct 2017 18:38:01 +0000 (20:38 +0200)]
core: simplify consumer, label & name strings handling
The separate buffers make the code less readable for no real benefit.
Remove them and simplify the strings handling. Also: improve the way
we're handling the chip names and labels.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Tue, 24 Oct 2017 12:48:54 +0000 (14:48 +0200)]
doc: minor fix for line bulk loop macros
Make it clear in the @brief section what the difference is between the
two variants.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Tue, 24 Oct 2017 12:46:24 +0000 (14:46 +0200)]
doc: improvements for the chip operations
Tweak the docs for the low-level chip API a bit.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Tue, 24 Oct 2017 12:25:02 +0000 (14:25 +0200)]
helpers: set errno in gpiod_chip_open_by_label()
If a GPIO chip with given label cannot be found but no other error
occurred, set errno to ENOENT before returning a NULL pointer.
Update the relevant test case.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Tue, 24 Oct 2017 09:31:16 +0000 (11:31 +0200)]
doc: extend the documentation of the simple API
Fix some minor issues and tweak the style and doxygen markup.
Describe in detail the way the simple event loop works.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Tue, 24 Oct 2017 08:20:47 +0000 (10:20 +0200)]
doc: extend the introduction
Add some additional info about the way the API is logically ordered
and a note on error handling.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Tue, 24 Oct 2017 07:28:10 +0000 (09:28 +0200)]
tests: remove the MALLOC attribute from xappend()
The internally called realloc() doesn't have this attribute so we
can't propagate it up the stack.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Mon, 23 Oct 2017 21:32:33 +0000 (23:32 +0200)]
tests: event: new test case
Add a test case which verifies that we can't request line events for
a set of lines if one of them has already been requested for values.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Mon, 23 Oct 2017 21:29:16 +0000 (23:29 +0200)]
core: fix an error path in line event requests
Correctly release already requested lines in case of an error
in line_request_event_single().
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Mon, 23 Oct 2017 10:49:06 +0000 (12:49 +0200)]
core: use gpiod_line_bulk_foreach_line_off()
Use the newly introduced iterator macro wherever there's a need to
access the line offset while looping over a bulk object.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Mon, 23 Oct 2017 10:47:55 +0000 (12:47 +0200)]
core: implement gpiod_line_bulk_foreach_line_off()
Implement a variant of gpiod_line_bulk_foreach_line() which allows to
store the loop state in an integer counter variable.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Fri, 20 Oct 2017 09:27:26 +0000 (11:27 +0200)]
core: code shrink for name, label & consumer strings handling
Create a helper function that implements a uniform way of copying the
info strings from the kernel data structures to gpiod_line and
gpiod_chip objects.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Fri, 20 Oct 2017 09:15:26 +0000 (11:15 +0200)]
core: update line info after requesting the event handle
Just as we do when requesting the regular line handle - update line
info to reflect the changes after the event request.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Fri, 20 Oct 2017 09:00:45 +0000 (11:00 +0200)]
helpers: fix a crash in gpiod_chip_find_line()
The name of a line can be NULL in which case we must check it and skip
the call to strcmp() to avoid a NULL pointer dereference.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Thu, 19 Oct 2017 16:07:09 +0000 (18:07 +0200)]
core: remove kernel data structures from struct gpiod_line
The structures defined in linux/gpio.h use non-standard data types.
Use them only when calling relevant ioctl()s and then copy the
necessary info to separate fields in struct gpiod_line.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Thu, 19 Oct 2017 12:15:15 +0000 (14:15 +0200)]
core: remove kernel data structures from struct gpiod_chip
The structures defined in linux/gpio.h use non-standard data types.
Use them only when calling relevant ioctl()s and then copy the
necessary info to separate fields in struct gpiod_chip.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Thu, 19 Oct 2017 07:33:24 +0000 (09:33 +0200)]
tests: line: coding style fix
Put local variables in correct order - from longest to shortest lines.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Wed, 18 Oct 2017 19:43:43 +0000 (21:43 +0200)]
core: rename a field in struct gpiod_chip
Initially 'cinfo' stood for chip info, but since there's no other
field in this struct to confuse it with, just rename it to 'info'.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Wed, 18 Oct 2017 16:01:53 +0000 (18:01 +0200)]
core: coding style fix
Break the lines according to the kernel coding style.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Wed, 18 Oct 2017 15:56:34 +0000 (17:56 +0200)]
core: move helpers to a separate file
Create a new source file for helper functions that don't need to know
the internal data structures or use any symbols exported by the kernel.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Wed, 18 Oct 2017 15:32:11 +0000 (17:32 +0200)]
core: remove unnecessary setters and getters
These routines only obscure the code. We don't need them for simple,
internal data structures.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Wed, 18 Oct 2017 15:16:07 +0000 (17:16 +0200)]
event: improve gpiod_line_event_get_fd()
Set errno to EINVAL when the user calls this routine for a line
requested for values. Verify correct behavior with a test case.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Wed, 18 Oct 2017 14:39:17 +0000 (16:39 +0200)]
core: move line-related static functions to more suitable places
Group the line state routines together and put line_bulk_is_requested()
next to verify_line_bulk().
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Wed, 18 Oct 2017 14:20:46 +0000 (16:20 +0200)]
core: remove line_set_offset()
This function is not used and should have been static anyway.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Wed, 18 Oct 2017 14:13:34 +0000 (16:13 +0200)]
core: simplify the internal line context structs
The kernel uapi line handle and event request structures are only
needed for relevant ioctl() calls. After that they can be discarded as
all we need is the file descriptor.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Mon, 16 Oct 2017 15:55:55 +0000 (17:55 +0200)]
tests: set errno to 0 before running each test case
Just to make sure we start with a clean environment, set errno
to 0 before running the test callback.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Mon, 16 Oct 2017 15:45:27 +0000 (17:45 +0200)]
core: don't allow OPEN_DRAIN & OPEN_SOURCE flags for input
OPEN_DRAIN and OPEN_SOURCE flags only affect the way we drive a GPIO
line, so they only make sense for output mode.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Sun, 15 Oct 2017 19:01:44 +0000 (21:01 +0200)]
tests: line: fix the misc flags test case
Setting the open-drain or open-source flags for input doesn't make any
sense as these flags are only valid for output mode. This should
actually be checked in the kernel. For now fix the test case.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Wed, 11 Oct 2017 16:33:03 +0000 (18:33 +0200)]
simple-api: modify the order of arguments in simple loop routines
Move the consumer string after the active_low property.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Wed, 11 Oct 2017 16:10:31 +0000 (18:10 +0200)]
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>
Bartosz Golaszewski [Wed, 11 Oct 2017 15:53:32 +0000 (17:53 +0200)]
simple-api: modify the order of arguments in get value routines
Move the consumer string to the end of the argument list as the least
significant option.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Wed, 11 Oct 2017 15:31:24 +0000 (17:31 +0200)]
simple-api: allow the simple event loop callback to indicate an error
Add a new return value for the simple event loop callback which, when
returned, makes the loop function return a negative value indicating
an error.
Include new test cases.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Wed, 11 Oct 2017 15:01:04 +0000 (17:01 +0200)]
simple-api: improve documentation
Mention the meaning of a positive value returned from the polling
callback of the simple event loop routines.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Wed, 11 Oct 2017 13:37:32 +0000 (15:37 +0200)]
simple-api: handle receiving multiple events
Make the simple event loop poll callback capable of signalling to the
caller that more than one event occurred. Make the event loop routine
for multiple lines aware of that so that it reads all the event data
queued up instead of needlessly polling in that case.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Wed, 11 Oct 2017 12:20:54 +0000 (14:20 +0200)]
simple-api: use correct prefixes for callback typedefs
We want to have all simple-api-related symbols prefixed with
gpiod_simple_.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Wed, 11 Oct 2017 09:48:03 +0000 (11:48 +0200)]
core: remove double whitespace
Should be 'return NULL', not 'return NULL'.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Wed, 11 Oct 2017 09:25:17 +0000 (11:25 +0200)]
event: rework gpiod_line_event_wait_bulk()
When monitoring more than one line, it's possible for two or more
events to be queued at the same time in the kernel, so the internal
call to ppoll() will return a value greater than 1. If we always only
read one event at most, we end up calling ppoll() needlessly, as we
already know more events are pending.
Allow gpiod_line_event_wait_bulk() to pass a list of all lines on
which events occurred via a line bulk object.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Tue, 10 Oct 2017 12:02:59 +0000 (14:02 +0200)]
build: fix building with static libraries
We call gpiod_version_string() from tools-common.c but adding
libgpiod.la to LDADD before libtools-common.la makes the linker
discard this symbol as unused.
Invert the LDADD order to fix the static build.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Mon, 9 Oct 2017 21:05:30 +0000 (23:05 +0200)]
gpioset: fix checking mutually exclusive options
Certain options are mutually exclusive but they're checked in a way
that doesn't always guarantee gpioset to bail out. Fix it by checking
the options that don't work together after all command-line parsing is
done.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Wed, 4 Oct 2017 09:23:08 +0000 (11:23 +0200)]
build: fix warnings when building with clang
Clang complains about "missing field 'has_arg' initializer" when
zeroing the last element of the struct option array with "{ 0 }".
Use a complete initializer to fix this warning.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Wed, 4 Oct 2017 07:32:58 +0000 (09:32 +0200)]
core: use line bulk accessors
Use provided routines for retrieving the line handles from line bulk
objects.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Wed, 4 Oct 2017 07:07:44 +0000 (09:07 +0200)]
line: provide gpiod_line_bulk_foreach_line()
Add a macro allowing to easily iterate over all lines held by a line
bulk object.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Mon, 2 Oct 2017 14:34:05 +0000 (16:34 +0200)]
core: drop unnecessary checks
The getter functions retrieving the file descriptors (both for events
and line values) check the line state internally but we don't check
their return values and just pass them on to ioctl()s. Drop the checks
altogether.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Mon, 2 Oct 2017 13:16:44 +0000 (15:16 +0200)]
core: provide gpiod_line_bulk_num_lines()
Add an inline routine allowing to retrieve the number of lines held by
a line bulk object.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Mon, 2 Oct 2017 13:04:12 +0000 (15:04 +0200)]
doc: split the documentation for GPIO lines into smaller chunks
Create separate sections for bulk, info, requests, values, events and
misc routines and data structures for GPIO lines.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Mon, 2 Oct 2017 12:48:03 +0000 (14:48 +0200)]
core: group the GCC attributes together
Put the defines wrapping the gcc attributes in the same place
in gpiod.h.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Mon, 2 Oct 2017 12:46:17 +0000 (14:46 +0200)]
iter: improve the naming of line iterator constants
These three constants define the possible line iterator states. Make
their names reflect that.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Mon, 2 Oct 2017 12:41:49 +0000 (14:41 +0200)]
line: rename the constant defining the max size of a bulk line object
Stay in line with other prefixes and change it to
GPIOD_LINE_BULK_MAX_LINES.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Mon, 2 Oct 2017 12:26:42 +0000 (14:26 +0200)]
line: use a common prefix for all line defines
Prefix all constants used by line functions with GPIOD_LINE_.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Fri, 29 Sep 2017 17:18:09 +0000 (19:18 +0200)]
gpiofind: use gpiod_simple_find_line() internally
Switch to using the simple API in gpiofind.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Fri, 29 Sep 2017 17:17:37 +0000 (19:17 +0200)]
simple-api: provide gpiod_simple_find_line()
Implement a simple API function for looking up GPIO lines. Include
a set of test cases.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Fri, 29 Sep 2017 16:47:51 +0000 (18:47 +0200)]
core: provide gpiod_line_get()
Provide a routine which simplifies the process of getting the handle
for a single GPIO line by encapsulating the calls opening the chip and
retrieving the line handle in a single function.
Implement test cases as well.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Fri, 29 Sep 2017 16:27:39 +0000 (18:27 +0200)]
core: rework gpiod_line_find()
Use gpiod_chip_find_line() internally for smaller code. Return NULL
if an error occurrs during the lookup. Update the documentation.
While we're at it: update the tests for line lookups.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Fri, 29 Sep 2017 16:20:30 +0000 (18:20 +0200)]
core: rename gpiod_line_find_by_name()
Shorten the name of the line lookup routine as any other type of
lookup wouldn't make sense anyway.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Fri, 29 Sep 2017 15:30:47 +0000 (17:30 +0200)]
tests: add parentheses in assert macros
Use parentheses around arguments wherever they can be numerical
values.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Fri, 29 Sep 2017 15:25:07 +0000 (17:25 +0200)]
tests: chip: add test cases for gpiod_chip_find_line()
Test two use cases: correct lookup and a search for a non-existent
line.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Fri, 29 Sep 2017 15:22:16 +0000 (17:22 +0200)]
tests: use TEST_ASSERT_ERRNO_IS()
Use the new assert macro wherever we're checking the errno value.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Fri, 29 Sep 2017 15:21:15 +0000 (17:21 +0200)]
tests: new assertion
Add a helper for checking the current errno value.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Fri, 29 Sep 2017 13:24:00 +0000 (15:24 +0200)]
core: implement gpiod_chip_find_line()
The low-level line lookup should be more fine-grained. As the first
step: introduce a routine performing a line lookup for specific chip.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Fri, 29 Sep 2017 13:47:12 +0000 (15:47 +0200)]
gpiomon: fix event counting
We must not increment the events_done variable for events we're not
watching.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Fri, 29 Sep 2017 13:31:12 +0000 (15:31 +0200)]
gpiomon: correctly handle poll timeouts
We don't check for timeout events in the simple loop event handler.
Fix it and return a correct value.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Thu, 28 Sep 2017 07:57:57 +0000 (09:57 +0200)]
tests: line: use test_line_close_chip()
Drop the unnecessary chip object.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Thu, 28 Sep 2017 07:56:41 +0000 (09:56 +0200)]
tests: new cleanup function
Add a new cleanup function which calls gpiod_line_close_chip().
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Thu, 28 Sep 2017 07:54:10 +0000 (09:54 +0200)]
core: implement gpiod_line_close_chip()
This function works nicely with gpiod_line_find_by_name() which
returns a line object whose owning chip must be later freed by the
caller. With this routine the caller can skip creating a temporary
chip object.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Wed, 27 Sep 2017 09:47:09 +0000 (11:47 +0200)]
tools: remove the redundant UNUSED define
Use GPIOD_UNUSED instead.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Wed, 27 Sep 2017 09:44:09 +0000 (11:44 +0200)]
simple-api: improve the naming convention
Discern between the callback arguments and return values by renaming
relevant defines.
Also: prefix all simple API defines with GPIOD_SIMPLE_.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Wed, 27 Sep 2017 09:10:38 +0000 (11:10 +0200)]
core: new public macro
Export GPIOD_UNUSED in gpiod.h as it may be useful for users not
using all arguments in certain callback functions.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Wed, 27 Sep 2017 09:09:37 +0000 (11:09 +0200)]
tests: simple-api: new test case
Add a test case for gpiod_simple_event_loop_multiple().
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Tue, 26 Sep 2017 21:58:44 +0000 (23:58 +0200)]
gpiomon: use the simple event loop
Switch to using the high-level API. This significantly shrinks the
code while keeping all the functionality.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Mon, 25 Sep 2017 17:13:48 +0000 (19:13 +0200)]
simple: rework the event loop
Implement a new routine for monitoring multiple lines with the simple
event loop and extend the simple loop interface with custom polling
capabilities.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Mon, 25 Sep 2017 18:22:03 +0000 (20:22 +0200)]
simple: event-loop: fix EINTR handling
We want to handle EINTR as a timeout event. Don't return here.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Sun, 24 Sep 2017 20:06:31 +0000 (22:06 +0200)]
core: add gpiod_line_bulk_get_line()
Add a getter function for retrieving line handles from bulk objects.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Sun, 24 Sep 2017 19:59:45 +0000 (21:59 +0200)]
simple: remove redundant line releases
We're closing the chip right after calling the release routines in all
three cases. The chip close function releases all line resources
anyway so no need to do it twice.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Sun, 24 Sep 2017 19:11:45 +0000 (21:11 +0200)]
simple: fix the active_low switch in gpiod_simple_event_loop()
We're incorrectly passing the boolean active_low argument to
gpiod_line_request_both_edges_events_flags() as flags. Add the same
conversion as in the other simple API routines.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Sun, 24 Sep 2017 08:52:55 +0000 (10:52 +0200)]
build: fix the kernel version in the 'make check' message
The minimum kernel version for running tests is now 4.12.6. Reflect
that in the message displayed after building the test suite.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Sun, 24 Sep 2017 08:48:14 +0000 (10:48 +0200)]
core: rename gpiod_line_is_used_by_kernel()
The UAPI flag checked by this routine is called GPIOLINE_FLAG_KERNEL
but its name may be a bit misleading. When set, it can mean that the
line is used by the kernel or by another user space process.
Use a more general name: gpiod_line_is_used().
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Thu, 14 Sep 2017 06:06:10 +0000 (08:06 +0200)]
README: add info about the subject line for e-mails sent to linux-gpio
For libgpiod-related e-mails the subject line should be prefixed
with [libgpiod].
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Wed, 13 Sep 2017 08:52:04 +0000 (10:52 +0200)]
README: update the section about contributing
The development will no longer happen on github, but on the linux-gpio
mailing list instead.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Wed, 13 Sep 2017 08:30:28 +0000 (10:30 +0200)]
build: silence an ar warning
In some configurations ar prints the following warnings:
ar: `u' modifier ignored since `D' is the default (see `U')
Silence it by setting the ar flags to 'cr' instead of 'cru' which is
the default.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Tue, 12 Sep 2017 16:05:48 +0000 (18:05 +0200)]
NEWS: updates for v0.3.1
Add release notes for libgpiod v0.3.1.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Tue, 12 Sep 2017 07:55:56 +0000 (09:55 +0200)]
README.md: rename to README
We now host libgpiod at kernel.org, so no need for the .md file.
This also fixes 'make dist' as README.md was not being packaged by
autotools.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Sun, 10 Sep 2017 11:24:37 +0000 (13:24 +0200)]
tests: gpioset: fix a typo
Fix the spelling of the test case function name.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Sat, 12 Aug 2017 19:46:13 +0000 (21:46 +0200)]
tests: re-enable a test case for gpiomon
The test case in which we verify if falling-edge events are correctly
ignored was failing due to a bug in the kernel. This has now been
fixed with commit
df1e76f28ffe ("gpiolib: skip unwanted events, don't
convert them to opposite edge") and released in linux v4.12.6.
Re-enable the test and make this version a hard requirement for
running the test suite.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Fri, 28 Jul 2017 11:00:41 +0000 (13:00 +0200)]
tools: use program_invocation_name
Remove set_progname() from tools-common and use the global
program_invocation_name variable.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Sat, 22 Jul 2017 15:31:47 +0000 (17:31 +0200)]
tests: use program_invocation_name
We're using _GNU_SOURCE, so it's ok to use program_invocation_name
instead of storing it manually.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Fri, 14 Jul 2017 11:25:40 +0000 (13:25 +0200)]
gpiod.h: improve the documentation for gpiod_line_iter_last_offset()
Mention the undefined behavior if gpiod_line_iter_last_offset() is
ever called before gpiod_line_iter_next().
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Fri, 14 Jul 2017 10:58:47 +0000 (12:58 +0200)]
gpiod.h: extend the introduction to the simple API
Add more info on the simple API functions.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Fri, 14 Jul 2017 10:45:51 +0000 (12:45 +0200)]
gpiod.h: move the mainpage doxygen comment down
Move it to where the libgpiod declarations begin.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Thu, 13 Jul 2017 16:24:54 +0000 (18:24 +0200)]
core: readability tweak
Create separate static functions for checking the request type.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Thu, 13 Jul 2017 16:09:17 +0000 (18:09 +0200)]
core: add the offset argument to the simple event loop callback
In preparation for introducing a multiple lines variant of the simple
event loop routine, add the offset argument to the callback prototype.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Thu, 13 Jul 2017 16:07:25 +0000 (18:07 +0200)]
core: fix single line event requests with flags
We currently always request rising edge events for the 'flags'
variants. Request correct event types.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Thu, 13 Jul 2017 11:53:46 +0000 (13:53 +0200)]
core: add bulk event requests
Add functions for requesting events for line bulk objects. Both with
and without additional flags.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Thu, 13 Jul 2017 11:29:27 +0000 (13:29 +0200)]
core: remove the active_low argument from line bulk requests
We previously removed this argument from routines dealing with single
line requests. Do the same for bulk requests.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Thu, 13 Jul 2017 11:15:39 +0000 (13:15 +0200)]
core: group the line request code together
Put both the regular input & output requests as well as event requests
together in the same place in core.c.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Thu, 13 Jul 2017 10:57:14 +0000 (12:57 +0200)]
core: move the chip-related code to the top of core.c
Just as with the public header - move the chip code above the line
definitions.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>