All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nirmoy Das <nirmoy.das@amd.com>
To: <dri-devel@lists.freedesktop.org>
Cc: <intel-gfx@lists.freedesktop.org>,
	Nirmoy Das <nirmoy.das@amd.com>,
	Christian Koenig <christian.koenig@amd.com>,
	Huang Rui <ray.huang@amd.com>, David Airlie <airlied@linux.ie>,
	Daniel Vetter <daniel@ffwll.ch>
Subject: [PATCH 2/4] drm/ttm: do not set NULL to debugfs dentry
Date: Wed, 13 Oct 2021 20:35:59 +0200	[thread overview]
Message-ID: <20211013183601.16514-2-nirmoy.das@amd.com> (raw)
In-Reply-To: <20211013183601.16514-1-nirmoy.das@amd.com>

For debugfs directory, it is recommended to save the result
and pass over to next debugfs API for creating debugfs
files/directories. Error conditions are handled by debugfs APIs.

CC: Christian Koenig <christian.koenig@amd.com>
CC: Huang Rui <ray.huang@amd.com>
CC: David Airlie <airlied@linux.ie>
CC: Daniel Vetter <daniel@ffwll.ch>

Signed-off-by: Nirmoy Das <nirmoy.das@amd.com>
---
 drivers/gpu/drm/ttm/ttm_device.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_device.c b/drivers/gpu/drm/ttm/ttm_device.c
index be24bb6cefd0..2c66f06198e9 100644
--- a/drivers/gpu/drm/ttm/ttm_device.c
+++ b/drivers/gpu/drm/ttm/ttm_device.c
@@ -44,6 +44,7 @@ static unsigned ttm_glob_use_count;
 struct ttm_global ttm_glob;
 EXPORT_SYMBOL(ttm_glob);
 
+/* Do not deference this pointer as it will contain ERR_PTR on error. */
 struct dentry *ttm_debugfs_root;
 
 static void ttm_global_release(void)
@@ -77,9 +78,6 @@ static int ttm_global_init(void)
 	si_meminfo(&si);
 
 	ttm_debugfs_root = debugfs_create_dir("ttm", NULL);
-	if (IS_ERR(ttm_debugfs_root)) {
-		ttm_debugfs_root = NULL;
-	}
 
 	/* Limit the number of pages in the pool to about 50% of the total
 	 * system memory.
@@ -108,8 +106,7 @@ static int ttm_global_init(void)
 	debugfs_create_atomic_t("buffer_objects", 0444, ttm_debugfs_root,
 				&glob->bo_count);
 out:
-	if (ret && ttm_debugfs_root)
-		debugfs_remove(ttm_debugfs_root);
+	debugfs_remove(ttm_debugfs_root);
 	if (ret)
 		--ttm_glob_use_count;
 	mutex_unlock(&ttm_global_mutex);
-- 
2.32.0


WARNING: multiple messages have this Message-ID (diff)
From: Nirmoy Das <nirmoy.das@amd.com>
To: <dri-devel@lists.freedesktop.org>
Cc: <intel-gfx@lists.freedesktop.org>,
	Nirmoy Das <nirmoy.das@amd.com>,
	Christian Koenig <christian.koenig@amd.com>,
	Huang Rui <ray.huang@amd.com>, David Airlie <airlied@linux.ie>,
	Daniel Vetter <daniel@ffwll.ch>
Subject: [Intel-gfx] [PATCH 2/4] drm/ttm: do not set NULL to debugfs dentry
Date: Wed, 13 Oct 2021 20:35:59 +0200	[thread overview]
Message-ID: <20211013183601.16514-2-nirmoy.das@amd.com> (raw)
In-Reply-To: <20211013183601.16514-1-nirmoy.das@amd.com>

For debugfs directory, it is recommended to save the result
and pass over to next debugfs API for creating debugfs
files/directories. Error conditions are handled by debugfs APIs.

CC: Christian Koenig <christian.koenig@amd.com>
CC: Huang Rui <ray.huang@amd.com>
CC: David Airlie <airlied@linux.ie>
CC: Daniel Vetter <daniel@ffwll.ch>

Signed-off-by: Nirmoy Das <nirmoy.das@amd.com>
---
 drivers/gpu/drm/ttm/ttm_device.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_device.c b/drivers/gpu/drm/ttm/ttm_device.c
index be24bb6cefd0..2c66f06198e9 100644
--- a/drivers/gpu/drm/ttm/ttm_device.c
+++ b/drivers/gpu/drm/ttm/ttm_device.c
@@ -44,6 +44,7 @@ static unsigned ttm_glob_use_count;
 struct ttm_global ttm_glob;
 EXPORT_SYMBOL(ttm_glob);
 
+/* Do not deference this pointer as it will contain ERR_PTR on error. */
 struct dentry *ttm_debugfs_root;
 
 static void ttm_global_release(void)
