From: Ovidiu Panait Date: Fri, 19 Sep 2025 19:53:59 +0000 (+0300) Subject: staging: axis-fifo: drop redundant read/write_flags from axis_fifo X-Git-Tag: v6.19-rc1~62^2~35 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=89443a92c506dcd91209ddd6d37e0d3beb5a4279;p=thirdparty%2Flinux.git staging: axis-fifo: drop redundant read/write_flags from axis_fifo 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 Link: https://lore.kernel.org/r/20250919195400.3180039-5-ovidiu.panait.oss@gmail.com Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/axis-fifo/axis-fifo.c b/drivers/staging/axis-fifo/axis-fifo.c index e3dec74a02a8e..a06f7c76658a7 100644 --- a/drivers/staging/axis-fifo/axis-fifo.c +++ b/drivers/staging/axis-fifo/axis-fifo.c @@ -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; }