[PATCH 16/22] usb: musb: reduce identation level

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Arnaud Mandy <ext-arnaud.2.mandy@xxxxxxxxx>

too many identation levels makes the code difficult to read.
Fix it.

Signed-off-by: Arnaud Mandy <ext-arnaud.2.mandy@xxxxxxxxx>
Signed-off-by: Felipe Balbi <felipe.balbi@xxxxxxxxx>
---
 drivers/usb/musb/musbhsdma.c |  126 +++++++++++++++++++-----------------------
 1 files changed, 57 insertions(+), 69 deletions(-)

diff --git a/drivers/usb/musb/musbhsdma.c b/drivers/usb/musb/musbhsdma.c
index 7472a02..4fccab9 100644
--- a/drivers/usb/musb/musbhsdma.c
+++ b/drivers/usb/musb/musbhsdma.c
@@ -254,7 +254,7 @@ static irqreturn_t dma_controller_irq(int irq, void *private_data)
 {
 	struct musb_dma_controller *controller = private_data;
 	struct musb *musb = controller->private_data;
-	struct musb_dma_channel *musb_channel;
+	struct musb_dma_channel *mchannel;
 	struct dma_channel *channel;
 
 	void __iomem *mbase = controller->base;
@@ -281,74 +281,62 @@ static irqreturn_t dma_controller_irq(int irq, void *private_data)
 #endif
 
 	for (bchannel = 0; bchannel < MUSB_HSDMA_CHANNELS; bchannel++) {
-		if (int_hsdma & (1 << bchannel)) {
-			musb_channel = (struct musb_dma_channel *)
-					&(controller->channel[bchannel]);
-			channel = &musb_channel->channel;
-
-			csr = musb_readw(mbase,
-					MUSB_HSDMA_CHANNEL_OFFSET(bchannel,
-							MUSB_HSDMA_CONTROL));
-
-			if (csr & MUSB_HSDMA_BUSERROR) {
-				musb_channel->channel.status =
-					MUSB_DMA_STATUS_BUS_ABORT;
-			} else {
-				u8 devctl;
-
-				addr = musb_read_hsdma_addr(mbase,
-						bchannel);
-				channel->actual_len = addr
-					- musb_channel->start_addr;
-
-				DBG(2, "ch %p, 0x%x -> 0x%x (%zu / %d) %s\n",
-					channel, musb_channel->start_addr,
-					addr, channel->actual_len,
-					musb_channel->len,
-					(channel->actual_len
-						< musb_channel->len) ?
-					"=> reconfig 0" : "=> complete");
-
-				devctl = musb_readb(mbase, MUSB_DEVCTL);
-
-				channel->status = MUSB_DMA_STATUS_FREE;
-
-				if (musb_channel->transmit)
-					controller->tx_active &=
-							~(1 << bchannel);
-				else
-					controller->rx_active &=
-							~(1 << bchannel);
-
-				/* completed */
-				if ((devctl & MUSB_DEVCTL_HM)
-					&& (musb_channel->transmit)
-					&& ((channel->desired_mode == 0)
-					    || (channel->actual_len &
-					    (musb_channel->max_packet_sz - 1)))
-				    ) {
-					u8  epnum  = musb_channel->epnum;
-					int offset = MUSB_EP_OFFSET(epnum,
-								    MUSB_TXCSR);
-					u16 txcsr;
-
-					/*
-					 * The programming guide says that we
-					 * must clear DMAENAB before DMAMODE.
-					 */
-					musb_ep_select(mbase, epnum);
-					txcsr = musb_readw(mbase, offset);
-					txcsr &= ~(MUSB_TXCSR_DMAENAB
-							| MUSB_TXCSR_AUTOSET);
-					musb_writew(mbase, offset, txcsr);
-					/* Send out the packet */
-					txcsr &= ~MUSB_TXCSR_DMAMODE;
-					txcsr |=  MUSB_TXCSR_TXPKTRDY;
-					musb_writew(mbase, offset, txcsr);
-				}
-				musb_dma_completion(musb, musb_channel->epnum,
-						    musb_channel->transmit);
-			}
+		u8 devctl;
+
+		if (!(int_hsdma & (1 << bchannel)))
+			continue;
+
+		mchannel = &(controller->channel[bchannel]);
+		channel = &mchannel->channel;
+
+		csr = musb_readw(mbase, MUSB_HSDMA_CHANNEL_OFFSET(bchannel,
+					MUSB_HSDMA_CONTROL));
+
+		if (csr & MUSB_HSDMA_BUSERROR) {
+			mchannel->channel.status = MUSB_DMA_STATUS_BUS_ABORT;
+			goto done;
+		}
+
+		addr = musb_read_hsdma_addr(mbase, bchannel);
+		channel->actual_len = addr - mchannel->start_addr;
+
+		DBG(2, "ch %p, 0x%x -> 0x%x (%zu / %d) %s\n",
+				channel, mchannel->start_addr,
+				addr, channel->actual_len, mchannel->len,
+				(channel->actual_len < mchannel->len) ?
+				"=> reconfig 0" : "=> complete");
+
+		devctl = musb_readb(mbase, MUSB_DEVCTL);
+		channel->status = MUSB_DMA_STATUS_FREE;
+
+		if (mchannel->transmit)
+			controller->tx_active &= ~(1 << bchannel);
+		else
+			controller->rx_active &= ~(1 << bchannel);
+
+		/* completed */
+		if ((devctl & MUSB_DEVCTL_HM) && (mchannel->transmit)
+				&& ((channel->desired_mode == 0)
+					|| (channel->actual_len &
+						(mchannel->max_packet_sz - 1)))) {
+			u8  epnum  = mchannel->epnum;
+			int offset = MUSB_EP_OFFSET(epnum, MUSB_TXCSR);
+			u16 txcsr;
+			/*
+			 * The programming guide says that we
+			 * must clear DMAENAB before DMAMODE.
+			 */
+			musb_ep_select(mbase, epnum);
+			txcsr = musb_readw(mbase, offset);
+			txcsr &= ~(MUSB_TXCSR_DMAENAB | MUSB_TXCSR_AUTOSET);
+			musb_writew(mbase, offset, txcsr);
+			/* Send out the packet */
+			txcsr &= ~MUSB_TXCSR_DMAMODE;
+			txcsr |=  MUSB_TXCSR_TXPKTRDY;
+			musb_writew(mbase, offset, txcsr);
+		} else {
+			musb_dma_completion(musb, mchannel->epnum,
+					mchannel->transmit);
 		}
 	}
 
-- 
1.6.6.rc0

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux