Skip to contentSkip to conversation

input_common.h: Add retry loop for event device

PATCH In review Edward Liaw via ltp 2 participants 5 messages Feb 28, 2025 – Mar 4, 2025

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 input_common.h: Add retry loop for event device

Android has a delay between the entry in /proc/bus/input/devices and the path /dev/input/eventN becoming accessible. Add a retry loop to account for this.

---
 testcases/kernel/input/input_common.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/input/input_common.h +1 -1
index 0ac1624b3..5b1755771 100644
@@ -29,7 +29,7 @@ static inline int open_event_device(void)
 			memset(path, 0, sizeof(path));
 			snprintf(path, sizeof(path), "/dev/input/%s", device);
 
-			if (!access(path, F_OK)) {
+			if (!TST_RETRY_FUNC(access(path, F_OK), TST_RETVAL_EQ0)) {
 				tst_res(TINFO, "Found event device: %s", path);
 				break;
 			}
Signature · 5 lines
2.48.1.711.g2feabab25a-goog


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v2 1/1
#1 lore raw
Quoted 4 lines · Edward Liaw via ltp

Android has a delay between the entry in /proc/bus/input/devices and the path /dev/input/eventN becoming accessible. Add a retry loop to account for this.

Did you count for how long it takes to entry? The default time TST_RETRY_FUNC
is backoff 1 second, if that time is not enough, you can consider the completed
version TST_RETRY_FN_EXP_BACKOFF for setting more seconds.

Anyway, this looks good.

Quoted 31 lines
---
 testcases/kernel/input/input_common.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/input/input_common.h +1 -1
index 0ac1624b3..5b1755771 100644
@@ -29,7 +29,7 @@ static inline int open_event_device(void)
                        memset(path, 0, sizeof(path));
                        snprintf(path, sizeof(path), "/dev/input/%s",
 device);
 
-                       if (!access(path, F_OK)) {
+                       if (!TST_RETRY_FUNC(access(path, F_OK),
 TST_RETVAL_EQ0)) {
                                tst_res(TINFO, "Found event device: %s",
path);
                                break;
                        }

--
2.48.1.711.g2feabab25a-goog

--
Mailing list info: https://lists.linux.it/listinfo/ltp

Signature · 5 lines
Regards,
Li Wang

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#2 lore raw
Quoted 10 lines · Li Wang
Quoted 4 lines · Edward Liaw via ltp

Android has a delay between the entry in /proc/bus/input/devices and the path /dev/input/eventN becoming accessible. Add a retry loop to account for this.

Quoted 9 lines

Did you count for how long it takes to entry? The default time TST_RETRY_FUNC
is backoff 1 second, if that time is not enough, you can consider the completed
version TST_RETRY_FN_EXP_BACKOFF for setting more seconds.

Anyway, this looks good.

Yeah, 1 sec should be more than enough for Android; the delay has so far been on the order of microseconds.

Quoted 39 lines
Quoted 26 lines
---
 testcases/kernel/input/input_common.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/input/input_common.h +1 -1
index 0ac1624b3..5b1755771 100644
@@ -29,7 +29,7 @@ static inline int open_event_device(void)
                        memset(path, 0, sizeof(path));
                        snprintf(path, sizeof(path), "/dev/input/%s",
 device);
 
-                       if (!access(path, F_OK)) {
+                       if (!TST_RETRY_FUNC(access(path, F_OK),
 TST_RETVAL_EQ0)) {
                                tst_res(TINFO, "Found event device: %s",
path);
                                break;
                        }
Quoted 8 lines

--
2.48.1.711.g2feabab25a-goog

--
Mailing list info: https://lists.linux.it/listinfo/ltp

--
Regards,
Li Wang

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#3 lore raw
Quoted 20 lines · Edward Liaw
Quoted 16 lines · Li Wang
Quoted 4 lines · Edward Liaw via ltp

Android has a delay between the entry in /proc/bus/input/devices and the path /dev/input/eventN becoming accessible. Add a retry loop to account for this.

Did you count for how long it takes to entry? The default time TST_RETRY_FUNC
is backoff 1 second, if that time is not enough, you can consider the completed
version TST_RETRY_FN_EXP_BACKOFF for setting more seconds.

Quoted 7 lines
Quoted 3 lines

Anyway, this looks good.

Yeah, 1 sec should be more than enough for Android; the delay has so far been on the order of microseconds.

Sorry, milliseconds* not microseconds.

Quoted 41 lines
Quoted 40 lines
Quoted 27 lines
---
 testcases/kernel/input/input_common.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/input/input_common.h +1 -1
index 0ac1624b3..5b1755771 100644
@@ -29,7 +29,7 @@ static inline int open_event_device(void)
                        memset(path, 0, sizeof(path));
                        snprintf(path, sizeof(path), "/dev/input/%s",
 device);
 
-                       if (!access(path, F_OK)) {
+                       if (!TST_RETRY_FUNC(access(path, F_OK),
 TST_RETVAL_EQ0)) {
                                tst_res(TINFO, "Found event device: %s",
path);
                                break;
                        }
Quoted 8 lines

--
2.48.1.711.g2feabab25a-goog

--
Mailing list info: https://lists.linux.it/listinfo/ltp

--
Regards,
Li Wang

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp