Lines Matching refs:hwreq
354 static int add_td_to_list(struct ci_hw_ep *hwep, struct ci_hw_req *hwreq,
375 u32 mul = hwreq->req.length / hwep->ep.maxpacket;
377 if (hwreq->req.length == 0
378 || hwreq->req.length % hwep->ep.maxpacket)
384 temp = (u32) (sg_dma_address(s) + hwreq->req.actual);
387 temp = (u32) (hwreq->req.dma + hwreq->req.actual);
399 hwreq->req.actual += length;
401 if (!list_empty(&hwreq->tds)) {
403 lastnode = list_entry(hwreq->tds.prev,
409 list_add_tail(&node->td, &hwreq->tds);
424 struct ci_hw_req *hwreq)
426 unsigned int rest = hwreq->req.length;
431 ret = add_td_to_list(hwep, hwreq, 0, NULL);
440 if (hwreq->req.dma % PAGE_SIZE)
444 unsigned int count = min(hwreq->req.length - hwreq->req.actual,
447 ret = add_td_to_list(hwep, hwreq, count, NULL);
454 if (hwreq->req.zero && hwreq->req.length && hwep->dir == TX
455 && (hwreq->req.length % hwep->ep.maxpacket == 0)) {
456 ret = add_td_to_list(hwep, hwreq, 0, NULL);
464 static int prepare_td_per_sg(struct ci_hw_ep *hwep, struct ci_hw_req *hwreq,
470 hwreq->req.actual = 0;
475 ret = add_td_to_list(hwep, hwreq, count, s);
504 static int prepare_td_for_sg(struct ci_hw_ep *hwep, struct ci_hw_req *hwreq)
506 struct usb_request *req = &hwreq->req;
526 ret = prepare_td_per_sg(hwep, hwreq, s);
530 node = list_entry(hwreq->tds.prev,
543 * @hwreq: request
547 static int _hardware_enqueue(struct ci_hw_ep *hwep, struct ci_hw_req *hwreq)
554 if (hwreq->req.status == -EALREADY)
557 hwreq->req.status = -EALREADY;
560 &hwreq->req, hwep->dir);
564 if (hwreq->req.num_mapped_sgs)
565 ret = prepare_td_for_sg(hwep, hwreq);
567 ret = prepare_td_for_non_sg(hwep, hwreq);
572 firstnode = list_first_entry(&hwreq->tds, struct td_node, td);
574 lastnode = list_entry(hwreq->tds.prev,
578 if (!hwreq->req.no_interrupt)
582 hwreq->req.actual = 0;
614 u32 mul = hwreq->req.length / hwep->ep.maxpacket;
616 if (hwreq->req.length == 0
617 || hwreq->req.length % hwep->ep.maxpacket)
655 * @hwreq: request
659 static int _hardware_dequeue(struct ci_hw_ep *hwep, struct ci_hw_req *hwreq)
664 unsigned actual = hwreq->req.length;
667 if (hwreq->req.status != -EALREADY)
670 hwreq->req.status = 0;
672 list_for_each_entry_safe(node, tmpnode, &hwreq->tds, td) {
680 hwreq->req.status = -EALREADY;
688 hwreq->req.status = tmptoken & TD_STATUS;
689 if ((TD_STATUS_HALTED & hwreq->req.status)) {
690 hwreq->req.status = -EPIPE;
692 } else if ((TD_STATUS_DT_ERR & hwreq->req.status)) {
693 hwreq->req.status = -EPROTO;
695 } else if ((TD_STATUS_TR_ERR & hwreq->req.status)) {
696 hwreq->req.status = -EILSEQ;
702 hwreq->req.status = -EPROTO;
719 &hwreq->req, hwep->dir);
721 hwreq->req.actual += actual;
723 if (hwreq->req.status)
724 return hwreq->req.status;
726 return hwreq->req.actual;
749 struct ci_hw_req *hwreq = list_entry(hwep->qh.queue.next,
752 list_for_each_entry_safe(node, tmpnode, &hwreq->tds, td) {
759 list_del_init(&hwreq->queue);
760 hwreq->req.status = -ESHUTDOWN;
762 if (hwreq->req.complete != NULL) {
764 usb_gadget_giveback_request(&hwep->ep, &hwreq->req);
918 struct ci_hw_req *hwreq = container_of(req, struct ci_hw_req, req);
937 hwreq->req.length > hwep->ep.mult * hwep->ep.maxpacket) {
943 if (!list_empty(&hwreq->queue)) {
949 hwreq->req.status = -EINPROGRESS;
950 hwreq->req.actual = 0;
952 retval = _hardware_enqueue(hwep, hwreq);
957 list_add_tail(&hwreq->queue, &hwep->qh.queue);
1090 struct ci_hw_req *hwreq, *hwreqtemp;
1094 list_for_each_entry_safe(hwreq, hwreqtemp, &hwep->qh.queue,
1096 retval = _hardware_dequeue(hwep, hwreq);
1099 list_del_init(&hwreq->queue);
1100 if (hwreq->req.complete != NULL) {
1103 hwreq->req.length)
1105 usb_gadget_giveback_request(&hweptemp->ep, &hwreq->req);
1452 struct ci_hw_req *hwreq = NULL;
1457 hwreq = kzalloc(sizeof(struct ci_hw_req), gfp_flags);
1458 if (hwreq != NULL) {
1459 INIT_LIST_HEAD(&hwreq->queue);
1460 INIT_LIST_HEAD(&hwreq->tds);
1463 return (hwreq == NULL) ? NULL : &hwreq->req;
1474 struct ci_hw_req *hwreq = container_of(req, struct ci_hw_req, req);
1480 } else if (!list_empty(&hwreq->queue)) {
1487 list_for_each_entry_safe(node, tmpnode, &hwreq->tds, td) {
1494 kfree(hwreq);
1532 struct ci_hw_req *hwreq = container_of(req, struct ci_hw_req, req);
1536 if (ep == NULL || req == NULL || hwreq->req.status != -EALREADY ||
1537 hwep->ep.desc == NULL || list_empty(&hwreq->queue) ||
1545 list_for_each_entry_safe(node, tmpnode, &hwreq->tds, td) {
1552 list_del_init(&hwreq->queue);
1558 if (hwreq->req.complete != NULL) {
1560 usb_gadget_giveback_request(&hwep->ep, &hwreq->req);