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
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>
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
© 2016 - 2025 Red Hat, Inc.