[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v6 05/40] hw/core: Move cpu_common_has_work() to cpu_has_work()
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH v6 05/40] hw/core: Move cpu_common_has_work() to cpu_has_work() |
Date: |
Fri, 24 Sep 2021 11:38:12 +0200 |
cpu_class_init() always register cpu_common_has_work() as
CPUClass::has_work() handler, so the assertion check in
cpu_has_work() is pointless.
Since cpu_common_has_work() simply returns 'false', we can
inline it in cpu_has_work(), improving the function readability.
Suggested-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/core/cpu-common.c | 6 ------
softmmu/cpus.c | 6 ++++--
2 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c
index e2f5a646046..5ed1ccdfdd5 100644
--- a/hw/core/cpu-common.c
+++ b/hw/core/cpu-common.c
@@ -143,11 +143,6 @@ static void cpu_common_reset(DeviceState *dev)
}
}
-static bool cpu_common_has_work(CPUState *cs)
-{
- return false;
-}
-
ObjectClass *cpu_class_by_name(const char *typename, const char *cpu_model)
{
CPUClass *cc = CPU_CLASS(object_class_by_name(typename));
@@ -279,7 +274,6 @@ static void cpu_class_init(ObjectClass *klass, void *data)
k->parse_features = cpu_common_parse_features;
k->get_arch_id = cpu_common_get_arch_id;
- k->has_work = cpu_common_has_work;
k->gdb_read_register = cpu_common_gdb_read_register;
k->gdb_write_register = cpu_common_gdb_write_register;
set_bit(DEVICE_CATEGORY_CPU, dc->categories);
diff --git a/softmmu/cpus.c b/softmmu/cpus.c
index 6a05860f7fe..accb20f0589 100644
--- a/softmmu/cpus.c
+++ b/softmmu/cpus.c
@@ -255,8 +255,10 @@ bool cpu_has_work(CPUState *cpu)
{
CPUClass *cc = CPU_GET_CLASS(cpu);
- g_assert(cc->has_work);
- return cc->has_work(cpu);
+ if (cc->has_work && cc->has_work(cpu)) {
+ return true;
+ }
+ return false;
}
static int do_vm_stop(RunState state, bool send_stop)
--
2.31.1
- [PATCH v6 00/40] accel: Move has_work() from CPUClass to AccelOpsClass, Philippe Mathieu-Daudé, 2021/09/24
- [PATCH v6 01/40] accel: Simplify qemu_init_vcpu(), Philippe Mathieu-Daudé, 2021/09/24
- [PATCH v6 02/40] accel/tcg: Restrict cpu_handle_halt() to sysemu, Philippe Mathieu-Daudé, 2021/09/24
- [PATCH v6 03/40] hw/core: Restrict cpu_has_work() to sysemu, Philippe Mathieu-Daudé, 2021/09/24
- [PATCH v6 04/40] hw/core: Un-inline cpu_has_work(), Philippe Mathieu-Daudé, 2021/09/24
- [PATCH v6 05/40] hw/core: Move cpu_common_has_work() to cpu_has_work(),
Philippe Mathieu-Daudé <=
- [PATCH v6 06/40] accel: Introduce AccelOpsClass::has_work(), Philippe Mathieu-Daudé, 2021/09/24
- [PATCH v6 07/40] accel/kvm: Implement AccelOpsClass::has_work(), Philippe Mathieu-Daudé, 2021/09/24
- [PATCH v6 08/40] accel/whpx: Implement AccelOpsClass::has_work(), Philippe Mathieu-Daudé, 2021/09/24
- [PATCH v6 09/40] accel/hvf: Implement AccelOpsClass::has_work(), Philippe Mathieu-Daudé, 2021/09/24
- [PATCH v6 10/40] accel/xen: Implement AccelOpsClass::has_work(), Philippe Mathieu-Daudé, 2021/09/24
- [PATCH v6 11/40] accel/hax: Implement AccelOpsClass::has_work(), Philippe Mathieu-Daudé, 2021/09/24
- [PATCH v6 12/40] accel/nvmm: Implement AccelOpsClass::has_work(), Philippe Mathieu-Daudé, 2021/09/24
- [PATCH v6 13/40] accel/qtest: Implement AccelOpsClass::has_work(), Philippe Mathieu-Daudé, 2021/09/24
- [PATCH v6 14/40] accel/tcg: Implement AccelOpsClass::has_work(), Philippe Mathieu-Daudé, 2021/09/24