From: Oliver Korpilla <Oliver.Korpilla@gmx.de>
To: kernel-janitors@vger.kernel.org
Subject: [KJ] Timer code duplication in driver
Date: Tue, 16 Aug 2005 12:53:43 +0000 [thread overview]
Message-ID: <4301E1D7.5070707@gmx.de> (raw)
[-- Attachment #1: Type: text/plain, Size: 1331 bytes --]
Hello!
I was just reviewing code about high resolution timers for learning to
use their API correctly, and have come to the following code duplication
(in 2.6.12.4 kernel.org):
drivers/char/ipmi/ipmi_si_intf.c:
static inline void add_usec_to_timer(struct timer_list *t, long v)
{
t->sub_expires += nsec_to_arch_cycle(v * 1000);
while (t->sub_expires >= arch_cycles_per_jiffy)
{
t->expires++;
t->sub_expires -= arch_cycles_per_jiffy;
}
}
And the standard methods to do this are defined as:
include/linux/posix-timers.h:
static inline void
normalize_jiffies(unsigned long *jiff, long *sub_jif)
{
while ((*(sub_jif) - arch_cycles_per_jiffy) >= 0) {
*(sub_jif) -= arch_cycles_per_jiffy;
(*(jiff))++;
}
}
static inline void
full_normalize_jiffies(unsigned long *jiff, long *sub_jif)
{
normalize_jiffies(jiff, sub_jif);
while (*(sub_jif) < 0) {
*(sub_jif) += arch_cycles_per_jiffy;
(*(jiff))--;
}
}
So wouldn't a better version be:
static inline void add_usec_to_timer(struct timer_list *t, long v)
{
t->sub_expires += nsec_to_arch_cycle(v * 1000);
full_normalize_jiffies(&(t->expires), &(t->sub_expires));
}
Anyone else thinking this should be fixed?
Could someone please review this?
Thanks and with kind regards,
Oliver Korpilla
[-- Attachment #2: Type: text/plain, Size: 168 bytes --]
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
next reply other threads:[~2005-08-16 12:53 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-08-16 12:53 Oliver Korpilla [this message]
2005-08-16 16:42 ` [KJ] Timer code duplication in driver Nishanth Aravamudan
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=4301E1D7.5070707@gmx.de \
--to=oliver.korpilla@gmx.de \
--cc=kernel-janitors@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.