mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 01/16] ata: ahci: use abstract read/write functions uniformly
@ 2022-05-04  9:25 Denis Orlov
  2022-05-04  9:25 ` [PATCH 02/16] ata: ahci: replace magic numbers with named constants Denis Orlov
                   ` (15 more replies)
  0 siblings, 16 replies; 17+ messages in thread
From: Denis Orlov @ 2022-05-04  9:25 UTC (permalink / raw)
  To: barebox; +Cc: Denis Orlov

Currently those are used in some routines side by side with underlying
functions with no apparent reason for it. Make their usage uniform, this
cleans up code a bit and allows to remove unneeded variables.

Signed-off-by: Denis Orlov <denorl2009@gmail.com>
---
 drivers/ata/ahci.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 3c0b0a5450..ad9e2f950f 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -172,7 +172,7 @@ static int ahci_io(struct ahci_port *ahci_port, u8 *fis, int fis_len, void *rbuf
 	ahci_port_write_f(ahci_port, PORT_CMD_ISSUE, 1);
 
 	ret = wait_on_timeout(WAIT_DATAIO,
-			(readl(ahci_port->port_mmio + PORT_CMD_ISSUE) & 0x1) == 0);
+			(ahci_port_read(ahci_port, PORT_CMD_ISSUE) & 0x1) == 0);
 	if (ret)
 		return -ETIMEDOUT;
 
@@ -274,12 +274,9 @@ static int ahci_write(struct ata_port *ata, const void *buf, sector_t block,
 
 static int ahci_init_port(struct ahci_port *ahci_port)
 {
-	void __iomem *port_mmio;
 	u32 val, cmd;
 	int ret;
 
-	port_mmio = ahci_port->port_mmio;
-
 	/* make sure port is not active */
 	val = ahci_port_read(ahci_port, PORT_CMD);
 	if (val & (PORT_CMD_LIST_ON | PORT_CMD_FIS_ON | PORT_CMD_FIS_RX | PORT_CMD_START)) {
@@ -375,16 +372,16 @@ static int ahci_init_port(struct ahci_port *ahci_port)
 	ahci_port_info(ahci_port, "Spinning up device...\n");
 
 	ret = wait_on_timeout(WAIT_SPINUP,
-			((readl(port_mmio + PORT_TFDATA) &
+			((ahci_port_read(ahci_port, PORT_TFDATA) &
 			 (ATA_STATUS_BUSY | ATA_STATUS_DRQ)) == 0)
-			|| ((readl(port_mmio + PORT_SCR_STAT) & 0xf) == 1));
+			|| ((ahci_port_read(ahci_port, PORT_SCR_STAT) & 0xf) == 1));
 	if (ret) {
 		ahci_port_info(ahci_port, "timeout.\n");
 		ret = -ENODEV;
 		goto err_init;
 	}
 
-	if ((readl(port_mmio + PORT_SCR_STAT) & 0xf) == 1) {
+	if ((ahci_port_read(ahci_port, PORT_SCR_STAT) & 0xf) == 1) {
 		ahci_port_info(ahci_port, "down.\n");
 		ret = -ENODEV;
 		goto err_init;
@@ -570,7 +567,6 @@ static int ahci_detect(struct device_d *dev)
 
 int ahci_add_host(struct ahci_device *ahci)
 {
-	u8 *mmio = (u8 *)ahci->mmio_base;
 	u32 tmp, cap_save;
 	int i, ret;
 
@@ -584,7 +580,7 @@ int ahci_add_host(struct ahci_device *ahci)
 
 	ahci_debug(ahci, "ahci_host_init: start\n");
 
-	cap_save = readl(mmio + HOST_CAP);
+	cap_save = ahci_ioread(ahci, HOST_CAP);
 	cap_save &= ((1 << 28) | (1 << 17));
 	cap_save |= (1 << 27);  /* Staggered Spin-up. Not needed. */
 
@@ -597,7 +593,7 @@ int ahci_add_host(struct ahci_device *ahci)
 	 * reset must complete within 1 second, or
 	 * the hardware should be considered fried.
 	 */
-	ret = wait_on_timeout(SECOND, (readl(mmio + HOST_CTL) & HOST_RESET) == 0);
+	ret = wait_on_timeout(SECOND, (ahci_ioread(ahci, HOST_CTL) & HOST_RESET) == 0);
 	if (ret) {
 		ahci_debug(ahci,"controller reset failed (0x%x)\n", tmp);
 		return -ENODEV;
@@ -620,7 +616,7 @@ int ahci_add_host(struct ahci_device *ahci)
 		ahci_port->num = i;
 		ahci_port->ahci = ahci;
 		ahci_port->ata.dev = ahci->dev;
-		ahci_port->port_mmio = ahci_port_base(mmio, i);
+		ahci_port->port_mmio = ahci_port_base(ahci->mmio_base, i);
 		ahci_port->ata.ops = &ahci_ops;
 		ata_port_register(&ahci_port->ata);
 	}
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2022-05-05  7:49 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-04  9:25 [PATCH 01/16] ata: ahci: use abstract read/write functions uniformly Denis Orlov
2022-05-04  9:25 ` [PATCH 02/16] ata: ahci: replace magic numbers with named constants Denis Orlov
2022-05-04  9:25 ` [PATCH 03/16] ata: ahci: fix missing whitespace in ahci_add_host() Denis Orlov
2022-05-04  9:25 ` [PATCH 04/16] ata: ahci: simplify fis structure creation Denis Orlov
2022-05-04  9:25 ` [PATCH 05/16] ata: ahci: do not ignore dma handles Denis Orlov
2022-05-04  9:25 ` [PATCH 06/16] ata: ahci: adjust debug messages in ahci_init_port() Denis Orlov
2022-05-04  9:25 ` [PATCH 07/16] ata: ahci: correct named constants values and names Denis Orlov
2022-05-04  9:25 ` [PATCH 08/16] ata: ahci: properly fill scatter/gather table Denis Orlov
2022-05-04  9:25 ` [PATCH 09/16] ata: ahci: use named constants for capabilities bits Denis Orlov
2022-05-04  9:25 ` [PATCH 10/16] ata: ahci: map buffers properly Denis Orlov
2022-05-04  9:25 ` [PATCH 11/16] ata: ahci: use 64-bit addressing if available Denis Orlov
2022-05-04  9:25 ` [PATCH 12/16] ata: ahci: make rx_fis field in ahci_port of type void* Denis Orlov
2022-05-04  9:25 ` [PATCH 13/16] ata: ahci: add missing capability in ahci_print_info() Denis Orlov
2022-05-04  9:25 ` [PATCH 14/16] ata: ahci: remove redundant cast in ahci_io() Denis Orlov
2022-05-04  9:25 ` [PATCH 15/16] ata: ahci: register only implemented ports Denis Orlov
2022-05-04  9:25 ` [PATCH 16/16] ata: ahci: allocate memory in one call in ahci_init_port() Denis Orlov
2022-05-05  7:48 ` [PATCH 01/16] ata: ahci: use abstract read/write functions uniformly Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox