else if (!atomic_read(&queue->set_pci_flags_count)) atomic_swap(&queue->state, QETH_OUT_Q_LOCKED_FLUSH); 
qeth_do_send_packet(struct qeth_card *card, struct qeth_qdio_out_q *queue,		    struct sk_buff *skb, struct qeth_hdr *hdr,		    int elements_needed, struct qeth_eddp_context *ctx){	struct qeth_qdio_out_buffer *buffer;	int start_index;	int flush_count = 0;	int do_pack = 0;	int tmp;	int rc = 0;	QETH_DBF_TEXT(trace, 6, "dosndpkt");	/* spin until we get the queue ... */	while (atomic_compare_and_swap(QETH_OUT_Q_UNLOCKED,				       QETH_OUT_Q_LOCKED,				       &queue->state));	start_index = queue->next_buf_to_fill;	buffer = &queue->bufs[queue->next_buf_to_fill];	/*	 * check if buffer is empty to make sure that we do not 'overtake'	 * ourselves and try to fill a buffer that is already primed	 */	if (atomic_read(&buffer->state) != QETH_QDIO_BUF_EMPTY){		card->stats.tx_dropped++;		atomic_set(&queue->state, QETH_OUT_Q_UNLOCKED);		return -EBUSY;	}	/* check if we need to switch packing state of this queue */	qeth_switch_to_packing_if_needed(queue);	if (queue->do_pack){		do_pack = 1;		if (ctx == NULL) {			/* does packet fit in current buffer? */			if((QETH_MAX_BUFFER_ELEMENTS(card) -			    buffer->next_element_to_fill) < elements_needed){				/* ... no -> set state PRIMED */				atomic_set(&buffer->state,QETH_QDIO_BUF_PRIMED);				flush_count++;				queue->next_buf_to_fill =					(queue->next_buf_to_fill + 1) %					QDIO_MAX_BUFFERS_PER_Q;				buffer = &queue->bufs[queue->next_buf_to_fill];				/* we did a step forward, so check buffer state				 * again */				if (atomic_read(&buffer->state) !=						QETH_QDIO_BUF_EMPTY){					card->stats.tx_dropped++;					qeth_flush_buffers(queue, 0, start_index, flush_count);					atomic_set(&queue->state, QETH_OUT_Q_UNLOCKED);					return -EBUSY;				}			}		} else {			/* check if we have enough elements (including following			 * free buffers) to handle eddp context */			if (qeth_eddp_check_buffers_for_context(queue,ctx) < 0){				printk("eddp tx_dropped 1\n");				card->stats.tx_dropped++;				rc = -EBUSY;				goto out;			}		}	}	if (ctx == NULL)		tmp = qeth_fill_buffer(queue, buffer, skb);	else {		tmp = qeth_eddp_fill_buffer(queue,ctx,queue->next_buf_to_fill);		if (tmp < 0) {			printk("eddp tx_dropped 2\n");			card->stats.tx_dropped++;			rc = - EBUSY;			goto out;		}	}	queue->next_buf_to_fill = (queue->next_buf_to_fill + tmp) %				  QDIO_MAX_BUFFERS_PER_Q;	flush_count += tmp;out:	if (flush_count)		qeth_flush_buffers(queue, 0, start_index, flush_count);	/*	 * queue->state will go from LOCKED -> UNLOCKED or from	 * LOCKED_FLUSH -> LOCKED if output_handler wanted to 'notify' us	 * (switch packing state or flush buffer to get another pci flag out).	 * In that case we will enter this loop	 */	while (atomic_dec_return(&queue->state)){		flush_count = 0;		start_index = queue->next_buf_to_fill;		/* check if we can go back to non-packing state */		flush_count += qeth_switch_to_nonpacking_if_needed(queue);		/*		 * check if we need to flush a packing buffer to get a pci		 * flag out on the queue		 */		if (!flush_count && !atomic_read(&queue->set_pci_flags_count))			flush_count += qeth_flush_buffers_on_no_pci(queue);		if (flush_count)			qeth_flush_buffers(queue, 0, start_index, flush_count);	}	/* at this point the queue is UNLOCKED again */#ifdef CONFIG_QETH_PERF_STATS	if (do_pack)		queue->card->perf_stats.bufs_sent_pack += flush_count;#endif /* CONFIG_QETH_PERF_STATS */	return rc;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/d805d7c692e414c3adf01bb414a8c542ac2e67d1/qeth_main.c/buggy/drivers/s390/net/qeth_main.c