linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mutex: make mutex_lock_nested an inline function
@ 2015-10-13 20:30 Arnd Bergmann
  2015-10-13 20:38 ` Peter Zijlstra
  0 siblings, 1 reply; 19+ messages in thread
From: Arnd Bergmann @ 2015-10-13 20:30 UTC (permalink / raw)
  To: linux-arm-kernel

The second argument of the mutex_lock_nested() helper is only
evaluated if CONFIG_DEBUG_LOCK_ALLOC is set. Otherwise we
get this build warning for the new regulator_lock_supply
function:

drivers/regulator/core.c: In function 'regulator_lock_supply':
drivers/regulator/core.c:142:6: warning: unused variable 'i' [-Wunused-variable]

To avoid the warning, this patch changes the definition of
mutex_lock_nested() to be static inline function rather than
a macro, which tells gcc that the variable is potentially
used.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: 9f01cd4a915 ("regulator: core: introduce function to lock regulators and its supplies")
---
Second try, this time fixing the root of the problem rather than the code
that triggered it, as suggested by Mark Brown.

I guess this means the fix should now probably go through Ingo's sched-locking
branch or through Andrew's mm patches. The warning currently only shows
up in Linux-next because of Mark's regulator branch that is destined for 4.4,
so it's not needed for 4.3 but also harmless.

diff --git a/include/linux/mutex.h b/include/linux/mutex.h
index 2cb7531e7d7a..9494dafd7a9c 100644
--- a/include/linux/mutex.h
+++ b/include/linux/mutex.h
@@ -158,7 +158,10 @@ extern void mutex_lock(struct mutex *lock);
 extern int __must_check mutex_lock_interruptible(struct mutex *lock);
 extern int __must_check mutex_lock_killable(struct mutex *lock);
 
-# define mutex_lock_nested(lock, subclass) mutex_lock(lock)
+static inline void mutex_lock_nested(struct mutex *lock, unsigned int subclass)
+{
+	return mutex_lock(lock);
+}
 # define mutex_lock_interruptible_nested(lock, subclass) mutex_lock_interruptible(lock)
 # define mutex_lock_killable_nested(lock, subclass) mutex_lock_killable(lock)
 # define mutex_lock_nest_lock(lock, nest_lock) mutex_lock(lock)

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

end of thread, other threads:[~2015-10-27 18:13 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-13 20:30 [PATCH] mutex: make mutex_lock_nested an inline function Arnd Bergmann
2015-10-13 20:38 ` Peter Zijlstra
2015-10-13 21:46   ` Arnd Bergmann
2015-10-14  8:20     ` Peter Zijlstra
2015-10-14  8:37       ` Peter Zijlstra
2015-10-14  9:00         ` Arnd Bergmann
2015-10-14  9:08           ` Peter Zijlstra
2015-10-14  9:59             ` Mark Brown
2015-10-14 10:27       ` Mark Brown
2015-10-14 11:07         ` Peter Zijlstra
2015-10-14 12:36           ` Mark Brown
2015-10-14 13:47             ` Peter Zijlstra
2015-10-14 13:50               ` Peter Zijlstra
2015-10-14 13:58                 ` Ingo Molnar
2015-10-14 14:11               ` Mark Brown
2015-10-22 15:02     ` Arnd Bergmann
2015-10-22 15:09       ` Peter Zijlstra
2015-10-22 17:44         ` Russell King - ARM Linux
2015-10-27 18:13           ` Ingo Molnar

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).