* [PATCH 0/5] hw/audio: Cleanups around QOM style
@ 2023-02-20 13:18 Philippe Mathieu-Daudé
2023-02-20 13:18 ` [PATCH 1/5] hw/audio/hda-codec: Avoid forward-declaring HDAAudioState Philippe Mathieu-Daudé
` (4 more replies)
0 siblings, 5 replies; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-02-20 13:18 UTC (permalink / raw)
To: qemu-devel
Cc: Eduardo Habkost, qemu-ppc, Paolo Bonzini, Michael S. Tsirkin,
Hervé Poussineau, Richard Henderson, Markus Armbruster,
Gerd Hoffmann, Philippe Mathieu-Daudé
- Use QOM's OBJECT_DECLARE*TYPE() to declare typedef / macros
- Use QOM cast macros instead of container_of()
- Open-code QDev helpers used few times
Philippe Mathieu-Daudé (5):
hw/audio/hda-codec: Avoid forward-declaring HDAAudioState
hw/audio/es1370: Avoid forward-declaring ES1370State
hw/audio/es1370: Replace container_of() by ES1370() QOM cast macro
hw/audio/ac97: Replace container_of() by AC97() QOM cast macro
hw/audio/pcspk: Open-code pcspk_init()
hw/audio/ac97.c | 2 +-
hw/audio/es1370.c | 10 +++++-----
hw/audio/hda-codec.c | 7 +++----
hw/i386/pc.c | 3 ++-
hw/isa/i82378.c | 5 ++++-
hw/mips/jazz.c | 5 ++++-
include/hw/audio/pcspk.h | 10 ----------
7 files changed, 19 insertions(+), 23 deletions(-)
--
2.38.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/5] hw/audio/hda-codec: Avoid forward-declaring HDAAudioState
2023-02-20 13:18 [PATCH 0/5] hw/audio: Cleanups around QOM style Philippe Mathieu-Daudé
@ 2023-02-20 13:18 ` 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é
` (3 subsequent siblings)
4 siblings, 1 reply; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-02-20 13:18 UTC (permalink / raw)
To: qemu-devel
Cc: Eduardo Habkost, qemu-ppc, Paolo Bonzini, Michael S. Tsirkin,
Hervé Poussineau, Richard Henderson, Markus Armbruster,
Gerd Hoffmann, Philippe Mathieu-Daudé
To avoid forward-declaring HDAAudioState, declare HDA_AUDIO QOM
definitions before its use in the HDAAudioStream structure.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/audio/hda-codec.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/hw/audio/hda-codec.c b/hw/audio/hda-codec.c
index feb8f9e2bb..c51d8ba617 100644
--- a/hw/audio/hda-codec.c
+++ b/hw/audio/hda-codec.c
@@ -145,7 +145,9 @@ static const char *fmt2name[] = {
[ AUDIO_FORMAT_S32 ] = "PCM-S32",
};
-typedef struct HDAAudioState HDAAudioState;
+#define TYPE_HDA_AUDIO "hda-audio"
+OBJECT_DECLARE_SIMPLE_TYPE(HDAAudioState, HDA_AUDIO)
+
typedef struct HDAAudioStream HDAAudioStream;
struct HDAAudioStream {
@@ -171,9 +173,6 @@ struct HDAAudioStream {
int64_t buft_start;
};
-#define TYPE_HDA_AUDIO "hda-audio"
-OBJECT_DECLARE_SIMPLE_TYPE(HDAAudioState, HDA_AUDIO)
-
struct HDAAudioState {
HDACodecDevice hda;
const char *name;
--
2.38.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/5] hw/audio/es1370: Avoid forward-declaring ES1370State
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 13:18 ` 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é
` (2 subsequent siblings)
4 siblings, 1 reply; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-02-20 13:18 UTC (permalink / raw)
To: qemu-devel
Cc: Eduardo Habkost, qemu-ppc, Paolo Bonzini, Michael S. Tsirkin,
Hervé Poussineau, Richard Henderson, Markus Armbruster,
Gerd Hoffmann, Philippe Mathieu-Daudé
To avoid forward-declaring ES1370State, declare ES1370 QOM
definitions before its use in the chan_bits structure.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/audio/es1370.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/hw/audio/es1370.c b/hw/audio/es1370.c
index 54cc19a637..ea76c9a734 100644
--- a/hw/audio/es1370.c
+++ b/hw/audio/es1370.c
@@ -256,6 +256,9 @@ static void print_sctl (uint32_t val)
#define lwarn(...)
#endif
+#define TYPE_ES1370 "ES1370"
+OBJECT_DECLARE_SIMPLE_TYPE(ES1370State, ES1370)
+
struct chan {
uint32_t shift;
uint32_t leftover;
@@ -278,7 +281,6 @@ struct ES1370State {
uint32_t codec;
uint32_t sctl;
};
-typedef struct ES1370State ES1370State;
struct chan_bits {
uint32_t ctl_en;
@@ -292,9 +294,6 @@ struct chan_bits {
uint32_t *old_freq, uint32_t *new_freq);
};
-#define TYPE_ES1370 "ES1370"
-OBJECT_DECLARE_SIMPLE_TYPE(ES1370State, ES1370)
-
static void es1370_dac1_calc_freq (ES1370State *s, uint32_t ctl,
uint32_t *old_freq, uint32_t *new_freq);
static void es1370_dac2_and_adc_calc_freq (ES1370State *s, uint32_t ctl,
--
2.38.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 3/5] hw/audio/es1370: Replace container_of() by ES1370() QOM cast macro
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 13:18 ` [PATCH 2/5] hw/audio/es1370: Avoid forward-declaring ES1370State Philippe Mathieu-Daudé
@ 2023-02-20 13:18 ` 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 13:18 ` [PATCH 5/5] hw/audio/pcspk: Open-code pcspk_init() Philippe Mathieu-Daudé
4 siblings, 1 reply; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-02-20 13:18 UTC (permalink / raw)
To: qemu-devel
Cc: Eduardo Habkost, qemu-ppc, Paolo Bonzini, Michael S. Tsirkin,
Hervé Poussineau, Richard Henderson, Markus Armbruster,
Gerd Hoffmann, Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/audio/es1370.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/hw/audio/es1370.c b/hw/audio/es1370.c
index ea76c9a734..4f738a0ad8 100644
--- a/hw/audio/es1370.c
+++ b/hw/audio/es1370.c
@@ -843,7 +843,8 @@ static const VMStateDescription vmstate_es1370 = {
static void es1370_on_reset(DeviceState *dev)
{
- ES1370State *s = container_of(dev, ES1370State, dev.qdev);
+ ES1370State *s = ES1370(dev);
+
es1370_reset (s);
}
--
2.38.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 4/5] hw/audio/ac97: Replace container_of() by AC97() QOM cast macro
2023-02-20 13:18 [PATCH 0/5] hw/audio: Cleanups around QOM style Philippe Mathieu-Daudé
` (2 preceding siblings ...)
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 13:18 ` Philippe Mathieu-Daudé
2023-02-20 19:06 ` Richard Henderson
2023-02-20 13:18 ` [PATCH 5/5] hw/audio/pcspk: Open-code pcspk_init() Philippe Mathieu-Daudé
4 siblings, 1 reply; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-02-20 13:18 UTC (permalink / raw)
To: qemu-devel
Cc: Eduardo Habkost, qemu-ppc, Paolo Bonzini, Michael S. Tsirkin,
Hervé Poussineau, Richard Henderson, Markus Armbruster,
Gerd Hoffmann, Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/audio/ac97.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/audio/ac97.c b/hw/audio/ac97.c
index 364cdfa733..b3a45bb49f 100644
--- a/hw/audio/ac97.c
+++ b/hw/audio/ac97.c
@@ -1295,7 +1295,7 @@ static const MemoryRegionOps ac97_io_nabm_ops = {
static void ac97_on_reset(DeviceState *dev)
{
- AC97LinkState *s = container_of(dev, AC97LinkState, dev.qdev);
+ AC97LinkState *s = AC97(dev);
reset_bm_regs(s, &s->bm_regs[0]);
reset_bm_regs(s, &s->bm_regs[1]);
--
2.38.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 5/5] hw/audio/pcspk: Open-code pcspk_init()
2023-02-20 13:18 [PATCH 0/5] hw/audio: Cleanups around QOM style Philippe Mathieu-Daudé
` (3 preceding siblings ...)
2023-02-20 13:18 ` [PATCH 4/5] hw/audio/ac97: Replace container_of() by AC97() " Philippe Mathieu-Daudé
@ 2023-02-20 13:18 ` Philippe Mathieu-Daudé
4 siblings, 0 replies; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-02-20 13:18 UTC (permalink / raw)
To: qemu-devel
Cc: Eduardo Habkost, qemu-ppc, Paolo Bonzini, Michael S. Tsirkin,
Hervé Poussineau, Richard Henderson, Markus Armbruster,
Gerd Hoffmann, Philippe Mathieu-Daudé,
Marcel Apfelbaum, Aleksandar Rikalo
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
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 1/5] hw/audio/hda-codec: Avoid forward-declaring HDAAudioState
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
0 siblings, 0 replies; 10+ messages in thread
From: Richard Henderson @ 2023-02-20 18:59 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Eduardo Habkost, qemu-ppc, Paolo Bonzini, Michael S. Tsirkin,
Hervé Poussineau, Markus Armbruster, Gerd Hoffmann
On 2/20/23 03:18, Philippe Mathieu-Daudé wrote:
> To avoid forward-declaring HDAAudioState, declare HDA_AUDIO QOM
> definitions before its use in the HDAAudioStream structure.
>
> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> ---
> hw/audio/hda-codec.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/5] hw/audio/es1370: Avoid forward-declaring ES1370State
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
0 siblings, 0 replies; 10+ messages in thread
From: Richard Henderson @ 2023-02-20 19:00 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Eduardo Habkost, qemu-ppc, Paolo Bonzini, Michael S. Tsirkin,
Hervé Poussineau, Markus Armbruster, Gerd Hoffmann
On 2/20/23 03:18, Philippe Mathieu-Daudé wrote:
> To avoid forward-declaring ES1370State, declare ES1370 QOM
> definitions before its use in the chan_bits structure.
>
> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> ---
> hw/audio/es1370.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 3/5] hw/audio/es1370: Replace container_of() by ES1370() QOM cast macro
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
0 siblings, 0 replies; 10+ messages in thread
From: Richard Henderson @ 2023-02-20 19:05 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Eduardo Habkost, qemu-ppc, Paolo Bonzini, Michael S. Tsirkin,
Hervé Poussineau, Markus Armbruster, Gerd Hoffmann
On 2/20/23 03:18, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> ---
> hw/audio/es1370.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 4/5] hw/audio/ac97: Replace container_of() by AC97() QOM cast macro
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
0 siblings, 0 replies; 10+ messages in thread
From: Richard Henderson @ 2023-02-20 19:06 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Eduardo Habkost, qemu-ppc, Paolo Bonzini, Michael S. Tsirkin,
Hervé Poussineau, Markus Armbruster, Gerd Hoffmann
On 2/20/23 03:18, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> ---
> hw/audio/ac97.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2023-02-20 19:07 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH 5/5] hw/audio/pcspk: Open-code pcspk_init() Philippe Mathieu-Daudé
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.