Skip to content

Commit

Permalink
Merge pull request #328 from sifive/use-labs
Browse files Browse the repository at this point in the history
Use labs() to compute abs() of long
  • Loading branch information
nategraff-sifive authored Aug 26, 2020
2 parents f30b32a + 083c7c8 commit 90b4d80
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions src/drivers/sifive_fe310-g000_pll.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,12 +260,7 @@ static int find_closest_config(long ref_hz, long rate) {
i--) {
long config_freq = get_pll_config_freq(ref_hz, &(pll_configs[i]));
if (config_freq != PLL_CONFIG_NOT_VALID) {
long freq_diff;
if (config_freq > rate) {
freq_diff = config_freq - rate;
} else {
freq_diff = rate - config_freq;
}
long freq_diff = labs(config_freq - rate);

if (freq_diff < closest_diff) {
closest_index = i;
Expand Down

0 comments on commit 90b4d80

Please sign in to comment.