From patchwork Wed Jan 4 22:04:30 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: 639062 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp1977051pvb; Wed, 4 Jan 2023 14:57:41 -0800 (PST) X-Google-Smtp-Source: AMrXdXv4GmlHkhj3odeInFba0l+egNEgSX0xShi9oT74Qar0yiLL3L4PI2YRlOASBzHgHZKTDCxP X-Received: by 2002:ad4:4428:0:b0:532:caf:e90e with SMTP id e8-20020ad44428000000b005320cafe90emr3659416qvt.35.1672873061637; Wed, 04 Jan 2023 14:57:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672873061; cv=none; d=google.com; s=arc-20160816; b=bPy/DiNZNzkLVkazhZCu+5gJ5j60aJNkGxkCfX0X5HQ8a3WGKOEQiC6DROPB+XjVGs EQ84m9QeiHzsOgbBuXrkly0bLJ/Ciq9k6WnQpaGjlTtnRkuTiNtd1LXSSz6x8TAFmioB FazbY2yyt78y0WoNBvUj8EMpSOsAw9hmn4FyUZaBL1key0awrlYEKMzsSHokCoUlmD9j qIkKnbDRBFEZzsr8wPE+Q2VMroGNt7J9/v1WWG3nbEqlXfqqWg+Aa0dL3IL0iIBNCEeJ n7Xe2jhTfYX4aLhxl73eSBpJbGCrzoFTSdZ2yMTxEVbm1cJIw02JCWyzdBE1LzdQnq1X gNpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=AymZEv+37B+jt/sn5PVP1oF6IqgH4PMlbkATZu7erfY=; b=M0KXQWqcY2zyImgALF61JT0yyQ5OkqZvJ5oGdg7T6dc5mNMKJHXIEtZwDZOE+KcTQe fmDfeCMnLeMRdojya4D2lWSTTDcZhSrY3JaTpzMuW6T2YmUqftxiHk9J9x1qRppjtURS HZU22CXno8zIx7wsFEMPX7AWCRgF1gxjM3vSE1e5C+0LNBTHpmmeMDHMCUDRqDuR6TDk 1/QE91HVa2OuiCMxH6Li20D6LTS86MuBfg5BAHXI0WtQqoYHTzNhKFHkzUgeK32E99sH tKKXtNgmi7n2EX3iaAZNseyYrQsB7qxzwJeXKSa89lj1wFhIoxRUkbBrLQ8tQ8U+HMGv lQ1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="V/sFf4E1"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id iv8-20020ad45ce8000000b00531a4ccf140si10648458qvb.456.2023.01.04.14.57.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 04 Jan 2023 14:57:41 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="V/sFf4E1"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pDBt7-0008Tu-LL; Wed, 04 Jan 2023 17:05:33 -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 1pDBsi-0008Gi-01 for qemu-devel@nongnu.org; Wed, 04 Jan 2023 17:05:10 -0500 Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pDBse-0005Ct-UG for qemu-devel@nongnu.org; Wed, 04 Jan 2023 17:05:07 -0500 Received: by mail-ej1-x62f.google.com with SMTP id gh17so86056416ejb.6 for ; Wed, 04 Jan 2023 14:05:04 -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=AymZEv+37B+jt/sn5PVP1oF6IqgH4PMlbkATZu7erfY=; b=V/sFf4E1NoHzdzE0y2hhEA6AF2IhFKc1USaCA+9mNcb1txQzd1RYTEwCU8aoYz5Sk6 lIH9/gFNBZO/3yRGixPD0j3uTLAAjCt0c5BmYAt8lpd7wGAigPHETbcyFxBhekOCPSgi u/c/avpkKQgljDC6miZAtV7aCmB6zNzyGwdy3w/UQh54KoUm/VbEmvSsTW4k+TNhLqXI A76NS9H/N2TI2GoBs6VIkSui55RNxbpTlB45g2LU9SIaDLGdJMKSx4jK+81P/wWVqzYS a6PqhtU6kUNsoMHF3y9qGYxLgxnm9udqN1I0qu4G9Bez23nfrPxgpf4lMUaaIvgb8+nL VX4A== 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=AymZEv+37B+jt/sn5PVP1oF6IqgH4PMlbkATZu7erfY=; b=KsQ9YOWBotj7TLM9jBfU/9tGee+4XEE1t1K6dbRYH8bgpGq8p6Z9zRqzc/H6VauXLg i6VTo2z/U+tCvcrWAdvlks6wIqKveZogjlNr1c3GDK4HnGgn6PsifLIFnrRLB1PsbssH qO+wHrOZLwcpjkpddh6VyHuXvHkVfH7wFYLqmScnVXdOuCKAgiwtghjyBHETHX+5FmXT uK/PAn5TH60h8jILt5sV0pidFKq5CV+0ioibzshyfOFIfUnit/e5uapZn+5MsPXBP8Jk Yj4YVS9Hsuu7FupCmaK+ttWyE0r/BCGT+T55VUKyPWJdsXYHts4y9GuKpCa3B53T9EB8 VAwA== X-Gm-Message-State: AFqh2komdotebDj2yP32JFQVGM/VhpBO5LwQ44D5/7XEmqtH8f/U4ybw C5/HtL63dy5DwuEHNZfbVuHf1hMfuOY3ZPJH X-Received: by 2002:a17:907:9394:b0:7b2:7ae8:3661 with SMTP id cm20-20020a170907939400b007b27ae83661mr44537804ejc.21.1672869903056; Wed, 04 Jan 2023 14:05:03 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id v9-20020a170906292900b0073dd8e5a39fsm15648723ejd.156.2023.01.04.14.04.59 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 04 Jan 2023 14:05:02 -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 01/20] hw/block: Pass DeviceState to pflash_cfi01_get_blk() Date: Wed, 4 Jan 2023 23:04:30 +0100 Message-Id: <20230104220449.41337-2-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::62f; envelope-from=philmd@linaro.org; helo=mail-ej1-x62f.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org The point of a getter() function is to not expose the structure internal fields. Otherwise callers could simply access the PFlashCFI01::blk field. Have the callers pass a DeviceState* argument. The QOM type check is done in the callee. 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 | 4 +++- hw/i386/pc_sysfw.c | 4 ++-- include/hw/block/flash.h | 2 +- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c index 4bb444684f..65b9acba04 100644 --- a/hw/arm/sbsa-ref.c +++ b/hw/arm/sbsa-ref.c @@ -346,7 +346,7 @@ static bool sbsa_firmware_init(SBSAMachineState *sms, sbsa_flash_map(sms, sysmem, secure_sysmem); - pflash_blk0 = pflash_cfi01_get_blk(sms->flash[0]); + pflash_blk0 = pflash_cfi01_get_blk(DEVICE(sms->flash[0])); bios_name = MACHINE(sms)->firmware; if (bios_name) { diff --git a/hw/arm/virt.c b/hw/arm/virt.c index ea2413a0ba..954e3ca5ce 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1233,7 +1233,7 @@ static bool virt_firmware_init(VirtMachineState *vms, virt_flash_map(vms, sysmem, secure_sysmem); - pflash_blk0 = pflash_cfi01_get_blk(vms->flash[0]); + pflash_blk0 = pflash_cfi01_get_blk(DEVICE(vms->flash[0])); bios_name = MACHINE(vms)->firmware; if (bios_name) { diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c index 0cbc2fb4cb..458c50ec45 100644 --- a/hw/block/pflash_cfi01.c +++ b/hw/block/pflash_cfi01.c @@ -984,8 +984,10 @@ PFlashCFI01 *pflash_cfi01_register(hwaddr base, return PFLASH_CFI01(dev); } -BlockBackend *pflash_cfi01_get_blk(PFlashCFI01 *fl) +BlockBackend *pflash_cfi01_get_blk(DeviceState *dev) { + PFlashCFI01 *fl = PFLASH_CFI01(dev); + return fl->blk; } diff --git a/hw/i386/pc_sysfw.c b/hw/i386/pc_sysfw.c index c8d9e71b88..4b85c48ec8 100644 --- a/hw/i386/pc_sysfw.c +++ b/hw/i386/pc_sysfw.c @@ -152,7 +152,7 @@ static void pc_system_flash_map(PCMachineState *pcms, for (i = 0; i < ARRAY_SIZE(pcms->flash); i++) { system_flash = pcms->flash[i]; - blk = pflash_cfi01_get_blk(system_flash); + blk = pflash_cfi01_get_blk(DEVICE(system_flash)); if (!blk) { break; } @@ -216,7 +216,7 @@ void pc_system_firmware_init(PCMachineState *pcms, for (i = 0; i < ARRAY_SIZE(pcms->flash); i++) { pflash_cfi01_legacy_drive(pcms->flash[i], drive_get(IF_PFLASH, 0, i)); - pflash_blk[i] = pflash_cfi01_get_blk(pcms->flash[i]); + pflash_blk[i] = pflash_cfi01_get_blk(DEVICE(pcms->flash[i])); } /* Reject gaps */ diff --git a/include/hw/block/flash.h b/include/hw/block/flash.h index 86d8363bb0..961b6e9f74 100644 --- a/include/hw/block/flash.h +++ b/include/hw/block/flash.h @@ -21,7 +21,7 @@ PFlashCFI01 *pflash_cfi01_register(hwaddr base, uint16_t id0, uint16_t id1, uint16_t id2, uint16_t id3, int be); -BlockBackend *pflash_cfi01_get_blk(PFlashCFI01 *fl); +BlockBackend *pflash_cfi01_get_blk(DeviceState *dev); MemoryRegion *pflash_cfi01_get_memory(PFlashCFI01 *fl); void pflash_cfi01_legacy_drive(PFlashCFI01 *dev, DriveInfo *dinfo);