From patchwork Fri Nov 20 11:30:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 105225 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp419779lbb; Fri, 20 Nov 2015 03:31:31 -0800 (PST) X-Received: by 10.66.121.110 with SMTP id lj14mr18433853pab.61.1448019091823; Fri, 20 Nov 2015 03:31:31 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id im8si19122074pbc.99.2015.11.20.03.31.31; Fri, 20 Nov 2015 03:31:31 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161937AbbKTLb3 (ORCPT + 28 others); Fri, 20 Nov 2015 06:31:29 -0500 Received: from mout.kundenserver.de ([212.227.126.131]:64896 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751211AbbKTLb2 (ORCPT ); Fri, 20 Nov 2015 06:31:28 -0500 Received: from wuerfel.localnet ([134.3.118.24]) by mrelayeu.kundenserver.de (mreue003) with ESMTPSA (Nemesis) id 0MZysF-1Ze5kK3aed-00LjTF; Fri, 20 Nov 2015 12:30:27 +0100 From: Arnd Bergmann To: Mark Brown , Sascha Hauer , Liam Girdwood , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Peter Zijlstra , Ingo Molnar Subject: [PATCH, once again] regulator: core: avoid unused variable warning Date: Fri, 20 Nov 2015 12:30:24 +0100 Message-ID: <4219157.sstthfjICN@wuerfel> User-Agent: KMail/4.11.5 (Linux/3.16.0-10-generic; KDE/4.11.5; x86_64; ; ) MIME-Version: 1.0 X-Provags-ID: V03:K0:nMICO14vwwG83HoXOxGOHSk+FE7CaDxPoXozEiAN6lJx4atFe3U GXJEw6xmhxSaD+V5QvHX2lpbcY0trN2DZNZJBeVjHLF4+vG9gRfta9cukyiOWFXtScc2ohh h//tgBuEaWGC41qKVWuyih77yWHmQ3S80S0l6NSCzc63qqREGB9vjVeYKaqTrHOWaSjg6rU 5aKZ6aNRBSmGTm5bRuJtA== X-UI-Out-Filterresults: notjunk:1; V01:K0:mbi1WwygfrQ=:tjyVjCkWhzBSDQ/QNILp0j +J9fm7jeYSBrRLUfY/CidO8TQZRhkAAKyWmLbtLPCTclWJRxueR20k1BDANcOjaLD1POIV88w u8OxuLZCeS4E/kAvhaJd35ebmfwqfbHxvqyLD4JcVBD6OdqWYKNfwpRJjXN9P8+jf+lEYLk3j VL6Rvf73it/l9T7US4qxVpWVUPokv3yZmHPUiz0zA2PAV+FHhGqacx43YmlW8k+XYSuAbmI4O 1fwocWbpvhvkBAUb/aRk1I9iqg6BhKKXzQ1UR7mT6bkz8KH1igSixqi2S43MvfEJs1dUVyoj4 zJkTbrSl2Eey7akUW13R0f1/1SgqUt/nDKvybwxU861v3xopMJhX3GpJWdL+ummxMfjEowzT4 PUt3ecXqmu9zoBUX7MlAs4LYGQ8bS6CtLx4byRKlJiXyemdwaLSdKEKH1tcvlNZWAvfeKNkzK 1ElfSEG065RP/w+ec9fiWqXvv3ip9GxnuSwCJXJJ8THYs1YcF9tlAIZ9J31EFqvWHOEem9w20 r2xAXm2vxEZZ4bPbyVBDC0osluooAzRheUe9tJxh7dwP647RO10HR39krxXtUbCCVJuRHFa7N 6I+FfTL3RHeyG73Rt1qkqkM+YVAVMrDW+UGBDXqyv/+AQJ9i3y9+RRMhinyuOoIQxy7EGfn8Z gDIDYF06XZE9CMDa9q9T9iy903XvRuZAvewZxinaYVIaNeJdnvtCqm/lhTOpuVC7sxV5AK0u5 prlfSH/n3GOELyiQ Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. We had some discussion about changing mutex_lock_nested to an inline function, which would make the code do the right thing here, but in the end decided against it, in order to guarantee that mutex_lock_nested() does not introduced overhead without CONFIG_DEBUG_LOCK_ALLOC. Signed-off-by: Arnd Bergmann Fixes: 9f01cd4a915 ("regulator: core: introduce function to lock regulators and its supplies") Link: http://permalink.gmane.org/gmane.linux.kernel/2068900 --- The patch that introduced the warning is now in 4.4-rc1, and I think this patch is still the least ugly workaround we found. -- 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/ diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 4cf1390784e5..cf5371ee0be4 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -142,7 +142,9 @@ static void 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)