@@ -77,9 +78,6 @@ static int ttm_global_init(void)
 	si_meminfo(&si);
 
 	ttm_debugfs_root = debugfs_create_dir("ttm", NULL);
-	if (IS_ERR(ttm_debugfs_root)) {
-		ttm_debugfs_root = NULL;
-	}
 
 	/* Limit the number of pages in the pool to about 50% of the total
 	 * system memory.
@@ -108,8 +106,7 @@ static int ttm_global_init(void)
 	debugfs_create_atomic_t("buffer_objects", 0444, ttm_debugfs_root,
 				&glob->bo_count);
 out:
-	if (ret && ttm_debugfs_root)
-		debugfs_remove(ttm_debugfs_root);
+	debugfs_remove(ttm_debugfs_root);
 	if (ret)
 		--ttm_glob_use_count;
 	mutex_unlock(&ttm_global_mutex);
-- 
2.32.0


  reply	other threads:[~2021-10-13 18:36 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-13 18:35 [PATCH v2 1/4] dri: do not check for NULL debugfs dentry Nirmoy Das
2021-10-13 18:35 ` [Intel-gfx] " Nirmoy Das
2021-10-13 18:35 ` Nirmoy Das [this message]
2021-10-13 18:35   ` [Intel-gfx] [PATCH 2/4] drm/ttm: do not set NULL to " Nirmoy Das
2021-10-13 18:36 ` [PATCH 3/4] drm/i915/gt: do not check for NULL " Nirmoy Das
2021-10-13 18:36   ` [Intel-gfx] " Nirmoy Das
2021-10-13 18:36 ` [PATCH v2 4/4] vgaswitcheroo: " Nirmoy Das
2021-10-13 18:36   ` [Intel-gfx] " Nirmoy Das
2021-10-17 20:03   ` Lukas Wunner
2021-10-17 20:03     ` Lukas Wunner
2021-10-18  8:28     ` Das, Nirmoy
2021-10-18  8:28       ` [Intel-gfx] " Das, Nirmoy
2021-10-13 18:43 ` [PATCH v2 1/4] dri: " Das, Nirmoy
2021-10-13 18:43   ` [Intel-gfx] " Das, Nirmoy
2021-10-13 19:00 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for series starting with [v2,1/4] " Patchwork
2021-10-13 19:03 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2021-10-13 19:32 ` [Intel-gfx] ✗ Fi.CI.BAT: failure " Patchwork
  -- strict thread matches above, loose matches on Subject: below --
2021-10-11 19:06 [PATCH 1/4] " Nirmoy Das
2021-10-11 19:06 ` [PATCH 2/4] drm/ttm: do not set NULL to " Nirmoy Das
2021-10-12  7:09   ` Christian König
2021-10-12  8:49     ` Das, Nirmoy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211013183601.16514-2-nirmoy.das@amd.com \
    --to=nirmoy.das@amd.com \
    --cc=airlied@linux.ie \
    --cc=christian.koenig@amd.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=ray.huang@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.