mirror of https://gitee.com/openkylin/linux.git
usb: dwc3: gadget: Return the number of prepared TRBs
In preparation for fixing the check for number of remaining TRBs, revise dwc3_prepare_one_trb_linear() and dwc3_prepare_one_trb_sg() to return the number of prepared TRBs. Signed-off-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com> Signed-off-by: Felipe Balbi <balbi@kernel.org>
This commit is contained in:
parent
66706077dc
commit
13111fcb0d
|
@ -1094,7 +1094,7 @@ static void dwc3_prepare_one_trb(struct dwc3_ep *dep,
|
|||
stream_id, short_not_ok, no_interrupt, is_last);
|
||||
}
|
||||
|
||||
static void dwc3_prepare_one_trb_sg(struct dwc3_ep *dep,
|
||||
static int dwc3_prepare_one_trb_sg(struct dwc3_ep *dep,
|
||||
struct dwc3_request *req)
|
||||
{
|
||||
struct scatterlist *sg = req->start_sg;
|
||||
|
@ -1105,6 +1105,7 @@ static void dwc3_prepare_one_trb_sg(struct dwc3_ep *dep,
|
|||
unsigned int rem = length % maxp;
|
||||
unsigned int remaining = req->request.num_mapped_sgs
|
||||
- req->num_queued_sgs;
|
||||
unsigned int num_trbs = req->num_trbs;
|
||||
|
||||
/*
|
||||
* If we resume preparing the request, then get the remaining length of
|
||||
|
@ -1131,9 +1132,15 @@ static void dwc3_prepare_one_trb_sg(struct dwc3_ep *dep,
|
|||
if ((i == remaining - 1) || !length)
|
||||
chain = false;
|
||||
|
||||
if (!dwc3_calc_trbs_left(dep))
|
||||
break;
|
||||
|
||||
if (rem && usb_endpoint_dir_out(dep->endpoint.desc) && !chain) {
|
||||
/* prepare normal TRB */
|
||||
if (req->request.length) {
|
||||
if (dwc3_calc_trbs_left(dep) < 2)
|
||||
goto out;
|
||||
|
||||
req->needs_extra_trb = true;
|
||||
dwc3_prepare_one_trb(dep, req, trb_length,
|
||||
true, i, false);
|
||||
|
@ -1145,6 +1152,10 @@ static void dwc3_prepare_one_trb_sg(struct dwc3_ep *dep,
|
|||
} else if (req->request.zero && req->request.length &&
|
||||
!usb_endpoint_xfer_isoc(dep->endpoint.desc) &&
|
||||
!rem && !chain) {
|
||||
|
||||
if (dwc3_calc_trbs_left(dep) < 2)
|
||||
goto out;
|
||||
|
||||
req->needs_extra_trb = true;
|
||||
|
||||
/* Prepare normal TRB */
|
||||
|
@ -1185,18 +1196,28 @@ static void dwc3_prepare_one_trb_sg(struct dwc3_ep *dep,
|
|||
if (!dwc3_calc_trbs_left(dep))
|
||||
break;
|
||||
}
|
||||
|
||||
out:
|
||||
return req->num_trbs - num_trbs;
|
||||
}
|
||||
|
||||
static void dwc3_prepare_one_trb_linear(struct dwc3_ep *dep,
|
||||
static int dwc3_prepare_one_trb_linear(struct dwc3_ep *dep,
|
||||
struct dwc3_request *req)
|
||||
{
|
||||
unsigned int length = req->request.length;
|
||||
unsigned int maxp = usb_endpoint_maxp(dep->endpoint.desc);
|
||||
unsigned int rem = length % maxp;
|
||||
unsigned int num_trbs = req->num_trbs;
|
||||
|
||||
if (!dwc3_calc_trbs_left(dep))
|
||||
goto out;
|
||||
|
||||
if ((!length || rem) && usb_endpoint_dir_out(dep->endpoint.desc)) {
|
||||
/* prepare normal TRB */
|
||||
if (req->request.length) {
|
||||
if (dwc3_calc_trbs_left(dep) < 2)
|
||||
goto out;
|
||||
|
||||
req->needs_extra_trb = true;
|
||||
dwc3_prepare_one_trb(dep, req, length, true, 0, false);
|
||||
}
|
||||
|
@ -1206,6 +1227,10 @@ static void dwc3_prepare_one_trb_linear(struct dwc3_ep *dep,
|
|||
} else if (req->request.zero && req->request.length &&
|
||||
!usb_endpoint_xfer_isoc(dep->endpoint.desc) &&
|
||||
(IS_ALIGNED(req->request.length, maxp))) {
|
||||
|
||||
if (dwc3_calc_trbs_left(dep) < 2)
|
||||
goto out;
|
||||
|
||||
req->needs_extra_trb = true;
|
||||
|
||||
/* prepare normal TRB */
|
||||
|
@ -1215,8 +1240,14 @@ static void dwc3_prepare_one_trb_linear(struct dwc3_ep *dep,
|
|||
dwc3_prepare_one_trb(dep, req, req->direction ? 0 : maxp,
|
||||
false, 1, true);
|
||||
} else {
|
||||
if (!dwc3_calc_trbs_left(dep))
|
||||
goto out;
|
||||
|
||||
dwc3_prepare_one_trb(dep, req, length, false, 0, false);
|
||||
}
|
||||
|
||||
out:
|
||||
return req->num_trbs - num_trbs;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue