diff mbox

[23/34] drm: Simplify drm_mm_clean()

Message ID 20161212115350.780-24-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show

Commit Message

Chris Wilson Dec. 12, 2016, 11:53 a.m. UTC
To test whether there are any nodes allocated within the range manager,
we merely have to ask whether the node_list is empty.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/drm_mm.c | 19 +------------------
 include/drm/drm_mm.h     | 14 +++++++++++++-
 2 files changed, 14 insertions(+), 19 deletions(-)

Comments

Joonas Lahtinen Dec. 13, 2016, 12:30 p.m. UTC | #1
On ma, 2016-12-12 at 11:53 +0000, Chris Wilson wrote:
> To test whether there are any nodes allocated within the range manager,
> we merely have to ask whether the node_list is empty.
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

For documentation purposes add "Since commit ..." to the commit
message?

Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>

Regards, Joonas
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_mm.c b/drivers/gpu/drm/drm_mm.c
index 381b4cf75da5..7479b908dd08 100644
--- a/drivers/gpu/drm/drm_mm.c
+++ b/drivers/gpu/drm/drm_mm.c
@@ -871,22 +871,6 @@  bool drm_mm_scan_remove_block(struct drm_mm_node *node)
 EXPORT_SYMBOL(drm_mm_scan_remove_block);
 
 /**
- * drm_mm_clean - checks whether an allocator is clean
- * @mm: drm_mm allocator to check
- *
- * Returns:
- * True if the allocator is completely free, false if there's still a node
- * allocated in it.
- */
-bool drm_mm_clean(const struct drm_mm *mm)
-{
-	const struct list_head *head = __drm_mm_nodes(mm);
-
-	return (head->next->next == head);
-}
-EXPORT_SYMBOL(drm_mm_clean);
-
-/**
  * drm_mm_init - initialize a drm-mm allocator
  * @mm: the drm_mm structure to initialize
  * @start: start of the range managed by @mm
@@ -926,10 +910,9 @@  EXPORT_SYMBOL(drm_mm_init);
  */
 void drm_mm_takedown(struct drm_mm *mm)
 {
-	if (WARN(!list_empty(__drm_mm_nodes(mm)),
+	if (WARN(!drm_mm_clean(mm),
 		 "Memory manager not clean during takedown.\n"))
 		show_leaks(mm);
-
 }
 EXPORT_SYMBOL(drm_mm_takedown);
 
diff --git a/include/drm/drm_mm.h b/include/drm/drm_mm.h
index 66140af0b5c9..4e65a69c3dc4 100644
--- a/include/drm/drm_mm.h
+++ b/include/drm/drm_mm.h
@@ -317,7 +317,19 @@  void drm_mm_remove_node(struct drm_mm_node *node);
 void drm_mm_replace_node(struct drm_mm_node *old, struct drm_mm_node *new);
 void drm_mm_init(struct drm_mm *mm, u64 start, u64 size);
 void drm_mm_takedown(struct drm_mm *mm);
-bool drm_mm_clean(const struct drm_mm *mm);
+
+/**
+ * drm_mm_clean - checks whether an allocator is clean
+ * @mm: drm_mm allocator to check
+ *
+ * Returns:
+ * True if the allocator is completely free, false if there's still a node
+ * allocated in it.
+ */
+static inline bool drm_mm_clean(const struct drm_mm *mm)
+{
+	return list_empty(__drm_mm_nodes(mm));
+}
 
 struct drm_mm_node *
 __drm_mm_interval_first(struct drm_mm *mm, u64 start, u64 last);