[alsa-devel] [PATCH 1/2] ASoC: core: call snd_soc_unregister_card() when component cleanup

Mark Brown broonie at kernel.org
Fri Feb 6 22:46:59 CET 2015


On Thu, Feb 05, 2015 at 05:33:55AM +0000, Kuninori Morimoto wrote:

> ASoC devices are organized as [CPU]-[CARD]-[CODEC]. Then, [CPU]/[CODEC]
> are based on [component] structure. Now, each [CARD] device knows that
> it has organized from which [component]. But current [component] doesn't
> inform to [CARD] that it was removed when user called rmmod or unbind it.
> Thus, [CARD] which lost some [components] still exist in system.
> And then, ALSA sound card will have some problem if user used this [CARD]
> in such timing. This patch unregister [CARD] when [component] was removed.
> If you want to use this [CARD] again, 
> you need to re-insmod or re-bind removed [component] and [CARD] again. 

So, there's a problem here but...

> @@ -2695,6 +2695,7 @@ static void snd_soc_component_add(struct snd_soc_component *component)
>  static void snd_soc_component_cleanup(struct snd_soc_component *component)
>  {
>  	snd_soc_unregister_dais(component);
> +	snd_soc_unregister_card(component->card);
>  	kfree(component->name);
>  }

...this doesn't look like the right fix.  If we just plain unregister
the card then if the component that was removed is loaded again then the
card won't be reinstantiated since the core has forgotten about the
card.  Further, if the card driver is removed then we'll get a duplicate
attempt to unregister it which doesn't seem clever.

What we need to do here is undo all the work that was done to
instantiate the card but not actually unregister it, returning
everything to the state it was in before the card was instantiated.
That's obviously a much more substantial change than this but it's
what's needed (and is the main reason this is broken at the minute).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://mailman.alsa-project.org/pipermail/alsa-devel/attachments/20150207/38763750/attachment.sig>


More information about the Alsa-devel mailing list