[RFC PATCH v2 074/137] hw/nvram/at24c: Give at24c_eeprom_init() a QOM parent

Alexander Graf <[email protected]>
Newsgroups org.nongnu.qemu-riscv,org.nongnu.qemu-arm,org.nongnu.qemu-devel
Message-ID <[email protected]>
Now that all callers of at24c_eeprom_init() and
at24c_eeprom_init_rom() live in already-converted hw/arm aspeed and
npcm board files, thread an Object *parent through these two
convenience helpers so that every I2C EEPROM created by an aspeed
or npcm board becomes a proper child of its machine instead of
landing under /machine/unattached.

Link: https://lore.kernel.org/qemu-devel/[email protected]/
AI-used-for: code (refactoring)
Signed-off-by: Alexander Graf <[email protected]>
---
 hw/arm/aspeed_ast2500_tiogapass.c  |  4 +--
 hw/arm/aspeed_ast2500_yosemitev2.c |  4 +--
 hw/arm/aspeed_ast2600_anacapa.c    | 20 +++++++-------
 hw/arm/aspeed_ast2600_bletchley.c  |  4 +--
 hw/arm/aspeed_ast2600_catalina.c   | 34 ++++++++++++------------
 hw/arm/aspeed_ast2600_fby35.c      | 10 +++----
 hw/arm/aspeed_ast2600_fuji.c       | 34 ++++++++++++------------
 hw/arm/aspeed_ast2600_gb200nvl.c   |  6 ++---
 hw/arm/aspeed_ast2600_rainier.c    | 42 +++++++++++++++---------------
 hw/arm/npcm7xx_boards.c            |  8 +++---
 hw/nvram/eeprom_at24c.c            | 12 +++++----
 include/hw/nvram/eeprom_at24c.h    |  6 +++--
 12 files changed, 94 insertions(+), 90 deletions(-)

