]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
char/nvram: Remove redundant nvram_mutex
authorVenkat Rao Bagalkote <venkat88@linux.ibm.com>
Tue, 28 Apr 2026 06:15:40 +0000 (11:45 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 23 May 2026 11:47:34 +0000 (13:47 +0200)
The global nvram_mutex in drivers/char/nvram.c is redundant and unused,
and this triggers compiler warnings on some configurations.

All platform-specific nvram operations already provide their own internal
synchronization, meaning the wrapper-level mutex does not provide any
additional safety.

Remove the nvram_mutex definition along with all remaining lock/unlock
users across PPC32, x86, and m68k code paths, and rely entirely on the
per-architecture nvram implementations for locking.

Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Suggested-by: Arnd Bergmann <arnd@arndb.de>
Tested-by: Tellakula Yeswanth Krishna <yeswanth@linux.ibm.com>
Signed-off-by: Venkat Rao Bagalkote <venkat88@linux.ibm.com>
Tested-by: yeswanth <yeswanth@linux.ibm.com>
Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Link: https://patch.msgid.link/20260428061540.73668-1-venkat88@linux.ibm.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/char/nvram.c

index 9eff426a928659c4fa63bedc2a9010a38a93498d..e89cc1f1c89eafed8e61ca052a7654579974addc 100644 (file)
@@ -53,7 +53,6 @@
 #include <asm/nvram.h>
 #endif
 
-static DEFINE_MUTEX(nvram_mutex);
 static DEFINE_SPINLOCK(nvram_state_lock);
 static int nvram_open_cnt;     /* #times opened */
 static int nvram_open_mode;    /* special open modes */
@@ -310,11 +309,8 @@ static long nvram_misc_ioctl(struct file *file, unsigned int cmd,
                break;
 #ifdef CONFIG_PPC32
        case IOC_NVRAM_SYNC:
-               if (ppc_md.nvram_sync != NULL) {
-                       mutex_lock(&nvram_mutex);
+               if (ppc_md.nvram_sync)
                        ppc_md.nvram_sync();
-                       mutex_unlock(&nvram_mutex);
-               }
                ret = 0;
                break;
 #endif
@@ -324,11 +320,8 @@ static long nvram_misc_ioctl(struct file *file, unsigned int cmd,
                if (!capable(CAP_SYS_ADMIN))
                        return -EACCES;
 
-               if (arch_nvram_ops.initialize != NULL) {
-                       mutex_lock(&nvram_mutex);
+               if (arch_nvram_ops.initialize)
                        ret = arch_nvram_ops.initialize();
-                       mutex_unlock(&nvram_mutex);
-               }
                break;
        case NVRAM_SETCKS:
                /* just set checksum, contents unchanged (maybe useful after
@@ -336,11 +329,8 @@ static long nvram_misc_ioctl(struct file *file, unsigned int cmd,
                if (!capable(CAP_SYS_ADMIN))
                        return -EACCES;
 
-               if (arch_nvram_ops.set_checksum != NULL) {
-                       mutex_lock(&nvram_mutex);
+               if (arch_nvram_ops.set_checksum)
                        ret = arch_nvram_ops.set_checksum();
-                       mutex_unlock(&nvram_mutex);
-               }
                break;
 #endif /* CONFIG_X86 || CONFIG_M68K */
        }