[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230330104243.2120761-2-jani.nikula@intel.com>
Date: Thu, 30 Mar 2023 13:42:40 +0300
From: Jani Nikula <jani.nikula@...el.com>
To: linux-kernel@...r.kernel.org
Cc: intel-gfx@...ts.freedesktop.org, dri-devel@...ts.freedesktop.org,
jani.nikula@...el.com, Andrew Morton <akpm@...ux-foundation.org>,
Christian König <christian.koenig@....com>,
David Gow <davidgow@...gle.com>
Subject: [PATCH 1/4] log2: add helper __IS_POWER_OF_2()
Add a helper to avoid duplication in the subsequent changes.
Cc: Andrew Morton <akpm@...ux-foundation.org>
Cc: Christian König <christian.koenig@....com>
Cc: David Gow <davidgow@...gle.com>
Signed-off-by: Jani Nikula <jani.nikula@...el.com>
---
include/linux/log2.h | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/include/linux/log2.h b/include/linux/log2.h
index 9f30d087a128..19e773116ae3 100644
--- a/include/linux/log2.h
+++ b/include/linux/log2.h
@@ -33,6 +33,8 @@ int __ilog2_u64(u64 n)
}
#endif
+#define __IS_POWER_OF_2(n) ((n) != 0 && (((n) & ((n) - 1)) == 0))
+
/**
* is_power_of_2() - check if a value is a power of two
* @n: the value to check
@@ -44,7 +46,7 @@ int __ilog2_u64(u64 n)
static inline __attribute__((const))
bool is_power_of_2(unsigned long n)
{
- return (n != 0 && ((n & (n - 1)) == 0));
+ return __IS_POWER_OF_2(n);
}
/**
--
2.39.2
Powered by blists - more mailing lists