Input: serio - use list_first_entry() helper

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
This commit is contained in:
Dmitry Torokhov 2010-01-05 17:56:04 -08:00
parent ddf1ffbd40
commit 4516c81832
1 changed files with 11 additions and 20 deletions

View File

@ -230,14 +230,12 @@ static void serio_free_event(struct serio_event *event)
static void serio_remove_duplicate_events(struct serio_event *event) static void serio_remove_duplicate_events(struct serio_event *event)
{ {
struct list_head *node, *next; struct serio_event *e, *next;
struct serio_event *e;
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&serio_event_lock, flags); spin_lock_irqsave(&serio_event_lock, flags);
list_for_each_safe(node, next, &serio_event_list) { list_for_each_entry_safe(e, next, &serio_event_list, node) {
e = list_entry(node, struct serio_event, node);
if (event->object == e->object) { if (event->object == e->object) {
/* /*
* If this event is of different type we should not * If this event is of different type we should not
@ -247,7 +245,7 @@ static void serio_remove_duplicate_events(struct serio_event *event)
if (event->type != e->type) if (event->type != e->type)
break; break;
list_del_init(node); list_del_init(&e->node);
serio_free_event(e); serio_free_event(e);
} }
} }
@ -258,23 +256,18 @@ static void serio_remove_duplicate_events(struct serio_event *event)
static struct serio_event *serio_get_event(void) static struct serio_event *serio_get_event(void)
{ {
struct serio_event *event; struct serio_event *event = NULL;
struct list_head *node;
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&serio_event_lock, flags); spin_lock_irqsave(&serio_event_lock, flags);
if (list_empty(&serio_event_list)) { if (!list_empty(&serio_event_list)) {
spin_unlock_irqrestore(&serio_event_lock, flags); event = list_first_entry(&serio_event_list,
return NULL; struct serio_event, node);
list_del_init(&event->node);
} }
node = serio_event_list.next;
event = list_entry(node, struct serio_event, node);
list_del_init(node);
spin_unlock_irqrestore(&serio_event_lock, flags); spin_unlock_irqrestore(&serio_event_lock, flags);
return event; return event;
} }
@ -331,16 +324,14 @@ static void serio_handle_event(void)
*/ */
static void serio_remove_pending_events(void *object) static void serio_remove_pending_events(void *object)
{ {
struct list_head *node, *next; struct serio_event *event, *next;
struct serio_event *event;
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&serio_event_lock, flags); spin_lock_irqsave(&serio_event_lock, flags);
list_for_each_safe(node, next, &serio_event_list) { list_for_each_entry_safe(event, next, &serio_event_list, node) {
event = list_entry(node, struct serio_event, node);
if (event->object == object) { if (event->object == object) {
list_del_init(node); list_del_init(&event->node);
serio_free_event(event); serio_free_event(event);
} }
} }