From patchwork Tue Jul 25 15:40:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9862351 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 C33DF600F5 for ; Tue, 25 Jul 2017 15:41:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AD276286BE for ; Tue, 25 Jul 2017 15:41:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A1B0C286E1; Tue, 25 Jul 2017 15:41: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=-3.7 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM 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 6B0FB286CD for ; Tue, 25 Jul 2017 15:41:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 70AB26E580; Tue, 25 Jul 2017 15:41:41 +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.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id E6A596E573 for ; Tue, 25 Jul 2017 15:41:39 +0000 (UTC) Received: from wuerfel.lan ([5.56.224.194]) by mrelayeu.kundenserver.de (mreue101 [212.227.15.145]) with ESMTPA (Nemesis) id 0MKJHi-1dYNGk2JS2-001fJl; Tue, 25 Jul 2017 17:41:32 +0200 From: Arnd Bergmann To: Yannick Fertre , Philippe Cornu , Benjamin Gaignard , Vincent Abriou , David Airlie Subject: [PATCH] drm/stm: fix warning about multiplication in condition Date: Tue, 25 Jul 2017 17:40:52 +0200 Message-Id: <20170725154130.332221-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:L1KgIp87nlv/0httxRci34AODCmRiEkxeBKYWusdy7ULfGJZTh3 pq+Fo6uhUb0RYQ9v6sg7ZVn8xB97s83FZpOUXkzJ0KDs6H+tMQtUduNmGuYM/F+Z3IMlzG7 EzcabyxneuxWlUv+yxqaOeTXTNfu3GTglI/cdd88R+qbtxeQExVCFNHFxrMmrEEeSJCTGBk sPU40QMSmhH1PWPuVQylQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:fPvkbDqJ8G0=:pmepIXf5mQ29Rte79ayekQ tSjOZsgokDLcno1o/oQ4hddHZsRV8Tx/Ac84hRfI/VmiKnXaGtUMaHLCdms0ErKruH55kYdGG dBYgi9dDhUSOuRx+JlG+W6XqRwXzFzoQTsIRGTz4jLfHo7J3FdVskDtCx1mKMIr4rBecxr3pD IwYq2MHQgg16bSm0c4FyTE+t/HoZ3Bgn3ZbEFCjsV3I+I/xHD7DYNRShuZrmt+pYUAOr1d8od O6CP7XQA4YaYQ+wT+uYKAgli98BvJXtpxlQthNrKHyXq10f3ZywTfhh669VPUAzIa2vbbWUpY iksj4y7hmIw7tAZfgsVYhn5etxXgh7tD4s21bF7G/jXXSLW+YErskbWb++VH7YUZt+i4PPqlL eEyR/twID6zndFXZ3NthDTSC1PDo8Qa81NWejLp6shFKULGXwmC+m+EVuISpc2WvbmNWJuwFt 8pA6pgET8g7ppdvBvbW1xj6KQcEJNljLIdkb0GeDsyRjRkKlw1F39JsCRGYGmz2v2Gw83SxfH j1fcRgYa1AU52LDLox/tFxotCrsr+jO5zmT4Eha1QudgPcEagjz6dY8ueIwt07zU4MCUNz75Z Oo+DyX6vZErV8BCw02QbRL3vHGuQcl8irBcGLFg/NTjbErv+qBGveijCKIknUddGwqkk9f+Pe N+HAZ+y7dp6YTkIspgCY69JvYrf2su1XDM/sg9ZSE0ewxoZxTIVQwFIEP0w0+rDXaePu5+0o9 VIIR39CtZQlYzDG4Byv+kU2PD7O/V3THbQhk+A== Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Arnd Bergmann , Neil Armstrong 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-7 complains about multiplying within a condition being suspicious: drivers/gpu/drm/stm/dw_mipi_dsi-stm.c: In function 'dsi_pll_get_clkout_khz': drivers/gpu/drm/stm/dw_mipi_dsi-stm.c:117:10: error: '*' in boolean context, suggest '&&' instead [-Werror=int-in-bool-context] The code here is correct, but can be easily rephrased to make that more obvious. I also swap out the error handling and the normal code path for clarity. Fixes: b0f09a3c69d9 ("drm/stm: Add STM32 DSI controller driver") Signed-off-by: Arnd Bergmann Acked-by: Philippe Cornu Tested-by: Philippe Cornu --- drivers/gpu/drm/stm/dw_mipi_dsi-stm.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/stm/dw_mipi_dsi-stm.c b/drivers/gpu/drm/stm/dw_mipi_dsi-stm.c index 568c5d0461ea..e5b6310240fe 100644 --- a/drivers/gpu/drm/stm/dw_mipi_dsi-stm.c +++ b/drivers/gpu/drm/stm/dw_mipi_dsi-stm.c @@ -113,11 +113,13 @@ static enum dsi_color dsi_color_from_mipi(enum mipi_dsi_pixel_format fmt) static int dsi_pll_get_clkout_khz(int clkin_khz, int idf, int ndiv, int odf) { + int divisor = idf * odf; + /* prevent from division by 0 */ - if (idf * odf) - return DIV_ROUND_CLOSEST(clkin_khz * ndiv, idf * odf); + if (!divisor) + return 0; - return 0; + return DIV_ROUND_CLOSEST(clkin_khz * ndiv, divisor); } static int dsi_pll_get_params(int clkin_khz, int clkout_khz,