diff options
author | Daniel Henrique Barboza <dbarboza@ventanamicro.com> | 2023-09-12 10:24:10 -0300 |
---|---|---|
committer | Alistair Francis <alistair.francis@wdc.com> | 2023-10-12 11:35:56 +1000 |
commit | 370d7c8ef8fb4630fb422c4176477d134ac8793d (patch) | |
tree | 2aeab8aa107392f72372f419340b86ba25bc1170 /target/riscv | |
parent | 82822b5d5a5fe2a7f780c9d27534ecaa42cacdec (diff) | |
download | qemu-370d7c8ef8fb4630fb422c4176477d134ac8793d.zip qemu-370d7c8ef8fb4630fb422c4176477d134ac8793d.tar.gz qemu-370d7c8ef8fb4630fb422c4176477d134ac8793d.tar.bz2 |
target/riscv/cpu.c: add riscv_cpu_add_qdev_prop_array()
The code inside riscv_cpu_add_user_properties() became quite repetitive
after recent changes. Add a helper to hide the repetition away.
Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20230912132423.268494-8-dbarboza@ventanamicro.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Diffstat (limited to 'target/riscv')
-rw-r--r-- | target/riscv/cpu.c | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 6289457..848b0d1 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1928,6 +1928,15 @@ static Property riscv_cpu_options[] = { DEFINE_PROP_END_OF_LIST(), }; +static void riscv_cpu_add_qdev_prop_array(DeviceState *dev, Property *array) +{ + g_assert(array); + + for (Property *prop = array; prop && prop->name; prop++) { + qdev_property_add_static(dev, prop); + } +} + #ifdef CONFIG_KVM static void cpu_set_cfg_unavailable(Object *obj, Visitor *v, const char *name, @@ -2001,7 +2010,6 @@ void kvm_riscv_cpu_add_kvm_properties(Object *obj) */ static void riscv_cpu_add_user_properties(Object *obj) { - Property *prop; DeviceState *dev = DEVICE(obj); #ifndef CONFIG_USER_ONLY @@ -2015,21 +2023,10 @@ static void riscv_cpu_add_user_properties(Object *obj) riscv_cpu_add_misa_properties(obj); - for (prop = riscv_cpu_extensions; prop && prop->name; prop++) { - 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); - } + riscv_cpu_add_qdev_prop_array(dev, riscv_cpu_extensions); + riscv_cpu_add_qdev_prop_array(dev, riscv_cpu_options); + riscv_cpu_add_qdev_prop_array(dev, riscv_cpu_vendor_exts); + riscv_cpu_add_qdev_prop_array(dev, riscv_cpu_experimental_exts); } static Property riscv_cpu_properties[] = { |