usb: dwc3: better name for our request management lists
authorFelipe Balbi <felipe.balbi@linux.intel.com>
Mon, 14 Mar 2016 09:01:31 +0000 (11:01 +0200)
committerFelipe Balbi <felipe.balbi@linux.intel.com>
Thu, 14 Apr 2016 06:24:38 +0000 (09:24 +0300)
request_list and req_queued were, well, weird naming
choices.

Let's give those better names and call them,
respectively, pending_list and started_list. These
new names better reflect what these lists are
supposed to do.

While at that also rename req->queued to req->started.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
drivers/usb/dwc3/core.h
drivers/usb/dwc3/ep0.c
drivers/usb/dwc3/gadget.c
drivers/usb/dwc3/gadget.h

index 5e17c02d3e924fec7bb7223dea0ab1b26f737483..4ea4b51688c11434d96c7f76318b9ab3efd1136b 100644 (file)
@@ -444,8 +444,8 @@ struct dwc3_event_buffer {
 /**
  * struct dwc3_ep - device side endpoint representation
  * @endpoint: usb endpoint
- * @request_list: list of requests for this endpoint
- * @req_queued: list of requests on this ep which have TRBs setup
+ * @pending_list: list of pending requests for this endpoint
+ * @started_list: list of started requests on this endpoint
  * @trb_pool: array of transaction buffers
  * @trb_pool_dma: dma address of @trb_pool
  * @free_slot: next slot which is going to be used
@@ -464,8 +464,8 @@ struct dwc3_event_buffer {
  */
 struct dwc3_ep {
        struct usb_ep           endpoint;
-       struct list_head        request_list;
-       struct list_head        req_queued;
+       struct list_head        pending_list;
+       struct list_head        started_list;
 
        struct dwc3_trb         *trb_pool;
        dma_addr_t              trb_pool_dma;
@@ -635,7 +635,7 @@ struct dwc3_request {
 
        unsigned                direction:1;
        unsigned                mapped:1;
-       unsigned                queued:1;
+       unsigned                started:1;
 };
 
 /*
index 4454de0d810c976c4f6cba08c58b15f4006a572c..5e0a21b65053651aa69c19b9fed940781c31dcce 100644 (file)
@@ -124,7 +124,7 @@ static int __dwc3_gadget_ep0_queue(struct dwc3_ep *dep,
        req->request.status     = -EINPROGRESS;
        req->epnum              = dep->number;
 
-       list_add_tail(&req->list, &dep->request_list);
+       list_add_tail(&req->list, &dep->pending_list);
 
        /*
         * Gadget driver might not be quick enough to queue a request
@@ -240,7 +240,7 @@ int dwc3_gadget_ep0_queue(struct usb_ep *ep, struct usb_request *request,
        }
 
        /* we share one TRB for ep0/1 */
-       if (!list_empty(&dep->request_list)) {
+       if (!list_empty(&dep->pending_list)) {
                ret = -EBUSY;
                goto out;
        }
@@ -272,10 +272,10 @@ static void dwc3_ep0_stall_and_restart(struct dwc3 *dwc)
        dep->flags = DWC3_EP_ENABLED;
        dwc->delayed_status = false;
 
-       if (!list_empty(&dep->request_list)) {
+       if (!list_empty(&dep->pending_list)) {
                struct dwc3_request     *req;
 
-               req = next_request(&dep->request_list);
+               req = next_request(&dep->pending_list);
                dwc3_gadget_giveback(dep, req, -ECONNRESET);
        }
 
@@ -806,7 +806,7 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc,
 
        trace_dwc3_complete_trb(ep0, trb);
 
-       r = next_request(&ep0->request_list);
+       r = next_request(&ep0->pending_list);
        if (!r)
                return;
 
@@ -894,8 +894,8 @@ static void dwc3_ep0_complete_status(struct dwc3 *dwc,
 
        trace_dwc3_complete_trb(dep, trb);
 
-       if (!list_empty(&dep->request_list)) {
-               r = next_request(&dep->request_list);
+       if (!list_empty(&dep->pending_list)) {
+               r = next_request(&dep->pending_list);
 
                dwc3_gadget_giveback(dep, r, 0);
        }
index 28d512a65ada54f2571a660d03a8e551c9f6344e..e6bd3a976ad9a1d9d9f4e9d4fa3eee009299f334 100644 (file)
@@ -151,7 +151,7 @@ void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req,
        struct dwc3                     *dwc = dep->dwc;
        int                             i;
 
-       if (req->queued) {
+       if (req->started) {
                i = 0;
                do {
                        dep->busy_slot++;
@@ -165,7 +165,7 @@ void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req,
                                usb_endpoint_xfer_isoc(dep->endpoint.desc))
                                dep->busy_slot++;
                } while(++i < req->request.num_mapped_sgs);
-               req->queued = false;
+               req->started = false;
        }
        list_del(&req->list);
        req->trb = NULL;
@@ -522,19 +522,19 @@ static void dwc3_remove_requests(struct dwc3 *dwc, struct dwc3_ep *dep)
 {
        struct dwc3_request             *req;
 
-       if (!list_empty(&dep->req_queued)) {
+       if (!list_empty(&dep->started_list)) {
                dwc3_stop_active_transfer(dwc, dep->number, true);
 
                /* - giveback all requests to gadget driver */
-               while (!list_empty(&dep->req_queued)) {
-                       req = next_request(&dep->req_queued);
+               while (!list_empty(&dep->started_list)) {
+                       req = next_request(&dep->started_list);
 
                        dwc3_gadget_giveback(dep, req, -ESHUTDOWN);
                }
        }
 
-       while (!list_empty(&dep->request_list)) {
-               req = next_request(&dep->request_list);
+       while (!list_empty(&dep->pending_list)) {
+               req = next_request(&dep->pending_list);
 
                dwc3_gadget_giveback(dep, req, -ESHUTDOWN);
        }
@@ -700,7 +700,7 @@ static void dwc3_prepare_one_trb(struct dwc3_ep *dep,
        trb = &dep->trb_pool[dep->free_slot & DWC3_TRB_MASK];
 
        if (!req->trb) {
-               dwc3_gadget_move_request_queued(req);
+               dwc3_gadget_move_started_request(req);
                req->trb = trb;
                req->trb_dma = dwc3_trb_dma_offset(dep, trb);
                req->start_slot = dep->free_slot & DWC3_TRB_MASK;
@@ -824,7 +824,7 @@ static void dwc3_prepare_trbs(struct dwc3_ep *dep, bool starting)
        if ((trbs_left <= 1) && usb_endpoint_xfer_isoc(dep->endpoint.desc))
                return;
 
-       list_for_each_entry_safe(req, n, &dep->request_list, list) {
+       list_for_each_entry_safe(req, n, &dep->pending_list, list) {
                unsigned        length;
                dma_addr_t      dma;
                last_one = false;
@@ -843,7 +843,7 @@ static void dwc3_prepare_trbs(struct dwc3_ep *dep, bool starting)
 
                                if (i == (request->num_mapped_sgs - 1) ||
                                                sg_is_last(s)) {
-                                       if (list_empty(&dep->request_list))
+                                       if (list_empty(&dep->pending_list))
                                                last_one = true;
                                        chain = false;
                                }
@@ -873,7 +873,7 @@ static void dwc3_prepare_trbs(struct dwc3_ep *dep, bool starting)
                                last_one = 1;
 
                        /* Is this the last request? */
-                       if (list_is_last(&req->list, &dep->request_list))
+                       if (list_is_last(&req->list, &dep->pending_list))
                                last_one = 1;
 
                        dwc3_prepare_one_trb(dep, req, dma, length,
@@ -904,18 +904,18 @@ static int __dwc3_gadget_kick_transfer(struct dwc3_ep *dep, u16 cmd_param,
         * new requests as we try to set the IOC bit only on the last request.
         */
        if (start_new) {
-               if (list_empty(&dep->req_queued))
+               if (list_empty(&dep->started_list))
                        dwc3_prepare_trbs(dep, start_new);
 
                /* req points to the first request which will be sent */
-               req = next_request(&dep->req_queued);
+               req = next_request(&dep->started_list);
        } else {
                dwc3_prepare_trbs(dep, start_new);
 
                /*
                 * req points to the first request where HWO changed from 0 to 1
                 */
-               req = next_request(&dep->req_queued);
+               req = next_request(&dep->started_list);
        }
        if (!req) {
                dep->flags |= DWC3_EP_PENDING_REQUEST;
@@ -962,7 +962,7 @@ static void __dwc3_gadget_start_isoc(struct dwc3 *dwc,
 {
        u32 uf;
 
-       if (list_empty(&dep->request_list)) {
+       if (list_empty(&dep->pending_list)) {
                dwc3_trace(trace_dwc3_gadget,
                                "ISOC ep %s run out for requests",
                                dep->name);
@@ -1030,7 +1030,7 @@ static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, struct dwc3_request *req)
        if (ret)
                return ret;
 
-       list_add_tail(&req->list, &dep->request_list);
+       list_add_tail(&req->list, &dep->pending_list);
 
        /*
         * If there are no pending requests and the endpoint isn't already
@@ -1065,7 +1065,7 @@ static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, struct dwc3_request *req)
                 * notion of current microframe.
                 */
                if (usb_endpoint_xfer_isoc(dep->endpoint.desc)) {
-                       if (list_empty(&dep->req_queued)) {
+                       if (list_empty(&dep->started_list)) {
                                dwc3_stop_active_transfer(dwc, dep->number, true);
                                dep->flags = DWC3_EP_ENABLED;
                        }
@@ -1183,13 +1183,13 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep,
 
        spin_lock_irqsave(&dwc->lock, flags);
 
-       list_for_each_entry(r, &dep->request_list, list) {
+       list_for_each_entry(r, &dep->pending_list, list) {
                if (r == req)
                        break;
        }
 
        if (r != req) {
-               list_for_each_entry(r, &dep->req_queued, list) {
+               list_for_each_entry(r, &dep->started_list, list) {
                        if (r == req)
                                break;
                }
@@ -1229,8 +1229,8 @@ int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value, int protocol)
 
        if (value) {
                if (!protocol && ((dep->direction && dep->flags & DWC3_EP_BUSY) ||
-                               (!list_empty(&dep->req_queued) ||
-                                !list_empty(&dep->request_list)))) {
+                               (!list_empty(&dep->started_list) ||
+                                !list_empty(&dep->pending_list)))) {
                        dwc3_trace(trace_dwc3_gadget,
                                        "%s: pending request, cannot halt\n",
                                        dep->name);
@@ -1731,8 +1731,8 @@ static int dwc3_gadget_init_hw_endpoints(struct dwc3 *dwc,
                dep->endpoint.caps.dir_in = !!direction;
                dep->endpoint.caps.dir_out = !direction;
 
-               INIT_LIST_HEAD(&dep->request_list);
-               INIT_LIST_HEAD(&dep->req_queued);
+               INIT_LIST_HEAD(&dep->pending_list);
+               INIT_LIST_HEAD(&dep->started_list);
        }
 
        return 0;
@@ -1829,11 +1829,11 @@ static int __dwc3_cleanup_done_trbs(struct dwc3 *dwc, struct dwc3_ep *dep,
                                 * If there are still queued request
                                 * then wait, do not issue either END
                                 * or UPDATE TRANSFER, just attach next
-                                * request in request_list during
+                                * request in pending_list during
                                 * giveback.If any future queued request
                                 * is successfully transferred then we
                                 * will issue UPDATE TRANSFER for all
-                                * request in the request_list.
+                                * request in the pending_list.
                                 */
                                dep->flags |= DWC3_EP_MISSED_ISOC;
                        } else {
@@ -1879,7 +1879,7 @@ static int dwc3_cleanup_done_reqs(struct dwc3 *dwc, struct dwc3_ep *dep,
        int                     ret;
 
        do {
-               req = next_request(&dep->req_queued);
+               req = next_request(&dep->started_list);
                if (WARN_ON_ONCE(!req))
                        return 1;
 
@@ -1905,8 +1905,8 @@ static int dwc3_cleanup_done_reqs(struct dwc3 *dwc, struct dwc3_ep *dep,
        } while (1);
 
        if (usb_endpoint_xfer_isoc(dep->endpoint.desc) &&
-                       list_empty(&dep->req_queued)) {
-               if (list_empty(&dep->request_list)) {
+                       list_empty(&dep->started_list)) {
+               if (list_empty(&dep->pending_list)) {
                        /*
                         * If there is no entry in request list then do
                         * not issue END TRANSFER now. Just set PENDING
@@ -1955,7 +1955,7 @@ static void dwc3_endpoint_transfer_complete(struct dwc3 *dwc,
                        if (!(dep->flags & DWC3_EP_ENABLED))
                                continue;
 
-                       if (!list_empty(&dep->req_queued))
+                       if (!list_empty(&dep->started_list))
                                return;
                }
 
index 18ae3eaa8b6fe476d83d89374141399cbbe1302f..f21c0fccbebdf92545c9f1ff7b8ae6415acc130b 100644 (file)
@@ -68,12 +68,12 @@ static inline struct dwc3_request *next_request(struct list_head *list)
        return list_first_entry(list, struct dwc3_request, list);
 }
 
-static inline void dwc3_gadget_move_request_queued(struct dwc3_request *req)
+static inline void dwc3_gadget_move_started_request(struct dwc3_request *req)
 {
        struct dwc3_ep          *dep = req->dep;
 
-       req->queued = true;
-       list_move_tail(&req->list, &dep->req_queued);
+       req->started = true;
+       list_move_tail(&req->list, &dep->started_list);
 }
 
 void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req,