diff options
author | Ian Moffett <ian@osmora.org> | 2025-05-09 22:13:09 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-05-09 22:13:09 -0400 |
commit | 260316209d0c3b781d1ae483372958434da70689 (patch) | |
tree | 4ae9670ece52db29dca0579fc7c83887dea0b5cf | |
parent | 1ec9b34e7abf37fd00fd04c3f2e1a75c41fe403f (diff) |
kernel: ahci: Improve HBA port scan logic
Signed-off-by: Ian Moffett <ian@osmora.org>
-rw-r--r-- | sys/dev/ic/ahci.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/sys/dev/ic/ahci.c b/sys/dev/ic/ahci.c index c0c6fec..4500a29 100644 --- a/sys/dev/ic/ahci.c +++ b/sys/dev/ic/ahci.c @@ -273,7 +273,7 @@ static int ahci_hba_scan(struct ahci_hba *hba) { struct hba_memspace *abar = hba->io; - uint32_t pi, i = 0; + uint32_t pi; size_t len; len = hba->nports * sizeof(struct hba_device); @@ -284,13 +284,10 @@ ahci_hba_scan(struct ahci_hba *hba) memset(devs, 0, len); pi = mmio_read32(&abar->pi); - while (pi != 0) { - if ((pi & 1) != 0) { + for (int i = 0; i < sizeof(pi) * 8; ++i) { + if (ISSET(pi, BIT(i))) { ahci_init_port(hba, i); } - - ++i; - pi >>= 1; } return 0; |