Skip to content

Commit cadab0a

Browse files
Dan Murphybroonie
authored andcommitted
ASoC: tas2770: Fix error handling with update_bits
snd_soc_update_bits returns a 1 when the bit was successfully updated, returns a 0 is no update was needed and a negative if the call failed. The code is currently failing the case of a successful update by just checking for a non-zero number. Modify these checks and return the error code only if there is a negative. Fixes: 1a476ab ("tas2770: add tas2770 smart PA kernel driver") Signed-off-by: Dan Murphy <dmurphy@ti.com> Link: https://lore.kernel.org/r/20200918190548.12598-7-dmurphy@ti.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 4b8ab8a commit cadab0a

1 file changed

Lines changed: 24 additions & 28 deletions

File tree

sound/soc/codecs/tas2770.c

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -140,23 +140,18 @@ static int tas2770_dac_event(struct snd_soc_dapm_widget *w,
140140
TAS2770_PWR_CTRL,
141141
TAS2770_PWR_CTRL_MASK,
142142
TAS2770_PWR_CTRL_MUTE);
143-
if (ret)
144-
goto end;
145143
break;
146144
case SND_SOC_DAPM_PRE_PMD:
147145
ret = snd_soc_component_update_bits(component,
148146
TAS2770_PWR_CTRL,
149147
TAS2770_PWR_CTRL_MASK,
150148
TAS2770_PWR_CTRL_SHUTDOWN);
151-
if (ret)
152-
goto end;
153149
break;
154150
default:
155151
dev_err(tas2770->dev, "Not supported evevt\n");
156152
return -EINVAL;
157153
}
158154

159-
end:
160155
if (ret < 0)
161156
return ret;
162157

@@ -248,6 +243,9 @@ static int tas2770_set_bitwidth(struct tas2770_priv *tas2770, int bitwidth)
248243
return -EINVAL;
249244
}
250245

246+
if (ret < 0)
247+
return ret;
248+
251249
tas2770->channel_size = bitwidth;
252250

253251
ret = snd_soc_component_update_bits(component,
@@ -256,16 +254,15 @@ static int tas2770_set_bitwidth(struct tas2770_priv *tas2770, int bitwidth)
256254
TAS2770_TDM_CFG_REG5_50_MASK,
257255
TAS2770_TDM_CFG_REG5_VSNS_ENABLE |
258256
tas2770->v_sense_slot);
259-
if (ret)
260-
goto end;
257+
if (ret < 0)
258+
return ret;
259+
261260
ret = snd_soc_component_update_bits(component,
262261
TAS2770_TDM_CFG_REG6,
263262
TAS2770_TDM_CFG_REG6_ISNS_MASK |
264263
TAS2770_TDM_CFG_REG6_50_MASK,
265264
TAS2770_TDM_CFG_REG6_ISNS_ENABLE |
266265
tas2770->i_sense_slot);
267-
268-
end:
269266
if (ret < 0)
270267
return ret;
271268

@@ -283,36 +280,35 @@ static int tas2770_set_samplerate(struct tas2770_priv *tas2770, int samplerate)
283280
TAS2770_TDM_CFG_REG0,
284281
TAS2770_TDM_CFG_REG0_SMP_MASK,
285282
TAS2770_TDM_CFG_REG0_SMP_48KHZ);
286-
if (ret)
287-
goto end;
283+
if (ret < 0)
284+
return ret;
285+
288286
ret = snd_soc_component_update_bits(component,
289287
TAS2770_TDM_CFG_REG0,
290288
TAS2770_TDM_CFG_REG0_31_MASK,
291289
TAS2770_TDM_CFG_REG0_31_44_1_48KHZ);
292-
if (ret)
293-
goto end;
294290
break;
295291
case 44100:
296292
ret = snd_soc_component_update_bits(component,
297293
TAS2770_TDM_CFG_REG0,
298294
TAS2770_TDM_CFG_REG0_SMP_MASK,
299295
TAS2770_TDM_CFG_REG0_SMP_44_1KHZ);
300-
if (ret)
301-
goto end;
296+
if (ret < 0)
297+
return ret;
298+
302299
ret = snd_soc_component_update_bits(component,
303300
TAS2770_TDM_CFG_REG0,
304301
TAS2770_TDM_CFG_REG0_31_MASK,
305302
TAS2770_TDM_CFG_REG0_31_44_1_48KHZ);
306-
if (ret)
307-
goto end;
308303
break;
309304
case 96000:
310305
ret = snd_soc_component_update_bits(component,
311306
TAS2770_TDM_CFG_REG0,
312307
TAS2770_TDM_CFG_REG0_SMP_MASK,
313308
TAS2770_TDM_CFG_REG0_SMP_48KHZ);
314-
if (ret)
315-
goto end;
309+
if (ret < 0)
310+
return ret;
311+
316312
ret = snd_soc_component_update_bits(component,
317313
TAS2770_TDM_CFG_REG0,
318314
TAS2770_TDM_CFG_REG0_31_MASK,
@@ -323,8 +319,9 @@ static int tas2770_set_samplerate(struct tas2770_priv *tas2770, int samplerate)
323319
TAS2770_TDM_CFG_REG0,
324320
TAS2770_TDM_CFG_REG0_SMP_MASK,
325321
TAS2770_TDM_CFG_REG0_SMP_44_1KHZ);
326-
if (ret)
327-
goto end;
322+
if (ret < 0)
323+
return ret;
324+
328325
ret = snd_soc_component_update_bits(component,
329326
TAS2770_TDM_CFG_REG0,
330327
TAS2770_TDM_CFG_REG0_31_MASK,
@@ -335,22 +332,22 @@ static int tas2770_set_samplerate(struct tas2770_priv *tas2770, int samplerate)
335332
TAS2770_TDM_CFG_REG0,
336333
TAS2770_TDM_CFG_REG0_SMP_MASK,
337334
TAS2770_TDM_CFG_REG0_SMP_48KHZ);
338-
if (ret)
339-
goto end;
335+
if (ret < 0)
336+
return ret;
337+
340338
ret = snd_soc_component_update_bits(component,
341339
TAS2770_TDM_CFG_REG0,
342340
TAS2770_TDM_CFG_REG0_31_MASK,
343341
TAS2770_TDM_CFG_REG0_31_176_4_192KHZ);
344-
if (ret)
345-
goto end;
346342
break;
347343
case 17640:
348344
ret = snd_soc_component_update_bits(component,
349345
TAS2770_TDM_CFG_REG0,
350346
TAS2770_TDM_CFG_REG0_SMP_MASK,
351347
TAS2770_TDM_CFG_REG0_SMP_44_1KHZ);
352-
if (ret)
353-
goto end;
348+
if (ret < 0)
349+
return ret;
350+
354351
ret = snd_soc_component_update_bits(component,
355352
TAS2770_TDM_CFG_REG0,
356353
TAS2770_TDM_CFG_REG0_31_MASK,
@@ -360,7 +357,6 @@ static int tas2770_set_samplerate(struct tas2770_priv *tas2770, int samplerate)
360357
ret = -EINVAL;
361358
}
362359

363-
end:
364360
if (ret < 0)
365361
return ret;
366362

0 commit comments

Comments
 (0)