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: 11996 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp474385wru; Thu, 27 Oct 2022 14:58:39 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6GA4oDw/HyeVk2OXTcU5qeWZVbO/qECpwTSFwTB8oYSPzyhOntYaVIjgkItbCc6GPbvYTW X-Received: by 2002:a17:907:9717:b0:78d:9fb4:16dd with SMTP id jg23-20020a170907971700b0078d9fb416ddmr45038675ejc.720.1666907919009; Thu, 27 Oct 2022 14:58:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666907919; cv=none; d=google.com; s=arc-20160816; b=IpH9iZ7Cf8rz625NgB23LDDKlIN0xll5wBhTgSweqecHWNHJH+M/KmGaGc+mIRZ74d rINDkA9UNYo+jTTsh0yRN+Pm4Je1YYe0yNBHmvedkc27sMW6IbpXbgEynCzfMBgcaec9 xBJrzyqj3T4ZBtlcvJi71nQdoaAi4QhaPlCwtv7bOW+GYIRVLtYX1GFu7lzyVVm2uMcp jJD/LPP1O8CnXAnuh7rLWGXre6j/ycve6rVyaO93otXVmYt5k4cGRIczMVBSRFBFUlnO UapfGZfRr7otM2TOCZ415wZ4fGJgygr449Yf0z1dF11iXr1wTNIfSGoFv1Eir25rjql1 vjRQ== 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=FTkhBeepRKSAHiYLJq9sHFnd+ItThndsaOmn8W9S0OA=; b=Q/fUtGIafCgF54Lqjeb8oj4PnRlXFmc3xwdeKdp9+dGwK29qAfo6Ba5KgaUiwfjdot 90gnwcPaoivUX9APb396jqdVWDxPEwipDJ3bU9OlIo4JFUD7rsR//52oJDaZy5/fkQpA ZuwpGParryPnyV6ZS+r8GBJRm1yZ+BYL1ymzvlRUAf6Rz0KPkFi1b7zCpp6HLZpFHIOl LpbVHjJwGu5pQfFTH/Mv883zw5IWaf767mv0JzQ1aO2MVc654akVUnyXKFU5OljX0yV2 tqoP7bPme75U9JcL5Wfx58ctD1sljHAxVoYtN3mi5D5wK0Z9y0VxqPhXh36R3IoeHwQn LDdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=e64bH2KC; 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 he8-20020a1709073d8800b00782a5657512si2724569ejc.416.2022.10.27.14.58.15; Thu, 27 Oct 2022 14:58:39 -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=e64bH2KC; 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 S236592AbiJ0Vy5 (ORCPT + 99 others); Thu, 27 Oct 2022 17:54:57 -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 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?1747879638119064991?= X-GMAIL-MSGID: =?utf-8?q?1747879638119064991?= 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,