ASoC: Kona: Make addition of aux codec as optional

Check for aux codec count and avoid aux codec registration
if the count is zero.

Change-Id: I540dcc8f14f138b8bd673d88ab7e033779a90843
Signed-off-by: Sudheer Papothi <spapothi@codeaurora.org>
This commit is contained in:
Sudheer Papothi
2019-06-19 02:31:11 +05:30
parent c63ec8cd8f
commit d6d524d678

View File

@@ -7168,6 +7168,7 @@ static int msm_init_aux_dev(struct platform_device *pdev,
struct device_node *aux_codec_of_node;
u32 wsa_max_devs;
u32 wsa_dev_cnt;
u32 codec_max_aux_devs = 0;
u32 codec_aux_dev_cnt = 0;
int i;
struct msm_wsa881x_dev_info *wsa881x_dev_info;
@@ -7283,6 +7284,24 @@ static int msm_init_aux_dev(struct platform_device *pdev,
__func__, found);
codec_aux_dev:
/* Get maximum aux codec device count for this platform */
ret = of_property_read_u32(pdev->dev.of_node,
"qcom,codec-max-aux-devs",
&codec_max_aux_devs);
if (ret) {
dev_err(&pdev->dev,
"%s: codec-max-aux-devs property missing in DT %s, ret = %d\n",
__func__, pdev->dev.of_node->full_name, ret);
codec_max_aux_devs = 0;
goto aux_dev_register;
}
if (codec_max_aux_devs == 0) {
dev_dbg(&pdev->dev,
"%s: Max aux codec devices is 0 for this target?\n",
__func__);
goto aux_dev_register;
}
/* Get count of aux codec device phandles for this platform */
codec_aux_dev_cnt = of_count_phandle_with_args(
pdev->dev.of_node,
@@ -7299,6 +7318,19 @@ codec_aux_dev:
goto err;
}
/*
* Expect total phandles count to be NOT less than maximum possible
* AUX device count. However, if it is less, then assign same value to
* max count as well.
*/
if (codec_aux_dev_cnt < codec_max_aux_devs) {
dev_dbg(&pdev->dev,
"%s: codec_max_aux_devs = %d cannot exceed codec_aux_dev_cnt = %d\n",
__func__, codec_max_aux_devs,
codec_aux_dev_cnt);
codec_max_aux_devs = codec_aux_dev_cnt;
}
/*
* Alloc mem to store phandle and index info of aux codec
* if already registered with ALSA core
@@ -7347,6 +7379,7 @@ codec_aux_dev:
"%s: found %d AUX codecs registered with ALSA core\n",
__func__, codecs_found);
aux_dev_register:
card->num_aux_devs = wsa_max_devs + codec_aux_dev_cnt;
card->num_configs = wsa_max_devs + codec_aux_dev_cnt;