Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
OF_DEVICE_FROM_XREF(9)	 BSD Kernel Developer's	Manual	OF_DEVICE_FROM_XREF(9)

NAME
     OF_device_from_xref, OF_xref_from_device, OF_device_register_xref -- man-
     age mappings between xrefs	and devices

SYNOPSIS
     #include <dev/ofw/ofw_bus.h>
     #include <dev/ofw/ofw_bus_subr.h>

     int
     OF_device_register_xref(phandle_t xref, device_t dev);

     device_t
     OF_device_from_xref(phandle_t xref);

     phandle_t
     OF_xref_from_device(device_t dev);

DESCRIPTION
     When a device tree	node references	another	node, the driver may need to
     get a device_t instance associated	with the referenced node.  For in-
     stance, an	Ethernet driver	accessing a PHY	device.	 To make this possi-
     ble, 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 ef-
     fective 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);
	 }

SEE ALSO
     OF_node_to_xref(9)

AUTHORS
     This manual page was written by Oleksandr Tymoshenko <gonzo@FreeBSD.org>.

BSD				 April 9, 2018				   BSD

NAME | SYNOPSIS | DESCRIPTION | EXAMPLES | SEE ALSO | AUTHORS

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=OF_device_from_xref&sektion=9&manpath=FreeBSD+12.0-RELEASE+and+Ports>

home | help