[PATCH 07/14] drm/ttm: add helper to get buffer object with ttm_mem_reg

Huang, Ray Ray.Huang at amd.com
Wed Sep 11 11:50:25 UTC 2019


This patch is to add a helper to get corresponding buffer object with a pointer
to a struct ttm_mem_reg.

Signed-off-by: Huang Rui <ray.huang at amd.com>
Reviewed-by: Alex Deucher <alexander.deucher at amd.com>
---
 include/drm/ttm/ttm_bo_driver.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index d69121c..264e6c3 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -786,6 +786,19 @@ static inline void ttm_bo_unreserve(struct ttm_buffer_object *bo)
 	reservation_object_unlock(bo->resv);
 }
 
+/**
+ * ttm_mem_reg_to_bo
+ *
+ * @mem: A pointer to a struct ttm_mem_reg.
+ *
+ * Returns corresponding buffer object of the @mem.
+ */
+static inline
+struct ttm_buffer_object *ttm_mem_reg_to_bo(struct ttm_mem_reg *mem)
+{
+	return container_of(mem, struct ttm_buffer_object, mem);
+}
+
 /*
  * ttm_bo_util.c
  */
-- 
2.7.4



More information about the dri-devel mailing list