qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 4/6] fw_cfg: move fw_cfg_init1() into the fw_cfg


From: Igor Mammedov
Subject: Re: [Qemu-devel] [PATCH 4/6] fw_cfg: move fw_cfg_init1() into the fw_cfg_*_realize() functions
Date: Mon, 12 Jun 2017 14:03:35 +0200

On Sat, 10 Jun 2017 13:30:19 +0100
Mark Cave-Ayland <address@hidden> wrote:

> And rename to fw_cfg_common_realize() which better describes its role.
> 
> Signed-off-by: Mark Cave-Ayland <address@hidden>
> ---
>  hw/nvram/fw_cfg.c |    8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
> index f7b78a9..87b4392 100644
> --- a/hw/nvram/fw_cfg.c
> +++ b/hw/nvram/fw_cfg.c
> @@ -910,7 +910,7 @@ static void fw_cfg_machine_ready(struct Notifier *n, void 
> *data)
>  
>  
>  
> -static void fw_cfg_init1(DeviceState *dev)
> +static void fw_cfg_common_realize(DeviceState *dev)
>  {
>      FWCfgState *s = FW_CFG(dev);
>      MachineState *machine = MACHINE(qdev_get_machine());
> @@ -951,7 +951,6 @@ FWCfgState *fw_cfg_init_io_dma(uint32_t iobase, uint32_t 
> dma_iobase,
>          qdev_prop_set_bit(dev, "dma_enabled", false);
>      }
>  
> -    fw_cfg_init1(dev);
>      qdev_init_nofail(dev);
>  
>      s = FW_CFG(dev);
> @@ -985,7 +984,6 @@ FWCfgState *fw_cfg_init_mem_wide(hwaddr ctl_addr,
>          qdev_prop_set_bit(dev, "dma_enabled", false);
>      }
>  
> -    fw_cfg_init1(dev);
>      qdev_init_nofail(dev);
>  
>      sbd = SYS_BUS_DEVICE(dev);
> @@ -1085,6 +1083,8 @@ static void fw_cfg_io_realize(DeviceState *dev, Error 
> **errp)
>          return;
>      }
>  
> +    fw_cfg_common_realize(dev);
For QOM objects it's done with inheritance, see 9f318f8f7e6 for example.

i.e. define in parent TYPE_FW_CFG.realize and call it from children.
You also can dedup fw_cfg_mem_realize/fw_cfg_mem_realize and
move common code into new fw_cfg_realize()





reply via email to

[Prev in Thread] Current Thread [Next in Thread]