Edward O'Callaghan (eocallaghan@alterapraxis.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/6221
-gerrit
commit 5b0c84fb7da2dcb7e617548082af0b0a811d9920 Author: Edward O'Callaghan eocallaghan@alterapraxis.com Date: Wed Jul 9 00:25:10 2014 +1000
device_romstage: Add a way to find tdev struct from port/dev no.
NOTFORMERGE
When trying to loop through all the devices in romstage, there was no function to translate a PnP port and device number to the corresponding device structure.
Change-Id: I73bd396a5247077aa09e01c0f22510a8b2777ab8 Signed-off-by: Edward O'Callaghan eocallaghan@alterapraxis.com --- src/device/device_romstage.c | 21 +++++++++++++++++++++ src/include/device/device.h | 1 + 2 files changed, 22 insertions(+)
diff --git a/src/device/device_romstage.c b/src/device/device_romstage.c index 987fdad..df0df6a 100644 --- a/src/device/device_romstage.c +++ b/src/device/device_romstage.c @@ -101,3 +101,24 @@ ROMSTAGE_CONST struct device *dev_find_slot_on_smbus(unsigned int bus, } return result; } + +/** + * Given a PnP port and a device number, find the device structure. + * + * @param port The I/O port. + * @param device Logical device number. + * @return Pointer to the device structure (if found), 0 otherwise. + */ +ROMSTAGE_CONST struct device *dev_find_slot_pnp(u16 port, u16 device) +{ + ROMSTAGE_CONST struct device *dev; + + for (dev = all_devices; dev; dev = dev->next) { + if ((dev->path.type == DEVICE_PATH_PNP) && + (dev->path.pnp.port == port) && + (dev->path.pnp.device == device)) { + return dev; + } + } + return 0; +} diff --git a/src/include/device/device.h b/src/include/device/device.h index ec17adf..77778db 100644 --- a/src/include/device/device.h +++ b/src/include/device/device.h @@ -248,6 +248,7 @@ ROMSTAGE_CONST struct device *dev_find_next_pci_device( ROMSTAGE_CONST struct device *previous_dev); ROMSTAGE_CONST struct device * dev_find_slot_on_smbus (unsigned int bus, unsigned int addr); +ROMSTAGE_CONST struct device * dev_find_slot_pnp(u16 port, u16 device);
#endif