overlay.c (b46c78661c42cb8b07eb213104c79cbab8ea7e0d) overlay.c (b89dae1852869d6bb3e4a8e3c6bdaf86dc2ef9da)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Functions for working with device tree overlays
4 *
5 * Copyright (C) 2012 Pantelis Antoniou <panto@antoniou-consulting.com>
6 * Copyright (C) 2012 Texas Instruments Inc.
7 */
8

--- 298 unchanged lines hidden (view full) ---

307 * to add @node in @target_node.
308 *
309 * If @node already exists in @target_node, and the existing node has
310 * a phandle, the overlay node is not allowed to have a phandle.
311 *
312 * If @node has child nodes, add the children recursively via
313 * build_changeset_next_level().
314 *
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Functions for working with device tree overlays
4 *
5 * Copyright (C) 2012 Pantelis Antoniou <panto@antoniou-consulting.com>
6 * Copyright (C) 2012 Texas Instruments Inc.
7 */
8

--- 298 unchanged lines hidden (view full) ---

307 * to add @node in @target_node.
308 *
309 * If @node already exists in @target_node, and the existing node has
310 * a phandle, the overlay node is not allowed to have a phandle.
311 *
312 * If @node has child nodes, add the children recursively via
313 * build_changeset_next_level().
314 *
315 * NOTE: Multiple mods of created nodes not supported.
315 * NOTE_1: A live devicetree created from a flattened device tree (FDT) will
316 * not contain the full path in node->full_name. Thus an overlay
317 * created from an FDT also will not contain the full path in
318 * node->full_name. However, a live devicetree created from Open
319 * Firmware may have the full path in node->full_name.
320 *
321 * add_changeset_node() follows the FDT convention and does not include
322 * the full path in node->full_name. Even though it expects the overlay
323 * to not contain the full path, it uses kbasename() to remove the
324 * full path should it exist. It also uses kbasename() in comparisons
325 * to nodes in the live devicetree so that it can apply an overlay to
326 * a live devicetree created from Open Firmware.
327 *
328 * NOTE_2: Multiple mods of created nodes not supported.
316 * If more than one fragment contains a node that does not already exist
317 * in the live tree, then for each fragment of_changeset_attach_node()
318 * will add a changeset entry to add the node. When the changeset is
319 * applied, __of_attach_node() will attach the node twice (once for
320 * each fragment). At this point the device tree will be corrupted.
321 *
322 * TODO: add integrity check to ensure that multiple fragments do not
323 * create the same node.

--- 10 unchanged lines hidden (view full) ---

334
335 node_kbasename = kbasename(node->full_name);
336
337 for_each_child_of_node(target_node, tchild)
338 if (!of_node_cmp(node_kbasename, kbasename(tchild->full_name)))
339 break;
340
341 if (!tchild) {
329 * If more than one fragment contains a node that does not already exist
330 * in the live tree, then for each fragment of_changeset_attach_node()
331 * will add a changeset entry to add the node. When the changeset is
332 * applied, __of_attach_node() will attach the node twice (once for
333 * each fragment). At this point the device tree will be corrupted.
334 *
335 * TODO: add integrity check to ensure that multiple fragments do not
336 * create the same node.

--- 10 unchanged lines hidden (view full) ---

347
348 node_kbasename = kbasename(node->full_name);
349
350 for_each_child_of_node(target_node, tchild)
351 if (!of_node_cmp(node_kbasename, kbasename(tchild->full_name)))
352 break;
353
354 if (!tchild) {
342 tchild = __of_node_dup(node, "%pOF/%s",
343 target_node, node_kbasename);
355 tchild = __of_node_dup(node, node_kbasename);
344 if (!tchild)
345 return -ENOMEM;
346
347 tchild->parent = target_node;
348
349 ret = of_changeset_attach_node(&ovcs->cset, tchild);
350 if (ret)
351 return ret;

--- 730 unchanged lines hidden ---
356 if (!tchild)
357 return -ENOMEM;
358
359 tchild->parent = target_node;
360
361 ret = of_changeset_attach_node(&ovcs->cset, tchild);
362 if (ret)
363 return ret;

--- 730 unchanged lines hidden ---