1*c978b524SChris Zankel /* 2*c978b524SChris Zankel * Copyright (C) 2001 - 2012 Tensilica Inc. 3*c978b524SChris Zankel * Copyright (C) 2014 - 2016 Cadence Design Systems Inc. 4*c978b524SChris Zankel * 5*c978b524SChris Zankel * SPDX-License-Identifier: GPL-2.0+ 6*c978b524SChris Zankel */ 7*c978b524SChris Zankel 8*c978b524SChris Zankel #ifndef _XTENSA_BITOPS_H 9*c978b524SChris Zankel #define _XTENSA_BITOPS_H 10*c978b524SChris Zankel 11*c978b524SChris Zankel #include <asm/system.h> 12*c978b524SChris Zankel #include <asm-generic/bitops/fls.h> 13*c978b524SChris Zankel #include <asm-generic/bitops/__fls.h> 14*c978b524SChris Zankel #include <asm-generic/bitops/fls64.h> 15*c978b524SChris Zankel #include <asm-generic/bitops/__ffs.h> 16*c978b524SChris Zankel test_bit(int nr,const void * addr)17*c978b524SChris Zankelstatic inline int test_bit(int nr, const void *addr) 18*c978b524SChris Zankel { 19*c978b524SChris Zankel return ((unsigned char *)addr)[nr >> 3] & (1u << (nr & 7)); 20*c978b524SChris Zankel } 21*c978b524SChris Zankel test_and_set_bit(int nr,volatile void * addr)22*c978b524SChris Zankelstatic inline int test_and_set_bit(int nr, volatile void *addr) 23*c978b524SChris Zankel { 24*c978b524SChris Zankel unsigned long flags; 25*c978b524SChris Zankel unsigned char tmp; 26*c978b524SChris Zankel unsigned char mask = 1u << (nr & 7); 27*c978b524SChris Zankel 28*c978b524SChris Zankel local_irq_save(flags); 29*c978b524SChris Zankel tmp = ((unsigned char *)addr)[nr >> 3]; 30*c978b524SChris Zankel ((unsigned char *)addr)[nr >> 3] |= mask; 31*c978b524SChris Zankel local_irq_restore(flags); 32*c978b524SChris Zankel 33*c978b524SChris Zankel return tmp & mask; 34*c978b524SChris Zankel } 35*c978b524SChris Zankel 36*c978b524SChris Zankel #endif /* _XTENSA_BITOPS_H */ 37