Bartosz Golaszewski [Mon, 27 Mar 2023 10:09:34 +0000 (12:09 +0200)]
build: use AM_V_GEN when calling external programs
In order to output a status line in silent mode and the whole command in
default mode, use the AM_V_GEN predefined automake variable when executing
external programs like doxygen and help2man.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Thu, 16 Mar 2023 10:59:13 +0000 (11:59 +0100)]
bindings: cxx: tests: fix the test case for chip::unwatch_line_info()
We need to actually trigger a line-info event before making sure the watch
has been disabled.
Fixes: f2245fa32c1b ("bindings: cxx: tests: add a test case for chip::unwatch_line_info()")
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Thu, 16 Mar 2023 09:03:10 +0000 (10:03 +0100)]
bindings: cxx: tests: add a test case for chip::unwatch_line_info()
We don't have any test case for chip::unwatch_line_info() so add a simple
one similar to the one we have for the core C library.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Thu, 16 Mar 2023 08:35:34 +0000 (09:35 +0100)]
bindings: cxx: tests: drop profiling flags from CXXFLAGS and LDFLAGS
We only need to generate gcov data for the library, not the test
executable.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Thu, 16 Mar 2023 08:24:47 +0000 (09:24 +0100)]
tests: drop the profiling CFLAGS from tests' Makefile
We only need the profiling flags on the library, we don't need to
generate gcov data for the test objects.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Wed, 15 Mar 2023 21:04:06 +0000 (22:04 +0100)]
tests: fix the test case for gpiod_line_request_reconfigure_lines()
We need to actually pass the line config with different offsets to
gpiod_line_request_reconfigure_lines() for the test to make sense.
Fixes: 8ef0ca0fae8f ("tests: add more test cases for gpiod_line_request_reconfigure_lines()")
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Wed, 15 Mar 2023 20:53:00 +0000 (21:53 +0100)]
tests: add a test case for gpiod_chip_request_lines()
Add a test case which verifies that gpiod_chip_request_lines() fails
when supplied with a NULL line config.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Wed, 15 Mar 2023 20:29:35 +0000 (21:29 +0100)]
tests: extend the test case for gpiod_request_config_set_consumer()
Also check that passing a NULL consumer string works as expected.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Wed, 15 Mar 2023 20:18:18 +0000 (21:18 +0100)]
tests: add more test cases for gpiod_line_request_reconfigure_lines()
Add two new test cases for gpiod_line_request_reconfigure_lines(). One
verifies that NULL line config is handled correctly, the other checks
that reconfigured offsets must be the same as the ones requested.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Wed, 15 Mar 2023 20:08:33 +0000 (21:08 +0100)]
tests: remove commented-out code
This is a leftover line and can be removed.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Wed, 15 Mar 2023 20:04:39 +0000 (21:04 +0100)]
tests: add a test case for gpiod_line_config_get_num_configured_offsets()
There are no tests calling gpiod_line_config_get_num_configured_offsets()
yet so add a simple one for more coverage.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Wed, 15 Mar 2023 19:54:52 +0000 (20:54 +0100)]
tests: add a test case for incorrect retrieving of edge events from buffer
Add a test case that makes sure we don't crash when trying to access an
out-of-bounds edge event in an edge event buffer.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Wed, 15 Mar 2023 19:53:23 +0000 (20:53 +0100)]
tests: add a test case for gpiod_line_config_add_line_settings()
Add a more detailed test case for input arguments sanitization for
gpiod_line_config_add_line_settings().
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Wed, 15 Mar 2023 19:52:53 +0000 (20:52 +0100)]
tests: add more test cases for gpiod_line_config_set_output_values()
Add test cases that check proper sanitization of input arguments of
gpiod_line_config_set_output_values().
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Wed, 15 Mar 2023 19:50:57 +0000 (20:50 +0100)]
core: remove dead code
gpiod_line_mask_fill() is unused, so remove it.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Wed, 15 Mar 2023 08:34:56 +0000 (09:34 +0100)]
tools: gpiomon: fix setting event clock type
Fix an inverted logic bug when parsing event clock type in gpiomon.
Fixes: 8ffb6489286f ("tools: line name focussed rework")
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Reported-by: Wes Tarro <wes.tarro@azuresummit.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Bartosz Golaszewski [Mon, 13 Mar 2023 15:28:51 +0000 (16:28 +0100)]
core: sanitize arguments in gpiod_line_config_set_output_values()
Add an assert() for the line config structure and check the rest of the
arguments for invalid values.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Fri, 10 Mar 2023 10:16:30 +0000 (11:16 +0100)]
bindings: rust: examples: add a reimplementation of gpionotify
Add a new rust example - a simplified reimplementation of the gpionotify
tool.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Bartosz Golaszewski [Fri, 10 Mar 2023 09:59:47 +0000 (10:59 +0100)]
bindings: python: examples: add gpionotify.py
Add a new Python code examples - gpionotify.py - which is a simplified
reimplementation of the gpionotify tool.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Fri, 10 Mar 2023 09:32:47 +0000 (10:32 +0100)]
bindings: cxx: examples: implement gpionotify using C++ bindings
Add a new C++ code example - gpionotifycxx - which is a simplified
reimplementation of the gpionotify tool.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Fri, 10 Mar 2023 09:24:04 +0000 (10:24 +0100)]
core: make the chip file descriptor blocking
After discussing this a while back we removed the call to fcntl() that
would make the request file descriptor non-blocking so that a call to
gpiod_line_request_read_edge_events() would block if no events are
pending. We agreed that the same behavior should apply to info events and
made the docs state that. Unfortunately we still pass the O_NONBLOCK flag
to open() making read() called on the chip file descriptor return
immediately if no info events are pending. Fix it by removing this flag.
Fixes: b7ba732e6a93 ("treewide: libgpiod v2 implementation")
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Fri, 10 Mar 2023 09:47:28 +0000 (10:47 +0100)]
bindings: cxx: examples: gpiomoncxx: drop unused header include
We don't need to include <chrono> in the gpiomon C++ example.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Fri, 10 Mar 2023 08:49:41 +0000 (09:49 +0100)]
bindings: cxx: examples: reserve correct amount of space for offsets
In gpiomoncxx we only need to reserve space for (argc - 2) offsets.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Benjamin Li [Mon, 6 Mar 2023 18:45:45 +0000 (10:45 -0800)]
contrib: add sample Android.bp to build within an Android tree
Add an Android.bp file for Soong, the Android build system, to build
the library including C++ bindings along with all the CLI tools.
This reference Android build file will live in a contrib/ folder to
indiciate it is a less-maintained part of libgpiod. It will need to
be moved to the root directory in order to use it, though, as Soong
doesn't let Blueprint files reference sources in a parent directory.
error: external/libgpiod/contrib/Android.bp:5:1: module "libgpiod" variant "...": Path is outside directory: ../include
error: external/libgpiod/contrib/Android.bp:5:1: module "libgpiod" variant "...": Path is outside directory: ../bindings/cxx
error: external/libgpiod/contrib/Android.bp:5:1: module "libgpiod" variant "...": Path is outside directory: ../lib/*.c
error: external/libgpiod/contrib/Android.bp:5:1: module "libgpiod" variant "...": Path is outside directory: ../bindings/cxx/*.cpp
Signed-off-by: Benjamin Li <benl@squareup.com>
[Bartosz: add the build file to the release tarball generated by 'make dist']
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Benjamin Li [Mon, 6 Mar 2023 18:45:44 +0000 (10:45 -0800)]
tools: remove dependency on glibc program_invocation_[short_]name
Platforms like Bionic libc don't have program_invocation_[short_]name,
which is a GNU extension. It does have getprogname(), a BSD extension,
but rather than supporting multiple extensions let's just introduce
our own local helpers.
We derive the short name ourselves rather than calling basename(),
as the POSIX version takes char *, not const char *, and is thus
not guaranteed to avoid modifying its input. (The GNU version does
take const char * but we are avoiding extensions here.)
Signed-off-by: Benjamin Li <benl@squareup.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Fri, 3 Mar 2023 16:23:38 +0000 (17:23 +0100)]
core: sanitize the output values in gpiod_line_config_set_output_values()
We check the output values for invalid ones in
gpiod_line_settings_set_output_value() but in
gpiod_line_config_set_output_values() we just accept all indiscriminately.
Factor out the common checking code into a helper function, use it in both
functions and add a relevant test case.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Mon, 27 Feb 2023 10:03:50 +0000 (11:03 +0100)]
bindings: cxx: make edge_event's impl struct implementations final
The implementations of the abstract edge_event's base impl private struct
can be made final and their destructors non-virtual. As these types are
entirely private, it does not affect the ABI.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Wed, 1 Mar 2023 09:23:37 +0000 (10:23 +0100)]
core: fix line breaking in the public header
Align the function parameters when breaking lines wherever possible.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Mon, 27 Feb 2023 09:33:36 +0000 (10:33 +0100)]
tests: add a test-case for looking up non-standard GPIO line names
Make sure line names with whitespaces or some less common characters (that
can be found in real-life names in mainline .dts files) can be correctly
mapped to offsets.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Fri, 3 Mar 2023 14:02:54 +0000 (15:02 +0100)]
libgpiod: start v2.1 development cycle
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Thu, 2 Mar 2023 14:09:51 +0000 (15:09 +0100)]
libgpiod v2.0
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Thu, 2 Mar 2023 14:36:07 +0000 (15:36 +0100)]
bindings: python: tests: fix the version parsing regex
Two-digit versions are not correctly parsed as the last "segment" is not
optional as it should.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Thu, 2 Mar 2023 14:34:36 +0000 (15:34 +0100)]
bindings: python: remove unneeded setup.py argument
GPIOD_VERSION_STRING environment variable is no longer used by setup.py.
It's been replaced by reading the version from the variable defined in
version.py.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Sat, 25 Feb 2023 14:15:34 +0000 (15:15 +0100)]
tools: remove unneeded #include
We don't use dirname() nor basename() anymore so pulling in libgen.h
is not necessary.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Thu, 23 Feb 2023 18:49:52 +0000 (19:49 +0100)]
libgpiod v2.0-rc3
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Tue, 21 Feb 2023 13:28:12 +0000 (14:28 +0100)]
bindings: cxx: mark public classes as final
libgpiod C++ types are not meant to be inherited from. They already don't
even provide virtual destructors so mark them explicitly as final. With
that the destructors of throwable types can also be made non-virtual.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Sun, 19 Feb 2023 20:39:03 +0000 (21:39 +0100)]
tests: fix a potential assert() abort()
If info is NULL in one of the line-info test cases, we'll still try to
read its property leading to an abort() triggered from assert(info). Just
bail out of the test function if gpiod_chip_get_line_info() fails.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Fri, 17 Feb 2023 13:17:34 +0000 (14:17 +0100)]
bindings: cxx: use C++-style compiler attributes
C++ provides a unified syntax for compiler extensions so use them
instead of redefining our own.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Fri, 17 Feb 2023 13:15:08 +0000 (14:15 +0100)]
bindings: cxx: remove unused define
Remove GPIOD_CXX_NORETURN as nobody is using it anymore.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Fri, 17 Feb 2023 13:05:30 +0000 (14:05 +0100)]
gpiosim: remove unused define
ARRAY_SIZE() is defined but unused so remove it.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Fri, 17 Feb 2023 12:54:05 +0000 (13:54 +0100)]
tools: remove unused defines
The UNUSED define is unused (sic!). Drop it. Same for ARRAY_SIZE().
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Wed, 15 Feb 2023 19:59:16 +0000 (20:59 +0100)]
libgpiod v2.0-rc2
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Wed, 15 Feb 2023 13:46:16 +0000 (14:46 +0100)]
bindings: python: tests: release the request before removing GPIO sim
One of the test cases doesn't release the request object leading to the
following warning in the kernel log:
REMOVING GPIOCHIP WITH GPIOS STILL REQUESTED
Fix it.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Wed, 15 Feb 2023 12:46:30 +0000 (13:46 +0100)]
tests: fix the enum type in line-request tests
Use the correct enumeration type for GPIO simulator line values.
Fixes: 67ffa262e393 ("tests: add line value enums for gpiosim GLib wrapper")
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Mon, 13 Feb 2023 10:53:42 +0000 (11:53 +0100)]
tests: add line value enums for gpiosim GLib wrapper
libgpiosim has a dedicated enum type for line values but the GLib wrapper
still uses magic numbers (0 and 1). Add an enum type for the wrapper and
use it across all test cases.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Mon, 13 Feb 2023 10:03:47 +0000 (11:03 +0100)]
tests: use GLib typedef conventions for line names and hogs
The GVariant packaging works in the context of GLib unit testing so use
GLib conventions for declaring data types.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Tue, 14 Feb 2023 10:10:56 +0000 (11:10 +0100)]
bindings: cxx: drop the re-export guard of visible symbols
The ifdef guard that changes the definition of GPIOD_CXX_API between
"default" and "hidden" is there to prevent libraries that would include
gpiod.hpp from re-exporting libgpiodcxx symbols.
Unfortunately the hidden linkage only works for translation units within
the same ELF object. At static linking time we must always mark the
throwable types as visible or we'll get the following errors:
/usr/bin/ld: tests-chip.o:(.data+0x0): undefined reference to `typeinfo for gpiod::chip_closed'
/usr/bin/ld: tests-line-request.o:(.data+0x0): undefined reference to `typeinfo for gpiod::request_released'
/usr/bin/ld: .libs/gpiod-cxx-test: hidden symbol `_ZTIN5gpiod11chip_closedE' isn't defined
/usr/bin/ld: final link failed: bad value
On top of that we actually WANT to re-export typeinfo for throwable types
as they can be propagated to external callers when an exception is thrown.
The above error can only be triggered on clang. GCC seems to be
incorrectly omitting the "hidden" attribute in this case.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Viresh Kumar [Tue, 14 Feb 2023 06:45:35 +0000 (12:15 +0530)]
bindings: rust: update bindgen's version
The currently selected version of bindgen has a unmaintained dependency
and generates the following build warning while building vhost-device
crate:
Crate: ansi_term
Version: 0.12.1
Warning: unmaintained
Title: ansi_term is Unmaintained
Date: 2021-08-18
ID: RUSTSEC-2021-0139
URL: https://rustsec.org/advisories/RUSTSEC-2021-0139
Dependency tree:
ansi_term 0.12.1
└── clap 2.34.0
└── bindgen 0.59.2
└── libgpiod-sys 0.1.0
└── libgpiod 0.1.0
└── vhost-device-gpio 0.1.0
error: 1 denied warning found!
Fix it by moving to a later version of bindgen, which updates the types
of few of the arguments to the FFI helpers and so required changes to
few of explicit type conversions.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Viresh Kumar [Tue, 14 Feb 2023 06:45:34 +0000 (12:15 +0530)]
bindings: rust: align formatting to what's suggested by 'cargo fmt'
Align code to follow what 'cargo fmt' suggests.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Fri, 10 Feb 2023 21:11:11 +0000 (22:11 +0100)]
gpiosim: use twalk() instead of twalk_r()
twalk_r() is a GNU extension for the binary search tree API. Musl libc
doesn't provide it and after inquiring with the maintainer it turned out
it won't provide it anytime soon as musl strives to only implement well
standardized functions.
In order to not limit building libgpiosim and tests to glibc only, let's
replace twalk_r() with twalk() and use global variables for the state.
It's not a big deal as we're already using a global root node and a mutex
to protect it.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Mon, 13 Feb 2023 17:10:32 +0000 (18:10 +0100)]
bindings: python: don't pass GPIOD_WITH_TESTS to 'setup.py install'
The GPIOD_WITH_TESTS environment variable is not used by setup.py install
command. Drop it.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Mon, 13 Feb 2023 16:54:31 +0000 (17:54 +0100)]
bindings: python: pass DESTDIR to setup.py
As per automake docs:
The DESTDIR variable can be used to perform a staged installation. The
package should be configured as if it was going to be installed in its
final location (e.g., --prefix /usr), but when running make install, the
DESTDIR should be set to the absolute name of a directory into which the
installation will be diverted. From this directory it is easy to review
which files are being installed where, and finally copy them to their
final location by some means.
Prefix $(prefix) with $(DESTDIR) when calling setup.py.
Reported-by: Peter Robinson <pbrobinson@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Reviewed-by: Peter Robinson <pbrobinson@gmail.com>
Tested-by: Peter Robinson <pbrobinson@gmail.com>
Bartosz Golaszewski [Fri, 10 Feb 2023 20:20:14 +0000 (21:20 +0100)]
configure: add more tests for less commonly used functions
Don't take chances - I've seen enough strange setups recently. Add more
checks for atexit() and functions from search.h.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Fri, 10 Feb 2023 12:54:18 +0000 (13:54 +0100)]
bindings: cxx: fix building gpiod::timestamp with clang
Clang's system_clock implementation uses microseconds resolution by
default and we fail to construct a time_point out of chrono::nanoseconds
as the library prohibits us from accidentally losing information when
casting the latter to the former. Use nanoseconds explicitly as the
resolution of the realtime timestamp.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Thu, 9 Feb 2023 20:03:56 +0000 (21:03 +0100)]
configure: verify the availability of twalk_r() for tests
Some C libraries (notably musl) don't have twalk_r() as of yet. Add a
check for it in configure so that we fail sooner rather than at
build-time.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Thu, 9 Feb 2023 18:49:38 +0000 (19:49 +0100)]
tools: use 'unsigned int' instead of 'uint'
uint is an old compatibility name that GCC still provides but clang
doesn't. Use unsigned int instead.
Fixes: 8ffb6489286f ("tools: line name focussed rework")
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Reviewed-by: Kent Gibson <warthog618@gmail.com>
Bartosz Golaszewski [Thu, 9 Feb 2023 18:29:07 +0000 (19:29 +0100)]
tests: remove unused variables
Clang (unlike GCC) reported certain GLib autopointers as unused. Remove
them.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Tue, 7 Feb 2023 20:23:41 +0000 (21:23 +0100)]
libgpiod v2.0-rc1
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Tue, 7 Feb 2023 13:56:49 +0000 (14:56 +0100)]
NEWS: updates for v2.0
Add release notes for libgpiod v2.0.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Tue, 7 Feb 2023 21:13:57 +0000 (22:13 +0100)]
tests: extend the regex matching string versions
We need to match release candidate versions too.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Tue, 7 Feb 2023 20:22:30 +0000 (21:22 +0100)]
tools: update the copyright date in the output of --version
Update the displayed years in the output of --version for all gpio-tools.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Wed, 8 Feb 2023 12:34:26 +0000 (13:34 +0100)]
bindings: python: don't store build system paths in output files
Using the __FILE__ macro contaminates the build artifacts with global
build host file system paths. Don't use it.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Tue, 7 Feb 2023 13:17:04 +0000 (14:17 +0100)]
tests: use predefined exit codes when returning from main()
Use EXIT_FAILURE to indicate an error in main() instead of returning 1.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Mon, 6 Feb 2023 09:58:02 +0000 (10:58 +0100)]
configure: don't look for qsort()
We no longer need qsort for the test suite after switching to gpio-sim.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Mon, 6 Feb 2023 10:18:34 +0000 (11:18 +0100)]
tests: use native types for main() arguments
Follow the GLib recommendation and use native C types for the main()
function's arguments and return values.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Wed, 1 Feb 2023 09:24:45 +0000 (10:24 +0100)]
tests: rework error handling and stop overusing g_error()
GLib recommends using g_error() only for programming errors and
unrecoverable situations. It calls abort() and triggers a core dump. This
means that if we encounter an error when running a test case, we'll
exit immediately and leave a "leaked" GPIO simulator in configfs.
Rework the error handling: use g_error() only when a programming bug is
encountered (e.g. invalid enum value) while everywhere else use the
regular GError-based error handling. This way, in case of an error in
libgpiosim, we'll simply fail the current test case and release all
resources as usual.
In order not to pollute the test cases with error handling, let's hide the
actual error checking behind macros for g_gpiosim_chip_new() and
g_gpiosim_chip_get_value(). For g_gpiosim_chip_set_pull() let's just emit
a log and do nothing as the test case in question will inevitably fail if
the expected value is not correctly read back.
In order for the chip to get a failing constructor, we need to link the
test-suite against the entire libgio, not only libgobject (for the
GInitable interface).
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Wed, 1 Feb 2023 09:18:57 +0000 (10:18 +0100)]
Revert "tests: consistently use GLib types in tests"
GLib recommends to use standard library's int as the return type for
main() and g_test_run() also returns int, not gint. Revert the commit
that made main() return gint.
This reverts commit
c0176f58f98e837f1b9eb40514ac58c51f24e644.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Wed, 1 Feb 2023 08:34:30 +0000 (09:34 +0100)]
tests: drop the .dispose() method from gpiosim-glib's chip class
The .dispose() method should be used to drop references to any other
GObjects while .finalize() should free any remaining memory. While we are
dropping references in .dispose(), these are references to the libgpiosim
objects that are also guaranteed to always be at most equal 1. Move the
reference drops to .finalize() and remove .dispose() entirely.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Wed, 1 Feb 2023 08:29:12 +0000 (09:29 +0100)]
tests: add a missing call to parent's implementation of .constructed()
In GObject inheriting classes must call the parent's implementation of
"virtual" methods manually. Add a missing call to parent's .constructed()
method in the GLib wrapper of libgpiosim.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Tue, 31 Jan 2023 18:29:16 +0000 (19:29 +0100)]
tests: shrink helper code
Use g_autoptr() for GVariantBuilder objects and shrink the code by a few
lines.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Tue, 31 Jan 2023 17:45:29 +0000 (18:45 +0100)]
configure: drop mention of a removed build option from comments
The make install-tests configure switch has been removed in commit
0dd2125c8ca9 ("tests: remove make check target") so don't mention it
in comments.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Tue, 31 Jan 2023 15:08:48 +0000 (16:08 +0100)]
gpioset: use #ifdef instead of #if with GPIOSET_INTERACTIVE
We're not setting GPIOSET_INTERACTIVE to any specific value that we'd
want to check so be consistent and use #ifdef everywhere to simply check
if it's defined or not.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Tue, 31 Jan 2023 14:53:27 +0000 (15:53 +0100)]
tests: fix a GVariant referencing bug
g_variant_new() returns a floating reference that must be converted to
a full reference before returning or else we may get weird reference
counting errors.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Mon, 30 Jan 2023 10:58:55 +0000 (11:58 +0100)]
doc: various tweaks and improvements treewide
Improve inline docs across the codebase. Fix formatting, unify the usage
of whitespaces inside comments, annotate argument names with '\p', etc.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Thu, 26 Jan 2023 12:24:39 +0000 (13:24 +0100)]
bindings: cxx: remove duplicate mapping helper
We have two helpers that do the same thing: given a key and a map, they
return the associated value or throw an exception if the map doesn't
contain it. The difference is just in the type of the exception. Remove
one and reuse the other. While at it: modify the names a bit for better
readability - especially the mapping function which is not limited to
just mapping enum types.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Thu, 26 Jan 2023 12:39:49 +0000 (13:39 +0100)]
bindings: cxx: don't shift raw pointers around
There are two leftover instances where we return raw C pointers from
local functions. For safety and consistency with the rest of the code
convert those functions to return unique_ptr.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Thu, 26 Jan 2023 12:36:16 +0000 (13:36 +0100)]
bindings: cxx: remove unused code
The malloc_deleter struct is a leftover from earlier implementation.
Drop it.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Fri, 13 Jan 2023 10:52:33 +0000 (11:52 +0100)]
bindings: rust: provide line_config.set_output_values()
Add a new function to line config allowing to set a list of output values
for requested lines. This works very similarily to the C++ version of the
new C interface.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Bartosz Golaszewski [Fri, 13 Jan 2023 14:12:46 +0000 (15:12 +0100)]
bindings: rust: make mutators return &mut self
In C++ bindings we can chain the mutators as they all return a reference
to the object they modify. It's a common practice to allow that in Rust
too so make all mutators that don't already do it return a mutable
reference to self.
It's also logically incorrect to make mutators borrow an immutable
reference to self. Even if that builds - as we're fiddling with C
pointers - it could change in the future. It's fine for getters but
setters should all use mutable references.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Bartosz Golaszewski [Fri, 13 Jan 2023 09:41:44 +0000 (10:41 +0100)]
bindings: python: add the output_values argument to Chip.request_lines()
Add a new optional argument to Chip.request_lines() called output_values.
It accepts a dictionary of mappings between line names or offsets to the
output values the requested lines should be set to at request-time.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Thu, 12 Jan 2023 18:30:25 +0000 (19:30 +0100)]
bindings: cxx: add line_config.set_output_values()
Extend line_config to expose a new method - set_output_values() - which
wraps the new C function for setting multiple output values at once.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Thu, 12 Jan 2023 18:13:12 +0000 (19:13 +0100)]
gpioset: use gpiod_line_config_set_output_values()
Use the new line config function to shrink the gpioset code and drop one
for loop.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Thu, 12 Jan 2023 18:12:51 +0000 (19:12 +0100)]
core: provide gpiod_line_config_set_output_values()
Currently if user wants to use the same settings for a set of requested
lines with the exception of the output value - they need to go through
hoops by updating the line settings object and adding it one by one to
the line config. Provide a helper function that allows to set a global
list of output values that override the settings. For details on the
interface: see documentation in this commit.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Tue, 24 Jan 2023 09:58:11 +0000 (10:58 +0100)]
treewide: unify gpiod_line_config/request_get_offsets() functions
We have two functions in the C API that allow users to retrieve a list
of offsets from objects: gpiod_line_request_get_offsets() and
gpiod_line_config_get_offsets(). Even though they serve pretty much the
same purpose, they have different signatures and one of them also
requires the user to free the memory allocated within the libgpiod
library with a non-libgpiod free() function.
Unify them: make them take the array in which to store offsets and the
size of this array. Make them return the number of offsets actually
stored in the array and make them impossible to fail. Change their names
to be more descriptive and in the case of line_config: add a new function
that allows users to get the number of configured offsets.
Update the entire tree to use the new interfaces.
For rust bindings: also unify the line config interface to return a map
of line settings like C++ bindings do instead of having a function to
get settings by offset. A map returned from a single call is easier to
iterate over with a for loop than using an integer and calling the
previous line_settings() method.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Viresh Kumar [Tue, 24 Jan 2023 08:23:43 +0000 (13:53 +0530)]
bindings: rust: Allow reusing locally installed gpio library
The rust crates builds fine when built with the 'make' command, as
static linking works fine. But when referenced from a remote rust crate,
it gives following error:
error: could not find native static library `gpiod`, perhaps an -L flag is missing?
This happens since we only support 'static' LIB-KIND currently. Remove
the same to allow others to work too.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Viresh Kumar [Tue, 24 Jan 2023 08:23:46 +0000 (13:53 +0530)]
bindings: rust: Align formatting to what's suggested by 'cargo fmt'
Align code to follow what 'cargo fmt' suggests.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Wed, 11 Jan 2023 12:30:24 +0000 (13:30 +0100)]
README: update for libgpiod v2
Certain parts of the README file still refer to concepts removed from
libgpiod v2. Update whatever needs updating.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Fri, 13 Jan 2023 13:51:09 +0000 (14:51 +0100)]
bindings: rust: make request_config optional in Chip.request_lines()
Request config is not necessary to request lines. In C API we accept
a NULL pointer, in C++ it's not necessary to assign a request_config
to the request builder, in Python the consumer and event buffer size
arguments are optional. Let's make rust bindings consistent and not
require the request config to be always present. Convert the argument
in request_lines to Option and update the rest of the code.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Bartosz Golaszewski [Thu, 12 Jan 2023 18:16:38 +0000 (19:16 +0100)]
tests: add a helper for reading back line settings from line config
Add a helper for getting line settings from line config that allows to
shrink the test code a bit.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Thu, 12 Jan 2023 18:15:12 +0000 (19:15 +0100)]
tests: fix the line config reset test case
We're using testing wrong variables in the reset_config test case. We
should be checking the retrieved0 settings which are read back from
the line config object.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Fri, 13 Jan 2023 08:52:24 +0000 (09:52 +0100)]
bindings: cxx: allow to copy line_settings
Implement the copy operator for line_settings. We have a copy() method
for line settings in C API while in C++ it's useful to copy line_settings
returned in an std::map from line_config.get_line_settings().
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Thu, 12 Jan 2023 18:36:32 +0000 (19:36 +0100)]
bindings: cxx: prepend all C symbols with the scope resolution operator
We explicitly resolve all global C symbols from libgpiod to the top-level
namespace. Fix it wherever its missing (mostly for C enum types).
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Wed, 11 Jan 2023 16:24:44 +0000 (17:24 +0100)]
doc: update docs for libgpiod v2
Update docs in gpiod.h wherever they're outdated or make incorrect
statements. While at it: fix formatting in some places.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Wed, 11 Jan 2023 13:13:21 +0000 (14:13 +0100)]
build: unify the coding style of source files lists in Makefiles
Use the most common and readable convention for listing source files
in Makefiles wherever it's not consistent yet.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Wed, 11 Jan 2023 13:08:40 +0000 (14:08 +0100)]
tests: avoid shadowing local variables with common names in macros
The name 'ret' if very common for local variables so change it to _ret
in test helper macros to avoid potential shadowing.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Bartosz Golaszewski [Mon, 16 Jan 2023 15:15:25 +0000 (16:15 +0100)]
build: update the required python version
We don't guarantee libgpiod python bindings to work with anything older
than python 3.9. Let's fix the required version in configure.ac.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Mon, 16 Jan 2023 15:08:21 +0000 (16:08 +0100)]
build: drop unused python-related bits from configure.ac
We no longer use autotools to build python bindings. We should still
check the interpreter but let's not set any automake variables.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Joerg Faschingbauer [Wed, 18 Jan 2023 09:11:45 +0000 (10:11 +0100)]
bindings: python: fix out-of-tree build
Makefile.am delegates the build of the python extension to its
setup.py file, which references the extension .c files relative to the
source dir. This makes it impossible to build in a directory that is
different from the source directory (for example, for PC and ARM but
from the same source).
* Invoke setup.py from $(srcdir)
* Modify setup.py to pick up .c files relative from setup.py's own
directory.
Signed-off-by: Joerg Faschingbauer <jf@faschingbauer.co.at>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Tue, 17 Jan 2023 08:24:44 +0000 (09:24 +0100)]
Revert "configure: replace deprecated macro"
This reverts commit
b353e7b1b65450d04bcbc72e42efc13b04d98a00.
AC_CHECK_INCLUDES_DEFAULT is only available in autoconf v2.70 while we
want to keep supporting v2.69.
Reported-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Kent Gibson [Mon, 16 Jan 2023 12:51:44 +0000 (20:51 +0800)]
bindings: rust: fix documentation of line_request set_values
Replace "Get" with "Set".
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>