예제 #1
0
/**
 * crystalhd_dioq_add - Add new DIO request element.
 * @ioq: DIO queue instance
 * @t: DIO request to be added.
 * @wake: True - Wake up suspended process.
 * @tag: Special tag to assign - For search and get.
 *
 * Return:
 *  Status.
 *
 * Insert new element to Q tail.
 */
BC_STATUS crystalhd_dioq_add(crystalhd_dioq_t *ioq, void *data,
                             bool wake, uint32_t tag)
{
    unsigned long flags = 0;
    crystalhd_elem_t *tmp;

    if (!ioq || (ioq->sig != BC_LINK_DIOQ_SIG) || !data) {
        dev_err(chddev(), "%s: Invalid arg\n", __func__);
        return BC_STS_INV_ARG;
    }

    tmp = crystalhd_alloc_elem(ioq->adp);
    if (!tmp) {
        dev_err(chddev(), "%s: No free elements.\n", __func__);
        return BC_STS_INSUFF_RES;
    }

    tmp->data = data;
    tmp->tag = tag;
    spin_lock_irqsave(&ioq->lock, flags);
    tmp->flink = (crystalhd_elem_t *)&ioq->head;
    tmp->blink = ioq->tail;
    tmp->flink->blink = tmp;
    tmp->blink->flink = tmp;
    ioq->count++;
    spin_unlock_irqrestore(&ioq->lock, flags);

    if (wake)
        crystalhd_set_event(&ioq->event);

    return BC_STS_SUCCESS;
}
static void bc_proc_in_completion(struct crystalhd_dio_req *dio_hnd,
				  wait_queue_head_t *event, enum BC_STATUS sts)
{
	if (!dio_hnd || !event) {
		BCMLOG_ERR("Invalid Arg!!\n");
		return;
	}
	if (sts == BC_STS_IO_USER_ABORT)
		return;

	dio_hnd->uinfo.comp_sts = sts;
	dio_hnd->uinfo.ev_sts = 1;
	crystalhd_set_event(event);
}