drm/i915: Remove i915_debugfs_unregister()
authorNoralf Trønnes <noralf@tronnes.org>
Thu, 26 Jan 2017 22:56:21 +0000 (23:56 +0100)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Wed, 1 Mar 2017 15:09:52 +0000 (16:09 +0100)
drm_debugfs_cleanup() now removes all minor->debugfs_list entries
automatically, so no need to do this explicitly. Additionally it
uses debugfs_remove_recursive() to clean up the debugfs files,
so no need for adding fake drm_info_node entries.

Cc: daniel.vetter@intel.com
Cc: jani.nikula@linux.intel.com
Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20170126225621.12314-20-noralf@tronnes.org
drivers/gpu/drm/i915/i915_debugfs.c
drivers/gpu/drm/i915/i915_drv.c
drivers/gpu/drm/i915/i915_drv.h
drivers/gpu/drm/i915/intel_drv.h
drivers/gpu/drm/i915/intel_pipe_crc.c

index fa69d72fdcb9ff45e6590402bb59b9b325d65c38..7d7244798507de0ac773927cba3e1676baa98696 100644 (file)
@@ -35,32 +35,6 @@ static inline struct drm_i915_private *node_to_i915(struct drm_info_node *node)
        return to_i915(node->minor->dev);
 }
 
