hw: Mark devices picking up block backends actively FIXME

Drives defined with if!=none are for board initialization to wire up.
Board code calls drive_get() or similar to find them, and creates
devices with their qdev drive properties set accordingly.

Except a few devices go on a fishing expedition for a suitable backend
instead of exposing a drive property for board code to set: they call
driver_get() or drive_get_next() in their realize() or init() method
to implicitly connect to the "next" backend with a certain interface
type.

Picking up backends that way works when the devices are created by
board code.  But it's inappropriate for -device or device_add.  Not
only is this inconsistent with how the other block device models work
(they connect to a backend explicitly identified by a "drive"
property), it breaks when the "next" backend has been picked up by the
board already.

Example:

    $ qemu-system-arm -S -M connex -pflash flash.img -device ssi-sd
    Aborted (core dumped)

Mark them with suitable FIXME comments.

Cc: Andrzej Zaborowski <balrogg@gmail.com>
Cc: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Cc: "Andreas Färber" <andreas.faerber@web.de>
Cc: Michael Walle <michael@walle.cc>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
This commit is contained in:
Markus Armbruster 2015-03-23 19:03:13 +01:00
parent b8a86c4ac4
commit af9e40aa8f
7 changed files with 8 additions and 0 deletions

View File

@ -168,6 +168,7 @@ static int sl_nand_init(SysBusDevice *dev)
DriveInfo *nand; DriveInfo *nand;
s->ctl = 0; s->ctl = 0;
/* FIXME use a qdev drive property instead of drive_get() */
nand = drive_get(IF_MTD, 0, 0); nand = drive_get(IF_MTD, 0, 0);
s->nand = nand_init(nand ? blk_by_legacy_dinfo(nand) : NULL, s->nand = nand_init(nand ? blk_by_legacy_dinfo(nand) : NULL,
s->manf_id, s->chip_id); s->manf_id, s->chip_id);

View File

@ -623,6 +623,7 @@ static int m25p80_init(SSISlave *ss)
s->dirty_page = -1; s->dirty_page = -1;
s->storage = blk_blockalign(s->blk, s->size); s->storage = blk_blockalign(s->blk, s->size);
/* FIXME use a qdev drive property instead of drive_get_next() */
dinfo = drive_get_next(IF_MTD); dinfo = drive_get_next(IF_MTD);
if (dinfo) { if (dinfo) {

View File

@ -319,11 +319,13 @@ static void pc87312_realize(DeviceState *dev, Error **errp)
d = DEVICE(isa); d = DEVICE(isa);
qdev_prop_set_uint32(d, "iobase", get_fdc_iobase(s)); qdev_prop_set_uint32(d, "iobase", get_fdc_iobase(s));
qdev_prop_set_uint32(d, "irq", 6); qdev_prop_set_uint32(d, "irq", 6);
/* FIXME use a qdev drive property instead of drive_get() */
drive = drive_get(IF_FLOPPY, 0, 0); drive = drive_get(IF_FLOPPY, 0, 0);
if (drive != NULL) { if (drive != NULL) {
qdev_prop_set_drive_nofail(d, "driveA", qdev_prop_set_drive_nofail(d, "driveA",
blk_by_legacy_dinfo(drive)); blk_by_legacy_dinfo(drive));
} }
/* FIXME use a qdev drive property instead of drive_get() */
drive = drive_get(IF_FLOPPY, 0, 1); drive = drive_get(IF_FLOPPY, 0, 1);
if (drive != NULL) { if (drive != NULL) {
qdev_prop_set_drive_nofail(d, "driveB", qdev_prop_set_drive_nofail(d, "driveB",

View File

@ -255,6 +255,7 @@ static int milkymist_memcard_init(SysBusDevice *dev)
DriveInfo *dinfo; DriveInfo *dinfo;
BlockBackend *blk; BlockBackend *blk;
/* FIXME use a qdev drive property instead of drive_get_next() */
dinfo = drive_get_next(IF_SD); dinfo = drive_get_next(IF_SD);
blk = dinfo ? blk_by_legacy_dinfo(dinfo) : NULL; blk = dinfo ? blk_by_legacy_dinfo(dinfo) : NULL;
s->card = sd_init(blk, false); s->card = sd_init(blk, false);

View File

@ -490,6 +490,7 @@ static int pl181_init(SysBusDevice *sbd)
sysbus_init_irq(sbd, &s->irq[0]); sysbus_init_irq(sbd, &s->irq[0]);
sysbus_init_irq(sbd, &s->irq[1]); sysbus_init_irq(sbd, &s->irq[1]);
qdev_init_gpio_out(dev, s->cardstatus, 2); qdev_init_gpio_out(dev, s->cardstatus, 2);
/* FIXME use a qdev drive property instead of drive_get_next() */
dinfo = drive_get_next(IF_SD); dinfo = drive_get_next(IF_SD);
s->card = sd_init(dinfo ? blk_by_legacy_dinfo(dinfo) : NULL, false); s->card = sd_init(dinfo ? blk_by_legacy_dinfo(dinfo) : NULL, false);
if (s->card == NULL) { if (s->card == NULL) {

View File

@ -1146,6 +1146,7 @@ static void sdhci_initfn(SDHCIState *s)
{ {
DriveInfo *di; DriveInfo *di;
/* FIXME use a qdev drive property instead of drive_get_next() */
di = drive_get_next(IF_SD); di = drive_get_next(IF_SD);
s->card = sd_init(di ? blk_by_legacy_dinfo(di) : NULL, false); s->card = sd_init(di ? blk_by_legacy_dinfo(di) : NULL, false);
if (s->card == NULL) { if (s->card == NULL) {

View File

@ -255,6 +255,7 @@ static int ssi_sd_init(SSISlave *d)
DriveInfo *dinfo; DriveInfo *dinfo;
s->mode = SSI_SD_CMD; s->mode = SSI_SD_CMD;
/* FIXME use a qdev drive property instead of drive_get_next() */
dinfo = drive_get_next(IF_SD); dinfo = drive_get_next(IF_SD);
s->sd = sd_init(dinfo ? blk_by_legacy_dinfo(dinfo) : NULL, true); s->sd = sd_init(dinfo ? blk_by_legacy_dinfo(dinfo) : NULL, true);
if (s->sd == NULL) { if (s->sd == NULL) {