提交 b331872b 编写于 作者: K Kuninori Morimoto 提交者: Felipe Balbi

usb: gadget: renesas_usbhs: move done callback to struct usbhs_pkt

transfer done function was registered in struct struct usbhs_pipe_info.
It was good for mod_gadget, but not good for mod_host.
This function move it to struct usbhs_pkt.
Signed-off-by: NKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: NFelipe Balbi <balbi@ti.com>
上级 3cf8ed12
...@@ -54,6 +54,8 @@ static struct usbhs_pkt_handle usbhsf_null_handler = { ...@@ -54,6 +54,8 @@ static struct usbhs_pkt_handle usbhsf_null_handler = {
}; };
void usbhs_pkt_push(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt, void usbhs_pkt_push(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt,
void (*done)(struct usbhs_priv *priv,
struct usbhs_pkt *pkt),
void *buf, int len, int zero) void *buf, int len, int zero)
{ {
struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe); struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe);
...@@ -63,6 +65,11 @@ void usbhs_pkt_push(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt, ...@@ -63,6 +65,11 @@ void usbhs_pkt_push(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt,
/******************** spin lock ********************/ /******************** spin lock ********************/
usbhs_lock(priv, flags); usbhs_lock(priv, flags);
if (!done) {
dev_err(dev, "no done function\n");
return;
}
if (!pipe->handler) { if (!pipe->handler) {
dev_err(dev, "no handler function\n"); dev_err(dev, "no handler function\n");
pipe->handler = &usbhsf_null_handler; pipe->handler = &usbhsf_null_handler;
...@@ -82,6 +89,7 @@ void usbhs_pkt_push(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt, ...@@ -82,6 +89,7 @@ void usbhs_pkt_push(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt,
pkt->length = len; pkt->length = len;
pkt->zero = zero; pkt->zero = zero;
pkt->actual = 0; pkt->actual = 0;
pkt->done = done;
usbhs_unlock(priv, flags); usbhs_unlock(priv, flags);
/******************** spin unlock ******************/ /******************** spin unlock ******************/
...@@ -131,7 +139,6 @@ enum { ...@@ -131,7 +139,6 @@ enum {
static int usbhsf_pkt_handler(struct usbhs_pipe *pipe, int type) static int usbhsf_pkt_handler(struct usbhs_pipe *pipe, int type)
{ {
struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe); struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe);
struct usbhs_pipe_info *info = usbhs_priv_to_pipeinfo(priv);
struct usbhs_pkt *pkt; struct usbhs_pkt *pkt;
struct device *dev = usbhs_priv_to_dev(priv); struct device *dev = usbhs_priv_to_dev(priv);
int (*func)(struct usbhs_pkt *pkt, int *is_done); int (*func)(struct usbhs_pkt *pkt, int *is_done);
...@@ -171,7 +178,7 @@ static int usbhsf_pkt_handler(struct usbhs_pipe *pipe, int type) ...@@ -171,7 +178,7 @@ static int usbhsf_pkt_handler(struct usbhs_pipe *pipe, int type)
/******************** spin unlock ******************/ /******************** spin unlock ******************/
if (is_done) { if (is_done) {
info->done(priv, pkt); pkt->done(priv, pkt);
usbhs_pkt_start(pipe); usbhs_pkt_start(pipe);
} }
......
...@@ -51,6 +51,8 @@ struct usbhs_pkt { ...@@ -51,6 +51,8 @@ struct usbhs_pkt {
struct list_head node; struct list_head node;
struct usbhs_pipe *pipe; struct usbhs_pipe *pipe;
struct usbhs_pkt_handle *handler; struct usbhs_pkt_handle *handler;
void (*done)(struct usbhs_priv *priv,
struct usbhs_pkt *pkt);
dma_addr_t dma; dma_addr_t dma;
void *buf; void *buf;
int length; int length;
...@@ -86,6 +88,8 @@ extern struct usbhs_pkt_handle usbhs_fifo_dma_pop_handler; ...@@ -86,6 +88,8 @@ extern struct usbhs_pkt_handle usbhs_fifo_dma_pop_handler;
void usbhs_pkt_init(struct usbhs_pkt *pkt); void usbhs_pkt_init(struct usbhs_pkt *pkt);
void usbhs_pkt_push(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt, void usbhs_pkt_push(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt,
void (*done)(struct usbhs_priv *priv,
struct usbhs_pkt *pkt),
void *buf, int len, int zero); void *buf, int len, int zero);
struct usbhs_pkt *usbhs_pkt_pop(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt); struct usbhs_pkt *usbhs_pkt_pop(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt);
void usbhs_pkt_start(struct usbhs_pipe *pipe); void usbhs_pkt_start(struct usbhs_pipe *pipe);
......
...@@ -127,24 +127,6 @@ LIST_HEAD(the_controller_link); ...@@ -127,24 +127,6 @@ LIST_HEAD(the_controller_link);
/* /*
* queue push/pop * queue push/pop
*/ */
static void usbhsg_queue_push(struct usbhsg_uep *uep,
struct usbhsg_request *ureq)
{
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);
struct usb_request *req = &ureq->req;
req->actual = 0;
req->status = -EINPROGRESS;
usbhs_pkt_push(pipe, pkt, req->buf, req->length, req->zero);
dev_dbg(dev, "pipe %d : queue push (%d)\n",
usbhs_pipe_number(pipe),
req->length);
}
static void usbhsg_queue_pop(struct usbhsg_uep *uep, static void usbhsg_queue_pop(struct usbhsg_uep *uep,
struct usbhsg_request *ureq, struct usbhsg_request *ureq,
int status) int status)
...@@ -170,6 +152,25 @@ static void usbhsg_queue_done(struct usbhs_priv *priv, struct usbhs_pkt *pkt) ...@@ -170,6 +152,25 @@ static void usbhsg_queue_done(struct usbhs_priv *priv, struct usbhs_pkt *pkt)
usbhsg_queue_pop(uep, ureq, 0); usbhsg_queue_pop(uep, ureq, 0);
} }
static void usbhsg_queue_push(struct usbhsg_uep *uep,
struct usbhsg_request *ureq)
{
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);
struct usb_request *req = &ureq->req;
req->actual = 0;
req->status = -EINPROGRESS;
usbhs_pkt_push(pipe, pkt, usbhsg_queue_done,
req->buf, req->length, req->zero);
dev_dbg(dev, "pipe %d : queue push (%d)\n",
usbhs_pipe_number(pipe),
req->length);
}
/* /*
* dma map/unmap * dma map/unmap
*/ */
...@@ -664,7 +665,6 @@ static int usbhsg_try_start(struct usbhs_priv *priv, u32 status) ...@@ -664,7 +665,6 @@ static int usbhsg_try_start(struct usbhs_priv *priv, u32 status)
* pipe initialize and enable DCP * pipe initialize and enable DCP
*/ */
usbhs_pipe_init(priv, usbhs_pipe_init(priv,
usbhsg_queue_done,
usbhsg_dma_map_ctrl); usbhsg_dma_map_ctrl);
usbhs_fifo_init(priv); usbhs_fifo_init(priv);
usbhsg_uep_init(gpriv); usbhsg_uep_init(gpriv);
......
...@@ -514,20 +514,12 @@ static struct usbhs_pipe *usbhsp_get_pipe(struct usbhs_priv *priv, u32 type) ...@@ -514,20 +514,12 @@ static struct usbhs_pipe *usbhsp_get_pipe(struct usbhs_priv *priv, u32 type)
} }
void usbhs_pipe_init(struct usbhs_priv *priv, void usbhs_pipe_init(struct usbhs_priv *priv,
void (*done)(struct usbhs_priv *priv,
struct usbhs_pkt *pkt),
int (*dma_map_ctrl)(struct usbhs_pkt *pkt, int map)) int (*dma_map_ctrl)(struct usbhs_pkt *pkt, int map))
{ {
struct usbhs_pipe_info *info = usbhs_priv_to_pipeinfo(priv); struct usbhs_pipe_info *info = usbhs_priv_to_pipeinfo(priv);
struct device *dev = usbhs_priv_to_dev(priv);
struct usbhs_pipe *pipe; struct usbhs_pipe *pipe;
int i; int i;
if (!done) {
dev_err(dev, "no done function\n");
return;
}
/* /*
* FIXME * FIXME
* *
...@@ -554,7 +546,6 @@ void usbhs_pipe_init(struct usbhs_priv *priv, ...@@ -554,7 +546,6 @@ void usbhs_pipe_init(struct usbhs_priv *priv,
usbhs_pipe_clear(pipe); usbhs_pipe_clear(pipe);
} }
info->done = done;
info->dma_map_ctrl = dma_map_ctrl; info->dma_map_ctrl = dma_map_ctrl;
} }
......
...@@ -47,7 +47,6 @@ struct usbhs_pipe_info { ...@@ -47,7 +47,6 @@ struct usbhs_pipe_info {
int size; /* array size of "pipe" */ int size; /* array size of "pipe" */
int bufnmb_last; /* FIXME : driver needs good allocator */ int bufnmb_last; /* FIXME : driver needs good allocator */
void (*done)(struct usbhs_priv *priv, struct usbhs_pkt *pkt);
int (*dma_map_ctrl)(struct usbhs_pkt *pkt, int map); int (*dma_map_ctrl)(struct usbhs_pkt *pkt, int map);
}; };
...@@ -81,8 +80,6 @@ void usbhs_pipe_remove(struct usbhs_priv *priv); ...@@ -81,8 +80,6 @@ void usbhs_pipe_remove(struct usbhs_priv *priv);
int usbhs_pipe_is_dir_in(struct usbhs_pipe *pipe); int usbhs_pipe_is_dir_in(struct usbhs_pipe *pipe);
int usbhs_pipe_is_dir_host(struct usbhs_pipe *pipe); int usbhs_pipe_is_dir_host(struct usbhs_pipe *pipe);
void usbhs_pipe_init(struct usbhs_priv *priv, void usbhs_pipe_init(struct usbhs_priv *priv,
void (*done)(struct usbhs_priv *priv,
struct usbhs_pkt *pkt),
int (*dma_map_ctrl)(struct usbhs_pkt *pkt, int map)); int (*dma_map_ctrl)(struct usbhs_pkt *pkt, int map));
int usbhs_pipe_get_maxpacket(struct usbhs_pipe *pipe); int usbhs_pipe_get_maxpacket(struct usbhs_pipe *pipe);
void usbhs_pipe_clear_sequence(struct usbhs_pipe *pipe); void usbhs_pipe_clear_sequence(struct usbhs_pipe *pipe);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册