1c942fddfSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */
2b285192aSMauro Carvalho Chehab /*
3b285192aSMauro Carvalho Chehab  *  Driver for the Conexant CX25821 PCIe bridge
4b285192aSMauro Carvalho Chehab  *
5b285192aSMauro Carvalho Chehab  *  Copyright (C) 2009 Conexant Systems Inc.
6b285192aSMauro Carvalho Chehab  *  Authors  <shu.lin@conexant.com>, <hiep.huynh@conexant.com>
7b285192aSMauro Carvalho Chehab  */
8b285192aSMauro Carvalho Chehab 
9b285192aSMauro Carvalho Chehab #ifndef _BITFUNCS_H
10b285192aSMauro Carvalho Chehab #define _BITFUNCS_H
11b285192aSMauro Carvalho Chehab 
12b285192aSMauro Carvalho Chehab #define SetBit(Bit)  (1 << Bit)
13b285192aSMauro Carvalho Chehab 
getBit(u32 sample,u8 index)14dafc456cSMauro Carvalho Chehab static inline u8 getBit(u32 sample, u8 index)
15b285192aSMauro Carvalho Chehab {
16b285192aSMauro Carvalho Chehab 	return (u8) ((sample >> index) & 1);
17b285192aSMauro Carvalho Chehab }
18b285192aSMauro Carvalho Chehab 
clearBitAtPos(u32 value,u8 bit)19dafc456cSMauro Carvalho Chehab static inline u32 clearBitAtPos(u32 value, u8 bit)
20b285192aSMauro Carvalho Chehab {
21b285192aSMauro Carvalho Chehab 	return value & ~(1 << bit);
22b285192aSMauro Carvalho Chehab }
23b285192aSMauro Carvalho Chehab 
setBitAtPos(u32 sample,u8 bit)24dafc456cSMauro Carvalho Chehab static inline u32 setBitAtPos(u32 sample, u8 bit)
25b285192aSMauro Carvalho Chehab {
26b285192aSMauro Carvalho Chehab 	sample |= (1 << bit);
27b285192aSMauro Carvalho Chehab 	return sample;
28b285192aSMauro Carvalho Chehab 
29b285192aSMauro Carvalho Chehab }
30b285192aSMauro Carvalho Chehab 
31b285192aSMauro Carvalho Chehab #endif
32