qemu-gpiodev/libgpiod.git
8 years agogpioset: include <poll.h> instead of <sys/poll.h>
Bartosz Golaszewski [Wed, 25 Jan 2017 10:55:31 +0000 (11:55 +0100)]
gpioset: include <poll.h> instead of <sys/poll.h>

Just like we did in core.c: don't include <sys/poll.h> directly.

Follow the manual and include <poll.h>.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agobuild: use AC_FUNC_STRERROR_R to check the version of strerror_r()
Bartosz Golaszewski [Tue, 24 Jan 2017 10:45:36 +0000 (11:45 +0100)]
build: use AC_FUNC_STRERROR_R to check the version of strerror_r()

Define _GNU_SOURCE globally in configure.ac and use the
AC_FUNC_STRERROR_R macro to figure out what version of strerror_r() is
provided. Some libraries (e.g. musl) only provide the POSIX version
even if we explicitly request GNU extensions.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agodoc: documentation updates
Bartosz Golaszewski [Tue, 24 Jan 2017 09:53:35 +0000 (10:53 +0100)]
doc: documentation updates

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: allow to read values of lines configured for events
Bartosz Golaszewski [Mon, 23 Jan 2017 15:01:28 +0000 (16:01 +0100)]
core: allow to read values of lines configured for events

The kernel allows us to read values of lines on which we're listening
for events, but libgpiod bails out if the user tries to do it.

Modify gpiod_line_get_value_bulk() to select the correct file
descriptor, depending on how the line object is configured and
allow reading values for both normally exported and monitored lines.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: include <poll.h> instead of <sys/poll.h>
Thomas Petazzoni [Mon, 23 Jan 2017 08:18:32 +0000 (21:18 +1300)]
core: include <poll.h> instead of <sys/poll.h>

<sys/poll.h> is an internal C library header, which shouldn't be
included directly. <poll.h> should be included instead, as advertised
in poll(2).

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
[Bartosz: tweaked the commit message]
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agogpiod.h: include missing <time.h> include
Thomas Petazzoni [Mon, 23 Jan 2017 08:17:15 +0000 (21:17 +1300)]
gpiod.h: include missing <time.h> include

gpiod.h uses "struct timespec", but forgets to include the <time.h>
header which defines "struct timespec". This causes a build error with
the musl C library:

In file included from core.c:11:0:
../../include/gpiod.h:232:49: warning: â€˜struct timespec’ declared inside parameter list
 typedef int (*gpiod_event_cb)(int, const struct timespec *, void *);

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
[Bartosz: tweaked the commit message]
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agoconfigure: add helpers for printing common errors
Bartosz Golaszewski [Fri, 20 Jan 2017 17:11:20 +0000 (18:11 +0100)]
configure: add helpers for printing common errors

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agoconfigure: tweak error messages
Bartosz Golaszewski [Fri, 20 Jan 2017 16:29:42 +0000 (17:29 +0100)]
configure: tweak error messages

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agoconfigure: don't check stdint.h
Bartosz Golaszewski [Fri, 20 Jan 2017 16:23:40 +0000 (17:23 +0100)]
configure: don't check stdint.h

We probably have it if AC_HEADER_STDC succeeded.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agoconfigure: don't check headers/functions unnecessarily
Bartosz Golaszewski [Fri, 20 Jan 2017 16:22:20 +0000 (17:22 +0100)]
configure: don't check headers/functions unnecessarily

Only check functions & headers required by tools if we're actually
building them.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agoconfigure: check sys/poll.h availability
Bartosz Golaszewski [Fri, 20 Jan 2017 14:57:54 +0000 (15:57 +0100)]
configure: check sys/poll.h availability

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agoconfigure: check ppoll() availability
Bartosz Golaszewski [Fri, 20 Jan 2017 14:41:46 +0000 (15:41 +0100)]
configure: check ppoll() availability

We're using ppoll() for events - not poll(). Check the right syscall.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agoREADME: fix the required version of kernel headers
Bartosz Golaszewski [Thu, 19 Jan 2017 14:53:25 +0000 (15:53 +0100)]
README: fix the required version of kernel headers