diff --git a/hw/arm/aspeed_ast2500_tiogapass.c b/hw/arm/aspeed_ast2500_tiogapass.c
index 13d1db9cfa..c813fc7301 100644
--- a/hw/arm/aspeed_ast2500_tiogapass.c
+++ b/hw/arm/aspeed_ast2500_tiogapass.c
@@ -51,8 +51,8 @@ static void tiogapass_bmc_i2c_init(AspeedMachineState *bmc)
 {
     AspeedSoCState *soc = bmc->soc;
 
-    at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 4), 0x54, 128 * KiB);
-    at24c_eeprom_init_rom(aspeed_i2c_get_bus(&soc->i2c, 6), 0x54, 128 * KiB,
+    at24c_eeprom_init(OBJECT(bmc), aspeed_i2c_get_bus(&soc->i2c, 4), 0x54, 128 * KiB);
+    at24c_eeprom_init_rom(OBJECT(bmc), aspeed_i2c_get_bus(&soc->i2c, 6), 0x54, 128 * KiB,
                           tiogapass_bmc_fruid, tiogapass_bmc_fruid_len);
     /* TMP421 */
     i2c_slave_create_simple(OBJECT(bmc), "tmp421[*]",
diff --git a/hw/arm/aspeed_ast2500_yosemitev2.c b/hw/arm/aspeed_ast2500_yosemitev2.c
index 4e3c19bc07..57c9976051 100644
--- a/hw/arm/aspeed_ast2500_yosemitev2.c
+++ b/hw/arm/aspeed_ast2500_yosemitev2.c
@@ -51,8 +51,8 @@ static void yosemitev2_bmc_i2c_init(AspeedMachineState *bmc)
 {
     AspeedSoCState *soc = bmc->soc;
 
-    at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 4), 0x51, 128 * KiB);
-    at24c_eeprom_init_rom(aspeed_i2c_get_bus(&soc->i2c, 8), 0x51, 128 * KiB,
+    at24c_eeprom_init(OBJECT(bmc), aspeed_i2c_get_bus(&soc->i2c, 4), 0x51, 128 * KiB);
+    at24c_eeprom_init_rom(OBJECT(bmc), aspeed_i2c_get_bus(&soc->i2c, 8), 0x51, 128 * KiB,
                           yosemitev2_bmc_fruid, yosemitev2_bmc_fruid_len);
     /* TMP421 */
     i2c_slave_create_simple(OBJECT(bmc), "tmp421[*]",
diff --git a/hw/arm/aspeed_ast2600_anacapa.c b/hw/arm/aspeed_ast2600_anacapa.c
index d6412f5b0c..faf3fc070d 100644
--- a/hw/arm/aspeed_ast2600_anacapa.c
+++ b/hw/arm/aspeed_ast2600_anacapa.c
@@ -236,13 +236,13 @@ static void anacapa_bmc_i2c_init(AspeedMachineState *bmc)
 
     /* &i2c0 */
     /* eeprom@50 */
-    at24c_eeprom_init(i2c[0], 0x50, 256 * KiB);
+    at24c_eeprom_init(o, i2c[0], 0x50, 256 * KiB);
     /* i2c-mux@70 */
     i2c_slave_create_simple(o, "i2c-mux[*]", i2c[0], TYPE_PCA9546, 0x70);
 
     /* &i2c1 */
     /* eeprom@50 */
-    at24c_eeprom_init(i2c[1], 0x50, 256 * KiB);
+    at24c_eeprom_init(o, i2c[1], 0x50, 256 * KiB);
     /* i2c-mux@70 (PCA9546) — 4 channels, empty */
     i2c_slave_create_simple(o, "i2c-mux[*]", i2c[1], TYPE_PCA9546, 0x70);
 
@@ -252,7 +252,7 @@ static void anacapa_bmc_i2c_init(AspeedMachineState *bmc)
 
     /* &i2c6 */
     /* eeprom@50 */
-    at24c_eeprom_init_rom(i2c[6], 0x50, 32 * KiB,
+    at24c_eeprom_init_rom(o, i2c[6], 0x50, 32 * KiB,
                           hpm_eeprom, hpm_eeprom_len);
 
     /* &i2c8 */
@@ -269,7 +269,7 @@ static void anacapa_bmc_i2c_init(AspeedMachineState *bmc)
     i2c_slave_create_simple(o, "gpio[*]", pca954x_i2c_get_bus(i2c_mux, 0),
                             TYPE_PCA9552, 0x24);
     /* eeprom@50 */
-    at24c_eeprom_init_rom(pca954x_i2c_get_bus(i2c_mux, 0), 0x50, 16 * KiB,
+    at24c_eeprom_init_rom(o, pca954x_i2c_get_bus(i2c_mux, 0), 0x50, 16 * KiB,
                           rpdb_eeprom, rpdb_eeprom_len);
 
     /* i2c8mux ch1 */
@@ -280,15 +280,15 @@ static void anacapa_bmc_i2c_init(AspeedMachineState *bmc)
     i2c_slave_create_simple(o, "gpio[*]", pca954x_i2c_get_bus(i2c_mux, 1),
                             TYPE_PCA9552, 0x24);
     /* eeprom@50 */
-    at24c_eeprom_init_rom(pca954x_i2c_get_bus(i2c_mux, 1), 0x50, 16 * KiB,
+    at24c_eeprom_init_rom(o, pca954x_i2c_get_bus(i2c_mux, 1), 0x50, 16 * KiB,
                           lpdb_eeprom, lpdb_eeprom_len);
 
     /* &i2c9 */
     /* eeprom@50 */
-    at24c_eeprom_init_rom(i2c[9], 0x50, 16 * KiB,
+    at24c_eeprom_init_rom(o, i2c[9], 0x50, 16 * KiB,
                           scm_eeprom, scm_eeprom_len);
     /* eeprom@56 */
-    at24c_eeprom_init_rom(i2c[9], 0x56, 8 * KiB,
+    at24c_eeprom_init_rom(o, i2c[9], 0x56, 8 * KiB,
                           bsm_eeprom, bsm_eeprom_len);
 
     /* &i2c10 */
@@ -301,7 +301,7 @@ static void anacapa_bmc_i2c_init(AspeedMachineState *bmc)
     i2c_slave_create_simple(o, "gpio[*]", pca954x_i2c_get_bus(i2c_mux, 5),
                             TYPE_PCA9552, 0x22);
     /* eeprom@52 */
-    at24c_eeprom_init_rom(pca954x_i2c_get_bus(i2c_mux, 5), 0x52, 32 * KiB,
+    at24c_eeprom_init_rom(o, pca954x_i2c_get_bus(i2c_mux, 5), 0x52, 32 * KiB,
                           rbb_eeprom, rbb_eeprom_len);
 
     /* &i2c11 */
@@ -316,7 +316,7 @@ static void anacapa_bmc_i2c_init(AspeedMachineState *bmc)
     i2c_slave_create_simple(o, "gpio[*]", pca954x_i2c_get_bus(i2c_mux, 5),
                             TYPE_PCA9552, 0x22);
     /* eeprom@52 */
-    at24c_eeprom_init_rom(pca954x_i2c_get_bus(i2c_mux, 5), 0x52, 32 * KiB,
+    at24c_eeprom_init_rom(o, pca954x_i2c_get_bus(i2c_mux, 5), 0x52, 32 * KiB,
                           lbb_eeprom, lbb_eeprom_len);
 
     /* &i2c13 */
@@ -329,7 +329,7 @@ static void anacapa_bmc_i2c_init(AspeedMachineState *bmc)
 
     /* i2c13mux ch4 */
     /* eeprom@51 */
-    at24c_eeprom_init_rom(pca954x_i2c_get_bus(i2c_mux, 4), 0x51, 32 * KiB,
+    at24c_eeprom_init_rom(o, pca954x_i2c_get_bus(i2c_mux, 4), 0x51, 32 * KiB,
                           hpm_brd_id_eeprom, hpm_brd_id_eeprom_len);
 
     /* i2c13mux ch7 */
diff --git a/hw/arm/aspeed_ast2600_bletchley.c b/hw/arm/aspeed_ast2600_bletchley.c
index 58f0bc89bd..a9ae61f864 100644
--- a/hw/arm/aspeed_ast2600_bletchley.c
+++ b/hw/arm/aspeed_ast2600_bletchley.c
@@ -46,13 +46,13 @@ static void bletchley_bmc_i2c_init(AspeedMachineState *bmc)
     }
 
     /* Bus 6 */
-    at24c_eeprom_init(i2c[6], 0x56, 65536);
+    at24c_eeprom_init(OBJECT(bmc), i2c[6], 0x56, 65536);
     /* Missing model: nxp,pcf85263 @ 0x51 , but ds1338 works enough */
     i2c_slave_create_simple(OBJECT(bmc), "rtc", i2c[6], "ds1338", 0x51);
 
 
     /* Bus 7 */
-    at24c_eeprom_init(i2c[7], 0x54, 65536);
+    at24c_eeprom_init(OBJECT(bmc), i2c[7], 0x54, 65536);
 
     /* Bus 9 */
     i2c_slave_create_simple(OBJECT(bmc), "tmp421[*]",
diff --git a/hw/arm/aspeed_ast2600_catalina.c b/hw/arm/aspeed_ast2600_catalina.c
index 59fc0d2437..e33e40590d 100644
--- a/hw/arm/aspeed_ast2600_catalina.c
+++ b/hw/arm/aspeed_ast2600_catalina.c
@@ -484,7 +484,7 @@ static void catalina_bmc_i2c_init(AspeedMachineState *bmc)
     i2c_slave_create_simple(o, "gpio[*]", pca954x_i2c_get_bus(i2c_mux, 1),
                             TYPE_PCA9535, 0x20);
     /* eeprom@50 */
-    at24c_eeprom_init_rom(pca954x_i2c_get_bus(i2c_mux, 1), 0x50, 8 * KiB,
+    at24c_eeprom_init_rom(o, pca954x_i2c_get_bus(i2c_mux, 1), 0x50, 8 * KiB,
                           gb200io_eeprom, gb200io_eeprom_len);
 
     /* i2c-mux@73 (PCA9546) on i2c0 */
@@ -502,7 +502,7 @@ static void catalina_bmc_i2c_init(AspeedMachineState *bmc)
     i2c_slave_create_simple(o, "gpio[*]", pca954x_i2c_get_bus(i2c_mux, 1),
                             TYPE_PCA9535, 0x21);
     /* eeprom@50 */
-    at24c_eeprom_init_rom(pca954x_i2c_get_bus(i2c_mux, 1), 0x50, 8 * KiB,
+    at24c_eeprom_init_rom(o, pca954x_i2c_get_bus(i2c_mux, 1), 0x50, 8 * KiB,
                           gb200io_eeprom, gb200io_eeprom_len);
 
     /* i2c-mux@77 (PCA9546) on i2c0 */
@@ -526,7 +526,7 @@ static void catalina_bmc_i2c_init(AspeedMachineState *bmc)
 
     /* i2c1mux0ch5 */
     /* eeprom@54 */
-    at24c_eeprom_init_rom(pca954x_i2c_get_bus(i2c_mux, 5), 0x54, 8 * KiB,
+    at24c_eeprom_init_rom(o, pca954x_i2c_get_bus(i2c_mux, 5), 0x54, 8 * KiB,
                           pdb_eeprom, pdb_eeprom_len);
     /* tpm75@4f */
     i2c_slave_create_simple(o, "tmp75[*]", pca954x_i2c_get_bus(i2c_mux, 5),
@@ -540,12 +540,12 @@ static void catalina_bmc_i2c_init(AspeedMachineState *bmc)
     i2c_slave_create_simple(o, "gpio[*]", pca954x_i2c_get_bus(i2c_mux, 6),
                             TYPE_PCA9552, 0x25);
     /* eeprom@51 */
-    at24c_eeprom_init_rom(pca954x_i2c_get_bus(i2c_mux, 6), 0x51, 8 * KiB,
+    at24c_eeprom_init_rom(o, pca954x_i2c_get_bus(i2c_mux, 6), 0x51, 8 * KiB,
                           osfp_eeprom, osfp_eeprom_len);
 
     /* i2c1mux0ch7 */
     /* eeprom@53 */
-    at24c_eeprom_init_rom(pca954x_i2c_get_bus(i2c_mux, 7), 0x53, 8 * KiB,
+    at24c_eeprom_init_rom(o, pca954x_i2c_get_bus(i2c_mux, 7), 0x53, 8 * KiB,
                           fio_eeprom, fio_eeprom_len);
     /* temperature-sensor@4b - tmp75 */
     i2c_slave_create_simple(o, "tmp75[*]", pca954x_i2c_get_bus(i2c_mux, 7),
@@ -559,9 +559,9 @@ static void catalina_bmc_i2c_init(AspeedMachineState *bmc)
     /* io_expander0 - pca9555@27 */
     i2c_slave_create_simple(o, "gpio[*]", i2c[2], TYPE_PCA9552, 0x27);
     /* eeprom@50 */
-    at24c_eeprom_init(i2c[2], 0x50, 8 * KiB);
+    at24c_eeprom_init(o, i2c[2], 0x50, 8 * KiB);
     /* eeprom@51 */
-    at24c_eeprom_init(i2c[2], 0x51, 8 * KiB);
+    at24c_eeprom_init(o, i2c[2], 0x51, 8 * KiB);
 
     /* &i2c5 */
     /* i2c-mux@70 (PCA9548) on i2c5 */
@@ -569,7 +569,7 @@ static void catalina_bmc_i2c_init(AspeedMachineState *bmc)
                                       TYPE_PCA9548, 0x70);
     /* i2c5mux0ch6 */
     /* eeprom@52 */
-    at24c_eeprom_init_rom(pca954x_i2c_get_bus(i2c_mux, 6), 0x52, 8 * KiB,
+    at24c_eeprom_init_rom(o, pca954x_i2c_get_bus(i2c_mux, 6), 0x52, 8 * KiB,
                           hdd_eeprom, hdd_eeprom_len);
     /* i2c5mux0ch7 */
     /* ina230@40 - no model */
@@ -589,36 +589,36 @@ static void catalina_bmc_i2c_init(AspeedMachineState *bmc)
     /* temperature-sensor@4b - tpm75 */
     i2c_slave_create_simple(o, "tmp75[*]", i2c[9], TYPE_TMP75, 0x4b);
     /* eeprom@50 */
-    at24c_eeprom_init_rom(i2c[9], 0x50, 8 * KiB, scm_eeprom, scm_eeprom_len);
+    at24c_eeprom_init_rom(o, i2c[9], 0x50, 8 * KiB, scm_eeprom, scm_eeprom_len);
     /* eeprom@56 */
-    at24c_eeprom_init_rom(i2c[9], 0x56, 8 * KiB, bsm_eeprom, bsm_eeprom_len);
+    at24c_eeprom_init_rom(o, i2c[9], 0x56, 8 * KiB, bsm_eeprom, bsm_eeprom_len);
 
     /* &i2c10 */
     /* temperature-sensor@1f - tpm421 */
     i2c_slave_create_simple(o, "tmp421[*]", i2c[10], TYPE_TMP421, 0x1f);
     /* eeprom@50 */
-    at24c_eeprom_init_rom(i2c[10], 0x50, 8 * KiB, nic_eeprom, nic_eeprom_len);
+    at24c_eeprom_init_rom(o, i2c[10], 0x50, 8 * KiB, nic_eeprom, nic_eeprom_len);
 
     /* &i2c11 */
     /* ssif-bmc@10 - no model */
 
     /* &i2c12 */
     /* eeprom@50 */
-    at24c_eeprom_init_rom(i2c[12], 0x50, 8 * KiB,
+    at24c_eeprom_init_rom(o, i2c[12], 0x50, 8 * KiB,
                           gb200_eeprom, gb200_eeprom_len);
     /* eeprom@54 */
-    at24c_eeprom_init_rom(i2c[12], 0x54, 256,
+    at24c_eeprom_init_rom(o, i2c[12], 0x54, 256,
                           cable_eeprom, cable_eeprom_len);
 
     /* &i2c13 */
     /* eeprom@50 */
-    at24c_eeprom_init_rom(i2c[13], 0x50, 8 * KiB,
+    at24c_eeprom_init_rom(o, i2c[13], 0x50, 8 * KiB,
                           gb200_eeprom, gb200_eeprom_len);
     /* eeprom@54 */
-    at24c_eeprom_init_rom(i2c[13], 0x54, 256,
+    at24c_eeprom_init_rom(o, i2c[13], 0x54, 256,
                           cable_eeprom, cable_eeprom_len);
     /* eeprom@57 */
-    at24c_eeprom_init_rom(i2c[13], 0x57, 256, hmc_eeprom, hmc_eeprom_len);
+    at24c_eeprom_init_rom(o, i2c[13], 0x57, 256, hmc_eeprom, hmc_eeprom_len);
 
     /* &i2c14 */
     /* io_expander9 - pca9555@10 */
@@ -638,7 +638,7 @@ static void catalina_bmc_i2c_init(AspeedMachineState *bmc)
     /* temperature-sensor@1f - tmp421 */
     i2c_slave_create_simple(o, "tmp421[*]", i2c[15], TYPE_TMP421, 0x1f);
     /* eeprom@52 */
-    at24c_eeprom_init_rom(i2c[15], 0x52, 8 * KiB, nic_eeprom, nic_eeprom_len);
+    at24c_eeprom_init_rom(o, i2c[15], 0x52, 8 * KiB, nic_eeprom, nic_eeprom_len);
 }
 
 static void aspeed_machine_catalina_class_init(ObjectClass *oc,
diff --git a/hw/arm/aspeed_ast2600_fby35.c b/hw/arm/aspeed_ast2600_fby35.c
index dedc273ee3..d7bea13706 100644
--- a/hw/arm/aspeed_ast2600_fby35.c
+++ b/hw/arm/aspeed_ast2600_fby35.c
@@ -109,13 +109,13 @@ static void fby35_i2c_init(AspeedMachineState *bmc)
     i2c_slave_create_simple(OBJECT(bmc), "lm75[*]", i2c[12], TYPE_LM75, 0x4e);
     i2c_slave_create_simple(OBJECT(bmc), "lm75[*]", i2c[12], TYPE_LM75, 0x4f);
 
-    at24c_eeprom_init(i2c[4], 0x51, 128 * KiB);
-    at24c_eeprom_init(i2c[6], 0x51, 128 * KiB);
-    at24c_eeprom_init_rom(i2c[8], 0x50, 32 * KiB, fby35_nic_fruid,
+    at24c_eeprom_init(OBJECT(bmc), i2c[4], 0x51, 128 * KiB);
+    at24c_eeprom_init(OBJECT(bmc), i2c[6], 0x51, 128 * KiB);
+    at24c_eeprom_init_rom(OBJECT(bmc), i2c[8], 0x50, 32 * KiB, fby35_nic_fruid,
                           fby35_nic_fruid_len);
-    at24c_eeprom_init_rom(i2c[11], 0x51, 128 * KiB, fby35_bb_fruid,
+    at24c_eeprom_init_rom(OBJECT(bmc), i2c[11], 0x51, 128 * KiB, fby35_bb_fruid,
                           fby35_bb_fruid_len);
-    at24c_eeprom_init_rom(i2c[11], 0x54, 128 * KiB, fby35_bmc_fruid,
+    at24c_eeprom_init_rom(OBJECT(bmc), i2c[11], 0x54, 128 * KiB, fby35_bmc_fruid,
                           fby35_bmc_fruid_len);
 
     /*
diff --git a/hw/arm/aspeed_ast2600_fuji.c b/hw/arm/aspeed_ast2600_fuji.c
index 1e681d0090..396bd6c8b7 100644
--- a/hw/arm/aspeed_ast2600_fuji.c
+++ b/hw/arm/aspeed_ast2600_fuji.c
@@ -66,45 +66,45 @@ static void fuji_bmc_i2c_init(AspeedMachineState *bmc)
      * EEPROM 24c64 size is 64Kbits or 8 Kbytes
      *        24c02 size is 2Kbits or 256 bytes
      */
-    at24c_eeprom_init(i2c[19], 0x52, 8 * KiB);
-    at24c_eeprom_init(i2c[20], 0x50, 256);
-    at24c_eeprom_init(i2c[22], 0x52, 256);
+    at24c_eeprom_init(o, i2c[19], 0x52, 8 * KiB);
+    at24c_eeprom_init(o, i2c[20], 0x50, 256);
+    at24c_eeprom_init(o, i2c[22], 0x52, 256);
 
     i2c_slave_create_simple(o, "lm75[*]", i2c[3], TYPE_LM75, 0x48);
     i2c_slave_create_simple(o, "lm75[*]", i2c[3], TYPE_LM75, 0x49);
     i2c_slave_create_simple(o, "lm75[*]", i2c[3], TYPE_LM75, 0x4a);
     i2c_slave_create_simple(o, "tmp422", i2c[3], TYPE_TMP422, 0x4c);
 
-    at24c_eeprom_init(i2c[8], 0x51, 8 * KiB);
+    at24c_eeprom_init(o, i2c[8], 0x51, 8 * KiB);
     i2c_slave_create_simple(o, "lm75[*]", i2c[8], TYPE_LM75, 0x4a);
 
     i2c_slave_create_simple(o, "lm75[*]", i2c[50], TYPE_LM75, 0x4c);
-    at24c_eeprom_init(i2c[50], 0x52, 8 * KiB);
+    at24c_eeprom_init(o, i2c[50], 0x52, 8 * KiB);
     i2c_slave_create_simple(o, "tmp75[*]", i2c[51], TYPE_TMP75, 0x48);
     i2c_slave_create_simple(o, "tmp75[*]", i2c[52], TYPE_TMP75, 0x49);
 
     i2c_slave_create_simple(o, "tmp75[*]", i2c[59], TYPE_TMP75, 0x48);
     i2c_slave_create_simple(o, "tmp75[*]", i2c[60], TYPE_TMP75, 0x49);
 
-    at24c_eeprom_init(i2c[65], 0x53, 8 * KiB);
+    at24c_eeprom_init(o, i2c[65], 0x53, 8 * KiB);
     i2c_slave_create_simple(o, "tmp75[*]", i2c[66], TYPE_TMP75, 0x49);
     i2c_slave_create_simple(o, "tmp75[*]", i2c[66], TYPE_TMP75, 0x48);
-    at24c_eeprom_init(i2c[68], 0x52, 8 * KiB);
-    at24c_eeprom_init(i2c[69], 0x52, 8 * KiB);
-    at24c_eeprom_init(i2c[70], 0x52, 8 * KiB);
-    at24c_eeprom_init(i2c[71], 0x52, 8 * KiB);
+    at24c_eeprom_init(o, i2c[68], 0x52, 8 * KiB);
+    at24c_eeprom_init(o, i2c[69], 0x52, 8 * KiB);
+    at24c_eeprom_init(o, i2c[70], 0x52, 8 * KiB);
+    at24c_eeprom_init(o, i2c[71], 0x52, 8 * KiB);
 
-    at24c_eeprom_init(i2c[73], 0x53, 8 * KiB);
+    at24c_eeprom_init(o, i2c[73], 0x53, 8 * KiB);
     i2c_slave_create_simple(o, "tmp75[*]", i2c[74], TYPE_TMP75, 0x49);
     i2c_slave_create_simple(o, "tmp75[*]", i2c[74], TYPE_TMP75, 0x48);
-    at24c_eeprom_init(i2c[76], 0x52, 8 * KiB);
-    at24c_eeprom_init(i2c[77], 0x52, 8 * KiB);
-    at24c_eeprom_init(i2c[78], 0x52, 8 * KiB);
-    at24c_eeprom_init(i2c[79], 0x52, 8 * KiB);
-    at24c_eeprom_init(i2c[28], 0x50, 256);
+    at24c_eeprom_init(o, i2c[76], 0x52, 8 * KiB);
+    at24c_eeprom_init(o, i2c[77], 0x52, 8 * KiB);
+    at24c_eeprom_init(o, i2c[78], 0x52, 8 * KiB);
+    at24c_eeprom_init(o, i2c[79], 0x52, 8 * KiB);
+    at24c_eeprom_init(o, i2c[28], 0x50, 256);
 
     for (int i = 0; i < 8; i++) {
-        at24c_eeprom_init(i2c[81 + i * 8], 0x56, 64 * KiB);
+        at24c_eeprom_init(o, i2c[81 + i * 8], 0x56, 64 * KiB);
         i2c_slave_create_simple(o, "tmp75[*]", i2c[82 + i * 8],
                                 TYPE_TMP75, 0x48);
         i2c_slave_create_simple(o, "tmp75[*]", i2c[83 + i * 8],
diff --git a/hw/arm/aspeed_ast2600_gb200nvl.c b/hw/arm/aspeed_ast2600_gb200nvl.c
index 1cf35f96bd..357f30cf83 100644
--- a/hw/arm/aspeed_ast2600_gb200nvl.c
+++ b/hw/arm/aspeed_ast2600_gb200nvl.c
@@ -68,11 +68,11 @@ static void gb200nvl_bmc_i2c_init(AspeedMachineState *bmc)
     object_property_set_str(OBJECT(dev), "pin1", "high", &error_fatal);
 
     aspeed_create_pca9554(OBJECT(bmc), soc, 9, 0x21);
-    at24c_eeprom_init(i2c[9], 0x50, 64 * KiB);
-    at24c_eeprom_init(i2c[9], 0x51, 64 * KiB);
+    at24c_eeprom_init(OBJECT(bmc), i2c[9], 0x50, 64 * KiB);
+    at24c_eeprom_init(OBJECT(bmc), i2c[9], 0x51, 64 * KiB);
 
     /* Bus 11 */
-    at24c_eeprom_init_rom(i2c[10], 0x50, 256, gb200nvl_bmc_fruid,
+    at24c_eeprom_init_rom(OBJECT(bmc), i2c[10], 0x50, 256, gb200nvl_bmc_fruid,
                           gb200nvl_bmc_fruid_len);
 }
 
diff --git a/hw/arm/aspeed_ast2600_rainier.c b/hw/arm/aspeed_ast2600_rainier.c
index 2f5e3daf3b..4ec36e6129 100644
--- a/hw/arm/aspeed_ast2600_rainier.c
+++ b/hw/arm/aspeed_ast2600_rainier.c
@@ -69,7 +69,7 @@ static void rainier_bmc_i2c_init(AspeedMachineState *bmc)
     I2CSlave *i2c_mux;
     Object *o = OBJECT(bmc);
 
-    at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 0), 0x51, 32 * KiB);
+    at24c_eeprom_init(o, aspeed_i2c_get_bus(&soc->i2c, 0), 0x51, 32 * KiB);
 
     aspeed_create_pca9552(OBJECT(bmc), soc, 3, 0x61);
 
@@ -86,9 +86,9 @@ static void rainier_bmc_i2c_init(AspeedMachineState *bmc)
     i2c_mux = i2c_slave_create_simple(o, "i2c-mux[*]",
                                       aspeed_i2c_get_bus(&soc->i2c, 4),
                                       "pca9546", 0x70);
-    at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 0), 0x50, 64 * KiB);
-    at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 1), 0x51, 64 * KiB);
-    at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 2), 0x52, 64 * KiB);
+    at24c_eeprom_init(o, pca954x_i2c_get_bus(i2c_mux, 0), 0x50, 64 * KiB);
+    at24c_eeprom_init(o, pca954x_i2c_get_bus(i2c_mux, 1), 0x51, 64 * KiB);
+    at24c_eeprom_init(o, pca954x_i2c_get_bus(i2c_mux, 2), 0x52, 64 * KiB);
     aspeed_create_pca9552(OBJECT(bmc), soc, 4, 0x60);
 
     i2c_slave_create_simple(o, "tmp105[*]",
@@ -102,8 +102,8 @@ static void rainier_bmc_i2c_init(AspeedMachineState *bmc)
     i2c_mux = i2c_slave_create_simple(o, "i2c-mux[*]",
                                       aspeed_i2c_get_bus(&soc->i2c, 5),
                                       "pca9546", 0x70);
-    at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 0), 0x50, 64 * KiB);
-    at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 1), 0x51, 64 * KiB);
+    at24c_eeprom_init(o, pca954x_i2c_get_bus(i2c_mux, 0), 0x50, 64 * KiB);
+    at24c_eeprom_init(o, pca954x_i2c_get_bus(i2c_mux, 1), 0x51, 64 * KiB);
 
     i2c_slave_create_simple(o, "tmp105[*]",
                             aspeed_i2c_get_bus(&soc->i2c, 6),
@@ -117,10 +117,10 @@ static void rainier_bmc_i2c_init(AspeedMachineState *bmc)
     i2c_mux = i2c_slave_create_simple(o, "i2c-mux[*]",
                                       aspeed_i2c_get_bus(&soc->i2c, 6),
                                       "pca9546", 0x70);
-    at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 0), 0x50, 64 * KiB);
-    at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 1), 0x51, 64 * KiB);
-    at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 2), 0x50, 64 * KiB);
-    at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 3), 0x51, 64 * KiB);
+    at24c_eeprom_init(o, pca954x_i2c_get_bus(i2c_mux, 0), 0x50, 64 * KiB);
+    at24c_eeprom_init(o, pca954x_i2c_get_bus(i2c_mux, 1), 0x51, 64 * KiB);
+    at24c_eeprom_init(o, pca954x_i2c_get_bus(i2c_mux, 2), 0x50, 64 * KiB);
+    at24c_eeprom_init(o, pca954x_i2c_get_bus(i2c_mux, 3), 0x51, 64 * KiB);
 
     aspeed_create_pca9552(OBJECT(bmc), soc, 7, 0x30);
     aspeed_create_pca9552(OBJECT(bmc), soc, 7, 0x31);
@@ -138,8 +138,8 @@ static void rainier_bmc_i2c_init(AspeedMachineState *bmc)
     i2c_slave_create_simple(o, "max31785",
                             aspeed_i2c_get_bus(&soc->i2c, 7),
                             "max31785", 0x52);
-    at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 7), 0x50, 64 * KiB);
-    at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 7), 0x51, 64 * KiB);
+    at24c_eeprom_init(o, aspeed_i2c_get_bus(&soc->i2c, 7), 0x50, 64 * KiB);
+    at24c_eeprom_init(o, aspeed_i2c_get_bus(&soc->i2c, 7), 0x51, 64 * KiB);
 
     i2c_slave_create_simple(o, "tmp105[*]",
                             aspeed_i2c_get_bus(&soc->i2c, 8),
@@ -147,9 +147,9 @@ static void rainier_bmc_i2c_init(AspeedMachineState *bmc)
     i2c_slave_create_simple(o, "tmp105[*]",
                             aspeed_i2c_get_bus(&soc->i2c, 8),
                             TYPE_TMP105, 0x4a);
-    at24c_eeprom_init_rom(aspeed_i2c_get_bus(&soc->i2c, 8), 0x50,
+    at24c_eeprom_init_rom(o, aspeed_i2c_get_bus(&soc->i2c, 8), 0x50,
                           64 * KiB, rainier_bb_fruid, rainier_bb_fruid_len);
-    at24c_eeprom_init_rom(aspeed_i2c_get_bus(&soc->i2c, 8), 0x51,
+    at24c_eeprom_init_rom(o, aspeed_i2c_get_bus(&soc->i2c, 8), 0x51,
                           64 * KiB, rainier_bmc_fruid, rainier_bmc_fruid_len);
     aspeed_create_pca9552(OBJECT(bmc), soc, 8, 0x60);
     aspeed_create_pca9552(OBJECT(bmc), soc, 8, 0x61);
@@ -163,7 +163,7 @@ static void rainier_bmc_i2c_init(AspeedMachineState *bmc)
     i2c_slave_create_simple(o, "tmp423[*]",
                             aspeed_i2c_get_bus(&soc->i2c, 9),
                             "tmp423", 0x4d);
-    at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 9), 0x50, 128 * KiB);
+    at24c_eeprom_init(o, aspeed_i2c_get_bus(&soc->i2c, 9), 0x50, 128 * KiB);
 
     i2c_slave_create_simple(o, "tmp423[*]",
                             aspeed_i2c_get_bus(&soc->i2c, 10),
@@ -171,7 +171,7 @@ static void rainier_bmc_i2c_init(AspeedMachineState *bmc)
     i2c_slave_create_simple(o, "tmp423[*]",
                             aspeed_i2c_get_bus(&soc->i2c, 10),
                             "tmp423", 0x4d);
-    at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 10), 0x50, 128 * KiB);
+    at24c_eeprom_init(o, aspeed_i2c_get_bus(&soc->i2c, 10), 0x50, 128 * KiB);
 
     i2c_slave_create_simple(o, "tmp105[*]",
                             aspeed_i2c_get_bus(&soc->i2c, 11),
@@ -182,18 +182,18 @@ static void rainier_bmc_i2c_init(AspeedMachineState *bmc)
     i2c_mux = i2c_slave_create_simple(o, "i2c-mux[*]",
                                       aspeed_i2c_get_bus(&soc->i2c, 11),
                                       "pca9546", 0x70);
-    at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 0), 0x50, 64 * KiB);
-    at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 1), 0x51, 64 * KiB);
+    at24c_eeprom_init(o, pca954x_i2c_get_bus(i2c_mux, 0), 0x50, 64 * KiB);
+    at24c_eeprom_init(o, pca954x_i2c_get_bus(i2c_mux, 1), 0x51, 64 * KiB);
     aspeed_create_pca9552(OBJECT(bmc), soc, 11, 0x60);
 
 
-    at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 13), 0x50, 64 * KiB);
+    at24c_eeprom_init(o, aspeed_i2c_get_bus(&soc->i2c, 13), 0x50, 64 * KiB);
     aspeed_create_pca9552(OBJECT(bmc), soc, 13, 0x60);
 
