ASoC: Intel: avs: Introduce helper functions for SSP and TDM handling
authorAmadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Thu, 12 Oct 2023 08:35:00 +0000 (10:35 +0200)
committerMark Brown <broonie@kernel.org>
Thu, 12 Oct 2023 12:04:38 +0000 (13:04 +0100)
commit7a6debe0478596ac892ecf3cc336aacf09a9e4d8
tree118a3b020e0a5292420a3f8c18e210026ef319ac
parent393648ce731b087f5a685044c9e41afb815421f7
ASoC: Intel: avs: Introduce helper functions for SSP and TDM handling

In quite a few places in code there are checks for number of SSPs
present on system, to reduce maintenance burden introduce helper
functions allowing to get SSP and TDM from machine board configuration.

Additionally in boards we use SSP and TDM to generate quite a few
strings, it could be done like:
if (tdms)
dl->name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d:%d-Codec",
ssp_port, tdm_slot);
else
dl->name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-Codec",
ssp_port);

but quite quickly code ends up with spaghetti of similar if elses.
Instead introduce macro which can be used to generate correct string,
allowing to minimize code to something like:
dl->name = devm_kasprintf(dev, GFP_KERNEL, AVS_STRING_FMT("SSP", "-Codec",
ssp_port, tdm_slot));

Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Link: https://lore.kernel.org/r/20231012083514.492626-3-amadeuszx.slawinski@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/intel/avs/utils.h [new file with mode: 0644]