All of lore.kernel.org
 help / color / mirror / Atom feed
* [libgpiod][PATCH] tests: rename freq parameter to period_ms
@ 2020-10-14  3:45 Kent Gibson
  2020-10-14  7:48 ` Bartosz Golaszewski
  0 siblings, 1 reply; 2+ messages in thread
From: Kent Gibson @ 2020-10-14  3:45 UTC (permalink / raw)
  To: linux-gpio, bgolaszewski; +Cc: Kent Gibson

The freq field of struct gpiod_test_event_thread is actually used as a
period measured in milliseconds, so rename it to period_ms in the struct
and wherever it is used as a function parameter.

Signed-off-by: Kent Gibson <warthog618@gmail.com>
---
 bindings/cxx/tests/gpio-mockup.cpp     | 6 +++---
 bindings/cxx/tests/gpio-mockup.hpp     | 4 ++--
 bindings/python/tests/gpiod_py_test.py | 6 +++---
 tests/gpiod-test.c                     | 8 ++++----
 tests/gpiod-test.h                     | 2 +-
 5 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/bindings/cxx/tests/gpio-mockup.cpp b/bindings/cxx/tests/gpio-mockup.cpp
index 0005d3f..e8db962 100644
--- a/bindings/cxx/tests/gpio-mockup.cpp
+++ b/bindings/cxx/tests/gpio-mockup.cpp
@@ -116,10 +116,10 @@ mockup::probe_guard::~probe_guard(void)
 }
 
 mockup::event_thread::event_thread(unsigned int chip_index,
-				   unsigned int line_offset, unsigned int freq)
+				   unsigned int line_offset, unsigned int period_ms)
 	: _m_chip_index(chip_index),
 	  _m_line_offset(line_offset),
-	  _m_freq(freq),
+	  _m_period_ms(period_ms),
 	  _m_stop(false),
 	  _m_mutex(),
 	  _m_cond(),
@@ -146,7 +146,7 @@ void mockup::event_thread::event_worker(void)
 			break;
 
 		::std::cv_status status = this->_m_cond.wait_for(lock,
-						std::chrono::milliseconds(this->_m_freq));
+						std::chrono::milliseconds(this->_m_period_ms));
 		if (status == ::std::cv_status::timeout)
 			mockup::instance().chip_set_pull(this->_m_chip_index,
 							 this->_m_line_offset, i % 2);
diff --git a/bindings/cxx/tests/gpio-mockup.hpp b/bindings/cxx/tests/gpio-mockup.hpp
index 1859010..f7ef985 100644
--- a/bindings/cxx/tests/gpio-mockup.hpp
+++ b/bindings/cxx/tests/gpio-mockup.hpp
@@ -61,7 +61,7 @@ public:
 	{
 	public:
 
-		event_thread(unsigned int chip_index, unsigned int line_offset, unsigned int freq);
+		event_thread(unsigned int chip_index, unsigned int line_offset, unsigned int period_ms);
 		~event_thread(void);
 
 		event_thread(const event_thread& other) = delete;
@@ -75,7 +75,7 @@ public:
 
 		unsigned int _m_chip_index;
 		unsigned int _m_line_offset;
-		unsigned int _m_freq;
+		unsigned int _m_period_ms;
 
 		bool _m_stop;
 
diff --git a/bindings/python/tests/gpiod_py_test.py b/bindings/python/tests/gpiod_py_test.py
index 572aad8..e835ef3 100755
--- a/bindings/python/tests/gpiod_py_test.py
+++ b/bindings/python/tests/gpiod_py_test.py
@@ -34,11 +34,11 @@ class MockupTestCase(unittest.TestCase):
 
 class EventThread(threading.Thread):
 
-    def __init__(self, chip_idx, line_offset, freq):
+    def __init__(self, chip_idx, line_offset, period_ms):
         threading.Thread.__init__(self)
         self.chip_idx = chip_idx
         self.line_offset = line_offset
-        self.freq = freq
+        self.period_ms = period_ms
         self.lock = threading.Lock()
         self.cond = threading.Condition(self.lock)
         self.should_stop = False
@@ -50,7 +50,7 @@ class EventThread(threading.Thread):
                 if self.should_stop:
                     break;
 
-                if not self.cond.wait(float(self.freq) / 1000):
+                if not self.cond.wait(float(self.period_ms) / 1000):
                     mockup.chip_set_pull(self.chip_idx,
                                          self.line_offset, i % 2)
                     i += 1
diff --git a/tests/gpiod-test.c b/tests/gpiod-test.c
index 72b228f..0411623 100644
--- a/tests/gpiod-test.c
+++ b/tests/gpiod-test.c
@@ -29,7 +29,7 @@ struct gpiod_test_event_thread {
 	gboolean should_stop;
 	guint chip_index;
 	guint line_offset;
-	guint freq;
+	guint period_ms;
 };
 
 static struct {
@@ -202,7 +202,7 @@ static gpointer event_worker_func(gpointer data)
 			break;
 		}
 
-		end_time = g_get_monotonic_time() + thread->freq * 1000;
+		end_time = g_get_monotonic_time() + thread->period_ms * 1000;
 
 		signalled = g_cond_wait_until(&thread->cond,
 					      &thread->lock, end_time);
@@ -217,7 +217,7 @@ static gpointer event_worker_func(gpointer data)
 }
 
 GpiodTestEventThread *
-gpiod_test_start_event_thread(guint chip_index, guint line_offset, guint freq)
+gpiod_test_start_event_thread(guint chip_index, guint line_offset, guint period_ms)
 {
 	GpiodTestEventThread *thread = g_malloc0(sizeof(*thread));
 
@@ -226,7 +226,7 @@ gpiod_test_start_event_thread(guint chip_index, guint line_offset, guint freq)
 
 	thread->chip_index = chip_index;
 	thread->line_offset = line_offset;
-	thread->freq = freq;
+	thread->period_ms = period_ms;
 
 	thread->id = g_thread_new("event-worker", event_worker_func, thread);
 
diff --git a/tests/gpiod-test.h b/tests/gpiod-test.h
index d4a8c5f..8308547 100644
--- a/tests/gpiod-test.h
+++ b/tests/gpiod-test.h
@@ -96,7 +96,7 @@ typedef struct gpiod_test_event_thread GpiodTestEventThread;
 
 GpiodTestEventThread *
 gpiod_test_start_event_thread(guint chip_index,
-			      guint line_offset, guint freq);
+			      guint line_offset, guint period_ms);
 void gpiod_test_stop_event_thread(GpiodTestEventThread *thread);
 
 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GpiodTestEventThread,
-- 
2.28.0


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

* Re: [libgpiod][PATCH] tests: rename freq parameter to period_ms
  2020-10-14  3:45 [libgpiod][PATCH] tests: rename freq parameter to period_ms Kent Gibson
@ 2020-10-14  7:48 ` Bartosz Golaszewski
  0 siblings, 0 replies; 2+ messages in thread
From: Bartosz Golaszewski @ 2020-10-14  7:48 UTC (permalink / raw)
  To: Kent Gibson; +Cc: linux-gpio

On Wed, Oct 14, 2020 at 5:46 AM Kent Gibson <warthog618@gmail.com> wrote:
>
> The freq field of struct gpiod_test_event_thread is actually used as a
> period measured in milliseconds, so rename it to period_ms in the struct
> and wherever it is used as a function parameter.
>
> Signed-off-by: Kent Gibson <warthog618@gmail.com>
> ---

Applied, thanks!

Bartosz

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

end of thread, other threads:[~2020-10-14  9:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-14  3:45 [libgpiod][PATCH] tests: rename freq parameter to period_ms Kent Gibson
2020-10-14  7:48 ` Bartosz Golaszewski

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