From: Thorsten Blum <thorsten.blum@linux.dev>
To: John Crispin <john@phrozen.org>,
Sergio Paracuellos <sergio.paracuellos@gmail.com>,
Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Thorsten Blum <thorsten.blum@linux.dev>,
David Laight <david.laight.linux@gmail.com>,
linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] MIPS: ralink: Avoid x/x division in rt_timer_config()
Date: Tue, 8 Apr 2025 10:28:05 +0200 [thread overview]
Message-ID: <20250408082804.796515-2-thorsten.blum@linux.dev> (raw)
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 --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;
}
--
2.49.0
next reply other threads:[~2025-04-08 8:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-08 8:28 Thorsten Blum [this message]
2025-04-27 8:18 ` [PATCH] MIPS: ralink: Avoid x/x division in rt_timer_config() Thomas Bogendoerfer
2025-04-27 9:25 ` Sergio Paracuellos
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250408082804.796515-2-thorsten.blum@linux.dev \
--to=thorsten.blum@linux.dev \
--cc=david.laight.linux@gmail.com \
--cc=john@phrozen.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=sergio.paracuellos@gmail.com \
--cc=tsbogend@alpha.franken.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).