qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: "Philippe Mathieu-Daudé" <philmd@redhat.com>,
	"QEMU Developers" <qemu-devel@nongnu.org>
Subject: Re: [PATCH 02/15] digic: stash firmware into DigicState
Date: Mon, 26 Oct 2020 14:44:54 +0000	[thread overview]
Message-ID: <CAFEAcA_VYpdo+KBxTkBfDzoOh7eCUrhFTxeh0VXpMB4Yv89NFA@mail.gmail.com> (raw)
In-Reply-To: <20201026143028.3034018-3-pbonzini@redhat.com>

On Mon, 26 Oct 2020 at 14:30, Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> Prepare for removing bios_name.
>
> Cc: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  hw/arm/digic_boards.c  | 5 +++--
>  include/hw/arm/digic.h | 1 +
>  2 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/hw/arm/digic_boards.c b/hw/arm/digic_boards.c
> index d5524d3e72..d320b54c44 100644
> --- a/hw/arm/digic_boards.c
> +++ b/hw/arm/digic_boards.c
> @@ -55,6 +55,7 @@ static void digic4_board_init(MachineState *machine, DigicBoard *board)
>      DigicState *s = DIGIC(object_new(TYPE_DIGIC));
>      MachineClass *mc = MACHINE_GET_CLASS(machine);
>
> +    s->firmware = machine->firmware;
>      if (machine->ram_size != mc->default_ram_size) {
>          char *sz = size_to_str(mc->default_ram_size);
>          error_report("Invalid RAM size, should be %s", sz);
> @@ -91,8 +92,8 @@ static void digic_load_rom(DigicState *s, hwaddr addr,
>          return;
>      }
>
> -    if (bios_name) {
> -        filename = bios_name;
> +    if (s->firmware) {
> +        filename = s->firmware;
>      } else {
>          filename = def_filename;
>      }

The existing code is a little odd, because if the user passes -bios
then we use it in both the add_rom0 and add_rom1 callbacks;
however this ends up not mattering for the moment because the
only supported Digic board has just the rom1 and no rom0.

Anyway, rather than stashing the firmware filename in the
DigicState, you could lift the "decide whether to use
machine->firmware or the def_filename" choice up to
the callsites in digic4_board_init():

    if (board->add_rom0) {
        board->add_rom0(s, DIGIC4_ROM0_BASE,
                        machine->firmware ?: board->rom0_def_filename);
    }
(and similarly for rom1).

Then you can delete the
    if (bios_name) {
        filename = bios_name;
    } else {
        filename = def_filename;
    }
block from digic_load_rom() and rename the arguments of
digic_load_rom() and digic4_add_k8p3215uqb_rom() to just
"filename" rather than "def_filename".

Doing it that way avoids passing things around that we don't
need to, and makes it clear in the digic4_board_init() code
that we're doing something a bit suspect in possibly using
the machine->firmware file twice -- if we ever need to fix
that bug then it'll be a simple change to the logic in that
one function.

thanks
-- PMM


  reply	other threads:[~2020-10-26 14:56 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-26 14:30 [PATCH 00/15] remove bios_name variable Paolo Bonzini
2020-10-26 14:30 ` [PATCH 01/15] alpha: remove bios_name Paolo Bonzini
2020-10-26 17:09   ` Alex Bennée
2020-10-26 18:11   ` Philippe Mathieu-Daudé
2020-10-26 14:30 ` [PATCH 02/15] digic: stash firmware into DigicState Paolo Bonzini
2020-10-26 14:44   ` Peter Maydell [this message]
2020-10-26 15:05     ` Paolo Bonzini
2020-10-26 14:30 ` [PATCH 03/15] arm: remove bios_name Paolo Bonzini
2020-10-26 17:11   ` Alex Bennée
2020-10-26 14:30 ` [PATCH 04/15] hppa: " Paolo Bonzini
2020-10-26 17:12   ` Alex Bennée
2020-10-26 18:11   ` Philippe Mathieu-Daudé
2020-10-26 14:30 ` [PATCH 05/15] i386: " Paolo Bonzini
2020-10-26 17:15   ` Alex Bennée
2020-10-26 14:30 ` [PATCH 06/15] lm32: " Paolo Bonzini
2020-10-26 17:15   ` Alex Bennée
2020-10-26 18:12   ` Philippe Mathieu-Daudé
2020-10-26 14:30 ` [PATCH 07/15] m68k: " Paolo Bonzini
2020-10-26 17:17   ` Alex Bennée
2020-10-26 18:13   ` Philippe Mathieu-Daudé
2020-10-26 18:54   ` Thomas Huth
2020-10-26 19:11   ` Laurent Vivier
2020-10-27 13:26     ` Paolo Bonzini
2020-10-26 14:30 ` [PATCH 08/15] mips: " Paolo Bonzini
2020-10-26 17:20   ` Alex Bennée
2020-10-27 14:40   ` Philippe Mathieu-Daudé
2020-10-26 14:30 ` [PATCH 09/15] moxie: " Paolo Bonzini
2020-10-26 17:20   ` Alex Bennée
2020-10-26 14:30 ` [PATCH 10/15] ppc: " Paolo Bonzini
2020-10-26 17:21   ` Alex Bennée
2020-10-27  2:04   ` David Gibson
2020-10-26 14:30 ` [PATCH 11/15] rx: move BIOS load from MCU to board Paolo Bonzini
2020-10-26 17:24   ` Alex Bennée
2020-10-26 17:34     ` Paolo Bonzini
2020-10-26 19:00       ` Philippe Mathieu-Daudé
2020-10-26 14:30 ` [PATCH 12/15] s390: remove bios_name Paolo Bonzini
2020-10-26 17:29   ` Alex Bennée
2020-10-26 18:58   ` Thomas Huth
2020-10-27  8:37   ` Cornelia Huck
2020-10-27  8:38   ` Christian Borntraeger
2020-10-27 13:26     ` Paolo Bonzini
2020-10-26 14:30 ` [PATCH 13/15] sh4: " Paolo Bonzini
2020-10-26 17:29   ` Alex Bennée
2020-10-26 18:56   ` Philippe Mathieu-Daudé
2020-10-26 14:30 ` [PATCH 14/15] sparc: " Paolo Bonzini
2020-10-26 17:30   ` Alex Bennée
2020-10-26 18:57   ` Philippe Mathieu-Daudé
2020-10-27 16:21   ` Mark Cave-Ayland
2020-10-26 14:30 ` [PATCH 15/15] vl: " Paolo Bonzini
2020-10-26 17:30   ` Alex Bennée
2020-10-27 14:22   ` Thomas Huth
2020-10-26 14:51 ` [PATCH 00/15] remove bios_name variable no-reply

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=CAFEAcA_VYpdo+KBxTkBfDzoOh7eCUrhFTxeh0VXpMB4Yv89NFA@mail.gmail.com \
    --to=peter.maydell@linaro.org \
    --cc=pbonzini@redhat.com \
    --cc=philmd@redhat.com \
    --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).