From patchwork Wed Jan 4 22:04:32 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: 639053 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp1973398pvb; Wed, 4 Jan 2023 14:44:36 -0800 (PST) X-Google-Smtp-Source: AMrXdXuoOcCUHoaEt9/MWi+Fgeo4E/vX2EXPOeU4D/l+RIeDlH0keaM1j4DX2M+R9+v8g1nz/Kpq X-Received: by 2002:ac8:754d:0:b0:3a9:8b1a:fe22 with SMTP id b13-20020ac8754d000000b003a98b1afe22mr66153483qtr.4.1672872276597; Wed, 04 Jan 2023 14:44:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672872276; cv=none; d=google.com; s=arc-20160816; b=G3BPPLSI31TWuZZuhQJZTxcyuxpVeXmL/iPeKv6ztdK5GQeXQ6aY/yHEy1qX9RzVUx qPI744xm4WyG8Mif97pTiCIMCAslFCTinl/fwTP8PX17pTEHf2rxwsMovGgb6HDcc9P8 I2ROyAmf5+75sH6jJJuPg8jQwMFHPVwv1WveFdYSr4ML7hBgGI4Zfbkd3XfwDwxXJ7x5 cJ3VOyJgWZX2b1UJljvETVJMDb8n5hg7CRFtaZM4w4JlODaQ3FmyAhLlOvQlhzhaLCjT A2j2/HlRexivB1DDpyL4BDoCTA7XaItL7CtJYGUHdQqRTR5iFViS/ggVdxJXSqIuXpZG sAbQ== 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=Q1t0N0tRAGBLSXopdQ2aZCaW6j+7EYMB+a4S4Z0Ax+Y=; b=rFSuuJg0A+DH2Sr+rNGxm3dUgMu/UtTFBn+Wp3oOLednrSf8GVtYtzBMUYqgBodWRs t/IGgVi6WKOD5JNZ/q05S3XkeTI41GsgeJnlg2NbhzpUUooS9TrC4zRxOKgUCCaystTK nPDcUcA6WoYjQ6WlvxYEF0sjECJKqHdkifsnGlxnKtVV4erIGxnoRbLXg2pIBGZfHLEo 0KouAGU2GxuleK4Rdcgx9+TKtCJyik0ZCRxk4eUq1HCjctVWi3MXtFcJZW/X0SjHUBXv xkIacBa1C6/TL7t+3Azvwz/gw59F/gBXNPmV0jHqWk9WJjqW4A4KIW7W4nBxk3FT4UNv CTJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NXf3buTS; 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 u21-20020a05620a455500b006fa49f39423si20181535qkp.485.2023.01.04.14.44.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 04 Jan 2023 14:44:36 -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=NXf3buTS; 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 1pDBtA-0000A5-KZ; Wed, 04 Jan 2023 17:05:36 -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 1pDBsy-0008Mu-2G for qemu-devel@nongnu.org; Wed, 04 Jan 2023 17:05:30 -0500 Received: from mail-ej1-x632.google.com ([2a00:1450:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pDBsv-0005IN-UX for qemu-devel@nongnu.org; Wed, 04 Jan 2023 17:05:23 -0500 Received: by mail-ej1-x632.google.com with SMTP id u9so86125687ejo.0 for ; Wed, 04 Jan 2023 14:05:20 -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=Q1t0N0tRAGBLSXopdQ2aZCaW6j+7EYMB+a4S4Z0Ax+Y=; b=NXf3buTStLj5mF9iDdLM4ngVyygOioxIe/xuES/sr9NLX5/CtT3WQ5ZbROOxphqbuZ pu8TXJxrUJ6i6Ylgnnqp4IzgWAvmtIFWy81GrLzYuJbH6abGiz56jhJLh1CO1f/j5VZZ bTrtFJKTAeyzRRki2347nW2sesuA5LDORBnOIwRMwI5Hd/J2PM0WtrfZ57FfwOPnfD4B lo5HOXw9mamm0MGTn7YKM1CNtiI+ErsLP8A0ukev0HVHpQ9am4HEqj6X/ej/L+0D/XCY 7RnrMieLoHrnvfTM/TNomDDJjF2tAY2W22haF7X+l+OPja8I7ASA6Bze7cIB5/Xw4Q43 7lHQ== 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=Q1t0N0tRAGBLSXopdQ2aZCaW6j+7EYMB+a4S4Z0Ax+Y=; b=5dyM8PmoEVMYcwYuzCGpSV9V2FVFqcoMIX1+KCDxE8Y5Dsh0yif3DBtoUB8uX3kg2y 3hUY/I788ZI8fZt7/FanzwMrJ6qrcL5s76p6sU4zWj9t720qLiiAbMaU6gdMk/9zMyZ3 L3q0vMZd9rP3ebiNptYxzSYhrhMV98GrtS5dWqyPpRKdj3KF4NDYAscQzeHX4lsf8PhR ZLEcPVjUe1bStQKPTmYMVkSkI/L23WYCw5h3MYLfq+6QqqbLASZiIU8qjHn7Zp9joXgt sugaG7+C0wJgX3paOvxbO0n+kP112OiN3MC1SKx79Dv2zEe63TlQs6LZSAA+JE+znxLe G7mw== X-Gm-Message-State: AFqh2krKkzB2FlokuPlUJPCTtMRk/8j0IsYL8fyjliiWINeDgCiQGc+R aowF3ItDJ9XLXB0l4Bif/NZxvLFOVWEMcRuv X-Received: by 2002:a17:906:d217:b0:7c1:6fc:6048 with SMTP id w23-20020a170906d21700b007c106fc6048mr40619376ejz.24.1672869919140; Wed, 04 Jan 2023 14:05:19 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id 1-20020a170906200100b007ae1e528390sm15617822ejo.163.2023.01.04.14.05.15 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 04 Jan 2023 14:05:18 -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 03/20] hw/block: Pass DeviceState to pflash_cfi01_get_memory() Date: Wed, 4 Jan 2023 23:04:32 +0100 Message-Id: <20230104220449.41337-4-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::632; envelope-from=philmd@linaro.org; helo=mail-ej1-x632.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::mem 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/block/pflash_cfi01.c | 4 +++- hw/i386/pc_sysfw.c | 2 +- hw/mips/malta.c | 3 ++- hw/ppc/e500.c | 2 +- hw/xtensa/xtfpga.c | 2 +- include/hw/block/flash.h | 2 +- 6 files changed, 9 insertions(+), 6 deletions(-) diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c index 8beba24989..866ea596ea 100644 --- a/hw/block/pflash_cfi01.c +++ b/hw/block/pflash_cfi01.c @@ -991,8 +991,10 @@ BlockBackend *pflash_cfi01_get_blk(DeviceState *dev) return fl->blk; } -MemoryRegion *pflash_cfi01_get_memory(PFlashCFI01 *fl) +MemoryRegion *pflash_cfi01_get_memory(DeviceState *dev) { + PFlashCFI01 *fl = PFLASH_CFI01(dev); + return &fl->mem; } diff --git a/hw/i386/pc_sysfw.c b/hw/i386/pc_sysfw.c index c08cba6628..60db0efb41 100644 --- a/hw/i386/pc_sysfw.c +++ b/hw/i386/pc_sysfw.c @@ -187,7 +187,7 @@ static void pc_system_flash_map(PCMachineState *pcms, 0x100000000ULL - total_size); if (i == 0) { - flash_mem = pflash_cfi01_get_memory(system_flash); + flash_mem = pflash_cfi01_get_memory(DEVICE(system_flash)); pc_isa_bios_init(rom_memory, flash_mem, size); /* Encrypt the pflash boot ROM */ diff --git a/hw/mips/malta.c b/hw/mips/malta.c index c0a2e0ab04..43fbb97799 100644 --- a/hw/mips/malta.c +++ b/hw/mips/malta.c @@ -1291,7 +1291,8 @@ void mips_malta_init(MachineState *machine) dinfo ? blk_by_legacy_dinfo(dinfo) : NULL, 65536, 4, 0x0000, 0x0000, 0x0000, 0x0000, be); - bios = pflash_cfi01_get_memory(fl); + dev = DEVICE(fl); + bios = pflash_cfi01_get_memory(dev); fl_idx++; if (kernel_filename) { ram_low_size = MIN(ram_size, 256 * MiB); diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c index 9fa1f8e6cf..b127068431 100644 --- a/hw/ppc/e500.c +++ b/hw/ppc/e500.c @@ -1144,7 +1144,7 @@ void ppce500_init(MachineState *machine) sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); memory_region_add_subregion(&pms->pbus_dev->mmio, 0, - pflash_cfi01_get_memory(PFLASH_CFI01(dev))); + pflash_cfi01_get_memory(dev)); } /* diff --git a/hw/xtensa/xtfpga.c b/hw/xtensa/xtfpga.c index 2a5556a35f..bce3a543b0 100644 --- a/hw/xtensa/xtfpga.c +++ b/hw/xtensa/xtfpga.c @@ -459,7 +459,7 @@ static void xtfpga_init(const XtfpgaBoardDesc *board, MachineState *machine) } } else { if (flash) { - MemoryRegion *flash_mr = pflash_cfi01_get_memory(flash); + MemoryRegion *flash_mr = pflash_cfi01_get_memory(DEVICE(flash)); MemoryRegion *flash_io = g_malloc(sizeof(*flash_io)); uint32_t size = env->config->sysrom.location[0].size; diff --git a/include/hw/block/flash.h b/include/hw/block/flash.h index 701a2c1701..25affdf7a5 100644 --- a/include/hw/block/flash.h +++ b/include/hw/block/flash.h @@ -22,7 +22,7 @@ PFlashCFI01 *pflash_cfi01_register(hwaddr base, uint16_t id2, uint16_t id3, int be); BlockBackend *pflash_cfi01_get_blk(DeviceState *dev); -MemoryRegion *pflash_cfi01_get_memory(PFlashCFI01 *fl); +MemoryRegion *pflash_cfi01_get_memory(DeviceState *dev); void pflash_cfi01_legacy_drive(DeviceState *dev, DriveInfo *dinfo); /* pflash_cfi02.c */