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
Subject: Re: [PATCH] hw/misc/mips_itu: Make MIPSITUState target agnostic
Date: Tue, 19 Sep 2023 08:41:54 +0200	[thread overview]
Message-ID: <6f97e558-f070-2d9e-74db-e3d612b10065@linaro.org> (raw)
In-Reply-To: <20230918073023.3846-1-philmd@linaro.org>

On 9/18/23 09:30, Philippe Mathieu-Daudé wrote:
> @@ -530,9 +530,12 @@ static void mips_itu_realize(DeviceState *dev, Error **errp)
>       if (!s->cpu0) {
>           error_setg(errp, "Missing 'cpu[0]' property");
>           return;
> +    } else if (!object_dynamic_cast(OBJECT(s->cpu0), TYPE_MIPS_CPU)) {
> +        error_setg(errp, "MIPS ITU expects a MIPS CPU");
> +        return;
>       }
>   
> -    env = &s->cpu0->env;
> +    env = &MIPS_CPU(s->cpu0)->env;
>       if (env->saarp) {
>           s->saar = env->CP0_SAAR;
>       }...
> @@ -563,7 +566,7 @@ static Property mips_itu_properties[] = {
>                        ITC_FIFO_NUM_MAX),
>      DEFINE_PROP_UINT32("num-semaphores", MIPSITUState, num_semaphores,
>                        ITC_SEMAPH_NUM_MAX),
> -    DEFINE_PROP_LINK("cpu[0]", MIPSITUState, cpu0, TYPE_MIPS_CPU, MIPSCPU *),
> +    DEFINE_PROP_LINK("cpu[0]", MIPSITUState, cpu0, TYPE_CPU, CPUState *),
>      DEFINE_PROP_END_OF_LIST(),

I think you want to keep TYPE_MIPS_CPU here.  If you do that, I believe you could remove 
the dynamic_cast check above and let the MIPS_CPU macro assert, because the link cannot be 
set with an incorrect type.


r~


      reply	other threads:[~2023-09-19  6:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-18  7:30 [PATCH] hw/misc/mips_itu: Make MIPSITUState target agnostic Philippe Mathieu-Daudé
2023-09-19  6:41 ` Richard Henderson [this message]

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=6f97e558-f070-2d9e-74db-e3d612b10065@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=philmd@linaro.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).