Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1243311 > unrolled thread

[PATCH] regulator: core: avoid unused variable warning

Started byArnd Bergmann <arnd@arndb.de>
First post2015-10-09 14:40 +0200
Last post2015-10-13 21:30 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] regulator: core: avoid unused variable warning Arnd Bergmann <arnd@arndb.de> - 2015-10-09 14:40 +0200
    Re: [PATCH] regulator: core: avoid unused variable warning Mark Brown <broonie@kernel.org> - 2015-10-12 17:50 +0200
      Re: [PATCH] regulator: core: avoid unused variable warning Arnd Bergmann <arnd@arndb.de> - 2015-10-13 21:30 +0200

#1243311 — [PATCH] regulator: core: avoid unused variable warning

FromArnd Bergmann <arnd@arndb.de>
Date2015-10-09 14:40 +0200
Subject[PATCH] regulator: core: avoid unused variable warning
Message-ID<qhF7P-2d6-1@gated-at.bofh.it>
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)

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1244842

FromMark Brown <broonie@kernel.org>
Date2015-10-12 17:50 +0200
Message-ID<qiNwm-3ks-19@gated-at.bofh.it>
In reply to#1243311

[Multipart message — attachments visible in raw view] — view raw

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.

[toc] | [prev] | [next] | [standalone]


#1246065

FromArnd Bergmann <arnd@arndb.de>
Date2015-10-13 21:30 +0200
Message-ID<qjdqN-7D7-3@gated-at.bofh.it>
In reply to#1244842
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web