Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp5864589ioo; Wed, 1 Jun 2022 14:24:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyCTWBI29U9yPzeHOHw04n2tOuocn4V7QpCcLgTllviIdabzjcIF5kvICtF5xEHz7vC+OOh X-Received: by 2002:a17:902:cf0a:b0:156:39c9:4c44 with SMTP id i10-20020a170902cf0a00b0015639c94c44mr1402145plg.124.1654118686477; Wed, 01 Jun 2022 14:24:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654118686; cv=none; d=google.com; s=arc-20160816; b=usQfb3kkyoeubXRg/bfCDk5mEni+rzanP8CPjBBSJe/Dastga8sFvrr4YIzEzskpmH HYm9vSku5l5zpu5ZLofFxTGyoShOlE3NeDNhT7+1Ex1VW4x6pL3NE8u/+/LX3YfrwDl0 dFaKst4A/QWocc9DjTYMEj7X0lDxvsY3p3NcTaOOWFRAT1BVs74dkOQ+1AHuoQN5k9jv nzEw+yvMUVavkH9844QwHbNiaNhZ7LxpTUIgg3s0MCoZ597tqFnJGQRHy17pkdVQgTS9 SavneGLDMPbAI1/VefXRROtrltv3G8v+Oyc86EdQAZZZexzn69Gl3g+5qIdCpZKlVXQr Jd8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=odLqDxATva496jSjcKRA/rnbHyy7zWZmSiqzXhQ90xs=; b=al5USh1UK/fgIVCjXGqA4tfzRdNgBY56YbI9KHO2kAHTwnqLKHvQL8idruvYC40o5Y 66Yqx8mIQLkePRAaz1lqLLEdqm6WUmJLnavPybreJ+GHm9c6PBzonfOOvdNQzMnbas6e E+Woqcau9l8FoF+ET7RSCd9ZZjXYAV6yTweB9s5OWVgewQnvLDcQtC2QSKcibHzLGqkU IlWqGLECkIMjTWBqxlrhf3Ov6gVlvlhl/Q8ALLqtw5XY9vUG0uOIxzGvdMUIbITp0khJ tzgMPe2kRtxi6QbN3Jv5NW7WkfcYqrM9gPh0rUolEJGWS7nnqcA2faxYmPQAR1fIJR0R Pr7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=URfkb99y; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id 18-20020a630e52000000b003c165f24f4csi3334978pgo.593.2022.06.01.14.24.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 14:24:46 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=URfkb99y; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 603453028A7; Wed, 1 Jun 2022 13:15:08 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349538AbiFAD4h (ORCPT + 99 others); Tue, 31 May 2022 23:56:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349534AbiFAD41 (ORCPT ); Tue, 31 May 2022 23:56:27 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8453091570; Tue, 31 May 2022 20:56:26 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 2574FB816D8; Wed, 1 Jun 2022 03:56:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4DEC4C385B8; Wed, 1 Jun 2022 03:56:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1654055783; bh=taaX67TqpbjlALhz00Fz0B4fcS5avMYVJlLFkD5iriU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=URfkb99ysqil4Iu7Ixb6vF+ILdN7TeatdQ1LNZs2vLMIMjUruJvKGEDdaVD63lPad /HHcoD0CYIWc4D9Q66XrEqwv/Yp0Mv8u+WiPo1GcpLdnjo/6xn8nfO6h8RLix8//e/ I0ED8+t6oiFVj1JyOLG6ky2SbppwS+raEVpaGiEgj8zxdl0iuSqu65HwWTAWWsT+U0 unEZD+PL8/mxMZP5VD3mIvd5Aic1YcdhIJoXqxyCmkNylQtcSB/Um+hEHQDQVyIsBT rLFskxn7xfBMCzNkiEjbhhrVRpQ+EIXrR3yk1rFJ8TqKmHKpzmyzfNiLbfvnVcuKko sFTApKwks6M1A== Date: Tue, 31 May 2022 20:56:22 -0700 From: Jakub Kicinski To: Piyush Malgujar Cc: , , , , , , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Paolo Abeni Subject: Re: [PATCH v2 3/3] net: mdio: mdio-thunder: support for clock-freq attribute Message-ID: <20220531205622.71475964@kernel.org> In-Reply-To: <20220530125329.30717-4-pmalgujar@marvell.com> References: <20220530125329.30717-1-pmalgujar@marvell.com> <20220530125329.30717-4-pmalgujar@marvell.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 On Mon, 30 May 2022 05:53:28 -0700 Piyush Malgujar wrote: > +static inline u32 clk_freq(u32 phase) > +{ > + return (100000000U / (2 * (phase))); > +} > + > +static inline u32 calc_sample(u32 phase) Please drop the inline keyword, the compiler will inline this anyway and static inline prevents unused code warnings. > +{ > + return (2 * (phase) - 3); No need to wrap arguments to a static inline in brackets. > +} > + > +static u32 _config_clk(u32 req_freq, u32 *phase, u32 *sample) > +{ > + unsigned int p; > + u32 freq = 0, freq_prev; It's customary in networking to order variable decl lines longest to shortest. > + for (p = PHASE_MIN; p < PHASE_DFLT; p++) { > + freq_prev = freq; > + freq = clk_freq(p); > + > + if (req_freq >= freq) > + break; > + } > + > + if (p == PHASE_DFLT) > + freq = clk_freq(PHASE_DFLT); > + > + if (p == PHASE_MIN || p == PHASE_DFLT) > + goto out; > + > + /* Check which clock value from the identified range > + * is closer to the requested value > + */ > + if ((freq_prev - req_freq) < (req_freq - freq)) { No need for brackets around the arithmetic, assume basic operator precedence is not broken in the compiler...