[PATCH] Char: timers cleanup

- Use timer macros to set function and data members and to modify
  expiration time.
- Use DEFINE_TIMER for global timers and do not init them at run-time in
  these cases.
- del_timer_sync is common in most cases -- we want to wait for timer
  function if it's still running.

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Cc: Dave Airlie <airlied@linux.ie>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Dominik Brodowski <linux@dominikbrodowski.net>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Paul Fulghum <paulkf@microgate.com>
Cc: Kylene Jo Hall <kjhall@us.ibm.com>
Cc: Wim Van Sebroeck <wim@iguana.be>
Acked-by: Dmitry Torokhov <dtor@mail.ru>	(Input bits)
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Jiri Slaby
2007-02-12 00:52:31 -08:00
committed by Linus Torvalds
parent d096f3e989
commit 40565f1962
17 changed files with 75 additions and 123 deletions

View File

@ -23,8 +23,11 @@
#define __NWBUTTON_C /* Tell the header file who we are */
#include "nwbutton.h"
static void button_sequence_finished (unsigned long parameters);
static int button_press_count; /* The count of button presses */
static struct timer_list button_timer; /* Times for the end of a sequence */
/* Times for the end of a sequence */
static DEFINE_TIMER(button_timer, button_sequence_finished, 0, 0);
static DECLARE_WAIT_QUEUE_HEAD(button_wait_queue); /* Used for blocking read */
static char button_output_buffer[32]; /* Stores data to write out of device */
static int bcount; /* The number of bytes in the buffer */
@ -146,14 +149,8 @@ static void button_sequence_finished (unsigned long parameters)
static irqreturn_t button_handler (int irq, void *dev_id)
{
if (button_press_count) {
del_timer (&button_timer);
}
button_press_count++;
init_timer (&button_timer);
button_timer.function = button_sequence_finished;
button_timer.expires = (jiffies + bdelay);
add_timer (&button_timer);
mod_timer(&button_timer, jiffies + bdelay);
return IRQ_HANDLED;
}