Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 70161ff3 authored by Grant Likely's avatar Grant Likely
Browse files

of: Drop ->next pointer from struct device_node



The ->next pointer in struct device_node is a hanger-on from when it was
used to iterate over the whole tree by a particular device_type property
value. Those days are long over, but the fdt unflattening code still
uses it to put nodes in the unflattened tree into the same order as node
in the flat tree. By reworking the unflattening code to reverse the list
after unflattening all the children of a node, the pointer can be
dropped which gives a small amount of memory savings.

Signed-off-by: default avatarGrant Likely <grant.likely@linaro.org>
Acked-by: default avatarFrank Rowand <frank.rowand@sonymobile.com>
Cc: Gaurav Minocha <gaurav.minocha.os@gmail.com>
parent 5267720e
Loading
Loading
Loading
Loading
+18 −6
Original line number Original line Diff line number Diff line
@@ -226,12 +226,8 @@ static void * unflatten_dt_node(void *blob,
		prev_pp = &np->properties;
		prev_pp = &np->properties;
		if (dad != NULL) {
		if (dad != NULL) {
			np->parent = dad;
			np->parent = dad;
			/* we temporarily use the next field as `last_child'*/
			np->sibling = dad->child;
			if (dad->next == NULL)
			dad->child = np;
			dad->child = np;
			else
				dad->next->sibling = np;
			dad->next = np;
		}
		}
	}
	}
	/* process properties */
	/* process properties */
@@ -329,6 +325,22 @@ static void * unflatten_dt_node(void *blob,


	if (*poffset < 0 && *poffset != -FDT_ERR_NOTFOUND)
	if (*poffset < 0 && *poffset != -FDT_ERR_NOTFOUND)
		pr_err("unflatten: error %d processing FDT\n", *poffset);
		pr_err("unflatten: error %d processing FDT\n", *poffset);

	/*
	 * Reverse the child list. Some drivers assumes node order matches .dts
	 * node order
	 */
	if (!dryrun && np->child) {
		struct device_node *child = np->child;
		np->child = NULL;
		while (child) {
			struct device_node *next = child->sibling;
			child->sibling = np->child;
			np->child = child;
			child = next;
		}
	}

	if (nodepp)
	if (nodepp)
		*nodepp = np;
		*nodepp = np;


+0 −1
Original line number Original line Diff line number Diff line
@@ -56,7 +56,6 @@ struct device_node {
	struct	device_node *parent;
	struct	device_node *parent;
	struct	device_node *child;
	struct	device_node *child;
	struct	device_node *sibling;
	struct	device_node *sibling;
	struct	device_node *next;	/* next device of same type */
	struct	kobject kobj;
	struct	kobject kobj;
	unsigned long _flags;
	unsigned long _flags;
	void	*data;
	void	*data;