From f195233410eadcfae581302d30ccfbb18f18a72d Mon Sep 17 00:00:00 2001 From: Adrian Szyndela Date: Mon, 28 Jun 2021 09:55:22 +0200 Subject: [PATCH] name magic numbers in poll() calls It probably does not help much as it does not explain intentions. They stay with the original authors of this code. However, I believe it is a small step in the right direction. Change-Id: I236a9b2b3dabb712ad7b1d0b6a8b1b33dd1e0230 --- src/common.c | 4 +++- src/peripheral_gpio.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/common.c b/src/common.c index d1a36b1..bf9a370 100644 --- a/src/common.c +++ b/src/common.c @@ -6,6 +6,8 @@ #include #include +#define UDEV_MONITOR_POLL_TIMEOUT_MILISECONDS 100 + int peripheral_lock(const char *file_name) { int fd = open(file_name, O_WRONLY | O_CLOEXEC); @@ -97,7 +99,7 @@ int peripheral_wait_for_udev(struct udev_monitor *monitor, UdevCompareFunc func, for (int cnt = 0; cnt < 10; cnt++) { _D("poll iteration"); - if (poll(&pfd, 1, 100) < 0) { + if (poll(&pfd, 1, UDEV_MONITOR_POLL_TIMEOUT_MILISECONDS) < 0) { _E("Failed to watch udev monitor"); return -EIO; } diff --git a/src/peripheral_gpio.c b/src/peripheral_gpio.c index cb99fba..6e8928b 100644 --- a/src/peripheral_gpio.c +++ b/src/peripheral_gpio.c @@ -47,6 +47,8 @@ FEATURE("http://tizen.org/feature/peripheral_io.gpio") #define GPIO_INTERRUPTED_CALLBACK_UNSET 0 #define GPIO_INTERRUPTED_CALLBACK_SET 1 +#define GPIO_INTERRUPTED_CALLBACK_CHECK_SET_INTERVAL_MILISECONDS 3000 + #define GPIO_BUFFER_MAX 64 typedef struct _peripheral_gpio_interrupted_cb_info_s { @@ -419,7 +421,7 @@ static gpointer __peripheral_gpio_poll(void *data) while (g_atomic_int_get(&gpio->cb_info.status) == GPIO_INTERRUPTED_CALLBACK_SET) { - poll_state = poll(&poll_fd, 1, 3000); + poll_state = poll(&poll_fd, 1, GPIO_INTERRUPTED_CALLBACK_CHECK_SET_INTERVAL_MILISECONDS); if (poll_state == 0) continue; -- 2.34.1