From patchwork Wed Sep 6 13:13:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9940663 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 185B060350 for ; Wed, 6 Sep 2017 13:13:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1245828BFE for ; Wed, 6 Sep 2017 13:13:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 042CB28C07; Wed, 6 Sep 2017 13:13:45 +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 7BE2628BFC for ; Wed, 6 Sep 2017 13:13:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6D0FB6E6F5; Wed, 6 Sep 2017 13:13:43 +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.134]) by gabe.freedesktop.org (Postfix) with ESMTPS id 38A996E6F5 for ; Wed, 6 Sep 2017 13:13:41 +0000 (UTC) Received: from wuerfel.lan ([95.208.190.237]) by mrelayeu.kundenserver.de (mreue001 [212.227.15.129]) with ESMTPA (Nemesis) id 0MQZS8-1duyy923Qa-00Tjia; Wed, 06 Sep 2017 15:13:33 +0200 From: Arnd Bergmann To: Yannick Fertre , Philippe Cornu , Benjamin Gaignard , Vincent Abriou , David Airlie Subject: [PATCH] [RESEND] drm/stm: fix warning about multiplication in condition Date: Wed, 6 Sep 2017 15:13:07 +0200 Message-Id: <20170906131331.2691300-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:TEldHEBOH7XVzFkPWLlJi9TRbqy7+gsyHTCxGe/qlrKVxHfJfk9 1xcXk46YjZGY3ySOkB7w2vtrrimxW0bdk/W2LYswZZWdVJqLQ8UXmOz8ABW/A/+L8+hpq4O 4hn3J2PwG7okf6eP872S4PAtbCylGnPaqdfgLPb5nVLhCOld3bQtSyiVtx3iCljhUwI+Dz8 xE8xBEbVx1KTDiLcE1/aA== X-UI-Out-Filterresults: notjunk:1; V01:K0:hFErB3lZNTc=:8YY6bhE7k5uWQBKMCHyohf y22rRRmpeAdn4HWgVUhruN/buGtded5aNmbY01+qFmd2DOtJvKhbf7/TUdORUmJ48K0B7Bixm 2lxSuGBxwJRcpbzzn7UsB5XuanuC36Wg4fgL16rFBhf8M0k/xAyuA0YgdD1PizbkgH62f/Kh3 qsh2TK4AqQsETQuEk1vA7F17CBYmMclinG17H0Z3je1TEH/AgoDvF2yiC1EiIHn8tSXI+bmbY +/v0qT8Y3ZIHViuAxNYFpX3I48MbcUVjAYpcNLfnNWDMcVAoTLyEhE9P0eH9PDY9zPA5pKydw wT1zUtvBiiou/o8U/5pCF8RlbMpsW059q3H0niftOQ7en4RsSWgY/u3NFWTHz+UTMmF+gi/cE Pp1SdRms/vyBrhIze0FTwcHIs8hPalW/cybhInvlbzPI8tGGkXkfv/R/utMkGFKKDHfze10Rq 4pa5U1bDStf/imBhy8ht+bQ9ZJZeT5FAXCO4ScQkmxDmX3itwv/DF+33/ikuQ14NnDSNjZavq s5NOuoPGwSAL0Afz78M0lwlVp5MlOllMy7vE1Gd7YAq3ml2u46tzI9+6detssBQt15iBhVFgZ jXRG0BZ8p2u+8C+brUzU+abPBh7V8ATcd5EpXTpUL5XAGU1cYEIgigf6qIuPVfYoXCiY7niVz /9vR1sb0i/pkX1+u43HnFJ2bckQrt2Fy0Nmph3wgfZUhoXQRf/WElB8icrAfkZUi3a0OT25I7 4nR+/z6R8aJp34pPgxz44g0zW21m7oNt2jxAsA== 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") Acked-by: Philippe Cornu Tested-by: Philippe Cornu Signed-off-by: Arnd Bergmann --- Originally sent on July 25, but never made it into linux-next. The warning is currently disabled in mainline, but this seems to be a legitimate instance, and we may want to turn it back on in the future. --- 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,