From 598534ea8c0d293c681178746ccb9d87221ecf8d Mon Sep 17 00:00:00 2001 From: xuhuicong Date: Sat, 24 Jun 2017 18:10:00 +0800 Subject: [PATCH] drm: bridge: dw-hdmi: add debugfs_remove_recursive when unbind On RK3328, dw-hdmi driver is reloaded after bind and unbind then it will use the first register debugfs address if no run debugfs_remove_recursive, and cause system crash. Change-Id: Iafa6b4059962b62c79157a9cf6c3e1d56df48f03 Signed-off-by: xuhuicong --- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c index 65257044bca2..1f3be402882e 100644 --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c @@ -258,6 +258,7 @@ struct dw_hdmi { spinlock_t audio_lock; struct mutex audio_mutex; + struct dentry *debugfs_dir; unsigned int sample_rate; unsigned int audio_cts; unsigned int audio_n; @@ -3516,18 +3517,16 @@ static const struct file_operations dw_hdmi_phy_fops = { static void dw_hdmi_register_debugfs(struct device *dev, struct dw_hdmi *hdmi) { - struct dentry *debugfs_dir; - - debugfs_dir = debugfs_create_dir("dw-hdmi", NULL); - if (IS_ERR(debugfs_dir)) { + hdmi->debugfs_dir = debugfs_create_dir("dw-hdmi", NULL); + if (IS_ERR(hdmi->debugfs_dir)) { dev_err(dev, "failed to create debugfs dir!\n"); return; } - debugfs_create_file("status", 0400, debugfs_dir, + debugfs_create_file("status", 0400, hdmi->debugfs_dir, hdmi, &dw_hdmi_status_fops); - debugfs_create_file("ctrl", 0400, debugfs_dir, + debugfs_create_file("ctrl", 0400, hdmi->debugfs_dir, hdmi, &dw_hdmi_ctrl_fops); - debugfs_create_file("phy", 0400, debugfs_dir, + debugfs_create_file("phy", 0400, hdmi->debugfs_dir, hdmi, &dw_hdmi_phy_fops); } @@ -3886,6 +3885,8 @@ static void __dw_hdmi_remove(struct dw_hdmi *hdmi) flush_workqueue(hdmi->workqueue); destroy_workqueue(hdmi->workqueue); + debugfs_remove_recursive(hdmi->debugfs_dir); + if (hdmi->audio && !IS_ERR(hdmi->audio)) platform_device_unregister(hdmi->audio); if (hdmi->hdcp_dev && !IS_ERR(hdmi->hdcp_dev))