Received: by 2002:a05:6358:795:b0:dc:4c66:fc3e with SMTP id n21csp362785rwj; Sat, 29 Oct 2022 04:29:56 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6Q7v5DZkOnfjJTB6NquPkSo/MwolTH8SkL8HbXktT7tv4F15CHLtgmjxv8ZwBTF0w30fMY X-Received: by 2002:a05:6402:2751:b0:443:d90a:43d4 with SMTP id z17-20020a056402275100b00443d90a43d4mr4025243edd.368.1667042996386; Sat, 29 Oct 2022 04:29:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667042996; cv=none; d=google.com; s=arc-20160816; b=hgttiRlxJkukBe9kJA9pjZM2FC6yj+R8XB0AIshLCfhbFadJafIUXyT5aBpG6hjxkF PJxPNs6s45uv3QgKSFFkmpY4BOfFYDIcAHyeMI31covN+DrUfljbrm8w/pUeN5MAJi6X 8K6wjYXEgU5E4QkK/Th0a2vI4BIUgboeUbEyFsD6Vjk3hc6MyRbvtKcCaciLcS/3827I 9lxVm32lz84WYSvSImqKeZT9QmiAdAPDha4X0lCAQMJPjNv8X1g4roFRYB6QRq2ybPKw rRSUCjn8iy6MCYNpMtR7cxu2JtX+b70KIAHMGSOCGo/Svqog4wHI57NKnWAfFwKaHJyX B1iA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :mime-version:accept-language:in-reply-to:references:message-id:date :thread-index:thread-topic:subject:to:from; bh=DADn/7SVa19oMfAZFiedxHrruzJI7+zwWkvhkjQOxhQ=; b=vJHNTJ0kcMIy98wAlivRQRt1+2gZBXrdddob7CSu/dTbV1+QfACU3RpNChmWYM2CJP TGJY5QXKe/QP6k5Re2LwfeePvD0iVD8gjw1F1N7Fxp+oNA7dOgUpSoboZ7lOMIopznfG dSUA2mNxVtHgS4R41OZ8TUFzphLCus6TQynfE1oejLQSX1ebIPBXYESh3dE3Qc10BmtY 6wuuppfpVKpHN6tI7mg9+s7zXdC4n+hkbguaQCl5Xp51qp/kMaT7ftDENd2HrOpOnCEY yINcsbPA3375a46YGkQcJBJOu24V8d/tV8oxZDILiDsRSd6FNYkU9wRbuLYqPEwux3Cd pK8g== ARC-Authentication-Results: i=1; mx.google.com; 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=aculab.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cs19-20020a170906dc9300b0078372cf516csi1701221ejc.229.2022.10.29.04.29.31; Sat, 29 Oct 2022 04:29:56 -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; 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=aculab.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229610AbiJ2LXM convert rfc822-to-8bit (ORCPT + 99 others); Sat, 29 Oct 2022 07:23:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229441AbiJ2LXL (ORCPT ); Sat, 29 Oct 2022 07:23:11 -0400 Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.85.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F418CD2EC for ; Sat, 29 Oct 2022 04:23:09 -0700 (PDT) Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mtapsc-2-oskDvvDuMcG4CvHtLEYEfA-1; Sat, 29 Oct 2022 12:23:07 +0100 X-MC-Unique: oskDvvDuMcG4CvHtLEYEfA-1 Received: from AcuMS.Aculab.com (10.202.163.6) by AcuMS.aculab.com (10.202.163.6) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Sat, 29 Oct 2022 12:23:06 +0100 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.042; Sat, 29 Oct 2022 12:23:06 +0100 From: David Laight To: "'Sa, Nuno'" , Deepak R Varma , "outreachy@lists.linux.dev" , Lars-Peter Clausen , "Hennerich, Michael" , Jonathan Cameron , Greg Kroah-Hartman , "linux-iio@vger.kernel.org" , "linux-staging@lists.linux.dev" , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH] staging: iio: ad5933: Use div64_ul instead of do_div Thread-Topic: [PATCH] staging: iio: ad5933: Use div64_ul instead of do_div Thread-Index: AQHY6ks4nrCWT2KFn0+DLX/dNrKI2K4jloMggAGkz5A= Date: Sat, 29 Oct 2022 11:23:06 +0000 Message-ID: <5740bcb3490d4c17bd9bc731e79b174b@AcuMS.aculab.com> References: In-Reply-To: Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, 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 > > -----Original Message----- > > From: Deepak R Varma > > > > [External] > > > > 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. These changes should all get nacked unless the domain of the values can be shown to be out of range. The entire point of do_div() is that because division is expensive using a limited range division is significantly faster. Even on Intel 64 bit cpu the 64 by 32 divide is significantly faster then a full 64 bit divide for the same input values. One might also question why the divisor is actually 'unsigned long' at all. The code is almost certainly expected to compile for 32bit so the domain of the value should fit in 32 bits. So either the type could be unsigned int, or it really doesn't matter that the value is truncated to 32bit because it can never be larger. David > > > > Signed-off-by: Deepak R Varma > > --- > > Reviewed-by: Nuno Sá - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)