Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 15 Dec 2009 22:35:43 GMT
From:      Rafal Jaworowski <raj@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 171818 for review
Message-ID:  <200912152235.nBFMZhFR073077@repoman.freebsd.org>

index | next in thread | raw e-mail

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

Change 171818 by raj@raj_fdt on 2009/12/15 22:35:36

	Allow for translation of internal FDT phandles via
	OF_instance_to_package().
	
	This slighly abuses the OF_* i/f as FDT does not really have the
	notion of instances, but lets us get away with a uniform way of
	handling internal FDT offsets at the consumer level; this is needed in
	some specific cases like interrupt domain graph traversal.

Affected files ...

.. //depot/projects/fdt/sys/dev/ofw/ofw_fdt.c#2 edit

Differences ...

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

@@ -201,8 +201,7 @@
 ofw_fdt_parent(ofw_t ofw, phandle_t node)
 {
 	phandle_t p;
-	int offset;
-	int paroffset;
+	int offset, paroffset;
 
 	offset = fdt_phandle_offset(node);
 	if (offset < 0)
@@ -217,8 +216,22 @@
 static phandle_t
 ofw_fdt_instance_to_package(ofw_t ofw, ihandle_t instance)
 {
+	phandle_t p;
+	int offset;
 
-	return (0);
+	/*
+	 * Note: FDT does not have the notion of instances, but we somewhat
+	 * abuse the semantics and let treat as 'instance' the internal
+	 * 'phandle' prop, so that ofw I/F consumers have a uniform way of
+	 * translation between internal representation (which appear in some
+	 * contexts as property values) and effective phandles.
+	 */
+	offset = fdt_node_offset_by_phandle(fdtp, instance);
+	if (offset < 0)
+		return (0);
+
+	p = (phandle_t)fdt_offset_ptr(fdtp, offset, sizeof(phandle_t));
+	return (p);
 }
 
 /* Get the length of a property of a package. */


help

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200912152235.nBFMZhFR073077>