diff options
author | Michal Orzel | 2022-09-07 13:08:51 +0200 |
---|---|---|
committer | Stefano Stabellini | 2022-09-07 16:36:33 -0700 |
commit | 22075f787417662d5f5c74af3fb85aea61dbb86a (patch) | |
tree | c79731dbd3d0f25c4467dccc311f39031c82eee6 /scripts/common | |
parent | 648a85038f7673d028cd9d345db9192d1cb62915 (diff) |
scripts/common: Introduce phandle_next and get_next_phandle()
When dealing with device trees, we need to have a solution to add
custom phandles to the nodes we create/modify. Add a global variable
phandle_next to act as a countdown counter starting with the highest
valid phandle value 0xfffffffe. Add a new function get_next_phandle
to get a value of the next available phandle and set it to a variable
whose name is passed as a first argument. The global counter will be
decremented with each call to this function.
Signed-off-by: Michal Orzel <michal.orzel@amd.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Signed-off-by: Stefano Stabellini <stefano.stabellini@amd.com>
Diffstat (limited to 'scripts/common')
-rw-r--r-- | scripts/common | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/scripts/common b/scripts/common index 68938be..25c0412 100644 --- a/scripts/common +++ b/scripts/common @@ -13,6 +13,9 @@ tmp_files=() tmp_dirs=() +# Highest valid phandle. Will be decremented with each call to get_next_phandle +phandle_next="0xfffffffe" + function remove_tmp_files() { for i in "${tmp_files[@]}" @@ -26,6 +29,14 @@ function remove_tmp_files() done } +# Get next phandle and set it as a value (in hex) of a variable whose name is +# passed as a first argument. Decrement global counter phandle_next. +function get_next_phandle() +{ + eval "$1=$(printf "0x%x" $phandle_next)" + phandle_next=$(( $phandle_next - 1 )) +} + function sanity_check_partial_dts() { local domU_passthrough_path="$1" |