aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/gameport
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2010-01-05 20:56:03 -0500
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2010-01-06 03:24:09 -0500
commitd621af473079851caac873adc5431a05c9d78dfd (patch)
tree100e2c489777bb05d7e11a2794cac7c2cf56995e /drivers/input/gameport
parent361b7b5b032338361ea88412f1fc45479fdd5859 (diff)
Input: gameport - make use of list_first_entry() helper
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input/gameport')
-rw-r--r--drivers/input/gameport/gameport.c30
1 files changed, 11 insertions, 19 deletions
diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
index f9e5f8e1690b..953a20bf26e8 100644
--- a/drivers/input/gameport/gameport.c
+++ b/drivers/input/gameport/gameport.c
@@ -298,14 +298,12 @@ static void gameport_free_event(struct gameport_event *event)
298 298
299static void gameport_remove_duplicate_events(struct gameport_event *event) 299static void gameport_remove_duplicate_events(struct gameport_event *event)
300{ 300{
301 struct list_head *node, *next; 301 struct gameport_event *e, *next;
302 struct gameport_event *e;
303 unsigned long flags; 302 unsigned long flags;
304 303
305 spin_lock_irqsave(&gameport_event_lock, flags); 304 spin_lock_irqsave(&gameport_event_lock, flags);
306 305
307 list_for_each_safe(node, next, &gameport_event_list) { 306 list_for_each_entry_safe(e, next, &gameport_event_list, node) {
308 e = list_entry(node, struct gameport_event, node);
309 if (event->object == e->object) { 307 if (event->object == e->object) {
310 /* 308 /*
311 * If this event is of different type we should not 309 * If this event is of different type we should not
@@ -315,7 +313,7 @@ static void gameport_remove_duplicate_events(struct gameport_event *event)
315 if (event->type != e->type) 313 if (event->type != e->type)
316 break; 314 break;
317 315
318 list_del_init(node); 316 list_del_init(&e->node);
319 gameport_free_event(e); 317 gameport_free_event(e);
320 } 318 }
321 } 319 }
@@ -325,21 +323,17 @@ static void gameport_remove_duplicate_events(struct gameport_event *event)
325 323
326static struct gameport_event *gameport_get_event(void) 324static struct gameport_event *gameport_get_event(void)
327{ 325{
328 struct gameport_event *event; 326 struct gameport_event *event = NULL;
329 struct list_head *node;
330 unsigned long flags; 327 unsigned long flags;
331 328
332 spin_lock_irqsave(&gameport_event_lock, flags); 329 spin_lock_irqsave(&gameport_event_lock, flags);
333 330
334 if (list_empty(&gameport_event_list)) { 331 if (!list_empty(&gameport_event_list)) {
335 spin_unlock_irqrestore(&gameport_event_lock, flags); 332 event = list_first_entry(&gameport_event_list,
336 return NULL; 333 struct gameport_event, node);
334 list_del_init(&event->node);
337 } 335 }
338 336
339 node = gameport_event_list.next;
340 event = list_entry(node, struct gameport_event, node);
341 list_del_init(node);
342
343 spin_unlock_irqrestore(&gameport_event_lock, flags); 337 spin_unlock_irqrestore(&gameport_event_lock, flags);
344 338
345 return event; 339 return event;
@@ -385,16 +379,14 @@ static void gameport_handle_event(void)
385 */ 379 */
386static void gameport_remove_pending_events(void *object) 380static void gameport_remove_pending_events(void *object)
387{ 381{
388 struct list_head *node, *next; 382 struct gameport_event *event, *next;
389 struct gameport_event *event;
390 unsigned long flags; 383 unsigned long flags;
391 384
392 spin_lock_irqsave(&gameport_event_lock, flags); 385 spin_lock_irqsave(&gameport_event_lock, flags);
393 386
394 list_for_each_safe(node, next, &gameport_event_list) { 387 list_for_each_entry_safe(event, next, &gameport_event_list, node) {
395 event = list_entry(node, struct gameport_event, node);
396 if (event->object == object) { 388 if (event->object == object) {
397 list_del_init(node); 389 list_del_init(&event->node);
398 gameport_free_event(event); 390 gameport_free_event(event);
399 } 391 }
400 } 392 }