diff mbox series

[libgpiod] tests: rename freq parameter to period_ms

Message ID 20201014034550.19290-1-warthog618@gmail.com
State New
Headers show
Series [libgpiod] tests: rename freq parameter to period_ms | expand

Commit Message

Kent Gibson Oct. 14, 2020, 3:45 a.m. UTC
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(-)

Comments

Bartosz Golaszewski Oct. 14, 2020, 7:48 a.m. UTC | #1
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
diff mbox series

Patch

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,