The project actually needs kernel headers >= v4.8 to compile.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agogpiomon: fix shortops
Bartosz Golaszewski [Thu, 19 Jan 2017 14:10:10 +0000 (15:10 +0100)]
gpiomon: fix shortops

The short option for --silent is missing in gpiomon. Add it.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agobuild: don't try to process docs if doxygen is not installed
Bartosz Golaszewski [Wed, 18 Jan 2017 14:14:36 +0000 (15:14 +0100)]
build: don't try to process docs if doxygen is not installed

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agolibgpiod: start 0.2 development cycle
Bartosz Golaszewski [Wed, 18 Jan 2017 13:59:37 +0000 (14:59 +0100)]
libgpiod: start 0.2 development cycle

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agolibgpiod v0.1
Bartosz Golaszewski [Wed, 18 Jan 2017 13:30:28 +0000 (14:30 +0100)]
libgpiod v0.1

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agoREADME: add examples
Bartosz Golaszewski [Wed, 18 Jan 2017 10:57:35 +0000 (11:57 +0100)]
README: add examples

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agoREADME: add the autoconf version needed to compile the project
Bartosz Golaszewski [Wed, 18 Jan 2017 10:30:25 +0000 (11:30 +0100)]
README: add the autoconf version needed to compile the project

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agoREADME: add bullet points to the tool list
Bartosz Golaszewski [Wed, 18 Jan 2017 10:26:49 +0000 (11:26 +0100)]
README: add bullet points to the tool list

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agoREADME: the introduction is not a code block
Bartosz Golaszewski [Wed, 18 Jan 2017 10:10:36 +0000 (11:10 +0100)]
README: the introduction is not a code block

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agoREADME: rename to README.md for nice github cover
Bartosz Golaszewski [Wed, 18 Jan 2017 10:09:42 +0000 (11:09 +0100)]
README: rename to README.md for nice github cover

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agoREADME: update
Bartosz Golaszewski [Tue, 17 Jan 2017 18:53:37 +0000 (19:53 +0100)]
README: update

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: constify function arguments that will not be modified
Bartosz Golaszewski [Tue, 17 Jan 2017 16:34:03 +0000 (17:34 +0100)]
core: constify function arguments that will not be modified

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agogpiomon: modify the output format
Bartosz Golaszewski [Tue, 17 Jan 2017 16:25:00 +0000 (17:25 +0100)]
gpiomon: modify the output format

Drop unnecessary strings. Add offset info (if we ever wanted to allow
monitoring multiple lines at once while staying backwards compatible).

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agogpiomon: check if offset is not negative
Bartosz Golaszewski [Tue, 17 Jan 2017 16:21:28 +0000 (17:21 +0100)]
gpiomon: check if offset is not negative

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: name the iterator functions consistently
Bartosz Golaszewski [Tue, 17 Jan 2017 16:06:53 +0000 (17:06 +0100)]
core: name the iterator functions consistently

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: skip chips and lines on error in gpiod_line_find_by_name()
Bartosz Golaszewski [Tue, 17 Jan 2017 16:04:46 +0000 (17:04 +0100)]
core: skip chips and lines on error in gpiod_line_find_by_name()

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agogpiomon: new options
Bartosz Golaszewski [Tue, 17 Jan 2017 15:51:11 +0000 (16:51 +0100)]
gpiomon: new options

