ringtest: commonize implementation of poll_avail/poll_used
[cascardo/linux.git] / tools / virtio / ringtest / ptr_ring.c
index bd2ad1d..635b07b 100644 (file)
@@ -133,18 +133,9 @@ void *get_buf(unsigned *lenp, void **bufp)
        return datap;
 }
 
-void poll_used(void)
+bool used_empty()
 {
-       void *b;
-
-       do {
-               if (tailcnt == headcnt || __ptr_ring_full(&array)) {
-                       b = NULL;
-                       barrier();
-               } else {
-                       b = "Buffer\n";
-               }
-       } while (!b);
+       return (tailcnt == headcnt || __ptr_ring_full(&array));
 }
 
 void disable_call()
@@ -173,14 +164,9 @@ bool enable_kick()
        assert(0);
 }
 
-void poll_avail(void)
+bool avail_empty()
 {
-       void *b;
-
-       do {
-               barrier();
-               b = __ptr_ring_peek(&array);
-       } while (!b);
+       return !__ptr_ring_peek(&array);
 }
 
 bool use_buf(unsigned *lenp, void **bufp)