-    at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 14), 0x50, 64 * KiB);
+    at24c_eeprom_init(o, aspeed_i2c_get_bus(&soc->i2c, 14), 0x50, 64 * KiB);
     aspeed_create_pca9552(OBJECT(bmc), soc, 14, 0x60);
 
-    at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 15), 0x50, 64 * KiB);
+    at24c_eeprom_init(o, aspeed_i2c_get_bus(&soc->i2c, 15), 0x50, 64 * KiB);
     aspeed_create_pca9552(OBJECT(bmc), soc, 15, 0x60);
 }
 
diff --git a/hw/arm/npcm7xx_boards.c b/hw/arm/npcm7xx_boards.c
index 778ef0f232..1862d0d007 100644
--- a/hw/arm/npcm7xx_boards.c
+++ b/hw/arm/npcm7xx_boards.c
@@ -248,8 +248,8 @@ static void quanta_gsj_i2c_init(Object *parent, NPCM7xxState *soc)
     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);
+    at24c_eeprom_init(parent, npcm7xx_i2c_get_bus(soc, 9), 0x55, 8192);
+    at24c_eeprom_init(parent, npcm7xx_i2c_get_bus(soc, 10), 0x55, 8192);
 
     /*
      * i2c-11:
@@ -363,7 +363,7 @@ static void kudo_bmc_i2c_init(Object *parent, NPCM7xxState *soc)
     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 */
