Skip to contentSkip to conversation

char: nvram: Remove unused nvram_mutex to fix -Wunused-variable warning

PATCH Superseded Venkat Rao Bagalkote 3 participants 4 messages Mar 23

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 char: nvram: Remove unused nvram_mutex to fix -Wunused-variable warning

drivers/char/nvram.c defines a static mutex 'nvram_mutex' which is never used. This results in a compiler warning on linux-next builds:

warning: 'nvram_mutex' defined but not used [-Wunused-variable]

Remove the unused definition to avoid the warning.

---
 drivers/char/nvram.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/nvram.c +1 -1
index 9eff426a9286..2ce3307663ed 100644
@@ -53,7 +53,7 @@
 #include <asm/nvram.h>
 #endif
 
-static DEFINE_MUTEX(nvram_mutex);
+static __maybe_unused 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 */
Signature · 1 line
2.45.2
#1 lore raw

Please ignore this. Sent v2 [1]

[1]: https://lore.kernel.org/all/[email protected]/

Regards,

Venkat.

Quoted 25 lines · Venkat Rao Bagalkote

drivers/char/nvram.c defines a static mutex 'nvram_mutex' which is never used. This results in a compiler warning on linux-next builds:

warning: 'nvram_mutex' defined but not used [-Wunused-variable]

Remove the unused definition to avoid the warning.

---
  drivers/char/nvram.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/nvram.c +1 -1
index 9eff426a9286..2ce3307663ed 100644
@@ -53,7 +53,7 @@
  #include <asm/nvram.h>
  #endif
 
-static DEFINE_MUTEX(nvram_mutex);
+static __maybe_unused 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 */
maintainer
#2 lore raw
In reply to Venkat Rao Bagalkote
Quoted 17 lines · Venkat Rao Bagalkote

drivers/char/nvram.c defines a static mutex 'nvram_mutex' which is never used. This results in a compiler warning on linux-next builds:

warning: 'nvram_mutex' defined but not used [-Wunused-variable]

Remove the unused definition to avoid the warning.

---
 drivers/char/nvram.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/nvram.c +0 -0
index 9eff426a9286..2ce3307663ed 100644

drivers/char/nvram.c line 56

Quoted 5 lines
drivers/char/nvram.c +1 -1
@@ -53,7 +53,7 @@
 #include <asm/nvram.h>
 #endif
 
-static DEFINE_MUTEX(nvram_mutex);
+static __maybe_unused DEFINE_MUTEX(nvram_mutex);

If it is never used, why not actually delete it? This just papers over the real issue :(

thanks,

greg k-h

maintainer
#3 lore raw
Quoted 21 lines · Greg KH
Quoted 20 lines · Venkat Rao Bagalkote

drivers/char/nvram.c defines a static mutex 'nvram_mutex' which is never used. This results in a compiler warning on linux-next builds:

warning: 'nvram_mutex' defined but not used [-Wunused-variable]

Remove the unused definition to avoid the warning.

---
 drivers/char/nvram.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/nvram.c +0 -0
index 9eff426a9286..2ce3307663ed 100644
@@ -53,7 +53,7 @@
 #include <asm/nvram.h>
 #endif
 
Quoted 5 lines

drivers/char/nvram.c line 56

Quoted 2 lines
drivers/char/nvram.c +1 -1
-static DEFINE_MUTEX(nvram_mutex);
+static __maybe_unused DEFINE_MUTEX(nvram_mutex);

If it is never used, why not actually delete it? This just papers over the real issue :(

It's used on ppc32, atari and x86, but not ppc64.

However, I see that all the implementations that have the mutex in their code path also have an inner spinlock that does the same thing, while the mutex is a renmant from my 613655fa39ff ("drivers: autoconvert trivial BKL users to private mutex").

I'm fairly sure we can actually remove it.

Arnd