From: Jean Tourrilhes <jt@bougret.hpl.hp.com>
To: Jeff Garzik <jgarzik@pobox.com>,
Linux kernel mailing list <linux-kernel@vger.kernel.org>
Subject: [PATCH 2.5] : IrDA timer fix
Date: Thu, 20 Feb 2003 16:10:34 -0800 [thread overview]
Message-ID: <20030221001034.GF26770@bougret.hpl.hp.com> (raw)
ir253_timer_mod.diff :
--------------------
o [FEATURE] Make IrDA timers use mod_timer instead of add+del_timer
diff -u -p linux/net/irda/timer.d5.c linux/net/irda/timer.c
--- linux/net/irda/timer.d5.c Thu Jan 9 13:36:15 2003
+++ linux/net/irda/timer.c Thu Jan 9 13:51:03 2003
@@ -39,8 +39,8 @@ static void irlap_query_timer_expired(vo
static void irlap_final_timer_expired(void* data);
static void irlap_wd_timer_expired(void* data);
static void irlap_backoff_timer_expired(void* data);
-
static void irlap_media_busy_expired(void* data);
+
/*
* Function irda_start_timer (timer, timeout)
*
@@ -50,19 +50,18 @@ static void irlap_media_busy_expired(voi
void irda_start_timer(struct timer_list *ptimer, int timeout, void *data,
TIMER_CALLBACK callback)
{
- del_timer(ptimer);
-
- ptimer->data = (unsigned long) data;
-
/*
* For most architectures void * is the same as unsigned long, but
* at least we try to use void * as long as possible. Since the
* timer functions use unsigned long, we cast the function here
*/
ptimer->function = (void (*)(unsigned long)) callback;
- ptimer->expires = jiffies + timeout;
+ ptimer->data = (unsigned long) data;
- add_timer(ptimer);
+ /* Set new value for timer (update or add timer).
+ * We use mod_timer() because it's more efficient and also
+ * safer with respect to race conditions - Jean II */
+ mod_timer(ptimer, jiffies + timeout);
}
void irlap_start_slot_timer(struct irlap_cb *self, int timeout)
@@ -136,8 +135,7 @@ void irlmp_start_idle_timer(struct lap_c
void irlmp_stop_idle_timer(struct lap_cb *self)
{
/* If timer is activated, kill it! */
- if(timer_pending(&self->idle_timer))
- del_timer(&self->idle_timer);
+ del_timer(&self->idle_timer);
}
/*
reply other threads:[~2003-02-21 0:01 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20030221001034.GF26770@bougret.hpl.hp.com \
--to=jt@bougret.hpl.hp.com \
--cc=jgarzik@pobox.com \
--cc=jt@hpl.hp.com \
--cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®