qemu-gpiodev/libgpiod.git
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>
8 years agoTODO: update
Bartosz Golaszewski [Mon, 9 Jan 2017 21:46:11 +0000 (22:46 +0100)]
TODO: update

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: move a call to memset() in gpiod_line_event_wait_bulk()
Bartosz Golaszewski [Mon, 9 Jan 2017 15:23:05 +0000 (16:23 +0100)]
core: move a call to memset() in gpiod_line_event_wait_bulk()

Check for error conditions first.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agogpioinfo: tweak the output format
Bartosz Golaszewski [Mon, 9 Jan 2017 14:14:51 +0000 (15:14 +0100)]
gpioinfo: tweak the output format

Add an additional space before the active state for better
readability.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: fix gpiod_line_event_request()
Bartosz Golaszewski [Mon, 9 Jan 2017 14:12:03 +0000 (15:12 +0100)]
core: fix gpiod_line_event_request()

Correctly set the last error if the line is busy.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: extend verify_line_bulk()
Bartosz Golaszewski [Mon, 9 Jan 2017 14:10:13 +0000 (15:10 +0100)]
core: extend verify_line_bulk()

Make verify_line_bulk() set the last error number (according to the
error condition) and verify if any line is busy too.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: new error number
Bartosz Golaszewski [Mon, 9 Jan 2017 14:08:47 +0000 (15:08 +0100)]
core: new error number

Add an error indicating that given line is currently in use.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: implement gpiod_line_is_free()
Bartosz Golaszewski [Mon, 9 Jan 2017 14:03:55 +0000 (15:03 +0100)]
core: implement gpiod_line_is_free()

This routine allows the user to check if neither ownership nor any
event notifications were requested for this line.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agogpioinfo: improve output format
Bartosz Golaszewski [Mon, 9 Jan 2017 13:53:33 +0000 (14:53 +0100)]
gpioinfo: improve output format

Improve the way the information is formatted. The code is still pretty
ugly though.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agogpioinfo: code cleanup
Bartosz Golaszewski [Mon, 9 Jan 2017 13:10:36 +0000 (14:10 +0100)]
gpioinfo: code cleanup

Use tools-common & getopt. Split the code into separate routines.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: naming convention tweaks
Bartosz Golaszewski [Mon, 9 Jan 2017 12:31:06 +0000 (13:31 +0100)]
core: naming convention tweaks

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: new error code
Bartosz Golaszewski [Mon, 9 Jan 2017 12:30:05 +0000 (13:30 +0100)]
core: new error code

Add an error code indicating that an event operation was requested on
a line for which no events were configured.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: new error number
Bartosz Golaszewski [Mon, 9 Jan 2017 12:23:00 +0000 (13:23 +0100)]
core: new error number

Add an error number indicating that a bulk operation was requested
on a set of lines not belonging to the same gpiochip.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: tweak the "line not requested" error code
Bartosz Golaszewski [Mon, 9 Jan 2017 12:18:42 +0000 (13:18 +0100)]
core: tweak the "line not requested" error code

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: merge the reserved and event_configured fields
Bartosz Golaszewski [Mon, 9 Jan 2017 12:08:47 +0000 (13:08 +0100)]
core: merge the reserved and event_configured fields

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: create accessors for up_to_date field of struct gpiod_line
Bartosz Golaszewski [Mon, 9 Jan 2017 12:01:16 +0000 (13:01 +0100)]
core: create accessors for up_to_date field of struct gpiod_line

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agogpiofind: fix segfault
Bartosz Golaszewski [Mon, 9 Jan 2017 11:55:30 +0000 (12:55 +0100)]
gpiofind: fix segfault

Should have been argv[0] instead of argv[1].

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: fix segfault in gpiod_line_find_by_name()
Bartosz Golaszewski [Mon, 9 Jan 2017 11:54:54 +0000 (12:54 +0100)]
core: fix segfault in gpiod_line_find_by_name()

We need to check whether gpiod_line_name() didn't return NULL.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agogpiofind: remove stray newline
Bartosz Golaszewski [Mon, 9 Jan 2017 11:42:39 +0000 (12:42 +0100)]
gpiofind: remove stray newline

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agotools-common: use gpiod_last_strerror()
Bartosz Golaszewski [Mon, 9 Jan 2017 11:38:10 +0000 (12:38 +0100)]
tools-common: use gpiod_last_strerror()

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: implement gpiod_last_strerror()
Bartosz Golaszewski [Mon, 9 Jan 2017 11:37:04 +0000 (12:37 +0100)]
core: implement gpiod_last_strerror()

This is the same as gpiod_strerror() except that it automatically
uses the last error number by calling gpiod_errno().

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

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agogpiod.h: documentation updates
Bartosz Golaszewski [Mon, 9 Jan 2017 11:33:31 +0000 (12:33 +0100)]
gpiod.h: documentation updates

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agogpiod.h: make the include guard more unique
Bartosz Golaszewski [Mon, 9 Jan 2017 11:22:48 +0000 (12:22 +0100)]
gpiod.h: make the include guard more unique

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agoconfigure: check for ppoll()
Bartosz Golaszewski [Sat, 7 Jan 2017 17:55:21 +0000 (18:55 +0100)]
configure: check for ppoll()

