[alsa-devel] regarding references taken on platform and codec driver modules

Koul, Vinod vinod.koul at intel.com
Wed Jan 5 18:19:32 CET 2011

> >> Please provide your comments on the patch below that makes this change
> >
> >Please follow Documentation/SubmittingPatches - remember to CC
> >maintainers (I've added Liam) and don't bury your patches in the middle
> >of another e-mail.
> >
> I have sent the patch in a separate email.
I seem to have hit another instance of where references are kept wrongly.

During the testing codec driver probe was failing and this results in wrong
reference of platform driver .

On investigating the issue is in soc_bind_dai_link()

It takes the reference of cpu_dai and adds the dai in the runtime structure.
But since the codec was not found these references are kept and modules cant be

Now thinking on this and other reference patch recently applied, IMO we can
instead of taking the module reference check if cpu_dai is probed.
If probed then only go ahead otherwise return error

Something like this
@@ -1238,9 +1238,10 @@ static int soc_bind_dai_link(struct snd_soc_card *card, int num)
        list_for_each_entry(cpu_dai, &dai_list, list) {
                if (!strcmp(cpu_dai->name, dai_link->cpu_dai_name)) {

-                       if (!try_module_get(cpu_dai->dev->driver->owner))
+                       if (!cpu_dai->probed)
		                     return -ENODEV;

Would this be right thing to do? My logic is that we should be relying on probed
to see references (as while marking probed we do take the reference).
I have tested with both false and positive case worked for me on both counts.

If this looks fine I will send a proper patch


More information about the Alsa-devel mailing list