From 2751d2922f7c87a6acf901a0008ac131bf7245db Mon Sep 17 00:00:00 2001 From: Yidi Lin Date: Tue, 31 Oct 2023 17:15:50 +0800 Subject: Use common GCD function Change-Id: I30e4b02a9ca6a15c9bc4edcf4143ffa13a21a732 Signed-off-by: Yidi Lin Reviewed-on: https://review.coreboot.org/c/coreboot/+/78799 Reviewed-by: Yu-Ping Wu Reviewed-by: Julius Werner Tested-by: build bot (Jenkins) Reviewed-by: Eric Lai --- src/drivers/analogix/anx7625/anx7625.c | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/analogix/anx7625/anx7625.c b/src/drivers/analogix/anx7625/anx7625.c index e3a511131f0b..8726ac025482 100644 --- a/src/drivers/analogix/anx7625/anx7625.c +++ b/src/drivers/analogix/anx7625/anx7625.c @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-only */ #include +#include #include #include #include @@ -152,30 +153,14 @@ static int wait_aux_op_finish(uint8_t bus) return 0; } -static unsigned long gcd(unsigned long a, unsigned long b) -{ - if (a == 0) - return b; - - while (b != 0) { - if (a > b) - a = a - b; - else - b = b - a; - } - - return a; -} - /* Reduce fraction a/b */ -static void anx7625_reduction_of_a_fraction(unsigned long *_a, - unsigned long *_b) +static void anx7625_reduction_of_a_fraction(u32 *_a, u32 *_b) { - unsigned long gcd_num; - unsigned long a = *_a, b = *_b, old_a, old_b; + u32 gcd_num; + u32 a = *_a, b = *_b, old_a, old_b; u32 denom = 1; - gcd_num = gcd(a, b); + gcd_num = gcd32(a, b); a /= gcd_num; b /= gcd_num; @@ -198,9 +183,7 @@ static void anx7625_reduction_of_a_fraction(unsigned long *_a, *_b = b; } -static int anx7625_calculate_m_n(u32 pixelclock, - unsigned long *m, unsigned long *n, - uint8_t *pd) +static int anx7625_calculate_m_n(u32 pixelclock, u32 *m, u32 *n, uint8_t *pd) { uint8_t post_divider = *pd; if (pixelclock > PLL_OUT_FREQ_ABS_MAX / POST_DIVIDER_MIN) { @@ -300,7 +283,7 @@ static int anx7625_odfc_config(uint8_t bus, uint8_t post_divider) static int anx7625_dsi_video_config(uint8_t bus, struct display_timing *dt) { - unsigned long m, n; + u32 m, n; u16 htotal; int ret; uint8_t post_divider = 0; @@ -311,7 +294,7 @@ static int anx7625_dsi_video_config(uint8_t bus, struct display_timing *dt) return -1; } - ANXINFO("compute M(%lu), N(%lu), divider(%d).\n", m, n, post_divider); + ANXINFO("compute M(%u), N(%u), divider(%d).\n", m, n, post_divider); /* configure pixel clock */ ret = anx7625_reg_write(bus, RX_P0_ADDR, PIXEL_CLOCK_L, -- cgit v1.2.3