Lines Matching refs:queue

3  *  linux/drivers/acorn/scsi/queue.c: queue handling primitives
50 #include "queue.h"
55 * Function: void queue_initialise (Queue_t *queue)
56 * Purpose : initialise a queue
57 * Params : queue - queue to initialise
59 int queue_initialise (Queue_t *queue)
64 spin_lock_init(&queue->queue_lock);
65 INIT_LIST_HEAD(&queue->head);
66 INIT_LIST_HEAD(&queue->free);
74 queue->alloc = q = kmalloc_array(nqueues, sizeof(QE_t), GFP_KERNEL);
79 list_add(&q->list, &queue->free);
83 return queue->alloc != NULL;
87 * Function: void queue_free (Queue_t *queue)
88 * Purpose : free a queue
89 * Params : queue - queue to free
91 void queue_free (Queue_t *queue)
93 if (!list_empty(&queue->head))
94 printk(KERN_WARNING "freeing non-empty queue %p\n", queue);
95 kfree(queue->alloc);
100 * Function: int __queue_add(Queue_t *queue, struct scsi_cmnd *SCpnt, int head)
101 * Purpose : Add a new command onto a queue, adding REQUEST_SENSE to head.
102 * Params : queue - destination queue
104 * head - add command to head of queue
107 int __queue_add(Queue_t *queue, struct scsi_cmnd *SCpnt, int head)
114 spin_lock_irqsave(&queue->queue_lock, flags);
115 if (list_empty(&queue->free))
118 l = queue->free.next;
128 list_add(l, &queue->head);
130 list_add_tail(l, &queue->head);
134 spin_unlock_irqrestore(&queue->queue_lock, flags);
138 static struct scsi_cmnd *__queue_remove(Queue_t *queue, struct list_head *ent)
150 list_add(ent, &queue->free);
156 * Function: struct scsi_cmnd *queue_remove_exclude (queue, exclude)
157 * Purpose : remove a SCSI command from a queue
158 * Params : queue - queue to remove command from
162 struct scsi_cmnd *queue_remove_exclude(Queue_t *queue, unsigned long *exclude)
168 spin_lock_irqsave(&queue->queue_lock, flags);
169 list_for_each(l, &queue->head) {
173 SCpnt = __queue_remove(queue, l);
177 spin_unlock_irqrestore(&queue->queue_lock, flags);
183 * Function: struct scsi_cmnd *queue_remove (queue)
184 * Purpose : removes first SCSI command from a queue
185 * Params : queue - queue to remove command from
188 struct scsi_cmnd *queue_remove(Queue_t *queue)
193 spin_lock_irqsave(&queue->queue_lock, flags);
194 if (!list_empty(&queue->head))
195 SCpnt = __queue_remove(queue, queue->head.next);
196 spin_unlock_irqrestore(&queue->queue_lock, flags);
202 * Function: struct scsi_cmnd *queue_remove_tgtluntag (queue, target, lun, tag)
203 * Purpose : remove a SCSI command from the queue for a specified target/lun/tag
204 * Params : queue - queue to remove command from
210 struct scsi_cmnd *queue_remove_tgtluntag(Queue_t *queue, int target, int lun,
217 spin_lock_irqsave(&queue->queue_lock, flags);
218 list_for_each(l, &queue->head) {
222 SCpnt = __queue_remove(queue, l);
226 spin_unlock_irqrestore(&queue->queue_lock, flags);
232 * Function: queue_remove_all_target(queue, target)
233 * Purpose : remove all SCSI commands from the queue for a specified target
234 * Params : queue - queue to remove command from
238 void queue_remove_all_target(Queue_t *queue, int target)
243 spin_lock_irqsave(&queue->queue_lock, flags);
244 list_for_each(l, &queue->head) {
247 __queue_remove(queue, l);
249 spin_unlock_irqrestore(&queue->queue_lock, flags);
253 * Function: int queue_probetgtlun (queue, target, lun)
254 * Purpose : check to see if we have a command in the queue for the specified
256 * Params : queue - queue to look in
261 int queue_probetgtlun (Queue_t *queue, int target, int lun)
267 spin_lock_irqsave(&queue->queue_lock, flags);
268 list_for_each(l, &queue->head) {
275 spin_unlock_irqrestore(&queue->queue_lock, flags);
281 * Function: int queue_remove_cmd(Queue_t *queue, struct scsi_cmnd *SCpnt)
283 * Params : queue - queue to look in
287 int queue_remove_cmd(Queue_t *queue, struct scsi_cmnd *SCpnt)
293 spin_lock_irqsave(&queue->queue_lock, flags);
294 list_for_each(l, &queue->head) {
297 __queue_remove(queue, l);
302 spin_unlock_irqrestore(&queue->queue_lock, flags);