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: 11995 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp473730wru; Thu, 27 Oct 2022 14:56:25 -0700 (PDT) X-Google-Smtp-Source: AMsMyM45/YHh4pVXk0z33VSniDuhNShRx9Bs4JL7td1P1a7px9PiCQadWqJLLyJE6FeOW8u7hxh8 X-Received: by 2002:a17:906:dacd:b0:780:a90c:e144 with SMTP id xi13-20020a170906dacd00b00780a90ce144mr43948204ejb.153.1666907785476; Thu, 27 Oct 2022 14:56:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666907785; cv=none; d=google.com; s=arc-20160816; b=Glw6Cofsudjw7nQg1jRW6UoAY47fzIrqvyKH4gBV9efQoBgS8nyMGLOPoG2biseF/D z7YK47XL8WhrfJlyz9OU607+WV7lBpP43i/aW9dpHCLDMIR2KY5OpRDe6yCb8D+cltdY mg+3GuQSF/NmDstEn37d96iGLGq3JFFNKSEkjBdtmEcRfb5aU6uKdZrsKwhEVXSNwj1S +DIZ+sIXsV6HWGyxPHiTqc+dSfhncZ/0yOMxo8QQ9t/NAOXXrrgqSY4xI81GXJFMALFs Dckoc+b5wVj3wpIyeP6PSXO/bG4aBv0SijjN72m0O3Ji85FuF5ZGhLcyGllKQMQHFMjM bQtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:to:from:date:dkim-signature; bh=iMADvq7qrNIbusUP4oTaF2xQiwB54l0j9CmC8apvEbU=; b=MrAvGnQwGdbK1oQCuiLZFN94ysYT7FAEQYNH/QVyQqGIOyqMLhm7UyR0rC0USbTCKi rjqnYwdezFJ2QDASdxhlb5aHNbpORXL7fZVWKHsg+FOjSsx7mGhmaVb7aDk607uWsXfi HZaCLfzDPlDDWq0gG4sDuSFxkVnTks2WfdIQR6Xk2SfaHVqJjIyY9EyUpUEEL1KpvIds wKYgvgx/zyMdrgXYcHJKynDUL+MKfO6hLkcHJG1/V7yucqPrHtOcdBcJcUU8V3eESRwP fWXmeObAVTVHgUOxc/g/XQlMe23HJAKo6kHVleiqNP71lXmzoZGruHSofnwsiZRWo2TI VTGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=TAAmoNC8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mailo.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p8-20020a170906498800b007ad69eba328si2194523eju.539.2022.10.27.14.56.01; Thu, 27 Oct 2022 14:56:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=TAAmoNC8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mailo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237020AbiJ0VsQ (ORCPT + 99 others); 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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747879497834867884?= X-GMAIL-MSGID: =?utf-8?q?1747879497834867884?= 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,