asoc: common: modify the incorrect comparsion
In case of error scenario for get_tdm_clk_id/get_mi2s_clk_id, storing the return value into uint32 clk_id which is always positive and does not handle the invalid clk ids failure. So modify the incorrect comparsion. Change-Id: I1e606709cd3c11a24a39679bcee638a045804961 Signed-off-by: Prasad Kumpatla <pkumpatl@codeaurora.org>
This commit is contained in:

committed by
Gerrit - the friendly Code Review server

parent
ffbb0c4a5b
commit
fd473434d7
@@ -278,7 +278,7 @@ static bool is_fractional_sample_rate(unsigned int sample_rate)
|
|||||||
|
|
||||||
static int get_mi2s_clk_id(int index)
|
static int get_mi2s_clk_id(int index)
|
||||||
{
|
{
|
||||||
int clk_id;
|
int clk_id = -EINVAL;
|
||||||
|
|
||||||
switch(index) {
|
switch(index) {
|
||||||
case PRI_MI2S_TDM_AUXPCM:
|
case PRI_MI2S_TDM_AUXPCM:
|
||||||
@@ -301,7 +301,6 @@ static int get_mi2s_clk_id(int index)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
pr_err("%s: Invalid interface index: %d\n", __func__, index);
|
pr_err("%s: Invalid interface index: %d\n", __func__, index);
|
||||||
clk_id = -EINVAL;
|
|
||||||
}
|
}
|
||||||
pr_debug("%s: clk id: %d\n", __func__, clk_id);
|
pr_debug("%s: clk id: %d\n", __func__, clk_id);
|
||||||
return clk_id;
|
return clk_id;
|
||||||
@@ -309,7 +308,7 @@ static int get_mi2s_clk_id(int index)
|
|||||||
|
|
||||||
static int get_tdm_clk_id(int index)
|
static int get_tdm_clk_id(int index)
|
||||||
{
|
{
|
||||||
int clk_id;
|
int clk_id = -EINVAL;
|
||||||
|
|
||||||
switch(index) {
|
switch(index) {
|
||||||
case PRI_MI2S_TDM_AUXPCM:
|
case PRI_MI2S_TDM_AUXPCM:
|
||||||
@@ -332,7 +331,6 @@ static int get_tdm_clk_id(int index)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
pr_err("%s: Invalid interface index: %d\n", __func__, index);
|
pr_err("%s: Invalid interface index: %d\n", __func__, index);
|
||||||
clk_id = -EINVAL;
|
|
||||||
}
|
}
|
||||||
pr_debug("%s: clk id: %d\n", __func__, clk_id);
|
pr_debug("%s: clk id: %d\n", __func__, clk_id);
|
||||||
return clk_id;
|
return clk_id;
|
||||||
@@ -401,14 +399,11 @@ int msm_common_snd_hw_params(struct snd_pcm_substream *substream,
|
|||||||
slots = pdata->tdm_max_slots;
|
slots = pdata->tdm_max_slots;
|
||||||
rate = params_rate(params);
|
rate = params_rate(params);
|
||||||
|
|
||||||
intf_clk_cfg.clk_id = get_tdm_clk_id(index);
|
ret = get_tdm_clk_id(index);
|
||||||
if (intf_clk_cfg.clk_id < 0) {
|
if ( ret < 0)
|
||||||
ret = -EINVAL;
|
|
||||||
pr_err("%s: Invalid tdm clk id %d", __func__,
|
|
||||||
intf_clk_cfg.clk_id);
|
|
||||||
goto done;
|
goto done;
|
||||||
}
|
|
||||||
|
|
||||||
|
intf_clk_cfg.clk_id = ret;
|
||||||
intf_clk_cfg.clk_freq_in_hz = rate * slot_width * slots;
|
intf_clk_cfg.clk_freq_in_hz = rate * slot_width * slots;
|
||||||
intf_clk_cfg.clk_attri = pdata->tdm_clk_attribute[index];
|
intf_clk_cfg.clk_attri = pdata->tdm_clk_attribute[index];
|
||||||
intf_clk_cfg.clk_root = 0;
|
intf_clk_cfg.clk_root = 0;
|
||||||
@@ -432,13 +427,11 @@ int msm_common_snd_hw_params(struct snd_pcm_substream *substream,
|
|||||||
}
|
}
|
||||||
} else if ((strnstr(stream_name, "MI2S", strlen(stream_name)))) {
|
} else if ((strnstr(stream_name, "MI2S", strlen(stream_name)))) {
|
||||||
|
|
||||||
intf_clk_cfg.clk_id = get_mi2s_clk_id(index);
|
ret = get_mi2s_clk_id(index);
|
||||||
if (intf_clk_cfg.clk_id < 0) {
|
if (ret < 0)
|
||||||
ret = -EINVAL;
|
|
||||||
pr_err("%s: Invalid mi2s clk id %d", __func__,
|
|
||||||
intf_clk_cfg.clk_id);
|
|
||||||
goto done;
|
goto done;
|
||||||
}
|
|
||||||
|
intf_clk_cfg.clk_id = ret;
|
||||||
rate = params_rate(params);
|
rate = params_rate(params);
|
||||||
switch (params_format(params)) {
|
switch (params_format(params)) {
|
||||||
case SNDRV_PCM_FORMAT_S24_LE:
|
case SNDRV_PCM_FORMAT_S24_LE:
|
||||||
@@ -554,21 +547,23 @@ void msm_common_snd_shutdown(struct snd_pcm_substream *substream)
|
|||||||
atomic_dec(&pdata->lpass_intf_clk_ref_cnt[index]);
|
atomic_dec(&pdata->lpass_intf_clk_ref_cnt[index]);
|
||||||
if (atomic_read(&pdata->lpass_intf_clk_ref_cnt[index]) == 0) {
|
if (atomic_read(&pdata->lpass_intf_clk_ref_cnt[index]) == 0) {
|
||||||
if ((strnstr(stream_name, "TDM", strlen(stream_name)))) {
|
if ((strnstr(stream_name, "TDM", strlen(stream_name)))) {
|
||||||
intf_clk_cfg.clk_id = get_tdm_clk_id(index);
|
ret = get_tdm_clk_id(index);
|
||||||
pr_debug("%s: Disable tdm clock ID: %d\n",
|
if (ret > 0) {
|
||||||
__func__, intf_clk_cfg.clk_id);
|
intf_clk_cfg.clk_id = ret;
|
||||||
ret = audio_prm_set_lpass_clk_cfg(&intf_clk_cfg, 0);
|
ret = audio_prm_set_lpass_clk_cfg(&intf_clk_cfg, 0);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
pr_err("%s: prm tdm clk cfg set failed ret %d\n",
|
pr_err("%s: prm tdm clk cfg set failed ret %d\n",
|
||||||
__func__, ret);
|
__func__, ret);
|
||||||
|
}
|
||||||
} else if((strnstr(stream_name, "MI2S", strlen(stream_name)))) {
|
} else if((strnstr(stream_name, "MI2S", strlen(stream_name)))) {
|
||||||
intf_clk_cfg.clk_id = get_mi2s_clk_id(index);
|
ret = get_mi2s_clk_id(index);
|
||||||
pr_debug("%s: Disable mi2s clock ID: %d\n",
|
if (ret > 0) {
|
||||||
__func__, intf_clk_cfg.clk_id);
|
intf_clk_cfg.clk_id = ret;
|
||||||
ret = audio_prm_set_lpass_clk_cfg(&intf_clk_cfg, 0);
|
ret = audio_prm_set_lpass_clk_cfg(&intf_clk_cfg, 0);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
pr_err("%s: prm mi2s clk cfg disable failed ret %d\n",
|
pr_err("%s: prm mi2s clk cfg disable failed ret %d\n",
|
||||||
__func__, ret);
|
__func__, ret);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
pr_err("%s: unsupported stream name: %s\n",
|
pr_err("%s: unsupported stream name: %s\n",
|
||||||
__func__, stream_name);
|
__func__, stream_name);
|
||||||
|
Reference in New Issue
Block a user