From: Paul Walmsley Date: Tue, 10 Dec 2013 02:35:24 +0000 (-0800) Subject: avr32: favr-32: clk_round_rate() can return a zero upon error X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=464b500e37a588be69ed9c9c21bca62a578ca66c;p=GitHub%2FLineageOS%2FG12%2Fandroid_kernel_amlogic_linux-4.9.git avr32: favr-32: clk_round_rate() can return a zero upon error 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 Cc: Nicolas Ferre Cc: HÃ¥vard Skinnemoen Cc: Hans-Christian Egtvedt Cc: Jean-Christophe PLAGNIOL-VILLARD Acked-by: Hans-Christian Egtvedt --- diff --git a/arch/avr32/boards/favr-32/setup.c b/arch/avr32/boards/favr-32/setup.c index 7b1f2cd85400..1f121497b517 100644 --- a/arch/avr32/boards/favr-32/setup.c +++ b/arch/avr32/boards/favr-32/setup.c @@ -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)