From: Jacob Keller <jacob.e.keller@intel.com>
To: Brian Masney <bmasney@redhat.com>,
Nicolas Ferre <nicolas.ferre@microchip.com>,
Claudiu Beznea <claudiu.beznea@tuxon.dev>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
Paul Walmsley <paul.walmsley@sifive.com>,
"Samuel Holland" <samuel.holland@sifive.com>,
Maxime Ripard <mripard@kernel.org>,
Stephen Boyd <sboyd@kernel.org>
Cc: <linux-clk@vger.kernel.org>, <netdev@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <linux-riscv@lists.infradead.org>
Subject: Re: [PATCH] net: cadence: macb: convert from round_rate() to determine_rate()
Date: Wed, 13 Aug 2025 08:29:52 -0700 [thread overview]
Message-ID: <b8eddc78-f9dd-491f-8c4e-98406ad6f8db@intel.com> (raw)
In-Reply-To: <20250810-net-round-rate-v1-1-dbb237c9fe5c@redhat.com>
[-- Attachment #1.1: Type: text/plain, Size: 3472 bytes --]
On 8/10/2025 3:24 PM, Brian Masney wrote:
> The round_rate() clk ops is deprecated, so migrate this driver from
> round_rate() to determine_rate().
>
> Signed-off-by: Brian Masney <bmasney@redhat.com>
> ---
> drivers/net/ethernet/cadence/macb_main.c | 61 ++++++++++++++++++--------------
> 1 file changed, 35 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
> index ce95fad8cedd7331d4818ba9f73fb6970249e85c..ce55a1f59b50dd85fa92bf139d06e6120d109e89 100644
> --- a/drivers/net/ethernet/cadence/macb_main.c
> +++ b/drivers/net/ethernet/cadence/macb_main.c
> @@ -4822,36 +4822,45 @@ static unsigned long fu540_macb_tx_recalc_rate(struct clk_hw *hw,
> return mgmt->rate;
> }
>
> -static long fu540_macb_tx_round_rate(struct clk_hw *hw, unsigned long rate,
> - unsigned long *parent_rate)
> -{
> - if (WARN_ON(rate < 2500000))
> - return 2500000;
> - else if (rate == 2500000)
> - return 2500000;
> - else if (WARN_ON(rate < 13750000))
> - return 2500000;
> - else if (WARN_ON(rate < 25000000))
> - return 25000000;
> - else if (rate == 25000000)
> - return 25000000;
> - else if (WARN_ON(rate < 75000000))
> - return 25000000;
> - else if (WARN_ON(rate < 125000000))
> - return 125000000;
> - else if (rate == 125000000)
> - return 125000000;
> -
> - WARN_ON(rate > 125000000);
> -
> - return 125000000;
> +static int fu540_macb_tx_determine_rate(struct clk_hw *hw,
> + struct clk_rate_request *req)
> +{
> + if (WARN_ON(req->rate < 2500000))
> + req->rate = 2500000;
> + else if (req->rate == 2500000)
> + req->rate = 2500000;
> + else if (WARN_ON(req->rate < 13750000))
> + req->rate = 2500000;
> + else if (WARN_ON(req->rate < 25000000))
> + req->rate = 25000000;
> + else if (req->rate == 25000000)
> + req->rate = 25000000;
> + else if (WARN_ON(req->rate < 75000000))
> + req->rate = 25000000;
> + else if (WARN_ON(req->rate < 125000000))
> + req->rate = 125000000;
> + else if (req->rate == 125000000)
> + req->rate = 125000000;
> + else if (WARN_ON(req->rate > 125000000))
> + req->rate = 125000000;
> + else
> + req->rate = 125000000;
> +
> + return 0;
> }
Quite a big diff for the minimal amount of actual changes. This looks a
bit nicer with --word-diff to show that there's no real functional changes.
>
> static int fu540_macb_tx_set_rate(struct clk_hw *hw, unsigned long rate,
> unsigned long parent_rate)
> {
> - rate = fu540_macb_tx_round_rate(hw, rate, &parent_rate);
> - if (rate != 125000000)
> + struct clk_rate_request req;
> + int ret;
> +
> + clk_hw_init_rate_request(hw, &req, rate);
> + ret = fu540_macb_tx_determine_rate(hw, &req);
> + if (ret != 0)
> + return ret;
> +
> + if (req.rate != 125000000)
> iowrite32(1, mgmt->reg);
> else
> iowrite32(0, mgmt->reg);
> @@ -4862,7 +4871,7 @@ static int fu540_macb_tx_set_rate(struct clk_hw *hw, unsigned long rate,
>
> static const struct clk_ops fu540_c000_ops = {
> .recalc_rate = fu540_macb_tx_recalc_rate,
> - .round_rate = fu540_macb_tx_round_rate,
> + .determine_rate = fu540_macb_tx_determine_rate,
> .set_rate = fu540_macb_tx_set_rate,
> };
>
>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
> ---
> base-commit: 8f5ae30d69d7543eee0d70083daf4de8fe15d585
> change-id: 20250729-net-round-rate-01147feda9af
>
> Best regards,
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]
next prev parent reply other threads:[~2025-08-13 15:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-10 22:24 Brian Masney
2025-08-13 15:29 ` Jacob Keller [this message]
2025-08-14 8:10 ` patchwork-bot+netdevbpf
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=b8eddc78-f9dd-491f-8c4e-98406ad6f8db@intel.com \
--to=jacob.e.keller@intel.com \
--cc=andrew+netdev@lunn.ch \
--cc=bmasney@redhat.com \
--cc=claudiu.beznea@tuxon.dev \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=mripard@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nicolas.ferre@microchip.com \
--cc=pabeni@redhat.com \
--cc=paul.walmsley@sifive.com \
--cc=samuel.holland@sifive.com \
--cc=sboyd@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®