diff mbox series

ppc/pegasos2: Improve readability of VIA south bridge creation

Message ID 20230117214545.5E191746369@zero.eik.bme.hu
State New
Headers show
Series ppc/pegasos2: Improve readability of VIA south bridge creation | expand

Commit Message

BALATON Zoltan Jan. 17, 2023, 9:36 p.m. UTC
Slightly improve readability of creating the south btidge by cnamging
type of a local variable to avoid some casts within function arguments
which makes some lines shorter and easier to read.
Also remove an unneded line break.

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
---
 hw/ppc/pegasos2.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

Comments

BALATON Zoltan Jan. 17, 2023, 9:57 p.m. UTC | #1
On Tue, 17 Jan 2023, BALATON Zoltan wrote:
> Slightly improve readability of creating the south btidge by cnamging

Still left a typo in "bridge" above...
This is alternative, inspired by Phil's patches, maybe I'd also need to 
add Inspired-by: tag.

> type of a local variable to avoid some casts within function arguments
> which makes some lines shorter and easier to read.
> Also remove an unneded line break.

and "unneeded" here. I wait what Phil says then correct these if needed.

Regards,
BALATON Zoltan

> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
> ---
> hw/ppc/pegasos2.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/hw/ppc/pegasos2.c b/hw/ppc/pegasos2.c
> index f46d4bf51d..1a13632ba6 100644
> --- a/hw/ppc/pegasos2.c
> +++ b/hw/ppc/pegasos2.c
> @@ -102,7 +102,8 @@ static void pegasos2_init(MachineState *machine)
>     CPUPPCState *env;
>     MemoryRegion *rom = g_new(MemoryRegion, 1);
>     PCIBus *pci_bus;
> -    PCIDevice *dev, *via;
> +    Object *via;
> +    PCIDevice *dev;
>     I2CBus *i2c_bus;
>     const char *fwname = machine->firmware ?: PROM_FILENAME;
>     char *filename;
> @@ -159,19 +160,18 @@ static void pegasos2_init(MachineState *machine)
>     pci_bus = mv64361_get_pci_bus(pm->mv, 1);
>
>     /* VIA VT8231 South Bridge (multifunction PCI device) */
> -    via = pci_create_simple_multifunction(pci_bus, PCI_DEVFN(12, 0), true,
> -                                          TYPE_VT8231_ISA);
> +    via = OBJECT(pci_create_simple_multifunction(pci_bus, PCI_DEVFN(12, 0),
> +                                                 true, TYPE_VT8231_ISA));
>     object_property_add_alias(OBJECT(machine), "rtc-time",
> -                              object_resolve_path_component(OBJECT(via),
> -                                                            "rtc"),
> +                              object_resolve_path_component(via, "rtc"),
>                               "date");
>     qdev_connect_gpio_out(DEVICE(via), 0,
>                           qdev_get_gpio_in_named(pm->mv, "gpp", 31));
>
> -    dev = PCI_DEVICE(object_resolve_path_component(OBJECT(via), "ide"));
> +    dev = PCI_DEVICE(object_resolve_path_component(via, "ide"));
>     pci_ide_create_devs(dev);
>
> -    dev = PCI_DEVICE(object_resolve_path_component(OBJECT(via), "pm"));
> +    dev = PCI_DEVICE(object_resolve_path_component(via, "pm"));
>     i2c_bus = I2C_BUS(qdev_get_child_bus(DEVICE(dev), "i2c"));
>     spd_data = spd_data_generate(DDR, machine->ram_size);
>     smbus_eeprom_init_one(i2c_bus, 0x57, spd_data);
>
Philippe Mathieu-Daudé Jan. 18, 2023, 9:53 a.m. UTC | #2
On 17/1/23 22:57, BALATON Zoltan wrote:
> On Tue, 17 Jan 2023, BALATON Zoltan wrote:
>> Slightly improve readability of creating the south btidge by cnamging
> 
> Still left a typo in "bridge" above...

Also "naming".

> This is alternative, inspired by Phil's patches, maybe I'd also need to 
> add Inspired-by: tag.

Not necessary.

>> type of a local variable to avoid some casts within function arguments
>> which makes some lines shorter and easier to read.
>> Also remove an unneded line break.
> 
> and "unneeded" here. I wait what Phil says then correct these if needed.

Fine by me, so with the typos fixed:

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

>> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
>> ---
>> hw/ppc/pegasos2.c | 14 +++++++-------
>> 1 file changed, 7 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/hw/ppc/pegasos2.c b/hw/ppc/pegasos2.c
index f46d4bf51d..1a13632ba6 100644
--- a/hw/ppc/pegasos2.c
+++ b/hw/ppc/pegasos2.c
@@ -102,7 +102,8 @@  static void pegasos2_init(MachineState *machine)
     CPUPPCState *env;
     MemoryRegion *rom = g_new(MemoryRegion, 1);
     PCIBus *pci_bus;
-    PCIDevice *dev, *via;
+    Object *via;
+    PCIDevice *dev;
     I2CBus *i2c_bus;
     const char *fwname = machine->firmware ?: PROM_FILENAME;
     char *filename;
@@ -159,19 +160,18 @@  static void pegasos2_init(MachineState *machine)
     pci_bus = mv64361_get_pci_bus(pm->mv, 1);
 
     /* VIA VT8231 South Bridge (multifunction PCI device) */
-    via = pci_create_simple_multifunction(pci_bus, PCI_DEVFN(12, 0), true,
-                                          TYPE_VT8231_ISA);
+    via = OBJECT(pci_create_simple_multifunction(pci_bus, PCI_DEVFN(12, 0),
+                                                 true, TYPE_VT8231_ISA));
     object_property_add_alias(OBJECT(machine), "rtc-time",
-                              object_resolve_path_component(OBJECT(via),
-                                                            "rtc"),
+                              object_resolve_path_component(via, "rtc"),
                               "date");
     qdev_connect_gpio_out(DEVICE(via), 0,
                           qdev_get_gpio_in_named(pm->mv, "gpp", 31));
 
-    dev = PCI_DEVICE(object_resolve_path_component(OBJECT(via), "ide"));
+    dev = PCI_DEVICE(object_resolve_path_component(via, "ide"));
     pci_ide_create_devs(dev);
 
-    dev = PCI_DEVICE(object_resolve_path_component(OBJECT(via), "pm"));
+    dev = PCI_DEVICE(object_resolve_path_component(via, "pm"));
     i2c_bus = I2C_BUS(qdev_get_child_bus(DEVICE(dev), "i2c"));
     spd_data = spd_data_generate(DDR, machine->ram_size);
     smbus_eeprom_init_one(i2c_bus, 0x57, spd_data);