Skip to content

Commit

Permalink
ata: sata_dwc_460ex: tidy up sata_dwc_clear_dmacr()
Browse files Browse the repository at this point in the history
This consolidates the reads from each of the if/else branches
to one place making the code a lot nicer to look at.

Tested-by: Christian Lamparter <[email protected]>
Signed-off-by: Mans Rullgard <[email protected]>
Signed-off-by: Tejun Heo <[email protected]>
  • Loading branch information
mansr authored and htejun committed May 12, 2016
1 parent ee81d6c commit af50f3a
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions drivers/ata/sata_dwc_460ex.c
Original file line number Diff line number Diff line change
Expand Up @@ -729,24 +729,22 @@ static irqreturn_t sata_dwc_isr(int irq, void *dev_instance)
static void sata_dwc_clear_dmacr(struct sata_dwc_device_port *hsdevp, u8 tag)
{
struct sata_dwc_device *hsdev = HSDEV_FROM_HSDEVP(hsdevp);
u32 dmacr = sata_dwc_readl(&hsdev->sata_dwc_regs->dmacr);

if (hsdevp->dma_pending[tag] == SATA_DWC_DMA_PENDING_RX) {
sata_dwc_writel(&hsdev->sata_dwc_regs->dmacr,
SATA_DWC_DMACR_RX_CLEAR(
sata_dwc_readl(&hsdev->sata_dwc_regs->dmacr)));
dmacr = SATA_DWC_DMACR_RX_CLEAR(dmacr);
sata_dwc_writel(&hsdev->sata_dwc_regs->dmacr, dmacr);
} else if (hsdevp->dma_pending[tag] == SATA_DWC_DMA_PENDING_TX) {
sata_dwc_writel(&hsdev->sata_dwc_regs->dmacr,
SATA_DWC_DMACR_TX_CLEAR(
sata_dwc_readl(&hsdev->sata_dwc_regs->dmacr)));
dmacr = SATA_DWC_DMACR_TX_CLEAR(dmacr);
sata_dwc_writel(&hsdev->sata_dwc_regs->dmacr, dmacr);
} else {
/*
* This should not happen, it indicates the driver is out of
* sync. If it does happen, clear dmacr anyway.
*/
dev_err(hsdev->dev,
"%s DMA protocol RX and TX DMA not pending tag=0x%02x pending=%d dmacr: 0x%08x\n",
__func__, tag, hsdevp->dma_pending[tag],
sata_dwc_readl(&hsdev->sata_dwc_regs->dmacr));
__func__, tag, hsdevp->dma_pending[tag], dmacr);
sata_dwc_writel(&hsdev->sata_dwc_regs->dmacr,
SATA_DWC_DMACR_TXRXCH_CLEAR);
}
Expand Down

0 comments on commit af50f3a

Please sign in to comment.