Merge "ASoC: bolero: check for port validation before configuration"

This commit is contained in:
qctecmdr 2019-08-25 03:14:53 -07:00 • committed by Gerrit - the friendly Code Review server
commit efdfdf2782
2 changed files with 29 additions and 8 deletions

View file

@ -1798,14 +1798,23 @@ static int rx_macro_mux_put(struct snd_kcontrol *kcontrol,
dev_err(rx_dev, "%s:AIF reset already\n", __func__);
return 0;
}
if (aif_rst > RX_MACRO_AIF4_PB) {
dev_err(rx_dev, "%s: Invalid AIF reset\n", __func__);
return 0;
}
}
rx_priv->rx_port_value[widget->shift] = rx_port_value;
dev_dbg(rx_dev, "%s: mux input: %d, mux output: %d, aif_rst: %d\n",
__func__, rx_port_value, widget->shift, aif_rst);
switch (rx_port_value) {
case 0:
clear_bit(widget->shift,
&rx_priv->active_ch_mask[aif_rst]);
rx_priv->active_ch_cnt[aif_rst]--;
if (rx_priv->active_ch_cnt[aif_rst]) {
clear_bit(widget->shift,
&rx_priv->active_ch_mask[aif_rst]);
rx_priv->active_ch_cnt[aif_rst]--;
}
break;
case 1:
case 2:
@ -1817,7 +1826,8 @@ static int rx_macro_mux_put(struct snd_kcontrol *kcontrol,
break;
default:
dev_err(component->dev,
"%s:Invalid AIF_ID for RX_MACRO MUX\n", __func__);
"%s:Invalid AIF_ID for RX_MACRO MUX %d\n",
__func__, rx_port_value);
goto err;
}

View file

@ -2057,6 +2057,10 @@ static int wsa_macro_rx_mux_put(struct snd_kcontrol *kcontrol,
dev_err(wsa_dev, "%s: AIF reset already\n", __func__);
return 0;
}
if (aif_rst >= WSA_MACRO_RX_MAX) {
dev_err(wsa_dev, "%s: Invalid AIF reset\n", __func__);
return 0;
}
}
wsa_priv->rx_port_value[widget->shift] = rx_port_value;
@ -2064,11 +2068,17 @@ static int wsa_macro_rx_mux_put(struct snd_kcontrol *kcontrol,
if (widget->shift >= WSA_MACRO_RX_MIX)
bit_input %= WSA_MACRO_RX_MIX;
dev_dbg(wsa_dev,
"%s: mux input: %d, mux output: %d, bit: %d\n",
__func__, rx_port_value, widget->shift, bit_input);
switch (rx_port_value) {
case 0:
clear_bit(bit_input,
&wsa_priv->active_ch_mask[aif_rst]);
wsa_priv->active_ch_cnt[aif_rst]--;
if (wsa_priv->active_ch_cnt[aif_rst]) {
clear_bit(bit_input,
&wsa_priv->active_ch_mask[aif_rst]);
wsa_priv->active_ch_cnt[aif_rst]--;
}
break;
case 1:
case 2:
@ -2078,7 +2088,8 @@ static int wsa_macro_rx_mux_put(struct snd_kcontrol *kcontrol,
break;
default:
dev_err(wsa_dev,
"%s: Invalid AIF_ID for WSA RX MUX\n", __func__);
"%s: Invalid AIF_ID for WSA RX MUX %d\n",
__func__, rx_port_value);
return -EINVAL;
}