-/* As the drm_debugfs_init() routines are called before dev->dev_private is
- * allocated we need to hook into the minor for release. */
-static int
-drm_add_fake_info_node(struct drm_minor *minor,
-                      struct dentry *ent,
-                      const void *key)
-{
-       struct drm_info_node *node;
-
-       node = kmalloc(sizeof(*node), GFP_KERNEL);
-       if (node == NULL) {
-               debugfs_remove(ent);
-               return -ENOMEM;
-       }
-
-       node->minor = minor;
-       node->dent = ent;
-       node->info_ent = (void *)key;
-
-       mutex_lock(&minor->debugfs_lock);
-       list_add(&node->list, &minor->debugfs_list);
-       mutex_unlock(&minor->debugfs_lock);
-
-       return 0;
-}
-
 static int i915_capabilities(struct seq_file *m, void *data)
 {
        struct drm_i915_private *dev_priv = node_to_i915(m->private);
@@ -4593,37 +4567,6 @@ static const struct file_operations i915_forcewake_fops = {
        .release = i915_forcewake_release,
 };
 
-static int i915_forcewake_create(struct dentry *root, struct drm_minor *minor)
-{
-       struct dentry *ent;
-
-       ent = debugfs_create_file("i915_forcewake_user",
-                                 S_IRUSR,
-                                 root, to_i915(minor->dev),
-                                 &i915_forcewake_fops);
-       if (!ent)
-               return -ENOMEM;
-
-       return drm_add_fake_info_node(minor, ent, &i915_forcewake_fops);
-}
-
-static int i915_debugfs_create(struct dentry *root,
-                              struct drm_minor *minor,
-                              const char *name,
-                              const struct file_operations *fops)
-{
-       struct dentry *ent;
-
-       ent = debugfs_create_file(name,
-                                 S_IRUGO | S_IWUSR,
-                                 root, to_i915(minor->dev),
-                                 fops);
-       if (!ent)
-               return -ENOMEM;
-
-       return drm_add_fake_info_node(minor, ent, fops);
-}
-
 static const struct drm_info_list i915_debugfs_list[] = {
        {"i915_capabilities", i915_capabilities, 0},
        {"i915_gem_objects", i915_gem_object_info, 0},
@@ -4706,22 +4649,27 @@ static const struct i915_debugfs_files {
 int i915_debugfs_register(struct drm_i915_private *dev_priv)
 {
        struct drm_minor *minor = dev_priv->drm.primary;
+       struct dentry *ent;
        int ret, i;
 
-       ret = i915_forcewake_create(minor->debugfs_root, minor);
-       if (ret)
-               return ret;
+       ent = debugfs_create_file("i915_forcewake_user", S_IRUSR,
+                                 minor->debugfs_root, to_i915(minor->dev),
+                                 &i915_forcewake_fops);
+       if (!ent)
+               return -ENOMEM;
 
        ret = intel_pipe_crc_create(minor);
        if (ret)
                return ret;
 
        for (i = 0; i < ARRAY_SIZE(i915_debugfs_files); i++) {
-               ret = i915_debugfs_create(minor->debugfs_root, minor,
-                                         i915_debugfs_files[i].name,
+               ent = debugfs_create_file(i915_debugfs_files[i].name,
+                                         S_IRUGO | S_IWUSR,
+                                         minor->debugfs_root,
+                                         to_i915(minor->dev),
                                          i915_debugfs_files[i].fops);
-               if (ret)
-                       return ret;
+               if (!ent)
+                       return -ENOMEM;
        }
 
        return drm_debugfs_create_files(i915_debugfs_list,
@@ -4729,27 +4677,6 @@ int i915_debugfs_register(struct drm_i915_private *dev_priv)
                                        minor->debugfs_root, minor);
 }
 
-void i915_debugfs_unregister(struct drm_i915_private *dev_priv)
-{
-       struct drm_minor *minor = dev_priv->drm.primary;
-       int i;
-
-       drm_debugfs_remove_files(i915_debugfs_list,
-                                I915_DEBUGFS_ENTRIES, minor);
-
-       drm_debugfs_remove_files((struct drm_info_list *)&i915_forcewake_fops,
-                                1, minor);
-
-       intel_pipe_crc_cleanup(minor);
-
-       for (i = 0; i < ARRAY_SIZE(i915_debugfs_files); i++) {
-               struct drm_info_list *info_list =
-                       (struct drm_info_list *)i915_debugfs_files[i].fops;
-
-               drm_debugfs_remove_files(info_list, 1, minor);
-       }
-}
-
 struct dpcd_block {
        /* DPCD dump start address. */
        unsigned int offset;
index f6017f2cfb864d4d1e7573e472838516074bbe62..8cdafef8eac9d9578008bbeb33e935aca3e65dd8 100644 (file)
@@ -1167,7 +1167,6 @@ static void i915_driver_unregister(struct drm_i915_private *dev_priv)
 
        i915_teardown_sysfs(dev_priv);
        i915_guc_log_unregister(dev_priv);
-       i915_debugfs_unregister(dev_priv);
        drm_dev_unregister(&dev_priv->drm);
 
        i915_gem_shrinker_cleanup(dev_priv);
index e44c598ecb82d1a891841bb6bd069fb69957b20e..75b0497649b9bbf565db8d09304c28dd9c9bcb43 100644 (file)
@@ -3522,12 +3522,10 @@ u32 i915_gem_fence_alignment(struct drm_i915_private *dev_priv, u32 size,
 /* i915_debugfs.c */
 #ifdef CONFIG_DEBUG_FS
 int i915_debugfs_register(struct drm_i915_private *dev_priv);
-void i915_debugfs_unregister(struct drm_i915_private *dev_priv);
 int i915_debugfs_connector_add(struct drm_connector *connector);
 void intel_display_crc_init(struct drm_i915_private *dev_priv);
 #else
 static inline int i915_debugfs_register(struct drm_i915_private *dev_priv) {return 0;}
-static inline void i915_debugfs_unregister(struct drm_i915_private *dev_priv) {}
 static inline int i915_debugfs_connector_add(struct drm_connector *connector)
 { return 0; }
 static inline void intel_display_crc_init(struct drm_i915_private *dev_priv) {}
index 40fed65a791d9fa56765a79be980740352443d6b..3b797909f631d3185b619acce88f5f9d6dce7fe8 100644 (file)
@@ -1888,7 +1888,6 @@ void lspcon_wait_pcon_mode(struct intel_lspcon *lspcon);
 
 /* intel_pipe_crc.c */
 int intel_pipe_crc_create(struct drm_minor *minor);
-void intel_pipe_crc_cleanup(struct drm_minor *minor);
 #ifdef CONFIG_DEBUG_FS
 int intel_crtc_set_crc_source(struct drm_crtc *crtc, const char *source_name,
                              size_t *values_cnt);
index c0b1f99da37b34c914fe180c856bec51dc4c333f..5aa524e32df776970445ef5258ba5ca4628928d7 100644 (file)
@@ -36,31 +36,6 @@ struct pipe_crc_info {
        enum pipe pipe;
 };
 
-/* As the drm_debugfs_init() routines are called before dev->dev_private is
- * allocated we need to hook into the minor for release.
- */
-static int drm_add_fake_info_node(struct drm_minor *minor,
-                                 struct dentry *ent, const void *key)
-{
-       struct drm_info_node *node;
-
-       node = kmalloc(sizeof(*node), GFP_KERNEL);
-       if (node == NULL) {
-               debugfs_remove(ent);
-               return -ENOMEM;
-       }
-
-       node->minor = minor;
-       node->dent = ent;
-       node->info_ent = (void *) key;
-
-       mutex_lock(&minor->debugfs_lock);
-       list_add(&node->list, &minor->debugfs_list);
-       mutex_unlock(&minor->debugfs_lock);
-
-       return 0;
-}
-
 static int i915_pipe_crc_open(struct inode *inode, struct file *filep)
 {
        struct pipe_crc_info *info = inode->i_private;
@@ -209,22 +184,6 @@ static struct pipe_crc_info i915_pipe_crc_data[I915_MAX_PIPES] = {
        },
 };
 
-static int i915_pipe_crc_create(struct dentry *root, struct drm_minor *minor,
-                               enum pipe pipe)
-{
-       struct drm_i915_private *dev_priv = to_i915(minor->dev);
-       struct dentry *ent;
-       struct pipe_crc_info *info = &i915_pipe_crc_data[pipe];
-
-       info->dev_priv = dev_priv;
-       ent = debugfs_create_file(info->name, S_IRUGO, root, info,
-                                 &i915_pipe_crc_fops);
-       if (!ent)
-               return -ENOMEM;
-
-       return drm_add_fake_info_node(minor, ent, info);
-}
-
 static const char * const pipe_crc_sources[] = {
        "none",
        "plane1",
@@ -928,27 +887,22 @@ void intel_display_crc_init(struct drm_i915_private *dev_priv)
 
 int intel_pipe_crc_create(struct drm_minor *minor)
 {
-       int ret, i;
-
-       for (i = 0; i < ARRAY_SIZE(i915_pipe_crc_data); i++) {
-               ret = i915_pipe_crc_create(minor->debugfs_root, minor, i);
-               if (ret)
-                       return ret;
-       }
-
-       return 0;
-}
-
-void intel_pipe_crc_cleanup(struct drm_minor *minor)
-{
+       struct drm_i915_private *dev_priv = to_i915(minor->dev);
+       struct dentry *ent;
        int i;
 
        for (i = 0; i < ARRAY_SIZE(i915_pipe_crc_data); i++) {
-               struct drm_info_list *info_list =
-                       (struct drm_info_list *)&i915_pipe_crc_data[i];
+               struct pipe_crc_info *info = &i915_pipe_crc_data[i];
 
-               drm_debugfs_remove_files(info_list, 1, minor);
+               info->dev_priv = dev_priv;
+               ent = debugfs_create_file(info->name, S_IRUGO,
+                                         minor->debugfs_root, info,
+                                         &i915_pipe_crc_fops);
+               if (!ent)
+                       return -ENOMEM;
        }
+
+       return 0;
 }
 
 int intel_crtc_set_crc_source(struct drm_crtc *crtc, const char *source_name,