Skip to content

Commit af7651e

Browse files
Codrin Ciubotariubebarino
authored andcommitted
clk: at91: clk-generated: Limit the requested rate to our range
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: df70aee ("clk: at91: add generated clock driver") Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@microchip.com> Link: https://lore.kernel.org/r/20210707131213.3283509-1-codrin.ciubotariu@microchip.com Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com> Signed-off-by: Stephen Boyd <sboyd@kernel.org>
1 parent e73f0f0 commit af7651e

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

drivers/clk/at91/clk-generated.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,12 @@ static int clk_generated_determine_rate(struct clk_hw *hw,
128128
int i;
129129
u32 div;
130130

131+
/* do not look for a rate that is outside of our range */
132+
if (gck->range.max && req->rate > gck->range.max)
133+
req->rate = gck->range.max;
134+
if (gck->range.min && req->rate < gck->range.min)
135+
req->rate = gck->range.min;
136+
131137
for (i = 0; i < clk_hw_get_num_parents(hw); i++) {
132138
if (gck->chg_pid == i)
133139
continue;

0 commit comments

Comments
 (0)