Add inline helper and simplify logic for subword operations in
pci/hive_isp_css_common/host/vmem.c.
Signed-off-by: Adrian Barnaś <abarnas@google.com>
---
.../media/atomisp/pci/hive_isp_css_common/host/vmem.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/media/atomisp/pci/hive_isp_css_common/host/vmem.c b/drivers/staging/media/atomisp/pci/hive_isp_css_common/host/vmem.c
index a3fe03216389..f11b0448ed83 100644
--- a/drivers/staging/media/atomisp/pci/hive_isp_css_common/host/vmem.c
+++ b/drivers/staging/media/atomisp/pci/hive_isp_css_common/host/vmem.c
@@ -15,18 +15,23 @@
/* Copied from SDK: sim_semantics.c */
+static inline unsigned long long subword_bitmask(unsigned int start, unsigned int end)
+{
+ return GENMASK_ULL(end - 1, 0) & ~(GENMASK_ULL(start, 0) >> 1);
+}
+
/* subword bits move like this: MSB[____xxxx____]LSB -> MSB[00000000xxxx]LSB */
static inline unsigned long long
subword(unsigned long long w, unsigned int start, unsigned int end)
{
- return (w & (((1ULL << (end - 1)) - 1) << 1 | 1)) >> start;
+ return (w & GENMASK_ULL(end - 1, 0)) >> start;
}
/* clears subword bits like this: MSB[xxxx____xxxx]LSB -> MSB[xxxx0000xxxx]LSB */
static inline unsigned long long
clear_subword(unsigned long long w, unsigned int start, unsigned int end)
{
- return w & (~(((1ULL << (end - 1)) - 1) << 1 | 1) | ((1ULL << start) - 1));
+ return w & ~subword_bitmask(start, end);
}
#define uedge_bits (8 * sizeof(unsigned long long))
--
2.51.0.355.g5224444f11-goog