of/promtree: no longer call prom_ functions directly; use an ops structure

Rather than assuming an architecture defines prom_getchild and friends,
define an ops struct with hooks for the various prom functions that
pdt.c needs.  This ops struct is filled in by the
arch-(and sometimes firmware-)specific code, and passed to
of_pdt_build_devicetree.

Update sparc code to define the ops struct as well.

Signed-off-by: Andres Salomon <dilinger@queued.net>
Acked-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
diff --git a/include/linux/of_pdt.h b/include/linux/of_pdt.h
index c0a8774..303c5ff 100644
--- a/include/linux/of_pdt.h
+++ b/include/linux/of_pdt.h
@@ -13,10 +13,28 @@
 #ifndef _LINUX_OF_PDT_H
 #define _LINUX_OF_PDT_H
 
+/* overridable operations for calling into the PROM */
+struct of_pdt_ops {
+	/*
+	 * buf should be 32 bytes; return 0 on success.
+	 * If prev is NULL, the first property will be returned.
+	 */
+	int (*nextprop)(phandle node, char *prev, char *buf);
+
+	/* for both functions, return proplen on success; -1 on error */
+	int (*getproplen)(phandle node, const char *prop);
+	int (*getproperty)(phandle node, const char *prop, char *buf,
+			int bufsize);
+
+	/* phandles are 0 if no child or sibling exists */
+	phandle (*getchild)(phandle parent);
+	phandle (*getsibling)(phandle node);
+};
+
 extern void *prom_early_alloc(unsigned long size);
 
 /* for building the device tree */
-extern void of_pdt_build_devicetree(phandle root_node);
+extern void of_pdt_build_devicetree(phandle root_node, struct of_pdt_ops *ops);
 
 extern void (*prom_build_more)(struct device_node *dp,
 		struct device_node ***nextp);