From patchwork Thu Oct 27 21:54:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Deepak R Varma X-Patchwork-Id: 13022863 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72D99FA3740 for ; Thu, 27 Oct 2022 21:54:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235273AbiJ0Vy4 (ORCPT ); Thu, 27 Oct 2022 17:54:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233569AbiJ0Vyz (ORCPT ); Thu, 27 Oct 2022 17:54:55 -0400 Received: from msg-1.mailo.com (msg-1.mailo.com [213.182.54.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E6505AA22; Thu, 27 Oct 2022 14:54:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailo.com; s=mailo; t=1666907670; bh=4oNdMi2kwzVQqP/G4iEoq1fG0MnLzqOREBAq7uQlKko=; h=X-EA-Auth:Date:From:To:Subject:Message-ID:MIME-Version: Content-Type; b=e64bH2KCF/NhJoK7k50x0726Cj5ZS9rGv3hbTf8tz3Bm/9XvAn5m+EMVyt2HlMW1c dvqfdpENHQrLWJtoicI2guChk23LV+q9UGLQPqoaBLAZ/D/NfnF7FaEML1GJPO21lx JvYGG7Wads6WLSJEnsC9A7xyJ7uJ1kKqmfZa4VFs= Received: by b-4.in.mailobj.net [192.168.90.14] with ESMTP via [213.182.55.206] Thu, 27 Oct 2022 23:54:30 +0200 (CEST) X-EA-Auth: pBtERwH+CqDwwoap8myOtvOhAxjDOFlSbXiE1xcZX4jb77aRpGyBPzTOL5KKCfbUA5uF7kSH2l7vbDTeoiapN5VOEN0ZNqsl Date: Fri, 28 Oct 2022 03:24:24 +0530 From: Deepak R Varma To: outreachy@lists.linux.dev, Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , Greg Kroah-Hartman , linux-iio@vger.kernel.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH] staging: iio: frequency: ad9832: Use div64_ul instead of do_div Message-ID: MIME-Version: 1.0 Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org do_div() does a 64-by-32 division. Here the divisor is an unsigned long which on some platforms is 64 bit wide. So use div64_ul instead of do_div to avoid a possible truncation. Issue identified using the coccicheck tool. Signed-off-by: Deepak R Varma Reviewed-by: Nuno Sá --- drivers/staging/iio/frequency/ad9832.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) -- 2.34.1 diff --git a/drivers/staging/iio/frequency/ad9832.c b/drivers/staging/iio/frequency/ad9832.c index 6f9eebd6c7ee..a8409f6b1c4c 100644 --- a/drivers/staging/iio/frequency/ad9832.c +++ b/drivers/staging/iio/frequency/ad9832.c @@ -122,8 +122,7 @@ static unsigned long ad9832_calc_freqreg(unsigned long mclk, unsigned long fout) { unsigned long long freqreg = (u64)fout * (u64)((u64)1L << AD9832_FREQ_BITS); - do_div(freqreg, mclk); - return freqreg; + return div64_ul(freqreg, mclk); } static int ad9832_write_frequency(struct ad9832_state *st,