[PATCH] MIPS: ralink: Use min() to simplify code in rt_timer_config()

wangyufei posted 1 patch 3 months, 3 weeks ago
arch/mips/ralink/timer.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
[PATCH] MIPS: ralink: Use min() to simplify code in rt_timer_config()
Posted by wangyufei 3 months, 3 weeks ago
Use min() to simplify rt_timer_config() and improve its readability.

Signed-off-by: wangyufei <wangyufei@vivo.com>
---
 arch/mips/ralink/timer.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/arch/mips/ralink/timer.c b/arch/mips/ralink/timer.c
index 54094f6e0..bbdd0af0b 100644
--- a/arch/mips/ralink/timer.c
+++ b/arch/mips/ralink/timer.c
@@ -75,10 +75,7 @@ static int rt_timer_request(struct rt_timer *rt)
 
 static int rt_timer_config(struct rt_timer *rt, unsigned long divisor)
 {
-	if (rt->timer_freq < divisor)
-		rt->timer_div = rt->timer_freq;
-	else
-		rt->timer_div = divisor;
+	rt->timer_div = min(rt->timer_freq, divisor);
 
 	rt_timer_w32(rt, TIMER_REG_TMR0LOAD, rt->timer_freq / rt->timer_div);
 
-- 
2.39.0
Re: [PATCH] MIPS: ralink: Use min() to simplify code in rt_timer_config()
Posted by Sergio Paracuellos 3 months, 3 weeks ago
Hi,

On Wed, Jun 18, 2025 at 2:21 PM wangyufei <wangyufei@vivo.com> wrote:
>
> Use min() to simplify rt_timer_config() and improve its readability.
>
> Signed-off-by: wangyufei <wangyufei@vivo.com>
> ---
>  arch/mips/ralink/timer.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)

I personally like the code as it is because it is more readable at
least to my eyes :)

Thanks,
    Sergio Paracuellos