diff options
-rw-r--r-- | include/sound/soc.h | 1 | ||||
-rw-r--r-- | sound/soc/soc-core.c | 18 |
2 files changed, 19 insertions, 0 deletions
diff --git a/include/sound/soc.h b/include/sound/soc.h index 4fb079e14e16..5c3bce83f28a 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h | |||
@@ -442,6 +442,7 @@ struct snd_soc_codec { | |||
442 | unsigned int suspended:1; /* Codec is in suspend PM state */ | 442 | unsigned int suspended:1; /* Codec is in suspend PM state */ |
443 | unsigned int probed:1; /* Codec has been probed */ | 443 | unsigned int probed:1; /* Codec has been probed */ |
444 | unsigned int ac97_registered:1; /* Codec has been AC97 registered */ | 444 | unsigned int ac97_registered:1; /* Codec has been AC97 registered */ |
445 | unsigned int ac97_created:1; /* Codec has been created by SoC */ | ||
445 | unsigned int sysfs_registered:1; /* codec has been sysfs registered */ | 446 | unsigned int sysfs_registered:1; /* codec has been sysfs registered */ |
446 | 447 | ||
447 | /* codec IO */ | 448 | /* codec IO */ |
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 8751efdea119..7d22b5d5bc0d 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c | |||
@@ -1497,6 +1497,16 @@ static int soc_register_ac97_dai_link(struct snd_soc_pcm_runtime *rtd) | |||
1497 | * for the generic AC97 subsystem. | 1497 | * for the generic AC97 subsystem. |
1498 | */ | 1498 | */ |
1499 | if (rtd->codec_dai->driver->ac97_control && !rtd->codec->ac97_registered) { | 1499 | if (rtd->codec_dai->driver->ac97_control && !rtd->codec->ac97_registered) { |
1500 | /* | ||
1501 | * It is possible that the AC97 device is already registered to | ||
1502 | * the device subsystem. This happens when the device is created | ||
1503 | * via snd_ac97_mixer(). Currently only SoC codec that does so | ||
1504 | * is the generic AC97 glue but others migh emerge. | ||
1505 | * | ||
1506 | * In those cases we don't try to register the device again. | ||
1507 | */ | ||
1508 | if (!rtd->codec->ac97_created) | ||
1509 | return 0; | ||
1500 | 1510 | ||
1501 | ret = soc_ac97_dev_register(rtd->codec); | 1511 | ret = soc_ac97_dev_register(rtd->codec); |
1502 | if (ret < 0) { | 1512 | if (ret < 0) { |
@@ -1812,6 +1822,13 @@ int snd_soc_new_ac97_codec(struct snd_soc_codec *codec, | |||
1812 | 1822 | ||
1813 | codec->ac97->bus->ops = ops; | 1823 | codec->ac97->bus->ops = ops; |
1814 | codec->ac97->num = num; | 1824 | codec->ac97->num = num; |
1825 | |||
1826 | /* | ||
1827 | * Mark the AC97 device to be created by us. This way we ensure that the | ||
1828 | * device will be registered with the device subsystem later on. | ||
1829 | */ | ||
1830 | codec->ac97_created = 1; | ||
1831 | |||
1815 | mutex_unlock(&codec->mutex); | 1832 | mutex_unlock(&codec->mutex); |
1816 | return 0; | 1833 | return 0; |
1817 | } | 1834 | } |
@@ -1832,6 +1849,7 @@ void snd_soc_free_ac97_codec(struct snd_soc_codec *codec) | |||
1832 | kfree(codec->ac97->bus); | 1849 | kfree(codec->ac97->bus); |
1833 | kfree(codec->ac97); | 1850 | kfree(codec->ac97); |
1834 | codec->ac97 = NULL; | 1851 | codec->ac97 = NULL; |
1852 | codec->ac97_created = 0; | ||
1835 | mutex_unlock(&codec->mutex); | 1853 | mutex_unlock(&codec->mutex); |
1836 | } | 1854 | } |
1837 | EXPORT_SYMBOL_GPL(snd_soc_free_ac97_codec); | 1855 | EXPORT_SYMBOL_GPL(snd_soc_free_ac97_codec); |