aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorMartin Kletzander <mkletzan@redhat.com>2022-04-25 10:21:46 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2023-09-22 16:30:07 +0200
commitb7639b7dd05de6d4f5ac2a30bb4a7a789286992f (patch)
tree964584a4858dd29a76ffbd4052ee494d938c3a6a /hw
parent38e476e88e7d5294c194d36d33e12f3d936a7e6a (diff)
hw/audio: Simplify hda audio init
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>
Diffstat (limited to 'hw')
-rw-r--r--hw/audio/hda-codec.c32
-rw-r--r--hw/audio/intel-hda.c4
-rw-r--r--hw/audio/intel-hda.h2
3 files changed, 20 insertions, 18 deletions
diff --git a/hw/audio/hda-codec.c b/hw/audio/hda-codec.c
index c51d8ba617..a26048cf15 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 = &micro_nomixemu;
if (!a->mixer) {
- return hda_audio_init(hda, &micro_nomixemu);
- } else {
- return hda_audio_init(hda, &micro_mixemu);
+ desc = &micro_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 b9ed231fe8..78ff9f9a68 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 f78c1833e3..8d710eee5d 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);