Updated: April 19, 2023 |
Find a specific item instance owned by a specific parent, resolving all synonym names
#include <drvr/hwinfo.h> unsigned hwi_find( const char *device_name, int unit, unsigned hwi_off);
The hwi_find() function lets you find a specific item instance owned by a specific parent, resolving (all) synonym names (aliases) to a real device or bus. If the unit instance of device_name has been added to the hwinfo section of the system page and belongs to parent hwi_off, the function returns its hwi offset.
If hwi_off is HWI_NULL_OFF, indicating no parent specified, then hwi_find() does a system-wide search and returns the results regardless of the owning parent. If unit is -1, indicating that you aren't looking for a specific instance, hwi_find() returns the offset of the first occurrence of device_name. Setting unit to -1 is most useful when you're searching for a device on a specific bus (i.e., hwi_off != HWI_NULL_OFF).
Note that the search can be directed from a specific item hwi_off. Therefore, if a certain device is expected to be found attached to a certain bus, you can set hwi_off to the results of hwi_find_bus(). For example, if you have multiple instances of the same device attached to two different buses, the hwi_off parameter allows you to find the instance connected to one of the buses only.
The offset of the device found, or HWI_NULL_OFF if no device was found.
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | No |
Signal handler | No |
Thread | Yes |