src/device: Get device structure by path type
Add helper function to find a device by path type in the device tree. Change-Id: I8846f63bd2488788ea3c7ab5154e7cf431a252bc Credits-to: Aaron Durbin <adurbin@chromium.org> Signed-off-by: Subrata Banik <subrata.banik@intel.com> Signed-off-by: Dhaval V Sharma <dhaval.v.sharma@intel.com> Reviewed-on: https://review.coreboot.org/17731 Reviewed-by: Aaron Durbin <adurbin@chromium.org> Tested-by: build bot (Jenkins)
This commit is contained in:
parent
d6c555971b
commit
fe204fe902
|
@ -130,6 +130,31 @@ device_t dev_find_lapic(unsigned apic_id)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given a Device Path Type, find the device structure.
|
||||||
|
*
|
||||||
|
* @param prev_match The previously matched device instance.
|
||||||
|
* @param path_type The Device Path Type.
|
||||||
|
* @return Pointer to the device structure (if found), 0 otherwise.
|
||||||
|
*/
|
||||||
|
device_t dev_find_path(device_t prev_match, enum device_path_type path_type)
|
||||||
|
{
|
||||||
|
device_t dev, result = NULL;
|
||||||
|
|
||||||
|
if (prev_match == NULL)
|
||||||
|
prev_match = all_devices;
|
||||||
|
else
|
||||||
|
prev_match = prev_match->next;
|
||||||
|
|
||||||
|
for (dev = prev_match; dev; dev = dev->next) {
|
||||||
|
if (dev->path.type == path_type) {
|
||||||
|
result = dev;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find a device of a given vendor and type.
|
* Find a device of a given vendor and type.
|
||||||
*
|
*
|
||||||
|
|
|
@ -195,6 +195,7 @@ device_t find_dev_path(struct bus *parent, struct device_path *path);
|
||||||
device_t alloc_find_dev(struct bus *parent, struct device_path *path);
|
device_t alloc_find_dev(struct bus *parent, struct device_path *path);
|
||||||
device_t dev_find_device (u16 vendor, u16 device, device_t from);
|
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_class (unsigned int class, device_t from);
|
||||||
|
device_t dev_find_path(device_t prev_match, enum device_path_type path_type);
|
||||||
device_t dev_find_slot (unsigned int bus, unsigned int devfn);
|
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_on_smbus (unsigned int bus, unsigned int addr);
|
||||||
device_t dev_find_slot_pnp(u16 port, u16 device);
|
device_t dev_find_slot_pnp(u16 port, u16 device);
|
||||||
|
|
Loading…
Reference in New Issue