Changeset View
Changeset View
Standalone View
Standalone View
share/man/man9/OF_device_from_xref.9
Show All 26 Lines | |||||
.\" | .\" | ||||
.Dd April 9, 2018 | .Dd April 9, 2018 | ||||
.Dt OF_DEVICE_FROM_XREF 9 | .Dt OF_DEVICE_FROM_XREF 9 | ||||
.Os | .Os | ||||
.Sh NAME | .Sh NAME | ||||
.Nm OF_device_from_xref , | .Nm OF_device_from_xref , | ||||
.Nm OF_xref_from_device , | .Nm OF_xref_from_device , | ||||
.Nm OF_device_register_xref | .Nm OF_device_register_xref | ||||
.Nm OF_device_unregister_xref | |||||
.Nd "manage mappings between xrefs and devices" | .Nd "manage mappings between xrefs and devices" | ||||
.Sh SYNOPSIS | .Sh SYNOPSIS | ||||
.In dev/ofw/ofw_bus.h | .In dev/ofw/ofw_bus.h | ||||
.In dev/ofw/ofw_bus_subr.h | .In dev/ofw/ofw_bus_subr.h | ||||
.Ft int | .Ft int | ||||
.Fn OF_device_register_xref "phandle_t xref" "device_t dev" | .Fn OF_device_register_xref "phandle_t xref" "device_t dev" | ||||
.Ft void | |||||
.Fn OF_device_unregister_xref "phandle_t xref" "device_t dev" | |||||
.Ft device_t | .Ft device_t | ||||
.Fn OF_device_from_xref "phandle_t xref" | .Fn OF_device_from_xref "phandle_t xref" | ||||
.Ft phandle_t | .Ft phandle_t | ||||
.Fn OF_xref_from_device "device_t dev" | .Fn OF_xref_from_device "device_t dev" | ||||
.Sh DESCRIPTION | .Sh DESCRIPTION | ||||
.Pp | .Pp | ||||
When a device tree node references another node, the driver may | When a device tree node references another node, the driver may | ||||
need to get a device_t instance associated with the referenced node. | need to get a device_t instance associated with the referenced node. | ||||
For instance, an Ethernet driver accessing a PHY device. | For instance, an Ethernet driver accessing a PHY device. | ||||
To make this possible, the kernel maintains a table that | To make this possible, the kernel maintains a table that | ||||
maps effective handles to device_t instances. | maps effective handles to device_t instances. | ||||
.Pp | .Pp | ||||
.Fn OF_device_register_xref | .Fn OF_device_register_xref | ||||
adds a map entry from the effective phandle | adds a map entry from the effective phandle | ||||
.Fa xref | .Fa xref | ||||
to device | to device | ||||
.Fa dev . | .Fa dev . | ||||
If a mapping entry for | If a mapping entry for | ||||
.Fa xref | .Fa xref | ||||
already exists, it is replaced with the new one. | already exists, it is replaced with the new one. | ||||
The function always returns 0. | The function always returns 0. | ||||
.Pp | |||||
.Fn OF_device_unregister_xref | |||||
removes a map entry from the effective phandle | |||||
.Fa xref | |||||
to device | |||||
.Fa dev . | |||||
If a mapping entry for | |||||
.Fa xref | |||||
does not exists, it silently returns. | |||||
.Pp | .Pp | ||||
.Fn OF_device_from_xref | .Fn OF_device_from_xref | ||||
returns a device_t instance associated with the effective phandle | returns a device_t instance associated with the effective phandle | ||||
.Fa xref . | .Fa xref . | ||||
If no such mapping exists, the function returns NULL. | If no such mapping exists, the function returns NULL. | ||||
.Pp | .Pp | ||||
.Fn OF_xref_from_device | .Fn OF_xref_from_device | ||||
returns the effective phandle associated with the device | returns the effective phandle associated with the device | ||||
Show All 22 Lines |