From 88bd00640f8a08afd396407569ed0122958e0541 Mon Sep 17 00:00:00 2001 From: xuhuicong Date: Mon, 26 Jun 2017 16:27:26 +0800 Subject: [PATCH] drm: bridge/dw-hdmi: add platform_device_unregister when remove Change-Id: I7fdc7046b0065329abddbe503c9acd576175670a Signed-off-by: xuhuicong --- drivers/gpu/drm/bridge/dw-hdmi-audio.h | 1 + drivers/gpu/drm/bridge/dw-hdmi-i2s-audio.c | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/bridge/dw-hdmi-audio.h b/drivers/gpu/drm/bridge/dw-hdmi-audio.h index b9e839f4151a..d3194b4e186b 100644 --- a/drivers/gpu/drm/bridge/dw-hdmi-audio.h +++ b/drivers/gpu/drm/bridge/dw-hdmi-audio.h @@ -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); diff --git a/drivers/gpu/drm/bridge/dw-hdmi-i2s-audio.c b/drivers/gpu/drm/bridge/dw-hdmi-i2s-audio.c index d4ad3f0014e7..f1f62d8c1d16 100644 --- a/drivers/gpu/drm/bridge/dw-hdmi-i2s-audio.c +++ b/drivers/gpu/drm/bridge/dw-hdmi-i2s-audio.c @@ -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, -- 2.34.1