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>
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>
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>
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>
Bartosz Golaszewski [Tue, 10 Jan 2017 11:40:19 +0000 (12:40 +0100)]
TODO: update
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
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>
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>
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>
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>
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>
Bartosz Golaszewski [Tue, 10 Jan 2017 10:12:47 +0000 (11:12 +0100)]
TODO: update
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
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>
Bartosz Golaszewski [Mon, 9 Jan 2017 21:46:11 +0000 (22:46 +0100)]
TODO: update
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Bartosz Golaszewski [Mon, 9 Jan 2017 11:33:42 +0000 (12:33 +0100)]
TODO: update
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
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>
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>
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>
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>
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>
Bartosz Golaszewski [Fri, 6 Jan 2017 17:11:46 +0000 (18:11 +0100)]
TODO: update
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Bartosz Golaszewski [Fri, 6 Jan 2017 14:12:55 +0000 (15:12 +0100)]
TODO: update
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
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>
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>
Bartosz Golaszewski [Fri, 6 Jan 2017 10:27:38 +0000 (11:27 +0100)]
TODO: update
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
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>
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>
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>
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>
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>
Bartosz Golaszewski [Thu, 5 Jan 2017 17:38:18 +0000 (18:38 +0100)]
TODO: update
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Bartosz Golaszewski [Wed, 4 Jan 2017 16:52:26 +0000 (17:52 +0100)]
core: put the line request configuration into a structure
The base routine for line requesting should have all config parameters
packed in a single structure. Future request helpers will simplify
this.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Wed, 4 Jan 2017 16:42:32 +0000 (17:42 +0100)]
core: remove different gpiod_line_request() versions
Until the request API is considered stable, remove all the request
helpers.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Wed, 4 Jan 2017 16:17:03 +0000 (17:17 +0100)]
core: rename GPIOD_MAX_LINES
This define specifies the maximum number of lines that can be
requested in a single operation. Make it clear with the new name.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Wed, 4 Jan 2017 16:09:28 +0000 (17:09 +0100)]
core: implement public line update routines
Line info is retrieved from the kernel for the first time
automatically when gpiod_chip_get_line() is called. Then the line
is updated automatically on request/release. If the ioctl fails in the
latter case, the up_to_date flag is set to false.
Expose an interface allowing users to check if a line is up-to-date
and manually update it if needed.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Tue, 3 Jan 2017 21:29:35 +0000 (22:29 +0100)]
misc: add a TODO file
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Tue, 3 Jan 2017 17:25:05 +0000 (18:25 +0100)]
core: add input/output flavors of bulk request routines
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Tue, 3 Jan 2017 17:20:09 +0000 (18:20 +0100)]
core: merge the direction argument into flags for request routines
There's no reason to keep the direction as a separate argument if we
have polarity configured using the flags argument. We have separate
routines for input/output requests anyway.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Tue, 3 Jan 2017 10:22:44 +0000 (11:22 +0100)]
build: add dependencies to Makefile.am
This fixes the build with multiple make jobs.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Tue, 3 Jan 2017 10:17:19 +0000 (11:17 +0100)]
core: implement gpiod_line_polarity()
Instead of returning a boolean value from gpiod_line_is_active_low(),
introduce two separate values as is done for direction and implement
gpiod_line_polarity(). This makes the code less confusing.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Mon, 2 Jan 2017 17:05:19 +0000 (18:05 +0100)]
gpiodetect: use the correct gpiod_chip_open() flavor
gpiod_chip_iter_next() should use gpiod_chip_open_by_name() internally
when opening chips by dentry->d_name.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Mon, 2 Jan 2017 17:02:16 +0000 (18:02 +0100)]
core: code shrink
Reuse the bulk routines for single lines too. This unduplicates
a lot of code.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Mon, 2 Jan 2017 16:51:04 +0000 (17:51 +0100)]
core: coding style fix
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Mon, 2 Jan 2017 16:49:35 +0000 (17:49 +0100)]
core: remove gpiod_simple_set_value()
This has been removed from gpiod.h and doesn't even work. Remove the
definition from core.c.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Mon, 2 Jan 2017 16:42:47 +0000 (17:42 +0100)]
core: add bulk operations
Add versions of the request/release and get/set value operations for
bundles of GPIO lines.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Mon, 2 Jan 2017 15:23:24 +0000 (16:23 +0100)]
core: update line info after a line request
Currently the line information isn't updated after it's been
requested. Re-read the line info after requesting it.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Mon, 2 Jan 2017 15:05:59 +0000 (16:05 +0100)]
core: add libgpiod-specific error numbers
In order to better report error conditions to users, we need a set
of libgpiod-specific errnos. Extend the previous API to be able to
use both regular errno and GPIO-related error numbers together.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Mon, 2 Jan 2017 14:55:30 +0000 (15:55 +0100)]
core: clamp GPIO values to either 1 or 0
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Mon, 2 Jan 2017 14:50:28 +0000 (15:50 +0100)]
gpioset: drop the call to gpiod_line_set_value()
This is not needed as we already pass the default value to
gpiod_line_request_dout();
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Mon, 2 Jan 2017 14:49:31 +0000 (15:49 +0100)]
core: fix a default value bug when requesting a GPIO line
The direction is stored in the 'direction' argument, not in flags.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>