From 742a2fa584fd32927c7a24838468e08616891e08 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 13 Nov 2017 14:23:48 -0800 Subject: [PATCH 221/277] drm/vc4: Fix crash if we have to unbind HDMI. We need the card to unregister before the codec that the card references. Signed-off-by: Eric Anholt --- drivers/gpu/drm/vc4/vc4_hdmi.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c index 8ab20c1e9e69..54fe4ceb1c3e 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c @@ -1130,7 +1130,7 @@ static int vc4_hdmi_audio_init(struct vc4_hdmi *hdmi) * snd_soc_card_get_drvdata() if needed. */ snd_soc_card_set_drvdata(card, hdmi); - ret = devm_snd_soc_register_card(dev, card); + ret = snd_soc_register_card(card); if (ret) { dev_err(dev, "Could not register sound card: %d\n", ret); goto unregister_codec; @@ -1147,13 +1147,16 @@ static int vc4_hdmi_audio_init(struct vc4_hdmi *hdmi) static void vc4_hdmi_audio_cleanup(struct vc4_hdmi *hdmi) { struct device *dev = &hdmi->pdev->dev; + struct snd_soc_card *card = &hdmi->audio.card; /* * If drvdata is not set this means the audio card was not * registered, just skip codec unregistration in this case. */ - if (dev_get_drvdata(dev)) + if (dev_get_drvdata(dev)) { + snd_soc_unregister_card(card); snd_soc_unregister_codec(dev); + } } #ifdef CONFIG_DRM_VC4_HDMI_CEC -- 2.16.1