linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] clk: at91: clk-generated: Limit the requested rate to our range
@ 2021-07-07 13:12 Codrin Ciubotariu
  2021-07-09  9:21 ` Nicolas Ferre
  2021-08-29  5:28 ` Stephen Boyd
  0 siblings, 2 replies; 5+ messages in thread
From: Codrin Ciubotariu @ 2021-07-07 13:12 UTC (permalink / raw)
  To: linux-clk, linux-arm-kernel, linux-kernel
  Cc: mturquette, sboyd, nicolas.ferre, alexandre.belloni,
	ludovic.desroches, claudiu.beznea, Codrin Ciubotariu

On clk_generated_determine_rate(), the requested rate could be outside
of clk's range. Limit the rate to the clock's range to not return an
error.

Fixes: df70aeef6083 ("clk: at91: add generated clock driver")
Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@microchip.com>
---
 drivers/clk/at91/clk-generated.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/clk/at91/clk-generated.c b/drivers/clk/at91/clk-generated.c
index b4fc8d71daf2..b656d25a9767 100644
--- a/drivers/clk/at91/clk-generated.c
+++ b/drivers/clk/at91/clk-generated.c
@@ -128,6 +128,12 @@ static int clk_generated_determine_rate(struct clk_hw *hw,
 	int i;
 	u32 div;
 
+	/* do not look for a rate that is outside of our range */
+	if (gck->range.max && req->rate > gck->range.max)
+		req->rate = gck->range.max;
+	if (gck->range.min && req->rate < gck->range.min)
+		req->rate = gck->range.min;
+
 	for (i = 0; i < clk_hw_get_num_parents(hw); i++) {
 		if (gck->chg_pid == i)
 			continue;
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-08-29  5:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-07 13:12 [PATCH] clk: at91: clk-generated: Limit the requested rate to our range Codrin Ciubotariu
2021-07-09  9:21 ` Nicolas Ferre
2021-07-09  9:59   ` Codrin.Ciubotariu
2021-07-16 19:17     ` Nicolas Ferre
2021-08-29  5:28 ` Stephen Boyd

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).