Lines Matching full:queue
2 * linux/drivers/acorn/scsi/queue.c: queue handling primitives
49 #include "queue.h"
54 * Function: void queue_initialise (Queue_t *queue)
55 * Purpose : initialise a queue
56 * Params : queue - queue to initialise
58 int queue_initialise (Queue_t *queue) in queue_initialise() argument
63 spin_lock_init(&queue->queue_lock); in queue_initialise()
64 INIT_LIST_HEAD(&queue->head); in queue_initialise()
65 INIT_LIST_HEAD(&queue->free); in queue_initialise()
73 queue->alloc = q = kmalloc_array(nqueues, sizeof(QE_t), GFP_KERNEL); in queue_initialise()
78 list_add(&q->list, &queue->free); in queue_initialise()
82 return queue->alloc != NULL; in queue_initialise()
86 * Function: void queue_free (Queue_t *queue)
87 * Purpose : free a queue
88 * Params : queue - queue to free
90 void queue_free (Queue_t *queue) in queue_free() argument
92 if (!list_empty(&queue->head)) in queue_free()
93 printk(KERN_WARNING "freeing non-empty queue %p\n", queue); in queue_free()
94 kfree(queue->alloc); in queue_free()
99 * Function: int __queue_add(Queue_t *queue, struct scsi_cmnd *SCpnt, int head)
100 * Purpose : Add a new command onto a queue, adding REQUEST_SENSE to head.
101 * Params : queue - destination queue
103 * head - add command to head of queue
106 int __queue_add(Queue_t *queue, struct scsi_cmnd *SCpnt, int head) in __queue_add() argument
113 spin_lock_irqsave(&queue->queue_lock, flags); in __queue_add()
114 if (list_empty(&queue->free)) in __queue_add()
117 l = queue->free.next; in __queue_add()
127 list_add(l, &queue->head); in __queue_add()
129 list_add_tail(l, &queue->head); in __queue_add()
133 spin_unlock_irqrestore(&queue->queue_lock, flags); in __queue_add()
137 static struct scsi_cmnd *__queue_remove(Queue_t *queue, struct list_head *ent) in __queue_remove() argument
149 list_add(ent, &queue->free); in __queue_remove()
155 * Function: struct scsi_cmnd *queue_remove_exclude (queue, exclude)
156 * Purpose : remove a SCSI command from a queue
157 * Params : queue - queue to remove command from
161 struct scsi_cmnd *queue_remove_exclude(Queue_t *queue, unsigned long *exclude) in queue_remove_exclude() argument
167 spin_lock_irqsave(&queue->queue_lock, flags); in queue_remove_exclude()
168 list_for_each(l, &queue->head) { in queue_remove_exclude()
172 SCpnt = __queue_remove(queue, l); in queue_remove_exclude()
176 spin_unlock_irqrestore(&queue->queue_lock, flags); in queue_remove_exclude()
182 * Function: struct scsi_cmnd *queue_remove (queue)
183 * Purpose : removes first SCSI command from a queue
184 * Params : queue - queue to remove command from
187 struct scsi_cmnd *queue_remove(Queue_t *queue) in queue_remove() argument
192 spin_lock_irqsave(&queue->queue_lock, flags); in queue_remove()
193 if (!list_empty(&queue->head)) in queue_remove()
194 SCpnt = __queue_remove(queue, queue->head.next); in queue_remove()
195 spin_unlock_irqrestore(&queue->queue_lock, flags); in queue_remove()
201 * Function: struct scsi_cmnd *queue_remove_tgtluntag (queue, target, lun, tag)
202 * Purpose : remove a SCSI command from the queue for a specified target/lun/tag
203 * Params : queue - queue to remove command from
209 struct scsi_cmnd *queue_remove_tgtluntag(Queue_t *queue, int target, int lun, in queue_remove_tgtluntag() argument
216 spin_lock_irqsave(&queue->queue_lock, flags); in queue_remove_tgtluntag()
217 list_for_each(l, &queue->head) { in queue_remove_tgtluntag()
221 SCpnt = __queue_remove(queue, l); in queue_remove_tgtluntag()
225 spin_unlock_irqrestore(&queue->queue_lock, flags); in queue_remove_tgtluntag()
231 * Function: queue_remove_all_target(queue, target)
232 * Purpose : remove all SCSI commands from the queue for a specified target
233 * Params : queue - queue to remove command from
237 void queue_remove_all_target(Queue_t *queue, int target) in queue_remove_all_target() argument
242 spin_lock_irqsave(&queue->queue_lock, flags); in queue_remove_all_target()
243 list_for_each(l, &queue->head) { in queue_remove_all_target()
246 __queue_remove(queue, l); in queue_remove_all_target()
248 spin_unlock_irqrestore(&queue->queue_lock, flags); in queue_remove_all_target()
252 * Function: int queue_probetgtlun (queue, target, lun)
253 * Purpose : check to see if we have a command in the queue for the specified
255 * Params : queue - queue to look in
260 int queue_probetgtlun (Queue_t *queue, int target, int lun) in queue_probetgtlun() argument
266 spin_lock_irqsave(&queue->queue_lock, flags); in queue_probetgtlun()
267 list_for_each(l, &queue->head) { in queue_probetgtlun()
274 spin_unlock_irqrestore(&queue->queue_lock, flags); in queue_probetgtlun()
280 * Function: int queue_remove_cmd(Queue_t *queue, struct scsi_cmnd *SCpnt)
282 * Params : queue - queue to look in
286 int queue_remove_cmd(Queue_t *queue, struct scsi_cmnd *SCpnt) in queue_remove_cmd() argument
292 spin_lock_irqsave(&queue->queue_lock, flags); in queue_remove_cmd()
293 list_for_each(l, &queue->head) { in queue_remove_cmd()
296 __queue_remove(queue, l); in queue_remove_cmd()
301 spin_unlock_irqrestore(&queue->queue_lock, flags); in queue_remove_cmd()