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 unloaded.
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
This won't work either as cpu_dai is probed after bind_dai_link()
This issue is on removal of soc_remove() it doesn't free up the reference if the card is not instantiated So in case one of the probes fails we should handle this in soc_remove in else for instantated
if (rtd->codec->probed) module_put(rtd->codec->dev->driver->owner); if (rtd->platform->probed) module_put(rtd->platform->dev->driver->owner); for (i = 0; i < card->num_rtd; i++) module_put(rtd[i].cpu_dai->dev->driver->owner);
Would this be the correct way to solve this?
~Vinod