From nobody Wed Nov 19 08:25:41 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1615395957; cv=none; d=zohomail.com; s=zohoarc; b=dijDiuaOssBD87Disoh6vetCI3491nOdqn1rr/Suprxiw6TXnXbUpKdE4tH3Rq6FcxefWbUyU4x0NSyqk+Lon0xFRHYzT6kGrDRgZufopr/v487Gycv3EyKdzko+Y0vdJl/xeh7U1SPFeaBYdH00NyqatiGKNPpPHTGOTYdgcqE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615395957; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=qQO9biHCPAJnw7a1zkeuv52hwPL+u8u+MaxlaPRiSEo=; b=iyWNUtSLJ4nbdgex9H2HT9gzy25eeZJTg+UjFcuwUAKHIIYMiKFMeMbATo4Xv7WfTTdUfwFwFgsgRDgaH4QCLJKCMZ6Uhp8LargFwZIu/+WWPrygPW8KPMs7yNpedILs4voX1VEaDQckjwxj+nOgQq9r4YCYEXsGSghq0xq1J84= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1615395957858151.9009940422461; Wed, 10 Mar 2021 09:05:57 -0800 (PST) Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-551-qq8QrMAqPUOhxod3_vTJeg-1; Wed, 10 Mar 2021 12:05:53 -0500 Received: by mail-ej1-f70.google.com with SMTP id rl7so7486083ejb.16 for ; Wed, 10 Mar 2021 09:05:53 -0800 (PST) Return-Path: Return-Path: Received: from x1w.redhat.com (68.red-83-57-175.dynamicip.rima-tde.net. [83.57.175.68]) by smtp.gmail.com with ESMTPSA id v12sm18597ejh.94.2021.03.10.09.05.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 09:05:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615395956; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qQO9biHCPAJnw7a1zkeuv52hwPL+u8u+MaxlaPRiSEo=; b=GUXsbTUAatpkZmp0W9AiWDsiCLRmFnHw74qZdm+Y4Z181P/Dc02KGDTmcVRSJyKxjVuhDA lBkPt3lEmhIXCM/EkIMcGkgTYy5z8WP3oWS3PHCKi1OORmNc9OX9cvjneemVUy77qvmnQZ glOUl/SaDmgEpkO63Z34pWS4PoFGfUw= X-MC-Unique: qq8QrMAqPUOhxod3_vTJeg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qQO9biHCPAJnw7a1zkeuv52hwPL+u8u+MaxlaPRiSEo=; b=lDDvA5QVkcGPibXQieMsbw6VI+aIOHRY6ETZmhPQnUQMc8SeHKGJZdrsZcT4ZzAwtI Srvj4tj2U3bnfrofpl3dHrxZiU/cML9R3ENWq5y9kEmiAku1Q3puG4IKSLzRZckPG8J+ c1mieyyvm/gPgJBZevNMg8XgmOETl8bkjj6SWBW5Gr7MRnkVEsCp0KdsSif9Y4cXlWj/ kmCySZWoLr3bAY8WCZxCqx8awDCQqIIDKLKFUk+0jhuvYrHxfpCzs3PSmt83Tww2Opar vErpL0aFg91War476eFVZX96TC/EQ1bdrvyi8wvzJR7HNkxoxZP3BLv3QmmgPQXZF4wJ uKzA== X-Gm-Message-State: AOAM533j/FRYx/k3The+iRkbr0VeIZEmItIzyeYudurO6epEHxdWoYHn ZIAugOa9u8zICvdllBrTkHyrvdiv5202QA/df0G+IHeajtlT0DIGbV1xABvURVzGvCJ7+zp3LmW ENMvVYI5obN+lig== X-Received: by 2002:aa7:d54a:: with SMTP id u10mr4492799edr.316.1615395952670; Wed, 10 Mar 2021 09:05:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJyOS4qzLs41HF0mG0I98Zsnk1nUUB2p++d/C4PaiupWqwDHXzFLG3McwoL7dZ0NHmtP/kR64A== X-Received: by 2002:aa7:d54a:: with SMTP id u10mr4492778edr.316.1615395952563; Wed, 10 Mar 2021 09:05:52 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Alistair Francis , Max Reitz , David Edmondson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org, Stephen Checkoway , Kevin Wolf , Bin Meng Subject: [PATCH v2 04/12] hw/block/pflash_cfi02: Set rom_mode to true in pflash_setup_mappings() Date: Wed, 10 Mar 2021 18:05:20 +0100 Message-Id: <20210310170528.1184868-5-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210310170528.1184868-1-philmd@redhat.com> References: <20210310170528.1184868-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) There is only one call to pflash_setup_mappings(). Convert 'rom_mode' to boolean and set it to true directly within pflash_setup_mappings(). Reviewed-by: Bin Meng Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: David Edmondson --- v2: Convert to bool in pflash_register_memory (David) --- hw/block/pflash_cfi02.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/block/pflash_cfi02.c b/hw/block/pflash_cfi02.c index 845f50ed99b..0eb868ecd3d 100644 --- a/hw/block/pflash_cfi02.c +++ b/hw/block/pflash_cfi02.c @@ -108,7 +108,7 @@ struct PFlashCFI02 { MemoryRegion mem; MemoryRegion *mem_mappings; /* array; one per mapping */ MemoryRegion orig_mem; - int rom_mode; + bool rom_mode; int read_counter; /* used for lazy switch-back to rom mode */ int sectors_to_erase; uint64_t erase_time_remaining; @@ -181,12 +181,13 @@ static void pflash_setup_mappings(PFlashCFI02 *pfl) "pflash-alias", &pfl->orig_mem, 0, size); memory_region_add_subregion(&pfl->mem, i * size, &pfl->mem_mapping= s[i]); } + pfl->rom_mode =3D true; } =20 static void pflash_register_memory(PFlashCFI02 *pfl, int rom_mode) { memory_region_rom_device_set_romd(&pfl->orig_mem, rom_mode); - pfl->rom_mode =3D rom_mode; + pfl->rom_mode =3D !!rom_mode; } =20 static size_t pflash_regions_count(PFlashCFI02 *pfl) @@ -927,7 +928,6 @@ static void pflash_cfi02_realize(DeviceState *dev, Erro= r **errp) pfl->sector_erase_map =3D bitmap_new(pfl->total_sectors); =20 pflash_setup_mappings(pfl); - pfl->rom_mode =3D 1; sysbus_init_mmio(SYS_BUS_DEVICE(dev), &pfl->mem); =20 timer_init_ns(&pfl->timer, QEMU_CLOCK_VIRTUAL, pflash_timer, pfl); --=20 2.26.2