io_uring/kbuf: move io_ring_head_to_buf() to kbuf.h
authorJens Axboe <axboe@kernel.dk>
Mon, 12 Aug 2024 15:25:36 +0000 (09:25 -0600)
committerJens Axboe <axboe@kernel.dk>
Thu, 29 Aug 2024 14:44:42 +0000 (08:44 -0600)
In preparation for using this helper in kbuf.h as well, move it there and
turn it into a macro.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/kbuf.c
io_uring/kbuf.h

index c69f698078854b0e9c3314d587baeac8ea83b652..297c1d2c3c2778acfe089feceb77ae01e0400c52 100644 (file)
@@ -132,12 +132,6 @@ static int io_provided_buffers_select(struct io_kiocb *req, size_t *len,
        return 0;
 }
 
-static struct io_uring_buf *io_ring_head_to_buf(struct io_uring_buf_ring *br,
-                                               __u16 head, __u16 mask)
-{
-       return &br->bufs[head & mask];
-}
-
 static void __user *io_ring_buffer_select(struct io_kiocb *req, size_t *len,
                                          struct io_buffer_list *bl,
                                          unsigned int issue_flags)
index 43c7b18244b3cab1531d98437eafd722838a1cab..4c34ff3144b9fd2623110f88ff9e8adaa6e600c9 100644 (file)
@@ -121,6 +121,9 @@ static inline bool io_kbuf_recycle(struct io_kiocb *req, unsigned issue_flags)
        return false;
 }
 
+/* Mapped buffer ring, return io_uring_buf from head */
+#define io_ring_head_to_buf(br, head, mask)    &(br)->bufs[(head) & (mask)]
+
 static inline void io_kbuf_commit(struct io_kiocb *req,
                                  struct io_buffer_list *bl, int nr)
 {