Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions sound/soc/intel/skylake/skl-pcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1462,9 +1462,16 @@ static int skl_platform_soc_probe(struct snd_soc_component *component)
return 0;
}

static void skl_pcm_remove(struct snd_soc_component *component)
{
/* remove topology */
snd_soc_tplg_component_remove(component, SND_SOC_TPLG_INDEX_ALL);
}

static const struct snd_soc_component_driver skl_component = {
.name = "pcm",
.probe = skl_platform_soc_probe,
.remove = skl_pcm_remove,
.ops = &skl_platform_ops,
.pcm_new = skl_pcm_new,
.pcm_free = skl_pcm_free,
Expand Down
11 changes: 11 additions & 0 deletions sound/soc/soc-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2831,10 +2831,21 @@ EXPORT_SYMBOL_GPL(snd_soc_register_card);

static void snd_soc_unbind_card(struct snd_soc_card *card, bool unregister)
{
struct snd_soc_pcm_runtime *rtd;
int order;

if (card->instantiated) {
card->instantiated = false;
snd_soc_dapm_shutdown(card);
snd_soc_flush_all_delayed_work(card);

/* remove all components used by DAI links on this card */
for_each_comp_order(order) {
for_each_card_rtds(card, rtd) {
soc_remove_link_components(card, rtd, order);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this patch is the one I am most scared of. I don't see a moral equivalent in snd_soc_bind_card that would add link components and don't know the internals of the ASoC code enough to judge if this is legit or not. Either you find a self-explanatory way of doing this or you have to run this by Mark Brown.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@plbossart let me submit a RFC patchset to the mailing list to get some feedback. What I did find was as far as I could tell none of the component drivers implement the remove() callback. So I doubt this will break anything. But I'll check with him anyway.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@plbossart that was easy. the most controversial one was the first one to be accepted. I'll clean up this PR based on Mark's feedback. I'll drop the first one and keep the rest.

}
}

soc_cleanup_card_resources(card);
if (!unregister)
list_add(&card->list, &unbind_card_list);
Expand Down
14 changes: 7 additions & 7 deletions sound/soc/sof/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,9 @@ static int sof_probe_continue(struct snd_sof_dev *sdev)
sdev->first_boot = false;

/* now register audio DSP platform driver and dai */
ret = snd_soc_register_component(sdev->dev, &sdev->plat_drv,
sof_ops(sdev)->drv,
sof_ops(sdev)->num_drv);
ret = devm_snd_soc_register_component(sdev->dev, &sdev->plat_drv,
sof_ops(sdev)->drv,
sof_ops(sdev)->num_drv);
if (ret < 0) {
dev_err(sdev->dev,
"error: failed to register DSP DAI driver %d\n", ret);
Expand Down Expand Up @@ -466,16 +466,16 @@ int snd_sof_device_remove(struct device *dev)
if (IS_ENABLED(CONFIG_SND_SOC_SOF_PROBE_WORK_QUEUE))
cancel_work_sync(&sdev->probe_work);

snd_soc_unregister_component(dev);
snd_sof_fw_unload(sdev);
snd_sof_ipc_free(sdev);
snd_sof_free_debug(sdev);
snd_sof_free_trace(sdev);
snd_sof_remove(sdev);

/*
* platform_device_unregister() frees the card and its resources.
* So it should be called after unregistering the comp driver
* so that the card is valid while unregistering comp driver.
* Unregister machine driver. This will unbind the snd_card which
* will remove the component driver and unload the topology
* before freeing the snd_card.
*/
if (!IS_ERR_OR_NULL(pdata->pdev_mach))
platform_device_unregister(pdata->pdev_mach);
Expand Down
2 changes: 2 additions & 0 deletions sound/soc/sof/pcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,8 @@ static int sof_pcm_probe(struct snd_soc_component *component)

static void sof_pcm_remove(struct snd_soc_component *component)
{
/* remove topology */
snd_soc_tplg_component_remove(component, SND_SOC_TPLG_INDEX_ALL);
}

void snd_sof_new_platform_drv(struct snd_sof_dev *sdev)
Expand Down