From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH] fixup! include: import Linux word-at-a-time.h
Date: Thu, 23 Nov 2023 09:16:34 +0100 [thread overview]
Message-ID: <20231123081634.1260704-1-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20231122172951.376531-9-a.fatoum@pengutronix.de>
word-at-a-time: include linux/bitops for fls definitions
In Linux, <linux/kernel.h> includes <linux/bitops.h>, which eventually
defines fls/fls64/__fls. In barebox this is not the case, so we need to
explicitly include <linux/bitops.h>.
Also PPC_CNTLZL isn't supported in barebox. Fix that too to avoid
compile errors on PowerPC.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
arch/arm/include/asm/word-at-a-time.h | 1 +
arch/powerpc/include/asm/bitops.h | 1 +
arch/powerpc/include/asm/word-at-a-time.h | 8 +++++++-
arch/riscv/include/asm/word-at-a-time.h | 1 +
4 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/arch/arm/include/asm/word-at-a-time.h b/arch/arm/include/asm/word-at-a-time.h
index f22198a66be3..a2b20be13d07 100644
--- a/arch/arm/include/asm/word-at-a-time.h
+++ b/arch/arm/include/asm/word-at-a-time.h
@@ -8,6 +8,7 @@
#if !defined(__AARCH64EB__) && !defined(__ARMEB__)
#include <linux/kernel.h>
+#include <linux/bitops.h>
struct word_at_a_time {
const unsigned long one_bits, high_bits;
diff --git a/arch/powerpc/include/asm/bitops.h b/arch/powerpc/include/asm/bitops.h
index 543612e6ede3..62b09c7da49c 100644
--- a/arch/powerpc/include/asm/bitops.h
+++ b/arch/powerpc/include/asm/bitops.h
@@ -184,6 +184,7 @@ static inline int ffs(int x)
return __ilog2(x & -x) + 1;
}
+#include <asm-generic/bitops/__fls.h>
#include <asm-generic/bitops/fls64.h>
#include <asm-generic/bitops/hweight.h>
diff --git a/arch/powerpc/include/asm/word-at-a-time.h b/arch/powerpc/include/asm/word-at-a-time.h
index 1de46fbd2e15..029740c6dedf 100644
--- a/arch/powerpc/include/asm/word-at-a-time.h
+++ b/arch/powerpc/include/asm/word-at-a-time.h
@@ -6,6 +6,7 @@
*/
#include <linux/kernel.h>
+#include <linux/bitops.h>
#ifdef __BIG_ENDIAN__
@@ -28,7 +29,12 @@ static inline long find_zero(unsigned long mask)
{
long leading_zero_bits;
- asm (PPC_CNTLZL "%0,%1" : "=r" (leading_zero_bits) : "r" (mask));
+#ifdef __powerpc64__
+ asm ("cntlzd %0,%1" : "=r" (leading_zero_bits) : "r" (mask));
+#else
+ asm ("cntlzw %0,%1" : "=r" (leading_zero_bits) : "r" (mask));
+#endif
+
return leading_zero_bits >> 3;
}
diff --git a/arch/riscv/include/asm/word-at-a-time.h b/arch/riscv/include/asm/word-at-a-time.h
index 7c086ac6ecd4..74f077d38fe0 100644
--- a/arch/riscv/include/asm/word-at-a-time.h
+++ b/arch/riscv/include/asm/word-at-a-time.h
@@ -10,6 +10,7 @@
#include <linux/kernel.h>
+#include <linux/bitops.h>
struct word_at_a_time {
const unsigned long one_bits, high_bits;
--
2.39.2
next prev parent reply other threads:[~2023-11-23 8:18 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-22 17:29 [PATCH v2 00/20] prepare for porting OP-TEE communication support Ahmad Fatoum
2023-11-22 17:29 ` [PATCH v2 01/20] include: provide linux/errno.h Ahmad Fatoum
2023-11-22 17:29 ` [PATCH v2 02/20] include: add linux/refcount.h Ahmad Fatoum
2023-11-22 17:29 ` [PATCH v2 03/20] bitops: split off linux/bits.h Ahmad Fatoum
2023-11-22 17:29 ` [PATCH v2 04/20] include: import <linux/instruction_pointer.h> Ahmad Fatoum
2023-11-22 17:29 ` [PATCH v2 05/20] asm-generic: split off typeconfused readl and friends Ahmad Fatoum
2023-11-22 17:29 ` [PATCH v2 06/20] asm-generic: migrate relaxed helpers into asm-generic/io.h Ahmad Fatoum
2023-11-22 17:29 ` [PATCH v2 07/20] include: add linux/io.h with strict prototypes Ahmad Fatoum
2023-11-22 17:29 ` [PATCH v2 08/20] include: import Linux word-at-a-time.h Ahmad Fatoum
2023-11-23 8:16 ` Ahmad Fatoum [this message]
2023-11-22 17:29 ` [PATCH v2 09/20] string: implement strscpy Ahmad Fatoum
2023-11-22 17:29 ` [PATCH v2 10/20] of: add CONFIG_OF for Linux compatibility Ahmad Fatoum
2023-11-22 17:29 ` [PATCH v2 11/20] include: asm-generic/atomic.h: define atomic_cmpxchg Ahmad Fatoum
2023-11-22 17:29 ` [PATCH v2 12/20] kbuild: build barebox for -std=gnu11 Ahmad Fatoum
2023-11-22 17:29 ` [PATCH v2 13/20] include: linux/idr.h: implement more Linux API Ahmad Fatoum
2023-11-30 20:37 ` Sascha Hauer
2023-11-22 17:29 ` [PATCH v2 14/20] test: self: add simple IDR test Ahmad Fatoum
2023-11-22 17:29 ` [PATCH v2 15/20] include: implement dev_warn_once and friends Ahmad Fatoum
2023-11-22 17:29 ` [PATCH v2 16/20] include: add blocking notifier aliases Ahmad Fatoum
2023-11-22 17:29 ` [PATCH v2 17/20] include: add Linux ktime API Ahmad Fatoum
2023-11-22 17:29 ` [PATCH v2 18/20] of: constify string pointed to by struct of_device_id::compatible Ahmad Fatoum
2023-11-22 17:29 ` [PATCH v2 19/20] of: define of_devices_ensure_probed_by_compatible Ahmad Fatoum
2023-11-22 17:29 ` [PATCH v2 20/20] include: add linux/device.h wrapper around driver.h Ahmad Fatoum
2023-11-23 14:50 ` [PATCH v2 00/20] prepare for porting OP-TEE communication support Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231123081634.1260704-1-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox