Lines Matching refs: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)
63 spin_lock_init(&queue->queue_lock);
64 INIT_LIST_HEAD(&queue->head);
65 INIT_LIST_HEAD(&queue->free);
73 queue->alloc = q = kmalloc(sizeof(QE_t) * nqueues, GFP_KERNEL);
78 list_add(&q->list, &queue->free);
82 return queue->alloc != NULL;
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)
92 if (!list_empty(&queue->head))
93 printk(KERN_WARNING "freeing non-empty queue %p\n", queue);
94 kfree(queue->alloc);
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)
113 spin_lock_irqsave(&queue->queue_lock, flags);
114 if (list_empty(&queue->free))
117 l = queue->free.next;
127 list_add(l, &queue->head);
129 list_add_tail(l, &queue->head);
133 spin_unlock_irqrestore(&queue->queue_lock, flags);
137 static struct scsi_cmnd *__queue_remove(Queue_t *queue, struct list_head *ent)
149 list_add(ent, &queue->free);
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)
167 spin_lock_irqsave(&queue->queue_lock, flags);
168 list_for_each(l, &queue->head) {
171 SCpnt = __queue_remove(queue, l);
175 spin_unlock_irqrestore(&queue->queue_lock, flags);
181 * Function: struct scsi_cmnd *queue_remove (queue)
182 * Purpose : removes first SCSI command from a queue
183 * Params : queue - queue to remove command from
186 struct scsi_cmnd *queue_remove(Queue_t *queue)
191 spin_lock_irqsave(&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);
200 * Function: struct scsi_cmnd *queue_remove_tgtluntag (queue, target, lun, tag)
201 * Purpose : remove a SCSI command from the queue for a specified target/lun/tag
202 * Params : queue - queue to remove command from
208 struct scsi_cmnd *queue_remove_tgtluntag(Queue_t *queue, int target, int lun,
215 spin_lock_irqsave(&queue->queue_lock, flags);
216 list_for_each(l, &queue->head) {
220 SCpnt = __queue_remove(queue, l);
224 spin_unlock_irqrestore(&queue->queue_lock, flags);
230 * Function: queue_remove_all_target(queue, target)
231 * Purpose : remove all SCSI commands from the queue for a specified target
232 * Params : queue - queue to remove command from
236 void queue_remove_all_target(Queue_t *queue, int target)
241 spin_lock_irqsave(&queue->queue_lock, flags);
242 list_for_each(l, &queue->head) {
245 __queue_remove(queue, l);
247 spin_unlock_irqrestore(&queue->queue_lock, flags);
251 * Function: int queue_probetgtlun (queue, target, lun)
252 * Purpose : check to see if we have a command in the queue for the specified
254 * Params : queue - queue to look in
259 int queue_probetgtlun (Queue_t *queue, int target, int lun)
265 spin_lock_irqsave(&queue->queue_lock, flags);
266 list_for_each(l, &queue->head) {
273 spin_unlock_irqrestore(&queue->queue_lock, flags);
279 * Function: int queue_remove_cmd(Queue_t *queue, struct scsi_cmnd *SCpnt)
281 * Params : queue - queue to look in
285 int queue_remove_cmd(Queue_t *queue, struct scsi_cmnd *SCpnt)
291 spin_lock_irqsave(&queue->queue_lock, flags);
292 list_for_each(l, &queue->head) {
295 __queue_remove(queue, l);
300 spin_unlock_irqrestore(&queue->queue_lock, flags);