提交 70d29331 编写于 作者: J Jarkko Nikula 提交者: Mark Brown

ASoC: soc-core: Increment codec and platform driver refcounts before probing

Commit f6c2ed5d "ASoC: Fix the device references to codec and platform drivers"
moved codec and platform driver refcount increments from soc_bind_dai_link
to more appropriate places.

Adjust a little them so that refcounts are incremented before executing the
driver probe functions.
Signed-off-by: NJarkko Nikula <jhnikula@gmail.com>
Cc: Vinod Koul <vinod.koul@intel.com>
Cc: Harsha Priya <priya.harsha@intel.com>
Signed-off-by: NMark Brown <broonie@opensource.wolfsonmicro.com>
上级 8c9daae2
...@@ -1412,26 +1412,31 @@ static int soc_probe_codec(struct snd_soc_card *card, ...@@ -1412,26 +1412,31 @@ static int soc_probe_codec(struct snd_soc_card *card,
codec->dapm.card = card; codec->dapm.card = card;
soc_set_name_prefix(card, codec); soc_set_name_prefix(card, codec);
if (!try_module_get(codec->dev->driver->owner))
return -ENODEV;
if (codec->driver->probe) { if (codec->driver->probe) {
ret = codec->driver->probe(codec); ret = codec->driver->probe(codec);
if (ret < 0) { if (ret < 0) {
dev_err(codec->dev, dev_err(codec->dev,
"asoc: failed to probe CODEC %s: %d\n", "asoc: failed to probe CODEC %s: %d\n",
codec->name, ret); codec->name, ret);
return ret; goto err_probe;
} }
} }
soc_init_codec_debugfs(codec); soc_init_codec_debugfs(codec);
/* mark codec as probed and add to card codec list */ /* mark codec as probed and add to card codec list */
if (!try_module_get(codec->dev->driver->owner))
return -ENODEV;
codec->probed = 1; codec->probed = 1;
list_add(&codec->card_list, &card->codec_dev_list); list_add(&codec->card_list, &card->codec_dev_list);
list_add(&codec->dapm.list, &card->dapm_list); list_add(&codec->dapm.list, &card->dapm_list);
return 0;
err_probe:
module_put(codec->dev->driver->owner);
return ret; return ret;
} }
...@@ -1549,19 +1554,19 @@ static int soc_probe_dai_link(struct snd_soc_card *card, int num) ...@@ -1549,19 +1554,19 @@ static int soc_probe_dai_link(struct snd_soc_card *card, int num)
/* probe the platform */ /* probe the platform */
if (!platform->probed) { if (!platform->probed) {
if (!try_module_get(platform->dev->driver->owner))
return -ENODEV;
if (platform->driver->probe) { if (platform->driver->probe) {
ret = platform->driver->probe(platform); ret = platform->driver->probe(platform);
if (ret < 0) { if (ret < 0) {
printk(KERN_ERR "asoc: failed to probe platform %s\n", printk(KERN_ERR "asoc: failed to probe platform %s\n",
platform->name); platform->name);
module_put(platform->dev->driver->owner);
return ret; return ret;
} }
} }
/* mark platform as probed and add to card platform list */ /* mark platform as probed and add to card platform list */
if (!try_module_get(platform->dev->driver->owner))
return -ENODEV;
platform->probed = 1; platform->probed = 1;
list_add(&platform->card_list, &card->platform_dev_list); list_add(&platform->card_list, &card->platform_dev_list);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册