From: Bartosz Golaszewski <brgl@bgdev.pl>
To: Kent Gibson <warthog618@gmail.com>,
Linus Walleij <linus.walleij@linaro.org>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: linux-gpio@vger.kernel.org, Bartosz Golaszewski <brgl@bgdev.pl>
Subject: [libgpiod v2][PATCH v3 1/3] API: add an enum for line values
Date: Thu, 3 Mar 2022 10:18:34 +0100 [thread overview]
Message-ID: <20220303091836.168223-2-brgl@bgdev.pl> (raw)
In-Reply-To: <20220303091836.168223-1-brgl@bgdev.pl>
In order to explicitly stress that line values as understood by libgpiod
are logical values, expose a two-value enum with values called: ACTIVE
and INACTIVE that should be used whenever referring to the state of GPIO
lines.
The value of INACTIVE is set to 0 while that of ACTIVE to 1 so that users
can still use integers in C (where no scoped enums exist).
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
---
include/gpiod.h | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/include/gpiod.h b/include/gpiod.h
index 074e395..34fdad6 100644
--- a/include/gpiod.h
+++ b/include/gpiod.h
@@ -185,12 +185,20 @@ gpiod_chip_request_lines(struct gpiod_chip *chip,
/**
* @}
*
- * @defgroup line_settings Line settings
+ * @defgroup line_settings Line definitions
* @{
*
- * These defines are used both by gpiod_line_info and gpiod_line_config.
+ * These defines are used across the API.
*/
+/**
+ * @brief Logical line state.
+ */
+enum {
+ GPIOD_LINE_VALUE_INACTIVE = 0,
+ GPIOD_LINE_VALUE_ACTIVE = 1,
+};
+
/**
* @brief Direction settings.
*/
--
2.30.1
next prev parent reply other threads:[~2022-03-03 9:18 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-03 9:18 [libgpiod v2][PATCH v3 0/3] libgpiod v2: rewrite tests for the C library Bartosz Golaszewski
2022-03-03 9:18 ` Bartosz Golaszewski [this message]
2022-03-05 5:50 ` [libgpiod v2][PATCH v3 1/3] API: add an enum for line values Kent Gibson
2022-03-03 9:18 ` [libgpiod v2][PATCH v3 2/3] line-config: expose the override logic to users Bartosz Golaszewski
2022-03-05 5:51 ` Kent Gibson
2022-03-05 20:57 ` Bartosz Golaszewski
2022-03-03 9:18 ` [libgpiod v2][PATCH v3 3/3] tests: rewrite core C tests using libgpiosim Bartosz Golaszewski
2022-03-05 5:51 ` Kent Gibson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220303091836.168223-2-brgl@bgdev.pl \
--to=brgl@bgdev.pl \
--cc=andriy.shevchenko@linux.intel.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=warthog618@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).