Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

of: overlay: rename variables to be consistent

Variables change name across function calls when there is not a good
reason to do so. Fix by changing "fdt" to "new_fdt" and "tree" to
"overlay_root".

The name disparity was confusing when creating the following commit.
The name changes are in this separate commit to make review of the
following commmit less complex.

Signed-off-by: Frank Rowand <frank.rowand@sony.com>
Signed-off-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20220420222505.928492-2-frowand.list@gmail.com

authored by

Frank Rowand and committed by
Rob Herring
1e408966 5f756a2e

+47 -47
+47 -47
drivers/of/overlay.c
··· 57 57 * struct overlay_changeset 58 58 * @id: changeset identifier 59 59 * @ovcs_list: list on which we are located 60 - * @fdt: base of memory allocated to hold aligned FDT that was unflattened to create @overlay_tree 61 - * @overlay_tree: expanded device tree that contains the fragment nodes 60 + * @new_fdt: Memory allocated to hold unflattened aligned FDT 61 + * @overlay_root: expanded device tree that contains the fragment nodes 62 62 * @count: count of fragment structures 63 63 * @fragments: fragment nodes in the overlay expanded device tree 64 64 * @symbols_fragment: last element of @fragments[] is the __symbols__ node ··· 67 67 struct overlay_changeset { 68 68 int id; 69 69 struct list_head ovcs_list; 70 - const void *fdt; 71 - struct device_node *overlay_tree; 70 + const void *new_fdt; 71 + struct device_node *overlay_root; 72 72 int count; 73 73 struct fragment *fragments; 74 74 bool symbols_fragment; ··· 183 183 184 184 /* 185 185 * The values of properties in the "/__symbols__" node are paths in 186 - * the ovcs->overlay_tree. When duplicating the properties, the paths 186 + * the ovcs->overlay_root. When duplicating the properties, the paths 187 187 * need to be adjusted to be the correct path for the live device tree. 188 188 * 189 189 * The paths refer to a node in the subtree of a fragment node's "__overlay__" ··· 219 219 220 220 if (path_len < 1) 221 221 return NULL; 222 - fragment_node = __of_find_node_by_path(ovcs->overlay_tree, path + 1); 222 + fragment_node = __of_find_node_by_path(ovcs->overlay_root, path + 1); 223 223 overlay_node = __of_find_node_by_path(fragment_node, "__overlay__/"); 224 224 of_node_put(fragment_node); 225 225 of_node_put(overlay_node); ··· 716 716 717 717 /** 718 718 * init_overlay_changeset() - initialize overlay changeset from overlay tree 719 - * @ovcs: Overlay changeset to build 720 - * @fdt: base of memory allocated to hold aligned FDT that was unflattened to create @tree 721 - * @tree: Contains the overlay fragments and overlay fixup nodes 719 + * @ovcs: Overlay changeset to build 720 + * @new_fdt: Memory allocated to hold unflattened aligned FDT 721 + * @overlay_root: Contains the overlay fragments and overlay fixup nodes 722 722 * 723 723 * Initialize @ovcs. Populate @ovcs->fragments with node information from 724 - * the top level of @tree. The relevant top level nodes are the fragment 725 - * nodes and the __symbols__ node. Any other top level node will be ignored. 724 + * the top level of @overlay_root. The relevant top level nodes are the 725 + * fragment nodes and the __symbols__ node. Any other top level node will 726 + * be ignored. 726 727 * 727 728 * Return: 0 on success, -ENOMEM if memory allocation failure, -EINVAL if error 728 - * detected in @tree, or -ENOSPC if idr_alloc() error. 729 + * detected in @overlay_root, or -ENOSPC if idr_alloc() error. 729 730 */ 730 731 static int init_overlay_changeset(struct overlay_changeset *ovcs, 731 - const void *fdt, struct device_node *tree) 732 + const void *new_fdt, struct device_node *overlay_root) 732 733 { 733 734 struct device_node *node, *overlay_node; 734 735 struct fragment *fragment; ··· 740 739 * Warn for some issues. Can not return -EINVAL for these until 741 740 * of_unittest_apply_overlay() is fixed to pass these checks. 742 741 */ 743 - if (!of_node_check_flag(tree, OF_DYNAMIC)) 744 - pr_debug("%s() tree is not dynamic\n", __func__); 742 + if (!of_node_check_flag(overlay_root, OF_DYNAMIC)) 743 + pr_debug("%s() overlay_root is not dynamic\n", __func__); 745 744 746 - if (!of_node_check_flag(tree, OF_DETACHED)) 747 - pr_debug("%s() tree is not detached\n", __func__); 745 + if (!of_node_check_flag(overlay_root, OF_DETACHED)) 746 + pr_debug("%s() overlay_root is not detached\n", __func__); 748 747 749 - if (!of_node_is_root(tree)) 750 - pr_debug("%s() tree is not root\n", __func__); 748 + if (!of_node_is_root(overlay_root)) 749 + pr_debug("%s() overlay_root is not root\n", __func__); 751 750 752 - ovcs->overlay_tree = tree; 753 - ovcs->fdt = fdt; 751 + ovcs->overlay_root = overlay_root; 752 + ovcs->new_fdt = new_fdt; 754 753 755 754 INIT_LIST_HEAD(&ovcs->ovcs_list); 756 755 ··· 763 762 cnt = 0; 764 763 765 764 /* fragment nodes */ 766 - for_each_child_of_node(tree, node) { 765 + for_each_child_of_node(overlay_root, node) { 767 766 overlay_node = of_get_child_by_name(node, "__overlay__"); 768 767 if (overlay_node) { 769 768 cnt++; ··· 771 770 } 772 771 } 773 772 774 - node = of_get_child_by_name(tree, "__symbols__"); 773 + node = of_get_child_by_name(overlay_root, "__symbols__"); 775 774 if (node) { 776 775 cnt++; 777 776 of_node_put(node); ··· 784 783 } 785 784 786 785 cnt = 0; 787 - for_each_child_of_node(tree, node) { 786 + for_each_child_of_node(overlay_root, node) { 788 787 overlay_node = of_get_child_by_name(node, "__overlay__"); 789 788 if (!overlay_node) 790 789 continue; ··· 806 805 * if there is a symbols fragment in ovcs->fragments[i] it is 807 806 * the final element in the array 808 807 */ 809 - node = of_get_child_by_name(tree, "__symbols__"); 808 + node = of_get_child_by_name(overlay_root, "__symbols__"); 810 809 if (node) { 811 810 ovcs->symbols_fragment = 1; 812 811 fragment = &fragments[cnt]; ··· 860 859 } 861 860 kfree(ovcs->fragments); 862 861 /* 863 - * There should be no live pointers into ovcs->overlay_tree and 864 - * ovcs->fdt due to the policy that overlay notifiers are not allowed 865 - * to retain pointers into the overlay devicetree. 862 + * There should be no live pointers into ovcs->overlay_root and 863 + * ovcs->new_fdt due to the policy that overlay notifiers are not 864 + * allowed to retain pointers into the overlay devicetree. 866 865 */ 867 - kfree(ovcs->overlay_tree); 868 - kfree(ovcs->fdt); 866 + kfree(ovcs->overlay_root); 867 + kfree(ovcs->new_fdt); 869 868 kfree(ovcs); 870 869 } 871 870 ··· 873 872 * internal documentation 874 873 * 875 874 * of_overlay_apply() - Create and apply an overlay changeset 876 - * @fdt: base of memory allocated to hold the aligned FDT 877 - * @tree: Expanded overlay device tree 878 - * @ovcs_id: Pointer to overlay changeset id 875 + * @new_fdt: Memory allocated to hold the aligned FDT 876 + * @overlay_root: Expanded overlay device tree 877 + * @ovcs_id: Pointer to overlay changeset id 879 878 * 880 879 * Creates and applies an overlay changeset. 881 880 * 882 881 * If an error occurs in a pre-apply notifier, then no changes are made 883 882 * to the device tree. 884 883 * 885 - 886 884 * A non-zero return value will not have created the changeset if error is from: 887 885 * - parameter checks 888 886 * - building the changeset ··· 911 911 * id is returned to *ovcs_id. 912 912 */ 913 913 914 - static int of_overlay_apply(const void *fdt, struct device_node *tree, 915 - int *ovcs_id) 914 + static int of_overlay_apply(const void *new_fdt, 915 + struct device_node *overlay_root, int *ovcs_id) 916 916 { 917 917 struct overlay_changeset *ovcs; 918 918 int ret = 0, ret_revert, ret_tmp; ··· 924 924 925 925 if (devicetree_corrupt()) { 926 926 pr_err("devicetree state suspect, refuse to apply overlay\n"); 927 - kfree(fdt); 928 - kfree(tree); 927 + kfree(new_fdt); 928 + kfree(overlay_root); 929 929 ret = -EBUSY; 930 930 goto out; 931 931 } 932 932 933 933 ovcs = kzalloc(sizeof(*ovcs), GFP_KERNEL); 934 934 if (!ovcs) { 935 - kfree(fdt); 936 - kfree(tree); 935 + kfree(new_fdt); 936 + kfree(overlay_root); 937 937 ret = -ENOMEM; 938 938 goto out; 939 939 } ··· 941 941 of_overlay_mutex_lock(); 942 942 mutex_lock(&of_mutex); 943 943 944 - ret = of_resolve_phandles(tree); 944 + ret = of_resolve_phandles(overlay_root); 945 945 if (ret) 946 946 goto err_free_tree; 947 947 948 - ret = init_overlay_changeset(ovcs, fdt, tree); 948 + ret = init_overlay_changeset(ovcs, new_fdt, overlay_root); 949 949 if (ret) 950 950 goto err_free_tree; 951 951 952 952 /* 953 - * after overlay_notify(), ovcs->overlay_tree related pointers may have 953 + * After overlay_notify(), ovcs->overlay_root related pointers may have 954 954 * leaked to drivers, so can not kfree() tree, aka ovcs->overlay_tree; 955 955 * and can not free memory containing aligned fdt. The aligned fdt 956 - * is contained within the memory at ovcs->fdt, possibly at an offset 957 - * from ovcs->fdt. 956 + * is contained within the memory at ovcs->new_fdt, possibly at an 957 + * offset from ovcs->new_fdt. 958 958 */ 959 959 ret = overlay_notify(ovcs, OF_OVERLAY_PRE_APPLY); 960 960 if (ret) { ··· 996 996 goto out_unlock; 997 997 998 998 err_free_tree: 999 - kfree(fdt); 1000 - kfree(tree); 999 + kfree(new_fdt); 1000 + kfree(overlay_root); 1001 1001 1002 1002 err_free_overlay_changeset: 1003 1003 free_overlay_changeset(ovcs);