return (void __user *)ptrval;
}
+static struct nvme_ns *file_to_ns(struct file *file)
+{
+ return container_of(file_inode(file)->i_cdev, struct nvme_ns, cdev);
+}
+
+static struct nvme_ns_head *file_to_ns_head(struct file *file)
+{
+ return container_of(file_inode(file)->i_cdev, struct nvme_ns_head,
+ cdev);
+}
+
static void *nvme_add_user_metadata(struct bio *bio, void __user *ubuf,
unsigned len, u32 seed, bool write)
{
long nvme_ns_chr_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
- struct nvme_ns *ns =
- container_of(file_inode(file)->i_cdev, struct nvme_ns, cdev);
-
- return __nvme_ioctl(ns, cmd, (void __user *)arg);
+ return __nvme_ioctl(file_to_ns(file), cmd, (void __user *)arg);
}
static int nvme_ns_uring_cmd(struct nvme_ns *ns, struct io_uring_cmd *ioucmd,
int nvme_ns_chr_uring_cmd(struct io_uring_cmd *ioucmd, unsigned int issue_flags)
{
- struct nvme_ns *ns = container_of(file_inode(ioucmd->file)->i_cdev,
- struct nvme_ns, cdev);
-
- return nvme_ns_uring_cmd(ns, ioucmd, issue_flags);
+ return nvme_ns_uring_cmd(file_to_ns(ioucmd->file), ioucmd, issue_flags);
}
#ifdef CONFIG_NVME_MULTIPATH
long nvme_ns_head_chr_ioctl(struct file *file, unsigned int cmd,
unsigned long arg)
{
- struct cdev *cdev = file_inode(file)->i_cdev;
- struct nvme_ns_head *head =
- container_of(cdev, struct nvme_ns_head, cdev);
+ struct nvme_ns_head *head = file_to_ns_head(file);
void __user *argp = (void __user *)arg;
struct nvme_ns *ns;
int srcu_idx, ret = -EWOULDBLOCK;
int nvme_ns_head_chr_uring_cmd(struct io_uring_cmd *ioucmd,
unsigned int issue_flags)
{
- struct cdev *cdev = file_inode(ioucmd->file)->i_cdev;
- struct nvme_ns_head *head = container_of(cdev, struct nvme_ns_head, cdev);
+ struct nvme_ns_head *head = file_to_ns_head(ioucmd->file);
int srcu_idx = srcu_read_lock(&head->srcu);
struct nvme_ns *ns = nvme_find_path(head);
int ret;