Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 259206
b: refs/heads/master
c: 6acb95d
h: refs/heads/master
v: v3
  • Loading branch information
Kuninori Morimoto authored and Greg Kroah-Hartman committed Jun 7, 2011
1 parent becf44f commit 7eeef28
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 25 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 4bd0481152d0d5e8326d7e24329b0069713ed718
refs/heads/master: 6acb95d4e0709a582023e87f9b3537fb4d837fd0
31 changes: 27 additions & 4 deletions trunk/drivers/usb/renesas_usbhs/fifo.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,40 @@
/*
* 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
*/
Expand Down
9 changes: 6 additions & 3 deletions trunk/drivers/usb/renesas_usbhs/fifo.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "pipe.h"

struct usbhs_pkt {
struct list_head node;
struct usbhs_pipe *pipe;
int maxp;
void *buf;
Expand All @@ -38,8 +39,10 @@ int usbhs_fifo_prepare_read(struct usbhs_pipe *pipe);
/*
* packet info
*/
void usbhs_pkt_update(struct usbhs_pkt *pkt,
struct usbhs_pipe *pipe,
void *buf, int len);
void usbhs_pkt_init(struct usbhs_pkt *pkt);
void usbhs_pkt_update(struct usbhs_pkt *pkt, void *buf, int len);
void usbhs_pkt_push(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt);
void usbhs_pkt_pop(struct usbhs_pkt *pkt);
struct usbhs_pkt *usbhs_pkt_get(struct usbhs_pipe *pipe);

#endif /* RENESAS_USB_FIFO_H */
32 changes: 15 additions & 17 deletions trunk/drivers/usb/renesas_usbhs/mod_gadget.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
*/
struct usbhsg_request {
struct usb_request req;
struct list_head node;
struct usbhs_pkt pkt;
};

Expand All @@ -36,7 +35,6 @@ struct usbhsg_pipe_handle;
struct usbhsg_uep {
struct usb_ep ep;
struct usbhs_pipe *pipe;
struct list_head list;

char ep_name[EP_NAME_SIZE];

Expand Down Expand Up @@ -161,12 +159,12 @@ static void usbhsg_queue_push(struct usbhsg_uep *uep,
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;

Expand All @@ -177,13 +175,16 @@ static void usbhsg_queue_push(struct usbhsg_uep *uep,

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);
Expand Down Expand Up @@ -243,6 +244,7 @@ static void usbhsg_queue_pop(struct usbhsg_uep *uep,
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 *********
Expand All @@ -268,7 +270,7 @@ static void usbhsg_queue_pop(struct usbhsg_uep *uep,

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);
Expand Down Expand Up @@ -386,7 +388,6 @@ static void usbhsg_try_run_send_packet_bh(struct usbhs_pkt *pkt)
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;
Expand All @@ -395,7 +396,7 @@ static int usbhsg_try_run_send_packet(struct usbhsg_uep *uep,
********* assume under spin lock *********
*/

usbhs_pkt_update(pkt, pipe,
usbhs_pkt_update(pkt,
req->buf + req->actual,
req->length - req->actual);

Expand Down Expand Up @@ -473,15 +474,14 @@ static void usbhsg_try_run_receive_packet_bh(struct usbhs_pkt *pkt)
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);

Expand Down Expand Up @@ -814,7 +814,6 @@ static int usbhsg_dcp_enable(struct usbhsg_uep *uep)

uep->pipe = pipe;
uep->pipe->mod_private = uep;
INIT_LIST_HEAD(&uep->list);

return 0;
}
Expand Down Expand Up @@ -888,7 +887,6 @@ static int usbhsg_ep_enable(struct usb_ep *ep,
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;
Expand Down Expand Up @@ -932,7 +930,8 @@ static struct usb_request *usbhsg_ep_alloc_request(struct usb_ep *ep,
if (!ureq)
return NULL;

INIT_LIST_HEAD(&ureq->node);
usbhs_pkt_init(usbhsg_ureq_to_pkt(ureq));

return &ureq->req;
}

Expand All @@ -941,7 +940,7 @@ static void usbhsg_ep_free_request(struct usb_ep *ep,
{
struct usbhsg_request *ureq = usbhsg_req_to_ureq(req);

WARN_ON(!list_empty(&ureq->node));
WARN_ON(!list_empty(&ureq->pkt.node));
kfree(ureq);
}

Expand Down Expand Up @@ -1379,7 +1378,6 @@ int __devinit usbhs_mod_gadget_probe(struct usbhs_priv *priv)
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)) {
Expand Down
4 changes: 4 additions & 0 deletions trunk/drivers/usb/renesas_usbhs/pipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,7 @@ void usbhs_pipe_init(struct usbhs_priv *priv,

usbhsp_flags_init(pipe);
pipe->mod_private = NULL;
INIT_LIST_HEAD(&pipe->list);

/* pipe force init */
usbhsp_pipectrl_set(pipe, ACLRM, ACLRM);
Expand Down Expand Up @@ -585,6 +586,8 @@ struct usbhs_pipe *usbhs_pipe_malloc(struct usbhs_priv *priv,
return NULL;
}

INIT_LIST_HEAD(&pipe->list);

usbhs_pipe_disable(pipe);

/* make sure pipe is not busy */
Expand Down Expand Up @@ -632,6 +635,7 @@ struct usbhs_pipe *usbhs_dcp_malloc(struct usbhs_priv *priv)

usbhsp_pipe_select(pipe);
usbhs_pipe_clear_sequence(pipe);
INIT_LIST_HEAD(&pipe->list);

return pipe;
}
Expand Down
1 change: 1 addition & 0 deletions trunk/drivers/usb/renesas_usbhs/pipe.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ struct usbhs_pipe {
u32 pipe_type; /* USB_ENDPOINT_XFER_xxx */

struct usbhs_priv *priv;
struct list_head list;

u32 flags;
#define USBHS_PIPE_FLAGS_IS_USED (1 << 0)
Expand Down

0 comments on commit 7eeef28

Please sign in to comment.