Message ID | 20170126225621.12314-14-noralf@tronnes.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Thank for this patch. It is working fine with sti driver. Acked-by: Vincent Abriou <vincent.abriou@st.com> Tested-by: Vincent Abriou <vincent.abriou@st.com> Vincent On 01/26/2017 11:56 PM, Noralf Trønnes wrote: > drm_debugfs_cleanup() now removes all minor->debugfs_list entries > automatically, so it's not necessary to call > drm_debugfs_remove_files(). Additionally it uses > debugfs_remove_recursive() to clean up the debugfs files, so no need > for adding fake drm_info_node entries. > > Cc: benjamin.gaignard@linaro.org > Cc: vincent.abriou@st.com > Signed-off-by: Noralf Trønnes <noralf@tronnes.org> > --- > drivers/gpu/drm/sti/sti_drv.c | 48 ++++++----------------------------------- > drivers/gpu/drm/sti/sti_dvo.c | 10 --------- > drivers/gpu/drm/sti/sti_hda.c | 11 ---------- > drivers/gpu/drm/sti/sti_hdmi.c | 11 ---------- > drivers/gpu/drm/sti/sti_tvout.c | 8 ------- > 5 files changed, 6 insertions(+), 82 deletions(-) > > diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c > index ff71e25..d3db224 100644 > --- a/drivers/gpu/drm/sti/sti_drv.c > +++ b/drivers/gpu/drm/sti/sti_drv.c > @@ -89,38 +89,9 @@ static struct drm_info_list sti_drm_dbg_list[] = { > {"fps_get", sti_drm_fps_dbg_show, 0}, > }; > > -static int sti_drm_debugfs_create(struct dentry *root, > - struct drm_minor *minor, > - const char *name, > - const struct file_operations *fops) > -{ > - struct drm_device *dev = minor->dev; > - struct drm_info_node *node; > - struct dentry *ent; > - > - ent = debugfs_create_file(name, S_IRUGO | S_IWUSR, root, dev, fops); > - if (IS_ERR(ent)) > - return PTR_ERR(ent); > - > - node = kmalloc(sizeof(*node), GFP_KERNEL); > - if (!node) { > - debugfs_remove(ent); > - return -ENOMEM; > - } > - > - node->minor = minor; > - node->dent = ent; > - node->info_ent = (void *)fops; > - > - mutex_lock(&minor->debugfs_lock); > - list_add(&node->list, &minor->debugfs_list); > - mutex_unlock(&minor->debugfs_lock); > - > - return 0; > -} > - > static int sti_drm_dbg_init(struct drm_minor *minor) > { > + struct dentry *dentry; > int ret; > > ret = drm_debugfs_create_files(sti_drm_dbg_list, > @@ -129,10 +100,13 @@ static int sti_drm_dbg_init(struct drm_minor *minor) > if (ret) > goto err; > > - ret = sti_drm_debugfs_create(minor->debugfs_root, minor, "fps_show", > + dentry = debugfs_create_file("fps_show", S_IRUGO | S_IWUSR, > + minor->debugfs_root, minor->dev, > &sti_drm_fps_fops); > - if (ret) > + if (!dentry) { > + ret = -ENOMEM; > goto err; > + } > > DRM_INFO("%s: debugfs installed\n", DRIVER_NAME); > return 0; > @@ -141,15 +115,6 @@ static int sti_drm_dbg_init(struct drm_minor *minor) > return ret; > } > > -static void sti_drm_dbg_cleanup(struct drm_minor *minor) > -{ > - drm_debugfs_remove_files(sti_drm_dbg_list, > - ARRAY_SIZE(sti_drm_dbg_list), minor); > - > - drm_debugfs_remove_files((struct drm_info_list *)&sti_drm_fps_fops, > - 1, minor); > -} > - > static void sti_atomic_schedule(struct sti_private *private, > struct drm_atomic_state *state) > { > @@ -326,7 +291,6 @@ static struct drm_driver sti_driver = { > .gem_prime_mmap = drm_gem_cma_prime_mmap, > > .debugfs_init = sti_drm_dbg_init, > - .debugfs_cleanup = sti_drm_dbg_cleanup, > > .name = DRIVER_NAME, > .desc = DRIVER_DESC, > diff --git a/drivers/gpu/drm/sti/sti_dvo.c b/drivers/gpu/drm/sti/sti_dvo.c > index 411dc6e..bb23318 100644 > --- a/drivers/gpu/drm/sti/sti_dvo.c > +++ b/drivers/gpu/drm/sti/sti_dvo.c > @@ -195,13 +195,6 @@ static struct drm_info_list dvo_debugfs_files[] = { > { "dvo", dvo_dbg_show, 0, NULL }, > }; > > -static void dvo_debugfs_exit(struct sti_dvo *dvo, struct drm_minor *minor) > -{ > - drm_debugfs_remove_files(dvo_debugfs_files, > - ARRAY_SIZE(dvo_debugfs_files), > - minor); > -} > - > static int dvo_debugfs_init(struct sti_dvo *dvo, struct drm_minor *minor) > { > unsigned int i; > @@ -514,9 +507,6 @@ static void sti_dvo_unbind(struct device *dev, > struct device *master, void *data) > { > struct sti_dvo *dvo = dev_get_drvdata(dev); > - struct drm_device *drm_dev = data; > - > - dvo_debugfs_exit(dvo, drm_dev->primary); > > drm_bridge_remove(dvo->bridge); > } > diff --git a/drivers/gpu/drm/sti/sti_hda.c b/drivers/gpu/drm/sti/sti_hda.c > index 66d37d78..0c0a75b 100644 > --- a/drivers/gpu/drm/sti/sti_hda.c > +++ b/drivers/gpu/drm/sti/sti_hda.c > @@ -365,13 +365,6 @@ static struct drm_info_list hda_debugfs_files[] = { > { "hda", hda_dbg_show, 0, NULL }, > }; > > -static void hda_debugfs_exit(struct sti_hda *hda, struct drm_minor *minor) > -{ > - drm_debugfs_remove_files(hda_debugfs_files, > - ARRAY_SIZE(hda_debugfs_files), > - minor); > -} > - > static int hda_debugfs_init(struct sti_hda *hda, struct drm_minor *minor) > { > unsigned int i; > @@ -739,10 +732,6 @@ static int sti_hda_bind(struct device *dev, struct device *master, void *data) > static void sti_hda_unbind(struct device *dev, > struct device *master, void *data) > { > - struct sti_hda *hda = dev_get_drvdata(dev); > - struct drm_device *drm_dev = data; > - > - hda_debugfs_exit(hda, drm_dev->primary); > } > > static const struct component_ops sti_hda_ops = { > diff --git a/drivers/gpu/drm/sti/sti_hdmi.c b/drivers/gpu/drm/sti/sti_hdmi.c > index f0af1ae..4a8bd62 100644 > --- a/drivers/gpu/drm/sti/sti_hdmi.c > +++ b/drivers/gpu/drm/sti/sti_hdmi.c > @@ -731,13 +731,6 @@ static struct drm_info_list hdmi_debugfs_files[] = { > { "hdmi", hdmi_dbg_show, 0, NULL }, > }; > > -static void hdmi_debugfs_exit(struct sti_hdmi *hdmi, struct drm_minor *minor) > -{ > - drm_debugfs_remove_files(hdmi_debugfs_files, > - ARRAY_SIZE(hdmi_debugfs_files), > - minor); > -} > - > static int hdmi_debugfs_init(struct sti_hdmi *hdmi, struct drm_minor *minor) > { > unsigned int i; > @@ -1359,10 +1352,6 @@ static int sti_hdmi_bind(struct device *dev, struct device *master, void *data) > static void sti_hdmi_unbind(struct device *dev, > struct device *master, void *data) > { > - struct sti_hdmi *hdmi = dev_get_drvdata(dev); > - struct drm_device *drm_dev = data; > - > - hdmi_debugfs_exit(hdmi, drm_dev->primary); > } > > static const struct component_ops sti_hdmi_ops = { > diff --git a/drivers/gpu/drm/sti/sti_tvout.c b/drivers/gpu/drm/sti/sti_tvout.c > index ad46d35..8b8ea71 100644 > --- a/drivers/gpu/drm/sti/sti_tvout.c > +++ b/drivers/gpu/drm/sti/sti_tvout.c > @@ -567,13 +567,6 @@ static struct drm_info_list tvout_debugfs_files[] = { > { "tvout", tvout_dbg_show, 0, NULL }, > }; > > -static void tvout_debugfs_exit(struct sti_tvout *tvout, struct drm_minor *minor) > -{ > - drm_debugfs_remove_files(tvout_debugfs_files, > - ARRAY_SIZE(tvout_debugfs_files), > - minor); > -} > - > static int tvout_debugfs_init(struct sti_tvout *tvout, struct drm_minor *minor) > { > unsigned int i; > @@ -627,7 +620,6 @@ static void sti_tvout_early_unregister(struct drm_encoder *encoder) > if (!tvout->debugfs_registered) > return; > > - tvout_debugfs_exit(tvout, encoder->dev->primary); > tvout->debugfs_registered = false; > } > >
diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c index ff71e25..d3db224 100644 --- a/drivers/gpu/drm/sti/sti_drv.c +++ b/drivers/gpu/drm/sti/sti_drv.c @@ -89,38 +89,9 @@ static struct drm_info_list sti_drm_dbg_list[] = { {"fps_get", sti_drm_fps_dbg_show, 0}, }; -static int sti_drm_debugfs_create(struct dentry *root, - struct drm_minor *minor, - const char *name, - const struct file_operations *fops) -{ - struct drm_device *dev = minor->dev; - struct drm_info_node *node; - struct dentry *ent; - - ent = debugfs_create_file(name, S_IRUGO | S_IWUSR, root, dev, fops); - if (IS_ERR(ent)) - return PTR_ERR(ent); - - node = kmalloc(sizeof(*node), GFP_KERNEL); - if (!node) { - debugfs_remove(ent); - return -ENOMEM; - } - - node->minor = minor; - node->dent = ent; - node->info_ent = (void *)fops; - - mutex_lock(&minor->debugfs_lock); - list_add(&node->list, &minor->debugfs_list); - mutex_unlock(&minor->debugfs_lock); - - return 0; -} - static int sti_drm_dbg_init(struct drm_minor *minor) { + struct dentry *dentry; int ret; ret = drm_debugfs_create_files(sti_drm_dbg_list, @@ -129,10 +100,13 @@ static int sti_drm_dbg_init(struct drm_minor *minor) if (ret) goto err; - ret = sti_drm_debugfs_create(minor->debugfs_root, minor, "fps_show", + dentry = debugfs_create_file("fps_show", S_IRUGO | S_IWUSR, + minor->debugfs_root, minor->dev, &sti_drm_fps_fops); - if (ret) + if (!dentry) { + ret = -ENOMEM; goto err; + } DRM_INFO("%s: debugfs installed\n", DRIVER_NAME); return 0; @@ -141,15 +115,6 @@ static int sti_drm_dbg_init(struct drm_minor *minor) return ret; } -static void sti_drm_dbg_cleanup(struct drm_minor *minor) -{ - drm_debugfs_remove_files(sti_drm_dbg_list, - ARRAY_SIZE(sti_drm_dbg_list), minor); - - drm_debugfs_remove_files((struct drm_info_list *)&sti_drm_fps_fops, - 1, minor); -} - static void sti_atomic_schedule(struct sti_private *private, struct drm_atomic_state *state) { @@ -326,7 +291,6 @@ static struct drm_driver sti_driver = { .gem_prime_mmap = drm_gem_cma_prime_mmap, .debugfs_init = sti_drm_dbg_init, - .debugfs_cleanup = sti_drm_dbg_cleanup, .name = DRIVER_NAME, .desc = DRIVER_DESC, diff --git a/drivers/gpu/drm/sti/sti_dvo.c b/drivers/gpu/drm/sti/sti_dvo.c index 411dc6e..bb23318 100644 --- a/drivers/gpu/drm/sti/sti_dvo.c +++ b/drivers/gpu/drm/sti/sti_dvo.c @@ -195,13 +195,6 @@ static struct drm_info_list dvo_debugfs_files[] = { { "dvo", dvo_dbg_show, 0, NULL }, }; -static void dvo_debugfs_exit(struct sti_dvo *dvo, struct drm_minor *minor) -{ - drm_debugfs_remove_files(dvo_debugfs_files, - ARRAY_SIZE(dvo_debugfs_files), - minor); -} - static int dvo_debugfs_init(struct sti_dvo *dvo, struct drm_minor *minor) { unsigned int i; @@ -514,9 +507,6 @@ static void sti_dvo_unbind(struct device *dev, struct device *master, void *data) { struct sti_dvo *dvo = dev_get_drvdata(dev); - struct drm_device *drm_dev = data; - - dvo_debugfs_exit(dvo, drm_dev->primary); drm_bridge_remove(dvo->bridge); } diff --git a/drivers/gpu/drm/sti/sti_hda.c b/drivers/gpu/drm/sti/sti_hda.c index 66d37d78..0c0a75b 100644 --- a/drivers/gpu/drm/sti/sti_hda.c +++ b/drivers/gpu/drm/sti/sti_hda.c @@ -365,13 +365,6 @@ static struct drm_info_list hda_debugfs_files[] = { { "hda", hda_dbg_show, 0, NULL }, }; -static void hda_debugfs_exit(struct sti_hda *hda, struct drm_minor *minor) -{ - drm_debugfs_remove_files(hda_debugfs_files, - ARRAY_SIZE(hda_debugfs_files), - minor); -} - static int hda_debugfs_init(struct sti_hda *hda, struct drm_minor *minor) { unsigned int i; @@ -739,10 +732,6 @@ static int sti_hda_bind(struct device *dev, struct device *master, void *data) static void sti_hda_unbind(struct device *dev, struct device *master, void *data) { - struct sti_hda *hda = dev_get_drvdata(dev); - struct drm_device *drm_dev = data; - - hda_debugfs_exit(hda, drm_dev->primary); } static const struct component_ops sti_hda_ops = { diff --git a/drivers/gpu/drm/sti/sti_hdmi.c b/drivers/gpu/drm/sti/sti_hdmi.c index f0af1ae..4a8bd62 100644 --- a/drivers/gpu/drm/sti/sti_hdmi.c +++ b/drivers/gpu/drm/sti/sti_hdmi.c @@ -731,13 +731,6 @@ static struct drm_info_list hdmi_debugfs_files[] = { { "hdmi", hdmi_dbg_show, 0, NULL }, }; -static void hdmi_debugfs_exit(struct sti_hdmi *hdmi, struct drm_minor *minor) -{ - drm_debugfs_remove_files(hdmi_debugfs_files, - ARRAY_SIZE(hdmi_debugfs_files), - minor); -} - static int hdmi_debugfs_init(struct sti_hdmi *hdmi, struct drm_minor *minor) { unsigned int i; @@ -1359,10 +1352,6 @@ static int sti_hdmi_bind(struct device *dev, struct device *master, void *data) static void sti_hdmi_unbind(struct device *dev, struct device *master, void *data) { - struct sti_hdmi *hdmi = dev_get_drvdata(dev); - struct drm_device *drm_dev = data; - - hdmi_debugfs_exit(hdmi, drm_dev->primary); } static const struct component_ops sti_hdmi_ops = { diff --git a/drivers/gpu/drm/sti/sti_tvout.c b/drivers/gpu/drm/sti/sti_tvout.c index ad46d35..8b8ea71 100644 --- a/drivers/gpu/drm/sti/sti_tvout.c +++ b/drivers/gpu/drm/sti/sti_tvout.c @@ -567,13 +567,6 @@ static struct drm_info_list tvout_debugfs_files[] = { { "tvout", tvout_dbg_show, 0, NULL }, }; -static void tvout_debugfs_exit(struct sti_tvout *tvout, struct drm_minor *minor) -{ - drm_debugfs_remove_files(tvout_debugfs_files, - ARRAY_SIZE(tvout_debugfs_files), - minor); -} - static int tvout_debugfs_init(struct sti_tvout *tvout, struct drm_minor *minor) { unsigned int i; @@ -627,7 +620,6 @@ static void sti_tvout_early_unregister(struct drm_encoder *encoder) if (!tvout->debugfs_registered) return; - tvout_debugfs_exit(tvout, encoder->dev->primary); tvout->debugfs_registered = false; }
drm_debugfs_cleanup() now removes all minor->debugfs_list entries automatically, so it's not necessary to call drm_debugfs_remove_files(). Additionally it uses debugfs_remove_recursive() to clean up the debugfs files, so no need for adding fake drm_info_node entries. Cc: benjamin.gaignard@linaro.org Cc: vincent.abriou@st.com Signed-off-by: Noralf Trønnes <noralf@tronnes.org> --- drivers/gpu/drm/sti/sti_drv.c | 48 ++++++----------------------------------- drivers/gpu/drm/sti/sti_dvo.c | 10 --------- drivers/gpu/drm/sti/sti_hda.c | 11 ---------- drivers/gpu/drm/sti/sti_hdmi.c | 11 ---------- drivers/gpu/drm/sti/sti_tvout.c | 8 ------- 5 files changed, 6 insertions(+), 82 deletions(-)