Add new options to gpiomon:
  - allow to specify the number of events after which the program
    should exit
  - allow to silence the output
  - allow to only monitor certain types of events

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agogpioset: arrange local arguments for better readability
Bartosz Golaszewski [Tue, 17 Jan 2017 15:21:28 +0000 (16:21 +0100)]
gpioset: arrange local arguments for better readability

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agoconfigure: check for daemon() and signalfd() functions
Bartosz Golaszewski [Tue, 17 Jan 2017 15:02:52 +0000 (16:02 +0100)]
configure: check for daemon() and signalfd() functions

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: allow to specify the consumer in the simple event loop
Bartosz Golaszewski [Tue, 17 Jan 2017 14:57:37 +0000 (15:57 +0100)]
core: allow to specify the consumer in the simple event loop

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: allow to specify the consumer in simple set value routines
Bartosz Golaszewski [Tue, 17 Jan 2017 14:54:24 +0000 (15:54 +0100)]
core: allow to specify the consumer in simple set value routines

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: allow to specify the consumer in simple get value routines
Bartosz Golaszewski [Tue, 17 Jan 2017 14:50:03 +0000 (15:50 +0100)]
core: allow to specify the consumer in simple get value routines

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agogpioset: tweak error messages
Bartosz Golaszewski [Tue, 17 Jan 2017 14:45:39 +0000 (15:45 +0100)]
gpioset: tweak error messages

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agogpioset: fix help text
Bartosz Golaszewski [Tue, 17 Jan 2017 14:44:23 +0000 (15:44 +0100)]
gpioset: fix help text

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agogpioset: new option
Bartosz Golaszewski [Tue, 17 Jan 2017 14:43:13 +0000 (15:43 +0100)]
gpioset: new option

Add an option allowing the program to detach from the controlling
terminal after setting values. This is useful for pulled-down/up pins
that we want to keep exported.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agogpioset: new mode of operation
Bartosz Golaszewski [Tue, 17 Jan 2017 14:29:43 +0000 (15:29 +0100)]
gpioset: new mode of operation

Add a new mode: 'signal', which makes the program set GPIO values and
then wait until it receives SIGTERM or SIGINT.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agogpioset: major rework
Bartosz Golaszewski [Tue, 17 Jan 2017 14:11:16 +0000 (15:11 +0100)]
gpioset: major rework

Allow setting multiple lines at once and add different modes
of operation.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agotools-common: make ARRAY_SIZE() a common macro
Bartosz Golaszewski [Tue, 17 Jan 2017 14:10:21 +0000 (15:10 +0100)]
tools-common: make ARRAY_SIZE() a common macro

Move ARRAY_SIZE() out of gpioinfo.c and place it in tools-common.h.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: add a typedef for the set value callback
Bartosz Golaszewski [Tue, 17 Jan 2017 08:54:36 +0000 (09:54 +0100)]
core: add a typedef for the set value callback

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: new error number
Bartosz Golaszewski [Tue, 17 Jan 2017 08:42:55 +0000 (09:42 +0100)]
core: new error number

Introduce an error number indicating that the caller tried to request
too many lines at once. This is only relevant for the 'simple' API, as
the bulk operations are limited by the bulk buffer size.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agogpioget: allow reading multiple lines at once
Bartosz Golaszewski [Tue, 17 Jan 2017 08:37:37 +0000 (09:37 +0100)]
gpioget: allow reading multiple lines at once

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: new set/get value helpers
Bartosz Golaszewski [Tue, 17 Jan 2017 08:15:47 +0000 (09:15 +0100)]
core: new set/get value helpers

Implement simple set/get value routines for multiple lines.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agogpioinfo: readability tweaks
Bartosz Golaszewski [Mon, 16 Jan 2017 17:06:52 +0000 (18:06 +0100)]
gpioinfo: readability tweaks

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agotools: tweak help text
Bartosz Golaszewski [Mon, 16 Jan 2017 15:56:40 +0000 (16:56 +0100)]
tools: tweak help text

Also: stop processing the command line after a first non-option is
encountered in all tools.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agodoc: don't generate class diagrams
Bartosz Golaszewski [Mon, 16 Jan 2017 10:53:22 +0000 (11:53 +0100)]
doc: don't generate class diagrams

This is only useful for C++. Maybe we'll restore it once we have C++
bindings done.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agodoc: document static inline functions
Bartosz Golaszewski [Mon, 16 Jan 2017 10:51:09 +0000 (11:51 +0100)]
doc: document static inline functions

Configure doxygen to document static inline functions from gpiod.h
as well. While we're at it: add a PREDEFINED option to mark functions
in the header that are not part of the API.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agodoc: pass the EXTRA_VERSION to doxygen as well
Bartosz Golaszewski [Mon, 16 Jan 2017 10:43:18 +0000 (11:43 +0100)]
doc: pass the EXTRA_VERSION to doxygen as well

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agodoc: fix Doxyfile
Bartosz Golaszewski [Mon, 16 Jan 2017 10:42:37 +0000 (11:42 +0100)]
doc: fix Doxyfile

