aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/musb/musb_host.c
diff options
context:
space:
mode:
authorSergei Shtylyov <sshtylyov@ru.mvista.com>2009-03-27 15:55:16 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2009-06-16 00:44:40 -0400
commit3e5c6dc71146c2c3f21d60d3b4b25dc7755d5339 (patch)
tree6d143a910ce47f6a8cd4da9c76493114005e4ecb /drivers/usb/musb/musb_host.c
parent846099a61cf549f450178f1fb3e27adcbd9dcfc2 (diff)
musb_host: factor out musb_ep_{get|set}_qh()
Factor out the often used code to get/set the active 'qh' pointer for the hardware endpoint. Change the way the case of a shared FIFO is handled by setting *both* 'in_qh' and 'out_qh' fields of 'struct musb_hw_ep'. That seems more consistent and makes getting to the current 'qh' easy when the code knows the direction beforehand. While at it, turn some assignments into intializers and fix declaration style in the vicinity. Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com> Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/musb/musb_host.c')
-rw-r--r--drivers/usb/musb/musb_host.c56
1 files changed, 22 insertions, 34 deletions
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
index bf194d244533..17d14f26bd6c 100644
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -181,6 +181,19 @@ static inline void musb_h_tx_dma_start(struct musb_hw_ep *ep)
181 musb_writew(ep->regs, MUSB_TXCSR, txcsr); 181 musb_writew(ep->regs, MUSB_TXCSR, txcsr);
182} 182}
183 183
184static void musb_ep_set_qh(struct musb_hw_ep *ep, int is_in, struct musb_qh *qh)
185{
186 if (is_in != 0 || ep->is_shared_fifo)
187 ep->in_qh = qh;
188 if (is_in == 0 || ep->is_shared_fifo)
189 ep->out_qh = qh;
190}
191
192static struct musb_qh *musb_ep_get_qh(struct musb_hw_ep *ep, int is_in)
193{
194 return is_in ? ep->in_qh : ep->out_qh;
195}
196
184/* 197/*
185 * Start the URB at the front of an endpoint's queue 198 * Start the URB at the front of an endpoint's queue
186 * end must be claimed from the caller. 199 * end must be claimed from the caller.
@@ -210,7 +223,6 @@ musb_start_urb(struct musb *musb, int is_in, struct musb_qh *qh)
210 case USB_ENDPOINT_XFER_CONTROL: 223 case USB_ENDPOINT_XFER_CONTROL:
211 /* control transfers always start with SETUP */ 224 /* control transfers always start with SETUP */
212 is_in = 0; 225 is_in = 0;
213 hw_ep->out_qh = qh;
214 musb->ep0_stage = MUSB_EP0_START; 226 musb->ep0_stage = MUSB_EP0_START;
215 buf = urb->setup_packet; 227 buf = urb->setup_packet;
216 len = 8; 228 len = 8;
@@ -239,10 +251,7 @@ musb_start_urb(struct musb *musb, int is_in, struct musb_qh *qh)
239 epnum, buf + offset, len); 251 epnum, buf + offset, len);
240 252
241 /* Configure endpoint */ 253 /* Configure endpoint */
242 if (is_in || hw_ep->is_shared_fifo) 254 musb_ep_set_qh(hw_ep, is_in, qh);
243 hw_ep->in_qh = qh;
244 else
245 hw_ep->out_qh = qh;
246 musb_ep_program(musb, epnum, urb, !is_in, buf, offset, len); 255 musb_ep_program(musb, epnum, urb, !is_in, buf, offset, len);
247 256
248 /* transmit may have more work: start it when it is time */ 257 /* transmit may have more work: start it when it is time */
@@ -377,11 +386,8 @@ musb_giveback(struct musb_qh *qh, struct urb *urb, int status)
377 else 386 else
378 ep->tx_reinit = 1; 387 ep->tx_reinit = 1;
379 388
380 /* clobber old pointers to this qh */ 389 /* Clobber old pointers to this qh */
381 if (is_in || ep->is_shared_fifo) 390 musb_ep_set_qh(ep, is_in, NULL);
382 ep->in_qh = NULL;
383 else
384 ep->out_qh = NULL;
385 qh->hep->hcpriv = NULL; 391 qh->hep->hcpriv = NULL;
386 392
387 switch (qh->type) { 393 switch (qh->type) {
@@ -424,12 +430,7 @@ static void
424musb_advance_schedule(struct musb *musb, struct urb *urb, 430musb_advance_schedule(struct musb *musb, struct urb *urb,
425 struct musb_hw_ep *hw_ep, int is_in) 431 struct musb_hw_ep *hw_ep, int is_in)
426{ 432{
427 struct musb_qh *qh; 433 struct musb_qh *qh = musb_ep_get_qh(hw_ep, is_in);
428
429 if (is_in || hw_ep->is_shared_fifo)
430 qh = hw_ep->in_qh;
431 else
432 qh = hw_ep->out_qh;
433 434
434 if (urb->status == -EINPROGRESS) 435 if (urb->status == -EINPROGRESS)
435 qh = musb_giveback(qh, urb, 0); 436 qh = musb_giveback(qh, urb, 0);
@@ -692,15 +693,8 @@ static void musb_ep_program(struct musb *musb, u8 epnum,
692 void __iomem *mbase = musb->mregs; 693 void __iomem *mbase = musb->mregs;
693 struct musb_hw_ep *hw_ep = musb->endpoints + epnum; 694 struct musb_hw_ep *hw_ep = musb->endpoints + epnum;
694 void __iomem *epio = hw_ep->regs; 695 void __iomem *epio = hw_ep->regs;
695 struct musb_qh *qh; 696 struct musb_qh *qh = musb_ep_get_qh(hw_ep, !is_out);
696 u16 packet_sz; 697 u16 packet_sz = qh->maxpacket;
697
698 if (!is_out || hw_ep->is_shared_fifo)
699 qh = hw_ep->in_qh;
700 else
701 qh = hw_ep->out_qh;
702
703 packet_sz = qh->maxpacket;
704 698
705 DBG(3, "%s hw%d urb %p spd%d dev%d ep%d%s " 699 DBG(3, "%s hw%d urb %p spd%d dev%d ep%d%s "
706 "h_addr%02x h_port%02x bytes %d\n", 700 "h_addr%02x h_port%02x bytes %d\n",
@@ -1118,17 +1112,14 @@ void musb_host_tx(struct musb *musb, u8 epnum)
1118 u16 tx_csr; 1112 u16 tx_csr;
1119 size_t length = 0; 1113 size_t length = 0;
1120 size_t offset = 0; 1114 size_t offset = 0;
1121 struct urb *urb;
1122 struct musb_hw_ep *hw_ep = musb->endpoints + epnum; 1115 struct musb_hw_ep *hw_ep = musb->endpoints + epnum;
1123 void __iomem *epio = hw_ep->regs; 1116 void __iomem *epio = hw_ep->regs;
1124 struct musb_qh *qh = hw_ep->is_shared_fifo ? hw_ep->in_qh 1117 struct musb_qh *qh = hw_ep->out_qh;
1125 : hw_ep->out_qh; 1118 struct urb *urb = next_urb(qh);
1126 u32 status = 0; 1119 u32 status = 0;
1127 void __iomem *mbase = musb->mregs; 1120 void __iomem *mbase = musb->mregs;
1128 struct dma_channel *dma; 1121 struct dma_channel *dma;
1129 1122
1130 urb = next_urb(qh);
1131
1132 musb_ep_select(mbase, epnum); 1123 musb_ep_select(mbase, epnum);
1133 tx_csr = musb_readw(epio, MUSB_TXCSR); 1124 tx_csr = musb_readw(epio, MUSB_TXCSR);
1134 1125
@@ -1806,10 +1797,7 @@ static int musb_schedule(
1806 epnum++, hw_ep++) { 1797 epnum++, hw_ep++) {
1807 int diff; 1798 int diff;
1808 1799
1809 if (is_in || hw_ep->is_shared_fifo) { 1800 if (musb_ep_get_qh(hw_ep, is_in) != NULL)
1810 if (hw_ep->in_qh != NULL)
1811 continue;
1812 } else if (hw_ep->out_qh != NULL)
1813 continue; 1801 continue;
1814 1802
1815 if (hw_ep == musb->bulk_ep) 1803 if (hw_ep == musb->bulk_ep)