diff mbox series

vfio: Use anon_inode_getfile_fmode() in vfio_device_open_file()

Message ID 20240424234147.7840-1-linux@osuchow.ski (mailing list archive)
State New, archived
Headers show
Series vfio: Use anon_inode_getfile_fmode() in vfio_device_open_file() | expand

Commit Message

Dawid Osuchowski April 24, 2024, 11:41 p.m. UTC
Remove TODO by using the anon_inode_getfile_fmode() instead of setting
the fmode directly in vfio_device_open_file().

Signed-off-by: Dawid Osuchowski <linux@osuchow.ski>
---
Depends on [1]

[1] https://lore.kernel.org/linux-fsdevel/20240424233859.7640-1-linux@osuchow.ski/T/#u
---
 drivers/vfio/group.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

Comments

Tian, Kevin April 28, 2024, 7:13 a.m. UTC | #1
> From: Dawid Osuchowski <linux@osuchow.ski>
> Sent: Thursday, April 25, 2024 7:42 AM
> 
> Remove TODO by using the anon_inode_getfile_fmode() instead of setting
> the fmode directly in vfio_device_open_file().
> 
> Signed-off-by: Dawid Osuchowski <linux@osuchow.ski>
> ---
> Depends on [1]
> 
> [1] https://lore.kernel.org/linux-fsdevel/20240424233859.7640-1-
> linux@osuchow.ski/T/#u

Reviewed-by: Kevin Tian <kevin.tian@intel.com>
diff mbox series

Patch

diff --git a/drivers/vfio/group.c b/drivers/vfio/group.c
index 610a429c6191..c9e7af2a1056 100644
--- a/drivers/vfio/group.c
+++ b/drivers/vfio/group.c
@@ -270,22 +270,15 @@  static struct file *vfio_device_open_file(struct vfio_device *device)
 
 	/*
 	 * We can't use anon_inode_getfd() because we need to modify
-	 * the f_mode flags directly to allow more than just ioctls
+	 * the f_mode flags to allow more than just ioctls
 	 */
-	filep = anon_inode_getfile("[vfio-device]", &vfio_device_fops,
-				   df, O_RDWR);
+	filep = anon_inode_getfile_fmode("[vfio-device]", &vfio_device_fops,
+				   df, O_RDWR, FMODE_PREAD | FMODE_PWRITE);
 	if (IS_ERR(filep)) {
 		ret = PTR_ERR(filep);
 		goto err_close_device;
 	}
 
-	/*
-	 * TODO: add an anon_inode interface to do this.
-	 * Appears to be missing by lack of need rather than
-	 * explicitly prevented.  Now there's need.
-	 */
-	filep->f_mode |= (FMODE_PREAD | FMODE_PWRITE);
-
 	if (device->group->type == VFIO_NO_IOMMU)
 		dev_warn(device->dev, "vfio-noiommu device opened by user "
 			 "(%s:%d)\n", current->comm, task_pid_nr(current));