[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [ImageBuilder v2 1/2] 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@xxxxxxx> --- To make the interface to phandle_next as simple as possible, we just need a single function that will get us the next phandle and update the global counter. That is why we cannot use the following: - "phandle=$(get_next_phandle)" as a subshell cannot modify the environment of its parent shell, - making use of return statement as it only works with values up to 255 The current solution with passing a variable name to a function that will modify its value using eval is the simplest one and serves our purpose. Changes in v2: - new patch --- scripts/common | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scripts/common b/scripts/common index 68938beb8557..25c041270c29 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" -- 2.25.1
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |