summaryrefslogtreecommitdiff
path: root/sound/soc
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2020-06-16 14:19:41 +0900
committerMark Brown <broonie@kernel.org>2020-06-22 15:13:36 +0100
commitcf6e26c71bfdff823fd40945b07666d75f1e1412 (patch)
tree442165e2d0a1605c68d5b3522772790e95afaa3c /sound/soc
parent3bd057c8219d4006f2b436cea2ae5ac723067a51 (diff)
ASoC: soc-component: merge snd_soc_component_read() and snd_soc_component_read32()
We had read/write function for Codec, Platform, etc, but these has been merged into snd_soc_component_read/write(). Internally, it is using regmap or driver function. In read case, each styles are like below regmap ret = regmap_read(..., reg, &val); driver function val = xxx->read(..., reg); Because of this kind of different style, to keep same read style, when we merged each read function into snd_soc_component_read(), we created snd_soc_component_read32(), like below. commit 738b49efe6c6 ("ASoC: add snd_soc_component_read32") (1) val = snd_soc_component_read32(component, reg); (2) ret = snd_soc_component_read(component, reg, &val); Many drivers are using snd_soc_component_read32(), and some drivers are using snd_soc_component_read() today. In generally, we don't check read function successes, because, we will have many other issues at initial timing if read function didn't work. Now we can use soc_component_err() when error case. This means, it is easy to notice if error occurred. This patch aggressively merge snd_soc_component_read() and _read32(), and makes snd_soc_component_read/write() as generally style. This patch do 1) merge snd_soc_component_read() and snd_soc_component_read32() 2) it uses soc_component_err() when error case (easy to notice) 3) keeps read32 for now by #define 4) update snd_soc_component_read() for all drivers Because _read() user drivers are not too many, this patch changes all user drivers. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com> Link: https://lore.kernel.org/r/87sgev4mfl.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc')
-rw-r--r--sound/soc/codecs/ak4613.c4
-rw-r--r--sound/soc/codecs/cs47l35.c10
-rw-r--r--sound/soc/codecs/cs47l85.c10
-rw-r--r--sound/soc/codecs/inno_rk3036.c6
-rw-r--r--sound/soc/codecs/madera.c49
-rw-r--r--sound/soc/codecs/nau8822.c2
-rw-r--r--sound/soc/codecs/rt1305.c2
-rw-r--r--sound/soc/codecs/rt5682.c3
-rw-r--r--sound/soc/codecs/tas5720.c4
-rw-r--r--sound/soc/codecs/tda7419.c9
-rw-r--r--sound/soc/codecs/tscs454.c24
-rw-r--r--sound/soc/fsl/fsl_audmix.c10
-rw-r--r--sound/soc/fsl/fsl_easrc.c5
-rw-r--r--sound/soc/meson/aiu-encoder-i2s.c3
-rw-r--r--sound/soc/meson/aiu-fifo-i2s.c3
-rw-r--r--sound/soc/meson/aiu-fifo.c3
-rw-r--r--sound/soc/soc-ac97.c7
-rw-r--r--sound/soc/soc-component.c40
-rw-r--r--sound/soc/soc-dapm.c31
-rw-r--r--sound/soc/soc-ops.c43
20 files changed, 67 insertions, 201 deletions
diff --git a/sound/soc/codecs/ak4613.c b/sound/soc/codecs/ak4613.c
index c1181a20714d..d4d2f0d9231a 100644
--- a/sound/soc/codecs/ak4613.c
+++ b/sound/soc/codecs/ak4613.c
@@ -490,8 +490,8 @@ static void ak4613_dummy_write(struct work_struct *work)
*/
udelay(5000000 / priv->rate);
- snd_soc_component_read(component, PW_MGMT1, &mgmt1);
- snd_soc_component_read(component, PW_MGMT3, &mgmt3);
+ mgmt1 = snd_soc_component_read(component, PW_MGMT1);
+ mgmt3 = snd_soc_component_read(component, PW_MGMT3);
snd_soc_component_write(component, PW_MGMT1, mgmt1);
snd_soc_component_write(component, PW_MGMT3, mgmt3);
diff --git a/sound/soc/codecs/cs47l35.c b/sound/soc/codecs/cs47l35.c
index d7538d50bbd3..e9b1fc4c7580 100644
--- a/sound/soc/codecs/cs47l35.c
+++ b/sound/soc/codecs/cs47l35.c
@@ -129,19 +129,11 @@ static void cs47l35_hp_post_enable(struct snd_soc_dapm_widget *w)
struct snd_soc_component *component =
snd_soc_dapm_to_component(w->dapm);
unsigned int val;
- int ret;
switch (w->shift) {
case MADERA_OUT1L_ENA_SHIFT:
case MADERA_OUT1R_ENA_SHIFT:
- ret = snd_soc_component_read(component, MADERA_OUTPUT_ENABLES_1,
- &val);
- if (ret) {
- dev_err(component->dev,
- "Failed to check output enables: %d\n", ret);
- return;
- }
-
+ val = snd_soc_component_read(component, MADERA_OUTPUT_ENABLES_1);
val &= (MADERA_OUT1L_ENA | MADERA_OUT1R_ENA);
if (val != (MADERA_OUT1L_ENA | MADERA_OUT1R_ENA))
diff --git a/sound/soc/codecs/cs47l85.c b/sound/soc/codecs/cs47l85.c
index 9de991adad74..64db07a99408 100644
--- a/sound/soc/codecs/cs47l85.c
+++ b/sound/soc/codecs/cs47l85.c
@@ -191,19 +191,11 @@ static void cs47l85_hp_post_enable(struct snd_soc_dapm_widget *w)
struct snd_soc_component *component =
snd_soc_dapm_to_component(w->dapm);
unsigned int val;
- int ret;
switch (w->shift) {
case MADERA_OUT1L_ENA_SHIFT:
case MADERA_OUT1R_ENA_SHIFT:
- ret = snd_soc_component_read(component, MADERA_OUTPUT_ENABLES_1,
- &val);
- if (ret) {
- dev_err(component->dev,
- "Failed to check output enables: %d\n", ret);
- return;
- }
-
+ val = snd_soc_component_read(component, MADERA_OUTPUT_ENABLES_1);
val &= (MADERA_OUT1L_ENA | MADERA_OUT1R_ENA);
if (val != (MADERA_OUT1L_ENA | MADERA_OUT1R_ENA))
diff --git a/sound/soc/codecs/inno_rk3036.c b/sound/soc/codecs/inno_rk3036.c
index 14d8fe1c28a4..d0e8f0d2fbc1 100644
--- a/sound/soc/codecs/inno_rk3036.c
+++ b/sound/soc/codecs/inno_rk3036.c
@@ -48,11 +48,9 @@ static int rk3036_codec_antipop_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
- int val, ret, regval;
+ int val, regval;
- ret = snd_soc_component_read(component, INNO_R09, &regval);
- if (ret)
- return ret;
+ regval = snd_soc_component_read(component, INNO_R09);
val = ((regval >> INNO_R09_HPL_ANITPOP_SHIFT) &
INNO_R09_HP_ANTIPOP_MSK) == INNO_R09_HP_ANTIPOP_ON;
ucontrol->value.integer.value[0] = val;
diff --git a/sound/soc/codecs/madera.c b/sound/soc/codecs/madera.c
index ec380b0b2d4e..680f31a6493a 100644
--- a/sound/soc/codecs/madera.c
+++ b/sound/soc/codecs/madera.c
@@ -628,12 +628,8 @@ int madera_out1_demux_get(struct snd_kcontrol *kcontrol,
struct snd_soc_component *component =
snd_soc_dapm_kcontrol_component(kcontrol);
unsigned int val;
- int ret;
-
- ret = snd_soc_component_read(component, MADERA_OUTPUT_ENABLES_1, &val);
- if (ret)
- return ret;
+ val = snd_soc_component_read(component, MADERA_OUTPUT_ENABLES_1);
val &= MADERA_EP_SEL_MASK;
val >>= MADERA_EP_SEL_SHIFT;
ucontrol->value.enumerated.item[0] = val;
@@ -1068,12 +1064,7 @@ int madera_rate_put(struct snd_kcontrol *kcontrol,
*/
mutex_lock(&priv->rate_lock);
- ret = snd_soc_component_read(component, e->reg, &val);
- if (ret < 0) {
- dev_warn(priv->madera->dev, "Failed to read 0x%x (%d)\n",
- e->reg, ret);
- goto out;
- }
+ val = snd_soc_component_read(component, e->reg);
val >>= e->shift_l;
val &= e->mask;
if (snd_soc_enum_item_to_val(e, item) == val) {
@@ -2178,10 +2169,7 @@ int madera_dfc_put(struct snd_kcontrol *kcontrol,
snd_soc_dapm_mutex_lock(dapm);
- ret = snd_soc_component_read(component, reg, &val);
- if (ret)
- goto exit;
-
+ val = snd_soc_component_read(component, reg);
if (val & MADERA_DFC1_ENA) {
ret = -EBUSY;
dev_err(component->dev, "Can't change mode on an active DFC\n");
@@ -2211,9 +2199,7 @@ int madera_lp_mode_put(struct snd_kcontrol *kcontrol,
snd_soc_dapm_mutex_lock(dapm);
/* Cannot change lp mode on an active input */
- ret = snd_soc_component_read(component, MADERA_INPUT_ENABLES, &val);
- if (ret)
- goto exit;
+ val = snd_soc_component_read(component, MADERA_INPUT_ENABLES);
mask = (mc->reg - MADERA_ADC_DIGITAL_VOLUME_1L) / 4;
mask ^= 0x1; /* Flip bottom bit for channel order */
@@ -2276,7 +2262,6 @@ int madera_in_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol,
struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
struct madera_priv *priv = snd_soc_component_get_drvdata(component);
unsigned int reg, val;
- int ret;
if (w->shift % 2)
reg = MADERA_ADC_DIGITAL_VOLUME_1L + ((w->shift / 2) * 8);
@@ -2305,9 +2290,8 @@ int madera_in_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol,
break;
case SND_SOC_DAPM_POST_PMD:
/* Disable volume updates if no inputs are enabled */
- ret = snd_soc_component_read(component, MADERA_INPUT_ENABLES,
- &val);
- if (!ret && !val)
+ val = snd_soc_component_read(component, MADERA_INPUT_ENABLES);
+ if (!val)
madera_in_set_vu(priv, false);
break;
default:
@@ -3087,26 +3071,16 @@ static int madera_aif_cfg_changed(struct snd_soc_component *component,
int base, int bclk, int lrclk, int frame)
{
unsigned int val;
- int ret;
- ret = snd_soc_component_read(component, base + MADERA_AIF_BCLK_CTRL,
- &val);
- if (ret)
- return ret;
+ val = snd_soc_component_read(component, base + MADERA_AIF_BCLK_CTRL);
if (bclk != (val & MADERA_AIF1_BCLK_FREQ_MASK))
return 1;
- ret = snd_soc_component_read(component, base + MADERA_AIF_RX_BCLK_RATE,
- &val);
- if (ret)
- return ret;
+ val = snd_soc_component_read(component, base + MADERA_AIF_RX_BCLK_RATE);
if (lrclk != (val & MADERA_AIF1RX_BCPF_MASK))
return 1;
- ret = snd_soc_component_read(component, base + MADERA_AIF_FRAME_CTRL_1,
- &val);
- if (ret)
- return ret;
+ val = snd_soc_component_read(component, base + MADERA_AIF_FRAME_CTRL_1);
if (frame != (val & (MADERA_AIF1TX_WL_MASK |
MADERA_AIF1TX_SLOT_LEN_MASK)))
return 1;
@@ -3162,10 +3136,7 @@ static int madera_hw_params(struct snd_pcm_substream *substream,
}
/* Force multiple of 2 channels for I2S mode */
- ret = snd_soc_component_read(component, base + MADERA_AIF_FORMAT, &val);
- if (ret)
- return ret;
-
+ val = snd_soc_component_read(component, base + MADERA_AIF_FORMAT);
val &= MADERA_AIF1_FMT_MASK;
if ((channels & 1) && val == MADERA_FMT_I2S_MODE) {
madera_aif_dbg(dai, "Forcing stereo mode\n");
diff --git a/sound/soc/codecs/nau8822.c b/sound/soc/codecs/nau8822.c
index 78db3bd0b3bc..a4f661335c57 100644
--- a/sound/soc/codecs/nau8822.c
+++ b/sound/soc/codecs/nau8822.c
@@ -831,7 +831,7 @@ static int nau8822_hw_params(struct snd_pcm_substream *substream,
unsigned int ctrl_val, bclk_fs, bclk_div;
/* make BCLK and LRC divide configuration if the codec as master. */
- snd_soc_component_read(component, NAU8822_REG_CLOCKING, &ctrl_val);
+ ctrl_val = snd_soc_component_read(component, NAU8822_REG_CLOCKING);
if (ctrl_val & NAU8822_CLK_MASTER) {
/* get the bclk and fs ratio */
bclk_fs = snd_soc_params_to_bclk(params) / params_rate(params);
diff --git a/sound/soc/codecs/rt1305.c b/sound/soc/codecs/rt1305.c
index e27742abfa76..4e9dfd235e59 100644
--- a/sound/soc/codecs/rt1305.c
+++ b/sound/soc/codecs/rt1305.c
@@ -411,7 +411,7 @@ static int rt1305_is_rc_clk_from_pll(struct snd_soc_dapm_widget *source,
struct rt1305_priv *rt1305 = snd_soc_component_get_drvdata(component);
unsigned int val;
- snd_soc_component_read(component, RT1305_CLK_1, &val);
+ val = snd_soc_component_read(component, RT1305_CLK_1);
if (rt1305->sysclk_src == RT1305_FS_SYS_PRE_S_PLL1 &&
(val & RT1305_SEL_PLL_SRC_2_RCCLK))
diff --git a/sound/soc/codecs/rt5682.c b/sound/soc/codecs/rt5682.c
index 36cfd10f8b04..8b592069a7e2 100644
--- a/sound/soc/codecs/rt5682.c
+++ b/sound/soc/codecs/rt5682.c
@@ -2640,8 +2640,7 @@ static unsigned long rt5682_bclk_recalc_rate(struct clk_hw *hw,
struct snd_soc_component *component = rt5682->component;
unsigned int bclks_per_wclk;
- snd_soc_component_read(component, RT5682_TDM_TCON_CTRL,
- &bclks_per_wclk);
+ bclks_per_wclk = snd_soc_component_read(component, RT5682_TDM_TCON_CTRL);
switch (bclks_per_wclk & RT5682_TDM_BCLK_MS1_MASK) {
case RT5682_TDM_BCLK_MS1_256:
diff --git a/sound/soc/codecs/tas5720.c b/sound/soc/codecs/tas5720.c
index 37fab8f22800..e159f839d928 100644
--- a/sound/soc/codecs/tas5720.c
+++ b/sound/soc/codecs/tas5720.c
@@ -508,10 +508,10 @@ static int tas5722_volume_get(struct snd_kcontrol *kcontrol,
struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
unsigned int val;
- snd_soc_component_read(component, TAS5720_VOLUME_CTRL_REG, &val);
+ val = snd_soc_component_read(component, TAS5720_VOLUME_CTRL_REG);
ucontrol->value.integer.value[0] = val << 1;
- snd_soc_component_read(component, TAS5722_DIGITAL_CTRL2_REG, &val);
+ val = snd_soc_component_read(component, TAS5722_DIGITAL_CTRL2_REG);
ucontrol->value.integer.value[0] |= val & TAS5722_VOL_CONTROL_LSB;
return 0;
diff --git a/sound/soc/codecs/tda7419.c b/sound/soc/codecs/tda7419.c
index 2bf4f5e8af27..83d220054c96 100644
--- a/sound/soc/codecs/tda7419.c
+++ b/sound/soc/codecs/tda7419.c
@@ -187,18 +187,13 @@ static int tda7419_vol_get(struct snd_kcontrol *kcontrol,
int thresh = tvc->thresh;
unsigned int invert = tvc->invert;
int val;
- int ret;
- ret = snd_soc_component_read(component, reg, &val);
- if (ret < 0)
- return ret;
+ val = snd_soc_component_read(component, reg);
ucontrol->value.integer.value[0] =
tda7419_vol_get_value(val, mask, min, thresh, invert);
if (tda7419_vol_is_stereo(tvc)) {
- ret = snd_soc_component_read(component, rreg, &val);
- if (ret < 0)
- return ret;
+ val = snd_soc_component_read(component, rreg);
ucontrol->value.integer.value[1] =
tda7419_vol_get_value(val, mask, min, thresh, invert);
}
diff --git a/sound/soc/codecs/tscs454.c b/sound/soc/codecs/tscs454.c
index c3587af9985c..d0af16b4db2f 100644
--- a/sound/soc/codecs/tscs454.c
+++ b/sound/soc/codecs/tscs454.c
@@ -353,12 +353,7 @@ static int write_coeff_ram(struct snd_soc_component *component, u8 *coeff_ram,
for (cnt = 0; cnt < coeff_cnt; cnt++, coeff_addr++) {
for (trys = 0; trys < DACCRSTAT_MAX_TRYS; trys++) {
- ret = snd_soc_component_read(component, r_stat, &val);
- if (ret < 0) {
- dev_err(component->dev,
- "Failed to read stat (%d)\n", ret);
- return ret;
- }
+ val = snd_soc_component_read(component, r_stat);
if (!val)
break;
}
@@ -444,12 +439,7 @@ static int coeff_ram_put(struct snd_kcontrol *kcontrol,
mutex_lock(&tscs454->pll1.lock);
mutex_lock(&tscs454->pll2.lock);
- ret = snd_soc_component_read(component, R_PLLSTAT, &val);
- if (ret < 0) {
- dev_err(component->dev, "Failed to read PLL status (%d)\n",
- ret);
- goto exit;
- }
+ val = snd_soc_component_read(component, R_PLLSTAT);
if (val) { /* PLLs locked */
ret = write_coeff_ram(component, coeff_ram,
r_stat, r_addr, r_wr,
@@ -2642,13 +2632,10 @@ static int tscs454_set_sysclk(struct snd_soc_dai *dai,
struct tscs454 *tscs454 = snd_soc_component_get_drvdata(component);
unsigned int val;
int bclk_dai;
- int ret;
dev_dbg(component->dev, "%s(): freq = %u\n", __func__, freq);
- ret = snd_soc_component_read(component, R_PLLCTL, &val);
- if (ret < 0)
- return ret;
+ val = snd_soc_component_read(component, R_PLLCTL);
bclk_dai = (val & FM_PLLCTL_BCLKSEL) >> FB_PLLCTL_BCLKSEL;
if (bclk_dai != dai->id)
@@ -3204,10 +3191,7 @@ static int tscs454_hw_params(struct snd_pcm_substream *substream,
}
if (!aifs_active(&tscs454->aifs_status)) { /* First active aif */
- ret = snd_soc_component_read(component, R_ISRC, &val);
- if (ret < 0)
- goto exit;
-
+ val = snd_soc_component_read(component, R_ISRC);
if ((val & FM_ISRC_IBR) == FV_IBR_48)
tscs454->internal_rate.pll = &tscs454->pll1;
else
diff --git a/sound/soc/fsl/fsl_audmix.c b/sound/soc/fsl/fsl_audmix.c
index 8b9027f76d8a..a447bafa00d2 100644
--- a/sound/soc/fsl/fsl_audmix.c
+++ b/sound/soc/fsl/fsl_audmix.c
@@ -116,13 +116,9 @@ static int fsl_audmix_put_mix_clk_src(struct snd_kcontrol *kcontrol,
struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
unsigned int *item = ucontrol->value.enumerated.item;
unsigned int reg_val, val, mix_clk;
- int ret;
/* Get current state */
- ret = snd_soc_component_read(comp, FSL_AUDMIX_CTR, &reg_val);
- if (ret)
- return ret;
-
+ reg_val = snd_soc_component_read(comp, FSL_AUDMIX_CTR);
mix_clk = ((reg_val & FSL_AUDMIX_CTR_MIXCLK_MASK)
>> FSL_AUDMIX_CTR_MIXCLK_SHIFT);
val = snd_soc_enum_item_to_val(e, item[0]);
@@ -162,9 +158,7 @@ static int fsl_audmix_put_out_src(struct snd_kcontrol *kcontrol,
int ret;
/* Get current state */
- ret = snd_soc_component_read(comp, FSL_AUDMIX_CTR, &reg_val);
- if (ret)
- return ret;
+ reg_val = snd_soc_component_read(comp, FSL_AUDMIX_CTR);
/* "From" state */
out_src = ((reg_val & FSL_AUDMIX_CTR_OUTSRC_MASK)
diff --git a/sound/soc/fsl/fsl_easrc.c b/sound/soc/fsl/fsl_easrc.c
index 2f6b3d8bfcfc..58cc093ad741 100644
--- a/sound/soc/fsl/fsl_easrc.c
+++ b/sound/soc/fsl/fsl_easrc.c
@@ -79,11 +79,8 @@ static int fsl_easrc_get_reg(struct snd_kcontrol *kcontrol,
struct soc_mreg_control *mc =
(struct soc_mreg_control *)kcontrol->private_value;
unsigned int regval;
- int ret;
- ret = snd_soc_component_read(component, mc->regbase, &regval);
- if (ret < 0)
- return ret;
+ regval = snd_soc_component_read(component, mc->regbase);
ucontrol->value.integer.value[0] = regval;
diff --git a/sound/soc/meson/aiu-encoder-i2s.c b/sound/soc/meson/aiu-encoder-i2s.c
index 832e22d275fe..932224552146 100644
--- a/sound/soc/meson/aiu-encoder-i2s.c
+++ b/sound/soc/meson/aiu-encoder-i2s.c
@@ -72,11 +72,10 @@ static int aiu_encoder_i2s_setup_desc(struct snd_soc_component *component,
{
/* Always operate in split (classic interleaved) mode */
unsigned int desc = AIU_I2S_SOURCE_DESC_MODE_SPLIT;
- unsigned int val;
/* Reset required to update the pipeline */
snd_soc_component_write(component, AIU_RST_SOFT, AIU_RST_SOFT_I2S_FAST);
- snd_soc_component_read(component, AIU_I2S_SYNC, &val);
+ snd_soc_component_read(component, AIU_I2S_SYNC);
switch (params_physical_width(params)) {
case 16: /* Nothing to do */
diff --git a/sound/soc/meson/aiu-fifo-i2s.c b/sound/soc/meson/aiu-fifo-i2s.c
index 9a5271ce80fe..d91b0d874342 100644
--- a/sound/soc/meson/aiu-fifo-i2s.c
+++ b/sound/soc/meson/aiu-fifo-i2s.c
@@ -46,7 +46,6 @@ static int aiu_fifo_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
struct snd_soc_dai *dai)
{
struct snd_soc_component *component = dai->component;
- unsigned int val;
switch (cmd) {
case SNDRV_PCM_TRIGGER_START:
@@ -54,7 +53,7 @@ static int aiu_fifo_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
snd_soc_component_write(component, AIU_RST_SOFT,
AIU_RST_SOFT_I2S_FAST);
- snd_soc_component_read(component, AIU_I2S_SYNC, &val);
+ snd_soc_component_read(component, AIU_I2S_SYNC);
break;
}
diff --git a/sound/soc/meson/aiu-fifo.c b/sound/soc/meson/aiu-fifo.c
index d9cede4c33ff..aa88aae8e517 100644
--- a/sound/soc/meson/aiu-fifo.c
+++ b/sound/soc/meson/aiu-fifo.c
@@ -37,8 +37,7 @@ snd_pcm_uframes_t aiu_fifo_pointer(struct snd_soc_component *component,
struct snd_pcm_runtime *runtime = substream->runtime;
unsigned int addr;
- snd_soc_component_read(component, fifo->mem_offset + AIU_MEM_RD,
- &addr);
+ addr = snd_soc_component_read(component, fifo->mem_offset + AIU_MEM_RD);
return bytes_to_frames(runtime, addr - (unsigned int)runtime->dma_addr);
}
diff --git a/sound/soc/soc-ac97.c b/sound/soc/soc-ac97.c
index c086786e4471..906106ed8ca1 100644
--- a/sound/soc/soc-ac97.c
+++ b/sound/soc/soc-ac97.c
@@ -82,13 +82,12 @@ static int snd_soc_ac97_gpio_get(struct gpio_chip *chip, unsigned offset)
struct snd_soc_component *component = gpio_to_component(chip);
int ret;
- if (snd_soc_component_read(component, AC97_GPIO_STATUS, &ret) < 0)
- ret = -1;
+ ret = snd_soc_component_read(component, AC97_GPIO_STATUS);
dev_dbg(component->dev, "get gpio %d : %d\n", offset,
- ret < 0 ? ret : ret & (1 << offset));
+ ret & (1 << offset));
- return ret < 0 ? ret : !!(ret & (1 << offset));
+ return !!(ret & (1 << offset));
}
static void snd_soc_ac97_gpio_set(struct gpio_chip *chip, unsigned offset,
diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c
index d121f5f7633c..428f88decfdb 100644
--- a/sound/soc/soc-component.c
+++ b/sound/soc/soc-component.c
@@ -407,41 +407,30 @@ EXPORT_SYMBOL_GPL(snd_soc_component_exit_regmap);
* snd_soc_component_read() - Read register value
* @component: Component to read from
* @reg: Register to read
- * @val: Pointer to where the read value is stored
*
- * Return: 0 on success, a negative error code otherwise.
+ * Return: read value
*/
-int snd_soc_component_read(struct snd_soc_component *component,
- unsigned int reg, unsigned int *val)
+unsigned int snd_soc_component_read(struct snd_soc_component *component,
+ unsigned int reg)
{
int ret;
+ unsigned int val = 0;
if (component->regmap)
- ret = regmap_read(component->regmap, reg, val);
+ ret = regmap_read(component->regmap, reg, &val);
else if (component->driver->read) {
- *val = component->driver->read(component, reg);
ret = 0;
+ val = component->driver->read(component, reg);
}
else
ret = -EIO;
- return soc_component_ret(component, ret);
-}
-EXPORT_SYMBOL_GPL(snd_soc_component_read);
-
-unsigned int snd_soc_component_read32(struct snd_soc_component *component,
- unsigned int reg)
-{
- unsigned int val;
- int ret;
-
- ret = snd_soc_component_read(component, reg, &val);
if (ret < 0)
- return soc_component_ret(component, -1);
+ soc_component_ret(component, ret);
return val;
}
-EXPORT_SYMBOL_GPL(snd_soc_component_read32);
+EXPORT_SYMBOL_GPL(snd_soc_component_read);
/**
* snd_soc_component_write() - Write register value
@@ -470,19 +459,17 @@ static int snd_soc_component_update_bits_legacy(
unsigned int mask, unsigned int val, bool *change)
{
unsigned int old, new;
- int ret;
+ int ret = 0;
mutex_lock(&component->io_mutex);
- ret = snd_soc_component_read(component, reg, &old);
- if (ret < 0)
- goto out_unlock;
+ old = snd_soc_component_read(component, reg);
new = (old & ~mask) | (val & mask);
*change = old != new;
if (*change)
ret = snd_soc_component_write(component, reg, new);
-out_unlock:
+
mutex_unlock(&component->io_mutex);
return soc_component_ret(component, ret);
@@ -584,11 +571,8 @@ int snd_soc_component_test_bits(struct snd_soc_component *component,
unsigned int reg, unsigned int mask, unsigned int value)
{
unsigned int old, new;
- int ret;
- ret = snd_soc_component_read(component, reg, &old);
- if (ret < 0)
- return soc_component_ret(component, ret);
+ old = snd_soc_component_read(component, reg);
new = (old & ~mask) | value;
return old != new;
}
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 2491e1ce16d3..e51aa2efc65c 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -616,12 +616,11 @@ static const char *soc_dapm_prefix(struct snd_soc_dapm_context *dapm)
return dapm->component->name_prefix;
}
-static int soc_dapm_read(struct snd_soc_dapm_context *dapm, int reg,
- unsigned int *value)
+static unsigned int soc_dapm_read(struct snd_soc_dapm_context *dapm, int reg)
{
if (!dapm->component)
return -EIO;
- return snd_soc_component_read(dapm->component, reg, value);
+ return snd_soc_component_read(dapm->component, reg);
}
static int soc_dapm_update_bits(struct snd_soc_dapm_context *dapm,
@@ -753,7 +752,7 @@ static int dapm_connect_mux(struct snd_soc_dapm_context *dapm,
int i;
if (e->reg != SND_SOC_NOPM) {
- soc_dapm_read(dapm, e->reg, &val);
+ val = soc_dapm_read(dapm, e->reg);
val = (val >> e->shift_l) & e->mask;
item = snd_soc_enum_val_to_item(e, val);
} else {
@@ -790,7 +789,7 @@ static void dapm_set_mixer_path_status(struct snd_soc_dapm_path *p, int i,
unsigned int val;
if (reg != SND_SOC_NOPM) {
- soc_dapm_read(p->sink->dapm, reg, &val);
+ val = soc_dapm_read(p->sink->dapm, reg);
/*
* The nth_path argument allows this function to know
* which path of a kcontrol it is setting the initial
@@ -805,7 +804,7 @@ static void dapm_set_mixer_path_status(struct snd_soc_dapm_path *p, int i,
*/
if (snd_soc_volsw_is_stereo(mc) && nth_path > 0) {
if (reg != mc->rreg)
- soc_dapm_read(p->sink->dapm, mc->rreg, &val);
+ val = soc_dapm_read(p->sink->dapm, mc->rreg);
val = (val >> mc->rshift) & mask;
} else {
val = (val >> shift) & mask;
@@ -3246,7 +3245,7 @@ int snd_soc_dapm_new_widgets(struct snd_soc_card *card)
/* Read the initial power state from the device */
if (w->reg >= 0) {
- soc_dapm_read(w->dapm, w->reg, &val);
+ val = soc_dapm_read(w->dapm, w->reg);
val = val >> w->shift;
val &= w->mask;
if (val == w->on_val)
@@ -3288,15 +3287,14 @@ int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol,
unsigned int mask = (1 << fls(max)) - 1;
unsigned int invert = mc->invert;
unsigned int reg_val, val, rval = 0;
- int ret = 0;
mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
if (dapm_kcontrol_is_powered(kcontrol) && reg != SND_SOC_NOPM) {
- ret = soc_dapm_read(dapm, reg, &reg_val);
+ reg_val = soc_dapm_read(dapm, reg);
val = (reg_val >> shift) & mask;
- if (ret == 0 && reg != mc->rreg)
- ret = soc_dapm_read(dapm, mc->rreg, &reg_val);
+ if (reg != mc->rreg)
+ reg_val = soc_dapm_read(dapm, mc->rreg);
if (snd_soc_volsw_is_stereo(mc))
rval = (reg_val >> mc->rshift) & mask;
@@ -3309,9 +3307,6 @@ int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol,
}
mutex_unlock(&card->dapm_mutex);
- if (ret)
- return ret;
-
if (invert)
ucontrol->value.integer.value[0] = max - val;
else
@@ -3324,7 +3319,7 @@ int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol,
ucontrol->value.integer.value[1] = rval;
}
- return ret;
+ return 0;
}
EXPORT_SYMBOL_GPL(snd_soc_dapm_get_volsw);
@@ -3439,11 +3434,7 @@ int snd_soc_dapm_get_enum_double(struct snd_kcontrol *kcontrol,
mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
if (e->reg != SND_SOC_NOPM && dapm_kcontrol_is_powered(kcontrol)) {
- int ret = soc_dapm_read(dapm, e->reg, &reg_val);
- if (ret) {
- mutex_unlock(&card->dapm_mutex);
- return ret;
- }
+ reg_val = soc_dapm_read(dapm, e->reg);
} else {
reg_val = dapm_kcontrol_get_value(kcontrol);
}
diff --git a/sound/soc/soc-ops.c b/sound/soc/soc-ops.c
index 55ffb34be95e..10f48827bb0e 100644
--- a/sound/soc/soc-ops.c
+++ b/sound/soc/soc-ops.c
@@ -63,11 +63,8 @@ int snd_soc_get_enum_double(struct snd_kcontrol *kcontrol,
struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
unsigned int val, item;
unsigned int reg_val;
- int ret;
- ret = snd_soc_component_read(component, e->reg, &reg_val);
- if (ret)
- return ret;
+ reg_val = snd_soc_component_read(component, e->reg);
val = (reg_val >> e->shift_l) & e->mask;
item = snd_soc_enum_val_to_item(e, val);
ucontrol->value.enumerated.item[0] = item;
@@ -136,10 +133,7 @@ static int snd_soc_read_signed(struct snd_soc_component *component,
int ret;
unsigned int val;
- ret = snd_soc_component_read(component, reg, &val);
- if (ret < 0)
- return ret;
-
+ val = snd_soc_component_read(component, reg);
val = (val >> shift) & mask;
if (!sign_bit) {
@@ -375,19 +369,12 @@ int snd_soc_get_volsw_sx(struct snd_kcontrol *kcontrol,
int min = mc->min;
unsigned int mask = (1U << (fls(min + max) - 1)) - 1;
unsigned int val;
- int ret;
-
- ret = snd_soc_component_read(component, reg, &val);
- if (ret < 0)
- return ret;
+ val = snd_soc_component_read(component, reg);
ucontrol->value.integer.value[0] = ((val >> shift) - min) & mask;
if (snd_soc_volsw_is_stereo(mc)) {
- ret = snd_soc_component_read(component, reg2, &val);
- if (ret < 0)
- return ret;
-
+ val = snd_soc_component_read(component, reg2);
val = ((val >> rshift) - min) & mask;
ucontrol->value.integer.value[1] = val;
}
@@ -548,12 +535,8 @@ int snd_soc_get_volsw_range(struct snd_kcontrol *kcontrol,
unsigned int mask = (1 << fls(max)) - 1;
unsigned int invert = mc->invert;
unsigned int val;
- int ret;
-
- ret = snd_soc_component_read(component, reg, &val);
- if (ret)
- return ret;
+ val = snd_soc_component_read(component, reg);
ucontrol->value.integer.value[0] = (val >> shift) & mask;
if (invert)
ucontrol->value.integer.value[0] =
@@ -563,10 +546,7 @@ int snd_soc_get_volsw_range(struct snd_kcontrol *kcontrol,
ucontrol->value.integer.value[0] - min;
if (snd_soc_volsw_is_stereo(mc)) {
- ret = snd_soc_component_read(component, rreg, &val);
- if (ret)
- return ret;
-
+ val = snd_soc_component_read(component, rreg);
ucontrol->value.integer.value[1] = (val >> shift) & mask;
if (invert)
ucontrol->value.integer.value[1] =
@@ -833,12 +813,9 @@ int snd_soc_get_xr_sx(struct snd_kcontrol *kcontrol,
long val = 0;
unsigned int regval;
unsigned int i;
- int ret;
for (i = 0; i < regcount; i++) {
- ret = snd_soc_component_read(component, regbase+i, &regval);
- if (ret)
- return ret;
+ regval = snd_soc_component_read(component, regbase+i);
val |= (regval & regwmask) << (regwshift*(regcount-i-1));
}
val &= mask;
@@ -918,12 +895,8 @@ int snd_soc_get_strobe(struct snd_kcontrol *kcontrol,
unsigned int mask = 1 << shift;
unsigned int invert = mc->invert != 0;
unsigned int val;
- int ret;
-
- ret = snd_soc_component_read(component, reg, &val);
- if (ret)
- return ret;
+ val = snd_soc_component_read(component, reg);
val &= mask;
if (shift != 0 && val != 0)