void dc_transfer_func_retain(struct dc_transfer_func *tf)
{
- ASSERT(atomic_read(&tf->ref_count) > 0);
- atomic_inc(&tf->ref_count);
+ kref_get(&tf->refcount);
}
-void dc_transfer_func_release(struct dc_transfer_func *tf)
+static void dc_transfer_func_free(struct kref *kref)
{
- ASSERT(atomic_read(&tf->ref_count) > 0);
- atomic_dec(&tf->ref_count);
+ struct dc_transfer_func *tf = container_of(kref, struct dc_transfer_func, refcount);
+ kfree(tf);
+}
- if (atomic_read(&tf->ref_count) == 0)
- kfree(tf);
+void dc_transfer_func_release(struct dc_transfer_func *tf)
+{
+ kref_put(&tf->refcount, dc_transfer_func_free);
}
struct dc_transfer_func *dc_create_transfer_func()
if (tf == NULL)
goto alloc_fail;
- atomic_inc(&tf->ref_count);
+ kref_init(&tf->refcount);
return tf;
};
struct dc_transfer_func {
+ struct kref refcount;
struct dc_transfer_func_distributed_points tf_pts;
enum dc_transfer_func_type type;
enum dc_transfer_func_predefined tf;
struct dc_context *ctx;
- atomic_t ref_count;
};
/*