From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Eduardo Habkost" <eduardo@habkost.net>,
qemu-ppc@nongnu.org, "Paolo Bonzini" <pbonzini@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Hervé Poussineau" <hpoussin@reactos.org>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Markus Armbruster" <armbru@redhat.com>,
"Gerd Hoffmann" <kraxel@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
"Aleksandar Rikalo" <aleksandar.rikalo@syrmia.com>
Subject: [PATCH 5/5] hw/audio/pcspk: Open-code pcspk_init()
Date: Mon, 20 Feb 2023 14:18:37 +0100 [thread overview]
Message-ID: <20230220131837.26292-6-philmd@linaro.org> (raw)
In-Reply-To: <20230220131837.26292-1-philmd@linaro.org>
pcspk_init() is used in 3 places and is 2-lines of code.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/i386/pc.c | 3 ++-
hw/isa/i82378.c | 5 ++++-
hw/mips/jazz.c | 5 ++++-
include/hw/audio/pcspk.h | 10 ----------
4 files changed, 10 insertions(+), 13 deletions(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 6e592bd969..73bd98997f 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1319,7 +1319,8 @@ void pc_basic_device_init(struct PCMachineState *pcms,
/* connect PIT to output control line of the HPET */
qdev_connect_gpio_out(hpet, 0, qdev_get_gpio_in(DEVICE(pit), 0));
}
- pcspk_init(pcms->pcspk, isa_bus, pit);
+ object_property_set_link(OBJECT(pcms->pcspk), "pit", OBJECT(pit), NULL);
+ isa_realize_and_unref(pcms->pcspk, isa_bus, &error_fatal);
}
/* Super I/O */
diff --git a/hw/isa/i82378.c b/hw/isa/i82378.c
index e3322e03bf..f0964cdcd9 100644
--- a/hw/isa/i82378.c
+++ b/hw/isa/i82378.c
@@ -68,6 +68,7 @@ static void i82378_realize(PCIDevice *pci, Error **errp)
uint8_t *pci_conf;
ISABus *isabus;
ISADevice *pit;
+ ISADevice *snd;
pci_conf = pci->config;
pci_set_word(pci_conf + PCI_COMMAND,
@@ -102,7 +103,9 @@ static void i82378_realize(PCIDevice *pci, Error **errp)
pit = i8254_pit_init(isabus, 0x40, 0, NULL);
/* speaker */
- pcspk_init(isa_new(TYPE_PC_SPEAKER), isabus, pit);
+ snd = isa_new(TYPE_PC_SPEAKER);
+ object_property_set_link(OBJECT(snd), "pit", OBJECT(pit), NULL);
+ isa_realize_and_unref(snd, isabus, &error_fatal);
/* 2 82C37 (dma) */
isa_create_simple(isabus, "i82374");
diff --git a/hw/mips/jazz.c b/hw/mips/jazz.c
index 6aefe9a61b..a4e035cd66 100644
--- a/hw/mips/jazz.c
+++ b/hw/mips/jazz.c
@@ -144,6 +144,7 @@ static void mips_jazz_init(MachineState *machine,
SysBusDevice *sysbus;
ISABus *isa_bus;
ISADevice *pit;
+ ISADevice *snd;
DriveInfo *fds[MAX_FD];
MemoryRegion *bios = g_new(MemoryRegion, 1);
MemoryRegion *bios2 = g_new(MemoryRegion, 1);
@@ -252,7 +253,9 @@ static void mips_jazz_init(MachineState *machine,
isa_bus_irqs(isa_bus, i8259);
i8257_dma_init(isa_bus, 0);
pit = i8254_pit_init(isa_bus, 0x40, 0, NULL);
- pcspk_init(isa_new(TYPE_PC_SPEAKER), isa_bus, pit);
+ snd = isa_new(TYPE_PC_SPEAKER);
+ object_property_set_link(OBJECT(snd), "pit", OBJECT(pit), NULL);
+ isa_realize_and_unref(snd, isa_bus, &error_fatal);
/* Video card */
switch (jazz_model) {
diff --git a/include/hw/audio/pcspk.h b/include/hw/audio/pcspk.h
index 9506179587..6be75a6b86 100644
--- a/include/hw/audio/pcspk.h
+++ b/include/hw/audio/pcspk.h
@@ -25,16 +25,6 @@
#ifndef HW_PCSPK_H
#define HW_PCSPK_H
-#include "hw/isa/isa.h"
-#include "hw/qdev-properties.h"
-#include "qapi/error.h"
-
#define TYPE_PC_SPEAKER "isa-pcspk"
-static inline void pcspk_init(ISADevice *isadev, ISABus *bus, ISADevice *pit)
-{
- object_property_set_link(OBJECT(isadev), "pit", OBJECT(pit), NULL);
- isa_realize_and_unref(isadev, bus, &error_fatal);
-}
-
#endif /* HW_PCSPK_H */
--
2.38.1
prev parent reply other threads:[~2023-02-20 13:20 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-20 13:18 [PATCH 0/5] hw/audio: Cleanups around QOM style Philippe Mathieu-Daudé
2023-02-20 13:18 ` [PATCH 1/5] hw/audio/hda-codec: Avoid forward-declaring HDAAudioState Philippe Mathieu-Daudé
2023-02-20 18:59 ` Richard Henderson
2023-02-20 13:18 ` [PATCH 2/5] hw/audio/es1370: Avoid forward-declaring ES1370State Philippe Mathieu-Daudé
2023-02-20 19:00 ` Richard Henderson
2023-02-20 13:18 ` [PATCH 3/5] hw/audio/es1370: Replace container_of() by ES1370() QOM cast macro Philippe Mathieu-Daudé
2023-02-20 19:05 ` Richard Henderson
2023-02-20 13:18 ` [PATCH 4/5] hw/audio/ac97: Replace container_of() by AC97() " Philippe Mathieu-Daudé
2023-02-20 19:06 ` Richard Henderson
2023-02-20 13:18 ` Philippe Mathieu-Daudé [this message]
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=20230220131837.26292-6-philmd@linaro.org \
--to=philmd@linaro.org \
--cc=aleksandar.rikalo@syrmia.com \
--cc=armbru@redhat.com \
--cc=eduardo@habkost.net \
--cc=hpoussin@reactos.org \
--cc=kraxel@redhat.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=richard.henderson@linaro.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).