The header path was not updated in the Doxyfile after recent directory
structure changes.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agoevent: new event request helpers
Bartosz Golaszewski [Mon, 16 Jan 2017 10:42:03 +0000 (11:42 +0100)]
event: new event request helpers

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agolibgpiod: start 0.1 development cycle
Bartosz Golaszewski [Sun, 15 Jan 2017 18:28:58 +0000 (19:28 +0100)]
libgpiod: start 0.1 development cycle

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agobuild: add EXTRA_VERSION to the version string
Bartosz Golaszewski [Sun, 15 Jan 2017 18:26:06 +0000 (19:26 +0100)]
build: add EXTRA_VERSION to the version string

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agoconfigure: don't use the m4 directory
Bartosz Golaszewski [Sun, 15 Jan 2017 17:58:08 +0000 (18:58 +0100)]
configure: don't use the m4 directory

This fixes the buildroot build.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agobuild: create an organized directory structure
Bartosz Golaszewski [Sun, 15 Jan 2017 17:24:24 +0000 (18:24 +0100)]
build: create an organized directory structure

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agodoc: doxygen: set the project version from Makefile
Bartosz Golaszewski [Sat, 14 Jan 2017 17:53:01 +0000 (18:53 +0100)]
doc: doxygen: set the project version from Makefile

Drop the PROJECT_NUMBER option from the Doxyfile and pass the version
to doxygen via command-line when invoking it from Makefile.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agobuild: drop redundant version variables
Bartosz Golaszewski [Sat, 14 Jan 2017 17:32:22 +0000 (18:32 +0100)]
build: drop redundant version variables

Just use the variable defined by AC_INIT().

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agoTODO: remove TODO from the repo - track features using github
Bartosz Golaszewski [Sat, 14 Jan 2017 17:08:08 +0000 (18:08 +0100)]
TODO: remove TODO from the repo - track features using github

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agoconfigure: drop redundant AC_HEADER_STDC
Bartosz Golaszewski [Fri, 13 Jan 2017 17:06:18 +0000 (18:06 +0100)]
configure: drop redundant AC_HEADER_STDC

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agobuild: drop the aclocal flags
Bartosz Golaszewski [Fri, 13 Jan 2017 16:49:47 +0000 (17:49 +0100)]
build: drop the aclocal flags

We don't use the m4 local directory for now.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agoTODO: update
Bartosz Golaszewski [Fri, 13 Jan 2017 16:42:38 +0000 (17:42 +0100)]
TODO: update

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agobuild: add a configure option for tools
Bartosz Golaszewski [Fri, 13 Jan 2017 16:41:53 +0000 (17:41 +0100)]
build: add a configure option for tools

This allows to build the tools conditionally, depending
on the configuration.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agobuild: check if basename() is available
Bartosz Golaszewski [Fri, 13 Jan 2017 14:55:26 +0000 (15:55 +0100)]
build: check if basename() is available

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agogpioset: coding style fix
Bartosz Golaszewski [Fri, 13 Jan 2017 14:43:02 +0000 (15:43 +0100)]
gpioset: coding style fix

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agoTODO: update
Bartosz Golaszewski [Fri, 13 Jan 2017 14:37:39 +0000 (15:37 +0100)]
TODO: update

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agotools: add the --version argument
Bartosz Golaszewski [Fri, 13 Jan 2017 14:36:49 +0000 (15:36 +0100)]
tools: add the --version argument

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agotools-common: add a function displaying the version info
Bartosz Golaszewski [Fri, 13 Jan 2017 14:26:55 +0000 (15:26 +0100)]
tools-common: add a function displaying the version info

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: add a function for accessing the library version string
Bartosz Golaszewski [Fri, 13 Jan 2017 14:25:23 +0000 (15:25 +0100)]
core: add a function for accessing the library version string

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agobuild: add library versioning
Bartosz Golaszewski [Fri, 13 Jan 2017 13:59:11 +0000 (14:59 +0100)]
build: add library versioning

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agomake: readability tweaks
Bartosz Golaszewski [Fri, 13 Jan 2017 13:49:30 +0000 (14:49 +0100)]
make: readability tweaks

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agomake: compile the library with debug symbols
Bartosz Golaszewski [Thu, 12 Jan 2017 11:52:38 +0000 (12:52 +0100)]
make: compile the library with debug symbols

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: rename line_bulk arguments to bulk where applicable
Bartosz Golaszewski [Wed, 11 Jan 2017 15:17:40 +0000 (16:17 +0100)]
core: rename line_bulk arguments to bulk where applicable

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agogpiod.h: fix a typo
Bartosz Golaszewski [Wed, 11 Jan 2017 15:11:49 +0000 (16:11 +0100)]
gpiod.h: fix a typo

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: add a helper for requesting all types of events
Bartosz Golaszewski [Wed, 11 Jan 2017 15:07:27 +0000 (16:07 +0100)]
core: add a helper for requesting all types of events

