All of lore.kernel.org
 help / color / mirror / Atom feed
* [libgpiod][PATCH 00/11] treewide: an assortment of tweaks and improvements
@ 2022-11-30 12:42 Bartosz Golaszewski
  2022-11-30 12:42 ` [libgpiod][PATCH 01/11] treewide: use C enum types explicitly Bartosz Golaszewski
                   ` (11 more replies)
  0 siblings, 12 replies; 28+ messages in thread
From: Bartosz Golaszewski @ 2022-11-30 12:42 UTC (permalink / raw)
  To: Kent Gibson, Linus Walleij, Andy Shevchenko, Viresh Kumar
  Cc: linux-gpio, Bartosz Golaszewski

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

This series contains various changes for libgpiod v2. There's no main theme
to it really, just fixing problems I noticed and introducing some more
changes to the API.

Bartosz Golaszewski (11):
  treewide: use C enum types explicitly
  treewide: apply formatting changes with clang-format
  treewide: use plural 'events' in read_edge_event() functions
  treewide: rename EVENT_CLOCK to CLOCK
  gpiosim: rename HOG_DIR to DIRECTION
  tools: display the correct license with --version
  bindings: rust: make reuse happy
  bindings: rust: include rust sources in the release tarballs
  bindings: python: decouple the version of the bindings from libgpiod
    API version
  bindings: python: fix the GPIOD_WITH_TESTS build flag
  bindings: python: extend setup.py

 LICENSES/Apache-2.0.txt                       | 201 ++++++++++++++++++
 LICENSES/BSD-3-Clause.txt                     |  28 +++
 LICENSES/CC0-1.0.txt                          | 121 +++++++++++
 Makefile.am                                   |   9 +-
 bindings/cxx/edge-event-buffer.cpp            |   2 +-
 bindings/cxx/edge-event.cpp                   |   2 +-
 bindings/cxx/examples/gpiomoncxx.cpp          |   2 +-
 bindings/cxx/gpiodcxx/line-request.hpp        |   6 +-
 bindings/cxx/info-event.cpp                   |   2 +-
 bindings/cxx/internal.hpp                     |   6 +-
 bindings/cxx/line-info.cpp                    |   8 +-
 bindings/cxx/line-request.cpp                 |  24 ++-
 bindings/cxx/line-settings.cpp                |  87 ++++----
 bindings/cxx/tests/gpiosim.cpp                |  24 +--
 bindings/cxx/tests/gpiosim.hpp                |   4 +-
 bindings/cxx/tests/tests-edge-event.cpp       |  56 ++---
 bindings/cxx/tests/tests-line-info.cpp        |   2 +-
 bindings/python/examples/gpiomon.py           |   2 +-
 bindings/python/gpiod/__init__.py             |   3 +-
 bindings/python/gpiod/ext/line-settings.c     |  54 ++---
 bindings/python/gpiod/ext/module.c            |   8 +-
 bindings/python/gpiod/ext/request.c           |  12 +-
 bindings/python/gpiod/line_request.py         |   6 +-
 bindings/python/gpiod/version.py              |   5 +
 bindings/python/setup.py                      |  18 +-
 bindings/python/tests/gpiosim/ext.c           |   6 +-
 bindings/python/tests/tests_edge_event.py     |  38 ++--
 bindings/python/tests/tests_module.py         |  15 +-
 bindings/rust/.gitignore                      |   4 +-
 bindings/rust/Makefile.am                     |   4 +
 bindings/rust/gpiosim-sys/Makefile.am         |   6 +
 bindings/rust/gpiosim-sys/src/Makefile.am     |   5 +
 bindings/rust/gpiosim-sys/src/lib.rs          |  48 +++--
 bindings/rust/gpiosim-sys/src/sim.rs          |   2 +-
 bindings/rust/libgpiod-sys/Makefile.am        |   6 +
 bindings/rust/libgpiod-sys/src/Makefile.am    |   5 +
 bindings/rust/libgpiod/Makefile.am            |   6 +
 bindings/rust/libgpiod/examples/Makefile.am   |  14 ++
 .../rust/libgpiod/examples/gpio_events.rs     |   2 +-
 bindings/rust/libgpiod/examples/gpiomon.rs    |   2 +-
 bindings/rust/libgpiod/src/Makefile.am        |  15 ++
 bindings/rust/libgpiod/src/event_buffer.rs    |   2 +-
 bindings/rust/libgpiod/src/lib.rs             | 169 +++++++++------
 bindings/rust/libgpiod/src/line_info.rs       |  10 +-
 bindings/rust/libgpiod/src/line_request.rs    |   4 +-
 bindings/rust/libgpiod/src/line_settings.rs   |  30 +--
 bindings/rust/libgpiod/tests/Makefile.am      |  15 ++
 .../rust/libgpiod/tests/common/Makefile.am    |   5 +
 bindings/rust/libgpiod/tests/edge_event.rs    |  24 +--
 bindings/rust/libgpiod/tests/line_request.rs  |   2 +-
 configure.ac                                  |   9 +
 include/gpiod.h                               | 106 +++++----
 lib/edge-event.c                              |  13 +-
 lib/info-event.c                              |   5 +-
 lib/internal.c                                |   4 +-
 lib/internal.h                                |   3 +-
 lib/line-config.c                             |  55 ++---
 lib/line-info.c                               |  31 +--
 lib/line-request.c                            |  31 +--
 lib/line-settings.c                           |  50 ++---
 tests/gpiod-test-helpers.h                    |   2 +-
 tests/gpiod-test-sim.c                        |  53 +++--
 tests/gpiod-test-sim.h                        |   8 +-
 tests/gpiosim/gpiosim-selftest.c              |   2 +-
 tests/gpiosim/gpiosim.c                       |  50 +++--
 tests/gpiosim/gpiosim.h                       |  30 +--
 tests/tests-chip-info.c                       |   1 -
 tests/tests-edge-event.c                      |  98 ++++-----
 tests/tests-info-event.c                      |   2 +-
 tests/tests-line-config.c                     |   2 +-
 tests/tests-line-info.c                       |  39 ++--
 tests/tests-line-request.c                    |  58 ++---
 tests/tests-line-settings.c                   |  40 ++--
 tests/tests-request-config.c                  |  12 +-
 tools/gpiodetect.c                            |   3 +-
 tools/gpioget.c                               |   7 +-
 tools/gpioinfo.c                              |  12 +-
 tools/gpiomon.c                               |  31 ++-
 tools/gpionotify.c                            |  10 +-
 tools/gpioset.c                               |  85 ++++----
 tools/tools-common.c                          |  47 ++--
 tools/tools-common.h                          |  11 +-
 82 files changed, 1284 insertions(+), 757 deletions(-)
 create mode 100644 LICENSES/Apache-2.0.txt
 create mode 100644 LICENSES/BSD-3-Clause.txt
 create mode 100644 LICENSES/CC0-1.0.txt
 create mode 100644 bindings/python/gpiod/version.py
 create mode 100644 bindings/rust/gpiosim-sys/Makefile.am
 create mode 100644 bindings/rust/gpiosim-sys/src/Makefile.am
 create mode 100644 bindings/rust/libgpiod-sys/Makefile.am
 create mode 100644 bindings/rust/libgpiod-sys/src/Makefile.am
 create mode 100644 bindings/rust/libgpiod/Makefile.am
 create mode 100644 bindings/rust/libgpiod/examples/Makefile.am
 create mode 100644 bindings/rust/libgpiod/src/Makefile.am
 create mode 100644 bindings/rust/libgpiod/tests/Makefile.am
 create mode 100644 bindings/rust/libgpiod/tests/common/Makefile.am

-- 
2.37.2


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [libgpiod][PATCH 01/11] treewide: use C enum types explicitly
  2022-11-30 12:42 [libgpiod][PATCH 00/11] treewide: an assortment of tweaks and improvements Bartosz Golaszewski
@ 2022-11-30 12:42 ` Bartosz Golaszewski
  2022-12-01  2:06   ` Viresh Kumar
  2022-11-30 12:42 ` [libgpiod][PATCH 02/11] treewide: apply formatting changes with clang-format Bartosz Golaszewski
                   ` (10 subsequent siblings)
  11 siblings, 1 reply; 28+ messages in thread
From: Bartosz Golaszewski @ 2022-11-30 12:42 UTC (permalink / raw)
  To: Kent Gibson, Linus Walleij, Andy Shevchenko, Viresh Kumar
  Cc: linux-gpio, Bartosz Golaszewski

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

Use enum types explicitly across the entire C API. Modern compilers can
catch some bugs with enums and it also helps IDEs and general readability.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
[Viresh: make rust bindings work with negative enum values]
Co-authored-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 bindings/cxx/edge-event.cpp                 |   2 +-
 bindings/cxx/info-event.cpp                 |   2 +-
 bindings/cxx/internal.hpp                   |   6 +-
 bindings/cxx/line-info.cpp                  |   2 +-
 bindings/cxx/line-request.cpp               |  14 +-
 bindings/cxx/line-settings.cpp              |  81 +++++-----
 bindings/cxx/tests/gpiosim.cpp              |  14 +-
 bindings/python/gpiod/ext/line-settings.c   |  54 +++----
 bindings/python/gpiod/ext/request.c         |   4 +-
 bindings/rust/gpiosim-sys/src/lib.rs        |  42 +++--
 bindings/rust/gpiosim-sys/src/sim.rs        |   2 +-
 bindings/rust/libgpiod/src/lib.rs           | 169 ++++++++++++--------
 bindings/rust/libgpiod/src/line_info.rs     |  10 +-
 bindings/rust/libgpiod/src/line_settings.rs |  30 ++--
 include/gpiod.h                             |  84 ++++++----
 lib/edge-event.c                            |   5 +-
 lib/info-event.c                            |   5 +-
 lib/line-config.c                           |  12 +-
 lib/line-info.c                             |  25 +--
 lib/line-request.c                          |  21 +--
 lib/line-settings.c                         |  39 ++---
 tests/gpiosim/gpiosim.c                     |  26 +--
 tests/gpiosim/gpiosim.h                     |  18 ++-
 tests/tests-line-request.c                  |  25 +--
 tools/gpioget.c                             |   7 +-
 tools/gpiomon.c                             |   6 +-
 tools/gpioset.c                             |  45 +++---
 tools/tools-common.c                        |   7 +-
 tools/tools-common.h                        |   8 +-
 29 files changed, 431 insertions(+), 334 deletions(-)

diff --git a/bindings/cxx/edge-event.cpp b/bindings/cxx/edge-event.cpp
index 5992934..9d12273 100644
--- a/bindings/cxx/edge-event.cpp
+++ b/bindings/cxx/edge-event.cpp
@@ -100,7 +100,7 @@ GPIOD_CXX_API edge_event::event_type edge_event::type() const
 {
 	int evtype = ::gpiod_edge_event_get_event_type(this->_m_priv->get_event_ptr());
 
-	return map_int_to_enum(evtype, event_type_mapping);
+	return map_enum_c_to_cxx(evtype, event_type_mapping);
 }
 
 GPIOD_CXX_API timestamp edge_event::timestamp_ns() const noexcept
diff --git a/bindings/cxx/info-event.cpp b/bindings/cxx/info-event.cpp
index d9e14a3..f709408 100644
--- a/bindings/cxx/info-event.cpp
+++ b/bindings/cxx/info-event.cpp
@@ -77,7 +77,7 @@ GPIOD_CXX_API info_event::event_type info_event::type() const
 {
 	int type = ::gpiod_info_event_get_event_type(this->_m_priv->event.get());
 
-	return map_int_to_enum(type, event_type_mapping);
+	return map_enum_c_to_cxx(type, event_type_mapping);
 }
 
 GPIOD_CXX_API ::std::uint64_t info_event::timestamp_ns() const noexcept
diff --git a/bindings/cxx/internal.hpp b/bindings/cxx/internal.hpp
index 0703474..d27aa22 100644
--- a/bindings/cxx/internal.hpp
+++ b/bindings/cxx/internal.hpp
@@ -18,15 +18,15 @@
 
 namespace gpiod {
 
-template<class enum_type> enum_type
-map_int_to_enum(int value, const ::std::map<int, enum_type>& mapping)
+template<class cxx_enum_type, class c_enum_type> cxx_enum_type
+map_enum_c_to_cxx(c_enum_type value, const ::std::map<c_enum_type, cxx_enum_type>& mapping)
 {
 	try {
 		return mapping.at(value);
 	} catch (const ::std::out_of_range& err) {
 		/* FIXME Demangle the name. */
 		throw bad_mapping(::std::string("invalid value for ") +
-				  typeid(enum_type).name());
+				  typeid(cxx_enum_type).name());
 	}
 }
 
diff --git a/bindings/cxx/line-info.cpp b/bindings/cxx/line-info.cpp
index a6b6dfa..944e34d 100644
--- a/bindings/cxx/line-info.cpp
+++ b/bindings/cxx/line-info.cpp
@@ -114,7 +114,7 @@ GPIOD_CXX_API line::direction line_info::direction() const
 {
 	int direction = ::gpiod_line_info_get_direction(this->_m_priv->info.get());
 
-	return map_int_to_enum(direction, direction_mapping);
+	return map_enum_c_to_cxx(direction, direction_mapping);
 }
 
 GPIOD_CXX_API bool line_info::active_low() const noexcept
diff --git a/bindings/cxx/line-request.cpp b/bindings/cxx/line-request.cpp
index bde34e8..be0bac5 100644
--- a/bindings/cxx/line-request.cpp
+++ b/bindings/cxx/line-request.cpp
@@ -115,9 +115,10 @@ GPIOD_CXX_API void line_request::get_values(const line::offsets& offsets, line::
 
 	this->_m_priv->fill_offset_buf(offsets);
 
-	int ret = ::gpiod_line_request_get_values_subset(this->_m_priv->request.get(),
-							 offsets.size(), this->_m_priv->offset_buf.data(),
-							 reinterpret_cast<int*>(values.data()));
+	int ret = ::gpiod_line_request_get_values_subset(
+					this->_m_priv->request.get(),
+					offsets.size(), this->_m_priv->offset_buf.data(),
+					reinterpret_cast<gpiod_line_value*>(values.data()));
 	if (ret)
 		throw_from_errno("unable to retrieve line values");
 }
