drm: bridge/dw-hdmi: add platform_device_unregister when remove
authorxuhuicong <xhc@rock-chips.com>
Mon, 26 Jun 2017 08:27:26 +0000 (16:27 +0800)
committerJianqun Xu <jay.xu@rock-chips.com>
Tue, 27 Jun 2017 00:12:15 +0000 (08:12 +0800)
Change-Id: I7fdc7046b0065329abddbe503c9acd576175670a
Signed-off-by: xuhuicong <xhc@rock-chips.com>
drivers/gpu/drm/bridge/dw-hdmi-audio.h
drivers/gpu/drm/bridge/dw-hdmi-i2s-audio.c

index b9e839f4151a62cd05e3c42e192d5fc4b6237757..d3194b4e186b71c6c272e12f32cd501061036ab3 100644 (file)
@@ -13,6 +13,7 @@ struct dw_hdmi_audio_data {
 
 struct dw_hdmi_i2s_audio_data {
        struct dw_hdmi *hdmi;
+       struct platform_device *pdev;
 
        void (*write)(struct dw_hdmi *hdmi, u8 val, int offset);
        u8 (*read)(struct dw_hdmi *hdmi, int offset);
index d4ad3f0014e7ef0db628f70ad6f076eca3e3b196..f1f62d8c1d16cb5b5087a9e7f1fd309b7e1fe326 100644 (file)
@@ -234,11 +234,23 @@ static int snd_dw_hdmi_probe(struct platform_device *pdev)
        pdevinfo.size_data      = sizeof(pdata);
        pdevinfo.dma_mask       = DMA_BIT_MASK(32);
 
-       return IS_ERR_OR_NULL(platform_device_register_full(&pdevinfo));
+       audio->pdev = platform_device_register_full(&pdevinfo);
+       return IS_ERR_OR_NULL(audio->pdev);
+}
+
+static int snd_dw_hdmi_remove(struct platform_device *pdev)
+{
+       struct dw_hdmi_i2s_audio_data *audio = pdev->dev.platform_data;
+
+       if (!IS_ERR_OR_NULL(audio->pdev))
+               platform_device_unregister(audio->pdev);
+
+       return 0;
 }
 
 static struct platform_driver snd_dw_hdmi_driver = {
        .probe  = snd_dw_hdmi_probe,
+       .remove = snd_dw_hdmi_remove,
        .driver = {
                .name = DRIVER_NAME,
                .owner = THIS_MODULE,