[PATCH 3/5] xhci: Pass the 'ep_ring' to prepare_transfer()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



prepare_transfer() looks up the endpoint ring structure, however
the caller already knows it.

Save code and an error test that can never fail by passing the ring
address instead of the stream_id.

Signed-off-by: David Laight <david.laight@xxxxxxxxxx>
---
 drivers/usb/host/xhci-ring.c | 18 +++++-------------
 1 file changed, 5 insertions(+), 13 deletions(-)

diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index ae5d32c..c1ba8ca 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -3072,7 +3072,7 @@ static int prepare_ring(struct xhci_hcd *xhci, struct xhci_ring *ep_ring,
 static int prepare_transfer(struct xhci_hcd *xhci,
 		struct xhci_virt_device *xdev,
 		unsigned int ep_index,
-		unsigned int stream_id,
+		struct xhci_ring *ep_ring,
 		unsigned int num_trbs,
 		struct urb *urb,
 		unsigned int td_index,
@@ -3081,16 +3081,8 @@ static int prepare_transfer(struct xhci_hcd *xhci,
 	int ret;
 	struct urb_priv *urb_priv;
 	struct xhci_td	*td;
-	struct xhci_ring *ep_ring;
 	struct xhci_ep_ctx *ep_ctx = xhci_get_ep_ctx(xhci, xdev->out_ctx, ep_index);
 
-	ep_ring = xhci_stream_id_to_ring(xdev, ep_index, stream_id);
-	if (!ep_ring) {
-		xhci_dbg(xhci, "Can't prepare ring for bad stream ID %u\n",
-				stream_id);
-		return -EINVAL;
-	}
-
 	/* xhci_queue_isoc_tx_prepare() called prepare ring earlier. */
 	if (ep_ring->type != TYPE_ISOC) {
 		ret = prepare_ring(xhci, ep_ring,
@@ -3309,7 +3301,7 @@ static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
 			usb_endpoint_maxp(&urb->ep->desc));
 
 	trb_buff_len = prepare_transfer(xhci, xhci->devs[slot_id],
-			ep_index, urb->stream_id,
+			ep_index, ep_ring,
 			num_trbs, urb, 0, mem_flags);
 	if (trb_buff_len < 0)
 		return trb_buff_len;
@@ -3479,7 +3471,7 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
 	/* FIXME: this doesn't deal with URB_ZERO_PACKET - need one more */
 
 	ret = prepare_transfer(xhci, xhci->devs[slot_id],
-			ep_index, urb->stream_id,
+			ep_index, ep_ring,
 			num_trbs, urb, 0, mem_flags);
 	if (ret < 0)
 		return ret;
@@ -3608,7 +3600,7 @@ int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
 	if (urb->transfer_buffer_length > 0)
 		num_trbs++;
 	ret = prepare_transfer(xhci, xhci->devs[slot_id],
-			ep_index, urb->stream_id,
+			ep_index, ep_ring,
 			num_trbs, urb, 0, mem_flags);
 	if (ret < 0)
 		return ret;
@@ -3818,7 +3810,7 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
 		trbs_per_td = count_isoc_trbs_needed(xhci, urb, i);
 
 		ret = prepare_transfer(xhci, xhci->devs[slot_id], ep_index,
-				urb->stream_id, trbs_per_td, urb, i, mem_flags);
+				ep_ring, trbs_per_td, urb, i, mem_flags);
 		if (ret < 0)
 			/* This can only happen when for the first TD */
 			return ret;
-- 
1.8.1.2



--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux