From: Denis Orlov <denorl2009@gmail.com> To: barebox@lists.infradead.org Cc: Denis Orlov <denorl2009@gmail.com> Subject: [PATCH 15/16] ata: ahci: register only implemented ports Date: Wed, 4 May 2022 12:25:52 +0300 [thread overview] Message-ID: <20220504092553.27961-15-denorl2009@gmail.com> (raw) In-Reply-To: <20220504092553.27961-1-denorl2009@gmail.com> 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> --- drivers/ata/ahci.c | 15 ++++++++++++--- 1 file 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; -- 2.20.1 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2022-05-04 9:46 UTC|newest] Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top 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 ` Denis Orlov [this message] 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
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220504092553.27961-15-denorl2009@gmail.com \ --to=denorl2009@gmail.com \ --cc=barebox@lists.infradead.org \ --subject='Re: [PATCH 15/16] ata: ahci: register only implemented ports' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox