Commit 5aefa34f authored by Paul Mundt's avatar Paul Mundt

sh: clkfwk: Fix up rate rounding error handling.

According to the linux/clk.h definition we should be handing back an
errno value or a valid rate. This fixes up the case where 0 can be
returned for invalid frequencies or cases where rounding has no
selectable candidate.
Reported-by: default avatarGuennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: default avatarPaul Mundt <lethal@linux-sh.org>
parent 3985c7ce
...@@ -90,8 +90,8 @@ struct clk_rate_round_data { ...@@ -90,8 +90,8 @@ struct clk_rate_round_data {
static long clk_rate_round_helper(struct clk_rate_round_data *rounder) static long clk_rate_round_helper(struct clk_rate_round_data *rounder)
{ {
unsigned long rate_error, rate_error_prev = ~0UL; unsigned long rate_error, rate_error_prev = ~0UL;
unsigned long rate_best_fit = rounder->rate;
unsigned long highest, lowest, freq; unsigned long highest, lowest, freq;
long rate_best_fit = -ENOENT;
int i; int i;
highest = 0; highest = 0;
...@@ -146,7 +146,7 @@ long clk_rate_table_round(struct clk *clk, ...@@ -146,7 +146,7 @@ long clk_rate_table_round(struct clk *clk,
}; };
if (clk->nr_freqs < 1) if (clk->nr_freqs < 1)
return 0; return -ENOSYS;
return clk_rate_round_helper(&table_round); return clk_rate_round_helper(&table_round);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment