From 5b72a540b050d810fd71707f80870fa4626b271c Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sat, 30 Jul 2022 14:46:45 +0200 Subject: [PATCH] ANDROID: restore some removed refcount functions Due to the refcount functions being cleaned up and majorly simplified in 5.4.208, a number of previously exported functions that were part of inline functions were removed and the real functions used instead. As those were part of the Android ABI, restore functions for these "checked" refcount abis so that existing code continues to build properly, while anything that is rebuilt, will be able to take advantage of the new inline functions instead. The functions restored are: refcount_inc_checked refcount_inc_not_zero_checked refcount_dec_checked refcount_dec_and_test_checked Bug: 161946584 Fixes: d0d583484d2e ("locking/refcount: Consolidate implementations of refcount_t") Cc: Will Deacon Signed-off-by: Greg Kroah-Hartman Change-Id: Ic080315ac173da8b374e0e5f2394cf2b6c1c109c --- lib/refcount.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/lib/refcount.c b/lib/refcount.c index ebac8b7d15a7..004a0b3c05c0 100644 --- a/lib/refcount.c +++ b/lib/refcount.c @@ -184,3 +184,32 @@ bool refcount_dec_and_lock_irqsave(refcount_t *r, spinlock_t *lock, return true; } EXPORT_SYMBOL(refcount_dec_and_lock_irqsave); + +/**************************************************************************/ +/* + * Android backport use only, due to these functions going away in 5.4.208 + * Do not use these in new code, this is only for ABI preservation. + */ +void refcount_inc_checked(refcount_t *r) +{ + refcount_inc(r); +} +EXPORT_SYMBOL(refcount_inc_checked); + +bool refcount_inc_not_zero_checked(refcount_t *r) +{ + return refcount_inc_not_zero(r); +} +EXPORT_SYMBOL(refcount_inc_not_zero_checked); + +void refcount_dec_checked(refcount_t *r) +{ + refcount_dec(r); +} +EXPORT_SYMBOL(refcount_dec_checked); + +bool refcount_dec_and_test_checked(refcount_t *r) +{ + return refcount_sub_and_test(1, r); +} +EXPORT_SYMBOL(refcount_dec_and_test_checked);