• S
    ASoC: tegra: free jack GPIOs before the sound card is freed · fb6b8e71
    Stephen Warren 提交于
    snd_soc_jack_add_gpios() schedules a work queue item to poll the GPIO to
    generate an initial jack status report. If sound card initialization
    fails, that work item needs to be cancelled, so it doesn't run after the
    card has been freed. Specifically, freeing the card calls
    snd_jack_dev_free() which calls snd_jack_dev_disconnect() which sets
    jack->input_dev = NULL, and input_dev is used by snd_jack_report(), which
    is called from the work queue item.
    
    snd_soc_jack_free_gpios() cancels the work item. The Tegra ASoC machine
    drivers do call this function in the platform driver remove() callback.
    However, this happens after the sound card is freed, at least when the
    card is freed due to errors late during snd_soc_instantiate_card(). This
    leaves a window where the work item can execute after the card is freed.
    In next-20140522, sound card initialization does fail for unrelated
    reasons, and hits the problem described above.
    
    To solve this, fix the Tegra ASoC machine drivers to clean up the Jack
    GPIOs during the snd_soc_card's .remove() callback, which is executed
    before the overall card object is freed. also, gGuard the cleanup call
    based on whether we actually setup up the GPIOs in the first place.
    Ideally, we'd do the cleanup in a struct snd_soc_dai_link .fini/remove
    function to match where the GPIOs get set up. However, there is no such
    callback.
    
    This change fixes all Tegra machine drivers. By code inspection, I
    believe some non-Tegra machine drivers have the same issue. I'll send a
    patch for that separately, once this is reviewed.
    Signed-off-by: NStephen Warren <swarren@nvidia.com>
    Signed-off-by: NMark Brown <broonie@linaro.org>
    fb6b8e71
tegra_alc5632.c 6.8 KB