Commit 0562f7882d968463119bb63d47ef4bdaba7d6631
Committed by
Mark Brown
1 parent
7750752a22
Exists in
master
and in
7 other branches
ASoC: don't register AC97 devices twice
With generic AC97 ASoC glue driver (codec/ac97.c), we get following warning when the device is registered (slightly stripped the backtrace): kobject (c5a863e8): tried to init an initialized object, something is seriously wrong. [<c00254fc>] (unwind_backtrace+0x0/0xec) [<c014fad0>] (kobject_init+0x38/0x70) [<c0171e94>] (device_initialize+0x20/0x70) [<c017267c>] (device_register+0xc/0x18) [<bf20db70>] (snd_soc_instantiate_cards+0x924/0xacc [snd_soc_core]) [<bf20e0d0>] (snd_soc_register_platform+0x16c/0x198 [snd_soc_core]) [<c0175304>] (platform_drv_probe+0x18/0x1c) [<c0174454>] (driver_probe_device+0xb0/0x16c) [<c017456c>] (__driver_attach+0x5c/0x7c) [<c0173cec>] (bus_for_each_dev+0x48/0x78) [<c0173600>] (bus_add_driver+0x98/0x214) [<c0174834>] (driver_register+0xa4/0x130) [<c001f410>] (do_one_initcall+0xd0/0x1a4) [<c0062ddc>] (sys_init_module+0x12b0/0x1454) This happens because the generic AC97 glue driver creates its codec->ac97 via calling snd_ac97_mixer(). snd_ac97_mixer() provides own version of snd_device.register which handles the device registration when snd_card_register() is called. To avoid registering the AC97 device twice, we add a new flag to the snd_soc_codec: ac97_created which tells whether the AC97 device was created by SoC subsystem. Signed-off-by: Mika Westerberg <mika.westerberg@iki.fi> Acked-by: Liam Girdwood <lrg@slimlogic.co.uk> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Showing 2 changed files with 19 additions and 0 deletions Side-by-side Diff
include/sound/soc.h
... | ... | @@ -442,6 +442,7 @@ |
442 | 442 | unsigned int suspended:1; /* Codec is in suspend PM state */ |
443 | 443 | unsigned int probed:1; /* Codec has been probed */ |
444 | 444 | unsigned int ac97_registered:1; /* Codec has been AC97 registered */ |
445 | + unsigned int ac97_created:1; /* Codec has been created by SoC */ | |
445 | 446 | unsigned int sysfs_registered:1; /* codec has been sysfs registered */ |
446 | 447 | |
447 | 448 | /* codec IO */ |
sound/soc/soc-core.c
... | ... | @@ -1497,6 +1497,16 @@ |
1497 | 1497 | * for the generic AC97 subsystem. |
1498 | 1498 | */ |
1499 | 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 | 1511 | ret = soc_ac97_dev_register(rtd->codec); |
1502 | 1512 | if (ret < 0) { |
... | ... | @@ -1812,6 +1822,13 @@ |
1812 | 1822 | |
1813 | 1823 | codec->ac97->bus->ops = ops; |
1814 | 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 | 1832 | mutex_unlock(&codec->mutex); |
1816 | 1833 | return 0; |
1817 | 1834 | } |
... | ... | @@ -1832,6 +1849,7 @@ |
1832 | 1849 | kfree(codec->ac97->bus); |
1833 | 1850 | kfree(codec->ac97); |
1834 | 1851 | codec->ac97 = NULL; |
1852 | + codec->ac97_created = 0; | |
1835 | 1853 | mutex_unlock(&codec->mutex); |
1836 | 1854 | } |
1837 | 1855 | EXPORT_SYMBOL_GPL(snd_soc_free_ac97_codec); |