dai-zephyr: handle NULL case when calling dai_config_get()

As per interface documentation of dai_config_get(), the function
may return NULL if the device is not configured for the requested
direction. Handle this case explicitly.

Currently no upstream Zephyr driver returns NULL, but e.g. dmic
driver returns invalid configuration when dai_config_get() is
called with DAI_DIR_TX as direction.

Link: https://github.com/thesofproject/sof/issues/6896
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
This commit is contained in:
Kai Vehmanen 2022-12-30 14:22:12 +02:00 committed by Kai Vehmanen
parent e584701a01
commit 90c14e56cb
1 changed files with 1 additions and 1 deletions

View File

@ -157,7 +157,7 @@ static const struct device *dai_get_zephyr_device(uint32_t type, uint32_t index)
for (i = 0; i < ARRAY_SIZE(zephyr_dev); i++) { for (i = 0; i < ARRAY_SIZE(zephyr_dev); i++) {
cfg = dai_config_get(zephyr_dev[i], dir); cfg = dai_config_get(zephyr_dev[i], dir);
if (cfg->type == type && cfg->dai_index == index) if (cfg && cfg->type == type && cfg->dai_index == index)
return zephyr_dev[i]; return zephyr_dev[i];
} }