int qcom_snd_parse_of(struct snd_soc_card *card)
{
- struct device_node *np;
- struct device_node *codec = NULL;
- struct device_node *platform = NULL;
- struct device_node *cpu = NULL;
struct device *dev = card->dev;
struct snd_soc_dai_link *link;
struct of_phandle_args args;
card->num_links = num_links;
link = card->dai_link;
- for_each_available_child_of_node(dev->of_node, np) {
+ for_each_available_child_of_node_scoped(dev->of_node, np) {
dlc = devm_kcalloc(dev, 2, sizeof(*dlc), GFP_KERNEL);
- if (!dlc) {
- ret = -ENOMEM;
- goto err_put_np;
- }
+ if (!dlc)
+ return -ENOMEM;
link->cpus = &dlc[0];
link->platforms = &dlc[1];
ret = of_property_read_string(np, "link-name", &link->name);
if (ret) {
dev_err(card->dev, "error getting codec dai_link name\n");
- goto err_put_np;
+ return ret;
}
- cpu = of_get_child_by_name(np, "cpu");
- platform = of_get_child_by_name(np, "platform");
- codec = of_get_child_by_name(np, "codec");
+ struct device_node *cpu __free(device_node) =
+ of_get_child_by_name(np, "cpu");
+ struct device_node *platform __free(device_node) =
+ of_get_child_by_name(np, "platform");
+ struct device_node *codec __free(device_node) =
+ of_get_child_by_name(np, "codec");
if (!cpu) {
dev_err(dev, "%s: Can't find cpu DT node\n", link->name);
- ret = -EINVAL;
- goto err;
+ return -EINVAL;
}
ret = snd_soc_of_get_dlc(cpu, &args, link->cpus, 0);
if (ret) {
dev_err_probe(card->dev, ret,
"%s: error getting cpu dai name\n", link->name);
- goto err;
+ return ret;
}
link->id = args.args[0];
if (link->id >= LPASS_MAX_PORT) {
dev_err(dev, "%s: Invalid cpu dai id %d\n", link->name, link->id);
- ret = -EINVAL;
- goto err;
+ return -EINVAL;
}
if (platform) {
0);
if (!link->platforms->of_node) {
dev_err(card->dev, "%s: platform dai not found\n", link->name);
- ret = -EINVAL;
- goto err;
+ return -EINVAL;
}
} else {
link->platforms->of_node = link->cpus->of_node;
if (ret < 0) {
dev_err_probe(card->dev, ret,
"%s: codec dai not found\n", link->name);
- goto err;
+ return ret;
}
if (platform) {
link->stream_name = link->name;
link++;
-
- of_node_put(cpu);
- of_node_put(codec);
- of_node_put(platform);
}
if (!card->dapm_widgets) {
}
return 0;
-err:
- of_node_put(cpu);
- of_node_put(codec);
- of_node_put(platform);
-err_put_np:
- of_node_put(np);
- return ret;
}
EXPORT_SYMBOL_GPL(qcom_snd_parse_of);