From owner-svn-src-head@FreeBSD.ORG Mon Sep 1 18:51:05 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id B0CF4DE4; Mon, 1 Sep 2014 18:51:05 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 996B51213; Mon, 1 Sep 2014 18:51:05 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s81Ip5kY093048; Mon, 1 Sep 2014 18:51:05 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s81Ip1oL093023; Mon, 1 Sep 2014 18:51:01 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201409011851.s81Ip1oL093023@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Mon, 1 Sep 2014 18:51:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r270945 - in head/sys: arm/arm arm/at91 arm/freescale/vybrid arm/mv arm/rockchip dev/fdt dev/gpio dev/ofw dev/tsec mips/beri powerpc/ofw powerpc/powermac X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Sep 2014 18:51:05 -0000 Author: ian Date: Mon Sep 1 18:51:01 2014 New Revision: 270945 URL: http://svnweb.freebsd.org/changeset/base/270945 Log: Rename OF_xref_phandle() to OF_node_from_xref() and add a new function that provides the inverse translation, OF_xref_from_node(). Discussed with: nwhitehorn Modified: head/sys/arm/arm/nexus.c head/sys/arm/at91/at91_pinctrl.c head/sys/arm/freescale/vybrid/vf_sai.c head/sys/arm/mv/gpio.c head/sys/arm/rockchip/rk30xx_gpio.c head/sys/dev/fdt/fdt_common.c head/sys/dev/fdt/simplebus.c head/sys/dev/gpio/ofw_gpiobus.c head/sys/dev/ofw/ofw_bus_subr.c head/sys/dev/ofw/ofw_fdt.c head/sys/dev/ofw/ofwbus.c head/sys/dev/ofw/openfirm.c head/sys/dev/ofw/openfirm.h head/sys/dev/tsec/if_tsec_fdt.c head/sys/mips/beri/beri_simplebus.c head/sys/powerpc/ofw/ofw_pcibus.c head/sys/powerpc/powermac/macio.c Modified: head/sys/arm/arm/nexus.c ============================================================================== --- head/sys/arm/arm/nexus.c Mon Sep 1 18:37:17 2014 (r270944) +++ head/sys/arm/arm/nexus.c Mon Sep 1 18:51:01 2014 (r270945) @@ -341,7 +341,7 @@ nexus_ofw_map_intr(device_t dev, device_ 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]); Modified: head/sys/arm/at91/at91_pinctrl.c ============================================================================== --- head/sys/arm/at91/at91_pinctrl.c Mon Sep 1 18:37:17 2014 (r270944) +++ head/sys/arm/at91/at91_pinctrl.c Mon Sep 1 18:51:01 2014 (r270945) @@ -136,7 +136,7 @@ at91_pinctrl_setup_dinfo(device_t dev, p "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_ 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); Modified: head/sys/arm/freescale/vybrid/vf_sai.c ============================================================================== --- head/sys/arm/freescale/vybrid/vf_sai.c Mon Sep 1 18:37:17 2014 (r270944) +++ head/sys/arm/freescale/vybrid/vf_sai.c Mon Sep 1 18:51:01 2014 (r270945) @@ -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); Modified: head/sys/arm/mv/gpio.c ============================================================================== --- head/sys/arm/mv/gpio.c Mon Sep 1 18:37:17 2014 (r270944) +++ head/sys/arm/mv/gpio.c Mon Sep 1 18:51:01 2014 (r270945) @@ -642,7 +642,7 @@ mv_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. */ Modified: head/sys/arm/rockchip/rk30xx_gpio.c ============================================================================== --- head/sys/arm/rockchip/rk30xx_gpio.c Mon Sep 1 18:37:17 2014 (r270944) +++ head/sys/arm/rockchip/rk30xx_gpio.c Mon Sep 1 18:51:01 2014 (r270945) @@ -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. */ Modified: head/sys/dev/fdt/fdt_common.c ============================================================================== --- head/sys/dev/fdt/fdt_common.c Mon Sep 1 18:37:17 2014 (r270944) +++ head/sys/dev/fdt/fdt_common.c Mon Sep 1 18:51:01 2014 (r270945) @@ -510,7 +510,7 @@ fdt_intr_to_rl(device_t dev, phandle_t n "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 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) Modified: head/sys/dev/fdt/simplebus.c ============================================================================== --- head/sys/dev/fdt/simplebus.c Mon Sep 1 18:37:17 2014 (r270944) +++ head/sys/dev/fdt/simplebus.c Mon Sep 1 18:51:01 2014 (r270945) @@ -298,7 +298,7 @@ simplebus_setup_dinfo(device_t dev, phan "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"); Modified: head/sys/dev/gpio/ofw_gpiobus.c ============================================================================== --- head/sys/dev/gpio/ofw_gpiobus.c Mon Sep 1 18:37:17 2014 (r270944) +++ head/sys/dev/gpio/ofw_gpiobus.c Mon Sep 1 18:51:01 2014 (r270945) @@ -129,7 +129,7 @@ ofw_gpiobus_parse_gpios(struct gpiobus_s 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_s 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) { Modified: head/sys/dev/ofw/ofw_bus_subr.c ============================================================================== --- head/sys/dev/ofw/ofw_bus_subr.c Mon Sep 1 18:37:17 2014 (r270944) +++ head/sys/dev/ofw/ofw_bus_subr.c Mon Sep 1 18:51:01 2014 (r270945) @@ -344,7 +344,7 @@ ofw_bus_search_intrmap(void *intr, int i 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); Modified: head/sys/dev/ofw/ofw_fdt.c ============================================================================== --- head/sys/dev/ofw/ofw_fdt.c Mon Sep 1 18:37:17 2014 (r270944) +++ head/sys/dev/ofw/ofw_fdt.c Mon Sep 1 18:51:01 2014 (r270945) @@ -208,7 +208,7 @@ ofw_fdt_instance_to_package(ofw_t ofw, i { /* 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. */ Modified: head/sys/dev/ofw/ofwbus.c ============================================================================== --- head/sys/dev/ofw/ofwbus.c Mon Sep 1 18:37:17 2014 (r270944) +++ head/sys/dev/ofw/ofwbus.c Mon Sep 1 18:51:01 2014 (r270945) @@ -494,7 +494,7 @@ ofwbus_setup_dinfo(device_t dev, phandle "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); Modified: head/sys/dev/ofw/openfirm.c ============================================================================== --- head/sys/dev/ofw/openfirm.c Mon Sep 1 18:37:17 2014 (r270944) +++ head/sys/dev/ofw/openfirm.c Mon Sep 1 18:51:01 2014 (r270945) @@ -463,7 +463,7 @@ OF_child_xref_phandle(phandle_t parent, } 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, Modified: head/sys/dev/ofw/openfirm.h ============================================================================== --- head/sys/dev/ofw/openfirm.h Mon Sep 1 18:37:17 2014 (r270944) +++ head/sys/dev/ofw/openfirm.h Mon Sep 1 18:51:01 2014 (r270945) @@ -130,7 +130,8 @@ ssize_t OF_package_to_path(phandle_t no * 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); Modified: head/sys/dev/tsec/if_tsec_fdt.c ============================================================================== --- head/sys/dev/tsec/if_tsec_fdt.c Mon Sep 1 18:37:17 2014 (r270944) +++ head/sys/dev/tsec/if_tsec_fdt.c Mon Sep 1 18:51:01 2014 (r270945) @@ -166,7 +166,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)); Modified: head/sys/mips/beri/beri_simplebus.c ============================================================================== --- head/sys/mips/beri/beri_simplebus.c Mon Sep 1 18:37:17 2014 (r270944) +++ head/sys/mips/beri/beri_simplebus.c Mon Sep 1 18:51:01 2014 (r270945) @@ -351,7 +351,7 @@ simplebus_get_interrupt_parent(device_t 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; Modified: head/sys/powerpc/ofw/ofw_pcibus.c ============================================================================== --- head/sys/powerpc/ofw/ofw_pcibus.c Mon Sep 1 18:37:17 2014 (r270944) +++ head/sys/powerpc/ofw/ofw_pcibus.c Mon Sep 1 18:51:01 2014 (r270945) @@ -212,7 +212,7 @@ ofw_pcibus_enum_devtree(device_t dev, u_ 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 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)); /* Modified: head/sys/powerpc/powermac/macio.c ============================================================================== --- head/sys/powerpc/powermac/macio.c Mon Sep 1 18:37:17 2014 (r270944) +++ head/sys/powerpc/powermac/macio.c Mon Sep 1 18:51:01 2014 (r270945) @@ -217,7 +217,7 @@ macio_add_intr(phandle_t devnode, struct <= 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;