diff options
author | Helmut Schaa <helmut.schaa@googlemail.com> | 2011-04-18 09:27:43 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2011-04-19 15:39:13 -0400 |
commit | 10e11568ca8b8a15f7478f6a4ceebabcbdba1018 (patch) | |
tree | 9ace4fe0ad5280fc46705aebef9bfa06b7c346ef /drivers/net/wireless/rt2x00/rt2x00queue.c | |
parent | 7dab73b37f5e8885cb73efd25e73861f9b4f0246 (diff) |
rt2x00: Make rt2x00_queue_entry_for_each more flexible
Allow passing a void pointer to rt2x00_queue_entry_for_each which in
turn in provided to the callback function.
Furthermore, allow the callback function to stop processing by returning
true. And also notify the caller of rt2x00_queue_entry_for_each if the
loop was canceled by the callback.
No functional changes, just preparation for an upcoming patch.
Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt2x00queue.c')
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2x00queue.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c index d03eef28f036..458bb489bc7c 100644 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c | |||
@@ -650,10 +650,12 @@ int rt2x00queue_update_beacon(struct rt2x00_dev *rt2x00dev, | |||
650 | return ret; | 650 | return ret; |
651 | } | 651 | } |
652 | 652 | ||
653 | void rt2x00queue_for_each_entry(struct data_queue *queue, | 653 | bool rt2x00queue_for_each_entry(struct data_queue *queue, |
654 | enum queue_index start, | 654 | enum queue_index start, |
655 | enum queue_index end, | 655 | enum queue_index end, |
656 | void (*fn)(struct queue_entry *entry)) | 656 | void *data, |
657 | bool (*fn)(struct queue_entry *entry, | ||
658 | void *data)) | ||
657 | { | 659 | { |
658 | unsigned long irqflags; | 660 | unsigned long irqflags; |
659 | unsigned int index_start; | 661 | unsigned int index_start; |
@@ -664,7 +666,7 @@ void rt2x00queue_for_each_entry(struct data_queue *queue, | |||
664 | ERROR(queue->rt2x00dev, | 666 | ERROR(queue->rt2x00dev, |
665 | "Entry requested from invalid index range (%d - %d)\n", | 667 | "Entry requested from invalid index range (%d - %d)\n", |
666 | start, end); | 668 | start, end); |
667 | return; | 669 | return true; |
668 | } | 670 | } |
669 | 671 | ||
670 | /* | 672 | /* |
@@ -683,15 +685,23 @@ void rt2x00queue_for_each_entry(struct data_queue *queue, | |||
683 | * send out all frames in the correct order. | 685 | * send out all frames in the correct order. |
684 | */ | 686 | */ |
685 | if (index_start < index_end) { | 687 | if (index_start < index_end) { |
686 | for (i = index_start; i < index_end; i++) | 688 | for (i = index_start; i < index_end; i++) { |
687 | fn(&queue->entries[i]); | 689 | if (fn(&queue->entries[i], data)) |
690 | return true; | ||
691 | } | ||
688 | } else { | 692 | } else { |
689 | for (i = index_start; i < queue->limit; i++) | 693 | for (i = index_start; i < queue->limit; i++) { |
690 | fn(&queue->entries[i]); | 694 | if (fn(&queue->entries[i], data)) |
695 | return true; | ||
696 | } | ||
691 | 697 | ||
692 | for (i = 0; i < index_end; i++) | 698 | for (i = 0; i < index_end; i++) { |
693 | fn(&queue->entries[i]); | 699 | if (fn(&queue->entries[i], data)) |
700 | return true; | ||
701 | } | ||
694 | } | 702 | } |
703 | |||
704 | return false; | ||
695 | } | 705 | } |
696 | EXPORT_SYMBOL_GPL(rt2x00queue_for_each_entry); | 706 | EXPORT_SYMBOL_GPL(rt2x00queue_for_each_entry); |
697 | 707 | ||