diff --git a/src/device/device_util.c b/src/device/device_util.c index 9b3e21f9d2..efefa88ed1 100644 --- a/src/device/device_util.c +++ b/src/device/device_util.c @@ -113,6 +113,29 @@ device_t dev_find_lapic(unsigned apic_id) return result; } +/** + * Find a PNP device of given port and device ID. + * + * @param port A PNP port ID. + * @param device A PNP device ID. + * @return Pointer to the device struct. + */ +struct device *dev_find_pnp(unsigned int port, unsigned int device) +{ + struct device *dev, *result; + + result = NULL; + 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)) { + result = dev; + break; + } + } + return result; +} + /** * Find a device of a given vendor and type. * diff --git a/src/include/device/device.h b/src/include/device/device.h index b0168fc3a4..3d74ecf56b 100644 --- a/src/include/device/device.h +++ b/src/include/device/device.h @@ -159,6 +159,7 @@ device_t dev_find_class (unsigned int class, device_t from); device_t dev_find_slot (unsigned int bus, unsigned int devfn); device_t dev_find_slot_on_smbus (unsigned int bus, unsigned int addr); device_t dev_find_lapic(unsigned apic_id); +device_t dev_find_pnp(unsigned int port, unsigned int device); int dev_count_cpu(void); void remap_bsp_lapic(struct bus *cpu_bus);