Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp2947932rwo; Mon, 24 Jul 2023 04:06:52 -0700 (PDT) X-Google-Smtp-Source: APBJJlECo35si8VsGC0Ils3qyziVZDtPd7dnw6IXbPElo41Gy98Kb1fvWXesbZlUkfPgq+yndE1x X-Received: by 2002:aa7:d90b:0:b0:522:2ada:c207 with SMTP id a11-20020aa7d90b000000b005222adac207mr2826930edr.34.1690196812363; Mon, 24 Jul 2023 04:06:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690196812; cv=none; d=google.com; s=arc-20160816; b=v5Rzvp246NCz6NNoNZziBpAFY79libGBgYochx/MCvKFbcIh9s6XyPOSDrha/Rx3zf 4z2fHw84AHuHQz2WjxTQ/TNnhlYAJ1kGTvhAk3BdZQ1WrYWL5BMLTBQsaZD6JJAI4Kx6 hl2fecsLrLbBxs15PbEnL/uEgqY64QMoUGUT9VzILxDxqDLePHjo5xwkgR0/axEnHvIg +BAqTKwTgyXMaI1uOK0JTC5ALvs/DET/DaNbGC5uu8YCF+zKispSg99ICU1i6XCazXa/ slsYUFOHWuW1RAuYrGlwLcmo6v2q3Eb6JdOoT30yj5DbaKr7DR3GPehaLCWwgBFHLlv0 sEYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=1Z+KuJXIZIEdepzvcrKhbKy6hp5E9cBIl84AkwWPkOo=; fh=MhhPrl49ywdxjQkIqGIio3Uqt7QOPeLqNMiJ9GTu9XA=; b=msBKDzLJa82IG6lHanfnSkAn7K4bbpFyzmsZk+5OLOg9cnqSHgtNN5zWGDyIUVWba4 lwnt5Ed6XOObL/wmHWtETDTSDtE2pOtoZ0gppyRfZbsTBKfiMGMqv/Gw1XNcn6RSHFF7 IG7IDVBFi1EXv8iqGzc5+mm5p9U8mMyYqryxZrNKnw0o2x/ruU/ls5SLhriJY0RXvuMI zHEIMdANYyakgPN1UqJI9aKigiQXka/yFZP4woRrsRb8BYTBJewFbF2pqKyFSG/WfNen sinOUOz+eC7F/kg43byWRu/rUSLwv5VrCNOme7Nsa8RMHE3Y0lqWj0MEvu8HkByrc/2A g3sw== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ay19-20020a056402203300b005222fd51562si1041197edb.69.2023.07.24.04.06.27; Mon, 24 Jul 2023 04:06:52 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233050AbjGXKNy convert rfc822-to-8bit (ORCPT + 99 others); Mon, 24 Jul 2023 06:13:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231779AbjGXKMj (ORCPT ); Mon, 24 Jul 2023 06:12:39 -0400 Received: from mail-yw1-f179.google.com (mail-yw1-f179.google.com [209.85.128.179]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B927C7D95; Mon, 24 Jul 2023 03:05:21 -0700 (PDT) Received: by mail-yw1-f179.google.com with SMTP id 00721157ae682-583b47809beso18621987b3.0; Mon, 24 Jul 2023 03:05:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690193072; x=1690797872; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kdime7qoPODmAiTa2PQFmD+bM1Qwuzb0rIVovoauwF0=; b=fOSxzlFxA8X1afGtT6G8mBinIkhtcXZ+ydmi/uDK1njapdH4XqDiQQUtdFb36fAxbn NUTVh6XaQTZ4x6sbP57YY4cj5m//mf4S4otpzAdP+Womumod5kKGZ/xL4XiA/kMIgGXb F8sKfHmdRshJp3m3kZo4hnS8naix4hjFYQRjlzgMWUpkAZN/CJ/HV1WYnJOofT0UX45/ Jk7xqQOU/bYhGSc2VXbU1GpTd6QDuTTnargJsbsEh1fkE2LA8LOLsPGNAqmDZW1Zf5/f C6TBm2W2/Y4kpQm4iw3XUvZihLM9QadR1BpBewCqpZQxEhdTfuWZbRHXXh3Th5hkIvQ+ t8Tg== X-Gm-Message-State: ABy/qLa75hRE4JKil0dpOKlCLCGg86Rk4fR396ZYf/d1o6Jg1FmizJac vkhgcry9nqGsJ6jEo9ZX95lrrHP8JpEnEg== X-Received: by 2002:a81:4e82:0:b0:56d:502:43d4 with SMTP id c124-20020a814e82000000b0056d050243d4mr5491485ywb.11.1690193072404; Mon, 24 Jul 2023 03:04:32 -0700 (PDT) Received: from mail-yw1-f175.google.com (mail-yw1-f175.google.com. [209.85.128.175]) by smtp.gmail.com with ESMTPSA id v14-20020a81a54e000000b005773430a57csm2654030ywg.78.2023.07.24.03.04.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 24 Jul 2023 03:04:32 -0700 (PDT) Received: by mail-yw1-f175.google.com with SMTP id 00721157ae682-5703cb4bcb4so46818587b3.3; Mon, 24 Jul 2023 03:04:32 -0700 (PDT) X-Received: by 2002:a5b:a8b:0:b0:cfd:1bb9:e356 with SMTP id h11-20020a5b0a8b000000b00cfd1bb9e356mr6248370ybq.32.1690193071935; Mon, 24 Jul 2023 03:04:31 -0700 (PDT) MIME-Version: 1.0 References: <20230612033904.34921-1-zhanglibing@cdjrlc.com> <0dc9409b662180ed29cbc281f0f076b7@208suo.com> In-Reply-To: From: Geert Uytterhoeven Date: Mon, 24 Jul 2023 12:04:19 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] clk: baikal-t1: Using div64_ Ul replaces do_ Div() function To: wuyonggang001@208suo.com Cc: mturquette@baylibre.com, sboyd@kernel.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Serge Semin Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, 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 Hi Yonggang, CC Serge On Wed, Jun 14, 2023 at 8:07 AM wrote: > Fix the following coccicheck warning: > > drivers/clk/baikal-t1/ccu-pll.c:81:1-7: WARNING: do_div() does a > 64-by-32 division, please consider using div64_ul instead. > > Signed-off-by: Yonggang Wu Thanks for your patch, which is now commit b93d1331ea266dea ("clk: baikal-t1: Using div64_ Ul replaces do_ Div() function") in clk/clk-next. > b/drivers/clk/baikal-t1/ccu-pll.c > index 13ef28001439..d41735c6956a 100644 > --- a/drivers/clk/baikal-t1/ccu-pll.c > +++ b/drivers/clk/baikal-t1/ccu-pll.c > @@ -66,7 +66,7 @@ static inline unsigned long > ccu_pll_lock_delay_us(unsigned long ref_clk, > { > u64 us = 500ULL * nr * USEC_PER_SEC; > > - do_div(us, ref_clk); > + div64_ul(us, ref_clk); The above is not equivalent: - do_div() returned the quotient as an output parameter in us, - div64_ul() returns the quotient using the return value. Have you tested your patch? > > return us; So this should become: return div64_ul(500ULL * nr * USEC_PER_SEC, ref_clk); > } > @@ -78,9 +78,9 @@ static inline unsigned long ccu_pll_calc_freq(unsigned > long ref_clk, > { > u64 tmp = ref_clk; > > - do_div(tmp, nr); > + div64_ul(tmp, nr); > tmp *= nf; > - do_div(tmp, od); > + div64_ul(tmp, od); > > return tmp; Likewise. But as ref_clk is unsigned long, there is no need to use div64_ul() for the first division, and this can be simplified to: u64 tmp = (u64)(ref_clk / nr) * nf; return div64_ul(tmp, od); To avoid loss of precision, it might be better to reverse the order of the division and multiplication: u64 tmp = (u64)ref_clk * nf / nr; But doing that requires intimate knowledge about the range of nf to avoid overflow, so I leave that to Serge. > } Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds