ASoC: codecs: wcd-mbhc-v2: fix resource leaks on component remove
authorJohan Hovold <johan+linaro@kernel.org>
Wed, 5 Jul 2023 12:30:16 +0000 (14:30 +0200)
committerMark Brown <broonie@kernel.org>
Thu, 6 Jul 2023 12:46:30 +0000 (13:46 +0100)
commita5475829adcc600bc69ee9ff7c9e3e43fb4f8d30
treed66f0f078af328136a6cc88d40802a02a542c982
parent798590cc7d3c2b5f3a7548d96dd4d8a081c1bc39
ASoC: codecs: wcd-mbhc-v2: fix resource leaks on component remove

The MBHC resources must be released on component probe failure and
removal so can not be tied to the lifetime of the component device.

This is specifically needed to allow probe deferrals of the sound card
which otherwise fails when reprobing the codec component:

    snd-sc8280xp sound: ASoC: failed to instantiate card -517
    genirq: Flags mismatch irq 299. 00002001 (mbhc sw intr) vs. 00002001 (mbhc sw intr)
    wcd938x_codec audio-codec: Failed to request mbhc interrupts -16
    wcd938x_codec audio-codec: mbhc initialization failed
    wcd938x_codec audio-codec: ASoC: error at snd_soc_component_probe on audio-codec: -16
    snd-sc8280xp sound: ASoC: failed to instantiate card -16

Fixes: 0e5c9e7ff899 ("ASoC: codecs: wcd: add multi button Headset detection support")
Cc: stable@vger.kernel.org # 5.14
Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20230705123018.30903-7-johan+linaro@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/wcd-mbhc-v2.c