| Main index | Section 9 | Options |
#include <dev/ofw/openfirm.h>
#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_bus_subr.h>
ofw_bus_is_compatible() returns 1 if the compatstr value occurs in the "compatible" property list of the device tree node associated with the device dev, and 0 otherwise.
ofw_bus_is_compatible_strict() return 1 if the "compatible" property of the device tree node associated with the device dev consists of only one string and this string is equal to compatstr, and 0 otherwise.
ofw_bus_node_is_compatible() returns 1 if the compatstr value occurs in the "compatible" property list of the device tree node node, and 0 otherwise.
ofw_bus_search_compatible() returns pointer to the first entry of the compat table whose ocd_str field occurs in "compatible" property of the device tree node associated with the device dev. The compat table is an array of struct ofw_compat_data elements defined as follows:
struct ofw_compat_data {
const char *ocd_str;
uintptr_t ocd_data;
};
The
compat
table must be terminated by the entry with ocd_str set to NULL.
If the device tree node is not compatible with any of
the entries, the function returns the pointer to the
terminating entry.
static struct ofw_compat_data compat_data[] = {
{"arm,hrdwrA", FEATURE_A},
{"arm,hrdwrB", FEATURE_A | FEATURE_B},
{NULL, 0}
};
static int
hrdwr_probe(device_t dev)
{
...
if (!ofw_bus_search_compatible(dev, compat_data)->ocd_data)
return (ENXIO);
...
}
static int
hrdwr_attach(device_t dev)
{
...
sc = device_get_softc(dev);
sc->sc_features = ofw_bus_search_compatible(dev, compat_data)->ocd_data;
...
}
| ofw_bus_is_compatible (9) | April 8, 2018 |
| Main index | Section 9 | Options |
Please direct any comments about this manual page service to Ben Bullock. Privacy policy.
| “ | The number of UNIX installations has grown to 10, with more expected. | ” |
| — UNIX Programming Manual, 1972 | ||