diff options
author | Ian Moffett <ian@osmora.org> | 2025-05-26 01:47:53 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-05-26 01:47:53 -0400 |
commit | 8ee8af7a61e929bedcd68617c3a5a1d2843936e8 (patch) | |
tree | 6152860b266c7924c765a9b513a7e6d8124a828f /sys/dev/ic | |
parent | 92d69b5538cc0828fc33e88fccb49ec62717133d (diff) |
kernel: ahci: Add ahci_get_dev() for drive lookups
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys/dev/ic')
-rw-r--r-- | sys/dev/ic/ahci.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/sys/dev/ic/ahci.c b/sys/dev/ic/ahci.c index 53113e7..9a9f896 100644 --- a/sys/dev/ic/ahci.c +++ b/sys/dev/ic/ahci.c @@ -96,6 +96,18 @@ ahci_poll_reg(volatile uint32_t *reg, uint32_t bits, bool pollset) return 0; } +static struct hba_device * +ahci_get_dev(dev_t dev) +{ + for (int i = 0; i < devs_max; ++i) { + if (devs[i].dev == dev) { + return &devs[i]; + } + } + + return NULL; +} + /* * Allocate a command slot for a port on * the HBA. @@ -638,7 +650,7 @@ sata_dev_rw(dev_t dev, struct sio_txn *sio, bool write) return -ENODEV; } - devp = &devs[dev]; + devp = ahci_get_dev(dev); if (__unlikely(devp == NULL)) { return -ENODEV; } |