Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix generic_gpio_libgpiod driver builds with libgpio 2.x API changes #2841

Merged
merged 7 commits into from
Mar 11, 2025

Conversation

jimklimov
Copy link
Member

Closes: #2833

API of the library has massively changed between 1.6.x available in older distros, and 2.x in newer ones (and matching Linux kernel functionality changed a lot as well). The driver was not buildable in newer/upcoming distribution releases because of that.

Great thanks to @modrisb for initial driver development, and for this subsequent fix (on short notice at that). And to @tomeko12 for raising the alarm :)

For my part, it should now be easy to identify which API (1 or 2) the program got built against:

### configure log: * build GPIO driver (library v2.3):     yes libgpiod
:; ./drivers/generic_gpio_libgpiod -V
Network UPS Tools 2.8.2.2324.5-2329-g03947d319 (development iteration after 2.8.2) - GPIO UPS driver (API 0x00020000) 1.03

### configure log: * build GPIO driver (library v1.6.3):   yes libgpiod
:; ./drivers/generic_gpio_libgpiod -V
Network UPS Tools 2.8.2.2327.5-2332-g4940ab008 (development iteration after 2.8.2) - GPIO UPS driver (API 0x00010000) 1.03

NOTE: Currently the API is not elaborated in detail by m4/nut_check_libgpiod.m4 and effectively just says 1 or 2 (extensibly as a 32-bit int define WITH_LIBGPIO_VERSION, so we can add minor/patch layers if wanted). Note that the GPIOD_VERSION used by the script comes from pkg-config and may reflect the library API version placed into the *.pc metadata, rather than a source/package version.

A custom build of the library to test NUT builds against is detailed at #2833 (comment) and trivial to complete.

…ure to C code of WITH_LIBGPIO_VERSION [networkupstools#2833]

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…ools#2833]

Should also serve for actual fix of the drivers for new libgpio API,
but not sure if that would land in NUT v2.8.3 timeframe or after the
release.

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
… WITH_LIBGPIO_VERSION_STR a driver was built against [networkupstools#2833]

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…WITH_LIBGPIO_VERSION [networkupstools#2833]

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…+modrisb'

Take advantage of WITH_LIBGPIO_VERSION defined by NUT configure.ac to
select the code path and signal it in DRIVER_VERSION for troubleshooting.

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…implementations [networkupstools#2833]

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…TH_LIBGPIO_VERSION [networkupstools#2833]

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
@jimklimov jimklimov added packaging GPIO Drivers talking to devices (or their chips) over GPIO interface portability We want NUT to build and run everywhere possible impacts-release-2.8.2 Issues reported against NUT release 2.8.2 (maybe vanilla or with minor packaging tweaks) labels Mar 9, 2025
@jimklimov jimklimov added this to the 2.8.3 milestone Mar 9, 2025
@jimklimov jimklimov merged commit e85467f into networkupstools:master Mar 11, 2025
30 checks passed
@jimklimov jimklimov deleted the issue-2833+modrisb branch March 11, 2025 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GPIO Drivers talking to devices (or their chips) over GPIO interface impacts-release-2.8.2 Issues reported against NUT release 2.8.2 (maybe vanilla or with minor packaging tweaks) packaging portability We want NUT to build and run everywhere possible
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update generic_gpio_libgpiod driver to latest libgpiod versions.
1 participant