From 96643455864a961881a3b2c4922ea76c3a5b4d20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ky=C3=B6sti=20M=C3=A4lkki?= Date: Wed, 28 Jan 2015 22:03:46 +0200 Subject: devicetree: Search PnP device node from the tree by path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Copied from device_util.c with added ROMSTAGE_CONST. Change-Id: If872631ed96a79b9a0b15e09382d6f81098c8db3 Signed-off-by: Kyösti Mälkki Reviewed-on: http://review.coreboot.org/8297 Tested-by: build bot (Jenkins) Reviewed-by: Paul Menzel Reviewed-by: Alexandru Gagniuc --- src/device/device_romstage.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/device') diff --git a/src/device/device_romstage.c b/src/device/device_romstage.c index 987fdade0e..df0df6a529 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; +} -- cgit v1.2.3