+    at24c_eeprom_init(parent, npcm7xx_i2c_get_bus(soc, 4), 0x50, 8192); /* mbfru */
 
     i2c_mux = i2c_slave_create_simple(parent, "pca9548[*]",
                                       npcm7xx_i2c_get_bus(soc, 13),
@@ -379,7 +379,7 @@ static void kudo_bmc_i2c_init(Object *parent, NPCM7xxState *soc)
     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 */
+    at24c_eeprom_init(parent, npcm7xx_i2c_get_bus(soc, 14), 0x55, 8192); /* bmcfru */
 
     /* TODO: Add remaining i2c devices. */
 }
diff --git a/hw/nvram/eeprom_at24c.c b/hw/nvram/eeprom_at24c.c
index b6d314447c..036955feee 100644
--- a/hw/nvram/eeprom_at24c.c
+++ b/hw/nvram/eeprom_at24c.c
@@ -138,17 +138,19 @@ int at24c_eeprom_send(I2CSlave *s, uint8_t data)
     return 0;
 }
 
-I2CSlave *at24c_eeprom_init(I2CBus *bus, uint8_t address, uint32_t rom_size)
+I2CSlave *at24c_eeprom_init(Object *parent, I2CBus *bus, uint8_t address,
+                            uint32_t rom_size)
 {
-    return at24c_eeprom_init_rom(bus, address, rom_size, NULL, 0);
+    return at24c_eeprom_init_rom(parent, bus, address, rom_size, NULL, 0);
 }
 
