Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] regulator: core: avoid unused variable warning
@ 2015-10-09 12:36 Arnd Bergmann
  2015-10-12 15:42 ` Mark Brown
  0 siblings, 1 reply; 3+ messages in thread
From: Arnd Bergmann @ 2015-10-09 12:36 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 moves the postincrement outside
of the call mutex_lock_nested(), which is enough to shut up
gcc about it.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: 9f01cd4a915 ("regulator: core: introduce function to lock regulators and its supplies")

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 96dd7e1f1f28..bac8eefbfeff 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -142,7 +142,9 @@ static void __maybe_unused regulator_lock_supply(struct regulator_dev *rdev)
 	int i = 0;
 
 	while (1) {
-		mutex_lock_nested(&rdev->mutex, i++);
+		mutex_lock_nested(&rdev->mutex, i);
+		i++;
+
 		supply = rdev->supply;
 
 		if (!rdev->supply)

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

* [PATCH] regulator: core: avoid unused variable warning
  2015-10-09 12:36 [PATCH] regulator: core: avoid unused variable warning Arnd Bergmann
@ 2015-10-12 15:42 ` Mark Brown
  2015-10-13 19:28   ` Arnd Bergmann
  0 siblings, 1 reply; 3+ messages in thread
From: Mark Brown @ 2015-10-12 15:42 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Oct 09, 2015 at 02:36:47PM +0200, Arnd Bergmann wrote:

> 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:

Shouldn't we have an annotation or something for this in
mutex_lock_nested()?  It seems like something that might come up
elsewhere and it's a bit of a surprise to have one of the arguments
there not be evaluated.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20151012/7f04d4b2/attachment.sig>

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

* [PATCH] regulator: core: avoid unused variable warning
  2015-10-12 15:42 ` Mark Brown
@ 2015-10-13 19:28   ` Arnd Bergmann
  0 siblings, 0 replies; 3+ messages in thread
From: Arnd Bergmann @ 2015-10-13 19:28 UTC (permalink / raw)
  To: linux-arm-kernel

On Monday 12 October 2015 16:42:31 Mark Brown wrote:
> On Fri, Oct 09, 2015 at 02:36:47PM +0200, Arnd Bergmann wrote:
> 
> > 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:
> 
> Shouldn't we have an annotation or something for this in
> mutex_lock_nested()?  It seems like something that might come up
> elsewhere and it's a bit of a surprise to have one of the arguments
> there not be evaluated.
> 

I've found a better solution by making mutex_lock_nested an
inline function. Will send a new patch.

	Arnd

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

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

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-09 12:36 [PATCH] regulator: core: avoid unused variable warning Arnd Bergmann
2015-10-12 15:42 ` Mark Brown
2015-10-13 19:28   ` Arnd Bergmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox