From patchwork Wed Nov 30 12:42:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 629730 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 90F6AC4708A for ; Wed, 30 Nov 2022 12:42:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234798AbiK3Mmx (ORCPT ); Wed, 30 Nov 2022 07:42:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234607AbiK3Mmt (ORCPT ); Wed, 30 Nov 2022 07:42:49 -0500 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F40F310FFA for ; Wed, 30 Nov 2022 04:42:37 -0800 (PST) Received: by mail-wr1-x42a.google.com with SMTP id x17so26869382wrn.6 for ; Wed, 30 Nov 2022 04:42:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tjTPJ7l3MPIYMCNcQHBVBhcoW9q7XcXRc5B6133NoOc=; b=B9U0NeX1sVCN2eLCS7wMlkI0Wua9M2ib9SPHk623eUDNpmyMytJD5+Z170a3FpO+qd 7jz88b2aSxRtVQOwWdn4kwSKQQ9Z+C/TrhkQs0tRgbuqHbX5uLMhLEm2Kh5daKHI8sVv 1i71wZZjhgms+3Jvs88nWqXg/YJ3cDj/7XSgc+Kb3miKsVQ11z2juD4ui4/wbl7laNC+ mXkWQxxyTeqWYvBG3Br8JmsU/aFohXhNi0wCXl3HEDuUZsKTj/aDtTBLmbzvPskMqS0/ Kua9bsVp87Mw591bvrEKytwivofA15Tt6bJjB9VlV8+FmoDs5jcOni+7ZGC251scOXjf w+PQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tjTPJ7l3MPIYMCNcQHBVBhcoW9q7XcXRc5B6133NoOc=; b=tE/8hDk69ECswIybYYpsHa6dLFQztC6vOssYe30EJOaTpraIIKtzgOhQlQv2+JqEas d4hqq23GiMcy339YhRjGbOPNiQtg8np/QEg6hzf9CaV0U+l+kBCBFU9p5cn/5gL7vEOf OSpx7PTWJQlc4orhSP7wBcPtOLCQzhO8blBii61EhU0lfKaenhAbcJgPdT7UYdbAvMKa gFtxrir7/64xkWhtJu/Gh5aoltiQ8ExfWufBqT4bQpflwKbH1ZYAUMAsp0W/EiA8R53g 4iN6WdXvspE+VwMFQVfqJz1ytAV2YLo1MxTucjQaJTr+6ZQMDbTPCqThkj03ZWVJdXcS 2doA== X-Gm-Message-State: ANoB5pmkosQ1UK3CKTf7Bmtsi7fd0s2s8UCYtwqDG1plQDSut2+OiDpO YiS7zaWhNXYqz/0nppYZuTp3AQ== X-Google-Smtp-Source: AA0mqf6YPY30y3uIjIrNgg7P2mwBVphGkg9gJGILRXrfJMFv8ECSIrGRJ0MZUVyTigYKrGXVc/rRKQ== X-Received: by 2002:a5d:614b:0:b0:242:18a0:d03 with SMTP id y11-20020a5d614b000000b0024218a00d03mr8788118wrt.542.1669812156014; Wed, 30 Nov 2022 04:42:36 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:458c:6db9:e033:a468]) by smtp.gmail.com with ESMTPSA id z2-20020a5d4402000000b00226dba960b4sm1514985wrq.3.2022.11.30.04.42.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Nov 2022 04:42:35 -0800 (PST) From: Bartosz Golaszewski To: Kent Gibson , Linus Walleij , Andy Shevchenko , Viresh Kumar Cc: linux-gpio@vger.kernel.org, Bartosz Golaszewski Subject: [libgpiod][PATCH 01/11] treewide: use C enum types explicitly Date: Wed, 30 Nov 2022 13:42:21 +0100 Message-Id: <20221130124231.1054001-2-brgl@bgdev.pl> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221130124231.1054001-1-brgl@bgdev.pl> References: <20221130124231.1054001-1-brgl@bgdev.pl> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Bartosz Golaszewski 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 [Viresh: make rust bindings work with negative enum values] Co-authored-by: Viresh Kumar --- 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 enum_type -map_int_to_enum(int value, const ::std::map& mapping) +template cxx_enum_type +map_enum_c_to_cxx(c_enum_type value, const ::std::map& 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(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(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(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(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 -::std::map make_reverse_maping(const ::std::map& mapping) +template +::std::map +make_reverse_maping(const ::std::map& mapping) { - ::std::map ret; + ::std::map ret; for (const auto &item: mapping) ret[item.second] = item.first; @@ -21,54 +22,56 @@ template return ret; } -const ::std::map direction_mapping = { +const ::std::map 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 reverse_direction_mapping = make_reverse_maping(direction_mapping); +const ::std::map +reverse_direction_mapping = make_reverse_maping(direction_mapping); -const ::std::map edge_mapping = { +const ::std::map 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 reverse_edge_mapping = make_reverse_maping(edge_mapping); +const ::std::map reverse_edge_mapping = make_reverse_maping(edge_mapping); -const ::std::map bias_mapping = { +const ::std::map 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 reverse_bias_mapping = make_reverse_maping(bias_mapping); +const ::std::map reverse_bias_mapping = make_reverse_maping(bias_mapping); -const ::std::map drive_mapping = { +const ::std::map 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 reverse_drive_mapping = make_reverse_maping(drive_mapping); +const ::std::map reverse_drive_mapping = make_reverse_maping(drive_mapping); -const ::std::map clock_mapping = { +const ::std::map 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 reverse_clock_mapping = make_reverse_maping(clock_mapping); +const ::std::map +reverse_clock_mapping = make_reverse_maping(clock_mapping); -const ::std::map value_mapping = { +const ::std::map value_mapping = { { line::value::INACTIVE, GPIOD_LINE_VALUE_INACTIVE }, { line::value::ACTIVE, GPIOD_LINE_VALUE_ACTIVE } }; -const ::std::map reverse_value_mapping = make_reverse_maping(value_mapping); +const ::std::map 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 -int do_map_value(enum_type value, const ::std::map& mapping) +template +c_enum_type do_map_value(cxx_enum_type value, const ::std::map& mapping) { - return map_setting(value, mapping); + return map_setting(value, mapping); } -template -void set_mapped_value(::gpiod_line_settings* settings, enum_type value, - const ::std::map& mapping) +template +void set_mapped_value(::gpiod_line_settings* settings, cxx_enum_type value, + const ::std::map& 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 -ret_type get_mapped_value(::gpiod_line_settings* settings, - const ::std::map& mapping) +template +cxx_enum_type get_mapped_value(::gpiod_line_settings* settings, + const ::std::map& 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(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( 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(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( 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(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(this->_m_priv->settings.get(), reverse_bias_mapping); } GPIOD_CXX_API line_settings& line_settings::set_drive(line::drive drive) { - set_mapped_value(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(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(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( 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(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( 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 pull_mapping = { +const ::std::map pull_mapping = { { chip::pull::PULL_UP, GPIOSIM_PULL_UP }, { chip::pull::PULL_DOWN, GPIOSIM_PULL_DOWN } }; -const ::std::map hog_dir_mapping = { +const ::std::map 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 value_mapping = { +const ::std::map 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 -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 { - 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 { + 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; impl Value { - pub fn new(val: i32) -> Result { + pub fn new(val: gpiod::gpiod_line_value) -> Result { 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 { + pub(crate) fn new(dir: gpiod::gpiod_line_direction) -> Result { 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> { + pub(crate) fn new(bias: gpiod::gpiod_line_bias) -> Result> { 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) -> u32 { + pub(crate) fn gpiod_bias(bias: Option) -> 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 { + pub(crate) fn new(drive: gpiod::gpiod_line_drive) -> Result { 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> { + pub(crate) fn new(edge: gpiod::gpiod_line_edge) -> Result> { 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) -> u32 { + pub(crate) fn gpiod_edge(edge: Option) -> 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 { + pub(crate) fn new(clock: gpiod::gpiod_line_event_clock) -> Result { 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 { + pub(crate) fn new(kind: gpiod::gpiod_info_event_type) -> Result { 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 { + pub(crate) fn new(kind: gpiod::gpiod_edge_event_type) -> Result { 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 { // 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> { // 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 { // 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> { // 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 { // 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 { // 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) -> 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> { // 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) -> 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> { // 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 { // 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__ */ From patchwork Wed Nov 30 12:42:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 629732 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 63CEDC352A1 for ; Wed, 30 Nov 2022 12:42:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234863AbiK3Mmw (ORCPT ); Wed, 30 Nov 2022 07:42:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235013AbiK3Mmm (ORCPT ); Wed, 30 Nov 2022 07:42:42 -0500 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4811C1A203 for ; Wed, 30 Nov 2022 04:42:40 -0800 (PST) Received: by mail-wr1-x42a.google.com with SMTP id bx10so14815076wrb.0 for ; Wed, 30 Nov 2022 04:42:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vJMIlBROsaNe4gxNcCnDB6MLPqghliTCjuy3UxJV31w=; b=oy/j/l1S/FH/3Glhz9G7UbyWuCKl1tFhXwVHVSX2jmV2qnlnv0NDoiEzmRMRe6hceX RXt7fM4kWPb79mqKYfsryB5ec25dkA27NoKLjb5TWgZeVgsKBE0MNa2VBAS18Mu59dcx 9hYIpKxTnJWqTMeGuvFC2cIgMjUvwYBsQSkN1/twHWQo8r2owVLFqC2MNzAly/o4kdca flo5OFTj2QAwaxK59++kjktDrXyhIvy8QFkTPPMyYJYyQ4uNwBi8k3TquY4subVcuS6Y kAlNBqrbI7NRKx7HCigAczdgMEVdwutD7442NKHh3MYbBRsx3aaFq1RFykxc35ONzXRc +PbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vJMIlBROsaNe4gxNcCnDB6MLPqghliTCjuy3UxJV31w=; b=6YNlION13GTPqhuKAaHKyKYTsrRk1eab805DeEwhmZ3UQr93+gqp8s4AAiPxm/syjy pNOQVVC9a1gxcLQ69NMrvThvGu7BQXGedi+Jo6d3W2N4ug+Hkli6wFlFJaGgp1KGjVN+ 4Jn5+WDRsBIn1A6PK2TxV65zXbX7Fd/U7qeu64UcLuOHwoGO8xYFNJLx2hCtUv+YLWu0 Fi5h+dqmJIEl4tG/WGHdeWrNJ49JK5y7MKk6hs4w+AeAYb2OWku3krS8/5GruIqJTubV 1dGqVeFJxtJkmY18LtmXJVl5rL/uAJTBDR3sPEc/zjqQ1RH8tmfnGL1POdWO7Ab+28LO tvmA== X-Gm-Message-State: ANoB5plfh6twsjd5KwA3dP6OU5qiSR4EJCFQfNc6OBrUDENwYnJbxiTA /dtQNN3DgFrNpPJL+ky0hRPCcQ== X-Google-Smtp-Source: AA0mqf6K1XTtQS4Q5FkLA5TL1O5IXtYDZ0XemLIsflsAs3V2ibkgnCVLiv6Lw9xDgRVFwqH0/keFNg== X-Received: by 2002:adf:eecf:0:b0:241:d333:c95d with SMTP id a15-20020adfeecf000000b00241d333c95dmr30224552wrp.301.1669812158622; Wed, 30 Nov 2022 04:42:38 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:458c:6db9:e033:a468]) by smtp.gmail.com with ESMTPSA id z2-20020a5d4402000000b00226dba960b4sm1514985wrq.3.2022.11.30.04.42.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Nov 2022 04:42:38 -0800 (PST) From: Bartosz Golaszewski To: Kent Gibson , Linus Walleij , Andy Shevchenko , Viresh Kumar Cc: linux-gpio@vger.kernel.org, Bartosz Golaszewski Subject: [libgpiod][PATCH 04/11] treewide: rename EVENT_CLOCK to CLOCK Date: Wed, 30 Nov 2022 13:42:24 +0100 Message-Id: <20221130124231.1054001-5-brgl@bgdev.pl> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221130124231.1054001-1-brgl@bgdev.pl> References: <20221130124231.1054001-1-brgl@bgdev.pl> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Bartosz Golaszewski 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 --- 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 edge_mapping = { }; const ::std::map 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 drive_mapping = { const ::std::map reverse_drive_mapping = make_reverse_maping(drive_mapping); -const ::std::map 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 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 +const ::std::map reverse_clock_mapping = make_reverse_maping(clock_mapping); const ::std::map 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(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( 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 { + pub(crate) fn new(clock: gpiod::gpiod_line_clock) -> Result { 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: From patchwork Wed Nov 30 12:42:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 629731 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24F30C4332F for ; Wed, 30 Nov 2022 12:42:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235147AbiK3Mmy (ORCPT ); Wed, 30 Nov 2022 07:42:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235032AbiK3Mmt (ORCPT ); Wed, 30 Nov 2022 07:42:49 -0500 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E55D81B1C9 for ; Wed, 30 Nov 2022 04:42:41 -0800 (PST) Received: by mail-wr1-x434.google.com with SMTP id v1so26866883wrt.11 for ; Wed, 30 Nov 2022 04:42:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=emp/AM2e2PfjsIK3lkYn8k6SeYggLBilZf6TLD/dWfg=; b=ksJzkKgbaC4Jq581Nw8lSpsuswTx1vgOP7QXdU4MPLip709OwWm8t+E2yLgsn2nLMw dxWmaYkFOSDlFNQD6JBhiYT/ItTtCOLftOoHfxkBK0K4DBJwuOX1eBDuNmaibEWxX29y I9XdBHWnGeNdaq5BkNXZugsxi2cLckOPuwmD7YF0Z7bZMYbc8H32OF/NvusTBaUmXZKA XFik0Z/PWuusltMzz2QZ2eZAMSy2Bgd4KjIS2hElsHCX1sml+H9UYGvLwXkDvhn6t/pw sy4JLBXj2N1I7wCPfzHtoMFBCfOrYTYxyldBeH6THHEaIk7Gz8GOESdA2UQi3ZUNwjeM w9Pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=emp/AM2e2PfjsIK3lkYn8k6SeYggLBilZf6TLD/dWfg=; b=EzkDcjUyo+gUfLIDBxa20lk7p3yI8knul7L8UvS7aMa0u0f9FBAxz8ioDrqwK9psWT ceHUqS/b+qtzQmc6zZacp5VO7Yl6LSdqg+0JQGF+tyYO5eDJuSE/3/AMDdCSm9X23voP uRu98gRcPFMgo6CxuxKhW41M1h/4JgacCat2jQ6nFKJtg3KEBu362NCA6te71Xjuqgb5 kPXeNyVDsc/1hp5NiCDBHMyrxTzdMG2ZYGqbIblbZnxCuvhdw6oaCvT//sS/Vy0Bvwhr QMs4XwRR+emxCk6+f2xTddFvUQ0dNS7F1GeUpYOsKaMN2Sz8huNSscDwldte8rq/sByM FmTQ== X-Gm-Message-State: ANoB5pm/roKyFsbxvjJFGjG7r6dIw5iN9iD5qu/wS6hf+yQOapl82aAv cNLdYMCiEg0l+djE0fCMZDzX6Q== X-Google-Smtp-Source: AA0mqf7FFem6N64zw3kdi4cqr0l2LeUOem+cWFXv3PaGi6tl+I++qygLKM5H9e/xiH5gRh51HMnj2g== X-Received: by 2002:adf:f944:0:b0:236:8f54:f1f4 with SMTP id q4-20020adff944000000b002368f54f1f4mr38019370wrr.654.1669812160441; Wed, 30 Nov 2022 04:42:40 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:458c:6db9:e033:a468]) by smtp.gmail.com with ESMTPSA id z2-20020a5d4402000000b00226dba960b4sm1514985wrq.3.2022.11.30.04.42.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Nov 2022 04:42:40 -0800 (PST) From: Bartosz Golaszewski To: Kent Gibson , Linus Walleij , Andy Shevchenko , Viresh Kumar Cc: linux-gpio@vger.kernel.org, Bartosz Golaszewski Subject: [libgpiod][PATCH 06/11] tools: display the correct license with --version Date: Wed, 30 Nov 2022 13:42:26 +0100 Message-Id: <20221130124231.1054001-7-brgl@bgdev.pl> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221130124231.1054001-1-brgl@bgdev.pl> References: <20221130124231.1054001-1-brgl@bgdev.pl> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Bartosz Golaszewski The tools are licensed under GPL-2.0-or-later so fix the output of --version. Signed-off-by: Bartosz Golaszewski --- 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"); } From patchwork Wed Nov 30 12:42:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 629729 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4885C433FE for ; Wed, 30 Nov 2022 12:43:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234896AbiK3Mm5 (ORCPT ); Wed, 30 Nov 2022 07:42:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234981AbiK3Mmt (ORCPT ); Wed, 30 Nov 2022 07:42:49 -0500 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0EA0224964 for ; Wed, 30 Nov 2022 04:42:43 -0800 (PST) Received: by mail-wr1-x42e.google.com with SMTP id q7so25991680wrr.8 for ; Wed, 30 Nov 2022 04:42:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=sl+xv4q2tfhzTmF01XGBemge0X7KFVMYQeCKJ44wxQU=; b=Mp0zLM7G3xTVMvDa/XBp1v1dxhvNF8ajk8Ce0jKsQaM+8hRJZPxnTBve85x8V05YMw ZPPF1iLrqezVYbJqjk03T4ASF5banzWW9CtGEifp9Qm1TOq5YZA4CGW7O6K1Inq7QIX0 rhiLBzB3tB1H4MlH84bRn8JZ9TpQ5s7XH10pNfKuDg18zlwMmGK4PkzRjYN38hY9pYXC Ge5lfUuMp8oDlxjJcTWXELtOfsXUvm0oVbTS0/rTx/M4ql0AFMuKG3IhdKBUCv+TvDzM iATh8P22cHnybz6zV260C03G011r8YZ6BE2DR7WtxC70LZFD4GJLwvRpj4HlQi2avGOf w4lQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sl+xv4q2tfhzTmF01XGBemge0X7KFVMYQeCKJ44wxQU=; b=VtWHTIsy8l8r8O9I4SNZtsezcaYAZ9VSkRcdpB/48MtBK1OHgLYizQrPF6SlptQY/K mPAr/fBWG06xDMFcvTH7aKbhqlI/jIYFy8T+gEIJquPbsEnF7x1P3KMBIOXMOlwlKjD8 3+XIkws2J3PmqT26mCdxZDpb26sbhN9W1cifaRgXZXBSFsuTKIcTN/+3QU4wDT1tuWYj MpExoj0PtGwfOTuSAjdPk2VVwmElRwFj2tv0xaS9UBvpI1CRt8aRSQfzZFIEYDWNn5tb k51e0h+yX8F/rfCNkmIEf4syr1yvWce8p7JYXzlvPxR+p2quI5piwJD8R8TAR8/cFjtK twZQ== X-Gm-Message-State: ANoB5pk0lV+9xraMGisCYHnbsNYaVa6eUBgZTQH2gn6aML4nJpYQUUSP +DC50kZAcByLp24AZXfP31pA+Q== X-Google-Smtp-Source: AA0mqf6XnR06fx/90mqBC3B4j0T78VROH2UsriItq3E/krzQPb7OVoA4+m5soXnyXx3Pl7+/drPXqQ== X-Received: by 2002:adf:f2d0:0:b0:242:7c:eb9c with SMTP id d16-20020adff2d0000000b00242007ceb9cmr18708889wrp.178.1669812161327; Wed, 30 Nov 2022 04:42:41 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:458c:6db9:e033:a468]) by smtp.gmail.com with ESMTPSA id z2-20020a5d4402000000b00226dba960b4sm1514985wrq.3.2022.11.30.04.42.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Nov 2022 04:42:40 -0800 (PST) From: Bartosz Golaszewski To: Kent Gibson , Linus Walleij , Andy Shevchenko , Viresh Kumar Cc: linux-gpio@vger.kernel.org, Bartosz Golaszewski Subject: [libgpiod][PATCH 07/11] bindings: rust: make reuse happy Date: Wed, 30 Nov 2022 13:42:27 +0100 Message-Id: <20221130124231.1054001-8-brgl@bgdev.pl> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221130124231.1054001-1-brgl@bgdev.pl> References: <20221130124231.1054001-1-brgl@bgdev.pl> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Bartosz Golaszewski Add missing license text files and use the CC0-1.0 license for the rust-specific .gitignore file. Signed-off-by: Bartosz Golaszewski --- 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 target Cargo.lock From patchwork Wed Nov 30 12:42:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 629728 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8E8CFC4332F for ; Wed, 30 Nov 2022 12:43:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235033AbiK3MnB (ORCPT ); Wed, 30 Nov 2022 07:43:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235045AbiK3Mmu (ORCPT ); Wed, 30 Nov 2022 07:42:50 -0500 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E55E1DF38 for ; Wed, 30 Nov 2022 04:42:43 -0800 (PST) Received: by mail-wr1-x42d.google.com with SMTP id o5so17881565wrm.1 for ; Wed, 30 Nov 2022 04:42:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NoA96d790qRsQ89rnEEt4R8/o1xErl2dRBGy7ZRzhJc=; b=5WX8VPDMPPIw+EZo0+Ah82fYUjm44LTKSIaJli/U68TT1TXMvb36rLfD2s6PGJMi/8 pZeQNd0gGZaRyKB/huKbl5FJdhm96XRBDv0vwvOUm/ToQVOq71DggyejkMfM3nkZxweK IlFe/BYtiqGP5dT+LCSRd7E2/jqMlf7e5UPPuspBiWD0xWilP/QcaToLZpLDggYYQ6sd 84wdRxJRw1hv05gauX41xouS1ExwOhODXx9IEyZWi8Zd6uEAo3w1hECjI2c9duGXvi4K 93Cq54Lx9s1lqq0TcFHmMrWaNRhl7yPIjUcf8Ja+hPYfiYTw0Bc6oBe3CnQ2XR7ZF1uh 9akA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NoA96d790qRsQ89rnEEt4R8/o1xErl2dRBGy7ZRzhJc=; b=LcCutciVLqSgESTQlcWWzI7Z3lTk7lspeGMFXKUCgUwkxG1A2UlvCp/3EYnsJJoort sRXkWPpxgRgtC7F9kqPJhn0IUWKwUa/Y+HDIsRbcmX9Y5BGBc+d4NLzl7xfviJ4/xJXq JozSx8a7a2c3RJ2Bqh7ANYA29gbwJi+yszDjy5DFb/3dcaz085AamUg7kOOgfFaynDGL 3bGk+zBs8OblHjojFpMqsyK5c+C0A68C5qeSBHaWhY7co0JEu08GAk+XnjstaKYIJKpJ OpuYN6bjBYpTwGJ/hEhd3PUelHeJXv/8jykJ2kklyqOLwP6kaf+AvHaNpTl1dFDE6W8m SF6g== X-Gm-Message-State: ANoB5pm4JE8/NzMDayzU4q4cSR83BvZyFdEH73nASPj1tC7p1Zti5fV5 yYfk3EuXa6Hk1983w98SFFbFMA== X-Google-Smtp-Source: AA0mqf5KnGyE/Fo8S6kSnpHk3I0bI1SioE0Fid7URYDX8By2onou5wd1YLHVkAhIf4izRRQpQddDNg== X-Received: by 2002:a5d:65c9:0:b0:241:bd29:6a73 with SMTP id e9-20020a5d65c9000000b00241bd296a73mr36070074wrw.499.1669812162130; Wed, 30 Nov 2022 04:42:42 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:458c:6db9:e033:a468]) by smtp.gmail.com with ESMTPSA id z2-20020a5d4402000000b00226dba960b4sm1514985wrq.3.2022.11.30.04.42.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Nov 2022 04:42:41 -0800 (PST) From: Bartosz Golaszewski To: Kent Gibson , Linus Walleij , Andy Shevchenko , Viresh Kumar Cc: linux-gpio@vger.kernel.org, Bartosz Golaszewski Subject: [libgpiod][PATCH 08/11] bindings: rust: include rust sources in the release tarballs Date: Wed, 30 Nov 2022 13:42:28 +0100 Message-Id: <20221130124231.1054001-9-brgl@bgdev.pl> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221130124231.1054001-1-brgl@bgdev.pl> References: <20221130124231.1054001-1-brgl@bgdev.pl> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Bartosz Golaszewski 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 --- 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 + +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 + +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 + +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 + +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 + +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 + +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 + +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 + +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 + +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 From patchwork Wed Nov 30 12:42:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 629727 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2F333C4332F for ; Wed, 30 Nov 2022 12:43:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235162AbiK3MnG (ORCPT ); Wed, 30 Nov 2022 07:43:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235084AbiK3Mmv (ORCPT ); Wed, 30 Nov 2022 07:42:51 -0500 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80BCC2611F for ; Wed, 30 Nov 2022 04:42:46 -0800 (PST) Received: by mail-wr1-x432.google.com with SMTP id o5so17881720wrm.1 for ; Wed, 30 Nov 2022 04:42:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7ZEJJxh2XaMBv4jBFweZR3RGB2Sg6NR3wHGmrq3luIQ=; b=zhyI9XpBkTltr35y55zqhU2COjvOkMrFg7IV+5xnJoEUC0wczqrY2j3R05pqciYBje VMOl0g0/TjJwQc0Wn796sUQTur5duKO0gRqqGI989L/oAqb6Xwy9ugu13E0b4JmGNiGQ +Hy3tFuOjXHiMyF5UFU2p6WgDf76txfdWopDj1Rcv8jjjaj067oXYR2ZmcJKWml71En1 7ebsSYKc2VkqQ1k4da+zKTSIteDY1JpCtJEBut8IEA0d/pMBvUDH6lhkvfo+Dai/A2G/ LdFt++g7t/h2y7oGN84x7TPKGyiH0JoncmH8ilpBqx3KmzwEIrwq85SBHKAy4W5tSfxk M0JA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7ZEJJxh2XaMBv4jBFweZR3RGB2Sg6NR3wHGmrq3luIQ=; b=53JQ1fS5u9GbD23JUnviHZevskA2Rrm8l9DRxqx5w6UvqaRbk5Xei4roJ3tHI5Cpon 0OHArvwCnSaCCUlay2GULTG9O9oZA1bf5qHSI/MjNwi/ZOyKqJn0uzdr/xvfnRjHUVFD B/PtWg7GXINMkCbSl866a1YArer9b09bDGjJDoRYzztxlDa1RBzhY1aNNBMs5EsicA3J eqlPwgV68vUWWBNf6ZPRGxZYpNB0WdcbjAIpxJBA25OD92AOfiGDFn5heZElhtifGeFK ljzQQo+mLaobTRSOzWhfRSNADMCYYca6SZWzEQ9SXQBBQVD/HbJpW8DdtMWN4mz4YY2c XDDA== X-Gm-Message-State: ANoB5pmuZjdyVffPicP7dXFB9zCrOTR/PGojcRuw11MOck8HrffzKzh7 IYauCj5SELhwL50Zoj+Rer1upg== X-Google-Smtp-Source: AA0mqf4v1agqbKlMFyKdoPqa50oxuX67XEvWKvEwylQidu89jyBAehw4fMxEXic7Rn2DIc/UmIZ2XA== X-Received: by 2002:a05:6000:783:b0:241:bc34:3149 with SMTP id bu3-20020a056000078300b00241bc343149mr32173543wrb.351.1669812165081; Wed, 30 Nov 2022 04:42:45 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:458c:6db9:e033:a468]) by smtp.gmail.com with ESMTPSA id z2-20020a5d4402000000b00226dba960b4sm1514985wrq.3.2022.11.30.04.42.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Nov 2022 04:42:44 -0800 (PST) From: Bartosz Golaszewski To: Kent Gibson , Linus Walleij , Andy Shevchenko , Viresh Kumar Cc: linux-gpio@vger.kernel.org, Bartosz Golaszewski Subject: [libgpiod][PATCH 11/11] bindings: python: extend setup.py Date: Wed, 30 Nov 2022 13:42:31 +0100 Message-Id: <20221130124231.1054001-12-brgl@bgdev.pl> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221130124231.1054001-1-brgl@bgdev.pl> References: <20221130124231.1054001-1-brgl@bgdev.pl> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Bartosz Golaszewski Add additional information to setup.py. This will be visible in the EGG file. Signed-off-by: Bartosz Golaszewski --- 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", )