qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>, qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	qemu-arm@nongnu.org, "Joel Stanley" <joel@jms.id.au>,
	"Andrew Jeffery" <andrew@codeconstruct.com.au>,
	"Cédric Le Goater" <clg@kaod.org>
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	[thread overview]
Message-ID: <dd1b61d7-267f-4f78-90cf-e25468747b08@linaro.org> (raw)
In-Reply-To: <20240123224842.18485-4-philmd@linaro.org>

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~


  parent reply	other threads:[~2024-01-24 23:16 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-23 22:48 [PATCH v2 0/5] hw/arm/aspeed: Check for CPU types in machine_run_board_init() Philippe Mathieu-Daudé
2024-01-23 22:48 ` [PATCH v2 1/5] hw/arm/aspeed: Remove dead code Philippe Mathieu-Daudé
2024-01-24  6:50   ` Cédric Le Goater
2024-01-24 23:12   ` Richard Henderson
2024-01-25  2:21   ` Gavin Shan
2024-01-23 22:48 ` [PATCH v2 2/5] hw/arm/aspeed: Set default CPU count using aspeed_soc_num_cpus() Philippe Mathieu-Daudé
2024-01-24  6:52   ` Cédric Le Goater
2024-01-25  2:23   ` Gavin Shan
2024-01-23 22:48 ` [PATCH v2 3/5] hw/arm/aspeed: Init CPU defaults in a common helper Philippe Mathieu-Daudé
2024-01-24  6:58   ` Cédric Le Goater
2024-01-24 23:15   ` Richard Henderson [this message]
2024-01-25  2:26   ` Gavin Shan
2024-01-25  4:50     ` Philippe Mathieu-Daudé
2024-01-23 22:48 ` [PATCH v2 4/5] hw/arm/aspeed: Introduce aspeed_soc_cpu_type() helper Philippe Mathieu-Daudé
2024-01-24  6:58   ` Cédric Le Goater
2024-01-24 23:17   ` Richard Henderson
2024-01-25  2:27   ` Gavin Shan
2024-01-23 22:48 ` [PATCH v2 5/5] hw/arm/aspeed: Check for CPU types in machine_run_board_init() Philippe Mathieu-Daudé
2024-01-24  6:59   ` Cédric Le Goater
2024-01-24 23:18   ` Richard Henderson
2024-01-25  2:28   ` Gavin Shan
2024-01-23 22:50 ` [PATCH v2 0/5] " Philippe Mathieu-Daudé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=dd1b61d7-267f-4f78-90cf-e25468747b08@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=andrew@codeconstruct.com.au \
    --cc=clg@kaod.org \
    --cc=joel@jms.id.au \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).