Skip to contentSkip to conversation

hw/pci-host/articia: Add variable for common type cast

PATCH In review BALATON Zoltan 2 participants 3 messages Oct 25, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/pci-host/articia: Add variable for common type cast

We need the device casted to OBJECT often enough in realize to store it in a local variable that also makes function calls more readable.

---
Based-on: <[email protected]>

hw/pci-host/articia.c | 14 +++++++-------

 1 file changed, 7 insertions(+), 7 deletions(-)
hw/pci-host/articia.c +7 -7
index 761e89bc8f..56fe3b6953 100644
@@ -174,24 +174,24 @@ static void articia_realize(DeviceState *dev, Error **errp)
 {
     ArticiaState *s = ARTICIA(dev);
     PCIHostState *h = PCI_HOST_BRIDGE(dev);
+    Object *o = OBJECT(dev);
     MemoryRegion *mr;
     PCIDevice *pdev;
 
     bitbang_i2c_init(&s->smbus, i2c_init_bus(dev, "smbus"));
-    memory_region_init_io(&s->gpio_reg, OBJECT(s), &articia_gpio_ops, s,
+    memory_region_init_io(&s->gpio_reg, o, &articia_gpio_ops, s,
                           TYPE_ARTICIA, 4);
 
-    memory_region_init(&s->mem, OBJECT(dev), "pci-mem", UINT64_MAX);
-    memory_region_init(&s->io, OBJECT(dev), "pci-io", 0xc00000);
-    memory_region_init_io(&s->reg, OBJECT(s), &articia_reg_ops, s,
+    memory_region_init(&s->mem, o, "pci-mem", UINT64_MAX);
+    memory_region_init(&s->io, o, "pci-io", 0xc00000);
+    memory_region_init_io(&s->reg, o, &articia_reg_ops, s,
                           TYPE_ARTICIA, 0x1000000);
     memory_region_add_subregion_overlap(&s->reg, 0, &s->io, 1);
     mr = g_new(MemoryRegion, 1);
-    memory_region_init_alias(mr, OBJECT(dev), "pci-mem-low", &s->mem,
-                             0, PCI_LOW_SIZE);
+    memory_region_init_alias(mr, o, "pci-mem-low", &s->mem, 0, PCI_LOW_SIZE);
     memory_region_add_subregion(get_system_memory(), PCI_LOW_ADDR, mr);
     mr = g_new(MemoryRegion, 1);
-    memory_region_init_alias(mr, OBJECT(dev), "pci-mem-high", &s->mem,
+    memory_region_init_alias(mr, o, "pci-mem-high", &s->mem,
                              PCI_HIGH_ADDR, PCI_HIGH_SIZE);
     memory_region_add_subregion(get_system_memory(), PCI_HIGH_ADDR, mr);
 
Signature · 1 line
2.41.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 15 lines · BALATON Zoltan

We need the device casted to OBJECT often enough in realize to store it in a local variable that also makes function calls more readable.

---
Based-on: <[email protected]>

hw/pci-host/articia.c | 14 +++++++-------

  1 file changed, 7 insertions(+), 7 deletions(-)
hw/pci-host/articia.c +0 -0
index 761e89bc8f..56fe3b6953 100644

hw/pci-host/articia.c static void articia_realize(DeviceState *dev, Error **errp) · line 177

Quoted 4 lines
hw/pci-host/articia.c +1 -0
@@ -174,24 +174,24 @@ static void articia_realize(DeviceState *dev, Error **errp)
  {
      ArticiaState *s = ARTICIA(dev);
      PCIHostState *h = PCI_HOST_BRIDGE(dev);
+    Object *o = OBJECT(dev);

Preferably "obj".

#2 lore raw
Quoted 11 lines · Philippe Mathieu-Daudé
Quoted 10 lines · BALATON Zoltan

We need the device casted to OBJECT often enough in realize to store it in a local variable that also makes function calls more readable.

---
Based-on: <[email protected]>

hw/pci-host/articia.c | 14 +++++++-------

  1 file changed, 7 insertions(+), 7 deletions(-)
Quoted 12 lines

hw/pci-host/articia.c static void articia_realize(DeviceState *dev, Error · line 178

Quoted 10 lines
hw/pci-host/articia.c +1 -0
index 761e89bc8f..56fe3b6953 100644
@@ -174,24 +174,24 @@ static void articia_realize(DeviceState *dev, Error 
 **errp)
  {
      ArticiaState *s = ARTICIA(dev);
      PCIHostState *h = PCI_HOST_BRIDGE(dev);
+    Object *o = OBJECT(dev);

Preferably "obj".

Since you said preferably I take that as personal preference and leave it as it is :-) I prefer shorter names for these to match s and h and to have a chance to fit in the 80 char limit with long_snake_case_function_names.

Quoted 1 line

I hope I can still keep your R-b.
Thanks,
BALATON Zoltan