}
 }
 
-static unsigned io_cqring_events(struct io_rings *rings)
+static unsigned io_cqring_events(struct io_ring_ctx *ctx)
 {
+       struct io_rings *rings = ctx->rings;
+
        /* See comment at the top of this file */
        smp_rmb();
        return READ_ONCE(rings->cq.tail) - READ_ONCE(rings->cq.head);
                 * If we do, we can potentially be spinning for commands that
                 * already triggered a CQE (eg in error).
                 */
-               if (io_cqring_events(ctx->rings))
+               if (io_cqring_events(ctx))
                        break;
 
                /*
         * started waiting. For timeouts, we always want to return to userspace,
         * regardless of event count.
         */
-       return io_cqring_events(ctx->rings) >= iowq->to_wait ||
+       return io_cqring_events(ctx) >= iowq->to_wait ||
                        atomic_read(&ctx->cq_timeouts) != iowq->nr_timeouts;
 }
 
        struct io_rings *rings = ctx->rings;
        int ret = 0;
 
-       if (io_cqring_events(rings) >= min_events)
+       if (io_cqring_events(ctx) >= min_events)
                return 0;
 
        if (sig) {