Re: [PATCH 13/19] drm/sti: Remove drm_debugfs_remove_files() calls

2017-01-27 Thread Vincent ABRIOU
Thank for this patch.
It is working fine with sti driver.

Acked-by: Vincent Abriou 
Tested-by: Vincent Abriou 

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.gaign...@linaro.org
> Cc: vincent.abr...@st.com
> Signed-off-by: Noralf Trønnes 
> ---
>  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(>debugfs_lock);
> - list_add(>list, >debugfs_list);
> - mutex_unlock(>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,
>_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 *)_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", 

[PATCH 13/19] drm/sti: Remove drm_debugfs_remove_files() calls

2017-01-26 Thread Noralf Trønnes
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.gaign...@linaro.org
Cc: vincent.abr...@st.com
Signed-off-by: Noralf Trønnes 
---
 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(>debugfs_lock);
-   list_add(>list, >debugfs_list);
-   mutex_unlock(>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,
 _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 *)_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)
 {