Skip to content

Commit

Permalink
sony-laptop - switch from workqueue to a timer
Browse files Browse the repository at this point in the history
The function that is executing in workqueue context does not need
to sleep so let's switch to a timer which is more lightweight.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Len Brown <len.brown@intel.com>
  • Loading branch information
Dmitry Torokhov authored and Len Brown committed Dec 24, 2009
1 parent c45bc9d commit cffdde9
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions drivers/platform/x86/sony-laptop.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ struct sony_laptop_input_s {
struct input_dev *key_dev;
struct kfifo fifo;
spinlock_t fifo_lock;
struct timer_list release_key_timer;
};

static struct sony_laptop_input_s sony_laptop_input = {
Expand Down Expand Up @@ -298,10 +299,8 @@ static int sony_laptop_input_keycode_map[] = {
};

/* release buttons after a short delay if pressed */
static void do_sony_laptop_release_key(struct work_struct *work)
static void do_sony_laptop_release_key(unsigned long unused)
{
struct delayed_work *dwork =
container_of(work, struct delayed_work, work);
struct sony_laptop_keypress kp;
unsigned long flags;

Expand All @@ -315,14 +314,12 @@ static void do_sony_laptop_release_key(struct work_struct *work)

/* If there is something in the fifo schedule next release. */
if (kfifo_len(&sony_laptop_input.fifo) != 0)
schedule_delayed_work(dwork, msecs_to_jiffies(10));
mod_timer(&sony_laptop_input.release_key_timer,
jiffies + msecs_to_jiffies(10));

spin_unlock_irqrestore(&sony_laptop_input.fifo_lock, flags);
}

static DECLARE_DELAYED_WORK(sony_laptop_release_key_work,
do_sony_laptop_release_key);

/* forward event to the input subsystem */
static void sony_laptop_report_input_event(u8 event)
{
Expand Down Expand Up @@ -380,8 +377,8 @@ static void sony_laptop_report_input_event(u8 event)
kfifo_in_locked(&sony_laptop_input.fifo,
(unsigned char *)&kp, sizeof(kp),
&sony_laptop_input.fifo_lock);
schedule_delayed_work(&sony_laptop_release_key_work,
msecs_to_jiffies(10));
mod_timer(&sony_laptop_input.release_key_timer,
jiffies + msecs_to_jiffies(10));
} else
dprintk("unknown input event %.2x\n", event);
}
Expand All @@ -406,6 +403,9 @@ static int sony_laptop_setup_input(struct acpi_device *acpi_device)
goto err_dec_users;
}

setup_timer(&sony_laptop_input.release_key_timer,
do_sony_laptop_release_key, 0);

/* input keys */
key_dev = input_allocate_device();
if (!key_dev) {
Expand Down Expand Up @@ -485,7 +485,7 @@ static void sony_laptop_remove_input(void)
if (!atomic_dec_and_test(&sony_laptop_input.users))
return;

cancel_delayed_work_sync(&sony_laptop_release_key_work);
del_timer_sync(&sony_laptop_input.release_key_timer);

/*
* Generate key-up events for remaining keys. Note that we don't
Expand Down

0 comments on commit cffdde9

Please sign in to comment.