diff options
author | Wolfram Sang <wsa+renesas@sang-engineering.com> | 2025-05-02 16:31:35 +0200 |
---|---|---|
committer | Wolfram Sang <wsa+renesas@sang-engineering.com> | 2025-05-02 16:31:35 +0200 |
commit | 8e17493ea2d1c9f72e5e31160f75f8be56f79ffb (patch) | |
tree | 0a3a6fbb8c1ec61bb08a9f612826521b5e15c1d9 /include/linux/file_ref.h | |
parent | 9c32cda43eb78f78c73aee4aa344b777714e259b (diff) | |
parent | b1852c5de2f2a37dd4462f7837c9e3e678f9e546 (diff) |
Merge tag 'i2c-host-fixes-6.15-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux into i2c/for-current
i2c-host-fixes for v6.15-rc5
- imx-lpi2c: fix error handling sequence in probe
Diffstat (limited to 'include/linux/file_ref.h')
-rw-r--r-- | include/linux/file_ref.h | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/include/linux/file_ref.h b/include/linux/file_ref.h index 7db62fbc0500..31551e4cb8f3 100644 --- a/include/linux/file_ref.h +++ b/include/linux/file_ref.h @@ -61,7 +61,6 @@ static inline void file_ref_init(file_ref_t *ref, unsigned long cnt) atomic_long_set(&ref->refcnt, cnt - 1); } -bool __file_ref_put_badval(file_ref_t *ref, unsigned long cnt); bool __file_ref_put(file_ref_t *ref, unsigned long cnt); /** @@ -178,20 +177,14 @@ static __always_inline __must_check bool file_ref_put(file_ref_t *ref) */ static __always_inline __must_check bool file_ref_put_close(file_ref_t *ref) { - long old, new; + long old; old = atomic_long_read(&ref->refcnt); - do { - if (unlikely(old < 0)) - return __file_ref_put_badval(ref, old); - - if (old == FILE_REF_ONEREF) - new = FILE_REF_DEAD; - else - new = old - 1; - } while (!atomic_long_try_cmpxchg(&ref->refcnt, &old, new)); - - return new == FILE_REF_DEAD; + if (likely(old == FILE_REF_ONEREF)) { + if (likely(atomic_long_try_cmpxchg(&ref->refcnt, &old, FILE_REF_DEAD))) + return true; + } + return file_ref_put(ref); } /** |