ASoC: codecs: Modify the transmission method of parameters
authorWeidong Wang <wangweidong.a@awinic.com>
Thu, 28 Sep 2023 10:57:22 +0000 (18:57 +0800)
committerMark Brown <broonie@kernel.org>
Thu, 28 Sep 2023 11:38:33 +0000 (13:38 +0200)
Change the transmission mode of the "aw88395_dev_get_prof_name"
function parameter, Instead of using return values for data
transfer, parameters are used

Signed-off-by: Weidong Wang <wangweidong.a@awinic.com>
Link: https://lore.kernel.org/r/20230928105727.47273-6-wangweidong.a@awinic.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/aw88395/aw88395.c
sound/soc/codecs/aw88395/aw88395_device.c
sound/soc/codecs/aw88395/aw88395_device.h

index 9dcd75dd799a55c07eae8a387883002655fd71f9..77227c8f01f60d8e63f9cd91030dcd9a93e1100e 100644 (file)
@@ -175,9 +175,8 @@ static int aw88395_profile_info(struct snd_kcontrol *kcontrol,
 {
        struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol);
        struct aw88395 *aw88395 = snd_soc_component_get_drvdata(codec);
-       const char *prof_name;
-       char *name;
-       int count;
+       char *prof_name, *name;
+       int count, ret;
 
        uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
        uinfo->count = 1;
@@ -196,8 +195,8 @@ static int aw88395_profile_info(struct snd_kcontrol *kcontrol,
        name = uinfo->value.enumerated.name;
        count = uinfo->value.enumerated.item;
 
-       prof_name = aw88395_dev_get_prof_name(aw88395->aw_pa, count);
-       if (!prof_name) {
+       ret = aw88395_dev_get_prof_name(aw88395->aw_pa, count, &prof_name);
+       if (ret) {
                strscpy(uinfo->value.enumerated.name, "null",
                                                strlen("null") + 1);
                return 0;
index 5ca4172cb788901dbd75c88afddfc18d11ebc157..fd1f67d5f22f0f633bbda3bb463b1fbfa0beafa5 100644 (file)
@@ -1296,7 +1296,9 @@ int aw88395_dev_fw_update(struct aw_device *aw_dev, bool up_dsp_fw_en, bool forc
                return -EPERM;
        }
 
-       prof_name = aw88395_dev_get_prof_name(aw_dev, aw_dev->prof_index);
+       ret = aw88395_dev_get_prof_name(aw_dev, aw_dev->prof_index, &prof_name);
+       if (ret)
+               return ret;
 
        dev_dbg(aw_dev->dev, "start update %s", prof_name);
 
@@ -1644,7 +1646,7 @@ int aw88395_dev_set_profile_index(struct aw_device *aw_dev, int index)
 }
 EXPORT_SYMBOL_GPL(aw88395_dev_set_profile_index);
 
-char *aw88395_dev_get_prof_name(struct aw_device *aw_dev, int index)
+int aw88395_dev_get_prof_name(struct aw_device *aw_dev, int index, char **prof_name)
 {
        struct aw_prof_info *prof_info = &aw_dev->prof_info;
        struct aw_prof_desc *prof_desc;
@@ -1652,12 +1654,14 @@ char *aw88395_dev_get_prof_name(struct aw_device *aw_dev, int index)
        if ((index >= aw_dev->prof_info.count) || (index < 0)) {
                dev_err(aw_dev->dev, "index[%d] overflow count[%d]",
                        index, aw_dev->prof_info.count);
-               return NULL;
+               return -EINVAL;
        }
 
        prof_desc = &aw_dev->prof_info.prof_desc[index];
 
-       return prof_info->prof_name_list[prof_desc->id];
+       *prof_name = prof_info->prof_name_list[prof_desc->id];
+
+       return 0;
 }
 EXPORT_SYMBOL_GPL(aw88395_dev_get_prof_name);
 
index d32d16c8950996ad3634125d2be79a9ff1f064ff..791c8c106557da6adc74250152fa68016f6b7542 100644 (file)
@@ -181,7 +181,7 @@ int aw88395_dev_fw_update(struct aw_device *aw_dev, bool up_dsp_fw_en, bool forc
 void aw88395_dev_set_volume(struct aw_device *aw_dev, unsigned short set_vol);
 int aw88395_dev_get_prof_data(struct aw_device *aw_dev, int index,
                        struct aw_prof_desc **prof_desc);
-char *aw88395_dev_get_prof_name(struct aw_device *aw_dev, int index);
+int aw88395_dev_get_prof_name(struct aw_device *aw_dev, int index, char **prof_name);
 int aw88395_dev_set_profile_index(struct aw_device *aw_dev, int index);
 int aw88395_dev_get_profile_index(struct aw_device *aw_dev);
 int aw88395_dev_get_profile_count(struct aw_device *aw_dev);