OF_xref_from_device9freebsd
Manage mappings between xrefs and devices
Part of OF_device_from_xref(9freebsd).
Usage
int
device_t
phandle_t
Overview
When a device tree node references another node, the driver may need to get a device_t instance associated with the referenced node. For instance, an Ethernet driver accessing a PHY device. To make this possible, the kernel maintains a table that maps effective handles to device_t instances.
OF_device_register_xref() adds a map entry from the effective phandle xref to device dev. If a mapping entry for xref already exists, it is replaced with the new one. The function always returns 0.
OF_device_from_xref() returns a device_t instance associated with the effective phandle xref. If no such mapping exists, the function returns NULL.
OF_xref_from_device() returns the effective phandle associated with the device dev. If no such mapping exists, the function returns 0.
Examples
static int
acmephy_attach(device_t dev)
{
phandle_t node;
/* PHY node is referenced from eth device, register it */
node = ofw_bus_get_node(dev);
OF_device_register_xref(OF_xref_from_node(node), dev);
return (0);
}
History
- Debian 13 (Trixie) to Debian 11 (Bullseye): the text shown here
- Debian 10 (Buster)