[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-arm] [Qemu-devel] [PATCH 2/6] hw/sd/milkymist-memcard: split r
From: |
Alistair Francis |
Subject: |
Re: [Qemu-arm] [Qemu-devel] [PATCH 2/6] hw/sd/milkymist-memcard: split realize() out of SysBusDevice init() |
Date: |
Fri, 5 Jan 2018 18:25:19 -0800 |
On Wed, Jan 3, 2018 at 8:23 AM, Philippe Mathieu-Daudé <address@hidden> wrote:
> Create the SDCard in the realize() function.
>
> Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
Reviewed-by: Alistair Francis <address@hidden>
Alistair
> ---
> hw/sd/milkymist-memcard.c | 24 +++++++++++++++---------
> 1 file changed, 15 insertions(+), 9 deletions(-)
>
> diff --git a/hw/sd/milkymist-memcard.c b/hw/sd/milkymist-memcard.c
> index 5de3e00e2f..5df3a0f815 100644
> --- a/hw/sd/milkymist-memcard.c
> +++ b/hw/sd/milkymist-memcard.c
> @@ -255,24 +255,29 @@ static void milkymist_memcard_reset(DeviceState *d)
> static int milkymist_memcard_init(SysBusDevice *dev)
> {
> MilkymistMemcardState *s = MILKYMIST_MEMCARD(dev);
> - DriveInfo *dinfo;
> +
> + memory_region_init_io(&s->regs_region, OBJECT(s), &memcard_mmio_ops, s,
> + "milkymist-memcard", R_MAX * 4);
> + sysbus_init_mmio(dev, &s->regs_region);
> +
> + return 0;
> +}
> +
> +static void milkymist_memcard_realize(DeviceState *dev, Error **errp)
> +{
> + MilkymistMemcardState *s = MILKYMIST_MEMCARD(dev);
> BlockBackend *blk;
> + DriveInfo *dinfo;
>
> /* FIXME use a qdev drive property instead of drive_get_next() */
> dinfo = drive_get_next(IF_SD);
> blk = dinfo ? blk_by_legacy_dinfo(dinfo) : NULL;
> s->card = sd_init(blk, false);
> if (s->card == NULL) {
> - return -1;
> + error_setg(errp, "failed to init SD card");
> + return;
> }
> -
> s->enabled = blk && blk_is_inserted(blk);
> -
> - memory_region_init_io(&s->regs_region, OBJECT(s), &memcard_mmio_ops, s,
> - "milkymist-memcard", R_MAX * 4);
> - sysbus_init_mmio(dev, &s->regs_region);
> -
> - return 0;
> }
>
> static const VMStateDescription vmstate_milkymist_memcard = {
> @@ -298,6 +303,7 @@ static void milkymist_memcard_class_init(ObjectClass
> *klass, void *data)
> SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
>
> k->init = milkymist_memcard_init;
> + dc->realize = milkymist_memcard_realize;
> dc->reset = milkymist_memcard_reset;
> dc->vmsd = &vmstate_milkymist_memcard;
> /* Reason: init() method uses drive_get_next() */
> --
> 2.15.1
>
>
- [Qemu-arm] [PATCH 3/6] hw/sd/milkymist-memcard: expose a SDBus and connect the SDCard to it, (continued)
- [Qemu-arm] [PATCH 3/6] hw/sd/milkymist-memcard: expose a SDBus and connect the SDCard to it, Philippe Mathieu-Daudé, 2018/01/03
- [Qemu-arm] [PATCH 4/6] hw/sd/pl181: expose a SDBus and connect the SDCard to it, Philippe Mathieu-Daudé, 2018/01/03
- [Qemu-arm] [PATCH 6/6] hw/sd: move sdcard legacy API to "hw/sd/sdcard_legacy.h", Philippe Mathieu-Daudé, 2018/01/03
- [Qemu-arm] [PATCH 1/6] hw/sd/milkymist-memcard: use qemu_log_mask(), Philippe Mathieu-Daudé, 2018/01/03
- [Qemu-arm] [PATCH 2/6] hw/sd/milkymist-memcard: split realize() out of SysBusDevice init(), Philippe Mathieu-Daudé, 2018/01/03
- [Qemu-arm] [PATCH 5/6] hw/sd/ssi-sd: expose a SDBus and connect the SDCard to it, Philippe Mathieu-Daudé, 2018/01/03