Implement gpiod_line_event_request_all() which requests all types of
events on a single line with less arguments. While we're at it: use it
in gpiod_simple_event_loop().

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: code shrink in gpiod_simple_set_value()
Bartosz Golaszewski [Wed, 11 Jan 2017 15:01:25 +0000 (16:01 +0100)]
core: code shrink in gpiod_simple_set_value()

Use one of the line request helpers and omit the set value operation,
since we can set the default value when requesting the line.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: code shrink in gpiod_simple_get_value()
Bartosz Golaszewski [Wed, 11 Jan 2017 14:53:34 +0000 (15:53 +0100)]
core: code shrink in gpiod_simple_get_value()

Use one of the request helpers for smaller code.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agogpiod.h: add line request helpers
Bartosz Golaszewski [Wed, 11 Jan 2017 14:50:31 +0000 (15:50 +0100)]
gpiod.h: add line request helpers

Add inline functions to gpiod.h which allow to request lines with
less arguments.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agoevent: implement gpiod_line_event_read_fd()
Bartosz Golaszewski [Wed, 11 Jan 2017 13:20:38 +0000 (14:20 +0100)]
event: implement gpiod_line_event_read_fd()

Add a new function which allows to read GPIO event data directly from
a file descriptor instead of a gpiod_line object. This is useful if
the user is already directly polling the file descriptors for events.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agogpiod.h: fix GPIOD_LINE_ITER_INITIALIZER()
Bartosz Golaszewski [Wed, 11 Jan 2017 13:13:09 +0000 (14:13 +0100)]
gpiod.h: fix GPIOD_LINE_ITER_INITIALIZER()

Add a missing dot.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: un-inline gpiod_line_iter_next()
Bartosz Golaszewski [Wed, 11 Jan 2017 13:11:43 +0000 (14:11 +0100)]
core: un-inline gpiod_line_iter_next()

This function grew to the point where it should go into a .c file.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agoTODO: simple events done
Bartosz Golaszewski [Wed, 11 Jan 2017 12:23:40 +0000 (13:23 +0100)]
TODO: simple events done

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agogpiomon: stop execution and exit cleanly on SIGINT or SIGTERM
Bartosz Golaszewski [Wed, 11 Jan 2017 12:18:07 +0000 (13:18 +0100)]
gpiomon: stop execution and exit cleanly on SIGINT or SIGTERM

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agoevent: tweak gpiod_simple_event_loop()
Bartosz Golaszewski [Wed, 11 Jan 2017 12:17:01 +0000 (13:17 +0100)]
event: tweak gpiod_simple_event_loop()

If the internal system call is interrupted by a signal - just act as
if the wait timed out.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agogpiomon: code shrink
Bartosz Golaszewski [Wed, 11 Jan 2017 11:58:22 +0000 (12:58 +0100)]
gpiomon: code shrink

Use tools-common like other tools. Convert the program to using the
simple event monitoring interface.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: implement simple event monitoring
Bartosz Golaszewski [Wed, 11 Jan 2017 11:57:39 +0000 (12:57 +0100)]
core: implement simple event monitoring

