k210: fix k210_pll_calc_config()
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Sun, 16 Oct 2022 16:12:32 +0000 (18:12 +0200)
committerLeo Yu-Chi Liang <ycliang@andestech.com>
Thu, 20 Oct 2022 07:22:30 +0000 (15:22 +0800)
commite77ef0bb74c0df010e83a1f60a1c3004f00703da
treec21dde9a5eb8152738f7d9da8e6935f706e5aee1
parente67f34f778baabd76f2e0e645a409fed14d2d156
k210: fix k210_pll_calc_config()

The k210 driver is selected by sandbox_defconfig.
Building the sandbox on 32bit systems fails with:

test/dm/k210_pll.c: In function ‘dm_test_k210_pll_calc_config’:
include/linux/bitops.h:11:38: warning:
left shift count >= width of type [-Wshift-count-overflow]
   11 | #define BIT(nr)         (1UL << (nr))
      |                              ^~
test/dm/k210_pll.c:36:54: note: in expansion of macro ‘BIT’
   36 |                         error = abs((error - BIT(32))) >> 16;
      |                                              ^~~

Use the BIT_ULL() macro to create a u64 value.
Replace abs() by abs64() to get correct results on 32bit system
Apply the same for the unit test.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Sean Anderson <seanga2@gmail.com>
drivers/clk/clk_k210.c
test/dm/k210_pll.c