We're using ppoll() for events - check if we have it before trying
to compile.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: use strerror_r() instead of strerror()
Bartosz Golaszewski [Sat, 7 Jan 2017 17:53:46 +0000 (18:53 +0100)]
core: use strerror_r() instead of strerror()

Use a thread-local buffer for the error message.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agotools-common: add the UNUSED attribute and use it in gpioset
Bartosz Golaszewski [Fri, 6 Jan 2017 17:16:12 +0000 (18:16 +0100)]
tools-common: add the UNUSED attribute and use it in gpioset

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agoTODO: update
Bartosz Golaszewski [Fri, 6 Jan 2017 17:11:46 +0000 (18:11 +0100)]
TODO: update

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agogpioset: code shrink
Bartosz Golaszewski [Fri, 6 Jan 2017 17:08:25 +0000 (18:08 +0100)]
gpioset: code shrink

Make gpioset use getopt, tools-common and use the new simple API for
setting values.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agogpioget: fix help message
Bartosz Golaszewski [Fri, 6 Jan 2017 16:56:28 +0000 (17:56 +0100)]
gpioget: fix help message

Also: add a space for readability.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: implement gpiod_simple_set_value()
Bartosz Golaszewski [Fri, 6 Jan 2017 16:42:17 +0000 (17:42 +0100)]
core: implement gpiod_simple_set_value()

Implement a counterpart for gpiod_simple_get_value().

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: move gpiod_line_find_by_name()
Bartosz Golaszewski [Fri, 6 Jan 2017 16:28:47 +0000 (17:28 +0100)]
core: move gpiod_line_find_by_name()

Move this routine to where other line-related functions live.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agogpioget: remove a FIXME
Bartosz Golaszewski [Fri, 6 Jan 2017 15:44:56 +0000 (16:44 +0100)]
gpioget: remove a FIXME

The user can't pass a negative number as argument anyway, as it's
considered an unrecognized option by getopt.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agotools: return from main() rather than exit()ing
Bartosz Golaszewski [Fri, 6 Jan 2017 15:30:15 +0000 (16:30 +0100)]
tools: return from main() rather than exit()ing

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agogpioget: move printing the help message to a separate function
Bartosz Golaszewski [Fri, 6 Jan 2017 15:29:15 +0000 (16:29 +0100)]
gpioget: move printing the help message to a separate function

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agogpiofind: add options to the help text
Bartosz Golaszewski [Fri, 6 Jan 2017 15:27:47 +0000 (16:27 +0100)]
gpiofind: add options to the help text

Also: move displaying the help message to a separate function.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agogpiodetect: add options to the help text
Bartosz Golaszewski [Fri, 6 Jan 2017 15:22:36 +0000 (16:22 +0100)]
gpiodetect: add options to the help text

Also: move displaying the help message to a separate function.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agogpioget: use tools-common
Bartosz Golaszewski [Fri, 6 Jan 2017 15:21:09 +0000 (16:21 +0100)]
gpioget: use tools-common

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: extend gpiod_simple_get_value()
Bartosz Golaszewski [Fri, 6 Jan 2017 14:56:49 +0000 (15:56 +0100)]
core: extend gpiod_simple_get_value()

Add the active state argument.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agoglobal: fix active state naming
Bartosz Golaszewski [Fri, 6 Jan 2017 14:48:45 +0000 (15:48 +0100)]
global: fix active state naming

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agogpiodetect: handle unrecognized options
Bartosz Golaszewski [Fri, 6 Jan 2017 14:29:02 +0000 (15:29 +0100)]
gpiodetect: handle unrecognized options

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agogpiofind: user tools-common
Bartosz Golaszewski [Fri, 6 Jan 2017 14:28:39 +0000 (15:28 +0100)]
gpiofind: user tools-common

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agoglobal: include gpiod.h locally from tools and library code
Bartosz Golaszewski [Fri, 6 Jan 2017 14:24:10 +0000 (15:24 +0100)]
global: include gpiod.h locally from tools and library code

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agotools-common: add gcc attributes
Bartosz Golaszewski [Fri, 6 Jan 2017 14:21:47 +0000 (15:21 +0100)]
tools-common: add gcc attributes

Add macros for two gcc attributes and use them in die()
and die_perror().

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agotools-common: new source file
Bartosz Golaszewski [Fri, 6 Jan 2017 14:13:07 +0000 (15:13 +0100)]
tools-common: new source file

Introduce a .c file containing code that is common across all GPIO
tools but not really related to the libgpiod functionality. This file
is statically linked with every executable.

While we're at it - make gpiodetect use it right away.

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

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agogpiod.h: don't include stdint.h
Bartosz Golaszewski [Fri, 6 Jan 2017 13:45:16 +0000 (14:45 +0100)]
gpiod.h: don't include stdint.h

