[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <7586cf33-078a-cb85-98c8-9969baa0f19d@microchip.com>
Date: Fri, 9 Jul 2021 11:21:29 +0200
From: Nicolas Ferre <nicolas.ferre@...rochip.com>
To: Codrin Ciubotariu <codrin.ciubotariu@...rochip.com>,
<linux-clk@...r.kernel.org>,
<linux-arm-kernel@...ts.infradead.org>,
<linux-kernel@...r.kernel.org>
CC: <mturquette@...libre.com>, <sboyd@...nel.org>,
<alexandre.belloni@...tlin.com>, <ludovic.desroches@...rochip.com>,
<claudiu.beznea@...rochip.com>
Subject: Re: [PATCH] clk: at91: clk-generated: Limit the requested rate to our
range
On 07/07/2021 at 15:12, Codrin Ciubotariu wrote:
> 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.
Isn't it saner for the user to return an error code instead of
automatically restrain the dynamics requested without notice?
Can you elaborate the use case where returning an error is not convenient?
Regards,
Nicolas
> Fixes: df70aeef6083 ("clk: at91: add generated clock driver")
> Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@...rochip.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;
>
--
Nicolas Ferre
Powered by blists - more mailing lists