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

BALATON Zoltan posted 1 patch 1 day, 19 hours ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20251025125512.19967597305@zero.eik.bme.hu
Maintainers: BALATON Zoltan <balaton@eik.bme.hu>
hw/pci-host/articia.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
[PATCH] hw/pci-host/articia: Add variable for common type cast
Posted by BALATON Zoltan 1 day, 19 hours ago
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.

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
---
Based-on: <cover.1761346145.git.balaton@eik.bme.hu>

hw/pci-host/articia.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/hw/pci-host/articia.c b/hw/pci-host/articia.c
index 761e89bc8f..56fe3b6953 100644
--- a/hw/pci-host/articia.c
+++ b/hw/pci-host/articia.c
@@ -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);
 
-- 
2.41.3
Re: [PATCH] hw/pci-host/articia: Add variable for common type cast
Posted by Philippe Mathieu-Daudé 1 day, 16 hours ago
On 25/10/25 14:55, BALATON Zoltan wrote:
> 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.
> 
> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
> ---
> Based-on: <cover.1761346145.git.balaton@eik.bme.hu>
> 
> hw/pci-host/articia.c | 14 +++++++-------
>   1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/hw/pci-host/articia.c b/hw/pci-host/articia.c
> index 761e89bc8f..56fe3b6953 100644
> --- a/hw/pci-host/articia.c
> +++ b/hw/pci-host/articia.c
> @@ -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".

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>


Re: [PATCH] hw/pci-host/articia: Add variable for common type cast
Posted by BALATON Zoltan 1 day, 12 hours ago
On Sat, 25 Oct 2025, Philippe Mathieu-Daudé wrote:
> On 25/10/25 14:55, BALATON Zoltan wrote:
>> 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.
>> 
>> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
>> ---
>> Based-on: <cover.1761346145.git.balaton@eik.bme.hu>
>> 
>> hw/pci-host/articia.c | 14 +++++++-------
>>   1 file changed, 7 insertions(+), 7 deletions(-)
>> 
>> diff --git a/hw/pci-host/articia.c b/hw/pci-host/articia.c
>> index 761e89bc8f..56fe3b6953 100644
>> --- a/hw/pci-host/articia.c
>> +++ b/hw/pci-host/articia.c
>> @@ -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.

> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>

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