[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220531205622.71475964@kernel.org>
Date: Tue, 31 May 2022 20:56:22 -0700
From: Jakub Kicinski <kuba@...nel.org>
To: Piyush Malgujar <pmalgujar@...vell.com>
Cc: <netdev@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<krzysztof.kozlowski+dt@...aro.org>, <devicetree@...r.kernel.org>,
<cchavva@...vell.com>, <deppel@...vell.com>,
Andrew Lunn <andrew@...n.ch>,
Heiner Kallweit <hkallweit1@...il.com>,
Russell King <linux@...linux.org.uk>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Paolo Abeni <pabeni@...hat.com>
Subject: Re: [PATCH v2 3/3] net: mdio: mdio-thunder: support for clock-freq
attribute
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...
Powered by blists - more mailing lists