diff options
author | Denis Orlov <denorl2009@gmail.com> | 2022-05-04 12:25:52 +0300 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2022-05-05 09:47:04 +0200 |
commit | d9376a4972ac96b4da2d1f42b4669de1068cad5e (patch) | |
tree | aab826226995a28211fcc09665affac074d531c9 /drivers/ata | |
parent | 42d11a362b2fda806a1be9620fc59fb9c87d0bea (diff) | |
download | barebox-d9376a4972ac96b4da2d1f42b4669de1068cad5e.tar.gz barebox-d9376a4972ac96b4da2d1f42b4669de1068cad5e.tar.xz |
ata: ahci: register only implemented ports
The value from the "ports implemented" register should be kept in mind
when registering ports or detecting devices on them.
Signed-off-by: Denis Orlov <denorl2009@gmail.com>
Link: https://lore.barebox.org/20220504092553.27961-15-denorl2009@gmail.com
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/ata')
-rw-r--r-- | drivers/ata/ahci.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index f9056ff418..24098ada08 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c @@ -563,11 +563,15 @@ void ahci_info(struct device_d *dev) static int ahci_detect(struct device_d *dev) { struct ahci_device *ahci = dev->priv; + int n_ports = max_t(int, ahci->n_ports, fls(ahci->port_map)); int i; - for (i = 0; i < ahci->n_ports; i++) { + for (i = 0; i < n_ports; i++) { struct ahci_port *ahci_port = &ahci->ports[i]; + if (!(ahci->port_map & (1 << i))) + continue; + ata_port_detect(&ahci_port->ata); } @@ -577,7 +581,7 @@ static int ahci_detect(struct device_d *dev) int ahci_add_host(struct ahci_device *ahci) { u32 tmp, cap_save; - int i, ret; + int n_ports, i, ret; ahci->host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY @@ -619,9 +623,14 @@ int ahci_add_host(struct ahci_device *ahci) ahci_debug(ahci, "cap 0x%x port_map 0x%x n_ports %d\n", ahci->cap, ahci->port_map, ahci->n_ports); - for (i = 0; i < ahci->n_ports; i++) { + n_ports = max_t(int, ahci->n_ports, fls(ahci->port_map)); + + for (i = 0; i < n_ports; i++) { struct ahci_port *ahci_port = &ahci->ports[i]; + if (!(ahci->port_map & (1 << i))) + continue; + ahci_port->num = i; ahci_port->ahci = ahci; ahci_port->ata.dev = ahci->dev; |