summaryrefslogtreecommitdiff
path: root/include/linux/dma-fence-chain.h
diff options
context:
space:
mode:
authorChristian König <christian.koenig@amd.com>2022-01-20 13:42:40 +0300
committerChristian König <christian.koenig@amd.com>2022-02-08 11:25:16 +0300
commit18f5fad275efef015226ee4f90eae34d8f44aa5e (patch)
treec8ed7d50c0814c29f1c3abb82054b92a4bf3bcf7 /include/linux/dma-fence-chain.h
parent68129f431faab376c1dd1c701f2fb999eea53383 (diff)
downloadlinux-18f5fad275efef015226ee4f90eae34d8f44aa5e.tar.xz
dma-buf: add dma_fence_chain_contained helper
It's a reoccurring pattern that we need to extract the fence from a dma_fence_chain object. Add a helper for this. Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Thomas Hellström <thomas.hellstrom@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20220204100429.2049-6-christian.koenig@amd.com
Diffstat (limited to 'include/linux/dma-fence-chain.h')
-rw-r--r--include/linux/dma-fence-chain.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/include/linux/dma-fence-chain.h b/include/linux/dma-fence-chain.h
index ee906b659694..10d51bcdf7b7 100644
--- a/include/linux/dma-fence-chain.h
+++ b/include/linux/dma-fence-chain.h
@@ -67,6 +67,21 @@ to_dma_fence_chain(struct dma_fence *fence)
}
/**
+ * dma_fence_chain_contained - return the contained fence
+ * @fence: the fence to test
+ *
+ * If the fence is a dma_fence_chain the function returns the fence contained
+ * inside the chain object, otherwise it returns the fence itself.
+ */
+static inline struct dma_fence *
+dma_fence_chain_contained(struct dma_fence *fence)
+{
+ struct dma_fence_chain *chain = to_dma_fence_chain(fence);
+
+ return chain ? chain->fence : fence;
+}
+
+/**
* dma_fence_chain_alloc
*
* Returns a new struct dma_fence_chain object or NULL on failure.