From: Codrin Ciubotariu <codrin.ciubotariu@microchip.com> To: <linux-clk@vger.kernel.org>, <linux-arm-kernel@lists.infradead.org>, <linux-kernel@vger.kernel.org> Cc: <mturquette@baylibre.com>, <sboyd@kernel.org>, <nicolas.ferre@microchip.com>, <alexandre.belloni@bootlin.com>, <claudiu.beznea@microchip.com>, Codrin Ciubotariu <codrin.ciubotariu@microchip.com> Subject: [PATCH] clk: at91: generated: consider range when calculating best rate Date: Wed, 13 Apr 2022 10:13:18 +0300 [thread overview] Message-ID: <20220413071318.244912-1-codrin.ciubotariu@microchip.com> (raw) clk_generated_best_diff() helps in finding the parent and the divisor to compute a rate closest to the required one. However, it doesn't take into account the request's range for the new rate. Make sure the new rate is within the required range. Fixes: 8a8f4bf0c480 ("clk: at91: clk-generated: create function to find best_diff") Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@microchip.com> --- drivers/clk/at91/clk-generated.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/clk/at91/clk-generated.c b/drivers/clk/at91/clk-generated.c index 23cc8297ec4c..d429ba52a719 100644 --- a/drivers/clk/at91/clk-generated.c +++ b/drivers/clk/at91/clk-generated.c @@ -117,6 +117,10 @@ static void clk_generated_best_diff(struct clk_rate_request *req, tmp_rate = parent_rate; else tmp_rate = parent_rate / div; + + if (tmp_rate < req->min_rate || tmp_rate > req->max_rate) + return; + tmp_diff = abs(req->rate - tmp_rate); if (*best_diff < 0 || *best_diff >= tmp_diff) { -- 2.32.0
WARNING: multiple messages have this Message-ID (diff)
From: Codrin Ciubotariu <codrin.ciubotariu@microchip.com> To: <linux-clk@vger.kernel.org>, <linux-arm-kernel@lists.infradead.org>, <linux-kernel@vger.kernel.org> Cc: alexandre.belloni@bootlin.com, sboyd@kernel.org, mturquette@baylibre.com, Codrin Ciubotariu <codrin.ciubotariu@microchip.com>, claudiu.beznea@microchip.com Subject: [PATCH] clk: at91: generated: consider range when calculating best rate Date: Wed, 13 Apr 2022 10:13:18 +0300 [thread overview] Message-ID: <20220413071318.244912-1-codrin.ciubotariu@microchip.com> (raw) clk_generated_best_diff() helps in finding the parent and the divisor to compute a rate closest to the required one. However, it doesn't take into account the request's range for the new rate. Make sure the new rate is within the required range. Fixes: 8a8f4bf0c480 ("clk: at91: clk-generated: create function to find best_diff") Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@microchip.com> --- drivers/clk/at91/clk-generated.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/clk/at91/clk-generated.c b/drivers/clk/at91/clk-generated.c index 23cc8297ec4c..d429ba52a719 100644 --- a/drivers/clk/at91/clk-generated.c +++ b/drivers/clk/at91/clk-generated.c @@ -117,6 +117,10 @@ static void clk_generated_best_diff(struct clk_rate_request *req, tmp_rate = parent_rate; else tmp_rate = parent_rate / div; + + if (tmp_rate < req->min_rate || tmp_rate > req->max_rate) + return; + tmp_diff = abs(req->rate - tmp_rate); if (*best_diff < 0 || *best_diff >= tmp_diff) { -- 2.32.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next reply other threads:[~2022-04-13 7:13 UTC|newest] Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-04-13 7:13 Codrin Ciubotariu [this message] 2022-04-13 7:13 ` [PATCH] clk: at91: generated: consider range when calculating best rate Codrin Ciubotariu 2022-04-13 7:54 ` Claudiu.Beznea 2022-04-13 7:54 ` Claudiu.Beznea 2022-04-22 1:12 ` Stephen Boyd 2022-04-22 1:12 ` Stephen Boyd 2022-04-26 7:24 ` Codrin.Ciubotariu 2022-04-26 7:24 ` Codrin.Ciubotariu 2022-05-17 7:14 ` Stephen Boyd 2022-05-17 7:14 ` Stephen Boyd 2022-05-17 8:04 ` Codrin.Ciubotariu 2022-05-17 8:04 ` Codrin.Ciubotariu 2022-05-17 19:41 ` Stephen Boyd 2022-05-17 19:41 ` Stephen Boyd
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=20220413071318.244912-1-codrin.ciubotariu@microchip.com \ --to=codrin.ciubotariu@microchip.com \ --cc=alexandre.belloni@bootlin.com \ --cc=claudiu.beznea@microchip.com \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-clk@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=mturquette@baylibre.com \ --cc=nicolas.ferre@microchip.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: linkBe 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.