From patchwork Wed Jan 4 22:04:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 13089119 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DF7FFC46467 for ; Wed, 4 Jan 2023 22:12:57 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pDBt9-00005z-7j; Wed, 04 Jan 2023 17:05:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pDBsr-0008Jr-1X for qemu-devel@nongnu.org; Wed, 04 Jan 2023 17:05:17 -0500 Received: from mail-ej1-x630.google.com ([2a00:1450:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pDBsm-0004zY-Go for qemu-devel@nongnu.org; Wed, 04 Jan 2023 17:05:15 -0500 Received: by mail-ej1-x630.google.com with SMTP id t17so85833085eju.1 for ; Wed, 04 Jan 2023 14:05:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rkKzY1HM1SiWRLbXS14jWSBKvZcyQVWsRHeTd+kMCAQ=; b=DarwSARFklHss2v0qIjFWeNAW6nNn1DVlR4Qz3fDpCU58Ljx5QTBo4LNk1mWeDze+T K0vUYHIWkRgv17TbkDomH+4N2YNXpQLmMgd4XIN8JDzrxA2/XHu7Y3rj896fTmtoN1+P RTATh9GVG/Np05/A9Mu1Vfcg0xeWjYaYeD5F+Io6x7aXBAfKWqOBKrIdk3JWMjNCp3ir vDdTOWyLwZaZQGL5WSSIhlA4YgodVPctNzGrr1UPvbI2A7Kf7oo4PNHXZpq4ATHkM7XO Uya4xYs9J31bxpmsfGf2AeBPNb4JGPhK4jar+Nww68/TEg995FEfqKtwttI/i28DM39M cfDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rkKzY1HM1SiWRLbXS14jWSBKvZcyQVWsRHeTd+kMCAQ=; b=iB7yTrnDcJVr5dYY6J3OpTC4Pb9bZeDOArKvX42Q02jXAbcaC7mB0Ts1hPbmir7/PU rGktk+B5JxEBNTs5L098C9NOJuQ5O1Kdp2pO4HYXdGeFTR9h0BKpsjgty3cHKt5vnNiF YR0XXVYEKLJM6DsR8PsVG1JFEFHjWJ1WN7+PLEYAfZ0eEYnUjo9HGe9cefl88ciPqo7B POFTDWZe/W2FzEajI1BNSZKQVp1+Ab7BZXQ7jvqGBPdVnjwRym0uTu3YqHhpx6AthWUY b+IVsvA/lfuFjQ3NHa3SbYpTFAO2DuAU2d+koxnJaOWZUNVJ6Dkb+oukPotxHe6GAQGU o5AA== X-Gm-Message-State: AFqh2kp9WvqlVj7t6rJMnYFwxvhuZ1g4zzBb9o2lUNdoLqT+mM9Y8pD3 VniX5OFepCUGVJjUf/AipW97N50Jb/XsnXxm X-Google-Smtp-Source: AMrXdXvFmpmXp0W590jjU/JK0hS97Y6poWePeIXehJ3olRjRpEuAe2EOY8h+HqJzFrWUS04TKPThMg== X-Received: by 2002:a17:906:99d1:b0:7c1:12ef:bf52 with SMTP id s17-20020a17090699d100b007c112efbf52mr39098475ejn.3.1672869911272; Wed, 04 Jan 2023 14:05:11 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id hb4-20020a170906b88400b008143bfe8429sm15797738ejb.73.2023.01.04.14.05.07 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 04 Jan 2023 14:05:10 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Song Gao , Antony Pavlov , Jan Kiszka , Marcel Apfelbaum , Hanna Reitz , Bernhard Beschow , BALATON Zoltan , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Alistair Francis , Paolo Bonzini , qemu-ppc@nongnu.org, Mark Burton , Richard Henderson , Magnus Damm , "Michael S. Tsirkin" , Bin Meng , Max Filippov , Aurelien Jarno , Eduardo Habkost , Palmer Dabbelt , Radoslaw Biernacki , Jiaxun Yang , "Edgar E. Iglesias" , Xiaojuan Yang , Peter Maydell , qemu-block@nongnu.org, qemu-riscv@nongnu.org, Yoshinori Sato , Alistair Francis , qemu-arm@nongnu.org, Leif Lindholm , Kevin Wolf Subject: [PATCH 02/20] hw/block: Use pflash_cfi01_get_blk() in pflash_cfi01_legacy_drive() Date: Wed, 4 Jan 2023 23:04:31 +0100 Message-Id: <20230104220449.41337-3-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230104220449.41337-1-philmd@linaro.org> References: <20230104220449.41337-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::630; envelope-from=philmd@linaro.org; helo=mail-ej1-x630.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org By using pflash_cfi01_get_blk(), pflash_cfi01_legacy_drive() doesn't require any knowledge of the PFlashCFI01 structure. Thus we can pass a generic DeviceState pointer. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Bin Meng --- hw/arm/sbsa-ref.c | 2 +- hw/arm/virt.c | 2 +- hw/block/pflash_cfi01.c | 6 +++--- hw/i386/pc_sysfw.c | 2 +- hw/riscv/virt.c | 2 +- include/hw/block/flash.h | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c index 65b9acba04..1d29e8ca7f 100644 --- a/hw/arm/sbsa-ref.c +++ b/hw/arm/sbsa-ref.c @@ -340,7 +340,7 @@ static bool sbsa_firmware_init(SBSAMachineState *sms, /* Map legacy -drive if=pflash to machine properties */ for (i = 0; i < ARRAY_SIZE(sms->flash); i++) { - pflash_cfi01_legacy_drive(sms->flash[i], + pflash_cfi01_legacy_drive(DEVICE(sms->flash[i]), drive_get(IF_PFLASH, 0, i)); } diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 954e3ca5ce..57726b0f52 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1227,7 +1227,7 @@ static bool virt_firmware_init(VirtMachineState *vms, /* Map legacy -drive if=pflash to machine properties */ for (i = 0; i < ARRAY_SIZE(vms->flash); i++) { - pflash_cfi01_legacy_drive(vms->flash[i], + pflash_cfi01_legacy_drive(DEVICE(vms->flash[i]), drive_get(IF_PFLASH, 0, i)); } diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c index 458c50ec45..8beba24989 100644 --- a/hw/block/pflash_cfi01.c +++ b/hw/block/pflash_cfi01.c @@ -1002,7 +1002,7 @@ MemoryRegion *pflash_cfi01_get_memory(PFlashCFI01 *fl) * Else if @fl's property "drive" is already set, fatal error. * Else set it to the BlockBackend with @dinfo. */ -void pflash_cfi01_legacy_drive(PFlashCFI01 *fl, DriveInfo *dinfo) +void pflash_cfi01_legacy_drive(DeviceState *dev, DriveInfo *dinfo) { Location loc; @@ -1012,11 +1012,11 @@ void pflash_cfi01_legacy_drive(PFlashCFI01 *fl, DriveInfo *dinfo) loc_push_none(&loc); qemu_opts_loc_restore(dinfo->opts); - if (fl->blk) { + if (pflash_cfi01_get_blk(dev)) { error_report("clashes with -machine"); exit(1); } - qdev_prop_set_drive_err(DEVICE(fl), "drive", blk_by_legacy_dinfo(dinfo), + qdev_prop_set_drive_err(dev, "drive", blk_by_legacy_dinfo(dinfo), &error_fatal); loc_pop(&loc); } diff --git a/hw/i386/pc_sysfw.c b/hw/i386/pc_sysfw.c index 4b85c48ec8..c08cba6628 100644 --- a/hw/i386/pc_sysfw.c +++ b/hw/i386/pc_sysfw.c @@ -214,7 +214,7 @@ void pc_system_firmware_init(PCMachineState *pcms, /* Map legacy -drive if=pflash to machine properties */ for (i = 0; i < ARRAY_SIZE(pcms->flash); i++) { - pflash_cfi01_legacy_drive(pcms->flash[i], + pflash_cfi01_legacy_drive(DEVICE(pcms->flash[i]), drive_get(IF_PFLASH, 0, i)); pflash_blk[i] = pflash_cfi01_get_blk(DEVICE(pcms->flash[i])); } diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index a5bc7353b4..400bd9329f 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -1517,7 +1517,7 @@ static void virt_machine_init(MachineState *machine) for (i = 0; i < ARRAY_SIZE(s->flash); i++) { /* Map legacy -drive if=pflash to machine properties */ - pflash_cfi01_legacy_drive(s->flash[i], + pflash_cfi01_legacy_drive(DEVICE(s->flash[i]), drive_get(IF_PFLASH, 0, i)); } virt_flash_map(s, system_memory); diff --git a/include/hw/block/flash.h b/include/hw/block/flash.h index 961b6e9f74..701a2c1701 100644 --- a/include/hw/block/flash.h +++ b/include/hw/block/flash.h @@ -23,7 +23,7 @@ PFlashCFI01 *pflash_cfi01_register(hwaddr base, int be); BlockBackend *pflash_cfi01_get_blk(DeviceState *dev); MemoryRegion *pflash_cfi01_get_memory(PFlashCFI01 *fl); -void pflash_cfi01_legacy_drive(PFlashCFI01 *dev, DriveInfo *dinfo); +void pflash_cfi01_legacy_drive(DeviceState *dev, DriveInfo *dinfo); /* pflash_cfi02.c */