Skip to content

Commit 77a4cd7

Browse files
committed
ASoC: sdw_utils: split asoc_sdw_get_codec_name
Currently asoc_sdw_get_codec_name will return codec_info->codec_name if it is set. However, in some case we need the sdw codec name no matter if codec_info->codec_name is set or not. _asoc_sdw_get_codec_name() will be used in the follow up commit. Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
1 parent b61c35b commit 77a4cd7

1 file changed

Lines changed: 19 additions & 12 deletions

File tree

sound/soc/sdw_utils/soc_sdw_utils.c

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -934,10 +934,10 @@ static bool asoc_sdw_is_unique_device(const struct snd_soc_acpi_link_adr *adr_li
934934
return true;
935935
}
936936

937-
const char *asoc_sdw_get_codec_name(struct device *dev,
938-
const struct asoc_sdw_codec_info *codec_info,
939-
const struct snd_soc_acpi_link_adr *adr_link,
940-
int adr_index)
937+
static const char *_asoc_sdw_get_codec_name(struct device *dev,
938+
const struct asoc_sdw_codec_info *codec_info,
939+
const struct snd_soc_acpi_link_adr *adr_link,
940+
int adr_index)
941941
{
942942
u64 adr = adr_link->adr_d[adr_index].adr;
943943
unsigned int sdw_version = SDW_VERSION(adr);
@@ -947,17 +947,24 @@ const char *asoc_sdw_get_codec_name(struct device *dev,
947947
unsigned int part_id = SDW_PART_ID(adr);
948948
unsigned int class_id = SDW_CLASS_ID(adr);
949949

950-
if (codec_info->codec_name)
951-
return devm_kstrdup(dev, codec_info->codec_name, GFP_KERNEL);
952-
else if (asoc_sdw_is_unique_device(adr_link, sdw_version, mfg_id, part_id,
953-
class_id, adr_index))
950+
if (asoc_sdw_is_unique_device(adr_link, sdw_version, mfg_id, part_id,
951+
class_id, adr_index))
954952
return devm_kasprintf(dev, GFP_KERNEL, "sdw:0:%01x:%04x:%04x:%02x",
955953
link_id, mfg_id, part_id, class_id);
956-
else
957-
return devm_kasprintf(dev, GFP_KERNEL, "sdw:0:%01x:%04x:%04x:%02x:%01x",
958-
link_id, mfg_id, part_id, class_id, unique_id);
959954

960-
return NULL;
955+
return devm_kasprintf(dev, GFP_KERNEL, "sdw:0:%01x:%04x:%04x:%02x:%01x",
956+
link_id, mfg_id, part_id, class_id, unique_id);
957+
}
958+
959+
const char *asoc_sdw_get_codec_name(struct device *dev,
960+
const struct asoc_sdw_codec_info *codec_info,
961+
const struct snd_soc_acpi_link_adr *adr_link,
962+
int adr_index)
963+
{
964+
if (codec_info->codec_name)
965+
return devm_kstrdup(dev, codec_info->codec_name, GFP_KERNEL);
966+
967+
return _asoc_sdw_get_codec_name(dev, codec_info, adr_link, adr_index);
961968
}
962969
EXPORT_SYMBOL_NS(asoc_sdw_get_codec_name, "SND_SOC_SDW_UTILS");
963970

0 commit comments

Comments
 (0)