linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
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>,
	Viresh Kumar <viresh.kumar@linaro.org>
Cc: linux-gpio@vger.kernel.org,
	Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Subject: [libgpiod][PATCH 05/11] gpiosim: rename HOG_DIR to DIRECTION
Date: Wed, 30 Nov 2022 13:42:25 +0100	[thread overview]
Message-ID: <20221130124231.1054001-6-brgl@bgdev.pl> (raw)
In-Reply-To: <20221130124231.1054001-1-brgl@bgdev.pl>

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

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

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

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


  parent reply	other threads:[~2022-11-30 12:42 UTC|newest]

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

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=20221130124231.1054001-6-brgl@bgdev.pl \
    --to=brgl@bgdev.pl \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=bartosz.golaszewski@linaro.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=viresh.kumar@linaro.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).