[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 17/32] target/tricore: Use generic helper to show CPU model na
From: |
Gavin Shan |
Subject: |
[PATCH v3 17/32] target/tricore: Use generic helper to show CPU model names |
Date: |
Thu, 7 Sep 2023 10:35:38 +1000 |
For target/tricore, the CPU type name is always the combination of the
CPU model name and suffix. The CPU model names have been correctly
shown in tricore_cpu_list_entry().
Use generic helper cpu_model_from_type() to show the CPU model names
in the above function. tricore_cpu_class_by_name() is also improved
by merging the condition of '@oc == NULL' to object_class_dynamic_cast().
Signed-off-by: Gavin Shan <gshan@redhat.com>
---
target/tricore/cpu.c | 9 +++++----
target/tricore/helper.c | 13 +++++--------
2 files changed, 10 insertions(+), 12 deletions(-)
diff --git a/target/tricore/cpu.c b/target/tricore/cpu.c
index 133a9ac70e..066249e50d 100644
--- a/target/tricore/cpu.c
+++ b/target/tricore/cpu.c
@@ -140,11 +140,12 @@ static ObjectClass *tricore_cpu_class_by_name(const char
*cpu_model)
typename = g_strdup_printf(TRICORE_CPU_TYPE_NAME("%s"), cpu_model);
oc = object_class_by_name(typename);
g_free(typename);
- if (!oc || !object_class_dynamic_cast(oc, TYPE_TRICORE_CPU) ||
- object_class_is_abstract(oc)) {
- return NULL;
+ if (object_class_dynamic_cast(oc, TYPE_TRICORE_CPU) &&
+ !object_class_is_abstract(oc)) {
+ return oc;
}
- return oc;
+
+ return NULL;
}
static void tc1796_initfn(Object *obj)
diff --git a/target/tricore/helper.c b/target/tricore/helper.c
index 6d076ac36f..21f4e1f1a3 100644
--- a/target/tricore/helper.c
+++ b/target/tricore/helper.c
@@ -98,14 +98,11 @@ bool tricore_cpu_tlb_fill(CPUState *cs, vaddr address, int
size,
static void tricore_cpu_list_entry(gpointer data, gpointer user_data)
{
- ObjectClass *oc = data;
- const char *typename;
- char *name;
-
- typename = object_class_get_name(oc);
- name = g_strndup(typename, strlen(typename) - strlen("-"
TYPE_TRICORE_CPU));
- qemu_printf(" %s\n", name);
- g_free(name);
+ const char *typename = object_class_get_name(OBJECT_CLASS(data));
+ char *model = cpu_model_from_type(typename);
+
+ qemu_printf(" %s\n", model);
+ g_free(model);
}
void tricore_cpu_list(void)
--
2.41.0
- [PATCH v3 13/32] target/riscv: Use generic helper to show CPU model names, (continued)
[PATCH v3 16/32] target/sh4: Use generic helper to show CPU model names, Gavin Shan, 2023/09/06
[PATCH v3 17/32] target/tricore: Use generic helper to show CPU model names,
Gavin Shan <=
[PATCH v3 18/32] target/sparc: Improve sparc_cpu_class_by_name(), Gavin Shan, 2023/09/06
[PATCH v3 19/32] target/xtensa: Improve xtensa_cpu_class_by_name(), Gavin Shan, 2023/09/06
[PATCH v3 20/32] target/hppa: Implement hppa_cpu_list(), Gavin Shan, 2023/09/06
[PATCH v3 21/32] target/microblaze: Implement microblaze_cpu_list(), Gavin Shan, 2023/09/06
[PATCH v3 22/32] target/nios2: Implement nios2_cpu_list(), Gavin Shan, 2023/09/06
[PATCH v3 23/32] Mark cpu_list() supported on all targets, Gavin Shan, 2023/09/06
[PATCH v3 24/32] machine: Constify MachineClass::valid_cpu_types[i], Gavin Shan, 2023/09/06
[PATCH v3 25/32] machine: Use error handling when CPU type is checked, Gavin Shan, 2023/09/06