]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - drivers/staging/ccree/cc_bitops.h
iio: imu: inv_mpu6050: test whoami first and against all known values
[mirror_ubuntu-artful-kernel.git] / drivers / staging / ccree / cc_bitops.h
CommitLineData
abefd674
GBY
1/*
2 * Copyright (C) 2012-2017 ARM Limited or its affiliates.
c8f17865 3 *
abefd674
GBY
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
c8f17865 7 *
abefd674
GBY
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
c8f17865 12 *
abefd674
GBY
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, see <http://www.gnu.org/licenses/>.
15 */
16
17/*!
18 * \file cc_bitops.h
19 * Bit fields operations macros.
20 */
21#ifndef _CC_BITOPS_H_
22#define _CC_BITOPS_H_
23
24#define BITMASK(mask_size) (((mask_size) < 32) ? \
25 ((1UL << (mask_size)) - 1) : 0xFFFFFFFFUL)
26#define BITMASK_AT(mask_size, mask_offset) (BITMASK(mask_size) << (mask_offset))
27
28#define BITFIELD_GET(word, bit_offset, bit_size) \
29 (((word) >> (bit_offset)) & BITMASK(bit_size))
30#define BITFIELD_SET(word, bit_offset, bit_size, new_val) do { \
31 word = ((word) & ~BITMASK_AT(bit_size, bit_offset)) | \
32 (((new_val) & BITMASK(bit_size)) << (bit_offset)); \
33} while (0)
34
abefd674 35#endif /*_CC_BITOPS_H_*/