Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp332776ybv; Thu, 13 Feb 2020 01:11:02 -0800 (PST) X-Google-Smtp-Source: APXvYqxThEfaPgh694/BvW7w8Qr94xIk0Ol3QXG4XIHWkvQHA+9TQsJVaNPyc7TWXrs+xIhrckJf X-Received: by 2002:a05:6808:30d:: with SMTP id i13mr2151064oie.144.1581585062142; Thu, 13 Feb 2020 01:11:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581585062; cv=none; d=google.com; s=arc-20160816; b=tA8xbCDuWjAPCNiVs5+A1AWZZb/ibWO+wE/kN/YC22MfSm7MokPX0INmfpqTfftkrB o+Ebv9qSL6WM5UpX3tW0dS5P/TYgiUnnSbEtnnWwcYbLrIqofN5chJbTmzrX+grgIeV4 m/aLtIWdLBV3TFEljR5ZlD65ux19ygBRPPRv+zM0VbJgYzEQb32H1L0HbNsgpIBP9rRI utEVRdyBgcE7swAfaVbdheZLzVAYNAbQExHdtpk0qdndZO0qO9zDdATs7Tik/UnC7qDo 3WWFXOCVcXa12A15xxM6JG/yYeJ4z4D7uIJFQ8YGDEmxtX6oAGdSS1PvdKR/m7JeB9ju NeRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=e48huERyAc6MWS0f2/jpjTt/WdqFIWBGvGl7+Z4sehY=; b=lS3dVYXndt7EnwlwAWItoGTPO0SasH/5svfMXNea4m/lY9LQGgceXb9T7WvIgmo/Ww yX72ChPStproG4602hiHQ7Mkxv+Um57Q88afdBlYkEWCbBhYOOzDca0EP9XN8kRwnX2H ai19XYCj8cXZtLO54d8FAQ3gTMHDgwFoySax6vByIxt3/EcY+0uED3uJOHYlW4l280et 0kNMWcPPIpAI9OJ87K4OV3+z7/A+TSWWIGiMzzjribno4v/tpnyt5AkIdQX9m/U0/LQ3 TTcWgYtsrpyNINhATrgKxrXWImkNFyR62vGz3obkDYDiYeGruuMqGqcBLATAughHWjIu hK9A== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g25si802065otp.20.2020.02.13.01.10.49; Thu, 13 Feb 2020 01:11:02 -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 S1729662AbgBMJKC (ORCPT + 99 others); Thu, 13 Feb 2020 04:10:02 -0500 Received: from sauhun.de ([88.99.104.3]:45230 "EHLO pokefinder.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729515AbgBMJKC (ORCPT ); Thu, 13 Feb 2020 04:10:02 -0500 Received: from localhost (p54B33627.dip0.t-ipconnect.de [84.179.54.39]) by pokefinder.org (Postfix) with ESMTPSA id CD4352C07AD; Thu, 13 Feb 2020 10:09:59 +0100 (CET) Date: Thu, 13 Feb 2020 10:09:59 +0100 From: Wolfram Sang To: "Gustavo A. R. Silva" Cc: Thor Thayer , Andy Shevchenko , David Laight , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] i2c: altera: Fix potential integer overflow Message-ID: <20200213090959.GA2123@ninjato> References: <20200211144704.GA6461@embeddedor> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="45Z9DzgjV8m4Oswq" Content-Disposition: inline In-Reply-To: <20200211144704.GA6461@embeddedor> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --45Z9DzgjV8m4Oswq Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Feb 11, 2020 at 08:47:04AM -0600, Gustavo A. R. Silva wrote: > Factor out 100 from the equation and do 32-bit arithmetic (3 * clk_mhz / = 10) > instead of 64-bit. >=20 > Notice that clk_mhz is MHz, so the multiplication will never wrap 32 bits > and there is no need for div_u64(). Was there ever? With u32 clk_mhz =3D clk_get_rate(idev->i2c_clk) / 1000000; a later multiplication with 300 should not wrap u32? > /* SDA Hold Time, 300ns */ > - writel(div_u64(300 * clk_mhz, 1000), idev->base + ALTR_I2C_SDA_HOLD); > + writel(3 * clk_mhz / 10, idev->base + ALTR_I2C_SDA_HOLD); The change itself is OK, yet I wonder about the comment above: 'clk_mhz * 0.3' will not give a constant 300ns, or? --45Z9DzgjV8m4Oswq Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEOZGx6rniZ1Gk92RdFA3kzBSgKbYFAl5FEmMACgkQFA3kzBSg KbY1uw/7BhPcgJIcLbjs58paXf+DrYXcCzE4JXUpsxHft1b1iZ35nwkka2gUVbj0 S2Hi9JqDetiMdhVWHYPjFb04Qe1vyfZa69zwWYjMCwMgLZUUBTDCd8a2enehWBAD DAE9DClhtvYWAHbl4BoQTqgFCjwmP5mit8EZjKY79SgfS7ZVPuKWCFOYUztWPBtc 1UnG2ZtT8eHTl/rrOMND+8+c0HYDuXBuNPCK6QVNX80yhtDgNfVpufQDTHXGgGV8 CMCmrvHu0To49H2Qj4sSZs/wQQX4u3eMqsS4PARW0UQm8jB/6+EmYoHJH4u87XBg 7KMQMPeQbMFuU998ns4R9Z32ouhwK+yQunjxL/Fezn9dhX/p6TxdvYu9difsmnPG vTPSs8yHSq2AYgfQ0DwWivV6cNEvfdFd7PiAnBBZCO+JDfziPfoqRGFz+do0O9Fm SHCm907tybkTtilG1EsgrSWTO04H9V9L7bq8mWc7eG+V7u1+YGkEwKH/38EgnQx1 em1FinZ/lLglFc17TEvEuapeRO5Nec120q6MHCEkHjuC6cz4SbWesLQnWStWmsBa 1TTBJT6D9ED0np3F8N7cNKHqbaCTB6V7rCLGgbm4PMKHK81TK/VL+Ya5/WluMv2f UtzX/DEoqDxsARBstFHP47bYJlPJCMF4a4CQcRR5ko6kWKXWjYE= =R290 -----END PGP SIGNATURE----- --45Z9DzgjV8m4Oswq--