From eb4f566bbbe195b2475e8fa5d9ed29ca56a18b02 Mon Sep 17 00:00:00 2001 From: Peter Maydell Date: Thu, 18 Feb 2016 14:16:18 +0000 Subject: sdhci_sysbus: Create SD card device in users, not the device itself Move the creation of the SD card device from the sdhci_sysbus device itself into the boards that create these devices. This allows us to remove the cannot_instantiate_with_device_add notation because we no longer call drive_get_next in the device model. Signed-off-by: Peter Maydell Reviewed-by: Alistair Francis Message-id: 1455646193-13238-7-git-send-email-peter.maydell@linaro.org --- hw/sd/sdhci.c | 25 ------------------------- 1 file changed, 25 deletions(-) (limited to 'hw/sd') diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c index 396dd10932..73e7c87fbf 100644 --- a/hw/sd/sdhci.c +++ b/hw/sd/sdhci.c @@ -1296,29 +1296,6 @@ static void sdhci_sysbus_realize(DeviceState *dev, Error ** errp) { SDHCIState *s = SYSBUS_SDHCI(dev); SysBusDevice *sbd = SYS_BUS_DEVICE(dev); - DriveInfo *di; - BlockBackend *blk; - DeviceState *carddev; - Error *err = NULL; - - /* Create and plug in the sd card. - * FIXME: this should be done by the users of this device so we - * do not use drive_get_next() here. - */ - di = drive_get_next(IF_SD); - blk = di ? blk_by_legacy_dinfo(di) : NULL; - - carddev = qdev_create(qdev_get_child_bus(dev, "sd-bus"), TYPE_SD_CARD); - qdev_prop_set_drive(carddev, "drive", blk, &err); - if (err) { - error_propagate(errp, err); - return; - } - object_property_set_bool(OBJECT(carddev), true, "realized", &err); - if (err) { - error_propagate(errp, err); - return; - } s->buf_maxsz = sdhci_get_fifolen(s); s->fifo_buffer = g_malloc0(s->buf_maxsz); @@ -1335,8 +1312,6 @@ static void sdhci_sysbus_class_init(ObjectClass *klass, void *data) dc->vmsd = &sdhci_vmstate; dc->props = sdhci_sysbus_properties; dc->realize = sdhci_sysbus_realize; - /* Reason: instance_init() method uses drive_get_next() */ - dc->cannot_instantiate_with_device_add_yet = true; } static const TypeInfo sdhci_sysbus_info = { -- cgit v1.2.3