Skip to contentSkip to conversation

tracing: Switch trace_recursion_record.c code over to use guard()

PATCH In review Yash Suthar 2 participants 3 messages May 2 – May 13 Tracing

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tracing: Switch trace_recursion_record.c code over to use guard()

Switch mutex_lock()/mutex_unlock() to guard(). also drop the ret local variable and return directly.

---
 kernel/trace/trace_recursion_record.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
kernel/trace/trace_recursion_record.c +3 -5
index 784fe1fbb866..bac4bc844ccd 100644
@@ -180,9 +180,8 @@ static const struct seq_operations recursed_function_seq_ops = {
 
 static int recursed_function_open(struct inode *inode, struct file *file)
 {
-	int ret = 0;
+	guard(mutex)(&recursed_function_lock);
 
-	mutex_lock(&recursed_function_lock);
 	/* If this file was opened for write, then erase contents */
 	if ((file->f_mode & FMODE_WRITE) && (file->f_flags & O_TRUNC)) {
 		/* disable updating records */
@@ -194,10 +193,9 @@ static int recursed_function_open(struct inode *inode, struct file *file)
 		atomic_set(&nr_records, 0);
 	}
 	if (file->f_mode & FMODE_READ)
-		ret = seq_open(file, &recursed_function_seq_ops);
-	mutex_unlock(&recursed_function_lock);
+		return seq_open(file, &recursed_function_seq_ops);
 
-	return ret;
+	return 0;
 }
 
 static ssize_t recursed_function_write(struct file *file,
Signature · 1 line
2.43.0
#1 lore raw

Gentle ping.

Sincerely,
Yash Suthar

Quoted 40 lines · Yash Suthar

Switch mutex_lock()/mutex_unlock() to guard(). also drop the ret local variable and return directly.

---
 kernel/trace/trace_recursion_record.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
kernel/trace/trace_recursion_record.c +3 -6
index 784fe1fbb866..bac4bc844ccd 100644
@@ -180,9 +180,8 @@ static const struct seq_operations recursed_function_seq_ops = {
 
 static int recursed_function_open(struct inode *inode, struct file *file)
 {
-       int ret = 0;
+       guard(mutex)(&recursed_function_lock);
 
-       mutex_lock(&recursed_function_lock);
        /* If this file was opened for write, then erase contents */
        if ((file->f_mode & FMODE_WRITE) && (file->f_flags & O_TRUNC)) {
                /* disable updating records */
@@ -194,10 +193,9 @@ static int recursed_function_open(struct inode *inode, struct file *file)
                atomic_set(&nr_records, 0);
        }
        if (file->f_mode & FMODE_READ)
-               ret = seq_open(file, &recursed_function_seq_ops);
-       mutex_unlock(&recursed_function_lock);
+               return seq_open(file, &recursed_function_seq_ops);
 
-       return ret;
+       return 0;
 }
 
 static ssize_t recursed_function_write(struct file *file,
--

2.43.0