aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/sound/hda/hdac_device.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/hda/hdac_device.c
parentALSA: hda - Enable widget power saving for Cirrus codecs (diff)
downloadwireguard-linux-ded255be2276d365a91af2de7c7f8e2c233d4fa2.tar.xz
wireguard-linux-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/hda/hdac_device.c')
-rw-r--r--sound/hda/hdac_device.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/sound/hda/hdac_device.c b/sound/hda/hdac_device.c
index b3b0ad289df1..4b06b26cee06 100644
--- a/sound/hda/hdac_device.c
+++ b/sound/hda/hdac_device.c
@@ -164,6 +164,28 @@ void snd_hdac_device_unregister(struct hdac_device *codec)
EXPORT_SYMBOL_GPL(snd_hdac_device_unregister);
/**
+ * snd_hdac_device_set_chip_name - set/update the codec name
+ * @codec: the HDAC device
+ * @name: name string to set
+ *
+ * Returns 0 if the name is set or updated, or a negative error code.
+ */
+int snd_hdac_device_set_chip_name(struct hdac_device *codec, const char *name)
+{
+ char *newname;
+
+ if (!name)
+ return 0;
+ newname = kstrdup(name, GFP_KERNEL);
+ if (!newname)
+ return -ENOMEM;
+ kfree(codec->chip_name);
+ codec->chip_name = newname;
+ return 0;
+}
+EXPORT_SYMBOL_GPL(snd_hdac_device_set_chip_name);
+
+/**
* snd_hdac_make_cmd - compose a 32bit command word to be sent to the
* HD-audio controller
* @codec: the codec object