diff options
author | ian <ian@FreeBSD.org> | 2014-10-26 01:30:46 +0000 |
---|---|---|
committer | ian <ian@FreeBSD.org> | 2014-10-26 01:30:46 +0000 |
commit | 1c8cde378e7386ca86f33d4ce67b360782b6abec (patch) | |
tree | f847b5f519d4b7fc00e295ee9cb3686f2cec6de9 /sys | |
parent | 520f9702ad1e3b22f76421e717bd01dd5c266bde (diff) | |
download | FreeBSD-src-1c8cde378e7386ca86f33d4ce67b360782b6abec.zip FreeBSD-src-1c8cde378e7386ca86f33d4ce67b360782b6abec.tar.gz |
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().
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arm/arm/nexus.c | 2 | ||||
-rw-r--r-- | sys/arm/at91/at91_pinctrl.c | 4 | ||||
-rw-r--r-- | sys/arm/freescale/vybrid/vf_sai.c | 2 | ||||
-rw-r--r-- | sys/arm/mv/gpio.c | 2 | ||||
-rw-r--r-- | sys/arm/rockchip/rk30xx_gpio.c | 2 | ||||
-rw-r--r-- | sys/dev/fdt/fdt_common.c | 4 | ||||
-rw-r--r-- | sys/dev/fdt/simplebus.c | 2 | ||||
-rw-r--r-- | sys/dev/gpio/ofw_gpiobus.c | 4 | ||||
-rw-r--r-- | sys/dev/ofw/ofw_bus_subr.c | 2 | ||||
-rw-r--r-- | sys/dev/ofw/ofw_fdt.c | 2 | ||||
-rw-r--r-- | sys/dev/ofw/ofwbus.c | 2 | ||||
-rw-r--r-- | sys/dev/ofw/openfirm.c | 16 | ||||
-rw-r--r-- | sys/dev/ofw/openfirm.h | 3 | ||||
-rw-r--r-- | sys/dev/tsec/if_tsec_fdt.c | 2 | ||||
-rw-r--r-- | sys/mips/beri/beri_simplebus.c | 2 | ||||
-rw-r--r-- | sys/powerpc/ofw/ofw_pcibus.c | 4 | ||||
-rw-r--r-- | sys/powerpc/powermac/macio.c | 2 |
17 files changed, 36 insertions, 21 deletions
diff --git a/sys/arm/arm/nexus.c b/sys/arm/arm/nexus.c index a66fc3e..83dbc7f 100644 --- a/sys/arm/arm/nexus.c +++ b/sys/arm/arm/nexus.c @@ -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]); diff --git a/sys/arm/at91/at91_pinctrl.c b/sys/arm/at91/at91_pinctrl.c index a53779b..755c8a4 100644 --- a/sys/arm/at91/at91_pinctrl.c +++ b/sys/arm/at91/at91_pinctrl.c @@ -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); diff --git a/sys/arm/freescale/vybrid/vf_sai.c b/sys/arm/freescale/vybrid/vf_sai.c index 018b4f6..586055d 100644 --- a/sys/arm/freescale/vybrid/vf_sai.c +++ b/sys/arm/freescale/vybrid/vf_sai.c @@ -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); diff --git a/sys/arm/mv/gpio.c b/sys/arm/mv/gpio.c index 1bdb81b..862ddd6 100644 --- a/sys/arm/mv/gpio.c +++ b/sys/arm/mv/gpio.c @@ -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. */ diff --git a/sys/arm/rockchip/rk30xx_gpio.c b/sys/arm/rockchip/rk30xx_gpio.c index 3ecedda..2a3288f 100644 --- a/sys/arm/rockchip/rk30xx_gpio.c +++ b/sys/arm/rockchip/rk30xx_gpio.c @@ -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. */ diff --git a/sys/dev/fdt/fdt_common.c b/sys/dev/fdt/fdt_common.c index 2651a3a..77cf8ba 100644 --- a/sys/dev/fdt/fdt_common.c +++ b/sys/dev/fdt/fdt_common.c @@ -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) diff --git a/sys/dev/fdt/simplebus.c b/sys/dev/fdt/simplebus.c index 1c8e54c..e21b913 100644 --- a/sys/dev/fdt/simplebus.c +++ b/sys/dev/fdt/simplebus.c @@ -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"); diff --git a/sys/dev/gpio/ofw_gpiobus.c b/sys/dev/gpio/ofw_gpiobus.c index 6e18292..b7cf65a 100644 --- a/sys/dev/gpio/ofw_gpiobus.c +++ b/sys/dev/gpio/ofw_gpiobus.c @@ -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) { diff --git a/sys/dev/ofw/ofw_bus_subr.c b/sys/dev/ofw/ofw_bus_subr.c index 64ac11f..7ddb5e6 100644 --- a/sys/dev/ofw/ofw_bus_subr.c +++ b/sys/dev/ofw/ofw_bus_subr.c @@ -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); diff --git a/sys/dev/ofw/ofw_fdt.c b/sys/dev/ofw/ofw_fdt.c index 617d2a3..2c9bf6e 100644 --- a/sys/dev/ofw/ofw_fdt.c +++ b/sys/dev/ofw/ofw_fdt.c @@ -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. */ diff --git a/sys/dev/ofw/ofwbus.c b/sys/dev/ofw/ofwbus.c index 22bdd25..5a141af 100644 --- a/sys/dev/ofw/ofwbus.c +++ b/sys/dev/ofw/ofwbus.c @@ -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); diff --git a/sys/dev/ofw/openfirm.c b/sys/dev/ofw/openfirm.c index 97e6cbf..ea82159 100644 --- a/sys/dev/ofw/openfirm.c +++ b/sys/dev/ofw/openfirm.c @@ -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, diff --git a/sys/dev/ofw/openfirm.h b/sys/dev/ofw/openfirm.h index 5ac08fe..5f96eeb 100644 --- a/sys/dev/ofw/openfirm.h +++ b/sys/dev/ofw/openfirm.h @@ -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); diff --git a/sys/dev/tsec/if_tsec_fdt.c b/sys/dev/tsec/if_tsec_fdt.c index 8d4b5a7..d2b6282 100644 --- a/sys/dev/tsec/if_tsec_fdt.c +++ b/sys/dev/tsec/if_tsec_fdt.c @@ -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)); diff --git a/sys/mips/beri/beri_simplebus.c b/sys/mips/beri/beri_simplebus.c index 934a395..ad1bde4 100644 --- a/sys/mips/beri/beri_simplebus.c +++ b/sys/mips/beri/beri_simplebus.c @@ -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; diff --git a/sys/powerpc/ofw/ofw_pcibus.c b/sys/powerpc/ofw/ofw_pcibus.c index ee14ccf..aa943ac 100644 --- a/sys/powerpc/ofw/ofw_pcibus.c +++ b/sys/powerpc/ofw/ofw_pcibus.c @@ -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)); /* diff --git a/sys/powerpc/powermac/macio.c b/sys/powerpc/powermac/macio.c index 6a0b913..b495cb3 100644 --- a/sys/powerpc/powermac/macio.c +++ b/sys/powerpc/powermac/macio.c @@ -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; |