Add a function and corresponding data structures for simple event
monitoring.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: code shrink
Bartosz Golaszewski [Wed, 11 Jan 2017 10:40:38 +0000 (11:40 +0100)]
core: code shrink

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agoiterators: improve error handling of line iterators
Bartosz Golaszewski [Wed, 11 Jan 2017 10:34:14 +0000 (11:34 +0100)]
iterators: improve error handling of line iterators

As was done for chip iterators: extend the API to include functions
that allow to check if an error occured while iterating over lines
and use them in the foreach macro and in gpioinfo.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agogpioinfo: check for errors when iterating over gpiochips
Bartosz Golaszewski [Wed, 11 Jan 2017 10:11:06 +0000 (11:11 +0100)]
gpioinfo: check for errors when iterating over gpiochips

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agoiterators: extend chip iterator error handling
Bartosz Golaszewski [Wed, 11 Jan 2017 10:06:50 +0000 (11:06 +0100)]
iterators: extend chip iterator error handling

Add a function that allows to retrieve the name of the gpiochip that
we failed to open from an iterator routine. Use it in gpiodetect.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agoiterators: improve error checking
Bartosz Golaszewski [Wed, 11 Jan 2017 09:52:13 +0000 (10:52 +0100)]
iterators: improve error checking

Add new functions that allow to check if opening a gpiochip device
file from an iterator routine failed or if we're done iterating over
all gpiochips present on the system.

Use them in the relevant foreach macro and gpiodetect.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: check for empty name & label of a gpiochip
Bartosz Golaszewski [Tue, 10 Jan 2017 15:16:15 +0000 (16:16 +0100)]
core: check for empty name & label of a gpiochip

In case the kernel passes us an empty name or label field when reading
the chip info: return NULL from gpiod_chip_name() & gpiod_chip_label()
just like the line counterparts do.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: implement gpiod_chip_iter_free_noclose()
Bartosz Golaszewski [Tue, 10 Jan 2017 15:09:23 +0000 (16:09 +0100)]
core: implement gpiod_chip_iter_free_noclose()

Implement a new version of gpiod_chip_iter_free() that doesn't close
the most recently opened gpiochip.

Use the new routine in gpiod_line_find_by_name().

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agoTODO: update
Bartosz Golaszewski [Tue, 10 Jan 2017 11:40:19 +0000 (12:40 +0100)]
TODO: update

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: rework line handle & event requests
Bartosz Golaszewski [Tue, 10 Jan 2017 11:24:29 +0000 (12:24 +0100)]
core: rework line handle & event requests

In order to correctly handle bulk requests create a separate,
refcounted structure for handle data.

Put the handle and event fields of struct gpiod_line into a union as
they can't be shared.

Add relevant helpers and use them in appropriate places.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: rename the req field of struct gpiod_line to request
Bartosz Golaszewski [Tue, 10 Jan 2017 10:57:41 +0000 (11:57 +0100)]
core: rename the req field of struct gpiod_line to request

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: add helpers for the line state field
Bartosz Golaszewski [Tue, 10 Jan 2017 10:50:48 +0000 (11:50 +0100)]
core: add helpers for the line state field

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: line status naming tweaks
Bartosz Golaszewski [Tue, 10 Jan 2017 10:43:27 +0000 (11:43 +0100)]
core: line status naming tweaks

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agoevent: rework gpiod_line_event_wait_bulk()
Bartosz Golaszewski [Tue, 10 Jan 2017 10:37:40 +0000 (11:37 +0100)]
event: rework gpiod_line_event_wait_bulk()

Instead of storing the index of the line - store the line handle
itself as the third parameter.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agoTODO: update
Bartosz Golaszewski [Tue, 10 Jan 2017 10:12:47 +0000 (11:12 +0100)]
TODO: update

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agoevent: remove the line field from struct gpiod_line_event
Bartosz Golaszewski [Tue, 10 Jan 2017 10:11:00 +0000 (11:11 +0100)]
event: remove the line field from struct gpiod_line_event

This doesn't make sense - we know what line we're reading the event
from anyway.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>