Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp2298038pxb; Wed, 9 Feb 2022 15:30:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJwZ4sbAUin6YuF/azDf2Dja8vHDuIcbDGQ6XtEvvxXW+jPoStzOLdWjjrh2ZL4JWOYeFjrZ X-Received: by 2002:a63:8842:: with SMTP id l63mr3812235pgd.421.1644449443510; Wed, 09 Feb 2022 15:30:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644449443; cv=none; d=google.com; s=arc-20160816; b=H5HFzeQsccsv27gbmMuH6NFgxxT93RDLbqmif8ZJCVsr29uJWQ+KNxUacqqj9SpBTq M7PFXyZDzSAYBrdUp9UaixC0Jx0Z31w8GhSHaTtej2JWcfE/YCLMGg6LR2qVuvndLAG0 MdapUBPX++Yt2WpBcVNR0NfJdbRezyPzSBYC1i9KHUJofc9+DNSjbUOL1Kol4HIOZ2Co 0LiLszMrSZJ2AhIsE/fg9q9PQZsDfsWkqJH8Ej52oUeh6iRm6ZrK+yWU2c13S8UI2VGH w1UWN1uWRuS/90Eo55CYkeOPjJ4uRtm3bsdcCEFnuavUTVTuPKa+zwIFHOV5Ws6fk8KB vhgA== 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=gasrNC1GGUawcKbNsQEDWsyYPD2Z7lSCNqbmphZQfJE=; b=eX9dw691BrvlZly4cQmgkrzkKzHGJKFqG1eTPP55ux4Q8bpc0Hb6fazwMqIXArbkpN KagSD5t18RtcTlxmdkhu8VVw61x0sksALpELWccs9ct97UsoAmV0mDyAZ1HDhjpq9nmc 4SSCyKLvejhPN1pudpF1wVZz93G3RUEmu+7bzoGYy4C+LnYKHnQMGqKA3p9LLeVw18lw SNiD1BcpwYmz2ljD270ue5jcnF07Hlrp7EhQPPaP13G9w8FwD0lCnsws6DjmJEzXC4P6 7DT2JHjqqRb7Vo686z4XPgCdHcBgwPuWy69V5XC50y/toPhOXyTTH7HddRu+SZ5HkLm8 tX1w== 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:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id a72si431057pge.419.2022.02.09.15.30.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 15:30:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C917CE074884; Wed, 9 Feb 2022 15:21:35 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235340AbiBIWVp convert rfc822-to-8bit (ORCPT + 99 others); Wed, 9 Feb 2022 17:21:45 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:49660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235335AbiBIWVi (ORCPT ); Wed, 9 Feb 2022 17:21:38 -0500 Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.85.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8BCF1C0F8699 for ; Wed, 9 Feb 2022 14:21:40 -0800 (PST) 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-mta-66-G1dgHlBaNBupzuHAnSEDBA-1; Wed, 09 Feb 2022 22:21:37 +0000 X-MC-Unique: G1dgHlBaNBupzuHAnSEDBA-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) by AcuMS.aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) with Microsoft SMTP Server (TLS) id 15.0.1497.28; Wed, 9 Feb 2022 22:21:36 +0000 Received: from AcuMS.Aculab.com ([fe80::994c:f5c2:35d6:9b65]) by AcuMS.aculab.com ([fe80::994c:f5c2:35d6:9b65%12]) with mapi id 15.00.1497.028; Wed, 9 Feb 2022 22:21:35 +0000 From: David Laight To: 'Qing Wang' , Abel Vesa , "Michael Turquette" , Stephen Boyd , "Shawn Guo" , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , "linux-clk@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH] clk: imx: use div64_u64() instead of do_div() Thread-Topic: [PATCH] clk: imx: use div64_u64() instead of do_div() Thread-Index: AQHYHZBjXPxrJKPUzEuGCK2WjoSvgayLy2mg Date: Wed, 9 Feb 2022 22:21:35 +0000 Message-ID: <4f0336b0217f4e7fa9a1a7aa044ee4fe@AcuMS.aculab.com> References: <1644395819-3791-1-git-send-email-wangqing@vivo.com> In-Reply-To: <1644395819-3791-1-git-send-email-wangqing@vivo.com> 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 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=C51A453 smtp.mailfrom=david.laight@aculab.com 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, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 From: Qing Wang > Sent: 09 February 2022 08:37 > > From: Wang Qing > > do_div() does a 64-by-32 division. > When the divisor is u64, do_div() truncates it to 32 bits, this means it > can test non-zero and be truncated to zero for division. What is the domain of parent_rate? Unless it can exceed 2^32 do_div() is correct. Ignore checkpatch. > > fix do_div.cocci warning: > WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead. > > Signed-off-by: Wang Qing > --- > drivers/clk/imx/clk-frac-pll.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/clk/imx/clk-frac-pll.c b/drivers/clk/imx/clk-frac-pll.c > index c703056..90b25e3 > --- a/drivers/clk/imx/clk-frac-pll.c > +++ b/drivers/clk/imx/clk-frac-pll.c > @@ -129,11 +129,11 @@ static long clk_pll_round_rate(struct clk_hw *hw, unsigned long rate, > parent_rate *= 8; > rate *= 2; > temp64 = rate; > - do_div(temp64, parent_rate); > + div64_u64(temp64, parent_rate); > divfi = temp64; > temp64 = rate - divfi * parent_rate; > temp64 *= PLL_FRAC_DENOM; > - do_div(temp64, parent_rate); > + div64_u64(temp64, parent_rate); > divff = temp64; > > temp64 = parent_rate; > -- > 2.7.4 - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)