Skip to content

Commit

Permalink
samples/kfifo: Rename read_lock/write_lock
Browse files Browse the repository at this point in the history
The variables names read_lock and write_lock can clash with functions used for
read/writer locks.

Rename read_lock to read_access and write_lock to write_access to avoid a name
collision.

Signed-off-by: Sebastian Andrzej Siewior <[email protected]>
Link: https://lkml.kernel.org/r/[email protected]
Link: https://lore.kernel.org/r/[email protected]
Acked-by: Stefani Seibold <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
Sebastian Andrzej Siewior authored and gregkh committed Oct 13, 2021
1 parent 85385a5 commit 880732a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
12 changes: 6 additions & 6 deletions samples/kfifo/bytestream-example.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
#define PROC_FIFO "bytestream-fifo"

/* lock for procfs read access */
static DEFINE_MUTEX(read_lock);
static DEFINE_MUTEX(read_access);

/* lock for procfs write access */
static DEFINE_MUTEX(write_lock);
static DEFINE_MUTEX(write_access);

/*
* define DYNAMIC in this example for a dynamically allocated fifo.
Expand Down Expand Up @@ -116,12 +116,12 @@ static ssize_t fifo_write(struct file *file, const char __user *buf,
int ret;
unsigned int copied;

if (mutex_lock_interruptible(&write_lock))
if (mutex_lock_interruptible(&write_access))
return -ERESTARTSYS;

ret = kfifo_from_user(&test, buf, count, &copied);

mutex_unlock(&write_lock);
mutex_unlock(&write_access);
if (ret)
return ret;

Expand All @@ -134,12 +134,12 @@ static ssize_t fifo_read(struct file *file, char __user *buf,
int ret;
unsigned int copied;

if (mutex_lock_interruptible(&read_lock))
if (mutex_lock_interruptible(&read_access))
return -ERESTARTSYS;

ret = kfifo_to_user(&test, buf, count, &copied);

mutex_unlock(&read_lock);
mutex_unlock(&read_access);
if (ret)
return ret;

Expand Down
12 changes: 6 additions & 6 deletions samples/kfifo/inttype-example.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
#define PROC_FIFO "int-fifo"

/* lock for procfs read access */
static DEFINE_MUTEX(read_lock);
static DEFINE_MUTEX(read_access);

/* lock for procfs write access */
static DEFINE_MUTEX(write_lock);
static DEFINE_MUTEX(write_access);

/*
* define DYNAMIC in this example for a dynamically allocated fifo.
Expand Down Expand Up @@ -109,12 +109,12 @@ static ssize_t fifo_write(struct file *file, const char __user *buf,
int ret;
unsigned int copied;

if (mutex_lock_interruptible(&write_lock))
if (mutex_lock_interruptible(&write_access))
return -ERESTARTSYS;

ret = kfifo_from_user(&test, buf, count, &copied);

mutex_unlock(&write_lock);
mutex_unlock(&write_access);
if (ret)
return ret;

Expand All @@ -127,12 +127,12 @@ static ssize_t fifo_read(struct file *file, char __user *buf,
int ret;
unsigned int copied;

if (mutex_lock_interruptible(&read_lock))
if (mutex_lock_interruptible(&read_access))
return -ERESTARTSYS;

ret = kfifo_to_user(&test, buf, count, &copied);

mutex_unlock(&read_lock);
mutex_unlock(&read_access);
if (ret)
return ret;

Expand Down
12 changes: 6 additions & 6 deletions samples/kfifo/record-example.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
#define PROC_FIFO "record-fifo"

/* lock for procfs read access */
static DEFINE_MUTEX(read_lock);
static DEFINE_MUTEX(read_access);

/* lock for procfs write access */
static DEFINE_MUTEX(write_lock);
static DEFINE_MUTEX(write_access);

/*
* define DYNAMIC in this example for a dynamically allocated fifo.
Expand Down Expand Up @@ -123,12 +123,12 @@ static ssize_t fifo_write(struct file *file, const char __user *buf,
int ret;
unsigned int copied;

if (mutex_lock_interruptible(&write_lock))
if (mutex_lock_interruptible(&write_access))
return -ERESTARTSYS;

ret = kfifo_from_user(&test, buf, count, &copied);

mutex_unlock(&write_lock);
mutex_unlock(&write_access);
if (ret)
return ret;

Expand All @@ -141,12 +141,12 @@ static ssize_t fifo_read(struct file *file, char __user *buf,
int ret;
unsigned int copied;

if (mutex_lock_interruptible(&read_lock))
if (mutex_lock_interruptible(&read_access))
return -ERESTARTSYS;

ret = kfifo_to_user(&test, buf, count, &copied);

mutex_unlock(&read_lock);
mutex_unlock(&read_access);
if (ret)
return ret;

Expand Down

0 comments on commit 880732a

Please sign in to comment.