Skip to content

Commit

Permalink
ppc: spapr: replace ppc_cpu_parse_features() with cpu_parse_cpu_model()
Browse files Browse the repository at this point in the history
ppc_cpu_parse_features() is doing practically the same thing as
generic cpu_parse_cpu_model(). So remove duplicated impl. and
reuse generic one.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
  • Loading branch information
Igor Mammedov authored and dgibson committed Oct 16, 2017
1 parent 23ec69e commit a1063aa
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 32 deletions.
25 changes: 0 additions & 25 deletions hw/ppc/ppc.c
Expand Up @@ -1359,28 +1359,3 @@ void PPC_debug_write (void *opaque, uint32_t addr, uint32_t val)
break;
}
}

void ppc_cpu_parse_features(const char *cpu_model)
{
CPUClass *cc;
ObjectClass *oc;
const char *typename;
gchar **model_pieces;

model_pieces = g_strsplit(cpu_model, ",", 2);
if (!model_pieces[0]) {
error_report("Invalid/empty CPU model name");
exit(1);
}

oc = cpu_class_by_name(TYPE_POWERPC_CPU, model_pieces[0]);
if (oc == NULL) {
error_report("Unable to find CPU definition: %s", model_pieces[0]);
exit(1);
}

typename = object_class_get_name(oc);
cc = CPU_CLASS(oc);
cc->parse_features(typename, model_pieces[1], &error_fatal);
g_strfreev(model_pieces);
}
9 changes: 4 additions & 5 deletions hw/ppc/spapr_cpu_core.c
Expand Up @@ -34,6 +34,7 @@ void spapr_cpu_parse_features(sPAPRMachineState *spapr)
* before passing it on to the cpu level parser.
*/
gchar **inpieces;
gchar *newprops;
int i, j;
gchar *compat_str = NULL;

Expand All @@ -58,17 +59,15 @@ void spapr_cpu_parse_features(sPAPRMachineState *spapr)

if (compat_str) {
char *val = compat_str + strlen("compat=");
gchar *newprops = g_strjoinv(",", inpieces);

object_property_set_str(OBJECT(spapr), val, "max-cpu-compat",
&error_fatal);

ppc_cpu_parse_features(newprops);
g_free(newprops);
} else {
ppc_cpu_parse_features(MACHINE(spapr)->cpu_model);
}

newprops = g_strjoinv(",", inpieces);
cpu_parse_cpu_model(TYPE_POWERPC_CPU, newprops);
g_free(newprops);
g_strfreev(inpieces);
}

Expand Down
2 changes: 0 additions & 2 deletions include/hw/ppc/ppc.h
Expand Up @@ -105,6 +105,4 @@ enum {

/* ppc_booke.c */
void ppc_booke_timers_init(PowerPCCPU *cpu, uint32_t freq, uint32_t flags);

void ppc_cpu_parse_features(const char *cpu_model);
#endif

0 comments on commit a1063aa

Please sign in to comment.