Commit edd6d539 authored by Dan Murphy's avatar Dan Murphy Committed by Mark Brown

ASoC: tas2770: Fix snd_soc_update_bits error handling

According the documentation for snd_soc_update_bits the API
will return a 1 if the update was successful with a value change,
a 0 if the update was successful with no value change or a negative
if the command just failed.

So the value of return in the driver needs to be checked for being less
then 0 or the caller may indicate failure when the value actually
changed.
Signed-off-by: default avatarDan Murphy <dmurphy@ti.com>
Link: https://lore.kernel.org/r/20191007171157.17813-1-dmurphy@ti.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 40f90ef0
...@@ -83,7 +83,8 @@ static int tas2770_codec_suspend(struct snd_soc_component *component) ...@@ -83,7 +83,8 @@ static int tas2770_codec_suspend(struct snd_soc_component *component)
TAS2770_PWR_CTRL, TAS2770_PWR_CTRL,
TAS2770_PWR_CTRL_MASK, TAS2770_PWR_CTRL_MASK,
TAS2770_PWR_CTRL_SHUTDOWN); TAS2770_PWR_CTRL_SHUTDOWN);
if (ret)
if (ret < 0)
return ret; return ret;
return 0; return 0;
...@@ -97,8 +98,9 @@ static int tas2770_codec_resume(struct snd_soc_component *component) ...@@ -97,8 +98,9 @@ static int tas2770_codec_resume(struct snd_soc_component *component)
TAS2770_PWR_CTRL, TAS2770_PWR_CTRL,
TAS2770_PWR_CTRL_MASK, TAS2770_PWR_CTRL_MASK,
TAS2770_PWR_CTRL_ACTIVE); TAS2770_PWR_CTRL_ACTIVE);
if (ret)
return -EINVAL; if (ret < 0)
return ret;
return 0; return 0;
} }
...@@ -150,7 +152,10 @@ static int tas2770_dac_event(struct snd_soc_dapm_widget *w, ...@@ -150,7 +152,10 @@ static int tas2770_dac_event(struct snd_soc_dapm_widget *w,
} }
end: end:
return ret; if (ret < 0)
return ret;
return 0;
} }
static const struct snd_kcontrol_new isense_switch = static const struct snd_kcontrol_new isense_switch =
...@@ -200,7 +205,10 @@ static int tas2770_mute(struct snd_soc_dai *dai, int mute) ...@@ -200,7 +205,10 @@ static int tas2770_mute(struct snd_soc_dai *dai, int mute)
TAS2770_PWR_CTRL_MASK, TAS2770_PWR_CTRL_MASK,
TAS2770_PWR_CTRL_ACTIVE); TAS2770_PWR_CTRL_ACTIVE);
return ret; if (ret < 0)
return ret;
return 0;
} }
static int tas2770_set_bitwidth(struct tas2770_priv *tas2770, int bitwidth) static int tas2770_set_bitwidth(struct tas2770_priv *tas2770, int bitwidth)
...@@ -253,7 +261,10 @@ static int tas2770_set_bitwidth(struct tas2770_priv *tas2770, int bitwidth) ...@@ -253,7 +261,10 @@ static int tas2770_set_bitwidth(struct tas2770_priv *tas2770, int bitwidth)
tas2770->i_sense_slot); tas2770->i_sense_slot);
end: end:
return ret; if (ret < 0)
return ret;
return 0;
} }
static int tas2770_set_samplerate(struct tas2770_priv *tas2770, int samplerate) static int tas2770_set_samplerate(struct tas2770_priv *tas2770, int samplerate)
...@@ -345,9 +356,11 @@ static int tas2770_set_samplerate(struct tas2770_priv *tas2770, int samplerate) ...@@ -345,9 +356,11 @@ static int tas2770_set_samplerate(struct tas2770_priv *tas2770, int samplerate)
} }
end: end:
if (!ret) if (ret < 0)
tas2770->sampling_rate = samplerate; return ret;
return ret;
tas2770->sampling_rate = samplerate;
return 0;
} }
static int tas2770_hw_params(struct snd_pcm_substream *substream, static int tas2770_hw_params(struct snd_pcm_substream *substream,
...@@ -401,7 +414,7 @@ static int tas2770_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) ...@@ -401,7 +414,7 @@ static int tas2770_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
ret = snd_soc_component_update_bits(component, TAS2770_TDM_CFG_REG1, ret = snd_soc_component_update_bits(component, TAS2770_TDM_CFG_REG1,
TAS2770_TDM_CFG_REG1_RX_MASK, TAS2770_TDM_CFG_REG1_RX_MASK,
asi_cfg_1); asi_cfg_1);
if (ret) if (ret < 0)
return ret; return ret;
switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
...@@ -426,7 +439,7 @@ static int tas2770_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) ...@@ -426,7 +439,7 @@ static int tas2770_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
ret = snd_soc_component_update_bits(component, TAS2770_TDM_CFG_REG1, ret = snd_soc_component_update_bits(component, TAS2770_TDM_CFG_REG1,
TAS2770_TDM_CFG_REG1_MASK, TAS2770_TDM_CFG_REG1_MASK,
(tdm_rx_start_slot << TAS2770_TDM_CFG_REG1_51_SHIFT)); (tdm_rx_start_slot << TAS2770_TDM_CFG_REG1_51_SHIFT));
if (ret) if (ret < 0)
return ret; return ret;
tas2770->asi_format = fmt; tas2770->asi_format = fmt;
...@@ -470,12 +483,12 @@ static int tas2770_set_dai_tdm_slot(struct snd_soc_dai *dai, ...@@ -470,12 +483,12 @@ static int tas2770_set_dai_tdm_slot(struct snd_soc_dai *dai,
ret = snd_soc_component_update_bits(component, TAS2770_TDM_CFG_REG3, ret = snd_soc_component_update_bits(component, TAS2770_TDM_CFG_REG3,
TAS2770_TDM_CFG_REG3_30_MASK, TAS2770_TDM_CFG_REG3_30_MASK,
(left_slot << TAS2770_TDM_CFG_REG3_30_SHIFT)); (left_slot << TAS2770_TDM_CFG_REG3_30_SHIFT));
if (ret) if (ret < 0)
return ret; return ret;
ret = snd_soc_component_update_bits(component, TAS2770_TDM_CFG_REG3, ret = snd_soc_component_update_bits(component, TAS2770_TDM_CFG_REG3,
TAS2770_TDM_CFG_REG3_RXS_MASK, TAS2770_TDM_CFG_REG3_RXS_MASK,
(right_slot << TAS2770_TDM_CFG_REG3_RXS_SHIFT)); (right_slot << TAS2770_TDM_CFG_REG3_RXS_SHIFT));
if (ret) if (ret < 0)
return ret; return ret;
switch (slot_width) { switch (slot_width) {
...@@ -509,10 +522,11 @@ static int tas2770_set_dai_tdm_slot(struct snd_soc_dai *dai, ...@@ -509,10 +522,11 @@ static int tas2770_set_dai_tdm_slot(struct snd_soc_dai *dai,
ret = -EINVAL; ret = -EINVAL;
} }
if (!ret) if (ret < 0)
tas2770->slot_width = slot_width; return ret;
return ret; tas2770->slot_width = slot_width;
return 0;
} }
static struct snd_soc_dai_ops tas2770_dai_ops = { static struct snd_soc_dai_ops tas2770_dai_ops = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment