Changeset View
Changeset View
Standalone View
Standalone View
sys/compat/linuxkpi/common/include/linux/kref.h
Context not available. | |||||
refcount_init(&kref->refcount.counter, 1); | refcount_init(&kref->refcount.counter, 1); | ||||
} | } | ||||
static inline unsigned int | |||||
kref_read(const struct kref *kref) | |||||
{ | |||||
return (atomic_read(&kref->refcount)); | |||||
} | |||||
static inline void | static inline void | ||||
kref_get(struct kref *kref) | kref_get(struct kref *kref) | ||||
{ | { | ||||
Context not available. | |||||
if (refcount_release(&kref->refcount.counter)) { | if (refcount_release(&kref->refcount.counter)) { | ||||
rel(kref); | rel(kref); | ||||
return 1; | return (1); | ||||
} | } | ||||
return 0; | return (0); | ||||
} | } | ||||
static inline int | static inline int | ||||
Context not available. | |||||
while (count--) { | while (count--) { | ||||
if (refcount_release(&kref->refcount.counter)) { | if (refcount_release(&kref->refcount.counter)) { | ||||
rel(kref); | rel(kref); | ||||
return 1; | return (1); | ||||
} | } | ||||
} | } | ||||
return 0; | return (0); | ||||
} | } | ||||
static inline int __must_check | static inline int __must_check | ||||
kref_get_unless_zero(struct kref *kref) | kref_get_unless_zero(struct kref *kref) | ||||
{ | { | ||||
return atomic_add_unless(&kref->refcount, 1, 0); | return (atomic_add_unless(&kref->refcount, 1, 0)); | ||||
} | } | ||||
static inline int kref_put_mutex(struct kref *kref, | static inline int kref_put_mutex(struct kref *kref, | ||||
Context not available. | |||||
mutex_lock(lock); | mutex_lock(lock); | ||||
if (unlikely(!atomic_dec_and_test(&kref->refcount))) { | if (unlikely(!atomic_dec_and_test(&kref->refcount))) { | ||||
mutex_unlock(lock); | mutex_unlock(lock); | ||||
return 0; | return (0); | ||||
} | } | ||||
release(kref); | release(kref); | ||||
return 1; | return (1); | ||||
} | } | ||||
return 0; | return (0); | ||||
} | } | ||||
#endif /* _LINUX_KREF_H_ */ | #endif /* _LINUX_KREF_H_ */ | ||||
Context not available. |