From patchwork Thu Oct 27 21:47:44 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: 13022858 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 B677DFA3740 for ; Thu, 27 Oct 2022 21:48:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235277AbiJ0VsQ (ORCPT ); Thu, 27 Oct 2022 17:48:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234947AbiJ0VsP (ORCPT ); Thu, 27 Oct 2022 17:48:15 -0400 Received: from msg-1.mailo.com (msg-1.mailo.com [213.182.54.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1B5985A83; Thu, 27 Oct 2022 14:48:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailo.com; s=mailo; t=1666907271; bh=yLm+PiUX5XIUPovFzVHx3LyxXFzrfVux7pO61g17TzE=; h=X-EA-Auth:Date:From:To:Subject:Message-ID:MIME-Version: Content-Type; b=TAAmoNC8wYFXIWG1qnxNHYFkiOszIFduU5pT6OmHq/Pzqe/4iS4Md4YRya70mS5eB F4rnvCUKKlTun2fy19uYhU03gAqQBbCroERP7aVGRCI3ixMuNK5+hon5YwYpG1JB0u xzIL1/WG4x8f42Gtrwb+42UqaZRHRmZ0er0SWzoU= Received: by b-2.in.mailobj.net [192.168.90.12] with ESMTP via [213.182.55.206] Thu, 27 Oct 2022 23:47:51 +0200 (CEST) X-EA-Auth: d9SByaZo8cw/fNOd4EIt6ycZB57O4VIIr8QshUjrUPxNGcHHY9c5Pv3ntXVyyyLj670DF+WmranW321ioaRf6dZ3gKl3ronA Date: Fri, 28 Oct 2022 03:17:44 +0530 From: Deepak R Varma To: 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: ad9834: 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/ad9834.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) -- 2.34.1 diff --git a/drivers/staging/iio/frequency/ad9834.c b/drivers/staging/iio/frequency/ad9834.c index 285df0e489a6..3917a76e7976 100644 --- a/drivers/staging/iio/frequency/ad9834.c +++ b/drivers/staging/iio/frequency/ad9834.c @@ -102,8 +102,7 @@ static unsigned int ad9834_calc_freqreg(unsigned long mclk, unsigned long fout) { unsigned long long freqreg = (u64)fout * (u64)BIT(AD9834_FREQ_BITS); - do_div(freqreg, mclk); - return freqreg; + return div64_ul(freqreg, mclk); } static int ad9834_write_frequency(struct ad9834_state *st,