audio: auge: check resample is inited
authorXing Wang <xing.wang@amlogic.com>
Sun, 30 Sep 2018 05:14:42 +0000 (13:14 +0800)
committerXing Wang <xing.wang@amlogic.com>
Sun, 30 Sep 2018 05:14:57 +0000 (13:14 +0800)
PD#163795: audio: auge: check resample is inited

Change-Id: Ib6f06f1e6f9d95a03a8ae5f968fd67af8c17f197
Signed-off-by: Xing Wang <xing.wang@amlogic.com>
sound/soc/amlogic/auge/resample.c

index 5338294..608591e 100644 (file)
@@ -182,7 +182,12 @@ static int resample_get_enum(
        struct snd_kcontrol *kcontrol,
        struct snd_ctl_elem_value *ucontrol)
 {
-       struct audioresample *p_resample =  snd_kcontrol_chip(kcontrol);
+       struct audioresample *p_resample = snd_kcontrol_chip(kcontrol);
+
+       if (!p_resample) {
+               pr_info("audio resample is not init\n");
+               return -EINVAL;
+       }
 
        ucontrol->value.enumerated.item[0] = p_resample->asr_idx;
 
@@ -193,6 +198,11 @@ int resample_set(int index)
 {
        int resample_rate = resample_idx2rate(index);
 
+       if (!s_resample) {
+               pr_info("audio resample is not init\n");
+               return -EINVAL;
+       }
+
        if (index == s_resample->asr_idx)
                return 0;
 
@@ -295,7 +305,7 @@ static int resample_module_get_enum(
        struct audioresample *p_resample =  snd_kcontrol_chip(kcontrol);
 
        if (!p_resample) {
-               pr_err("audio resample is not init\n");
+               pr_info("audio resample is not init\n");
                return -EINVAL;
        }
 
@@ -311,7 +321,7 @@ static int resample_module_set_enum(
        struct audioresample *p_resample =  snd_kcontrol_chip(kcontrol);
 
        if (!p_resample) {
-               pr_err("audio resample is not init\n");
+               pr_info("audio resample is not init\n");
                return -EINVAL;
        }