Commit cf6e26c7 authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Mark Brown

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 738b49ef ("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: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: default avatarKai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/87sgev4mfl.wl-kuninori.morimoto.gx@renesas.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 3bd057c8
...@@ -333,9 +333,8 @@ void snd_soc_component_set_aux(struct snd_soc_component *component, ...@@ -333,9 +333,8 @@ void snd_soc_component_set_aux(struct snd_soc_component *component,
int snd_soc_component_init(struct snd_soc_component *component); int snd_soc_component_init(struct snd_soc_component *component);
/* component IO */ /* component IO */
int snd_soc_component_read(struct snd_soc_component *component, #define snd_soc_component_read32 snd_soc_component_read
unsigned int reg, unsigned int *val); unsigned int snd_soc_component_read(struct snd_soc_component *component,
unsigned int snd_soc_component_read32(struct snd_soc_component *component,
unsigned int reg); unsigned int reg);
int snd_soc_component_write(struct snd_soc_component *component, int snd_soc_component_write(struct snd_soc_component *component,
unsigned int reg, unsigned int val); unsigned int reg, unsigned int val);
......
...@@ -490,8 +490,8 @@ static void ak4613_dummy_write(struct work_struct *work) ...@@ -490,8 +490,8 @@ static void ak4613_dummy_write(struct work_struct *work)
*/ */
udelay(5000000 / priv->rate); udelay(5000000 / priv->rate);
snd_soc_component_read(component, PW_MGMT1, &mgmt1); mgmt1 = snd_soc_component_read(component, PW_MGMT1);
snd_soc_component_read(component, PW_MGMT3, &mgmt3); mgmt3 = snd_soc_component_read(component, PW_MGMT3);
snd_soc_component_write(component, PW_MGMT1, mgmt1); snd_soc_component_write(component, PW_MGMT1, mgmt1);
snd_soc_component_write(component, PW_MGMT3, mgmt3); snd_soc_component_write(component, PW_MGMT3, mgmt3);
......
...@@ -129,19 +129,11 @@ static void cs47l35_hp_post_enable(struct snd_soc_dapm_widget *w) ...@@ -129,19 +129,11 @@ static void cs47l35_hp_post_enable(struct snd_soc_dapm_widget *w)
struct snd_soc_component *component = struct snd_soc_component *component =
snd_soc_dapm_to_component(w->dapm); snd_soc_dapm_to_component(w->dapm);
unsigned int val; unsigned int val;
int ret;
switch (w->shift) { switch (w->shift) {
case MADERA_OUT1L_ENA_SHIFT: case MADERA_OUT1L_ENA_SHIFT:
case MADERA_OUT1R_ENA_SHIFT: case MADERA_OUT1R_ENA_SHIFT:
ret = snd_soc_component_read(component, MADERA_OUTPUT_ENABLES_1, val = 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 &= (MADERA_OUT1L_ENA | MADERA_OUT1R_ENA); val &= (MADERA_OUT1L_ENA | MADERA_OUT1R_ENA);
if (val != (MADERA_OUT1L_ENA | MADERA_OUT1R_ENA)) if (val != (MADERA_OUT1L_ENA | MADERA_OUT1R_ENA))
......
...@@ -191,19 +191,11 @@ static void cs47l85_hp_post_enable(struct snd_soc_dapm_widget *w) ...@@ -191,19 +191,11 @@ static void cs47l85_hp_post_enable(struct snd_soc_dapm_widget *w)
struct snd_soc_component *component = struct snd_soc_component *component =
snd_soc_dapm_to_component(w->dapm); snd_soc_dapm_to_component(w->dapm);
unsigned int val; unsigned int val;
int ret;
switch (w->shift) { switch (w->shift) {
case MADERA_OUT1L_ENA_SHIFT: case MADERA_OUT1L_ENA_SHIFT:
case MADERA_OUT1R_ENA_SHIFT: case MADERA_OUT1R_ENA_SHIFT:
ret = snd_soc_component_read(component, MADERA_OUTPUT_ENABLES_1, val = 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 &= (MADERA_OUT1L_ENA | MADERA_OUT1R_ENA); val &= (MADERA_OUT1L_ENA | MADERA_OUT1R_ENA);
if (val != (MADERA_OUT1L_ENA | MADERA_OUT1R_ENA)) if (val != (MADERA_OUT1L_ENA | MADERA_OUT1R_ENA))
......
...@@ -48,11 +48,9 @@ static int rk3036_codec_antipop_get(struct snd_kcontrol *kcontrol, ...@@ -48,11 +48,9 @@ static int rk3036_codec_antipop_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); 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); regval = snd_soc_component_read(component, INNO_R09);
if (ret)
return ret;
val = ((regval >> INNO_R09_HPL_ANITPOP_SHIFT) & val = ((regval >> INNO_R09_HPL_ANITPOP_SHIFT) &
INNO_R09_HP_ANTIPOP_MSK) == INNO_R09_HP_ANTIPOP_ON; INNO_R09_HP_ANTIPOP_MSK) == INNO_R09_HP_ANTIPOP_ON;
ucontrol->value.integer.value[0] = val; ucontrol->value.integer.value[0] = val;
......
...@@ -628,12 +628,8 @@ int madera_out1_demux_get(struct snd_kcontrol *kcontrol, ...@@ -628,12 +628,8 @@ int madera_out1_demux_get(struct snd_kcontrol *kcontrol,
struct snd_soc_component *component = struct snd_soc_component *component =
snd_soc_dapm_kcontrol_component(kcontrol); snd_soc_dapm_kcontrol_component(kcontrol);
unsigned int val; 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_MASK;
val >>= MADERA_EP_SEL_SHIFT; val >>= MADERA_EP_SEL_SHIFT;
ucontrol->value.enumerated.item[0] = val; ucontrol->value.enumerated.item[0] = val;
...@@ -1068,12 +1064,7 @@ int madera_rate_put(struct snd_kcontrol *kcontrol, ...@@ -1068,12 +1064,7 @@ int madera_rate_put(struct snd_kcontrol *kcontrol,
*/ */
mutex_lock(&priv->rate_lock); mutex_lock(&priv->rate_lock);
ret = snd_soc_component_read(component, e->reg, &val); val = snd_soc_component_read(component, e->reg);
if (ret < 0) {
dev_warn(priv->madera->dev, "Failed to read 0x%x (%d)\n",
e->reg, ret);
goto out;
}
val >>= e->shift_l; val >>= e->shift_l;
val &= e->mask; val &= e->mask;
if (snd_soc_enum_item_to_val(e, item) == val) { if (snd_soc_enum_item_to_val(e, item) == val) {
...@@ -2178,10 +2169,7 @@ int madera_dfc_put(struct snd_kcontrol *kcontrol, ...@@ -2178,10 +2169,7 @@ int madera_dfc_put(struct snd_kcontrol *kcontrol,
snd_soc_dapm_mutex_lock(dapm); snd_soc_dapm_mutex_lock(dapm);
ret = snd_soc_component_read(component, reg, &val); val = snd_soc_component_read(component, reg);
if (ret)
goto exit;
if (val & MADERA_DFC1_ENA) { if (val & MADERA_DFC1_ENA) {
ret = -EBUSY; ret = -EBUSY;
dev_err(component->dev, "Can't change mode on an active DFC\n"); 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, ...@@ -2211,9 +2199,7 @@ int madera_lp_mode_put(struct snd_kcontrol *kcontrol,
snd_soc_dapm_mutex_lock(dapm); snd_soc_dapm_mutex_lock(dapm);
/* Cannot change lp mode on an active input */ /* Cannot change lp mode on an active input */
ret = snd_soc_component_read(component, MADERA_INPUT_ENABLES, &val); val = snd_soc_component_read(component, MADERA_INPUT_ENABLES);
if (ret)
goto exit;
mask = (mc->reg - MADERA_ADC_DIGITAL_VOLUME_1L) / 4; mask = (mc->reg - MADERA_ADC_DIGITAL_VOLUME_1L) / 4;
mask ^= 0x1; /* Flip bottom bit for channel order */ 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, ...@@ -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 snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
struct madera_priv *priv = snd_soc_component_get_drvdata(component); struct madera_priv *priv = snd_soc_component_get_drvdata(component);
unsigned int reg, val; unsigned int reg, val;
int ret;
if (w->shift % 2) if (w->shift % 2)
reg = MADERA_ADC_DIGITAL_VOLUME_1L + ((w->shift / 2) * 8); 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, ...@@ -2305,9 +2290,8 @@ int madera_in_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol,
break; break;
case SND_SOC_DAPM_POST_PMD: case SND_SOC_DAPM_POST_PMD:
/* Disable volume updates if no inputs are enabled */ /* Disable volume updates if no inputs are enabled */
ret = snd_soc_component_read(component, MADERA_INPUT_ENABLES, val = snd_soc_component_read(component, MADERA_INPUT_ENABLES);
&val); if (!val)
if (!ret && !val)
madera_in_set_vu(priv, false); madera_in_set_vu(priv, false);
break; break;
default: default:
...@@ -3087,26 +3071,16 @@ static int madera_aif_cfg_changed(struct snd_soc_component *component, ...@@ -3087,26 +3071,16 @@ static int madera_aif_cfg_changed(struct snd_soc_component *component,
int base, int bclk, int lrclk, int frame) int base, int bclk, int lrclk, int frame)
{ {
unsigned int val; unsigned int val;
int ret;
ret = snd_soc_component_read(component, base + MADERA_AIF_BCLK_CTRL, val = snd_soc_component_read(component, base + MADERA_AIF_BCLK_CTRL);
&val);
if (ret)
return ret;
if (bclk != (val & MADERA_AIF1_BCLK_FREQ_MASK)) if (bclk != (val & MADERA_AIF1_BCLK_FREQ_MASK))
return 1; return 1;
ret = snd_soc_component_read(component, base + MADERA_AIF_RX_BCLK_RATE, val = snd_soc_component_read(component, base + MADERA_AIF_RX_BCLK_RATE);
&val);
if (ret)
return ret;
if (lrclk != (val & MADERA_AIF1RX_BCPF_MASK)) if (lrclk != (val & MADERA_AIF1RX_BCPF_MASK))
return 1; return 1;
ret = snd_soc_component_read(component, base + MADERA_AIF_FRAME_CTRL_1, val = snd_soc_component_read(component, base + MADERA_AIF_FRAME_CTRL_1);
&val);
if (ret)
return ret;
if (frame != (val & (MADERA_AIF1TX_WL_MASK | if (frame != (val & (MADERA_AIF1TX_WL_MASK |
MADERA_AIF1TX_SLOT_LEN_MASK))) MADERA_AIF1TX_SLOT_LEN_MASK)))
return 1; return 1;
...@@ -3162,10 +3136,7 @@ static int madera_hw_params(struct snd_pcm_substream *substream, ...@@ -3162,10 +3136,7 @@ static int madera_hw_params(struct snd_pcm_substream *substream,
} }
/* Force multiple of 2 channels for I2S mode */ /* Force multiple of 2 channels for I2S mode */
ret = snd_soc_component_read(component, base + MADERA_AIF_FORMAT, &val); val = snd_soc_component_read(component, base + MADERA_AIF_FORMAT);
if (ret)
return ret;
val &= MADERA_AIF1_FMT_MASK; val &= MADERA_AIF1_FMT_MASK;
if ((channels & 1) && val == MADERA_FMT_I2S_MODE) { if ((channels & 1) && val == MADERA_FMT_I2S_MODE) {
madera_aif_dbg(dai, "Forcing stereo mode\n"); madera_aif_dbg(dai, "Forcing stereo mode\n");
......
...@@ -831,7 +831,7 @@ static int nau8822_hw_params(struct snd_pcm_substream *substream, ...@@ -831,7 +831,7 @@ static int nau8822_hw_params(struct snd_pcm_substream *substream,
unsigned int ctrl_val, bclk_fs, bclk_div; unsigned int ctrl_val, bclk_fs, bclk_div;
/* make BCLK and LRC divide configuration if the codec as master. */ /* 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) { if (ctrl_val & NAU8822_CLK_MASTER) {
/* get the bclk and fs ratio */ /* get the bclk and fs ratio */
bclk_fs = snd_soc_params_to_bclk(params) / params_rate(params); bclk_fs = snd_soc_params_to_bclk(params) / params_rate(params);
......
...@@ -411,7 +411,7 @@ static int rt1305_is_rc_clk_from_pll(struct snd_soc_dapm_widget *source, ...@@ -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); struct rt1305_priv *rt1305 = snd_soc_component_get_drvdata(component);
unsigned int val; 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 && if (rt1305->sysclk_src == RT1305_FS_SYS_PRE_S_PLL1 &&
(val & RT1305_SEL_PLL_SRC_2_RCCLK)) (val & RT1305_SEL_PLL_SRC_2_RCCLK))
......
...@@ -2640,8 +2640,7 @@ static unsigned long rt5682_bclk_recalc_rate(struct clk_hw *hw, ...@@ -2640,8 +2640,7 @@ static unsigned long rt5682_bclk_recalc_rate(struct clk_hw *hw,
struct snd_soc_component *component = rt5682->component; struct snd_soc_component *component = rt5682->component;
unsigned int bclks_per_wclk; unsigned int bclks_per_wclk;
snd_soc_component_read(component, RT5682_TDM_TCON_CTRL, bclks_per_wclk = snd_soc_component_read(component, RT5682_TDM_TCON_CTRL);
&bclks_per_wclk);
switch (bclks_per_wclk & RT5682_TDM_BCLK_MS1_MASK) { switch (bclks_per_wclk & RT5682_TDM_BCLK_MS1_MASK) {
case RT5682_TDM_BCLK_MS1_256: case RT5682_TDM_BCLK_MS1_256:
......
...@@ -508,10 +508,10 @@ static int tas5722_volume_get(struct snd_kcontrol *kcontrol, ...@@ -508,10 +508,10 @@ static int tas5722_volume_get(struct snd_kcontrol *kcontrol,
struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
unsigned int val; 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; 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; ucontrol->value.integer.value[0] |= val & TAS5722_VOL_CONTROL_LSB;
return 0; return 0;
......
...@@ -187,18 +187,13 @@ static int tda7419_vol_get(struct snd_kcontrol *kcontrol, ...@@ -187,18 +187,13 @@ static int tda7419_vol_get(struct snd_kcontrol *kcontrol,
int thresh = tvc->thresh; int thresh = tvc->thresh;
unsigned int invert = tvc->invert; unsigned int invert = tvc->invert;
int val; int val;
int ret;
ret = snd_soc_component_read(component, reg, &val); val = snd_soc_component_read(component, reg);
if (ret < 0)
return ret;
ucontrol->value.integer.value[0] = ucontrol->value.integer.value[0] =
tda7419_vol_get_value(val, mask, min, thresh, invert); tda7419_vol_get_value(val, mask, min, thresh, invert);
if (tda7419_vol_is_stereo(tvc)) { if (tda7419_vol_is_stereo(tvc)) {
ret = snd_soc_component_read(component, rreg, &val); val = snd_soc_component_read(component, rreg);
if (ret < 0)
return ret;
ucontrol->value.integer.value[1] = ucontrol->value.integer.value[1] =
tda7419_vol_get_value(val, mask, min, thresh, invert); tda7419_vol_get_value(val, mask, min, thresh, invert);
} }
......
...@@ -353,12 +353,7 @@ static int write_coeff_ram(struct snd_soc_component *component, u8 *coeff_ram, ...@@ -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 (cnt = 0; cnt < coeff_cnt; cnt++, coeff_addr++) {
for (trys = 0; trys < DACCRSTAT_MAX_TRYS; trys++) { for (trys = 0; trys < DACCRSTAT_MAX_TRYS; trys++) {
ret = snd_soc_component_read(component, r_stat, &val); val = snd_soc_component_read(component, r_stat);
if (ret < 0) {
dev_err(component->dev,
"Failed to read stat (%d)\n", ret);
return ret;
}
if (!val) if (!val)
break; break;
} }
...@@ -444,12 +439,7 @@ static int coeff_ram_put(struct snd_kcontrol *kcontrol, ...@@ -444,12 +439,7 @@ static int coeff_ram_put(struct snd_kcontrol *kcontrol,
mutex_lock(&tscs454->pll1.lock); mutex_lock(&tscs454->pll1.lock);
mutex_lock(&tscs454->pll2.lock); mutex_lock(&tscs454->pll2.lock);
ret = snd_soc_component_read(component, R_PLLSTAT, &val); val = snd_soc_component_read(component, R_PLLSTAT);
if (ret < 0) {
dev_err(component->dev, "Failed to read PLL status (%d)\n",
ret);
goto exit;
}
if (val) { /* PLLs locked */ if (val) { /* PLLs locked */
ret = write_coeff_ram(component, coeff_ram, ret = write_coeff_ram(component, coeff_ram,
r_stat, r_addr, r_wr, r_stat, r_addr, r_wr,
...@@ -2642,13 +2632,10 @@ static int tscs454_set_sysclk(struct snd_soc_dai *dai, ...@@ -2642,13 +2632,10 @@ static int tscs454_set_sysclk(struct snd_soc_dai *dai,
struct tscs454 *tscs454 = snd_soc_component_get_drvdata(component); struct tscs454 *tscs454 = snd_soc_component_get_drvdata(component);
unsigned int val; unsigned int val;
int bclk_dai; int bclk_dai;
int ret;
dev_dbg(component->dev, "%s(): freq = %u\n", __func__, freq); dev_dbg(component->dev, "%s(): freq = %u\n", __func__, freq);
ret = snd_soc_component_read(component, R_PLLCTL, &val); val = snd_soc_component_read(component, R_PLLCTL);
if (ret < 0)
return ret;
bclk_dai = (val & FM_PLLCTL_BCLKSEL) >> FB_PLLCTL_BCLKSEL; bclk_dai = (val & FM_PLLCTL_BCLKSEL) >> FB_PLLCTL_BCLKSEL;
if (bclk_dai != dai->id) if (bclk_dai != dai->id)
...@@ -3204,10 +3191,7 @@ static int tscs454_hw_params(struct snd_pcm_substream *substream, ...@@ -3204,10 +3191,7 @@ static int tscs454_hw_params(struct snd_pcm_substream *substream,
} }
if (!aifs_active(&tscs454->aifs_status)) { /* First active aif */ if (!aifs_active(&tscs454->aifs_status)) { /* First active aif */
ret = snd_soc_component_read(component, R_ISRC, &val); val = snd_soc_component_read(component, R_ISRC);
if (ret < 0)
goto exit;
if ((val & FM_ISRC_IBR) == FV_IBR_48) if ((val & FM_ISRC_IBR) == FV_IBR_48)
tscs454->internal_rate.pll = &tscs454->pll1; tscs454->internal_rate.pll = &tscs454->pll1;
else else
......
...@@ -116,13 +116,9 @@ static int fsl_audmix_put_mix_clk_src(struct snd_kcontrol *kcontrol, ...@@ -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; struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
unsigned int *item = ucontrol->value.enumerated.item; unsigned int *item = ucontrol->value.enumerated.item;
unsigned int reg_val, val, mix_clk; unsigned int reg_val, val, mix_clk;
int ret;
/* Get current state */ /* Get current state */
ret = snd_soc_component_read(comp, FSL_AUDMIX_CTR, &reg_val); reg_val = snd_soc_component_read(comp, FSL_AUDMIX_CTR);
if (ret)
return ret;
mix_clk = ((reg_val & FSL_AUDMIX_CTR_MIXCLK_MASK) mix_clk = ((reg_val & FSL_AUDMIX_CTR_MIXCLK_MASK)
>> FSL_AUDMIX_CTR_MIXCLK_SHIFT); >> FSL_AUDMIX_CTR_MIXCLK_SHIFT);
val = snd_soc_enum_item_to_val(e, item[0]); 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, ...@@ -162,9 +158,7 @@ static int fsl_audmix_put_out_src(struct snd_kcontrol *kcontrol,
int ret; int ret;
/* Get current state */ /* Get current state */
ret = snd_soc_component_read(comp, FSL_AUDMIX_CTR, &reg_val); reg_val = snd_soc_component_read(comp, FSL_AUDMIX_CTR);
if (ret)
return ret;
/* "From" state */ /* "From" state */
out_src = ((reg_val & FSL_AUDMIX_CTR_OUTSRC_MASK) out_src = ((reg_val & FSL_AUDMIX_CTR_OUTSRC_MASK)
......
...@@ -79,11 +79,8 @@ static int fsl_easrc_get_reg(struct snd_kcontrol *kcontrol, ...@@ -79,11 +79,8 @@ static int fsl_easrc_get_reg(struct snd_kcontrol *kcontrol,
struct soc_mreg_control *mc = struct soc_mreg_control *mc =
(struct soc_mreg_control *)kcontrol->private_value; (struct soc_mreg_control *)kcontrol->private_value;
unsigned int regval; unsigned int regval;
int ret;
ret = snd_soc_component_read(component, mc->regbase, &regval); regval = snd_soc_component_read(component, mc->regbase);
if (ret < 0)
return ret;
ucontrol->value.integer.value[0] = regval; ucontrol->value.integer.value[0] = regval;
......
...@@ -72,11 +72,10 @@ static int aiu_encoder_i2s_setup_desc(struct snd_soc_component *component, ...@@ -72,11 +72,10 @@ static int aiu_encoder_i2s_setup_desc(struct snd_soc_component *component,
{ {
/* Always operate in split (classic interleaved) mode */ /* Always operate in split (classic interleaved) mode */
unsigned int desc = AIU_I2S_SOURCE_DESC_MODE_SPLIT; unsigned int desc = AIU_I2S_SOURCE_DESC_MODE_SPLIT;
unsigned int val;
/* Reset required to update the pipeline */ /* Reset required to update the pipeline */
snd_soc_component_write(component, AIU_RST_SOFT, AIU_RST_SOFT_I2S_FAST); 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)) { switch (params_physical_width(params)) {
case 16: /* Nothing to do */ case 16: /* Nothing to do */
......
...@@ -46,7 +46,6 @@ static int aiu_fifo_i2s_trigger(struct snd_pcm_substream *substream, int cmd, ...@@ -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_dai *dai)
{ {
struct snd_soc_component *component = dai->component; struct snd_soc_component *component = dai->component;
unsigned int val;
switch (cmd) { switch (cmd) {
case SNDRV_PCM_TRIGGER_START: case SNDRV_PCM_TRIGGER_START:
...@@ -54,7 +53,7 @@ static int aiu_fifo_i2s_trigger(struct snd_pcm_substream *substream, int cmd, ...@@ -54,7 +53,7 @@ static int aiu_fifo_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
snd_soc_component_write(component, AIU_RST_SOFT, snd_soc_component_write(component, AIU_RST_SOFT,
AIU_RST_SOFT_I2S_FAST); AIU_RST_SOFT_I2S_FAST);
snd_soc_component_read(component, AIU_I2S_SYNC, &val); snd_soc_component_read(component, AIU_I2S_SYNC);
break; break;
} }
......
...@@ -37,8 +37,7 @@ snd_pcm_uframes_t aiu_fifo_pointer(struct snd_soc_component *component, ...@@ -37,8 +37,7 @@ snd_pcm_uframes_t aiu_fifo_pointer(struct snd_soc_component *component,
struct snd_pcm_runtime *runtime = substream->runtime; struct snd_pcm_runtime *runtime = substream->runtime;
unsigned int addr; unsigned int addr;
snd_soc_component_read(component, fifo->mem_offset + AIU_MEM_RD, addr = snd_soc_component_read(component, fifo->mem_offset + AIU_MEM_RD);
&addr);
return bytes_to_frames(runtime, addr - (unsigned int)runtime->dma_addr); return bytes_to_frames(runtime, addr - (unsigned int)runtime->dma_addr);
} }
......
...@@ -82,13 +82,12 @@ static int snd_soc_ac97_gpio_get(struct gpio_chip *chip, unsigned offset) ...@@ -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); struct snd_soc_component *component = gpio_to_component(chip);
int ret; int ret;
if (snd_soc_component_read(component, AC97_GPIO_STATUS, &ret) < 0) ret = snd_soc_component_read(component, AC97_GPIO_STATUS);
ret = -1;
dev_dbg(component->dev, "get gpio %d : %d\n", offset, 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, static void snd_soc_ac97_gpio_set(struct gpio_chip *chip, unsigned offset,
......
...@@ -407,41 +407,30 @@ EXPORT_SYMBOL_GPL(snd_soc_component_exit_regmap); ...@@ -407,41 +407,30 @@ EXPORT_SYMBOL_GPL(snd_soc_component_exit_regmap);
* snd_soc_component_read() - Read register value * snd_soc_component_read() - Read register value
* @component: Component to read from * @component: Component to read from
* @reg: Register to read * @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 snd_soc_component_read(struct snd_soc_component *component,
unsigned int reg, unsigned int *val) unsigned int reg)
{ {
int ret; int ret;
unsigned int val = 0;
if (component->regmap) if (component->regmap)
ret = regmap_read(component->regmap, reg, val); ret = regmap_read(component->regmap, reg, &val);
else if (component->driver->read) { else if (component->driver->read) {
*val = component->driver->read(component, reg);
ret = 0; ret = 0;
val = component->driver->read(component, reg);
} }
else else
ret = -EIO; 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) if (ret < 0)
return soc_component_ret(component, -1); soc_component_ret(component, ret);
return val; return val;
} }
EXPORT_SYMBOL_GPL(snd_soc_component_read32); EXPORT_SYMBOL_GPL(snd_soc_component_read);
/** /**
* snd_soc_component_write() - Write register value * snd_soc_component_write() - Write register value
...@@ -470,19 +459,17 @@ static int snd_soc_component_update_bits_legacy( ...@@ -470,19 +459,17 @@ static int snd_soc_component_update_bits_legacy(
unsigned int mask, unsigned int val, bool *change) unsigned int mask, unsigned int val, bool *change)
{ {
unsigned int old, new; unsigned int old, new;
int ret; int ret = 0;
mutex_lock(&component->io_mutex); mutex_lock(&component->io_mutex);
ret = snd_soc_component_read(component, reg, &old); old = snd_soc_component_read(component, reg);
if (ret < 0)
goto out_unlock;
new = (old & ~mask) | (val & mask); new = (old & ~mask) | (val & mask);
*change = old != new; *change = old != new;
if (*change) if (*change)
ret = snd_soc_component_write(component, reg, new); ret = snd_soc_component_write(component, reg, new);
out_unlock:
mutex_unlock(&component->io_mutex); mutex_unlock(&component->io_mutex);
return soc_component_ret(component, ret); return soc_component_ret(component, ret);
...@@ -584,11 +571,8 @@ int snd_soc_component_test_bits(struct snd_soc_component *component, ...@@ -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 reg, unsigned int mask, unsigned int value)
{ {
unsigned int old, new; unsigned int old, new;
int ret;
ret = snd_soc_component_read(component, reg, &old); old = snd_soc_component_read(component, reg);
if (ret < 0)
return soc_component_ret(component, ret);
new = (old & ~mask) | value; new = (old & ~mask) | value;
return old != new; return old != new;
} }
......
...@@ -616,12 +616,11 @@ static const char *soc_dapm_prefix(struct snd_soc_dapm_context *dapm) ...@@ -616,12 +616,11 @@ static const char *soc_dapm_prefix(struct snd_soc_dapm_context *dapm)
return dapm->component->name_prefix; return dapm->component->name_prefix;
} }
static int soc_dapm_read(struct snd_soc_dapm_context *dapm, int reg, static unsigned int soc_dapm_read(struct snd_soc_dapm_context *dapm, int reg)
unsigned int *value)
{ {
if (!dapm->component) if (!dapm->component)
return -EIO; 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, 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, ...@@ -753,7 +752,7 @@ static int dapm_connect_mux(struct snd_soc_dapm_context *dapm,
int i; int i;
if (e->reg != SND_SOC_NOPM) { 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; val = (val >> e->shift_l) & e->mask;
item = snd_soc_enum_val_to_item(e, val); item = snd_soc_enum_val_to_item(e, val);
} else { } else {
...@@ -790,7 +789,7 @@ static void dapm_set_mixer_path_status(struct snd_soc_dapm_path *p, int i, ...@@ -790,7 +789,7 @@ static void dapm_set_mixer_path_status(struct snd_soc_dapm_path *p, int i,
unsigned int val; unsigned int val;
if (reg != SND_SOC_NOPM) { 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 * The nth_path argument allows this function to know
* which path of a kcontrol it is setting the initial * 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, ...@@ -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 (snd_soc_volsw_is_stereo(mc) && nth_path > 0) {
if (reg != mc->rreg) 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; val = (val >> mc->rshift) & mask;
} else { } else {
val = (val >> shift) & mask; val = (val >> shift) & mask;
...@@ -3246,7 +3245,7 @@ int snd_soc_dapm_new_widgets(struct snd_soc_card *card) ...@@ -3246,7 +3245,7 @@ int snd_soc_dapm_new_widgets(struct snd_soc_card *card)
/* Read the initial power state from the device */ /* Read the initial power state from the device */
if (w->reg >= 0) { 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 = val >> w->shift;
val &= w->mask; val &= w->mask;
if (val == w->on_val) if (val == w->on_val)
...@@ -3288,15 +3287,14 @@ int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol, ...@@ -3288,15 +3287,14 @@ int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol,
unsigned int mask = (1 << fls(max)) - 1; unsigned int mask = (1 << fls(max)) - 1;
unsigned int invert = mc->invert; unsigned int invert = mc->invert;
unsigned int reg_val, val, rval = 0; unsigned int reg_val, val, rval = 0;
int ret = 0;
mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
if (dapm_kcontrol_is_powered(kcontrol) && reg != SND_SOC_NOPM) { 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; val = (reg_val >> shift) & mask;
if (ret == 0 && reg != mc->rreg) if (reg != mc->rreg)
ret = soc_dapm_read(dapm, mc->rreg, &reg_val); reg_val = soc_dapm_read(dapm, mc->rreg);
if (snd_soc_volsw_is_stereo(mc)) if (snd_soc_volsw_is_stereo(mc))
rval = (reg_val >> mc->rshift) & mask; rval = (reg_val >> mc->rshift) & mask;
...@@ -3309,9 +3307,6 @@ int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol, ...@@ -3309,9 +3307,6 @@ int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol,
} }
mutex_unlock(&card->dapm_mutex); mutex_unlock(&card->dapm_mutex);
if (ret)
return ret;
if (invert) if (invert)
ucontrol->value.integer.value[0] = max - val; ucontrol->value.integer.value[0] = max - val;
else else
...@@ -3324,7 +3319,7 @@ int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol, ...@@ -3324,7 +3319,7 @@ int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol,
ucontrol->value.integer.value[1] = rval; ucontrol->value.integer.value[1] = rval;
} }
return ret; return 0;
} }
EXPORT_SYMBOL_GPL(snd_soc_dapm_get_volsw); EXPORT_SYMBOL_GPL(snd_soc_dapm_get_volsw);
...@@ -3439,11 +3434,7 @@ int snd_soc_dapm_get_enum_double(struct snd_kcontrol *kcontrol, ...@@ -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); mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
if (e->reg != SND_SOC_NOPM && dapm_kcontrol_is_powered(kcontrol)) { if (e->reg != SND_SOC_NOPM && dapm_kcontrol_is_powered(kcontrol)) {
int ret = soc_dapm_read(dapm, e->reg, &reg_val); reg_val = soc_dapm_read(dapm, e->reg);
if (ret) {
mutex_unlock(&card->dapm_mutex);
return ret;
}
} else { } else {
reg_val = dapm_kcontrol_get_value(kcontrol); reg_val = dapm_kcontrol_get_value(kcontrol);
} }
......
...@@ -63,11 +63,8 @@ int snd_soc_get_enum_double(struct snd_kcontrol *kcontrol, ...@@ -63,11 +63,8 @@ int snd_soc_get_enum_double(struct snd_kcontrol *kcontrol,
struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
unsigned int val, item; unsigned int val, item;
unsigned int reg_val; unsigned int reg_val;
int ret;
ret = snd_soc_component_read(component, e->reg, &reg_val); reg_val = snd_soc_component_read(component, e->reg);
if (ret)
return ret;
val = (reg_val >> e->shift_l) & e->mask; val = (reg_val >> e->shift_l) & e->mask;
item = snd_soc_enum_val_to_item(e, val); item = snd_soc_enum_val_to_item(e, val);
ucontrol->value.enumerated.item[0] = item; ucontrol->value.enumerated.item[0] = item;
...@@ -136,10 +133,7 @@ static int snd_soc_read_signed(struct snd_soc_component *component, ...@@ -136,10 +133,7 @@ static int snd_soc_read_signed(struct snd_soc_component *component,
int ret; int ret;
unsigned int val; unsigned int val;
ret = snd_soc_component_read(component, reg, &val); val = snd_soc_component_read(component, reg);
if (ret < 0)
return ret;
val = (val >> shift) & mask; val = (val >> shift) & mask;
if (!sign_bit) { if (!sign_bit) {
...@@ -375,19 +369,12 @@ int snd_soc_get_volsw_sx(struct snd_kcontrol *kcontrol, ...@@ -375,19 +369,12 @@ int snd_soc_get_volsw_sx(struct snd_kcontrol *kcontrol,
int min = mc->min; int min = mc->min;
unsigned int mask = (1U << (fls(min + max) - 1)) - 1; unsigned int mask = (1U << (fls(min + max) - 1)) - 1;
unsigned int val; 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; ucontrol->value.integer.value[0] = ((val >> shift) - min) & mask;
if (snd_soc_volsw_is_stereo(mc)) { if (snd_soc_volsw_is_stereo(mc)) {
ret = snd_soc_component_read(component, reg2, &val); val = snd_soc_component_read(component, reg2);
if (ret < 0)
return ret;
val = ((val >> rshift) - min) & mask; val = ((val >> rshift) - min) & mask;
ucontrol->value.integer.value[1] = val; ucontrol->value.integer.value[1] = val;
} }
...@@ -548,12 +535,8 @@ int snd_soc_get_volsw_range(struct snd_kcontrol *kcontrol, ...@@ -548,12 +535,8 @@ int snd_soc_get_volsw_range(struct snd_kcontrol *kcontrol,
unsigned int mask = (1 << fls(max)) - 1; unsigned int mask = (1 << fls(max)) - 1;
unsigned int invert = mc->invert; unsigned int invert = mc->invert;
unsigned int val; 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; ucontrol->value.integer.value[0] = (val >> shift) & mask;
if (invert) if (invert)
ucontrol->value.integer.value[0] = ucontrol->value.integer.value[0] =
...@@ -563,10 +546,7 @@ int snd_soc_get_volsw_range(struct snd_kcontrol *kcontrol, ...@@ -563,10 +546,7 @@ int snd_soc_get_volsw_range(struct snd_kcontrol *kcontrol,
ucontrol->value.integer.value[0] - min; ucontrol->value.integer.value[0] - min;
if (snd_soc_volsw_is_stereo(mc)) { if (snd_soc_volsw_is_stereo(mc)) {
ret = snd_soc_component_read(component, rreg, &val); val = snd_soc_component_read(component, rreg);
if (ret)
return ret;
ucontrol->value.integer.value[1] = (val >> shift) & mask; ucontrol->value.integer.value[1] = (val >> shift) & mask;
if (invert) if (invert)
ucontrol->value.integer.value[1] = ucontrol->value.integer.value[1] =
...@@ -833,12 +813,9 @@ int snd_soc_get_xr_sx(struct snd_kcontrol *kcontrol, ...@@ -833,12 +813,9 @@ int snd_soc_get_xr_sx(struct snd_kcontrol *kcontrol,
long val = 0; long val = 0;
unsigned int regval; unsigned int regval;
unsigned int i; unsigned int i;
int ret;
for (i = 0; i < regcount; i++) { for (i = 0; i < regcount; i++) {
ret = snd_soc_component_read(component, regbase+i, &regval); regval = snd_soc_component_read(component, regbase+i);
if (ret)
return ret;
val |= (regval & regwmask) << (regwshift*(regcount-i-1)); val |= (regval & regwmask) << (regwshift*(regcount-i-1));
} }
val &= mask; val &= mask;
...@@ -918,12 +895,8 @@ int snd_soc_get_strobe(struct snd_kcontrol *kcontrol, ...@@ -918,12 +895,8 @@ int snd_soc_get_strobe(struct snd_kcontrol *kcontrol,
unsigned int mask = 1 << shift; unsigned int mask = 1 << shift;
unsigned int invert = mc->invert != 0; unsigned int invert = mc->invert != 0;
unsigned int val; 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; val &= mask;
if (shift != 0 && val != 0) if (shift != 0 && val != 0)
......
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