diff options
author | Vincent Abriou <vincent.abriou@st.com> | 2017-02-08 04:47:01 -0500 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2017-02-08 13:33:16 -0500 |
commit | 8480ac567959eecdc694cf4f9c02d6fa687384b6 (patch) | |
tree | 03f55796b287f9fb4a18358768082859d5675a08 | |
parent | cd6111b26280a2f38a9fb8e6630c63a96477e4bf (diff) |
ASoC: hdmi-codec: remove HDMI device unregister
While unregistering the hdmi-codec, the hdmi device list must be
cleaned up. It avoid kernel page fault when registering again the
hdmi-codec.
Signed-off-by: Vincent Abriou <vincent.abriou@st.com>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | sound/soc/codecs/hdmi-codec.c | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c index dc6715a804a1..8c5ae1fc23a9 100644 --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c | |||
@@ -32,6 +32,7 @@ struct hdmi_device { | |||
32 | }; | 32 | }; |
33 | #define pos_to_hdmi_device(pos) container_of((pos), struct hdmi_device, list) | 33 | #define pos_to_hdmi_device(pos) container_of((pos), struct hdmi_device, list) |
34 | LIST_HEAD(hdmi_device_list); | 34 | LIST_HEAD(hdmi_device_list); |
35 | static DEFINE_MUTEX(hdmi_mutex); | ||
35 | 36 | ||
36 | #define DAI_NAME_SIZE 16 | 37 | #define DAI_NAME_SIZE 16 |
37 | 38 | ||
@@ -794,6 +795,7 @@ static int hdmi_codec_probe(struct platform_device *pdev) | |||
794 | return -ENOMEM; | 795 | return -ENOMEM; |
795 | 796 | ||
796 | hd = NULL; | 797 | hd = NULL; |
798 | mutex_lock(&hdmi_mutex); | ||
797 | list_for_each(pos, &hdmi_device_list) { | 799 | list_for_each(pos, &hdmi_device_list) { |
798 | struct hdmi_device *tmp = pos_to_hdmi_device(pos); | 800 | struct hdmi_device *tmp = pos_to_hdmi_device(pos); |
799 | 801 | ||
@@ -805,13 +807,16 @@ static int hdmi_codec_probe(struct platform_device *pdev) | |||
805 | 807 | ||
806 | if (!hd) { | 808 | if (!hd) { |
807 | hd = devm_kzalloc(dev, sizeof(*hd), GFP_KERNEL); | 809 | hd = devm_kzalloc(dev, sizeof(*hd), GFP_KERNEL); |
808 | if (!hd) | 810 | if (!hd) { |
811 | mutex_unlock(&hdmi_mutex); | ||
809 | return -ENOMEM; | 812 | return -ENOMEM; |
813 | } | ||
810 | 814 | ||
811 | hd->dev = dev->parent; | 815 | hd->dev = dev->parent; |
812 | 816 | ||
813 | list_add_tail(&hd->list, &hdmi_device_list); | 817 | list_add_tail(&hd->list, &hdmi_device_list); |
814 | } | 818 | } |
819 | mutex_unlock(&hdmi_mutex); | ||
815 | 820 | ||
816 | if (hd->cnt >= ARRAY_SIZE(hdmi_dai_name)) { | 821 | if (hd->cnt >= ARRAY_SIZE(hdmi_dai_name)) { |
817 | dev_err(dev, "too many hdmi codec are deteced\n"); | 822 | dev_err(dev, "too many hdmi codec are deteced\n"); |
@@ -853,11 +858,25 @@ static int hdmi_codec_probe(struct platform_device *pdev) | |||
853 | 858 | ||
854 | static int hdmi_codec_remove(struct platform_device *pdev) | 859 | static int hdmi_codec_remove(struct platform_device *pdev) |
855 | { | 860 | { |
861 | struct device *dev = &pdev->dev; | ||
862 | struct list_head *pos; | ||
856 | struct hdmi_codec_priv *hcp; | 863 | struct hdmi_codec_priv *hcp; |
857 | 864 | ||
858 | hcp = dev_get_drvdata(&pdev->dev); | 865 | mutex_lock(&hdmi_mutex); |
866 | list_for_each(pos, &hdmi_device_list) { | ||
867 | struct hdmi_device *tmp = pos_to_hdmi_device(pos); | ||
868 | |||
869 | if (tmp->dev == dev->parent) { | ||
870 | list_del(pos); | ||
871 | break; | ||
872 | } | ||
873 | } | ||
874 | mutex_unlock(&hdmi_mutex); | ||
875 | |||
876 | hcp = dev_get_drvdata(dev); | ||
859 | kfree(hcp->chmap_info); | 877 | kfree(hcp->chmap_info); |
860 | snd_soc_unregister_codec(&pdev->dev); | 878 | snd_soc_unregister_codec(dev); |
879 | |||
861 | return 0; | 880 | return 0; |
862 | } | 881 | } |
863 | 882 | ||