| 129 | } |
| 130 | |
| 131 | static struct rt_ofw_node *ofw_get_next_node(struct rt_ofw_node *prev) |
| 132 | { |
| 133 | struct rt_ofw_node *np; |
| 134 | |
| 135 | /* |
| 136 | * Walk: |
| 137 | * |
| 138 | * / { ------------------------ [0] (START) has child, goto child. |
| 139 | * |
| 140 | * node0 { ---------------- [1] has child, goto child. |
| 141 | * |
| 142 | * node0_0 { ---------- [2] no child, has sibling, goto sibling. |
| 143 | * }; |
| 144 | * |
| 145 | * node0_1 { ---------- [3] no sibling now. |
| 146 | * upward while the parent has sibling. |
| 147 | * }; |
| 148 | * }; |
| 149 | * |
| 150 | * node1 { ---------------- [4] come from node0 who find the sibling: |
| 151 | * node1, node1 has child, goto child. |
| 152 | * |
| 153 | * node1_0 { ---------- [5] has child, goto child. |
| 154 | * |
| 155 | * node1_0_0 { ---- [6] no sibling now. |
| 156 | * upward while the parent has sibling. |
| 157 | * (END) in the root. |
| 158 | * }; |
| 159 | * }; |
| 160 | * }; |
| 161 | * }; |
| 162 | */ |
| 163 | |
| 164 | if (!prev) |
| 165 | { |
| 166 | np = ofw_node_root; |
| 167 | } |
| 168 | else if (prev->child) |
| 169 | { |
| 170 | np = prev->child; |
| 171 | } |
| 172 | else |
| 173 | { |
| 174 | np = prev; |
| 175 | |
| 176 | while (np->parent && !np->sibling) |
| 177 | { |
| 178 | np = np->parent; |
| 179 | } |
| 180 | |
| 181 | np = np->sibling; |
| 182 | } |
| 183 | |
| 184 | return np; |
| 185 | } |
| 186 | |
| 187 | static void ofw_node_destroy(struct rt_ofw_node *np) |
| 188 | { |
no outgoing calls
no test coverage detected