@@ -157,9 +158,10 @@ GPIOD_CXX_API line_request& line_request::set_values(const line::offsets& offset
 
 	this->_m_priv->fill_offset_buf(offsets);
 
-	int ret = ::gpiod_line_request_set_values_subset(this->_m_priv->request.get(),
-							 offsets.size(), this->_m_priv->offset_buf.data(),
-							 reinterpret_cast<const int*>(values.data()));
+	int ret = ::gpiod_line_request_set_values_subset(
+					this->_m_priv->request.get(),
+					offsets.size(), this->_m_priv->offset_buf.data(),
+					reinterpret_cast<const enum gpiod_line_value*>(values.data()));
 	if (ret)
 		throw_from_errno("unable to set line values");
 
diff --git a/bindings/cxx/line-settings.cpp b/bindings/cxx/line-settings.cpp
index 22655e2..17c5ca2 100644
--- a/bindings/cxx/line-settings.cpp
+++ b/bindings/cxx/line-settings.cpp
@@ -10,10 +10,11 @@ namespace gpiod {
 
 namespace {
 
-template<class enum_type>
-::std::map<int, enum_type> make_reverse_maping(const ::std::map<enum_type, int>& mapping)
+template<class cxx_enum_type, class c_enum_type>
+::std::map<c_enum_type, cxx_enum_type>
+make_reverse_maping(const ::std::map<cxx_enum_type, c_enum_type>& mapping)
 {
-	::std::map<int, enum_type> ret;
+	::std::map<c_enum_type, cxx_enum_type> ret;
 
 	for (const auto &item: mapping)
 		ret[item.second] = item.first;
@@ -21,54 +22,56 @@ template<class enum_type>
 	return ret;
 }
 
-const ::std::map<line::direction, int> direction_mapping = {
+const ::std::map<line::direction, gpiod_line_direction> direction_mapping = {
 	{ line::direction::AS_IS,	GPIOD_LINE_DIRECTION_AS_IS },
 	{ line::direction::INPUT,	GPIOD_LINE_DIRECTION_INPUT },
 	{ line::direction::OUTPUT,	GPIOD_LINE_DIRECTION_OUTPUT }
 };
 
-const ::std::map<int, line::direction> reverse_direction_mapping = make_reverse_maping(direction_mapping);
+const ::std::map<gpiod_line_direction, line::direction>
+reverse_direction_mapping = make_reverse_maping(direction_mapping);
 
-const ::std::map<line::edge, int> edge_mapping = {
+const ::std::map<line::edge, gpiod_line_edge> edge_mapping = {
 	{ line::edge::NONE,		GPIOD_LINE_EDGE_NONE },
 	{ line::edge::FALLING,		GPIOD_LINE_EDGE_FALLING },
 	{ line::edge::RISING,		GPIOD_LINE_EDGE_RISING },
 	{ line::edge::BOTH,		GPIOD_LINE_EDGE_BOTH }
 };
 
-const ::std::map<int, line::edge> reverse_edge_mapping = make_reverse_maping(edge_mapping);
+const ::std::map<gpiod_line_edge, line::edge> reverse_edge_mapping = make_reverse_maping(edge_mapping);
 
-const ::std::map<line::bias, int> bias_mapping = {
+const ::std::map<line::bias, gpiod_line_bias> bias_mapping = {
 	{ line::bias::AS_IS,		GPIOD_LINE_BIAS_AS_IS },
 	{ line::bias::DISABLED,		GPIOD_LINE_BIAS_DISABLED },
 	{ line::bias::PULL_UP,		GPIOD_LINE_BIAS_PULL_UP },
 	{ line::bias::PULL_DOWN,	GPIOD_LINE_BIAS_PULL_DOWN }
 };
 
-const ::std::map<int, line::bias> reverse_bias_mapping = make_reverse_maping(bias_mapping);
+const ::std::map<gpiod_line_bias, line::bias> reverse_bias_mapping = make_reverse_maping(bias_mapping);
 
-const ::std::map<line::drive, int> drive_mapping = {
+const ::std::map<line::drive, gpiod_line_drive> drive_mapping = {
 	{ line::drive::PUSH_PULL,	GPIOD_LINE_DRIVE_PUSH_PULL },
 	{ line::drive::OPEN_DRAIN,	GPIOD_LINE_DRIVE_OPEN_DRAIN },
 	{ line::drive::OPEN_SOURCE,	GPIOD_LINE_DRIVE_OPEN_SOURCE }
 };
 
-const ::std::map<int, line::drive> reverse_drive_mapping = make_reverse_maping(drive_mapping);
+const ::std::map<gpiod_line_drive, line::drive> reverse_drive_mapping = make_reverse_maping(drive_mapping);
 
-const ::std::map<line::clock, int> clock_mapping = {
+const ::std::map<line::clock, gpiod_line_event_clock> clock_mapping = {
 	{ line::clock::MONOTONIC,	GPIOD_LINE_EVENT_CLOCK_MONOTONIC },
 	{ line::clock::REALTIME,	GPIOD_LINE_EVENT_CLOCK_REALTIME },
 	{ line::clock::HTE,		GPIOD_LINE_EVENT_CLOCK_HTE }
 };
 
-const ::std::map<int, line::clock> reverse_clock_mapping = make_reverse_maping(clock_mapping);
+const ::std::map<gpiod_line_event_clock, line::clock>
+reverse_clock_mapping = make_reverse_maping(clock_mapping);
 
-const ::std::map<line::value, int> value_mapping = {
+const ::std::map<line::value, gpiod_line_value> value_mapping = {
 	{ line::value::INACTIVE,	GPIOD_LINE_VALUE_INACTIVE },
 	{ line::value::ACTIVE,		GPIOD_LINE_VALUE_ACTIVE }
 };
 
-const ::std::map<int, line::value> reverse_value_mapping = make_reverse_maping(value_mapping);
+const ::std::map<gpiod_line_value, line::value> reverse_value_mapping = make_reverse_maping(value_mapping);
 
 line_settings_ptr make_line_settings()
 {
@@ -95,30 +98,30 @@ value_type map_setting(const key_type& key, const ::std::map<key_type, value_typ
 	return ret;
 }
 
-template<class enum_type>
-int do_map_value(enum_type value, const ::std::map<enum_type, int>& mapping)
+template<class cxx_enum_type, class c_enum_type>
+c_enum_type do_map_value(cxx_enum_type value, const ::std::map<cxx_enum_type, c_enum_type>& mapping)
 {
-	return map_setting<enum_type, int, ::std::invalid_argument>(value, mapping);
+	return map_setting<cxx_enum_type, c_enum_type, ::std::invalid_argument>(value, mapping);
 }
 
-template<class enum_type, int set_func(::gpiod_line_settings*, int)>
-void set_mapped_value(::gpiod_line_settings* settings, enum_type value,
-		      const ::std::map<enum_type, int>& mapping)
+template<class cxx_enum_type, class c_enum_type, int set_func(::gpiod_line_settings*, c_enum_type)>
+void set_mapped_value(::gpiod_line_settings* settings, cxx_enum_type value,
+		      const ::std::map<cxx_enum_type, c_enum_type>& mapping)
 {
-	auto mapped_val = do_map_value(value, mapping);
+	c_enum_type mapped_val = do_map_value(value, mapping);
 
 	auto ret = set_func(settings, mapped_val);
 	if (ret)
 		throw_from_errno("unable to set property");
 }
 
-template<class ret_type, int get_func(::gpiod_line_settings*)>
-ret_type get_mapped_value(::gpiod_line_settings* settings,
-			  const ::std::map<int, ret_type>& mapping)
+template<class cxx_enum_type, class c_enum_type, c_enum_type get_func(::gpiod_line_settings*)>
+cxx_enum_type get_mapped_value(::gpiod_line_settings* settings,
+			  const ::std::map<c_enum_type, cxx_enum_type>& mapping)
 {
-	int mapped_val = get_func(settings);
+	auto mapped_val = get_func(settings);
 
-	return map_int_to_enum(mapped_val, mapping);
+	return map_enum_c_to_cxx(mapped_val, mapping);
 }
 
 } /* namespace */
@@ -162,7 +165,7 @@ GPIOD_CXX_API line_settings& line_settings::reset(void) noexcept
 
 GPIOD_CXX_API line_settings& line_settings::set_direction(line::direction direction)
 {
-	set_mapped_value<line::direction,
+	set_mapped_value<line::direction, gpiod_line_direction,
 			 ::gpiod_line_settings_set_direction>(this->_m_priv->settings.get(),
 							      direction, direction_mapping);
 
@@ -171,7 +174,7 @@ GPIOD_CXX_API line_settings& line_settings::set_direction(line::direction direct
 
 GPIOD_CXX_API line::direction line_settings::direction() const
 {
-	return get_mapped_value<line::direction,
+	return get_mapped_value<line::direction, gpiod_line_direction,
 				::gpiod_line_settings_get_direction>(
 							this->_m_priv->settings.get(),
 							reverse_direction_mapping);
@@ -179,7 +182,7 @@ GPIOD_CXX_API line::direction line_settings::direction() const
 
 GPIOD_CXX_API line_settings& line_settings::set_edge_detection(line::edge edge)
 {
-	set_mapped_value<line::edge,
+	set_mapped_value<line::edge, gpiod_line_edge,
 			 ::gpiod_line_settings_set_edge_detection>(this->_m_priv->settings.get(),
 								   edge, edge_mapping);
 
@@ -188,7 +191,7 @@ GPIOD_CXX_API line_settings& line_settings::set_edge_detection(line::edge edge)
 
 GPIOD_CXX_API line::edge line_settings::edge_detection() const
 {
-	return get_mapped_value<line::edge,
+	return get_mapped_value<line::edge, gpiod_line_edge,
 				::gpiod_line_settings_get_edge_detection>(
 							this->_m_priv->settings.get(),
 							reverse_edge_mapping);
@@ -196,7 +199,7 @@ GPIOD_CXX_API line::edge line_settings::edge_detection() const
 
 GPIOD_CXX_API line_settings& line_settings::set_bias(line::bias bias)
 {
-	set_mapped_value<line::bias,
+	set_mapped_value<line::bias, gpiod_line_bias,
 			 ::gpiod_line_settings_set_bias>(this->_m_priv->settings.get(),
 							 bias, bias_mapping);
 
@@ -205,14 +208,14 @@ GPIOD_CXX_API line_settings& line_settings::set_bias(line::bias bias)
 
 GPIOD_CXX_API line::bias line_settings::bias() const
 {
-	return get_mapped_value<line::bias,
+	return get_mapped_value<line::bias, gpiod_line_bias,
 				::gpiod_line_settings_get_bias>(this->_m_priv->settings.get(),
 								reverse_bias_mapping);
 }
 
 GPIOD_CXX_API line_settings& line_settings::set_drive(line::drive drive)
 {
-	set_mapped_value<line::drive,
+	set_mapped_value<line::drive, gpiod_line_drive,
 			 ::gpiod_line_settings_set_drive>(this->_m_priv->settings.get(),
 							  drive, drive_mapping);
 
@@ -221,7 +224,7 @@ GPIOD_CXX_API line_settings& line_settings::set_drive(line::drive drive)
 
 GPIOD_CXX_API line::drive line_settings::drive() const
 {
-	return get_mapped_value<line::drive,
+	return get_mapped_value<line::drive, gpiod_line_drive,
 				::gpiod_line_settings_get_drive>(this->_m_priv->settings.get(),
 								 reverse_drive_mapping);
 }
@@ -254,7 +257,7 @@ GPIOD_CXX_API ::std::chrono::microseconds line_settings::debounce_period() const
 
 GPIOD_CXX_API line_settings& line_settings::set_event_clock(line::clock event_clock)
 {
-	set_mapped_value<line::clock,
+	set_mapped_value<line::clock, gpiod_line_event_clock,
 			 ::gpiod_line_settings_set_event_clock>(this->_m_priv->settings.get(),
 								event_clock, clock_mapping);
 
@@ -263,7 +266,7 @@ GPIOD_CXX_API line_settings& line_settings::set_event_clock(line::clock event_cl
 
 GPIOD_CXX_API line::clock line_settings::event_clock() const
 {
-	return get_mapped_value<line::clock,
+	return get_mapped_value<line::clock, gpiod_line_event_clock,
 				::gpiod_line_settings_get_event_clock>(
 							this->_m_priv->settings.get(),
 							reverse_clock_mapping);
@@ -271,7 +274,7 @@ GPIOD_CXX_API line::clock line_settings::event_clock() const
 
 GPIOD_CXX_API line_settings& line_settings::set_output_value(line::value value)
 {
-	set_mapped_value<line::value,
+	set_mapped_value<line::value, gpiod_line_value,
 			 ::gpiod_line_settings_set_output_value>(this->_m_priv->settings.get(),
 								 value, value_mapping);
 
@@ -280,7 +283,7 @@ GPIOD_CXX_API line_settings& line_settings::set_output_value(line::value value)
 
 GPIOD_CXX_API line::value line_settings::output_value() const
 {
-	return get_mapped_value<line::value,
+	return get_mapped_value<line::value, gpiod_line_value,
 				::gpiod_line_settings_get_output_value>(
 							this->_m_priv->settings.get(),
 							reverse_value_mapping);
diff --git a/bindings/cxx/tests/gpiosim.cpp b/bindings/cxx/tests/gpiosim.cpp
index 0a29efe..281f9cc 100644
--- a/bindings/cxx/tests/gpiosim.cpp
+++ b/bindings/cxx/tests/gpiosim.cpp
@@ -12,18 +12,18 @@ namespace gpiosim {
 
 namespace {
 
-const ::std::map<chip::pull, int> pull_mapping = {
+const ::std::map<chip::pull, gpiosim_pull> pull_mapping = {
 	{ chip::pull::PULL_UP,		GPIOSIM_PULL_UP },
 	{ chip::pull::PULL_DOWN,	GPIOSIM_PULL_DOWN }
 };
 
-const ::std::map<chip_builder::hog_direction, int> hog_dir_mapping = {
+const ::std::map<chip_builder::hog_direction, gpiosim_direction> hog_dir_mapping = {
 	{ chip_builder::hog_direction::INPUT,		GPIOSIM_HOG_DIR_INPUT },
 	{ chip_builder::hog_direction::OUTPUT_HIGH,	GPIOSIM_HOG_DIR_OUTPUT_HIGH },
 	{ chip_builder::hog_direction::OUTPUT_LOW,	GPIOSIM_HOG_DIR_OUTPUT_LOW }
 };
 
-const ::std::map<int, chip::value> value_mapping = {
+const ::std::map<gpiosim_value, chip::value> value_mapping = {
 	{ GPIOSIM_VALUE_INACTIVE,	chip::value::INACTIVE },
 	{ GPIOSIM_VALUE_ACTIVE,		chip::value::ACTIVE }
 };
@@ -137,8 +137,8 @@ chip& chip::operator=(chip&& other)
 
 chip::value chip::get_value(unsigned int offset)
 {
-	int val = ::gpiosim_bank_get_value(this->_m_priv->bank.get(), offset);
-	if (val < 0)
+	auto val = ::gpiosim_bank_get_value(this->_m_priv->bank.get(), offset);
+	if (val == GPIOSIM_VALUE_ERROR)
 		throw ::std::system_error(errno, ::std::system_category(),
 					  "failed to read the simulated GPIO line value");
 
@@ -147,8 +147,8 @@ chip::value chip::get_value(unsigned int offset)
 
 void chip::set_pull(unsigned int offset, pull pull)
 {
-	int ret = ::gpiosim_bank_set_pull(this->_m_priv->bank.get(),
-					  offset, pull_mapping.at(pull));
+	auto ret = ::gpiosim_bank_set_pull(this->_m_priv->bank.get(),
+					   offset, pull_mapping.at(pull));
 	if (ret)
 		throw ::std::system_error(errno, ::std::system_category(),
 					  "failed to set the pull of simulated GPIO line");
diff --git a/bindings/python/gpiod/ext/line-settings.c b/bindings/python/gpiod/ext/line-settings.c
index f38b770..8ec1390 100644
--- a/bindings/python/gpiod/ext/line-settings.c
+++ b/bindings/python/gpiod/ext/line-settings.c
@@ -8,18 +8,10 @@ typedef struct {
 	struct gpiod_line_settings *settings;
 } line_settings_object;
 
-static int set_int_prop(struct gpiod_line_settings *settings, int val,
-			int (*func)(struct gpiod_line_settings *, int))
+static int set_error(void)
 {
-	int ret;
-
-	ret = func(settings, val);
-	if (ret) {
-		Py_gpiod_SetErrFromErrno();
-		return -1;
-	}
-
-	return 0;
+	Py_gpiod_SetErrFromErrno();
+	return -1;
 }
 
 static int
@@ -37,9 +29,14 @@ line_settings_init(line_settings_object *self, PyObject *args, PyObject *kwargs)
 		NULL
 	};
 
-	int direction, edge, bias, drive, active_low, event_clock, output_value,
-	    ret;
+	enum gpiod_line_event_clock event_clock;
+	enum gpiod_line_direction direction;
+	enum gpiod_line_value output_value;
 	unsigned long debounce_period;
+	enum gpiod_line_drive drive;
+	enum gpiod_line_edge edge;
+	enum gpiod_line_bias bias;
+	int ret, active_low;
 
 	ret = PyArg_ParseTupleAndKeywords(args, kwargs, "IIIIpkII", kwlist,
 			&direction, &edge, &bias, &drive, &active_low,
@@ -53,39 +50,34 @@ line_settings_init(line_settings_object *self, PyObject *args, PyObject *kwargs)
 		return -1;
 	}
 
-	ret = set_int_prop(self->settings, direction,
-			   gpiod_line_settings_set_direction);
+	ret = gpiod_line_settings_set_direction(self->settings, direction);
 	if (ret)
-		return -1;
+		return set_error();
 
-	ret = set_int_prop(self->settings, edge,
-			   gpiod_line_settings_set_edge_detection);
+	ret = gpiod_line_settings_set_edge_detection(self->settings, edge);
 	if (ret)
-		return -1;
+		return set_error();
 
-	ret = set_int_prop(self->settings, bias,
-			   gpiod_line_settings_set_bias);
+	ret = gpiod_line_settings_set_bias(self->settings, bias);
 	if (ret)
-		return -1;
+		return set_error();
 
-	ret = set_int_prop(self->settings, drive,
-			   gpiod_line_settings_set_drive);
+	ret = gpiod_line_settings_set_drive(self->settings, drive);
 	if (ret)
-		return -1;
+		return set_error();
 
 	gpiod_line_settings_set_active_low(self->settings, active_low);
 	gpiod_line_settings_set_debounce_period_us(self->settings,
 						   debounce_period);
 
-	ret = set_int_prop(self->settings, edge,
-			   gpiod_line_settings_set_edge_detection);
+	ret = gpiod_line_settings_set_edge_detection(self->settings, edge);
 	if (ret)
-		return -1;
+		return set_error();
 
-	ret = set_int_prop(self->settings, output_value,
-			   gpiod_line_settings_set_output_value);
+	ret = gpiod_line_settings_set_output_value(self->settings,
+						   output_value);
 	if (ret)
-		return -1;
+		return set_error();
 
 	return 0;
 }
diff --git a/bindings/python/gpiod/ext/request.c b/bindings/python/gpiod/ext/request.c
index 820d1e1..62378f5 100644
--- a/bindings/python/gpiod/ext/request.c
+++ b/bindings/python/gpiod/ext/request.c
@@ -7,7 +7,7 @@ typedef struct {
 	PyObject_HEAD;
 	struct gpiod_line_request *request;
 	unsigned int *offsets;
-	int *values;
+	enum gpiod_line_value *values;
 	size_t num_lines;
 	struct gpiod_edge_event_buffer *buffer;
 } request_object;
@@ -360,10 +360,10 @@ PyObject *Py_gpiod_MakeRequestObject(struct gpiod_line_request *request,
 				     size_t event_buffer_size)
 {
 	struct gpiod_edge_event_buffer *buffer;
+	enum gpiod_line_value *values;
 	request_object *req_obj;
 	unsigned int *offsets;
 	size_t num_lines;
-	int *values;
 
 	num_lines = gpiod_line_request_get_num_lines(request);
 
diff --git a/bindings/rust/gpiosim-sys/src/lib.rs b/bindings/rust/gpiosim-sys/src/lib.rs
index 5391dbd..420e015 100644
--- a/bindings/rust/gpiosim-sys/src/lib.rs
+++ b/bindings/rust/gpiosim-sys/src/lib.rs
@@ -2,7 +2,7 @@
 // SPDX-FileCopyrightText: 2022 Linaro Ltd.
 // SPDX-FileCopyrightTest: 2022 Viresh Kumar <viresh.kumar@linaro.org>
 
-use libgpiod::{Error, Result};
+use libgpiod::{Error, Result, OperationType};
 
 #[allow(non_camel_case_types, non_upper_case_globals)]
 #[cfg_attr(test, allow(deref_nullptr, non_snake_case))]
@@ -15,6 +15,17 @@ use bindings_raw::*;
 mod sim;
 pub use sim::*;
 
+use crate::{
+    gpiosim_value_GPIOSIM_VALUE_INACTIVE as GPIOSIM_VALUE_INACTIVE,
+    gpiosim_value_GPIOSIM_VALUE_ACTIVE as GPIOSIM_VALUE_ACTIVE,	
+    gpiosim_value_GPIOSIM_VALUE_ERROR as GPIOSIM_VALUE_ERROR,
+    gpiosim_direction_GPIOSIM_HOG_DIR_INPUT as GPIOSIM_HOG_DIR_INPUT,
+    gpiosim_direction_GPIOSIM_HOG_DIR_OUTPUT_HIGH as GPIOSIM_HOG_DIR_OUTPUT_HIGH,
+    gpiosim_direction_GPIOSIM_HOG_DIR_OUTPUT_LOW as GPIOSIM_HOG_DIR_OUTPUT_LOW,
+    gpiosim_pull_GPIOSIM_PULL_UP as GPIOSIM_PULL_UP,
+    gpiosim_pull_GPIOSIM_PULL_DOWN as GPIOSIM_PULL_DOWN,
+};
+
 /// Value settings.
 #[derive(Copy, Clone, Debug, Eq, PartialEq)]
 pub enum Value {
@@ -25,12 +36,17 @@ pub enum Value {
 }
 
 impl Value {
-    pub(crate) fn new(val: u32) -> Result<Self> {
-        match val {
-            GPIOSIM_VALUE_INACTIVE => Ok(Value::InActive),
-            GPIOSIM_VALUE_ACTIVE => Ok(Value::Active),
-            _ => Err(Error::InvalidEnumValue("Value", val as u32)),
-        }
+    pub(crate) fn new(val: gpiosim_value) -> Result<Self> {
+        Ok(match val {
+            GPIOSIM_VALUE_INACTIVE => Value::InActive,
+            GPIOSIM_VALUE_ACTIVE => Value::Active,
+            GPIOSIM_VALUE_ERROR => {
+                return Err(Error::OperationFailed(
+                    OperationType::SimBankGetVal, errno::errno()
+                ))
+            }
+            _ => return Err(Error::InvalidEnumValue("Value", val as i32)),
+        })
     }
 }
 
@@ -46,12 +62,12 @@ pub enum Direction {
 }
 
 impl Direction {
-    fn val(self) -> i32 {
-        (match self {
+    fn val(self) -> gpiosim_direction {
+        match self {
             Direction::Input => GPIOSIM_HOG_DIR_INPUT,
             Direction::OutputHigh => GPIOSIM_HOG_DIR_OUTPUT_HIGH,
             Direction::OutputLow => GPIOSIM_HOG_DIR_OUTPUT_LOW,
-        }) as i32
+        }
     }
 }
 
@@ -65,10 +81,10 @@ pub enum Pull {
 }
 
 impl Pull {
-    fn val(self) -> i32 {
-        (match self {
+    fn val(self) -> gpiosim_pull {
+        match self {
             Pull::Up => GPIOSIM_PULL_UP,
             Pull::Down => GPIOSIM_PULL_DOWN,
-        }) as i32
+        }
     }
 }
diff --git a/bindings/rust/gpiosim-sys/src/sim.rs b/bindings/rust/gpiosim-sys/src/sim.rs
index 4930fb6..777bf08 100644
--- a/bindings/rust/gpiosim-sys/src/sim.rs
+++ b/bindings/rust/gpiosim-sys/src/sim.rs
@@ -164,7 +164,7 @@ impl SimBank {
                 errno::errno(),
             ))
         } else {
-            Value::new(ret as u32)
+            Value::new(ret as i32)
         }
     }
 
diff --git a/bindings/rust/libgpiod/src/lib.rs b/bindings/rust/libgpiod/src/lib.rs
index 161de16..d7a0615 100644
--- a/bindings/rust/libgpiod/src/lib.rs
+++ b/bindings/rust/libgpiod/src/lib.rs
@@ -24,6 +24,35 @@ use thiserror::Error as ThisError;
 
 use libgpiod_sys as gpiod;
 
+use gpiod::{
+    gpiod_edge_event_type_GPIOD_EDGE_EVENT_FALLING_EDGE as GPIOD_EDGE_EVENT_FALLING_EDGE,
+    gpiod_edge_event_type_GPIOD_EDGE_EVENT_RISING_EDGE as GPIOD_EDGE_EVENT_RISING_EDGE,
+    gpiod_info_event_type_GPIOD_INFO_EVENT_LINE_CONFIG_CHANGED as GPIOD_INFO_EVENT_LINE_CONFIG_CHANGED,
+    gpiod_info_event_type_GPIOD_INFO_EVENT_LINE_RELEASED as GPIOD_INFO_EVENT_LINE_RELEASED,
+    gpiod_info_event_type_GPIOD_INFO_EVENT_LINE_REQUESTED as GPIOD_INFO_EVENT_LINE_REQUESTED,
+    gpiod_line_bias_GPIOD_LINE_BIAS_AS_IS as GPIOD_LINE_BIAS_AS_IS,
+    gpiod_line_bias_GPIOD_LINE_BIAS_DISABLED as GPIOD_LINE_BIAS_DISABLED,
+    gpiod_line_bias_GPIOD_LINE_BIAS_PULL_DOWN as GPIOD_LINE_BIAS_PULL_DOWN,
+    gpiod_line_bias_GPIOD_LINE_BIAS_PULL_UP as GPIOD_LINE_BIAS_PULL_UP,
+    gpiod_line_bias_GPIOD_LINE_BIAS_UNKNOWN as GPIOD_LINE_BIAS_UNKNOWN,
+    gpiod_line_direction_GPIOD_LINE_DIRECTION_AS_IS as GPIOD_LINE_DIRECTION_AS_IS,
+    gpiod_line_direction_GPIOD_LINE_DIRECTION_INPUT as GPIOD_LINE_DIRECTION_INPUT,
+    gpiod_line_direction_GPIOD_LINE_DIRECTION_OUTPUT as GPIOD_LINE_DIRECTION_OUTPUT,
+    gpiod_line_drive_GPIOD_LINE_DRIVE_OPEN_DRAIN as GPIOD_LINE_DRIVE_OPEN_DRAIN,
+    gpiod_line_drive_GPIOD_LINE_DRIVE_OPEN_SOURCE as GPIOD_LINE_DRIVE_OPEN_SOURCE,
+    gpiod_line_drive_GPIOD_LINE_DRIVE_PUSH_PULL as GPIOD_LINE_DRIVE_PUSH_PULL,
+    gpiod_line_edge_GPIOD_LINE_EDGE_BOTH as GPIOD_LINE_EDGE_BOTH,
+    gpiod_line_edge_GPIOD_LINE_EDGE_FALLING as GPIOD_LINE_EDGE_FALLING,
+    gpiod_line_edge_GPIOD_LINE_EDGE_NONE as GPIOD_LINE_EDGE_NONE,
+    gpiod_line_edge_GPIOD_LINE_EDGE_RISING as GPIOD_LINE_EDGE_RISING,
+    gpiod_line_event_clock_GPIOD_LINE_EVENT_CLOCK_HTE as GPIOD_LINE_EVENT_CLOCK_HTE,
+    gpiod_line_event_clock_GPIOD_LINE_EVENT_CLOCK_MONOTONIC as GPIOD_LINE_EVENT_CLOCK_MONOTONIC,
+    gpiod_line_event_clock_GPIOD_LINE_EVENT_CLOCK_REALTIME as GPIOD_LINE_EVENT_CLOCK_REALTIME,
+    gpiod_line_value_GPIOD_LINE_VALUE_ACTIVE as GPIOD_LINE_VALUE_ACTIVE,
+    gpiod_line_value_GPIOD_LINE_VALUE_INACTIVE as GPIOD_LINE_VALUE_INACTIVE,
+    gpiod_line_value_GPIOD_LINE_VALUE_ERROR as GPIOD_LINE_VALUE_ERROR,
+};
+
 /// Operation types, used with OperationFailed() Error.
 #[derive(Copy, Clone, Debug, Eq, PartialEq)]
 pub enum OperationType {
@@ -96,7 +125,7 @@ pub enum Error {
     #[error("Invalid String")]
     InvalidString,
     #[error("Invalid enum {0} value: {1}")]
-    InvalidEnumValue(&'static str, u32),
+    InvalidEnumValue(&'static str, i32),
     #[error("Operation {0} Failed: {1}")]
     OperationFailed(OperationType, errno::Errno),
     #[error("Invalid Arguments")]
@@ -150,18 +179,24 @@ pub mod line {
     pub type ValueMap = IntMap<Value>;
 
     impl Value {
-        pub fn new(val: i32) -> Result<Self> {
+        pub fn new(val: gpiod::gpiod_line_value) -> Result<Self> {
             Ok(match val {
-                0 => Value::InActive,
-                1 => Value::Active,
-                _ => return Err(Error::InvalidEnumValue("Value", val as u32)),
+                GPIOD_LINE_VALUE_INACTIVE => Value::InActive,
+                GPIOD_LINE_VALUE_ACTIVE => Value::Active,
+                GPIOD_LINE_VALUE_ERROR => {
+                    return Err(Error::OperationFailed(
+                        OperationType::LineRequestGetVal,
+                        errno::errno(),
+                    ))
+                }
+                _ => return Err(Error::InvalidEnumValue("Value", val as i32)),
             })
         }
 
-        pub(crate) fn value(&self) -> i32 {
+        pub(crate) fn value(&self) -> gpiod::gpiod_line_value {
             match self {
-                Value::Active => 1,
-                Value::InActive => 0,
+                Value::Active => GPIOD_LINE_VALUE_ACTIVE,
+                Value::InActive => GPIOD_LINE_VALUE_INACTIVE,
             }
         }
     }
@@ -181,20 +216,20 @@ pub mod line {
     }
 
     impl Direction {
-        pub(crate) fn new(dir: u32) -> Result<Self> {
+        pub(crate) fn new(dir: gpiod::gpiod_line_direction) -> Result<Self> {
             Ok(match dir {
-                gpiod::GPIOD_LINE_DIRECTION_AS_IS => Direction::AsIs,
-                gpiod::GPIOD_LINE_DIRECTION_INPUT => Direction::Input,
-                gpiod::GPIOD_LINE_DIRECTION_OUTPUT => Direction::Output,
-                _ => return Err(Error::InvalidEnumValue("Direction", dir)),
+                GPIOD_LINE_DIRECTION_AS_IS => Direction::AsIs,
+                GPIOD_LINE_DIRECTION_INPUT => Direction::Input,
+                GPIOD_LINE_DIRECTION_OUTPUT => Direction::Output,
+                _ => return Err(Error::InvalidEnumValue("Direction", dir as i32)),
             })
         }
 
-        pub(crate) fn gpiod_direction(&self) -> u32 {
+        pub(crate) fn gpiod_direction(&self) -> gpiod::gpiod_line_direction {
             match self {
-                Direction::AsIs => gpiod::GPIOD_LINE_DIRECTION_AS_IS,
-                Direction::Input => gpiod::GPIOD_LINE_DIRECTION_INPUT,
-                Direction::Output => gpiod::GPIOD_LINE_DIRECTION_OUTPUT,
+                Direction::AsIs => GPIOD_LINE_DIRECTION_AS_IS,
+                Direction::Input => GPIOD_LINE_DIRECTION_INPUT,
+                Direction::Output => GPIOD_LINE_DIRECTION_OUTPUT,
             }
         }
     }
@@ -211,24 +246,24 @@ pub mod line {
     }
 
     impl Bias {
-        pub(crate) fn new(bias: u32) -> Result<Option<Self>> {
+        pub(crate) fn new(bias: gpiod::gpiod_line_bias) -> Result<Option<Self>> {
             Ok(match bias {
-                gpiod::GPIOD_LINE_BIAS_UNKNOWN => None,
-                gpiod::GPIOD_LINE_BIAS_AS_IS => None,
-                gpiod::GPIOD_LINE_BIAS_DISABLED => Some(Bias::Disabled),
-                gpiod::GPIOD_LINE_BIAS_PULL_UP => Some(Bias::PullUp),
-                gpiod::GPIOD_LINE_BIAS_PULL_DOWN => Some(Bias::PullDown),
-                _ => return Err(Error::InvalidEnumValue("Bias", bias)),
+                GPIOD_LINE_BIAS_UNKNOWN => None,
+                GPIOD_LINE_BIAS_AS_IS => None,
+                GPIOD_LINE_BIAS_DISABLED => Some(Bias::Disabled),
+                GPIOD_LINE_BIAS_PULL_UP => Some(Bias::PullUp),
+                GPIOD_LINE_BIAS_PULL_DOWN => Some(Bias::PullDown),
+                _ => return Err(Error::InvalidEnumValue("Bias", bias as i32)),
             })
         }
 
-        pub(crate) fn gpiod_bias(bias: Option<Bias>) -> u32 {
+        pub(crate) fn gpiod_bias(bias: Option<Bias>) -> gpiod::gpiod_line_bias {
             match bias {
-                None => gpiod::GPIOD_LINE_BIAS_AS_IS,
+                None => GPIOD_LINE_BIAS_AS_IS,
                 Some(bias) => match bias {
-                    Bias::Disabled => gpiod::GPIOD_LINE_BIAS_DISABLED,
-                    Bias::PullUp => gpiod::GPIOD_LINE_BIAS_PULL_UP,
-                    Bias::PullDown => gpiod::GPIOD_LINE_BIAS_PULL_DOWN,
+                    Bias::Disabled => GPIOD_LINE_BIAS_DISABLED,
+                    Bias::PullUp => GPIOD_LINE_BIAS_PULL_UP,
+                    Bias::PullDown => GPIOD_LINE_BIAS_PULL_DOWN,
                 },
             }
         }
@@ -246,20 +281,20 @@ pub mod line {
     }
 
     impl Drive {
-        pub(crate) fn new(drive: u32) -> Result<Self> {
+        pub(crate) fn new(drive: gpiod::gpiod_line_drive) -> Result<Self> {
             Ok(match drive {
-                gpiod::GPIOD_LINE_DRIVE_PUSH_PULL => Drive::PushPull,
-                gpiod::GPIOD_LINE_DRIVE_OPEN_DRAIN => Drive::OpenDrain,
-                gpiod::GPIOD_LINE_DRIVE_OPEN_SOURCE => Drive::OpenSource,
-                _ => return Err(Error::InvalidEnumValue("Drive", drive)),
+                GPIOD_LINE_DRIVE_PUSH_PULL => Drive::PushPull,
+                GPIOD_LINE_DRIVE_OPEN_DRAIN => Drive::OpenDrain,
+                GPIOD_LINE_DRIVE_OPEN_SOURCE => Drive::OpenSource,
+                _ => return Err(Error::InvalidEnumValue("Drive", drive as i32)),
             })
         }
 
-        pub(crate) fn gpiod_drive(&self) -> u32 {
+        pub(crate) fn gpiod_drive(&self) -> gpiod::gpiod_line_drive {
             match self {
-                Drive::PushPull => gpiod::GPIOD_LINE_DRIVE_PUSH_PULL,
-                Drive::OpenDrain => gpiod::GPIOD_LINE_DRIVE_OPEN_DRAIN,
-                Drive::OpenSource => gpiod::GPIOD_LINE_DRIVE_OPEN_SOURCE,
+                Drive::PushPull => GPIOD_LINE_DRIVE_PUSH_PULL,
+                Drive::OpenDrain => GPIOD_LINE_DRIVE_OPEN_DRAIN,
+                Drive::OpenSource => GPIOD_LINE_DRIVE_OPEN_SOURCE,
             }
         }
     }
@@ -276,23 +311,23 @@ pub mod line {
     }
 
     impl Edge {
-        pub(crate) fn new(edge: u32) -> Result<Option<Self>> {
+        pub(crate) fn new(edge: gpiod::gpiod_line_edge) -> Result<Option<Self>> {
             Ok(match edge {
-                gpiod::GPIOD_LINE_EDGE_NONE => None,
-                gpiod::GPIOD_LINE_EDGE_RISING => Some(Edge::Rising),
-                gpiod::GPIOD_LINE_EDGE_FALLING => Some(Edge::Falling),
-                gpiod::GPIOD_LINE_EDGE_BOTH => Some(Edge::Both),
-                _ => return Err(Error::InvalidEnumValue("Edge", edge)),
+                GPIOD_LINE_EDGE_NONE => None,
+                GPIOD_LINE_EDGE_RISING => Some(Edge::Rising),
+                GPIOD_LINE_EDGE_FALLING => Some(Edge::Falling),
+                GPIOD_LINE_EDGE_BOTH => Some(Edge::Both),
+                _ => return Err(Error::InvalidEnumValue("Edge", edge as i32)),
             })
         }
 
-        pub(crate) fn gpiod_edge(edge: Option<Edge>) -> u32 {
+        pub(crate) fn gpiod_edge(edge: Option<Edge>) -> gpiod::gpiod_line_edge {
             match edge {
-                None => gpiod::GPIOD_LINE_EDGE_NONE,
+                None => GPIOD_LINE_EDGE_NONE,
                 Some(edge) => match edge {
-                    Edge::Rising => gpiod::GPIOD_LINE_EDGE_RISING,
-                    Edge::Falling => gpiod::GPIOD_LINE_EDGE_FALLING,
-                    Edge::Both => gpiod::GPIOD_LINE_EDGE_BOTH,
+                    Edge::Rising => GPIOD_LINE_EDGE_RISING,
+                    Edge::Falling => GPIOD_LINE_EDGE_FALLING,
+                    Edge::Both => GPIOD_LINE_EDGE_BOTH,
                 },
             }
         }
@@ -358,20 +393,20 @@ pub mod line {
     }
 
     impl EventClock {
-        pub(crate) fn new(clock: u32) -> Result<Self> {
+        pub(crate) fn new(clock: gpiod::gpiod_line_event_clock) -> Result<Self> {
             Ok(match clock {
-                gpiod::GPIOD_LINE_EVENT_CLOCK_MONOTONIC => EventClock::Monotonic,
-                gpiod::GPIOD_LINE_EVENT_CLOCK_REALTIME => EventClock::Realtime,
-                gpiod::GPIOD_LINE_EVENT_CLOCK_HTE => EventClock::HTE,
-                _ => return Err(Error::InvalidEnumValue("Eventclock", clock)),
+                GPIOD_LINE_EVENT_CLOCK_MONOTONIC => EventClock::Monotonic,
+                GPIOD_LINE_EVENT_CLOCK_REALTIME => EventClock::Realtime,
+                GPIOD_LINE_EVENT_CLOCK_HTE => EventClock::HTE,
+                _ => return Err(Error::InvalidEnumValue("Eventclock", clock as i32)),
             })
         }
 
-        pub(crate) fn gpiod_clock(&self) -> u32 {
+        pub(crate) fn gpiod_clock(&self) -> gpiod::gpiod_line_event_clock {
             match self {
-                EventClock::Monotonic => gpiod::GPIOD_LINE_EVENT_CLOCK_MONOTONIC,
-                EventClock::Realtime => gpiod::GPIOD_LINE_EVENT_CLOCK_REALTIME,
-                EventClock::HTE => gpiod::GPIOD_LINE_EVENT_CLOCK_HTE,
+                EventClock::Monotonic => GPIOD_LINE_EVENT_CLOCK_MONOTONIC,
+                EventClock::Realtime => GPIOD_LINE_EVENT_CLOCK_REALTIME,
+                EventClock::HTE => GPIOD_LINE_EVENT_CLOCK_HTE,
             }
         }
     }
@@ -388,12 +423,12 @@ pub mod line {
     }
 
     impl InfoChangeKind {
-        pub(crate) fn new(kind: u32) -> Result<Self> {
+        pub(crate) fn new(kind: gpiod::gpiod_info_event_type) -> Result<Self> {
             Ok(match kind {
-                gpiod::GPIOD_INFO_EVENT_LINE_REQUESTED => InfoChangeKind::LineRequested,
-                gpiod::GPIOD_INFO_EVENT_LINE_RELEASED => InfoChangeKind::LineReleased,
-                gpiod::GPIOD_INFO_EVENT_LINE_CONFIG_CHANGED => InfoChangeKind::LineConfigChanged,
-                _ => return Err(Error::InvalidEnumValue("InfoChangeKind", kind)),
+                GPIOD_INFO_EVENT_LINE_REQUESTED => InfoChangeKind::LineRequested,
+                GPIOD_INFO_EVENT_LINE_RELEASED => InfoChangeKind::LineReleased,
+                GPIOD_INFO_EVENT_LINE_CONFIG_CHANGED => InfoChangeKind::LineConfigChanged,
+                _ => return Err(Error::InvalidEnumValue("InfoChangeKind", kind as i32)),
             })
         }
     }
@@ -408,11 +443,11 @@ pub mod line {
     }
 
     impl EdgeKind {
-        pub(crate) fn new(kind: u32) -> Result<Self> {
+        pub(crate) fn new(kind: gpiod::gpiod_edge_event_type) -> Result<Self> {
             Ok(match kind {
-                gpiod::GPIOD_EDGE_EVENT_RISING_EDGE => EdgeKind::Rising,
-                gpiod::GPIOD_EDGE_EVENT_FALLING_EDGE => EdgeKind::Falling,
-                _ => return Err(Error::InvalidEnumValue("EdgeEvent", kind)),
+                GPIOD_EDGE_EVENT_RISING_EDGE => EdgeKind::Rising,
+                GPIOD_EDGE_EVENT_FALLING_EDGE => EdgeKind::Falling,
+                _ => return Err(Error::InvalidEnumValue("EdgeEvent", kind as i32)),
             })
         }
     }
diff --git a/bindings/rust/libgpiod/src/line_info.rs b/bindings/rust/libgpiod/src/line_info.rs
index 1784cde..b45878c 100644
--- a/bindings/rust/libgpiod/src/line_info.rs
+++ b/bindings/rust/libgpiod/src/line_info.rs
@@ -100,7 +100,7 @@ impl Info {
     /// Get the GPIO line's direction.
     pub fn direction(&self) -> Result<Direction> {
         // SAFETY: `gpiod_line_info` is guaranteed to be valid here.
-        Direction::new(unsafe { gpiod::gpiod_line_info_get_direction(self.info) } as u32)
+        Direction::new(unsafe { gpiod::gpiod_line_info_get_direction(self.info) })
     }
 
     /// Returns true if the line is "active-low", false otherwise.
@@ -112,25 +112,25 @@ impl Info {
     /// Get the GPIO line's bias setting.
     pub fn bias(&self) -> Result<Option<Bias>> {
         // SAFETY: `gpiod_line_info` is guaranteed to be valid here.
-        Bias::new(unsafe { gpiod::gpiod_line_info_get_bias(self.info) } as u32)
+        Bias::new(unsafe { gpiod::gpiod_line_info_get_bias(self.info) })
     }
 
     /// Get the GPIO line's drive setting.
     pub fn drive(&self) -> Result<Drive> {
         // SAFETY: `gpiod_line_info` is guaranteed to be valid here.
-        Drive::new(unsafe { gpiod::gpiod_line_info_get_drive(self.info) } as u32)
+        Drive::new(unsafe { gpiod::gpiod_line_info_get_drive(self.info) })
     }
 
     /// Get the current edge detection setting of the line.
     pub fn edge_detection(&self) -> Result<Option<Edge>> {
         // SAFETY: `gpiod_line_info` is guaranteed to be valid here.
-        Edge::new(unsafe { gpiod::gpiod_line_info_get_edge_detection(self.info) } as u32)
+        Edge::new(unsafe { gpiod::gpiod_line_info_get_edge_detection(self.info) })
     }
 
     /// Get the current event clock setting used for edge event timestamps.
     pub fn event_clock(&self) -> Result<EventClock> {
         // SAFETY: `gpiod_line_info` is guaranteed to be valid here.
-        EventClock::new(unsafe { gpiod::gpiod_line_info_get_event_clock(self.info) } as u32)
+        EventClock::new(unsafe { gpiod::gpiod_line_info_get_event_clock(self.info) })
     }
 
     /// Returns true if the line is debounced (either by hardware or by the
diff --git a/bindings/rust/libgpiod/src/line_settings.rs b/bindings/rust/libgpiod/src/line_settings.rs
index cedf7ca..1c5ac66 100644
--- a/bindings/rust/libgpiod/src/line_settings.rs
+++ b/bindings/rust/libgpiod/src/line_settings.rs
@@ -102,10 +102,7 @@ impl Settings {
     pub fn set_direction(&mut self, direction: Direction) -> Result<&mut Self> {
         // SAFETY: `gpiod_line_settings` is guaranteed to be valid here.
         let ret = unsafe {
-            gpiod::gpiod_line_settings_set_direction(
-                self.settings,
-                direction.gpiod_direction() as i32,
-            )
+            gpiod::gpiod_line_settings_set_direction(self.settings, direction.gpiod_direction())
         };
 
         if ret == -1 {
@@ -121,17 +118,14 @@ impl Settings {
     /// Get the direction setting.
     pub fn direction(&self) -> Result<Direction> {
         // SAFETY: `gpiod_line_settings` is guaranteed to be valid here.
-        Direction::new(unsafe { gpiod::gpiod_line_settings_get_direction(self.settings) } as u32)
+        Direction::new(unsafe { gpiod::gpiod_line_settings_get_direction(self.settings) })
     }
 
     /// Set the edge event detection setting.
     pub fn set_edge_detection(&mut self, edge: Option<Edge>) -> Result<&mut Self> {
         // SAFETY: `gpiod_line_settings` is guaranteed to be valid here.
         let ret = unsafe {
-            gpiod::gpiod_line_settings_set_edge_detection(
-                self.settings,
-                Edge::gpiod_edge(edge) as i32,
-            )
+            gpiod::gpiod_line_settings_set_edge_detection(self.settings, Edge::gpiod_edge(edge))
         };
 
         if ret == -1 {
@@ -147,15 +141,14 @@ impl Settings {
     /// Get the edge event detection setting.
     pub fn edge_detection(&self) -> Result<Option<Edge>> {
         // SAFETY: `gpiod_line_settings` is guaranteed to be valid here.
-        Edge::new(unsafe { gpiod::gpiod_line_settings_get_edge_detection(self.settings) } as u32)
+        Edge::new(unsafe { gpiod::gpiod_line_settings_get_edge_detection(self.settings) })
     }
 
     /// Set the bias setting.
     pub fn set_bias(&mut self, bias: Option<Bias>) -> Result<&mut Self> {
         // SAFETY: `gpiod_line_settings` is guaranteed to be valid here.
-        let ret = unsafe {
-            gpiod::gpiod_line_settings_set_bias(self.settings, Bias::gpiod_bias(bias) as i32)
-        };
+        let ret =
+            unsafe { gpiod::gpiod_line_settings_set_bias(self.settings, Bias::gpiod_bias(bias)) };
 
         if ret == -1 {
             Err(Error::OperationFailed(
@@ -170,15 +163,14 @@ impl Settings {
     /// Get the bias setting.
     pub fn bias(&self) -> Result<Option<Bias>> {
         // SAFETY: `gpiod_line_settings` is guaranteed to be valid here.
-        Bias::new(unsafe { gpiod::gpiod_line_settings_get_bias(self.settings) } as u32)
+        Bias::new(unsafe { gpiod::gpiod_line_settings_get_bias(self.settings) })
     }
 
     /// Set the drive setting.
     pub fn set_drive(&mut self, drive: Drive) -> Result<&mut Self> {
         // SAFETY: `gpiod_line_settings` is guaranteed to be valid here.
-        let ret = unsafe {
-            gpiod::gpiod_line_settings_set_drive(self.settings, drive.gpiod_drive() as i32)
-        };
+        let ret =
+            unsafe { gpiod::gpiod_line_settings_set_drive(self.settings, drive.gpiod_drive()) };
 
         if ret == -1 {
             Err(Error::OperationFailed(
@@ -193,7 +185,7 @@ impl Settings {
     /// Get the drive setting.
     pub fn drive(&self) -> Result<Drive> {
         // SAFETY: `gpiod_line_settings` is guaranteed to be valid here.
-        Drive::new(unsafe { gpiod::gpiod_line_settings_get_drive(self.settings) } as u32)
+        Drive::new(unsafe { gpiod::gpiod_line_settings_get_drive(self.settings) })
     }
 
     /// Set active-low setting.
@@ -236,7 +228,7 @@ impl Settings {
     pub fn set_event_clock(&mut self, clock: EventClock) -> Result<&mut Self> {
         // SAFETY: `gpiod_line_settings` is guaranteed to be valid here.
         let ret = unsafe {
-            gpiod::gpiod_line_settings_set_event_clock(self.settings, clock.gpiod_clock() as i32)
+            gpiod::gpiod_line_settings_set_event_clock(self.settings, clock.gpiod_clock())
         };
 
         if ret == -1 {
diff --git a/include/gpiod.h b/include/gpiod.h
index 2975e3a..f4bb5f2 100644
--- a/include/gpiod.h
+++ b/include/gpiod.h
@@ -244,7 +244,9 @@ size_t gpiod_chip_info_get_num_lines(struct gpiod_chip_info *info);
 /**
  * @brief Logical line state.
  */
-enum {
+enum gpiod_line_value {
+	GPIOD_LINE_VALUE_ERROR = -1,
+	/**< Returned to indicate an error when reading the value. */
 	GPIOD_LINE_VALUE_INACTIVE = 0,
 	/**< Line is logically inactive. */
 	GPIOD_LINE_VALUE_ACTIVE = 1,
@@ -254,7 +256,7 @@ enum {
 /**
  * @brief Direction settings.
  */
-enum {
+enum gpiod_line_direction {
 	GPIOD_LINE_DIRECTION_AS_IS = 1,
 	/**< Request the line(s), but don't change direction. */
 	GPIOD_LINE_DIRECTION_INPUT,
@@ -266,7 +268,7 @@ enum {
 /**
  * @brief Edge detection settings.
  */
-enum {
+enum gpiod_line_edge {
 	GPIOD_LINE_EDGE_NONE = 1,
 	/**< Line edge detection is disabled. */
 	GPIOD_LINE_EDGE_RISING,
@@ -280,7 +282,7 @@ enum {
 /**
  * @brief Internal bias settings.
  */
-enum {
+enum gpiod_line_bias {
 	GPIOD_LINE_BIAS_AS_IS = 1,
 	/**< Don't change the bias setting when applying line config. */
 	GPIOD_LINE_BIAS_UNKNOWN,
@@ -296,7 +298,7 @@ enum {
 /**
  * @brief Drive settings.
  */
-enum {
+enum gpiod_line_drive {
 	GPIOD_LINE_DRIVE_PUSH_PULL = 1,
 	/**< Drive setting is push-pull. */
 	GPIOD_LINE_DRIVE_OPEN_DRAIN,
@@ -308,7 +310,7 @@ enum {
 /**
  * @brief Event clock settings.
  */
-enum {
+enum gpiod_line_event_clock {
 	GPIOD_LINE_EVENT_CLOCK_MONOTONIC = 1,
 	/**< Line uses the monotonic clock for edge event timestamps. */
 	GPIOD_LINE_EVENT_CLOCK_REALTIME,
@@ -404,7 +406,8 @@ const char *gpiod_line_info_get_consumer(struct gpiod_line_info *info);
  * @return Returns ::GPIOD_LINE_DIRECTION_INPUT or
  *	   ::GPIOD_LINE_DIRECTION_OUTPUT.
  */
-int gpiod_line_info_get_direction(struct gpiod_line_info *info);
+enum gpiod_line_direction
+gpiod_line_info_get_direction(struct gpiod_line_info *info);
 
 /**
  * @brief Get the edge detection setting of the line.
@@ -412,7 +415,8 @@ int gpiod_line_info_get_direction(struct gpiod_line_info *info);
  * @return Returns ::GPIOD_LINE_EDGE_NONE, ::GPIOD_LINE_EDGE_RISING,
  *	   ::GPIOD_LINE_EDGE_FALLING or ::GPIOD_LINE_EDGE_BOTH.
  */
-int gpiod_line_info_get_edge_detection(struct gpiod_line_info *info);
+enum gpiod_line_edge
+gpiod_line_info_get_edge_detection(struct gpiod_line_info *info);
 
 /**
  * @brief Get the bias setting of the line.
@@ -420,7 +424,8 @@ int gpiod_line_info_get_edge_detection(struct gpiod_line_info *info);
  * @return Returns ::GPIOD_LINE_BIAS_PULL_UP, ::GPIOD_LINE_BIAS_PULL_DOWN,
  *	   ::GPIOD_LINE_BIAS_DISABLED or ::GPIOD_LINE_BIAS_UNKNOWN.
  */
-int gpiod_line_info_get_bias(struct gpiod_line_info *info);
+enum gpiod_line_bias
+gpiod_line_info_get_bias(struct gpiod_line_info *info);
 
 /**
  * @brief Get the drive setting of the line.
@@ -428,7 +433,8 @@ int gpiod_line_info_get_bias(struct gpiod_line_info *info);
  * @return Returns ::GPIOD_LINE_DRIVE_PUSH_PULL, ::GPIOD_LINE_DRIVE_OPEN_DRAIN
  *	   or ::GPIOD_LINE_DRIVE_OPEN_SOURCE.
  */
-int gpiod_line_info_get_drive(struct gpiod_line_info *info);
+enum gpiod_line_drive
+gpiod_line_info_get_drive(struct gpiod_line_info *info);
 
 /**
  * @brief Check if the logical value of the line is inverted compared to the
@@ -462,7 +468,8 @@ gpiod_line_info_get_debounce_period_us(struct gpiod_line_info *info);
  * @return Returns ::GPIOD_LINE_EVENT_CLOCK_MONOTONIC or
  *	   ::GPIOD_LINE_EVENT_CLOCK_REALTIME.
  */
-int gpiod_line_info_get_event_clock(struct gpiod_line_info *info);
+enum gpiod_line_event_clock
+gpiod_line_info_get_event_clock(struct gpiod_line_info *info);
 
 /**
  * @}
@@ -482,7 +489,7 @@ int gpiod_line_info_get_event_clock(struct gpiod_line_info *info);
 /**
  * @brief Line status change event types.
  */
-enum {
+enum gpiod_info_event_type {
 	GPIOD_INFO_EVENT_LINE_REQUESTED = 1,
 	/**< Line has been requested. */
 	GPIOD_INFO_EVENT_LINE_RELEASED,
@@ -504,7 +511,8 @@ void gpiod_info_event_free(struct gpiod_info_event *event);
  *	   ::GPIOD_INFO_EVENT_LINE_RELEASED or
  *	   ::GPIOD_INFO_EVENT_LINE_CONFIG_CHANGED.
  */
-int gpiod_info_event_get_event_type(struct gpiod_info_event *event);
+enum gpiod_info_event_type
+gpiod_info_event_get_event_type(struct gpiod_info_event *event);
 
 /**
  * @brief Get the timestamp of the event.
@@ -575,14 +583,15 @@ gpiod_line_settings_copy(struct gpiod_line_settings *settings);
  * @return 0 on success, -1 on error.
  */
 int gpiod_line_settings_set_direction(struct gpiod_line_settings *settings,
-				      int direction);
+				      enum gpiod_line_direction direction);
 
 /**
  * @brief Get direction.
  * @param settings Line settings object.
  * @return Current direction.
  */
-int gpiod_line_settings_get_direction(struct gpiod_line_settings *settings);
+enum gpiod_line_direction
+gpiod_line_settings_get_direction(struct gpiod_line_settings *settings);
 
 /**
  * @brief Set edge detection.
@@ -591,14 +600,14 @@ int gpiod_line_settings_get_direction(struct gpiod_line_settings *settings);
  * @return 0 on success, -1 on failure.
  */
 int gpiod_line_settings_set_edge_detection(struct gpiod_line_settings *settings,
-					   int edge);
+					   enum gpiod_line_edge edge);
 
 /**
  * @brief Get edge detection.
  * @param settings Line settings object.
  * @return Current edge detection setting.
  */
-int
+enum gpiod_line_edge
 gpiod_line_settings_get_edge_detection(struct gpiod_line_settings *settings);
 
 /**
@@ -608,14 +617,15 @@ gpiod_line_settings_get_edge_detection(struct gpiod_line_settings *settings);
  * @return 0 on success, -1 on failure.
  */
 int gpiod_line_settings_set_bias(struct gpiod_line_settings *settings,
-				 int bias);
+				 enum gpiod_line_bias bias);
 
 /**
  * @brief Get bias.
  * @param settings Line settings object.
  * @return Current bias setting.
  */
-int gpiod_line_settings_get_bias(struct gpiod_line_settings *settings);
+enum gpiod_line_bias
+gpiod_line_settings_get_bias(struct gpiod_line_settings *settings);
 
 /**
  * @brief Set drive.
@@ -624,14 +634,15 @@ int gpiod_line_settings_get_bias(struct gpiod_line_settings *settings);
  * @return 0 on success, -1 on failure.
  */
 int gpiod_line_settings_set_drive(struct gpiod_line_settings *settings,
-				  int drive);
+				  enum gpiod_line_drive drive);
 
 /**
  * @brief Get drive.
  * @param settings Line settings object.
  * @return Current drive setting.
  */
-int gpiod_line_settings_get_drive(struct gpiod_line_settings *settings);
+enum gpiod_line_drive
+gpiod_line_settings_get_drive(struct gpiod_line_settings *settings);
 
 /**
  * @brief Set active-low setting.
@@ -673,14 +684,15 @@ gpiod_line_settings_get_debounce_period_us(
  * @return 0 on success, -1 on failure.
  */
 int gpiod_line_settings_set_event_clock(struct gpiod_line_settings *settings,
-					int event_clock);
+				enum gpiod_line_event_clock event_clock);
 
 /**
  * @brief Get event clock setting.
  * @param settings Line settings object.
  * @return Current event clock setting.
  */
-int gpiod_line_settings_get_event_clock(struct gpiod_line_settings *settings);
+enum gpiod_line_event_clock
+gpiod_line_settings_get_event_clock(struct gpiod_line_settings *settings);
 
 /**
  * @brief Set the output value.
@@ -689,14 +701,15 @@ int gpiod_line_settings_get_event_clock(struct gpiod_line_settings *settings);
  * @return 0 on success, -1 on failure.
  */
 int gpiod_line_settings_set_output_value(struct gpiod_line_settings *settings,
-					 int value);
+					 enum gpiod_line_value value);
 
 /**
  * @brief Get the output value.
  * @param settings Line settings object.
  * @return Current output value.
  */
-int gpiod_line_settings_get_output_value(struct gpiod_line_settings *settings);
+enum gpiod_line_value
+gpiod_line_settings_get_output_value(struct gpiod_line_settings *settings);
 
 /*
  * @}
@@ -884,8 +897,9 @@ void gpiod_line_request_get_offsets(struct gpiod_line_request *request,
  * @param offset The offset of the line of which the value should be read.
  * @return Returns 1 or 0 on success and -1 on error.
  */
-int gpiod_line_request_get_value(struct gpiod_line_request *request,
-				 unsigned int offset);
+enum gpiod_line_value
+gpiod_line_request_get_value(struct gpiod_line_request *request,
+			     unsigned int offset);
 
 /**
  * @brief Get the values of a subset of requested lines.
@@ -901,7 +915,7 @@ int gpiod_line_request_get_value(struct gpiod_line_request *request,
 int gpiod_line_request_get_values_subset(struct gpiod_line_request *request,
 					 size_t num_values,
 					 const unsigned int *offsets,
-					 int *values);
+					 enum gpiod_line_value *values);
 
 /**
  * @brief Get the values of all requested lines.
@@ -915,7 +929,7 @@ int gpiod_line_request_get_values_subset(struct gpiod_line_request *request,
  * @return 0 on success, -1 on failure.
  */
 int gpiod_line_request_get_values(struct gpiod_line_request *request,
-				  int *values);
+				  enum gpiod_line_value *values);
 
 /**
  * @brief Set the value of a single requested line.
@@ -924,7 +938,8 @@ int gpiod_line_request_get_values(struct gpiod_line_request *request,
  * @param value Value to set.
  */
 int gpiod_line_request_set_value(struct gpiod_line_request *request,
-				 unsigned int offset, int value);
+				 unsigned int offset,
+				 enum gpiod_line_value value);
 
 /**
  * @brief Set the values of a subset of requested lines.
@@ -941,7 +956,7 @@ int gpiod_line_request_set_value(struct gpiod_line_request *request,
 int gpiod_line_request_set_values_subset(struct gpiod_line_request *request,
 					 size_t num_values,
 					 const unsigned int *offsets,
-					 const int *values);
+					 const enum gpiod_line_value *values);
 
 /**
  * @brief Set the values of all lines associated with a request.
@@ -954,7 +969,7 @@ int gpiod_line_request_set_values_subset(struct gpiod_line_request *request,
  *		 ::gpiod_line_request_get_offsets.
  */
 int gpiod_line_request_set_values(struct gpiod_line_request *request,
-				  const int *values);
+				  const enum gpiod_line_value *values);
 
 /**
  * @brief Update the configuration of lines associated with a line request.
@@ -1032,7 +1047,7 @@ int gpiod_line_request_read_edge_event(struct gpiod_line_request *request,
 /**
  * @brief Event types.
  */
-enum {
+enum gpiod_edge_event_type {
 	GPIOD_EDGE_EVENT_RISING_EDGE = 1,
 	/**< Rising edge event. */
 	GPIOD_EDGE_EVENT_FALLING_EDGE
@@ -1059,7 +1074,8 @@ struct gpiod_edge_event *gpiod_edge_event_copy(struct gpiod_edge_event *event);
  * @return The event type (::GPIOD_EDGE_EVENT_RISING_EDGE or
  *	   ::GPIOD_EDGE_EVENT_FALLING_EDGE).
  */
-int gpiod_edge_event_get_event_type(struct gpiod_edge_event *event);
+enum gpiod_edge_event_type
+gpiod_edge_event_get_event_type(struct gpiod_edge_event *event);
 
 /**
  * @brief Get the timestamp of the event.
diff --git a/lib/edge-event.c b/lib/edge-event.c
index 48a0f95..ad8a7d1 100644
--- a/lib/edge-event.c
+++ b/lib/edge-event.c
@@ -13,7 +13,7 @@
 #define EVENT_BUFFER_MAX_CAPACITY (GPIO_V2_LINES_MAX * 16)
 
 struct gpiod_edge_event {
-	int event_type;
+	enum gpiod_edge_event_type event_type;
 	uint64_t timestamp;
 	unsigned int line_offset;
 	unsigned long global_seqno;
@@ -49,7 +49,8 @@ gpiod_edge_event_copy(struct gpiod_edge_event *event)
 	return copy;
 }
 
-GPIOD_API int gpiod_edge_event_get_event_type(struct gpiod_edge_event *event)
+GPIOD_API enum gpiod_edge_event_type
+gpiod_edge_event_get_event_type(struct gpiod_edge_event *event)
 {
 	return event->event_type;
 }
diff --git a/lib/info-event.c b/lib/info-event.c
index 73a3d6d..c0d7307 100644
--- a/lib/info-event.c
+++ b/lib/info-event.c
@@ -9,7 +9,7 @@
 #include "internal.h"
 
 struct gpiod_info_event {
-	int event_type;
+	enum gpiod_info_event_type event_type;
 	uint64_t timestamp;
 	struct gpiod_line_info *info;
 };
@@ -61,7 +61,8 @@ GPIOD_API void gpiod_info_event_free(struct gpiod_info_event *event)
 	free(event);
 }
 
-GPIOD_API int gpiod_info_event_get_event_type(struct gpiod_info_event *event)
+GPIOD_API enum gpiod_info_event_type
+gpiod_info_event_get_event_type(struct gpiod_info_event *event)
 {
 	return event->event_type;
 }
diff --git a/lib/line-config.c b/lib/line-config.c
index 5ee7390..48ea618 100644
--- a/lib/line-config.c
+++ b/lib/line-config.c
@@ -194,7 +194,7 @@ static void set_kernel_output_values(uint64_t *mask, uint64_t *vals,
 				     struct gpiod_line_config *config)
 {
 	struct per_line_config *per_line;
-	int value;
+	enum gpiod_line_value value;
 	size_t i;
 
 	gpiod_line_mask_zero(mask);
@@ -292,6 +292,8 @@ static uint64_t make_kernel_flags(struct gpiod_line_settings *settings)
 	case GPIOD_LINE_DIRECTION_OUTPUT:
 		flags |= GPIO_V2_LINE_FLAG_OUTPUT;
 		break;
+	default:
+		break;
 	}
 
 	switch (gpiod_line_settings_get_edge_detection(settings)) {
@@ -311,6 +313,8 @@ static uint64_t make_kernel_flags(struct gpiod_line_settings *settings)
 			   GPIO_V2_LINE_FLAG_INPUT);
 		flags &= ~GPIOD_LINE_DIRECTION_OUTPUT;
 		break;
+	default:
+		break;
 	}
 
 	switch (gpiod_line_settings_get_drive(settings)) {
@@ -320,6 +324,8 @@ static uint64_t make_kernel_flags(struct gpiod_line_settings *settings)
 	case GPIOD_LINE_DRIVE_OPEN_SOURCE:
 		flags |= GPIO_V2_LINE_FLAG_OPEN_SOURCE;
 		break;
+	default:
+		break;
 	}
 
 	switch (gpiod_line_settings_get_bias(settings)) {
@@ -332,6 +338,8 @@ static uint64_t make_kernel_flags(struct gpiod_line_settings *settings)
 	case GPIOD_LINE_BIAS_PULL_DOWN:
 		flags |= GPIO_V2_LINE_FLAG_BIAS_PULL_DOWN;
 		break;
+	default:
+		break;
 	}
 
 	if (gpiod_line_settings_get_active_low(settings))
@@ -344,6 +352,8 @@ static uint64_t make_kernel_flags(struct gpiod_line_settings *settings)
 	case GPIOD_LINE_EVENT_CLOCK_HTE:
 		flags |= GPIO_V2_LINE_FLAG_EVENT_CLOCK_HTE;
 		break;
+	default:
+		break;
 	}
 
 	return flags;
diff --git a/lib/line-info.c b/lib/line-info.c
index 9809c43..75d886f 100644
--- a/lib/line-info.c
+++ b/lib/line-info.c
@@ -12,12 +12,12 @@ struct gpiod_line_info {
 	char name[GPIO_MAX_NAME_SIZE];
 	bool used;
 	char consumer[GPIO_MAX_NAME_SIZE];
-	int direction;
+	enum gpiod_line_direction direction;
 	bool active_low;
-	int bias;
-	int drive;
-	int edge;
-	int event_clock;
+	enum gpiod_line_bias bias;
+	enum gpiod_line_drive drive;
+	enum gpiod_line_edge edge;
+	enum gpiod_line_event_clock event_clock;
 	bool debounced;
 	unsigned long debounce_period_us;
 };
@@ -64,7 +64,8 @@ GPIOD_API const char *gpiod_line_info_get_consumer(struct gpiod_line_info *info)
 	return info->consumer[0] == '\0' ? NULL : info->consumer;
 }
 
-GPIOD_API int gpiod_line_info_get_direction(struct gpiod_line_info *info)
+GPIOD_API enum gpiod_line_direction
+gpiod_line_info_get_direction(struct gpiod_line_info *info)
 {
 	return info->direction;
 }
@@ -74,22 +75,26 @@ GPIOD_API bool gpiod_line_info_is_active_low(struct gpiod_line_info *info)
 	return info->active_low;
 }
 
-GPIOD_API int gpiod_line_info_get_bias(struct gpiod_line_info *info)
+GPIOD_API enum gpiod_line_bias
+gpiod_line_info_get_bias(struct gpiod_line_info *info)
 {
 	return info->bias;
 }
 
-GPIOD_API int gpiod_line_info_get_drive(struct gpiod_line_info *info)
+GPIOD_API enum gpiod_line_drive
+gpiod_line_info_get_drive(struct gpiod_line_info *info)
 {
 	return info->drive;
 }
 
-GPIOD_API int gpiod_line_info_get_edge_detection(struct gpiod_line_info *info)
+GPIOD_API enum gpiod_line_edge
+gpiod_line_info_get_edge_detection(struct gpiod_line_info *info)
 {
 	return info->edge;
 }
 
-GPIOD_API int gpiod_line_info_get_event_clock(struct gpiod_line_info *info)
+GPIOD_API enum gpiod_line_event_clock
+gpiod_line_info_get_event_clock(struct gpiod_line_info *info)
 {
 	return info->event_clock;
 }
diff --git a/lib/line-request.c b/lib/line-request.c
index ee452e7..5936593 100644
--- a/lib/line-request.c
+++ b/lib/line-request.c
@@ -57,15 +57,16 @@ gpiod_line_request_get_offsets(struct gpiod_line_request *request,
 	       sizeof(*offsets) * request->num_lines);
 }
 
-GPIOD_API int gpiod_line_request_get_value(struct gpiod_line_request *request,
-					   unsigned int offset)
+GPIOD_API enum gpiod_line_value
+gpiod_line_request_get_value(struct gpiod_line_request *request,
+			     unsigned int offset)
 {
+	enum gpiod_line_value val;
 	unsigned int ret;
-	int val;
 
 	ret = gpiod_line_request_get_values_subset(request, 1, &offset, &val);
 	if (ret)
-		return -1;
+		return GPIOD_LINE_VALUE_ERROR;
 
 	return val;
 }
@@ -86,7 +87,8 @@ static int offset_to_bit(struct gpiod_line_request *request,
 GPIOD_API int
 gpiod_line_request_get_values_subset(struct gpiod_line_request *request,
 				     size_t num_values,
-				     const unsigned int *offsets, int *values)
+				     const unsigned int *offsets,
+				     enum gpiod_line_value *values)
 {
 	struct gpio_v2_line_values uapi_values;
 	uint64_t mask = 0, bits = 0;
@@ -123,14 +125,15 @@ gpiod_line_request_get_values_subset(struct gpiod_line_request *request,
 }
 
 GPIOD_API int gpiod_line_request_get_values(struct gpiod_line_request *request,
-					    int *values)
+					    enum gpiod_line_value *values)
 {
 	return gpiod_line_request_get_values_subset(request, request->num_lines,
 						    request->offsets, values);
 }
 
 GPIOD_API int gpiod_line_request_set_value(struct gpiod_line_request *request,
-					   unsigned int offset, int value)
+					   unsigned int offset,
+					   enum gpiod_line_value value)
 {
 	return gpiod_line_request_set_values_subset(request, 1,
 						    &offset, &value);
@@ -140,7 +143,7 @@ GPIOD_API int
 gpiod_line_request_set_values_subset(struct gpiod_line_request *request,
 				     size_t num_values,
 				     const unsigned int *offsets,
-				     const int *values)
+				     const enum gpiod_line_value *values)
 {
 	struct gpio_v2_line_values uapi_values;
 	uint64_t mask = 0, bits = 0;
@@ -166,7 +169,7 @@ gpiod_line_request_set_values_subset(struct gpiod_line_request *request,
 }
 
 GPIOD_API int gpiod_line_request_set_values(struct gpiod_line_request *request,
-					    const int *values)
+					    const enum gpiod_line_value *values)
 {
 	return gpiod_line_request_set_values_subset(request, request->num_lines,
 						    request->offsets, values);
diff --git a/lib/line-settings.c b/lib/line-settings.c
index f97a90e..f245b20 100644
--- a/lib/line-settings.c
+++ b/lib/line-settings.c
@@ -9,14 +9,14 @@
 #include "internal.h"
 
 struct gpiod_line_settings {
-	int direction;
-	int edge_detection;
-	int drive;
-	int bias;
+	enum gpiod_line_direction direction;
+	enum gpiod_line_edge edge_detection;
+	enum gpiod_line_drive drive;
+	enum gpiod_line_bias bias;
 	bool active_low;
-	int event_clock;
+	enum gpiod_line_event_clock event_clock;
 	long debounce_period_us;
-	int output_value;
+	enum gpiod_line_value output_value;
 };
 
 GPIOD_API struct gpiod_line_settings *gpiod_line_settings_new(void)
@@ -65,7 +65,7 @@ gpiod_line_settings_copy(struct gpiod_line_settings *settings)
 
 GPIOD_API int
 gpiod_line_settings_set_direction(struct gpiod_line_settings *settings,
-				  int direction)
+				  enum gpiod_line_direction direction)
 {
 	switch (direction) {
 	case GPIOD_LINE_DIRECTION_INPUT:
@@ -82,7 +82,7 @@ gpiod_line_settings_set_direction(struct gpiod_line_settings *settings,
 	return 0;
 }
 
-GPIOD_API int
+GPIOD_API enum gpiod_line_direction
 gpiod_line_settings_get_direction(struct gpiod_line_settings *settings)
 {
 	return settings->direction;
@@ -90,7 +90,7 @@ gpiod_line_settings_get_direction(struct gpiod_line_settings *settings)
 
 GPIOD_API int
 gpiod_line_settings_set_edge_detection(struct gpiod_line_settings *settings,
-				       int edge)
+				       enum gpiod_line_edge edge)
 {
 	switch (edge) {
 	case GPIOD_LINE_EDGE_NONE:
@@ -108,14 +108,15 @@ gpiod_line_settings_set_edge_detection(struct gpiod_line_settings *settings,
 	return 0;
 }
 
-GPIOD_API int
+GPIOD_API enum gpiod_line_edge
 gpiod_line_settings_get_edge_detection(struct gpiod_line_settings *settings)
 {
 	return settings->edge_detection;
 }
 
 GPIOD_API int
-gpiod_line_settings_set_bias(struct gpiod_line_settings *settings, int bias)
+gpiod_line_settings_set_bias(struct gpiod_line_settings *settings,
+			     enum gpiod_line_bias bias)
 {
 	switch (bias) {
 	case GPIOD_LINE_BIAS_AS_IS:
@@ -133,13 +134,15 @@ gpiod_line_settings_set_bias(struct gpiod_line_settings *settings, int bias)
 	return 0;
 }
 
-GPIOD_API int gpiod_line_settings_get_bias(struct gpiod_line_settings *settings)
+GPIOD_API enum gpiod_line_bias
+gpiod_line_settings_get_bias(struct gpiod_line_settings *settings)
 {
 	return settings->bias;
 }
 
 GPIOD_API int
-gpiod_line_settings_set_drive(struct gpiod_line_settings *settings, int drive)
+gpiod_line_settings_set_drive(struct gpiod_line_settings *settings,
+			      enum gpiod_line_drive drive)
 {
 	switch (drive) {
 	case GPIOD_LINE_DRIVE_PUSH_PULL:
@@ -156,7 +159,7 @@ gpiod_line_settings_set_drive(struct gpiod_line_settings *settings, int drive)
 	return 0;
 }
 
-GPIOD_API int
+GPIOD_API enum gpiod_line_drive
 gpiod_line_settings_get_drive(struct gpiod_line_settings *settings)
 {
 	return settings->drive;
@@ -190,7 +193,7 @@ gpiod_line_settings_get_debounce_period_us(struct gpiod_line_settings *settings)
 
 GPIOD_API int
 gpiod_line_settings_set_event_clock(struct gpiod_line_settings *settings,
-				    int event_clock)
+				    enum gpiod_line_event_clock event_clock)
 {
 	switch (event_clock) {
 	case GPIOD_LINE_EVENT_CLOCK_MONOTONIC:
@@ -207,7 +210,7 @@ gpiod_line_settings_set_event_clock(struct gpiod_line_settings *settings,
 	return 0;
 }
 
-GPIOD_API int
+GPIOD_API enum gpiod_line_event_clock
 gpiod_line_settings_get_event_clock(struct gpiod_line_settings *settings)
 {
 	return settings->event_clock;
@@ -215,7 +218,7 @@ gpiod_line_settings_get_event_clock(struct gpiod_line_settings *settings)
 
 GPIOD_API int
 gpiod_line_settings_set_output_value(struct gpiod_line_settings *settings,
-				     int value)
+				     enum gpiod_line_value value)
 {
 	switch (value) {
 	case GPIOD_LINE_VALUE_INACTIVE:
@@ -231,7 +234,7 @@ gpiod_line_settings_set_output_value(struct gpiod_line_settings *settings,
 	return 0;
 }
 
-GPIOD_API int
+GPIOD_API enum gpiod_line_value
 gpiod_line_settings_get_output_value(struct gpiod_line_settings *settings)
 {
 	return settings->output_value;
diff --git a/tests/gpiosim/gpiosim.c b/tests/gpiosim/gpiosim.c
index ea638cd..5a8ec88 100644
--- a/tests/gpiosim/gpiosim.c
+++ b/tests/gpiosim/gpiosim.c
@@ -1007,8 +1007,8 @@ GPIOSIM_API int gpiosim_bank_set_line_name(struct gpiosim_bank *bank,
 }
 
 GPIOSIM_API int gpiosim_bank_hog_line(struct gpiosim_bank *bank,
-				      unsigned int offset,
-				      const char *name, int direction)
+				      unsigned int offset, const char *name,
+				      enum gpiosim_direction direction)
 {
 	char buf[64], *dir;
 	int ret, fd;
@@ -1081,15 +1081,16 @@ static int sysfs_read_bank_attr(struct gpiosim_bank *bank, unsigned int offset,
 	return open_read_close(bank->sysfs_dir_fd, where, buf, bufsize);
 }
 
-GPIOSIM_API int gpiosim_bank_get_value(struct gpiosim_bank *bank,
-				       unsigned int offset)
+GPIOSIM_API enum
+gpiosim_value gpiosim_bank_get_value(struct gpiosim_bank *bank,
+				     unsigned int offset)
 {
 	char what[3];
 	int ret;
 
 	ret = sysfs_read_bank_attr(bank, offset, "value", what, sizeof(what));
 	if (ret)
-		return ret;
+		return GPIOSIM_VALUE_ERROR;
 
 	if (what[0] == '0')
 		return GPIOSIM_VALUE_INACTIVE;
@@ -1097,18 +1098,18 @@ GPIOSIM_API int gpiosim_bank_get_value(struct gpiosim_bank *bank,
 		return GPIOSIM_VALUE_ACTIVE;
 
 	errno = EIO;
-	return -1;
+	return GPIOSIM_VALUE_ERROR;
 }
 
-GPIOSIM_API int gpiosim_bank_get_pull(struct gpiosim_bank *bank,
-				      unsigned int offset)
+GPIOSIM_API enum gpiosim_pull
+gpiosim_bank_get_pull(struct gpiosim_bank *bank, unsigned int offset)
 {
 	char what[16];
 	int ret;
 
 	ret = sysfs_read_bank_attr(bank, offset, "pull", what, sizeof(what));
 	if (ret)
-		return ret;
+		return GPIOSIM_PULL_ERROR;
 
 	if (strcmp(what, "pull-down") == 0)
 		return GPIOSIM_PULL_DOWN;
@@ -1116,11 +1117,12 @@ GPIOSIM_API int gpiosim_bank_get_pull(struct gpiosim_bank *bank,
 		return GPIOSIM_PULL_UP;
 
 	errno = EIO;
-	return -1;
+	return GPIOSIM_PULL_ERROR;
 }
 
-GPIOSIM_API int gpiosim_bank_set_pull(struct gpiosim_bank *bank,
-				      unsigned int offset, int pull)
+GPIOSIM_API int
+gpiosim_bank_set_pull(struct gpiosim_bank *bank,
+		      unsigned int offset, enum gpiosim_pull pull)
 {
 	struct gpiosim_dev *dev = bank->dev;
 	char where[32], what[16];
diff --git a/tests/gpiosim/gpiosim.h b/tests/gpiosim/gpiosim.h
index 8013595..80d437e 100644
--- a/tests/gpiosim/gpiosim.h
+++ b/tests/gpiosim/gpiosim.h
@@ -15,17 +15,19 @@ struct gpiosim_ctx;
 struct gpiosim_dev;
 struct gpiosim_bank;
 
-enum {
+enum gpiosim_value {
+	GPIOSIM_VALUE_ERROR = -1,
 	GPIOSIM_VALUE_INACTIVE = 0,
 	GPIOSIM_VALUE_ACTIVE = 1,
 };
 
-enum {
+enum gpiosim_pull {
+	GPIOSIM_PULL_ERROR = -1,
 	GPIOSIM_PULL_DOWN = 1,
 	GPIOSIM_PULL_UP,
 };
 
-enum {
+enum gpiosim_direction {
 	GPIOSIM_HOG_DIR_INPUT = 1,
 	GPIOSIM_HOG_DIR_OUTPUT_HIGH,
 	GPIOSIM_HOG_DIR_OUTPUT_LOW,
@@ -59,13 +61,15 @@ int gpiosim_bank_set_num_lines(struct gpiosim_bank *bank, size_t num_lines);
 int gpiosim_bank_set_line_name(struct gpiosim_bank *bank,
 			       unsigned int offset, const char *name);
 int gpiosim_bank_hog_line(struct gpiosim_bank *bank, unsigned int offset,
-			  const char *name, int direction);
+			  const char *name, enum gpiosim_direction direction);
 int gpiosim_bank_clear_hog(struct gpiosim_bank *bank, unsigned int offset);
 
-int gpiosim_bank_get_value(struct gpiosim_bank *bank, unsigned int offset);
-int gpiosim_bank_get_pull(struct gpiosim_bank *bank, unsigned int offset);
+enum gpiosim_value
+gpiosim_bank_get_value(struct gpiosim_bank *bank, unsigned int offset);
+enum gpiosim_pull
+gpiosim_bank_get_pull(struct gpiosim_bank *bank, unsigned int offset);
 int gpiosim_bank_set_pull(struct gpiosim_bank *bank,
-			  unsigned int offset, int pull);
+			  unsigned int offset, enum gpiosim_pull pull);
 
 #ifdef __cplusplus
 } /* extern "C" */
diff --git a/tests/tests-line-request.c b/tests/tests-line-request.c
index 92e3028..6cf85ab 100644
--- a/tests/tests-line-request.c
+++ b/tests/tests-line-request.c
@@ -173,7 +173,8 @@ GPIOD_TEST_CASE(read_all_values)
 	g_autoptr(struct_gpiod_line_settings) settings = NULL;
 	g_autoptr(struct_gpiod_line_config) line_cfg = NULL;
 	g_autoptr(struct_gpiod_line_request) request = NULL;
-	gint ret, values[5];
+	enum gpiod_line_value values[5];
+	gint ret;
 	guint i;
 
 	chip = gpiod_test_open_chip_or_fail(g_gpiosim_chip_get_dev_path(sim));
@@ -232,11 +233,13 @@ GPIOD_TEST_CASE(request_multiple_values_but_read_one)
 GPIOD_TEST_CASE(set_all_values)
 {
 	static const guint offsets[] = { 0, 2, 4, 5, 6 };
-	static const gint values[] = { GPIOD_LINE_VALUE_ACTIVE,
-				       GPIOD_LINE_VALUE_INACTIVE,
-				       GPIOD_LINE_VALUE_ACTIVE,
-				       GPIOD_LINE_VALUE_ACTIVE,
-				       GPIOD_LINE_VALUE_ACTIVE };
+	static const enum gpiod_line_value values[] = {
+		GPIOD_LINE_VALUE_ACTIVE,
+		GPIOD_LINE_VALUE_INACTIVE,
+		GPIOD_LINE_VALUE_ACTIVE,
+		GPIOD_LINE_VALUE_ACTIVE,
+		GPIOD_LINE_VALUE_ACTIVE
+	};
 
 	g_autoptr(GPIOSimChip) sim = g_gpiosim_chip_new("num-lines", 8, NULL);
 	g_autoptr(struct_gpiod_chip) chip = NULL;
@@ -270,9 +273,11 @@ GPIOD_TEST_CASE(set_values_subset_of_lines)
 {
 	static const guint offsets[] = { 0, 1, 2, 3 };
 	static const guint offsets_to_set[] = { 0, 1, 3 };
-	static const gint values[] = { GPIOD_LINE_VALUE_ACTIVE,
-				       GPIOD_LINE_VALUE_INACTIVE,
-				       GPIOD_LINE_VALUE_ACTIVE };
+	static const enum gpiod_line_value values[] = {
+		GPIOD_LINE_VALUE_ACTIVE,
+		GPIOD_LINE_VALUE_INACTIVE,
+		GPIOD_LINE_VALUE_ACTIVE
+	};
 
 	g_autoptr(GPIOSimChip) sim = g_gpiosim_chip_new("num-lines", 4, NULL);
 	g_autoptr(struct_gpiod_chip) chip = NULL;
@@ -508,8 +513,8 @@ GPIOD_TEST_CASE(request_lines_with_unordered_offsets)
 	g_autoptr(struct_gpiod_line_settings) settings = NULL;
 	g_autoptr(struct_gpiod_line_config) line_cfg = NULL;
 	g_autoptr(struct_gpiod_line_request) request = NULL;
+	enum gpiod_line_value values[4];
 	guint set_offsets[4];
-	gint values[4];
 
 	chip = gpiod_test_open_chip_or_fail(g_gpiosim_chip_get_dev_path(sim));
 	settings = gpiod_test_create_line_settings_or_fail();
diff --git a/tools/gpioget.c b/tools/gpioget.c
index 31a3102..08c17e6 100644
--- a/tools/gpioget.c
+++ b/tools/gpioget.c
@@ -17,8 +17,8 @@ struct config {
 	bool numeric;
 	bool strict;
 	bool unquoted;
-	int bias;
-	int direction;
+	enum gpiod_line_bias bias;
+	enum gpiod_line_direction direction;
 	unsigned int hold_period_us;
 	const char *chip_id;
 	const char *consumer;
@@ -137,11 +137,12 @@ int main(int argc, char **argv)
 	struct gpiod_request_config *req_cfg;
 	struct gpiod_line_request *request;
 	struct gpiod_line_config *line_cfg;
-	int i, num_lines, ret, *values;
 	struct line_resolver *resolver;
+	enum gpiod_line_value *values;
 	struct resolved_line *line;
 	struct gpiod_chip *chip;
 	unsigned int *offsets;
+	int i, num_lines, ret;
 	struct config cfg;
 	const char *fmt;
 
diff --git a/tools/gpiomon.c b/tools/gpiomon.c
index 45e4471..dc157df 100644
--- a/tools/gpiomon.c
+++ b/tools/gpiomon.c
@@ -21,14 +21,14 @@ struct config {
 	bool quiet;
 	bool strict;
 	bool unquoted;
-	int bias;
-	int edges;
+	enum gpiod_line_bias bias;
+	enum gpiod_line_edge edges;
 	int events_wanted;
 	unsigned int debounce_period_us;
 	const char *chip_id;
 	const char *consumer;
 	const char *fmt;
-	int event_clock;
+	enum gpiod_line_event_clock event_clock;
 	int timestamp_fmt;
 };
 
diff --git a/tools/gpioset.c b/tools/gpioset.c
index c49d229..a32c894 100644
--- a/tools/gpioset.c
+++ b/tools/gpioset.c
@@ -25,8 +25,8 @@ struct config {
 	bool interactive;
 	bool strict;
 	bool unquoted;
-	int bias;
-	int drive;
+	enum gpiod_line_bias bias;
+	enum gpiod_line_drive drive;
 	int toggles;
 	unsigned int *toggle_periods;
 	unsigned int hold_period_us;
@@ -228,25 +228,26 @@ static int parse_config(int argc, char **argv, struct config *cfg)
 	return optind;
 }
 
-static int parse_value(const char *option)
+static enum gpiod_line_value parse_value(const char *option)
 {
 	if (strcmp(option, "0") == 0)
-		return 0;
+		return GPIOD_LINE_VALUE_INACTIVE;
 	if (strcmp(option, "1") == 0)
-		return 1;
+		return GPIOD_LINE_VALUE_ACTIVE;
 	if (strcmp(option, "inactive") == 0)
-		return 0;
+		return GPIOD_LINE_VALUE_INACTIVE;
 	if (strcmp(option, "active") == 0)
-		return 1;
+		return GPIOD_LINE_VALUE_ACTIVE;
 	if (strcmp(option, "off") == 0)
-		return 0;
+		return GPIOD_LINE_VALUE_INACTIVE;
 	if (strcmp(option, "on") == 0)
-		return 1;
+		return GPIOD_LINE_VALUE_ACTIVE;
 	if (strcmp(option, "false") == 0)
-		return 0;
+		return GPIOD_LINE_VALUE_INACTIVE;
 	if (strcmp(option, "true") == 0)
-		return 1;
-	return -1;
+		return GPIOD_LINE_VALUE_ACTIVE;
+
+	return GPIOD_LINE_VALUE_ERROR;
 }
 
 /*
@@ -259,7 +260,7 @@ static int parse_value(const char *option)
  * If line id is quoted then it is returned unquoted.
  */
 static bool parse_line_values(int num_lines, char **lvs, char **lines,
-			      int *values, bool interactive)
+			      enum gpiod_line_value *values, bool interactive)
 {
 	char *value;
 	char *line;
@@ -293,7 +294,7 @@ static bool parse_line_values(int num_lines, char **lvs, char **lines,
 		value++;
 		values[i] = parse_value(value);
 
-		if (values[i] < 0) {
+		if (values[i] == GPIOD_LINE_VALUE_ERROR) {
 			if (interactive)
 				printf("invalid line value: '%s'\n", value);
 			else
@@ -312,7 +313,7 @@ static bool parse_line_values(int num_lines, char **lvs, char **lines,
  * Parse line id and values from lvs into lines and values, or die trying.
  */
 static void parse_line_values_or_die(int num_lines, char **lvs, char **lines,
-				     int *values)
+				     enum gpiod_line_value *values)
 {
 	if (!parse_line_values(num_lines, lvs, lines, values, false))
 		exit(EXIT_FAILURE);
@@ -352,7 +353,7 @@ static void wait_fd(int fd)
  */
 static void apply_values(struct gpiod_line_request **requests,
 			 struct line_resolver *resolver,
-			 unsigned int *offsets, int *values)
+			 unsigned int *offsets, enum gpiod_line_value *values)
 {
 	int i;
 
@@ -381,7 +382,7 @@ static void toggle_all_lines(struct line_resolver *resolver)
 static void toggle_sequence(int toggles, unsigned int *toggle_periods,
 			 struct gpiod_line_request **requests,
 			 struct line_resolver *resolver,
-			 unsigned int *offsets, int *values)
+			 unsigned int *offsets, enum gpiod_line_value *values)
 {
 	int i = 0;
 
@@ -436,7 +437,8 @@ static bool parse_line_ids(int num_lines, char **words, char **lines)
  * the remaining parameters.
  */
 static void set_line_values_subset(struct line_resolver *resolver,
-				   int num_lines, char **lines, int *values)
+				   int num_lines, char **lines,
+				   enum gpiod_line_value *values)
 {
 	int l, i;
 
@@ -739,8 +741,8 @@ static char **tab_completion(const char *text, int start, int end)
 
 static void interact(struct gpiod_line_request **requests,
 		    struct line_resolver *resolver,
-		    char **lines, unsigned int *offsets, int *values,
-		    bool unquoted)
+		    char **lines, unsigned int *offsets,
+		    enum gpiod_line_value *values, bool unquoted)
 {
 	int num_words, num_lines, max_words, period_us, i;
 	char *line, **words, *line_buf;
@@ -869,8 +871,9 @@ int main(int argc, char **argv)
 	struct gpiod_request_config *req_cfg;
 	struct gpiod_line_request **requests;
 	struct gpiod_line_config *line_cfg;
-	int i, j, num_lines, ret, *values;
 	struct line_resolver *resolver;
+	enum gpiod_line_value *values;
+	int i, j, num_lines, ret;
 	struct gpiod_chip *chip;
 	unsigned int *offsets;
 	struct config cfg;
diff --git a/tools/tools-common.c b/tools/tools-common.c
index 69af77a..6dbcf57 100644
--- a/tools/tools-common.c
+++ b/tools/tools-common.c
@@ -336,7 +336,7 @@ static void print_consumer(struct gpiod_line_info *info, bool unquoted)
 
 void print_line_attributes(struct gpiod_line_info *info, bool unquoted_strings)
 {
-	int direction;
+	enum gpiod_line_direction direction;
 
 	direction = gpiod_line_info_get_direction(info);
 
@@ -714,7 +714,7 @@ void free_line_resolver(struct line_resolver *resolver)
 
 int get_line_offsets_and_values(struct line_resolver *resolver,
 				int chip_num, unsigned int *offsets,
-				int *values)
+				enum gpiod_line_value *values)
 {
 	struct resolved_line *line;
 	int i, num_lines = 0;
@@ -754,7 +754,8 @@ const char *get_line_name(struct line_resolver *resolver,
 	return 0;
 }
 
-void set_line_values(struct line_resolver *resolver, int chip_num, int *values)
+void set_line_values(struct line_resolver *resolver, int chip_num,
+		     enum gpiod_line_value *values)
 {
 	int i, j;
 
diff --git a/tools/tools-common.h b/tools/tools-common.h
index aa697de..d467197 100644
--- a/tools/tools-common.h
+++ b/tools/tools-common.h
@@ -110,11 +110,13 @@ bool resolve_lines_by_offset(struct line_resolver *resolver,
 bool resolve_done(struct line_resolver *resolver);
 void validate_resolution(struct line_resolver *resolver, const char *chip_id);
 void free_line_resolver(struct line_resolver *resolver);
-int get_line_offsets_and_values(struct line_resolver *resolver,
-		int chip_num, unsigned int *offsets, int *values);
+int get_line_offsets_and_values(struct line_resolver *resolver, int chip_num,
+				unsigned int *offsets,
+				enum gpiod_line_value *values);
 const char *get_chip_name(struct line_resolver *resolver, int chip_num);
 const char *get_line_name(struct line_resolver *resolver, int chip_num,
 			  unsigned int offset);
-void set_line_values(struct line_resolver *resolver, int chip_num, int *values);
+void set_line_values(struct line_resolver *resolver, int chip_num,
+		     enum gpiod_line_value *values);
 
 #endif /* __GPIOD_TOOLS_COMMON_H__ */
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [libgpiod][PATCH 02/11] treewide: apply formatting changes with clang-format
  2022-11-30 12:42 [libgpiod][PATCH 00/11] treewide: an assortment of tweaks and improvements Bartosz Golaszewski
  2022-11-30 12:42 ` [libgpiod][PATCH 01/11] treewide: use C enum types explicitly Bartosz Golaszewski
@ 2022-11-30 12:42 ` Bartosz Golaszewski
  2022-11-30 13:59   ` Andy Shevchenko
  2022-11-30 12:42 ` [libgpiod][PATCH 03/11] treewide: use plural 'events' in read_edge_event() functions Bartosz Golaszewski
                   ` (9 subsequent siblings)
  11 siblings, 1 reply; 28+ messages in thread
From: Bartosz Golaszewski @ 2022-11-30 12:42 UTC (permalink / raw)
  To: Kent Gibson, Linus Walleij, Andy Shevchenko, Viresh Kumar
  Cc: linux-gpio, Bartosz Golaszewski

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

Use linux kernel's .clang-format file to automatically improve the coding
style of libgpiod's C code base. We don't import the file into the
repository as it's not perfect and certain converted fragments were
rolled back because they looked better before the conversion.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 lib/edge-event.c             |  8 +++---
 lib/internal.c               |  4 +--
 lib/internal.h               |  3 ++-
 lib/line-config.c            | 39 +++++++++++++--------------
 lib/line-settings.c          |  5 ++--
 tests/gpiod-test-sim.c       | 41 +++++++++++++++++-----------
 tests/gpiosim/gpiosim.c      | 18 +++++--------
 tests/gpiosim/gpiosim.h      |  6 ++---
 tests/tests-chip-info.c      |  1 -
 tests/tests-edge-event.c     | 52 +++++++++++++++---------------------
 tests/tests-info-event.c     |  2 +-
 tests/tests-line-config.c    |  2 +-
 tests/tests-line-info.c      | 23 ++++++++--------
 tests/tests-line-request.c   | 33 ++++++++++++-----------
 tests/tests-line-settings.c  | 16 +++++------
 tests/tests-request-config.c | 12 ++++-----
 tools/gpiodetect.c           |  3 +--
 tools/gpioinfo.c             | 12 ++++-----
 tools/gpiomon.c              | 11 ++++----
 tools/gpionotify.c           | 10 +++----
 tools/gpioset.c              | 48 +++++++++++++++------------------
 tools/tools-common.c         | 34 +++++++++++------------
 tools/tools-common.h         |  3 ++-
 23 files changed, 182 insertions(+), 204 deletions(-)

diff --git a/lib/edge-event.c b/lib/edge-event.c
index ad8a7d1..fbbe4a8 100644
--- a/lib/edge-event.c
+++ b/lib/edge-event.c
@@ -131,7 +131,7 @@ gpiod_edge_event_buffer_free(struct gpiod_edge_event_buffer *buffer)
 
 GPIOD_API struct gpiod_edge_event *
 gpiod_edge_event_buffer_get_event(struct gpiod_edge_event_buffer *buffer,
-				   unsigned long index)
+				  unsigned long index)
 {
 	if (index >= buffer->num_events) {
 		errno = EINVAL;
@@ -179,9 +179,9 @@ int gpiod_edge_event_buffer_read_fd(int fd,
 		event = &buffer->events[i];
 
 		event->line_offset = curr->offset;
-		event->event_type = curr->id == GPIO_V2_LINE_EVENT_RISING_EDGE
-					? GPIOD_EDGE_EVENT_RISING_EDGE
-					: GPIOD_EDGE_EVENT_FALLING_EDGE;
+		event->event_type = curr->id == GPIO_V2_LINE_EVENT_RISING_EDGE ?
+					    GPIOD_EDGE_EVENT_RISING_EDGE :
+					    GPIOD_EDGE_EVENT_FALLING_EDGE;
 		event->timestamp = curr->timestamp_ns;
 		event->global_seqno = curr->seqno;
 		event->line_seqno = curr->line_seqno;
diff --git a/lib/internal.c b/lib/internal.c
index ef87ecd..5d79ff7 100644
--- a/lib/internal.c
+++ b/lib/internal.c
@@ -29,8 +29,8 @@ bool gpiod_check_gpiochip_device(const char *path, bool set_errno)
 	 * Is it a symbolic link? We have to resolve it before checking
 	 * the rest.
 	 */
-	realname = S_ISLNK(statbuf.st_mode) ? realpath(path, NULL)
-					    : strdup(path);
+	realname = S_ISLNK(statbuf.st_mode) ? realpath(path, NULL) :
+					      strdup(path);
 	if (realname == NULL)
 		goto out;
 
diff --git a/lib/internal.h b/lib/internal.h
index eef70aa..6646647 100644
--- a/lib/internal.h
+++ b/lib/internal.h
@@ -27,7 +27,8 @@ int gpiod_line_config_to_uapi(struct gpiod_line_config *config,
 			      struct gpio_v2_line_request *uapi_cfg);
 struct gpiod_line_request *
 gpiod_line_request_from_uapi(struct gpio_v2_line_request *uapi_req);
-int gpiod_edge_event_buffer_read_fd(int fd, struct gpiod_edge_event_buffer *buffer,
+int gpiod_edge_event_buffer_read_fd(int fd,
+				    struct gpiod_edge_event_buffer *buffer,
 				    size_t max_events);
 struct gpiod_info_event *
 gpiod_info_event_from_uapi(struct gpio_v2_line_info_changed *uapi_evt);
diff --git a/lib/line-config.c b/lib/line-config.c
index 48ea618..436f4e8 100644
--- a/lib/line-config.c
+++ b/lib/line-config.c
@@ -63,8 +63,8 @@ GPIOD_API void gpiod_line_config_reset(struct gpiod_line_config *config)
 	memset(config, 0, sizeof(*config));
 }
 
-static struct per_line_config *
-find_config(struct gpiod_line_config *config, unsigned int offset)
+static struct per_line_config *find_config(struct gpiod_line_config *config,
+					   unsigned int offset)
 {
 	struct per_line_config *per_line;
 	size_t i;
@@ -79,11 +79,9 @@ find_config(struct gpiod_line_config *config, unsigned int offset)
 	return &config->line_configs[config->num_configs++];
 }
 
-GPIOD_API int
-gpiod_line_config_add_line_settings(struct gpiod_line_config *config,
-				    const unsigned int *offsets,
-				    size_t num_offsets,
-				    struct gpiod_line_settings *settings)
+GPIOD_API int gpiod_line_config_add_line_settings(
+	struct gpiod_line_config *config, const unsigned int *offsets,
+	size_t num_offsets, struct gpiod_line_settings *settings)
 {
 	struct per_line_config *per_line;
 	struct settings_node *node;
@@ -139,10 +137,9 @@ gpiod_line_config_get_line_settings(struct gpiod_line_config *config,
 	return NULL;
 }
 
-GPIOD_API int
-gpiod_line_config_get_offsets(struct gpiod_line_config *config,
-			      size_t *num_offsets,
-			      unsigned int **offsets)
+GPIOD_API int gpiod_line_config_get_offsets(struct gpiod_line_config *config,
+					    size_t *num_offsets,
+					    unsigned int **offsets)
 {
 	unsigned int *offs;
 	size_t i;
@@ -182,7 +179,7 @@ static bool has_at_least_one_output_direction(struct gpiod_line_config *config)
 
 	for (i = 0; i < config->num_configs; i++) {
 		if (gpiod_line_settings_get_direction(
-				config->line_configs[i].node->settings) ==
+			    config->line_configs[i].node->settings) ==
 		    GPIOD_LINE_DIRECTION_OUTPUT)
 			return true;
 	}
@@ -204,15 +201,15 @@ static void set_kernel_output_values(uint64_t *mask, uint64_t *vals,
 		per_line = &config->line_configs[i];
 
 		if (gpiod_line_settings_get_direction(
-				per_line->node->settings) !=
+			    per_line->node->settings) !=
 		    GPIOD_LINE_DIRECTION_OUTPUT)
 			continue;
 
 		gpiod_line_mask_set_bit(mask, i);
 		value = gpiod_line_settings_get_output_value(
-						per_line->node->settings);
-		gpiod_line_mask_assign_bit(vals, i,
-				value == GPIOD_LINE_VALUE_ACTIVE ? 1 : 0);
+			per_line->node->settings);
+		gpiod_line_mask_assign_bit(
+			vals, i, value == GPIOD_LINE_VALUE_ACTIVE ? 1 : 0);
 	}
 }
 
@@ -299,18 +296,18 @@ static uint64_t make_kernel_flags(struct gpiod_line_settings *settings)
 	switch (gpiod_line_settings_get_edge_detection(settings)) {
 	case GPIOD_LINE_EDGE_FALLING:
 		flags |= (GPIO_V2_LINE_FLAG_EDGE_FALLING |
-			   GPIO_V2_LINE_FLAG_INPUT);
+			  GPIO_V2_LINE_FLAG_INPUT);
 		flags &= ~GPIOD_LINE_DIRECTION_OUTPUT;
 		break;
 	case GPIOD_LINE_EDGE_RISING:
 		flags |= (GPIO_V2_LINE_FLAG_EDGE_RISING |
-			   GPIO_V2_LINE_FLAG_INPUT);
+			  GPIO_V2_LINE_FLAG_INPUT);
 		flags &= ~GPIOD_LINE_DIRECTION_OUTPUT;
 		break;
 	case GPIOD_LINE_EDGE_BOTH:
 		flags |= (GPIO_V2_LINE_FLAG_EDGE_FALLING |
-			   GPIO_V2_LINE_FLAG_EDGE_RISING |
-			   GPIO_V2_LINE_FLAG_INPUT);
+			  GPIO_V2_LINE_FLAG_EDGE_RISING |
+			  GPIO_V2_LINE_FLAG_INPUT);
 		flags &= ~GPIOD_LINE_DIRECTION_OUTPUT;
 		break;
 	default:
@@ -360,7 +357,7 @@ static uint64_t make_kernel_flags(struct gpiod_line_settings *settings)
 }
 
 static bool settings_equal(struct gpiod_line_settings *left,
-			 struct gpiod_line_settings *right)
+			   struct gpiod_line_settings *right)
 {
 	if (gpiod_line_settings_get_direction(left) !=
 	    gpiod_line_settings_get_direction(right))
diff --git a/lib/line-settings.c b/lib/line-settings.c
index f245b20..dcd0f6b 100644
--- a/lib/line-settings.c
+++ b/lib/line-settings.c
@@ -114,9 +114,8 @@ gpiod_line_settings_get_edge_detection(struct gpiod_line_settings *settings)
 	return settings->edge_detection;
 }
 
-GPIOD_API int
-gpiod_line_settings_set_bias(struct gpiod_line_settings *settings,
-			     enum gpiod_line_bias bias)
+GPIOD_API int gpiod_line_settings_set_bias(struct gpiod_line_settings *settings,
+					   enum gpiod_line_bias bias)
 {
 	switch (bias) {
 	case GPIOD_LINE_BIAS_AS_IS:
diff --git a/tests/gpiod-test-sim.c b/tests/gpiod-test-sim.c
index fe5db38..fe9f822 100644
--- a/tests/gpiod-test-sim.c
+++ b/tests/gpiod-test-sim.c
@@ -193,35 +193,44 @@ static void g_gpiosim_chip_class_init(GPIOSimChipClass *chip_class)
 	class->dispose = g_gpiosim_chip_dispose;
 	class->finalize = g_gpiosim_chip_finalize;
 
-	g_object_class_install_property(class, G_GPIOSIM_CHIP_PROP_DEV_PATH,
+	g_object_class_install_property(
+		class, G_GPIOSIM_CHIP_PROP_DEV_PATH,
 		g_param_spec_string("dev-path", "Device path",
-			"Character device filesystem path.", NULL,
-			G_PARAM_READABLE));
+				    "Character device filesystem path.", NULL,
+				    G_PARAM_READABLE));
 
-	g_object_class_install_property(class, G_GPIOSIM_CHIP_PROP_NAME,
-		g_param_spec_string("name", "Chip name",
+	g_object_class_install_property(
+		class, G_GPIOSIM_CHIP_PROP_NAME,
+		g_param_spec_string(
+			"name", "Chip name",
 			"Name of this chip device as set by the kernel.", NULL,
 			G_PARAM_READABLE));
 
-	g_object_class_install_property(class, G_GPIOSIM_CHIP_PROP_NUM_LINES,
+	g_object_class_install_property(
+		class, G_GPIOSIM_CHIP_PROP_NUM_LINES,
 		g_param_spec_uint("num-lines", "Number of lines",
-			"Number of lines this simulated chip exposes.",
-			1, G_MAXUINT, 1,
-			G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
+				  "Number of lines this simulated chip exposes.",
+				  1, G_MAXUINT, 1,
+				  G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
 
-	g_object_class_install_property(class, G_GPIOSIM_CHIP_PROP_LABEL,
+	g_object_class_install_property(
+		class, G_GPIOSIM_CHIP_PROP_LABEL,
 		g_param_spec_string("label", "Chip label",
-			"Label of this simulated chip.", NULL,
-			G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
+				    "Label of this simulated chip.", NULL,
+				    G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
 
-	g_object_class_install_property(class, G_GPIOSIM_CHIP_PROP_LINE_NAMES,
-		g_param_spec_variant("line-names", "Line names",
+	g_object_class_install_property(
+		class, G_GPIOSIM_CHIP_PROP_LINE_NAMES,
+		g_param_spec_variant(
+			"line-names", "Line names",
 			"List of names of the lines exposed by this chip",
 			(GVariantType *)"a(us)", NULL,
 			G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
 
-	g_object_class_install_property(class, G_GPIOSIM_CHIP_PROP_HOGS,
-		g_param_spec_variant("hogs", "Line hogs",
+	g_object_class_install_property(
+		class, G_GPIOSIM_CHIP_PROP_HOGS,
+		g_param_spec_variant(
+			"hogs", "Line hogs",
 			"List of hogged lines and their directions.",
 			(GVariantType *)"a(usi)", NULL,
 			G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
diff --git a/tests/gpiosim/gpiosim.c b/tests/gpiosim/gpiosim.c
index 5a8ec88..9e6c635 100644
--- a/tests/gpiosim/gpiosim.c
+++ b/tests/gpiosim/gpiosim.c
@@ -213,8 +213,7 @@ static void list_del(struct list_head *entry)
 	((type *)(__mptr - offsetof(type, member))); \
 })
 
-#define list_entry(ptr, type, member) \
-	container_of(ptr, type, member)
+#define list_entry(ptr, type, member) container_of(ptr, type, member)
 
 #define list_first_entry(ptr, type, member) \
 	list_entry((ptr)->next, type, member)
@@ -222,8 +221,7 @@ static void list_del(struct list_head *entry)
 #define list_next_entry(pos, member) \
 	list_entry((pos)->member.next, typeof(*(pos)), member)
 
-#define list_entry_is_head(pos, head, member) \
-	(&pos->member == (head))
+#define list_entry_is_head(pos, head, member) (&pos->member == (head))
 
 #define list_for_each_entry(pos, head, member) \
 	for (pos = list_first_entry(head, typeof(*pos), member); \
@@ -334,9 +332,9 @@ again:
 				goto out_unref_module;
 			}
 
-			ret = kmod_module_probe_insert_module(module,
-						KMOD_PROBE_IGNORE_LOADED,
-						NULL, NULL, NULL, NULL);
+			ret = kmod_module_probe_insert_module(
+				module, KMOD_PROBE_IGNORE_LOADED, NULL, NULL,
+				NULL, NULL);
 			if (ret)
 				goto out_unref_module;
 
@@ -577,8 +575,7 @@ static void dev_release(struct refcount *ref)
 	free(dev);
 }
 
-GPIOSIM_API struct gpiosim_dev *
-gpiosim_dev_new(struct gpiosim_ctx *ctx)
+GPIOSIM_API struct gpiosim_dev *gpiosim_dev_new(struct gpiosim_ctx *ctx)
 {
 	int configfs_fd, ret, id;
 	struct gpiosim_dev *dev;
@@ -855,8 +852,7 @@ static void bank_release(struct refcount *ref)
 	free(bank);
 }
 
-GPIOSIM_API struct gpiosim_bank*
-gpiosim_bank_new(struct gpiosim_dev *dev)
+GPIOSIM_API struct gpiosim_bank *gpiosim_bank_new(struct gpiosim_dev *dev)
 {
 	struct gpiosim_bank *bank;
 	int configfs_fd, id;
diff --git a/tests/gpiosim/gpiosim.h b/tests/gpiosim/gpiosim.h
index 80d437e..ab26900 100644
--- a/tests/gpiosim/gpiosim.h
+++ b/tests/gpiosim/gpiosim.h
@@ -37,8 +37,7 @@ struct gpiosim_ctx *gpiosim_ctx_new(void);
 struct gpiosim_ctx *gpiosim_ctx_ref(struct gpiosim_ctx *ctx);
 void gpiosim_ctx_unref(struct gpiosim_ctx *ctx);
 
-struct gpiosim_dev *
-gpiosim_dev_new(struct gpiosim_ctx *ctx);
+struct gpiosim_dev *gpiosim_dev_new(struct gpiosim_ctx *ctx);
 struct gpiosim_dev *gpiosim_dev_ref(struct gpiosim_dev *dev);
 void gpiosim_dev_unref(struct gpiosim_dev *dev);
 struct gpiosim_ctx *gpiosim_dev_get_ctx(struct gpiosim_dev *dev);
@@ -48,8 +47,7 @@ int gpiosim_dev_enable(struct gpiosim_dev *dev);
 int gpiosim_dev_disable(struct gpiosim_dev *dev);
 bool gpiosim_dev_is_live(struct gpiosim_dev *dev);
 
-struct gpiosim_bank*
-gpiosim_bank_new(struct gpiosim_dev *dev);
+struct gpiosim_bank *gpiosim_bank_new(struct gpiosim_dev *dev);
 struct gpiosim_bank *gpiosim_bank_ref(struct gpiosim_bank *bank);
 void gpiosim_bank_unref(struct gpiosim_bank *bank);
 struct gpiosim_dev *gpiosim_bank_get_dev(struct gpiosim_bank *bank);
diff --git a/tests/tests-chip-info.c b/tests/tests-chip-info.c
index 85477c6..c43cfbe 100644
--- a/tests/tests-chip-info.c
+++ b/tests/tests-chip-info.c
@@ -48,4 +48,3 @@ GPIOD_TEST_CASE(get_num_lines)
 
 	g_assert_cmpuint(gpiod_chip_info_get_num_lines(info), ==, 16);
 }
-
diff --git a/tests/tests-edge-event.c b/tests/tests-edge-event.c
index 66fe075..5eb275c 100644
--- a/tests/tests-edge-event.c
+++ b/tests/tests-edge-event.c
@@ -116,8 +116,7 @@ GPIOD_TEST_CASE(read_both_events)
 	line_cfg = gpiod_test_create_line_config_or_fail();
 	buffer = gpiod_test_create_edge_event_buffer_or_fail(64);
 
-	gpiod_line_settings_set_direction(settings,
-					  GPIOD_LINE_DIRECTION_INPUT);
+	gpiod_line_settings_set_direction(settings, GPIOD_LINE_DIRECTION_INPUT);
 	gpiod_line_settings_set_edge_detection(settings, GPIOD_LINE_EDGE_BOTH);
 
 	gpiod_test_line_config_add_line_settings_or_fail(line_cfg, &offset, 1,
@@ -144,8 +143,8 @@ GPIOD_TEST_CASE(read_both_events)
 	g_assert_nonnull(event);
 	gpiod_test_join_thread_and_return_if_failed(thread);
 
-	g_assert_cmpint(gpiod_edge_event_get_event_type(event),
-			==, GPIOD_EDGE_EVENT_RISING_EDGE);
+	g_assert_cmpint(gpiod_edge_event_get_event_type(event), ==,
+			GPIOD_EDGE_EVENT_RISING_EDGE);
 	g_assert_cmpuint(gpiod_edge_event_get_line_offset(event), ==, 2);
 	ts_rising = gpiod_edge_event_get_timestamp_ns(event);
 
@@ -164,8 +163,8 @@ GPIOD_TEST_CASE(read_both_events)
 	g_assert_nonnull(event);
 	gpiod_test_join_thread_and_return_if_failed(thread);
 
-	g_assert_cmpint(gpiod_edge_event_get_event_type(event),
-			==, GPIOD_EDGE_EVENT_FALLING_EDGE);
+	g_assert_cmpint(gpiod_edge_event_get_event_type(event), ==,
+			GPIOD_EDGE_EVENT_FALLING_EDGE);
 	g_assert_cmpuint(gpiod_edge_event_get_line_offset(event), ==, 2);
 	ts_falling = gpiod_edge_event_get_timestamp_ns(event);
 
@@ -193,8 +192,7 @@ GPIOD_TEST_CASE(read_rising_edge_event)
 	line_cfg = gpiod_test_create_line_config_or_fail();
 	buffer = gpiod_test_create_edge_event_buffer_or_fail(64);
 
-	gpiod_line_settings_set_direction(settings,
-					  GPIOD_LINE_DIRECTION_INPUT);
+	gpiod_line_settings_set_direction(settings, GPIOD_LINE_DIRECTION_INPUT);
 	gpiod_line_settings_set_edge_detection(settings,
 					       GPIOD_LINE_EDGE_RISING);
 
@@ -222,8 +220,8 @@ GPIOD_TEST_CASE(read_rising_edge_event)
 	g_assert_nonnull(event);
 	gpiod_test_join_thread_and_return_if_failed(thread);
 
-	g_assert_cmpint(gpiod_edge_event_get_event_type(event),
-			==, GPIOD_EDGE_EVENT_RISING_EDGE);
+	g_assert_cmpint(gpiod_edge_event_get_event_type(event), ==,
+			GPIOD_EDGE_EVENT_RISING_EDGE);
 	g_assert_cmpuint(gpiod_edge_event_get_line_offset(event), ==, 2);
 
 	/* Second event. */
@@ -253,8 +251,7 @@ GPIOD_TEST_CASE(read_falling_edge_event)
 	line_cfg = gpiod_test_create_line_config_or_fail();
 	buffer = gpiod_test_create_edge_event_buffer_or_fail(64);
 
-	gpiod_line_settings_set_direction(settings,
-					  GPIOD_LINE_DIRECTION_INPUT);
+	gpiod_line_settings_set_direction(settings, GPIOD_LINE_DIRECTION_INPUT);
 	gpiod_line_settings_set_edge_detection(settings,
 					       GPIOD_LINE_EDGE_FALLING);
 
@@ -282,8 +279,8 @@ GPIOD_TEST_CASE(read_falling_edge_event)
 	g_assert_nonnull(event);
 	gpiod_test_join_thread_and_return_if_failed(thread);
 
-	g_assert_cmpint(gpiod_edge_event_get_event_type(event),
-			==, GPIOD_EDGE_EVENT_FALLING_EDGE);
+	g_assert_cmpint(gpiod_edge_event_get_event_type(event), ==,
+			GPIOD_EDGE_EVENT_FALLING_EDGE);
 	g_assert_cmpuint(gpiod_edge_event_get_line_offset(event), ==, 2);
 
 	/* No more events. */
@@ -315,8 +312,7 @@ GPIOD_TEST_CASE(read_rising_edge_event_polled)
 	line_cfg = gpiod_test_create_line_config_or_fail();
 	buffer = gpiod_test_create_edge_event_buffer_or_fail(64);
 
-	gpiod_line_settings_set_direction(settings,
-					  GPIOD_LINE_DIRECTION_INPUT);
+	gpiod_line_settings_set_direction(settings, GPIOD_LINE_DIRECTION_INPUT);
 	gpiod_line_settings_set_edge_detection(settings,
 					       GPIOD_LINE_EDGE_RISING);
 
@@ -353,8 +349,8 @@ GPIOD_TEST_CASE(read_rising_edge_event_polled)
 	g_assert_nonnull(event);
 	gpiod_test_join_thread_and_return_if_failed(thread);
 
-	g_assert_cmpint(gpiod_edge_event_get_event_type(event),
-			==, GPIOD_EDGE_EVENT_RISING_EDGE);
+	g_assert_cmpint(gpiod_edge_event_get_event_type(event), ==,
+			GPIOD_EDGE_EVENT_RISING_EDGE);
 	g_assert_cmpuint(gpiod_edge_event_get_line_offset(event), ==, 2);
 
 	/* Second event. */
@@ -389,8 +385,7 @@ GPIOD_TEST_CASE(read_both_events_blocking)
 	line_cfg = gpiod_test_create_line_config_or_fail();
 	buffer = gpiod_test_create_edge_event_buffer_or_fail(64);
 
-	gpiod_line_settings_set_direction(settings,
-					  GPIOD_LINE_DIRECTION_INPUT);
+	gpiod_line_settings_set_direction(settings, GPIOD_LINE_DIRECTION_INPUT);
 	gpiod_line_settings_set_edge_detection(settings, GPIOD_LINE_EDGE_BOTH);
 
 	gpiod_test_line_config_add_line_settings_or_fail(line_cfg, &offset, 1,
@@ -413,8 +408,8 @@ GPIOD_TEST_CASE(read_both_events_blocking)
 	g_assert_nonnull(event);
 	gpiod_test_join_thread_and_return_if_failed(thread);
 
-	g_assert_cmpint(gpiod_edge_event_get_event_type(event),
-			==, GPIOD_EDGE_EVENT_RISING_EDGE);
+	g_assert_cmpint(gpiod_edge_event_get_event_type(event), ==,
+			GPIOD_EDGE_EVENT_RISING_EDGE);
 	g_assert_cmpuint(gpiod_edge_event_get_line_offset(event), ==, 2);
 
 	/* Second event. */
@@ -428,8 +423,8 @@ GPIOD_TEST_CASE(read_both_events_blocking)
 	g_assert_nonnull(event);
 	gpiod_test_join_thread_and_return_if_failed(thread);
 
-	g_assert_cmpint(gpiod_edge_event_get_event_type(event),
-			==, GPIOD_EDGE_EVENT_FALLING_EDGE);
+	g_assert_cmpint(gpiod_edge_event_get_event_type(event), ==,
+			GPIOD_EDGE_EVENT_FALLING_EDGE);
 	g_assert_cmpuint(gpiod_edge_event_get_line_offset(event), ==, 2);
 
 	g_thread_join(thread);
@@ -469,8 +464,7 @@ GPIOD_TEST_CASE(seqno)
 	line_cfg = gpiod_test_create_line_config_or_fail();
 	buffer = gpiod_test_create_edge_event_buffer_or_fail(64);
 
-	gpiod_line_settings_set_direction(settings,
-					  GPIOD_LINE_DIRECTION_INPUT);
+	gpiod_line_settings_set_direction(settings, GPIOD_LINE_DIRECTION_INPUT);
 	gpiod_line_settings_set_edge_detection(settings, GPIOD_LINE_EDGE_BOTH);
 
 	gpiod_test_line_config_add_line_settings_or_fail(line_cfg, offsets, 2,
@@ -541,8 +535,7 @@ GPIOD_TEST_CASE(event_copy)
 	line_cfg = gpiod_test_create_line_config_or_fail();
 	buffer = gpiod_test_create_edge_event_buffer_or_fail(64);
 
-	gpiod_line_settings_set_direction(settings,
-					  GPIOD_LINE_DIRECTION_INPUT);
+	gpiod_line_settings_set_direction(settings, GPIOD_LINE_DIRECTION_INPUT);
 	gpiod_line_settings_set_edge_detection(settings, GPIOD_LINE_EDGE_BOTH);
 
 	gpiod_test_line_config_add_line_settings_or_fail(line_cfg, &offset, 1,
@@ -587,8 +580,7 @@ GPIOD_TEST_CASE(reading_more_events_than_the_queue_contains_doesnt_block)
 	line_cfg = gpiod_test_create_line_config_or_fail();
 	buffer = gpiod_test_create_edge_event_buffer_or_fail(64);
 
-	gpiod_line_settings_set_direction(settings,
-					  GPIOD_LINE_DIRECTION_INPUT);
+	gpiod_line_settings_set_direction(settings, GPIOD_LINE_DIRECTION_INPUT);
 	gpiod_line_settings_set_edge_detection(settings, GPIOD_LINE_EDGE_BOTH);
 
 	gpiod_test_line_config_add_line_settings_or_fail(line_cfg, &offset, 1,
diff --git a/tests/tests-info-event.c b/tests/tests-info-event.c
index a960ba9..a0cf5b6 100644
--- a/tests/tests-info-event.c
+++ b/tests/tests-info-event.c
@@ -199,7 +199,7 @@ GPIOD_TEST_CASE(request_reconfigure_release_events)
 }
 
 GPIOD_TEST_CASE(chip_fd_can_be_polled)
-{\
+{
 	g_autoptr(GPIOSimChip) sim = g_gpiosim_chip_new("num-lines", 8, NULL);
 	g_autoptr(struct_gpiod_chip) chip = NULL;
 	g_autoptr(struct_gpiod_line_info) info = NULL;
diff --git a/tests/tests-line-config.c b/tests/tests-line-config.c
index 27cc228..5dc9022 100644
--- a/tests/tests-line-config.c
+++ b/tests/tests-line-config.c
@@ -110,7 +110,7 @@ GPIOD_TEST_CASE(too_many_attrs)
 							 settings);
 
 	gpiod_line_settings_set_event_clock(settings,
-					     GPIOD_LINE_EVENT_CLOCK_REALTIME);
+					    GPIOD_LINE_EVENT_CLOCK_REALTIME);
 	offset = 7;
 	gpiod_test_line_config_add_line_settings_or_fail(line_cfg, &offset, 1,
 							 settings);
diff --git a/tests/tests-line-info.c b/tests/tests-line-info.c
index 8ec1b1b..4751db2 100644
--- a/tests/tests-line-info.c
+++ b/tests/tests-line-info.c
@@ -66,11 +66,9 @@ GPIOD_TEST_CASE(line_info_basic_properties)
 	g_autoptr(struct_gpiod_line_info) info4 = NULL;
 	g_autoptr(struct_gpiod_line_info) info6 = NULL;
 
-	sim = g_gpiosim_chip_new(
-			"num-lines", 8,
-			"line-names", gpiod_test_package_line_names(names),
-			"hogs", gpiod_test_package_hogs(hogs),
-			NULL);
+	sim = g_gpiosim_chip_new("num-lines", 8, "line-names",
+				 gpiod_test_package_line_names(names), "hogs",
+				 gpiod_test_package_hogs(hogs), NULL);
 
 	chip = gpiod_test_open_chip_or_fail(g_gpiosim_chip_get_dev_path(sim));
 	info4 = gpiod_test_get_line_info_or_fail(chip, 4);
@@ -137,8 +135,7 @@ GPIOD_TEST_CASE(direction_settings)
 	offset = 1;
 	gpiod_test_line_config_add_line_settings_or_fail(line_cfg, &offset, 1,
 							 settings);
-	gpiod_line_settings_set_direction(settings,
-					  GPIOD_LINE_DIRECTION_AS_IS);
+	gpiod_line_settings_set_direction(settings, GPIOD_LINE_DIRECTION_AS_IS);
 	offset = 2;
 	gpiod_test_line_config_add_line_settings_or_fail(line_cfg, &offset, 1,
 							 settings);
@@ -202,7 +199,8 @@ GPIOD_TEST_CASE(edge_detection_settings)
 	offset = 0;
 	gpiod_test_line_config_add_line_settings_or_fail(line_cfg, &offset, 1,
 							 settings);
-	gpiod_line_settings_set_edge_detection(settings, GPIOD_LINE_EDGE_RISING);
+	gpiod_line_settings_set_edge_detection(settings,
+					       GPIOD_LINE_EDGE_RISING);
 	offset = 1;
 	gpiod_test_line_config_add_line_settings_or_fail(line_cfg, &offset, 1,
 							 settings);
@@ -249,7 +247,8 @@ GPIOD_TEST_CASE(bias_settings)
 	settings = gpiod_test_create_line_settings_or_fail();
 	line_cfg = gpiod_test_create_line_config_or_fail();
 
-	gpiod_line_settings_set_direction(settings,GPIOD_LINE_DIRECTION_OUTPUT);
+	gpiod_line_settings_set_direction(settings,
+					  GPIOD_LINE_DIRECTION_OUTPUT);
 	offset = 0;
 	gpiod_test_line_config_add_line_settings_or_fail(line_cfg, &offset, 1,
 							 settings);
@@ -349,8 +348,8 @@ GPIOD_TEST_CASE(debounce_period)
 	request = gpiod_test_request_lines_or_fail(chip, NULL, line_cfg);
 	info = gpiod_test_get_line_info_or_fail(chip, 5);
 
-	g_assert_cmpuint(gpiod_line_info_get_debounce_period_us(info),
-			 ==, 1000);
+	g_assert_cmpuint(gpiod_line_info_get_debounce_period_us(info), ==,
+			 1000);
 }
 
 GPIOD_TEST_CASE(event_clock)
@@ -391,7 +390,7 @@ GPIOD_TEST_CASE(event_clock)
 	}
 
 	gpiod_test_return_if_failed();
-	
+
 	info0 = gpiod_test_get_line_info_or_fail(chip, 0);
 	info1 = gpiod_test_get_line_info_or_fail(chip, 1);
 	info2 = gpiod_test_get_line_info_or_fail(chip, 2);
diff --git a/tests/tests-line-request.c b/tests/tests-line-request.c
index 6cf85ab..2c2af01 100644
--- a/tests/tests-line-request.c
+++ b/tests/tests-line-request.c
@@ -156,8 +156,8 @@ GPIOD_TEST_CASE(default_output_value)
 	request = gpiod_test_request_lines_or_fail(chip, NULL, line_cfg);
 
 	for (i = 0; i < 4; i++)
-		g_assert_cmpint(g_gpiosim_chip_get_value(sim, offsets[i]),
-				==, GPIOD_LINE_VALUE_ACTIVE);
+		g_assert_cmpint(g_gpiosim_chip_get_value(sim, offsets[i]), ==,
+				GPIOD_LINE_VALUE_ACTIVE);
 
 	g_assert_cmpint(g_gpiosim_chip_get_value(sim, 2), ==,
 			GPIOD_LINE_VALUE_INACTIVE);
@@ -189,7 +189,8 @@ GPIOD_TEST_CASE(read_all_values)
 
 	for (i = 0; i < 5; i++)
 		g_gpiosim_chip_set_pull(sim, offsets[i],
-			pulls[i] ? G_GPIOSIM_PULL_UP : G_GPIOSIM_PULL_DOWN);
+					pulls[i] ? G_GPIOSIM_PULL_UP :
+						   G_GPIOSIM_PULL_DOWN);
 
 	ret = gpiod_line_request_get_values(request, values);
 	g_assert_cmpint(ret, ==, 0);
@@ -224,7 +225,8 @@ GPIOD_TEST_CASE(request_multiple_values_but_read_one)
 
 	for (i = 0; i < 5; i++)
 		g_gpiosim_chip_set_pull(sim, offsets[i],
-			pulls[i] ? G_GPIOSIM_PULL_UP : G_GPIOSIM_PULL_DOWN);
+					pulls[i] ? G_GPIOSIM_PULL_UP :
+						   G_GPIOSIM_PULL_DOWN);
 
 	ret = gpiod_line_request_get_value(request, 5);
 	g_assert_cmpint(ret, ==, 1);
@@ -265,8 +267,8 @@ GPIOD_TEST_CASE(set_all_values)
 	gpiod_test_return_if_failed();
 
 	for (i = 0; i < 5; i++)
-		g_assert_cmpint(g_gpiosim_chip_get_value(sim, offsets[i]),
-				==, values[i]);
+		g_assert_cmpint(g_gpiosim_chip_get_value(sim, offsets[i]), ==,
+				values[i]);
 }
 
 GPIOD_TEST_CASE(set_values_subset_of_lines)
@@ -297,17 +299,17 @@ GPIOD_TEST_CASE(set_values_subset_of_lines)
 
 	request = gpiod_test_request_lines_or_fail(chip, NULL, line_cfg);
 
-	ret = gpiod_line_request_set_values_subset(request, 3,
-						   offsets_to_set, values);
+	ret = gpiod_line_request_set_values_subset(request, 3, offsets_to_set,
+						   values);
 	g_assert_cmpint(ret, ==, 0);
 	gpiod_test_return_if_failed();
 
-	g_assert_cmpint(g_gpiosim_chip_get_value(sim, 0),
-			==, GPIOD_LINE_VALUE_ACTIVE);
-	g_assert_cmpint(g_gpiosim_chip_get_value(sim, 1),
-			==, GPIOD_LINE_VALUE_INACTIVE);
-	g_assert_cmpint(g_gpiosim_chip_get_value(sim, 3),
-			==, GPIOD_LINE_VALUE_ACTIVE);
+	g_assert_cmpint(g_gpiosim_chip_get_value(sim, 0), ==,
+			GPIOD_LINE_VALUE_ACTIVE);
+	g_assert_cmpint(g_gpiosim_chip_get_value(sim, 1), ==,
+			GPIOD_LINE_VALUE_INACTIVE);
+	g_assert_cmpint(g_gpiosim_chip_get_value(sim, 3), ==,
+			GPIOD_LINE_VALUE_ACTIVE);
 }
 
 GPIOD_TEST_CASE(set_line_after_requesting)
@@ -358,8 +360,7 @@ GPIOD_TEST_CASE(request_survives_parent_chip)
 
 	gpiod_line_settings_set_direction(settings,
 					  GPIOD_LINE_DIRECTION_OUTPUT);
-	gpiod_line_settings_set_output_value(settings,
-					     GPIOD_LINE_VALUE_ACTIVE);
+	gpiod_line_settings_set_output_value(settings, GPIOD_LINE_VALUE_ACTIVE);
 	gpiod_test_line_config_add_line_settings_or_fail(line_cfg, &offset, 1,
 							 settings);
 
diff --git a/tests/tests-line-settings.c b/tests/tests-line-settings.c
index bdf932d..e6c0277 100644
--- a/tests/tests-line-settings.c
+++ b/tests/tests-line-settings.c
@@ -26,7 +26,7 @@ GPIOD_TEST_CASE(default_config)
 			GPIOD_LINE_DRIVE_PUSH_PULL);
 	g_assert_false(gpiod_line_settings_get_active_low(settings));
 	g_assert_cmpuint(gpiod_line_settings_get_debounce_period_us(settings),
-			==, 0);
+			 ==, 0);
 	g_assert_cmpint(gpiod_line_settings_get_event_clock(settings), ==,
 			GPIOD_LINE_EVENT_CLOCK_MONOTONIC);
 	g_assert_cmpint(gpiod_line_settings_get_output_value(settings), ==,
@@ -110,26 +110,22 @@ GPIOD_TEST_CASE(set_bias)
 
 	settings = gpiod_test_create_line_settings_or_fail();
 
-	ret = gpiod_line_settings_set_bias(settings,
-					   GPIOD_LINE_BIAS_DISABLED);
+	ret = gpiod_line_settings_set_bias(settings, GPIOD_LINE_BIAS_DISABLED);
 	g_assert_cmpint(ret, ==, 0);
 	g_assert_cmpint(gpiod_line_settings_get_bias(settings), ==,
 			GPIOD_LINE_BIAS_DISABLED);
 
-	ret = gpiod_line_settings_set_bias(settings,
-					   GPIOD_LINE_BIAS_AS_IS);
+	ret = gpiod_line_settings_set_bias(settings, GPIOD_LINE_BIAS_AS_IS);
 	g_assert_cmpint(ret, ==, 0);
 	g_assert_cmpint(gpiod_line_settings_get_bias(settings), ==,
 			GPIOD_LINE_BIAS_AS_IS);
 
-	ret = gpiod_line_settings_set_bias(settings,
-					   GPIOD_LINE_BIAS_PULL_DOWN);
+	ret = gpiod_line_settings_set_bias(settings, GPIOD_LINE_BIAS_PULL_DOWN);
 	g_assert_cmpint(ret, ==, 0);
 	g_assert_cmpint(gpiod_line_settings_get_bias(settings), ==,
 			GPIOD_LINE_BIAS_PULL_DOWN);
 
-	ret = gpiod_line_settings_set_bias(settings,
-					   GPIOD_LINE_BIAS_PULL_UP);
+	ret = gpiod_line_settings_set_bias(settings, GPIOD_LINE_BIAS_PULL_UP);
 	g_assert_cmpint(ret, ==, 0);
 	g_assert_cmpint(gpiod_line_settings_get_bias(settings), ==,
 			GPIOD_LINE_BIAS_PULL_UP);
@@ -312,7 +308,7 @@ GPIOD_TEST_CASE(reset_settings)
 			GPIOD_LINE_DRIVE_PUSH_PULL);
 	g_assert_false(gpiod_line_settings_get_active_low(settings));
 	g_assert_cmpuint(gpiod_line_settings_get_debounce_period_us(settings),
-			==, 0);
+			 ==, 0);
 	g_assert_cmpint(gpiod_line_settings_get_event_clock(settings), ==,
 			GPIOD_LINE_EVENT_CLOCK_MONOTONIC);
 	g_assert_cmpint(gpiod_line_settings_get_output_value(settings), ==,
diff --git a/tests/tests-request-config.c b/tests/tests-request-config.c
index f26c05a..71fccde 100644
--- a/tests/tests-request-config.c
+++ b/tests/tests-request-config.c
@@ -16,8 +16,8 @@ GPIOD_TEST_CASE(default_config)
 	config = gpiod_test_create_request_config_or_fail();
 
 	g_assert_null(gpiod_request_config_get_consumer(config));
-	g_assert_cmpuint(gpiod_request_config_get_event_buffer_size(config),
-			 ==, 0);
+	g_assert_cmpuint(gpiod_request_config_get_event_buffer_size(config), ==,
+			 0);
 }
 
 GPIOD_TEST_CASE(set_consumer)
@@ -27,8 +27,8 @@ GPIOD_TEST_CASE(set_consumer)
 	config = gpiod_test_create_request_config_or_fail();
 
 	gpiod_request_config_set_consumer(config, "foobar");
-	g_assert_cmpstr(gpiod_request_config_get_consumer(config),
-			==, "foobar");
+	g_assert_cmpstr(gpiod_request_config_get_consumer(config), ==,
+			"foobar");
 }
 
 GPIOD_TEST_CASE(set_event_buffer_size)
@@ -38,6 +38,6 @@ GPIOD_TEST_CASE(set_event_buffer_size)
 	config = gpiod_test_create_request_config_or_fail();
 
 	gpiod_request_config_set_event_buffer_size(config, 128);
-	g_assert_cmpuint(gpiod_request_config_get_event_buffer_size(config),
-			 ==, 128);
+	g_assert_cmpuint(gpiod_request_config_get_event_buffer_size(config), ==,
+			 128);
 }
diff --git a/tools/gpiodetect.c b/tools/gpiodetect.c
index 671ed6a..f0211da 100644
--- a/tools/gpiodetect.c
+++ b/tools/gpiodetect.c
@@ -74,8 +74,7 @@ static int print_chip_info(const char *path)
 	if (!info)
 		die_perror("unable to read info for '%s'", path);
 
-	printf("%s [%s] (%zu lines)\n",
-	       gpiod_chip_info_get_name(info),
+	printf("%s [%s] (%zu lines)\n", gpiod_chip_info_get_name(info),
 	       gpiod_chip_info_get_label(info),
 	       gpiod_chip_info_get_num_lines(info));
 
diff --git a/tools/gpioinfo.c b/tools/gpioinfo.c
index 592f4a6..1ec7f63 100644
--- a/tools/gpioinfo.c
+++ b/tools/gpioinfo.c
@@ -100,7 +100,7 @@ static int parse_config(int argc, char **argv, struct config *cfg)
  * Does not die on non-unique lines.
  */
 static bool resolve_line(struct line_resolver *resolver,
-			  struct gpiod_line_info *info, int chip_num)
+			 struct gpiod_line_info *info, int chip_num)
 {
 	struct resolved_line *line;
 	bool resolved = false;
@@ -114,8 +114,7 @@ static bool resolve_line(struct line_resolver *resolver,
 		line = &resolver->lines[i];
 
 		/* already resolved by offset? */
-		if (line->resolved &&
-		    (line->offset == offset) &&
+		if (line->resolved && (line->offset == offset) &&
 		    (line->chip_num == chip_num)) {
 			resolved = true;
 		}
@@ -187,9 +186,8 @@ static void list_lines(struct line_resolver *resolver, struct gpiod_chip *chip,
 	if ((chip_num == 0) && (cfg->chip_id && !cfg->by_name))
 		resolve_lines_by_offset(resolver, num_lines);
 
-	for (offset = 0;
-	     ((offset < num_lines) &&
-	      !(resolver->num_lines && resolve_done(resolver)));
+	for (offset = 0; ((offset < num_lines) &&
+			  !(resolver->num_lines && resolve_done(resolver)));
 	     offset++) {
 		info = gpiod_chip_get_line_info(chip, offset);
 		if (!info)
@@ -238,7 +236,7 @@ int main(int argc, char **argv)
 		cfg.by_name = true;
 
 	num_chips = chip_paths(cfg.chip_id, &paths);
-	if (cfg.chip_id  && (num_chips == 0))
+	if (cfg.chip_id && (num_chips == 0))
 		die("cannot find GPIO chip character device '%s'", cfg.chip_id);
 
 	resolver = resolver_init(argc, argv, num_chips, cfg.strict,
diff --git a/tools/gpiomon.c b/tools/gpiomon.c
index dc157df..ba457e4 100644
--- a/tools/gpiomon.c
+++ b/tools/gpiomon.c
@@ -210,7 +210,7 @@ static int parse_config(int argc, char **argv, struct config *cfg)
 		else
 			cfg->event_clock = GPIOD_LINE_EVENT_CLOCK_MONOTONIC;
 	} else if ((cfg->event_clock == GPIOD_LINE_EVENT_CLOCK_REALTIME) &&
-		 (cfg->timestamp_fmt == 0)) {
+		   (cfg->timestamp_fmt == 0)) {
 		cfg->timestamp_fmt = 1;
 	}
 
@@ -234,8 +234,8 @@ static void print_banner(int num_lines, char **lines)
 }
 
 static void event_print_formatted(struct gpiod_edge_event *event,
-			struct line_resolver *resolver, int chip_num,
-			struct config *cfg)
+				  struct line_resolver *resolver, int chip_num,
+				  struct config *cfg)
 {
 	const char *lname, *prev, *curr;
 	unsigned int offset;
@@ -381,8 +381,8 @@ int main(int argc, char **argv)
 		gpiod_line_settings_set_active_low(settings, true);
 
 	if (cfg.debounce_period_us)
-		gpiod_line_settings_set_debounce_period_us(settings,
-					cfg.debounce_period_us);
+		gpiod_line_settings_set_debounce_period_us(
+			settings, cfg.debounce_period_us);
 
 	gpiod_line_settings_set_event_clock(settings, cfg.event_clock);
 	gpiod_line_settings_set_edge_detection(settings, cfg.edges);
@@ -484,4 +484,3 @@ done:
 
 	return EXIT_SUCCESS;
 }
-
diff --git a/tools/gpionotify.c b/tools/gpionotify.c
index 2367495..a0976f7 100644
--- a/tools/gpionotify.c
+++ b/tools/gpionotify.c
@@ -216,7 +216,7 @@ static uint64_t monotonic_to_realtime(uint64_t evtime)
 	clock_gettime(CLOCK_REALTIME, &ts);
 	after = ts.tv_nsec + ((uint64_t)ts.tv_sec) * 1000000000;
 
-	evtime += (after/2 - mono + before/2);
+	evtime += (after / 2 - mono + before / 2);
 
 	return evtime;
 }
@@ -230,7 +230,7 @@ static void event_print_formatted(struct gpiod_info_event *event,
 	unsigned int offset;
 	uint64_t evtime;
 	int evtype;
-	char  fmt;
+	char fmt;
 
 	info = gpiod_info_event_get_line_info(event);
 	evtime = gpiod_info_event_get_timestamp_ns(event);
@@ -310,8 +310,8 @@ end:
 }
 
 static void event_print_human_readable(struct gpiod_info_event *event,
-			struct line_resolver *resolver, int chip_num,
-			struct config *cfg)
+				       struct line_resolver *resolver,
+				       int chip_num, struct config *cfg)
 {
 	struct gpiod_line_info *info;
 	unsigned int offset;
@@ -397,7 +397,7 @@ int main(int argc, char **argv)
 		for (j = 0; j < resolver->num_lines; j++)
 			if ((resolver->lines[j].chip_num == i) &&
 			    !gpiod_chip_watch_line_info(
-					chip, resolver->lines[j].offset))
+				    chip, resolver->lines[j].offset))
 				die_perror("unable to watch line on chip '%s'",
 					   resolver->chips[i].path);
 
diff --git a/tools/gpioset.c b/tools/gpioset.c
index a32c894..698dba3 100644
--- a/tools/gpioset.c
+++ b/tools/gpioset.c
@@ -278,7 +278,6 @@ static bool parse_line_values(int num_lines, char **lvs, char **lines,
 				*value = '\0';
 				value++;
 			}
-
 		}
 
 		if (!value) {
@@ -352,8 +351,8 @@ static void wait_fd(int fd)
  * offset and values are scratch pads for working.
  */
 static void apply_values(struct gpiod_line_request **requests,
-			 struct line_resolver *resolver,
-			 unsigned int *offsets, enum gpiod_line_value *values)
+			 struct line_resolver *resolver, unsigned int *offsets,
+			 enum gpiod_line_value *values)
 {
 	int i;
 
@@ -380,9 +379,10 @@ static void toggle_all_lines(struct line_resolver *resolver)
  * offset and values are scratch pads for working.
  */
 static void toggle_sequence(int toggles, unsigned int *toggle_periods,
-			 struct gpiod_line_request **requests,
-			 struct line_resolver *resolver,
-			 unsigned int *offsets, enum gpiod_line_value *values)
+			    struct gpiod_line_request **requests,
+			    struct line_resolver *resolver,
+			    unsigned int *offsets,
+			    enum gpiod_line_value *values)
 {
 	int i = 0;
 
@@ -537,7 +537,7 @@ static bool valid_lines(struct line_resolver *resolver, int num_lines,
 		}
 	}
 
-	return  ret;
+	return ret;
 }
 
 static void print_interactive_help(void)
@@ -639,8 +639,7 @@ static char *complete_line_id(const char *text, int state)
 		id = completion_context->lines[idx].id;
 		idx++;
 
-		if ((strncmp(id, text, len) == 0) &&
-		    (!in_line_buffer(id)))
+		if ((strncmp(id, text, len) == 0) && (!in_line_buffer(id)))
 			return strdup(id);
 	}
 
@@ -708,16 +707,14 @@ static char **tab_completion(const char *text, int start, int end)
 	rl_completion_append_character = ' ';
 
 	for (cmd_start = 0;
-	     isspace(rl_line_buffer[cmd_start]) && cmd_start < end;
-	     cmd_start++)
+	     isspace(rl_line_buffer[cmd_start]) && cmd_start < end; cmd_start++)
 		;
 
 	if (cmd_start == start)
 		matches = rl_completion_matches(text, complete_command);
 
 	for (cmd_end = cmd_start + 1;
-	     !isspace(rl_line_buffer[cmd_end]) && cmd_end < end;
-	     cmd_end++)
+	     !isspace(rl_line_buffer[cmd_end]) && cmd_end < end; cmd_end++)
 		;
 
 	len = cmd_end - cmd_start;
@@ -731,7 +728,8 @@ static char **tab_completion(const char *text, int start, int end)
 	}
 
 	if ((len == 3 && strncmp("get ", &rl_line_buffer[cmd_start], 4) == 0) ||
-	    (len == 6 && strncmp("toggle ", &rl_line_buffer[cmd_start], 7) == 0))
+	    (len == 6 &&
+	     strncmp("toggle ", &rl_line_buffer[cmd_start], 7) == 0))
 		matches = rl_completion_matches(text, complete_line_id);
 
 	return matches;
@@ -740,9 +738,9 @@ static char **tab_completion(const char *text, int start, int end)
 #define PROMPT "gpioset> "
 
 static void interact(struct gpiod_line_request **requests,
-		    struct line_resolver *resolver,
-		    char **lines, unsigned int *offsets,
-		    enum gpiod_line_value *values, bool unquoted)
+		     struct line_resolver *resolver, char **lines,
+		     unsigned int *offsets, enum gpiod_line_value *values,
+		     bool unquoted)
 {
 	int num_words, num_lines, max_words, period_us, i;
 	char *line, **words, *line_buf;
@@ -788,8 +786,8 @@ static void interact(struct gpiod_line_request **requests,
 				print_all_line_values(resolver, unquoted);
 			else if (parse_line_ids(num_lines, &words[1], lines) &&
 				 valid_lines(resolver, num_lines, lines))
-				print_line_values(resolver, num_lines,
-						  lines, unquoted);
+				print_line_values(resolver, num_lines, lines,
+						  unquoted);
 			goto cmd_ok;
 		}
 		if (strcmp(words[0], "set") == 0) {
@@ -844,8 +842,7 @@ static void interact(struct gpiod_line_request **requests,
 		}
 
 		printf("unknown command: '%s'\n", words[0]);
-		printf("Try the 'help' command\n")
-			;
+		printf("Try the 'help' command\n");
 
 cmd_ok:
 		for (i = 0; isspace(line[i]); i++)
@@ -932,16 +929,16 @@ int main(int argc, char **argv)
 		die_perror("unable to allocate the line config structure");
 
 	for (i = 0; i < resolver->num_chips; i++) {
-		num_lines = get_line_offsets_and_values(resolver, i,
-							offsets, values);
+		num_lines = get_line_offsets_and_values(resolver, i, offsets,
+							values);
 
 		gpiod_line_config_reset(line_cfg);
 		for (j = 0; j < num_lines; j++) {
 			gpiod_line_settings_set_output_value(settings,
 							     values[j]);
 
-			ret = gpiod_line_config_add_line_settings(line_cfg,
-					 &offsets[j], 1, settings);
+			ret = gpiod_line_config_add_line_settings(
+				line_cfg, &offsets[j], 1, settings);
 			if (ret)
 				die_perror("unable to add line settings");
 		}
@@ -1007,4 +1004,3 @@ int main(int argc, char **argv)
 
 	return EXIT_SUCCESS;
 }
-
diff --git a/tools/tools-common.c b/tools/tools-common.c
index 6dbcf57..4477ac8 100644
--- a/tools/tools-common.c
+++ b/tools/tools-common.c
@@ -214,10 +214,10 @@ void print_event_time(uint64_t evtime, int format)
 			tz = "Z";
 		}
 		strftime(tbuf, TIME_BUFFER_SIZE, "%FT%T", &t);
-		printf("%s.%09"PRIu64"%s", tbuf, evtime % 1000000000, tz);
+		printf("%s.%09" PRIu64 "%s", tbuf, evtime % 1000000000, tz);
 	} else {
-		printf("%"PRIu64".%09"PRIu64,
-		       evtime / 1000000000, evtime % 1000000000);
+		printf("%" PRIu64 ".%09" PRIu64, evtime / 1000000000,
+		       evtime % 1000000000);
 	}
 }
 
@@ -380,8 +380,7 @@ static int chip_dir_filter(const struct dirent *entry)
 	if (asprintf(&path, "/dev/%s", entry->d_name) < 0)
 		return 0;
 
-	if ((lstat(path, &sb) == 0) &&
-	    (!S_ISLNK(sb.st_mode)) &&
+	if ((lstat(path, &sb) == 0) && (!S_ISLNK(sb.st_mode)) &&
 	    gpiod_is_gpiochip_device(path))
 		ret = 1;
 
@@ -482,8 +481,7 @@ int all_chip_paths(char ***paths_ptr)
 }
 
 static bool resolve_line(struct line_resolver *resolver,
-			  struct gpiod_line_info *info,
-			  int chip_num)
+			 struct gpiod_line_info *info, int chip_num)
 {
 	struct resolved_line *line;
 	bool resolved = false;
@@ -495,8 +493,7 @@ static bool resolve_line(struct line_resolver *resolver,
 	for (i = 0; i < resolver->num_lines; i++) {
 		line = &resolver->lines[i];
 		/* already resolved by offset? */
-		if (line->resolved &&
-		    (line->offset == offset) &&
+		if (line->resolved && (line->offset == offset) &&
 		    (line->chip_num == chip_num)) {
 			line->info = info;
 			resolver->num_found++;
@@ -548,7 +545,6 @@ bool resolve_lines_by_offset(struct line_resolver *resolver,
 	return used;
 }
 
-
 bool resolve_done(struct line_resolver *resolver)
 {
 	return (!resolver->strict &&
@@ -588,7 +584,8 @@ struct line_resolver *resolver_init(int num_lines, char **lines, int num_chips,
 }
 
 struct line_resolver *resolve_lines(int num_lines, char **lines,
-			const char *chip_id, bool strict, bool by_name)
+				    const char *chip_id, bool strict,
+				    bool by_name)
 {
 	struct gpiod_chip_info *chip_info;
 	struct gpiod_line_info *line_info;
@@ -602,7 +599,7 @@ struct line_resolver *resolve_lines(int num_lines, char **lines,
 		by_name = true;
 
 	num_chips = chip_paths(chip_id, &paths);
-	if (chip_id  && (num_chips == 0))
+	if (chip_id && (num_chips == 0))
 		die("cannot find GPIO chip character device '%s'", chip_id);
 
 	resolver = resolver_init(num_lines, lines, num_chips, strict, by_name);
@@ -666,7 +663,7 @@ void validate_resolution(struct line_resolver *resolver, const char *chip_id)
 	bool valid = true;
 	int i, j;
 
-	for (i = 0 ; i < resolver->num_lines; i++) {
+	for (i = 0; i < resolver->num_lines; i++) {
 		line = &resolver->lines[i];
 		if (line->resolved) {
 			for (j = 0; j < i; j++) {
@@ -712,8 +709,8 @@ void free_line_resolver(struct line_resolver *resolver)
 	free(resolver);
 }
 
-int get_line_offsets_and_values(struct line_resolver *resolver,
-				int chip_num, unsigned int *offsets,
+int get_line_offsets_and_values(struct line_resolver *resolver, int chip_num,
+				unsigned int *offsets,
 				enum gpiod_line_value *values)
 {
 	struct resolved_line *line;
@@ -738,8 +735,8 @@ const char *get_chip_name(struct line_resolver *resolver, int chip_num)
 	return gpiod_chip_info_get_name(resolver->chips[chip_num].info);
 }
 
-const char *get_line_name(struct line_resolver *resolver,
-			  int chip_num, unsigned int offset)
+const char *get_line_name(struct line_resolver *resolver, int chip_num,
+			  unsigned int offset)
 {
 	struct resolved_line *line;
 	int i;
@@ -748,7 +745,8 @@ const char *get_line_name(struct line_resolver *resolver,
 		line = &resolver->lines[i];
 		if (line->info && (line->offset == offset) &&
 		    (line->chip_num == chip_num))
-			return gpiod_line_info_get_name(resolver->lines[i].info);
+			return gpiod_line_info_get_name(
+				resolver->lines[i].info);
 	}
 
 	return 0;
diff --git a/tools/tools-common.h b/tools/tools-common.h
index d467197..efbeeb8 100644
--- a/tools/tools-common.h
+++ b/tools/tools-common.h
@@ -102,7 +102,8 @@ bool chip_path_lookup(const char *id, char **path_ptr);
 int chip_paths(const char *id, char ***paths_ptr);
 int all_chip_paths(char ***paths_ptr);
 struct line_resolver *resolve_lines(int num_lines, char **lines,
-		const char *chip_id, bool strict, bool by_name);
+				    const char *chip_id, bool strict,
+				    bool by_name);
 struct line_resolver *resolver_init(int num_lines, char **lines, int num_chips,
 				    bool strict, bool by_name);
 bool resolve_lines_by_offset(struct line_resolver *resolver,
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [libgpiod][PATCH 03/11] treewide: use plural 'events' in read_edge_event() functions
  2022-11-30 12:42 [libgpiod][PATCH 00/11] treewide: an assortment of tweaks and improvements Bartosz Golaszewski
  2022-11-30 12:42 ` [libgpiod][PATCH 01/11] treewide: use C enum types explicitly Bartosz Golaszewski
  2022-11-30 12:42 ` [libgpiod][PATCH 02/11] treewide: apply formatting changes with clang-format Bartosz Golaszewski
@ 2022-11-30 12:42 ` Bartosz Golaszewski
  2022-12-01  2:08   ` Viresh Kumar
  2022-11-30 12:42 ` [libgpiod][PATCH 04/11] treewide: rename EVENT_CLOCK to CLOCK Bartosz Golaszewski
                   ` (8 subsequent siblings)
  11 siblings, 1 reply; 28+ messages in thread
From: Bartosz Golaszewski @ 2022-11-30 12:42 UTC (permalink / raw)
  To: Kent Gibson, Linus Walleij, Andy Shevchenko, Viresh Kumar
  Cc: linux-gpio, Bartosz Golaszewski

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

The read_edge_event() family of functions should actually be called
read_edge_events() as they universally allow to read more than one
event. We're converting wait_edge_event() too for consistency.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 bindings/cxx/edge-event-buffer.cpp            |  2 +-
 bindings/cxx/examples/gpiomoncxx.cpp          |  2 +-
 bindings/cxx/gpiodcxx/line-request.hpp        |  6 +-
 bindings/cxx/line-request.cpp                 | 10 ++--
 bindings/cxx/tests/tests-edge-event.cpp       | 56 +++++++++----------
 bindings/python/examples/gpiomon.py           |  2 +-
 bindings/python/gpiod/ext/request.c           |  8 +--
 bindings/python/gpiod/line_request.py         |  6 +-
 bindings/python/tests/tests_edge_event.py     | 38 ++++++-------
 .../rust/libgpiod/examples/gpio_events.rs     |  2 +-
 bindings/rust/libgpiod/examples/gpiomon.rs    |  2 +-
 bindings/rust/libgpiod/src/event_buffer.rs    |  2 +-
 bindings/rust/libgpiod/src/line_request.rs    |  4 +-
 bindings/rust/libgpiod/tests/edge_event.rs    | 24 ++++----
 bindings/rust/libgpiod/tests/line_request.rs  |  2 +-
 include/gpiod.h                               | 10 ++--
 lib/line-request.c                            | 10 ++--
 tests/tests-edge-event.c                      | 46 +++++++--------
 tools/gpiomon.c                               |  2 +-
 19 files changed, 117 insertions(+), 117 deletions(-)

diff --git a/bindings/cxx/edge-event-buffer.cpp b/bindings/cxx/edge-event-buffer.cpp
index ff398f1..3c551df 100644
--- a/bindings/cxx/edge-event-buffer.cpp
+++ b/bindings/cxx/edge-event-buffer.cpp
@@ -36,7 +36,7 @@ edge_event_buffer::impl::impl(unsigned int capacity)
 
 int edge_event_buffer::impl::read_events(const line_request_ptr& request, unsigned int max_events)
 {
-	int ret = ::gpiod_line_request_read_edge_event(request.get(),
+	int ret = ::gpiod_line_request_read_edge_events(request.get(),
 						       this->buffer.get(), max_events);
 	if (ret < 0)
 		throw_from_errno("error reading edge events from file descriptor");
diff --git a/bindings/cxx/examples/gpiomoncxx.cpp b/bindings/cxx/examples/gpiomoncxx.cpp
index c351567..4f765ba 100644
--- a/bindings/cxx/examples/gpiomoncxx.cpp
+++ b/bindings/cxx/examples/gpiomoncxx.cpp
@@ -56,7 +56,7 @@ int main(int argc, char **argv)
 	::gpiod::edge_event_buffer buffer;
 
 	for (;;) {
-		request.read_edge_event(buffer);
+		request.read_edge_events(buffer);
 
 		for (const auto& event: buffer)
 			print_event(event);
diff --git a/bindings/cxx/gpiodcxx/line-request.hpp b/bindings/cxx/gpiodcxx/line-request.hpp
index 659251b..f9f0322 100644
--- a/bindings/cxx/gpiodcxx/line-request.hpp
+++ b/bindings/cxx/gpiodcxx/line-request.hpp
@@ -180,7 +180,7 @@ public:
 	 * @return True if at least one event is ready to be read. False if the
 	 *         wait timed out.
 	 */
-	bool wait_edge_event(const ::std::chrono::nanoseconds& timeout) const;
+	bool wait_edge_events(const ::std::chrono::nanoseconds& timeout) const;
 
 	/**
 	 * @brief Read a number of edge events from this request up to the
@@ -188,7 +188,7 @@ public:
 	 * @param buffer Edge event buffer to read events into.
 	 * @return Number of events read.
 	 */
-	::std::size_t read_edge_event(edge_event_buffer& buffer);
+	::std::size_t read_edge_events(edge_event_buffer& buffer);
 
 	/**
 	 * @brief Read a number of edge events from this request.
@@ -197,7 +197,7 @@ public:
 	 *                   capacity of the buffer.
 	 * @return Number of events read.
 	 */
-	::std::size_t read_edge_event(edge_event_buffer& buffer, ::std::size_t max_events);
+	::std::size_t read_edge_events(edge_event_buffer& buffer, ::std::size_t max_events);
 
 private:
 
diff --git a/bindings/cxx/line-request.cpp b/bindings/cxx/line-request.cpp
index be0bac5..34c5850 100644
--- a/bindings/cxx/line-request.cpp
+++ b/bindings/cxx/line-request.cpp
@@ -192,11 +192,11 @@ GPIOD_CXX_API int line_request::fd() const
 	return ::gpiod_line_request_get_fd(this->_m_priv->request.get());
 }
 
-GPIOD_CXX_API bool line_request::wait_edge_event(const ::std::chrono::nanoseconds& timeout) const
+GPIOD_CXX_API bool line_request::wait_edge_events(const ::std::chrono::nanoseconds& timeout) const
 {
 	this->_m_priv->throw_if_released();
 
-	int ret = ::gpiod_line_request_wait_edge_event(this->_m_priv->request.get(),
+	int ret = ::gpiod_line_request_wait_edge_events(this->_m_priv->request.get(),
 						       timeout.count());
 	if (ret < 0)
 		throw_from_errno("error waiting for edge events");
@@ -204,13 +204,13 @@ GPIOD_CXX_API bool line_request::wait_edge_event(const ::std::chrono::nanosecond
 	return ret;
 }
 
-GPIOD_CXX_API ::std::size_t line_request::read_edge_event(edge_event_buffer& buffer)
+GPIOD_CXX_API ::std::size_t line_request::read_edge_events(edge_event_buffer& buffer)
 {
-	return this->read_edge_event(buffer, buffer.capacity());
+	return this->read_edge_events(buffer, buffer.capacity());
 }
 
 GPIOD_CXX_API ::std::size_t
-line_request::read_edge_event(edge_event_buffer& buffer, ::std::size_t max_events)
+line_request::read_edge_events(edge_event_buffer& buffer, ::std::size_t max_events)
 {
 	this->_m_priv->throw_if_released();
 
diff --git a/bindings/cxx/tests/tests-edge-event.cpp b/bindings/cxx/tests/tests-edge-event.cpp
index ca42c42..19a6ab3 100644
--- a/bindings/cxx/tests/tests-edge-event.cpp
+++ b/bindings/cxx/tests/tests-edge-event.cpp
@@ -51,7 +51,7 @@ TEST_CASE("edge_event wait timeout", "[edge-event]")
 		)
 		.do_request();
 
-	REQUIRE_FALSE(request.wait_edge_event(::std::chrono::milliseconds(100)));
+	REQUIRE_FALSE(request.wait_edge_events(::std::chrono::milliseconds(100)));
 }
 
 TEST_CASE("output mode and edge detection don't work together", "[edge-event]")
@@ -113,23 +113,23 @@ TEST_CASE("waiting for and reading edge events works", "[edge-event]")
 
 		::std::thread thread(trigger_falling_and_rising_edge, ::std::ref(sim), 2);
 
-		REQUIRE(request.wait_edge_event(::std::chrono::seconds(1)));
-		REQUIRE(request.read_edge_event(buffer, 1) == 1);
+		REQUIRE(request.wait_edge_events(::std::chrono::seconds(1)));
+		REQUIRE(request.read_edge_events(buffer, 1) == 1);
 		REQUIRE(buffer.num_events() == 1);
 		auto event = buffer.get_event(0);
 		REQUIRE(event.type() == event_type::RISING_EDGE);
 		REQUIRE(event.line_offset() == 2);
 		ts_rising = event.timestamp_ns();
 
-		REQUIRE(request.wait_edge_event(::std::chrono::seconds(1)));
-		REQUIRE(request.read_edge_event(buffer, 1) == 1);
+		REQUIRE(request.wait_edge_events(::std::chrono::seconds(1)));
+		REQUIRE(request.read_edge_events(buffer, 1) == 1);
 		REQUIRE(buffer.num_events() == 1);
 		event = buffer.get_event(0);
 		REQUIRE(event.type() == event_type::FALLING_EDGE);
 		REQUIRE(event.line_offset() == 2);
 		ts_falling = event.timestamp_ns();
 
-		REQUIRE_FALSE(request.wait_edge_event(::std::chrono::milliseconds(100)));
+		REQUIRE_FALSE(request.wait_edge_events(::std::chrono::milliseconds(100)));
 
 		thread.join();
 
@@ -149,14 +149,14 @@ TEST_CASE("waiting for and reading edge events works", "[edge-event]")
 
 		::std::thread thread(trigger_falling_and_rising_edge, ::std::ref(sim), 6);
 
-		REQUIRE(request.wait_edge_event(::std::chrono::seconds(1)));
-		REQUIRE(request.read_edge_event(buffer, 1) == 1);
+		REQUIRE(request.wait_edge_events(::std::chrono::seconds(1)));
+		REQUIRE(request.read_edge_events(buffer, 1) == 1);
 		REQUIRE(buffer.num_events() == 1);
 		auto event = buffer.get_event(0);
 		REQUIRE(event.type() == event_type::RISING_EDGE);
 		REQUIRE(event.line_offset() == 6);
 
-		REQUIRE_FALSE(request.wait_edge_event(::std::chrono::milliseconds(100)));
+		REQUIRE_FALSE(request.wait_edge_events(::std::chrono::milliseconds(100)));
 
 		thread.join();
 	}
@@ -174,14 +174,14 @@ TEST_CASE("waiting for and reading edge events works", "[edge-event]")
 
 		::std::thread thread(trigger_falling_and_rising_edge, ::std::ref(sim), 7);
 
-		REQUIRE(request.wait_edge_event(::std::chrono::seconds(1)));
-		REQUIRE(request.read_edge_event(buffer, 1) == 1);
+		REQUIRE(request.wait_edge_events(::std::chrono::seconds(1)));
+		REQUIRE(request.read_edge_events(buffer, 1) == 1);
 		REQUIRE(buffer.num_events() == 1);
 		auto event = buffer.get_event(0);
 		REQUIRE(event.type() == event_type::FALLING_EDGE);
 		REQUIRE(event.line_offset() == 7);
 
-		REQUIRE_FALSE(request.wait_edge_event(::std::chrono::milliseconds(100)));
+		REQUIRE_FALSE(request.wait_edge_events(::std::chrono::milliseconds(100)));
 
 		thread.join();
 	}
@@ -199,8 +199,8 @@ TEST_CASE("waiting for and reading edge events works", "[edge-event]")
 
 		::std::thread thread(trigger_rising_edge_events_on_two_offsets, ::std::ref(sim), 0, 1);
 
-		REQUIRE(request.wait_edge_event(::std::chrono::seconds(1)));
-		REQUIRE(request.read_edge_event(buffer, 1) == 1);
+		REQUIRE(request.wait_edge_events(::std::chrono::seconds(1)));
+		REQUIRE(request.read_edge_events(buffer, 1) == 1);
 		REQUIRE(buffer.num_events() == 1);
 		auto event = buffer.get_event(0);
 		REQUIRE(event.type() == event_type::RISING_EDGE);
@@ -208,8 +208,8 @@ TEST_CASE("waiting for and reading edge events works", "[edge-event]")
 		REQUIRE(event.global_seqno() == 1);
 		REQUIRE(event.line_seqno() == 1);
 
-		REQUIRE(request.wait_edge_event(::std::chrono::seconds(1)));
-		REQUIRE(request.read_edge_event(buffer, 1) == 1);
+		REQUIRE(request.wait_edge_events(::std::chrono::seconds(1)));
+		REQUIRE(request.read_edge_events(buffer, 1) == 1);
 		REQUIRE(buffer.num_events() == 1);
 		event = buffer.get_event(0);
 		REQUIRE(event.type() == event_type::RISING_EDGE);
@@ -251,8 +251,8 @@ TEST_CASE("reading multiple events", "[edge-event]")
 	{
 		::gpiod::edge_event_buffer buffer;
 
-		REQUIRE(request.wait_edge_event(::std::chrono::seconds(1)));
-		REQUIRE(request.read_edge_event(buffer) == 3);
+		REQUIRE(request.wait_edge_events(::std::chrono::seconds(1)));
+		REQUIRE(request.read_edge_events(buffer) == 3);
 		REQUIRE(buffer.num_events() == 3);
 
 		for (const auto& event: buffer) {
@@ -266,8 +266,8 @@ TEST_CASE("reading multiple events", "[edge-event]")
 	{
 		::gpiod::edge_event_buffer buffer(2);
 
-		REQUIRE(request.wait_edge_event(::std::chrono::seconds(1)));
-		REQUIRE(request.read_edge_event(buffer) == 2);
+		REQUIRE(request.wait_edge_events(::std::chrono::seconds(1)));
+		REQUIRE(request.read_edge_events(buffer) == 2);
 		REQUIRE(buffer.num_events() == 2);
 	}
 }
@@ -300,8 +300,8 @@ TEST_CASE("edge_event_buffer can be moved", "[edge-event]")
 
 	::std::this_thread::sleep_for(::std::chrono::milliseconds(500));
 
-	REQUIRE(request.wait_edge_event(::std::chrono::seconds(1)));
-	REQUIRE(request.read_edge_event(buffer) == 3);
+	REQUIRE(request.wait_edge_events(::std::chrono::seconds(1)));
+	REQUIRE(request.read_edge_events(buffer) == 3);
 
 	SECTION("move constructor works")
 	{
@@ -337,14 +337,14 @@ TEST_CASE("edge_event can be copied and moved", "[edge-event]")
 
 	sim.set_pull(0, pull::PULL_UP);
 	::std::this_thread::sleep_for(::std::chrono::milliseconds(10));
-	REQUIRE(request.wait_edge_event(::std::chrono::seconds(1)));
-	REQUIRE(request.read_edge_event(buffer) == 1);
+	REQUIRE(request.wait_edge_events(::std::chrono::seconds(1)));
+	REQUIRE(request.read_edge_events(buffer) == 1);
 	auto event = buffer.get_event(0);
 
 	sim.set_pull(0, pull::PULL_DOWN);
 	::std::this_thread::sleep_for(::std::chrono::milliseconds(10));
-	REQUIRE(request.wait_edge_event(::std::chrono::seconds(1)));
-	REQUIRE(request.read_edge_event(buffer) == 1);
+	REQUIRE(request.wait_edge_events(::std::chrono::seconds(1)));
+	REQUIRE(request.read_edge_events(buffer) == 1);
 	auto copy = buffer.get_event(0);
 
 	SECTION("copy constructor works")
@@ -406,8 +406,8 @@ TEST_CASE("stream insertion operators work for edge_event and edge_event_buffer"
 	sim.set_pull(0, pull::PULL_DOWN);
 	::std::this_thread::sleep_for(::std::chrono::milliseconds(30));
 
-	REQUIRE(request.wait_edge_event(::std::chrono::seconds(1)));
-	REQUIRE(request.read_edge_event(buffer) == 2);
+	REQUIRE(request.wait_edge_events(::std::chrono::seconds(1)));
+	REQUIRE(request.read_edge_events(buffer) == 2);
 
 	sbuf << buffer;
 
diff --git a/bindings/python/examples/gpiomon.py b/bindings/python/examples/gpiomon.py
index 58d47a5..702d7c8 100755
--- a/bindings/python/examples/gpiomon.py
+++ b/bindings/python/examples/gpiomon.py
@@ -22,5 +22,5 @@ if __name__ == "__main__":
         config={tuple(lines): gpiod.LineSettings(edge_detection=Edge.BOTH)},
     ) as request:
         while True:
-            for event in request.read_edge_event():
+            for event in request.read_edge_events():
                 print(event)
diff --git a/bindings/python/gpiod/ext/request.c b/bindings/python/gpiod/ext/request.c
index 62378f5..d3e1448 100644
--- a/bindings/python/gpiod/ext/request.c
+++ b/bindings/python/gpiod/ext/request.c
@@ -249,7 +249,7 @@ static PyObject *request_reconfigure_lines(request_object *self, PyObject *args)
 	Py_RETURN_NONE;
 }
 
-static PyObject *request_read_edge_event(request_object *self, PyObject *args)
+static PyObject *request_read_edge_events(request_object *self, PyObject *args)
 {
 	PyObject *max_events_obj, *event_obj, *events, *type;
 	size_t max_events, num_events, i;
@@ -273,7 +273,7 @@ static PyObject *request_read_edge_event(request_object *self, PyObject *args)
 		return NULL;
 
 	Py_BEGIN_ALLOW_THREADS;
-	ret = gpiod_line_request_read_edge_event(self->request,
+	ret = gpiod_line_request_read_edge_events(self->request,
 						 self->buffer, max_events);
 	Py_END_ALLOW_THREADS;
 	if (ret < 0)
@@ -336,8 +336,8 @@ static PyMethodDef request_methods[] = {
 		.ml_flags = METH_VARARGS,
 	},
 	{
-		.ml_name = "read_edge_event",
-		.ml_meth = (PyCFunction)request_read_edge_event,
+		.ml_name = "read_edge_events",
+		.ml_meth = (PyCFunction)request_read_edge_events,
 		.ml_flags = METH_VARARGS,
 	},
 	{ }
diff --git a/bindings/python/gpiod/line_request.py b/bindings/python/gpiod/line_request.py
index 1796069..a0f97b7 100644
--- a/bindings/python/gpiod/line_request.py
+++ b/bindings/python/gpiod/line_request.py
@@ -169,7 +169,7 @@ class LineRequest:
 
         self._req.reconfigure_lines(line_cfg)
 
-    def wait_edge_event(
+    def wait_edge_events(
         self, timeout: Optional[Union[timedelta, float]] = None
     ) -> bool:
         """
@@ -187,7 +187,7 @@ class LineRequest:
 
         return poll_fd(self.fd, timeout)
 
-    def read_edge_event(self, max_events: Optional[int] = None) -> list[EdgeEvent]:
+    def read_edge_events(self, max_events: Optional[int] = None) -> list[EdgeEvent]:
         """
         Read a number of edge events from a line request.
 
@@ -200,7 +200,7 @@ class LineRequest:
         """
         self._check_released()
 
-        return self._req.read_edge_event(max_events)
+        return self._req.read_edge_events(max_events)
 
     def __str__(self):
         """
diff --git a/bindings/python/tests/tests_edge_event.py b/bindings/python/tests/tests_edge_event.py
index c443772..430b27d 100644
--- a/bindings/python/tests/tests_edge_event.py
+++ b/bindings/python/tests/tests_edge_event.py
@@ -23,7 +23,7 @@ class EdgeEventWaitTimeout(TestCase):
             sim.dev_path,
             {0: gpiod.LineSettings(edge_detection=Edge.BOTH)},
         ) as req:
-            self.assertEqual(req.wait_edge_event(timedelta(microseconds=10000)), False)
+            self.assertEqual(req.wait_edge_events(timedelta(microseconds=10000)), False)
 
     def test_event_wait_timeout_float(self):
         sim = gpiosim.Chip()
@@ -32,7 +32,7 @@ class EdgeEventWaitTimeout(TestCase):
             sim.dev_path,
             {0: gpiod.LineSettings(edge_detection=Edge.BOTH)},
         ) as req:
-            self.assertEqual(req.wait_edge_event(0.01), False)
+            self.assertEqual(req.wait_edge_events(0.01), False)
 
 
 class EdgeEventInvalidConfig(TestCase):
@@ -82,16 +82,16 @@ class WaitingForEdgeEvents(TestCase):
             )
             self.thread.start()
 
-            self.assertTrue(req.wait_edge_event(timedelta(seconds=1)))
-            events = req.read_edge_event()
+            self.assertTrue(req.wait_edge_events(timedelta(seconds=1)))
+            events = req.read_edge_events()
             self.assertEqual(len(events), 1)
             event = events[0]
             self.assertEqual(event.event_type, EventType.RISING_EDGE)
             self.assertEqual(event.line_offset, 2)
             ts_rising = event.timestamp_ns
 
-            self.assertTrue(req.wait_edge_event(timedelta(seconds=1)))
-            events = req.read_edge_event()
+            self.assertTrue(req.wait_edge_events(timedelta(seconds=1)))
+            events = req.read_edge_events()
             self.assertEqual(len(events), 1)
             event = events[0]
             self.assertEqual(event.event_type, EventType.FALLING_EDGE)
@@ -109,14 +109,14 @@ class WaitingForEdgeEvents(TestCase):
             )
             self.thread.start()
 
-            self.assertTrue(req.wait_edge_event(timedelta(seconds=1)))
-            events = req.read_edge_event()
+            self.assertTrue(req.wait_edge_events(timedelta(seconds=1)))
+            events = req.read_edge_events()
             self.assertEqual(len(events), 1)
             event = events[0]
             self.assertEqual(event.event_type, EventType.RISING_EDGE)
             self.assertEqual(event.line_offset, 6)
 
-            self.assertFalse(req.wait_edge_event(timedelta(microseconds=10000)))
+            self.assertFalse(req.wait_edge_events(timedelta(microseconds=10000)))
 
     def test_rising_edge_event(self):
         with gpiod.request_lines(
@@ -127,14 +127,14 @@ class WaitingForEdgeEvents(TestCase):
             )
             self.thread.start()
 
-            self.assertTrue(req.wait_edge_event(timedelta(seconds=1)))
-            events = req.read_edge_event()
+            self.assertTrue(req.wait_edge_events(timedelta(seconds=1)))
+            events = req.read_edge_events()
             self.assertEqual(len(events), 1)
             event = events[0]
             self.assertEqual(event.event_type, EventType.FALLING_EDGE)
             self.assertEqual(event.line_offset, 6)
 
-            self.assertFalse(req.wait_edge_event(timedelta(microseconds=10000)))
+            self.assertFalse(req.wait_edge_events(timedelta(microseconds=10000)))
 
     def test_sequence_numbers(self):
         with gpiod.request_lines(
@@ -145,8 +145,8 @@ class WaitingForEdgeEvents(TestCase):
             )
             self.thread.start()
 
-            self.assertTrue(req.wait_edge_event(timedelta(seconds=1)))
-            events = req.read_edge_event()
+            self.assertTrue(req.wait_edge_events(timedelta(seconds=1)))
+            events = req.read_edge_events()
             self.assertEqual(len(events), 1)
             event = events[0]
             self.assertEqual(event.event_type, EventType.RISING_EDGE)
@@ -154,8 +154,8 @@ class WaitingForEdgeEvents(TestCase):
             self.assertEqual(event.global_seqno, 1)
             self.assertEqual(event.line_seqno, 1)
 
-            self.assertTrue(req.wait_edge_event(timedelta(seconds=1)))
-            events = req.read_edge_event()
+            self.assertTrue(req.wait_edge_events(timedelta(seconds=1)))
+            events = req.read_edge_events()
             self.assertEqual(len(events), 1)
             event = events[0]
             self.assertEqual(event.event_type, EventType.RISING_EDGE)
@@ -185,8 +185,8 @@ class ReadingMultipleEdgeEvents(TestCase):
         del self.sim
 
     def test_read_multiple_events(self):
-        self.assertTrue(self.request.wait_edge_event(timedelta(seconds=1)))
-        events = self.request.read_edge_event()
+        self.assertTrue(self.request.wait_edge_events(timedelta(seconds=1)))
+        events = self.request.read_edge_events()
         self.assertEqual(len(events), 3)
 
         for event in events:
@@ -205,7 +205,7 @@ class EdgeEventStringRepresentation(TestCase):
             path=sim.dev_path, config={0: gpiod.LineSettings(edge_detection=Edge.BOTH)}
         ) as req:
             sim.set_pull(0, Pull.UP)
-            event = req.read_edge_event()[0]
+            event = req.read_edge_events()[0]
             self.assertRegex(
                 str(event),
                 "<EdgeEvent type=Type\.RISING_EDGE timestamp_ns=[0-9]+ line_offset=0 global_seqno=1 line_seqno=1>",
diff --git a/bindings/rust/libgpiod/examples/gpio_events.rs b/bindings/rust/libgpiod/examples/gpio_events.rs
index 9810050..04267d9 100644
--- a/bindings/rust/libgpiod/examples/gpio_events.rs
+++ b/bindings/rust/libgpiod/examples/gpio_events.rs
@@ -45,7 +45,7 @@ fn main() -> Result<()> {
     let request = chip.request_lines(&rconfig, &lconfig)?;
 
     loop {
-        match request.wait_edge_event(None) {
+        match request.wait_edge_events(None) {
             Err(x) => {
                 println!("{:?}", x);
                 return Err(Error::InvalidArguments);
diff --git a/bindings/rust/libgpiod/examples/gpiomon.rs b/bindings/rust/libgpiod/examples/gpiomon.rs
index c38652c..f17a81f 100644
--- a/bindings/rust/libgpiod/examples/gpiomon.rs
+++ b/bindings/rust/libgpiod/examples/gpiomon.rs
@@ -44,7 +44,7 @@ fn main() -> Result<()> {
     let request = chip.request_lines(&rconfig, &lconfig)?;
 
     loop {
-        match request.wait_edge_event(None) {
+        match request.wait_edge_events(None) {
             Err(x) => {
                 println!("{:?}", x);
                 return Err(Error::InvalidArguments);
diff --git a/bindings/rust/libgpiod/src/event_buffer.rs b/bindings/rust/libgpiod/src/event_buffer.rs
index b56be9a..5a72ddb 100644
--- a/bindings/rust/libgpiod/src/event_buffer.rs
+++ b/bindings/rust/libgpiod/src/event_buffer.rs
@@ -106,7 +106,7 @@ impl Buffer {
 
         // SAFETY: `gpiod_line_request` is guaranteed to be valid here.
         let ret = unsafe {
-            gpiod::gpiod_line_request_read_edge_event(
+            gpiod::gpiod_line_request_read_edge_events(
                 request.request,
                 self.buffer,
                 self.events.len().try_into().unwrap(),
diff --git a/bindings/rust/libgpiod/src/line_request.rs b/bindings/rust/libgpiod/src/line_request.rs
index 3215ab8..c16ec9f 100644
--- a/bindings/rust/libgpiod/src/line_request.rs
+++ b/bindings/rust/libgpiod/src/line_request.rs
@@ -178,7 +178,7 @@ impl Request {
     }
 
     /// Wait for edge events on any of the lines associated with the request.
-    pub fn wait_edge_event(&self, timeout: Option<Duration>) -> Result<bool> {
+    pub fn wait_edge_events(&self, timeout: Option<Duration>) -> Result<bool> {
         let timeout = match timeout {
             Some(x) => x.as_nanos() as i64,
             // Block indefinitely
@@ -186,7 +186,7 @@ impl Request {
         };
 
         // SAFETY: `gpiod_line_request` is guaranteed to be valid here.
-        let ret = unsafe { gpiod::gpiod_line_request_wait_edge_event(self.request, timeout) };
+        let ret = unsafe { gpiod::gpiod_line_request_wait_edge_events(self.request, timeout) };
 
         match ret {
             -1 => Err(Error::OperationFailed(
diff --git a/bindings/rust/libgpiod/tests/edge_event.rs b/bindings/rust/libgpiod/tests/edge_event.rs
index 571e574..45c1cfc 100644
--- a/bindings/rust/libgpiod/tests/edge_event.rs
+++ b/bindings/rust/libgpiod/tests/edge_event.rs
@@ -89,7 +89,7 @@ mod edge_event {
             // Rising event
             assert!(config
                 .request()
-                .wait_edge_event(Some(Duration::from_secs(1)))
+                .wait_edge_events(Some(Duration::from_secs(1)))
                 .unwrap());
 
             let mut events = config.request().read_edge_events(&mut buf).unwrap();
@@ -103,7 +103,7 @@ mod edge_event {
             // Falling event
             assert!(config
                 .request()
-                .wait_edge_event(Some(Duration::from_secs(1)))
+                .wait_edge_events(Some(Duration::from_secs(1)))
                 .unwrap());
 
             let mut events = config.request().read_edge_events(&mut buf).unwrap();
@@ -117,7 +117,7 @@ mod edge_event {
             // No events available
             assert!(!config
                 .request()
-                .wait_edge_event(Some(Duration::from_millis(100)))
+                .wait_edge_events(Some(Duration::from_millis(100)))
                 .unwrap());
 
             assert!(ts_falling > ts_rising);
@@ -138,7 +138,7 @@ mod edge_event {
             // Rising event
             assert!(config
                 .request()
-                .wait_edge_event(Some(Duration::from_secs(1)))
+                .wait_edge_events(Some(Duration::from_secs(1)))
                 .unwrap());
 
             let mut events = config.request().read_edge_events(&mut buf).unwrap();
@@ -151,7 +151,7 @@ mod edge_event {
             // No events available
             assert!(!config
                 .request()
-                .wait_edge_event(Some(Duration::from_millis(100)))
+                .wait_edge_events(Some(Duration::from_millis(100)))
                 .unwrap());
         }
 
@@ -170,7 +170,7 @@ mod edge_event {
             // Falling event
             assert!(config
                 .request()
-                .wait_edge_event(Some(Duration::from_secs(1)))
+                .wait_edge_events(Some(Duration::from_secs(1)))
                 .unwrap());
 
             let mut events = config.request().read_edge_events(&mut buf).unwrap();
@@ -183,7 +183,7 @@ mod edge_event {
             // No events available
             assert!(!config
                 .request()
-                .wait_edge_event(Some(Duration::from_millis(100)))
+                .wait_edge_events(Some(Duration::from_millis(100)))
                 .unwrap());
         }
 
@@ -202,7 +202,7 @@ mod edge_event {
             let mut buf = request::Buffer::new(0).unwrap();
             assert!(config
                 .request()
-                .wait_edge_event(Some(Duration::from_secs(1)))
+                .wait_edge_events(Some(Duration::from_secs(1)))
                 .unwrap());
 
             let mut events = config.request().read_edge_events(&mut buf).unwrap();
@@ -217,7 +217,7 @@ mod edge_event {
             // Rising event GPIO 1
             assert!(config
                 .request()
-                .wait_edge_event(Some(Duration::from_secs(1)))
+                .wait_edge_events(Some(Duration::from_secs(1)))
                 .unwrap());
 
             let mut events = config.request().read_edge_events(&mut buf).unwrap();
@@ -232,7 +232,7 @@ mod edge_event {
             // No events available
             assert!(!config
                 .request()
-                .wait_edge_event(Some(Duration::from_millis(100)))
+                .wait_edge_events(Some(Duration::from_millis(100)))
                 .unwrap());
         }
 
@@ -251,7 +251,7 @@ mod edge_event {
             // Read multiple events
             assert!(config
                 .request()
-                .wait_edge_event(Some(Duration::from_secs(1)))
+                .wait_edge_events(Some(Duration::from_secs(1)))
                 .unwrap());
 
             let events = config.request().read_edge_events(&mut buf).unwrap();
@@ -287,7 +287,7 @@ mod edge_event {
             // Read multiple events
             assert!(config
                 .request()
-                .wait_edge_event(Some(Duration::from_secs(1)))
+                .wait_edge_events(Some(Duration::from_secs(1)))
                 .unwrap());
 
             let events = config.request().read_edge_events(&mut buf).unwrap();
diff --git a/bindings/rust/libgpiod/tests/line_request.rs b/bindings/rust/libgpiod/tests/line_request.rs
index 286cd6c..c3fc37b 100644
--- a/bindings/rust/libgpiod/tests/line_request.rs
+++ b/bindings/rust/libgpiod/tests/line_request.rs
@@ -231,7 +231,7 @@ mod line_request {
             // No events available
             assert!(!config
                 .request()
-                .wait_edge_event(Some(Duration::from_millis(100)))
+                .wait_edge_events(Some(Duration::from_millis(100)))
                 .unwrap());
         }
     }
diff --git a/include/gpiod.h b/include/gpiod.h
index f4bb5f2..fc9d4c0 100644
--- a/include/gpiod.h
+++ b/include/gpiod.h
@@ -1008,8 +1008,8 @@ int gpiod_line_request_get_fd(struct gpiod_line_request *request);
  * Lines must have edge detection set for edge events to be emitted.
  * By default edge detection is disabled.
  */
-int gpiod_line_request_wait_edge_event(struct gpiod_line_request *request,
-				       int64_t timeout_ns);
+int gpiod_line_request_wait_edge_events(struct gpiod_line_request *request,
+					int64_t timeout_ns);
 
 /**
  * @brief Read a number of edge events from a line request.
@@ -1022,9 +1022,9 @@ int gpiod_line_request_wait_edge_event(struct gpiod_line_request *request,
  * @note Any exising events in the buffer are overwritten.  This is not an
  *       append operation.
  */
-int gpiod_line_request_read_edge_event(struct gpiod_line_request *request,
-				       struct gpiod_edge_event_buffer *buffer,
-				       size_t max_events);
+int gpiod_line_request_read_edge_events(struct gpiod_line_request *request,
+					struct gpiod_edge_event_buffer *buffer,
+					size_t max_events);
 
 /**
  * @}
diff --git a/lib/line-request.c b/lib/line-request.c
index 5936593..58dc3c9 100644
--- a/lib/line-request.c
+++ b/lib/line-request.c
@@ -223,16 +223,16 @@ GPIOD_API int gpiod_line_request_get_fd(struct gpiod_line_request *request)
 }
 
 GPIOD_API int
-gpiod_line_request_wait_edge_event(struct gpiod_line_request *request,
-				   int64_t timeout_ns)
+gpiod_line_request_wait_edge_events(struct gpiod_line_request *request,
+				    int64_t timeout_ns)
 {
 	return gpiod_poll_fd(request->fd, timeout_ns);
 }
 
 GPIOD_API int
-gpiod_line_request_read_edge_event(struct gpiod_line_request *request,
-				   struct gpiod_edge_event_buffer *buffer,
-				   size_t max_events)
+gpiod_line_request_read_edge_events(struct gpiod_line_request *request,
+				    struct gpiod_edge_event_buffer *buffer,
+				    size_t max_events)
 {
 	return gpiod_edge_event_buffer_read_fd(request->fd, buffer, max_events);
 }
diff --git a/tests/tests-edge-event.c b/tests/tests-edge-event.c
index 5eb275c..b9e29b2 100644
--- a/tests/tests-edge-event.c
+++ b/tests/tests-edge-event.c
@@ -51,7 +51,7 @@ GPIOD_TEST_CASE(edge_event_wait_timeout)
 
 	request = gpiod_test_request_lines_or_fail(chip, NULL, line_cfg);
 
-	ret = gpiod_line_request_wait_edge_event(request, 1000000);
+	ret = gpiod_line_request_wait_edge_events(request, 1000000);
 	g_assert_cmpint(ret, ==, 0);
 }
 
@@ -130,11 +130,11 @@ GPIOD_TEST_CASE(read_both_events)
 
 	/* First event. */
 
-	ret = gpiod_line_request_wait_edge_event(request, 1000000000);
+	ret = gpiod_line_request_wait_edge_events(request, 1000000000);
 	g_assert_cmpint(ret, >, 0);
 	gpiod_test_join_thread_and_return_if_failed(thread);
 
-	ret = gpiod_line_request_read_edge_event(request, buffer, 1);
+	ret = gpiod_line_request_read_edge_events(request, buffer, 1);
 	g_assert_cmpint(ret, ==, 1);
 	gpiod_test_join_thread_and_return_if_failed(thread);
 
@@ -150,11 +150,11 @@ GPIOD_TEST_CASE(read_both_events)
 
 	/* Second event. */
 
-	ret = gpiod_line_request_wait_edge_event(request, 1000000000);
+	ret = gpiod_line_request_wait_edge_events(request, 1000000000);
 	g_assert_cmpint(ret, >, 0);
 	gpiod_test_join_thread_and_return_if_failed(thread);
 
-	ret = gpiod_line_request_read_edge_event(request, buffer, 1);
+	ret = gpiod_line_request_read_edge_events(request, buffer, 1);
 	g_assert_cmpint(ret, ==, 1);
 	gpiod_test_join_thread_and_return_if_failed(thread);
 
@@ -207,11 +207,11 @@ GPIOD_TEST_CASE(read_rising_edge_event)
 
 	/* First event. */
 
-	ret = gpiod_line_request_wait_edge_event(request, 1000000000);
+	ret = gpiod_line_request_wait_edge_events(request, 1000000000);
 	g_assert_cmpint(ret, >, 0);
 	gpiod_test_join_thread_and_return_if_failed(thread);
 
-	ret = gpiod_line_request_read_edge_event(request, buffer, 1);
+	ret = gpiod_line_request_read_edge_events(request, buffer, 1);
 	g_assert_cmpint(ret, ==, 1);
 	gpiod_test_join_thread_and_return_if_failed(thread);
 
@@ -226,7 +226,7 @@ GPIOD_TEST_CASE(read_rising_edge_event)
 
 	/* Second event. */
 
-	ret = gpiod_line_request_wait_edge_event(request, 1000000);
+	ret = gpiod_line_request_wait_edge_events(request, 1000000);
 	g_assert_cmpint(ret, ==, 0); /* Time-out. */
 
 	g_thread_join(thread);
@@ -266,11 +266,11 @@ GPIOD_TEST_CASE(read_falling_edge_event)
 
 	/* First event is the second generated. */
 
-	ret = gpiod_line_request_wait_edge_event(request, 1000000000);
+	ret = gpiod_line_request_wait_edge_events(request, 1000000000);
 	g_assert_cmpint(ret, >, 0);
 	gpiod_test_join_thread_and_return_if_failed(thread);
 
-	ret = gpiod_line_request_read_edge_event(request, buffer, 1);
+	ret = gpiod_line_request_read_edge_events(request, buffer, 1);
 	g_assert_cmpint(ret, ==, 1);
 	gpiod_test_join_thread_and_return_if_failed(thread);
 
@@ -285,7 +285,7 @@ GPIOD_TEST_CASE(read_falling_edge_event)
 
 	/* No more events. */
 
-	ret = gpiod_line_request_wait_edge_event(request, 1000000);
+	ret = gpiod_line_request_wait_edge_events(request, 1000000);
 	g_assert_cmpint(ret, ==, 0); /* Time-out. */
 
 	g_thread_join(thread);
@@ -340,7 +340,7 @@ GPIOD_TEST_CASE(read_rising_edge_event_polled)
 	g_assert_cmpint(ret, >, 0);
 	gpiod_test_join_thread_and_return_if_failed(thread);
 
-	ret = gpiod_line_request_read_edge_event(request, buffer, 1);
+	ret = gpiod_line_request_read_edge_events(request, buffer, 1);
 	g_assert_cmpint(ret, ==, 1);
 	gpiod_test_join_thread_and_return_if_failed(thread);
 
@@ -355,7 +355,7 @@ GPIOD_TEST_CASE(read_rising_edge_event_polled)
 
 	/* Second event. */
 
-	ret = gpiod_line_request_wait_edge_event(request, 1000000);
+	ret = gpiod_line_request_wait_edge_events(request, 1000000);
 	g_assert_cmpint(ret, ==, 0); /* Time-out. */
 
 	g_thread_join(thread);
@@ -399,7 +399,7 @@ GPIOD_TEST_CASE(read_both_events_blocking)
 
 	/* First event. */
 
-	ret = gpiod_line_request_read_edge_event(request, buffer, 1);
+	ret = gpiod_line_request_read_edge_events(request, buffer, 1);
 	g_assert_cmpint(ret, ==, 1);
 	gpiod_test_join_thread_and_return_if_failed(thread);
 
@@ -414,7 +414,7 @@ GPIOD_TEST_CASE(read_both_events_blocking)
 
 	/* Second event. */
 
-	ret = gpiod_line_request_read_edge_event(request, buffer, 1);
+	ret = gpiod_line_request_read_edge_events(request, buffer, 1);
 	g_assert_cmpint(ret, ==, 1);
 	gpiod_test_join_thread_and_return_if_failed(thread);
 
@@ -478,11 +478,11 @@ GPIOD_TEST_CASE(seqno)
 
 	/* First event. */
 
-	ret = gpiod_line_request_wait_edge_event(request, 1000000000);
+	ret = gpiod_line_request_wait_edge_events(request, 1000000000);
 	g_assert_cmpint(ret, >, 0);
 	gpiod_test_join_thread_and_return_if_failed(thread);
 
-	ret = gpiod_line_request_read_edge_event(request, buffer, 1);
+	ret = gpiod_line_request_read_edge_events(request, buffer, 1);
 	g_assert_cmpint(ret, ==, 1);
 	gpiod_test_join_thread_and_return_if_failed(thread);
 
@@ -497,11 +497,11 @@ GPIOD_TEST_CASE(seqno)
 
 	/* Second event. */
 
-	ret = gpiod_line_request_wait_edge_event(request, 1000000000);
+	ret = gpiod_line_request_wait_edge_events(request, 1000000000);
 	g_assert_cmpint(ret, >, 0);
 	gpiod_test_join_thread_and_return_if_failed(thread);
 
-	ret = gpiod_line_request_read_edge_event(request, buffer, 1);
+	ret = gpiod_line_request_read_edge_events(request, buffer, 1);
 	g_assert_cmpint(ret, ==, 1);
 	gpiod_test_join_thread_and_return_if_failed(thread);
 
@@ -545,11 +545,11 @@ GPIOD_TEST_CASE(event_copy)
 
 	g_gpiosim_chip_set_pull(sim, 2, G_GPIOSIM_PULL_UP);
 
-	ret = gpiod_line_request_wait_edge_event(request, 1000000000);
+	ret = gpiod_line_request_wait_edge_events(request, 1000000000);
 	g_assert_cmpint(ret, >, 0);
 	gpiod_test_return_if_failed();
 
-	ret = gpiod_line_request_read_edge_event(request, buffer, 1);
+	ret = gpiod_line_request_read_edge_events(request, buffer, 1);
 	g_assert_cmpint(ret, ==, 1);
 	gpiod_test_return_if_failed();
 
@@ -603,11 +603,11 @@ GPIOD_TEST_CASE(reading_more_events_than_the_queue_contains_doesnt_block)
 	g_gpiosim_chip_set_pull(sim, 2, G_GPIOSIM_PULL_UP);
 	g_usleep(500);
 
-	ret = gpiod_line_request_read_edge_event(request, buffer, 12);
+	ret = gpiod_line_request_read_edge_events(request, buffer, 12);
 	g_assert_cmpint(ret, ==, 7);
 	gpiod_test_return_if_failed();
 
-	ret = gpiod_line_request_wait_edge_event(request, 1000);
+	ret = gpiod_line_request_wait_edge_events(request, 1000);
 	g_assert_cmpint(ret, ==, 0);
 	gpiod_test_return_if_failed();
 }
diff --git a/tools/gpiomon.c b/tools/gpiomon.c
index ba457e4..0bc057a 100644
--- a/tools/gpiomon.c
+++ b/tools/gpiomon.c
@@ -451,7 +451,7 @@ int main(int argc, char **argv)
 			if (pollfds[i].revents == 0)
 				continue;
 
-			ret = gpiod_line_request_read_edge_event(requests[i],
+			ret = gpiod_line_request_read_edge_events(requests[i],
 					 event_buffer, EVENT_BUF_SIZE);
 			if (ret < 0)
 				die_perror("error reading line events");
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [libgpiod][PATCH 04/11] treewide: rename EVENT_CLOCK to CLOCK
  2022-11-30 12:42 [libgpiod][PATCH 00/11] treewide: an assortment of tweaks and improvements Bartosz Golaszewski
                   ` (2 preceding siblings ...)
  2022-11-30 12:42 ` [libgpiod][PATCH 03/11] treewide: use plural 'events' in read_edge_event() functions Bartosz Golaszewski
@ 2022-11-30 12:42 ` Bartosz Golaszewski
  2022-12-01  2:09   ` Viresh Kumar
  2022-11-30 12:42 ` [libgpiod][PATCH 05/11] gpiosim: rename HOG_DIR to DIRECTION Bartosz Golaszewski
                   ` (7 subsequent siblings)
  11 siblings, 1 reply; 28+ messages in thread
From: Bartosz Golaszewski @ 2022-11-30 12:42 UTC (permalink / raw)
  To: Kent Gibson, Linus Walleij, Andy Shevchenko, Viresh Kumar
  Cc: linux-gpio, Bartosz Golaszewski

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

While we use it for edge event timestamps exclusively at the moment,
the actual enum names shouldn't limit its application and simply just
refer to existing clock types known by the GPIO uAPI. The relevant
functions are still called set/get_event_clock() as it's in line with
their functionality.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 bindings/cxx/line-info.cpp                |  6 +++---
 bindings/cxx/line-settings.cpp            | 14 ++++++-------
 bindings/python/gpiod/ext/line-settings.c |  2 +-
 bindings/python/gpiod/ext/module.c        |  6 +++---
 bindings/rust/libgpiod/src/lib.rs         | 22 ++++++++++-----------
 include/gpiod.h                           | 20 +++++++++----------
 lib/line-config.c                         |  4 ++--
 lib/line-info.c                           | 10 +++++-----
 lib/line-settings.c                       | 16 +++++++--------
 tests/tests-line-config.c                 |  2 +-
 tests/tests-line-info.c                   | 12 ++++++------
 tests/tests-line-settings.c               | 24 +++++++++++------------
 tools/gpiomon.c                           | 14 ++++++-------
 tools/tools-common.c                      |  4 ++--
 14 files changed, 78 insertions(+), 78 deletions(-)

diff --git a/bindings/cxx/line-info.cpp b/bindings/cxx/line-info.cpp
index 944e34d..5eb2a3f 100644
--- a/bindings/cxx/line-info.cpp
+++ b/bindings/cxx/line-info.cpp
@@ -37,9 +37,9 @@ const ::std::map<int, line::edge> edge_mapping = {
 };
 
 const ::std::map<int, line::clock> clock_mapping = {
-	{ GPIOD_LINE_EVENT_CLOCK_MONOTONIC,	line::clock::MONOTONIC },
-	{ GPIOD_LINE_EVENT_CLOCK_REALTIME,	line::clock::REALTIME },
-	{ GPIOD_LINE_EVENT_CLOCK_HTE,		line::clock::HTE }
+	{ GPIOD_LINE_CLOCK_MONOTONIC,		line::clock::MONOTONIC },
+	{ GPIOD_LINE_CLOCK_REALTIME,		line::clock::REALTIME },
+	{ GPIOD_LINE_CLOCK_HTE,			line::clock::HTE }
 };
 
 } /* namespace */
diff --git a/bindings/cxx/line-settings.cpp b/bindings/cxx/line-settings.cpp
index 17c5ca2..58860db 100644
--- a/bindings/cxx/line-settings.cpp
+++ b/bindings/cxx/line-settings.cpp
@@ -57,13 +57,13 @@ const ::std::map<line::drive, gpiod_line_drive> drive_mapping = {
 
 const ::std::map<gpiod_line_drive, line::drive> reverse_drive_mapping = make_reverse_maping(drive_mapping);
 
-const ::std::map<line::clock, gpiod_line_event_clock> clock_mapping = {
-	{ line::clock::MONOTONIC,	GPIOD_LINE_EVENT_CLOCK_MONOTONIC },
-	{ line::clock::REALTIME,	GPIOD_LINE_EVENT_CLOCK_REALTIME },
-	{ line::clock::HTE,		GPIOD_LINE_EVENT_CLOCK_HTE }
+const ::std::map<line::clock, gpiod_line_clock> clock_mapping = {
+	{ line::clock::MONOTONIC,	GPIOD_LINE_CLOCK_MONOTONIC },
+	{ line::clock::REALTIME,	GPIOD_LINE_CLOCK_REALTIME },
+	{ line::clock::HTE,		GPIOD_LINE_CLOCK_HTE }
 };
 
-const ::std::map<gpiod_line_event_clock, line::clock>
+const ::std::map<gpiod_line_clock, line::clock>
 reverse_clock_mapping = make_reverse_maping(clock_mapping);
 
 const ::std::map<line::value, gpiod_line_value> value_mapping = {
@@ -257,7 +257,7 @@ GPIOD_CXX_API ::std::chrono::microseconds line_settings::debounce_period() const
 
 GPIOD_CXX_API line_settings& line_settings::set_event_clock(line::clock event_clock)
 {
-	set_mapped_value<line::clock, gpiod_line_event_clock,
+	set_mapped_value<line::clock, gpiod_line_clock,
 			 ::gpiod_line_settings_set_event_clock>(this->_m_priv->settings.get(),
 								event_clock, clock_mapping);
 
@@ -266,7 +266,7 @@ GPIOD_CXX_API line_settings& line_settings::set_event_clock(line::clock event_cl
 
 GPIOD_CXX_API line::clock line_settings::event_clock() const
 {
-	return get_mapped_value<line::clock, gpiod_line_event_clock,
+	return get_mapped_value<line::clock, gpiod_line_clock,
 				::gpiod_line_settings_get_event_clock>(
 							this->_m_priv->settings.get(),
 							reverse_clock_mapping);
diff --git a/bindings/python/gpiod/ext/line-settings.c b/bindings/python/gpiod/ext/line-settings.c
index 8ec1390..2cacbef 100644
--- a/bindings/python/gpiod/ext/line-settings.c
+++ b/bindings/python/gpiod/ext/line-settings.c
@@ -29,7 +29,7 @@ line_settings_init(line_settings_object *self, PyObject *args, PyObject *kwargs)
 		NULL
 	};
 
-	enum gpiod_line_event_clock event_clock;
+	enum gpiod_line_clock event_clock;
 	enum gpiod_line_direction direction;
 	enum gpiod_line_value output_value;
 	unsigned long debounce_period;
diff --git a/bindings/python/gpiod/ext/module.c b/bindings/python/gpiod/ext/module.c
index 8725ef2..12fb92c 100644
--- a/bindings/python/gpiod/ext/module.c
+++ b/bindings/python/gpiod/ext/module.c
@@ -80,15 +80,15 @@ static const struct module_const module_constants[] = {
 	},
 	{
 		.name = "CLOCK_MONOTONIC",
-		.val = GPIOD_LINE_EVENT_CLOCK_MONOTONIC,
+		.val = GPIOD_LINE_CLOCK_MONOTONIC,
 	},
 	{
 		.name = "CLOCK_REALTIME",
-		.val = GPIOD_LINE_EVENT_CLOCK_REALTIME,
+		.val = GPIOD_LINE_CLOCK_REALTIME,
 	},
 	{
 		.name = "CLOCK_HTE",
-		.val = GPIOD_LINE_EVENT_CLOCK_HTE,
+		.val = GPIOD_LINE_CLOCK_HTE,
 	},
 	{
 		.name = "EDGE_EVENT_TYPE_RISING",
diff --git a/bindings/rust/libgpiod/src/lib.rs b/bindings/rust/libgpiod/src/lib.rs
index d7a0615..1b2c765 100644
--- a/bindings/rust/libgpiod/src/lib.rs
+++ b/bindings/rust/libgpiod/src/lib.rs
@@ -45,9 +45,9 @@ use gpiod::{
     gpiod_line_edge_GPIOD_LINE_EDGE_FALLING as GPIOD_LINE_EDGE_FALLING,
     gpiod_line_edge_GPIOD_LINE_EDGE_NONE as GPIOD_LINE_EDGE_NONE,
     gpiod_line_edge_GPIOD_LINE_EDGE_RISING as GPIOD_LINE_EDGE_RISING,
-    gpiod_line_event_clock_GPIOD_LINE_EVENT_CLOCK_HTE as GPIOD_LINE_EVENT_CLOCK_HTE,
-    gpiod_line_event_clock_GPIOD_LINE_EVENT_CLOCK_MONOTONIC as GPIOD_LINE_EVENT_CLOCK_MONOTONIC,
-    gpiod_line_event_clock_GPIOD_LINE_EVENT_CLOCK_REALTIME as GPIOD_LINE_EVENT_CLOCK_REALTIME,
+    gpiod_line_clock_GPIOD_LINE_CLOCK_HTE as GPIOD_LINE_CLOCK_HTE,
+    gpiod_line_clock_GPIOD_LINE_CLOCK_MONOTONIC as GPIOD_LINE_CLOCK_MONOTONIC,
+    gpiod_line_clock_GPIOD_LINE_CLOCK_REALTIME as GPIOD_LINE_CLOCK_REALTIME,
     gpiod_line_value_GPIOD_LINE_VALUE_ACTIVE as GPIOD_LINE_VALUE_ACTIVE,
     gpiod_line_value_GPIOD_LINE_VALUE_INACTIVE as GPIOD_LINE_VALUE_INACTIVE,
     gpiod_line_value_GPIOD_LINE_VALUE_ERROR as GPIOD_LINE_VALUE_ERROR,
@@ -393,20 +393,20 @@ pub mod line {
     }
 
     impl EventClock {
-        pub(crate) fn new(clock: gpiod::gpiod_line_event_clock) -> Result<Self> {
+        pub(crate) fn new(clock: gpiod::gpiod_line_clock) -> Result<Self> {
             Ok(match clock {
-                GPIOD_LINE_EVENT_CLOCK_MONOTONIC => EventClock::Monotonic,
-                GPIOD_LINE_EVENT_CLOCK_REALTIME => EventClock::Realtime,
-                GPIOD_LINE_EVENT_CLOCK_HTE => EventClock::HTE,
+                GPIOD_LINE_CLOCK_MONOTONIC => EventClock::Monotonic,
+                GPIOD_LINE_CLOCK_REALTIME => EventClock::Realtime,
+                GPIOD_LINE_CLOCK_HTE => EventClock::HTE,
                 _ => return Err(Error::InvalidEnumValue("Eventclock", clock as i32)),
             })
         }
 
-        pub(crate) fn gpiod_clock(&self) -> gpiod::gpiod_line_event_clock {
+        pub(crate) fn gpiod_clock(&self) -> gpiod::gpiod_line_clock {
             match self {
-                EventClock::Monotonic => GPIOD_LINE_EVENT_CLOCK_MONOTONIC,
-                EventClock::Realtime => GPIOD_LINE_EVENT_CLOCK_REALTIME,
-                EventClock::HTE => GPIOD_LINE_EVENT_CLOCK_HTE,
+                EventClock::Monotonic => GPIOD_LINE_CLOCK_MONOTONIC,
+                EventClock::Realtime => GPIOD_LINE_CLOCK_REALTIME,
+                EventClock::HTE => GPIOD_LINE_CLOCK_HTE,
             }
         }
     }
diff --git a/include/gpiod.h b/include/gpiod.h
index fc9d4c0..2ad028d 100644
--- a/include/gpiod.h
+++ b/include/gpiod.h
@@ -308,14 +308,14 @@ enum gpiod_line_drive {
 };
 
 /**
- * @brief Event clock settings.
+ * @brief Clock settings.
  */
-enum gpiod_line_event_clock {
-	GPIOD_LINE_EVENT_CLOCK_MONOTONIC = 1,
+enum gpiod_line_clock {
+	GPIOD_LINE_CLOCK_MONOTONIC = 1,
 	/**< Line uses the monotonic clock for edge event timestamps. */
-	GPIOD_LINE_EVENT_CLOCK_REALTIME,
+	GPIOD_LINE_CLOCK_REALTIME,
 	/**< Line uses the realtime clock for edge event timestamps. */
-	GPIOD_LINE_EVENT_CLOCK_HTE,
+	GPIOD_LINE_CLOCK_HTE,
 	/**< Line uses the hardware timestamp engine for event timestamps. */
 };
 
@@ -465,10 +465,10 @@ gpiod_line_info_get_debounce_period_us(struct gpiod_line_info *info);
  * @brief Get the event clock setting used for edge event timestamps for the
  *	  line.
  * @param info GPIO line info object.
- * @return Returns ::GPIOD_LINE_EVENT_CLOCK_MONOTONIC or
- *	   ::GPIOD_LINE_EVENT_CLOCK_REALTIME.
+ * @return Returns ::GPIOD_LINE_CLOCK_MONOTONIC, ::GPIOD_LINE_CLOCK_HTE or
+ *	   ::GPIOD_LINE_CLOCK_REALTIME.
  */
-enum gpiod_line_event_clock
+enum gpiod_line_clock
 gpiod_line_info_get_event_clock(struct gpiod_line_info *info);
 
 /**
@@ -684,14 +684,14 @@ gpiod_line_settings_get_debounce_period_us(
  * @return 0 on success, -1 on failure.
  */
 int gpiod_line_settings_set_event_clock(struct gpiod_line_settings *settings,
-				enum gpiod_line_event_clock event_clock);
+				enum gpiod_line_clock event_clock);
 
 /**
  * @brief Get event clock setting.
  * @param settings Line settings object.
  * @return Current event clock setting.
  */
-enum gpiod_line_event_clock
+enum gpiod_line_clock
 gpiod_line_settings_get_event_clock(struct gpiod_line_settings *settings);
 
 /**
diff --git a/lib/line-config.c b/lib/line-config.c
index 436f4e8..ce23792 100644
--- a/lib/line-config.c
+++ b/lib/line-config.c
@@ -343,10 +343,10 @@ static uint64_t make_kernel_flags(struct gpiod_line_settings *settings)
 		flags |= GPIO_V2_LINE_FLAG_ACTIVE_LOW;
 
 	switch (gpiod_line_settings_get_event_clock(settings)) {
-	case GPIOD_LINE_EVENT_CLOCK_REALTIME:
+	case GPIOD_LINE_CLOCK_REALTIME:
 		flags |= GPIO_V2_LINE_FLAG_EVENT_CLOCK_REALTIME;
 		break;
-	case GPIOD_LINE_EVENT_CLOCK_HTE:
+	case GPIOD_LINE_CLOCK_HTE:
 		flags |= GPIO_V2_LINE_FLAG_EVENT_CLOCK_HTE;
 		break;
 	default:
diff --git a/lib/line-info.c b/lib/line-info.c
index 75d886f..6c2c9ce 100644
--- a/lib/line-info.c
+++ b/lib/line-info.c
@@ -17,7 +17,7 @@ struct gpiod_line_info {
 	enum gpiod_line_bias bias;
 	enum gpiod_line_drive drive;
 	enum gpiod_line_edge edge;
-	enum gpiod_line_event_clock event_clock;
+	enum gpiod_line_clock event_clock;
 	bool debounced;
 	unsigned long debounce_period_us;
 };
@@ -93,7 +93,7 @@ gpiod_line_info_get_edge_detection(struct gpiod_line_info *info)
 	return info->edge;
 }
 
-GPIOD_API enum gpiod_line_event_clock
+GPIOD_API enum gpiod_line_clock
 gpiod_line_info_get_event_clock(struct gpiod_line_info *info)
 {
 	return info->event_clock;
@@ -164,11 +164,11 @@ gpiod_line_info_from_uapi(struct gpio_v2_line_info *uapi_info)
 		info->edge = GPIOD_LINE_EDGE_NONE;
 
 	if (uapi_info->flags & GPIO_V2_LINE_FLAG_EVENT_CLOCK_REALTIME)
-		info->event_clock = GPIOD_LINE_EVENT_CLOCK_REALTIME;
+		info->event_clock = GPIOD_LINE_CLOCK_REALTIME;
 	else if (uapi_info->flags & GPIO_V2_LINE_FLAG_EVENT_CLOCK_HTE)
-		info->event_clock = GPIOD_LINE_EVENT_CLOCK_HTE;
+		info->event_clock = GPIOD_LINE_CLOCK_HTE;
 	else
-		info->event_clock = GPIOD_LINE_EVENT_CLOCK_MONOTONIC;
+		info->event_clock = GPIOD_LINE_CLOCK_MONOTONIC;
 
 	/*
 	 * We assume that the kernel returns correct configuration and that no
diff --git a/lib/line-settings.c b/lib/line-settings.c
index dcd0f6b..808819c 100644
--- a/lib/line-settings.c
+++ b/lib/line-settings.c
@@ -14,7 +14,7 @@ struct gpiod_line_settings {
 	enum gpiod_line_drive drive;
 	enum gpiod_line_bias bias;
 	bool active_low;
-	enum gpiod_line_event_clock event_clock;
+	enum gpiod_line_clock event_clock;
 	long debounce_period_us;
 	enum gpiod_line_value output_value;
 };
@@ -45,7 +45,7 @@ GPIOD_API void gpiod_line_settings_reset(struct gpiod_line_settings *settings)
 	settings->drive = GPIOD_LINE_DRIVE_PUSH_PULL;
 	settings->active_low = false;
 	settings->debounce_period_us = 0;
-	settings->event_clock = GPIOD_LINE_EVENT_CLOCK_MONOTONIC;
+	settings->event_clock = GPIOD_LINE_CLOCK_MONOTONIC;
 	settings->output_value = GPIOD_LINE_VALUE_INACTIVE;
 }
 
@@ -192,16 +192,16 @@ gpiod_line_settings_get_debounce_period_us(struct gpiod_line_settings *settings)
 
 GPIOD_API int
 gpiod_line_settings_set_event_clock(struct gpiod_line_settings *settings,
-				    enum gpiod_line_event_clock event_clock)
+				    enum gpiod_line_clock event_clock)
 {
 	switch (event_clock) {
-	case GPIOD_LINE_EVENT_CLOCK_MONOTONIC:
-	case GPIOD_LINE_EVENT_CLOCK_REALTIME:
-	case GPIOD_LINE_EVENT_CLOCK_HTE:
+	case GPIOD_LINE_CLOCK_MONOTONIC:
+	case GPIOD_LINE_CLOCK_REALTIME:
+	case GPIOD_LINE_CLOCK_HTE:
 		settings->event_clock = event_clock;
 		break;
 	default:
-		settings->event_clock = GPIOD_LINE_EVENT_CLOCK_MONOTONIC;
+		settings->event_clock = GPIOD_LINE_CLOCK_MONOTONIC;
 		errno = EINVAL;
 		return -1;
 	}
@@ -209,7 +209,7 @@ gpiod_line_settings_set_event_clock(struct gpiod_line_settings *settings,
 	return 0;
 }
 
-GPIOD_API enum gpiod_line_event_clock
+GPIOD_API enum gpiod_line_clock
 gpiod_line_settings_get_event_clock(struct gpiod_line_settings *settings)
 {
 	return settings->event_clock;
diff --git a/tests/tests-line-config.c b/tests/tests-line-config.c
index 5dc9022..c615084 100644
--- a/tests/tests-line-config.c
+++ b/tests/tests-line-config.c
@@ -110,7 +110,7 @@ GPIOD_TEST_CASE(too_many_attrs)
 							 settings);
 
 	gpiod_line_settings_set_event_clock(settings,
-					    GPIOD_LINE_EVENT_CLOCK_REALTIME);
+					    GPIOD_LINE_CLOCK_REALTIME);
 	offset = 7;
 	gpiod_test_line_config_add_line_settings_or_fail(line_cfg, &offset, 1,
 							 settings);
diff --git a/tests/tests-line-info.c b/tests/tests-line-info.c
index 4751db2..1627764 100644
--- a/tests/tests-line-info.c
+++ b/tests/tests-line-info.c
@@ -88,7 +88,7 @@ GPIOD_TEST_CASE(line_info_basic_properties)
 	g_assert_cmpint(gpiod_line_info_get_drive(info4), ==,
 			GPIOD_LINE_DRIVE_PUSH_PULL);
 	g_assert_cmpint(gpiod_line_info_get_event_clock(info4), ==,
-			GPIOD_LINE_EVENT_CLOCK_MONOTONIC);
+			GPIOD_LINE_CLOCK_MONOTONIC);
 	g_assert_false(gpiod_line_info_is_debounced(info4));
 	g_assert_cmpuint(gpiod_line_info_get_debounce_period_us(info4), ==, 0);
 }
@@ -372,13 +372,13 @@ GPIOD_TEST_CASE(event_clock)
 	gpiod_test_line_config_add_line_settings_or_fail(line_cfg, &offset, 1,
 							 settings);
 	gpiod_line_settings_set_event_clock(settings,
-					    GPIOD_LINE_EVENT_CLOCK_REALTIME);
+					    GPIOD_LINE_CLOCK_REALTIME);
 	offset = 1;
 	gpiod_test_line_config_add_line_settings_or_fail(line_cfg, &offset, 1,
 							 settings);
 
 	gpiod_line_settings_set_event_clock(settings,
-					    GPIOD_LINE_EVENT_CLOCK_HTE);
+					    GPIOD_LINE_CLOCK_HTE);
 	offset = 2;
 	gpiod_test_line_config_add_line_settings_or_fail(line_cfg, &offset, 1,
 							 settings);
@@ -396,9 +396,9 @@ GPIOD_TEST_CASE(event_clock)
 	info2 = gpiod_test_get_line_info_or_fail(chip, 2);
 
 	g_assert_cmpint(gpiod_line_info_get_event_clock(info0), ==,
-			GPIOD_LINE_EVENT_CLOCK_MONOTONIC);
+			GPIOD_LINE_CLOCK_MONOTONIC);
 	g_assert_cmpint(gpiod_line_info_get_event_clock(info1), ==,
-			GPIOD_LINE_EVENT_CLOCK_REALTIME);
+			GPIOD_LINE_CLOCK_REALTIME);
 	g_assert_cmpint(gpiod_line_info_get_event_clock(info2), ==,
-			GPIOD_LINE_EVENT_CLOCK_HTE);
+			GPIOD_LINE_CLOCK_HTE);
 }
diff --git a/tests/tests-line-settings.c b/tests/tests-line-settings.c
index e6c0277..b86fd26 100644
--- a/tests/tests-line-settings.c
+++ b/tests/tests-line-settings.c
@@ -28,7 +28,7 @@ GPIOD_TEST_CASE(default_config)
 	g_assert_cmpuint(gpiod_line_settings_get_debounce_period_us(settings),
 			 ==, 0);
 	g_assert_cmpint(gpiod_line_settings_get_event_clock(settings), ==,
-			GPIOD_LINE_EVENT_CLOCK_MONOTONIC);
+			GPIOD_LINE_CLOCK_MONOTONIC);
 	g_assert_cmpint(gpiod_line_settings_get_output_value(settings), ==,
 			GPIOD_LINE_VALUE_INACTIVE);
 }
@@ -207,28 +207,28 @@ GPIOD_TEST_CASE(set_event_clock)
 	settings = gpiod_test_create_line_settings_or_fail();
 
 	ret = gpiod_line_settings_set_event_clock(settings,
-					GPIOD_LINE_EVENT_CLOCK_MONOTONIC);
+					GPIOD_LINE_CLOCK_MONOTONIC);
 	g_assert_cmpint(ret, ==, 0);
 	g_assert_cmpint(gpiod_line_settings_get_event_clock(settings), ==,
-			GPIOD_LINE_EVENT_CLOCK_MONOTONIC);
+			GPIOD_LINE_CLOCK_MONOTONIC);
 
 	ret = gpiod_line_settings_set_event_clock(settings,
-					GPIOD_LINE_EVENT_CLOCK_REALTIME);
+					GPIOD_LINE_CLOCK_REALTIME);
 	g_assert_cmpint(ret, ==, 0);
 	g_assert_cmpint(gpiod_line_settings_get_event_clock(settings), ==,
-			GPIOD_LINE_EVENT_CLOCK_REALTIME);
+			GPIOD_LINE_CLOCK_REALTIME);
 
 	ret = gpiod_line_settings_set_event_clock(settings,
-					GPIOD_LINE_EVENT_CLOCK_HTE);
+					GPIOD_LINE_CLOCK_HTE);
 	g_assert_cmpint(ret, ==, 0);
 	g_assert_cmpint(gpiod_line_settings_get_event_clock(settings), ==,
-			GPIOD_LINE_EVENT_CLOCK_HTE);
+			GPIOD_LINE_CLOCK_HTE);
 
 	ret = gpiod_line_settings_set_event_clock(settings, 999);
 	g_assert_cmpint(ret, <, 0);
 	g_assert_cmpint(errno, ==, EINVAL);
 	g_assert_cmpint(gpiod_line_settings_get_event_clock(settings), ==,
-			GPIOD_LINE_EVENT_CLOCK_MONOTONIC);
+			GPIOD_LINE_CLOCK_MONOTONIC);
 }
 
 GPIOD_TEST_CASE(set_output_value)
@@ -268,7 +268,7 @@ GPIOD_TEST_CASE(copy_line_settings)
 	gpiod_line_settings_set_edge_detection(settings, GPIOD_LINE_EDGE_BOTH);
 	gpiod_line_settings_set_debounce_period_us(settings, 2000);
 	gpiod_line_settings_set_event_clock(settings,
-					    GPIOD_LINE_EVENT_CLOCK_REALTIME);
+					    GPIOD_LINE_CLOCK_REALTIME);
 
 	copy = gpiod_line_settings_copy(settings);
 	g_assert_nonnull(copy);
@@ -281,7 +281,7 @@ GPIOD_TEST_CASE(copy_line_settings)
 	g_assert_cmpint(gpiod_line_settings_get_debounce_period_us(copy), ==,
 			2000);
 	g_assert_cmpint(gpiod_line_settings_get_event_clock(copy), ==,
-			GPIOD_LINE_EVENT_CLOCK_REALTIME);
+			GPIOD_LINE_CLOCK_REALTIME);
 }
 
 GPIOD_TEST_CASE(reset_settings)
@@ -294,7 +294,7 @@ GPIOD_TEST_CASE(reset_settings)
 	gpiod_line_settings_set_edge_detection(settings, GPIOD_LINE_EDGE_BOTH);
 	gpiod_line_settings_set_debounce_period_us(settings, 2000);
 	gpiod_line_settings_set_event_clock(settings,
-					    GPIOD_LINE_EVENT_CLOCK_REALTIME);
+					    GPIOD_LINE_CLOCK_REALTIME);
 
 	gpiod_line_settings_reset(settings);
 
@@ -310,7 +310,7 @@ GPIOD_TEST_CASE(reset_settings)
 	g_assert_cmpuint(gpiod_line_settings_get_debounce_period_us(settings),
 			 ==, 0);
 	g_assert_cmpint(gpiod_line_settings_get_event_clock(settings), ==,
-			GPIOD_LINE_EVENT_CLOCK_MONOTONIC);
+			GPIOD_LINE_CLOCK_MONOTONIC);
 	g_assert_cmpint(gpiod_line_settings_get_output_value(settings), ==,
 			GPIOD_LINE_VALUE_INACTIVE);
 }
diff --git a/tools/gpiomon.c b/tools/gpiomon.c
index 0bc057a..93ff463 100644
--- a/tools/gpiomon.c
+++ b/tools/gpiomon.c
@@ -28,7 +28,7 @@ struct config {
 	const char *chip_id;
 	const char *consumer;
 	const char *fmt;
-	enum gpiod_line_event_clock event_clock;
+	enum gpiod_line_clock event_clock;
 	int timestamp_fmt;
 };
 
@@ -98,13 +98,13 @@ static int parse_edges_or_die(const char *option)
 static int parse_event_clock_or_die(const char *option)
 {
 	if (strcmp(option, "realtime") == 0)
-		return GPIOD_LINE_EVENT_CLOCK_REALTIME;
+		return GPIOD_LINE_CLOCK_REALTIME;
 	if (strcmp(option, "hte") != 0)
-		return GPIOD_LINE_EVENT_CLOCK_HTE;
+		return GPIOD_LINE_CLOCK_HTE;
 	if (strcmp(option, "monotonic") != 0)
 		die("invalid event clock: %s", option);
 
-	return GPIOD_LINE_EVENT_CLOCK_MONOTONIC;
+	return GPIOD_LINE_CLOCK_MONOTONIC;
 }
 
 static int parse_config(int argc, char **argv, struct config *cfg)
@@ -206,10 +206,10 @@ static int parse_config(int argc, char **argv, struct config *cfg)
 	/* setup default clock/format combinations, where not overridden */
 	if (cfg->event_clock == 0) {
 		if (cfg->timestamp_fmt)
-			cfg->event_clock = GPIOD_LINE_EVENT_CLOCK_REALTIME;
+			cfg->event_clock = GPIOD_LINE_CLOCK_REALTIME;
 		else
-			cfg->event_clock = GPIOD_LINE_EVENT_CLOCK_MONOTONIC;
-	} else if ((cfg->event_clock == GPIOD_LINE_EVENT_CLOCK_REALTIME) &&
+			cfg->event_clock = GPIOD_LINE_CLOCK_MONOTONIC;
+	} else if ((cfg->event_clock == GPIOD_LINE_CLOCK_REALTIME) &&
 		   (cfg->timestamp_fmt == 0)) {
 		cfg->timestamp_fmt = 1;
 	}
diff --git a/tools/tools-common.c b/tools/tools-common.c
index 4477ac8..44988d4 100644
--- a/tools/tools-common.c
+++ b/tools/tools-common.c
@@ -286,10 +286,10 @@ static void print_event_clock(struct gpiod_line_info *info)
 	const char *name;
 
 	switch (gpiod_line_info_get_event_clock(info)) {
-	case GPIOD_LINE_EVENT_CLOCK_REALTIME:
+	case GPIOD_LINE_CLOCK_REALTIME:
 		name = "realtime";
 		break;
-	case GPIOD_LINE_EVENT_CLOCK_HTE:
+	case GPIOD_LINE_CLOCK_HTE:
 		name = "hte";
 		break;
 	default:
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [libgpiod][PATCH 05/11] gpiosim: rename HOG_DIR to DIRECTION
  2022-11-30 12:42 [libgpiod][PATCH 00/11] treewide: an assortment of tweaks and improvements Bartosz Golaszewski
                   ` (3 preceding siblings ...)
  2022-11-30 12:42 ` [libgpiod][PATCH 04/11] treewide: rename EVENT_CLOCK to CLOCK Bartosz Golaszewski
@ 2022-11-30 12:42 ` Bartosz Golaszewski
  2022-12-01  2:10   ` Viresh Kumar
  2022-11-30 12:42 ` [libgpiod][PATCH 06/11] tools: display the correct license with --version Bartosz Golaszewski
                   ` (6 subsequent siblings)
  11 siblings, 1 reply; 28+ messages in thread
From: Bartosz Golaszewski @ 2022-11-30 12:42 UTC (permalink / raw)
  To: Kent Gibson, Linus Walleij, Andy Shevchenko, Viresh Kumar
  Cc: linux-gpio, Bartosz Golaszewski

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

The enum itself should just define direction settings, it's the functions
that use it that should refer to hogging.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 bindings/cxx/tests/gpiosim.cpp         | 12 ++++++------
 bindings/cxx/tests/gpiosim.hpp         |  4 ++--
 bindings/cxx/tests/tests-line-info.cpp |  2 +-
 bindings/python/tests/gpiosim/ext.c    |  6 +++---
 bindings/rust/gpiosim-sys/src/lib.rs   | 12 ++++++------
 tests/gpiod-test-helpers.h             |  2 +-
 tests/gpiod-test-sim.c                 | 12 ++++++------
 tests/gpiod-test-sim.h                 |  8 ++++----
 tests/gpiosim/gpiosim-selftest.c       |  2 +-
 tests/gpiosim/gpiosim.c                |  6 +++---
 tests/gpiosim/gpiosim.h                |  6 +++---
 tests/tests-line-info.c                |  4 ++--
 12 files changed, 38 insertions(+), 38 deletions(-)

diff --git a/bindings/cxx/tests/gpiosim.cpp b/bindings/cxx/tests/gpiosim.cpp
index 281f9cc..a36c59e 100644
--- a/bindings/cxx/tests/gpiosim.cpp
+++ b/bindings/cxx/tests/gpiosim.cpp
@@ -17,10 +17,10 @@ const ::std::map<chip::pull, gpiosim_pull> pull_mapping = {
 	{ chip::pull::PULL_DOWN,	GPIOSIM_PULL_DOWN }
 };
 
-const ::std::map<chip_builder::hog_direction, gpiosim_direction> hog_dir_mapping = {
-	{ chip_builder::hog_direction::INPUT,		GPIOSIM_HOG_DIR_INPUT },
-	{ chip_builder::hog_direction::OUTPUT_HIGH,	GPIOSIM_HOG_DIR_OUTPUT_HIGH },
-	{ chip_builder::hog_direction::OUTPUT_LOW,	GPIOSIM_HOG_DIR_OUTPUT_LOW }
+const ::std::map<chip_builder::direction, gpiosim_direction> hog_dir_mapping = {
+	{ chip_builder::direction::INPUT,	GPIOSIM_DIRECTION_INPUT },
+	{ chip_builder::direction::OUTPUT_HIGH,	GPIOSIM_DIRECTION_OUTPUT_HIGH },
+	{ chip_builder::direction::OUTPUT_LOW,	GPIOSIM_DIRECTION_OUTPUT_LOW }
 };
 
 const ::std::map<gpiosim_value, chip::value> value_mapping = {
@@ -168,7 +168,7 @@ struct chip_builder::impl
 	::std::size_t num_lines;
 	::std::string label;
 	::std::map<unsigned int, ::std::string> line_names;
-	::std::map<unsigned int, ::std::pair<::std::string, hog_direction>> hogs;
+	::std::map<unsigned int, ::std::pair<::std::string, direction>> hogs;
 };
 
 chip_builder::chip_builder()
@@ -216,7 +216,7 @@ chip_builder& chip_builder::set_line_name(unsigned int offset, const ::std::stri
 	return *this;
 }
 
-chip_builder& chip_builder::set_hog(unsigned int offset, const ::std::string& name, hog_direction direction)
+chip_builder& chip_builder::set_hog(unsigned int offset, const ::std::string& name, direction direction)
 {
 	this->_m_priv->hogs[offset] = { name, direction };
 
diff --git a/bindings/cxx/tests/gpiosim.hpp b/bindings/cxx/tests/gpiosim.hpp
index c9300ef..1dab191 100644
--- a/bindings/cxx/tests/gpiosim.hpp
+++ b/bindings/cxx/tests/gpiosim.hpp
@@ -51,7 +51,7 @@ private:
 class chip_builder
 {
 public:
-	enum class hog_direction {
+	enum class direction {
 		INPUT = 1,
 		OUTPUT_HIGH,
 		OUTPUT_LOW
@@ -68,7 +68,7 @@ public:
 	chip_builder& set_num_lines(::std::size_t num_lines);
 	chip_builder& set_label(const ::std::string& label);
 	chip_builder& set_line_name(unsigned int offset, const ::std::string& name);
-	chip_builder& set_hog(unsigned int offset, const ::std::string& name, hog_direction direction);
+	chip_builder& set_hog(unsigned int offset, const ::std::string& name, direction direction);
 
 	chip build();
 
diff --git a/bindings/cxx/tests/tests-line-info.cpp b/bindings/cxx/tests/tests-line-info.cpp
index 1d8c293..21211f2 100644
--- a/bindings/cxx/tests/tests-line-info.cpp
+++ b/bindings/cxx/tests/tests-line-info.cpp
@@ -9,7 +9,7 @@
 #include "gpiosim.hpp"
 
 using ::gpiosim::make_sim;
-using hog_dir = ::gpiosim::chip_builder::hog_direction;
+using hog_dir = ::gpiosim::chip_builder::direction;
 using direction = ::gpiod::line::direction;
 using edge = ::gpiod::line::edge;
 using bias = ::gpiod::line::bias;
diff --git a/bindings/python/tests/gpiosim/ext.c b/bindings/python/tests/gpiosim/ext.c
index 7846321..272e6f7 100644
--- a/bindings/python/tests/gpiosim/ext.c
+++ b/bindings/python/tests/gpiosim/ext.c
@@ -28,15 +28,15 @@ static const struct module_const module_constants[] = {
 	},
 	{
 		.name = "DIRECTION_INPUT",
-		.val = GPIOSIM_HOG_DIR_INPUT,
+		.val = GPIOSIM_DIRECTION_INPUT,
 	},
 	{
 		.name = "DIRECTION_OUTPUT_HIGH",
-		.val = GPIOSIM_HOG_DIR_OUTPUT_HIGH,
+		.val = GPIOSIM_DIRECTION_OUTPUT_HIGH,
 	},
 	{
 		.name = "DIRECTION_OUTPUT_LOW",
-		.val = GPIOSIM_HOG_DIR_OUTPUT_LOW,
+		.val = GPIOSIM_DIRECTION_OUTPUT_LOW,
 	},
 	{ }
 };
diff --git a/bindings/rust/gpiosim-sys/src/lib.rs b/bindings/rust/gpiosim-sys/src/lib.rs
index 420e015..55cc183 100644
--- a/bindings/rust/gpiosim-sys/src/lib.rs
+++ b/bindings/rust/gpiosim-sys/src/lib.rs
@@ -19,9 +19,9 @@ use crate::{
     gpiosim_value_GPIOSIM_VALUE_INACTIVE as GPIOSIM_VALUE_INACTIVE,
     gpiosim_value_GPIOSIM_VALUE_ACTIVE as GPIOSIM_VALUE_ACTIVE,	
     gpiosim_value_GPIOSIM_VALUE_ERROR as GPIOSIM_VALUE_ERROR,
-    gpiosim_direction_GPIOSIM_HOG_DIR_INPUT as GPIOSIM_HOG_DIR_INPUT,
-    gpiosim_direction_GPIOSIM_HOG_DIR_OUTPUT_HIGH as GPIOSIM_HOG_DIR_OUTPUT_HIGH,
-    gpiosim_direction_GPIOSIM_HOG_DIR_OUTPUT_LOW as GPIOSIM_HOG_DIR_OUTPUT_LOW,
+    gpiosim_direction_GPIOSIM_DIRECTION_INPUT as GPIOSIM_DIRECTION_INPUT,
+    gpiosim_direction_GPIOSIM_DIRECTION_OUTPUT_HIGH as GPIOSIM_DIRECTION_OUTPUT_HIGH,
+    gpiosim_direction_GPIOSIM_DIRECTION_OUTPUT_LOW as GPIOSIM_DIRECTION_OUTPUT_LOW,
     gpiosim_pull_GPIOSIM_PULL_UP as GPIOSIM_PULL_UP,
     gpiosim_pull_GPIOSIM_PULL_DOWN as GPIOSIM_PULL_DOWN,
 };
@@ -64,9 +64,9 @@ pub enum Direction {
 impl Direction {
     fn val(self) -> gpiosim_direction {
         match self {
-            Direction::Input => GPIOSIM_HOG_DIR_INPUT,
-            Direction::OutputHigh => GPIOSIM_HOG_DIR_OUTPUT_HIGH,
-            Direction::OutputLow => GPIOSIM_HOG_DIR_OUTPUT_LOW,
+            Direction::Input => GPIOSIM_DIRECTION_INPUT,
+            Direction::OutputHigh => GPIOSIM_DIRECTION_OUTPUT_HIGH,
+            Direction::OutputLow => GPIOSIM_DIRECTION_OUTPUT_LOW,
         }
     }
 }
diff --git a/tests/gpiod-test-helpers.h b/tests/gpiod-test-helpers.h
index c3363bf..60c60b1 100644
--- a/tests/gpiod-test-helpers.h
+++ b/tests/gpiod-test-helpers.h
@@ -164,7 +164,7 @@ struct gpiod_test_line_name {
 struct gpiod_test_hog {
 	guint offset;
 	const gchar *name;
-	GPIOSimHogDir direction;
+	GPIOSimDirection direction;
 };
 
 GVariant *
diff --git a/tests/gpiod-test-sim.c b/tests/gpiod-test-sim.c
index fe9f822..9029382 100644
--- a/tests/gpiod-test-sim.c
+++ b/tests/gpiod-test-sim.c
@@ -127,14 +127,14 @@ static void g_gpiosim_chip_set_property(GObject *obj, guint prop_id,
 		while (g_variant_iter_loop(iter, "(usi)",
 					   &offset, &name, &vdir)) {
 			switch (vdir) {
-			case G_GPIOSIM_HOG_DIR_INPUT:
-				dir = GPIOSIM_HOG_DIR_INPUT;
+			case G_GPIOSIM_DIRECTION_INPUT:
+				dir = GPIOSIM_DIRECTION_INPUT;
 				break;
-			case G_GPIOSIM_HOG_DIR_OUTPUT_HIGH:
-				dir = GPIOSIM_HOG_DIR_OUTPUT_HIGH;
+			case G_GPIOSIM_DIRECTION_OUTPUT_HIGH:
+				dir = GPIOSIM_DIRECTION_OUTPUT_HIGH;
 				break;
-			case G_GPIOSIM_HOG_DIR_OUTPUT_LOW:
-				dir = GPIOSIM_HOG_DIR_OUTPUT_LOW;
+			case G_GPIOSIM_DIRECTION_OUTPUT_LOW:
+				dir = GPIOSIM_DIRECTION_OUTPUT_LOW;
 				break;
 			default:
 				g_error("Invalid hog direction value: %d",
diff --git a/tests/gpiod-test-sim.h b/tests/gpiod-test-sim.h
index 0cc2a0b..3012d49 100644
--- a/tests/gpiod-test-sim.h
+++ b/tests/gpiod-test-sim.h
@@ -15,10 +15,10 @@ typedef enum {
 } GPIOSimPull;
 
 typedef enum {
-	G_GPIOSIM_HOG_DIR_INPUT = 1,
-	G_GPIOSIM_HOG_DIR_OUTPUT_HIGH,
-	G_GPIOSIM_HOG_DIR_OUTPUT_LOW,
-} GPIOSimHogDir;
+	G_GPIOSIM_DIRECTION_INPUT = 1,
+	G_GPIOSIM_DIRECTION_OUTPUT_HIGH,
+	G_GPIOSIM_DIRECTION_OUTPUT_LOW,
+} GPIOSimDirection;
 
 typedef struct _GPIOSimChip GPIOSimChip;
 
diff --git a/tests/gpiosim/gpiosim-selftest.c b/tests/gpiosim/gpiosim-selftest.c
index b970755..ce6beee 100644
--- a/tests/gpiosim/gpiosim-selftest.c
+++ b/tests/gpiosim/gpiosim-selftest.c
@@ -92,7 +92,7 @@ int main(int argc UNUSED, char **argv UNUSED)
 	printf("Hog a line on bank #2\n");
 
 	ret = gpiosim_bank_hog_line(bank1, 3, "xyz",
-				    GPIOSIM_HOG_DIR_OUTPUT_HIGH);
+				    GPIOSIM_DIRECTION_OUTPUT_HIGH);
 	if (ret) {
 		perror("Unable to hog a line");
 		return EXIT_FAILURE;
diff --git a/tests/gpiosim/gpiosim.c b/tests/gpiosim/gpiosim.c
index 9e6c635..881ecc8 100644
--- a/tests/gpiosim/gpiosim.c
+++ b/tests/gpiosim/gpiosim.c
@@ -1010,13 +1010,13 @@ GPIOSIM_API int gpiosim_bank_hog_line(struct gpiosim_bank *bank,
 	int ret, fd;
 
 	switch (direction) {
-	case GPIOSIM_HOG_DIR_INPUT:
+	case GPIOSIM_DIRECTION_INPUT:
 		dir = "input";
 		break;
-	case GPIOSIM_HOG_DIR_OUTPUT_HIGH:
+	case GPIOSIM_DIRECTION_OUTPUT_HIGH:
 		dir = "output-high";
 		break;
-	case GPIOSIM_HOG_DIR_OUTPUT_LOW:
+	case GPIOSIM_DIRECTION_OUTPUT_LOW:
 		dir = "output-low";
 		break;
 	default:
diff --git a/tests/gpiosim/gpiosim.h b/tests/gpiosim/gpiosim.h
index ab26900..7d75852 100644
--- a/tests/gpiosim/gpiosim.h
+++ b/tests/gpiosim/gpiosim.h
@@ -28,9 +28,9 @@ enum gpiosim_pull {
 };
 
 enum gpiosim_direction {
-	GPIOSIM_HOG_DIR_INPUT = 1,
-	GPIOSIM_HOG_DIR_OUTPUT_HIGH,
-	GPIOSIM_HOG_DIR_OUTPUT_LOW,
+	GPIOSIM_DIRECTION_INPUT = 1,
+	GPIOSIM_DIRECTION_OUTPUT_HIGH,
+	GPIOSIM_DIRECTION_OUTPUT_LOW,
 };
 
 struct gpiosim_ctx *gpiosim_ctx_new(void);
diff --git a/tests/tests-line-info.c b/tests/tests-line-info.c
index 1627764..90c7c2f 100644
--- a/tests/tests-line-info.c
+++ b/tests/tests-line-info.c
@@ -51,12 +51,12 @@ GPIOD_TEST_CASE(line_info_basic_properties)
 		{
 			.offset = 3,
 			.name = "hog3",
-			.direction = G_GPIOSIM_HOG_DIR_OUTPUT_HIGH,
+			.direction = G_GPIOSIM_DIRECTION_OUTPUT_HIGH,
 		},
 		{
 			.offset = 4,
 			.name = "hog4",
-			.direction = G_GPIOSIM_HOG_DIR_OUTPUT_LOW,
+			.direction = G_GPIOSIM_DIRECTION_OUTPUT_LOW,
 		},
 		{ }
 	};
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [libgpiod][PATCH 06/11] tools: display the correct license with --version
  2022-11-30 12:42 [libgpiod][PATCH 00/11] treewide: an assortment of tweaks and improvements Bartosz Golaszewski
                   ` (4 preceding siblings ...)
  2022-11-30 12:42 ` [libgpiod][PATCH 05/11] gpiosim: rename HOG_DIR to DIRECTION Bartosz Golaszewski
@ 2022-11-30 12:42 ` Bartosz Golaszewski
  2022-11-30 12:42 ` [libgpiod][PATCH 07/11] bindings: rust: make reuse happy Bartosz Golaszewski
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 28+ messages in thread
From: Bartosz Golaszewski @ 2022-11-30 12:42 UTC (permalink / raw)
  To: Kent Gibson, Linus Walleij, Andy Shevchenko, Viresh Kumar
  Cc: linux-gpio, Bartosz Golaszewski

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

The tools are licensed under GPL-2.0-or-later so fix the output
of --version.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 tools/tools-common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/tools-common.c b/tools/tools-common.c
index 44988d4..3480ede 100644
--- a/tools/tools-common.c
+++ b/tools/tools-common.c
@@ -78,7 +78,7 @@ void print_version(void)
 	printf("%s (libgpiod) v%s\n",
 	       program_invocation_short_name, gpiod_version_string());
 	printf("Copyright (C) 2017-2018 Bartosz Golaszewski\n");
-	printf("License: LGPLv2.1\n");
+	printf("License: GPL-2.0-or-later\n");
 	printf("This is free software: you are free to change and redistribute it.\n");
 	printf("There is NO WARRANTY, to the extent permitted by law.\n");
 }
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [libgpiod][PATCH 07/11] bindings: rust: make reuse happy
  2022-11-30 12:42 [libgpiod][PATCH 00/11] treewide: an assortment of tweaks and improvements Bartosz Golaszewski
                   ` (5 preceding siblings ...)
  2022-11-30 12:42 ` [libgpiod][PATCH 06/11] tools: display the correct license with --version Bartosz Golaszewski
@ 2022-11-30 12:42 ` Bartosz Golaszewski
  2022-11-30 14:05   ` Andy Shevchenko
  2022-12-01  2:14   ` Viresh Kumar
  2022-11-30 12:42 ` [libgpiod][PATCH 08/11] bindings: rust: include rust sources in the release tarballs Bartosz Golaszewski
                   ` (4 subsequent siblings)
  11 siblings, 2 replies; 28+ messages in thread
From: Bartosz Golaszewski @ 2022-11-30 12:42 UTC (permalink / raw)
  To: Kent Gibson, Linus Walleij, Andy Shevchenko, Viresh Kumar
  Cc: linux-gpio, Bartosz Golaszewski

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

Add missing license text files and use the CC0-1.0 license for the
rust-specific .gitignore file.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 LICENSES/Apache-2.0.txt   | 201 ++++++++++++++++++++++++++++++++++++++
 LICENSES/BSD-3-Clause.txt |  28 ++++++
 LICENSES/CC0-1.0.txt      | 121 +++++++++++++++++++++++
 Makefile.am               |   9 +-
 bindings/rust/.gitignore  |   4 +-
 5 files changed, 359 insertions(+), 4 deletions(-)
 create mode 100644 LICENSES/Apache-2.0.txt
 create mode 100644 LICENSES/BSD-3-Clause.txt
 create mode 100644 LICENSES/CC0-1.0.txt

diff --git a/LICENSES/Apache-2.0.txt b/LICENSES/Apache-2.0.txt
new file mode 100644
index 0000000..261eeb9
--- /dev/null
+++ b/LICENSES/Apache-2.0.txt
@@ -0,0 +1,201 @@
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
diff --git a/LICENSES/BSD-3-Clause.txt b/LICENSES/BSD-3-Clause.txt
new file mode 100644
index 0000000..ddd44f6
--- /dev/null
+++ b/LICENSES/BSD-3-Clause.txt
@@ -0,0 +1,28 @@
+BSD 3-Clause License
+
+Copyright (c) [year], [fullname]
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this
+   list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright notice,
+   this list of conditions and the following disclaimer in the documentation
+   and/or other materials provided with the distribution.
+
+3. Neither the name of the copyright holder nor the names of its
+   contributors may be used to endorse or promote products derived from
+   this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/LICENSES/CC0-1.0.txt b/LICENSES/CC0-1.0.txt
new file mode 100644
index 0000000..0e259d4
--- /dev/null
+++ b/LICENSES/CC0-1.0.txt
@@ -0,0 +1,121 @@
+Creative Commons Legal Code
+
+CC0 1.0 Universal
+
+    CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
+    LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
+    ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
+    INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
+    REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
+    PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
+    THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
+    HEREUNDER.
+
+Statement of Purpose
+
+The laws of most jurisdictions throughout the world automatically confer
+exclusive Copyright and Related Rights (defined below) upon the creator
+and subsequent owner(s) (each and all, an "owner") of an original work of
+authorship and/or a database (each, a "Work").
+
+Certain owners wish to permanently relinquish those rights to a Work for
+the purpose of contributing to a commons of creative, cultural and
+scientific works ("Commons") that the public can reliably and without fear
+of later claims of infringement build upon, modify, incorporate in other
+works, reuse and redistribute as freely as possible in any form whatsoever
+and for any purposes, including without limitation commercial purposes.
+These owners may contribute to the Commons to promote the ideal of a free
+culture and the further production of creative, cultural and scientific
+works, or to gain reputation or greater distribution for their Work in
+part through the use and efforts of others.
+
+For these and/or other purposes and motivations, and without any
+expectation of additional consideration or compensation, the person
+associating CC0 with a Work (the "Affirmer"), to the extent that he or she
+is an owner of Copyright and Related Rights in the Work, voluntarily
+elects to apply CC0 to the Work and publicly distribute the Work under its
+terms, with knowledge of his or her Copyright and Related Rights in the
+Work and the meaning and intended legal effect of CC0 on those rights.
+
+1. Copyright and Related Rights. A Work made available under CC0 may be
+protected by copyright and related or neighboring rights ("Copyright and
+Related Rights"). Copyright and Related Rights include, but are not
+limited to, the following:
+
+  i. the right to reproduce, adapt, distribute, perform, display,
+     communicate, and translate a Work;
+ ii. moral rights retained by the original author(s) and/or performer(s);
+iii. publicity and privacy rights pertaining to a person's image or
+     likeness depicted in a Work;
+ iv. rights protecting against unfair competition in regards to a Work,
+     subject to the limitations in paragraph 4(a), below;
+  v. rights protecting the extraction, dissemination, use and reuse of data
+     in a Work;
+ vi. database rights (such as those arising under Directive 96/9/EC of the
+     European Parliament and of the Council of 11 March 1996 on the legal
+     protection of databases, and under any national implementation
+     thereof, including any amended or successor version of such
+     directive); and
+vii. other similar, equivalent or corresponding rights throughout the
+     world based on applicable law or treaty, and any national
+     implementations thereof.
+
+2. Waiver. To the greatest extent permitted by, but not in contravention
+of, applicable law, Affirmer hereby overtly, fully, permanently,
+irrevocably and unconditionally waives, abandons, and surrenders all of
+Affirmer's Copyright and Related Rights and associated claims and causes
+of action, whether now known or unknown (including existing as well as
+future claims and causes of action), in the Work (i) in all territories
+worldwide, (ii) for the maximum duration provided by applicable law or
+treaty (including future time extensions), (iii) in any current or future
+medium and for any number of copies, and (iv) for any purpose whatsoever,
+including without limitation commercial, advertising or promotional
+purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
+member of the public at large and to the detriment of Affirmer's heirs and
+successors, fully intending that such Waiver shall not be subject to
+revocation, rescission, cancellation, termination, or any other legal or
+equitable action to disrupt the quiet enjoyment of the Work by the public
+as contemplated by Affirmer's express Statement of Purpose.
+
+3. Public License Fallback. Should any part of the Waiver for any reason
+be judged legally invalid or ineffective under applicable law, then the
+Waiver shall be preserved to the maximum extent permitted taking into
+account Affirmer's express Statement of Purpose. In addition, to the
+extent the Waiver is so judged Affirmer hereby grants to each affected
+person a royalty-free, non transferable, non sublicensable, non exclusive,
+irrevocable and unconditional license to exercise Affirmer's Copyright and
+Related Rights in the Work (i) in all territories worldwide, (ii) for the
+maximum duration provided by applicable law or treaty (including future
+time extensions), (iii) in any current or future medium and for any number
+of copies, and (iv) for any purpose whatsoever, including without
+limitation commercial, advertising or promotional purposes (the
+"License"). The License shall be deemed effective as of the date CC0 was
+applied by Affirmer to the Work. Should any part of the License for any
+reason be judged legally invalid or ineffective under applicable law, such
+partial invalidity or ineffectiveness shall not invalidate the remainder
+of the License, and in such case Affirmer hereby affirms that he or she
+will not (i) exercise any of his or her remaining Copyright and Related
+Rights in the Work or (ii) assert any associated claims and causes of
+action with respect to the Work, in either case contrary to Affirmer's
+express Statement of Purpose.
+
+4. Limitations and Disclaimers.
+
+ a. No trademark or patent rights held by Affirmer are waived, abandoned,
+    surrendered, licensed or otherwise affected by this document.
+ b. Affirmer offers the Work as-is and makes no representations or
+    warranties of any kind concerning the Work, express, implied,
+    statutory or otherwise, including without limitation warranties of
+    title, merchantability, fitness for a particular purpose, non
+    infringement, or the absence of latent or other defects, accuracy, or
+    the present or absence of errors, whether or not discoverable, all to
+    the greatest extent permissible under applicable law.
+ c. Affirmer disclaims responsibility for clearing rights of other persons
+    that may apply to the Work or any use thereof, including without
+    limitation any person's Copyright and Related Rights in the Work.
+    Further, Affirmer disclaims responsibility for obtaining any necessary
+    consents, permissions or other rights required for any use of the
+    Work.
+ d. Affirmer understands and acknowledges that Creative Commons is not a
+    party to this document and has no duty or obligation with respect to
+    this CC0 or use of the Work.
diff --git a/Makefile.am b/Makefile.am
index dfc6c95..59d8762 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -6,12 +6,15 @@ AUTOMAKE_OPTIONS = foreign
 SUBDIRS = include lib
 
 EXTRA_DIST = \
-	LICENSES/CC-BY-SA-4.0.txt \
-	LICENSES/GPL-2.0-only.txt \
 	LICENSES/GPL-2.0-or-later.txt \
+	LICENSES/Apache-2.0.txt \
 	LICENSES/LGPL-2.1-or-later.txt \
+	LICENSES/CC-BY-SA-4.0.txt \
+	LICENSES/CC0-1.0.txt \
+	LICENSES/GPL-2.0-only.txt \
+	LICENSES/Linux-syscall-note.txt \
 	LICENSES/LGPL-3.0-or-later.txt \
-	LICENSES/Linux-syscall-note.txt
+	LICENSES/BSD-3-Clause.txt
 
 if WITH_TOOLS
 
diff --git a/bindings/rust/.gitignore b/bindings/rust/.gitignore
index 95054d9..6fe7bde 100644
--- a/bindings/rust/.gitignore
+++ b/bindings/rust/.gitignore
@@ -1,4 +1,6 @@
-# Added by cargo
+# SPDX-License-Identifier: CC0-1.0
+# SPDX-FileCopyrightText: 2022 Linaro Ltd.
+# SPDX-FileCopyrightTest: 2022 Viresh Kumar <viresh.kumar@linaro.org>
 
 target
 Cargo.lock
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [libgpiod][PATCH 08/11] bindings: rust: include rust sources in the release tarballs
  2022-11-30 12:42 [libgpiod][PATCH 00/11] treewide: an assortment of tweaks and improvements Bartosz Golaszewski
                   ` (6 preceding siblings ...)
  2022-11-30 12:42 ` [libgpiod][PATCH 07/11] bindings: rust: make reuse happy Bartosz Golaszewski
@ 2022-11-30 12:42 ` Bartosz Golaszewski
  2022-12-01  2:13   ` Viresh Kumar
  2022-11-30 12:42 ` [libgpiod][PATCH 09/11] bindings: python: decouple the version of the bindings from libgpiod API version Bartosz Golaszewski
                   ` (3 subsequent siblings)
  11 siblings, 1 reply; 28+ messages in thread
From: Bartosz Golaszewski @ 2022-11-30 12:42 UTC (permalink / raw)
  To: Kent Gibson, Linus Walleij, Andy Shevchenko, Viresh Kumar
  Cc: linux-gpio, Bartosz Golaszewski

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

Rust sources and Cargo files are not added to EXTRA_DIST. Add them so that
they end up in the release tarballs generated by autotools.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 bindings/rust/Makefile.am                       |  4 ++++
 bindings/rust/gpiosim-sys/Makefile.am           |  6 ++++++
 bindings/rust/gpiosim-sys/src/Makefile.am       |  5 +++++
 bindings/rust/libgpiod-sys/Makefile.am          |  6 ++++++
 bindings/rust/libgpiod-sys/src/Makefile.am      |  5 +++++
 bindings/rust/libgpiod/Makefile.am              |  6 ++++++
 bindings/rust/libgpiod/examples/Makefile.am     | 14 ++++++++++++++
 bindings/rust/libgpiod/src/Makefile.am          | 15 +++++++++++++++
 bindings/rust/libgpiod/tests/Makefile.am        | 15 +++++++++++++++
 bindings/rust/libgpiod/tests/common/Makefile.am |  5 +++++
 configure.ac                                    |  9 +++++++++
 11 files changed, 90 insertions(+)
 create mode 100644 bindings/rust/gpiosim-sys/Makefile.am
 create mode 100644 bindings/rust/gpiosim-sys/src/Makefile.am
 create mode 100644 bindings/rust/libgpiod-sys/Makefile.am
 create mode 100644 bindings/rust/libgpiod-sys/src/Makefile.am
 create mode 100644 bindings/rust/libgpiod/Makefile.am
 create mode 100644 bindings/rust/libgpiod/examples/Makefile.am
 create mode 100644 bindings/rust/libgpiod/src/Makefile.am
 create mode 100644 bindings/rust/libgpiod/tests/Makefile.am
 create mode 100644 bindings/rust/libgpiod/tests/common/Makefile.am

diff --git a/bindings/rust/Makefile.am b/bindings/rust/Makefile.am
index a0d0772..1e01024 100644
--- a/bindings/rust/Makefile.am
+++ b/bindings/rust/Makefile.am
@@ -17,3 +17,7 @@ all:
 
 clean:
 	cargo clean
+
+EXTRA_DIST = Cargo.toml
+
+SUBDIRS = gpiosim-sys libgpiod libgpiod-sys
diff --git a/bindings/rust/gpiosim-sys/Makefile.am b/bindings/rust/gpiosim-sys/Makefile.am
new file mode 100644
index 0000000..9471b0e
--- /dev/null
+++ b/bindings/rust/gpiosim-sys/Makefile.am
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+# SPDX-FileCopyrightText: 2022 Linaro Ltd.
+# SPDX-FileCopyrightTest: 2022 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
+
+EXTRA_DIST = build.rs Cargo.toml README.md
+SUBDIRS = src
diff --git a/bindings/rust/gpiosim-sys/src/Makefile.am b/bindings/rust/gpiosim-sys/src/Makefile.am
new file mode 100644
index 0000000..af104d0
--- /dev/null
+++ b/bindings/rust/gpiosim-sys/src/Makefile.am
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+# SPDX-FileCopyrightText: 2022 Linaro Ltd.
+# SPDX-FileCopyrightTest: 2022 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
+
+EXTRA_DIST = lib.rs sim.rs
diff --git a/bindings/rust/libgpiod-sys/Makefile.am b/bindings/rust/libgpiod-sys/Makefile.am
new file mode 100644
index 0000000..9471b0e
--- /dev/null
+++ b/bindings/rust/libgpiod-sys/Makefile.am
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+# SPDX-FileCopyrightText: 2022 Linaro Ltd.
+# SPDX-FileCopyrightTest: 2022 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
+
+EXTRA_DIST = build.rs Cargo.toml README.md
+SUBDIRS = src
diff --git a/bindings/rust/libgpiod-sys/src/Makefile.am b/bindings/rust/libgpiod-sys/src/Makefile.am
new file mode 100644
index 0000000..36361e7
--- /dev/null
+++ b/bindings/rust/libgpiod-sys/src/Makefile.am
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+# SPDX-FileCopyrightText: 2022 Linaro Ltd.
+# SPDX-FileCopyrightTest: 2022 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
+
+EXTRA_DIST = lib.rs
diff --git a/bindings/rust/libgpiod/Makefile.am b/bindings/rust/libgpiod/Makefile.am
new file mode 100644
index 0000000..6b55d0d
--- /dev/null
+++ b/bindings/rust/libgpiod/Makefile.am
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+# SPDX-FileCopyrightText: 2022 Linaro Ltd.
+# SPDX-FileCopyrightTest: 2022 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
+
+EXTRA_DIST = Cargo.toml
+SUBDIRS = examples src tests
diff --git a/bindings/rust/libgpiod/examples/Makefile.am b/bindings/rust/libgpiod/examples/Makefile.am
new file mode 100644
index 0000000..6028fff
--- /dev/null
+++ b/bindings/rust/libgpiod/examples/Makefile.am
@@ -0,0 +1,14 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+# SPDX-FileCopyrightText: 2022 Linaro Ltd.
+# SPDX-FileCopyrightTest: 2022 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
+
+EXTRA_DIST = \
+	gpiodetect.rs \
+	gpio_events.rs \
+	gpiofind.rs \
+	gpioget.rs \
+	gpioinfo.rs \
+	gpiomon.rs \
+	gpioset.rs \
+	gpio_threaded_info_events.rs \
+	gpiowatch.rs
diff --git a/bindings/rust/libgpiod/src/Makefile.am b/bindings/rust/libgpiod/src/Makefile.am
new file mode 100644
index 0000000..df63c72
--- /dev/null
+++ b/bindings/rust/libgpiod/src/Makefile.am
@@ -0,0 +1,15 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+# SPDX-FileCopyrightText: 2022 Linaro Ltd.
+# SPDX-FileCopyrightTest: 2022 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
+
+EXTRA_DIST = \
+	chip.rs \
+	edge_event.rs \
+	event_buffer.rs \
+	info_event.rs \
+	lib.rs \
+	line_config.rs \
+	line_info.rs \
+	line_request.rs \
+	line_settings.rs \
+	request_config.rs
diff --git a/bindings/rust/libgpiod/tests/Makefile.am b/bindings/rust/libgpiod/tests/Makefile.am
new file mode 100644
index 0000000..198f4e4
--- /dev/null
+++ b/bindings/rust/libgpiod/tests/Makefile.am
@@ -0,0 +1,15 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+# SPDX-FileCopyrightText: 2022 Linaro Ltd.
+# SPDX-FileCopyrightTest: 2022 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
+
+EXTRA_DIST = \
+	chip.rs \
+	edge_event.rs \
+	info_event.rs \
+	line_config.rs \
+	line_info.rs \
+	line_request.rs \
+	line_settings.rs \
+	request_config.rs
+
+SUBDIRS = common
diff --git a/bindings/rust/libgpiod/tests/common/Makefile.am b/bindings/rust/libgpiod/tests/common/Makefile.am
new file mode 100644
index 0000000..4cfc355
--- /dev/null
+++ b/bindings/rust/libgpiod/tests/common/Makefile.am
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+# SPDX-FileCopyrightText: 2022 Linaro Ltd.
+# SPDX-FileCopyrightTest: 2022 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
+
+EXTRA_DIST = config.rs mod.rs
diff --git a/configure.ac b/configure.ac
index ccbb88a..dc945ef 100644
--- a/configure.ac
+++ b/configure.ac
@@ -266,7 +266,16 @@ AC_CONFIG_FILES([Makefile
 		 bindings/python/examples/Makefile
 		 bindings/python/tests/Makefile
 		 bindings/python/tests/gpiosim/Makefile
+		 bindings/rust/libgpiod-sys/src/Makefile
+		 bindings/rust/libgpiod-sys/Makefile
+		 bindings/rust/libgpiod/src/Makefile
+		 bindings/rust/libgpiod/tests/common/Makefile
+		 bindings/rust/libgpiod/tests/Makefile
+		 bindings/rust/libgpiod/Makefile
+		 bindings/rust/libgpiod/examples/Makefile
 		 bindings/rust/Makefile
+		 bindings/rust/gpiosim-sys/src/Makefile
+		 bindings/rust/gpiosim-sys/Makefile
 		 man/Makefile])
 
 AC_OUTPUT
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [libgpiod][PATCH 09/11] bindings: python: decouple the version of the bindings from libgpiod API version
  2022-11-30 12:42 [libgpiod][PATCH 00/11] treewide: an assortment of tweaks and improvements Bartosz Golaszewski
                   ` (7 preceding siblings ...)
  2022-11-30 12:42 ` [libgpiod][PATCH 08/11] bindings: rust: include rust sources in the release tarballs Bartosz Golaszewski
@ 2022-11-30 12:42 ` Bartosz Golaszewski
  2022-11-30 12:42 ` [libgpiod][PATCH 10/11] bindings: python: fix the GPIOD_WITH_TESTS build flag Bartosz Golaszewski
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 28+ messages in thread
From: Bartosz Golaszewski @ 2022-11-30 12:42 UTC (permalink / raw)
  To: Kent Gibson, Linus Walleij, Andy Shevchenko, Viresh Kumar
  Cc: linux-gpio, Bartosz Golaszewski

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

Python bindings now have their own setup.py script and can be built
separately from the rest of the code-base. Let's decouple the python
package version from libgpiod API (but let's keep a module attribute
containing the API version) by introducing a version.py submodule that
can be executed by the setup.py script. This way we have a single
canonical place defining the version number.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 bindings/python/gpiod/__init__.py     |  3 ++-
 bindings/python/gpiod/ext/module.c    |  2 +-
 bindings/python/gpiod/version.py      |  5 +++++
 bindings/python/setup.py              | 10 +++-------
 bindings/python/tests/tests_module.py | 15 ++++++++-------
 5 files changed, 19 insertions(+), 16 deletions(-)
 create mode 100644 bindings/python/gpiod/version.py

diff --git a/bindings/python/gpiod/__init__.py b/bindings/python/gpiod/__init__.py
index 7854cfd..9cbb8df 100644
--- a/bindings/python/gpiod/__init__.py
+++ b/bindings/python/gpiod/__init__.py
@@ -16,8 +16,9 @@ from .exception import ChipClosedError, RequestReleasedError
 from .info_event import InfoEvent
 from .line_request import LineRequest
 from .line_settings import LineSettings
+from .version import __version__
 
-__version__ = _ext.__version__
+api_version = _ext.api_version
 
 
 def is_gpiochip_device(path: str) -> bool:
diff --git a/bindings/python/gpiod/ext/module.c b/bindings/python/gpiod/ext/module.c
index 12fb92c..8b5a032 100644
--- a/bindings/python/gpiod/ext/module.c
+++ b/bindings/python/gpiod/ext/module.c
@@ -165,7 +165,7 @@ PyMODINIT_FUNC PyInit__ext(void)
 	if (!module)
 		return NULL;
 
-	ret = PyModule_AddStringConstant(module, "__version__",
+	ret = PyModule_AddStringConstant(module, "api_version",
 					 gpiod_version_string());
 	if (ret) {
 		Py_DECREF(module);
diff --git a/bindings/python/gpiod/version.py b/bindings/python/gpiod/version.py
new file mode 100644
index 0000000..c650969
--- /dev/null
+++ b/bindings/python/gpiod/version.py
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+# SPDX-FileCopyrightText: 2022 Linaro Ltd.
+# SPDX-FileCopyrightTest: 2022 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
+
+__version__ = "2.0.0"
diff --git a/bindings/python/setup.py b/bindings/python/setup.py
index ec8f99d..2a8481c 100644
--- a/bindings/python/setup.py
+++ b/bindings/python/setup.py
@@ -32,16 +32,12 @@ with_tests = bool(environ["GPIOD_WITH_TESTS"])
 if with_tests:
     extensions.append(gpiosim_ext)
 
-# FIXME Find a better way to get the version
-version = None
-try:
-    version = environ["GPIOD_VERSION_STR"]
-except KeyError:
-    pass
+with open("gpiod/version.py", "r") as fd:
+    exec(fd.read())
 
 setup(
     name="gpiod",
     packages=find_packages(include=["gpiod"]),
     ext_modules=extensions,
-    version=version,
+    version=__version__,
 )
diff --git a/bindings/python/tests/tests_module.py b/bindings/python/tests/tests_module.py
index 4eeae76..de56356 100644
--- a/bindings/python/tests/tests_module.py
+++ b/bindings/python/tests/tests_module.py
@@ -3,7 +3,6 @@
 
 import gpiod
 import os
-import re
 import unittest
 
 from . import gpiosim
@@ -51,9 +50,11 @@ class IsGPIOChip(TestCase):
 
 
 class VersionString(TestCase):
-    def test_version_string(self):
-        self.assertTrue(
-            re.match(
-                "^[0-9][1-9]?\\.[0-9][1-9]?([\\.0-9]?|\\-devel)$", gpiod.__version__
-            )
-        )
+
+    VERSION_PATTERN = "^[0-9][1-9]?\\.[0-9][1-9]?(\\.[0-9]?|\\-devel)$"
+
+    def test_api_version_string(self):
+        self.assertRegex(gpiod.api_version, VersionString.VERSION_PATTERN)
+
+    def test_module_version(self):
+        self.assertRegex(gpiod.__version__, VersionString.VERSION_PATTERN)
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [libgpiod][PATCH 10/11] bindings: python: fix the GPIOD_WITH_TESTS build flag
  2022-11-30 12:42 [libgpiod][PATCH 00/11] treewide: an assortment of tweaks and improvements Bartosz Golaszewski
                   ` (8 preceding siblings ...)
  2022-11-30 12:42 ` [libgpiod][PATCH 09/11] bindings: python: decouple the version of the bindings from libgpiod API version Bartosz Golaszewski
@ 2022-11-30 12:42 ` Bartosz Golaszewski
  2022-11-30 12:42 ` [libgpiod][PATCH 11/11] bindings: python: extend setup.py Bartosz Golaszewski
  2022-12-07  8:58 ` [libgpiod][PATCH 00/11] treewide: an assortment of tweaks and improvements Bartosz Golaszewski
  11 siblings, 0 replies; 28+ messages in thread
From: Bartosz Golaszewski @ 2022-11-30 12:42 UTC (permalink / raw)
  To: Kent Gibson, Linus Walleij, Andy Shevchenko, Viresh Kumar
  Cc: linux-gpio, Bartosz Golaszewski

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

Currently in order to disable test the variable needs to be explicitly
set to GPIOD_WITH_TESTS= in the environment or setup.py will crash.

Assume tests should not be built if the variable is not set at all.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 bindings/python/setup.py | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/bindings/python/setup.py b/bindings/python/setup.py
index 2a8481c..c90d7d7 100644
--- a/bindings/python/setup.py
+++ b/bindings/python/setup.py
@@ -28,8 +28,7 @@ gpiosim_ext = Extension(
 )
 
 extensions = [gpiod_ext]
-with_tests = bool(environ["GPIOD_WITH_TESTS"])
-if with_tests:
+if "GPIOD_WITH_TESTS" in environ and environ["GPIOD_WITH_TESTS"] == "1":
     extensions.append(gpiosim_ext)
 
 with open("gpiod/version.py", "r") as fd:
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [libgpiod][PATCH 11/11] bindings: python: extend setup.py
  2022-11-30 12:42 [libgpiod][PATCH 00/11] treewide: an assortment of tweaks and improvements Bartosz Golaszewski
                   ` (9 preceding siblings ...)
  2022-11-30 12:42 ` [libgpiod][PATCH 10/11] bindings: python: fix the GPIOD_WITH_TESTS build flag Bartosz Golaszewski
@ 2022-11-30 12:42 ` Bartosz Golaszewski
  2022-11-30 14:09   ` Andy Shevchenko
  2022-12-07  8:58 ` [libgpiod][PATCH 00/11] treewide: an assortment of tweaks and improvements Bartosz Golaszewski
  11 siblings, 1 reply; 28+ messages in thread
From: Bartosz Golaszewski @ 2022-11-30 12:42 UTC (permalink / raw)
  To: Kent Gibson, Linus Walleij, Andy Shevchenko, Viresh Kumar
  Cc: linux-gpio, Bartosz Golaszewski

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

Add additional information to setup.py. This will be visible in the EGG
file.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 bindings/python/setup.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/bindings/python/setup.py b/bindings/python/setup.py
index c90d7d7..7ad5de3 100644
--- a/bindings/python/setup.py
+++ b/bindings/python/setup.py
@@ -39,4 +39,9 @@ setup(
     packages=find_packages(include=["gpiod"]),
     ext_modules=extensions,
     version=__version__,
+    author="Bartosz Golaszewski",
+    author_email="brgl@bgdev.pl",
+    description="Python bindings for libgpiod",
+    platforms=["linux"],
+    license="LGPLv2.1",
 )
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* Re: [libgpiod][PATCH 02/11] treewide: apply formatting changes with clang-format
  2022-11-30 12:42 ` [libgpiod][PATCH 02/11] treewide: apply formatting changes with clang-format Bartosz Golaszewski
@ 2022-11-30 13:59   ` Andy Shevchenko
  2022-12-01 14:21     ` Bartosz Golaszewski
  0 siblings, 1 reply; 28+ messages in thread
From: Andy Shevchenko @ 2022-11-30 13:59 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Kent Gibson, Linus Walleij, Viresh Kumar, linux-gpio,
	Bartosz Golaszewski

On Wed, Nov 30, 2022 at 01:42:22PM +0100, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> 
> Use linux kernel's .clang-format file to automatically improve the coding
> style of libgpiod's C code base. We don't import the file into the
> repository as it's not perfect and certain converted fragments were
> rolled back because they looked better before the conversion.

...

>  		if (gpiod_line_settings_get_direction(
> -				per_line->node->settings) !=
> +			    per_line->node->settings) !=
>  		    GPIOD_LINE_DIRECTION_OUTPUT)
>  			continue;

Personally I percept this as an ugly indented code...

One reason is too strict 80 or whatever rule (we are almost in
the second quarter of the 21st century!), another is that trailing
opening parenthesis.

That said, some of the changes in this patch I like, some I disgust.
Quite controversial to me, but it's your project and esp. taking into
account that it's a user space, the kernel or other project rules are
not applicable in a general sense anyway.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [libgpiod][PATCH 07/11] bindings: rust: make reuse happy
  2022-11-30 12:42 ` [libgpiod][PATCH 07/11] bindings: rust: make reuse happy Bartosz Golaszewski
@ 2022-11-30 14:05   ` Andy Shevchenko
  2022-11-30 16:20     ` Bartosz Golaszewski
  2022-12-01  2:14   ` Viresh Kumar
  1 sibling, 1 reply; 28+ messages in thread
From: Andy Shevchenko @ 2022-11-30 14:05 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Kent Gibson, Linus Walleij, Viresh Kumar, linux-gpio,
	Bartosz Golaszewski

On Wed, Nov 30, 2022 at 01:42:27PM +0100, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> 
> Add missing license text files and use the CC0-1.0 license for the
> rust-specific .gitignore file.

...

> diff --git a/bindings/rust/.gitignore b/bindings/rust/.gitignore
> index 95054d9..6fe7bde 100644
> --- a/bindings/rust/.gitignore
> +++ b/bindings/rust/.gitignore
> @@ -1,4 +1,6 @@

> -# Added by cargo

Seems like automatically generated, which means that next time something comes
here may well screw up the below.

> +# SPDX-License-Identifier: CC0-1.0
> +# SPDX-FileCopyrightText: 2022 Linaro Ltd.
> +# SPDX-FileCopyrightTest: 2022 Viresh Kumar <viresh.kumar@linaro.org>

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [libgpiod][PATCH 11/11] bindings: python: extend setup.py
  2022-11-30 12:42 ` [libgpiod][PATCH 11/11] bindings: python: extend setup.py Bartosz Golaszewski
@ 2022-11-30 14:09   ` Andy Shevchenko
  2022-11-30 16:16     ` Bartosz Golaszewski
  0 siblings, 1 reply; 28+ messages in thread
From: Andy Shevchenko @ 2022-11-30 14:09 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Kent Gibson, Linus Walleij, Viresh Kumar, linux-gpio,
	Bartosz Golaszewski

On Wed, Nov 30, 2022 at 01:42:31PM +0100, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> 
> Add additional information to setup.py. This will be visible in the EGG
> file.

...

>      packages=find_packages(include=["gpiod"]),
>      ext_modules=extensions,
>      version=__version__,
> +    author="Bartosz Golaszewski",
> +    author_email="brgl@bgdev.pl",
> +    description="Python bindings for libgpiod",
> +    platforms=["linux"],

> +    license="LGPLv2.1",

Is it applicable to the bindings only? I am not familiar with the code base,
but one of the patches in this series makes me wonder if you are not going to
make same mistake by licensing tools, if any written in pure Python, with a
wrong license.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [libgpiod][PATCH 11/11] bindings: python: extend setup.py
  2022-11-30 14:09   ` Andy Shevchenko
@ 2022-11-30 16:16     ` Bartosz Golaszewski
  0 siblings, 0 replies; 28+ messages in thread
From: Bartosz Golaszewski @ 2022-11-30 16:16 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Kent Gibson, Linus Walleij, Viresh Kumar, linux-gpio,
	Bartosz Golaszewski

On Wed, Nov 30, 2022 at 3:09 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> On Wed, Nov 30, 2022 at 01:42:31PM +0100, Bartosz Golaszewski wrote:
> > From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> >
> > Add additional information to setup.py. This will be visible in the EGG
> > file.
>
> ...
>
> >      packages=find_packages(include=["gpiod"]),
> >      ext_modules=extensions,
> >      version=__version__,
> > +    author="Bartosz Golaszewski",
> > +    author_email="brgl@bgdev.pl",
> > +    description="Python bindings for libgpiod",
> > +    platforms=["linux"],
>
> > +    license="LGPLv2.1",
>
> Is it applicable to the bindings only? I am not familiar with the code base,
> but one of the patches in this series makes me wonder if you are not going to
> make same mistake by licensing tools, if any written in pure Python, with a
> wrong license.
>

Every file has its own SPDX identifier that takes precedence anyway.
The module is licensed under LGPLv2.1. The tests and examples are
under GPLv2. The setup.py applies to the importable library so
LGPLv2.1 sounds good to me.

Bart

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [libgpiod][PATCH 07/11] bindings: rust: make reuse happy
  2022-11-30 14:05   ` Andy Shevchenko
@ 2022-11-30 16:20     ` Bartosz Golaszewski
  2022-12-01  2:20       ` Viresh Kumar
  0 siblings, 1 reply; 28+ messages in thread
From: Bartosz Golaszewski @ 2022-11-30 16:20 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Kent Gibson, Linus Walleij, Viresh Kumar, linux-gpio,
	Bartosz Golaszewski

On Wed, Nov 30, 2022 at 3:05 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> On Wed, Nov 30, 2022 at 01:42:27PM +0100, Bartosz Golaszewski wrote:
> > From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> >
> > Add missing license text files and use the CC0-1.0 license for the
> > rust-specific .gitignore file.
>
> ...
>
> > diff --git a/bindings/rust/.gitignore b/bindings/rust/.gitignore
> > index 95054d9..6fe7bde 100644
> > --- a/bindings/rust/.gitignore
> > +++ b/bindings/rust/.gitignore
> > @@ -1,4 +1,6 @@
>
> > -# Added by cargo
>
> Seems like automatically generated, which means that next time something comes
> here may well screw up the below.
>

I think the comment refers to the *ignored* files *added* by cargo,
not saying that .gitignore was added by cargo.

Viresh, please confirm.

Bart

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [libgpiod][PATCH 01/11] treewide: use C enum types explicitly
  2022-11-30 12:42 ` [libgpiod][PATCH 01/11] treewide: use C enum types explicitly Bartosz Golaszewski
@ 2022-12-01  2:06   ` Viresh Kumar
  0 siblings, 0 replies; 28+ messages in thread
From: Viresh Kumar @ 2022-12-01  2:06 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Kent Gibson, Linus Walleij, Andy Shevchenko, linux-gpio,
	Bartosz Golaszewski

On 30-11-22, 13:42, Bartosz Golaszewski wrote:
>  bindings/rust/gpiosim-sys/src/lib.rs        |  42 +++--
>  bindings/rust/gpiosim-sys/src/sim.rs        |   2 +-
>  bindings/rust/libgpiod/src/lib.rs           | 169 ++++++++++++--------
>  bindings/rust/libgpiod/src/line_info.rs     |  10 +-
>  bindings/rust/libgpiod/src/line_settings.rs |  30 ++--

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

-- 
viresh

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [libgpiod][PATCH 03/11] treewide: use plural 'events' in read_edge_event() functions
  2022-11-30 12:42 ` [libgpiod][PATCH 03/11] treewide: use plural 'events' in read_edge_event() functions Bartosz Golaszewski
@ 2022-12-01  2:08   ` Viresh Kumar
  0 siblings, 0 replies; 28+ messages in thread
From: Viresh Kumar @ 2022-12-01  2:08 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Kent Gibson, Linus Walleij, Andy Shevchenko, linux-gpio,
	Bartosz Golaszewski

On 30-11-22, 13:42, Bartosz Golaszewski wrote:
>  .../rust/libgpiod/examples/gpio_events.rs     |  2 +-
>  bindings/rust/libgpiod/examples/gpiomon.rs    |  2 +-
>  bindings/rust/libgpiod/src/event_buffer.rs    |  2 +-
>  bindings/rust/libgpiod/src/line_request.rs    |  4 +-
>  bindings/rust/libgpiod/tests/edge_event.rs    | 24 ++++----
>  bindings/rust/libgpiod/tests/line_request.rs  |  2 +-

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

-- 
viresh

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [libgpiod][PATCH 04/11] treewide: rename EVENT_CLOCK to CLOCK
  2022-11-30 12:42 ` [libgpiod][PATCH 04/11] treewide: rename EVENT_CLOCK to CLOCK Bartosz Golaszewski
@ 2022-12-01  2:09   ` Viresh Kumar
  0 siblings, 0 replies; 28+ messages in thread
From: Viresh Kumar @ 2022-12-01  2:09 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Kent Gibson, Linus Walleij, Andy Shevchenko, linux-gpio,
	Bartosz Golaszewski

On 30-11-22, 13:42, Bartosz Golaszewski wrote:
>  bindings/rust/libgpiod/src/lib.rs         | 22 ++++++++++-----------

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

-- 
viresh

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [libgpiod][PATCH 05/11] gpiosim: rename HOG_DIR to DIRECTION
  2022-11-30 12:42 ` [libgpiod][PATCH 05/11] gpiosim: rename HOG_DIR to DIRECTION Bartosz Golaszewski
@ 2022-12-01  2:10   ` Viresh Kumar
  0 siblings, 0 replies; 28+ messages in thread
From: Viresh Kumar @ 2022-12-01  2:10 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Kent Gibson, Linus Walleij, Andy Shevchenko, linux-gpio,
	Bartosz Golaszewski

On 30-11-22, 13:42, Bartosz Golaszewski wrote:
>  bindings/rust/gpiosim-sys/src/lib.rs   | 12 ++++++------

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

-- 
viresh

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [libgpiod][PATCH 08/11] bindings: rust: include rust sources in the release tarballs
  2022-11-30 12:42 ` [libgpiod][PATCH 08/11] bindings: rust: include rust sources in the release tarballs Bartosz Golaszewski
@ 2022-12-01  2:13   ` Viresh Kumar
  0 siblings, 0 replies; 28+ messages in thread
From: Viresh Kumar @ 2022-12-01  2:13 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Kent Gibson, Linus Walleij, Andy Shevchenko, linux-gpio,
	Bartosz Golaszewski

On 30-11-22, 13:42, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> 
> Rust sources and Cargo files are not added to EXTRA_DIST. Add them so that
> they end up in the release tarballs generated by autotools.
> 
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> ---
>  bindings/rust/Makefile.am                       |  4 ++++
>  bindings/rust/gpiosim-sys/Makefile.am           |  6 ++++++
>  bindings/rust/gpiosim-sys/src/Makefile.am       |  5 +++++
>  bindings/rust/libgpiod-sys/Makefile.am          |  6 ++++++
>  bindings/rust/libgpiod-sys/src/Makefile.am      |  5 +++++
>  bindings/rust/libgpiod/Makefile.am              |  6 ++++++
>  bindings/rust/libgpiod/examples/Makefile.am     | 14 ++++++++++++++
>  bindings/rust/libgpiod/src/Makefile.am          | 15 +++++++++++++++
>  bindings/rust/libgpiod/tests/Makefile.am        | 15 +++++++++++++++
>  bindings/rust/libgpiod/tests/common/Makefile.am |  5 +++++
>  configure.ac                                    |  9 +++++++++
>  11 files changed, 90 insertions(+)
>  create mode 100644 bindings/rust/gpiosim-sys/Makefile.am
>  create mode 100644 bindings/rust/gpiosim-sys/src/Makefile.am
>  create mode 100644 bindings/rust/libgpiod-sys/Makefile.am
>  create mode 100644 bindings/rust/libgpiod-sys/src/Makefile.am
>  create mode 100644 bindings/rust/libgpiod/Makefile.am
>  create mode 100644 bindings/rust/libgpiod/examples/Makefile.am
>  create mode 100644 bindings/rust/libgpiod/src/Makefile.am
>  create mode 100644 bindings/rust/libgpiod/tests/Makefile.am
>  create mode 100644 bindings/rust/libgpiod/tests/common/Makefile.am

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

-- 
viresh

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [libgpiod][PATCH 07/11] bindings: rust: make reuse happy
  2022-11-30 12:42 ` [libgpiod][PATCH 07/11] bindings: rust: make reuse happy Bartosz Golaszewski
  2022-11-30 14:05   ` Andy Shevchenko
@ 2022-12-01  2:14   ` Viresh Kumar
  1 sibling, 0 replies; 28+ messages in thread
From: Viresh Kumar @ 2022-12-01  2:14 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Kent Gibson, Linus Walleij, Andy Shevchenko, linux-gpio,
	Bartosz Golaszewski

On 30-11-22, 13:42, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> 
> Add missing license text files and use the CC0-1.0 license for the
> rust-specific .gitignore file.
> 
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> ---
>  LICENSES/Apache-2.0.txt   | 201 ++++++++++++++++++++++++++++++++++++++
>  LICENSES/BSD-3-Clause.txt |  28 ++++++
>  LICENSES/CC0-1.0.txt      | 121 +++++++++++++++++++++++
>  Makefile.am               |   9 +-
>  bindings/rust/.gitignore  |   4 +-
>  5 files changed, 359 insertions(+), 4 deletions(-)
>  create mode 100644 LICENSES/Apache-2.0.txt
>  create mode 100644 LICENSES/BSD-3-Clause.txt
>  create mode 100644 LICENSES/CC0-1.0.txt

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

-- 
viresh

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [libgpiod][PATCH 07/11] bindings: rust: make reuse happy
  2022-11-30 16:20     ` Bartosz Golaszewski
@ 2022-12-01  2:20       ` Viresh Kumar
  2022-12-01  8:29         ` Bartosz Golaszewski
  0 siblings, 1 reply; 28+ messages in thread
From: Viresh Kumar @ 2022-12-01  2:20 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Andy Shevchenko, Kent Gibson, Linus Walleij, linux-gpio,
	Bartosz Golaszewski

On 30-11-22, 17:20, Bartosz Golaszewski wrote:
> On Wed, Nov 30, 2022 at 3:05 PM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> >
> > On Wed, Nov 30, 2022 at 01:42:27PM +0100, Bartosz Golaszewski wrote:
> > > From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> > >
> > > Add missing license text files and use the CC0-1.0 license for the
> > > rust-specific .gitignore file.
> >
> > ...
> >
> > > diff --git a/bindings/rust/.gitignore b/bindings/rust/.gitignore
> > > index 95054d9..6fe7bde 100644
> > > --- a/bindings/rust/.gitignore
> > > +++ b/bindings/rust/.gitignore
> > > @@ -1,4 +1,6 @@
> >
> > > -# Added by cargo
> >
> > Seems like automatically generated, which means that next time something comes
> > here may well screw up the below.
> >
> 
> I think the comment refers to the *ignored* files *added* by cargo,
> not saying that .gitignore was added by cargo.

Yes. Cargo, by itself, updated the root folder's .gitignore I think and I had to
copy/paste stuff here.

-- 
viresh

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [libgpiod][PATCH 07/11] bindings: rust: make reuse happy
  2022-12-01  2:20       ` Viresh Kumar
@ 2022-12-01  8:29         ` Bartosz Golaszewski
  2022-12-01  9:00           ` Viresh Kumar
  0 siblings, 1 reply; 28+ messages in thread
From: Bartosz Golaszewski @ 2022-12-01  8:29 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: Andy Shevchenko, Kent Gibson, Linus Walleij, linux-gpio,
	Bartosz Golaszewski

On Thu, Dec 1, 2022 at 3:20 AM Viresh Kumar <viresh.kumar@linaro.org> wrote:
>
> On 30-11-22, 17:20, Bartosz Golaszewski wrote:
> > On Wed, Nov 30, 2022 at 3:05 PM Andy Shevchenko
> > <andriy.shevchenko@linux.intel.com> wrote:
> > >
> > > On Wed, Nov 30, 2022 at 01:42:27PM +0100, Bartosz Golaszewski wrote:
> > > > From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> > > >
> > > > Add missing license text files and use the CC0-1.0 license for the
> > > > rust-specific .gitignore file.
> > >
> > > ...
> > >
> > > > diff --git a/bindings/rust/.gitignore b/bindings/rust/.gitignore
> > > > index 95054d9..6fe7bde 100644
> > > > --- a/bindings/rust/.gitignore
> > > > +++ b/bindings/rust/.gitignore
> > > > @@ -1,4 +1,6 @@
> > >
> > > > -# Added by cargo
> > >
> > > Seems like automatically generated, which means that next time something comes
> > > here may well screw up the below.
> > >
> >
> > I think the comment refers to the *ignored* files *added* by cargo,
> > not saying that .gitignore was added by cargo.
>
> Yes. Cargo, by itself, updated the root folder's .gitignore I think and I had to
> copy/paste stuff here.
>

OMG cargo cares about the VCS of the project it builds? Good to know I guess.

Bart

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [libgpiod][PATCH 07/11] bindings: rust: make reuse happy
  2022-12-01  8:29         ` Bartosz Golaszewski
@ 2022-12-01  9:00           ` Viresh Kumar
  0 siblings, 0 replies; 28+ messages in thread
From: Viresh Kumar @ 2022-12-01  9:00 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Andy Shevchenko, Kent Gibson, Linus Walleij, linux-gpio,
	Bartosz Golaszewski

On 01-12-22, 09:29, Bartosz Golaszewski wrote:
> OMG cargo cares about the VCS of the project it builds? Good to know I guess.

By default it is git. You can specify --vcs option to Cargo init [1].

--vcs vcs

Initialize a new VCS repository for the given version control system (git, hg,
pijul, or fossil) or do not initialize any version control at all (none). If not
specified, defaults to git or the configuration value cargo-new.vcs, or none if
already inside a VCS repository.

-- 
viresh

[1] https://doc.rust-lang.org/cargo/commands/cargo-new.html

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [libgpiod][PATCH 02/11] treewide: apply formatting changes with clang-format
  2022-11-30 13:59   ` Andy Shevchenko
@ 2022-12-01 14:21     ` Bartosz Golaszewski
  0 siblings, 0 replies; 28+ messages in thread
From: Bartosz Golaszewski @ 2022-12-01 14:21 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Kent Gibson, Linus Walleij, Viresh Kumar, linux-gpio,
	Bartosz Golaszewski

On Wed, Nov 30, 2022 at 2:59 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> On Wed, Nov 30, 2022 at 01:42:22PM +0100, Bartosz Golaszewski wrote:
> > From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> >
> > Use linux kernel's .clang-format file to automatically improve the coding
> > style of libgpiod's C code base. We don't import the file into the
> > repository as it's not perfect and certain converted fragments were
> > rolled back because they looked better before the conversion.
>
> ...
>
> >               if (gpiod_line_settings_get_direction(
> > -                             per_line->node->settings) !=
> > +                         per_line->node->settings) !=
> >                   GPIOD_LINE_DIRECTION_OUTPUT)
> >                       continue;
>
> Personally I percept this as an ugly indented code...
>
> One reason is too strict 80 or whatever rule (we are almost in
> the second quarter of the 21st century!), another is that trailing
> opening parenthesis.

This is very much a question of personal preference and as the
maintainer I get to pick and choose the coding style for the project
but let me provide a personal argument in favor of the 80 line limit.
I mostly work with C and use a single big screen for work. When the
limit is set to 80 chars (or 88 which is standard for python), I get
to have four columns of code on my screen and still work comfortably.
Unless it really adds to the readability, I prefer to keep it.

Bart

>
> That said, some of the changes in this patch I like, some I disgust.
> Quite controversial to me, but it's your project and esp. taking into
> account that it's a user space, the kernel or other project rules are
> not applicable in a general sense anyway.
>
> --
> With Best Regards,
> Andy Shevchenko
>
>

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [libgpiod][PATCH 00/11] treewide: an assortment of tweaks and improvements
  2022-11-30 12:42 [libgpiod][PATCH 00/11] treewide: an assortment of tweaks and improvements Bartosz Golaszewski
                   ` (10 preceding siblings ...)
  2022-11-30 12:42 ` [libgpiod][PATCH 11/11] bindings: python: extend setup.py Bartosz Golaszewski
@ 2022-12-07  8:58 ` Bartosz Golaszewski
  11 siblings, 0 replies; 28+ messages in thread
From: Bartosz Golaszewski @ 2022-12-07  8:58 UTC (permalink / raw)
  To: Kent Gibson, Linus Walleij, Andy Shevchenko, Viresh Kumar
  Cc: linux-gpio, Bartosz Golaszewski

On Wed, Nov 30, 2022 at 1:42 PM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
>
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>
> This series contains various changes for libgpiod v2. There's no main theme
> to it really, just fixing problems I noticed and introducing some more
> changes to the API.
>

It's been a week, there are no objections so I applied the series.

Bart

^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2022-12-07  8:58 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-30 12:42 [libgpiod][PATCH 00/11] treewide: an assortment of tweaks and improvements Bartosz Golaszewski
2022-11-30 12:42 ` [libgpiod][PATCH 01/11] treewide: use C enum types explicitly Bartosz Golaszewski
2022-12-01  2:06   ` Viresh Kumar
2022-11-30 12:42 ` [libgpiod][PATCH 02/11] treewide: apply formatting changes with clang-format Bartosz Golaszewski
2022-11-30 13:59   ` Andy Shevchenko
2022-12-01 14:21     ` Bartosz Golaszewski
2022-11-30 12:42 ` [libgpiod][PATCH 03/11] treewide: use plural 'events' in read_edge_event() functions Bartosz Golaszewski
2022-12-01  2:08   ` Viresh Kumar
2022-11-30 12:42 ` [libgpiod][PATCH 04/11] treewide: rename EVENT_CLOCK to CLOCK Bartosz Golaszewski
2022-12-01  2:09   ` Viresh Kumar
2022-11-30 12:42 ` [libgpiod][PATCH 05/11] gpiosim: rename HOG_DIR to DIRECTION Bartosz Golaszewski
2022-12-01  2:10   ` Viresh Kumar
2022-11-30 12:42 ` [libgpiod][PATCH 06/11] tools: display the correct license with --version Bartosz Golaszewski
2022-11-30 12:42 ` [libgpiod][PATCH 07/11] bindings: rust: make reuse happy Bartosz Golaszewski
2022-11-30 14:05   ` Andy Shevchenko
2022-11-30 16:20     ` Bartosz Golaszewski
2022-12-01  2:20       ` Viresh Kumar
2022-12-01  8:29         ` Bartosz Golaszewski
2022-12-01  9:00           ` Viresh Kumar
2022-12-01  2:14   ` Viresh Kumar
2022-11-30 12:42 ` [libgpiod][PATCH 08/11] bindings: rust: include rust sources in the release tarballs Bartosz Golaszewski
2022-12-01  2:13   ` Viresh Kumar
2022-11-30 12:42 ` [libgpiod][PATCH 09/11] bindings: python: decouple the version of the bindings from libgpiod API version Bartosz Golaszewski
2022-11-30 12:42 ` [libgpiod][PATCH 10/11] bindings: python: fix the GPIOD_WITH_TESTS build flag Bartosz Golaszewski
2022-11-30 12:42 ` [libgpiod][PATCH 11/11] bindings: python: extend setup.py Bartosz Golaszewski
2022-11-30 14:09   ` Andy Shevchenko
2022-11-30 16:16     ` Bartosz Golaszewski
2022-12-07  8:58 ` [libgpiod][PATCH 00/11] treewide: an assortment of tweaks and improvements Bartosz Golaszewski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.