LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] kfifo: Rename read_lock/write_lock
@ 2021-08-06 15:25 Sebastian Andrzej Siewior
  0 siblings, 0 replies; 2+ messages in thread
From: Sebastian Andrzej Siewior @ 2021-08-06 15:25 UTC (permalink / raw)
  To: linux-kernel; +Cc: Stefani Seibold, Thomas Gleixner

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 <bigeasy@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 samples/kfifo/bytestream-example.c | 12 ++++++------
 samples/kfifo/inttype-example.c    | 12 ++++++------
 samples/kfifo/record-example.c     | 12 ++++++------
 3 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/samples/kfifo/bytestream-example.c b/samples/kfifo/bytestream-example.c
index 5a90aa5278775..642d0748c1695 100644
--- a/samples/kfifo/bytestream-example.c
+++ b/samples/kfifo/bytestream-example.c
@@ -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.
@@ -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;
 
@@ -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;
 
diff --git a/samples/kfifo/inttype-example.c b/samples/kfifo/inttype-example.c
index e5403d8c971a5..c61482ba94f4d 100644
--- a/samples/kfifo/inttype-example.c
+++ b/samples/kfifo/inttype-example.c
@@ -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.
@@ -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;
 
@@ -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;
 
diff --git a/samples/kfifo/record-example.c b/samples/kfifo/record-example.c
index f64f3d62d6c2a..e4087b2d3fc4b 100644
--- a/samples/kfifo/record-example.c
+++ b/samples/kfifo/record-example.c
@@ -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.
@@ -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;
 
@@ -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;
 
-- 
2.32.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH] kfifo: Rename read_lock/write_lock
@ 2021-10-05 13:45 Sebastian Andrzej Siewior
  0 siblings, 0 replies; 2+ messages in thread
From: Sebastian Andrzej Siewior @ 2021-10-05 13:45 UTC (permalink / raw)
  To: linux-kernel; +Cc: Stefani Seibold, Thomas Gleixner

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 <bigeasy@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked by Stefani Seibold <stefani@seibold.net>
---
 samples/kfifo/bytestream-example.c | 12 ++++++------
 samples/kfifo/inttype-example.c    | 12 ++++++------
 samples/kfifo/record-example.c     | 12 ++++++------
 3 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/samples/kfifo/bytestream-example.c
b/samples/kfifo/bytestream-example.c
index 5a90aa5278775..642d0748c1695 100644
--- a/samples/kfifo/bytestream-example.c
+++ b/samples/kfifo/bytestream-example.c
@@ -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.
@@ -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;
 
@@ -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;
 
diff --git a/samples/kfifo/inttype-example.c b/samples/kfifo/inttype-
example.c
index e5403d8c971a5..c61482ba94f4d 100644
--- a/samples/kfifo/inttype-example.c
+++ b/samples/kfifo/inttype-example.c
@@ -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.
@@ -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;
 
@@ -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;
 
diff --git a/samples/kfifo/record-example.c b/samples/kfifo/record-
example.c
index f64f3d62d6c2a..e4087b2d3fc4b 100644
--- a/samples/kfifo/record-example.c
+++ b/samples/kfifo/record-example.c
@@ -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.
@@ -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;
 
@@ -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;
 



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-10-05 14:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-06 15:25 [PATCH] kfifo: Rename read_lock/write_lock Sebastian Andrzej Siewior
2021-10-05 13:45 Sebastian Andrzej Siewior

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).