Re: [PATCH 1/2] dma-buf: add dma_fence_chain_for_each_unwrap helper

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Quoting Christian König (2019-07-30 13:15:53)
> +/**
> + * dma_fence_chain_unwrap - unwrap chain node
> + * @fence: fence which could be a chain node
> + *
> + * If the paramter is a chain node return the cotained fence, otherwise return
> + * the parameter itself.
> + */

s/paramter/parameter/
s/cotained/contained/

> +static inline struct dma_fence *
> +dma_fence_chain_unwrap(struct dma_fence *fence)
> +{
> +       struct dma_fence_chain *chain = to_dma_fence_chain(fence);
> +
> +       if (!chain)
> +               return fence;
> +
> +       return chain->fence;
> +}

> +/**
> + * dma_fence_chain_for_each_unwrap - iterate over all unwrapped fences in chain
> + * @fence: the unwrapped fence
> + * @iter: current fence
> + * @head: starting point
> + *
> + * Iterate over all fences in the chain with unwrapping. We keep a reference to
> + * the current fence while inside the loop which must be dropped when breaking
> + * out.
> + */
> +#define dma_fence_chain_for_each_unwrap(fence, iter, head)     \
> +       for (iter = dma_fence_get(head),                        \
> +            fence = dma_fence_chain_unwrap(iter);              \
> +            iter; iter = dma_fence_chain_walk(iter),           \
> +            fence = dma_fence_chain_unwrap(iter))

Why not
for (iter = dma_fence_get(head);
	(fence = dma_fence_chain_unwrap(iter));
	iter = dma_fence_chain_walk(iter))
? It doesn't look like dma_fence_chain_unwrap() can legally return NULL,
but if you pass NULL to unwrap it returns NULL.

I'd vote for dma_fence_chain_for_each_fence() in the spirit of
list_for_each_entry().
-Chris
_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux