From: Jakub Kicinski <kuba@kernel.org>
To: Piyush Malgujar <pmalgujar@marvell.com>
Cc: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<krzysztof.kozlowski+dt@linaro.org>, <devicetree@vger.kernel.org>,
<cchavva@marvell.com>, <deppel@marvell.com>,
Andrew Lunn <andrew@lunn.ch>,
Heiner Kallweit <hkallweit1@gmail.com>,
Russell King <linux@armlinux.org.uk>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Paolo Abeni <pabeni@redhat.com>
Subject: Re: [PATCH v2 3/3] net: mdio: mdio-thunder: support for clock-freq attribute
Date: Tue, 31 May 2022 20:56:22 -0700 [thread overview]
Message-ID: <20220531205622.71475964@kernel.org> (raw)
In-Reply-To: <20220530125329.30717-4-pmalgujar@marvell.com>
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...
next prev parent reply other threads:[~2022-06-01 3:56 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-30 12:53 [PATCH v2 0/3] net: mdio: mdio-thunder: MDIO clock related changes for Marvell Octeon Family Piyush Malgujar
2022-05-30 12:53 ` [PATCH v2 1/3] net: mdio: mdio-thunder: stop toggling SMI clock on idle Piyush Malgujar
2022-05-30 12:53 ` [PATCH v2 2/3] dt-bindings: net: cavium-mdio.txt: add clock-frequency attribute Piyush Malgujar
2022-06-02 15:07 ` Rob Herring
2022-06-05 14:59 ` Andrew Lunn
2022-05-30 12:53 ` [PATCH v2 3/3] net: mdio: mdio-thunder: support for clock-freq attribute Piyush Malgujar
2022-06-01 3:56 ` Jakub Kicinski [this message]
2022-06-05 3:24 ` Andrew Lunn
2022-06-01 3:54 ` [PATCH v2 0/3] net: mdio: mdio-thunder: MDIO clock related changes for Marvell Octeon Family Jakub Kicinski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220531205622.71475964@kernel.org \
--to=kuba@kernel.org \
--cc=andrew@lunn.ch \
--cc=cchavva@marvell.com \
--cc=davem@davemloft.net \
--cc=deppel@marvell.com \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pmalgujar@marvell.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.