From: Felix Fietkau Date: Sun, 16 Nov 2014 13:39:57 +0000 (+0100) Subject: backports: add GENMASK and GENMASK_ULL X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=8c742cc8e6cdbe2c9d39a036ece86c098db18684;p=openwrt%2Fstaging%2Fblogic.git backports: add GENMASK and GENMASK_ULL I intend to use this for a new driver Signed-off-by: Felix Fietkau Signed-off-by: Hauke Mehrtens --- diff --git a/backport/backport-include/linux/bitops.h b/backport/backport-include/linux/bitops.h new file mode 100644 index 000000000000..b0e9283e93c7 --- /dev/null +++ b/backport/backport-include/linux/bitops.h @@ -0,0 +1,19 @@ +#ifndef __BACKPORT_BITOPS_H +#define __BACKPORT_BITOPS_H +#include_next +#include +#include + +#ifndef GENMASK + +/* + * Create a contiguous bitmask starting at bit position @l and ending at + * position @h. For example + * GENMASK_ULL(39, 21) gives us the 64bit vector 0x000000ffffe00000. + */ +#define GENMASK(h, l) (((U32_C(1) << ((h) - (l) + 1)) - 1) << (l)) +#define GENMASK_ULL(h, l) (((U64_C(1) << ((h) - (l) + 1)) - 1) << (l)) + +#endif + +#endif /* __BACKPORT_BITOPS_H */