summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOvidiu Panait <ovidiu.panait.oss@gmail.com>2025-09-19 22:53:59 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-10-13 09:09:29 +0200
commit89443a92c506dcd91209ddd6d37e0d3beb5a4279 (patch)
tree70152639d09d8200e897f9023f1650c452db281b
parent4497288513350d19e75232d0a8161f0094ade026 (diff)
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 <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>
-rw-r--r--drivers/staging/axis-fifo/axis-fifo.c30
1 files changed, 8 insertions, 22 deletions
diff --git a/drivers/staging/axis-fifo/axis-fifo.c b/drivers/staging/axis-fifo/axis-fifo.c
index e3dec74a02a8..a06f7c76658a 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;
}