aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/soc-ac97.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/soc-ac97.c')
-rw-r--r--sound/soc/soc-ac97.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/sound/soc/soc-ac97.c b/sound/soc/soc-ac97.c
index 08d7259bbaab..d40efc9fe0a9 100644
--- a/sound/soc/soc-ac97.c
+++ b/sound/soc/soc-ac97.c
@@ -85,10 +85,19 @@ EXPORT_SYMBOL(snd_soc_alloc_ac97_codec);
85/** 85/**
86 * snd_soc_new_ac97_codec - initailise AC97 device 86 * snd_soc_new_ac97_codec - initailise AC97 device
87 * @codec: audio codec 87 * @codec: audio codec
88 * @id: The expected device ID
89 * @id_mask: Mask that is applied to the device ID before comparing with @id
88 * 90 *
89 * Initialises AC97 codec resources for use by ad-hoc devices only. 91 * Initialises AC97 codec resources for use by ad-hoc devices only.
92 *
93 * If @id is not 0 this function will reset the device, then read the ID from
94 * the device and check if it matches the expected ID. If it doesn't match an
95 * error will be returned and device will not be registered.
96 *
97 * Returns: A PTR_ERR() on failure or a valid snd_ac97 struct on success.
90 */ 98 */
91struct snd_ac97 *snd_soc_new_ac97_codec(struct snd_soc_codec *codec) 99struct snd_ac97 *snd_soc_new_ac97_codec(struct snd_soc_codec *codec,
100 unsigned int id, unsigned int id_mask)
92{ 101{
93 struct snd_ac97 *ac97; 102 struct snd_ac97 *ac97;
94 int ret; 103 int ret;
@@ -97,13 +106,24 @@ struct snd_ac97 *snd_soc_new_ac97_codec(struct snd_soc_codec *codec)
97 if (IS_ERR(ac97)) 106 if (IS_ERR(ac97))
98 return ac97; 107 return ac97;
99 108
100 ret = device_add(&ac97->dev); 109 if (id) {
101 if (ret) { 110 ret = snd_ac97_reset(ac97, false, id, id_mask);
102 put_device(&ac97->dev); 111 if (ret < 0) {
103 return ERR_PTR(ret); 112 dev_err(codec->dev, "Failed to reset AC97 device: %d\n",
113 ret);
114 goto err_put_device;
115 }
104 } 116 }
105 117
118 ret = device_add(&ac97->dev);
119 if (ret)
120 goto err_put_device;
121
106 return ac97; 122 return ac97;
123
124err_put_device:
125 put_device(&ac97->dev);
126 return ERR_PTR(ret);
107} 127}
108EXPORT_SYMBOL_GPL(snd_soc_new_ac97_codec); 128EXPORT_SYMBOL_GPL(snd_soc_new_ac97_codec);
109 129