PERFORCE change 172869 for review

Rafal Jaworowski raj at FreeBSD.org
Sat Jan 9 21:03:20 UTC 2010


http://p4web.freebsd.org/chv.cgi?CH=172869

Change 172869 by raj at raj_fdt on 2010/01/09 21:03:08

	Respect 'status' property if present in the node.
	
	Do not instantiate a device unless status == okay.

Affected files ...

.. //depot/projects/fdt/sys/dev/fdt/fdt_common.c#3 edit
.. //depot/projects/fdt/sys/dev/fdt/fdt_common.h#2 edit
.. //depot/projects/fdt/sys/dev/fdt/fdtbus.c#2 edit
.. //depot/projects/fdt/sys/dev/fdt/simplebus.c#2 edit

Differences ...

==== //depot/projects/fdt/sys/dev/fdt/fdt_common.c#3 (text+ko) ====

@@ -59,6 +59,28 @@
 #endif
 
 int
+fdt_is_enabled(phandle_t node)
+{
+	char *stat;
+	int ena, len;
+
+	len = OF_getprop_alloc(node, "status", sizeof(char),
+	    (void **)&stat);
+
+	if (len <= 0)
+		/* It is OK if no 'status' property. */
+		return (1);
+
+	/* Anything other than 'okay' means disabled. */
+	ena = 0;
+	if (strncmp((char *)stat, "okay", len) == 0)
+		ena = 1;
+
+	free(stat, M_OFWPROP);
+	return (ena);
+}
+
+int
 fdt_parent_addr_cells(phandle_t node)
 {
 	pcell_t addr_cells;

==== //depot/projects/fdt/sys/dev/fdt/fdt_common.h#2 (text+ko) ====

@@ -47,5 +47,6 @@
 int fdt_reg_to_rl(phandle_t, struct resource_list *, u_long);
 int fdt_intr_to_rl(phandle_t, struct resource_list *, struct sense_level *);
 int fdt_data_to_res(pcell_t *, int, int, u_long *, u_long *);
+int fdt_is_enabled(phandle_t);
 
 #endif /* FDT_COMMON_H */

==== //depot/projects/fdt/sys/dev/fdt/fdtbus.c#2 (text+ko) ====

@@ -213,8 +213,13 @@
 	/*
 	 * Walk the FDT root node and add top-level devices as our children.
 	 */
-	for (child = OF_child(root); child != 0; child = OF_peer(child))
+	for (child = OF_child(root); child != 0; child = OF_peer(child)) {
+		/* Check and process 'status' property. */
+		if (!(fdt_is_enabled(child)))
+			continue;
+
 		newbus_device_from_fdt_node(dev, child);
+	}
 
 	return (bus_generic_attach(dev));
 }

==== //depot/projects/fdt/sys/dev/fdt/simplebus.c#2 (text+ko) ====

@@ -163,6 +163,7 @@
 	len = OF_getprop_alloc(root, "model", 1, (void **)&model);
 	if (len <= 0)
 		return;
+	/* XXX this should be a table with {model->fixup_handler} */
 	if (!(strcmp(model, "fsl,MPC8572DS") == 0 ||
 	    strcmp(model, "MPC8555CDS") == 0))
 		goto out;
@@ -248,6 +249,10 @@
 	 */
 	for (child = OF_child(node); child != 0; child = OF_peer(child)) {
 
+		/* Check and process 'status' property. */
+		if (!(fdt_is_enabled(child)))
+			continue;
+
 		di = malloc(sizeof(*di), M_SIMPLEBUS, M_WAITOK | M_ZERO);
 
 		if (ofw_bus_gen_setup_devinfo(&di->di_ofw, child) != 0) {
@@ -317,8 +322,6 @@
 	struct simplebus_devinfo *di;
 	struct resource_list_entry *rle;
 
-	debugf("type = %d, rid = %d\n", type, *rid);
-
 	/*
 	 * Request for the default allocation with a given rid: use resource
 	 * list stored in the local device info.


More information about the p4-projects mailing list