X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=wrapper%2Fkref.h;h=3f3be7a42d27c0445d7273fc771b5d55dd120248;hb=2e9cb2ea35b4d7f91af714cbddf58b674bbf7b2c;hp=eedefbfe87e96ab47ac79ac0c4a36565c03a47ae;hpb=9c1f4643eb4a11d451a979d81389f0c2ff666af2;p=lttng-modules.git diff --git a/wrapper/kref.h b/wrapper/kref.h index eedefbfe..3f3be7a4 100644 --- a/wrapper/kref.h +++ b/wrapper/kref.h @@ -28,19 +28,24 @@ #include #include +#include /* * lttng_kref_get: get reference count, checking for overflow. * * Return 1 if reference is taken, 0 otherwise (overflow). */ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)) static inline int lttng_kref_get(struct kref *kref) { - if (atomic_add_unless(&kref->refcount, 1, INT_MAX) != INT_MAX) { - return 1; - } else { - return 0; - } + kref_get(kref); + return 1; } +#else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)) */ +static inline int lttng_kref_get(struct kref *kref) +{ + return atomic_add_unless(&kref->refcount, 1, INT_MAX); +} +#endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)) */ #endif /* _LTTNG_WRAPPER_KREF_H */