From patchwork Wed Sep 6 21:40:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9941371 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3C4406035F for ; Wed, 6 Sep 2017 21:46:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2D82920683 for ; Wed, 6 Sep 2017 21:46:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 21C0E212E8; Wed, 6 Sep 2017 21:46:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B09C720683 for ; Wed, 6 Sep 2017 21:46:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3E6926E82B; Wed, 6 Sep 2017 21:46:35 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.135]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3F2136E828; Wed, 6 Sep 2017 21:46:32 +0000 (UTC) Received: from wuerfel.lan ([95.208.190.237]) by mrelayeu.kundenserver.de (mreue001 [212.227.15.129]) with ESMTPA (Nemesis) id 0LhoIM-1d3yuC1fGs-00nDRU; Wed, 06 Sep 2017 23:41:10 +0200 From: Arnd Bergmann To: Ben Skeggs , David Airlie Subject: [PATCH] [v2] drm/nouveau/clk: fix gcc-7 -Wint-in-bool-context warning Date: Wed, 6 Sep 2017 23:40:53 +0200 Message-Id: <20170906214108.1985196-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:irTedbdMJPt7gUsDoNyZbSFiFlJdhuqH7I7HGRZQZsKZzQ1bYOb jMs9y2OtI3dRZpaFvvdO27OZ6jN+X6NyYycYGWOl+Q73A72jBQl9ALPv26VUebidMAovXW5 iFFfDWmqwe1QW9hy/bt9uoS1M1Jzt9CltgpgJyvfc0A5loSSKJJmqym6/fLfS1ATQKkMNJw xaluPWlr5gWnOx+1E2vLA== X-UI-Out-Filterresults: notjunk:1; V01:K0:KR7Z/xMgDRc=:1JtazXXQxwsqKwkJyCakQR aogCFttxhxlWF29qKfzF3qjnWdeiyEg6Art8wQTjdRF16TmzCrbTGV4b8DDZfzArZRhUIlRFM kWmuRhtjjbGjpMY+OnnRSk5N1VUwchl547lnDBtFWWwdwNA2ROrjEALntL6H2977Haifj5e5g GEiuuRKxdBE6I9Q07o55k6DJ9D6P8KF/JouL+uq01SVCsdD5+WnaTb6lvZUGDkc6XLlo7AWyJ aZOx1zo9qAhyJ48ag19NpxF2rz/q4M+Hzmui0xKmbGFqnqhbLTRgl/FRrdeJXZnwNFpUIoHKF o1QfpK7SKPkztlqxQR4Rmw7YXmebRLHgsQG0eUa0Ny5egaVUdKDrFkY/2+x8ZDJyiT1Pf3mpp d71Dq7fDShpZOvT+vsWiABGa2ww0Q/sgsT+ilzd6eeGIxYOrdfjG3GxyktbKtMF7pxtVu2lhs W9NHP4l1ORtWxaTCJ7GMRtidAkhYFq46fam3+sqY05jEw0zdzP3sKc3ITA+z97ZPuc0lAba5R 1Y5Eoy2X/vAEKNMG6bLFiFAAX5J/xzq0Ue70L8YmCznkypX1mAALCt0jbDBn7cIx3lQebs8qY 6EE8TY1c21EcEN6QYEma2ucW47hUg5EsyKkHse7kTjwXH6PrHJ1oYH/qejaTwkCboTauiK8UW c5gwDNog2i3N+zCvHPt5LBDHI5XV1IS9FBpC28WkRkx+iHspwiaUoiBkK4Yf9Zm9kjYBFiLg/ kOE89W9YDaAHA7tdspcBwZHLowIb2aBa+KYUNw== Cc: Arnd Bergmann , nouveau@lists.freedesktop.org, Karol Herbst , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Baoyou Xie X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP gcc thinks that interpreting a multiplication result as a bool is confusing: drivers/gpu/drm/nouveau/nvkm/subdev/clk/gt215.c: In function 'read_pll': drivers/gpu/drm/nouveau/nvkm/subdev/clk/gt215.c:133:8: error: '*' in boolean context, suggest '&&' instead [-Werror=int-in-bool-context] Adding a temporary variable to contain the divisor helps make it clear what is going on and avoids that warning. Fixes: 7632b30e4b8b ("drm/nouveau/clk: namespace + nvidia gpu names (no binary change)") Signed-off-by: Arnd Bergmann --- Originally submitted on July 14, but no reply. This is the same patch again. The warning is currently disabled in mainline, but I think we can turn it back on in the future, and this change here seems harmless. v2: use a temporary variable as suggested by Karol Herbst. --- drivers/gpu/drm/nouveau/nvkm/subdev/clk/gt215.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/gt215.c b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/gt215.c index 96e0941c8edd..f0a26881d9b9 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/gt215.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/gt215.c @@ -110,6 +110,7 @@ read_pll(struct gt215_clk *clk, int idx, u32 pll) struct nvkm_device *device = clk->base.subdev.device; u32 ctrl = nvkm_rd32(device, pll + 0); u32 sclk = 0, P = 1, N = 1, M = 1; + u32 MP; if (!(ctrl & 0x00000008)) { if (ctrl & 0x00000001) { @@ -130,10 +131,12 @@ read_pll(struct gt215_clk *clk, int idx, u32 pll) sclk = read_clk(clk, 0x10 + idx, false); } - if (M * P) - return sclk * N / (M * P); + MP = M * P; - return 0; + if (!MP) + return 0; + + return sclk * N / MP; } static int