cpufreq/amd-pstate: Move registration after static function call update
[pf-kernel.git] / io_uring / nop.c
bloba5bcf3d6984f7be6e5d4d9ac0adb5f34fdfe8276
1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/kernel.h>
3 #include <linux/errno.h>
4 #include <linux/fs.h>
5 #include <linux/file.h>
6 #include <linux/io_uring.h>
8 #include <uapi/linux/io_uring.h>
10 #include "io_uring.h"
11 #include "nop.h"
13 struct io_nop {
14 /* NOTE: kiocb has the file as the first member, so don't do it here */
15 struct file *file;
16 int result;
19 int io_nop_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
21 unsigned int flags;
22 struct io_nop *nop = io_kiocb_to_cmd(req, struct io_nop);
24 flags = READ_ONCE(sqe->nop_flags);
25 if (flags & ~IORING_NOP_INJECT_RESULT)
26 return -EINVAL;
28 if (flags & IORING_NOP_INJECT_RESULT)
29 nop->result = READ_ONCE(sqe->len);
30 else
31 nop->result = 0;
32 return 0;
35 int io_nop(struct io_kiocb *req, unsigned int issue_flags)
37 struct io_nop *nop = io_kiocb_to_cmd(req, struct io_nop);
39 if (nop->result < 0)
40 req_set_fail(req);
41 io_req_set_res(req, nop->result, 0);
42 return IOU_OK;