From patchwork Thu Oct 27 21:28:49 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: 13022856 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 C2B97FA3740 for ; Thu, 27 Oct 2022 21:29:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235686AbiJ0V3d (ORCPT ); Thu, 27 Oct 2022 17:29:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236551AbiJ0V3c (ORCPT ); Thu, 27 Oct 2022 17:29:32 -0400 Received: from msg-1.mailo.com (msg-1.mailo.com [213.182.54.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F1B76352; Thu, 27 Oct 2022 14:29:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailo.com; s=mailo; t=1666906136; bh=OOdVohmxjyqwES6BVgivansb/UtVz9aFP/lWyrNnjg8=; h=X-EA-Auth:Date:From:To:Subject:Message-ID:MIME-Version: Content-Type; b=pKtWuCzhbBIk1PM0LhtiIxTshU6xE/iTaortghI75CbomsIrhKFsHXQw8TQumY9L5 k2qAe37H/A9uZuvnnIM1JRkFeMIpLbCz8vO5wju6oIi2Kmp++bZOsRqacSYC80WEIw UZdceXgXv6uxSJC/GqSsOwPvuKGDe6+CaF9SGvF4= Received: by b-2.in.mailobj.net [192.168.90.12] with ESMTP via [213.182.55.206] Thu, 27 Oct 2022 23:28:56 +0200 (CEST) X-EA-Auth: 12GbF3MYEzhNl3lHw/2UILN1hYg3324yD/EbSHxll6FcVpG2POaqfvUrBwf5K3X6yPxM/38dmvXLCKbUsrRha4lx6gNTmkx5 Date: Fri, 28 Oct 2022 02:58:49 +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: ad5933: 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 was identified using the coccicheck tool. Signed-off-by: Deepak R Varma Reviewed-by: Nuno Sá --- drivers/staging/iio/impedance-analyzer/ad5933.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.34.1 diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c index f177b20f0f2d..730bb31a20d8 100644 --- a/drivers/staging/iio/impedance-analyzer/ad5933.c +++ b/drivers/staging/iio/impedance-analyzer/ad5933.c @@ -196,7 +196,7 @@ static int ad5933_set_freq(struct ad5933_state *st, } dat; freqreg = (u64)freq * (u64)(1 << 27); - do_div(freqreg, st->mclk_hz / 4); + freqreg = div64_ul(freqreg, st->mclk_hz / 4); switch (reg) { case AD5933_REG_FREQ_START: