From patchwork Fri Nov 20 14:23:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 105224 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp512220lbb; Fri, 20 Nov 2015 06:24:49 -0800 (PST) X-Received: by 10.67.4.202 with SMTP id cg10mr16876657pad.81.1448029488905; Fri, 20 Nov 2015 06:24:48 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 17si582257pfo.238.2015.11.20.06.24.48; Fri, 20 Nov 2015 06:24:48 -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 S1162763AbbKTOYr (ORCPT + 28 others); Fri, 20 Nov 2015 09:24:47 -0500 Received: from mout.kundenserver.de ([212.227.17.24]:53416 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161373AbbKTOYp (ORCPT ); Fri, 20 Nov 2015 09:24:45 -0500 Received: from wuerfel.localnet ([134.3.118.24]) by mrelayeu.kundenserver.de (mreue101) with ESMTPSA (Nemesis) id 0MGzMw-1aCPut1Va6-00DpQz; Fri, 20 Nov 2015 15:23:21 +0100 From: Arnd Bergmann To: Mark Brown Cc: Sascha Hauer , Liam Girdwood , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Peter Zijlstra , Ingo Molnar Subject: [PATCH v3a] regulator: core: avoid unused variable warning Date: Fri, 20 Nov 2015 15:23:19 +0100 Message-ID: <57950510.5n95rqyCDA@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:1njvwj48hWIGEAFeJvoEdsxZDywu46U+I6OzBbeD0TDAHL8GgMX hI3n+f3X8155HOal+HdlG3R7b9sSa53nglwpkv+t8vHHbsj4UL28kA+miRaEJ8VNyIj6c8E jMESTb5k4dQXd2eMs3kXwYvpKf45Uheq6s9JHV8BNarmk/SDPxyNsSd97rZTvEHv7tVWmu/ 1sJ/wuEdARQRrmLIM7hTQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:wvLQcL5PBYM=:tgP5X2q9OXr/0zgtSZg6bq Szf2Se58mShDseFq/ddYBJivlnhneX9CAzwlofaR13KU/x1isUiTFRc5sg7TUneTjjKzqUdFU BUiyYOyvGpUNf07dzRZegPDnmntDsLigykdYejifXKJ469mK4pcLEDMgwtfMbTuaRL8NCjc/b xc+dKfPYFlDrF5JCu03itNQMgVLH1AB4SwSPL/gXIjUSWFhOcGaZrmQARNskL/CXcBP/L3/gb jM8U76ARjL8S9Uroul0wkYf7zN7vNce74AtkMyOHK1EzVqla3iXj7iOikMknzmAhHVIYsGDPh +ycIlT3h6RMJ+Hu53aCz8UnhjNFbVLP1hrdivrBrmxNF2fbc7IUBPq04/+LhQv9At6wHfi38K EqMsjjzaov5qyde4RiNBfOJHnlTaN/mqgk7Qrn/Cu4qYyYS/X74NJOwdJNqdA9HpfhO4f31g1 QkzG8CLhylGdIzvFzP7WdjfPCYyhduaKTBEHzHUCxohp+Ru5nV9FEhgKj8qxrr+7tgyY1eX64 Bmc1baiqlU9yyeJ09iQHBP09pyGRDcPV5No4BHiMiD5oUrSVw66117MlTemJUCTmLsIEHLCMw 8dwvAyMNHxAEtkG+cBTCFYMr5hqciEHVqOUQx7buyDuZ5aNvgUR+zAvrxfnfA55f11SwOoBpd xCfIOYlc/0pdEtsSM8njobLvYfYAGyV+p7Fjr4LRSlz7uDOYZdpR8KbBTimfNduQNGbNigW9T rIDPyYydSMMWFXPj 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 -- 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..5afe02cce9aa 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -142,7 +142,11 @@ 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); + + /* avoid unused variable warning without DEBUG_LOCK_ALLOC */ + (void)i++; + supply = rdev->supply; if (!rdev->supply)