aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2011-10-11 01:04:41 -0400
committerFelipe Balbi <balbi@ti.com>2011-10-13 13:41:44 -0400
commitb331872b85c2ab388129af3343474e02e89498af (patch)
tree2337bac307e1dc6998bb010b00a4fcc7b0015fd2
parent3cf8ed1284799406c506029207004e97d5b2c738 (diff)
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: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
-rw-r--r--drivers/usb/renesas_usbhs/fifo.c11
-rw-r--r--drivers/usb/renesas_usbhs/fifo.h4
-rw-r--r--drivers/usb/renesas_usbhs/mod_gadget.c38
-rw-r--r--drivers/usb/renesas_usbhs/pipe.c9
-rw-r--r--drivers/usb/renesas_usbhs/pipe.h3
5 files changed, 32 insertions, 33 deletions
diff --git a/drivers/usb/renesas_usbhs/fifo.c b/drivers/usb/renesas_usbhs/fifo.c
index 9bf3a437ea0b..8b40726ba966 100644
--- a/drivers/usb/renesas_usbhs/fifo.c
+++ b/drivers/usb/renesas_usbhs/fifo.c
@@ -54,6 +54,8 @@ static struct usbhs_pkt_handle usbhsf_null_handler = {
54}; 54};
55 55
56void usbhs_pkt_push(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt, 56void usbhs_pkt_push(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt,
57 void (*done)(struct usbhs_priv *priv,
58 struct usbhs_pkt *pkt),
57 void *buf, int len, int zero) 59 void *buf, int len, int zero)
58{ 60{
59 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe); 61 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 /******************** spin lock ********************/ 65 /******************** spin lock ********************/
64 usbhs_lock(priv, flags); 66 usbhs_lock(priv, flags);
65 67
68 if (!done) {
69 dev_err(dev, "no done function\n");
70 return;
71 }
72
66 if (!pipe->handler) { 73 if (!pipe->handler) {
67 dev_err(dev, "no handler function\n"); 74 dev_err(dev, "no handler function\n");
68 pipe->handler = &usbhsf_null_handler; 75 pipe->handler = &usbhsf_null_handler;
@@ -82,6 +89,7 @@ void usbhs_pkt_push(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt,
82 pkt->length = len; 89 pkt->length = len;
83 pkt->zero = zero; 90 pkt->zero = zero;
84 pkt->actual = 0; 91 pkt->actual = 0;
92 pkt->done = done;
85 93
86 usbhs_unlock(priv, flags); 94 usbhs_unlock(priv, flags);
87 /******************** spin unlock ******************/ 95 /******************** spin unlock ******************/
@@ -131,7 +139,6 @@ enum {
131static int usbhsf_pkt_handler(struct usbhs_pipe *pipe, int type) 139static int usbhsf_pkt_handler(struct usbhs_pipe *pipe, int type)
132{ 140{
133 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe); 141 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe);
134 struct usbhs_pipe_info *info = usbhs_priv_to_pipeinfo(priv);
135 struct usbhs_pkt *pkt; 142 struct usbhs_pkt *pkt;
136 struct device *dev = usbhs_priv_to_dev(priv); 143 struct device *dev = usbhs_priv_to_dev(priv);
137 int (*func)(struct usbhs_pkt *pkt, int *is_done); 144 int (*func)(struct usbhs_pkt *pkt, int *is_done);
@@ -171,7 +178,7 @@ __usbhs_pkt_handler_end:
171 /******************** spin unlock ******************/ 178 /******************** spin unlock ******************/
172 179
173 if (is_done) { 180 if (is_done) {
174 info->done(priv, pkt); 181 pkt->done(priv, pkt);
175 usbhs_pkt_start(pipe); 182 usbhs_pkt_start(pipe);
176 } 183 }
177 184
diff --git a/drivers/usb/renesas_usbhs/fifo.h b/drivers/usb/renesas_usbhs/fifo.h
index 60aa20fd303e..0e82d67a0257 100644
--- a/drivers/usb/renesas_usbhs/fifo.h
+++ b/drivers/usb/renesas_usbhs/fifo.h
@@ -51,6 +51,8 @@ struct usbhs_pkt {
51 struct list_head node; 51 struct list_head node;
52 struct usbhs_pipe *pipe; 52 struct usbhs_pipe *pipe;
53 struct usbhs_pkt_handle *handler; 53 struct usbhs_pkt_handle *handler;
54 void (*done)(struct usbhs_priv *priv,
55 struct usbhs_pkt *pkt);
54 dma_addr_t dma; 56 dma_addr_t dma;
55 void *buf; 57 void *buf;
56 int length; 58 int length;
@@ -86,6 +88,8 @@ extern struct usbhs_pkt_handle usbhs_fifo_dma_pop_handler;
86 88
87void usbhs_pkt_init(struct usbhs_pkt *pkt); 89void usbhs_pkt_init(struct usbhs_pkt *pkt);
88void usbhs_pkt_push(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt, 90void usbhs_pkt_push(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt,
91 void (*done)(struct usbhs_priv *priv,
92 struct usbhs_pkt *pkt),
89 void *buf, int len, int zero); 93 void *buf, int len, int zero);
90struct usbhs_pkt *usbhs_pkt_pop(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt); 94struct usbhs_pkt *usbhs_pkt_pop(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt);
91void usbhs_pkt_start(struct usbhs_pipe *pipe); 95void usbhs_pkt_start(struct usbhs_pipe *pipe);
diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c b/drivers/usb/renesas_usbhs/mod_gadget.c
index d5f80c4457e5..563128531e65 100644
--- a/drivers/usb/renesas_usbhs/mod_gadget.c
+++ b/drivers/usb/renesas_usbhs/mod_gadget.c
@@ -127,24 +127,6 @@ LIST_HEAD(the_controller_link);
127/* 127/*
128 * queue push/pop 128 * queue push/pop
129 */ 129 */
130static void usbhsg_queue_push(struct usbhsg_uep *uep,
131 struct usbhsg_request *ureq)
132{
133 struct usbhsg_gpriv *gpriv = usbhsg_uep_to_gpriv(uep);
134 struct device *dev = usbhsg_gpriv_to_dev(gpriv);
135 struct usbhs_pipe *pipe = usbhsg_uep_to_pipe(uep);
136 struct usbhs_pkt *pkt = usbhsg_ureq_to_pkt(ureq);
137 struct usb_request *req = &ureq->req;
138
139 req->actual = 0;
140 req->status = -EINPROGRESS;
141 usbhs_pkt_push(pipe, pkt, req->buf, req->length, req->zero);
142
143 dev_dbg(dev, "pipe %d : queue push (%d)\n",
144 usbhs_pipe_number(pipe),
145 req->length);
146}
147
148static void usbhsg_queue_pop(struct usbhsg_uep *uep, 130static void usbhsg_queue_pop(struct usbhsg_uep *uep,
149 struct usbhsg_request *ureq, 131 struct usbhsg_request *ureq,
150 int status) 132 int status)
@@ -170,6 +152,25 @@ static void usbhsg_queue_done(struct usbhs_priv *priv, struct usbhs_pkt *pkt)
170 usbhsg_queue_pop(uep, ureq, 0); 152 usbhsg_queue_pop(uep, ureq, 0);
171} 153}
172 154
155static void usbhsg_queue_push(struct usbhsg_uep *uep,
156 struct usbhsg_request *ureq)
157{
158 struct usbhsg_gpriv *gpriv = usbhsg_uep_to_gpriv(uep);
159 struct device *dev = usbhsg_gpriv_to_dev(gpriv);
160 struct usbhs_pipe *pipe = usbhsg_uep_to_pipe(uep);
161 struct usbhs_pkt *pkt = usbhsg_ureq_to_pkt(ureq);
162 struct usb_request *req = &ureq->req;
163
164 req->actual = 0;
165 req->status = -EINPROGRESS;
166 usbhs_pkt_push(pipe, pkt, usbhsg_queue_done,
167 req->buf, req->length, req->zero);
168
169 dev_dbg(dev, "pipe %d : queue push (%d)\n",
170 usbhs_pipe_number(pipe),
171 req->length);
172}
173
173/* 174/*
174 * dma map/unmap 175 * dma map/unmap
175 */ 176 */
@@ -664,7 +665,6 @@ static int usbhsg_try_start(struct usbhs_priv *priv, u32 status)
664 * pipe initialize and enable DCP 665 * pipe initialize and enable DCP
665 */ 666 */
666 usbhs_pipe_init(priv, 667 usbhs_pipe_init(priv,
667 usbhsg_queue_done,
668 usbhsg_dma_map_ctrl); 668 usbhsg_dma_map_ctrl);
669 usbhs_fifo_init(priv); 669 usbhs_fifo_init(priv);
670 usbhsg_uep_init(gpriv); 670 usbhsg_uep_init(gpriv);
diff --git a/drivers/usb/renesas_usbhs/pipe.c b/drivers/usb/renesas_usbhs/pipe.c
index 7636f2353b9d..6bc9e3327064 100644
--- a/drivers/usb/renesas_usbhs/pipe.c
+++ b/drivers/usb/renesas_usbhs/pipe.c
@@ -514,20 +514,12 @@ static struct usbhs_pipe *usbhsp_get_pipe(struct usbhs_priv *priv, u32 type)
514} 514}
515 515
516void usbhs_pipe_init(struct usbhs_priv *priv, 516void usbhs_pipe_init(struct usbhs_priv *priv,
517 void (*done)(struct usbhs_priv *priv,
518 struct usbhs_pkt *pkt),
519 int (*dma_map_ctrl)(struct usbhs_pkt *pkt, int map)) 517 int (*dma_map_ctrl)(struct usbhs_pkt *pkt, int map))
520{ 518{
521 struct usbhs_pipe_info *info = usbhs_priv_to_pipeinfo(priv); 519 struct usbhs_pipe_info *info = usbhs_priv_to_pipeinfo(priv);
522 struct device *dev = usbhs_priv_to_dev(priv);
523 struct usbhs_pipe *pipe; 520 struct usbhs_pipe *pipe;
524 int i; 521 int i;
525 522
526 if (!done) {
527 dev_err(dev, "no done function\n");
528 return;
529 }
530
531 /* 523 /*
532 * FIXME 524 * FIXME
533 * 525 *
@@ -554,7 +546,6 @@ void usbhs_pipe_init(struct usbhs_priv *priv,
554 usbhs_pipe_clear(pipe); 546 usbhs_pipe_clear(pipe);
555 } 547 }
556 548
557 info->done = done;
558 info->dma_map_ctrl = dma_map_ctrl; 549 info->dma_map_ctrl = dma_map_ctrl;
559} 550}
560 551
diff --git a/drivers/usb/renesas_usbhs/pipe.h b/drivers/usb/renesas_usbhs/pipe.h
index 37018351f47c..ddbd3193c1fb 100644
--- a/drivers/usb/renesas_usbhs/pipe.h
+++ b/drivers/usb/renesas_usbhs/pipe.h
@@ -47,7 +47,6 @@ struct usbhs_pipe_info {
47 int size; /* array size of "pipe" */ 47 int size; /* array size of "pipe" */
48 int bufnmb_last; /* FIXME : driver needs good allocator */ 48 int bufnmb_last; /* FIXME : driver needs good allocator */
49 49
50 void (*done)(struct usbhs_priv *priv, struct usbhs_pkt *pkt);
51 int (*dma_map_ctrl)(struct usbhs_pkt *pkt, int map); 50 int (*dma_map_ctrl)(struct usbhs_pkt *pkt, int map);
52}; 51};
53 52
@@ -81,8 +80,6 @@ void usbhs_pipe_remove(struct usbhs_priv *priv);
81int usbhs_pipe_is_dir_in(struct usbhs_pipe *pipe); 80int usbhs_pipe_is_dir_in(struct usbhs_pipe *pipe);
82int usbhs_pipe_is_dir_host(struct usbhs_pipe *pipe); 81int usbhs_pipe_is_dir_host(struct usbhs_pipe *pipe);
83void usbhs_pipe_init(struct usbhs_priv *priv, 82void usbhs_pipe_init(struct usbhs_priv *priv,
84 void (*done)(struct usbhs_priv *priv,
85 struct usbhs_pkt *pkt),
86 int (*dma_map_ctrl)(struct usbhs_pkt *pkt, int map)); 83 int (*dma_map_ctrl)(struct usbhs_pkt *pkt, int map));
87int usbhs_pipe_get_maxpacket(struct usbhs_pipe *pipe); 84int usbhs_pipe_get_maxpacket(struct usbhs_pipe *pipe);
88void usbhs_pipe_clear_sequence(struct usbhs_pipe *pipe); 85void usbhs_pipe_clear_sequence(struct usbhs_pipe *pipe);