/*
* packet info function
*/
-void usbhs_pkt_update(struct usbhs_pkt *pkt,
- struct usbhs_pipe *pipe,
- void *buf, int len)
+void usbhs_pkt_init(struct usbhs_pkt *pkt)
+{
+ INIT_LIST_HEAD(&pkt->node);
+}
+
+void usbhs_pkt_update(struct usbhs_pkt *pkt, void *buf, int len)
{
- pkt->pipe = pipe;
pkt->buf = buf;
pkt->length = len;
pkt->actual = 0;
pkt->maxp = 0;
}
+void usbhs_pkt_push(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt)
+{
+ list_del_init(&pkt->node);
+ list_add_tail(&pkt->node, &pipe->list);
+
+ pkt->pipe = pipe;
+}
+
+void usbhs_pkt_pop(struct usbhs_pkt *pkt)
+{
+ list_del_init(&pkt->node);
+}
+
+struct usbhs_pkt *usbhs_pkt_get(struct usbhs_pipe *pipe)
+{
+ if (list_empty(&pipe->list))
+ return NULL;
+
+ return list_entry(pipe->list.next, struct usbhs_pkt, node);
+}
+
/*
* FIFO ctrl
*/
*/
struct usbhsg_request {
struct usb_request req;
- struct list_head node;
struct usbhs_pkt pkt;
};
struct usbhsg_uep {
struct usb_ep ep;
struct usbhs_pipe *pipe;
- struct list_head list;
char ep_name[EP_NAME_SIZE];
struct usbhsg_gpriv *gpriv = usbhsg_uep_to_gpriv(uep);
struct device *dev = usbhsg_gpriv_to_dev(gpriv);
struct usbhs_pipe *pipe = usbhsg_uep_to_pipe(uep);
+ struct usbhs_pkt *pkt = usbhsg_ureq_to_pkt(ureq);
/*
********* assume under spin lock *********
*/
- list_del_init(&ureq->node);
- list_add_tail(&ureq->node, &uep->list);
+ usbhs_pkt_push(pipe, pkt);
ureq->req.actual = 0;
ureq->req.status = -EINPROGRESS;
static struct usbhsg_request *usbhsg_queue_get(struct usbhsg_uep *uep)
{
+ struct usbhs_pipe *pipe = usbhsg_uep_to_pipe(uep);
+ struct usbhs_pkt *pkt = usbhs_pkt_get(pipe);
+
/*
********* assume under spin lock *********
*/
- if (list_empty(&uep->list))
- return NULL;
+ if (!pkt)
+ return 0;
- return list_entry(uep->list.next, struct usbhsg_request, node);
+ return usbhsg_pkt_to_ureq(pkt);
}
#define usbhsg_queue_prepare(uep) __usbhsg_queue_handler(uep, 1);
struct usbhsg_gpriv *gpriv = usbhsg_uep_to_gpriv(uep);
struct usbhs_pipe *pipe = usbhsg_uep_to_pipe(uep);
struct device *dev = usbhsg_gpriv_to_dev(gpriv);
+ struct usbhs_pkt *pkt = usbhsg_ureq_to_pkt(ureq);
/*
********* assume under spin lock *********
dev_dbg(dev, "pipe %d : queue pop\n", usbhs_pipe_number(pipe));
- list_del_init(&ureq->node);
+ usbhs_pkt_pop(pkt);
ureq->req.status = status;
ureq->req.complete(&uep->ep, &ureq->req);
static int usbhsg_try_run_send_packet(struct usbhsg_uep *uep,
struct usbhsg_request *ureq)
{
- struct usbhs_pipe *pipe = usbhsg_uep_to_pipe(uep);
struct usb_request *req = &ureq->req;
struct usbhs_pkt *pkt = usbhsg_ureq_to_pkt(ureq);
int ret;
********* assume under spin lock *********
*/
- usbhs_pkt_update(pkt, pipe,
+ usbhs_pkt_update(pkt,
req->buf + req->actual,
req->length - req->actual);
static int usbhsg_try_run_receive_packet(struct usbhsg_uep *uep,
struct usbhsg_request *ureq)
{
- struct usbhs_pipe *pipe = usbhsg_uep_to_pipe(uep);
struct usb_request *req = &ureq->req;
struct usbhs_pkt *pkt = usbhsg_ureq_to_pkt(ureq);
********* assume under spin lock *********
*/
- usbhs_pkt_update(pkt, pipe,
+ usbhs_pkt_update(pkt,
req->buf + req->actual,
req->length - req->actual);
uep->pipe = pipe;
uep->pipe->mod_private = uep;
- INIT_LIST_HEAD(&uep->list);
return 0;
}
if (pipe) {
uep->pipe = pipe;
pipe->mod_private = uep;
- INIT_LIST_HEAD(&uep->list);
if (usb_endpoint_dir_in(desc))
uep->handler = &usbhsg_handler_send_packet;
if (!ureq)
return NULL;
- INIT_LIST_HEAD(&ureq->node);
+ usbhs_pkt_init(usbhsg_ureq_to_pkt(ureq));
+
return &ureq->req;
}
{
struct usbhsg_request *ureq = usbhsg_req_to_ureq(req);
- WARN_ON(!list_empty(&ureq->node));
+ WARN_ON(!list_empty(&ureq->pkt.node));
kfree(ureq);
}
uep->ep.name = uep->ep_name;
uep->ep.ops = &usbhsg_ep_ops;
INIT_LIST_HEAD(&uep->ep.ep_list);
- INIT_LIST_HEAD(&uep->list);
/* init DCP */
if (usbhsg_is_dcp(uep)) {