diff mbox series

MIPS: ralink: Avoid x/x division in rt_timer_config()

Message ID 20250408082804.796515-2-thorsten.blum@linux.dev (mailing list archive)
State New
Headers show
Series MIPS: ralink: Avoid x/x division in rt_timer_config() | expand

Commit Message

Thorsten Blum April 8, 2025, 8:28 a.m. UTC
Avoid the 'rt->timer_freq / rt->timer_freq' division when the divisor is
larger than the timer frequency and use '1' directly.

No functional changes intended.

Suggested-by: David Laight <david.laight.linux@gmail.com>
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 arch/mips/ralink/timer.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/arch/mips/ralink/timer.c b/arch/mips/ralink/timer.c
index 54094f6e033e..5d8286603584 100644
--- a/arch/mips/ralink/timer.c
+++ b/arch/mips/ralink/timer.c
@@ -75,12 +75,16 @@  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)
+	u32 t;
+
+	if (rt->timer_freq < divisor) {
 		rt->timer_div = rt->timer_freq;
-	else
+		t = 1;
+	} else {
 		rt->timer_div = divisor;
-
-	rt_timer_w32(rt, TIMER_REG_TMR0LOAD, rt->timer_freq / rt->timer_div);
+		t = rt->timer_freq / rt->timer_div;
+	}
+	rt_timer_w32(rt, TIMER_REG_TMR0LOAD, t);
 
 	return 0;
 }