device_util: Add dev_find_slot_pnp.

Change-Id: I5223c54c8ddbc60a176e4d718730e99decc772a3
Signed-off-by: Vladimir Serbinenko <phcoder@gmail.com>
Reviewed-on: http://review.coreboot.org/5112
Tested-by: build bot (Jenkins)
Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
This commit is contained in:
Vladimir Serbinenko 2014-02-04 14:34:11 +01:00
parent 732cee31a6
commit 400c05cf25
2 changed files with 22 additions and 0 deletions

View File

@ -93,6 +93,27 @@ struct device *dev_find_slot_on_smbus(unsigned int bus, unsigned int addr)
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.
*/
struct device *dev_find_slot_pnp(u16 port, u8 device)
{
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;
}
/**
* Given a Local APIC ID, find the device structure.
*

View File

@ -169,6 +169,7 @@ device_t dev_find_device (u16 vendor, u16 device, device_t from);
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_slot_pnp(u16 port, u8 device);
device_t dev_find_lapic(unsigned apic_id);
int dev_count_cpu(void);