-I2CSlave *at24c_eeprom_init_rom(I2CBus *bus, uint8_t address, uint32_t rom_size,
+I2CSlave *at24c_eeprom_init_rom(Object *parent, I2CBus *bus, uint8_t address,
+                                uint32_t rom_size,
                                 const uint8_t *init_rom, uint32_t init_rom_size)
 {
     EEPROMState *s;
 
-    s = AT24C_EE(i2c_slave_new_orphan(TYPE_AT24C_EE, address));
+    s = AT24C_EE(i2c_slave_new(parent, "eeprom[*]", TYPE_AT24C_EE, address));
 
     qdev_prop_set_uint32(DEVICE(s), "rom-size", rom_size);
 
@@ -156,7 +158,7 @@ I2CSlave *at24c_eeprom_init_rom(I2CBus *bus, uint8_t address, uint32_t rom_size,
     s->init_rom = init_rom;
     s->init_rom_size = init_rom_size;
 
-    i2c_slave_realize_and_unref(I2C_SLAVE(s), bus, &error_abort);
+    qdev_realize(DEVICE(s), BUS(bus), &error_abort);
 
     return I2C_SLAVE(s);
 }
diff --git a/include/hw/nvram/eeprom_at24c.h b/include/hw/nvram/eeprom_at24c.h
index acb9857b2a..6686c7ff46 100644
--- a/include/hw/nvram/eeprom_at24c.h
+++ b/include/hw/nvram/eeprom_at24c.h
@@ -18,7 +18,8 @@
  * Create the device state structure, initialize it, put it on the specified
  * @bus, and drop the reference to it (the device is realized).
  */
-I2CSlave *at24c_eeprom_init(I2CBus *bus, uint8_t address, uint32_t rom_size);
+I2CSlave *at24c_eeprom_init(Object *parent, I2CBus *bus, uint8_t address,
+                            uint32_t rom_size);
 
 
 /*
@@ -33,7 +34,8 @@ I2CSlave *at24c_eeprom_init(I2CBus *bus, uint8_t address, uint32_t rom_size);
  * @bus, and drop the reference to it (the device is realized). Copies the data
  * from @init_rom to the beginning of the EEPROM memory buffer.
  */
-I2CSlave *at24c_eeprom_init_rom(I2CBus *bus, uint8_t address, uint32_t rom_size,
+I2CSlave *at24c_eeprom_init_rom(Object *parent, I2CBus *bus, uint8_t address,
+                                uint32_t rom_size,
                                 const uint8_t *init_rom, uint32_t init_rom_size);
 
 #endif
-- 
2.47.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.