Commit df87e6b1b815ae3484ea2aa7c53b90af382eae1b

Authored by Simon Glass
1 parent b02e4044ff

libfdt: Sync fdt_for_each_subnode() with upstream

The signature for this macro has changed. Bring in the upstream version and
adjust U-Boot's usages to suit.

Signed-off-by: Simon Glass <sjg@chromium.org>
Update to drivers/power/pmic/palmas.c:
Signed-off-by: Keerthy <j-keerthy@ti.com>

Change-Id: I6cc9021339bfe686f9df21d61a1095ca2b3776e8

Showing 14 changed files with 35 additions and 32 deletions Side-by-side Diff

arch/arm/mach-tegra/xusb-padctl-common.c
... ... @@ -223,7 +223,7 @@
223 223  
224 224 config->name = fdt_get_name(fdt, node, NULL);
225 225  
226   - fdt_for_each_subnode(fdt, subnode, node) {
  226 + fdt_for_each_subnode(subnode, fdt, node) {
227 227 struct tegra_xusb_padctl_group *group;
228 228 int err;
229 229  
... ... @@ -253,7 +253,7 @@
253 253 return err;
254 254 }
255 255  
256   - fdt_for_each_subnode(fdt, subnode, node) {
  256 + fdt_for_each_subnode(subnode, fdt, node) {
257 257 struct tegra_xusb_padctl_config *config = &padctl->config;
258 258  
259 259 err = tegra_xusb_padctl_config_parse_dt(padctl, config, fdt,
... ... @@ -1026,7 +1026,7 @@
1026 1026 }
1027 1027  
1028 1028 /* Process all hash subnodes of the component image node */
1029   - fdt_for_each_subnode(fit, noffset, image_noffset) {
  1029 + fdt_for_each_subnode(noffset, fit, image_noffset) {
1030 1030 const char *name = fit_get_name(fit, noffset, NULL);
1031 1031  
1032 1032 /*
... ... @@ -212,7 +212,7 @@
212 212 int ret;
213 213  
214 214 /* Process all hash subnodes of the component image node */
215   - fdt_for_each_subnode(fit, noffset, image_noffset) {
  215 + fdt_for_each_subnode(noffset, fit, image_noffset) {
216 216 const char *name = fit_get_name(fit, noffset, NULL);
217 217  
218 218 if (!strncmp(name, FIT_SIG_NODENAME,
... ... @@ -260,7 +260,7 @@
260 260 return 0;
261 261 }
262 262  
263   - fdt_for_each_subnode(sig_blob, noffset, sig_node) {
  263 + fdt_for_each_subnode(noffset, sig_blob, sig_node) {
264 264 const char *required;
265 265 int ret;
266 266  
... ... @@ -393,7 +393,7 @@
393 393 int ret;
394 394  
395 395 /* Process all hash subnodes of the component conf node */
396   - fdt_for_each_subnode(fit, noffset, conf_noffset) {
  396 + fdt_for_each_subnode(noffset, fit, conf_noffset) {
397 397 const char *name = fit_get_name(fit, noffset, NULL);
398 398  
399 399 if (!strncmp(name, FIT_SIG_NODENAME,
... ... @@ -438,7 +438,7 @@
438 438 return 0;
439 439 }
440 440  
441   - fdt_for_each_subnode(sig_blob, noffset, sig_node) {
  441 + fdt_for_each_subnode(noffset, sig_blob, sig_node) {
442 442 const char *required;
443 443 int ret;
444 444  
... ... @@ -1219,7 +1219,7 @@
1219 1219 active_slave = fdtdec_get_int(fdt, node, "active_slave", 0);
1220 1220 priv->data.active_slave = active_slave;
1221 1221  
1222   - fdt_for_each_subnode(fdt, subnode, node) {
  1222 + fdt_for_each_subnode(subnode, fdt, node) {
1223 1223 int len;
1224 1224 const char *name;
1225 1225  
drivers/net/keystone_net.c
... ... @@ -990,7 +990,7 @@
990 990 char *slave_name;
991 991  
992 992 interfaces = fdt_subnode_offset(fdt, gbe, "interfaces");
993   - fdt_for_each_subnode(fdt, slave, interfaces) {
  993 + fdt_for_each_subnode(slave, fdt, interfaces) {
994 994 int slave_no;
995 995  
996 996 slave_no = fdtdec_get_int(fdt, slave, "slave-port", -ENOENT);
... ... @@ -1015,7 +1015,7 @@
1015 1015 }
1016 1016  
1017 1017 sec_slave = fdt_subnode_offset(fdt, gbe, "secondary-slave-ports");
1018   - fdt_for_each_subnode(fdt, slave, sec_slave) {
  1018 + fdt_for_each_subnode(slave, fdt, sec_slave) {
1019 1019 int slave_no;
1020 1020  
1021 1021 slave_no = fdtdec_get_int(fdt, slave, "slave-port", -ENOENT);
... ... @@ -4153,7 +4153,7 @@
4153 4153 return -ENOENT;
4154 4154 }
4155 4155  
4156   - fdt_for_each_subnode(blob, subnode, node) {
  4156 + fdt_for_each_subnode(subnode, blob, node) {
4157 4157 /* Skip disabled ports */
4158 4158 if (!fdtdec_get_is_enabled(blob, subnode))
4159 4159 continue;
drivers/pci/pci_tegra.c
... ... @@ -531,7 +531,7 @@
531 531 }
532 532 #endif
533 533  
534   - fdt_for_each_subnode(fdt, subnode, node) {
  534 + fdt_for_each_subnode(subnode, fdt, node) {
535 535 unsigned int index = 0, num_lanes = 0;
536 536 struct tegra_pcie_port *port;
537 537  
drivers/phy/marvell/comphy_core.c
... ... @@ -152,7 +152,7 @@
152 152 }
153 153  
154 154 lane = 0;
155   - fdt_for_each_subnode(blob, subnode, node) {
  155 + fdt_for_each_subnode(subnode, blob, node) {
156 156 /* Skip disabled ports */
157 157 if (!fdtdec_get_is_enabled(blob, subnode))
158 158 continue;
drivers/pinctrl/meson/pinctrl-meson.c
... ... @@ -154,7 +154,7 @@
154 154 return -EINVAL;
155 155 }
156 156  
157   - fdt_for_each_subnode(gd->fdt_blob, node, dev->of_offset) {
  157 + fdt_for_each_subnode(node, gd->fdt_blob, dev->of_offset) {
158 158 if (fdt_getprop(gd->fdt_blob, node, "gpio-controller", &len)) {
159 159 gpio = node;
160 160 break;
drivers/power/pmic/palmas.c
... ... @@ -52,7 +52,7 @@
52 52 int node = dev->of_offset;
53 53 int subnode, len;
54 54  
55   - fdt_for_each_subnode(blob, subnode, node) {
  55 + fdt_for_each_subnode(subnode, blob, node) {
56 56 const char *name;
57 57 char *temp;
58 58  
drivers/spi/fsl_qspi.c
... ... @@ -1098,7 +1098,7 @@
1098 1098 }
1099 1099  
1100 1100 /* Count flash numbers */
1101   - fdt_for_each_subnode(blob, subnode, node)
  1101 + fdt_for_each_subnode(subnode, blob, node)
1102 1102 ++flash_num;
1103 1103  
1104 1104 if (flash_num == 0) {
... ... @@ -176,24 +176,27 @@
176 176 /**
177 177 * fdt_for_each_subnode - iterate over all subnodes of a parent
178 178 *
  179 + * @node: child node (int, lvalue)
  180 + * @fdt: FDT blob (const void *)
  181 + * @parent: parent node (int)
  182 + *
179 183 * This is actually a wrapper around a for loop and would be used like so:
180 184 *
181   - * fdt_for_each_subnode(fdt, node, parent) {
  185 + * fdt_for_each_subnode(node, fdt, parent) {
  186 + * Use node
182 187 * ...
183   - * use node
184   - * ...
185 188 * }
186 189 *
187   - * Note that this is implemented as a macro and node is used as iterator in
188   - * the loop. It should therefore be a locally allocated variable. The parent
189   - * variable on the other hand is never modified, so it can be constant or
190   - * even a literal.
  190 + * if ((node < 0) && (node != -FDT_ERR_NOT_FOUND)) {
  191 + * Error handling
  192 + * }
191 193 *
192   - * @fdt: FDT blob (const void *)
193   - * @node: child node (int)
194   - * @parent: parent node (int)
  194 + * Note that this is implemented as a macro and @node is used as
  195 + * iterator in the loop. The parent variable be constant or even a
  196 + * literal.
  197 + *
195 198 */
196   -#define fdt_for_each_subnode(fdt, node, parent) \
  199 +#define fdt_for_each_subnode(node, fdt, parent) \
197 200 for (node = fdt_first_subnode(fdt, parent); \
198 201 node >= 0; \
199 202 node = fdt_next_subnode(fdt, node))
... ... @@ -836,7 +836,7 @@
836 836 int subnode;
837 837 int num = 0;
838 838  
839   - fdt_for_each_subnode(blob, subnode, node)
  839 + fdt_for_each_subnode(subnode, blob, node)
840 840 num++;
841 841  
842 842 return num;
lib/libfdt/fdt_overlay.c
... ... @@ -146,7 +146,7 @@
146 146 if (!found && !ret)
147 147 return ret;
148 148  
149   - fdt_for_each_subnode(fdto, child, node)
  149 + fdt_for_each_subnode(child, fdto, node)
150 150 overlay_adjust_node_phandles(fdto, child, delta);
151 151  
152 152 return 0;
... ... @@ -248,7 +248,7 @@
248 248 }
249 249 }
250 250  
251   - fdt_for_each_subnode(fdto, fixup_child, fixup_node) {
  251 + fdt_for_each_subnode(fixup_child, fdto, fixup_node) {
252 252 const char *fixup_child_name = fdt_get_name(fdto, fixup_child,
253 253 NULL);
254 254 int tree_child;
... ... @@ -511,7 +511,7 @@
511 511 return ret;
512 512 }
513 513  
514   - fdt_for_each_subnode(fdto, node, fragment) {
  514 + fdt_for_each_subnode(node, fdto, fragment) {
515 515 const char *name = fdt_get_name(fdto, node, NULL);
516 516 int nnode;
517 517 int ret;
... ... @@ -550,7 +550,7 @@
550 550 {
551 551 int fragment;
552 552  
553   - fdt_for_each_subnode(dto, fragment, 0) {
  553 + fdt_for_each_subnode(fragment, dto, 0) {
554 554 int overlay;
555 555 int target;
556 556 int ret;