aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/hda/hda_bind.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2015-02-27 20:44:54 +0100
committerTakashi Iwai <tiwai@suse.de>2015-03-03 11:28:36 +0100
commitbcd96557bd0ab1129fcdde073d5700aed8fcb942 (patch)
tree8f246b3fc0b986ba9d105f632aa7cef485123825 /sound/pci/hda/hda_bind.c
parentALSA: hda - Implement unbind more safely (diff)
downloadlinux-dev-bcd96557bd0ab1129fcdde073d5700aed8fcb942.tar.xz
linux-dev-bcd96557bd0ab1129fcdde073d5700aed8fcb942.zip
ALSA: hda - Build PCMs and controls at codec driver probe
This makes the code flow easier -- instead of the controller driver calling snd_hda_build_pcms() and snd_hda_build_controls() explicitly, the codec driver itself builds PCMs and controls at probe time. Then the controller driver only needs to call snd_card_register(). Also, this allows us the full bind/unbind control, too. Even when a codec driver is bound later, it automatically registers the new PCM and controls by itself. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/hda/hda_bind.c')
-rw-r--r--sound/pci/hda/hda_bind.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/sound/pci/hda/hda_bind.c b/sound/pci/hda/hda_bind.c
index 311896a23cd1..a49bc45c2ea5 100644
--- a/sound/pci/hda/hda_bind.c
+++ b/sound/pci/hda/hda_bind.c
@@ -106,16 +106,28 @@ static int hda_codec_driver_probe(struct device *dev)
}
err = codec->preset->patch(codec);
- if (err < 0) {
- module_put(owner);
- goto error;
+ if (err < 0)
+ goto error_module;
+
+ err = snd_hda_codec_build_pcms(codec);
+ if (err < 0)
+ goto error_module;
+ err = snd_hda_codec_build_controls(codec);
+ if (err < 0)
+ goto error_module;
+ if (codec->card->registered) {
+ err = snd_card_register(codec->card);
+ if (err < 0)
+ goto error_module;
}
return 0;
+ error_module:
+ module_put(owner);
+
error:
- codec->preset = NULL;
- memset(&codec->patch_ops, 0, sizeof(codec->patch_ops));
+ snd_hda_codec_cleanup_for_unbind(codec);
return err;
}