From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Martin Kletzander" <mkletzan@redhat.com>,
"Daniel P . Berrangé" <berrange@redhat.com>
Subject: [PULL 06/12] hw/audio: Simplify hda audio init
Date: Fri, 22 Sep 2023 11:31:19 +0200 [thread overview]
Message-ID: <20230922093126.264016-7-pbonzini@redhat.com> (raw)
In-Reply-To: <20230922093126.264016-1-pbonzini@redhat.com>
From: Martin Kletzander <mkletzan@redhat.com>
No return values are used anywhere, so switch the functions to be void
and add support for error reporting using errp for use in next patches.
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <cd1df4ad2a6fae969c4a02a77955c4a8c0d430b6.1650874791.git.mkletzan@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
hw/audio/hda-codec.c | 32 ++++++++++++++++++--------------
hw/audio/intel-hda.c | 4 +---
hw/audio/intel-hda.h | 2 +-
3 files changed, 20 insertions(+), 18 deletions(-)
diff --git a/hw/audio/hda-codec.c b/hw/audio/hda-codec.c
index c51d8ba6177..a26048cf15e 100644
--- a/hw/audio/hda-codec.c
+++ b/hw/audio/hda-codec.c
@@ -675,7 +675,9 @@ static void hda_audio_stream(HDACodecDevice *hda, uint32_t stnr, bool running, b
}
}
-static int hda_audio_init(HDACodecDevice *hda, const struct desc_codec *desc)
+static void hda_audio_init(HDACodecDevice *hda,
+ const struct desc_codec *desc,
+ Error **errp)
{
HDAAudioState *a = HDA_AUDIO(hda);
HDAAudioStream *st;
@@ -718,7 +720,6 @@ static int hda_audio_init(HDACodecDevice *hda, const struct desc_codec *desc)
break;
}
}
- return 0;
}
static void hda_audio_exit(HDACodecDevice *hda)
@@ -848,37 +849,40 @@ static Property hda_audio_properties[] = {
DEFINE_PROP_END_OF_LIST(),
};
-static int hda_audio_init_output(HDACodecDevice *hda)
+static void hda_audio_init_output(HDACodecDevice *hda, Error **errp)
{
HDAAudioState *a = HDA_AUDIO(hda);
+ const struct desc_codec *desc = &output_nomixemu;
if (!a->mixer) {
- return hda_audio_init(hda, &output_nomixemu);
- } else {
- return hda_audio_init(hda, &output_mixemu);
+ desc = &output_mixemu;
}
+
+ hda_audio_init(hda, desc, errp);
}
-static int hda_audio_init_duplex(HDACodecDevice *hda)
+static void hda_audio_init_duplex(HDACodecDevice *hda, Error **errp)
{
HDAAudioState *a = HDA_AUDIO(hda);
+ const struct desc_codec *desc = &duplex_nomixemu;
if (!a->mixer) {
- return hda_audio_init(hda, &duplex_nomixemu);
- } else {
- return hda_audio_init(hda, &duplex_mixemu);
+ desc = &duplex_mixemu;
}
+
+ hda_audio_init(hda, desc, errp);
}
-static int hda_audio_init_micro(HDACodecDevice *hda)
+static void hda_audio_init_micro(HDACodecDevice *hda, Error **errp)
{
HDAAudioState *a = HDA_AUDIO(hda);
+ const struct desc_codec *desc = µ_nomixemu;
if (!a->mixer) {
- return hda_audio_init(hda, µ_nomixemu);
- } else {
- return hda_audio_init(hda, µ_mixemu);
+ desc = µ_mixemu;
}
+
+ hda_audio_init(hda, desc, errp);
}
static void hda_audio_base_class_init(ObjectClass *klass, void *data)
diff --git a/hw/audio/intel-hda.c b/hw/audio/intel-hda.c
index b9ed231fe84..78ff9f9a680 100644
--- a/hw/audio/intel-hda.c
+++ b/hw/audio/intel-hda.c
@@ -71,9 +71,7 @@ static void hda_codec_dev_realize(DeviceState *qdev, Error **errp)
return;
}
bus->next_cad = dev->cad + 1;
- if (cdc->init(dev) != 0) {
- error_setg(errp, "HDA audio init failed");
- }
+ cdc->init(dev, errp);
}
static void hda_codec_dev_unrealize(DeviceState *qdev)
diff --git a/hw/audio/intel-hda.h b/hw/audio/intel-hda.h
index f78c1833e34..8d710eee5d6 100644
--- a/hw/audio/intel-hda.h
+++ b/hw/audio/intel-hda.h
@@ -31,7 +31,7 @@ struct HDACodecBus {
struct HDACodecDeviceClass {
DeviceClass parent_class;
- int (*init)(HDACodecDevice *dev);
+ void (*init)(HDACodecDevice *dev, Error **errp);
void (*exit)(HDACodecDevice *dev);
void (*command)(HDACodecDevice *dev, uint32_t nid, uint32_t data);
void (*stream)(HDACodecDevice *dev, uint32_t stnr, bool running, bool output);
--
2.41.0
next prev parent reply other threads:[~2023-09-22 9:33 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-22 9:31 [PULL 00/12] Audio, i386 patches for 2022-09-22 Paolo Bonzini
2023-09-22 9:31 ` [PULL 01/12] target/i386: enumerate bit 56 of MSR_IA32_VMX_BASIC Paolo Bonzini
2023-09-22 9:31 ` [PULL 02/12] target/i386: Export GDS_NO bit to guests Paolo Bonzini
2023-09-22 9:31 ` [PULL 03/12] qemu/timer: Add host ticks function for RISC-V Paolo Bonzini
2023-09-22 9:31 ` [PULL 04/12] audio: remove QEMU_AUDIO_* and -audio-help support Paolo Bonzini
2023-09-22 9:31 ` [PULL 05/12] hw/input/tsc210x: Extract common init code into new function Paolo Bonzini
2023-09-22 9:31 ` Paolo Bonzini [this message]
2023-09-22 9:31 ` [PULL 07/12] hw/audio/lm4549: Add errp error reporting to init function Paolo Bonzini
2023-09-22 9:31 ` [PULL 08/12] hw/display/xlnx_dp.c: Add audiodev property Paolo Bonzini
2023-09-22 9:31 ` [PULL 09/12] tests/qtest: Specify audiodev= and -audiodev Paolo Bonzini
2023-09-22 9:31 ` [PULL 10/12] audio/spiceaudio: Fail initialisation when not using spice Paolo Bonzini
2023-09-22 9:31 ` [PULL 11/12] ui/vnc: Require audiodev= to enable audio Paolo Bonzini
2023-09-22 9:31 ` [PULL 12/12] audio: Require AudioState in AUD_add_capture Paolo Bonzini
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=20230922093126.264016-7-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=berrange@redhat.com \
--cc=mkletzan@redhat.com \
--cc=qemu-devel@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).