]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
staging: axis-fifo: drop redundant read/write_flags from axis_fifo
authorOvidiu Panait <ovidiu.panait.oss@gmail.com>
Fri, 19 Sep 2025 19:53:59 +0000 (22:53 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 13 Oct 2025 07:09:29 +0000 (09:09 +0200)
The driver stores file flags (read_flags/write_flags) in the axis_fifo
struct, duplicating information already available in struct file.

Switch to using f->f_flags directly in read/write paths and open(),
removing the unnecessary fields.

Signed-off-by: Ovidiu Panait <ovidiu.panait.oss@gmail.com>
Link: https://lore.kernel.org/r/20250919195400.3180039-5-ovidiu.panait.oss@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/axis-fifo/axis-fifo.c

index e3dec74a02a8e91be4784f61238cf8abf9264e00..a06f7c76658a741f5d46270c00b4a00b7a2567cf 100644 (file)
@@ -128,8 +128,6 @@ struct axis_fifo {
        struct mutex read_lock; /* lock for reading */
        wait_queue_head_t write_queue; /* wait queue for asynchronos write */
        struct mutex write_lock; /* lock for writing */
-       unsigned int write_flags; /* write file flags */
-       unsigned int read_flags; /* read file flags */
 
        struct device *dt_device; /* device created from the device tree */
        struct miscdevice miscdev;
@@ -186,7 +184,7 @@ static ssize_t axis_fifo_read(struct file *f, char __user *buf,
        int ret;
        u32 tmp_buf[READ_BUF_SIZE];
 
-       if (fifo->read_flags & O_NONBLOCK) {
+       if (f->f_flags & O_NONBLOCK) {
                /*
                 * Device opened in non-blocking mode. Try to lock it and then
                 * check if any packet is available.
@@ -328,7 +326,7 @@ static ssize_t axis_fifo_write(struct file *f, const char __user *buf,
        if (words_to_write > (fifo->tx_fifo_depth - 4))
                return -EINVAL;
 
-       if (fifo->write_flags & O_NONBLOCK) {
+       if (f->f_flags & O_NONBLOCK) {
                /*
                 * Device opened in non-blocking mode. Try to lock it and then
                 * check if there is any room to write the given buffer.
@@ -425,27 +423,15 @@ static int axis_fifo_open(struct inode *inod, struct file *f)
 {
        struct axis_fifo *fifo = container_of(f->private_data,
                                              struct axis_fifo, miscdev);
+       unsigned int flags = f->f_flags & O_ACCMODE;
+
        f->private_data = fifo;
 
-       if (((f->f_flags & O_ACCMODE) == O_WRONLY) ||
-           ((f->f_flags & O_ACCMODE) == O_RDWR)) {
-               if (fifo->has_tx_fifo) {
-                       fifo->write_flags = f->f_flags;
-               } else {
-                       dev_err(fifo->dt_device, "tried to open device for write but the transmit fifo is disabled\n");
-                       return -EPERM;
-               }
-       }
+       if ((flags == O_WRONLY || flags == O_RDWR) && !fifo->has_tx_fifo)
+               return -EPERM;
 
-       if (((f->f_flags & O_ACCMODE) == O_RDONLY) ||
-           ((f->f_flags & O_ACCMODE) == O_RDWR)) {
-               if (fifo->has_rx_fifo) {
-                       fifo->read_flags = f->f_flags;
-               } else {
-                       dev_err(fifo->dt_device, "tried to open device for read but the receive fifo is disabled\n");
-                       return -EPERM;
-               }
-       }
+       if ((flags == O_RDONLY || flags == O_RDWR) && !fifo->has_rx_fifo)
+               return -EPERM;
 
        return 0;
 }