Commit 8bf207d242b603954d5338dabf31b8de01805677
Committed by
Tom Rini
1 parent
47cef9c805
Exists in
smarc_8mq_lf_v2020.04
and in
11 other branches
ata: ahci: Loop over the actual number of ports, not the maximum
The loop in ahci_start_ports() is looping over the maximum number of SCSI devices in the system, which can be larger than the amount of ports a particular AHCI controller has. The extra looping isn't directly harmful because the link_port_map bitmap won't have the bit set for a nonexistent port, but it is wasteful. Replace the loop limit with the port count of the AHCI controller instead. Signed-off-by: Tuomas Tynkkynen <tuomas.tynkkynen@iki.fi> Reviewed-by: Simon Glass <sjg@chromium.org>
Showing 1 changed file with 1 additions and 1 deletions Side-by-side Diff
drivers/ata/ahci.c
... | ... | @@ -980,7 +980,7 @@ |
980 | 980 | |
981 | 981 | linkmap = uc_priv->link_port_map; |
982 | 982 | |
983 | - for (i = 0; i < CONFIG_SYS_SCSI_MAX_SCSI_ID; i++) { | |
983 | + for (i = 0; i < uc_priv->n_ports; i++) { | |
984 | 984 | if (((linkmap >> i) & 0x01)) { |
985 | 985 | if (ahci_port_start(uc_priv, (u8) i)) { |
986 | 986 | printf("Can not start port %d\n", i); |