Skip to content

Commit

Permalink
avr32: favr-32: clk_round_rate() can return a zero upon error
Browse files Browse the repository at this point in the history
Treat both negative and zero return values from clk_round_rate() as
errors.  This is needed since subsequent patches will convert
clk_round_rate()'s return value to be an unsigned type, rather than a
signed type, since some clock sources can generate rates higher than
(2^31)-1 Hz.

Eventually, when calling clk_round_rate(), only a return value of zero
will be considered a error.  All other values will be considered valid
rates.  The comparison against values less than 0 is kept to preserve
the correct behavior in the meantime.

Signed-off-by: Paul Walmsley <paul@pwsan.com>
Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
Cc: Håvard Skinnemoen <hskinnemoen@gmail.com>
Cc: Hans-Christian Egtvedt <egtvedt@samfundet.no>
Cc: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Acked-by: Hans-Christian Egtvedt <egtvedt@samfundet.no>
  • Loading branch information
Paul Walmsley authored and Hans-Christian Egtvedt committed Dec 10, 2013
1 parent 7155530 commit 464b500
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion arch/avr32/boards/favr-32/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,10 @@ static int __init set_abdac_rate(struct platform_device *pdev)
*/
retval = clk_round_rate(pll1,
CONFIG_BOARD_FAVR32_ABDAC_RATE * 256 * 16);
if (retval < 0)
if (retval <= 0) {
retval = -EINVAL;
goto out_abdac;
}

retval = clk_set_rate(pll1, retval);
if (retval != 0)
Expand Down

0 comments on commit 464b500

Please sign in to comment.