[PATCH 1/4] hw/i386/pc: Get pflash MemoryRegion with sysbus_mmio_get_region()

Philippe Mathieu-Daudé posted 4 patches 4 years, 11 months ago
Maintainers: Aleksandar Rikalo <aleksandar.rikalo@syrmia.com>, Jiaxun Yang <jiaxun.yang@flygoat.com>, "Philippe Mathieu-Daudé" <f4bug@amsat.org>, Aurelien Jarno <aurelien@aurel32.net>
[PATCH 1/4] hw/i386/pc: Get pflash MemoryRegion with sysbus_mmio_get_region()
Posted by Philippe Mathieu-Daudé 4 years, 11 months ago
TYPE_PFLASH_CFI01 is a TYPE_SYS_BUS_DEVICE which registers its romd
MemoryRegion with sysbus_init_mmio(), so we can use the generic
sysbus_mmio_get_region() to get the region, no need for a specific
pflash_cfi01_get_memory() helper.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/i386/pc_sysfw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/i386/pc_sysfw.c b/hw/i386/pc_sysfw.c
index 9fe72b370e8..caad9cbd5eb 100644
--- a/hw/i386/pc_sysfw.c
+++ b/hw/i386/pc_sysfw.c
@@ -297,7 +297,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 = sysbus_mmio_get_region(SYS_BUS_DEVICE(system_flash), 0);
             pc_isa_bios_init(rom_memory, flash_mem, size);
 
             /* Encrypt the pflash boot ROM */
-- 
2.26.2

Re: [PATCH 1/4] hw/i386/pc: Get pflash MemoryRegion with sysbus_mmio_get_region()
Posted by Philippe Mathieu-Daudé 4 years, 11 months ago
Michael, Paolo, if you Ack this patch I can queue the series
via pflash-next.

On 3/7/21 11:26 PM, Philippe Mathieu-Daudé wrote:
> TYPE_PFLASH_CFI01 is a TYPE_SYS_BUS_DEVICE which registers its romd
> MemoryRegion with sysbus_init_mmio(), so we can use the generic
> sysbus_mmio_get_region() to get the region, no need for a specific
> pflash_cfi01_get_memory() helper.
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  hw/i386/pc_sysfw.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/i386/pc_sysfw.c b/hw/i386/pc_sysfw.c
> index 9fe72b370e8..caad9cbd5eb 100644
> --- a/hw/i386/pc_sysfw.c
> +++ b/hw/i386/pc_sysfw.c
> @@ -297,7 +297,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 = sysbus_mmio_get_region(SYS_BUS_DEVICE(system_flash), 0);
>              pc_isa_bios_init(rom_memory, flash_mem, size);
>  
>              /* Encrypt the pflash boot ROM */
>