Path: blob/master/ALFA-W1F1/RTL8814AU/os_dep/linux/rtw_rhashtable.c
1307 views
/******************************************************************************1*2* Copyright(c) 2007 - 2017 Realtek Corporation.3*4* This program is free software; you can redistribute it and/or modify it5* under the terms of version 2 of the GNU General Public License as6* published by the Free Software Foundation.7*8* This program is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for11* more details.12*13*****************************************************************************/1415#ifdef CONFIG_RTW_MESH /* for now, only promised for kernel versions we support mesh */1617#include <drv_types.h>1819int rtw_rhashtable_walk_enter(rtw_rhashtable *ht, rtw_rhashtable_iter *iter)20{21#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0))22rhashtable_walk_enter((ht), (iter));23return 0;24#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0))25return rhashtable_walk_init((ht), (iter), GFP_ATOMIC);26#else27/* kernel >= 4.4.0 rhashtable_walk_init use GFP_KERNEL to alloc, spin_lock for assignment */28iter->ht = ht;29iter->p = NULL;30iter->slot = 0;31iter->skip = 0;3233iter->walker = kmalloc(sizeof(*iter->walker), GFP_ATOMIC);34if (!iter->walker)35return -ENOMEM;3637spin_lock(&ht->lock);38iter->walker->tbl =39rcu_dereference_protected(ht->tbl, lockdep_is_held(&ht->lock));40list_add(&iter->walker->list, &iter->walker->tbl->walkers);41spin_unlock(&ht->lock);4243return 0;44#endif45}4647#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0))48#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 15, 0))49#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25))50static inline int is_vmalloc_addr(const void *x)51{52#ifdef CONFIG_MMU53unsigned long addr = (unsigned long)x;5455return addr >= VMALLOC_START && addr < VMALLOC_END;56#else57return 0;58#endif59}60#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25)) */6162void kvfree(const void *addr)63{64if (is_vmalloc_addr(addr))65vfree(addr);66else67kfree(addr);68}69#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3, 15, 0)) */7071#include "rhashtable.c"7273#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0)) */7475#endif /* CONFIG_RTW_MESH */76777879