From: Gustavo Padovan <gustavo.padovan@xxxxxxxxxxxxxxx> This functions in intended to replace sync_pt_create() and it does exactly the same thing sync_pt_create() did. Signed-off-by: Gustavo Padovan <gustavo.padovan@xxxxxxxxxxxxxxx> --- drivers/dma-buf/fence.c | 38 ++++++++++++++++++++++++++++++++++++++ drivers/staging/android/sync.c | 20 ++------------------ include/linux/fence.h | 3 +++ 3 files changed, 43 insertions(+), 18 deletions(-) diff --git a/drivers/dma-buf/fence.c b/drivers/dma-buf/fence.c index ec51146..0a07fcb 100644 --- a/drivers/dma-buf/fence.c +++ b/drivers/dma-buf/fence.c @@ -768,6 +768,44 @@ err_free_cb: EXPORT_SYMBOL(fence_wait_any_timeout); /** + * fence_create_on_timeline - create a fence and add it to the timeline + * or until timeout elapses + * @obj: [in] timeline object + * @ops: [in] fence_ops to use + * @size: [in] size to allocate struct fence + * @value: [in] value of this fence + * + * This function allocates a new fence and initialize it as a child of the + * fence_timeline provided. The value received is the seqno used to know + * when the fence is signaled. + * + * Returns NULL if fails to allocate memory or size is too small. + */ +struct fence *fence_create_on_timeline(struct fence_timeline *obj, + const struct fence_ops *ops, int size, + unsigned int value) +{ + unsigned long flags; + struct fence *fence; + + if (size < sizeof(*fence)) + return NULL; + + fence = kzalloc(size, GFP_KERNEL); + if (!fence) + return NULL; + + spin_lock_irqsave(&obj->lock, flags); + fence_timeline_get(obj); + fence_init(fence, ops, &obj->lock, obj->context, value); + list_add_tail(&fence->child_list, &obj->child_list_head); + INIT_LIST_HEAD(&fence->active_list); + spin_unlock_irqrestore(&obj->lock, flags); + return fence; +} +EXPORT_SYMBOL(fence_create_on_timeline); + +/** * fence_init - Initialize a custom fence. * @fence: [in] the fence to initialize * @ops: [in] the fence_ops for operations on this fence diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c index a275108..2365db7 100644 --- a/drivers/staging/android/sync.c +++ b/drivers/staging/android/sync.c @@ -36,24 +36,8 @@ static const struct file_operations sync_fence_fops; struct fence *sync_pt_create(struct fence_timeline *obj, int size, u32 value) { - unsigned long flags; - struct fence *fence; - - if (size < sizeof(*fence)) - return NULL; - - fence = kzalloc(size, GFP_KERNEL); - if (!fence) - return NULL; - - spin_lock_irqsave(&obj->lock, flags); - fence_timeline_get(obj); - fence_init(fence, &sync_fence_ops, &obj->lock, - obj->context, value); - list_add_tail(&fence->child_list, &obj->child_list_head); - INIT_LIST_HEAD(&fence->active_list); - spin_unlock_irqrestore(&obj->lock, flags); - return fence; + return fence_create_on_timeline(obj, &sync_fence_ops, + sizeof(struct fence), value); } EXPORT_SYMBOL(sync_pt_create); diff --git a/include/linux/fence.h b/include/linux/fence.h index 8908433..adece43 100644 --- a/include/linux/fence.h +++ b/include/linux/fence.h @@ -212,6 +212,9 @@ struct fence_ops { void (*timeline_value_str)(struct fence *fence, char *str, int size); }; +struct fence *fence_create_on_timeline(struct fence_timeline *obj, + const struct fence_ops *ops, int size, + unsigned int value); void fence_init(struct fence *fence, const struct fence_ops *ops, spinlock_t *lock, unsigned context, unsigned seqno); -- 2.5.0 _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel