Convert the *_orphan() device-creation calls in the hw/arm npcm board files to the new parented API introduced earlier in this series, so every onboard device gets a stable path in the composition tree instead of landing in /machine/unattached with an unstable device[N] name.
The parent for each device is the object that owns its lifetime: the machine for board-created devices, the containing SoC device for composite children. Names follow existing QOM conventions. Per-site rationale (reviewers: dispute the modeling here): hw/arm/npcm7xx_boards.c:87 | qdev_new | parent | "flash[*]" | helper: threaded Object *parent from board init; multiple callers/CS → auto-index hw/arm/npcm7xx_boards.c:116 | qdev_new | parent | "sd-card[*]" | helper: threaded Object *parent from board init; per-unit → auto-index hw/arm/npcm7xx_boards.c:201 | i2c_slave_create_simple | parent | "tmp105[*]" | helper: threaded Object *parent from board init; 4× tmp105 → auto-index hw/arm/npcm7xx_boards.c:203 | i2c_slave_create_simple | parent | "tmp105[*]" | helper from board init; auto-index hw/arm/npcm7xx_boards.c:205 | i2c_slave_create_simple | parent | "tmp105[*]" | helper from board init; auto-index hw/arm/npcm7xx_boards.c:207 | i2c_slave_create_simple | parent | "tmp105[*]" | helper from board init; auto-index hw/arm/npcm7xx_boards.c:237 | i2c_slave_create_simple | parent | "tmp105[*]" | helper: threaded Object *parent from board init; 4× tmp105 → auto-index hw/arm/npcm7xx_boards.c:238 | i2c_slave_create_simple | parent | "tmp105[*]" | helper from board init; auto-index hw/arm/npcm7xx_boards.c:239 | i2c_slave_create_simple | parent | "tmp105[*]" | helper from board init; auto-index hw/arm/npcm7xx_boards.c:240 | i2c_slave_create_simple | parent | "tmp105[*]" | helper from board init; auto-index hw/arm/npcm7xx_boards.c:256 | i2c_slave_create_simple | parent | "pca9548" | helper from board init; single mux hw/arm/npcm7xx_boards.c:336 | i2c_slave_create_simple | parent | "pca9548[*]" | helper: threaded Object *parent from board init; 4× pca9548 → auto-index hw/arm/npcm7xx_boards.c:340 | i2c_slave_create_simple | parent | "tmp105[*]" | helper from board init; 8× tmp105 → auto-index hw/arm/npcm7xx_boards.c:341 | i2c_slave_create_simple | parent | "tmp105[*]" | helper from board init; auto-index hw/arm/npcm7xx_boards.c:342 | i2c_slave_create_simple | parent | "tmp105[*]" | helper from board init; auto-index hw/arm/npcm7xx_boards.c:343 | i2c_slave_create_simple | parent | "tmp105[*]" | helper from board init; auto-index hw/arm/npcm7xx_boards.c:345 | i2c_slave_create_simple | parent | "pca9548[*]" | helper from board init; auto-index hw/arm/npcm7xx_boards.c:347 | i2c_slave_create_simple | parent | "pca9548[*]" | helper from board init; auto-index hw/arm/npcm7xx_boards.c:351 | i2c_slave_create_simple | parent | "pca9548[*]" | helper from board init; auto-index hw/arm/npcm7xx_boards.c:355 | i2c_slave_create_simple | parent | "tmp105[*]" | helper from board init; auto-index hw/arm/npcm7xx_boards.c:356 | i2c_slave_create_simple | parent | "tmp105[*]" | helper from board init; auto-index hw/arm/npcm7xx_boards.c:357 | i2c_slave_create_simple | parent | "tmp105[*]" | helper from board init; auto-index hw/arm/npcm7xx_boards.c:358 | i2c_slave_create_simple | parent | "tmp105[*]" | helper from board init; auto-index hw/arm/npcm7xx.c:524 | sysbus_create_simple | OBJECT(dev) | "l2x0" | SoC DeviceClass.realize(dev); single L2 cache ctlr hw/arm/npcm8xx_boards.c:64 | qdev_new | parent | "flash[*]" | helper: threaded Object *parent from board init; auto-index hw/arm/npcm8xx_boards.c:162 | i2c_slave_create_simple | parent | "tmp105" | helper: threaded Object *parent from board init; single tmp105 Link: https://lore.kernel.org/qemu-devel/[email protected]/ Assisted-by: Kiro Signed-off-by: Alexander Graf <[email protected]> --- hw/arm/npcm7xx.c | 2 +- hw/arm/npcm7xx_boards.c | 107 ++++++++++++++++++++++++---------------- hw/arm/npcm8xx_boards.c | 19 ++++--- 3 files changed, 77 insertions(+), 51 deletions(-) diff --git a/hw/arm/npcm7xx.c b/hw/arm/npcm7xx.c index 8363a04f10..a930f7843a 100644 --- a/hw/arm/npcm7xx.c +++ b/hw/arm/npcm7xx.c @@ -521,7 +521,7 @@ static void npcm7xx_realize(DeviceState *dev, Error **errp) } /* L2 cache controller */ - sysbus_create_simple_orphan("l2x0", NPCM7XX_L2C_BA, NULL); + sysbus_create_simple(OBJECT(dev), "l2x0", "l2x0", NPCM7XX_L2C_BA, NULL); /* System Global Control Registers (GCR). Can fail due to user input. */ object_property_set_int(OBJECT(&s->gcr), "disabled-modules", diff --git a/hw/arm/npcm7xx_boards.c b/hw/arm/npcm7xx_boards.c index 7b5cdd7191..778ef0f232 100644 --- a/hw/arm/npcm7xx_boards.c +++ b/hw/arm/npcm7xx_boards.c @@ -78,17 +78,18 @@ static void npcm7xx_load_bootrom(MachineState *machine, NPCM7xxState *soc) } } -static void npcm7xx_connect_flash(NPCM7xxFIUState *fiu, int cs_no, - const char *flash_type, DriveInfo *dinfo) +static void npcm7xx_connect_flash(Object *parent, NPCM7xxFIUState *fiu, + int cs_no, const char *flash_type, + DriveInfo *dinfo) { DeviceState *flash; qemu_irq flash_cs; - flash = qdev_new_orphan(flash_type); + flash = qdev_new(parent, "flash[*]", flash_type); if (dinfo) { qdev_prop_set_drive(flash, "drive", blk_by_legacy_dinfo(dinfo)); } - qdev_realize_and_unref(flash, BUS(fiu->spi), &error_fatal); + qdev_realize(flash, BUS(fiu->spi), &error_fatal); flash_cs = qdev_get_gpio_in_named(flash, SSI_GPIO_CS, 0); qdev_connect_gpio_out_named(DEVICE(fiu), "cs", cs_no, flash_cs); @@ -102,7 +103,7 @@ static void npcm7xx_connect_dram(NPCM7xxState *soc, MemoryRegion *dram) &error_abort); } -static void sdhci_attach_drive(SDHCIState *sdhci, int unit) +static void sdhci_attach_drive(Object *parent, SDHCIState *sdhci, int unit) { DriveInfo *di = drive_get(IF_SD, 0, unit); BlockBackend *blk = di ? blk_by_legacy_dinfo(di) : NULL; @@ -113,9 +114,9 @@ static void sdhci_attach_drive(SDHCIState *sdhci, int unit) exit(1); } - DeviceState *carddev = qdev_new_orphan(TYPE_SD_CARD); + DeviceState *carddev = qdev_new(parent, "sd-card[*]", TYPE_SD_CARD); qdev_prop_set_drive_err(carddev, "drive", blk, &error_fatal); - qdev_realize_and_unref(carddev, bus, &error_fatal); + qdev_realize(carddev, bus, &error_fatal); } static NPCM7xxState *npcm7xx_create_soc(MachineState *machine, @@ -195,16 +196,20 @@ static void npcm7xx_connect_pwm_fan(NPCM7xxState *soc, SplitIRQ *splitter, qdev_connect_gpio_out(DEVICE(splitter), output_no, fan_duty_gpio); } -static void npcm750_evb_i2c_init(NPCM7xxState *soc) +static void npcm750_evb_i2c_init(Object *parent, NPCM7xxState *soc) { /* lm75 temperature sensor on SVB, tmp105 is compatible */ - i2c_slave_create_simple_orphan(npcm7xx_i2c_get_bus(soc, 0), "tmp105", 0x48); + i2c_slave_create_simple(parent, "tmp105[*]", + npcm7xx_i2c_get_bus(soc, 0), "tmp105", 0x48); /* lm75 temperature sensor on EB, tmp105 is compatible */ - i2c_slave_create_simple_orphan(npcm7xx_i2c_get_bus(soc, 1), "tmp105", 0x48); + i2c_slave_create_simple(parent, "tmp105[*]", + npcm7xx_i2c_get_bus(soc, 1), "tmp105", 0x48); /* tmp100 temperature sensor on EB, tmp105 is compatible */ - i2c_slave_create_simple_orphan(npcm7xx_i2c_get_bus(soc, 2), "tmp105", 0x48); + i2c_slave_create_simple(parent, "tmp105[*]", + npcm7xx_i2c_get_bus(soc, 2), "tmp105", 0x48); /* tmp100 temperature sensor on SVB, tmp105 is compatible */ - i2c_slave_create_simple_orphan(npcm7xx_i2c_get_bus(soc, 6), "tmp105", 0x48); + i2c_slave_create_simple(parent, "tmp105[*]", + npcm7xx_i2c_get_bus(soc, 6), "tmp105", 0x48); } static void npcm750_evb_fan_init(NPCM7xxMachine *machine, NPCM7xxState *soc) @@ -231,13 +236,17 @@ static void npcm750_evb_fan_init(NPCM7xxMachine *machine, NPCM7xxState *soc) npcm7xx_connect_pwm_fan(soc, &splitter[7], 0x0f, 1); } -static void quanta_gsj_i2c_init(NPCM7xxState *soc) +static void quanta_gsj_i2c_init(Object *parent, NPCM7xxState *soc) { /* GSJ machine have 4 max31725 temperature sensors, tmp105 is compatible. */ - i2c_slave_create_simple_orphan(npcm7xx_i2c_get_bus(soc, 1), "tmp105", 0x5c); - i2c_slave_create_simple_orphan(npcm7xx_i2c_get_bus(soc, 2), "tmp105", 0x5c); - i2c_slave_create_simple_orphan(npcm7xx_i2c_get_bus(soc, 3), "tmp105", 0x5c); - i2c_slave_create_simple_orphan(npcm7xx_i2c_get_bus(soc, 4), "tmp105", 0x5c); + i2c_slave_create_simple(parent, "tmp105[*]", + npcm7xx_i2c_get_bus(soc, 1), "tmp105", 0x5c); + i2c_slave_create_simple(parent, "tmp105[*]", + npcm7xx_i2c_get_bus(soc, 2), "tmp105", 0x5c); + i2c_slave_create_simple(parent, "tmp105[*]", + npcm7xx_i2c_get_bus(soc, 3), "tmp105", 0x5c); + i2c_slave_create_simple(parent, "tmp105[*]", + npcm7xx_i2c_get_bus(soc, 4), "tmp105", 0x5c); at24c_eeprom_init(npcm7xx_i2c_get_bus(soc, 9), 0x55, 8192); at24c_eeprom_init(npcm7xx_i2c_get_bus(soc, 10), 0x55, 8192); @@ -253,7 +262,8 @@ static void quanta_gsj_i2c_init(NPCM7xxState *soc) * - ucd90160@6b */ - i2c_slave_create_simple_orphan(npcm7xx_i2c_get_bus(soc, 15), "pca9548", 0x75); + i2c_slave_create_simple(parent, "pca9548", + npcm7xx_i2c_get_bus(soc, 15), "pca9548", 0x75); } static void quanta_gsj_fan_init(NPCM7xxMachine *machine, NPCM7xxState *soc) @@ -329,33 +339,45 @@ static void quanta_gbs_i2c_init(NPCM7xxState *soc) */ } -static void kudo_bmc_i2c_init(NPCM7xxState *soc) +static void kudo_bmc_i2c_init(Object *parent, NPCM7xxState *soc) { I2CSlave *i2c_mux; - i2c_mux = i2c_slave_create_simple_orphan(npcm7xx_i2c_get_bus(soc, 1), + i2c_mux = i2c_slave_create_simple(parent, "pca9548[*]", + npcm7xx_i2c_get_bus(soc, 1), TYPE_PCA9548, 0x75); /* tmp105 is compatible with the lm75 */ - i2c_slave_create_simple_orphan(pca954x_i2c_get_bus(i2c_mux, 4), "tmp105", 0x5c); - i2c_slave_create_simple_orphan(pca954x_i2c_get_bus(i2c_mux, 5), "tmp105", 0x5c); - i2c_slave_create_simple_orphan(pca954x_i2c_get_bus(i2c_mux, 6), "tmp105", 0x5c); - i2c_slave_create_simple_orphan(pca954x_i2c_get_bus(i2c_mux, 7), "tmp105", 0x5c); + i2c_slave_create_simple(parent, "tmp105[*]", + pca954x_i2c_get_bus(i2c_mux, 4), "tmp105", 0x5c); + i2c_slave_create_simple(parent, "tmp105[*]", + pca954x_i2c_get_bus(i2c_mux, 5), "tmp105", 0x5c); + i2c_slave_create_simple(parent, "tmp105[*]", + pca954x_i2c_get_bus(i2c_mux, 6), "tmp105", 0x5c); + i2c_slave_create_simple(parent, "tmp105[*]", + pca954x_i2c_get_bus(i2c_mux, 7), "tmp105", 0x5c); - i2c_slave_create_simple_orphan(npcm7xx_i2c_get_bus(soc, 1), TYPE_PCA9548, 0x77); + i2c_slave_create_simple(parent, "pca9548[*]", + npcm7xx_i2c_get_bus(soc, 1), TYPE_PCA9548, 0x77); - i2c_slave_create_simple_orphan(npcm7xx_i2c_get_bus(soc, 4), TYPE_PCA9548, 0x77); + i2c_slave_create_simple(parent, "pca9548[*]", + npcm7xx_i2c_get_bus(soc, 4), TYPE_PCA9548, 0x77); at24c_eeprom_init(npcm7xx_i2c_get_bus(soc, 4), 0x50, 8192); /* mbfru */ - i2c_mux = i2c_slave_create_simple_orphan(npcm7xx_i2c_get_bus(soc, 13), + i2c_mux = i2c_slave_create_simple(parent, "pca9548[*]", + npcm7xx_i2c_get_bus(soc, 13), TYPE_PCA9548, 0x77); /* tmp105 is compatible with the lm75 */ - i2c_slave_create_simple_orphan(pca954x_i2c_get_bus(i2c_mux, 2), "tmp105", 0x48); - i2c_slave_create_simple_orphan(pca954x_i2c_get_bus(i2c_mux, 3), "tmp105", 0x49); - i2c_slave_create_simple_orphan(pca954x_i2c_get_bus(i2c_mux, 4), "tmp105", 0x48); - i2c_slave_create_simple_orphan(pca954x_i2c_get_bus(i2c_mux, 5), "tmp105", 0x49); + i2c_slave_create_simple(parent, "tmp105[*]", + pca954x_i2c_get_bus(i2c_mux, 2), "tmp105", 0x48); + i2c_slave_create_simple(parent, "tmp105[*]", + pca954x_i2c_get_bus(i2c_mux, 3), "tmp105", 0x49); + i2c_slave_create_simple(parent, "tmp105[*]", + pca954x_i2c_get_bus(i2c_mux, 4), "tmp105", 0x48); + i2c_slave_create_simple(parent, "tmp105[*]", + pca954x_i2c_get_bus(i2c_mux, 5), "tmp105", 0x49); at24c_eeprom_init(npcm7xx_i2c_get_bus(soc, 14), 0x55, 8192); /* bmcfru */ @@ -371,8 +393,9 @@ static void npcm750_evb_init(MachineState *machine) qdev_realize(DEVICE(soc), NULL, &error_fatal); npcm7xx_load_bootrom(machine, soc); - npcm7xx_connect_flash(&soc->fiu[0], 0, "w25q256", drive_get(IF_MTD, 0, 0)); - npcm750_evb_i2c_init(soc); + npcm7xx_connect_flash(OBJECT(machine), &soc->fiu[0], 0, "w25q256", + drive_get(IF_MTD, 0, 0)); + npcm750_evb_i2c_init(OBJECT(machine), soc); npcm750_evb_fan_init(NPCM7XX_MACHINE(machine), soc); npcm7xx_load_kernel(machine, soc); } @@ -386,9 +409,9 @@ static void quanta_gsj_init(MachineState *machine) qdev_realize(DEVICE(soc), NULL, &error_fatal); npcm7xx_load_bootrom(machine, soc); - npcm7xx_connect_flash(&soc->fiu[0], 0, "mx25l25635e", + npcm7xx_connect_flash(OBJECT(machine), &soc->fiu[0], 0, "mx25l25635e", drive_get(IF_MTD, 0, 0)); - quanta_gsj_i2c_init(soc); + quanta_gsj_i2c_init(OBJECT(machine), soc); quanta_gsj_fan_init(NPCM7XX_MACHINE(machine), soc); npcm7xx_load_kernel(machine, soc); } @@ -403,11 +426,11 @@ static void quanta_gbs_init(MachineState *machine) npcm7xx_load_bootrom(machine, soc); - npcm7xx_connect_flash(&soc->fiu[0], 0, "mx66u51235f", + npcm7xx_connect_flash(OBJECT(machine), &soc->fiu[0], 0, "mx66u51235f", drive_get(IF_MTD, 0, 0)); quanta_gbs_i2c_init(soc); - sdhci_attach_drive(&soc->mmc.sdhci, 0); + sdhci_attach_drive(OBJECT(machine), &soc->mmc.sdhci, 0); npcm7xx_load_kernel(machine, soc); } @@ -420,13 +443,13 @@ static void kudo_bmc_init(MachineState *machine) qdev_realize(DEVICE(soc), NULL, &error_fatal); npcm7xx_load_bootrom(machine, soc); - npcm7xx_connect_flash(&soc->fiu[0], 0, "mx66u51235f", + npcm7xx_connect_flash(OBJECT(machine), &soc->fiu[0], 0, "mx66u51235f", drive_get(IF_MTD, 0, 0)); - npcm7xx_connect_flash(&soc->fiu[1], 0, "mx66u51235f", + npcm7xx_connect_flash(OBJECT(machine), &soc->fiu[1], 0, "mx66u51235f", drive_get(IF_MTD, 3, 0)); - kudo_bmc_i2c_init(soc); - sdhci_attach_drive(&soc->mmc.sdhci, 0); + kudo_bmc_i2c_init(OBJECT(machine), soc); + sdhci_attach_drive(OBJECT(machine), &soc->mmc.sdhci, 0); npcm7xx_load_kernel(machine, soc); } @@ -439,7 +462,7 @@ static void mori_bmc_init(MachineState *machine) qdev_realize(DEVICE(soc), NULL, &error_fatal); npcm7xx_load_bootrom(machine, soc); - npcm7xx_connect_flash(&soc->fiu[1], 0, "mx66u51235f", + npcm7xx_connect_flash(OBJECT(machine), &soc->fiu[1], 0, "mx66u51235f", drive_get(IF_MTD, 3, 0)); npcm7xx_load_kernel(machine, soc); diff --git a/hw/arm/npcm8xx_boards.c b/hw/arm/npcm8xx_boards.c index eb0248552f..ff2840b409 100644 --- a/hw/arm/npcm8xx_boards.c +++ b/hw/arm/npcm8xx_boards.c @@ -55,17 +55,18 @@ static void npcm8xx_load_bootrom(MachineState *machine, NPCM8xxState *soc) } } -static void npcm8xx_connect_flash(NPCM7xxFIUState *fiu, int cs_no, - const char *flash_type, DriveInfo *dinfo) +static void npcm8xx_connect_flash(Object *parent, NPCM7xxFIUState *fiu, + int cs_no, const char *flash_type, + DriveInfo *dinfo) { DeviceState *flash; qemu_irq flash_cs; - flash = qdev_new_orphan(flash_type); + flash = qdev_new(parent, "flash[*]", flash_type); if (dinfo) { qdev_prop_set_drive(flash, "drive", blk_by_legacy_dinfo(dinfo)); } - qdev_realize_and_unref(flash, BUS(fiu->spi), &error_fatal); + qdev_realize(flash, BUS(fiu->spi), &error_fatal); flash_cs = qdev_get_gpio_in_named(flash, SSI_GPIO_CS, 0); qdev_connect_gpio_out_named(DEVICE(fiu), "cs", cs_no, flash_cs); @@ -156,10 +157,11 @@ static void npcm8xx_connect_pwm_fan(NPCM8xxState *soc, SplitIRQ *splitter, qdev_connect_gpio_out(DEVICE(splitter), output_no, fan_duty_gpio); } -static void npcm845_evb_i2c_init(NPCM8xxState *soc) +static void npcm845_evb_i2c_init(Object *parent, NPCM8xxState *soc) { /* tmp100 temperature sensor on SVB, tmp105 is compatible */ - i2c_slave_create_simple_orphan(npcm8xx_i2c_get_bus(soc, 6), "tmp105", 0x48); + i2c_slave_create_simple(parent, "tmp105", + npcm8xx_i2c_get_bus(soc, 6), "tmp105", 0x48); } static void npcm845_evb_fan_init(NPCM8xxMachine *machine, NPCM8xxState *soc) @@ -195,8 +197,9 @@ static void npcm845_evb_init(MachineState *machine) qdev_realize(DEVICE(soc), NULL, &error_fatal); npcm8xx_load_bootrom(machine, soc); - npcm8xx_connect_flash(&soc->fiu[0], 0, "w25q256", drive_get(IF_MTD, 0, 0)); - npcm845_evb_i2c_init(soc); + npcm8xx_connect_flash(OBJECT(machine), &soc->fiu[0], 0, "w25q256", + drive_get(IF_MTD, 0, 0)); + npcm845_evb_i2c_init(OBJECT(machine), soc); npcm845_evb_fan_init(NPCM8XX_MACHINE(machine), soc); npcm8xx_load_kernel(machine, soc); } -- 2.47.1
