struct snd_sof_tuple *tuples;
int num_tuples;
struct snd_soc_dai_link *link;
- struct snd_soc_tplg_hw_config *hw_configs;
int num_hw_configs;
int default_hw_cfg_id;
int type;
struct list_head list;
+ struct snd_soc_tplg_hw_config hw_configs[] __counted_by(num_hw_configs);
};
/* ASoC SOF DAPM widget */
return -EINVAL;
}
- slink = kzalloc_obj(*slink);
+ slink = kzalloc_flex(*slink, hw_configs, le32_to_cpu(cfg->num_hw_configs));
if (!slink)
return -ENOMEM;
slink->num_hw_configs = le32_to_cpu(cfg->num_hw_configs);
- slink->hw_configs = kmemdup_array(cfg->hw_config,
- slink->num_hw_configs, sizeof(*slink->hw_configs),
- GFP_KERNEL);
- if (!slink->hw_configs) {
- kfree(slink);
- return -ENOMEM;
- }
+ memcpy(slink->hw_configs, cfg->hw_config, le32_to_cpu(cfg->num_hw_configs) * sizeof(*slink->hw_configs));
slink->default_hw_cfg_id = le32_to_cpu(cfg->default_hw_config_id);
slink->link = link;
private->array, le32_to_cpu(private->size));
if (ret < 0) {
dev_err(scomp->dev, "Failed tp parse common DAI link tokens\n");
- kfree(slink->hw_configs);
kfree(slink);
return ret;
}
/* allocate memory for tuples array */
slink->tuples = kzalloc_objs(*slink->tuples, num_tuples);
if (!slink->tuples) {
- kfree(slink->hw_configs);
kfree(slink);
return -ENOMEM;
}
err:
kfree(slink->tuples);
- kfree(slink->hw_configs);
kfree(slink);
return ret;
kfree(slink->tuples);
list_del(&slink->list);
- kfree(slink->hw_configs);
kfree(slink);
dobj->private = NULL;