[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH for-8.2 5/7] target/riscv/cpu.c: add a ADD_CPU_PROPERTIES_ARRAY()
From: |
Daniel Henrique Barboza |
Subject: |
[PATCH for-8.2 5/7] target/riscv/cpu.c: add a ADD_CPU_PROPERTIES_ARRAY() macro |
Date: |
Wed, 12 Jul 2023 16:01:47 -0300 |
The code inside riscv_cpu_add_user_properties() became quite repetitive
after recent changes. Add a macro to hide the repetition away.
Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
---
target/riscv/cpu.c | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
index c0826b449d..b61465c8c4 100644
--- a/target/riscv/cpu.c
+++ b/target/riscv/cpu.c
@@ -1881,6 +1881,11 @@ static void cpu_set_cfg_unavailable(Object *obj, Visitor
*v,
}
#endif
+#define ADD_CPU_PROPERTIES_ARRAY(_dev, _array) \
+ for (prop = _array; prop && prop->name; prop++) { \
+ qdev_property_add_static(_dev, prop); \
+ } \
+
/*
* Add CPU properties with user-facing flags.
*
@@ -1924,17 +1929,9 @@ static void riscv_cpu_add_user_properties(Object *obj)
qdev_property_add_static(dev, prop);
}
- for (prop = riscv_cpu_options; prop && prop->name; prop++) {
- qdev_property_add_static(dev, prop);
- }
-
- for (prop = riscv_cpu_vendor_exts; prop && prop->name; prop++) {
- qdev_property_add_static(dev, prop);
- }
-
- for (prop = riscv_cpu_experimental_exts; prop && prop->name; prop++) {
- qdev_property_add_static(dev, prop);
- }
+ ADD_CPU_PROPERTIES_ARRAY(dev, riscv_cpu_options);
+ ADD_CPU_PROPERTIES_ARRAY(dev, riscv_cpu_vendor_exts);
+ ADD_CPU_PROPERTIES_ARRAY(dev, riscv_cpu_experimental_exts);
}
static Property riscv_cpu_properties[] = {
--
2.41.0
- [PATCH for-8.2 0/7] target/riscv: add 'max' CPU type, Daniel Henrique Barboza, 2023/07/12
- [PATCH for-8.2 1/7] target/riscv/cpu.c: split CPU options from riscv_cpu_extensions[], Daniel Henrique Barboza, 2023/07/12
- [PATCH for-8.2 2/7] target/riscv/cpu.c: skip 'bool' check when filtering KVM props, Daniel Henrique Barboza, 2023/07/12
- [PATCH for-8.2 4/7] target/riscv/cpu.c: split non-ratified exts from riscv_cpu_extensions[], Daniel Henrique Barboza, 2023/07/12
- [PATCH for-8.2 5/7] target/riscv/cpu.c: add a ADD_CPU_PROPERTIES_ARRAY() macro,
Daniel Henrique Barboza <=
- [PATCH for-8.2 3/7] target/riscv/cpu.c: split vendor exts from riscv_cpu_extensions[], Daniel Henrique Barboza, 2023/07/12
- [PATCH for-8.2 7/7] avocado, risc-v: add opensbi tests for 'max' CPU, Daniel Henrique Barboza, 2023/07/12
- [PATCH for-8.2 6/7] target/riscv: add 'max' CPU type, Daniel Henrique Barboza, 2023/07/12
- Re: [PATCH for-8.2 6/7] target/riscv: add 'max' CPU type, Conor Dooley, 2023/07/12
- Re: [PATCH for-8.2 6/7] target/riscv: add 'max' CPU type, Daniel Henrique Barboza, 2023/07/12
- Re: [PATCH for-8.2 6/7] target/riscv: add 'max' CPU type, Conor Dooley, 2023/07/12
- Re: [PATCH for-8.2 6/7] target/riscv: add 'max' CPU type, Daniel Henrique Barboza, 2023/07/12
- Re: [PATCH for-8.2 6/7] target/riscv: add 'max' CPU type, Conor Dooley, 2023/07/12
- Re: [PATCH for-8.2 6/7] target/riscv: add 'max' CPU type, Daniel Henrique Barboza, 2023/07/12
- Re: [PATCH for-8.2 6/7] target/riscv: add 'max' CPU type, Conor Dooley, 2023/07/12