aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/input/input.c29
1 files changed, 4 insertions, 25 deletions
diff --git a/drivers/input/input.c b/drivers/input/input.c
index 75b4d2a83dd9..5fe755586623 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -471,37 +471,16 @@ static unsigned int input_proc_devices_poll(struct file *file, poll_table *wait)
471 return 0; 471 return 0;
472} 472}
473 473
474static struct list_head *list_get_nth_element(struct list_head *list, loff_t *pos)
475{
476 struct list_head *node;
477 loff_t i = 0;
478
479 list_for_each(node, list)
480 if (i++ == *pos)
481 return node;
482
483 return NULL;
484}
485
486static struct list_head *list_get_next_element(struct list_head *list, struct list_head *element, loff_t *pos)
487{
488 if (element->next == list)
489 return NULL;
490
491 ++(*pos);
492 return element->next;
493}
494
495static void *input_devices_seq_start(struct seq_file *seq, loff_t *pos) 474static void *input_devices_seq_start(struct seq_file *seq, loff_t *pos)
496{ 475{
497 /* acquire lock here ... Yes, we do need locking, I knowi, I know... */ 476 /* acquire lock here ... Yes, we do need locking, I knowi, I know... */
498 477
499 return list_get_nth_element(&input_dev_list, pos); 478 return seq_list_start(&input_dev_list, *pos);
500} 479}
501 480
502static void *input_devices_seq_next(struct seq_file *seq, void *v, loff_t *pos) 481static void *input_devices_seq_next(struct seq_file *seq, void *v, loff_t *pos)
503{ 482{
504 return list_get_next_element(&input_dev_list, v, pos); 483 return seq_list_next(v, &input_dev_list, pos);
505} 484}
506 485
507static void input_devices_seq_stop(struct seq_file *seq, void *v) 486static void input_devices_seq_stop(struct seq_file *seq, void *v)
@@ -592,13 +571,13 @@ static void *input_handlers_seq_start(struct seq_file *seq, loff_t *pos)
592{ 571{
593 /* acquire lock here ... Yes, we do need locking, I knowi, I know... */ 572 /* acquire lock here ... Yes, we do need locking, I knowi, I know... */
594 seq->private = (void *)(unsigned long)*pos; 573 seq->private = (void *)(unsigned long)*pos;
595 return list_get_nth_element(&input_handler_list, pos); 574 return seq_list_start(&input_handler_list, *pos);
596} 575}
597 576
598static void *input_handlers_seq_next(struct seq_file *seq, void *v, loff_t *pos) 577static void *input_handlers_seq_next(struct seq_file *seq, void *v, loff_t *pos)
599{ 578{
600 seq->private = (void *)(unsigned long)(*pos + 1); 579 seq->private = (void *)(unsigned long)(*pos + 1);
601 return list_get_next_element(&input_handler_list, v, pos); 580 return seq_list_next(v, &input_handler_list, pos);
602} 581}
603 582
604static void input_handlers_seq_stop(struct seq_file *seq, void *v) 583static void input_handlers_seq_stop(struct seq_file *seq, void *v)