clk: k210: Fix checking if ulongs are less than 0
authorSean Anderson <seanga2@gmail.com>
Sat, 11 Sep 2021 17:20:00 +0000 (13:20 -0400)
committerLeo Yu-Chi Liang <ycliang@andestech.com>
Thu, 7 Oct 2021 08:08:22 +0000 (16:08 +0800)
commit54d5d2d56bb6c46c996a4d249dbae3b12a7a4fac
tree245646fa525ae5f488fac6e32653697aee35e72b
parentea67f467a43e4c8852bd1ce1bb75f5dc6c3788d1
clk: k210: Fix checking if ulongs are less than 0

The PLL functions take ulong arguments for rate, but still check if that
rate is negative (which is never true). The correct way to handle this is
to use IS_ERR_VALUE (like is already done in k210_clk_set_rate). While
we're at it, we can move the error checking up into the caller of the pll
set/get rate functions.  This also protects our other calculations from
using bogus values for rate.

Fixes: 609bd60b94 ("clk: k210: Rewrite to remove CCF")
Reported-by: Coverity Scan <scan-admin@coverity.com>
Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>
drivers/clk/clk_kendryte.c