MFC r270945:

Rename OF_xref_phandle() to OF_node_from_xref() and add a new function
that provides the inverse translation, OF_xref_from_node().
This commit is contained in:
ian 2014-10-26 01:30:46 +00:00
parent 520f9702ad
commit 1c8cde378e
17 changed files with 36 additions and 21 deletions

View File

@ -341,7 +341,7 @@ nexus_ofw_map_intr(device_t dev, device_t child, phandle_t iparent, int icells,
phandle_t intr_offset;
int i, rv, interrupt, trig, pol;
intr_offset = OF_xref_phandle(iparent);
intr_offset = OF_node_from_xref(iparent);
for (i = 0; i < icells; i++)
intr[i] = cpu_to_fdt32(intr[i]);

View File

@ -136,7 +136,7 @@ at91_pinctrl_setup_dinfo(device_t dev, phandle_t node)
"assuming direct parent\n");
iparent = OF_parent(node);
}
if (OF_searchencprop(OF_xref_phandle(iparent),
if (OF_searchencprop(OF_node_from_xref(iparent),
"#interrupt-cells", &icells, sizeof(icells)) == -1) {
device_printf(dev, "Missing #interrupt-cells property, "
"assuming <1>\n");
@ -399,7 +399,7 @@ pinctrl_walk_tree(device_t bus, phandle_t node)
len /= sizeof(phandle_t);
printf("pinctrl: Found active node %s\n", name);
for (i = 0; i < len; i++) {
scratch = OF_xref_phandle(pinctrl[i]);
scratch = OF_node_from_xref(pinctrl[i]);
npins = OF_getencprop(scratch, "atmel,pins", pins, sizeof(pins));
if (npins <= 0) {
printf("We're doing it wrong %s\n", name);

View File

@ -430,7 +430,7 @@ find_edma_controller(struct sc_info *sc)
OF_getprop(node, "edma-mux-group", &dts_value, len);
edma_mux_group = fdt32_to_cpu(dts_value);
OF_getprop(node, "edma-controller", &dts_value, len);
edma_node = OF_xref_phandle(fdt32_to_cpu(dts_value));
edma_node = OF_node_from_xref(fdt32_to_cpu(dts_value));
if ((len = OF_getproplen(edma_node, "device-id")) <= 0) {
return (ENXIO);

View File

@ -641,7 +641,7 @@ platform_gpio_init(void)
* contain a ref. to a node defining GPIO
* controller.
*/
ctrl = OF_xref_phandle(fdt32_to_cpu(gpios[0]));
ctrl = OF_node_from_xref(fdt32_to_cpu(gpios[0]));
if (fdt_is_compatible(ctrl, e->compat))
/* Call a handler. */

View File

@ -656,7 +656,7 @@ rk30_gpio_init(void)
* contain a ref. to a node defining GPIO
* controller.
*/
ctrl = OF_xref_phandle(fdt32_to_cpu(gpios[0]));
ctrl = OF_node_from_xref(fdt32_to_cpu(gpios[0]));
if (fdt_is_compatible(ctrl, e->compat))
/* Call a handler. */

View File

@ -510,7 +510,7 @@ fdt_intr_to_rl(device_t dev, phandle_t node, struct resource_list *rl,
"assuming direct parent\n");
iparent = OF_parent(node);
}
if (OF_searchencprop(OF_xref_phandle(iparent),
if (OF_searchencprop(OF_node_from_xref(iparent),
"#interrupt-cells", &icells, sizeof(icells)) == -1) {
device_printf(dev, "Missing #interrupt-cells property, "
"assuming <1>\n");
@ -545,7 +545,7 @@ fdt_get_phyaddr(phandle_t node, device_t dev, int *phy_addr, void **phy_sc)
sizeof(phy_handle)) <= 0)
return (ENXIO);
phy_node = OF_xref_phandle(phy_handle);
phy_node = OF_node_from_xref(phy_handle);
if (OF_getprop(phy_node, "reg", (void *)&phy_reg,
sizeof(phy_reg)) <= 0)

View File

@ -298,7 +298,7 @@ simplebus_setup_dinfo(device_t dev, phandle_t node)
"assuming direct parent\n");
iparent = OF_parent(node);
}
if (OF_searchencprop(OF_xref_phandle(iparent),
if (OF_searchencprop(OF_node_from_xref(iparent),
"#interrupt-cells", &icells, sizeof(icells)) == -1) {
device_printf(dev, "Missing #interrupt-cells property, "
"assuming <1>\n");

View File

@ -129,7 +129,7 @@ ofw_gpiobus_parse_gpios(struct gpiobus_softc *sc, struct gpiobus_ivar *dinfo,
i++;
continue;
}
gpio = OF_xref_phandle(gpios[i]);
gpio = OF_node_from_xref(gpios[i]);
/* Verify if we're attaching to the correct GPIO controller. */
if (!OF_hasprop(gpio, "gpio-controller") ||
gpio != ofw_bus_get_node(sc->sc_dev)) {
@ -168,7 +168,7 @@ ofw_gpiobus_parse_gpios(struct gpiobus_softc *sc, struct gpiobus_ivar *dinfo,
continue;
}
gpio = OF_xref_phandle(gpios[i]);
gpio = OF_node_from_xref(gpios[i]);
/* Read gpio-cells property for this GPIO controller. */
if (OF_getencprop(gpio, "#gpio-cells", &cells,
sizeof(cells)) < 0) {

View File

@ -344,7 +344,7 @@ ofw_bus_search_intrmap(void *intr, int intrsz, void *regs, int physsz,
i = imapsz;
while (i > 0) {
bcopy(mptr + physsz + intrsz, &parent, sizeof(parent));
if (OF_searchencprop(OF_xref_phandle(parent),
if (OF_searchencprop(OF_node_from_xref(parent),
"#interrupt-cells", &pintrsz, sizeof(pintrsz)) == -1)
pintrsz = 1; /* default */
pintrsz *= sizeof(pcell_t);

View File

@ -208,7 +208,7 @@ ofw_fdt_instance_to_package(ofw_t ofw, ihandle_t instance)
{
/* Where real OF uses ihandles in the tree, FDT uses xref phandles */
return (OF_xref_phandle(instance));
return (OF_node_from_xref(instance));
}
/* Get the length of a property of a package. */

View File

@ -494,7 +494,7 @@ ofwbus_setup_dinfo(device_t dev, phandle_t node)
"assuming nexus on <%s>\n", nodename);
iparent = 0xffffffff;
}
if (OF_searchencprop(OF_xref_phandle(iparent),
if (OF_searchencprop(OF_node_from_xref(iparent),
"#interrupt-cells", &icells, sizeof(icells)) == -1) {
device_printf(dev, "Missing #interrupt-cells property, "
"assuming <1> on <%s>\n", nodename);

View File

@ -463,7 +463,7 @@ OF_child_xref_phandle(phandle_t parent, phandle_t xref)
}
phandle_t
OF_xref_phandle(phandle_t xref)
OF_node_from_xref(phandle_t xref)
{
phandle_t node;
@ -474,6 +474,20 @@ OF_xref_phandle(phandle_t xref)
return (node);
}
phandle_t
OF_xref_from_node(phandle_t node)
{
phandle_t xref;
if (OF_getencprop(node, "phandle", &xref, sizeof(xref)) ==
-1 && OF_getencprop(node, "ibm,phandle", &xref,
sizeof(xref)) == -1 && OF_getencprop(node,
"linux,phandle", &xref, sizeof(xref)) == -1)
return (node);
return (xref);
}
/* Call the method in the scope of a given instance. */
int
OF_call_method(const char *method, ihandle_t instance, int nargs, int nreturns,

View File

@ -130,7 +130,8 @@ ssize_t OF_package_to_path(phandle_t node, char *buf, size_t len);
* real phandle. If one can't be found (or running on OF implementations
* without this property), returns its input.
*/
phandle_t OF_xref_phandle(phandle_t xref);
phandle_t OF_node_from_xref(phandle_t xref);
phandle_t OF_xref_from_node(phandle_t node);
/* Device I/O functions */
ihandle_t OF_open(const char *path);

View File

@ -168,7 +168,7 @@ tsec_fdt_attach(device_t dev)
return (ENXIO);
}
phy = OF_xref_phandle(phy);
phy = OF_node_from_xref(phy);
OF_decode_addr(OF_parent(phy), 0, &sc->phy_bst, &sc->phy_bsh);
OF_getencprop(phy, "reg", &sc->phyaddr, sizeof(sc->phyaddr));

View File

@ -350,7 +350,7 @@ simplebus_get_interrupt_parent(device_t dev)
if (OF_getencprop(di->di_ofw.obd_node, "interrupt-parent", &iph,
sizeof(iph)) > 0) {
ph = OF_xref_phandle(iph);
ph = OF_node_from_xref(iph);
SLIST_FOREACH(ic, &fdt_ic_list_head, fdt_ics) {
if (ic->iph == ph) {
ip = ic->dev;

View File

@ -212,7 +212,7 @@ ofw_pcibus_enum_devtree(device_t dev, u_int domain, u_int busno)
OF_getprop(child, "interrupt-parent", &iparent,
sizeof(iparent));
if (iparent != 0) {
OF_getprop(OF_xref_phandle(iparent),
OF_getprop(OF_node_from_xref(iparent),
"#interrupt-cells", &icells,
sizeof(icells));
intr[0] = ofw_bus_map_intr(dev, iparent,
@ -329,7 +329,7 @@ ofw_pcibus_assign_interrupt(device_t dev, device_t child)
iparent = -1;
icells = 1;
if (iparent != -1)
OF_getprop(OF_xref_phandle(iparent), "#interrupt-cells",
OF_getprop(OF_node_from_xref(iparent), "#interrupt-cells",
&icells, sizeof(icells));
/*

View File

@ -217,7 +217,7 @@ macio_add_intr(phandle_t devnode, struct macio_devinfo *dinfo)
<= 0)
panic("Interrupt but no interrupt parent!\n");
if (OF_getprop(OF_xref_phandle(iparent), "#interrupt-cells", &icells,
if (OF_getprop(OF_node_from_xref(iparent), "#interrupt-cells", &icells,
sizeof(icells)) <= 0)
icells = 1;