From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: qemu-ppc@nongnu.org, "BALATON Zoltan" <balaton@eik.bme.hu>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [PATCH 1/2] hw/ppc/pegasos2: Extract via_i2c_bus() helper
Date: Tue, 17 Jan 2023 21:16:39 +0100 [thread overview]
Message-ID: <20230117201640.88365-2-philmd@linaro.org> (raw)
In-Reply-To: <20230117201640.88365-1-philmd@linaro.org>
Simplify a bit pegasos2_init() by extracting via_i2c_bus().
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/ppc/pegasos2.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/hw/ppc/pegasos2.c b/hw/ppc/pegasos2.c
index f46d4bf51d..ac69aee099 100644
--- a/hw/ppc/pegasos2.c
+++ b/hw/ppc/pegasos2.c
@@ -96,6 +96,14 @@ static void pegasos2_cpu_reset(void *opaque)
}
}
+static I2CBus *via_i2c_bus(PCIDevice *via)
+{
+ PCIDevice *dev;
+
+ dev = PCI_DEVICE(object_resolve_path_component(OBJECT(via), "pm"));
+ return I2C_BUS(qdev_get_child_bus(DEVICE(dev), "i2c"));
+}
+
static void pegasos2_init(MachineState *machine)
{
Pegasos2MachineState *pm = PEGASOS2_MACHINE(machine);
@@ -103,7 +111,6 @@ static void pegasos2_init(MachineState *machine)
MemoryRegion *rom = g_new(MemoryRegion, 1);
PCIBus *pci_bus;
PCIDevice *dev, *via;
- I2CBus *i2c_bus;
const char *fwname = machine->firmware ?: PROM_FILENAME;
char *filename;
int sz;
@@ -171,10 +178,8 @@ static void pegasos2_init(MachineState *machine)
dev = PCI_DEVICE(object_resolve_path_component(OBJECT(via), "ide"));
pci_ide_create_devs(dev);
- dev = PCI_DEVICE(object_resolve_path_component(OBJECT(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);
+ smbus_eeprom_init_one(via_i2c_bus(via), 0x57, spd_data);
/* other PC hardware */
pci_vga_init(pci_bus);
--
2.38.1
next prev parent reply other threads:[~2023-01-17 20:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-17 20:16 [PATCH 0/2] hw/ppc/pegasos2: Extract southbridge creation code to via_vt8231_create Philippe Mathieu-Daudé
2023-01-17 20:16 ` Philippe Mathieu-Daudé [this message]
2023-01-17 20:16 ` [PATCH 2/2] hw/ppc/pegasos2: Extract via_vt8231_create() helper Philippe Mathieu-Daudé
2023-01-17 21:17 ` BALATON Zoltan
2023-01-18 9:51 ` Philippe Mathieu-Daudé
2023-01-18 16:59 ` BALATON Zoltan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230117201640.88365-2-philmd@linaro.org \
--to=philmd@linaro.org \
--cc=balaton@eik.bme.hu \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).