We can move this include to core.c.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agogpiofind: new tool
Bartosz Golaszewski [Fri, 6 Jan 2017 13:34:55 +0000 (14:34 +0100)]
gpiofind: new tool

Add a simple program for finding the gpiochip and offset of a GPIO
line by name.

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

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agoevent: modify the API
Bartosz Golaszewski [Fri, 6 Jan 2017 10:26:18 +0000 (11:26 +0100)]
event: modify the API

In order to make it possible for users to poll the event file
descriptor, we need to split the logic of waiting for events to occur
and reading them into separate routines.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: remove gpiod_chip_get_fd()
Bartosz Golaszewski [Fri, 6 Jan 2017 10:01:25 +0000 (11:01 +0100)]
core: remove gpiod_chip_get_fd()

With current functionality offered by the library, there's no need for
the user to directly access the gpiochip file descriptor.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: move struct definitions to the top of core.c
Bartosz Golaszewski [Fri, 6 Jan 2017 09:54:20 +0000 (10:54 +0100)]
core: move struct definitions to the top of core.c

We will need to access the chip data from the line-related code.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agogpiod.h: shuffle some declarations
Bartosz Golaszewski [Fri, 6 Jan 2017 09:51:17 +0000 (10:51 +0100)]
gpiod.h: shuffle some declarations

Move the opaque structs declarations to the top of the file - they are
ignored by doxygen anyway and that way we can move
gpiod_line_get_chip() to the line defgroup.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agogpiod.h: doxygen documentation - part II
Bartosz Golaszewski [Thu, 5 Jan 2017 17:38:41 +0000 (18:38 +0100)]
gpiod.h: doxygen documentation - part II

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

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: naming convention tweaks
Bartosz Golaszewski [Thu, 5 Jan 2017 16:48:53 +0000 (17:48 +0100)]
core: naming convention tweaks

Change naming of some routines and variables dealing with line
requests. This makes their purpose more obvious.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agogpiod.h: document the API - part I
Bartosz Golaszewski [Thu, 5 Jan 2017 15:19:19 +0000 (16:19 +0100)]
gpiod.h: document the API - part I

As of now, the public API should stay more or less similar to the
current version. Add the first batch of doxygen documentation for
exported symbols, routines and macros.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agogpiomon: fix Makefile.am
Bartosz Golaszewski [Thu, 5 Jan 2017 15:11:08 +0000 (16:11 +0100)]
gpiomon: fix Makefile.am

Add gpiomon to the list of programs to build.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agogpiomon: new tool
Bartosz Golaszewski [Thu, 5 Jan 2017 14:22:41 +0000 (15:22 +0100)]
gpiomon: new tool

Implement a simple GPIO event monitor.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agogpioset: release the line before exiting
Bartosz Golaszewski [Thu, 5 Jan 2017 14:14:19 +0000 (15:14 +0100)]
gpioset: release the line before exiting

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: fix gpiod_simple_get_value()
Bartosz Golaszewski [Thu, 5 Jan 2017 13:59:36 +0000 (14:59 +0100)]
core: fix gpiod_simple_get_value()

We should set direction to INPUT.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: fix gpiod_line_update()
Bartosz Golaszewski [Thu, 5 Jan 2017 13:48:28 +0000 (14:48 +0100)]
core: fix gpiod_line_update()

Don't zero the line offset.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: implement the event API
Bartosz Golaszewski [Thu, 5 Jan 2017 10:26:15 +0000 (11:26 +0100)]
core: implement the event API

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agobuild: install headers too
Bartosz Golaszewski [Thu, 5 Jan 2017 09:27:31 +0000 (10:27 +0100)]
build: install headers too

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: fix leftovers from flag shuffling
Bartosz Golaszewski [Thu, 5 Jan 2017 09:22:36 +0000 (10:22 +0100)]
core: fix leftovers from flag shuffling

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: implement gpiod_line_find_by_name()
Bartosz Golaszewski [Wed, 4 Jan 2017 21:52:54 +0000 (22:52 +0100)]
core: implement gpiod_line_find_by_name()

Implement a routine for finding lines by name.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: tweak line iterators
Bartosz Golaszewski [Wed, 4 Jan 2017 21:44:41 +0000 (22:44 +0100)]
core: tweak line iterators

Some line iterator changes to keep them similar to chip iterators.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: simplify iterating over line bulk objects
Bartosz Golaszewski [Wed, 4 Jan 2017 17:00:18 +0000 (18:00 +0100)]
core: simplify iterating over line bulk objects

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: rename direction defines
Bartosz Golaszewski [Wed, 4 Jan 2017 16:55:26 +0000 (17:55 +0100)]
core: rename direction defines

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: remove redundant memset()
Bartosz Golaszewski [Wed, 4 Jan 2017 16:54:15 +0000 (17:54 +0100)]
core: remove redundant memset()

The request structure is already zeroed by zalloc().

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