Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9f592056 authored by Tejun Heo's avatar Tejun Heo Committed by Jeff Garzik
Browse files

[PATCH] ahci: simplify ahci_start_engine()



Simplify ahci_start_engine() by killing prerequisite condition checks.
Rationales are..

* No user checks error return from ahci_start_engine()

* Code flow guarantees the prerequisite conditions unless the
  controller is malfunctioning.  In such cases, the driver had chances
  to learn about the problem _before_ calling this function.

* Closely related to the above two, driver calls into this function
  even when prerequisites fail hoping for the best.

Basically, ahci_start_engine() should only do the operation itself.
It isn't the right place to check for prerequisites.

Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
Signed-off-by: default avatarZhao, Forrest <forrest.zhao@intel.com>
Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
parent d8fcd116
Loading
Loading
Loading
Loading
+2 −19
Original line number Diff line number Diff line
@@ -406,32 +406,15 @@ static void ahci_scr_write (struct ata_port *ap, unsigned int sc_reg_in,
	writel(val, (void __iomem *) ap->ioaddr.scr_addr + (sc_reg * 4));
}

static int ahci_start_engine(void __iomem *port_mmio)
static void ahci_start_engine(void __iomem *port_mmio)
{
	u32 tmp;

	/* get current status */
	tmp = readl(port_mmio + PORT_CMD);

	/* AHCI rev 1.1 section 10.3.1:
	 * Software shall not set PxCMD.ST to '1' until it verifies
	 * that PxCMD.CR is '0' and has set PxCMD.FRE to '1'
	 */
	if ((tmp & PORT_CMD_FIS_RX) == 0)
		return -EPERM;

	/* wait for engine to become idle */
	tmp = ata_wait_register(port_mmio + PORT_CMD,
				PORT_CMD_LIST_ON, PORT_CMD_LIST_ON, 1,500);
	if (tmp & PORT_CMD_LIST_ON)
		return -EBUSY;

	/* start DMA */
	tmp = readl(port_mmio + PORT_CMD);
	tmp |= PORT_CMD_START;
	writel(tmp, port_mmio + PORT_CMD);
	readl(port_mmio + PORT_CMD); /* flush */

	return 0;
}

static int ahci_stop_engine(void __iomem *port_mmio)