Kent Gibson [Fri, 29 Dec 2023 09:33:27 +0000 (17:33 +0800)]
gpioset: reword note on post-exit behaviour
The note regarding the state of a line after gpioset exits is confusing
and unhelpful to the average reader, if not outright incorrect.
A common mis-interpretation is that this behaviour is arbitrarily chosen
by spiteful implementors. The note also specifies that the line reverts
to default, but that is not always the case, or is at least out of the
control of gpioset or libgpiod.
Reword the note to constrain the scope to that relevant to the likely
reader, and to emphasize that the behaviour is inherent in the kernel
GPIO interface, not in the gpioset implementation.
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Erik Schilling [Tue, 21 Nov 2023 08:43:03 +0000 (09:43 +0100)]
bindings: rust: libgpiod-sys: new release
During
86860fb ("bindings: rust: libgpiod: release 0.2.2"), I forgot that
we also need a libgpiod-sys release in order to expose the new feature
flag to raise the minimum libgpiod version.
Changelog:
7552e5d (bindings: rust: expose v2.1 features as flag, 2023-11-06)
bc91656 (bindings: rust: add wrapper.h to EXTRA_DIST, 2023-11-03)
2e6ee87 (bindings: rust: mention the libgpiod crate from libgpiod-sys, 2023-07-03)
d04639d (bindings: rust: bump MSRV to 1.60, 2023-06-16)
ebfed6c (bindings: rust: document build without install, 2023-06-12)
bce8623 (bindings: rust: exclude Makefile.am from package, 2023-06-12)
caabf53 (bindings: rust: add missing license and copyright boilerplate, 2023-06-13)
Most changes only touch the build scripts or modify packaging details.
Bumping the MSRV and introducing a new feature does not require a major
bump.
Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Erik Schilling [Tue, 14 Nov 2023 08:43:40 +0000 (09:43 +0100)]
bindings: rust: libgpiod: release 0.2.2
Minor update the exposes feature flag and bindings for v2.1.
Changelog:
==========
7552e5d (bindings: rust: expose v2.1 features as flag, 2023-11-06)
bc91656 (bindings: rust: add wrapper.h to EXTRA_DIST, 2023-11-03)
3b40a37 (bindings: rust: fix EXTRA_DIST for examples, 2023-11-03)
Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Thu, 9 Nov 2023 20:26:53 +0000 (21:26 +0100)]
bindings: python: gpiod v2.1.3
Another small bugfix release addressing an issue with building tests.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Thu, 9 Nov 2023 20:21:24 +0000 (21:21 +0100)]
bindings: python: add build_tests.py to the manifest
build_tests.py is not part of the sdist so tests cannot be built from
pypi releases. Add it to MANIFEST.in.
Fixes: d588a6a5928a ("bindings: python: standalone build tooling for tests")
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Thu, 9 Nov 2023 20:13:47 +0000 (21:13 +0100)]
bindings: python: gpiod v2.1.2
This is a small bugfix release improving how the C extensions for python
bindings tests are built.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Phil Howard [Wed, 8 Nov 2023 15:52:00 +0000 (15:52 +0000)]
bindings: python: standalone build tooling for tests
Move extension definitions and tooling for building tests into
`build_tests.py` and update Makefile.am to call it with appropriate path
prefixes.
`build_tests.py` will perform a standalone build of the text extensions,
keeping any build noise in a temporary directory and copying the final
built modules automatically out to `tests/gpiosim` and `tests/procname`.
Add "python-tests-run" to Makefile.am so it's clear how to run the tests.
Add .so object files generated by build_test.py to Makefile.am's
clean-local.
Signed-off-by: Phil Howard <phil@gadgetoid.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Erik Schilling [Mon, 6 Nov 2023 12:53:14 +0000 (13:53 +0100)]
bindings: rust: expose v2.1 features as flag
v2.1 provided a getter to read the chip name from a request.
This adds v2_1 as feature in order to raise the minimum requested version
to v2.1 for exposing the new API.
This is identical to the concept patch that was posted [1] when this
feature flag mechanism was proposed. Only the commit message was
reworded.
[1] https://lore.kernel.org/all/
20231006-b4-bindings-old-version-fix-v1-2-
a65f431afb97@linaro.org/
Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Fri, 3 Nov 2023 19:31:23 +0000 (20:31 +0100)]
bindings: python: gpiod v2.1.1
This is a small bugfix release of the python bindings fixing how the
homepage on pypi is displayed.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Phil Howard [Fri, 3 Nov 2023 19:14:55 +0000 (19:14 +0000)]
bindings: python: fix README.md SPDX license tags
Replace the # (which is a markdown heading) with HTML tags to hide SPDX
identifier tags within the project description on pypi.
Signed-off-by: Phil Howard <phil@gadgetoid.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Fri, 3 Nov 2023 18:34:25 +0000 (19:34 +0100)]
bindings: python: gpiod v2.1.0
Release libgpiod python bindings v2.1.0.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Fri, 3 Nov 2023 16:40:15 +0000 (17:40 +0100)]
libgpiod: start v2.2 development cycle
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Fri, 3 Nov 2023 13:25:38 +0000 (14:25 +0100)]
libgpiod v2.1
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Fri, 3 Nov 2023 13:25:14 +0000 (14:25 +0100)]
NEWS: updates for v2.1
Add release notes for libgpiod v2.1.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Fri, 3 Nov 2023 16:17:00 +0000 (17:17 +0100)]
tests: fix version parsing (again)
This time we missed the fact that the last part is optional. Fix it
treewide.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Fri, 3 Nov 2023 13:06:06 +0000 (14:06 +0100)]
tools: tests: include the test script in the release tarball
Apparently bash scripts need to be listed in the dist_noinst_SCRIPTS in
order to be picked up into the dist package, noinst_SCRIPTS is not
enough.
Fixes: 555f5e4cfe9f ("tools: tests: port tests to shunit2")
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Fri, 3 Nov 2023 13:01:27 +0000 (14:01 +0100)]
bindings: rust: add wrapper.h to EXTRA_DIST
We need to package wrapper.h in the release tarball so add it to
EXTRA_DIST.
Fixes: 1f8085953086 ("bindings: rust: build against pkg-config info")
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Fri, 3 Nov 2023 11:04:16 +0000 (12:04 +0100)]
bindings: rust: fix EXTRA_DIST for examples
One of the examples listed in EXTRA_DIST is missing the .rs suffix while
another lists a file that doesn't exist. Fix both issues.
Fixes: aaed0f2e6255 ("bindings: rust: examples: replace tools examples with use case examples")
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Fri, 3 Nov 2023 10:53:11 +0000 (11:53 +0100)]
bindings: python: fix EXTRA_DIST for examples
One of the example scripts is named differently than what the Makefile
lists it as. Change the EXTRA_DIST variable to fix it.
Fixes: 96c52d3e595b ("bindings: python: examples: replace tools examples with use case examples")
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Phil Howard [Wed, 25 Oct 2023 08:27:07 +0000 (09:27 +0100)]
bindings: python: optionally include module in sdist
Optionally vendor libgpiod source into sdist so that the Python module can
be built from source, even with a missing or mismatched system libgpiod.
Add two new environment variables "LINK_SYSTEM_LIBGPIOD" and
"LIBGPIOD_VERSION" to control what kind of package setup.py will build.
In order to build an sdist or wheel package with a vendored libgpiod a
version must be specified via the "LIBGPIOD_VERSION" environment variable.
This will instruct setup.py to verify the given version against the list
in sha256sums.asc and ensure it meets or exceeds a LIBGPIOD_MINIMUM_VERSION
required for compatibility with the bindings.
It will then fetch the tarball matching the requested version from
mirrors.edge.kernel.org, verify the sha256 signature, unpack it, and copy
the lib and include directories into the package root so they can be
included in sdist or used to build a binary wheel.
eg: LIBGPIOD_VERSION=2.1.0 python3 setup.py sdist
Will build a source distribution with gpiod version 2.1.0 source included.
It will also save the gpiod version into "libgpiod-version.txt" so that it
can be passed to the build when the sdist is built by pip.
Requiring an explicit version ensures that the Python bindings - which
can be changed and versions independent of libgpiod - are built against a
stable libgpiod release.
In order to force a package with vendored gpiod source to link the system
libgpiod, the "LINK_SYSTEM_LIBGPIOD" environment variable can be used:
eg: LINK_SYSTEM_LIBGPIOD=1 pip install libgpiod
Signed-off-by: Phil Howard <phil@gadgetoid.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Phil Howard [Tue, 17 Oct 2023 14:55:49 +0000 (15:55 +0100)]
bindings: python: move long_description into README.md
Move the long_description into README.md and include some basic
information about libgpiod, and some simple Python example code.
Signed-off-by: Phil Howard <phil@gadgetoid.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Tue, 17 Oct 2023 11:41:59 +0000 (13:41 +0200)]
bindings: python: change the package name to 'gpiod'
We now control the name 'gpiod' on pypi. Let's change the project name
as the package we import in python code is named 'gpiod' and not
'libgpiod'
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Tue, 24 Oct 2023 07:55:12 +0000 (09:55 +0200)]
bindings: python: fix the distutils import
The presence of _distutils in setuptools is an implementation detail. If
we want anything from the distutils package, we should import it directly.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Phil Howard [Thu, 12 Oct 2023 19:51:39 +0000 (20:51 +0100)]
bindings: python: simplify environ access
Use environ.get() in lieu of an explicit check for GPIOD_WITH_TESTS in
os.environ.
Returns None and evaluates as False if GPIOD_WITH_TESTS == "1" is
not specified.
Signed-off-by: Phil Howard <phil@gadgetoid.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Phil Howard [Thu, 12 Oct 2023 21:02:28 +0000 (22:02 +0100)]
bindings: python: add pyproject.toml, pep 518
Add pyproject.toml to prevent spurious deprecation warnings from pip.
Signed-off-by: Phil Howard <phil@gadgetoid.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Phil Howard [Wed, 11 Oct 2023 12:12:46 +0000 (13:12 +0100)]
bindings: python: require python 3.9.0
Required minimum version for PyModule_AddType helper.
Signed-off-by: Phil Howard <phil@gadgetoid.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Erik Schilling [Tue, 10 Oct 2023 07:13:11 +0000 (09:13 +0200)]
bindings: rust: libgpiod: release 0.2.1
While the release technically removes a function, that function was not
available in any released libgpiod version. Therefore, this only bumps
the minor.
This release fixes building with releases from the 2.x series of the C
lib.
Changelog:
=========
acebcf2 (bindings: rust: feature gate unreleased features, 2023-10-06)
Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Mon, 9 Oct 2023 19:02:52 +0000 (21:02 +0200)]
bindings: python: replace PyModule_AddObjectRef() with PyModule_AddObject()
PyModule_AddObjectRef() was added in cpython v3.10 while libgpiod claims
to depend on python v3.9. Replace it with an older variant that steals the
reference to the added object on success.
Reported-by: Phil Howard <phil@gadgetoid.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Erik Schilling [Fri, 6 Oct 2023 07:24:26 +0000 (09:24 +0200)]
bindings: rust: feature gate unreleased features
`gpiod_line_request_get_chip_name()` is not released yet. Still, libgpiod-sys
will just happily generate bindings for it if it sees the definition in the
header file.
This guards the unreleased features behind an optional feature `vnext`.
To sketch the process of what happens once these features get into an
assumed "2.1" release:
libgpiod-sys will get updated with a `v2_1` feature. That feature would
then raise the minimum version that is attempted to query from pkg-
config. An identical feature will then be introduced on the `libgpiod`
crate and `vnext` guards will be changed to `v2_1` guards. The `vnext`
feature will then be updated to require the new `v2_1` feature.
Eventually, we will probably raise the minimum supported version for the
rust bindings and drop all the version gates before that.
Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Erik Schilling [Thu, 5 Oct 2023 07:42:23 +0000 (09:42 +0200)]
bindings: rust: libgpiod: release 0.2.0
Since we had some (potentially-)breaking changes, we bump the major for
the next release of the crate.
Note:
I am using the term "major" as defined in the Rust SemVer compatibility
guide [1], where the first non-zero digit is considered as "major".
[1] https://doc.rust-lang.org/cargo/reference/semver.html
Changelog:
=========
(potentially-)breaking changes:
a29f3e6 (bindings: rust: rename {event,settings}_clone to try_clone, 2023-10-04)
b290348 (bindings: rust: fix soundness of line_info modeling, 2023-10-03)
d04639d (bindings: rust: bump MSRV to 1.60, 2023-06-16)
new functionality:
808d15e (bindings: rust: allow cloning line::InfoRef -> line::Info, 2023-10-03)
64aac85 (bindings: rust: mark all owning types as `Send`, 2023-09-28)
d12ce74 (bindings: rust: provide LineRequest::chip_name(), 2023-07-20)
53226d5 (bindings: rust: examples: add dedicated examples, 2023-06-14)
other changes:
0a570b6 (bindings: rust: drop unneeded Arc within Chip, 2023-09-27)
a97fe96 (bindings: rust: construct chip infos by reference, 2023-09-27)
27afa47 (bindings: rust: remove useless clone, 2023-09-28)
3f6e0bf (bindings: rust: add README.md for libgpiod crate, 2023-07-03)
4b8357b (bindings: rust: clippy: silence false-positive on iterator, 2023-06-30)
39189f0 (bindings: rust: clippy: drop unneeded conversions, 2023-06-30)
46115fd (bindings: rust: clippy: silence false-positives on casts, 2023-06-30)
901104e (bindings: rust: clippy: drop unnecessary casts, 2023-06-30)
46ecbe0 (rust: examples: file comment consistency, 2023-06-24)
aaed0f2 (bindings: rust: examples: replace tools examples with use case examples, 2023-06-23)
b37bd9e (bindings: rust: examples: consistency cleanup, 2023-06-23)
06c8ad9 (bindings: rust: package new examples in the distro tarball, 2023-06-15)
Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Erik Schilling [Wed, 4 Oct 2023 13:00:00 +0000 (15:00 +0200)]
bindings: rust: rename {event,settings}_clone to try_clone
What is getting cloned is already clear from the type. This also aligns
a bit better with similar methods from the `std` crate [1].
[1] https://doc.rust-lang.org/std/index.html?search=try_clone
Link: https://lore.kernel.org/r/CVUKC1HXG1P8.13XIUCCXN95F0@ablu-work
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Erik Schilling [Tue, 3 Oct 2023 09:39:59 +0000 (11:39 +0200)]
bindings: rust: allow cloning line::InfoRef -> line::Info
While one would usually use the ToOwned [1] contract in rust, libgpipd's
API only allows copying that may fail.
Thus, we cannot implement the existing trait and roll our own method. I
went with `try_clone` since that seems to be used in similar cases across
the `std` crate [2].
It also closes the gap of not having any way to clone owned instances.
Though - again - not through the Clone trait which may not fail [3].
[1] https://doc.rust-lang.org/std/borrow/trait.ToOwned.html
[2] https://doc.rust-lang.org/std/index.html?search=try_clone
[3] https://doc.rust-lang.org/std/clone/trait.Clone.html
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Erik Schilling [Tue, 3 Oct 2023 09:39:57 +0000 (11:39 +0200)]
bindings: rust: fix soundness of line_info modeling
While attention was provided to prevent freeing in non-owned use-cases,
the lifetime of these object was not properly modeled.
The line_info from an event may only be used for as long as the event
exists.
This allowed us to write unsafe-free Rust code that causes a
use-after-free:
let event = chip.read_info_event().unwrap();
let line_info = event.line_info().unwrap();
drop(event);
dbg!(line_info.name().unwrap());
Which makes the AddressSanitizer scream:
==90154==ERROR: AddressSanitizer: heap-use-after-free on address 0x50b000005dc4 at pc 0x55a4f883a009 bp 0x7f60ac8fbbc0 sp 0x7f60ac8fb388
READ of size 2 at 0x50b000005dc4 thread T2
[...]
#3 0x55a4f8c3d5f3 in libgpiod::line_info::Info::name::h5ba0bfd360ecb405 libgpiod/bindings/rust/libgpiod/src/line_info.rs:70:18
[...]
0x50b000005dc4 is located 4 bytes inside of 112-byte region [0x50b000005dc0,0x50b000005e30)
freed by thread T2 here:
[...]
#1 0x7f60b07f7e31 in gpiod_info_event_free libgpiod/lib/info-event.c:61:2
[...]
previously allocated by thread T2 here:
#0 0x55a4f88b04be in malloc /rustc/llvm/src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:69:3
#1 0x7f60b07f8ff0 in gpiod_line_info_from_uapi libgpiod/lib/line-info.c:144:9
The fix is to distinguish between the owned and non-owned variants and
assigning lifetimes to non-owned variants.
For modeling the non-owned type there are a couple of options. The ideal
solution would be using extern_types [1]. But that is still unstable.
Instead, we are defining a #[repr(transparent)] wrapper around the opaque
gpiod_line_info struct and cast the pointer to a reference.
This was recommended on the Rust Discord server as good practise.
(Thanks to Kyuuhachi, shepmaster, pie_flavor and ilyvion! Also thanks to
@epilys for a brainstorming on this on #linaro-virtualization IRC).
Of course, determining the lifetimes and casting across the types
requires some care. So this adds a couple of SAFETY comments that would
probably also have helped the existing code.
[1] https://github.com/rust-lang/rfcs/blob/master/text/1861-extern-types.md
Fixes: 91f9373c6558 ("bindings: rust: Add libgpiod crate")
Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Erik Schilling [Thu, 28 Sep 2023 14:37:30 +0000 (16:37 +0200)]
bindings: rust: mark all owning types as `Send`
The thread-safety rules of libgpiod allow individual object instances to
be used from different threads. So far, this was not actually possible
with the Rust bindings. Not being `Send` disallowed the user to transfer
the ownership to different threads.
Rust also has a `Sync` marker. That one would even allow sending
references of objects to other threads. Since we wrap a lot of C
functions with `fn foo(&self)` signatures, that would not be safe.
libgpiod does not allow concurrent API calls to the same object instance
- which Rust would allow for read-only references. Thus, we do not
define that one.
Chip was already modeled correctly.
line::Info is not marked as Send since it may either be owning or non-
owning. That problem is fixed as part of a separate pull request [1].
[1] https://lore.kernel.org/r/
20230927-rust-line-info-soundness-v1-0-
990dce6f18ab@linaro.org
Link: https://lore.kernel.org/r/CVHO091CC80Y.3KUOSLSOBVL0T@ablu-work
Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Erik Schilling [Thu, 28 Sep 2023 14:37:29 +0000 (16:37 +0200)]
doc: document thread safety guarantees
This mostly adds the information from the linked thread to the doxygen
documentation.
Summarized:
- libgpiod object's require synchronization
- individual objects may be used concurrently by different threds
Link: https://lore.kernel.org/r/CVHO091CC80Y.3KUOSLSOBVL0T@ablu-work
Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Erik Schilling [Thu, 28 Sep 2023 14:37:28 +0000 (16:37 +0200)]
doc: drop unneeded <p> tags
Even before Doxygen gained Markdown support, empty lines were considered
as paragraphs. Changelogs indicate that this was the case since at least
the doxygen 1.2 series (where I found a mentiond that something around
this behaviour was fixed). So at least works in Doxygen versions
released after 2001 [1].
[1] https://sourceforge.net/p/doxygen/mailman/message/172899/
Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Erik Schilling [Wed, 27 Sep 2023 09:25:24 +0000 (11:25 +0200)]
bindings: rust: drop unneeded Arc within Chip
Chip was modeled with an Arc that only was used to pass the chip pointer
to the chip::Info constructor. With that refactored to take a reference,
we can just drop the Arc.
This allows to get rid of the `Internal` helper struct that was only
required by the Arc.
As a side-effect, we also get rid of this clippy warning:
warning: usage of an `Arc` that is not `Send` or `Sync`
--> libgpiod/src/chip.rs:75:21
|
75 | let ichip = Arc::new(Internal::open(path)?);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: the trait `Send` is not implemented for `Internal`
= note: the trait `Sync` is not implemented for `Internal`
= note: required for `Arc<Internal>` to implement `Send` and `Sync`
= help: consider using an `Rc` instead or wrapping the inner type with a `Mutex`
Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Erik Schilling [Wed, 27 Sep 2023 09:25:23 +0000 (11:25 +0200)]
bindings: rust: construct chip infos by reference
No need to clone the Arc for this. A simple reference is enough to get
to the underlying chip pointer.
Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Erik Schilling [Thu, 28 Sep 2023 06:23:19 +0000 (08:23 +0200)]
bindings: rust: remove useless clone
Reported by 1.74.0-nightly:
warning: call to `.clone()` on a reference in this situation does nothing
--> libgpiod/tests/line_request.rs:71:44
|
71 | let chip_name = sim.chip_name().clone();
| ^^^^^^^^ help: remove this redundant call
|
= note: the type `str` does not implement `Clone`, so calling `clone` on `&str` copies the reference, which does not do anything and can be removed
= note: `#[warn(noop_method_call)]` on by default
Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Tue, 19 Sep 2023 09:31:42 +0000 (11:31 +0200)]
bindings: python: tests: don't use the same chip from different threads
There are no thread-safety guarantees in libgpiod. Let's not reuse the
chip object created in one thread to generate info events in another but
use a global request function instead.
Reported-by: Erik Schilling <erik.schilling@linaro.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Reviewed-by: Erik Schilling <erik.schilling@linaro.org>
Bartosz Golaszewski [Tue, 19 Sep 2023 09:31:41 +0000 (11:31 +0200)]
bindings: cxx: tests: don't use the same chip from different threads
There are no thread-safety guarantees in libgpiod. Let's not reuse the
chip object created in one thread to generate info events in another but
create a second chip for that purpose instead.
Reported-by: Erik Schilling <erik.schilling@linaro.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Reviewed-by: Erik Schilling <erik.schilling@linaro.org>
Bartosz Golaszewski [Tue, 19 Sep 2023 09:31:40 +0000 (11:31 +0200)]
tests: don't use the same chip object from different threads
There are no thread-safety guarantees in libgpiod. Let's not reuse the
chip object created in one thread to generate info events in another but
create a second chip for that purpose instead.
Reported-by: Erik Schilling <erik.schilling@linaro.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Reviewed-by: Erik Schilling <erik.schilling@linaro.org>
Bartosz Golaszewski [Sun, 6 Aug 2023 20:16:15 +0000 (22:16 +0200)]
tests: add missing return value check
One of the line-request test cases is missing the return value check
after the call to gpiod_line_request_set_values_subset(). Add it.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Kent Gibson [Thu, 27 Jul 2023 21:10:56 +0000 (05:10 +0800)]
examples: simplify find_line_by_name
Simplify the find_line_by_name example by using
gpiod_chip_get_line_offset_from_name() rather than iterating over each
line in a chip.
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Thu, 20 Jul 2023 14:47:47 +0000 (16:47 +0200)]
bindings: rust: provide LineRequest::chip_name()
Provide a wrapper around gpiod_line_request_get_chip_name() for Rust
bindings and add a test-case.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Reviewed-by: Erik Schilling <erik.schilling@linaro.org>
Reviewed-by: Kent Gibson <warthog618@gmail.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Bartosz Golaszewski [Thu, 20 Jul 2023 14:47:46 +0000 (16:47 +0200)]
bindings: python: provide the chip_name property in line_request
Provide a wrapper around gpiod_line_request_get_chip_name() for Python
bindings and update the tests.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Thu, 20 Jul 2023 14:47:45 +0000 (16:47 +0200)]
bindings: cxx: provide line_request::chip_name()
Provide a wrapper around gpiod_line_request_get_chip_name() for C++
bindings and update the tests.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Thu, 20 Jul 2023 14:47:44 +0000 (16:47 +0200)]
tests: add a test-case for gpiod_line_request_get_chip_name()
Add a test case for the chip name getter on line-request objects.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Thu, 20 Jul 2023 14:47:43 +0000 (16:47 +0200)]
core: provide gpiod_line_request_get_chip_name()
While we can get the list of requested offsets from a line-request object,
this information lacks context if we don't provide any data about the GPIO
chip the request was made on. Add a helper allowing users to get the name
of the parent chip.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Erik Schilling [Mon, 3 Jul 2023 07:20:00 +0000 (09:20 +0200)]
bindings: rust: mention the libgpiod crate from libgpiod-sys
If people view this README.md on crates.io [1], they likely want to
use the safe wrapper instead. So this hints the existence of that other
crate.
[1] https://crates.io/crates/libgpiod-sys
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Erik Schilling [Mon, 3 Jul 2023 07:19:59 +0000 (09:19 +0200)]
bindings: rust: add README.md for libgpiod crate
crates.io treats the README as landing page for a crate [1]. Since
we have none, it currently displays a blank page. Lets add at least a
little bit of info here so people can figure out what they are dealing
with.
[1] https://crates.io/crates/libgpiod
Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Mon, 3 Jul 2023 10:39:06 +0000 (12:39 +0200)]
tools: tests: print additional info when regex matching fails
Add shunit assert messages when testing the result of regex matches,
otherwise we're left with a not very useful: "expected:<0> but was:<1>".
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Fri, 30 Jun 2023 12:28:25 +0000 (14:28 +0200)]
build: remove redundant SOURCES assignments
For any given target (let's say foobar), automake defaults to looking for
foobar.c if foobar_SOURCES are not specified. Remove redundant assignments
as we've seen multiple hidden typos in makefiles already.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Reviewed-by: Kent Gibson <warthog618@gmail.com>
Kent Gibson [Fri, 30 Jun 2023 09:08:57 +0000 (17:08 +0800)]
core: examples: fix warning for u64 formatting on 32bit
The watch_line_info example prints the u64 timestamps using "%ld" which
produces a warning for 32bit. Replace it with PRIu64.
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Erik Schilling [Fri, 30 Jun 2023 11:18:47 +0000 (13:18 +0200)]
bindings: rust: clippy: silence false-positive on iterator
This was fixed on clippy master [1], but it is still broken on 0.1.70. So
lets silence it until the clippy fix is widely available.
clippy version: clippy 0.1.70 (
90c5418 2023-05-31).
[1] https://github.com/rust-lang/rust-clippy/commit/
9fa40894103e32364fdbade539d4ecb3d40f3d7f
Reported-by: Kent Gibson <warthog618@gmail.com>
Link: https://lore.kernel.org/r/20230612154055.56556-1-warthog618@gmail.com
Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Erik Schilling [Fri, 30 Jun 2023 11:18:46 +0000 (13:18 +0200)]
bindings: rust: clippy: drop unneeded conversions
Fixes clippy warnings on these lines.
Applied the suggested fix using:
cargo clippy --fix
clippy version: clippy 0.1.70 (
90c5418 2023-05-31).
Reported-by: Kent Gibson <warthog618@gmail.com>
Link: https://lore.kernel.org/r/20230612154055.56556-1-warthog618@gmail.com
Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Erik Schilling [Fri, 30 Jun 2023 11:18:45 +0000 (13:18 +0200)]
bindings: rust: clippy: silence false-positives on casts
clippy falsely complains about these lines. The problem is known, but
unfixed [1]. So lets silence the warning until a fix is widely available.
clippy version: clippy 0.1.70 (
90c5418 2023-05-31).
[1] https://github.com/rust-lang/rust-clippy/issues/10555
Reported-by: Kent Gibson <warthog618@gmail.com>
Link: https://lore.kernel.org/r/20230612154055.56556-1-warthog618@gmail.com
Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Erik Schilling [Fri, 30 Jun 2023 11:18:44 +0000 (13:18 +0200)]
bindings: rust: clippy: drop unnecessary casts
Fixes clippy warnings on these lines.
Applied the suggested fix using:
cargo clippy --fix
clippy version: clippy 0.1.70 (
90c5418 2023-05-31).
Reported-by: Kent Gibson <warthog618@gmail.com>
Link: https://lore.kernel.org/r/20230612154055.56556-1-warthog618@gmail.com
Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Kent Gibson [Thu, 29 Jun 2023 10:14:55 +0000 (18:14 +0800)]
bindings: rust: fix unclear resolver warning
Fix the following warning:
"some crates are on edition 2021 which defaults to `resolver = "2"`,
but virtual workspaces default to `resolver = "1"`"
Clarify the resolver selection as the 2021 edition by setting the
workspace.resolver to "2".
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Reviewed-by: Erik Schilling <erik.schilling@linaro.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Mon, 26 Jun 2023 10:44:57 +0000 (12:44 +0200)]
bindings: cxx: use () instead of (void) in line_settings::reset()
While () and (void) are synonymous in C++, we use () everywhere else so
fix the only exception. This DOES NOT change the ABI as the generated
symbol is the same (at least as verified on gcc and clang).
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Mon, 26 Jun 2023 10:36:03 +0000 (12:36 +0200)]
bindings: cxx: examples: consistently use () for functions taking no args
While () and (void) are synonymous in C++, we use () everywhere else so
stick to that pattern in examples.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Erik Schilling [Mon, 26 Jun 2023 13:14:29 +0000 (15:14 +0200)]
gpiosim: fix data race that corrupts heap
Hit this while seeing some heap corruptions when running cargo test on
the Rust bindings.
Took a bit to track down since I first used address sanitizers, but with
the thread sanitizer it becomes obvious immediately (output simplified):
==================
WARNING: ThreadSanitizer: data race (pid=288119)
Write of size 8 at 0x0000018f1e78 by thread T6:
#0 id_free /libgpiod/tests/gpiosim/gpiosim.c:141:17
#1 dev_release /libgpiod/tests/gpiosim/gpiosim.c:600:2
#2 refcount_dec /libgpiod/tests/gpiosim/gpiosim.c:176:3
#3 gpiosim_dev_unref /libgpiod/tests/gpiosim/gpiosim.c:671:2
#4 bank_release /libgpiod/tests/gpiosim/gpiosim.c:873:2
#5 refcount_dec /libgpiod/tests/gpiosim/gpiosim.c:176:3
#6 gpiosim_bank_unref /libgpiod/tests/gpiosim/gpiosim.c:941:2
[...]
Previous write of size 8 at 0x0000018f1e78 by thread T1:
#0 id_free /libgpiod/tests/gpiosim/gpiosim.c:141:17
#1 bank_release /libgpiod/tests/gpiosim/gpiosim.c:878:2
#2 refcount_dec /libgpiod/tests/gpiosim/gpiosim.c:176:3
#3 gpiosim_bank_unref /libgpiod/tests/gpiosim/gpiosim.c:941:2
[...]
Location is global 'id_del_ctx' of size 16 at 0x0000018f1e70
Thread T6 'chip::verify::f' (tid=288126, running) created by main thread at:
#7 test::run_tests::hd53a07a011bd771f /.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:407:21
[...]
Thread T1 'chip::open::gpi' (tid=288121, finished) created by main thread at:
#7 test::run_tests::hd53a07a011bd771f /.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:407:21
[...]
SUMMARY: ThreadSanitizer: data race /libgpiod/tests/gpiosim/gpiosim.c:141:17 in id_free
==================
This eventually can either lead to leaks or double free's that corrupt
the heap and lead to crashes.
The issue got introduced when a previously local variable that did not
require protection was turned into a global variable.
Fixes: 5e111df2fca5 ("gpiosim: use twalk() instead of twalk_r()")
Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Kent Gibson [Mon, 26 Jun 2023 08:34:02 +0000 (16:34 +0800)]
bindings: python: examples: replace tools examples with use case examples
Replace tool examples with use case examples drawn from the tools.
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Kent Gibson [Sat, 24 Jun 2023 05:20:54 +0000 (13:20 +0800)]
rust: examples: file comment consistency
Make the file comment for reconfigure_input_to_output consistent with
other language examples.
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Kent Gibson [Sat, 24 Jun 2023 05:20:53 +0000 (13:20 +0800)]
cxx: examples: file comment consistency
Make the file comment for reconfigure_input_to_output consistent with
other language examples.
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Kent Gibson [Sat, 24 Jun 2023 05:20:52 +0000 (13:20 +0800)]
core: examples: fix file comments
Some of the file comments are cut-and-paste errors, so replace them
with the correct comment.
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Kent Gibson [Fri, 23 Jun 2023 04:39:01 +0000 (12:39 +0800)]
bindings: rust: examples: replace tools examples with use case examples
Replace tool examples with use case examples drawn from the tools,
gpio_events example with buffered_event_lifetimes, and
gpio_threaded_info_events with reconfigure_input_to_output.
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Reviewed-by: Erik Schilling <erik.schilling@linaro.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Kent Gibson [Fri, 23 Jun 2023 04:39:00 +0000 (12:39 +0800)]
bindings: rust: examples: consistency cleanup
A collection of minor changes to be more consistent with other examples:
- capitalize comments
- add line offset to value outputs
- drop comma from edge event outputs
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Reviewed-by: Erik Schilling <erik.schilling@linaro.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Kent Gibson [Fri, 23 Jun 2023 04:38:58 +0000 (12:38 +0800)]
bindings: python: examples: consistency cleanup
A collection of minor changes to be more consistent with other examples:
- capitalize comments
- add line offset to value outputs
- drop comma from edge event outputs
- improve behaviour if run on a platform that does not match the
example configuration
- use with to cleanup request in toggle_line_value.py
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Kent Gibson [Fri, 23 Jun 2023 04:38:57 +0000 (12:38 +0800)]
bindings: cxx: examples: replace tools examples with use case examples
Replace tool examples with use case examples drawn from the tools.
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Kent Gibson [Fri, 23 Jun 2023 04:38:56 +0000 (12:38 +0800)]
bindings: cxx: examples: consistency cleanup
A collection of minor changes to be more consistent with other examples:
- capitalize comments
- add line offset to value outputs
- drop comma from edge event outputs
- drop trailing return where example loops indefintely
- sort includes
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Kent Gibson [Fri, 23 Jun 2023 04:38:55 +0000 (12:38 +0800)]
core: examples: add more use case examples
Add examples for use cases drawn from the tools.
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Kent Gibson [Fri, 23 Jun 2023 04:38:54 +0000 (12:38 +0800)]
core: examples: consistency cleanups
A collection of minor cleanups to make the examples more consistent and
ease the addition of more examples:
- reformat Makefile.am to simplify adding more examples
- add line offset to value output
- remove commas from edge event output
- replace while(1) with for (;;)
- fix a typo in Makefile.am
- fix an error handling goto in toggle_line_value.c
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Thu, 22 Jun 2023 07:32:39 +0000 (09:32 +0200)]
tools: tests: remove a stray newline
There's an unnecessary double newline in one of the test cases. Drop it.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Thu, 15 Jun 2023 11:57:45 +0000 (13:57 +0200)]
tools: tests: port tests to shunit2
BATS has been confirmed to run much more slowly that shunit2. This is
most likely caused by the way BATS evaluates each test file n+1 times
where n is the number of tests[1].
Port tests to using shunit2 which executes as a regular shell script
which, in addition to higher speed, allows for easier debugging as
standard shell flags like -x now work.
[1] https://bats-core.readthedocs.io/en/stable/writing-tests.html
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Reviewed-by: Kent Gibson <warthog618@gmail.com>
Bartosz Golaszewski [Wed, 21 Jun 2023 07:23:27 +0000 (09:23 +0200)]
tools: tests: add short sleeps between generating edge events
Toggling the gpio-sim pull too fast can lead to losing events by gpiomon.
Add short sleeps between the calls to gpiosim_set_pull.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Erik Schilling [Fri, 16 Jun 2023 08:37:48 +0000 (10:37 +0200)]
bindings: rust: bump MSRV to 1.60
Specifying MSRV (minimum supported rust version) was introduced with
Rust 1.56. So old versions of libraries do not have this restriction
spelled out in their Cargo.toml.
This means that even if we claimed a MSRV of 1.56 until now, that did
not mean that things were actually buildable with 1.56 practically
(without manually researching compatible versions and pinning them
down).
`bindgen` started listing a MSRV from v0.61 (requiring Rust 1.57) [1].
So that may seem like an obvious choice. But if one attempts to build
it with such an old version one will realize that `log` only started
requesting a MSRV with 0.4.19 (requesting Rust 1.60) [2]. Hence, we
would either need to manually restrict log to an old, but compatible
release (which would unnecessarily restrict everyone on newer Rust
versions) or just also bump our MSRV to 1.60.
Rust 1.60 was released on 2022-04-07 [3] and seems like an acceptable
choice if core components such as `log` started their MSRV tracking with
that version. If someone is determined wanting to use this with an older
version of Rust, thats still possible. If one has done the necessary
manual research and pinned their versions down, one can use
--ignore-rust-version (or a < 1.56 version of Rust that does not check
the MSRV yet).
Thanks to Manos Pitsidianakis <manos.pitsidianakis@linaro.org> for
helping me out when I successfully confused myself somewhere.
[1] https://github.com/rust-lang/rust-bindgen/blob/v0.61.0/bindgen/Cargo.toml
[2] https://github.com/rust-lang/log/blob/0.4.19/Cargo.toml
[3] https://blog.rust-lang.org/2022/04/07/Rust-1.60.0.html
Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Thu, 15 Jun 2023 08:50:26 +0000 (10:50 +0200)]
bindings: rust: package new examples in the distro tarball
Add new example files to EXTRA_DIST in the Makefile so that they end up
being shipped with the rest of the code.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Thu, 15 Jun 2023 08:43:31 +0000 (10:43 +0200)]
bindings: python: package new examples in the distro tarball
Add new example scripts to EXTRA_DIST in the Makefile so that they end up
being shipped with the rest of the code.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Kent Gibson [Wed, 14 Jun 2023 03:54:26 +0000 (11:54 +0800)]
bindings: rust: examples: add dedicated examples
Add rust equivalents of the core examples.
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Reviewed-by: Erik Schilling <erik.schilling@linaro.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Kent Gibson [Wed, 14 Jun 2023 03:54:25 +0000 (11:54 +0800)]
bindings: python: examples: add dedicated examples
Add python equivalents of the core examples.
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Kent Gibson [Wed, 14 Jun 2023 03:54:24 +0000 (11:54 +0800)]
bindings: cxx: examples: add dedicated examples
Add cxx equivalents of the core examples.
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Kent Gibson [Wed, 14 Jun 2023 03:54:23 +0000 (11:54 +0800)]
examples: add dedicated examples
The tools have served as example code, but have become too complicated
to serve that purpose.
Add a set of examples that have no purpose other than providing minimal
examples of common use cases.
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Mon, 12 Jun 2023 14:53:51 +0000 (16:53 +0200)]
bindings: cxx: examples: fix potential glitch in gpiosetcxx
gpiosetcxx requests lines without setting their output value, and so
sets them all inactive, and subsequently sets them to their requested
value. This can result in glitches on lines which were active and
are set active.
As this is example code, it is also important to demonstrate that the
output value can be set by the request itself.
Request the lines with the correct output values set in the request
itself.
Suggested-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Reviewed-by: Kent Gibson <warthog618@gmail.com>
Bartosz Golaszewski [Mon, 12 Jun 2023 14:52:03 +0000 (16:52 +0200)]
bindings: cxx: provide request_builder::set_output_values()
Implement a new method in the request_builder class that allows to set
output values at request-time by calling the set_output_values() method
of the internal line_config object.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Reviewed-by: Kent Gibson <warthog618@gmail.com>
Kent Gibson [Tue, 13 Jun 2023 01:52:03 +0000 (09:52 +0800)]
doc: add configuration to generate doxygen documentation on readthedocs
Having the libgpiod documentation available online would be helpful, so
add the configuration required to generate the existing docygen C/C++
documentation on readthedocs.
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Erik Schilling [Mon, 12 Jun 2023 11:14:50 +0000 (13:14 +0200)]
bindings: rust: document build without install
While the Makefile does this automatically, a user may want to do
something similar for other cargo commands.
Reported-by: Kent Gibson <warthog618@gmail.com>
Link: https://lore.kernel.org/r/ZIQJquwzNacp1Nuh@sol/
Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Erik Schilling [Mon, 12 Jun 2023 11:14:49 +0000 (13:14 +0200)]
bindings: rust: exclude Makefile.am from package
We do not use those when building from crates.io.
Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Erik Schilling [Mon, 12 Jun 2023 11:14:48 +0000 (13:14 +0200)]
bindings: rust: add version number to dependencies
When publishing to crates.io, all dependencies need to have a version
number. When building from crates.io the version number will be used,
otherwise the `path` is effective for builds when checking out the
repository.
As discussed on the maillinglist [1], each crate will have their own
version number (like the other language bindings) that will be bumped as
needed to fulfill the Rust SemVer requirements.
[1] https://lore.kernel.org/r/CACMJSes5+vT=NBqSe7xpSEPAEMmkgrZvJ8iKx7oBCKZQaGB_rg@mail.gmail.com/
Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Tue, 13 Jun 2023 07:24:42 +0000 (09:24 +0200)]
bindings: rust: add missing license and copyright boilerplate
Make reuse happy again by adding appropriate license and copyright info.
Fixes: 1f8085953086 ("bindings: rust: build against pkg-config info")
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Erik Schilling <erik.schilling@linaro.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Kent Gibson [Mon, 12 Jun 2023 02:56:42 +0000 (10:56 +0800)]
tools: tests: remove implicit run-time dependency on ncurses
bats has an implicit depencency on ncurses, as I found when trying to
run the tests on a minimal install that lacked ncurses. Rather than make
the dependency explicit, force the output formatting to use the TAP
format which does not require ncurses.
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Kent Gibson [Mon, 12 Jun 2023 02:56:41 +0000 (10:56 +0800)]
tools: tests: speed up continuous toggle test
The continuous toggle test was recently changed to poll the line to
check for toggles, and so increase test reliability. Tighten up the
test timings so the test can now also run in a significantly shorter
time.
And, as it is now faster, add an extra edge just to be sure.
Note that the test does not need to catch every edge, it only has to
check that the line is in fact toggling.
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Kent Gibson [Mon, 12 Jun 2023 02:56:40 +0000 (10:56 +0800)]
tools: tests: add tests for idle-timeout and debounce period.
There are no tests for the --debounce-period for gpiomon, or the new
idle-timeout option for gpiomon and gpionotify, so add some.
In both cases the focus of the test is not the period itself, which is
problematic to test reliably, but that the options are supported and
have the otherwise anticipated effects.
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Gabriel Matni [Mon, 12 Jun 2023 01:30:49 +0000 (21:30 -0400)]
tools: gpiomon/gpionotify: add idle-timeout option
Add an idle timeout option to gpiomon and gpionotify to exit gracefully
when no event has been detected for a given period.
Signed-off-by: Gabriel Matni <gabriel.matni@exfo.com>
Reviewed-by: Kent Gibson <warthog618@gmail.com>
Tested-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Mon, 12 Jun 2023 15:55:29 +0000 (17:55 +0200)]
bindings: python: examples: gpioset: drop redundant []
dict() accepts an iterable, so the [] brackets are redundant.
Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Kent Gibson [Fri, 9 Jun 2023 15:36:06 +0000 (23:36 +0800)]
bindings: python: examples: fix potential glitch in gpioset.py
gpioset.py requests lines without setting their output value, and so
sets them all inactive, and subsequently sets them to their requested
value. This can result in glitches on lines which were active and
are set active.
As this is example code, it is also important to demonstrate that the
output value can be set by the request itself.
Request the lines with the correct output values set in the request
itself.
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Kent Gibson [Fri, 9 Jun 2023 07:39:57 +0000 (15:39 +0800)]
doc: add doc for opaque structs to link to the relevant page
The C doxygen documentation is difficult to navigate as the opaque types
do not get linked to anything.
Add doc for each opaque struct that references the relevant page.
While at it: fix a typo in the line-request group.
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Kent Gibson [Fri, 9 Jun 2023 04:07:37 +0000 (12:07 +0800)]
doc: fix line_config documentation generation
The line configuration is missing from the generated documentation as the
comment for the defgroup is a normal comment, not a doc comment.
Add the asterisk to make the section a doc comment.
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Joe Slater [Tue, 6 Jun 2023 15:04:27 +0000 (08:04 -0700)]
tools: tests: modify delays in toggle test
The test "gpioset: toggle (continuous)" uses fixed delays to test
toggling values. This is not reliable, so we switch to looking
for transitions from one value to another.
We wait for a transition up to 1.5 seconds.
Signed-off-by: Joe Slater <joe.slater@windriver.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Bartosz Golaszewski [Tue, 6 Jun 2023 10:12:39 +0000 (12:12 +0200)]
build: drop a reference to libgpiomockup from a comment in Makefile
We no longer use libgpiomockup. Replace the reference to it with
libgpiosim.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>