Commit 4e930a36 authored by Roman Stratiienko's avatar Roman Stratiienko Committed by Jan Kiszka

drivers: net: use atomic_fetch_add_unless() for v4.19 and higher

After changes introduced in kernel v4.19, commit bfc18e389c7a
("atomics/treewide: Rename __atomic_add_unless() => atomic_fetch_add_unless()")
use atomic_fetch_add_unless() function instead of __atomic_add_unless().

Add wrapper for backward compatibility.
Signed-off-by: default avatarRoman Stratiienko <roman.stratiienko@globallogic.com>
Signed-off-by: Jan Kiszka's avatarJan Kiszka <jan.kiszka@siemens.com>
parent 5eb15959
......@@ -52,10 +52,14 @@ DEFINE_MUTEX(rtnet_devices_nrt_lock);
static int rtdev_locked_xmit(struct rtskb *skb, struct rtnet_device *rtdev);
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 19, 0)
#define atomic_fetch_add_unless __atomic_add_unless
#endif
int rtdev_reference(struct rtnet_device *rtdev)
{
smp_mb__before_atomic();
if (rtdev->rt_owner && __atomic_add_unless(&rtdev->refcount, 1, 0) == 0) {
if (rtdev->rt_owner && atomic_fetch_add_unless(&rtdev->refcount, 1, 0) == 0) {
if (!try_module_get(rtdev->rt_owner))
return 0;
if (atomic_inc_return(&rtdev->refcount) != 1)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment