1
0
mirror of https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git synced 2026-10-24 00:48:53 +03:00
Commit Graph

1505 Commits

Author SHA1 Message Date
Bartosz Golaszewski
268286995d bindings: python: gpiod v2.4.2
- fix heap-buffer overflow bugs on setting/getting values
- remove duplicated edge detection setting

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
python-v2.4.2
2026-04-09 10:49:49 +02:00
Bartosz Golaszewski
057aab6517 bindings: python: remove duplicated edge detection setting
In line_settings_init() we call gpiod_line_settings_set_edge_detection()
twice unnecessarily. Remove the second call.

Fixes: b7ba732e6a ("treewide: libgpiod v2 implementation")
Reported-by: 4fqr <4fqr@proton.me>
Tested-by: Vincent Fazio <vfazio@xes-inc.com>
Reviewed-by: Vincent Fazio <vfazio@xes-inc.com>
Link: https://patch.msgid.link/20260407-treewide-fixes-v1-2-66c9744a56a3@oss.qualcomm.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
2026-04-09 09:33:29 +02:00
Bartosz Golaszewski
c3655b5f64 bindings: python: fix heap-buffer overflow bugs on setting/getting values
The C extension methods request_set_values() and request_get_values()
iterate over a caller-supplied sequence and write offsets/values into
pre-allocated buffers self->offsets and self->values, without checking
the write index.

If the user tries to read values for more lines than they previously
requested, we overflow the buffers.

Add appropriate bounds checks and implement test cases for this issue.

Fixes: b7ba732e6a ("treewide: libgpiod v2 implementation")
Reported-by: 4fqr <4fqr@proton.me>
Tested-by: Vincent Fazio <vfazio@xes-inc.com>
Reviewed-by: Vincent Fazio <vfazio@xes-inc.com>
Link: https://patch.msgid.link/20260407-treewide-fixes-v1-1-66c9744a56a3@oss.qualcomm.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
2026-04-09 09:33:29 +02:00
Bartosz Golaszewski
d9d3ef9042 bindings: python: gpiod v2.4.1
- fix a Py_None reference leak
- fix setuptools dependency
- ship the license file with dist artifacts
- remove egg-info during clean

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
python-v2.4.1
2026-03-10 13:35:23 +01:00
Vincent Fazio
c921c813db bindings: python: remove egg-info during clean
The egg-info directory gets generated when a distribution is built so
should be removed when `make clean` is run.

Signed-off-by: Vincent Fazio <vfazio@gmail.com>
Link: https://patch.msgid.link/20260228185213.31442-1-vfazio@gmail.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
2026-03-02 12:19:53 +01:00
Vincent Fazio
51ee19fe1e bindings: python: copy the license into distributions
Previously, the bindings called out the SPDX license identifier in the
pyproject.toml but did not include a copy of the license in either the
source or binary distributions.

This can be problematic for tools that rely on extracting license
information, such as Buildroot or other license auditing mechanisms.

Now, when distributions are built, the license is copied out of the
libgpiod source tarball and into the target distribution.

Closes: https://github.com/brgl/libgpiod/issues/162
Signed-off-by: Vincent Fazio <vfazio@gmail.com>
Link: https://patch.msgid.link/20260228184158.25003-1-vfazio@gmail.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
2026-03-02 12:19:52 +01:00
Vincent Fazio
f26d5c9f2b bindings: python: require newer setuptools
When commit d9b156ecc2 updated pyproject.toml to conform to PEP 639
we failed to make sure the build dependencies were updated to support
the new structure.

Support for PEP 639 was added to setuptools in v77.0.0 [0] so minimally
require that version in `build-system.requires` to avoid failures.

Link: https://setuptools.pypa.io/en/latest/history.html#v77-0-0 # [0]
Fixes: d9b156ecc2 ("bindings: python: make licensing information conform with PEP 639")
Signed-off-by: Vincent Fazio <vfazio@gmail.com>
Link: https://patch.msgid.link/20260217005314.31016-1-vfazio@gmail.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
2026-02-18 09:26:22 +01:00
Bartosz Golaszewski
8a3058296d bindings: python: add missing Py_None reference increment
For lines with no name, chip_get_line_name() returns Py_None but does
not increment its reference count. Do it enough times and the following
error will occur with cpython before v3.12:

  Fatal Python error: none_dealloc: deallocating None: bug likely caused by a refcount error in a C extension

Add the missing Py_INCREF(). It's safe to do even on python >= v3.12 as
Py_INCREF() has no effect on immortal objects in more recent versions.

Fixes: 0c0993569c ("bindings: python: ext: add ability to query line name")
Reported-by: Pierre Gramme <pgramme@gmail.com>
Closes: https://github.com/brgl/libgpiod/issues/166
Link: https://lore.kernel.org/r/20260113092852.42573-1-bartosz.golaszewski@oss.qualcomm.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
2026-01-13 16:12:16 +01:00
Bartosz Golaszewski
e1d5096c6d bindings: python: gpiod v2.4.0
Changelog:
- make request and reconfigure behavior for lines requested by names
  consistent with that of lines requested by offsets
- fix parsing non-tuple keys when requesting a line
- disable UP045 linter check
- use quoted types when casting
- generate wheels for CPython 3.14
- issue a warning when reconfiguring a line not in the original request
- update dependencies for wheel generation
- update licensing information
- coding style fixes
- minor performance improvements

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
python-v2.4.0
2025-10-24 16:34:39 +02:00
Vincent Fazio
d62f3be0c4 bindings: python: bump cibuildwheel to 3.2.1
Version 3.2.1 uses images CPython 3.14.0 final instead of 3.14.0-rc3.

Signed-off-by: Vincent Fazio <vfazio@gmail.com>
Link: https://lore.kernel.org/r/20251022160406.1810450-1-vfazio@gmail.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-10-23 10:01:47 +02:00
Vincent Fazio
962a1924e1 bindings: python: line_request: warn on unknown lines when reconfiguring
Previously, attempting to reconfigure a line that was not included in
the original request provided no feedback to the caller that there was
invalid data in the request.

Now, emit a warning when an unknown offset or line name is encountered.

Signed-off-by: Vincent Fazio <vfazio@gmail.com>
Link: https://lore.kernel.org/r/20251009130516.3729433-10-vfazio@gmail.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-10-13 17:24:07 +02:00
Vincent Fazio
6a7d3306e4 bindings: python: chip: map names for lines requested by offset
Previously, lines requested by name could also be referred to by offset
when calling LineRequest.reconfigure_lines. However, lines requested by
offset could not be reconfigured by name if they had one.

Now, the name map is populated if the line has a name regardless of if
it's requested by name or offset.

To make behavior as consistent with earlier versions as possible, a line
requested by name always returns the first line on the chip with that
name. If there are duplicate line names and lines are requested by
offset, the first line in the request is mapped to the name. A line
requested by name always overrides a name mapped via an offset request.

If lines 0-3 all have the same name and a config object looks like:
  {("foo", 1, 2): None}
or
  {(1, "foo", 2): None}

Then lines 0-2 are requested and line 0 can be reconfigured by name.

If the config object looks like:
  {(1, 2): None}

Then lines 1 and 2 are requested and line 1 can be reconfigured by name.

Signed-off-by: Vincent Fazio <vfazio@gmail.com>
Link: https://lore.kernel.org/r/20251009130516.3729433-9-vfazio@gmail.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-10-13 17:24:07 +02:00
Vincent Fazio
0c0993569c bindings: python: ext: add ability to query line name
Investigation has shown that the construction of the Enum values to
create the LineInfo object is expensive [0].

Add a method to retrieve the line name from a given offset without the
overhead of generating a full LineInfo object.

[0]: https://github.com/brgl/libgpiod/issues/149#issuecomment-3319448712

Signed-off-by: Vincent Fazio <vfazio@gmail.com>
Link: https://lore.kernel.org/r/20251009130516.3729433-8-vfazio@gmail.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-10-13 17:24:07 +02:00
Vincent Fazio
e2d7b6abaf bindings: python: line_request: ignore invalid line names in reconfigure_lines
Previously, calling `reconfigure_lines` with line identifiers that were
not included in the original request produced different behaviors
depending on the identifier type.

If the identifier was an integer, it would be silently ignored.

If the identifier was a string, it would raise a `ValueError`.

To be consistent, invalid line names are now silently ignored.

Signed-off-by: Vincent Fazio <vfazio@gmail.com>
Link: https://lore.kernel.org/r/20251009130516.3729433-7-vfazio@gmail.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-10-13 17:24:07 +02:00
Vincent Fazio
0110c11626 bindings: python: chip: check mapped_output_values membership once
Simplify looking up mapped output values by providing a default value to
dict.get instead of checking for membership in the dict and then
fetching the value subsequently.

While hashing and lookup is fast, it's unnecessary overhead.

Signed-off-by: Vincent Fazio <vfazio@gmail.com>
Link: https://lore.kernel.org/r/20251009130516.3729433-6-vfazio@gmail.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-10-13 17:24:07 +02:00
Vincent Fazio
ea21b447d7 bindings: python: chip: simplify duplicate checking
Previously, a check was performed to prevent requests that included
duplicative lines.

While this provided quick feedback on erroneous requests, it penalized
callers that had a good config due to the over head of iterating the
config multiple times.

Now, duplicate check is performed as the config object is iterated.

Signed-off-by: Vincent Fazio <vfazio@gmail.com>
Link: https://lore.kernel.org/r/20251009130516.3729433-5-vfazio@gmail.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-10-13 17:24:07 +02:00
Vincent Fazio
728a2f9b22 bindings: python: chip: track requested lines when enumerating
Previously, an offset map was maintained to lookup the name used to
request a line so that a list could be generated that reflected the
identifier used to request a given line.

For example, if a config looked like {0: None, ("foo", "bar"): None}, the
LineRequest.lines property would contain [0, "foo", "bar"].

Now, the line identifier is tracked in request order as the config
object is iterated to avoid maintaining an offset map.

Signed-off-by: Vincent Fazio <vfazio@gmail.com>
Link: https://lore.kernel.org/r/20251009130516.3729433-4-vfazio@gmail.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-10-13 17:24:07 +02:00
Vincent Fazio
11aa4254b2 bindings: python: remove unused attribute from LineRequest
The _offset_map attribute was a map of offset -> line name. Values were
only inserted when a line was requested via name. As this map is never
utilized, remove it.

Signed-off-by: Vincent Fazio <vfazio@gmail.com>
Link: https://lore.kernel.org/r/20251009130516.3729433-3-vfazio@gmail.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-10-13 17:24:07 +02:00
Vincent Fazio
8c9d5b4fdf bindings: python: make config iteration consistent
Previously, Chip.request_lines and LineRequest.reconfigure_lines
iterated over a config object but did so in subtly different ways.

Create a generator that iterates over a config object and returns line +
settings pairs. Update the aforementioned functions to use the generator
to consolidate and condense code.

Signed-off-by: Vincent Fazio <vfazio@gmail.com>
Link: https://lore.kernel.org/r/20251009130516.3729433-2-vfazio@gmail.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-10-13 17:24:07 +02:00
Bartosz Golaszewski
2838c7604a bindings: python: fix coding style in setup.py
Add a missing newline and make black happy.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-10-13 17:24:07 +02:00
Bartosz Golaszewski
7a768dc5b7 tests: gpiosim: revert minimum kernel version back to v5.17.4
Commit b4009e2e67 ("tests: gpiosim: provide
gpiosim_bank_set_line_valid()") added support for marking simulated GPIO
lines as valid/invalid using a new attribute of the kernel configfs
interface of the gpio-sim module. In the process it bumped the minimum
kernel version required to use it to v6.17 where this feature first
appeared. The test cases we added later only appear in gpiod-test which
is the test suite for the core C library. However with the kernel
version change in libgpiosim other test suites have also seen their
minimum kernel versions implicitly increase.

Since the libgpiosim library will simply return an error in the event
that the attribute in question doesn't exist when the new function is
called, we can revert the required kernel version to what it was before
and allow just the individual test suites to bump their respective
minimums separately.

Reported-by: Vincent Fazio <vfazio@gmail.com>
Tested-by: Vincent Fazio <vfazio@gmail.com>
Link: https://lore.kernel.org/r/20251010094951.18927-1-brgl@bgdev.pl
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-10-13 09:54:31 +02:00
Bartosz Golaszewski
f4fe71e940 tests: add a test case for checking invalid lines
Add a test case for validating kernel's behavior when user-space tries
to request an invalid GPIO line.

Link: https://lore.kernel.org/r/20251006-gpiosim-valid-lines-v1-7-b399373e90a9@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-10-09 10:12:59 +02:00
Bartosz Golaszewski
d6fd0a065a tests: harness: support setting invalid lines
Wrap the new gpiosim_bank_set_line_valid() symbol exported by libgpiosim
in a GLib property and allow libgpiod tests to mark simulated lines as
invalid.

Link: https://lore.kernel.org/r/20251006-gpiosim-valid-lines-v1-6-b399373e90a9@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-10-09 10:12:59 +02:00
Bartosz Golaszewski
b4009e2e67 tests: gpiosim: provide gpiosim_bank_set_line_valid()
Provide a function allowing to mark a GPIO at given offset as valid or
invalid (all lines are valid by default). This will make it impossible
for any user to request it once the simulator is up.

Link: https://lore.kernel.org/r/20251006-gpiosim-valid-lines-v1-5-b399373e90a9@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-10-09 10:12:59 +02:00
Bartosz Golaszewski
8379438130 tests: gpiosim: selftests: add more test cases
Add simple self tests for libgpiosim functions that were not tested
before.

Link: https://lore.kernel.org/r/20251006-gpiosim-valid-lines-v1-4-b399373e90a9@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-10-09 10:12:59 +02:00
Bartosz Golaszewski
43d100a49c tests: gpiosim: selftests: shrink the self-test code
Most tests failures end with a perror() print and an exit(1) so wrap it
in a helper function and a macro and shrink the code.

Link: https://lore.kernel.org/r/20251006-gpiosim-valid-lines-v1-3-b399373e90a9@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-10-09 10:12:59 +02:00
Bartosz Golaszewski
1aca992f8b tests: gpiosim: don't allow clearing hogs on active devices
Check if the GPIO device is pending in gpiosim_bank_clear_hog() before
actually trying to remove the hog directory.

Fixes: a2f6e8cd35 ("libgpiosim: new library for controlling the gpio-sim module")
Link: https://lore.kernel.org/r/20251006-gpiosim-valid-lines-v1-2-b399373e90a9@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-10-09 10:12:59 +02:00
Bartosz Golaszewski
347adbd698 tests: harness: use correct type to capture a boolean retval
Unlike the libgpiosim functions used in g_gpiosim_glib_apply_properties(),
the return value of g_gpiosim_chip_apply_line_names() is a gboolean so
add a second local variable of the correct type to capture it.

Fixes: daaa6964c9 ("tests: rework error handling and stop overusing g_error()")
Link: https://lore.kernel.org/r/20251006-gpiosim-valid-lines-v1-1-b399373e90a9@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-10-09 10:12:59 +02:00
Bartosz Golaszewski
ea53c35a82 build: fix pkgconfig check and drop unneeded AS_IF() in configure
The problem that was worked around with the AS_IF() hack turned out to
be caused by not expanding PKG_PROG_PKG_CONFIG() before the first
expansion of PKG_CHECK_MODULES(). Moving it near the top of the file
fixes the problem. This allows us to make the tests section consistent
with the rest of the configure.ac file.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-10-08 18:10:06 +02:00
Bartosz Golaszewski
6d04afc54a build: use correct macros for error printing in configure
Configure errors in the tests section will make it seem like the problem
is related to the core library. Use the correct error macros we define
earlier.

Fixes: 9e69d7552c ("configure: improve the header and library function checks")
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-10-08 18:08:35 +02:00
Bartosz Golaszewski
f5625166a5 build: move the HEADER_NOT_FOUND macros in configure to the right places
Typically we define these right before they're needed in their
respective sections so be consistent and move the two currently defined
at the top of the file to configure sections for tests and C++ bindings.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-10-08 16:31:36 +02:00
Bartosz Golaszewski
727d07ee53 dbus: don't install generated headers
The header generated by gdbus-codegen and the library wrapper around it
are not part of the stable API so don't install them.

Fixes: a5ab76da1e ("dbus: add the D-Bus daemon, command-line client and tests")
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-10-01 15:30:36 +02:00
Bartosz Golaszewski
63a264079f bindings: glib: don't install examples
Example programs using the libgpiod GLib bindings are erroneously
installed under $(prefix)/bin/. Change the bin_PROGRAMS make variable
to noinst_PROGRAMS to fix it.

Fixes: e090088c21 ("bindings: add GLib bindings")
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-10-01 09:50:48 +02:00
Bartosz Golaszewski
2eab5e896f bindings: rust: add examples to the README.md in the libgpiod crate
Add some code examples to the README.md with the aim of showing how to
use the bindings on the crates.io landing page for the libgpiod crate.

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Erik Wierich <erik@riscstar.com>
Link: https://lore.kernel.org/r/20250926-rust-release-tweaks-v1-3-beae932eb691@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
rust-v1.0.0
2025-09-30 09:53:22 +02:00
Bartosz Golaszewski
d0f1291f41 bindings: rust: update formatting to --edition 2024
Update the formatting of all rust source files to be up to date with the
2024 rust edition.

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Erik Wierich <erik@riscstar.com>
Link: https://lore.kernel.org/r/20250926-rust-release-tweaks-v1-2-beae932eb691@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-09-30 09:53:22 +02:00
Bartosz Golaszewski
e549494229 bindings: rust: complete the unification of imports in examples
Commit cd32f27dd5 ("bindings: rust: unify imports in examples") failed
to consistently unify the code across all examples so finish the
process.

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Erik Wierich <erik@riscstar.com>
Link: https://lore.kernel.org/r/20250926-rust-release-tweaks-v1-1-beae932eb691@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-09-30 09:52:58 +02:00
Vincent Fazio
97ee308728 bindings: python: generate wheels for CPython 3.14
Update cibuildwheel to add support for generating 3.14 wheels.

Configuration options for cibuildwheel have been moved to pyproject.toml
to keep it in line with other tools used by the bindings.

The configuration has been updated to skip generating free-threaded
wheels since the bindings do not support free-threaded builds [0] and
cibuildwheel generates them by default starting with CPython3.14 [1].

[0]: https://github.com/brgl/libgpiod/issues/117
[1]: https://github.com/pypa/cibuildwheel/pull/2503

Closes: https://github.com/brgl/libgpiod/issues/138
Signed-off-by: Vincent Fazio <vfazio@gmail.com>
Link: https://lore.kernel.org/r/20250923200737.3177136-1-vfazio@gmail.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-09-26 11:54:44 +02:00
Vincent Fazio
36f1e51b37 bindings: python: use quoted types when casting
Linter check T006 [0] recommends using quotes around types (making them
strings) when casting values to a type to avoid the overhead of runtime
type evaluation.

This provides a small performance benefit at runtime [1].

  >>> timeit(lambda: cast(gpiod._ext.Request, "a"), number=100000000)
  6.4817840601317585
  >>> timeit(lambda: cast("gpiod._ext.Request", "a"), number=100000000)
  4.369633618975058

This also allows moving some imports behind type checking guards as they
are not required at runtime.

[0]: https://docs.astral.sh/ruff/rules/runtime-cast-value/
[1]: https://github.com/snok/flake8-type-checking/issues/119#issuecomment-2511022212

Signed-off-by: Vincent Fazio <vfazio@gmail.com>
Link: https://lore.kernel.org/r/20250909125300.3507377-1-vfazio@gmail.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-09-09 15:04:54 +02:00
Vincent Fazio
4db8707554 bindings: python: disable UP045 linter check
Linter check UP045 [0] was recently stabilized in ruff 0.12 [1].

UP045 suggests using the `X | Y` syntax for files that perform:

  from __future__ import annotations

This import drives the Python interpreter to store type annotations as
strings and defers their evaluation [2] making the new syntax "safe".

See also [3] for a brief history.

For now, disable the UP045 linter warnings like we do UP007 [4] for the
sake of consistency within the bindings so there is no mixed usage of
`Union[X, Y]` and `Optional[X]` vs `X | Y` until the bindings minimally
target Python 3.10 and can move to the latter syntax.

[0]: https://docs.astral.sh/ruff/rules/non-pep604-annotation-optional/
[1]: de4fc5b171
[2]: https://peps.python.org/pep-0563/#implementation
[3]: https://peps.python.org/pep-0649/#a-history-of-annotations
[4]: https://docs.astral.sh/ruff/rules/non-pep604-annotation-union/

Signed-off-by: Vincent Fazio <vfazio@gmail.com>
Link: https://lore.kernel.org/r/20250907142919.1382670-1-vfazio@gmail.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-09-09 11:24:36 +02:00
Bartosz Golaszewski
6c4812be6a dbus: gpiocli: display the libgpiod package version for --version
Currently gpiocli does not display the libgpiod API version in the
output of gpiocli --version because it's not linked against libgpiod -
it's only a consumer of the DBus API.

However, with the recent changes to the versioning scheme and the
disassociation of the core C API from the libgpiod package version, it
now makes sense to display the latter so add it.

Acked-by: Erik Wierich <erik@riscstar.com>
Link: https://lore.kernel.org/r/20250903-api-version-detach-v1-7-027ca5928518@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-09-09 10:24:00 +02:00
Bartosz Golaszewski
5204b44f83 dbus: manager: display C API *and* libgpiod package version for '-v'
With the recent changes to the versioning scheme and the disassociation
of the core C API from the libgpiod package version, it now makes sense
to display both in the output of 'gpio-manager --version'.

Acked-by: Erik Wierich <erik@riscstar.com>
Link: https://lore.kernel.org/r/20250903-api-version-detach-v1-6-027ca5928518@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-09-09 10:24:00 +02:00
Bartosz Golaszewski
8d0cae535d tools: display C API *and* libgpiod package version for '-v'
With the recent changes to the versioning scheme and the disassociation
of the core C API from the libgpiod package version, it now makes sense
to display both in the output of '<tool> --version' for all gpio-tools.

Acked-by: Erik Wierich <erik@riscstar.com>
Link: https://lore.kernel.org/r/20250903-api-version-detach-v1-5-027ca5928518@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-09-09 10:24:00 +02:00
Bartosz Golaszewski
d30bcd7b2e tests: update library API version string tests
The version string returned by gpiod_api_version() is now stricter and
will always be of the form: x.y.z where x, y and z are unsigned integer
numbers. We no longer have to parse various suffixes so update the test
cases tree-wide.

Acked-by: Erik Wierich <erik@riscstar.com>
Link: https://lore.kernel.org/r/20250903-api-version-detach-v1-4-027ca5928518@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-09-09 10:24:00 +02:00
Bartosz Golaszewski
a62c732936 core: change the behavior of gpiod_api_version()
Make gpiod_api_version() return the human-readable form of the libgpiod
C API instead of the libgpiod package version.

Acked-by: Erik Wierich <erik@riscstar.com>
Link: https://lore.kernel.org/r/20250903-api-version-detach-v1-3-027ca5928518@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-09-09 10:24:00 +02:00
Bartosz Golaszewski
cf49a9a571 build: define a separate API version for the core C library
The core C API of libgpiod has become quite stable and unlikely to
change soon. We will still be adding some new features to the included
programs and some of the bindings (notably: Python and Rust) but it
doesn't make sense to bump the C API which hasn't changed, just becuase
we're doing a minor release of the larger package.

Define a separate libgpiod C API version in configure.ac. This will
affect the C, C++ and GLib APIs as the latter two track the C API
closely. Rust and Python bindings already have their own API versions.

Set the API version to v2.2.0 as it hasn't changed in the libgpiod v2.3
release cycle yet.

Acked-by: Erik Wierich <erik@riscstar.com>
Link: https://lore.kernel.org/r/20250903-api-version-detach-v1-2-027ca5928518@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-09-09 10:24:00 +02:00
Bartosz Golaszewski
aeb74d629b bindings: cxx: move misc.hpp inclusion to the correct place
The symbols from gpiodcxx/misc.hpp are correctly exported to users of
gpiod.hpp because it's implicitly pulled in by line-request.hpp but
that's incorrect: line-request.hpp has no need for any of the symbols
from misc.hpp and it should be part of the set of headers included by
the top-level gpiod.hpp. Move it to the correct place.

Acked-by: Erik Wierich <erik@riscstar.com>
Link: https://lore.kernel.org/r/20250903-api-version-detach-v1-1-027ca5928518@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-09-09 10:24:00 +02:00
Vincent Fazio
1f2ba0deab bindings: python: parse non-tuple Iterable keys
When `chip.request_lines` was modified to allow `Iterable`s instead of
only `tuple`s, the code that checked for duplicate line entries in the
`config` argument was not updated to account for the expanded types.

If the `config` argument had a key that was not a `tuple`, `str`, or
`int`, a `TypeError` would be raised when resolving the line offset.

Refactor the code the resolves IDs to offsets into a separate function
to make the logic a bit clearer and to account for the widened types.

Fixes: 8f62e6c453 ("bindings: python: loosen type requirements in public API")
Closes: https://github.com/brgl/libgpiod/issues/148
Signed-off-by: Vincent Fazio <vfazio@gmail.com>
Link: https://lore.kernel.org/r/20250902123905.6491-1-vfazio@gmail.com
[Bartosz: don't pass the only argument by name in the call to
_resolve_config_keys_to_offsets()]
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-09-08 09:29:13 +02:00
Bartosz Golaszewski
d0006cc3d5 bindings: rust: update crate versions to v1.0.0
Ahead of the first stable release, update versions for all libgpiod
crates to v1.0.0.

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Erik Wierich <erik@riscstar.com>
Link: https://lore.kernel.org/r/20250828-rust-1-0-0-release-v3-10-0f9c6c1c4808@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-09-01 10:23:50 +02:00
Bartosz Golaszewski
efc39de44a bindings: rust: update intmap dependency
Bump the intmap dependency for libgpiod to the most recent major version.
The IntMap type now takes two explicit type arguments for the key and
value so adjust the code accordingly. No longer require a specific minor
version.

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Erik Wierich <erik@riscstar.com>
Link: https://lore.kernel.org/r/20250828-rust-1-0-0-release-v3-9-0f9c6c1c4808@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-09-01 10:23:50 +02:00
Bartosz Golaszewski
751a37fa37 bindings: rust: update thiserror dependency
Bump the thiserror dependency for libgpiod to the most recent major
version. No code changes required. No longer require a specific minor
version.

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Erik Wierich <erik@riscstar.com>
Link: https://lore.kernel.org/r/20250828-rust-1-0-0-release-v3-8-0f9c6c1c4808@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-09-01 10:23:50 +02:00