diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2010-01-05 20:56:04 -0500 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2010-01-06 03:22:23 -0500 |
commit | 4516c8183213b59c3645d810ccb04b70c2606743 (patch) | |
tree | fab594d014d82a6172bb54fd4328670ed14fe646 /drivers/input/serio | |
parent | ddf1ffbd40c92ff1e58c45fa96d309788f7beb60 (diff) |
Input: serio - use list_first_entry() helper
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input/serio')
-rw-r--r-- | drivers/input/serio/serio.c | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c index d89880450f7..7fbf7670ae0 100644 --- a/drivers/input/serio/serio.c +++ b/drivers/input/serio/serio.c | |||
@@ -230,14 +230,12 @@ static void serio_free_event(struct serio_event *event) | |||
230 | 230 | ||
231 | static void serio_remove_duplicate_events(struct serio_event *event) | 231 | static void serio_remove_duplicate_events(struct serio_event *event) |
232 | { | 232 | { |
233 | struct list_head *node, *next; | 233 | struct serio_event *e, *next; |
234 | struct serio_event *e; | ||
235 | unsigned long flags; | 234 | unsigned long flags; |
236 | 235 | ||
237 | spin_lock_irqsave(&serio_event_lock, flags); | 236 | spin_lock_irqsave(&serio_event_lock, flags); |
238 | 237 | ||
239 | list_for_each_safe(node, next, &serio_event_list) { | 238 | list_for_each_entry_safe(e, next, &serio_event_list, node) { |
240 | e = list_entry(node, struct serio_event, node); | ||
241 | if (event->object == e->object) { | 239 | if (event->object == e->object) { |
242 | /* | 240 | /* |
243 | * If this event is of different type we should not | 241 | * If this event is of different type we should not |
@@ -247,7 +245,7 @@ static void serio_remove_duplicate_events(struct serio_event *event) | |||
247 | if (event->type != e->type) | 245 | if (event->type != e->type) |
248 | break; | 246 | break; |
249 | 247 | ||
250 | list_del_init(node); | 248 | list_del_init(&e->node); |
251 | serio_free_event(e); | 249 | serio_free_event(e); |
252 | } | 250 | } |
253 | } | 251 | } |
@@ -258,23 +256,18 @@ static void serio_remove_duplicate_events(struct serio_event *event) | |||
258 | 256 | ||
259 | static struct serio_event *serio_get_event(void) | 257 | static struct serio_event *serio_get_event(void) |
260 | { | 258 | { |
261 | struct serio_event *event; | 259 | struct serio_event *event = NULL; |
262 | struct list_head *node; | ||
263 | unsigned long flags; | 260 | unsigned long flags; |
264 | 261 | ||
265 | spin_lock_irqsave(&serio_event_lock, flags); | 262 | spin_lock_irqsave(&serio_event_lock, flags); |
266 | 263 | ||
267 | if (list_empty(&serio_event_list)) { | 264 | if (!list_empty(&serio_event_list)) { |
268 | spin_unlock_irqrestore(&serio_event_lock, flags); | 265 | event = list_first_entry(&serio_event_list, |
269 | return NULL; | 266 | struct serio_event, node); |
267 | list_del_init(&event->node); | ||
270 | } | 268 | } |
271 | 269 | ||
272 | node = serio_event_list.next; | ||
273 | event = list_entry(node, struct serio_event, node); | ||
274 | list_del_init(node); | ||
275 | |||
276 | spin_unlock_irqrestore(&serio_event_lock, flags); | 270 | spin_unlock_irqrestore(&serio_event_lock, flags); |
277 | |||
278 | return event; | 271 | return event; |
279 | } | 272 | } |
280 | 273 | ||
@@ -331,16 +324,14 @@ static void serio_handle_event(void) | |||
331 | */ | 324 | */ |
332 | static void serio_remove_pending_events(void *object) | 325 | static void serio_remove_pending_events(void *object) |
333 | { | 326 | { |
334 | struct list_head *node, *next; | 327 | struct serio_event *event, *next; |
335 | struct serio_event *event; | ||
336 | unsigned long flags; | 328 | unsigned long flags; |
337 | 329 | ||
338 | spin_lock_irqsave(&serio_event_lock, flags); | 330 | spin_lock_irqsave(&serio_event_lock, flags); |
339 | 331 | ||
340 | list_for_each_safe(node, next, &serio_event_list) { | 332 | list_for_each_entry_safe(event, next, &serio_event_list, node) { |
341 | event = list_entry(node, struct serio_event, node); | ||
342 | if (event->object == object) { | 333 | if (event->object == object) { |
343 | list_del_init(node); | 334 | list_del_init(&event->node); |
344 | serio_free_event(event); | 335 | serio_free_event(event); |
345 | } | 336 | } |
346 | } | 337 | } |