aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJohn Tsichritzis <john.tsichritzis@arm.com>2018-10-30 14:49:31 +0000
committerSandrine Bailleux <sandrine.bailleux@arm.com>2018-11-29 11:20:45 +0000
commit941fab43c5147427617ce797b23bb873038f7f9f (patch)
treed4ae5e5e03533e09d5c51db317f83840185c051c /include
parent7d34d304a5115a167102aa165c6a41124b00205d (diff)
downloadtf-a-tests-941fab43c5147427617ce797b23bb873038f7f9f.tar.gz
Make topology.h macros more readable
The three parts of the "for" loops are more readable than before. The way they are written now, it is clear which are the initial and final values of the loop controlling variables. Also, parentheses were added only to those macro parameters that can receive expressions as arguments. E.g. in for_each_cpu(cpu), "cpu" must receive a variable name, it cannot receive an expression. So there was no reason to clutter the macro body with unnecessary parentheses wherever "cpu" parameter appears. Parentheses were added only around those parameters that might receive expressions. The parameters in for_each_cpu_in_power_domain were swapped. This was done for consistency with the other two macros. Thus, the first parameter is always the iterating variable, in all macros. Change-Id: I18831237840e9cfa738a48dbe7f1ec449c89f7af Signed-off-by: John Tsichritzis <john.tsichritzis@arm.com>
Diffstat (limited to 'include')
-rw-r--r--include/plat/common/plat_topology.h34
1 files changed, 17 insertions, 17 deletions
diff --git a/include/plat/common/plat_topology.h b/include/plat/common/plat_topology.h
index 1846b9173..0da0b5ee7 100644
--- a/include/plat/common/plat_topology.h
+++ b/include/plat/common/plat_topology.h
@@ -126,34 +126,34 @@ unsigned int tftf_topology_next_cpu(unsigned int cpu_node);
/*
* Iterate over every CPU. Skip absent CPUs.
* cpu: unsigned integer corresponding to the index of the cpu in
- * the topology array. After the loop, cpu is equal to PWR_DOMAIN_INIT.
+ * the topology array.
*/
-#define for_each_cpu(cpu) \
- for ((cpu) = PWR_DOMAIN_INIT; \
- (cpu) = tftf_topology_next_cpu(cpu), \
- (cpu) != PWR_DOMAIN_INIT;)
+#define for_each_cpu(cpu) \
+ for (cpu = tftf_topology_next_cpu(PWR_DOMAIN_INIT); \
+ cpu != PWR_DOMAIN_INIT; \
+ cpu = tftf_topology_next_cpu(cpu))
/*
* Iterate over every power domain idx for a given level.
- * - idx: unsigned integer corresponding to the power domain index. After the
- * loop, idx is equal to PWR_DOMAIN_INIT.
+ * - idx: unsigned integer corresponding to the power domain index.
* - lvl: level
*/
-#define for_each_power_domain_idx(idx, lvl) \
- for (idx = PWR_DOMAIN_INIT; \
- idx = tftf_get_next_peer_domain(idx, lvl), \
- idx != PWR_DOMAIN_INIT;)
+#define for_each_power_domain_idx(idx, lvl) \
+ for (idx = tftf_get_next_peer_domain(PWR_DOMAIN_INIT, (lvl)); \
+ idx != PWR_DOMAIN_INIT; \
+ idx = tftf_get_next_peer_domain(idx, (lvl)))
/*
* Iterate over every CPU in a power domain idx.
+ * - cpu_idx: CPU index.
* - pwr_domain_idx: unsigned integer corresponding to the power domain index.
- * After the loop, idx is equal to PWR_DOMAIN_INIT.
- * - cpu_idx: CPU index
*/
-#define for_each_cpu_in_power_domain(pwr_domain_idx, cpu_idx) \
- for (cpu_idx = PWR_DOMAIN_INIT; \
- cpu_idx = tftf_get_next_cpu_in_pwr_domain(pwr_domain_idx, cpu_idx),\
- cpu_idx != PWR_DOMAIN_INIT;)
+#define for_each_cpu_in_power_domain(cpu_idx, pwr_domain_idx) \
+ for (cpu_idx = tftf_get_next_cpu_in_pwr_domain( \
+ (pwr_domain_idx), PWR_DOMAIN_INIT); \
+ cpu_idx != PWR_DOMAIN_INIT; \
+ cpu_idx = tftf_get_next_cpu_in_pwr_domain( \
+ (pwr_domain_idx), cpu_idx))
/*
* Returns the MPIDR of the CPU power domain node indexed by `cpu_node`