summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAnup Patel <anup.patel@wdc.com>2020-03-04 08:38:35 +0300
committerAnup Patel <anup@brainfault.org>2020-03-08 08:36:18 +0300
commit00d332bbe726d85e4c2b81ab0a08182612f96c03 (patch)
tree7e0a75570a8b92bff0d74b2141869ce99dd7171a /include
parent8c83fb2fc8ef0c356f291a7e6517dad70a759981 (diff)
downloadopensbi-00d332bbe726d85e4c2b81ab0a08182612f96c03.tar.xz
include: Move bits related defines and macros to sbi_bitops.h
The right location for all bits related defines and macros is sbi_bitops.h hence this patch. With this patch, the sbi_bits.h is redundant so we remove it. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
Diffstat (limited to 'include')
-rw-r--r--include/sbi/riscv_asm.h2
-rw-r--r--include/sbi/sbi_bitops.h19
-rw-r--r--include/sbi/sbi_bits.h19
3 files changed, 17 insertions, 23 deletions
diff --git a/include/sbi/riscv_asm.h b/include/sbi/riscv_asm.h
index c3d5985..63df3fc 100644
--- a/include/sbi/riscv_asm.h
+++ b/include/sbi/riscv_asm.h
@@ -38,7 +38,6 @@
#define LGREG __REG_SEL(3, 2)
#if __SIZEOF_POINTER__ == 8
-#define BITS_PER_LONG 64
#ifdef __ASSEMBLY__
#define RISCV_PTR .dword
#define RISCV_SZPTR 8
@@ -49,7 +48,6 @@
#define RISCV_LGPTR "3"
#endif
#elif __SIZEOF_POINTER__ == 4
-#define BITS_PER_LONG 32
#ifdef __ASSEMBLY__
#define RISCV_PTR .word
#define RISCV_SZPTR 4
diff --git a/include/sbi/sbi_bitops.h b/include/sbi/sbi_bitops.h
index 9d99299..10c29f1 100644
--- a/include/sbi/sbi_bitops.h
+++ b/include/sbi/sbi_bitops.h
@@ -10,8 +10,23 @@
#ifndef __SBI_BITOPS_H__
#define __SBI_BITOPS_H__
-#include <sbi/sbi_bits.h>
-#include <sbi/riscv_asm.h>
+#include <sbi/sbi_types.h>
+
+#if __SIZEOF_POINTER__ == 8
+#define BITS_PER_LONG 64
+#elif __SIZEOF_POINTER__ == 4
+#define BITS_PER_LONG 32
+#else
+#error "Unexpected __SIZEOF_POINTER__"
+#endif
+
+#define EXTRACT_FIELD(val, which) \
+ (((val) & (which)) / ((which) & ~((which)-1)))
+#define INSERT_FIELD(val, which, fieldval) \
+ (((val) & ~(which)) | ((fieldval) * ((which) & ~((which)-1))))
+
+#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG))
+#define BIT_WORD(nr) ((nr) / BITS_PER_LONG)
/**
* ffs - Find first bit set
diff --git a/include/sbi/sbi_bits.h b/include/sbi/sbi_bits.h
deleted file mode 100644
index 3963d84..0000000
--- a/include/sbi/sbi_bits.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2019 Western Digital Corporation or its affiliates.
- *
- * Authors:
- * Anup Patel <anup.patel@wdc.com>
- */
-
-#ifndef __SBI_BITS_H__
-#define __SBI_BITS_H__
-
-#define EXTRACT_FIELD(val, which) (((val) & (which)) / ((which) & ~((which)-1)))
-#define INSERT_FIELD(val, which, fieldval) \
- (((val) & ~(which)) | ((fieldval) * ((which) & ~((which)-1))))
-
-#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG))
-#define BIT_WORD(nr) ((nr) / BITS_PER_LONG)
-#endif