17 #include <linux/module.h>
19 #include <linux/kernel.h>
20 #include <linux/string.h>
21 #include <linux/slab.h>
23 #include <linux/list.h>
30 typedef struct queue_entry {
39 #define QUEUE_MAGIC_FREE 0xf7e1c9a3
40 #define QUEUE_MAGIC_USED 0xf7e1cc33
42 #define SET_MAGIC(q,m) ((q)->magic = (m))
43 #define BAD_MAGIC(q,m) ((q)->magic != (m))
45 #define SET_MAGIC(q,m) do { } while (0)
46 #define BAD_MAGIC(q,m) (0)
60 unsigned int nqueues =
NR_QE;
64 INIT_LIST_HEAD(&queue->
head);
65 INIT_LIST_HEAD(&queue->
free);
75 for (; nqueues; q++, nqueues--) {
78 list_add(&q->list, &queue->
free);
92 if (!list_empty(&queue->
head))
114 if (list_empty(&queue->
free))
117 l = queue->
free.next;
127 list_add(l, &queue->
head);
133 spin_unlock_irqrestore(&queue->
queue_lock, flags);
149 list_add(ent, &queue->
free);
170 if (!
test_bit(q->SCpnt->device->id * 8 + q->SCpnt->device->lun, exclude)) {
171 SCpnt = __queue_remove(queue, l);
175 spin_unlock_irqrestore(&queue->
queue_lock, flags);
192 if (!list_empty(&queue->
head))
193 SCpnt = __queue_remove(queue, queue->
head.next);
194 spin_unlock_irqrestore(&queue->
queue_lock, flags);
218 if (q->SCpnt->device->id == target && q->SCpnt->device->lun == lun &&
219 q->SCpnt->tag == tag) {
220 SCpnt = __queue_remove(queue, l);
224 spin_unlock_irqrestore(&queue->
queue_lock, flags);
244 if (q->SCpnt->device->id == target)
245 __queue_remove(queue, l);
247 spin_unlock_irqrestore(&queue->
queue_lock, flags);
268 if (q->SCpnt->device->id == target && q->SCpnt->device->lun == lun) {
273 spin_unlock_irqrestore(&queue->
queue_lock, flags);
294 if (q->SCpnt == SCpnt) {
295 __queue_remove(queue, l);
300 spin_unlock_irqrestore(&queue->
queue_lock, flags);