<p>Furquan Shaikh has uploaded this change for <strong>review</strong>.</p><p><a href="https://review.coreboot.org/26803">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">util/sconfig: Change walk_device_tree to breadth-first walk<br><br>Instead of relying on next_sibling to walk through the entire device<br>tree, this change does breadth-first walk by making use of the generic<br>queue.<br><br>BUG=b:80081934<br>TEST=Verified by grepping and sorting device structure names with and<br>without this CL to ensure that there is no change in static.c for all<br>boards built using abuild.<br><br>Change-Id: I485b2c51f091d5186f8bc8f3075f28193148e940<br>Signed-off-by: Furquan Shaikh <furquan@google.com><br>---<br>M util/sconfig/main.c<br>1 file changed, 29 insertions(+), 3 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://review.coreboot.org:29418/coreboot refs/changes/03/26803/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/util/sconfig/main.c b/util/sconfig/main.c</span><br><span>index 3bdd4d2..d60fb03 100644</span><br><span>--- a/util/sconfig/main.c</span><br><span>+++ b/util/sconfig/main.c</span><br><span>@@ -750,13 +750,39 @@</span><br><span>              emit_dev_children(fil, ptr);</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+static void add_siblings_to_queue(struct queue **bfs_queue, struct device *d)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+       while (d) {</span><br><span style="color: hsl(120, 100%, 40%);">+           enqueue_tail(bfs_queue, d);</span><br><span style="color: hsl(120, 100%, 40%);">+           d = d->sibling;</span><br><span style="color: hsl(120, 100%, 40%);">+    }</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+static void add_children_to_queue(struct queue **bfs_queue, struct device *d)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+      if (!device_has_instance(d)) {</span><br><span style="color: hsl(120, 100%, 40%);">+                add_siblings_to_queue(bfs_queue, d->children);</span><br><span style="color: hsl(120, 100%, 40%);">+             return;</span><br><span style="color: hsl(120, 100%, 40%);">+       }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   struct dev_instance *ins = d->dev_instance;</span><br><span style="color: hsl(120, 100%, 40%);">+        while (ins) {</span><br><span style="color: hsl(120, 100%, 40%);">+         add_siblings_to_queue(bfs_queue, ins->children);</span><br><span style="color: hsl(120, 100%, 40%);">+           ins = ins->next;</span><br><span style="color: hsl(120, 100%, 40%);">+   }</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> static void walk_device_tree(FILE * fil, struct device *ptr,</span><br><span>                            void (*func) (FILE *, struct device *))</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">-       do {</span><br><span style="color: hsl(120, 100%, 40%);">+  struct queue *bfs_queue = NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     enqueue_tail(&bfs_queue, ptr);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+  while ((ptr = dequeue_head(&bfs_queue))) {</span><br><span style="color: hsl(120, 100%, 40%);">+                add_children_to_queue(&bfs_queue, ptr);</span><br><span>          func(fil, ptr);</span><br><span style="color: hsl(0, 100%, 40%);">-         ptr = ptr->next_sibling;</span><br><span style="color: hsl(0, 100%, 40%);">-     } while (ptr);</span><br><span style="color: hsl(120, 100%, 40%);">+        }</span><br><span> }</span><br><span> </span><br><span> static void emit_chip_headers(FILE *fil, struct chip *chip)</span><br><span></span><br></pre><p>To view, visit <a href="https://review.coreboot.org/26803">change 26803</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://review.coreboot.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://review.coreboot.org/26803"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: coreboot </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I485b2c51f091d5186f8bc8f3075f28193148e940 </div>
<div style="display:none"> Gerrit-Change-Number: 26803 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Furquan Shaikh <furquan@google.com> </div>