aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sound/soc/codecs/si476x.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/sound/soc/codecs/si476x.c b/sound/soc/codecs/si476x.c
index 03645ce42063..52e7cb08434b 100644
--- a/sound/soc/codecs/si476x.c
+++ b/sound/soc/codecs/si476x.c
@@ -73,6 +73,7 @@ static const struct snd_soc_dapm_route si476x_dapm_routes[] = {
73static int si476x_codec_set_dai_fmt(struct snd_soc_dai *codec_dai, 73static int si476x_codec_set_dai_fmt(struct snd_soc_dai *codec_dai,
74 unsigned int fmt) 74 unsigned int fmt)
75{ 75{
76 struct si476x_core *core = i2c_mfd_cell_to_core(codec_dai->dev);
76 int err; 77 int err;
77 u16 format = 0; 78 u16 format = 0;
78 79
@@ -136,9 +137,14 @@ static int si476x_codec_set_dai_fmt(struct snd_soc_dai *codec_dai,
136 return -EINVAL; 137 return -EINVAL;
137 } 138 }
138 139
140 si476x_core_lock(core);
141
139 err = snd_soc_update_bits(codec_dai->codec, SI476X_DIGITAL_IO_OUTPUT_FORMAT, 142 err = snd_soc_update_bits(codec_dai->codec, SI476X_DIGITAL_IO_OUTPUT_FORMAT,
140 SI476X_DIGITAL_IO_OUTPUT_FORMAT_MASK, 143 SI476X_DIGITAL_IO_OUTPUT_FORMAT_MASK,
141 format); 144 format);
145
146 si476x_core_unlock(core);
147
142 if (err < 0) { 148 if (err < 0) {
143 dev_err(codec_dai->codec->dev, "Failed to set output format\n"); 149 dev_err(codec_dai->codec->dev, "Failed to set output format\n");
144 return err; 150 return err;
@@ -151,6 +157,7 @@ static int si476x_codec_hw_params(struct snd_pcm_substream *substream,
151 struct snd_pcm_hw_params *params, 157 struct snd_pcm_hw_params *params,
152 struct snd_soc_dai *dai) 158 struct snd_soc_dai *dai)
153{ 159{
160 struct si476x_core *core = i2c_mfd_cell_to_core(dai->dev);
154 int rate, width, err; 161 int rate, width, err;
155 162
156 rate = params_rate(params); 163 rate = params_rate(params);
@@ -176,11 +183,13 @@ static int si476x_codec_hw_params(struct snd_pcm_substream *substream,
176 return -EINVAL; 183 return -EINVAL;
177 } 184 }
178 185
186 si476x_core_lock(core);
187
179 err = snd_soc_write(dai->codec, SI476X_DIGITAL_IO_OUTPUT_SAMPLE_RATE, 188 err = snd_soc_write(dai->codec, SI476X_DIGITAL_IO_OUTPUT_SAMPLE_RATE,
180 rate); 189 rate);
181 if (err < 0) { 190 if (err < 0) {
182 dev_err(dai->codec->dev, "Failed to set sample rate\n"); 191 dev_err(dai->codec->dev, "Failed to set sample rate\n");
183 return err; 192 goto out;
184 } 193 }
185 194
186 err = snd_soc_update_bits(dai->codec, SI476X_DIGITAL_IO_OUTPUT_FORMAT, 195 err = snd_soc_update_bits(dai->codec, SI476X_DIGITAL_IO_OUTPUT_FORMAT,
@@ -189,10 +198,13 @@ static int si476x_codec_hw_params(struct snd_pcm_substream *substream,
189 (width << SI476X_DIGITAL_IO_SAMPLE_SIZE_SHIFT)); 198 (width << SI476X_DIGITAL_IO_SAMPLE_SIZE_SHIFT));
190 if (err < 0) { 199 if (err < 0) {
191 dev_err(dai->codec->dev, "Failed to set output width\n"); 200 dev_err(dai->codec->dev, "Failed to set output width\n");
192 return err; 201 goto out;
193 } 202 }
194 203
195 return 0; 204out:
205 si476x_core_unlock(core);
206
207 return err;
196} 208}
197 209
198static int si476x_codec_probe(struct snd_soc_codec *codec) 210static int si476x_codec_probe(struct snd_soc_codec *codec)