qemu-arm
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 3/5] hw/arm/aspeed: Init CPU defaults in a common helper


From: Richard Henderson
Subject: Re: [PATCH v2 3/5] hw/arm/aspeed: Init CPU defaults in a common helper
Date: Thu, 25 Jan 2024 09:15:28 +1000
User-agent: Mozilla Thunderbird

On 1/24/24 08:48, Philippe Mathieu-Daudé wrote:
Rework aspeed_soc_num_cpus() as a new init_cpus_defaults()
helper to reduce code duplication.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
  hw/arm/aspeed.c | 71 +++++++++++++++++++------------------------------
  1 file changed, 28 insertions(+), 43 deletions(-)

diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
index 5b01a4dd28..636a6269aa 100644
--- a/hw/arm/aspeed.c
+++ b/hw/arm/aspeed.c
@@ -1141,10 +1141,14 @@ static void aspeed_machine_class_props_init(ObjectClass 
*oc)
                                            "Change the SPI Flash model");
  }
-static int aspeed_soc_num_cpus(const char *soc_name)
+static void aspeed_machine_class_init_cpus_defaults(MachineClass *mc)
  {
-   AspeedSoCClass *sc = ASPEED_SOC_CLASS(object_class_by_name(soc_name));
-   return sc->num_cpus;
+    AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(mc);
+    AspeedSoCClass *sc = ASPEED_SOC_CLASS(object_class_by_name(amc->soc_name));
+
+    mc->default_cpus = mc->min_cpus
+                     = mc->max_cpus
+                     = sc->num_cpus;

Not keen on that layout.  If you don't want to repeat sc->num_cpus, maybe just 
pull out

  int n = sc->num_cpus;

at the top.

Otherwise,
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~



reply via email to

[Prev in Thread] Current Thread [Next in Thread]