summaryrefslogtreecommitdiffstats
path: root/sound/pci/hda/hda_bind.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2015-10-01 17:59:43 +0200
committerTakashi Iwai <tiwai@suse.de>2015-10-15 14:05:28 +0200
commitded255be2276d365a91af2de7c7f8e2c233d4fa2 (patch)
tree4b12a3214ae05ccc3b1b31367c9cec53771cc251 /sound/pci/hda/hda_bind.c
parent3e19fec33a5493f8a627a96ad3494d6c6dc2a624 (diff)
downloadlinux-stable-ded255be2276d365a91af2de7c7f8e2c233d4fa2.tar.gz
linux-stable-ded255be2276d365a91af2de7c7f8e2c233d4fa2.tar.bz2
linux-stable-ded255be2276d365a91af2de7c7f8e2c233d4fa2.zip
ALSA: hda - consolidate chip rename functions
A few multiple codec drivers do renaming the chip_name string but all these are open-coded and some of them have even no error check. Let's make common helpers to do it properly. 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.c35
1 files changed, 23 insertions, 12 deletions
diff --git a/sound/pci/hda/hda_bind.c b/sound/pci/hda/hda_bind.c
index d5ac25cc7fee..ef6b8f836a87 100644
--- a/sound/pci/hda/hda_bind.c
+++ b/sound/pci/hda/hda_bind.c
@@ -45,15 +45,31 @@ static void hda_codec_unsol_event(struct hdac_device *dev, unsigned int ev)
codec->patch_ops.unsol_event(codec, ev);
}
-/* reset the codec name from the preset */
-static int codec_refresh_name(struct hda_codec *codec, const char *name)
+/**
+ * snd_hda_codec_set_name - set the codec name
+ * @codec: the HDA codec
+ * @name: name string to set
+ */
+int snd_hda_codec_set_name(struct hda_codec *codec, const char *name)
{
- if (name) {
- kfree(codec->core.chip_name);
- codec->core.chip_name = kstrdup(name, GFP_KERNEL);
+ int err;
+
+ if (!name)
+ return 0;
+ err = snd_hdac_device_set_chip_name(&codec->core, name);
+ if (err < 0)
+ return err;
+
+ /* update the mixer name */
+ if (!*codec->card->mixername) {
+ snprintf(codec->card->mixername,
+ sizeof(codec->card->mixername), "%s %s",
+ codec->core.vendor_name, codec->core.chip_name);
}
- return codec->core.chip_name ? 0 : -ENOMEM;
+
+ return 0;
}
+EXPORT_SYMBOL_GPL(snd_hda_codec_set_name);
static int hda_codec_driver_probe(struct device *dev)
{
@@ -64,7 +80,7 @@ static int hda_codec_driver_probe(struct device *dev)
if (WARN_ON(!codec->preset))
return -EINVAL;
- err = codec_refresh_name(codec, codec->preset->name);
+ err = snd_hda_codec_set_name(codec, codec->preset->name);
if (err < 0)
goto error;
err = snd_hdac_regmap_init(&codec->core);
@@ -251,11 +267,6 @@ int snd_hda_codec_configure(struct hda_codec *codec)
}
}
- /* audio codec should override the mixer name */
- if (codec->core.afg || !*codec->card->mixername)
- snprintf(codec->card->mixername,
- sizeof(codec->card->mixername), "%s %s",
- codec->core.vendor_name, codec->core.chip_name);
return 0;
error: