On 7/16/26 18:56, [email protected] wrote:
On 10 Jul 2026, at 17:25, Markus Armbruster wrote:
Emmanuel Blot <[email protected]> writes:
Slaves created with i2c_slave_create_simple() were left unparented and
showed up under /machine/unattached with no stable QOM path. Add each
slave as a QOM child of its bus, named after its I2C address, so it has
a deterministic and addressable QOM path.
index 54f6bdca88..0bbce45d48 100644
--- a/hw/i2c/core.c
+++ b/hw/i2c/core.c
@@ -382,6 +382,9 @@ I2CSlave *i2c_slave_create_simple(I2CBus *bus, const char
*name, uint8_t addr)
{
I2CSlave *dev = i2c_slave_new(name, addr);
+ g_autofree char *childname = g_strdup_printf("0x%02x", addr);
Is the hex address a satisfactory child name?
Addresses are unique on a I2C bus. They are identified on the bus with their
unique address, which is usually expressed as an hex integer in the datasheets.
It makes the QOM path easy to interpret and use to access an I2C device, but I
do not have a strong opinion on how to name them.
I tend to agree. Oarenting the device to the board seems to be
a preferred solution :
See :
Call to clean up QOM onboard devices lacking a parent
https://lore.kernel.org/qemu-devel/[email protected]/
and
[RFC PATCH 000/134] qom: Make composition-tree parenting mandatory
https://lore.kernel.org/qemu-devel/[email protected]/
Thanks,
C.