From patchwork Tue Jan 16 13:44:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 10167047 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 05EE860325 for ; Tue, 16 Jan 2018 13:51:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EC8E828516 for ; Tue, 16 Jan 2018 13:51:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EB51E28543; Tue, 16 Jan 2018 13:51:53 +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 C9476287D4 for ; Tue, 16 Jan 2018 13:50:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7E7E46E22C; Tue, 16 Jan 2018 13:50:53 +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.17.10]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1EE3F6E227; Tue, 16 Jan 2018 13:50:50 +0000 (UTC) Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue102 [212.227.15.145]) with ESMTPA (Nemesis) id 0LyDvp-1ewsRU0M2X-015Wau; Tue, 16 Jan 2018 14:45:09 +0100 From: Arnd Bergmann To: Ben Skeggs Subject: [PATCH] [RESEND v2] drm/nouveau/clk: fix gcc-7 -Wint-in-bool-context warning Date: Tue, 16 Jan 2018 14:44:50 +0100 Message-Id: <20180116134507.3856450-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:1aNey5RHVn0QHB2uDe5O5qzTKCfAdHz5ARC4IQ1t3e5NfOfk7/i zvJp+ZlmPirS91O9Gm1NIDtJQizy7w1bwA83u7LvqsQXV57Ngdi0kGC8X9fqnDUJtVPHOnS zO96Y1yeaEaP4iE2HVSd2Cou69wGCmfiUIYC5glqD5UtJZnlRilPiNriTS6eNwQKiju60x/ Q1I8Z8D0+8Y4r67O7iZAg== X-UI-Out-Filterresults: notjunk:1; V01:K0:SGFLD6K9XFA=:u3axpg9yf1vWvgp5mF4LR8 bZCRCgr6MP/FGTwpBAqdB1eCUUbC0NbreIkbgXHc1BcXIjnd7exRjnK5CkD1ZVuZ71LjDxEmV vMGFYPXEPJSHfHy6/tzEqLC0aalESzqjYt2FH1N6neZBHUIVSFS9AcUH2HFv7Vh7/WEziinsG URJwD0C1DEQ10fTtIpXHrgaiCFZpqwu/+zxHBtJe2Q/TVijbtRR676I5gucWvrgljZq+aOaJp YLmrXwO13hTTGXjwDZ55Z03Mf8VO/ltvDF2M7lzYi43PaZD1eqNmglwiNOz069aGqU3ct05M7 0jr77ky/OotkAkzReFKCbGTrNFpzaHXAPmSCfWep0dLI5qit7uCnEGbV3znJWi92L2aoGVkVY j7g10IMozOWGxcF8cRbW3OmgZjGthatmhp7X3Ejg2N90TBUwsfc/chXwJOmSu1VyvAuKAIefR PT7ebt/t6CEp4McjTueFB17V7IiTmsPt3rwqSS0ZRNbZhnlMy4jWjxXrAmkm7+8VMePY8QBXq I0JIDseSjjcljpWqKX806C+W58TtU48TffjWcE11jZiMsGb4aEQ/7VpJJmMLwokZzyaVNI/xB LSqd9M1T+K+k8oD0auzXiCER6KQk4eISTpVUtqd+QFP30aBiwdy3NzwXcjP+L1xnJ7Yh81YFD AMcLp5rRAfYqxWHHht899AGMk3wKgA4MAgR5Aav8Y5BrodfmR/0uciOfZTaKs++qsN4wpmll5 vdSf4XblPuWT8EFFPWyu7HNDCez8/dVRyXNs1Q== Cc: Arnd Bergmann , David Airlie , nouveau@lists.freedesktop.org, Karol Herbst , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org 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. Resent on Sep 6, got one comment and sent an updated version, which again got no other replies. This is the v2 version 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