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

Ian Lepore ian at FreeBSD.org
Mon Sep 1 18:51:05 UTC 2014


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;
 


More information about the svn-src-all mailing list